{"version":3,"file":"CoordinatorProfileDialog.cjs","names":["useT","useId","Dialog","DialogContent","DialogHeader","DialogTitle","DialogBody","DialogDescription","Input","Select","SelectTrigger","SelectValue","SelectContent","SelectItem","DialogFooter","Button","ProfilePicker","Checkbox"],"sources":["../../../../src/web/features/sessions/CoordinatorProfileDialog.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/web';\nimport {\n  Button,\n  Checkbox,\n  Dialog,\n  DialogBody,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogTitle,\n  Input,\n  ProfilePicker,\n  Select,\n  SelectContent,\n  SelectItem,\n  SelectTrigger,\n  SelectValue,\n  type ProfilePickerProfile,\n  type ProfilePickerStatus,\n} from '@agimon-ai/po-web-components';\nimport { useId } from 'react';\n\nimport type { CreateProfileInput } from '../../lib/hubApi';\n\n// These IDs match the profile API's existing persona presets. The server owns their full personality text.\nconst PERSONALITIES = ['focused', 'friendly', 'creative', 'persuasive'] as const;\n\nfunction personality(\n  id: (typeof PERSONALITIES)[number],\n  t: ReturnType<typeof useT>,\n): { label: string; description: string } {\n  switch (id) {\n    case 'focused':\n      return {\n        label: t('webDashboard.profile.personality.focused', 'Focused'),\n        description: t(\n          'webDashboard.profile.personality.focusedDescription',\n          'A precise coding partner that keeps work small and verified.',\n        ),\n      };\n    case 'friendly':\n      return {\n        label: t('webDashboard.profile.personality.friendly', 'Friendly'),\n        description: t(\n          'webDashboard.profile.personality.friendlyDescription',\n          'A warm everyday assistant that explains things plainly.',\n        ),\n      };\n    case 'creative':\n      return {\n        label: t('webDashboard.profile.personality.creative', 'Creative'),\n        description: t(\n          'webDashboard.profile.personality.creativeDescription',\n          'A marketing partner that offers fresh angles and options.',\n        ),\n      };\n    case 'persuasive':\n      return {\n        label: t('webDashboard.profile.personality.persuasive', 'Persuasive'),\n        description: t(\n          'webDashboard.profile.personality.persuasiveDescription',\n          'A sales partner that frames value and drives to the next step.',\n        ),\n      };\n  }\n}\n\n/** Creates a bot from a profile, optionally as the coordinator. A missing default is a choice to make here, not a failure in the rail. */\nexport function CoordinatorProfileDialog({\n  profiles,\n  status,\n  profile,\n  workspaceName,\n  actAsCoordinator = false,\n  coordinatorBlocked,\n  pending = false,\n  error = '',\n  savedProfile,\n  profileForm,\n  onProfile,\n  onActAsCoordinator,\n  onNewProfile,\n  onCreate,\n  onRetry,\n  onClose,\n}: {\n  profiles: readonly ProfilePickerProfile[];\n  status: ProfilePickerStatus;\n  profile?: string;\n  workspaceName?: string;\n  actAsCoordinator?: boolean;\n  /** Why this bot cannot act as coordinator, such as an existing one. Absent offers the choice. */\n  coordinatorBlocked?: string;\n  pending?: boolean;\n  error?: string;\n  savedProfile?: string;\n  profileForm?: {\n    value: CreateProfileInput;\n    onChange: (value: CreateProfileInput) => void;\n    onBack: () => void;\n    onSave: () => void;\n  };\n  onProfile: (profile: string | undefined) => void;\n  onActAsCoordinator: (value: boolean) => void;\n  onNewProfile: () => void;\n  onCreate: () => void;\n  onRetry: () => void;\n  onClose: () => void;\n}) {\n  const t = useT();\n  const id = useId();\n  const empty = status === 'ready' && profiles.length === 0;\n  const chosen = profiles.some((item) => item.name === profile);\n  const missingSaved = status === 'ready' && savedProfile && !profiles.some((item) => item.name === savedProfile);\n  const message =\n    error ||\n    (missingSaved\n      ? t('webDashboard.profile.savedMissing', 'Profile saved, but it is not available here yet. Retry profiles.')\n      : '');\n  return (\n    <Dialog open onOpenChange={(open) => !open && !pending && onClose()}>\n      <DialogContent key={profileForm ? 'profile' : 'bot'} width=\"sm\" data-testid=\"coordinator-profile-dialog\">\n        <DialogHeader>\n          <DialogTitle>\n            {profileForm\n              ? t('webDashboard.profile.createProfile', 'Create profile')\n              : t('webDashboard.profile.createBot', 'Create bot')}\n          </DialogTitle>\n        </DialogHeader>\n        <DialogBody>\n          <DialogDescription>\n            {profileForm\n              ? t('webDashboard.profile.formDescription', 'Choose a name and how Po works with you.')\n              : empty\n                ? t(\n                    'webDashboard.profile.needsProfile',\n                    'Your bot needs a profile. Create one to choose how Po works with you.',\n                  )\n                : workspaceName\n                  ? t(\n                      'webDashboard.profile.chooseInWorkspace',\n                      'Choose a profile for a new bot in {workspace}. This does not change your default profile.',\n                      { workspace: workspaceName },\n                    )\n                  : t(\n                      'webDashboard.profile.chooseInHome',\n                      'Choose a profile for a new bot in Home. This does not change your default profile.',\n                    )}\n          </DialogDescription>\n          {profileForm ? (\n            <form\n              className=\"flex flex-col gap-3\"\n              onSubmit={(event) => {\n                event.preventDefault();\n                if (!pending) profileForm.onSave();\n              }}\n            >\n              <label htmlFor={`${id}-name`} className=\"flex flex-col gap-1 text-base font-medium\">\n                {t('webDashboard.profile.name', 'Name')}\n                <Input\n                  id={`${id}-name`}\n                  value={profileForm.value.displayName}\n                  onChange={(event) => profileForm.onChange({ ...profileForm.value, displayName: event.target.value })}\n                  required\n                  pattern=\".*\\S.*\"\n                  maxLength={80}\n                  disabled={pending}\n                  autoFocus\n                />\n              </label>\n              <div className=\"flex flex-col gap-1\">\n                <label htmlFor={`${id}-alias`} className=\"text-base font-medium\">\n                  {t('webDashboard.profile.id', 'Profile ID')}\n                </label>\n                <Input\n                  id={`${id}-alias`}\n                  value={profileForm.value.alias}\n                  onChange={(event) => profileForm.onChange({ ...profileForm.value, alias: event.target.value })}\n                  required\n                  pattern=\"[a-z0-9][a-z0-9\\-]{0,39}\"\n                  maxLength={40}\n                  aria-describedby={`${id}-alias-help`}\n                  disabled={pending}\n                />\n                <p id={`${id}-alias-help`} className=\"text-sm text-po-dim\">\n                  {t('webDashboard.profile.idHelp', 'Lowercase letters, numbers, and hyphens.')}\n                </p>\n              </div>\n              <div className=\"flex flex-col gap-1\">\n                <label htmlFor={`${id}-personality`} className=\"text-base font-medium\">\n                  {t('webDashboard.profile.personality', 'Personality')}\n                </label>\n                <Select\n                  value={profileForm.value.preset}\n                  onValueChange={(value) => {\n                    const preset = PERSONALITIES.find((item) => item === value);\n                    if (preset) profileForm.onChange({ ...profileForm.value, preset });\n                  }}\n                  disabled={pending}\n                >\n                  <SelectTrigger\n                    id={`${id}-personality`}\n                    aria-describedby={`${id}-personality-help`}\n                    className=\"w-full\"\n                  >\n                    <SelectValue />\n                  </SelectTrigger>\n                  <SelectContent>\n                    {PERSONALITIES.map((item) => (\n                      <SelectItem key={item} value={item}>\n                        {personality(item, t).label}\n                      </SelectItem>\n                    ))}\n                  </SelectContent>\n                </Select>\n                <p id={`${id}-personality-help`} className=\"text-sm text-po-dim\">\n                  {(() => {\n                    const preset = PERSONALITIES.find((item) => item === profileForm.value.preset);\n                    return preset === undefined ? undefined : personality(preset, t).description;\n                  })()}\n                </p>\n              </div>\n              {message ? (\n                <p role=\"alert\" className=\"text-sm text-po-red\">\n                  {message}\n                </p>\n              ) : null}\n              <DialogFooter>\n                <Button type=\"button\" variant=\"outline\" onClick={profileForm.onBack} disabled={pending}>\n                  {t('webDashboard.common.back', 'Back')}\n                </Button>\n                <Button type=\"submit\" variant=\"primary\" disabled={pending} aria-busy={pending}>\n                  {pending\n                    ? t('webDashboard.common.saving', 'Saving…')\n                    : t('webDashboard.profile.save', 'Save profile')}\n                </Button>\n              </DialogFooter>\n            </form>\n          ) : (\n            <>\n              {empty ? (\n                <p className=\"text-sm text-po-dim\">\n                  {t('webDashboard.profile.defaultUnchanged', 'Your default profile stays unchanged.')}\n                </p>\n              ) : (\n                <>\n                  <ProfilePicker\n                    required\n                    profiles={profiles}\n                    status={status}\n                    value={profile}\n                    onChange={(choice) => onProfile(typeof choice === 'string' ? choice : undefined)}\n                    disabled={pending}\n                  />\n                  <Button\n                    variant=\"outline\"\n                    onClick={onNewProfile}\n                    disabled={pending}\n                    data-testid=\"coordinator-new-profile\"\n                  >\n                    {t('webDashboard.profile.new', 'New profile')}\n                  </Button>\n                  <div className=\"flex flex-col gap-1\">\n                    <label htmlFor={`${id}-coordinator`} className=\"flex items-center gap-2 text-base\">\n                      <Checkbox\n                        id={`${id}-coordinator`}\n                        checked={actAsCoordinator && !coordinatorBlocked}\n                        onCheckedChange={(checked) => onActAsCoordinator(checked === true)}\n                        disabled={pending || Boolean(coordinatorBlocked)}\n                        aria-describedby={`${id}-coordinator-help`}\n                        data-testid=\"bot-act-as-coordinator\"\n                      />\n                      {t('webDashboard.profile.actAsCoordinator', 'Act as coordinator')}\n                    </label>\n                    <p id={`${id}-coordinator-help`} className=\"text-sm text-po-dim\">\n                      {coordinatorBlocked ||\n                        t(\n                          'webDashboard.profile.coordinatorHelp',\n                          'Oversees the other sessions here and keeps their logbook.',\n                        )}\n                    </p>\n                  </div>\n                </>\n              )}\n              {status === 'unavailable' || missingSaved ? (\n                <Button variant=\"outline\" onClick={onRetry} disabled={pending}>\n                  {t('webDashboard.profile.retry', 'Retry profiles')}\n                </Button>\n              ) : null}\n              {message ? (\n                <p role=\"alert\" className=\"text-sm text-po-red\">\n                  {message}\n                </p>\n              ) : null}\n              <DialogFooter>\n                <Button variant=\"outline\" onClick={onClose} disabled={pending}>\n                  {t('webDashboard.common.cancel', 'Cancel')}\n                </Button>\n                {empty ? (\n                  <Button variant=\"primary\" onClick={onNewProfile} disabled={pending}>\n                    {t('webDashboard.profile.createProfile', 'Create profile')}\n                  </Button>\n                ) : (\n                  <Button variant=\"primary\" onClick={onCreate} disabled={pending || status === 'loading' || !chosen}>\n                    {pending\n                      ? t('webDashboard.common.creating', 'Creating…')\n                      : t('webDashboard.profile.createBot', 'Create bot')}\n                  </Button>\n                )}\n              </DialogFooter>\n            </>\n          )}\n        </DialogBody>\n      </DialogContent>\n    </Dialog>\n  );\n}\n"],"mappings":";;;;;AA0BA,MAAM,gBAAgB;CAAC;CAAW;CAAY;CAAY;AAAY;AAEtE,SAAS,YACP,IACA,GACwC;CACxC,QAAQ,IAAR;EACE,KAAK,WACH,OAAO;GACL,OAAO,EAAE,4CAA4C,SAAS;GAC9D,aAAa,EACX,uDACA,8DACF;EACF;EACF,KAAK,YACH,OAAO;GACL,OAAO,EAAE,6CAA6C,UAAU;GAChE,aAAa,EACX,wDACA,yDACF;EACF;EACF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