"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultExifToolOptions = exports.ConsoleLogger = void 0;
exports.defaultAdjustTimeZoneIfDaylightSavings = defaultAdjustTimeZoneIfDaylightSavings;
const bc = __importStar(require("batch-cluster"));
const node_util_1 = require("node:util");
const Boolean_1 = require("./Boolean");
const CapturedAtTagNames_1 = require("./CapturedAtTagNames");
const DefaultExiftoolArgs_1 = require("./DefaultExiftoolArgs");
const DefaultMaxProcs_1 = require("./DefaultMaxProcs");
const ExiftoolPath_1 = require("./ExiftoolPath");
const GeoTz_1 = require("./GeoTz");
const IsWin32_1 = require("./IsWin32");
const VersionTask_1 = require("./VersionTask");
const _debuglog = (0, node_util_1.debuglog)("exiftool-vendored");
function noop() { }
exports.ConsoleLogger = {
    trace: noop,
    debug: _debuglog,
    info: _debuglog,
    warn: console.warn,
    error: console.error,
};
function logger() {
    return (0, node_util_1.debuglog)("exiftool-vendored").enabled ? exports.ConsoleLogger : bc.NoLogger;
}
/**
 * Default values for `ExifToolOptions`, except for `processFactory` (which is
 * created by the ExifTool constructor) and `ignoreShebang` (which is set
 * dynamically based on OS). See {@link ExifToolOptions} for details.
 */
exports.DefaultExifToolOptions = Object.freeze({
    ...new bc.BatchClusterOptions(),
    maxProcs: DefaultMaxProcs_1.DefaultMaxProcs,
    maxTasksPerProcess: 500,
    spawnTimeoutMillis: 30000,
    // ExifTool always flushes stderr before emitting "{ready}" on stdout when
    // in -stay_open mode (see exiftool lines 426-438). It explicitly calls
    // STDERR->flush() before printing "{ready}\n" with autoflush enabled on
    // stdout. This means stderr data for a given task is guaranteed to arrive
    // before the stdout sentinel, so we can safely use a very short flush delay.
    //
    // Caveat: the flush requires IO::Handle to load successfully (via eval),
    // but this is available in all standard Perl installations.
    //
    // Reduced from batch-cluster's default (30-200ms) to 1ms based on
    // empirical testing on Windows and Linux.
    streamFlushMillis: 1,
    // see https://github.com/photostructure/exiftool-vendored.js/issues/34 :
    taskTimeoutMillis: 30000,
    onIdleIntervalMillis: 2000,
    taskRetries: 1,
    exiftoolPath: ExiftoolPath_1.exiftoolPath,
    exiftoolArgs: DefaultExiftoolArgs_1.DefaultExiftoolArgs,
    exiftoolEnv: {},
    checkPerl: !(0, IsWin32_1.isWin32)(),
    pass: "{ready}",
    fail: "{ready}",
    exitCommand: "-stay_open\nFalse\n",
    versionCommand: new VersionTask_1.VersionTask().command,
    healthCheckIntervalMillis: 30000,
    healthCheckCommand: "-ver\n-execute\n",
    backfillTimezones: true,
    defaultVideosToUTC: true,
    geoTz: GeoTz_1.geoTz,
    geolocation: false,
    ignoreZeroZeroLatLon: true,
    ignoreMinorErrors: true,
    forceWrite: false,
    imageHashType: false,
    includeImageDataMD5: undefined,
    // Changed from false to true in v35.2.0 to fix issue #320 - timezone info
    // in IPTC TimeCreated and XMP datetime tags should be used by default.
    // See https://github.com/photostructure/exiftool-vendored.js/issues/320
    inferTimezoneFromDatestamps: true,
    inferTimezoneFromDatestampTags: [...CapturedAtTagNames_1.CapturedAtTagNames],
    inferTimezoneFromTimeStamp: false, // to retain prior behavior
    logger,
    numericTags: [
        "*Duration*",
        "GPSAltitude",
        "GPSLatitude",
        "GPSLongitude",
        "GPSPosition",
        "GeolocationPosition",
        "Orientation",
        // NOT Rotation! Rotation can be encoded as degrees rotated clockwise, or a
        // EXIF-Orientation string (!!). If we ask ExifTool for numeric rotations of HEICs,
        // we get "3" (when it means "Rotate 90 CW"):
        // $ exiftool -j -Rotation -Orientation IMG_6947.HEIC
        // [{
        //   "Rotation": "Rotate 90 CW",
        //   "Orientation": "Rotate 90 CW"
        // }]
        // $ exiftool -j -Rotation# -Orientation# IMG_6947.HEIC
        // [{
        //   "Rotation": 3,   // < WTH is this? 3 means 180º (!?)
        //   "Orientation": 6 // < expected
        // }]
    ],
    useMWG: true,
    struct: 1,
    readArgs: ["-fast"],
    writeArgs: [],
    adjustTimeZoneIfDaylightSavings: defaultAdjustTimeZoneIfDaylightSavings,
    preferTimezoneInferenceFromGps: false, // to retain prior behavior
    keepUTCTime: true,
    disposalTimeoutMs: 1000,
    asyncDisposalTimeoutMs: 5000,
});
/**
 * Returns a timezone offset adjustment for Nikon cameras that set DaylightSavings.
 * @param t - the tags to check for DaylightSavings and Make
 * @returns 60 (minutes) if Nikon camera with DaylightSavings=true, otherwise undefined
 * @see https://github.com/photostructure/exiftool-vendored.js/issues/215
 */
function defaultAdjustTimeZoneIfDaylightSavings(t) {
    // `DaylightSavings` may be "Yes" or `true`:
    return true === (0, Boolean_1.toBoolean)(t.DaylightSavings) &&
        // Daggum Nikon likes "FS-Nikon", "Nikon", "NIKON", and "NIKON CORPORATION"
        /\bnikon\b/i.test(String(t.Make))
        ? 60
        : undefined;
}
//# sourceMappingURL=DefaultExifToolOptions.js.map