{
  "version": 3,
  "sources": ["../../../src/store/utils/debug-logger.ts"],
  "sourcesContent": ["/**\n * Debug logger for client-side media processing.\n *\n * Provides diagnostic logging via `console.debug` and performance\n * measurement via the User Timings API. Both are only emitted when\n * SCRIPT_DEBUG is true, so there is no overhead in production builds.\n */\n\nfunction isDebugEnabled(): boolean {\n\t// eslint-disable-next-line @wordpress/wp-global-usage\n\treturn globalThis.SCRIPT_DEBUG === true;\n}\n\n/**\n * Logs a diagnostic message visible in the browser console.\n *\n * Unlike `@wordpress/warning`, this does not throw a caught `Error`, so it\n * won't trip the debugger for developers who pause on caught exceptions.\n * Use it for non-error lifecycle diagnostics (cancellations, batch\n * completion). Only emits when SCRIPT_DEBUG is true.\n *\n * @param message Message to log.\n * @param args    Additional values to log.\n */\nexport function debug( message: string, ...args: unknown[] ): void {\n\tif ( ! isDebugEnabled() ) {\n\t\treturn;\n\t}\n\n\t// eslint-disable-next-line no-console -- Deliberately log diagnostics here.\n\tconsole.debug( `[upload-media] ${ message }`, ...args );\n}\n\ninterface MeasureOptions {\n\tmeasureName: string;\n\tstartTime: number;\n\tendTime?: number;\n\ttooltipText?: string;\n\tproperties?: Array< [ string, string ] >;\n}\n\n/**\n * Records a performance measure visible in DevTools Performance panel.\n *\n * Uses the User Timings API (performance.measure) to create entries\n * under a custom \"Upload Media\" track in DevTools. Only emits when\n * SCRIPT_DEBUG is true, so there's no overhead in production builds.\n *\n * @param options             Measure options.\n * @param options.measureName Name for the performance measure entry.\n * @param options.startTime   Start time from performance.now().\n * @param options.endTime     End time from performance.now(). Defaults to current time.\n * @param options.tooltipText Tooltip text shown in DevTools.\n * @param options.properties  Key-value pairs shown in DevTools detail view.\n */\nexport function measure( options: MeasureOptions ): void {\n\tif ( ! isDebugEnabled() ) {\n\t\treturn;\n\t}\n\n\tconst {\n\t\tmeasureName,\n\t\tstartTime,\n\t\tendTime = performance.now(),\n\t\ttooltipText,\n\t\tproperties,\n\t} = options;\n\n\tconst detail: Record< string, unknown > = {\n\t\tdevtools: {\n\t\t\tdataType: 'track-entry',\n\t\t\ttrack: 'Upload Media',\n\t\t\ttooltipText,\n\t\t\tproperties: properties?.map( ( [ key, value ] ) => ( {\n\t\t\t\tkey,\n\t\t\t\tvalue,\n\t\t\t} ) ),\n\t\t},\n\t};\n\n\ttry {\n\t\tperformance.measure( measureName, {\n\t\t\tstart: startTime,\n\t\t\tend: endTime,\n\t\t\tdetail,\n\t\t} );\n\t} catch {\n\t\t// Silently ignore if User Timings API is unavailable.\n\t}\n}\n"],
  "mappings": ";AAQA,SAAS,iBAA0B;AAElC,SAAO,WAAW,iBAAiB;AACpC;AAaO,SAAS,MAAO,YAAoB,MAAwB;AAClE,MAAK,CAAE,eAAe,GAAI;AACzB;AAAA,EACD;AAGA,UAAQ,MAAO,kBAAmB,OAAQ,IAAI,GAAG,IAAK;AACvD;AAwBO,SAAS,QAAS,SAAgC;AACxD,MAAK,CAAE,eAAe,GAAI;AACzB;AAAA,EACD;AAEA,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU,YAAY,IAAI;AAAA,IAC1B;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,QAAM,SAAoC;AAAA,IACzC,UAAU;AAAA,MACT,UAAU;AAAA,MACV,OAAO;AAAA,MACP;AAAA,MACA,YAAY,YAAY,IAAK,CAAE,CAAE,KAAK,KAAM,OAAS;AAAA,QACpD;AAAA,QACA;AAAA,MACD,EAAI;AAAA,IACL;AAAA,EACD;AAEA,MAAI;AACH,gBAAY,QAAS,aAAa;AAAA,MACjC,OAAO;AAAA,MACP,KAAK;AAAA,MACL;AAAA,IACD,CAAE;AAAA,EACH,QAAQ;AAAA,EAER;AACD;",
  "names": []
}
