import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  useBiLogger
} from "./chunk-HWT3LUJJ.js";
import {
  wixCliAction,
  wixCliAppFlowFileUploadStarted,
  wixCliAppFlowStepsAnswers,
  wixCliAppFlowUploadEnded,
  wixCliAppsFlowDeploymentStatusSrc11Evid5232
} from "./chunk-TOBTRYZF.js";
import {
  require_react
} from "./chunk-TODKQSCF.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-astro-commands/src/bi-app/useWixCliAppBi.ts
init_esm_shims();
var import_react = __toESM(require_react(), 1);

// ../cli-astro-commands/src/bi-app/events.ts
init_esm_shims();
var wixCliAppBiEvents = (biLogger) => ({
  cliAction: ({
    questionKey,
    question,
    action,
    key,
    additionalInfo
  }) => {
    void biLogger.report(
      wixCliAction({
        questionKey,
        question,
        action,
        key,
        additionalInfo: JSON.stringify(additionalInfo)
      })
    );
  },
  cliStepBack: ({
    additionalInfo
  }) => {
    void biLogger.report(
      wixCliAction({
        action: "goToPreviousStep",
        key: "Esc",
        additionalInfo: JSON.stringify(additionalInfo)
      })
    );
  },
  cliFlowStepAnswered: ({
    question,
    questionKey,
    answer,
    additionalInfo
  }) => {
    void biLogger.report(
      wixCliAppFlowStepsAnswers({
        questionKey,
        question,
        answer,
        additionalInfo: JSON.stringify(additionalInfo)
      })
    );
  },
  fileUpload({
    provider,
    fileCount,
    totalSizeInKb,
    cliVersion
  }) {
    const startTimestamp = Date.now();
    void biLogger.report(
      wixCliAppFlowFileUploadStarted({
        timestampMs: startTimestamp,
        hostingProvider: provider,
        numFiles: fileCount,
        fileSizeCompressed: 0,
        fileSizeNotCompressed: totalSizeInKb,
        cliVersion
      })
    );
    return {
      finished() {
        void biLogger.report(
          wixCliAppFlowUploadEnded({
            duration: Date.now() - startTimestamp
          })
        );
      }
    };
  },
  cliDeployment: ({
    appId,
    deploymentId,
    files
  }) => {
    const startTimestamp = Date.now();
    const fileDetails = files ? files.filter((f) => f.filePath).map((file) => ({
      filePath: file.filePath,
      fileSizeKb: file.content ? file.content.length / 1024 : 0
    })) : [];
    return {
      finish: ({
        isSuccess,
        failureReason
      }) => {
        void biLogger.report(
          wixCliAppsFlowDeploymentStatusSrc11Evid5232({
            isSuccess,
            failureReason,
            filesDetails: JSON.stringify(fileDetails),
            filesSize: Math.round(
              fileDetails.reduce((acc, { fileSizeKb }) => acc + fileSizeKb, 0)
            ),
            uploadSource: "backend",
            appId,
            deploymentId,
            filesUploadTime: Date.now() - startTimestamp
          })
        );
      }
    };
  }
});

// ../cli-astro-commands/src/bi-app/useWixCliAppBi.ts
function useWixCliAppBi() {
  const biLogger = useBiLogger();
  return (0, import_react.useMemo)(() => wixCliAppBiEvents(biLogger), [biLogger]);
}

// ../cli-astro-commands/src/bi-app/index.ts
init_esm_shims();

export {
  useWixCliAppBi
};
//# sourceMappingURL=chunk-RDXUYCUV.js.map