{
  "version": 3,
  "sources": ["../src/main.ts", "../src/logger.ts"],
  "sourcesContent": ["export * from './logger.js';\nexport * from './type.js';\n", "import {getGlobalThis} from '@alwatr/global-this';\nimport {platformInfo} from '@alwatr/platform-info';\n\nimport type {AlwatrLogger} from './type.js';\n\nconst console_ = getGlobalThis().console;\n\n/**\n * Default debug mode state, determined by environment variables or localStorage.\n */\nconst defaultDebugMode = (() => {\n  if (platformInfo.development) {\n    if (platformInfo.isCli) {\n      return process.env.ALWATR_DEBUG !== '0';\n    }\n    else {\n      return typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') !== '0';\n    }\n  }\n  // else\n  return platformInfo.isCli\n    ? Boolean(process.env.DEBUG)\n    : typeof localStorage !== 'undefined' && localStorage.getItem('ALWATR_DEBUG') === '1';\n})();\n\n/**\n * A list of aesthetically pleasing colors for console logging, adapted for CLI and browser environments.\n */\nconst colorList = (() =>\n  platformInfo.isCli\n    ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // CLI-safe colors\n    : [\n      '#35b997',\n      '#f05561',\n      '#ee224a',\n      '#91c13e',\n      '#22af4b',\n      '#f0e995',\n      '#0fe995',\n      '#0f89ca',\n      '#08b9a5',\n      '#fee851',\n      '#ee573d',\n      '#f9df30',\n      '#1da2dc',\n      '#f05123',\n      '#ee2524',\n    ])();\n\n/**\n * Platform-specific styling templates for logger output.\n */\nconst style_ = (() => ({\n  scope: platformInfo.isCli ? '\\x1b[{{color}}m' : 'color: {{color}};',\n  reset: platformInfo.isCli ? '\\x1b[0m' : 'color: inherit;',\n}))();\n\n/**\n * Platform-specific format for displaying the logger's scope.\n */\nconst keySection_ = (() => (platformInfo.isCli ? '%s%s%s' : '%c%s%c'))();\n\n// --- Utility Functions ---\n\nlet colorIndex_ = 0;\n/**\n * Cycles through the `colorList` to provide a new color for each logger instance.\n */\nfunction getNextColor_(): string {\n  const color = colorList[colorIndex_];\n  colorIndex_ = (colorIndex_ + 1) % colorList.length;\n  return color;\n}\n\n/**\n * Sanitizes and formats the logger domain string by wrapping it in brackets if not already.\n */\nfunction sanitizeDomain_(domain: string): string {\n  domain = domain.trim();\n  if (!/^[[{<]/.test(domain)) {\n    domain = `{${domain}}`;\n  }\n  return domain;\n}\n\n// --- Core Factory ---\n\n/**\n * Create a logger function for fancy console debug with custom scope.\n *\n * - `color` is optional and automatically selected from an internal list.\n * - `debug` is optional and automatically detected from `ALWATR_DEBUG` in localStorage or `process.env.DEBUG`.\n *\n * @example\n * ```ts\n * import {createLogger} from '@alwatr/logger';\n * const logger = createLogger('my-module');\n *\n * logger.logMethodArgs?.('myMethod', {a: 1}); // This line is ignored if debugMode is false.\n * ```\n */\nexport function createLogger(domain: string, debugMode = defaultDebugMode): AlwatrLogger {\n  const color = getNextColor_();\n  const styleScope = style_.scope.replace('{{color}}', color);\n  const sanitizedDomain = sanitizeDomain_(domain);\n\n  /**\n   * Logger methods that are always available, regardless of debugMode.\n   */\n  const requiredItems: AlwatrLogger = {\n    debugMode,\n\n    banner: platformInfo.isCli\n      ? console_.log.bind(console_, `\\x1b[1;37;45m {{{ %s }}} ${style_.reset}`)\n      : console_.log.bind(\n        console_,\n        '%c%s',\n        'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;',\n      ),\n\n    accident: platformInfo.isCli\n      ? console_.warn.bind(console_, `${styleScope}⚠️\\n%s\\x1b[33m.%s() Accident \\`%s\\`!${style_.reset}`, sanitizedDomain)\n      : console_.warn.bind(console_, '%c%s%c.%s() Accident `%s`!', styleScope, sanitizedDomain, style_.reset),\n\n    error: platformInfo.isCli\n      ? console_.error.bind(console_, `${styleScope}❌\\n%s\\x1b[31m.%s() Error \\`%s\\`${style_.reset}\\n`, sanitizedDomain)\n      : console_.error.bind(console_, '%c%s%c.%s() Error `%s`\\n', styleScope, sanitizedDomain, style_.reset),\n  };\n\n  if (!debugMode) {\n    return requiredItems;\n  }\n\n  /**\n   * Logger methods available only when debugMode is true.\n   * Using `console.debug` which is often filtered by default in browsers unless \"Verbose\" logs are enabled.\n   */\n  return {\n    ...requiredItems,\n\n    logProperty: console_.debug.bind(console_, keySection_ + '.%s = %o;', styleScope, sanitizedDomain, style_.reset),\n\n    logMethod: console_.debug.bind(console_, keySection_ + '.%s();', styleScope, sanitizedDomain, style_.reset),\n\n    logFileModule: console_.debug.bind(console_, keySection_ + '/%s.js;', styleScope, sanitizedDomain, style_.reset),\n\n    logMethodArgs: console_.debug.bind(console_, keySection_ + '.%s(%o);', styleScope, sanitizedDomain, style_.reset),\n\n    logMethodFull: console_.debug.bind(console_, keySection_ + '.%s(%o) => %o', styleScope, sanitizedDomain, style_.reset),\n\n    logStep: console_.debug.bind(console_, keySection_ + '.%s() -> %s', styleScope, sanitizedDomain, style_.reset),\n\n    logOther: console_.debug.bind(console_, keySection_, styleScope, sanitizedDomain, style_.reset),\n\n    logTable: console_.table.bind(console_),\n\n    incident: platformInfo.isCli\n      ? console_.log.bind(console_, `${styleScope}🚸\\n%s${style_.reset}.%s() Incident \\`%s\\`!${style_.reset}`, sanitizedDomain)\n      : console_.log.bind(console_, '%c%s%c.%s() Incident `%s`!', styleScope, sanitizedDomain, 'color: orange;'),\n\n    time: (label: string) => console_.time(sanitizedDomain + '.' + label),\n    timeEnd: (label: string) => console_.timeEnd(sanitizedDomain + '.' + label),\n  } as const;\n}\n"],
  "mappings": ";;qqBAAA,qHCAA,uBAA4B,+BAC5B,yBAA2B,iCAI3B,IAAM,YAAW,kCAAc,EAAE,QAKjC,IAAM,kBAAoB,IAAM,CAC9B,GAAI,kCAAa,YAAa,CAC5B,GAAI,kCAAa,MAAO,CACtB,OAAO,QAAQ,IAAI,eAAiB,GACtC,KACK,CACH,OAAO,OAAO,eAAiB,aAAe,aAAa,QAAQ,cAAc,IAAM,GACzF,CACF,CAEA,OAAO,kCAAa,MAChB,QAAQ,QAAQ,IAAI,KAAK,EACzB,OAAO,eAAiB,aAAe,aAAa,QAAQ,cAAc,IAAM,GACtF,GAAG,EAKH,I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