import { jsx as e, Fragment as x, jsxs as a } from "react/jsx-runtime";
import { useState as y } from "react";
import { MediaProvider as v, MediaConsumer as N, PostProvider as b, PostConsumer as m, Post as M } from "@devgateway/wp-react-lib";
import { Modal as r, Button as d } from "semantic-ui-react";
const A = (l) => {
  const {
    "data-post-type": h,
    "data-download-style": u,
    "data-post-slug": i,
    "data-post-id": P,
    "data-media-id": g,
    "data-text": s,
    "data-agree": p = "Agree",
    "data-cancel": w = "Cancel",
    intl: { locale: C }
  } = l, f = (n) => {
    var t, c;
    return /* @__PURE__ */ e("div", { class: "ui container entry-content", children: /* @__PURE__ */ e(
      "span",
      {
        dangerouslySetInnerHTML: { __html: (c = (t = n == null ? void 0 : n.posts) == null ? void 0 : t[0]) == null ? void 0 : c.title.rendered },
        id: "agreement-text",
        class: "title"
      }
    ) });
  }, [k, o] = y(!1);
  return /* @__PURE__ */ e("span", { className: "", children: /* @__PURE__ */ e(v, { id: g, children: /* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(({ media: n }) => /* @__PURE__ */ e(x, { children: i && /* @__PURE__ */ e(b, { locale: C, type: h, slug: i, children: /* @__PURE__ */ a(
    r,
    {
      onClose: () => o(!1),
      onOpen: () => o(!0),
      open: k,
      trigger: /* @__PURE__ */ e("span", { children: u == "link" ? /* @__PURE__ */ a("a", { className: "agree-and-download link", children: [
        " ",
        s,
        " "
      ] }) : /* @__PURE__ */ e(d, { className: "agree-and-download button", children: s }) }),
      children: [
        /* @__PURE__ */ e(r.Header, { className: "agreement-header", children: /* @__PURE__ */ a(m, { children: [
          /* @__PURE__ */ a(
            "svg",
            {
              width: "97",
              height: "97",
              viewBox: "0 0 97 97",
              fill: "none",
              xmlns: "http://www.w3.org/2000/svg",
              children: [
                /* @__PURE__ */ e(
                  "path",
                  {
                    d: "M48.6761 26L70.1999 47.5588C70.3676 47.7162 70.5012 47.9062 70.5925 48.1172C70.6839 48.3283 70.731 48.5558 70.731 48.7857C70.731 49.0157 70.6839 49.2432 70.5925 49.4542C70.5012 49.6652 70.3676 49.8553 70.1999 50.0126L48.6761 71.5714",
                    stroke: "white",
                    "stroke-linecap": "round",
                    "stroke-linejoin": "round"
                  }
                ),
                /* @__PURE__ */ e(
                  "path",
                  {
                    d: "M31.2041 26L52.7629 47.5588C53.084 47.8864 53.2639 48.3269 53.2639 48.7857C53.2639 49.2445 53.084 49.685 52.7629 50.0126L31.2041 71.5714",
                    stroke: "white",
                    "stroke-linecap": "round",
                    "stroke-linejoin": "round"
                  }
                ),
                /* @__PURE__ */ e("circle", { cx: "48.5", cy: "48.5", r: "48", stroke: "white" })
              ]
            }
          ),
          /* @__PURE__ */ e(f, { ...l })
        ] }) }),
        /* @__PURE__ */ e(r.Content, { className: "agreement-body", children: /* @__PURE__ */ e(m, { children: /* @__PURE__ */ e(M, { preview: !0, showIntro: !0 }) }) }),
        /* @__PURE__ */ a(r.Actions, { className: "agreement-footer", children: [
          /* @__PURE__ */ e(
            d,
            {
              className: "modal-cancel-button",
              onClick: () => o(!1),
              children: w
            }
          ),
          /* @__PURE__ */ e(
            d,
            {
              className: "modal-agree-button",
              content: p,
              onClick: () => {
                o(!1);
                const t = document.createElement("a");
                t.href = n.guid.rendered + "?accepted=YES", document.body.appendChild(t), t.click(), document.body.removeChild(t);
              },
              positive: !0
            }
          )
        ] })
      ]
    }
  ) }) }), {}) }) }) });
};
export {
  A as default
};
