import { webcrypto, createHash } from 'node:crypto';
import { createRequire } from 'node:module';
import path, { resolve as resolve$1, join, sep as sep$1, normalize as normalize$3 } from 'node:path';
import { fileURLToPath, URL as URL$1, pathToFileURL } from 'node:url';
import * as fs$2 from 'node:fs';
import fs__default, { statSync } from 'node:fs';
import 'node:fs/promises';
import process$2, { stdin, stdout } from 'node:process';
import * as vite from 'vite';
import { normalizePath as normalizePath$1, loadConfigFromFile, createLogger, mergeConfig as mergeConfig$1, searchForWorkspaceRoot, build as build$9, transformWithEsbuild, createServer as createServer$1 } from 'vite';
import { inspect, formatWithOptions, stripVTControlCharacters } from 'node:util';
import { Transform } from 'node:stream';
import k$1 from 'node:readline';
import 'node:child_process';
import zlib from 'node:zlib';
import 'node:stream/promises';
import { isBooleanAttr } from '@vue/shared';
import { isatty } from 'node:tty';
import require$$4 from 'util';
import http from 'node:http';
import { setImmediate } from 'node:timers';
import * as qs from 'node:querystring';
import require$$1, { sep, basename, dirname, resolve as resolve$2, normalize as normalize$2, relative, posix, join as join$1 } from 'path';
import * as nativeFs from 'fs';
import nativeFs__default, { readdirSync, statSync as statSync$1 } from 'fs';
import require$$0 from 'constants';
import require$$0$1 from 'stream';
import require$$5 from 'assert';
import { fileURLToPath as fileURLToPath$1 } from 'url';
import { createRequire as createRequire$1 } from 'module';
import { transformerMetaHighlight, transformerNotationDiff, transformerNotationFocus, transformerNotationHighlight, transformerNotationErrorLevel } from '@shikijs/transformers';
import { createHighlighter, isSpecialLang, guessEmbeddedLanguages } from 'shiki';
import require$$0$2 from 'child_process';
import MiniSearch from 'minisearch';
/** Default values for dimensions */
const defaultIconDimensions = Object.freeze({
left: 0,
top: 0,
width: 16,
height: 16
});
/** Default values for transformations */
const defaultIconTransformations = Object.freeze({
rotate: 0,
vFlip: false,
hFlip: false
});
/** Default values for all optional IconifyIcon properties */
const defaultIconProps = Object.freeze({
...defaultIconDimensions,
...defaultIconTransformations
});
/** Default values for all properties used in ExtendedIconifyIcon */
const defaultExtendedIconProps = Object.freeze({
...defaultIconProps,
body: "",
hidden: false
});
/**
* Default icon customisations values
*/
const defaultIconSizeCustomisations = Object.freeze({
width: null,
height: null
});
const defaultIconCustomisations = Object.freeze({
...defaultIconSizeCustomisations,
...defaultIconTransformations
});
/**
* Merge transformations
*/
function mergeIconTransformations(obj1, obj2) {
const result = {};
if (!obj1.hFlip !== !obj2.hFlip) result.hFlip = true;
if (!obj1.vFlip !== !obj2.vFlip) result.vFlip = true;
const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
if (rotate) result.rotate = rotate;
return result;
}
/**
* Merge icon and alias
*
* Can also be used to merge default values and icon
*/
function mergeIconData(parent, child) {
const result = mergeIconTransformations(parent, child);
for (const key in defaultExtendedIconProps) if (key in defaultIconTransformations) {
if (key in parent && !(key in result)) result[key] = defaultIconTransformations[key];
} else if (key in child) result[key] = child[key];
else if (key in parent) result[key] = parent[key];
return result;
}
/**
* Make icon square
*/
/**
* Make icon viewBox square
*/
function makeViewBoxSquare(viewBox) {
const [left, top, width, height] = viewBox;
if (width !== height) {
const max = Math.max(width, height);
return [
left - (max - width) / 2,
top - (max - height) / 2,
max,
max
];
}
return viewBox;
}
/**
* Resolve icon set icons
*
* Returns parent icon for each icon
*/
function getIconsTree(data, names) {
const icons = data.icons;
const aliases = data.aliases || Object.create(null);
const resolved = Object.create(null);
function resolve(name) {
if (icons[name]) return resolved[name] = [];
if (!(name in resolved)) {
resolved[name] = null;
const parent = aliases[name] && aliases[name].parent;
const value = parent && resolve(parent);
if (value) resolved[name] = [parent].concat(value);
}
return resolved[name];
}
(names || Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
return resolved;
}
/**
* Get icon data, using prepared aliases tree
*/
function internalGetIconData(data, name, tree) {
const icons = data.icons;
const aliases = data.aliases || Object.create(null);
let currentProps = {};
function parse(name$1) {
currentProps = mergeIconData(icons[name$1] || aliases[name$1], currentProps);
}
parse(name);
tree.forEach(parse);
return mergeIconData(data, currentProps);
}
/**
* Get data for icon
*/
function getIconData(data, name) {
if (data.icons[name]) return internalGetIconData(data, name, []);
const tree = getIconsTree(data, [name])[name];
return tree ? internalGetIconData(data, name, tree) : null;
}
/**
* Optional properties
*/
({
...defaultIconDimensions
});
/**
* Optional properties that must be copied when copying icon set
*/
Object.keys(defaultIconDimensions).concat(["provider"]);
/**
* Regular expressions for calculating dimensions
*/
const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
function calculateSize(size, ratio, precision) {
if (ratio === 1) return size;
precision = precision || 100;
if (typeof size === "number") return Math.ceil(size * ratio * precision) / precision;
if (typeof size !== "string") return size;
const oldParts = size.split(unitsSplit);
if (oldParts === null || !oldParts.length) return size;
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 splitSVGDefs(content, tag = "defs") {
let defs = "";
const index = content.indexOf("<" + tag);
while (index >= 0) {
const start = content.indexOf(">", index);
const end = content.indexOf("" + tag);
if (start === -1 || end === -1) break;
const endEnd = content.indexOf(">", end);
if (endEnd === -1) break;
defs += content.slice(start + 1, end).trim();
content = content.slice(0, index).trim() + content.slice(endEnd + 1);
}
return {
defs,
content
};
}
/**
* Merge defs and content
*/
function mergeDefsAndContent(defs, content) {
return defs ? "" + defs + "" + content : content;
}
/**
* Wrap SVG content, without wrapping definitions
*/
function wrapSVGContent(body, start, end) {
const split = splitSVGDefs(body);
return mergeDefsAndContent(split.defs, start + split.content + end);
}
/**
* Check if value should be unset. Allows multiple keywords
*/
const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
/**
* Get SVG attributes and content from icon + customisations
*
* Does not generate style to make it compatible with frameworks that use objects for style, such as React.
* Instead, it generates 'inline' value. If true, rendering engine should add verticalAlign: -0.125em to icon.
*
* Customisations should be normalised by platform specific parser.
* Result should be converted to