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