{"version":3,"file":"boot.js","names":[],"sources":["esm/dom/boot.js"],"sourcesContent":["const bootStages = [\"script\", \"module\", \"faces\", \"provider\", \"flow\", \"ready\"];\nconst graphReadySettleMs = 1800;\nconst bootGlobalKey = \"__mp_graph_boot\";\nfunction slot() {\n  return globalThis;\n}\nfunction bootStageIndex(stage) {\n  return bootStages.indexOf(stage);\n}\nfunction isBootStage(value) {\n  return typeof value === \"string\" && bootStages.includes(value);\n}\nfunction readBootRecord() {\n  const raw = slot()[bootGlobalKey];\n  if (!raw || typeof raw !== \"object\") return null;\n  const record = raw;\n  if (!isBootStage(record.stage)) return null;\n  const history = Array.isArray(record.history) ? record.history.filter(isBootStage) : [];\n  const at = typeof record.at === \"number\" ? record.at : 0;\n  return {\n    stage: record.stage,\n    at,\n    // A raw `{ stage: \"script\" }` from the entry has no `startedAt`; reading it\n    // back as `at` makes the elapsed time zero rather than a decade, which is\n    // the honest answer for a record that never carried a start.\n    startedAt: typeof record.startedAt === \"number\" ? record.startedAt : at,\n    history: history.length > 0 ? history : [record.stage]\n  };\n}\nfunction readBootElapsedMs(now = Date.now()) {\n  const record = readBootRecord();\n  if (!record || record.startedAt === 0) return null;\n  return Math.max(0, now - record.startedAt);\n}\nfunction readBootStage() {\n  return readBootRecord()?.stage ?? null;\n}\nfunction stampBootStage(stage) {\n  const previous = readBootRecord();\n  if (stage === \"script\" || !previous) {\n    const now = Date.now();\n    const fresh = { stage, at: now, startedAt: now, history: [stage] };\n    slot()[bootGlobalKey] = fresh;\n    return stage;\n  }\n  if (bootStageIndex(stage) <= bootStageIndex(previous.stage)) return previous.stage;\n  slot()[bootGlobalKey] = {\n    stage,\n    at: Date.now(),\n    // Carried forward, never re-stamped: the elapsed time is measured from the\n    // start of the attempt, and a later stage resetting it would report every\n    // boot as instant.\n    startedAt: previous.startedAt,\n    history: [...previous.history, stage]\n  };\n  return stage;\n}\nfunction resetBoot() {\n  delete slot()[bootGlobalKey];\n}\nexport {\n  bootGlobalKey,\n  bootStageIndex,\n  bootStages,\n  graphReadySettleMs,\n  readBootElapsedMs,\n  readBootRecord,\n  readBootStage,\n  resetBoot,\n  stampBootStage\n};\n//# sourceMappingURL=boot.js.map\n"],"mappings":";AAAA,MAAM,aAAa;CAAC;CAAU;CAAU;CAAS;CAAY;CAAQ;AAAO;AAC5E,MAAM,qBAAqB;AAC3B,MAAM,gBAAgB;AACtB,SAAS,OAAO;CACd,OAAO;AACT;AACA,SAAS,eAAe,OAAO;CAC7B,OAAO,WAAW,QAAQ,KAAK;AACjC;AACA,SAAS,YAAY,OAAO;CAC1B,OAAO,OAAO,UAAU,YAAY,WAAW,SAAS,KAAK;AAC/D;AACA,SAAS,iBAAiB;CACxB,MAAM,MAAM,KAAK,CAAC,CAAC;CACnB,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,OAAO;CAC5C,MAAM,SAAS;CACf,IAAI,CAAC,YAAY,OAAO,KAAK,GAAG,OAAO;CACvC,MAAM,UAAU,MAAM,QAAQ,OAAO,OAAO,IAAI,OAAO,QAAQ,OAAO,WAAW,IAAI,CAAC;CACtF,MAAM,KAAK,OAAO,OAAO,OAAO,WAAW,OAAO,KAAK;CACvD,OAAO;EACL,OAAO,OAAO;EACd;EAIA,WAAW,OAAO,OAAO,cAAc,WAAW,OAAO,YAAY;EACrE,SAAS,QAAQ,SAAS,IAAI,UAAU,CAAC,OAAO,KAAK;CACvD;AACF;AACA,SAAS,kBAAkB,MAAM,KAAK,IAAI,GAAG;CAC3C,MAAM,SAAS,eAAe;CAC9B,IAAI,CAAC,UAAU,OAAO,cAAc,GAAG,OAAO;CAC9C,OAAO,KAAK,IAAI,GAAG,MAAM,OAAO,SAAS;AAC3C;AACA,SAAS,gBAAgB;CACvB,OAAO,eAAe,CAAC,EAAE,SAAS;AACpC;AACA,SAAS,eAAe,OAAO;CAC7B,MAAM,WAAW,eAAe;CAChC,IAAI,UAAU,YAAY,CAAC,UAAU;EACnC,MAAM,MAAM,KAAK,IAAI;EACrB,MAAM,QAA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