{
  "version": 3,
  "sources": ["../Source/Dependency/index.ts", "../Source/Dependency/Dependency.ts", "../Source/Dependency/Dependency.Internal.ts"],
  "sourcesContent": ["/**\n * Utilities that are useful for libraries, which may need to interact with\n * their dependent's codebase, or make it easier for their dependents to access\n * information about a library using this package.\n *\n * @module @sorrell/utilities/dependency\n */\n/**\n * @file      index.ts\n * @author    Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license   MIT\n */\nexport * from \"./Dependency.ts\";\nexport * from \"./Dependency.Types.ts\";\n", "/**\n * @file      Dependency.ts\n * @author    Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license   MIT\n */\n/* eslint-disable jsdoc/require-example, jsdoc/match-description */\nimport type { DependencyLogger, TRuntimeModeProductionOptions } from \"./Dependency.Types.ts\";\nimport { type InspectOptions, format } from \"node:util\";\nimport { Code } from \"./Dependency.Internal.ts\";\nimport { DefaultOptions } from \"./Dependency.Internal.ts\";\n/**\n * Guess whether the current session is in *production mode* by,\n *\n * 1. If the function did not already return in Step 1, then {@link process.env} is checked for\n * a property with key `\"NODE_ENV\"`.\n *     - If there exists a property with this key, and if `process.env[\"NODE_ENV\"] === \"production\"`\n *       (or similar; see below), then this returns `true`.\n * 2. If the function did not already return in Step 2, then `true` is returned.\n *\n * @note If Step 2 is executed, then this returns `true` when `process.env[\"NODE_ENV\"].toLowerCase()`\n * is any one of,\n * - `\"production\"`\n * - `\"prod\"`\n *\n * @returns {boolean} Whether the current session is likely in *production mode*, or,\n * if unsure, `true` is returned.\n */\nexport function IsRuntimeModeProduction(): boolean;\n/**\n * Guess whether the current session is in *production mode* by,\n *\n * 1. If a {@link DebugEnvironmentVariable} is given, then {@link process.env}\n * is checked for the existence of a property having this key.\n *     - If the property exists and is in {@link TruthyValues}, then this function returns `true`.\n *     - If the property exists but is in {@link TruthyValues}, then this returns `false`.\n * 2. If the function did not already return in Step 1, then {@link process.env} is checked for\n * a property with key `\"NODE_ENV\"`.\n *     - If there exists a property with this key, and if `process.env[\"NODE_ENV\"] === \"production\"`\n *       (or similar; see below), then this returns `true`.\n * 3. If the function did not already return in Step 2, then {@link UncertainValue} is returned.\n * By default, this is `true`, but any value of any type can be used.\n *\n * @template UncertainType - The type of the {@link UncertainValue}.  By default, this is `boolean`.\n *\n * @param Options - The {@link TRuntimeModeProductionOptions} options object.  All properties are optional.\n *\n * @note If Step 2 is executed, then this returns `true` when `process.env[\"NODE_ENV\"].toLowerCase()`\n * is any one of,\n * - `\"production\"`\n * - `\"prod\"`\n *\n * @returns {boolean | typeof UncertainValue} Whether the current session is likely in *production mode*, or,\n * if unsure, the given {@link UncertainValue} is returned (by default, this is `true`).\n */\nexport function IsRuntimeModeProduction<UncertainType = boolean>(Options: TRuntimeModeProductionOptions<UncertainType>): boolean | Exclude<typeof Options.UncertainValue, undefined>;\nexport function IsRuntimeModeProduction<UncertainType = boolean>(Options: TRuntimeModeProductionOptions<UncertainType> = (DefaultOptions as TRuntimeModeProductionOptions<UncertainType>)): boolean | typeof Options.UncertainValue {\n    const { DebugEnvironmentVariable, UncertainValue, TruthyValues } = {\n        ...DefaultOptions,\n        ...Options\n    } as Required<TRuntimeModeProductionOptions<UncertainType>>;\n    if (DebugEnvironmentVariable !== undefined) {\n        if (DebugEnvironmentVariable in process.env) {\n            const IsDebugTruthy: boolean = TruthyValues\n                .map((TruthyWord: string) => TruthyWord.toLowerCase())\n                .includes(DebugEnvironmentVariable.toLowerCase());\n            return IsDebugTruthy;\n        }\n    }\n    const NodeEnvKey: \"NODE_ENV\" = \"NODE_ENV\" as const;\n    if (NodeEnvKey in process.env && typeof process.env[NodeEnvKey] === \"string\") {\n        return [\"production\", \"prod\"].includes(process.env[NodeEnvKey].toLowerCase());\n    }\n    return UncertainValue;\n}\n/**\n * This patches the default logger so that the statements that are logged by your dependency package\n * do not overwhelm or annoy the consuming developer.\n *\n * {@link IsDependentModeProduction} is used to determine whether to return a no-op\n * (iff `true`), or a function that wraps {@link Console} (iff `false`).\n *\n * @param PackageName - The name of your package.  It is strongly recommended, but not *enforced*,\n * that this is exactly the `name` in your `package.json`.  Statements logged under this\n * {@link Layer.Layer | Layer} are prefixed with `[${ PackageName }]`.\n *\n * @param SuppressLoggerFrequency - When {@link SuppressLoggerFrequency} statements have been logged,\n * a short message is *also* logged, explaining how to suppress output from your package.\n *\n * @param SuppressLogEnvironmentVariable - If specified, this is the environment variable name passed to\n * {@link IsDependentModeProduction} to determine whether the logger will be a no-op.\n *\n * @returns {Layer.Layer} A {@link Layer.Layer | Layer} that provides the {@link DependencyLogger}\n * with the {@link PackageName}.\n */\nexport function GetDependencyLogger(PackageName: string, SuppressLoggerFrequency: number = 12, SuppressLogEnvironmentVariable: string | undefined = undefined): DependencyLogger {\n    const IsProductionMode: boolean = SuppressLogEnvironmentVariable !== undefined\n        ? IsRuntimeModeProduction({ DebugEnvironmentVariable: SuppressLogEnvironmentVariable })\n        : IsRuntimeModeProduction();\n    if (IsProductionMode) {\n        return {\n            debug(..._Statements: Array<unknown>): void { },\n            dir(_InObject: unknown, _Options: InspectOptions | undefined): void { },\n            error(..._Statements: Array<unknown>): void { },\n            info(..._Statements: Array<unknown>): void { },\n            log(..._Statements: Array<unknown>): void { },\n            warn(..._Statements: Array<unknown>): void { }\n        } as const;\n    }\n    const Prefix: string = `[${PackageName}]`;\n    const LogSuppressionStatement: string = `[${PackageName}] To suppress logs from ${PackageName}, set the env. variable ` +\n        `${Code(\"NODE_ENV\")} to ${Code(\"\\\"production\\\"\")}` + (SuppressLogEnvironmentVariable !== undefined\n        ? `, or set the env. variable ${Code(SuppressLogEnvironmentVariable)} to ` +\n            `${Code(\"\\\"false\\\"\")}.`\n        : \".\");\n    let LoggedStatementCount: number = 0;\n    function OnStatementLogged(): boolean {\n        LoggedStatementCount++;\n        const Out: boolean = (SuppressLoggerFrequency > 0 &&\n            LoggedStatementCount % SuppressLoggerFrequency === 0);\n        if (Out) {\n            LoggedStatementCount = 0;\n        }\n        return Out;\n    }\n    function PrintLogSuppressionStatement(): void {\n        console.log(LogSuppressionStatement);\n    }\n    function OnStatementLoggedManual(): void {\n        if (OnStatementLogged()) {\n            PrintLogSuppressionStatement();\n        }\n    }\n    function GetFormattedStatements(...Statements: Array<unknown>): ReadonlyArray<string> {\n        return Statements\n            .flatMap((Statement: unknown): Array<string> => {\n            const OutStatement: string = `${Prefix} ${format(Statement)}`;\n            return OnStatementLogged()\n                ? [OutStatement, LogSuppressionStatement]\n                : [OutStatement];\n        });\n    }\n    ;\n    return {\n        debug(...Statements: Array<unknown>): void {\n            console.debug(...GetFormattedStatements(Statements));\n        },\n        dir(InObject: unknown, Options: InspectOptions | undefined): void {\n            console.dir(InObject, Options);\n            OnStatementLoggedManual();\n        },\n        error(...Statements: Array<unknown>): void {\n            console.error(...GetFormattedStatements(Statements));\n        },\n        info(...Statements: Array<unknown>): void {\n            console.info(...GetFormattedStatements(...Statements));\n        },\n        log(...Statements: Array<unknown>): void {\n            console.log(...GetFormattedStatements(...Statements));\n        },\n        warn(...Statements: Array<unknown>): void {\n            console.warn(...GetFormattedStatements(...Statements));\n        }\n    } as const;\n}\n", "/**\n * @file      Dependency.Internal.ts\n * @author    Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license   MIT\n */\nimport Chalk from \"chalk\";\n/* eslint-disable-next-line @typescript-eslint/no-unused-vars */\nimport type { IsRuntimeModeProduction } from \"./Dependency.ts\";\nimport type { TRuntimeModeProductionOptions } from \"./Dependency.Types.ts\";\n/**\n * The default value of the `TruthyValues` argument of {@link IsRuntimeModeProduction}.\n */\nconst DefaultTruthyValues: ReadonlyArray<string> = [\n    \"true\",\n    \"1\",\n    \"yes\",\n    \"y\",\n    \"on\"\n] as const;\nexport /**\n        * The default options of {@link IsRuntimeModeProduction}.\n        */ const DefaultOptions: TRuntimeModeProductionOptions<boolean> = {\n    TruthyValues: DefaultTruthyValues,\n    UncertainValue: true\n};\n/* eslint-disable jsdoc/require-example */\n/**\n * Formats a given {@link Message} to look like a code snippet (or path, *etc.*).\n *\n * @param Message - The message to format.\n *\n * @returns {string} The {@link Message}, formatted to look like code (or a path, *etc.*).\n */\nexport function Code(Message: string): string {\n    return Chalk.reset.red(Message);\n}\n/* eslint-enable jsdoc/require-example */\n/* eslint-disable-next-line jsdoc/require-jsdoc */\nexport function NormalizeLogMessage(Message: unknown): ReadonlyArray<unknown> {\n    if (Array.isArray(Message)) {\n        return Message;\n    }\n    return [Message];\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQA,uBAA4C;;;ACF5C,mBAAkB;AAOlB,IAAM,sBAA6C;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAGW,IAAM,iBAAyD;AAAA,EACtE,cAAc;AAAA,EACd,gBAAgB;AACpB;AASO,SAAS,KAAK,SAAyB;AAC1C,SAAO,aAAAA,QAAM,MAAM,IAAI,OAAO;AAClC;;;ADoBO,SAAS,wBAAiD,UAAyD,gBAA0G;AAChO,QAAM,EAAE,0BAA0B,gBAAgB,aAAa,IAAI;AAAA,IAC/D,GAAG;AAAA,IACH,GAAG;AAAA,EACP;AACA,MAAI,6BAA6B,QAAW;AACxC,QAAI,4BAA4B,QAAQ,KAAK;AACzC,YAAM,gBAAyB,aAC1B,IAAI,CAAC,eAAuB,WAAW,YAAY,CAAC,EACpD,SAAS,yBAAyB,YAAY,CAAC;AACpD,aAAO;AAAA,IACX;AAAA,EACJ;AACA,QAAM,aAAyB;AAC/B,MAAI,cAAc,QAAQ,OAAO,OAAO,QAAQ,IAAI,UAAU,MAAM,UAAU;AAC1E,WAAO,CAAC,cAAc,MAAM,EAAE,SAAS,QAAQ,IAAI,UAAU,EAAE,YAAY,CAAC;AAAA,EAChF;AACA,SAAO;AACX;AAqBO,SAAS,oBAAoB,aAAqB,0BAAkC,IAAI,iCAAqD,QAA6B;AAC7K,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