rrweb-player
Version:
rrweb's replayer UI
1,647 lines • 294 kB
JavaScript
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
function noop() {
}
function assign(tar, src) {
for (const k in src) tar[k] = src[k];
return (
/** @type {T & S} */
tar
);
}
function run(fn) {
return fn();
}
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(a, b) {
return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function";
}
function is_empty(obj) {
return Object.keys(obj).length === 0;
}
function exclude_internal_props(props) {
const result2 = {};
for (const k in props) if (k[0] !== "$") result2[k] = props[k];
return result2;
}
function append(target, node2) {
target.appendChild(node2);
}
function insert(target, node2, anchor) {
target.insertBefore(node2, anchor || null);
}
function detach(node2) {
if (node2.parentNode) {
node2.parentNode.removeChild(node2);
}
}
function destroy_each(iterations, detaching) {
for (let i = 0; i < iterations.length; i += 1) {
if (iterations[i]) iterations[i].d(detaching);
}
}
function element(name) {
return document.createElement(name);
}
function svg_element(name) {
return document.createElementNS("http://www.w3.org/2000/svg", name);
}
function text(data) {
return document.createTextNode(data);
}
function space() {
return text(" ");
}
function empty() {
return text("");
}
function listen(node2, event, handler, options) {
node2.addEventListener(event, handler, options);
return () => node2.removeEventListener(event, handler, options);
}
function attr(node2, attribute, value) {
if (value == null) node2.removeAttribute(attribute);
else if (node2.getAttribute(attribute) !== value) node2.setAttribute(attribute, value);
}
function children(element2) {
return Array.from(element2.childNodes);
}
function set_data(text2, data) {
data = "" + data;
if (text2.data === data) return;
text2.data = /** @type {string} */
data;
}
function set_style(node2, key, value, important) {
if (value == null) {
node2.style.removeProperty(key);
} else {
node2.style.setProperty(key, value, "");
}
}
function toggle_class(element2, name, toggle) {
element2.classList.toggle(name, !!toggle);
}
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
return new CustomEvent(type, { detail, bubbles, cancelable });
}
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 onDestroy(fn) {
get_current_component().$$.on_destroy.push(fn);
}
function createEventDispatcher() {
const component = get_current_component();
return (type, detail, { cancelable = false } = {}) => {
const callbacks = component.$$.callbacks[type];
if (callbacks) {
const event = custom_event(
/** @type {string} */
type,
detail,
{ cancelable }
);
callbacks.slice().forEach((fn) => {
fn.call(component, event);
});
return !event.defaultPrevented;
}
return true;
};
}
const dirty_components = [];
const binding_callbacks = [];
let render_callbacks = [];
const flush_callbacks = [];
const resolved_promise = /* @__PURE__ */ Promise.resolve();
let update_scheduled = false;
function schedule_update() {
if (!update_scheduled) {
update_scheduled = true;
resolved_promise.then(flush);
}
}
function add_render_callback(fn) {
render_callbacks.push(fn);
}
function add_flush_callback(fn) {
flush_callbacks.push(fn);
}
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 (e) {
dirty_components.length = 0;
flushidx = 0;
throw e;
}
set_current_component(null);
dirty_components.length = 0;
flushidx = 0;
while (binding_callbacks.length) binding_callbacks.pop()();
for (let i = 0; i < render_callbacks.length; i += 1) {
const callback = render_callbacks[i];
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);
}
}
function flush_render_callbacks(fns) {
const filtered = [];
const targets = [];
render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c));
targets.forEach((c) => c());
render_callbacks = filtered;
}
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 ensure_array_like(array_like_or_iterator) {
return (array_like_or_iterator == null ? void 0 : array_like_or_iterator.length) !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
}
function bind(component, name, callback) {
const index = component.$$.props[name];
if (index !== void 0) {
component.$$.bound[index] = callback;
callback(component.$$.ctx[index]);
}
}
function create_component(block) {
block && block.c();
}
function mount_component(component, target, anchor) {
const { fragment, after_update } = component.$$;
fragment && fragment.m(target, anchor);
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) {
flush_render_callbacks($$.after_update);
run_all($$.on_destroy);
$$.fragment && $$.fragment.d(detaching);
$$.on_destroy = $$.fragment = null;
$$.ctx = [];
}
}
function make_dirty(component, i) {
if (component.$$.dirty[0] === -1) {
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
}
component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
}
function init(component, options, instance2, create_fragment2, not_equal, props, append_styles = null, dirty = [-1]) {
const parent_component = current_component;
set_current_component(component);
const $$ = component.$$ = {
fragment: null,
ctx: [],
// state
props,
update: noop,
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 = instance2 ? instance2(component, options.props || {}, (i, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);
if (ready) make_dirty(component, i);
}
return ret;
}) : [];
$$.update();
ready = true;
run_all($$.before_update);
$$.fragment = create_fragment2 ? create_fragment2($$.ctx) : false;
if (options.target) {
if (options.hydrate) {
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);
flush();
}
set_current_component(parent_component);
}
class SvelteComponent {
constructor() {
/**
* ### PRIVATE API
*
* Do not use, may change at any time
*
* @type {any}
*/
__publicField(this, "$$");
/**
* ### PRIVATE API
*
* Do not use, may change at any time
*
* @type {any}
*/
__publicField(this, "$$set");
}
/** @returns {void} */
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
/**
* @template {Extract<keyof Events, string>} K
* @param {K} type
* @param {((e: Events[K]) => void) | null | undefined} callback
* @returns {() => void}
*/
$on(type, callback) {
if (!is_function(callback)) {
return noop;
}
const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
callbacks.push(callback);
return () => {
const index = callbacks.indexOf(callback);
if (index !== -1) callbacks.splice(index, 1);
};
}
/**
* @param {Partial<Props>} props
* @returns {void}
*/
$set(props) {
if (this.$$set && !is_empty(props)) {
this.$$.skip_bound = true;
this.$$set(props);
this.$$.skip_bound = false;
}
}
}
const PUBLIC_VERSION = "4";
if (typeof window !== "undefined")
(window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
var _a$1;
var __defProp$1 = Object.defineProperty;
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) ;
class Mirror {
constructor() {
__publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
__publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
}
getId(n2) {
var _a2;
if (!n2) return -1;
const id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
return id ?? -1;
}
getNode(id) {
return this.idNodeMap.get(id) || null;
}
getIds() {
return Array.from(this.idNodeMap.keys());
}
getMeta(n2) {
return this.nodeMetaMap.get(n2) || null;
}
// removes the node from idNodeMap
// doesn't remove the node from nodeMetaMap
removeNodeFromMap(n2) {
const id = this.getId(n2);
this.idNodeMap.delete(id);
if (n2.childNodes) {
n2.childNodes.forEach(
(childNode) => this.removeNodeFromMap(childNode)
);
}
}
has(id) {
return this.idNodeMap.has(id);
}
hasNode(node2) {
return this.nodeMetaMap.has(node2);
}
add(n2, meta) {
const id = meta.id;
this.idNodeMap.set(id, n2);
this.nodeMetaMap.set(n2, meta);
}
replace(id, n2) {
const oldNode = this.getNode(id);
if (oldNode) {
const meta = this.nodeMetaMap.get(oldNode);
if (meta) this.nodeMetaMap.set(n2, meta);
}
this.idNodeMap.set(id, n2);
}
reset() {
this.idNodeMap = /* @__PURE__ */ new Map();
this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
}
}
function createMirror$2() {
return new Mirror();
}
function getDefaultExportFromCjs$1(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
function getAugmentedNamespace$1(n2) {
if (n2.__esModule) return n2;
var f2 = n2.default;
if (typeof f2 == "function") {
var a2 = function a22() {
if (this instanceof a22) {
return Reflect.construct(f2, arguments, this.constructor);
}
return f2.apply(this, arguments);
};
a2.prototype = f2.prototype;
} else a2 = {};
Object.defineProperty(a2, "__esModule", { value: true });
Object.keys(n2).forEach(function(k) {
var d = Object.getOwnPropertyDescriptor(n2, k);
Object.defineProperty(a2, k, d.get ? d : {
enumerable: true,
get: function() {
return n2[k];
}
});
});
return a2;
}
var picocolors_browser$1 = { exports: {} };
var hasRequiredPicocolors_browser$1;
function requirePicocolors_browser$1() {
if (hasRequiredPicocolors_browser$1) return picocolors_browser$1.exports;
hasRequiredPicocolors_browser$1 = 1;
var x = String;
var create = function() {
return { isColorSupported: false, reset: x, bold: x, dim: x, italic: x, underline: x, inverse: x, hidden: x, strikethrough: x, black: x, red: x, green: x, yellow: x, blue: x, magenta: x, cyan: x, white: x, gray: x, bgBlack: x, bgRed: x, bgGreen: x, bgYellow: x, bgBlue: x, bgMagenta: x, bgCyan: x, bgWhite: x };
};
picocolors_browser$1.exports = create();
picocolors_browser$1.exports.createColors = create;
return picocolors_browser$1.exports;
}
const __viteBrowserExternal$2 = {};
const __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: __viteBrowserExternal$2
}, Symbol.toStringTag, { value: "Module" }));
const require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
var cssSyntaxError$1;
var hasRequiredCssSyntaxError$1;
function requireCssSyntaxError$1() {
if (hasRequiredCssSyntaxError$1) return cssSyntaxError$1;
hasRequiredCssSyntaxError$1 = 1;
let pico = /* @__PURE__ */ requirePicocolors_browser$1();
let terminalHighlight = require$$2$1;
class CssSyntaxError extends Error {
constructor(message, line, column, source, file, plugin) {
super(message);
this.name = "CssSyntaxError";
this.reason = message;
if (file) {
this.file = file;
}
if (source) {
this.source = source;
}
if (plugin) {
this.plugin = plugin;
}
if (typeof line !== "undefined" && typeof column !== "undefined") {
if (typeof line === "number") {
this.line = line;
this.column = column;
} else {
this.line = line.line;
this.column = line.column;
this.endLine = column.line;
this.endColumn = column.column;
}
}
this.setMessage();
if (Error.captureStackTrace) {
Error.captureStackTrace(this, CssSyntaxError);
}
}
setMessage() {
this.message = this.plugin ? this.plugin + ": " : "";
this.message += this.file ? this.file : "<css input>";
if (typeof this.line !== "undefined") {
this.message += ":" + this.line + ":" + this.column;
}
this.message += ": " + this.reason;
}
showSourceCode(color) {
if (!this.source) return "";
let css = this.source;
if (color == null) color = pico.isColorSupported;
if (terminalHighlight) {
if (color) css = terminalHighlight(css);
}
let lines = css.split(/\r?\n/);
let start = Math.max(this.line - 3, 0);
let end = Math.min(this.line + 2, lines.length);
let maxWidth = String(end).length;
let mark, aside;
if (color) {
let { bold, gray, red } = pico.createColors(true);
mark = (text2) => bold(red(text2));
aside = (text2) => gray(text2);
} else {
mark = aside = (str) => str;
}
return lines.slice(start, end).map((line, index2) => {
let number = start + 1 + index2;
let gutter = " " + (" " + number).slice(-maxWidth) + " | ";
if (number === this.line) {
let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, this.column - 1).replace(/[^\t]/g, " ");
return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
}
return " " + aside(gutter) + line;
}).join("\n");
}
toString() {
let code = this.showSourceCode();
if (code) {
code = "\n\n" + code + "\n";
}
return this.name + ": " + this.message + code;
}
}
cssSyntaxError$1 = CssSyntaxError;
CssSyntaxError.default = CssSyntaxError;
return cssSyntaxError$1;
}
var symbols$1 = {};
var hasRequiredSymbols$1;
function requireSymbols$1() {
if (hasRequiredSymbols$1) return symbols$1;
hasRequiredSymbols$1 = 1;
symbols$1.isClean = Symbol("isClean");
symbols$1.my = Symbol("my");
return symbols$1;
}
var stringifier$1;
var hasRequiredStringifier$1;
function requireStringifier$1() {
if (hasRequiredStringifier$1) return stringifier$1;
hasRequiredStringifier$1 = 1;
const DEFAULT_RAW = {
after: "\n",
beforeClose: "\n",
beforeComment: "\n",
beforeDecl: "\n",
beforeOpen: " ",
beforeRule: "\n",
colon: ": ",
commentLeft: " ",
commentRight: " ",
emptyBody: "",
indent: " ",
semicolon: false
};
function capitalize(str) {
return str[0].toUpperCase() + str.slice(1);
}
class Stringifier {
constructor(builder) {
this.builder = builder;
}
atrule(node2, semicolon) {
let name = "@" + node2.name;
let params = node2.params ? this.rawValue(node2, "params") : "";
if (typeof node2.raws.afterName !== "undefined") {
name += node2.raws.afterName;
} else if (params) {
name += " ";
}
if (node2.nodes) {
this.block(node2, name + params);
} else {
let end = (node2.raws.between || "") + (semicolon ? ";" : "");
this.builder(name + params + end, node2);
}
}
beforeAfter(node2, detect) {
let value;
if (node2.type === "decl") {
value = this.raw(node2, null, "beforeDecl");
} else if (node2.type === "comment") {
value = this.raw(node2, null, "beforeComment");
} else if (detect === "before") {
value = this.raw(node2, null, "beforeRule");
} else {
value = this.raw(node2, null, "beforeClose");
}
let buf = node2.parent;
let depth = 0;
while (buf && buf.type !== "root") {
depth += 1;
buf = buf.parent;
}
if (value.includes("\n")) {
let indent = this.raw(node2, null, "indent");
if (indent.length) {
for (let step = 0; step < depth; step++) value += indent;
}
}
return value;
}
block(node2, start) {
let between = this.raw(node2, "between", "beforeOpen");
this.builder(start + between + "{", node2, "start");
let after;
if (node2.nodes && node2.nodes.length) {
this.body(node2);
after = this.raw(node2, "after");
} else {
after = this.raw(node2, "after", "emptyBody");
}
if (after) this.builder(after);
this.builder("}", node2, "end");
}
body(node2) {
let last = node2.nodes.length - 1;
while (last > 0) {
if (node2.nodes[last].type !== "comment") break;
last -= 1;
}
let semicolon = this.raw(node2, "semicolon");
for (let i2 = 0; i2 < node2.nodes.length; i2++) {
let child = node2.nodes[i2];
let before = this.raw(child, "before");
if (before) this.builder(before);
this.stringify(child, last !== i2 || semicolon);
}
}
comment(node2) {
let left = this.raw(node2, "left", "commentLeft");
let right = this.raw(node2, "right", "commentRight");
this.builder("/*" + left + node2.text + right + "*/", node2);
}
decl(node2, semicolon) {
let between = this.raw(node2, "between", "colon");
let string = node2.prop + between + this.rawValue(node2, "value");
if (node2.important) {
string += node2.raws.important || " !important";
}
if (semicolon) string += ";";
this.builder(string, node2);
}
document(node2) {
this.body(node2);
}
raw(node2, own, detect) {
let value;
if (!detect) detect = own;
if (own) {
value = node2.raws[own];
if (typeof value !== "undefined") return value;
}
let parent = node2.parent;
if (detect === "before") {
if (!parent || parent.type === "root" && parent.first === node2) {
return "";
}
if (parent && parent.type === "document") {
return "";
}
}
if (!parent) return DEFAULT_RAW[detect];
let root2 = node2.root();
if (!root2.rawCache) root2.rawCache = {};
if (typeof root2.rawCache[detect] !== "undefined") {
return root2.rawCache[detect];
}
if (detect === "before" || detect === "after") {
return this.beforeAfter(node2, detect);
} else {
let method = "raw" + capitalize(detect);
if (this[method]) {
value = this[method](root2, node2);
} else {
root2.walk((i2) => {
value = i2.raws[own];
if (typeof value !== "undefined") return false;
});
}
}
if (typeof value === "undefined") value = DEFAULT_RAW[detect];
root2.rawCache[detect] = value;
return value;
}
rawBeforeClose(root2) {
let value;
root2.walk((i2) => {
if (i2.nodes && i2.nodes.length > 0) {
if (typeof i2.raws.after !== "undefined") {
value = i2.raws.after;
if (value.includes("\n")) {
value = value.replace(/[^\n]+$/, "");
}
return false;
}
}
});
if (value) value = value.replace(/\S/g, "");
return value;
}
rawBeforeComment(root2, node2) {
let value;
root2.walkComments((i2) => {
if (typeof i2.raws.before !== "undefined") {
value = i2.raws.before;
if (value.includes("\n")) {
value = value.replace(/[^\n]+$/, "");
}
return false;
}
});
if (typeof value === "undefined") {
value = this.raw(node2, null, "beforeDecl");
} else if (value) {
value = value.replace(/\S/g, "");
}
return value;
}
rawBeforeDecl(root2, node2) {
let value;
root2.walkDecls((i2) => {
if (typeof i2.raws.before !== "undefined") {
value = i2.raws.before;
if (value.includes("\n")) {
value = value.replace(/[^\n]+$/, "");
}
return false;
}
});
if (typeof value === "undefined") {
value = this.raw(node2, null, "beforeRule");
} else if (value) {
value = value.replace(/\S/g, "");
}
return value;
}
rawBeforeOpen(root2) {
let value;
root2.walk((i2) => {
if (i2.type !== "decl") {
value = i2.raws.between;
if (typeof value !== "undefined") return false;
}
});
return value;
}
rawBeforeRule(root2) {
let value;
root2.walk((i2) => {
if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
if (typeof i2.raws.before !== "undefined") {
value = i2.raws.before;
if (value.includes("\n")) {
value = value.replace(/[^\n]+$/, "");
}
return false;
}
}
});
if (value) value = value.replace(/\S/g, "");
return value;
}
rawColon(root2) {
let value;
root2.walkDecls((i2) => {
if (typeof i2.raws.between !== "undefined") {
value = i2.raws.between.replace(/[^\s:]/g, "");
return false;
}
});
return value;
}
rawEmptyBody(root2) {
let value;
root2.walk((i2) => {
if (i2.nodes && i2.nodes.length === 0) {
value = i2.raws.after;
if (typeof value !== "undefined") return false;
}
});
return value;
}
rawIndent(root2) {
if (root2.raws.indent) return root2.raws.indent;
let value;
root2.walk((i2) => {
let p = i2.parent;
if (p && p !== root2 && p.parent && p.parent === root2) {
if (typeof i2.raws.before !== "undefined") {
let parts = i2.raws.before.split("\n");
value = parts[parts.length - 1];
value = value.replace(/\S/g, "");
return false;
}
}
});
return value;
}
rawSemicolon(root2) {
let value;
root2.walk((i2) => {
if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
value = i2.raws.semicolon;
if (typeof value !== "undefined") return false;
}
});
return value;
}
rawValue(node2, prop) {
let value = node2[prop];
let raw = node2.raws[prop];
if (raw && raw.value === value) {
return raw.raw;
}
return value;
}
root(node2) {
this.body(node2);
if (node2.raws.after) this.builder(node2.raws.after);
}
rule(node2) {
this.block(node2, this.rawValue(node2, "selector"));
if (node2.raws.ownSemicolon) {
this.builder(node2.raws.ownSemicolon, node2, "end");
}
}
stringify(node2, semicolon) {
if (!this[node2.type]) {
throw new Error(
"Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier."
);
}
this[node2.type](node2, semicolon);
}
}
stringifier$1 = Stringifier;
Stringifier.default = Stringifier;
return stringifier$1;
}
var stringify_1$1;
var hasRequiredStringify$1;
function requireStringify$1() {
if (hasRequiredStringify$1) return stringify_1$1;
hasRequiredStringify$1 = 1;
let Stringifier = requireStringifier$1();
function stringify(node2, builder) {
let str = new Stringifier(builder);
str.stringify(node2);
}
stringify_1$1 = stringify;
stringify.default = stringify;
return stringify_1$1;
}
var node$1;
var hasRequiredNode$1;
function requireNode$1() {
if (hasRequiredNode$1) return node$1;
hasRequiredNode$1 = 1;
let { isClean, my } = requireSymbols$1();
let CssSyntaxError = requireCssSyntaxError$1();
let Stringifier = requireStringifier$1();
let stringify = requireStringify$1();
function cloneNode(obj, parent) {
let cloned = new obj.constructor();
for (let i2 in obj) {
if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
continue;
}
if (i2 === "proxyCache") continue;
let value = obj[i2];
let type = typeof value;
if (i2 === "parent" && type === "object") {
if (parent) cloned[i2] = parent;
} else if (i2 === "source") {
cloned[i2] = value;
} else if (Array.isArray(value)) {
cloned[i2] = value.map((j) => cloneNode(j, cloned));
} else {
if (type === "object" && value !== null) value = cloneNode(value);
cloned[i2] = value;
}
}
return cloned;
}
class Node2 {
constructor(defaults = {}) {
this.raws = {};
this[isClean] = false;
this[my] = true;
for (let name in defaults) {
if (name === "nodes") {
this.nodes = [];
for (let node2 of defaults[name]) {
if (typeof node2.clone === "function") {
this.append(node2.clone());
} else {
this.append(node2);
}
}
} else {
this[name] = defaults[name];
}
}
}
addToError(error) {
error.postcssNode = this;
if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
let s2 = this.source;
error.stack = error.stack.replace(
/\n\s{4}at /,
`$&${s2.input.from}:${s2.start.line}:${s2.start.column}$&`
);
}
return error;
}
after(add) {
this.parent.insertAfter(this, add);
return this;
}
assign(overrides = {}) {
for (let name in overrides) {
this[name] = overrides[name];
}
return this;
}
before(add) {
this.parent.insertBefore(this, add);
return this;
}
cleanRaws(keepBetween) {
delete this.raws.before;
delete this.raws.after;
if (!keepBetween) delete this.raws.between;
}
clone(overrides = {}) {
let cloned = cloneNode(this);
for (let name in overrides) {
cloned[name] = overrides[name];
}
return cloned;
}
cloneAfter(overrides = {}) {
let cloned = this.clone(overrides);
this.parent.insertAfter(this, cloned);
return cloned;
}
cloneBefore(overrides = {}) {
let cloned = this.clone(overrides);
this.parent.insertBefore(this, cloned);
return cloned;
}
error(message, opts = {}) {
if (this.source) {
let { end, start } = this.rangeBy(opts);
return this.source.input.error(
message,
{ column: start.column, line: start.line },
{ column: end.column, line: end.line },
opts
);
}
return new CssSyntaxError(message);
}
getProxyProcessor() {
return {
get(node2, prop) {
if (prop === "proxyOf") {
return node2;
} else if (prop === "root") {
return () => node2.root().toProxy();
} else {
return node2[prop];
}
},
set(node2, prop, value) {
if (node2[prop] === value) return true;
node2[prop] = value;
if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */
prop === "text") {
node2.markDirty();
}
return true;
}
};
}
markDirty() {
if (this[isClean]) {
this[isClean] = false;
let next = this;
while (next = next.parent) {
next[isClean] = false;
}
}
}
next() {
if (!this.parent) return void 0;
let index2 = this.parent.index(this);
return this.parent.nodes[index2 + 1];
}
positionBy(opts, stringRepresentation) {
let pos = this.source.start;
if (opts.index) {
pos = this.positionInside(opts.index, stringRepresentation);
} else if (opts.word) {
stringRepresentation = this.toString();
let index2 = stringRepresentation.indexOf(opts.word);
if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
}
return pos;
}
positionInside(index2, stringRepresentation) {
let string = stringRepresentation || this.toString();
let column = this.source.start.column;
let line = this.source.start.line;
for (let i2 = 0; i2 < index2; i2++) {
if (string[i2] === "\n") {
column = 1;
line += 1;
} else {
column += 1;
}
}
return { column, line };
}
prev() {
if (!this.parent) return void 0;
let index2 = this.parent.index(this);
return this.parent.nodes[index2 - 1];
}
rangeBy(opts) {
let start = {
column: this.source.start.column,
line: this.source.start.line
};
let end = this.source.end ? {
column: this.source.end.column + 1,
line: this.source.end.line
} : {
column: start.column + 1,
line: start.line
};
if (opts.word) {
let stringRepresentation = this.toString();
let index2 = stringRepresentation.indexOf(opts.word);
if (index2 !== -1) {
start = this.positionInside(index2, stringRepresentation);
end = this.positionInside(index2 + opts.word.length, stringRepresentation);
}
} else {
if (opts.start) {
start = {
column: opts.start.column,
line: opts.start.line
};
} else if (opts.index) {
start = this.positionInside(opts.index);
}
if (opts.end) {
end = {
column: opts.end.column,
line: opts.end.line
};
} else if (typeof opts.endIndex === "number") {
end = this.positionInside(opts.endIndex);
} else if (opts.index) {
end = this.positionInside(opts.index + 1);
}
}
if (end.line < start.line || end.line === start.line && end.column <= start.column) {
end = { column: start.column + 1, line: start.line };
}
return { end, start };
}
raw(prop, defaultType) {
let str = new Stringifier();
return str.raw(this, prop, defaultType);
}
remove() {
if (this.parent) {
this.parent.removeChild(this);
}
this.parent = void 0;
return this;
}
replaceWith(...nodes) {
if (this.parent) {
let bookmark = this;
let foundSelf = false;
for (let node2 of nodes) {
if (node2 === this) {
foundSelf = true;
} else if (foundSelf) {
this.parent.insertAfter(bookmark, node2);
bookmark = node2;
} else {
this.parent.insertBefore(bookmark, node2);
}
}
if (!foundSelf) {
this.remove();
}
}
return this;
}
root() {
let result2 = this;
while (result2.parent && result2.parent.type !== "document") {
result2 = result2.parent;
}
return result2;
}
toJSON(_, inputs) {
let fixed = {};
let emitInputs = inputs == null;
inputs = inputs || /* @__PURE__ */ new Map();
let inputsNextIndex = 0;
for (let name in this) {
if (!Object.prototype.hasOwnProperty.call(this, name)) {
continue;
}
if (name === "parent" || name === "proxyCache") continue;
let value = this[name];
if (Array.isArray(value)) {
fixed[name] = value.map((i2) => {
if (typeof i2 === "object" && i2.toJSON) {
return i2.toJSON(null, inputs);
} else {
return i2;
}
});
} else if (typeof value === "object" && value.toJSON) {
fixed[name] = value.toJSON(null, inputs);
} else if (name === "source") {
let inputId = inputs.get(value.input);
if (inputId == null) {
inputId = inputsNextIndex;
inputs.set(value.input, inputsNextIndex);
inputsNextIndex++;
}
fixed[name] = {
end: value.end,
inputId,
start: value.start
};
} else {
fixed[name] = value;
}
}
if (emitInputs) {
fixed.inputs = [...inputs.keys()].map((input2) => input2.toJSON());
}
return fixed;
}
toProxy() {
if (!this.proxyCache) {
this.proxyCache = new Proxy(this, this.getProxyProcessor());
}
return this.proxyCache;
}
toString(stringifier2 = stringify) {
if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
let result2 = "";
stringifier2(this, (i2) => {
result2 += i2;
});
return result2;
}
warn(result2, text2, opts) {
let data = { node: this };
for (let i2 in opts) data[i2] = opts[i2];
return result2.warn(text2, data);
}
get proxyOf() {
return this;
}
}
node$1 = Node2;
Node2.default = Node2;
return node$1;
}
var declaration$1;
var hasRequiredDeclaration$1;
function requireDeclaration$1() {
if (hasRequiredDeclaration$1) return declaration$1;
hasRequiredDeclaration$1 = 1;
let Node2 = requireNode$1();
class Declaration extends Node2 {
constructor(defaults) {
if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
defaults = { ...defaults, value: String(defaults.value) };
}
super(defaults);
this.type = "decl";
}
get variable() {
return this.prop.startsWith("--") || this.prop[0] === "$";
}
}
declaration$1 = Declaration;
Declaration.default = Declaration;
return declaration$1;
}
var nonSecure$1;
var hasRequiredNonSecure$1;
function requireNonSecure$1() {
if (hasRequiredNonSecure$1) return nonSecure$1;
hasRequiredNonSecure$1 = 1;
let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
let customAlphabet = (alphabet, defaultSize = 21) => {
return (size = defaultSize) => {
let id = "";
let i2 = size;
while (i2--) {
id += alphabet[Math.random() * alphabet.length | 0];
}
return id;
};
};
let nanoid = (size = 21) => {
let id = "";
let i2 = size;
while (i2--) {
id += urlAlphabet[Math.random() * 64 | 0];
}
return id;
};
nonSecure$1 = { nanoid, customAlphabet };
return nonSecure$1;
}
var previousMap$1;
var hasRequiredPreviousMap$1;
function requirePreviousMap$1() {
if (hasRequiredPreviousMap$1) return previousMap$1;
hasRequiredPreviousMap$1 = 1;
let { SourceMapConsumer, SourceMapGenerator } = require$$2$1;
let { existsSync, readFileSync } = require$$2$1;
let { dirname, join } = require$$2$1;
function fromBase64(str) {
if (Buffer) {
return Buffer.from(str, "base64").toString();
} else {
return window.atob(str);
}
}
class PreviousMap {
constructor(css, opts) {
if (opts.map === false) return;
this.loadAnnotation(css);
this.inline = this.startWith(this.annotation, "data:");
let prev = opts.map ? opts.map.prev : void 0;
let text2 = this.loadMap(opts.from, prev);
if (!this.mapFile && opts.from) {
this.mapFile = opts.from;
}
if (this.mapFile) this.root = dirname(this.mapFile);
if (text2) this.text = text2;
}
consumer() {
if (!this.consumerCache) {
this.consumerCache = new SourceMapConsumer(this.text);
}
return this.consumerCache;
}
decodeInline(text2) {
let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
let baseUri = /^data:application\/json;base64,/;
let charsetUri = /^data:application\/json;charset=utf-?8,/;
let uri = /^data:application\/json,/;
if (charsetUri.test(text2) || uri.test(text2)) {
return decodeURIComponent(text2.substr(RegExp.lastMatch.length));
}
if (baseCharsetUri.test(text2) || baseUri.test(text2)) {
return fromBase64(text2.substr(RegExp.lastMatch.length));
}
let encoding = text2.match(/data:application\/json;([^,]+),/)[1];
throw new Error("Unsupported source map encoding " + encoding);
}
getAnnotationURL(sourceMapString) {
return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
}
isMap(map) {
if (typeof map !== "object") return false;
return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
}
loadAnnotation(css) {
let comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
if (!comments) return;
let start = css.lastIndexOf(comments.pop());
let end = css.indexOf("*/", start);
if (start > -1 && end > -1) {
this.annotation = this.getAnnotationURL(css.substring(start, end));
}
}
loadFile(path) {
this.root = dirname(path);
if (existsSync(path)) {
this.mapFile = path;
return readFileSync(path, "utf-8").toString().trim();
}
}
loadMap(file, prev) {
if (prev === false) return false;
if (prev) {
if (typeof prev === "string") {
return prev;
} else if (typeof prev === "function") {
let prevPath = prev(file);
if (prevPath) {
let map = this.loadFile(prevPath);
if (!map) {
throw new Error(
"Unable to load previous source map: " + prevPath.toString()
);
}
return map;
}
} else if (prev instanceof SourceMapConsumer) {
return SourceMapGenerator.fromSourceMap(prev).toString();
} else if (prev instanceof SourceMapGenerator) {
return prev.toString();
} else if (this.isMap(prev)) {
return JSON.stringify(prev);
} else {
throw new Error(
"Unsupported previous source map format: " + prev.toString()
);
}
} else if (this.inline) {
return this.decodeInline(this.annotation);
} else if (this.annotation) {
let map = this.annotation;
if (file) map = join(dirname(file), map);
return this.loadFile(map);
}
}
startWith(string, start) {
if (!string) return false;
return string.substr(0, start.length) === start;
}
withContent() {
return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
}
}
previousMap$1 = PreviousMap;
PreviousMap.default = PreviousMap;
return previousMap$1;
}
var input$1;
var hasRequiredInput$1;
function requireInput$1() {
if (hasRequiredInput$1) return input$1;
hasRequiredInput$1 = 1;
let { SourceMapConsumer, SourceMapGenerator } = require$$2$1;
let { fileURLToPath, pathToFileURL } = require$$2$1;
let { isAbsolute, resolve } = require$$2$1;
let { nanoid } = /* @__PURE__ */ requireNonSecure$1();
let terminalHighlight = require$$2$1;
let CssSyntaxError = requireCssSyntaxError$1();
let PreviousMap = requirePreviousMap$1();
let fromOffsetCache = Symbol("fromOffsetCache");
let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
let pathAvailable = Boolean(resolve && isAbsolute);
class Input {
constructor(css, opts = {}) {
if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
throw new Error(`PostCSS received ${css} instead of CSS string`);
}
this.css = css.toString();
if (this.css[0] === "\uFEFF" || this.css[0] === "") {
this.hasBOM = true;
this.css = this.css.slice(1);
} else {
this.hasBOM = false;
}
if (opts.from) {
if (!pathAvailable || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
this.file = opts.from;
} else {
this.file = resolve(opts.from);
}
}
if (pathAvailable && sourceMapAvailable) {
let map = new PreviousMap(this.css, opts);
if (map.text) {
this.map = map;
let file = map.consumer().file;
if (!this.file && file) this.file = this.mapResolve(file);
}
}
if (!this.file) {
this.id = "<input css " + nanoid(6) + ">";
}
if (this.map) this.map.file = this.from;
}
error(message, line, column, opts = {}) {
let result2, endLine, endColumn;
if (line && typeof line === "object") {
let start = line;
let end = column;
if (typeof start.offset === "number") {
let pos = this.fromOffset(start.offset);
line = pos.line;
column = pos.col;
} else {
line = start.line;
column = start.column;
}
if (typeof end.offset === "number") {
let pos = this.fromOffset(end.offset);
endLine = pos.line;
endColumn = pos.col;
} else {
endLine = end.line;
endColumn = end.column;
}
} else if (!column) {
let pos = this.fromOffset(line);
line = pos.line;
column = pos.col;
}
let origin = this.origin(line, column, endLine, endColumn);
if (origin) {
result2 = new CssSyntaxError(
message,
origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line },
origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine },
origin.source,
origin.file,
opts.plugin
);
} else {
result2 = new CssSyntaxError(
message,
endLine === void 0 ? line : { column, line },
endLine === void 0 ? column : { column: endColumn, line: endLine },
this.css,
this.file,
opts.plugin
);
}
result2.input = { column, endColumn, endLine, line, source: this.css };
if (this.file) {
if (pathToFileURL) {
result2.input.url = pathToFileURL(this.file).toString();
}
result2.input.file = this.file;
}
return result2;
}
fromOffset(offset) {
let lastLine, lineToIndex;
if (!this[fromOffsetCache]) {
let lines = this.css.split("\n");
lineToIndex = new Array(lines.length);
let prevIndex = 0;
for (let i2 = 0, l2 = lines.length; i2 < l2; i2++) {
lineToIndex[i2] = prevIndex;
prevIndex += lines[i2].length + 1;
}
this[fromOffsetCache] = lineToIndex;
} else {
lineToIndex = this[fromOffsetCache];
}
lastLine = lineToIndex[lineToIndex.length - 1];
let min = 0;
if (offset >= lastLine) {
min = lineToIndex.length - 1;
} else {
let max = lineToIndex.length - 2;
let mid;
while (min < max) {
mid = min + (max - min >> 1);
if (offset < lineToIndex[mid]) {
max = mid - 1;
} else if (offset >= lineToIndex[mid + 1]) {
min = mid + 1;
} else {
min = mid;
break;
}
}
}
return {
col: offset - lineToIndex[min] + 1,
line: min + 1
};
}
mapResolve(file) {
if (/^\w+:\/\//.test(file)) {
return file;
}
return resolve(this.map.consumer().sourceRoot || this.map.root || ".", file);
}
origin(line, column, endLine, endColumn) {
if (!this.map) return false;
let consumer = this.map.consumer();
let from = consumer.originalPositionFor({ column, line });
if (!from.source) return false;
let to;
if (typeof endLine === "number") {
to = consumer.originalPositionFor({ column: endColumn, line: endLine });
}
let fromUrl;
if (isAbsolute(from.source)) {
fromUrl = pathToFileURL(from.source);
} else {
fromUrl = new URL(
from.source,
this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)
);
}
let result2 = {
column: from.column,
endColumn: to && to.column,
endLine: to && to.line,
line: from.line,
url: fromUrl.toString()
};
if (fromUrl.protocol === "file:") {
if (fileURLToPath) {
result2.file = fileURLToPath(fromUrl);
} else {
throw new Error(`file: protocol is not available in this PostCSS build`);
}
}
let source = consumer.sourceContentFor(from.source);
if (source) result2.source = source;
return result2;
}
toJSON() {
let json = {};
for (let name of ["hasBOM", "css", "file", "id"]) {
if (this[name] != null) {
json[name] = this[name];
}
}
if (this.map) {
json.map = { ...this.map };
if (json.map.consumerCache) {
json.map.consumerCache = void 0;
}
}
return json;
}
get from() {
return this.file || this.id;
}
}
input$1 = Input;
Input.default = Input;
if (terminalHighlight && terminalHighlight.registerInput) {
terminalHighlight.registerInput(Input);
}
return input$1;
}
var mapGenerator$1;
var hasRequiredMapGenerator$1;
function requireMapGenerator$1() {
if (hasRequiredMapGenerator$1) return mapGenerator$1;
hasRequiredMapGenerator$1 = 1;
let { SourceMapConsumer, SourceMapGenerator } = require$$2$1;
let { dirname, relative, resolve, sep } = require$$2$1;
let { pathToFileURL } = require$$2$1;
let Input = requireInput$1();
let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
let pathAvailable = Boolean(dirname && resolve && relative && sep);
class MapGenerator {
constructor(stringify, root2, opts, cssString) {
this.stringify = stringify;
this.mapOpts = opts.map || {};
this.root = root2;
this.opts = opts;
this.css = cssString;
this.originalCSS = cssString;
this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
this.memoizedFileURLs = /* @__PURE__ */ new Map();
this.memoizedPaths = /* @__PURE__ */ new Map();
this.memoizedURLs = /* @__PURE__ */ new Map();
}
addAnnotation() {
let content;
if (this.isInline()) {
content = "data:application/json;base64," + this.toBase64(this.map.toString());
} else if (typeof this.mapOpts.annotation === "string") {
content = this.mapOpts.annotation;
} else