(function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode(`.pl-log-view{--log-background: var(--bg-base-light);--contour-color: var(--txt-01);--contour-border-width: 1px;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--border-color-log-view: var(--border-color-div-grey);height:100%;max-height:calc(100% - var(--contour-offset));max-width:calc(100% - var(--contour-offset));border-radius:6px;background:var(--log-background);display:flex;position:relative;min-height:44px;padding-right:40px}.pl-log-view__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--border-color-log-view);border-style:solid;box-shadow:none;z-index:0;pointer-events:none}.pl-log-view label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-log-view label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-log-view.has-error{--log-background: linear-gradient(90deg, #FFEBEB 0%, #FFFFFF 100%);--border-color-log-view: var(--border-color-error)}.pl-log-view__copy{position:absolute;top:12px;right:12px;cursor:pointer;--icon-color: var(--ic-02)}.pl-log-view__copy>*:hover{--icon-color: var(--txt-01)}.pl-log-view__content{margin:12px;max-height:100%;max-width:100%;flex:1;color:var(--txt-01);font-feature-settings:"ss11" on,"ss15" on,"ss17" on;font-family:var(--font-family-monospace);white-space:pre;font-size:14px;font-weight:400;line-height:20px;--thumb-color: var(--ic-02);overflow-y:auto;overflow-x:auto}.pl-log-view__content::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-log-view__content::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-log-view__content::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}.pl-log-view__error{margin:12px;max-height:100%;max-width:100%;flex:1;color:var(--txt-01);font-feature-settings:"ss11" on,"ss15" on,"ss17" on;font-family:var(--font-family-monospace);white-space:pre;font-size:14px;font-weight:400;line-height:20px;--thumb-color: var(--ic-02);overflow-y:auto;overflow-x:auto}.pl-log-view__error::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-log-view__error::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-log-view__error::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}
.double-contour.top>div{border-bottom-right-radius:0;border-bottom-left-radius:0}.double-contour.bottom>div{border-top-right-radius:0;border-top-left-radius:0}.double-contour.left>div{border-top-right-radius:0;border-bottom-right-radius:0}.double-contour.right>div{border-top-left-radius:0;border-bottom-left-radius:0}.double-contour.top-left>div{border-top-right-radius:0;border-bottom-left-radius:0;border-bottom-right-radius:0}.double-contour.top-right>div{border-bottom-right-radius:0;border-top-left-radius:0;border-top-right-radius:0}.double-contour.bottom-left>div{border-top-right-radius:0;border-bottom-right-radius:0;border-top-left-radius:0}.double-contour.bottom-right>div{border-top-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:0}.double-contour.middle>div{border-radius:0}`)),document.head.appendChild(o)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
import { defineComponent as E, useSlots as F, ref as c, computed as u, watch as L, createElementBlock as p, openBlock as l, normalizeClass as P, createCommentVNode as v, createVNode as d, createElementVNode as b, createBlock as S, toDisplayString as m, unref as r, withCtx as i, renderSlot as R, createTextVNode as T } from "vue";
import h from "../PlIcon24/PlIcon24.vue.js";

import { okOptional as $, tapIf as I } from "@milaboratories/helpers";
import { useLogHandle as O } from "./useLogHandle.js";
import { useLabelNotch as j } from "../../utils/useLabelNotch.js";
import q from "../../utils/DoubleContour.vue.js";

import y from "../PlTooltip/PlTooltip.vue.js";
import { downloadContent as z } from "../../helpers/downloadContent.js";
const M = { key: 0 }, G = { class: "pl-log-view__copy" }, J = {
  key: 1,
  class: "pl-log-view__error"
}, K = {
  name: "PlLogView"
}, ro = /* @__PURE__ */ E({
  ...K,
  props: {
    value: {},
    valueToCopy: {},
    logHandle: {},
    progressPrefix: {},
    error: {},
    output: {},
    maxRetries: {},
    mockPlatforma: {},
    label: {},
    disableAutoScroll: { type: Boolean },
    downloadFilename: {}
  },
  setup(n) {
    const x = (o) => {
      if (o && o.ok === !1)
        return o.errors.join(`
`);
    }, V = F(), t = n, g = O(t), k = c(!0), w = c(), _ = c(), f = u(() => {
      var o;
      return ((o = g.value) == null ? void 0 : o.error) ?? t.error ?? x(t.output);
    }), a = u(() => {
      var o;
      return ((o = g.value) == null ? void 0 : o.lines) ?? t.value ?? $(t.output);
    }), C = u(() => {
      if (t.valueToCopy)
        return t.valueToCopy;
      if (a.value && typeof a.value == "string")
        return a.value;
    }), s = c(!1);
    j(_);
    const N = u(() => s.value ? "clipboard-copied" : "clipboard"), A = () => {
      s.value = !0, setTimeout(() => {
        s.value = !1;
      }, 1200);
      const o = C.value;
      o !== void 0 && navigator.clipboard.writeText(o);
    }, H = (o) => {
      const e = C.value;
      e !== void 0 && z([e, "text/plain"], o);
    }, B = () => {
      t.disableAutoScroll || I(w.value, (o) => {
        k.value && o.scrollTo(o.scrollLeft, o.scrollHeight);
      });
    };
    L(
      a,
      () => {
        requestAnimationFrame(() => {
          B();
        });
      },
      { immediate: !0 }
    );
    const D = (o) => {
      const e = o.target;
      k.value = e.scrollTop + 20 >= e.scrollHeight - e.offsetHeight;
    };
    return (o, e) => (l(), p("div", {
      ref_key: "root",
      ref: _,
      class: P(["pl-log-view", { "has-error": f.value }])
    }, [
      n.label ? (l(), p("label", M, [
        b("span", null, m(n.label), 1),
        r(V).tooltip ? (l(), S(r(y), {
          key: 0,
          class: "info",
          position: "top"
        }, {
          tooltip: i(() => [
            R(o.$slots, "tooltip")
          ]),
          _: 3
        })) : v("", !0)
      ])) : v("", !0),
      d(q, { class: "pl-log-view__contour" }),
      b("div", G, [
        d(r(y), {
          "close-delay": 800,
          position: "top"
        }, {
          tooltip: i(() => [
            T(m(s.value ? "copied" : "copy"), 1)
          ]),
          default: i(() => [
            d(r(h), {
              title: "Copy content",
              name: N.value,
              onClick: A
            }, null, 8, ["name"])
          ]),
          _: 1
        }),
        n.downloadFilename ? (l(), S(r(y), {
          key: 0,
          "close-delay": 800,
          position: "top"
        }, {
          tooltip: i(() => [...e[1] || (e[1] = [
            T("download", -1)
          ])]),
          default: i(() => [
            d(r(h), {
              name: "download",
              onClick: e[0] || (e[0] = () => H(n.downloadFilename))
            })
          ]),
          _: 1
        })) : v("", !0)
      ]),
      f.value ? (l(), p("div", J, m(f.value), 1)) : (l(), p("div", {
        key: 2,
        ref_key: "contentRef",
        ref: w,
        class: "pl-log-view__content",
        onScroll: D
      }, m(a.value), 545))
    ], 2));
  }
});
export {
  ro as default
};
//# sourceMappingURL=PlLogView.vue.js.map
