@imgproxy/imgproxy-js-core
Version:
imgproxy-js-core package is designed to be used as part of framework-specific packages and plugins.
1,316 lines • 52.6 kB
JavaScript
const l = (t) => t === !0 || t === "t" || t === 1 ? "t" : "f", _ = (t) => `${t}${t.includes(".") ? "" : " option"}`;
function n(t, e, o) {
if (t === void 0)
throw new Error(
`${_(e)} is undefined${o ? `. ${o}` : ""}`
);
}
function z(t, e, o, r) {
return `${_(t)} value can't be less${r ? " or equal" : ""} than ${e}${o ? `. ${o}` : ""}`;
}
function i(t, e, o) {
if (typeof t != "number")
throw new Error(
`${_(e)} is not a number${o != null && o.addInfo ? `. ${o == null ? void 0 : o.addInfo}` : ""}`
);
if (!(o != null && o.addParam)) return;
const r = o.addParam, s = o == null ? void 0 : o.addInfo;
if (r.min !== void 0) {
if (r.minEqual && t <= r.min)
throw new Error(z(e, r.min, s, !0));
if (t < r.min)
throw new Error(z(e, r.min, s));
if (r.max !== void 0 && t > r.max)
throw new Error(
`${_(e)} value can't be more than ${r.max}${s ? `. ${s}` : ""}`
);
}
if (r.isInt && !Number.isInteger(t))
throw new Error(`${_(e)} is must be an integer`);
}
function d(t, e, o) {
const r = `Valid values are: ${Object.keys(t).join(", ")}`;
if (!t[e])
throw new Error(`${_(o)} is invalid. ${r}`);
}
function ze(t, e, o) {
if (!t.includes(e)) {
const r = `Valid values are: ${t.join(", ")}`;
throw new Error(`${_(o)} is invalid. ${r}`);
}
}
function b(t, e, o) {
if (typeof t != "string")
throw new Error(`${_(e)} is not a string`);
if (o) {
if (t.match(/[^0-9a-fA-F]/))
throw new Error(`${_(e)} must be hexadecimal`);
if (t.length !== 3 && t.length !== 6 && t.length !== 8)
throw new Error(
`${_(e)} must be 3, 6 or 8 characters long (with alpha)`
);
}
}
function f(t, e) {
if (!Array.isArray(t))
throw new Error(`${_(e)} is not an array`);
if (t.length === 0)
throw new Error(`${_(e)} is empty`);
}
function p(t, e) {
if (typeof t != "boolean")
throw new Error(`${_(e)} is not a boolean`);
}
const B = (t) => t.adjust || t.a, xe = (t) => !!B(t), Te = (t) => {
const e = B(t);
n(e, "adjust"), e.brightness !== void 0 && i(e.brightness, "adjust.brightness", {
addParam: { min: -255, max: 255 }
});
const o = e.brightness ?? "", r = e.contrast ?? "", s = e.saturation ?? "";
return `a:${o}:${r}:${s}`;
}, Me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Te,
test: xe
}, Symbol.toStringTag, { value: "Module" })), ke = {
none: !0,
size: !0,
dssim: !0,
ml: !0
}, q = (t) => t.autoquality || t.aq, Be = (t) => !!q(t), qe = (t) => {
const e = q(t);
n(e, "autoquality");
const { method: o, target: r, min_quality: s, max_quality: a, allowed_error: c } = e;
if (o && d(ke, o, "autoquality.method"), r !== void 0 && i(r, "autoquality.target", {
addParam: { min: 0 }
}), s !== void 0 && i(s, "autoquality.min_quality", {
addParam: { min: 0, max: 100 }
}), a !== void 0 && i(a, "autoquality.max_quality", {
addParam: { min: 0, max: 100 }
}), c !== void 0) {
if (o !== "dssim" && o !== "ml")
throw new Error(
"autoquality.allowed_error is applicable only to dssim and ml methods"
);
i(c, "autoquality.allowed_error", {
addParam: { min: 0, max: 1 }
});
}
return `aq:${o ?? ""}:${r ?? ""}:${s ?? ""}:${a ?? ""}:${c ?? ""}`.replace(/:+$/, "");
}, Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: qe,
test: Be
}, Symbol.toStringTag, { value: "Module" })), E = (t) => {
if ("auto_rotate" in t)
return t.auto_rotate;
if ("ar" in t)
return t.ar;
}, Ae = (t) => E(t) !== void 0, Ie = (t) => {
const e = E(t);
return n(e, "auto_rotate"), `ar:${l(e)}`;
}, Ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Ie,
test: Ae
}, Symbol.toStringTag, { value: "Module" })), Fe = {
auto: !0,
on: !0,
off: !0
}, A = (t) => t.avif_options || t.avifo, Ne = (t) => !!A(t), Re = (t) => {
const e = A(t);
let o;
return n(e, "avif_options"), typeof e == "string" ? o = e : o = e.subsample, d(Fe, o, "avif_options"), `avifo:${o}`;
}, Ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Re,
test: Ne
}, Symbol.toStringTag, { value: "Module" })), I = (t) => t.background || t.bg, He = (t) => !!I(t), Ce = (t) => {
const e = I(t);
if (n(e, "background"), typeof e == "number")
throw new Error("background option is not a string or object");
return typeof e == "string" ? (b(e, "background", !0), `bg:${e}`) : (n(e.r, "background.r"), n(e.g, "background.g"), n(e.b, "background.b"), i(e.r, "background.r"), i(e.g, "background.g"), i(e.b, "background.b"), `bg:${e.r}:${e.g}:${e.b}`);
}, De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Ce,
test: He
}, Symbol.toStringTag, { value: "Module" })), V = (t) => t.background_alpha ?? t.bga, Qe = (t) => !!V(t), Xe = (t) => {
const e = V(t);
return n(e, "background_alpha"), i(e, "background_alpha", {
addParam: { min: 0, max: 1 }
}), `background_alpha:${e}`;
}, We = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Xe,
test: Qe
}, Symbol.toStringTag, { value: "Module" })), F = (t) => t.blur ?? t.bl, Je = (t) => !!F(t), Ye = (t) => {
const e = F(t);
return n(e, "blur"), i(e, "blur", { addParam: { min: 0 } }), `bl:${e}`;
}, Ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Ye,
test: Je
}, Symbol.toStringTag, { value: "Module" })), N = (t) => t.blur_areas ?? t.ba, Ke = (t) => !!N(t), Le = (t) => {
const e = N(t);
n(e, "blur_areas"), i(e.sigma, "blur_areas.sigma", {
addParam: { min: 0 }
}), f(e.areas, "blur_areas.areas");
const o = [e.sigma];
return e.areas.forEach((r, s) => {
i(r == null ? void 0 : r.left, `blur_areas.areas[${s}].left`, {
addParam: { min: 0, max: 1 }
}), i(r.top, `blur_areas.areas[${s}].top`, {
addParam: { min: 0, max: 1 }
}), i(r.width, `blur_areas.areas[${s}].width`, {
addParam: { min: 0, max: 1 }
}), i(r.height, `blur_areas.areas[${s}].height`, {
addParam: { min: 0, max: 1 }
}), o.push(r.left, r.top, r.width, r.height);
}), `ba:${o.join(":")}`;
}, Ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Le,
test: Ke
}, Symbol.toStringTag, { value: "Module" })), R = (t) => t.blur_detections || t.bd, to = (t) => !!R(t), eo = (t) => {
const e = R(t);
n(e, "blur_detections"), n(e.sigma, "blur_detections.sigma"), i(e.sigma, "blur_detections.sigma");
const o = e.sigma, r = e.class_names ? e.class_names.join(":") : "";
return `bd:${o}:${r}`.replace(/:+$/, "");
}, oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: eo,
test: to
}, Symbol.toStringTag, { value: "Module" })), U = (t) => t.brightness ?? t.br, ro = (t) => !!U(t), no = (t) => {
const e = U(t);
return n(e, "brightness"), i(e, "brightness", {
addParam: { min: -255, max: 255 }
}), `br:${e}`;
}, so = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: no,
test: ro
}, Symbol.toStringTag, { value: "Module" })), H = (t) => t.cachebuster || t.cb, io = (t) => !!H(t), ao = (t) => {
const e = H(t);
return n(e, "cachebuster"), b(e, "cachebuster"), `cb:${e}`;
}, C = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ao,
test: io
}, Symbol.toStringTag, { value: "Module" })), D = (t) => {
if ("color_profile" in t)
return t.color_profile;
if ("cp" in t)
return t.cp;
if ("icc" in t)
return t.icc;
}, lo = (t) => D(t) !== void 0, co = (t) => {
const e = D(t);
return n(e, "color_profile"), `cp:${e}`;
}, uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: co,
test: lo
}, Symbol.toStringTag, { value: "Module" })), Q = (t) => t.colorize ?? t.col, _o = (t) => !!Q(t), bo = (t) => {
const e = Q(t);
n(e, "colorize");
const { opacity: o, color: r, keepAlpha: s } = e;
i(o, "colorize.opacity", {
addParam: {
min: 0,
max: 1
}
});
let a = `col:${o}`;
return r && (a += `:${r}`), s !== void 0 && (r || (a += ":"), a += `:${s ? 1 : 0}`), a;
}, mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: bo,
test: _o
}, Symbol.toStringTag, { value: "Module" })), X = (t) => t.contrast ?? t.co, po = (t) => !!X(t), fo = (t) => {
const e = X(t);
return n(e, "contrast"), i(e, "contrast", { addParam: { min: 0 } }), `co:${e}`;
}, go = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: fo,
test: po
}, Symbol.toStringTag, { value: "Module" })), W = {
no: !0,
so: !0,
ea: !0,
we: !0,
ce: !0,
noea: !0,
nowe: !0,
soea: !0,
sowe: !0
}, $o = {
...W,
sm: !0,
fp: !0,
obj: !0,
objw: !0
}, J = (t) => t.gravity || t.g, O = (t) => !!J(t), y = (t, e) => `${e ? "" : "g:"}${t.replace(/:+$/, "")}`, v = (t, e = {}) => {
const { headless: o = !1 } = e, r = J(t);
n(r, "gravity"), n(r.type, "gravity.type");
const s = r.type;
if (d($o, s, "gravity.type"), (r.x_offset || r.y_offset) && d(W, s, "gravity.type"), r.class_names && s !== "obj")
throw new Error("gravity.class_names can be used only with type obj");
if (r.class_weights && s !== "objw")
throw new Error("gravity.class_weights can be used only with type objw");
if ((r.x || r.y) && s !== "fp")
throw new Error("gravity.x and gravity.y can be used only with type fp");
if (s === "sm")
return y(s, o);
if (s === "fp") {
const a = r;
return n(a.x, "gravity.x"), n(a.y, "gravity.y"), i(a.x, "gravity.x", { addParam: { min: 0, max: 1 } }), i(a.y, "gravity.y", { addParam: { min: 0, max: 1 } }), y(`${s}:${a.x}:${a.y}`, o);
}
if (s === "obj") {
const a = r;
n(r.class_names, "gravity.class_names"), f(a.class_names, "gravity.class_names");
const c = a.class_names;
return y(`${s}:${c.join(":")}`, o);
}
if (s === "objw") {
const a = r;
n(a.class_weights, "gravity.class_weights"), f(a.class_weights, "gravity.class_weights");
const c = a.class_weights.map((u) => {
if (typeof u != "object" || !u.class || typeof u.weight != "number")
throw new Error(
"Each item in gravity.class_weights must have 'class' and 'weight' properties"
);
return `${u.class}:${u.weight}`;
});
return y(`${s}:${c.join(":")}`, o);
} else {
const a = r, c = a.x_offset === void 0 ? "" : a.x_offset, u = a.y_offset === void 0 ? "" : a.y_offset;
return y(`${a.type}:${c}:${u}`, o);
}
}, yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: v,
test: O
}, Symbol.toStringTag, { value: "Module" })), Y = (t) => t.crop || t.c, Oo = (t) => !!Y(t), vo = (t) => {
const e = Y(t);
n(e, "crop");
const { width: o, height: r } = e;
n(o, "crop.width"), n(r, "crop.height"), i(o, "crop.width", { addParam: { min: 0 } }), i(r, "crop.height", { addParam: { min: 0 } });
const s = O(e) ? v(e, { headless: !0 }) : "";
return `c:${o}:${r}:${s}`.replace(/:+$/, "");
}, G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: vo,
test: Oo
}, Symbol.toStringTag, { value: "Module" })), K = (t) => t.crop_aspect_ratio || t.crop_ar || t.car, ho = (t) => !!K(t), jo = (t) => {
const e = K(t);
n(e, "crop_aspect_ratio");
const { aspect_ratio: o, enlarge: r } = e;
n(o, "crop_aspect_ratio.aspect_ratio"), i(o, "crop_aspect_ratio.aspect_ratio", {
addParam: { min: 0 }
});
let s = `crop_ar:${o}`;
return r !== void 0 && (s += `:${l(r)}`), s;
}, wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: jo,
test: ho
}, Symbol.toStringTag, { value: "Module" })), L = (t) => {
if ("disable_animation" in t)
return t.disable_animation;
if ("da" in t)
return t.da;
}, So = (t) => L(t) !== void 0, Po = (t) => {
const e = L(t);
return n(e, "disable_animation"), `da:${l(e)}`;
}, zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Po,
test: So
}, Symbol.toStringTag, { value: "Module" })), Z = (t) => t.duotone ?? t.dt, xo = (t) => !!Z(t), To = (t) => {
const e = Z(t);
n(e, "duotone");
const { intensity: o, color1: r = "", color2: s = "" } = e;
return i(o, "duotone.intensity", {
addParam: {
min: 0,
max: 1
}
}), s ? `dt:${o}:${r}:${s}` : r ? `dt:${o}:${r}` : `dt:${o}`;
}, Mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: To,
test: xo
}, Symbol.toStringTag, { value: "Module" })), tt = (t) => t.dpi, ko = (t) => !!tt(t), Bo = (t) => {
const e = tt(t);
return n(e, "dpi"), i(e, "dpi"), `dpi:${e}`;
}, qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Bo,
test: ko
}, Symbol.toStringTag, { value: "Module" })), et = (t) => t.dpr, Eo = (t) => !!et(t), Ao = (t) => {
const e = et(t);
return n(e, "dpr"), i(e, "dpr", { addParam: { min: 0 } }), `dpr:${e}`;
}, Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Ao,
test: Eo
}, Symbol.toStringTag, { value: "Module" })), ot = (t) => t.draw_detections || t.dd, Vo = (t) => !!ot(t), Fo = (t) => {
const e = ot(t);
n(e, "draw_detections"), n(e.draw, "draw_detections.draw");
const o = l(e.draw), r = e.class_names ? `:${e.class_names.join(":")}` : "";
return `dd:${o}${r}`;
}, No = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Fo,
test: Vo
}, Symbol.toStringTag, { value: "Module" })), rt = (t) => {
if ("enforce_thumbnail" in t)
return t.enforce_thumbnail;
if ("eth" in t)
return t.eth;
}, Ro = (t) => rt(t) !== void 0, Uo = (t) => {
const e = rt(t);
return n(e, "enforce_thumbnail"), `eth:${l(e)}`;
}, Ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Uo,
test: Ro
}, Symbol.toStringTag, { value: "Module" })), nt = (t) => {
if ("enlarge" in t)
return t.enlarge;
if ("el" in t)
return t.el;
}, Co = (t) => nt(t) !== void 0, Do = (t) => {
const e = nt(t);
return n(e, "enlarge"), `el:${l(e)}`;
}, Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Do,
test: Co
}, Symbol.toStringTag, { value: "Module" })), st = (t) => t.expires || t.exp, Xo = (t) => !!st(t), Wo = (t) => {
const e = st(t);
return n(e, "expires"), i(e, "expires"), `exp:${e}`;
}, it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Wo,
test: Xo
}, Symbol.toStringTag, { value: "Module" })), at = (t) => t.extend || t.ex, w = (t) => !!at(t), Jo = (t, e) => `${e ? "" : "ex:"}${t.replace(/:+$/, "")}`, S = (t, e = {}) => {
const { headless: o = !1 } = e, r = at(t);
n(r, "extend"), n(r.extend, "extend.extend");
const s = O(r) ? `:${v(r, { headless: !0 })}` : "";
return Jo(`${l(r.extend)}${s}`, o);
}, Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: S,
test: w
}, Symbol.toStringTag, { value: "Module" })), lt = (t) => t.extend_aspect_ratio || t.exar || t.extend_ar, Go = (t) => !!lt(t), Ko = (t) => {
const e = lt(t);
n(e, "extend_aspect_ratio"), n(e.extend, "extend_aspect_ratio.extend");
const o = O(e) ? `:${v(e, { headless: !0 })}` : "";
return `exar:${l(e.extend)}${o}`;
}, Lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Ko,
test: Go
}, Symbol.toStringTag, { value: "Module" })), ct = (t) => t.fallback_image_url || t.fiu, Zo = (t) => !!ct(t), tr = (t) => {
const e = ct(t);
return n(e, "fallback_image_url"), b(e, "fallback_image_url"), `fiu:${e}`;
}, er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: tr,
test: Zo
}, Symbol.toStringTag, { value: "Module" })), ut = (t) => t.filename || t.fn, or = (t) => !!ut(t), rr = (t) => {
const e = ut(t);
n(e, "filename"), n(e.name, "filename.name"), b(e.name, "filename.name");
const o = e.encoded === void 0 ? "" : `:${l(e.encoded)}`;
return `fn:${e.name}${o}`;
}, nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: rr,
test: or
}, Symbol.toStringTag, { value: "Module" })), dt = (t) => t.flip || t.fl, sr = (t) => !!dt(t), ir = (t) => {
const e = dt(t);
n(e, "flip");
const o = e.horizontal ?? !1, r = e.vertical ?? !1;
return `fl:${l(o)}:${l(r)}`;
}, ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ir,
test: sr
}, Symbol.toStringTag, { value: "Module" })), lr = {
png: !0,
jpg: !0,
jxl: !0,
webp: !0,
avif: !0,
gif: !0,
ico: !0,
svg: !0,
bmp: !0,
tiff: !0,
mp4: !0,
pdf: !0,
best: !0
}, _t = (t) => t.format || t.f || t.ext, cr = (t) => !!_t(t), ur = (t) => {
const e = _t(t);
return n(e, "format"), d(lr, e, "format"), `f:${e}`;
}, dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ur,
test: cr
}, Symbol.toStringTag, { value: "Module" })), bt = (t) => t.format_quality || t.fq, _r = (t) => !!bt(t), br = (t) => {
const e = bt(t);
n(e, "format_quality"), f(e, "format_quality");
const o = [];
return e.forEach((r) => {
o.push(`${r.format}:${r.quality}`);
}), `fq:${o.join(":")}`;
}, mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: br,
test: _r
}, Symbol.toStringTag, { value: "Module" })), pr = {
down: !0,
up: !0,
right: !0,
left: !0
}, mt = (t) => t.gradient || t.gr, fr = (t) => !!mt(t), gr = (t) => {
const e = mt(t);
n(e, "gradient");
const { opacity: o, color: r, direction: s, start: a, stop: c } = e;
return n(o, "gradient.opacity"), i(o, "gradient.opacity", {
addParam: { min: 0, max: 1 }
}), r && b(r, "gradient.color", !0), s && (typeof s == "number" ? i(s, "gradient.direction") : (b(s, "gradient.direction"), d(pr, s, "gradient.direction"))), a && i(a, "gradient.start", { addParam: { min: 0, max: 1 } }), c && i(c, "gradient.stop", { addParam: { min: 0, max: 1 } }), `gr:${o}:${r || ""}:${s || ""}:${a || ""}:${c || ""}`.replace(/:+$/, "");
}, $r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: gr,
test: fr
}, Symbol.toStringTag, { value: "Module" })), pt = (t) => t.height ?? t.h, yr = (t) => !!pt(t), Or = (t) => {
const e = pt(t);
return n(e, "height"), i(e, "height", { addParam: { min: 0 } }), `h:${e}`;
}, vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Or,
test: yr
}, Symbol.toStringTag, { value: "Module" })), ft = (t) => t.jpeg_options || t.jpgo, hr = (t) => !!ft(t), jr = (t) => {
const e = ft(t);
n(e, "jpeg_options");
const {
progressive: o,
no_subsample: r,
trellis_quant: s,
overshoot_deringing: a,
optimize_scans: c,
quant_table: u
} = e;
if (o && p(o, "jpeg_options.progressive"), r && p(r, "jpeg_options.no_subsample"), s && p(s, "jpeg_options.trellis_quant"), a && p(a, "jpeg_options.overshoot_deringing"), c && (p(c, "jpeg_options.optimize_scans"), o === !1))
throw new Error(
"jpeg_options.progressive must be true if jpeg_options.optimize_scans is true"
);
return u && i(u, "jpeg_options.quant_table", {
addParam: { min: 0, max: 8 }
}), `jpgo:${o === void 0 ? "" : o}:${r === void 0 ? "" : r}:${s === void 0 ? "" : s}:${a === void 0 ? "" : a}:${c === void 0 ? "" : c}:${u === void 0 ? "" : u}`.replace(/:+$/, "");
}, wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: jr,
test: hr
}, Symbol.toStringTag, { value: "Module" })), gt = (t) => {
if ("keep_copyright" in t)
return t.keep_copyright;
if ("kcr" in t)
return t.kcr;
}, Sr = (t) => gt(t) !== void 0, Pr = (t) => {
const e = gt(t);
return n(e, "keep_copyright"), `kcr:${l(e)}`;
}, zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Pr,
test: Sr
}, Symbol.toStringTag, { value: "Module" })), $t = (t) => {
if ("max_animation_frames" in t)
return t.max_animation_frames;
if ("maf" in t)
return t.maf;
}, xr = (t) => $t(t) !== void 0, Tr = (t) => {
const e = $t(t);
return n(e, "max_animation_frames"), i(e, "max_animation_frames", {
addParam: { min: 0, minEqual: !0 }
}), `maf:${e}`;
}, Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Tr,
test: xr
}, Symbol.toStringTag, { value: "Module" })), yt = (t) => {
if ("max_animation_frame_resolution" in t)
return t.max_animation_frame_resolution;
if ("mafr" in t)
return t.mafr;
}, kr = (t) => yt(t) !== void 0, Br = (t) => {
const e = yt(t);
return n(e, "max_animation_frame_resolution"), i(e, "max_animation_frame_resolution", {
addParam: { min: 0 }
}), `mafr:${e}`;
}, qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Br,
test: kr
}, Symbol.toStringTag, { value: "Module" })), Ot = (t) => t.max_bytes ?? t.mb, Er = (t) => !!Ot(t), Ar = (t) => {
const e = Ot(t);
return n(e, "max_bytes"), i(e, "max_bytes", { addParam: { min: 0 } }), `mb:${e}`;
}, Ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Ar,
test: Er
}, Symbol.toStringTag, { value: "Module" })), vt = (t) => t.max_result_dimension ?? t.mrd, Vr = (t) => vt(t) !== void 0, Fr = (t) => {
const e = vt(t);
return n(e, "max_result_dimension"), i(e, "max_result_dimension", {
addParam: { min: 0 }
}), `mrd:${e}`;
}, Nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Fr,
test: Vr
}, Symbol.toStringTag, { value: "Module" })), ht = [
"no",
"so",
"ea",
"we",
"noea",
"nowe",
"soea",
"sowe",
"ce"
], Rr = (t) => ht.includes(t.type), jt = (t) => t.objects_position || t.obj_pos || t.op, Ur = (t) => !!jt(t), Hr = (t) => {
const e = jt(t);
n(e, "objects_position");
const o = e.type;
if (ze([...ht, "fp", "prop"], o, "type"), Rr(e)) {
e.xOffset !== void 0 && i(e.xOffset, "objects_position.xOffset"), e.yOffset !== void 0 && i(e.yOffset, "objects_position.yOffset");
const r = e.xOffset ?? "", s = e.yOffset ?? "";
return `op:${o}:${r}:${s}`;
} else if (e.type === "fp") {
e.x !== void 0 && i(e.x, "objects_position.x", {
addParam: { min: 0, max: 1 }
}), e.y !== void 0 && i(e.y, "objects_position.y", {
addParam: { min: 0, max: 1 }
});
const r = e.x ?? "", s = e.y ?? "";
return `op:${o}:${r}:${s}`;
} else {
if (o === "prop")
return "op:prop";
throw new Error(`Unknown object position type: ${o}`);
}
}, Cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Hr,
test: Ur
}, Symbol.toStringTag, { value: "Module" })), wt = (t) => {
if ("max_src_file_size" in t)
return t.max_src_file_size;
if ("msfs" in t)
return t.msfs;
}, Dr = (t) => wt(t) !== void 0, Qr = (t) => {
const e = wt(t);
return n(e, "max_src_file_size"), i(e, "max_src_file_size", { addParam: { min: 0 } }), `msfs:${e}`;
}, St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Qr,
test: Dr
}, Symbol.toStringTag, { value: "Module" })), Pt = (t) => {
if ("max_src_resolution" in t)
return t.max_src_resolution;
if ("msr" in t)
return t.msr;
}, Xr = (t) => Pt(t) !== void 0, Wr = (t) => {
const e = Pt(t);
return n(e, "max_src_resolution"), i(e, "max_src_resolution", {
addParam: { min: 0, minEqual: !0 }
}), `msr:${e}`;
}, zt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Wr,
test: Xr
}, Symbol.toStringTag, { value: "Module" })), xt = (t) => t.min_height ?? t.mh, Jr = (t) => !!xt(t), Yr = (t) => {
const e = xt(t);
return n(e, "min_height"), i(e, "min_height", { addParam: { min: 0 } }), `mh:${e}`;
}, Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Yr,
test: Jr
}, Symbol.toStringTag, { value: "Module" })), Tt = (t) => t.min_width ?? t.mw, Kr = (t) => !!Tt(t), Lr = (t) => {
const e = Tt(t);
return n(e, "min_width"), i(e, "min_width", { addParam: { min: 0 } }), `mw:${e}`;
}, Zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Lr,
test: Kr
}, Symbol.toStringTag, { value: "Module" })), Mt = (t) => t.monochrome ?? t.mc, tn = (t) => !!Mt(t), en = (t) => {
const e = Mt(t);
n(e, "monochrome");
const { intensity: o, color: r } = e;
return i(o, "monochrome.intensity", {
addParam: {
min: 0,
max: 1
}
}), r ? `mc:${o}:${r}` : `mc:${o}`;
}, on = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: en,
test: tn
}, Symbol.toStringTag, { value: "Module" })), kt = (t) => t.padding || t.pd, rn = (t) => !!kt(t), nn = (t) => {
const e = kt(t);
if (n(e, "padding"), typeof e == "string")
throw new Error("padding option is not a number or object");
if (typeof e == "number")
return i(e, "padding", { addParam: { min: 0 } }), `pd:${e}`;
e.top !== void 0 && i(e.top, "padding.top"), e.right !== void 0 && i(e.right, "padding.right"), e.bottom !== void 0 && i(e.bottom, "padding.bottom"), e.left !== void 0 && i(e.left, "padding.left");
const o = e.top ?? "", r = e.right ?? "", s = e.bottom ?? "", a = e.left ?? "";
return `pd:${o}:${r}:${s}:${a}`.replace(/:+$/, "");
}, sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: nn,
test: rn
}, Symbol.toStringTag, { value: "Module" })), Bt = (t) => {
if ("page" in t)
return t.page;
if ("pg" in t)
return t.pg;
}, an = (t) => Bt(t) !== void 0, ln = (t) => {
const e = Bt(t);
return n(e, "page"), i(e, "page", { addParam: { min: 0, isInt: !0 } }), `pg:${e}`;
}, qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ln,
test: an
}, Symbol.toStringTag, { value: "Module" })), Et = (t) => {
if ("pages" in t)
return t.pages;
if ("pgs" in t)
return t.pgs;
}, cn = (t) => Et(t) !== void 0, un = (t) => {
const e = Et(t);
return n(e, "pages"), i(e, "pages", { addParam: { min: 1, isInt: !0 } }), `pgs:${e}`;
}, dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: un,
test: cn
}, Symbol.toStringTag, { value: "Module" })), At = (t) => t.pixelate ?? t.pix, _n = (t) => !!At(t), bn = (t) => {
const e = At(t);
return n(e, "pixelate"), i(e, "pixelate", { addParam: { min: 0 } }), `pix:${e}`;
}, mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: bn,
test: _n
}, Symbol.toStringTag, { value: "Module" })), It = (t) => t.png_options || t.pngo, pn = (t) => !!It(t), fn = (t) => {
const e = It(t);
n(e, "png_options");
const { interlaced: o, quantize: r, quantization_colors: s } = e;
return o && p(o, "png_options.interlaced"), r && p(r, "png_options.quantize"), s && i(s, "png_options.quantization_colors", {
addParam: { min: 2, max: 256 }
}), `pngo:${o === void 0 ? "" : o}:${r === void 0 ? "" : r}:${s || ""}`.replace(/:+$/, "");
}, gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: fn,
test: pn
}, Symbol.toStringTag, { value: "Module" })), Vt = (t) => t.preset || t.pr, $n = (t) => !!Vt(t), yn = (t, e) => {
let o = Vt(t);
if (n(o, "preset"), f(o, "preset"), o.some((r) => typeof r != "string"))
throw new Error("preset option should contain only strings");
return e != null && e.onlyPresets || (o = ["pr", ...o]), `${o.join(":")}`;
}, h = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: yn,
test: $n
}, Symbol.toStringTag, { value: "Module" })), Ft = (t) => t.quality ?? t.q, On = (t) => !!Ft(t), vn = (t) => {
const e = Ft(t);
return n(e, "quality"), i(e, "quality", { addParam: { min: 0, max: 100 } }), `q:${e}`;
}, hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: vn,
test: On
}, Symbol.toStringTag, { value: "Module" })), Nt = (t) => {
if ("raw" in t)
return t.raw;
}, jn = (t) => Nt(t) !== void 0, wn = (t) => {
const e = Nt(t);
return n(e, "raw"), `raw:${l(e)}`;
}, Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: wn,
test: jn
}, Symbol.toStringTag, { value: "Module" })), Pn = {
fit: !0,
fill: !0,
auto: !0,
"fill-down": !0,
force: !0
}, Rt = (t) => t.resize || t.rs, zn = (t) => !!Rt(t), xn = (t) => {
const e = Rt(t);
n(e, "resize");
const { resizing_type: o, width: r, height: s, enlarge: a } = e;
o && d(Pn, o, "resize.resizing_type"), r && i(r, "resize.width", { addParam: { min: 0 } }), s && i(s, "resize.height", { addParam: { min: 0 } });
const c = o || "", u = r || "", m = s || "", g = a === void 0 ? "" : l(a), $ = w(e) ? S(e, { headless: !0 }) : "";
return `rs:${c}:${u}:${m}:${g}:${$}`.replace(/:+$/, "");
}, Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: xn,
test: zn
}, Symbol.toStringTag, { value: "Module" })), Mn = {
nearest: !0,
linear: !0,
cubic: !0,
lanczos2: !0,
lanczos3: !0
}, Ut = (t) => t.resizing_algorithm || t.ra, kn = (t) => !!Ut(t), Bn = (t) => {
const e = Ut(t);
return n(e, "resizing_algorithm"), d(Mn, e, "resizing_algorithm"), `ra:${e}`;
}, qn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Bn,
test: kn
}, Symbol.toStringTag, { value: "Module" })), En = {
fit: !0,
fill: !0,
"fill-down": !0,
force: !0,
auto: !0
}, Ht = (t) => t.resizing_type || t.rt, An = (t) => !!Ht(t), In = (t) => {
const e = Ht(t);
return n(e, "resizing_type"), d(En, e, "resizing_type"), `rt:${e}`;
}, Vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: In,
test: An
}, Symbol.toStringTag, { value: "Module" })), Ct = (t) => {
if ("return_attachment" in t)
return t.return_attachment;
if ("att" in t)
return t.att;
}, Fn = (t) => Ct(t) !== void 0, Nn = (t) => {
const e = Ct(t);
return n(e, "return_attachment"), `att:${l(e)}`;
}, Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Nn,
test: Fn
}, Symbol.toStringTag, { value: "Module" })), x = {
0: !0,
90: !0,
180: !0,
270: !0
}, Dt = (t) => t.rotate ?? t.rot, Un = (t) => !!Dt(t), Hn = (t) => {
const e = Dt(t), o = `You can use values ${Object.keys(x).join(", ")}`;
return n(e, "rotate"), i(e, "rotate", { addInfo: o }), d(x, e, "rotate"), `rot:${e}`;
}, Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Hn,
test: Un
}, Symbol.toStringTag, { value: "Module" })), Qt = (t) => t.saturation ?? t.sa, Dn = (t) => !!Qt(t), Qn = (t) => {
const e = Qt(t);
return n(e, "saturation"), i(e, "saturation", { addParam: { min: 0 } }), `sa:${e}`;
}, Xn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Qn,
test: Dn
}, Symbol.toStringTag, { value: "Module" })), Xt = (t) => t.sharpen ?? t.sh, Wn = (t) => !!Xt(t), Jn = (t) => {
const e = Xt(t);
return n(e, "sharpen"), i(e, "sharpen", { addParam: { min: 0 } }), `sh:${e}`;
}, Yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Jn,
test: Wn
}, Symbol.toStringTag, { value: "Module" })), Wt = (t) => t.size || t.s, Gn = (t) => !!Wt(t), Kn = (t) => {
const e = Wt(t);
n(e, "size");
const { width: o, height: r, enlarge: s } = e;
o && i(o, "size.width", { addParam: { min: 0 } }), r && i(r, "size.height", { addParam: { min: 0 } });
const a = o || "", c = r || "", u = s === void 0 ? "" : l(s), m = w(e) ? S(e, { headless: !0 }) : "";
return `s:${a}:${c}:${u}:${m}`.replace(/:+$/, "");
}, Ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Kn,
test: Gn
}, Symbol.toStringTag, { value: "Module" })), T = [
"jpg",
"jxl",
"png",
"webp",
"avif",
"gif",
"ico",
"svg",
"heic",
"bmp",
"tiff",
"pdf",
"mp4"
], Jt = (t) => t.skip_processing || t.sp, Zn = (t) => !!Jt(t), ts = (t) => {
const e = Jt(t);
if (n(e, "skip_processing"), f(e, "skip_processing"), e.some((o) => !T.includes(o))) {
const o = `Valid values are: ${T.join(",")}`;
throw new Error(
`skip_processing option contains unsupported extension. ${o}`
);
}
return `sp:${e.join(":")}`;
}, es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ts,
test: Zn
}, Symbol.toStringTag, { value: "Module" })), Yt = (t) => {
if ("strip_color_profile" in t)
return t.strip_color_profile;
if ("scp" in t)
return t.scp;
}, os = (t) => Yt(t) !== void 0, rs = (t) => {
const e = Yt(t);
return n(e, "strip_color_profile"), `scp:${l(e)}`;
}, ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: rs,
test: os
}, Symbol.toStringTag, { value: "Module" })), Gt = (t) => "strip_metadata" in t ? t.strip_metadata : "sm" in t ? t.sm : void 0, ss = (t) => Gt(t) !== void 0, is = (t) => {
const e = Gt(t);
return n(e, "strip_metadata"), `sm:${l(e)}`;
}, as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: is,
test: ss
}, Symbol.toStringTag, { value: "Module" })), Kt = (t) => t.style || t.stl, ls = (t) => !!Kt(t), cs = (t) => {
const e = Kt(t);
return n(e, "style"), b(e, "style"), `stl:${e}`;
}, us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: cs,
test: ls
}, Symbol.toStringTag, { value: "Module" })), Lt = (t) => t.trim || t.t, ds = (t) => !!Lt(t), _s = (t) => {
const e = Lt(t);
n(e, "trim");
const { threshold: o, color: r, equal_hor: s, equal_ver: a } = e;
n(o, "trim.threshold"), i(o, "trim.threshold"), r && b(r, "trim.color", !0);
const c = s === void 0 ? "" : l(s), u = a === void 0 ? "" : l(a);
return `t:${o}:${r || ""}:${c}:${u}`.replace(/:+$/, "");
}, bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: _s,
test: ds
}, Symbol.toStringTag, { value: "Module" })), ms = {
auto: !0,
none: !0,
always: !0
}, Zt = (t) => t.unsharp_masking || t.ush, ps = (t) => !!Zt(t), fs = (t) => {
const e = Zt(t);
n(e, "unsharp_masking");
const { mode: o, weight: r, divider: s } = e;
return o && d(ms, o, "unsharp_masking.mode"), r !== void 0 && i(r, "unsharp_masking.weight", {
addParam: { min: 0, minEqual: !0 }
}), s !== void 0 && i(s, "unsharp_masking.divider", {
addParam: { min: 0, minEqual: !0 }
}), `ush:${o || ""}:${r || ""}:${s || ""}`.replace(/:+$/, "");
}, gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: fs,
test: ps
}, Symbol.toStringTag, { value: "Module" })), te = (t) => {
if ("video_thumbnail_second" in t)
return t.video_thumbnail_second;
if ("vts" in t)
return t.vts;
}, $s = (t) => te(t) !== void 0, ys = (t) => {
const e = te(t);
return n(e, "video_thumbnail_second"), i(e, "video_thumbnail_second", {
addParam: { min: 1, isInt: !0 }
}), `vts:${e}`;
}, ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ys,
test: $s
}, Symbol.toStringTag, { value: "Module" }));
function oe(t) {
return t.video_thumbnail_animation || t.vta;
}
function Os(t) {
return !!oe(t);
}
function vs(t) {
const e = oe(t);
n(e, "video_thumbnail_animation"), i(e.step, "video_thumbnail_animation.step"), i(e.delay, "video_thumbnail_animation.delay"), i(e.frames, "video_thumbnail_animation.frames"), e.frame_width !== void 0 && i(e.frame_width, "video_thumbnail_animation.frame_width"), e.frame_height !== void 0 && i(e.frame_height, "video_thumbnail_animation.frame_height");
const o = [], r = e.extend_frame !== void 0 ? l(e.extend_frame) : void 0, s = e.trim !== void 0 ? l(e.trim) : void 0, a = e.fill !== void 0 ? l(e.fill) : void 0;
for (o.push(r, s, a), a === "t" && o.push(e.focus_x, e.focus_y); o.length > 0 && o[o.length - 1] === void 0; )
o.pop();
const c = o.length > 0 ? `:${o.join(":")}` : "";
return `vta:${e.step}:${e.delay}:${e.frames}:${e.frame_width}:${e.frame_height}${c}`;
}
const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: vs,
test: Os
}, Symbol.toStringTag, { value: "Module" }));
function re(t) {
return t.video_thumbnail_tile || t.vtt;
}
function js(t) {
return !!re(t);
}
function ws(t) {
const e = re(t);
n(e, "video_thumbnail_tile"), i(e.step, "video_thumbnail_tile.step"), i(e.columns, "video_thumbnail_tile.columns"), i(e.rows, "video_thumbnail_tile.rows"), i(e.tile_width, "video_thumbnail_tile.tile_width"), i(e.tile_height, "video_thumbnail_tile.tile_height");
const o = [], r = e.extend_tile !== void 0 ? l(e.extend_tile) : void 0, s = e.trim !== void 0 ? l(e.trim) : void 0, a = e.fill !== void 0 ? l(e.fill) : void 0;
for (o.push(r, s, a), a === "t" && o.push(e.focus_x, e.focus_y); o.length > 0 && o[o.length - 1] === void 0; )
o.pop();
const c = o.length > 0 ? `:${o.join(":")}` : "";
return `vtt:${e.step}:${e.columns}:${e.rows}:${e.tile_width}:${e.tile_height}${c}`;
}
const Ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ws,
test: js
}, Symbol.toStringTag, { value: "Module" })), Ps = {
ce: !0,
no: !0,
so: !0,
ea: !0,
we: !0,
noea: !0,
nowe: !0,
soea: !0,
sowe: !0,
re: !0,
ch: !0
}, ne = (t) => t.watermark || t.wm, zs = (t) => !!ne(t), xs = (t) => {
const e = ne(t);
n(e, "watermark");
const { opacity: o, position: r, x_offset: s, y_offset: a, scale: c } = e;
return n(o, "watermark.opacity"), i(o, "watermark.opacity", { addParam: { min: 0, max: 1 } }), r && (b(r, "watermark.position"), d(Ps, r, "watermark.position")), s && i(s, "watermark.x_offset"), a && i(a, "watermark.y_offset"), c && i(c, "watermark.scale"), `wm:${o}:${r || ""}:${s || ""}:${a || ""}:${c || ""}`.replace(/:+$/, "");
}, Ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: xs,
test: zs
}, Symbol.toStringTag, { value: "Module" })), se = (t) => t.watermark_shadow ?? t.wmsh, Ms = (t) => !!se(t), ks = (t) => {
const e = se(t);
return n(e, "watermark_shadow"), i(e, "watermark_shadow", {
addParam: { min: 0 }
}), `wmsh:${e}`;
}, Bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ks,
test: Ms
}, Symbol.toStringTag, { value: "Module" })), ie = (t) => t.watermark_size || t.wms, qs = (t) => !!ie(t), Es = (t) => {
const e = ie(t);
n(e, "watermark_size");
const { width: o, height: r } = e;
return o && i(o, "watermark_size.width", { addParam: { min: 0 } }), r && i(r, "watermark_size.height", { addParam: { min: 0 } }), `wms:${o || ""}:${r || ""}`.replace(/:+$/, "");
}, As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Es,
test: qs
}, Symbol.toStringTag, { value: "Module" })), ae = (t) => t.watermark_text || t.wmt, Is = (t) => !!ae(t), Vs = (t) => {
const e = ae(t);
return n(e, "watermark_text"), b(e, "watermark_text"), `wmt:${e}`;
}, Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Vs,
test: Is
}, Symbol.toStringTag, { value: "Module" })), le = (t) => t.watermark_url || t.wmu, Ns = (t) => !!le(t), Rs = (t) => {
const e = le(t);
return n(e, "watermark_url"), b(e, "watermark_url"), `wmu:${e}`;
}, Us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Rs,
test: Ns
}, Symbol.toStringTag, { value: "Module" })), Hs = {
lossy: !0,
near_lossless: !0,
lossless: !0
}, Cs = {
default: !0,
photo: !0,
picture: !0,
drawing: !0,
icon: !0,
text: !0
}, ce = (t) => t.webp_options || t.webpo, Ds = (t) => !!ce(t), Qs = (t) => {
const e = ce(t);
let o, r, s;
n(e, "webp_options"), typeof e == "string" ? o = e : (o = e.compression, e.smart_subsample !== void 0 && (r = e.smart_subsample, p(r, "webp_options.smart_subsample")), e.preset !== void 0 && (s = e.preset, d(Cs, s, "webp_options.preset"))), d(Hs, o, "webp_options");
let a = `webpo:${o}`;
return (r !== void 0 || s !== void 0) && (a += `:${r !== void 0 ? r : ""}`), s !== void 0 && (a += `:${s}`), a;
}, Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Qs,
test: Ds
}, Symbol.toStringTag, { value: "Module" })), ue = (t) => t.width ?? t.w, Ws = (t) => !!ue(t), Js = (t) => {
const e = ue(t);
return n(e, "width"), i(e, "width", { addParam: { min: 0 } }), `w:${e}`;
}, Ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Js,
test: Ws
}, Symbol.toStringTag, { value: "Module" })), j = (t, e) => {
n(t, e), i(t, e, { addParam: { min: 0 } });
}, de = (t) => t.zoom || t.z, Gs = (t) => !!de(t), Ks = (t) => {
const e = de(t);
return n(e, "zoom"), typeof e == "string" && i(e, "zoom"), typeof e == "number" ? (j(e, "zoom"), `z:${e}`) : (j(e.zoom_x, "zoom.zoom_x"), j(e.zoom_y, "zoom.zoom_y"), `z:${e.zoom_x}:${e.zoom_y}`);
}, Ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Ks,
test: Gs
}, Symbol.toStringTag, { value: "Module" })), Zs = (t) => t.wild_options, ti = (t) => !!Zs(t), ei = (t) => {
const e = t.wild_options;
if (n(e, "raw_options"), f(e, "raw_options"), !e.every((r) => Array.isArray(r)))
throw new Error("raw_options is not an array of arrays");
let o = "";
for (let r = 0; r < e.length; r++) {
let s = "";
for (let a = 0; a < e[r].length; a++)
a > 0 && (s += ":"), s += e[r][a];
r > 0 && (o += "/"), o += s;
}
return o;
}, _e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ei,
test: ti
}, Symbol.toStringTag, { value: "Module" })), oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
adjust: Me,
autoRotate: Ve,
autoquality: Ee,
avifOptions: Ue,
background: De,
backgroundAlpha: We,
blur: Ge,
blurAreas: Ze,
blurDetections: oo,
brightness: so,
cacheBuster: C,
colorProfile: uo,
colorize: mo,
contrast: go,
crop: G,
cropAspectRatio: wo,
disableAnimation: zo,
dpi: qo,
dpr: Io,
drawDetections: No,
duotone: Mo,
enforceThumbnail: Ho,
enlarge: Qo,
expires: it,
extend: Yo,
extendAspectRatio: Lo,
fallbackImageUrl: er,
filename: nr,
flip: ar,
format: dr,
formatQuality: mr,
gradient: $r,
gravity: yo,
height: vr,
jpegOptions: wr,
keepCopyright: zr,
maxAnimationFrameResolution: qr,
maxAnimationFrames: Mr,
maxBytes: Ir,
maxResultDimension: Nr,
maxSrcFileSize: St,
maxSrcResolution: zt,
minHeight: Gr,
minWidth: Zr,
monochrome: on,
objectPosition: Cr,
padding: sn,
page: qt,
pages: dn,
pixelate: mn,
pngOptions: gn,
preset: h,
quality: hn,
raw: Sn,
resize: Tn,
resizingAlgorithm: qn,
resizingType: Vn,
returnAttachment: Rn,
rotate: Cn,
saturation: Xn,
sharpen: Yn,
size: Ln,
skipProcessing: es,
stripColorProfile: ns,
stripMetadata: as,
style: us,
trim: bs,
unsharpMasking: gs,
videoThumbnailAnimation: hs,
videoThumbnailSecond: ee,
videoThumbnailTile: Ss,
watermark: Ts,
watermarkShadow: Bs,
watermarkSize: As,
watermarkText: Fs,
watermarkUrl: Us,
webpOptions: Xs,
width: Ys,
wildOptions: _e,
zoom: Ls
}, Symbol.toStringTag, { value: "Module" })), M = {
plain: !0,
base64: !0,
encrypted: !0
}, ri = Object.values(oi), ni = [h], Zi = (t, e, o) => {
if (n(t.value, "url.value", "Must be a string"), n(
t.type,
"url.type",
`Valid values are: ${Object.keys(M).join(", ")}`
), d(M, t.type, "url.type"), t.filename && t.type === "plain")
throw new Error("url.filename is only valid for base64 or encrypted url");
let r = "";
if (e) {
const a = o != null && o.onlyPresets ? ni : ri;
for (const c of a)
c.test(e) && (r += "/", r += c.build(e, o));
}
let s = "";
return t.type === "plain" ? s = `/plain/${t.value}` : t.type === "base64" ? s = `/${t.value}` : t.type === "encrypted" && (s = `/enc/${t.value}`), t.filename && (s += `/${t.filename}`), `${r}${s}`;
}, be = (t) => {
if ("average" in t)
return t.average;
if ("avg" in t)
return t.avg;
}, si = (t) => be(t) !== void 0, ii = (t) => {
const e = be(t);
n(e, "average"), n(e.average, "average.average");
const o = e.ignore_transparent === void 0 ? "" : `:${l(e.ignore_transparent)}`;
return `avg:${l(e.average)}${o}`;
}, ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ii,
test: si
}, Symbol.toStringTag, { value: "Module" })), me = (t) => {
if ("blurhash" in t)
return t.blurhash;
if ("bh" in t)
return t.bh;
}, li = (t) => me(t) !== void 0, ci = (t) => {
const e = me(t);
n(e, "blurhash");
const { x_components: o, y_components: r } = e;
return n(o, "blurhash.x_components"), n(r, "blurhash.y_components"), i(o, "blurhash.x_components", {
addParam: { min: 0, max: 9 }
}), i(r, "blurhash.y_components", {
addParam: { min: 0, max: 9 }
}), `bh:${o}:${r}`;
}, ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ci,
test: li
}, Symbol.toStringTag, { value: "Module" })), pe = (t) => {
if ("calcHashsums" in t)
return t.calcHashsums;
if ("chs" in t)
return t.chs;
}, di = (t) => pe(t) !== void 0, _i = (t) => {
const e = pe(t);
return n(e, "calcHashsums"), e.length ? `chs:${e.join(":")}` : "chs:";
}, bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: _i,
test: di
}, Symbol.toStringTag, { value: "Module" })), fe = (t) => {
if ("detect_objects" in t)
return t.detect_objects;
if ("do" in t)
return t.do;
}, mi = (t) => fe(t) !== void 0, pi = (t) => {
const e = fe(t);
return n(e, "detect_objects"), `do:${l(e)}`;
}, fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: pi,
test: mi
}, Symbol.toStringTag, { value: "Module" })), ge = (t) => {
if ("dimensions" in t)
return t.dimensions;
if ("d" in t)
return t.d;
}, gi = (t) => ge(t) !== void 0, $i = (t) => {
const e = ge(t);
return n(e, "dimensions"), `d:${l(e)}`;
}, yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: $i,
test: gi
}, Symbol.toStringTag, { value: "Module" })), $e = (t) => {
if ("dominant_colors" in t)
return t.dominant_colors;
if ("dc" in t)
return t.dc;
}, Oi = (t) => $e(t) !== void 0, vi = (t) => {
const e = $e(t);
n(e, "dominant_colors"), n(e.dominant_colors, "dominant_colors.dominant_colors");
const o = e.build_missed === void 0 ? "" : `:${l(e.build_missed)}`;
return `dc:${l(e.dominant_colors)}${o}`;
}, hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: vi,
test: Oi
}, Symbol.toStringTag, { value: "Module" })), ye = (t) => {
if ("exif" in t)
return t.exif;
}, ji = (t) => ye(t) !== void 0, wi = (t) => typeof t == "object" && t !== null, Si = (t) => {
const e = ye(t);
if (n(e, "EXIF"), !wi(e))
return `exif:${l(e)}`;
const { enabled: o, canonical_names: r } = e, s = o !== void 0 ? l(o) : "t";
return r === void 0 ? `exif:${s}` : `exif:${s}:${l(r)}`;
}, Pi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Si,
test: ji
}, Symbol.toStringTag, { value: "Module" })), Oe = (t) => {
if ("format" in t)
return t.format;
if ("f" in t)
return t.f;
}, zi = (t) => Oe(t) !== void 0, xi = (t) => {
const e = Oe(t);
return n(e, "format"), `f:${l(e)}`;
}, Ti = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: xi,
test: zi
}, Symbol.toStringTag, { value: "Module" })), ve = (t) => {
if ("iptc" in t)
return t.iptc;
}, Mi = (t) => ve(t) !== void 0, ki = (t) => {
const e = ve(t);
return n(e, "IPTC"), `iptc:${l(e)}`;
}, Bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: ki,
test: Mi
}, Symbol.toStringTag, { value: "Module" })), he = (t) => {
if ("pages_number" in t)
return t.pages_number;
if ("pn" in t)
return t.pn;
}, qi = (t) => he(t) !== void 0, Ei = (t) => {
const e = he(t);
return n(e, "pages_number"), `pn:${l(e)}`;
}, Ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
build: Ei,
test: qi
}, Symbol.toStringTag, { value: "Module" })), je = (t) => {
if ("palette" in t)
return t.palette;
if ("p" in t)
return t.p;
}, Ii = (t) => je(t) !== void 0, Vi = (t) => {
const e = je(t);
if (n(e, "palette"), i(e, "palette", {
addParam: { min: 0, max: 256, isInt: !0 }
}), e === 1)
throw new Error("palette option is should be 0 or b