// Detect It Easy: detection rule file

// Author: DosX
// E-Mail: collab@kay-software.ru
// GitHub: https://github.com/DosX-dev
// Telegram: @DosX_dev
// Updated by BJNFNE

const detect = main;

function main() {
    if (Binary.isHeuristicScan()) {

        const
            currentFileExtension = Binary.getFileSuffix().toLowerCase(),
            isBinaryFile = !Binary.isPlainText(),
            extensionsDb = [
                { ext: ["cmd", "bat"], type: "language", name: "Batch", bin: false },
                { ext: ["html", "htm"], type: "language", name: "HTM", bin: false },
                { ext: ["css"], type: "language", name: "Cascading Style Sheets", bin: false },
                { ext: ["c", "h"], type: "language", name: "C", bin: false },
                { ext: ["cpp", "hpp"], type: "language", name: "C++", bin: false },
                { ext: ["cs"], type: "language", name: "C#", bin: false },
                { ext: ["java"], type: "language", name: "Java", bin: false },
                { ext: ["py"], type: "language", name: "Python 🐓", bin: false },
                { ext: ["json"], type: "language", name: "JavaScript Object Notation", bin: false },
                { ext: ["xml"], type: "language", name: "Extensible Markup", bin: false },
                { ext: ["ini"], type: "format", name: "Configuration File", bin: false },
                { ext: ["yml", "yaml"], type: "language", name: "YAML", bin: false },
                { ext: ["php"], type: "language", name: "PHP", bin: false },
                { ext: ["rb"], type: "language", name: "Ruby", bin: false },
                { ext: ["pl"], type: "language", name: "Perl", bin: false },
                { ext: ["swift"], type: "language", name: "Swift", bin: false },
                { ext: ["rs"], type: "language", name: "Rust", bin: false },
                { ext: ["go"], type: "language", name: "Go", bin: false },
                { ext: ["ts"], type: "language", name: "TypeScript", bin: false },
                { ext: ["kt"], type: "language", name: "Kotlin", bin: false },
                { ext: ["dart"], type: "language", name: "Dart", bin: false },
                { ext: ["lua"], type: "language", name: "Lua", bin: false },
                { ext: ["sh"], type: "language", name: "Bash", bin: false },
                { ext: ["r"], type: "language", name: "R", bin: false },
                { ext: ["scala"], type: "language", name: "Scala", bin: false },
                { ext: ["lisp"], type: "language", name: "Lisp", bin: false },
                { ext: ["clj"], type: "language", name: "Clojure", bin: false },
                { ext: ["asm"], type: "language", name: "Assembly", bin: false },
                { ext: ["vb"], type: "language", name: "VB.NET", bin: false },
                { ext: ["fs"], type: "language", name: "F#", bin: false },
                { ext: ["ps1"], type: "language", name: "PowerShell Script", bin: false },
                { ext: ["ml"], type: "language", name: "OCaml", bin: false },
                { ext: ["hs"], type: "language", name: "Haskell", bin: false },
                { ext: ["vhd"], type: "language", name: "VHDL", bin: false },
                { ext: ["verilog"], type: "language", name: "Verilog", bin: false },
                { ext: ["ada"], type: "language", name: "Ada", bin: false },
                { ext: ["for"], type: "language", name: "Fortran", bin: false },
                { ext: ["pas"], type: "language", name: "Pascal", bin: false },
                { ext: ["m"], type: "language", name: "Objective-C", bin: false },
                { ext: ["v"], type: "language", name: "V", bin: false },
                { ext: ["img", "iso"], type: "format", name: "Disk Image", bin: true },
                { ext: ["dmg"], type: "format", name: "Apple Disk Image", bin: true },
                { ext: ["cab"], type: "format", name: "Cabinet Archive", bin: true },
                { ext: ["dat"], type: "format", name: "Data File", bin: true },
                { ext: ["vmdk"], type: "format", name: "VMware Virtual Disk", bin: true },
                { ext: ["vhd", "vhdx"], type: "format", name: "Virtual Hard Disk", bin: true },
                { ext: ["apk"], type: "format", name: "Android Package", bin: true },
                { ext: ["so"], type: "format", name: "Shared Object Library", bin: true },
                { ext: ["obj"], type: "format", name: "Object File", bin: true },
                { ext: ["a"], type: "format", name: "Static Library", bin: true },
                { ext: ["lib"], type: "format", name: "Library File", bin: true },
                { ext: ["o"], type: "format", name: "Compiled Object File", bin: true },
                { ext: ["pdb"], type: "format", name: "Program Database", bin: true },
                { ext: ["nso"], type: "format", name: "Nintendo Switch Object", bin: true },
                { ext: ["iso"], type: "format", name: "ISO Disk Image", bin: true },
                { ext: ["img"], type: "format", name: "Raw Disk Image", bin: true },
                { ext: ["dylib"], type: "format", name: "Dynamic Library (macOS)", bin: true },
                { ext: ["xex"], type: "format", name: "Xbox Executable File", bin: true },
                { ext: ["rom"], type: "format", name: "ROM Image", bin: true },
                { ext: ["pe"], type: "format", name: "Portable Executable", bin: true },
                { ext: ["bpl"], type: "format", name: "Borland Package Library", bin: true },
                { ext: ["vbx"], type: "format", name: "Visual Basic", bin: true },
                { ext: ["ocx"], type: "format", name: "ActiveX Control", bin: true },
                { ext: ["psd"], type: "format", name: "Photoshop Document", bin: true },
                { ext: ["ai"], type: "format", name: "Adobe Illustrator", bin: true },
                { ext: ["indd"], type: "format", name: "InDesign Document", bin: true },
                { ext: ["xd"], type: "format", name: "Adobe XD", bin: true },
                { ext: ["svg"], type: "format", name: "Scalable Vector Graphics", bin: false },
                { ext: ["blend"], type: "format", name: "Blender Project", bin: true },
                { ext: ["obj"], type: "format", name: "3D Object", bin: true },
                { ext: ["fbx"], type: "format", name: "Autodesk FBX", bin: true },
                { ext: ["stl"], type: "format", name: "STL Model", bin: true },
                { ext: ["gltf", "glb"], type: "format", name: "GLTF/GLB Model", bin: true },
                { ext: ["png"], type: "format", name: "Portable Network Graphics", bin: true },
                { ext: ["jpg", "jpeg"], type: "format", name: "JPEG Image", bin: true },
                { ext: ["bmp"], type: "format", name: "Bitmap Image", bin: true },
                { ext: ["tiff"], type: "format", name: "Tagged Image File Format", bin: true },
                { ext: ["tga"], type: "format", name: "Targa Image", bin: true },
                { ext: ["heic"], type: "format", name: "High Efficiency Image Format", bin: true },
                { ext: ["raw", "cr2", "nef", "orf"], type: "format", name: "RAW Image", bin: true },
                { ext: ["eps"], type: "format", name: "Encapsulated PostScript", bin: true },
                { ext: ["3ds"], type: "format", name: "3D Studio Max", bin: true },
                { ext: ["max"], type: "format", name: "3ds Max Project", bin: true },
                { ext: ["c4d"], type: "format", name: "Cinema 4D Project", bin: true },
                { ext: ["dae"], type: "format", name: "Collada", bin: true },
                { ext: ["skp"], type: "format", name: "SketchUp", bin: true },
                { ext: ["dxf"], type: "format", name: "Drawing Exchange Format", bin: true },
                { ext: ["dwg"], type: "format", name: "AutoCAD Drawing", bin: true },
                { ext: ["iges", "igs"], type: "format", name: "IGES Model", bin: true },
                { ext: ["step", "stp"], type: "format", name: "STEP Model", bin: true },
                { ext: ["vrml", "wrl"], type: "format", name: "VRML Model", bin: true },
                { ext: ["x3d"], type: "format", name: "X3D Model", bin: true },
                { ext: ["mp4"], type: "format", name: "MPEG-4 Video", bin: true },
                { ext: ["bik"], type: "format", name: "Bink Video", bin: true },
                { ext: ["mkv"], type: "format", name: "Matroska Video", bin: true },
                { ext: ["avi"], type: "format", name: "AVI Video", bin: true },
                { ext: ["mov"], type: "format", name: "QuickTime Movie", bin: true },
                { ext: ["flv"], type: "format", name: "Flash Video", bin: true },
                { ext: ["webm"], type: "format", name: "WebM Video", bin: true },
                { ext: ["mp3"], type: "format", name: "MP3 Audio", bin: true },
                { ext: ["wav"], type: "format", name: "Waveform Audio", bin: true },
                { ext: ["aac"], type: "format", name: "Advanced Audio Coding", bin: true },
                { ext: ["ogg"], type: "format", name: "Ogg Vorbis", bin: true },
                { ext: ["m4a"], type: "format", name: "MPEG-4 Audio", bin: true },
                { ext: ["wma"], type: "format", name: "Windows Media Audio", bin: true },
                { ext: ["prproj"], type: "format", name: "Premiere Pro Project", bin: true },
                { ext: ["aep"], type: "format", name: "After Effects Project", bin: true },
                { ext: ["psb"], type: "format", name: "Photoshop Big Document", bin: true },
                { ext: ["cdr"], type: "format", name: "CorelDRAW Image", bin: true },
                { ext: ["afdesign"], type: "format", name: "Affinity Designer", bin: true },
                { ext: ["afphoto"], type: "format", name: "Affinity Photo", bin: true },
                { ext: ["afpub"], type: "format", name: "Affinity Publisher", bin: true },
                { ext: ["sketch"], type: "format", name: "Sketch Project", bin: true },
                { ext: ["xcf"], type: "format", name: "GIMP Image", bin: true },
                { ext: ["kra"], type: "format", name: "Krita Image", bin: true },
                { ext: ["vproj"], type: "format", name: "Vegas Pro Project", bin: true },
                { ext: ["wpd"], type: "format", name: "WordPerfect Document", bin: true },
                { ext: ["vpj"], type: "format", name: "VideoPad Project", bin: true },
                { ext: ["prtl"], type: "format", name: "Premiere Title", bin: true },
                { ext: ["pdn"], type: "format", name: "Paint.NET Image", bin: true },
                { ext: ["tmp", "temp"], type: "format", name: "Temporary file", bin: true },
                { ext: ["tmp", "temp"], type: "format", name: "Temporary file", bin: false },
                { ext: ["mb"], type: "format", name: "Maya Binary Project", bin: true },
                { ext: ["ma"], type: "format", name: "Maya ASCII Project", bin: true },
                { ext: ["lwo"], type: "format", name: "LightWave Object", bin: true },
                { ext: ["lws"], type: "format", name: "LightWave Scene", bin: true },
                { ext: ["obj"], type: "format", name: "Wavefront OBJ", bin: true },
                { ext: ["abc"], type: "format", name: "Alembic", bin: true },
                { ext: ["bgeo"], type: "format", name: "Houdini Geometry", bin: true },
                { ext: ["vdb"], type: "format", name: "OpenVDB", bin: true },
                { ext: ["usd"], type: "format", name: "Universal Scene Description", bin: true },
                { ext: ["usdz"], type: "format", name: "Universal Scene Description (zipped)", bin: true },
                { ext: ["vox"], type: "format", name: "MagicaVoxel", bin: true },
                { ext: ["cob"], type: "format", name: "Caligari Object", bin: true },
                { ext: ["scn"], type: "format", name: "3D Scene", bin: true },
                { ext: ["3dm"], type: "format", name: "Rhinoceros 3D Model", bin: true },
                { ext: ["ztl"], type: "format", name: "ZBrush Tool", bin: true },
                { ext: ["zpr"], type: "format", name: "ZBrush Project", bin: true },
                { ext: ["bip"], type: "format", name: "Character Studio Biped", bin: true },
                { ext: ["3mf"], type: "format", name: "3D Manufacturing Format", bin: true },
                { ext: ["ply"], type: "format", name: "Polygon File Format", bin: true },
                { ext: ["x"], type: "format", name: "DirectX Model", bin: true },
                { ext: ["ms3d"], type: "format", name: "MilkShape 3D Model", bin: true },
                { ext: ["nif"], type: "format", name: "Gamebryo Model Format", bin: true },
                { ext: ["mdl"], type: "format", name: "3D Model", bin: true },
                { ext: ["wrl"], type: "format", name: "VRML World", bin: true },
                { ext: ["fac"], type: "format", name: "Autodesk Face", bin: true },
                { ext: ["xsi"], type: "format", name: "Softimage XSI", bin: true },
                { ext: ["pov"], type: "format", name: "POV-Ray File", bin: true },
                { ext: ["sldprt"], type: "format", name: "SolidWorks Part", bin: true },
                { ext: ["sldasm"], type: "format", name: "SolidWorks Assembly", bin: true },
                { ext: ["slddrw"], type: "format", name: "SolidWorks Drawing", bin: true },
                { ext: ["prt"], type: "format", name: "Creo Parametric Part", bin: true },
                { ext: ["asm"], type: "format", name: "Creo Parametric Assembly", bin: true },
                { ext: ["nds"], type: "format", name: "Nintendo DS ROM", bin: true },
                { ext: ["z64"], type: "format", name: "Nintendo 64 ROM", bin: true },
                { ext: ["n64"], type: "format", name: "Nintendo 64 ROM image (V64)", bin: true },
                { ext: ["pcx"], type: "format", name: "PiCture eXchange", bin: true },
                { ext: ["wbfs"], type: "format", name: "Wii Backup File System", bin: true },
                { ext: ["si"], type: "format", name: "Interleaf File", bin: true },
                { ext: ["wdb"], type: "format", name: "World DataBase", bin: true },
                { ext: ["asp"], type: "format", name: "Active Server Pages", bin: false },
                // Coktel Vision formats:
                { ext: ["vmd"], type: "format", name: "Video and Media Data", bin: true },
                { ext: ["mesh"], type: "format", name: "3D Collide Data", bin: true },
                { ext: ["tot"], type: "format", name: "Script file", bin: true },
                { ext: ["ext"], type: "format", name: "Script resource file", bin: true },
                { ext: ["ide"], type: "format", name: "Script function name offset", bin: true },
                { ext: ["stk", "itk", "jtk", "ltk"], type: "format", name: "STK1.0", bin: true },
                { ext: ["var"], type: "format", name: "Variable file", bin: true },
                { ext: ["cmp"], type: "format", name: "Sprite file", bin: true },
                { ext: ["tts"], type: "format", name: "Text to Speech file", bin: false },
                { ext: ["pag"], type: "format", name: "Update file", bin: false },
                { ext: ["bcd"], type: "format", name: "BCD (Information for new Application)", bin: false },
                { ext: ["bcd1"], type: "format", name: "BCD (Information for Environment)", bin: false },
                { ext: ["cd1"], type: "format", name: "CD1 (Setup Information)", bin: false },
                { ext: ["rxy"], type: "format", name: "Relative Sprite Coordinates", bin: true },
                { ext: ["fra"], type: "format", name: "French text (Francais)", bin: true },
                { ext: ["all"], type: "format", name: "German text (Allemand)", bin: true },
                { ext: ["ang"], type: "format", name: "English text (Anglais)", bin: true },
                { ext: ["esp"], type: "format", name: "Spanish text (Espagnol)", bin: true },
                { ext: ["ita"], type: "format", name: "Italian text", bin: true },
                { ext: ["fnt", "let"], type: "format", name: "Font", bin: true },
                { ext: ["snd"], type: "format", name: "Sound file", bin: true },
                { ext: ["ani"], type: "format", name: "Animation file", bin: true },
                { ext: ["dec"], type: "format", name: "Decal (Background) file", bin: true },
                { ext: ["tbr"], type: "format", name: "Instrument parameters", bin: true },
                { ext: ["mdy"], type: "format", name: "Music score", bin: true },
                { ext: ["err"], type: "format", name: "Error File", bin: false },
                { ext: ["adi"], type: "format", name: "Debug (Adi) File", bin: true },
                { ext: ["bou"], type: "format", name: "Debug (Adibou) File", bin: true },
                { ext: ["pla"], type: "format", name: "Debug (Playtoons) File", bin: true },
                { ext: ["ask"], type: "format", name: "Installation help", bin: false },
                { ext: ["dag"], type: "format", name: "Dialog Text", bin: true },
                { ext: ["seq"], type: "format", name: "Animation Sequence", bin: true },
                { ext: ["scn"], type: "format", name: "Scene File", bin: false },
                { ext: ["rec"], type: "format", name: "Record File", bin: true },
                { ext: ["gam"], type: "format", name: "Savegame File", bin: true },
                { ext: ["lvl"], type: "format", name: "Level File", bin: true },
                { ext: ["stb"], type: "format", name: "STB (OGG)", bin: true },
                { ext: ["adbx"], type: "format", name: "AdibouX", bin: true },
                { ext: ["sav"], type: "format", name: "Save", bin: true },
                // Generic formats:
                { ext: ["flx", "flc"], type: "format", name: "FLIC", bin: true },
                { ext: ["md"], type: "format", name: "Markdown", bin: false },
                { ext: ["map"], type: "format", name: "Mapfile", bin: false },
                { ext: ["def"], type: "format", name: "Definition file", bin: false },
                { ext: ["dbt"], type: "format", name: "Database Text File", bin: true },
                { ext: ["cfg"], type: "format", name: "Config File", bin: true },
                { ext: ["inf"], type: "format", name: "INF file (setup Information file)", bin: true },
                { ext: ["icns"], type: "format", name: "Apple Icon Image format", bin: true },
                { ext: ["mdx"], type: "format", name: "Multidimensional Expressions", bin: true },
                { ext: ["qdat"], type: "format", name: "QuickTime data", bin: true },
                { ext: ["pup"], type: "format", name: "Playstation Update Package", bin: true },
                { ext: ["mps"], type: "format", name: "Mathematical Programming System", bin: true },
                { ext: ["gzf"], type: "format", name: "Ghidra Zip File", bin: true },
                { ext: ["cue"], type: "format", name: "CUE sheet", bin: false },
                { ext: ["cat"], type: "format", name: "Windows Cabinet File", bin: true },
                { ext: ["sdb"], type: "format", name: "Shim Database", bin: true },
                { ext: ["mof"], type: "format", name: "Managed Object Format", bin: false },
                { ext: ["nls"], type: "format", name: "National Language Support", bin: true },
                { ext: ["sse"], type: "format", name: "Streaming SIMD Extensions", bin: true },
                { ext: ["res"], type: "format", name: "Resource file", bin: true },
                { ext: ["md5"], type: "format", name: "MD5 Checksum", bin: false },
                { ext: ["db"], type: "format", name: "Database", bin: true },
                { ext: ["xa"], type: "audio", name: "XA", bin: true },
                { ext: ["torrent"], type: "format", name: "Torrent", bin: true },
                { ext: ["bms"], type: "format", name: "QuickBMS", bin: false },
                { ext: ["gbc"], type: "format", name: "GameBoy Color ROM", bin: true },
                { ext: ["tsv"], type: "format", name: "Tab-Separated Values", bin: false },
                { ext: ["st"], type: "format", name: "ST Disk Image", bin: true },
                { ext: ["str"], type: "format", name: "Streaming Data Movie", bin: true },
                { ext: ["rpt"], type: "format", name: "Report file", bin: false },
                { ext: ["iss"], type: "format", name: "Inno Setup Script", bin: false },
                { ext: ["plist"], type: "format", name: "Property List", bin: false },
                { ext: ["vcd"], type: "format", name: "Value change dump", bin: false },
                { ext: ["gitignore"], type: "format", name: "Git ignore file", bin: false },
                // ScummVM formats:
                { ext: ["gob"], type: "format", name: "Config file (extract_gob_stk)", bin: false },
                // Director formats:
                { ext: ["dxr"], type: "format", name: "Protected Director Movie", bin: true },
                { ext: ["cxt"], type: "format", name: "Adobe Director Protected Cast file", bin: true },
                { ext: ["dcr"], type: "format", name: "Published Shockwave Movie", bin: true },
                { ext: ["cct"], type: "format", name: "Published Shockwave Cast", bin: true },
                { ext: ["cst"], type: "format", name: "Cast file", bin: true },
                { ext: ["xobj"], type: "format", name: "XObjects", bin: true },
                // 3DS formats:
                { ext: ["cia"], type: "format", name: "CTR Importable Archive", bin: true },
                // Amiga formats:
                { ext: ["adf"], type: "format", name: "Amiga Disk File", bin: true },
            ];

        for (var i = 0; i < extensionsDb.length; i++) {
            var extGroup = extensionsDb[i].ext;
            for (var j = 0; j < extGroup.length; j++) {
                if (extGroup[j] === currentFileExtension && extensionsDb[i].bin === isBinaryFile) {
                    if (_getNumberOfResults(extensionsDb[i]) < 1) {
                        _setResult("~" + extensionsDb[i].type, extensionsDb[i].name, String(), "by extension");
                    }
                    return null;
                }
            }
        }
    }
}