{
  "version": 3,
  "sources": ["../../../static/script/webserver-base/frontend-error.ts", "../../../static/script/webserver-base/scitylana.ts", "../../../static/script/main.ts"],
  "sourcesContent": ["/**\n * This module provides functions to report frontend errors to the server.\n * @module\n */\n\n/**\n * The payload of a frontend error report.\n */\ntype FrontendErrorPayload = {\n  sourceFile: string | null;\n  lineNumber: number | null;\n  columnNumber: number | null;\n\n  message: string | null;\n  stackTrace: string | null;\n  currentUrl: string | null;\n  timestamp: string | null;\n};\n\n/**\n * Reports a frontend error to the server.\n */\nasync function reportError(frontend_error_payload: FrontendErrorPayload): Promise<void> {\n  const response: Response = await fetch(\"/api/v1/frontend-error\", {\n    method: \"POST\",\n    headers: { \"Content-Type\": \"application/json\" },\n    body: JSON.stringify(frontend_error_payload),\n  });\n  if (!response.ok) {\n    console.error(\"Failed to send frontend error report: \", response);\n  }\n}\n\n/**\n * Initializes global error handlers to report frontend errors to the server.\n */\nexport function initGlobalErrorHandlers(): void {\n  // handle synchronous errors\n  globalThis.onerror = (\n    message: string | Event,\n    source: string | undefined,\n    lineno: number | undefined,\n    colno: number | undefined,\n    error: Error | undefined,\n  ) => {\n    const errorReport: FrontendErrorPayload = {\n      sourceFile: source || null,\n      lineNumber: lineno || null,\n      columnNumber: colno || null,\n\n      message: String(message),\n      stackTrace: error?.stack || null,\n      currentUrl: globalThis.location.href,\n      timestamp: new Date().toString(),\n    };\n    reportError(errorReport);\n    return false;\n  };\n\n  // handle Promise rejections\n  globalThis.addEventListener(\"unhandledrejection\", (event: PromiseRejectionEvent) => {\n    const error = event.reason;\n    const errorReport: FrontendErrorPayload = {\n      sourceFile: null, // not available in Promise rejections\n      lineNumber: null,\n      columnNumber: null,\n\n      message: error instanceof Error ? error.message : String(error),\n      stackTrace: error instanceof Error ? error.stack || null : null,\n      currentUrl: globalThis.location.href,\n      timestamp: new Date().toString(),\n    };\n    reportError(errorReport);\n  });\n}\n", "/**\n * This module provides functions to publish custom analytics events to the server.\n * @module\n */\n\n/**\n * Publishes a highly-opinionated custom analytics event to the server.\n */\nasync function scitylana(e: Event): Promise<void> {\n  e.preventDefault();\n\n  const response: Response = await fetch(\"/api/v1/scitylana\", {\n    method: \"POST\",\n    headers: {\n      \"Content-Type\": \"application/x-www-form-urlencoded;charset=UTF-8\",\n    },\n    body: new URLSearchParams({\n      \"user_agent\": navigator.userAgent,\n      \"url\": globalThis.location.href,\n      \"referrer\": document.referrer,\n      \"screen_width\": globalThis.innerWidth.toString(),\n    }),\n  });\n  if (!response.ok) {\n    console.error(\"Failed scitylana: \", response);\n  }\n}\n\n/**\n * Configures the analytics event to be sent on page load.\n */\nexport function initScitylana(): void {\n  document.addEventListener(\"DOMContentLoaded\", scitylana);\n}\n", "import { initGlobalErrorHandlers } from \"./webserver-base/frontend-error.ts\";\nimport { initScitylana } from \"./webserver-base/scitylana.ts\";\n\ninitGlobalErrorHandlers();\ninitScitylana();\n"],
  "mappings": "AAsBA,eAAeA,EAAYC,EAA6D,CACtF,IAAMC,EAAqB,MAAM,MAAM,yBAA0B,CAC/D,OAAQ,OACR,QAAS,CAAE,eAAgB,kBAAmB,EAC9C,KAAM,KAAK,UAAUD,CAAsB,CAC7C,CAAC,EACIC,EAAS,IACZ,QAAQ,MAAM,yCAA0CA,CAAQ,CAEpE,CAKO,SAASC,GAAgC,CAE9C,WAAW,QAAU,CACnBC,EACAC,EACAC,EACAC,EACAC,IACG,CACH,IAAMC,EAAoC,CACxC,WAAYJ,GAAU,KACtB,WAAYC,GAAU,KACtB,aAAcC,GAAS,KAEvB,QAAS,OAAOH,CAAO,EACvB,WAAYI,GAAO,OAAS,KAC5B,WAAY,WAAW,SAAS,KAChC,UAAW,IAAI,KAAK,EAAE,SAAS,CACjC,EACA,OAAAR,EAAYS,CAAW,EAChB,EACT,EAGA,WAAW,iBAAiB,qBAAuBC,GAAiC,CAClF,IAAMF,EAAQE,EAAM,OACdD,EAAoC,CACxC,WAAY,KACZ,WAAY,KACZ,aAAc,KAEd,QAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EAC9D,WAAYA,aAAiB,OAAQA,EAAM,OAAS,KACpD,WAAY,WAAW,SAAS,KAChC,UAAW,IAAI,KAAK,EAAE,SAAS,CACjC,EACAR,EAAYS,CAAW,CACzB,CAAC,CACH,CClEA,eAAeE,EAAU,EAAyB,CAChD,EAAE,eAAe,EAEjB,IAAMC,EAAqB,MAAM,MAAM,oBAAqB,CAC1D,OAAQ,OACR,QAAS,CACP,eAAgB,iDAClB,EACA,KAAM,IAAI,gBAAgB,CACxB,WAAc,UAAU,UACxB,IAAO,WAAW,SAAS,KAC3B,SAAY,SAAS,SACrB,aAAgB,WAAW,WAAW,SAAS,CACjD,CAAC,CACH,CAAC,EACIA,EAAS,IACZ,QAAQ,MAAM,qBAAsBA,CAAQ,CAEhD,CAKO,SAASC,GAAsB,CACpC,SAAS,iBAAiB,mBAAoBF,CAAS,CACzD,CC9BAG,EAAwB,EACxBC,EAAc",
  "names": ["reportError", "frontend_error_payload", "response", "initGlobalErrorHandlers", "message", "source", "lineno", "colno", "error", "errorReport", "event", "scitylana", "response", "initScitylana", "initGlobalErrorHandlers", "initScitylana"]
}