import { d as M, ag as Y, r as d, U as q, V as N, o as l, c as o, a as t, x as E, t as c, W as A, b as G, F as R, e as F, n as H, f as v, k as P, p as S, q as z, v as I, _ as K } from "./main-b2186337.mjs";
import { _ as C } from "./loadernew-ac153a51.mjs";
import { D as O } from "./Header-72db5d07.mjs";
import { c as W, u as j } from "./delphi_utils-11f1be37.mjs";
import "./genome-Logo-white-ffcf2413.mjs";
import "./PopupComponent-31cc3623.mjs";
import "./Close-button-48e5479d.mjs";
import "./index-169cd149.mjs";
const J = {
  key: 0,
  class: "flex h-screen flex-col"
}, Q = { class: "flex" }, X = {
  key: 0,
  class: "genpact-blue-box mt-14 flex flex-1 overflow-hidden"
}, Z = { class: "mx-auto md:w-11/12 lg:w-11/12 overflow-y-auto" }, ee = { class: "bot-start bg-gray-100 min-h-screen px-4 py-6 md:px-8 md:py-12 lg:px-8 lg:py-12" }, te = { class: "mt-4 w-full flex" }, se = { class: "text-left text-3xl text-background-secondary w-full" }, ae = { class: "mt-4 w-full" }, le = { class: "text-left text-background-secondary" }, oe = { class: "mt-4 w-full" }, ue = { class: "text-left text-background-secondary" }, ne = { class: "mt-4 w-full" }, re = { class: "text-left text-background-secondary" }, de = { class: "mt-4 w-full" }, ie = { class: "text-left text-background-secondary" }, ce = { class: "mt-4 w-full" }, pe = {
  key: 0,
  class: "bot-text text-row-bg relative w-full max-w-3xl md:w-auto lg:w-auto"
}, ve = { class: "border border-gray-400 px-3 py-2 flex items-center" }, me = { class: "w-auto" }, _e = ["for"], fe = ["disabled", "onChange"], xe = { key: 0 }, ge = { class: "text-red-900 text-[15px]" }, be = { key: 1 }, ye = { class: "-text-blue text-[15px]" }, he = { class: "pl-2" }, ke = ["disabled", "onClick"], we = { key: 1 }, $e = ["id", "onUpdate:modelValue"], Re = ["disabled"], Ce = {
  key: 1,
  class: "w-10",
  src: C,
  alt: "Loader Gif"
}, Ee = { key: 0 }, Fe = { class: "text-red-900" }, Pe = {
  key: 1,
  class: "border border-gray-400 mt-4 p-2 w-full"
}, Se = ["innerHTML"], De = {
  key: 0,
  class: "w-10",
  src: C,
  alt: "Loader Gif"
}, Le = ["disabled"], Be = {
  key: 1,
  class: "flex h-screen flex-col"
}, Te = {
  key: 1,
  class: "h-min-screen flex flex-col justify-center text-center"
}, Ue = /* @__PURE__ */ M({
  __name: "PromptDetails",
  setup(Ve) {
    const h = Y(), k = d(!1), w = d(), u = d(), $ = d(!1), s = d(), g = d(!0), b = d(), i = d(""), p = d(), _ = d(), m = d(!1), y = d(!0), D = async () => {
      try {
        const a = await P(`/delphi/prompt/${w.value}`);
        u.value = a && a.data.data ? a.data.data : [], $.value = !0;
      } catch (a) {
        $.value = !0, console.log("Error in fetching all prompts", { message: a.message });
      }
    }, L = (a, e) => {
      s.value || (s.value = {}), s.value[`uploadResume-${e}`] = { value: a.target.files[0], error_message: "", success_message: "", afterResumeuploaded: !1 }, console.log("event", a.target.files[0]), console.log("uploadedFile.value", s.value);
    }, B = async (a) => {
      const e = `uploadResume-${a}`;
      if (console.log(`input_name ${e}`), console.log("uploadedFiles.value", { val: s.value }), console.log(`uploadedFiles.value || (uploadedFiles.value && !uploadedFiles.value[input_name].value) ${!s.value || s.value && !s.value[e] || s.value && s.value[e] && !s.value[e].value}`), !s.value || s.value && !s.value[e] || s.value && s.value[e] && !s.value[e].value)
        s.value || (s.value = {}), s.value[e] ? s.value[e].error_message = "Please Select valid file to upload" : s.value[e] = {
          value: null,
          error_message: "Please Select valid file to upload",
          success_message: "",
          afterResumeuploaded: !1
        }, setTimeout(() => {
          s.value[e].error_message = null;
        }, 6e3);
      else {
        const f = await S("/delphi/signed_url", {
          file_name: s.value[e].value.name
        });
        console.log("preSignedRes", f);
        const n = f.data.messsage.url, r = f.data.messsage.file_key;
        console.log("preSignedUrl", n), console.log("fileKey", r), (await j(n, s.value[e].value)).status === 200 && (s.value[e].success_message = "Resume has been uploaded successfully", setTimeout(() => {
          s.value[e].success_message = null;
        }, 6e3), s.value[e].afterResumeuploaded = !0, u.value.input_parameters[a].parameter_value = r, console.log("prompt_details.value", { data: u.value }));
      }
    }, T = async () => {
      for (let a = 0; a < u.value.input_parameters.length; a++) {
        const e = u.value.input_parameters[a];
        console.log("input_params", { input_params: e }), console.log("input_params.is_mandatory", { value: e.is_mandatory }), console.log("input_params.parameter_value", { value: e.parameter_value }), console.log(`input_params.is_mandatory && !input_params.parameter_value, ${e.is_mandatory && !e.parameter_value}`), e.is_mandatory && !e.parameter_value && (g.value = g.value && !1);
      }
    }, U = async () => {
      try {
        if (y.value = !1, u.value.input_parameters && u.value.input_parameters.length && await T(), console.log(`is_mandatory_completed ${g.value}`), !g.value) {
          y.value = !0, b.value = "All mandatory inputs are not completed", setTimeout(() => {
            b.value = null;
          }, 6e3);
          return;
        }
        const { data: a } = await S("/delphi/prompt/execution", {
          prompt_id: w.value,
          input_params: u.value.input_parameters,
          linked_app_id: "cdbb9123e5688d6b71541d537418bc24da8e95e9896ce9898b97bbf391fdb8c0"
        });
        console.log("res", { data: a }), console.log("data", { val: a.data }), y.value = !0, i.value = a.data, _.value = `You execution id is "${i.value}" and status is <span class="font-bold">in progress</span>`;
      } catch (a) {
        m.value = !1, console.log("Error in executing prompt", { message: a.message });
      }
    }, V = async () => {
      try {
        m.value = !0;
        const { data: a } = await P(`/delphi/prompt/execution/status/${i.value}`);
        p.value = a && a.data ? a.data : [], m.value = !1, p.value.execution_status === "success" ? _.value = `<div>You execution id is "${i.value}" and status is <span class="font-bold">${p.value.execution_status}</span></div><div><span class="font-bold">Execution Output: </span>${p.value.execution_ouput}</div>` : p.value.execution_status === "failed" ? _.value = `<div>You execution id is "${i.value}" and status is <span class="font-bold">${p.value.execution_status}</span></div><div><span>Execution Error: </span>${p.value.execution_error}</div>` : _.value = `You execution id is "${i.value}" and status is <span class="font-bold">${p.value.execution_status}</span>`;
      } catch (a) {
        m.value = !1, console.log("Error in fetching execution status", { message: a.message });
      }
    };
    return q(async () => {
      w.value = h.query && h.query.prompt_id ? h.query.prompt_id : null, k.value = await W(), k.value && await D();
    }), (a, e) => {
      const f = N("router-link");
      return $.value ? (l(), o(R, { key: 0 }, [
        k.value ? (l(), o("div", J, [
          t("nav", Q, [
            E(O)
          ]),
          u.value ? (l(), o("section", X, [
            t("div", Z, [
              t("div", ee, [
                t("div", te, [
                  t("div", se, c(u.value.prompt_display_name), 1),
                  E(f, {
                    to: { name: "Prompt" },
                    class: "bg-background-secondary inline-block mr-4 px-4 py-2 text-white w-1/6"
                  }, {
                    default: A(() => e[2] || (e[2] = [
                      G(" Back to Prompt Lists ")
                    ])),
                    _: 1,
                    __: [2]
                  })
                ]),
                t("div", ae, [
                  e[3] || (e[3] = t("div", { class: "text-left font-bold text-background-secondary" }, "Persona", -1)),
                  t("div", le, c(u.value.persona), 1)
                ]),
                t("div", oe, [
                  e[4] || (e[4] = t("div", { class: "text-left font-bold text-background-secondary" }, "Intent", -1)),
                  t("div", ue, c(u.value.intent), 1)
                ]),
                t("div", ne, [
                  e[5] || (e[5] = t("div", { class: "text-left font-bold text-background-secondary" }, "Description", -1)),
                  t("div", re, c(u.value.desc), 1)
                ]),
                t("div", de, [
                  e[6] || (e[6] = t("div", { class: "text-left font-bold text-background-secondary" }, "Rules", -1)),
                  t("ul", ie, [
                    (l(!0), o(R, null, F(u.value.rules, (n, r) => (l(), o("li", { key: r }, c(n), 1))), 128))
                  ])
                ]),
                t("div", ce, [
                  (l(!0), o(R, null, F(u.value.input_parameters, (n, r) => (l(), o("div", {
                    key: n.parameter_name,
                    class: "text-left font-bold text-background-secondary"
                  }, [
                    t("div", null, c(n.display_name), 1),
                    n.parameter_type === "file" ? (l(), o("div", pe, [
                      t("div", ve, [
                        t("div", me, [
                          e[7] || (e[7] = t("div", { class: "-text-blue py-1.5" }, "Upload resume here", -1)),
                          t("label", {
                            for: `uploadResume-${r}`,
                            class: "pointer text-gray-500"
                          }, [
                            t("input", {
                              disabled: s.value && s.value[`uploadResume-${r}`].afterResumeuploaded,
                              type: "file",
                              accept: ".pdf,.docx,.doc,.txt",
                              onChange: (x) => L(x, r)
                            }, null, 40, fe)
                          ], 8, _e),
                          e[8] || (e[8] = t("div", { class: "mt-1 flex" }, [
                            t("div", { class: "-text-blue text-[15px]" }, "File size max 5 MB"),
                            t("div", { class: "pl-6 text-[15px]" }, "File types .pdf/ .docx/.doc/.txt")
                          ], -1)),
                          s.value && s.value[`uploadResume-${r}`].error_message ? (l(), o("div", xe, [
                            t("span", ge, c(s.value[`uploadResume-${r}`].error_message), 1)
                          ])) : v("", !0),
                          s.value && s.value[`uploadResume-${r}`].success_message ? (l(), o("div", be, [
                            t("span", ye, c(s.value[`uploadResume-${r}`].success_message), 1)
                          ])) : v("", !0)
                        ]),
                        t("div", he, [
                          t("button", {
                            disabled: s.value && s.value[`uploadResume-${r}`].afterResumeuploaded,
                            class: "-border-blue-1 -bg-blue inline-block rounded px-6 py-1.5 text-white",
                            onClick: (x) => B(r)
                          }, "Upload", 8, ke)
                        ])
                      ])
                    ])) : v("", !0),
                    n.parameter_type === "text" ? (l(), o("div", we, [
                      z(t("textarea", {
                        id: n.parameter_name,
                        "onUpdate:modelValue": (x) => n.parameter_value = x,
                        class: "m-0 w-full border border-solid border-gray-300 bg-white bg-clip-padding px-3 py-1.5 text-gray-700 ease-in-out focus:border-blue-600 focus:bg-white focus:text-gray-700 focus:outline-none",
                        rows: "3"
                      }, null, 8, $e), [
                        [I, n.parameter_value]
                      ])
                    ])) : v("", !0)
                  ]))), 128))
                ]),
                t("div", {
                  class: "mt-4 w-full",
                  disabled: i.value
                }, [
                  y.value ? (l(), o("button", {
                    key: 0,
                    class: H(["mr-4 mt-4 inline-block px-4 py-2 text-white", i.value ? "bg-gray-500 cursor-not-allowed" : "bg-background-secondary cursor-pointer"]),
                    onClick: e[0] || (e[0] = (n) => U())
                  }, "Start Execution", 2)) : (l(), o("img", Ce))
                ], 8, Re),
                b.value ? (l(), o("div", Ee, [
                  t("span", Fe, c(b.value), 1)
                ])) : v("", !0),
                i.value ? (l(), o("div", Pe, [
                  e[9] || (e[9] = t("div", { class: "font-bold" }, "Execution Status", -1)),
                  t("div", { innerHTML: _.value }, null, 8, Se),
                  t("div", null, [
                    m.value ? (l(), o("img", De)) : (l(), o("button", {
                      key: 1,
                      disabled: m.value,
                      class: "mr-4 mt-4 inline-block bg-background-secondary px-4 py-2 text-white",
                      onClick: e[1] || (e[1] = (n) => V())
                    }, " Check Status ", 8, Le))
                  ])
                ])) : v("", !0)
              ])
            ])
          ])) : v("", !0)
        ])) : (l(), o("div", Be, "You don't have access"))
      ], 64)) : (l(), o("div", Te, e[10] || (e[10] = [
        t("img", {
          class: "loadercss mx-auto mb-8 mt-3% block",
          src: C,
          alt: "Loader Gif"
        }, null, -1),
        t("p", { class: "loadertextcss ext-genpact-darkest-blue mx-auto mb-10 px-4 leading-normal" }, "Loading...", -1)
      ])));
    };
  }
});
const Ie = /* @__PURE__ */ K(Ue, [["__scopeId", "data-v-3b2826d5"]]);
export {
  Ie as default
};
