{"version":3,"file":"connection-form-CjUay_qz.mjs","names":["generateId","LabelRow","HintText"],"sources":["../../editors/shared/undo-plan.ts","../../editors/shared/editor-chrome.tsx","../../editors/connection-editor/connection-callbacks.ts","../../editors/connection-editor/status.ts","../../editors/connection-editor/connection-form.tsx"],"sourcesContent":["// Undo that steps over operations that are not the author's edits, such as\n// the runtime's test and run facts, and redo of what it took back.\nimport {\n  garbageCollect,\n  garbageCollectV2,\n  generateId,\n  sortOperations,\n  type Action,\n  type Operation,\n} from \"@powerhousedao/shared/document-model\";\n\nexport interface UndoPolicy {\n  // Operation types undo passes over.\n  skip: ReadonlySet<string>;\n  // Rebuilds a skipped action that must outlive the undo; undefined drops it.\n  // `undone` is the edit being taken back, e.g. the step a test was of.\n  replay?: (action: Action, undone: readonly Action[]) => Action | undefined;\n}\n\nexport interface UndoPlan {\n  // UNDOs to dispatch: the skipped operations and the edit before them.\n  undos: number;\n  // Re-dispatched after the undos, oldest first.\n  replay: Action[];\n  // The edit the undos take back, oldest first; redo dispatches it again.\n  undone: Action[];\n}\n\n// Actions of one edit share an id prefix, so undo takes them back together.\nconst GROUP_PREFIX = \"undo-group:\";\n\nexport function newUndoGroup(): string {\n  return generateId();\n}\n\nexport function groupedAction<A extends Action>(action: A, group: string): A {\n  return { ...action, id: `${GROUP_PREFIX}${group}:${generateId()}` };\n}\n\nexport function undoGroupOf(action: Action): string | undefined {\n  if (!action.id.startsWith(GROUP_PREFIX)) return undefined;\n  const end = action.id.indexOf(\":\", GROUP_PREFIX.length);\n  return end > GROUP_PREFIX.length\n    ? action.id.slice(GROUP_PREFIX.length, end)\n    : undefined;\n}\n\n// The operations still in effect: undone ones and the NOOPs removed.\nexport function effectiveOperations(\n  operations: readonly Operation[],\n  protocolVersion: number,\n): Operation[] {\n  const sorted = sortOperations([...operations]);\n  const kept =\n    protocolVersion >= 2 ? garbageCollectV2(sorted) : garbageCollect(sorted);\n  return kept.filter((operation) => operation.action.type !== \"NOOP\");\n}\n\n// Where the edit ending at `last` starts: back through its group's actions,\n// passing over skipped and failed operations between them.\nfunction editStart(\n  effective: readonly Operation[],\n  last: number,\n  policy: UndoPolicy,\n): number {\n  const group = undoGroupOf(effective[last].action);\n  if (!group) return last;\n  let start = last;\n  for (let index = last - 1; index >= 0; index--) {\n    const { action, error } = effective[index];\n    if (undoGroupOf(action) === group) start = index;\n    else if (!error && !policy.skip.has(action.type)) break;\n  }\n  return start;\n}\n\n// Null when nothing but skipped operations is left to undo.\nexport function planUndo(\n  effective: readonly Operation[],\n  policy: UndoPolicy,\n): UndoPlan | null {\n  for (let last = effective.length - 1; last >= 0; last--) {\n    const { action, error } = effective[last];\n    // A failed operation changed nothing, so it is passed over too.\n    if (error || policy.skip.has(action.type)) continue;\n    const start = editStart(effective, last, policy);\n    const group = undoGroupOf(action);\n    const isMember = (candidate: Action) =>\n      candidate === action ||\n      (group !== undefined && undoGroupOf(candidate) === group);\n    const applied = effective\n      .slice(start)\n      .filter((operation) => !operation.error)\n      .map((operation) => operation.action);\n    const undone = applied.filter(isMember);\n    const replay = applied\n      .filter((candidate) => !isMember(candidate))\n      .map((candidate) => policy.replay?.(candidate, undone))\n      .filter((kept): kept is Action => kept !== undefined);\n    return { undos: effective.length - start, replay, undone };\n  }\n  return null;\n}\n\n// The last operation index in `operations`, or -1.\nexport function headIndex(operations: readonly Operation[]): number {\n  return operations.reduce((head, op) => Math.max(head, op.index), -1);\n}\n\n// Whether an author edit landed after `head`, which voids pending redos.\nexport function editedSince(\n  operations: readonly Operation[],\n  head: number,\n  policy: UndoPolicy,\n): boolean {\n  return operations.some(\n    (op) =>\n      op.index > head &&\n      op.action.type !== \"NOOP\" &&\n      !policy.skip.has(op.action.type),\n  );\n}\n\n// A fresh action carrying an undone edit, to dispatch as its redo.\nexport function redoAction(action: Action): Action {\n  return {\n    id: generateId(),\n    type: action.type,\n    scope: action.scope,\n    input: action.input,\n    timestampUtcMs: new Date().toISOString(),\n  };\n}\n\n// An undone edit's actions again, in a group of their own when there are several.\nexport function redoActions(actions: readonly Action[]): Action[] {\n  if (actions.length <= 1) return actions.map(redoAction);\n  const group = newUndoGroup();\n  return actions.map((action) => groupedAction(redoAction(action), group));\n}\n","// The controls every editor's own header carries in place of Connect's\n// document toolbar: a way back out, and undo/redo.\nimport {\n  setSelectedNode,\n  useDocumentById,\n} from \"@powerhousedao/reactor-browser\";\nimport {\n  baseReducerVersion,\n  undo,\n  type Action,\n  type Operation,\n  type PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { Button, IconButton } from \"./controls.js\";\nimport { Icon } from \"./icons.js\";\nimport {\n  editedSince,\n  effectiveOperations,\n  headIndex,\n  planUndo,\n  redoActions,\n  type UndoPolicy,\n} from \"./undo-plan.js\";\n\nexport function BackButton(props: { label?: string }) {\n  return (\n    <Button\n      size=\"sm\"\n      variant=\"ghost\"\n      className=\"-ml-1\"\n      onClick={() => setSelectedNode(undefined)}\n    >\n      <Icon name=\"back\" className=\"h-3.5 w-3.5\" />\n      {props.label ?? \"Back\"}\n    </Button>\n  );\n}\n\nconst NO_SKIP: UndoPolicy = { skip: new Set() };\n\nfunction protocolVersion(document: PHDocument): number {\n  try {\n    return baseReducerVersion(document.header);\n  } catch {\n    return 1;\n  }\n}\n\nconst PAGE = 500;\n\n// Documents in the cache carry no history, so undo reads it when pressed.\nasync function globalHistory(documentId: string): Promise<Operation[]> {\n  const client = window.ph?.reactorClient;\n  if (!client) return [];\n  let page = await client.getOperations(\n    documentId,\n    { branch: \"main\", scopes: [\"global\"] },\n    undefined,\n    { cursor: \"\", limit: PAGE },\n  );\n  const all = [...page.results];\n  while (page.next && page.results.length > 0) {\n    page = await page.next();\n    all.push(...page.results);\n  }\n  return all;\n}\n\n// Text fields keep the browser's own undo.\nfunction isEditable(target: EventTarget | null): boolean {\n  if (!(target instanceof HTMLElement)) return false;\n  return (\n    target.isContentEditable ||\n    target.tagName === \"INPUT\" ||\n    target.tagName === \"TEXTAREA\" ||\n    target.tagName === \"SELECT\"\n  );\n}\n\nexport function UndoRedo(props: { documentId: string; policy?: UndoPolicy }) {\n  const [document, dispatch] = useDocumentById(props.documentId);\n  const policy = props.policy ?? NO_SKIP;\n  const canUndo = Object.values(document?.header.revision ?? {}).some(Boolean);\n  // Edits undone here, newest last: the reactor keeps no clipboard to redo\n  // from. Any other edit after `head` voids them.\n  const [undone, setUndone] = useState<Action[][]>([]);\n  const head = useRef(-1);\n  const own = useRef(new Set<string>());\n  // One undo or redo at a time: a second press plans from the same history.\n  const busy = useRef(false);\n\n  const send = (list: Action[]) =>\n    new Promise<void>((resolve, reject) =>\n      dispatch(\n        list,\n        (errors) => reject(errors[0]),\n        () => resolve(),\n      ),\n    );\n  const stale = (history: Operation[]) =>\n    editedSince(\n      history.filter((op) => !own.current.has(op.action.id)),\n      head.current,\n      policy,\n    );\n  // Moves `head` past what was sent, and says whether anything landed after\n  // `since`: a batch whose later action failed still applied the ones before.\n  const settle = async (since: number) => {\n    head.current = headIndex(await globalHistory(props.documentId));\n    return head.current > since;\n  };\n  const run = (task: () => Promise<void>) => {\n    if (!document || busy.current) return;\n    busy.current = true;\n    task()\n      .catch(() => undefined)\n      .finally(() => {\n        busy.current = false;\n      });\n  };\n\n  const doUndo = () =>\n    run(async () => {\n      const history = await globalHistory(props.documentId);\n      const plan = planUndo(\n        effectiveOperations(history, protocolVersion(document!)),\n        policy,\n      );\n      if (!plan) return;\n      const keep = !stale(history);\n      try {\n        await send([\n          ...Array.from({ length: plan.undos }, () => undo()),\n          ...plan.replay,\n        ]);\n      } finally {\n        if (await settle(headIndex(history))) {\n          setUndone((list) => [...(keep ? list : []), plan.undone]);\n        }\n      }\n    });\n  const doRedo = () =>\n    run(async () => {\n      const last = undone.at(-1);\n      if (!last) return;\n      const history = await globalHistory(props.documentId);\n      if (stale(history)) {\n        setUndone([]);\n        return;\n      }\n      const again = redoActions(last);\n      for (const action of again) own.current.add(action.id);\n      try {\n        await send(again);\n      } finally {\n        if (await settle(headIndex(history))) {\n          setUndone((list) => list.slice(0, -1));\n        }\n      }\n    });\n\n  // Read by the key handler and the effects, which don't rerun for them.\n  const latest = useRef({ doUndo, doRedo, stale });\n  useEffect(() => {\n    latest.current = { doUndo, doRedo, stale };\n  });\n\n  // An edit made elsewhere voids what is left to redo.\n  const revision = JSON.stringify(document?.header.revision ?? {});\n  const pending = undone.length > 0;\n  useEffect(() => {\n    if (!pending || busy.current) return;\n    let active = true;\n    void globalHistory(props.documentId).then((history) => {\n      if (active && !busy.current && latest.current.stale(history)) {\n        setUndone([]);\n      }\n    });\n    return () => {\n      active = false;\n    };\n  }, [revision, pending, props.documentId]);\n  useEffect(() => {\n    const onKeyDown = (event: KeyboardEvent) => {\n      if (!(event.metaKey || event.ctrlKey) || event.altKey) return;\n      if (isEditable(event.target)) return;\n      const key = event.key.toLowerCase();\n      if (key === \"z\" && !event.shiftKey) {\n        event.preventDefault();\n        event.stopPropagation();\n        latest.current.doUndo();\n      } else if ((key === \"z\" && event.shiftKey) || key === \"y\") {\n        event.preventDefault();\n        event.stopPropagation();\n        latest.current.doRedo();\n      }\n    };\n    // Capture, so Connect's own shortcut doesn't undo a second time.\n    window.addEventListener(\"keydown\", onKeyDown, true);\n    return () => window.removeEventListener(\"keydown\", onKeyDown, true);\n  }, []);\n\n  return (\n    <span className=\"flex items-center\">\n      <IconButton\n        icon=\"undo\"\n        label=\"Undo\"\n        disabled={!canUndo}\n        onClick={doUndo}\n      />\n      <IconButton\n        icon=\"redo\"\n        label=\"Redo\"\n        disabled={undone.length === 0}\n        onClick={doRedo}\n      />\n    </span>\n  );\n}\n","// The document side of ConnectionForm: form callbacks mapped onto connection\n// actions. Shared by this editor and the workflow editor's create modal.\nimport type { DocumentDispatch } from \"@powerhousedao/reactor-browser\";\nimport { generateId } from \"document-model\";\nimport {\n  actions,\n  type ConnectionAction,\n  type ConnectionState,\n} from \"document-models/connection\";\nimport type { ConnectionCallbacks } from \"./connection-form.js\";\nimport {\n  connectorIdForPiece,\n  planFromAuth,\n  UNKNOWN_AUTH,\n} from \"./piece-auth.js\";\n\nexport function connectionCallbacks(\n  state: ConnectionState,\n  dispatch: DocumentDispatch<ConnectionAction>,\n): ConnectionCallbacks {\n  return {\n    setName: (name) => {\n      dispatch(actions.setConnectionName({ name }));\n      dispatch(actions.setName(name));\n    },\n    pickPiece: (piece) => {\n      const plan = planFromAuth(piece.auth);\n      // An auth type this runtime doesn't know is never stored as another.\n      if (plan.authType === UNKNOWN_AUTH) return;\n      dispatch(\n        actions.setConnector({\n          connectorId: connectorIdForPiece(piece.name),\n          authType: plan.authType,\n        }),\n      );\n    },\n    // Same connector, another sign-in method: only the fields the new method\n    // asks for survive, so a SECRET_TEXT never carries a CUSTOM_AUTH token.\n    setAuthType: (authType, keep) => {\n      dispatch(\n        actions.setConnector({ connectorId: state.connectorId, authType }),\n      );\n      const config = Object.fromEntries(\n        Object.entries((state.config ?? {}) as Record<string, unknown>).filter(\n          ([name]) => keep.config.includes(name),\n        ),\n      );\n      dispatch(actions.setConfig({ config }));\n      for (const ref of state.secretRefs) {\n        if (!keep.secrets.includes(ref.name)) {\n          dispatch(actions.removeSecretRef({ id: ref.id }));\n        }\n      }\n    },\n    setConfigValue: (name, value) => {\n      const config = {\n        ...((state.config ?? {}) as Record<string, unknown>),\n      };\n      if (value === undefined) delete config[name];\n      else config[name] = value;\n      dispatch(actions.setConfig({ config }));\n    },\n    setSecretRef: (name, ref) => {\n      const existing = state.secretRefs.find((entry) => entry.name === name);\n      dispatch(\n        actions.setSecretRef({ id: existing?.id ?? generateId(), name, ref }),\n      );\n    },\n    removeSecretRef: (name) => {\n      const existing = state.secretRefs.find((entry) => entry.name === name);\n      if (existing) dispatch(actions.removeSecretRef({ id: existing.id }));\n    },\n    setStatus: (status) => {\n      dispatch(\n        actions.recordCheckResult({\n          status,\n          checkedAt: new Date().toISOString(),\n        }),\n      );\n    },\n  };\n}\n","// Shared by the connection toolbar and the form, so a connection's status\n// looks the same wherever it appears.\nimport type {\n  ConnectionAuthType,\n  ConnectionStatus,\n} from \"document-models/connection\";\nimport { UNKNOWN_AUTH } from \"./piece-auth.js\";\n\nexport const CONNECTION_STATUS_STYLES: Record<ConnectionStatus, string> = {\n  OK: \"bg-wf-ok/12 text-wf-ok\",\n  ERROR: \"bg-wf-fail/12 text-wf-fail\",\n  REVOKED: \"bg-wf-fail/12 text-wf-fail\",\n  UNCONFIGURED: \"bg-wf-warn/12 text-wf-warn\",\n};\n\nexport const CONNECTION_STATUS_LABEL: Record<ConnectionStatus, string> = {\n  OK: \"Connected\",\n  ERROR: \"Error\",\n  REVOKED: \"Revoked\",\n  UNCONFIGURED: \"Not set up\",\n};\n\nexport const AUTH_TYPE_LABEL: Record<\n  ConnectionAuthType | typeof UNKNOWN_AUTH,\n  string\n> = {\n  [UNKNOWN_AUTH]: \"Not supported by this runtime\",\n  NONE: \"None\",\n  SECRET_TEXT: \"API key\",\n  BASIC_AUTH: \"Username and password\",\n  CUSTOM_AUTH: \"Keys and tokens\",\n  OAUTH2: \"OAuth 2\",\n  OIDC: \"OpenID Connect\",\n};\n","// Presentation for the connection editor: connector picker driven by the\n// piece catalog, auth form driven by the piece's PieceAuth descriptor.\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport type {\n  ConnectionAuthType,\n  ConnectionState,\n  ConnectionStatus,\n} from \"document-models/connection\";\nimport type {\n  PieceSummary,\n  SecretStat,\n} from \"../workflow-editor/runtime-client.js\";\nimport {\n  useOAuthAttempt,\n  useOAuthRedirectUri,\n  usePieceCatalog,\n  useRuntimeActions,\n  useSecretStat,\n} from \"../workflow-editor/runtime-context.js\";\nimport { formatWhen } from \"../workflow-studio/components/run-format.js\";\nimport { Icon } from \"../shared/icons.js\";\nimport { AUTH_TYPE_LABEL } from \"./status.js\";\nimport {\n  Button,\n  FieldError,\n  FieldLabel as LabelRow,\n  Hint as HintText,\n  IconButton,\n  Select,\n  Switch,\n  textInputClass,\n} from \"../shared/controls.js\";\nimport {\n  isAuthComplete,\n  OAUTH_TOKEN,\n  packageFromConnectorId,\n  planForConnection,\n  planFromAuth,\n  plansFromAuth,\n  UNKNOWN_AUTH,\n  type AuthField,\n  type AuthPlan,\n} from \"./piece-auth.js\";\n\nexport interface ConnectionCallbacks {\n  setName: (name: string) => void;\n  pickPiece: (piece: PieceSummary) => void;\n  // `keep` names the new method's fields; any other credential is dropped.\n  setAuthType: (\n    authType: ConnectionAuthType,\n    keep: { config: string[]; secrets: string[] },\n  ) => void;\n  setConfigValue: (name: string, value: unknown) => void;\n  setSecretRef: (name: string, ref: string) => void;\n  removeSecretRef: (name: string) => void;\n  setStatus: (status: ConnectionStatus) => void;\n}\n\nconst inputClass = textInputClass;\n\nfunction FieldLabel(props: { field: AuthField }) {\n  return (\n    <LabelRow\n      label={props.field.displayName}\n      optional={!props.field.required}\n    />\n  );\n}\n\nfunction Hint(props: { children?: string }) {\n  return <HintText text={props.children ?? \"\"} />;\n}\n\nfunction ConfigField(props: {\n  field: AuthField;\n  value: unknown;\n  onCommit: (value: unknown) => void;\n}) {\n  const { field, value } = props;\n  if (field.inputType === \"CHECKBOX\") {\n    return (\n      <Switch\n        checked={Boolean(value)}\n        onChange={(checked) => props.onCommit(checked)}\n        label={field.displayName}\n        description={field.description}\n      />\n    );\n  }\n  if (field.inputType === \"STATIC_DROPDOWN\") {\n    return (\n      <div>\n        <FieldLabel field={field} />\n        <Select\n          value={typeof value === \"string\" ? value : \"\"}\n          options={(field.options ?? []).map((option) => ({\n            value: String(option.value),\n            label: option.label,\n          }))}\n          clearable={!field.required}\n          onChange={(next) => props.onCommit(next || undefined)}\n        />\n        <Hint>{field.description}</Hint>\n      </div>\n    );\n  }\n  return (\n    <label className=\"block\">\n      <FieldLabel field={field} />\n      <input\n        className={inputClass}\n        type={field.inputType === \"NUMBER\" ? \"number\" : \"text\"}\n        defaultValue={\n          typeof value === \"string\" || typeof value === \"number\" ? value : \"\"\n        }\n        spellCheck={false}\n        onBlur={(event) => {\n          const raw = event.target.value.trim();\n          if (raw === \"\") props.onCommit(undefined);\n          else if (field.inputType === \"NUMBER\") props.onCommit(Number(raw));\n          else props.onCommit(raw);\n        }}\n      />\n      <Hint>{field.description}</Hint>\n    </label>\n  );\n}\n\nconst SECRET_REF_PREFIX = \"secret://v1:\";\n\nfunction isManagedRef(ref: string): boolean {\n  return ref.startsWith(SECRET_REF_PREFIX);\n}\n\nfunction SavedSecret(props: {\n  stat: SecretStat | undefined;\n  fresh: boolean;\n  onReplace: () => void;\n  onRemove: () => void;\n}) {\n  const { stat, fresh } = props;\n  return (\n    <div\n      className=\"flex items-center gap-3 rounded-lg border border-solid border-foreground/10 bg-muted/40 px-3 py-2.5\"\n      title={stat?.label ?? undefined}\n    >\n      <span className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-wf-ok/12 text-wf-ok\">\n        <Icon name=\"lock\" className=\"h-4 w-4\" />\n      </span>\n      <span className=\"min-w-0 flex-1\">\n        <span\n          aria-hidden\n          className=\"block font-mono text-sm leading-5 tracking-[0.08em] text-foreground\"\n        >\n          ••••••••••••\n        </span>\n        <span className=\"block text-xs text-muted-foreground\">\n          {stat === undefined ? (\n            \"Checking the saved value…\"\n          ) : fresh ? (\n            <span className=\"inline-flex items-center gap-1 font-medium text-wf-ok\">\n              <Icon name=\"check\" className=\"h-3 w-3\" />\n              Saved just now\n            </span>\n          ) : (\n            <span title={new Date(stat.updatedAt).toLocaleString()}>\n              Saved {formatWhen(stat.updatedAt)}\n              {stat.version > 1 ? `, version ${stat.version}` : \"\"}\n            </span>\n          )}\n        </span>\n      </span>\n      <Button size=\"sm\" onClick={props.onReplace}>\n        Replace\n      </Button>\n      <IconButton\n        icon=\"trash\"\n        label=\"Remove saved value\"\n        onClick={props.onRemove}\n      />\n    </div>\n  );\n}\n\n// The input takes the VALUE; only the minted ref ever enters the document.\n// A stored secret is replaced by rotating it in place unless asked otherwise.\nfunction SecretField(props: {\n  field: AuthField;\n  refValue: string;\n  connectionName: string;\n  onCommit: (ref: string) => void;\n  onRemove: () => void;\n}) {\n  const { field, refValue } = props;\n  const inputId = useId();\n  const managed = isManagedRef(refValue);\n  const stat = useSecretStat(refValue, managed);\n  const actions = useRuntimeActions();\n  const [value, setValue] = useState(\"\");\n  const [reveal, setReveal] = useState(false);\n  const [busy, setBusy] = useState(false);\n  const [error, setError] = useState<string | null>(null);\n  const [editing, setEditing] = useState(false);\n  const [justSaved, setJustSaved] = useState(false);\n  const [advanced, setAdvanced] = useState(false);\n  // Mints a new ref instead of rotating the existing one.\n  const [separate, setSeparate] = useState(false);\n\n  const stored = managed && stat !== null && stat?.status !== \"DELETED\";\n  const problem = !refValue\n    ? null\n    : stat?.status === \"DELETED\"\n      ? \"The saved value was deleted on the switchboard. Paste a new one.\"\n      : stat === null\n        ? \"The saved reference no longer resolves. Paste the value again.\"\n        : null;\n  const showEditor = !stored || editing;\n\n  const cancel = () => {\n    setValue(\"\");\n    setError(null);\n    setEditing(false);\n    setReveal(false);\n  };\n\n  const save = () => {\n    if (!value || busy) return;\n    setBusy(true);\n    setError(null);\n    const label = `${props.connectionName || \"connection\"} · ${field.displayName}`;\n    const request =\n      stored && !separate\n        ? actions.rotateSecret(refValue, value)\n        : actions.createSecret(value, label);\n    request\n      .then((result) => {\n        cancel();\n        setJustSaved(true);\n        if (result.ref !== refValue) props.onCommit(result.ref);\n      })\n      .catch((requestError: unknown) => {\n        setError(\n          requestError instanceof Error\n            ? requestError.message\n            : String(requestError),\n        );\n      })\n      .finally(() => setBusy(false));\n  };\n\n  return (\n    <div>\n      <LabelRow\n        htmlFor={showEditor ? inputId : undefined}\n        label={field.displayName}\n        optional={!field.required}\n        needsValue={field.required && !stored}\n        action={\n          <button\n            type=\"button\"\n            className=\"text-xs text-muted-foreground hover:text-foreground\"\n            aria-expanded={advanced}\n            onClick={() => setAdvanced((open) => !open)}\n          >\n            {advanced ? \"Hide reference\" : \"Reference\"}\n          </button>\n        }\n      />\n      {stored && !editing ? (\n        <SavedSecret\n          stat={stat}\n          fresh={justSaved}\n          onReplace={() => {\n            setJustSaved(false);\n            setEditing(true);\n          }}\n          onRemove={props.onRemove}\n        />\n      ) : null}\n      {problem ? (\n        <p className=\"mb-2 flex items-start gap-2 rounded-md bg-wf-warn/10 px-3 py-2 text-xs text-wf-warn\">\n          <Icon name=\"alert\" className=\"mt-px h-3.5 w-3.5\" />\n          {problem}\n        </p>\n      ) : null}\n      {showEditor ? (\n        <div className=\"flex items-center gap-2\">\n          <div className=\"relative min-w-0 flex-1\">\n            <input\n              id={inputId}\n              className={`${inputClass} pr-9 ${value && !reveal ? \"font-mono tracking-wider\" : \"\"}`}\n              type={reveal ? \"text\" : \"password\"}\n              value={value}\n              disabled={busy}\n              autoFocus={editing}\n              placeholder={\n                stored\n                  ? `Paste the new ${field.displayName.toLowerCase()}`\n                  : `Paste the ${field.displayName.toLowerCase()}`\n              }\n              autoComplete=\"off\"\n              spellCheck={false}\n              onChange={(event) => setValue(event.target.value)}\n              onKeyDown={(event) => {\n                if (event.key === \"Enter\") save();\n                if (event.key === \"Escape\" && editing) cancel();\n              }}\n            />\n            <span className=\"absolute inset-y-0 right-1 flex items-center\">\n              <IconButton\n                icon={reveal ? \"eyeOff\" : \"eye\"}\n                label={`${reveal ? \"Hide\" : \"Show\"} ${field.displayName}`}\n                onClick={() => setReveal((shown) => !shown)}\n              />\n            </span>\n          </div>\n          <Button\n            variant=\"primary\"\n            aria-label={`Save ${field.displayName}`}\n            disabled={!value || busy}\n            onClick={save}\n          >\n            {busy ? \"Saving…\" : \"Save\"}\n          </Button>\n          {editing ? (\n            <Button variant=\"ghost\" onClick={cancel}>\n              Cancel\n            </Button>\n          ) : null}\n          {problem ? (\n            <IconButton\n              icon=\"trash\"\n              label=\"Remove saved value\"\n              onClick={props.onRemove}\n            />\n          ) : null}\n        </div>\n      ) : null}\n      <FieldError>{error}</FieldError>\n      <Hint>{field.description}</Hint>\n      {advanced ? (\n        <div className=\"mt-3 flex flex-col gap-3 rounded-lg border border-dashed border-foreground/15 px-3 py-3\">\n          <div>\n            <LabelRow htmlFor={`${inputId}-ref`} label=\"Secret reference\" />\n            <input\n              id={`${inputId}-ref`}\n              key={refValue}\n              className={`${inputClass} font-mono text-xs`}\n              defaultValue={refValue}\n              placeholder=\"secret://v1:…\"\n              spellCheck={false}\n              onBlur={(event) => {\n                const ref = event.target.value.trim();\n                if (!ref || ref === refValue) return;\n                if (!isManagedRef(ref)) {\n                  setError(\n                    \"Only secret://v1: references resolve. To store a value, paste it above instead.\",\n                  );\n                  return;\n                }\n                setError(null);\n                props.onCommit(ref);\n              }}\n            />\n            <HintText text=\"Point at a secret that already exists on the switchboard, for example one shared with another connection.\" />\n          </div>\n          {stored ? (\n            <Switch\n              checked={separate}\n              onChange={setSeparate}\n              label=\"Save replacements as a separate secret\"\n              description=\"Leaves the current secret untouched for anything else that uses it, instead of adding a new version.\"\n            />\n          ) : null}\n        </div>\n      ) : null}\n    </div>\n  );\n}\n\n// Set on the page a full-page sign-in returns to.\nconst RETURN_PARAM = \"ph_oauth\";\n\nfunction returnedState(): string | null {\n  if (typeof window === \"undefined\") return null;\n  return new URL(window.location.href).searchParams.get(RETURN_PARAM);\n}\n\nfunction clearReturnedState(): void {\n  const url = new URL(window.location.href);\n  if (!url.searchParams.has(RETURN_PARAM)) return;\n  url.searchParams.delete(RETURN_PARAM);\n  window.history.replaceState(window.history.state, \"\", url.href);\n}\n\nfunction CopyField(props: { label: string; value: string; hint: string }) {\n  const [copied, setCopied] = useState(false);\n  return (\n    <div>\n      <LabelRow label={props.label} />\n      <div className=\"flex items-center gap-2\">\n        <input\n          className={`${inputClass} font-mono text-xs`}\n          readOnly\n          value={props.value}\n          onFocus={(event) => event.target.select()}\n        />\n        <IconButton\n          icon={copied ? \"check\" : \"copy\"}\n          label={`Copy ${props.label.toLowerCase()}`}\n          onClick={() => {\n            void navigator.clipboard.writeText(props.value).then(() => {\n              setCopied(true);\n              setTimeout(() => setCopied(false), 1500);\n            });\n          }}\n        />\n      </div>\n      <HintText text={props.hint} />\n    </div>\n  );\n}\n\n// Signs in through the provider in a popup; the switchboard exchanges the\n// code and stores the token, and this polls until it has.\nfunction OAuthConnect(props: {\n  connectionId: string | undefined;\n  state: ConnectionState;\n  ready: boolean;\n}) {\n  const { connectionId, state } = props;\n  const actions = useRuntimeActions();\n  const redirect = useOAuthRedirectUri();\n  const [attemptState, setAttemptState] = useState<string | null>(\n    returnedState,\n  );\n  const [error, setError] = useState<string | null>(null);\n  const [starting, setStarting] = useState(false);\n  const popup = useRef<Window | null>(null);\n  const polled = useOAuthAttempt(attemptState);\n  // A returned sign-in may be another connection's; that one's editor takes it.\n  const ours = polled != null && polled.connectionId === connectionId;\n  const attempt = ours ? polled : null;\n  const dropped = polled === null || (polled !== undefined && !ours);\n  const finished =\n    dropped || attempt?.status === \"OK\" || attempt?.status === \"ERROR\";\n\n  useEffect(() => {\n    if (ours || polled === null) clearReturnedState();\n  }, [ours, polled]);\n\n  useEffect(() => {\n    if (!finished) return;\n    popup.current?.close();\n    popup.current = null;\n  }, [finished]);\n\n  const signedIn = state.secretRefs.some((ref) => ref.name === OAUTH_TOKEN);\n  const redirectUri = redirect.data ?? undefined;\n  const waiting = attemptState !== null && !finished;\n\n  const connect = () => {\n    if (!connectionId || starting) return;\n    setError(null);\n    setStarting(true);\n    // Opened on the click itself, or a popup blocker refuses it.\n    const opened = window.open(\n      \"about:blank\",\n      \"ph-oauth\",\n      \"popup,width=520,height=700\",\n    );\n    popup.current = opened;\n    actions\n      .startOAuth(connectionId, {\n        redirectUri,\n        // Blocked: the whole page goes, and comes back here afterwards.\n        ...(opened ? {} : { returnUrl: window.location.href }),\n      })\n      .then((started) => {\n        if (opened) {\n          opened.location.href = started.authorizationUrl;\n          setAttemptState(started.state);\n        } else {\n          window.location.assign(started.authorizationUrl);\n        }\n      })\n      .catch((startError: unknown) => {\n        opened?.close();\n        popup.current = null;\n        setError(\n          startError instanceof Error ? startError.message : String(startError),\n        );\n      })\n      .finally(() => setStarting(false));\n  };\n\n  const cancel = () => {\n    popup.current?.close();\n    popup.current = null;\n    setAttemptState(null);\n  };\n\n  return (\n    <div className=\"flex flex-col gap-5 border-t border-solid border-foreground/10 pt-5\">\n      <div>\n        <h3 className=\"text-[13px] font-semibold text-foreground\">Sign in</h3>\n        <p className=\"mt-0.5 text-xs text-muted-foreground\">\n          Uses your own OAuth app. Register the redirect URL below with it, fill\n          in its client ID and secret, then connect.\n        </p>\n      </div>\n      {redirect.data ? (\n        <CopyField\n          label=\"Redirect URL\"\n          value={redirect.data}\n          hint=\"Add this as an authorized redirect URI in the service's developer console.\"\n        />\n      ) : redirect.data === null ? (\n        <p className=\"rounded-md bg-wf-warn/10 px-3 py-2 text-xs text-wf-warn\">\n          This switchboard serves no OAuth callback, so it cannot sign in.\n        </p>\n      ) : null}\n      <div className=\"flex items-center gap-3\">\n        <Button\n          variant={signedIn ? \"secondary\" : \"primary\"}\n          disabled={\n            !connectionId || !props.ready || starting || waiting || !redirectUri\n          }\n          onClick={connect}\n        >\n          {starting\n            ? \"Opening…\"\n            : waiting\n              ? \"Waiting for sign-in…\"\n              : signedIn\n                ? \"Reconnect\"\n                : \"Connect\"}\n        </Button>\n        {waiting ? (\n          <Button variant=\"ghost\" onClick={cancel}>\n            Cancel\n          </Button>\n        ) : null}\n        <span className=\"text-xs text-muted-foreground\">\n          {attempt?.status === \"OK\"\n            ? `Signed in${state.accountLabel ? ` as ${state.accountLabel}` : \"\"}`\n            : signedIn && !waiting\n              ? state.accountLabel\n                ? `Signed in as ${state.accountLabel}`\n                : \"Signed in\"\n              : !connectionId\n                ? \"Open the connection to sign in.\"\n                : !props.ready\n                  ? \"Fill in the client ID and secret first.\"\n                  : \"\"}\n        </span>\n      </div>\n      <FieldError>\n        {error ?? (attempt?.status === \"ERROR\" ? attempt.error : null)}\n      </FieldError>\n    </div>\n  );\n}\n\n// A method's own name, unless it's the generic \"Connection\" OAuth2 uses.\nfunction methodLabel(plan: AuthPlan): string {\n  return plan.displayName && plan.displayName !== \"Connection\"\n    ? plan.displayName\n    : AUTH_TYPE_LABEL[plan.authType];\n}\n\nexport function ConnectionForm(props: {\n  state: ConnectionState;\n  callbacks: ConnectionCallbacks;\n  // Needed to sign an OAuth2 connection in.\n  connectionId?: string;\n}) {\n  const { state, callbacks } = props;\n  const catalogQuery = usePieceCatalog();\n  const catalog = catalogQuery.data ?? (catalogQuery.isError ? [] : null);\n\n  const packageName = packageFromConnectorId(state.connectorId);\n  const piece = catalog?.find((entry) => entry.name === packageName);\n  // Descriptor plan when the piece is known; otherwise reconstruct enough\n  // from state so existing refs stay editable.\n  const plans = piece ? plansFromAuth(piece.auth) : [];\n  const plan: AuthPlan = piece\n    ? planForConnection(piece.auth, state.authType)\n    : {\n        authType: state.authType,\n        configFields: [],\n        secretFields: state.secretRefs.map((ref) => ({\n          name: ref.name,\n          displayName: ref.name,\n          required: false,\n        })),\n        supported: state.authType !== \"OIDC\",\n      };\n\n  const config = (state.config ?? {}) as Record<string, unknown>;\n  const refByName = new Map(state.secretRefs.map((ref) => [ref.name, ref.ref]));\n\n  // Recomputed on every edit: promotes UNCONFIGURED to OK, and demotes back\n  // when a required field is cleared. REVOKED/ERROR are left alone.\n  const maybeMarkConfigured = (\n    nextConfig: Record<string, unknown>,\n    nextRefs: Map<string, string>,\n  ) => {\n    // An OAuth2 connection is ready once signed in, which the switchboard records.\n    if (!plan.supported || plan.oauth2) return;\n    const complete = isAuthComplete(plan, nextConfig, nextRefs);\n    if (complete && state.status === \"UNCONFIGURED\") {\n      callbacks.setStatus(\"OK\");\n    } else if (!complete && state.status === \"OK\") {\n      callbacks.setStatus(\"UNCONFIGURED\");\n    }\n  };\n\n  return (\n    <div className=\"flex flex-col gap-6\">\n      <div>\n        <LabelRow label=\"Service\" />\n        <Select\n          value={packageName}\n          loading={catalog === null}\n          placeholder=\"Choose the service to connect\"\n          options={(catalog ?? []).map((entry) => ({\n            value: entry.name,\n            label: entry.displayName,\n            // Its only sign-in method is one this runtime can't store.\n            ...(planFromAuth(entry.auth).authType === UNKNOWN_AUTH\n              ? { disabled: true, description: AUTH_TYPE_LABEL[UNKNOWN_AUTH] }\n              : { description: entry.description }),\n            icon: entry.logoUrl ? (\n              <img\n                src={entry.logoUrl}\n                alt=\"\"\n                loading=\"lazy\"\n                className=\"h-4 w-4 shrink-0 object-contain\"\n              />\n            ) : undefined,\n          }))}\n          onChange={(name) => {\n            const picked = catalog?.find((entry) => entry.name === name);\n            if (picked) callbacks.pickPiece(picked);\n          }}\n        />\n        {piece ? <HintText text={piece.description} /> : null}\n      </div>\n\n      {plans.length > 1 ? (\n        <div>\n          <LabelRow label=\"Sign in with\" />\n          <Select\n            value={plan.authType}\n            options={plans.map((option) => ({\n              value: option.authType,\n              label: methodLabel(option),\n              description:\n                option.supported || option.authType === UNKNOWN_AUTH\n                  ? AUTH_TYPE_LABEL[option.authType]\n                  : \"Not supported yet\",\n              disabled: !option.supported,\n            }))}\n            onChange={(value) => {\n              const authType = value as ConnectionAuthType;\n              const next = plans.find((option) => option.authType === authType);\n              if (!next) return;\n              callbacks.setAuthType(authType, {\n                config: next.configFields.map((field) => field.name),\n                secrets: next.secretFields.map((field) => field.name),\n              });\n              // Switching resets the status; a method already filled in is ready.\n              if (isAuthComplete(next, config, refByName)) {\n                callbacks.setStatus(\"OK\");\n              }\n            }}\n          />\n          {plan.description ? <HintText text={plan.description} /> : null}\n        </div>\n      ) : null}\n\n      {plan.supported ? null : (\n        <p className=\"rounded-md bg-wf-warn/10 px-3 py-2 text-xs text-wf-warn\">\n          {plan.authType === UNKNOWN_AUTH\n            ? `${plan.declaredType ?? \"This sign-in method\"}: not supported by this runtime.`\n            : `${plan.authType} connections are not executable by the workflow runtime yet.`}\n        </p>\n      )}\n\n      {plan.configFields.length > 0 ? (\n        <div className=\"flex flex-col gap-5 border-t border-solid border-foreground/10 pt-5\">\n          <h3 className=\"text-[13px] font-semibold text-foreground\">\n            Configuration\n          </h3>\n          {plan.configFields.map((field) => (\n            <ConfigField\n              key={field.name}\n              field={field}\n              value={config[field.name]}\n              onCommit={(value) => {\n                callbacks.setConfigValue(field.name, value);\n                maybeMarkConfigured(\n                  { ...config, [field.name]: value },\n                  refByName,\n                );\n              }}\n            />\n          ))}\n        </div>\n      ) : null}\n\n      {plan.secretFields.length > 0 ? (\n        <div className=\"flex flex-col gap-5 border-t border-solid border-foreground/10 pt-5\">\n          <div>\n            <h3 className=\"text-[13px] font-semibold text-foreground\">\n              Credentials\n            </h3>\n            <p className=\"mt-0.5 text-xs text-muted-foreground\">\n              Saved encrypted on the switchboard. This connection only keeps a\n              reference, so nobody reading it can see the values.\n            </p>\n          </div>\n          {plan.secretFields.map((field) => (\n            <SecretField\n              key={field.name}\n              field={field}\n              connectionName={state.name}\n              refValue={refByName.get(field.name) ?? \"\"}\n              onCommit={(ref) => {\n                callbacks.setSecretRef(field.name, ref);\n                const nextRefs = new Map(refByName);\n                nextRefs.set(field.name, ref);\n                maybeMarkConfigured(config, nextRefs);\n              }}\n              onRemove={() => {\n                callbacks.removeSecretRef(field.name);\n                const nextRefs = new Map(refByName);\n                nextRefs.delete(field.name);\n                maybeMarkConfigured(config, nextRefs);\n              }}\n            />\n          ))}\n        </div>\n      ) : null}\n\n      {plan.oauth2 && plan.supported ? (\n        <OAuthConnect\n          connectionId={props.connectionId}\n          state={state}\n          ready={isAuthComplete(plan, config, refByName)}\n        />\n      ) : null}\n\n      {state.lastError ? (\n        <p className=\"rounded-md bg-wf-fail/10 px-3 py-2 text-xs text-wf-fail\">\n          {state.lastError}\n        </p>\n      ) : null}\n    </div>\n  );\n}\n"],"mappings":";;;;;;;;;AA6BA,MAAM,eAAe;AAErB,SAAgB,eAAuB;CACrC,OAAOA,aAAW;AACpB;AAEA,SAAgB,cAAgC,QAAW,OAAkB;CAC3E,OAAO;EAAE,GAAG;EAAQ,IAAI,GAAG,eAAe,MAAM,GAAGA,aAAW;CAAI;AACpE;AAEA,SAAgB,YAAY,QAAoC;CAC9D,IAAI,CAAC,OAAO,GAAG,WAAW,YAAY,GAAG,OAAO,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