import e from "./exponent.js";
import t from "./formatGroup.js";
import n from "./formatNumerals.js";
import r from "./formatSpecifier.js";
import i from "./formatTrim.js";
import { prefixExponent as a } from "./formatPrefixAuto.js";
import o from "./formatTypes.js";
import s from "./identity.js";
//#region ../../node_modules/d3-format/src/locale.js
var c = Array.prototype.map, l = [
	"y",
	"z",
	"a",
	"f",
	"p",
	"n",
	"µ",
	"m",
	"",
	"k",
	"M",
	"G",
	"T",
	"P",
	"E",
	"Z",
	"Y"
];
function u(u) {
	var d = u.grouping === void 0 || u.thousands === void 0 ? s : t(c.call(u.grouping, Number), u.thousands + ""), f = u.currency === void 0 ? "" : u.currency[0] + "", p = u.currency === void 0 ? "" : u.currency[1] + "", m = u.decimal === void 0 ? "." : u.decimal + "", h = u.numerals === void 0 ? s : n(c.call(u.numerals, String)), g = u.percent === void 0 ? "%" : u.percent + "", _ = u.minus === void 0 ? "−" : u.minus + "", v = u.nan === void 0 ? "NaN" : u.nan + "";
	function y(e, t) {
		e = r(e);
		var n = e.fill, s = e.align, c = e.sign, u = e.symbol, y = e.zero, b = e.width, x = e.comma, S = e.precision, C = e.trim, w = e.type;
		w === "n" ? (x = !0, w = "g") : o[w] || (S === void 0 && (S = 12), C = !0, w = "g"), (y || n === "0" && s === "=") && (y = !0, n = "0", s = "=");
		var T = (t && t.prefix !== void 0 ? t.prefix : "") + (u === "$" ? f : u === "#" && /[boxX]/.test(w) ? "0" + w.toLowerCase() : ""), E = (u === "$" ? p : /[%p]/.test(w) ? g : "") + (t && t.suffix !== void 0 ? t.suffix : ""), D = o[w], O = /[defgprs%]/.test(w);
		S = S === void 0 ? 6 : /[gprs]/.test(w) ? Math.max(1, Math.min(21, S)) : Math.max(0, Math.min(20, S));
		function k(e) {
			var t = T, r = E, o, u, f;
			if (w === "c") r = D(e) + r, e = "";
			else {
				e = +e;
				var p = e < 0 || 1 / e < 0;
				if (e = isNaN(e) ? v : D(Math.abs(e), S), C && (e = i(e)), p && +e == 0 && c !== "+" && (p = !1), t = (p ? c === "(" ? c : _ : c === "-" || c === "(" ? "" : c) + t, r = (w === "s" && !isNaN(e) && a !== void 0 ? l[8 + a / 3] : "") + r + (p && c === "(" ? ")" : ""), O) {
					for (o = -1, u = e.length; ++o < u;) if (f = e.charCodeAt(o), 48 > f || f > 57) {
						r = (f === 46 ? m + e.slice(o + 1) : e.slice(o)) + r, e = e.slice(0, o);
						break;
					}
				}
			}
			x && !y && (e = d(e, Infinity));
			var g = t.length + e.length + r.length, k = g < b ? Array(b - g + 1).join(n) : "";
			switch (x && y && (e = d(k + e, k.length ? b - r.length : Infinity), k = ""), s) {
				case "<":
					e = t + e + r + k;
					break;
				case "=":
					e = t + k + e + r;
					break;
				case "^":
					e = k.slice(0, g = k.length >> 1) + t + e + r + k.slice(g);
					break;
				default:
					e = k + t + e + r;
					break;
			}
			return h(e);
		}
		return k.toString = function() {
			return e + "";
		}, k;
	}
	function b(t, n) {
		var i = Math.max(-8, Math.min(8, Math.floor(e(n) / 3))) * 3, a = 10 ** -i, o = y((t = r(t), t.type = "f", t), { suffix: l[8 + i / 3] });
		return function(e) {
			return o(a * e);
		};
	}
	return {
		format: y,
		formatPrefix: b
	};
}
//#endregion
export { u as default };
