import { aJ as o, af as f, ah as d, ai as m, ag as g, e as C, aO as p } from "./index-THhC4TET.js";
import { useState as h } from "react";
import { u as y } from "./useAddAppMutation-AVqslsQL.js";
var i = function(n) {
  switch (typeof n) {
    case "string":
      return n;
    case "boolean":
      return n ? "true" : "false";
    case "number":
      return isFinite(n) ? n : "";
    default:
      return "";
  }
}, E = function(n, t, e, a) {
  return t = t || "&", e = e || "=", n === null && (n = void 0), typeof n == "object" ? Object.keys(n).map(function(r) {
    var c = encodeURIComponent(i(r)) + e;
    return Array.isArray(n[r]) ? n[r].map(function(l) {
      return c + encodeURIComponent(i(l));
    }).join(t) : c + encodeURIComponent(i(n[r]));
  }).filter(Boolean).join(t) : a ? encodeURIComponent(i(a)) + e + encodeURIComponent(i(n)) : "";
}, s;
s = E;
var u = /* @__PURE__ */ ((n) => (n.ACCOUNTS_STEP = "accounts", n.EVENT_TYPES_STEP = "event-types", n.CONFIGURE_STEP = "configure", n))(u || {});
const x = ({
  slug: n,
  step: t,
  teamId: e
}) => {
  const a = { slug: n };
  e && (a.teamId = e);
  const r = s(a);
  return `/apps/installation/${t}?${r}`;
};
function T(n) {
  const t = y(null);
  return /* @__PURE__ */ o.jsx(f, { name: "Account check", open: n.open, onOpenChange: n.onOpenChange, children: /* @__PURE__ */ o.jsx(
    d,
    {
      type: "creation",
      title: "Connecting with MS Teams requires a work/school Microsoft account.",
      description: "If you continue with a personal account you will receive an error",
      children: /* @__PURE__ */ o.jsx(m, { showDivider: !0, className: "mt-6", children: /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
        /* @__PURE__ */ o.jsx(
          g,
          {
            type: "button",
            color: "secondary",
            tabIndex: -1,
            onClick: () => {
              var e;
              (e = n.onOpenChange) == null || e.call(n, !1);
            },
            children: "Cancel"
          }
        ),
        /* @__PURE__ */ o.jsx(
          C,
          {
            type: "button",
            onClick: () => t.mutate({
              type: "office365_video",
              variant: "conferencing",
              slug: "msteams",
              returnTo: p + x({
                slug: "msteams",
                step: u.EVENT_TYPES_STEP
              })
            }),
            children: "Continue"
          }
        )
      ] }) })
    }
  ) });
}
function U(n) {
  const [t, e] = h(!1);
  return /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
    n.render({
      onClick() {
        e(!0);
      },
      disabled: t
    }),
    /* @__PURE__ */ o.jsx(T, { open: t, onOpenChange: e })
  ] });
}
export {
  U as default
};
