aotds-docks/.histoire/dist/assets/vendor-3ab3e533.js

39187 lines
1.3 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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

var _a2, _b;
function makeMap(str, expectsLowerCase) {
const map2 = /* @__PURE__ */ Object.create(null);
const list = str.split(",");
for (let i2 = 0; i2 < list.length; i2++) {
map2[list[i2]] = true;
}
return expectsLowerCase ? (val) => !!map2[val.toLowerCase()] : (val) => !!map2[val];
}
function normalizeStyle(value) {
if (isArray$1(value)) {
const res = {};
for (let i2 = 0; i2 < value.length; i2++) {
const item = value[i2];
const normalized = isString$1(item) ? parseStringStyle(item) : normalizeStyle(item);
if (normalized) {
for (const key in normalized) {
res[key] = normalized[key];
}
}
}
return res;
} else if (isString$1(value)) {
return value;
} else if (isObject(value)) {
return value;
}
}
const listDelimiterRE = /;(?![^(]*\))/g;
const propertyDelimiterRE = /:([^]+)/;
const styleCommentRE = /\/\*.*?\*\//gs;
function parseStringStyle(cssText) {
const ret = {};
cssText.replace(styleCommentRE, "").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$1(value)) {
res = value;
} else if (isArray$1(value)) {
for (let i2 = 0; i2 < value.length; i2++) {
const normalized = normalizeClass(value[i2]);
if (normalized) {
res += normalized + " ";
}
}
} else if (isObject(value)) {
for (const name in value) {
if (value[name]) {
res += name + " ";
}
}
}
return res.trim();
}
function normalizeProps(props) {
if (!props)
return null;
let { class: klass, style } = props;
if (klass && !isString$1(klass)) {
props.class = normalizeClass(klass);
}
if (style) {
props.style = normalizeStyle(style);
}
return props;
}
const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
function includeBooleanAttr(value) {
return !!value || value === "";
}
const toDisplayString = (val) => {
return isString$1(val) ? val : val == null ? "" : isArray$1(val) || isObject(val) && (val.toString === objectToString || !isFunction$1(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(val) && !isArray$1(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, el2) => {
const i2 = arr.indexOf(el2);
if (i2 > -1) {
arr.splice(i2, 1);
}
};
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
const isArray$1 = Array.isArray;
const isMap = (val) => toTypeString(val) === "[object Map]";
const isSet = (val) => toTypeString(val) === "[object Set]";
const isFunction$1 = (val) => typeof val === "function";
const isString$1 = (val) => typeof val === "string";
const isSymbol = (val) => typeof val === "symbol";
const isObject = (val) => val !== null && typeof val === "object";
const isPromise = (val) => {
return isObject(val) && isFunction$1(val.then) && isFunction$1(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$1(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
const isReservedProp = /* @__PURE__ */ makeMap(
// the leading comma is intentional so empty string "" is also included
",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 = (fn2) => {
const cache2 = /* @__PURE__ */ Object.create(null);
return (str) => {
const hit = cache2[str];
return hit || (cache2[str] = fn2(str));
};
};
const camelizeRE = /-(\w)/g;
const camelize = cacheStringFunction((str) => {
return str.replace(camelizeRE, (_, 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 = (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 looseToNumber = (val) => {
const n2 = parseFloat(val);
return isNaN(n2) ? val : n2;
};
const toNumber = (val) => {
const n2 = isString$1(val) ? Number(val) : NaN;
return isNaN(n2) ? val : n2;
};
let _globalThis;
const getGlobalThis = () => {
return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
};
function warn$1(msg, ...args) {
console.warn(`[Vue warn] ${msg}`, ...args);
}
let activeEffectScope;
class EffectScope {
constructor(detached = false) {
this.detached = detached;
this._active = true;
this.effects = [];
this.cleanups = [];
this.parent = activeEffectScope;
if (!detached && activeEffectScope) {
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
}
}
get active() {
return this._active;
}
run(fn2) {
if (this._active) {
const currentEffectScope = activeEffectScope;
try {
activeEffectScope = this;
return fn2();
} finally {
activeEffectScope = currentEffectScope;
}
} else {
warn$1(`cannot run an inactive effect scope.`);
}
}
/**
* This should only be called on non-detached scopes
* @internal
*/
on() {
activeEffectScope = this;
}
/**
* This should only be called on non-detached scopes
* @internal
*/
off() {
activeEffectScope = this.parent;
}
stop(fromParent) {
if (this._active) {
let i2, l;
for (i2 = 0, l = this.effects.length; i2 < l; i2++) {
this.effects[i2].stop();
}
for (i2 = 0, l = this.cleanups.length; i2 < l; i2++) {
this.cleanups[i2]();
}
if (this.scopes) {
for (i2 = 0, l = this.scopes.length; i2 < l; i2++) {
this.scopes[i2].stop(true);
}
}
if (!this.detached && this.parent && !fromParent) {
const last = this.parent.scopes.pop();
if (last && last !== this) {
this.parent.scopes[this.index] = last;
last.index = this.index;
}
}
this.parent = void 0;
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(fn2) {
if (activeEffectScope) {
activeEffectScope.cleanups.push(fn2);
} else {
warn$1(`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(fn2, scheduler = null, scope) {
this.fn = fn2;
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$1(target)) {
const newLength = Number(newValue);
depsMap.forEach((dep, key2) => {
if (key2 === "length" || key2 >= newLength) {
deps.push(dep);
}
});
} else {
if (key !== void 0) {
deps.push(depsMap.get(key));
}
switch (type) {
case "add":
if (!isArray$1(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$1(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$1(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();
}
}
}
function getDepFromReactive(object, key) {
var _a3;
return (_a3 = targetMap.get(object)) === null || _a3 === void 0 ? void 0 : _a3.get(key);
}
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, l = this.length; i2 < l; 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 hasOwnProperty(key) {
const obj = toRaw(this);
track(obj, "has", key);
return obj.hasOwnProperty(key);
}
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$1(target);
if (!isReadonly2) {
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
if (key === "hasOwnProperty") {
return hasOwnProperty;
}
}
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(res)) {
return isReadonly2 ? readonly(res) : reactive(res);
}
return res;
};
}
const set$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) {
if (!isShallow$1(value) && !isReadonly(value)) {
oldValue = toRaw(oldValue);
value = toRaw(value);
}
if (!isArray$1(target) && isRef(oldValue) && !isRef(value)) {
oldValue.value = value;
return true;
}
}
const hadKey = isArray$1(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$1(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$1(target) ? "length" : ITERATE_KEY);
return Reflect.ownKeys(target);
}
const mutableHandlers = {
get: get$1,
set: set$1,
deleteProperty,
has: has$1,
ownKeys
};
const readonlyHandlers = {
get: readonlyGet,
set(target, key) {
{
warn$1(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
}
return true;
},
deleteProperty(target, key) {
{
warn$1(`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(target, key, isReadonly2 = false, isShallow2 = false) {
target = target[
"__v_raw"
/* ReactiveFlags.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(key, isReadonly2 = false) {
const target = this[
"__v_raw"
/* ReactiveFlags.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$1(target, isReadonly2 = false) {
target = target[
"__v_raw"
/* ReactiveFlags.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 proto = getProto(target);
const hadKey = proto.has.call(target, value);
if (!hadKey) {
target.add(value);
trigger(target, "add", value, value);
}
return this;
}
function set$2(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"
/* ReactiveFlags.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"
/* ReactiveFlags.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 {
// iterator protocol
next() {
const { value, done } = innerIterator.next();
return done ? { value, done } : {
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
done
};
},
// iterable protocol
[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(this, key);
},
get size() {
return size$1(this);
},
has,
add,
set: set$2,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations2 = {
get(key) {
return get(this, key, false, true);
},
get size() {
return size$1(this);
},
has,
add,
set: set$2,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations2 = {
get(key) {
return get(this, key, true);
},
get size() {
return size$1(this, true);
},
has(key) {
return has.call(this, key, true);
},
add: createReadonlyMethod(
"add"
/* TriggerOpTypes.ADD */
),
set: createReadonlyMethod(
"set"
/* TriggerOpTypes.SET */
),
delete: createReadonlyMethod(
"delete"
/* TriggerOpTypes.DELETE */
),
clear: createReadonlyMethod(
"clear"
/* TriggerOpTypes.CLEAR */
),
forEach: createForEach(true, false)
};
const shallowReadonlyInstrumentations2 = {
get(key) {
return get(this, key, true, true);
},
get size() {
return size$1(this, true);
},
has(key) {
return has.call(this, key, true);
},
add: createReadonlyMethod(
"add"
/* TriggerOpTypes.ADD */
),
set: createReadonlyMethod(
"set"
/* TriggerOpTypes.SET */
),
delete: createReadonlyMethod(
"delete"
/* TriggerOpTypes.DELETE */
),
clear: createReadonlyMethod(
"clear"
/* TriggerOpTypes.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"
/* ReactiveFlags.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(target)) {
{
console.warn(`value cannot be made reactive: ${String(target)}`);
}
return target;
}
if (target[
"__v_raw"
/* ReactiveFlags.RAW */
] && !(isReadonly2 && target[
"__v_isReactive"
/* ReactiveFlags.IS_REACTIVE */
])) {
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"
/* ReactiveFlags.RAW */
]);
}
return !!(value && value[
"__v_isReactive"
/* ReactiveFlags.IS_REACTIVE */
]);
}
function isReadonly(value) {
return !!(value && value[
"__v_isReadonly"
/* ReactiveFlags.IS_READONLY */
]);
}
function isShallow$1(value) {
return !!(value && value[
"__v_isShallow"
/* ReactiveFlags.IS_SHALLOW */
]);
}
function isProxy(value) {
return isReactive(value) || isReadonly(value);
}
function toRaw(observed) {
const raw = observed && observed[
"__v_raw"
/* ReactiveFlags.RAW */
];
return raw ? toRaw(raw) : observed;
}
function markRaw(value) {
def(value, "__v_skip", true);
return value;
}
const toReactive = (value) => isObject(value) ? reactive(value) : value;
const toReadonly = (value) => isObject(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);
const dep = ref2.dep;
if (dep) {
{
triggerEffects(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 shallowRef(value) {
return createRef(value, true);
}
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) {
const useDirectValue = this.__v_isShallow || isShallow$1(newVal) || isReadonly(newVal);
newVal = useDirectValue ? newVal : toRaw(newVal);
if (hasChanged(newVal, this._rawValue)) {
this._rawValue = newVal;
this._value = useDirectValue ? 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);
}
class CustomRefImpl {
constructor(factory) {
this.dep = void 0;
this.__v_isRef = true;
const { get: get2, set: set2 } = factory(() => trackRefValue(this), () => triggerRefValue(this));
this._get = get2;
this._set = set2;
}
get value() {
return this._get();
}
set value(newVal) {
this._set(newVal);
}
}
function customRef(factory) {
return new CustomRefImpl(factory);
}
function toRefs(object) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
}
const ret = isArray$1(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;
}
get dep() {
return getDepFromReactive(toRaw(this._object), this._key);
}
}
function toRef(object, key, defaultValue) {
const val = object[key];
return isRef(val) ? val : new ObjectRefImpl(object, key, defaultValue);
}
var _a$1$1;
class ComputedRefImpl {
constructor(getter, _setter, isReadonly2, isSSR) {
this._setter = _setter;
this.dep = void 0;
this.__v_isRef = true;
this[_a$1$1] = false;
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"
/* ReactiveFlags.IS_READONLY */
] = 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);
}
}
_a$1$1 = "__v_isReadonly";
function computed$1(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = isFunction$1(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$2(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 && // avoid spamming console during tests
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 open2 = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
const close = `>` + postfix;
return vnode.props ? [open2, ...formatProps(vnode.props), close] : [open2 + 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$1(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$1(value)) {
return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
} else {
value = toRaw(value);
return raw ? value : [`${key}=`, value];
}
}
function assertNumber(val, type) {
if (val === void 0) {
return;
} else if (typeof val !== "number") {
warn$2(`${type} is not a valid number - got ${JSON.stringify(val)}.`);
} else if (isNaN(val)) {
warn$2(`${type} is NaN - the duration expression might be incorrect.`);
}
}
const ErrorTypeStrings = {
[
"sp"
/* LifecycleHooks.SERVER_PREFETCH */
]: "serverPrefetch hook",
[
"bc"
/* LifecycleHooks.BEFORE_CREATE */
]: "beforeCreate hook",
[
"c"
/* LifecycleHooks.CREATED */
]: "created hook",
[
"bm"
/* LifecycleHooks.BEFORE_MOUNT */
]: "beforeMount hook",
[
"m"
/* LifecycleHooks.MOUNTED */
]: "mounted hook",
[
"bu"
/* LifecycleHooks.BEFORE_UPDATE */
]: "beforeUpdate hook",
[
"u"
/* LifecycleHooks.UPDATED */
]: "updated",
[
"bum"
/* LifecycleHooks.BEFORE_UNMOUNT */
]: "beforeUnmount hook",
[
"um"
/* LifecycleHooks.UNMOUNTED */
]: "unmounted hook",
[
"a"
/* LifecycleHooks.ACTIVATED */
]: "activated hook",
[
"da"
/* LifecycleHooks.DEACTIVATED */
]: "deactivated hook",
[
"ec"
/* LifecycleHooks.ERROR_CAPTURED */
]: "errorCaptured hook",
[
"rtc"
/* LifecycleHooks.RENDER_TRACKED */
]: "renderTracked hook",
[
"rtg"
/* LifecycleHooks.RENDER_TRIGGERED */
]: "renderTriggered hook",
[
0
/* ErrorCodes.SETUP_FUNCTION */
]: "setup function",
[
1
/* ErrorCodes.RENDER_FUNCTION */
]: "render function",
[
2
/* ErrorCodes.WATCH_GETTER */
]: "watcher getter",
[
3
/* ErrorCodes.WATCH_CALLBACK */
]: "watcher callback",
[
4
/* ErrorCodes.WATCH_CLEANUP */
]: "watcher cleanup function",
[
5
/* ErrorCodes.NATIVE_EVENT_HANDLER */
]: "native event handler",
[
6
/* ErrorCodes.COMPONENT_EVENT_HANDLER */
]: "component event handler",
[
7
/* ErrorCodes.VNODE_HOOK */
]: "vnode hook",
[
8
/* ErrorCodes.DIRECTIVE_HOOK */
]: "directive hook",
[
9
/* ErrorCodes.TRANSITION_HOOK */
]: "transition hook",
[
10
/* ErrorCodes.APP_ERROR_HANDLER */
]: "app errorHandler",
[
11
/* ErrorCodes.APP_WARN_HANDLER */
]: "app warnHandler",
[
12
/* ErrorCodes.FUNCTION_REF */
]: "ref function",
[
13
/* ErrorCodes.ASYNC_COMPONENT_LOADER */
]: "async component loader",
[
14
/* ErrorCodes.SCHEDULER */
]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core"
};
function callWithErrorHandling(fn2, instance, type, args) {
let res;
try {
res = args ? fn2(...args) : fn2();
} catch (err) {
handleError(err, instance, type);
}
return res;
}
function callWithAsyncErrorHandling(fn2, instance, type, args) {
if (isFunction$1(fn2)) {
const res = callWithErrorHandling(fn2, instance, type, args);
if (res && isPromise(res)) {
res.catch((err) => {
handleError(err, instance, type);
});
}
return res;
}
const values = [];
for (let i2 = 0; i2 < fn2.length; i2++) {
values.push(callWithAsyncErrorHandling(fn2[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];
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];
if (contextVNode) {
pushWarningContext(contextVNode);
}
warn$2(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
if (contextVNode) {
popWarningContext();
}
if (throwInDev) {
throw err;
} else {
console.error(err);
}
}
}
let isFlushing = false;
let isFlushPending = false;
const queue = [];
let flushIndex = 0;
const pendingPostFlushCbs = [];
let activePostFlushCbs = null;
let postFlushIndex = 0;
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
let currentFlushPromise = null;
const RECURSION_LIMIT = 100;
function nextTick(fn2) {
const p2 = currentFlushPromise || resolvedPromise;
return fn2 ? p2.then(this ? fn2.bind(this) : fn2) : p2;
}
function findInsertionIndex(id2) {
let start = flushIndex + 1;
let end = queue.length;
while (start < end) {
const middle = start + end >>> 1;
const middleJobId = getId(queue[middle]);
middleJobId < id2 ? start = middle + 1 : end = middle;
}
return start;
}
function queueJob(job) {
if (!queue.length || !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) {
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 invalidateJob(job) {
const i2 = queue.indexOf(job);
if (i2 > flushIndex) {
queue.splice(i2, 1);
}
}
function queuePostFlushCb(cb) {
if (!isArray$1(cb)) {
if (!activePostFlushCbs || !activePostFlushCbs.includes(cb, cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex)) {
pendingPostFlushCbs.push(cb);
}
} else {
pendingPostFlushCbs.push(...cb);
}
queueFlush();
}
function flushPreFlushCbs(seen2, i2 = isFlushing ? flushIndex + 1 : 0) {
{
seen2 = seen2 || /* @__PURE__ */ new Map();
}
for (; i2 < queue.length; i2++) {
const cb = queue[i2];
if (cb && cb.pre) {
if (checkRecursiveUpdates(seen2, cb)) {
continue;
}
queue.splice(i2, 1);
i2--;
cb();
}
}
}
function flushPostFlushCbs(seen2) {
if (pendingPostFlushCbs.length) {
const deduped = [...new Set(pendingPostFlushCbs)];
pendingPostFlushCbs.length = 0;
if (activePostFlushCbs) {
activePostFlushCbs.push(...deduped);
return;
}
activePostFlushCbs = deduped;
{
seen2 = seen2 || /* @__PURE__ */ new Map();
}
activePostFlushCbs.sort((a2, b3) => getId(a2) - getId(b3));
for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
if (checkRecursiveUpdates(seen2, activePostFlushCbs[postFlushIndex])) {
continue;
}
activePostFlushCbs[postFlushIndex]();
}
activePostFlushCbs = null;
postFlushIndex = 0;
}
}
const getId = (job) => job.id == null ? Infinity : job.id;
const comparator = (a2, b3) => {
const diff = getId(a2) - getId(b3);
if (diff === 0) {
if (a2.pre && !b3.pre)
return -1;
if (b3.pre && !a2.pre)
return 1;
}
return diff;
};
function flushJobs(seen2) {
isFlushPending = false;
isFlushing = true;
{
seen2 = seen2 || /* @__PURE__ */ new Map();
}
queue.sort(comparator);
const check = (job) => checkRecursiveUpdates(seen2, 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
/* ErrorCodes.SCHEDULER */
);
}
}
} finally {
flushIndex = 0;
queue.length = 0;
flushPostFlushCbs(seen2);
isFlushing = false;
currentFlushPromise = null;
if (queue.length || pendingPostFlushCbs.length) {
flushJobs(seen2);
}
}
}
function checkRecursiveUpdates(seen2, fn2) {
if (!seen2.has(fn2)) {
seen2.set(fn2, 1);
} else {
const count2 = seen2.get(fn2);
if (count2 > RECURSION_LIMIT) {
const instance = fn2.ownerInstance;
const componentName = instance && getComponentName(instance.type);
warn$2(`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 {
seen2.set(fn2, count2 + 1);
}
}
}
let isHmrUpdating = false;
const hmrDirtyComponents = /* @__PURE__ */ new Set();
{
getGlobalThis().__VUE_HMR_RUNTIME__ = {
createRecord: tryWrap(createRecord),
rerender: tryWrap(rerender),
reload: tryWrap(reload)
};
}
const map = /* @__PURE__ */ new Map();
function registerHMR(instance) {
const id2 = instance.type.__hmrId;
let record = map.get(id2);
if (!record) {
createRecord(id2, instance.type);
record = map.get(id2);
}
record.instances.add(instance);
}
function unregisterHMR(instance) {
map.get(instance.type.__hmrId).instances.delete(instance);
}
function createRecord(id2, initialDef) {
if (map.has(id2)) {
return false;
}
map.set(id2, {
initialDef: normalizeClassComponent(initialDef),
instances: /* @__PURE__ */ new Set()
});
return true;
}
function normalizeClassComponent(component) {
return isClassComponent(component) ? component.__vccOpts : component;
}
function rerender(id2, newRender) {
const record = map.get(id2);
if (!record) {
return;
}
record.initialDef.render = newRender;
[...record.instances].forEach((instance) => {
if (newRender) {
instance.render = newRender;
normalizeClassComponent(instance.type).render = newRender;
}
instance.renderCache = [];
isHmrUpdating = true;
instance.update();
isHmrUpdating = false;
});
}
function reload(id2, newComp) {
const record = map.get(id2);
if (!record)
return;
newComp = normalizeClassComponent(newComp);
updateComponentDef(record.initialDef, newComp);
const instances = [...record.instances];
for (const instance of instances) {
const oldComp = normalizeClassComponent(instance.type);
if (!hmrDirtyComponents.has(oldComp)) {
if (oldComp !== record.initialDef) {
updateComponentDef(oldComp, newComp);
}
hmrDirtyComponents.add(oldComp);
}
instance.appContext.optionsCache.delete(instance.type);
if (instance.ceReload) {
hmrDirtyComponents.add(oldComp);
instance.ceReload(newComp.styles);
hmrDirtyComponents.delete(oldComp);
} else if (instance.parent) {
queueJob(instance.parent.update);
} else if (instance.appContext.reload) {
instance.appContext.reload();
} else if (typeof window !== "undefined") {
window.location.reload();
} else {
console.warn("[HMR] Root or manually mounted instance modified. Full reload required.");
}
}
queuePostFlushCb(() => {
for (const instance of instances) {
hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
}
});
}
function updateComponentDef(oldComp, newComp) {
extend(oldComp, newComp);
for (const key in oldComp) {
if (key !== "__file" && !(key in newComp)) {
delete oldComp[key];
}
}
}
function tryWrap(fn2) {
return (id2, arg) => {
try {
return fn2(id2, arg);
} catch (e2) {
console.error(e2);
console.warn(`[HMR] Something went wrong during Vue component hot-reload. Full reload required.`);
}
};
}
let devtools;
let buffer = [];
let devtoolsNotInstalled = false;
function emit$1(event, ...args) {
if (devtools) {
devtools.emit(event, ...args);
} else if (!devtoolsNotInstalled) {
buffer.push({ event, args });
}
}
function setDevtoolsHook(hook, target) {
var _a3, _b2;
devtools = hook;
if (devtools) {
devtools.enabled = true;
buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
buffer = [];
} else if (
// handle late devtools injection - only do this if we are in an actual
// browser environment to avoid the timer handle stalling test runner exit
// (#4815)
typeof window !== "undefined" && // some envs mock window but not fully
window.HTMLElement && // also exclude jsdom
!((_b2 = (_a3 = window.navigator) === null || _a3 === void 0 ? void 0 : _a3.userAgent) === null || _b2 === void 0 ? void 0 : _b2.includes("jsdom"))
) {
const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
replay.push((newHook) => {
setDevtoolsHook(newHook, target);
});
setTimeout(() => {
if (!devtools) {
target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
devtoolsNotInstalled = true;
buffer = [];
}
}, 3e3);
} else {
devtoolsNotInstalled = true;
buffer = [];
}
}
function devtoolsInitApp(app, version2) {
emit$1("app:init", app, version2, {
Fragment,
Text,
Comment,
Static
});
}
function devtoolsUnmountApp(app) {
emit$1("app:unmount", app);
}
const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook(
"component:added"
/* DevtoolsHooks.COMPONENT_ADDED */
);
const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook(
"component:updated"
/* DevtoolsHooks.COMPONENT_UPDATED */
);
const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
"component:removed"
/* DevtoolsHooks.COMPONENT_REMOVED */
);
const devtoolsComponentRemoved = (component) => {
if (devtools && typeof devtools.cleanupBuffer === "function" && // remove the component if it wasn't buffered
!devtools.cleanupBuffer(component)) {
_devtoolsComponentRemoved(component);
}
};
function createDevtoolsComponentHook(hook) {
return (component) => {
emit$1(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : void 0, component);
};
}
const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook(
"perf:start"
/* DevtoolsHooks.PERFORMANCE_START */
);
const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook(
"perf:end"
/* DevtoolsHooks.PERFORMANCE_END */
);
function createDevtoolsPerformanceHook(hook) {
return (component, type, time) => {
emit$1(hook, component.appContext.app, component.uid, component, type, time);
};
}
function devtoolsComponentEmit(component, event, params) {
emit$1("component:emit", component.appContext.app, component, event, params);
}
function emit(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$2(`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$1(validator)) {
const isValid = validator(...rawArgs);
if (!isValid) {
warn$2(`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) => isString$1(a2) ? a2.trim() : a2);
}
if (number) {
args = rawArgs.map(looseToNumber);
}
}
{
devtoolsComponentEmit(instance, event, args);
}
{
const lowerCaseEvent = event.toLowerCase();
if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
warn$2(`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)] || // also try camelCase event handler (#2249)
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 cache2 = appContext.emitsCache;
const cached = cache2.get(comp);
if (cached !== void 0) {
return cached;
}
const raw = comp.emits;
let normalized = {};
let hasExtends = false;
if (!isFunction$1(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) {
if (isObject(comp)) {
cache2.set(comp, null);
}
return null;
}
if (isArray$1(raw)) {
raw.forEach((key) => normalized[key] = null);
} else {
extend(normalized, raw);
}
if (isObject(comp)) {
cache2.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;
let currentScopeId = null;
function setCurrentRenderingInstance(instance) {
const prev = currentRenderingInstance;
currentRenderingInstance = instance;
currentScopeId = instance && instance.type.__scopeId || null;
return prev;
}
function pushScopeId(id2) {
currentScopeId = id2;
}
function popScopeId() {
currentScopeId = null;
}
const withScopeId = (_id) => withCtx;
function withCtx(fn2, ctx = currentRenderingInstance, isNonScopedSlot) {
if (!ctx)
return fn2;
if (fn2._n) {
return fn2;
}
const renderFnWithContext = (...args) => {
if (renderFnWithContext._d) {
setBlockTracking(-1);
}
const prevInstance = setCurrentRenderingInstance(ctx);
let res;
try {
res = fn2(...args);
} finally {
setCurrentRenderingInstance(prevInstance);
if (renderFnWithContext._d) {
setBlockTracking(1);
}
}
{
devtoolsComponentUpdated(ctx);
}
return res;
};
renderFnWithContext._n = true;
renderFnWithContext._c = true;
renderFnWithContext._d = true;
return renderFnWithContext;
}
let accessedAttrs = false;
function markAttrsAccessed() {
accessedAttrs = true;
}
function renderComponentRoot(instance) {
const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit: emit2, render: render2, renderCache, data, setupState, ctx, inheritAttrs } = instance;
let result;
let fallthroughAttrs;
const prev = setCurrentRenderingInstance(instance);
{
accessedAttrs = false;
}
try {
if (vnode.shapeFlag & 4) {
const proxyToUse = withProxy || proxy;
result = normalizeVNode(render2.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
fallthroughAttrs = attrs;
} else {
const render3 = Component;
if (attrs === props) {
markAttrsAccessed();
}
result = normalizeVNode(render3.length > 1 ? render3(props, true ? {
get attrs() {
markAttrsAccessed();
return attrs;
},
slots,
emit: emit2
} : { attrs, slots, emit: emit2 }) : render3(
props,
null
/* we know it doesn't need it */
));
fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
}
} catch (err) {
blockStack.length = 0;
handleError(
err,
instance,
1
/* ErrorCodes.RENDER_FUNCTION */
);
result = createVNode(Comment);
}
let root = result;
let setRoot = void 0;
if (result.patchFlag > 0 && result.patchFlag & 2048) {
[root, setRoot] = getChildRoot(result);
}
if (fallthroughAttrs && inheritAttrs !== false) {
const keys = Object.keys(fallthroughAttrs);
const { shapeFlag } = root;
if (keys.length) {
if (shapeFlag & (1 | 6)) {
if (propsOptions && keys.some(isModelListener)) {
fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
}
root = cloneVNode(root, fallthroughAttrs);
} else if (!accessedAttrs && root.type !== Comment) {
const allAttrs = Object.keys(attrs);
const eventAttrs = [];
const extraAttrs = [];
for (let i2 = 0, l = allAttrs.length; i2 < l; i2++) {
const key = allAttrs[i2];
if (isOn(key)) {
if (!isModelListener(key)) {
eventAttrs.push(key[2].toLowerCase() + key.slice(3));
}
} else {
extraAttrs.push(key);
}
}
if (extraAttrs.length) {
warn$2(`Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`);
}
if (eventAttrs.length) {
warn$2(`Extraneous non-emits event listeners (${eventAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`);
}
}
}
}
if (vnode.dirs) {
if (!isElementRoot(root)) {
warn$2(`Runtime directive used on component with non-element root node. The directives will not function as intended.`);
}
root = cloneVNode(root);
root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
}
if (vnode.transition) {
if (!isElementRoot(root)) {
warn$2(`Component inside <Transition> renders non-element root node that cannot be animated.`);
}
root.transition = vnode.transition;
}
if (setRoot) {
setRoot(root);
} else {
result = root;
}
setCurrentRenderingInstance(prev);
return result;
}
const getChildRoot = (vnode) => {
const rawChildren = vnode.children;
const dynamicChildren = vnode.dynamicChildren;
const childRoot = filterSingleRoot(rawChildren);
if (!childRoot) {
return [vnode, void 0];
}
const index2 = rawChildren.indexOf(childRoot);
const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
const setRoot = (updatedRoot) => {
rawChildren[index2] = updatedRoot;
if (dynamicChildren) {
if (dynamicIndex > -1) {
dynamicChildren[dynamicIndex] = updatedRoot;
} else if (updatedRoot.patchFlag > 0) {
vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
}
}
};
return [normalizeVNode(childRoot), setRoot];
};
function filterSingleRoot(children2) {
let singleRoot;
for (let i2 = 0; i2 < children2.length; i2++) {
const child = children2[i2];
if (isVNode(child)) {
if (child.type !== Comment || child.children === "v-if") {
if (singleRoot) {
return;
} else {
singleRoot = child;
}
}
} else {
return;
}
}
return singleRoot;
}
const getFunctionalFallthrough = (attrs) => {
let res;
for (const key in attrs) {
if (key === "class" || key === "style" || isOn(key)) {
(res || (res = {}))[key] = attrs[key];
}
}
return res;
};
const filterModelListeners = (attrs, props) => {
const res = {};
for (const key in attrs) {
if (!isModelListener(key) || !(key.slice(9) in props)) {
res[key] = attrs[key];
}
}
return res;
};
const isElementRoot = (vnode) => {
return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
};
function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
const { props: prevProps, children: prevChildren, component } = prevVNode;
const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
const emits = component.emitsOptions;
if ((prevChildren || nextChildren) && isHmrUpdating) {
return true;
}
if (nextVNode.dirs || nextVNode.transition) {
return true;
}
if (optimized && patchFlag >= 0) {
if (patchFlag & 1024) {
return true;
}
if (patchFlag & 16) {
if (!prevProps) {
return !!nextProps;
}
return hasPropsChanged(prevProps, nextProps, emits);
} else if (patchFlag & 8) {
const dynamicProps = nextVNode.dynamicProps;
for (let i2 = 0; i2 < dynamicProps.length; i2++) {
const key = dynamicProps[i2];
if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
return true;
}
}
}
} else {
if (prevChildren || nextChildren) {
if (!nextChildren || !nextChildren.$stable) {
return true;
}
}
if (prevProps === nextProps) {
return false;
}
if (!prevProps) {
return !!nextProps;
}
if (!nextProps) {
return true;
}
return hasPropsChanged(prevProps, nextProps, emits);
}
return false;
}
function hasPropsChanged(prevProps, nextProps, emitsOptions) {
const nextKeys = Object.keys(nextProps);
if (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] && !isEmitListener(emitsOptions, key)) {
return true;
}
}
return false;
}
function updateHOCHostEl({ vnode, parent }, el2) {
while (parent && parent.subTree === vnode) {
(vnode = parent.vnode).el = el2;
parent = parent.parent;
}
}
const isSuspense = (type) => type.__isSuspense;
function queueEffectWithSuspense(fn2, suspense) {
if (suspense && suspense.pendingBranch) {
if (isArray$1(fn2)) {
suspense.effects.push(...fn2);
} else {
suspense.effects.push(fn2);
}
} else {
queuePostFlushCb(fn2);
}
}
function provide(key, value) {
if (!currentInstance) {
{
warn$2(`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;
}
}
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$1(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;
} else {
warn$2(`injection "${String(key)}" not found.`);
}
} else {
warn$2(`inject() can only be used inside setup() or functional components.`);
}
}
function watchEffect(effect, options) {
return doWatch(effect, null, options);
}
function watchPostEffect(effect, options) {
return doWatch(effect, null, Object.assign(Object.assign({}, options), { flush: "post" }));
}
const INITIAL_WATCHER_VALUE = {};
function watch(source, cb, options) {
if (!isFunction$1(cb)) {
warn$2(`\`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: flush2, onTrack, onTrigger } = EMPTY_OBJ) {
if (!cb) {
if (immediate !== void 0) {
warn$2(`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`);
}
if (deep !== void 0) {
warn$2(`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`);
}
}
const warnInvalidSource = (s) => {
warn$2(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`);
};
const instance = getCurrentScope() === (currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope) ? currentInstance : null;
let getter;
let forceTrigger = false;
let isMultiSource = false;
if (isRef(source)) {
getter = () => source.value;
forceTrigger = isShallow$1(source);
} else if (isReactive(source)) {
getter = () => source;
deep = true;
} else if (isArray$1(source)) {
isMultiSource = true;
forceTrigger = source.some((s) => isReactive(s) || isShallow$1(s));
getter = () => source.map((s) => {
if (isRef(s)) {
return s.value;
} else if (isReactive(s)) {
return traverse(s);
} else if (isFunction$1(s)) {
return callWithErrorHandling(
s,
instance,
2
/* ErrorCodes.WATCH_GETTER */
);
} else {
warnInvalidSource(s);
}
});
} else if (isFunction$1(source)) {
if (cb) {
getter = () => callWithErrorHandling(
source,
instance,
2
/* ErrorCodes.WATCH_GETTER */
);
} 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 = (fn2) => {
cleanup = effect.onStop = () => {
callWithErrorHandling(
fn2,
instance,
4
/* ErrorCodes.WATCH_CLEANUP */
);
};
};
let ssrCleanup;
if (isInSSRComponentSetup) {
onCleanup = NOOP;
if (!cb) {
getter();
} else if (immediate) {
callWithAsyncErrorHandling(cb, instance, 3, [
getter(),
isMultiSource ? [] : void 0,
onCleanup
]);
}
if (flush2 === "sync") {
const ctx = useSSRContext();
ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
} else {
return NOOP;
}
}
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : 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,
// pass undefined as the old value when it's changed for the first time
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
onCleanup
]);
oldValue = newValue;
}
} else {
effect.run();
}
};
job.allowRecurse = !!cb;
let scheduler;
if (flush2 === "sync") {
scheduler = job;
} else if (flush2 === "post") {
scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
} else {
job.pre = true;
if (instance)
job.id = instance.uid;
scheduler = () => queueJob(job);
}
const effect = new ReactiveEffect(getter, scheduler);
{
effect.onTrack = onTrack;
effect.onTrigger = onTrigger;
}
if (cb) {
if (immediate) {
job();
} else {
oldValue = effect.run();
}
} else if (flush2 === "post") {
queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
} else {
effect.run();
}
const unwatch = () => {
effect.stop();
if (instance && instance.scope) {
remove(instance.scope.effects, effect);
}
};
if (ssrCleanup)
ssrCleanup.push(unwatch);
return unwatch;
}
function instanceWatch(source, value, options) {
const publicThis = this.proxy;
const getter = isString$1(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
let cb;
if (isFunction$1(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, seen2) {
if (!isObject(value) || value[
"__v_skip"
/* ReactiveFlags.SKIP */
]) {
return value;
}
seen2 = seen2 || /* @__PURE__ */ new Set();
if (seen2.has(value)) {
return value;
}
seen2.add(value);
if (isRef(value)) {
traverse(value.value, seen2);
} else if (isArray$1(value)) {
for (let i2 = 0; i2 < value.length; i2++) {
traverse(value[i2], seen2);
}
} else if (isSet(value) || isMap(value)) {
value.forEach((v2) => {
traverse(v2, seen2);
});
} else if (isPlainObject$1(value)) {
for (const key in value) {
traverse(value[key], seen2);
}
}
return value;
}
function useTransitionState() {
const state = {
isMounted: false,
isLeaving: false,
isUnmounting: false,
leavingVNodes: /* @__PURE__ */ new Map()
};
onMounted(() => {
state.isMounted = true;
});
onBeforeUnmount(() => {
state.isUnmounting = true;
});
return state;
}
const TransitionHookValidator = [Function, Array];
const BaseTransitionImpl = {
name: `BaseTransition`,
props: {
mode: String,
appear: Boolean,
persisted: Boolean,
// enter
onBeforeEnter: TransitionHookValidator,
onEnter: TransitionHookValidator,
onAfterEnter: TransitionHookValidator,
onEnterCancelled: TransitionHookValidator,
// leave
onBeforeLeave: TransitionHookValidator,
onLeave: TransitionHookValidator,
onAfterLeave: TransitionHookValidator,
onLeaveCancelled: TransitionHookValidator,
// appear
onBeforeAppear: TransitionHookValidator,
onAppear: TransitionHookValidator,
onAfterAppear: TransitionHookValidator,
onAppearCancelled: TransitionHookValidator
},
setup(props, { slots }) {
const instance = getCurrentInstance();
const state = useTransitionState();
let prevTransitionKey;
return () => {
const children2 = slots.default && getTransitionRawChildren(slots.default(), true);
if (!children2 || !children2.length) {
return;
}
let child = children2[0];
if (children2.length > 1) {
let hasFound = false;
for (const c2 of children2) {
if (c2.type !== Comment) {
if (hasFound) {
warn$2("<transition> can only be used on a single element or component. Use <transition-group> for lists.");
break;
}
child = c2;
hasFound = true;
}
}
}
const rawProps = toRaw(props);
const { mode } = rawProps;
if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
warn$2(`invalid <transition> mode: ${mode}`);
}
if (state.isLeaving) {
return emptyPlaceholder(child);
}
const innerChild = getKeepAliveChild(child);
if (!innerChild) {
return emptyPlaceholder(child);
}
const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
setTransitionHooks(innerChild, enterHooks);
const oldChild = instance.subTree;
const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
let transitionKeyChanged = false;
const { getTransitionKey } = innerChild.type;
if (getTransitionKey) {
const key = getTransitionKey();
if (prevTransitionKey === void 0) {
prevTransitionKey = key;
} else if (key !== prevTransitionKey) {
prevTransitionKey = key;
transitionKeyChanged = true;
}
}
if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
setTransitionHooks(oldInnerChild, leavingHooks);
if (mode === "out-in") {
state.isLeaving = true;
leavingHooks.afterLeave = () => {
state.isLeaving = false;
if (instance.update.active !== false) {
instance.update();
}
};
return emptyPlaceholder(child);
} else if (mode === "in-out" && innerChild.type !== Comment) {
leavingHooks.delayLeave = (el2, earlyRemove, delayedLeave) => {
const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
el2._leaveCb = () => {
earlyRemove();
el2._leaveCb = void 0;
delete enterHooks.delayedLeave;
};
enterHooks.delayedLeave = delayedLeave;
};
}
}
return child;
};
}
};
const BaseTransition = BaseTransitionImpl;
function getLeavingNodesForType(state, vnode) {
const { leavingVNodes } = state;
let leavingVNodesCache = leavingVNodes.get(vnode.type);
if (!leavingVNodesCache) {
leavingVNodesCache = /* @__PURE__ */ Object.create(null);
leavingVNodes.set(vnode.type, leavingVNodesCache);
}
return leavingVNodesCache;
}
function resolveTransitionHooks(vnode, props, state, instance) {
const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
const key = String(vnode.key);
const leavingVNodesCache = getLeavingNodesForType(state, vnode);
const callHook2 = (hook, args) => {
hook && callWithAsyncErrorHandling(hook, instance, 9, args);
};
const callAsyncHook = (hook, args) => {
const done = args[1];
callHook2(hook, args);
if (isArray$1(hook)) {
if (hook.every((hook2) => hook2.length <= 1))
done();
} else if (hook.length <= 1) {
done();
}
};
const hooks = {
mode,
persisted,
beforeEnter(el2) {
let hook = onBeforeEnter;
if (!state.isMounted) {
if (appear) {
hook = onBeforeAppear || onBeforeEnter;
} else {
return;
}
}
if (el2._leaveCb) {
el2._leaveCb(
true
/* cancelled */
);
}
const leavingVNode = leavingVNodesCache[key];
if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el._leaveCb) {
leavingVNode.el._leaveCb();
}
callHook2(hook, [el2]);
},
enter(el2) {
let hook = onEnter;
let afterHook = onAfterEnter;
let cancelHook = onEnterCancelled;
if (!state.isMounted) {
if (appear) {
hook = onAppear || onEnter;
afterHook = onAfterAppear || onAfterEnter;
cancelHook = onAppearCancelled || onEnterCancelled;
} else {
return;
}
}
let called = false;
const done = el2._enterCb = (cancelled) => {
if (called)
return;
called = true;
if (cancelled) {
callHook2(cancelHook, [el2]);
} else {
callHook2(afterHook, [el2]);
}
if (hooks.delayedLeave) {
hooks.delayedLeave();
}
el2._enterCb = void 0;
};
if (hook) {
callAsyncHook(hook, [el2, done]);
} else {
done();
}
},
leave(el2, remove2) {
const key2 = String(vnode.key);
if (el2._enterCb) {
el2._enterCb(
true
/* cancelled */
);
}
if (state.isUnmounting) {
return remove2();
}
callHook2(onBeforeLeave, [el2]);
let called = false;
const done = el2._leaveCb = (cancelled) => {
if (called)
return;
called = true;
remove2();
if (cancelled) {
callHook2(onLeaveCancelled, [el2]);
} else {
callHook2(onAfterLeave, [el2]);
}
el2._leaveCb = void 0;
if (leavingVNodesCache[key2] === vnode) {
delete leavingVNodesCache[key2];
}
};
leavingVNodesCache[key2] = vnode;
if (onLeave) {
callAsyncHook(onLeave, [el2, done]);
} else {
done();
}
},
clone(vnode2) {
return resolveTransitionHooks(vnode2, props, state, instance);
}
};
return hooks;
}
function emptyPlaceholder(vnode) {
if (isKeepAlive(vnode)) {
vnode = cloneVNode(vnode);
vnode.children = null;
return vnode;
}
}
function getKeepAliveChild(vnode) {
return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
}
function setTransitionHooks(vnode, hooks) {
if (vnode.shapeFlag & 6 && vnode.component) {
setTransitionHooks(vnode.component.subTree, hooks);
} else if (vnode.shapeFlag & 128) {
vnode.ssContent.transition = hooks.clone(vnode.ssContent);
vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
} else {
vnode.transition = hooks;
}
}
function getTransitionRawChildren(children2, keepComment = false, parentKey) {
let ret = [];
let keyedFragmentCount = 0;
for (let i2 = 0; i2 < children2.length; i2++) {
let child = children2[i2];
const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i2);
if (child.type === Fragment) {
if (child.patchFlag & 128)
keyedFragmentCount++;
ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
} else if (keepComment || child.type !== Comment) {
ret.push(key != null ? cloneVNode(child, { key }) : child);
}
}
if (keyedFragmentCount > 1) {
for (let i2 = 0; i2 < ret.length; i2++) {
ret[i2].patchFlag = -2;
}
}
return ret;
}
function defineComponent(options) {
return isFunction$1(options) ? { setup: options, name: options.name } : options;
}
const isAsyncWrapper = (i2) => !!i2.type.__asyncLoader;
function defineAsyncComponent(source) {
if (isFunction$1(source)) {
source = { loader: source };
}
const {
loader,
loadingComponent,
errorComponent,
delay = 200,
timeout,
// undefined = never times out
suspensible = true,
onError: userOnError
} = source;
let pendingRequest = null;
let resolvedComp;
let retries = 0;
const retry = () => {
retries++;
pendingRequest = null;
return load();
};
const load = () => {
let thisRequest;
return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
err = err instanceof Error ? err : new Error(String(err));
if (userOnError) {
return new Promise((resolve2, reject) => {
const userRetry = () => resolve2(retry());
const userFail = () => reject(err);
userOnError(err, userRetry, userFail, retries + 1);
});
} else {
throw err;
}
}).then((comp) => {
if (thisRequest !== pendingRequest && pendingRequest) {
return pendingRequest;
}
if (!comp) {
warn$2(`Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`);
}
if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
comp = comp.default;
}
if (comp && !isObject(comp) && !isFunction$1(comp)) {
throw new Error(`Invalid async component load result: ${comp}`);
}
resolvedComp = comp;
return comp;
}));
};
return defineComponent({
name: "AsyncComponentWrapper",
__asyncLoader: load,
get __asyncResolved() {
return resolvedComp;
},
setup() {
const instance = currentInstance;
if (resolvedComp) {
return () => createInnerComp(resolvedComp, instance);
}
const onError = (err) => {
pendingRequest = null;
handleError(
err,
instance,
13,
!errorComponent
/* do not throw in dev if user provided error component */
);
};
if (suspensible && instance.suspense || isInSSRComponentSetup) {
return load().then((comp) => {
return () => createInnerComp(comp, instance);
}).catch((err) => {
onError(err);
return () => errorComponent ? createVNode(errorComponent, {
error: err
}) : null;
});
}
const loaded2 = ref(false);
const error = ref();
const delayed = ref(!!delay);
if (delay) {
setTimeout(() => {
delayed.value = false;
}, delay);
}
if (timeout != null) {
setTimeout(() => {
if (!loaded2.value && !error.value) {
const err = new Error(`Async component timed out after ${timeout}ms.`);
onError(err);
error.value = err;
}
}, timeout);
}
load().then(() => {
loaded2.value = true;
if (instance.parent && isKeepAlive(instance.parent.vnode)) {
queueJob(instance.parent.update);
}
}).catch((err) => {
onError(err);
error.value = err;
});
return () => {
if (loaded2.value && resolvedComp) {
return createInnerComp(resolvedComp, instance);
} else if (error.value && errorComponent) {
return createVNode(errorComponent, {
error: error.value
});
} else if (loadingComponent && !delayed.value) {
return createVNode(loadingComponent);
}
};
}
});
}
function createInnerComp(comp, parent) {
const { ref: ref2, props, children: children2, ce: ce2 } = parent.vnode;
const vnode = createVNode(comp, props, children2);
vnode.ref = ref2;
vnode.ce = ce2;
delete parent.vnode.ce;
return vnode;
}
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
/* prepend */
);
onUnmounted(() => {
remove(keepAliveRoot[type], injected);
}, target);
}
function injectHook(type, hook, target = currentInstance, prepend = false) {
if (target) {
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].replace(/ hook$/, ""));
warn$2(`${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(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`);
}
}
const createHook = (lifecycle) => (hook, target = currentInstance) => (
// post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
(!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target)
);
const onBeforeMount = createHook(
"bm"
/* LifecycleHooks.BEFORE_MOUNT */
);
const onMounted = createHook(
"m"
/* LifecycleHooks.MOUNTED */
);
const onBeforeUpdate = createHook(
"bu"
/* LifecycleHooks.BEFORE_UPDATE */
);
const onUpdated = createHook(
"u"
/* LifecycleHooks.UPDATED */
);
const onBeforeUnmount = createHook(
"bum"
/* LifecycleHooks.BEFORE_UNMOUNT */
);
const onUnmounted = createHook(
"um"
/* LifecycleHooks.UNMOUNTED */
);
const onServerPrefetch = createHook(
"sp"
/* LifecycleHooks.SERVER_PREFETCH */
);
const onRenderTriggered = createHook(
"rtg"
/* LifecycleHooks.RENDER_TRIGGERED */
);
const onRenderTracked = createHook(
"rtc"
/* LifecycleHooks.RENDER_TRACKED */
);
function onErrorCaptured(hook, target = currentInstance) {
injectHook("ec", hook, target);
}
function validateDirectiveName(name) {
if (isBuiltInDirective(name)) {
warn$2("Do not use built-in directive ids as custom directive id: " + name);
}
}
function withDirectives(vnode, directives2) {
const internalInstance = currentRenderingInstance;
if (internalInstance === null) {
warn$2(`withDirectives can only be used inside render functions.`);
return vnode;
}
const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
const bindings = vnode.dirs || (vnode.dirs = []);
for (let i2 = 0; i2 < directives2.length; i2++) {
let [dir, value, arg, modifiers = EMPTY_OBJ] = directives2[i2];
if (dir) {
if (isFunction$1(dir)) {
dir = {
mounted: dir,
updated: dir
};
}
if (dir.deep) {
traverse(value);
}
bindings.push({
dir,
instance,
value,
oldValue: void 0,
arg,
modifiers
});
}
}
return vnode;
}
function invokeDirectiveHook(vnode, prevVNode, instance, name) {
const bindings = vnode.dirs;
const oldBindings = prevVNode && prevVNode.dirs;
for (let i2 = 0; i2 < bindings.length; i2++) {
const binding = bindings[i2];
if (oldBindings) {
binding.oldValue = oldBindings[i2].value;
}
let hook = binding.dir[name];
if (hook) {
pauseTracking();
callWithAsyncErrorHandling(hook, instance, 8, [
vnode.el,
binding,
vnode,
prevVNode
]);
resetTracking();
}
}
}
const COMPONENTS = "components";
const DIRECTIVES = "directives";
function resolveComponent(name, maybeSelfReference) {
return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
}
const NULL_DYNAMIC_COMPONENT = Symbol();
function resolveDynamicComponent(component) {
if (isString$1(component)) {
return resolveAsset(COMPONENTS, component, false) || component;
} else {
return component || NULL_DYNAMIC_COMPONENT;
}
}
function resolveDirective(name) {
return resolveAsset(DIRECTIVES, name);
}
function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
const instance = currentRenderingInstance || currentInstance;
if (instance) {
const Component = instance.type;
if (type === COMPONENTS) {
const selfName = getComponentName(
Component,
false
/* do not include inferred name to avoid breaking existing code */
);
if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
return Component;
}
}
const res = (
// local registration
// check instance[type] first which is resolved for options API
resolve(instance[type] || Component[type], name) || // global registration
resolve(instance.appContext[type], name)
);
if (!res && maybeSelfReference) {
return Component;
}
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$2(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
}
return res;
} else {
warn$2(`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))]);
}
function renderList(source, renderItem, cache2, index2) {
let ret;
const cached = cache2 && cache2[index2];
if (isArray$1(source) || isString$1(source)) {
ret = new Array(source.length);
for (let i2 = 0, l = source.length; i2 < l; i2++) {
ret[i2] = renderItem(source[i2], i2, void 0, cached && cached[i2]);
}
} else if (typeof source === "number") {
if (!Number.isInteger(source)) {
warn$2(`The v-for range expect an integer value but got ${source}.`);
}
ret = new Array(source);
for (let i2 = 0; i2 < source; i2++) {
ret[i2] = renderItem(i2 + 1, i2, void 0, cached && cached[i2]);
}
} else if (isObject(source)) {
if (source[Symbol.iterator]) {
ret = Array.from(source, (item, i2) => renderItem(item, i2, void 0, cached && cached[i2]));
} else {
const keys = Object.keys(source);
ret = new Array(keys.length);
for (let i2 = 0, l = keys.length; i2 < l; i2++) {
const key = keys[i2];
ret[i2] = renderItem(source[key], key, i2, cached && cached[i2]);
}
}
} else {
ret = [];
}
if (cache2) {
cache2[index2] = ret;
}
return ret;
}
function renderSlot(slots, name, props = {}, fallback, noSlotted) {
if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
if (name !== "default")
props.name = name;
return createVNode("slot", props, fallback && fallback());
}
let slot = slots[name];
if (slot && slot.length > 1) {
warn$2(`SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template.`);
slot = () => [];
}
if (slot && slot._c) {
slot._d = false;
}
openBlock();
const validSlotContent = slot && ensureValidVNode(slot(props));
const rendered = createBlock(
Fragment,
{
key: props.key || // slot content array of a dynamic conditional slot may have a branch
// key attached in the `createSlots` helper, respect that
validSlotContent && validSlotContent.key || `_${name}`
},
validSlotContent || (fallback ? fallback() : []),
validSlotContent && slots._ === 1 ? 64 : -2
/* PatchFlags.BAIL */
);
if (!noSlotted && rendered.scopeId) {
rendered.slotScopeIds = [rendered.scopeId + "-s"];
}
if (slot && slot._c) {
slot._d = true;
}
return rendered;
}
function ensureValidVNode(vnodes) {
return vnodes.some((child) => {
if (!isVNode(child))
return true;
if (child.type === Comment)
return false;
if (child.type === Fragment && !ensureValidVNode(child.children))
return false;
return true;
}) ? vnodes : null;
}
const getPublicInstance = (i2) => {
if (!i2)
return null;
if (isStatefulComponent(i2))
return getExposeProxy(i2) || i2.proxy;
return getPublicInstance(i2.parent);
};
const publicPropertiesMap = (
// Move PURE marker to new line to workaround compiler discarding it
// due to type annotation
/* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
$: (i2) => i2,
$el: (i2) => i2.vnode.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)),
$nextTick: (i2) => i2.n || (i2.n = nextTick.bind(i2.proxy)),
$watch: (i2) => instanceWatch.bind(i2)
})
);
const isReservedPrefix = (key) => key === "_" || key === "$";
const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
const PublicInstanceProxyHandlers = {
get({ _: instance }, key) {
const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
if (key === "__isVue") {
return true;
}
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 (hasSetupBinding(setupState, key)) {
accessCache[key] = 1;
return setupState[key];
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
accessCache[key] = 2;
return data[key];
} else if (
// only cache other properties when instance has declared (thus stable)
// props
(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);
markAttrsAccessed();
}
return publicGetter(instance);
} else if (
// css module (injected by vue-loader)
(cssModule = type.__cssModules) && (cssModule = cssModule[key])
) {
return cssModule;
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
accessCache[key] = 4;
return ctx[key];
} else if (
// global properties
globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
) {
{
return globalProperties[key];
}
} else if (currentRenderingInstance && (!isString$1(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
// to infinite warning loop
key.indexOf("__v") !== 0)) {
if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
warn$2(`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$2(`Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`);
}
}
},
set({ _: instance }, key, value) {
const { data, setupState, ctx } = instance;
if (hasSetupBinding(setupState, key)) {
setupState[key] = value;
return true;
} else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
warn$2(`Cannot mutate <script setup> binding "${key}" from Options API.`);
return false;
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
data[key] = value;
return true;
} else if (hasOwn(instance.props, key)) {
warn$2(`Attempting to mutate prop "${key}". Props are readonly.`);
return false;
}
if (key[0] === "$" && key.slice(1) in instance) {
warn$2(`Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`);
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) || hasSetupBinding(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$2(`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),
// intercepted by the proxy so no need for implementation,
// but needed to prevent set errors
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$2(`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 cache2 = /* @__PURE__ */ Object.create(null);
return (type, key) => {
if (cache2[key]) {
warn$2(`${type} property "${key}" is already defined in ${cache2[key]}.`);
} else {
cache2[key] = type;
}
};
}
let shouldCacheAccess = true;
function applyOptions(instance) {
const options = resolveMergedOptions(instance);
const publicThis = instance.proxy;
const ctx = instance.ctx;
shouldCacheAccess = false;
if (options.beforeCreate) {
callHook$1(
options.beforeCreate,
instance,
"bc"
/* LifecycleHooks.BEFORE_CREATE */
);
}
const {
// state
data: dataOptions,
computed: computedOptions,
methods,
watch: watchOptions,
provide: provideOptions,
inject: injectOptions,
// lifecycle
created,
beforeMount,
mounted,
beforeUpdate,
updated,
activated,
deactivated,
beforeDestroy,
beforeUnmount,
destroyed,
unmounted,
render: render2,
renderTracked,
renderTriggered,
errorCaptured,
serverPrefetch,
// public API
expose,
inheritAttrs,
// assets
components,
directives: directives2,
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$1(methodHandler)) {
{
Object.defineProperty(ctx, key, {
value: methodHandler.bind(publicThis),
configurable: true,
enumerable: true,
writable: true
});
}
{
checkDuplicateProperties("Methods", key);
}
} else {
warn$2(`Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`);
}
}
}
if (dataOptions) {
if (!isFunction$1(dataOptions)) {
warn$2(`The data option must be a function. Plain object usage is no longer supported.`);
}
const data = dataOptions.call(publicThis, publicThis);
if (isPromise(data)) {
warn$2(`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(data)) {
warn$2(`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$1(opt) ? opt.bind(publicThis, publicThis) : isFunction$1(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
if (get2 === NOOP) {
warn$2(`Computed property "${key}" has no getter.`);
}
const set2 = !isFunction$1(opt) && isFunction$1(opt.set) ? opt.set.bind(publicThis) : () => {
warn$2(`Write operation failed: computed property "${key}" is readonly.`);
};
const c2 = computed({
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$1(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
Reflect.ownKeys(provides).forEach((key) => {
provide(key, provides[key]);
});
}
if (created) {
callHook$1(
created,
instance,
"c"
/* LifecycleHooks.CREATED */
);
}
function registerLifecycleHook(register, hook) {
if (isArray$1(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$1(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 (render2 && instance.render === NOOP) {
instance.render = render2;
}
if (inheritAttrs != null) {
instance.inheritAttrs = inheritAttrs;
}
if (components)
instance.components = components;
if (directives2)
instance.directives = directives2;
}
function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
if (isArray$1(injectOptions)) {
injectOptions = normalizeInject(injectOptions);
}
for (const key in injectOptions) {
const opt = injectOptions[key];
let injected;
if (isObject(opt)) {
if ("default" in opt) {
injected = inject(
opt.from || key,
opt.default,
true
/* treat default function as factory */
);
} 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$2(`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$1(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$1(raw)) {
const handler = ctx[raw];
if (isFunction$1(handler)) {
watch(getter, handler);
} else {
warn$2(`Invalid watch handler specified by key "${raw}"`, handler);
}
} else if (isFunction$1(raw)) {
watch(getter, raw.bind(publicThis));
} else if (isObject(raw)) {
if (isArray$1(raw)) {
raw.forEach((r2) => createWatcher(r2, ctx, publicThis, key));
} else {
const handler = isFunction$1(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
if (isFunction$1(handler)) {
watch(getter, handler, raw);
} else {
warn$2(`Invalid watch handler specified by key "${raw.handler}"`, handler);
}
}
} else {
warn$2(`Invalid watch option: "${key}"`, raw);
}
}
function resolveMergedOptions(instance) {
const base2 = instance.type;
const { mixins, extends: extendsOptions } = base2;
const { mixins: globalMixins, optionsCache: cache2, config: { optionMergeStrategies } } = instance.appContext;
const cached = cache2.get(base2);
let resolved;
if (cached) {
resolved = cached;
} else if (!globalMixins.length && !mixins && !extendsOptions) {
{
resolved = base2;
}
} else {
resolved = {};
if (globalMixins.length) {
globalMixins.forEach((m2) => mergeOptions$1(resolved, m2, optionMergeStrategies, true));
}
mergeOptions$1(resolved, base2, optionMergeStrategies);
}
if (isObject(base2)) {
cache2.set(base2, resolved);
}
return resolved;
}
function mergeOptions$1(to2, from, strats, asMixin = false) {
const { mixins, extends: extendsOptions } = from;
if (extendsOptions) {
mergeOptions$1(to2, extendsOptions, strats, true);
}
if (mixins) {
mixins.forEach((m2) => mergeOptions$1(to2, m2, strats, true));
}
for (const key in from) {
if (asMixin && key === "expose") {
warn$2(`"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];
to2[key] = strat ? strat(to2[key], from[key]) : from[key];
}
}
return to2;
}
const internalOptionMergeStrats = {
data: mergeDataFn,
props: mergeObjectOptions,
emits: mergeObjectOptions,
// objects
methods: mergeObjectOptions,
computed: mergeObjectOptions,
// lifecycle
beforeCreate: mergeAsArray,
created: mergeAsArray,
beforeMount: mergeAsArray,
mounted: mergeAsArray,
beforeUpdate: mergeAsArray,
updated: mergeAsArray,
beforeDestroy: mergeAsArray,
beforeUnmount: mergeAsArray,
destroyed: mergeAsArray,
unmounted: mergeAsArray,
activated: mergeAsArray,
deactivated: mergeAsArray,
errorCaptured: mergeAsArray,
serverPrefetch: mergeAsArray,
// assets
components: mergeObjectOptions,
directives: mergeObjectOptions,
// watch
watch: mergeWatchOptions,
// provide / inject
provide: mergeDataFn,
inject: mergeInject
};
function mergeDataFn(to2, from) {
if (!from) {
return to2;
}
if (!to2) {
return from;
}
return function mergedDataFn() {
return extend(isFunction$1(to2) ? to2.call(this, this) : to2, isFunction$1(from) ? from.call(this, this) : from);
};
}
function mergeInject(to2, from) {
return mergeObjectOptions(normalizeInject(to2), normalizeInject(from));
}
function normalizeInject(raw) {
if (isArray$1(raw)) {
const res = {};
for (let i2 = 0; i2 < raw.length; i2++) {
res[raw[i2]] = raw[i2];
}
return res;
}
return raw;
}
function mergeAsArray(to2, from) {
return to2 ? [...new Set([].concat(to2, from))] : from;
}
function mergeObjectOptions(to2, from) {
return to2 ? extend(extend(/* @__PURE__ */ Object.create(null), to2), from) : from;
}
function mergeWatchOptions(to2, from) {
if (!to2)
return from;
if (!from)
return to2;
const merged = extend(/* @__PURE__ */ Object.create(null), to2);
for (const key in from) {
merged[key] = mergeAsArray(to2[key], from[key]);
}
return merged;
}
function initProps(instance, rawProps, isStateful, isSSR = false) {
const props = {};
const attrs = {};
def(attrs, InternalObjectKey, 1);
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 isInHmrContext(instance) {
while (instance) {
if (instance.type.__hmrId)
return true;
instance = instance.parent;
}
}
function updateProps(instance, rawProps, rawPrevProps, optimized) {
const { props, attrs, vnode: { patchFlag } } = instance;
const rawCurrentProps = toRaw(props);
const [options] = instance.propsOptions;
let hasAttrsChanged = false;
if (
// always force full diff in dev
// - #1942 if hmr is enabled with sfc component
// - vite#872 non-sfc component used by sfc component
!isInHmrContext(instance) && (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
/* isAbsent */
);
}
} 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 || // for camelCase
!hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
// and converted to camelCase (#955)
((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
if (options) {
if (rawPrevProps && // for camelCase
(rawPrevProps[key] !== void 0 || // for kebab-case
rawPrevProps[kebabKey] !== void 0)) {
props[key] = resolvePropValue(
options,
rawCurrentProps,
key,
void 0,
instance,
true
/* isAbsent */
);
}
} 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$1(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
/* BooleanFlags.shouldCast */
]) {
if (isAbsent && !hasDefault) {
value = false;
} else if (opt[
1
/* BooleanFlags.shouldCastTrue */
] && (value === "" || value === hyphenate(key))) {
value = true;
}
}
}
return value;
}
function normalizePropsOptions(comp, appContext, asMixin = false) {
const cache2 = appContext.propsCache;
const cached = cache2.get(comp);
if (cached) {
return cached;
}
const raw = comp.props;
const normalized = {};
const needCastKeys = [];
let hasExtends = false;
if (!isFunction$1(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) {
if (isObject(comp)) {
cache2.set(comp, EMPTY_ARR);
}
return EMPTY_ARR;
}
if (isArray$1(raw)) {
for (let i2 = 0; i2 < raw.length; i2++) {
if (!isString$1(raw[i2])) {
warn$2(`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(raw)) {
warn$2(`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$1(opt) || isFunction$1(opt) ? { type: opt } : Object.assign({}, opt);
if (prop) {
const booleanIndex = getTypeIndex(Boolean, prop.type);
const stringIndex = getTypeIndex(String, prop.type);
prop[
0
/* BooleanFlags.shouldCast */
] = booleanIndex > -1;
prop[
1
/* BooleanFlags.shouldCastTrue */
] = stringIndex < 0 || booleanIndex < stringIndex;
if (booleanIndex > -1 || hasOwn(prop, "default")) {
needCastKeys.push(normalizedKey);
}
}
}
}
}
const res = [normalized, needCastKeys];
if (isObject(comp)) {
cache2.set(comp, res);
}
return res;
}
function validatePropName(key) {
if (key[0] !== "$") {
return true;
} else {
warn$2(`Invalid prop name: "${key}" is a reserved property.`);
}
return false;
}
function getType(ctor) {
const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
return match ? match[2] : ctor === null ? "null" : "";
}
function isSameType(a2, b3) {
return getType(a2) === getType(b3);
}
function getTypeIndex(type, expectedTypes) {
if (isArray$1(expectedTypes)) {
return expectedTypes.findIndex((t2) => isSameType(t2, type));
} else if (isFunction$1(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$2('Missing required prop: "' + name + '"');
return;
}
if (value == null && !prop.required) {
return;
}
if (type != null && type !== true) {
let isValid = false;
const types = isArray$1(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$2(getInvalidTypeMessage(name, value, expectedTypes));
return;
}
}
if (validator && !validator(value)) {
warn$2('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(value);
} else if (expectedType === "Array") {
valid = isArray$1(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");
}
const isInternalKey = (key) => key[0] === "_" || key === "$stable";
const normalizeSlotValue = (value) => isArray$1(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
const normalizeSlot$1 = (key, rawSlot, ctx) => {
if (rawSlot._n) {
return rawSlot;
}
const normalized = withCtx((...args) => {
if (currentInstance) {
warn$2(`Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`);
}
return normalizeSlotValue(rawSlot(...args));
}, ctx);
normalized._c = false;
return normalized;
};
const normalizeObjectSlots = (rawSlots, slots, instance) => {
const ctx = rawSlots._ctx;
for (const key in rawSlots) {
if (isInternalKey(key))
continue;
const value = rawSlots[key];
if (isFunction$1(value)) {
slots[key] = normalizeSlot$1(key, value, ctx);
} else if (value != null) {
{
warn$2(`Non-function value encountered for slot "${key}". Prefer function slots for better performance.`);
}
const normalized = normalizeSlotValue(value);
slots[key] = () => normalized;
}
}
};
const normalizeVNodeSlots = (instance, children2) => {
if (!isKeepAlive(instance.vnode) && true) {
warn$2(`Non-function value encountered for default slot. Prefer function slots for better performance.`);
}
const normalized = normalizeSlotValue(children2);
instance.slots.default = () => normalized;
};
const initSlots = (instance, children2) => {
if (instance.vnode.shapeFlag & 32) {
const type = children2._;
if (type) {
instance.slots = toRaw(children2);
def(children2, "_", type);
} else {
normalizeObjectSlots(children2, instance.slots = {});
}
} else {
instance.slots = {};
if (children2) {
normalizeVNodeSlots(instance, children2);
}
}
def(instance.slots, InternalObjectKey, 1);
};
const updateSlots = (instance, children2, optimized) => {
const { vnode, slots } = instance;
let needDeletionCheck = true;
let deletionComparisonTarget = EMPTY_OBJ;
if (vnode.shapeFlag & 32) {
const type = children2._;
if (type) {
if (isHmrUpdating) {
extend(slots, children2);
} else if (optimized && type === 1) {
needDeletionCheck = false;
} else {
extend(slots, children2);
if (!optimized && type === 1) {
delete slots._;
}
}
} else {
needDeletionCheck = !children2.$stable;
normalizeObjectSlots(children2, slots);
}
deletionComparisonTarget = children2;
} else if (children2) {
normalizeVNodeSlots(instance, children2);
deletionComparisonTarget = { default: 1 };
}
if (needDeletionCheck) {
for (const key in slots) {
if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
delete slots[key];
}
}
}
};
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$1 = 0;
function createAppAPI(render2, hydrate) {
return function createApp2(rootComponent, rootProps = null) {
if (!isFunction$1(rootComponent)) {
rootComponent = Object.assign({}, rootComponent);
}
if (rootProps != null && !isObject(rootProps)) {
warn$2(`root props passed to app.mount() must be an object.`);
rootProps = null;
}
const context = createAppContext();
const installedPlugins = /* @__PURE__ */ new Set();
let isMounted = false;
const app = context.app = {
_uid: uid$1++,
_component: rootComponent,
_props: rootProps,
_container: null,
_context: context,
_instance: null,
version: version$1,
get config() {
return context.config;
},
set config(v2) {
{
warn$2(`app.config cannot be replaced. Modify individual options instead.`);
}
},
use(plugin2, ...options) {
if (installedPlugins.has(plugin2)) {
warn$2(`Plugin has already been applied to target app.`);
} else if (plugin2 && isFunction$1(plugin2.install)) {
installedPlugins.add(plugin2);
plugin2.install(app, ...options);
} else if (isFunction$1(plugin2)) {
installedPlugins.add(plugin2);
plugin2(app, ...options);
} else {
warn$2(`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$2("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$2(`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$2(`Directive "${name}" has already been registered in target app.`);
}
context.directives[name] = directive;
return app;
},
mount(rootContainer, isHydrate, isSVG) {
if (!isMounted) {
if (rootContainer.__vue_app__) {
warn$2(`There is already an app instance mounted on the host container.
If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`);
}
const vnode = createVNode(rootComponent, rootProps);
vnode.appContext = context;
{
context.reload = () => {
render2(cloneVNode(vnode), rootContainer, isSVG);
};
}
if (isHydrate && hydrate) {
hydrate(vnode, rootContainer);
} else {
render2(vnode, rootContainer, isSVG);
}
isMounted = true;
app._container = rootContainer;
rootContainer.__vue_app__ = app;
{
app._instance = vnode.component;
devtoolsInitApp(app, version$1);
}
return getExposeProxy(vnode.component) || vnode.component.proxy;
} else {
warn$2(`App has already been mounted.
If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``);
}
},
unmount() {
if (isMounted) {
render2(null, app._container);
{
app._instance = null;
devtoolsUnmountApp(app);
}
delete app._container.__vue_app__;
} else {
warn$2(`Cannot unmount an app that is not mounted.`);
}
},
provide(key, value) {
if (key in context.provides) {
warn$2(`App already provides property with key "${String(key)}". It will be overwritten with the new value.`);
}
context.provides[key] = value;
return app;
}
};
return app;
};
}
function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
if (isArray$1(rawRef)) {
rawRef.forEach((r2, i2) => setRef(r2, oldRawRef && (isArray$1(oldRawRef) ? oldRawRef[i2] : oldRawRef), parentSuspense, vnode, isUnmount));
return;
}
if (isAsyncWrapper(vnode) && !isUnmount) {
return;
}
const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el;
const value = isUnmount ? null : refValue;
const { i: owner, r: ref2 } = rawRef;
if (!owner) {
warn$2(`Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`);
return;
}
const oldRef = oldRawRef && oldRawRef.r;
const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
const setupState = owner.setupState;
if (oldRef != null && oldRef !== ref2) {
if (isString$1(oldRef)) {
refs[oldRef] = null;
if (hasOwn(setupState, oldRef)) {
setupState[oldRef] = null;
}
} else if (isRef(oldRef)) {
oldRef.value = null;
}
}
if (isFunction$1(ref2)) {
callWithErrorHandling(ref2, owner, 12, [value, refs]);
} else {
const _isString = isString$1(ref2);
const _isRef = isRef(ref2);
if (_isString || _isRef) {
const doSet = () => {
if (rawRef.f) {
const existing = _isString ? hasOwn(setupState, ref2) ? setupState[ref2] : refs[ref2] : ref2.value;
if (isUnmount) {
isArray$1(existing) && remove(existing, refValue);
} else {
if (!isArray$1(existing)) {
if (_isString) {
refs[ref2] = [refValue];
if (hasOwn(setupState, ref2)) {
setupState[ref2] = refs[ref2];
}
} else {
ref2.value = [refValue];
if (rawRef.k)
refs[rawRef.k] = ref2.value;
}
} else if (!existing.includes(refValue)) {
existing.push(refValue);
}
}
} else if (_isString) {
refs[ref2] = value;
if (hasOwn(setupState, ref2)) {
setupState[ref2] = value;
}
} else if (_isRef) {
ref2.value = value;
if (rawRef.k)
refs[rawRef.k] = value;
} else {
warn$2("Invalid template ref type:", ref2, `(${typeof ref2})`);
}
};
if (value) {
doSet.id = -1;
queuePostRenderEffect(doSet, parentSuspense);
} else {
doSet();
}
} else {
warn$2("Invalid template ref type:", ref2, `(${typeof ref2})`);
}
}
}
let supported$1;
let perf$1;
function startMeasure(instance, type) {
if (instance.appContext.config.performance && isSupported()) {
perf$1.mark(`vue-${type}-${instance.uid}`);
}
{
devtoolsPerfStart(instance, type, isSupported() ? perf$1.now() : Date.now());
}
}
function endMeasure(instance, type) {
if (instance.appContext.config.performance && isSupported()) {
const startTag = `vue-${type}-${instance.uid}`;
const endTag = startTag + `:end`;
perf$1.mark(endTag);
perf$1.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
perf$1.clearMarks(startTag);
perf$1.clearMarks(endTag);
}
{
devtoolsPerfEnd(instance, type, isSupported() ? perf$1.now() : Date.now());
}
}
function isSupported() {
if (supported$1 !== void 0) {
return supported$1;
}
if (typeof window !== "undefined" && window.performance) {
supported$1 = true;
perf$1 = window.performance;
} else {
supported$1 = false;
}
return supported$1;
}
function initFeatureFlags() {
const needWarn = [];
if (needWarn.length) {
const multi = needWarn.length > 1;
console.warn(`Feature flag${multi ? `s` : ``} ${needWarn.join(", ")} ${multi ? `are` : `is`} not explicitly defined. You are running the esm-bundler build of Vue, which expects these compile-time feature flags to be globally injected via the bundler config in order to get better tree-shaking in the production bundle.
For more details, see https://link.vuejs.org/feature-flags.`);
}
}
const queuePostRenderEffect = queueEffectWithSuspense;
function createRenderer(options) {
return baseCreateRenderer(options);
}
function baseCreateRenderer(options, createHydrationFns) {
{
initFeatureFlags();
}
const target = getGlobalThis();
target.__VUE__ = true;
{
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
}
const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, insertStaticContent: hostInsertStaticContent } = options;
const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
if (n1 === n2) {
return;
}
if (n1 && !isSameVNodeType(n1, n2)) {
anchor = getNextHostNode(n1);
unmount(n1, parentComponent, parentSuspense, true);
n1 = null;
}
if (n2.patchFlag === -2) {
optimized = false;
n2.dynamicChildren = null;
}
const { type, ref: ref2, shapeFlag } = n2;
switch (type) {
case Text:
processText(n1, n2, container, anchor);
break;
case Comment:
processCommentNode(n1, n2, container, anchor);
break;
case Static:
if (n1 == null) {
mountStaticNode(n2, container, anchor, isSVG);
} else {
patchStaticNode(n1, n2, container, isSVG);
}
break;
case Fragment:
processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
break;
default:
if (shapeFlag & 1) {
processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (shapeFlag & 6) {
processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (shapeFlag & 64) {
type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
} else if (shapeFlag & 128) {
type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
} else {
warn$2("Invalid VNode type:", type, `(${typeof type})`);
}
}
if (ref2 != null && parentComponent) {
setRef(ref2, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
}
};
const processText = (n1, n2, container, anchor) => {
if (n1 == null) {
hostInsert(n2.el = hostCreateText(n2.children), container, anchor);
} else {
const el2 = n2.el = n1.el;
if (n2.children !== n1.children) {
hostSetText(el2, n2.children);
}
}
};
const processCommentNode = (n1, n2, container, anchor) => {
if (n1 == null) {
hostInsert(n2.el = hostCreateComment(n2.children || ""), container, anchor);
} else {
n2.el = n1.el;
}
};
const mountStaticNode = (n2, container, anchor, isSVG) => {
[n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG, n2.el, n2.anchor);
};
const patchStaticNode = (n1, n2, container, isSVG) => {
if (n2.children !== n1.children) {
const anchor = hostNextSibling(n1.anchor);
removeStaticNode(n1);
[n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
} else {
n2.el = n1.el;
n2.anchor = n1.anchor;
}
};
const moveStaticNode = ({ el: el2, anchor }, container, nextSibling) => {
let next;
while (el2 && el2 !== anchor) {
next = hostNextSibling(el2);
hostInsert(el2, container, nextSibling);
el2 = next;
}
hostInsert(anchor, container, nextSibling);
};
const removeStaticNode = ({ el: el2, anchor }) => {
let next;
while (el2 && el2 !== anchor) {
next = hostNextSibling(el2);
hostRemove(el2);
el2 = next;
}
hostRemove(anchor);
};
const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
isSVG = isSVG || n2.type === "svg";
if (n1 == null) {
mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else {
patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
}
};
const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
let el2;
let vnodeHook;
const { type, props, shapeFlag, transition, dirs } = vnode;
el2 = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
if (shapeFlag & 8) {
hostSetElementText(el2, vnode.children);
} else if (shapeFlag & 16) {
mountChildren(vnode.children, el2, null, parentComponent, parentSuspense, isSVG && type !== "foreignObject", slotScopeIds, optimized);
}
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, "created");
}
setScopeId(el2, vnode, vnode.scopeId, slotScopeIds, parentComponent);
if (props) {
for (const key in props) {
if (key !== "value" && !isReservedProp(key)) {
hostPatchProp(el2, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
}
}
if ("value" in props) {
hostPatchProp(el2, "value", null, props.value);
}
if (vnodeHook = props.onVnodeBeforeMount) {
invokeVNodeHook(vnodeHook, parentComponent, vnode);
}
}
{
Object.defineProperty(el2, "__vnode", {
value: vnode,
enumerable: false
});
Object.defineProperty(el2, "__vueParentComponent", {
value: parentComponent,
enumerable: false
});
}
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
}
const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
if (needCallTransitionHooks) {
transition.beforeEnter(el2);
}
hostInsert(el2, container, anchor);
if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
queuePostRenderEffect(() => {
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
needCallTransitionHooks && transition.enter(el2);
dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
}, parentSuspense);
}
};
const setScopeId = (el2, vnode, scopeId, slotScopeIds, parentComponent) => {
if (scopeId) {
hostSetScopeId(el2, scopeId);
}
if (slotScopeIds) {
for (let i2 = 0; i2 < slotScopeIds.length; i2++) {
hostSetScopeId(el2, slotScopeIds[i2]);
}
}
if (parentComponent) {
let subTree = parentComponent.subTree;
if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
subTree = filterSingleRoot(subTree.children) || subTree;
}
if (vnode === subTree) {
const parentVNode = parentComponent.vnode;
setScopeId(el2, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
}
}
};
const mountChildren = (children2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
for (let i2 = start; i2 < children2.length; i2++) {
const child = children2[i2] = optimized ? cloneIfMounted(children2[i2]) : normalizeVNode(children2[i2]);
patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
}
};
const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
const el2 = n2.el = n1.el;
let { patchFlag, dynamicChildren, dirs } = n2;
patchFlag |= n1.patchFlag & 16;
const oldProps = n1.props || EMPTY_OBJ;
const newProps = n2.props || EMPTY_OBJ;
let vnodeHook;
parentComponent && toggleRecurse(parentComponent, false);
if (vnodeHook = newProps.onVnodeBeforeUpdate) {
invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
}
if (dirs) {
invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
}
parentComponent && toggleRecurse(parentComponent, true);
if (isHmrUpdating) {
patchFlag = 0;
optimized = false;
dynamicChildren = null;
}
const areChildrenSVG = isSVG && n2.type !== "foreignObject";
if (dynamicChildren) {
patchBlockChildren(n1.dynamicChildren, dynamicChildren, el2, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
if (parentComponent && parentComponent.type.__hmrId) {
traverseStaticChildren(n1, n2);
}
} else if (!optimized) {
patchChildren(n1, n2, el2, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
}
if (patchFlag > 0) {
if (patchFlag & 16) {
patchProps(el2, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
} else {
if (patchFlag & 2) {
if (oldProps.class !== newProps.class) {
hostPatchProp(el2, "class", null, newProps.class, isSVG);
}
}
if (patchFlag & 4) {
hostPatchProp(el2, "style", oldProps.style, newProps.style, isSVG);
}
if (patchFlag & 8) {
const propsToUpdate = n2.dynamicProps;
for (let i2 = 0; i2 < propsToUpdate.length; i2++) {
const key = propsToUpdate[i2];
const prev = oldProps[key];
const next = newProps[key];
if (next !== prev || key === "value") {
hostPatchProp(el2, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
}
}
}
}
if (patchFlag & 1) {
if (n1.children !== n2.children) {
hostSetElementText(el2, n2.children);
}
}
} else if (!optimized && dynamicChildren == null) {
patchProps(el2, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
}
if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
queuePostRenderEffect(() => {
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
}, parentSuspense);
}
};
const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
for (let i2 = 0; i2 < newChildren.length; i2++) {
const oldVNode = oldChildren[i2];
const newVNode = newChildren[i2];
const container = (
// oldVNode may be an errored async setup() component inside Suspense
// which will not have a mounted element
oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
// of the Fragment itself so it can move its children.
(oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
// which also requires the correct parent container
!isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
// In other cases, the parent container is not actually used so we
// just pass the block element here to avoid a DOM parentNode call.
fallbackContainer
)
);
patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
}
};
const patchProps = (el2, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
if (oldProps !== newProps) {
if (oldProps !== EMPTY_OBJ) {
for (const key in oldProps) {
if (!isReservedProp(key) && !(key in newProps)) {
hostPatchProp(el2, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
}
}
}
for (const key in newProps) {
if (isReservedProp(key))
continue;
const next = newProps[key];
const prev = oldProps[key];
if (next !== prev && key !== "value") {
hostPatchProp(el2, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
}
}
if ("value" in newProps) {
hostPatchProp(el2, "value", oldProps.value, newProps.value);
}
}
};
const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
if (
// #5523 dev root fragment may inherit directives
isHmrUpdating || patchFlag & 2048
) {
patchFlag = 0;
optimized = false;
dynamicChildren = null;
}
if (fragmentSlotScopeIds) {
slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
}
if (n1 == null) {
hostInsert(fragmentStartAnchor, container, anchor);
hostInsert(fragmentEndAnchor, container, anchor);
mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else {
if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
// of renderSlot() with no valid children
n1.dynamicChildren) {
patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
if (parentComponent && parentComponent.type.__hmrId) {
traverseStaticChildren(n1, n2);
} else if (
// #2080 if the stable fragment has a key, it's a <template v-for> that may
// get moved around. Make sure all root level vnodes inherit el.
// #2134 or if it's a component root, it may also get moved around
// as the component is being moved.
n2.key != null || parentComponent && n2 === parentComponent.subTree
) {
traverseStaticChildren(
n1,
n2,
true
/* shallow */
);
}
} else {
patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
}
}
};
const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
n2.slotScopeIds = slotScopeIds;
if (n1 == null) {
if (n2.shapeFlag & 512) {
parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
} else {
mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
}
} else {
updateComponent(n1, n2, optimized);
}
};
const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
const instance = initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense);
if (instance.type.__hmrId) {
registerHMR(instance);
}
{
pushWarningContext(initialVNode);
startMeasure(instance, `mount`);
}
if (isKeepAlive(initialVNode)) {
instance.ctx.renderer = internals;
}
{
{
startMeasure(instance, `init`);
}
setupComponent(instance);
{
endMeasure(instance, `init`);
}
}
if (instance.asyncDep) {
parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
if (!initialVNode.el) {
const placeholder = instance.subTree = createVNode(Comment);
processCommentNode(null, placeholder, container, anchor);
}
return;
}
setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
{
popWarningContext();
endMeasure(instance, `mount`);
}
};
const updateComponent = (n1, n2, optimized) => {
const instance = n2.component = n1.component;
if (shouldUpdateComponent(n1, n2, optimized)) {
if (instance.asyncDep && !instance.asyncResolved) {
{
pushWarningContext(n2);
}
updateComponentPreRender(instance, n2, optimized);
{
popWarningContext();
}
return;
} else {
instance.next = n2;
invalidateJob(instance.update);
instance.update();
}
} else {
n2.el = n1.el;
instance.vnode = n2;
}
};
const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
const componentUpdateFn = () => {
if (!instance.isMounted) {
let vnodeHook;
const { el: el2, props } = initialVNode;
const { bm, m: m2, parent } = instance;
const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
toggleRecurse(instance, false);
if (bm) {
invokeArrayFns(bm);
}
if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
invokeVNodeHook(vnodeHook, parent, initialVNode);
}
toggleRecurse(instance, true);
if (el2 && hydrateNode) {
const hydrateSubTree = () => {
{
startMeasure(instance, `render`);
}
instance.subTree = renderComponentRoot(instance);
{
endMeasure(instance, `render`);
}
{
startMeasure(instance, `hydrate`);
}
hydrateNode(el2, instance.subTree, instance, parentSuspense, null);
{
endMeasure(instance, `hydrate`);
}
};
if (isAsyncWrapperVNode) {
initialVNode.type.__asyncLoader().then(
// note: we are moving the render call into an async callback,
// which means it won't track dependencies - but it's ok because
// a server-rendered async wrapper is already in resolved state
// and it will never need to change.
() => !instance.isUnmounted && hydrateSubTree()
);
} else {
hydrateSubTree();
}
} else {
{
startMeasure(instance, `render`);
}
const subTree = instance.subTree = renderComponentRoot(instance);
{
endMeasure(instance, `render`);
}
{
startMeasure(instance, `patch`);
}
patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
{
endMeasure(instance, `patch`);
}
initialVNode.el = subTree.el;
}
if (m2) {
queuePostRenderEffect(m2, parentSuspense);
}
if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
const scopedInitialVNode = initialVNode;
queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
}
if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
instance.a && queuePostRenderEffect(instance.a, parentSuspense);
}
instance.isMounted = true;
{
devtoolsComponentAdded(instance);
}
initialVNode = container = anchor = null;
} else {
let { next, bu: bu2, u: u2, parent, vnode } = instance;
let originNext = next;
let vnodeHook;
{
pushWarningContext(next || instance.vnode);
}
toggleRecurse(instance, false);
if (next) {
next.el = vnode.el;
updateComponentPreRender(instance, next, optimized);
} else {
next = vnode;
}
if (bu2) {
invokeArrayFns(bu2);
}
if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
invokeVNodeHook(vnodeHook, parent, next, vnode);
}
toggleRecurse(instance, true);
{
startMeasure(instance, `render`);
}
const nextTree = renderComponentRoot(instance);
{
endMeasure(instance, `render`);
}
const prevTree = instance.subTree;
instance.subTree = nextTree;
{
startMeasure(instance, `patch`);
}
patch(
prevTree,
nextTree,
// parent may have changed if it's in a teleport
hostParentNode(prevTree.el),
// anchor may have changed if it's in a fragment
getNextHostNode(prevTree),
instance,
parentSuspense,
isSVG
);
{
endMeasure(instance, `patch`);
}
next.el = nextTree.el;
if (originNext === null) {
updateHOCHostEl(instance, nextTree.el);
}
if (u2) {
queuePostRenderEffect(u2, parentSuspense);
}
if (vnodeHook = next.props && next.props.onVnodeUpdated) {
queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
}
{
devtoolsComponentUpdated(instance);
}
{
popWarningContext();
}
}
};
const effect = instance.effect = new ReactiveEffect(
componentUpdateFn,
() => queueJob(update2),
instance.scope
// track it in component's effect scope
);
const update2 = instance.update = () => effect.run();
update2.id = instance.uid;
toggleRecurse(instance, true);
{
effect.onTrack = instance.rtc ? (e2) => invokeArrayFns(instance.rtc, e2) : void 0;
effect.onTrigger = instance.rtg ? (e2) => invokeArrayFns(instance.rtg, e2) : void 0;
update2.ownerInstance = instance;
}
update2();
};
const updateComponentPreRender = (instance, nextVNode, optimized) => {
nextVNode.component = instance;
const prevProps = instance.vnode.props;
instance.vnode = nextVNode;
instance.next = null;
updateProps(instance, nextVNode.props, prevProps, optimized);
updateSlots(instance, nextVNode.children, optimized);
pauseTracking();
flushPreFlushCbs();
resetTracking();
};
const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
const c1 = n1 && n1.children;
const prevShapeFlag = n1 ? n1.shapeFlag : 0;
const c2 = n2.children;
const { patchFlag, shapeFlag } = n2;
if (patchFlag > 0) {
if (patchFlag & 128) {
patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
return;
} else if (patchFlag & 256) {
patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
return;
}
}
if (shapeFlag & 8) {
if (prevShapeFlag & 16) {
unmountChildren(c1, parentComponent, parentSuspense);
}
if (c2 !== c1) {
hostSetElementText(container, c2);
}
} else {
if (prevShapeFlag & 16) {
if (shapeFlag & 16) {
patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else {
unmountChildren(c1, parentComponent, parentSuspense, true);
}
} else {
if (prevShapeFlag & 8) {
hostSetElementText(container, "");
}
if (shapeFlag & 16) {
mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
}
}
}
};
const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
c1 = c1 || EMPTY_ARR;
c2 = c2 || EMPTY_ARR;
const oldLength = c1.length;
const newLength = c2.length;
const commonLength = Math.min(oldLength, newLength);
let i2;
for (i2 = 0; i2 < commonLength; i2++) {
const nextChild = c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]);
patch(c1[i2], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
}
if (oldLength > newLength) {
unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
} else {
mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
}
};
const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
let i2 = 0;
const l2 = c2.length;
let e1 = c1.length - 1;
let e2 = l2 - 1;
while (i2 <= e1 && i2 <= e2) {
const n1 = c1[i2];
const n2 = c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]);
if (isSameVNodeType(n1, n2)) {
patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else {
break;
}
i2++;
}
while (i2 <= e1 && i2 <= e2) {
const n1 = c1[e1];
const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
if (isSameVNodeType(n1, n2)) {
patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else {
break;
}
e1--;
e2--;
}
if (i2 > e1) {
if (i2 <= e2) {
const nextPos = e2 + 1;
const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
while (i2 <= e2) {
patch(null, c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
i2++;
}
}
} else if (i2 > e2) {
while (i2 <= e1) {
unmount(c1[i2], parentComponent, parentSuspense, true);
i2++;
}
} else {
const s1 = i2;
const s2 = i2;
const keyToNewIndexMap = /* @__PURE__ */ new Map();
for (i2 = s2; i2 <= e2; i2++) {
const nextChild = c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]);
if (nextChild.key != null) {
if (keyToNewIndexMap.has(nextChild.key)) {
warn$2(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
}
keyToNewIndexMap.set(nextChild.key, i2);
}
}
let j2;
let patched = 0;
const toBePatched = e2 - s2 + 1;
let moved = false;
let maxNewIndexSoFar = 0;
const newIndexToOldIndexMap = new Array(toBePatched);
for (i2 = 0; i2 < toBePatched; i2++)
newIndexToOldIndexMap[i2] = 0;
for (i2 = s1; i2 <= e1; i2++) {
const prevChild = c1[i2];
if (patched >= toBePatched) {
unmount(prevChild, parentComponent, parentSuspense, true);
continue;
}
let newIndex;
if (prevChild.key != null) {
newIndex = keyToNewIndexMap.get(prevChild.key);
} else {
for (j2 = s2; j2 <= e2; j2++) {
if (newIndexToOldIndexMap[j2 - s2] === 0 && isSameVNodeType(prevChild, c2[j2])) {
newIndex = j2;
break;
}
}
}
if (newIndex === void 0) {
unmount(prevChild, parentComponent, parentSuspense, true);
} else {
newIndexToOldIndexMap[newIndex - s2] = i2 + 1;
if (newIndex >= maxNewIndexSoFar) {
maxNewIndexSoFar = newIndex;
} else {
moved = true;
}
patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
patched++;
}
}
const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
j2 = increasingNewIndexSequence.length - 1;
for (i2 = toBePatched - 1; i2 >= 0; i2--) {
const nextIndex = s2 + i2;
const nextChild = c2[nextIndex];
const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
if (newIndexToOldIndexMap[i2] === 0) {
patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (moved) {
if (j2 < 0 || i2 !== increasingNewIndexSequence[j2]) {
move(
nextChild,
container,
anchor,
2
/* MoveType.REORDER */
);
} else {
j2--;
}
}
}
}
};
const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
const { el: el2, type, transition, children: children2, shapeFlag } = vnode;
if (shapeFlag & 6) {
move(vnode.component.subTree, container, anchor, moveType);
return;
}
if (shapeFlag & 128) {
vnode.suspense.move(container, anchor, moveType);
return;
}
if (shapeFlag & 64) {
type.move(vnode, container, anchor, internals);
return;
}
if (type === Fragment) {
hostInsert(el2, container, anchor);
for (let i2 = 0; i2 < children2.length; i2++) {
move(children2[i2], container, anchor, moveType);
}
hostInsert(vnode.anchor, container, anchor);
return;
}
if (type === Static) {
moveStaticNode(vnode, container, anchor);
return;
}
const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
if (needTransition) {
if (moveType === 0) {
transition.beforeEnter(el2);
hostInsert(el2, container, anchor);
queuePostRenderEffect(() => transition.enter(el2), parentSuspense);
} else {
const { leave, delayLeave, afterLeave } = transition;
const remove3 = () => hostInsert(el2, container, anchor);
const performLeave = () => {
leave(el2, () => {
remove3();
afterLeave && afterLeave();
});
};
if (delayLeave) {
delayLeave(el2, remove3, performLeave);
} else {
performLeave();
}
}
} else {
hostInsert(el2, container, anchor);
}
};
const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
const { type, props, ref: ref2, children: children2, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
if (ref2 != null) {
setRef(ref2, null, parentSuspense, vnode, true);
}
if (shapeFlag & 256) {
parentComponent.ctx.deactivate(vnode);
return;
}
const shouldInvokeDirs = shapeFlag & 1 && dirs;
const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
let vnodeHook;
if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
invokeVNodeHook(vnodeHook, parentComponent, vnode);
}
if (shapeFlag & 6) {
unmountComponent(vnode.component, parentSuspense, doRemove);
} else {
if (shapeFlag & 128) {
vnode.suspense.unmount(parentSuspense, doRemove);
return;
}
if (shouldInvokeDirs) {
invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
}
if (shapeFlag & 64) {
vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
} else if (dynamicChildren && // #1153: fast path should not be taken for non-stable (v-for) fragments
(type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
} else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
unmountChildren(children2, parentComponent, parentSuspense);
}
if (doRemove) {
remove2(vnode);
}
}
if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
queuePostRenderEffect(() => {
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
}, parentSuspense);
}
};
const remove2 = (vnode) => {
const { type, el: el2, anchor, transition } = vnode;
if (type === Fragment) {
if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
vnode.children.forEach((child) => {
if (child.type === Comment) {
hostRemove(child.el);
} else {
remove2(child);
}
});
} else {
removeFragment(el2, anchor);
}
return;
}
if (type === Static) {
removeStaticNode(vnode);
return;
}
const performRemove = () => {
hostRemove(el2);
if (transition && !transition.persisted && transition.afterLeave) {
transition.afterLeave();
}
};
if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
const { leave, delayLeave } = transition;
const performLeave = () => leave(el2, performRemove);
if (delayLeave) {
delayLeave(vnode.el, performRemove, performLeave);
} else {
performLeave();
}
} else {
performRemove();
}
};
const removeFragment = (cur, end) => {
let next;
while (cur !== end) {
next = hostNextSibling(cur);
hostRemove(cur);
cur = next;
}
hostRemove(end);
};
const unmountComponent = (instance, parentSuspense, doRemove) => {
if (instance.type.__hmrId) {
unregisterHMR(instance);
}
const { bum, scope, update: update2, subTree, um } = instance;
if (bum) {
invokeArrayFns(bum);
}
scope.stop();
if (update2) {
update2.active = false;
unmount(subTree, instance, parentSuspense, doRemove);
}
if (um) {
queuePostRenderEffect(um, parentSuspense);
}
queuePostRenderEffect(() => {
instance.isUnmounted = true;
}, parentSuspense);
if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
parentSuspense.deps--;
if (parentSuspense.deps === 0) {
parentSuspense.resolve();
}
}
{
devtoolsComponentRemoved(instance);
}
};
const unmountChildren = (children2, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
for (let i2 = start; i2 < children2.length; i2++) {
unmount(children2[i2], parentComponent, parentSuspense, doRemove, optimized);
}
};
const getNextHostNode = (vnode) => {
if (vnode.shapeFlag & 6) {
return getNextHostNode(vnode.component.subTree);
}
if (vnode.shapeFlag & 128) {
return vnode.suspense.next();
}
return hostNextSibling(vnode.anchor || vnode.el);
};
const render2 = (vnode, container, isSVG) => {
if (vnode == null) {
if (container._vnode) {
unmount(container._vnode, null, null, true);
}
} else {
patch(container._vnode || null, vnode, container, null, null, null, isSVG);
}
flushPreFlushCbs();
flushPostFlushCbs();
container._vnode = vnode;
};
const internals = {
p: patch,
um: unmount,
m: move,
r: remove2,
mt: mountComponent,
mc: mountChildren,
pc: patchChildren,
pbc: patchBlockChildren,
n: getNextHostNode,
o: options
};
let hydrate;
let hydrateNode;
if (createHydrationFns) {
[hydrate, hydrateNode] = createHydrationFns(internals);
}
return {
render: render2,
hydrate,
createApp: createAppAPI(render2, hydrate)
};
}
function toggleRecurse({ effect, update: update2 }, allowed) {
effect.allowRecurse = update2.allowRecurse = allowed;
}
function traverseStaticChildren(n1, n2, shallow = false) {
const ch1 = n1.children;
const ch2 = n2.children;
if (isArray$1(ch1) && isArray$1(ch2)) {
for (let i2 = 0; i2 < ch1.length; i2++) {
const c1 = ch1[i2];
let c2 = ch2[i2];
if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
c2 = ch2[i2] = cloneIfMounted(ch2[i2]);
c2.el = c1.el;
}
if (!shallow)
traverseStaticChildren(c1, c2);
}
if (c2.type === Text) {
c2.el = c1.el;
}
if (c2.type === Comment && !c2.el) {
c2.el = c1.el;
}
}
}
}
function getSequence(arr) {
const p2 = arr.slice();
const result = [0];
let i2, j2, u2, v2, c2;
const len = arr.length;
for (i2 = 0; i2 < len; i2++) {
const arrI = arr[i2];
if (arrI !== 0) {
j2 = result[result.length - 1];
if (arr[j2] < arrI) {
p2[i2] = j2;
result.push(i2);
continue;
}
u2 = 0;
v2 = result.length - 1;
while (u2 < v2) {
c2 = u2 + v2 >> 1;
if (arr[result[c2]] < arrI) {
u2 = c2 + 1;
} else {
v2 = c2;
}
}
if (arrI < arr[result[u2]]) {
if (u2 > 0) {
p2[i2] = result[u2 - 1];
}
result[u2] = i2;
}
}
}
u2 = result.length;
v2 = result[u2 - 1];
while (u2-- > 0) {
result[u2] = v2;
v2 = p2[v2];
}
return result;
}
const isTeleport = (type) => type.__isTeleport;
const Fragment = Symbol("Fragment");
const Text = Symbol("Text");
const Comment = Symbol("Comment");
const Static = Symbol("Static");
const blockStack = [];
let currentBlock = null;
function openBlock(disableTracking = false) {
blockStack.push(currentBlock = disableTracking ? null : []);
}
function closeBlock() {
blockStack.pop();
currentBlock = blockStack[blockStack.length - 1] || null;
}
let isBlockTreeEnabled = 1;
function setBlockTracking(value) {
isBlockTreeEnabled += value;
}
function setupBlock(vnode) {
vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
closeBlock();
if (isBlockTreeEnabled > 0 && currentBlock) {
currentBlock.push(vnode);
}
return vnode;
}
function createElementBlock(type, props, children2, patchFlag, dynamicProps, shapeFlag) {
return setupBlock(createBaseVNode(
type,
props,
children2,
patchFlag,
dynamicProps,
shapeFlag,
true
/* isBlock */
));
}
function createBlock(type, props, children2, patchFlag, dynamicProps) {
return setupBlock(createVNode(
type,
props,
children2,
patchFlag,
dynamicProps,
true
/* isBlock: prevent a block from tracking itself */
));
}
function isVNode(value) {
return value ? value.__v_isVNode === true : false;
}
function isSameVNodeType(n1, n2) {
if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
n1.shapeFlag &= ~256;
n2.shapeFlag &= ~512;
return false;
}
return n1.type === n2.type && n1.key === n2.key;
}
const createVNodeWithArgsTransform = (...args) => {
return _createVNode(...args);
};
const InternalObjectKey = `__vInternal`;
const normalizeKey = ({ key }) => key != null ? key : null;
const normalizeRef = ({ ref: ref2, ref_key, ref_for }) => {
return ref2 != null ? isString$1(ref2) || isRef(ref2) || isFunction$1(ref2) ? { i: currentRenderingInstance, r: ref2, k: ref_key, f: !!ref_for } : ref2 : null;
};
function createBaseVNode(type, props = null, children2 = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
const vnode = {
__v_isVNode: true,
__v_skip: true,
type,
props,
key: props && normalizeKey(props),
ref: props && normalizeRef(props),
scopeId: currentScopeId,
slotScopeIds: null,
children: children2,
component: null,
suspense: null,
ssContent: null,
ssFallback: null,
dirs: null,
transition: null,
el: null,
anchor: null,
target: null,
targetAnchor: null,
staticCount: 0,
shapeFlag,
patchFlag,
dynamicProps,
dynamicChildren: null,
appContext: null,
ctx: currentRenderingInstance
};
if (needFullChildrenNormalization) {
normalizeChildren(vnode, children2);
if (shapeFlag & 128) {
type.normalize(vnode);
}
} else if (children2) {
vnode.shapeFlag |= isString$1(children2) ? 8 : 16;
}
if (vnode.key !== vnode.key) {
warn$2(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
}
if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
!isBlockNode && // has current parent block
currentBlock && // presence of a patch flag indicates this node needs patching on updates.
// component nodes also should always be patched, because even if the
// component doesn't need to update, it needs to persist the instance on to
// the next vnode so that it can be properly unmounted later.
(vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
// vnode should not be considered dynamic due to handler caching.
vnode.patchFlag !== 32) {
currentBlock.push(vnode);
}
return vnode;
}
const createVNode = createVNodeWithArgsTransform;
function _createVNode(type, props = null, children2 = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
if (!type || type === NULL_DYNAMIC_COMPONENT) {
if (!type) {
warn$2(`Invalid vnode type when creating vnode: ${type}.`);
}
type = Comment;
}
if (isVNode(type)) {
const cloned = cloneVNode(
type,
props,
true
/* mergeRef: true */
);
if (children2) {
normalizeChildren(cloned, children2);
}
if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
if (cloned.shapeFlag & 6) {
currentBlock[currentBlock.indexOf(type)] = cloned;
} else {
currentBlock.push(cloned);
}
}
cloned.patchFlag |= -2;
return cloned;
}
if (isClassComponent(type)) {
type = type.__vccOpts;
}
if (props) {
props = guardReactiveProps(props);
let { class: klass, style } = props;
if (klass && !isString$1(klass)) {
props.class = normalizeClass(klass);
}
if (isObject(style)) {
if (isProxy(style) && !isArray$1(style)) {
style = extend({}, style);
}
props.style = normalizeStyle(style);
}
}
const shapeFlag = isString$1(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction$1(type) ? 2 : 0;
if (shapeFlag & 4 && isProxy(type)) {
type = toRaw(type);
warn$2(`Vue received a Component which was made a reactive object. This can lead to unnecessary performance overhead, and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`, `
Component that was made reactive: `, type);
}
return createBaseVNode(type, props, children2, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
}
function guardReactiveProps(props) {
if (!props)
return null;
return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props;
}
function cloneVNode(vnode, extraProps, mergeRef = false) {
const { props, ref: ref2, patchFlag, children: children2 } = vnode;
const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
const cloned = {
__v_isVNode: true,
__v_skip: true,
type: vnode.type,
props: mergedProps,
key: mergedProps && normalizeKey(mergedProps),
ref: extraProps && extraProps.ref ? (
// #2078 in the case of <component :is="vnode" ref="extra"/>
// if the vnode itself already has a ref, cloneVNode will need to merge
// the refs so the single vnode can be set on multiple refs
mergeRef && ref2 ? isArray$1(ref2) ? ref2.concat(normalizeRef(extraProps)) : [ref2, normalizeRef(extraProps)] : normalizeRef(extraProps)
) : ref2,
scopeId: vnode.scopeId,
slotScopeIds: vnode.slotScopeIds,
children: patchFlag === -1 && isArray$1(children2) ? children2.map(deepCloneVNode) : children2,
target: vnode.target,
targetAnchor: vnode.targetAnchor,
staticCount: vnode.staticCount,
shapeFlag: vnode.shapeFlag,
// if the vnode is cloned with extra props, we can no longer assume its
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
// note: preserve flag for fragments since they use the flag for children
// fast paths only.
patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
dynamicProps: vnode.dynamicProps,
dynamicChildren: vnode.dynamicChildren,
appContext: vnode.appContext,
dirs: vnode.dirs,
transition: vnode.transition,
// These should technically only be non-null on mounted VNodes. However,
// they *should* be copied for kept-alive vnodes. So we just always copy
// them since them being non-null during a mount doesn't affect the logic as
// they will simply be overwritten.
component: vnode.component,
suspense: vnode.suspense,
ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
el: vnode.el,
anchor: vnode.anchor,
ctx: vnode.ctx,
ce: vnode.ce
};
return cloned;
}
function deepCloneVNode(vnode) {
const cloned = cloneVNode(vnode);
if (isArray$1(vnode.children)) {
cloned.children = vnode.children.map(deepCloneVNode);
}
return cloned;
}
function createTextVNode(text2 = " ", flag = 0) {
return createVNode(Text, null, text2, flag);
}
function createStaticVNode(content, numberOfNodes) {
const vnode = createVNode(Static, null, content);
vnode.staticCount = numberOfNodes;
return vnode;
}
function createCommentVNode(text2 = "", asBlock = false) {
return asBlock ? (openBlock(), createBlock(Comment, null, text2)) : createVNode(Comment, null, text2);
}
function normalizeVNode(child) {
if (child == null || typeof child === "boolean") {
return createVNode(Comment);
} else if (isArray$1(child)) {
return createVNode(
Fragment,
null,
// #3666, avoid reference pollution when reusing vnode
child.slice()
);
} else if (typeof child === "object") {
return cloneIfMounted(child);
} else {
return createVNode(Text, null, String(child));
}
}
function cloneIfMounted(child) {
return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
}
function normalizeChildren(vnode, children2) {
let type = 0;
const { shapeFlag } = vnode;
if (children2 == null) {
children2 = null;
} else if (isArray$1(children2)) {
type = 16;
} else if (typeof children2 === "object") {
if (shapeFlag & (1 | 64)) {
const slot = children2.default;
if (slot) {
slot._c && (slot._d = false);
normalizeChildren(vnode, slot());
slot._c && (slot._d = true);
}
return;
} else {
type = 32;
const slotFlag = children2._;
if (!slotFlag && !(InternalObjectKey in children2)) {
children2._ctx = currentRenderingInstance;
} else if (slotFlag === 3 && currentRenderingInstance) {
if (currentRenderingInstance.slots._ === 1) {
children2._ = 1;
} else {
children2._ = 2;
vnode.patchFlag |= 1024;
}
}
}
} else if (isFunction$1(children2)) {
children2 = { default: children2, _ctx: currentRenderingInstance };
type = 32;
} else {
children2 = String(children2);
if (shapeFlag & 64) {
type = 16;
children2 = [createTextVNode(children2)];
} else {
type = 8;
}
}
vnode.children = children2;
vnode.shapeFlag |= type;
}
function mergeProps(...args) {
const ret = {};
for (let i2 = 0; i2 < args.length; i2++) {
const toMerge = args[i2];
for (const key in toMerge) {
if (key === "class") {
if (ret.class !== toMerge.class) {
ret.class = normalizeClass([ret.class, toMerge.class]);
}
} else if (key === "style") {
ret.style = normalizeStyle([ret.style, toMerge.style]);
} else if (isOn(key)) {
const existing = ret[key];
const incoming = toMerge[key];
if (incoming && existing !== incoming && !(isArray$1(existing) && existing.includes(incoming))) {
ret[key] = existing ? [].concat(existing, incoming) : incoming;
}
} else if (key !== "") {
ret[key] = toMerge[key];
}
}
}
return ret;
}
function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
callWithAsyncErrorHandling(hook, instance, 7, [
vnode,
prevVNode
]);
}
const emptyAppContext = createAppContext();
let uid$2 = 0;
function createComponentInstance(vnode, parent, suspense) {
const type = vnode.type;
const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
const instance = {
uid: uid$2++,
vnode,
type,
parent,
appContext,
root: null,
next: null,
subTree: null,
effect: null,
update: null,
scope: new EffectScope(
true
/* detached */
),
render: null,
proxy: null,
exposed: null,
exposeProxy: null,
withProxy: null,
provides: parent ? parent.provides : Object.create(appContext.provides),
accessCache: null,
renderCache: [],
// local resolved assets
components: null,
directives: null,
// resolved props and emits options
propsOptions: normalizePropsOptions(type, appContext),
emitsOptions: normalizeEmitsOptions(type, appContext),
// emit
emit: null,
emitted: null,
// props default value
propsDefaults: EMPTY_OBJ,
// inheritAttrs
inheritAttrs: type.inheritAttrs,
// state
ctx: EMPTY_OBJ,
data: EMPTY_OBJ,
props: EMPTY_OBJ,
attrs: EMPTY_OBJ,
slots: EMPTY_OBJ,
refs: EMPTY_OBJ,
setupState: EMPTY_OBJ,
setupContext: null,
// suspense related
suspense,
suspenseId: suspense ? suspense.pendingId : 0,
asyncDep: null,
asyncResolved: false,
// lifecycle hooks
// not using enums here because it results in computed properties
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.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, config2) {
const appIsNativeTag = config2.isNativeTag || NO;
if (isBuiltInTag(name) || appIsNativeTag(name)) {
warn$2("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, children: children2 } = instance.vnode;
const isStateful = isStatefulComponent(instance);
initProps(instance, props, isStateful, isSSR);
initSlots(instance, children2);
const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
isInSSRComponentSetup = false;
return setupResult;
}
function setupStatefulComponent(instance, isSSR) {
var _a3;
const Component = instance.type;
{
if (Component.name) {
validateComponentName(Component.name, instance.appContext.config);
}
if (Component.components) {
const names = Object.keys(Component.components);
for (let i2 = 0; i2 < names.length; i2++) {
validateComponentName(names[i2], instance.appContext.config);
}
}
if (Component.directives) {
const names = Object.keys(Component.directives);
for (let i2 = 0; i2 < names.length; i2++) {
validateDirectiveName(names[i2]);
}
}
if (Component.compilerOptions && isRuntimeOnly()) {
warn$2(`"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 } = Component;
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);
if (isSSR) {
return setupResult.then((resolvedResult) => {
handleSetupResult(instance, resolvedResult, isSSR);
}).catch((e2) => {
handleError(
e2,
instance,
0
/* ErrorCodes.SETUP_FUNCTION */
);
});
} else {
instance.asyncDep = setupResult;
if (!instance.suspense) {
const name = (_a3 = Component.name) !== null && _a3 !== void 0 ? _a3 : "Anonymous";
warn$2(`Component <${name}>: setup function returned a promise, but no <Suspense> boundary was found in the parent component tree. A component with async setup() must be nested in a <Suspense> in order to be rendered.`);
}
}
} else {
handleSetupResult(instance, setupResult, isSSR);
}
} else {
finishComponentSetup(instance, isSSR);
}
}
function handleSetupResult(instance, setupResult, isSSR) {
if (isFunction$1(setupResult)) {
if (instance.type.__ssrInlineRender) {
instance.ssrRender = setupResult;
} else {
instance.render = setupResult;
}
} else if (isObject(setupResult)) {
if (isVNode(setupResult)) {
warn$2(`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$2(`setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`);
}
finishComponentSetup(instance, isSSR);
}
let compile$1;
const isRuntimeOnly = () => !compile$1;
function finishComponentSetup(instance, isSSR, skipOptions) {
const Component = instance.type;
if (!instance.render) {
if (!isSSR && compile$1 && !Component.render) {
const template = Component.template || resolveMergedOptions(instance).template;
if (template) {
{
startMeasure(instance, `compile`);
}
const { isCustomElement, compilerOptions } = instance.appContext.config;
const { delimiters, compilerOptions: componentCompilerOptions } = Component;
const finalCompilerOptions = extend(extend({
isCustomElement,
delimiters
}, compilerOptions), componentCompilerOptions);
Component.render = compile$1(template, finalCompilerOptions);
{
endMeasure(instance, `compile`);
}
}
}
instance.render = Component.render || NOOP;
}
{
setCurrentInstance(instance);
pauseTracking();
applyOptions(instance);
resetTracking();
unsetCurrentInstance();
}
if (!Component.render && instance.render === NOOP && !isSSR) {
if (Component.template) {
warn$2(
`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".`
/* should not happen */
);
} else {
warn$2(`Component is missing template or render function.`);
}
}
}
function createAttrsProxy(instance) {
return new Proxy(
instance.attrs,
{
get(target, key) {
markAttrsAccessed();
track(instance, "get", "$attrs");
return target[key];
},
set() {
warn$2(`setupContext.attrs is readonly.`);
return false;
},
deleteProperty() {
warn$2(`setupContext.attrs is readonly.`);
return false;
}
}
);
}
function createSetupContext(instance) {
const expose = (exposed) => {
{
if (instance.exposed) {
warn$2(`expose() should be called only once per setup().`);
}
if (exposed != null) {
let exposedType = typeof exposed;
if (exposedType === "object") {
if (isArray$1(exposed)) {
exposedType = "array";
} else if (isRef(exposed)) {
exposedType = "ref";
}
}
if (exposedType !== "object") {
warn$2(`expose() should be passed a plain object, received ${exposedType}.`);
}
}
}
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];
} else if (key in publicPropertiesMap) {
return publicPropertiesMap[key](instance);
}
},
has(target, key) {
return key in target || key in publicPropertiesMap;
}
}));
}
}
const classifyRE = /(?:^|[-_])(\w)/g;
const classify = (str) => str.replace(classifyRE, (c2) => c2.toUpperCase()).replace(/[-_]/g, "");
function getComponentName(Component, includeInferred = true) {
return isFunction$1(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
}
function formatComponentName(instance, Component, isRoot = false) {
let name = getComponentName(Component);
if (!name && Component.__file) {
const match = Component.__file.match(/([^/\\]+)\.\w+$/);
if (match) {
name = match[1];
}
}
if (!name && instance && instance.parent) {
const inferFromRegistry = (registry) => {
for (const key in registry) {
if (registry[key] === Component) {
return key;
}
}
};
name = inferFromRegistry(instance.components || instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
}
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
}
function isClassComponent(value) {
return isFunction$1(value) && "__vccOpts" in value;
}
const computed = (getterOrOptions, debugOptions) => {
return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
};
function h$1(type, propsOrChildren, children2) {
const l = arguments.length;
if (l === 2) {
if (isObject(propsOrChildren) && !isArray$1(propsOrChildren)) {
if (isVNode(propsOrChildren)) {
return createVNode(type, null, [propsOrChildren]);
}
return createVNode(type, propsOrChildren);
} else {
return createVNode(type, null, propsOrChildren);
}
} else {
if (l > 3) {
children2 = Array.prototype.slice.call(arguments, 2);
} else if (l === 3 && isVNode(children2)) {
children2 = [children2];
}
return createVNode(type, propsOrChildren, children2);
}
}
const ssrContextKey = Symbol(`ssrContext`);
const useSSRContext = () => {
{
const ctx = inject(ssrContextKey);
if (!ctx) {
warn$2(`Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`);
}
return ctx;
}
};
function isShallow(value) {
return !!(value && value[
"__v_isShallow"
/* ReactiveFlags.IS_SHALLOW */
]);
}
function initCustomFormatter() {
if (typeof window === "undefined") {
return;
}
const vueStyle = { style: "color:#3ba776" };
const numberStyle = { style: "color:#0b1bc9" };
const stringStyle = { style: "color:#b62e24" };
const keywordStyle = { style: "color:#9d288c" };
const formatter = {
header(obj) {
if (!isObject(obj)) {
return null;
}
if (obj.__isVue) {
return ["div", vueStyle, `VueInstance`];
} else if (isRef(obj)) {
return [
"div",
{},
["span", vueStyle, genRefFlag(obj)],
"<",
formatValue(obj.value),
`>`
];
} else if (isReactive(obj)) {
return [
"div",
{},
["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
"<",
formatValue(obj),
`>${isReadonly(obj) ? ` (readonly)` : ``}`
];
} else if (isReadonly(obj)) {
return [
"div",
{},
["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
"<",
formatValue(obj),
">"
];
}
return null;
},
hasBody(obj) {
return obj && obj.__isVue;
},
body(obj) {
if (obj && obj.__isVue) {
return [
"div",
{},
...formatInstance(obj.$)
];
}
}
};
function formatInstance(instance) {
const blocks = [];
if (instance.type.props && instance.props) {
blocks.push(createInstanceBlock("props", toRaw(instance.props)));
}
if (instance.setupState !== EMPTY_OBJ) {
blocks.push(createInstanceBlock("setup", instance.setupState));
}
if (instance.data !== EMPTY_OBJ) {
blocks.push(createInstanceBlock("data", toRaw(instance.data)));
}
const computed2 = extractKeys(instance, "computed");
if (computed2) {
blocks.push(createInstanceBlock("computed", computed2));
}
const injected = extractKeys(instance, "inject");
if (injected) {
blocks.push(createInstanceBlock("injected", injected));
}
blocks.push([
"div",
{},
[
"span",
{
style: keywordStyle.style + ";opacity:0.66"
},
"$ (internal): "
],
["object", { object: instance }]
]);
return blocks;
}
function createInstanceBlock(type, target) {
target = extend({}, target);
if (!Object.keys(target).length) {
return ["span", {}];
}
return [
"div",
{ style: "line-height:1.25em;margin-bottom:0.6em" },
[
"div",
{
style: "color:#476582"
},
type
],
[
"div",
{
style: "padding-left:1.25em"
},
...Object.keys(target).map((key) => {
return [
"div",
{},
["span", keywordStyle, key + ": "],
formatValue(target[key], false)
];
})
]
];
}
function formatValue(v2, asRaw = true) {
if (typeof v2 === "number") {
return ["span", numberStyle, v2];
} else if (typeof v2 === "string") {
return ["span", stringStyle, JSON.stringify(v2)];
} else if (typeof v2 === "boolean") {
return ["span", keywordStyle, v2];
} else if (isObject(v2)) {
return ["object", { object: asRaw ? toRaw(v2) : v2 }];
} else {
return ["span", stringStyle, String(v2)];
}
}
function extractKeys(instance, type) {
const Comp = instance.type;
if (isFunction$1(Comp)) {
return;
}
const extracted = {};
for (const key in instance.ctx) {
if (isKeyOfType(Comp, key, type)) {
extracted[key] = instance.ctx[key];
}
}
return extracted;
}
function isKeyOfType(Comp, key, type) {
const opts = Comp[type];
if (isArray$1(opts) && opts.includes(key) || isObject(opts) && key in opts) {
return true;
}
if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
return true;
}
if (Comp.mixins && Comp.mixins.some((m2) => isKeyOfType(m2, key, type))) {
return true;
}
}
function genRefFlag(v2) {
if (isShallow(v2)) {
return `ShallowRef`;
}
if (v2.effect) {
return `ComputedRef`;
}
return `Ref`;
}
if (window.devtoolsFormatters) {
window.devtoolsFormatters.push(formatter);
} else {
window.devtoolsFormatters = [formatter];
}
}
const version$1 = "3.2.47";
const svgNS = "http://www.w3.org/2000/svg";
const doc = typeof document !== "undefined" ? document : null;
const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
const nodeOps = {
insert: (child, parent, anchor) => {
parent.insertBefore(child, anchor || null);
},
remove: (child) => {
const parent = child.parentNode;
if (parent) {
parent.removeChild(child);
}
},
createElement: (tag, isSVG, is2, props) => {
const el2 = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is2 ? { is: is2 } : void 0);
if (tag === "select" && props && props.multiple != null) {
el2.setAttribute("multiple", props.multiple);
}
return el2;
},
createText: (text2) => doc.createTextNode(text2),
createComment: (text2) => doc.createComment(text2),
setText: (node, text2) => {
node.nodeValue = text2;
},
setElementText: (el2, text2) => {
el2.textContent = text2;
},
parentNode: (node) => node.parentNode,
nextSibling: (node) => node.nextSibling,
querySelector: (selector) => doc.querySelector(selector),
setScopeId(el2, id2) {
el2.setAttribute(id2, "");
},
// __UNSAFE__
// Reason: innerHTML.
// Static content here can only come from compiled templates.
// As long as the user only uses trusted templates, this is safe.
insertStaticContent(content, parent, anchor, isSVG, start, end) {
const before = anchor ? anchor.previousSibling : parent.lastChild;
if (start && (start === end || start.nextSibling)) {
while (true) {
parent.insertBefore(start.cloneNode(true), anchor);
if (start === end || !(start = start.nextSibling))
break;
}
} else {
templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
const template = templateContainer.content;
if (isSVG) {
const wrapper = template.firstChild;
while (wrapper.firstChild) {
template.appendChild(wrapper.firstChild);
}
template.removeChild(wrapper);
}
parent.insertBefore(template, anchor);
}
return [
// first
before ? before.nextSibling : parent.firstChild,
// last
anchor ? anchor.previousSibling : parent.lastChild
];
}
};
function patchClass(el2, value, isSVG) {
const transitionClasses = el2._vtc;
if (transitionClasses) {
value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
}
if (value == null) {
el2.removeAttribute("class");
} else if (isSVG) {
el2.setAttribute("class", value);
} else {
el2.className = value;
}
}
function patchStyle(el2, prev, next) {
const style = el2.style;
const isCssString = isString$1(next);
if (next && !isCssString) {
if (prev && !isString$1(prev)) {
for (const key in prev) {
if (next[key] == null) {
setStyle(style, key, "");
}
}
}
for (const key in next) {
setStyle(style, key, next[key]);
}
} else {
const currentDisplay = style.display;
if (isCssString) {
if (prev !== next) {
style.cssText = next;
}
} else if (prev) {
el2.removeAttribute("style");
}
if ("_vod" in el2) {
style.display = currentDisplay;
}
}
}
const semicolonRE = /[^\\];\s*$/;
const importantRE = /\s*!important$/;
function setStyle(style, name, val) {
if (isArray$1(val)) {
val.forEach((v2) => setStyle(style, name, v2));
} else {
if (val == null)
val = "";
{
if (semicolonRE.test(val)) {
warn$2(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
}
}
if (name.startsWith("--")) {
style.setProperty(name, val);
} else {
const prefixed = autoPrefix(style, name);
if (importantRE.test(val)) {
style.setProperty(hyphenate(prefixed), val.replace(importantRE, ""), "important");
} else {
style[prefixed] = val;
}
}
}
}
const prefixes = ["Webkit", "Moz", "ms"];
const prefixCache = {};
function autoPrefix(style, rawName) {
const cached = prefixCache[rawName];
if (cached) {
return cached;
}
let name = camelize(rawName);
if (name !== "filter" && name in style) {
return prefixCache[rawName] = name;
}
name = capitalize(name);
for (let i2 = 0; i2 < prefixes.length; i2++) {
const prefixed = prefixes[i2] + name;
if (prefixed in style) {
return prefixCache[rawName] = prefixed;
}
}
return rawName;
}
const xlinkNS = "http://www.w3.org/1999/xlink";
function patchAttr(el2, key, value, isSVG, instance) {
if (isSVG && key.startsWith("xlink:")) {
if (value == null) {
el2.removeAttributeNS(xlinkNS, key.slice(6, key.length));
} else {
el2.setAttributeNS(xlinkNS, key, value);
}
} else {
const isBoolean2 = isSpecialBooleanAttr(key);
if (value == null || isBoolean2 && !includeBooleanAttr(value)) {
el2.removeAttribute(key);
} else {
el2.setAttribute(key, isBoolean2 ? "" : value);
}
}
}
function patchDOMProp(el2, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
if (key === "innerHTML" || key === "textContent") {
if (prevChildren) {
unmountChildren(prevChildren, parentComponent, parentSuspense);
}
el2[key] = value == null ? "" : value;
return;
}
if (key === "value" && el2.tagName !== "PROGRESS" && // custom elements may use _value internally
!el2.tagName.includes("-")) {
el2._value = value;
const newValue = value == null ? "" : value;
if (el2.value !== newValue || // #4956: always set for OPTION elements because its value falls back to
// textContent if no value attribute is present. And setting .value for
// OPTION has no side effect
el2.tagName === "OPTION") {
el2.value = newValue;
}
if (value == null) {
el2.removeAttribute(key);
}
return;
}
let needRemove = false;
if (value === "" || value == null) {
const type = typeof el2[key];
if (type === "boolean") {
value = includeBooleanAttr(value);
} else if (value == null && type === "string") {
value = "";
needRemove = true;
} else if (type === "number") {
value = 0;
needRemove = true;
}
}
try {
el2[key] = value;
} catch (e2) {
if (!needRemove) {
warn$2(`Failed setting prop "${key}" on <${el2.tagName.toLowerCase()}>: value ${value} is invalid.`, e2);
}
}
needRemove && el2.removeAttribute(key);
}
function addEventListener(el2, event, handler, options) {
el2.addEventListener(event, handler, options);
}
function removeEventListener(el2, event, handler, options) {
el2.removeEventListener(event, handler, options);
}
function patchEvent(el2, rawName, prevValue, nextValue, instance = null) {
const invokers = el2._vei || (el2._vei = {});
const existingInvoker = invokers[rawName];
if (nextValue && existingInvoker) {
existingInvoker.value = nextValue;
} else {
const [name, options] = parseName(rawName);
if (nextValue) {
const invoker = invokers[rawName] = createInvoker(nextValue, instance);
addEventListener(el2, name, invoker, options);
} else if (existingInvoker) {
removeEventListener(el2, name, existingInvoker, options);
invokers[rawName] = void 0;
}
}
}
const optionsModifierRE = /(?:Once|Passive|Capture)$/;
function parseName(name) {
let options;
if (optionsModifierRE.test(name)) {
options = {};
let m2;
while (m2 = name.match(optionsModifierRE)) {
name = name.slice(0, name.length - m2[0].length);
options[m2[0].toLowerCase()] = true;
}
}
const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
return [event, options];
}
let cachedNow = 0;
const p = /* @__PURE__ */ Promise.resolve();
const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
function createInvoker(initialValue, instance) {
const invoker = (e2) => {
if (!e2._vts) {
e2._vts = Date.now();
} else if (e2._vts <= invoker.attached) {
return;
}
callWithAsyncErrorHandling(patchStopImmediatePropagation(e2, invoker.value), instance, 5, [e2]);
};
invoker.value = initialValue;
invoker.attached = getNow();
return invoker;
}
function patchStopImmediatePropagation(e2, value) {
if (isArray$1(value)) {
const originalStop = e2.stopImmediatePropagation;
e2.stopImmediatePropagation = () => {
originalStop.call(e2);
e2._stopped = true;
};
return value.map((fn2) => (e3) => !e3._stopped && fn2 && fn2(e3));
} else {
return value;
}
}
const nativeOnRE = /^on[a-z]/;
const patchProp = (el2, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
if (key === "class") {
patchClass(el2, nextValue, isSVG);
} else if (key === "style") {
patchStyle(el2, prevValue, nextValue);
} else if (isOn(key)) {
if (!isModelListener(key)) {
patchEvent(el2, key, prevValue, nextValue, parentComponent);
}
} else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el2, key, nextValue, isSVG)) {
patchDOMProp(el2, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
} else {
if (key === "true-value") {
el2._trueValue = nextValue;
} else if (key === "false-value") {
el2._falseValue = nextValue;
}
patchAttr(el2, key, nextValue, isSVG);
}
};
function shouldSetAsProp(el2, key, value, isSVG) {
if (isSVG) {
if (key === "innerHTML" || key === "textContent") {
return true;
}
if (key in el2 && nativeOnRE.test(key) && isFunction$1(value)) {
return true;
}
return false;
}
if (key === "spellcheck" || key === "draggable" || key === "translate") {
return false;
}
if (key === "form") {
return false;
}
if (key === "list" && el2.tagName === "INPUT") {
return false;
}
if (key === "type" && el2.tagName === "TEXTAREA") {
return false;
}
if (nativeOnRE.test(key) && isString$1(value)) {
return false;
}
return key in el2;
}
function useCssVars(getter) {
const instance = getCurrentInstance();
if (!instance) {
warn$2(`useCssVars is called without current active component instance.`);
return;
}
const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach((node) => setVarsOnNode(node, vars));
};
const setVars = () => {
const vars = getter(instance.proxy);
setVarsOnVNode(instance.subTree, vars);
updateTeleports(vars);
};
watchPostEffect(setVars);
onMounted(() => {
const ob = new MutationObserver(setVars);
ob.observe(instance.subTree.el.parentNode, { childList: true });
onUnmounted(() => ob.disconnect());
});
}
function setVarsOnVNode(vnode, vars) {
if (vnode.shapeFlag & 128) {
const suspense = vnode.suspense;
vnode = suspense.activeBranch;
if (suspense.pendingBranch && !suspense.isHydrating) {
suspense.effects.push(() => {
setVarsOnVNode(suspense.activeBranch, vars);
});
}
}
while (vnode.component) {
vnode = vnode.component.subTree;
}
if (vnode.shapeFlag & 1 && vnode.el) {
setVarsOnNode(vnode.el, vars);
} else if (vnode.type === Fragment) {
vnode.children.forEach((c2) => setVarsOnVNode(c2, vars));
} else if (vnode.type === Static) {
let { el: el2, anchor } = vnode;
while (el2) {
setVarsOnNode(el2, vars);
if (el2 === anchor)
break;
el2 = el2.nextSibling;
}
}
}
function setVarsOnNode(el2, vars) {
if (el2.nodeType === 1) {
const style = el2.style;
for (const key in vars) {
style.setProperty(`--${key}`, vars[key]);
}
}
}
const TRANSITION = "transition";
const ANIMATION = "animation";
const Transition = (props, { slots }) => h$1(BaseTransition, resolveTransitionProps(props), slots);
Transition.displayName = "Transition";
const DOMTransitionPropsValidators = {
name: String,
type: String,
css: {
type: Boolean,
default: true
},
duration: [String, Number, Object],
enterFromClass: String,
enterActiveClass: String,
enterToClass: String,
appearFromClass: String,
appearActiveClass: String,
appearToClass: String,
leaveFromClass: String,
leaveActiveClass: String,
leaveToClass: String
};
const TransitionPropsValidators = Transition.props = /* @__PURE__ */ extend({}, BaseTransition.props, DOMTransitionPropsValidators);
const callHook = (hook, args = []) => {
if (isArray$1(hook)) {
hook.forEach((h2) => h2(...args));
} else if (hook) {
hook(...args);
}
};
const hasExplicitCallback = (hook) => {
return hook ? isArray$1(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
};
function resolveTransitionProps(rawProps) {
const baseProps = {};
for (const key in rawProps) {
if (!(key in DOMTransitionPropsValidators)) {
baseProps[key] = rawProps[key];
}
}
if (rawProps.css === false) {
return baseProps;
}
const { name = "v", type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
const durations = normalizeDuration(duration);
const enterDuration = durations && durations[0];
const leaveDuration = durations && durations[1];
const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
const finishEnter = (el2, isAppear, done) => {
removeTransitionClass(el2, isAppear ? appearToClass : enterToClass);
removeTransitionClass(el2, isAppear ? appearActiveClass : enterActiveClass);
done && done();
};
const finishLeave = (el2, done) => {
el2._isLeaving = false;
removeTransitionClass(el2, leaveFromClass);
removeTransitionClass(el2, leaveToClass);
removeTransitionClass(el2, leaveActiveClass);
done && done();
};
const makeEnterHook = (isAppear) => {
return (el2, done) => {
const hook = isAppear ? onAppear : onEnter;
const resolve2 = () => finishEnter(el2, isAppear, done);
callHook(hook, [el2, resolve2]);
nextFrame$1(() => {
removeTransitionClass(el2, isAppear ? appearFromClass : enterFromClass);
addTransitionClass(el2, isAppear ? appearToClass : enterToClass);
if (!hasExplicitCallback(hook)) {
whenTransitionEnds(el2, type, enterDuration, resolve2);
}
});
};
};
return extend(baseProps, {
onBeforeEnter(el2) {
callHook(onBeforeEnter, [el2]);
addTransitionClass(el2, enterFromClass);
addTransitionClass(el2, enterActiveClass);
},
onBeforeAppear(el2) {
callHook(onBeforeAppear, [el2]);
addTransitionClass(el2, appearFromClass);
addTransitionClass(el2, appearActiveClass);
},
onEnter: makeEnterHook(false),
onAppear: makeEnterHook(true),
onLeave(el2, done) {
el2._isLeaving = true;
const resolve2 = () => finishLeave(el2, done);
addTransitionClass(el2, leaveFromClass);
forceReflow();
addTransitionClass(el2, leaveActiveClass);
nextFrame$1(() => {
if (!el2._isLeaving) {
return;
}
removeTransitionClass(el2, leaveFromClass);
addTransitionClass(el2, leaveToClass);
if (!hasExplicitCallback(onLeave)) {
whenTransitionEnds(el2, type, leaveDuration, resolve2);
}
});
callHook(onLeave, [el2, resolve2]);
},
onEnterCancelled(el2) {
finishEnter(el2, false);
callHook(onEnterCancelled, [el2]);
},
onAppearCancelled(el2) {
finishEnter(el2, true);
callHook(onAppearCancelled, [el2]);
},
onLeaveCancelled(el2) {
finishLeave(el2);
callHook(onLeaveCancelled, [el2]);
}
});
}
function normalizeDuration(duration) {
if (duration == null) {
return null;
} else if (isObject(duration)) {
return [NumberOf(duration.enter), NumberOf(duration.leave)];
} else {
const n2 = NumberOf(duration);
return [n2, n2];
}
}
function NumberOf(val) {
const res = toNumber(val);
{
assertNumber(res, "<transition> explicit duration");
}
return res;
}
function addTransitionClass(el2, cls) {
cls.split(/\s+/).forEach((c2) => c2 && el2.classList.add(c2));
(el2._vtc || (el2._vtc = /* @__PURE__ */ new Set())).add(cls);
}
function removeTransitionClass(el2, cls) {
cls.split(/\s+/).forEach((c2) => c2 && el2.classList.remove(c2));
const { _vtc } = el2;
if (_vtc) {
_vtc.delete(cls);
if (!_vtc.size) {
el2._vtc = void 0;
}
}
}
function nextFrame$1(cb) {
requestAnimationFrame(() => {
requestAnimationFrame(cb);
});
}
let endId = 0;
function whenTransitionEnds(el2, expectedType, explicitTimeout, resolve2) {
const id2 = el2._endId = ++endId;
const resolveIfNotStale = () => {
if (id2 === el2._endId) {
resolve2();
}
};
if (explicitTimeout) {
return setTimeout(resolveIfNotStale, explicitTimeout);
}
const { type, timeout, propCount } = getTransitionInfo(el2, expectedType);
if (!type) {
return resolve2();
}
const endEvent = type + "end";
let ended = 0;
const end = () => {
el2.removeEventListener(endEvent, onEnd);
resolveIfNotStale();
};
const onEnd = (e2) => {
if (e2.target === el2 && ++ended >= propCount) {
end();
}
};
setTimeout(() => {
if (ended < propCount) {
end();
}
}, timeout + 1);
el2.addEventListener(endEvent, onEnd);
}
function getTransitionInfo(el2, expectedType) {
const styles = window.getComputedStyle(el2);
const getStyleProperties = (key) => (styles[key] || "").split(", ");
const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
const animationTimeout = getTimeout(animationDelays, animationDurations);
let type = null;
let timeout = 0;
let propCount = 0;
if (expectedType === TRANSITION) {
if (transitionTimeout > 0) {
type = TRANSITION;
timeout = transitionTimeout;
propCount = transitionDurations.length;
}
} else if (expectedType === ANIMATION) {
if (animationTimeout > 0) {
type = ANIMATION;
timeout = animationTimeout;
propCount = animationDurations.length;
}
} else {
timeout = Math.max(transitionTimeout, animationTimeout);
type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
}
const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
return {
type,
timeout,
propCount,
hasTransform
};
}
function getTimeout(delays, durations) {
while (delays.length < durations.length) {
delays = delays.concat(delays);
}
return Math.max(...durations.map((d2, i2) => toMs(d2) + toMs(delays[i2])));
}
function toMs(s) {
return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
}
function forceReflow() {
return document.body.offsetHeight;
}
const positionMap = /* @__PURE__ */ new WeakMap();
const newPositionMap = /* @__PURE__ */ new WeakMap();
const TransitionGroupImpl = {
name: "TransitionGroup",
props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
tag: String,
moveClass: String
}),
setup(props, { slots }) {
const instance = getCurrentInstance();
const state = useTransitionState();
let prevChildren;
let children2;
onUpdated(() => {
if (!prevChildren.length) {
return;
}
const moveClass = props.moveClass || `${props.name || "v"}-move`;
if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
return;
}
prevChildren.forEach(callPendingCbs);
prevChildren.forEach(recordPosition);
const movedChildren = prevChildren.filter(applyTranslation);
forceReflow();
movedChildren.forEach((c2) => {
const el2 = c2.el;
const style = el2.style;
addTransitionClass(el2, moveClass);
style.transform = style.webkitTransform = style.transitionDuration = "";
const cb = el2._moveCb = (e2) => {
if (e2 && e2.target !== el2) {
return;
}
if (!e2 || /transform$/.test(e2.propertyName)) {
el2.removeEventListener("transitionend", cb);
el2._moveCb = null;
removeTransitionClass(el2, moveClass);
}
};
el2.addEventListener("transitionend", cb);
});
});
return () => {
const rawProps = toRaw(props);
const cssTransitionProps = resolveTransitionProps(rawProps);
let tag = rawProps.tag || Fragment;
prevChildren = children2;
children2 = slots.default ? getTransitionRawChildren(slots.default()) : [];
for (let i2 = 0; i2 < children2.length; i2++) {
const child = children2[i2];
if (child.key != null) {
setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
} else {
warn$2(`<TransitionGroup> children must be keyed.`);
}
}
if (prevChildren) {
for (let i2 = 0; i2 < prevChildren.length; i2++) {
const child = prevChildren[i2];
setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
positionMap.set(child, child.el.getBoundingClientRect());
}
}
return createVNode(tag, null, children2);
};
}
};
const removeMode = (props) => delete props.mode;
/* @__PURE__ */ removeMode(TransitionGroupImpl.props);
function callPendingCbs(c2) {
const el2 = c2.el;
if (el2._moveCb) {
el2._moveCb();
}
if (el2._enterCb) {
el2._enterCb();
}
}
function recordPosition(c2) {
newPositionMap.set(c2, c2.el.getBoundingClientRect());
}
function applyTranslation(c2) {
const oldPos = positionMap.get(c2);
const newPos = newPositionMap.get(c2);
const dx = oldPos.left - newPos.left;
const dy = oldPos.top - newPos.top;
if (dx || dy) {
const s = c2.el.style;
s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
s.transitionDuration = "0s";
return c2;
}
}
function hasCSSTransform(el2, root, moveClass) {
const clone2 = el2.cloneNode();
if (el2._vtc) {
el2._vtc.forEach((cls) => {
cls.split(/\s+/).forEach((c2) => c2 && clone2.classList.remove(c2));
});
}
moveClass.split(/\s+/).forEach((c2) => c2 && clone2.classList.add(c2));
clone2.style.display = "none";
const container = root.nodeType === 1 ? root : root.parentNode;
container.appendChild(clone2);
const { hasTransform } = getTransitionInfo(clone2);
container.removeChild(clone2);
return hasTransform;
}
const getModelAssigner = (vnode) => {
const fn2 = vnode.props["onUpdate:modelValue"] || false;
return isArray$1(fn2) ? (value) => invokeArrayFns(fn2, value) : fn2;
};
function onCompositionStart(e2) {
e2.target.composing = true;
}
function onCompositionEnd(e2) {
const target = e2.target;
if (target.composing) {
target.composing = false;
target.dispatchEvent(new Event("input"));
}
}
const vModelText = {
created(el2, { modifiers: { lazy, trim, number } }, vnode) {
el2._assign = getModelAssigner(vnode);
const castToNumber = number || vnode.props && vnode.props.type === "number";
addEventListener(el2, lazy ? "change" : "input", (e2) => {
if (e2.target.composing)
return;
let domValue = el2.value;
if (trim) {
domValue = domValue.trim();
}
if (castToNumber) {
domValue = looseToNumber(domValue);
}
el2._assign(domValue);
});
if (trim) {
addEventListener(el2, "change", () => {
el2.value = el2.value.trim();
});
}
if (!lazy) {
addEventListener(el2, "compositionstart", onCompositionStart);
addEventListener(el2, "compositionend", onCompositionEnd);
addEventListener(el2, "change", onCompositionEnd);
}
},
// set value on mounted so it's after min/max for type="range"
mounted(el2, { value }) {
el2.value = value == null ? "" : value;
},
beforeUpdate(el2, { value, modifiers: { lazy, trim, number } }, vnode) {
el2._assign = getModelAssigner(vnode);
if (el2.composing)
return;
if (document.activeElement === el2 && el2.type !== "range") {
if (lazy) {
return;
}
if (trim && el2.value.trim() === value) {
return;
}
if ((number || el2.type === "number") && looseToNumber(el2.value) === value) {
return;
}
}
const newValue = value == null ? "" : value;
if (el2.value !== newValue) {
el2.value = newValue;
}
}
};
const systemModifiers = ["ctrl", "shift", "alt", "meta"];
const modifierGuards = {
stop: (e2) => e2.stopPropagation(),
prevent: (e2) => e2.preventDefault(),
self: (e2) => e2.target !== e2.currentTarget,
ctrl: (e2) => !e2.ctrlKey,
shift: (e2) => !e2.shiftKey,
alt: (e2) => !e2.altKey,
meta: (e2) => !e2.metaKey,
left: (e2) => "button" in e2 && e2.button !== 0,
middle: (e2) => "button" in e2 && e2.button !== 1,
right: (e2) => "button" in e2 && e2.button !== 2,
exact: (e2, modifiers) => systemModifiers.some((m2) => e2[`${m2}Key`] && !modifiers.includes(m2))
};
const withModifiers = (fn2, modifiers) => {
return (event, ...args) => {
for (let i2 = 0; i2 < modifiers.length; i2++) {
const guard = modifierGuards[modifiers[i2]];
if (guard && guard(event, modifiers))
return;
}
return fn2(event, ...args);
};
};
const keyNames = {
esc: "escape",
space: " ",
up: "arrow-up",
left: "arrow-left",
right: "arrow-right",
down: "arrow-down",
delete: "backspace"
};
const withKeys = (fn2, modifiers) => {
return (event) => {
if (!("key" in event)) {
return;
}
const eventKey = hyphenate(event.key);
if (modifiers.some((k2) => k2 === eventKey || keyNames[k2] === eventKey)) {
return fn2(event);
}
};
};
const vShow = {
beforeMount(el2, { value }, { transition }) {
el2._vod = el2.style.display === "none" ? "" : el2.style.display;
if (transition && value) {
transition.beforeEnter(el2);
} else {
setDisplay(el2, value);
}
},
mounted(el2, { value }, { transition }) {
if (transition && value) {
transition.enter(el2);
}
},
updated(el2, { value, oldValue }, { transition }) {
if (!value === !oldValue)
return;
if (transition) {
if (value) {
transition.beforeEnter(el2);
setDisplay(el2, true);
transition.enter(el2);
} else {
transition.leave(el2, () => {
setDisplay(el2, false);
});
}
} else {
setDisplay(el2, value);
}
},
beforeUnmount(el2, { value }) {
setDisplay(el2, value);
}
};
function setDisplay(el2, value) {
el2.style.display = value ? el2._vod : "none";
}
const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
let renderer;
function ensureRenderer() {
return renderer || (renderer = createRenderer(rendererOptions));
}
const createApp = (...args) => {
const app = ensureRenderer().createApp(...args);
{
injectNativeTagCheck(app);
injectCompilerOptionsCheck(app);
}
const { mount } = app;
app.mount = (containerOrSelector) => {
const container = normalizeContainer(containerOrSelector);
if (!container)
return;
const component = app._component;
if (!isFunction$1(component) && !component.render && !component.template) {
component.template = container.innerHTML;
}
container.innerHTML = "";
const proxy = mount(container, false, container instanceof SVGElement);
if (container instanceof Element) {
container.removeAttribute("v-cloak");
container.setAttribute("data-v-app", "");
}
return proxy;
};
return app;
};
function injectNativeTagCheck(app) {
Object.defineProperty(app.config, "isNativeTag", {
value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
writable: false
});
}
function injectCompilerOptionsCheck(app) {
{
const isCustomElement = app.config.isCustomElement;
Object.defineProperty(app.config, "isCustomElement", {
get() {
return isCustomElement;
},
set() {
warn$2(`The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`);
}
});
const compilerOptions = app.config.compilerOptions;
const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
Object.defineProperty(app.config, "compilerOptions", {
get() {
warn$2(msg);
return compilerOptions;
},
set() {
warn$2(msg);
}
});
}
}
function normalizeContainer(container) {
if (isString$1(container)) {
const res = document.querySelector(container);
if (!res) {
warn$2(`Failed to mount app: mount target selector "${container}" returned null.`);
}
return res;
}
if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
warn$2(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
}
return container;
}
function initDev() {
{
initCustomFormatter();
}
}
{
initDev();
}
var isVue2 = false;
function set(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];
}
function getDevtoolsGlobalHook() {
return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
}
function getTarget() {
return typeof navigator !== "undefined" && typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
}
const isProxyAvailable = typeof Proxy === "function";
const HOOK_SETUP = "devtools-plugin:setup";
const HOOK_PLUGIN_SETTINGS_SET = "plugin:settings:set";
let supported;
let perf;
function isPerformanceSupported() {
var _a3;
if (supported !== void 0) {
return supported;
}
if (typeof window !== "undefined" && window.performance) {
supported = true;
perf = window.performance;
} else if (typeof global !== "undefined" && ((_a3 = global.perf_hooks) === null || _a3 === void 0 ? void 0 : _a3.performance)) {
supported = true;
perf = global.perf_hooks.performance;
} else {
supported = false;
}
return supported;
}
function now() {
return isPerformanceSupported() ? perf.now() : Date.now();
}
class ApiProxy {
constructor(plugin2, hook) {
this.target = null;
this.targetQueue = [];
this.onQueue = [];
this.plugin = plugin2;
this.hook = hook;
const defaultSettings = {};
if (plugin2.settings) {
for (const id2 in plugin2.settings) {
const item = plugin2.settings[id2];
defaultSettings[id2] = item.defaultValue;
}
}
const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin2.id}`;
let currentSettings = Object.assign({}, defaultSettings);
try {
const raw = localStorage.getItem(localSettingsSaveId);
const data = JSON.parse(raw);
Object.assign(currentSettings, data);
} catch (e2) {
}
this.fallbacks = {
getSettings() {
return currentSettings;
},
setSettings(value) {
try {
localStorage.setItem(localSettingsSaveId, JSON.stringify(value));
} catch (e2) {
}
currentSettings = value;
},
now() {
return now();
}
};
if (hook) {
hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => {
if (pluginId === this.plugin.id) {
this.fallbacks.setSettings(value);
}
});
}
this.proxiedOn = new Proxy({}, {
get: (_target, prop) => {
if (this.target) {
return this.target.on[prop];
} else {
return (...args) => {
this.onQueue.push({
method: prop,
args
});
};
}
}
});
this.proxiedTarget = new Proxy({}, {
get: (_target, prop) => {
if (this.target) {
return this.target[prop];
} else if (prop === "on") {
return this.proxiedOn;
} else if (Object.keys(this.fallbacks).includes(prop)) {
return (...args) => {
this.targetQueue.push({
method: prop,
args,
resolve: () => {
}
});
return this.fallbacks[prop](...args);
};
} else {
return (...args) => {
return new Promise((resolve2) => {
this.targetQueue.push({
method: prop,
args,
resolve: resolve2
});
});
};
}
}
});
}
async setRealTarget(target) {
this.target = target;
for (const item of this.onQueue) {
this.target.on[item.method](...item.args);
}
for (const item of this.targetQueue) {
item.resolve(await this.target[item.method](...item.args));
}
}
}
function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
const descriptor = pluginDescriptor;
const target = getTarget();
const hook = getDevtoolsGlobalHook();
const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy;
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
hook.emit(HOOK_SETUP, pluginDescriptor, setupFn);
} else {
const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null;
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
list.push({
pluginDescriptor: descriptor,
setupFn,
proxy
});
if (proxy)
setupFn(proxy.proxiedTarget);
}
}
/*!
* pinia v2.0.30
* (c) 2023 Eduardo San Martin Morote
* @license MIT
*/
let activePinia;
const setActivePinia = (pinia) => activePinia = pinia;
const piniaSymbol = Symbol("pinia");
function isPlainObject(o) {
return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.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 _global$1 = /* @__PURE__ */ (() => typeof window === "object" && window.window === window ? window : typeof self === "object" && self.self === self ? self : typeof global === "object" && global.global === global ? global : typeof globalThis === "object" ? globalThis : { HTMLElement: null })();
function bom(blob, { autoBom = false } = {}) {
if (autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
return new Blob([String.fromCharCode(65279), blob], { type: blob.type });
}
return blob;
}
function download(url, name, opts) {
const xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.responseType = "blob";
xhr.onload = function() {
saveAs(xhr.response, name, opts);
};
xhr.onerror = function() {
console.error("could not download file");
};
xhr.send();
}
function corsEnabled(url) {
const xhr = new XMLHttpRequest();
xhr.open("HEAD", url, false);
try {
xhr.send();
} catch (e2) {
}
return xhr.status >= 200 && xhr.status <= 299;
}
function click(node) {
try {
node.dispatchEvent(new MouseEvent("click"));
} catch (e2) {
const evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
node.dispatchEvent(evt);
}
}
const _navigator = typeof navigator === "object" ? navigator : { userAgent: "" };
const isMacOSWebView = /* @__PURE__ */ (() => /Macintosh/.test(_navigator.userAgent) && /AppleWebKit/.test(_navigator.userAgent) && !/Safari/.test(_navigator.userAgent))();
const saveAs = !IS_CLIENT ? () => {
} : (
// Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program
typeof HTMLAnchorElement !== "undefined" && "download" in HTMLAnchorElement.prototype && !isMacOSWebView ? downloadSaveAs : (
// Use msSaveOrOpenBlob as a second approach
"msSaveOrOpenBlob" in _navigator ? msSaveAs : (
// Fallback to using FileReader and a popup
fileSaverSaveAs
)
)
);
function downloadSaveAs(blob, name = "download", opts) {
const a2 = document.createElement("a");
a2.download = name;
a2.rel = "noopener";
if (typeof blob === "string") {
a2.href = blob;
if (a2.origin !== location.origin) {
if (corsEnabled(a2.href)) {
download(blob, name, opts);
} else {
a2.target = "_blank";
click(a2);
}
} else {
click(a2);
}
} else {
a2.href = URL.createObjectURL(blob);
setTimeout(function() {
URL.revokeObjectURL(a2.href);
}, 4e4);
setTimeout(function() {
click(a2);
}, 0);
}
}
function msSaveAs(blob, name = "download", opts) {
if (typeof blob === "string") {
if (corsEnabled(blob)) {
download(blob, name, opts);
} else {
const a2 = document.createElement("a");
a2.href = blob;
a2.target = "_blank";
setTimeout(function() {
click(a2);
});
}
} else {
navigator.msSaveOrOpenBlob(bom(blob, opts), name);
}
}
function fileSaverSaveAs(blob, name, opts, popup) {
popup = popup || open("", "_blank");
if (popup) {
popup.document.title = popup.document.body.innerText = "downloading...";
}
if (typeof blob === "string")
return download(blob, name, opts);
const force = blob.type === "application/octet-stream";
const isSafari = /constructor/i.test(String(_global$1.HTMLElement)) || "safari" in _global$1;
const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== "undefined") {
const reader = new FileReader();
reader.onloadend = function() {
let url = reader.result;
if (typeof url !== "string") {
popup = null;
throw new Error("Wrong reader.result type");
}
url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, "data:attachment/file;");
if (popup) {
popup.location.href = url;
} else {
location.assign(url);
}
popup = null;
};
reader.readAsDataURL(blob);
} else {
const url = URL.createObjectURL(blob);
if (popup)
popup.location.assign(url);
else
location.href = url;
popup = null;
setTimeout(function() {
URL.revokeObjectURL(url);
}, 4e4);
}
}
function toastMessage(message, type) {
const piniaMessage = "🍍 " + message;
if (typeof __VUE_DEVTOOLS_TOAST__ === "function") {
__VUE_DEVTOOLS_TOAST__(piniaMessage, type);
} else if (type === "error") {
console.error(piniaMessage);
} else if (type === "warn") {
console.warn(piniaMessage);
} else {
console.log(piniaMessage);
}
}
function isPinia(o) {
return "_a" in o && "install" in o;
}
function checkClipboardAccess() {
if (!("clipboard" in navigator)) {
toastMessage(`Your browser doesn't support the Clipboard API`, "error");
return true;
}
}
function checkNotFocusedError(error) {
if (error instanceof Error && error.message.toLowerCase().includes("document is not focused")) {
toastMessage('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', "warn");
return true;
}
return false;
}
async function actionGlobalCopyState(pinia) {
if (checkClipboardAccess())
return;
try {
await navigator.clipboard.writeText(JSON.stringify(pinia.state.value));
toastMessage("Global state copied to clipboard.");
} catch (error) {
if (checkNotFocusedError(error))
return;
toastMessage(`Failed to serialize the state. Check the console for more details.`, "error");
console.error(error);
}
}
async function actionGlobalPasteState(pinia) {
if (checkClipboardAccess())
return;
try {
pinia.state.value = JSON.parse(await navigator.clipboard.readText());
toastMessage("Global state pasted from clipboard.");
} catch (error) {
if (checkNotFocusedError(error))
return;
toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, "error");
console.error(error);
}
}
async function actionGlobalSaveState(pinia) {
try {
saveAs(new Blob([JSON.stringify(pinia.state.value)], {
type: "text/plain;charset=utf-8"
}), "pinia-state.json");
} catch (error) {
toastMessage(`Failed to export the state as JSON. Check the console for more details.`, "error");
console.error(error);
}
}
let fileInput;
function getFileOpener() {
if (!fileInput) {
fileInput = document.createElement("input");
fileInput.type = "file";
fileInput.accept = ".json";
}
function openFile() {
return new Promise((resolve2, reject) => {
fileInput.onchange = async () => {
const files = fileInput.files;
if (!files)
return resolve2(null);
const file = files.item(0);
if (!file)
return resolve2(null);
return resolve2({ text: await file.text(), file });
};
fileInput.oncancel = () => resolve2(null);
fileInput.onerror = reject;
fileInput.click();
});
}
return openFile;
}
async function actionGlobalOpenStateFile(pinia) {
try {
const open2 = await getFileOpener();
const result = await open2();
if (!result)
return;
const { text: text2, file } = result;
pinia.state.value = JSON.parse(text2);
toastMessage(`Global state imported from "${file.name}".`);
} catch (error) {
toastMessage(`Failed to export the state as JSON. Check the console for more details.`, "error");
console.error(error);
}
}
function formatDisplay$1(display) {
return {
_custom: {
display
}
};
}
const PINIA_ROOT_LABEL = "🍍 Pinia (root)";
const PINIA_ROOT_ID = "_root";
function formatStoreForInspectorTree(store) {
return isPinia(store) ? {
id: PINIA_ROOT_ID,
label: PINIA_ROOT_LABEL
} : {
id: store.$id,
label: store.$id
};
}
function formatStoreForInspectorState(store) {
if (isPinia(store)) {
const storeNames = Array.from(store._s.keys());
const storeMap = store._s;
const state2 = {
state: storeNames.map((storeId) => ({
editable: true,
key: storeId,
value: store.state.value[storeId]
})),
getters: storeNames.filter((id2) => storeMap.get(id2)._getters).map((id2) => {
const store2 = storeMap.get(id2);
return {
editable: false,
key: id2,
value: store2._getters.reduce((getters, key) => {
getters[key] = store2[key];
return getters;
}, {})
};
})
};
return state2;
}
const state = {
state: Object.keys(store.$state).map((key) => ({
editable: true,
key,
value: store.$state[key]
}))
};
if (store._getters && store._getters.length) {
state.getters = store._getters.map((getterName) => ({
editable: false,
key: getterName,
value: store[getterName]
}));
}
if (store._customProperties.size) {
state.customProperties = Array.from(store._customProperties).map((key) => ({
editable: true,
key,
value: store[key]
}));
}
return state;
}
function formatEventData(events) {
if (!events)
return {};
if (Array.isArray(events)) {
return events.reduce((data, event) => {
data.keys.push(event.key);
data.operations.push(event.type);
data.oldValue[event.key] = event.oldValue;
data.newValue[event.key] = event.newValue;
return data;
}, {
oldValue: {},
keys: [],
operations: [],
newValue: {}
});
} else {
return {
operation: formatDisplay$1(events.type),
key: formatDisplay$1(events.key),
oldValue: events.oldValue,
newValue: events.newValue
};
}
}
function formatMutationType(type) {
switch (type) {
case MutationType.direct:
return "mutation";
case MutationType.patchFunction:
return "$patch";
case MutationType.patchObject:
return "$patch";
default:
return "unknown";
}
}
let isTimelineActive = true;
const componentStateTypes = [];
const MUTATIONS_LAYER_ID = "pinia:mutations";
const INSPECTOR_ID = "pinia";
const { assign: assign$1$1 } = Object;
const getStoreType = (id2) => "🍍 " + id2;
function registerPiniaDevtools(app, pinia) {
setupDevtoolsPlugin({
id: "dev.esm.pinia",
label: "Pinia 🍍",
logo: "https://pinia.vuejs.org/logo.svg",
packageName: "pinia",
homepage: "https://pinia.vuejs.org",
componentStateTypes,
app
}, (api) => {
if (typeof api.now !== "function") {
toastMessage("You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.");
}
api.addTimelineLayer({
id: MUTATIONS_LAYER_ID,
label: `Pinia 🍍`,
color: 15064968
});
api.addInspector({
id: INSPECTOR_ID,
label: "Pinia 🍍",
icon: "storage",
treeFilterPlaceholder: "Search stores",
actions: [
{
icon: "content_copy",
action: () => {
actionGlobalCopyState(pinia);
},
tooltip: "Serialize and copy the state"
},
{
icon: "content_paste",
action: async () => {
await actionGlobalPasteState(pinia);
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
},
tooltip: "Replace the state with the content of your clipboard"
},
{
icon: "save",
action: () => {
actionGlobalSaveState(pinia);
},
tooltip: "Save the state as a JSON file"
},
{
icon: "folder_open",
action: async () => {
await actionGlobalOpenStateFile(pinia);
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
},
tooltip: "Import the state from a JSON file"
}
],
nodeActions: [
{
icon: "restore",
tooltip: "Reset the state (option store only)",
action: (nodeId) => {
const store = pinia._s.get(nodeId);
if (!store) {
toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, "warn");
} else if (!store._isOptionsAPI) {
toastMessage(`Cannot reset "${nodeId}" store because it's a setup store.`, "warn");
} else {
store.$reset();
toastMessage(`Store "${nodeId}" reset.`);
}
}
}
]
});
api.on.inspectComponent((payload, ctx) => {
const proxy = payload.componentInstance && payload.componentInstance.proxy;
if (proxy && proxy._pStores) {
const piniaStores = payload.componentInstance.proxy._pStores;
Object.values(piniaStores).forEach((store) => {
payload.instanceData.state.push({
type: getStoreType(store.$id),
key: "state",
editable: true,
value: store._isOptionsAPI ? {
_custom: {
value: toRaw(store.$state),
actions: [
{
icon: "restore",
tooltip: "Reset the state of this store",
action: () => store.$reset()
}
]
}
} : (
// NOTE: workaround to unwrap transferred refs
Object.keys(store.$state).reduce((state, key) => {
state[key] = store.$state[key];
return state;
}, {})
)
});
if (store._getters && store._getters.length) {
payload.instanceData.state.push({
type: getStoreType(store.$id),
key: "getters",
editable: false,
value: store._getters.reduce((getters, key) => {
try {
getters[key] = store[key];
} catch (error) {
getters[key] = error;
}
return getters;
}, {})
});
}
});
}
});
api.on.getInspectorTree((payload) => {
if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
let stores = [pinia];
stores = stores.concat(Array.from(pinia._s.values()));
payload.rootNodes = (payload.filter ? stores.filter((store) => "$id" in store ? store.$id.toLowerCase().includes(payload.filter.toLowerCase()) : PINIA_ROOT_LABEL.toLowerCase().includes(payload.filter.toLowerCase())) : stores).map(formatStoreForInspectorTree);
}
});
api.on.getInspectorState((payload) => {
if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
const inspectedStore = payload.nodeId === PINIA_ROOT_ID ? pinia : pinia._s.get(payload.nodeId);
if (!inspectedStore) {
return;
}
if (inspectedStore) {
payload.state = formatStoreForInspectorState(inspectedStore);
}
}
});
api.on.editInspectorState((payload, ctx) => {
if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
const inspectedStore = payload.nodeId === PINIA_ROOT_ID ? pinia : pinia._s.get(payload.nodeId);
if (!inspectedStore) {
return toastMessage(`store "${payload.nodeId}" not found`, "error");
}
const { path } = payload;
if (!isPinia(inspectedStore)) {
if (path.length !== 1 || !inspectedStore._customProperties.has(path[0]) || path[0] in inspectedStore.$state) {
path.unshift("$state");
}
} else {
path.unshift("state");
}
isTimelineActive = false;
payload.set(inspectedStore, path, payload.state.value);
isTimelineActive = true;
}
});
api.on.editComponentState((payload) => {
if (payload.type.startsWith("🍍")) {
const storeId = payload.type.replace(/^🍍\s*/, "");
const store = pinia._s.get(storeId);
if (!store) {
return toastMessage(`store "${storeId}" not found`, "error");
}
const { path } = payload;
if (path[0] !== "state") {
return toastMessage(`Invalid path for store "${storeId}":
${path}
Only state can be modified.`);
}
path[0] = "$state";
isTimelineActive = false;
payload.set(store, path, payload.state.value);
isTimelineActive = true;
}
});
});
}
function addStoreToDevtools(app, store) {
if (!componentStateTypes.includes(getStoreType(store.$id))) {
componentStateTypes.push(getStoreType(store.$id));
}
setupDevtoolsPlugin({
id: "dev.esm.pinia",
label: "Pinia 🍍",
logo: "https://pinia.vuejs.org/logo.svg",
packageName: "pinia",
homepage: "https://pinia.vuejs.org",
componentStateTypes,
app,
settings: {
logStoreChanges: {
label: "Notify about new/deleted stores",
type: "boolean",
defaultValue: true
}
// useEmojis: {
// label: 'Use emojis in messages ⚡️',
// type: 'boolean',
// defaultValue: true,
// },
}
}, (api) => {
const now2 = typeof api.now === "function" ? api.now.bind(api) : Date.now;
store.$onAction(({ after, onError, name, args }) => {
const groupId = runningActionId++;
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "🛫 " + name,
subtitle: "start",
data: {
store: formatDisplay$1(store.$id),
action: formatDisplay$1(name),
args
},
groupId
}
});
after((result) => {
activeAction = void 0;
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "🛬 " + name,
subtitle: "end",
data: {
store: formatDisplay$1(store.$id),
action: formatDisplay$1(name),
args,
result
},
groupId
}
});
});
onError((error) => {
activeAction = void 0;
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
logType: "error",
title: "💥 " + name,
subtitle: "end",
data: {
store: formatDisplay$1(store.$id),
action: formatDisplay$1(name),
args,
error
},
groupId
}
});
});
}, true);
store._customProperties.forEach((name) => {
watch(() => unref(store[name]), (newValue, oldValue) => {
api.notifyComponentUpdate();
api.sendInspectorState(INSPECTOR_ID);
if (isTimelineActive) {
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "Change",
subtitle: name,
data: {
newValue,
oldValue
},
groupId: activeAction
}
});
}
}, { deep: true });
});
store.$subscribe(({ events, type }, state) => {
api.notifyComponentUpdate();
api.sendInspectorState(INSPECTOR_ID);
if (!isTimelineActive)
return;
const eventData = {
time: now2(),
title: formatMutationType(type),
data: assign$1$1({ store: formatDisplay$1(store.$id) }, formatEventData(events)),
groupId: activeAction
};
activeAction = void 0;
if (type === MutationType.patchFunction) {
eventData.subtitle = "⤵️";
} else if (type === MutationType.patchObject) {
eventData.subtitle = "🧩";
} else if (events && !Array.isArray(events)) {
eventData.subtitle = events.type;
}
if (events) {
eventData.data["rawEvent(s)"] = {
_custom: {
display: "DebuggerEvent",
type: "object",
tooltip: "raw DebuggerEvent[]",
value: events
}
};
}
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: eventData
});
}, { detached: true, flush: "sync" });
const hotUpdate = store._hotUpdate;
store._hotUpdate = markRaw((newStore) => {
hotUpdate(newStore);
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "🔥 " + store.$id,
subtitle: "HMR update",
data: {
store: formatDisplay$1(store.$id),
info: formatDisplay$1(`HMR update`)
}
}
});
api.notifyComponentUpdate();
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
});
const { $dispose } = store;
store.$dispose = () => {
$dispose();
api.notifyComponentUpdate();
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
api.getSettings().logStoreChanges && toastMessage(`Disposed "${store.$id}" store 🗑`);
};
api.notifyComponentUpdate();
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
api.getSettings().logStoreChanges && toastMessage(`"${store.$id}" store installed 🆕`);
});
}
let runningActionId = 0;
let activeAction;
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 _actionId = runningActionId;
const trackedStore = new Proxy(store, {
get(...args) {
activeAction = _actionId;
return Reflect.get(...args);
},
set(...args) {
activeAction = _actionId;
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(
// @ts-expect-error: can cast the store...
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,
// FIXME: is there a way to allow the assignment from Store<Id, S, G, A> to StoreGeneric?
store
);
}
function createPinia() {
const scope = effectScope(true);
const state = scope.run(() => ref({}));
let _p2 = [];
let toBeInstalled = [];
const pinia = markRaw({
install(app) {
setActivePinia(pinia);
{
pinia._a = app;
app.provide(piniaSymbol, pinia);
app.config.globalProperties.$pinia = pinia;
if (USE_DEVTOOLS) {
registerPiniaDevtools(app, pinia);
}
toBeInstalled.forEach((plugin2) => _p2.push(plugin2));
toBeInstalled = [];
}
},
use(plugin2) {
if (!this._a && !isVue2) {
toBeInstalled.push(plugin2);
} else {
_p2.push(plugin2);
}
return this;
},
_p: _p2,
// it's actually undefined here
// @ts-expect-error
_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$3 = () => {
};
function addSubscription(subscriptions, callback, detached, onCleanup = noop$3) {
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: assign$3 } = Object;
function isComputed(o) {
return !!(isRef(o) && o.effect);
}
function createOptionsStore(id2, options, pinia, hot) {
const { state, actions, getters } = options;
const initialState = pinia.state.value[id2];
let store;
function setup() {
if (!initialState && !hot) {
{
pinia.state.value[id2] = state ? state() : {};
}
}
const localState = hot ? (
// use ref() to unwrap refs inside state TODO: check if this is still necessary
toRefs(ref(state ? state() : {}).value)
) : toRefs(pinia.state.value[id2]);
return assign$3(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => {
if (name in localState) {
console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id2}".`);
}
computedGetters[name] = markRaw(computed(() => {
setActivePinia(pinia);
const store2 = pinia._s.get(id2);
return getters[name].call(store2, store2);
}));
return computedGetters;
}, {}));
}
store = createSetupStore(id2, setup, options, pinia, hot, true);
store.$reset = function $reset() {
const newState = state ? state() : {};
this.$patch(($state) => {
assign$3($state, newState);
});
};
return store;
}
function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
let scope;
const optionsForPlugin = assign$3({ actions: {} }, options);
if (!pinia._e.active) {
throw new Error("Pinia destroyed");
}
const $subscribeOptions = {
deep: true
// flush: 'post',
};
{
$subscribeOptions.onTrigger = (event) => {
if (isListening) {
debuggerEvents = event;
} else if (isListening == false && !store._hotUpdating) {
if (Array.isArray(debuggerEvents)) {
debuggerEvents.push(event);
} else {
console.error("🍍 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 = () => {
throw new Error(`🍍: 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,
// _s: scope,
$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$3({}, $subscribeOptions, options2)));
return removeSubscription;
},
$dispose
};
const store = reactive(
assign$3(
{
_hmrPayload,
_customProperties: markRaw(/* @__PURE__ */ new Set())
// devtools custom properties
},
partialStore
// must be added later
// setupStore
)
);
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(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 ? (
// @ts-expect-error
options.getters[key]
) : prop;
if (IS_CLIENT) {
const getters = setupStore._getters || // @ts-expect-error: same
(setupStore._getters = markRaw([]));
getters.push(key);
}
}
}
}
{
assign$3(store, setupStore);
assign$3(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$3($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(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(store, actionName, wrapAction(actionName, action));
}
for (const getterName in newStore._hmrPayload.getters) {
const getter = newStore._hmrPayload.getters[getterName];
const getterValue = isOptionsStore ? (
// special handling of options api
computed(() => {
setActivePinia(pinia);
return getter.call(store, store);
})
) : getter;
set(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,
// avoid warning on devtools trying to display this property
enumerable: false
};
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((p2) => {
Object.defineProperty(store, p2, assign$3({ 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$3(store, extensions);
} else {
assign$3(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(`[🍍]: 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 id2;
let options;
const isSetupStore = typeof setup === "function";
if (typeof idOrOptions === "string") {
id2 = idOrOptions;
options = isSetupStore ? setupOptions : setup;
} else {
options = idOrOptions;
id2 = idOrOptions.id;
}
function useStore(pinia, hot) {
const currentInstance2 = getCurrentInstance();
pinia = // in test mode, ignore the argument provided as we can always retrieve a
// pinia instance with getActivePinia()
pinia || currentInstance2 && inject(piniaSymbol, null);
if (pinia)
setActivePinia(pinia);
if (!activePinia) {
throw new Error(`[🍍]: getActivePinia was called with 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(id2)) {
if (isSetupStore) {
createSetupStore(id2, setup, options, pinia);
} else {
createOptionsStore(id2, options, pinia);
}
{
useStore._pinia = pinia;
}
}
const store = pinia._s.get(id2);
if (hot) {
const hotId = "__hot:" + id2;
const newStore = isSetupStore ? createSetupStore(hotId, setup, options, pinia, true) : createOptionsStore(hotId, assign$3({}, options), pinia, true);
hot._hotUpdate(newStore);
delete pinia.state.value[hotId];
pinia._s.delete(hotId);
}
if (IS_CLIENT && currentInstance2 && currentInstance2.proxy && // avoid adding stores that are just built for hot module replacement
!hot) {
const vm = currentInstance2.proxy;
const cache2 = "_pStores" in vm ? vm._pStores : vm._pStores = {};
cache2[id2] = store;
}
return store;
}
useStore.$id = id2;
return useStore;
}
function getBasePlacement(placement) {
return placement.split("-")[0];
}
function getAlignment(placement) {
return placement.split("-")[1];
}
function getMainAxisFromPlacement(placement) {
return ["top", "bottom"].includes(getBasePlacement(placement)) ? "x" : "y";
}
function getLengthFromAxis(axis) {
return axis === "y" ? "height" : "width";
}
function computeCoordsFromPlacement(_ref) {
let {
reference,
floating,
placement
} = _ref;
const commonX = reference.x + reference.width / 2 - floating.width / 2;
const commonY = reference.y + reference.height / 2 - floating.height / 2;
let coords;
switch (getBasePlacement(placement)) {
case "top":
coords = {
x: commonX,
y: reference.y - floating.height
};
break;
case "bottom":
coords = {
x: commonX,
y: reference.y + reference.height
};
break;
case "right":
coords = {
x: reference.x + reference.width,
y: commonY
};
break;
case "left":
coords = {
x: reference.x - floating.width,
y: commonY
};
break;
default:
coords = {
x: reference.x,
y: reference.y
};
}
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
switch (getAlignment(placement)) {
case "start":
coords[mainAxis] = coords[mainAxis] - (reference[length] / 2 - floating[length] / 2);
break;
case "end":
coords[mainAxis] = coords[mainAxis] + (reference[length] / 2 - floating[length] / 2);
break;
}
return coords;
}
const computePosition$1 = async (reference, floating, config2) => {
const {
placement = "bottom",
strategy = "absolute",
middleware = [],
platform: platform2
} = config2;
{
if (platform2 == null) {
console.error(["Floating UI: `platform` property was not passed to config. If you", "want to use Floating UI on the web, install @floating-ui/dom", "instead of the /core package. Otherwise, you can create your own", "`platform`: https://floating-ui.com/docs/platform"].join(" "));
}
if (middleware.filter((_ref) => {
let {
name
} = _ref;
return name === "autoPlacement" || name === "flip";
}).length > 1) {
throw new Error(["Floating UI: duplicate `flip` and/or `autoPlacement`", "middleware detected. This will lead to an infinite loop. Ensure only", "one of either has been passed to the `middleware` array."].join(" "));
}
}
let rects = await platform2.getElementRects({
reference,
floating,
strategy
});
let {
x: x2,
y: y2
} = computeCoordsFromPlacement({
...rects,
placement
});
let statefulPlacement = placement;
let middlewareData = {};
let _debug_loop_count_ = 0;
for (let i2 = 0; i2 < middleware.length; i2++) {
{
_debug_loop_count_++;
if (_debug_loop_count_ > 100) {
throw new Error(["Floating UI: The middleware lifecycle appears to be", "running in an infinite loop. This is usually caused by a `reset`", "continually being returned without a break condition."].join(" "));
}
}
const {
name,
fn: fn2
} = middleware[i2];
const {
x: nextX,
y: nextY,
data,
reset
} = await fn2({
x: x2,
y: y2,
initialPlacement: placement,
placement: statefulPlacement,
strategy,
middlewareData,
rects,
platform: platform2,
elements: {
reference,
floating
}
});
x2 = nextX != null ? nextX : x2;
y2 = nextY != null ? nextY : y2;
middlewareData = {
...middlewareData,
[name]: data != null ? data : {}
};
if (reset) {
if (typeof reset === "object") {
if (reset.placement) {
statefulPlacement = reset.placement;
}
if (reset.rects) {
rects = reset.rects === true ? await platform2.getElementRects({
reference,
floating,
strategy
}) : reset.rects;
}
({
x: x2,
y: y2
} = computeCoordsFromPlacement({
...rects,
placement: statefulPlacement
}));
}
i2 = -1;
continue;
}
}
return {
x: x2,
y: y2,
placement: statefulPlacement,
strategy,
middlewareData
};
};
function expandPaddingObject(padding) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...padding
};
}
function getSideObjectFromPadding(padding) {
return typeof padding !== "number" ? expandPaddingObject(padding) : {
top: padding,
right: padding,
bottom: padding,
left: padding
};
}
function rectToClientRect(rect) {
return {
...rect,
top: rect.y,
left: rect.x,
right: rect.x + rect.width,
bottom: rect.y + rect.height
};
}
async function detectOverflow(middlewareArguments, options) {
if (options === void 0) {
options = {};
}
const {
x: x2,
y: y2,
platform: platform2,
rects,
elements,
strategy
} = middlewareArguments;
const {
boundary = "clippingParents",
rootBoundary = "viewport",
elementContext = "floating",
altBoundary = false,
padding = 0
} = options;
const paddingObject = getSideObjectFromPadding(padding);
const altContext = elementContext === "floating" ? "reference" : "floating";
const element2 = elements[altBoundary ? altContext : elementContext];
const clippingClientRect = await platform2.getClippingClientRect({
element: await platform2.isElement(element2) ? element2 : element2.contextElement || await platform2.getDocumentElement({
element: elements.floating
}),
boundary,
rootBoundary
});
const elementClientRect = rectToClientRect(await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: elementContext === "floating" ? {
...rects.floating,
x: x2,
y: y2
} : rects.reference,
offsetParent: await platform2.getOffsetParent({
element: elements.floating
}),
strategy
}));
return {
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
};
}
const min$1 = Math.min;
const max$1 = Math.max;
function within(min$1$1, value, max$1$1) {
return max$1(min$1$1, min$1(value, max$1$1));
}
const arrow = (options) => ({
name: "arrow",
options,
async fn(middlewareArguments) {
const {
element: element2,
padding = 0
} = options != null ? options : {};
const {
x: x2,
y: y2,
placement,
rects,
platform: platform2
} = middlewareArguments;
if (element2 == null) {
{
console.warn("Floating UI: No `element` was passed to the `arrow` middleware.");
}
return {};
}
const paddingObject = getSideObjectFromPadding(padding);
const coords = {
x: x2,
y: y2
};
const basePlacement = getBasePlacement(placement);
const axis = getMainAxisFromPlacement(basePlacement);
const length = getLengthFromAxis(axis);
const arrowDimensions = await platform2.getDimensions({
element: element2
});
const minProp = axis === "y" ? "top" : "left";
const maxProp = axis === "y" ? "bottom" : "right";
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
const startDiff = coords[axis] - rects.reference[axis];
const arrowOffsetParent = await platform2.getOffsetParent({
element: element2
});
const clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
const centerToReference = endDiff / 2 - startDiff / 2;
const min2 = paddingObject[minProp];
const max2 = clientSize - arrowDimensions[length] - paddingObject[maxProp];
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset2 = within(min2, center, max2);
return {
data: {
[axis]: offset2,
centerOffset: center - offset2
}
};
}
});
const hash$1 = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
};
function getOppositePlacement(placement) {
return placement.replace(/left|right|bottom|top/g, (matched) => hash$1[matched]);
}
function getAlignmentSides(placement, rects) {
const isStart = getAlignment(placement) === "start";
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
let mainAlignmentSide = mainAxis === "x" ? isStart ? "right" : "left" : isStart ? "bottom" : "top";
if (rects.reference[length] > rects.floating[length]) {
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
}
return {
main: mainAlignmentSide,
cross: getOppositePlacement(mainAlignmentSide)
};
}
const hash = {
start: "end",
end: "start"
};
function getOppositeAlignmentPlacement(placement) {
return placement.replace(/start|end/g, (matched) => hash[matched]);
}
const basePlacements = ["top", "right", "bottom", "left"];
const allPlacements = /* @__PURE__ */ basePlacements.reduce((acc, basePlacement) => acc.concat(basePlacement, basePlacement + "-start", basePlacement + "-end"), []);
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getBasePlacement(placement) === placement);
return allowedPlacementsSortedByAlignment.filter((placement) => {
if (alignment) {
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
}
return true;
});
}
const autoPlacement = function(options) {
if (options === void 0) {
options = {};
}
return {
name: "autoPlacement",
options,
async fn(middlewareArguments) {
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _middlewareData$autoP5, _placementsSortedByLe;
const {
x: x2,
y: y2,
rects,
middlewareData,
placement
} = middlewareArguments;
const {
alignment = null,
allowedPlacements = allPlacements,
autoAlignment = true,
...detectOverflowOptions
} = options;
if ((_middlewareData$autoP = middlewareData.autoPlacement) != null && _middlewareData$autoP.skip) {
return {};
}
const placements2 = getPlacementList(alignment, autoAlignment, allowedPlacements);
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const currentIndex = (_middlewareData$autoP2 = (_middlewareData$autoP3 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP3.index) != null ? _middlewareData$autoP2 : 0;
const currentPlacement = placements2[currentIndex];
const {
main: main2,
cross
} = getAlignmentSides(currentPlacement, rects);
if (placement !== currentPlacement) {
return {
x: x2,
y: y2,
reset: {
placement: placements2[0]
}
};
}
const currentOverflows = [overflow[getBasePlacement(currentPlacement)], overflow[main2], overflow[cross]];
const allOverflows = [...(_middlewareData$autoP4 = (_middlewareData$autoP5 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP5.overflows) != null ? _middlewareData$autoP4 : [], {
placement: currentPlacement,
overflows: currentOverflows
}];
const nextPlacement = placements2[currentIndex + 1];
if (nextPlacement) {
return {
data: {
index: currentIndex + 1,
overflows: allOverflows
},
reset: {
placement: nextPlacement
}
};
}
const placementsSortedByLeastOverflow = allOverflows.slice().sort((a2, b3) => a2.overflows[0] - b3.overflows[0]);
const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find((_ref) => {
let {
overflows
} = _ref;
return overflows.every((overflow2) => overflow2 <= 0);
})) == null ? void 0 : _placementsSortedByLe.placement;
return {
data: {
skip: true
},
reset: {
placement: placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement
}
};
}
};
};
function getExpandedPlacements(placement) {
const oppositePlacement = getOppositePlacement(placement);
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
}
const flip = function(options) {
if (options === void 0) {
options = {};
}
return {
name: "flip",
options,
async fn(middlewareArguments) {
var _middlewareData$flip, _middlewareData$flip2;
const {
placement,
middlewareData,
rects,
initialPlacement
} = middlewareArguments;
if ((_middlewareData$flip = middlewareData.flip) != null && _middlewareData$flip.skip) {
return {};
}
const {
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = true,
fallbackPlacements: specifiedFallbackPlacements,
fallbackStrategy = "bestFit",
flipAlignment = true,
...detectOverflowOptions
} = options;
const basePlacement = getBasePlacement(placement);
const isBasePlacement = basePlacement === initialPlacement;
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
const placements2 = [initialPlacement, ...fallbackPlacements];
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const overflows = [];
let overflowsData = ((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.overflows) || [];
if (checkMainAxis) {
overflows.push(overflow[basePlacement]);
}
if (checkCrossAxis) {
const {
main: main2,
cross
} = getAlignmentSides(placement, rects);
overflows.push(overflow[main2], overflow[cross]);
}
overflowsData = [...overflowsData, {
placement,
overflows
}];
if (!overflows.every((side) => side <= 0)) {
var _middlewareData$flip$, _middlewareData$flip3;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip3 = middlewareData.flip) == null ? void 0 : _middlewareData$flip3.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextPlacement = placements2[nextIndex];
if (nextPlacement) {
return {
data: {
index: nextIndex,
overflows: overflowsData
},
reset: {
placement: nextPlacement
}
};
}
let resetPlacement = "bottom";
switch (fallbackStrategy) {
case "bestFit": {
var _overflowsData$slice$;
const placement2 = (_overflowsData$slice$ = overflowsData.slice().sort((a2, b3) => a2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0) - b3.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0))[0]) == null ? void 0 : _overflowsData$slice$.placement;
if (placement2) {
resetPlacement = placement2;
}
break;
}
case "initialPlacement":
resetPlacement = initialPlacement;
break;
}
return {
data: {
skip: true
},
reset: {
placement: resetPlacement
}
};
}
return {};
}
};
};
function convertValueToCoords(_ref) {
let {
placement,
rects,
value
} = _ref;
const basePlacement = getBasePlacement(placement);
const multiplier = ["left", "top"].includes(basePlacement) ? -1 : 1;
const rawValue = typeof value === "function" ? value({
...rects,
placement
}) : value;
const {
mainAxis,
crossAxis
} = typeof rawValue === "number" ? {
mainAxis: rawValue,
crossAxis: 0
} : {
mainAxis: 0,
crossAxis: 0,
...rawValue
};
return getMainAxisFromPlacement(basePlacement) === "x" ? {
x: crossAxis,
y: mainAxis * multiplier
} : {
x: mainAxis * multiplier,
y: crossAxis
};
}
const offset = function(value) {
if (value === void 0) {
value = 0;
}
return {
name: "offset",
options: value,
fn(middlewareArguments) {
const {
x: x2,
y: y2,
placement,
rects
} = middlewareArguments;
const diffCoords = convertValueToCoords({
placement,
rects,
value
});
return {
x: x2 + diffCoords.x,
y: y2 + diffCoords.y,
data: diffCoords
};
}
};
};
function getCrossAxis(axis) {
return axis === "x" ? "y" : "x";
}
const shift = function(options) {
if (options === void 0) {
options = {};
}
return {
name: "shift",
options,
async fn(middlewareArguments) {
const {
x: x2,
y: y2,
placement
} = middlewareArguments;
const {
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = false,
limiter = {
fn: (_ref) => {
let {
x: x3,
y: y3
} = _ref;
return {
x: x3,
y: y3
};
}
},
...detectOverflowOptions
} = options;
const coords = {
x: x2,
y: y2
};
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const mainAxis = getMainAxisFromPlacement(getBasePlacement(placement));
const crossAxis = getCrossAxis(mainAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
if (checkMainAxis) {
const minSide = mainAxis === "y" ? "top" : "left";
const maxSide = mainAxis === "y" ? "bottom" : "right";
const min2 = mainAxisCoord + overflow[minSide];
const max2 = mainAxisCoord - overflow[maxSide];
mainAxisCoord = within(min2, mainAxisCoord, max2);
}
if (checkCrossAxis) {
const minSide = crossAxis === "y" ? "top" : "left";
const maxSide = crossAxis === "y" ? "bottom" : "right";
const min2 = crossAxisCoord + overflow[minSide];
const max2 = crossAxisCoord - overflow[maxSide];
crossAxisCoord = within(min2, crossAxisCoord, max2);
}
const limitedCoords = limiter.fn({
...middlewareArguments,
[mainAxis]: mainAxisCoord,
[crossAxis]: crossAxisCoord
});
return {
...limitedCoords,
data: {
x: limitedCoords.x - x2,
y: limitedCoords.y - y2
}
};
}
};
};
const size = function(options) {
if (options === void 0) {
options = {};
}
return {
name: "size",
options,
async fn(middlewareArguments) {
var _middlewareData$size;
const {
placement,
rects,
middlewareData
} = middlewareArguments;
const {
apply,
...detectOverflowOptions
} = options;
if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {
return {};
}
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const basePlacement = getBasePlacement(placement);
const isEnd = getAlignment(placement) === "end";
let heightSide;
let widthSide;
if (basePlacement === "top" || basePlacement === "bottom") {
heightSide = basePlacement;
widthSide = isEnd ? "left" : "right";
} else {
widthSide = basePlacement;
heightSide = isEnd ? "top" : "bottom";
}
const xMin = max$1(overflow.left, 0);
const xMax = max$1(overflow.right, 0);
const yMin = max$1(overflow.top, 0);
const yMax = max$1(overflow.bottom, 0);
const dimensions = {
height: rects.floating.height - (["left", "right"].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max$1(overflow.top, overflow.bottom)) : overflow[heightSide]),
width: rects.floating.width - (["top", "bottom"].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max$1(overflow.left, overflow.right)) : overflow[widthSide])
};
apply == null ? void 0 : apply({
...dimensions,
...rects
});
return {
data: {
skip: true
},
reset: {
rects: true
}
};
}
};
};
function isWindow(value) {
return (value == null ? void 0 : value.toString()) === "[object Window]";
}
function getWindow(node) {
if (node == null) {
return window;
}
if (!isWindow(node)) {
const ownerDocument = node.ownerDocument;
return ownerDocument ? ownerDocument.defaultView || window : window;
}
return node;
}
function getComputedStyle$1(element2) {
return getWindow(element2).getComputedStyle(element2);
}
function getNodeName(node) {
return isWindow(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
}
function isHTMLElement(value) {
return value instanceof getWindow(value).HTMLElement;
}
function isElement(value) {
return value instanceof getWindow(value).Element;
}
function isNode(value) {
return value instanceof getWindow(value).Node;
}
function isShadowRoot(node) {
const OwnElement = getWindow(node).ShadowRoot;
return node instanceof OwnElement || node instanceof ShadowRoot;
}
function isScrollParent(element2) {
const {
overflow,
overflowX,
overflowY
} = getComputedStyle$1(element2);
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
}
function isTableElement(element2) {
return ["table", "td", "th"].includes(getNodeName(element2));
}
function isContainingBlock(element2) {
const isFirefox = navigator.userAgent.toLowerCase().includes("firefox");
const css = getComputedStyle$1(element2);
return css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].includes(css.willChange) || isFirefox && css.willChange === "filter" || isFirefox && (css.filter ? css.filter !== "none" : false);
}
const min = Math.min;
const max = Math.max;
const round = Math.round;
function getBoundingClientRect(element2, includeScale) {
if (includeScale === void 0) {
includeScale = false;
}
const clientRect = element2.getBoundingClientRect();
let scaleX = 1;
let scaleY = 1;
if (includeScale && isHTMLElement(element2)) {
scaleX = element2.offsetWidth > 0 ? round(clientRect.width) / element2.offsetWidth || 1 : 1;
scaleY = element2.offsetHeight > 0 ? round(clientRect.height) / element2.offsetHeight || 1 : 1;
}
return {
width: clientRect.width / scaleX,
height: clientRect.height / scaleY,
top: clientRect.top / scaleY,
right: clientRect.right / scaleX,
bottom: clientRect.bottom / scaleY,
left: clientRect.left / scaleX,
x: clientRect.left / scaleX,
y: clientRect.top / scaleY
};
}
function getDocumentElement(node) {
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
}
function getNodeScroll(element2) {
if (isWindow(element2)) {
return {
scrollLeft: element2.pageXOffset,
scrollTop: element2.pageYOffset
};
}
return {
scrollLeft: element2.scrollLeft,
scrollTop: element2.scrollTop
};
}
function getWindowScrollBarX(element2) {
return getBoundingClientRect(getDocumentElement(element2)).left + getNodeScroll(element2).scrollLeft;
}
function isScaled(element2) {
const rect = getBoundingClientRect(element2);
return round(rect.width) !== element2.offsetWidth || round(rect.height) !== element2.offsetHeight;
}
function getRectRelativeToOffsetParent(element2, offsetParent, strategy) {
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
const rect = getBoundingClientRect(element2, isOffsetParentAnElement && isScaled(offsetParent));
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = {
x: 0,
y: 0
};
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
if (getNodeName(offsetParent) !== "body" || isScrollParent(documentElement)) {
scroll = getNodeScroll(offsetParent);
}
if (isHTMLElement(offsetParent)) {
const offsetRect = getBoundingClientRect(offsetParent, true);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
} else if (documentElement) {
offsets.x = getWindowScrollBarX(documentElement);
}
}
return {
x: rect.left + scroll.scrollLeft - offsets.x,
y: rect.top + scroll.scrollTop - offsets.y,
width: rect.width,
height: rect.height
};
}
function getParentNode(node) {
if (getNodeName(node) === "html") {
return node;
}
return (
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
// @ts-ignore
node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
node.parentNode || // DOM Element detected
(isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
getDocumentElement(node)
);
}
function getTrueOffsetParent(element2) {
if (!isHTMLElement(element2) || getComputedStyle(element2).position === "fixed") {
return null;
}
return element2.offsetParent;
}
function getContainingBlock(element2) {
let currentNode = getParentNode(element2);
while (isHTMLElement(currentNode) && !["html", "body"].includes(getNodeName(currentNode))) {
if (isContainingBlock(currentNode)) {
return currentNode;
} else {
currentNode = currentNode.parentNode;
}
}
return null;
}
function getOffsetParent(element2) {
const window2 = getWindow(element2);
let offsetParent = getTrueOffsetParent(element2);
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
offsetParent = getTrueOffsetParent(offsetParent);
}
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
return window2;
}
return offsetParent || getContainingBlock(element2) || window2;
}
function getDimensions(element2) {
return {
width: element2.offsetWidth,
height: element2.offsetHeight
};
}
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
let {
rect,
offsetParent,
strategy
} = _ref;
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
if (offsetParent === documentElement) {
return rect;
}
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = {
x: 0,
y: 0
};
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
if (getNodeName(offsetParent) !== "body" || isScrollParent(documentElement)) {
scroll = getNodeScroll(offsetParent);
}
if (isHTMLElement(offsetParent)) {
const offsetRect = getBoundingClientRect(offsetParent, true);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
}
}
return {
...rect,
x: rect.x - scroll.scrollLeft + offsets.x,
y: rect.y - scroll.scrollTop + offsets.y
};
}
function getViewportRect(element2) {
const win = getWindow(element2);
const html = getDocumentElement(element2);
const visualViewport = win.visualViewport;
let width = html.clientWidth;
let height = html.clientHeight;
let x2 = 0;
let y2 = 0;
if (visualViewport) {
width = visualViewport.width;
height = visualViewport.height;
if (Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) < 0.01) {
x2 = visualViewport.offsetLeft;
y2 = visualViewport.offsetTop;
}
}
return {
width,
height,
x: x2,
y: y2
};
}
function getDocumentRect(element2) {
var _element$ownerDocumen;
const html = getDocumentElement(element2);
const scroll = getNodeScroll(element2);
const body = (_element$ownerDocumen = element2.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
let x2 = -scroll.scrollLeft + getWindowScrollBarX(element2);
const y2 = -scroll.scrollTop;
if (getComputedStyle$1(body || html).direction === "rtl") {
x2 += max(html.clientWidth, body ? body.clientWidth : 0) - width;
}
return {
width,
height,
x: x2,
y: y2
};
}
function getScrollParent(node) {
if (["html", "body", "#document"].includes(getNodeName(node))) {
return node.ownerDocument.body;
}
if (isHTMLElement(node) && isScrollParent(node)) {
return node;
}
return getScrollParent(getParentNode(node));
}
function getScrollParents(node, list) {
var _node$ownerDocument;
if (list === void 0) {
list = [];
}
const scrollParent = getScrollParent(node);
const isBody = scrollParent === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
const win = getWindow(scrollParent);
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
const updatedList = list.concat(target);
return isBody ? updatedList : (
// @ts-ignore: isBody tells us target will be an HTMLElement here
updatedList.concat(getScrollParents(getParentNode(target)))
);
}
function contains(parent, child) {
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
if (parent.contains(child)) {
return true;
} else if (rootNode && isShadowRoot(rootNode)) {
let next = child;
do {
if (next && parent === next) {
return true;
}
next = next.parentNode || next.host;
} while (next);
}
return false;
}
function getInnerBoundingClientRect(element2) {
const clientRect = getBoundingClientRect(element2);
const top = clientRect.top + element2.clientTop;
const left = clientRect.left + element2.clientLeft;
return {
top,
left,
x: left,
y: top,
right: left + element2.clientWidth,
bottom: top + element2.clientHeight,
width: element2.clientWidth,
height: element2.clientHeight
};
}
function getClientRectFromClippingParent(element2, clippingParent) {
if (clippingParent === "viewport") {
return rectToClientRect(getViewportRect(element2));
}
if (isElement(clippingParent)) {
return getInnerBoundingClientRect(clippingParent);
}
return rectToClientRect(getDocumentRect(getDocumentElement(element2)));
}
function getClippingParents(element2) {
const clippingParents = getScrollParents(getParentNode(element2));
const canEscapeClipping = ["absolute", "fixed"].includes(getComputedStyle$1(element2).position);
const clipperElement = canEscapeClipping && isHTMLElement(element2) ? getOffsetParent(element2) : element2;
if (!isElement(clipperElement)) {
return [];
}
return clippingParents.filter((clippingParent) => isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body");
}
function getClippingClientRect(_ref) {
let {
element: element2,
boundary,
rootBoundary
} = _ref;
const mainClippingParents = boundary === "clippingParents" ? getClippingParents(element2) : [].concat(boundary);
const clippingParents = [...mainClippingParents, rootBoundary];
const firstClippingParent = clippingParents[0];
const clippingRect = clippingParents.reduce((accRect, clippingParent) => {
const rect = getClientRectFromClippingParent(element2, clippingParent);
accRect.top = max(rect.top, accRect.top);
accRect.right = min(rect.right, accRect.right);
accRect.bottom = min(rect.bottom, accRect.bottom);
accRect.left = max(rect.left, accRect.left);
return accRect;
}, getClientRectFromClippingParent(element2, firstClippingParent));
clippingRect.width = clippingRect.right - clippingRect.left;
clippingRect.height = clippingRect.bottom - clippingRect.top;
clippingRect.x = clippingRect.left;
clippingRect.y = clippingRect.top;
return clippingRect;
}
const platform = {
getElementRects: (_ref) => {
let {
reference,
floating,
strategy
} = _ref;
return {
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
floating: {
...getDimensions(floating),
x: 0,
y: 0
}
};
},
convertOffsetParentRelativeRectToViewportRelativeRect: (args) => convertOffsetParentRelativeRectToViewportRelativeRect(args),
getOffsetParent: (_ref2) => {
let {
element: element2
} = _ref2;
return getOffsetParent(element2);
},
isElement: (value) => isElement(value),
getDocumentElement: (_ref3) => {
let {
element: element2
} = _ref3;
return getDocumentElement(element2);
},
getClippingClientRect: (args) => getClippingClientRect(args),
getDimensions: (_ref4) => {
let {
element: element2
} = _ref4;
return getDimensions(element2);
},
getClientRects: (_ref5) => {
let {
element: element2
} = _ref5;
return element2.getClientRects();
}
};
const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
platform,
...options
});
var __defProp$1 = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$1 = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp$1.call(b3, prop))
__defNormalProp$1(a2, prop, b3[prop]);
if (__getOwnPropSymbols$1)
for (var prop of __getOwnPropSymbols$1(b3)) {
if (__propIsEnum$1.call(b3, prop))
__defNormalProp$1(a2, prop, b3[prop]);
}
return a2;
};
var __spreadProps = (a2, b3) => __defProps(a2, __getOwnPropDescs(b3));
function assign$2(to2, from) {
for (const key in from) {
if (Object.prototype.hasOwnProperty.call(from, key)) {
if (typeof from[key] === "object" && to2[key]) {
assign$2(to2[key], from[key]);
} else {
to2[key] = from[key];
}
}
}
}
const config$2 = {
disabled: false,
distance: 5,
skidding: 0,
container: "body",
boundary: void 0,
instantMove: false,
disposeTimeout: 5e3,
popperTriggers: [],
strategy: "absolute",
preventOverflow: true,
flip: true,
shift: true,
overflowPadding: 0,
arrowPadding: 0,
arrowOverflow: true,
themes: {
tooltip: {
placement: "top",
triggers: ["hover", "focus", "touch"],
hideTriggers: (events) => [...events, "click"],
delay: {
show: 200,
hide: 0
},
handleResize: false,
html: false,
loadingContent: "..."
},
dropdown: {
placement: "bottom",
triggers: ["click"],
delay: 0,
handleResize: true,
autoHide: true
},
menu: {
$extend: "dropdown",
triggers: ["hover", "focus"],
popperTriggers: ["hover", "focus"],
delay: {
show: 0,
hide: 400
}
}
}
};
function getDefaultConfig(theme, key) {
let themeConfig = config$2.themes[theme] || {};
let value;
do {
value = themeConfig[key];
if (typeof value === "undefined") {
if (themeConfig.$extend) {
themeConfig = config$2.themes[themeConfig.$extend] || {};
} else {
themeConfig = null;
value = config$2[key];
}
} else {
themeConfig = null;
}
} while (themeConfig);
return value;
}
function getThemeClasses(theme) {
const result = [theme];
let themeConfig = config$2.themes[theme] || {};
do {
if (themeConfig.$extend && !themeConfig.$resetCss) {
result.push(themeConfig.$extend);
themeConfig = config$2.themes[themeConfig.$extend] || {};
} else {
themeConfig = null;
}
} while (themeConfig);
return result.map((c2) => `v-popper--theme-${c2}`);
}
function getAllParentThemes(theme) {
const result = [theme];
let themeConfig = config$2.themes[theme] || {};
do {
if (themeConfig.$extend) {
result.push(themeConfig.$extend);
themeConfig = config$2.themes[themeConfig.$extend] || {};
} else {
themeConfig = null;
}
} while (themeConfig);
return result;
}
let supportsPassive = false;
if (typeof window !== "undefined") {
supportsPassive = false;
try {
const opts = Object.defineProperty({}, "passive", {
get() {
supportsPassive = true;
}
});
window.addEventListener("test", null, opts);
} catch (e2) {
}
}
let isIOS = false;
if (typeof window !== "undefined" && typeof navigator !== "undefined") {
isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
}
const placements = ["auto", "top", "bottom", "left", "right"].reduce((acc, base2) => acc.concat([
base2,
`${base2}-start`,
`${base2}-end`
]), []);
const SHOW_EVENT_MAP = {
hover: "mouseenter",
focus: "focus",
click: "click",
touch: "touchstart"
};
const HIDE_EVENT_MAP = {
hover: "mouseleave",
focus: "blur",
click: "click",
touch: "touchend"
};
function removeFromArray(array, item) {
const index2 = array.indexOf(item);
if (index2 !== -1) {
array.splice(index2, 1);
}
}
function nextFrame() {
return new Promise((resolve2) => requestAnimationFrame(() => {
requestAnimationFrame(resolve2);
}));
}
const shownPoppers = [];
let hidingPopper = null;
const shownPoppersByTheme = {};
function getShownPoppersByTheme(theme) {
let list = shownPoppersByTheme[theme];
if (!list) {
list = shownPoppersByTheme[theme] = [];
}
return list;
}
let Element$1 = function() {
};
if (typeof window !== "undefined") {
Element$1 = window.Element;
}
function defaultPropFactory(prop) {
return function(props) {
return getDefaultConfig(props.theme, prop);
};
}
const PROVIDE_KEY = "__floating-vue__popper";
var PrivatePopper = () => defineComponent({
name: "VPopper",
provide() {
return {
[PROVIDE_KEY]: {
parentPopper: this
}
};
},
inject: {
[PROVIDE_KEY]: { default: null }
},
props: {
theme: {
type: String,
required: true
},
targetNodes: {
type: Function,
required: true
},
referenceNode: {
type: Function,
default: null
},
popperNode: {
type: Function,
required: true
},
shown: {
type: Boolean,
default: false
},
showGroup: {
type: String,
default: null
},
ariaId: {
default: null
},
disabled: {
type: Boolean,
default: defaultPropFactory("disabled")
},
positioningDisabled: {
type: Boolean,
default: defaultPropFactory("positioningDisabled")
},
placement: {
type: String,
default: defaultPropFactory("placement"),
validator: (value) => placements.includes(value)
},
delay: {
type: [String, Number, Object],
default: defaultPropFactory("delay")
},
distance: {
type: [Number, String],
default: defaultPropFactory("distance")
},
skidding: {
type: [Number, String],
default: defaultPropFactory("skidding")
},
triggers: {
type: Array,
default: defaultPropFactory("triggers")
},
showTriggers: {
type: [Array, Function],
default: defaultPropFactory("showTriggers")
},
hideTriggers: {
type: [Array, Function],
default: defaultPropFactory("hideTriggers")
},
popperTriggers: {
type: Array,
default: defaultPropFactory("popperTriggers")
},
popperShowTriggers: {
type: [Array, Function],
default: defaultPropFactory("popperShowTriggers")
},
popperHideTriggers: {
type: [Array, Function],
default: defaultPropFactory("popperHideTriggers")
},
container: {
type: [String, Object, Element$1, Boolean],
default: defaultPropFactory("container")
},
boundary: {
type: [String, Element$1],
default: defaultPropFactory("boundary")
},
strategy: {
type: String,
validator: (value) => ["absolute", "fixed"].includes(value),
default: defaultPropFactory("strategy")
},
autoHide: {
type: [Boolean, Function],
default: defaultPropFactory("autoHide")
},
handleResize: {
type: Boolean,
default: defaultPropFactory("handleResize")
},
instantMove: {
type: Boolean,
default: defaultPropFactory("instantMove")
},
eagerMount: {
type: Boolean,
default: defaultPropFactory("eagerMount")
},
popperClass: {
type: [String, Array, Object],
default: defaultPropFactory("popperClass")
},
computeTransformOrigin: {
type: Boolean,
default: defaultPropFactory("computeTransformOrigin")
},
autoMinSize: {
type: Boolean,
default: defaultPropFactory("autoMinSize")
},
autoSize: {
type: [Boolean, String],
default: defaultPropFactory("autoSize")
},
autoMaxSize: {
type: Boolean,
default: defaultPropFactory("autoMaxSize")
},
autoBoundaryMaxSize: {
type: Boolean,
default: defaultPropFactory("autoBoundaryMaxSize")
},
preventOverflow: {
type: Boolean,
default: defaultPropFactory("preventOverflow")
},
overflowPadding: {
type: [Number, String],
default: defaultPropFactory("overflowPadding")
},
arrowPadding: {
type: [Number, String],
default: defaultPropFactory("arrowPadding")
},
arrowOverflow: {
type: Boolean,
default: defaultPropFactory("arrowOverflow")
},
flip: {
type: Boolean,
default: defaultPropFactory("flip")
},
shift: {
type: Boolean,
default: defaultPropFactory("shift")
},
shiftCrossAxis: {
type: Boolean,
default: defaultPropFactory("shiftCrossAxis")
},
noAutoFocus: {
type: Boolean,
default: defaultPropFactory("noAutoFocus")
}
},
emits: [
"show",
"hide",
"update:shown",
"apply-show",
"apply-hide",
"close-group",
"close-directive",
"auto-hide",
"resize",
"dispose"
],
data() {
return {
isShown: false,
isMounted: false,
skipTransition: false,
classes: {
showFrom: false,
showTo: false,
hideFrom: false,
hideTo: true
},
result: {
x: 0,
y: 0,
placement: "",
strategy: this.strategy,
arrow: {
x: 0,
y: 0,
centerOffset: 0
},
transformOrigin: null
},
shownChildren: /* @__PURE__ */ new Set(),
lastAutoHide: true
};
},
computed: {
popperId() {
return this.ariaId != null ? this.ariaId : this.randomId;
},
shouldMountContent() {
return this.eagerMount || this.isMounted;
},
slotData() {
return {
popperId: this.popperId,
isShown: this.isShown,
shouldMountContent: this.shouldMountContent,
skipTransition: this.skipTransition,
autoHide: typeof this.autoHide === "function" ? this.lastAutoHide : this.autoHide,
show: this.show,
hide: this.hide,
handleResize: this.handleResize,
onResize: this.onResize,
classes: __spreadProps(__spreadValues$1({}, this.classes), {
popperClass: this.popperClass
}),
result: this.positioningDisabled ? null : this.result,
attrs: this.$attrs
};
},
parentPopper() {
var _a3;
return (_a3 = this[PROVIDE_KEY]) == null ? void 0 : _a3.parentPopper;
},
hasPopperShowTriggerHover() {
var _a3, _b2;
return ((_a3 = this.popperTriggers) == null ? void 0 : _a3.includes("hover")) || ((_b2 = this.popperShowTriggers) == null ? void 0 : _b2.includes("hover"));
}
},
watch: __spreadValues$1(__spreadValues$1({
shown: "$_autoShowHide",
disabled(value) {
if (value) {
this.dispose();
} else {
this.init();
}
},
async container() {
if (this.isShown) {
this.$_ensureTeleport();
await this.$_computePosition();
}
}
}, [
"triggers",
"positioningDisabled"
].reduce((acc, prop) => {
acc[prop] = "$_refreshListeners";
return acc;
}, {})), [
"placement",
"distance",
"skidding",
"boundary",
"strategy",
"overflowPadding",
"arrowPadding",
"preventOverflow",
"shift",
"shiftCrossAxis",
"flip"
].reduce((acc, prop) => {
acc[prop] = "$_computePosition";
return acc;
}, {})),
created() {
this.$_isDisposed = true;
this.randomId = `popper_${[Math.random(), Date.now()].map((n2) => n2.toString(36).substring(2, 10)).join("_")}`;
if (this.autoMinSize) {
console.warn('[floating-vue] `autoMinSize` option is deprecated. Use `autoSize="min"` instead.');
}
if (this.autoMaxSize) {
console.warn("[floating-vue] `autoMaxSize` option is deprecated. Use `autoBoundaryMaxSize` instead.");
}
},
mounted() {
this.init();
this.$_detachPopperNode();
},
activated() {
this.$_autoShowHide();
},
deactivated() {
this.hide();
},
beforeUnmount() {
this.dispose();
},
methods: {
show({ event = null, skipDelay = false, force = false } = {}) {
var _a3, _b2;
if (((_a3 = this.parentPopper) == null ? void 0 : _a3.lockedChild) && this.parentPopper.lockedChild !== this)
return;
this.$_pendingHide = false;
if (force || !this.disabled) {
if (((_b2 = this.parentPopper) == null ? void 0 : _b2.lockedChild) === this) {
this.parentPopper.lockedChild = null;
}
this.$_scheduleShow(event, skipDelay);
this.$emit("show");
this.$_showFrameLocked = true;
requestAnimationFrame(() => {
this.$_showFrameLocked = false;
});
}
this.$emit("update:shown", true);
},
hide({ event = null, skipDelay = false } = {}) {
var _a3;
if (this.$_hideInProgress)
return;
if (this.shownChildren.size > 0) {
this.$_pendingHide = true;
return;
}
if (this.hasPopperShowTriggerHover && this.$_isAimingPopper()) {
if (this.parentPopper) {
this.parentPopper.lockedChild = this;
clearTimeout(this.parentPopper.lockedChildTimer);
this.parentPopper.lockedChildTimer = setTimeout(() => {
if (this.parentPopper.lockedChild === this) {
this.parentPopper.lockedChild.hide({ skipDelay });
this.parentPopper.lockedChild = null;
}
}, 1e3);
}
return;
}
if (((_a3 = this.parentPopper) == null ? void 0 : _a3.lockedChild) === this) {
this.parentPopper.lockedChild = null;
}
this.$_pendingHide = false;
this.$_scheduleHide(event, skipDelay);
this.$emit("hide");
this.$emit("update:shown", false);
},
init() {
var _a3, _b2;
if (!this.$_isDisposed)
return;
this.$_isDisposed = false;
this.isMounted = false;
this.$_events = [];
this.$_preventShow = false;
this.$_referenceNode = (_b2 = (_a3 = this.referenceNode) == null ? void 0 : _a3.call(this)) != null ? _b2 : this.$el;
this.$_targetNodes = this.targetNodes().filter((e2) => e2.nodeType === e2.ELEMENT_NODE);
this.$_popperNode = this.popperNode();
this.$_innerNode = this.$_popperNode.querySelector(".v-popper__inner");
this.$_arrowNode = this.$_popperNode.querySelector(".v-popper__arrow-container");
this.$_swapTargetAttrs("title", "data-original-title");
this.$_detachPopperNode();
if (this.triggers.length) {
this.$_addEventListeners();
}
if (this.shown) {
this.show();
}
},
dispose() {
if (this.$_isDisposed)
return;
this.$_isDisposed = true;
this.$_removeEventListeners();
this.hide({ skipDelay: true });
this.$_detachPopperNode();
this.isMounted = false;
this.isShown = false;
this.$_updateParentShownChildren(false);
this.$_swapTargetAttrs("data-original-title", "title");
this.$emit("dispose");
},
async onResize() {
if (this.isShown) {
await this.$_computePosition();
this.$emit("resize");
}
},
async $_computePosition() {
var _a3;
if (this.$_isDisposed || this.positioningDisabled)
return;
const options2 = {
strategy: this.strategy,
middleware: []
};
if (this.distance || this.skidding) {
options2.middleware.push(offset({
mainAxis: this.distance,
crossAxis: this.skidding
}));
}
const isPlacementAuto = this.placement.startsWith("auto");
if (isPlacementAuto) {
options2.middleware.push(autoPlacement({
alignment: (_a3 = this.placement.split("-")[1]) != null ? _a3 : ""
}));
} else {
options2.placement = this.placement;
}
if (this.preventOverflow) {
if (this.shift) {
options2.middleware.push(shift({
padding: this.overflowPadding,
boundary: this.boundary,
crossAxis: this.shiftCrossAxis
}));
}
if (!isPlacementAuto && this.flip) {
options2.middleware.push(flip({
padding: this.overflowPadding,
boundary: this.boundary
}));
}
}
options2.middleware.push(arrow({
element: this.$_arrowNode,
padding: this.arrowPadding
}));
if (this.arrowOverflow) {
options2.middleware.push({
name: "arrowOverflow",
fn: ({ placement, rects, middlewareData }) => {
let overflow;
const { centerOffset } = middlewareData.arrow;
if (placement.startsWith("top") || placement.startsWith("bottom")) {
overflow = Math.abs(centerOffset) > rects.reference.width / 2;
} else {
overflow = Math.abs(centerOffset) > rects.reference.height / 2;
}
return {
data: {
overflow
}
};
}
});
}
if (this.autoMinSize || this.autoSize) {
const autoSize = this.autoSize ? this.autoSize : this.autoMinSize ? "min" : null;
options2.middleware.push({
name: "autoSize",
fn: ({ rects, placement, middlewareData }) => {
var _a22;
if ((_a22 = middlewareData.autoSize) == null ? void 0 : _a22.skip) {
return {};
}
let width;
let height;
if (placement.startsWith("top") || placement.startsWith("bottom")) {
width = rects.reference.width;
} else {
height = rects.reference.height;
}
this.$_innerNode.style[autoSize === "min" ? "minWidth" : autoSize === "max" ? "maxWidth" : "width"] = width != null ? `${width}px` : null;
this.$_innerNode.style[autoSize === "min" ? "minHeight" : autoSize === "max" ? "maxHeight" : "height"] = height != null ? `${height}px` : null;
return {
data: {
skip: true
},
reset: {
rects: true
}
};
}
});
}
if (this.autoMaxSize || this.autoBoundaryMaxSize) {
this.$_innerNode.style.maxWidth = null;
this.$_innerNode.style.maxHeight = null;
options2.middleware.push(size({
boundary: this.boundary,
padding: this.overflowPadding,
apply: ({ width, height }) => {
this.$_innerNode.style.maxWidth = width != null ? `${width}px` : null;
this.$_innerNode.style.maxHeight = height != null ? `${height}px` : null;
}
}));
}
const data = await computePosition(this.$_referenceNode, this.$_popperNode, options2);
Object.assign(this.result, {
x: data.x,
y: data.y,
placement: data.placement,
strategy: data.strategy,
arrow: __spreadValues$1(__spreadValues$1({}, data.middlewareData.arrow), data.middlewareData.arrowOverflow)
});
},
$_scheduleShow(event = null, skipDelay = false) {
this.$_updateParentShownChildren(true);
this.$_hideInProgress = false;
clearTimeout(this.$_scheduleTimer);
if (hidingPopper && this.instantMove && hidingPopper.instantMove && hidingPopper !== this.parentPopper) {
hidingPopper.$_applyHide(true);
this.$_applyShow(true);
return;
}
if (skipDelay) {
this.$_applyShow();
} else {
this.$_scheduleTimer = setTimeout(this.$_applyShow.bind(this), this.$_computeDelay("show"));
}
},
$_scheduleHide(event = null, skipDelay = false) {
if (this.shownChildren.size > 0) {
this.$_pendingHide = true;
return;
}
this.$_updateParentShownChildren(false);
this.$_hideInProgress = true;
clearTimeout(this.$_scheduleTimer);
if (this.isShown) {
hidingPopper = this;
}
if (skipDelay) {
this.$_applyHide();
} else {
this.$_scheduleTimer = setTimeout(this.$_applyHide.bind(this), this.$_computeDelay("hide"));
}
},
$_computeDelay(type) {
const delay = this.delay;
return parseInt(delay && delay[type] || delay || 0);
},
async $_applyShow(skipTransition = false) {
clearTimeout(this.$_disposeTimer);
clearTimeout(this.$_scheduleTimer);
this.skipTransition = skipTransition;
if (this.isShown) {
return;
}
this.$_ensureTeleport();
await nextFrame();
await this.$_computePosition();
await this.$_applyShowEffect();
if (!this.positioningDisabled) {
this.$_registerEventListeners([
...getScrollParents(this.$_referenceNode),
...getScrollParents(this.$_popperNode)
], "scroll", () => {
this.$_computePosition();
});
}
},
async $_applyShowEffect() {
if (this.$_hideInProgress)
return;
if (this.computeTransformOrigin) {
const bounds = this.$_referenceNode.getBoundingClientRect();
const popperWrapper = this.$_popperNode.querySelector(".v-popper__wrapper");
const parentBounds = popperWrapper.parentNode.getBoundingClientRect();
const x2 = bounds.x + bounds.width / 2 - (parentBounds.left + popperWrapper.offsetLeft);
const y2 = bounds.y + bounds.height / 2 - (parentBounds.top + popperWrapper.offsetTop);
this.result.transformOrigin = `${x2}px ${y2}px`;
}
this.isShown = true;
this.$_applyAttrsToTarget({
"aria-describedby": this.popperId,
"data-popper-shown": ""
});
const showGroup = this.showGroup;
if (showGroup) {
let popover;
for (let i2 = 0; i2 < shownPoppers.length; i2++) {
popover = shownPoppers[i2];
if (popover.showGroup !== showGroup) {
popover.hide();
popover.$emit("close-group");
}
}
}
shownPoppers.push(this);
document.body.classList.add("v-popper--some-open");
for (const theme of getAllParentThemes(this.theme)) {
getShownPoppersByTheme(theme).push(this);
document.body.classList.add(`v-popper--some-open--${theme}`);
}
this.$emit("apply-show");
this.classes.showFrom = true;
this.classes.showTo = false;
this.classes.hideFrom = false;
this.classes.hideTo = false;
await nextFrame();
this.classes.showFrom = false;
this.classes.showTo = true;
if (!this.noAutoFocus)
this.$_popperNode.focus();
},
async $_applyHide(skipTransition = false) {
if (this.shownChildren.size > 0) {
this.$_pendingHide = true;
this.$_hideInProgress = false;
return;
}
clearTimeout(this.$_scheduleTimer);
if (!this.isShown) {
return;
}
this.skipTransition = skipTransition;
removeFromArray(shownPoppers, this);
if (shownPoppers.length === 0) {
document.body.classList.remove("v-popper--some-open");
}
for (const theme of getAllParentThemes(this.theme)) {
const list = getShownPoppersByTheme(theme);
removeFromArray(list, this);
if (list.length === 0) {
document.body.classList.remove(`v-popper--some-open--${theme}`);
}
}
if (hidingPopper === this) {
hidingPopper = null;
}
this.isShown = false;
this.$_applyAttrsToTarget({
"aria-describedby": void 0,
"data-popper-shown": void 0
});
clearTimeout(this.$_disposeTimer);
const disposeTime = getDefaultConfig(this.theme, "disposeTimeout");
if (disposeTime !== null) {
this.$_disposeTimer = setTimeout(() => {
if (this.$_popperNode) {
this.$_detachPopperNode();
this.isMounted = false;
}
}, disposeTime);
}
this.$_removeEventListeners("scroll");
this.$emit("apply-hide");
this.classes.showFrom = false;
this.classes.showTo = false;
this.classes.hideFrom = true;
this.classes.hideTo = false;
await nextFrame();
this.classes.hideFrom = false;
this.classes.hideTo = true;
},
$_autoShowHide() {
if (this.shown) {
this.show();
} else {
this.hide();
}
},
$_ensureTeleport() {
if (this.$_isDisposed)
return;
let container = this.container;
if (typeof container === "string") {
container = window.document.querySelector(container);
} else if (container === false) {
container = this.$_targetNodes[0].parentNode;
}
if (!container) {
throw new Error("No container for popover: " + this.container);
}
container.appendChild(this.$_popperNode);
this.isMounted = true;
},
$_addEventListeners() {
const handleShow = (event) => {
if (this.isShown && !this.$_hideInProgress) {
return;
}
event.usedByTooltip = true;
!this.$_preventShow && this.show({ event });
};
this.$_registerTriggerListeners(this.$_targetNodes, SHOW_EVENT_MAP, this.triggers, this.showTriggers, handleShow);
this.$_registerTriggerListeners([this.$_popperNode], SHOW_EVENT_MAP, this.popperTriggers, this.popperShowTriggers, handleShow);
const handleHide = (event) => {
if (event.usedByTooltip) {
return;
}
this.hide({ event });
};
this.$_registerTriggerListeners(this.$_targetNodes, HIDE_EVENT_MAP, this.triggers, this.hideTriggers, handleHide);
this.$_registerTriggerListeners([this.$_popperNode], HIDE_EVENT_MAP, this.popperTriggers, this.popperHideTriggers, handleHide);
},
$_registerEventListeners(targetNodes, eventType, handler) {
this.$_events.push({ targetNodes, eventType, handler });
targetNodes.forEach((node) => node.addEventListener(eventType, handler, supportsPassive ? {
passive: true
} : void 0));
},
$_registerTriggerListeners(targetNodes, eventMap, commonTriggers, customTrigger, handler) {
let triggers = commonTriggers;
if (customTrigger != null) {
triggers = typeof customTrigger === "function" ? customTrigger(triggers) : customTrigger;
}
triggers.forEach((trigger2) => {
const eventType = eventMap[trigger2];
if (eventType) {
this.$_registerEventListeners(targetNodes, eventType, handler);
}
});
},
$_removeEventListeners(filterEventType) {
const newList = [];
this.$_events.forEach((listener) => {
const { targetNodes, eventType, handler } = listener;
if (!filterEventType || filterEventType === eventType) {
targetNodes.forEach((node) => node.removeEventListener(eventType, handler));
} else {
newList.push(listener);
}
});
this.$_events = newList;
},
$_refreshListeners() {
if (!this.$_isDisposed) {
this.$_removeEventListeners();
this.$_addEventListeners();
}
},
$_handleGlobalClose(event, touch = false) {
if (this.$_showFrameLocked)
return;
this.hide({ event });
if (event.closePopover) {
this.$emit("close-directive");
} else {
this.$emit("auto-hide");
}
if (touch) {
this.$_preventShow = true;
setTimeout(() => {
this.$_preventShow = false;
}, 300);
}
},
$_detachPopperNode() {
this.$_popperNode.parentNode && this.$_popperNode.parentNode.removeChild(this.$_popperNode);
},
$_swapTargetAttrs(attrFrom, attrTo) {
for (const el2 of this.$_targetNodes) {
const value = el2.getAttribute(attrFrom);
if (value) {
el2.removeAttribute(attrFrom);
el2.setAttribute(attrTo, value);
}
}
},
$_applyAttrsToTarget(attrs) {
for (const el2 of this.$_targetNodes) {
for (const n2 in attrs) {
const value = attrs[n2];
if (value == null) {
el2.removeAttribute(n2);
} else {
el2.setAttribute(n2, value);
}
}
}
},
$_updateParentShownChildren(value) {
let parent = this.parentPopper;
while (parent) {
if (value) {
parent.shownChildren.add(this.randomId);
} else {
parent.shownChildren.delete(this.randomId);
if (parent.$_pendingHide) {
parent.hide();
}
}
parent = parent.parentPopper;
}
},
$_isAimingPopper() {
const referenceBounds = this.$_referenceNode.getBoundingClientRect();
if (mouseX >= referenceBounds.left && mouseX <= referenceBounds.right && mouseY >= referenceBounds.top && mouseY <= referenceBounds.bottom) {
const popperBounds = this.$_popperNode.getBoundingClientRect();
const vectorX = mouseX - mousePreviousX;
const vectorY = mouseY - mousePreviousY;
const distance = popperBounds.left + popperBounds.width / 2 - mousePreviousX + (popperBounds.top + popperBounds.height / 2) - mousePreviousY;
const newVectorLength = distance + popperBounds.width + popperBounds.height;
const edgeX = mousePreviousX + vectorX * newVectorLength;
const edgeY = mousePreviousY + vectorY * newVectorLength;
return lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.left, popperBounds.top, popperBounds.left, popperBounds.bottom) || lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.left, popperBounds.top, popperBounds.right, popperBounds.top) || lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.right, popperBounds.top, popperBounds.right, popperBounds.bottom) || lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.left, popperBounds.bottom, popperBounds.right, popperBounds.bottom);
}
return false;
}
},
render() {
return this.$slots.default(this.slotData);
}
});
if (typeof document !== "undefined" && typeof window !== "undefined") {
if (isIOS) {
document.addEventListener("touchstart", handleGlobalMousedown, supportsPassive ? {
passive: true,
capture: true
} : true);
document.addEventListener("touchend", handleGlobalTouchend, supportsPassive ? {
passive: true,
capture: true
} : true);
} else {
window.addEventListener("mousedown", handleGlobalMousedown, true);
window.addEventListener("click", handleGlobalClick, true);
}
window.addEventListener("resize", computePositionAllShownPoppers);
}
function handleGlobalMousedown(event) {
for (let i2 = 0; i2 < shownPoppers.length; i2++) {
const popper = shownPoppers[i2];
try {
const popperContent = popper.popperNode();
popper.$_mouseDownContains = popperContent.contains(event.target);
} catch (e2) {
}
}
}
function handleGlobalClick(event) {
handleGlobalClose(event);
}
function handleGlobalTouchend(event) {
handleGlobalClose(event, true);
}
function handleGlobalClose(event, touch = false) {
const preventClose = {};
for (let i2 = shownPoppers.length - 1; i2 >= 0; i2--) {
const popper = shownPoppers[i2];
try {
const contains2 = popper.$_containsGlobalTarget = isContainingEventTarget(popper, event);
popper.$_pendingHide = false;
requestAnimationFrame(() => {
popper.$_pendingHide = false;
if (preventClose[popper.randomId])
return;
if (shouldAutoHide(popper, contains2, event)) {
popper.$_handleGlobalClose(event, touch);
if (!event.closeAllPopover && event.closePopover && contains2) {
let parent2 = popper.parentPopper;
while (parent2) {
preventClose[parent2.randomId] = true;
parent2 = parent2.parentPopper;
}
return;
}
let parent = popper.parentPopper;
while (parent) {
if (shouldAutoHide(parent, parent.$_containsGlobalTarget, event)) {
parent.$_handleGlobalClose(event, touch);
} else {
break;
}
parent = parent.parentPopper;
}
}
});
} catch (e2) {
}
}
}
function isContainingEventTarget(popper, event) {
const popperContent = popper.popperNode();
return popper.$_mouseDownContains || popperContent.contains(event.target);
}
function shouldAutoHide(popper, contains2, event) {
return event.closeAllPopover || event.closePopover && contains2 || getAutoHideResult(popper, event) && !contains2;
}
function getAutoHideResult(popper, event) {
if (typeof popper.autoHide === "function") {
const result = popper.autoHide(event);
popper.lastAutoHide = result;
return result;
}
return popper.autoHide;
}
function computePositionAllShownPoppers(event) {
for (let i2 = 0; i2 < shownPoppers.length; i2++) {
const popper = shownPoppers[i2];
popper.$_computePosition(event);
}
}
let mousePreviousX = 0;
let mousePreviousY = 0;
let mouseX = 0;
let mouseY = 0;
if (typeof window !== "undefined") {
window.addEventListener("mousemove", (event) => {
mousePreviousX = mouseX;
mousePreviousY = mouseY;
mouseX = event.clientX;
mouseY = event.clientY;
}, supportsPassive ? {
passive: true
} : void 0);
}
function lineIntersectsLine(x1, y1, x2, y2, x3, y3, x4, y4) {
const uA = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1));
const uB = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1));
return uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1;
}
var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _sfc_main$6 = {
extends: PrivatePopper()
};
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", {
ref: "reference",
class: normalizeClass(["v-popper", {
"v-popper--shown": _ctx.slotData.isShown
}])
}, [
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(_ctx.slotData)))
], 2);
}
var Popper$1 = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$3]]);
function getInternetExplorerVersion() {
var ua2 = window.navigator.userAgent;
var msie = ua2.indexOf("MSIE ");
if (msie > 0) {
return parseInt(ua2.substring(msie + 5, ua2.indexOf(".", msie)), 10);
}
var trident = ua2.indexOf("Trident/");
if (trident > 0) {
var rv = ua2.indexOf("rv:");
return parseInt(ua2.substring(rv + 3, ua2.indexOf(".", rv)), 10);
}
var edge = ua2.indexOf("Edge/");
if (edge > 0) {
return parseInt(ua2.substring(edge + 5, ua2.indexOf(".", edge)), 10);
}
return -1;
}
let isIE;
function initCompat() {
if (!initCompat.init) {
initCompat.init = true;
isIE = getInternetExplorerVersion() !== -1;
}
}
var script = {
name: "ResizeObserver",
props: {
emitOnMount: {
type: Boolean,
default: false
},
ignoreWidth: {
type: Boolean,
default: false
},
ignoreHeight: {
type: Boolean,
default: false
}
},
emits: [
"notify"
],
mounted() {
initCompat();
nextTick(() => {
this._w = this.$el.offsetWidth;
this._h = this.$el.offsetHeight;
if (this.emitOnMount) {
this.emitSize();
}
});
const object = document.createElement("object");
this._resizeObject = object;
object.setAttribute("aria-hidden", "true");
object.setAttribute("tabindex", -1);
object.onload = this.addResizeHandlers;
object.type = "text/html";
if (isIE) {
this.$el.appendChild(object);
}
object.data = "about:blank";
if (!isIE) {
this.$el.appendChild(object);
}
},
beforeUnmount() {
this.removeResizeHandlers();
},
methods: {
compareAndNotify() {
if (!this.ignoreWidth && this._w !== this.$el.offsetWidth || !this.ignoreHeight && this._h !== this.$el.offsetHeight) {
this._w = this.$el.offsetWidth;
this._h = this.$el.offsetHeight;
this.emitSize();
}
},
emitSize() {
this.$emit("notify", {
width: this._w,
height: this._h
});
},
addResizeHandlers() {
this._resizeObject.contentDocument.defaultView.addEventListener("resize", this.compareAndNotify);
this.compareAndNotify();
},
removeResizeHandlers() {
if (this._resizeObject && this._resizeObject.onload) {
if (!isIE && this._resizeObject.contentDocument) {
this._resizeObject.contentDocument.defaultView.removeEventListener("resize", this.compareAndNotify);
}
this.$el.removeChild(this._resizeObject);
this._resizeObject.onload = null;
this._resizeObject = null;
}
}
}
};
const _withId = /* @__PURE__ */ withScopeId();
pushScopeId("data-v-b329ee4c");
const _hoisted_1$2 = {
class: "resize-observer",
tabindex: "-1"
};
popScopeId();
const render$1 = /* @__PURE__ */ _withId((_ctx, _cache, $props, $setup, $data, $options) => {
return openBlock(), createBlock("div", _hoisted_1$2);
});
script.render = render$1;
script.__scopeId = "data-v-b329ee4c";
script.__file = "src/components/ResizeObserver.vue";
var PrivateThemeClass = (prop = "theme") => ({
computed: {
themeClass() {
return getThemeClasses(this[prop]);
}
}
});
const _sfc_main$5 = defineComponent({
name: "VPopperContent",
components: {
ResizeObserver: script
},
mixins: [
PrivateThemeClass()
],
props: {
popperId: String,
theme: String,
shown: Boolean,
mounted: Boolean,
skipTransition: Boolean,
autoHide: Boolean,
handleResize: Boolean,
classes: Object,
result: Object
},
emits: [
"hide",
"resize"
],
methods: {
toPx(value) {
if (value != null && !isNaN(value)) {
return `${value}px`;
}
return null;
}
}
});
const _hoisted_1$1 = ["id", "aria-hidden", "tabindex", "data-popper-placement"];
const _hoisted_2$1 = {
ref: "inner",
class: "v-popper__inner"
};
const _hoisted_3 = /* @__PURE__ */ createBaseVNode("div", { class: "v-popper__arrow-outer" }, null, -1);
const _hoisted_4 = /* @__PURE__ */ createBaseVNode("div", { class: "v-popper__arrow-inner" }, null, -1);
const _hoisted_5 = [
_hoisted_3,
_hoisted_4
];
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
const _component_ResizeObserver = resolveComponent("ResizeObserver");
return openBlock(), createElementBlock("div", {
id: _ctx.popperId,
ref: "popover",
class: normalizeClass(["v-popper__popper", [
_ctx.themeClass,
_ctx.classes.popperClass,
{
"v-popper__popper--shown": _ctx.shown,
"v-popper__popper--hidden": !_ctx.shown,
"v-popper__popper--show-from": _ctx.classes.showFrom,
"v-popper__popper--show-to": _ctx.classes.showTo,
"v-popper__popper--hide-from": _ctx.classes.hideFrom,
"v-popper__popper--hide-to": _ctx.classes.hideTo,
"v-popper__popper--skip-transition": _ctx.skipTransition,
"v-popper__popper--arrow-overflow": _ctx.result && _ctx.result.arrow.overflow,
"v-popper__popper--no-positioning": !_ctx.result
}
]]),
style: normalizeStyle(_ctx.result ? {
position: _ctx.result.strategy,
transform: `translate3d(${Math.round(_ctx.result.x)}px,${Math.round(_ctx.result.y)}px,0)`
} : void 0),
"aria-hidden": _ctx.shown ? "false" : "true",
tabindex: _ctx.autoHide ? 0 : void 0,
"data-popper-placement": _ctx.result ? _ctx.result.placement : void 0,
onKeyup: _cache[2] || (_cache[2] = withKeys(($event) => _ctx.autoHide && _ctx.$emit("hide"), ["esc"]))
}, [
createBaseVNode("div", {
class: "v-popper__backdrop",
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.autoHide && _ctx.$emit("hide"))
}),
createBaseVNode("div", {
class: "v-popper__wrapper",
style: normalizeStyle(_ctx.result ? {
transformOrigin: _ctx.result.transformOrigin
} : void 0)
}, [
createBaseVNode("div", _hoisted_2$1, [
_ctx.mounted ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
createBaseVNode("div", null, [
renderSlot(_ctx.$slots, "default")
]),
_ctx.handleResize ? (openBlock(), createBlock(_component_ResizeObserver, {
key: 0,
onNotify: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("resize", $event))
})) : createCommentVNode("", true)
], 64)) : createCommentVNode("", true)
], 512),
createBaseVNode("div", {
ref: "arrow",
class: "v-popper__arrow-container",
style: normalizeStyle(_ctx.result ? {
left: _ctx.toPx(_ctx.result.arrow.x),
top: _ctx.toPx(_ctx.result.arrow.y)
} : void 0)
}, _hoisted_5, 4)
], 4)
], 46, _hoisted_1$1);
}
var PrivatePopperContent = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$2]]);
var PrivatePopperMethods = {
methods: {
show(...args) {
return this.$refs.popper.show(...args);
},
hide(...args) {
return this.$refs.popper.hide(...args);
},
dispose(...args) {
return this.$refs.popper.dispose(...args);
},
onResize(...args) {
return this.$refs.popper.onResize(...args);
}
}
};
const _sfc_main$4 = defineComponent({
name: "VPopperWrapper",
components: {
Popper: Popper$1,
PopperContent: PrivatePopperContent
},
mixins: [
PrivatePopperMethods,
PrivateThemeClass("finalTheme")
],
props: {
theme: {
type: String,
default: null
}
},
computed: {
finalTheme() {
var _a3;
return (_a3 = this.theme) != null ? _a3 : this.$options.vPopperTheme;
}
},
methods: {
getTargetNodes() {
return Array.from(this.$el.children).filter((node) => node !== this.$refs.popperContent.$el);
}
}
});
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
const _component_PopperContent = resolveComponent("PopperContent");
const _component_Popper = resolveComponent("Popper");
return openBlock(), createBlock(_component_Popper, {
ref: "popper",
theme: _ctx.finalTheme,
"target-nodes": _ctx.getTargetNodes,
"popper-node": () => _ctx.$refs.popperContent.$el,
class: normalizeClass([
_ctx.themeClass
])
}, {
default: withCtx(({
popperId,
isShown,
shouldMountContent,
skipTransition,
autoHide,
show,
hide,
handleResize,
onResize,
classes,
result
}) => [
renderSlot(_ctx.$slots, "default", {
shown: isShown,
show,
hide
}),
createVNode(_component_PopperContent, {
ref: "popperContent",
"popper-id": popperId,
theme: _ctx.finalTheme,
shown: isShown,
mounted: shouldMountContent,
"skip-transition": skipTransition,
"auto-hide": autoHide,
"handle-resize": handleResize,
classes,
result,
onHide: hide,
onResize
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "popper", {
shown: isShown,
hide
})
]),
_: 2
}, 1032, ["popper-id", "theme", "shown", "mounted", "skip-transition", "auto-hide", "handle-resize", "classes", "result", "onHide", "onResize"])
]),
_: 3
}, 8, ["theme", "target-nodes", "popper-node", "class"]);
}
var PrivatePopperWrapper = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$1]]);
const _sfc_main$3 = defineComponent(__spreadProps(__spreadValues$1({}, PrivatePopperWrapper), {
name: "VDropdown",
vPopperTheme: "dropdown"
}));
const _sfc_main$2 = defineComponent(__spreadProps(__spreadValues$1({}, PrivatePopperWrapper), {
name: "VMenu",
vPopperTheme: "menu"
}));
const _sfc_main$1 = defineComponent(__spreadProps(__spreadValues$1({}, PrivatePopperWrapper), {
name: "VTooltip",
vPopperTheme: "tooltip"
}));
const _sfc_main = defineComponent({
name: "VTooltipDirective",
components: {
Popper: PrivatePopper(),
PopperContent: PrivatePopperContent
},
mixins: [
PrivatePopperMethods
],
inheritAttrs: false,
props: {
theme: {
type: String,
default: "tooltip"
},
html: {
type: Boolean,
default: (props) => getDefaultConfig(props.theme, "html")
},
content: {
type: [String, Number, Function],
default: null
},
loadingContent: {
type: String,
default: (props) => getDefaultConfig(props.theme, "loadingContent")
}
},
data() {
return {
asyncContent: null
};
},
computed: {
isContentAsync() {
return typeof this.content === "function";
},
loading() {
return this.isContentAsync && this.asyncContent == null;
},
finalContent() {
if (this.isContentAsync) {
return this.loading ? this.loadingContent : this.asyncContent;
}
return this.content;
}
},
watch: {
content: {
handler() {
this.fetchContent(true);
},
immediate: true
},
async finalContent() {
await this.$nextTick();
this.$refs.popper.onResize();
}
},
created() {
this.$_fetchId = 0;
},
methods: {
fetchContent(force) {
if (typeof this.content === "function" && this.$_isShown && (force || !this.$_loading && this.asyncContent == null)) {
this.asyncContent = null;
this.$_loading = true;
const fetchId = ++this.$_fetchId;
const result = this.content(this);
if (result.then) {
result.then((res) => this.onResult(fetchId, res));
} else {
this.onResult(fetchId, result);
}
}
},
onResult(fetchId, result) {
if (fetchId !== this.$_fetchId)
return;
this.$_loading = false;
this.asyncContent = result;
},
onShow() {
this.$_isShown = true;
this.fetchContent();
},
onHide() {
this.$_isShown = false;
}
}
});
const _hoisted_1 = ["innerHTML"];
const _hoisted_2 = ["textContent"];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_PopperContent = resolveComponent("PopperContent");
const _component_Popper = resolveComponent("Popper");
return openBlock(), createBlock(_component_Popper, mergeProps({ ref: "popper" }, _ctx.$attrs, {
theme: _ctx.theme,
"popper-node": () => _ctx.$refs.popperContent.$el,
onApplyShow: _ctx.onShow,
onApplyHide: _ctx.onHide
}), {
default: withCtx(({
popperId,
isShown,
shouldMountContent,
skipTransition,
autoHide,
hide,
handleResize,
onResize,
classes,
result
}) => [
createVNode(_component_PopperContent, {
ref: "popperContent",
class: normalizeClass({
"v-popper--tooltip-loading": _ctx.loading
}),
"popper-id": popperId,
theme: _ctx.theme,
shown: isShown,
mounted: shouldMountContent,
"skip-transition": skipTransition,
"auto-hide": autoHide,
"handle-resize": handleResize,
classes,
result,
onHide: hide,
onResize
}, {
default: withCtx(() => [
_ctx.html ? (openBlock(), createElementBlock("div", {
key: 0,
innerHTML: _ctx.finalContent
}, null, 8, _hoisted_1)) : (openBlock(), createElementBlock("div", {
key: 1,
textContent: toDisplayString(_ctx.finalContent)
}, null, 8, _hoisted_2))
]),
_: 2
}, 1032, ["class", "popper-id", "theme", "shown", "mounted", "skip-transition", "auto-hide", "handle-resize", "classes", "result", "onHide", "onResize"])
]),
_: 1
}, 16, ["theme", "popper-node", "onApplyShow", "onApplyHide"]);
}
var PrivateTooltipDirective = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
const TARGET_CLASS = "v-popper--has-tooltip";
function getPlacement(options2, modifiers) {
let result = options2.placement;
if (!result && modifiers) {
for (const pos of placements) {
if (modifiers[pos]) {
result = pos;
}
}
}
if (!result) {
result = getDefaultConfig(options2.theme || "tooltip", "placement");
}
return result;
}
function getOptions$1(el2, value, modifiers) {
let options2;
const type = typeof value;
if (type === "string") {
options2 = { content: value };
} else if (value && type === "object") {
options2 = value;
} else {
options2 = { content: false };
}
options2.placement = getPlacement(options2, modifiers);
options2.targetNodes = () => [el2];
options2.referenceNode = () => el2;
return options2;
}
let directiveApp;
let directives;
let uid = 0;
function ensureDirectiveApp() {
if (directiveApp)
return;
directives = ref([]);
directiveApp = createApp({
name: "VTooltipDirectiveApp",
setup() {
return {
directives
};
},
render() {
return this.directives.map((directive) => {
return h$1(PrivateTooltipDirective, __spreadProps(__spreadValues$1({}, directive.options), {
shown: directive.shown || directive.options.shown,
key: directive.id
}));
});
},
devtools: {
hide: true
}
});
const mountTarget = document.createElement("div");
document.body.appendChild(mountTarget);
directiveApp.mount(mountTarget);
}
function createTooltip(el2, value, modifiers) {
ensureDirectiveApp();
const options2 = ref(getOptions$1(el2, value, modifiers));
const shown = ref(false);
const item = {
id: uid++,
options: options2,
shown
};
directives.value.push(item);
if (el2.classList) {
el2.classList.add(TARGET_CLASS);
}
const result = el2.$_popper = {
options: options2,
item,
show() {
shown.value = true;
},
hide() {
shown.value = false;
}
};
return result;
}
function destroyTooltip(el2) {
if (el2.$_popper) {
const index2 = directives.value.indexOf(el2.$_popper.item);
if (index2 !== -1)
directives.value.splice(index2, 1);
delete el2.$_popper;
delete el2.$_popperOldShown;
delete el2.$_popperMountTarget;
}
if (el2.classList) {
el2.classList.remove(TARGET_CLASS);
}
}
function bind$1(el2, { value, modifiers }) {
const options2 = getOptions$1(el2, value, modifiers);
if (!options2.content || getDefaultConfig(options2.theme || "tooltip", "disabled")) {
destroyTooltip(el2);
} else {
let directive;
if (el2.$_popper) {
directive = el2.$_popper;
directive.options.value = options2;
} else {
directive = createTooltip(el2, value, modifiers);
}
if (typeof value.shown !== "undefined" && value.shown !== el2.$_popperOldShown) {
el2.$_popperOldShown = value.shown;
value.shown ? directive.show() : directive.hide();
}
}
}
var PrivateVTooltip = {
beforeMount: bind$1,
updated: bind$1,
beforeUnmount(el2) {
destroyTooltip(el2);
}
};
function addListeners(el2) {
el2.addEventListener("click", onClick);
el2.addEventListener("touchstart", onTouchStart, supportsPassive ? {
passive: true
} : false);
}
function removeListeners(el2) {
el2.removeEventListener("click", onClick);
el2.removeEventListener("touchstart", onTouchStart);
el2.removeEventListener("touchend", onTouchEnd);
el2.removeEventListener("touchcancel", onTouchCancel);
}
function onClick(event) {
const el2 = event.currentTarget;
event.closePopover = !el2.$_vclosepopover_touch;
event.closeAllPopover = el2.$_closePopoverModifiers && !!el2.$_closePopoverModifiers.all;
}
function onTouchStart(event) {
if (event.changedTouches.length === 1) {
const el2 = event.currentTarget;
el2.$_vclosepopover_touch = true;
const touch = event.changedTouches[0];
el2.$_vclosepopover_touchPoint = touch;
el2.addEventListener("touchend", onTouchEnd);
el2.addEventListener("touchcancel", onTouchCancel);
}
}
function onTouchEnd(event) {
const el2 = event.currentTarget;
el2.$_vclosepopover_touch = false;
if (event.changedTouches.length === 1) {
const touch = event.changedTouches[0];
const firstTouch = el2.$_vclosepopover_touchPoint;
event.closePopover = Math.abs(touch.screenY - firstTouch.screenY) < 20 && Math.abs(touch.screenX - firstTouch.screenX) < 20;
event.closeAllPopover = el2.$_closePopoverModifiers && !!el2.$_closePopoverModifiers.all;
}
}
function onTouchCancel(event) {
const el2 = event.currentTarget;
el2.$_vclosepopover_touch = false;
}
var PrivateVClosePopper = {
beforeMount(el2, { value, modifiers }) {
el2.$_closePopoverModifiers = modifiers;
if (typeof value === "undefined" || value) {
addListeners(el2);
}
},
updated(el2, { value, oldValue, modifiers }) {
el2.$_closePopoverModifiers = modifiers;
if (value !== oldValue) {
if (typeof value === "undefined" || value) {
addListeners(el2);
} else {
removeListeners(el2);
}
}
},
beforeUnmount(el2) {
removeListeners(el2);
}
};
const VTooltip = PrivateVTooltip;
const Dropdown = _sfc_main$3;
function install(app, options2 = {}) {
if (app.$_vTooltipInstalled)
return;
app.$_vTooltipInstalled = true;
assign$2(config$2, options2);
app.directive("tooltip", PrivateVTooltip);
app.directive("close-popper", PrivateVClosePopper);
app.component("VTooltip", _sfc_main$1);
app.component("VDropdown", _sfc_main$3);
app.component("VMenu", _sfc_main$2);
}
const plugin = {
version: "2.0.0-beta.20",
install,
options: config$2
};
const scriptRel = "modulepreload";
const assetsURL = function(dep) {
return "/" + dep;
};
const seen = {};
const __vitePreload = function preload(baseModule, deps, importerUrl) {
if (!deps || deps.length === 0) {
return baseModule();
}
const links = document.getElementsByTagName("link");
return Promise.all(deps.map((dep) => {
dep = assetsURL(dep);
if (dep in seen)
return;
seen[dep] = true;
const isCss = dep.endsWith(".css");
const cssSelector = isCss ? '[rel="stylesheet"]' : "";
const isBaseRelative = !!importerUrl;
if (isBaseRelative) {
for (let i2 = links.length - 1; i2 >= 0; i2--) {
const link2 = links[i2];
if (link2.href === dep && (!isCss || link2.rel === "stylesheet")) {
return;
}
}
} else if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) {
return;
}
const link = document.createElement("link");
link.rel = isCss ? "stylesheet" : scriptRel;
if (!isCss) {
link.as = "script";
link.crossOrigin = "";
}
link.href = dep;
document.head.appendChild(link);
if (isCss) {
return new Promise((res, rej) => {
link.addEventListener("load", res);
link.addEventListener("error", () => rej(new Error(`Unable to preload CSS for ${dep}`)));
});
}
})).then(() => baseModule());
};
function noop$2() {
}
function assign$1(tar, src) {
for (const k2 in src)
tar[k2] = src[k2];
return tar;
}
function add_location(element2, file, line, column, char) {
element2.__svelte_meta = {
loc: { file, line, column, char }
};
}
function run(fn2) {
return fn2();
}
function blank_object() {
return /* @__PURE__ */ Object.create(null);
}
function run_all(fns) {
fns.forEach(run);
}
function is_function(thing) {
return typeof thing === "function";
}
function safe_not_equal(a2, b3) {
return a2 != a2 ? b3 == b3 : a2 !== b3 || (a2 && typeof a2 === "object" || typeof a2 === "function");
}
let src_url_equal_anchor;
function src_url_equal(element_src, url) {
if (!src_url_equal_anchor) {
src_url_equal_anchor = document.createElement("a");
}
src_url_equal_anchor.href = url;
return element_src === src_url_equal_anchor.href;
}
function is_empty(obj) {
return Object.keys(obj).length === 0;
}
function create_slot(definition, ctx, $$scope, fn2) {
if (definition) {
const slot_ctx = get_slot_context(definition, ctx, $$scope, fn2);
return definition[0](slot_ctx);
}
}
function get_slot_context(definition, ctx, $$scope, fn2) {
return definition[1] && fn2 ? assign$1($$scope.ctx.slice(), definition[1](fn2(ctx))) : $$scope.ctx;
}
function get_slot_changes(definition, $$scope, dirty, fn2) {
if (definition[2] && fn2) {
const lets = definition[2](fn2(dirty));
if ($$scope.dirty === void 0) {
return lets;
}
if (typeof lets === "object") {
const merged = [];
const len = Math.max($$scope.dirty.length, lets.length);
for (let i2 = 0; i2 < len; i2 += 1) {
merged[i2] = $$scope.dirty[i2] | lets[i2];
}
return merged;
}
return $$scope.dirty | lets;
}
return $$scope.dirty;
}
function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
if (slot_changes) {
const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
slot.p(slot_context, slot_changes);
}
}
function get_all_dirty_from_scope($$scope) {
if ($$scope.ctx.length > 32) {
const dirty = [];
const length = $$scope.ctx.length / 32;
for (let i2 = 0; i2 < length; i2++) {
dirty[i2] = -1;
}
return dirty;
}
return -1;
}
function exclude_internal_props(props) {
const result = {};
for (const k2 in props)
if (k2[0] !== "$")
result[k2] = props[k2];
return result;
}
function compute_rest_props(props, keys) {
const rest = {};
keys = new Set(keys);
for (const k2 in props)
if (!keys.has(k2) && k2[0] !== "$")
rest[k2] = props[k2];
return rest;
}
function compute_slots(slots) {
const result = {};
for (const key in slots) {
result[key] = true;
}
return result;
}
let is_hydrating = false;
function start_hydrating() {
is_hydrating = true;
}
function end_hydrating() {
is_hydrating = false;
}
function upper_bound(low, high, key, value) {
while (low < high) {
const mid = low + (high - low >> 1);
if (key(mid) <= value) {
low = mid + 1;
} else {
high = mid;
}
}
return low;
}
function init_hydrate(target) {
if (target.hydrate_init)
return;
target.hydrate_init = true;
let children2 = target.childNodes;
if (target.nodeName === "HEAD") {
const myChildren = [];
for (let i2 = 0; i2 < children2.length; i2++) {
const node = children2[i2];
if (node.claim_order !== void 0) {
myChildren.push(node);
}
}
children2 = myChildren;
}
const m2 = new Int32Array(children2.length + 1);
const p2 = new Int32Array(children2.length);
m2[0] = -1;
let longest = 0;
for (let i2 = 0; i2 < children2.length; i2++) {
const current = children2[i2].claim_order;
const seqLen = (longest > 0 && children2[m2[longest]].claim_order <= current ? longest + 1 : upper_bound(1, longest, (idx) => children2[m2[idx]].claim_order, current)) - 1;
p2[i2] = m2[seqLen] + 1;
const newLen = seqLen + 1;
m2[newLen] = i2;
longest = Math.max(newLen, longest);
}
const lis = [];
const toMove = [];
let last = children2.length - 1;
for (let cur = m2[longest] + 1; cur != 0; cur = p2[cur - 1]) {
lis.push(children2[cur - 1]);
for (; last >= cur; last--) {
toMove.push(children2[last]);
}
last--;
}
for (; last >= 0; last--) {
toMove.push(children2[last]);
}
lis.reverse();
toMove.sort((a2, b3) => a2.claim_order - b3.claim_order);
for (let i2 = 0, j2 = 0; i2 < toMove.length; i2++) {
while (j2 < lis.length && toMove[i2].claim_order >= lis[j2].claim_order) {
j2++;
}
const anchor = j2 < lis.length ? lis[j2] : null;
target.insertBefore(toMove[i2], anchor);
}
}
function append(target, node) {
target.appendChild(node);
}
function append_hydration(target, node) {
if (is_hydrating) {
init_hydrate(target);
if (target.actual_end_child === void 0 || target.actual_end_child !== null && target.actual_end_child.parentNode !== target) {
target.actual_end_child = target.firstChild;
}
while (target.actual_end_child !== null && target.actual_end_child.claim_order === void 0) {
target.actual_end_child = target.actual_end_child.nextSibling;
}
if (node !== target.actual_end_child) {
if (node.claim_order !== void 0 || node.parentNode !== target) {
target.insertBefore(node, target.actual_end_child);
}
} else {
target.actual_end_child = node.nextSibling;
}
} else if (node.parentNode !== target || node.nextSibling !== null) {
target.appendChild(node);
}
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor || null);
}
function insert_hydration(target, node, anchor) {
if (is_hydrating && !anchor) {
append_hydration(target, node);
} else if (node.parentNode !== target || node.nextSibling != anchor) {
target.insertBefore(node, anchor || null);
}
}
function detach(node) {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
}
function element(name) {
return document.createElement(name);
}
function text(data) {
return document.createTextNode(data);
}
function space() {
return text(" ");
}
function empty() {
return text("");
}
function listen(node, event, handler, options) {
node.addEventListener(event, handler, options);
return () => node.removeEventListener(event, handler, options);
}
function attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
node.setAttribute(attribute, value);
}
function to_number(value) {
return value === "" ? null : +value;
}
function children(element2) {
return Array.from(element2.childNodes);
}
function init_claim_info(nodes) {
if (nodes.claim_info === void 0) {
nodes.claim_info = { last_index: 0, total_claimed: 0 };
}
}
function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) {
init_claim_info(nodes);
const resultNode = (() => {
for (let i2 = nodes.claim_info.last_index; i2 < nodes.length; i2++) {
const node = nodes[i2];
if (predicate(node)) {
const replacement = processNode(node);
if (replacement === void 0) {
nodes.splice(i2, 1);
} else {
nodes[i2] = replacement;
}
if (!dontUpdateLastIndex) {
nodes.claim_info.last_index = i2;
}
return node;
}
}
for (let i2 = nodes.claim_info.last_index - 1; i2 >= 0; i2--) {
const node = nodes[i2];
if (predicate(node)) {
const replacement = processNode(node);
if (replacement === void 0) {
nodes.splice(i2, 1);
} else {
nodes[i2] = replacement;
}
if (!dontUpdateLastIndex) {
nodes.claim_info.last_index = i2;
} else if (replacement === void 0) {
nodes.claim_info.last_index--;
}
return node;
}
}
return createNode();
})();
resultNode.claim_order = nodes.claim_info.total_claimed;
nodes.claim_info.total_claimed += 1;
return resultNode;
}
function claim_element_base(nodes, name, attributes, create_element) {
return claim_node(nodes, (node) => node.nodeName === name, (node) => {
const remove2 = [];
for (let j2 = 0; j2 < node.attributes.length; j2++) {
const attribute = node.attributes[j2];
if (!attributes[attribute.name]) {
remove2.push(attribute.name);
}
}
remove2.forEach((v2) => node.removeAttribute(v2));
return void 0;
}, () => create_element(name));
}
function claim_element(nodes, name, attributes) {
return claim_element_base(nodes, name, attributes, element);
}
function claim_text(nodes, data) {
return claim_node(
nodes,
(node) => node.nodeType === 3,
(node) => {
const dataStr = "" + data;
if (node.data.startsWith(dataStr)) {
if (node.data.length !== dataStr.length) {
return node.splitText(dataStr.length);
}
} else {
node.data = dataStr;
}
},
() => text(data),
true
// Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements
);
}
function claim_space(nodes) {
return claim_text(nodes, " ");
}
function set_data(text2, data) {
data = "" + data;
if (text2.wholeText !== data)
text2.data = data;
}
function set_input_value(input, value) {
input.value = value == null ? "" : value;
}
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
const e2 = document.createEvent("CustomEvent");
e2.initCustomEvent(type, bubbles, cancelable, detail);
return e2;
}
let current_component;
function set_current_component(component) {
current_component = component;
}
function get_current_component() {
if (!current_component)
throw new Error("Function called outside component initialization");
return current_component;
}
function onMount(fn2) {
get_current_component().$$.on_mount.push(fn2);
}
function afterUpdate(fn2) {
get_current_component().$$.after_update.push(fn2);
}
function createEventDispatcher() {
const component = get_current_component();
return (type, detail, { cancelable = false } = {}) => {
const callbacks2 = component.$$.callbacks[type];
if (callbacks2) {
const event = custom_event(type, detail, { cancelable });
callbacks2.slice().forEach((fn2) => {
fn2.call(component, event);
});
return !event.defaultPrevented;
}
return true;
};
}
function setContext(key, context) {
get_current_component().$$.context.set(key, context);
return context;
}
function getContext(key) {
return get_current_component().$$.context.get(key);
}
function bubble(component, event) {
const callbacks2 = component.$$.callbacks[event.type];
if (callbacks2) {
callbacks2.slice().forEach((fn2) => fn2.call(this, event));
}
}
const dirty_components = [];
const binding_callbacks = [];
const render_callbacks = [];
const flush_callbacks = [];
const resolved_promise = Promise.resolve();
let update_scheduled = false;
function schedule_update() {
if (!update_scheduled) {
update_scheduled = true;
resolved_promise.then(flush);
}
}
function tick() {
schedule_update();
return resolved_promise;
}
function add_render_callback(fn2) {
render_callbacks.push(fn2);
}
function add_flush_callback(fn2) {
flush_callbacks.push(fn2);
}
const seen_callbacks = /* @__PURE__ */ new Set();
let flushidx = 0;
function flush() {
if (flushidx !== 0) {
return;
}
const saved_component = current_component;
do {
try {
while (flushidx < dirty_components.length) {
const component = dirty_components[flushidx];
flushidx++;
set_current_component(component);
update(component.$$);
}
} catch (e2) {
dirty_components.length = 0;
flushidx = 0;
throw e2;
}
set_current_component(null);
dirty_components.length = 0;
flushidx = 0;
while (binding_callbacks.length)
binding_callbacks.pop()();
for (let i2 = 0; i2 < render_callbacks.length; i2 += 1) {
const callback = render_callbacks[i2];
if (!seen_callbacks.has(callback)) {
seen_callbacks.add(callback);
callback();
}
}
render_callbacks.length = 0;
} while (dirty_components.length);
while (flush_callbacks.length) {
flush_callbacks.pop()();
}
update_scheduled = false;
seen_callbacks.clear();
set_current_component(saved_component);
}
function update($$) {
if ($$.fragment !== null) {
$$.update();
run_all($$.before_update);
const dirty = $$.dirty;
$$.dirty = [-1];
$$.fragment && $$.fragment.p($$.ctx, dirty);
$$.after_update.forEach(add_render_callback);
}
}
const outroing = /* @__PURE__ */ new Set();
let outros;
function group_outros() {
outros = {
r: 0,
c: [],
p: outros
// parent group
};
}
function check_outros() {
if (!outros.r) {
run_all(outros.c);
}
outros = outros.p;
}
function transition_in(block, local) {
if (block && block.i) {
outroing.delete(block);
block.i(local);
}
}
function transition_out(block, local, detach2, callback) {
if (block && block.o) {
if (outroing.has(block))
return;
outroing.add(block);
outros.c.push(() => {
outroing.delete(block);
if (callback) {
if (detach2)
block.d(1);
callback();
}
});
block.o(local);
} else if (callback) {
callback();
}
}
function destroy_block(block, lookup) {
block.d(1);
lookup.delete(block.key);
}
function update_keyed_each(old_blocks, dirty, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, next, get_context) {
let o = old_blocks.length;
let n2 = list.length;
let i2 = o;
const old_indexes = {};
while (i2--)
old_indexes[old_blocks[i2].key] = i2;
const new_blocks = [];
const new_lookup = /* @__PURE__ */ new Map();
const deltas = /* @__PURE__ */ new Map();
i2 = n2;
while (i2--) {
const child_ctx = get_context(ctx, list, i2);
const key = get_key(child_ctx);
let block = lookup.get(key);
if (!block) {
block = create_each_block(key, child_ctx);
block.c();
} else if (dynamic) {
block.p(child_ctx, dirty);
}
new_lookup.set(key, new_blocks[i2] = block);
if (key in old_indexes)
deltas.set(key, Math.abs(i2 - old_indexes[key]));
}
const will_move = /* @__PURE__ */ new Set();
const did_move = /* @__PURE__ */ new Set();
function insert2(block) {
transition_in(block, 1);
block.m(node, next);
lookup.set(block.key, block);
next = block.first;
n2--;
}
while (o && n2) {
const new_block = new_blocks[n2 - 1];
const old_block = old_blocks[o - 1];
const new_key = new_block.key;
const old_key = old_block.key;
if (new_block === old_block) {
next = new_block.first;
o--;
n2--;
} else if (!new_lookup.has(old_key)) {
destroy(old_block, lookup);
o--;
} else if (!lookup.has(new_key) || will_move.has(new_key)) {
insert2(new_block);
} else if (did_move.has(old_key)) {
o--;
} else if (deltas.get(new_key) > deltas.get(old_key)) {
did_move.add(new_key);
insert2(new_block);
} else {
will_move.add(old_key);
o--;
}
}
while (o--) {
const old_block = old_blocks[o];
if (!new_lookup.has(old_block.key))
destroy(old_block, lookup);
}
while (n2)
insert2(new_blocks[n2 - 1]);
return new_blocks;
}
function validate_each_keys(ctx, list, get_context, get_key) {
const keys = /* @__PURE__ */ new Set();
for (let i2 = 0; i2 < list.length; i2++) {
const key = get_key(get_context(ctx, list, i2));
if (keys.has(key)) {
throw new Error("Cannot have duplicate keys in a keyed each");
}
keys.add(key);
}
}
function get_spread_update(levels, updates) {
const update2 = {};
const to_null_out = {};
const accounted_for = { $$scope: 1 };
let i2 = levels.length;
while (i2--) {
const o = levels[i2];
const n2 = updates[i2];
if (n2) {
for (const key in o) {
if (!(key in n2))
to_null_out[key] = 1;
}
for (const key in n2) {
if (!accounted_for[key]) {
update2[key] = n2[key];
accounted_for[key] = 1;
}
}
levels[i2] = n2;
} else {
for (const key in o) {
accounted_for[key] = 1;
}
}
}
for (const key in to_null_out) {
if (!(key in update2))
update2[key] = void 0;
}
return update2;
}
function get_spread_object(spread_props) {
return typeof spread_props === "object" && spread_props !== null ? spread_props : {};
}
function bind(component, name, callback) {
const index2 = component.$$.props[name];
if (index2 !== void 0) {
component.$$.bound[index2] = callback;
callback(component.$$.ctx[index2]);
}
}
function create_component(block) {
block && block.c();
}
function claim_component(block, parent_nodes) {
block && block.l(parent_nodes);
}
function mount_component(component, target, anchor, customElement) {
const { fragment, after_update } = component.$$;
fragment && fragment.m(target, anchor);
if (!customElement) {
add_render_callback(() => {
const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
if (component.$$.on_destroy) {
component.$$.on_destroy.push(...new_on_destroy);
} else {
run_all(new_on_destroy);
}
component.$$.on_mount = [];
});
}
after_update.forEach(add_render_callback);
}
function destroy_component(component, detaching) {
const $$ = component.$$;
if ($$.fragment !== null) {
run_all($$.on_destroy);
$$.fragment && $$.fragment.d(detaching);
$$.on_destroy = $$.fragment = null;
$$.ctx = [];
}
}
function make_dirty(component, i2) {
if (component.$$.dirty[0] === -1) {
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
}
component.$$.dirty[i2 / 31 | 0] |= 1 << i2 % 31;
}
function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) {
const parent_component = current_component;
set_current_component(component);
const $$ = component.$$ = {
fragment: null,
ctx: [],
// state
props,
update: noop$2,
not_equal,
bound: blank_object(),
// lifecycle
on_mount: [],
on_destroy: [],
on_disconnect: [],
before_update: [],
after_update: [],
context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
// everything else
callbacks: blank_object(),
dirty,
skip_bound: false,
root: options.target || parent_component.$$.root
};
append_styles && append_styles($$.root);
let ready = false;
$$.ctx = instance ? instance(component, options.props || {}, (i2, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;
if ($$.ctx && not_equal($$.ctx[i2], $$.ctx[i2] = value)) {
if (!$$.skip_bound && $$.bound[i2])
$$.bound[i2](value);
if (ready)
make_dirty(component, i2);
}
return ret;
}) : [];
$$.update();
ready = true;
run_all($$.before_update);
$$.fragment = create_fragment ? create_fragment($$.ctx) : false;
if (options.target) {
if (options.hydrate) {
start_hydrating();
const nodes = children(options.target);
$$.fragment && $$.fragment.l(nodes);
nodes.forEach(detach);
} else {
$$.fragment && $$.fragment.c();
}
if (options.intro)
transition_in(component.$$.fragment);
mount_component(component, options.target, options.anchor, options.customElement);
end_hydrating();
flush();
}
set_current_component(parent_component);
}
class SvelteComponent {
$destroy() {
destroy_component(this, 1);
this.$destroy = noop$2;
}
$on(type, callback) {
if (!is_function(callback)) {
return noop$2;
}
const callbacks2 = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
callbacks2.push(callback);
return () => {
const index2 = callbacks2.indexOf(callback);
if (index2 !== -1)
callbacks2.splice(index2, 1);
};
}
$set($$props) {
if (this.$$set && !is_empty($$props)) {
this.$$.skip_bound = true;
this.$$set($$props);
this.$$.skip_bound = false;
}
}
}
function dispatch_dev(type, detail) {
document.dispatchEvent(custom_event(type, Object.assign({ version: "3.55.1" }, detail), { bubbles: true }));
}
function append_hydration_dev(target, node) {
dispatch_dev("SvelteDOMInsert", { target, node });
append_hydration(target, node);
}
function insert_hydration_dev(target, node, anchor) {
dispatch_dev("SvelteDOMInsert", { target, node, anchor });
insert_hydration(target, node, anchor);
}
function detach_dev(node) {
dispatch_dev("SvelteDOMRemove", { node });
detach(node);
}
function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) {
const modifiers = options === true ? ["capture"] : options ? Array.from(Object.keys(options)) : [];
if (has_prevent_default)
modifiers.push("preventDefault");
if (has_stop_propagation)
modifiers.push("stopPropagation");
dispatch_dev("SvelteDOMAddEventListener", { node, event, handler, modifiers });
const dispose = listen(node, event, handler, options);
return () => {
dispatch_dev("SvelteDOMRemoveEventListener", { node, event, handler, modifiers });
dispose();
};
}
function attr_dev(node, attribute, value) {
attr(node, attribute, value);
if (value == null)
dispatch_dev("SvelteDOMRemoveAttribute", { node, attribute });
else
dispatch_dev("SvelteDOMSetAttribute", { node, attribute, value });
}
function set_data_dev(text2, data) {
data = "" + data;
if (text2.wholeText === data)
return;
dispatch_dev("SvelteDOMSetData", { node: text2, data });
text2.data = data;
}
function validate_each_argument(arg) {
if (typeof arg !== "string" && !(arg && typeof arg === "object" && "length" in arg)) {
let msg = "{#each} only iterates over array-like objects.";
if (typeof Symbol === "function" && arg && Symbol.iterator in arg) {
msg += " You can use a spread to convert this iterable into an array.";
}
throw new Error(msg);
}
}
function validate_slots(name, slot, keys) {
for (const slot_key of Object.keys(slot)) {
if (!~keys.indexOf(slot_key)) {
console.warn(`<${name}> received an unexpected slot "${slot_key}".`);
}
}
}
class SvelteComponentDev extends SvelteComponent {
constructor(options) {
if (!options || !options.target && !options.$$inline) {
throw new Error("'target' is a required option");
}
super();
}
$destroy() {
super.$destroy();
this.$destroy = () => {
console.warn("Component was already destroyed");
};
}
$capture_state() {
}
$inject_state() {
}
}
const base = ((_a2 = globalThis.__sveltekit_1xeb56h) == null ? void 0 : _a2.base) ?? "";
((_b = globalThis.__sveltekit_1xeb56h) == null ? void 0 : _b.assets) ?? base;
var _a$1;
const isClient = typeof window !== "undefined";
const isDef = (val) => typeof val !== "undefined";
const isFunction = (val) => typeof val === "function";
const isString = (val) => typeof val === "string";
const noop$1 = () => {
};
isClient && ((_a$1 = window == null ? void 0 : window.navigator) == null ? void 0 : _a$1.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
function resolveUnref(r2) {
return typeof r2 === "function" ? r2() : unref(r2);
}
function createFilterWrapper(filter, fn2) {
function wrapper(...args) {
return new Promise((resolve2, reject) => {
Promise.resolve(filter(() => fn2.apply(this, args), { fn: fn2, thisArg: this, args })).then(resolve2).catch(reject);
});
}
return wrapper;
}
const bypassFilter = (invoke) => {
return invoke();
};
function debounceFilter(ms2, options = {}) {
let timer;
let maxTimer;
let lastRejector = noop$1;
const _clearTimeout = (timer2) => {
clearTimeout(timer2);
lastRejector();
lastRejector = noop$1;
};
const filter = (invoke) => {
const duration = resolveUnref(ms2);
const maxDuration = resolveUnref(options.maxWait);
if (timer)
_clearTimeout(timer);
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
if (maxTimer) {
_clearTimeout(maxTimer);
maxTimer = null;
}
return Promise.resolve(invoke());
}
return new Promise((resolve2, reject) => {
lastRejector = options.rejectOnCancel ? reject : resolve2;
if (maxDuration && !maxTimer) {
maxTimer = setTimeout(() => {
if (timer)
_clearTimeout(timer);
maxTimer = null;
resolve2(invoke());
}, maxDuration);
}
timer = setTimeout(() => {
if (maxTimer)
_clearTimeout(maxTimer);
maxTimer = null;
resolve2(invoke());
}, duration);
});
};
return filter;
}
function pausableFilter(extendFilter = bypassFilter) {
const isActive = ref(true);
function pause() {
isActive.value = false;
}
function resume() {
isActive.value = true;
}
const eventFilter = (...args) => {
if (isActive.value)
extendFilter(...args);
};
return { isActive: readonly(isActive), pause, resume, eventFilter };
}
function identity(arg) {
return arg;
}
function computedWithControl(source, fn2) {
let v2 = void 0;
let track2;
let trigger2;
const dirty = ref(true);
const update2 = () => {
dirty.value = true;
trigger2();
};
watch(source, update2, { flush: "sync" });
const get2 = isFunction(fn2) ? fn2 : fn2.get;
const set2 = isFunction(fn2) ? void 0 : fn2.set;
const result = customRef((_track, _trigger) => {
track2 = _track;
trigger2 = _trigger;
return {
get() {
if (dirty.value) {
v2 = get2();
dirty.value = false;
}
track2();
return v2;
},
set(v22) {
set2 == null ? void 0 : set2(v22);
}
};
});
if (Object.isExtensible(result))
result.trigger = update2;
return result;
}
function tryOnScopeDispose(fn2) {
if (getCurrentScope()) {
onScopeDispose(fn2);
return true;
}
return false;
}
function useDebounceFn(fn2, ms2 = 200, options = {}) {
return createFilterWrapper(debounceFilter(ms2, options), fn2);
}
function refDebounced(value, ms2 = 200, options = {}) {
const debounced = ref(value.value);
const updater = useDebounceFn(() => {
debounced.value = value.value;
}, ms2, options);
watch(value, () => updater());
return debounced;
}
function resolveRef(r2) {
return typeof r2 === "function" ? computed(r2) : ref(r2);
}
function tryOnMounted(fn2, sync = true) {
if (getCurrentInstance())
onMounted(fn2);
else if (sync)
fn2();
else
nextTick(fn2);
}
function useTimeoutFn(cb, interval, options = {}) {
const {
immediate = true
} = options;
const isPending = ref(false);
let timer = null;
function clear2() {
if (timer) {
clearTimeout(timer);
timer = null;
}
}
function stop() {
isPending.value = false;
clear2();
}
function start(...args) {
clear2();
isPending.value = true;
timer = setTimeout(() => {
isPending.value = false;
timer = null;
cb(...args);
}, resolveUnref(interval));
}
if (immediate) {
isPending.value = true;
if (isClient)
start();
}
tryOnScopeDispose(stop);
return {
isPending: readonly(isPending),
start,
stop
};
}
function useToggle(initialValue = false, options = {}) {
const {
truthyValue = true,
falsyValue = false
} = options;
const valueIsRef = isRef(initialValue);
const _value = ref(initialValue);
function toggle(value) {
if (arguments.length) {
_value.value = value;
return _value.value;
} else {
const truthy = resolveUnref(truthyValue);
_value.value = _value.value === truthy ? resolveUnref(falsyValue) : truthy;
return _value.value;
}
}
if (valueIsRef)
return toggle;
else
return [_value, toggle];
}
var __getOwnPropSymbols$6$1 = Object.getOwnPropertySymbols;
var __hasOwnProp$6$1 = Object.prototype.hasOwnProperty;
var __propIsEnum$6$1 = Object.prototype.propertyIsEnumerable;
var __objRest$5 = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp$6$1.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols$6$1)
for (var prop of __getOwnPropSymbols$6$1(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum$6$1.call(source, prop))
target[prop] = source[prop];
}
return target;
};
function watchWithFilter(source, cb, options = {}) {
const _a3 = options, {
eventFilter = bypassFilter
} = _a3, watchOptions = __objRest$5(_a3, [
"eventFilter"
]);
return watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
}
var __defProp$2$1 = Object.defineProperty;
var __defProps$2$1 = Object.defineProperties;
var __getOwnPropDescs$2$1 = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols$2$1 = Object.getOwnPropertySymbols;
var __hasOwnProp$2$1 = Object.prototype.hasOwnProperty;
var __propIsEnum$2$1 = Object.prototype.propertyIsEnumerable;
var __defNormalProp$2$1 = (obj, key, value) => key in obj ? __defProp$2$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$2$1 = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp$2$1.call(b3, prop))
__defNormalProp$2$1(a2, prop, b3[prop]);
if (__getOwnPropSymbols$2$1)
for (var prop of __getOwnPropSymbols$2$1(b3)) {
if (__propIsEnum$2$1.call(b3, prop))
__defNormalProp$2$1(a2, prop, b3[prop]);
}
return a2;
};
var __spreadProps$2$1 = (a2, b3) => __defProps$2$1(a2, __getOwnPropDescs$2$1(b3));
var __objRest$1$1 = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp$2$1.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols$2$1)
for (var prop of __getOwnPropSymbols$2$1(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum$2$1.call(source, prop))
target[prop] = source[prop];
}
return target;
};
function watchPausable(source, cb, options = {}) {
const _a3 = options, {
eventFilter: filter
} = _a3, watchOptions = __objRest$1$1(_a3, [
"eventFilter"
]);
const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
const stop = watchWithFilter(source, cb, __spreadProps$2$1(__spreadValues$2$1({}, watchOptions), {
eventFilter
}));
return { stop, pause, resume, isActive };
}
function unrefElement(elRef) {
var _a3;
const plain = resolveUnref(elRef);
return (_a3 = plain == null ? void 0 : plain.$el) != null ? _a3 : plain;
}
const defaultWindow = isClient ? window : void 0;
const defaultDocument = isClient ? window.document : void 0;
const defaultNavigator = isClient ? window.navigator : void 0;
function useEventListener(...args) {
let target;
let events;
let listeners;
let options;
if (isString(args[0]) || Array.isArray(args[0])) {
[events, listeners, options] = args;
target = defaultWindow;
} else {
[target, events, listeners, options] = args;
}
if (!target)
return noop$1;
if (!Array.isArray(events))
events = [events];
if (!Array.isArray(listeners))
listeners = [listeners];
const cleanups = [];
const cleanup = () => {
cleanups.forEach((fn2) => fn2());
cleanups.length = 0;
};
const register = (el2, event, listener) => {
el2.addEventListener(event, listener, options);
return () => el2.removeEventListener(event, listener, options);
};
const stopWatch = watch(() => unrefElement(target), (el2) => {
cleanup();
if (!el2)
return;
cleanups.push(...events.flatMap((event) => {
return listeners.map((listener) => register(el2, event, listener));
}));
}, { immediate: true, flush: "post" });
const stop = () => {
stopWatch();
cleanup();
};
tryOnScopeDispose(stop);
return stop;
}
function onClickOutside(target, handler, options = {}) {
const { window: window2 = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
if (!window2)
return;
let shouldListen = true;
let fallback;
const shouldIgnore = (event) => {
return ignore.some((target2) => {
if (typeof target2 === "string") {
return Array.from(window2.document.querySelectorAll(target2)).some((el2) => el2 === event.target || event.composedPath().includes(el2));
} else {
const el2 = unrefElement(target2);
return el2 && (event.target === el2 || event.composedPath().includes(el2));
}
});
};
const listener = (event) => {
window2.clearTimeout(fallback);
const el2 = unrefElement(target);
if (!el2 || el2 === event.target || event.composedPath().includes(el2))
return;
if (event.detail === 0)
shouldListen = !shouldIgnore(event);
if (!shouldListen) {
shouldListen = true;
return;
}
handler(event);
};
const cleanup = [
useEventListener(window2, "click", listener, { passive: true, capture }),
useEventListener(window2, "pointerdown", (e2) => {
const el2 = unrefElement(target);
if (el2)
shouldListen = !e2.composedPath().includes(el2) && !shouldIgnore(e2);
}, { passive: true }),
useEventListener(window2, "pointerup", (e2) => {
if (e2.button === 0) {
const path = e2.composedPath();
e2.composedPath = () => path;
fallback = window2.setTimeout(() => listener(e2), 50);
}
}, { passive: true }),
detectIframe && useEventListener(window2, "blur", (event) => {
var _a3;
const el2 = unrefElement(target);
if (((_a3 = window2.document.activeElement) == null ? void 0 : _a3.tagName) === "IFRAME" && !(el2 == null ? void 0 : el2.contains(window2.document.activeElement)))
handler(event);
})
].filter(Boolean);
const stop = () => cleanup.forEach((fn2) => fn2());
return stop;
}
function useActiveElement(options = {}) {
var _a3;
const { window: window2 = defaultWindow } = options;
const document2 = (_a3 = options.document) != null ? _a3 : window2 == null ? void 0 : window2.document;
const activeElement = computedWithControl(() => null, () => document2 == null ? void 0 : document2.activeElement);
if (window2) {
useEventListener(window2, "blur", (event) => {
if (event.relatedTarget !== null)
return;
activeElement.trigger();
}, true);
useEventListener(window2, "focus", activeElement.trigger, true);
}
return activeElement;
}
function useSupported(callback, sync = false) {
const isSupported2 = ref();
const update2 = () => isSupported2.value = Boolean(callback());
update2();
tryOnMounted(update2, sync);
return isSupported2;
}
function useMediaQuery(query, options = {}) {
const { window: window2 = defaultWindow } = options;
const isSupported2 = useSupported(() => window2 && "matchMedia" in window2 && typeof window2.matchMedia === "function");
let mediaQuery;
const matches2 = ref(false);
const cleanup = () => {
if (!mediaQuery)
return;
if ("removeEventListener" in mediaQuery)
mediaQuery.removeEventListener("change", update2);
else
mediaQuery.removeListener(update2);
};
const update2 = () => {
if (!isSupported2.value)
return;
cleanup();
mediaQuery = window2.matchMedia(resolveRef(query).value);
matches2.value = mediaQuery.matches;
if ("addEventListener" in mediaQuery)
mediaQuery.addEventListener("change", update2);
else
mediaQuery.addListener(update2);
};
watchEffect(update2);
tryOnScopeDispose(() => cleanup());
return matches2;
}
function useClipboard(options = {}) {
const {
navigator: navigator2 = defaultNavigator,
read: read2 = false,
source,
copiedDuring = 1500,
legacy = false
} = options;
const events = ["copy", "cut"];
const isClipboardApiSupported = useSupported(() => navigator2 && "clipboard" in navigator2);
const isSupported2 = computed(() => isClipboardApiSupported.value || legacy);
const text2 = ref("");
const copied = ref(false);
const timeout = useTimeoutFn(() => copied.value = false, copiedDuring);
function updateText() {
if (isClipboardApiSupported.value) {
navigator2.clipboard.readText().then((value) => {
text2.value = value;
});
} else {
text2.value = legacyRead();
}
}
if (isSupported2.value && read2) {
for (const event of events)
useEventListener(event, updateText);
}
async function copy(value = resolveUnref(source)) {
if (isSupported2.value && value != null) {
if (isClipboardApiSupported.value)
await navigator2.clipboard.writeText(value);
else
legacyCopy(value);
text2.value = value;
copied.value = true;
timeout.start();
}
}
function legacyCopy(value) {
const ta2 = document.createElement("textarea");
ta2.value = value != null ? value : "";
ta2.style.position = "absolute";
ta2.style.opacity = "0";
document.body.appendChild(ta2);
ta2.select();
document.execCommand("copy");
ta2.remove();
}
function legacyRead() {
var _a3, _b2, _c2;
return (_c2 = (_b2 = (_a3 = document == null ? void 0 : document.getSelection) == null ? void 0 : _a3.call(document)) == null ? void 0 : _b2.toString()) != null ? _c2 : "";
}
return {
isSupported: isSupported2,
text: text2,
copied,
copy
};
}
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
const globalKey = "__vueuse_ssr_handlers__";
_global[globalKey] = _global[globalKey] || {};
const handlers = _global[globalKey];
function getSSRHandler(key, fallback) {
return handlers[key] || fallback;
}
function guessSerializerType(rawInit) {
return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
}
var __defProp$j = Object.defineProperty;
var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
var __hasOwnProp$l = Object.prototype.hasOwnProperty;
var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$j = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp$l.call(b3, prop))
__defNormalProp$j(a2, prop, b3[prop]);
if (__getOwnPropSymbols$l)
for (var prop of __getOwnPropSymbols$l(b3)) {
if (__propIsEnum$l.call(b3, prop))
__defNormalProp$j(a2, prop, b3[prop]);
}
return a2;
};
const StorageSerializers = {
boolean: {
read: (v2) => v2 === "true",
write: (v2) => String(v2)
},
object: {
read: (v2) => JSON.parse(v2),
write: (v2) => JSON.stringify(v2)
},
number: {
read: (v2) => Number.parseFloat(v2),
write: (v2) => String(v2)
},
any: {
read: (v2) => v2,
write: (v2) => String(v2)
},
string: {
read: (v2) => v2,
write: (v2) => String(v2)
},
map: {
read: (v2) => new Map(JSON.parse(v2)),
write: (v2) => JSON.stringify(Array.from(v2.entries()))
},
set: {
read: (v2) => new Set(JSON.parse(v2)),
write: (v2) => JSON.stringify(Array.from(v2))
},
date: {
read: (v2) => new Date(v2),
write: (v2) => v2.toISOString()
}
};
function useStorage(key, defaults2, storage2, options = {}) {
var _a3;
const {
flush: flush2 = "pre",
deep = true,
listenToStorageChanges = true,
writeDefaults = true,
mergeDefaults = false,
shallow,
window: window2 = defaultWindow,
eventFilter,
onError = (e2) => {
console.error(e2);
}
} = options;
const data = (shallow ? shallowRef : ref)(defaults2);
if (!storage2) {
try {
storage2 = getSSRHandler("getDefaultStorage", () => {
var _a22;
return (_a22 = defaultWindow) == null ? void 0 : _a22.localStorage;
})();
} catch (e2) {
onError(e2);
}
}
if (!storage2)
return data;
const rawInit = resolveUnref(defaults2);
const type = guessSerializerType(rawInit);
const serializer = (_a3 = options.serializer) != null ? _a3 : StorageSerializers[type];
const { pause: pauseWatch, resume: resumeWatch } = watchPausable(data, () => write(data.value), { flush: flush2, deep, eventFilter });
if (window2 && listenToStorageChanges)
useEventListener(window2, "storage", update2);
update2();
return data;
function write(v2) {
try {
if (v2 == null) {
storage2.removeItem(key);
} else {
const serialized = serializer.write(v2);
const oldValue = storage2.getItem(key);
if (oldValue !== serialized) {
storage2.setItem(key, serialized);
if (window2) {
window2 == null ? void 0 : window2.dispatchEvent(new StorageEvent("storage", {
key,
oldValue,
newValue: serialized,
storageArea: storage2
}));
}
}
}
} catch (e2) {
onError(e2);
}
}
function read2(event) {
const rawValue = event ? event.newValue : storage2.getItem(key);
if (rawValue == null) {
if (writeDefaults && rawInit !== null)
storage2.setItem(key, serializer.write(rawInit));
return rawInit;
} else if (!event && mergeDefaults) {
const value = serializer.read(rawValue);
if (isFunction(mergeDefaults))
return mergeDefaults(value, rawInit);
else if (type === "object" && !Array.isArray(value))
return __spreadValues$j(__spreadValues$j({}, rawInit), value);
return value;
} else if (typeof rawValue !== "string") {
return rawValue;
} else {
return serializer.read(rawValue);
}
}
function update2(event) {
if (event && event.storageArea !== storage2)
return;
if (event && event.key == null) {
data.value = rawInit;
return;
}
if (event && event.key !== key)
return;
pauseWatch();
try {
data.value = read2(event);
} catch (e2) {
onError(e2);
} finally {
if (event)
nextTick(resumeWatch);
else
resumeWatch();
}
}
}
function usePreferredDark(options) {
return useMediaQuery("(prefers-color-scheme: dark)", options);
}
var __defProp$i = Object.defineProperty;
var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
var __hasOwnProp$k = Object.prototype.hasOwnProperty;
var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$i = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp$k.call(b3, prop))
__defNormalProp$i(a2, prop, b3[prop]);
if (__getOwnPropSymbols$k)
for (var prop of __getOwnPropSymbols$k(b3)) {
if (__propIsEnum$k.call(b3, prop))
__defNormalProp$i(a2, prop, b3[prop]);
}
return a2;
};
function useColorMode(options = {}) {
const {
selector = "html",
attribute = "class",
initialValue = "auto",
window: window2 = defaultWindow,
storage: storage2,
storageKey = "vueuse-color-scheme",
listenToStorageChanges = true,
storageRef,
emitAuto
} = options;
const modes = __spreadValues$i({
auto: "",
light: "light",
dark: "dark"
}, options.modes || {});
const preferredDark = usePreferredDark({ window: window2 });
const preferredMode = computed(() => preferredDark.value ? "dark" : "light");
const store = storageRef || (storageKey == null ? ref(initialValue) : useStorage(storageKey, initialValue, storage2, { window: window2, listenToStorageChanges }));
const state = computed({
get() {
return store.value === "auto" && !emitAuto ? preferredMode.value : store.value;
},
set(v2) {
store.value = v2;
}
});
const updateHTMLAttrs = getSSRHandler("updateHTMLAttrs", (selector2, attribute2, value) => {
const el2 = window2 == null ? void 0 : window2.document.querySelector(selector2);
if (!el2)
return;
if (attribute2 === "class") {
const current = value.split(/\s/g);
Object.values(modes).flatMap((i2) => (i2 || "").split(/\s/g)).filter(Boolean).forEach((v2) => {
if (current.includes(v2))
el2.classList.add(v2);
else
el2.classList.remove(v2);
});
} else {
el2.setAttribute(attribute2, value);
}
});
function defaultOnChanged(mode) {
var _a3;
const resolvedMode = mode === "auto" ? preferredMode.value : mode;
updateHTMLAttrs(selector, attribute, (_a3 = modes[resolvedMode]) != null ? _a3 : resolvedMode);
}
function onChanged(mode) {
if (options.onChanged)
options.onChanged(mode, defaultOnChanged);
else
defaultOnChanged(mode);
}
watch(state, onChanged, { flush: "post", immediate: true });
if (emitAuto)
watch(preferredMode, () => onChanged(state.value), { flush: "post" });
tryOnMounted(() => onChanged(state.value));
return state;
}
var __defProp$h = Object.defineProperty;
var __defProps$7 = Object.defineProperties;
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
var __hasOwnProp$j = Object.prototype.hasOwnProperty;
var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$h = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp$j.call(b3, prop))
__defNormalProp$h(a2, prop, b3[prop]);
if (__getOwnPropSymbols$j)
for (var prop of __getOwnPropSymbols$j(b3)) {
if (__propIsEnum$j.call(b3, prop))
__defNormalProp$h(a2, prop, b3[prop]);
}
return a2;
};
var __spreadProps$7 = (a2, b3) => __defProps$7(a2, __getOwnPropDescs$7(b3));
function useDark(options = {}) {
const {
valueDark = "dark",
valueLight = "",
window: window2 = defaultWindow
} = options;
const mode = useColorMode(__spreadProps$7(__spreadValues$h({}, options), {
onChanged: (mode2, defaultHandler) => {
var _a3;
if (options.onChanged)
(_a3 = options.onChanged) == null ? void 0 : _a3.call(options, mode2 === "dark");
else
defaultHandler(mode2);
},
modes: {
dark: valueDark,
light: valueLight
}
}));
const preferredDark = usePreferredDark({ window: window2 });
const isDark2 = computed({
get() {
return mode.value === "dark";
},
set(v2) {
if (v2 === preferredDark.value)
mode.value = "auto";
else
mode.value = v2 ? "dark" : "light";
}
});
return isDark2;
}
var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
var __hasOwnProp$f = Object.prototype.hasOwnProperty;
var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
var __objRest$2 = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp$f.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols$f)
for (var prop of __getOwnPropSymbols$f(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum$f.call(source, prop))
target[prop] = source[prop];
}
return target;
};
function useResizeObserver(target, callback, options = {}) {
const _a3 = options, { window: window2 = defaultWindow } = _a3, observerOptions = __objRest$2(_a3, ["window"]);
let observer;
const isSupported2 = useSupported(() => window2 && "ResizeObserver" in window2);
const cleanup = () => {
if (observer) {
observer.disconnect();
observer = void 0;
}
};
const stopWatch = watch(() => unrefElement(target), (el2) => {
cleanup();
if (isSupported2.value && window2 && el2) {
observer = new ResizeObserver(callback);
observer.observe(el2, observerOptions);
}
}, { immediate: true, flush: "post" });
const stop = () => {
cleanup();
stopWatch();
};
tryOnScopeDispose(stop);
return {
isSupported: isSupported2,
stop
};
}
function useFocus(target, options = {}) {
const { initialValue = false } = options;
const activeElement = useActiveElement(options);
const targetElement = computed(() => unrefElement(target));
const focused = computed({
get() {
return isDef(activeElement.value) && isDef(targetElement.value) && activeElement.value === targetElement.value;
},
set(value) {
var _a3, _b2;
if (!value && focused.value)
(_a3 = targetElement.value) == null ? void 0 : _a3.blur();
if (value && !focused.value)
(_b2 = targetElement.value) == null ? void 0 : _b2.focus();
}
});
watch(targetElement, () => {
focused.value = initialValue;
}, { immediate: true, flush: "post" });
return { focused };
}
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
var __objRest$1 = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols$7)
for (var prop of __getOwnPropSymbols$7(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
target[prop] = source[prop];
}
return target;
};
function useMutationObserver(target, callback, options = {}) {
const _a3 = options, { window: window2 = defaultWindow } = _a3, mutationOptions = __objRest$1(_a3, ["window"]);
let observer;
const isSupported2 = useSupported(() => window2 && "MutationObserver" in window2);
const cleanup = () => {
if (observer) {
observer.disconnect();
observer = void 0;
}
};
const stopWatch = watch(() => unrefElement(target), (el2) => {
cleanup();
if (isSupported2.value && window2 && el2) {
observer = new MutationObserver(callback);
observer.observe(el2, mutationOptions);
}
}, { immediate: true });
const stop = () => {
cleanup();
stopWatch();
};
tryOnScopeDispose(stop);
return {
isSupported: isSupported2,
stop
};
}
var SwipeDirection;
(function(SwipeDirection2) {
SwipeDirection2["UP"] = "UP";
SwipeDirection2["RIGHT"] = "RIGHT";
SwipeDirection2["DOWN"] = "DOWN";
SwipeDirection2["LEFT"] = "LEFT";
SwipeDirection2["NONE"] = "NONE";
})(SwipeDirection || (SwipeDirection = {}));
function useTitle(newTitle = null, options = {}) {
var _a3, _b2;
const {
document: document2 = defaultDocument
} = options;
const title = resolveRef((_a3 = newTitle != null ? newTitle : document2 == null ? void 0 : document2.title) != null ? _a3 : null);
const isReadonly2 = newTitle && isFunction(newTitle);
function format(t2) {
if (!("titleTemplate" in options))
return t2;
const template = options.titleTemplate || "%s";
return isFunction(template) ? template(t2) : unref(template).replace(/%s/g, t2);
}
watch(title, (t2, o) => {
if (t2 !== o && document2)
document2.title = format(isString(t2) ? t2 : "");
}, { immediate: true });
if (options.observe && !options.titleTemplate && document2 && !isReadonly2) {
useMutationObserver((_b2 = document2.head) == null ? void 0 : _b2.querySelector("title"), () => {
if (document2 && document2.title !== title.value)
title.value = format(document2.title);
}, { childList: true });
}
return title;
}
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp.call(b3, prop))
__defNormalProp(a2, prop, b3[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b3)) {
if (__propIsEnum.call(b3, prop))
__defNormalProp(a2, prop, b3[prop]);
}
return a2;
};
const _TransitionPresets = {
easeInSine: [0.12, 0, 0.39, 0],
easeOutSine: [0.61, 1, 0.88, 1],
easeInOutSine: [0.37, 0, 0.63, 1],
easeInQuad: [0.11, 0, 0.5, 0],
easeOutQuad: [0.5, 1, 0.89, 1],
easeInOutQuad: [0.45, 0, 0.55, 1],
easeInCubic: [0.32, 0, 0.67, 0],
easeOutCubic: [0.33, 1, 0.68, 1],
easeInOutCubic: [0.65, 0, 0.35, 1],
easeInQuart: [0.5, 0, 0.75, 0],
easeOutQuart: [0.25, 1, 0.5, 1],
easeInOutQuart: [0.76, 0, 0.24, 1],
easeInQuint: [0.64, 0, 0.78, 0],
easeOutQuint: [0.22, 1, 0.36, 1],
easeInOutQuint: [0.83, 0, 0.17, 1],
easeInExpo: [0.7, 0, 0.84, 0],
easeOutExpo: [0.16, 1, 0.3, 1],
easeInOutExpo: [0.87, 0, 0.13, 1],
easeInCirc: [0.55, 0, 1, 0.45],
easeOutCirc: [0, 0.55, 0.45, 1],
easeInOutCirc: [0.85, 0, 0.15, 1],
easeInBack: [0.36, 0, 0.66, -0.56],
easeOutBack: [0.34, 1.56, 0.64, 1],
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
};
__spreadValues({
linear: identity
}, _TransitionPresets);
const Logo_square = "/assets/histoire-svelte-e093dabf.svg";
const Logo_dark = "/assets/histoire-svelte-text-008b417c.svg";
const config$1 = { "plugins": [{ "name": "builtin:tailwind-tokens" }, { "name": "builtin:vanilla-support", "supportPlugin": { "id": "vanilla", "moduleName": "/home/yanick/work/javascript/aotds/node_modules/.pnpm/histoire@0.15.9_vite@4.1.4/node_modules/histoire/dist/node/builtin-plugins/vanilla-support", "setupFn": "setupVanilla" } }, { "name": "@histoire/plugin-svelte", "supportPlugin": { "id": "svelte3", "moduleName": "@histoire/plugin-svelte", "setupFn": "setupSvelte3" }, "commands": [{ "id": "histoire:plugin-svelte:generate-story", "label": "Generate Svelte 3 story from component", "icon": "https://svelte.dev/favicon.png", "searchText": "generate create", "clientSetupFile": "@histoire/plugin-svelte/dist/commands/generate-story.client.js" }] }, { "name": "@histoire/plugin-screenshot" }], "outDir": "/home/yanick/work/javascript/aotds/aotds-docks/.histoire/dist", "storyMatch": ["**/*.story.vue", "**/*.story.svelte"], "storyIgnored": ["**/node_modules/**", "**/dist/**"], "supportMatch": [{ "id": "vanilla", "patterns": ["**/*.js"], "pluginIds": ["vanilla"] }, { "id": "svelte", "patterns": ["**/*.svelte"], "pluginIds": ["svelte3"] }], "tree": { "file": "title", "order": "asc" }, "theme": { "title": "Histoire", "colors": { "primary": { "50": "#fff7ed", "100": "#ffedd5", "200": "#fed7aa", "300": "#fdba74", "400": "#fb923c", "500": "#f97316", "600": "#ea580c", "700": "#c2410c", "800": "#9a3412", "900": "#7c2d12" }, "gray": { "50": "#fafafa", "100": "#f4f4f5", "200": "#e4e4e7", "300": "#d4d4d8", "400": "#a1a1aa", "500": "#71717a", "600": "#52525b", "700": "#3f3f46", "750": "#323238", "800": "#27272a", "850": "#1f1f21", "900": "#18181b", "950": "#101012" } }, "defaultColorScheme": "auto", "storeColorScheme": true, "darkClass": "dark", "logo": { "square": "@histoire/plugin-svelte/assets/histoire-svelte.svg", "light": "@histoire/plugin-svelte/assets/histoire-svelte-text.svg", "dark": "@histoire/plugin-svelte/assets/histoire-svelte-text.svg" } }, "responsivePresets": [{ "label": "Mobile (Small)", "width": 320, "height": 560 }, { "label": "Mobile (Medium)", "width": 360, "height": 640 }, { "label": "Mobile (Large)", "width": 414, "height": 896 }, { "label": "Tablet", "width": 768, "height": 1024 }, { "label": "Laptop (Small)", "width": 1024, "height": null }, { "label": "Laptop (Large)", "width": 1366, "height": null }, { "label": "Desktop", "width": 1920, "height": null }, { "label": "4K", "width": 3840, "height": null }], "backgroundPresets": [{ "label": "Transparent", "color": "transparent", "contrastColor": "#333" }, { "label": "White", "color": "#fff", "contrastColor": "#333" }, { "label": "Light gray", "color": "#aaa", "contrastColor": "#000" }, { "label": "Dark gray", "color": "#333", "contrastColor": "#fff" }, { "label": "Black", "color": "#000", "contrastColor": "#eee" }], "sandboxDarkClass": "dark", "routerMode": "history", "build": { "excludeFromVendorsChunk": [] }, "viteIgnorePlugins": ["vite-plugin-sveltekit-compile"] };
const logos = { square: Logo_square, light: Logo_dark, dark: Logo_dark };
const histoireConfig = config$1;
const customLogos = logos;
const isDark = useDark({
valueDark: "htw-dark",
initialValue: histoireConfig.theme.defaultColorScheme,
storageKey: "histoire-color-scheme",
storage: histoireConfig.theme.storeColorScheme ? localStorage : sessionStorage
});
const toggleDark = useToggle(isDark);
function applyDarkToControls() {
var _a3;
(_a3 = window.__hst_controls_dark) == null ? void 0 : _a3.forEach((ref2) => {
ref2.value = isDark.value;
});
}
watch(isDark, () => {
applyDarkToControls();
}, {
immediate: true
});
window.__hst_controls_dark_ready = () => {
applyDarkToControls();
};
const STATE_SYNC = "__histoire:state-sync";
const SANDBOX_READY = "__histoire:sandbox-ready";
const EVENT_SEND = "__histoire:event";
const PREVIEW_SETTINGS_SYNC = "__histoire:preview-settings-sync";
async function logEvent(name, argument) {
var _a3;
console.log("[histoire] Event fired", { name, argument });
const event = {
name,
argument: JSON.parse(stringifyEvent(argument))
// Needed for HTMLEvent that can't be cloned
};
if (location.href.includes("__sandbox")) {
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
type: EVENT_SEND,
event
});
} else {
const { useEventsStore } = await __vitePreload(() => import("./events-ae5cec59.js"), true ? ["assets/events-ae5cec59.js","assets/story-804dabc9.js","assets/GenericMountStory.vue2-2bb5633d.js"] : void 0);
useEventsStore().addEvent(event);
}
}
function stringifyEvent(e2) {
const obj = {};
for (const k2 in e2) {
obj[k2] = e2[k2];
}
return JSON.stringify(obj, (k2, v2) => {
if (v2 instanceof Node)
return "Node";
if (v2 instanceof Window)
return "Window";
return v2;
}, " ");
}
const pico_min = "";
const matchName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
const iconDefaults = Object.freeze({
left: 0,
top: 0,
width: 16,
height: 16,
rotate: 0,
vFlip: false,
hFlip: false
});
function fullIcon(data) {
return { ...iconDefaults, ...data };
}
const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
const colonSeparated = value.split(":");
if (value.slice(0, 1) === "@") {
if (colonSeparated.length < 2 || colonSeparated.length > 3) {
return null;
}
provider = colonSeparated.shift().slice(1);
}
if (colonSeparated.length > 3 || !colonSeparated.length) {
return null;
}
if (colonSeparated.length > 1) {
const name2 = colonSeparated.pop();
const prefix = colonSeparated.pop();
const result = {
provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
prefix,
name: name2
};
return validate && !validateIcon(result) ? null : result;
}
const name = colonSeparated[0];
const dashSeparated = name.split("-");
if (dashSeparated.length > 1) {
const result = {
provider,
prefix: dashSeparated.shift(),
name: dashSeparated.join("-")
};
return validate && !validateIcon(result) ? null : result;
}
if (allowSimpleName && provider === "") {
const result = {
provider,
prefix: "",
name
};
return validate && !validateIcon(result, allowSimpleName) ? null : result;
}
return null;
};
const validateIcon = (icon, allowSimpleName) => {
if (!icon) {
return false;
}
return !!((icon.provider === "" || icon.provider.match(matchName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchName)) && icon.name.match(matchName));
};
function mergeIconData(icon, alias) {
const result = { ...icon };
for (const key in iconDefaults) {
const prop = key;
if (alias[prop] !== void 0) {
const value = alias[prop];
if (result[prop] === void 0) {
result[prop] = value;
continue;
}
switch (prop) {
case "rotate":
result[prop] = (result[prop] + value) % 4;
break;
case "hFlip":
case "vFlip":
result[prop] = value !== result[prop];
break;
default:
result[prop] = value;
}
}
}
return result;
}
function getIconData$1(data, name, full = false) {
function getIcon(name2, iteration) {
if (data.icons[name2] !== void 0) {
return Object.assign({}, data.icons[name2]);
}
if (iteration > 5) {
return null;
}
const aliases = data.aliases;
if (aliases && aliases[name2] !== void 0) {
const item = aliases[name2];
const result2 = getIcon(item.parent, iteration + 1);
if (result2) {
return mergeIconData(result2, item);
}
return result2;
}
const chars = data.chars;
if (!iteration && chars && chars[name2] !== void 0) {
return getIcon(chars[name2], iteration + 1);
}
return null;
}
const result = getIcon(name, 0);
if (result) {
for (const key in iconDefaults) {
if (result[key] === void 0 && data[key] !== void 0) {
result[key] = data[key];
}
}
}
return result && full ? fullIcon(result) : result;
}
function isVariation(item) {
for (const key in iconDefaults) {
if (item[key] !== void 0) {
return true;
}
}
return false;
}
function parseIconSet(data, callback, options) {
options = options || {};
const names = [];
if (typeof data !== "object" || typeof data.icons !== "object") {
return names;
}
if (data.not_found instanceof Array) {
data.not_found.forEach((name) => {
callback(name, null);
names.push(name);
});
}
const icons = data.icons;
Object.keys(icons).forEach((name) => {
const iconData = getIconData$1(data, name, true);
if (iconData) {
callback(name, iconData);
names.push(name);
}
});
const parseAliases = options.aliases || "all";
if (parseAliases !== "none" && typeof data.aliases === "object") {
const aliases = data.aliases;
Object.keys(aliases).forEach((name) => {
if (parseAliases === "variations" && isVariation(aliases[name])) {
return;
}
const iconData = getIconData$1(data, name, true);
if (iconData) {
callback(name, iconData);
names.push(name);
}
});
}
return names;
}
const optionalProperties = {
provider: "string",
aliases: "object",
not_found: "object"
};
for (const prop in iconDefaults) {
optionalProperties[prop] = typeof iconDefaults[prop];
}
function quicklyValidateIconSet(obj) {
if (typeof obj !== "object" || obj === null) {
return null;
}
const data = obj;
if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
return null;
}
for (const prop in optionalProperties) {
if (obj[prop] !== void 0 && typeof obj[prop] !== optionalProperties[prop]) {
return null;
}
}
const icons = data.icons;
for (const name in icons) {
const icon = icons[name];
if (!name.match(matchName) || typeof icon.body !== "string") {
return null;
}
for (const prop in iconDefaults) {
if (icon[prop] !== void 0 && typeof icon[prop] !== typeof iconDefaults[prop]) {
return null;
}
}
}
const aliases = data.aliases;
if (aliases) {
for (const name in aliases) {
const icon = aliases[name];
const parent = icon.parent;
if (!name.match(matchName) || typeof parent !== "string" || !icons[parent] && !aliases[parent]) {
return null;
}
for (const prop in iconDefaults) {
if (icon[prop] !== void 0 && typeof icon[prop] !== typeof iconDefaults[prop]) {
return null;
}
}
}
}
return data;
}
const storageVersion = 1;
let storage$1 = /* @__PURE__ */ Object.create(null);
try {
const w2 = window || self;
if (w2 && w2._iconifyStorage.version === storageVersion) {
storage$1 = w2._iconifyStorage.storage;
}
} catch (err) {
}
function newStorage(provider, prefix) {
return {
provider,
prefix,
icons: /* @__PURE__ */ Object.create(null),
missing: /* @__PURE__ */ Object.create(null)
};
}
function getStorage(provider, prefix) {
if (storage$1[provider] === void 0) {
storage$1[provider] = /* @__PURE__ */ Object.create(null);
}
const providerStorage = storage$1[provider];
if (providerStorage[prefix] === void 0) {
providerStorage[prefix] = newStorage(provider, prefix);
}
return providerStorage[prefix];
}
function addIconSet(storage2, data) {
if (!quicklyValidateIconSet(data)) {
return [];
}
const t2 = Date.now();
return parseIconSet(data, (name, icon) => {
if (icon) {
storage2.icons[name] = icon;
} else {
storage2.missing[name] = t2;
}
});
}
function addIconToStorage(storage2, name, icon) {
try {
if (typeof icon.body === "string") {
storage2.icons[name] = Object.freeze(fullIcon(icon));
return true;
}
} catch (err) {
}
return false;
}
function getIconFromStorage(storage2, name) {
const value = storage2.icons[name];
return value === void 0 ? null : value;
}
let simpleNames = false;
function allowSimpleNames(allow) {
if (typeof allow === "boolean") {
simpleNames = allow;
}
return simpleNames;
}
function getIconData(name) {
const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
return icon ? getIconFromStorage(getStorage(icon.provider, icon.prefix), icon.name) : null;
}
function addIcon(name, data) {
const icon = stringToIcon(name, true, simpleNames);
if (!icon) {
return false;
}
const storage2 = getStorage(icon.provider, icon.prefix);
return addIconToStorage(storage2, icon.name, data);
}
function addCollection(data, provider) {
if (typeof data !== "object") {
return false;
}
if (typeof provider !== "string") {
provider = typeof data.provider === "string" ? data.provider : "";
}
if (simpleNames && provider === "" && (typeof data.prefix !== "string" || data.prefix === "")) {
let added = false;
if (quicklyValidateIconSet(data)) {
data.prefix = "";
parseIconSet(data, (name, icon) => {
if (icon && addIcon(name, icon)) {
added = true;
}
});
}
return added;
}
if (typeof data.prefix !== "string" || !validateIcon({
provider,
prefix: data.prefix,
name: "a"
})) {
return false;
}
const storage2 = getStorage(provider, data.prefix);
return !!addIconSet(storage2, data);
}
const defaults = Object.freeze({
inline: false,
width: null,
height: null,
hAlign: "center",
vAlign: "middle",
slice: false,
hFlip: false,
vFlip: false,
rotate: 0
});
function mergeCustomisations(defaults2, item) {
const result = {};
for (const key in defaults2) {
const attr2 = key;
result[attr2] = defaults2[attr2];
if (item[attr2] === void 0) {
continue;
}
const value = item[attr2];
switch (attr2) {
case "inline":
case "slice":
if (typeof value === "boolean") {
result[attr2] = value;
}
break;
case "hFlip":
case "vFlip":
if (value === true) {
result[attr2] = !result[attr2];
}
break;
case "hAlign":
case "vAlign":
if (typeof value === "string" && value !== "") {
result[attr2] = value;
}
break;
case "width":
case "height":
if (typeof value === "string" && value !== "" || typeof value === "number" && value || value === null) {
result[attr2] = value;
}
break;
case "rotate":
if (typeof value === "number") {
result[attr2] += value;
}
break;
}
}
return result;
}
const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
function calculateSize(size2, ratio, precision) {
if (ratio === 1) {
return size2;
}
precision = precision === void 0 ? 100 : precision;
if (typeof size2 === "number") {
return Math.ceil(size2 * ratio * precision) / precision;
}
if (typeof size2 !== "string") {
return size2;
}
const oldParts = size2.split(unitsSplit);
if (oldParts === null || !oldParts.length) {
return size2;
}
const newParts = [];
let code = oldParts.shift();
let isNumber = unitsTest.test(code);
while (true) {
if (isNumber) {
const num = parseFloat(code);
if (isNaN(num)) {
newParts.push(code);
} else {
newParts.push(Math.ceil(num * ratio * precision) / precision);
}
} else {
newParts.push(code);
}
code = oldParts.shift();
if (code === void 0) {
return newParts.join("");
}
isNumber = !isNumber;
}
}
function preserveAspectRatio(props) {
let result = "";
switch (props.hAlign) {
case "left":
result += "xMin";
break;
case "right":
result += "xMax";
break;
default:
result += "xMid";
}
switch (props.vAlign) {
case "top":
result += "YMin";
break;
case "bottom":
result += "YMax";
break;
default:
result += "YMid";
}
result += props.slice ? " slice" : " meet";
return result;
}
function iconToSVG(icon, customisations) {
const box = {
left: icon.left,
top: icon.top,
width: icon.width,
height: icon.height
};
let body = icon.body;
[icon, customisations].forEach((props) => {
const transformations = [];
const hFlip = props.hFlip;
const vFlip = props.vFlip;
let rotation = props.rotate;
if (hFlip) {
if (vFlip) {
rotation += 2;
} else {
transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")");
transformations.push("scale(-1 1)");
box.top = box.left = 0;
}
} else if (vFlip) {
transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")");
transformations.push("scale(1 -1)");
box.top = box.left = 0;
}
let tempValue;
if (rotation < 0) {
rotation -= Math.floor(rotation / 4) * 4;
}
rotation = rotation % 4;
switch (rotation) {
case 1:
tempValue = box.height / 2 + box.top;
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
break;
case 2:
transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")");
break;
case 3:
tempValue = box.width / 2 + box.left;
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
break;
}
if (rotation % 2 === 1) {
if (box.left !== 0 || box.top !== 0) {
tempValue = box.left;
box.left = box.top;
box.top = tempValue;
}
if (box.width !== box.height) {
tempValue = box.width;
box.width = box.height;
box.height = tempValue;
}
}
if (transformations.length) {
body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
}
});
let width, height;
if (customisations.width === null && customisations.height === null) {
height = "1em";
width = calculateSize(height, box.width / box.height);
} else if (customisations.width !== null && customisations.height !== null) {
width = customisations.width;
height = customisations.height;
} else if (customisations.height !== null) {
height = customisations.height;
width = calculateSize(height, box.width / box.height);
} else {
width = customisations.width;
height = calculateSize(width, box.height / box.width);
}
if (width === "auto") {
width = box.width;
}
if (height === "auto") {
height = box.height;
}
width = typeof width === "string" ? width : width.toString() + "";
height = typeof height === "string" ? height : height.toString() + "";
const result = {
attributes: {
width,
height,
preserveAspectRatio: preserveAspectRatio(customisations),
viewBox: box.left.toString() + " " + box.top.toString() + " " + box.width.toString() + " " + box.height.toString()
},
body
};
if (customisations.inline) {
result.inline = true;
}
return result;
}
const regex = /\sid="(\S+)"/g;
const randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
let counter = 0;
function replaceIDs(body, prefix = randomPrefix) {
const ids = [];
let match;
while (match = regex.exec(body)) {
ids.push(match[1]);
}
if (!ids.length) {
return body;
}
ids.forEach((id2) => {
const newID = typeof prefix === "function" ? prefix(id2) : prefix + (counter++).toString();
const escapedID = id2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
body = body.replace(new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), "$1" + newID + "$3");
});
return body;
}
const storage = /* @__PURE__ */ Object.create(null);
function setAPIModule(provider, item) {
storage[provider] = item;
}
function getAPIModule(provider) {
return storage[provider] || storage[""];
}
function createAPIConfig(source) {
let resources;
if (typeof source.resources === "string") {
resources = [source.resources];
} else {
resources = source.resources;
if (!(resources instanceof Array) || !resources.length) {
return null;
}
}
const result = {
resources,
path: source.path === void 0 ? "/" : source.path,
maxURL: source.maxURL ? source.maxURL : 500,
rotate: source.rotate ? source.rotate : 750,
timeout: source.timeout ? source.timeout : 5e3,
random: source.random === true,
index: source.index ? source.index : 0,
dataAfterTimeout: source.dataAfterTimeout !== false
};
return result;
}
const configStorage = /* @__PURE__ */ Object.create(null);
const fallBackAPISources = [
"https://api.simplesvg.com",
"https://api.unisvg.com"
];
const fallBackAPI = [];
while (fallBackAPISources.length > 0) {
if (fallBackAPISources.length === 1) {
fallBackAPI.push(fallBackAPISources.shift());
} else {
if (Math.random() > 0.5) {
fallBackAPI.push(fallBackAPISources.shift());
} else {
fallBackAPI.push(fallBackAPISources.pop());
}
}
}
configStorage[""] = createAPIConfig({
resources: ["https://api.iconify.design"].concat(fallBackAPI)
});
function addAPIProvider(provider, customConfig) {
const config2 = createAPIConfig(customConfig);
if (config2 === null) {
return false;
}
configStorage[provider] = config2;
return true;
}
function getAPIConfig(provider) {
return configStorage[provider];
}
const mergeParams = (base2, params) => {
let result = base2, hasParams = result.indexOf("?") !== -1;
function paramToString(value) {
switch (typeof value) {
case "boolean":
return value ? "true" : "false";
case "number":
return encodeURIComponent(value);
case "string":
return encodeURIComponent(value);
default:
throw new Error("Invalid parameter");
}
}
Object.keys(params).forEach((key) => {
let value;
try {
value = paramToString(params[key]);
} catch (err) {
return;
}
result += (hasParams ? "&" : "?") + encodeURIComponent(key) + "=" + value;
hasParams = true;
});
return result;
};
const maxLengthCache = {};
const pathCache = {};
const detectFetch = () => {
let callback;
try {
callback = fetch;
if (typeof callback === "function") {
return callback;
}
} catch (err) {
}
return null;
};
let fetchModule = detectFetch();
function calculateMaxLength(provider, prefix) {
const config2 = getAPIConfig(provider);
if (!config2) {
return 0;
}
let result;
if (!config2.maxURL) {
result = 0;
} else {
let maxHostLength = 0;
config2.resources.forEach((item) => {
const host = item;
maxHostLength = Math.max(maxHostLength, host.length);
});
const url = mergeParams(prefix + ".json", {
icons: ""
});
result = config2.maxURL - maxHostLength - config2.path.length - url.length;
}
const cacheKey = provider + ":" + prefix;
pathCache[provider] = config2.path;
maxLengthCache[cacheKey] = result;
return result;
}
function shouldAbort(status) {
return status === 404;
}
const prepare = (provider, prefix, icons) => {
const results = [];
let maxLength = maxLengthCache[prefix];
if (maxLength === void 0) {
maxLength = calculateMaxLength(provider, prefix);
}
const type = "icons";
let item = {
type,
provider,
prefix,
icons: []
};
let length = 0;
icons.forEach((name, index2) => {
length += name.length + 1;
if (length >= maxLength && index2 > 0) {
results.push(item);
item = {
type,
provider,
prefix,
icons: []
};
length = name.length;
}
item.icons.push(name);
});
results.push(item);
return results;
};
function getPath(provider) {
if (typeof provider === "string") {
if (pathCache[provider] === void 0) {
const config2 = getAPIConfig(provider);
if (!config2) {
return "/";
}
pathCache[provider] = config2.path;
}
return pathCache[provider];
}
return "/";
}
const send = (host, params, callback) => {
if (!fetchModule) {
callback("abort", 424);
return;
}
let path = getPath(params.provider);
switch (params.type) {
case "icons": {
const prefix = params.prefix;
const icons = params.icons;
const iconsList = icons.join(",");
path += mergeParams(prefix + ".json", {
icons: iconsList
});
break;
}
case "custom": {
const uri = params.uri;
path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
break;
}
default:
callback("abort", 400);
return;
}
let defaultError = 503;
fetchModule(host + path).then((response) => {
const status = response.status;
if (status !== 200) {
setTimeout(() => {
callback(shouldAbort(status) ? "abort" : "next", status);
});
return;
}
defaultError = 501;
return response.json();
}).then((data) => {
if (typeof data !== "object" || data === null) {
setTimeout(() => {
callback("next", defaultError);
});
return;
}
setTimeout(() => {
callback("success", data);
});
}).catch(() => {
callback("next", defaultError);
});
};
const fetchAPIModule = {
prepare,
send
};
function sortIcons(icons) {
const result = {
loaded: [],
missing: [],
pending: []
};
const storage2 = /* @__PURE__ */ Object.create(null);
icons.sort((a2, b3) => {
if (a2.provider !== b3.provider) {
return a2.provider.localeCompare(b3.provider);
}
if (a2.prefix !== b3.prefix) {
return a2.prefix.localeCompare(b3.prefix);
}
return a2.name.localeCompare(b3.name);
});
let lastIcon = {
provider: "",
prefix: "",
name: ""
};
icons.forEach((icon) => {
if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
return;
}
lastIcon = icon;
const provider = icon.provider;
const prefix = icon.prefix;
const name = icon.name;
if (storage2[provider] === void 0) {
storage2[provider] = /* @__PURE__ */ Object.create(null);
}
const providerStorage = storage2[provider];
if (providerStorage[prefix] === void 0) {
providerStorage[prefix] = getStorage(provider, prefix);
}
const localStorage2 = providerStorage[prefix];
let list;
if (localStorage2.icons[name] !== void 0) {
list = result.loaded;
} else if (prefix === "" || localStorage2.missing[name] !== void 0) {
list = result.missing;
} else {
list = result.pending;
}
const item = {
provider,
prefix,
name
};
list.push(item);
});
return result;
}
const callbacks = /* @__PURE__ */ Object.create(null);
const pendingUpdates = /* @__PURE__ */ Object.create(null);
function removeCallback(sources, id2) {
sources.forEach((source) => {
const provider = source.provider;
if (callbacks[provider] === void 0) {
return;
}
const providerCallbacks = callbacks[provider];
const prefix = source.prefix;
const items = providerCallbacks[prefix];
if (items) {
providerCallbacks[prefix] = items.filter((row) => row.id !== id2);
}
});
}
function updateCallbacks(provider, prefix) {
if (pendingUpdates[provider] === void 0) {
pendingUpdates[provider] = /* @__PURE__ */ Object.create(null);
}
const providerPendingUpdates = pendingUpdates[provider];
if (!providerPendingUpdates[prefix]) {
providerPendingUpdates[prefix] = true;
setTimeout(() => {
providerPendingUpdates[prefix] = false;
if (callbacks[provider] === void 0 || callbacks[provider][prefix] === void 0) {
return;
}
const items = callbacks[provider][prefix].slice(0);
if (!items.length) {
return;
}
const storage2 = getStorage(provider, prefix);
let hasPending = false;
items.forEach((item) => {
const icons = item.icons;
const oldLength = icons.pending.length;
icons.pending = icons.pending.filter((icon) => {
if (icon.prefix !== prefix) {
return true;
}
const name = icon.name;
if (storage2.icons[name] !== void 0) {
icons.loaded.push({
provider,
prefix,
name
});
} else if (storage2.missing[name] !== void 0) {
icons.missing.push({
provider,
prefix,
name
});
} else {
hasPending = true;
return true;
}
return false;
});
if (icons.pending.length !== oldLength) {
if (!hasPending) {
removeCallback([
{
provider,
prefix
}
], item.id);
}
item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);
}
});
});
}
}
let idCounter = 0;
function storeCallback(callback, icons, pendingSources) {
const id2 = idCounter++;
const abort = removeCallback.bind(null, pendingSources, id2);
if (!icons.pending.length) {
return abort;
}
const item = {
id: id2,
icons,
callback,
abort
};
pendingSources.forEach((source) => {
const provider = source.provider;
const prefix = source.prefix;
if (callbacks[provider] === void 0) {
callbacks[provider] = /* @__PURE__ */ Object.create(null);
}
const providerCallbacks = callbacks[provider];
if (providerCallbacks[prefix] === void 0) {
providerCallbacks[prefix] = [];
}
providerCallbacks[prefix].push(item);
});
return abort;
}
function listToIcons(list, validate = true, simpleNames2 = false) {
const result = [];
list.forEach((item) => {
const icon = typeof item === "string" ? stringToIcon(item, false, simpleNames2) : item;
if (!validate || validateIcon(icon, simpleNames2)) {
result.push({
provider: icon.provider,
prefix: icon.prefix,
name: icon.name
});
}
});
return result;
}
var defaultConfig = {
resources: [],
index: 0,
timeout: 2e3,
rotate: 750,
random: false,
dataAfterTimeout: false
};
function sendQuery(config2, payload, query, done) {
const resourcesCount = config2.resources.length;
const startIndex = config2.random ? Math.floor(Math.random() * resourcesCount) : config2.index;
let resources;
if (config2.random) {
let list = config2.resources.slice(0);
resources = [];
while (list.length > 1) {
const nextIndex = Math.floor(Math.random() * list.length);
resources.push(list[nextIndex]);
list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
}
resources = resources.concat(list);
} else {
resources = config2.resources.slice(startIndex).concat(config2.resources.slice(0, startIndex));
}
const startTime = Date.now();
let status = "pending";
let queriesSent = 0;
let lastError;
let timer = null;
let queue2 = [];
let doneCallbacks = [];
if (typeof done === "function") {
doneCallbacks.push(done);
}
function resetTimer() {
if (timer) {
clearTimeout(timer);
timer = null;
}
}
function abort() {
if (status === "pending") {
status = "aborted";
}
resetTimer();
queue2.forEach((item) => {
if (item.status === "pending") {
item.status = "aborted";
}
});
queue2 = [];
}
function subscribe(callback, overwrite) {
if (overwrite) {
doneCallbacks = [];
}
if (typeof callback === "function") {
doneCallbacks.push(callback);
}
}
function getQueryStatus() {
return {
startTime,
payload,
status,
queriesSent,
queriesPending: queue2.length,
subscribe,
abort
};
}
function failQuery() {
status = "failed";
doneCallbacks.forEach((callback) => {
callback(void 0, lastError);
});
}
function clearQueue() {
queue2.forEach((item) => {
if (item.status === "pending") {
item.status = "aborted";
}
});
queue2 = [];
}
function moduleResponse(item, response, data) {
const isError = response !== "success";
queue2 = queue2.filter((queued) => queued !== item);
switch (status) {
case "pending":
break;
case "failed":
if (isError || !config2.dataAfterTimeout) {
return;
}
break;
default:
return;
}
if (response === "abort") {
lastError = data;
failQuery();
return;
}
if (isError) {
lastError = data;
if (!queue2.length) {
if (!resources.length) {
failQuery();
} else {
execNext();
}
}
return;
}
resetTimer();
clearQueue();
if (!config2.random) {
const index2 = config2.resources.indexOf(item.resource);
if (index2 !== -1 && index2 !== config2.index) {
config2.index = index2;
}
}
status = "completed";
doneCallbacks.forEach((callback) => {
callback(data);
});
}
function execNext() {
if (status !== "pending") {
return;
}
resetTimer();
const resource = resources.shift();
if (resource === void 0) {
if (queue2.length) {
timer = setTimeout(() => {
resetTimer();
if (status === "pending") {
clearQueue();
failQuery();
}
}, config2.timeout);
return;
}
failQuery();
return;
}
const item = {
status: "pending",
resource,
callback: (status2, data) => {
moduleResponse(item, status2, data);
}
};
queue2.push(item);
queriesSent++;
timer = setTimeout(execNext, config2.rotate);
query(resource, payload, item.callback);
}
setTimeout(execNext);
return getQueryStatus;
}
function setConfig(config2) {
if (typeof config2 !== "object" || typeof config2.resources !== "object" || !(config2.resources instanceof Array) || !config2.resources.length) {
throw new Error("Invalid Reduncancy configuration");
}
const newConfig = /* @__PURE__ */ Object.create(null);
let key;
for (key in defaultConfig) {
if (config2[key] !== void 0) {
newConfig[key] = config2[key];
} else {
newConfig[key] = defaultConfig[key];
}
}
return newConfig;
}
function initRedundancy(cfg) {
const config2 = setConfig(cfg);
let queries = [];
function cleanup() {
queries = queries.filter((item) => item().status === "pending");
}
function query(payload, queryCallback, doneCallback) {
const query2 = sendQuery(config2, payload, queryCallback, (data, error) => {
cleanup();
if (doneCallback) {
doneCallback(data, error);
}
});
queries.push(query2);
return query2;
}
function find(callback) {
const result = queries.find((value) => {
return callback(value);
});
return result !== void 0 ? result : null;
}
const instance = {
query,
find,
setIndex: (index2) => {
config2.index = index2;
},
getIndex: () => config2.index,
cleanup
};
return instance;
}
function emptyCallback$1() {
}
const redundancyCache = /* @__PURE__ */ Object.create(null);
function getRedundancyCache(provider) {
if (redundancyCache[provider] === void 0) {
const config2 = getAPIConfig(provider);
if (!config2) {
return;
}
const redundancy = initRedundancy(config2);
const cachedReundancy = {
config: config2,
redundancy
};
redundancyCache[provider] = cachedReundancy;
}
return redundancyCache[provider];
}
function sendAPIQuery(target, query, callback) {
let redundancy;
let send2;
if (typeof target === "string") {
const api = getAPIModule(target);
if (!api) {
callback(void 0, 424);
return emptyCallback$1;
}
send2 = api.send;
const cached = getRedundancyCache(target);
if (cached) {
redundancy = cached.redundancy;
}
} else {
const config2 = createAPIConfig(target);
if (config2) {
redundancy = initRedundancy(config2);
const moduleKey = target.resources ? target.resources[0] : "";
const api = getAPIModule(moduleKey);
if (api) {
send2 = api.send;
}
}
}
if (!redundancy || !send2) {
callback(void 0, 424);
return emptyCallback$1;
}
return redundancy.query(query, send2, callback)().abort;
}
const cache = {};
function emptyCallback() {
}
const pendingIcons = /* @__PURE__ */ Object.create(null);
const iconsToLoad = /* @__PURE__ */ Object.create(null);
const loaderFlags = /* @__PURE__ */ Object.create(null);
const queueFlags = /* @__PURE__ */ Object.create(null);
function loadedNewIcons(provider, prefix) {
if (loaderFlags[provider] === void 0) {
loaderFlags[provider] = /* @__PURE__ */ Object.create(null);
}
const providerLoaderFlags = loaderFlags[provider];
if (!providerLoaderFlags[prefix]) {
providerLoaderFlags[prefix] = true;
setTimeout(() => {
providerLoaderFlags[prefix] = false;
updateCallbacks(provider, prefix);
});
}
}
const errorsCache = /* @__PURE__ */ Object.create(null);
function loadNewIcons(provider, prefix, icons) {
function err() {
const key = (provider === "" ? "" : "@" + provider + ":") + prefix;
const time = Math.floor(Date.now() / 6e4);
if (errorsCache[key] < time) {
errorsCache[key] = time;
console.error('Unable to retrieve icons for "' + key + '" because API is not configured properly.');
}
}
if (iconsToLoad[provider] === void 0) {
iconsToLoad[provider] = /* @__PURE__ */ Object.create(null);
}
const providerIconsToLoad = iconsToLoad[provider];
if (queueFlags[provider] === void 0) {
queueFlags[provider] = /* @__PURE__ */ Object.create(null);
}
const providerQueueFlags = queueFlags[provider];
if (pendingIcons[provider] === void 0) {
pendingIcons[provider] = /* @__PURE__ */ Object.create(null);
}
const providerPendingIcons = pendingIcons[provider];
if (providerIconsToLoad[prefix] === void 0) {
providerIconsToLoad[prefix] = icons;
} else {
providerIconsToLoad[prefix] = providerIconsToLoad[prefix].concat(icons).sort();
}
if (!providerQueueFlags[prefix]) {
providerQueueFlags[prefix] = true;
setTimeout(() => {
providerQueueFlags[prefix] = false;
const icons2 = providerIconsToLoad[prefix];
delete providerIconsToLoad[prefix];
const api = getAPIModule(provider);
if (!api) {
err();
return;
}
const params = api.prepare(provider, prefix, icons2);
params.forEach((item) => {
sendAPIQuery(provider, item, (data, error) => {
const storage2 = getStorage(provider, prefix);
if (typeof data !== "object") {
if (error !== 404) {
return;
}
const t2 = Date.now();
item.icons.forEach((name) => {
storage2.missing[name] = t2;
});
} else {
try {
const parsed = addIconSet(storage2, data);
if (!parsed.length) {
return;
}
const pending = providerPendingIcons[prefix];
parsed.forEach((name) => {
delete pending[name];
});
if (cache.store) {
cache.store(provider, data);
}
} catch (err2) {
console.error(err2);
}
}
loadedNewIcons(provider, prefix);
});
});
});
}
}
const loadIcons = (icons, callback) => {
const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
const sortedIcons = sortIcons(cleanedIcons);
if (!sortedIcons.pending.length) {
let callCallback = true;
if (callback) {
setTimeout(() => {
if (callCallback) {
callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);
}
});
}
return () => {
callCallback = false;
};
}
const newIcons = /* @__PURE__ */ Object.create(null);
const sources = [];
let lastProvider, lastPrefix;
sortedIcons.pending.forEach((icon) => {
const provider = icon.provider;
const prefix = icon.prefix;
if (prefix === lastPrefix && provider === lastProvider) {
return;
}
lastProvider = provider;
lastPrefix = prefix;
sources.push({
provider,
prefix
});
if (pendingIcons[provider] === void 0) {
pendingIcons[provider] = /* @__PURE__ */ Object.create(null);
}
const providerPendingIcons = pendingIcons[provider];
if (providerPendingIcons[prefix] === void 0) {
providerPendingIcons[prefix] = /* @__PURE__ */ Object.create(null);
}
if (newIcons[provider] === void 0) {
newIcons[provider] = /* @__PURE__ */ Object.create(null);
}
const providerNewIcons = newIcons[provider];
if (providerNewIcons[prefix] === void 0) {
providerNewIcons[prefix] = [];
}
});
const time = Date.now();
sortedIcons.pending.forEach((icon) => {
const provider = icon.provider;
const prefix = icon.prefix;
const name = icon.name;
const pendingQueue = pendingIcons[provider][prefix];
if (pendingQueue[name] === void 0) {
pendingQueue[name] = time;
newIcons[provider][prefix].push(name);
}
});
sources.forEach((source) => {
const provider = source.provider;
const prefix = source.prefix;
if (newIcons[provider][prefix].length) {
loadNewIcons(provider, prefix, newIcons[provider][prefix]);
}
});
return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
};
const cacheVersion = "iconify2";
const cachePrefix = "iconify";
const countKey = cachePrefix + "-count";
const versionKey = cachePrefix + "-version";
const hour = 36e5;
const cacheExpiration = 168;
const config = {
local: true,
session: true
};
let loaded = false;
const count = {
local: 0,
session: 0
};
const emptyList = {
local: [],
session: []
};
let _window = typeof window === "undefined" ? {} : window;
function getGlobal(key) {
const attr2 = key + "Storage";
try {
if (_window && _window[attr2] && typeof _window[attr2].length === "number") {
return _window[attr2];
}
} catch (err) {
}
config[key] = false;
return null;
}
function setCount(storage2, key, value) {
try {
storage2.setItem(countKey, value.toString());
count[key] = value;
return true;
} catch (err) {
return false;
}
}
function getCount(storage2) {
const count2 = storage2.getItem(countKey);
if (count2) {
const total = parseInt(count2);
return total ? total : 0;
}
return 0;
}
function initCache(storage2, key) {
try {
storage2.setItem(versionKey, cacheVersion);
} catch (err) {
}
setCount(storage2, key, 0);
}
function destroyCache(storage2) {
try {
const total = getCount(storage2);
for (let i2 = 0; i2 < total; i2++) {
storage2.removeItem(cachePrefix + i2.toString());
}
} catch (err) {
}
}
const loadCache = () => {
if (loaded) {
return;
}
loaded = true;
const minTime = Math.floor(Date.now() / hour) - cacheExpiration;
function load(key) {
const func = getGlobal(key);
if (!func) {
return;
}
const getItem = (index2) => {
const name = cachePrefix + index2.toString();
const item = func.getItem(name);
if (typeof item !== "string") {
return false;
}
let valid = true;
try {
const data = JSON.parse(item);
if (typeof data !== "object" || typeof data.cached !== "number" || data.cached < minTime || typeof data.provider !== "string" || typeof data.data !== "object" || typeof data.data.prefix !== "string") {
valid = false;
} else {
const provider = data.provider;
const prefix = data.data.prefix;
const storage2 = getStorage(provider, prefix);
valid = addIconSet(storage2, data.data).length > 0;
}
} catch (err) {
valid = false;
}
if (!valid) {
func.removeItem(name);
}
return valid;
};
try {
const version2 = func.getItem(versionKey);
if (version2 !== cacheVersion) {
if (version2) {
destroyCache(func);
}
initCache(func, key);
return;
}
let total = getCount(func);
for (let i2 = total - 1; i2 >= 0; i2--) {
if (!getItem(i2)) {
if (i2 === total - 1) {
total--;
} else {
emptyList[key].push(i2);
}
}
}
setCount(func, key, total);
} catch (err) {
}
}
for (const key in config) {
load(key);
}
};
const storeCache = (provider, data) => {
if (!loaded) {
loadCache();
}
function store(key) {
if (!config[key]) {
return false;
}
const func = getGlobal(key);
if (!func) {
return false;
}
let index2 = emptyList[key].shift();
if (index2 === void 0) {
index2 = count[key];
if (!setCount(func, key, index2 + 1)) {
return false;
}
}
try {
const item = {
cached: Math.floor(Date.now() / hour),
provider,
data
};
func.setItem(cachePrefix + index2.toString(), JSON.stringify(item));
} catch (err) {
return false;
}
return true;
}
if (!Object.keys(data.icons).length) {
return;
}
if (data.not_found) {
data = Object.assign({}, data);
delete data.not_found;
}
if (!store("local")) {
store("session");
}
};
const separator = /[\s,]+/;
function flipFromString(custom, flip2) {
flip2.split(separator).forEach((str) => {
const value = str.trim();
switch (value) {
case "horizontal":
custom.hFlip = true;
break;
case "vertical":
custom.vFlip = true;
break;
}
});
}
function alignmentFromString(custom, align) {
align.split(separator).forEach((str) => {
const value = str.trim();
switch (value) {
case "left":
case "center":
case "right":
custom.hAlign = value;
break;
case "top":
case "middle":
case "bottom":
custom.vAlign = value;
break;
case "slice":
case "crop":
custom.slice = true;
break;
case "meet":
custom.slice = false;
}
});
}
function rotateFromString(value, defaultValue = 0) {
const units = value.replace(/^-?[0-9.]*/, "");
function cleanup(value2) {
while (value2 < 0) {
value2 += 4;
}
return value2 % 4;
}
if (units === "") {
const num = parseInt(value);
return isNaN(num) ? 0 : cleanup(num);
} else if (units !== value) {
let split = 0;
switch (units) {
case "%":
split = 25;
break;
case "deg":
split = 90;
}
if (split) {
let num = parseFloat(value.slice(0, value.length - units.length));
if (isNaN(num)) {
return 0;
}
num = num / split;
return num % 1 === 0 ? cleanup(num) : 0;
}
}
return defaultValue;
}
const svgDefaults = {
"xmlns": "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"aria-hidden": true,
"role": "img"
};
let customisationAliases = {};
["horizontal", "vertical"].forEach((prefix) => {
["Align", "Flip"].forEach((suffix) => {
const attr2 = prefix.slice(0, 1) + suffix;
const value = {
attr: attr2,
boolean: suffix === "Flip"
};
customisationAliases[prefix + "-" + suffix.toLowerCase()] = value;
customisationAliases[prefix.slice(0, 1) + "-" + suffix.toLowerCase()] = value;
customisationAliases[prefix + suffix] = value;
});
});
const render = (icon, props) => {
const customisations = mergeCustomisations(defaults, props);
const componentProps = { ...svgDefaults };
let style = typeof props.style === "object" && !(props.style instanceof Array) ? { ...props.style } : {};
for (let key in props) {
const value = props[key];
if (value === void 0) {
continue;
}
switch (key) {
case "icon":
case "style":
case "onLoad":
break;
case "inline":
case "hFlip":
case "vFlip":
customisations[key] = value === true || value === "true" || value === 1;
break;
case "flip":
if (typeof value === "string") {
flipFromString(customisations, value);
}
break;
case "align":
if (typeof value === "string") {
alignmentFromString(customisations, value);
}
break;
case "color":
style.color = value;
break;
case "rotate":
if (typeof value === "string") {
customisations[key] = rotateFromString(value);
} else if (typeof value === "number") {
customisations[key] = value;
}
break;
case "ariaHidden":
case "aria-hidden":
if (value !== true && value !== "true") {
delete componentProps["aria-hidden"];
}
break;
default:
if (customisationAliases[key] !== void 0) {
if (customisationAliases[key].boolean && (value === true || value === "true" || value === 1)) {
customisations[customisationAliases[key].attr] = true;
} else if (!customisationAliases[key].boolean && typeof value === "string" && value !== "") {
customisations[customisationAliases[key].attr] = value;
}
} else if (defaults[key] === void 0) {
componentProps[key] = value;
}
}
}
const item = iconToSVG(icon, customisations);
for (let key in item.attributes) {
componentProps[key] = item.attributes[key];
}
if (item.inline && style.verticalAlign === void 0 && style["vertical-align"] === void 0) {
style.verticalAlign = "-0.125em";
}
let localCounter = 0;
let id2 = props.id;
if (typeof id2 === "string") {
id2 = id2.replace(/-/g, "_");
}
componentProps["innerHTML"] = replaceIDs(item.body, id2 ? () => id2 + "ID" + localCounter++ : "iconifyVue");
if (Object.keys(style).length > 0) {
componentProps["style"] = style;
}
return h$1("svg", componentProps);
};
allowSimpleNames(true);
setAPIModule("", fetchAPIModule);
if (typeof document !== "undefined" && typeof window !== "undefined") {
cache.store = storeCache;
loadCache();
const _window2 = window;
if (_window2.IconifyPreload !== void 0) {
const preload2 = _window2.IconifyPreload;
const err = "Invalid IconifyPreload syntax.";
if (typeof preload2 === "object" && preload2 !== null) {
(preload2 instanceof Array ? preload2 : [preload2]).forEach((item) => {
try {
if (
// Check if item is an object and not null/array
typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
!addCollection(item)
) {
console.error(err);
}
} catch (e2) {
console.error(err);
}
});
}
}
if (_window2.IconifyProviders !== void 0) {
const providers = _window2.IconifyProviders;
if (typeof providers === "object" && providers !== null) {
for (let key in providers) {
const err = "IconifyProviders[" + key + "] is invalid.";
try {
const value = providers[key];
if (typeof value !== "object" || !value || value.resources === void 0) {
continue;
}
if (!addAPIProvider(key, value)) {
console.error(err);
}
} catch (e2) {
console.error(err);
}
}
}
}
}
const emptyIcon = fullIcon({
body: ""
});
const Icon = defineComponent({
// Do not inherit other attributes: it is handled by render()
inheritAttrs: false,
// Set initial data
data() {
return {
// Mounted status
iconMounted: false,
// Callback counter to trigger re-render
counter: 0
};
},
mounted() {
this._name = "";
this._loadingIcon = null;
this.iconMounted = true;
},
unmounted() {
this.abortLoading();
},
methods: {
abortLoading() {
if (this._loadingIcon) {
this._loadingIcon.abort();
this._loadingIcon = null;
}
},
// Get data for icon to render or null
getIcon(icon, onload) {
if (typeof icon === "object" && icon !== null && typeof icon.body === "string") {
this._name = "";
this.abortLoading();
return {
data: fullIcon(icon)
};
}
let iconName;
if (typeof icon !== "string" || (iconName = stringToIcon(icon, false, true)) === null) {
this.abortLoading();
return null;
}
const data = getIconData(iconName);
if (data === null) {
if (!this._loadingIcon || this._loadingIcon.name !== icon) {
this.abortLoading();
this._name = "";
this._loadingIcon = {
name: icon,
abort: loadIcons([iconName], () => {
this.counter++;
})
};
}
return null;
}
this.abortLoading();
if (this._name !== icon) {
this._name = icon;
if (onload) {
onload(icon);
}
}
const classes = ["iconify"];
if (iconName.prefix !== "") {
classes.push("iconify--" + iconName.prefix);
}
if (iconName.provider !== "") {
classes.push("iconify--" + iconName.provider);
}
return { data, classes };
}
},
// Render icon
render() {
this.counter;
const props = this.$attrs;
const icon = this.iconMounted ? this.getIcon(props.icon, props.onLoad) : null;
if (!icon) {
return render(emptyIcon, props);
}
let newProps = props;
if (icon.classes) {
newProps = {
...props,
class: (typeof props["class"] === "string" ? props["class"] + " " : "") + icon.classes.join(" ")
};
}
return render(icon.data, newProps);
}
});
/*!
* vue-router v4.1.6
* (c) 2022 Eduardo San Martin Morote
* @license MIT
*/
const isBrowser = typeof window !== "undefined";
function isESModule(obj) {
return obj.__esModule || obj[Symbol.toStringTag] === "Module";
}
const assign = Object.assign;
function applyToParams(fn2, params) {
const newParams = {};
for (const key in params) {
const value = params[key];
newParams[key] = isArray(value) ? value.map(fn2) : fn2(value);
}
return newParams;
}
const noop = () => {
};
const isArray = Array.isArray;
function warn(msg) {
const args = Array.from(arguments).slice(1);
console.warn.apply(console, ["[Vue Router warn]: " + msg].concat(args));
}
const TRAILING_SLASH_RE = /\/$/;
const removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, "");
function parseURL(parseQuery2, location2, currentLocation = "/") {
let path, query = {}, searchString = "", hash2 = "";
const hashPos = location2.indexOf("#");
let searchPos = location2.indexOf("?");
if (hashPos < searchPos && hashPos >= 0) {
searchPos = -1;
}
if (searchPos > -1) {
path = location2.slice(0, searchPos);
searchString = location2.slice(searchPos + 1, hashPos > -1 ? hashPos : location2.length);
query = parseQuery2(searchString);
}
if (hashPos > -1) {
path = path || location2.slice(0, hashPos);
hash2 = location2.slice(hashPos, location2.length);
}
path = resolveRelativePath(path != null ? path : location2, currentLocation);
return {
fullPath: path + (searchString && "?") + searchString + hash2,
path,
query,
hash: hash2
};
}
function stringifyURL(stringifyQuery2, location2) {
const query = location2.query ? stringifyQuery2(location2.query) : "";
return location2.path + (query && "?") + query + (location2.hash || "");
}
function stripBase(pathname, base2) {
if (!base2 || !pathname.toLowerCase().startsWith(base2.toLowerCase()))
return pathname;
return pathname.slice(base2.length) || "/";
}
function isSameRouteLocation(stringifyQuery2, a2, b3) {
const aLastIndex = a2.matched.length - 1;
const bLastIndex = b3.matched.length - 1;
return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a2.matched[aLastIndex], b3.matched[bLastIndex]) && isSameRouteLocationParams(a2.params, b3.params) && stringifyQuery2(a2.query) === stringifyQuery2(b3.query) && a2.hash === b3.hash;
}
function isSameRouteRecord(a2, b3) {
return (a2.aliasOf || a2) === (b3.aliasOf || b3);
}
function isSameRouteLocationParams(a2, b3) {
if (Object.keys(a2).length !== Object.keys(b3).length)
return false;
for (const key in a2) {
if (!isSameRouteLocationParamsValue(a2[key], b3[key]))
return false;
}
return true;
}
function isSameRouteLocationParamsValue(a2, b3) {
return isArray(a2) ? isEquivalentArray(a2, b3) : isArray(b3) ? isEquivalentArray(b3, a2) : a2 === b3;
}
function isEquivalentArray(a2, b3) {
return isArray(b3) ? a2.length === b3.length && a2.every((value, i2) => value === b3[i2]) : a2.length === 1 && a2[0] === b3;
}
function resolveRelativePath(to2, from) {
if (to2.startsWith("/"))
return to2;
if (!from.startsWith("/")) {
warn(`Cannot resolve a relative location without an absolute path. Trying to resolve "${to2}" from "${from}". It should look like "/${from}".`);
return to2;
}
if (!to2)
return from;
const fromSegments = from.split("/");
const toSegments = to2.split("/");
let position = fromSegments.length - 1;
let toPosition;
let segment;
for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
segment = toSegments[toPosition];
if (segment === ".")
continue;
if (segment === "..") {
if (position > 1)
position--;
} else
break;
}
return fromSegments.slice(0, position).join("/") + "/" + toSegments.slice(toPosition - (toPosition === toSegments.length ? 1 : 0)).join("/");
}
var NavigationType;
(function(NavigationType2) {
NavigationType2["pop"] = "pop";
NavigationType2["push"] = "push";
})(NavigationType || (NavigationType = {}));
var NavigationDirection;
(function(NavigationDirection2) {
NavigationDirection2["back"] = "back";
NavigationDirection2["forward"] = "forward";
NavigationDirection2["unknown"] = "";
})(NavigationDirection || (NavigationDirection = {}));
function normalizeBase(base2) {
if (!base2) {
if (isBrowser) {
const baseEl = document.querySelector("base");
base2 = baseEl && baseEl.getAttribute("href") || "/";
base2 = base2.replace(/^\w+:\/\/[^\/]+/, "");
} else {
base2 = "/";
}
}
if (base2[0] !== "/" && base2[0] !== "#")
base2 = "/" + base2;
return removeTrailingSlash(base2);
}
const BEFORE_HASH_RE = /^[^#]+#/;
function createHref(base2, location2) {
return base2.replace(BEFORE_HASH_RE, "#") + location2;
}
function getElementPosition(el2, offset2) {
const docRect = document.documentElement.getBoundingClientRect();
const elRect = el2.getBoundingClientRect();
return {
behavior: offset2.behavior,
left: elRect.left - docRect.left - (offset2.left || 0),
top: elRect.top - docRect.top - (offset2.top || 0)
};
}
const computeScrollPosition = () => ({
left: window.pageXOffset,
top: window.pageYOffset
});
function scrollToPosition(position) {
let scrollToOptions;
if ("el" in position) {
const positionEl = position.el;
const isIdSelector = typeof positionEl === "string" && positionEl.startsWith("#");
if (typeof position.el === "string") {
if (!isIdSelector || !document.getElementById(position.el.slice(1))) {
try {
const foundEl = document.querySelector(position.el);
if (isIdSelector && foundEl) {
warn(`The selector "${position.el}" should be passed as "el: document.querySelector('${position.el}')" because it starts with "#".`);
return;
}
} catch (err) {
warn(`The selector "${position.el}" is invalid. If you are using an id selector, make sure to escape it. You can find more information about escaping characters in selectors at https://mathiasbynens.be/notes/css-escapes or use CSS.escape (https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape).`);
return;
}
}
}
const el2 = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
if (!el2) {
warn(`Couldn't find element using selector "${position.el}" returned by scrollBehavior.`);
return;
}
scrollToOptions = getElementPosition(el2, position);
} else {
scrollToOptions = position;
}
if ("scrollBehavior" in document.documentElement.style)
window.scrollTo(scrollToOptions);
else {
window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.pageXOffset, scrollToOptions.top != null ? scrollToOptions.top : window.pageYOffset);
}
}
function getScrollKey(path, delta) {
const position = history.state ? history.state.position - delta : -1;
return position + path;
}
const scrollPositions = /* @__PURE__ */ new Map();
function saveScrollPosition(key, scrollPosition) {
scrollPositions.set(key, scrollPosition);
}
function getSavedScrollPosition(key) {
const scroll = scrollPositions.get(key);
scrollPositions.delete(key);
return scroll;
}
let createBaseLocation = () => location.protocol + "//" + location.host;
function createCurrentLocation(base2, location2) {
const { pathname, search, hash: hash2 } = location2;
const hashPos = base2.indexOf("#");
if (hashPos > -1) {
let slicePos = hash2.includes(base2.slice(hashPos)) ? base2.slice(hashPos).length : 1;
let pathFromHash = hash2.slice(slicePos);
if (pathFromHash[0] !== "/")
pathFromHash = "/" + pathFromHash;
return stripBase(pathFromHash, "");
}
const path = stripBase(pathname, base2);
return path + search + hash2;
}
function useHistoryListeners(base2, historyState, currentLocation, replace) {
let listeners = [];
let teardowns = [];
let pauseState = null;
const popStateHandler = ({ state }) => {
const to2 = createCurrentLocation(base2, location);
const from = currentLocation.value;
const fromState = historyState.value;
let delta = 0;
if (state) {
currentLocation.value = to2;
historyState.value = state;
if (pauseState && pauseState === from) {
pauseState = null;
return;
}
delta = fromState ? state.position - fromState.position : 0;
} else {
replace(to2);
}
listeners.forEach((listener) => {
listener(currentLocation.value, from, {
delta,
type: NavigationType.pop,
direction: delta ? delta > 0 ? NavigationDirection.forward : NavigationDirection.back : NavigationDirection.unknown
});
});
};
function pauseListeners() {
pauseState = currentLocation.value;
}
function listen2(callback) {
listeners.push(callback);
const teardown = () => {
const index2 = listeners.indexOf(callback);
if (index2 > -1)
listeners.splice(index2, 1);
};
teardowns.push(teardown);
return teardown;
}
function beforeUnloadListener() {
const { history: history2 } = window;
if (!history2.state)
return;
history2.replaceState(assign({}, history2.state, { scroll: computeScrollPosition() }), "");
}
function destroy() {
for (const teardown of teardowns)
teardown();
teardowns = [];
window.removeEventListener("popstate", popStateHandler);
window.removeEventListener("beforeunload", beforeUnloadListener);
}
window.addEventListener("popstate", popStateHandler);
window.addEventListener("beforeunload", beforeUnloadListener);
return {
pauseListeners,
listen: listen2,
destroy
};
}
function buildState(back, current, forward, replaced = false, computeScroll = false) {
return {
back,
current,
forward,
replaced,
position: window.history.length,
scroll: computeScroll ? computeScrollPosition() : null
};
}
function useHistoryStateNavigation(base2) {
const { history: history2, location: location2 } = window;
const currentLocation = {
value: createCurrentLocation(base2, location2)
};
const historyState = { value: history2.state };
if (!historyState.value) {
changeLocation(currentLocation.value, {
back: null,
current: currentLocation.value,
forward: null,
// the length is off by one, we need to decrease it
position: history2.length - 1,
replaced: true,
// don't add a scroll as the user may have an anchor, and we want
// scrollBehavior to be triggered without a saved position
scroll: null
}, true);
}
function changeLocation(to2, state, replace2) {
const hashIndex = base2.indexOf("#");
const url = hashIndex > -1 ? (location2.host && document.querySelector("base") ? base2 : base2.slice(hashIndex)) + to2 : createBaseLocation() + base2 + to2;
try {
history2[replace2 ? "replaceState" : "pushState"](state, "", url);
historyState.value = state;
} catch (err) {
{
warn("Error with push/replace State", err);
}
location2[replace2 ? "replace" : "assign"](url);
}
}
function replace(to2, data) {
const state = assign({}, history2.state, buildState(
historyState.value.back,
// keep back and forward entries but override current position
to2,
historyState.value.forward,
true
), data, { position: historyState.value.position });
changeLocation(to2, state, true);
currentLocation.value = to2;
}
function push(to2, data) {
const currentState = assign(
{},
// use current history state to gracefully handle a wrong call to
// history.replaceState
// https://github.com/vuejs/router/issues/366
historyState.value,
history2.state,
{
forward: to2,
scroll: computeScrollPosition()
}
);
if (!history2.state) {
warn(`history.state seems to have been manually replaced without preserving the necessary values. Make sure to preserve existing history state if you are manually calling history.replaceState:
history.replaceState(history.state, '', url)
You can find more information at https://next.router.vuejs.org/guide/migration/#usage-of-history-state.`);
}
changeLocation(currentState.current, currentState, true);
const state = assign({}, buildState(currentLocation.value, to2, null), { position: currentState.position + 1 }, data);
changeLocation(to2, state, false);
currentLocation.value = to2;
}
return {
location: currentLocation,
state: historyState,
push,
replace
};
}
function createWebHistory(base2) {
base2 = normalizeBase(base2);
const historyNavigation = useHistoryStateNavigation(base2);
const historyListeners = useHistoryListeners(base2, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
function go2(delta, triggerListeners = true) {
if (!triggerListeners)
historyListeners.pauseListeners();
history.go(delta);
}
const routerHistory = assign({
// it's overridden right after
location: "",
base: base2,
go: go2,
createHref: createHref.bind(null, base2)
}, historyNavigation, historyListeners);
Object.defineProperty(routerHistory, "location", {
enumerable: true,
get: () => historyNavigation.location.value
});
Object.defineProperty(routerHistory, "state", {
enumerable: true,
get: () => historyNavigation.state.value
});
return routerHistory;
}
function createWebHashHistory(base2) {
base2 = location.host ? base2 || location.pathname + location.search : "";
if (!base2.includes("#"))
base2 += "#";
if (!base2.endsWith("#/") && !base2.endsWith("#")) {
warn(`A hash base must end with a "#":
"${base2}" should be "${base2.replace(/#.*$/, "#")}".`);
}
return createWebHistory(base2);
}
function isRouteLocation(route) {
return typeof route === "string" || route && typeof route === "object";
}
function isRouteName(name) {
return typeof name === "string" || typeof name === "symbol";
}
const START_LOCATION_NORMALIZED = {
path: "/",
name: void 0,
params: {},
query: {},
hash: "",
fullPath: "/",
matched: [],
meta: {},
redirectedFrom: void 0
};
const NavigationFailureSymbol = Symbol("navigation failure");
var NavigationFailureType;
(function(NavigationFailureType2) {
NavigationFailureType2[NavigationFailureType2["aborted"] = 4] = "aborted";
NavigationFailureType2[NavigationFailureType2["cancelled"] = 8] = "cancelled";
NavigationFailureType2[NavigationFailureType2["duplicated"] = 16] = "duplicated";
})(NavigationFailureType || (NavigationFailureType = {}));
const ErrorTypeMessages = {
[
1
/* ErrorTypes.MATCHER_NOT_FOUND */
]({ location: location2, currentLocation }) {
return `No match for
${JSON.stringify(location2)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
},
[
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
]({ from, to: to2 }) {
return `Redirected from "${from.fullPath}" to "${stringifyRoute(to2)}" via a navigation guard.`;
},
[
4
/* ErrorTypes.NAVIGATION_ABORTED */
]({ from, to: to2 }) {
return `Navigation aborted from "${from.fullPath}" to "${to2.fullPath}" via a navigation guard.`;
},
[
8
/* ErrorTypes.NAVIGATION_CANCELLED */
]({ from, to: to2 }) {
return `Navigation cancelled from "${from.fullPath}" to "${to2.fullPath}" with a new navigation.`;
},
[
16
/* ErrorTypes.NAVIGATION_DUPLICATED */
]({ from, to: to2 }) {
return `Avoided redundant navigation to current location: "${from.fullPath}".`;
}
};
function createRouterError(type, params) {
{
return assign(new Error(ErrorTypeMessages[type](params)), {
type,
[NavigationFailureSymbol]: true
}, params);
}
}
function isNavigationFailure(error, type) {
return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
}
const propertiesToLog = ["params", "query", "hash"];
function stringifyRoute(to2) {
if (typeof to2 === "string")
return to2;
if ("path" in to2)
return to2.path;
const location2 = {};
for (const key of propertiesToLog) {
if (key in to2)
location2[key] = to2[key];
}
return JSON.stringify(location2, null, 2);
}
const BASE_PARAM_PATTERN = "[^/]+?";
const BASE_PATH_PARSER_OPTIONS = {
sensitive: false,
strict: false,
start: true,
end: true
};
const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
function tokensToParser(segments, extraOptions) {
const options = assign({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
const score = [];
let pattern = options.start ? "^" : "";
const keys = [];
for (const segment of segments) {
const segmentScores = segment.length ? [] : [
90
/* PathScore.Root */
];
if (options.strict && !segment.length)
pattern += "/";
for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
const token = segment[tokenIndex];
let subSegmentScore = 40 + (options.sensitive ? 0.25 : 0);
if (token.type === 0) {
if (!tokenIndex)
pattern += "/";
pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
subSegmentScore += 40;
} else if (token.type === 1) {
const { value, repeatable, optional, regexp } = token;
keys.push({
name: value,
repeatable,
optional
});
const re3 = regexp ? regexp : BASE_PARAM_PATTERN;
if (re3 !== BASE_PARAM_PATTERN) {
subSegmentScore += 10;
try {
new RegExp(`(${re3})`);
} catch (err) {
throw new Error(`Invalid custom RegExp for param "${value}" (${re3}): ` + err.message);
}
}
let subPattern = repeatable ? `((?:${re3})(?:/(?:${re3}))*)` : `(${re3})`;
if (!tokenIndex)
subPattern = // avoid an optional / if there are more segments e.g. /:p?-static
// or /:p?-:p2
optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
if (optional)
subPattern += "?";
pattern += subPattern;
subSegmentScore += 20;
if (optional)
subSegmentScore += -8;
if (repeatable)
subSegmentScore += -20;
if (re3 === ".*")
subSegmentScore += -50;
}
segmentScores.push(subSegmentScore);
}
score.push(segmentScores);
}
if (options.strict && options.end) {
const i2 = score.length - 1;
score[i2][score[i2].length - 1] += 0.7000000000000001;
}
if (!options.strict)
pattern += "/?";
if (options.end)
pattern += "$";
else if (options.strict)
pattern += "(?:/|$)";
const re2 = new RegExp(pattern, options.sensitive ? "" : "i");
function parse2(path) {
const match = path.match(re2);
const params = {};
if (!match)
return null;
for (let i2 = 1; i2 < match.length; i2++) {
const value = match[i2] || "";
const key = keys[i2 - 1];
params[key.name] = value && key.repeatable ? value.split("/") : value;
}
return params;
}
function stringify(params) {
let path = "";
let avoidDuplicatedSlash = false;
for (const segment of segments) {
if (!avoidDuplicatedSlash || !path.endsWith("/"))
path += "/";
avoidDuplicatedSlash = false;
for (const token of segment) {
if (token.type === 0) {
path += token.value;
} else if (token.type === 1) {
const { value, repeatable, optional } = token;
const param = value in params ? params[value] : "";
if (isArray(param) && !repeatable) {
throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
}
const text2 = isArray(param) ? param.join("/") : param;
if (!text2) {
if (optional) {
if (segment.length < 2) {
if (path.endsWith("/"))
path = path.slice(0, -1);
else
avoidDuplicatedSlash = true;
}
} else
throw new Error(`Missing required param "${value}"`);
}
path += text2;
}
}
}
return path || "/";
}
return {
re: re2,
score,
keys,
parse: parse2,
stringify
};
}
function compareScoreArray(a2, b3) {
let i2 = 0;
while (i2 < a2.length && i2 < b3.length) {
const diff = b3[i2] - a2[i2];
if (diff)
return diff;
i2++;
}
if (a2.length < b3.length) {
return a2.length === 1 && a2[0] === 40 + 40 ? -1 : 1;
} else if (a2.length > b3.length) {
return b3.length === 1 && b3[0] === 40 + 40 ? 1 : -1;
}
return 0;
}
function comparePathParserScore(a2, b3) {
let i2 = 0;
const aScore = a2.score;
const bScore = b3.score;
while (i2 < aScore.length && i2 < bScore.length) {
const comp = compareScoreArray(aScore[i2], bScore[i2]);
if (comp)
return comp;
i2++;
}
if (Math.abs(bScore.length - aScore.length) === 1) {
if (isLastScoreNegative(aScore))
return 1;
if (isLastScoreNegative(bScore))
return -1;
}
return bScore.length - aScore.length;
}
function isLastScoreNegative(score) {
const last = score[score.length - 1];
return score.length > 0 && last[last.length - 1] < 0;
}
const ROOT_TOKEN = {
type: 0,
value: ""
};
const VALID_PARAM_RE = /[a-zA-Z0-9_]/;
function tokenizePath(path) {
if (!path)
return [[]];
if (path === "/")
return [[ROOT_TOKEN]];
if (!path.startsWith("/")) {
throw new Error(
`Route paths should start with a "/": "${path}" should be "/${path}".`
);
}
function crash(message) {
throw new Error(`ERR (${state})/"${buffer2}": ${message}`);
}
let state = 0;
let previousState = state;
const tokens = [];
let segment;
function finalizeSegment() {
if (segment)
tokens.push(segment);
segment = [];
}
let i2 = 0;
let char;
let buffer2 = "";
let customRe = "";
function consumeBuffer() {
if (!buffer2)
return;
if (state === 0) {
segment.push({
type: 0,
value: buffer2
});
} else if (state === 1 || state === 2 || state === 3) {
if (segment.length > 1 && (char === "*" || char === "+"))
crash(`A repeatable param (${buffer2}) must be alone in its segment. eg: '/:ids+.`);
segment.push({
type: 1,
value: buffer2,
regexp: customRe,
repeatable: char === "*" || char === "+",
optional: char === "*" || char === "?"
});
} else {
crash("Invalid state to consume buffer");
}
buffer2 = "";
}
function addCharToBuffer() {
buffer2 += char;
}
while (i2 < path.length) {
char = path[i2++];
if (char === "\\" && state !== 2) {
previousState = state;
state = 4;
continue;
}
switch (state) {
case 0:
if (char === "/") {
if (buffer2) {
consumeBuffer();
}
finalizeSegment();
} else if (char === ":") {
consumeBuffer();
state = 1;
} else {
addCharToBuffer();
}
break;
case 4:
addCharToBuffer();
state = previousState;
break;
case 1:
if (char === "(") {
state = 2;
} else if (VALID_PARAM_RE.test(char)) {
addCharToBuffer();
} else {
consumeBuffer();
state = 0;
if (char !== "*" && char !== "?" && char !== "+")
i2--;
}
break;
case 2:
if (char === ")") {
if (customRe[customRe.length - 1] == "\\")
customRe = customRe.slice(0, -1) + char;
else
state = 3;
} else {
customRe += char;
}
break;
case 3:
consumeBuffer();
state = 0;
if (char !== "*" && char !== "?" && char !== "+")
i2--;
customRe = "";
break;
default:
crash("Unknown state");
break;
}
}
if (state === 2)
crash(`Unfinished custom RegExp for param "${buffer2}"`);
consumeBuffer();
finalizeSegment();
return tokens;
}
function createRouteRecordMatcher(record, parent, options) {
const parser = tokensToParser(tokenizePath(record.path), options);
{
const existingKeys = /* @__PURE__ */ new Set();
for (const key of parser.keys) {
if (existingKeys.has(key.name))
warn(`Found duplicated params with name "${key.name}" for path "${record.path}". Only the last one will be available on "$route.params".`);
existingKeys.add(key.name);
}
}
const matcher = assign(parser, {
record,
parent,
// these needs to be populated by the parent
children: [],
alias: []
});
if (parent) {
if (!matcher.record.aliasOf === !parent.record.aliasOf)
parent.children.push(matcher);
}
return matcher;
}
function createRouterMatcher(routes, globalOptions) {
const matchers = [];
const matcherMap = /* @__PURE__ */ new Map();
globalOptions = mergeOptions({ strict: false, end: true, sensitive: false }, globalOptions);
function getRecordMatcher(name) {
return matcherMap.get(name);
}
function addRoute(record, parent, originalRecord) {
const isRootAdd = !originalRecord;
const mainNormalizedRecord = normalizeRouteRecord(record);
{
checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent);
}
mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
const options = mergeOptions(globalOptions, record);
const normalizedRecords = [
mainNormalizedRecord
];
if ("alias" in record) {
const aliases = typeof record.alias === "string" ? [record.alias] : record.alias;
for (const alias of aliases) {
normalizedRecords.push(assign({}, mainNormalizedRecord, {
// this allows us to hold a copy of the `components` option
// so that async components cache is hold on the original record
components: originalRecord ? originalRecord.record.components : mainNormalizedRecord.components,
path: alias,
// we might be the child of an alias
aliasOf: originalRecord ? originalRecord.record : mainNormalizedRecord
// the aliases are always of the same kind as the original since they
// are defined on the same record
}));
}
}
let matcher;
let originalMatcher;
for (const normalizedRecord of normalizedRecords) {
const { path } = normalizedRecord;
if (parent && path[0] !== "/") {
const parentPath = parent.record.path;
const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
normalizedRecord.path = parent.record.path + (path && connectingSlash + path);
}
if (normalizedRecord.path === "*") {
throw new Error('Catch all routes ("*") must now be defined using a param with a custom regexp.\nSee more at https://next.router.vuejs.org/guide/migration/#removed-star-or-catch-all-routes.');
}
matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
if (parent && path[0] === "/")
checkMissingParamsInAbsolutePath(matcher, parent);
if (originalRecord) {
originalRecord.alias.push(matcher);
{
checkSameParams(originalRecord, matcher);
}
} else {
originalMatcher = originalMatcher || matcher;
if (originalMatcher !== matcher)
originalMatcher.alias.push(matcher);
if (isRootAdd && record.name && !isAliasRecord(matcher))
removeRoute(record.name);
}
if (mainNormalizedRecord.children) {
const children2 = mainNormalizedRecord.children;
for (let i2 = 0; i2 < children2.length; i2++) {
addRoute(children2[i2], matcher, originalRecord && originalRecord.children[i2]);
}
}
originalRecord = originalRecord || matcher;
if (matcher.record.components && Object.keys(matcher.record.components).length || matcher.record.name || matcher.record.redirect) {
insertMatcher(matcher);
}
}
return originalMatcher ? () => {
removeRoute(originalMatcher);
} : noop;
}
function removeRoute(matcherRef) {
if (isRouteName(matcherRef)) {
const matcher = matcherMap.get(matcherRef);
if (matcher) {
matcherMap.delete(matcherRef);
matchers.splice(matchers.indexOf(matcher), 1);
matcher.children.forEach(removeRoute);
matcher.alias.forEach(removeRoute);
}
} else {
const index2 = matchers.indexOf(matcherRef);
if (index2 > -1) {
matchers.splice(index2, 1);
if (matcherRef.record.name)
matcherMap.delete(matcherRef.record.name);
matcherRef.children.forEach(removeRoute);
matcherRef.alias.forEach(removeRoute);
}
}
}
function getRoutes() {
return matchers;
}
function insertMatcher(matcher) {
let i2 = 0;
while (i2 < matchers.length && comparePathParserScore(matcher, matchers[i2]) >= 0 && // Adding children with empty path should still appear before the parent
// https://github.com/vuejs/router/issues/1124
(matcher.record.path !== matchers[i2].record.path || !isRecordChildOf(matcher, matchers[i2])))
i2++;
matchers.splice(i2, 0, matcher);
if (matcher.record.name && !isAliasRecord(matcher))
matcherMap.set(matcher.record.name, matcher);
}
function resolve2(location2, currentLocation) {
let matcher;
let params = {};
let path;
let name;
if ("name" in location2 && location2.name) {
matcher = matcherMap.get(location2.name);
if (!matcher)
throw createRouterError(1, {
location: location2
});
{
const invalidParams = Object.keys(location2.params || {}).filter((paramName) => !matcher.keys.find((k2) => k2.name === paramName));
if (invalidParams.length) {
warn(`Discarded invalid param(s) "${invalidParams.join('", "')}" when navigating. See https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md#414-2022-08-22 for more details.`);
}
}
name = matcher.record.name;
params = assign(
// paramsFromLocation is a new object
paramsFromLocation(
currentLocation.params,
// only keep params that exist in the resolved location
// TODO: only keep optional params coming from a parent record
matcher.keys.filter((k2) => !k2.optional).map((k2) => k2.name)
),
// discard any existing params in the current location that do not exist here
// #1497 this ensures better active/exact matching
location2.params && paramsFromLocation(location2.params, matcher.keys.map((k2) => k2.name))
);
path = matcher.stringify(params);
} else if ("path" in location2) {
path = location2.path;
if (!path.startsWith("/")) {
warn(`The Matcher cannot resolve relative paths but received "${path}". Unless you directly called \`matcher.resolve("${path}")\`, this is probably a bug in vue-router. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/router.`);
}
matcher = matchers.find((m2) => m2.re.test(path));
if (matcher) {
params = matcher.parse(path);
name = matcher.record.name;
}
} else {
matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m2) => m2.re.test(currentLocation.path));
if (!matcher)
throw createRouterError(1, {
location: location2,
currentLocation
});
name = matcher.record.name;
params = assign({}, currentLocation.params, location2.params);
path = matcher.stringify(params);
}
const matched = [];
let parentMatcher = matcher;
while (parentMatcher) {
matched.unshift(parentMatcher.record);
parentMatcher = parentMatcher.parent;
}
return {
name,
path,
params,
matched,
meta: mergeMetaFields(matched)
};
}
routes.forEach((route) => addRoute(route));
return { addRoute, resolve: resolve2, removeRoute, getRoutes, getRecordMatcher };
}
function paramsFromLocation(params, keys) {
const newParams = {};
for (const key of keys) {
if (key in params)
newParams[key] = params[key];
}
return newParams;
}
function normalizeRouteRecord(record) {
return {
path: record.path,
redirect: record.redirect,
name: record.name,
meta: record.meta || {},
aliasOf: void 0,
beforeEnter: record.beforeEnter,
props: normalizeRecordProps(record),
children: record.children || [],
instances: {},
leaveGuards: /* @__PURE__ */ new Set(),
updateGuards: /* @__PURE__ */ new Set(),
enterCallbacks: {},
components: "components" in record ? record.components || null : record.component && { default: record.component }
};
}
function normalizeRecordProps(record) {
const propsObject = {};
const props = record.props || false;
if ("component" in record) {
propsObject.default = props;
} else {
for (const name in record.components)
propsObject[name] = typeof props === "boolean" ? props : props[name];
}
return propsObject;
}
function isAliasRecord(record) {
while (record) {
if (record.record.aliasOf)
return true;
record = record.parent;
}
return false;
}
function mergeMetaFields(matched) {
return matched.reduce((meta, record) => assign(meta, record.meta), {});
}
function mergeOptions(defaults2, partialOptions) {
const options = {};
for (const key in defaults2) {
options[key] = key in partialOptions ? partialOptions[key] : defaults2[key];
}
return options;
}
function isSameParam(a2, b3) {
return a2.name === b3.name && a2.optional === b3.optional && a2.repeatable === b3.repeatable;
}
function checkSameParams(a2, b3) {
for (const key of a2.keys) {
if (!key.optional && !b3.keys.find(isSameParam.bind(null, key)))
return warn(`Alias "${b3.record.path}" and the original record: "${a2.record.path}" must have the exact same param named "${key.name}"`);
}
for (const key of b3.keys) {
if (!key.optional && !a2.keys.find(isSameParam.bind(null, key)))
return warn(`Alias "${b3.record.path}" and the original record: "${a2.record.path}" must have the exact same param named "${key.name}"`);
}
}
function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
if (parent && parent.record.name && !mainNormalizedRecord.name && !mainNormalizedRecord.path) {
warn(`The route named "${String(parent.record.name)}" has a child without a name and an empty path. Using that name won't render the empty path child so you probably want to move the name to the child instead. If this is intentional, add a name to the child route to remove the warning.`);
}
}
function checkMissingParamsInAbsolutePath(record, parent) {
for (const key of parent.keys) {
if (!record.keys.find(isSameParam.bind(null, key)))
return warn(`Absolute path "${record.record.path}" must have the exact same param named "${key.name}" as its parent "${parent.record.path}".`);
}
}
function isRecordChildOf(record, parent) {
return parent.children.some((child) => child === record || isRecordChildOf(record, child));
}
const HASH_RE = /#/g;
const AMPERSAND_RE = /&/g;
const SLASH_RE = /\//g;
const EQUAL_RE = /=/g;
const IM_RE = /\?/g;
const PLUS_RE = /\+/g;
const ENC_BRACKET_OPEN_RE = /%5B/g;
const ENC_BRACKET_CLOSE_RE = /%5D/g;
const ENC_CARET_RE = /%5E/g;
const ENC_BACKTICK_RE = /%60/g;
const ENC_CURLY_OPEN_RE = /%7B/g;
const ENC_PIPE_RE = /%7C/g;
const ENC_CURLY_CLOSE_RE = /%7D/g;
const ENC_SPACE_RE = /%20/g;
function commonEncode(text2) {
return encodeURI("" + text2).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
}
function encodeHash(text2) {
return commonEncode(text2).replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
}
function encodeQueryValue(text2) {
return commonEncode(text2).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
}
function encodeQueryKey(text2) {
return encodeQueryValue(text2).replace(EQUAL_RE, "%3D");
}
function encodePath(text2) {
return commonEncode(text2).replace(HASH_RE, "%23").replace(IM_RE, "%3F");
}
function encodeParam(text2) {
return text2 == null ? "" : encodePath(text2).replace(SLASH_RE, "%2F");
}
function decode(text2) {
try {
return decodeURIComponent("" + text2);
} catch (err) {
warn(`Error decoding "${text2}". Using original value`);
}
return "" + text2;
}
function parseQuery(search) {
const query = {};
if (search === "" || search === "?")
return query;
const hasLeadingIM = search[0] === "?";
const searchParams = (hasLeadingIM ? search.slice(1) : search).split("&");
for (let i2 = 0; i2 < searchParams.length; ++i2) {
const searchParam = searchParams[i2].replace(PLUS_RE, " ");
const eqPos = searchParam.indexOf("=");
const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
if (key in query) {
let currentValue = query[key];
if (!isArray(currentValue)) {
currentValue = query[key] = [currentValue];
}
currentValue.push(value);
} else {
query[key] = value;
}
}
return query;
}
function stringifyQuery(query) {
let search = "";
for (let key in query) {
const value = query[key];
key = encodeQueryKey(key);
if (value == null) {
if (value !== void 0) {
search += (search.length ? "&" : "") + key;
}
continue;
}
const values = isArray(value) ? value.map((v2) => v2 && encodeQueryValue(v2)) : [value && encodeQueryValue(value)];
values.forEach((value2) => {
if (value2 !== void 0) {
search += (search.length ? "&" : "") + key;
if (value2 != null)
search += "=" + value2;
}
});
}
return search;
}
function normalizeQuery(query) {
const normalizedQuery = {};
for (const key in query) {
const value = query[key];
if (value !== void 0) {
normalizedQuery[key] = isArray(value) ? value.map((v2) => v2 == null ? null : "" + v2) : value == null ? value : "" + value;
}
}
return normalizedQuery;
}
const matchedRouteKey = Symbol("router view location matched");
const viewDepthKey = Symbol("router view depth");
const routerKey = Symbol("router");
const routeLocationKey = Symbol("route location");
const routerViewLocationKey = Symbol("router view location");
function useCallbacks() {
let handlers2 = [];
function add2(handler) {
handlers2.push(handler);
return () => {
const i2 = handlers2.indexOf(handler);
if (i2 > -1)
handlers2.splice(i2, 1);
};
}
function reset() {
handlers2 = [];
}
return {
add: add2,
list: () => handlers2,
reset
};
}
function guardToPromiseFn(guard, to2, from, record, name) {
const enterCallbackArray = record && // name is defined if record is because of the function overload
(record.enterCallbacks[name] = record.enterCallbacks[name] || []);
return () => new Promise((resolve2, reject) => {
const next = (valid) => {
if (valid === false) {
reject(createRouterError(4, {
from,
to: to2
}));
} else if (valid instanceof Error) {
reject(valid);
} else if (isRouteLocation(valid)) {
reject(createRouterError(2, {
from: to2,
to: valid
}));
} else {
if (enterCallbackArray && // since enterCallbackArray is truthy, both record and name also are
record.enterCallbacks[name] === enterCallbackArray && typeof valid === "function") {
enterCallbackArray.push(valid);
}
resolve2();
}
};
const guardReturn = guard.call(record && record.instances[name], to2, from, canOnlyBeCalledOnce(next, to2, from));
let guardCall = Promise.resolve(guardReturn);
if (guard.length < 3)
guardCall = guardCall.then(next);
if (guard.length > 2) {
const message = `The "next" callback was never called inside of ${guard.name ? '"' + guard.name + '"' : ""}:
${guard.toString()}
. If you are returning a value instead of calling "next", make sure to remove the "next" parameter from your function.`;
if (typeof guardReturn === "object" && "then" in guardReturn) {
guardCall = guardCall.then((resolvedValue) => {
if (!next._called) {
warn(message);
return Promise.reject(new Error("Invalid navigation guard"));
}
return resolvedValue;
});
} else if (guardReturn !== void 0) {
if (!next._called) {
warn(message);
reject(new Error("Invalid navigation guard"));
return;
}
}
}
guardCall.catch((err) => reject(err));
});
}
function canOnlyBeCalledOnce(next, to2, from) {
let called = 0;
return function() {
if (called++ === 1)
warn(`The "next" callback was called more than once in one navigation guard when going from "${from.fullPath}" to "${to2.fullPath}". It should be called exactly one time in each navigation guard. This will fail in production.`);
next._called = true;
if (called === 1)
next.apply(null, arguments);
};
}
function extractComponentsGuards(matched, guardType, to2, from) {
const guards = [];
for (const record of matched) {
if (!record.components && !record.children.length) {
warn(`Record with path "${record.path}" is either missing a "component(s)" or "children" property.`);
}
for (const name in record.components) {
let rawComponent = record.components[name];
{
if (!rawComponent || typeof rawComponent !== "object" && typeof rawComponent !== "function") {
warn(`Component "${name}" in record with path "${record.path}" is not a valid component. Received "${String(rawComponent)}".`);
throw new Error("Invalid route component");
} else if ("then" in rawComponent) {
warn(`Component "${name}" in record with path "${record.path}" is a Promise instead of a function that returns a Promise. Did you write "import('./MyPage.vue')" instead of "() => import('./MyPage.vue')" ? This will break in production if not fixed.`);
const promise = rawComponent;
rawComponent = () => promise;
} else if (rawComponent.__asyncLoader && // warn only once per component
!rawComponent.__warnedDefineAsync) {
rawComponent.__warnedDefineAsync = true;
warn(`Component "${name}" in record with path "${record.path}" is defined using "defineAsyncComponent()". Write "() => import('./MyPage.vue')" instead of "defineAsyncComponent(() => import('./MyPage.vue'))".`);
}
}
if (guardType !== "beforeRouteEnter" && !record.instances[name])
continue;
if (isRouteComponent(rawComponent)) {
const options = rawComponent.__vccOpts || rawComponent;
const guard = options[guardType];
guard && guards.push(guardToPromiseFn(guard, to2, from, record, name));
} else {
let componentPromise = rawComponent();
if (!("catch" in componentPromise)) {
warn(`Component "${name}" in record with path "${record.path}" is a function that does not return a Promise. If you were passing a functional component, make sure to add a "displayName" to the component. This will break in production if not fixed.`);
componentPromise = Promise.resolve(componentPromise);
}
guards.push(() => componentPromise.then((resolved) => {
if (!resolved)
return Promise.reject(new Error(`Couldn't resolve component "${name}" at "${record.path}"`));
const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
record.components[name] = resolvedComponent;
const options = resolvedComponent.__vccOpts || resolvedComponent;
const guard = options[guardType];
return guard && guardToPromiseFn(guard, to2, from, record, name)();
}));
}
}
}
return guards;
}
function isRouteComponent(component) {
return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
}
function useLink(props) {
const router = inject(routerKey);
const currentRoute = inject(routeLocationKey);
const route = computed(() => router.resolve(unref(props.to)));
const activeRecordIndex = computed(() => {
const { matched } = route.value;
const { length } = matched;
const routeMatched = matched[length - 1];
const currentMatched = currentRoute.matched;
if (!routeMatched || !currentMatched.length)
return -1;
const index2 = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
if (index2 > -1)
return index2;
const parentRecordPath = getOriginalPath(matched[length - 2]);
return (
// we are dealing with nested routes
length > 1 && // if the parent and matched route have the same path, this link is
// referring to the empty child. Or we currently are on a different
// child of the same parent
getOriginalPath(routeMatched) === parentRecordPath && // avoid comparing the child with its parent
currentMatched[currentMatched.length - 1].path !== parentRecordPath ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2])) : index2
);
});
const isActive = computed(() => activeRecordIndex.value > -1 && includesParams(currentRoute.params, route.value.params));
const isExactActive = computed(() => activeRecordIndex.value > -1 && activeRecordIndex.value === currentRoute.matched.length - 1 && isSameRouteLocationParams(currentRoute.params, route.value.params));
function navigate(e2 = {}) {
if (guardEvent(e2)) {
return router[unref(props.replace) ? "replace" : "push"](
unref(props.to)
// avoid uncaught errors are they are logged anyway
).catch(noop);
}
return Promise.resolve();
}
if (isBrowser) {
const instance = getCurrentInstance();
if (instance) {
const linkContextDevtools = {
route: route.value,
isActive: isActive.value,
isExactActive: isExactActive.value
};
instance.__vrl_devtools = instance.__vrl_devtools || [];
instance.__vrl_devtools.push(linkContextDevtools);
watchEffect(() => {
linkContextDevtools.route = route.value;
linkContextDevtools.isActive = isActive.value;
linkContextDevtools.isExactActive = isExactActive.value;
}, { flush: "post" });
}
}
return {
route,
href: computed(() => route.value.href),
isActive,
isExactActive,
navigate
};
}
const RouterLinkImpl = /* @__PURE__ */ defineComponent({
name: "RouterLink",
compatConfig: { MODE: 3 },
props: {
to: {
type: [String, Object],
required: true
},
replace: Boolean,
activeClass: String,
// inactiveClass: String,
exactActiveClass: String,
custom: Boolean,
ariaCurrentValue: {
type: String,
default: "page"
}
},
useLink,
setup(props, { slots }) {
const link = reactive(useLink(props));
const { options } = inject(routerKey);
const elClass = computed(() => ({
[getLinkClass(props.activeClass, options.linkActiveClass, "router-link-active")]: link.isActive,
// [getLinkClass(
// props.inactiveClass,
// options.linkInactiveClass,
// 'router-link-inactive'
// )]: !link.isExactActive,
[getLinkClass(props.exactActiveClass, options.linkExactActiveClass, "router-link-exact-active")]: link.isExactActive
}));
return () => {
const children2 = slots.default && slots.default(link);
return props.custom ? children2 : h$1("a", {
"aria-current": link.isExactActive ? props.ariaCurrentValue : null,
href: link.href,
// this would override user added attrs but Vue will still add
// the listener, so we end up triggering both
onClick: link.navigate,
class: elClass.value
}, children2);
};
}
});
const RouterLink = RouterLinkImpl;
function guardEvent(e2) {
if (e2.metaKey || e2.altKey || e2.ctrlKey || e2.shiftKey)
return;
if (e2.defaultPrevented)
return;
if (e2.button !== void 0 && e2.button !== 0)
return;
if (e2.currentTarget && e2.currentTarget.getAttribute) {
const target = e2.currentTarget.getAttribute("target");
if (/\b_blank\b/i.test(target))
return;
}
if (e2.preventDefault)
e2.preventDefault();
return true;
}
function includesParams(outer, inner) {
for (const key in inner) {
const innerValue = inner[key];
const outerValue = outer[key];
if (typeof innerValue === "string") {
if (innerValue !== outerValue)
return false;
} else {
if (!isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i2) => value !== outerValue[i2]))
return false;
}
}
return true;
}
function getOriginalPath(record) {
return record ? record.aliasOf ? record.aliasOf.path : record.path : "";
}
const getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
const RouterViewImpl = /* @__PURE__ */ defineComponent({
name: "RouterView",
// #674 we manually inherit them
inheritAttrs: false,
props: {
name: {
type: String,
default: "default"
},
route: Object
},
// Better compat for @vue/compat users
// https://github.com/vuejs/router/issues/1315
compatConfig: { MODE: 3 },
setup(props, { attrs, slots }) {
warnDeprecatedUsage();
const injectedRoute = inject(routerViewLocationKey);
const routeToDisplay = computed(() => props.route || injectedRoute.value);
const injectedDepth = inject(viewDepthKey, 0);
const depth = computed(() => {
let initialDepth = unref(injectedDepth);
const { matched } = routeToDisplay.value;
let matchedRoute;
while ((matchedRoute = matched[initialDepth]) && !matchedRoute.components) {
initialDepth++;
}
return initialDepth;
});
const matchedRouteRef = computed(() => routeToDisplay.value.matched[depth.value]);
provide(viewDepthKey, computed(() => depth.value + 1));
provide(matchedRouteKey, matchedRouteRef);
provide(routerViewLocationKey, routeToDisplay);
const viewRef = ref();
watch(() => [viewRef.value, matchedRouteRef.value, props.name], ([instance, to2, name], [oldInstance, from, oldName]) => {
if (to2) {
to2.instances[name] = instance;
if (from && from !== to2 && instance && instance === oldInstance) {
if (!to2.leaveGuards.size) {
to2.leaveGuards = from.leaveGuards;
}
if (!to2.updateGuards.size) {
to2.updateGuards = from.updateGuards;
}
}
}
if (instance && to2 && // if there is no instance but to and from are the same this might be
// the first visit
(!from || !isSameRouteRecord(to2, from) || !oldInstance)) {
(to2.enterCallbacks[name] || []).forEach((callback) => callback(instance));
}
}, { flush: "post" });
return () => {
const route = routeToDisplay.value;
const currentName = props.name;
const matchedRoute = matchedRouteRef.value;
const ViewComponent = matchedRoute && matchedRoute.components[currentName];
if (!ViewComponent) {
return normalizeSlot(slots.default, { Component: ViewComponent, route });
}
const routePropsOption = matchedRoute.props[currentName];
const routeProps = routePropsOption ? routePropsOption === true ? route.params : typeof routePropsOption === "function" ? routePropsOption(route) : routePropsOption : null;
const onVnodeUnmounted = (vnode) => {
if (vnode.component.isUnmounted) {
matchedRoute.instances[currentName] = null;
}
};
const component = h$1(ViewComponent, assign({}, routeProps, attrs, {
onVnodeUnmounted,
ref: viewRef
}));
if (isBrowser && component.ref) {
const info = {
depth: depth.value,
name: matchedRoute.name,
path: matchedRoute.path,
meta: matchedRoute.meta
};
const internalInstances = isArray(component.ref) ? component.ref.map((r2) => r2.i) : [component.ref.i];
internalInstances.forEach((instance) => {
instance.__vrv_devtools = info;
});
}
return (
// pass the vnode to the slot as a prop.
// h and <component :is="..."> both accept vnodes
normalizeSlot(slots.default, { Component: component, route }) || component
);
};
}
});
function normalizeSlot(slot, data) {
if (!slot)
return null;
const slotContent = slot(data);
return slotContent.length === 1 ? slotContent[0] : slotContent;
}
const RouterView = RouterViewImpl;
function warnDeprecatedUsage() {
const instance = getCurrentInstance();
const parentName = instance.parent && instance.parent.type.name;
if (parentName && (parentName === "KeepAlive" || parentName.includes("Transition"))) {
const comp = parentName === "KeepAlive" ? "keep-alive" : "transition";
warn(`<router-view> can no longer be used directly inside <transition> or <keep-alive>.
Use slot props instead:
<router-view v-slot="{ Component }">
<${comp}>
<component :is="Component" />
</${comp}>
</router-view>`);
}
}
function formatRouteLocation(routeLocation, tooltip) {
const copy = assign({}, routeLocation, {
// remove variables that can contain vue instances
matched: routeLocation.matched.map((matched) => omit$1(matched, ["instances", "children", "aliasOf"]))
});
return {
_custom: {
type: null,
readOnly: true,
display: routeLocation.fullPath,
tooltip,
value: copy
}
};
}
function formatDisplay(display) {
return {
_custom: {
display
}
};
}
let routerId = 0;
function addDevtools(app, router, matcher) {
if (router.__hasDevtools)
return;
router.__hasDevtools = true;
const id2 = routerId++;
setupDevtoolsPlugin({
id: "org.vuejs.router" + (id2 ? "." + id2 : ""),
label: "Vue Router",
packageName: "vue-router",
homepage: "https://router.vuejs.org",
logo: "https://router.vuejs.org/logo.png",
componentStateTypes: ["Routing"],
app
}, (api) => {
if (typeof api.now !== "function") {
console.warn("[Vue Router]: You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.");
}
api.on.inspectComponent((payload, ctx) => {
if (payload.instanceData) {
payload.instanceData.state.push({
type: "Routing",
key: "$route",
editable: false,
value: formatRouteLocation(router.currentRoute.value, "Current Route")
});
}
});
api.on.visitComponentTree(({ treeNode: node, componentInstance }) => {
if (componentInstance.__vrv_devtools) {
const info = componentInstance.__vrv_devtools;
node.tags.push({
label: (info.name ? `${info.name.toString()}: ` : "") + info.path,
textColor: 0,
tooltip: "This component is rendered by &lt;router-view&gt;",
backgroundColor: PINK_500
});
}
if (isArray(componentInstance.__vrl_devtools)) {
componentInstance.__devtoolsApi = api;
componentInstance.__vrl_devtools.forEach((devtoolsData) => {
let backgroundColor = ORANGE_400;
let tooltip = "";
if (devtoolsData.isExactActive) {
backgroundColor = LIME_500;
tooltip = "This is exactly active";
} else if (devtoolsData.isActive) {
backgroundColor = BLUE_600;
tooltip = "This link is active";
}
node.tags.push({
label: devtoolsData.route.path,
textColor: 0,
tooltip,
backgroundColor
});
});
}
});
watch(router.currentRoute, () => {
refreshRoutesView();
api.notifyComponentUpdate();
api.sendInspectorTree(routerInspectorId);
api.sendInspectorState(routerInspectorId);
});
const navigationsLayerId = "router:navigations:" + id2;
api.addTimelineLayer({
id: navigationsLayerId,
label: `Router${id2 ? " " + id2 : ""} Navigations`,
color: 4237508
});
router.onError((error, to2) => {
api.addTimelineEvent({
layerId: navigationsLayerId,
event: {
title: "Error during Navigation",
subtitle: to2.fullPath,
logType: "error",
time: api.now(),
data: { error },
groupId: to2.meta.__navigationId
}
});
});
let navigationId = 0;
router.beforeEach((to2, from) => {
const data = {
guard: formatDisplay("beforeEach"),
from: formatRouteLocation(from, "Current Location during this navigation"),
to: formatRouteLocation(to2, "Target location")
};
Object.defineProperty(to2.meta, "__navigationId", {
value: navigationId++
});
api.addTimelineEvent({
layerId: navigationsLayerId,
event: {
time: api.now(),
title: "Start of navigation",
subtitle: to2.fullPath,
data,
groupId: to2.meta.__navigationId
}
});
});
router.afterEach((to2, from, failure) => {
const data = {
guard: formatDisplay("afterEach")
};
if (failure) {
data.failure = {
_custom: {
type: Error,
readOnly: true,
display: failure ? failure.message : "",
tooltip: "Navigation Failure",
value: failure
}
};
data.status = formatDisplay("❌");
} else {
data.status = formatDisplay("✅");
}
data.from = formatRouteLocation(from, "Current Location during this navigation");
data.to = formatRouteLocation(to2, "Target location");
api.addTimelineEvent({
layerId: navigationsLayerId,
event: {
title: "End of navigation",
subtitle: to2.fullPath,
time: api.now(),
data,
logType: failure ? "warning" : "default",
groupId: to2.meta.__navigationId
}
});
});
const routerInspectorId = "router-inspector:" + id2;
api.addInspector({
id: routerInspectorId,
label: "Routes" + (id2 ? " " + id2 : ""),
icon: "book",
treeFilterPlaceholder: "Search routes"
});
function refreshRoutesView() {
if (!activeRoutesPayload)
return;
const payload = activeRoutesPayload;
let routes = matcher.getRoutes().filter((route) => !route.parent);
routes.forEach(resetMatchStateOnRouteRecord);
if (payload.filter) {
routes = routes.filter((route) => (
// save matches state based on the payload
isRouteMatching(route, payload.filter.toLowerCase())
));
}
routes.forEach((route) => markRouteRecordActive(route, router.currentRoute.value));
payload.rootNodes = routes.map(formatRouteRecordForInspector);
}
let activeRoutesPayload;
api.on.getInspectorTree((payload) => {
activeRoutesPayload = payload;
if (payload.app === app && payload.inspectorId === routerInspectorId) {
refreshRoutesView();
}
});
api.on.getInspectorState((payload) => {
if (payload.app === app && payload.inspectorId === routerInspectorId) {
const routes = matcher.getRoutes();
const route = routes.find((route2) => route2.record.__vd_id === payload.nodeId);
if (route) {
payload.state = {
options: formatRouteRecordMatcherForStateInspector(route)
};
}
}
});
api.sendInspectorTree(routerInspectorId);
api.sendInspectorState(routerInspectorId);
});
}
function modifierForKey(key) {
if (key.optional) {
return key.repeatable ? "*" : "?";
} else {
return key.repeatable ? "+" : "";
}
}
function formatRouteRecordMatcherForStateInspector(route) {
const { record } = route;
const fields = [
{ editable: false, key: "path", value: record.path }
];
if (record.name != null) {
fields.push({
editable: false,
key: "name",
value: record.name
});
}
fields.push({ editable: false, key: "regexp", value: route.re });
if (route.keys.length) {
fields.push({
editable: false,
key: "keys",
value: {
_custom: {
type: null,
readOnly: true,
display: route.keys.map((key) => `${key.name}${modifierForKey(key)}`).join(" "),
tooltip: "Param keys",
value: route.keys
}
}
});
}
if (record.redirect != null) {
fields.push({
editable: false,
key: "redirect",
value: record.redirect
});
}
if (route.alias.length) {
fields.push({
editable: false,
key: "aliases",
value: route.alias.map((alias) => alias.record.path)
});
}
if (Object.keys(route.record.meta).length) {
fields.push({
editable: false,
key: "meta",
value: route.record.meta
});
}
fields.push({
key: "score",
editable: false,
value: {
_custom: {
type: null,
readOnly: true,
display: route.score.map((score) => score.join(", ")).join(" | "),
tooltip: "Score used to sort routes",
value: route.score
}
}
});
return fields;
}
const PINK_500 = 15485081;
const BLUE_600 = 2450411;
const LIME_500 = 8702998;
const CYAN_400 = 2282478;
const ORANGE_400 = 16486972;
const DARK = 6710886;
function formatRouteRecordForInspector(route) {
const tags = [];
const { record } = route;
if (record.name != null) {
tags.push({
label: String(record.name),
textColor: 0,
backgroundColor: CYAN_400
});
}
if (record.aliasOf) {
tags.push({
label: "alias",
textColor: 0,
backgroundColor: ORANGE_400
});
}
if (route.__vd_match) {
tags.push({
label: "matches",
textColor: 0,
backgroundColor: PINK_500
});
}
if (route.__vd_exactActive) {
tags.push({
label: "exact",
textColor: 0,
backgroundColor: LIME_500
});
}
if (route.__vd_active) {
tags.push({
label: "active",
textColor: 0,
backgroundColor: BLUE_600
});
}
if (record.redirect) {
tags.push({
label: typeof record.redirect === "string" ? `redirect: ${record.redirect}` : "redirects",
textColor: 16777215,
backgroundColor: DARK
});
}
let id2 = record.__vd_id;
if (id2 == null) {
id2 = String(routeRecordId++);
record.__vd_id = id2;
}
return {
id: id2,
label: record.path,
tags,
children: route.children.map(formatRouteRecordForInspector)
};
}
let routeRecordId = 0;
const EXTRACT_REGEXP_RE = /^\/(.*)\/([a-z]*)$/;
function markRouteRecordActive(route, currentRoute) {
const isExactActive = currentRoute.matched.length && isSameRouteRecord(currentRoute.matched[currentRoute.matched.length - 1], route.record);
route.__vd_exactActive = route.__vd_active = isExactActive;
if (!isExactActive) {
route.__vd_active = currentRoute.matched.some((match) => isSameRouteRecord(match, route.record));
}
route.children.forEach((childRoute) => markRouteRecordActive(childRoute, currentRoute));
}
function resetMatchStateOnRouteRecord(route) {
route.__vd_match = false;
route.children.forEach(resetMatchStateOnRouteRecord);
}
function isRouteMatching(route, filter) {
const found = String(route.re).match(EXTRACT_REGEXP_RE);
route.__vd_match = false;
if (!found || found.length < 3) {
return false;
}
const nonEndingRE = new RegExp(found[1].replace(/\$$/, ""), found[2]);
if (nonEndingRE.test(filter)) {
route.children.forEach((child) => isRouteMatching(child, filter));
if (route.record.path !== "/" || filter === "/") {
route.__vd_match = route.re.test(filter);
return true;
}
return false;
}
const path = route.record.path.toLowerCase();
const decodedPath = decode(path);
if (!filter.startsWith("/") && (decodedPath.includes(filter) || path.includes(filter)))
return true;
if (decodedPath.startsWith(filter) || path.startsWith(filter))
return true;
if (route.record.name && String(route.record.name).includes(filter))
return true;
return route.children.some((child) => isRouteMatching(child, filter));
}
function omit$1(obj, keys) {
const ret = {};
for (const key in obj) {
if (!keys.includes(key)) {
ret[key] = obj[key];
}
}
return ret;
}
function createRouter(options) {
const matcher = createRouterMatcher(options.routes, options);
const parseQuery$1 = options.parseQuery || parseQuery;
const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
const routerHistory = options.history;
if (!routerHistory)
throw new Error('Provide the "history" option when calling "createRouter()": https://next.router.vuejs.org/api/#history.');
const beforeGuards = useCallbacks();
const beforeResolveGuards = useCallbacks();
const afterGuards = useCallbacks();
const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
let pendingLocation = START_LOCATION_NORMALIZED;
if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) {
history.scrollRestoration = "manual";
}
const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
const encodeParams = applyToParams.bind(null, encodeParam);
const decodeParams = (
// @ts-expect-error: intentionally avoid the type check
applyToParams.bind(null, decode)
);
function addRoute(parentOrRoute, route) {
let parent;
let record;
if (isRouteName(parentOrRoute)) {
parent = matcher.getRecordMatcher(parentOrRoute);
record = route;
} else {
record = parentOrRoute;
}
return matcher.addRoute(record, parent);
}
function removeRoute(name) {
const recordMatcher = matcher.getRecordMatcher(name);
if (recordMatcher) {
matcher.removeRoute(recordMatcher);
} else {
warn(`Cannot remove non-existent route "${String(name)}"`);
}
}
function getRoutes() {
return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
}
function hasRoute(name) {
return !!matcher.getRecordMatcher(name);
}
function resolve2(rawLocation, currentLocation) {
currentLocation = assign({}, currentLocation || currentRoute.value);
if (typeof rawLocation === "string") {
const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
const matchedRoute2 = matcher.resolve({ path: locationNormalized.path }, currentLocation);
const href2 = routerHistory.createHref(locationNormalized.fullPath);
{
if (href2.startsWith("//"))
warn(`Location "${rawLocation}" resolved to "${href2}". A resolved location cannot start with multiple slashes.`);
else if (!matchedRoute2.matched.length) {
warn(`No match found for location with path "${rawLocation}"`);
}
}
return assign(locationNormalized, matchedRoute2, {
params: decodeParams(matchedRoute2.params),
hash: decode(locationNormalized.hash),
redirectedFrom: void 0,
href: href2
});
}
let matcherLocation;
if ("path" in rawLocation) {
if ("params" in rawLocation && !("name" in rawLocation) && // @ts-expect-error: the type is never
Object.keys(rawLocation.params).length) {
warn(`Path "${// @ts-expect-error: the type is never
rawLocation.path}" was passed with params but they will be ignored. Use a named route alongside params instead.`);
}
matcherLocation = assign({}, rawLocation, {
path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path
});
} else {
const targetParams = assign({}, rawLocation.params);
for (const key in targetParams) {
if (targetParams[key] == null) {
delete targetParams[key];
}
}
matcherLocation = assign({}, rawLocation, {
params: encodeParams(rawLocation.params)
});
currentLocation.params = encodeParams(currentLocation.params);
}
const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
const hash2 = rawLocation.hash || "";
if (hash2 && !hash2.startsWith("#")) {
warn(`A \`hash\` should always start with the character "#". Replace "${hash2}" with "#${hash2}".`);
}
matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
const fullPath = stringifyURL(stringifyQuery$1, assign({}, rawLocation, {
hash: encodeHash(hash2),
path: matchedRoute.path
}));
const href = routerHistory.createHref(fullPath);
{
if (href.startsWith("//")) {
warn(`Location "${rawLocation}" resolved to "${href}". A resolved location cannot start with multiple slashes.`);
} else if (!matchedRoute.matched.length) {
warn(`No match found for location with path "${"path" in rawLocation ? rawLocation.path : rawLocation}"`);
}
}
return assign({
fullPath,
// keep the hash encoded so fullPath is effectively path + encodedQuery +
// hash
hash: hash2,
query: (
// if the user is using a custom query lib like qs, we might have
// nested objects, so we keep the query as is, meaning it can contain
// numbers at `$route.query`, but at the point, the user will have to
// use their own type anyway.
// https://github.com/vuejs/router/issues/328#issuecomment-649481567
stringifyQuery$1 === stringifyQuery ? normalizeQuery(rawLocation.query) : rawLocation.query || {}
)
}, matchedRoute, {
redirectedFrom: void 0,
href
});
}
function locationAsObject(to2) {
return typeof to2 === "string" ? parseURL(parseQuery$1, to2, currentRoute.value.path) : assign({}, to2);
}
function checkCanceledNavigation(to2, from) {
if (pendingLocation !== to2) {
return createRouterError(8, {
from,
to: to2
});
}
}
function push(to2) {
return pushWithRedirect(to2);
}
function replace(to2) {
return push(assign(locationAsObject(to2), { replace: true }));
}
function handleRedirectRecord(to2) {
const lastMatched = to2.matched[to2.matched.length - 1];
if (lastMatched && lastMatched.redirect) {
const { redirect } = lastMatched;
let newTargetLocation = typeof redirect === "function" ? redirect(to2) : redirect;
if (typeof newTargetLocation === "string") {
newTargetLocation = newTargetLocation.includes("?") || newTargetLocation.includes("#") ? newTargetLocation = locationAsObject(newTargetLocation) : (
// force empty params
{ path: newTargetLocation }
);
newTargetLocation.params = {};
}
if (!("path" in newTargetLocation) && !("name" in newTargetLocation)) {
warn(`Invalid redirect found:
${JSON.stringify(newTargetLocation, null, 2)}
when navigating to "${to2.fullPath}". A redirect must contain a name or path. This will break in production.`);
throw new Error("Invalid redirect");
}
return assign({
query: to2.query,
hash: to2.hash,
// avoid transferring params if the redirect has a path
params: "path" in newTargetLocation ? {} : to2.params
}, newTargetLocation);
}
}
function pushWithRedirect(to2, redirectedFrom) {
const targetLocation = pendingLocation = resolve2(to2);
const from = currentRoute.value;
const data = to2.state;
const force = to2.force;
const replace2 = to2.replace === true;
const shouldRedirect = handleRedirectRecord(targetLocation);
if (shouldRedirect)
return pushWithRedirect(
assign(locationAsObject(shouldRedirect), {
state: typeof shouldRedirect === "object" ? assign({}, data, shouldRedirect.state) : data,
force,
replace: replace2
}),
// keep original redirectedFrom if it exists
redirectedFrom || targetLocation
);
const toLocation = targetLocation;
toLocation.redirectedFrom = redirectedFrom;
let failure;
if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
failure = createRouterError(16, { to: toLocation, from });
handleScroll(
from,
from,
// this is a push, the only way for it to be triggered from a
// history.listen is with a redirect, which makes it become a push
true,
// This cannot be the first navigation because the initial location
// cannot be manually navigated to
false
);
}
return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error) => isNavigationFailure(error) ? (
// navigation redirects still mark the router as ready
isNavigationFailure(
error,
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
) ? error : markAsReady(error)
) : (
// reject any unknown error
triggerError(error, toLocation, from)
)).then((failure2) => {
if (failure2) {
if (isNavigationFailure(
failure2,
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
)) {
if (
// we are redirecting to the same location we were already at
isSameRouteLocation(stringifyQuery$1, resolve2(failure2.to), toLocation) && // and we have done it a couple of times
redirectedFrom && // @ts-expect-error: added only in dev
(redirectedFrom._count = redirectedFrom._count ? (
// @ts-expect-error
redirectedFrom._count + 1
) : 1) > 10
) {
warn(`Detected an infinite redirection in a navigation guard when going from "${from.fullPath}" to "${toLocation.fullPath}". Aborting to avoid a Stack Overflow. This will break in production if not fixed.`);
return Promise.reject(new Error("Infinite redirect in navigation guard"));
}
return pushWithRedirect(
// keep options
assign({
// preserve an existing replacement but allow the redirect to override it
replace: replace2
}, locationAsObject(failure2.to), {
state: typeof failure2.to === "object" ? assign({}, data, failure2.to.state) : data,
force
}),
// preserve the original redirectedFrom if any
redirectedFrom || toLocation
);
}
} else {
failure2 = finalizeNavigation(toLocation, from, true, replace2, data);
}
triggerAfterEach(toLocation, from, failure2);
return failure2;
});
}
function checkCanceledNavigationAndReject(to2, from) {
const error = checkCanceledNavigation(to2, from);
return error ? Promise.reject(error) : Promise.resolve();
}
function navigate(to2, from) {
let guards;
const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to2, from);
guards = extractComponentsGuards(leavingRecords.reverse(), "beforeRouteLeave", to2, from);
for (const record of leavingRecords) {
record.leaveGuards.forEach((guard) => {
guards.push(guardToPromiseFn(guard, to2, from));
});
}
const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to2, from);
guards.push(canceledNavigationCheck);
return runGuardQueue(guards).then(() => {
guards = [];
for (const guard of beforeGuards.list()) {
guards.push(guardToPromiseFn(guard, to2, from));
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
guards = extractComponentsGuards(updatingRecords, "beforeRouteUpdate", to2, from);
for (const record of updatingRecords) {
record.updateGuards.forEach((guard) => {
guards.push(guardToPromiseFn(guard, to2, from));
});
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
guards = [];
for (const record of to2.matched) {
if (record.beforeEnter && !from.matched.includes(record)) {
if (isArray(record.beforeEnter)) {
for (const beforeEnter of record.beforeEnter)
guards.push(guardToPromiseFn(beforeEnter, to2, from));
} else {
guards.push(guardToPromiseFn(record.beforeEnter, to2, from));
}
}
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
to2.matched.forEach((record) => record.enterCallbacks = {});
guards = extractComponentsGuards(enteringRecords, "beforeRouteEnter", to2, from);
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
guards = [];
for (const guard of beforeResolveGuards.list()) {
guards.push(guardToPromiseFn(guard, to2, from));
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).catch((err) => isNavigationFailure(
err,
8
/* ErrorTypes.NAVIGATION_CANCELLED */
) ? err : Promise.reject(err));
}
function triggerAfterEach(to2, from, failure) {
for (const guard of afterGuards.list())
guard(to2, from, failure);
}
function finalizeNavigation(toLocation, from, isPush, replace2, data) {
const error = checkCanceledNavigation(toLocation, from);
if (error)
return error;
const isFirstNavigation = from === START_LOCATION_NORMALIZED;
const state = !isBrowser ? {} : history.state;
if (isPush) {
if (replace2 || isFirstNavigation)
routerHistory.replace(toLocation.fullPath, assign({
scroll: isFirstNavigation && state && state.scroll
}, data));
else
routerHistory.push(toLocation.fullPath, data);
}
currentRoute.value = toLocation;
handleScroll(toLocation, from, isPush, isFirstNavigation);
markAsReady();
}
let removeHistoryListener;
function setupListeners() {
if (removeHistoryListener)
return;
removeHistoryListener = routerHistory.listen((to2, _from, info) => {
if (!router.listening)
return;
const toLocation = resolve2(to2);
const shouldRedirect = handleRedirectRecord(toLocation);
if (shouldRedirect) {
pushWithRedirect(assign(shouldRedirect, { replace: true }), toLocation).catch(noop);
return;
}
pendingLocation = toLocation;
const from = currentRoute.value;
if (isBrowser) {
saveScrollPosition(getScrollKey(from.fullPath, info.delta), computeScrollPosition());
}
navigate(toLocation, from).catch((error) => {
if (isNavigationFailure(
error,
4 | 8
/* ErrorTypes.NAVIGATION_CANCELLED */
)) {
return error;
}
if (isNavigationFailure(
error,
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
)) {
pushWithRedirect(
error.to,
toLocation
// avoid an uncaught rejection, let push call triggerError
).then((failure) => {
if (isNavigationFailure(
failure,
4 | 16
/* ErrorTypes.NAVIGATION_DUPLICATED */
) && !info.delta && info.type === NavigationType.pop) {
routerHistory.go(-1, false);
}
}).catch(noop);
return Promise.reject();
}
if (info.delta) {
routerHistory.go(-info.delta, false);
}
return triggerError(error, toLocation, from);
}).then((failure) => {
failure = failure || finalizeNavigation(
// after navigation, all matched components are resolved
toLocation,
from,
false
);
if (failure) {
if (info.delta && // a new navigation has been triggered, so we do not want to revert, that will change the current history
// entry while a different route is displayed
!isNavigationFailure(
failure,
8
/* ErrorTypes.NAVIGATION_CANCELLED */
)) {
routerHistory.go(-info.delta, false);
} else if (info.type === NavigationType.pop && isNavigationFailure(
failure,
4 | 16
/* ErrorTypes.NAVIGATION_DUPLICATED */
)) {
routerHistory.go(-1, false);
}
}
triggerAfterEach(toLocation, from, failure);
}).catch(noop);
});
}
let readyHandlers = useCallbacks();
let errorHandlers = useCallbacks();
let ready;
function triggerError(error, to2, from) {
markAsReady(error);
const list = errorHandlers.list();
if (list.length) {
list.forEach((handler) => handler(error, to2, from));
} else {
{
warn("uncaught error during route navigation:");
}
console.error(error);
}
return Promise.reject(error);
}
function isReady() {
if (ready && currentRoute.value !== START_LOCATION_NORMALIZED)
return Promise.resolve();
return new Promise((resolve3, reject) => {
readyHandlers.add([resolve3, reject]);
});
}
function markAsReady(err) {
if (!ready) {
ready = !err;
setupListeners();
readyHandlers.list().forEach(([resolve3, reject]) => err ? reject(err) : resolve3());
readyHandlers.reset();
}
return err;
}
function handleScroll(to2, from, isPush, isFirstNavigation) {
const { scrollBehavior } = options;
if (!isBrowser || !scrollBehavior)
return Promise.resolve();
const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to2.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
return nextTick().then(() => scrollBehavior(to2, from, scrollPosition)).then((position) => position && scrollToPosition(position)).catch((err) => triggerError(err, to2, from));
}
const go2 = (delta) => routerHistory.go(delta);
let started;
const installedApps = /* @__PURE__ */ new Set();
const router = {
currentRoute,
listening: true,
addRoute,
removeRoute,
hasRoute,
getRoutes,
resolve: resolve2,
options,
push,
replace,
go: go2,
back: () => go2(-1),
forward: () => go2(1),
beforeEach: beforeGuards.add,
beforeResolve: beforeResolveGuards.add,
afterEach: afterGuards.add,
onError: errorHandlers.add,
isReady,
install(app) {
const router2 = this;
app.component("RouterLink", RouterLink);
app.component("RouterView", RouterView);
app.config.globalProperties.$router = router2;
Object.defineProperty(app.config.globalProperties, "$route", {
enumerable: true,
get: () => unref(currentRoute)
});
if (isBrowser && // used for the initial navigation client side to avoid pushing
// multiple times when the router is used in multiple apps
!started && currentRoute.value === START_LOCATION_NORMALIZED) {
started = true;
push(routerHistory.location).catch((err) => {
warn("Unexpected error when starting the router:", err);
});
}
const reactiveRoute = {};
for (const key in START_LOCATION_NORMALIZED) {
reactiveRoute[key] = computed(() => currentRoute.value[key]);
}
app.provide(routerKey, router2);
app.provide(routeLocationKey, reactive(reactiveRoute));
app.provide(routerViewLocationKey, currentRoute);
const unmountApp = app.unmount;
installedApps.add(app);
app.unmount = function() {
installedApps.delete(app);
if (installedApps.size < 1) {
pendingLocation = START_LOCATION_NORMALIZED;
removeHistoryListener && removeHistoryListener();
removeHistoryListener = null;
currentRoute.value = START_LOCATION_NORMALIZED;
started = false;
ready = false;
}
unmountApp();
};
if (isBrowser) {
addDevtools(app, router2, matcher);
}
}
};
return router;
}
function runGuardQueue(guards) {
return guards.reduce((promise, guard) => promise.then(() => guard()), Promise.resolve());
}
function extractChangingRecords(to2, from) {
const leavingRecords = [];
const updatingRecords = [];
const enteringRecords = [];
const len = Math.max(from.matched.length, to2.matched.length);
for (let i2 = 0; i2 < len; i2++) {
const recordFrom = from.matched[i2];
if (recordFrom) {
if (to2.matched.find((record) => isSameRouteRecord(record, recordFrom)))
updatingRecords.push(recordFrom);
else
leavingRecords.push(recordFrom);
}
const recordTo = to2.matched[i2];
if (recordTo) {
if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) {
enteringRecords.push(recordTo);
}
}
}
return [leavingRecords, updatingRecords, enteringRecords];
}
function useRouter() {
return inject(routerKey);
}
function useRoute() {
return inject(routeLocationKey);
}
function t(t2) {
return "object" == typeof t2 && null != t2 && 1 === t2.nodeType;
}
function e$1(t2, e2) {
return (!e2 || "hidden" !== t2) && "visible" !== t2 && "clip" !== t2;
}
function n(t2, n2) {
if (t2.clientHeight < t2.scrollHeight || t2.clientWidth < t2.scrollWidth) {
var r2 = getComputedStyle(t2, null);
return e$1(r2.overflowY, n2) || e$1(r2.overflowX, n2) || function(t3) {
var e2 = function(t4) {
if (!t4.ownerDocument || !t4.ownerDocument.defaultView)
return null;
try {
return t4.ownerDocument.defaultView.frameElement;
} catch (t5) {
return null;
}
}(t3);
return !!e2 && (e2.clientHeight < t3.scrollHeight || e2.clientWidth < t3.scrollWidth);
}(t2);
}
return false;
}
function r(t2, e2, n2, r2, i2, o, l, d2) {
return o < t2 && l > e2 || o > t2 && l < e2 ? 0 : o <= t2 && d2 <= n2 || l >= e2 && d2 >= n2 ? o - t2 - r2 : l > e2 && d2 < n2 || o < t2 && d2 > n2 ? l - e2 + i2 : 0;
}
var i = function(e2, i2) {
var o = window, l = i2.scrollMode, d2 = i2.block, f2 = i2.inline, h2 = i2.boundary, u2 = i2.skipOverflowHiddenElements, s = "function" == typeof h2 ? h2 : function(t2) {
return t2 !== h2;
};
if (!t(e2))
throw new TypeError("Invalid target");
for (var a2, c2, g = document.scrollingElement || document.documentElement, p2 = [], m2 = e2; t(m2) && s(m2); ) {
if ((m2 = null == (c2 = (a2 = m2).parentElement) ? a2.getRootNode().host || null : c2) === g) {
p2.push(m2);
break;
}
null != m2 && m2 === document.body && n(m2) && !n(document.documentElement) || null != m2 && n(m2, u2) && p2.push(m2);
}
for (var w2 = o.visualViewport ? o.visualViewport.width : innerWidth, v2 = o.visualViewport ? o.visualViewport.height : innerHeight, W3 = window.scrollX || pageXOffset, H2 = window.scrollY || pageYOffset, b3 = e2.getBoundingClientRect(), y2 = b3.height, E3 = b3.width, M2 = b3.top, V2 = b3.right, x2 = b3.bottom, I2 = b3.left, C2 = "start" === d2 || "nearest" === d2 ? M2 : "end" === d2 ? x2 : M2 + y2 / 2, R2 = "center" === f2 ? I2 + E3 / 2 : "end" === f2 ? V2 : I2, T2 = [], k2 = 0; k2 < p2.length; k2++) {
var B3 = p2[k2], D2 = B3.getBoundingClientRect(), O2 = D2.height, X2 = D2.width, Y2 = D2.top, L2 = D2.right, S2 = D2.bottom, j2 = D2.left;
if ("if-needed" === l && M2 >= 0 && I2 >= 0 && x2 <= v2 && V2 <= w2 && M2 >= Y2 && x2 <= S2 && I2 >= j2 && V2 <= L2)
return T2;
var N3 = getComputedStyle(B3), q2 = parseInt(N3.borderLeftWidth, 10), z2 = parseInt(N3.borderTopWidth, 10), A3 = parseInt(N3.borderRightWidth, 10), F2 = parseInt(N3.borderBottomWidth, 10), G3 = 0, J3 = 0, K2 = "offsetWidth" in B3 ? B3.offsetWidth - B3.clientWidth - q2 - A3 : 0, P3 = "offsetHeight" in B3 ? B3.offsetHeight - B3.clientHeight - z2 - F2 : 0, Q2 = "offsetWidth" in B3 ? 0 === B3.offsetWidth ? 0 : X2 / B3.offsetWidth : 0, U2 = "offsetHeight" in B3 ? 0 === B3.offsetHeight ? 0 : O2 / B3.offsetHeight : 0;
if (g === B3)
G3 = "start" === d2 ? C2 : "end" === d2 ? C2 - v2 : "nearest" === d2 ? r(H2, H2 + v2, v2, z2, F2, H2 + C2, H2 + C2 + y2, y2) : C2 - v2 / 2, J3 = "start" === f2 ? R2 : "center" === f2 ? R2 - w2 / 2 : "end" === f2 ? R2 - w2 : r(W3, W3 + w2, w2, q2, A3, W3 + R2, W3 + R2 + E3, E3), G3 = Math.max(0, G3 + H2), J3 = Math.max(0, J3 + W3);
else {
G3 = "start" === d2 ? C2 - Y2 - z2 : "end" === d2 ? C2 - S2 + F2 + P3 : "nearest" === d2 ? r(Y2, S2, O2, z2, F2 + P3, C2, C2 + y2, y2) : C2 - (Y2 + O2 / 2) + P3 / 2, J3 = "start" === f2 ? R2 - j2 - q2 : "center" === f2 ? R2 - (j2 + X2 / 2) + K2 / 2 : "end" === f2 ? R2 - L2 + A3 + K2 : r(j2, L2, X2, q2, A3 + K2, R2, R2 + E3, E3);
var Z2 = B3.scrollLeft, $2 = B3.scrollTop;
C2 += $2 - (G3 = Math.max(0, Math.min($2 + G3 / U2, B3.scrollHeight - O2 / U2 + P3))), R2 += Z2 - (J3 = Math.max(0, Math.min(Z2 + J3 / Q2, B3.scrollWidth - X2 / Q2 + K2)));
}
T2.push({ el: B3, top: G3, left: J3 });
}
return T2;
};
function isOptionsObject(options) {
return options === Object(options) && Object.keys(options).length !== 0;
}
function defaultBehavior(actions, behavior) {
if (behavior === void 0) {
behavior = "auto";
}
var canSmoothScroll = "scrollBehavior" in document.body.style;
actions.forEach(function(_ref) {
var el2 = _ref.el, top = _ref.top, left = _ref.left;
if (el2.scroll && canSmoothScroll) {
el2.scroll({
top,
left,
behavior
});
} else {
el2.scrollTop = top;
el2.scrollLeft = left;
}
});
}
function getOptions(options) {
if (options === false) {
return {
block: "end",
inline: "nearest"
};
}
if (isOptionsObject(options)) {
return options;
}
return {
block: "start",
inline: "nearest"
};
}
function scrollIntoView(target, options) {
var isTargetAttached = target.isConnected || target.ownerDocument.documentElement.contains(target);
if (isOptionsObject(options) && typeof options.behavior === "function") {
return options.behavior(isTargetAttached ? i(target, options) : []);
}
if (!isTargetAttached) {
return;
}
var computeOptions = getOptions(options);
return defaultBehavior(i(target, computeOptions), computeOptions.behavior);
}
function unindent(code) {
const lines = code.split("\n");
let indentLevel = -1;
let indentText;
const linesToAnalyze = lines.filter((line) => line.trim().length > 0);
for (const line of linesToAnalyze) {
const match = /^\s*/.exec(line);
if (match && (indentLevel === -1 || indentLevel > match[0].length)) {
indentLevel = match[0].length;
indentText = match[0];
}
}
const result = [];
for (const line of lines) {
result.push(line.replace(indentText, ""));
}
return result.join("\n").trim();
}
function clone(data) {
try {
return structuredClone(data);
} catch (e2) {
console.warn(e2, `Fallback to JSON cloning`);
try {
return JSON.parse(JSON.stringify(data));
} catch (e3) {
console.error(e3);
}
return data;
}
}
function omit(data, keys) {
const copy = {};
for (const key in data) {
if (!keys.includes(key)) {
copy[key] = data[key];
}
}
return copy;
}
function applyState(target, state, override = false) {
for (const key in state) {
if (!override && target[key] && !key.startsWith("_h") && typeof target[key] === "object" && !Array.isArray(target[key])) {
Object.assign(target[key], state[key]);
} else {
target[key] = state[key];
}
}
}
const omitInheritStoryProps = [
"id",
"title",
"group",
"layout",
"variants",
"file",
"slots",
"lastSelectedVariant"
];
const pa = {
name: "HstButton"
}, Uo = /* @__PURE__ */ defineComponent({
...pa,
props: {
color: null
},
setup(s) {
const t2 = {
default: "htw-bg-gray-200 dark:htw-bg-gray-750 htw-text-gray-900 dark:htw-text-gray-100 hover:htw-bg-primary-200 dark:hover:htw-bg-primary-900",
primary: "htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black",
flat: "htw-bg-transparent hover:htw-bg-gray-500/20 htw-text-gray-900 dark:htw-text-gray-100"
};
return (e2, i2) => (openBlock(), createElementBlock("button", {
class: normalizeClass(["histoire-button htw-cursor-pointer htw-rounded-sm", t2[s.color ?? "default"]])
}, [
renderSlot(e2.$slots, "default")
], 2));
}
}), ga = { class: "htw-w-28 htw-whitespace-nowrap htw-text-ellipsis htw-overflow-hidden htw-shrink-0" }, ma = { class: "htw-grow htw-max-w-full htw-flex htw-items-center htw-gap-1" }, wa = { class: "htw-block htw-grow htw-max-w-full" }, ya = {
name: "HstWrapper"
}, qt = /* @__PURE__ */ defineComponent({
...ya,
props: {
title: { default: void 0 },
tag: { default: "label" }
},
setup(s) {
return (t2, e2) => (openBlock(), createBlock(resolveDynamicComponent(s.tag), { class: "histoire-wrapper htw-p-2 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-gap-2 htw-flex-wrap" }, {
default: withCtx(() => [
withDirectives((openBlock(), createElementBlock("span", ga, [
createTextVNode(toDisplayString(s.title), 1)
])), [
[unref(VTooltip), {
content: s.title,
placement: "left",
distance: 12
}]
]),
createBaseVNode("span", ma, [
createBaseVNode("span", wa, [
renderSlot(t2.$slots, "default")
]),
renderSlot(t2.$slots, "actions")
])
]),
_: 3
}));
}
}), ba = { class: "htw-flex htw-gap-px htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 htw-rounded-sm htw-p-px" }, ka = {
name: "HstButtonGroup"
}, xa = /* @__PURE__ */ defineComponent({
...ka,
props: {
title: null,
modelValue: null,
options: null
},
emits: ["update:modelValue"],
setup(s, { emit: t2 }) {
const e2 = s, i2 = computed(() => Array.isArray(e2.options) ? e2.options.map((r2) => typeof r2 == "string" || typeof r2 == "number" ? { value: r2, label: String(r2) } : r2) : Object.keys(e2.options).map((r2) => ({
value: r2,
label: e2.options[r2]
})));
function n2(r2) {
t2("update:modelValue", r2);
}
return (r2, o) => (openBlock(), createBlock(qt, {
tag: "div",
role: "group",
title: s.title,
class: "histoire-button-group htw-flex-nowrap htw-items-center"
}, {
actions: withCtx(() => [
renderSlot(r2.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("div", ba, [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(i2), ({ label: l, value: h2 }) => (openBlock(), createBlock(Uo, {
key: h2,
class: "htw-px-1 htw-h-[22px] htw-flex-1 !htw-rounded-[3px]",
color: h2 === s.modelValue ? "primary" : "flat",
rounded: false,
onClick: (a2) => n2(h2)
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(l), 1)
]),
_: 2
}, 1032, ["color", "onClick"]))), 128))
])
]),
_: 3
}, 8, ["title"]));
}
}), va = {
width: "16",
height: "16",
viewBox: "0 0 24 24",
class: "htw-relative htw-z-10"
}, Sa = ["stroke-dasharray", "stroke-dashoffset"], Ca = {
name: "HstSimpleCheckbox"
}, Qo = /* @__PURE__ */ defineComponent({
...Ca,
props: {
modelValue: { type: Boolean },
withToggle: { type: Boolean }
},
emits: {
"update:modelValue": (s) => true
},
setup(s, { emit: t2 }) {
const e2 = s;
function i2() {
e2.withToggle && t2("update:modelValue", !e2.modelValue);
}
watch(() => e2.modelValue, () => {
h2.value = true;
});
const n2 = ref(), r2 = ref(0), o = computed(() => e2.modelValue ? 1 : 0), l = computed(() => (1 - o.value) * r2.value), h2 = ref(false);
return watch(n2, () => {
var a2, c2;
r2.value = ((c2 = (a2 = n2.value).getTotalLength) == null ? void 0 : c2.call(a2)) ?? 21.21;
}), (a2, c2) => (openBlock(), createElementBlock("div", {
class: normalizeClass(["histoire-simple-checkbox htw-group htw-text-white htw-w-[16px] htw-h-[16px] htw-relative", { "htw-cursor-pointer": s.withToggle }]),
onClick: i2
}, [
createBaseVNode("div", {
class: normalizeClass(["htw-border htw-border-solid group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out group-hover:htw-border-primary-500 group-hover:dark:htw-border-primary-500", [
s.modelValue ? "htw-border-primary-500 htw-border-8" : "htw-border-black/25 dark:htw-border-white/25 htw-delay-150"
]])
}, null, 2),
(openBlock(), createElementBlock("svg", va, [
createBaseVNode("path", {
ref_key: "path",
ref: n2,
d: "m 4 12 l 5 5 l 10 -10",
fill: "none",
class: normalizeClass(["htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out", [
h2.value ? "htw-transition-all" : "htw-transition-none",
{
"htw-delay-150": s.modelValue
}
]]),
"stroke-dasharray": r2.value,
"stroke-dashoffset": unref(l)
}, null, 10, Sa)
]))
], 2));
}
}), Aa = {
name: "HstCheckbox"
}, Oa = /* @__PURE__ */ defineComponent({
...Aa,
props: {
modelValue: { type: Boolean },
title: null
},
emits: {
"update:modelValue": (s) => true
},
setup(s, { emit: t2 }) {
const e2 = s;
function i2() {
t2("update:modelValue", !e2.modelValue);
}
return (n2, r2) => (openBlock(), createBlock(qt, {
role: "checkbox",
tabindex: "0",
class: "histoire-checkbox htw-cursor-pointer htw-items-center",
title: s.title,
onClick: r2[0] || (r2[0] = (o) => i2()),
onKeydown: [
r2[1] || (r2[1] = withKeys(withModifiers((o) => i2(), ["prevent"]), ["enter"])),
r2[2] || (r2[2] = withKeys(withModifiers((o) => i2(), ["prevent"]), ["space"]))
]
}, {
actions: withCtx(() => [
renderSlot(n2.$slots, "actions")
]),
default: withCtx(() => [
createVNode(Qo, { "model-value": s.modelValue }, null, 8, ["model-value"])
]),
_: 3
}, 8, ["title"]));
}
}), Ma = { class: "-htw-my-1" }, Da = ["for", "onKeydown", "onClick"], Ta = {
name: "HstCheckboxList"
}, Pa = /* @__PURE__ */ defineComponent({
...Ta,
props: {
title: null,
modelValue: null,
options: null
},
emits: ["update:modelValue"],
setup(s, { emit: t2 }) {
const e2 = s, i2 = computed(() => Array.isArray(e2.options) ? Object.fromEntries(e2.options.map((r2) => typeof r2 == "string" ? [r2, r2] : [r2.value, r2.label])) : e2.options);
function n2(r2) {
e2.modelValue.includes(r2) ? t2("update:modelValue", e2.modelValue.filter((o) => o !== r2)) : t2("update:modelValue", [...e2.modelValue, r2]);
}
return (r2, o) => (openBlock(), createBlock(qt, {
role: "group",
title: s.title,
class: normalizeClass(["histoire-checkbox-list htw-cursor-text", r2.$attrs.class]),
style: normalizeStyle(r2.$attrs.style)
}, {
actions: withCtx(() => [
renderSlot(r2.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("div", Ma, [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(i2), (l, h2) => (openBlock(), createElementBlock("label", {
key: h2,
tabindex: "0",
for: `${h2}-radio`,
class: "htw-cursor-pointer htw-flex htw-items-center htw-relative htw-py-1 htw-group",
onKeydown: [
withKeys(withModifiers((a2) => n2(h2), ["prevent"]), ["enter"]),
withKeys(withModifiers((a2) => n2(h2), ["prevent"]), ["space"])
],
onClick: (a2) => n2(h2)
}, [
createVNode(Qo, {
"model-value": s.modelValue.includes(h2),
class: "htw-mr-2"
}, null, 8, ["model-value"]),
createTextVNode(" " + toDisplayString(l), 1)
], 40, Da))), 128))
])
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), Ba = ["value"], Ra = {
name: "HstText"
}, La = /* @__PURE__ */ defineComponent({
...Ra,
props: {
title: null,
modelValue: null
},
emits: {
"update:modelValue": (s) => true
},
setup(s, { emit: t2 }) {
const e2 = ref();
return (i2, n2) => (openBlock(), createBlock(qt, {
title: s.title,
class: normalizeClass(["histoire-text htw-cursor-text htw-items-center", i2.$attrs.class]),
style: normalizeStyle(i2.$attrs.style),
onClick: n2[1] || (n2[1] = (r2) => e2.value.focus())
}, {
actions: withCtx(() => [
renderSlot(i2.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("input", mergeProps({
ref_key: "input",
ref: e2
}, { ...i2.$attrs, class: null, style: null }, {
type: "text",
value: s.modelValue,
class: "htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-px-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm",
onInput: n2[0] || (n2[0] = (r2) => t2("update:modelValue", r2.target.value))
}), null, 16, Ba)
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), Ea = {
name: "HstNumber",
inheritAttrs: false
}, Na = /* @__PURE__ */ defineComponent({
...Ea,
props: {
title: null,
modelValue: null
},
emits: {
"update:modelValue": (s) => true
},
setup(s, { emit: t2 }) {
const e2 = s, i2 = computed({
get: () => e2.modelValue,
set: (u2) => {
t2("update:modelValue", u2);
}
}), n2 = ref();
function r2() {
n2.value.focus(), n2.value.select();
}
const o = ref(false);
let l, h2;
function a2(u2) {
o.value = true, l = u2.clientX, h2 = i2.value, window.addEventListener("mousemove", c2), window.addEventListener("mouseup", f2);
}
function c2(u2) {
let d2 = parseFloat(n2.value.step);
isNaN(d2) && (d2 = 1), i2.value = h2 + Math.round((u2.clientX - l) / 10 / d2) * d2;
}
function f2() {
o.value = false, window.removeEventListener("mousemove", c2), window.removeEventListener("mouseup", f2);
}
return onUnmounted(() => {
f2();
}), (u2, d2) => (openBlock(), createBlock(qt, {
class: normalizeClass(["histoire-number htw-cursor-ew-resize htw-items-center", [
u2.$attrs.class,
{ "htw-select-none": o.value }
]]),
title: s.title,
style: normalizeStyle(u2.$attrs.style),
onClick: r2,
onMousedown: a2
}, {
actions: withCtx(() => [
renderSlot(u2.$slots, "actions")
]),
default: withCtx(() => [
withDirectives(createBaseVNode("input", mergeProps({
ref_key: "input",
ref: n2
}, { ...u2.$attrs, class: null, style: null }, {
"onUpdate:modelValue": d2[0] || (d2[0] = (p2) => isRef(i2) ? i2.value = p2 : null),
type: "number",
class: [{
"htw-select-none": o.value
}, "htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-pl-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm htw-cursor-ew-resize htw-box-border"]
}), null, 16), [
[
vModelText,
unref(i2),
void 0,
{ number: true }
]
])
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), Va = { class: "htw-relative htw-w-full htw-flex htw-items-center" }, Ia = /* @__PURE__ */ createBaseVNode("div", { class: "htw-absolute htw-inset-0 htw-flex htw-items-center" }, [
/* @__PURE__ */ createBaseVNode("div", { class: "htw-border htw-border-black/25 dark:htw-border-white/25 htw-h-1 htw-w-full htw-rounded-full" })
], -1), Ha = {
name: "HstSlider",
inheritAttrs: false
}, $a = /* @__PURE__ */ defineComponent({
...Ha,
props: {
title: null,
modelValue: null,
min: null,
max: null
},
emits: {
"update:modelValue": (s) => true
},
setup(s, { emit: t2 }) {
const e2 = s, i2 = ref(false), n2 = ref(null), r2 = computed({
get: () => e2.modelValue,
set: (h2) => {
t2("update:modelValue", h2);
}
}), o = computed(() => (e2.modelValue - e2.min) / (e2.max - e2.min)), l = computed(() => n2.value ? {
left: 8 + (n2.value.clientWidth - 16) * o.value + "px"
} : {});
return (h2, a2) => (openBlock(), createBlock(qt, {
class: normalizeClass(["histoire-slider htw-items-center", h2.$attrs.class]),
title: s.title,
style: normalizeStyle(h2.$attrs.style)
}, {
default: withCtx(() => [
createBaseVNode("div", Va, [
Ia,
withDirectives(createBaseVNode("input", mergeProps({
ref_key: "input",
ref: n2,
"onUpdate:modelValue": a2[0] || (a2[0] = (c2) => isRef(r2) ? r2.value = c2 : null),
class: "htw-range-input htw-appearance-none htw-border-0 htw-bg-transparent htw-cursor-pointer htw-relative htw-w-full htw-m-0 htw-text-gray-700",
type: "range"
}, { ...h2.$attrs, class: null, style: null, min: s.min, max: s.max }, {
onMouseover: a2[1] || (a2[1] = (c2) => i2.value = true),
onMouseleave: a2[2] || (a2[2] = (c2) => i2.value = false)
}), null, 16), [
[
vModelText,
unref(r2),
void 0,
{ number: true }
]
]),
i2.value ? withDirectives((openBlock(), createElementBlock("div", {
key: 0,
class: "htw-absolute",
style: normalizeStyle(unref(l))
}, null, 4)), [
[unref(VTooltip), { content: s.modelValue.toString(), shown: true, distance: 16, delay: 0 }]
]) : createCommentVNode("", true)
])
]),
_: 1
}, 8, ["title", "class", "style"]));
}
});
const Fa = ["value"], za = {
name: "HstTextarea",
inheritAttrs: false
}, _a = /* @__PURE__ */ defineComponent({
...za,
props: {
title: null,
modelValue: null
},
emits: {
"update:modelValue": (s) => true
},
setup(s, { emit: t2 }) {
const e2 = ref();
return (i2, n2) => (openBlock(), createBlock(qt, {
title: s.title,
class: normalizeClass(["histoire-textarea htw-cursor-text", i2.$attrs.class]),
style: normalizeStyle(i2.$attrs.style),
onClick: n2[1] || (n2[1] = (r2) => e2.value.focus())
}, {
actions: withCtx(() => [
renderSlot(i2.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("textarea", mergeProps({
ref_key: "input",
ref: e2
}, { ...i2.$attrs, class: null, style: null }, {
value: s.modelValue,
class: "htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-px-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm htw-box-border htw-resize-y htw-min-h-[26px]",
onInput: n2[0] || (n2[0] = (r2) => t2("update:modelValue", r2.target.value))
}), null, 16, Fa)
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), Wa = { class: "htw-cursor-pointer htw-w-full htw-outline-none htw-px-2 htw-h-[27px] -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 hover:htw-border-primary-500 dark:hover:htw-border-primary-500 htw-rounded-sm htw-flex htw-gap-2 htw-items-center htw-leading-normal" }, ja = { class: "htw-flex-1 htw-truncate" }, qa = { class: "htw-flex htw-flex-col htw-bg-gray-50 dark:htw-bg-gray-700" }, Ka = ["onClick"], Ga = {
name: "CustomSelect"
}, Ua = /* @__PURE__ */ defineComponent({
...Ga,
props: {
modelValue: null,
options: null
},
emits: ["update:modelValue"],
setup(s, { emit: t2 }) {
const e2 = s, i2 = computed(() => Array.isArray(e2.options) ? e2.options.map((o) => typeof o == "string" || typeof o == "number" ? [o, String(o)] : [o.value, o.label]) : Object.entries(e2.options)), n2 = computed(() => {
var o;
return (o = i2.value.find(([l]) => l === e2.modelValue)) == null ? void 0 : o[1];
});
function r2(o, l) {
t2("update:modelValue", o), l();
}
return (o, l) => (openBlock(), createBlock(unref(Dropdown), {
"auto-size": "",
"auto-boundary-max-size": ""
}, {
popper: withCtx(({ hide: h2 }) => [
createBaseVNode("div", qa, [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(i2), ([a2, c2]) => (openBlock(), createElementBlock("div", mergeProps({ ...o.$attrs, class: null, style: null }, {
key: c2,
class: ["htw-px-2 htw-py-1 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700", {
"htw-bg-primary-200 dark:htw-bg-primary-800": e2.modelValue === a2
}],
onClick: (f2) => r2(a2, h2)
}), toDisplayString(c2), 17, Ka))), 128))
])
]),
default: withCtx(() => [
createBaseVNode("div", Wa, [
createBaseVNode("div", ja, [
renderSlot(o.$slots, "default", { label: unref(n2) }, () => [
createTextVNode(toDisplayString(unref(n2)), 1)
])
]),
createVNode(unref(Icon), {
icon: "carbon:chevron-sort",
class: "htw-w-4 htw-h-4 htw-flex-none htw-ml-auto"
})
])
]),
_: 3
}));
}
});
const Qa = {
name: "HstSelect"
}, Ja = /* @__PURE__ */ defineComponent({
...Qa,
props: {
title: null,
modelValue: null,
options: null
},
emits: ["update:modelValue"],
setup(s, { emit: t2 }) {
return (e2, i2) => (openBlock(), createBlock(qt, {
title: s.title,
class: normalizeClass(["histoire-select htw-cursor-text htw-items-center", e2.$attrs.class]),
style: normalizeStyle(e2.$attrs.style)
}, {
actions: withCtx(() => [
renderSlot(e2.$slots, "actions")
]),
default: withCtx(() => [
createVNode(Ua, {
options: s.options,
"model-value": s.modelValue,
"onUpdate:modelValue": i2[0] || (i2[0] = (n2) => t2("update:modelValue", n2))
}, null, 8, ["options", "model-value"])
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), Xa = {
name: "HstCopyIcon"
}, Me = /* @__PURE__ */ defineComponent({
...Xa,
props: {
content: { type: [String, Function] }
},
setup(s) {
const t2 = s, { copy: e2, copied: i2 } = useClipboard(), n2 = async () => {
const r2 = typeof t2.content == "function" ? await t2.content() : t2.content;
e2(r2);
};
return (r2, o) => withDirectives((openBlock(), createBlock(unref(Icon), {
icon: "carbon:copy-file",
class: "htw-w-4 htw-h-4 htw-opacity-50 hover:htw-opacity-100 hover:htw-text-primary-500 htw-cursor-pointer",
onClick: o[0] || (o[0] = (l) => n2())
}, null, 512)), [
[unref(VTooltip), {
content: "Copied!",
triggers: [],
shown: unref(i2),
distance: 12,
delay: 0
}]
]);
}
}), Ya = {
key: 0,
class: "histoire-color-shades htw-grid htw-gap-4 htw-grid-cols-[repeat(auto-fill,minmax(200px,1fr))] htw-m-4"
}, Za = ["onMouseenter"], tc = { class: "htw-flex htw-gap-1" }, ec = { class: "htw-my-0 htw-truncate htw-shrink" }, ic = { class: "htw-flex htw-gap-1" }, nc = { class: "htw-my-0 htw-opacity-50 htw-truncate htw-shrink" }, sc = {
name: "HstColorShades"
}, rc = /* @__PURE__ */ defineComponent({
...sc,
props: {
shades: null,
getName: { type: Function },
search: null
},
setup(s) {
const t2 = s, e2 = (o, l = "") => Object.entries(o).reduce((h2, [a2, c2]) => {
const f2 = l ? a2 === "DEFAULT" ? l : `${l}-${a2}` : a2, u2 = typeof c2 == "object" ? e2(c2, f2) : { [f2]: c2 };
return { ...h2, ...u2 };
}, {}), i2 = computed(() => {
const o = t2.shades, l = t2.getName, h2 = e2(o);
return Object.entries(h2).map(([a2, c2]) => {
const f2 = l ? l(a2, c2) : a2;
return {
key: a2,
color: c2,
name: f2
};
});
}), n2 = computed(() => {
let o = i2.value;
if (t2.search) {
const l = new RegExp(t2.search, "i");
o = o.filter(({ name: h2 }) => l.test(h2));
}
return o;
}), r2 = ref(null);
return (o, l) => unref(n2).length ? (openBlock(), createElementBlock("div", Ya, [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(n2), (h2) => (openBlock(), createElementBlock("div", {
key: h2.key,
class: "htw-flex htw-flex-col htw-gap-2",
onMouseenter: (a2) => r2.value = h2.key,
onMouseleave: l[0] || (l[0] = (a2) => r2.value = null)
}, [
renderSlot(o.$slots, "default", {
color: h2.color
}, () => [
createBaseVNode("div", {
class: "htw-rounded-full htw-w-16 htw-h-16",
style: normalizeStyle({
backgroundColor: h2.color
})
}, null, 4)
]),
createBaseVNode("div", null, [
createBaseVNode("div", tc, [
withDirectives((openBlock(), createElementBlock("pre", ec, [
createTextVNode(toDisplayString(h2.name), 1)
])), [
[unref(VTooltip), h2.name.length > 23 ? h2.name : ""]
]),
r2.value === h2.key ? (openBlock(), createBlock(Me, {
key: 0,
content: h2.name,
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
]),
createBaseVNode("div", ic, [
withDirectives((openBlock(), createElementBlock("pre", nc, [
createTextVNode(toDisplayString(h2.color), 1)
])), [
[unref(VTooltip), h2.color.length > 23 ? h2.color : ""]
]),
r2.value === h2.key ? (openBlock(), createBlock(Me, {
key: 0,
content: h2.color,
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
])
])
], 40, Za))), 128))
])) : createCommentVNode("", true);
}
}), oc = ["onMouseenter"], lc = { class: "htw-mx-4" }, hc = { class: "htw-flex htw-gap-1" }, ac = { class: "htw-my-0 htw-truncate htw-shrink" }, cc = { class: "htw-flex htw-gap-1" }, fc = { class: "htw-my-0 htw-opacity-50 htw-truncate htw-shrink" }, uc = {
name: "HstTokenList"
}, dc = /* @__PURE__ */ defineComponent({
...uc,
props: {
tokens: null,
getName: { type: Function }
},
setup(s) {
const t2 = s, e2 = computed(() => {
const n2 = t2.tokens, r2 = t2.getName;
return Object.entries(n2).map(([o, l]) => {
const h2 = r2 ? r2(o, l) : o;
return {
key: o,
name: h2,
value: typeof l == "number" ? l.toString() : l
};
});
}), i2 = ref(null);
return (n2, r2) => (openBlock(true), createElementBlock(Fragment, null, renderList(unref(e2), (o) => (openBlock(), createElementBlock("div", {
key: o.key,
class: "histoire-token-list htw-flex htw-flex-col htw-gap-2 htw-my-8",
onMouseenter: (l) => i2.value = o.key,
onMouseleave: r2[0] || (r2[0] = (l) => i2.value = null)
}, [
renderSlot(n2.$slots, "default", { token: o }),
createBaseVNode("div", lc, [
createBaseVNode("div", hc, [
createBaseVNode("pre", ac, toDisplayString(o.name), 1),
i2.value === o.key ? (openBlock(), createBlock(Me, {
key: 0,
content: o.name,
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
]),
createBaseVNode("div", cc, [
createBaseVNode("pre", fc, toDisplayString(o.value), 1),
i2.value === o.key ? (openBlock(), createBlock(Me, {
key: 0,
content: typeof o.value == "string" ? o.value : JSON.stringify(o.value),
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
])
])
], 40, oc))), 128));
}
}), pc = ["onMouseenter"], gc = { class: "htw-flex htw-gap-1" }, mc = { class: "htw-my-0 htw-truncate htw-shrink" }, wc = { class: "htw-flex htw-gap-1" }, yc = { class: "htw-my-0 htw-opacity-50 htw-truncate htw-shrink" }, bc = {
name: "HstTokenGrid"
}, kc = /* @__PURE__ */ defineComponent({
...bc,
props: {
tokens: null,
colSize: { default: 180 },
getName: { type: Function, default: null }
},
setup(s) {
const t2 = s, e2 = computed(() => {
const r2 = t2.tokens, o = t2.getName;
return Object.entries(r2).map(([l, h2]) => {
const a2 = o ? o(l, h2) : l;
return {
key: l,
name: a2,
value: typeof h2 == "number" ? h2.toString() : h2
};
});
}), i2 = computed(() => `${t2.colSize}px`), n2 = ref(null);
return (r2, o) => (openBlock(), createElementBlock("div", {
class: "histoire-token-grid htw-bind-col-size htw-grid htw-gap-4 htw-m-4",
style: normalizeStyle({
"--histoire-col-size": unref(i2)
})
}, [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(e2), (l) => (openBlock(), createElementBlock("div", {
key: l.key,
class: "htw-flex htw-flex-col htw-gap-2",
onMouseenter: (h2) => n2.value = l.key,
onMouseleave: o[0] || (o[0] = (h2) => n2.value = null)
}, [
renderSlot(r2.$slots, "default", { token: l }),
createBaseVNode("div", null, [
createBaseVNode("div", gc, [
withDirectives((openBlock(), createElementBlock("pre", mc, [
createTextVNode(toDisplayString(l.name), 1)
])), [
[unref(VTooltip), l.name.length > s.colSize / 8 ? l.name : ""]
]),
n2.value === l.key ? (openBlock(), createBlock(Me, {
key: 0,
content: l.name,
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
]),
createBaseVNode("div", wc, [
withDirectives((openBlock(), createElementBlock("pre", yc, [
createTextVNode(toDisplayString(l.value), 1)
])), [
[unref(VTooltip), l.value.length > s.colSize / 8 ? l.value : ""]
]),
n2.value === l.key ? (openBlock(), createBlock(Me, {
key: 0,
content: typeof l.value == "string" ? l.value : JSON.stringify(l.value),
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
])
])
], 40, pc))), 128))
], 4));
}
});
const xc = { class: "-htw-my-1" }, vc = ["id", "name", "value", "checked", "onChange"], Sc = ["for", "onKeydown"], Cc = {
name: "HstRadio"
}, Ac = /* @__PURE__ */ defineComponent({
...Cc,
props: {
title: null,
modelValue: null,
options: null
},
emits: ["update:modelValue"],
setup(s, { emit: t2 }) {
const e2 = s, i2 = computed(() => Array.isArray(e2.options) ? Object.fromEntries(e2.options.map((o) => typeof o == "string" ? [o, o] : [o.value, o.label])) : e2.options);
function n2(o) {
t2("update:modelValue", o), r2.value = true;
}
const r2 = ref(false);
return (o, l) => (openBlock(), createBlock(qt, {
role: "group",
title: s.title,
class: normalizeClass(["histoire-radio htw-cursor-text", o.$attrs.class]),
style: normalizeStyle(o.$attrs.style)
}, {
actions: withCtx(() => [
renderSlot(o.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("div", xc, [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(i2), (h2, a2) => (openBlock(), createElementBlock(Fragment, { key: a2 }, [
createBaseVNode("input", {
id: `${a2}-radio`,
type: "radio",
name: `${a2}-radio`,
value: a2,
checked: a2 === s.modelValue,
class: "htw-hidden",
onChange: (c2) => n2(a2)
}, null, 40, vc),
createBaseVNode("label", {
tabindex: "0",
for: `${a2}-radio`,
class: "htw-cursor-pointer htw-flex htw-items-center htw-relative htw-py-1 htw-group",
onKeydown: [
withKeys(withModifiers((c2) => n2(a2), ["prevent"]), ["enter"]),
withKeys(withModifiers((c2) => n2(a2), ["prevent"]), ["space"])
]
}, [
(openBlock(), createElementBlock("svg", {
width: "16",
height: "16",
viewBox: "-12 -12 24 24",
class: normalizeClass(["htw-relative htw-z-10 htw-border htw-border-solid htw-text-inherit htw-rounded-full htw-box-border htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out htw-mr-2 group-hover:htw-border-primary-500", [
s.modelValue === a2 ? "htw-border-primary-500" : "htw-border-black/25 dark:htw-border-white/25"
]])
}, [
createBaseVNode("circle", {
r: "7",
class: normalizeClass(["htw-will-change-transform", [
r2.value ? "htw-transition-all" : "htw-transition-none",
{
"htw-delay-150": s.modelValue === a2
},
s.modelValue === a2 ? "htw-fill-primary-500" : "htw-fill-transparent htw-scale-0"
]])
}, null, 2)
], 2)),
createTextVNode(" " + toDisplayString(h2), 1)
], 40, Sc)
], 64))), 128))
])
]),
_: 3
}, 8, ["title", "class", "style"]));
}
});
let E$1 = class E2 {
/**
@internal
*/
constructor() {
}
/**
Get the line description around the given position.
*/
lineAt(t2) {
if (t2 < 0 || t2 > this.length)
throw new RangeError(`Invalid position ${t2} in document of length ${this.length}`);
return this.lineInner(t2, false, 1, 0);
}
/**
Get the description for the given (1-based) line number.
*/
line(t2) {
if (t2 < 1 || t2 > this.lines)
throw new RangeError(`Invalid line number ${t2} in ${this.lines}-line document`);
return this.lineInner(t2, true, 1, 0);
}
/**
Replace a range of the text with the given content.
*/
replace(t2, e2, i2) {
let n2 = [];
return this.decompose(
0,
t2,
n2,
2
/* Open.To */
), i2.length && i2.decompose(
0,
i2.length,
n2,
3
/* Open.To */
), this.decompose(
e2,
this.length,
n2,
1
/* Open.From */
), Ht.from(n2, this.length - (e2 - t2) + i2.length);
}
/**
Append another document to this one.
*/
append(t2) {
return this.replace(this.length, this.length, t2);
}
/**
Retrieve the text between the given points.
*/
slice(t2, e2 = this.length) {
let i2 = [];
return this.decompose(t2, e2, i2, 0), Ht.from(i2, e2 - t2);
}
/**
Test whether this text is equal to another instance.
*/
eq(t2) {
if (t2 == this)
return true;
if (t2.length != this.length || t2.lines != this.lines)
return false;
let e2 = this.scanIdentical(t2, 1), i2 = this.length - this.scanIdentical(t2, -1), n2 = new li(this), r2 = new li(t2);
for (let o = e2, l = e2; ; ) {
if (n2.next(o), r2.next(o), o = 0, n2.lineBreak != r2.lineBreak || n2.done != r2.done || n2.value != r2.value)
return false;
if (l += n2.value.length, n2.done || l >= i2)
return true;
}
}
/**
Iterate over the text. When `dir` is `-1`, iteration happens
from end to start. This will return lines and the breaks between
them as separate strings.
*/
iter(t2 = 1) {
return new li(this, t2);
}
/**
Iterate over a range of the text. When `from` > `to`, the
iterator will run in reverse.
*/
iterRange(t2, e2 = this.length) {
return new Jo(this, t2, e2);
}
/**
Return a cursor that iterates over the given range of lines,
_without_ returning the line breaks between, and yielding empty
strings for empty lines.
When `from` and `to` are given, they should be 1-based line numbers.
*/
iterLines(t2, e2) {
let i2;
if (t2 == null)
i2 = this.iter();
else {
e2 == null && (e2 = this.lines + 1);
let n2 = this.line(t2).from;
i2 = this.iterRange(n2, Math.max(n2, e2 == this.lines + 1 ? this.length : e2 <= 1 ? 0 : this.line(e2 - 1).to));
}
return new Xo(i2);
}
/**
@internal
*/
toString() {
return this.sliceString(0);
}
/**
Convert the document to an array of lines (which can be
deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
*/
toJSON() {
let t2 = [];
return this.flatten(t2), t2;
}
/**
Create a `Text` instance for the given array of lines.
*/
static of(t2) {
if (t2.length == 0)
throw new RangeError("A document must have at least one line");
return t2.length == 1 && !t2[0] ? E2.empty : t2.length <= 32 ? new G$2(t2) : Ht.from(G$2.split(t2, []));
}
};
let G$2 = class G2 extends E$1 {
constructor(t2, e2 = Oc(t2)) {
super(), this.text = t2, this.length = e2;
}
get lines() {
return this.text.length;
}
get children() {
return null;
}
lineInner(t2, e2, i2, n2) {
for (let r2 = 0; ; r2++) {
let o = this.text[r2], l = n2 + o.length;
if ((e2 ? i2 : l) >= t2)
return new Mc(n2, l, i2, o);
n2 = l + 1, i2++;
}
}
decompose(t2, e2, i2, n2) {
let r2 = t2 <= 0 && e2 >= this.length ? this : new G2(dr(this.text, t2, e2), Math.min(e2, this.length) - Math.max(0, t2));
if (n2 & 1) {
let o = i2.pop(), l = _i(r2.text, o.text.slice(), 0, r2.length);
if (l.length <= 32)
i2.push(new G2(l, o.length + r2.length));
else {
let h2 = l.length >> 1;
i2.push(new G2(l.slice(0, h2)), new G2(l.slice(h2)));
}
} else
i2.push(r2);
}
replace(t2, e2, i2) {
if (!(i2 instanceof G2))
return super.replace(t2, e2, i2);
let n2 = _i(this.text, _i(i2.text, dr(this.text, 0, t2)), e2), r2 = this.length + i2.length - (e2 - t2);
return n2.length <= 32 ? new G2(n2, r2) : Ht.from(G2.split(n2, []), r2);
}
sliceString(t2, e2 = this.length, i2 = `
`) {
let n2 = "";
for (let r2 = 0, o = 0; r2 <= e2 && o < this.text.length; o++) {
let l = this.text[o], h2 = r2 + l.length;
r2 > t2 && o && (n2 += i2), t2 < h2 && e2 > r2 && (n2 += l.slice(Math.max(0, t2 - r2), e2 - r2)), r2 = h2 + 1;
}
return n2;
}
flatten(t2) {
for (let e2 of this.text)
t2.push(e2);
}
scanIdentical() {
return 0;
}
static split(t2, e2) {
let i2 = [], n2 = -1;
for (let r2 of t2)
i2.push(r2), n2 += r2.length + 1, i2.length == 32 && (e2.push(new G2(i2, n2)), i2 = [], n2 = -1);
return n2 > -1 && e2.push(new G2(i2, n2)), e2;
}
};
class Ht extends E$1 {
constructor(t2, e2) {
super(), this.children = t2, this.length = e2, this.lines = 0;
for (let i2 of t2)
this.lines += i2.lines;
}
lineInner(t2, e2, i2, n2) {
for (let r2 = 0; ; r2++) {
let o = this.children[r2], l = n2 + o.length, h2 = i2 + o.lines - 1;
if ((e2 ? h2 : l) >= t2)
return o.lineInner(t2, e2, i2, n2);
n2 = l + 1, i2 = h2 + 1;
}
}
decompose(t2, e2, i2, n2) {
for (let r2 = 0, o = 0; o <= e2 && r2 < this.children.length; r2++) {
let l = this.children[r2], h2 = o + l.length;
if (t2 <= h2 && e2 >= o) {
let a2 = n2 & ((o <= t2 ? 1 : 0) | (h2 >= e2 ? 2 : 0));
o >= t2 && h2 <= e2 && !a2 ? i2.push(l) : l.decompose(t2 - o, e2 - o, i2, a2);
}
o = h2 + 1;
}
}
replace(t2, e2, i2) {
if (i2.lines < this.lines)
for (let n2 = 0, r2 = 0; n2 < this.children.length; n2++) {
let o = this.children[n2], l = r2 + o.length;
if (t2 >= r2 && e2 <= l) {
let h2 = o.replace(t2 - r2, e2 - r2, i2), a2 = this.lines - o.lines + h2.lines;
if (h2.lines < a2 >> 5 - 1 && h2.lines > a2 >> 5 + 1) {
let c2 = this.children.slice();
return c2[n2] = h2, new Ht(c2, this.length - (e2 - t2) + i2.length);
}
return super.replace(r2, l, h2);
}
r2 = l + 1;
}
return super.replace(t2, e2, i2);
}
sliceString(t2, e2 = this.length, i2 = `
`) {
let n2 = "";
for (let r2 = 0, o = 0; r2 < this.children.length && o <= e2; r2++) {
let l = this.children[r2], h2 = o + l.length;
o > t2 && r2 && (n2 += i2), t2 < h2 && e2 > o && (n2 += l.sliceString(t2 - o, e2 - o, i2)), o = h2 + 1;
}
return n2;
}
flatten(t2) {
for (let e2 of this.children)
e2.flatten(t2);
}
scanIdentical(t2, e2) {
if (!(t2 instanceof Ht))
return 0;
let i2 = 0, [n2, r2, o, l] = e2 > 0 ? [0, 0, this.children.length, t2.children.length] : [this.children.length - 1, t2.children.length - 1, -1, -1];
for (; ; n2 += e2, r2 += e2) {
if (n2 == o || r2 == l)
return i2;
let h2 = this.children[n2], a2 = t2.children[r2];
if (h2 != a2)
return i2 + h2.scanIdentical(a2, e2);
i2 += h2.length + 1;
}
}
static from(t2, e2 = t2.reduce((i2, n2) => i2 + n2.length + 1, -1)) {
let i2 = 0;
for (let d2 of t2)
i2 += d2.lines;
if (i2 < 32) {
let d2 = [];
for (let p2 of t2)
p2.flatten(d2);
return new G$2(d2, e2);
}
let n2 = Math.max(
32,
i2 >> 5
/* Tree.BranchShift */
), r2 = n2 << 1, o = n2 >> 1, l = [], h2 = 0, a2 = -1, c2 = [];
function f2(d2) {
let p2;
if (d2.lines > r2 && d2 instanceof Ht)
for (let w2 of d2.children)
f2(w2);
else
d2.lines > o && (h2 > o || !h2) ? (u2(), l.push(d2)) : d2 instanceof G$2 && h2 && (p2 = c2[c2.length - 1]) instanceof G$2 && d2.lines + p2.lines <= 32 ? (h2 += d2.lines, a2 += d2.length + 1, c2[c2.length - 1] = new G$2(p2.text.concat(d2.text), p2.length + 1 + d2.length)) : (h2 + d2.lines > n2 && u2(), h2 += d2.lines, a2 += d2.length + 1, c2.push(d2));
}
function u2() {
h2 != 0 && (l.push(c2.length == 1 ? c2[0] : Ht.from(c2, a2)), a2 = -1, h2 = c2.length = 0);
}
for (let d2 of t2)
f2(d2);
return u2(), l.length == 1 ? l[0] : new Ht(l, e2);
}
}
E$1.empty = /* @__PURE__ */ new G$2([""], 0);
function Oc(s) {
let t2 = -1;
for (let e2 of s)
t2 += e2.length + 1;
return t2;
}
function _i(s, t2, e2 = 0, i2 = 1e9) {
for (let n2 = 0, r2 = 0, o = true; r2 < s.length && n2 <= i2; r2++) {
let l = s[r2], h2 = n2 + l.length;
h2 >= e2 && (h2 > i2 && (l = l.slice(0, i2 - n2)), n2 < e2 && (l = l.slice(e2 - n2)), o ? (t2[t2.length - 1] += l, o = false) : t2.push(l)), n2 = h2 + 1;
}
return t2;
}
function dr(s, t2, e2) {
return _i(s, [""], t2, e2);
}
class li {
constructor(t2, e2 = 1) {
this.dir = e2, this.done = false, this.lineBreak = false, this.value = "", this.nodes = [t2], this.offsets = [e2 > 0 ? 1 : (t2 instanceof G$2 ? t2.text.length : t2.children.length) << 1];
}
nextInner(t2, e2) {
for (this.done = this.lineBreak = false; ; ) {
let i2 = this.nodes.length - 1, n2 = this.nodes[i2], r2 = this.offsets[i2], o = r2 >> 1, l = n2 instanceof G$2 ? n2.text.length : n2.children.length;
if (o == (e2 > 0 ? l : 0)) {
if (i2 == 0)
return this.done = true, this.value = "", this;
e2 > 0 && this.offsets[i2 - 1]++, this.nodes.pop(), this.offsets.pop();
} else if ((r2 & 1) == (e2 > 0 ? 0 : 1)) {
if (this.offsets[i2] += e2, t2 == 0)
return this.lineBreak = true, this.value = `
`, this;
t2--;
} else if (n2 instanceof G$2) {
let h2 = n2.text[o + (e2 < 0 ? -1 : 0)];
if (this.offsets[i2] += e2, h2.length > Math.max(0, t2))
return this.value = t2 == 0 ? h2 : e2 > 0 ? h2.slice(t2) : h2.slice(0, h2.length - t2), this;
t2 -= h2.length;
} else {
let h2 = n2.children[o + (e2 < 0 ? -1 : 0)];
t2 > h2.length ? (t2 -= h2.length, this.offsets[i2] += e2) : (e2 < 0 && this.offsets[i2]--, this.nodes.push(h2), this.offsets.push(e2 > 0 ? 1 : (h2 instanceof G$2 ? h2.text.length : h2.children.length) << 1));
}
}
}
next(t2 = 0) {
return t2 < 0 && (this.nextInner(-t2, -this.dir), t2 = this.value.length), this.nextInner(t2, this.dir);
}
}
class Jo {
constructor(t2, e2, i2) {
this.value = "", this.done = false, this.cursor = new li(t2, e2 > i2 ? -1 : 1), this.pos = e2 > i2 ? t2.length : 0, this.from = Math.min(e2, i2), this.to = Math.max(e2, i2);
}
nextInner(t2, e2) {
if (e2 < 0 ? this.pos <= this.from : this.pos >= this.to)
return this.value = "", this.done = true, this;
t2 += Math.max(0, e2 < 0 ? this.pos - this.to : this.from - this.pos);
let i2 = e2 < 0 ? this.pos - this.from : this.to - this.pos;
t2 > i2 && (t2 = i2), i2 -= t2;
let { value: n2 } = this.cursor.next(t2);
return this.pos += (n2.length + t2) * e2, this.value = n2.length <= i2 ? n2 : e2 < 0 ? n2.slice(n2.length - i2) : n2.slice(0, i2), this.done = !this.value, this;
}
next(t2 = 0) {
return t2 < 0 ? t2 = Math.max(t2, this.from - this.pos) : t2 > 0 && (t2 = Math.min(t2, this.to - this.pos)), this.nextInner(t2, this.cursor.dir);
}
get lineBreak() {
return this.cursor.lineBreak && this.value != "";
}
}
class Xo {
constructor(t2) {
this.inner = t2, this.afterBreak = true, this.value = "", this.done = false;
}
next(t2 = 0) {
let { done: e2, lineBreak: i2, value: n2 } = this.inner.next(t2);
return e2 ? (this.done = true, this.value = "") : i2 ? this.afterBreak ? this.value = "" : (this.afterBreak = true, this.next()) : (this.value = n2, this.afterBreak = false), this;
}
get lineBreak() {
return false;
}
}
typeof Symbol < "u" && (E$1.prototype[Symbol.iterator] = function() {
return this.iter();
}, li.prototype[Symbol.iterator] = Jo.prototype[Symbol.iterator] = Xo.prototype[Symbol.iterator] = function() {
return this;
});
class Mc {
/**
@internal
*/
constructor(t2, e2, i2, n2) {
this.from = t2, this.to = e2, this.number = i2, this.text = n2;
}
/**
The length of the line (not including any line break after it).
*/
get length() {
return this.to - this.from;
}
}
let Ie = /* @__PURE__ */ "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((s) => s ? parseInt(s, 36) : 1);
for (let s = 1; s < Ie.length; s++)
Ie[s] += Ie[s - 1];
function Dc(s) {
for (let t2 = 1; t2 < Ie.length; t2 += 2)
if (Ie[t2] > s)
return Ie[t2 - 1] <= s;
return false;
}
function pr(s) {
return s >= 127462 && s <= 127487;
}
const gr = 8205;
function xt(s, t2, e2 = true, i2 = true) {
return (e2 ? Yo : Tc)(s, t2, i2);
}
function Yo(s, t2, e2) {
if (t2 == s.length)
return t2;
t2 && Zo(s.charCodeAt(t2)) && tl(s.charCodeAt(t2 - 1)) && t2--;
let i2 = hi(s, t2);
for (t2 += es(i2); t2 < s.length; ) {
let n2 = hi(s, t2);
if (i2 == gr || n2 == gr || e2 && Dc(n2))
t2 += es(n2), i2 = n2;
else if (pr(n2)) {
let r2 = 0, o = t2 - 2;
for (; o >= 0 && pr(hi(s, o)); )
r2++, o -= 2;
if (r2 % 2 == 0)
break;
t2 += 2;
} else
break;
}
return t2;
}
function Tc(s, t2, e2) {
for (; t2 > 0; ) {
let i2 = Yo(s, t2 - 2, e2);
if (i2 < t2)
return i2;
t2--;
}
return 0;
}
function Zo(s) {
return s >= 56320 && s < 57344;
}
function tl(s) {
return s >= 55296 && s < 56320;
}
function hi(s, t2) {
let e2 = s.charCodeAt(t2);
if (!tl(e2) || t2 + 1 == s.length)
return e2;
let i2 = s.charCodeAt(t2 + 1);
return Zo(i2) ? (e2 - 55296 << 10) + (i2 - 56320) + 65536 : e2;
}
function es(s) {
return s < 65536 ? 1 : 2;
}
const is = /\r\n?|\n/;
var gt = /* @__PURE__ */ function(s) {
return s[s.Simple = 0] = "Simple", s[s.TrackDel = 1] = "TrackDel", s[s.TrackBefore = 2] = "TrackBefore", s[s.TrackAfter = 3] = "TrackAfter", s;
}(gt || (gt = {}));
class Yt {
// Sections are encoded as pairs of integers. The first is the
// length in the current document, and the second is -1 for
// unaffected sections, and the length of the replacement content
// otherwise. So an insertion would be (0, n>0), a deletion (n>0,
// 0), and a replacement two positive numbers.
/**
@internal
*/
constructor(t2) {
this.sections = t2;
}
/**
The length of the document before the change.
*/
get length() {
let t2 = 0;
for (let e2 = 0; e2 < this.sections.length; e2 += 2)
t2 += this.sections[e2];
return t2;
}
/**
The length of the document after the change.
*/
get newLength() {
let t2 = 0;
for (let e2 = 0; e2 < this.sections.length; e2 += 2) {
let i2 = this.sections[e2 + 1];
t2 += i2 < 0 ? this.sections[e2] : i2;
}
return t2;
}
/**
False when there are actual changes in this set.
*/
get empty() {
return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0;
}
/**
Iterate over the unchanged parts left by these changes. `posA`
provides the position of the range in the old document, `posB`
the new position in the changed document.
*/
iterGaps(t2) {
for (let e2 = 0, i2 = 0, n2 = 0; e2 < this.sections.length; ) {
let r2 = this.sections[e2++], o = this.sections[e2++];
o < 0 ? (t2(i2, n2, r2), n2 += r2) : n2 += o, i2 += r2;
}
}
/**
Iterate over the ranges changed by these changes. (See
[`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
variant that also provides you with the inserted text.)
`fromA`/`toA` provides the extent of the change in the starting
document, `fromB`/`toB` the extent of the replacement in the
changed document.
When `individual` is true, adjacent changes (which are kept
separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
reported separately.
*/
iterChangedRanges(t2, e2 = false) {
ns(this, t2, e2);
}
/**
Get a description of the inverted form of these changes.
*/
get invertedDesc() {
let t2 = [];
for (let e2 = 0; e2 < this.sections.length; ) {
let i2 = this.sections[e2++], n2 = this.sections[e2++];
n2 < 0 ? t2.push(i2, n2) : t2.push(n2, i2);
}
return new Yt(t2);
}
/**
Compute the combined effect of applying another set of changes
after this one. The length of the document after this set should
match the length before `other`.
*/
composeDesc(t2) {
return this.empty ? t2 : t2.empty ? this : el(this, t2);
}
/**
Map this description, which should start with the same document
as `other`, over another set of changes, so that it can be
applied after it. When `before` is true, map as if the changes
in `other` happened before the ones in `this`.
*/
mapDesc(t2, e2 = false) {
return t2.empty ? this : ss(this, t2, e2);
}
mapPos(t2, e2 = -1, i2 = gt.Simple) {
let n2 = 0, r2 = 0;
for (let o = 0; o < this.sections.length; ) {
let l = this.sections[o++], h2 = this.sections[o++], a2 = n2 + l;
if (h2 < 0) {
if (a2 > t2)
return r2 + (t2 - n2);
r2 += l;
} else {
if (i2 != gt.Simple && a2 >= t2 && (i2 == gt.TrackDel && n2 < t2 && a2 > t2 || i2 == gt.TrackBefore && n2 < t2 || i2 == gt.TrackAfter && a2 > t2))
return null;
if (a2 > t2 || a2 == t2 && e2 < 0 && !l)
return t2 == n2 || e2 < 0 ? r2 : r2 + h2;
r2 += h2;
}
n2 = a2;
}
if (t2 > n2)
throw new RangeError(`Position ${t2} is out of range for changeset of length ${n2}`);
return r2;
}
/**
Check whether these changes touch a given range. When one of the
changes entirely covers the range, the string `"cover"` is
returned.
*/
touchesRange(t2, e2 = t2) {
for (let i2 = 0, n2 = 0; i2 < this.sections.length && n2 <= e2; ) {
let r2 = this.sections[i2++], o = this.sections[i2++], l = n2 + r2;
if (o >= 0 && n2 <= e2 && l >= t2)
return n2 < t2 && l > e2 ? "cover" : true;
n2 = l;
}
return false;
}
/**
@internal
*/
toString() {
let t2 = "";
for (let e2 = 0; e2 < this.sections.length; ) {
let i2 = this.sections[e2++], n2 = this.sections[e2++];
t2 += (t2 ? " " : "") + i2 + (n2 >= 0 ? ":" + n2 : "");
}
return t2;
}
/**
Serialize this change desc to a JSON-representable value.
*/
toJSON() {
return this.sections;
}
/**
Create a change desc from its JSON representation (as produced
by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
*/
static fromJSON(t2) {
if (!Array.isArray(t2) || t2.length % 2 || t2.some((e2) => typeof e2 != "number"))
throw new RangeError("Invalid JSON representation of ChangeDesc");
return new Yt(t2);
}
/**
@internal
*/
static create(t2) {
return new Yt(t2);
}
}
class Z extends Yt {
constructor(t2, e2) {
super(t2), this.inserted = e2;
}
/**
Apply the changes to a document, returning the modified
document.
*/
apply(t2) {
if (this.length != t2.length)
throw new RangeError("Applying change set to a document with the wrong length");
return ns(this, (e2, i2, n2, r2, o) => t2 = t2.replace(n2, n2 + (i2 - e2), o), false), t2;
}
mapDesc(t2, e2 = false) {
return ss(this, t2, e2, true);
}
/**
Given the document as it existed _before_ the changes, return a
change set that represents the inverse of this set, which could
be used to go from the document created by the changes back to
the document as it existed before the changes.
*/
invert(t2) {
let e2 = this.sections.slice(), i2 = [];
for (let n2 = 0, r2 = 0; n2 < e2.length; n2 += 2) {
let o = e2[n2], l = e2[n2 + 1];
if (l >= 0) {
e2[n2] = l, e2[n2 + 1] = o;
let h2 = n2 >> 1;
for (; i2.length < h2; )
i2.push(E$1.empty);
i2.push(o ? t2.slice(r2, r2 + o) : E$1.empty);
}
r2 += o;
}
return new Z(e2, i2);
}
/**
Combine two subsequent change sets into a single set. `other`
must start in the document produced by `this`. If `this` goes
`docA` → `docB` and `other` represents `docB` → `docC`, the
returned value will represent the change `docA` → `docC`.
*/
compose(t2) {
return this.empty ? t2 : t2.empty ? this : el(this, t2, true);
}
/**
Given another change set starting in the same document, maps this
change set over the other, producing a new change set that can be
applied to the document produced by applying `other`. When
`before` is `true`, order changes as if `this` comes before
`other`, otherwise (the default) treat `other` as coming first.
Given two changes `A` and `B`, `A.compose(B.map(A))` and
`B.compose(A.map(B, true))` will produce the same document. This
provides a basic form of [operational
transformation](https://en.wikipedia.org/wiki/Operational_transformation),
and can be used for collaborative editing.
*/
map(t2, e2 = false) {
return t2.empty ? this : ss(this, t2, e2, true);
}
/**
Iterate over the changed ranges in the document, calling `f` for
each, with the range in the original document (`fromA`-`toA`)
and the range that replaces it in the new document
(`fromB`-`toB`).
When `individual` is true, adjacent changes are reported
separately.
*/
iterChanges(t2, e2 = false) {
ns(this, t2, e2);
}
/**
Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
set.
*/
get desc() {
return Yt.create(this.sections);
}
/**
@internal
*/
filter(t2) {
let e2 = [], i2 = [], n2 = [], r2 = new ci(this);
t:
for (let o = 0, l = 0; ; ) {
let h2 = o == t2.length ? 1e9 : t2[o++];
for (; l < h2 || l == h2 && r2.len == 0; ) {
if (r2.done)
break t;
let c2 = Math.min(r2.len, h2 - l);
ot(n2, c2, -1);
let f2 = r2.ins == -1 ? -1 : r2.off == 0 ? r2.ins : 0;
ot(e2, c2, f2), f2 > 0 && oe(i2, e2, r2.text), r2.forward(c2), l += c2;
}
let a2 = t2[o++];
for (; l < a2; ) {
if (r2.done)
break t;
let c2 = Math.min(r2.len, a2 - l);
ot(e2, c2, -1), ot(n2, c2, r2.ins == -1 ? -1 : r2.off == 0 ? r2.ins : 0), r2.forward(c2), l += c2;
}
}
return {
changes: new Z(e2, i2),
filtered: Yt.create(n2)
};
}
/**
Serialize this change set to a JSON-representable value.
*/
toJSON() {
let t2 = [];
for (let e2 = 0; e2 < this.sections.length; e2 += 2) {
let i2 = this.sections[e2], n2 = this.sections[e2 + 1];
n2 < 0 ? t2.push(i2) : n2 == 0 ? t2.push([i2]) : t2.push([i2].concat(this.inserted[e2 >> 1].toJSON()));
}
return t2;
}
/**
Create a change set for the given changes, for a document of the
given length, using `lineSep` as line separator.
*/
static of(t2, e2, i2) {
let n2 = [], r2 = [], o = 0, l = null;
function h2(c2 = false) {
if (!c2 && !n2.length)
return;
o < e2 && ot(n2, e2 - o, -1);
let f2 = new Z(n2, r2);
l = l ? l.compose(f2.map(l)) : f2, n2 = [], r2 = [], o = 0;
}
function a2(c2) {
if (Array.isArray(c2))
for (let f2 of c2)
a2(f2);
else if (c2 instanceof Z) {
if (c2.length != e2)
throw new RangeError(`Mismatched change set length (got ${c2.length}, expected ${e2})`);
h2(), l = l ? l.compose(c2.map(l)) : c2;
} else {
let { from: f2, to: u2 = f2, insert: d2 } = c2;
if (f2 > u2 || f2 < 0 || u2 > e2)
throw new RangeError(`Invalid change range ${f2} to ${u2} (in doc of length ${e2})`);
let p2 = d2 ? typeof d2 == "string" ? E$1.of(d2.split(i2 || is)) : d2 : E$1.empty, w2 = p2.length;
if (f2 == u2 && w2 == 0)
return;
f2 < o && h2(), f2 > o && ot(n2, f2 - o, -1), ot(n2, u2 - f2, w2), oe(r2, n2, p2), o = u2;
}
}
return a2(t2), h2(!l), l;
}
/**
Create an empty changeset of the given length.
*/
static empty(t2) {
return new Z(t2 ? [t2, -1] : [], []);
}
/**
Create a changeset from its JSON representation (as produced by
[`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
*/
static fromJSON(t2) {
if (!Array.isArray(t2))
throw new RangeError("Invalid JSON representation of ChangeSet");
let e2 = [], i2 = [];
for (let n2 = 0; n2 < t2.length; n2++) {
let r2 = t2[n2];
if (typeof r2 == "number")
e2.push(r2, -1);
else {
if (!Array.isArray(r2) || typeof r2[0] != "number" || r2.some((o, l) => l && typeof o != "string"))
throw new RangeError("Invalid JSON representation of ChangeSet");
if (r2.length == 1)
e2.push(r2[0], 0);
else {
for (; i2.length < n2; )
i2.push(E$1.empty);
i2[n2] = E$1.of(r2.slice(1)), e2.push(r2[0], i2[n2].length);
}
}
}
return new Z(e2, i2);
}
/**
@internal
*/
static createSet(t2, e2) {
return new Z(t2, e2);
}
}
function ot(s, t2, e2, i2 = false) {
if (t2 == 0 && e2 <= 0)
return;
let n2 = s.length - 2;
n2 >= 0 && e2 <= 0 && e2 == s[n2 + 1] ? s[n2] += t2 : t2 == 0 && s[n2] == 0 ? s[n2 + 1] += e2 : i2 ? (s[n2] += t2, s[n2 + 1] += e2) : s.push(t2, e2);
}
function oe(s, t2, e2) {
if (e2.length == 0)
return;
let i2 = t2.length - 2 >> 1;
if (i2 < s.length)
s[s.length - 1] = s[s.length - 1].append(e2);
else {
for (; s.length < i2; )
s.push(E$1.empty);
s.push(e2);
}
}
function ns(s, t2, e2) {
let i2 = s.inserted;
for (let n2 = 0, r2 = 0, o = 0; o < s.sections.length; ) {
let l = s.sections[o++], h2 = s.sections[o++];
if (h2 < 0)
n2 += l, r2 += l;
else {
let a2 = n2, c2 = r2, f2 = E$1.empty;
for (; a2 += l, c2 += h2, h2 && i2 && (f2 = f2.append(i2[o - 2 >> 1])), !(e2 || o == s.sections.length || s.sections[o + 1] < 0); )
l = s.sections[o++], h2 = s.sections[o++];
t2(n2, a2, r2, c2, f2), n2 = a2, r2 = c2;
}
}
}
function ss(s, t2, e2, i2 = false) {
let n2 = [], r2 = i2 ? [] : null, o = new ci(s), l = new ci(t2);
for (let h2 = -1; ; )
if (o.ins == -1 && l.ins == -1) {
let a2 = Math.min(o.len, l.len);
ot(n2, a2, -1), o.forward(a2), l.forward(a2);
} else if (l.ins >= 0 && (o.ins < 0 || h2 == o.i || o.off == 0 && (l.len < o.len || l.len == o.len && !e2))) {
let a2 = l.len;
for (ot(n2, l.ins, -1); a2; ) {
let c2 = Math.min(o.len, a2);
o.ins >= 0 && h2 < o.i && o.len <= c2 && (ot(n2, 0, o.ins), r2 && oe(r2, n2, o.text), h2 = o.i), o.forward(c2), a2 -= c2;
}
l.next();
} else if (o.ins >= 0) {
let a2 = 0, c2 = o.len;
for (; c2; )
if (l.ins == -1) {
let f2 = Math.min(c2, l.len);
a2 += f2, c2 -= f2, l.forward(f2);
} else if (l.ins == 0 && l.len < c2)
c2 -= l.len, l.next();
else
break;
ot(n2, a2, h2 < o.i ? o.ins : 0), r2 && h2 < o.i && oe(r2, n2, o.text), h2 = o.i, o.forward(o.len - c2);
} else {
if (o.done && l.done)
return r2 ? Z.createSet(n2, r2) : Yt.create(n2);
throw new Error("Mismatched change set lengths");
}
}
function el(s, t2, e2 = false) {
let i2 = [], n2 = e2 ? [] : null, r2 = new ci(s), o = new ci(t2);
for (let l = false; ; ) {
if (r2.done && o.done)
return n2 ? Z.createSet(i2, n2) : Yt.create(i2);
if (r2.ins == 0)
ot(i2, r2.len, 0, l), r2.next();
else if (o.len == 0 && !o.done)
ot(i2, 0, o.ins, l), n2 && oe(n2, i2, o.text), o.next();
else {
if (r2.done || o.done)
throw new Error("Mismatched change set lengths");
{
let h2 = Math.min(r2.len2, o.len), a2 = i2.length;
if (r2.ins == -1) {
let c2 = o.ins == -1 ? -1 : o.off ? 0 : o.ins;
ot(i2, h2, c2, l), n2 && c2 && oe(n2, i2, o.text);
} else
o.ins == -1 ? (ot(i2, r2.off ? 0 : r2.len, h2, l), n2 && oe(n2, i2, r2.textBit(h2))) : (ot(i2, r2.off ? 0 : r2.len, o.off ? 0 : o.ins, l), n2 && !o.off && oe(n2, i2, o.text));
l = (r2.ins > h2 || o.ins >= 0 && o.len > h2) && (l || i2.length > a2), r2.forward2(h2), o.forward(h2);
}
}
}
}
class ci {
constructor(t2) {
this.set = t2, this.i = 0, this.next();
}
next() {
let { sections: t2 } = this.set;
this.i < t2.length ? (this.len = t2[this.i++], this.ins = t2[this.i++]) : (this.len = 0, this.ins = -2), this.off = 0;
}
get done() {
return this.ins == -2;
}
get len2() {
return this.ins < 0 ? this.len : this.ins;
}
get text() {
let { inserted: t2 } = this.set, e2 = this.i - 2 >> 1;
return e2 >= t2.length ? E$1.empty : t2[e2];
}
textBit(t2) {
let { inserted: e2 } = this.set, i2 = this.i - 2 >> 1;
return i2 >= e2.length && !t2 ? E$1.empty : e2[i2].slice(this.off, t2 == null ? void 0 : this.off + t2);
}
forward(t2) {
t2 == this.len ? this.next() : (this.len -= t2, this.off += t2);
}
forward2(t2) {
this.ins == -1 ? this.forward(t2) : t2 == this.ins ? this.next() : (this.ins -= t2, this.off += t2);
}
}
class Ce {
constructor(t2, e2, i2) {
this.from = t2, this.to = e2, this.flags = i2;
}
/**
The anchor of the range—the side that doesn't move when you
extend it.
*/
get anchor() {
return this.flags & 16 ? this.to : this.from;
}
/**
The head of the range, which is moved when the range is
[extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
*/
get head() {
return this.flags & 16 ? this.from : this.to;
}
/**
True when `anchor` and `head` are at the same position.
*/
get empty() {
return this.from == this.to;
}
/**
If this is a cursor that is explicitly associated with the
character on one of its sides, this returns the side. -1 means
the character before its position, 1 the character after, and 0
means no association.
*/
get assoc() {
return this.flags & 4 ? -1 : this.flags & 8 ? 1 : 0;
}
/**
The bidirectional text level associated with this cursor, if
any.
*/
get bidiLevel() {
let t2 = this.flags & 3;
return t2 == 3 ? null : t2;
}
/**
The goal column (stored vertical offset) associated with a
cursor. This is used to preserve the vertical position when
[moving](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) across
lines of different length.
*/
get goalColumn() {
let t2 = this.flags >> 5;
return t2 == 33554431 ? void 0 : t2;
}
/**
Map this range through a change, producing a valid range in the
updated document.
*/
map(t2, e2 = -1) {
let i2, n2;
return this.empty ? i2 = n2 = t2.mapPos(this.from, e2) : (i2 = t2.mapPos(this.from, 1), n2 = t2.mapPos(this.to, -1)), i2 == this.from && n2 == this.to ? this : new Ce(i2, n2, this.flags);
}
/**
Extend this range to cover at least `from` to `to`.
*/
extend(t2, e2 = t2) {
if (t2 <= this.anchor && e2 >= this.anchor)
return b$2.range(t2, e2);
let i2 = Math.abs(t2 - this.anchor) > Math.abs(e2 - this.anchor) ? t2 : e2;
return b$2.range(this.anchor, i2);
}
/**
Compare this range to another range.
*/
eq(t2) {
return this.anchor == t2.anchor && this.head == t2.head;
}
/**
Return a JSON-serializable object representing the range.
*/
toJSON() {
return { anchor: this.anchor, head: this.head };
}
/**
Convert a JSON representation of a range to a `SelectionRange`
instance.
*/
static fromJSON(t2) {
if (!t2 || typeof t2.anchor != "number" || typeof t2.head != "number")
throw new RangeError("Invalid JSON representation for SelectionRange");
return b$2.range(t2.anchor, t2.head);
}
/**
@internal
*/
static create(t2, e2, i2) {
return new Ce(t2, e2, i2);
}
}
let b$2 = class b2 {
constructor(t2, e2) {
this.ranges = t2, this.mainIndex = e2;
}
/**
Map a selection through a change. Used to adjust the selection
position for changes.
*/
map(t2, e2 = -1) {
return t2.empty ? this : b2.create(this.ranges.map((i2) => i2.map(t2, e2)), this.mainIndex);
}
/**
Compare this selection to another selection.
*/
eq(t2) {
if (this.ranges.length != t2.ranges.length || this.mainIndex != t2.mainIndex)
return false;
for (let e2 = 0; e2 < this.ranges.length; e2++)
if (!this.ranges[e2].eq(t2.ranges[e2]))
return false;
return true;
}
/**
Get the primary selection range. Usually, you should make sure
your code applies to _all_ ranges, by using methods like
[`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).
*/
get main() {
return this.ranges[this.mainIndex];
}
/**
Make sure the selection only has one range. Returns a selection
holding only the main range from this selection.
*/
asSingle() {
return this.ranges.length == 1 ? this : new b2([this.main], 0);
}
/**
Extend this selection with an extra range.
*/
addRange(t2, e2 = true) {
return b2.create([t2].concat(this.ranges), e2 ? 0 : this.mainIndex + 1);
}
/**
Replace a given range with another range, and then normalize the
selection to merge and sort ranges if necessary.
*/
replaceRange(t2, e2 = this.mainIndex) {
let i2 = this.ranges.slice();
return i2[e2] = t2, b2.create(i2, this.mainIndex);
}
/**
Convert this selection to an object that can be serialized to
JSON.
*/
toJSON() {
return { ranges: this.ranges.map((t2) => t2.toJSON()), main: this.mainIndex };
}
/**
Create a selection from a JSON representation.
*/
static fromJSON(t2) {
if (!t2 || !Array.isArray(t2.ranges) || typeof t2.main != "number" || t2.main >= t2.ranges.length)
throw new RangeError("Invalid JSON representation for EditorSelection");
return new b2(t2.ranges.map((e2) => Ce.fromJSON(e2)), t2.main);
}
/**
Create a selection holding a single range.
*/
static single(t2, e2 = t2) {
return new b2([b2.range(t2, e2)], 0);
}
/**
Sort and merge the given set of ranges, creating a valid
selection.
*/
static create(t2, e2 = 0) {
if (t2.length == 0)
throw new RangeError("A selection needs at least one range");
for (let i2 = 0, n2 = 0; n2 < t2.length; n2++) {
let r2 = t2[n2];
if (r2.empty ? r2.from <= i2 : r2.from < i2)
return b2.normalized(t2.slice(), e2);
i2 = r2.to;
}
return new b2(t2, e2);
}
/**
Create a cursor selection range at the given position. You can
safely ignore the optional arguments in most situations.
*/
static cursor(t2, e2 = 0, i2, n2) {
return Ce.create(t2, t2, (e2 == 0 ? 0 : e2 < 0 ? 4 : 8) | (i2 == null ? 3 : Math.min(2, i2)) | (n2 ?? 33554431) << 5);
}
/**
Create a selection range.
*/
static range(t2, e2, i2, n2) {
let r2 = (i2 ?? 33554431) << 5 | (n2 == null ? 3 : Math.min(2, n2));
return e2 < t2 ? Ce.create(e2, t2, 24 | r2) : Ce.create(t2, e2, (e2 > t2 ? 4 : 0) | r2);
}
/**
@internal
*/
static normalized(t2, e2 = 0) {
let i2 = t2[e2];
t2.sort((n2, r2) => n2.from - r2.from), e2 = t2.indexOf(i2);
for (let n2 = 1; n2 < t2.length; n2++) {
let r2 = t2[n2], o = t2[n2 - 1];
if (r2.empty ? r2.from <= o.to : r2.from < o.to) {
let l = o.from, h2 = Math.max(r2.to, o.to);
n2 <= e2 && e2--, t2.splice(--n2, 2, r2.anchor > r2.head ? b2.range(h2, l) : b2.range(l, h2));
}
}
return new b2(t2, e2);
}
};
function il(s, t2) {
for (let e2 of s.ranges)
if (e2.to > t2)
throw new RangeError("Selection points outside of document");
}
let _s = 0;
class v {
constructor(t2, e2, i2, n2, r2) {
this.combine = t2, this.compareInput = e2, this.compare = i2, this.isStatic = n2, this.id = _s++, this.default = t2([]), this.extensions = typeof r2 == "function" ? r2(this) : r2;
}
/**
Define a new facet.
*/
static define(t2 = {}) {
return new v(t2.combine || ((e2) => e2), t2.compareInput || ((e2, i2) => e2 === i2), t2.compare || (t2.combine ? (e2, i2) => e2 === i2 : Ws), !!t2.static, t2.enables);
}
/**
Returns an extension that adds the given value to this facet.
*/
of(t2) {
return new Wi([], this, 0, t2);
}
/**
Create an extension that computes a value for the facet from a
state. You must take care to declare the parts of the state that
this value depends on, since your function is only called again
for a new state when one of those parts changed.
In cases where your value depends only on a single field, you'll
want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
*/
compute(t2, e2) {
if (this.isStatic)
throw new Error("Can't compute a static facet");
return new Wi(t2, this, 1, e2);
}
/**
Create an extension that computes zero or more values for this
facet from a state.
*/
computeN(t2, e2) {
if (this.isStatic)
throw new Error("Can't compute a static facet");
return new Wi(t2, this, 2, e2);
}
from(t2, e2) {
return e2 || (e2 = (i2) => i2), this.compute([t2], (i2) => e2(i2.field(t2)));
}
}
function Ws(s, t2) {
return s == t2 || s.length == t2.length && s.every((e2, i2) => e2 === t2[i2]);
}
class Wi {
constructor(t2, e2, i2, n2) {
this.dependencies = t2, this.facet = e2, this.type = i2, this.value = n2, this.id = _s++;
}
dynamicSlot(t2) {
var e2;
let i2 = this.value, n2 = this.facet.compareInput, r2 = this.id, o = t2[r2] >> 1, l = this.type == 2, h2 = false, a2 = false, c2 = [];
for (let f2 of this.dependencies)
f2 == "doc" ? h2 = true : f2 == "selection" ? a2 = true : ((e2 = t2[f2.id]) !== null && e2 !== void 0 ? e2 : 1) & 1 || c2.push(t2[f2.id]);
return {
create(f2) {
return f2.values[o] = i2(f2), 1;
},
update(f2, u2) {
if (h2 && u2.docChanged || a2 && (u2.docChanged || u2.selection) || rs(f2, c2)) {
let d2 = i2(f2);
if (l ? !mr(d2, f2.values[o], n2) : !n2(d2, f2.values[o]))
return f2.values[o] = d2, 1;
}
return 0;
},
reconfigure: (f2, u2) => {
let d2, p2 = u2.config.address[r2];
if (p2 != null) {
let w2 = tn(u2, p2);
if (this.dependencies.every((g) => g instanceof v ? u2.facet(g) === f2.facet(g) : g instanceof Bt ? u2.field(g, false) == f2.field(g, false) : true) || (l ? mr(d2 = i2(f2), w2, n2) : n2(d2 = i2(f2), w2)))
return f2.values[o] = w2, 0;
} else
d2 = i2(f2);
return f2.values[o] = d2, 1;
}
};
}
}
function mr(s, t2, e2) {
if (s.length != t2.length)
return false;
for (let i2 = 0; i2 < s.length; i2++)
if (!e2(s[i2], t2[i2]))
return false;
return true;
}
function rs(s, t2) {
let e2 = false;
for (let i2 of t2)
ai(s, i2) & 1 && (e2 = true);
return e2;
}
function Pc(s, t2, e2) {
let i2 = e2.map((h2) => s[h2.id]), n2 = e2.map((h2) => h2.type), r2 = i2.filter((h2) => !(h2 & 1)), o = s[t2.id] >> 1;
function l(h2) {
let a2 = [];
for (let c2 = 0; c2 < i2.length; c2++) {
let f2 = tn(h2, i2[c2]);
if (n2[c2] == 2)
for (let u2 of f2)
a2.push(u2);
else
a2.push(f2);
}
return t2.combine(a2);
}
return {
create(h2) {
for (let a2 of i2)
ai(h2, a2);
return h2.values[o] = l(h2), 1;
},
update(h2, a2) {
if (!rs(h2, r2))
return 0;
let c2 = l(h2);
return t2.compare(c2, h2.values[o]) ? 0 : (h2.values[o] = c2, 1);
},
reconfigure(h2, a2) {
let c2 = rs(h2, i2), f2 = a2.config.facets[t2.id], u2 = a2.facet(t2);
if (f2 && !c2 && Ws(e2, f2))
return h2.values[o] = u2, 0;
let d2 = l(h2);
return t2.compare(d2, u2) ? (h2.values[o] = u2, 0) : (h2.values[o] = d2, 1);
}
};
}
const wr = /* @__PURE__ */ v.define({ static: true });
class Bt {
constructor(t2, e2, i2, n2, r2) {
this.id = t2, this.createF = e2, this.updateF = i2, this.compareF = n2, this.spec = r2, this.provides = void 0;
}
/**
Define a state field.
*/
static define(t2) {
let e2 = new Bt(_s++, t2.create, t2.update, t2.compare || ((i2, n2) => i2 === n2), t2);
return t2.provide && (e2.provides = t2.provide(e2)), e2;
}
create(t2) {
let e2 = t2.facet(wr).find((i2) => i2.field == this);
return ((e2 == null ? void 0 : e2.create) || this.createF)(t2);
}
/**
@internal
*/
slot(t2) {
let e2 = t2[this.id] >> 1;
return {
create: (i2) => (i2.values[e2] = this.create(i2), 1),
update: (i2, n2) => {
let r2 = i2.values[e2], o = this.updateF(r2, n2);
return this.compareF(r2, o) ? 0 : (i2.values[e2] = o, 1);
},
reconfigure: (i2, n2) => n2.config.address[this.id] != null ? (i2.values[e2] = n2.field(this), 0) : (i2.values[e2] = this.create(i2), 1)
};
}
/**
Returns an extension that enables this field and overrides the
way it is initialized. Can be useful when you need to provide a
non-default starting value for the field.
*/
init(t2) {
return [this, wr.of({ field: this, create: t2 })];
}
/**
State field instances can be used as
[`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
given state.
*/
get extension() {
return this;
}
}
const ve = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
function Ze(s) {
return (t2) => new nl(t2, s);
}
const js = {
/**
The highest precedence level, for extensions that should end up
near the start of the precedence ordering.
*/
highest: /* @__PURE__ */ Ze(ve.highest),
/**
A higher-than-default precedence, for extensions that should
come before those with default precedence.
*/
high: /* @__PURE__ */ Ze(ve.high),
/**
The default precedence, which is also used for extensions
without an explicit precedence.
*/
default: /* @__PURE__ */ Ze(ve.default),
/**
A lower-than-default precedence.
*/
low: /* @__PURE__ */ Ze(ve.low),
/**
The lowest precedence level. Meant for things that should end up
near the end of the extension order.
*/
lowest: /* @__PURE__ */ Ze(ve.lowest)
};
class nl {
constructor(t2, e2) {
this.inner = t2, this.prec = e2;
}
}
class yi {
/**
Create an instance of this compartment to add to your [state
configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
*/
of(t2) {
return new os(this, t2);
}
/**
Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
reconfigures this compartment.
*/
reconfigure(t2) {
return yi.reconfigure.of({ compartment: this, extension: t2 });
}
/**
Get the current content of the compartment in the state, or
`undefined` if it isn't present.
*/
get(t2) {
return t2.config.compartments.get(this);
}
}
class os {
constructor(t2, e2) {
this.compartment = t2, this.inner = e2;
}
}
class Zi {
constructor(t2, e2, i2, n2, r2, o) {
for (this.base = t2, this.compartments = e2, this.dynamicSlots = i2, this.address = n2, this.staticValues = r2, this.facets = o, this.statusTemplate = []; this.statusTemplate.length < i2.length; )
this.statusTemplate.push(
0
/* SlotStatus.Unresolved */
);
}
staticFacet(t2) {
let e2 = this.address[t2.id];
return e2 == null ? t2.default : this.staticValues[e2 >> 1];
}
static resolve(t2, e2, i2) {
let n2 = [], r2 = /* @__PURE__ */ Object.create(null), o = /* @__PURE__ */ new Map();
for (let u2 of Bc(t2, e2, o))
u2 instanceof Bt ? n2.push(u2) : (r2[u2.facet.id] || (r2[u2.facet.id] = [])).push(u2);
let l = /* @__PURE__ */ Object.create(null), h2 = [], a2 = [];
for (let u2 of n2)
l[u2.id] = a2.length << 1, a2.push((d2) => u2.slot(d2));
let c2 = i2 == null ? void 0 : i2.config.facets;
for (let u2 in r2) {
let d2 = r2[u2], p2 = d2[0].facet, w2 = c2 && c2[u2] || [];
if (d2.every(
(g) => g.type == 0
/* Provider.Static */
))
if (l[p2.id] = h2.length << 1 | 1, Ws(w2, d2))
h2.push(i2.facet(p2));
else {
let g = p2.combine(d2.map((y2) => y2.value));
h2.push(i2 && p2.compare(g, i2.facet(p2)) ? i2.facet(p2) : g);
}
else {
for (let g of d2)
g.type == 0 ? (l[g.id] = h2.length << 1 | 1, h2.push(g.value)) : (l[g.id] = a2.length << 1, a2.push((y2) => g.dynamicSlot(y2)));
l[p2.id] = a2.length << 1, a2.push((g) => Pc(g, p2, d2));
}
}
let f2 = a2.map((u2) => u2(l));
return new Zi(t2, o, f2, l, h2, r2);
}
}
function Bc(s, t2, e2) {
let i2 = [[], [], [], [], []], n2 = /* @__PURE__ */ new Map();
function r2(o, l) {
let h2 = n2.get(o);
if (h2 != null) {
if (h2 <= l)
return;
let a2 = i2[h2].indexOf(o);
a2 > -1 && i2[h2].splice(a2, 1), o instanceof os && e2.delete(o.compartment);
}
if (n2.set(o, l), Array.isArray(o))
for (let a2 of o)
r2(a2, l);
else if (o instanceof os) {
if (e2.has(o.compartment))
throw new RangeError("Duplicate use of compartment in extensions");
let a2 = t2.get(o.compartment) || o.inner;
e2.set(o.compartment, a2), r2(a2, l);
} else if (o instanceof nl)
r2(o.inner, o.prec);
else if (o instanceof Bt)
i2[l].push(o), o.provides && r2(o.provides, l);
else if (o instanceof Wi)
i2[l].push(o), o.facet.extensions && r2(o.facet.extensions, ve.default);
else {
let a2 = o.extension;
if (!a2)
throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
r2(a2, l);
}
}
return r2(s, ve.default), i2.reduce((o, l) => o.concat(l));
}
function ai(s, t2) {
if (t2 & 1)
return 2;
let e2 = t2 >> 1, i2 = s.status[e2];
if (i2 == 4)
throw new Error("Cyclic dependency between fields and/or facets");
if (i2 & 2)
return i2;
s.status[e2] = 4;
let n2 = s.computeSlot(s, s.config.dynamicSlots[e2]);
return s.status[e2] = 2 | n2;
}
function tn(s, t2) {
return t2 & 1 ? s.config.staticValues[t2 >> 1] : s.values[t2 >> 1];
}
const sl = /* @__PURE__ */ v.define(), rl = /* @__PURE__ */ v.define({
combine: (s) => s.some((t2) => t2),
static: true
}), ol = /* @__PURE__ */ v.define({
combine: (s) => s.length ? s[0] : void 0,
static: true
}), ll = /* @__PURE__ */ v.define(), hl = /* @__PURE__ */ v.define(), al = /* @__PURE__ */ v.define(), cl = /* @__PURE__ */ v.define({
combine: (s) => s.length ? s[0] : false
});
class bi {
/**
@internal
*/
constructor(t2, e2) {
this.type = t2, this.value = e2;
}
/**
Define a new type of annotation.
*/
static define() {
return new Rc();
}
}
class Rc {
/**
Create an instance of this annotation.
*/
of(t2) {
return new bi(this, t2);
}
}
class Lc {
/**
@internal
*/
constructor(t2) {
this.map = t2;
}
/**
Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
type.
*/
of(t2) {
return new F(this, t2);
}
}
class F {
/**
@internal
*/
constructor(t2, e2) {
this.type = t2, this.value = e2;
}
/**
Map this effect through a position mapping. Will return
`undefined` when that ends up deleting the effect.
*/
map(t2) {
let e2 = this.type.map(this.value, t2);
return e2 === void 0 ? void 0 : e2 == this.value ? this : new F(this.type, e2);
}
/**
Tells you whether this effect object is of a given
[type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
*/
is(t2) {
return this.type == t2;
}
/**
Define a new effect type. The type parameter indicates the type
of values that his effect holds.
*/
static define(t2 = {}) {
return new Lc(t2.map || ((e2) => e2));
}
/**
Map an array of effects through a change set.
*/
static mapEffects(t2, e2) {
if (!t2.length)
return t2;
let i2 = [];
for (let n2 of t2) {
let r2 = n2.map(e2);
r2 && i2.push(r2);
}
return i2;
}
}
F.reconfigure = /* @__PURE__ */ F.define();
F.appendConfig = /* @__PURE__ */ F.define();
class lt {
constructor(t2, e2, i2, n2, r2, o) {
this.startState = t2, this.changes = e2, this.selection = i2, this.effects = n2, this.annotations = r2, this.scrollIntoView = o, this._doc = null, this._state = null, i2 && il(i2, e2.newLength), r2.some((l) => l.type == lt.time) || (this.annotations = r2.concat(lt.time.of(Date.now())));
}
/**
@internal
*/
static create(t2, e2, i2, n2, r2, o) {
return new lt(t2, e2, i2, n2, r2, o);
}
/**
The new document produced by the transaction. Contrary to
[`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
force the entire new state to be computed right away, so it is
recommended that [transaction
filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
when they need to look at the new document.
*/
get newDoc() {
return this._doc || (this._doc = this.changes.apply(this.startState.doc));
}
/**
The new selection produced by the transaction. If
[`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
current selection through the changes made by the transaction.
*/
get newSelection() {
return this.selection || this.startState.selection.map(this.changes);
}
/**
The new state created by the transaction. Computed on demand
(but retained for subsequent access), so it is recommended not to
access it in [transaction
filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
*/
get state() {
return this._state || this.startState.applyTransaction(this), this._state;
}
/**
Get the value of the given annotation type, if any.
*/
annotation(t2) {
for (let e2 of this.annotations)
if (e2.type == t2)
return e2.value;
}
/**
Indicates whether the transaction changed the document.
*/
get docChanged() {
return !this.changes.empty;
}
/**
Indicates whether this transaction reconfigures the state
(through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
with a top-level configuration
[effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
*/
get reconfigured() {
return this.startState.config != this.state.config;
}
/**
Returns true if the transaction has a [user
event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
or more specific than `event`. For example, if the transaction
has `"select.pointer"` as user event, `"select"` and
`"select.pointer"` will match it.
*/
isUserEvent(t2) {
let e2 = this.annotation(lt.userEvent);
return !!(e2 && (e2 == t2 || e2.length > t2.length && e2.slice(0, t2.length) == t2 && e2[t2.length] == "."));
}
}
lt.time = /* @__PURE__ */ bi.define();
lt.userEvent = /* @__PURE__ */ bi.define();
lt.addToHistory = /* @__PURE__ */ bi.define();
lt.remote = /* @__PURE__ */ bi.define();
function Ec(s, t2) {
let e2 = [];
for (let i2 = 0, n2 = 0; ; ) {
let r2, o;
if (i2 < s.length && (n2 == t2.length || t2[n2] >= s[i2]))
r2 = s[i2++], o = s[i2++];
else if (n2 < t2.length)
r2 = t2[n2++], o = t2[n2++];
else
return e2;
!e2.length || e2[e2.length - 1] < r2 ? e2.push(r2, o) : e2[e2.length - 1] < o && (e2[e2.length - 1] = o);
}
}
function fl(s, t2, e2) {
var i2;
let n2, r2, o;
return e2 ? (n2 = t2.changes, r2 = Z.empty(t2.changes.length), o = s.changes.compose(t2.changes)) : (n2 = t2.changes.map(s.changes), r2 = s.changes.mapDesc(t2.changes, true), o = s.changes.compose(n2)), {
changes: o,
selection: t2.selection ? t2.selection.map(r2) : (i2 = s.selection) === null || i2 === void 0 ? void 0 : i2.map(n2),
effects: F.mapEffects(s.effects, n2).concat(F.mapEffects(t2.effects, r2)),
annotations: s.annotations.length ? s.annotations.concat(t2.annotations) : t2.annotations,
scrollIntoView: s.scrollIntoView || t2.scrollIntoView
};
}
function ls(s, t2, e2) {
let i2 = t2.selection, n2 = He(t2.annotations);
return t2.userEvent && (n2 = n2.concat(lt.userEvent.of(t2.userEvent))), {
changes: t2.changes instanceof Z ? t2.changes : Z.of(t2.changes || [], e2, s.facet(ol)),
selection: i2 && (i2 instanceof b$2 ? i2 : b$2.single(i2.anchor, i2.head)),
effects: He(t2.effects),
annotations: n2,
scrollIntoView: !!t2.scrollIntoView
};
}
function ul(s, t2, e2) {
let i2 = ls(s, t2.length ? t2[0] : {}, s.doc.length);
t2.length && t2[0].filter === false && (e2 = false);
for (let r2 = 1; r2 < t2.length; r2++) {
t2[r2].filter === false && (e2 = false);
let o = !!t2[r2].sequential;
i2 = fl(i2, ls(s, t2[r2], o ? i2.changes.newLength : s.doc.length), o);
}
let n2 = lt.create(s, i2.changes, i2.selection, i2.effects, i2.annotations, i2.scrollIntoView);
return Vc(e2 ? Nc(n2) : n2);
}
function Nc(s) {
let t2 = s.startState, e2 = true;
for (let n2 of t2.facet(ll)) {
let r2 = n2(s);
if (r2 === false) {
e2 = false;
break;
}
Array.isArray(r2) && (e2 = e2 === true ? r2 : Ec(e2, r2));
}
if (e2 !== true) {
let n2, r2;
if (e2 === false)
r2 = s.changes.invertedDesc, n2 = Z.empty(t2.doc.length);
else {
let o = s.changes.filter(e2);
n2 = o.changes, r2 = o.filtered.mapDesc(o.changes).invertedDesc;
}
s = lt.create(t2, n2, s.selection && s.selection.map(r2), F.mapEffects(s.effects, r2), s.annotations, s.scrollIntoView);
}
let i2 = t2.facet(hl);
for (let n2 = i2.length - 1; n2 >= 0; n2--) {
let r2 = i2[n2](s);
r2 instanceof lt ? s = r2 : Array.isArray(r2) && r2.length == 1 && r2[0] instanceof lt ? s = r2[0] : s = ul(t2, He(r2), false);
}
return s;
}
function Vc(s) {
let t2 = s.startState, e2 = t2.facet(al), i2 = s;
for (let n2 = e2.length - 1; n2 >= 0; n2--) {
let r2 = e2[n2](s);
r2 && Object.keys(r2).length && (i2 = fl(i2, ls(t2, r2, s.changes.newLength), true));
}
return i2 == s ? s : lt.create(t2, s.changes, s.selection, i2.effects, i2.annotations, i2.scrollIntoView);
}
const Ic = [];
function He(s) {
return s == null ? Ic : Array.isArray(s) ? s : [s];
}
var Jt = /* @__PURE__ */ function(s) {
return s[s.Word = 0] = "Word", s[s.Space = 1] = "Space", s[s.Other = 2] = "Other", s;
}(Jt || (Jt = {}));
const Hc = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
let hs;
try {
hs = /* @__PURE__ */ new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
} catch {
}
function $c(s) {
if (hs)
return hs.test(s);
for (let t2 = 0; t2 < s.length; t2++) {
let e2 = s[t2];
if (/\w/.test(e2) || e2 > "€" && (e2.toUpperCase() != e2.toLowerCase() || Hc.test(e2)))
return true;
}
return false;
}
function Fc(s) {
return (t2) => {
if (!/\S/.test(t2))
return Jt.Space;
if ($c(t2))
return Jt.Word;
for (let e2 = 0; e2 < s.length; e2++)
if (t2.indexOf(s[e2]) > -1)
return Jt.Word;
return Jt.Other;
};
}
let N$2 = class N2 {
constructor(t2, e2, i2, n2, r2, o) {
this.config = t2, this.doc = e2, this.selection = i2, this.values = n2, this.status = t2.statusTemplate.slice(), this.computeSlot = r2, o && (o._state = this);
for (let l = 0; l < this.config.dynamicSlots.length; l++)
ai(this, l << 1);
this.computeSlot = null;
}
field(t2, e2 = true) {
let i2 = this.config.address[t2.id];
if (i2 == null) {
if (e2)
throw new RangeError("Field is not present in this state");
return;
}
return ai(this, i2), tn(this, i2);
}
/**
Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
can be passed. Unless
[`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
[changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
are assumed to start in the _current_ document (not the document
produced by previous specs), and its
[selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
[effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
to the document created by its _own_ changes. The resulting
transaction contains the combined effect of all the different
specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
specs take precedence over earlier ones.
*/
update(...t2) {
return ul(this, t2, true);
}
/**
@internal
*/
applyTransaction(t2) {
let e2 = this.config, { base: i2, compartments: n2 } = e2;
for (let o of t2.effects)
o.is(yi.reconfigure) ? (e2 && (n2 = /* @__PURE__ */ new Map(), e2.compartments.forEach((l, h2) => n2.set(h2, l)), e2 = null), n2.set(o.value.compartment, o.value.extension)) : o.is(F.reconfigure) ? (e2 = null, i2 = o.value) : o.is(F.appendConfig) && (e2 = null, i2 = He(i2).concat(o.value));
let r2;
e2 ? r2 = t2.startState.values.slice() : (e2 = Zi.resolve(i2, n2, this), r2 = new N2(e2, this.doc, this.selection, e2.dynamicSlots.map(() => null), (l, h2) => h2.reconfigure(l, this), null).values), new N2(e2, t2.newDoc, t2.newSelection, r2, (o, l) => l.update(o, t2), t2);
}
/**
Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
replaces every selection range with the given content.
*/
replaceSelection(t2) {
return typeof t2 == "string" && (t2 = this.toText(t2)), this.changeByRange((e2) => ({
changes: { from: e2.from, to: e2.to, insert: t2 },
range: b$2.cursor(e2.from + t2.length)
}));
}
/**
Create a set of changes and a new selection by running the given
function for each range in the active selection. The function
can return an optional set of changes (in the coordinate space
of the start document), plus an updated range (in the coordinate
space of the document produced by the call's own changes). This
method will merge all the changes and ranges into a single
changeset and selection, and return it as a [transaction
spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
[`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
*/
changeByRange(t2) {
let e2 = this.selection, i2 = t2(e2.ranges[0]), n2 = this.changes(i2.changes), r2 = [i2.range], o = He(i2.effects);
for (let l = 1; l < e2.ranges.length; l++) {
let h2 = t2(e2.ranges[l]), a2 = this.changes(h2.changes), c2 = a2.map(n2);
for (let u2 = 0; u2 < l; u2++)
r2[u2] = r2[u2].map(c2);
let f2 = n2.mapDesc(a2, true);
r2.push(h2.range.map(f2)), n2 = n2.compose(c2), o = F.mapEffects(o, c2).concat(F.mapEffects(He(h2.effects), f2));
}
return {
changes: n2,
selection: b$2.create(r2, e2.mainIndex),
effects: o
};
}
/**
Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
description, taking the state's document length and line
separator into account.
*/
changes(t2 = []) {
return t2 instanceof Z ? t2 : Z.of(t2, this.doc.length, this.facet(N2.lineSeparator));
}
/**
Using the state's [line
separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
[`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
*/
toText(t2) {
return E$1.of(t2.split(this.facet(N2.lineSeparator) || is));
}
/**
Return the given range of the document as a string.
*/
sliceDoc(t2 = 0, e2 = this.doc.length) {
return this.doc.sliceString(t2, e2, this.lineBreak);
}
/**
Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
*/
facet(t2) {
let e2 = this.config.address[t2.id];
return e2 == null ? t2.default : (ai(this, e2), tn(this, e2));
}
/**
Convert this state to a JSON-serializable object. When custom
fields should be serialized, you can pass them in as an object
mapping property names (in the resulting object, which should
not use `doc` or `selection`) to fields.
*/
toJSON(t2) {
let e2 = {
doc: this.sliceDoc(),
selection: this.selection.toJSON()
};
if (t2)
for (let i2 in t2) {
let n2 = t2[i2];
n2 instanceof Bt && this.config.address[n2.id] != null && (e2[i2] = n2.spec.toJSON(this.field(t2[i2]), this));
}
return e2;
}
/**
Deserialize a state from its JSON representation. When custom
fields should be deserialized, pass the same object you passed
to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
third argument.
*/
static fromJSON(t2, e2 = {}, i2) {
if (!t2 || typeof t2.doc != "string")
throw new RangeError("Invalid JSON representation for EditorState");
let n2 = [];
if (i2) {
for (let r2 in i2)
if (Object.prototype.hasOwnProperty.call(t2, r2)) {
let o = i2[r2], l = t2[r2];
n2.push(o.init((h2) => o.spec.fromJSON(l, h2)));
}
}
return N2.create({
doc: t2.doc,
selection: b$2.fromJSON(t2.selection),
extensions: e2.extensions ? n2.concat([e2.extensions]) : n2
});
}
/**
Create a new state. You'll usually only need this when
initializing an editor—updated states are created by applying
transactions.
*/
static create(t2 = {}) {
let e2 = Zi.resolve(t2.extensions || [], /* @__PURE__ */ new Map()), i2 = t2.doc instanceof E$1 ? t2.doc : E$1.of((t2.doc || "").split(e2.staticFacet(N2.lineSeparator) || is)), n2 = t2.selection ? t2.selection instanceof b$2 ? t2.selection : b$2.single(t2.selection.anchor, t2.selection.head) : b$2.single(0);
return il(n2, i2.length), e2.staticFacet(rl) || (n2 = n2.asSingle()), new N2(e2, i2, n2, e2.dynamicSlots.map(() => null), (r2, o) => o.create(r2), null);
}
/**
The size (in columns) of a tab in the document, determined by
the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
*/
get tabSize() {
return this.facet(N2.tabSize);
}
/**
Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
string for this state.
*/
get lineBreak() {
return this.facet(N2.lineSeparator) || `
`;
}
/**
Returns true when the editor is
[configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
*/
get readOnly() {
return this.facet(cl);
}
/**
Look up a translation for the given phrase (via the
[`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
original string if no translation is found.
If additional arguments are passed, they will be inserted in
place of markers like `$1` (for the first value) and `$2`, etc.
A single `$` is equivalent to `$1`, and `$$` will produce a
literal dollar sign.
*/
phrase(t2, ...e2) {
for (let i2 of this.facet(N2.phrases))
if (Object.prototype.hasOwnProperty.call(i2, t2)) {
t2 = i2[t2];
break;
}
return e2.length && (t2 = t2.replace(/\$(\$|\d*)/g, (i2, n2) => {
if (n2 == "$")
return "$";
let r2 = +(n2 || 1);
return !r2 || r2 > e2.length ? i2 : e2[r2 - 1];
})), t2;
}
/**
Find the values for a given language data field, provided by the
the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
Examples of language data fields are...
- [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
comment syntax.
- [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
for providing language-specific completion sources.
- [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
characters that should be considered part of words in this
language.
- [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
bracket closing behavior.
*/
languageDataAt(t2, e2, i2 = -1) {
let n2 = [];
for (let r2 of this.facet(sl))
for (let o of r2(this, e2, i2))
Object.prototype.hasOwnProperty.call(o, t2) && n2.push(o[t2]);
return n2;
}
/**
Return a function that can categorize strings (expected to
represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
into one of:
- Word (contains an alphanumeric character or a character
explicitly listed in the local language's `"wordChars"`
language data, which should be a string)
- Space (contains only whitespace)
- Other (anything else)
*/
charCategorizer(t2) {
return Fc(this.languageDataAt("wordChars", t2).join(""));
}
/**
Find the word at the given position, meaning the range
containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
around it. If no word characters are adjacent to the position,
this returns null.
*/
wordAt(t2) {
let { text: e2, from: i2, length: n2 } = this.doc.lineAt(t2), r2 = this.charCategorizer(t2), o = t2 - i2, l = t2 - i2;
for (; o > 0; ) {
let h2 = xt(e2, o, false);
if (r2(e2.slice(h2, o)) != Jt.Word)
break;
o = h2;
}
for (; l < n2; ) {
let h2 = xt(e2, l);
if (r2(e2.slice(l, h2)) != Jt.Word)
break;
l = h2;
}
return o == l ? null : b$2.range(o + i2, l + i2);
}
};
N$2.allowMultipleSelections = rl;
N$2.tabSize = /* @__PURE__ */ v.define({
combine: (s) => s.length ? s[0] : 4
});
N$2.lineSeparator = ol;
N$2.readOnly = cl;
N$2.phrases = /* @__PURE__ */ v.define({
compare(s, t2) {
let e2 = Object.keys(s), i2 = Object.keys(t2);
return e2.length == i2.length && e2.every((n2) => s[n2] == t2[n2]);
}
});
N$2.languageData = sl;
N$2.changeFilter = ll;
N$2.transactionFilter = hl;
N$2.transactionExtender = al;
yi.reconfigure = /* @__PURE__ */ F.define();
function Sn(s, t2, e2 = {}) {
let i2 = {};
for (let n2 of s)
for (let r2 of Object.keys(n2)) {
let o = n2[r2], l = i2[r2];
if (l === void 0)
i2[r2] = o;
else if (!(l === o || o === void 0))
if (Object.hasOwnProperty.call(e2, r2))
i2[r2] = e2[r2](l, o);
else
throw new Error("Config merge conflict for field " + r2);
}
for (let n2 in t2)
i2[n2] === void 0 && (i2[n2] = t2[n2]);
return i2;
}
class je {
/**
Compare this value with another value. Used when comparing
rangesets. The default implementation compares by identity.
Unless you are only creating a fixed number of unique instances
of your value type, it is a good idea to implement this
properly.
*/
eq(t2) {
return this == t2;
}
/**
Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
*/
range(t2, e2 = t2) {
return as.create(t2, e2, this);
}
}
je.prototype.startSide = je.prototype.endSide = 0;
je.prototype.point = false;
je.prototype.mapMode = gt.TrackDel;
let as = class dl {
constructor(t2, e2, i2) {
this.from = t2, this.to = e2, this.value = i2;
}
/**
@internal
*/
static create(t2, e2, i2) {
return new dl(t2, e2, i2);
}
};
function cs(s, t2) {
return s.from - t2.from || s.value.startSide - t2.value.startSide;
}
class qs {
constructor(t2, e2, i2, n2) {
this.from = t2, this.to = e2, this.value = i2, this.maxPoint = n2;
}
get length() {
return this.to[this.to.length - 1];
}
// Find the index of the given position and side. Use the ranges'
// `from` pos when `end == false`, `to` when `end == true`.
findIndex(t2, e2, i2, n2 = 0) {
let r2 = i2 ? this.to : this.from;
for (let o = n2, l = r2.length; ; ) {
if (o == l)
return o;
let h2 = o + l >> 1, a2 = r2[h2] - t2 || (i2 ? this.value[h2].endSide : this.value[h2].startSide) - e2;
if (h2 == o)
return a2 >= 0 ? o : l;
a2 >= 0 ? l = h2 : o = h2 + 1;
}
}
between(t2, e2, i2, n2) {
for (let r2 = this.findIndex(e2, -1e9, true), o = this.findIndex(i2, 1e9, false, r2); r2 < o; r2++)
if (n2(this.from[r2] + t2, this.to[r2] + t2, this.value[r2]) === false)
return false;
}
map(t2, e2) {
let i2 = [], n2 = [], r2 = [], o = -1, l = -1;
for (let h2 = 0; h2 < this.value.length; h2++) {
let a2 = this.value[h2], c2 = this.from[h2] + t2, f2 = this.to[h2] + t2, u2, d2;
if (c2 == f2) {
let p2 = e2.mapPos(c2, a2.startSide, a2.mapMode);
if (p2 == null || (u2 = d2 = p2, a2.startSide != a2.endSide && (d2 = e2.mapPos(c2, a2.endSide), d2 < u2)))
continue;
} else if (u2 = e2.mapPos(c2, a2.startSide), d2 = e2.mapPos(f2, a2.endSide), u2 > d2 || u2 == d2 && a2.startSide > 0 && a2.endSide <= 0)
continue;
(d2 - u2 || a2.endSide - a2.startSide) < 0 || (o < 0 && (o = u2), a2.point && (l = Math.max(l, d2 - u2)), i2.push(a2), n2.push(u2 - o), r2.push(d2 - o));
}
return { mapped: i2.length ? new qs(n2, r2, i2, l) : null, pos: o };
}
}
class $ {
constructor(t2, e2, i2, n2) {
this.chunkPos = t2, this.chunk = e2, this.nextLayer = i2, this.maxPoint = n2;
}
/**
@internal
*/
static create(t2, e2, i2, n2) {
return new $(t2, e2, i2, n2);
}
/**
@internal
*/
get length() {
let t2 = this.chunk.length - 1;
return t2 < 0 ? 0 : Math.max(this.chunkEnd(t2), this.nextLayer.length);
}
/**
The number of ranges in the set.
*/
get size() {
if (this.isEmpty)
return 0;
let t2 = this.nextLayer.size;
for (let e2 of this.chunk)
t2 += e2.value.length;
return t2;
}
/**
@internal
*/
chunkEnd(t2) {
return this.chunkPos[t2] + this.chunk[t2].length;
}
/**
Update the range set, optionally adding new ranges or filtering
out existing ones.
(Note: The type parameter is just there as a kludge to work
around TypeScript variance issues that prevented `RangeSet<X>`
from being a subtype of `RangeSet<Y>` when `X` is a subtype of
`Y`.)
*/
update(t2) {
let { add: e2 = [], sort: i2 = false, filterFrom: n2 = 0, filterTo: r2 = this.length } = t2, o = t2.filter;
if (e2.length == 0 && !o)
return this;
if (i2 && (e2 = e2.slice().sort(cs)), this.isEmpty)
return e2.length ? $.of(e2) : this;
let l = new pl(this, null, -1).goto(0), h2 = 0, a2 = [], c2 = new De();
for (; l.value || h2 < e2.length; )
if (h2 < e2.length && (l.from - e2[h2].from || l.startSide - e2[h2].value.startSide) >= 0) {
let f2 = e2[h2++];
c2.addInner(f2.from, f2.to, f2.value) || a2.push(f2);
} else
l.rangeIndex == 1 && l.chunkIndex < this.chunk.length && (h2 == e2.length || this.chunkEnd(l.chunkIndex) < e2[h2].from) && (!o || n2 > this.chunkEnd(l.chunkIndex) || r2 < this.chunkPos[l.chunkIndex]) && c2.addChunk(this.chunkPos[l.chunkIndex], this.chunk[l.chunkIndex]) ? l.nextChunk() : ((!o || n2 > l.to || r2 < l.from || o(l.from, l.to, l.value)) && (c2.addInner(l.from, l.to, l.value) || a2.push(as.create(l.from, l.to, l.value))), l.next());
return c2.finishInner(this.nextLayer.isEmpty && !a2.length ? $.empty : this.nextLayer.update({ add: a2, filter: o, filterFrom: n2, filterTo: r2 }));
}
/**
Map this range set through a set of changes, return the new set.
*/
map(t2) {
if (t2.empty || this.isEmpty)
return this;
let e2 = [], i2 = [], n2 = -1;
for (let o = 0; o < this.chunk.length; o++) {
let l = this.chunkPos[o], h2 = this.chunk[o], a2 = t2.touchesRange(l, l + h2.length);
if (a2 === false)
n2 = Math.max(n2, h2.maxPoint), e2.push(h2), i2.push(t2.mapPos(l));
else if (a2 === true) {
let { mapped: c2, pos: f2 } = h2.map(l, t2);
c2 && (n2 = Math.max(n2, c2.maxPoint), e2.push(c2), i2.push(f2));
}
}
let r2 = this.nextLayer.map(t2);
return e2.length == 0 ? r2 : new $(i2, e2, r2 || $.empty, n2);
}
/**
Iterate over the ranges that touch the region `from` to `to`,
calling `f` for each. There is no guarantee that the ranges will
be reported in any specific order. When the callback returns
`false`, iteration stops.
*/
between(t2, e2, i2) {
if (!this.isEmpty) {
for (let n2 = 0; n2 < this.chunk.length; n2++) {
let r2 = this.chunkPos[n2], o = this.chunk[n2];
if (e2 >= r2 && t2 <= r2 + o.length && o.between(r2, t2 - r2, e2 - r2, i2) === false)
return;
}
this.nextLayer.between(t2, e2, i2);
}
}
/**
Iterate over the ranges in this set, in order, including all
ranges that end at or after `from`.
*/
iter(t2 = 0) {
return fi.from([this]).goto(t2);
}
/**
@internal
*/
get isEmpty() {
return this.nextLayer == this;
}
/**
Iterate over the ranges in a collection of sets, in order,
starting from `from`.
*/
static iter(t2, e2 = 0) {
return fi.from(t2).goto(e2);
}
/**
Iterate over two groups of sets, calling methods on `comparator`
to notify it of possible differences.
*/
static compare(t2, e2, i2, n2, r2 = -1) {
let o = t2.filter((f2) => f2.maxPoint > 0 || !f2.isEmpty && f2.maxPoint >= r2), l = e2.filter((f2) => f2.maxPoint > 0 || !f2.isEmpty && f2.maxPoint >= r2), h2 = yr(o, l, i2), a2 = new ti(o, h2, r2), c2 = new ti(l, h2, r2);
i2.iterGaps((f2, u2, d2) => br(a2, f2, c2, u2, d2, n2)), i2.empty && i2.length == 0 && br(a2, 0, c2, 0, 0, n2);
}
/**
Compare the contents of two groups of range sets, returning true
if they are equivalent in the given range.
*/
static eq(t2, e2, i2 = 0, n2) {
n2 == null && (n2 = 1e9 - 1);
let r2 = t2.filter((c2) => !c2.isEmpty && e2.indexOf(c2) < 0), o = e2.filter((c2) => !c2.isEmpty && t2.indexOf(c2) < 0);
if (r2.length != o.length)
return false;
if (!r2.length)
return true;
let l = yr(r2, o), h2 = new ti(r2, l, 0).goto(i2), a2 = new ti(o, l, 0).goto(i2);
for (; ; ) {
if (h2.to != a2.to || !fs(h2.active, a2.active) || h2.point && (!a2.point || !h2.point.eq(a2.point)))
return false;
if (h2.to > n2)
return true;
h2.next(), a2.next();
}
}
/**
Iterate over a group of range sets at the same time, notifying
the iterator about the ranges covering every given piece of
content. Returns the open count (see
[`SpanIterator.span`](https://codemirror.net/6/docs/ref/#state.SpanIterator.span)) at the end
of the iteration.
*/
static spans(t2, e2, i2, n2, r2 = -1) {
let o = new ti(t2, null, r2).goto(e2), l = e2, h2 = o.openStart;
for (; ; ) {
let a2 = Math.min(o.to, i2);
if (o.point) {
let c2 = o.activeForPoint(o.to), f2 = o.pointFrom < e2 ? c2.length + 1 : Math.min(c2.length, h2);
n2.point(l, a2, o.point, c2, f2, o.pointRank), h2 = Math.min(o.openEnd(a2), c2.length);
} else
a2 > l && (n2.span(l, a2, o.active, h2), h2 = o.openEnd(a2));
if (o.to > i2)
return h2 + (o.point && o.to > i2 ? 1 : 0);
l = o.to, o.next();
}
}
/**
Create a range set for the given range or array of ranges. By
default, this expects the ranges to be _sorted_ (by start
position and, if two start at the same position,
`value.startSide`). You can pass `true` as second argument to
cause the method to sort them.
*/
static of(t2, e2 = false) {
let i2 = new De();
for (let n2 of t2 instanceof as ? [t2] : e2 ? zc(t2) : t2)
i2.add(n2.from, n2.to, n2.value);
return i2.finish();
}
}
$.empty = /* @__PURE__ */ new $([], [], null, -1);
function zc(s) {
if (s.length > 1)
for (let t2 = s[0], e2 = 1; e2 < s.length; e2++) {
let i2 = s[e2];
if (cs(t2, i2) > 0)
return s.slice().sort(cs);
t2 = i2;
}
return s;
}
$.empty.nextLayer = $.empty;
class De {
/**
Create an empty builder.
*/
constructor() {
this.chunks = [], this.chunkPos = [], this.chunkStart = -1, this.last = null, this.lastFrom = -1e9, this.lastTo = -1e9, this.from = [], this.to = [], this.value = [], this.maxPoint = -1, this.setMaxPoint = -1, this.nextLayer = null;
}
finishChunk(t2) {
this.chunks.push(new qs(this.from, this.to, this.value, this.maxPoint)), this.chunkPos.push(this.chunkStart), this.chunkStart = -1, this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint), this.maxPoint = -1, t2 && (this.from = [], this.to = [], this.value = []);
}
/**
Add a range. Ranges should be added in sorted (by `from` and
`value.startSide`) order.
*/
add(t2, e2, i2) {
this.addInner(t2, e2, i2) || (this.nextLayer || (this.nextLayer = new De())).add(t2, e2, i2);
}
/**
@internal
*/
addInner(t2, e2, i2) {
let n2 = t2 - this.lastTo || i2.startSide - this.last.endSide;
if (n2 <= 0 && (t2 - this.lastFrom || i2.startSide - this.last.startSide) < 0)
throw new Error("Ranges must be added sorted by `from` position and `startSide`");
return n2 < 0 ? false : (this.from.length == 250 && this.finishChunk(true), this.chunkStart < 0 && (this.chunkStart = t2), this.from.push(t2 - this.chunkStart), this.to.push(e2 - this.chunkStart), this.last = i2, this.lastFrom = t2, this.lastTo = e2, this.value.push(i2), i2.point && (this.maxPoint = Math.max(this.maxPoint, e2 - t2)), true);
}
/**
@internal
*/
addChunk(t2, e2) {
if ((t2 - this.lastTo || e2.value[0].startSide - this.last.endSide) < 0)
return false;
this.from.length && this.finishChunk(true), this.setMaxPoint = Math.max(this.setMaxPoint, e2.maxPoint), this.chunks.push(e2), this.chunkPos.push(t2);
let i2 = e2.value.length - 1;
return this.last = e2.value[i2], this.lastFrom = e2.from[i2] + t2, this.lastTo = e2.to[i2] + t2, true;
}
/**
Finish the range set. Returns the new set. The builder can't be
used anymore after this has been called.
*/
finish() {
return this.finishInner($.empty);
}
/**
@internal
*/
finishInner(t2) {
if (this.from.length && this.finishChunk(false), this.chunks.length == 0)
return t2;
let e2 = $.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(t2) : t2, this.setMaxPoint);
return this.from = null, e2;
}
}
function yr(s, t2, e2) {
let i2 = /* @__PURE__ */ new Map();
for (let r2 of s)
for (let o = 0; o < r2.chunk.length; o++)
r2.chunk[o].maxPoint <= 0 && i2.set(r2.chunk[o], r2.chunkPos[o]);
let n2 = /* @__PURE__ */ new Set();
for (let r2 of t2)
for (let o = 0; o < r2.chunk.length; o++) {
let l = i2.get(r2.chunk[o]);
l != null && (e2 ? e2.mapPos(l) : l) == r2.chunkPos[o] && !(e2 != null && e2.touchesRange(l, l + r2.chunk[o].length)) && n2.add(r2.chunk[o]);
}
return n2;
}
class pl {
constructor(t2, e2, i2, n2 = 0) {
this.layer = t2, this.skip = e2, this.minPoint = i2, this.rank = n2;
}
get startSide() {
return this.value ? this.value.startSide : 0;
}
get endSide() {
return this.value ? this.value.endSide : 0;
}
goto(t2, e2 = -1e9) {
return this.chunkIndex = this.rangeIndex = 0, this.gotoInner(t2, e2, false), this;
}
gotoInner(t2, e2, i2) {
for (; this.chunkIndex < this.layer.chunk.length; ) {
let n2 = this.layer.chunk[this.chunkIndex];
if (!(this.skip && this.skip.has(n2) || this.layer.chunkEnd(this.chunkIndex) < t2 || n2.maxPoint < this.minPoint))
break;
this.chunkIndex++, i2 = false;
}
if (this.chunkIndex < this.layer.chunk.length) {
let n2 = this.layer.chunk[this.chunkIndex].findIndex(t2 - this.layer.chunkPos[this.chunkIndex], e2, true);
(!i2 || this.rangeIndex < n2) && this.setRangeIndex(n2);
}
this.next();
}
forward(t2, e2) {
(this.to - t2 || this.endSide - e2) < 0 && this.gotoInner(t2, e2, true);
}
next() {
for (; ; )
if (this.chunkIndex == this.layer.chunk.length) {
this.from = this.to = 1e9, this.value = null;
break;
} else {
let t2 = this.layer.chunkPos[this.chunkIndex], e2 = this.layer.chunk[this.chunkIndex], i2 = t2 + e2.from[this.rangeIndex];
if (this.from = i2, this.to = t2 + e2.to[this.rangeIndex], this.value = e2.value[this.rangeIndex], this.setRangeIndex(this.rangeIndex + 1), this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
break;
}
}
setRangeIndex(t2) {
if (t2 == this.layer.chunk[this.chunkIndex].value.length) {
if (this.chunkIndex++, this.skip)
for (; this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]); )
this.chunkIndex++;
this.rangeIndex = 0;
} else
this.rangeIndex = t2;
}
nextChunk() {
this.chunkIndex++, this.rangeIndex = 0, this.next();
}
compare(t2) {
return this.from - t2.from || this.startSide - t2.startSide || this.rank - t2.rank || this.to - t2.to || this.endSide - t2.endSide;
}
}
class fi {
constructor(t2) {
this.heap = t2;
}
static from(t2, e2 = null, i2 = -1) {
let n2 = [];
for (let r2 = 0; r2 < t2.length; r2++)
for (let o = t2[r2]; !o.isEmpty; o = o.nextLayer)
o.maxPoint >= i2 && n2.push(new pl(o, e2, i2, r2));
return n2.length == 1 ? n2[0] : new fi(n2);
}
get startSide() {
return this.value ? this.value.startSide : 0;
}
goto(t2, e2 = -1e9) {
for (let i2 of this.heap)
i2.goto(t2, e2);
for (let i2 = this.heap.length >> 1; i2 >= 0; i2--)
Nn(this.heap, i2);
return this.next(), this;
}
forward(t2, e2) {
for (let i2 of this.heap)
i2.forward(t2, e2);
for (let i2 = this.heap.length >> 1; i2 >= 0; i2--)
Nn(this.heap, i2);
(this.to - t2 || this.value.endSide - e2) < 0 && this.next();
}
next() {
if (this.heap.length == 0)
this.from = this.to = 1e9, this.value = null, this.rank = -1;
else {
let t2 = this.heap[0];
this.from = t2.from, this.to = t2.to, this.value = t2.value, this.rank = t2.rank, t2.value && t2.next(), Nn(this.heap, 0);
}
}
}
function Nn(s, t2) {
for (let e2 = s[t2]; ; ) {
let i2 = (t2 << 1) + 1;
if (i2 >= s.length)
break;
let n2 = s[i2];
if (i2 + 1 < s.length && n2.compare(s[i2 + 1]) >= 0 && (n2 = s[i2 + 1], i2++), e2.compare(n2) < 0)
break;
s[i2] = e2, s[t2] = n2, t2 = i2;
}
}
class ti {
constructor(t2, e2, i2) {
this.minPoint = i2, this.active = [], this.activeTo = [], this.activeRank = [], this.minActive = -1, this.point = null, this.pointFrom = 0, this.pointRank = 0, this.to = -1e9, this.endSide = 0, this.openStart = -1, this.cursor = fi.from(t2, e2, i2);
}
goto(t2, e2 = -1e9) {
return this.cursor.goto(t2, e2), this.active.length = this.activeTo.length = this.activeRank.length = 0, this.minActive = -1, this.to = t2, this.endSide = e2, this.openStart = -1, this.next(), this;
}
forward(t2, e2) {
for (; this.minActive > -1 && (this.activeTo[this.minActive] - t2 || this.active[this.minActive].endSide - e2) < 0; )
this.removeActive(this.minActive);
this.cursor.forward(t2, e2);
}
removeActive(t2) {
Ci(this.active, t2), Ci(this.activeTo, t2), Ci(this.activeRank, t2), this.minActive = kr(this.active, this.activeTo);
}
addActive(t2) {
let e2 = 0, { value: i2, to: n2, rank: r2 } = this.cursor;
for (; e2 < this.activeRank.length && this.activeRank[e2] <= r2; )
e2++;
Ai(this.active, e2, i2), Ai(this.activeTo, e2, n2), Ai(this.activeRank, e2, r2), t2 && Ai(t2, e2, this.cursor.from), this.minActive = kr(this.active, this.activeTo);
}
// After calling this, if `this.point` != null, the next range is a
// point. Otherwise, it's a regular range, covered by `this.active`.
next() {
let t2 = this.to, e2 = this.point;
this.point = null;
let i2 = this.openStart < 0 ? [] : null;
for (; ; ) {
let n2 = this.minActive;
if (n2 > -1 && (this.activeTo[n2] - this.cursor.from || this.active[n2].endSide - this.cursor.startSide) < 0) {
if (this.activeTo[n2] > t2) {
this.to = this.activeTo[n2], this.endSide = this.active[n2].endSide;
break;
}
this.removeActive(n2), i2 && Ci(i2, n2);
} else if (this.cursor.value)
if (this.cursor.from > t2) {
this.to = this.cursor.from, this.endSide = this.cursor.startSide;
break;
} else {
let r2 = this.cursor.value;
if (!r2.point)
this.addActive(i2), this.cursor.next();
else if (e2 && this.cursor.to == this.to && this.cursor.from < this.cursor.to)
this.cursor.next();
else {
this.point = r2, this.pointFrom = this.cursor.from, this.pointRank = this.cursor.rank, this.to = this.cursor.to, this.endSide = r2.endSide, this.cursor.next(), this.forward(this.to, this.endSide);
break;
}
}
else {
this.to = this.endSide = 1e9;
break;
}
}
if (i2) {
this.openStart = 0;
for (let n2 = i2.length - 1; n2 >= 0 && i2[n2] < t2; n2--)
this.openStart++;
}
}
activeForPoint(t2) {
if (!this.active.length)
return this.active;
let e2 = [];
for (let i2 = this.active.length - 1; i2 >= 0 && !(this.activeRank[i2] < this.pointRank); i2--)
(this.activeTo[i2] > t2 || this.activeTo[i2] == t2 && this.active[i2].endSide >= this.point.endSide) && e2.push(this.active[i2]);
return e2.reverse();
}
openEnd(t2) {
let e2 = 0;
for (let i2 = this.activeTo.length - 1; i2 >= 0 && this.activeTo[i2] > t2; i2--)
e2++;
return e2;
}
}
function br(s, t2, e2, i2, n2, r2) {
s.goto(t2), e2.goto(i2);
let o = i2 + n2, l = i2, h2 = i2 - t2;
for (; ; ) {
let a2 = s.to + h2 - e2.to || s.endSide - e2.endSide, c2 = a2 < 0 ? s.to + h2 : e2.to, f2 = Math.min(c2, o);
if (s.point || e2.point ? s.point && e2.point && (s.point == e2.point || s.point.eq(e2.point)) && fs(s.activeForPoint(s.to + h2), e2.activeForPoint(e2.to)) || r2.comparePoint(l, f2, s.point, e2.point) : f2 > l && !fs(s.active, e2.active) && r2.compareRange(l, f2, s.active, e2.active), c2 > o)
break;
l = c2, a2 <= 0 && s.next(), a2 >= 0 && e2.next();
}
}
function fs(s, t2) {
if (s.length != t2.length)
return false;
for (let e2 = 0; e2 < s.length; e2++)
if (s[e2] != t2[e2] && !s[e2].eq(t2[e2]))
return false;
return true;
}
function Ci(s, t2) {
for (let e2 = t2, i2 = s.length - 1; e2 < i2; e2++)
s[e2] = s[e2 + 1];
s.pop();
}
function Ai(s, t2, e2) {
for (let i2 = s.length - 1; i2 >= t2; i2--)
s[i2 + 1] = s[i2];
s[t2] = e2;
}
function kr(s, t2) {
let e2 = -1, i2 = 1e9;
for (let n2 = 0; n2 < t2.length; n2++)
(t2[n2] - i2 || s[n2].endSide - s[e2].endSide) < 0 && (e2 = n2, i2 = t2[n2]);
return e2;
}
function Cn(s, t2, e2 = s.length) {
let i2 = 0;
for (let n2 = 0; n2 < e2; )
s.charCodeAt(n2) == 9 ? (i2 += t2 - i2 % t2, n2++) : (i2++, n2 = xt(s, n2));
return i2;
}
function _c(s, t2, e2, i2) {
for (let n2 = 0, r2 = 0; ; ) {
if (r2 >= t2)
return n2;
if (n2 == s.length)
break;
r2 += s.charCodeAt(n2) == 9 ? e2 - r2 % e2 : 1, n2 = xt(s, n2);
}
return i2 === true ? -1 : s.length;
}
const us = "ͼ", xr = typeof Symbol > "u" ? "__" + us : Symbol.for(us), ds = typeof Symbol > "u" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet"), vr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : {};
class de {
// :: (Object<Style>, ?{finish: ?(string) → string})
// Create a style module from the given spec.
//
// When `finish` is given, it is called on regular (non-`@`)
// selectors (after `&` expansion) to compute the final selector.
constructor(t2, e2) {
this.rules = [];
let { finish: i2 } = e2 || {};
function n2(o) {
return /^@/.test(o) ? [o] : o.split(/,\s*/);
}
function r2(o, l, h2, a2) {
let c2 = [], f2 = /^@(\w+)\b/.exec(o[0]), u2 = f2 && f2[1] == "keyframes";
if (f2 && l == null)
return h2.push(o[0] + ";");
for (let d2 in l) {
let p2 = l[d2];
if (/&/.test(d2))
r2(
d2.split(/,\s*/).map((w2) => o.map((g) => w2.replace(/&/, g))).reduce((w2, g) => w2.concat(g)),
p2,
h2
);
else if (p2 && typeof p2 == "object") {
if (!f2)
throw new RangeError("The value of a property (" + d2 + ") should be a primitive value.");
r2(n2(d2), p2, c2, u2);
} else
p2 != null && c2.push(d2.replace(/_.*/, "").replace(/[A-Z]/g, (w2) => "-" + w2.toLowerCase()) + ": " + p2 + ";");
}
(c2.length || u2) && h2.push((i2 && !f2 && !a2 ? o.map(i2) : o).join(", ") + " {" + c2.join(" ") + "}");
}
for (let o in t2)
r2(n2(o), t2[o], this.rules);
}
// :: () → string
// Returns a string containing the module's CSS rules.
getRules() {
return this.rules.join(`
`);
}
// :: () → string
// Generate a new unique CSS class name.
static newName() {
let t2 = vr[xr] || 1;
return vr[xr] = t2 + 1, us + t2.toString(36);
}
// :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>)
//
// Mount the given set of modules in the given DOM root, which ensures
// that the CSS rules defined by the module are available in that
// context.
//
// Rules are only added to the document once per root.
//
// Rule order will follow the order of the modules, so that rules from
// modules later in the array take precedence of those from earlier
// modules. If you call this function multiple times for the same root
// in a way that changes the order of already mounted modules, the old
// order will be changed.
static mount(t2, e2) {
(t2[ds] || new Wc(t2)).mount(Array.isArray(e2) ? e2 : [e2]);
}
}
let Oi = null;
class Wc {
constructor(t2) {
if (!t2.head && t2.adoptedStyleSheets && typeof CSSStyleSheet < "u") {
if (Oi)
return t2.adoptedStyleSheets = [Oi.sheet].concat(t2.adoptedStyleSheets), t2[ds] = Oi;
this.sheet = new CSSStyleSheet(), t2.adoptedStyleSheets = [this.sheet].concat(t2.adoptedStyleSheets), Oi = this;
} else {
this.styleTag = (t2.ownerDocument || t2).createElement("style");
let e2 = t2.head || t2;
e2.insertBefore(this.styleTag, e2.firstChild);
}
this.modules = [], t2[ds] = this;
}
mount(t2) {
let e2 = this.sheet, i2 = 0, n2 = 0;
for (let r2 = 0; r2 < t2.length; r2++) {
let o = t2[r2], l = this.modules.indexOf(o);
if (l < n2 && l > -1 && (this.modules.splice(l, 1), n2--, l = -1), l == -1) {
if (this.modules.splice(n2++, 0, o), e2)
for (let h2 = 0; h2 < o.rules.length; h2++)
e2.insertRule(o.rules[h2], i2++);
} else {
for (; n2 < l; )
i2 += this.modules[n2++].rules.length;
i2 += o.rules.length, n2++;
}
}
if (!e2) {
let r2 = "";
for (let o = 0; o < this.modules.length; o++)
r2 += this.modules[o].getRules() + `
`;
this.styleTag.textContent = r2;
}
}
}
var pe = {
8: "Backspace",
9: "Tab",
10: "Enter",
12: "NumLock",
13: "Enter",
16: "Shift",
17: "Control",
18: "Alt",
20: "CapsLock",
27: "Escape",
32: " ",
33: "PageUp",
34: "PageDown",
35: "End",
36: "Home",
37: "ArrowLeft",
38: "ArrowUp",
39: "ArrowRight",
40: "ArrowDown",
44: "PrintScreen",
45: "Insert",
46: "Delete",
59: ";",
61: "=",
91: "Meta",
92: "Meta",
106: "*",
107: "+",
108: ",",
109: "-",
110: ".",
111: "/",
144: "NumLock",
145: "ScrollLock",
160: "Shift",
161: "Shift",
162: "Control",
163: "Control",
164: "Alt",
165: "Alt",
173: "-",
186: ";",
187: "=",
188: ",",
189: "-",
190: ".",
191: "/",
192: "`",
219: "[",
220: "\\",
221: "]",
222: "'"
}, ui = {
48: ")",
49: "!",
50: "@",
51: "#",
52: "$",
53: "%",
54: "^",
55: "&",
56: "*",
57: "(",
59: ":",
61: "+",
173: "_",
186: ":",
187: "+",
188: "<",
189: "_",
190: ">",
191: "?",
192: "~",
219: "{",
220: "|",
221: "}",
222: '"'
}, Sr = typeof navigator < "u" && /Chrome\/(\d+)/.exec(navigator.userAgent), jc = typeof navigator < "u" && /Mac/.test(navigator.platform), qc = typeof navigator < "u" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent), Kc = jc || Sr && +Sr[1] < 57;
for (var nt = 0; nt < 10; nt++)
pe[48 + nt] = pe[96 + nt] = String(nt);
for (var nt = 1; nt <= 24; nt++)
pe[nt + 111] = "F" + nt;
for (var nt = 65; nt <= 90; nt++)
pe[nt] = String.fromCharCode(nt + 32), ui[nt] = String.fromCharCode(nt);
for (var Vn in pe)
ui.hasOwnProperty(Vn) || (ui[Vn] = pe[Vn]);
function Gc(s) {
var t2 = Kc && (s.ctrlKey || s.altKey || s.metaKey) || qc && s.shiftKey && s.key && s.key.length == 1 || s.key == "Unidentified", e2 = !t2 && s.key || (s.shiftKey ? ui : pe)[s.keyCode] || s.key || "Unidentified";
return e2 == "Esc" && (e2 = "Escape"), e2 == "Del" && (e2 = "Delete"), e2 == "Left" && (e2 = "ArrowLeft"), e2 == "Up" && (e2 = "ArrowUp"), e2 == "Right" && (e2 = "ArrowRight"), e2 == "Down" && (e2 = "ArrowDown"), e2;
}
function en(s) {
let t2;
return s.nodeType == 11 ? t2 = s.getSelection ? s : s.ownerDocument : t2 = s, t2.getSelection();
}
function qe(s, t2) {
return t2 ? s == t2 || s.contains(t2.nodeType != 1 ? t2.parentNode : t2) : false;
}
function Uc(s) {
let t2 = s.activeElement;
for (; t2 && t2.shadowRoot; )
t2 = t2.shadowRoot.activeElement;
return t2;
}
function ji(s, t2) {
if (!t2.anchorNode)
return false;
try {
return qe(s, t2.anchorNode);
} catch {
return false;
}
}
function di(s) {
return s.nodeType == 3 ? Ke(s, 0, s.nodeValue.length).getClientRects() : s.nodeType == 1 ? s.getClientRects() : [];
}
function nn(s, t2, e2, i2) {
return e2 ? Cr(s, t2, e2, i2, -1) || Cr(s, t2, e2, i2, 1) : false;
}
function sn(s) {
for (var t2 = 0; ; t2++)
if (s = s.previousSibling, !s)
return t2;
}
function Cr(s, t2, e2, i2, n2) {
for (; ; ) {
if (s == e2 && t2 == i2)
return true;
if (t2 == (n2 < 0 ? 0 : pi(s))) {
if (s.nodeName == "DIV")
return false;
let r2 = s.parentNode;
if (!r2 || r2.nodeType != 1)
return false;
t2 = sn(s) + (n2 < 0 ? 0 : 1), s = r2;
} else if (s.nodeType == 1) {
if (s = s.childNodes[t2 + (n2 < 0 ? -1 : 0)], s.nodeType == 1 && s.contentEditable == "false")
return false;
t2 = n2 < 0 ? pi(s) : 0;
} else
return false;
}
}
function pi(s) {
return s.nodeType == 3 ? s.nodeValue.length : s.childNodes.length;
}
const gl = { left: 0, right: 0, top: 0, bottom: 0 };
function Ks(s, t2) {
let e2 = t2 ? s.left : s.right;
return { left: e2, right: e2, top: s.top, bottom: s.bottom };
}
function Qc(s) {
return {
left: 0,
right: s.innerWidth,
top: 0,
bottom: s.innerHeight
};
}
function Jc(s, t2, e2, i2, n2, r2, o, l) {
let h2 = s.ownerDocument, a2 = h2.defaultView || window;
for (let c2 = s; c2; )
if (c2.nodeType == 1) {
let f2, u2 = c2 == h2.body;
if (u2)
f2 = Qc(a2);
else {
if (c2.scrollHeight <= c2.clientHeight && c2.scrollWidth <= c2.clientWidth) {
c2 = c2.assignedSlot || c2.parentNode;
continue;
}
let w2 = c2.getBoundingClientRect();
f2 = {
left: w2.left,
right: w2.left + c2.clientWidth,
top: w2.top,
bottom: w2.top + c2.clientHeight
};
}
let d2 = 0, p2 = 0;
if (n2 == "nearest")
t2.top < f2.top ? (p2 = -(f2.top - t2.top + o), e2 > 0 && t2.bottom > f2.bottom + p2 && (p2 = t2.bottom - f2.bottom + p2 + o)) : t2.bottom > f2.bottom && (p2 = t2.bottom - f2.bottom + o, e2 < 0 && t2.top - p2 < f2.top && (p2 = -(f2.top + p2 - t2.top + o)));
else {
let w2 = t2.bottom - t2.top, g = f2.bottom - f2.top;
p2 = (n2 == "center" && w2 <= g ? t2.top + w2 / 2 - g / 2 : n2 == "start" || n2 == "center" && e2 < 0 ? t2.top - o : t2.bottom - g + o) - f2.top;
}
if (i2 == "nearest" ? t2.left < f2.left ? (d2 = -(f2.left - t2.left + r2), e2 > 0 && t2.right > f2.right + d2 && (d2 = t2.right - f2.right + d2 + r2)) : t2.right > f2.right && (d2 = t2.right - f2.right + r2, e2 < 0 && t2.left < f2.left + d2 && (d2 = -(f2.left + d2 - t2.left + r2))) : d2 = (i2 == "center" ? t2.left + (t2.right - t2.left) / 2 - (f2.right - f2.left) / 2 : i2 == "start" == l ? t2.left - r2 : t2.right - (f2.right - f2.left) + r2) - f2.left, d2 || p2)
if (u2)
a2.scrollBy(d2, p2);
else {
let w2 = 0, g = 0;
if (p2) {
let y2 = c2.scrollTop;
c2.scrollTop += p2, g = c2.scrollTop - y2;
}
if (d2) {
let y2 = c2.scrollLeft;
c2.scrollLeft += d2, w2 = c2.scrollLeft - y2;
}
t2 = {
left: t2.left - w2,
top: t2.top - g,
right: t2.right - w2,
bottom: t2.bottom - g
}, w2 && Math.abs(w2 - d2) < 1 && (i2 = "nearest"), g && Math.abs(g - p2) < 1 && (n2 = "nearest");
}
if (u2)
break;
c2 = c2.assignedSlot || c2.parentNode;
} else if (c2.nodeType == 11)
c2 = c2.host;
else
break;
}
function Xc(s) {
let t2 = s.ownerDocument;
for (let e2 = s.parentNode; e2 && e2 != t2.body; )
if (e2.nodeType == 1) {
if (e2.scrollHeight > e2.clientHeight || e2.scrollWidth > e2.clientWidth)
return e2;
e2 = e2.assignedSlot || e2.parentNode;
} else if (e2.nodeType == 11)
e2 = e2.host;
else
break;
return null;
}
class Yc {
constructor() {
this.anchorNode = null, this.anchorOffset = 0, this.focusNode = null, this.focusOffset = 0;
}
eq(t2) {
return this.anchorNode == t2.anchorNode && this.anchorOffset == t2.anchorOffset && this.focusNode == t2.focusNode && this.focusOffset == t2.focusOffset;
}
setRange(t2) {
this.set(t2.anchorNode, t2.anchorOffset, t2.focusNode, t2.focusOffset);
}
set(t2, e2, i2, n2) {
this.anchorNode = t2, this.anchorOffset = e2, this.focusNode = i2, this.focusOffset = n2;
}
}
let Ne = null;
function ml(s) {
if (s.setActive)
return s.setActive();
if (Ne)
return s.focus(Ne);
let t2 = [];
for (let e2 = s; e2 && (t2.push(e2, e2.scrollTop, e2.scrollLeft), e2 != e2.ownerDocument); e2 = e2.parentNode)
;
if (s.focus(Ne == null ? {
get preventScroll() {
return Ne = { preventScroll: true }, true;
}
} : void 0), !Ne) {
Ne = false;
for (let e2 = 0; e2 < t2.length; ) {
let i2 = t2[e2++], n2 = t2[e2++], r2 = t2[e2++];
i2.scrollTop != n2 && (i2.scrollTop = n2), i2.scrollLeft != r2 && (i2.scrollLeft = r2);
}
}
}
let Ar;
function Ke(s, t2, e2 = t2) {
let i2 = Ar || (Ar = document.createRange());
return i2.setEnd(s, e2), i2.setStart(s, t2), i2;
}
function $e(s, t2, e2) {
let i2 = { key: t2, code: t2, keyCode: e2, which: e2, cancelable: true }, n2 = new KeyboardEvent("keydown", i2);
n2.synthetic = true, s.dispatchEvent(n2);
let r2 = new KeyboardEvent("keyup", i2);
return r2.synthetic = true, s.dispatchEvent(r2), n2.defaultPrevented || r2.defaultPrevented;
}
function Zc(s) {
for (; s; ) {
if (s && (s.nodeType == 9 || s.nodeType == 11 && s.host))
return s;
s = s.assignedSlot || s.parentNode;
}
return null;
}
function wl(s) {
for (; s.attributes.length; )
s.removeAttributeNode(s.attributes[0]);
}
function tf(s, t2) {
let e2 = t2.focusNode, i2 = t2.focusOffset;
if (!e2 || t2.anchorNode != e2 || t2.anchorOffset != i2)
return false;
for (; ; )
if (i2) {
if (e2.nodeType != 1)
return false;
let n2 = e2.childNodes[i2 - 1];
n2.contentEditable == "false" ? i2-- : (e2 = n2, i2 = pi(e2));
} else {
if (e2 == s)
return true;
i2 = sn(e2), e2 = e2.parentNode;
}
}
class ht {
constructor(t2, e2, i2 = true) {
this.node = t2, this.offset = e2, this.precise = i2;
}
static before(t2, e2) {
return new ht(t2.parentNode, sn(t2), e2);
}
static after(t2, e2) {
return new ht(t2.parentNode, sn(t2) + 1, e2);
}
}
const Gs = [];
let W$1 = class W2 {
constructor() {
this.parent = null, this.dom = null, this.dirty = 2;
}
get editorView() {
if (!this.parent)
throw new Error("Accessing view in orphan content view");
return this.parent.editorView;
}
get overrideDOMText() {
return null;
}
get posAtStart() {
return this.parent ? this.parent.posBefore(this) : 0;
}
get posAtEnd() {
return this.posAtStart + this.length;
}
posBefore(t2) {
let e2 = this.posAtStart;
for (let i2 of this.children) {
if (i2 == t2)
return e2;
e2 += i2.length + i2.breakAfter;
}
throw new RangeError("Invalid child in posBefore");
}
posAfter(t2) {
return this.posBefore(t2) + t2.length;
}
// Will return a rectangle directly before (when side < 0), after
// (side > 0) or directly on (when the browser supports it) the
// given position.
coordsAt(t2, e2) {
return null;
}
sync(t2) {
if (this.dirty & 2) {
let e2 = this.dom, i2 = null, n2;
for (let r2 of this.children) {
if (r2.dirty) {
if (!r2.dom && (n2 = i2 ? i2.nextSibling : e2.firstChild)) {
let o = W2.get(n2);
(!o || !o.parent && o.canReuseDOM(r2)) && r2.reuseDOM(n2);
}
r2.sync(t2), r2.dirty = 0;
}
if (n2 = i2 ? i2.nextSibling : e2.firstChild, t2 && !t2.written && t2.node == e2 && n2 != r2.dom && (t2.written = true), r2.dom.parentNode == e2)
for (; n2 && n2 != r2.dom; )
n2 = Or(n2);
else
e2.insertBefore(r2.dom, n2);
i2 = r2.dom;
}
for (n2 = i2 ? i2.nextSibling : e2.firstChild, n2 && t2 && t2.node == e2 && (t2.written = true); n2; )
n2 = Or(n2);
} else if (this.dirty & 1)
for (let e2 of this.children)
e2.dirty && (e2.sync(t2), e2.dirty = 0);
}
reuseDOM(t2) {
}
localPosFromDOM(t2, e2) {
let i2;
if (t2 == this.dom)
i2 = this.dom.childNodes[e2];
else {
let n2 = pi(t2) == 0 ? 0 : e2 == 0 ? -1 : 1;
for (; ; ) {
let r2 = t2.parentNode;
if (r2 == this.dom)
break;
n2 == 0 && r2.firstChild != r2.lastChild && (t2 == r2.firstChild ? n2 = -1 : n2 = 1), t2 = r2;
}
n2 < 0 ? i2 = t2 : i2 = t2.nextSibling;
}
if (i2 == this.dom.firstChild)
return 0;
for (; i2 && !W2.get(i2); )
i2 = i2.nextSibling;
if (!i2)
return this.length;
for (let n2 = 0, r2 = 0; ; n2++) {
let o = this.children[n2];
if (o.dom == i2)
return r2;
r2 += o.length + o.breakAfter;
}
}
domBoundsAround(t2, e2, i2 = 0) {
let n2 = -1, r2 = -1, o = -1, l = -1;
for (let h2 = 0, a2 = i2, c2 = i2; h2 < this.children.length; h2++) {
let f2 = this.children[h2], u2 = a2 + f2.length;
if (a2 < t2 && u2 > e2)
return f2.domBoundsAround(t2, e2, a2);
if (u2 >= t2 && n2 == -1 && (n2 = h2, r2 = a2), a2 > e2 && f2.dom.parentNode == this.dom) {
o = h2, l = c2;
break;
}
c2 = u2, a2 = u2 + f2.breakAfter;
}
return {
from: r2,
to: l < 0 ? i2 + this.length : l,
startDOM: (n2 ? this.children[n2 - 1].dom.nextSibling : null) || this.dom.firstChild,
endDOM: o < this.children.length && o >= 0 ? this.children[o].dom : null
};
}
markDirty(t2 = false) {
this.dirty |= 2, this.markParentsDirty(t2);
}
markParentsDirty(t2) {
for (let e2 = this.parent; e2; e2 = e2.parent) {
if (t2 && (e2.dirty |= 2), e2.dirty & 1)
return;
e2.dirty |= 1, t2 = false;
}
}
setParent(t2) {
this.parent != t2 && (this.parent = t2, this.dirty && this.markParentsDirty(true));
}
setDOM(t2) {
this.dom && (this.dom.cmView = null), this.dom = t2, t2.cmView = this;
}
get rootView() {
for (let t2 = this; ; ) {
let e2 = t2.parent;
if (!e2)
return t2;
t2 = e2;
}
}
replaceChildren(t2, e2, i2 = Gs) {
this.markDirty();
for (let n2 = t2; n2 < e2; n2++) {
let r2 = this.children[n2];
r2.parent == this && r2.destroy();
}
this.children.splice(t2, e2 - t2, ...i2);
for (let n2 = 0; n2 < i2.length; n2++)
i2[n2].setParent(this);
}
ignoreMutation(t2) {
return false;
}
ignoreEvent(t2) {
return false;
}
childCursor(t2 = this.length) {
return new yl(this.children, t2, this.children.length);
}
childPos(t2, e2 = 1) {
return this.childCursor().findPos(t2, e2);
}
toString() {
let t2 = this.constructor.name.replace("View", "");
return t2 + (this.children.length ? "(" + this.children.join() + ")" : this.length ? "[" + (t2 == "Text" ? this.text : this.length) + "]" : "") + (this.breakAfter ? "#" : "");
}
static get(t2) {
return t2.cmView;
}
get isEditable() {
return true;
}
merge(t2, e2, i2, n2, r2, o) {
return false;
}
become(t2) {
return false;
}
canReuseDOM(t2) {
return t2.constructor == this.constructor;
}
// When this is a zero-length view with a side, this should return a
// number <= 0 to indicate it is before its position, or a
// number > 0 when after its position.
getSide() {
return 0;
}
destroy() {
this.parent = null;
}
};
W$1.prototype.breakAfter = 0;
function Or(s) {
let t2 = s.nextSibling;
return s.parentNode.removeChild(s), t2;
}
class yl {
constructor(t2, e2, i2) {
this.children = t2, this.pos = e2, this.i = i2, this.off = 0;
}
findPos(t2, e2 = 1) {
for (; ; ) {
if (t2 > this.pos || t2 == this.pos && (e2 > 0 || this.i == 0 || this.children[this.i - 1].breakAfter))
return this.off = t2 - this.pos, this;
let i2 = this.children[--this.i];
this.pos -= i2.length + i2.breakAfter;
}
}
}
function bl(s, t2, e2, i2, n2, r2, o, l, h2) {
let { children: a2 } = s, c2 = a2.length ? a2[t2] : null, f2 = r2.length ? r2[r2.length - 1] : null, u2 = f2 ? f2.breakAfter : o;
if (!(t2 == i2 && c2 && !o && !u2 && r2.length < 2 && c2.merge(e2, n2, r2.length ? f2 : null, e2 == 0, l, h2))) {
if (i2 < a2.length) {
let d2 = a2[i2];
d2 && n2 < d2.length ? (t2 == i2 && (d2 = d2.split(n2), n2 = 0), !u2 && f2 && d2.merge(0, n2, f2, true, 0, h2) ? r2[r2.length - 1] = d2 : (n2 && d2.merge(0, n2, null, false, 0, h2), r2.push(d2))) : d2 != null && d2.breakAfter && (f2 ? f2.breakAfter = 1 : o = 1), i2++;
}
for (c2 && (c2.breakAfter = o, e2 > 0 && (!o && r2.length && c2.merge(e2, c2.length, r2[0], false, l, 0) ? c2.breakAfter = r2.shift().breakAfter : (e2 < c2.length || c2.children.length && c2.children[c2.children.length - 1].length == 0) && c2.merge(e2, c2.length, null, false, l, 0), t2++)); t2 < i2 && r2.length; )
if (a2[i2 - 1].become(r2[r2.length - 1]))
i2--, r2.pop(), h2 = r2.length ? 0 : l;
else if (a2[t2].become(r2[0]))
t2++, r2.shift(), l = r2.length ? 0 : h2;
else
break;
!r2.length && t2 && i2 < a2.length && !a2[t2 - 1].breakAfter && a2[i2].merge(0, 0, a2[t2 - 1], false, l, h2) && t2--, (t2 < i2 || r2.length) && s.replaceChildren(t2, i2, r2);
}
}
function kl(s, t2, e2, i2, n2, r2) {
let o = s.childCursor(), { i: l, off: h2 } = o.findPos(e2, 1), { i: a2, off: c2 } = o.findPos(t2, -1), f2 = t2 - e2;
for (let u2 of i2)
f2 += u2.length;
s.length += f2, bl(s, a2, c2, l, h2, i2, 0, n2, r2);
}
let kt = typeof navigator < "u" ? navigator : { userAgent: "", vendor: "", platform: "" }, ps = typeof document < "u" ? document : { documentElement: { style: {} } };
const gs = /* @__PURE__ */ /Edge\/(\d+)/.exec(kt.userAgent), xl = /* @__PURE__ */ /MSIE \d/.test(kt.userAgent), ms = /* @__PURE__ */ /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(kt.userAgent), An = !!(xl || ms || gs), Mr = !An && /* @__PURE__ */ /gecko\/(\d+)/i.test(kt.userAgent), In = !An && /* @__PURE__ */ /Chrome\/(\d+)/.exec(kt.userAgent), Dr = "webkitFontSmoothing" in ps.documentElement.style, vl = !An && /* @__PURE__ */ /Apple Computer/.test(kt.vendor), Tr = vl && (/* @__PURE__ */ /Mobile\/\w+/.test(kt.userAgent) || kt.maxTouchPoints > 2);
var x$1 = {
mac: Tr || /* @__PURE__ */ /Mac/.test(kt.platform),
windows: /* @__PURE__ */ /Win/.test(kt.platform),
linux: /* @__PURE__ */ /Linux|X11/.test(kt.platform),
ie: An,
ie_version: xl ? ps.documentMode || 6 : ms ? +ms[1] : gs ? +gs[1] : 0,
gecko: Mr,
gecko_version: Mr ? +(/* @__PURE__ */ /Firefox\/(\d+)/.exec(kt.userAgent) || [0, 0])[1] : 0,
chrome: !!In,
chrome_version: In ? +In[1] : 0,
ios: Tr,
android: /* @__PURE__ */ /Android\b/.test(kt.userAgent),
webkit: Dr,
safari: vl,
webkit_version: Dr ? +(/* @__PURE__ */ /\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
tabSize: ps.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
};
const ef = 256;
class ge extends W$1 {
constructor(t2) {
super(), this.text = t2;
}
get length() {
return this.text.length;
}
createDOM(t2) {
this.setDOM(t2 || document.createTextNode(this.text));
}
sync(t2) {
this.dom || this.createDOM(), this.dom.nodeValue != this.text && (t2 && t2.node == this.dom && (t2.written = true), this.dom.nodeValue = this.text);
}
reuseDOM(t2) {
t2.nodeType == 3 && this.createDOM(t2);
}
merge(t2, e2, i2) {
return i2 && (!(i2 instanceof ge) || this.length - (e2 - t2) + i2.length > ef) ? false : (this.text = this.text.slice(0, t2) + (i2 ? i2.text : "") + this.text.slice(e2), this.markDirty(), true);
}
split(t2) {
let e2 = new ge(this.text.slice(t2));
return this.text = this.text.slice(0, t2), this.markDirty(), e2;
}
localPosFromDOM(t2, e2) {
return t2 == this.dom ? e2 : e2 ? this.text.length : 0;
}
domAtPos(t2) {
return new ht(this.dom, t2);
}
domBoundsAround(t2, e2, i2) {
return { from: i2, to: i2 + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
}
coordsAt(t2, e2) {
return ws(this.dom, t2, e2);
}
}
class jt extends W$1 {
constructor(t2, e2 = [], i2 = 0) {
super(), this.mark = t2, this.children = e2, this.length = i2;
for (let n2 of e2)
n2.setParent(this);
}
setAttrs(t2) {
if (wl(t2), this.mark.class && (t2.className = this.mark.class), this.mark.attrs)
for (let e2 in this.mark.attrs)
t2.setAttribute(e2, this.mark.attrs[e2]);
return t2;
}
reuseDOM(t2) {
t2.nodeName == this.mark.tagName.toUpperCase() && (this.setDOM(t2), this.dirty |= 6);
}
sync(t2) {
this.dom ? this.dirty & 4 && this.setAttrs(this.dom) : this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))), super.sync(t2);
}
merge(t2, e2, i2, n2, r2, o) {
return i2 && (!(i2 instanceof jt && i2.mark.eq(this.mark)) || t2 && r2 <= 0 || e2 < this.length && o <= 0) ? false : (kl(this, t2, e2, i2 ? i2.children : [], r2 - 1, o - 1), this.markDirty(), true);
}
split(t2) {
let e2 = [], i2 = 0, n2 = -1, r2 = 0;
for (let l of this.children) {
let h2 = i2 + l.length;
h2 > t2 && e2.push(i2 < t2 ? l.split(t2 - i2) : l), n2 < 0 && i2 >= t2 && (n2 = r2), i2 = h2, r2++;
}
let o = this.length - t2;
return this.length = t2, n2 > -1 && (this.children.length = n2, this.markDirty()), new jt(this.mark, e2, o);
}
domAtPos(t2) {
return Al(this, t2);
}
coordsAt(t2, e2) {
return Ml(this, t2, e2);
}
}
function ws(s, t2, e2) {
let i2 = s.nodeValue.length;
t2 > i2 && (t2 = i2);
let n2 = t2, r2 = t2, o = 0;
t2 == 0 && e2 < 0 || t2 == i2 && e2 >= 0 ? x$1.chrome || x$1.gecko || (t2 ? (n2--, o = 1) : r2 < i2 && (r2++, o = -1)) : e2 < 0 ? n2-- : r2 < i2 && r2++;
let l = Ke(s, n2, r2).getClientRects();
if (!l.length)
return gl;
let h2 = l[(o ? o < 0 : e2 >= 0) ? 0 : l.length - 1];
return x$1.safari && !o && h2.width == 0 && (h2 = Array.prototype.find.call(l, (a2) => a2.width) || h2), o ? Ks(h2, o < 0) : h2 || null;
}
class le extends W$1 {
constructor(t2, e2, i2) {
super(), this.widget = t2, this.length = e2, this.side = i2, this.prevWidget = null;
}
static create(t2, e2, i2) {
return new (t2.customView || le)(t2, e2, i2);
}
split(t2) {
let e2 = le.create(this.widget, this.length - t2, this.side);
return this.length -= t2, e2;
}
sync() {
(!this.dom || !this.widget.updateDOM(this.dom)) && (this.dom && this.prevWidget && this.prevWidget.destroy(this.dom), this.prevWidget = null, this.setDOM(this.widget.toDOM(this.editorView)), this.dom.contentEditable = "false");
}
getSide() {
return this.side;
}
merge(t2, e2, i2, n2, r2, o) {
return i2 && (!(i2 instanceof le) || !this.widget.compare(i2.widget) || t2 > 0 && r2 <= 0 || e2 < this.length && o <= 0) ? false : (this.length = t2 + (i2 ? i2.length : 0) + (this.length - e2), true);
}
become(t2) {
return t2.length == this.length && t2 instanceof le && t2.side == this.side && this.widget.constructor == t2.widget.constructor ? (this.widget.eq(t2.widget) || this.markDirty(true), this.dom && !this.prevWidget && (this.prevWidget = this.widget), this.widget = t2.widget, true) : false;
}
ignoreMutation() {
return true;
}
ignoreEvent(t2) {
return this.widget.ignoreEvent(t2);
}
get overrideDOMText() {
if (this.length == 0)
return E$1.empty;
let t2 = this;
for (; t2.parent; )
t2 = t2.parent;
let e2 = t2.editorView, i2 = e2 && e2.state.doc, n2 = this.posAtStart;
return i2 ? i2.slice(n2, n2 + this.length) : E$1.empty;
}
domAtPos(t2) {
return t2 == 0 ? ht.before(this.dom) : ht.after(this.dom, t2 == this.length);
}
domBoundsAround() {
return null;
}
coordsAt(t2, e2) {
let i2 = this.dom.getClientRects(), n2 = null;
if (!i2.length)
return gl;
for (let r2 = t2 > 0 ? i2.length - 1 : 0; n2 = i2[r2], !(t2 > 0 ? r2 == 0 : r2 == i2.length - 1 || n2.top < n2.bottom); r2 += t2 > 0 ? -1 : 1)
;
return this.length ? n2 : Ks(n2, this.side > 0);
}
get isEditable() {
return false;
}
destroy() {
super.destroy(), this.dom && this.widget.destroy(this.dom);
}
}
class Sl extends le {
domAtPos(t2) {
let { topView: e2, text: i2 } = this.widget;
return e2 ? ys(t2, 0, e2, i2, (n2, r2) => n2.domAtPos(r2), (n2) => new ht(i2, Math.min(n2, i2.nodeValue.length))) : new ht(i2, Math.min(t2, i2.nodeValue.length));
}
sync() {
this.setDOM(this.widget.toDOM());
}
localPosFromDOM(t2, e2) {
let { topView: i2, text: n2 } = this.widget;
return i2 ? Cl(t2, e2, i2, n2) : Math.min(e2, this.length);
}
ignoreMutation() {
return false;
}
get overrideDOMText() {
return null;
}
coordsAt(t2, e2) {
let { topView: i2, text: n2 } = this.widget;
return i2 ? ys(t2, e2, i2, n2, (r2, o, l) => r2.coordsAt(o, l), (r2, o) => ws(n2, r2, o)) : ws(n2, t2, e2);
}
destroy() {
var t2;
super.destroy(), (t2 = this.widget.topView) === null || t2 === void 0 || t2.destroy();
}
get isEditable() {
return true;
}
canReuseDOM() {
return true;
}
}
function ys(s, t2, e2, i2, n2, r2) {
if (e2 instanceof jt) {
for (let o = e2.dom.firstChild; o; o = o.nextSibling) {
let l = W$1.get(o);
if (!l)
return r2(s, t2);
let h2 = qe(o, i2), a2 = l.length + (h2 ? i2.nodeValue.length : 0);
if (s < a2 || s == a2 && l.getSide() <= 0)
return h2 ? ys(s, t2, l, i2, n2, r2) : n2(l, s, t2);
s -= a2;
}
return n2(e2, e2.length, -1);
} else
return e2.dom == i2 ? r2(s, t2) : n2(e2, s, t2);
}
function Cl(s, t2, e2, i2) {
if (e2 instanceof jt)
for (let n2 of e2.children) {
let r2 = 0, o = qe(n2.dom, i2);
if (qe(n2.dom, s))
return r2 + (o ? Cl(s, t2, n2, i2) : n2.localPosFromDOM(s, t2));
r2 += o ? i2.nodeValue.length : n2.length;
}
else if (e2.dom == i2)
return Math.min(t2, i2.nodeValue.length);
return e2.localPosFromDOM(s, t2);
}
class Ge extends W$1 {
constructor(t2) {
super(), this.side = t2;
}
get length() {
return 0;
}
merge() {
return false;
}
become(t2) {
return t2 instanceof Ge && t2.side == this.side;
}
split() {
return new Ge(this.side);
}
sync() {
if (!this.dom) {
let t2 = document.createElement("img");
t2.className = "cm-widgetBuffer", t2.setAttribute("aria-hidden", "true"), this.setDOM(t2);
}
}
getSide() {
return this.side;
}
domAtPos(t2) {
return ht.before(this.dom);
}
localPosFromDOM() {
return 0;
}
domBoundsAround() {
return null;
}
coordsAt(t2) {
let e2 = this.dom.getBoundingClientRect(), i2 = nf(this, this.side > 0 ? -1 : 1);
return i2 && i2.top < e2.bottom && i2.bottom > e2.top ? { left: e2.left, right: e2.right, top: i2.top, bottom: i2.bottom } : e2;
}
get overrideDOMText() {
return E$1.empty;
}
}
ge.prototype.children = le.prototype.children = Ge.prototype.children = Gs;
function nf(s, t2) {
let e2 = s.parent, i2 = e2 ? e2.children.indexOf(s) : -1;
for (; e2 && i2 >= 0; )
if (t2 < 0 ? i2 > 0 : i2 < e2.children.length) {
let n2 = e2.children[i2 + t2];
if (n2 instanceof ge) {
let r2 = n2.coordsAt(t2 < 0 ? n2.length : 0, t2);
if (r2)
return r2;
}
i2 += t2;
} else if (e2 instanceof jt && e2.parent)
i2 = e2.parent.children.indexOf(e2) + (t2 < 0 ? 0 : 1), e2 = e2.parent;
else {
let n2 = e2.dom.lastChild;
if (n2 && n2.nodeName == "BR")
return n2.getClientRects()[0];
break;
}
}
function Al(s, t2) {
let e2 = s.dom, { children: i2 } = s, n2 = 0;
for (let r2 = 0; n2 < i2.length; n2++) {
let o = i2[n2], l = r2 + o.length;
if (!(l == r2 && o.getSide() <= 0)) {
if (t2 > r2 && t2 < l && o.dom.parentNode == e2)
return o.domAtPos(t2 - r2);
if (t2 <= r2)
break;
r2 = l;
}
}
for (let r2 = n2; r2 > 0; r2--) {
let o = i2[r2 - 1];
if (o.dom.parentNode == e2)
return o.domAtPos(o.length);
}
for (let r2 = n2; r2 < i2.length; r2++) {
let o = i2[r2];
if (o.dom.parentNode == e2)
return o.domAtPos(0);
}
return new ht(e2, 0);
}
function Ol(s, t2, e2) {
let i2, { children: n2 } = s;
e2 > 0 && t2 instanceof jt && n2.length && (i2 = n2[n2.length - 1]) instanceof jt && i2.mark.eq(t2.mark) ? Ol(i2, t2.children[0], e2 - 1) : (n2.push(t2), t2.setParent(s)), s.length += t2.length;
}
function Ml(s, t2, e2) {
let i2 = null, n2 = -1, r2 = null, o = -1;
function l(a2, c2) {
for (let f2 = 0, u2 = 0; f2 < a2.children.length && u2 <= c2; f2++) {
let d2 = a2.children[f2], p2 = u2 + d2.length;
p2 >= c2 && (d2.children.length ? l(d2, c2 - u2) : !r2 && (p2 > c2 || u2 == p2 && d2.getSide() > 0) ? (r2 = d2, o = c2 - u2) : (u2 < c2 || u2 == p2 && d2.getSide() < 0) && (i2 = d2, n2 = c2 - u2)), u2 = p2;
}
}
l(s, t2);
let h2 = (e2 < 0 ? i2 : r2) || i2 || r2;
return h2 ? h2.coordsAt(Math.max(0, h2 == i2 ? n2 : o), e2) : sf(s);
}
function sf(s) {
let t2 = s.dom.lastChild;
if (!t2)
return s.dom.getBoundingClientRect();
let e2 = di(t2);
return e2[e2.length - 1] || null;
}
function bs(s, t2) {
for (let e2 in s)
e2 == "class" && t2.class ? t2.class += " " + s.class : e2 == "style" && t2.style ? t2.style += ";" + s.style : t2[e2] = s[e2];
return t2;
}
function Us(s, t2) {
if (s == t2)
return true;
if (!s || !t2)
return false;
let e2 = Object.keys(s), i2 = Object.keys(t2);
if (e2.length != i2.length)
return false;
for (let n2 of e2)
if (i2.indexOf(n2) == -1 || s[n2] !== t2[n2])
return false;
return true;
}
function ks(s, t2, e2) {
let i2 = null;
if (t2)
for (let n2 in t2)
e2 && n2 in e2 || s.removeAttribute(i2 = n2);
if (e2)
for (let n2 in e2)
t2 && t2[n2] == e2[n2] || s.setAttribute(i2 = n2, e2[n2]);
return !!i2;
}
class ye {
/**
Compare this instance to another instance of the same type.
(TypeScript can't express this, but only instances of the same
specific class will be passed to this method.) This is used to
avoid redrawing widgets when they are replaced by a new
decoration of the same type. The default implementation just
returns `false`, which will cause new instances of the widget to
always be redrawn.
*/
eq(t2) {
return false;
}
/**
Update a DOM element created by a widget of the same type (but
different, non-`eq` content) to reflect this widget. May return
true to indicate that it could update, false to indicate it
couldn't (in which case the widget will be redrawn). The default
implementation just returns false.
*/
updateDOM(t2) {
return false;
}
/**
@internal
*/
compare(t2) {
return this == t2 || this.constructor == t2.constructor && this.eq(t2);
}
/**
The estimated height this widget will have, to be used when
estimating the height of content that hasn't been drawn. May
return -1 to indicate you don't know. The default implementation
returns -1.
*/
get estimatedHeight() {
return -1;
}
/**
Can be used to configure which kinds of events inside the widget
should be ignored by the editor. The default is to ignore all
events.
*/
ignoreEvent(t2) {
return true;
}
/**
@internal
*/
get customView() {
return null;
}
/**
This is called when the an instance of the widget is removed
from the editor view.
*/
destroy(t2) {
}
}
var U = /* @__PURE__ */ function(s) {
return s[s.Text = 0] = "Text", s[s.WidgetBefore = 1] = "WidgetBefore", s[s.WidgetAfter = 2] = "WidgetAfter", s[s.WidgetRange = 3] = "WidgetRange", s;
}(U || (U = {}));
class T extends je {
constructor(t2, e2, i2, n2) {
super(), this.startSide = t2, this.endSide = e2, this.widget = i2, this.spec = n2;
}
/**
@internal
*/
get heightRelevant() {
return false;
}
/**
Create a mark decoration, which influences the styling of the
content in its range. Nested mark decorations will cause nested
DOM elements to be created. Nesting order is determined by
precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
the higher-precedence decorations creating the inner DOM nodes.
Such elements are split on line boundaries and on the boundaries
of lower-precedence decorations.
*/
static mark(t2) {
return new On(t2);
}
/**
Create a widget decoration, which displays a DOM element at the
given position.
*/
static widget(t2) {
let e2 = t2.side || 0, i2 = !!t2.block;
return e2 += i2 ? e2 > 0 ? 3e8 : -4e8 : e2 > 0 ? 1e8 : -1e8, new Te(t2, e2, e2, i2, t2.widget || null, false);
}
/**
Create a replace decoration which replaces the given range with
a widget, or simply hides it.
*/
static replace(t2) {
let e2 = !!t2.block, i2, n2;
if (t2.isBlockGap)
i2 = -5e8, n2 = 4e8;
else {
let { start: r2, end: o } = Dl(t2, e2);
i2 = (r2 ? e2 ? -3e8 : -1 : 5e8) - 1, n2 = (o ? e2 ? 2e8 : 1 : -6e8) + 1;
}
return new Te(t2, i2, n2, e2, t2.widget || null, true);
}
/**
Create a line decoration, which can add DOM attributes to the
line starting at the given position.
*/
static line(t2) {
return new ki(t2);
}
/**
Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
decorated range or ranges. If the ranges aren't already sorted,
pass `true` for `sort` to make the library sort them for you.
*/
static set(t2, e2 = false) {
return $.of(t2, e2);
}
/**
@internal
*/
hasHeight() {
return this.widget ? this.widget.estimatedHeight > -1 : false;
}
}
T.none = $.empty;
class On extends T {
constructor(t2) {
let { start: e2, end: i2 } = Dl(t2);
super(e2 ? -1 : 5e8, i2 ? 1 : -6e8, null, t2), this.tagName = t2.tagName || "span", this.class = t2.class || "", this.attrs = t2.attributes || null;
}
eq(t2) {
return this == t2 || t2 instanceof On && this.tagName == t2.tagName && this.class == t2.class && Us(this.attrs, t2.attrs);
}
range(t2, e2 = t2) {
if (t2 >= e2)
throw new RangeError("Mark decorations may not be empty");
return super.range(t2, e2);
}
}
On.prototype.point = false;
class ki extends T {
constructor(t2) {
super(-2e8, -2e8, null, t2);
}
eq(t2) {
return t2 instanceof ki && this.spec.class == t2.spec.class && Us(this.spec.attributes, t2.spec.attributes);
}
range(t2, e2 = t2) {
if (e2 != t2)
throw new RangeError("Line decoration ranges must be zero-length");
return super.range(t2, e2);
}
}
ki.prototype.mapMode = gt.TrackBefore;
ki.prototype.point = true;
class Te extends T {
constructor(t2, e2, i2, n2, r2, o) {
super(e2, i2, r2, t2), this.block = n2, this.isReplace = o, this.mapMode = n2 ? e2 <= 0 ? gt.TrackBefore : gt.TrackAfter : gt.TrackDel;
}
// Only relevant when this.block == true
get type() {
return this.startSide < this.endSide ? U.WidgetRange : this.startSide <= 0 ? U.WidgetBefore : U.WidgetAfter;
}
get heightRelevant() {
return this.block || !!this.widget && this.widget.estimatedHeight >= 5;
}
eq(t2) {
return t2 instanceof Te && rf(this.widget, t2.widget) && this.block == t2.block && this.startSide == t2.startSide && this.endSide == t2.endSide;
}
range(t2, e2 = t2) {
if (this.isReplace && (t2 > e2 || t2 == e2 && this.startSide > 0 && this.endSide <= 0))
throw new RangeError("Invalid range for replacement decoration");
if (!this.isReplace && e2 != t2)
throw new RangeError("Widget decorations can only have zero-length ranges");
return super.range(t2, e2);
}
}
Te.prototype.point = true;
function Dl(s, t2 = false) {
let { inclusiveStart: e2, inclusiveEnd: i2 } = s;
return e2 == null && (e2 = s.inclusive), i2 == null && (i2 = s.inclusive), { start: e2 ?? t2, end: i2 ?? t2 };
}
function rf(s, t2) {
return s == t2 || !!(s && t2 && s.compare(t2));
}
function xs(s, t2, e2, i2 = 0) {
let n2 = e2.length - 1;
n2 >= 0 && e2[n2] + i2 >= s ? e2[n2] = Math.max(e2[n2], t2) : e2.push(s, t2);
}
class ut extends W$1 {
constructor() {
super(...arguments), this.children = [], this.length = 0, this.prevAttrs = void 0, this.attrs = null, this.breakAfter = 0;
}
// Consumes source
merge(t2, e2, i2, n2, r2, o) {
if (i2) {
if (!(i2 instanceof ut))
return false;
this.dom || i2.transferDOM(this);
}
return n2 && this.setDeco(i2 ? i2.attrs : null), kl(this, t2, e2, i2 ? i2.children : [], r2, o), true;
}
split(t2) {
let e2 = new ut();
if (e2.breakAfter = this.breakAfter, this.length == 0)
return e2;
let { i: i2, off: n2 } = this.childPos(t2);
n2 && (e2.append(this.children[i2].split(n2), 0), this.children[i2].merge(n2, this.children[i2].length, null, false, 0, 0), i2++);
for (let r2 = i2; r2 < this.children.length; r2++)
e2.append(this.children[r2], 0);
for (; i2 > 0 && this.children[i2 - 1].length == 0; )
this.children[--i2].destroy();
return this.children.length = i2, this.markDirty(), this.length = t2, e2;
}
transferDOM(t2) {
this.dom && (this.markDirty(), t2.setDOM(this.dom), t2.prevAttrs = this.prevAttrs === void 0 ? this.attrs : this.prevAttrs, this.prevAttrs = void 0, this.dom = null);
}
setDeco(t2) {
Us(this.attrs, t2) || (this.dom && (this.prevAttrs = this.attrs, this.markDirty()), this.attrs = t2);
}
append(t2, e2) {
Ol(this, t2, e2);
}
// Only called when building a line view in ContentBuilder
addLineDeco(t2) {
let e2 = t2.spec.attributes, i2 = t2.spec.class;
e2 && (this.attrs = bs(e2, this.attrs || {})), i2 && (this.attrs = bs({ class: i2 }, this.attrs || {}));
}
domAtPos(t2) {
return Al(this, t2);
}
reuseDOM(t2) {
t2.nodeName == "DIV" && (this.setDOM(t2), this.dirty |= 6);
}
sync(t2) {
var e2;
this.dom ? this.dirty & 4 && (wl(this.dom), this.dom.className = "cm-line", this.prevAttrs = this.attrs ? null : void 0) : (this.setDOM(document.createElement("div")), this.dom.className = "cm-line", this.prevAttrs = this.attrs ? null : void 0), this.prevAttrs !== void 0 && (ks(this.dom, this.prevAttrs, this.attrs), this.dom.classList.add("cm-line"), this.prevAttrs = void 0), super.sync(t2);
let i2 = this.dom.lastChild;
for (; i2 && W$1.get(i2) instanceof jt; )
i2 = i2.lastChild;
if (!i2 || !this.length || i2.nodeName != "BR" && ((e2 = W$1.get(i2)) === null || e2 === void 0 ? void 0 : e2.isEditable) == false && (!x$1.ios || !this.children.some((n2) => n2 instanceof ge))) {
let n2 = document.createElement("BR");
n2.cmIgnore = true, this.dom.appendChild(n2);
}
}
measureTextSize() {
if (this.children.length == 0 || this.length > 20)
return null;
let t2 = 0;
for (let e2 of this.children) {
if (!(e2 instanceof ge) || /[^ -~]/.test(e2.text))
return null;
let i2 = di(e2.dom);
if (i2.length != 1)
return null;
t2 += i2[0].width;
}
return t2 ? {
lineHeight: this.dom.getBoundingClientRect().height,
charWidth: t2 / this.length
} : null;
}
coordsAt(t2, e2) {
return Ml(this, t2, e2);
}
become(t2) {
return false;
}
get type() {
return U.Text;
}
static find(t2, e2) {
for (let i2 = 0, n2 = 0; i2 < t2.children.length; i2++) {
let r2 = t2.children[i2], o = n2 + r2.length;
if (o >= e2) {
if (r2 instanceof ut)
return r2;
if (o > e2)
break;
}
n2 = o + r2.breakAfter;
}
return null;
}
}
class Ae extends W$1 {
constructor(t2, e2, i2) {
super(), this.widget = t2, this.length = e2, this.type = i2, this.breakAfter = 0, this.prevWidget = null;
}
merge(t2, e2, i2, n2, r2, o) {
return i2 && (!(i2 instanceof Ae) || !this.widget.compare(i2.widget) || t2 > 0 && r2 <= 0 || e2 < this.length && o <= 0) ? false : (this.length = t2 + (i2 ? i2.length : 0) + (this.length - e2), true);
}
domAtPos(t2) {
return t2 == 0 ? ht.before(this.dom) : ht.after(this.dom, t2 == this.length);
}
split(t2) {
let e2 = this.length - t2;
this.length = t2;
let i2 = new Ae(this.widget, e2, this.type);
return i2.breakAfter = this.breakAfter, i2;
}
get children() {
return Gs;
}
sync() {
(!this.dom || !this.widget.updateDOM(this.dom)) && (this.dom && this.prevWidget && this.prevWidget.destroy(this.dom), this.prevWidget = null, this.setDOM(this.widget.toDOM(this.editorView)), this.dom.contentEditable = "false");
}
get overrideDOMText() {
return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : E$1.empty;
}
domBoundsAround() {
return null;
}
become(t2) {
return t2 instanceof Ae && t2.type == this.type && t2.widget.constructor == this.widget.constructor ? (t2.widget.eq(this.widget) || this.markDirty(true), this.dom && !this.prevWidget && (this.prevWidget = this.widget), this.widget = t2.widget, this.length = t2.length, this.breakAfter = t2.breakAfter, true) : false;
}
ignoreMutation() {
return true;
}
ignoreEvent(t2) {
return this.widget.ignoreEvent(t2);
}
destroy() {
super.destroy(), this.dom && this.widget.destroy(this.dom);
}
}
class Qs {
constructor(t2, e2, i2, n2) {
this.doc = t2, this.pos = e2, this.end = i2, this.disallowBlockEffectsFor = n2, this.content = [], this.curLine = null, this.breakAtStart = 0, this.pendingBuffer = 0, this.bufferMarks = [], this.atCursorPos = true, this.openStart = -1, this.openEnd = -1, this.text = "", this.textOff = 0, this.cursor = t2.iter(), this.skip = e2;
}
posCovered() {
if (this.content.length == 0)
return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
let t2 = this.content[this.content.length - 1];
return !t2.breakAfter && !(t2 instanceof Ae && t2.type == U.WidgetBefore);
}
getLine() {
return this.curLine || (this.content.push(this.curLine = new ut()), this.atCursorPos = true), this.curLine;
}
flushBuffer(t2 = this.bufferMarks) {
this.pendingBuffer && (this.curLine.append(Mi(new Ge(-1), t2), t2.length), this.pendingBuffer = 0);
}
addBlockWidget(t2) {
this.flushBuffer(), this.curLine = null, this.content.push(t2);
}
finish(t2) {
this.pendingBuffer && t2 <= this.bufferMarks.length ? this.flushBuffer() : this.pendingBuffer = 0, this.posCovered() || this.getLine();
}
buildText(t2, e2, i2) {
for (; t2 > 0; ) {
if (this.textOff == this.text.length) {
let { value: r2, lineBreak: o, done: l } = this.cursor.next(this.skip);
if (this.skip = 0, l)
throw new Error("Ran out of text content when drawing inline views");
if (o) {
this.posCovered() || this.getLine(), this.content.length ? this.content[this.content.length - 1].breakAfter = 1 : this.breakAtStart = 1, this.flushBuffer(), this.curLine = null, this.atCursorPos = true, t2--;
continue;
} else
this.text = r2, this.textOff = 0;
}
let n2 = Math.min(
this.text.length - this.textOff,
t2,
512
/* T.Chunk */
);
this.flushBuffer(e2.slice(e2.length - i2)), this.getLine().append(Mi(new ge(this.text.slice(this.textOff, this.textOff + n2)), e2), i2), this.atCursorPos = true, this.textOff += n2, t2 -= n2, i2 = 0;
}
}
span(t2, e2, i2, n2) {
this.buildText(e2 - t2, i2, n2), this.pos = e2, this.openStart < 0 && (this.openStart = n2);
}
point(t2, e2, i2, n2, r2, o) {
if (this.disallowBlockEffectsFor[o] && i2 instanceof Te) {
if (i2.block)
throw new RangeError("Block decorations may not be specified via plugins");
if (e2 > this.doc.lineAt(this.pos).to)
throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
}
let l = e2 - t2;
if (i2 instanceof Te)
if (i2.block) {
let { type: h2 } = i2;
h2 == U.WidgetAfter && !this.posCovered() && this.getLine(), this.addBlockWidget(new Ae(i2.widget || new Pr("div"), l, h2));
} else {
let h2 = le.create(i2.widget || new Pr("span"), l, l ? 0 : i2.startSide), a2 = this.atCursorPos && !h2.isEditable && r2 <= n2.length && (t2 < e2 || i2.startSide > 0), c2 = !h2.isEditable && (t2 < e2 || r2 > n2.length || i2.startSide <= 0), f2 = this.getLine();
this.pendingBuffer == 2 && !a2 && (this.pendingBuffer = 0), this.flushBuffer(n2), a2 && (f2.append(Mi(new Ge(1), n2), r2), r2 = n2.length + Math.max(0, r2 - n2.length)), f2.append(Mi(h2, n2), r2), this.atCursorPos = c2, this.pendingBuffer = c2 ? t2 < e2 || r2 > n2.length ? 1 : 2 : 0, this.pendingBuffer && (this.bufferMarks = n2.slice());
}
else
this.doc.lineAt(this.pos).from == this.pos && this.getLine().addLineDeco(i2);
l && (this.textOff + l <= this.text.length ? this.textOff += l : (this.skip += l - (this.text.length - this.textOff), this.text = "", this.textOff = 0), this.pos = e2), this.openStart < 0 && (this.openStart = r2);
}
static build(t2, e2, i2, n2, r2) {
let o = new Qs(t2, e2, i2, r2);
return o.openEnd = $.spans(n2, e2, i2, o), o.openStart < 0 && (o.openStart = o.openEnd), o.finish(o.openEnd), o;
}
}
function Mi(s, t2) {
for (let e2 of t2)
s = new jt(e2, [s], s.length);
return s;
}
class Pr extends ye {
constructor(t2) {
super(), this.tag = t2;
}
eq(t2) {
return t2.tag == this.tag;
}
toDOM() {
return document.createElement(this.tag);
}
updateDOM(t2) {
return t2.nodeName.toLowerCase() == this.tag;
}
}
const Tl = /* @__PURE__ */ v.define(), Pl = /* @__PURE__ */ v.define(), Bl = /* @__PURE__ */ v.define(), Rl = /* @__PURE__ */ v.define(), vs = /* @__PURE__ */ v.define(), Ll = /* @__PURE__ */ v.define(), El = /* @__PURE__ */ v.define({
combine: (s) => s.some((t2) => t2)
}), of = /* @__PURE__ */ v.define({
combine: (s) => s.some((t2) => t2)
});
class rn {
constructor(t2, e2 = "nearest", i2 = "nearest", n2 = 5, r2 = 5) {
this.range = t2, this.y = e2, this.x = i2, this.yMargin = n2, this.xMargin = r2;
}
map(t2) {
return t2.empty ? this : new rn(this.range.map(t2), this.y, this.x, this.yMargin, this.xMargin);
}
}
const Br = /* @__PURE__ */ F.define({ map: (s, t2) => s.map(t2) });
function zt(s, t2, e2) {
let i2 = s.facet(Rl);
i2.length ? i2[0](t2) : window.onerror ? window.onerror(String(t2), e2, void 0, void 0, t2) : e2 ? console.error(e2 + ":", t2) : console.error(t2);
}
const Mn = /* @__PURE__ */ v.define({ combine: (s) => s.length ? s[0] : true });
let lf = 0;
const si = /* @__PURE__ */ v.define();
class wt {
constructor(t2, e2, i2, n2) {
this.id = t2, this.create = e2, this.domEventHandlers = i2, this.extension = n2(this);
}
/**
Define a plugin from a constructor function that creates the
plugin's value, given an editor view.
*/
static define(t2, e2) {
const { eventHandlers: i2, provide: n2, decorations: r2 } = e2 || {};
return new wt(lf++, t2, i2, (o) => {
let l = [si.of(o)];
return r2 && l.push(gi.of((h2) => {
let a2 = h2.plugin(o);
return a2 ? r2(a2) : T.none;
})), n2 && l.push(n2(o)), l;
});
}
/**
Create a plugin for a class whose constructor takes a single
editor view as argument.
*/
static fromClass(t2, e2) {
return wt.define((i2) => new t2(i2), e2);
}
}
class Hn {
constructor(t2) {
this.spec = t2, this.mustUpdate = null, this.value = null;
}
update(t2) {
if (this.value) {
if (this.mustUpdate) {
let e2 = this.mustUpdate;
if (this.mustUpdate = null, this.value.update)
try {
this.value.update(e2);
} catch (i2) {
if (zt(e2.state, i2, "CodeMirror plugin crashed"), this.value.destroy)
try {
this.value.destroy();
} catch {
}
this.deactivate();
}
}
} else if (this.spec)
try {
this.value = this.spec.create(t2);
} catch (e2) {
zt(t2.state, e2, "CodeMirror plugin crashed"), this.deactivate();
}
return this;
}
destroy(t2) {
var e2;
if (!((e2 = this.value) === null || e2 === void 0) && e2.destroy)
try {
this.value.destroy();
} catch (i2) {
zt(t2.state, i2, "CodeMirror plugin crashed");
}
}
deactivate() {
this.spec = this.value = null;
}
}
const Nl = /* @__PURE__ */ v.define(), Js = /* @__PURE__ */ v.define(), gi = /* @__PURE__ */ v.define(), Vl = /* @__PURE__ */ v.define(), Il = /* @__PURE__ */ v.define(), ri = /* @__PURE__ */ v.define();
class _t {
constructor(t2, e2, i2, n2) {
this.fromA = t2, this.toA = e2, this.fromB = i2, this.toB = n2;
}
join(t2) {
return new _t(Math.min(this.fromA, t2.fromA), Math.max(this.toA, t2.toA), Math.min(this.fromB, t2.fromB), Math.max(this.toB, t2.toB));
}
addToSet(t2) {
let e2 = t2.length, i2 = this;
for (; e2 > 0; e2--) {
let n2 = t2[e2 - 1];
if (!(n2.fromA > i2.toA)) {
if (n2.toA < i2.fromA)
break;
i2 = i2.join(n2), t2.splice(e2 - 1, 1);
}
}
return t2.splice(e2, 0, i2), t2;
}
static extendWithRanges(t2, e2) {
if (e2.length == 0)
return t2;
let i2 = [];
for (let n2 = 0, r2 = 0, o = 0, l = 0; ; n2++) {
let h2 = n2 == t2.length ? null : t2[n2], a2 = o - l, c2 = h2 ? h2.fromB : 1e9;
for (; r2 < e2.length && e2[r2] < c2; ) {
let f2 = e2[r2], u2 = e2[r2 + 1], d2 = Math.max(l, f2), p2 = Math.min(c2, u2);
if (d2 <= p2 && new _t(d2 + a2, p2 + a2, d2, p2).addToSet(i2), u2 > c2)
break;
r2 += 2;
}
if (!h2)
return i2;
new _t(h2.fromA, h2.toA, h2.fromB, h2.toB).addToSet(i2), o = h2.toA, l = h2.toB;
}
}
}
class on {
constructor(t2, e2, i2) {
this.view = t2, this.state = e2, this.transactions = i2, this.flags = 0, this.startState = t2.state, this.changes = Z.empty(this.startState.doc.length);
for (let o of i2)
this.changes = this.changes.compose(o.changes);
let n2 = [];
this.changes.iterChangedRanges((o, l, h2, a2) => n2.push(new _t(o, l, h2, a2))), this.changedRanges = n2;
let r2 = t2.hasFocus;
r2 != t2.inputState.notifiedFocused && (t2.inputState.notifiedFocused = r2, this.flags |= 1);
}
/**
@internal
*/
static create(t2, e2, i2) {
return new on(t2, e2, i2);
}
/**
Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
[visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
update.
*/
get viewportChanged() {
return (this.flags & 4) > 0;
}
/**
Indicates whether the height of a block element in the editor
changed in this update.
*/
get heightChanged() {
return (this.flags & 2) > 0;
}
/**
Returns true when the document was modified or the size of the
editor, or elements within the editor, changed.
*/
get geometryChanged() {
return this.docChanged || (this.flags & 10) > 0;
}
/**
True when this update indicates a focus change.
*/
get focusChanged() {
return (this.flags & 1) > 0;
}
/**
Whether the document changed in this update.
*/
get docChanged() {
return !this.changes.empty;
}
/**
Whether the selection was explicitly set in this update.
*/
get selectionSet() {
return this.transactions.some((t2) => t2.selection);
}
/**
@internal
*/
get empty() {
return this.flags == 0 && this.transactions.length == 0;
}
}
var X = /* @__PURE__ */ function(s) {
return s[s.LTR = 0] = "LTR", s[s.RTL = 1] = "RTL", s;
}(X || (X = {}));
const Ss = X.LTR, hf = X.RTL;
function Hl(s) {
let t2 = [];
for (let e2 = 0; e2 < s.length; e2++)
t2.push(1 << +s[e2]);
return t2;
}
const af = /* @__PURE__ */ Hl("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"), cf = /* @__PURE__ */ Hl("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"), Cs = /* @__PURE__ */ Object.create(null), Lt = [];
for (let s of ["()", "[]", "{}"]) {
let t2 = /* @__PURE__ */ s.charCodeAt(0), e2 = /* @__PURE__ */ s.charCodeAt(1);
Cs[t2] = e2, Cs[e2] = -t2;
}
function ff(s) {
return s <= 247 ? af[s] : 1424 <= s && s <= 1524 ? 2 : 1536 <= s && s <= 1785 ? cf[s - 1536] : 1774 <= s && s <= 2220 ? 4 : 8192 <= s && s <= 8203 ? 256 : 64336 <= s && s <= 65023 ? 4 : s == 8204 ? 256 : 1;
}
const uf = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
class Fe {
/**
@internal
*/
constructor(t2, e2, i2) {
this.from = t2, this.to = e2, this.level = i2;
}
/**
The direction of this span.
*/
get dir() {
return this.level % 2 ? hf : Ss;
}
/**
@internal
*/
side(t2, e2) {
return this.dir == e2 == t2 ? this.to : this.from;
}
/**
@internal
*/
static find(t2, e2, i2, n2) {
let r2 = -1;
for (let o = 0; o < t2.length; o++) {
let l = t2[o];
if (l.from <= e2 && l.to >= e2) {
if (l.level == i2)
return o;
(r2 < 0 || (n2 != 0 ? n2 < 0 ? l.from < e2 : l.to > e2 : t2[r2].level > l.level)) && (r2 = o);
}
}
if (r2 < 0)
throw new RangeError("Index out of range");
return r2;
}
}
const j$1 = [];
function df(s, t2) {
let e2 = s.length, i2 = t2 == Ss ? 1 : 2, n2 = t2 == Ss ? 2 : 1;
if (!s || i2 == 1 && !uf.test(s))
return $l(e2);
for (let o = 0, l = i2, h2 = i2; o < e2; o++) {
let a2 = ff(s.charCodeAt(o));
a2 == 512 ? a2 = l : a2 == 8 && h2 == 4 && (a2 = 16), j$1[o] = a2 == 4 ? 2 : a2, a2 & 7 && (h2 = a2), l = a2;
}
for (let o = 0, l = i2, h2 = i2; o < e2; o++) {
let a2 = j$1[o];
if (a2 == 128)
o < e2 - 1 && l == j$1[o + 1] && l & 24 ? a2 = j$1[o] = l : j$1[o] = 256;
else if (a2 == 64) {
let c2 = o + 1;
for (; c2 < e2 && j$1[c2] == 64; )
c2++;
let f2 = o && l == 8 || c2 < e2 && j$1[c2] == 8 ? h2 == 1 ? 1 : 8 : 256;
for (let u2 = o; u2 < c2; u2++)
j$1[u2] = f2;
o = c2 - 1;
} else
a2 == 8 && h2 == 1 && (j$1[o] = 1);
l = a2, a2 & 7 && (h2 = a2);
}
for (let o = 0, l = 0, h2 = 0, a2, c2, f2; o < e2; o++)
if (c2 = Cs[a2 = s.charCodeAt(o)])
if (c2 < 0) {
for (let u2 = l - 3; u2 >= 0; u2 -= 3)
if (Lt[u2 + 1] == -c2) {
let d2 = Lt[u2 + 2], p2 = d2 & 2 ? i2 : d2 & 4 ? d2 & 1 ? n2 : i2 : 0;
p2 && (j$1[o] = j$1[Lt[u2]] = p2), l = u2;
break;
}
} else {
if (Lt.length == 189)
break;
Lt[l++] = o, Lt[l++] = a2, Lt[l++] = h2;
}
else if ((f2 = j$1[o]) == 2 || f2 == 1) {
let u2 = f2 == i2;
h2 = u2 ? 0 : 1;
for (let d2 = l - 3; d2 >= 0; d2 -= 3) {
let p2 = Lt[d2 + 2];
if (p2 & 2)
break;
if (u2)
Lt[d2 + 2] |= 2;
else {
if (p2 & 4)
break;
Lt[d2 + 2] |= 4;
}
}
}
for (let o = 0; o < e2; o++)
if (j$1[o] == 256) {
let l = o + 1;
for (; l < e2 && j$1[l] == 256; )
l++;
let h2 = (o ? j$1[o - 1] : i2) == 1, a2 = (l < e2 ? j$1[l] : i2) == 1, c2 = h2 == a2 ? h2 ? 1 : 2 : i2;
for (let f2 = o; f2 < l; f2++)
j$1[f2] = c2;
o = l - 1;
}
let r2 = [];
if (i2 == 1)
for (let o = 0; o < e2; ) {
let l = o, h2 = j$1[o++] != 1;
for (; o < e2 && h2 == (j$1[o] != 1); )
o++;
if (h2)
for (let a2 = o; a2 > l; ) {
let c2 = a2, f2 = j$1[--a2] != 2;
for (; a2 > l && f2 == (j$1[a2 - 1] != 2); )
a2--;
r2.push(new Fe(a2, c2, f2 ? 2 : 1));
}
else
r2.push(new Fe(l, o, 0));
}
else
for (let o = 0; o < e2; ) {
let l = o, h2 = j$1[o++] == 2;
for (; o < e2 && h2 == (j$1[o] == 2); )
o++;
r2.push(new Fe(l, o, h2 ? 1 : 2));
}
return r2;
}
function $l(s) {
return [new Fe(0, s, 0)];
}
let Fl = "";
function pf(s, t2, e2, i2, n2) {
var r2;
let o = i2.head - s.from, l = -1;
if (o == 0) {
if (!n2 || !s.length)
return null;
t2[0].level != e2 && (o = t2[0].side(false, e2), l = 0);
} else if (o == s.length) {
if (n2)
return null;
let u2 = t2[t2.length - 1];
u2.level != e2 && (o = u2.side(true, e2), l = t2.length - 1);
}
l < 0 && (l = Fe.find(t2, o, (r2 = i2.bidiLevel) !== null && r2 !== void 0 ? r2 : -1, i2.assoc));
let h2 = t2[l];
o == h2.side(n2, e2) && (h2 = t2[l += n2 ? 1 : -1], o = h2.side(!n2, e2));
let a2 = n2 == (h2.dir == e2), c2 = xt(s.text, o, a2);
if (Fl = s.text.slice(Math.min(o, c2), Math.max(o, c2)), c2 != h2.side(n2, e2))
return b$2.cursor(c2 + s.from, a2 ? -1 : 1, h2.level);
let f2 = l == (n2 ? t2.length - 1 : 0) ? null : t2[l + (n2 ? 1 : -1)];
return !f2 && h2.level != e2 ? b$2.cursor(n2 ? s.to : s.from, n2 ? -1 : 1, e2) : f2 && f2.level < h2.level ? b$2.cursor(f2.side(!n2, e2) + s.from, n2 ? 1 : -1, f2.level) : b$2.cursor(c2 + s.from, n2 ? -1 : 1, h2.level);
}
const he = "￿";
class zl {
constructor(t2, e2) {
this.points = t2, this.text = "", this.lineSeparator = e2.facet(N$2.lineSeparator);
}
append(t2) {
this.text += t2;
}
lineBreak() {
this.text += he;
}
readRange(t2, e2) {
if (!t2)
return this;
let i2 = t2.parentNode;
for (let n2 = t2; ; ) {
this.findPointBefore(i2, n2), this.readNode(n2);
let r2 = n2.nextSibling;
if (r2 == e2)
break;
let o = W$1.get(n2), l = W$1.get(r2);
(o && l ? o.breakAfter : (o ? o.breakAfter : Rr(n2)) || Rr(r2) && (n2.nodeName != "BR" || n2.cmIgnore)) && this.lineBreak(), n2 = r2;
}
return this.findPointBefore(i2, e2), this;
}
readTextNode(t2) {
let e2 = t2.nodeValue;
for (let i2 of this.points)
i2.node == t2 && (i2.pos = this.text.length + Math.min(i2.offset, e2.length));
for (let i2 = 0, n2 = this.lineSeparator ? null : /\r\n?|\n/g; ; ) {
let r2 = -1, o = 1, l;
if (this.lineSeparator ? (r2 = e2.indexOf(this.lineSeparator, i2), o = this.lineSeparator.length) : (l = n2.exec(e2)) && (r2 = l.index, o = l[0].length), this.append(e2.slice(i2, r2 < 0 ? e2.length : r2)), r2 < 0)
break;
if (this.lineBreak(), o > 1)
for (let h2 of this.points)
h2.node == t2 && h2.pos > this.text.length && (h2.pos -= o - 1);
i2 = r2 + o;
}
}
readNode(t2) {
if (t2.cmIgnore)
return;
let e2 = W$1.get(t2), i2 = e2 && e2.overrideDOMText;
if (i2 != null) {
this.findPointInside(t2, i2.length);
for (let n2 = i2.iter(); !n2.next().done; )
n2.lineBreak ? this.lineBreak() : this.append(n2.value);
} else
t2.nodeType == 3 ? this.readTextNode(t2) : t2.nodeName == "BR" ? t2.nextSibling && this.lineBreak() : t2.nodeType == 1 && this.readRange(t2.firstChild, null);
}
findPointBefore(t2, e2) {
for (let i2 of this.points)
i2.node == t2 && t2.childNodes[i2.offset] == e2 && (i2.pos = this.text.length);
}
findPointInside(t2, e2) {
for (let i2 of this.points)
(t2.nodeType == 3 ? i2.node == t2 : t2.contains(i2.node)) && (i2.pos = this.text.length + Math.min(e2, i2.offset));
}
}
function Rr(s) {
return s.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(s.nodeName);
}
class Lr {
constructor(t2, e2) {
this.node = t2, this.offset = e2, this.pos = -1;
}
}
class Er extends W$1 {
constructor(t2) {
super(), this.view = t2, this.compositionDeco = T.none, this.decorations = [], this.dynamicDecorationMap = [], this.minWidth = 0, this.minWidthFrom = 0, this.minWidthTo = 0, this.impreciseAnchor = null, this.impreciseHead = null, this.forceSelection = false, this.lastUpdate = Date.now(), this.setDOM(t2.contentDOM), this.children = [new ut()], this.children[0].setParent(this), this.updateDeco(), this.updateInner([new _t(0, 0, 0, t2.state.doc.length)], 0);
}
get editorView() {
return this.view;
}
get length() {
return this.view.state.doc.length;
}
// Update the document view to a given state. scrollIntoView can be
// used as a hint to compute a new viewport that includes that
// position, if we know the editor is going to scroll that position
// into view.
update(t2) {
let e2 = t2.changedRanges;
this.minWidth > 0 && e2.length && (e2.every(({ fromA: o, toA: l }) => l < this.minWidthFrom || o > this.minWidthTo) ? (this.minWidthFrom = t2.changes.mapPos(this.minWidthFrom, 1), this.minWidthTo = t2.changes.mapPos(this.minWidthTo, 1)) : this.minWidth = this.minWidthFrom = this.minWidthTo = 0), this.view.inputState.composing < 0 ? this.compositionDeco = T.none : (t2.transactions.length || this.dirty) && (this.compositionDeco = mf(this.view, t2.changes)), (x$1.ie || x$1.chrome) && !this.compositionDeco.size && t2 && t2.state.doc.lines != t2.startState.doc.lines && (this.forceSelection = true);
let i2 = this.decorations, n2 = this.updateDeco(), r2 = kf(i2, n2, t2.changes);
return e2 = _t.extendWithRanges(e2, r2), this.dirty == 0 && e2.length == 0 ? false : (this.updateInner(e2, t2.startState.doc.length), t2.transactions.length && (this.lastUpdate = Date.now()), true);
}
// Used by update and the constructor do perform the actual DOM
// update
updateInner(t2, e2) {
this.view.viewState.mustMeasureContent = true, this.updateChildren(t2, e2);
let { observer: i2 } = this.view;
i2.ignore(() => {
this.dom.style.height = this.view.viewState.contentHeight + "px", this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
let r2 = x$1.chrome || x$1.ios ? { node: i2.selectionRange.focusNode, written: false } : void 0;
this.sync(r2), this.dirty = 0, r2 && (r2.written || i2.selectionRange.focusNode != r2.node) && (this.forceSelection = true), this.dom.style.height = "";
});
let n2 = [];
if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
for (let r2 of this.children)
r2 instanceof Ae && r2.widget instanceof Nr && n2.push(r2.dom);
i2.updateGaps(n2);
}
updateChildren(t2, e2) {
let i2 = this.childCursor(e2);
for (let n2 = t2.length - 1; ; n2--) {
let r2 = n2 >= 0 ? t2[n2] : null;
if (!r2)
break;
let { fromA: o, toA: l, fromB: h2, toB: a2 } = r2, { content: c2, breakAtStart: f2, openStart: u2, openEnd: d2 } = Qs.build(this.view.state.doc, h2, a2, this.decorations, this.dynamicDecorationMap), { i: p2, off: w2 } = i2.findPos(l, 1), { i: g, off: y2 } = i2.findPos(o, -1);
bl(this, g, y2, p2, w2, c2, f2, u2, d2);
}
}
// Sync the DOM selection to this.state.selection
updateSelection(t2 = false, e2 = false) {
if ((t2 || !this.view.observer.selectionRange.focusNode) && this.view.observer.readSelectionRange(), !(e2 || this.mayControlSelection()))
return;
let i2 = this.forceSelection;
this.forceSelection = false;
let n2 = this.view.state.selection.main, r2 = this.domAtPos(n2.anchor), o = n2.empty ? r2 : this.domAtPos(n2.head);
if (x$1.gecko && n2.empty && gf(r2)) {
let h2 = document.createTextNode("");
this.view.observer.ignore(() => r2.node.insertBefore(h2, r2.node.childNodes[r2.offset] || null)), r2 = o = new ht(h2, 0), i2 = true;
}
let l = this.view.observer.selectionRange;
(i2 || !l.focusNode || !nn(r2.node, r2.offset, l.anchorNode, l.anchorOffset) || !nn(o.node, o.offset, l.focusNode, l.focusOffset)) && (this.view.observer.ignore(() => {
x$1.android && x$1.chrome && this.dom.contains(l.focusNode) && xf(l.focusNode, this.dom) && (this.dom.blur(), this.dom.focus({ preventScroll: true }));
let h2 = en(this.view.root);
if (h2)
if (n2.empty) {
if (x$1.gecko) {
let a2 = yf(r2.node, r2.offset);
if (a2 && a2 != 3) {
let c2 = Wl(r2.node, r2.offset, a2 == 1 ? 1 : -1);
c2 && (r2 = new ht(c2, a2 == 1 ? 0 : c2.nodeValue.length));
}
}
h2.collapse(r2.node, r2.offset), n2.bidiLevel != null && l.cursorBidiLevel != null && (l.cursorBidiLevel = n2.bidiLevel);
} else if (h2.extend) {
h2.collapse(r2.node, r2.offset);
try {
h2.extend(o.node, o.offset);
} catch {
}
} else {
let a2 = document.createRange();
n2.anchor > n2.head && ([r2, o] = [o, r2]), a2.setEnd(o.node, o.offset), a2.setStart(r2.node, r2.offset), h2.removeAllRanges(), h2.addRange(a2);
}
}), this.view.observer.setSelectionRange(r2, o)), this.impreciseAnchor = r2.precise ? null : new ht(l.anchorNode, l.anchorOffset), this.impreciseHead = o.precise ? null : new ht(l.focusNode, l.focusOffset);
}
enforceCursorAssoc() {
if (this.compositionDeco.size)
return;
let { view: t2 } = this, e2 = t2.state.selection.main, i2 = en(t2.root), { anchorNode: n2, anchorOffset: r2 } = t2.observer.selectionRange;
if (!i2 || !e2.empty || !e2.assoc || !i2.modify)
return;
let o = ut.find(this, e2.head);
if (!o)
return;
let l = o.posAtStart;
if (e2.head == l || e2.head == l + o.length)
return;
let h2 = this.coordsAt(e2.head, -1), a2 = this.coordsAt(e2.head, 1);
if (!h2 || !a2 || h2.bottom > a2.top)
return;
let c2 = this.domAtPos(e2.head + e2.assoc);
i2.collapse(c2.node, c2.offset), i2.modify("move", e2.assoc < 0 ? "forward" : "backward", "lineboundary"), t2.observer.readSelectionRange();
let f2 = t2.observer.selectionRange;
t2.docView.posFromDOM(f2.anchorNode, f2.anchorOffset) != e2.from && i2.collapse(n2, r2);
}
mayControlSelection() {
let t2 = this.view.root.activeElement;
return t2 == this.dom || ji(this.dom, this.view.observer.selectionRange) && !(t2 && this.dom.contains(t2));
}
nearest(t2) {
for (let e2 = t2; e2; ) {
let i2 = W$1.get(e2);
if (i2 && i2.rootView == this)
return i2;
e2 = e2.parentNode;
}
return null;
}
posFromDOM(t2, e2) {
let i2 = this.nearest(t2);
if (!i2)
throw new RangeError("Trying to find position for a DOM position outside of the document");
return i2.localPosFromDOM(t2, e2) + i2.posAtStart;
}
domAtPos(t2) {
let { i: e2, off: i2 } = this.childCursor().findPos(t2, -1);
for (; e2 < this.children.length - 1; ) {
let n2 = this.children[e2];
if (i2 < n2.length || n2 instanceof ut)
break;
e2++, i2 = 0;
}
return this.children[e2].domAtPos(i2);
}
coordsAt(t2, e2) {
for (let i2 = this.length, n2 = this.children.length - 1; ; n2--) {
let r2 = this.children[n2], o = i2 - r2.breakAfter - r2.length;
if (t2 > o || t2 == o && r2.type != U.WidgetBefore && r2.type != U.WidgetAfter && (!n2 || e2 == 2 || this.children[n2 - 1].breakAfter || this.children[n2 - 1].type == U.WidgetBefore && e2 > -2))
return r2.coordsAt(t2 - o, e2);
i2 = o;
}
}
measureVisibleLineHeights(t2) {
let e2 = [], { from: i2, to: n2 } = t2, r2 = this.view.contentDOM.clientWidth, o = r2 > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1, l = -1, h2 = this.view.textDirection == X.LTR;
for (let a2 = 0, c2 = 0; c2 < this.children.length; c2++) {
let f2 = this.children[c2], u2 = a2 + f2.length;
if (u2 > n2)
break;
if (a2 >= i2) {
let d2 = f2.dom.getBoundingClientRect();
if (e2.push(d2.height), o) {
let p2 = f2.dom.lastChild, w2 = p2 ? di(p2) : [];
if (w2.length) {
let g = w2[w2.length - 1], y2 = h2 ? g.right - d2.left : d2.right - g.left;
y2 > l && (l = y2, this.minWidth = r2, this.minWidthFrom = a2, this.minWidthTo = u2);
}
}
}
a2 = u2 + f2.breakAfter;
}
return e2;
}
textDirectionAt(t2) {
let { i: e2 } = this.childPos(t2, 1);
return getComputedStyle(this.children[e2].dom).direction == "rtl" ? X.RTL : X.LTR;
}
measureTextSize() {
for (let n2 of this.children)
if (n2 instanceof ut) {
let r2 = n2.measureTextSize();
if (r2)
return r2;
}
let t2 = document.createElement("div"), e2, i2;
return t2.className = "cm-line", t2.style.width = "99999px", t2.textContent = "abc def ghi jkl mno pqr stu", this.view.observer.ignore(() => {
this.dom.appendChild(t2);
let n2 = di(t2.firstChild)[0];
e2 = t2.getBoundingClientRect().height, i2 = n2 ? n2.width / 27 : 7, t2.remove();
}), { lineHeight: e2, charWidth: i2 };
}
childCursor(t2 = this.length) {
let e2 = this.children.length;
return e2 && (t2 -= this.children[--e2].length), new yl(this.children, t2, e2);
}
computeBlockGapDeco() {
let t2 = [], e2 = this.view.viewState;
for (let i2 = 0, n2 = 0; ; n2++) {
let r2 = n2 == e2.viewports.length ? null : e2.viewports[n2], o = r2 ? r2.from - 1 : this.length;
if (o > i2) {
let l = e2.lineBlockAt(o).bottom - e2.lineBlockAt(i2).top;
t2.push(T.replace({
widget: new Nr(l),
block: true,
inclusive: true,
isBlockGap: true
}).range(i2, o));
}
if (!r2)
break;
i2 = r2.to + 1;
}
return T.set(t2);
}
updateDeco() {
let t2 = this.view.state.facet(gi).map((e2, i2) => (this.dynamicDecorationMap[i2] = typeof e2 == "function") ? e2(this.view) : e2);
for (let e2 = t2.length; e2 < t2.length + 3; e2++)
this.dynamicDecorationMap[e2] = false;
return this.decorations = [
...t2,
this.compositionDeco,
this.computeBlockGapDeco(),
this.view.viewState.lineGapDeco
];
}
scrollIntoView(t2) {
let { range: e2 } = t2, i2 = this.coordsAt(e2.head, e2.empty ? e2.assoc : e2.head > e2.anchor ? -1 : 1), n2;
if (!i2)
return;
!e2.empty && (n2 = this.coordsAt(e2.anchor, e2.anchor > e2.head ? -1 : 1)) && (i2 = {
left: Math.min(i2.left, n2.left),
top: Math.min(i2.top, n2.top),
right: Math.max(i2.right, n2.right),
bottom: Math.max(i2.bottom, n2.bottom)
});
let r2 = 0, o = 0, l = 0, h2 = 0;
for (let c2 of this.view.state.facet(Il).map((f2) => f2(this.view)))
if (c2) {
let { left: f2, right: u2, top: d2, bottom: p2 } = c2;
f2 != null && (r2 = Math.max(r2, f2)), u2 != null && (o = Math.max(o, u2)), d2 != null && (l = Math.max(l, d2)), p2 != null && (h2 = Math.max(h2, p2));
}
let a2 = {
left: i2.left - r2,
top: i2.top - l,
right: i2.right + o,
bottom: i2.bottom + h2
};
Jc(this.view.scrollDOM, a2, e2.head < e2.anchor ? -1 : 1, t2.x, t2.y, t2.xMargin, t2.yMargin, this.view.textDirection == X.LTR);
}
}
function gf(s) {
return s.node.nodeType == 1 && s.node.firstChild && (s.offset == 0 || s.node.childNodes[s.offset - 1].contentEditable == "false") && (s.offset == s.node.childNodes.length || s.node.childNodes[s.offset].contentEditable == "false");
}
class Nr extends ye {
constructor(t2) {
super(), this.height = t2;
}
toDOM() {
let t2 = document.createElement("div");
return this.updateDOM(t2), t2;
}
eq(t2) {
return t2.height == this.height;
}
updateDOM(t2) {
return t2.style.height = this.height + "px", true;
}
get estimatedHeight() {
return this.height;
}
}
function _l(s) {
let t2 = s.observer.selectionRange, e2 = t2.focusNode && Wl(t2.focusNode, t2.focusOffset, 0);
if (!e2)
return null;
let i2 = s.docView.nearest(e2);
if (!i2)
return null;
if (i2 instanceof ut) {
let n2 = e2;
for (; n2.parentNode != i2.dom; )
n2 = n2.parentNode;
let r2 = n2.previousSibling;
for (; r2 && !W$1.get(r2); )
r2 = r2.previousSibling;
let o = r2 ? W$1.get(r2).posAtEnd : i2.posAtStart;
return { from: o, to: o, node: n2, text: e2 };
} else {
for (; ; ) {
let { parent: r2 } = i2;
if (!r2)
return null;
if (r2 instanceof ut)
break;
i2 = r2;
}
let n2 = i2.posAtStart;
return { from: n2, to: n2 + i2.length, node: i2.dom, text: e2 };
}
}
function mf(s, t2) {
let e2 = _l(s);
if (!e2)
return T.none;
let { from: i2, to: n2, node: r2, text: o } = e2, l = t2.mapPos(i2, 1), h2 = Math.max(l, t2.mapPos(n2, -1)), { state: a2 } = s, c2 = r2.nodeType == 3 ? r2.nodeValue : new zl([], a2).readRange(r2.firstChild, null).text;
if (h2 - l < c2.length)
if (a2.doc.sliceString(l, Math.min(a2.doc.length, l + c2.length), he) == c2)
h2 = l + c2.length;
else if (a2.doc.sliceString(Math.max(0, h2 - c2.length), h2, he) == c2)
l = h2 - c2.length;
else
return T.none;
else if (a2.doc.sliceString(l, h2, he) != c2)
return T.none;
let f2 = W$1.get(r2);
return f2 instanceof Sl ? f2 = f2.widget.topView : f2 && (f2.parent = null), T.set(T.replace({ widget: new wf(r2, o, f2), inclusive: true }).range(l, h2));
}
class wf extends ye {
constructor(t2, e2, i2) {
super(), this.top = t2, this.text = e2, this.topView = i2;
}
eq(t2) {
return this.top == t2.top && this.text == t2.text;
}
toDOM() {
return this.top;
}
ignoreEvent() {
return false;
}
get customView() {
return Sl;
}
}
function Wl(s, t2, e2) {
for (; ; ) {
if (s.nodeType == 3)
return s;
if (s.nodeType == 1 && t2 > 0 && e2 <= 0)
s = s.childNodes[t2 - 1], t2 = pi(s);
else if (s.nodeType == 1 && t2 < s.childNodes.length && e2 >= 0)
s = s.childNodes[t2], t2 = 0;
else
return null;
}
}
function yf(s, t2) {
return s.nodeType != 1 ? 0 : (t2 && s.childNodes[t2 - 1].contentEditable == "false" ? 1 : 0) | (t2 < s.childNodes.length && s.childNodes[t2].contentEditable == "false" ? 2 : 0);
}
class bf {
constructor() {
this.changes = [];
}
compareRange(t2, e2) {
xs(t2, e2, this.changes);
}
comparePoint(t2, e2) {
xs(t2, e2, this.changes);
}
}
function kf(s, t2, e2) {
let i2 = new bf();
return $.compare(s, t2, e2, i2), i2.changes;
}
function xf(s, t2) {
for (let e2 = s; e2 && e2 != t2; e2 = e2.assignedSlot || e2.parentNode)
if (e2.nodeType == 1 && e2.contentEditable == "false")
return true;
return false;
}
function vf(s, t2, e2 = 1) {
let i2 = s.charCategorizer(t2), n2 = s.doc.lineAt(t2), r2 = t2 - n2.from;
if (n2.length == 0)
return b$2.cursor(t2);
r2 == 0 ? e2 = 1 : r2 == n2.length && (e2 = -1);
let o = r2, l = r2;
e2 < 0 ? o = xt(n2.text, r2, false) : l = xt(n2.text, r2);
let h2 = i2(n2.text.slice(o, l));
for (; o > 0; ) {
let a2 = xt(n2.text, o, false);
if (i2(n2.text.slice(a2, o)) != h2)
break;
o = a2;
}
for (; l < n2.length; ) {
let a2 = xt(n2.text, l);
if (i2(n2.text.slice(l, a2)) != h2)
break;
l = a2;
}
return b$2.range(o + n2.from, l + n2.from);
}
function Sf(s, t2) {
return t2.left > s ? t2.left - s : Math.max(0, s - t2.right);
}
function Cf(s, t2) {
return t2.top > s ? t2.top - s : Math.max(0, s - t2.bottom);
}
function $n(s, t2) {
return s.top < t2.bottom - 1 && s.bottom > t2.top + 1;
}
function Vr(s, t2) {
return t2 < s.top ? { top: t2, left: s.left, right: s.right, bottom: s.bottom } : s;
}
function Ir(s, t2) {
return t2 > s.bottom ? { top: s.top, left: s.left, right: s.right, bottom: t2 } : s;
}
function As(s, t2, e2) {
let i2, n2, r2, o, l = false, h2, a2, c2, f2;
for (let p2 = s.firstChild; p2; p2 = p2.nextSibling) {
let w2 = di(p2);
for (let g = 0; g < w2.length; g++) {
let y2 = w2[g];
n2 && $n(n2, y2) && (y2 = Vr(Ir(y2, n2.bottom), n2.top));
let O2 = Sf(t2, y2), S2 = Cf(e2, y2);
if (O2 == 0 && S2 == 0)
return p2.nodeType == 3 ? Hr(p2, t2, e2) : As(p2, t2, e2);
if (!i2 || o > S2 || o == S2 && r2 > O2) {
i2 = p2, n2 = y2, r2 = O2, o = S2;
let D2 = S2 ? e2 < y2.top ? -1 : 1 : O2 ? t2 < y2.left ? -1 : 1 : 0;
l = !D2 || (D2 > 0 ? g < w2.length - 1 : g > 0);
}
O2 == 0 ? e2 > y2.bottom && (!c2 || c2.bottom < y2.bottom) ? (h2 = p2, c2 = y2) : e2 < y2.top && (!f2 || f2.top > y2.top) && (a2 = p2, f2 = y2) : c2 && $n(c2, y2) ? c2 = Ir(c2, y2.bottom) : f2 && $n(f2, y2) && (f2 = Vr(f2, y2.top));
}
}
if (c2 && c2.bottom >= e2 ? (i2 = h2, n2 = c2) : f2 && f2.top <= e2 && (i2 = a2, n2 = f2), !i2)
return { node: s, offset: 0 };
let u2 = Math.max(n2.left, Math.min(n2.right, t2));
if (i2.nodeType == 3)
return Hr(i2, u2, e2);
if (l && i2.contentEditable != "false")
return As(i2, u2, e2);
let d2 = Array.prototype.indexOf.call(s.childNodes, i2) + (t2 >= (n2.left + n2.right) / 2 ? 1 : 0);
return { node: s, offset: d2 };
}
function Hr(s, t2, e2) {
let i2 = s.nodeValue.length, n2 = -1, r2 = 1e9, o = 0;
for (let l = 0; l < i2; l++) {
let h2 = Ke(s, l, l + 1).getClientRects();
for (let a2 = 0; a2 < h2.length; a2++) {
let c2 = h2[a2];
if (c2.top == c2.bottom)
continue;
o || (o = t2 - c2.left);
let f2 = (c2.top > e2 ? c2.top - e2 : e2 - c2.bottom) - 1;
if (c2.left - 1 <= t2 && c2.right + 1 >= t2 && f2 < r2) {
let u2 = t2 >= (c2.left + c2.right) / 2, d2 = u2;
if ((x$1.chrome || x$1.gecko) && Ke(s, l).getBoundingClientRect().left == c2.right && (d2 = !u2), f2 <= 0)
return { node: s, offset: l + (d2 ? 1 : 0) };
n2 = l + (d2 ? 1 : 0), r2 = f2;
}
}
}
return { node: s, offset: n2 > -1 ? n2 : o > 0 ? s.nodeValue.length : 0 };
}
function jl(s, { x: t2, y: e2 }, i2, n2 = -1) {
var r2;
let o = s.contentDOM.getBoundingClientRect(), l = o.top + s.viewState.paddingTop, h2, { docHeight: a2 } = s.viewState, c2 = e2 - l;
if (c2 < 0)
return 0;
if (c2 > a2)
return s.state.doc.length;
for (let y2 = s.defaultLineHeight / 2, O2 = false; h2 = s.elementAtHeight(c2), h2.type != U.Text; )
for (; c2 = n2 > 0 ? h2.bottom + y2 : h2.top - y2, !(c2 >= 0 && c2 <= a2); ) {
if (O2)
return i2 ? null : 0;
O2 = true, n2 = -n2;
}
e2 = l + c2;
let f2 = h2.from;
if (f2 < s.viewport.from)
return s.viewport.from == 0 ? 0 : i2 ? null : $r(s, o, h2, t2, e2);
if (f2 > s.viewport.to)
return s.viewport.to == s.state.doc.length ? s.state.doc.length : i2 ? null : $r(s, o, h2, t2, e2);
let u2 = s.dom.ownerDocument, d2 = s.root.elementFromPoint ? s.root : u2, p2 = d2.elementFromPoint(t2, e2);
p2 && !s.contentDOM.contains(p2) && (p2 = null), p2 || (t2 = Math.max(o.left + 1, Math.min(o.right - 1, t2)), p2 = d2.elementFromPoint(t2, e2), p2 && !s.contentDOM.contains(p2) && (p2 = null));
let w2, g = -1;
if (p2 && ((r2 = s.docView.nearest(p2)) === null || r2 === void 0 ? void 0 : r2.isEditable) != false) {
if (u2.caretPositionFromPoint) {
let y2 = u2.caretPositionFromPoint(t2, e2);
y2 && ({ offsetNode: w2, offset: g } = y2);
} else if (u2.caretRangeFromPoint) {
let y2 = u2.caretRangeFromPoint(t2, e2);
y2 && ({ startContainer: w2, startOffset: g } = y2, (!s.contentDOM.contains(w2) || x$1.safari && Af(w2, g, t2) || x$1.chrome && Of(w2, g, t2)) && (w2 = void 0));
}
}
if (!w2 || !s.docView.dom.contains(w2)) {
let y2 = ut.find(s.docView, f2);
if (!y2)
return c2 > h2.top + h2.height / 2 ? h2.to : h2.from;
({ node: w2, offset: g } = As(y2.dom, t2, e2));
}
return s.docView.posFromDOM(w2, g);
}
function $r(s, t2, e2, i2, n2) {
let r2 = Math.round((i2 - t2.left) * s.defaultCharacterWidth);
if (s.lineWrapping && e2.height > s.defaultLineHeight * 1.5) {
let l = Math.floor((n2 - e2.top) / s.defaultLineHeight);
r2 += l * s.viewState.heightOracle.lineLength;
}
let o = s.state.sliceDoc(e2.from, e2.to);
return e2.from + _c(o, r2, s.state.tabSize);
}
function Af(s, t2, e2) {
let i2;
if (s.nodeType != 3 || t2 != (i2 = s.nodeValue.length))
return false;
for (let n2 = s.nextSibling; n2; n2 = n2.nextSibling)
if (n2.nodeType != 1 || n2.nodeName != "BR")
return false;
return Ke(s, i2 - 1, i2).getBoundingClientRect().left > e2;
}
function Of(s, t2, e2) {
if (t2 != 0)
return false;
for (let n2 = s; ; ) {
let r2 = n2.parentNode;
if (!r2 || r2.nodeType != 1 || r2.firstChild != n2)
return false;
if (r2.classList.contains("cm-line"))
break;
n2 = r2;
}
let i2 = s.nodeType == 1 ? s.getBoundingClientRect() : Ke(s, 0, Math.max(s.nodeValue.length, 1)).getBoundingClientRect();
return e2 - i2.left > 5;
}
function Mf(s, t2, e2, i2) {
let n2 = s.state.doc.lineAt(t2.head), r2 = !i2 || !s.lineWrapping ? null : s.coordsAtPos(t2.assoc < 0 && t2.head > n2.from ? t2.head - 1 : t2.head);
if (r2) {
let h2 = s.dom.getBoundingClientRect(), a2 = s.textDirectionAt(n2.from), c2 = s.posAtCoords({
x: e2 == (a2 == X.LTR) ? h2.right - 1 : h2.left + 1,
y: (r2.top + r2.bottom) / 2
});
if (c2 != null)
return b$2.cursor(c2, e2 ? -1 : 1);
}
let o = ut.find(s.docView, t2.head), l = o ? e2 ? o.posAtEnd : o.posAtStart : e2 ? n2.to : n2.from;
return b$2.cursor(l, e2 ? -1 : 1);
}
function Fr(s, t2, e2, i2) {
let n2 = s.state.doc.lineAt(t2.head), r2 = s.bidiSpans(n2), o = s.textDirectionAt(n2.from);
for (let l = t2, h2 = null; ; ) {
let a2 = pf(n2, r2, o, l, e2), c2 = Fl;
if (!a2) {
if (n2.number == (e2 ? s.state.doc.lines : 1))
return l;
c2 = `
`, n2 = s.state.doc.line(n2.number + (e2 ? 1 : -1)), r2 = s.bidiSpans(n2), a2 = b$2.cursor(e2 ? n2.from : n2.to);
}
if (h2) {
if (!h2(c2))
return l;
} else {
if (!i2)
return a2;
h2 = i2(c2);
}
l = a2;
}
}
function Df(s, t2, e2) {
let i2 = s.state.charCategorizer(t2), n2 = i2(e2);
return (r2) => {
let o = i2(r2);
return n2 == Jt.Space && (n2 = o), n2 == o;
};
}
function Tf(s, t2, e2, i2) {
let n2 = t2.head, r2 = e2 ? 1 : -1;
if (n2 == (e2 ? s.state.doc.length : 0))
return b$2.cursor(n2, t2.assoc);
let o = t2.goalColumn, l, h2 = s.contentDOM.getBoundingClientRect(), a2 = s.coordsAtPos(n2), c2 = s.documentTop;
if (a2)
o == null && (o = a2.left - h2.left), l = r2 < 0 ? a2.top : a2.bottom;
else {
let d2 = s.viewState.lineBlockAt(n2);
o == null && (o = Math.min(h2.right - h2.left, s.defaultCharacterWidth * (n2 - d2.from))), l = (r2 < 0 ? d2.top : d2.bottom) + c2;
}
let f2 = h2.left + o, u2 = i2 ?? s.defaultLineHeight >> 1;
for (let d2 = 0; ; d2 += 10) {
let p2 = l + (u2 + d2) * r2, w2 = jl(s, { x: f2, y: p2 }, false, r2);
if (p2 < h2.top || p2 > h2.bottom || (r2 < 0 ? w2 < n2 : w2 > n2))
return b$2.cursor(w2, t2.assoc, void 0, o);
}
}
function Fn(s, t2, e2) {
let i2 = s.state.facet(Vl).map((n2) => n2(s));
for (; ; ) {
let n2 = false;
for (let r2 of i2)
r2.between(e2.from - 1, e2.from + 1, (o, l, h2) => {
e2.from > o && e2.from < l && (e2 = t2.head > e2.from ? b$2.cursor(o, 1) : b$2.cursor(l, -1), n2 = true);
});
if (!n2)
return e2;
}
}
class Pf {
constructor(t2) {
this.lastKeyCode = 0, this.lastKeyTime = 0, this.lastTouchTime = 0, this.lastFocusTime = 0, this.lastScrollTop = 0, this.lastScrollLeft = 0, this.chromeScrollHack = -1, this.pendingIOSKey = void 0, this.lastSelectionOrigin = null, this.lastSelectionTime = 0, this.lastEscPress = 0, this.lastContextMenu = 0, this.scrollHandlers = [], this.registeredEvents = [], this.customHandlers = [], this.composing = -1, this.compositionFirstChange = null, this.compositionEndedAt = 0, this.mouseSelection = null;
let e2 = (i2, n2) => {
this.ignoreDuringComposition(n2) || n2.type == "keydown" && this.keydown(t2, n2) || (this.mustFlushObserver(n2) && t2.observer.forceFlush(), this.runCustomHandlers(n2.type, t2, n2) ? n2.preventDefault() : i2(t2, n2));
};
for (let i2 in Y$1) {
let n2 = Y$1[i2];
t2.contentDOM.addEventListener(i2, (r2) => {
zr(t2, r2) && e2(n2, r2);
}, Os[i2]), this.registeredEvents.push(i2);
}
t2.scrollDOM.addEventListener("mousedown", (i2) => {
i2.target == t2.scrollDOM && e2(Y$1.mousedown, i2);
}), x$1.chrome && x$1.chrome_version == 102 && t2.scrollDOM.addEventListener("wheel", () => {
this.chromeScrollHack < 0 ? t2.contentDOM.style.pointerEvents = "none" : window.clearTimeout(this.chromeScrollHack), this.chromeScrollHack = setTimeout(() => {
this.chromeScrollHack = -1, t2.contentDOM.style.pointerEvents = "";
}, 100);
}, { passive: true }), this.notifiedFocused = t2.hasFocus, x$1.safari && t2.contentDOM.addEventListener("input", () => null);
}
setSelectionOrigin(t2) {
this.lastSelectionOrigin = t2, this.lastSelectionTime = Date.now();
}
ensureHandlers(t2, e2) {
var i2;
let n2;
this.customHandlers = [];
for (let r2 of e2)
if (n2 = (i2 = r2.update(t2).spec) === null || i2 === void 0 ? void 0 : i2.domEventHandlers) {
this.customHandlers.push({ plugin: r2.value, handlers: n2 });
for (let o in n2)
this.registeredEvents.indexOf(o) < 0 && o != "scroll" && (this.registeredEvents.push(o), t2.contentDOM.addEventListener(o, (l) => {
zr(t2, l) && this.runCustomHandlers(o, t2, l) && l.preventDefault();
}));
}
}
runCustomHandlers(t2, e2, i2) {
for (let n2 of this.customHandlers) {
let r2 = n2.handlers[t2];
if (r2)
try {
if (r2.call(n2.plugin, i2, e2) || i2.defaultPrevented)
return true;
} catch (o) {
zt(e2.state, o);
}
}
return false;
}
runScrollHandlers(t2, e2) {
this.lastScrollTop = t2.scrollDOM.scrollTop, this.lastScrollLeft = t2.scrollDOM.scrollLeft;
for (let i2 of this.customHandlers) {
let n2 = i2.handlers.scroll;
if (n2)
try {
n2.call(i2.plugin, e2, t2);
} catch (r2) {
zt(t2.state, r2);
}
}
}
keydown(t2, e2) {
if (this.lastKeyCode = e2.keyCode, this.lastKeyTime = Date.now(), e2.keyCode == 9 && Date.now() < this.lastEscPress + 2e3)
return true;
if (x$1.android && x$1.chrome && !e2.synthetic && (e2.keyCode == 13 || e2.keyCode == 8))
return t2.observer.delayAndroidKey(e2.key, e2.keyCode), true;
let i2;
return x$1.ios && !e2.synthetic && !e2.altKey && !e2.metaKey && ((i2 = ql.find((n2) => n2.keyCode == e2.keyCode)) && !e2.ctrlKey || Bf.indexOf(e2.key) > -1 && e2.ctrlKey && !e2.shiftKey) ? (this.pendingIOSKey = i2 || e2, setTimeout(() => this.flushIOSKey(t2), 250), true) : false;
}
flushIOSKey(t2) {
let e2 = this.pendingIOSKey;
return e2 ? (this.pendingIOSKey = void 0, $e(t2.contentDOM, e2.key, e2.keyCode)) : false;
}
ignoreDuringComposition(t2) {
return /^key/.test(t2.type) ? this.composing > 0 ? true : x$1.safari && !x$1.ios && Date.now() - this.compositionEndedAt < 100 ? (this.compositionEndedAt = 0, true) : false : false;
}
mustFlushObserver(t2) {
return t2.type == "keydown" && t2.keyCode != 229;
}
startMouseSelection(t2) {
this.mouseSelection && this.mouseSelection.destroy(), this.mouseSelection = t2;
}
update(t2) {
this.mouseSelection && this.mouseSelection.update(t2), t2.transactions.length && (this.lastKeyCode = this.lastSelectionTime = 0);
}
destroy() {
this.mouseSelection && this.mouseSelection.destroy();
}
}
const ql = [
{ key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
{ key: "Enter", keyCode: 13, inputType: "insertParagraph" },
{ key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
], Bf = "dthko", Kl = [16, 17, 18, 20, 91, 92, 224, 225];
function Di(s) {
return s * 0.7 + 8;
}
class Rf {
constructor(t2, e2, i2, n2) {
this.view = t2, this.style = i2, this.mustSelect = n2, this.scrollSpeed = { x: 0, y: 0 }, this.scrolling = -1, this.lastEvent = e2, this.scrollParent = Xc(t2.contentDOM);
let r2 = t2.contentDOM.ownerDocument;
r2.addEventListener("mousemove", this.move = this.move.bind(this)), r2.addEventListener("mouseup", this.up = this.up.bind(this)), this.extend = e2.shiftKey, this.multiple = t2.state.facet(N$2.allowMultipleSelections) && Lf(t2, e2), this.dragMove = Ef(t2, e2), this.dragging = Nf(t2, e2) && Jl(e2) == 1 ? null : false, this.dragging === false && (e2.preventDefault(), this.select(e2));
}
move(t2) {
var e2;
if (t2.buttons == 0)
return this.destroy();
if (this.dragging !== false)
return;
this.select(this.lastEvent = t2);
let i2 = 0, n2 = 0, r2 = ((e2 = this.scrollParent) === null || e2 === void 0 ? void 0 : e2.getBoundingClientRect()) || { left: 0, top: 0, right: this.view.win.innerWidth, bottom: this.view.win.innerHeight };
t2.clientX <= r2.left ? i2 = -Di(r2.left - t2.clientX) : t2.clientX >= r2.right && (i2 = Di(t2.clientX - r2.right)), t2.clientY <= r2.top ? n2 = -Di(r2.top - t2.clientY) : t2.clientY >= r2.bottom && (n2 = Di(t2.clientY - r2.bottom)), this.setScrollSpeed(i2, n2);
}
up(t2) {
this.dragging == null && this.select(this.lastEvent), this.dragging || t2.preventDefault(), this.destroy();
}
destroy() {
this.setScrollSpeed(0, 0);
let t2 = this.view.contentDOM.ownerDocument;
t2.removeEventListener("mousemove", this.move), t2.removeEventListener("mouseup", this.up), this.view.inputState.mouseSelection = null;
}
setScrollSpeed(t2, e2) {
this.scrollSpeed = { x: t2, y: e2 }, t2 || e2 ? this.scrolling < 0 && (this.scrolling = setInterval(() => this.scroll(), 50)) : this.scrolling > -1 && (clearInterval(this.scrolling), this.scrolling = -1);
}
scroll() {
this.scrollParent ? (this.scrollParent.scrollLeft += this.scrollSpeed.x, this.scrollParent.scrollTop += this.scrollSpeed.y) : this.view.win.scrollBy(this.scrollSpeed.x, this.scrollSpeed.y), this.dragging === false && this.select(this.lastEvent);
}
select(t2) {
let e2 = this.style.get(t2, this.extend, this.multiple);
(this.mustSelect || !e2.eq(this.view.state.selection) || e2.main.assoc != this.view.state.selection.main.assoc) && this.view.dispatch({
selection: e2,
userEvent: "select.pointer"
}), this.mustSelect = false;
}
update(t2) {
t2.docChanged && this.dragging && (this.dragging = this.dragging.map(t2.changes)), this.style.update(t2) && setTimeout(() => this.select(this.lastEvent), 20);
}
}
function Lf(s, t2) {
let e2 = s.state.facet(Tl);
return e2.length ? e2[0](t2) : x$1.mac ? t2.metaKey : t2.ctrlKey;
}
function Ef(s, t2) {
let e2 = s.state.facet(Pl);
return e2.length ? e2[0](t2) : x$1.mac ? !t2.altKey : !t2.ctrlKey;
}
function Nf(s, t2) {
let { main: e2 } = s.state.selection;
if (e2.empty)
return false;
let i2 = en(s.root);
if (!i2 || i2.rangeCount == 0)
return true;
let n2 = i2.getRangeAt(0).getClientRects();
for (let r2 = 0; r2 < n2.length; r2++) {
let o = n2[r2];
if (o.left <= t2.clientX && o.right >= t2.clientX && o.top <= t2.clientY && o.bottom >= t2.clientY)
return true;
}
return false;
}
function zr(s, t2) {
if (!t2.bubbles)
return true;
if (t2.defaultPrevented)
return false;
for (let e2 = t2.target, i2; e2 != s.contentDOM; e2 = e2.parentNode)
if (!e2 || e2.nodeType == 11 || (i2 = W$1.get(e2)) && i2.ignoreEvent(t2))
return false;
return true;
}
const Y$1 = /* @__PURE__ */ Object.create(null), Os = /* @__PURE__ */ Object.create(null), Gl = x$1.ie && x$1.ie_version < 15 || x$1.ios && x$1.webkit_version < 604;
function Vf(s) {
let t2 = s.dom.parentNode;
if (!t2)
return;
let e2 = t2.appendChild(document.createElement("textarea"));
e2.style.cssText = "position: fixed; left: -10000px; top: 10px", e2.focus(), setTimeout(() => {
s.focus(), e2.remove(), Ul(s, e2.value);
}, 50);
}
function Ul(s, t2) {
let { state: e2 } = s, i2, n2 = 1, r2 = e2.toText(t2), o = r2.lines == e2.selection.ranges.length;
if (Ms != null && e2.selection.ranges.every((h2) => h2.empty) && Ms == r2.toString()) {
let h2 = -1;
i2 = e2.changeByRange((a2) => {
let c2 = e2.doc.lineAt(a2.from);
if (c2.from == h2)
return { range: a2 };
h2 = c2.from;
let f2 = e2.toText((o ? r2.line(n2++).text : t2) + e2.lineBreak);
return {
changes: { from: c2.from, insert: f2 },
range: b$2.cursor(a2.from + f2.length)
};
});
} else
o ? i2 = e2.changeByRange((h2) => {
let a2 = r2.line(n2++);
return {
changes: { from: h2.from, to: h2.to, insert: a2.text },
range: b$2.cursor(h2.from + a2.length)
};
}) : i2 = e2.replaceSelection(r2);
s.dispatch(i2, {
userEvent: "input.paste",
scrollIntoView: true
});
}
Y$1.keydown = (s, t2) => {
s.inputState.setSelectionOrigin("select"), t2.keyCode == 27 ? s.inputState.lastEscPress = Date.now() : Kl.indexOf(t2.keyCode) < 0 && (s.inputState.lastEscPress = 0);
};
Y$1.touchstart = (s, t2) => {
s.inputState.lastTouchTime = Date.now(), s.inputState.setSelectionOrigin("select.pointer");
};
Y$1.touchmove = (s) => {
s.inputState.setSelectionOrigin("select.pointer");
};
Os.touchstart = Os.touchmove = { passive: true };
Y$1.mousedown = (s, t2) => {
if (s.observer.flush(), s.inputState.lastTouchTime > Date.now() - 2e3)
return;
let e2 = null;
for (let i2 of s.state.facet(Bl))
if (e2 = i2(s, t2), e2)
break;
if (!e2 && t2.button == 0 && (e2 = $f(s, t2)), e2) {
let i2 = s.root.activeElement != s.contentDOM;
i2 && s.observer.ignore(() => ml(s.contentDOM)), s.inputState.startMouseSelection(new Rf(s, t2, e2, i2));
}
};
function _r(s, t2, e2, i2) {
if (i2 == 1)
return b$2.cursor(t2, e2);
if (i2 == 2)
return vf(s.state, t2, e2);
{
let n2 = ut.find(s.docView, t2), r2 = s.state.doc.lineAt(n2 ? n2.posAtEnd : t2), o = n2 ? n2.posAtStart : r2.from, l = n2 ? n2.posAtEnd : r2.to;
return l < s.state.doc.length && l == r2.to && l++, b$2.range(o, l);
}
}
let Ql = (s, t2) => s >= t2.top && s <= t2.bottom, Wr = (s, t2, e2) => Ql(t2, e2) && s >= e2.left && s <= e2.right;
function If(s, t2, e2, i2) {
let n2 = ut.find(s.docView, t2);
if (!n2)
return 1;
let r2 = t2 - n2.posAtStart;
if (r2 == 0)
return 1;
if (r2 == n2.length)
return -1;
let o = n2.coordsAt(r2, -1);
if (o && Wr(e2, i2, o))
return -1;
let l = n2.coordsAt(r2, 1);
return l && Wr(e2, i2, l) ? 1 : o && Ql(i2, o) ? -1 : 1;
}
function jr(s, t2) {
let e2 = s.posAtCoords({ x: t2.clientX, y: t2.clientY }, false);
return { pos: e2, bias: If(s, e2, t2.clientX, t2.clientY) };
}
const Hf = x$1.ie && x$1.ie_version <= 11;
let qr = null, Kr = 0, Gr = 0;
function Jl(s) {
if (!Hf)
return s.detail;
let t2 = qr, e2 = Gr;
return qr = s, Gr = Date.now(), Kr = !t2 || e2 > Date.now() - 400 && Math.abs(t2.clientX - s.clientX) < 2 && Math.abs(t2.clientY - s.clientY) < 2 ? (Kr + 1) % 3 : 1;
}
function $f(s, t2) {
let e2 = jr(s, t2), i2 = Jl(t2), n2 = s.state.selection;
return {
update(r2) {
r2.docChanged && (e2.pos = r2.changes.mapPos(e2.pos), n2 = n2.map(r2.changes));
},
get(r2, o, l) {
let h2 = jr(s, r2), a2 = _r(s, h2.pos, h2.bias, i2);
if (e2.pos != h2.pos && !o) {
let c2 = _r(s, e2.pos, e2.bias, i2), f2 = Math.min(c2.from, a2.from), u2 = Math.max(c2.to, a2.to);
a2 = f2 < a2.from ? b$2.range(f2, u2) : b$2.range(u2, f2);
}
return o ? n2.replaceRange(n2.main.extend(a2.from, a2.to)) : l && n2.ranges.length > 1 && n2.ranges.some((c2) => c2.eq(a2)) ? Ff(n2, a2) : l ? n2.addRange(a2) : b$2.create([a2]);
}
};
}
function Ff(s, t2) {
for (let e2 = 0; ; e2++)
if (s.ranges[e2].eq(t2))
return b$2.create(s.ranges.slice(0, e2).concat(s.ranges.slice(e2 + 1)), s.mainIndex == e2 ? 0 : s.mainIndex - (s.mainIndex > e2 ? 1 : 0));
}
Y$1.dragstart = (s, t2) => {
let { selection: { main: e2 } } = s.state, { mouseSelection: i2 } = s.inputState;
i2 && (i2.dragging = e2), t2.dataTransfer && (t2.dataTransfer.setData("Text", s.state.sliceDoc(e2.from, e2.to)), t2.dataTransfer.effectAllowed = "copyMove");
};
function Ur(s, t2, e2, i2) {
if (!e2)
return;
let n2 = s.posAtCoords({ x: t2.clientX, y: t2.clientY }, false);
t2.preventDefault();
let { mouseSelection: r2 } = s.inputState, o = i2 && r2 && r2.dragging && r2.dragMove ? { from: r2.dragging.from, to: r2.dragging.to } : null, l = { from: n2, insert: e2 }, h2 = s.state.changes(o ? [o, l] : l);
s.focus(), s.dispatch({
changes: h2,
selection: { anchor: h2.mapPos(n2, -1), head: h2.mapPos(n2, 1) },
userEvent: o ? "move.drop" : "input.drop"
});
}
Y$1.drop = (s, t2) => {
if (!t2.dataTransfer)
return;
if (s.state.readOnly)
return t2.preventDefault();
let e2 = t2.dataTransfer.files;
if (e2 && e2.length) {
t2.preventDefault();
let i2 = Array(e2.length), n2 = 0, r2 = () => {
++n2 == e2.length && Ur(s, t2, i2.filter((o) => o != null).join(s.state.lineBreak), false);
};
for (let o = 0; o < e2.length; o++) {
let l = new FileReader();
l.onerror = r2, l.onload = () => {
/[\x00-\x08\x0e-\x1f]{2}/.test(l.result) || (i2[o] = l.result), r2();
}, l.readAsText(e2[o]);
}
} else
Ur(s, t2, t2.dataTransfer.getData("Text"), true);
};
Y$1.paste = (s, t2) => {
if (s.state.readOnly)
return t2.preventDefault();
s.observer.flush();
let e2 = Gl ? null : t2.clipboardData;
e2 ? (Ul(s, e2.getData("text/plain")), t2.preventDefault()) : Vf(s);
};
function zf(s, t2) {
let e2 = s.dom.parentNode;
if (!e2)
return;
let i2 = e2.appendChild(document.createElement("textarea"));
i2.style.cssText = "position: fixed; left: -10000px; top: 10px", i2.value = t2, i2.focus(), i2.selectionEnd = t2.length, i2.selectionStart = 0, setTimeout(() => {
i2.remove(), s.focus();
}, 50);
}
function _f(s) {
let t2 = [], e2 = [], i2 = false;
for (let n2 of s.selection.ranges)
n2.empty || (t2.push(s.sliceDoc(n2.from, n2.to)), e2.push(n2));
if (!t2.length) {
let n2 = -1;
for (let { from: r2 } of s.selection.ranges) {
let o = s.doc.lineAt(r2);
o.number > n2 && (t2.push(o.text), e2.push({ from: o.from, to: Math.min(s.doc.length, o.to + 1) })), n2 = o.number;
}
i2 = true;
}
return { text: t2.join(s.lineBreak), ranges: e2, linewise: i2 };
}
let Ms = null;
Y$1.copy = Y$1.cut = (s, t2) => {
let { text: e2, ranges: i2, linewise: n2 } = _f(s.state);
if (!e2 && !n2)
return;
Ms = n2 ? e2 : null;
let r2 = Gl ? null : t2.clipboardData;
r2 ? (t2.preventDefault(), r2.clearData(), r2.setData("text/plain", e2)) : zf(s, e2), t2.type == "cut" && !s.state.readOnly && s.dispatch({
changes: i2,
scrollIntoView: true,
userEvent: "delete.cut"
});
};
function Xl(s) {
setTimeout(() => {
s.hasFocus != s.inputState.notifiedFocused && s.update([]);
}, 10);
}
Y$1.focus = (s) => {
s.inputState.lastFocusTime = Date.now(), !s.scrollDOM.scrollTop && (s.inputState.lastScrollTop || s.inputState.lastScrollLeft) && (s.scrollDOM.scrollTop = s.inputState.lastScrollTop, s.scrollDOM.scrollLeft = s.inputState.lastScrollLeft), Xl(s);
};
Y$1.blur = (s) => {
s.observer.clearSelectionRange(), Xl(s);
};
Y$1.compositionstart = Y$1.compositionupdate = (s) => {
s.inputState.compositionFirstChange == null && (s.inputState.compositionFirstChange = true), s.inputState.composing < 0 && (s.inputState.composing = 0);
};
Y$1.compositionend = (s) => {
s.inputState.composing = -1, s.inputState.compositionEndedAt = Date.now(), s.inputState.compositionFirstChange = null, x$1.chrome && x$1.android && s.observer.flushSoon(), setTimeout(() => {
s.inputState.composing < 0 && s.docView.compositionDeco.size && s.update([]);
}, 50);
};
Y$1.contextmenu = (s) => {
s.inputState.lastContextMenu = Date.now();
};
Y$1.beforeinput = (s, t2) => {
var e2;
let i2;
if (x$1.chrome && x$1.android && (i2 = ql.find((n2) => n2.inputType == t2.inputType)) && (s.observer.delayAndroidKey(i2.key, i2.keyCode), i2.key == "Backspace" || i2.key == "Delete")) {
let n2 = ((e2 = window.visualViewport) === null || e2 === void 0 ? void 0 : e2.height) || 0;
setTimeout(() => {
var r2;
(((r2 = window.visualViewport) === null || r2 === void 0 ? void 0 : r2.height) || 0) > n2 + 10 && s.hasFocus && (s.contentDOM.blur(), s.focus());
}, 100);
}
};
const Qr = ["pre-wrap", "normal", "pre-line", "break-spaces"];
class Wf {
constructor(t2) {
this.lineWrapping = t2, this.doc = E$1.empty, this.heightSamples = {}, this.lineHeight = 14, this.charWidth = 7, this.lineLength = 30, this.heightChanged = false;
}
heightForGap(t2, e2) {
let i2 = this.doc.lineAt(e2).number - this.doc.lineAt(t2).number + 1;
return this.lineWrapping && (i2 += Math.ceil((e2 - t2 - i2 * this.lineLength * 0.5) / this.lineLength)), this.lineHeight * i2;
}
heightForLine(t2) {
return this.lineWrapping ? (1 + Math.max(0, Math.ceil((t2 - this.lineLength) / (this.lineLength - 5)))) * this.lineHeight : this.lineHeight;
}
setDoc(t2) {
return this.doc = t2, this;
}
mustRefreshForWrapping(t2) {
return Qr.indexOf(t2) > -1 != this.lineWrapping;
}
mustRefreshForHeights(t2) {
let e2 = false;
for (let i2 = 0; i2 < t2.length; i2++) {
let n2 = t2[i2];
n2 < 0 ? i2++ : this.heightSamples[Math.floor(n2 * 10)] || (e2 = true, this.heightSamples[Math.floor(n2 * 10)] = true);
}
return e2;
}
refresh(t2, e2, i2, n2, r2) {
let o = Qr.indexOf(t2) > -1, l = Math.round(e2) != Math.round(this.lineHeight) || this.lineWrapping != o;
if (this.lineWrapping = o, this.lineHeight = e2, this.charWidth = i2, this.lineLength = n2, l) {
this.heightSamples = {};
for (let h2 = 0; h2 < r2.length; h2++) {
let a2 = r2[h2];
a2 < 0 ? h2++ : this.heightSamples[Math.floor(a2 * 10)] = true;
}
}
return l;
}
}
class jf {
constructor(t2, e2) {
this.from = t2, this.heights = e2, this.index = 0;
}
get more() {
return this.index < this.heights.length;
}
}
class ae {
/**
@internal
*/
constructor(t2, e2, i2, n2, r2) {
this.from = t2, this.length = e2, this.top = i2, this.height = n2, this.type = r2;
}
/**
The end of the element as a document position.
*/
get to() {
return this.from + this.length;
}
/**
The bottom position of the element.
*/
get bottom() {
return this.top + this.height;
}
/**
@internal
*/
join(t2) {
let e2 = (Array.isArray(this.type) ? this.type : [this]).concat(Array.isArray(t2.type) ? t2.type : [t2]);
return new ae(this.from, this.length + t2.length, this.top, this.height + t2.height, e2);
}
}
var z$2 = /* @__PURE__ */ function(s) {
return s[s.ByPos = 0] = "ByPos", s[s.ByHeight = 1] = "ByHeight", s[s.ByPosNoHeight = 2] = "ByPosNoHeight", s;
}(z$2 || (z$2 = {}));
const qi = 1e-3;
class dt {
constructor(t2, e2, i2 = 2) {
this.length = t2, this.height = e2, this.flags = i2;
}
get outdated() {
return (this.flags & 2) > 0;
}
set outdated(t2) {
this.flags = (t2 ? 2 : 0) | this.flags & -3;
}
setHeight(t2, e2) {
this.height != e2 && (Math.abs(this.height - e2) > qi && (t2.heightChanged = true), this.height = e2);
}
// Base case is to replace a leaf node, which simply builds a tree
// from the new nodes and returns that (HeightMapBranch and
// HeightMapGap override this to actually use from/to)
replace(t2, e2, i2) {
return dt.of(i2);
}
// Again, these are base cases, and are overridden for branch and gap nodes.
decomposeLeft(t2, e2) {
e2.push(this);
}
decomposeRight(t2, e2) {
e2.push(this);
}
applyChanges(t2, e2, i2, n2) {
let r2 = this;
for (let o = n2.length - 1; o >= 0; o--) {
let { fromA: l, toA: h2, fromB: a2, toB: c2 } = n2[o], f2 = r2.lineAt(l, z$2.ByPosNoHeight, e2, 0, 0), u2 = f2.to >= h2 ? f2 : r2.lineAt(h2, z$2.ByPosNoHeight, e2, 0, 0);
for (c2 += u2.to - h2, h2 = u2.to; o > 0 && f2.from <= n2[o - 1].toA; )
l = n2[o - 1].fromA, a2 = n2[o - 1].fromB, o--, l < f2.from && (f2 = r2.lineAt(l, z$2.ByPosNoHeight, e2, 0, 0));
a2 += f2.from - l, l = f2.from;
let d2 = Xs.build(i2, t2, a2, c2);
r2 = r2.replace(l, h2, d2);
}
return r2.updateHeight(i2, 0);
}
static empty() {
return new bt(0, 0);
}
// nodes uses null values to indicate the position of line breaks.
// There are never line breaks at the start or end of the array, or
// two line breaks next to each other, and the array isn't allowed
// to be empty (same restrictions as return value from the builder).
static of(t2) {
if (t2.length == 1)
return t2[0];
let e2 = 0, i2 = t2.length, n2 = 0, r2 = 0;
for (; ; )
if (e2 == i2)
if (n2 > r2 * 2) {
let l = t2[e2 - 1];
l.break ? t2.splice(--e2, 1, l.left, null, l.right) : t2.splice(--e2, 1, l.left, l.right), i2 += 1 + l.break, n2 -= l.size;
} else if (r2 > n2 * 2) {
let l = t2[i2];
l.break ? t2.splice(i2, 1, l.left, null, l.right) : t2.splice(i2, 1, l.left, l.right), i2 += 2 + l.break, r2 -= l.size;
} else
break;
else if (n2 < r2) {
let l = t2[e2++];
l && (n2 += l.size);
} else {
let l = t2[--i2];
l && (r2 += l.size);
}
let o = 0;
return t2[e2 - 1] == null ? (o = 1, e2--) : t2[e2] == null && (o = 1, i2++), new qf(dt.of(t2.slice(0, e2)), o, dt.of(t2.slice(i2)));
}
}
dt.prototype.size = 1;
class Yl extends dt {
constructor(t2, e2, i2) {
super(t2, e2), this.type = i2;
}
blockAt(t2, e2, i2, n2) {
return new ae(n2, this.length, i2, this.height, this.type);
}
lineAt(t2, e2, i2, n2, r2) {
return this.blockAt(0, i2, n2, r2);
}
forEachLine(t2, e2, i2, n2, r2, o) {
t2 <= r2 + this.length && e2 >= r2 && o(this.blockAt(0, i2, n2, r2));
}
updateHeight(t2, e2 = 0, i2 = false, n2) {
return n2 && n2.from <= e2 && n2.more && this.setHeight(t2, n2.heights[n2.index++]), this.outdated = false, this;
}
toString() {
return `block(${this.length})`;
}
}
class bt extends Yl {
constructor(t2, e2) {
super(t2, e2, U.Text), this.collapsed = 0, this.widgetHeight = 0;
}
replace(t2, e2, i2) {
let n2 = i2[0];
return i2.length == 1 && (n2 instanceof bt || n2 instanceof it && n2.flags & 4) && Math.abs(this.length - n2.length) < 10 ? (n2 instanceof it ? n2 = new bt(n2.length, this.height) : n2.height = this.height, this.outdated || (n2.outdated = false), n2) : dt.of(i2);
}
updateHeight(t2, e2 = 0, i2 = false, n2) {
return n2 && n2.from <= e2 && n2.more ? this.setHeight(t2, n2.heights[n2.index++]) : (i2 || this.outdated) && this.setHeight(t2, Math.max(this.widgetHeight, t2.heightForLine(this.length - this.collapsed))), this.outdated = false, this;
}
toString() {
return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
}
}
class it extends dt {
constructor(t2) {
super(t2, 0);
}
lines(t2, e2) {
let i2 = t2.lineAt(e2).number, n2 = t2.lineAt(e2 + this.length).number;
return { firstLine: i2, lastLine: n2, lineHeight: this.height / (n2 - i2 + 1) };
}
blockAt(t2, e2, i2, n2) {
let { firstLine: r2, lastLine: o, lineHeight: l } = this.lines(e2, n2), h2 = Math.max(0, Math.min(o - r2, Math.floor((t2 - i2) / l))), { from: a2, length: c2 } = e2.line(r2 + h2);
return new ae(a2, c2, i2 + l * h2, l, U.Text);
}
lineAt(t2, e2, i2, n2, r2) {
if (e2 == z$2.ByHeight)
return this.blockAt(t2, i2, n2, r2);
if (e2 == z$2.ByPosNoHeight) {
let { from: f2, to: u2 } = i2.lineAt(t2);
return new ae(f2, u2 - f2, 0, 0, U.Text);
}
let { firstLine: o, lineHeight: l } = this.lines(i2, r2), { from: h2, length: a2, number: c2 } = i2.lineAt(t2);
return new ae(h2, a2, n2 + l * (c2 - o), l, U.Text);
}
forEachLine(t2, e2, i2, n2, r2, o) {
let { firstLine: l, lineHeight: h2 } = this.lines(i2, r2);
for (let a2 = Math.max(t2, r2), c2 = Math.min(r2 + this.length, e2); a2 <= c2; ) {
let f2 = i2.lineAt(a2);
a2 == t2 && (n2 += h2 * (f2.number - l)), o(new ae(f2.from, f2.length, n2, h2, U.Text)), n2 += h2, a2 = f2.to + 1;
}
}
replace(t2, e2, i2) {
let n2 = this.length - e2;
if (n2 > 0) {
let r2 = i2[i2.length - 1];
r2 instanceof it ? i2[i2.length - 1] = new it(r2.length + n2) : i2.push(null, new it(n2 - 1));
}
if (t2 > 0) {
let r2 = i2[0];
r2 instanceof it ? i2[0] = new it(t2 + r2.length) : i2.unshift(new it(t2 - 1), null);
}
return dt.of(i2);
}
decomposeLeft(t2, e2) {
e2.push(new it(t2 - 1), null);
}
decomposeRight(t2, e2) {
e2.push(null, new it(this.length - t2 - 1));
}
updateHeight(t2, e2 = 0, i2 = false, n2) {
let r2 = e2 + this.length;
if (n2 && n2.from <= e2 + this.length && n2.more) {
let o = [], l = Math.max(e2, n2.from), h2 = -1, a2 = t2.heightChanged;
for (n2.from > e2 && o.push(new it(n2.from - e2 - 1).updateHeight(t2, e2)); l <= r2 && n2.more; ) {
let f2 = t2.doc.lineAt(l).length;
o.length && o.push(null);
let u2 = n2.heights[n2.index++];
h2 == -1 ? h2 = u2 : Math.abs(u2 - h2) >= qi && (h2 = -2);
let d2 = new bt(f2, u2);
d2.outdated = false, o.push(d2), l += f2 + 1;
}
l <= r2 && o.push(null, new it(r2 - l).updateHeight(t2, l));
let c2 = dt.of(o);
return t2.heightChanged = a2 || h2 < 0 || Math.abs(c2.height - this.height) >= qi || Math.abs(h2 - this.lines(t2.doc, e2).lineHeight) >= qi, c2;
} else
(i2 || this.outdated) && (this.setHeight(t2, t2.heightForGap(e2, e2 + this.length)), this.outdated = false);
return this;
}
toString() {
return `gap(${this.length})`;
}
}
class qf extends dt {
constructor(t2, e2, i2) {
super(t2.length + e2 + i2.length, t2.height + i2.height, e2 | (t2.outdated || i2.outdated ? 2 : 0)), this.left = t2, this.right = i2, this.size = t2.size + i2.size;
}
get break() {
return this.flags & 1;
}
blockAt(t2, e2, i2, n2) {
let r2 = i2 + this.left.height;
return t2 < r2 ? this.left.blockAt(t2, e2, i2, n2) : this.right.blockAt(t2, e2, r2, n2 + this.left.length + this.break);
}
lineAt(t2, e2, i2, n2, r2) {
let o = n2 + this.left.height, l = r2 + this.left.length + this.break, h2 = e2 == z$2.ByHeight ? t2 < o : t2 < l, a2 = h2 ? this.left.lineAt(t2, e2, i2, n2, r2) : this.right.lineAt(t2, e2, i2, o, l);
if (this.break || (h2 ? a2.to < l : a2.from > l))
return a2;
let c2 = e2 == z$2.ByPosNoHeight ? z$2.ByPosNoHeight : z$2.ByPos;
return h2 ? a2.join(this.right.lineAt(l, c2, i2, o, l)) : this.left.lineAt(l, c2, i2, n2, r2).join(a2);
}
forEachLine(t2, e2, i2, n2, r2, o) {
let l = n2 + this.left.height, h2 = r2 + this.left.length + this.break;
if (this.break)
t2 < h2 && this.left.forEachLine(t2, e2, i2, n2, r2, o), e2 >= h2 && this.right.forEachLine(t2, e2, i2, l, h2, o);
else {
let a2 = this.lineAt(h2, z$2.ByPos, i2, n2, r2);
t2 < a2.from && this.left.forEachLine(t2, a2.from - 1, i2, n2, r2, o), a2.to >= t2 && a2.from <= e2 && o(a2), e2 > a2.to && this.right.forEachLine(a2.to + 1, e2, i2, l, h2, o);
}
}
replace(t2, e2, i2) {
let n2 = this.left.length + this.break;
if (e2 < n2)
return this.balanced(this.left.replace(t2, e2, i2), this.right);
if (t2 > this.left.length)
return this.balanced(this.left, this.right.replace(t2 - n2, e2 - n2, i2));
let r2 = [];
t2 > 0 && this.decomposeLeft(t2, r2);
let o = r2.length;
for (let l of i2)
r2.push(l);
if (t2 > 0 && Jr(r2, o - 1), e2 < this.length) {
let l = r2.length;
this.decomposeRight(e2, r2), Jr(r2, l);
}
return dt.of(r2);
}
decomposeLeft(t2, e2) {
let i2 = this.left.length;
if (t2 <= i2)
return this.left.decomposeLeft(t2, e2);
e2.push(this.left), this.break && (i2++, t2 >= i2 && e2.push(null)), t2 > i2 && this.right.decomposeLeft(t2 - i2, e2);
}
decomposeRight(t2, e2) {
let i2 = this.left.length, n2 = i2 + this.break;
if (t2 >= n2)
return this.right.decomposeRight(t2 - n2, e2);
t2 < i2 && this.left.decomposeRight(t2, e2), this.break && t2 < n2 && e2.push(null), e2.push(this.right);
}
balanced(t2, e2) {
return t2.size > 2 * e2.size || e2.size > 2 * t2.size ? dt.of(this.break ? [t2, null, e2] : [t2, e2]) : (this.left = t2, this.right = e2, this.height = t2.height + e2.height, this.outdated = t2.outdated || e2.outdated, this.size = t2.size + e2.size, this.length = t2.length + this.break + e2.length, this);
}
updateHeight(t2, e2 = 0, i2 = false, n2) {
let { left: r2, right: o } = this, l = e2 + r2.length + this.break, h2 = null;
return n2 && n2.from <= e2 + r2.length && n2.more ? h2 = r2 = r2.updateHeight(t2, e2, i2, n2) : r2.updateHeight(t2, e2, i2), n2 && n2.from <= l + o.length && n2.more ? h2 = o = o.updateHeight(t2, l, i2, n2) : o.updateHeight(t2, l, i2), h2 ? this.balanced(r2, o) : (this.height = this.left.height + this.right.height, this.outdated = false, this);
}
toString() {
return this.left + (this.break ? " " : "-") + this.right;
}
}
function Jr(s, t2) {
let e2, i2;
s[t2] == null && (e2 = s[t2 - 1]) instanceof it && (i2 = s[t2 + 1]) instanceof it && s.splice(t2 - 1, 3, new it(e2.length + 1 + i2.length));
}
const Kf = 5;
class Xs {
constructor(t2, e2) {
this.pos = t2, this.oracle = e2, this.nodes = [], this.lineStart = -1, this.lineEnd = -1, this.covering = null, this.writtenTo = t2;
}
get isCovered() {
return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
}
span(t2, e2) {
if (this.lineStart > -1) {
let i2 = Math.min(e2, this.lineEnd), n2 = this.nodes[this.nodes.length - 1];
n2 instanceof bt ? n2.length += i2 - this.pos : (i2 > this.pos || !this.isCovered) && this.nodes.push(new bt(i2 - this.pos, -1)), this.writtenTo = i2, e2 > i2 && (this.nodes.push(null), this.writtenTo++, this.lineStart = -1);
}
this.pos = e2;
}
point(t2, e2, i2) {
if (t2 < e2 || i2.heightRelevant) {
let n2 = i2.widget ? i2.widget.estimatedHeight : 0;
n2 < 0 && (n2 = this.oracle.lineHeight);
let r2 = e2 - t2;
i2.block ? this.addBlock(new Yl(r2, n2, i2.type)) : (r2 || n2 >= Kf) && this.addLineDeco(n2, r2);
} else
e2 > t2 && this.span(t2, e2);
this.lineEnd > -1 && this.lineEnd < this.pos && (this.lineEnd = this.oracle.doc.lineAt(this.pos).to);
}
enterLine() {
if (this.lineStart > -1)
return;
let { from: t2, to: e2 } = this.oracle.doc.lineAt(this.pos);
this.lineStart = t2, this.lineEnd = e2, this.writtenTo < t2 && ((this.writtenTo < t2 - 1 || this.nodes[this.nodes.length - 1] == null) && this.nodes.push(this.blankContent(this.writtenTo, t2 - 1)), this.nodes.push(null)), this.pos > t2 && this.nodes.push(new bt(this.pos - t2, -1)), this.writtenTo = this.pos;
}
blankContent(t2, e2) {
let i2 = new it(e2 - t2);
return this.oracle.doc.lineAt(t2).to == e2 && (i2.flags |= 4), i2;
}
ensureLine() {
this.enterLine();
let t2 = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
if (t2 instanceof bt)
return t2;
let e2 = new bt(0, -1);
return this.nodes.push(e2), e2;
}
addBlock(t2) {
this.enterLine(), t2.type == U.WidgetAfter && !this.isCovered && this.ensureLine(), this.nodes.push(t2), this.writtenTo = this.pos = this.pos + t2.length, t2.type != U.WidgetBefore && (this.covering = t2);
}
addLineDeco(t2, e2) {
let i2 = this.ensureLine();
i2.length += e2, i2.collapsed += e2, i2.widgetHeight = Math.max(i2.widgetHeight, t2), this.writtenTo = this.pos = this.pos + e2;
}
finish(t2) {
let e2 = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
this.lineStart > -1 && !(e2 instanceof bt) && !this.isCovered ? this.nodes.push(new bt(0, -1)) : (this.writtenTo < this.pos || e2 == null) && this.nodes.push(this.blankContent(this.writtenTo, this.pos));
let i2 = t2;
for (let n2 of this.nodes)
n2 instanceof bt && n2.updateHeight(this.oracle, i2), i2 += n2 ? n2.length : 1;
return this.nodes;
}
// Always called with a region that on both sides either stretches
// to a line break or the end of the document.
// The returned array uses null to indicate line breaks, but never
// starts or ends in a line break, or has multiple line breaks next
// to each other.
static build(t2, e2, i2, n2) {
let r2 = new Xs(i2, t2);
return $.spans(e2, i2, n2, r2, 0), r2.finish(i2);
}
}
function Gf(s, t2, e2) {
let i2 = new Uf();
return $.compare(s, t2, e2, i2, 0), i2.changes;
}
class Uf {
constructor() {
this.changes = [];
}
compareRange() {
}
comparePoint(t2, e2, i2, n2) {
(t2 < e2 || i2 && i2.heightRelevant || n2 && n2.heightRelevant) && xs(t2, e2, this.changes, 5);
}
}
function Qf(s, t2) {
let e2 = s.getBoundingClientRect(), i2 = s.ownerDocument, n2 = i2.defaultView || window, r2 = Math.max(0, e2.left), o = Math.min(n2.innerWidth, e2.right), l = Math.max(0, e2.top), h2 = Math.min(n2.innerHeight, e2.bottom);
for (let a2 = s.parentNode; a2 && a2 != i2.body; )
if (a2.nodeType == 1) {
let c2 = a2, f2 = window.getComputedStyle(c2);
if ((c2.scrollHeight > c2.clientHeight || c2.scrollWidth > c2.clientWidth) && f2.overflow != "visible") {
let u2 = c2.getBoundingClientRect();
r2 = Math.max(r2, u2.left), o = Math.min(o, u2.right), l = Math.max(l, u2.top), h2 = a2 == s.parentNode ? u2.bottom : Math.min(h2, u2.bottom);
}
a2 = f2.position == "absolute" || f2.position == "fixed" ? c2.offsetParent : c2.parentNode;
} else if (a2.nodeType == 11)
a2 = a2.host;
else
break;
return {
left: r2 - e2.left,
right: Math.max(r2, o) - e2.left,
top: l - (e2.top + t2),
bottom: Math.max(l, h2) - (e2.top + t2)
};
}
function Jf(s, t2) {
let e2 = s.getBoundingClientRect();
return {
left: 0,
right: e2.right - e2.left,
top: t2,
bottom: e2.bottom - (e2.top + t2)
};
}
class zn {
constructor(t2, e2, i2) {
this.from = t2, this.to = e2, this.size = i2;
}
static same(t2, e2) {
if (t2.length != e2.length)
return false;
for (let i2 = 0; i2 < t2.length; i2++) {
let n2 = t2[i2], r2 = e2[i2];
if (n2.from != r2.from || n2.to != r2.to || n2.size != r2.size)
return false;
}
return true;
}
draw(t2) {
return T.replace({ widget: new Xf(this.size, t2) }).range(this.from, this.to);
}
}
class Xf extends ye {
constructor(t2, e2) {
super(), this.size = t2, this.vertical = e2;
}
eq(t2) {
return t2.size == this.size && t2.vertical == this.vertical;
}
toDOM() {
let t2 = document.createElement("div");
return this.vertical ? t2.style.height = this.size + "px" : (t2.style.width = this.size + "px", t2.style.height = "2px", t2.style.display = "inline-block"), t2;
}
get estimatedHeight() {
return this.vertical ? this.size : -1;
}
}
class Xr {
constructor(t2) {
this.state = t2, this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 }, this.inView = true, this.paddingTop = 0, this.paddingBottom = 0, this.contentDOMWidth = 0, this.contentDOMHeight = 0, this.editorHeight = 0, this.editorWidth = 0, this.scaler = Yr, this.scrollTarget = null, this.printing = false, this.mustMeasureContent = true, this.defaultTextDirection = X.LTR, this.visibleRanges = [], this.mustEnforceCursorAssoc = false;
let e2 = t2.facet(Js).some((i2) => typeof i2 != "function" && i2.class == "cm-lineWrapping");
this.heightOracle = new Wf(e2), this.stateDeco = t2.facet(gi).filter((i2) => typeof i2 != "function"), this.heightMap = dt.empty().applyChanges(this.stateDeco, E$1.empty, this.heightOracle.setDoc(t2.doc), [new _t(0, 0, 0, t2.doc.length)]), this.viewport = this.getViewport(0, null), this.updateViewportLines(), this.updateForViewport(), this.lineGaps = this.ensureLineGaps([]), this.lineGapDeco = T.set(this.lineGaps.map((i2) => i2.draw(false))), this.computeVisibleRanges();
}
updateForViewport() {
let t2 = [this.viewport], { main: e2 } = this.state.selection;
for (let i2 = 0; i2 <= 1; i2++) {
let n2 = i2 ? e2.head : e2.anchor;
if (!t2.some(({ from: r2, to: o }) => n2 >= r2 && n2 <= o)) {
let { from: r2, to: o } = this.lineBlockAt(n2);
t2.push(new Ti(r2, o));
}
}
this.viewports = t2.sort((i2, n2) => i2.from - n2.from), this.scaler = this.heightMap.height <= 7e6 ? Yr : new tu(this.heightOracle.doc, this.heightMap, this.viewports);
}
updateViewportLines() {
this.viewportLines = [], this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.state.doc, 0, 0, (t2) => {
this.viewportLines.push(this.scaler.scale == 1 ? t2 : oi(t2, this.scaler));
});
}
update(t2, e2 = null) {
this.state = t2.state;
let i2 = this.stateDeco;
this.stateDeco = this.state.facet(gi).filter((a2) => typeof a2 != "function");
let n2 = t2.changedRanges, r2 = _t.extendWithRanges(n2, Gf(i2, this.stateDeco, t2 ? t2.changes : Z.empty(this.state.doc.length))), o = this.heightMap.height;
this.heightMap = this.heightMap.applyChanges(this.stateDeco, t2.startState.doc, this.heightOracle.setDoc(this.state.doc), r2), this.heightMap.height != o && (t2.flags |= 2);
let l = r2.length ? this.mapViewport(this.viewport, t2.changes) : this.viewport;
(e2 && (e2.range.head < l.from || e2.range.head > l.to) || !this.viewportIsAppropriate(l)) && (l = this.getViewport(0, e2));
let h2 = !t2.changes.empty || t2.flags & 2 || l.from != this.viewport.from || l.to != this.viewport.to;
this.viewport = l, this.updateForViewport(), h2 && this.updateViewportLines(), (this.lineGaps.length || this.viewport.to - this.viewport.from > 2e3 << 1) && this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, t2.changes))), t2.flags |= this.computeVisibleRanges(), e2 && (this.scrollTarget = e2), !this.mustEnforceCursorAssoc && t2.selectionSet && t2.view.lineWrapping && t2.state.selection.main.empty && t2.state.selection.main.assoc && !t2.state.facet(of) && (this.mustEnforceCursorAssoc = true);
}
measure(t2) {
let e2 = t2.contentDOM, i2 = window.getComputedStyle(e2), n2 = this.heightOracle, r2 = i2.whiteSpace;
this.defaultTextDirection = i2.direction == "rtl" ? X.RTL : X.LTR;
let o = this.heightOracle.mustRefreshForWrapping(r2), l = o || this.mustMeasureContent || this.contentDOMHeight != e2.clientHeight;
this.contentDOMHeight = e2.clientHeight, this.mustMeasureContent = false;
let h2 = 0, a2 = 0, c2 = parseInt(i2.paddingTop) || 0, f2 = parseInt(i2.paddingBottom) || 0;
(this.paddingTop != c2 || this.paddingBottom != f2) && (this.paddingTop = c2, this.paddingBottom = f2, h2 |= 10), this.editorWidth != t2.scrollDOM.clientWidth && (n2.lineWrapping && (l = true), this.editorWidth = t2.scrollDOM.clientWidth, h2 |= 8);
let u2 = (this.printing ? Jf : Qf)(e2, this.paddingTop), d2 = u2.top - this.pixelViewport.top, p2 = u2.bottom - this.pixelViewport.bottom;
this.pixelViewport = u2;
let w2 = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
if (w2 != this.inView && (this.inView = w2, w2 && (l = true)), !this.inView && !this.scrollTarget)
return 0;
let g = e2.clientWidth;
if ((this.contentDOMWidth != g || this.editorHeight != t2.scrollDOM.clientHeight) && (this.contentDOMWidth = g, this.editorHeight = t2.scrollDOM.clientHeight, h2 |= 8), l) {
let O2 = t2.docView.measureVisibleLineHeights(this.viewport);
if (n2.mustRefreshForHeights(O2) && (o = true), o || n2.lineWrapping && Math.abs(g - this.contentDOMWidth) > n2.charWidth) {
let { lineHeight: S2, charWidth: D2 } = t2.docView.measureTextSize();
o = S2 > 0 && n2.refresh(r2, S2, D2, g / D2, O2), o && (t2.docView.minWidth = 0, h2 |= 8);
}
d2 > 0 && p2 > 0 ? a2 = Math.max(d2, p2) : d2 < 0 && p2 < 0 && (a2 = Math.min(d2, p2)), n2.heightChanged = false;
for (let S2 of this.viewports) {
let D2 = S2.from == this.viewport.from ? O2 : t2.docView.measureVisibleLineHeights(S2);
this.heightMap = (o ? dt.empty().applyChanges(this.stateDeco, E$1.empty, this.heightOracle, [new _t(0, 0, 0, t2.state.doc.length)]) : this.heightMap).updateHeight(n2, 0, o, new jf(S2.from, D2));
}
n2.heightChanged && (h2 |= 2);
}
let y2 = !this.viewportIsAppropriate(this.viewport, a2) || this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
return y2 && (this.viewport = this.getViewport(a2, this.scrollTarget)), this.updateForViewport(), (h2 & 2 || y2) && this.updateViewportLines(), (this.lineGaps.length || this.viewport.to - this.viewport.from > 2e3 << 1) && this.updateLineGaps(this.ensureLineGaps(o ? [] : this.lineGaps, t2)), h2 |= this.computeVisibleRanges(), this.mustEnforceCursorAssoc && (this.mustEnforceCursorAssoc = false, t2.docView.enforceCursorAssoc()), h2;
}
get visibleTop() {
return this.scaler.fromDOM(this.pixelViewport.top);
}
get visibleBottom() {
return this.scaler.fromDOM(this.pixelViewport.bottom);
}
getViewport(t2, e2) {
let i2 = 0.5 - Math.max(-0.5, Math.min(0.5, t2 / 1e3 / 2)), n2 = this.heightMap, r2 = this.state.doc, { visibleTop: o, visibleBottom: l } = this, h2 = new Ti(n2.lineAt(o - i2 * 1e3, z$2.ByHeight, r2, 0, 0).from, n2.lineAt(l + (1 - i2) * 1e3, z$2.ByHeight, r2, 0, 0).to);
if (e2) {
let { head: a2 } = e2.range;
if (a2 < h2.from || a2 > h2.to) {
let c2 = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top), f2 = n2.lineAt(a2, z$2.ByPos, r2, 0, 0), u2;
e2.y == "center" ? u2 = (f2.top + f2.bottom) / 2 - c2 / 2 : e2.y == "start" || e2.y == "nearest" && a2 < h2.from ? u2 = f2.top : u2 = f2.bottom - c2, h2 = new Ti(n2.lineAt(u2 - 1e3 / 2, z$2.ByHeight, r2, 0, 0).from, n2.lineAt(u2 + c2 + 1e3 / 2, z$2.ByHeight, r2, 0, 0).to);
}
}
return h2;
}
mapViewport(t2, e2) {
let i2 = e2.mapPos(t2.from, -1), n2 = e2.mapPos(t2.to, 1);
return new Ti(this.heightMap.lineAt(i2, z$2.ByPos, this.state.doc, 0, 0).from, this.heightMap.lineAt(n2, z$2.ByPos, this.state.doc, 0, 0).to);
}
// Checks if a given viewport covers the visible part of the
// document and not too much beyond that.
viewportIsAppropriate({ from: t2, to: e2 }, i2 = 0) {
if (!this.inView)
return true;
let { top: n2 } = this.heightMap.lineAt(t2, z$2.ByPos, this.state.doc, 0, 0), { bottom: r2 } = this.heightMap.lineAt(e2, z$2.ByPos, this.state.doc, 0, 0), { visibleTop: o, visibleBottom: l } = this;
return (t2 == 0 || n2 <= o - Math.max(10, Math.min(
-i2,
250
/* VP.MaxCoverMargin */
))) && (e2 == this.state.doc.length || r2 >= l + Math.max(10, Math.min(
i2,
250
/* VP.MaxCoverMargin */
))) && n2 > o - 2 * 1e3 && r2 < l + 2 * 1e3;
}
mapLineGaps(t2, e2) {
if (!t2.length || e2.empty)
return t2;
let i2 = [];
for (let n2 of t2)
e2.touchesRange(n2.from, n2.to) || i2.push(new zn(e2.mapPos(n2.from), e2.mapPos(n2.to), n2.size));
return i2;
}
// Computes positions in the viewport where the start or end of a
// line should be hidden, trying to reuse existing line gaps when
// appropriate to avoid unneccesary redraws.
// Uses crude character-counting for the positioning and sizing,
// since actual DOM coordinates aren't always available and
// predictable. Relies on generous margins (see LG.Margin) to hide
// the artifacts this might produce from the user.
ensureLineGaps(t2, e2) {
let i2 = this.heightOracle.lineWrapping, n2 = i2 ? 1e4 : 2e3, r2 = n2 >> 1, o = n2 << 1;
if (this.defaultTextDirection != X.LTR && !i2)
return [];
let l = [], h2 = (a2, c2, f2, u2) => {
if (c2 - a2 < r2)
return;
let d2 = this.state.selection.main, p2 = [d2.from];
d2.empty || p2.push(d2.to);
for (let g of p2)
if (g > a2 && g < c2) {
h2(a2, g - 10, f2, u2), h2(g + 10, c2, f2, u2);
return;
}
let w2 = Zf(t2, (g) => g.from >= f2.from && g.to <= f2.to && Math.abs(g.from - a2) < r2 && Math.abs(g.to - c2) < r2 && !p2.some((y2) => g.from < y2 && g.to > y2));
if (!w2) {
if (c2 < f2.to && e2 && i2 && e2.visibleRanges.some((g) => g.from <= c2 && g.to >= c2)) {
let g = e2.moveToLineBoundary(b$2.cursor(c2), false, true).head;
g > a2 && (c2 = g);
}
w2 = new zn(a2, c2, this.gapSize(f2, a2, c2, u2));
}
l.push(w2);
};
for (let a2 of this.viewportLines) {
if (a2.length < o)
continue;
let c2 = Yf(a2.from, a2.to, this.stateDeco);
if (c2.total < o)
continue;
let f2 = this.scrollTarget ? this.scrollTarget.range.head : null, u2, d2;
if (i2) {
let p2 = n2 / this.heightOracle.lineLength * this.heightOracle.lineHeight, w2, g;
if (f2 != null) {
let y2 = Bi(c2, f2), O2 = ((this.visibleBottom - this.visibleTop) / 2 + p2) / a2.height;
w2 = y2 - O2, g = y2 + O2;
} else
w2 = (this.visibleTop - a2.top - p2) / a2.height, g = (this.visibleBottom - a2.top + p2) / a2.height;
u2 = Pi(c2, w2), d2 = Pi(c2, g);
} else {
let p2 = c2.total * this.heightOracle.charWidth, w2 = n2 * this.heightOracle.charWidth, g, y2;
if (f2 != null) {
let O2 = Bi(c2, f2), S2 = ((this.pixelViewport.right - this.pixelViewport.left) / 2 + w2) / p2;
g = O2 - S2, y2 = O2 + S2;
} else
g = (this.pixelViewport.left - w2) / p2, y2 = (this.pixelViewport.right + w2) / p2;
u2 = Pi(c2, g), d2 = Pi(c2, y2);
}
u2 > a2.from && h2(a2.from, u2, a2, c2), d2 < a2.to && h2(d2, a2.to, a2, c2);
}
return l;
}
gapSize(t2, e2, i2, n2) {
let r2 = Bi(n2, i2) - Bi(n2, e2);
return this.heightOracle.lineWrapping ? t2.height * r2 : n2.total * this.heightOracle.charWidth * r2;
}
updateLineGaps(t2) {
zn.same(t2, this.lineGaps) || (this.lineGaps = t2, this.lineGapDeco = T.set(t2.map((e2) => e2.draw(this.heightOracle.lineWrapping))));
}
computeVisibleRanges() {
let t2 = this.stateDeco;
this.lineGaps.length && (t2 = t2.concat(this.lineGapDeco));
let e2 = [];
$.spans(t2, this.viewport.from, this.viewport.to, {
span(n2, r2) {
e2.push({ from: n2, to: r2 });
},
point() {
}
}, 20);
let i2 = e2.length != this.visibleRanges.length || this.visibleRanges.some((n2, r2) => n2.from != e2[r2].from || n2.to != e2[r2].to);
return this.visibleRanges = e2, i2 ? 4 : 0;
}
lineBlockAt(t2) {
return t2 >= this.viewport.from && t2 <= this.viewport.to && this.viewportLines.find((e2) => e2.from <= t2 && e2.to >= t2) || oi(this.heightMap.lineAt(t2, z$2.ByPos, this.state.doc, 0, 0), this.scaler);
}
lineBlockAtHeight(t2) {
return oi(this.heightMap.lineAt(this.scaler.fromDOM(t2), z$2.ByHeight, this.state.doc, 0, 0), this.scaler);
}
elementAtHeight(t2) {
return oi(this.heightMap.blockAt(this.scaler.fromDOM(t2), this.state.doc, 0, 0), this.scaler);
}
get docHeight() {
return this.scaler.toDOM(this.heightMap.height);
}
get contentHeight() {
return this.docHeight + this.paddingTop + this.paddingBottom;
}
}
class Ti {
constructor(t2, e2) {
this.from = t2, this.to = e2;
}
}
function Yf(s, t2, e2) {
let i2 = [], n2 = s, r2 = 0;
return $.spans(e2, s, t2, {
span() {
},
point(o, l) {
o > n2 && (i2.push({ from: n2, to: o }), r2 += o - n2), n2 = l;
}
}, 20), n2 < t2 && (i2.push({ from: n2, to: t2 }), r2 += t2 - n2), { total: r2, ranges: i2 };
}
function Pi({ total: s, ranges: t2 }, e2) {
if (e2 <= 0)
return t2[0].from;
if (e2 >= 1)
return t2[t2.length - 1].to;
let i2 = Math.floor(s * e2);
for (let n2 = 0; ; n2++) {
let { from: r2, to: o } = t2[n2], l = o - r2;
if (i2 <= l)
return r2 + i2;
i2 -= l;
}
}
function Bi(s, t2) {
let e2 = 0;
for (let { from: i2, to: n2 } of s.ranges) {
if (t2 <= n2) {
e2 += t2 - i2;
break;
}
e2 += n2 - i2;
}
return e2 / s.total;
}
function Zf(s, t2) {
for (let e2 of s)
if (t2(e2))
return e2;
}
const Yr = {
toDOM(s) {
return s;
},
fromDOM(s) {
return s;
},
scale: 1
};
class tu {
constructor(t2, e2, i2) {
let n2 = 0, r2 = 0, o = 0;
this.viewports = i2.map(({ from: l, to: h2 }) => {
let a2 = e2.lineAt(l, z$2.ByPos, t2, 0, 0).top, c2 = e2.lineAt(h2, z$2.ByPos, t2, 0, 0).bottom;
return n2 += c2 - a2, { from: l, to: h2, top: a2, bottom: c2, domTop: 0, domBottom: 0 };
}), this.scale = (7e6 - n2) / (e2.height - n2);
for (let l of this.viewports)
l.domTop = o + (l.top - r2) * this.scale, o = l.domBottom = l.domTop + (l.bottom - l.top), r2 = l.bottom;
}
toDOM(t2) {
for (let e2 = 0, i2 = 0, n2 = 0; ; e2++) {
let r2 = e2 < this.viewports.length ? this.viewports[e2] : null;
if (!r2 || t2 < r2.top)
return n2 + (t2 - i2) * this.scale;
if (t2 <= r2.bottom)
return r2.domTop + (t2 - r2.top);
i2 = r2.bottom, n2 = r2.domBottom;
}
}
fromDOM(t2) {
for (let e2 = 0, i2 = 0, n2 = 0; ; e2++) {
let r2 = e2 < this.viewports.length ? this.viewports[e2] : null;
if (!r2 || t2 < r2.domTop)
return i2 + (t2 - n2) / this.scale;
if (t2 <= r2.domBottom)
return r2.top + (t2 - r2.domTop);
i2 = r2.bottom, n2 = r2.domBottom;
}
}
}
function oi(s, t2) {
if (t2.scale == 1)
return s;
let e2 = t2.toDOM(s.top), i2 = t2.toDOM(s.bottom);
return new ae(s.from, s.length, e2, i2 - e2, Array.isArray(s.type) ? s.type.map((n2) => oi(n2, t2)) : s.type);
}
const Ri = /* @__PURE__ */ v.define({ combine: (s) => s.join(" ") }), Ds = /* @__PURE__ */ v.define({ combine: (s) => s.indexOf(true) > -1 }), Ts = /* @__PURE__ */ de.newName(), Zl = /* @__PURE__ */ de.newName(), th = /* @__PURE__ */ de.newName(), eh = { "&light": "." + Zl, "&dark": "." + th };
function Ps(s, t2, e2) {
return new de(t2, {
finish(i2) {
return /&/.test(i2) ? i2.replace(/&\w*/, (n2) => {
if (n2 == "&")
return s;
if (!e2 || !e2[n2])
throw new RangeError(`Unsupported selector: ${n2}`);
return e2[n2];
}) : s + " " + i2;
}
});
}
const eu = /* @__PURE__ */ Ps("." + Ts, {
"&": {
position: "relative !important",
boxSizing: "border-box",
"&.cm-focused": {
// Provide a simple default outline to make sure a focused
// editor is visually distinct. Can't leave the default behavior
// because that will apply to the content element, which is
// inside the scrollable container and doesn't include the
// gutters. We also can't use an 'auto' outline, since those
// are, for some reason, drawn behind the element content, which
// will cause things like the active line background to cover
// the outline (#297).
outline: "1px dotted #212121"
},
display: "flex !important",
flexDirection: "column"
},
".cm-scroller": {
display: "flex !important",
alignItems: "flex-start !important",
fontFamily: "monospace",
lineHeight: 1.4,
height: "100%",
overflowX: "auto",
position: "relative",
zIndex: 0
},
".cm-content": {
margin: 0,
flexGrow: 2,
flexShrink: 0,
display: "block",
whiteSpace: "pre",
wordWrap: "normal",
boxSizing: "border-box",
padding: "4px 0",
outline: "none",
"&[contenteditable=true]": {
WebkitUserModify: "read-write-plaintext-only"
}
},
".cm-lineWrapping": {
whiteSpace_fallback: "pre-wrap",
whiteSpace: "break-spaces",
wordBreak: "break-word",
overflowWrap: "anywhere",
flexShrink: 1
},
"&light .cm-content": { caretColor: "black" },
"&dark .cm-content": { caretColor: "white" },
".cm-line": {
display: "block",
padding: "0 2px 0 6px"
},
".cm-layer": {
contain: "size style",
"& > *": {
position: "absolute"
}
},
"&light .cm-selectionBackground": {
background: "#d9d9d9"
},
"&dark .cm-selectionBackground": {
background: "#222"
},
"&light.cm-focused .cm-selectionBackground": {
background: "#d7d4f0"
},
"&dark.cm-focused .cm-selectionBackground": {
background: "#233"
},
".cm-cursorLayer": {
pointerEvents: "none"
},
"&.cm-focused .cm-cursorLayer": {
animation: "steps(1) cm-blink 1.2s infinite"
},
// Two animations defined so that we can switch between them to
// restart the animation without forcing another style
// recomputation.
"@keyframes cm-blink": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
"@keyframes cm-blink2": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
".cm-cursor, .cm-dropCursor": {
borderLeft: "1.2px solid black",
marginLeft: "-0.6px",
pointerEvents: "none"
},
".cm-cursor": {
display: "none"
},
"&dark .cm-cursor": {
borderLeftColor: "#444"
},
"&.cm-focused .cm-cursor": {
display: "block"
},
"&light .cm-activeLine": { backgroundColor: "#cceeff44" },
"&dark .cm-activeLine": { backgroundColor: "#99eeff33" },
"&light .cm-specialChar": { color: "red" },
"&dark .cm-specialChar": { color: "#f78" },
".cm-gutters": {
flexShrink: 0,
display: "flex",
height: "100%",
boxSizing: "border-box",
left: 0,
zIndex: 200
},
"&light .cm-gutters": {
backgroundColor: "#f5f5f5",
color: "#6c6c6c",
borderRight: "1px solid #ddd"
},
"&dark .cm-gutters": {
backgroundColor: "#333338",
color: "#ccc"
},
".cm-gutter": {
display: "flex !important",
flexDirection: "column",
flexShrink: 0,
boxSizing: "border-box",
minHeight: "100%",
overflow: "hidden"
},
".cm-gutterElement": {
boxSizing: "border-box"
},
".cm-lineNumbers .cm-gutterElement": {
padding: "0 3px 0 5px",
minWidth: "20px",
textAlign: "right",
whiteSpace: "nowrap"
},
"&light .cm-activeLineGutter": {
backgroundColor: "#e2f2ff"
},
"&dark .cm-activeLineGutter": {
backgroundColor: "#222227"
},
".cm-panels": {
boxSizing: "border-box",
position: "sticky",
left: 0,
right: 0
},
"&light .cm-panels": {
backgroundColor: "#f5f5f5",
color: "black"
},
"&light .cm-panels-top": {
borderBottom: "1px solid #ddd"
},
"&light .cm-panels-bottom": {
borderTop: "1px solid #ddd"
},
"&dark .cm-panels": {
backgroundColor: "#333338",
color: "white"
},
".cm-tab": {
display: "inline-block",
overflow: "hidden",
verticalAlign: "bottom"
},
".cm-widgetBuffer": {
verticalAlign: "text-top",
height: "1em",
width: 0,
display: "inline"
},
".cm-placeholder": {
color: "#888",
display: "inline-block",
verticalAlign: "top"
},
".cm-highlightSpace:before": {
content: "attr(data-display)",
position: "absolute",
pointerEvents: "none",
color: "#888"
},
".cm-highlightTab": {
backgroundImage: `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,
backgroundSize: "auto 100%",
backgroundPosition: "right 90%",
backgroundRepeat: "no-repeat"
},
".cm-trailingSpace": {
backgroundColor: "#ff332255"
},
".cm-button": {
verticalAlign: "middle",
color: "inherit",
fontSize: "70%",
padding: ".2em 1em",
borderRadius: "1px"
},
"&light .cm-button": {
backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
border: "1px solid #888",
"&:active": {
backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
}
},
"&dark .cm-button": {
backgroundImage: "linear-gradient(#393939, #111)",
border: "1px solid #888",
"&:active": {
backgroundImage: "linear-gradient(#111, #333)"
}
},
".cm-textfield": {
verticalAlign: "middle",
color: "inherit",
fontSize: "70%",
border: "1px solid silver",
padding: ".2em .5em"
},
"&light .cm-textfield": {
backgroundColor: "white"
},
"&dark .cm-textfield": {
border: "1px solid #555",
backgroundColor: "inherit"
}
}, eh);
class iu {
constructor(t2, e2, i2, n2) {
this.typeOver = n2, this.bounds = null, this.text = "";
let { impreciseHead: r2, impreciseAnchor: o } = t2.docView;
if (t2.state.readOnly && e2 > -1)
this.newSel = null;
else if (e2 > -1 && (this.bounds = t2.docView.domBoundsAround(e2, i2, 0))) {
let l = r2 || o ? [] : su(t2), h2 = new zl(l, t2.state);
h2.readRange(this.bounds.startDOM, this.bounds.endDOM), this.text = h2.text, this.newSel = ru(l, this.bounds.from);
} else {
let l = t2.observer.selectionRange, h2 = r2 && r2.node == l.focusNode && r2.offset == l.focusOffset || !qe(t2.contentDOM, l.focusNode) ? t2.state.selection.main.head : t2.docView.posFromDOM(l.focusNode, l.focusOffset), a2 = o && o.node == l.anchorNode && o.offset == l.anchorOffset || !qe(t2.contentDOM, l.anchorNode) ? t2.state.selection.main.anchor : t2.docView.posFromDOM(l.anchorNode, l.anchorOffset);
this.newSel = b$2.single(a2, h2);
}
}
}
function ih(s, t2) {
let e2, { newSel: i2 } = t2, n2 = s.state.selection.main;
if (t2.bounds) {
let { from: r2, to: o } = t2.bounds, l = n2.from, h2 = null;
(s.inputState.lastKeyCode === 8 && s.inputState.lastKeyTime > Date.now() - 100 || x$1.android && t2.text.length < o - r2) && (l = n2.to, h2 = "end");
let a2 = nu(s.state.doc.sliceString(r2, o, he), t2.text, l - r2, h2);
a2 && (x$1.chrome && s.inputState.lastKeyCode == 13 && a2.toB == a2.from + 2 && t2.text.slice(a2.from, a2.toB) == he + he && a2.toB--, e2 = {
from: r2 + a2.from,
to: r2 + a2.toA,
insert: E$1.of(t2.text.slice(a2.from, a2.toB).split(he))
});
} else
i2 && (!s.hasFocus && s.state.facet(Mn) || i2.main.eq(n2)) && (i2 = null);
if (!e2 && !i2)
return false;
if (!e2 && t2.typeOver && !n2.empty && i2 && i2.main.empty ? e2 = { from: n2.from, to: n2.to, insert: s.state.doc.slice(n2.from, n2.to) } : e2 && e2.from >= n2.from && e2.to <= n2.to && (e2.from != n2.from || e2.to != n2.to) && n2.to - n2.from - (e2.to - e2.from) <= 4 ? e2 = {
from: n2.from,
to: n2.to,
insert: s.state.doc.slice(n2.from, e2.from).append(e2.insert).append(s.state.doc.slice(e2.to, n2.to))
} : (x$1.mac || x$1.android) && e2 && e2.from == e2.to && e2.from == n2.head - 1 && /^\. ?$/.test(e2.insert.toString()) ? (i2 && e2.insert.length == 2 && (i2 = b$2.single(i2.main.anchor - 1, i2.main.head - 1)), e2 = { from: n2.from, to: n2.to, insert: E$1.of([" "]) }) : x$1.chrome && e2 && e2.from == e2.to && e2.from == n2.head && e2.insert.toString() == `
` && s.lineWrapping && (i2 && (i2 = b$2.single(i2.main.anchor - 1, i2.main.head - 1)), e2 = { from: n2.from, to: n2.to, insert: E$1.of([" "]) }), e2) {
let r2 = s.state;
if (x$1.ios && s.inputState.flushIOSKey(s) || x$1.android && (e2.from == n2.from && e2.to == n2.to && e2.insert.length == 1 && e2.insert.lines == 2 && $e(s.contentDOM, "Enter", 13) || e2.from == n2.from - 1 && e2.to == n2.to && e2.insert.length == 0 && $e(s.contentDOM, "Backspace", 8) || e2.from == n2.from && e2.to == n2.to + 1 && e2.insert.length == 0 && $e(s.contentDOM, "Delete", 46)))
return true;
let o = e2.insert.toString();
if (s.state.facet(Ll).some((a2) => a2(s, e2.from, e2.to, o)))
return true;
s.inputState.composing >= 0 && s.inputState.composing++;
let l;
if (e2.from >= n2.from && e2.to <= n2.to && e2.to - e2.from >= (n2.to - n2.from) / 3 && (!i2 || i2.main.empty && i2.main.from == e2.from + e2.insert.length) && s.inputState.composing < 0) {
let a2 = n2.from < e2.from ? r2.sliceDoc(n2.from, e2.from) : "", c2 = n2.to > e2.to ? r2.sliceDoc(e2.to, n2.to) : "";
l = r2.replaceSelection(s.state.toText(a2 + e2.insert.sliceString(0, void 0, s.state.lineBreak) + c2));
} else {
let a2 = r2.changes(e2), c2 = i2 && !r2.selection.main.eq(i2.main) && i2.main.to <= a2.newLength ? i2.main : void 0;
if (r2.selection.ranges.length > 1 && s.inputState.composing >= 0 && e2.to <= n2.to && e2.to >= n2.to - 10) {
let f2 = s.state.sliceDoc(e2.from, e2.to), u2 = _l(s) || s.state.doc.lineAt(n2.head), d2 = n2.to - e2.to, p2 = n2.to - n2.from;
l = r2.changeByRange((w2) => {
if (w2.from == n2.from && w2.to == n2.to)
return { changes: a2, range: c2 || w2.map(a2) };
let g = w2.to - d2, y2 = g - f2.length;
if (w2.to - w2.from != p2 || s.state.sliceDoc(y2, g) != f2 || // Unfortunately, there's no way to make multiple
// changes in the same node work without aborting
// composition, so cursors in the composition range are
// ignored.
u2 && w2.to >= u2.from && w2.from <= u2.to)
return { range: w2 };
let O2 = r2.changes({ from: y2, to: g, insert: e2.insert }), S2 = w2.to - n2.to;
return {
changes: O2,
range: c2 ? b$2.range(Math.max(0, c2.anchor + S2), Math.max(0, c2.head + S2)) : w2.map(O2)
};
});
} else
l = {
changes: a2,
selection: c2 && r2.selection.replaceRange(c2)
};
}
let h2 = "input.type";
return s.composing && (h2 += ".compose", s.inputState.compositionFirstChange && (h2 += ".start", s.inputState.compositionFirstChange = false)), s.dispatch(l, { scrollIntoView: true, userEvent: h2 }), true;
} else if (i2 && !i2.main.eq(n2)) {
let r2 = false, o = "select";
return s.inputState.lastSelectionTime > Date.now() - 50 && (s.inputState.lastSelectionOrigin == "select" && (r2 = true), o = s.inputState.lastSelectionOrigin), s.dispatch({ selection: i2, scrollIntoView: r2, userEvent: o }), true;
} else
return false;
}
function nu(s, t2, e2, i2) {
let n2 = Math.min(s.length, t2.length), r2 = 0;
for (; r2 < n2 && s.charCodeAt(r2) == t2.charCodeAt(r2); )
r2++;
if (r2 == n2 && s.length == t2.length)
return null;
let o = s.length, l = t2.length;
for (; o > 0 && l > 0 && s.charCodeAt(o - 1) == t2.charCodeAt(l - 1); )
o--, l--;
if (i2 == "end") {
let h2 = Math.max(0, r2 - Math.min(o, l));
e2 -= o + h2 - r2;
}
if (o < r2 && s.length < t2.length) {
let h2 = e2 <= r2 && e2 >= o ? r2 - e2 : 0;
r2 -= h2, l = r2 + (l - o), o = r2;
} else if (l < r2) {
let h2 = e2 <= r2 && e2 >= l ? r2 - e2 : 0;
r2 -= h2, o = r2 + (o - l), l = r2;
}
return { from: r2, toA: o, toB: l };
}
function su(s) {
let t2 = [];
if (s.root.activeElement != s.contentDOM)
return t2;
let { anchorNode: e2, anchorOffset: i2, focusNode: n2, focusOffset: r2 } = s.observer.selectionRange;
return e2 && (t2.push(new Lr(e2, i2)), (n2 != e2 || r2 != i2) && t2.push(new Lr(n2, r2))), t2;
}
function ru(s, t2) {
if (s.length == 0)
return null;
let e2 = s[0].pos, i2 = s.length == 2 ? s[1].pos : e2;
return e2 > -1 && i2 > -1 ? b$2.single(e2 + t2, i2 + t2) : null;
}
const ou = {
childList: true,
characterData: true,
subtree: true,
attributes: true,
characterDataOldValue: true
}, _n = x$1.ie && x$1.ie_version <= 11;
class lu {
constructor(t2) {
this.view = t2, this.active = false, this.selectionRange = new Yc(), this.selectionChanged = false, this.delayedFlush = -1, this.resizeTimeout = -1, this.queue = [], this.delayedAndroidKey = null, this.flushingAndroidKey = -1, this.lastChange = 0, this.scrollTargets = [], this.intersection = null, this.resizeScroll = null, this.resizeContent = null, this.intersecting = false, this.gapIntersection = null, this.gaps = [], this.parentCheck = -1, this.dom = t2.contentDOM, this.observer = new MutationObserver((e2) => {
for (let i2 of e2)
this.queue.push(i2);
(x$1.ie && x$1.ie_version <= 11 || x$1.ios && t2.composing) && e2.some((i2) => i2.type == "childList" && i2.removedNodes.length || i2.type == "characterData" && i2.oldValue.length > i2.target.nodeValue.length) ? this.flushSoon() : this.flush();
}), _n && (this.onCharData = (e2) => {
this.queue.push({
target: e2.target,
type: "characterData",
oldValue: e2.prevValue
}), this.flushSoon();
}), this.onSelectionChange = this.onSelectionChange.bind(this), this.onResize = this.onResize.bind(this), this.onPrint = this.onPrint.bind(this), this.onScroll = this.onScroll.bind(this), typeof ResizeObserver == "function" && (this.resizeScroll = new ResizeObserver(() => {
var e2;
((e2 = this.view.docView) === null || e2 === void 0 ? void 0 : e2.lastUpdate) < Date.now() - 75 && this.onResize();
}), this.resizeScroll.observe(t2.scrollDOM), this.resizeContent = new ResizeObserver(() => this.view.requestMeasure()), this.resizeContent.observe(t2.contentDOM)), this.addWindowListeners(this.win = t2.win), this.start(), typeof IntersectionObserver == "function" && (this.intersection = new IntersectionObserver((e2) => {
this.parentCheck < 0 && (this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1e3)), e2.length > 0 && e2[e2.length - 1].intersectionRatio > 0 != this.intersecting && (this.intersecting = !this.intersecting, this.intersecting != this.view.inView && this.onScrollChanged(document.createEvent("Event")));
}, {}), this.intersection.observe(this.dom), this.gapIntersection = new IntersectionObserver((e2) => {
e2.length > 0 && e2[e2.length - 1].intersectionRatio > 0 && this.onScrollChanged(document.createEvent("Event"));
}, {})), this.listenForScroll(), this.readSelectionRange();
}
onScrollChanged(t2) {
this.view.inputState.runScrollHandlers(this.view, t2), this.intersecting && this.view.measure();
}
onScroll(t2) {
this.intersecting && this.flush(false), this.onScrollChanged(t2);
}
onResize() {
this.resizeTimeout < 0 && (this.resizeTimeout = setTimeout(() => {
this.resizeTimeout = -1, this.view.requestMeasure();
}, 50));
}
onPrint() {
this.view.viewState.printing = true, this.view.measure(), setTimeout(() => {
this.view.viewState.printing = false, this.view.requestMeasure();
}, 500);
}
updateGaps(t2) {
if (this.gapIntersection && (t2.length != this.gaps.length || this.gaps.some((e2, i2) => e2 != t2[i2]))) {
this.gapIntersection.disconnect();
for (let e2 of t2)
this.gapIntersection.observe(e2);
this.gaps = t2;
}
}
onSelectionChange(t2) {
let e2 = this.selectionChanged;
if (!this.readSelectionRange() || this.delayedAndroidKey)
return;
let { view: i2 } = this, n2 = this.selectionRange;
if (i2.state.facet(Mn) ? i2.root.activeElement != this.dom : !ji(i2.dom, n2))
return;
let r2 = n2.anchorNode && i2.docView.nearest(n2.anchorNode);
if (r2 && r2.ignoreEvent(t2)) {
e2 || (this.selectionChanged = false);
return;
}
(x$1.ie && x$1.ie_version <= 11 || x$1.android && x$1.chrome) && !i2.state.selection.main.empty && // (Selection.isCollapsed isn't reliable on IE)
n2.focusNode && nn(n2.focusNode, n2.focusOffset, n2.anchorNode, n2.anchorOffset) ? this.flushSoon() : this.flush(false);
}
readSelectionRange() {
let { view: t2 } = this, e2 = x$1.safari && t2.root.nodeType == 11 && Uc(this.dom.ownerDocument) == this.dom && hu(this.view) || en(t2.root);
if (!e2 || this.selectionRange.eq(e2))
return false;
let i2 = ji(this.dom, e2);
return i2 && !this.selectionChanged && t2.inputState.lastFocusTime > Date.now() - 200 && t2.inputState.lastTouchTime < Date.now() - 300 && tf(this.dom, e2) ? (this.view.inputState.lastFocusTime = 0, t2.docView.updateSelection(), false) : (this.selectionRange.setRange(e2), i2 && (this.selectionChanged = true), true);
}
setSelectionRange(t2, e2) {
this.selectionRange.set(t2.node, t2.offset, e2.node, e2.offset), this.selectionChanged = false;
}
clearSelectionRange() {
this.selectionRange.set(null, 0, null, 0);
}
listenForScroll() {
this.parentCheck = -1;
let t2 = 0, e2 = null;
for (let i2 = this.dom; i2; )
if (i2.nodeType == 1)
!e2 && t2 < this.scrollTargets.length && this.scrollTargets[t2] == i2 ? t2++ : e2 || (e2 = this.scrollTargets.slice(0, t2)), e2 && e2.push(i2), i2 = i2.assignedSlot || i2.parentNode;
else if (i2.nodeType == 11)
i2 = i2.host;
else
break;
if (t2 < this.scrollTargets.length && !e2 && (e2 = this.scrollTargets.slice(0, t2)), e2) {
for (let i2 of this.scrollTargets)
i2.removeEventListener("scroll", this.onScroll);
for (let i2 of this.scrollTargets = e2)
i2.addEventListener("scroll", this.onScroll);
}
}
ignore(t2) {
if (!this.active)
return t2();
try {
return this.stop(), t2();
} finally {
this.start(), this.clear();
}
}
start() {
this.active || (this.observer.observe(this.dom, ou), _n && this.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.active = true);
}
stop() {
this.active && (this.active = false, this.observer.disconnect(), _n && this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData));
}
// Throw away any pending changes
clear() {
this.processRecords(), this.queue.length = 0, this.selectionChanged = false;
}
// Chrome Android, especially in combination with GBoard, not only
// doesn't reliably fire regular key events, but also often
// surrounds the effect of enter or backspace with a bunch of
// composition events that, when interrupted, cause text duplication
// or other kinds of corruption. This hack makes the editor back off
// from handling DOM changes for a moment when such a key is
// detected (via beforeinput or keydown), and then tries to flush
// them or, if that has no effect, dispatches the given key.
delayAndroidKey(t2, e2) {
var i2;
if (!this.delayedAndroidKey) {
let n2 = () => {
let r2 = this.delayedAndroidKey;
r2 && (this.clearDelayedAndroidKey(), !this.flush() && r2.force && $e(this.dom, r2.key, r2.keyCode));
};
this.flushingAndroidKey = this.view.win.requestAnimationFrame(n2);
}
(!this.delayedAndroidKey || t2 == "Enter") && (this.delayedAndroidKey = {
key: t2,
keyCode: e2,
// Only run the key handler when no changes are detected if
// this isn't coming right after another change, in which case
// it is probably part of a weird chain of updates, and should
// be ignored if it returns the DOM to its previous state.
force: this.lastChange < Date.now() - 50 || !!(!((i2 = this.delayedAndroidKey) === null || i2 === void 0) && i2.force)
});
}
clearDelayedAndroidKey() {
this.win.cancelAnimationFrame(this.flushingAndroidKey), this.delayedAndroidKey = null, this.flushingAndroidKey = -1;
}
flushSoon() {
this.delayedFlush < 0 && (this.delayedFlush = this.view.win.requestAnimationFrame(() => {
this.delayedFlush = -1, this.flush();
}));
}
forceFlush() {
this.delayedFlush >= 0 && (this.view.win.cancelAnimationFrame(this.delayedFlush), this.delayedFlush = -1), this.flush();
}
processRecords() {
let t2 = this.queue;
for (let r2 of this.observer.takeRecords())
t2.push(r2);
t2.length && (this.queue = []);
let e2 = -1, i2 = -1, n2 = false;
for (let r2 of t2) {
let o = this.readMutation(r2);
o && (o.typeOver && (n2 = true), e2 == -1 ? { from: e2, to: i2 } = o : (e2 = Math.min(o.from, e2), i2 = Math.max(o.to, i2)));
}
return { from: e2, to: i2, typeOver: n2 };
}
readChange() {
let { from: t2, to: e2, typeOver: i2 } = this.processRecords(), n2 = this.selectionChanged && ji(this.dom, this.selectionRange);
return t2 < 0 && !n2 ? null : (t2 > -1 && (this.lastChange = Date.now()), this.view.inputState.lastFocusTime = 0, this.selectionChanged = false, new iu(this.view, t2, e2, i2));
}
// Apply pending changes, if any
flush(t2 = true) {
if (this.delayedFlush >= 0 || this.delayedAndroidKey)
return false;
t2 && this.readSelectionRange();
let e2 = this.readChange();
if (!e2)
return false;
let i2 = this.view.state, n2 = ih(this.view, e2);
return this.view.state == i2 && this.view.update([]), n2;
}
readMutation(t2) {
let e2 = this.view.docView.nearest(t2.target);
if (!e2 || e2.ignoreMutation(t2))
return null;
if (e2.markDirty(t2.type == "attributes"), t2.type == "attributes" && (e2.dirty |= 4), t2.type == "childList") {
let i2 = Zr(e2, t2.previousSibling || t2.target.previousSibling, -1), n2 = Zr(e2, t2.nextSibling || t2.target.nextSibling, 1);
return {
from: i2 ? e2.posAfter(i2) : e2.posAtStart,
to: n2 ? e2.posBefore(n2) : e2.posAtEnd,
typeOver: false
};
} else
return t2.type == "characterData" ? { from: e2.posAtStart, to: e2.posAtEnd, typeOver: t2.target.nodeValue == t2.oldValue } : null;
}
setWindow(t2) {
t2 != this.win && (this.removeWindowListeners(this.win), this.win = t2, this.addWindowListeners(this.win));
}
addWindowListeners(t2) {
t2.addEventListener("resize", this.onResize), t2.addEventListener("beforeprint", this.onPrint), t2.addEventListener("scroll", this.onScroll), t2.document.addEventListener("selectionchange", this.onSelectionChange);
}
removeWindowListeners(t2) {
t2.removeEventListener("scroll", this.onScroll), t2.removeEventListener("resize", this.onResize), t2.removeEventListener("beforeprint", this.onPrint), t2.document.removeEventListener("selectionchange", this.onSelectionChange);
}
destroy() {
var t2, e2, i2, n2;
this.stop(), (t2 = this.intersection) === null || t2 === void 0 || t2.disconnect(), (e2 = this.gapIntersection) === null || e2 === void 0 || e2.disconnect(), (i2 = this.resizeScroll) === null || i2 === void 0 || i2.disconnect(), (n2 = this.resizeContent) === null || n2 === void 0 || n2.disconnect();
for (let r2 of this.scrollTargets)
r2.removeEventListener("scroll", this.onScroll);
this.removeWindowListeners(this.win), clearTimeout(this.parentCheck), clearTimeout(this.resizeTimeout), this.win.cancelAnimationFrame(this.delayedFlush), this.win.cancelAnimationFrame(this.flushingAndroidKey);
}
}
function Zr(s, t2, e2) {
for (; t2; ) {
let i2 = W$1.get(t2);
if (i2 && i2.parent == s)
return i2;
let n2 = t2.parentNode;
t2 = n2 != s.dom ? n2 : e2 > 0 ? t2.nextSibling : t2.previousSibling;
}
return null;
}
function hu(s) {
let t2 = null;
function e2(h2) {
h2.preventDefault(), h2.stopImmediatePropagation(), t2 = h2.getTargetRanges()[0];
}
if (s.contentDOM.addEventListener("beforeinput", e2, true), s.dom.ownerDocument.execCommand("indent"), s.contentDOM.removeEventListener("beforeinput", e2, true), !t2)
return null;
let i2 = t2.startContainer, n2 = t2.startOffset, r2 = t2.endContainer, o = t2.endOffset, l = s.docView.domAtPos(s.state.selection.main.anchor);
return nn(l.node, l.offset, r2, o) && ([i2, n2, r2, o] = [r2, o, i2, n2]), { anchorNode: i2, anchorOffset: n2, focusNode: r2, focusOffset: o };
}
let A$2 = class A2 {
/**
Construct a new view. You'll want to either provide a `parent`
option, or put `view.dom` into your document after creating a
view, so that the user can see the editor.
*/
constructor(t2 = {}) {
this.plugins = [], this.pluginMap = /* @__PURE__ */ new Map(), this.editorAttrs = {}, this.contentAttrs = {}, this.bidiCache = [], this.destroyed = false, this.updateState = 2, this.measureScheduled = -1, this.measureRequests = [], this.contentDOM = document.createElement("div"), this.scrollDOM = document.createElement("div"), this.scrollDOM.tabIndex = -1, this.scrollDOM.className = "cm-scroller", this.scrollDOM.appendChild(this.contentDOM), this.announceDOM = document.createElement("div"), this.announceDOM.style.cssText = "position: fixed; top: -10000px", this.announceDOM.setAttribute("aria-live", "polite"), this.dom = document.createElement("div"), this.dom.appendChild(this.announceDOM), this.dom.appendChild(this.scrollDOM), this._dispatch = t2.dispatch || ((e2) => this.update([e2])), this.dispatch = this.dispatch.bind(this), this._root = t2.root || Zc(t2.parent) || document, this.viewState = new Xr(t2.state || N$2.create(t2)), this.plugins = this.state.facet(si).map((e2) => new Hn(e2));
for (let e2 of this.plugins)
e2.update(this);
this.observer = new lu(this), this.inputState = new Pf(this), this.inputState.ensureHandlers(this, this.plugins), this.docView = new Er(this), this.mountStyles(), this.updateAttrs(), this.updateState = 0, this.requestMeasure(), t2.parent && t2.parent.appendChild(this.dom);
}
/**
The current editor state.
*/
get state() {
return this.viewState.state;
}
/**
To be able to display large documents without consuming too much
memory or overloading the browser, CodeMirror only draws the
code that is visible (plus a margin around it) to the DOM. This
property tells you the extent of the current drawn viewport, in
document positions.
*/
get viewport() {
return this.viewState.viewport;
}
/**
When there are, for example, large collapsed ranges in the
viewport, its size can be a lot bigger than the actual visible
content. Thus, if you are doing something like styling the
content in the viewport, it is preferable to only do so for
these ranges, which are the subset of the viewport that is
actually drawn.
*/
get visibleRanges() {
return this.viewState.visibleRanges;
}
/**
Returns false when the editor is entirely scrolled out of view
or otherwise hidden.
*/
get inView() {
return this.viewState.inView;
}
/**
Indicates whether the user is currently composing text via
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
one change has been made in the current composition.
*/
get composing() {
return this.inputState.composing > 0;
}
/**
Indicates whether the user is currently in composing state. Note
that on some platforms, like Android, this will be the case a
lot, since just putting the cursor on a word starts a
composition there.
*/
get compositionStarted() {
return this.inputState.composing >= 0;
}
/**
The document or shadow root that the view lives in.
*/
get root() {
return this._root;
}
/**
@internal
*/
get win() {
return this.dom.ownerDocument.defaultView || window;
}
dispatch(...t2) {
this._dispatch(t2.length == 1 && t2[0] instanceof lt ? t2[0] : this.state.update(...t2));
}
/**
Update the view for the given array of transactions. This will
update the visible document and selection to match the state
produced by the transactions, and notify view plugins of the
change. You should usually call
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
as a primitive.
*/
update(t2) {
if (this.updateState != 0)
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
let e2 = false, i2 = false, n2, r2 = this.state;
for (let a2 of t2) {
if (a2.startState != r2)
throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
r2 = a2.state;
}
if (this.destroyed) {
this.viewState.state = r2;
return;
}
let o = this.observer.delayedAndroidKey, l = null;
if (o ? (this.observer.clearDelayedAndroidKey(), l = this.observer.readChange(), (l && !this.state.doc.eq(r2.doc) || !this.state.selection.eq(r2.selection)) && (l = null)) : this.observer.clear(), r2.facet(N$2.phrases) != this.state.facet(N$2.phrases))
return this.setState(r2);
n2 = on.create(this, r2, t2);
let h2 = this.viewState.scrollTarget;
try {
this.updateState = 2;
for (let a2 of t2) {
if (h2 && (h2 = h2.map(a2.changes)), a2.scrollIntoView) {
let { main: c2 } = a2.state.selection;
h2 = new rn(c2.empty ? c2 : b$2.cursor(c2.head, c2.head > c2.anchor ? -1 : 1));
}
for (let c2 of a2.effects)
c2.is(Br) && (h2 = c2.value);
}
this.viewState.update(n2, h2), this.bidiCache = ln.update(this.bidiCache, n2.changes), n2.empty || (this.updatePlugins(n2), this.inputState.update(n2)), e2 = this.docView.update(n2), this.state.facet(ri) != this.styleModules && this.mountStyles(), i2 = this.updateAttrs(), this.showAnnouncements(t2), this.docView.updateSelection(e2, t2.some((a2) => a2.isUserEvent("select.pointer")));
} finally {
this.updateState = 0;
}
if (n2.startState.facet(Ri) != n2.state.facet(Ri) && (this.viewState.mustMeasureContent = true), (e2 || i2 || h2 || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent) && this.requestMeasure(), !n2.empty)
for (let a2 of this.state.facet(vs))
a2(n2);
l && !ih(this, l) && o.force && $e(this.contentDOM, o.key, o.keyCode);
}
/**
Reset the view to the given state. (This will cause the entire
document to be redrawn and all view plugins to be reinitialized,
so you should probably only use it when the new state isn't
derived from the old state. Otherwise, use
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
*/
setState(t2) {
if (this.updateState != 0)
throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
if (this.destroyed) {
this.viewState.state = t2;
return;
}
this.updateState = 2;
let e2 = this.hasFocus;
try {
for (let i2 of this.plugins)
i2.destroy(this);
this.viewState = new Xr(t2), this.plugins = t2.facet(si).map((i2) => new Hn(i2)), this.pluginMap.clear();
for (let i2 of this.plugins)
i2.update(this);
this.docView = new Er(this), this.inputState.ensureHandlers(this, this.plugins), this.mountStyles(), this.updateAttrs(), this.bidiCache = [];
} finally {
this.updateState = 0;
}
e2 && this.focus(), this.requestMeasure();
}
updatePlugins(t2) {
let e2 = t2.startState.facet(si), i2 = t2.state.facet(si);
if (e2 != i2) {
let n2 = [];
for (let r2 of i2) {
let o = e2.indexOf(r2);
if (o < 0)
n2.push(new Hn(r2));
else {
let l = this.plugins[o];
l.mustUpdate = t2, n2.push(l);
}
}
for (let r2 of this.plugins)
r2.mustUpdate != t2 && r2.destroy(this);
this.plugins = n2, this.pluginMap.clear(), this.inputState.ensureHandlers(this, this.plugins);
} else
for (let n2 of this.plugins)
n2.mustUpdate = t2;
for (let n2 = 0; n2 < this.plugins.length; n2++)
this.plugins[n2].update(this);
}
/**
@internal
*/
measure(t2 = true) {
if (this.destroyed)
return;
this.measureScheduled > -1 && cancelAnimationFrame(this.measureScheduled), this.measureScheduled = 0, t2 && this.observer.forceFlush();
let e2 = null, { scrollHeight: i2, scrollTop: n2, clientHeight: r2 } = this.scrollDOM, o = n2 > i2 - r2 - 4 ? i2 : n2;
try {
for (let l = 0; ; l++) {
this.updateState = 1;
let h2 = this.viewport, a2 = this.viewState.lineBlockAtHeight(o), c2 = this.viewState.measure(this);
if (!c2 && !this.measureRequests.length && this.viewState.scrollTarget == null)
break;
if (l > 5) {
console.warn(this.measureRequests.length ? "Measure loop restarted more than 5 times" : "Viewport failed to stabilize");
break;
}
let f2 = [];
c2 & 4 || ([this.measureRequests, f2] = [f2, this.measureRequests]);
let u2 = f2.map((g) => {
try {
return g.read(this);
} catch (y2) {
return zt(this.state, y2), to;
}
}), d2 = on.create(this, this.state, []), p2 = false, w2 = false;
d2.flags |= c2, e2 ? e2.flags |= c2 : e2 = d2, this.updateState = 2, d2.empty || (this.updatePlugins(d2), this.inputState.update(d2), this.updateAttrs(), p2 = this.docView.update(d2));
for (let g = 0; g < f2.length; g++)
if (u2[g] != to)
try {
let y2 = f2[g];
y2.write && y2.write(u2[g], this);
} catch (y2) {
zt(this.state, y2);
}
if (this.viewState.editorHeight)
if (this.viewState.scrollTarget)
this.docView.scrollIntoView(this.viewState.scrollTarget), this.viewState.scrollTarget = null, w2 = true;
else {
let g = this.viewState.lineBlockAt(a2.from).top - a2.top;
(g > 1 || g < -1) && (this.scrollDOM.scrollTop += g, w2 = true);
}
if (p2 && this.docView.updateSelection(true), this.viewport.from == h2.from && this.viewport.to == h2.to && !w2 && this.measureRequests.length == 0)
break;
}
} finally {
this.updateState = 0, this.measureScheduled = -1;
}
if (e2 && !e2.empty)
for (let l of this.state.facet(vs))
l(e2);
}
/**
Get the CSS classes for the currently active editor themes.
*/
get themeClasses() {
return Ts + " " + (this.state.facet(Ds) ? th : Zl) + " " + this.state.facet(Ri);
}
updateAttrs() {
let t2 = eo(this, Nl, {
class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
}), e2 = {
spellcheck: "false",
autocorrect: "off",
autocapitalize: "off",
translate: "no",
contenteditable: this.state.facet(Mn) ? "true" : "false",
class: "cm-content",
style: `${x$1.tabSize}: ${this.state.tabSize}`,
role: "textbox",
"aria-multiline": "true"
};
this.state.readOnly && (e2["aria-readonly"] = "true"), eo(this, Js, e2);
let i2 = this.observer.ignore(() => {
let n2 = ks(this.contentDOM, this.contentAttrs, e2), r2 = ks(this.dom, this.editorAttrs, t2);
return n2 || r2;
});
return this.editorAttrs = t2, this.contentAttrs = e2, i2;
}
showAnnouncements(t2) {
let e2 = true;
for (let i2 of t2)
for (let n2 of i2.effects)
if (n2.is(A2.announce)) {
e2 && (this.announceDOM.textContent = ""), e2 = false;
let r2 = this.announceDOM.appendChild(document.createElement("div"));
r2.textContent = n2.value;
}
}
mountStyles() {
this.styleModules = this.state.facet(ri), de.mount(this.root, this.styleModules.concat(eu).reverse());
}
readMeasured() {
if (this.updateState == 2)
throw new Error("Reading the editor layout isn't allowed during an update");
this.updateState == 0 && this.measureScheduled > -1 && this.measure(false);
}
/**
Schedule a layout measurement, optionally providing callbacks to
do custom DOM measuring followed by a DOM write phase. Using
this is preferable reading DOM layout directly from, for
example, an event handler, because it'll make sure measuring and
drawing done by other components is synchronized, avoiding
unnecessary DOM layout computations.
*/
requestMeasure(t2) {
if (this.measureScheduled < 0 && (this.measureScheduled = this.win.requestAnimationFrame(() => this.measure())), t2) {
if (this.measureRequests.indexOf(t2) > -1)
return;
if (t2.key != null) {
for (let e2 = 0; e2 < this.measureRequests.length; e2++)
if (this.measureRequests[e2].key === t2.key) {
this.measureRequests[e2] = t2;
return;
}
}
this.measureRequests.push(t2);
}
}
/**
Get the value of a specific plugin, if present. Note that
plugins that crash can be dropped from a view, so even when you
know you registered a given plugin, it is recommended to check
the return value of this method.
*/
plugin(t2) {
let e2 = this.pluginMap.get(t2);
return (e2 === void 0 || e2 && e2.spec != t2) && this.pluginMap.set(t2, e2 = this.plugins.find((i2) => i2.spec == t2) || null), e2 && e2.update(this).value;
}
/**
The top position of the document, in screen coordinates. This
may be negative when the editor is scrolled down. Points
directly to the top of the first line, not above the padding.
*/
get documentTop() {
return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
}
/**
Reports the padding above and below the document.
*/
get documentPadding() {
return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
}
/**
Find the text line or block widget at the given vertical
position (which is interpreted as relative to the [top of the
document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)).
*/
elementAtHeight(t2) {
return this.readMeasured(), this.viewState.elementAtHeight(t2);
}
/**
Find the line block (see
[`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
height, again interpreted relative to the [top of the
document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
*/
lineBlockAtHeight(t2) {
return this.readMeasured(), this.viewState.lineBlockAtHeight(t2);
}
/**
Get the extent and vertical position of all [line
blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
are relative to the [top of the
document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
*/
get viewportLineBlocks() {
return this.viewState.viewportLines;
}
/**
Find the line block around the given document position. A line
block is a range delimited on both sides by either a
non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the
start/end of the document. It will usually just hold a line of
text, but may be broken into multiple textblocks by block
widgets.
*/
lineBlockAt(t2) {
return this.viewState.lineBlockAt(t2);
}
/**
The editor's total content height.
*/
get contentHeight() {
return this.viewState.contentHeight;
}
/**
Move a cursor position by [grapheme
cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
the motion is away from the line start, or towards it. In
bidirectional text, the line is traversed in visual order, using
the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
When the start position was the last one on the line, the
returned position will be across the line break. If there is no
further line, the original position is returned.
By default, this method moves over a single cluster. The
optional `by` argument can be used to move across more. It will
be called with the first cluster as argument, and should return
a predicate that determines, for each subsequent cluster,
whether it should also be moved over.
*/
moveByChar(t2, e2, i2) {
return Fn(this, t2, Fr(this, t2, e2, i2));
}
/**
Move a cursor position across the next group of either
[letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
non-whitespace characters.
*/
moveByGroup(t2, e2) {
return Fn(this, t2, Fr(this, t2, e2, (i2) => Df(this, t2.head, i2)));
}
/**
Move to the next line boundary in the given direction. If
`includeWrap` is true, line wrapping is on, and there is a
further wrap point on the current line, the wrap point will be
returned. Otherwise this function will return the start or end
of the line.
*/
moveToLineBoundary(t2, e2, i2 = true) {
return Mf(this, t2, e2, i2);
}
/**
Move a cursor position vertically. When `distance` isn't given,
it defaults to moving to the next line (including wrapped
lines). Otherwise, `distance` should provide a positive distance
in pixels.
When `start` has a
[`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
motion will use that as a target horizontal position. Otherwise,
the cursor's own horizontal position is used. The returned
cursor will have its goal column set to whichever column was
used.
*/
moveVertically(t2, e2, i2) {
return Fn(this, t2, Tf(this, t2, e2, i2));
}
/**
Find the DOM parent node and offset (child offset if `node` is
an element, character offset when it is a text node) at the
given document position.
Note that for positions that aren't currently in
`visibleRanges`, the resulting DOM position isn't necessarily
meaningful (it may just point before or after a placeholder
element).
*/
domAtPos(t2) {
return this.docView.domAtPos(t2);
}
/**
Find the document position at the given DOM node. Can be useful
for associating positions with DOM events. Will raise an error
when `node` isn't part of the editor content.
*/
posAtDOM(t2, e2 = 0) {
return this.docView.posFromDOM(t2, e2);
}
posAtCoords(t2, e2 = true) {
return this.readMeasured(), jl(this, t2, e2);
}
/**
Get the screen coordinates at the given document position.
`side` determines whether the coordinates are based on the
element before (-1) or after (1) the position (if no element is
available on the given side, the method will transparently use
another strategy to get reasonable coordinates).
*/
coordsAtPos(t2, e2 = 1) {
this.readMeasured();
let i2 = this.docView.coordsAt(t2, e2);
if (!i2 || i2.left == i2.right)
return i2;
let n2 = this.state.doc.lineAt(t2), r2 = this.bidiSpans(n2), o = r2[Fe.find(r2, t2 - n2.from, -1, e2)];
return Ks(i2, o.dir == X.LTR == e2 > 0);
}
/**
The default width of a character in the editor. May not
accurately reflect the width of all characters (given variable
width fonts or styling of invididual ranges).
*/
get defaultCharacterWidth() {
return this.viewState.heightOracle.charWidth;
}
/**
The default height of a line in the editor. May not be accurate
for all lines.
*/
get defaultLineHeight() {
return this.viewState.heightOracle.lineHeight;
}
/**
The text direction
([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
CSS property) of the editor's content element.
*/
get textDirection() {
return this.viewState.defaultTextDirection;
}
/**
Find the text direction of the block at the given position, as
assigned by CSS. If
[`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
isn't enabled, or the given position is outside of the viewport,
this will always return the same as
[`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
this may trigger a DOM layout.
*/
textDirectionAt(t2) {
return !this.state.facet(El) || t2 < this.viewport.from || t2 > this.viewport.to ? this.textDirection : (this.readMeasured(), this.docView.textDirectionAt(t2));
}
/**
Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
(as determined by the
[`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
CSS property of its content element).
*/
get lineWrapping() {
return this.viewState.heightOracle.lineWrapping;
}
/**
Returns the bidirectional text structure of the given line
(which should be in the current document) as an array of span
objects. The order of these spans matches the [text
direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
left-to-right, the leftmost spans come first, otherwise the
rightmost spans come first.
*/
bidiSpans(t2) {
if (t2.length > au)
return $l(t2.length);
let e2 = this.textDirectionAt(t2.from);
for (let n2 of this.bidiCache)
if (n2.from == t2.from && n2.dir == e2)
return n2.order;
let i2 = df(t2.text, e2);
return this.bidiCache.push(new ln(t2.from, t2.to, e2, i2)), i2;
}
/**
Check whether the editor has focus.
*/
get hasFocus() {
var t2;
return (this.dom.ownerDocument.hasFocus() || x$1.safari && ((t2 = this.inputState) === null || t2 === void 0 ? void 0 : t2.lastContextMenu) > Date.now() - 3e4) && this.root.activeElement == this.contentDOM;
}
/**
Put focus on the editor.
*/
focus() {
this.observer.ignore(() => {
ml(this.contentDOM), this.docView.updateSelection();
});
}
/**
Update the [root](https://codemirror.net/6/docs/ref/##view.EditorViewConfig.root) in which the editor lives. This is only
necessary when moving the editor's existing DOM to a new window or shadow root.
*/
setRoot(t2) {
this._root != t2 && (this._root = t2, this.observer.setWindow((t2.nodeType == 9 ? t2 : t2.ownerDocument).defaultView || window), this.mountStyles());
}
/**
Clean up this editor view, removing its element from the
document, unregistering event handlers, and notifying
plugins. The view instance can no longer be used after
calling this.
*/
destroy() {
for (let t2 of this.plugins)
t2.destroy(this);
this.plugins = [], this.inputState.destroy(), this.dom.remove(), this.observer.destroy(), this.measureScheduled > -1 && cancelAnimationFrame(this.measureScheduled), this.destroyed = true;
}
/**
Returns an effect that can be
[added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
cause it to scroll the given position or range into view.
*/
static scrollIntoView(t2, e2 = {}) {
return Br.of(new rn(typeof t2 == "number" ? b$2.cursor(t2) : t2, e2.y, e2.x, e2.yMargin, e2.xMargin));
}
/**
Returns an extension that can be used to add DOM event handlers.
The value should be an object mapping event names to handler
functions. For any given event, such functions are ordered by
extension precedence, and the first handler to return true will
be assumed to have handled that event, and no other handlers or
built-in behavior will be activated for it. These are registered
on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
for `scroll` handlers, which will be called any time the
editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
its parent nodes is scrolled.
*/
static domEventHandlers(t2) {
return wt.define(() => ({}), { eventHandlers: t2 });
}
/**
Create a theme extension. The first argument can be a
[`style-mod`](https://github.com/marijnh/style-mod#documentation)
style spec providing the styles for the theme. These will be
prefixed with a generated class for the style.
Because the selectors will be prefixed with a scope class, rule
that directly match the editor's [wrapper
element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
added—need to be explicitly differentiated by adding an `&` to
the selector for that element—for example
`&.cm-focused`.
When `dark` is set to true, the theme will be marked as dark,
which will cause the `&dark` rules from [base
themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
`&light` when a light theme is active).
*/
static theme(t2, e2) {
let i2 = de.newName(), n2 = [Ri.of(i2), ri.of(Ps(`.${i2}`, t2))];
return e2 && e2.dark && n2.push(Ds.of(true)), n2;
}
/**
Create an extension that adds styles to the base theme. Like
with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
place of the editor wrapper element when directly targeting
that. You can also use `&dark` or `&light` instead to only
target editors with a dark or light theme.
*/
static baseTheme(t2) {
return js.lowest(ri.of(Ps("." + Ts, t2, eh)));
}
/**
Retrieve an editor view instance from the view's DOM
representation.
*/
static findFromDOM(t2) {
var e2;
let i2 = t2.querySelector(".cm-content"), n2 = i2 && W$1.get(i2) || W$1.get(t2);
return ((e2 = n2 == null ? void 0 : n2.rootView) === null || e2 === void 0 ? void 0 : e2.view) || null;
}
};
A$2.styleModule = ri;
A$2.inputHandler = Ll;
A$2.perLineTextDirection = El;
A$2.exceptionSink = Rl;
A$2.updateListener = vs;
A$2.editable = Mn;
A$2.mouseSelectionStyle = Bl;
A$2.dragMovesSelection = Pl;
A$2.clickAddsSelectionRange = Tl;
A$2.decorations = gi;
A$2.atomicRanges = Vl;
A$2.scrollMargins = Il;
A$2.darkTheme = Ds;
A$2.contentAttributes = Js;
A$2.editorAttributes = Nl;
A$2.lineWrapping = /* @__PURE__ */ A$2.contentAttributes.of({ class: "cm-lineWrapping" });
A$2.announce = /* @__PURE__ */ F.define();
const au = 4096, to = {};
class ln {
constructor(t2, e2, i2, n2) {
this.from = t2, this.to = e2, this.dir = i2, this.order = n2;
}
static update(t2, e2) {
if (e2.empty)
return t2;
let i2 = [], n2 = t2.length ? t2[t2.length - 1].dir : X.LTR;
for (let r2 = Math.max(0, t2.length - 10); r2 < t2.length; r2++) {
let o = t2[r2];
o.dir == n2 && !e2.touchesRange(o.from, o.to) && i2.push(new ln(e2.mapPos(o.from, 1), e2.mapPos(o.to, -1), o.dir, o.order));
}
return i2;
}
}
function eo(s, t2, e2) {
for (let i2 = s.state.facet(t2), n2 = i2.length - 1; n2 >= 0; n2--) {
let r2 = i2[n2], o = typeof r2 == "function" ? r2(s) : r2;
o && bs(o, e2);
}
return e2;
}
const cu = x$1.mac ? "mac" : x$1.windows ? "win" : x$1.linux ? "linux" : "key";
function fu(s, t2) {
const e2 = s.split(/-(?!$)/);
let i2 = e2[e2.length - 1];
i2 == "Space" && (i2 = " ");
let n2, r2, o, l;
for (let h2 = 0; h2 < e2.length - 1; ++h2) {
const a2 = e2[h2];
if (/^(cmd|meta|m)$/i.test(a2))
l = true;
else if (/^a(lt)?$/i.test(a2))
n2 = true;
else if (/^(c|ctrl|control)$/i.test(a2))
r2 = true;
else if (/^s(hift)?$/i.test(a2))
o = true;
else if (/^mod$/i.test(a2))
t2 == "mac" ? l = true : r2 = true;
else
throw new Error("Unrecognized modifier name: " + a2);
}
return n2 && (i2 = "Alt-" + i2), r2 && (i2 = "Ctrl-" + i2), l && (i2 = "Meta-" + i2), o && (i2 = "Shift-" + i2), i2;
}
function Li(s, t2, e2) {
return t2.altKey && (s = "Alt-" + s), t2.ctrlKey && (s = "Ctrl-" + s), t2.metaKey && (s = "Meta-" + s), e2 !== false && t2.shiftKey && (s = "Shift-" + s), s;
}
const uu = /* @__PURE__ */ js.default(/* @__PURE__ */ A$2.domEventHandlers({
keydown(s, t2) {
return mu(du(t2.state), s, t2, "editor");
}
})), nh = /* @__PURE__ */ v.define({ enables: uu }), io = /* @__PURE__ */ new WeakMap();
function du(s) {
let t2 = s.facet(nh), e2 = io.get(t2);
return e2 || io.set(t2, e2 = gu(t2.reduce((i2, n2) => i2.concat(n2), []))), e2;
}
let re = null;
const pu = 4e3;
function gu(s, t2 = cu) {
let e2 = /* @__PURE__ */ Object.create(null), i2 = /* @__PURE__ */ Object.create(null), n2 = (o, l) => {
let h2 = i2[o];
if (h2 == null)
i2[o] = l;
else if (h2 != l)
throw new Error("Key binding " + o + " is used both as a regular binding and as a multi-stroke prefix");
}, r2 = (o, l, h2, a2) => {
var c2, f2;
let u2 = e2[o] || (e2[o] = /* @__PURE__ */ Object.create(null)), d2 = l.split(/ (?!$)/).map((g) => fu(g, t2));
for (let g = 1; g < d2.length; g++) {
let y2 = d2.slice(0, g).join(" ");
n2(y2, true), u2[y2] || (u2[y2] = {
preventDefault: true,
run: [(O2) => {
let S2 = re = { view: O2, prefix: y2, scope: o };
return setTimeout(() => {
re == S2 && (re = null);
}, pu), true;
}]
});
}
let p2 = d2.join(" ");
n2(p2, false);
let w2 = u2[p2] || (u2[p2] = { preventDefault: false, run: ((f2 = (c2 = u2._any) === null || c2 === void 0 ? void 0 : c2.run) === null || f2 === void 0 ? void 0 : f2.slice()) || [] });
h2 && w2.run.push(h2), a2 && (w2.preventDefault = true);
};
for (let o of s) {
let l = o.scope ? o.scope.split(" ") : ["editor"];
if (o.any)
for (let a2 of l) {
let c2 = e2[a2] || (e2[a2] = /* @__PURE__ */ Object.create(null));
c2._any || (c2._any = { preventDefault: false, run: [] });
for (let f2 in c2)
c2[f2].run.push(o.any);
}
let h2 = o[t2] || o.key;
if (h2)
for (let a2 of l)
r2(a2, h2, o.run, o.preventDefault), o.shift && r2(a2, "Shift-" + h2, o.shift, o.preventDefault);
}
return e2;
}
function mu(s, t2, e2, i2) {
let n2 = Gc(t2), r2 = hi(n2, 0), o = es(r2) == n2.length && n2 != " ", l = "", h2 = false;
re && re.view == e2 && re.scope == i2 && (l = re.prefix + " ", (h2 = Kl.indexOf(t2.keyCode) < 0) && (re = null));
let a2 = /* @__PURE__ */ new Set(), c2 = (p2) => {
if (p2) {
for (let w2 of p2.run)
if (!a2.has(w2) && (a2.add(w2), w2(e2, t2)))
return true;
p2.preventDefault && (h2 = true);
}
return false;
}, f2 = s[i2], u2, d2;
if (f2) {
if (c2(f2[l + Li(n2, t2, !o)]))
return true;
if (o && (t2.altKey || t2.metaKey || t2.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
!(x$1.windows && t2.ctrlKey && t2.altKey) && (u2 = pe[t2.keyCode]) && u2 != n2) {
if (c2(f2[l + Li(u2, t2, true)]))
return true;
if (t2.shiftKey && (d2 = ui[t2.keyCode]) != n2 && d2 != u2 && c2(f2[l + Li(d2, t2, false)]))
return true;
} else if (o && t2.shiftKey && c2(f2[l + Li(n2, t2, true)]))
return true;
if (c2(f2._any))
return true;
}
return h2;
}
function no(s, t2, e2, i2, n2) {
t2.lastIndex = 0;
for (let r2 = s.iterRange(e2, i2), o = e2, l; !r2.next().done; o += r2.value.length)
if (!r2.lineBreak)
for (; l = t2.exec(r2.value); )
n2(o + l.index, l);
}
function bu(s, t2) {
let e2 = s.visibleRanges;
if (e2.length == 1 && e2[0].from == s.viewport.from && e2[0].to == s.viewport.to)
return e2;
let i2 = [];
for (let { from: n2, to: r2 } of e2)
n2 = Math.max(s.state.doc.lineAt(n2).from, n2 - t2), r2 = Math.min(s.state.doc.lineAt(r2).to, r2 + t2), i2.length && i2[i2.length - 1].to >= n2 ? i2[i2.length - 1].to = r2 : i2.push({ from: n2, to: r2 });
return i2;
}
class ku {
/**
Create a decorator.
*/
constructor(t2) {
const { regexp: e2, decoration: i2, decorate: n2, boundary: r2, maxLength: o = 1e3 } = t2;
if (!e2.global)
throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");
if (this.regexp = e2, n2)
this.addMatch = (l, h2, a2, c2) => n2(c2, a2, a2 + l[0].length, l, h2);
else if (typeof i2 == "function")
this.addMatch = (l, h2, a2, c2) => {
let f2 = i2(l, h2, a2);
f2 && c2(a2, a2 + l[0].length, f2);
};
else if (i2)
this.addMatch = (l, h2, a2, c2) => c2(a2, a2 + l[0].length, i2);
else
throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");
this.boundary = r2, this.maxLength = o;
}
/**
Compute the full set of decorations for matches in the given
view's viewport. You'll want to call this when initializing your
plugin.
*/
createDeco(t2) {
let e2 = new De(), i2 = e2.add.bind(e2);
for (let { from: n2, to: r2 } of bu(t2, this.maxLength))
no(t2.state.doc, this.regexp, n2, r2, (o, l) => this.addMatch(l, t2, o, i2));
return e2.finish();
}
/**
Update a set of decorations for a view update. `deco` _must_ be
the set of decorations produced by _this_ `MatchDecorator` for
the view state before the update.
*/
updateDeco(t2, e2) {
let i2 = 1e9, n2 = -1;
return t2.docChanged && t2.changes.iterChanges((r2, o, l, h2) => {
h2 > t2.view.viewport.from && l < t2.view.viewport.to && (i2 = Math.min(l, i2), n2 = Math.max(h2, n2));
}), t2.viewportChanged || n2 - i2 > 1e3 ? this.createDeco(t2.view) : n2 > -1 ? this.updateRange(t2.view, e2.map(t2.changes), i2, n2) : e2;
}
updateRange(t2, e2, i2, n2) {
for (let r2 of t2.visibleRanges) {
let o = Math.max(r2.from, i2), l = Math.min(r2.to, n2);
if (l > o) {
let h2 = t2.state.doc.lineAt(o), a2 = h2.to < l ? t2.state.doc.lineAt(l) : h2, c2 = Math.max(r2.from, h2.from), f2 = Math.min(r2.to, a2.to);
if (this.boundary) {
for (; o > h2.from; o--)
if (this.boundary.test(h2.text[o - 1 - h2.from])) {
c2 = o;
break;
}
for (; l < a2.to; l++)
if (this.boundary.test(a2.text[l - a2.from])) {
f2 = l;
break;
}
}
let u2 = [], d2, p2 = (w2, g, y2) => u2.push(y2.range(w2, g));
if (h2 == a2)
for (this.regexp.lastIndex = c2 - h2.from; (d2 = this.regexp.exec(h2.text)) && d2.index < f2 - h2.from; )
this.addMatch(d2, t2, d2.index + h2.from, p2);
else
no(t2.state.doc, this.regexp, c2, f2, (w2, g) => this.addMatch(g, t2, w2, p2));
e2 = e2.update({ filterFrom: c2, filterTo: f2, filter: (w2, g) => w2 < c2 || g > f2, add: u2 });
}
}
return e2;
}
}
const Bs = /x/.unicode != null ? "gu" : "g", xu = /* @__PURE__ */ new RegExp(`[\0-\b
--Ÿ­؜\u2028\u2029\uFEFF-]`, Bs), vu = {
0: "null",
7: "bell",
8: "backspace",
10: "newline",
11: "vertical tab",
13: "carriage return",
27: "escape",
8203: "zero width space",
8204: "zero width non-joiner",
8205: "zero width joiner",
8206: "left-to-right mark",
8207: "right-to-left mark",
8232: "line separator",
8237: "left-to-right override",
8238: "right-to-left override",
8294: "left-to-right isolate",
8295: "right-to-left isolate",
8297: "pop directional isolate",
8233: "paragraph separator",
65279: "zero width no-break space",
65532: "object replacement"
};
let Wn = null;
function Su() {
var s;
if (Wn == null && typeof document < "u" && document.body) {
let t2 = document.body.style;
Wn = ((s = t2.tabSize) !== null && s !== void 0 ? s : t2.MozTabSize) != null;
}
return Wn || false;
}
const Ki = /* @__PURE__ */ v.define({
combine(s) {
let t2 = Sn(s, {
render: null,
specialChars: xu,
addSpecialChars: null
});
return (t2.replaceTabs = !Su()) && (t2.specialChars = new RegExp(" |" + t2.specialChars.source, Bs)), t2.addSpecialChars && (t2.specialChars = new RegExp(t2.specialChars.source + "|" + t2.addSpecialChars.source, Bs)), t2;
}
});
function Cu(s = {}) {
return [Ki.of(s), Au()];
}
let so = null;
function Au() {
return so || (so = wt.fromClass(class {
constructor(s) {
this.view = s, this.decorations = T.none, this.decorationCache = /* @__PURE__ */ Object.create(null), this.decorator = this.makeDecorator(s.state.facet(Ki)), this.decorations = this.decorator.createDeco(s);
}
makeDecorator(s) {
return new ku({
regexp: s.specialChars,
decoration: (t2, e2, i2) => {
let { doc: n2 } = e2.state, r2 = hi(t2[0], 0);
if (r2 == 9) {
let o = n2.lineAt(i2), l = e2.state.tabSize, h2 = Cn(o.text, l, i2 - o.from);
return T.replace({ widget: new Tu((l - h2 % l) * this.view.defaultCharacterWidth) });
}
return this.decorationCache[r2] || (this.decorationCache[r2] = T.replace({ widget: new Du(s, r2) }));
},
boundary: s.replaceTabs ? void 0 : /[^]/
});
}
update(s) {
let t2 = s.state.facet(Ki);
s.startState.facet(Ki) != t2 ? (this.decorator = this.makeDecorator(t2), this.decorations = this.decorator.createDeco(s.view)) : this.decorations = this.decorator.updateDeco(s, this.decorations);
}
}, {
decorations: (s) => s.decorations
}));
}
const Ou = "•";
function Mu(s) {
return s >= 32 ? Ou : s == 10 ? "␤" : String.fromCharCode(9216 + s);
}
class Du extends ye {
constructor(t2, e2) {
super(), this.options = t2, this.code = e2;
}
eq(t2) {
return t2.code == this.code;
}
toDOM(t2) {
let e2 = Mu(this.code), i2 = t2.state.phrase("Control character") + " " + (vu[this.code] || "0x" + this.code.toString(16)), n2 = this.options.render && this.options.render(this.code, i2, e2);
if (n2)
return n2;
let r2 = document.createElement("span");
return r2.textContent = e2, r2.title = i2, r2.setAttribute("aria-label", i2), r2.className = "cm-specialChar", r2;
}
ignoreEvent() {
return false;
}
}
class Tu extends ye {
constructor(t2) {
super(), this.width = t2;
}
eq(t2) {
return t2.width == this.width;
}
toDOM() {
let t2 = document.createElement("span");
return t2.textContent = " ", t2.className = "cm-tab", t2.style.width = this.width + "px", t2;
}
ignoreEvent() {
return false;
}
}
function Pu() {
return Ru;
}
const Bu = /* @__PURE__ */ T.line({ class: "cm-activeLine" }), Ru = /* @__PURE__ */ wt.fromClass(class {
constructor(s) {
this.decorations = this.getDeco(s);
}
update(s) {
(s.docChanged || s.selectionSet) && (this.decorations = this.getDeco(s.view));
}
getDeco(s) {
let t2 = -1, e2 = [];
for (let i2 of s.state.selection.ranges) {
let n2 = s.lineBlockAt(i2.head);
n2.from > t2 && (e2.push(Bu.range(n2.from)), t2 = n2.from);
}
return T.set(e2);
}
}, {
decorations: (s) => s.decorations
}), Ei = "-10000px";
class sh {
constructor(t2, e2, i2) {
this.facet = e2, this.createTooltipView = i2, this.input = t2.state.facet(e2), this.tooltips = this.input.filter((n2) => n2), this.tooltipViews = this.tooltips.map(i2);
}
update(t2) {
var e2;
let i2 = t2.state.facet(this.facet), n2 = i2.filter((o) => o);
if (i2 === this.input) {
for (let o of this.tooltipViews)
o.update && o.update(t2);
return false;
}
let r2 = [];
for (let o = 0; o < n2.length; o++) {
let l = n2[o], h2 = -1;
if (l) {
for (let a2 = 0; a2 < this.tooltips.length; a2++) {
let c2 = this.tooltips[a2];
c2 && c2.create == l.create && (h2 = a2);
}
if (h2 < 0)
r2[o] = this.createTooltipView(l);
else {
let a2 = r2[o] = this.tooltipViews[h2];
a2.update && a2.update(t2);
}
}
}
for (let o of this.tooltipViews)
r2.indexOf(o) < 0 && (o.dom.remove(), (e2 = o.destroy) === null || e2 === void 0 || e2.call(o));
return this.input = i2, this.tooltips = n2, this.tooltipViews = r2, true;
}
}
function Lu(s) {
let { win: t2 } = s;
return { top: 0, left: 0, bottom: t2.innerHeight, right: t2.innerWidth };
}
const jn = /* @__PURE__ */ v.define({
combine: (s) => {
var t2, e2, i2;
return {
position: x$1.ios ? "absolute" : ((t2 = s.find((n2) => n2.position)) === null || t2 === void 0 ? void 0 : t2.position) || "fixed",
parent: ((e2 = s.find((n2) => n2.parent)) === null || e2 === void 0 ? void 0 : e2.parent) || null,
tooltipSpace: ((i2 = s.find((n2) => n2.tooltipSpace)) === null || i2 === void 0 ? void 0 : i2.tooltipSpace) || Lu
};
}
}), Eu = /* @__PURE__ */ wt.fromClass(class {
constructor(s) {
this.view = s, this.inView = true, this.lastTransaction = 0, this.measureTimeout = -1;
let t2 = s.state.facet(jn);
this.position = t2.position, this.parent = t2.parent, this.classes = s.themeClasses, this.createContainer(), this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this }, this.manager = new sh(s, rh, (e2) => this.createTooltip(e2)), this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver((e2) => {
Date.now() > this.lastTransaction - 50 && e2.length > 0 && e2[e2.length - 1].intersectionRatio < 1 && this.measureSoon();
}, { threshold: [1] }) : null, this.observeIntersection(), s.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this)), this.maybeMeasure();
}
createContainer() {
this.parent ? (this.container = document.createElement("div"), this.container.style.position = "relative", this.container.className = this.view.themeClasses, this.parent.appendChild(this.container)) : this.container = this.view.dom;
}
observeIntersection() {
if (this.intersectionObserver) {
this.intersectionObserver.disconnect();
for (let s of this.manager.tooltipViews)
this.intersectionObserver.observe(s.dom);
}
}
measureSoon() {
this.measureTimeout < 0 && (this.measureTimeout = setTimeout(() => {
this.measureTimeout = -1, this.maybeMeasure();
}, 50));
}
update(s) {
s.transactions.length && (this.lastTransaction = Date.now());
let t2 = this.manager.update(s);
t2 && this.observeIntersection();
let e2 = t2 || s.geometryChanged, i2 = s.state.facet(jn);
if (i2.position != this.position) {
this.position = i2.position;
for (let n2 of this.manager.tooltipViews)
n2.dom.style.position = this.position;
e2 = true;
}
if (i2.parent != this.parent) {
this.parent && this.container.remove(), this.parent = i2.parent, this.createContainer();
for (let n2 of this.manager.tooltipViews)
this.container.appendChild(n2.dom);
e2 = true;
} else
this.parent && this.view.themeClasses != this.classes && (this.classes = this.container.className = this.view.themeClasses);
e2 && this.maybeMeasure();
}
createTooltip(s) {
let t2 = s.create(this.view);
if (t2.dom.classList.add("cm-tooltip"), s.arrow && !t2.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
let e2 = document.createElement("div");
e2.className = "cm-tooltip-arrow", t2.dom.appendChild(e2);
}
return t2.dom.style.position = this.position, t2.dom.style.top = Ei, this.container.appendChild(t2.dom), t2.mount && t2.mount(this.view), t2;
}
destroy() {
var s, t2;
this.view.win.removeEventListener("resize", this.measureSoon);
for (let e2 of this.manager.tooltipViews)
e2.dom.remove(), (s = e2.destroy) === null || s === void 0 || s.call(e2);
(t2 = this.intersectionObserver) === null || t2 === void 0 || t2.disconnect(), clearTimeout(this.measureTimeout);
}
readMeasure() {
let s = this.view.dom.getBoundingClientRect();
return {
editor: s,
parent: this.parent ? this.container.getBoundingClientRect() : s,
pos: this.manager.tooltips.map((t2, e2) => {
let i2 = this.manager.tooltipViews[e2];
return i2.getCoords ? i2.getCoords(t2.pos) : this.view.coordsAtPos(t2.pos);
}),
size: this.manager.tooltipViews.map(({ dom: t2 }) => t2.getBoundingClientRect()),
space: this.view.state.facet(jn).tooltipSpace(this.view)
};
}
writeMeasure(s) {
let { editor: t2, space: e2 } = s, i2 = [];
for (let n2 = 0; n2 < this.manager.tooltips.length; n2++) {
let r2 = this.manager.tooltips[n2], o = this.manager.tooltipViews[n2], { dom: l } = o, h2 = s.pos[n2], a2 = s.size[n2];
if (!h2 || h2.bottom <= Math.max(t2.top, e2.top) || h2.top >= Math.min(t2.bottom, e2.bottom) || h2.right < Math.max(t2.left, e2.left) - 0.1 || h2.left > Math.min(t2.right, e2.right) + 0.1) {
l.style.top = Ei;
continue;
}
let c2 = r2.arrow ? o.dom.querySelector(".cm-tooltip-arrow") : null, f2 = c2 ? 7 : 0, u2 = a2.right - a2.left, d2 = a2.bottom - a2.top, p2 = o.offset || Vu, w2 = this.view.textDirection == X.LTR, g = a2.width > e2.right - e2.left ? w2 ? e2.left : e2.right - a2.width : w2 ? Math.min(h2.left - (c2 ? 14 : 0) + p2.x, e2.right - u2) : Math.max(e2.left, h2.left - u2 + (c2 ? 14 : 0) - p2.x), y2 = !!r2.above;
!r2.strictSide && (y2 ? h2.top - (a2.bottom - a2.top) - p2.y < e2.top : h2.bottom + (a2.bottom - a2.top) + p2.y > e2.bottom) && y2 == e2.bottom - h2.bottom > h2.top - e2.top && (y2 = !y2);
let O2 = (y2 ? h2.top - e2.top : e2.bottom - h2.bottom) - f2;
if (O2 < d2 && o.resize !== false) {
if (O2 < this.view.defaultLineHeight) {
l.style.top = Ei;
continue;
}
l.style.height = (d2 = O2) + "px";
} else
l.style.height && (l.style.height = "");
let S2 = y2 ? h2.top - d2 - f2 - p2.y : h2.bottom + f2 + p2.y, D2 = g + u2;
if (o.overlap !== true)
for (let B3 of i2)
B3.left < D2 && B3.right > g && B3.top < S2 + d2 && B3.bottom > S2 && (S2 = y2 ? B3.top - d2 - 2 - f2 : B3.bottom + f2 + 2);
this.position == "absolute" ? (l.style.top = S2 - s.parent.top + "px", l.style.left = g - s.parent.left + "px") : (l.style.top = S2 + "px", l.style.left = g + "px"), c2 && (c2.style.left = `${h2.left + (w2 ? p2.x : -p2.x) - (g + 14 - 7)}px`), o.overlap !== true && i2.push({ left: g, top: S2, right: D2, bottom: S2 + d2 }), l.classList.toggle("cm-tooltip-above", y2), l.classList.toggle("cm-tooltip-below", !y2), o.positioned && o.positioned(s.space);
}
}
maybeMeasure() {
if (this.manager.tooltips.length && (this.view.inView && this.view.requestMeasure(this.measureReq), this.inView != this.view.inView && (this.inView = this.view.inView, !this.inView)))
for (let s of this.manager.tooltipViews)
s.dom.style.top = Ei;
}
}, {
eventHandlers: {
scroll() {
this.maybeMeasure();
}
}
}), Nu = /* @__PURE__ */ A$2.baseTheme({
".cm-tooltip": {
zIndex: 100,
boxSizing: "border-box"
},
"&light .cm-tooltip": {
border: "1px solid #bbb",
backgroundColor: "#f5f5f5"
},
"&light .cm-tooltip-section:not(:first-child)": {
borderTop: "1px solid #bbb"
},
"&dark .cm-tooltip": {
backgroundColor: "#333338",
color: "white"
},
".cm-tooltip-arrow": {
height: `${7}px`,
width: `${7 * 2}px`,
position: "absolute",
zIndex: -1,
overflow: "hidden",
"&:before, &:after": {
content: "''",
position: "absolute",
width: 0,
height: 0,
borderLeft: `${7}px solid transparent`,
borderRight: `${7}px solid transparent`
},
".cm-tooltip-above &": {
bottom: `-${7}px`,
"&:before": {
borderTop: `${7}px solid #bbb`
},
"&:after": {
borderTop: `${7}px solid #f5f5f5`,
bottom: "1px"
}
},
".cm-tooltip-below &": {
top: `-${7}px`,
"&:before": {
borderBottom: `${7}px solid #bbb`
},
"&:after": {
borderBottom: `${7}px solid #f5f5f5`,
top: "1px"
}
}
},
"&dark .cm-tooltip .cm-tooltip-arrow": {
"&:before": {
borderTopColor: "#333338",
borderBottomColor: "#333338"
},
"&:after": {
borderTopColor: "transparent",
borderBottomColor: "transparent"
}
}
}), Vu = { x: 0, y: 0 }, rh = /* @__PURE__ */ v.define({
enables: [Eu, Nu]
}), hn = /* @__PURE__ */ v.define();
class Ys {
constructor(t2) {
this.view = t2, this.mounted = false, this.dom = document.createElement("div"), this.dom.classList.add("cm-tooltip-hover"), this.manager = new sh(t2, hn, (e2) => this.createHostedView(e2));
}
// Needs to be static so that host tooltip instances always match
static create(t2) {
return new Ys(t2);
}
createHostedView(t2) {
let e2 = t2.create(this.view);
return e2.dom.classList.add("cm-tooltip-section"), this.dom.appendChild(e2.dom), this.mounted && e2.mount && e2.mount(this.view), e2;
}
mount(t2) {
for (let e2 of this.manager.tooltipViews)
e2.mount && e2.mount(t2);
this.mounted = true;
}
positioned(t2) {
for (let e2 of this.manager.tooltipViews)
e2.positioned && e2.positioned(t2);
}
update(t2) {
this.manager.update(t2);
}
}
const Iu = /* @__PURE__ */ rh.compute([hn], (s) => {
let t2 = s.facet(hn).filter((e2) => e2);
return t2.length === 0 ? null : {
pos: Math.min(...t2.map((e2) => e2.pos)),
end: Math.max(...t2.filter((e2) => e2.end != null).map((e2) => e2.end)),
create: Ys.create,
above: t2[0].above,
arrow: t2.some((e2) => e2.arrow)
};
});
class Hu {
constructor(t2, e2, i2, n2, r2) {
this.view = t2, this.source = e2, this.field = i2, this.setHover = n2, this.hoverTime = r2, this.hoverTimeout = -1, this.restartTimeout = -1, this.pending = null, this.lastMove = { x: 0, y: 0, target: t2.dom, time: 0 }, this.checkHover = this.checkHover.bind(this), t2.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this)), t2.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
}
update() {
this.pending && (this.pending = null, clearTimeout(this.restartTimeout), this.restartTimeout = setTimeout(() => this.startHover(), 20));
}
get active() {
return this.view.state.field(this.field);
}
checkHover() {
if (this.hoverTimeout = -1, this.active)
return;
let t2 = Date.now() - this.lastMove.time;
t2 < this.hoverTime ? this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - t2) : this.startHover();
}
startHover() {
clearTimeout(this.restartTimeout);
let { lastMove: t2 } = this, e2 = this.view.contentDOM.contains(t2.target) ? this.view.posAtCoords(t2) : null;
if (e2 == null)
return;
let i2 = this.view.coordsAtPos(e2);
if (i2 == null || t2.y < i2.top || t2.y > i2.bottom || t2.x < i2.left - this.view.defaultCharacterWidth || t2.x > i2.right + this.view.defaultCharacterWidth)
return;
let n2 = this.view.bidiSpans(this.view.state.doc.lineAt(e2)).find((l) => l.from <= e2 && l.to >= e2), r2 = n2 && n2.dir == X.RTL ? -1 : 1, o = this.source(this.view, e2, t2.x < i2.left ? -r2 : r2);
if (o != null && o.then) {
let l = this.pending = { pos: e2 };
o.then((h2) => {
this.pending == l && (this.pending = null, h2 && this.view.dispatch({ effects: this.setHover.of(h2) }));
}, (h2) => zt(this.view.state, h2, "hover tooltip"));
} else
o && this.view.dispatch({ effects: this.setHover.of(o) });
}
mousemove(t2) {
var e2;
this.lastMove = { x: t2.clientX, y: t2.clientY, target: t2.target, time: Date.now() }, this.hoverTimeout < 0 && (this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime));
let i2 = this.active;
if (i2 && !ro(this.lastMove.target) || this.pending) {
let { pos: n2 } = i2 || this.pending, r2 = (e2 = i2 == null ? void 0 : i2.end) !== null && e2 !== void 0 ? e2 : n2;
(n2 == r2 ? this.view.posAtCoords(this.lastMove) != n2 : !$u(
this.view,
n2,
r2,
t2.clientX,
t2.clientY,
6
/* Hover.MaxDist */
)) && (this.view.dispatch({ effects: this.setHover.of(null) }), this.pending = null);
}
}
mouseleave(t2) {
clearTimeout(this.hoverTimeout), this.hoverTimeout = -1, this.active && !ro(t2.relatedTarget) && this.view.dispatch({ effects: this.setHover.of(null) });
}
destroy() {
clearTimeout(this.hoverTimeout), this.view.dom.removeEventListener("mouseleave", this.mouseleave), this.view.dom.removeEventListener("mousemove", this.mousemove);
}
}
function ro(s) {
for (let t2 = s; t2; t2 = t2.parentNode)
if (t2.nodeType == 1 && t2.classList.contains("cm-tooltip"))
return true;
return false;
}
function $u(s, t2, e2, i2, n2, r2) {
let o = document.createRange(), l = s.domAtPos(t2), h2 = s.domAtPos(e2);
o.setEnd(h2.node, h2.offset), o.setStart(l.node, l.offset);
let a2 = o.getClientRects();
o.detach();
for (let c2 = 0; c2 < a2.length; c2++) {
let f2 = a2[c2];
if (Math.max(f2.top - n2, n2 - f2.bottom, f2.left - i2, i2 - f2.right) <= r2)
return true;
}
return false;
}
function Fu(s, t2 = {}) {
let e2 = F.define(), i2 = Bt.define({
create() {
return null;
},
update(n2, r2) {
if (n2 && (t2.hideOnChange && (r2.docChanged || r2.selection) || t2.hideOn && t2.hideOn(r2, n2)))
return null;
if (n2 && r2.docChanged) {
let o = r2.changes.mapPos(n2.pos, -1, gt.TrackDel);
if (o == null)
return null;
let l = Object.assign(/* @__PURE__ */ Object.create(null), n2);
l.pos = o, n2.end != null && (l.end = r2.changes.mapPos(n2.end)), n2 = l;
}
for (let o of r2.effects)
o.is(e2) && (n2 = o.value), o.is(zu) && (n2 = null);
return n2;
},
provide: (n2) => hn.from(n2)
});
return [
i2,
wt.define((n2) => new Hu(
n2,
s,
i2,
e2,
t2.hoverTime || 300
/* Hover.Time */
)),
Iu
];
}
const zu = /* @__PURE__ */ F.define(), oo = /* @__PURE__ */ v.define({
combine(s) {
let t2, e2;
for (let i2 of s)
t2 = t2 || i2.topContainer, e2 = e2 || i2.bottomContainer;
return { topContainer: t2, bottomContainer: e2 };
}
});
function _u(s, t2) {
let e2 = s.plugin(oh), i2 = e2 ? e2.specs.indexOf(t2) : -1;
return i2 > -1 ? e2.panels[i2] : null;
}
const oh = /* @__PURE__ */ wt.fromClass(class {
constructor(s) {
this.input = s.state.facet(Rs), this.specs = this.input.filter((e2) => e2), this.panels = this.specs.map((e2) => e2(s));
let t2 = s.state.facet(oo);
this.top = new Ni(s, true, t2.topContainer), this.bottom = new Ni(s, false, t2.bottomContainer), this.top.sync(this.panels.filter((e2) => e2.top)), this.bottom.sync(this.panels.filter((e2) => !e2.top));
for (let e2 of this.panels)
e2.dom.classList.add("cm-panel"), e2.mount && e2.mount();
}
update(s) {
let t2 = s.state.facet(oo);
this.top.container != t2.topContainer && (this.top.sync([]), this.top = new Ni(s.view, true, t2.topContainer)), this.bottom.container != t2.bottomContainer && (this.bottom.sync([]), this.bottom = new Ni(s.view, false, t2.bottomContainer)), this.top.syncClasses(), this.bottom.syncClasses();
let e2 = s.state.facet(Rs);
if (e2 != this.input) {
let i2 = e2.filter((h2) => h2), n2 = [], r2 = [], o = [], l = [];
for (let h2 of i2) {
let a2 = this.specs.indexOf(h2), c2;
a2 < 0 ? (c2 = h2(s.view), l.push(c2)) : (c2 = this.panels[a2], c2.update && c2.update(s)), n2.push(c2), (c2.top ? r2 : o).push(c2);
}
this.specs = i2, this.panels = n2, this.top.sync(r2), this.bottom.sync(o);
for (let h2 of l)
h2.dom.classList.add("cm-panel"), h2.mount && h2.mount();
} else
for (let i2 of this.panels)
i2.update && i2.update(s);
}
destroy() {
this.top.sync([]), this.bottom.sync([]);
}
}, {
provide: (s) => A$2.scrollMargins.of((t2) => {
let e2 = t2.plugin(s);
return e2 && { top: e2.top.scrollMargin(), bottom: e2.bottom.scrollMargin() };
})
});
class Ni {
constructor(t2, e2, i2) {
this.view = t2, this.top = e2, this.container = i2, this.dom = void 0, this.classes = "", this.panels = [], this.syncClasses();
}
sync(t2) {
for (let e2 of this.panels)
e2.destroy && t2.indexOf(e2) < 0 && e2.destroy();
this.panels = t2, this.syncDOM();
}
syncDOM() {
if (this.panels.length == 0) {
this.dom && (this.dom.remove(), this.dom = void 0);
return;
}
if (!this.dom) {
this.dom = document.createElement("div"), this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom", this.dom.style[this.top ? "top" : "bottom"] = "0";
let e2 = this.container || this.view.dom;
e2.insertBefore(this.dom, this.top ? e2.firstChild : null);
}
let t2 = this.dom.firstChild;
for (let e2 of this.panels)
if (e2.dom.parentNode == this.dom) {
for (; t2 != e2.dom; )
t2 = lo(t2);
t2 = t2.nextSibling;
} else
this.dom.insertBefore(e2.dom, t2);
for (; t2; )
t2 = lo(t2);
}
scrollMargin() {
return !this.dom || this.container ? 0 : Math.max(0, this.top ? this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) : Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
}
syncClasses() {
if (!(!this.container || this.classes == this.view.themeClasses)) {
for (let t2 of this.classes.split(" "))
t2 && this.container.classList.remove(t2);
for (let t2 of (this.classes = this.view.themeClasses).split(" "))
t2 && this.container.classList.add(t2);
}
}
}
function lo(s) {
let t2 = s.nextSibling;
return s.remove(), t2;
}
const Rs = /* @__PURE__ */ v.define({
enables: oh
});
class me extends je {
/**
@internal
*/
compare(t2) {
return this == t2 || this.constructor == t2.constructor && this.eq(t2);
}
/**
Compare this marker to another marker of the same type.
*/
eq(t2) {
return false;
}
/**
Called if the marker has a `toDOM` method and its representation
was removed from a gutter.
*/
destroy(t2) {
}
}
me.prototype.elementClass = "";
me.prototype.toDOM = void 0;
me.prototype.mapMode = gt.TrackBefore;
me.prototype.startSide = me.prototype.endSide = -1;
me.prototype.point = true;
const Gi = /* @__PURE__ */ v.define(), Wu = {
class: "",
renderEmptyElements: false,
elementStyle: "",
markers: () => $.empty,
lineMarker: () => null,
lineMarkerChange: null,
initialSpacer: null,
updateSpacer: null,
domEventHandlers: {}
}, Ui = /* @__PURE__ */ v.define();
function ju(s) {
return [qu(), Ui.of(Object.assign(Object.assign({}, Wu), s))];
}
const Ls = /* @__PURE__ */ v.define({
combine: (s) => s.some((t2) => t2)
});
function qu(s) {
let t2 = [
Ku
];
return s && s.fixed === false && t2.push(Ls.of(true)), t2;
}
const Ku = /* @__PURE__ */ wt.fromClass(class {
constructor(s) {
this.view = s, this.prevViewport = s.viewport, this.dom = document.createElement("div"), this.dom.className = "cm-gutters", this.dom.setAttribute("aria-hidden", "true"), this.dom.style.minHeight = this.view.contentHeight + "px", this.gutters = s.state.facet(Ui).map((t2) => new ao(s, t2));
for (let t2 of this.gutters)
this.dom.appendChild(t2.dom);
this.fixed = !s.state.facet(Ls), this.fixed && (this.dom.style.position = "sticky"), this.syncGutters(false), s.scrollDOM.insertBefore(this.dom, s.contentDOM);
}
update(s) {
if (this.updateGutters(s)) {
let t2 = this.prevViewport, e2 = s.view.viewport, i2 = Math.min(t2.to, e2.to) - Math.max(t2.from, e2.from);
this.syncGutters(i2 < (e2.to - e2.from) * 0.8);
}
s.geometryChanged && (this.dom.style.minHeight = this.view.contentHeight + "px"), this.view.state.facet(Ls) != !this.fixed && (this.fixed = !this.fixed, this.dom.style.position = this.fixed ? "sticky" : ""), this.prevViewport = s.view.viewport;
}
syncGutters(s) {
let t2 = this.dom.nextSibling;
s && this.dom.remove();
let e2 = $.iter(this.view.state.facet(Gi), this.view.viewport.from), i2 = [], n2 = this.gutters.map((r2) => new Gu(r2, this.view.viewport, -this.view.documentPadding.top));
for (let r2 of this.view.viewportLineBlocks) {
let o;
if (Array.isArray(r2.type)) {
for (let l of r2.type)
if (l.type == U.Text) {
o = l;
break;
}
} else
o = r2.type == U.Text ? r2 : void 0;
if (o) {
i2.length && (i2 = []), lh(e2, i2, r2.from);
for (let l of n2)
l.line(this.view, o, i2);
}
}
for (let r2 of n2)
r2.finish();
s && this.view.scrollDOM.insertBefore(this.dom, t2);
}
updateGutters(s) {
let t2 = s.startState.facet(Ui), e2 = s.state.facet(Ui), i2 = s.docChanged || s.heightChanged || s.viewportChanged || !$.eq(s.startState.facet(Gi), s.state.facet(Gi), s.view.viewport.from, s.view.viewport.to);
if (t2 == e2)
for (let n2 of this.gutters)
n2.update(s) && (i2 = true);
else {
i2 = true;
let n2 = [];
for (let r2 of e2) {
let o = t2.indexOf(r2);
o < 0 ? n2.push(new ao(this.view, r2)) : (this.gutters[o].update(s), n2.push(this.gutters[o]));
}
for (let r2 of this.gutters)
r2.dom.remove(), n2.indexOf(r2) < 0 && r2.destroy();
for (let r2 of n2)
this.dom.appendChild(r2.dom);
this.gutters = n2;
}
return i2;
}
destroy() {
for (let s of this.gutters)
s.destroy();
this.dom.remove();
}
}, {
provide: (s) => A$2.scrollMargins.of((t2) => {
let e2 = t2.plugin(s);
return !e2 || e2.gutters.length == 0 || !e2.fixed ? null : t2.textDirection == X.LTR ? { left: e2.dom.offsetWidth } : { right: e2.dom.offsetWidth };
})
});
function ho(s) {
return Array.isArray(s) ? s : [s];
}
function lh(s, t2, e2) {
for (; s.value && s.from <= e2; )
s.from == e2 && t2.push(s.value), s.next();
}
class Gu {
constructor(t2, e2, i2) {
this.gutter = t2, this.height = i2, this.i = 0, this.cursor = $.iter(t2.markers, e2.from);
}
line(t2, e2, i2) {
let n2 = [];
lh(this.cursor, n2, e2.from), i2.length && (n2 = n2.concat(i2));
let r2 = this.gutter.config.lineMarker(t2, e2, n2);
r2 && n2.unshift(r2);
let o = this.gutter;
if (n2.length == 0 && !o.config.renderEmptyElements)
return;
let l = e2.top - this.height;
if (this.i == o.elements.length) {
let h2 = new hh(t2, e2.height, l, n2);
o.elements.push(h2), o.dom.appendChild(h2.dom);
} else
o.elements[this.i].update(t2, e2.height, l, n2);
this.height = e2.bottom, this.i++;
}
finish() {
let t2 = this.gutter;
for (; t2.elements.length > this.i; ) {
let e2 = t2.elements.pop();
t2.dom.removeChild(e2.dom), e2.destroy();
}
}
}
class ao {
constructor(t2, e2) {
this.view = t2, this.config = e2, this.elements = [], this.spacer = null, this.dom = document.createElement("div"), this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
for (let i2 in e2.domEventHandlers)
this.dom.addEventListener(i2, (n2) => {
let r2 = n2.target, o;
if (r2 != this.dom && this.dom.contains(r2)) {
for (; r2.parentNode != this.dom; )
r2 = r2.parentNode;
let h2 = r2.getBoundingClientRect();
o = (h2.top + h2.bottom) / 2;
} else
o = n2.clientY;
let l = t2.lineBlockAtHeight(o - t2.documentTop);
e2.domEventHandlers[i2](t2, l, n2) && n2.preventDefault();
});
this.markers = ho(e2.markers(t2)), e2.initialSpacer && (this.spacer = new hh(t2, 0, 0, [e2.initialSpacer(t2)]), this.dom.appendChild(this.spacer.dom), this.spacer.dom.style.cssText += "visibility: hidden; pointer-events: none");
}
update(t2) {
let e2 = this.markers;
if (this.markers = ho(this.config.markers(t2.view)), this.spacer && this.config.updateSpacer) {
let n2 = this.config.updateSpacer(this.spacer.markers[0], t2);
n2 != this.spacer.markers[0] && this.spacer.update(t2.view, 0, 0, [n2]);
}
let i2 = t2.view.viewport;
return !$.eq(this.markers, e2, i2.from, i2.to) || (this.config.lineMarkerChange ? this.config.lineMarkerChange(t2) : false);
}
destroy() {
for (let t2 of this.elements)
t2.destroy();
}
}
class hh {
constructor(t2, e2, i2, n2) {
this.height = -1, this.above = 0, this.markers = [], this.dom = document.createElement("div"), this.dom.className = "cm-gutterElement", this.update(t2, e2, i2, n2);
}
update(t2, e2, i2, n2) {
this.height != e2 && (this.dom.style.height = (this.height = e2) + "px"), this.above != i2 && (this.dom.style.marginTop = (this.above = i2) ? i2 + "px" : ""), Uu(this.markers, n2) || this.setMarkers(t2, n2);
}
setMarkers(t2, e2) {
let i2 = "cm-gutterElement", n2 = this.dom.firstChild;
for (let r2 = 0, o = 0; ; ) {
let l = o, h2 = r2 < e2.length ? e2[r2++] : null, a2 = false;
if (h2) {
let c2 = h2.elementClass;
c2 && (i2 += " " + c2);
for (let f2 = o; f2 < this.markers.length; f2++)
if (this.markers[f2].compare(h2)) {
l = f2, a2 = true;
break;
}
} else
l = this.markers.length;
for (; o < l; ) {
let c2 = this.markers[o++];
if (c2.toDOM) {
c2.destroy(n2);
let f2 = n2.nextSibling;
n2.remove(), n2 = f2;
}
}
if (!h2)
break;
h2.toDOM && (a2 ? n2 = n2.nextSibling : this.dom.insertBefore(h2.toDOM(t2), n2)), a2 && o++;
}
this.dom.className = i2, this.markers = e2;
}
destroy() {
this.setMarkers(null, []);
}
}
function Uu(s, t2) {
if (s.length != t2.length)
return false;
for (let e2 = 0; e2 < s.length; e2++)
if (!s[e2].compare(t2[e2]))
return false;
return true;
}
const Qu = /* @__PURE__ */ new class extends me {
constructor() {
super(...arguments), this.elementClass = "cm-activeLineGutter";
}
}(), Ju = /* @__PURE__ */ Gi.compute(["selection"], (s) => {
let t2 = [], e2 = -1;
for (let i2 of s.selection.ranges) {
let n2 = s.doc.lineAt(i2.head).from;
n2 > e2 && (e2 = n2, t2.push(Qu.range(n2)));
}
return $.of(t2);
});
function Xu() {
return Ju;
}
const ah = 1024;
let Yu = 0;
class qn {
constructor(t2, e2) {
this.from = t2, this.to = e2;
}
}
let P$1 = class P2 {
/// Create a new node prop type.
constructor(t2 = {}) {
this.id = Yu++, this.perNode = !!t2.perNode, this.deserialize = t2.deserialize || (() => {
throw new Error("This node type doesn't define a deserialize function");
});
}
/// This is meant to be used with
/// [`NodeSet.extend`](#common.NodeSet.extend) or
/// [`LRParser.configure`](#lr.ParserConfig.props) to compute
/// prop values for each node type in the set. Takes a [match
/// object](#common.NodeType^match) or function that returns undefined
/// if the node type doesn't get this prop, and the prop's value if
/// it does.
add(t2) {
if (this.perNode)
throw new RangeError("Can't add per-node props to node types");
return typeof t2 != "function" && (t2 = yt.match(t2)), (e2) => {
let i2 = t2(e2);
return i2 === void 0 ? null : [this, i2];
};
}
};
P$1.closedBy = new P$1({ deserialize: (s) => s.split(" ") });
P$1.openedBy = new P$1({ deserialize: (s) => s.split(" ") });
P$1.group = new P$1({ deserialize: (s) => s.split(" ") });
P$1.contextHash = new P$1({ perNode: true });
P$1.lookAhead = new P$1({ perNode: true });
P$1.mounted = new P$1({ perNode: true });
const Zu = /* @__PURE__ */ Object.create(null);
class yt {
/// @internal
constructor(t2, e2, i2, n2 = 0) {
this.name = t2, this.props = e2, this.id = i2, this.flags = n2;
}
/// Define a node type.
static define(t2) {
let e2 = t2.props && t2.props.length ? /* @__PURE__ */ Object.create(null) : Zu, i2 = (t2.top ? 1 : 0) | (t2.skipped ? 2 : 0) | (t2.error ? 4 : 0) | (t2.name == null ? 8 : 0), n2 = new yt(t2.name || "", e2, t2.id, i2);
if (t2.props) {
for (let r2 of t2.props)
if (Array.isArray(r2) || (r2 = r2(n2)), r2) {
if (r2[0].perNode)
throw new RangeError("Can't store a per-node prop on a node type");
e2[r2[0].id] = r2[1];
}
}
return n2;
}
/// Retrieves a node prop for this type. Will return `undefined` if
/// the prop isn't present on this node.
prop(t2) {
return this.props[t2.id];
}
/// True when this is the top node of a grammar.
get isTop() {
return (this.flags & 1) > 0;
}
/// True when this node is produced by a skip rule.
get isSkipped() {
return (this.flags & 2) > 0;
}
/// Indicates whether this is an error node.
get isError() {
return (this.flags & 4) > 0;
}
/// When true, this node type doesn't correspond to a user-declared
/// named node, for example because it is used to cache repetition.
get isAnonymous() {
return (this.flags & 8) > 0;
}
/// Returns true when this node's name or one of its
/// [groups](#common.NodeProp^group) matches the given string.
is(t2) {
if (typeof t2 == "string") {
if (this.name == t2)
return true;
let e2 = this.prop(P$1.group);
return e2 ? e2.indexOf(t2) > -1 : false;
}
return this.id == t2;
}
/// Create a function from node types to arbitrary values by
/// specifying an object whose property names are node or
/// [group](#common.NodeProp^group) names. Often useful with
/// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
/// names, separated by spaces, in a single property name to map
/// multiple node names to a single value.
static match(t2) {
let e2 = /* @__PURE__ */ Object.create(null);
for (let i2 in t2)
for (let n2 of i2.split(" "))
e2[n2] = t2[i2];
return (i2) => {
for (let n2 = i2.prop(P$1.group), r2 = -1; r2 < (n2 ? n2.length : 0); r2++) {
let o = e2[r2 < 0 ? i2.name : n2[r2]];
if (o)
return o;
}
};
}
}
yt.none = new yt(
"",
/* @__PURE__ */ Object.create(null),
0,
8
/* NodeFlag.Anonymous */
);
class Zs {
/// Create a set with the given types. The `id` property of each
/// type should correspond to its position within the array.
constructor(t2) {
this.types = t2;
for (let e2 = 0; e2 < t2.length; e2++)
if (t2[e2].id != e2)
throw new RangeError("Node type ids should correspond to array positions when creating a node set");
}
/// Create a copy of this set with some node properties added. The
/// arguments to this method can be created with
/// [`NodeProp.add`](#common.NodeProp.add).
extend(...t2) {
let e2 = [];
for (let i2 of this.types) {
let n2 = null;
for (let r2 of t2) {
let o = r2(i2);
o && (n2 || (n2 = Object.assign({}, i2.props)), n2[o[0].id] = o[1]);
}
e2.push(n2 ? new yt(i2.name, n2, i2.id, i2.flags) : i2);
}
return new Zs(e2);
}
}
const Vi = /* @__PURE__ */ new WeakMap(), co = /* @__PURE__ */ new WeakMap();
var st;
(function(s) {
s[s.ExcludeBuffers = 1] = "ExcludeBuffers", s[s.IncludeAnonymous = 2] = "IncludeAnonymous", s[s.IgnoreMounts = 4] = "IgnoreMounts", s[s.IgnoreOverlays = 8] = "IgnoreOverlays";
})(st || (st = {}));
let J$1 = class J2 {
/// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
constructor(t2, e2, i2, n2, r2) {
if (this.type = t2, this.children = e2, this.positions = i2, this.length = n2, this.props = null, r2 && r2.length) {
this.props = /* @__PURE__ */ Object.create(null);
for (let [o, l] of r2)
this.props[typeof o == "number" ? o : o.id] = l;
}
}
/// @internal
toString() {
let t2 = this.prop(P$1.mounted);
if (t2 && !t2.overlay)
return t2.tree.toString();
let e2 = "";
for (let i2 of this.children) {
let n2 = i2.toString();
n2 && (e2 && (e2 += ","), e2 += n2);
}
return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (e2.length ? "(" + e2 + ")" : "") : e2;
}
/// Get a [tree cursor](#common.TreeCursor) positioned at the top of
/// the tree. Mode can be used to [control](#common.IterMode) which
/// nodes the cursor visits.
cursor(t2 = 0) {
return new fn(this.topNode, t2);
}
/// Get a [tree cursor](#common.TreeCursor) pointing into this tree
/// at the given position and side (see
/// [`moveTo`](#common.TreeCursor.moveTo).
cursorAt(t2, e2 = 0, i2 = 0) {
let n2 = Vi.get(this) || this.topNode, r2 = new fn(n2);
return r2.moveTo(t2, e2), Vi.set(this, r2._tree), r2;
}
/// Get a [syntax node](#common.SyntaxNode) object for the top of the
/// tree.
get topNode() {
return new Zt(this, 0, 0, null);
}
/// Get the [syntax node](#common.SyntaxNode) at the given position.
/// If `side` is -1, this will move into nodes that end at the
/// position. If 1, it'll move into nodes that start at the
/// position. With 0, it'll only enter nodes that cover the position
/// from both sides.
///
/// Note that this will not enter
/// [overlays](#common.MountedTree.overlay), and you often want
/// [`resolveInner`](#common.Tree.resolveInner) instead.
resolve(t2, e2 = 0) {
let i2 = Ue(Vi.get(this) || this.topNode, t2, e2, false);
return Vi.set(this, i2), i2;
}
/// Like [`resolve`](#common.Tree.resolve), but will enter
/// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
/// pointing into the innermost overlaid tree at the given position
/// (with parent links going through all parent structure, including
/// the host trees).
resolveInner(t2, e2 = 0) {
let i2 = Ue(co.get(this) || this.topNode, t2, e2, true);
return co.set(this, i2), i2;
}
/// Iterate over the tree and its children, calling `enter` for any
/// node that touches the `from`/`to` region (if given) before
/// running over such a node's children, and `leave` (if given) when
/// leaving the node. When `enter` returns `false`, that node will
/// not have its children iterated over (or `leave` called).
iterate(t2) {
let { enter: e2, leave: i2, from: n2 = 0, to: r2 = this.length } = t2;
for (let o = this.cursor((t2.mode || 0) | st.IncludeAnonymous); ; ) {
let l = false;
if (o.from <= r2 && o.to >= n2 && (o.type.isAnonymous || e2(o) !== false)) {
if (o.firstChild())
continue;
l = true;
}
for (; l && i2 && !o.type.isAnonymous && i2(o), !o.nextSibling(); ) {
if (!o.parent())
return;
l = true;
}
}
}
/// Get the value of the given [node prop](#common.NodeProp) for this
/// node. Works with both per-node and per-type props.
prop(t2) {
return t2.perNode ? this.props ? this.props[t2.id] : void 0 : this.type.prop(t2);
}
/// Returns the node's [per-node props](#common.NodeProp.perNode) in a
/// format that can be passed to the [`Tree`](#common.Tree)
/// constructor.
get propValues() {
let t2 = [];
if (this.props)
for (let e2 in this.props)
t2.push([+e2, this.props[e2]]);
return t2;
}
/// Balance the direct children of this tree, producing a copy of
/// which may have children grouped into subtrees with type
/// [`NodeType.none`](#common.NodeType^none).
balance(t2 = {}) {
return this.children.length <= 8 ? this : ir(yt.none, this.children, this.positions, 0, this.children.length, 0, this.length, (e2, i2, n2) => new J2(this.type, e2, i2, n2, this.propValues), t2.makeTree || ((e2, i2, n2) => new J2(yt.none, e2, i2, n2)));
}
/// Build a tree from a postfix-ordered buffer of node information,
/// or a cursor over such a buffer.
static build(t2) {
return ed(t2);
}
};
J$1.empty = new J$1(yt.none, [], [], 0);
class tr {
constructor(t2, e2) {
this.buffer = t2, this.index = e2;
}
get id() {
return this.buffer[this.index - 4];
}
get start() {
return this.buffer[this.index - 3];
}
get end() {
return this.buffer[this.index - 2];
}
get size() {
return this.buffer[this.index - 1];
}
get pos() {
return this.index;
}
next() {
this.index -= 4;
}
fork() {
return new tr(this.buffer, this.index);
}
}
class Re {
/// Create a tree buffer.
constructor(t2, e2, i2) {
this.buffer = t2, this.length = e2, this.set = i2;
}
/// @internal
get type() {
return yt.none;
}
/// @internal
toString() {
let t2 = [];
for (let e2 = 0; e2 < this.buffer.length; )
t2.push(this.childString(e2)), e2 = this.buffer[e2 + 3];
return t2.join(",");
}
/// @internal
childString(t2) {
let e2 = this.buffer[t2], i2 = this.buffer[t2 + 3], n2 = this.set.types[e2], r2 = n2.name;
if (/\W/.test(r2) && !n2.isError && (r2 = JSON.stringify(r2)), t2 += 4, i2 == t2)
return r2;
let o = [];
for (; t2 < i2; )
o.push(this.childString(t2)), t2 = this.buffer[t2 + 3];
return r2 + "(" + o.join(",") + ")";
}
/// @internal
findChild(t2, e2, i2, n2, r2) {
let { buffer: o } = this, l = -1;
for (let h2 = t2; h2 != e2 && !(ch(r2, n2, o[h2 + 1], o[h2 + 2]) && (l = h2, i2 > 0)); h2 = o[h2 + 3])
;
return l;
}
/// @internal
slice(t2, e2, i2) {
let n2 = this.buffer, r2 = new Uint16Array(e2 - t2), o = 0;
for (let l = t2, h2 = 0; l < e2; ) {
r2[h2++] = n2[l++], r2[h2++] = n2[l++] - i2;
let a2 = r2[h2++] = n2[l++] - i2;
r2[h2++] = n2[l++] - t2, o = Math.max(o, a2);
}
return new Re(r2, o, this.set);
}
}
function ch(s, t2, e2, i2) {
switch (s) {
case -2:
return e2 < t2;
case -1:
return i2 >= t2 && e2 < t2;
case 0:
return e2 < t2 && i2 > t2;
case 1:
return e2 <= t2 && i2 > t2;
case 2:
return i2 > t2;
case 4:
return true;
}
}
function fh(s, t2) {
let e2 = s.childBefore(t2);
for (; e2; ) {
let i2 = e2.lastChild;
if (!i2 || i2.to != e2.to)
break;
i2.type.isError && i2.from == i2.to ? (s = e2, e2 = i2.prevSibling) : e2 = i2;
}
return s;
}
function Ue(s, t2, e2, i2) {
for (var n2; s.from == s.to || (e2 < 1 ? s.from >= t2 : s.from > t2) || (e2 > -1 ? s.to <= t2 : s.to < t2); ) {
let o = !i2 && s instanceof Zt && s.index < 0 ? null : s.parent;
if (!o)
return s;
s = o;
}
let r2 = i2 ? 0 : st.IgnoreOverlays;
if (i2)
for (let o = s, l = o.parent; l; o = l, l = o.parent)
o instanceof Zt && o.index < 0 && ((n2 = l.enter(t2, e2, r2)) === null || n2 === void 0 ? void 0 : n2.from) != o.from && (s = l);
for (; ; ) {
let o = s.enter(t2, e2, r2);
if (!o)
return s;
s = o;
}
}
class Zt {
constructor(t2, e2, i2, n2) {
this._tree = t2, this.from = e2, this.index = i2, this._parent = n2;
}
get type() {
return this._tree.type;
}
get name() {
return this._tree.type.name;
}
get to() {
return this.from + this._tree.length;
}
nextChild(t2, e2, i2, n2, r2 = 0) {
for (let o = this; ; ) {
for (let { children: l, positions: h2 } = o._tree, a2 = e2 > 0 ? l.length : -1; t2 != a2; t2 += e2) {
let c2 = l[t2], f2 = h2[t2] + o.from;
if (ch(n2, i2, f2, f2 + c2.length)) {
if (c2 instanceof Re) {
if (r2 & st.ExcludeBuffers)
continue;
let u2 = c2.findChild(0, c2.buffer.length, e2, i2 - f2, n2);
if (u2 > -1)
return new ce(new td(o, c2, t2, f2), null, u2);
} else if (r2 & st.IncludeAnonymous || !c2.type.isAnonymous || er(c2)) {
let u2;
if (!(r2 & st.IgnoreMounts) && c2.props && (u2 = c2.prop(P$1.mounted)) && !u2.overlay)
return new Zt(u2.tree, f2, t2, o);
let d2 = new Zt(c2, f2, t2, o);
return r2 & st.IncludeAnonymous || !d2.type.isAnonymous ? d2 : d2.nextChild(e2 < 0 ? c2.children.length - 1 : 0, e2, i2, n2);
}
}
}
if (r2 & st.IncludeAnonymous || !o.type.isAnonymous || (o.index >= 0 ? t2 = o.index + e2 : t2 = e2 < 0 ? -1 : o._parent._tree.children.length, o = o._parent, !o))
return null;
}
}
get firstChild() {
return this.nextChild(
0,
1,
0,
4
/* Side.DontCare */
);
}
get lastChild() {
return this.nextChild(
this._tree.children.length - 1,
-1,
0,
4
/* Side.DontCare */
);
}
childAfter(t2) {
return this.nextChild(
0,
1,
t2,
2
/* Side.After */
);
}
childBefore(t2) {
return this.nextChild(
this._tree.children.length - 1,
-1,
t2,
-2
/* Side.Before */
);
}
enter(t2, e2, i2 = 0) {
let n2;
if (!(i2 & st.IgnoreOverlays) && (n2 = this._tree.prop(P$1.mounted)) && n2.overlay) {
let r2 = t2 - this.from;
for (let { from: o, to: l } of n2.overlay)
if ((e2 > 0 ? o <= r2 : o < r2) && (e2 < 0 ? l >= r2 : l > r2))
return new Zt(n2.tree, n2.overlay[0].from + this.from, -1, this);
}
return this.nextChild(0, 1, t2, e2, i2);
}
nextSignificantParent() {
let t2 = this;
for (; t2.type.isAnonymous && t2._parent; )
t2 = t2._parent;
return t2;
}
get parent() {
return this._parent ? this._parent.nextSignificantParent() : null;
}
get nextSibling() {
return this._parent && this.index >= 0 ? this._parent.nextChild(
this.index + 1,
1,
0,
4
/* Side.DontCare */
) : null;
}
get prevSibling() {
return this._parent && this.index >= 0 ? this._parent.nextChild(
this.index - 1,
-1,
0,
4
/* Side.DontCare */
) : null;
}
cursor(t2 = 0) {
return new fn(this, t2);
}
get tree() {
return this._tree;
}
toTree() {
return this._tree;
}
resolve(t2, e2 = 0) {
return Ue(this, t2, e2, false);
}
resolveInner(t2, e2 = 0) {
return Ue(this, t2, e2, true);
}
enterUnfinishedNodesBefore(t2) {
return fh(this, t2);
}
getChild(t2, e2 = null, i2 = null) {
let n2 = an(this, t2, e2, i2);
return n2.length ? n2[0] : null;
}
getChildren(t2, e2 = null, i2 = null) {
return an(this, t2, e2, i2);
}
/// @internal
toString() {
return this._tree.toString();
}
get node() {
return this;
}
matchContext(t2) {
return cn(this, t2);
}
}
function an(s, t2, e2, i2) {
let n2 = s.cursor(), r2 = [];
if (!n2.firstChild())
return r2;
if (e2 != null) {
for (; !n2.type.is(e2); )
if (!n2.nextSibling())
return r2;
}
for (; ; ) {
if (i2 != null && n2.type.is(i2))
return r2;
if (n2.type.is(t2) && r2.push(n2.node), !n2.nextSibling())
return i2 == null ? r2 : [];
}
}
function cn(s, t2, e2 = t2.length - 1) {
for (let i2 = s.parent; e2 >= 0; i2 = i2.parent) {
if (!i2)
return false;
if (!i2.type.isAnonymous) {
if (t2[e2] && t2[e2] != i2.name)
return false;
e2--;
}
}
return true;
}
class td {
constructor(t2, e2, i2, n2) {
this.parent = t2, this.buffer = e2, this.index = i2, this.start = n2;
}
}
class ce {
get name() {
return this.type.name;
}
get from() {
return this.context.start + this.context.buffer.buffer[this.index + 1];
}
get to() {
return this.context.start + this.context.buffer.buffer[this.index + 2];
}
constructor(t2, e2, i2) {
this.context = t2, this._parent = e2, this.index = i2, this.type = t2.buffer.set.types[t2.buffer.buffer[i2]];
}
child(t2, e2, i2) {
let { buffer: n2 } = this.context, r2 = n2.findChild(this.index + 4, n2.buffer[this.index + 3], t2, e2 - this.context.start, i2);
return r2 < 0 ? null : new ce(this.context, this, r2);
}
get firstChild() {
return this.child(
1,
0,
4
/* Side.DontCare */
);
}
get lastChild() {
return this.child(
-1,
0,
4
/* Side.DontCare */
);
}
childAfter(t2) {
return this.child(
1,
t2,
2
/* Side.After */
);
}
childBefore(t2) {
return this.child(
-1,
t2,
-2
/* Side.Before */
);
}
enter(t2, e2, i2 = 0) {
if (i2 & st.ExcludeBuffers)
return null;
let { buffer: n2 } = this.context, r2 = n2.findChild(this.index + 4, n2.buffer[this.index + 3], e2 > 0 ? 1 : -1, t2 - this.context.start, e2);
return r2 < 0 ? null : new ce(this.context, this, r2);
}
get parent() {
return this._parent || this.context.parent.nextSignificantParent();
}
externalSibling(t2) {
return this._parent ? null : this.context.parent.nextChild(
this.context.index + t2,
t2,
0,
4
/* Side.DontCare */
);
}
get nextSibling() {
let { buffer: t2 } = this.context, e2 = t2.buffer[this.index + 3];
return e2 < (this._parent ? t2.buffer[this._parent.index + 3] : t2.buffer.length) ? new ce(this.context, this._parent, e2) : this.externalSibling(1);
}
get prevSibling() {
let { buffer: t2 } = this.context, e2 = this._parent ? this._parent.index + 4 : 0;
return this.index == e2 ? this.externalSibling(-1) : new ce(this.context, this._parent, t2.findChild(
e2,
this.index,
-1,
0,
4
/* Side.DontCare */
));
}
cursor(t2 = 0) {
return new fn(this, t2);
}
get tree() {
return null;
}
toTree() {
let t2 = [], e2 = [], { buffer: i2 } = this.context, n2 = this.index + 4, r2 = i2.buffer[this.index + 3];
if (r2 > n2) {
let o = i2.buffer[this.index + 1];
t2.push(i2.slice(n2, r2, o)), e2.push(0);
}
return new J$1(this.type, t2, e2, this.to - this.from);
}
resolve(t2, e2 = 0) {
return Ue(this, t2, e2, false);
}
resolveInner(t2, e2 = 0) {
return Ue(this, t2, e2, true);
}
enterUnfinishedNodesBefore(t2) {
return fh(this, t2);
}
/// @internal
toString() {
return this.context.buffer.childString(this.index);
}
getChild(t2, e2 = null, i2 = null) {
let n2 = an(this, t2, e2, i2);
return n2.length ? n2[0] : null;
}
getChildren(t2, e2 = null, i2 = null) {
return an(this, t2, e2, i2);
}
get node() {
return this;
}
matchContext(t2) {
return cn(this, t2);
}
}
class fn {
/// Shorthand for `.type.name`.
get name() {
return this.type.name;
}
/// @internal
constructor(t2, e2 = 0) {
if (this.mode = e2, this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, t2 instanceof Zt)
this.yieldNode(t2);
else {
this._tree = t2.context.parent, this.buffer = t2.context;
for (let i2 = t2._parent; i2; i2 = i2._parent)
this.stack.unshift(i2.index);
this.bufferNode = t2, this.yieldBuf(t2.index);
}
}
yieldNode(t2) {
return t2 ? (this._tree = t2, this.type = t2.type, this.from = t2.from, this.to = t2.to, true) : false;
}
yieldBuf(t2, e2) {
this.index = t2;
let { start: i2, buffer: n2 } = this.buffer;
return this.type = e2 || n2.set.types[n2.buffer[t2]], this.from = i2 + n2.buffer[t2 + 1], this.to = i2 + n2.buffer[t2 + 2], true;
}
yield(t2) {
return t2 ? t2 instanceof Zt ? (this.buffer = null, this.yieldNode(t2)) : (this.buffer = t2.context, this.yieldBuf(t2.index, t2.type)) : false;
}
/// @internal
toString() {
return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
}
/// @internal
enterChild(t2, e2, i2) {
if (!this.buffer)
return this.yield(this._tree.nextChild(t2 < 0 ? this._tree._tree.children.length - 1 : 0, t2, e2, i2, this.mode));
let { buffer: n2 } = this.buffer, r2 = n2.findChild(this.index + 4, n2.buffer[this.index + 3], t2, e2 - this.buffer.start, i2);
return r2 < 0 ? false : (this.stack.push(this.index), this.yieldBuf(r2));
}
/// Move the cursor to this node's first child. When this returns
/// false, the node has no child, and the cursor has not been moved.
firstChild() {
return this.enterChild(
1,
0,
4
/* Side.DontCare */
);
}
/// Move the cursor to this node's last child.
lastChild() {
return this.enterChild(
-1,
0,
4
/* Side.DontCare */
);
}
/// Move the cursor to the first child that ends after `pos`.
childAfter(t2) {
return this.enterChild(
1,
t2,
2
/* Side.After */
);
}
/// Move to the last child that starts before `pos`.
childBefore(t2) {
return this.enterChild(
-1,
t2,
-2
/* Side.Before */
);
}
/// Move the cursor to the child around `pos`. If side is -1 the
/// child may end at that position, when 1 it may start there. This
/// will also enter [overlaid](#common.MountedTree.overlay)
/// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
/// set to false.
enter(t2, e2, i2 = this.mode) {
return this.buffer ? i2 & st.ExcludeBuffers ? false : this.enterChild(1, t2, e2) : this.yield(this._tree.enter(t2, e2, i2));
}
/// Move to the node's parent node, if this isn't the top node.
parent() {
if (!this.buffer)
return this.yieldNode(this.mode & st.IncludeAnonymous ? this._tree._parent : this._tree.parent);
if (this.stack.length)
return this.yieldBuf(this.stack.pop());
let t2 = this.mode & st.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
return this.buffer = null, this.yieldNode(t2);
}
/// @internal
sibling(t2) {
if (!this.buffer)
return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + t2, t2, 0, 4, this.mode)) : false;
let { buffer: e2 } = this.buffer, i2 = this.stack.length - 1;
if (t2 < 0) {
let n2 = i2 < 0 ? 0 : this.stack[i2] + 4;
if (this.index != n2)
return this.yieldBuf(e2.findChild(
n2,
this.index,
-1,
0,
4
/* Side.DontCare */
));
} else {
let n2 = e2.buffer[this.index + 3];
if (n2 < (i2 < 0 ? e2.buffer.length : e2.buffer[this.stack[i2] + 3]))
return this.yieldBuf(n2);
}
return i2 < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + t2, t2, 0, 4, this.mode)) : false;
}
/// Move to this node's next sibling, if any.
nextSibling() {
return this.sibling(1);
}
/// Move to this node's previous sibling, if any.
prevSibling() {
return this.sibling(-1);
}
atLastNode(t2) {
let e2, i2, { buffer: n2 } = this;
if (n2) {
if (t2 > 0) {
if (this.index < n2.buffer.buffer.length)
return false;
} else
for (let r2 = 0; r2 < this.index; r2++)
if (n2.buffer.buffer[r2 + 3] < this.index)
return false;
({ index: e2, parent: i2 } = n2);
} else
({ index: e2, _parent: i2 } = this._tree);
for (; i2; { index: e2, _parent: i2 } = i2)
if (e2 > -1)
for (let r2 = e2 + t2, o = t2 < 0 ? -1 : i2._tree.children.length; r2 != o; r2 += t2) {
let l = i2._tree.children[r2];
if (this.mode & st.IncludeAnonymous || l instanceof Re || !l.type.isAnonymous || er(l))
return false;
}
return true;
}
move(t2, e2) {
if (e2 && this.enterChild(
t2,
0,
4
/* Side.DontCare */
))
return true;
for (; ; ) {
if (this.sibling(t2))
return true;
if (this.atLastNode(t2) || !this.parent())
return false;
}
}
/// Move to the next node in a
/// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
/// traversal, going from a node to its first child or, if the
/// current node is empty or `enter` is false, its next sibling or
/// the next sibling of the first parent node that has one.
next(t2 = true) {
return this.move(1, t2);
}
/// Move to the next node in a last-to-first pre-order traveral. A
/// node is followed by its last child or, if it has none, its
/// previous sibling or the previous sibling of the first parent
/// node that has one.
prev(t2 = true) {
return this.move(-1, t2);
}
/// Move the cursor to the innermost node that covers `pos`. If
/// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
/// it will enter nodes that start at `pos`.
moveTo(t2, e2 = 0) {
for (; (this.from == this.to || (e2 < 1 ? this.from >= t2 : this.from > t2) || (e2 > -1 ? this.to <= t2 : this.to < t2)) && this.parent(); )
;
for (; this.enterChild(1, t2, e2); )
;
return this;
}
/// Get a [syntax node](#common.SyntaxNode) at the cursor's current
/// position.
get node() {
if (!this.buffer)
return this._tree;
let t2 = this.bufferNode, e2 = null, i2 = 0;
if (t2 && t2.context == this.buffer) {
t:
for (let n2 = this.index, r2 = this.stack.length; r2 >= 0; ) {
for (let o = t2; o; o = o._parent)
if (o.index == n2) {
if (n2 == this.index)
return o;
e2 = o, i2 = r2 + 1;
break t;
}
n2 = this.stack[--r2];
}
}
for (let n2 = i2; n2 < this.stack.length; n2++)
e2 = new ce(this.buffer, e2, this.stack[n2]);
return this.bufferNode = new ce(this.buffer, e2, this.index);
}
/// Get the [tree](#common.Tree) that represents the current node, if
/// any. Will return null when the node is in a [tree
/// buffer](#common.TreeBuffer).
get tree() {
return this.buffer ? null : this._tree._tree;
}
/// Iterate over the current node and all its descendants, calling
/// `enter` when entering a node and `leave`, if given, when leaving
/// one. When `enter` returns `false`, any children of that node are
/// skipped, and `leave` isn't called for it.
iterate(t2, e2) {
for (let i2 = 0; ; ) {
let n2 = false;
if (this.type.isAnonymous || t2(this) !== false) {
if (this.firstChild()) {
i2++;
continue;
}
this.type.isAnonymous || (n2 = true);
}
for (; n2 && e2 && e2(this), n2 = this.type.isAnonymous, !this.nextSibling(); ) {
if (!i2)
return;
this.parent(), i2--, n2 = true;
}
}
}
/// Test whether the current node matches a given context—a sequence
/// of direct parent node names. Empty strings in the context array
/// are treated as wildcards.
matchContext(t2) {
if (!this.buffer)
return cn(this.node, t2);
let { buffer: e2 } = this.buffer, { types: i2 } = e2.set;
for (let n2 = t2.length - 1, r2 = this.stack.length - 1; n2 >= 0; r2--) {
if (r2 < 0)
return cn(this.node, t2, n2);
let o = i2[e2.buffer[this.stack[r2]]];
if (!o.isAnonymous) {
if (t2[n2] && t2[n2] != o.name)
return false;
n2--;
}
}
return true;
}
}
function er(s) {
return s.children.some((t2) => t2 instanceof Re || !t2.type.isAnonymous || er(t2));
}
function ed(s) {
var t2;
let { buffer: e2, nodeSet: i2, maxBufferLength: n2 = ah, reused: r2 = [], minRepeatType: o = i2.types.length } = s, l = Array.isArray(e2) ? new tr(e2, e2.length) : e2, h2 = i2.types, a2 = 0, c2 = 0;
function f2(D2, B3, M2, V2, et) {
let { id: I2, start: L2, end: K2, size: pt } = l, Ot = c2;
for (; pt < 0; )
if (l.next(), pt == -1) {
let ie = r2[I2];
M2.push(ie), V2.push(L2 - D2);
return;
} else if (pt == -3) {
a2 = I2;
return;
} else if (pt == -4) {
c2 = I2;
return;
} else
throw new RangeError(`Unrecognized record size: ${pt}`);
let Le = h2[I2], ee, Gt, fr = L2 - D2;
if (K2 - L2 <= n2 && (Gt = w2(l.pos - B3, et))) {
let ie = new Uint16Array(Gt.size - Gt.skip), Mt = l.pos - Gt.size, Ut = ie.length;
for (; l.pos > Mt; )
Ut = g(Gt.start, ie, Ut);
ee = new Re(ie, K2 - Gt.start, i2), fr = Gt.start - D2;
} else {
let ie = l.pos - pt;
l.next();
let Mt = [], Ut = [], ke = I2 >= o ? I2 : -1, Ee = 0, Si = K2;
for (; l.pos > ie; )
ke >= 0 && l.id == ke && l.size >= 0 ? (l.end <= Si - n2 && (d2(Mt, Ut, L2, Ee, l.end, Si, ke, Ot), Ee = Mt.length, Si = l.end), l.next()) : f2(L2, ie, Mt, Ut, ke);
if (ke >= 0 && Ee > 0 && Ee < Mt.length && d2(Mt, Ut, L2, Ee, L2, Si, ke, Ot), Mt.reverse(), Ut.reverse(), ke > -1 && Ee > 0) {
let ur = u2(Le);
ee = ir(Le, Mt, Ut, 0, Mt.length, 0, K2 - L2, ur, ur);
} else
ee = p2(Le, Mt, Ut, K2 - L2, Ot - K2);
}
M2.push(ee), V2.push(fr);
}
function u2(D2) {
return (B3, M2, V2) => {
let et = 0, I2 = B3.length - 1, L2, K2;
if (I2 >= 0 && (L2 = B3[I2]) instanceof J$1) {
if (!I2 && L2.type == D2 && L2.length == V2)
return L2;
(K2 = L2.prop(P$1.lookAhead)) && (et = M2[I2] + L2.length + K2);
}
return p2(D2, B3, M2, V2, et);
};
}
function d2(D2, B3, M2, V2, et, I2, L2, K2) {
let pt = [], Ot = [];
for (; D2.length > V2; )
pt.push(D2.pop()), Ot.push(B3.pop() + M2 - et);
D2.push(p2(i2.types[L2], pt, Ot, I2 - et, K2 - I2)), B3.push(et - M2);
}
function p2(D2, B3, M2, V2, et = 0, I2) {
if (a2) {
let L2 = [P$1.contextHash, a2];
I2 = I2 ? [L2].concat(I2) : [L2];
}
if (et > 25) {
let L2 = [P$1.lookAhead, et];
I2 = I2 ? [L2].concat(I2) : [L2];
}
return new J$1(D2, B3, M2, V2, I2);
}
function w2(D2, B3) {
let M2 = l.fork(), V2 = 0, et = 0, I2 = 0, L2 = M2.end - n2, K2 = { size: 0, start: 0, skip: 0 };
t:
for (let pt = M2.pos - D2; M2.pos > pt; ) {
let Ot = M2.size;
if (M2.id == B3 && Ot >= 0) {
K2.size = V2, K2.start = et, K2.skip = I2, I2 += 4, V2 += 4, M2.next();
continue;
}
let Le = M2.pos - Ot;
if (Ot < 0 || Le < pt || M2.start < L2)
break;
let ee = M2.id >= o ? 4 : 0, Gt = M2.start;
for (M2.next(); M2.pos > Le; ) {
if (M2.size < 0)
if (M2.size == -3)
ee += 4;
else
break t;
else
M2.id >= o && (ee += 4);
M2.next();
}
et = Gt, V2 += Ot, I2 += ee;
}
return (B3 < 0 || V2 == D2) && (K2.size = V2, K2.start = et, K2.skip = I2), K2.size > 4 ? K2 : void 0;
}
function g(D2, B3, M2) {
let { id: V2, start: et, end: I2, size: L2 } = l;
if (l.next(), L2 >= 0 && V2 < o) {
let K2 = M2;
if (L2 > 4) {
let pt = l.pos - (L2 - 4);
for (; l.pos > pt; )
M2 = g(D2, B3, M2);
}
B3[--M2] = K2, B3[--M2] = I2 - D2, B3[--M2] = et - D2, B3[--M2] = V2;
} else
L2 == -3 ? a2 = V2 : L2 == -4 && (c2 = V2);
return M2;
}
let y2 = [], O2 = [];
for (; l.pos > 0; )
f2(s.start || 0, s.bufferStart || 0, y2, O2, -1);
let S2 = (t2 = s.length) !== null && t2 !== void 0 ? t2 : y2.length ? O2[0] + y2[0].length : 0;
return new J$1(h2[s.topID], y2.reverse(), O2.reverse(), S2);
}
const fo = /* @__PURE__ */ new WeakMap();
function Qi(s, t2) {
if (!s.isAnonymous || t2 instanceof Re || t2.type != s)
return 1;
let e2 = fo.get(t2);
if (e2 == null) {
e2 = 1;
for (let i2 of t2.children) {
if (i2.type != s || !(i2 instanceof J$1)) {
e2 = 1;
break;
}
e2 += Qi(s, i2);
}
fo.set(t2, e2);
}
return e2;
}
function ir(s, t2, e2, i2, n2, r2, o, l, h2) {
let a2 = 0;
for (let p2 = i2; p2 < n2; p2++)
a2 += Qi(s, t2[p2]);
let c2 = Math.ceil(
a2 * 1.5 / 8
/* Balance.BranchFactor */
), f2 = [], u2 = [];
function d2(p2, w2, g, y2, O2) {
for (let S2 = g; S2 < y2; ) {
let D2 = S2, B3 = w2[S2], M2 = Qi(s, p2[S2]);
for (S2++; S2 < y2; S2++) {
let V2 = Qi(s, p2[S2]);
if (M2 + V2 >= c2)
break;
M2 += V2;
}
if (S2 == D2 + 1) {
if (M2 > c2) {
let V2 = p2[D2];
d2(V2.children, V2.positions, 0, V2.children.length, w2[D2] + O2);
continue;
}
f2.push(p2[D2]);
} else {
let V2 = w2[S2 - 1] + p2[S2 - 1].length - B3;
f2.push(ir(s, p2, w2, D2, S2, B3, V2, null, h2));
}
u2.push(B3 + O2 - r2);
}
}
return d2(t2, e2, i2, n2, 0), (l || h2)(f2, u2, o);
}
class Oe {
/// Construct a tree fragment. You'll usually want to use
/// [`addTree`](#common.TreeFragment^addTree) and
/// [`applyChanges`](#common.TreeFragment^applyChanges) instead of
/// calling this directly.
constructor(t2, e2, i2, n2, r2 = false, o = false) {
this.from = t2, this.to = e2, this.tree = i2, this.offset = n2, this.open = (r2 ? 1 : 0) | (o ? 2 : 0);
}
/// Whether the start of the fragment represents the start of a
/// parse, or the end of a change. (In the second case, it may not
/// be safe to reuse some nodes at the start, depending on the
/// parsing algorithm.)
get openStart() {
return (this.open & 1) > 0;
}
/// Whether the end of the fragment represents the end of a
/// full-document parse, or the start of a change.
get openEnd() {
return (this.open & 2) > 0;
}
/// Create a set of fragments from a freshly parsed tree, or update
/// an existing set of fragments by replacing the ones that overlap
/// with a tree with content from the new tree. When `partial` is
/// true, the parse is treated as incomplete, and the resulting
/// fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
/// true.
static addTree(t2, e2 = [], i2 = false) {
let n2 = [new Oe(0, t2.length, t2, 0, false, i2)];
for (let r2 of e2)
r2.to > t2.length && n2.push(r2);
return n2;
}
/// Apply a set of edits to an array of fragments, removing or
/// splitting fragments as necessary to remove edited ranges, and
/// adjusting offsets for fragments that moved.
static applyChanges(t2, e2, i2 = 128) {
if (!e2.length)
return t2;
let n2 = [], r2 = 1, o = t2.length ? t2[0] : null;
for (let l = 0, h2 = 0, a2 = 0; ; l++) {
let c2 = l < e2.length ? e2[l] : null, f2 = c2 ? c2.fromA : 1e9;
if (f2 - h2 >= i2)
for (; o && o.from < f2; ) {
let u2 = o;
if (h2 >= u2.from || f2 <= u2.to || a2) {
let d2 = Math.max(u2.from, h2) - a2, p2 = Math.min(u2.to, f2) - a2;
u2 = d2 >= p2 ? null : new Oe(d2, p2, u2.tree, u2.offset + a2, l > 0, !!c2);
}
if (u2 && n2.push(u2), o.to > f2)
break;
o = r2 < t2.length ? t2[r2++] : null;
}
if (!c2)
break;
h2 = c2.toA, a2 = c2.toA - c2.toB;
}
return n2;
}
}
class uh {
/// Start a parse, returning a [partial parse](#common.PartialParse)
/// object. [`fragments`](#common.TreeFragment) can be passed in to
/// make the parse incremental.
///
/// By default, the entire input is parsed. You can pass `ranges`,
/// which should be a sorted array of non-empty, non-overlapping
/// ranges, to parse only those ranges. The tree returned in that
/// case will start at `ranges[0].from`.
startParse(t2, e2, i2) {
return typeof t2 == "string" && (t2 = new id(t2)), i2 = i2 ? i2.length ? i2.map((n2) => new qn(n2.from, n2.to)) : [new qn(0, 0)] : [new qn(0, t2.length)], this.createParse(t2, e2 || [], i2);
}
/// Run a full parse, returning the resulting tree.
parse(t2, e2, i2) {
let n2 = this.startParse(t2, e2, i2);
for (; ; ) {
let r2 = n2.advance();
if (r2)
return r2;
}
}
}
class id {
constructor(t2) {
this.string = t2;
}
get length() {
return this.string.length;
}
chunk(t2) {
return this.string.slice(t2);
}
get lineChunks() {
return false;
}
read(t2, e2) {
return this.string.slice(t2, e2);
}
}
new P$1({ perNode: true });
let nd = 0;
class It {
/// @internal
constructor(t2, e2, i2) {
this.set = t2, this.base = e2, this.modified = i2, this.id = nd++;
}
/// Define a new tag. If `parent` is given, the tag is treated as a
/// sub-tag of that parent, and
/// [highlighters](#highlight.tagHighlighter) that don't mention
/// this tag will try to fall back to the parent tag (or grandparent
/// tag, etc).
static define(t2) {
if (t2 != null && t2.base)
throw new Error("Can not derive from a modified tag");
let e2 = new It([], null, []);
if (e2.set.push(e2), t2)
for (let i2 of t2.set)
e2.set.push(i2);
return e2;
}
/// Define a tag _modifier_, which is a function that, given a tag,
/// will return a tag that is a subtag of the original. Applying the
/// same modifier to a twice tag will return the same value (`m1(t1)
/// == m1(t1)`) and applying multiple modifiers will, regardless or
/// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
///
/// When multiple modifiers are applied to a given base tag, each
/// smaller set of modifiers is registered as a parent, so that for
/// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
/// `m1(m3(t1)`, and so on.
static defineModifier() {
let t2 = new un();
return (e2) => e2.modified.indexOf(t2) > -1 ? e2 : un.get(e2.base || e2, e2.modified.concat(t2).sort((i2, n2) => i2.id - n2.id));
}
}
let sd = 0;
class un {
constructor() {
this.instances = [], this.id = sd++;
}
static get(t2, e2) {
if (!e2.length)
return t2;
let i2 = e2[0].instances.find((l) => l.base == t2 && rd(e2, l.modified));
if (i2)
return i2;
let n2 = [], r2 = new It(n2, t2, e2);
for (let l of e2)
l.instances.push(r2);
let o = od(e2);
for (let l of t2.set)
if (!l.modified.length)
for (let h2 of o)
n2.push(un.get(l, h2));
return r2;
}
}
function rd(s, t2) {
return s.length == t2.length && s.every((e2, i2) => e2 == t2[i2]);
}
function od(s) {
let t2 = [[]];
for (let e2 = 0; e2 < s.length; e2++)
for (let i2 = 0, n2 = t2.length; i2 < n2; i2++)
t2.push(t2[i2].concat(s[e2]));
return t2.sort((e2, i2) => i2.length - e2.length);
}
function dh(s) {
let t2 = /* @__PURE__ */ Object.create(null);
for (let e2 in s) {
let i2 = s[e2];
Array.isArray(i2) || (i2 = [i2]);
for (let n2 of e2.split(" "))
if (n2) {
let r2 = [], o = 2, l = n2;
for (let f2 = 0; ; ) {
if (l == "..." && f2 > 0 && f2 + 3 == n2.length) {
o = 1;
break;
}
let u2 = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);
if (!u2)
throw new RangeError("Invalid path: " + n2);
if (r2.push(u2[0] == "*" ? "" : u2[0][0] == '"' ? JSON.parse(u2[0]) : u2[0]), f2 += u2[0].length, f2 == n2.length)
break;
let d2 = n2[f2++];
if (f2 == n2.length && d2 == "!") {
o = 0;
break;
}
if (d2 != "/")
throw new RangeError("Invalid path: " + n2);
l = n2.slice(f2);
}
let h2 = r2.length - 1, a2 = r2[h2];
if (!a2)
throw new RangeError("Invalid path: " + n2);
let c2 = new dn(i2, o, h2 > 0 ? r2.slice(0, h2) : null);
t2[a2] = c2.sort(t2[a2]);
}
}
return ph.add(t2);
}
const ph = new P$1();
class dn {
constructor(t2, e2, i2, n2) {
this.tags = t2, this.mode = e2, this.context = i2, this.next = n2;
}
get opaque() {
return this.mode == 0;
}
get inherit() {
return this.mode == 1;
}
sort(t2) {
return !t2 || t2.depth < this.depth ? (this.next = t2, this) : (t2.next = this.sort(t2.next), t2);
}
get depth() {
return this.context ? this.context.length : 0;
}
}
dn.empty = new dn([], 2, null);
function gh(s, t2) {
let e2 = /* @__PURE__ */ Object.create(null);
for (let r2 of s)
if (!Array.isArray(r2.tag))
e2[r2.tag.id] = r2.class;
else
for (let o of r2.tag)
e2[o.id] = r2.class;
let { scope: i2, all: n2 = null } = t2 || {};
return {
style: (r2) => {
let o = n2;
for (let l of r2)
for (let h2 of l.set) {
let a2 = e2[h2.id];
if (a2) {
o = o ? o + " " + a2 : a2;
break;
}
}
return o;
},
scope: i2
};
}
function ld(s, t2) {
let e2 = null;
for (let i2 of s) {
let n2 = i2.style(t2);
n2 && (e2 = e2 ? e2 + " " + n2 : n2);
}
return e2;
}
function hd(s, t2, e2, i2 = 0, n2 = s.length) {
let r2 = new ad(i2, Array.isArray(t2) ? t2 : [t2], e2);
r2.highlightRange(s.cursor(), i2, n2, "", r2.highlighters), r2.flush(n2);
}
class ad {
constructor(t2, e2, i2) {
this.at = t2, this.highlighters = e2, this.span = i2, this.class = "";
}
startSpan(t2, e2) {
e2 != this.class && (this.flush(t2), t2 > this.at && (this.at = t2), this.class = e2);
}
flush(t2) {
t2 > this.at && this.class && this.span(this.at, t2, this.class);
}
highlightRange(t2, e2, i2, n2, r2) {
let { type: o, from: l, to: h2 } = t2;
if (l >= i2 || h2 <= e2)
return;
o.isTop && (r2 = this.highlighters.filter((d2) => !d2.scope || d2.scope(o)));
let a2 = n2, c2 = cd(t2) || dn.empty, f2 = ld(r2, c2.tags);
if (f2 && (a2 && (a2 += " "), a2 += f2, c2.mode == 1 && (n2 += (n2 ? " " : "") + f2)), this.startSpan(t2.from, a2), c2.opaque)
return;
let u2 = t2.tree && t2.tree.prop(P$1.mounted);
if (u2 && u2.overlay) {
let d2 = t2.node.enter(u2.overlay[0].from + l, 1), p2 = this.highlighters.filter((g) => !g.scope || g.scope(u2.tree.type)), w2 = t2.firstChild();
for (let g = 0, y2 = l; ; g++) {
let O2 = g < u2.overlay.length ? u2.overlay[g] : null, S2 = O2 ? O2.from + l : h2, D2 = Math.max(e2, y2), B3 = Math.min(i2, S2);
if (D2 < B3 && w2)
for (; t2.from < B3 && (this.highlightRange(t2, D2, B3, n2, r2), this.startSpan(Math.min(B3, t2.to), a2), !(t2.to >= S2 || !t2.nextSibling())); )
;
if (!O2 || S2 > i2)
break;
y2 = O2.to + l, y2 > e2 && (this.highlightRange(d2.cursor(), Math.max(e2, O2.from + l), Math.min(i2, y2), n2, p2), this.startSpan(y2, a2));
}
w2 && t2.parent();
} else if (t2.firstChild()) {
do
if (!(t2.to <= e2)) {
if (t2.from >= i2)
break;
this.highlightRange(t2, e2, i2, n2, r2), this.startSpan(Math.min(i2, t2.to), a2);
}
while (t2.nextSibling());
t2.parent();
}
}
}
function cd(s) {
let t2 = s.type.prop(ph);
for (; t2 && t2.context && !s.matchContext(t2.context); )
t2 = t2.next;
return t2 || null;
}
const k$1 = It.define, Ii = k$1(), ne = k$1(), uo = k$1(ne), po = k$1(ne), se = k$1(), Hi = k$1(se), Kn = k$1(se), Vt = k$1(), xe = k$1(Vt), Et = k$1(), Nt = k$1(), Es = k$1(), ei = k$1(Es), $i = k$1(), m$1 = {
/// A comment.
comment: Ii,
/// A line [comment](#highlight.tags.comment).
lineComment: k$1(Ii),
/// A block [comment](#highlight.tags.comment).
blockComment: k$1(Ii),
/// A documentation [comment](#highlight.tags.comment).
docComment: k$1(Ii),
/// Any kind of identifier.
name: ne,
/// The [name](#highlight.tags.name) of a variable.
variableName: k$1(ne),
/// A type [name](#highlight.tags.name).
typeName: uo,
/// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
tagName: k$1(uo),
/// A property or field [name](#highlight.tags.name).
propertyName: po,
/// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
attributeName: k$1(po),
/// The [name](#highlight.tags.name) of a class.
className: k$1(ne),
/// A label [name](#highlight.tags.name).
labelName: k$1(ne),
/// A namespace [name](#highlight.tags.name).
namespace: k$1(ne),
/// The [name](#highlight.tags.name) of a macro.
macroName: k$1(ne),
/// A literal value.
literal: se,
/// A string [literal](#highlight.tags.literal).
string: Hi,
/// A documentation [string](#highlight.tags.string).
docString: k$1(Hi),
/// A character literal (subtag of [string](#highlight.tags.string)).
character: k$1(Hi),
/// An attribute value (subtag of [string](#highlight.tags.string)).
attributeValue: k$1(Hi),
/// A number [literal](#highlight.tags.literal).
number: Kn,
/// An integer [number](#highlight.tags.number) literal.
integer: k$1(Kn),
/// A floating-point [number](#highlight.tags.number) literal.
float: k$1(Kn),
/// A boolean [literal](#highlight.tags.literal).
bool: k$1(se),
/// Regular expression [literal](#highlight.tags.literal).
regexp: k$1(se),
/// An escape [literal](#highlight.tags.literal), for example a
/// backslash escape in a string.
escape: k$1(se),
/// A color [literal](#highlight.tags.literal).
color: k$1(se),
/// A URL [literal](#highlight.tags.literal).
url: k$1(se),
/// A language keyword.
keyword: Et,
/// The [keyword](#highlight.tags.keyword) for the self or this
/// object.
self: k$1(Et),
/// The [keyword](#highlight.tags.keyword) for null.
null: k$1(Et),
/// A [keyword](#highlight.tags.keyword) denoting some atomic value.
atom: k$1(Et),
/// A [keyword](#highlight.tags.keyword) that represents a unit.
unit: k$1(Et),
/// A modifier [keyword](#highlight.tags.keyword).
modifier: k$1(Et),
/// A [keyword](#highlight.tags.keyword) that acts as an operator.
operatorKeyword: k$1(Et),
/// A control-flow related [keyword](#highlight.tags.keyword).
controlKeyword: k$1(Et),
/// A [keyword](#highlight.tags.keyword) that defines something.
definitionKeyword: k$1(Et),
/// A [keyword](#highlight.tags.keyword) related to defining or
/// interfacing with modules.
moduleKeyword: k$1(Et),
/// An operator.
operator: Nt,
/// An [operator](#highlight.tags.operator) that dereferences something.
derefOperator: k$1(Nt),
/// Arithmetic-related [operator](#highlight.tags.operator).
arithmeticOperator: k$1(Nt),
/// Logical [operator](#highlight.tags.operator).
logicOperator: k$1(Nt),
/// Bit [operator](#highlight.tags.operator).
bitwiseOperator: k$1(Nt),
/// Comparison [operator](#highlight.tags.operator).
compareOperator: k$1(Nt),
/// [Operator](#highlight.tags.operator) that updates its operand.
updateOperator: k$1(Nt),
/// [Operator](#highlight.tags.operator) that defines something.
definitionOperator: k$1(Nt),
/// Type-related [operator](#highlight.tags.operator).
typeOperator: k$1(Nt),
/// Control-flow [operator](#highlight.tags.operator).
controlOperator: k$1(Nt),
/// Program or markup punctuation.
punctuation: Es,
/// [Punctuation](#highlight.tags.punctuation) that separates
/// things.
separator: k$1(Es),
/// Bracket-style [punctuation](#highlight.tags.punctuation).
bracket: ei,
/// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
/// tokens).
angleBracket: k$1(ei),
/// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
/// tokens).
squareBracket: k$1(ei),
/// Parentheses (usually `(` and `)` tokens). Subtag of
/// [bracket](#highlight.tags.bracket).
paren: k$1(ei),
/// Braces (usually `{` and `}` tokens). Subtag of
/// [bracket](#highlight.tags.bracket).
brace: k$1(ei),
/// Content, for example plain text in XML or markup documents.
content: Vt,
/// [Content](#highlight.tags.content) that represents a heading.
heading: xe,
/// A level 1 [heading](#highlight.tags.heading).
heading1: k$1(xe),
/// A level 2 [heading](#highlight.tags.heading).
heading2: k$1(xe),
/// A level 3 [heading](#highlight.tags.heading).
heading3: k$1(xe),
/// A level 4 [heading](#highlight.tags.heading).
heading4: k$1(xe),
/// A level 5 [heading](#highlight.tags.heading).
heading5: k$1(xe),
/// A level 6 [heading](#highlight.tags.heading).
heading6: k$1(xe),
/// A prose separator (such as a horizontal rule).
contentSeparator: k$1(Vt),
/// [Content](#highlight.tags.content) that represents a list.
list: k$1(Vt),
/// [Content](#highlight.tags.content) that represents a quote.
quote: k$1(Vt),
/// [Content](#highlight.tags.content) that is emphasized.
emphasis: k$1(Vt),
/// [Content](#highlight.tags.content) that is styled strong.
strong: k$1(Vt),
/// [Content](#highlight.tags.content) that is part of a link.
link: k$1(Vt),
/// [Content](#highlight.tags.content) that is styled as code or
/// monospace.
monospace: k$1(Vt),
/// [Content](#highlight.tags.content) that has a strike-through
/// style.
strikethrough: k$1(Vt),
/// Inserted text in a change-tracking format.
inserted: k$1(),
/// Deleted text.
deleted: k$1(),
/// Changed text.
changed: k$1(),
/// An invalid or unsyntactic element.
invalid: k$1(),
/// Metadata or meta-instruction.
meta: $i,
/// [Metadata](#highlight.tags.meta) that applies to the entire
/// document.
documentMeta: k$1($i),
/// [Metadata](#highlight.tags.meta) that annotates or adds
/// attributes to a given syntactic element.
annotation: k$1($i),
/// Processing instruction or preprocessor directive. Subtag of
/// [meta](#highlight.tags.meta).
processingInstruction: k$1($i),
/// [Modifier](#highlight.Tag^defineModifier) that indicates that a
/// given element is being defined. Expected to be used with the
/// various [name](#highlight.tags.name) tags.
definition: It.defineModifier(),
/// [Modifier](#highlight.Tag^defineModifier) that indicates that
/// something is constant. Mostly expected to be used with
/// [variable names](#highlight.tags.variableName).
constant: It.defineModifier(),
/// [Modifier](#highlight.Tag^defineModifier) used to indicate that
/// a [variable](#highlight.tags.variableName) or [property
/// name](#highlight.tags.propertyName) is being called or defined
/// as a function.
function: It.defineModifier(),
/// [Modifier](#highlight.Tag^defineModifier) that can be applied to
/// [names](#highlight.tags.name) to indicate that they belong to
/// the language's standard environment.
standard: It.defineModifier(),
/// [Modifier](#highlight.Tag^defineModifier) that indicates a given
/// [names](#highlight.tags.name) is local to some scope.
local: It.defineModifier(),
/// A generic variant [modifier](#highlight.Tag^defineModifier) that
/// can be used to tag language-specific alternative variants of
/// some common tag. It is recommended for themes to define special
/// forms of at least the [string](#highlight.tags.string) and
/// [variable name](#highlight.tags.variableName) tags, since those
/// come up a lot.
special: It.defineModifier()
};
gh([
{ tag: m$1.link, class: "tok-link" },
{ tag: m$1.heading, class: "tok-heading" },
{ tag: m$1.emphasis, class: "tok-emphasis" },
{ tag: m$1.strong, class: "tok-strong" },
{ tag: m$1.keyword, class: "tok-keyword" },
{ tag: m$1.atom, class: "tok-atom" },
{ tag: m$1.bool, class: "tok-bool" },
{ tag: m$1.url, class: "tok-url" },
{ tag: m$1.labelName, class: "tok-labelName" },
{ tag: m$1.inserted, class: "tok-inserted" },
{ tag: m$1.deleted, class: "tok-deleted" },
{ tag: m$1.literal, class: "tok-literal" },
{ tag: m$1.string, class: "tok-string" },
{ tag: m$1.number, class: "tok-number" },
{ tag: [m$1.regexp, m$1.escape, m$1.special(m$1.string)], class: "tok-string2" },
{ tag: m$1.variableName, class: "tok-variableName" },
{ tag: m$1.local(m$1.variableName), class: "tok-variableName tok-local" },
{ tag: m$1.definition(m$1.variableName), class: "tok-variableName tok-definition" },
{ tag: m$1.special(m$1.variableName), class: "tok-variableName2" },
{ tag: m$1.definition(m$1.propertyName), class: "tok-propertyName tok-definition" },
{ tag: m$1.typeName, class: "tok-typeName" },
{ tag: m$1.namespace, class: "tok-namespace" },
{ tag: m$1.className, class: "tok-className" },
{ tag: m$1.macroName, class: "tok-macroName" },
{ tag: m$1.propertyName, class: "tok-propertyName" },
{ tag: m$1.operator, class: "tok-operator" },
{ tag: m$1.comment, class: "tok-comment" },
{ tag: m$1.meta, class: "tok-meta" },
{ tag: m$1.invalid, class: "tok-invalid" },
{ tag: m$1.punctuation, class: "tok-punctuation" }
]);
var Gn;
const mi = /* @__PURE__ */ new P$1();
function fd(s) {
return v.define({
combine: s ? (t2) => t2.concat(s) : void 0
});
}
class Tt {
/**
Construct a language object. If you need to invoke this
directly, first define a data facet with
[`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
to the language's outer syntax node.
*/
constructor(t2, e2, i2 = [], n2 = "") {
this.data = t2, this.name = n2, N$2.prototype.hasOwnProperty("tree") || Object.defineProperty(N$2.prototype, "tree", { get() {
return St(this);
} }), this.parser = e2, this.extension = [
we.of(this),
N$2.languageData.of((r2, o, l) => r2.facet(go(r2, o, l)))
].concat(i2);
}
/**
Query whether this language is active at the given position.
*/
isActiveAt(t2, e2, i2 = -1) {
return go(t2, e2, i2) == this.data;
}
/**
Find the document regions that were parsed using this language.
The returned regions will _include_ any nested languages rooted
in this language, when those exist.
*/
findRegions(t2) {
let e2 = t2.facet(we);
if ((e2 == null ? void 0 : e2.data) == this.data)
return [{ from: 0, to: t2.doc.length }];
if (!e2 || !e2.allowsNesting)
return [];
let i2 = [], n2 = (r2, o) => {
if (r2.prop(mi) == this.data) {
i2.push({ from: o, to: o + r2.length });
return;
}
let l = r2.prop(P$1.mounted);
if (l) {
if (l.tree.prop(mi) == this.data) {
if (l.overlay)
for (let h2 of l.overlay)
i2.push({ from: h2.from + o, to: h2.to + o });
else
i2.push({ from: o, to: o + r2.length });
return;
} else if (l.overlay) {
let h2 = i2.length;
if (n2(l.tree, l.overlay[0].from + o), i2.length > h2)
return;
}
}
for (let h2 = 0; h2 < r2.children.length; h2++) {
let a2 = r2.children[h2];
a2 instanceof J$1 && n2(a2, r2.positions[h2] + o);
}
};
return n2(St(t2), 0), i2;
}
/**
Indicates whether this language allows nested languages. The
default implementation returns true.
*/
get allowsNesting() {
return true;
}
}
Tt.setState = /* @__PURE__ */ F.define();
function go(s, t2, e2) {
let i2 = s.facet(we);
if (!i2)
return null;
let n2 = i2.data;
if (i2.allowsNesting)
for (let r2 = St(s).topNode; r2; r2 = r2.enter(t2, e2, st.ExcludeBuffers))
n2 = r2.type.prop(mi) || n2;
return n2;
}
class pn extends Tt {
constructor(t2, e2, i2) {
super(t2, e2, [], i2), this.parser = e2;
}
/**
Define a language from a parser.
*/
static define(t2) {
let e2 = fd(t2.languageData);
return new pn(e2, t2.parser.configure({
props: [mi.add((i2) => i2.isTop ? e2 : void 0)]
}), t2.name);
}
/**
Create a new instance of this language with a reconfigured
version of its parser and optionally a new name.
*/
configure(t2, e2) {
return new pn(this.data, this.parser.configure(t2), e2 || this.name);
}
get allowsNesting() {
return this.parser.hasWrappers();
}
}
function St(s) {
let t2 = s.field(Tt.state, false);
return t2 ? t2.tree : J$1.empty;
}
class ud {
constructor(t2, e2 = t2.length) {
this.doc = t2, this.length = e2, this.cursorPos = 0, this.string = "", this.cursor = t2.iter();
}
syncTo(t2) {
return this.string = this.cursor.next(t2 - this.cursorPos).value, this.cursorPos = t2 + this.string.length, this.cursorPos - this.string.length;
}
chunk(t2) {
return this.syncTo(t2), this.string;
}
get lineChunks() {
return true;
}
read(t2, e2) {
let i2 = this.cursorPos - this.string.length;
return t2 < i2 || e2 >= this.cursorPos ? this.doc.sliceString(t2, e2) : this.string.slice(t2 - i2, e2 - i2);
}
}
let ii = null;
class gn {
constructor(t2, e2, i2 = [], n2, r2, o, l, h2) {
this.parser = t2, this.state = e2, this.fragments = i2, this.tree = n2, this.treeLen = r2, this.viewport = o, this.skipped = l, this.scheduleOn = h2, this.parse = null, this.tempSkipped = [];
}
/**
@internal
*/
static create(t2, e2, i2) {
return new gn(t2, e2, [], J$1.empty, 0, i2, [], null);
}
startParse() {
return this.parser.startParse(new ud(this.state.doc), this.fragments);
}
/**
@internal
*/
work(t2, e2) {
return e2 != null && e2 >= this.state.doc.length && (e2 = void 0), this.tree != J$1.empty && this.isDone(e2 ?? this.state.doc.length) ? (this.takeTree(), true) : this.withContext(() => {
var i2;
if (typeof t2 == "number") {
let n2 = Date.now() + t2;
t2 = () => Date.now() > n2;
}
for (this.parse || (this.parse = this.startParse()), e2 != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > e2) && e2 < this.state.doc.length && this.parse.stopAt(e2); ; ) {
let n2 = this.parse.advance();
if (n2)
if (this.fragments = this.withoutTempSkipped(Oe.addTree(n2, this.fragments, this.parse.stoppedAt != null)), this.treeLen = (i2 = this.parse.stoppedAt) !== null && i2 !== void 0 ? i2 : this.state.doc.length, this.tree = n2, this.parse = null, this.treeLen < (e2 ?? this.state.doc.length))
this.parse = this.startParse();
else
return true;
if (t2())
return false;
}
});
}
/**
@internal
*/
takeTree() {
let t2, e2;
this.parse && (t2 = this.parse.parsedPos) >= this.treeLen && ((this.parse.stoppedAt == null || this.parse.stoppedAt > t2) && this.parse.stopAt(t2), this.withContext(() => {
for (; !(e2 = this.parse.advance()); )
;
}), this.treeLen = t2, this.tree = e2, this.fragments = this.withoutTempSkipped(Oe.addTree(this.tree, this.fragments, true)), this.parse = null);
}
withContext(t2) {
let e2 = ii;
ii = this;
try {
return t2();
} finally {
ii = e2;
}
}
withoutTempSkipped(t2) {
for (let e2; e2 = this.tempSkipped.pop(); )
t2 = mo(t2, e2.from, e2.to);
return t2;
}
/**
@internal
*/
changes(t2, e2) {
let { fragments: i2, tree: n2, treeLen: r2, viewport: o, skipped: l } = this;
if (this.takeTree(), !t2.empty) {
let h2 = [];
if (t2.iterChangedRanges((a2, c2, f2, u2) => h2.push({ fromA: a2, toA: c2, fromB: f2, toB: u2 })), i2 = Oe.applyChanges(i2, h2), n2 = J$1.empty, r2 = 0, o = { from: t2.mapPos(o.from, -1), to: t2.mapPos(o.to, 1) }, this.skipped.length) {
l = [];
for (let a2 of this.skipped) {
let c2 = t2.mapPos(a2.from, 1), f2 = t2.mapPos(a2.to, -1);
c2 < f2 && l.push({ from: c2, to: f2 });
}
}
}
return new gn(this.parser, e2, i2, n2, r2, o, l, this.scheduleOn);
}
/**
@internal
*/
updateViewport(t2) {
if (this.viewport.from == t2.from && this.viewport.to == t2.to)
return false;
this.viewport = t2;
let e2 = this.skipped.length;
for (let i2 = 0; i2 < this.skipped.length; i2++) {
let { from: n2, to: r2 } = this.skipped[i2];
n2 < t2.to && r2 > t2.from && (this.fragments = mo(this.fragments, n2, r2), this.skipped.splice(i2--, 1));
}
return this.skipped.length >= e2 ? false : (this.reset(), true);
}
/**
@internal
*/
reset() {
this.parse && (this.takeTree(), this.parse = null);
}
/**
Notify the parse scheduler that the given region was skipped
because it wasn't in view, and the parse should be restarted
when it comes into view.
*/
skipUntilInView(t2, e2) {
this.skipped.push({ from: t2, to: e2 });
}
/**
Returns a parser intended to be used as placeholder when
asynchronously loading a nested parser. It'll skip its input and
mark it as not-really-parsed, so that the next update will parse
it again.
When `until` is given, a reparse will be scheduled when that
promise resolves.
*/
static getSkippingParser(t2) {
return new class extends uh {
createParse(e2, i2, n2) {
let r2 = n2[0].from, o = n2[n2.length - 1].to;
return {
parsedPos: r2,
advance() {
let h2 = ii;
if (h2) {
for (let a2 of n2)
h2.tempSkipped.push(a2);
t2 && (h2.scheduleOn = h2.scheduleOn ? Promise.all([h2.scheduleOn, t2]) : t2);
}
return this.parsedPos = o, new J$1(yt.none, [], [], o - r2);
},
stoppedAt: null,
stopAt() {
}
};
}
}();
}
/**
@internal
*/
isDone(t2) {
t2 = Math.min(t2, this.state.doc.length);
let e2 = this.fragments;
return this.treeLen >= t2 && e2.length && e2[0].from == 0 && e2[0].to >= t2;
}
/**
Get the context for the current parse, or `null` if no editor
parse is in progress.
*/
static get() {
return ii;
}
}
function mo(s, t2, e2) {
return Oe.applyChanges(s, [{ fromA: t2, toA: e2, fromB: t2, toB: e2 }]);
}
class Qe {
constructor(t2) {
this.context = t2, this.tree = t2.tree;
}
apply(t2) {
if (!t2.docChanged && this.tree == this.context.tree)
return this;
let e2 = this.context.changes(t2.changes, t2.state), i2 = this.context.treeLen == t2.startState.doc.length ? void 0 : Math.max(t2.changes.mapPos(this.context.treeLen), e2.viewport.to);
return e2.work(20, i2) || e2.takeTree(), new Qe(e2);
}
static init(t2) {
let e2 = Math.min(3e3, t2.doc.length), i2 = gn.create(t2.facet(we).parser, t2, { from: 0, to: e2 });
return i2.work(20, e2) || i2.takeTree(), new Qe(i2);
}
}
Tt.state = /* @__PURE__ */ Bt.define({
create: Qe.init,
update(s, t2) {
for (let e2 of t2.effects)
if (e2.is(Tt.setState))
return e2.value;
return t2.startState.facet(we) != t2.state.facet(we) ? Qe.init(t2.state) : s.apply(t2);
}
});
let mh = (s) => {
let t2 = setTimeout(
() => s(),
500
/* Work.MaxPause */
);
return () => clearTimeout(t2);
};
typeof requestIdleCallback < "u" && (mh = (s) => {
let t2 = -1, e2 = setTimeout(
() => {
t2 = requestIdleCallback(s, {
timeout: 500 - 100
/* Work.MinPause */
});
},
100
/* Work.MinPause */
);
return () => t2 < 0 ? clearTimeout(e2) : cancelIdleCallback(t2);
});
const Un = typeof navigator < "u" && (!((Gn = navigator.scheduling) === null || Gn === void 0) && Gn.isInputPending) ? () => navigator.scheduling.isInputPending() : null, dd = /* @__PURE__ */ wt.fromClass(class {
constructor(t2) {
this.view = t2, this.working = null, this.workScheduled = 0, this.chunkEnd = -1, this.chunkBudget = -1, this.work = this.work.bind(this), this.scheduleWork();
}
update(t2) {
let e2 = this.view.state.field(Tt.state).context;
(e2.updateViewport(t2.view.viewport) || this.view.viewport.to > e2.treeLen) && this.scheduleWork(), t2.docChanged && (this.view.hasFocus && (this.chunkBudget += 50), this.scheduleWork()), this.checkAsyncSchedule(e2);
}
scheduleWork() {
if (this.working)
return;
let { state: t2 } = this.view, e2 = t2.field(Tt.state);
(e2.tree != e2.context.tree || !e2.context.isDone(t2.doc.length)) && (this.working = mh(this.work));
}
work(t2) {
this.working = null;
let e2 = Date.now();
if (this.chunkEnd < e2 && (this.chunkEnd < 0 || this.view.hasFocus) && (this.chunkEnd = e2 + 3e4, this.chunkBudget = 3e3), this.chunkBudget <= 0)
return;
let { state: i2, viewport: { to: n2 } } = this.view, r2 = i2.field(Tt.state);
if (r2.tree == r2.context.tree && r2.context.isDone(
n2 + 1e5
/* Work.MaxParseAhead */
))
return;
let o = Date.now() + Math.min(this.chunkBudget, 100, t2 && !Un ? Math.max(25, t2.timeRemaining() - 5) : 1e9), l = r2.context.treeLen < n2 && i2.doc.length > n2 + 1e3, h2 = r2.context.work(() => Un && Un() || Date.now() > o, n2 + (l ? 0 : 1e5));
this.chunkBudget -= Date.now() - e2, (h2 || this.chunkBudget <= 0) && (r2.context.takeTree(), this.view.dispatch({ effects: Tt.setState.of(new Qe(r2.context)) })), this.chunkBudget > 0 && !(h2 && !l) && this.scheduleWork(), this.checkAsyncSchedule(r2.context);
}
checkAsyncSchedule(t2) {
t2.scheduleOn && (this.workScheduled++, t2.scheduleOn.then(() => this.scheduleWork()).catch((e2) => zt(this.view.state, e2)).then(() => this.workScheduled--), t2.scheduleOn = null);
}
destroy() {
this.working && this.working();
}
isWorking() {
return !!(this.working || this.workScheduled > 0);
}
}, {
eventHandlers: { focus() {
this.scheduleWork();
} }
}), we = /* @__PURE__ */ v.define({
combine(s) {
return s.length ? s[0] : null;
},
enables: (s) => [
Tt.state,
dd,
A$2.contentAttributes.compute([s], (t2) => {
let e2 = t2.facet(s);
return e2 && e2.name ? { "data-language": e2.name } : {};
})
]
});
class pd {
/**
Create a language support object.
*/
constructor(t2, e2 = []) {
this.language = t2, this.support = e2, this.extension = [t2, e2];
}
}
const gd = /* @__PURE__ */ v.define(), nr = /* @__PURE__ */ v.define({
combine: (s) => {
if (!s.length)
return " ";
if (!/^(?: +|\t+)$/.test(s[0]))
throw new Error("Invalid indent unit: " + JSON.stringify(s[0]));
return s[0];
}
});
function mn(s) {
let t2 = s.facet(nr);
return t2.charCodeAt(0) == 9 ? s.tabSize * t2.length : t2.length;
}
function wi(s, t2) {
let e2 = "", i2 = s.tabSize;
if (s.facet(nr).charCodeAt(0) == 9)
for (; t2 >= i2; )
e2 += " ", t2 -= i2;
for (let n2 = 0; n2 < t2; n2++)
e2 += " ";
return e2;
}
function sr(s, t2) {
s instanceof N$2 && (s = new Dn(s));
for (let i2 of s.state.facet(gd)) {
let n2 = i2(s, t2);
if (n2 !== void 0)
return n2;
}
let e2 = St(s.state);
return e2 ? md(s, e2, t2) : null;
}
class Dn {
/**
Create an indent context.
*/
constructor(t2, e2 = {}) {
this.state = t2, this.options = e2, this.unit = mn(t2);
}
/**
Get a description of the line at the given position, taking
[simulated line
breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
into account. If there is such a break at `pos`, the `bias`
argument determines whether the part of the line line before or
after the break is used.
*/
lineAt(t2, e2 = 1) {
let i2 = this.state.doc.lineAt(t2), { simulateBreak: n2, simulateDoubleBreak: r2 } = this.options;
return n2 != null && n2 >= i2.from && n2 <= i2.to ? r2 && n2 == t2 ? { text: "", from: t2 } : (e2 < 0 ? n2 < t2 : n2 <= t2) ? { text: i2.text.slice(n2 - i2.from), from: n2 } : { text: i2.text.slice(0, n2 - i2.from), from: i2.from } : i2;
}
/**
Get the text directly after `pos`, either the entire line
or the next 100 characters, whichever is shorter.
*/
textAfterPos(t2, e2 = 1) {
if (this.options.simulateDoubleBreak && t2 == this.options.simulateBreak)
return "";
let { text: i2, from: n2 } = this.lineAt(t2, e2);
return i2.slice(t2 - n2, Math.min(i2.length, t2 + 100 - n2));
}
/**
Find the column for the given position.
*/
column(t2, e2 = 1) {
let { text: i2, from: n2 } = this.lineAt(t2, e2), r2 = this.countColumn(i2, t2 - n2), o = this.options.overrideIndentation ? this.options.overrideIndentation(n2) : -1;
return o > -1 && (r2 += o - this.countColumn(i2, i2.search(/\S|$/))), r2;
}
/**
Find the column position (taking tabs into account) of the given
position in the given string.
*/
countColumn(t2, e2 = t2.length) {
return Cn(t2, this.state.tabSize, e2);
}
/**
Find the indentation column of the line at the given point.
*/
lineIndent(t2, e2 = 1) {
let { text: i2, from: n2 } = this.lineAt(t2, e2), r2 = this.options.overrideIndentation;
if (r2) {
let o = r2(n2);
if (o > -1)
return o;
}
return this.countColumn(i2, i2.search(/\S|$/));
}
/**
Returns the [simulated line
break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
for this context, if any.
*/
get simulatedBreak() {
return this.options.simulateBreak || null;
}
}
const wh = /* @__PURE__ */ new P$1();
function md(s, t2, e2) {
return yh(t2.resolveInner(e2).enterUnfinishedNodesBefore(e2), e2, s);
}
function wd(s) {
return s.pos == s.options.simulateBreak && s.options.simulateDoubleBreak;
}
function yd(s) {
let t2 = s.type.prop(wh);
if (t2)
return t2;
let e2 = s.firstChild, i2;
if (e2 && (i2 = e2.type.prop(P$1.closedBy))) {
let n2 = s.lastChild, r2 = n2 && i2.indexOf(n2.name) > -1;
return (o) => vd(o, true, 1, void 0, r2 && !wd(o) ? n2.from : void 0);
}
return s.parent == null ? bd : null;
}
function yh(s, t2, e2) {
for (; s; s = s.parent) {
let i2 = yd(s);
if (i2)
return i2(rr.create(e2, t2, s));
}
return null;
}
function bd() {
return 0;
}
class rr extends Dn {
constructor(t2, e2, i2) {
super(t2.state, t2.options), this.base = t2, this.pos = e2, this.node = i2;
}
/**
@internal
*/
static create(t2, e2, i2) {
return new rr(t2, e2, i2);
}
/**
Get the text directly after `this.pos`, either the entire line
or the next 100 characters, whichever is shorter.
*/
get textAfter() {
return this.textAfterPos(this.pos);
}
/**
Get the indentation at the reference line for `this.node`, which
is the line on which it starts, unless there is a node that is
_not_ a parent of this node covering the start of that line. If
so, the line at the start of that node is tried, again skipping
on if it is covered by another such node.
*/
get baseIndent() {
let t2 = this.state.doc.lineAt(this.node.from);
for (; ; ) {
let e2 = this.node.resolve(t2.from);
for (; e2.parent && e2.parent.from == e2.from; )
e2 = e2.parent;
if (kd(e2, this.node))
break;
t2 = this.state.doc.lineAt(e2.from);
}
return this.lineIndent(t2.from);
}
/**
Continue looking for indentations in the node's parent nodes,
and return the result of that.
*/
continue() {
let t2 = this.node.parent;
return t2 ? yh(t2, this.pos, this.base) : 0;
}
}
function kd(s, t2) {
for (let e2 = t2; e2; e2 = e2.parent)
if (s == e2)
return true;
return false;
}
function xd(s) {
let t2 = s.node, e2 = t2.childAfter(t2.from), i2 = t2.lastChild;
if (!e2)
return null;
let n2 = s.options.simulateBreak, r2 = s.state.doc.lineAt(e2.from), o = n2 == null || n2 <= r2.from ? r2.to : Math.min(r2.to, n2);
for (let l = e2.to; ; ) {
let h2 = t2.childAfter(l);
if (!h2 || h2 == i2)
return null;
if (!h2.type.isSkipped)
return h2.from < o ? e2 : null;
l = h2.to;
}
}
function vd(s, t2, e2, i2, n2) {
let r2 = s.textAfter, o = r2.match(/^\s*/)[0].length, l = i2 && r2.slice(o, o + i2.length) == i2 || n2 == s.pos + o, h2 = t2 ? xd(s) : null;
return h2 ? l ? s.column(h2.from) : s.column(h2.to) : s.baseIndent + (l ? 0 : s.unit * e2);
}
function wo({ except: s, units: t2 = 1 } = {}) {
return (e2) => {
let i2 = s && s.test(e2.textAfter);
return e2.baseIndent + (i2 ? 0 : t2 * e2.unit);
};
}
const Sd = 200;
function Cd() {
return N$2.transactionFilter.of((s) => {
if (!s.docChanged || !s.isUserEvent("input.type") && !s.isUserEvent("input.complete"))
return s;
let t2 = s.startState.languageDataAt("indentOnInput", s.startState.selection.main.head);
if (!t2.length)
return s;
let e2 = s.newDoc, { head: i2 } = s.newSelection.main, n2 = e2.lineAt(i2);
if (i2 > n2.from + Sd)
return s;
let r2 = e2.sliceString(n2.from, i2);
if (!t2.some((a2) => a2.test(r2)))
return s;
let { state: o } = s, l = -1, h2 = [];
for (let { head: a2 } of o.selection.ranges) {
let c2 = o.doc.lineAt(a2);
if (c2.from == l)
continue;
l = c2.from;
let f2 = sr(o, c2.from);
if (f2 == null)
continue;
let u2 = /^\s*/.exec(c2.text)[0], d2 = wi(o, f2);
u2 != d2 && h2.push({ from: c2.from, to: c2.from + u2.length, insert: d2 });
}
return h2.length ? [s, { changes: h2, sequential: true }] : s;
});
}
const Ad = /* @__PURE__ */ v.define(), bh = /* @__PURE__ */ new P$1();
function Od(s) {
let t2 = s.firstChild, e2 = s.lastChild;
return t2 && t2.to < e2.from ? { from: t2.to, to: e2.type.isError ? s.to : e2.from } : null;
}
function Md(s, t2, e2) {
let i2 = St(s);
if (i2.length < e2)
return null;
let n2 = i2.resolveInner(e2, 1), r2 = null;
for (let o = n2; o; o = o.parent) {
if (o.to <= e2 || o.from > e2)
continue;
if (r2 && o.from < t2)
break;
let l = o.type.prop(bh);
if (l && (o.to < i2.length - 50 || i2.length == s.doc.length || !Dd(o))) {
let h2 = l(o, s);
h2 && h2.from <= e2 && h2.from >= t2 && h2.to > e2 && (r2 = h2);
}
}
return r2;
}
function Dd(s) {
let t2 = s.lastChild;
return t2 && t2.to == s.to && t2.type.isError;
}
function wn(s, t2, e2) {
for (let i2 of s.facet(Ad)) {
let n2 = i2(s, t2, e2);
if (n2)
return n2;
}
return Md(s, t2, e2);
}
function kh(s, t2) {
let e2 = t2.mapPos(s.from, 1), i2 = t2.mapPos(s.to, -1);
return e2 >= i2 ? void 0 : { from: e2, to: i2 };
}
const Tn = /* @__PURE__ */ F.define({ map: kh }), xi = /* @__PURE__ */ F.define({ map: kh });
function xh(s) {
let t2 = [];
for (let { head: e2 } of s.state.selection.ranges)
t2.some((i2) => i2.from <= e2 && i2.to >= e2) || t2.push(s.lineBlockAt(e2));
return t2;
}
const Pe = /* @__PURE__ */ Bt.define({
create() {
return T.none;
},
update(s, t2) {
s = s.map(t2.changes);
for (let e2 of t2.effects)
e2.is(Tn) && !Td(s, e2.value.from, e2.value.to) ? s = s.update({ add: [yo.range(e2.value.from, e2.value.to)] }) : e2.is(xi) && (s = s.update({
filter: (i2, n2) => e2.value.from != i2 || e2.value.to != n2,
filterFrom: e2.value.from,
filterTo: e2.value.to
}));
if (t2.selection) {
let e2 = false, { head: i2 } = t2.selection.main;
s.between(i2, i2, (n2, r2) => {
n2 < i2 && r2 > i2 && (e2 = true);
}), e2 && (s = s.update({
filterFrom: i2,
filterTo: i2,
filter: (n2, r2) => r2 <= i2 || n2 >= i2
}));
}
return s;
},
provide: (s) => A$2.decorations.from(s),
toJSON(s, t2) {
let e2 = [];
return s.between(0, t2.doc.length, (i2, n2) => {
e2.push(i2, n2);
}), e2;
},
fromJSON(s) {
if (!Array.isArray(s) || s.length % 2)
throw new RangeError("Invalid JSON for fold state");
let t2 = [];
for (let e2 = 0; e2 < s.length; ) {
let i2 = s[e2++], n2 = s[e2++];
if (typeof i2 != "number" || typeof n2 != "number")
throw new RangeError("Invalid JSON for fold state");
t2.push(yo.range(i2, n2));
}
return T.set(t2, true);
}
});
function yn(s, t2, e2) {
var i2;
let n2 = null;
return (i2 = s.field(Pe, false)) === null || i2 === void 0 || i2.between(t2, e2, (r2, o) => {
(!n2 || n2.from > r2) && (n2 = { from: r2, to: o });
}), n2;
}
function Td(s, t2, e2) {
let i2 = false;
return s.between(t2, t2, (n2, r2) => {
n2 == t2 && r2 == e2 && (i2 = true);
}), i2;
}
function vh(s, t2) {
return s.field(Pe, false) ? t2 : t2.concat(F.appendConfig.of(Ah()));
}
const Pd = (s) => {
for (let t2 of xh(s)) {
let e2 = wn(s.state, t2.from, t2.to);
if (e2)
return s.dispatch({ effects: vh(s.state, [Tn.of(e2), Sh(s, e2)]) }), true;
}
return false;
}, Bd = (s) => {
if (!s.state.field(Pe, false))
return false;
let t2 = [];
for (let e2 of xh(s)) {
let i2 = yn(s.state, e2.from, e2.to);
i2 && t2.push(xi.of(i2), Sh(s, i2, false));
}
return t2.length && s.dispatch({ effects: t2 }), t2.length > 0;
};
function Sh(s, t2, e2 = true) {
let i2 = s.state.doc.lineAt(t2.from).number, n2 = s.state.doc.lineAt(t2.to).number;
return A$2.announce.of(`${s.state.phrase(e2 ? "Folded lines" : "Unfolded lines")} ${i2} ${s.state.phrase("to")} ${n2}.`);
}
const Rd = (s) => {
let { state: t2 } = s, e2 = [];
for (let i2 = 0; i2 < t2.doc.length; ) {
let n2 = s.lineBlockAt(i2), r2 = wn(t2, n2.from, n2.to);
r2 && e2.push(Tn.of(r2)), i2 = (r2 ? s.lineBlockAt(r2.to) : n2).to + 1;
}
return e2.length && s.dispatch({ effects: vh(s.state, e2) }), !!e2.length;
}, Ld = (s) => {
let t2 = s.state.field(Pe, false);
if (!t2 || !t2.size)
return false;
let e2 = [];
return t2.between(0, s.state.doc.length, (i2, n2) => {
e2.push(xi.of({ from: i2, to: n2 }));
}), s.dispatch({ effects: e2 }), true;
}, Ed = [
{ key: "Ctrl-Shift-[", mac: "Cmd-Alt-[", run: Pd },
{ key: "Ctrl-Shift-]", mac: "Cmd-Alt-]", run: Bd },
{ key: "Ctrl-Alt-[", run: Rd },
{ key: "Ctrl-Alt-]", run: Ld }
], Nd = {
placeholderDOM: null,
placeholderText: "…"
}, Ch = /* @__PURE__ */ v.define({
combine(s) {
return Sn(s, Nd);
}
});
function Ah(s) {
let t2 = [Pe, Hd];
return s && t2.push(Ch.of(s)), t2;
}
const yo = /* @__PURE__ */ T.replace({ widget: /* @__PURE__ */ new class extends ye {
toDOM(s) {
let { state: t2 } = s, e2 = t2.facet(Ch), i2 = (r2) => {
let o = s.lineBlockAt(s.posAtDOM(r2.target)), l = yn(s.state, o.from, o.to);
l && s.dispatch({ effects: xi.of(l) }), r2.preventDefault();
};
if (e2.placeholderDOM)
return e2.placeholderDOM(s, i2);
let n2 = document.createElement("span");
return n2.textContent = e2.placeholderText, n2.setAttribute("aria-label", t2.phrase("folded code")), n2.title = t2.phrase("unfold"), n2.className = "cm-foldPlaceholder", n2.onclick = i2, n2;
}
}() }), Vd = {
openText: "⌄",
closedText: "",
markerDOM: null,
domEventHandlers: {},
foldingChanged: () => false
};
class Qn extends me {
constructor(t2, e2) {
super(), this.config = t2, this.open = e2;
}
eq(t2) {
return this.config == t2.config && this.open == t2.open;
}
toDOM(t2) {
if (this.config.markerDOM)
return this.config.markerDOM(this.open);
let e2 = document.createElement("span");
return e2.textContent = this.open ? this.config.openText : this.config.closedText, e2.title = t2.state.phrase(this.open ? "Fold line" : "Unfold line"), e2;
}
}
function Id(s = {}) {
let t2 = Object.assign(Object.assign({}, Vd), s), e2 = new Qn(t2, true), i2 = new Qn(t2, false), n2 = wt.fromClass(class {
constructor(o) {
this.from = o.viewport.from, this.markers = this.buildMarkers(o);
}
update(o) {
(o.docChanged || o.viewportChanged || o.startState.facet(we) != o.state.facet(we) || o.startState.field(Pe, false) != o.state.field(Pe, false) || St(o.startState) != St(o.state) || t2.foldingChanged(o)) && (this.markers = this.buildMarkers(o.view));
}
buildMarkers(o) {
let l = new De();
for (let h2 of o.viewportLineBlocks) {
let a2 = yn(o.state, h2.from, h2.to) ? i2 : wn(o.state, h2.from, h2.to) ? e2 : null;
a2 && l.add(h2.from, h2.from, a2);
}
return l.finish();
}
}), { domEventHandlers: r2 } = t2;
return [
n2,
ju({
class: "cm-foldGutter",
markers(o) {
var l;
return ((l = o.plugin(n2)) === null || l === void 0 ? void 0 : l.markers) || $.empty;
},
initialSpacer() {
return new Qn(t2, false);
},
domEventHandlers: Object.assign(Object.assign({}, r2), { click: (o, l, h2) => {
if (r2.click && r2.click(o, l, h2))
return true;
let a2 = yn(o.state, l.from, l.to);
if (a2)
return o.dispatch({ effects: xi.of(a2) }), true;
let c2 = wn(o.state, l.from, l.to);
return c2 ? (o.dispatch({ effects: Tn.of(c2) }), true) : false;
} })
}),
Ah()
];
}
const Hd = /* @__PURE__ */ A$2.baseTheme({
".cm-foldPlaceholder": {
backgroundColor: "#eee",
border: "1px solid #ddd",
color: "#888",
borderRadius: ".2em",
margin: "0 1px",
padding: "0 1px",
cursor: "pointer"
},
".cm-foldGutter span": {
padding: "0 1px",
cursor: "pointer"
}
});
class vi {
constructor(t2, e2) {
this.specs = t2;
let i2;
function n2(l) {
let h2 = de.newName();
return (i2 || (i2 = /* @__PURE__ */ Object.create(null)))["." + h2] = l, h2;
}
const r2 = typeof e2.all == "string" ? e2.all : e2.all ? n2(e2.all) : void 0, o = e2.scope;
this.scope = o instanceof Tt ? (l) => l.prop(mi) == o.data : o ? (l) => l == o : void 0, this.style = gh(t2.map((l) => ({
tag: l.tag,
class: l.class || n2(Object.assign({}, l, { tag: null }))
})), {
all: r2
}).style, this.module = i2 ? new de(i2) : null, this.themeType = e2.themeType;
}
/**
Create a highlighter style that associates the given styles to
the given tags. The specs must be objects that hold a style tag
or array of tags in their `tag` property, and either a single
`class` property providing a static CSS class (for highlighter
that rely on external styling), or a
[`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
set of CSS properties (which define the styling for those tags).
The CSS rules created for a highlighter will be emitted in the
order of the spec's properties. That means that for elements that
have multiple tags associated with them, styles defined further
down in the list will have a higher CSS precedence than styles
defined earlier.
*/
static define(t2, e2) {
return new vi(t2, e2 || {});
}
}
const Ns = /* @__PURE__ */ v.define(), Oh = /* @__PURE__ */ v.define({
combine(s) {
return s.length ? [s[0]] : null;
}
});
function Jn(s) {
let t2 = s.facet(Ns);
return t2.length ? t2 : s.facet(Oh);
}
function bo(s, t2) {
let e2 = [Fd], i2;
return s instanceof vi && (s.module && e2.push(A$2.styleModule.of(s.module)), i2 = s.themeType), t2 != null && t2.fallback ? e2.push(Oh.of(s)) : i2 ? e2.push(Ns.computeN([A$2.darkTheme], (n2) => n2.facet(A$2.darkTheme) == (i2 == "dark") ? [s] : [])) : e2.push(Ns.of(s)), e2;
}
class $d {
constructor(t2) {
this.markCache = /* @__PURE__ */ Object.create(null), this.tree = St(t2.state), this.decorations = this.buildDeco(t2, Jn(t2.state));
}
update(t2) {
let e2 = St(t2.state), i2 = Jn(t2.state), n2 = i2 != Jn(t2.startState);
e2.length < t2.view.viewport.to && !n2 && e2.type == this.tree.type ? this.decorations = this.decorations.map(t2.changes) : (e2 != this.tree || t2.viewportChanged || n2) && (this.tree = e2, this.decorations = this.buildDeco(t2.view, i2));
}
buildDeco(t2, e2) {
if (!e2 || !this.tree.length)
return T.none;
let i2 = new De();
for (let { from: n2, to: r2 } of t2.visibleRanges)
hd(this.tree, e2, (o, l, h2) => {
i2.add(o, l, this.markCache[h2] || (this.markCache[h2] = T.mark({ class: h2 })));
}, n2, r2);
return i2.finish();
}
}
const Fd = /* @__PURE__ */ js.high(/* @__PURE__ */ wt.fromClass($d, {
decorations: (s) => s.decorations
})), zd = /* @__PURE__ */ vi.define([
{
tag: m$1.meta,
color: "#404740"
},
{
tag: m$1.link,
textDecoration: "underline"
},
{
tag: m$1.heading,
textDecoration: "underline",
fontWeight: "bold"
},
{
tag: m$1.emphasis,
fontStyle: "italic"
},
{
tag: m$1.strong,
fontWeight: "bold"
},
{
tag: m$1.strikethrough,
textDecoration: "line-through"
},
{
tag: m$1.keyword,
color: "#708"
},
{
tag: [m$1.atom, m$1.bool, m$1.url, m$1.contentSeparator, m$1.labelName],
color: "#219"
},
{
tag: [m$1.literal, m$1.inserted],
color: "#164"
},
{
tag: [m$1.string, m$1.deleted],
color: "#a11"
},
{
tag: [m$1.regexp, m$1.escape, /* @__PURE__ */ m$1.special(m$1.string)],
color: "#e40"
},
{
tag: /* @__PURE__ */ m$1.definition(m$1.variableName),
color: "#00f"
},
{
tag: /* @__PURE__ */ m$1.local(m$1.variableName),
color: "#30a"
},
{
tag: [m$1.typeName, m$1.namespace],
color: "#085"
},
{
tag: m$1.className,
color: "#167"
},
{
tag: [/* @__PURE__ */ m$1.special(m$1.variableName), m$1.macroName],
color: "#256"
},
{
tag: /* @__PURE__ */ m$1.definition(m$1.propertyName),
color: "#00c"
},
{
tag: m$1.comment,
color: "#940"
},
{
tag: m$1.invalid,
color: "#f00"
}
]), _d = /* @__PURE__ */ A$2.baseTheme({
"&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
"&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
}), Mh = 1e4, Dh = "()[]{}", Th = /* @__PURE__ */ v.define({
combine(s) {
return Sn(s, {
afterCursor: true,
brackets: Dh,
maxScanDistance: Mh,
renderMatch: qd
});
}
}), Wd = /* @__PURE__ */ T.mark({ class: "cm-matchingBracket" }), jd = /* @__PURE__ */ T.mark({ class: "cm-nonmatchingBracket" });
function qd(s) {
let t2 = [], e2 = s.matched ? Wd : jd;
return t2.push(e2.range(s.start.from, s.start.to)), s.end && t2.push(e2.range(s.end.from, s.end.to)), t2;
}
const Kd = /* @__PURE__ */ Bt.define({
create() {
return T.none;
},
update(s, t2) {
if (!t2.docChanged && !t2.selection)
return s;
let e2 = [], i2 = t2.state.facet(Th);
for (let n2 of t2.state.selection.ranges) {
if (!n2.empty)
continue;
let r2 = Ft(t2.state, n2.head, -1, i2) || n2.head > 0 && Ft(t2.state, n2.head - 1, 1, i2) || i2.afterCursor && (Ft(t2.state, n2.head, 1, i2) || n2.head < t2.state.doc.length && Ft(t2.state, n2.head + 1, -1, i2));
r2 && (e2 = e2.concat(i2.renderMatch(r2, t2.state)));
}
return T.set(e2, true);
},
provide: (s) => A$2.decorations.from(s)
}), Gd = [
Kd,
_d
];
function Ud(s = {}) {
return [Th.of(s), Gd];
}
const Qd = /* @__PURE__ */ new P$1();
function Vs(s, t2, e2) {
let i2 = s.prop(t2 < 0 ? P$1.openedBy : P$1.closedBy);
if (i2)
return i2;
if (s.name.length == 1) {
let n2 = e2.indexOf(s.name);
if (n2 > -1 && n2 % 2 == (t2 < 0 ? 1 : 0))
return [e2[n2 + t2]];
}
return null;
}
function Is(s) {
let t2 = s.type.prop(Qd);
return t2 ? t2(s.node) : s;
}
function Ft(s, t2, e2, i2 = {}) {
let n2 = i2.maxScanDistance || Mh, r2 = i2.brackets || Dh, o = St(s), l = o.resolveInner(t2, e2);
for (let h2 = l; h2; h2 = h2.parent) {
let a2 = Vs(h2.type, e2, r2);
if (a2 && h2.from < h2.to) {
let c2 = Is(h2);
if (c2 && (e2 > 0 ? t2 >= c2.from && t2 < c2.to : t2 > c2.from && t2 <= c2.to))
return Jd(s, t2, e2, h2, c2, a2, r2);
}
}
return Xd(s, t2, e2, o, l.type, n2, r2);
}
function Jd(s, t2, e2, i2, n2, r2, o) {
let l = i2.parent, h2 = { from: n2.from, to: n2.to }, a2 = 0, c2 = l == null ? void 0 : l.cursor();
if (c2 && (e2 < 0 ? c2.childBefore(i2.from) : c2.childAfter(i2.to)))
do
if (e2 < 0 ? c2.to <= i2.from : c2.from >= i2.to) {
if (a2 == 0 && r2.indexOf(c2.type.name) > -1 && c2.from < c2.to) {
let f2 = Is(c2);
return { start: h2, end: f2 ? { from: f2.from, to: f2.to } : void 0, matched: true };
} else if (Vs(c2.type, e2, o))
a2++;
else if (Vs(c2.type, -e2, o)) {
if (a2 == 0) {
let f2 = Is(c2);
return {
start: h2,
end: f2 && f2.from < f2.to ? { from: f2.from, to: f2.to } : void 0,
matched: false
};
}
a2--;
}
}
while (e2 < 0 ? c2.prevSibling() : c2.nextSibling());
return { start: h2, matched: false };
}
function Xd(s, t2, e2, i2, n2, r2, o) {
let l = e2 < 0 ? s.sliceDoc(t2 - 1, t2) : s.sliceDoc(t2, t2 + 1), h2 = o.indexOf(l);
if (h2 < 0 || h2 % 2 == 0 != e2 > 0)
return null;
let a2 = { from: e2 < 0 ? t2 - 1 : t2, to: e2 > 0 ? t2 + 1 : t2 }, c2 = s.doc.iterRange(t2, e2 > 0 ? s.doc.length : 0), f2 = 0;
for (let u2 = 0; !c2.next().done && u2 <= r2; ) {
let d2 = c2.value;
e2 < 0 && (u2 += d2.length);
let p2 = t2 + u2 * e2;
for (let w2 = e2 > 0 ? 0 : d2.length - 1, g = e2 > 0 ? d2.length : -1; w2 != g; w2 += e2) {
let y2 = o.indexOf(d2[w2]);
if (!(y2 < 0 || i2.resolveInner(p2 + w2, 1).type != n2))
if (y2 % 2 == 0 == e2 > 0)
f2++;
else {
if (f2 == 1)
return { start: a2, end: { from: p2 + w2, to: p2 + w2 + 1 }, matched: y2 >> 1 == h2 >> 1 };
f2--;
}
}
e2 > 0 && (u2 += d2.length);
}
return c2.done ? { start: a2, matched: false } : null;
}
const Yd = /* @__PURE__ */ Object.create(null), ko = [yt.none], xo = [], Zd = /* @__PURE__ */ Object.create(null);
for (let [s, t2] of [
["variable", "variableName"],
["variable-2", "variableName.special"],
["string-2", "string.special"],
["def", "variableName.definition"],
["tag", "tagName"],
["attribute", "attributeName"],
["type", "typeName"],
["builtin", "variableName.standard"],
["qualifier", "modifier"],
["error", "invalid"],
["header", "heading"],
["property", "propertyName"]
])
Zd[s] = /* @__PURE__ */ tp(Yd, t2);
function Xn(s, t2) {
xo.indexOf(s) > -1 || (xo.push(s), console.warn(t2));
}
function tp(s, t2) {
let e2 = null;
for (let r2 of t2.split(".")) {
let o = s[r2] || m$1[r2];
o ? typeof o == "function" ? e2 ? e2 = o(e2) : Xn(r2, `Modifier ${r2} used at start of tag`) : e2 ? Xn(r2, `Tag ${r2} used as modifier`) : e2 = o : Xn(r2, `Unknown highlighting tag ${r2}`);
}
if (!e2)
return 0;
let i2 = t2.replace(/ /g, "_"), n2 = yt.define({
id: ko.length,
name: i2,
props: [dh({ [i2]: e2 })]
});
return ko.push(n2), n2.id;
}
const ep = (s) => {
let t2 = lr(s.state);
return t2.line ? ip(s) : t2.block ? sp(s) : false;
};
function or(s, t2) {
return ({ state: e2, dispatch: i2 }) => {
if (e2.readOnly)
return false;
let n2 = s(t2, e2);
return n2 ? (i2(e2.update(n2)), true) : false;
};
}
const ip = /* @__PURE__ */ or(
lp,
0
/* CommentOption.Toggle */
), np = /* @__PURE__ */ or(
Ph,
0
/* CommentOption.Toggle */
), sp = /* @__PURE__ */ or(
(s, t2) => Ph(s, t2, op(t2)),
0
/* CommentOption.Toggle */
);
function lr(s, t2 = s.selection.main.head) {
let e2 = s.languageDataAt("commentTokens", t2);
return e2.length ? e2[0] : {};
}
const ni = 50;
function rp(s, { open: t2, close: e2 }, i2, n2) {
let r2 = s.sliceDoc(i2 - ni, i2), o = s.sliceDoc(n2, n2 + ni), l = /\s*$/.exec(r2)[0].length, h2 = /^\s*/.exec(o)[0].length, a2 = r2.length - l;
if (r2.slice(a2 - t2.length, a2) == t2 && o.slice(h2, h2 + e2.length) == e2)
return {
open: { pos: i2 - l, margin: l && 1 },
close: { pos: n2 + h2, margin: h2 && 1 }
};
let c2, f2;
n2 - i2 <= 2 * ni ? c2 = f2 = s.sliceDoc(i2, n2) : (c2 = s.sliceDoc(i2, i2 + ni), f2 = s.sliceDoc(n2 - ni, n2));
let u2 = /^\s*/.exec(c2)[0].length, d2 = /\s*$/.exec(f2)[0].length, p2 = f2.length - d2 - e2.length;
return c2.slice(u2, u2 + t2.length) == t2 && f2.slice(p2, p2 + e2.length) == e2 ? {
open: {
pos: i2 + u2 + t2.length,
margin: /\s/.test(c2.charAt(u2 + t2.length)) ? 1 : 0
},
close: {
pos: n2 - d2 - e2.length,
margin: /\s/.test(f2.charAt(p2 - 1)) ? 1 : 0
}
} : null;
}
function op(s) {
let t2 = [];
for (let e2 of s.selection.ranges) {
let i2 = s.doc.lineAt(e2.from), n2 = e2.to <= i2.to ? i2 : s.doc.lineAt(e2.to), r2 = t2.length - 1;
r2 >= 0 && t2[r2].to > i2.from ? t2[r2].to = n2.to : t2.push({ from: i2.from, to: n2.to });
}
return t2;
}
function Ph(s, t2, e2 = t2.selection.ranges) {
let i2 = e2.map((r2) => lr(t2, r2.from).block);
if (!i2.every((r2) => r2))
return null;
let n2 = e2.map((r2, o) => rp(t2, i2[o], r2.from, r2.to));
if (s != 2 && !n2.every((r2) => r2))
return { changes: t2.changes(e2.map((r2, o) => n2[o] ? [] : [{ from: r2.from, insert: i2[o].open + " " }, { from: r2.to, insert: " " + i2[o].close }])) };
if (s != 1 && n2.some((r2) => r2)) {
let r2 = [];
for (let o = 0, l; o < n2.length; o++)
if (l = n2[o]) {
let h2 = i2[o], { open: a2, close: c2 } = l;
r2.push({ from: a2.pos - h2.open.length, to: a2.pos + a2.margin }, { from: c2.pos - c2.margin, to: c2.pos + h2.close.length });
}
return { changes: r2 };
}
return null;
}
function lp(s, t2, e2 = t2.selection.ranges) {
let i2 = [], n2 = -1;
for (let { from: r2, to: o } of e2) {
let l = i2.length, h2 = 1e9;
for (let a2 = r2; a2 <= o; ) {
let c2 = t2.doc.lineAt(a2);
if (c2.from > n2 && (r2 == o || o > c2.from)) {
n2 = c2.from;
let f2 = lr(t2, a2).line;
if (!f2)
continue;
let u2 = /^\s*/.exec(c2.text)[0].length, d2 = u2 == c2.length, p2 = c2.text.slice(u2, u2 + f2.length) == f2 ? u2 : -1;
u2 < c2.text.length && u2 < h2 && (h2 = u2), i2.push({ line: c2, comment: p2, token: f2, indent: u2, empty: d2, single: false });
}
a2 = c2.to + 1;
}
if (h2 < 1e9)
for (let a2 = l; a2 < i2.length; a2++)
i2[a2].indent < i2[a2].line.text.length && (i2[a2].indent = h2);
i2.length == l + 1 && (i2[l].single = true);
}
if (s != 2 && i2.some((r2) => r2.comment < 0 && (!r2.empty || r2.single))) {
let r2 = [];
for (let { line: l, token: h2, indent: a2, empty: c2, single: f2 } of i2)
(f2 || !c2) && r2.push({ from: l.from + a2, insert: h2 + " " });
let o = t2.changes(r2);
return { changes: o, selection: t2.selection.map(o, 1) };
} else if (s != 1 && i2.some((r2) => r2.comment >= 0)) {
let r2 = [];
for (let { line: o, comment: l, token: h2 } of i2)
if (l >= 0) {
let a2 = o.from + l, c2 = a2 + h2.length;
o.text[c2 - o.from] == " " && c2++, r2.push({ from: a2, to: c2 });
}
return { changes: r2 };
}
return null;
}
function Ye(s, t2) {
return b$2.create(s.ranges.map(t2), s.mainIndex);
}
function Kt(s, t2) {
return s.update({ selection: t2, scrollIntoView: true, userEvent: "select" });
}
function Rt({ state: s, dispatch: t2 }, e2) {
let i2 = Ye(s.selection, e2);
return i2.eq(s.selection) ? false : (t2(Kt(s, i2)), true);
}
function Pn(s, t2) {
return b$2.cursor(t2 ? s.to : s.from);
}
function Bh(s, t2) {
return Rt(s, (e2) => e2.empty ? s.moveByChar(e2, t2) : Pn(e2, t2));
}
function ft(s) {
return s.textDirectionAt(s.state.selection.main.head) == X.LTR;
}
const Rh = (s) => Bh(s, !ft(s)), Lh = (s) => Bh(s, ft(s));
function Eh(s, t2) {
return Rt(s, (e2) => e2.empty ? s.moveByGroup(e2, t2) : Pn(e2, t2));
}
const hp = (s) => Eh(s, !ft(s)), ap = (s) => Eh(s, ft(s));
function cp(s, t2, e2) {
if (t2.type.prop(e2))
return true;
let i2 = t2.to - t2.from;
return i2 && (i2 > 2 || /[^\s,.;:]/.test(s.sliceDoc(t2.from, t2.to))) || t2.firstChild;
}
function Bn(s, t2, e2) {
let i2 = St(s).resolveInner(t2.head), n2 = e2 ? P$1.closedBy : P$1.openedBy;
for (let h2 = t2.head; ; ) {
let a2 = e2 ? i2.childAfter(h2) : i2.childBefore(h2);
if (!a2)
break;
cp(s, a2, n2) ? i2 = a2 : h2 = e2 ? a2.to : a2.from;
}
let r2 = i2.type.prop(n2), o, l;
return r2 && (o = e2 ? Ft(s, i2.from, 1) : Ft(s, i2.to, -1)) && o.matched ? l = e2 ? o.end.to : o.end.from : l = e2 ? i2.to : i2.from, b$2.cursor(l, e2 ? -1 : 1);
}
const fp = (s) => Rt(s, (t2) => Bn(s.state, t2, !ft(s))), up = (s) => Rt(s, (t2) => Bn(s.state, t2, ft(s)));
function Nh(s, t2) {
return Rt(s, (e2) => {
if (!e2.empty)
return Pn(e2, t2);
let i2 = s.moveVertically(e2, t2);
return i2.head != e2.head ? i2 : s.moveToLineBoundary(e2, t2);
});
}
const Vh = (s) => Nh(s, false), Ih = (s) => Nh(s, true);
function Hh(s) {
return Math.max(s.defaultLineHeight, Math.min(s.dom.clientHeight, innerHeight) - 5);
}
function $h(s, t2) {
let { state: e2 } = s, i2 = Ye(e2.selection, (l) => l.empty ? s.moveVertically(l, t2, Hh(s)) : Pn(l, t2));
if (i2.eq(e2.selection))
return false;
let n2 = s.coordsAtPos(e2.selection.main.head), r2 = s.scrollDOM.getBoundingClientRect(), o;
return n2 && n2.top > r2.top && n2.bottom < r2.bottom && n2.top - r2.top <= s.scrollDOM.scrollHeight - s.scrollDOM.scrollTop - s.scrollDOM.clientHeight && (o = A$2.scrollIntoView(i2.main.head, { y: "start", yMargin: n2.top - r2.top })), s.dispatch(Kt(e2, i2), { effects: o }), true;
}
const vo = (s) => $h(s, false), Hs = (s) => $h(s, true);
function be(s, t2, e2) {
let i2 = s.lineBlockAt(t2.head), n2 = s.moveToLineBoundary(t2, e2);
if (n2.head == t2.head && n2.head != (e2 ? i2.to : i2.from) && (n2 = s.moveToLineBoundary(t2, e2, false)), !e2 && n2.head == i2.from && i2.length) {
let r2 = /^\s*/.exec(s.state.sliceDoc(i2.from, Math.min(i2.from + 100, i2.to)))[0].length;
r2 && t2.head != i2.from + r2 && (n2 = b$2.cursor(i2.from + r2));
}
return n2;
}
const dp = (s) => Rt(s, (t2) => be(s, t2, true)), pp = (s) => Rt(s, (t2) => be(s, t2, false)), gp = (s) => Rt(s, (t2) => be(s, t2, !ft(s))), mp = (s) => Rt(s, (t2) => be(s, t2, ft(s))), wp = (s) => Rt(s, (t2) => b$2.cursor(s.lineBlockAt(t2.head).from, 1)), yp = (s) => Rt(s, (t2) => b$2.cursor(s.lineBlockAt(t2.head).to, -1));
function bp(s, t2, e2) {
let i2 = false, n2 = Ye(s.selection, (r2) => {
let o = Ft(s, r2.head, -1) || Ft(s, r2.head, 1) || r2.head > 0 && Ft(s, r2.head - 1, 1) || r2.head < s.doc.length && Ft(s, r2.head + 1, -1);
if (!o || !o.end)
return r2;
i2 = true;
let l = o.start.from == r2.head ? o.end.to : o.end.from;
return e2 ? b$2.range(r2.anchor, l) : b$2.cursor(l);
});
return i2 ? (t2(Kt(s, n2)), true) : false;
}
const kp = ({ state: s, dispatch: t2 }) => bp(s, t2, false);
function At(s, t2) {
let e2 = Ye(s.state.selection, (i2) => {
let n2 = t2(i2);
return b$2.range(i2.anchor, n2.head, n2.goalColumn, n2.bidiLevel || void 0);
});
return e2.eq(s.state.selection) ? false : (s.dispatch(Kt(s.state, e2)), true);
}
function Fh(s, t2) {
return At(s, (e2) => s.moveByChar(e2, t2));
}
const zh = (s) => Fh(s, !ft(s)), _h = (s) => Fh(s, ft(s));
function Wh(s, t2) {
return At(s, (e2) => s.moveByGroup(e2, t2));
}
const xp = (s) => Wh(s, !ft(s)), vp = (s) => Wh(s, ft(s)), Sp = (s) => At(s, (t2) => Bn(s.state, t2, !ft(s))), Cp = (s) => At(s, (t2) => Bn(s.state, t2, ft(s)));
function jh(s, t2) {
return At(s, (e2) => s.moveVertically(e2, t2));
}
const qh = (s) => jh(s, false), Kh = (s) => jh(s, true);
function Gh(s, t2) {
return At(s, (e2) => s.moveVertically(e2, t2, Hh(s)));
}
const So = (s) => Gh(s, false), Co = (s) => Gh(s, true), Ap = (s) => At(s, (t2) => be(s, t2, true)), Op = (s) => At(s, (t2) => be(s, t2, false)), Mp = (s) => At(s, (t2) => be(s, t2, !ft(s))), Dp = (s) => At(s, (t2) => be(s, t2, ft(s))), Tp = (s) => At(s, (t2) => b$2.cursor(s.lineBlockAt(t2.head).from)), Pp = (s) => At(s, (t2) => b$2.cursor(s.lineBlockAt(t2.head).to)), Ao = ({ state: s, dispatch: t2 }) => (t2(Kt(s, { anchor: 0 })), true), Oo = ({ state: s, dispatch: t2 }) => (t2(Kt(s, { anchor: s.doc.length })), true), Mo = ({ state: s, dispatch: t2 }) => (t2(Kt(s, { anchor: s.selection.main.anchor, head: 0 })), true), Do = ({ state: s, dispatch: t2 }) => (t2(Kt(s, { anchor: s.selection.main.anchor, head: s.doc.length })), true), Bp = ({ state: s, dispatch: t2 }) => (t2(s.update({ selection: { anchor: 0, head: s.doc.length }, userEvent: "select" })), true), Rp = ({ state: s, dispatch: t2 }) => {
let e2 = Ln(s).map(({ from: i2, to: n2 }) => b$2.range(i2, Math.min(n2 + 1, s.doc.length)));
return t2(s.update({ selection: b$2.create(e2), userEvent: "select" })), true;
}, Lp = ({ state: s, dispatch: t2 }) => {
let e2 = Ye(s.selection, (i2) => {
var n2;
let r2 = St(s).resolveInner(i2.head, 1);
for (; !(r2.from < i2.from && r2.to >= i2.to || r2.to > i2.to && r2.from <= i2.from || !(!((n2 = r2.parent) === null || n2 === void 0) && n2.parent)); )
r2 = r2.parent;
return b$2.range(r2.to, r2.from);
});
return t2(Kt(s, e2)), true;
}, Ep = ({ state: s, dispatch: t2 }) => {
let e2 = s.selection, i2 = null;
return e2.ranges.length > 1 ? i2 = b$2.create([e2.main]) : e2.main.empty || (i2 = b$2.create([b$2.cursor(e2.main.head)])), i2 ? (t2(Kt(s, i2)), true) : false;
};
function Rn(s, t2) {
if (s.state.readOnly)
return false;
let e2 = "delete.selection", { state: i2 } = s, n2 = i2.changeByRange((r2) => {
let { from: o, to: l } = r2;
if (o == l) {
let h2 = t2(o);
h2 < o ? (e2 = "delete.backward", h2 = Fi(s, h2, false)) : h2 > o && (e2 = "delete.forward", h2 = Fi(s, h2, true)), o = Math.min(o, h2), l = Math.max(l, h2);
} else
o = Fi(s, o, false), l = Fi(s, l, true);
return o == l ? { range: r2 } : { changes: { from: o, to: l }, range: b$2.cursor(o) };
});
return n2.changes.empty ? false : (s.dispatch(i2.update(n2, {
scrollIntoView: true,
userEvent: e2,
effects: e2 == "delete.selection" ? A$2.announce.of(i2.phrase("Selection deleted")) : void 0
})), true);
}
function Fi(s, t2, e2) {
if (s instanceof A$2)
for (let i2 of s.state.facet(A$2.atomicRanges).map((n2) => n2(s)))
i2.between(t2, t2, (n2, r2) => {
n2 < t2 && r2 > t2 && (t2 = e2 ? r2 : n2);
});
return t2;
}
const Uh = (s, t2) => Rn(s, (e2) => {
let { state: i2 } = s, n2 = i2.doc.lineAt(e2), r2, o;
if (!t2 && e2 > n2.from && e2 < n2.from + 200 && !/[^ \t]/.test(r2 = n2.text.slice(0, e2 - n2.from))) {
if (r2[r2.length - 1] == " ")
return e2 - 1;
let l = Cn(r2, i2.tabSize), h2 = l % mn(i2) || mn(i2);
for (let a2 = 0; a2 < h2 && r2[r2.length - 1 - a2] == " "; a2++)
e2--;
o = e2;
} else
o = xt(n2.text, e2 - n2.from, t2, t2) + n2.from, o == e2 && n2.number != (t2 ? i2.doc.lines : 1) && (o += t2 ? 1 : -1);
return o;
}), $s = (s) => Uh(s, false), Qh = (s) => Uh(s, true), Jh = (s, t2) => Rn(s, (e2) => {
let i2 = e2, { state: n2 } = s, r2 = n2.doc.lineAt(i2), o = n2.charCategorizer(i2);
for (let l = null; ; ) {
if (i2 == (t2 ? r2.to : r2.from)) {
i2 == e2 && r2.number != (t2 ? n2.doc.lines : 1) && (i2 += t2 ? 1 : -1);
break;
}
let h2 = xt(r2.text, i2 - r2.from, t2) + r2.from, a2 = r2.text.slice(Math.min(i2, h2) - r2.from, Math.max(i2, h2) - r2.from), c2 = o(a2);
if (l != null && c2 != l)
break;
(a2 != " " || i2 != e2) && (l = c2), i2 = h2;
}
return i2;
}), Xh = (s) => Jh(s, false), Np = (s) => Jh(s, true), Yh = (s) => Rn(s, (t2) => {
let e2 = s.lineBlockAt(t2).to;
return t2 < e2 ? e2 : Math.min(s.state.doc.length, t2 + 1);
}), Vp = (s) => Rn(s, (t2) => {
let e2 = s.lineBlockAt(t2).from;
return t2 > e2 ? e2 : Math.max(0, t2 - 1);
}), Ip = ({ state: s, dispatch: t2 }) => {
if (s.readOnly)
return false;
let e2 = s.changeByRange((i2) => ({
changes: { from: i2.from, to: i2.to, insert: E$1.of(["", ""]) },
range: b$2.cursor(i2.from)
}));
return t2(s.update(e2, { scrollIntoView: true, userEvent: "input" })), true;
}, Hp = ({ state: s, dispatch: t2 }) => {
if (s.readOnly)
return false;
let e2 = s.changeByRange((i2) => {
if (!i2.empty || i2.from == 0 || i2.from == s.doc.length)
return { range: i2 };
let n2 = i2.from, r2 = s.doc.lineAt(n2), o = n2 == r2.from ? n2 - 1 : xt(r2.text, n2 - r2.from, false) + r2.from, l = n2 == r2.to ? n2 + 1 : xt(r2.text, n2 - r2.from, true) + r2.from;
return {
changes: { from: o, to: l, insert: s.doc.slice(n2, l).append(s.doc.slice(o, n2)) },
range: b$2.cursor(l)
};
});
return e2.changes.empty ? false : (t2(s.update(e2, { scrollIntoView: true, userEvent: "move.character" })), true);
};
function Ln(s) {
let t2 = [], e2 = -1;
for (let i2 of s.selection.ranges) {
let n2 = s.doc.lineAt(i2.from), r2 = s.doc.lineAt(i2.to);
if (!i2.empty && i2.to == r2.from && (r2 = s.doc.lineAt(i2.to - 1)), e2 >= n2.number) {
let o = t2[t2.length - 1];
o.to = r2.to, o.ranges.push(i2);
} else
t2.push({ from: n2.from, to: r2.to, ranges: [i2] });
e2 = r2.number + 1;
}
return t2;
}
function Zh(s, t2, e2) {
if (s.readOnly)
return false;
let i2 = [], n2 = [];
for (let r2 of Ln(s)) {
if (e2 ? r2.to == s.doc.length : r2.from == 0)
continue;
let o = s.doc.lineAt(e2 ? r2.to + 1 : r2.from - 1), l = o.length + 1;
if (e2) {
i2.push({ from: r2.to, to: o.to }, { from: r2.from, insert: o.text + s.lineBreak });
for (let h2 of r2.ranges)
n2.push(b$2.range(Math.min(s.doc.length, h2.anchor + l), Math.min(s.doc.length, h2.head + l)));
} else {
i2.push({ from: o.from, to: r2.from }, { from: r2.to, insert: s.lineBreak + o.text });
for (let h2 of r2.ranges)
n2.push(b$2.range(h2.anchor - l, h2.head - l));
}
}
return i2.length ? (t2(s.update({
changes: i2,
scrollIntoView: true,
selection: b$2.create(n2, s.selection.mainIndex),
userEvent: "move.line"
})), true) : false;
}
const $p = ({ state: s, dispatch: t2 }) => Zh(s, t2, false), Fp = ({ state: s, dispatch: t2 }) => Zh(s, t2, true);
function ta(s, t2, e2) {
if (s.readOnly)
return false;
let i2 = [];
for (let n2 of Ln(s))
e2 ? i2.push({ from: n2.from, insert: s.doc.slice(n2.from, n2.to) + s.lineBreak }) : i2.push({ from: n2.to, insert: s.lineBreak + s.doc.slice(n2.from, n2.to) });
return t2(s.update({ changes: i2, scrollIntoView: true, userEvent: "input.copyline" })), true;
}
const zp = ({ state: s, dispatch: t2 }) => ta(s, t2, false), _p = ({ state: s, dispatch: t2 }) => ta(s, t2, true), Wp = (s) => {
if (s.state.readOnly)
return false;
let { state: t2 } = s, e2 = t2.changes(Ln(t2).map(({ from: n2, to: r2 }) => (n2 > 0 ? n2-- : r2 < t2.doc.length && r2++, { from: n2, to: r2 }))), i2 = Ye(t2.selection, (n2) => s.moveVertically(n2, true)).map(e2);
return s.dispatch({ changes: e2, selection: i2, scrollIntoView: true, userEvent: "delete.line" }), true;
};
function jp(s, t2) {
if (/\(\)|\[\]|\{\}/.test(s.sliceDoc(t2 - 1, t2 + 1)))
return { from: t2, to: t2 };
let e2 = St(s).resolveInner(t2), i2 = e2.childBefore(t2), n2 = e2.childAfter(t2), r2;
return i2 && n2 && i2.to <= t2 && n2.from >= t2 && (r2 = i2.type.prop(P$1.closedBy)) && r2.indexOf(n2.name) > -1 && s.doc.lineAt(i2.to).from == s.doc.lineAt(n2.from).from ? { from: i2.to, to: n2.from } : null;
}
const qp = /* @__PURE__ */ ea(false), Kp = /* @__PURE__ */ ea(true);
function ea(s) {
return ({ state: t2, dispatch: e2 }) => {
if (t2.readOnly)
return false;
let i2 = t2.changeByRange((n2) => {
let { from: r2, to: o } = n2, l = t2.doc.lineAt(r2), h2 = !s && r2 == o && jp(t2, r2);
s && (r2 = o = (o <= l.to ? l : t2.doc.lineAt(o)).to);
let a2 = new Dn(t2, { simulateBreak: r2, simulateDoubleBreak: !!h2 }), c2 = sr(a2, r2);
for (c2 == null && (c2 = /^\s*/.exec(t2.doc.lineAt(r2).text)[0].length); o < l.to && /\s/.test(l.text[o - l.from]); )
o++;
h2 ? { from: r2, to: o } = h2 : r2 > l.from && r2 < l.from + 100 && !/\S/.test(l.text.slice(0, r2)) && (r2 = l.from);
let f2 = ["", wi(t2, c2)];
return h2 && f2.push(wi(t2, a2.lineIndent(l.from, -1))), {
changes: { from: r2, to: o, insert: E$1.of(f2) },
range: b$2.cursor(r2 + 1 + f2[1].length)
};
});
return e2(t2.update(i2, { scrollIntoView: true, userEvent: "input" })), true;
};
}
function hr(s, t2) {
let e2 = -1;
return s.changeByRange((i2) => {
let n2 = [];
for (let o = i2.from; o <= i2.to; ) {
let l = s.doc.lineAt(o);
l.number > e2 && (i2.empty || i2.to > l.from) && (t2(l, n2, i2), e2 = l.number), o = l.to + 1;
}
let r2 = s.changes(n2);
return {
changes: n2,
range: b$2.range(r2.mapPos(i2.anchor, 1), r2.mapPos(i2.head, 1))
};
});
}
const Gp = ({ state: s, dispatch: t2 }) => {
if (s.readOnly)
return false;
let e2 = /* @__PURE__ */ Object.create(null), i2 = new Dn(s, { overrideIndentation: (r2) => {
let o = e2[r2];
return o ?? -1;
} }), n2 = hr(s, (r2, o, l) => {
let h2 = sr(i2, r2.from);
if (h2 == null)
return;
/\S/.test(r2.text) || (h2 = 0);
let a2 = /^\s*/.exec(r2.text)[0], c2 = wi(s, h2);
(a2 != c2 || l.from < r2.from + a2.length) && (e2[r2.from] = h2, o.push({ from: r2.from, to: r2.from + a2.length, insert: c2 }));
});
return n2.changes.empty || t2(s.update(n2, { userEvent: "indent" })), true;
}, Up = ({ state: s, dispatch: t2 }) => s.readOnly ? false : (t2(s.update(hr(s, (e2, i2) => {
i2.push({ from: e2.from, insert: s.facet(nr) });
}), { userEvent: "input.indent" })), true), Qp = ({ state: s, dispatch: t2 }) => s.readOnly ? false : (t2(s.update(hr(s, (e2, i2) => {
let n2 = /^\s*/.exec(e2.text)[0];
if (!n2)
return;
let r2 = Cn(n2, s.tabSize), o = 0, l = wi(s, Math.max(0, r2 - mn(s)));
for (; o < n2.length && o < l.length && n2.charCodeAt(o) == l.charCodeAt(o); )
o++;
i2.push({ from: e2.from + o, to: e2.from + n2.length, insert: l.slice(o) });
}), { userEvent: "delete.dedent" })), true), Jp = [
{ key: "Ctrl-b", run: Rh, shift: zh, preventDefault: true },
{ key: "Ctrl-f", run: Lh, shift: _h },
{ key: "Ctrl-p", run: Vh, shift: qh },
{ key: "Ctrl-n", run: Ih, shift: Kh },
{ key: "Ctrl-a", run: wp, shift: Tp },
{ key: "Ctrl-e", run: yp, shift: Pp },
{ key: "Ctrl-d", run: Qh },
{ key: "Ctrl-h", run: $s },
{ key: "Ctrl-k", run: Yh },
{ key: "Ctrl-Alt-h", run: Xh },
{ key: "Ctrl-o", run: Ip },
{ key: "Ctrl-t", run: Hp },
{ key: "Ctrl-v", run: Hs }
], Xp = /* @__PURE__ */ [
{ key: "ArrowLeft", run: Rh, shift: zh, preventDefault: true },
{ key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: hp, shift: xp, preventDefault: true },
{ mac: "Cmd-ArrowLeft", run: gp, shift: Mp, preventDefault: true },
{ key: "ArrowRight", run: Lh, shift: _h, preventDefault: true },
{ key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: ap, shift: vp, preventDefault: true },
{ mac: "Cmd-ArrowRight", run: mp, shift: Dp, preventDefault: true },
{ key: "ArrowUp", run: Vh, shift: qh, preventDefault: true },
{ mac: "Cmd-ArrowUp", run: Ao, shift: Mo },
{ mac: "Ctrl-ArrowUp", run: vo, shift: So },
{ key: "ArrowDown", run: Ih, shift: Kh, preventDefault: true },
{ mac: "Cmd-ArrowDown", run: Oo, shift: Do },
{ mac: "Ctrl-ArrowDown", run: Hs, shift: Co },
{ key: "PageUp", run: vo, shift: So },
{ key: "PageDown", run: Hs, shift: Co },
{ key: "Home", run: pp, shift: Op, preventDefault: true },
{ key: "Mod-Home", run: Ao, shift: Mo },
{ key: "End", run: dp, shift: Ap, preventDefault: true },
{ key: "Mod-End", run: Oo, shift: Do },
{ key: "Enter", run: qp },
{ key: "Mod-a", run: Bp },
{ key: "Backspace", run: $s, shift: $s },
{ key: "Delete", run: Qh },
{ key: "Mod-Backspace", mac: "Alt-Backspace", run: Xh },
{ key: "Mod-Delete", mac: "Alt-Delete", run: Np },
{ mac: "Mod-Backspace", run: Vp },
{ mac: "Mod-Delete", run: Yh }
].concat(/* @__PURE__ */ Jp.map((s) => ({ mac: s.key, run: s.run, shift: s.shift }))), Yp = /* @__PURE__ */ [
{ key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: fp, shift: Sp },
{ key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: up, shift: Cp },
{ key: "Alt-ArrowUp", run: $p },
{ key: "Shift-Alt-ArrowUp", run: zp },
{ key: "Alt-ArrowDown", run: Fp },
{ key: "Shift-Alt-ArrowDown", run: _p },
{ key: "Escape", run: Ep },
{ key: "Mod-Enter", run: Kp },
{ key: "Alt-l", mac: "Ctrl-l", run: Rp },
{ key: "Mod-i", run: Lp, preventDefault: true },
{ key: "Mod-[", run: Qp },
{ key: "Mod-]", run: Up },
{ key: "Mod-Alt-\\", run: Gp },
{ key: "Shift-Mod-k", run: Wp },
{ key: "Shift-Mod-\\", run: kp },
{ key: "Mod-/", run: ep },
{ key: "Alt-A", run: np }
].concat(Xp);
class bn {
/// @internal
constructor(t2, e2, i2, n2, r2, o, l, h2, a2, c2 = 0, f2) {
this.p = t2, this.stack = e2, this.state = i2, this.reducePos = n2, this.pos = r2, this.score = o, this.buffer = l, this.bufferBase = h2, this.curContext = a2, this.lookAhead = c2, this.parent = f2;
}
/// @internal
toString() {
return `[${this.stack.filter((t2, e2) => e2 % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
}
// Start an empty stack
/// @internal
static start(t2, e2, i2 = 0) {
let n2 = t2.parser.context;
return new bn(t2, [], e2, i2, i2, 0, [], 0, n2 ? new To(n2, n2.start) : null, 0, null);
}
/// The stack's current [context](#lr.ContextTracker) value, if
/// any. Its type will depend on the context tracker's type
/// parameter, or it will be `null` if there is no context
/// tracker.
get context() {
return this.curContext ? this.curContext.context : null;
}
// Push a state onto the stack, tracking its start position as well
// as the buffer base at that point.
/// @internal
pushState(t2, e2) {
this.stack.push(this.state, e2, this.bufferBase + this.buffer.length), this.state = t2;
}
// Apply a reduce action
/// @internal
reduce(t2) {
var e2;
let i2 = t2 >> 19, n2 = t2 & 65535, { parser: r2 } = this.p, o = r2.dynamicPrecedence(n2);
if (o && (this.score += o), i2 == 0) {
this.pushState(r2.getGoto(this.state, n2, true), this.reducePos), n2 < r2.minRepeatTerm && this.storeNode(n2, this.reducePos, this.reducePos, 4, true), this.reduceContext(n2, this.reducePos);
return;
}
let l = this.stack.length - (i2 - 1) * 3 - (t2 & 262144 ? 6 : 0), h2 = l ? this.stack[l - 2] : this.p.ranges[0].from, a2 = this.reducePos - h2;
a2 >= 2e3 && !(!((e2 = this.p.parser.nodeSet.types[n2]) === null || e2 === void 0) && e2.isAnonymous) && (h2 == this.p.lastBigReductionStart ? (this.p.bigReductionCount++, this.p.lastBigReductionSize = a2) : this.p.lastBigReductionSize < a2 && (this.p.bigReductionCount = 1, this.p.lastBigReductionStart = h2, this.p.lastBigReductionSize = a2));
let c2 = l ? this.stack[l - 1] : 0, f2 = this.bufferBase + this.buffer.length - c2;
if (n2 < r2.minRepeatTerm || t2 & 131072) {
let u2 = r2.stateFlag(
this.state,
1
/* StateFlag.Skipped */
) ? this.pos : this.reducePos;
this.storeNode(n2, h2, u2, f2 + 4, true);
}
if (t2 & 262144)
this.state = this.stack[l];
else {
let u2 = this.stack[l - 3];
this.state = r2.getGoto(u2, n2, true);
}
for (; this.stack.length > l; )
this.stack.pop();
this.reduceContext(n2, h2);
}
// Shift a value into the buffer
/// @internal
storeNode(t2, e2, i2, n2 = 4, r2 = false) {
if (t2 == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
let o = this, l = this.buffer.length;
if (l == 0 && o.parent && (l = o.bufferBase - o.parent.bufferBase, o = o.parent), l > 0 && o.buffer[l - 4] == 0 && o.buffer[l - 1] > -1) {
if (e2 == i2)
return;
if (o.buffer[l - 2] >= e2) {
o.buffer[l - 2] = i2;
return;
}
}
}
if (!r2 || this.pos == i2)
this.buffer.push(t2, e2, i2, n2);
else {
let o = this.buffer.length;
if (o > 0 && this.buffer[o - 4] != 0)
for (; o > 0 && this.buffer[o - 2] > i2; )
this.buffer[o] = this.buffer[o - 4], this.buffer[o + 1] = this.buffer[o - 3], this.buffer[o + 2] = this.buffer[o - 2], this.buffer[o + 3] = this.buffer[o - 1], o -= 4, n2 > 4 && (n2 -= 4);
this.buffer[o] = t2, this.buffer[o + 1] = e2, this.buffer[o + 2] = i2, this.buffer[o + 3] = n2;
}
}
// Apply a shift action
/// @internal
shift(t2, e2, i2) {
let n2 = this.pos;
if (t2 & 131072)
this.pushState(t2 & 65535, this.pos);
else if (t2 & 262144)
this.pos = i2, this.shiftContext(e2, n2), e2 <= this.p.parser.maxNode && this.buffer.push(e2, n2, i2, 4);
else {
let r2 = t2, { parser: o } = this.p;
(i2 > this.pos || e2 <= o.maxNode) && (this.pos = i2, o.stateFlag(
r2,
1
/* StateFlag.Skipped */
) || (this.reducePos = i2)), this.pushState(r2, n2), this.shiftContext(e2, n2), e2 <= o.maxNode && this.buffer.push(e2, n2, i2, 4);
}
}
// Apply an action
/// @internal
apply(t2, e2, i2) {
t2 & 65536 ? this.reduce(t2) : this.shift(t2, e2, i2);
}
// Add a prebuilt (reused) node into the buffer.
/// @internal
useNode(t2, e2) {
let i2 = this.p.reused.length - 1;
(i2 < 0 || this.p.reused[i2] != t2) && (this.p.reused.push(t2), i2++);
let n2 = this.pos;
this.reducePos = this.pos = n2 + t2.length, this.pushState(e2, n2), this.buffer.push(
i2,
n2,
this.reducePos,
-1
/* size == -1 means this is a reused value */
), this.curContext && this.updateContext(this.curContext.tracker.reuse(this.curContext.context, t2, this, this.p.stream.reset(this.pos - t2.length)));
}
// Split the stack. Due to the buffer sharing and the fact
// that `this.stack` tends to stay quite shallow, this isn't very
// expensive.
/// @internal
split() {
let t2 = this, e2 = t2.buffer.length;
for (; e2 > 0 && t2.buffer[e2 - 2] > t2.reducePos; )
e2 -= 4;
let i2 = t2.buffer.slice(e2), n2 = t2.bufferBase + e2;
for (; t2 && n2 == t2.bufferBase; )
t2 = t2.parent;
return new bn(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, i2, n2, this.curContext, this.lookAhead, t2);
}
// Try to recover from an error by 'deleting' (ignoring) one token.
/// @internal
recoverByDelete(t2, e2) {
let i2 = t2 <= this.p.parser.maxNode;
i2 && this.storeNode(t2, this.pos, e2, 4), this.storeNode(0, this.pos, e2, i2 ? 8 : 4), this.pos = this.reducePos = e2, this.score -= 190;
}
/// Check if the given term would be able to be shifted (optionally
/// after some reductions) on this stack. This can be useful for
/// external tokenizers that want to make sure they only provide a
/// given token when it applies.
canShift(t2) {
for (let e2 = new Zp(this); ; ) {
let i2 = this.p.parser.stateSlot(
e2.state,
4
/* ParseState.DefaultReduce */
) || this.p.parser.hasAction(e2.state, t2);
if (i2 == 0)
return false;
if (!(i2 & 65536))
return true;
e2.reduce(i2);
}
}
// Apply up to Recover.MaxNext recovery actions that conceptually
// inserts some missing token or rule.
/// @internal
recoverByInsert(t2) {
if (this.stack.length >= 300)
return [];
let e2 = this.p.parser.nextStates(this.state);
if (e2.length > 4 << 1 || this.stack.length >= 120) {
let n2 = [];
for (let r2 = 0, o; r2 < e2.length; r2 += 2)
(o = e2[r2 + 1]) != this.state && this.p.parser.hasAction(o, t2) && n2.push(e2[r2], o);
if (this.stack.length < 120)
for (let r2 = 0; n2.length < 4 << 1 && r2 < e2.length; r2 += 2) {
let o = e2[r2 + 1];
n2.some((l, h2) => h2 & 1 && l == o) || n2.push(e2[r2], o);
}
e2 = n2;
}
let i2 = [];
for (let n2 = 0; n2 < e2.length && i2.length < 4; n2 += 2) {
let r2 = e2[n2 + 1];
if (r2 == this.state)
continue;
let o = this.split();
o.pushState(r2, this.pos), o.storeNode(0, o.pos, o.pos, 4, true), o.shiftContext(e2[n2], this.pos), o.score -= 200, i2.push(o);
}
return i2;
}
// Force a reduce, if possible. Return false if that can't
// be done.
/// @internal
forceReduce() {
let t2 = this.p.parser.stateSlot(
this.state,
5
/* ParseState.ForcedReduce */
);
if (!(t2 & 65536))
return false;
let { parser: e2 } = this.p;
if (!e2.validAction(this.state, t2)) {
let i2 = t2 >> 19, n2 = t2 & 65535, r2 = this.stack.length - i2 * 3;
if (r2 < 0 || e2.getGoto(this.stack[r2], n2, false) < 0)
return false;
this.storeNode(0, this.reducePos, this.reducePos, 4, true), this.score -= 100;
}
return this.reducePos = this.pos, this.reduce(t2), true;
}
/// @internal
forceAll() {
for (; !this.p.parser.stateFlag(
this.state,
2
/* StateFlag.Accepting */
); )
if (!this.forceReduce()) {
this.storeNode(0, this.pos, this.pos, 4, true);
break;
}
return this;
}
/// Check whether this state has no further actions (assumed to be a direct descendant of the
/// top state, since any other states must be able to continue
/// somehow). @internal
get deadEnd() {
if (this.stack.length != 3)
return false;
let { parser: t2 } = this.p;
return t2.data[t2.stateSlot(
this.state,
1
/* ParseState.Actions */
)] == 65535 && !t2.stateSlot(
this.state,
4
/* ParseState.DefaultReduce */
);
}
/// Restart the stack (put it back in its start state). Only safe
/// when this.stack.length == 3 (state is directly below the top
/// state). @internal
restart() {
this.state = this.stack[0], this.stack.length = 0;
}
/// @internal
sameState(t2) {
if (this.state != t2.state || this.stack.length != t2.stack.length)
return false;
for (let e2 = 0; e2 < this.stack.length; e2 += 3)
if (this.stack[e2] != t2.stack[e2])
return false;
return true;
}
/// Get the parser used by this stack.
get parser() {
return this.p.parser;
}
/// Test whether a given dialect (by numeric ID, as exported from
/// the terms file) is enabled.
dialectEnabled(t2) {
return this.p.parser.dialect.flags[t2];
}
shiftContext(t2, e2) {
this.curContext && this.updateContext(this.curContext.tracker.shift(this.curContext.context, t2, this, this.p.stream.reset(e2)));
}
reduceContext(t2, e2) {
this.curContext && this.updateContext(this.curContext.tracker.reduce(this.curContext.context, t2, this, this.p.stream.reset(e2)));
}
/// @internal
emitContext() {
let t2 = this.buffer.length - 1;
(t2 < 0 || this.buffer[t2] != -3) && this.buffer.push(this.curContext.hash, this.reducePos, this.reducePos, -3);
}
/// @internal
emitLookAhead() {
let t2 = this.buffer.length - 1;
(t2 < 0 || this.buffer[t2] != -4) && this.buffer.push(this.lookAhead, this.reducePos, this.reducePos, -4);
}
updateContext(t2) {
if (t2 != this.curContext.context) {
let e2 = new To(this.curContext.tracker, t2);
e2.hash != this.curContext.hash && this.emitContext(), this.curContext = e2;
}
}
/// @internal
setLookAhead(t2) {
t2 > this.lookAhead && (this.emitLookAhead(), this.lookAhead = t2);
}
/// @internal
close() {
this.curContext && this.curContext.tracker.strict && this.emitContext(), this.lookAhead > 0 && this.emitLookAhead();
}
}
class To {
constructor(t2, e2) {
this.tracker = t2, this.context = e2, this.hash = t2.strict ? t2.hash(e2) : 0;
}
}
var Po;
(function(s) {
s[s.Insert = 200] = "Insert", s[s.Delete = 190] = "Delete", s[s.Reduce = 100] = "Reduce", s[s.MaxNext = 4] = "MaxNext", s[s.MaxInsertStackDepth = 300] = "MaxInsertStackDepth", s[s.DampenInsertStackDepth = 120] = "DampenInsertStackDepth", s[s.MinBigReduction = 2e3] = "MinBigReduction";
})(Po || (Po = {}));
class Zp {
constructor(t2) {
this.start = t2, this.state = t2.state, this.stack = t2.stack, this.base = this.stack.length;
}
reduce(t2) {
let e2 = t2 & 65535, i2 = t2 >> 19;
i2 == 0 ? (this.stack == this.start.stack && (this.stack = this.stack.slice()), this.stack.push(this.state, 0, 0), this.base += 3) : this.base -= (i2 - 1) * 3;
let n2 = this.start.p.parser.getGoto(this.stack[this.base - 3], e2, true);
this.state = n2;
}
}
class kn {
constructor(t2, e2, i2) {
this.stack = t2, this.pos = e2, this.index = i2, this.buffer = t2.buffer, this.index == 0 && this.maybeNext();
}
static create(t2, e2 = t2.bufferBase + t2.buffer.length) {
return new kn(t2, e2, e2 - t2.bufferBase);
}
maybeNext() {
let t2 = this.stack.parent;
t2 != null && (this.index = this.stack.bufferBase - t2.bufferBase, this.stack = t2, this.buffer = t2.buffer);
}
get id() {
return this.buffer[this.index - 4];
}
get start() {
return this.buffer[this.index - 3];
}
get end() {
return this.buffer[this.index - 2];
}
get size() {
return this.buffer[this.index - 1];
}
next() {
this.index -= 4, this.pos -= 4, this.index == 0 && this.maybeNext();
}
fork() {
return new kn(this.stack, this.pos, this.index);
}
}
function zi(s, t2 = Uint16Array) {
if (typeof s != "string")
return s;
let e2 = null;
for (let i2 = 0, n2 = 0; i2 < s.length; ) {
let r2 = 0;
for (; ; ) {
let o = s.charCodeAt(i2++), l = false;
if (o == 126) {
r2 = 65535;
break;
}
o >= 92 && o--, o >= 34 && o--;
let h2 = o - 32;
if (h2 >= 46 && (h2 -= 46, l = true), r2 += h2, l)
break;
r2 *= 46;
}
e2 ? e2[n2++] = r2 : e2 = new t2(r2);
}
return e2;
}
class Ji {
constructor() {
this.start = -1, this.value = -1, this.end = -1, this.extended = -1, this.lookAhead = 0, this.mask = 0, this.context = 0;
}
}
const Bo = new Ji();
class tg {
/// @internal
constructor(t2, e2) {
this.input = t2, this.ranges = e2, this.chunk = "", this.chunkOff = 0, this.chunk2 = "", this.chunk2Pos = 0, this.next = -1, this.token = Bo, this.rangeIndex = 0, this.pos = this.chunkPos = e2[0].from, this.range = e2[0], this.end = e2[e2.length - 1].to, this.readNext();
}
/// @internal
resolveOffset(t2, e2) {
let i2 = this.range, n2 = this.rangeIndex, r2 = this.pos + t2;
for (; r2 < i2.from; ) {
if (!n2)
return null;
let o = this.ranges[--n2];
r2 -= i2.from - o.to, i2 = o;
}
for (; e2 < 0 ? r2 > i2.to : r2 >= i2.to; ) {
if (n2 == this.ranges.length - 1)
return null;
let o = this.ranges[++n2];
r2 += o.from - i2.to, i2 = o;
}
return r2;
}
/// @internal
clipPos(t2) {
if (t2 >= this.range.from && t2 < this.range.to)
return t2;
for (let e2 of this.ranges)
if (e2.to > t2)
return Math.max(t2, e2.from);
return this.end;
}
/// Look at a code unit near the stream position. `.peek(0)` equals
/// `.next`, `.peek(-1)` gives you the previous character, and so
/// on.
///
/// Note that looking around during tokenizing creates dependencies
/// on potentially far-away content, which may reduce the
/// effectiveness incremental parsing—when looking forward—or even
/// cause invalid reparses when looking backward more than 25 code
/// units, since the library does not track lookbehind.
peek(t2) {
let e2 = this.chunkOff + t2, i2, n2;
if (e2 >= 0 && e2 < this.chunk.length)
i2 = this.pos + t2, n2 = this.chunk.charCodeAt(e2);
else {
let r2 = this.resolveOffset(t2, 1);
if (r2 == null)
return -1;
if (i2 = r2, i2 >= this.chunk2Pos && i2 < this.chunk2Pos + this.chunk2.length)
n2 = this.chunk2.charCodeAt(i2 - this.chunk2Pos);
else {
let o = this.rangeIndex, l = this.range;
for (; l.to <= i2; )
l = this.ranges[++o];
this.chunk2 = this.input.chunk(this.chunk2Pos = i2), i2 + this.chunk2.length > l.to && (this.chunk2 = this.chunk2.slice(0, l.to - i2)), n2 = this.chunk2.charCodeAt(0);
}
}
return i2 >= this.token.lookAhead && (this.token.lookAhead = i2 + 1), n2;
}
/// Accept a token. By default, the end of the token is set to the
/// current stream position, but you can pass an offset (relative to
/// the stream position) to change that.
acceptToken(t2, e2 = 0) {
let i2 = e2 ? this.resolveOffset(e2, -1) : this.pos;
if (i2 == null || i2 < this.token.start)
throw new RangeError("Token end out of bounds");
this.token.value = t2, this.token.end = i2;
}
getChunk() {
if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
let { chunk: t2, chunkPos: e2 } = this;
this.chunk = this.chunk2, this.chunkPos = this.chunk2Pos, this.chunk2 = t2, this.chunk2Pos = e2, this.chunkOff = this.pos - this.chunkPos;
} else {
this.chunk2 = this.chunk, this.chunk2Pos = this.chunkPos;
let t2 = this.input.chunk(this.pos), e2 = this.pos + t2.length;
this.chunk = e2 > this.range.to ? t2.slice(0, this.range.to - this.pos) : t2, this.chunkPos = this.pos, this.chunkOff = 0;
}
}
readNext() {
return this.chunkOff >= this.chunk.length && (this.getChunk(), this.chunkOff == this.chunk.length) ? this.next = -1 : this.next = this.chunk.charCodeAt(this.chunkOff);
}
/// Move the stream forward N (defaults to 1) code units. Returns
/// the new value of [`next`](#lr.InputStream.next).
advance(t2 = 1) {
for (this.chunkOff += t2; this.pos + t2 >= this.range.to; ) {
if (this.rangeIndex == this.ranges.length - 1)
return this.setDone();
t2 -= this.range.to - this.pos, this.range = this.ranges[++this.rangeIndex], this.pos = this.range.from;
}
return this.pos += t2, this.pos >= this.token.lookAhead && (this.token.lookAhead = this.pos + 1), this.readNext();
}
setDone() {
return this.pos = this.chunkPos = this.end, this.range = this.ranges[this.rangeIndex = this.ranges.length - 1], this.chunk = "", this.next = -1;
}
/// @internal
reset(t2, e2) {
if (e2 ? (this.token = e2, e2.start = t2, e2.lookAhead = t2 + 1, e2.value = e2.extended = -1) : this.token = Bo, this.pos != t2) {
if (this.pos = t2, t2 == this.end)
return this.setDone(), this;
for (; t2 < this.range.from; )
this.range = this.ranges[--this.rangeIndex];
for (; t2 >= this.range.to; )
this.range = this.ranges[++this.rangeIndex];
t2 >= this.chunkPos && t2 < this.chunkPos + this.chunk.length ? this.chunkOff = t2 - this.chunkPos : (this.chunk = "", this.chunkOff = 0), this.readNext();
}
return this;
}
/// @internal
read(t2, e2) {
if (t2 >= this.chunkPos && e2 <= this.chunkPos + this.chunk.length)
return this.chunk.slice(t2 - this.chunkPos, e2 - this.chunkPos);
if (t2 >= this.chunk2Pos && e2 <= this.chunk2Pos + this.chunk2.length)
return this.chunk2.slice(t2 - this.chunk2Pos, e2 - this.chunk2Pos);
if (t2 >= this.range.from && e2 <= this.range.to)
return this.input.read(t2, e2);
let i2 = "";
for (let n2 of this.ranges) {
if (n2.from >= e2)
break;
n2.to > t2 && (i2 += this.input.read(Math.max(n2.from, t2), Math.min(n2.to, e2)));
}
return i2;
}
}
class ze {
constructor(t2, e2) {
this.data = t2, this.id = e2;
}
token(t2, e2) {
let { parser: i2 } = e2.p;
eg(this.data, t2, e2, this.id, i2.data, i2.tokenPrecTable);
}
}
ze.prototype.contextual = ze.prototype.fallback = ze.prototype.extend = false;
ze.prototype.fallback = ze.prototype.extend = false;
function eg(s, t2, e2, i2, n2, r2) {
let o = 0, l = 1 << i2, { dialect: h2 } = e2.p.parser;
t:
for (; l & s[o]; ) {
let a2 = s[o + 1];
for (let d2 = o + 3; d2 < a2; d2 += 2)
if ((s[d2 + 1] & l) > 0) {
let p2 = s[d2];
if (h2.allows(p2) && (t2.token.value == -1 || t2.token.value == p2 || ig(p2, t2.token.value, n2, r2))) {
t2.acceptToken(p2);
break;
}
}
let c2 = t2.next, f2 = 0, u2 = s[o + 2];
if (t2.next < 0 && u2 > f2 && s[a2 + u2 * 3 - 3] == 65535 && s[a2 + u2 * 3 - 3] == 65535) {
o = s[a2 + u2 * 3 - 1];
continue t;
}
for (; f2 < u2; ) {
let d2 = f2 + u2 >> 1, p2 = a2 + d2 + (d2 << 1), w2 = s[p2], g = s[p2 + 1] || 65536;
if (c2 < w2)
u2 = d2;
else if (c2 >= g)
f2 = d2 + 1;
else {
o = s[p2 + 2], t2.advance();
continue t;
}
}
break;
}
}
function Ro(s, t2, e2) {
for (let i2 = t2, n2; (n2 = s[i2]) != 65535; i2++)
if (n2 == e2)
return i2 - t2;
return -1;
}
function ig(s, t2, e2, i2) {
let n2 = Ro(e2, i2, t2);
return n2 < 0 || Ro(e2, i2, s) < n2;
}
const Dt = typeof process < "u" && process.env && /\bparse\b/.test({}.LOG);
let Yn = null;
var Lo;
(function(s) {
s[s.Margin = 25] = "Margin";
})(Lo || (Lo = {}));
function Eo(s, t2, e2) {
let i2 = s.cursor(st.IncludeAnonymous);
for (i2.moveTo(t2); ; )
if (!(e2 < 0 ? i2.childBefore(t2) : i2.childAfter(t2)))
for (; ; ) {
if ((e2 < 0 ? i2.to < t2 : i2.from > t2) && !i2.type.isError)
return e2 < 0 ? Math.max(0, Math.min(
i2.to - 1,
t2 - 25
/* Safety.Margin */
)) : Math.min(s.length, Math.max(
i2.from + 1,
t2 + 25
/* Safety.Margin */
));
if (e2 < 0 ? i2.prevSibling() : i2.nextSibling())
break;
if (!i2.parent())
return e2 < 0 ? 0 : s.length;
}
}
class ng {
constructor(t2, e2) {
this.fragments = t2, this.nodeSet = e2, this.i = 0, this.fragment = null, this.safeFrom = -1, this.safeTo = -1, this.trees = [], this.start = [], this.index = [], this.nextFragment();
}
nextFragment() {
let t2 = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
if (t2) {
for (this.safeFrom = t2.openStart ? Eo(t2.tree, t2.from + t2.offset, 1) - t2.offset : t2.from, this.safeTo = t2.openEnd ? Eo(t2.tree, t2.to + t2.offset, -1) - t2.offset : t2.to; this.trees.length; )
this.trees.pop(), this.start.pop(), this.index.pop();
this.trees.push(t2.tree), this.start.push(-t2.offset), this.index.push(0), this.nextStart = this.safeFrom;
} else
this.nextStart = 1e9;
}
// `pos` must be >= any previously given `pos` for this cursor
nodeAt(t2) {
if (t2 < this.nextStart)
return null;
for (; this.fragment && this.safeTo <= t2; )
this.nextFragment();
if (!this.fragment)
return null;
for (; ; ) {
let e2 = this.trees.length - 1;
if (e2 < 0)
return this.nextFragment(), null;
let i2 = this.trees[e2], n2 = this.index[e2];
if (n2 == i2.children.length) {
this.trees.pop(), this.start.pop(), this.index.pop();
continue;
}
let r2 = i2.children[n2], o = this.start[e2] + i2.positions[n2];
if (o > t2)
return this.nextStart = o, null;
if (r2 instanceof J$1) {
if (o == t2) {
if (o < this.safeFrom)
return null;
let l = o + r2.length;
if (l <= this.safeTo) {
let h2 = r2.prop(P$1.lookAhead);
if (!h2 || l + h2 < this.fragment.to)
return r2;
}
}
this.index[e2]++, o + r2.length >= Math.max(this.safeFrom, t2) && (this.trees.push(r2), this.start.push(o), this.index.push(0));
} else
this.index[e2]++, this.nextStart = o + r2.length;
}
}
}
class sg {
constructor(t2, e2) {
this.stream = e2, this.tokens = [], this.mainToken = null, this.actions = [], this.tokens = t2.tokenizers.map((i2) => new Ji());
}
getActions(t2) {
let e2 = 0, i2 = null, { parser: n2 } = t2.p, { tokenizers: r2 } = n2, o = n2.stateSlot(
t2.state,
3
/* ParseState.TokenizerMask */
), l = t2.curContext ? t2.curContext.hash : 0, h2 = 0;
for (let a2 = 0; a2 < r2.length; a2++) {
if (!(1 << a2 & o))
continue;
let c2 = r2[a2], f2 = this.tokens[a2];
if (!(i2 && !c2.fallback) && ((c2.contextual || f2.start != t2.pos || f2.mask != o || f2.context != l) && (this.updateCachedToken(f2, c2, t2), f2.mask = o, f2.context = l), f2.lookAhead > f2.end + 25 && (h2 = Math.max(f2.lookAhead, h2)), f2.value != 0)) {
let u2 = e2;
if (f2.extended > -1 && (e2 = this.addActions(t2, f2.extended, f2.end, e2)), e2 = this.addActions(t2, f2.value, f2.end, e2), !c2.extend && (i2 = f2, e2 > u2))
break;
}
}
for (; this.actions.length > e2; )
this.actions.pop();
return h2 && t2.setLookAhead(h2), !i2 && t2.pos == this.stream.end && (i2 = new Ji(), i2.value = t2.p.parser.eofTerm, i2.start = i2.end = t2.pos, e2 = this.addActions(t2, i2.value, i2.end, e2)), this.mainToken = i2, this.actions;
}
getMainToken(t2) {
if (this.mainToken)
return this.mainToken;
let e2 = new Ji(), { pos: i2, p: n2 } = t2;
return e2.start = i2, e2.end = Math.min(i2 + 1, n2.stream.end), e2.value = i2 == n2.stream.end ? n2.parser.eofTerm : 0, e2;
}
updateCachedToken(t2, e2, i2) {
let n2 = this.stream.clipPos(i2.pos);
if (e2.token(this.stream.reset(n2, t2), i2), t2.value > -1) {
let { parser: r2 } = i2.p;
for (let o = 0; o < r2.specialized.length; o++)
if (r2.specialized[o] == t2.value) {
let l = r2.specializers[o](this.stream.read(t2.start, t2.end), i2);
if (l >= 0 && i2.p.parser.dialect.allows(l >> 1)) {
l & 1 ? t2.extended = l >> 1 : t2.value = l >> 1;
break;
}
}
} else
t2.value = 0, t2.end = this.stream.clipPos(n2 + 1);
}
putAction(t2, e2, i2, n2) {
for (let r2 = 0; r2 < n2; r2 += 3)
if (this.actions[r2] == t2)
return n2;
return this.actions[n2++] = t2, this.actions[n2++] = e2, this.actions[n2++] = i2, n2;
}
addActions(t2, e2, i2, n2) {
let { state: r2 } = t2, { parser: o } = t2.p, { data: l } = o;
for (let h2 = 0; h2 < 2; h2++)
for (let a2 = o.stateSlot(
r2,
h2 ? 2 : 1
/* ParseState.Actions */
); ; a2 += 3) {
if (l[a2] == 65535)
if (l[a2 + 1] == 1)
a2 = Qt(l, a2 + 2);
else {
n2 == 0 && l[a2 + 1] == 2 && (n2 = this.putAction(Qt(l, a2 + 2), e2, i2, n2));
break;
}
l[a2] == e2 && (n2 = this.putAction(Qt(l, a2 + 1), e2, i2, n2));
}
return n2;
}
}
var No;
(function(s) {
s[s.Distance = 5] = "Distance", s[s.MaxRemainingPerStep = 3] = "MaxRemainingPerStep", s[s.MinBufferLengthPrune = 500] = "MinBufferLengthPrune", s[s.ForceReduceLimit = 10] = "ForceReduceLimit", s[s.CutDepth = 15e3] = "CutDepth", s[s.CutTo = 9e3] = "CutTo", s[s.MaxLeftAssociativeReductionCount = 300] = "MaxLeftAssociativeReductionCount", s[s.MaxStackCount = 12] = "MaxStackCount";
})(No || (No = {}));
class rg {
constructor(t2, e2, i2, n2) {
this.parser = t2, this.input = e2, this.ranges = n2, this.recovering = 0, this.nextStackID = 9812, this.minStackPos = 0, this.reused = [], this.stoppedAt = null, this.lastBigReductionStart = -1, this.lastBigReductionSize = 0, this.bigReductionCount = 0, this.stream = new tg(e2, n2), this.tokens = new sg(t2, this.stream), this.topTerm = t2.top[1];
let { from: r2 } = n2[0];
this.stacks = [bn.start(this, t2.top[0], r2)], this.fragments = i2.length && this.stream.end - r2 > t2.bufferLength * 4 ? new ng(i2, t2.nodeSet) : null;
}
get parsedPos() {
return this.minStackPos;
}
// Move the parser forward. This will process all parse stacks at
// `this.pos` and try to advance them to a further position. If no
// stack for such a position is found, it'll start error-recovery.
//
// When the parse is finished, this will return a syntax tree. When
// not, it returns `null`.
advance() {
let t2 = this.stacks, e2 = this.minStackPos, i2 = this.stacks = [], n2, r2;
if (this.bigReductionCount > 300 && t2.length == 1) {
let [o] = t2;
for (; o.forceReduce() && o.stack.length && o.stack[o.stack.length - 2] >= this.lastBigReductionStart; )
;
this.bigReductionCount = this.lastBigReductionSize = 0;
}
for (let o = 0; o < t2.length; o++) {
let l = t2[o];
for (; ; ) {
if (this.tokens.mainToken = null, l.pos > e2)
i2.push(l);
else {
if (this.advanceStack(l, i2, t2))
continue;
{
n2 || (n2 = [], r2 = []), n2.push(l);
let h2 = this.tokens.getMainToken(l);
r2.push(h2.value, h2.end);
}
}
break;
}
}
if (!i2.length) {
let o = n2 && lg(n2);
if (o)
return this.stackToTree(o);
if (this.parser.strict)
throw Dt && n2 && console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none")), new SyntaxError("No parse at " + e2);
this.recovering || (this.recovering = 5);
}
if (this.recovering && n2) {
let o = this.stoppedAt != null && n2[0].pos > this.stoppedAt ? n2[0] : this.runRecovery(n2, r2, i2);
if (o)
return this.stackToTree(o.forceAll());
}
if (this.recovering) {
let o = this.recovering == 1 ? 1 : this.recovering * 3;
if (i2.length > o)
for (i2.sort((l, h2) => h2.score - l.score); i2.length > o; )
i2.pop();
i2.some((l) => l.reducePos > e2) && this.recovering--;
} else if (i2.length > 1) {
t:
for (let o = 0; o < i2.length - 1; o++) {
let l = i2[o];
for (let h2 = o + 1; h2 < i2.length; h2++) {
let a2 = i2[h2];
if (l.sameState(a2) || l.buffer.length > 500 && a2.buffer.length > 500)
if ((l.score - a2.score || l.buffer.length - a2.buffer.length) > 0)
i2.splice(h2--, 1);
else {
i2.splice(o--, 1);
continue t;
}
}
}
i2.length > 12 && i2.splice(
12,
i2.length - 12
/* Rec.MaxStackCount */
);
}
this.minStackPos = i2[0].pos;
for (let o = 1; o < i2.length; o++)
i2[o].pos < this.minStackPos && (this.minStackPos = i2[o].pos);
return null;
}
stopAt(t2) {
if (this.stoppedAt != null && this.stoppedAt < t2)
throw new RangeError("Can't move stoppedAt forward");
this.stoppedAt = t2;
}
// Returns an updated version of the given stack, or null if the
// stack can't advance normally. When `split` and `stacks` are
// given, stacks split off by ambiguous operations will be pushed to
// `split`, or added to `stacks` if they move `pos` forward.
advanceStack(t2, e2, i2) {
let n2 = t2.pos, { parser: r2 } = this, o = Dt ? this.stackID(t2) + " -> " : "";
if (this.stoppedAt != null && n2 > this.stoppedAt)
return t2.forceReduce() ? t2 : null;
if (this.fragments) {
let a2 = t2.curContext && t2.curContext.tracker.strict, c2 = a2 ? t2.curContext.hash : 0;
for (let f2 = this.fragments.nodeAt(n2); f2; ) {
let u2 = this.parser.nodeSet.types[f2.type.id] == f2.type ? r2.getGoto(t2.state, f2.type.id) : -1;
if (u2 > -1 && f2.length && (!a2 || (f2.prop(P$1.contextHash) || 0) == c2))
return t2.useNode(f2, u2), Dt && console.log(o + this.stackID(t2) + ` (via reuse of ${r2.getName(f2.type.id)})`), true;
if (!(f2 instanceof J$1) || f2.children.length == 0 || f2.positions[0] > 0)
break;
let d2 = f2.children[0];
if (d2 instanceof J$1 && f2.positions[0] == 0)
f2 = d2;
else
break;
}
}
let l = r2.stateSlot(
t2.state,
4
/* ParseState.DefaultReduce */
);
if (l > 0)
return t2.reduce(l), Dt && console.log(o + this.stackID(t2) + ` (via always-reduce ${r2.getName(
l & 65535
/* Action.ValueMask */
)})`), true;
if (t2.stack.length >= 15e3)
for (; t2.stack.length > 9e3 && t2.forceReduce(); )
;
let h2 = this.tokens.getActions(t2);
for (let a2 = 0; a2 < h2.length; ) {
let c2 = h2[a2++], f2 = h2[a2++], u2 = h2[a2++], d2 = a2 == h2.length || !i2, p2 = d2 ? t2 : t2.split();
if (p2.apply(c2, f2, u2), Dt && console.log(o + this.stackID(p2) + ` (via ${c2 & 65536 ? `reduce of ${r2.getName(
c2 & 65535
/* Action.ValueMask */
)}` : "shift"} for ${r2.getName(f2)} @ ${n2}${p2 == t2 ? "" : ", split"})`), d2)
return true;
p2.pos > n2 ? e2.push(p2) : i2.push(p2);
}
return false;
}
// Advance a given stack forward as far as it will go. Returns the
// (possibly updated) stack if it got stuck, or null if it moved
// forward and was given to `pushStackDedup`.
advanceFully(t2, e2) {
let i2 = t2.pos;
for (; ; ) {
if (!this.advanceStack(t2, null, null))
return false;
if (t2.pos > i2)
return Vo(t2, e2), true;
}
}
runRecovery(t2, e2, i2) {
let n2 = null, r2 = false;
for (let o = 0; o < t2.length; o++) {
let l = t2[o], h2 = e2[o << 1], a2 = e2[(o << 1) + 1], c2 = Dt ? this.stackID(l) + " -> " : "";
if (l.deadEnd && (r2 || (r2 = true, l.restart(), Dt && console.log(c2 + this.stackID(l) + " (restarted)"), this.advanceFully(l, i2))))
continue;
let f2 = l.split(), u2 = c2;
for (let d2 = 0; f2.forceReduce() && d2 < 10 && (Dt && console.log(u2 + this.stackID(f2) + " (via force-reduce)"), !this.advanceFully(f2, i2)); d2++)
Dt && (u2 = this.stackID(f2) + " -> ");
for (let d2 of l.recoverByInsert(h2))
Dt && console.log(c2 + this.stackID(d2) + " (via recover-insert)"), this.advanceFully(d2, i2);
this.stream.end > l.pos ? (a2 == l.pos && (a2++, h2 = 0), l.recoverByDelete(h2, a2), Dt && console.log(c2 + this.stackID(l) + ` (via recover-delete ${this.parser.getName(h2)})`), Vo(l, i2)) : (!n2 || n2.score < l.score) && (n2 = l);
}
return n2;
}
// Convert the stack's buffer to a syntax tree.
stackToTree(t2) {
return t2.close(), J$1.build({
buffer: kn.create(t2),
nodeSet: this.parser.nodeSet,
topID: this.topTerm,
maxBufferLength: this.parser.bufferLength,
reused: this.reused,
start: this.ranges[0].from,
length: t2.pos - this.ranges[0].from,
minRepeatType: this.parser.minRepeatTerm
});
}
stackID(t2) {
let e2 = (Yn || (Yn = /* @__PURE__ */ new WeakMap())).get(t2);
return e2 || Yn.set(t2, e2 = String.fromCodePoint(this.nextStackID++)), e2 + t2;
}
}
function Vo(s, t2) {
for (let e2 = 0; e2 < t2.length; e2++) {
let i2 = t2[e2];
if (i2.pos == s.pos && i2.sameState(s)) {
t2[e2].score < s.score && (t2[e2] = s);
return;
}
}
t2.push(s);
}
class og {
constructor(t2, e2, i2) {
this.source = t2, this.flags = e2, this.disabled = i2;
}
allows(t2) {
return !this.disabled || this.disabled[t2] == 0;
}
}
class xn extends uh {
/// @internal
constructor(t2) {
if (super(), this.wrappers = [], t2.version != 14)
throw new RangeError(`Parser version (${t2.version}) doesn't match runtime version (${14})`);
let e2 = t2.nodeNames.split(" ");
this.minRepeatTerm = e2.length;
for (let l = 0; l < t2.repeatNodeCount; l++)
e2.push("");
let i2 = Object.keys(t2.topRules).map((l) => t2.topRules[l][1]), n2 = [];
for (let l = 0; l < e2.length; l++)
n2.push([]);
function r2(l, h2, a2) {
n2[l].push([h2, h2.deserialize(String(a2))]);
}
if (t2.nodeProps)
for (let l of t2.nodeProps) {
let h2 = l[0];
typeof h2 == "string" && (h2 = P$1[h2]);
for (let a2 = 1; a2 < l.length; ) {
let c2 = l[a2++];
if (c2 >= 0)
r2(c2, h2, l[a2++]);
else {
let f2 = l[a2 + -c2];
for (let u2 = -c2; u2 > 0; u2--)
r2(l[a2++], h2, f2);
a2++;
}
}
}
this.nodeSet = new Zs(e2.map((l, h2) => yt.define({
name: h2 >= this.minRepeatTerm ? void 0 : l,
id: h2,
props: n2[h2],
top: i2.indexOf(h2) > -1,
error: h2 == 0,
skipped: t2.skippedNodes && t2.skippedNodes.indexOf(h2) > -1
}))), t2.propSources && (this.nodeSet = this.nodeSet.extend(...t2.propSources)), this.strict = false, this.bufferLength = ah;
let o = zi(t2.tokenData);
this.context = t2.context, this.specializerSpecs = t2.specialized || [], this.specialized = new Uint16Array(this.specializerSpecs.length);
for (let l = 0; l < this.specializerSpecs.length; l++)
this.specialized[l] = this.specializerSpecs[l].term;
this.specializers = this.specializerSpecs.map(Io), this.states = zi(t2.states, Uint32Array), this.data = zi(t2.stateData), this.goto = zi(t2.goto), this.maxTerm = t2.maxTerm, this.tokenizers = t2.tokenizers.map((l) => typeof l == "number" ? new ze(o, l) : l), this.topRules = t2.topRules, this.dialects = t2.dialects || {}, this.dynamicPrecedences = t2.dynamicPrecedences || null, this.tokenPrecTable = t2.tokenPrec, this.termNames = t2.termNames || null, this.maxNode = this.nodeSet.types.length - 1, this.dialect = this.parseDialect(), this.top = this.topRules[Object.keys(this.topRules)[0]];
}
createParse(t2, e2, i2) {
let n2 = new rg(this, t2, e2, i2);
for (let r2 of this.wrappers)
n2 = r2(n2, t2, e2, i2);
return n2;
}
/// Get a goto table entry @internal
getGoto(t2, e2, i2 = false) {
let n2 = this.goto;
if (e2 >= n2[0])
return -1;
for (let r2 = n2[e2 + 1]; ; ) {
let o = n2[r2++], l = o & 1, h2 = n2[r2++];
if (l && i2)
return h2;
for (let a2 = r2 + (o >> 1); r2 < a2; r2++)
if (n2[r2] == t2)
return h2;
if (l)
return -1;
}
}
/// Check if this state has an action for a given terminal @internal
hasAction(t2, e2) {
let i2 = this.data;
for (let n2 = 0; n2 < 2; n2++)
for (let r2 = this.stateSlot(
t2,
n2 ? 2 : 1
/* ParseState.Actions */
), o; ; r2 += 3) {
if ((o = i2[r2]) == 65535)
if (i2[r2 + 1] == 1)
o = i2[r2 = Qt(i2, r2 + 2)];
else {
if (i2[r2 + 1] == 2)
return Qt(i2, r2 + 2);
break;
}
if (o == e2 || o == 0)
return Qt(i2, r2 + 1);
}
return 0;
}
/// @internal
stateSlot(t2, e2) {
return this.states[t2 * 6 + e2];
}
/// @internal
stateFlag(t2, e2) {
return (this.stateSlot(
t2,
0
/* ParseState.Flags */
) & e2) > 0;
}
/// @internal
validAction(t2, e2) {
if (e2 == this.stateSlot(
t2,
4
/* ParseState.DefaultReduce */
))
return true;
for (let i2 = this.stateSlot(
t2,
1
/* ParseState.Actions */
); ; i2 += 3) {
if (this.data[i2] == 65535)
if (this.data[i2 + 1] == 1)
i2 = Qt(this.data, i2 + 2);
else
return false;
if (e2 == Qt(this.data, i2 + 1))
return true;
}
}
/// Get the states that can follow this one through shift actions or
/// goto jumps. @internal
nextStates(t2) {
let e2 = [];
for (let i2 = this.stateSlot(
t2,
1
/* ParseState.Actions */
); ; i2 += 3) {
if (this.data[i2] == 65535)
if (this.data[i2 + 1] == 1)
i2 = Qt(this.data, i2 + 2);
else
break;
if (!(this.data[i2 + 2] & 1)) {
let n2 = this.data[i2 + 1];
e2.some((r2, o) => o & 1 && r2 == n2) || e2.push(this.data[i2], n2);
}
}
return e2;
}
/// Configure the parser. Returns a new parser instance that has the
/// given settings modified. Settings not provided in `config` are
/// kept from the original parser.
configure(t2) {
let e2 = Object.assign(Object.create(xn.prototype), this);
if (t2.props && (e2.nodeSet = this.nodeSet.extend(...t2.props)), t2.top) {
let i2 = this.topRules[t2.top];
if (!i2)
throw new RangeError(`Invalid top rule name ${t2.top}`);
e2.top = i2;
}
return t2.tokenizers && (e2.tokenizers = this.tokenizers.map((i2) => {
let n2 = t2.tokenizers.find((r2) => r2.from == i2);
return n2 ? n2.to : i2;
})), t2.specializers && (e2.specializers = this.specializers.slice(), e2.specializerSpecs = this.specializerSpecs.map((i2, n2) => {
let r2 = t2.specializers.find((l) => l.from == i2.external);
if (!r2)
return i2;
let o = Object.assign(Object.assign({}, i2), { external: r2.to });
return e2.specializers[n2] = Io(o), o;
})), t2.contextTracker && (e2.context = t2.contextTracker), t2.dialect && (e2.dialect = this.parseDialect(t2.dialect)), t2.strict != null && (e2.strict = t2.strict), t2.wrap && (e2.wrappers = e2.wrappers.concat(t2.wrap)), t2.bufferLength != null && (e2.bufferLength = t2.bufferLength), e2;
}
/// Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
/// are registered for this parser.
hasWrappers() {
return this.wrappers.length > 0;
}
/// Returns the name associated with a given term. This will only
/// work for all terms when the parser was generated with the
/// `--names` option. By default, only the names of tagged terms are
/// stored.
getName(t2) {
return this.termNames ? this.termNames[t2] : String(t2 <= this.maxNode && this.nodeSet.types[t2].name || t2);
}
/// The eof term id is always allocated directly after the node
/// types. @internal
get eofTerm() {
return this.maxNode + 1;
}
/// The type of top node produced by the parser.
get topNode() {
return this.nodeSet.types[this.top[1]];
}
/// @internal
dynamicPrecedence(t2) {
let e2 = this.dynamicPrecedences;
return e2 == null ? 0 : e2[t2] || 0;
}
/// @internal
parseDialect(t2) {
let e2 = Object.keys(this.dialects), i2 = e2.map(() => false);
if (t2)
for (let r2 of t2.split(" ")) {
let o = e2.indexOf(r2);
o >= 0 && (i2[o] = true);
}
let n2 = null;
for (let r2 = 0; r2 < e2.length; r2++)
if (!i2[r2])
for (let o = this.dialects[e2[r2]], l; (l = this.data[o++]) != 65535; )
(n2 || (n2 = new Uint8Array(this.maxTerm + 1)))[l] = 1;
return new og(t2, i2, n2);
}
/// Used by the output of the parser generator. Not available to
/// user code. @hide
static deserialize(t2) {
return new xn(t2);
}
}
function Qt(s, t2) {
return s[t2] | s[t2 + 1] << 16;
}
function lg(s) {
let t2 = null;
for (let e2 of s) {
let i2 = e2.p.stoppedAt;
(e2.pos == e2.p.stream.end || i2 != null && e2.pos > i2) && e2.p.parser.stateFlag(
e2.state,
2
/* StateFlag.Accepting */
) && (!t2 || t2.score < e2.score) && (t2 = e2);
}
return t2;
}
function Io(s) {
if (s.external) {
let t2 = s.extend ? 1 : 0;
return (e2, i2) => s.external(e2, i2) << 1 | t2;
}
return s.get;
}
const hg = dh({
String: m$1.string,
Number: m$1.number,
"True False": m$1.bool,
PropertyName: m$1.propertyName,
Null: m$1.null,
",": m$1.separator,
"[ ]": m$1.squareBracket,
"{ }": m$1.brace
}), ag = xn.deserialize({
version: 14,
states: "$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",
stateData: "#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",
goto: "!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",
nodeNames: "⚠ JsonText True False Null Number String } { Object Property PropertyName ] [ Array",
maxTerm: 25,
nodeProps: [
["openedBy", 7, "{", 12, "["],
["closedBy", 8, "}", 13, "]"]
],
propSources: [hg],
skippedNodes: [0],
repeatNodeCount: 2,
tokenData: "(p~RaXY!WYZ!W]^!Wpq!Wrs!]|}$i}!O$n!Q!R$w!R![&V![!]&h!}#O&m#P#Q&r#Y#Z&w#b#c'f#h#i'}#o#p(f#q#r(k~!]Oc~~!`Upq!]qr!]rs!rs#O!]#O#P!w#P~!]~!wOe~~!zXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#g~#jR!Q![#s!c!i#s#T#Z#s~#vR!Q![$P!c!i$P#T#Z$P~$SR!Q![$]!c!i$]#T#Z$]~$`R!Q![!]!c!i!]#T#Z!]~$nOh~~$qQ!Q!R$w!R![&V~$|RT~!O!P%V!g!h%k#X#Y%k~%YP!Q![%]~%bRT~!Q![%]!g!h%k#X#Y%k~%nR{|%w}!O%w!Q![%}~%zP!Q![%}~&SPT~!Q![%}~&[ST~!O!P%V!Q![&V!g!h%k#X#Y%k~&mOg~~&rO]~~&wO[~~&zP#T#U&}~'QP#`#a'T~'WP#g#h'Z~'^P#X#Y'a~'fOR~~'iP#i#j'l~'oP#`#a'r~'uP#`#a'x~'}OS~~(QP#f#g(T~(WP#i#j(Z~(^P#X#Y(a~(fOQ~~(kOW~~(pOV~",
tokenizers: [0],
topRules: { JsonText: [0, 1] },
tokenPrec: 0
}), cg = /* @__PURE__ */ pn.define({
name: "json",
parser: /* @__PURE__ */ ag.configure({
props: [
/* @__PURE__ */ wh.add({
Object: /* @__PURE__ */ wo({ except: /^\s*\}/ }),
Array: /* @__PURE__ */ wo({ except: /^\s*\]/ })
}),
/* @__PURE__ */ bh.add({
"Object Array": Od
})
]
}),
languageData: {
closeBrackets: { brackets: ["[", "{", '"'] },
indentOnInput: /^\s*[\}\]]$/
}
});
function fg() {
return new pd(cg);
}
function $t() {
var s = arguments[0];
typeof s == "string" && (s = document.createElement(s));
var t2 = 1, e2 = arguments[1];
if (e2 && typeof e2 == "object" && e2.nodeType == null && !Array.isArray(e2)) {
for (var i2 in e2)
if (Object.prototype.hasOwnProperty.call(e2, i2)) {
var n2 = e2[i2];
typeof n2 == "string" ? s.setAttribute(i2, n2) : n2 != null && (s[i2] = n2);
}
t2++;
}
for (; t2 < arguments.length; t2++)
ia(s, arguments[t2]);
return s;
}
function ia(s, t2) {
if (typeof t2 == "string")
s.appendChild(document.createTextNode(t2));
else if (t2 != null)
if (t2.nodeType != null)
s.appendChild(t2);
else if (Array.isArray(t2))
for (var e2 = 0; e2 < t2.length; e2++)
ia(s, t2[e2]);
else
throw new RangeError("Unsupported child node: " + t2);
}
class ug {
constructor(t2, e2, i2) {
this.from = t2, this.to = e2, this.diagnostic = i2;
}
}
class Se {
constructor(t2, e2, i2) {
this.diagnostics = t2, this.panel = e2, this.selected = i2;
}
static init(t2, e2, i2) {
let n2 = t2, r2 = i2.facet(Ve).markerFilter;
r2 && (n2 = r2(n2));
let o = T.set(n2.map((l) => l.from == l.to || l.from == l.to - 1 && i2.doc.lineAt(l.from).to == l.from ? T.widget({
widget: new vg(l),
diagnostic: l
}).range(l.from) : T.mark({
attributes: { class: "cm-lintRange cm-lintRange-" + l.severity },
diagnostic: l
}).range(l.from, l.to)), true);
return new Se(o, e2, Je(o));
}
}
function Je(s, t2 = null, e2 = 0) {
let i2 = null;
return s.between(e2, 1e9, (n2, r2, { spec: o }) => {
if (!(t2 && o.diagnostic != t2))
return i2 = new ug(n2, r2, o.diagnostic), false;
}), i2;
}
function dg(s, t2) {
return !!(s.effects.some((e2) => e2.is(ar)) || s.changes.touchesRange(t2.pos));
}
function na(s, t2) {
return s.field(vt, false) ? t2 : t2.concat(F.appendConfig.of([
vt,
A$2.decorations.compute([vt], (e2) => {
let { selected: i2, panel: n2 } = e2.field(vt);
return !i2 || !n2 || i2.from == i2.to ? T.none : T.set([
gg.range(i2.from, i2.to)
]);
}),
Fu(mg, { hideOn: dg }),
Cg
]));
}
function pg(s, t2) {
return {
effects: na(s, [ar.of(t2)])
};
}
const ar = /* @__PURE__ */ F.define(), cr = /* @__PURE__ */ F.define(), sa = /* @__PURE__ */ F.define(), vt = /* @__PURE__ */ Bt.define({
create() {
return new Se(T.none, null, null);
},
update(s, t2) {
if (t2.docChanged) {
let e2 = s.diagnostics.map(t2.changes), i2 = null;
if (s.selected) {
let n2 = t2.changes.mapPos(s.selected.from, 1);
i2 = Je(e2, s.selected.diagnostic, n2) || Je(e2, null, n2);
}
s = new Se(e2, s.panel, i2);
}
for (let e2 of t2.effects)
e2.is(ar) ? s = Se.init(e2.value, s.panel, t2.state) : e2.is(cr) ? s = new Se(s.diagnostics, e2.value ? En.open : null, s.selected) : e2.is(sa) && (s = new Se(s.diagnostics, s.panel, e2.value));
return s;
},
provide: (s) => [
Rs.from(s, (t2) => t2.panel),
A$2.decorations.from(s, (t2) => t2.diagnostics)
]
}), gg = /* @__PURE__ */ T.mark({ class: "cm-lintRange cm-lintRange-active" });
function mg(s, t2, e2) {
let { diagnostics: i2 } = s.state.field(vt), n2 = [], r2 = 2e8, o = 0;
i2.between(t2 - (e2 < 0 ? 1 : 0), t2 + (e2 > 0 ? 1 : 0), (h2, a2, { spec: c2 }) => {
t2 >= h2 && t2 <= a2 && (h2 == a2 || (t2 > h2 || e2 > 0) && (t2 < a2 || e2 < 0)) && (n2.push(c2.diagnostic), r2 = Math.min(h2, r2), o = Math.max(a2, o));
});
let l = s.state.facet(Ve).tooltipFilter;
return l && (n2 = l(n2)), n2.length ? {
pos: r2,
end: o,
above: s.state.doc.lineAt(r2).to < o,
create() {
return { dom: wg(s, n2) };
}
} : null;
}
function wg(s, t2) {
return $t("ul", { class: "cm-tooltip-lint" }, t2.map((e2) => oa(s, e2, false)));
}
const yg = (s) => {
let t2 = s.state.field(vt, false);
(!t2 || !t2.panel) && s.dispatch({ effects: na(s.state, [cr.of(true)]) });
let e2 = _u(s, En.open);
return e2 && e2.dom.querySelector(".cm-panel-lint ul").focus(), true;
}, Ho = (s) => {
let t2 = s.state.field(vt, false);
return !t2 || !t2.panel ? false : (s.dispatch({ effects: cr.of(false) }), true);
}, bg = (s) => {
let t2 = s.state.field(vt, false);
if (!t2)
return false;
let e2 = s.state.selection.main, i2 = t2.diagnostics.iter(e2.to + 1);
return !i2.value && (i2 = t2.diagnostics.iter(0), !i2.value || i2.from == e2.from && i2.to == e2.to) ? false : (s.dispatch({ selection: { anchor: i2.from, head: i2.to }, scrollIntoView: true }), true);
}, kg = [
{ key: "Mod-Shift-m", run: yg, preventDefault: true },
{ key: "F8", run: bg }
], xg = /* @__PURE__ */ wt.fromClass(class {
constructor(s) {
this.view = s, this.timeout = -1, this.set = true;
let { delay: t2 } = s.state.facet(Ve);
this.lintTime = Date.now() + t2, this.run = this.run.bind(this), this.timeout = setTimeout(this.run, t2);
}
run() {
let s = Date.now();
if (s < this.lintTime - 10)
setTimeout(this.run, this.lintTime - s);
else {
this.set = false;
let { state: t2 } = this.view, { sources: e2 } = t2.facet(Ve);
Promise.all(e2.map((i2) => Promise.resolve(i2(this.view)))).then((i2) => {
let n2 = i2.reduce((r2, o) => r2.concat(o));
this.view.state.doc == t2.doc && this.view.dispatch(pg(this.view.state, n2));
}, (i2) => {
zt(this.view.state, i2);
});
}
}
update(s) {
let t2 = s.state.facet(Ve);
(s.docChanged || t2 != s.startState.facet(Ve)) && (this.lintTime = Date.now() + t2.delay, this.set || (this.set = true, this.timeout = setTimeout(this.run, t2.delay)));
}
force() {
this.set && (this.lintTime = Date.now(), this.run());
}
destroy() {
clearTimeout(this.timeout);
}
}), Ve = /* @__PURE__ */ v.define({
combine(s) {
return Object.assign({ sources: s.map((t2) => t2.source) }, Sn(s.map((t2) => t2.config), {
delay: 750,
markerFilter: null,
tooltipFilter: null
}));
},
enables: xg
});
function ra(s) {
let t2 = [];
if (s)
t:
for (let { name: e2 } of s) {
for (let i2 = 0; i2 < e2.length; i2++) {
let n2 = e2[i2];
if (/[a-zA-Z]/.test(n2) && !t2.some((r2) => r2.toLowerCase() == n2.toLowerCase())) {
t2.push(n2);
continue t;
}
}
t2.push("");
}
return t2;
}
function oa(s, t2, e2) {
var i2;
let n2 = e2 ? ra(t2.actions) : [];
return $t("li", { class: "cm-diagnostic cm-diagnostic-" + t2.severity }, $t("span", { class: "cm-diagnosticText" }, t2.renderMessage ? t2.renderMessage() : t2.message), (i2 = t2.actions) === null || i2 === void 0 ? void 0 : i2.map((r2, o) => {
let l = (f2) => {
f2.preventDefault();
let u2 = Je(s.state.field(vt).diagnostics, t2);
u2 && r2.apply(s, u2.from, u2.to);
}, { name: h2 } = r2, a2 = n2[o] ? h2.indexOf(n2[o]) : -1, c2 = a2 < 0 ? h2 : [
h2.slice(0, a2),
$t("u", h2.slice(a2, a2 + 1)),
h2.slice(a2 + 1)
];
return $t("button", {
type: "button",
class: "cm-diagnosticAction",
onclick: l,
onmousedown: l,
"aria-label": ` Action: ${h2}${a2 < 0 ? "" : ` (access key "${n2[o]})"`}.`
}, c2);
}), t2.source && $t("div", { class: "cm-diagnosticSource" }, t2.source));
}
class vg extends ye {
constructor(t2) {
super(), this.diagnostic = t2;
}
eq(t2) {
return t2.diagnostic == this.diagnostic;
}
toDOM() {
return $t("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
}
}
class $o {
constructor(t2, e2) {
this.diagnostic = e2, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = oa(t2, e2, true), this.dom.id = this.id, this.dom.setAttribute("role", "option");
}
}
class En {
constructor(t2) {
this.view = t2, this.items = [];
let e2 = (n2) => {
if (n2.keyCode == 27)
Ho(this.view), this.view.focus();
else if (n2.keyCode == 38 || n2.keyCode == 33)
this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
else if (n2.keyCode == 40 || n2.keyCode == 34)
this.moveSelection((this.selectedIndex + 1) % this.items.length);
else if (n2.keyCode == 36)
this.moveSelection(0);
else if (n2.keyCode == 35)
this.moveSelection(this.items.length - 1);
else if (n2.keyCode == 13)
this.view.focus();
else if (n2.keyCode >= 65 && n2.keyCode <= 90 && this.selectedIndex >= 0) {
let { diagnostic: r2 } = this.items[this.selectedIndex], o = ra(r2.actions);
for (let l = 0; l < o.length; l++)
if (o[l].toUpperCase().charCodeAt(0) == n2.keyCode) {
let h2 = Je(this.view.state.field(vt).diagnostics, r2);
h2 && r2.actions[l].apply(t2, h2.from, h2.to);
}
} else
return;
n2.preventDefault();
}, i2 = (n2) => {
for (let r2 = 0; r2 < this.items.length; r2++)
this.items[r2].dom.contains(n2.target) && this.moveSelection(r2);
};
this.list = $t("ul", {
tabIndex: 0,
role: "listbox",
"aria-label": this.view.state.phrase("Diagnostics"),
onkeydown: e2,
onclick: i2
}), this.dom = $t("div", { class: "cm-panel-lint" }, this.list, $t("button", {
type: "button",
name: "close",
"aria-label": this.view.state.phrase("close"),
onclick: () => Ho(this.view)
}, "×")), this.update();
}
get selectedIndex() {
let t2 = this.view.state.field(vt).selected;
if (!t2)
return -1;
for (let e2 = 0; e2 < this.items.length; e2++)
if (this.items[e2].diagnostic == t2.diagnostic)
return e2;
return -1;
}
update() {
let { diagnostics: t2, selected: e2 } = this.view.state.field(vt), i2 = 0, n2 = false, r2 = null;
for (t2.between(0, this.view.state.doc.length, (o, l, { spec: h2 }) => {
let a2 = -1, c2;
for (let f2 = i2; f2 < this.items.length; f2++)
if (this.items[f2].diagnostic == h2.diagnostic) {
a2 = f2;
break;
}
a2 < 0 ? (c2 = new $o(this.view, h2.diagnostic), this.items.splice(i2, 0, c2), n2 = true) : (c2 = this.items[a2], a2 > i2 && (this.items.splice(i2, a2 - i2), n2 = true)), e2 && c2.diagnostic == e2.diagnostic ? c2.dom.hasAttribute("aria-selected") || (c2.dom.setAttribute("aria-selected", "true"), r2 = c2) : c2.dom.hasAttribute("aria-selected") && c2.dom.removeAttribute("aria-selected"), i2++;
}); i2 < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0); )
n2 = true, this.items.pop();
this.items.length == 0 && (this.items.push(new $o(this.view, {
from: -1,
to: -1,
severity: "info",
message: this.view.state.phrase("No diagnostics")
})), n2 = true), r2 ? (this.list.setAttribute("aria-activedescendant", r2.id), this.view.requestMeasure({
key: this,
read: () => ({ sel: r2.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
write: ({ sel: o, panel: l }) => {
o.top < l.top ? this.list.scrollTop -= l.top - o.top : o.bottom > l.bottom && (this.list.scrollTop += o.bottom - l.bottom);
}
})) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), n2 && this.sync();
}
sync() {
let t2 = this.list.firstChild;
function e2() {
let i2 = t2;
t2 = i2.nextSibling, i2.remove();
}
for (let i2 of this.items)
if (i2.dom.parentNode == this.list) {
for (; t2 != i2.dom; )
e2();
t2 = i2.dom.nextSibling;
} else
this.list.insertBefore(i2.dom, t2);
for (; t2; )
e2();
}
moveSelection(t2) {
if (this.selectedIndex < 0)
return;
let e2 = this.view.state.field(vt), i2 = Je(e2.diagnostics, this.items[t2].diagnostic);
i2 && this.view.dispatch({
selection: { anchor: i2.from, head: i2.to },
scrollIntoView: true,
effects: sa.of(i2)
});
}
static open(t2) {
return new En(t2);
}
}
function Sg(s, t2 = 'viewBox="0 0 40 40"') {
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t2}>${encodeURIComponent(s)}</svg>')`;
}
function Zn(s) {
return Sg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${s}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
}
const Cg = /* @__PURE__ */ A$2.baseTheme({
".cm-diagnostic": {
padding: "3px 6px 3px 8px",
marginLeft: "-1px",
display: "block",
whiteSpace: "pre-wrap"
},
".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
".cm-diagnostic-info": { borderLeft: "5px solid #999" },
".cm-diagnosticAction": {
font: "inherit",
border: "none",
padding: "2px 4px",
backgroundColor: "#444",
color: "white",
borderRadius: "3px",
marginLeft: "8px"
},
".cm-diagnosticSource": {
fontSize: "70%",
opacity: 0.7
},
".cm-lintRange": {
backgroundPosition: "left bottom",
backgroundRepeat: "repeat-x",
paddingBottom: "0.7px"
},
".cm-lintRange-error": { backgroundImage: /* @__PURE__ */ Zn("#d11") },
".cm-lintRange-warning": { backgroundImage: /* @__PURE__ */ Zn("orange") },
".cm-lintRange-info": { backgroundImage: /* @__PURE__ */ Zn("#999") },
".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
".cm-tooltip-lint": {
padding: 0,
margin: 0
},
".cm-lintPoint": {
position: "relative",
"&:after": {
content: '""',
position: "absolute",
bottom: 0,
left: "-2px",
borderLeft: "3px solid transparent",
borderRight: "3px solid transparent",
borderBottom: "4px solid #d11"
}
},
".cm-lintPoint-warning": {
"&:after": { borderBottomColor: "orange" }
},
".cm-lintPoint-info": {
"&:after": { borderBottomColor: "#999" }
},
".cm-panel.cm-panel-lint": {
position: "relative",
"& ul": {
maxHeight: "100px",
overflowY: "auto",
"& [aria-selected]": {
backgroundColor: "#ddd",
"& u": { textDecoration: "underline" }
},
"&:focus [aria-selected]": {
background_fallback: "#bdf",
backgroundColor: "Highlight",
color_fallback: "white",
color: "HighlightText"
},
"& u": { textDecoration: "none" },
padding: 0,
margin: 0
},
"& [name=close]": {
position: "absolute",
top: "0",
right: "2px",
background: "inherit",
border: "none",
font: "inherit",
padding: 0,
margin: 0
}
}
}), Ag = "#e5c07b", Fo = "#e06c75", Og = "#56b6c2", Mg = "#ffffff", Xi = "#abb2bf", Fs = "#7d8799", Dg = "#61afef", Tg = "#98c379", zo = "#d19a66", Pg = "#c678dd", Bg = "#21252b", _o = "#2c313a", Wo = "#282c34", ts = "#353a42", Rg = "#3E4451", jo = "#528bff", Lg = /* @__PURE__ */ A$2.theme({
"&": {
color: Xi,
backgroundColor: Wo
},
".cm-content": {
caretColor: jo
},
".cm-cursor, .cm-dropCursor": { borderLeftColor: jo },
"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: Rg },
".cm-panels": { backgroundColor: Bg, color: Xi },
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
".cm-searchMatch": {
backgroundColor: "#72a1ff59",
outline: "1px solid #457dff"
},
".cm-searchMatch.cm-searchMatch-selected": {
backgroundColor: "#6199ff2f"
},
".cm-activeLine": { backgroundColor: "#6699ff0b" },
".cm-selectionMatch": { backgroundColor: "#aafe661a" },
"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": {
backgroundColor: "#bad0f847",
outline: "1px solid #515a6b"
},
".cm-gutters": {
backgroundColor: Wo,
color: Fs,
border: "none"
},
".cm-activeLineGutter": {
backgroundColor: _o
},
".cm-foldPlaceholder": {
backgroundColor: "transparent",
border: "none",
color: "#ddd"
},
".cm-tooltip": {
border: "none",
backgroundColor: ts
},
".cm-tooltip .cm-tooltip-arrow:before": {
borderTopColor: "transparent",
borderBottomColor: "transparent"
},
".cm-tooltip .cm-tooltip-arrow:after": {
borderTopColor: ts,
borderBottomColor: ts
},
".cm-tooltip-autocomplete": {
"& > ul > li[aria-selected]": {
backgroundColor: _o,
color: Xi
}
}
}, { dark: true }), Eg = /* @__PURE__ */ vi.define([
{
tag: m$1.keyword,
color: Pg
},
{
tag: [m$1.name, m$1.deleted, m$1.character, m$1.propertyName, m$1.macroName],
color: Fo
},
{
tag: [/* @__PURE__ */ m$1.function(m$1.variableName), m$1.labelName],
color: Dg
},
{
tag: [m$1.color, /* @__PURE__ */ m$1.constant(m$1.name), /* @__PURE__ */ m$1.standard(m$1.name)],
color: zo
},
{
tag: [/* @__PURE__ */ m$1.definition(m$1.name), m$1.separator],
color: Xi
},
{
tag: [m$1.typeName, m$1.className, m$1.number, m$1.changed, m$1.annotation, m$1.modifier, m$1.self, m$1.namespace],
color: Ag
},
{
tag: [m$1.operator, m$1.operatorKeyword, m$1.url, m$1.escape, m$1.regexp, m$1.link, /* @__PURE__ */ m$1.special(m$1.string)],
color: Og
},
{
tag: [m$1.meta, m$1.comment],
color: Fs
},
{
tag: m$1.strong,
fontWeight: "bold"
},
{
tag: m$1.emphasis,
fontStyle: "italic"
},
{
tag: m$1.strikethrough,
textDecoration: "line-through"
},
{
tag: m$1.link,
color: Fs,
textDecoration: "underline"
},
{
tag: m$1.heading,
fontWeight: "bold",
color: Fo
},
{
tag: [m$1.atom, m$1.bool, /* @__PURE__ */ m$1.special(m$1.variableName)],
color: zo
},
{
tag: [m$1.processingInstruction, m$1.string, m$1.inserted],
color: Tg
},
{
tag: m$1.invalid,
color: Mg
}
]), la = ref(false);
window.__hst_controls_dark || (window.__hst_controls_dark = []);
window.__hst_controls_dark.push(la);
var qo;
(qo = window.__hst_controls_dark_ready) == null || qo.call(window);
const Ng = {
name: "HstJson",
inheritAttrs: false
}, Vg = /* @__PURE__ */ defineComponent({
...Ng,
props: {
title: null,
modelValue: null
},
emits: {
"update:modelValue": (s) => true
},
setup(s, { emit: t2 }) {
const e2 = s;
let i2;
const n2 = ref(""), r2 = ref(false), o = ref(), l = {
light: [A$2.baseTheme({}), bo(zd)],
dark: [Lg, bo(Eg)]
}, h2 = new yi(), a2 = [
Xu(),
Pu(),
Cu(),
fg(),
Ud(),
Cd(),
Id(),
nh.of([
...Yp,
...Ed,
...kg
]),
A$2.updateListener.of((c2) => {
n2.value = c2.view.state.doc.toString();
}),
h2.of(l.light)
];
return onMounted(() => {
i2 = new A$2({
doc: JSON.stringify(e2.modelValue, null, 2),
extensions: a2,
parent: o.value
}), watchEffect(() => {
i2.dispatch({
effects: [
h2.reconfigure(l[la.value ? "dark" : "light"])
]
});
});
}), watch(() => e2.modelValue, () => {
let c2;
try {
c2 = JSON.stringify(JSON.parse(n2.value)) === JSON.stringify(e2.modelValue);
} catch {
c2 = false;
}
c2 || i2.dispatch({ changes: [{ from: 0, to: i2.state.doc.length, insert: JSON.stringify(e2.modelValue, null, 2) }] });
}, { deep: true }), watch(() => n2.value, () => {
r2.value = false;
try {
t2("update:modelValue", JSON.parse(n2.value));
} catch {
r2.value = true;
}
}), (c2, f2) => (openBlock(), createBlock(qt, {
title: s.title,
class: normalizeClass(["histoire-json htw-cursor-text", c2.$attrs.class]),
style: normalizeStyle(c2.$attrs.style)
}, {
actions: withCtx(() => [
r2.value ? withDirectives((openBlock(), createBlock(unref(Icon), {
key: 0,
icon: "carbon:warning-alt",
class: "htw-text-orange-500"
}, null, 512)), [
[unref(VTooltip), "JSON error"]
]) : createCommentVNode("", true),
renderSlot(c2.$slots, "actions", {}, void 0, true)
]),
default: withCtx(() => [
createBaseVNode("div", mergeProps({
ref_key: "editorElement",
ref: o,
class: "__histoire-json-code htw-w-full htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus-within:htw-border-primary-500 dark:focus-within:htw-border-primary-500 htw-rounded-sm htw-box-border htw-overflow-auto htw-resize-y htw-min-h-32 htw-h-48 htw-relative"
}, { ...c2.$attrs, class: null, style: null }), null, 16)
]),
_: 3
}, 8, ["title", "class", "style"]));
}
});
const Ig = (s, t2) => {
const e2 = s.__vccOpts || s;
for (const [i2, n2] of t2)
e2[i2] = n2;
return e2;
}, Hg = /* @__PURE__ */ Ig(Vg, [["__scopeId", "data-v-e5fbff29"]]), $g = Uo, Fg = xa, zg = Oa, _g = Pa, Wg = La, jg = Na, qg = $a, Kg = _a, Gg = Ja, Ug = rc, Qg = dc, Jg = kc, Xg = Me, Yg = Ac, Zg = Hg, rm = {
HstButton: $g,
HstButtonGroup: Fg,
HstCheckbox: zg,
HstCheckboxList: _g,
HstText: Wg,
HstNumber: jg,
HstSlider: qg,
HstTextarea: Kg,
HstSelect: Gg,
HstRadio: Yg,
HstJson: Zg,
HstColorShades: Ug,
HstTokenList: Qg,
HstTokenGrid: Jg,
HstCopyIcon: Xg
};
var commonjsGlobal$1 = typeof globalThis !== "undefined" ? globalThis : typeof {} !== "undefined" ? {} : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
var mainExports$1 = {};
var main$1 = {
get exports() {
return mainExports$1;
},
set exports(v2) {
mainExports$1 = v2;
}
};
(function(module2, exports) {
!function(t2, n2) {
module2.exports = n2();
}(commonjsGlobal$1, () => {
return t2 = { 770: function(t3, n3, e2) {
var r2 = this && this.__importDefault || function(t4) {
return t4 && t4.__esModule ? t4 : { default: t4 };
};
Object.defineProperty(n3, "__esModule", { value: true }), n3.setDefaultDebugCall = n3.createOnigScanner = n3.createOnigString = n3.loadWASM = n3.OnigScanner = n3.OnigString = void 0;
const i2 = r2(e2(418));
let o = null, a2 = false;
class f2 {
static _utf8ByteLength(t4) {
let n4 = 0;
for (let e3 = 0, r3 = t4.length; e3 < r3; e3++) {
const i3 = t4.charCodeAt(e3);
let o2 = i3, a3 = false;
if (i3 >= 55296 && i3 <= 56319 && e3 + 1 < r3) {
const n5 = t4.charCodeAt(e3 + 1);
n5 >= 56320 && n5 <= 57343 && (o2 = 65536 + (i3 - 55296 << 10) | n5 - 56320, a3 = true);
}
n4 += o2 <= 127 ? 1 : o2 <= 2047 ? 2 : o2 <= 65535 ? 3 : 4, a3 && e3++;
}
return n4;
}
constructor(t4) {
const n4 = t4.length, e3 = f2._utf8ByteLength(t4), r3 = e3 !== n4, i3 = r3 ? new Uint32Array(n4 + 1) : null;
r3 && (i3[n4] = e3);
const o2 = r3 ? new Uint32Array(e3 + 1) : null;
r3 && (o2[e3] = n4);
const a3 = new Uint8Array(e3);
let s2 = 0;
for (let e4 = 0; e4 < n4; e4++) {
const f3 = t4.charCodeAt(e4);
let u3 = f3, c3 = false;
if (f3 >= 55296 && f3 <= 56319 && e4 + 1 < n4) {
const n5 = t4.charCodeAt(e4 + 1);
n5 >= 56320 && n5 <= 57343 && (u3 = 65536 + (f3 - 55296 << 10) | n5 - 56320, c3 = true);
}
r3 && (i3[e4] = s2, c3 && (i3[e4 + 1] = s2), u3 <= 127 ? o2[s2 + 0] = e4 : u3 <= 2047 ? (o2[s2 + 0] = e4, o2[s2 + 1] = e4) : u3 <= 65535 ? (o2[s2 + 0] = e4, o2[s2 + 1] = e4, o2[s2 + 2] = e4) : (o2[s2 + 0] = e4, o2[s2 + 1] = e4, o2[s2 + 2] = e4, o2[s2 + 3] = e4)), u3 <= 127 ? a3[s2++] = u3 : u3 <= 2047 ? (a3[s2++] = 192 | (1984 & u3) >>> 6, a3[s2++] = 128 | (63 & u3) >>> 0) : u3 <= 65535 ? (a3[s2++] = 224 | (61440 & u3) >>> 12, a3[s2++] = 128 | (4032 & u3) >>> 6, a3[s2++] = 128 | (63 & u3) >>> 0) : (a3[s2++] = 240 | (1835008 & u3) >>> 18, a3[s2++] = 128 | (258048 & u3) >>> 12, a3[s2++] = 128 | (4032 & u3) >>> 6, a3[s2++] = 128 | (63 & u3) >>> 0), c3 && e4++;
}
this.utf16Length = n4, this.utf8Length = e3, this.utf16Value = t4, this.utf8Value = a3, this.utf16OffsetToUtf8 = i3, this.utf8OffsetToUtf16 = o2;
}
createString(t4) {
const n4 = t4._omalloc(this.utf8Length);
return t4.HEAPU8.set(this.utf8Value, n4), n4;
}
}
class s {
constructor(t4) {
if (this.id = ++s.LAST_ID, !o)
throw new Error("Must invoke loadWASM first.");
this._onigBinding = o, this.content = t4;
const n4 = new f2(t4);
this.utf16Length = n4.utf16Length, this.utf8Length = n4.utf8Length, this.utf16OffsetToUtf8 = n4.utf16OffsetToUtf8, this.utf8OffsetToUtf16 = n4.utf8OffsetToUtf16, this.utf8Length < 1e4 && !s._sharedPtrInUse ? (s._sharedPtr || (s._sharedPtr = o._omalloc(1e4)), s._sharedPtrInUse = true, o.HEAPU8.set(n4.utf8Value, s._sharedPtr), this.ptr = s._sharedPtr) : this.ptr = n4.createString(o);
}
convertUtf8OffsetToUtf16(t4) {
return this.utf8OffsetToUtf16 ? t4 < 0 ? 0 : t4 > this.utf8Length ? this.utf16Length : this.utf8OffsetToUtf16[t4] : t4;
}
convertUtf16OffsetToUtf8(t4) {
return this.utf16OffsetToUtf8 ? t4 < 0 ? 0 : t4 > this.utf16Length ? this.utf8Length : this.utf16OffsetToUtf8[t4] : t4;
}
dispose() {
this.ptr === s._sharedPtr ? s._sharedPtrInUse = false : this._onigBinding._ofree(this.ptr);
}
}
n3.OnigString = s, s.LAST_ID = 0, s._sharedPtr = 0, s._sharedPtrInUse = false;
class u2 {
constructor(t4) {
if (!o)
throw new Error("Must invoke loadWASM first.");
const n4 = [], e3 = [];
for (let r4 = 0, i4 = t4.length; r4 < i4; r4++) {
const i5 = new f2(t4[r4]);
n4[r4] = i5.createString(o), e3[r4] = i5.utf8Length;
}
const r3 = o._omalloc(4 * t4.length);
o.HEAPU32.set(n4, r3 / 4);
const i3 = o._omalloc(4 * t4.length);
o.HEAPU32.set(e3, i3 / 4);
const a3 = o._createOnigScanner(r3, i3, t4.length);
for (let e4 = 0, r4 = t4.length; e4 < r4; e4++)
o._ofree(n4[e4]);
o._ofree(i3), o._ofree(r3), 0 === a3 && function(t5) {
throw new Error(t5.UTF8ToString(t5._getLastOnigError()));
}(o), this._onigBinding = o, this._ptr = a3;
}
dispose() {
this._onigBinding._freeOnigScanner(this._ptr);
}
findNextMatchSync(t4, n4, e3) {
let r3 = a2, i3 = 0;
if ("number" == typeof e3 ? (8 & e3 && (r3 = true), i3 = e3) : "boolean" == typeof e3 && (r3 = e3), "string" == typeof t4) {
t4 = new s(t4);
const e4 = this._findNextMatchSync(t4, n4, r3, i3);
return t4.dispose(), e4;
}
return this._findNextMatchSync(t4, n4, r3, i3);
}
_findNextMatchSync(t4, n4, e3, r3) {
const i3 = this._onigBinding;
let o2;
if (o2 = e3 ? i3._findNextOnigScannerMatchDbg(this._ptr, t4.id, t4.ptr, t4.utf8Length, t4.convertUtf16OffsetToUtf8(n4), r3) : i3._findNextOnigScannerMatch(this._ptr, t4.id, t4.ptr, t4.utf8Length, t4.convertUtf16OffsetToUtf8(n4), r3), 0 === o2)
return null;
const a3 = i3.HEAPU32;
let f3 = o2 / 4;
const s2 = a3[f3++], u3 = a3[f3++];
let c3 = [];
for (let n5 = 0; n5 < u3; n5++) {
const e4 = t4.convertUtf8OffsetToUtf16(a3[f3++]), r4 = t4.convertUtf8OffsetToUtf16(a3[f3++]);
c3[n5] = { start: e4, end: r4, length: r4 - e4 };
}
return { index: s2, captureIndices: c3 };
}
}
n3.OnigScanner = u2;
let c2 = false, l = null;
n3.loadWASM = function(t4) {
if (c2)
return l;
let n4, e3, r3, a3;
if (c2 = true, function(t5) {
return "function" == typeof t5.instantiator;
}(t4))
n4 = t4.instantiator, e3 = t4.print;
else {
let r4;
!function(t5) {
return void 0 !== t5.data;
}(t4) ? r4 = t4 : (r4 = t4.data, e3 = t4.print), n4 = function(t5) {
return "undefined" != typeof Response && t5 instanceof Response;
}(r4) ? "function" == typeof WebAssembly.instantiateStreaming ? function(t5) {
return (n5) => WebAssembly.instantiateStreaming(t5, n5);
}(r4) : function(t5) {
return async (n5) => {
const e4 = await t5.arrayBuffer();
return WebAssembly.instantiate(e4, n5);
};
}(r4) : function(t5) {
return (n5) => WebAssembly.instantiate(t5, n5);
}(r4);
}
return l = new Promise((t5, n5) => {
r3 = t5, a3 = n5;
}), function(t5, n5, e4, r4) {
(0, i2.default)({ print: n5, instantiateWasm: (n6, e5) => {
if ("undefined" == typeof performance) {
const t6 = () => Date.now();
n6.env.emscripten_get_now = t6, n6.wasi_snapshot_preview1.emscripten_get_now = t6;
}
return t5(n6).then((t6) => e5(t6.instance), r4), {};
} }).then((t6) => {
o = t6, e4();
});
}(n4, e3, r3, a3), l;
}, n3.createOnigString = function(t4) {
return new s(t4);
}, n3.createOnigScanner = function(t4) {
return new u2(t4);
}, n3.setDefaultDebugCall = function(t4) {
a2 = t4;
};
}, 418: (t3) => {
var n3 = ("undefined" != typeof document && document.currentScript && document.currentScript.src, function(t4) {
var n4, e2, r2 = void 0 !== (t4 = t4 || {}) ? t4 : {};
r2.ready = new Promise(function(t5, r3) {
n4 = t5, e2 = r3;
});
var i2, o = Object.assign({}, r2), s = false, c2 = "";
function l(t5) {
return r2.locateFile ? r2.locateFile(t5, c2) : c2 + t5;
}
i2 = function(t5) {
let n5;
return "function" == typeof readbuffer ? new Uint8Array(readbuffer(t5)) : (n5 = read(t5, "binary"), m2("object" == typeof n5), n5);
}, "undefined" != typeof scriptArgs ? scriptArgs : void 0 !== arguments && arguments, "undefined" != typeof onig_print && ("undefined" == typeof console && (console = {}), console.log = onig_print, console.warn = console.error = "undefined" != typeof printErr ? printErr : onig_print);
var h2, p2, d2 = r2.print || console.log.bind(console), g = r2.printErr || console.warn.bind(console);
Object.assign(r2, o), o = null, r2.arguments && r2.arguments, r2.thisProgram && r2.thisProgram, r2.quit && r2.quit, r2.wasmBinary && (h2 = r2.wasmBinary), r2.noExitRuntime, "object" != typeof WebAssembly && k2("no native wasm support detected");
var _ = false;
function m2(t5, n5) {
t5 || k2(n5);
}
var y2, w2, S2, v2 = "undefined" != typeof TextDecoder ? new TextDecoder("utf8") : void 0;
function A3(t5, n5, e3) {
for (var r3 = n5 + e3, i3 = n5; t5[i3] && !(i3 >= r3); )
++i3;
if (i3 - n5 > 16 && t5.buffer && v2)
return v2.decode(t5.subarray(n5, i3));
for (var o2 = ""; n5 < i3; ) {
var a2 = t5[n5++];
if (128 & a2) {
var f2 = 63 & t5[n5++];
if (192 != (224 & a2)) {
var s2 = 63 & t5[n5++];
if ((a2 = 224 == (240 & a2) ? (15 & a2) << 12 | f2 << 6 | s2 : (7 & a2) << 18 | f2 << 12 | s2 << 6 | 63 & t5[n5++]) < 65536)
o2 += String.fromCharCode(a2);
else {
var u2 = a2 - 65536;
o2 += String.fromCharCode(55296 | u2 >> 10, 56320 | 1023 & u2);
}
} else
o2 += String.fromCharCode((31 & a2) << 6 | f2);
} else
o2 += String.fromCharCode(a2);
}
return o2;
}
function b3(t5, n5) {
return t5 ? A3(w2, t5, n5) : "";
}
function O2(t5) {
y2 = t5, r2.HEAP8 = new Int8Array(t5), r2.HEAP16 = new Int16Array(t5), r2.HEAP32 = new Int32Array(t5), r2.HEAPU8 = w2 = new Uint8Array(t5), r2.HEAPU16 = new Uint16Array(t5), r2.HEAPU32 = S2 = new Uint32Array(t5), r2.HEAPF32 = new Float32Array(t5), r2.HEAPF64 = new Float64Array(t5);
}
r2.INITIAL_MEMORY;
var U2 = [], P3 = [], R2 = [];
function x2() {
if (r2.preRun)
for ("function" == typeof r2.preRun && (r2.preRun = [r2.preRun]); r2.preRun.length; )
M2(r2.preRun.shift());
G3(U2);
}
function T2() {
G3(P3);
}
function E3() {
if (r2.postRun)
for ("function" == typeof r2.postRun && (r2.postRun = [r2.postRun]); r2.postRun.length; )
I2(r2.postRun.shift());
G3(R2);
}
function M2(t5) {
U2.unshift(t5);
}
function L2(t5) {
P3.unshift(t5);
}
function I2(t5) {
R2.unshift(t5);
}
var W3 = 0, C2 = null;
function N3(t5) {
W3++, r2.monitorRunDependencies && r2.monitorRunDependencies(W3);
}
function j2(t5) {
if (W3--, r2.monitorRunDependencies && r2.monitorRunDependencies(W3), 0 == W3 && C2) {
var n5 = C2;
C2 = null, n5();
}
}
function k2(t5) {
r2.onAbort && r2.onAbort(t5), g(t5 = "Aborted(" + t5 + ")"), _ = true, t5 += ". Build with -sASSERTIONS for more info.";
var n5 = new WebAssembly.RuntimeError(t5);
throw e2(n5), n5;
}
var B3, H2, F2 = "data:application/octet-stream;base64,";
function V2(t5) {
return t5.startsWith(F2);
}
function z2(t5) {
try {
if (t5 == B3 && h2)
return new Uint8Array(h2);
if (i2)
return i2(t5);
throw "both async and sync fetching of the wasm failed";
} catch (t6) {
k2(t6);
}
}
function q2() {
return h2 || !s || "function" != typeof fetch ? Promise.resolve().then(function() {
return z2(B3);
}) : fetch(B3, { credentials: "same-origin" }).then(function(t5) {
if (!t5.ok)
throw "failed to load wasm binary file at '" + B3 + "'";
return t5.arrayBuffer();
}).catch(function() {
return z2(B3);
});
}
function Y2() {
var t5 = { env: nt2, wasi_snapshot_preview1: nt2 };
function n5(t6, n6) {
var e3 = t6.exports;
r2.asm = e3, O2((p2 = r2.asm.memory).buffer), r2.asm.__indirect_function_table, L2(r2.asm.__wasm_call_ctors), j2();
}
function i3(t6) {
n5(t6.instance);
}
function o2(n6) {
return q2().then(function(n7) {
return WebAssembly.instantiate(n7, t5);
}).then(function(t6) {
return t6;
}).then(n6, function(t6) {
g("failed to asynchronously prepare wasm: " + t6), k2(t6);
});
}
if (N3(), r2.instantiateWasm)
try {
return r2.instantiateWasm(t5, n5);
} catch (t6) {
g("Module.instantiateWasm callback failed with error: " + t6), e2(t6);
}
return (h2 || "function" != typeof WebAssembly.instantiateStreaming || V2(B3) || "function" != typeof fetch ? o2(i3) : fetch(B3, { credentials: "same-origin" }).then(function(n6) {
return WebAssembly.instantiateStreaming(n6, t5).then(i3, function(t6) {
return g("wasm streaming compile failed: " + t6), g("falling back to ArrayBuffer instantiation"), o2(i3);
});
})).catch(e2), {};
}
function G3(t5) {
for (; t5.length > 0; )
t5.shift()(r2);
}
function J3(t5, n5, e3) {
w2.copyWithin(t5, n5, n5 + e3);
}
function K2(t5) {
try {
return p2.grow(t5 - y2.byteLength + 65535 >>> 16), O2(p2.buffer), 1;
} catch (t6) {
}
}
function Q2(t5) {
var n5, e3 = w2.length, r3 = 2147483648;
if ((t5 >>>= 0) > r3)
return false;
for (var i3 = 1; i3 <= 4; i3 *= 2) {
var o2 = e3 * (1 + 0.2 / i3);
if (o2 = Math.min(o2, t5 + 100663296), K2(Math.min(r3, (n5 = Math.max(t5, o2)) + (65536 - n5 % 65536) % 65536)))
return true;
}
return false;
}
V2(B3 = "onig.wasm") || (B3 = l(B3)), H2 = "undefined" != typeof dateNow ? dateNow : () => performance.now();
var X2 = [null, [], []];
function Z2(t5, n5) {
var e3 = X2[t5];
0 === n5 || 10 === n5 ? ((1 === t5 ? d2 : g)(A3(e3, 0)), e3.length = 0) : e3.push(n5);
}
function $2(t5, n5, e3, r3) {
for (var i3 = 0, o2 = 0; o2 < e3; o2++) {
var a2 = S2[n5 >> 2], f2 = S2[n5 + 4 >> 2];
n5 += 8;
for (var s2 = 0; s2 < f2; s2++)
Z2(t5, w2[a2 + s2]);
i3 += f2;
}
return S2[r3 >> 2] = i3, 0;
}
var tt, nt2 = { emscripten_get_now: H2, emscripten_memcpy_big: J3, emscripten_resize_heap: Q2, fd_write: $2 };
function et(t5) {
function e3() {
tt || (tt = true, r2.calledRun = true, _ || (T2(), n4(r2), r2.onRuntimeInitialized && r2.onRuntimeInitialized(), E3()));
}
W3 > 0 || (x2(), W3 > 0 || (r2.setStatus ? (r2.setStatus("Running..."), setTimeout(function() {
setTimeout(function() {
r2.setStatus("");
}, 1), e3();
}, 1)) : e3()));
}
if (Y2(), r2.___wasm_call_ctors = function() {
return (r2.___wasm_call_ctors = r2.asm.__wasm_call_ctors).apply(null, arguments);
}, r2.___errno_location = function() {
return (r2.___errno_location = r2.asm.__errno_location).apply(null, arguments);
}, r2._omalloc = function() {
return (r2._omalloc = r2.asm.omalloc).apply(null, arguments);
}, r2._ofree = function() {
return (r2._ofree = r2.asm.ofree).apply(null, arguments);
}, r2._getLastOnigError = function() {
return (r2._getLastOnigError = r2.asm.getLastOnigError).apply(null, arguments);
}, r2._createOnigScanner = function() {
return (r2._createOnigScanner = r2.asm.createOnigScanner).apply(null, arguments);
}, r2._freeOnigScanner = function() {
return (r2._freeOnigScanner = r2.asm.freeOnigScanner).apply(null, arguments);
}, r2._findNextOnigScannerMatch = function() {
return (r2._findNextOnigScannerMatch = r2.asm.findNextOnigScannerMatch).apply(null, arguments);
}, r2._findNextOnigScannerMatchDbg = function() {
return (r2._findNextOnigScannerMatchDbg = r2.asm.findNextOnigScannerMatchDbg).apply(null, arguments);
}, r2.stackSave = function() {
return (r2.stackSave = r2.asm.stackSave).apply(null, arguments);
}, r2.stackRestore = function() {
return (r2.stackRestore = r2.asm.stackRestore).apply(null, arguments);
}, r2.stackAlloc = function() {
return (r2.stackAlloc = r2.asm.stackAlloc).apply(null, arguments);
}, r2.dynCall_jiji = function() {
return (r2.dynCall_jiji = r2.asm.dynCall_jiji).apply(null, arguments);
}, r2.UTF8ToString = b3, C2 = function t5() {
tt || et(), tt || (C2 = t5);
}, r2.preInit)
for ("function" == typeof r2.preInit && (r2.preInit = [r2.preInit]); r2.preInit.length > 0; )
r2.preInit.pop()();
return et(), t4.ready;
});
t3.exports = n3;
} }, n2 = {}, function e2(r2) {
var i2 = n2[r2];
if (void 0 !== i2)
return i2.exports;
var o = n2[r2] = { exports: {} };
return t2[r2].call(o.exports, o, o.exports, e2), o.exports;
}(770);
var t2, n2;
});
})(main$1);
var mainExports = {};
var main = {
get exports() {
return mainExports;
},
set exports(v2) {
mainExports = v2;
}
};
(function(module2, exports) {
!function(e2, t2) {
module2.exports = t2();
}(commonjsGlobal$1, function() {
return (() => {
var e2 = { 350: (e3, t3) => {
Object.defineProperty(t3, "__esModule", { value: true }), t3.UseOnigurumaFindOptions = t3.DebugFlags = void 0, t3.DebugFlags = { InDebugMode: "undefined" != typeof process && !!{}.VSCODE_TEXTMATE_DEBUG }, t3.UseOnigurumaFindOptions = false;
}, 36: (e3, t3) => {
var n2;
Object.defineProperty(t3, "__esModule", { value: true }), t3.toOptionalTokenType = t3.EncodedTokenAttributes = void 0, (n2 = t3.EncodedTokenAttributes || (t3.EncodedTokenAttributes = {})).toBinaryStr = function(e4) {
let t4 = e4.toString(2);
for (; t4.length < 32; )
t4 = "0" + t4;
return t4;
}, n2.print = function(e4) {
const t4 = n2.getLanguageId(e4), s = n2.getTokenType(e4), r2 = n2.getFontStyle(e4), i2 = n2.getForeground(e4), o = n2.getBackground(e4);
console.log({ languageId: t4, tokenType: s, fontStyle: r2, foreground: i2, background: o });
}, n2.getLanguageId = function(e4) {
return (255 & e4) >>> 0;
}, n2.getTokenType = function(e4) {
return (768 & e4) >>> 8;
}, n2.containsBalancedBrackets = function(e4) {
return 0 != (1024 & e4);
}, n2.getFontStyle = function(e4) {
return (30720 & e4) >>> 11;
}, n2.getForeground = function(e4) {
return (16744448 & e4) >>> 15;
}, n2.getBackground = function(e4) {
return (4278190080 & e4) >>> 24;
}, n2.set = function(e4, t4, s, r2, i2, o, c2) {
let a2 = n2.getLanguageId(e4), l = n2.getTokenType(e4), u2 = n2.containsBalancedBrackets(e4) ? 1 : 0, h2 = n2.getFontStyle(e4), p2 = n2.getForeground(e4), d2 = n2.getBackground(e4);
return 0 !== t4 && (a2 = t4), 8 !== s && (l = s), null !== r2 && (u2 = r2 ? 1 : 0), -1 !== i2 && (h2 = i2), 0 !== o && (p2 = o), 0 !== c2 && (d2 = c2), (a2 << 0 | l << 8 | u2 << 10 | h2 << 11 | p2 << 15 | d2 << 24) >>> 0;
}, t3.toOptionalTokenType = function(e4) {
return e4;
};
}, 996: (e3, t3, n2) => {
Object.defineProperty(t3, "__esModule", { value: true }), t3.BasicScopeAttributesProvider = t3.BasicScopeAttributes = void 0;
const s = n2(878);
class r2 {
constructor(e4, t4) {
this.languageId = e4, this.tokenType = t4;
}
}
t3.BasicScopeAttributes = r2;
class i2 {
constructor(e4, t4) {
this._getBasicScopeAttributes = new s.CachedFn((e5) => {
const t5 = this._scopeToLanguage(e5), n3 = this._toStandardTokenType(e5);
return new r2(t5, n3);
}), this._defaultAttributes = new r2(e4, 8), this._embeddedLanguagesMatcher = new o(Object.entries(t4 || {}));
}
getDefaultAttributes() {
return this._defaultAttributes;
}
getBasicScopeAttributes(e4) {
return null === e4 ? i2._NULL_SCOPE_METADATA : this._getBasicScopeAttributes.get(e4);
}
_scopeToLanguage(e4) {
return this._embeddedLanguagesMatcher.match(e4) || 0;
}
_toStandardTokenType(e4) {
const t4 = e4.match(i2.STANDARD_TOKEN_TYPE_REGEXP);
if (!t4)
return 8;
switch (t4[1]) {
case "comment":
return 1;
case "string":
return 2;
case "regex":
return 3;
case "meta.embedded":
return 0;
}
throw new Error("Unexpected match for standard token type!");
}
}
t3.BasicScopeAttributesProvider = i2, i2._NULL_SCOPE_METADATA = new r2(0, 0), i2.STANDARD_TOKEN_TYPE_REGEXP = /\b(comment|string|regex|meta\.embedded)\b/;
class o {
constructor(e4) {
if (0 === e4.length)
this.values = null, this.scopesRegExp = null;
else {
this.values = new Map(e4);
const t4 = e4.map(([e5, t5]) => s.escapeRegExpCharacters(e5));
t4.sort(), t4.reverse(), this.scopesRegExp = new RegExp(`^((${t4.join(")|(")}))($|\\.)`, "");
}
}
match(e4) {
if (!this.scopesRegExp)
return;
const t4 = e4.match(this.scopesRegExp);
return t4 ? this.values.get(t4[1]) : void 0;
}
}
}, 947: (e3, t3, n2) => {
Object.defineProperty(t3, "__esModule", { value: true }), t3.LineTokens = t3.BalancedBracketSelectors = t3.StateStack = t3.AttributedScopeStack = t3.Grammar = t3.createGrammar = void 0;
const s = n2(350), r2 = n2(36), i2 = n2(736), o = n2(44), c2 = n2(792), a2 = n2(583), l = n2(878), u2 = n2(996), h2 = n2(47);
function p2(e4, t4, n3, s2, r3) {
const o2 = i2.createMatchers(t4, d2), a3 = c2.RuleFactory.getCompiledRuleId(n3, s2, r3.repository);
for (const n4 of o2)
e4.push({ debugSelector: t4, matcher: n4.matcher, ruleId: a3, grammar: r3, priority: n4.priority });
}
function d2(e4, t4) {
if (t4.length < e4.length)
return false;
let n3 = 0;
return e4.every((e5) => {
for (let s2 = n3; s2 < t4.length; s2++)
if (f2(t4[s2], e5))
return n3 = s2 + 1, true;
return false;
});
}
function f2(e4, t4) {
if (!e4)
return false;
if (e4 === t4)
return true;
const n3 = t4.length;
return e4.length > n3 && e4.substr(0, n3) === t4 && "." === e4[n3];
}
t3.createGrammar = function(e4, t4, n3, s2, r3, i3, o2, c3) {
return new g(e4, t4, n3, s2, r3, i3, o2, c3);
};
class g {
constructor(e4, t4, n3, s2, r3, o2, c3, a3) {
if (this._rootScopeName = e4, this.balancedBracketSelectors = o2, this._onigLib = a3, this._basicScopeAttributesProvider = new u2.BasicScopeAttributesProvider(n3, s2), this._rootId = -1, this._lastRuleId = 0, this._ruleId2desc = [null], this._includedGrammars = {}, this._grammarRepository = c3, this._grammar = m2(t4, null), this._injections = null, this._tokenTypeMatchers = [], r3)
for (const e5 of Object.keys(r3)) {
const t5 = i2.createMatchers(e5, d2);
for (const n4 of t5)
this._tokenTypeMatchers.push({ matcher: n4.matcher, type: r3[e5] });
}
}
get themeProvider() {
return this._grammarRepository;
}
dispose() {
for (const e4 of this._ruleId2desc)
e4 && e4.dispose();
}
createOnigScanner(e4) {
return this._onigLib.createOnigScanner(e4);
}
createOnigString(e4) {
return this._onigLib.createOnigString(e4);
}
getMetadataForScope(e4) {
return this._basicScopeAttributesProvider.getBasicScopeAttributes(e4);
}
_collectInjections() {
const e4 = [], t4 = this._rootScopeName, n3 = ((e5) => e5 === this._rootScopeName ? this._grammar : this.getExternalGrammar(e5))(t4);
if (n3) {
const s2 = n3.injections;
if (s2)
for (let t5 in s2)
p2(e4, t5, s2[t5], this, n3);
const r3 = this._grammarRepository.injections(t4);
r3 && r3.forEach((t5) => {
const n4 = this.getExternalGrammar(t5);
if (n4) {
const t6 = n4.injectionSelector;
t6 && p2(e4, t6, n4, this, n4);
}
});
}
return e4.sort((e5, t5) => e5.priority - t5.priority), e4;
}
getInjections() {
if (null === this._injections && (this._injections = this._collectInjections(), s.DebugFlags.InDebugMode && this._injections.length > 0)) {
console.log(`Grammar ${this._rootScopeName} contains the following injections:`);
for (const e4 of this._injections)
console.log(` - ${e4.debugSelector}`);
}
return this._injections;
}
registerRule(e4) {
const t4 = ++this._lastRuleId, n3 = e4(c2.ruleIdFromNumber(t4));
return this._ruleId2desc[t4] = n3, n3;
}
getRule(e4) {
return this._ruleId2desc[c2.ruleIdToNumber(e4)];
}
getExternalGrammar(e4, t4) {
if (this._includedGrammars[e4])
return this._includedGrammars[e4];
if (this._grammarRepository) {
const n3 = this._grammarRepository.lookup(e4);
if (n3)
return this._includedGrammars[e4] = m2(n3, t4 && t4.$base), this._includedGrammars[e4];
}
}
tokenizeLine(e4, t4, n3 = 0) {
const s2 = this._tokenize(e4, t4, false, n3);
return { tokens: s2.lineTokens.getResult(s2.ruleStack, s2.lineLength), ruleStack: s2.ruleStack, stoppedEarly: s2.stoppedEarly };
}
tokenizeLine2(e4, t4, n3 = 0) {
const s2 = this._tokenize(e4, t4, true, n3);
return { tokens: s2.lineTokens.getBinaryResult(s2.ruleStack, s2.lineLength), ruleStack: s2.ruleStack, stoppedEarly: s2.stoppedEarly };
}
_tokenize(e4, t4, n3, s2) {
let i3;
if (-1 === this._rootId && (this._rootId = c2.RuleFactory.getCompiledRuleId(this._grammar.repository.$self, this, this._grammar.repository)), t4 && t4 !== b3.NULL)
i3 = false, t4.reset();
else {
i3 = true;
const e5 = this._basicScopeAttributesProvider.getDefaultAttributes(), n4 = this.themeProvider.getDefaults(), s3 = r2.EncodedTokenAttributes.set(0, e5.languageId, e5.tokenType, null, n4.fontStyle, n4.foregroundId, n4.backgroundId), o2 = this.getRule(this._rootId).getName(null, null);
let c3;
c3 = o2 ? _.createRootAndLookUpScopeName(o2, s3, this) : _.createRoot("unknown", s3), t4 = new b3(null, this._rootId, -1, -1, false, null, c3, c3);
}
e4 += "\n";
const a3 = this.createOnigString(e4), l2 = a3.content.length, u3 = new y2(n3, e4, this._tokenTypeMatchers, this.balancedBracketSelectors), p3 = h2._tokenizeString(this, a3, i3, 0, t4, u3, true, s2);
return o.disposeOnigString(a3), { lineLength: l2, lineTokens: u3, ruleStack: p3.stack, stoppedEarly: p3.stoppedEarly };
}
}
function m2(e4, t4) {
return (e4 = l.clone(e4)).repository = e4.repository || {}, e4.repository.$self = { $vscodeTextmateLocation: e4.$vscodeTextmateLocation, patterns: e4.patterns, name: e4.scopeName }, e4.repository.$base = t4 || e4.repository.$self, e4;
}
t3.Grammar = g;
class _ {
constructor(e4, t4, n3) {
this.parent = e4, this.scopePath = t4, this.tokenAttributes = n3;
}
static createRoot(e4, t4) {
return new _(null, new a2.ScopeStack(null, e4), t4);
}
static createRootAndLookUpScopeName(e4, t4, n3) {
const s2 = n3.getMetadataForScope(e4), r3 = new a2.ScopeStack(null, e4), i3 = n3.themeProvider.themeMatch(r3), o2 = _.mergeAttributes(t4, s2, i3);
return new _(null, r3, o2);
}
get scopeName() {
return this.scopePath.scopeName;
}
equals(e4) {
return _._equals(this, e4);
}
static _equals(e4, t4) {
for (; ; ) {
if (e4 === t4)
return true;
if (!e4 && !t4)
return true;
if (!e4 || !t4)
return false;
if (e4.scopeName !== t4.scopeName || e4.tokenAttributes !== t4.tokenAttributes)
return false;
e4 = e4.parent, t4 = t4.parent;
}
}
static mergeAttributes(e4, t4, n3) {
let s2 = -1, i3 = 0, o2 = 0;
return null !== n3 && (s2 = n3.fontStyle, i3 = n3.foregroundId, o2 = n3.backgroundId), r2.EncodedTokenAttributes.set(e4, t4.languageId, t4.tokenType, null, s2, i3, o2);
}
pushAttributed(e4, t4) {
if (null === e4)
return this;
if (-1 === e4.indexOf(" "))
return _._pushAttributed(this, e4, t4);
const n3 = e4.split(/ /g);
let s2 = this;
for (const e5 of n3)
s2 = _._pushAttributed(s2, e5, t4);
return s2;
}
static _pushAttributed(e4, t4, n3) {
const s2 = n3.getMetadataForScope(t4), r3 = e4.scopePath.push(t4), i3 = n3.themeProvider.themeMatch(r3), o2 = _.mergeAttributes(e4.tokenAttributes, s2, i3);
return new _(e4, r3, o2);
}
getScopeNames() {
return this.scopePath.getSegments();
}
}
t3.AttributedScopeStack = _;
class b3 {
constructor(e4, t4, n3, s2, r3, i3, o2, c3) {
this.parent = e4, this.ruleId = t4, this.beginRuleCapturedEOL = r3, this.endRule = i3, this.nameScopesList = o2, this.contentNameScopesList = c3, this._stackElementBrand = void 0, this.depth = this.parent ? this.parent.depth + 1 : 1, this._enterPos = n3, this._anchorPos = s2;
}
equals(e4) {
return null !== e4 && b3._equals(this, e4);
}
static _equals(e4, t4) {
return e4 === t4 || !!this._structuralEquals(e4, t4) && e4.contentNameScopesList.equals(t4.contentNameScopesList);
}
static _structuralEquals(e4, t4) {
for (; ; ) {
if (e4 === t4)
return true;
if (!e4 && !t4)
return true;
if (!e4 || !t4)
return false;
if (e4.depth !== t4.depth || e4.ruleId !== t4.ruleId || e4.endRule !== t4.endRule)
return false;
e4 = e4.parent, t4 = t4.parent;
}
}
clone() {
return this;
}
static _reset(e4) {
for (; e4; )
e4._enterPos = -1, e4._anchorPos = -1, e4 = e4.parent;
}
reset() {
b3._reset(this);
}
pop() {
return this.parent;
}
safePop() {
return this.parent ? this.parent : this;
}
push(e4, t4, n3, s2, r3, i3, o2) {
return new b3(this, e4, t4, n3, s2, r3, i3, o2);
}
getEnterPos() {
return this._enterPos;
}
getAnchorPos() {
return this._anchorPos;
}
getRule(e4) {
return e4.getRule(this.ruleId);
}
toString() {
const e4 = [];
return this._writeString(e4, 0), "[" + e4.join(",") + "]";
}
_writeString(e4, t4) {
return this.parent && (t4 = this.parent._writeString(e4, t4)), e4[t4++] = `(${this.ruleId}, TODO-${this.nameScopesList}, TODO-${this.contentNameScopesList})`, t4;
}
withContentNameScopesList(e4) {
return this.contentNameScopesList === e4 ? this : this.parent.push(this.ruleId, this._enterPos, this._anchorPos, this.beginRuleCapturedEOL, this.endRule, this.nameScopesList, e4);
}
withEndRule(e4) {
return this.endRule === e4 ? this : new b3(this.parent, this.ruleId, this._enterPos, this._anchorPos, this.beginRuleCapturedEOL, e4, this.nameScopesList, this.contentNameScopesList);
}
hasSameRuleAs(e4) {
let t4 = this;
for (; t4 && t4._enterPos === e4._enterPos; ) {
if (t4.ruleId === e4.ruleId)
return true;
t4 = t4.parent;
}
return false;
}
}
t3.StateStack = b3, b3.NULL = new b3(null, 0, 0, 0, false, null, null, null), t3.BalancedBracketSelectors = class {
constructor(e4, t4) {
this.allowAny = false, this.balancedBracketScopes = e4.flatMap((e5) => "*" === e5 ? (this.allowAny = true, []) : i2.createMatchers(e5, d2).map((e6) => e6.matcher)), this.unbalancedBracketScopes = t4.flatMap((e5) => i2.createMatchers(e5, d2).map((e6) => e6.matcher));
}
get matchesAlways() {
return this.allowAny && 0 === this.unbalancedBracketScopes.length;
}
get matchesNever() {
return 0 === this.balancedBracketScopes.length && !this.allowAny;
}
match(e4) {
for (const t4 of this.unbalancedBracketScopes)
if (t4(e4))
return false;
for (const t4 of this.balancedBracketScopes)
if (t4(e4))
return true;
return this.allowAny;
}
};
class y2 {
constructor(e4, t4, n3, r3) {
this.balancedBracketSelectors = r3, this._emitBinaryTokens = e4, this._tokenTypeOverrides = n3, s.DebugFlags.InDebugMode ? this._lineText = t4 : this._lineText = null, this._tokens = [], this._binaryTokens = [], this._lastTokenEndIndex = 0;
}
produce(e4, t4) {
this.produceFromScopes(e4.contentNameScopesList, t4);
}
produceFromScopes(e4, t4) {
var _a3;
if (this._lastTokenEndIndex >= t4)
return;
if (this._emitBinaryTokens) {
let n4 = e4.tokenAttributes, i3 = false;
if (((_a3 = this.balancedBracketSelectors) == null ? void 0 : _a3.matchesAlways) && (i3 = true), this._tokenTypeOverrides.length > 0 || this.balancedBracketSelectors && !this.balancedBracketSelectors.matchesAlways && !this.balancedBracketSelectors.matchesNever) {
const t5 = e4.getScopeNames();
for (const e5 of this._tokenTypeOverrides)
e5.matcher(t5) && (n4 = r2.EncodedTokenAttributes.set(n4, 0, r2.toOptionalTokenType(e5.type), null, -1, 0, 0));
this.balancedBracketSelectors && (i3 = this.balancedBracketSelectors.match(t5));
}
if (i3 && (n4 = r2.EncodedTokenAttributes.set(n4, 0, 8, i3, -1, 0, 0)), this._binaryTokens.length > 0 && this._binaryTokens[this._binaryTokens.length - 1] === n4)
return void (this._lastTokenEndIndex = t4);
if (s.DebugFlags.InDebugMode) {
const n5 = e4.getScopeNames();
console.log(" token: |" + this._lineText.substring(this._lastTokenEndIndex, t4).replace(/\n$/, "\\n") + "|");
for (let e5 = 0; e5 < n5.length; e5++)
console.log(" * " + n5[e5]);
}
return this._binaryTokens.push(this._lastTokenEndIndex), this._binaryTokens.push(n4), void (this._lastTokenEndIndex = t4);
}
const n3 = e4.getScopeNames();
if (s.DebugFlags.InDebugMode) {
console.log(" token: |" + this._lineText.substring(this._lastTokenEndIndex, t4).replace(/\n$/, "\\n") + "|");
for (let e5 = 0; e5 < n3.length; e5++)
console.log(" * " + n3[e5]);
}
this._tokens.push({ startIndex: this._lastTokenEndIndex, endIndex: t4, scopes: n3 }), this._lastTokenEndIndex = t4;
}
getResult(e4, t4) {
return this._tokens.length > 0 && this._tokens[this._tokens.length - 1].startIndex === t4 - 1 && this._tokens.pop(), 0 === this._tokens.length && (this._lastTokenEndIndex = -1, this.produce(e4, t4), this._tokens[this._tokens.length - 1].startIndex = 0), this._tokens;
}
getBinaryResult(e4, t4) {
this._binaryTokens.length > 0 && this._binaryTokens[this._binaryTokens.length - 2] === t4 - 1 && (this._binaryTokens.pop(), this._binaryTokens.pop()), 0 === this._binaryTokens.length && (this._lastTokenEndIndex = -1, this.produce(e4, t4), this._binaryTokens[this._binaryTokens.length - 2] = 0);
const n3 = new Uint32Array(this._binaryTokens.length);
for (let e5 = 0, t5 = this._binaryTokens.length; e5 < t5; e5++)
n3[e5] = this._binaryTokens[e5];
return n3;
}
}
t3.LineTokens = y2;
}, 965: (e3, t3, n2) => {
Object.defineProperty(t3, "__esModule", { value: true }), t3.parseInclude = t3.TopLevelRepositoryReference = t3.TopLevelReference = t3.RelativeReference = t3.SelfReference = t3.BaseReference = t3.ScopeDependencyProcessor = t3.ExternalReferenceCollector = t3.TopLevelRepositoryRuleReference = t3.TopLevelRuleReference = void 0;
const s = n2(878);
class r2 {
constructor(e4) {
this.scopeName = e4;
}
toKey() {
return this.scopeName;
}
}
t3.TopLevelRuleReference = r2;
class i2 {
constructor(e4, t4) {
this.scopeName = e4, this.ruleName = t4;
}
toKey() {
return `${this.scopeName}#${this.ruleName}`;
}
}
t3.TopLevelRepositoryRuleReference = i2;
class o {
constructor() {
this._references = [], this._seenReferenceKeys = /* @__PURE__ */ new Set(), this.visitedRule = /* @__PURE__ */ new Set();
}
get references() {
return this._references;
}
add(e4) {
const t4 = e4.toKey();
this._seenReferenceKeys.has(t4) || (this._seenReferenceKeys.add(t4), this._references.push(e4));
}
}
function c2(e4, t4, n3, s2) {
const i3 = n3.lookup(e4.scopeName);
if (!i3) {
if (e4.scopeName === t4)
throw new Error(`No grammar provided for <${t4}>`);
return;
}
const o2 = n3.lookup(t4);
e4 instanceof r2 ? l({ baseGrammar: o2, selfGrammar: i3 }, s2) : a2(e4.ruleName, { baseGrammar: o2, selfGrammar: i3, repository: i3.repository }, s2);
const c3 = n3.injections(e4.scopeName);
if (c3)
for (const e5 of c3)
s2.add(new r2(e5));
}
function a2(e4, t4, n3) {
t4.repository && t4.repository[e4] && u2([t4.repository[e4]], t4, n3);
}
function l(e4, t4) {
e4.selfGrammar.patterns && Array.isArray(e4.selfGrammar.patterns) && u2(e4.selfGrammar.patterns, { ...e4, repository: e4.selfGrammar.repository }, t4), e4.selfGrammar.injections && u2(Object.values(e4.selfGrammar.injections), { ...e4, repository: e4.selfGrammar.repository }, t4);
}
function u2(e4, t4, n3) {
for (const o2 of e4) {
if (n3.visitedRule.has(o2))
continue;
n3.visitedRule.add(o2);
const e5 = o2.repository ? s.mergeObjects({}, t4.repository, o2.repository) : t4.repository;
Array.isArray(o2.patterns) && u2(o2.patterns, { ...t4, repository: e5 }, n3);
const c3 = o2.include;
if (!c3)
continue;
const h3 = m2(c3);
switch (h3.kind) {
case 0:
l({ ...t4, selfGrammar: t4.baseGrammar }, n3);
break;
case 1:
l(t4, n3);
break;
case 2:
a2(h3.ruleName, { ...t4, repository: e5 }, n3);
break;
case 3:
case 4:
const s2 = h3.scopeName === t4.selfGrammar.scopeName ? t4.selfGrammar : h3.scopeName === t4.baseGrammar.scopeName ? t4.baseGrammar : void 0;
if (s2) {
const r3 = { baseGrammar: t4.baseGrammar, selfGrammar: s2, repository: e5 };
4 === h3.kind ? a2(h3.ruleName, r3, n3) : l(r3, n3);
} else
4 === h3.kind ? n3.add(new i2(h3.scopeName, h3.ruleName)) : n3.add(new r2(h3.scopeName));
}
}
}
t3.ExternalReferenceCollector = o, t3.ScopeDependencyProcessor = class {
constructor(e4, t4) {
this.repo = e4, this.initialScopeName = t4, this.seenFullScopeRequests = /* @__PURE__ */ new Set(), this.seenPartialScopeRequests = /* @__PURE__ */ new Set(), this.seenFullScopeRequests.add(this.initialScopeName), this.Q = [new r2(this.initialScopeName)];
}
processQueue() {
const e4 = this.Q;
this.Q = [];
const t4 = new o();
for (const n3 of e4)
c2(n3, this.initialScopeName, this.repo, t4);
for (const e5 of t4.references)
if (e5 instanceof r2) {
if (this.seenFullScopeRequests.has(e5.scopeName))
continue;
this.seenFullScopeRequests.add(e5.scopeName), this.Q.push(e5);
} else {
if (this.seenFullScopeRequests.has(e5.scopeName))
continue;
if (this.seenPartialScopeRequests.has(e5.toKey()))
continue;
this.seenPartialScopeRequests.add(e5.toKey()), this.Q.push(e5);
}
}
};
class h2 {
constructor() {
this.kind = 0;
}
}
t3.BaseReference = h2;
class p2 {
constructor() {
this.kind = 1;
}
}
t3.SelfReference = p2;
class d2 {
constructor(e4) {
this.ruleName = e4, this.kind = 2;
}
}
t3.RelativeReference = d2;
class f2 {
constructor(e4) {
this.scopeName = e4, this.kind = 3;
}
}
t3.TopLevelReference = f2;
class g {
constructor(e4, t4) {
this.scopeName = e4, this.ruleName = t4, this.kind = 4;
}
}
function m2(e4) {
if ("$base" === e4)
return new h2();
if ("$self" === e4)
return new p2();
const t4 = e4.indexOf("#");
if (-1 === t4)
return new f2(e4);
if (0 === t4)
return new d2(e4.substring(1));
{
const n3 = e4.substring(0, t4), s2 = e4.substring(t4 + 1);
return new g(n3, s2);
}
}
t3.TopLevelRepositoryReference = g, t3.parseInclude = m2;
}, 391: function(e3, t3, n2) {
var s = this && this.__createBinding || (Object.create ? function(e4, t4, n3, s2) {
void 0 === s2 && (s2 = n3), Object.defineProperty(e4, s2, { enumerable: true, get: function() {
return t4[n3];
} });
} : function(e4, t4, n3, s2) {
void 0 === s2 && (s2 = n3), e4[s2] = t4[n3];
}), r2 = this && this.__exportStar || function(e4, t4) {
for (var n3 in e4)
"default" === n3 || Object.prototype.hasOwnProperty.call(t4, n3) || s(t4, e4, n3);
};
Object.defineProperty(t3, "__esModule", { value: true }), r2(n2(947), t3);
}, 47: (e3, t3, n2) => {
Object.defineProperty(t3, "__esModule", { value: true }), t3.LocalStackElement = t3._tokenizeString = void 0;
const s = n2(350), r2 = n2(44), i2 = n2(792), o = n2(878);
class c2 {
constructor(e4, t4) {
this.stack = e4, this.stoppedEarly = t4;
}
}
function a2(e4, t4, n3, r3, a3, h3, d3, f2) {
const g = t4.content.length;
let m2 = false, _ = -1;
if (d3) {
const o2 = function(e5, t5, n4, r4, o3, c3) {
let a4 = o3.beginRuleCapturedEOL ? 0 : -1;
const l2 = [];
for (let t6 = o3; t6; t6 = t6.pop()) {
const n5 = t6.getRule(e5);
n5 instanceof i2.BeginWhileRule && l2.push({ rule: n5, stack: t6 });
}
for (let h4 = l2.pop(); h4; h4 = l2.pop()) {
const { ruleScanner: l3, findOptions: d4 } = u2(h4.rule, e5, h4.stack.endRule, n4, r4 === a4), f3 = l3.findNextMatchSync(t5, r4, d4);
if (s.DebugFlags.InDebugMode && (console.log(" scanning for while rule"), console.log(l3.toString())), !f3) {
s.DebugFlags.InDebugMode && console.log(" popping " + h4.rule.debugName + " - " + h4.rule.debugWhileRegExp), o3 = h4.stack.pop();
break;
}
if (f3.ruleId !== i2.whileRuleId) {
o3 = h4.stack.pop();
break;
}
f3.captureIndices && f3.captureIndices.length && (c3.produce(h4.stack, f3.captureIndices[0].start), p2(e5, t5, n4, h4.stack, c3, h4.rule.whileCaptures, f3.captureIndices), c3.produce(h4.stack, f3.captureIndices[0].end), a4 = f3.captureIndices[0].end, f3.captureIndices[0].end > r4 && (r4 = f3.captureIndices[0].end, n4 = false));
}
return { stack: o3, linePos: r4, anchorPosition: a4, isFirstLine: n4 };
}(e4, t4, n3, r3, a3, h3);
a3 = o2.stack, r3 = o2.linePos, n3 = o2.isFirstLine, _ = o2.anchorPosition;
}
const b3 = Date.now();
for (; !m2; ) {
if (0 !== f2 && Date.now() - b3 > f2)
return new c2(a3, true);
y2();
}
return new c2(a3, false);
function y2() {
s.DebugFlags.InDebugMode && (console.log(""), console.log(`@@scanNext ${r3}: |${t4.content.substr(r3).replace(/\n$/, "\\n")}|`));
const c3 = function(e5, t5, n4, r4, i3, c4) {
const a4 = function(e6, t6, n5, r5, i4, c5) {
const a5 = i4.getRule(e6), { ruleScanner: u5, findOptions: h5 } = l(a5, e6, i4.endRule, n5, r5 === c5);
let p4 = 0;
s.DebugFlags.InDebugMode && (p4 = o.performanceNow());
const d6 = u5.findNextMatchSync(t6, r5, h5);
if (s.DebugFlags.InDebugMode) {
const e7 = o.performanceNow() - p4;
e7 > 5 && console.warn(`Rule ${a5.debugName} (${a5.id}) matching took ${e7} against '${t6}'`), console.log(` scanning for (linePos: ${r5}, anchorPosition: ${c5})`), console.log(u5.toString()), d6 && console.log(`matched rule id: ${d6.ruleId} from ${d6.captureIndices[0].start} to ${d6.captureIndices[0].end}`);
}
return d6 ? { captureIndices: d6.captureIndices, matchedRuleId: d6.ruleId } : null;
}(e5, t5, n4, r4, i3, c4), u4 = e5.getInjections();
if (0 === u4.length)
return a4;
const h4 = function(e6, t6, n5, r5, i4, o2, c5) {
let a5, u5 = Number.MAX_VALUE, h5 = null, p4 = 0;
const d6 = o2.contentNameScopesList.getScopeNames();
for (let o3 = 0, f4 = e6.length; o3 < f4; o3++) {
const f5 = e6[o3];
if (!f5.matcher(d6))
continue;
const g2 = t6.getRule(f5.ruleId), { ruleScanner: m3, findOptions: _2 } = l(g2, t6, null, r5, i4 === c5), b4 = m3.findNextMatchSync(n5, i4, _2);
if (!b4)
continue;
s.DebugFlags.InDebugMode && (console.log(` matched injection: ${f5.debugSelector}`), console.log(m3.toString()));
const y3 = b4.captureIndices[0].start;
if (!(y3 >= u5) && (u5 = y3, h5 = b4.captureIndices, a5 = b4.ruleId, p4 = f5.priority, u5 === i4))
break;
}
return h5 ? { priorityMatch: -1 === p4, captureIndices: h5, matchedRuleId: a5 } : null;
}(u4, e5, t5, n4, r4, i3, c4);
if (!h4)
return a4;
if (!a4)
return h4;
const p3 = a4.captureIndices[0].start, d5 = h4.captureIndices[0].start;
return d5 < p3 || h4.priorityMatch && d5 === p3 ? h4 : a4;
}(e4, t4, n3, r3, a3, _);
if (!c3)
return s.DebugFlags.InDebugMode && console.log(" no more matches."), h3.produce(a3, g), void (m2 = true);
const u3 = c3.captureIndices, d4 = c3.matchedRuleId, f3 = !!(u3 && u3.length > 0) && u3[0].end > r3;
if (d4 === i2.endRuleId) {
const i3 = a3.getRule(e4);
s.DebugFlags.InDebugMode && console.log(" popping " + i3.debugName + " - " + i3.debugEndRegExp), h3.produce(a3, u3[0].start), a3 = a3.withContentNameScopesList(a3.nameScopesList), p2(e4, t4, n3, a3, h3, i3.endCaptures, u3), h3.produce(a3, u3[0].end);
const o2 = a3;
if (a3 = a3.parent, _ = o2.getAnchorPos(), !f3 && o2.getEnterPos() === r3)
return s.DebugFlags.InDebugMode && console.error("[1] - Grammar is in an endless loop - Grammar pushed & popped a rule without advancing"), a3 = o2, h3.produce(a3, g), void (m2 = true);
} else {
const o2 = e4.getRule(d4);
h3.produce(a3, u3[0].start);
const c4 = a3, l2 = o2.getName(t4.content, u3), b4 = a3.contentNameScopesList.pushAttributed(l2, e4);
if (a3 = a3.push(d4, r3, _, u3[0].end === g, null, b4, b4), o2 instanceof i2.BeginEndRule) {
const r4 = o2;
s.DebugFlags.InDebugMode && console.log(" pushing " + r4.debugName + " - " + r4.debugBeginRegExp), p2(e4, t4, n3, a3, h3, r4.beginCaptures, u3), h3.produce(a3, u3[0].end), _ = u3[0].end;
const i3 = r4.getContentName(t4.content, u3), l3 = b4.pushAttributed(i3, e4);
if (a3 = a3.withContentNameScopesList(l3), r4.endHasBackReferences && (a3 = a3.withEndRule(r4.getEndWithResolvedBackReferences(t4.content, u3))), !f3 && c4.hasSameRuleAs(a3))
return s.DebugFlags.InDebugMode && console.error("[2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing"), a3 = a3.pop(), h3.produce(a3, g), void (m2 = true);
} else if (o2 instanceof i2.BeginWhileRule) {
const r4 = o2;
s.DebugFlags.InDebugMode && console.log(" pushing " + r4.debugName), p2(e4, t4, n3, a3, h3, r4.beginCaptures, u3), h3.produce(a3, u3[0].end), _ = u3[0].end;
const i3 = r4.getContentName(t4.content, u3), l3 = b4.pushAttributed(i3, e4);
if (a3 = a3.withContentNameScopesList(l3), r4.whileHasBackReferences && (a3 = a3.withEndRule(r4.getWhileWithResolvedBackReferences(t4.content, u3))), !f3 && c4.hasSameRuleAs(a3))
return s.DebugFlags.InDebugMode && console.error("[3] - Grammar is in an endless loop - Grammar pushed the same rule without advancing"), a3 = a3.pop(), h3.produce(a3, g), void (m2 = true);
} else {
const r4 = o2;
if (s.DebugFlags.InDebugMode && console.log(" matched " + r4.debugName + " - " + r4.debugMatchRegExp), p2(e4, t4, n3, a3, h3, r4.captures, u3), h3.produce(a3, u3[0].end), a3 = a3.pop(), !f3)
return s.DebugFlags.InDebugMode && console.error("[4] - Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping"), a3 = a3.safePop(), h3.produce(a3, g), void (m2 = true);
}
}
u3[0].end > r3 && (r3 = u3[0].end, n3 = false);
}
}
function l(e4, t4, n3, r3, i3) {
return s.UseOnigurumaFindOptions ? { ruleScanner: e4.compile(t4, n3), findOptions: h2(r3, i3) } : { ruleScanner: e4.compileAG(t4, n3, r3, i3), findOptions: 0 };
}
function u2(e4, t4, n3, r3, i3) {
return s.UseOnigurumaFindOptions ? { ruleScanner: e4.compileWhile(t4, n3), findOptions: h2(r3, i3) } : { ruleScanner: e4.compileWhileAG(t4, n3, r3, i3), findOptions: 0 };
}
function h2(e4, t4) {
let n3 = 0;
return e4 || (n3 |= 1), t4 || (n3 |= 4), n3;
}
function p2(e4, t4, n3, s2, i3, o2, c3) {
if (0 === o2.length)
return;
const l2 = t4.content, u3 = Math.min(o2.length, c3.length), h3 = [], p3 = c3[0].end;
for (let t5 = 0; t5 < u3; t5++) {
const u4 = o2[t5];
if (null === u4)
continue;
const f2 = c3[t5];
if (0 === f2.length)
continue;
if (f2.start > p3)
break;
for (; h3.length > 0 && h3[h3.length - 1].endPos <= f2.start; )
i3.produceFromScopes(h3[h3.length - 1].scopes, h3[h3.length - 1].endPos), h3.pop();
if (h3.length > 0 ? i3.produceFromScopes(h3[h3.length - 1].scopes, f2.start) : i3.produce(s2, f2.start), u4.retokenizeCapturedWithRuleId) {
const t6 = u4.getName(l2, c3), o3 = s2.contentNameScopesList.pushAttributed(t6, e4), h4 = u4.getContentName(l2, c3), p4 = o3.pushAttributed(h4, e4), d3 = s2.push(u4.retokenizeCapturedWithRuleId, f2.start, -1, false, null, o3, p4), g2 = e4.createOnigString(l2.substring(0, f2.end));
a2(e4, g2, n3 && 0 === f2.start, f2.start, d3, i3, false, 0), r2.disposeOnigString(g2);
continue;
}
const g = u4.getName(l2, c3);
if (null !== g) {
const t6 = (h3.length > 0 ? h3[h3.length - 1].scopes : s2.contentNameScopesList).pushAttributed(g, e4);
h3.push(new d2(t6, f2.end));
}
}
for (; h3.length > 0; )
i3.produceFromScopes(h3[h3.length - 1].scopes, h3[h3.length - 1].endPos), h3.pop();
}
t3._tokenizeString = a2;
class d2 {
constructor(e4, t4) {
this.scopes = e4, this.endPos = t4;
}
}
t3.LocalStackElement = d2;
}, 974: (e3, t3) => {
function n2(e4, t4) {
throw new Error("Near offset " + e4.pos + ": " + t4 + " ~~~" + e4.source.substr(e4.pos, 50) + "~~~");
}
Object.defineProperty(t3, "__esModule", { value: true }), t3.parseJSON = void 0, t3.parseJSON = function(e4, t4, o) {
let c2 = new s(e4), a2 = new r2(), l = 0, u2 = null, h2 = [], p2 = [];
function d2() {
h2.push(l), p2.push(u2);
}
function f2() {
l = h2.pop(), u2 = p2.pop();
}
function g(e5) {
n2(c2, e5);
}
for (; i2(c2, a2); ) {
if (0 === l) {
if (null !== u2 && g("too many constructs in root"), 3 === a2.type) {
u2 = {}, o && (u2.$vscodeTextmateLocation = a2.toLocation(t4)), d2(), l = 1;
continue;
}
if (2 === a2.type) {
u2 = [], d2(), l = 4;
continue;
}
g("unexpected token in root");
}
if (2 === l) {
if (5 === a2.type) {
f2();
continue;
}
if (7 === a2.type) {
l = 3;
continue;
}
g("expected , or }");
}
if (1 === l || 3 === l) {
if (1 === l && 5 === a2.type) {
f2();
continue;
}
if (1 === a2.type) {
let e5 = a2.value;
if (i2(c2, a2) && 6 === a2.type || g("expected colon"), i2(c2, a2) || g("expected value"), l = 2, 1 === a2.type) {
u2[e5] = a2.value;
continue;
}
if (8 === a2.type) {
u2[e5] = null;
continue;
}
if (9 === a2.type) {
u2[e5] = true;
continue;
}
if (10 === a2.type) {
u2[e5] = false;
continue;
}
if (11 === a2.type) {
u2[e5] = parseFloat(a2.value);
continue;
}
if (2 === a2.type) {
let t5 = [];
u2[e5] = t5, d2(), l = 4, u2 = t5;
continue;
}
if (3 === a2.type) {
let n3 = {};
o && (n3.$vscodeTextmateLocation = a2.toLocation(t4)), u2[e5] = n3, d2(), l = 1, u2 = n3;
continue;
}
}
g("unexpected token in dict");
}
if (5 === l) {
if (4 === a2.type) {
f2();
continue;
}
if (7 === a2.type) {
l = 6;
continue;
}
g("expected , or ]");
}
if (4 === l || 6 === l) {
if (4 === l && 4 === a2.type) {
f2();
continue;
}
if (l = 5, 1 === a2.type) {
u2.push(a2.value);
continue;
}
if (8 === a2.type) {
u2.push(null);
continue;
}
if (9 === a2.type) {
u2.push(true);
continue;
}
if (10 === a2.type) {
u2.push(false);
continue;
}
if (11 === a2.type) {
u2.push(parseFloat(a2.value));
continue;
}
if (2 === a2.type) {
let e5 = [];
u2.push(e5), d2(), l = 4, u2 = e5;
continue;
}
if (3 === a2.type) {
let e5 = {};
o && (e5.$vscodeTextmateLocation = a2.toLocation(t4)), u2.push(e5), d2(), l = 1, u2 = e5;
continue;
}
g("unexpected token in array");
}
g("unknown state");
}
return 0 !== p2.length && g("unclosed constructs"), u2;
};
class s {
constructor(e4) {
this.source = e4, this.pos = 0, this.len = e4.length, this.line = 1, this.char = 0;
}
}
class r2 {
constructor() {
this.value = null, this.type = 0, this.offset = -1, this.len = -1, this.line = -1, this.char = -1;
}
toLocation(e4) {
return { filename: e4, line: this.line, char: this.char };
}
}
function i2(e4, t4) {
t4.value = null, t4.type = 0, t4.offset = -1, t4.len = -1, t4.line = -1, t4.char = -1;
let s2, r3 = e4.source, i3 = e4.pos, o = e4.len, c2 = e4.line, a2 = e4.char;
for (; ; ) {
if (i3 >= o)
return false;
if (s2 = r3.charCodeAt(i3), 32 !== s2 && 9 !== s2 && 13 !== s2) {
if (10 !== s2)
break;
i3++, c2++, a2 = 0;
} else
i3++, a2++;
}
if (t4.offset = i3, t4.line = c2, t4.char = a2, 34 === s2) {
for (t4.type = 1, i3++, a2++; ; ) {
if (i3 >= o)
return false;
if (s2 = r3.charCodeAt(i3), i3++, a2++, 92 !== s2) {
if (34 === s2)
break;
} else
i3++, a2++;
}
t4.value = r3.substring(t4.offset + 1, i3 - 1).replace(/\\u([0-9A-Fa-f]{4})/g, (e5, t5) => String.fromCodePoint(parseInt(t5, 16))).replace(/\\(.)/g, (t5, s3) => {
switch (s3) {
case '"':
return '"';
case "\\":
return "\\";
case "/":
return "/";
case "b":
return "\b";
case "f":
return "\f";
case "n":
return "\n";
case "r":
return "\r";
case "t":
return " ";
default:
n2(e4, "invalid escape sequence");
}
throw new Error("unreachable");
});
} else if (91 === s2)
t4.type = 2, i3++, a2++;
else if (123 === s2)
t4.type = 3, i3++, a2++;
else if (93 === s2)
t4.type = 4, i3++, a2++;
else if (125 === s2)
t4.type = 5, i3++, a2++;
else if (58 === s2)
t4.type = 6, i3++, a2++;
else if (44 === s2)
t4.type = 7, i3++, a2++;
else if (110 === s2) {
if (t4.type = 8, i3++, a2++, s2 = r3.charCodeAt(i3), 117 !== s2)
return false;
if (i3++, a2++, s2 = r3.charCodeAt(i3), 108 !== s2)
return false;
if (i3++, a2++, s2 = r3.charCodeAt(i3), 108 !== s2)
return false;
i3++, a2++;
} else if (116 === s2) {
if (t4.type = 9, i3++, a2++, s2 = r3.charCodeAt(i3), 114 !== s2)
return false;
if (i3++, a2++, s2 = r3.charCodeAt(i3), 117 !== s2)
return false;
if (i3++, a2++, s2 = r3.charCodeAt(i3), 101 !== s2)
return false;
i3++, a2++;
} else if (102 === s2) {
if (t4.type = 10, i3++, a2++, s2 = r3.charCodeAt(i3), 97 !== s2)
return false;
if (i3++, a2++, s2 = r3.charCodeAt(i3), 108 !== s2)
return false;
if (i3++, a2++, s2 = r3.charCodeAt(i3), 115 !== s2)
return false;
if (i3++, a2++, s2 = r3.charCodeAt(i3), 101 !== s2)
return false;
i3++, a2++;
} else
for (t4.type = 11; ; ) {
if (i3 >= o)
return false;
if (s2 = r3.charCodeAt(i3), !(46 === s2 || s2 >= 48 && s2 <= 57 || 101 === s2 || 69 === s2 || 45 === s2 || 43 === s2))
break;
i3++, a2++;
}
return t4.len = i3 - t4.offset, null === t4.value && (t4.value = r3.substr(t4.offset, t4.len)), e4.pos = i3, e4.line = c2, e4.char = a2, true;
}
}, 787: function(e3, t3, n2) {
var s = this && this.__createBinding || (Object.create ? function(e4, t4, n3, s2) {
void 0 === s2 && (s2 = n3), Object.defineProperty(e4, s2, { enumerable: true, get: function() {
return t4[n3];
} });
} : function(e4, t4, n3, s2) {
void 0 === s2 && (s2 = n3), e4[s2] = t4[n3];
}), r2 = this && this.__exportStar || function(e4, t4) {
for (var n3 in e4)
"default" === n3 || Object.prototype.hasOwnProperty.call(t4, n3) || s(t4, e4, n3);
};
Object.defineProperty(t3, "__esModule", { value: true }), t3.parseRawGrammar = t3.INITIAL = t3.Registry = void 0;
const i2 = n2(391), o = n2(50), c2 = n2(652), a2 = n2(583), l = n2(965);
r2(n2(44), t3), t3.Registry = class {
constructor(e4) {
this._options = e4, this._syncRegistry = new c2.SyncRegistry(a2.Theme.createFromRawTheme(e4.theme, e4.colorMap), e4.onigLib), this._ensureGrammarCache = /* @__PURE__ */ new Map();
}
dispose() {
this._syncRegistry.dispose();
}
setTheme(e4, t4) {
this._syncRegistry.setTheme(a2.Theme.createFromRawTheme(e4, t4));
}
getColorMap() {
return this._syncRegistry.getColorMap();
}
loadGrammarWithEmbeddedLanguages(e4, t4, n3) {
return this.loadGrammarWithConfiguration(e4, t4, { embeddedLanguages: n3 });
}
loadGrammarWithConfiguration(e4, t4, n3) {
return this._loadGrammar(e4, t4, n3.embeddedLanguages, n3.tokenTypes, new i2.BalancedBracketSelectors(n3.balancedBracketSelectors || [], n3.unbalancedBracketSelectors || []));
}
loadGrammar(e4) {
return this._loadGrammar(e4, 0, null, null, null);
}
async _loadGrammar(e4, t4, n3, s2, r3) {
const i3 = new l.ScopeDependencyProcessor(this._syncRegistry, e4);
for (; i3.Q.length > 0; )
await Promise.all(i3.Q.map((e5) => this._loadSingleGrammar(e5.scopeName))), i3.processQueue();
return this._grammarForScopeName(e4, t4, n3, s2, r3);
}
async _loadSingleGrammar(e4) {
return this._ensureGrammarCache.has(e4) || this._ensureGrammarCache.set(e4, this._doLoadSingleGrammar(e4)), this._ensureGrammarCache.get(e4);
}
async _doLoadSingleGrammar(e4) {
const t4 = await this._options.loadGrammar(e4);
if (t4) {
const n3 = "function" == typeof this._options.getInjections ? this._options.getInjections(e4) : void 0;
this._syncRegistry.addGrammar(t4, n3);
}
}
async addGrammar(e4, t4 = [], n3 = 0, s2 = null) {
return this._syncRegistry.addGrammar(e4, t4), await this._grammarForScopeName(e4.scopeName, n3, s2);
}
_grammarForScopeName(e4, t4 = 0, n3 = null, s2 = null, r3 = null) {
return this._syncRegistry.grammarForScopeName(e4, t4, n3, s2, r3);
}
}, t3.INITIAL = i2.StateStack.NULL, t3.parseRawGrammar = o.parseRawGrammar;
}, 736: (e3, t3) => {
function n2(e4) {
return !!e4 && !!e4.match(/[\w\.:]+/);
}
Object.defineProperty(t3, "__esModule", { value: true }), t3.createMatchers = void 0, t3.createMatchers = function(e4, t4) {
const s = [], r2 = function(e5) {
let t5 = /([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g, n3 = t5.exec(e5);
return { next: () => {
if (!n3)
return null;
const s2 = n3[0];
return n3 = t5.exec(e5), s2;
} };
}(e4);
let i2 = r2.next();
for (; null !== i2; ) {
let e5 = 0;
if (2 === i2.length && ":" === i2.charAt(1)) {
switch (i2.charAt(0)) {
case "R":
e5 = 1;
break;
case "L":
e5 = -1;
break;
default:
console.log(`Unknown priority ${i2} in scope selector`);
}
i2 = r2.next();
}
let t5 = c2();
if (s.push({ matcher: t5, priority: e5 }), "," !== i2)
break;
i2 = r2.next();
}
return s;
function o() {
if ("-" === i2) {
i2 = r2.next();
const e5 = o();
return (t5) => !!e5 && !e5(t5);
}
if ("(" === i2) {
i2 = r2.next();
const e5 = function() {
const e6 = [];
let t5 = c2();
for (; t5 && (e6.push(t5), "|" === i2 || "," === i2); ) {
do {
i2 = r2.next();
} while ("|" === i2 || "," === i2);
t5 = c2();
}
return (t6) => e6.some((e7) => e7(t6));
}();
return ")" === i2 && (i2 = r2.next()), e5;
}
if (n2(i2)) {
const e5 = [];
do {
e5.push(i2), i2 = r2.next();
} while (n2(i2));
return (n3) => t4(e5, n3);
}
return null;
}
function c2() {
const e5 = [];
let t5 = o();
for (; t5; )
e5.push(t5), t5 = o();
return (t6) => e5.every((e6) => e6(t6));
}
};
}, 44: (e3, t3) => {
Object.defineProperty(t3, "__esModule", { value: true }), t3.disposeOnigString = void 0, t3.disposeOnigString = function(e4) {
"function" == typeof e4.dispose && e4.dispose();
};
}, 50: (e3, t3, n2) => {
Object.defineProperty(t3, "__esModule", { value: true }), t3.parseRawGrammar = void 0;
const s = n2(69), r2 = n2(350), i2 = n2(974);
t3.parseRawGrammar = function(e4, t4 = null) {
return null !== t4 && /\.json$/.test(t4) ? (n3 = e4, o = t4, r2.DebugFlags.InDebugMode ? i2.parseJSON(n3, o, true) : JSON.parse(n3)) : function(e5, t5) {
return r2.DebugFlags.InDebugMode ? s.parseWithLocation(e5, t5, "$vscodeTextmateLocation") : s.parsePLIST(e5);
}(e4, t4);
var n3, o;
};
}, 69: (e3, t3) => {
function n2(e4, t4, n3) {
const s = e4.length;
let r2 = 0, i2 = 1, o = 0;
function c2(t5) {
if (null === n3)
r2 += t5;
else
for (; t5 > 0; )
10 === e4.charCodeAt(r2) ? (r2++, i2++, o = 0) : (r2++, o++), t5--;
}
function a2(e5) {
null === n3 ? r2 = e5 : c2(e5 - r2);
}
function l() {
for (; r2 < s; ) {
let t5 = e4.charCodeAt(r2);
if (32 !== t5 && 9 !== t5 && 13 !== t5 && 10 !== t5)
break;
c2(1);
}
}
function u2(t5) {
return e4.substr(r2, t5.length) === t5 && (c2(t5.length), true);
}
function h2(t5) {
let n4 = e4.indexOf(t5, r2);
a2(-1 !== n4 ? n4 + t5.length : s);
}
function p2(t5) {
let n4 = e4.indexOf(t5, r2);
if (-1 !== n4) {
let s2 = e4.substring(r2, n4);
return a2(n4 + t5.length), s2;
}
{
let t6 = e4.substr(r2);
return a2(s), t6;
}
}
s > 0 && 65279 === e4.charCodeAt(0) && (r2 = 1);
let d2 = 0, f2 = null, g = [], m2 = [], _ = null;
function b3(e5, t5) {
g.push(d2), m2.push(f2), d2 = e5, f2 = t5;
}
function y2() {
if (0 === g.length)
return S2("illegal state stack");
d2 = g.pop(), f2 = m2.pop();
}
function S2(t5) {
throw new Error("Near offset " + r2 + ": " + t5 + " ~~~" + e4.substr(r2, 50) + "~~~");
}
const k2 = function() {
if (null === _)
return S2("missing <key>");
let e5 = {};
null !== n3 && (e5[n3] = { filename: t4, line: i2, char: o }), f2[_] = e5, _ = null, b3(1, e5);
}, C2 = function() {
if (null === _)
return S2("missing <key>");
let e5 = [];
f2[_] = e5, _ = null, b3(2, e5);
}, R2 = function() {
let e5 = {};
null !== n3 && (e5[n3] = { filename: t4, line: i2, char: o }), f2.push(e5), b3(1, e5);
}, A3 = function() {
let e5 = [];
f2.push(e5), b3(2, e5);
};
function w2() {
if (1 !== d2)
return S2("unexpected </dict>");
y2();
}
function P3() {
return 1 === d2 || 2 !== d2 ? S2("unexpected </array>") : void y2();
}
function I2(e5) {
if (1 === d2) {
if (null === _)
return S2("missing <key>");
f2[_] = e5, _ = null;
} else
2 === d2 ? f2.push(e5) : f2 = e5;
}
function v2(e5) {
if (isNaN(e5))
return S2("cannot parse float");
if (1 === d2) {
if (null === _)
return S2("missing <key>");
f2[_] = e5, _ = null;
} else
2 === d2 ? f2.push(e5) : f2 = e5;
}
function N3(e5) {
if (isNaN(e5))
return S2("cannot parse integer");
if (1 === d2) {
if (null === _)
return S2("missing <key>");
f2[_] = e5, _ = null;
} else
2 === d2 ? f2.push(e5) : f2 = e5;
}
function T2(e5) {
if (1 === d2) {
if (null === _)
return S2("missing <key>");
f2[_] = e5, _ = null;
} else
2 === d2 ? f2.push(e5) : f2 = e5;
}
function x2(e5) {
if (1 === d2) {
if (null === _)
return S2("missing <key>");
f2[_] = e5, _ = null;
} else
2 === d2 ? f2.push(e5) : f2 = e5;
}
function G3(e5) {
if (1 === d2) {
if (null === _)
return S2("missing <key>");
f2[_] = e5, _ = null;
} else
2 === d2 ? f2.push(e5) : f2 = e5;
}
function E3() {
let e5 = p2(">"), t5 = false;
return 47 === e5.charCodeAt(e5.length - 1) && (t5 = true, e5 = e5.substring(0, e5.length - 1)), { name: e5.trim(), isClosed: t5 };
}
function L2(e5) {
if (e5.isClosed)
return "";
let t5 = p2("</");
return h2(">"), t5.replace(/&#([0-9]+);/g, function(e6, t6) {
return String.fromCodePoint(parseInt(t6, 10));
}).replace(/&#x([0-9a-f]+);/g, function(e6, t6) {
return String.fromCodePoint(parseInt(t6, 16));
}).replace(/&amp;|&lt;|&gt;|&quot;|&apos;/g, function(e6) {
switch (e6) {
case "&amp;":
return "&";
case "&lt;":
return "<";
case "&gt;":
return ">";
case "&quot;":
return '"';
case "&apos;":
return "'";
}
return e6;
});
}
for (; r2 < s && (l(), !(r2 >= s)); ) {
const a3 = e4.charCodeAt(r2);
if (c2(1), 60 !== a3)
return S2("expected <");
if (r2 >= s)
return S2("unexpected end of input");
const p3 = e4.charCodeAt(r2);
if (63 === p3) {
c2(1), h2("?>");
continue;
}
if (33 === p3) {
if (c2(1), u2("--")) {
h2("-->");
continue;
}
h2(">");
continue;
}
if (47 === p3) {
if (c2(1), l(), u2("plist")) {
h2(">");
continue;
}
if (u2("dict")) {
h2(">"), w2();
continue;
}
if (u2("array")) {
h2(">"), P3();
continue;
}
return S2("unexpected closed tag");
}
let g2 = E3();
switch (g2.name) {
case "dict":
1 === d2 ? k2() : 2 === d2 ? R2() : (f2 = {}, null !== n3 && (f2[n3] = { filename: t4, line: i2, char: o }), b3(1, f2)), g2.isClosed && w2();
continue;
case "array":
1 === d2 ? C2() : 2 === d2 ? A3() : (f2 = [], b3(2, f2)), g2.isClosed && P3();
continue;
case "key":
M2 = L2(g2), 1 !== d2 ? S2("unexpected <key>") : null !== _ ? S2("too many <key>") : _ = M2;
continue;
case "string":
I2(L2(g2));
continue;
case "real":
v2(parseFloat(L2(g2)));
continue;
case "integer":
N3(parseInt(L2(g2), 10));
continue;
case "date":
T2(new Date(L2(g2)));
continue;
case "data":
x2(L2(g2));
continue;
case "true":
L2(g2), G3(true);
continue;
case "false":
L2(g2), G3(false);
continue;
}
if (!/^plist/.test(g2.name))
return S2("unexpected opened tag " + g2.name);
}
var M2;
return f2;
}
Object.defineProperty(t3, "__esModule", { value: true }), t3.parsePLIST = t3.parseWithLocation = void 0, t3.parseWithLocation = function(e4, t4, s) {
return n2(e4, t4, s);
}, t3.parsePLIST = function(e4) {
return n2(e4, null, null);
};
}, 652: (e3, t3, n2) => {
Object.defineProperty(t3, "__esModule", { value: true }), t3.SyncRegistry = void 0;
const s = n2(391);
t3.SyncRegistry = class {
constructor(e4, t4) {
this._onigLibPromise = t4, this._grammars = /* @__PURE__ */ new Map(), this._rawGrammars = /* @__PURE__ */ new Map(), this._injectionGrammars = /* @__PURE__ */ new Map(), this._theme = e4;
}
dispose() {
for (const e4 of this._grammars.values())
e4.dispose();
}
setTheme(e4) {
this._theme = e4;
}
getColorMap() {
return this._theme.getColorMap();
}
addGrammar(e4, t4) {
this._rawGrammars.set(e4.scopeName, e4), t4 && this._injectionGrammars.set(e4.scopeName, t4);
}
lookup(e4) {
return this._rawGrammars.get(e4);
}
injections(e4) {
return this._injectionGrammars.get(e4);
}
getDefaults() {
return this._theme.getDefaults();
}
themeMatch(e4) {
return this._theme.match(e4);
}
async grammarForScopeName(e4, t4, n3, r2, i2) {
if (!this._grammars.has(e4)) {
let o = this._rawGrammars.get(e4);
if (!o)
return null;
this._grammars.set(e4, s.createGrammar(e4, o, t4, n3, r2, i2, this, await this._onigLibPromise));
}
return this._grammars.get(e4);
}
};
}, 792: (e3, t3, n2) => {
Object.defineProperty(t3, "__esModule", { value: true }), t3.CompiledRule = t3.RegExpSourceList = t3.RegExpSource = t3.RuleFactory = t3.BeginWhileRule = t3.BeginEndRule = t3.IncludeOnlyRule = t3.MatchRule = t3.CaptureRule = t3.Rule = t3.ruleIdToNumber = t3.ruleIdFromNumber = t3.whileRuleId = t3.endRuleId = void 0;
const s = n2(878), r2 = n2(965), i2 = /\\(\d+)/, o = /\\(\d+)/g;
t3.endRuleId = -1, t3.whileRuleId = -2, t3.ruleIdFromNumber = function(e4) {
return e4;
}, t3.ruleIdToNumber = function(e4) {
return e4;
};
class c2 {
constructor(e4, t4, n3, r3) {
this.$location = e4, this.id = t4, this._name = n3 || null, this._nameIsCapturing = s.RegexSource.hasCaptures(this._name), this._contentName = r3 || null, this._contentNameIsCapturing = s.RegexSource.hasCaptures(this._contentName);
}
get debugName() {
const e4 = this.$location ? `${s.basename(this.$location.filename)}:${this.$location.line}` : "unknown";
return `${this.constructor.name}#${this.id} @ ${e4}`;
}
getName(e4, t4) {
return this._nameIsCapturing && null !== this._name && null !== e4 && null !== t4 ? s.RegexSource.replaceCaptures(this._name, e4, t4) : this._name;
}
getContentName(e4, t4) {
return this._contentNameIsCapturing && null !== this._contentName ? s.RegexSource.replaceCaptures(this._contentName, e4, t4) : this._contentName;
}
}
t3.Rule = c2;
class a2 extends c2 {
constructor(e4, t4, n3, s2, r3) {
super(e4, t4, n3, s2), this.retokenizeCapturedWithRuleId = r3;
}
dispose() {
}
collectPatterns(e4, t4) {
throw new Error("Not supported!");
}
compile(e4, t4) {
throw new Error("Not supported!");
}
compileAG(e4, t4, n3, s2) {
throw new Error("Not supported!");
}
}
t3.CaptureRule = a2;
class l extends c2 {
constructor(e4, t4, n3, s2, r3) {
super(e4, t4, n3, null), this._match = new f2(s2, this.id), this.captures = r3, this._cachedCompiledPatterns = null;
}
dispose() {
this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null);
}
get debugMatchRegExp() {
return `${this._match.source}`;
}
collectPatterns(e4, t4) {
t4.push(this._match);
}
compile(e4, t4) {
return this._getCachedCompiledPatterns(e4).compile(e4);
}
compileAG(e4, t4, n3, s2) {
return this._getCachedCompiledPatterns(e4).compileAG(e4, n3, s2);
}
_getCachedCompiledPatterns(e4) {
return this._cachedCompiledPatterns || (this._cachedCompiledPatterns = new g(), this.collectPatterns(e4, this._cachedCompiledPatterns)), this._cachedCompiledPatterns;
}
}
t3.MatchRule = l;
class u2 extends c2 {
constructor(e4, t4, n3, s2, r3) {
super(e4, t4, n3, s2), this.patterns = r3.patterns, this.hasMissingPatterns = r3.hasMissingPatterns, this._cachedCompiledPatterns = null;
}
dispose() {
this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null);
}
collectPatterns(e4, t4) {
for (const n3 of this.patterns)
e4.getRule(n3).collectPatterns(e4, t4);
}
compile(e4, t4) {
return this._getCachedCompiledPatterns(e4).compile(e4);
}
compileAG(e4, t4, n3, s2) {
return this._getCachedCompiledPatterns(e4).compileAG(e4, n3, s2);
}
_getCachedCompiledPatterns(e4) {
return this._cachedCompiledPatterns || (this._cachedCompiledPatterns = new g(), this.collectPatterns(e4, this._cachedCompiledPatterns)), this._cachedCompiledPatterns;
}
}
t3.IncludeOnlyRule = u2;
class h2 extends c2 {
constructor(e4, t4, n3, s2, r3, i3, o2, c3, a3, l2) {
super(e4, t4, n3, s2), this._begin = new f2(r3, this.id), this.beginCaptures = i3, this._end = new f2(o2 || "￿", -1), this.endHasBackReferences = this._end.hasBackReferences, this.endCaptures = c3, this.applyEndPatternLast = a3 || false, this.patterns = l2.patterns, this.hasMissingPatterns = l2.hasMissingPatterns, this._cachedCompiledPatterns = null;
}
dispose() {
this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null);
}
get debugBeginRegExp() {
return `${this._begin.source}`;
}
get debugEndRegExp() {
return `${this._end.source}`;
}
getEndWithResolvedBackReferences(e4, t4) {
return this._end.resolveBackReferences(e4, t4);
}
collectPatterns(e4, t4) {
t4.push(this._begin);
}
compile(e4, t4) {
return this._getCachedCompiledPatterns(e4, t4).compile(e4);
}
compileAG(e4, t4, n3, s2) {
return this._getCachedCompiledPatterns(e4, t4).compileAG(e4, n3, s2);
}
_getCachedCompiledPatterns(e4, t4) {
if (!this._cachedCompiledPatterns) {
this._cachedCompiledPatterns = new g();
for (const t5 of this.patterns)
e4.getRule(t5).collectPatterns(e4, this._cachedCompiledPatterns);
this.applyEndPatternLast ? this._cachedCompiledPatterns.push(this._end.hasBackReferences ? this._end.clone() : this._end) : this._cachedCompiledPatterns.unshift(this._end.hasBackReferences ? this._end.clone() : this._end);
}
return this._end.hasBackReferences && (this.applyEndPatternLast ? this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length() - 1, t4) : this._cachedCompiledPatterns.setSource(0, t4)), this._cachedCompiledPatterns;
}
}
t3.BeginEndRule = h2;
class p2 extends c2 {
constructor(e4, n3, s2, r3, i3, o2, c3, a3, l2) {
super(e4, n3, s2, r3), this._begin = new f2(i3, this.id), this.beginCaptures = o2, this.whileCaptures = a3, this._while = new f2(c3, t3.whileRuleId), this.whileHasBackReferences = this._while.hasBackReferences, this.patterns = l2.patterns, this.hasMissingPatterns = l2.hasMissingPatterns, this._cachedCompiledPatterns = null, this._cachedCompiledWhilePatterns = null;
}
dispose() {
this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null), this._cachedCompiledWhilePatterns && (this._cachedCompiledWhilePatterns.dispose(), this._cachedCompiledWhilePatterns = null);
}
get debugBeginRegExp() {
return `${this._begin.source}`;
}
get debugWhileRegExp() {
return `${this._while.source}`;
}
getWhileWithResolvedBackReferences(e4, t4) {
return this._while.resolveBackReferences(e4, t4);
}
collectPatterns(e4, t4) {
t4.push(this._begin);
}
compile(e4, t4) {
return this._getCachedCompiledPatterns(e4).compile(e4);
}
compileAG(e4, t4, n3, s2) {
return this._getCachedCompiledPatterns(e4).compileAG(e4, n3, s2);
}
_getCachedCompiledPatterns(e4) {
if (!this._cachedCompiledPatterns) {
this._cachedCompiledPatterns = new g();
for (const t4 of this.patterns)
e4.getRule(t4).collectPatterns(e4, this._cachedCompiledPatterns);
}
return this._cachedCompiledPatterns;
}
compileWhile(e4, t4) {
return this._getCachedCompiledWhilePatterns(e4, t4).compile(e4);
}
compileWhileAG(e4, t4, n3, s2) {
return this._getCachedCompiledWhilePatterns(e4, t4).compileAG(e4, n3, s2);
}
_getCachedCompiledWhilePatterns(e4, t4) {
return this._cachedCompiledWhilePatterns || (this._cachedCompiledWhilePatterns = new g(), this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences ? this._while.clone() : this._while)), this._while.hasBackReferences && this._cachedCompiledWhilePatterns.setSource(0, t4 || "￿"), this._cachedCompiledWhilePatterns;
}
}
t3.BeginWhileRule = p2;
class d2 {
static createCaptureRule(e4, t4, n3, s2, r3) {
return e4.registerRule((e5) => new a2(t4, e5, n3, s2, r3));
}
static getCompiledRuleId(e4, t4, n3) {
return e4.id || t4.registerRule((r3) => {
if (e4.id = r3, e4.match)
return new l(e4.$vscodeTextmateLocation, e4.id, e4.name, e4.match, d2._compileCaptures(e4.captures, t4, n3));
if (void 0 === e4.begin) {
e4.repository && (n3 = s.mergeObjects({}, n3, e4.repository));
let r4 = e4.patterns;
return void 0 === r4 && e4.include && (r4 = [{ include: e4.include }]), new u2(e4.$vscodeTextmateLocation, e4.id, e4.name, e4.contentName, d2._compilePatterns(r4, t4, n3));
}
return e4.while ? new p2(e4.$vscodeTextmateLocation, e4.id, e4.name, e4.contentName, e4.begin, d2._compileCaptures(e4.beginCaptures || e4.captures, t4, n3), e4.while, d2._compileCaptures(e4.whileCaptures || e4.captures, t4, n3), d2._compilePatterns(e4.patterns, t4, n3)) : new h2(e4.$vscodeTextmateLocation, e4.id, e4.name, e4.contentName, e4.begin, d2._compileCaptures(e4.beginCaptures || e4.captures, t4, n3), e4.end, d2._compileCaptures(e4.endCaptures || e4.captures, t4, n3), e4.applyEndPatternLast, d2._compilePatterns(e4.patterns, t4, n3));
}), e4.id;
}
static _compileCaptures(e4, t4, n3) {
let s2 = [];
if (e4) {
let r3 = 0;
for (const t5 in e4) {
if ("$vscodeTextmateLocation" === t5)
continue;
const e5 = parseInt(t5, 10);
e5 > r3 && (r3 = e5);
}
for (let e5 = 0; e5 <= r3; e5++)
s2[e5] = null;
for (const r4 in e4) {
if ("$vscodeTextmateLocation" === r4)
continue;
const i3 = parseInt(r4, 10);
let o2 = 0;
e4[r4].patterns && (o2 = d2.getCompiledRuleId(e4[r4], t4, n3)), s2[i3] = d2.createCaptureRule(t4, e4[r4].$vscodeTextmateLocation, e4[r4].name, e4[r4].contentName, o2);
}
}
return s2;
}
static _compilePatterns(e4, t4, n3) {
let s2 = [];
if (e4)
for (let i3 = 0, o2 = e4.length; i3 < o2; i3++) {
const o3 = e4[i3];
let c3 = -1;
if (o3.include) {
const e5 = r2.parseInclude(o3.include);
switch (e5.kind) {
case 0:
case 1:
c3 = d2.getCompiledRuleId(n3[o3.include], t4, n3);
break;
case 2:
let s3 = n3[e5.ruleName];
s3 && (c3 = d2.getCompiledRuleId(s3, t4, n3));
break;
case 3:
case 4:
const r3 = e5.scopeName, i4 = 4 === e5.kind ? e5.ruleName : null, a3 = t4.getExternalGrammar(r3, n3);
if (a3)
if (i4) {
let e6 = a3.repository[i4];
e6 && (c3 = d2.getCompiledRuleId(e6, t4, a3.repository));
} else
c3 = d2.getCompiledRuleId(a3.repository.$self, t4, a3.repository);
}
} else
c3 = d2.getCompiledRuleId(o3, t4, n3);
if (-1 !== c3) {
const e5 = t4.getRule(c3);
let n4 = false;
if ((e5 instanceof u2 || e5 instanceof h2 || e5 instanceof p2) && e5.hasMissingPatterns && 0 === e5.patterns.length && (n4 = true), n4)
continue;
s2.push(c3);
}
}
return { patterns: s2, hasMissingPatterns: (e4 ? e4.length : 0) !== s2.length };
}
}
t3.RuleFactory = d2;
class f2 {
constructor(e4, t4) {
if (e4) {
const t5 = e4.length;
let n3 = 0, s2 = [], r3 = false;
for (let i3 = 0; i3 < t5; i3++)
if ("\\" === e4.charAt(i3) && i3 + 1 < t5) {
const t6 = e4.charAt(i3 + 1);
"z" === t6 ? (s2.push(e4.substring(n3, i3)), s2.push("$(?!\\n)(?<!\\n)"), n3 = i3 + 2) : "A" !== t6 && "G" !== t6 || (r3 = true), i3++;
}
this.hasAnchor = r3, 0 === n3 ? this.source = e4 : (s2.push(e4.substring(n3, t5)), this.source = s2.join(""));
} else
this.hasAnchor = false, this.source = e4;
this.hasAnchor ? this._anchorCache = this._buildAnchorCache() : this._anchorCache = null, this.ruleId = t4, this.hasBackReferences = i2.test(this.source);
}
clone() {
return new f2(this.source, this.ruleId);
}
setSource(e4) {
this.source !== e4 && (this.source = e4, this.hasAnchor && (this._anchorCache = this._buildAnchorCache()));
}
resolveBackReferences(e4, t4) {
let n3 = t4.map((t5) => e4.substring(t5.start, t5.end));
return o.lastIndex = 0, this.source.replace(o, (e5, t5) => s.escapeRegExpCharacters(n3[parseInt(t5, 10)] || ""));
}
_buildAnchorCache() {
let e4, t4, n3, s2, r3 = [], i3 = [], o2 = [], c3 = [];
for (e4 = 0, t4 = this.source.length; e4 < t4; e4++)
n3 = this.source.charAt(e4), r3[e4] = n3, i3[e4] = n3, o2[e4] = n3, c3[e4] = n3, "\\" === n3 && e4 + 1 < t4 && (s2 = this.source.charAt(e4 + 1), "A" === s2 ? (r3[e4 + 1] = "￿", i3[e4 + 1] = "￿", o2[e4 + 1] = "A", c3[e4 + 1] = "A") : "G" === s2 ? (r3[e4 + 1] = "￿", i3[e4 + 1] = "G", o2[e4 + 1] = "￿", c3[e4 + 1] = "G") : (r3[e4 + 1] = s2, i3[e4 + 1] = s2, o2[e4 + 1] = s2, c3[e4 + 1] = s2), e4++);
return { A0_G0: r3.join(""), A0_G1: i3.join(""), A1_G0: o2.join(""), A1_G1: c3.join("") };
}
resolveAnchors(e4, t4) {
return this.hasAnchor && this._anchorCache ? e4 ? t4 ? this._anchorCache.A1_G1 : this._anchorCache.A1_G0 : t4 ? this._anchorCache.A0_G1 : this._anchorCache.A0_G0 : this.source;
}
}
t3.RegExpSource = f2;
class g {
constructor() {
this._items = [], this._hasAnchors = false, this._cached = null, this._anchorCache = { A0_G0: null, A0_G1: null, A1_G0: null, A1_G1: null };
}
dispose() {
this._disposeCaches();
}
_disposeCaches() {
this._cached && (this._cached.dispose(), this._cached = null), this._anchorCache.A0_G0 && (this._anchorCache.A0_G0.dispose(), this._anchorCache.A0_G0 = null), this._anchorCache.A0_G1 && (this._anchorCache.A0_G1.dispose(), this._anchorCache.A0_G1 = null), this._anchorCache.A1_G0 && (this._anchorCache.A1_G0.dispose(), this._anchorCache.A1_G0 = null), this._anchorCache.A1_G1 && (this._anchorCache.A1_G1.dispose(), this._anchorCache.A1_G1 = null);
}
push(e4) {
this._items.push(e4), this._hasAnchors = this._hasAnchors || e4.hasAnchor;
}
unshift(e4) {
this._items.unshift(e4), this._hasAnchors = this._hasAnchors || e4.hasAnchor;
}
length() {
return this._items.length;
}
setSource(e4, t4) {
this._items[e4].source !== t4 && (this._disposeCaches(), this._items[e4].setSource(t4));
}
compile(e4) {
if (!this._cached) {
let t4 = this._items.map((e5) => e5.source);
this._cached = new m2(e4, t4, this._items.map((e5) => e5.ruleId));
}
return this._cached;
}
compileAG(e4, t4, n3) {
return this._hasAnchors ? t4 ? n3 ? (this._anchorCache.A1_G1 || (this._anchorCache.A1_G1 = this._resolveAnchors(e4, t4, n3)), this._anchorCache.A1_G1) : (this._anchorCache.A1_G0 || (this._anchorCache.A1_G0 = this._resolveAnchors(e4, t4, n3)), this._anchorCache.A1_G0) : n3 ? (this._anchorCache.A0_G1 || (this._anchorCache.A0_G1 = this._resolveAnchors(e4, t4, n3)), this._anchorCache.A0_G1) : (this._anchorCache.A0_G0 || (this._anchorCache.A0_G0 = this._resolveAnchors(e4, t4, n3)), this._anchorCache.A0_G0) : this.compile(e4);
}
_resolveAnchors(e4, t4, n3) {
let s2 = this._items.map((e5) => e5.resolveAnchors(t4, n3));
return new m2(e4, s2, this._items.map((e5) => e5.ruleId));
}
}
t3.RegExpSourceList = g;
class m2 {
constructor(e4, t4, n3) {
this.regExps = t4, this.rules = n3, this.scanner = e4.createOnigScanner(t4);
}
dispose() {
"function" == typeof this.scanner.dispose && this.scanner.dispose();
}
toString() {
const e4 = [];
for (let t4 = 0, n3 = this.rules.length; t4 < n3; t4++)
e4.push(" - " + this.rules[t4] + ": " + this.regExps[t4]);
return e4.join("\n");
}
findNextMatchSync(e4, t4, n3) {
const s2 = this.scanner.findNextMatchSync(e4, t4, n3);
return s2 ? { ruleId: this.rules[s2.index], captureIndices: s2.captureIndices } : null;
}
}
t3.CompiledRule = m2;
}, 583: (e3, t3, n2) => {
Object.defineProperty(t3, "__esModule", { value: true }), t3.ThemeTrieElement = t3.ThemeTrieElementRule = t3.ColorMap = t3.fontStyleToString = t3.ParsedThemeRule = t3.parseTheme = t3.StyleAttributes = t3.ScopeStack = t3.Theme = void 0;
const s = n2(878);
class r2 {
constructor(e4, t4, n3) {
this._colorMap = e4, this._defaults = t4, this._root = n3, this._cachedMatchRoot = new s.CachedFn((e5) => this._root.match(e5));
}
static createFromRawTheme(e4, t4) {
return this.createFromParsedTheme(a2(e4), t4);
}
static createFromParsedTheme(e4, t4) {
return function(e5, t5) {
e5.sort((e6, t6) => {
let n4 = s.strcmp(e6.scope, t6.scope);
return 0 !== n4 ? n4 : (n4 = s.strArrCmp(e6.parentScopes, t6.parentScopes), 0 !== n4 ? n4 : e6.index - t6.index);
});
let n3 = 0, i3 = "#000000", o2 = "#ffffff";
for (; e5.length >= 1 && "" === e5[0].scope; ) {
let t6 = e5.shift();
-1 !== t6.fontStyle && (n3 = t6.fontStyle), null !== t6.foreground && (i3 = t6.foreground), null !== t6.background && (o2 = t6.background);
}
let a3 = new u2(t5), l2 = new c2(n3, a3.getId(i3), a3.getId(o2)), d2 = new p2(new h2(0, null, -1, 0, 0), []);
for (let t6 = 0, n4 = e5.length; t6 < n4; t6++) {
let n5 = e5[t6];
d2.insert(0, n5.scope, n5.parentScopes, n5.fontStyle, a3.getId(n5.foreground), a3.getId(n5.background));
}
return new r2(a3, l2, d2);
}(e4, t4);
}
getColorMap() {
return this._colorMap.getColorMap();
}
getDefaults() {
return this._defaults;
}
match(e4) {
if (null === e4)
return this._defaults;
const t4 = e4.scopeName, n3 = this._cachedMatchRoot.get(t4).find((t5) => function(e5, t6) {
if (null === t6)
return true;
let n4 = 0, s2 = t6[n4];
for (; e5; ) {
if (o(e5.scopeName, s2)) {
if (n4++, n4 === t6.length)
return true;
s2 = t6[n4];
}
e5 = e5.parent;
}
return false;
}(e4.parent, t5.parentScopes));
return n3 ? new c2(n3.fontStyle, n3.foreground, n3.background) : null;
}
}
t3.Theme = r2;
class i2 {
constructor(e4, t4) {
this.parent = e4, this.scopeName = t4;
}
static from(...e4) {
let t4 = null;
for (let n3 = 0; n3 < e4.length; n3++)
t4 = new i2(t4, e4[n3]);
return t4;
}
push(e4) {
return new i2(this, e4);
}
getSegments() {
let e4 = this;
const t4 = [];
for (; e4; )
t4.push(e4.scopeName), e4 = e4.parent;
return t4.reverse(), t4;
}
toString() {
return this.getSegments().join(" ");
}
}
function o(e4, t4) {
return t4 === e4 || e4.startsWith(t4) && "." === e4[t4.length];
}
t3.ScopeStack = i2;
class c2 {
constructor(e4, t4, n3) {
this.fontStyle = e4, this.foregroundId = t4, this.backgroundId = n3;
}
}
function a2(e4) {
if (!e4)
return [];
if (!e4.settings || !Array.isArray(e4.settings))
return [];
let t4 = e4.settings, n3 = [], r3 = 0;
for (let e5 = 0, i3 = t4.length; e5 < i3; e5++) {
let i4, o2 = t4[e5];
if (!o2.settings)
continue;
if ("string" == typeof o2.scope) {
let e6 = o2.scope;
e6 = e6.replace(/^[,]+/, ""), e6 = e6.replace(/[,]+$/, ""), i4 = e6.split(",");
} else
i4 = Array.isArray(o2.scope) ? o2.scope : [""];
let c3 = -1;
if ("string" == typeof o2.settings.fontStyle) {
c3 = 0;
let e6 = o2.settings.fontStyle.split(" ");
for (let t5 = 0, n4 = e6.length; t5 < n4; t5++)
switch (e6[t5]) {
case "italic":
c3 |= 1;
break;
case "bold":
c3 |= 2;
break;
case "underline":
c3 |= 4;
break;
case "strikethrough":
c3 |= 8;
}
}
let a3 = null;
"string" == typeof o2.settings.foreground && s.isValidHexColor(o2.settings.foreground) && (a3 = o2.settings.foreground);
let u3 = null;
"string" == typeof o2.settings.background && s.isValidHexColor(o2.settings.background) && (u3 = o2.settings.background);
for (let t5 = 0, s2 = i4.length; t5 < s2; t5++) {
let s3 = i4[t5].trim().split(" "), o3 = s3[s3.length - 1], h3 = null;
s3.length > 1 && (h3 = s3.slice(0, s3.length - 1), h3.reverse()), n3[r3++] = new l(o3, h3, e5, c3, a3, u3);
}
}
return n3;
}
t3.StyleAttributes = c2, t3.parseTheme = a2;
class l {
constructor(e4, t4, n3, s2, r3, i3) {
this.scope = e4, this.parentScopes = t4, this.index = n3, this.fontStyle = s2, this.foreground = r3, this.background = i3;
}
}
t3.ParsedThemeRule = l, t3.fontStyleToString = function(e4) {
if (-1 === e4)
return "not set";
let t4 = "";
return 1 & e4 && (t4 += "italic "), 2 & e4 && (t4 += "bold "), 4 & e4 && (t4 += "underline "), 8 & e4 && (t4 += "strikethrough "), "" === t4 && (t4 = "none"), t4.trim();
};
class u2 {
constructor(e4) {
if (this._lastColorId = 0, this._id2color = [], this._color2id = /* @__PURE__ */ Object.create(null), Array.isArray(e4)) {
this._isFrozen = true;
for (let t4 = 0, n3 = e4.length; t4 < n3; t4++)
this._color2id[e4[t4]] = t4, this._id2color[t4] = e4[t4];
} else
this._isFrozen = false;
}
getId(e4) {
if (null === e4)
return 0;
e4 = e4.toUpperCase();
let t4 = this._color2id[e4];
if (t4)
return t4;
if (this._isFrozen)
throw new Error(`Missing color in color map - ${e4}`);
return t4 = ++this._lastColorId, this._color2id[e4] = t4, this._id2color[t4] = e4, t4;
}
getColorMap() {
return this._id2color.slice(0);
}
}
t3.ColorMap = u2;
class h2 {
constructor(e4, t4, n3, s2, r3) {
this.scopeDepth = e4, this.parentScopes = t4, this.fontStyle = n3, this.foreground = s2, this.background = r3;
}
clone() {
return new h2(this.scopeDepth, this.parentScopes, this.fontStyle, this.foreground, this.background);
}
static cloneArr(e4) {
let t4 = [];
for (let n3 = 0, s2 = e4.length; n3 < s2; n3++)
t4[n3] = e4[n3].clone();
return t4;
}
acceptOverwrite(e4, t4, n3, s2) {
this.scopeDepth > e4 ? console.log("how did this happen?") : this.scopeDepth = e4, -1 !== t4 && (this.fontStyle = t4), 0 !== n3 && (this.foreground = n3), 0 !== s2 && (this.background = s2);
}
}
t3.ThemeTrieElementRule = h2;
class p2 {
constructor(e4, t4 = [], n3 = {}) {
this._mainRule = e4, this._children = n3, this._rulesWithParentScopes = t4;
}
static _sortBySpecificity(e4) {
return 1 === e4.length || e4.sort(this._cmpBySpecificity), e4;
}
static _cmpBySpecificity(e4, t4) {
if (e4.scopeDepth === t4.scopeDepth) {
const n3 = e4.parentScopes, s2 = t4.parentScopes;
let r3 = null === n3 ? 0 : n3.length, i3 = null === s2 ? 0 : s2.length;
if (r3 === i3)
for (let e5 = 0; e5 < r3; e5++) {
const t5 = n3[e5].length, r4 = s2[e5].length;
if (t5 !== r4)
return r4 - t5;
}
return i3 - r3;
}
return t4.scopeDepth - e4.scopeDepth;
}
match(e4) {
if ("" === e4)
return p2._sortBySpecificity([].concat(this._mainRule).concat(this._rulesWithParentScopes));
let t4, n3, s2 = e4.indexOf(".");
return -1 === s2 ? (t4 = e4, n3 = "") : (t4 = e4.substring(0, s2), n3 = e4.substring(s2 + 1)), this._children.hasOwnProperty(t4) ? this._children[t4].match(n3) : p2._sortBySpecificity([].concat(this._mainRule).concat(this._rulesWithParentScopes));
}
insert(e4, t4, n3, s2, r3, i3) {
if ("" === t4)
return void this._doInsertHere(e4, n3, s2, r3, i3);
let o2, c3, a3, l2 = t4.indexOf(".");
-1 === l2 ? (o2 = t4, c3 = "") : (o2 = t4.substring(0, l2), c3 = t4.substring(l2 + 1)), this._children.hasOwnProperty(o2) ? a3 = this._children[o2] : (a3 = new p2(this._mainRule.clone(), h2.cloneArr(this._rulesWithParentScopes)), this._children[o2] = a3), a3.insert(e4 + 1, c3, n3, s2, r3, i3);
}
_doInsertHere(e4, t4, n3, r3, i3) {
if (null !== t4) {
for (let o2 = 0, c3 = this._rulesWithParentScopes.length; o2 < c3; o2++) {
let c4 = this._rulesWithParentScopes[o2];
if (0 === s.strArrCmp(c4.parentScopes, t4))
return void c4.acceptOverwrite(e4, n3, r3, i3);
}
-1 === n3 && (n3 = this._mainRule.fontStyle), 0 === r3 && (r3 = this._mainRule.foreground), 0 === i3 && (i3 = this._mainRule.background), this._rulesWithParentScopes.push(new h2(e4, t4, n3, r3, i3));
} else
this._mainRule.acceptOverwrite(e4, n3, r3, i3);
}
}
t3.ThemeTrieElement = p2;
}, 878: (e3, t3) => {
function n2(e4) {
return Array.isArray(e4) ? function(e5) {
let t4 = [];
for (let s2 = 0, r3 = e5.length; s2 < r3; s2++)
t4[s2] = n2(e5[s2]);
return t4;
}(e4) : "object" == typeof e4 ? function(e5) {
let t4 = {};
for (let s2 in e5)
t4[s2] = n2(e5[s2]);
return t4;
}(e4) : e4;
}
Object.defineProperty(t3, "__esModule", { value: true }), t3.performanceNow = t3.CachedFn = t3.escapeRegExpCharacters = t3.isValidHexColor = t3.strArrCmp = t3.strcmp = t3.RegexSource = t3.basename = t3.mergeObjects = t3.clone = void 0, t3.clone = function(e4) {
return n2(e4);
}, t3.mergeObjects = function(e4, ...t4) {
return t4.forEach((t5) => {
for (let n3 in t5)
e4[n3] = t5[n3];
}), e4;
}, t3.basename = function e4(t4) {
const n3 = ~t4.lastIndexOf("/") || ~t4.lastIndexOf("\\");
return 0 === n3 ? t4 : ~n3 == t4.length - 1 ? e4(t4.substring(0, t4.length - 1)) : t4.substr(1 + ~n3);
};
let s = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/g;
function r2(e4, t4) {
return e4 < t4 ? -1 : e4 > t4 ? 1 : 0;
}
t3.RegexSource = class {
static hasCaptures(e4) {
return null !== e4 && (s.lastIndex = 0, s.test(e4));
}
static replaceCaptures(e4, t4, n3) {
return e4.replace(s, (e5, s2, r3, i2) => {
let o = n3[parseInt(s2 || r3, 10)];
if (!o)
return e5;
{
let e6 = t4.substring(o.start, o.end);
for (; "." === e6[0]; )
e6 = e6.substring(1);
switch (i2) {
case "downcase":
return e6.toLowerCase();
case "upcase":
return e6.toUpperCase();
default:
return e6;
}
}
});
}
}, t3.strcmp = r2, t3.strArrCmp = function(e4, t4) {
if (null === e4 && null === t4)
return 0;
if (!e4)
return -1;
if (!t4)
return 1;
let n3 = e4.length, s2 = t4.length;
if (n3 === s2) {
for (let s3 = 0; s3 < n3; s3++) {
let n4 = r2(e4[s3], t4[s3]);
if (0 !== n4)
return n4;
}
return 0;
}
return n3 - s2;
}, t3.isValidHexColor = function(e4) {
return !!(/^#[0-9a-f]{6}$/i.test(e4) || /^#[0-9a-f]{8}$/i.test(e4) || /^#[0-9a-f]{3}$/i.test(e4) || /^#[0-9a-f]{4}$/i.test(e4));
}, t3.escapeRegExpCharacters = function(e4) {
return e4.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, "\\$&");
}, t3.CachedFn = class {
constructor(e4) {
this.fn = e4, this.cache = /* @__PURE__ */ new Map();
}
get(e4) {
if (this.cache.has(e4))
return this.cache.get(e4);
const t4 = this.fn(e4);
return this.cache.set(e4, t4), t4;
}
}, t3.performanceNow = "undefined" == typeof performance ? function() {
return Date.now();
} : function() {
return performance.now();
};
} }, t2 = {};
return function n2(s) {
var r2 = t2[s];
if (void 0 !== r2)
return r2.exports;
var i2 = t2[s] = { exports: {} };
return e2[s].call(i2.exports, i2, i2.exports, n2), i2.exports;
}(787);
})();
});
})(main);
const languages = [
{
id: "abap",
scopeName: "source.abap",
path: "abap.tmLanguage.json",
samplePath: "abap.sample"
},
{
id: "actionscript-3",
scopeName: "source.actionscript.3",
path: "actionscript-3.tmLanguage.json",
samplePath: "actionscript-3.sample"
},
{
id: "ada",
scopeName: "source.ada",
path: "ada.tmLanguage.json",
samplePath: "ada.sample"
},
{
id: "apache",
scopeName: "source.apacheconf",
path: "apache.tmLanguage.json"
},
{
id: "apex",
scopeName: "source.apex",
path: "apex.tmLanguage.json",
samplePath: "apex.sample"
},
{
id: "apl",
scopeName: "source.apl",
path: "apl.tmLanguage.json",
embeddedLangs: ["html", "xml", "css", "javascript", "json"]
},
{
id: "applescript",
scopeName: "source.applescript",
path: "applescript.tmLanguage.json",
samplePath: "applescript.sample"
},
{
id: "asm",
scopeName: "source.asm.x86_64",
path: "asm.tmLanguage.json",
samplePath: "asm.sample"
},
{
id: "astro",
scopeName: "source.astro",
path: "astro.tmLanguage.json",
samplePath: "astro.sample",
embeddedLangs: ["json", "javascript", "typescript", "tsx", "css", "less", "sass", "scss", "stylus"]
},
{
id: "awk",
scopeName: "source.awk",
path: "awk.tmLanguage.json",
samplePath: "awk.sample"
},
{
id: "ballerina",
scopeName: "source.ballerina",
path: "ballerina.tmLanguage.json",
samplePath: "ballerina.sample"
},
{
id: "bat",
scopeName: "source.batchfile",
path: "bat.tmLanguage.json",
samplePath: "bat.sample",
aliases: ["batch"]
},
{
id: "berry",
scopeName: "source.berry",
path: "berry.tmLanguage.json",
samplePath: "berry.sample",
aliases: ["be"]
},
{
id: "bibtex",
scopeName: "text.bibtex",
path: "bibtex.tmLanguage.json"
},
{
id: "bicep",
scopeName: "source.bicep",
path: "bicep.tmLanguage.json",
samplePath: "bicep.sample"
},
{
id: "blade",
scopeName: "text.html.php.blade",
path: "blade.tmLanguage.json",
samplePath: "blade.sample",
embeddedLangs: ["html", "xml", "sql", "javascript", "json", "css"]
},
{
id: "c",
scopeName: "source.c",
path: "c.tmLanguage.json",
samplePath: "c.sample"
},
{
id: "cadence",
scopeName: "source.cadence",
path: "cadence.tmLanguage.json",
samplePath: "cadence.sample",
aliases: ["cdc"]
},
{
id: "clarity",
scopeName: "source.clar",
path: "clarity.tmLanguage.json",
samplePath: "clarity.sample"
},
{
id: "clojure",
scopeName: "source.clojure",
path: "clojure.tmLanguage.json",
samplePath: "clojure.sample",
aliases: ["clj"]
},
{
id: "cmake",
scopeName: "source.cmake",
path: "cmake.tmLanguage.json",
samplePath: "cmake.sample"
},
{
id: "cobol",
scopeName: "source.cobol",
path: "cobol.tmLanguage.json",
samplePath: "cobol.sample",
embeddedLangs: ["sql", "html", "java"]
},
{
id: "codeql",
scopeName: "source.ql",
path: "codeql.tmLanguage.json",
samplePath: "codeql.sample",
aliases: ["ql"],
embeddedLangs: ["markdown"]
},
{
id: "coffee",
scopeName: "source.coffee",
path: "coffee.tmLanguage.json",
samplePath: "coffee.sample",
embeddedLangs: ["javascript"]
},
{
id: "cpp",
scopeName: "source.cpp",
path: "cpp.tmLanguage.json",
samplePath: "cpp.sample",
embeddedLangs: ["glsl", "sql"]
},
{
id: "crystal",
scopeName: "source.crystal",
path: "crystal.tmLanguage.json",
samplePath: "crystal.sample",
embeddedLangs: ["html", "sql", "css", "c", "javascript", "shellscript"]
},
{
id: "csharp",
scopeName: "source.cs",
path: "csharp.tmLanguage.json",
samplePath: "csharp.sample",
aliases: ["c#", "cs"]
},
{
id: "css",
scopeName: "source.css",
path: "css.tmLanguage.json",
samplePath: "css.sample"
},
{
id: "cue",
scopeName: "source.cue",
path: "cue.tmLanguage.json",
samplePath: "cue.sample"
},
{
id: "d",
scopeName: "source.d",
path: "d.tmLanguage.json",
samplePath: "d.sample"
},
{
id: "dart",
scopeName: "source.dart",
path: "dart.tmLanguage.json",
samplePath: "dart.sample"
},
{
id: "diff",
scopeName: "source.diff",
path: "diff.tmLanguage.json",
samplePath: "diff.sample"
},
{
id: "docker",
scopeName: "source.dockerfile",
path: "docker.tmLanguage.json",
samplePath: "docker.sample"
},
{
id: "dream-maker",
scopeName: "source.dm",
path: "dream-maker.tmLanguage.json"
},
{
id: "elixir",
scopeName: "source.elixir",
path: "elixir.tmLanguage.json",
samplePath: "elixir.sample",
embeddedLangs: ["html"]
},
{
id: "elm",
scopeName: "source.elm",
path: "elm.tmLanguage.json",
samplePath: "elm.sample",
embeddedLangs: ["glsl"]
},
{
id: "erb",
scopeName: "text.html.erb",
path: "erb.tmLanguage.json",
samplePath: "erb.sample",
embeddedLangs: ["html", "ruby"]
},
{
id: "erlang",
scopeName: "source.erlang",
path: "erlang.tmLanguage.json",
samplePath: "erlang.sample",
aliases: ["erl"]
},
{
id: "fish",
scopeName: "source.fish",
path: "fish.tmLanguage.json",
samplePath: "fish.sample"
},
{
id: "fsharp",
scopeName: "source.fsharp",
path: "fsharp.tmLanguage.json",
samplePath: "fsharp.sample",
aliases: ["f#", "fs"],
embeddedLangs: ["markdown"]
},
{
id: "gherkin",
scopeName: "text.gherkin.feature",
path: "gherkin.tmLanguage.json"
},
{
id: "git-commit",
scopeName: "text.git-commit",
path: "git-commit.tmLanguage.json",
embeddedLangs: ["diff"]
},
{
id: "git-rebase",
scopeName: "text.git-rebase",
path: "git-rebase.tmLanguage.json",
embeddedLangs: ["shellscript"]
},
{
id: "glsl",
scopeName: "source.glsl",
path: "glsl.tmLanguage.json",
samplePath: "glsl.sample",
embeddedLangs: ["c"]
},
{
id: "gnuplot",
scopeName: "source.gnuplot",
path: "gnuplot.tmLanguage.json"
},
{
id: "go",
scopeName: "source.go",
path: "go.tmLanguage.json",
samplePath: "go.sample"
},
{
id: "graphql",
scopeName: "source.graphql",
path: "graphql.tmLanguage.json",
embeddedLangs: ["javascript", "typescript", "jsx", "tsx"]
},
{
id: "groovy",
scopeName: "source.groovy",
path: "groovy.tmLanguage.json"
},
{
id: "hack",
scopeName: "source.hack",
path: "hack.tmLanguage.json",
embeddedLangs: ["html", "sql"]
},
{
id: "haml",
scopeName: "text.haml",
path: "haml.tmLanguage.json",
embeddedLangs: ["ruby", "javascript", "sass", "coffee", "markdown", "css"]
},
{
id: "handlebars",
scopeName: "text.html.handlebars",
path: "handlebars.tmLanguage.json",
aliases: ["hbs"],
embeddedLangs: ["html", "css", "javascript", "yaml"]
},
{
id: "haskell",
scopeName: "source.haskell",
path: "haskell.tmLanguage.json",
aliases: ["hs"]
},
{
id: "hcl",
scopeName: "source.hcl",
path: "hcl.tmLanguage.json",
samplePath: "hcl.sample"
},
{
id: "hlsl",
scopeName: "source.hlsl",
path: "hlsl.tmLanguage.json"
},
{
id: "html",
scopeName: "text.html.basic",
path: "html.tmLanguage.json",
samplePath: "html.sample",
embeddedLangs: ["javascript", "css"]
},
{
id: "imba",
scopeName: "source.imba",
path: "imba.tmLanguage.json",
samplePath: "imba.sample"
},
{
id: "ini",
scopeName: "source.ini",
path: "ini.tmLanguage.json"
},
{
id: "java",
scopeName: "source.java",
path: "java.tmLanguage.json",
samplePath: "java.sample"
},
{
id: "javascript",
scopeName: "source.js",
path: "javascript.tmLanguage.json",
samplePath: "javascript.sample",
aliases: ["js"]
},
{
id: "jinja-html",
scopeName: "text.html.jinja",
path: "jinja-html.tmLanguage.json",
embeddedLangs: ["html"]
},
{
id: "json",
scopeName: "source.json",
path: "json.tmLanguage.json"
},
{
id: "json5",
scopeName: "source.json5",
path: "json5.tmLanguage.json",
samplePath: "json5.sample"
},
{
id: "jsonc",
scopeName: "source.json.comments",
path: "jsonc.tmLanguage.json"
},
{
id: "jsonnet",
scopeName: "source.jsonnet",
path: "jsonnet.tmLanguage.json"
},
{
id: "jssm",
scopeName: "source.jssm",
path: "jssm.tmLanguage.json",
samplePath: "jssm.sample",
aliases: ["fsl"]
},
{
id: "jsx",
scopeName: "source.js.jsx",
path: "jsx.tmLanguage.json"
},
{
id: "julia",
scopeName: "source.julia",
path: "julia.tmLanguage.json",
embeddedLangs: ["cpp", "python", "javascript", "r", "sql"]
},
{
id: "kotlin",
scopeName: "source.kotlin",
path: "kotlin.tmLanguage.json"
},
{
id: "latex",
scopeName: "text.tex.latex",
path: "latex.tmLanguage.json",
embeddedLangs: ["tex", "css", "haskell", "html", "xml", "java", "lua", "julia", "ruby", "javascript", "typescript", "python", "yaml", "rust", "scala", "gnuplot"]
},
{
id: "less",
scopeName: "source.css.less",
path: "less.tmLanguage.json",
embeddedLangs: ["css"]
},
{
id: "liquid",
scopeName: "text.html.liquid",
path: "liquid.tmLanguage.json",
samplePath: "liquid.sample",
embeddedLangs: ["html", "css", "json", "javascript"]
},
{
id: "lisp",
scopeName: "source.lisp",
path: "lisp.tmLanguage.json"
},
{
id: "logo",
scopeName: "source.logo",
path: "logo.tmLanguage.json"
},
{
id: "lua",
scopeName: "source.lua",
path: "lua.tmLanguage.json",
embeddedLangs: ["c"]
},
{
id: "make",
scopeName: "source.makefile",
path: "make.tmLanguage.json",
aliases: ["makefile"]
},
{
id: "markdown",
scopeName: "text.html.markdown",
path: "markdown.tmLanguage.json",
aliases: ["md"],
embeddedLangs: ["css", "html", "ini", "java", "lua", "make", "perl", "r", "ruby", "php", "sql", "vb", "xml", "xsl", "yaml", "bat", "clojure", "coffee", "c", "cpp", "diff", "docker", "git-commit", "git-rebase", "go", "groovy", "pug", "javascript", "json", "jsonc", "less", "objective-c", "swift", "scss", "raku", "powershell", "python", "julia", "rust", "scala", "shellscript", "typescript", "tsx", "csharp", "fsharp", "dart", "handlebars", "erlang", "elixir", "latex", "bibtex"]
},
{
id: "marko",
scopeName: "text.marko",
path: "marko.tmLanguage.json",
embeddedLangs: ["css", "less", "scss", "typescript"]
},
{
id: "matlab",
scopeName: "source.matlab",
path: "matlab.tmLanguage.json"
},
{
id: "mdx",
scopeName: "text.html.markdown.jsx",
path: "mdx.tmLanguage.json",
embeddedLangs: ["jsx", "markdown"]
},
{
id: "mermaid",
scopeName: "source.mermaid",
path: "mermaid.tmLanguage.json"
},
{
id: "nginx",
scopeName: "source.nginx",
path: "nginx.tmLanguage.json",
embeddedLangs: ["lua"]
},
{
id: "nim",
scopeName: "source.nim",
path: "nim.tmLanguage.json",
embeddedLangs: ["c", "html", "xml", "javascript", "css", "glsl", "markdown"]
},
{
id: "nix",
scopeName: "source.nix",
path: "nix.tmLanguage.json"
},
{
id: "objective-c",
scopeName: "source.objc",
path: "objective-c.tmLanguage.json",
aliases: ["objc"]
},
{
id: "objective-cpp",
scopeName: "source.objcpp",
path: "objective-cpp.tmLanguage.json"
},
{
id: "ocaml",
scopeName: "source.ocaml",
path: "ocaml.tmLanguage.json"
},
{
id: "pascal",
scopeName: "source.pascal",
path: "pascal.tmLanguage.json"
},
{
id: "perl",
scopeName: "source.perl",
path: "perl.tmLanguage.json",
embeddedLangs: ["html", "xml", "css", "javascript", "sql"]
},
{
id: "php",
scopeName: "source.php",
path: "php.tmLanguage.json",
embeddedLangs: ["html", "xml", "sql", "javascript", "json", "css"]
},
{
id: "plsql",
scopeName: "source.plsql.oracle",
path: "plsql.tmLanguage.json"
},
{
id: "postcss",
scopeName: "source.css.postcss",
path: "postcss.tmLanguage.json"
},
{
id: "powershell",
scopeName: "source.powershell",
path: "powershell.tmLanguage.json",
aliases: ["ps", "ps1"]
},
{
id: "prisma",
scopeName: "source.prisma",
path: "prisma.tmLanguage.json",
samplePath: "prisma.sample"
},
{
id: "prolog",
scopeName: "source.prolog",
path: "prolog.tmLanguage.json"
},
{
id: "proto",
scopeName: "source.proto",
path: "proto.tmLanguage.json",
samplePath: "proto.sample"
},
{
id: "pug",
scopeName: "text.pug",
path: "pug.tmLanguage.json",
aliases: ["jade"],
embeddedLangs: ["javascript", "css", "sass", "scss", "stylus", "coffee", "html"]
},
{
id: "puppet",
scopeName: "source.puppet",
path: "puppet.tmLanguage.json"
},
{
id: "purescript",
scopeName: "source.purescript",
path: "purescript.tmLanguage.json"
},
{
id: "python",
scopeName: "source.python",
path: "python.tmLanguage.json",
samplePath: "python.sample",
aliases: ["py"]
},
{
id: "r",
scopeName: "source.r",
path: "r.tmLanguage.json"
},
{
id: "raku",
scopeName: "source.perl.6",
path: "raku.tmLanguage.json",
aliases: ["perl6"]
},
{
id: "razor",
scopeName: "text.aspnetcorerazor",
path: "razor.tmLanguage.json",
embeddedLangs: ["html", "csharp"]
},
{
id: "rel",
scopeName: "source.rel",
path: "rel.tmLanguage.json",
samplePath: "rel.sample"
},
{
id: "riscv",
scopeName: "source.riscv",
path: "riscv.tmLanguage.json"
},
{
id: "rst",
scopeName: "source.rst",
path: "rst.tmLanguage.json",
embeddedLangs: ["cpp", "python", "javascript", "shellscript", "yaml", "cmake", "ruby"]
},
{
id: "ruby",
scopeName: "source.ruby",
path: "ruby.tmLanguage.json",
samplePath: "ruby.sample",
aliases: ["rb"],
embeddedLangs: ["html", "xml", "sql", "css", "c", "javascript", "shellscript", "lua"]
},
{
id: "rust",
scopeName: "source.rust",
path: "rust.tmLanguage.json",
aliases: ["rs"]
},
{
id: "sas",
scopeName: "source.sas",
path: "sas.tmLanguage.json",
embeddedLangs: ["sql"]
},
{
id: "sass",
scopeName: "source.sass",
path: "sass.tmLanguage.json"
},
{
id: "scala",
scopeName: "source.scala",
path: "scala.tmLanguage.json"
},
{
id: "scheme",
scopeName: "source.scheme",
path: "scheme.tmLanguage.json"
},
{
id: "scss",
scopeName: "source.css.scss",
path: "scss.tmLanguage.json",
embeddedLangs: ["css"]
},
{
id: "shaderlab",
scopeName: "source.shaderlab",
path: "shaderlab.tmLanguage.json",
aliases: ["shader"],
embeddedLangs: ["hlsl"]
},
{
id: "shellscript",
scopeName: "source.shell",
path: "shellscript.tmLanguage.json",
aliases: ["shell", "bash", "sh", "zsh"]
},
{
id: "smalltalk",
scopeName: "source.smalltalk",
path: "smalltalk.tmLanguage.json"
},
{
id: "solidity",
scopeName: "source.solidity",
path: "solidity.tmLanguage.json"
},
{
id: "sparql",
scopeName: "source.sparql",
path: "sparql.tmLanguage.json",
samplePath: "sparql.sample",
embeddedLangs: ["turtle"]
},
{
id: "sql",
scopeName: "source.sql",
path: "sql.tmLanguage.json"
},
{
id: "ssh-config",
scopeName: "source.ssh-config",
path: "ssh-config.tmLanguage.json"
},
{
id: "stata",
scopeName: "source.stata",
path: "stata.tmLanguage.json",
samplePath: "stata.sample",
embeddedLangs: ["sql"]
},
{
id: "stylus",
scopeName: "source.stylus",
path: "stylus.tmLanguage.json",
aliases: ["styl"]
},
{
id: "svelte",
scopeName: "source.svelte",
path: "svelte.tmLanguage.json",
embeddedLangs: ["javascript", "typescript", "coffee", "stylus", "sass", "css", "scss", "less", "postcss", "pug", "markdown"]
},
{
id: "swift",
scopeName: "source.swift",
path: "swift.tmLanguage.json"
},
{
id: "system-verilog",
scopeName: "source.systemverilog",
path: "system-verilog.tmLanguage.json"
},
{
id: "tasl",
scopeName: "source.tasl",
path: "tasl.tmLanguage.json",
samplePath: "tasl.sample"
},
{
id: "tcl",
scopeName: "source.tcl",
path: "tcl.tmLanguage.json"
},
{
id: "tex",
scopeName: "text.tex",
path: "tex.tmLanguage.json",
embeddedLangs: ["r"]
},
{
id: "toml",
scopeName: "source.toml",
path: "toml.tmLanguage.json"
},
{
id: "tsx",
scopeName: "source.tsx",
path: "tsx.tmLanguage.json",
samplePath: "tsx.sample"
},
{
id: "turtle",
scopeName: "source.turtle",
path: "turtle.tmLanguage.json",
samplePath: "turtle.sample"
},
{
id: "twig",
scopeName: "text.html.twig",
path: "twig.tmLanguage.json",
embeddedLangs: ["css", "javascript", "php", "python", "ruby"]
},
{
id: "typescript",
scopeName: "source.ts",
path: "typescript.tmLanguage.json",
aliases: ["ts"]
},
{
id: "v",
scopeName: "source.v",
path: "v.tmLanguage.json",
samplePath: "v.sample"
},
{
id: "vb",
scopeName: "source.asp.vb.net",
path: "vb.tmLanguage.json",
aliases: ["cmd"]
},
{
id: "verilog",
scopeName: "source.verilog",
path: "verilog.tmLanguage.json"
},
{
id: "vhdl",
scopeName: "source.vhdl",
path: "vhdl.tmLanguage.json"
},
{
id: "viml",
scopeName: "source.viml",
path: "viml.tmLanguage.json",
aliases: ["vim", "vimscript"]
},
{
id: "vue-html",
scopeName: "text.html.vue-html",
path: "vue-html.tmLanguage.json",
embeddedLangs: ["vue", "javascript"]
},
{
id: "vue",
scopeName: "source.vue",
path: "vue.tmLanguage.json",
embeddedLangs: ["html", "markdown", "pug", "stylus", "sass", "css", "scss", "less", "javascript", "typescript", "jsx", "tsx", "json", "jsonc", "yaml", "toml", "graphql"]
},
{
id: "wasm",
scopeName: "source.wat",
path: "wasm.tmLanguage.json"
},
{
id: "wenyan",
scopeName: "source.wenyan",
path: "wenyan.tmLanguage.json",
aliases: ["文言"]
},
{
id: "xml",
scopeName: "text.xml",
path: "xml.tmLanguage.json",
embeddedLangs: ["java"]
},
{
id: "xsl",
scopeName: "text.xml.xsl",
path: "xsl.tmLanguage.json",
embeddedLangs: ["xml"]
},
{
id: "yaml",
scopeName: "source.yaml",
path: "yaml.tmLanguage.json"
},
{
id: "zenscript",
scopeName: "source.zenscript",
path: "zenscript.tmLanguage.json",
samplePath: "zenscript.sample"
}
];
var FontStyle = /* @__PURE__ */ ((FontStyle2) => {
FontStyle2[FontStyle2["NotSet"] = -1] = "NotSet";
FontStyle2[FontStyle2["None"] = 0] = "None";
FontStyle2[FontStyle2["Italic"] = 1] = "Italic";
FontStyle2[FontStyle2["Bold"] = 2] = "Bold";
FontStyle2[FontStyle2["Underline"] = 4] = "Underline";
return FontStyle2;
})(FontStyle || {});
class StackElementMetadata {
static toBinaryStr(metadata) {
let r2 = metadata.toString(2);
while (r2.length < 32) {
r2 = "0" + r2;
}
return r2;
}
static printMetadata(metadata) {
let languageId = StackElementMetadata.getLanguageId(metadata);
let tokenType = StackElementMetadata.getTokenType(metadata);
let fontStyle = StackElementMetadata.getFontStyle(metadata);
let foreground = StackElementMetadata.getForeground(metadata);
let background = StackElementMetadata.getBackground(metadata);
console.log({
languageId,
tokenType,
fontStyle,
foreground,
background
});
}
static getLanguageId(metadata) {
return (metadata & 255) >>> 0;
}
static getTokenType(metadata) {
return (metadata & 768) >>> 8;
}
static getFontStyle(metadata) {
return (metadata & 14336) >>> 11;
}
static getForeground(metadata) {
return (metadata & 8372224) >>> 15;
}
static getBackground(metadata) {
return (metadata & 4286578688) >>> 24;
}
static containsBalancedBrackets(metadata) {
return (metadata & 1024) !== 0;
}
static set(metadata, languageId, tokenType, fontStyle, foreground, background) {
let _languageId = StackElementMetadata.getLanguageId(metadata);
let _tokenType = StackElementMetadata.getTokenType(metadata);
let _fontStyle = StackElementMetadata.getFontStyle(metadata);
let _foreground = StackElementMetadata.getForeground(metadata);
let _background = StackElementMetadata.getBackground(metadata);
let _containsBalancedBracketsBit = StackElementMetadata.containsBalancedBrackets(
metadata
) ? 1 : 0;
if (languageId !== 0) {
_languageId = languageId;
}
if (tokenType !== 0) {
_tokenType = tokenType === 8 ? 0 : tokenType;
}
if (fontStyle !== -1) {
_fontStyle = fontStyle;
}
if (foreground !== 0) {
_foreground = foreground;
}
if (background !== 0) {
_background = background;
}
return (_languageId << 0 | _tokenType << 8 | _fontStyle << 11 | _containsBalancedBracketsBit << 10 | _foreground << 15 | _background << 24) >>> 0;
}
}
function trimEndSlash(str) {
if (str.endsWith("/") || str.endsWith("\\"))
return str.slice(0, -1);
return str;
}
function trimStartDot(str) {
if (str.startsWith("./"))
return str.slice(2);
return str;
}
function dirpathparts(str) {
const parts = str.split(/[\/\\]/g);
return parts.slice(0, parts.length - 1);
}
function join(...parts) {
return parts.map(trimEndSlash).map(trimStartDot).join("/");
}
function groupBy(elements, keyGetter) {
const map2 = /* @__PURE__ */ new Map();
for (const element2 of elements) {
const key = keyGetter(element2);
if (map2.has(key)) {
const group = map2.get(key);
group.push(element2);
} else {
map2.set(key, [element2]);
}
}
return map2;
}
function createScanner(text2, ignoreTrivia = false) {
const len = text2.length;
let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
function scanHexDigits(count2, exact) {
let digits = 0;
let value2 = 0;
while (digits < count2 || !exact) {
let ch2 = text2.charCodeAt(pos);
if (ch2 >= 48 && ch2 <= 57) {
value2 = value2 * 16 + ch2 - 48;
} else if (ch2 >= 65 && ch2 <= 70) {
value2 = value2 * 16 + ch2 - 65 + 10;
} else if (ch2 >= 97 && ch2 <= 102) {
value2 = value2 * 16 + ch2 - 97 + 10;
} else {
break;
}
pos++;
digits++;
}
if (digits < count2) {
value2 = -1;
}
return value2;
}
function setPosition(newPosition) {
pos = newPosition;
value = "";
tokenOffset = 0;
token = 16;
scanError = 0;
}
function scanNumber() {
let start = pos;
if (text2.charCodeAt(pos) === 48) {
pos++;
} else {
pos++;
while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
pos++;
}
}
if (pos < text2.length && text2.charCodeAt(pos) === 46) {
pos++;
if (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
pos++;
while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
pos++;
}
} else {
scanError = 3;
return text2.substring(start, pos);
}
}
let end = pos;
if (pos < text2.length && (text2.charCodeAt(pos) === 69 || text2.charCodeAt(pos) === 101)) {
pos++;
if (pos < text2.length && text2.charCodeAt(pos) === 43 || text2.charCodeAt(pos) === 45) {
pos++;
}
if (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
pos++;
while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
pos++;
}
end = pos;
} else {
scanError = 3;
}
}
return text2.substring(start, end);
}
function scanString() {
let result = "", start = pos;
while (true) {
if (pos >= len) {
result += text2.substring(start, pos);
scanError = 2;
break;
}
const ch2 = text2.charCodeAt(pos);
if (ch2 === 34) {
result += text2.substring(start, pos);
pos++;
break;
}
if (ch2 === 92) {
result += text2.substring(start, pos);
pos++;
if (pos >= len) {
scanError = 2;
break;
}
const ch22 = text2.charCodeAt(pos++);
switch (ch22) {
case 34:
result += '"';
break;
case 92:
result += "\\";
break;
case 47:
result += "/";
break;
case 98:
result += "\b";
break;
case 102:
result += "\f";
break;
case 110:
result += "\n";
break;
case 114:
result += "\r";
break;
case 116:
result += " ";
break;
case 117:
const ch3 = scanHexDigits(4, true);
if (ch3 >= 0) {
result += String.fromCharCode(ch3);
} else {
scanError = 4;
}
break;
default:
scanError = 5;
}
start = pos;
continue;
}
if (ch2 >= 0 && ch2 <= 31) {
if (isLineBreak(ch2)) {
result += text2.substring(start, pos);
scanError = 2;
break;
} else {
scanError = 6;
}
}
pos++;
}
return result;
}
function scanNext() {
value = "";
scanError = 0;
tokenOffset = pos;
lineStartOffset = lineNumber;
prevTokenLineStartOffset = tokenLineStartOffset;
if (pos >= len) {
tokenOffset = len;
return token = 17;
}
let code = text2.charCodeAt(pos);
if (isWhiteSpace(code)) {
do {
pos++;
value += String.fromCharCode(code);
code = text2.charCodeAt(pos);
} while (isWhiteSpace(code));
return token = 15;
}
if (isLineBreak(code)) {
pos++;
value += String.fromCharCode(code);
if (code === 13 && text2.charCodeAt(pos) === 10) {
pos++;
value += "\n";
}
lineNumber++;
tokenLineStartOffset = pos;
return token = 14;
}
switch (code) {
case 123:
pos++;
return token = 1;
case 125:
pos++;
return token = 2;
case 91:
pos++;
return token = 3;
case 93:
pos++;
return token = 4;
case 58:
pos++;
return token = 6;
case 44:
pos++;
return token = 5;
case 34:
pos++;
value = scanString();
return token = 10;
case 47:
const start = pos - 1;
if (text2.charCodeAt(pos + 1) === 47) {
pos += 2;
while (pos < len) {
if (isLineBreak(text2.charCodeAt(pos))) {
break;
}
pos++;
}
value = text2.substring(start, pos);
return token = 12;
}
if (text2.charCodeAt(pos + 1) === 42) {
pos += 2;
const safeLength = len - 1;
let commentClosed = false;
while (pos < safeLength) {
const ch2 = text2.charCodeAt(pos);
if (ch2 === 42 && text2.charCodeAt(pos + 1) === 47) {
pos += 2;
commentClosed = true;
break;
}
pos++;
if (isLineBreak(ch2)) {
if (ch2 === 13 && text2.charCodeAt(pos) === 10) {
pos++;
}
lineNumber++;
tokenLineStartOffset = pos;
}
}
if (!commentClosed) {
pos++;
scanError = 1;
}
value = text2.substring(start, pos);
return token = 13;
}
value += String.fromCharCode(code);
pos++;
return token = 16;
case 45:
value += String.fromCharCode(code);
pos++;
if (pos === len || !isDigit(text2.charCodeAt(pos))) {
return token = 16;
}
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
value += scanNumber();
return token = 11;
default:
while (pos < len && isUnknownContentCharacter(code)) {
pos++;
code = text2.charCodeAt(pos);
}
if (tokenOffset !== pos) {
value = text2.substring(tokenOffset, pos);
switch (value) {
case "true":
return token = 8;
case "false":
return token = 9;
case "null":
return token = 7;
}
return token = 16;
}
value += String.fromCharCode(code);
pos++;
return token = 16;
}
}
function isUnknownContentCharacter(code) {
if (isWhiteSpace(code) || isLineBreak(code)) {
return false;
}
switch (code) {
case 125:
case 93:
case 123:
case 91:
case 34:
case 58:
case 44:
case 47:
return false;
}
return true;
}
function scanNextNonTrivia() {
let result;
do {
result = scanNext();
} while (result >= 12 && result <= 15);
return result;
}
return {
setPosition,
getPosition: () => pos,
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
getToken: () => token,
getTokenValue: () => value,
getTokenOffset: () => tokenOffset,
getTokenLength: () => pos - tokenOffset,
getTokenStartLine: () => lineStartOffset,
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
getTokenError: () => scanError
};
}
function isWhiteSpace(ch2) {
return ch2 === 32 || ch2 === 9;
}
function isLineBreak(ch2) {
return ch2 === 10 || ch2 === 13;
}
function isDigit(ch2) {
return ch2 >= 48 && ch2 <= 57;
}
var CharacterCodes;
(function(CharacterCodes2) {
CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
})(CharacterCodes || (CharacterCodes = {}));
var ParseOptions;
(function(ParseOptions2) {
ParseOptions2.DEFAULT = {
allowTrailingComma: false
};
})(ParseOptions || (ParseOptions = {}));
function parse$1(text2, errors = [], options = ParseOptions.DEFAULT) {
let currentProperty = null;
let currentParent = [];
const previousParents = [];
function onValue(value) {
if (Array.isArray(currentParent)) {
currentParent.push(value);
} else if (currentProperty !== null) {
currentParent[currentProperty] = value;
}
}
const visitor = {
onObjectBegin: () => {
const object = {};
onValue(object);
previousParents.push(currentParent);
currentParent = object;
currentProperty = null;
},
onObjectProperty: (name) => {
currentProperty = name;
},
onObjectEnd: () => {
currentParent = previousParents.pop();
},
onArrayBegin: () => {
const array = [];
onValue(array);
previousParents.push(currentParent);
currentParent = array;
currentProperty = null;
},
onArrayEnd: () => {
currentParent = previousParents.pop();
},
onLiteralValue: onValue,
onError: (error, offset2, length) => {
errors.push({ error, offset: offset2, length });
}
};
visit(text2, visitor, options);
return currentParent[0];
}
function visit(text2, visitor, options = ParseOptions.DEFAULT) {
const _scanner = createScanner(text2, false);
const _jsonPath = [];
function toNoArgVisit(visitFunction) {
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
}
function toNoArgVisitWithPath(visitFunction) {
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
}
function toOneArgVisit(visitFunction) {
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
}
function toOneArgVisitWithPath(visitFunction) {
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
}
const onObjectBegin = toNoArgVisitWithPath(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisitWithPath(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
const disallowComments = options && options.disallowComments;
const allowTrailingComma = options && options.allowTrailingComma;
function scanNext() {
while (true) {
const token = _scanner.scan();
switch (_scanner.getTokenError()) {
case 4:
handleError2(
14
/* ParseErrorCode.InvalidUnicode */
);
break;
case 5:
handleError2(
15
/* ParseErrorCode.InvalidEscapeCharacter */
);
break;
case 3:
handleError2(
13
/* ParseErrorCode.UnexpectedEndOfNumber */
);
break;
case 1:
if (!disallowComments) {
handleError2(
11
/* ParseErrorCode.UnexpectedEndOfComment */
);
}
break;
case 2:
handleError2(
12
/* ParseErrorCode.UnexpectedEndOfString */
);
break;
case 6:
handleError2(
16
/* ParseErrorCode.InvalidCharacter */
);
break;
}
switch (token) {
case 12:
case 13:
if (disallowComments) {
handleError2(
10
/* ParseErrorCode.InvalidCommentToken */
);
} else {
onComment();
}
break;
case 16:
handleError2(
1
/* ParseErrorCode.InvalidSymbol */
);
break;
case 15:
case 14:
break;
default:
return token;
}
}
}
function handleError2(error, skipUntilAfter = [], skipUntil = []) {
onError(error);
if (skipUntilAfter.length + skipUntil.length > 0) {
let token = _scanner.getToken();
while (token !== 17) {
if (skipUntilAfter.indexOf(token) !== -1) {
scanNext();
break;
} else if (skipUntil.indexOf(token) !== -1) {
break;
}
token = scanNext();
}
}
}
function parseString(isValue) {
const value = _scanner.getTokenValue();
if (isValue) {
onLiteralValue(value);
} else {
onObjectProperty(value);
_jsonPath.push(value);
}
scanNext();
return true;
}
function parseLiteral() {
switch (_scanner.getToken()) {
case 11:
const tokenValue = _scanner.getTokenValue();
let value = Number(tokenValue);
if (isNaN(value)) {
handleError2(
2
/* ParseErrorCode.InvalidNumberFormat */
);
value = 0;
}
onLiteralValue(value);
break;
case 7:
onLiteralValue(null);
break;
case 8:
onLiteralValue(true);
break;
case 9:
onLiteralValue(false);
break;
default:
return false;
}
scanNext();
return true;
}
function parseProperty() {
if (_scanner.getToken() !== 10) {
handleError2(3, [], [
2,
5
/* SyntaxKind.CommaToken */
]);
return false;
}
parseString(false);
if (_scanner.getToken() === 6) {
onSeparator(":");
scanNext();
if (!parseValue()) {
handleError2(4, [], [
2,
5
/* SyntaxKind.CommaToken */
]);
}
} else {
handleError2(5, [], [
2,
5
/* SyntaxKind.CommaToken */
]);
}
_jsonPath.pop();
return true;
}
function parseObject() {
onObjectBegin();
scanNext();
let needsComma = false;
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
if (_scanner.getToken() === 5) {
if (!needsComma) {
handleError2(4, [], []);
}
onSeparator(",");
scanNext();
if (_scanner.getToken() === 2 && allowTrailingComma) {
break;
}
} else if (needsComma) {
handleError2(6, [], []);
}
if (!parseProperty()) {
handleError2(4, [], [
2,
5
/* SyntaxKind.CommaToken */
]);
}
needsComma = true;
}
onObjectEnd();
if (_scanner.getToken() !== 2) {
handleError2(7, [
2
/* SyntaxKind.CloseBraceToken */
], []);
} else {
scanNext();
}
return true;
}
function parseArray() {
onArrayBegin();
scanNext();
let isFirstElement = true;
let needsComma = false;
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
if (_scanner.getToken() === 5) {
if (!needsComma) {
handleError2(4, [], []);
}
onSeparator(",");
scanNext();
if (_scanner.getToken() === 4 && allowTrailingComma) {
break;
}
} else if (needsComma) {
handleError2(6, [], []);
}
if (isFirstElement) {
_jsonPath.push(0);
isFirstElement = false;
} else {
_jsonPath[_jsonPath.length - 1]++;
}
if (!parseValue()) {
handleError2(4, [], [
4,
5
/* SyntaxKind.CommaToken */
]);
}
needsComma = true;
}
onArrayEnd();
if (!isFirstElement) {
_jsonPath.pop();
}
if (_scanner.getToken() !== 4) {
handleError2(8, [
4
/* SyntaxKind.CloseBracketToken */
], []);
} else {
scanNext();
}
return true;
}
function parseValue() {
switch (_scanner.getToken()) {
case 3:
return parseArray();
case 1:
return parseObject();
case 10:
return parseString(true);
default:
return parseLiteral();
}
}
scanNext();
if (_scanner.getToken() === 17) {
if (options.allowEmptyContent) {
return true;
}
handleError2(4, [], []);
return false;
}
if (!parseValue()) {
handleError2(4, [], []);
return false;
}
if (_scanner.getToken() !== 17) {
handleError2(9, [], []);
}
return true;
}
var ScanError;
(function(ScanError2) {
ScanError2[ScanError2["None"] = 0] = "None";
ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
})(ScanError || (ScanError = {}));
var SyntaxKind;
(function(SyntaxKind2) {
SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
})(SyntaxKind || (SyntaxKind = {}));
const parse = parse$1;
var ParseErrorCode;
(function(ParseErrorCode2) {
ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
})(ParseErrorCode || (ParseErrorCode = {}));
"process" in globalThis && typeof process !== "undefined" && typeof process.release !== "undefined" && process.release.name === "node";
let CDN_ROOT = "";
const WASM_PATH = "dist/";
function setCDN(root) {
CDN_ROOT = root.endsWith("/") ? root : root + "/";
}
let _onigurumaPromise = null;
async function getOniguruma(wasmPath) {
if (!_onigurumaPromise) {
let loader;
{
{
loader = mainExports$1.loadWASM({
data: await (globalThis.__shiki_fetch__ || globalThis.fetch)(_resolvePath(join(...dirpathparts(wasmPath), "onig.wasm")))
});
}
}
_onigurumaPromise = loader.then(() => {
return {
createOnigScanner(patterns) {
return mainExports$1.createOnigScanner(patterns);
},
createOnigString(s) {
return mainExports$1.createOnigString(s);
}
};
});
}
return _onigurumaPromise;
}
function _resolvePath(filepath) {
{
return `${CDN_ROOT}${filepath}`;
}
}
async function _fetchAssets(filepath) {
const path = _resolvePath(filepath);
{
return await (globalThis.__shiki_fetch__ || globalThis.fetch)(path).then((r2) => r2.text());
}
}
async function _fetchJSONAssets(filepath) {
const errors = [];
const rawTheme = parse(await _fetchAssets(filepath), errors, {
allowTrailingComma: true
});
if (errors.length) {
throw errors[0];
}
return rawTheme;
}
async function fetchTheme(themePath) {
let theme = await _fetchJSONAssets(themePath);
const shikiTheme = toShikiTheme(theme);
if (shikiTheme.include) {
const includedTheme = await fetchTheme(join(...dirpathparts(themePath), shikiTheme.include));
if (includedTheme.settings) {
shikiTheme.settings = includedTheme.settings.concat(shikiTheme.settings);
}
if (includedTheme.bg && !shikiTheme.bg) {
shikiTheme.bg = includedTheme.bg;
}
if (includedTheme.colors) {
shikiTheme.colors = { ...includedTheme.colors, ...shikiTheme.colors };
}
delete shikiTheme.include;
}
return shikiTheme;
}
async function fetchGrammar(filepath) {
return await _fetchJSONAssets(filepath);
}
function repairTheme(theme) {
if (!theme.settings)
theme.settings = [];
if (theme.settings[0] && theme.settings[0].settings && !theme.settings[0].scope) {
return;
}
theme.settings.unshift({
settings: {
foreground: theme.fg,
background: theme.bg
}
});
}
function toShikiTheme(rawTheme) {
const type = rawTheme.type || "dark";
const shikiTheme = {
name: rawTheme.name,
type,
...rawTheme,
...getThemeDefaultColors(rawTheme)
};
if (rawTheme.include) {
shikiTheme.include = rawTheme.include;
}
if (rawTheme.tokenColors) {
shikiTheme.settings = rawTheme.tokenColors;
delete shikiTheme.tokenColors;
}
repairTheme(shikiTheme);
return shikiTheme;
}
const VSCODE_FALLBACK_EDITOR_FG = { light: "#333333", dark: "#bbbbbb" };
const VSCODE_FALLBACK_EDITOR_BG = { light: "#fffffe", dark: "#1e1e1e" };
function getThemeDefaultColors(theme) {
var _a3, _b2, _c2, _d2;
let fg2, bg2;
let settings = theme.settings ? theme.settings : theme.tokenColors;
const globalSetting = settings ? settings.find((s) => {
return !s.name && !s.scope;
}) : void 0;
if ((_a3 = globalSetting == null ? void 0 : globalSetting.settings) == null ? void 0 : _a3.foreground) {
fg2 = globalSetting.settings.foreground;
}
if ((_b2 = globalSetting == null ? void 0 : globalSetting.settings) == null ? void 0 : _b2.background) {
bg2 = globalSetting.settings.background;
}
if (!fg2 && ((_c2 = theme == null ? void 0 : theme.colors) == null ? void 0 : _c2["editor.foreground"])) {
fg2 = theme.colors["editor.foreground"];
}
if (!bg2 && ((_d2 = theme == null ? void 0 : theme.colors) == null ? void 0 : _d2["editor.background"])) {
bg2 = theme.colors["editor.background"];
}
if (!fg2) {
fg2 = theme.type === "light" ? VSCODE_FALLBACK_EDITOR_FG.light : VSCODE_FALLBACK_EDITOR_FG.dark;
}
if (!bg2) {
bg2 = theme.type === "light" ? VSCODE_FALLBACK_EDITOR_BG.light : VSCODE_FALLBACK_EDITOR_BG.dark;
}
return {
fg: fg2,
bg: bg2
};
}
class Resolver {
constructor(onigLibPromise, onigLibName) {
this.languagesPath = "languages/";
this.languageMap = {};
this.scopeToLangMap = {};
this._onigLibPromise = onigLibPromise;
this._onigLibName = onigLibName;
}
get onigLib() {
return this._onigLibPromise;
}
getOnigLibName() {
return this._onigLibName;
}
getLangRegistration(langIdOrAlias) {
return this.languageMap[langIdOrAlias];
}
async loadGrammar(scopeName) {
const lang = this.scopeToLangMap[scopeName];
if (!lang) {
return null;
}
if (lang.grammar) {
return lang.grammar;
}
const g = await fetchGrammar(
languages.includes(lang) ? `${this.languagesPath}${lang.path}` : lang.path
);
lang.grammar = g;
return g;
}
addLanguage(l) {
this.languageMap[l.id] = l;
if (l.aliases) {
l.aliases.forEach((a2) => {
this.languageMap[a2] = l;
});
}
this.scopeToLangMap[l.scopeName] = l;
}
}
function tokenizeWithTheme(theme, colorMap, fileContents, grammar, options) {
let lines = fileContents.split(/\r\n|\r|\n/);
let ruleStack = mainExports.INITIAL;
let actual = [];
let final = [];
for (let i2 = 0, len = lines.length; i2 < len; i2++) {
let line = lines[i2];
if (line === "") {
actual = [];
final.push([]);
continue;
}
let resultWithScopes;
let tokensWithScopes;
let tokensWithScopesIndex;
if (options.includeExplanation) {
resultWithScopes = grammar.tokenizeLine(line, ruleStack);
tokensWithScopes = resultWithScopes.tokens;
tokensWithScopesIndex = 0;
}
let result = grammar.tokenizeLine2(line, ruleStack);
let tokensLength = result.tokens.length / 2;
for (let j2 = 0; j2 < tokensLength; j2++) {
let startIndex = result.tokens[2 * j2];
let nextStartIndex = j2 + 1 < tokensLength ? result.tokens[2 * j2 + 2] : line.length;
if (startIndex === nextStartIndex) {
continue;
}
let metadata = result.tokens[2 * j2 + 1];
let foreground = StackElementMetadata.getForeground(metadata);
let foregroundColor = colorMap[foreground];
let fontStyle = StackElementMetadata.getFontStyle(metadata);
let explanation = [];
if (options.includeExplanation) {
let offset2 = 0;
while (startIndex + offset2 < nextStartIndex) {
let tokenWithScopes = tokensWithScopes[tokensWithScopesIndex];
let tokenWithScopesText = line.substring(
tokenWithScopes.startIndex,
tokenWithScopes.endIndex
);
offset2 += tokenWithScopesText.length;
explanation.push({
content: tokenWithScopesText,
scopes: explainThemeScopes(theme, tokenWithScopes.scopes)
});
tokensWithScopesIndex++;
}
}
actual.push({
content: line.substring(startIndex, nextStartIndex),
color: foregroundColor,
fontStyle,
explanation
});
}
final.push(actual);
actual = [];
ruleStack = result.ruleStack;
}
return final;
}
function explainThemeScopes(theme, scopes) {
let result = [];
for (let i2 = 0, len = scopes.length; i2 < len; i2++) {
let parentScopes = scopes.slice(0, i2);
let scope = scopes[i2];
result[i2] = {
scopeName: scope,
themeMatches: explainThemeScope(theme, scope, parentScopes)
};
}
return result;
}
function matchesOne(selector, scope) {
let selectorPrefix = selector + ".";
if (selector === scope || scope.substring(0, selectorPrefix.length) === selectorPrefix) {
return true;
}
return false;
}
function matches(selector, selectorParentScopes, scope, parentScopes) {
if (!matchesOne(selector, scope)) {
return false;
}
let selectorParentIndex = selectorParentScopes.length - 1;
let parentIndex = parentScopes.length - 1;
while (selectorParentIndex >= 0 && parentIndex >= 0) {
if (matchesOne(selectorParentScopes[selectorParentIndex], parentScopes[parentIndex])) {
selectorParentIndex--;
}
parentIndex--;
}
if (selectorParentIndex === -1) {
return true;
}
return false;
}
function explainThemeScope(theme, scope, parentScopes) {
let result = [], resultLen = 0;
for (let i2 = 0, len = theme.settings.length; i2 < len; i2++) {
let setting = theme.settings[i2];
let selectors;
if (typeof setting.scope === "string") {
selectors = setting.scope.split(/,/).map((scope2) => scope2.trim());
} else if (Array.isArray(setting.scope)) {
selectors = setting.scope;
} else {
continue;
}
for (let j2 = 0, lenJ = selectors.length; j2 < lenJ; j2++) {
let rawSelector = selectors[j2];
let rawSelectorPieces = rawSelector.split(/ /);
let selector = rawSelectorPieces[rawSelectorPieces.length - 1];
let selectorParentScopes = rawSelectorPieces.slice(0, rawSelectorPieces.length - 1);
if (matches(selector, selectorParentScopes, scope, parentScopes)) {
result[resultLen++] = setting;
j2 = lenJ;
}
}
}
return result;
}
const defaultElements = {
pre({ className, style, children: children2 }) {
return `<pre class="${className}" style="${style}">${children2}</pre>`;
},
code({ children: children2 }) {
return `<code>${children2}</code>`;
},
line({ className, children: children2 }) {
return `<span class="${className}">${children2}</span>`;
},
token({ style, children: children2 }) {
return `<span style="${style}">${children2}</span>`;
}
};
function renderToHtml(lines, options = {}) {
const bg2 = options.bg || "#fff";
const optionsByLineNumber = groupBy(options.lineOptions ?? [], (option) => option.line);
const userElements = options.elements || {};
function h2(type = "", props = {}, children2) {
const element2 = userElements[type] || defaultElements[type];
if (element2) {
children2 = children2.filter(Boolean);
return element2({
...props,
children: type === "code" ? children2.join("\n") : children2.join("")
});
}
return "";
}
return h2(
"pre",
{ className: "shiki " + (options.themeName || ""), style: `background-color: ${bg2}` },
[
options.langId ? `<div class="language-id">${options.langId}</div>` : "",
h2(
"code",
{},
lines.map((line, index2) => {
const lineNumber = index2 + 1;
const lineOptions = optionsByLineNumber.get(lineNumber) ?? [];
const lineClasses = getLineClasses(lineOptions).join(" ");
return h2(
"line",
{
className: lineClasses,
lines,
line,
index: index2
},
line.map((token, index22) => {
const cssDeclarations = [`color: ${token.color || options.fg}`];
if (token.fontStyle & FontStyle.Italic) {
cssDeclarations.push("font-style: italic");
}
if (token.fontStyle & FontStyle.Bold) {
cssDeclarations.push("font-weight: bold");
}
if (token.fontStyle & FontStyle.Underline) {
cssDeclarations.push("text-decoration: underline");
}
return h2(
"token",
{
style: cssDeclarations.join("; "),
tokens: line,
token,
index: index22
},
[escapeHtml(token.content)]
);
})
);
})
)
]
);
}
const htmlEscapes = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#39;"
};
function escapeHtml(html) {
return html.replace(/[&<>"']/g, (chr) => htmlEscapes[chr]);
}
function getLineClasses(lineOptions) {
const lineClasses = /* @__PURE__ */ new Set(["line"]);
for (const lineOption of lineOptions) {
for (const lineClass of lineOption.classes ?? []) {
lineClasses.add(lineClass);
}
}
return Array.from(lineClasses);
}
class Registry extends mainExports.Registry {
constructor(_resolver) {
super(_resolver);
this._resolver = _resolver;
this.themesPath = "themes/";
this._resolvedThemes = {};
this._resolvedGrammars = {};
this._langGraph = /* @__PURE__ */ new Map();
this._langMap = languages.reduce((acc, lang) => {
acc[lang.id] = lang;
return acc;
}, {});
}
getTheme(theme) {
if (typeof theme === "string") {
return this._resolvedThemes[theme];
} else {
return theme;
}
}
async loadTheme(theme) {
if (typeof theme === "string") {
if (!this._resolvedThemes[theme]) {
this._resolvedThemes[theme] = await fetchTheme(`${this.themesPath}${theme}.json`);
}
return this._resolvedThemes[theme];
} else {
theme = toShikiTheme(theme);
if (theme.name) {
this._resolvedThemes[theme.name] = theme;
}
return theme;
}
}
async loadThemes(themes) {
return await Promise.all(themes.map((theme) => this.loadTheme(theme)));
}
getLoadedThemes() {
return Object.keys(this._resolvedThemes);
}
getGrammar(name) {
return this._resolvedGrammars[name];
}
async loadLanguage(lang) {
var _a3;
const embeddedLanguages = (_a3 = lang.embeddedLangs) == null ? void 0 : _a3.reduce(async (acc, l, idx) => {
if (!this.getLoadedLanguages().includes(l) && this._resolver.getLangRegistration(l)) {
await this._resolver.loadGrammar(this._resolver.getLangRegistration(l).scopeName);
acc[this._resolver.getLangRegistration(l).scopeName] = idx + 2;
return acc;
}
}, {});
const grammarConfig = {
embeddedLanguages,
balancedBracketSelectors: lang.balancedBracketSelectors || ["*"],
unbalancedBracketSelectors: lang.unbalancedBracketSelectors || []
};
const g = await this.loadGrammarWithConfiguration(lang.scopeName, 1, grammarConfig);
this._resolvedGrammars[lang.id] = g;
if (lang.aliases) {
lang.aliases.forEach((la2) => {
this._resolvedGrammars[la2] = g;
});
}
}
async loadLanguages(langs) {
for (const lang of langs) {
this.resolveEmbeddedLanguages(lang);
}
const langsGraphArray = Array.from(this._langGraph.values());
for (const lang of langsGraphArray) {
this._resolver.addLanguage(lang);
}
for (const lang of langsGraphArray) {
await this.loadLanguage(lang);
}
}
getLoadedLanguages() {
return Object.keys(this._resolvedGrammars);
}
resolveEmbeddedLanguages(lang) {
if (!this._langGraph.has(lang.id)) {
this._langGraph.set(lang.id, lang);
}
if (lang.embeddedLangs) {
for (const embeddedLang of lang.embeddedLangs) {
this._langGraph.set(embeddedLang, this._langMap[embeddedLang]);
}
}
}
}
function resolveLang(lang) {
return typeof lang === "string" ? languages.find((l) => {
var _a3;
return l.id === lang || ((_a3 = l.aliases) == null ? void 0 : _a3.includes(lang));
}) : lang;
}
function resolveOptions(options) {
var _a3;
let _languages = languages;
let _themes = options.themes || [];
let _wasmPath = ((_a3 = options.paths) == null ? void 0 : _a3.wasm) ? options.paths.wasm.endsWith("/") ? options.paths.wasm : options.paths.wasm + "/" : WASM_PATH;
if (options.langs) {
_languages = options.langs.map(resolveLang);
}
if (options.theme) {
_themes.unshift(options.theme);
}
if (!_themes.length) {
_themes = ["nord"];
}
return { _languages, _themes, _wasmPath };
}
async function getHighlighter(options) {
var _a3, _b2;
const { _languages, _themes, _wasmPath } = resolveOptions(options);
const _resolver = new Resolver(getOniguruma(_wasmPath), "vscode-oniguruma");
const _registry = new Registry(_resolver);
if ((_a3 = options.paths) == null ? void 0 : _a3.themes) {
_registry.themesPath = options.paths.themes.endsWith("/") ? options.paths.themes : options.paths.themes + "/";
}
if ((_b2 = options.paths) == null ? void 0 : _b2.languages) {
_resolver.languagesPath = options.paths.languages.endsWith("/") ? options.paths.languages : options.paths.languages + "/";
}
const themes = await _registry.loadThemes(_themes);
const _defaultTheme = themes[0];
let _currentTheme;
await _registry.loadLanguages(_languages);
let COLOR_REPLACEMENTS = {
"#000001": "var(--shiki-color-text)",
"#000002": "var(--shiki-color-background)",
"#000004": "var(--shiki-token-constant)",
"#000005": "var(--shiki-token-string)",
"#000006": "var(--shiki-token-comment)",
"#000007": "var(--shiki-token-keyword)",
"#000008": "var(--shiki-token-parameter)",
"#000009": "var(--shiki-token-function)",
"#000010": "var(--shiki-token-string-expression)",
"#000011": "var(--shiki-token-punctuation)",
"#000012": "var(--shiki-token-link)"
};
function setColorReplacements(map2) {
COLOR_REPLACEMENTS = map2;
}
function fixCssVariablesTheme(theme, colorMap) {
theme.bg = COLOR_REPLACEMENTS[theme.bg] || theme.bg;
theme.fg = COLOR_REPLACEMENTS[theme.fg] || theme.fg;
colorMap.forEach((val, i2) => {
colorMap[i2] = COLOR_REPLACEMENTS[val] || val;
});
}
function getTheme(theme) {
const _theme = theme ? _registry.getTheme(theme) : _defaultTheme;
if (!_theme) {
throw Error(`No theme registration for ${theme}`);
}
if (!_currentTheme || _currentTheme.name !== _theme.name) {
_registry.setTheme(_theme);
_currentTheme = _theme;
}
const _colorMap = _registry.getColorMap();
if (_theme.type === "css") {
fixCssVariablesTheme(_theme, _colorMap);
}
return { _theme, _colorMap };
}
function getGrammar(lang) {
const _grammar = _registry.getGrammar(lang);
if (!_grammar) {
throw Error(`No language registration for ${lang}`);
}
return { _grammar };
}
function codeToThemedTokens(code, lang = "text", theme, options2 = { includeExplanation: true }) {
if (isPlaintext(lang)) {
const lines = code.split(/\r\n|\r|\n/);
return [...lines.map((line) => [{ content: line }])];
}
const { _grammar } = getGrammar(lang);
const { _theme, _colorMap } = getTheme(theme);
return tokenizeWithTheme(_theme, _colorMap, code, _grammar, options2);
}
function codeToHtml(code, arg1 = "text", arg2) {
let options2;
if (typeof arg1 === "object") {
options2 = arg1;
} else {
options2 = {
lang: arg1,
theme: arg2
};
}
const tokens = codeToThemedTokens(code, options2.lang, options2.theme, {
includeExplanation: false
});
const { _theme } = getTheme(options2.theme);
return renderToHtml(tokens, {
fg: _theme.fg,
bg: _theme.bg,
lineOptions: options2 == null ? void 0 : options2.lineOptions,
themeName: _theme.name
});
}
async function loadTheme(theme) {
await _registry.loadTheme(theme);
}
async function loadLanguage(lang) {
const _lang = resolveLang(lang);
_resolver.addLanguage(_lang);
await _registry.loadLanguage(_lang);
}
function getLoadedThemes() {
return _registry.getLoadedThemes();
}
function getLoadedLanguages() {
return _registry.getLoadedLanguages();
}
function getBackgroundColor(theme) {
const { _theme } = getTheme(theme);
return _theme.bg;
}
function getForegroundColor(theme) {
const { _theme } = getTheme(theme);
return _theme.fg;
}
return {
codeToThemedTokens,
codeToHtml,
getTheme: (theme) => {
return getTheme(theme)._theme;
},
loadTheme,
loadLanguage,
getBackgroundColor,
getForegroundColor,
getLoadedThemes,
getLoadedLanguages,
setColorReplacements
};
}
function isPlaintext(lang) {
return !lang || ["plaintext", "txt", "text"].includes(lang);
}
const version = "0.2.0";
setCDN(`https://cdn.jsdelivr.net/npm/shiki-es@${version}/dist/assets/`);
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
var flexsearch_bundleExports = {};
var flexsearch_bundle = {
get exports() {
return flexsearch_bundleExports;
},
set exports(v2) {
flexsearch_bundleExports = v2;
}
};
(function(module) {
(function _f(self) {
try {
if (module)
self = module;
} catch (e2) {
}
self._factory = _f;
var t;
function u(a2) {
return "undefined" !== typeof a2 ? a2 : true;
}
function aa(a2) {
const b3 = Array(a2);
for (let c2 = 0; c2 < a2; c2++)
b3[c2] = v();
return b3;
}
function v() {
return /* @__PURE__ */ Object.create(null);
}
function ba(a2, b3) {
return b3.length - a2.length;
}
function x(a2) {
return "string" === typeof a2;
}
function C(a2) {
return "object" === typeof a2;
}
function D(a2) {
return "function" === typeof a2;
}
function ca(a2, b3) {
var c2 = da;
if (a2 && (b3 && (a2 = E(a2, b3)), this.H && (a2 = E(a2, this.H)), this.J && 1 < a2.length && (a2 = E(a2, this.J)), c2 || "" === c2)) {
a2 = a2.split(c2);
if (this.filter) {
b3 = this.filter;
c2 = a2.length;
const d2 = [];
for (let e2 = 0, f2 = 0; e2 < c2; e2++) {
const g = a2[e2];
g && !b3[g] && (d2[f2++] = g);
}
a2 = d2;
}
return a2;
}
return a2;
}
const da = /[\p{Z}\p{S}\p{P}\p{C}]+/u, ea = /[\u0300-\u036f]/g;
function fa(a2, b3) {
const c2 = Object.keys(a2), d2 = c2.length, e2 = [];
let f2 = "", g = 0;
for (let h2 = 0, k2, m2; h2 < d2; h2++)
k2 = c2[h2], (m2 = a2[k2]) ? (e2[g++] = F(b3 ? "(?!\\b)" + k2 + "(\\b|_)" : k2), e2[g++] = m2) : f2 += (f2 ? "|" : "") + k2;
f2 && (e2[g++] = F(b3 ? "(?!\\b)(" + f2 + ")(\\b|_)" : "(" + f2 + ")"), e2[g] = "");
return e2;
}
function E(a2, b3) {
for (let c2 = 0, d2 = b3.length; c2 < d2 && (a2 = a2.replace(b3[c2], b3[c2 + 1]), a2); c2 += 2)
;
return a2;
}
function F(a2) {
return new RegExp(a2, "g");
}
function ha(a2) {
let b3 = "", c2 = "";
for (let d2 = 0, e2 = a2.length, f2; d2 < e2; d2++)
(f2 = a2[d2]) !== c2 && (b3 += c2 = f2);
return b3;
}
var ja = { encode: ia, F: false, G: "" };
function ia(a2) {
return ca.call(this, ("" + a2).toLowerCase(), false);
}
const ka = {}, G = {};
function la(a2) {
I(a2, "add");
I(a2, "append");
I(a2, "search");
I(a2, "update");
I(a2, "remove");
}
function I(a2, b3) {
a2[b3 + "Async"] = function() {
const c2 = this, d2 = arguments;
var e2 = d2[d2.length - 1];
let f2;
D(e2) && (f2 = e2, delete d2[d2.length - 1]);
e2 = new Promise(function(g) {
setTimeout(function() {
c2.async = true;
const h2 = c2[b3].apply(c2, d2);
c2.async = false;
g(h2);
});
});
return f2 ? (e2.then(f2), this) : e2;
};
}
function ma(a2, b3, c2, d2) {
const e2 = a2.length;
let f2 = [], g, h2, k2 = 0;
d2 && (d2 = []);
for (let m2 = e2 - 1; 0 <= m2; m2--) {
const n2 = a2[m2], w2 = n2.length, q2 = v();
let r2 = !g;
for (let l = 0; l < w2; l++) {
const p2 = n2[l], z2 = p2.length;
if (z2)
for (let B3 = 0, A3, y2; B3 < z2; B3++)
if (y2 = p2[B3], g) {
if (g[y2]) {
if (!m2) {
if (c2)
c2--;
else if (f2[k2++] = y2, k2 === b3)
return f2;
}
if (m2 || d2)
q2[y2] = 1;
r2 = true;
}
if (d2 && (h2[y2] = (A3 = h2[y2]) ? ++A3 : A3 = 1, A3 < e2)) {
const H2 = d2[A3 - 2] || (d2[A3 - 2] = []);
H2[H2.length] = y2;
}
} else
q2[y2] = 1;
}
if (d2)
g || (h2 = q2);
else if (!r2)
return [];
g = q2;
}
if (d2)
for (let m2 = d2.length - 1, n2, w2; 0 <= m2; m2--) {
n2 = d2[m2];
w2 = n2.length;
for (let q2 = 0, r2; q2 < w2; q2++)
if (r2 = n2[q2], !g[r2]) {
if (c2)
c2--;
else if (f2[k2++] = r2, k2 === b3)
return f2;
g[r2] = 1;
}
}
return f2;
}
function na(a2, b3) {
const c2 = v(), d2 = v(), e2 = [];
for (let f2 = 0; f2 < a2.length; f2++)
c2[a2[f2]] = 1;
for (let f2 = 0, g; f2 < b3.length; f2++) {
g = b3[f2];
for (let h2 = 0, k2; h2 < g.length; h2++)
k2 = g[h2], c2[k2] && !d2[k2] && (d2[k2] = 1, e2[e2.length] = k2);
}
return e2;
}
function J(a2) {
this.l = true !== a2 && a2;
this.cache = v();
this.h = [];
}
function oa(a2, b3, c2) {
C(a2) && (a2 = a2.query);
let d2 = this.cache.get(a2);
d2 || (d2 = this.search(a2, b3, c2), this.cache.set(a2, d2));
return d2;
}
J.prototype.set = function(a2, b3) {
if (!this.cache[a2]) {
var c2 = this.h.length;
c2 === this.l ? delete this.cache[this.h[c2 - 1]] : c2++;
for (--c2; 0 < c2; c2--)
this.h[c2] = this.h[c2 - 1];
this.h[0] = a2;
}
this.cache[a2] = b3;
};
J.prototype.get = function(a2) {
const b3 = this.cache[a2];
if (this.l && b3 && (a2 = this.h.indexOf(a2))) {
const c2 = this.h[a2 - 1];
this.h[a2 - 1] = this.h[a2];
this.h[a2] = c2;
}
return b3;
};
const qa = { memory: { charset: "latin:extra", D: 3, B: 4, m: false }, performance: { D: 3, B: 3, s: false, context: { depth: 2, D: 1 } }, match: { charset: "latin:extra", G: "reverse" }, score: { charset: "latin:advanced", D: 20, B: 3, context: { depth: 3, D: 9 } }, "default": {} };
function ra(a2, b3, c2, d2, e2, f2) {
setTimeout(function() {
const g = a2(c2, JSON.stringify(f2));
g && g.then ? g.then(function() {
b3.export(a2, b3, c2, d2, e2 + 1);
}) : b3.export(a2, b3, c2, d2, e2 + 1);
});
}
function K(a2, b3) {
if (!(this instanceof K))
return new K(a2);
var c2;
if (a2) {
x(a2) ? a2 = qa[a2] : (c2 = a2.preset) && (a2 = Object.assign({}, c2[c2], a2));
c2 = a2.charset;
var d2 = a2.lang;
x(c2) && (-1 === c2.indexOf(":") && (c2 += ":default"), c2 = G[c2]);
x(d2) && (d2 = ka[d2]);
} else
a2 = {};
let e2, f2, g = a2.context || {};
this.encode = a2.encode || c2 && c2.encode || ia;
this.register = b3 || v();
this.D = e2 = a2.resolution || 9;
this.G = b3 = c2 && c2.G || a2.tokenize || "strict";
this.depth = "strict" === b3 && g.depth;
this.l = u(g.bidirectional);
this.s = f2 = u(a2.optimize);
this.m = u(a2.fastupdate);
this.B = a2.minlength || 1;
this.C = a2.boost;
this.map = f2 ? aa(e2) : v();
this.A = e2 = g.resolution || 1;
this.h = f2 ? aa(e2) : v();
this.F = c2 && c2.F || a2.rtl;
this.H = (b3 = a2.matcher || d2 && d2.H) && fa(b3, false);
this.J = (b3 = a2.stemmer || d2 && d2.J) && fa(b3, true);
if (c2 = b3 = a2.filter || d2 && d2.filter) {
c2 = b3;
d2 = v();
for (let h2 = 0, k2 = c2.length; h2 < k2; h2++)
d2[c2[h2]] = 1;
c2 = d2;
}
this.filter = c2;
this.cache = (b3 = a2.cache) && new J(b3);
}
t = K.prototype;
t.append = function(a2, b3) {
return this.add(a2, b3, true);
};
t.add = function(a2, b3, c2, d2) {
if (b3 && (a2 || 0 === a2)) {
if (!d2 && !c2 && this.register[a2])
return this.update(a2, b3);
b3 = this.encode(b3);
if (d2 = b3.length) {
const m2 = v(), n2 = v(), w2 = this.depth, q2 = this.D;
for (let r2 = 0; r2 < d2; r2++) {
let l = b3[this.F ? d2 - 1 - r2 : r2];
var e2 = l.length;
if (l && e2 >= this.B && (w2 || !n2[l])) {
var f2 = L(q2, d2, r2), g = "";
switch (this.G) {
case "full":
if (3 < e2) {
for (f2 = 0; f2 < e2; f2++)
for (var h2 = e2; h2 > f2; h2--)
if (h2 - f2 >= this.B) {
var k2 = L(q2, d2, r2, e2, f2);
g = l.substring(f2, h2);
M(this, n2, g, k2, a2, c2);
}
break;
}
case "reverse":
if (2 < e2) {
for (h2 = e2 - 1; 0 < h2; h2--)
g = l[h2] + g, g.length >= this.B && M(
this,
n2,
g,
L(q2, d2, r2, e2, h2),
a2,
c2
);
g = "";
}
case "forward":
if (1 < e2) {
for (h2 = 0; h2 < e2; h2++)
g += l[h2], g.length >= this.B && M(this, n2, g, f2, a2, c2);
break;
}
default:
if (this.C && (f2 = Math.min(f2 / this.C(b3, l, r2) | 0, q2 - 1)), M(this, n2, l, f2, a2, c2), w2 && 1 < d2 && r2 < d2 - 1) {
for (e2 = v(), g = this.A, f2 = l, h2 = Math.min(w2 + 1, d2 - r2), e2[f2] = 1, k2 = 1; k2 < h2; k2++)
if ((l = b3[this.F ? d2 - 1 - r2 - k2 : r2 + k2]) && l.length >= this.B && !e2[l]) {
e2[l] = 1;
const p2 = this.l && l > f2;
M(this, m2, p2 ? f2 : l, L(g + (d2 / 2 > g ? 0 : 1), d2, r2, h2 - 1, k2 - 1), a2, c2, p2 ? l : f2);
}
}
}
}
}
this.m || (this.register[a2] = 1);
}
}
return this;
};
function L(a2, b3, c2, d2, e2) {
return c2 && 1 < a2 ? b3 + (d2 || 0) <= a2 ? c2 + (e2 || 0) : (a2 - 1) / (b3 + (d2 || 0)) * (c2 + (e2 || 0)) + 1 | 0 : 0;
}
function M(a2, b3, c2, d2, e2, f2, g) {
let h2 = g ? a2.h : a2.map;
if (!b3[c2] || g && !b3[c2][g])
a2.s && (h2 = h2[d2]), g ? (b3 = b3[c2] || (b3[c2] = v()), b3[g] = 1, h2 = h2[g] || (h2[g] = v())) : b3[c2] = 1, h2 = h2[c2] || (h2[c2] = []), a2.s || (h2 = h2[d2] || (h2[d2] = [])), f2 && -1 !== h2.indexOf(e2) || (h2[h2.length] = e2, a2.m && (a2 = a2.register[e2] || (a2.register[e2] = []), a2[a2.length] = h2));
}
t.search = function(a2, b3, c2) {
c2 || (!b3 && C(a2) ? (c2 = a2, a2 = c2.query) : C(b3) && (c2 = b3));
let d2 = [], e2;
let f2, g = 0;
if (c2) {
b3 = c2.limit;
g = c2.offset || 0;
var h2 = c2.context;
f2 = c2.suggest;
}
if (a2 && (a2 = this.encode(a2), e2 = a2.length, 1 < e2)) {
c2 = v();
var k2 = [];
for (let n2 = 0, w2 = 0, q2; n2 < e2; n2++)
if ((q2 = a2[n2]) && q2.length >= this.B && !c2[q2])
if (this.s || f2 || this.map[q2])
k2[w2++] = q2, c2[q2] = 1;
else
return d2;
a2 = k2;
e2 = a2.length;
}
if (!e2)
return d2;
b3 || (b3 = 100);
h2 = this.depth && 1 < e2 && false !== h2;
c2 = 0;
let m2;
h2 ? (m2 = a2[0], c2 = 1) : 1 < e2 && a2.sort(ba);
for (let n2, w2; c2 < e2; c2++) {
w2 = a2[c2];
h2 ? (n2 = sa(this, d2, f2, b3, g, 2 === e2, w2, m2), f2 && false === n2 && d2.length || (m2 = w2)) : n2 = sa(this, d2, f2, b3, g, 1 === e2, w2);
if (n2)
return n2;
if (f2 && c2 === e2 - 1) {
k2 = d2.length;
if (!k2) {
if (h2) {
h2 = 0;
c2 = -1;
continue;
}
return d2;
}
if (1 === k2)
return ta(d2[0], b3, g);
}
}
return ma(d2, b3, g, f2);
};
function sa(a2, b3, c2, d2, e2, f2, g, h2) {
let k2 = [], m2 = h2 ? a2.h : a2.map;
a2.s || (m2 = ua(m2, g, h2, a2.l));
if (m2) {
let n2 = 0;
const w2 = Math.min(m2.length, h2 ? a2.A : a2.D);
for (let q2 = 0, r2 = 0, l, p2; q2 < w2; q2++)
if (l = m2[q2]) {
if (a2.s && (l = ua(l, g, h2, a2.l)), e2 && l && f2 && (p2 = l.length, p2 <= e2 ? (e2 -= p2, l = null) : (l = l.slice(e2), e2 = 0)), l && (k2[n2++] = l, f2 && (r2 += l.length, r2 >= d2)))
break;
}
if (n2) {
if (f2)
return ta(k2, d2, 0);
b3[b3.length] = k2;
return;
}
}
return !c2 && k2;
}
function ta(a2, b3, c2) {
a2 = 1 === a2.length ? a2[0] : [].concat.apply([], a2);
return c2 || a2.length > b3 ? a2.slice(c2, c2 + b3) : a2;
}
function ua(a2, b3, c2, d2) {
c2 ? (d2 = d2 && b3 > c2, a2 = (a2 = a2[d2 ? b3 : c2]) && a2[d2 ? c2 : b3]) : a2 = a2[b3];
return a2;
}
t.contain = function(a2) {
return !!this.register[a2];
};
t.update = function(a2, b3) {
return this.remove(a2).add(a2, b3);
};
t.remove = function(a2, b3) {
const c2 = this.register[a2];
if (c2) {
if (this.m)
for (let d2 = 0, e2; d2 < c2.length; d2++)
e2 = c2[d2], e2.splice(e2.indexOf(a2), 1);
else
N(this.map, a2, this.D, this.s), this.depth && N(this.h, a2, this.A, this.s);
b3 || delete this.register[a2];
if (this.cache) {
b3 = this.cache;
for (let d2 = 0, e2, f2; d2 < b3.h.length; d2++)
f2 = b3.h[d2], e2 = b3.cache[f2], -1 !== e2.indexOf(a2) && (b3.h.splice(d2--, 1), delete b3.cache[f2]);
}
}
return this;
};
function N(a2, b3, c2, d2, e2) {
let f2 = 0;
if (a2.constructor === Array)
if (e2)
b3 = a2.indexOf(b3), -1 !== b3 ? 1 < a2.length && (a2.splice(b3, 1), f2++) : f2++;
else {
e2 = Math.min(a2.length, c2);
for (let g = 0, h2; g < e2; g++)
if (h2 = a2[g])
f2 = N(h2, b3, c2, d2, e2), d2 || f2 || delete a2[g];
}
else
for (let g in a2)
(f2 = N(a2[g], b3, c2, d2, e2)) || delete a2[g];
return f2;
}
t.searchCache = oa;
t.export = function(a2, b3, c2, d2, e2) {
let f2, g;
switch (e2 || (e2 = 0)) {
case 0:
f2 = "reg";
if (this.m) {
g = v();
for (let h2 in this.register)
g[h2] = 1;
} else
g = this.register;
break;
case 1:
f2 = "cfg";
g = { doc: 0, opt: this.s ? 1 : 0 };
break;
case 2:
f2 = "map";
g = this.map;
break;
case 3:
f2 = "ctx";
g = this.h;
break;
default:
return;
}
ra(a2, b3 || this, c2 ? c2 + "." + f2 : f2, d2, e2, g);
return true;
};
t.import = function(a2, b3) {
if (b3)
switch (x(b3) && (b3 = JSON.parse(b3)), a2) {
case "cfg":
this.s = !!b3.opt;
break;
case "reg":
this.m = false;
this.register = b3;
break;
case "map":
this.map = b3;
break;
case "ctx":
this.h = b3;
}
};
la(K.prototype);
function va(a2) {
a2 = a2.data;
var b3 = self._index;
const c2 = a2.args;
var d2 = a2.task;
switch (d2) {
case "init":
d2 = a2.options || {};
a2 = a2.factory;
b3 = d2.encode;
d2.cache = false;
b3 && 0 === b3.indexOf("function") && (d2.encode = Function("return " + b3)());
a2 ? (Function("return " + a2)()(self), self._index = new self.FlexSearch.Index(d2), delete self.FlexSearch) : self._index = new K(d2);
break;
default:
a2 = a2.id, b3 = b3[d2].apply(b3, c2), postMessage("search" === d2 ? { id: a2, msg: b3 } : { id: a2 });
}
}
let wa = 0;
function O(a2) {
if (!(this instanceof O))
return new O(a2);
var b3;
a2 ? D(b3 = a2.encode) && (a2.encode = b3.toString()) : a2 = {};
(b3 = (self || window)._factory) && (b3 = b3.toString());
const c2 = self.exports, d2 = this;
this.o = xa(b3, c2, a2.worker);
this.h = v();
if (this.o) {
if (c2)
this.o.on("message", function(e2) {
d2.h[e2.id](e2.msg);
delete d2.h[e2.id];
});
else
this.o.onmessage = function(e2) {
e2 = e2.data;
d2.h[e2.id](e2.msg);
delete d2.h[e2.id];
};
this.o.postMessage({ task: "init", factory: b3, options: a2 });
}
}
P("add");
P("append");
P("search");
P("update");
P("remove");
function P(a2) {
O.prototype[a2] = O.prototype[a2 + "Async"] = function() {
const b3 = this, c2 = [].slice.call(arguments);
var d2 = c2[c2.length - 1];
let e2;
D(d2) && (e2 = d2, c2.splice(c2.length - 1, 1));
d2 = new Promise(function(f2) {
setTimeout(function() {
b3.h[++wa] = f2;
b3.o.postMessage({ task: a2, id: wa, args: c2 });
});
});
return e2 ? (d2.then(e2), this) : d2;
};
}
function xa(a, b, c) {
let d;
try {
d = b ? eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")') : a ? new Worker(URL.createObjectURL(new Blob(["onmessage=" + va.toString()], { type: "text/javascript" }))) : new Worker(x(c) ? c : "worker/worker.js", { type: "module" });
} catch (e2) {
}
return d;
}
function Q(a2) {
if (!(this instanceof Q))
return new Q(a2);
var b3 = a2.document || a2.doc || a2, c2;
this.K = [];
this.h = [];
this.A = [];
this.register = v();
this.key = (c2 = b3.key || b3.id) && S(c2, this.A) || "id";
this.m = u(a2.fastupdate);
this.C = (c2 = b3.store) && true !== c2 && [];
this.store = c2 && v();
this.I = (c2 = b3.tag) && S(c2, this.A);
this.l = c2 && v();
this.cache = (c2 = a2.cache) && new J(c2);
a2.cache = false;
this.o = a2.worker;
this.async = false;
c2 = v();
let d2 = b3.index || b3.field || b3;
x(d2) && (d2 = [d2]);
for (let e2 = 0, f2, g; e2 < d2.length; e2++)
f2 = d2[e2], x(f2) || (g = f2, f2 = f2.field), g = C(g) ? Object.assign({}, a2, g) : a2, this.o && (c2[f2] = new O(g), c2[f2].o || (this.o = false)), this.o || (c2[f2] = new K(g, this.register)), this.K[e2] = S(f2, this.A), this.h[e2] = f2;
if (this.C)
for (a2 = b3.store, x(a2) && (a2 = [a2]), b3 = 0; b3 < a2.length; b3++)
this.C[b3] = S(a2[b3], this.A);
this.index = c2;
}
function S(a2, b3) {
const c2 = a2.split(":");
let d2 = 0;
for (let e2 = 0; e2 < c2.length; e2++)
a2 = c2[e2], 0 <= a2.indexOf("[]") && (a2 = a2.substring(0, a2.length - 2)) && (b3[d2] = true), a2 && (c2[d2++] = a2);
d2 < c2.length && (c2.length = d2);
return 1 < d2 ? c2 : c2[0];
}
function T(a2, b3) {
if (x(b3))
a2 = a2[b3];
else
for (let c2 = 0; a2 && c2 < b3.length; c2++)
a2 = a2[b3[c2]];
return a2;
}
function U(a2, b3, c2, d2, e2) {
a2 = a2[e2];
if (d2 === c2.length - 1)
b3[e2] = a2;
else if (a2)
if (a2.constructor === Array)
for (b3 = b3[e2] = Array(a2.length), e2 = 0; e2 < a2.length; e2++)
U(a2, b3, c2, d2, e2);
else
b3 = b3[e2] || (b3[e2] = v()), e2 = c2[++d2], U(a2, b3, c2, d2, e2);
}
function V(a2, b3, c2, d2, e2, f2, g, h2) {
if (a2 = a2[g])
if (d2 === b3.length - 1) {
if (a2.constructor === Array) {
if (c2[d2]) {
for (b3 = 0; b3 < a2.length; b3++)
e2.add(f2, a2[b3], true, true);
return;
}
a2 = a2.join(" ");
}
e2.add(f2, a2, h2, true);
} else if (a2.constructor === Array)
for (g = 0; g < a2.length; g++)
V(a2, b3, c2, d2, e2, f2, g, h2);
else
g = b3[++d2], V(a2, b3, c2, d2, e2, f2, g, h2);
}
t = Q.prototype;
t.add = function(a2, b3, c2) {
C(a2) && (b3 = a2, a2 = T(b3, this.key));
if (b3 && (a2 || 0 === a2)) {
if (!c2 && this.register[a2])
return this.update(a2, b3);
for (let d2 = 0, e2, f2; d2 < this.h.length; d2++)
f2 = this.h[d2], e2 = this.K[d2], x(e2) && (e2 = [e2]), V(b3, e2, this.A, 0, this.index[f2], a2, e2[0], c2);
if (this.I) {
let d2 = T(b3, this.I), e2 = v();
x(d2) && (d2 = [d2]);
for (let f2 = 0, g, h2; f2 < d2.length; f2++)
if (g = d2[f2], !e2[g] && (e2[g] = 1, h2 = this.l[g] || (this.l[g] = []), !c2 || -1 === h2.indexOf(a2))) {
if (h2[h2.length] = a2, this.m) {
const k2 = this.register[a2] || (this.register[a2] = []);
k2[k2.length] = h2;
}
}
}
if (this.store && (!c2 || !this.store[a2])) {
let d2;
if (this.C) {
d2 = v();
for (let e2 = 0, f2; e2 < this.C.length; e2++)
f2 = this.C[e2], x(f2) ? d2[f2] = b3[f2] : U(b3, d2, f2, 0, f2[0]);
}
this.store[a2] = d2 || b3;
}
}
return this;
};
t.append = function(a2, b3) {
return this.add(a2, b3, true);
};
t.update = function(a2, b3) {
return this.remove(a2).add(a2, b3);
};
t.remove = function(a2) {
C(a2) && (a2 = T(a2, this.key));
if (this.register[a2]) {
for (var b3 = 0; b3 < this.h.length && (this.index[this.h[b3]].remove(a2, !this.o), !this.m); b3++)
;
if (this.I && !this.m)
for (let c2 in this.l) {
b3 = this.l[c2];
const d2 = b3.indexOf(a2);
-1 !== d2 && (1 < b3.length ? b3.splice(d2, 1) : delete this.l[c2]);
}
this.store && delete this.store[a2];
delete this.register[a2];
}
return this;
};
t.search = function(a2, b3, c2, d2) {
c2 || (!b3 && C(a2) ? (c2 = a2, a2 = c2.query) : C(b3) && (c2 = b3, b3 = 0));
let e2 = [], f2 = [], g, h2, k2, m2, n2, w2, q2 = 0;
if (c2)
if (c2.constructor === Array)
k2 = c2, c2 = null;
else {
k2 = (g = c2.pluck) || c2.index || c2.field;
m2 = c2.tag;
h2 = this.store && c2.enrich;
n2 = "and" === c2.bool;
b3 = c2.limit || 100;
w2 = c2.offset || 0;
if (m2 && (x(m2) && (m2 = [m2]), !a2)) {
for (let l = 0, p2; l < m2.length; l++)
if (p2 = ya.call(this, m2[l], b3, w2, h2))
e2[e2.length] = p2, q2++;
return q2 ? e2 : [];
}
x(k2) && (k2 = [k2]);
}
k2 || (k2 = this.h);
n2 = n2 && (1 < k2.length || m2 && 1 < m2.length);
const r2 = !d2 && (this.o || this.async) && [];
for (let l = 0, p2, z2, B3; l < k2.length; l++) {
let A3;
z2 = k2[l];
x(z2) || (A3 = z2, z2 = z2.field);
if (r2)
r2[l] = this.index[z2].searchAsync(a2, b3, A3 || c2);
else {
d2 ? p2 = d2[l] : p2 = this.index[z2].search(a2, b3, A3 || c2);
B3 = p2 && p2.length;
if (m2 && B3) {
const y2 = [];
let H2 = 0;
n2 && (y2[0] = [p2]);
for (let X2 = 0, pa2, R2; X2 < m2.length; X2++)
if (pa2 = m2[X2], B3 = (R2 = this.l[pa2]) && R2.length)
H2++, y2[y2.length] = n2 ? [R2] : R2;
H2 && (p2 = n2 ? ma(y2, b3 || 100, w2 || 0) : na(p2, y2), B3 = p2.length);
}
if (B3)
f2[q2] = z2, e2[q2++] = p2;
else if (n2)
return [];
}
}
if (r2) {
const l = this;
return new Promise(function(p2) {
Promise.all(r2).then(function(z2) {
p2(l.search(a2, b3, c2, z2));
});
});
}
if (!q2)
return [];
if (g && (!h2 || !this.store))
return e2[0];
for (let l = 0, p2; l < f2.length; l++) {
p2 = e2[l];
p2.length && h2 && (p2 = za.call(this, p2));
if (g)
return p2;
e2[l] = { field: f2[l], result: p2 };
}
return e2;
};
function ya(a2, b3, c2, d2) {
let e2 = this.l[a2], f2 = e2 && e2.length - c2;
if (f2 && 0 < f2) {
if (f2 > b3 || c2)
e2 = e2.slice(c2, c2 + b3);
d2 && (e2 = za.call(this, e2));
return { tag: a2, result: e2 };
}
}
function za(a2) {
const b3 = Array(a2.length);
for (let c2 = 0, d2; c2 < a2.length; c2++)
d2 = a2[c2], b3[c2] = { id: d2, doc: this.store[d2] };
return b3;
}
t.contain = function(a2) {
return !!this.register[a2];
};
t.get = function(a2) {
return this.store[a2];
};
t.set = function(a2, b3) {
this.store[a2] = b3;
return this;
};
t.searchCache = oa;
t.export = function(a2, b3, c2, d2, e2) {
e2 || (e2 = 0);
d2 || (d2 = 0);
if (d2 < this.h.length) {
const f2 = this.h[d2], g = this.index[f2];
b3 = this;
setTimeout(function() {
g.export(a2, b3, e2 ? f2.replace(":", "-") : "", d2, e2++) || (d2++, e2 = 1, b3.export(a2, b3, f2, d2, e2));
});
} else {
let f2;
switch (e2) {
case 1:
c2 = "tag";
f2 = this.l;
break;
case 2:
c2 = "store";
f2 = this.store;
break;
default:
return;
}
ra(a2, this, c2, d2, e2, f2);
}
};
t.import = function(a2, b3) {
if (b3)
switch (x(b3) && (b3 = JSON.parse(b3)), a2) {
case "tag":
this.l = b3;
break;
case "reg":
this.m = false;
this.register = b3;
for (let d2 = 0, e2; d2 < this.h.length; d2++)
e2 = this.index[this.h[d2]], e2.register = b3, e2.m = false;
break;
case "store":
this.store = b3;
break;
default:
a2 = a2.split(".");
const c2 = a2[0];
a2 = a2[1];
c2 && a2 && this.index[c2].import(a2, b3);
}
};
la(Q.prototype);
var Ba = { encode: Aa, F: false, G: "" };
const Ca = [F("[àáâãäå]"), "a", F("[èéêë]"), "e", F("[ìíîï]"), "i", F("[òóôõöő]"), "o", F("[ùúûüű]"), "u", F("[ýŷÿ]"), "y", F("ñ"), "n", F("[çc]"), "k", F("ß"), "s", F(" & "), " and "];
function Aa(a2) {
var b3 = a2;
b3.normalize && (b3 = b3.normalize("NFD").replace(ea, ""));
return ca.call(this, b3.toLowerCase(), !a2.normalize && Ca);
}
var Ea = { encode: Da, F: false, G: "strict" };
const Fa = /[^a-z0-9]+/, Ga = { b: "p", v: "f", w: "f", z: "s", x: "s", "ß": "s", d: "t", n: "m", c: "k", g: "k", j: "k", q: "k", i: "e", y: "e", u: "o" };
function Da(a2) {
a2 = Aa.call(this, a2).join(" ");
const b3 = [];
if (a2) {
const c2 = a2.split(Fa), d2 = c2.length;
for (let e2 = 0, f2, g = 0; e2 < d2; e2++)
if ((a2 = c2[e2]) && (!this.filter || !this.filter[a2])) {
f2 = a2[0];
let h2 = Ga[f2] || f2, k2 = h2;
for (let m2 = 1; m2 < a2.length; m2++) {
f2 = a2[m2];
const n2 = Ga[f2] || f2;
n2 && n2 !== k2 && (h2 += n2, k2 = n2);
}
b3[g++] = h2;
}
}
return b3;
}
var Ia = { encode: Ha, F: false, G: "" };
const Ja = [F("ae"), "a", F("oe"), "o", F("sh"), "s", F("th"), "t", F("ph"), "f", F("pf"), "f", F("(?![aeo])h(?![aeo])"), "", F("(?!^[aeo])h(?!^[aeo])"), ""];
function Ha(a2, b3) {
a2 && (a2 = Da.call(this, a2).join(" "), 2 < a2.length && (a2 = E(a2, Ja)), b3 || (1 < a2.length && (a2 = ha(a2)), a2 && (a2 = a2.split(" "))));
return a2;
}
var La = { encode: Ka, F: false, G: "" };
const Ma = F("(?!\\b)[aeo]");
function Ka(a2) {
a2 && (a2 = Ha.call(this, a2, true), 1 < a2.length && (a2 = a2.replace(Ma, "")), 1 < a2.length && (a2 = ha(a2)), a2 && (a2 = a2.split(" ")));
return a2;
}
G["latin:default"] = ja;
G["latin:simple"] = Ba;
G["latin:balance"] = Ea;
G["latin:advanced"] = Ia;
G["latin:extra"] = La;
const W = self;
let Y;
const Z = { Index: K, Document: Q, Worker: O, registerCharset: function(a2, b3) {
G[a2] = b3;
}, registerLanguage: function(a2, b3) {
ka[a2] = b3;
} };
(Y = W.define) && Y.amd ? Y([], function() {
return Z;
}) : W.exports ? W.exports = Z : W.FlexSearch = Z;
})(commonjsGlobal);
})(flexsearch_bundle);
const MountStory = defineComponent({
name: "MountStory",
props: {
story: {
type: Object,
required: true
}
},
setup(props) {
const options = props.story.file.component;
let rawVariants = [];
if (options.onMount) {
rawVariants = [{
id: "_default",
title: "default",
onMount: options.onMount,
onMountControls: options.onMountControls
}];
} else {
rawVariants = options.variants;
}
for (const index2 in props.story.variants) {
const rawVariant = rawVariants[index2];
Object.assign(props.story.variants[index2], {
slots: () => ({ default: rawVariant.onMount, controls: rawVariant.onMountControls }),
source: rawVariant.source ?? options.source,
responsiveDisabled: rawVariant.responsiveDisabled ?? options.responsiveDisabled,
autoPropsDisabled: rawVariant.autoPropsDisabled ?? options.autoPropsDisabled,
setupApp: rawVariant.setupApp ?? options.setupApp,
configReady: true
});
}
},
render() {
return null;
}
});
const virtual_$histoireNoop = () => {
};
const f$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: virtual_$histoireNoop
}, Symbol.toStringTag, { value: "Module" }));
const m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" }));
const RenderStory = defineComponent({
name: "RenderStory",
props: {
variant: {
type: Object,
required: true
},
story: {
type: Object,
required: true
},
slotName: {
type: String,
default: "default"
}
},
emits: {
ready: () => true
},
setup(props, { emit: emit2 }) {
const sandbox = ref();
let mounting = false;
let app;
let appHooks;
async function unmountVariant() {
var _a3;
if (app) {
await ((_a3 = app.onUnmount) == null ? void 0 : _a3.call(app));
if (appHooks) {
for (const hook of appHooks.onUnmount) {
await hook();
}
}
app.el.parentNode.removeChild(app.el);
app = null;
}
}
async function mountVariant() {
var _a3;
if (mounting)
return;
mounting = true;
await unmountVariant();
app = {
el: document.createElement("div")
};
if (typeof props.variant.setupApp === "function") {
await props.variant.setupApp({
app,
story: props.story,
variant: props.variant
});
}
await ((_a3 = app.onMount) == null ? void 0 : _a3.call(app));
appHooks = {
onUpdate: [],
onUnmount: []
};
const api = {
el: app.el,
state: props.variant.state,
onUpdate: (cb) => {
appHooks.onUpdate.push(cb);
},
onUnmount: (cb) => {
appHooks.onUnmount.push(cb);
}
};
const onMount2 = props.variant.slots()[props.slotName];
await onMount2(api);
sandbox.value.appendChild(app.el);
emit2("ready");
}
onMounted(async () => {
if (props.variant.configReady) {
await mountVariant();
}
});
watch(() => props.variant, async (value) => {
if (value.configReady && !mounting) {
if (!app) {
await mountVariant();
}
}
}, {
deep: true
});
watch(() => props.variant.state, async () => {
if (appHooks) {
for (const hook of appHooks.onUpdate) {
await hook();
}
}
}, {
deep: true
});
onBeforeUnmount(() => {
unmountVariant();
});
return {
sandbox
};
},
render() {
return h$1("div", {
ref: "sandbox"
});
}
});
function generateSourceCode() {
}
const client = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
MountStory,
RenderStory,
generateSourceCode
}, Symbol.toStringTag, { value: "Module" }));
function j(n2) {
let e2, s, o = false;
return { c() {
e2 = empty();
}, m(l, i2) {
insert(l, e2, i2), s = true;
}, p(l, [i2]) {
}, i(l) {
s || (transition_in(o), s = true);
}, o(l) {
transition_out(o), s = false;
}, d(l) {
l && detach(e2);
} };
}
function O$1(n2, e2, s) {
let { $$slots: o = {}, $$scope: l } = e2;
const i2 = compute_slots(o);
let { source: f2 = null } = e2, { responsiveDisabled: c2 = false } = e2, { autoPropsDisabled: a2 = false } = e2, { setupApp: u2 = null } = e2, { implicit: r2 = false } = e2;
const _ = getContext("__hstStory"), d2 = getContext("__hstIndex"), b3 = getContext("__hstSlots"), D2 = _.variants[d2.value];
d2.value++;
function p2() {
var t2;
Object.assign(D2, { slots: () => ({ default: true, controls: i2.controls ?? b3.controls }), source: f2, responsiveDisabled: c2, autoPropsDisabled: a2, setupApp: u2, configReady: true }), !r2 && !((t2 = _.meta) != null && t2.hasVariantChildComponents) && Object.assign(_, { meta: { hasVariantChildComponents: true } });
}
return p2(), afterUpdate(() => {
p2();
}), n2.$$set = (t2) => {
"source" in t2 && s(0, f2 = t2.source), "responsiveDisabled" in t2 && s(1, c2 = t2.responsiveDisabled), "autoPropsDisabled" in t2 && s(2, a2 = t2.autoPropsDisabled), "setupApp" in t2 && s(3, u2 = t2.setupApp), "implicit" in t2 && s(4, r2 = t2.implicit), "$$scope" in t2 && s(5, l = t2.$$scope);
}, [f2, c2, a2, u2, r2, l, o];
}
class E extends SvelteComponent {
constructor(e2) {
super(), init(this, e2, O$1, j, safe_not_equal, { source: 0, responsiveDisabled: 1, autoPropsDisabled: 2, setupApp: 3, implicit: 4 });
}
}
const G$1 = (s) => ({}), S = (s) => ({ slot: "controls" });
function H$1(s) {
let o;
const r2 = s[3].default, e2 = create_slot(r2, s, s[4], null);
return { c() {
e2 && e2.c();
}, m(t2, n2) {
e2 && e2.m(t2, n2), o = true;
}, p(t2, n2) {
e2 && e2.p && (!o || n2 & 16) && update_slot_base(e2, r2, t2, t2[4], o ? get_slot_changes(r2, t2[4], n2, null) : get_all_dirty_from_scope(t2[4]), null);
}, i(t2) {
o || (transition_in(e2, t2), o = true);
}, o(t2) {
transition_out(e2, t2), o = false;
}, d(t2) {
e2 && e2.d(t2);
} };
}
function J(s) {
let o, r2;
const e2 = [s[0], s[2], { implicit: true }];
let t2 = { $$slots: { controls: [L], default: [K] }, $$scope: { ctx: s } };
for (let n2 = 0; n2 < e2.length; n2 += 1)
t2 = assign$1(t2, e2[n2]);
return o = new E({ props: t2 }), { c() {
create_component(o.$$.fragment);
}, m(n2, l) {
mount_component(o, n2, l), r2 = true;
}, p(n2, l) {
const c2 = l & 5 ? get_spread_update(e2, [l & 1 && get_spread_object(n2[0]), l & 4 && get_spread_object(n2[2]), e2[2]]) : {};
l & 16 && (c2.$$scope = { dirty: l, ctx: n2 }), o.$set(c2);
}, i(n2) {
r2 || (transition_in(o.$$.fragment, n2), r2 = true);
}, o(n2) {
transition_out(o.$$.fragment, n2), r2 = false;
}, d(n2) {
destroy_component(o, n2);
} };
}
function K(s) {
let o;
const r2 = s[3].default, e2 = create_slot(r2, s, s[4], null);
return { c() {
e2 && e2.c();
}, m(t2, n2) {
e2 && e2.m(t2, n2), o = true;
}, p(t2, n2) {
e2 && e2.p && (!o || n2 & 16) && update_slot_base(e2, r2, t2, t2[4], o ? get_slot_changes(r2, t2[4], n2, null) : get_all_dirty_from_scope(t2[4]), null);
}, i(t2) {
o || (transition_in(e2, t2), o = true);
}, o(t2) {
transition_out(e2, t2), o = false;
}, d(t2) {
e2 && e2.d(t2);
} };
}
function L(s) {
let o;
const r2 = s[3].controls, e2 = create_slot(r2, s, s[4], S);
return { c() {
e2 && e2.c();
}, m(t2, n2) {
e2 && e2.m(t2, n2), o = true;
}, p(t2, n2) {
e2 && e2.p && (!o || n2 & 16) && update_slot_base(e2, r2, t2, t2[4], o ? get_slot_changes(r2, t2[4], n2, G$1) : get_all_dirty_from_scope(t2[4]), S);
}, i(t2) {
o || (transition_in(e2, t2), o = true);
}, o(t2) {
transition_out(e2, t2), o = false;
}, d(t2) {
e2 && e2.d(t2);
} };
}
function N$1(s) {
let o, r2, e2, t2;
const n2 = [J, H$1], l = [];
function c2(u2, i2) {
return u2[1].variants.length === 1 && u2[1].variants[0].id === "_default" ? 0 : 1;
}
return o = c2(s), r2 = l[o] = n2[o](s), { c() {
r2.c(), e2 = empty();
}, m(u2, i2) {
l[o].m(u2, i2), insert(u2, e2, i2), t2 = true;
}, p(u2, [i2]) {
r2.p(u2, i2);
}, i(u2) {
t2 || (transition_in(r2), t2 = true);
}, o(u2) {
transition_out(r2), t2 = false;
}, d(u2) {
l[o].d(u2), u2 && detach(e2);
} };
}
function Q(s, o, r2) {
let e2;
const t2 = [];
let n2 = compute_rest_props(o, t2), { $$slots: l = {}, $$scope: c2 } = o;
const u2 = compute_slots(l), i2 = getContext("__hstStory");
setContext("__hstIndex", { value: 0 }), setContext("__hstSlots", u2), s.$$set = (_) => {
o = assign$1(assign$1({}, o), exclude_internal_props(_)), r2(2, n2 = compute_rest_props(o, t2)), "$$scope" in _ && r2(4, c2 = _.$$scope);
};
r2(0, e2 = Object.keys(i2).filter((_) => !omitInheritStoryProps.includes(_)).reduce((_, h2) => (_[h2] = i2[h2], _), {}));
return [e2, i2, n2, l, c2];
}
class Y extends SvelteComponent {
constructor(o) {
super(), init(this, o, Q, N$1, safe_not_equal, {});
}
}
class u extends SvelteComponent {
constructor(t2) {
super(), init(this, t2, null, null, safe_not_equal, {});
}
}
const x = defineComponent({ name: "MountStory", props: { story: { type: Object, required: true } }, setup(t2) {
const n2 = ref();
let e2, o;
async function u2() {
o = document.createElement("div"), n2.value.appendChild(o), e2 = new t2.story.file.component({ target: o, props: { Hst: { Story: Y, Variant: E, ...h() } }, context: new Map(Object.entries({ __hstStory: t2.story })) }), typeof (m == null ? void 0 : void 0) == "function" && await (void 0)({ app: e2, story: t2.story, variant: null }), typeof (f$1 == null ? void 0 : void 0) == "function" && await (void 0)({ app: e2, story: t2.story, variant: null });
}
function s() {
var a2;
e2 == null || e2.$destroy(), o && ((a2 = o.parentNode) == null || a2.removeChild(o), o = null);
}
return watch(() => t2.story.id, async () => {
s(), await u2();
}), onMounted(async () => {
await u2();
}), onUnmounted(() => {
s();
}), { el: n2 };
}, render() {
return h$1("div", { ref: "el" });
} });
function h() {
const t2 = {};
for (const n2 in rm)
t2[n2.substring(3)] = u;
return t2;
}
const I = (l) => ({}), b$1 = (l) => ({});
function N(l) {
let o;
const i2 = l[4].controls, e2 = create_slot(i2, l, l[3], b$1);
return { c() {
e2 && e2.c();
}, m(t2, n2) {
e2 && e2.m(t2, n2), o = true;
}, p(t2, n2) {
e2 && e2.p && (!o || n2 & 8) && update_slot_base(e2, i2, t2, t2[3], o ? get_slot_changes(i2, t2[3], n2, I) : get_all_dirty_from_scope(t2[3]), b$1);
}, i(t2) {
o || (transition_in(e2, t2), o = true);
}, o(t2) {
transition_out(e2, t2), o = false;
}, d(t2) {
e2 && e2.d(t2);
} };
}
function O(l) {
let o;
const i2 = l[4].default, e2 = create_slot(i2, l, l[3], null);
return { c() {
e2 && e2.c();
}, m(t2, n2) {
e2 && e2.m(t2, n2), o = true;
}, p(t2, n2) {
e2 && e2.p && (!o || n2 & 8) && update_slot_base(e2, i2, t2, t2[3], o ? get_slot_changes(i2, t2[3], n2, null) : get_all_dirty_from_scope(t2[3]), null);
}, i(t2) {
o || (transition_in(e2, t2), o = true);
}, o(t2) {
transition_out(e2, t2), o = false;
}, d(t2) {
e2 && e2.d(t2);
} };
}
function R(l) {
var u2;
let o, i2, e2, t2 = l[1] === "controls" && N(l), n2 = (l[1] === "default" || ((u2 = l[0].meta) == null ? void 0 : u2.hasVariantChildComponents)) && O(l);
return { c() {
t2 && t2.c(), o = space(), n2 && n2.c(), i2 = empty();
}, m(s, r2) {
t2 && t2.m(s, r2), insert(s, o, r2), n2 && n2.m(s, r2), insert(s, i2, r2), e2 = true;
}, p(s, [r2]) {
var f2;
s[1] === "controls" && t2.p(s, r2), (s[1] === "default" || (f2 = s[0].meta) != null && f2.hasVariantChildComponents) && n2.p(s, r2);
}, i(s) {
e2 || (transition_in(t2), transition_in(n2), e2 = true);
}, o(s) {
transition_out(t2), transition_out(n2), e2 = false;
}, d(s) {
t2 && t2.d(s), s && detach(o), n2 && n2.d(s), s && detach(i2);
} };
}
function w$1(l, o, i2) {
let { $$slots: e2 = {}, $$scope: t2 } = o;
const n2 = getContext("__hstStory"), u2 = getContext("__hstVariant"), s = getContext("__hstSlot");
setContext("__hstIndex", { value: 0 });
let { source: f2 = null } = o;
return l.$$set = (_) => {
"source" in _ && i2(2, f2 = _.source), "$$scope" in _ && i2(3, t2 = _.$$scope);
}, l.$$.update = () => {
if (l.$$.dirty & 4) {
f2 != null && Object.assign(u2, { source: f2 });
}
}, [n2, s, f2, t2, e2];
}
let B$1 = class B2 extends SvelteComponent {
constructor(o) {
super(), init(this, o, w$1, R, safe_not_equal, { source: 2 });
}
};
const w = (n2) => ({}), b = (n2) => ({});
function k(n2) {
let o, s, t2, e2 = n2[1] === "default" && z$1(n2), l = n2[1] === "controls" && A$1(n2);
return { c() {
e2 && e2.c(), o = space(), l && l.c(), s = empty();
}, m(i2, r2) {
e2 && e2.m(i2, r2), insert(i2, o, r2), l && l.m(i2, r2), insert(i2, s, r2), t2 = true;
}, p(i2, r2) {
i2[1] === "default" && e2.p(i2, r2), i2[1] === "controls" && l.p(i2, r2);
}, i(i2) {
t2 || (transition_in(e2), transition_in(l), t2 = true);
}, o(i2) {
transition_out(e2), transition_out(l), t2 = false;
}, d(i2) {
e2 && e2.d(i2), i2 && detach(o), l && l.d(i2), i2 && detach(s);
} };
}
function z$1(n2) {
let o;
const s = n2[4].default, t2 = create_slot(s, n2, n2[3], null);
return { c() {
t2 && t2.c();
}, m(e2, l) {
t2 && t2.m(e2, l), o = true;
}, p(e2, l) {
t2 && t2.p && (!o || l & 8) && update_slot_base(t2, s, e2, e2[3], o ? get_slot_changes(s, e2[3], l, null) : get_all_dirty_from_scope(e2[3]), null);
}, i(e2) {
o || (transition_in(t2, e2), o = true);
}, o(e2) {
transition_out(t2, e2), o = false;
}, d(e2) {
t2 && t2.d(e2);
} };
}
function A$1(n2) {
let o;
const s = n2[4].controls, t2 = create_slot(s, n2, n2[3], b);
return { c() {
t2 && t2.c();
}, m(e2, l) {
t2 && t2.m(e2, l), o = true;
}, p(e2, l) {
t2 && t2.p && (!o || l & 8) && update_slot_base(t2, s, e2, e2[3], o ? get_slot_changes(s, e2[3], l, w) : get_all_dirty_from_scope(e2[3]), b);
}, i(e2) {
o || (transition_in(t2, e2), o = true);
}, o(e2) {
transition_out(t2, e2), o = false;
}, d(e2) {
t2 && t2.d(e2);
} };
}
function B(n2) {
let o, s, t2 = n2[0] && k(n2);
return { c() {
t2 && t2.c(), o = empty();
}, m(e2, l) {
t2 && t2.m(e2, l), insert(e2, o, l), s = true;
}, p(e2, [l]) {
e2[0] ? t2 ? (t2.p(e2, l), l & 1 && transition_in(t2, 1)) : (t2 = k(e2), t2.c(), transition_in(t2, 1), t2.m(o.parentNode, o)) : t2 && (group_outros(), transition_out(t2, 1, 1, () => {
t2 = null;
}), check_outros());
}, i(e2) {
s || (transition_in(t2), s = true);
}, o(e2) {
transition_out(t2), s = false;
}, d(e2) {
t2 && t2.d(e2), e2 && detach(o);
} };
}
function D(n2, o, s) {
let t2, { $$slots: e2 = {}, $$scope: l } = o;
const i2 = getContext("__hstStory"), r2 = getContext("__hstVariant"), y2 = getContext("__hstSlot"), p2 = getContext("__hstIndex"), C2 = i2.variants[p2.value];
p2.value++;
let { source: c2 = null } = o;
n2.$$set = (_) => {
"source" in _ && s(2, c2 = _.source), "$$scope" in _ && s(3, l = _.$$scope);
}, n2.$$.update = () => {
if (n2.$$.dirty & 4) {
c2 != null && Object.assign(r2, { source: c2 });
}
};
s(0, t2 = r2.id === C2.id);
return [t2, y2, c2, l, e2];
}
class G extends SvelteComponent {
constructor(o) {
super(), init(this, o, D, B, safe_not_equal, { source: 2 });
}
}
function W(i2) {
let t2, o = i2[0].name + "", r2;
return { c() {
t2 = element("div"), r2 = text(o);
}, m(a2, n2) {
insert(a2, t2, n2), append(t2, r2), i2[3](t2);
}, p(a2, [n2]) {
n2 & 1 && o !== (o = a2[0].name + "") && set_data(r2, o);
}, i: noop$2, o: noop$2, d(a2) {
a2 && detach(t2), i2[3](null);
} };
}
function z(i2, t2, o) {
const r2 = ["controlComponent", "value"];
let a2 = compute_rest_props(t2, r2), { controlComponent: n2 } = t2, { value: s } = t2;
const b3 = createEventDispatcher();
let l, m2;
const p2 = reactive({});
function f2(e2, c2) {
Object.assign(p2, { value: e2, attrs: c2 });
}
onMount(() => {
f2(s, a2), m2 = createApp({ render() {
const e2 = {};
if (n2.emits)
for (const c2 in n2.emits) {
const u2 = Array.isArray(n2.emits) ? n2.emits[c2] : c2, d2 = u2 === "input" ? "update:modelValue" : u2;
e2[`on${d2.charAt(0).toUpperCase()}${d2.substring(1)}`] = (..._) => {
u2 === "update:modelValue" ? o(2, s = _[0]) : b3(u2, ..._);
};
}
return h$1(n2, { modelValue: s, ...p2.attrs, ...e2, key: "component" });
} }), m2.mount(l);
});
function g(e2) {
binding_callbacks[e2 ? "unshift" : "push"](() => {
l = e2, o(1, l);
});
}
return i2.$$set = (e2) => {
t2 = assign$1(assign$1({}, t2), exclude_internal_props(e2)), o(8, a2 = compute_rest_props(t2, r2)), "controlComponent" in e2 && o(0, n2 = e2.controlComponent), "value" in e2 && o(2, s = e2.value);
}, i2.$$.update = () => {
f2(s, a2);
}, [n2, l, s, g];
}
class H extends SvelteComponent {
constructor(t2) {
super(), init(this, t2, z, W, safe_not_equal, { controlComponent: 0, value: 2 });
}
}
function f(n2) {
const i2 = {};
for (const t2 in n2) {
if (t2 === "Hst")
continue;
const e2 = n2[t2];
typeof e2 != "function" && (typeof e2 > "u" || e2 instanceof HTMLElement || typeof e2 == "object" && (e2 != null && e2.$$) || (i2[t2] = e2));
}
return i2;
}
function y(n2, i2) {
let t2 = false;
const e2 = watch(() => n2, (o) => {
o != null && (t2 ? t2 = false : (t2 = true, i2(f(o))));
}, { deep: true, immediate: true });
function c2(o) {
o != null && (t2 ? t2 = false : (t2 = true, applyState(n2, clone(f(o)))));
}
return { apply: c2, stop() {
e2();
} };
}
const P = defineComponent({ name: "RenderStory", props: { variant: { type: Object, required: true }, story: { type: Object, required: true }, slotName: { type: String, default: "default" } }, setup(t2, { emit: i2 }) {
const u2 = ref();
let r2, a2, c2 = [];
function $2(n2, s) {
document.addEventListener(n2, s);
const e2 = () => document.removeEventListener(n2, s);
return c2.push(e2), { off: e2 };
}
async function l() {
a2 = document.createElement("div"), u2.value.appendChild(a2);
let n2 = [];
const { off: s } = $2("SvelteRegisterComponent", (o) => {
const { component: p2 } = o.detail;
n2.push(p2);
});
r2 = new t2.story.file.component({ target: a2, props: { Hst: { Story: B$1, Variant: G, ...q() } }, context: new Map(Object.entries({ __hstStory: t2.story, __hstVariant: t2.variant, __hstSlot: t2.slotName })) });
let e2 = n2.find((o) => o.$$ === r2.$$);
s(), n2 = [];
function d2() {
const o = e2.$replace;
o && (e2.$replace = (...p2) => {
const S2 = o.apply(e2, p2);
return e2 = S2, h2(), d2(), S2;
});
}
d2();
const { apply: v2, stop: _ } = y(t2.variant.state, (o) => {
e2.$inject_state(o);
});
c2.push(_);
function h2() {
e2.$$.after_update.push(() => {
v2(e2.$capture_state());
});
}
h2(), v2(e2.$capture_state()), typeof (m == null ? void 0 : void 0) == "function" && await (void 0)({ app: r2, story: t2.story, variant: t2.variant }), typeof (f$1 == null ? void 0 : void 0) == "function" && await (void 0)({ app: r2, story: t2.story, variant: t2.variant }), typeof t2.variant.setupApp == "function" && await t2.variant.setupApp({ app: r2, story: t2.story, variant: t2.variant }), i2("ready");
}
function y$1() {
var n2;
r2 == null || r2.$destroy(), a2 && ((n2 = a2.parentNode) == null || n2.removeChild(a2), a2 = null), c2.forEach((s) => s()), c2 = [];
}
return watch(() => t2.story.id, async () => {
y$1(), await l();
}), onMounted(async () => {
await l();
}), onUnmounted(() => {
y$1();
}), { el: u2 };
}, render() {
return h$1("div", { ref: "el" });
} });
function q() {
const t2 = {};
for (const i2 in rm)
t2[i2.substring(3)] = A(rm[i2]);
return t2;
}
function A(t2) {
function i2(u2) {
return new H({ ...u2, props: { ...u2.props, controlComponent: t2 } });
}
return i2;
}
function e() {
}
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
MountStory: x,
RenderStory: P,
generateSourceCode: e
}, Symbol.toStringTag, { value: "Module" }));
export {
safe_not_equal as $,
resolveDirective as A,
withDirectives as B,
toggleDark as C,
createTextVNode as D,
pushScopeId as E,
Fragment as F,
popScopeId as G,
defineAsyncComponent as H,
Icon as I,
vShow as J,
reactive as K,
normalizeStyle as L,
useTitle as M,
onMounted as N,
createApp as O,
createPinia as P,
plugin as Q,
parseQuery as R,
STATE_SYNC as S,
Transition as T,
PREVIEW_SETTINGS_SYNC as U,
h$1 as V,
SANDBOX_READY as W,
applyState as X,
SvelteComponentDev as Y,
init as Z,
__vitePreload as _,
unref as a,
VTooltip as a$,
dispatch_dev as a0,
create_slot as a1,
validate_slots as a2,
base as a3,
tick as a4,
element as a5,
space as a6,
text as a7,
claim_element as a8,
children as a9,
assign$1 as aA,
getContext as aB,
get_spread_update as aC,
get_spread_object as aD,
to_number as aE,
validate_each_argument as aF,
validate_each_keys as aG,
empty as aH,
update_keyed_each as aI,
destroy_block as aJ,
logEvent as aK,
createRouter as aL,
createWebHistory as aM,
createWebHashHistory as aN,
markRaw as aO,
watchEffect as aP,
mergeProps as aQ,
resolveDynamicComponent as aR,
toRefs as aS,
unindent as aT,
useRouter as aU,
useResizeObserver as aV,
Xg as aW,
withModifiers as aX,
renderSlot as aY,
vModelText as aZ,
onUnmounted as a_,
detach_dev as aa,
claim_space as ab,
claim_text as ac,
attr_dev as ad,
add_location as ae,
src_url_equal as af,
insert_hydration_dev as ag,
append_hydration_dev as ah,
update_slot_base as ai,
get_all_dirty_from_scope as aj,
get_slot_changes as ak,
set_data_dev as al,
transition_in as am,
transition_out as an,
binding_callbacks as ao,
bind as ap,
create_component as aq,
claim_component as ar,
mount_component as as,
destroy_component as at,
add_flush_callback as au,
noop$2 as av,
bubble as aw,
set_input_value as ax,
listen_dev as ay,
run_all as az,
useRoute as b,
createStaticVNode as b0,
EVENT_SEND as b1,
toRaw as b2,
Dropdown as b3,
clone as b4,
omit as b5,
useTimeoutFn as b6,
onClickOutside as b7,
nextTick as b8,
Zg as b9,
zg as ba,
jg as bb,
Wg as bc,
shallowRef as bd,
getHighlighter as be,
onBeforeUnmount as bf,
scrollIntoView as bg,
useMediaQuery as bh,
useFocus as bi,
refDebounced as bj,
flexsearch_bundleExports as bk,
client as bl,
index as bm,
computed as c,
defineComponent as d,
createElementBlock as e,
createVNode as f,
createBaseVNode as g,
createCommentVNode as h,
defineStore as i,
useStorage as j,
watch as k,
resolveComponent as l,
withKeys as m,
normalizeClass as n,
openBlock as o,
renderList as p,
createBlock as q,
ref as r,
isDark as s,
toDisplayString as t,
useCssVars as u,
histoireConfig as v,
withCtx as w,
customLogos as x,
useEventListener as y,
isRef as z
};