import { jsxs as r, jsx as e } from "react/jsx-runtime";
import { mb2 as j } from "./index-general.module.js";
import { uuidv4 as v } from "./index-generate-uid.js";
import { AIAssistantPanel as b } from "./index-AIAssistantPanel.js";
import { Button as i, ButtonTypes as a } from "./index-Button.js";
import { ComponentContainer as x } from "./index-ComponentContainer.js";
import { IconNames as l } from "./index-IconNames.js";
import { Render as c } from "./index-Render.js";
import "react";
import { useAiAssistantAdjustAndGenerate as B } from "./index-useAiAssistant-GenerateAndAdjust.js";
const $ = (s) => {
  const {
    id: d = `AIAssistant_${v()}`,
    children: A,
    generateBtnText: p,
    className: C,
    value: o,
    setValue: h,
    anchorElem: m,
    needsCommandOnGenerate: k,
    disabled: u
  } = s, {
    panelStatus: t,
    setPanelStatus: n,
    generateError: I,
    onGenerateClick: f,
    onAdjustClick: y
  } = B(s), G = () => {
    if (k) {
      n("needsCommand");
      return;
    }
    f();
  };
  return r(x, {
    id: d,
    testId: `${d}_TestID`,
    className: C,
    children: [r("div", {
      className: j,
      children: [e(c, {
        if: t === "closed" && o == "",
        children: e(i, {
          type: a.secondary,
          iconLeft: l.ai,
          onClick: G,
          disabled: u,
          children: p ?? "Generate"
        })
      }), e(c, {
        if: t === "closed" && o != "",
        children: e(i, {
          type: a.secondary,
          iconLeft: l.ai,
          onClick: () => {
            n("open");
          },
          disabled: u,
          children: "Use AI Assistant"
        })
      }), e(c, {
        if: t !== "closed",
        children: e(i, {
          type: a.secondary,
          iconLeft: l.ai,
          onClick: () => {
            n("closed");
          },
          children: "Close AI Assistant"
        })
      })]
    }), r("div", {
      children: [A, m && e(b, {
        ...s,
        anchorElem: m,
        status: t,
        setStatus: n,
        useHtml: !0,
        //
        onGenerateClick: f,
        generateError: I,
        onAdjustClick: y,
        //
        value: o,
        setValue: h
      })]
    })]
  });
};
export {
  $ as AIAssistant
};
