{"version":3,"file":"firstSessionWelcome.mjs","names":[],"sources":["../../../src/web/lib/firstSessionWelcome.ts"],"sourcesContent":["import { STARTER_POS, type StarterPo } from './starterPos';\n\nconst STORAGE_KEY = 'po.firstSessionWelcome';\n\n/** What the first session greets the person with: the Po they chose and what they said on About you. */\nexport interface FirstSessionWelcome {\n  sessionId: string;\n  poId: StarterPo['id'];\n  name: string;\n  interests: string;\n}\n\n/**\n * Kept for the one session onboarding opened, until that conversation has a message.\n * ponytail: this browser only. Another device shows the plain empty conversation; move it to the\n * session's own metadata if the welcome should follow the person.\n */\nexport function rememberFirstSessionWelcome(welcome: FirstSessionWelcome): void {\n  try {\n    window.localStorage.setItem(STORAGE_KEY, JSON.stringify(welcome));\n  } catch {\n    // Persistence is optional: the session opens with the plain empty conversation instead.\n    return;\n  }\n}\n\n/** The welcome for this session and its Po, if onboarding opened it here. */\nexport function firstSessionWelcomeFor(\n  sessionId: string | null,\n): { po: StarterPo; name: string; interests: string } | undefined {\n  if (sessionId === null) return undefined;\n  let parsed: unknown;\n  try {\n    parsed = JSON.parse(window.localStorage.getItem(STORAGE_KEY) ?? 'null');\n  } catch {\n    return undefined;\n  }\n  if (typeof parsed !== 'object' || parsed === null) return undefined;\n  const welcome = parsed as Partial<FirstSessionWelcome>;\n  const po = STARTER_POS.find((entry) => entry.id === welcome.poId);\n  if (welcome.sessionId !== sessionId || po === undefined) return undefined;\n  return {\n    po,\n    name: typeof welcome.name === 'string' ? welcome.name : '',\n    interests: typeof welcome.interests === 'string' ? welcome.interests : '',\n  };\n}\n"],"mappings":";;AAEA,MAAM,cAAc;;;;;;AAepB,SAAgB,4BAA4B,SAAoC;CAC9E,IAAI;EACF,OAAO,aAAa,QAAQ,aAAa,KAAK,UAAU,OAAO,CAAC;CAClE,QAAQ;EAEN;CACF;AACF;;AAGA,SAAgB,uBACd,WACgE;CAChE,IAAI,cAAc,MAAM,OAAO,KAAA;CAC/B,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,OAAO,aAAa,QAAQ,WAAW,KAAK,MAAM;CACxE,QAAQ;EACN;CACF;CACA,IAAI,OAAO,WAAW,YAAY,WAAW,MAAM,OAAO,KAAA;CAC1D,MAAM,UAAU;CAChB,MAAM,KAAK,YAAY,MAAM,UAAU,MAAM,OAAO,QAAQ,IAAI;CAChE,IAAI,QAAQ,cAAc,aAAa,OAAO,KAAA,GAAW,OAAO,KAAA;CAChE,OAAO;EACL;EACA,MAAM,OAAO,QAAQ,SAAS,WAAW,QAAQ,OAAO;EACxD,WAAW,OAAO,QAAQ,cAAc,WAAW,QAAQ,YAAY;CACzE;AACF"}