{"version":3,"file":"load-queue.mjs","names":[],"sources":["../../../../../../../notifications/src/queue/load-queue.ts"],"sourcesContent":["/**\n * Lazily load `@warlock.js/queue` — the optional peer backing the `bullmq`\n * queue driver (`bullmqQueue()`). Mirrors `loadHerald`'s lazy-optional-peer\n * pattern: the dynamic import runs at most once and is memoized, and a\n * missing package surfaces a curated, named error at USE time rather than a\n * boot-time resolution error.\n *\n * The `loader` parameter exists so specs can inject a failing import without\n * needing the real package installed or uninstalled.\n */\nimport { QueuePackageNotInstalledError } from \"./queue-package-not-installed.error\";\n\n/** A function that performs the dynamic import of `@warlock.js/queue`. */\nexport type QueuePackageLoader = () => Promise<typeof import(\"@warlock.js/queue\")>;\n\nconst defaultLoader: QueuePackageLoader = () => import(\"@warlock.js/queue\");\n\nlet queueModule: typeof import(\"@warlock.js/queue\") | undefined;\n\n/**\n * Resolve `@warlock.js/queue`, memoized after the first successful load.\n * Throws {@link QueuePackageNotInstalledError} when the import fails.\n */\nexport async function loadQueuePackage(\n  loader: QueuePackageLoader = defaultLoader,\n): Promise<typeof import(\"@warlock.js/queue\")> {\n  if (queueModule) {\n    return queueModule;\n  }\n\n  try {\n    queueModule = await loader();\n    return queueModule;\n  } catch {\n    throw new QueuePackageNotInstalledError();\n  }\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,sBAA0C,OAAO;AAEvD,IAAI;;;;;AAMJ,eAAsB,iBACpB,SAA6B,eACgB;CAC7C,IAAI,aACF,OAAO;CAGT,IAAI;EACF,cAAc,MAAM,OAAO;EAC3B,OAAO;CACT,QAAQ;EACN,MAAM,IAAI,8BAA8B;CAC1C;AACF"}