import { c as _c } from "react/compiler-runtime";
import React, { useEffect, useState } from 'react';
import { Box, Link, Text } from '../ink.js';
import { type AwsAuthStatus, AwsAuthStatusManager } from '../utils/awsAuthStatusManager.js';
const URL_RE = /https?:\/\/\S+/;
export function AwsAuthStatusBox() {
  const $ = _c(11);
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = AwsAuthStatusManager.getInstance().getStatus();
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  const [status, setStatus] = useState(t0);
  let t1;
  let t2;
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = () => {
      const unsubscribe = AwsAuthStatusManager.getInstance().subscribe(setStatus);
      return unsubscribe;
    };
    t2 = [];
    $[1] = t1;
    $[2] = t2;
  } else {
    t1 = $[1];
    t2 = $[2];
  }
  useEffect(t1, t2);
  if (!status.isAuthenticating && !status.error && status.output.length === 0) {
    return null;
  }
  if (!status.isAuthenticating && !status.error) {
    return null;
  }
  let t3;
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
    t3 = <Text bold={true} color="permission">Cloud Authentication</Text>;
    $[3] = t3;
  } else {
    t3 = $[3];
  }
  let t4;
  if ($[4] !== status.output) {
    t4 = status.output.length > 0 && <Box flexDirection="column" marginTop={1}>{status.output.slice(-5).map(_temp)}</Box>;
    $[4] = status.output;
    $[5] = t4;
  } else {
    t4 = $[5];
  }
  let t5;
  if ($[6] !== status.error) {
    t5 = status.error && <Box marginTop={1}><Text color="error">{status.error}</Text></Box>;
    $[6] = status.error;
    $[7] = t5;
  } else {
    t5 = $[7];
  }
  let t6;
  if ($[8] !== t4 || $[9] !== t5) {
    t6 = <Box flexDirection="column" borderStyle="round" borderColor="permission" paddingX={1} marginY={1}>{t3}{t4}{t5}</Box>;
    $[8] = t4;
    $[9] = t5;
    $[10] = t6;
  } else {
    t6 = $[10];
  }
  return t6;
}
function _temp(line, index) {
  const m = line.match(URL_RE);
  if (!m) {
    return <Text key={index} dimColor={true}>{line}</Text>;
  }
  const url = m[0];
  const start = m.index ?? 0;
  const before = line.slice(0, start);
  const after = line.slice(start + url.length);
  return <Text key={index} dimColor={true}>{before}<Link url={url}>{url}</Link>{after}</Text>;
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJSZWFjdCIsInVzZUVmZmVjdCIsInVzZVN0YXRlIiwiQm94IiwiTGluayIsIlRleHQiLCJBd3NBdXRoU3RhdHVzIiwiQXdzQXV0aFN0YXR1c01hbmFnZXIiLCJVUkxfUkUiLCJBd3NBdXRoU3RhdHVzQm94IiwiJCIsIl9jIiwidDAiLCJTeW1ib2wiLCJmb3IiLCJnZXRJbnN0YW5jZSIsImdldFN0YXR1cyIsInN0YXR1cyIsInNldFN0YXR1cyIsInQxIiwidDIiLCJ1bnN1YnNjcmliZSIsInN1YnNjcmliZSIsImlzQXV0aGVudGljYXRpbmciLCJlcnJvciIsIm91dHB1dCIsImxlbmd0aCIsInQzIiwidDQiLCJzbGljZSIsIm1hcCIsIl90ZW1wIiwidDUiLCJ0NiIsImxpbmUiLCJpbmRleCIsIm0iLCJtYXRjaCIsInVybCIsInN0YXJ0IiwiYmVmb3JlIiwiYWZ0ZXIiXSwic291cmNlcyI6WyJBd3NBdXRoU3RhdHVzQm94LnRzeCJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgUmVhY3QsIHsgdXNlRWZmZWN0LCB1c2VTdGF0ZSB9IGZyb20gJ3JlYWN0J1xuaW1wb3J0IHsgQm94LCBMaW5rLCBUZXh0IH0gZnJvbSAnLi4vaW5rLmpzJ1xuaW1wb3J0IHtcbiAgdHlwZSBBd3NBdXRoU3RhdHVzLFxuICBBd3NBdXRoU3RhdHVzTWFuYWdlcixcbn0gZnJvbSAnLi4vdXRpbHMvYXdzQXV0aFN0YXR1c01hbmFnZXIuanMnXG5cbmNvbnN0IFVSTF9SRSA9IC9odHRwcz86XFwvXFwvXFxTKy9cblxuZXhwb3J0IGZ1b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+XG4gICAgICA8VGV4dCBib2xkIGNvbG9yPVwicGVybWlzc2lvblwiPlxuICAgICAgICBDbG91ZCBBdXRoZW50aWNhdGlvblxuICAgICAgPC9UZXh0PlxuXG4gICAgICB7c3RhdHVzLm91dHB1dC5sZW5ndGggPiAwICYmIChcbiAgICAgICAgPEJveCBmbGV4RGlyZWN0aW9uPVwiY29sdW1uXCIgbWFyZ2luVG9wPXsxfT5cbiAgICAgICAgICB7c3RhdHVzLm91dHB1dC5zbGljZSgtNSkubWFwKChsaW5lLCBpbmRleCkgPT4ge1xuICAgICAgICAgICAgY29uc3QgbSA9IGxpbmUubWF0Y2goVVJMX1JFKVxuICAgICAgICAgICAgaWYgKCFtKSB7XG4gICAgICAgICAgICAgIHJldHVybiAoXG4gICAgICAgICAgICAgICAgPFRleHQga2V5PXtpbmRleH0gZGltQ29sb3I+XG4gICAgICAgICAgICAgICAgICB7bGluZX1cbiAgICAgICAgICAgICAgICA8L1RleHQ+XG4gICAgICAgICAgICAgIClcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbnN0IHVybCA9IG1bMF1cbiAgICAgICAgICAgIGNvbnN0IHN0YXJ0ID0gbS5pbmRleCA/PyAwXG4gICAgICAgICAgICBjb25zdCBiZWZvcmUgPSBsaW5lLnNsaWNlKDAsIHN0YXJ0KVxuICAgICAgICAgICAgY29uc3QgYWZ0ZXIgPSBsaW5lLnNsaWNlKHN0YXJ0ICsgdXJsLmxlbmd0aClcbiAgICAgICAgICAgIHJldHVybiAoXG4gICAgICAgICAgICAgIDxUZXh0IGtleT17aW5kZXh9IGRpbUNvbG9yPlxuICAgICAgICAgICAgICAgIHtiZWZvcmV9XG4gICAgICAgICAgICAgICAgPExpbmsgdXJsPXt1cmx9Pnt1cmx9PC9MaW5rPlxuICAgICAgICAgICAgICAgIHthZnRlcn1cbiAgICAgICAgICAgICAgPC9UZXh0PlxuICAgICAgICAgICAgKVxuICAgICAgICAgIH0pfVxuICAgICAgICA8L0JveD5cbiA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