TrinetraLabs/Placebo_AI
0
1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3exports.detector = void 0;4const index_1 = require("./types/index");5const keys = Object.keys(index_1.typeHandlers);6// This map helps avoid validating for every single image type7const firstBytes = {8 0x38: 'psd',9 0x42: 'bmp',10 0x44: 'dds',11 0x47: 'gif',12 0x49: 'tiff',13 0x4d: 'tiff',14 0x52: 'webp',15 0x69: 'icns',16 0x89: 'png',17 0xff: 'jpg',18};19function detector(input) {20 const byte = input[0];21 if (byte in firstBytes) {22 const type = firstBytes[byte];23 if (type && index_1.typeHandlers[type].validate(input)) {24 return type;25 }26 }27 const finder = (key) => index_1.typeHandlers[key].validate(input);28 return keys.find(finder);29}30exports.detector = detector;31 