{"version":3,"file":"NewSessionDialog.mjs","names":[],"sources":["../../../../src/web/features/sessions/NewSessionDialog.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/web';\nimport {\n  Button,\n  Dialog,\n  DialogBody,\n  DialogContent,\n  DialogFooter,\n  DialogHeader,\n  DialogTitle,\n  Input,\n  ProfilePicker,\n  type ProfileChoice,\n  type ProfilePickerProfile,\n  type ProfilePickerStatus,\n  useProfileCatalog,\n} from '@agimon-ai/po-web-components';\nimport { useStore } from '@tanstack/react-store';\n\nimport {\n  generalSessionDraftKey,\n  newSessionDraftStore,\n  EMPTY_NEW_SESSION_DRAFT,\n  setNewSessionName,\n  setNewSessionProfile,\n} from '../../stores/newSessionStore';\nimport { useNewSessionActions } from './useNewSessionActions';\n\n/** The same plain creation form for an admitted workspace or a workspace-free session. */\nexport function NewSessionDialog({\n  workspaceId,\n  workspaceRoot,\n  hostId,\n  onClose,\n}: {\n  workspaceId?: string;\n  workspaceRoot?: string;\n  hostId?: string;\n  onClose: () => void;\n}) {\n  const { createPlain, loadProfiles } = useNewSessionActions(workspaceId ?? null, onClose, hostId);\n  const key = workspaceId ?? generalSessionDraftKey(hostId);\n  const draft = useStore(newSessionDraftStore, (state) => state[key] ?? EMPTY_NEW_SESSION_DRAFT);\n  const catalog = useProfileCatalog(key, loadProfiles);\n  return (\n    <NewSessionDialogView\n      workspaceRoot={workspaceRoot}\n      name={draft.name}\n      error={draft.error}\n      busy={draft.pending}\n      profilePicker={\n        catalog === undefined\n          ? undefined\n          : {\n              profiles: catalog.profiles,\n              status: catalog.status,\n              value: draft.profile,\n              onChange: (choice) => setNewSessionProfile(key, choice),\n            }\n      }\n      onName={(name) => setNewSessionName(key, name)}\n      onCreate={() => void createPlain(draft.name)}\n      onClose={onClose}\n    />\n  );\n}\n\n/** Pure composition shared by production and deterministic approval stories. */\nexport function NewSessionDialogView({\n  workspaceRoot,\n  name,\n  error,\n  busy,\n  profilePicker,\n  onName,\n  onCreate,\n  onClose,\n}: {\n  workspaceRoot?: string;\n  name: string;\n  error: string;\n  busy: boolean;\n  /** Absent when the target has no profile list, such as a workspace-free session. */\n  profilePicker?: {\n    profiles: readonly ProfilePickerProfile[];\n    status: ProfilePickerStatus;\n    value: ProfileChoice;\n    onChange: (choice: ProfileChoice) => void;\n  };\n  onName: (name: string) => void;\n  onCreate: () => void;\n  onClose: () => void;\n}) {\n  const t = useT();\n  return (\n    <Dialog open onOpenChange={(next) => !next && !busy && onClose()}>\n      <DialogContent width=\"md\" data-testid=\"new-session-dialog\" aria-describedby={undefined}>\n        <DialogHeader>\n          <DialogTitle>{t('webDashboard.welcome.newSession', 'New session')}</DialogTitle>\n        </DialogHeader>\n        <DialogBody>\n          {workspaceRoot === undefined ? null : (\n            <p className=\"truncate text-sm text-po-dim\" title={workspaceRoot}>\n              {workspaceRoot}\n            </p>\n          )}\n          <label htmlFor=\"new-session-name\" className=\"flex flex-col gap-1\">\n            <span className=\"text-base font-medium text-po-text\">\n              {t('webDashboard.newSession.nameLabel', 'Name (optional)')}\n            </span>\n            <Input\n              id=\"new-session-name\"\n              data-testid=\"new-session-name\"\n              value={name}\n              autoFocus\n              disabled={busy}\n              onChange={(event) => onName(event.target.value)}\n              onKeyDown={(event) => {\n                if (event.key === 'Enter' && !busy) onCreate();\n              }}\n              placeholder={t('webDashboard.newSession.namePlaceholder', 'Session name')}\n            />\n          </label>\n          {profilePicker === undefined ? null : <ProfilePicker {...profilePicker} disabled={busy} />}\n          {error ? (\n            <p role=\"alert\" data-testid=\"new-session-error\" className=\"text-sm text-po-red\">\n              {error}\n            </p>\n          ) : null}\n          <DialogFooter>\n            <Button variant=\"outline\" data-testid=\"new-session-cancel\" onClick={onClose} disabled={busy}>\n              {t('webDashboard.common.cancel', 'Cancel')}\n            </Button>\n            <Button variant=\"primary\" data-testid=\"new-session-create\" onClick={onCreate} disabled={busy}>\n              {busy ? t('webDashboard.common.creating', 'Creating…') : t('webDashboard.presets.create', 'Create')}\n            </Button>\n          </DialogFooter>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