| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953 |
- globalThis.process ??= {}; globalThis.process.env ??= {};
- import { j as joinPaths, i as isRemotePath } from './path_CH3auf61.mjs';
- import { A as AstroError, E as ExpectedImage, L as LocalImageUsedWrongly, M as MissingImageDimension, U as UnsupportedImageFormat, I as IncompatibleDescriptorOptions, a as UnsupportedImageConversion, t as toStyleString, N as NoImageMetadata, F as FailedToFetchRemoteImageDimensions, b as ExpectedImageOptions, c as ExpectedNotESMImage, d as InvalidImageService, e as createComponent, f as createAstro, g as ImageMissingAlt, m as maybeRenderHead, h as addAttribute, s as spreadAttributes, r as renderTemplate, i as ExperimentalFontsNotEnabled, j as FontFamilyNotFound, u as unescapeHTML } from './astro/server_WO3f6Mge.mjs';
- import { i as isRemoteAllowed } from './remote_BC1y8RCW.mjs';
- import './_@astro-renderers_DpxbEuk7.mjs';
- const VALID_SUPPORTED_FORMATS = [
- "jpeg",
- "jpg",
- "png",
- "tiff",
- "webp",
- "gif",
- "svg",
- "avif"
- ];
- const DEFAULT_OUTPUT_FORMAT = "webp";
- const DEFAULT_HASH_PROPS = [
- "src",
- "width",
- "height",
- "format",
- "quality",
- "fit",
- "position"
- ];
- const DEFAULT_RESOLUTIONS = [
- 640,
- // older and lower-end phones
- 750,
- // iPhone 6-8
- 828,
- // iPhone XR/11
- 960,
- // older horizontal phones
- 1080,
- // iPhone 6-8 Plus
- 1280,
- // 720p
- 1668,
- // Various iPads
- 1920,
- // 1080p
- 2048,
- // QXGA
- 2560,
- // WQXGA
- 3200,
- // QHD+
- 3840,
- // 4K
- 4480,
- // 4.5K
- 5120,
- // 5K
- 6016
- // 6K
- ];
- const LIMITED_RESOLUTIONS = [
- 640,
- // older and lower-end phones
- 750,
- // iPhone 6-8
- 828,
- // iPhone XR/11
- 1080,
- // iPhone 6-8 Plus
- 1280,
- // 720p
- 1668,
- // Various iPads
- 2048,
- // QXGA
- 2560
- // WQXGA
- ];
- const getWidths = ({
- width,
- layout,
- breakpoints = DEFAULT_RESOLUTIONS,
- originalWidth
- }) => {
- const smallerThanOriginal = (w) => !originalWidth || w <= originalWidth;
- if (layout === "full-width") {
- return breakpoints.filter(smallerThanOriginal);
- }
- if (!width) {
- return [];
- }
- const doubleWidth = width * 2;
- const maxSize = originalWidth ? Math.min(doubleWidth, originalWidth) : doubleWidth;
- if (layout === "fixed") {
- return originalWidth && width > originalWidth ? [originalWidth] : [width, maxSize];
- }
- if (layout === "constrained") {
- return [
- // Always include the image at 1x and 2x the specified width
- width,
- doubleWidth,
- ...breakpoints
- ].filter((w) => w <= maxSize).sort((a, b) => a - b);
- }
- return [];
- };
- const getSizesAttribute = ({
- width,
- layout
- }) => {
- if (!width || !layout) {
- return void 0;
- }
- switch (layout) {
- // If screen is wider than the max size then image width is the max size,
- // otherwise it's the width of the screen
- case "constrained":
- return `(min-width: ${width}px) ${width}px, 100vw`;
- // Image is always the same width, whatever the size of the screen
- case "fixed":
- return `${width}px`;
- // Image is always the width of the screen
- case "full-width":
- return `100vw`;
- case "none":
- default:
- return void 0;
- }
- };
- function isESMImportedImage(src) {
- return typeof src === "object" || typeof src === "function" && "src" in src;
- }
- function isRemoteImage(src) {
- return typeof src === "string";
- }
- async function resolveSrc(src) {
- if (typeof src === "object" && "then" in src) {
- const resource = await src;
- return resource.default ?? resource;
- }
- return src;
- }
- function isLocalService(service) {
- if (!service) {
- return false;
- }
- return "transform" in service;
- }
- function parseQuality(quality) {
- let result = parseInt(quality);
- if (Number.isNaN(result)) {
- return quality;
- }
- return result;
- }
- const sortNumeric = (a, b) => a - b;
- const baseService = {
- validateOptions(options) {
- if (!options.src || !isRemoteImage(options.src) && !isESMImportedImage(options.src)) {
- throw new AstroError({
- ...ExpectedImage,
- message: ExpectedImage.message(
- JSON.stringify(options.src),
- typeof options.src,
- JSON.stringify(options, (_, v) => v === void 0 ? null : v)
- )
- });
- }
- if (!isESMImportedImage(options.src)) {
- if (options.src.startsWith("/@fs/") || !isRemotePath(options.src) && !options.src.startsWith("/")) {
- throw new AstroError({
- ...LocalImageUsedWrongly,
- message: LocalImageUsedWrongly.message(options.src)
- });
- }
- let missingDimension;
- if (!options.width && !options.height) {
- missingDimension = "both";
- } else if (!options.width && options.height) {
- missingDimension = "width";
- } else if (options.width && !options.height) {
- missingDimension = "height";
- }
- if (missingDimension) {
- throw new AstroError({
- ...MissingImageDimension,
- message: MissingImageDimension.message(missingDimension, options.src)
- });
- }
- } else {
- if (!VALID_SUPPORTED_FORMATS.includes(options.src.format)) {
- throw new AstroError({
- ...UnsupportedImageFormat,
- message: UnsupportedImageFormat.message(
- options.src.format,
- options.src.src,
- VALID_SUPPORTED_FORMATS
- )
- });
- }
- if (options.widths && options.densities) {
- throw new AstroError(IncompatibleDescriptorOptions);
- }
- if (options.src.format === "svg") {
- options.format = "svg";
- }
- if (options.src.format === "svg" && options.format !== "svg" || options.src.format !== "svg" && options.format === "svg") {
- throw new AstroError(UnsupportedImageConversion);
- }
- }
- if (!options.format) {
- options.format = DEFAULT_OUTPUT_FORMAT;
- }
- if (options.width) options.width = Math.round(options.width);
- if (options.height) options.height = Math.round(options.height);
- if (options.layout && options.width && options.height) {
- options.fit ??= "cover";
- delete options.layout;
- }
- if (options.fit === "none") {
- delete options.fit;
- }
- return options;
- },
- getHTMLAttributes(options) {
- const { targetWidth, targetHeight } = getTargetDimensions(options);
- const {
- src,
- width,
- height,
- format,
- quality,
- densities,
- widths,
- formats,
- layout,
- priority,
- fit,
- position,
- ...attributes
- } = options;
- return {
- ...attributes,
- width: targetWidth,
- height: targetHeight,
- loading: attributes.loading ?? "lazy",
- decoding: attributes.decoding ?? "async"
- };
- },
- getSrcSet(options) {
- const { targetWidth, targetHeight } = getTargetDimensions(options);
- const aspectRatio = targetWidth / targetHeight;
- const { widths, densities } = options;
- const targetFormat = options.format ?? DEFAULT_OUTPUT_FORMAT;
- let transformedWidths = (widths ?? []).sort(sortNumeric);
- let imageWidth = options.width;
- let maxWidth = Infinity;
- if (isESMImportedImage(options.src)) {
- imageWidth = options.src.width;
- maxWidth = imageWidth;
- if (transformedWidths.length > 0 && transformedWidths.at(-1) > maxWidth) {
- transformedWidths = transformedWidths.filter((width) => width <= maxWidth);
- transformedWidths.push(maxWidth);
- }
- }
- transformedWidths = Array.from(new Set(transformedWidths));
- const {
- width: transformWidth,
- height: transformHeight,
- ...transformWithoutDimensions
- } = options;
- let allWidths = [];
- if (densities) {
- const densityValues = densities.map((density) => {
- if (typeof density === "number") {
- return density;
- } else {
- return parseFloat(density);
- }
- });
- const densityWidths = densityValues.sort(sortNumeric).map((density) => Math.round(targetWidth * density));
- allWidths = densityWidths.map((width, index) => ({
- width,
- descriptor: `${densityValues[index]}x`
- }));
- } else if (transformedWidths.length > 0) {
- allWidths = transformedWidths.map((width) => ({
- width,
- descriptor: `${width}w`
- }));
- }
- return allWidths.map(({ width, descriptor }) => {
- const height = Math.round(width / aspectRatio);
- const transform = { ...transformWithoutDimensions, width, height };
- return {
- transform,
- descriptor,
- attributes: {
- type: `image/${targetFormat}`
- }
- };
- });
- },
- getURL(options, imageConfig) {
- const searchParams = new URLSearchParams();
- if (isESMImportedImage(options.src)) {
- searchParams.append("href", options.src.src);
- } else if (isRemoteAllowed(options.src, imageConfig)) {
- searchParams.append("href", options.src);
- } else {
- return options.src;
- }
- const params = {
- w: "width",
- h: "height",
- q: "quality",
- f: "format",
- fit: "fit",
- position: "position"
- };
- Object.entries(params).forEach(([param, key]) => {
- options[key] && searchParams.append(param, options[key].toString());
- });
- const imageEndpoint = joinPaths("/", imageConfig.endpoint.route);
- return `${imageEndpoint}?${searchParams}`;
- },
- parseURL(url) {
- const params = url.searchParams;
- if (!params.has("href")) {
- return void 0;
- }
- const transform = {
- src: params.get("href"),
- width: params.has("w") ? parseInt(params.get("w")) : void 0,
- height: params.has("h") ? parseInt(params.get("h")) : void 0,
- format: params.get("f"),
- quality: params.get("q"),
- fit: params.get("fit"),
- position: params.get("position") ?? void 0
- };
- return transform;
- }
- };
- function getTargetDimensions(options) {
- let targetWidth = options.width;
- let targetHeight = options.height;
- if (isESMImportedImage(options.src)) {
- const aspectRatio = options.src.width / options.src.height;
- if (targetHeight && !targetWidth) {
- targetWidth = Math.round(targetHeight * aspectRatio);
- } else if (targetWidth && !targetHeight) {
- targetHeight = Math.round(targetWidth / aspectRatio);
- } else if (!targetWidth && !targetHeight) {
- targetWidth = options.src.width;
- targetHeight = options.src.height;
- }
- }
- return {
- targetWidth,
- targetHeight
- };
- }
- function isImageMetadata(src) {
- return src.fsPath && !("fsPath" in src);
- }
- const cssFitValues = ["fill", "contain", "cover", "scale-down"];
- function addCSSVarsToStyle(vars, styles) {
- const cssVars = Object.entries(vars).filter(([_, value]) => value !== void 0 && value !== false).map(([key, value]) => `--${key}: ${value};`).join(" ");
- if (!styles) {
- return cssVars;
- }
- const style = typeof styles === "string" ? styles : toStyleString(styles);
- return `${cssVars} ${style}`;
- }
- const decoder = new TextDecoder();
- const toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end));
- const toHexString = (input, start = 0, end = input.length) => input.slice(start, end).reduce((memo, i) => memo + ("0" + i.toString(16)).slice(-2), "");
- const readInt16LE = (input, offset = 0) => {
- const val = input[offset] + input[offset + 1] * 2 ** 8;
- return val | (val & 2 ** 15) * 131070;
- };
- const readUInt16BE = (input, offset = 0) => input[offset] * 2 ** 8 + input[offset + 1];
- const readUInt16LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8;
- const readUInt24LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16;
- const readInt32LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16 + (input[offset + 3] << 24);
- const readUInt32BE = (input, offset = 0) => input[offset] * 2 ** 24 + input[offset + 1] * 2 ** 16 + input[offset + 2] * 2 ** 8 + input[offset + 3];
- const readUInt32LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16 + input[offset + 3] * 2 ** 24;
- const methods = {
- readUInt16BE,
- readUInt16LE,
- readUInt32BE,
- readUInt32LE
- };
- function readUInt(input, bits, offset, isBigEndian) {
- offset = offset || 0;
- const endian = isBigEndian ? "BE" : "LE";
- const methodName = "readUInt" + bits + endian;
- return methods[methodName](input, offset);
- }
- function readBox(buffer, offset) {
- if (buffer.length - offset < 4) return;
- const boxSize = readUInt32BE(buffer, offset);
- if (buffer.length - offset < boxSize) return;
- return {
- name: toUTF8String(buffer, 4 + offset, 8 + offset),
- offset,
- size: boxSize
- };
- }
- function findBox(buffer, boxName, offset) {
- while (offset < buffer.length) {
- const box = readBox(buffer, offset);
- if (!box) break;
- if (box.name === boxName) return box;
- offset += box.size;
- }
- }
- const BMP = {
- validate: (input) => toUTF8String(input, 0, 2) === "BM",
- calculate: (input) => ({
- height: Math.abs(readInt32LE(input, 22)),
- width: readUInt32LE(input, 18)
- })
- };
- const TYPE_ICON = 1;
- const SIZE_HEADER$1 = 2 + 2 + 2;
- const SIZE_IMAGE_ENTRY = 1 + 1 + 1 + 1 + 2 + 2 + 4 + 4;
- function getSizeFromOffset(input, offset) {
- const value = input[offset];
- return value === 0 ? 256 : value;
- }
- function getImageSize$1(input, imageIndex) {
- const offset = SIZE_HEADER$1 + imageIndex * SIZE_IMAGE_ENTRY;
- return {
- height: getSizeFromOffset(input, offset + 1),
- width: getSizeFromOffset(input, offset)
- };
- }
- const ICO = {
- validate(input) {
- const reserved = readUInt16LE(input, 0);
- const imageCount = readUInt16LE(input, 4);
- if (reserved !== 0 || imageCount === 0) return false;
- const imageType = readUInt16LE(input, 2);
- return imageType === TYPE_ICON;
- },
- calculate(input) {
- const nbImages = readUInt16LE(input, 4);
- const imageSize = getImageSize$1(input, 0);
- if (nbImages === 1) return imageSize;
- const imgs = [imageSize];
- for (let imageIndex = 1; imageIndex < nbImages; imageIndex += 1) {
- imgs.push(getImageSize$1(input, imageIndex));
- }
- return {
- height: imageSize.height,
- images: imgs,
- width: imageSize.width
- };
- }
- };
- const TYPE_CURSOR = 2;
- const CUR = {
- validate(input) {
- const reserved = readUInt16LE(input, 0);
- const imageCount = readUInt16LE(input, 4);
- if (reserved !== 0 || imageCount === 0) return false;
- const imageType = readUInt16LE(input, 2);
- return imageType === TYPE_CURSOR;
- },
- calculate: (input) => ICO.calculate(input)
- };
- const DDS = {
- validate: (input) => readUInt32LE(input, 0) === 542327876,
- calculate: (input) => ({
- height: readUInt32LE(input, 12),
- width: readUInt32LE(input, 16)
- })
- };
- const gifRegexp = /^GIF8[79]a/;
- const GIF = {
- validate: (input) => gifRegexp.test(toUTF8String(input, 0, 6)),
- calculate: (input) => ({
- height: readUInt16LE(input, 8),
- width: readUInt16LE(input, 6)
- })
- };
- const brandMap = {
- avif: "avif",
- avis: "avif",
- // avif-sequence
- mif1: "heif",
- msf1: "heif",
- // heif-sequence
- heic: "heic",
- heix: "heic",
- hevc: "heic",
- // heic-sequence
- hevx: "heic"
- // heic-sequence
- };
- function detectBrands(buffer, start, end) {
- let brandsDetected = {};
- for (let i = start; i <= end; i += 4) {
- const brand = toUTF8String(buffer, i, i + 4);
- if (brand in brandMap) {
- brandsDetected[brand] = 1;
- }
- }
- if ("avif" in brandsDetected || "avis" in brandsDetected) {
- return "avif";
- } else if ("heic" in brandsDetected || "heix" in brandsDetected || "hevc" in brandsDetected || "hevx" in brandsDetected) {
- return "heic";
- } else if ("mif1" in brandsDetected || "msf1" in brandsDetected) {
- return "heif";
- }
- }
- const HEIF = {
- validate(buffer) {
- const ftype = toUTF8String(buffer, 4, 8);
- const brand = toUTF8String(buffer, 8, 12);
- return "ftyp" === ftype && brand in brandMap;
- },
- calculate(buffer) {
- const metaBox = findBox(buffer, "meta", 0);
- const iprpBox = metaBox && findBox(buffer, "iprp", metaBox.offset + 12);
- const ipcoBox = iprpBox && findBox(buffer, "ipco", iprpBox.offset + 8);
- const ispeBox = ipcoBox && findBox(buffer, "ispe", ipcoBox.offset + 8);
- if (ispeBox) {
- return {
- height: readUInt32BE(buffer, ispeBox.offset + 16),
- width: readUInt32BE(buffer, ispeBox.offset + 12),
- type: detectBrands(buffer, 8, metaBox.offset)
- };
- }
- throw new TypeError("Invalid HEIF, no size found");
- }
- };
- const SIZE_HEADER = 4 + 4;
- const FILE_LENGTH_OFFSET = 4;
- const ENTRY_LENGTH_OFFSET = 4;
- const ICON_TYPE_SIZE = {
- ICON: 32,
- "ICN#": 32,
- // m => 16 x 16
- "icm#": 16,
- icm4: 16,
- icm8: 16,
- // s => 16 x 16
- "ics#": 16,
- ics4: 16,
- ics8: 16,
- is32: 16,
- s8mk: 16,
- icp4: 16,
- // l => 32 x 32
- icl4: 32,
- icl8: 32,
- il32: 32,
- l8mk: 32,
- icp5: 32,
- ic11: 32,
- // h => 48 x 48
- ich4: 48,
- ich8: 48,
- ih32: 48,
- h8mk: 48,
- // . => 64 x 64
- icp6: 64,
- ic12: 32,
- // t => 128 x 128
- it32: 128,
- t8mk: 128,
- ic07: 128,
- // . => 256 x 256
- ic08: 256,
- ic13: 256,
- // . => 512 x 512
- ic09: 512,
- ic14: 512,
- // . => 1024 x 1024
- ic10: 1024
- };
- function readImageHeader(input, imageOffset) {
- const imageLengthOffset = imageOffset + ENTRY_LENGTH_OFFSET;
- return [
- toUTF8String(input, imageOffset, imageLengthOffset),
- readUInt32BE(input, imageLengthOffset)
- ];
- }
- function getImageSize(type) {
- const size = ICON_TYPE_SIZE[type];
- return { width: size, height: size, type };
- }
- const ICNS = {
- validate: (input) => toUTF8String(input, 0, 4) === "icns",
- calculate(input) {
- const inputLength = input.length;
- const fileLength = readUInt32BE(input, FILE_LENGTH_OFFSET);
- let imageOffset = SIZE_HEADER;
- let imageHeader = readImageHeader(input, imageOffset);
- let imageSize = getImageSize(imageHeader[0]);
- imageOffset += imageHeader[1];
- if (imageOffset === fileLength) return imageSize;
- const result = {
- height: imageSize.height,
- images: [imageSize],
- width: imageSize.width
- };
- while (imageOffset < fileLength && imageOffset < inputLength) {
- imageHeader = readImageHeader(input, imageOffset);
- imageSize = getImageSize(imageHeader[0]);
- imageOffset += imageHeader[1];
- result.images.push(imageSize);
- }
- return result;
- }
- };
- const J2C = {
- // TODO: this doesn't seem right. SIZ marker doesn't have to be right after the SOC
- validate: (input) => toHexString(input, 0, 4) === "ff4fff51",
- calculate: (input) => ({
- height: readUInt32BE(input, 12),
- width: readUInt32BE(input, 8)
- })
- };
- const JP2 = {
- validate(input) {
- if (readUInt32BE(input, 4) !== 1783636e3 || readUInt32BE(input, 0) < 1) return false;
- const ftypBox = findBox(input, "ftyp", 0);
- if (!ftypBox) return false;
- return readUInt32BE(input, ftypBox.offset + 4) === 1718909296;
- },
- calculate(input) {
- const jp2hBox = findBox(input, "jp2h", 0);
- const ihdrBox = jp2hBox && findBox(input, "ihdr", jp2hBox.offset + 8);
- if (ihdrBox) {
- return {
- height: readUInt32BE(input, ihdrBox.offset + 8),
- width: readUInt32BE(input, ihdrBox.offset + 12)
- };
- }
- throw new TypeError("Unsupported JPEG 2000 format");
- }
- };
- const EXIF_MARKER = "45786966";
- const APP1_DATA_SIZE_BYTES = 2;
- const EXIF_HEADER_BYTES = 6;
- const TIFF_BYTE_ALIGN_BYTES = 2;
- const BIG_ENDIAN_BYTE_ALIGN = "4d4d";
- const LITTLE_ENDIAN_BYTE_ALIGN = "4949";
- const IDF_ENTRY_BYTES = 12;
- const NUM_DIRECTORY_ENTRIES_BYTES = 2;
- function isEXIF(input) {
- return toHexString(input, 2, 6) === EXIF_MARKER;
- }
- function extractSize(input, index) {
- return {
- height: readUInt16BE(input, index),
- width: readUInt16BE(input, index + 2)
- };
- }
- function extractOrientation(exifBlock, isBigEndian) {
- const idfOffset = 8;
- const offset = EXIF_HEADER_BYTES + idfOffset;
- const idfDirectoryEntries = readUInt(exifBlock, 16, offset, isBigEndian);
- for (let directoryEntryNumber = 0; directoryEntryNumber < idfDirectoryEntries; directoryEntryNumber++) {
- const start = offset + NUM_DIRECTORY_ENTRIES_BYTES + directoryEntryNumber * IDF_ENTRY_BYTES;
- const end = start + IDF_ENTRY_BYTES;
- if (start > exifBlock.length) {
- return;
- }
- const block = exifBlock.slice(start, end);
- const tagNumber = readUInt(block, 16, 0, isBigEndian);
- if (tagNumber === 274) {
- const dataFormat = readUInt(block, 16, 2, isBigEndian);
- if (dataFormat !== 3) {
- return;
- }
- const numberOfComponents = readUInt(block, 32, 4, isBigEndian);
- if (numberOfComponents !== 1) {
- return;
- }
- return readUInt(block, 16, 8, isBigEndian);
- }
- }
- }
- function validateExifBlock(input, index) {
- const exifBlock = input.slice(APP1_DATA_SIZE_BYTES, index);
- const byteAlign = toHexString(
- exifBlock,
- EXIF_HEADER_BYTES,
- EXIF_HEADER_BYTES + TIFF_BYTE_ALIGN_BYTES
- );
- const isBigEndian = byteAlign === BIG_ENDIAN_BYTE_ALIGN;
- const isLittleEndian = byteAlign === LITTLE_ENDIAN_BYTE_ALIGN;
- if (isBigEndian || isLittleEndian) {
- return extractOrientation(exifBlock, isBigEndian);
- }
- }
- function validateInput(input, index) {
- if (index > input.length) {
- throw new TypeError("Corrupt JPG, exceeded buffer limits");
- }
- }
- const JPG = {
- validate: (input) => toHexString(input, 0, 2) === "ffd8",
- calculate(input) {
- input = input.slice(4);
- let orientation;
- let next;
- while (input.length) {
- const i = readUInt16BE(input, 0);
- if (input[i] !== 255) {
- input = input.slice(i);
- continue;
- }
- if (isEXIF(input)) {
- orientation = validateExifBlock(input, i);
- }
- validateInput(input, i);
- next = input[i + 1];
- if (next === 192 || next === 193 || next === 194) {
- const size = extractSize(input, i + 5);
- if (!orientation) {
- return size;
- }
- return {
- height: size.height,
- orientation,
- width: size.width
- };
- }
- input = input.slice(i + 2);
- }
- throw new TypeError("Invalid JPG, no size found");
- }
- };
- const KTX = {
- validate: (input) => {
- const signature = toUTF8String(input, 1, 7);
- return ["KTX 11", "KTX 20"].includes(signature);
- },
- calculate: (input) => {
- const type = input[5] === 49 ? "ktx" : "ktx2";
- const offset = type === "ktx" ? 36 : 20;
- return {
- height: readUInt32LE(input, offset + 4),
- width: readUInt32LE(input, offset),
- type
- };
- }
- };
- const pngSignature = "PNG\r\n\n";
- const pngImageHeaderChunkName = "IHDR";
- const pngFriedChunkName = "CgBI";
- const PNG = {
- validate(input) {
- if (pngSignature === toUTF8String(input, 1, 8)) {
- let chunkName = toUTF8String(input, 12, 16);
- if (chunkName === pngFriedChunkName) {
- chunkName = toUTF8String(input, 28, 32);
- }
- if (chunkName !== pngImageHeaderChunkName) {
- throw new TypeError("Invalid PNG");
- }
- return true;
- }
- return false;
- },
- calculate(input) {
- if (toUTF8String(input, 12, 16) === pngFriedChunkName) {
- return {
- height: readUInt32BE(input, 36),
- width: readUInt32BE(input, 32)
- };
- }
- return {
- height: readUInt32BE(input, 20),
- width: readUInt32BE(input, 16)
- };
- }
- };
- const PNMTypes = {
- P1: "pbm/ascii",
- P2: "pgm/ascii",
- P3: "ppm/ascii",
- P4: "pbm",
- P5: "pgm",
- P6: "ppm",
- P7: "pam",
- PF: "pfm"
- };
- const handlers = {
- default: (lines) => {
- let dimensions = [];
- while (lines.length > 0) {
- const line = lines.shift();
- if (line[0] === "#") {
- continue;
- }
- dimensions = line.split(" ");
- break;
- }
- if (dimensions.length === 2) {
- return {
- height: parseInt(dimensions[1], 10),
- width: parseInt(dimensions[0], 10)
- };
- } else {
- throw new TypeError("Invalid PNM");
- }
- },
- pam: (lines) => {
- const size = {};
- while (lines.length > 0) {
- const line = lines.shift();
- if (line.length > 16 || line.charCodeAt(0) > 128) {
- continue;
- }
- const [key, value] = line.split(" ");
- if (key && value) {
- size[key.toLowerCase()] = parseInt(value, 10);
- }
- if (size.height && size.width) {
- break;
- }
- }
- if (size.height && size.width) {
- return {
- height: size.height,
- width: size.width
- };
- } else {
- throw new TypeError("Invalid PAM");
- }
- }
- };
- const PNM = {
- validate: (input) => toUTF8String(input, 0, 2) in PNMTypes,
- calculate(input) {
- const signature = toUTF8String(input, 0, 2);
- const type = PNMTypes[signature];
- const lines = toUTF8String(input, 3).split(/[\r\n]+/);
- const handler = handlers[type] || handlers.default;
- return handler(lines);
- }
- };
- const PSD = {
- validate: (input) => toUTF8String(input, 0, 4) === "8BPS",
- calculate: (input) => ({
- height: readUInt32BE(input, 14),
- width: readUInt32BE(input, 18)
- })
- };
- const svgReg = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/;
- const extractorRegExps = {
- height: /\sheight=(['"])([^%]+?)\1/,
- root: svgReg,
- viewbox: /\sviewBox=(['"])(.+?)\1/i,
- width: /\swidth=(['"])([^%]+?)\1/
- };
- const INCH_CM = 2.54;
- const units = {
- in: 96,
- cm: 96 / INCH_CM,
- em: 16,
- ex: 8,
- m: 96 / INCH_CM * 100,
- mm: 96 / INCH_CM / 10,
- pc: 96 / 72 / 12,
- pt: 96 / 72,
- px: 1
- };
- const unitsReg = new RegExp(
- `^([0-9.]+(?:e\\d+)?)(${Object.keys(units).join("|")})?$`
- );
- function parseLength(len) {
- const m = unitsReg.exec(len);
- if (!m) {
- return void 0;
- }
- return Math.round(Number(m[1]) * (units[m[2]] || 1));
- }
- function parseViewbox(viewbox) {
- const bounds = viewbox.split(" ");
- return {
- height: parseLength(bounds[3]),
- width: parseLength(bounds[2])
- };
- }
- function parseAttributes(root) {
- const width = extractorRegExps.width.exec(root);
- const height = extractorRegExps.height.exec(root);
- const viewbox = extractorRegExps.viewbox.exec(root);
- return {
- height: height && parseLength(height[2]),
- viewbox: viewbox && parseViewbox(viewbox[2]),
- width: width && parseLength(width[2])
- };
- }
- function calculateByDimensions(attrs) {
- return {
- height: attrs.height,
- width: attrs.width
- };
- }
- function calculateByViewbox(attrs, viewbox) {
- const ratio = viewbox.width / viewbox.height;
- if (attrs.width) {
- return {
- height: Math.floor(attrs.width / ratio),
- width: attrs.width
- };
- }
- if (attrs.height) {
- return {
- height: attrs.height,
- width: Math.floor(attrs.height * ratio)
- };
- }
- return {
- height: viewbox.height,
- width: viewbox.width
- };
- }
- const SVG = {
- // Scan only the first kilo-byte to speed up the check on larger files
- validate: (input) => svgReg.test(toUTF8String(input, 0, 1e3)),
- calculate(input) {
- const root = extractorRegExps.root.exec(toUTF8String(input));
- if (root) {
- const attrs = parseAttributes(root[0]);
- if (attrs.width && attrs.height) {
- return calculateByDimensions(attrs);
- }
- if (attrs.viewbox) {
- return calculateByViewbox(attrs, attrs.viewbox);
- }
- }
- throw new TypeError("Invalid SVG");
- }
- };
- const TGA = {
- validate(input) {
- return readUInt16LE(input, 0) === 0 && readUInt16LE(input, 4) === 0;
- },
- calculate(input) {
- return {
- height: readUInt16LE(input, 14),
- width: readUInt16LE(input, 12)
- };
- }
- };
- function readIFD(input, isBigEndian) {
- const ifdOffset = readUInt(input, 32, 4, isBigEndian);
- return input.slice(ifdOffset + 2);
- }
- function readValue(input, isBigEndian) {
- const low = readUInt(input, 16, 8, isBigEndian);
- const high = readUInt(input, 16, 10, isBigEndian);
- return (high << 16) + low;
- }
- function nextTag(input) {
- if (input.length > 24) {
- return input.slice(12);
- }
- }
- function extractTags(input, isBigEndian) {
- const tags = {};
- let temp = input;
- while (temp && temp.length) {
- const code = readUInt(temp, 16, 0, isBigEndian);
- const type = readUInt(temp, 16, 2, isBigEndian);
- const length = readUInt(temp, 32, 4, isBigEndian);
- if (code === 0) {
- break;
- } else {
- if (length === 1 && (type === 3 || type === 4)) {
- tags[code] = readValue(temp, isBigEndian);
- }
- temp = nextTag(temp);
- }
- }
- return tags;
- }
- function determineEndianness(input) {
- const signature = toUTF8String(input, 0, 2);
- if ("II" === signature) {
- return "LE";
- } else if ("MM" === signature) {
- return "BE";
- }
- }
- const signatures = [
- // '492049', // currently not supported
- "49492a00",
- // Little endian
- "4d4d002a"
- // Big Endian
- // '4d4d002a', // BigTIFF > 4GB. currently not supported
- ];
- const TIFF = {
- validate: (input) => signatures.includes(toHexString(input, 0, 4)),
- calculate(input) {
- const isBigEndian = determineEndianness(input) === "BE";
- const ifdBuffer = readIFD(input, isBigEndian);
- const tags = extractTags(ifdBuffer, isBigEndian);
- const width = tags[256];
- const height = tags[257];
- if (!width || !height) {
- throw new TypeError("Invalid Tiff. Missing tags");
- }
- return { height, width };
- }
- };
- function calculateExtended(input) {
- return {
- height: 1 + readUInt24LE(input, 7),
- width: 1 + readUInt24LE(input, 4)
- };
- }
- function calculateLossless(input) {
- return {
- height: 1 + ((input[4] & 15) << 10 | input[3] << 2 | (input[2] & 192) >> 6),
- width: 1 + ((input[2] & 63) << 8 | input[1])
- };
- }
- function calculateLossy(input) {
- return {
- height: readInt16LE(input, 8) & 16383,
- width: readInt16LE(input, 6) & 16383
- };
- }
- const WEBP = {
- validate(input) {
- const riffHeader = "RIFF" === toUTF8String(input, 0, 4);
- const webpHeader = "WEBP" === toUTF8String(input, 8, 12);
- const vp8Header = "VP8" === toUTF8String(input, 12, 15);
- return riffHeader && webpHeader && vp8Header;
- },
- calculate(input) {
- const chunkHeader = toUTF8String(input, 12, 16);
- input = input.slice(20, 30);
- if (chunkHeader === "VP8X") {
- const extendedHeader = input[0];
- const validStart = (extendedHeader & 192) === 0;
- const validEnd = (extendedHeader & 1) === 0;
- if (validStart && validEnd) {
- return calculateExtended(input);
- } else {
- throw new TypeError("Invalid WebP");
- }
- }
- if (chunkHeader === "VP8 " && input[0] !== 47) {
- return calculateLossy(input);
- }
- const signature = toHexString(input, 3, 6);
- if (chunkHeader === "VP8L" && signature !== "9d012a") {
- return calculateLossless(input);
- }
- throw new TypeError("Invalid WebP");
- }
- };
- const typeHandlers = /* @__PURE__ */ new Map([
- ["bmp", BMP],
- ["cur", CUR],
- ["dds", DDS],
- ["gif", GIF],
- ["heif", HEIF],
- ["icns", ICNS],
- ["ico", ICO],
- ["j2c", J2C],
- ["jp2", JP2],
- ["jpg", JPG],
- ["ktx", KTX],
- ["png", PNG],
- ["pnm", PNM],
- ["psd", PSD],
- ["svg", SVG],
- ["tga", TGA],
- ["tiff", TIFF],
- ["webp", WEBP]
- ]);
- const types = Array.from(typeHandlers.keys());
- const firstBytes = /* @__PURE__ */ new Map([
- [56, "psd"],
- [66, "bmp"],
- [68, "dds"],
- [71, "gif"],
- [73, "tiff"],
- [77, "tiff"],
- [82, "webp"],
- [105, "icns"],
- [137, "png"],
- [255, "jpg"]
- ]);
- function detector(input) {
- const byte = input[0];
- const type = firstBytes.get(byte);
- if (type && typeHandlers.get(type).validate(input)) {
- return type;
- }
- return types.find((fileType) => typeHandlers.get(fileType).validate(input));
- }
- function lookup$1(input) {
- const type = detector(input);
- if (typeof type !== "undefined") {
- const size = typeHandlers.get(type).calculate(input);
- if (size !== void 0) {
- size.type = size.type ?? type;
- return size;
- }
- }
- throw new TypeError("unsupported file type: " + type);
- }
- async function imageMetadata(data, src) {
- let result;
- try {
- result = lookup$1(data);
- } catch {
- throw new AstroError({
- ...NoImageMetadata,
- message: NoImageMetadata.message(src)
- });
- }
- if (!result.height || !result.width || !result.type) {
- throw new AstroError({
- ...NoImageMetadata,
- message: NoImageMetadata.message(src)
- });
- }
- const { width, height, type, orientation } = result;
- const isPortrait = (orientation || 0) >= 5;
- return {
- width: isPortrait ? height : width,
- height: isPortrait ? width : height,
- format: type,
- orientation
- };
- }
- async function inferRemoteSize(url) {
- const response = await fetch(url);
- if (!response.body || !response.ok) {
- throw new AstroError({
- ...FailedToFetchRemoteImageDimensions,
- message: FailedToFetchRemoteImageDimensions.message(url)
- });
- }
- const reader = response.body.getReader();
- let done, value;
- let accumulatedChunks = new Uint8Array();
- while (!done) {
- const readResult = await reader.read();
- done = readResult.done;
- if (done) break;
- if (readResult.value) {
- value = readResult.value;
- let tmp = new Uint8Array(accumulatedChunks.length + value.length);
- tmp.set(accumulatedChunks, 0);
- tmp.set(value, accumulatedChunks.length);
- accumulatedChunks = tmp;
- try {
- const dimensions = await imageMetadata(accumulatedChunks, url);
- if (dimensions) {
- await reader.cancel();
- return dimensions;
- }
- } catch {
- }
- }
- }
- throw new AstroError({
- ...NoImageMetadata,
- message: NoImageMetadata.message(url)
- });
- }
- async function getConfiguredImageService() {
- if (!globalThis?.astroAsset?.imageService) {
- const { default: service } = await import(
- // @ts-expect-error
- './sharp_CG4EIo5e.mjs'
- ).catch((e) => {
- const error = new AstroError(InvalidImageService);
- error.cause = e;
- throw error;
- });
- if (!globalThis.astroAsset) globalThis.astroAsset = {};
- globalThis.astroAsset.imageService = service;
- return service;
- }
- return globalThis.astroAsset.imageService;
- }
- async function getImage$1(options, imageConfig) {
- if (!options || typeof options !== "object") {
- throw new AstroError({
- ...ExpectedImageOptions,
- message: ExpectedImageOptions.message(JSON.stringify(options))
- });
- }
- if (typeof options.src === "undefined") {
- throw new AstroError({
- ...ExpectedImage,
- message: ExpectedImage.message(
- options.src,
- "undefined",
- JSON.stringify(options)
- )
- });
- }
- if (isImageMetadata(options)) {
- throw new AstroError(ExpectedNotESMImage);
- }
- const service = await getConfiguredImageService();
- const resolvedOptions = {
- ...options,
- src: await resolveSrc(options.src)
- };
- let originalWidth;
- let originalHeight;
- if (options.inferSize && isRemoteImage(resolvedOptions.src) && isRemotePath(resolvedOptions.src)) {
- const result = await inferRemoteSize(resolvedOptions.src);
- resolvedOptions.width ??= result.width;
- resolvedOptions.height ??= result.height;
- originalWidth = result.width;
- originalHeight = result.height;
- delete resolvedOptions.inferSize;
- }
- const originalFilePath = isESMImportedImage(resolvedOptions.src) ? resolvedOptions.src.fsPath : void 0;
- const clonedSrc = isESMImportedImage(resolvedOptions.src) ? (
- // @ts-expect-error - clone is a private, hidden prop
- resolvedOptions.src.clone ?? resolvedOptions.src
- ) : resolvedOptions.src;
- if (isESMImportedImage(clonedSrc)) {
- originalWidth = clonedSrc.width;
- originalHeight = clonedSrc.height;
- }
- if (originalWidth && originalHeight) {
- const aspectRatio = originalWidth / originalHeight;
- if (resolvedOptions.height && !resolvedOptions.width) {
- resolvedOptions.width = Math.round(resolvedOptions.height * aspectRatio);
- } else if (resolvedOptions.width && !resolvedOptions.height) {
- resolvedOptions.height = Math.round(resolvedOptions.width / aspectRatio);
- } else if (!resolvedOptions.width && !resolvedOptions.height) {
- resolvedOptions.width = originalWidth;
- resolvedOptions.height = originalHeight;
- }
- }
- resolvedOptions.src = clonedSrc;
- const layout = options.layout ?? imageConfig.layout ?? "none";
- if (resolvedOptions.priority) {
- resolvedOptions.loading ??= "eager";
- resolvedOptions.decoding ??= "sync";
- resolvedOptions.fetchpriority ??= "high";
- delete resolvedOptions.priority;
- } else {
- resolvedOptions.loading ??= "lazy";
- resolvedOptions.decoding ??= "async";
- resolvedOptions.fetchpriority ??= "auto";
- }
- if (layout !== "none") {
- resolvedOptions.widths ||= getWidths({
- width: resolvedOptions.width,
- layout,
- originalWidth,
- breakpoints: imageConfig.breakpoints?.length ? imageConfig.breakpoints : isLocalService(service) ? LIMITED_RESOLUTIONS : DEFAULT_RESOLUTIONS
- });
- resolvedOptions.sizes ||= getSizesAttribute({ width: resolvedOptions.width, layout });
- delete resolvedOptions.densities;
- resolvedOptions.style = addCSSVarsToStyle(
- {
- fit: cssFitValues.includes(resolvedOptions.fit ?? "") && resolvedOptions.fit,
- pos: resolvedOptions.position
- },
- resolvedOptions.style
- );
- resolvedOptions["data-astro-image"] = layout;
- }
- const validatedOptions = service.validateOptions ? await service.validateOptions(resolvedOptions, imageConfig) : resolvedOptions;
- const srcSetTransforms = service.getSrcSet ? await service.getSrcSet(validatedOptions, imageConfig) : [];
- let imageURL = await service.getURL(validatedOptions, imageConfig);
- const matchesValidatedTransform = (transform) => transform.width === validatedOptions.width && transform.height === validatedOptions.height && transform.format === validatedOptions.format;
- let srcSets = await Promise.all(
- srcSetTransforms.map(async (srcSet) => {
- return {
- transform: srcSet.transform,
- url: matchesValidatedTransform(srcSet.transform) ? imageURL : await service.getURL(srcSet.transform, imageConfig),
- descriptor: srcSet.descriptor,
- attributes: srcSet.attributes
- };
- })
- );
- if (isLocalService(service) && globalThis.astroAsset.addStaticImage && !(isRemoteImage(validatedOptions.src) && imageURL === validatedOptions.src)) {
- const propsToHash = service.propertiesToHash ?? DEFAULT_HASH_PROPS;
- imageURL = globalThis.astroAsset.addStaticImage(
- validatedOptions,
- propsToHash,
- originalFilePath
- );
- srcSets = srcSetTransforms.map((srcSet) => {
- return {
- transform: srcSet.transform,
- url: matchesValidatedTransform(srcSet.transform) ? imageURL : globalThis.astroAsset.addStaticImage(srcSet.transform, propsToHash, originalFilePath),
- descriptor: srcSet.descriptor,
- attributes: srcSet.attributes
- };
- });
- }
- return {
- rawOptions: resolvedOptions,
- options: validatedOptions,
- src: imageURL,
- srcSet: {
- values: srcSets,
- attribute: srcSets.map((srcSet) => `${srcSet.url} ${srcSet.descriptor}`).join(", ")
- },
- attributes: service.getHTMLAttributes !== void 0 ? await service.getHTMLAttributes(validatedOptions, imageConfig) : {}
- };
- }
- const $$Astro$2 = createAstro();
- const $$Image = createComponent(async ($$result, $$props, $$slots) => {
- const Astro2 = $$result.createAstro($$Astro$2, $$props, $$slots);
- Astro2.self = $$Image;
- const props = Astro2.props;
- if (props.alt === void 0 || props.alt === null) {
- throw new AstroError(ImageMissingAlt);
- }
- if (typeof props.width === "string") {
- props.width = parseInt(props.width);
- }
- if (typeof props.height === "string") {
- props.height = parseInt(props.height);
- }
- const layout = props.layout ?? imageConfig.layout ?? "none";
- if (layout !== "none") {
- props.layout ??= imageConfig.layout;
- props.fit ??= imageConfig.objectFit ?? "cover";
- props.position ??= imageConfig.objectPosition ?? "center";
- }
- const image = await getImage(props);
- const additionalAttributes = {};
- if (image.srcSet.values.length > 0) {
- additionalAttributes.srcset = image.srcSet.attribute;
- }
- const { class: className, ...attributes } = { ...additionalAttributes, ...image.attributes };
- return renderTemplate`${maybeRenderHead()}<img${addAttribute(image.src, "src")}${spreadAttributes(attributes)}${addAttribute(className, "class")}>`;
- }, "/home/fc/Projects/glance/node_modules/astro/components/Image.astro", void 0);
- const mimes = {
- "3g2": "video/3gpp2",
- "3gp": "video/3gpp",
- "3gpp": "video/3gpp",
- "3mf": "model/3mf",
- "aac": "audio/aac",
- "ac": "application/pkix-attr-cert",
- "adp": "audio/adpcm",
- "adts": "audio/aac",
- "ai": "application/postscript",
- "aml": "application/automationml-aml+xml",
- "amlx": "application/automationml-amlx+zip",
- "amr": "audio/amr",
- "apng": "image/apng",
- "appcache": "text/cache-manifest",
- "appinstaller": "application/appinstaller",
- "appx": "application/appx",
- "appxbundle": "application/appxbundle",
- "asc": "application/pgp-keys",
- "atom": "application/atom+xml",
- "atomcat": "application/atomcat+xml",
- "atomdeleted": "application/atomdeleted+xml",
- "atomsvc": "application/atomsvc+xml",
- "au": "audio/basic",
- "avci": "image/avci",
- "avcs": "image/avcs",
- "avif": "image/avif",
- "aw": "application/applixware",
- "bdoc": "application/bdoc",
- "bin": "application/octet-stream",
- "bmp": "image/bmp",
- "bpk": "application/octet-stream",
- "btf": "image/prs.btif",
- "btif": "image/prs.btif",
- "buffer": "application/octet-stream",
- "ccxml": "application/ccxml+xml",
- "cdfx": "application/cdfx+xml",
- "cdmia": "application/cdmi-capability",
- "cdmic": "application/cdmi-container",
- "cdmid": "application/cdmi-domain",
- "cdmio": "application/cdmi-object",
- "cdmiq": "application/cdmi-queue",
- "cer": "application/pkix-cert",
- "cgm": "image/cgm",
- "cjs": "application/node",
- "class": "application/java-vm",
- "coffee": "text/coffeescript",
- "conf": "text/plain",
- "cpl": "application/cpl+xml",
- "cpt": "application/mac-compactpro",
- "crl": "application/pkix-crl",
- "css": "text/css",
- "csv": "text/csv",
- "cu": "application/cu-seeme",
- "cwl": "application/cwl",
- "cww": "application/prs.cww",
- "davmount": "application/davmount+xml",
- "dbk": "application/docbook+xml",
- "deb": "application/octet-stream",
- "def": "text/plain",
- "deploy": "application/octet-stream",
- "dib": "image/bmp",
- "disposition-notification": "message/disposition-notification",
- "dist": "application/octet-stream",
- "distz": "application/octet-stream",
- "dll": "application/octet-stream",
- "dmg": "application/octet-stream",
- "dms": "application/octet-stream",
- "doc": "application/msword",
- "dot": "application/msword",
- "dpx": "image/dpx",
- "drle": "image/dicom-rle",
- "dsc": "text/prs.lines.tag",
- "dssc": "application/dssc+der",
- "dtd": "application/xml-dtd",
- "dump": "application/octet-stream",
- "dwd": "application/atsc-dwd+xml",
- "ear": "application/java-archive",
- "ecma": "application/ecmascript",
- "elc": "application/octet-stream",
- "emf": "image/emf",
- "eml": "message/rfc822",
- "emma": "application/emma+xml",
- "emotionml": "application/emotionml+xml",
- "eps": "application/postscript",
- "epub": "application/epub+zip",
- "exe": "application/octet-stream",
- "exi": "application/exi",
- "exp": "application/express",
- "exr": "image/aces",
- "ez": "application/andrew-inset",
- "fdf": "application/fdf",
- "fdt": "application/fdt+xml",
- "fits": "image/fits",
- "g3": "image/g3fax",
- "gbr": "application/rpki-ghostbusters",
- "geojson": "application/geo+json",
- "gif": "image/gif",
- "glb": "model/gltf-binary",
- "gltf": "model/gltf+json",
- "gml": "application/gml+xml",
- "gpx": "application/gpx+xml",
- "gram": "application/srgs",
- "grxml": "application/srgs+xml",
- "gxf": "application/gxf",
- "gz": "application/gzip",
- "h261": "video/h261",
- "h263": "video/h263",
- "h264": "video/h264",
- "heic": "image/heic",
- "heics": "image/heic-sequence",
- "heif": "image/heif",
- "heifs": "image/heif-sequence",
- "hej2": "image/hej2k",
- "held": "application/atsc-held+xml",
- "hjson": "application/hjson",
- "hlp": "application/winhlp",
- "hqx": "application/mac-binhex40",
- "hsj2": "image/hsj2",
- "htm": "text/html",
- "html": "text/html",
- "ics": "text/calendar",
- "ief": "image/ief",
- "ifb": "text/calendar",
- "iges": "model/iges",
- "igs": "model/iges",
- "img": "application/octet-stream",
- "in": "text/plain",
- "ini": "text/plain",
- "ink": "application/inkml+xml",
- "inkml": "application/inkml+xml",
- "ipfix": "application/ipfix",
- "iso": "application/octet-stream",
- "its": "application/its+xml",
- "jade": "text/jade",
- "jar": "application/java-archive",
- "jhc": "image/jphc",
- "jls": "image/jls",
- "jp2": "image/jp2",
- "jpe": "image/jpeg",
- "jpeg": "image/jpeg",
- "jpf": "image/jpx",
- "jpg": "image/jpeg",
- "jpg2": "image/jp2",
- "jpgm": "image/jpm",
- "jpgv": "video/jpeg",
- "jph": "image/jph",
- "jpm": "image/jpm",
- "jpx": "image/jpx",
- "js": "text/javascript",
- "json": "application/json",
- "json5": "application/json5",
- "jsonld": "application/ld+json",
- "jsonml": "application/jsonml+json",
- "jsx": "text/jsx",
- "jt": "model/jt",
- "jxl": "image/jxl",
- "jxr": "image/jxr",
- "jxra": "image/jxra",
- "jxrs": "image/jxrs",
- "jxs": "image/jxs",
- "jxsc": "image/jxsc",
- "jxsi": "image/jxsi",
- "jxss": "image/jxss",
- "kar": "audio/midi",
- "ktx": "image/ktx",
- "ktx2": "image/ktx2",
- "less": "text/less",
- "lgr": "application/lgr+xml",
- "list": "text/plain",
- "litcoffee": "text/coffeescript",
- "log": "text/plain",
- "lostxml": "application/lost+xml",
- "lrf": "application/octet-stream",
- "m1v": "video/mpeg",
- "m21": "application/mp21",
- "m2a": "audio/mpeg",
- "m2t": "video/mp2t",
- "m2ts": "video/mp2t",
- "m2v": "video/mpeg",
- "m3a": "audio/mpeg",
- "m4a": "audio/mp4",
- "m4p": "application/mp4",
- "m4s": "video/iso.segment",
- "ma": "application/mathematica",
- "mads": "application/mads+xml",
- "maei": "application/mmt-aei+xml",
- "man": "text/troff",
- "manifest": "text/cache-manifest",
- "map": "application/json",
- "mar": "application/octet-stream",
- "markdown": "text/markdown",
- "mathml": "application/mathml+xml",
- "mb": "application/mathematica",
- "mbox": "application/mbox",
- "md": "text/markdown",
- "mdx": "text/mdx",
- "me": "text/troff",
- "mesh": "model/mesh",
- "meta4": "application/metalink4+xml",
- "metalink": "application/metalink+xml",
- "mets": "application/mets+xml",
- "mft": "application/rpki-manifest",
- "mid": "audio/midi",
- "midi": "audio/midi",
- "mime": "message/rfc822",
- "mj2": "video/mj2",
- "mjp2": "video/mj2",
- "mjs": "text/javascript",
- "mml": "text/mathml",
- "mods": "application/mods+xml",
- "mov": "video/quicktime",
- "mp2": "audio/mpeg",
- "mp21": "application/mp21",
- "mp2a": "audio/mpeg",
- "mp3": "audio/mpeg",
- "mp4": "video/mp4",
- "mp4a": "audio/mp4",
- "mp4s": "application/mp4",
- "mp4v": "video/mp4",
- "mpd": "application/dash+xml",
- "mpe": "video/mpeg",
- "mpeg": "video/mpeg",
- "mpf": "application/media-policy-dataset+xml",
- "mpg": "video/mpeg",
- "mpg4": "video/mp4",
- "mpga": "audio/mpeg",
- "mpp": "application/dash-patch+xml",
- "mrc": "application/marc",
- "mrcx": "application/marcxml+xml",
- "ms": "text/troff",
- "mscml": "application/mediaservercontrol+xml",
- "msh": "model/mesh",
- "msi": "application/octet-stream",
- "msix": "application/msix",
- "msixbundle": "application/msixbundle",
- "msm": "application/octet-stream",
- "msp": "application/octet-stream",
- "mtl": "model/mtl",
- "mts": "video/mp2t",
- "musd": "application/mmt-usd+xml",
- "mxf": "application/mxf",
- "mxmf": "audio/mobile-xmf",
- "mxml": "application/xv+xml",
- "n3": "text/n3",
- "nb": "application/mathematica",
- "nq": "application/n-quads",
- "nt": "application/n-triples",
- "obj": "model/obj",
- "oda": "application/oda",
- "oga": "audio/ogg",
- "ogg": "audio/ogg",
- "ogv": "video/ogg",
- "ogx": "application/ogg",
- "omdoc": "application/omdoc+xml",
- "onepkg": "application/onenote",
- "onetmp": "application/onenote",
- "onetoc": "application/onenote",
- "onetoc2": "application/onenote",
- "opf": "application/oebps-package+xml",
- "opus": "audio/ogg",
- "otf": "font/otf",
- "owl": "application/rdf+xml",
- "oxps": "application/oxps",
- "p10": "application/pkcs10",
- "p7c": "application/pkcs7-mime",
- "p7m": "application/pkcs7-mime",
- "p7s": "application/pkcs7-signature",
- "p8": "application/pkcs8",
- "pdf": "application/pdf",
- "pfr": "application/font-tdpfr",
- "pgp": "application/pgp-encrypted",
- "pkg": "application/octet-stream",
- "pki": "application/pkixcmp",
- "pkipath": "application/pkix-pkipath",
- "pls": "application/pls+xml",
- "png": "image/png",
- "prc": "model/prc",
- "prf": "application/pics-rules",
- "provx": "application/provenance+xml",
- "ps": "application/postscript",
- "pskcxml": "application/pskc+xml",
- "pti": "image/prs.pti",
- "qt": "video/quicktime",
- "raml": "application/raml+yaml",
- "rapd": "application/route-apd+xml",
- "rdf": "application/rdf+xml",
- "relo": "application/p2p-overlay+xml",
- "rif": "application/reginfo+xml",
- "rl": "application/resource-lists+xml",
- "rld": "application/resource-lists-diff+xml",
- "rmi": "audio/midi",
- "rnc": "application/relax-ng-compact-syntax",
- "rng": "application/xml",
- "roa": "application/rpki-roa",
- "roff": "text/troff",
- "rq": "application/sparql-query",
- "rs": "application/rls-services+xml",
- "rsat": "application/atsc-rsat+xml",
- "rsd": "application/rsd+xml",
- "rsheet": "application/urc-ressheet+xml",
- "rss": "application/rss+xml",
- "rtf": "text/rtf",
- "rtx": "text/richtext",
- "rusd": "application/route-usd+xml",
- "s3m": "audio/s3m",
- "sbml": "application/sbml+xml",
- "scq": "application/scvp-cv-request",
- "scs": "application/scvp-cv-response",
- "sdp": "application/sdp",
- "senmlx": "application/senml+xml",
- "sensmlx": "application/sensml+xml",
- "ser": "application/java-serialized-object",
- "setpay": "application/set-payment-initiation",
- "setreg": "application/set-registration-initiation",
- "sgi": "image/sgi",
- "sgm": "text/sgml",
- "sgml": "text/sgml",
- "shex": "text/shex",
- "shf": "application/shf+xml",
- "shtml": "text/html",
- "sieve": "application/sieve",
- "sig": "application/pgp-signature",
- "sil": "audio/silk",
- "silo": "model/mesh",
- "siv": "application/sieve",
- "slim": "text/slim",
- "slm": "text/slim",
- "sls": "application/route-s-tsid+xml",
- "smi": "application/smil+xml",
- "smil": "application/smil+xml",
- "snd": "audio/basic",
- "so": "application/octet-stream",
- "spdx": "text/spdx",
- "spp": "application/scvp-vp-response",
- "spq": "application/scvp-vp-request",
- "spx": "audio/ogg",
- "sql": "application/sql",
- "sru": "application/sru+xml",
- "srx": "application/sparql-results+xml",
- "ssdl": "application/ssdl+xml",
- "ssml": "application/ssml+xml",
- "stk": "application/hyperstudio",
- "stl": "model/stl",
- "stpx": "model/step+xml",
- "stpxz": "model/step-xml+zip",
- "stpz": "model/step+zip",
- "styl": "text/stylus",
- "stylus": "text/stylus",
- "svg": "image/svg+xml",
- "svgz": "image/svg+xml",
- "swidtag": "application/swid+xml",
- "t": "text/troff",
- "t38": "image/t38",
- "td": "application/urc-targetdesc+xml",
- "tei": "application/tei+xml",
- "teicorpus": "application/tei+xml",
- "text": "text/plain",
- "tfi": "application/thraud+xml",
- "tfx": "image/tiff-fx",
- "tif": "image/tiff",
- "tiff": "image/tiff",
- "toml": "application/toml",
- "tr": "text/troff",
- "trig": "application/trig",
- "ts": "video/mp2t",
- "tsd": "application/timestamped-data",
- "tsv": "text/tab-separated-values",
- "ttc": "font/collection",
- "ttf": "font/ttf",
- "ttl": "text/turtle",
- "ttml": "application/ttml+xml",
- "txt": "text/plain",
- "u3d": "model/u3d",
- "u8dsn": "message/global-delivery-status",
- "u8hdr": "message/global-headers",
- "u8mdn": "message/global-disposition-notification",
- "u8msg": "message/global",
- "ubj": "application/ubjson",
- "uri": "text/uri-list",
- "uris": "text/uri-list",
- "urls": "text/uri-list",
- "vcard": "text/vcard",
- "vrml": "model/vrml",
- "vtt": "text/vtt",
- "vxml": "application/voicexml+xml",
- "war": "application/java-archive",
- "wasm": "application/wasm",
- "wav": "audio/wav",
- "weba": "audio/webm",
- "webm": "video/webm",
- "webmanifest": "application/manifest+json",
- "webp": "image/webp",
- "wgsl": "text/wgsl",
- "wgt": "application/widget",
- "wif": "application/watcherinfo+xml",
- "wmf": "image/wmf",
- "woff": "font/woff",
- "woff2": "font/woff2",
- "wrl": "model/vrml",
- "wsdl": "application/wsdl+xml",
- "wspolicy": "application/wspolicy+xml",
- "x3d": "model/x3d+xml",
- "x3db": "model/x3d+fastinfoset",
- "x3dbz": "model/x3d+binary",
- "x3dv": "model/x3d-vrml",
- "x3dvz": "model/x3d+vrml",
- "x3dz": "model/x3d+xml",
- "xaml": "application/xaml+xml",
- "xav": "application/xcap-att+xml",
- "xca": "application/xcap-caps+xml",
- "xcs": "application/calendar+xml",
- "xdf": "application/xcap-diff+xml",
- "xdssc": "application/dssc+xml",
- "xel": "application/xcap-el+xml",
- "xenc": "application/xenc+xml",
- "xer": "application/patch-ops-error+xml",
- "xfdf": "application/xfdf",
- "xht": "application/xhtml+xml",
- "xhtml": "application/xhtml+xml",
- "xhvml": "application/xv+xml",
- "xlf": "application/xliff+xml",
- "xm": "audio/xm",
- "xml": "text/xml",
- "xns": "application/xcap-ns+xml",
- "xop": "application/xop+xml",
- "xpl": "application/xproc+xml",
- "xsd": "application/xml",
- "xsf": "application/prs.xsf+xml",
- "xsl": "application/xml",
- "xslt": "application/xml",
- "xspf": "application/xspf+xml",
- "xvm": "application/xv+xml",
- "xvml": "application/xv+xml",
- "yaml": "text/yaml",
- "yang": "application/yang",
- "yin": "application/yin+xml",
- "yml": "text/yaml",
- "zip": "application/zip"
- };
- function lookup(extn) {
- let tmp = ('' + extn).trim().toLowerCase();
- let idx = tmp.lastIndexOf('.');
- return mimes[!~idx ? tmp : tmp.substring(++idx)];
- }
- const $$Astro$1 = createAstro();
- const $$Picture = createComponent(async ($$result, $$props, $$slots) => {
- const Astro2 = $$result.createAstro($$Astro$1, $$props, $$slots);
- Astro2.self = $$Picture;
- const defaultFormats = ["webp"];
- const defaultFallbackFormat = "png";
- const specialFormatsFallback = ["gif", "svg", "jpg", "jpeg"];
- const { formats = defaultFormats, pictureAttributes = {}, fallbackFormat, ...props } = Astro2.props;
- if (props.alt === void 0 || props.alt === null) {
- throw new AstroError(ImageMissingAlt);
- }
- const scopedStyleClass = props.class?.match(/\bastro-\w{8}\b/)?.[0];
- if (scopedStyleClass) {
- if (pictureAttributes.class) {
- pictureAttributes.class = `${pictureAttributes.class} ${scopedStyleClass}`;
- } else {
- pictureAttributes.class = scopedStyleClass;
- }
- }
- const layout = props.layout ?? imageConfig.layout ?? "none";
- const useResponsive = layout !== "none";
- if (useResponsive) {
- props.layout ??= imageConfig.layout;
- props.fit ??= imageConfig.objectFit ?? "cover";
- props.position ??= imageConfig.objectPosition ?? "center";
- }
- for (const key in props) {
- if (key.startsWith("data-astro-cid")) {
- pictureAttributes[key] = props[key];
- }
- }
- const originalSrc = await resolveSrc(props.src);
- const optimizedImages = await Promise.all(
- formats.map(
- async (format) => await getImage({
- ...props,
- src: originalSrc,
- format,
- widths: props.widths,
- densities: props.densities
- })
- )
- );
- let resultFallbackFormat = fallbackFormat ?? defaultFallbackFormat;
- if (!fallbackFormat && isESMImportedImage(originalSrc) && specialFormatsFallback.includes(originalSrc.format)) {
- resultFallbackFormat = originalSrc.format;
- }
- const fallbackImage = await getImage({
- ...props,
- format: resultFallbackFormat,
- widths: props.widths,
- densities: props.densities
- });
- const imgAdditionalAttributes = {};
- const sourceAdditionalAttributes = {};
- if (props.sizes) {
- sourceAdditionalAttributes.sizes = props.sizes;
- }
- if (fallbackImage.srcSet.values.length > 0) {
- imgAdditionalAttributes.srcset = fallbackImage.srcSet.attribute;
- }
- const { class: className, ...attributes } = {
- ...imgAdditionalAttributes,
- ...fallbackImage.attributes
- };
- return renderTemplate`${maybeRenderHead()}<picture${spreadAttributes(pictureAttributes)}> ${Object.entries(optimizedImages).map(([_, image]) => {
- const srcsetAttribute = props.densities || !props.densities && !props.widths && !useResponsive ? `${image.src}${image.srcSet.values.length > 0 ? ", " + image.srcSet.attribute : ""}` : image.srcSet.attribute;
- return renderTemplate`<source${addAttribute(srcsetAttribute, "srcset")}${addAttribute(lookup(image.options.format ?? image.src) ?? `image/${image.options.format}`, "type")}${spreadAttributes(sourceAdditionalAttributes)}>`;
- })} <img${addAttribute(fallbackImage.src, "src")}${spreadAttributes(attributes)}${addAttribute(className, "class")}> </picture>`;
- }, "/home/fc/Projects/glance/node_modules/astro/components/Picture.astro", void 0);
- const fontsMod = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
- __proto__: null
- }, Symbol.toStringTag, { value: 'Module' }));
- const $$Astro = createAstro();
- const $$Font = createComponent(($$result, $$props, $$slots) => {
- const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
- Astro2.self = $$Font;
- const { internalConsumableMap } = fontsMod;
- if (!internalConsumableMap) {
- throw new AstroError(ExperimentalFontsNotEnabled);
- }
- const { cssVariable, preload = false } = Astro2.props;
- const data = internalConsumableMap.get(cssVariable);
- if (!data) {
- throw new AstroError({
- ...FontFamilyNotFound,
- message: FontFamilyNotFound.message(cssVariable)
- });
- }
- return renderTemplate`${preload && data.preloadData.map(({ url, type }) => renderTemplate`<link rel="preload"${addAttribute(url, "href")} as="font"${addAttribute(`font/${type}`, "type")} crossorigin>`)}<style>${unescapeHTML(data.css)}</style>`;
- }, "/home/fc/Projects/glance/node_modules/astro/components/Font.astro", void 0);
- const imageConfig = {"endpoint":{"route":"/_image","entrypoint":"@astrojs/cloudflare/image-endpoint"},"service":{"entrypoint":"astro/assets/services/sharp","config":{}},"domains":[],"remotePatterns":[],"responsiveStyles":false};
- const getImage = async (options) => await getImage$1(options, imageConfig);
- const prerender = false;
- const GET = (ctx) => {
- const href = ctx.url.searchParams.get("href");
- if (!href) {
- return new Response("Missing 'href' query parameter", {
- status: 400,
- statusText: "Missing 'href' query parameter"
- });
- }
- if (isRemotePath(href)) {
- if (isRemoteAllowed(href, imageConfig) === false) {
- return new Response("Forbidden", { status: 403 });
- } else {
- return Response.redirect(href, 302);
- }
- }
- const proxied = new URL(href, ctx.url.origin);
- if (proxied.origin !== ctx.url.origin) {
- return new Response("Forbidden", { status: 403 });
- }
- return fetch(proxied);
- };
- const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
- __proto__: null,
- GET,
- prerender
- }, Symbol.toStringTag, { value: 'Module' }));
- const page = () => _page;
- export { page as a, baseService as b, parseQuality as p };
|