{"version":3,"sources":["../../../../../src/shared/lib/segment-cache/vary-params-decoding.ts"],"sourcesContent":["/**\n * Vary Params Decoding\n *\n * This module is shared between server and client.\n */\n\nexport type VaryParams = Set<string>\n\ntype FulfilledVaryParamsThenable = {\n  status: 'fulfilled'\n  value: VaryParams\n} & PromiseLike<VaryParams>\n\ntype PendingVaryParamsThenable = {\n  // 'resolved_model' is an internal React Flight state: the underlying model\n  // data has arrived but the thenable hasn't been \"unwrapped\" yet. Calling\n  // .then() triggers Flight to synchronously transition to 'fulfilled'.\n  status: 'pending' | 'resolved_model'\n  value: unknown\n} & PromiseLike<VaryParams>\n\nexport type VaryParamsThenable =\n  | FulfilledVaryParamsThenable\n  | PendingVaryParamsThenable\n\n/**\n * Synchronously reads vary params from a thenable.\n *\n * By the time this is called (client-side or in collectSegmentData), the\n * thenable should already be fulfilled because the Flight stream has been\n * fully received. We check the status synchronously to avoid unnecessary\n * microtasks.\n *\n * Returns null if the thenable is still pending (which shouldn't happen in\n * normal operation - it indicates the server failed to track vary params).\n */\nexport function readVaryParams(\n  thenable: VaryParamsThenable\n): VaryParams | null {\n  // Attach a no-op listener to force Flight to synchronously resolve the\n  // thenable. When a thenable arrives from the Flight stream, it may be in an\n  // intermediate 'resolved_model' state (data received but not unwrapped).\n  // Calling .then() triggers Flight to transition it to 'fulfilled', making\n  // the value available synchronously. React uses this same optimization\n  // internally to avoid unnecessary microtasks.\n  thenable.then(noop)\n  // If the thenable is still not 'fulfilled' after calling .then(), the server\n  // failed to resolve it before the stream ended. Treat as unknown.\n  if (thenable.status !== 'fulfilled') {\n    return null\n  }\n  return thenable.value\n}\n\nconst noop = () => {}\n"],"names":["readVaryParams","thenable","then","noop","status","value"],"mappings":"AAAA;;;;CAIC,GAqBD;;;;;;;;;;CAUC,GACD,OAAO,SAASA,eACdC,QAA4B;IAE5B,uEAAuE;IACvE,4EAA4E;IAC5E,yEAAyE;IACzE,0EAA0E;IAC1E,uEAAuE;IACvE,8CAA8C;IAC9CA,SAASC,IAAI,CAACC;IACd,6EAA6E;IAC7E,kEAAkE;IAClE,IAAIF,SAASG,MAAM,KAAK,aAAa;QACnC,OAAO;IACT;IACA,OAAOH,SAASI,KAAK;AACvB;AAEA,MAAMF,OAAO,KAAO","ignoreList":[0]}