{"version":3,"file":"teamStore.mjs","names":[],"sources":["../../../src/web/stores/teamStore.ts"],"sourcesContent":["import { Store } from '@tanstack/store';\n\nexport type PoTeamRole = 'owner' | 'admin' | 'member';\nexport type PoTeamGrant = Exclude<PoTeamRole, 'owner'>;\n\n/** The signed-in session's team, as Po Cloud's Team client reads it. */\nexport interface PoTeam {\n  id: string;\n  name: string;\n  role: PoTeamRole;\n  people: readonly { id: string; name: string; email: string; role: PoTeamRole; you: boolean }[];\n  invites: readonly { id: string; email: string; role: PoTeamGrant; expiresAt: string }[];\n}\n\n/**\n * Po Cloud's Team calls, as the host lends them: po-identity's Team client over the browser's own session on\n * Po Cloud's web app, or over Po Desktop's main process. Every change names the team it was read for.\n */\nexport interface PoTeamClient {\n  read(): Promise<PoTeam>;\n  rename(team: Pick<PoTeam, 'id'>, name: string): Promise<void>;\n  invite(team: Pick<PoTeam, 'id'>, email: string, role: PoTeamGrant): Promise<void>;\n  cancelInvite(inviteId: string): Promise<void>;\n  setRole(team: Pick<PoTeam, 'id'>, memberId: string, role: PoTeamGrant): Promise<void>;\n  remove(team: Pick<PoTeam, 'id'>, memberId: string): Promise<void>;\n  leave(team: Pick<PoTeam, 'id'>): Promise<void>;\n  delete(team: Pick<PoTeam, 'id'>): Promise<void>;\n}\n\n/** Undefined where this Po has no Po Cloud team, so neither the Team row nor its pages show. */\nexport const teamStore = new Store<{ client?: PoTeamClient }>({});\n\n/** The host binds Po Cloud's Team client once at startup; the returned function unbinds it. */\nexport function bindTeam(client: PoTeamClient | undefined): () => void {\n  teamStore.setState(() => ({ client }));\n  return () => {\n    if (teamStore.state.client === client) teamStore.setState(() => ({}));\n  };\n}\n"],"mappings":";;;AA8BA,MAAa,YAAY,IAAI,MAAiC,CAAC,CAAC;;AAGhE,SAAgB,SAAS,QAA8C;CACrE,UAAU,gBAAgB,EAAE,OAAO,EAAE;CACrC,aAAa;EACX,IAAI,UAAU,MAAM,WAAW,QAAQ,UAAU,gBAAgB,CAAC,EAAE;CACtE;AACF"}