{"version":3,"sources":["../src/cli/utils/spinnerError.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport type { Ora } from \"ora\";\nimport { formatApiErrorMessage } from \"@/client-sdk/services/_shared/format-api-error\";\n\n/**\n * Collapses the `spinner.fail(); console.error(...)` pattern into a single\n * call. A bare `spinner.fail()` leaves the spinner's starting text\n * (\"Fetching X...\") on screen with a red X, then the real error prints\n * on a separate line — two lines that look unrelated.\n *\n * Also avoids double-prefixing when the caught error is already a service\n * layer `*ApiError` whose message starts with \"Failed to …\" (these come\n * from `formatApiErrorForOperation`).\n */\nexport function failSpinner({\n  spinner,\n  error,\n  action,\n}: {\n  spinner: Ora;\n  error: unknown;\n  /** Short description of what was being done, e.g. \"fetch agents\". */\n  action: string;\n}): void {\n  const rendered = formatApiErrorMessage({ error });\n  const message = /^failed to /i.test(rendered)\n    ? rendered\n    : `Failed to ${action}: ${rendered}`;\n  spinner.fail(chalk.red(message));\n}\n"],"mappings":";;;;;AAAA,OAAO,WAAW;AAcX,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACF,GAKS;AACP,QAAM,WAAW,sBAAsB,EAAE,MAAM,CAAC;AAChD,QAAM,UAAU,eAAe,KAAK,QAAQ,IACxC,WACA,aAAa,MAAM,KAAK,QAAQ;AACpC,UAAQ,KAAK,MAAM,IAAI,OAAO,CAAC;AACjC;","names":[]}