import {
  EditCoachingTime
} from "./chunk-TNJG6DRI.js";
import {
  EditServiceType
} from "./chunk-WNSDISYV.js";
import {
  Grid
} from "./chunk-EGEQY3KT.js";
import {
  DataList
} from "./chunk-VTJZMOSP.js";
import {
  Dialog
} from "./chunk-JHZGOPC4.js";
import {
  Heading
} from "./chunk-HK224ADT.js";
import {
  BulletText
} from "./chunk-NAL2USH5.js";
import {
  Flex
} from "./chunk-25HMMI7R.js";
import {
  Button
} from "./chunk-U7JPP7WJ.js";
import {
  Card
} from "./chunk-2ZQK7NTN.js";
import {
  Pencil1Icon
} from "./chunk-OXXF2CUB.js";
import {
  __objRest,
  __spreadProps,
  __spreadValues
} from "./chunk-N552FDTV.js";

// src/app/platform/session-card.tsx
import { useCallback, useMemo } from "react";
import { format } from "date-fns";
import { jsx, jsxs } from "react/jsx-runtime";
var preventDefault = (e) => {
  e.preventDefault();
};
function SessionCard(props) {
  const _a = props, {
    sessionNumber,
    userName,
    error,
    ExtraButtons,
    TitleExtra,
    editable,
    onSaveDate,
    onSaveSessionType,
    startAt,
    endAt,
    sessionType
  } = _a, rest = __objRest(_a, [
    "sessionNumber",
    "userName",
    "error",
    "ExtraButtons",
    "TitleExtra",
    "editable",
    "onSaveDate",
    "onSaveSessionType",
    "startAt",
    "endAt",
    "sessionType"
  ]);
  const renderEditButton = useCallback(() => {
    return /* @__PURE__ */ jsx(Button, { color: "gray", ml: "2", variant: "transparent", children: /* @__PURE__ */ jsx(Pencil1Icon, {}) });
  }, []);
  const sessionTimeStr = useMemo(() => {
    if (!startAt || !endAt)
      return "\uC54C \uC218 \uC5C6\uC74C";
    return `${format(startAt, "yyyy\uB144 MM\uC6D4 dd\uC77C HH\uC2DC mm\uBD84")} ~ ${format(endAt, "HH\uC2DC mm\uBD84")}`;
  }, [startAt, endAt]);
  return /* @__PURE__ */ jsx(Card, __spreadProps(__spreadValues({ error: Boolean(error) }, rest), { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "3", children: [
    /* @__PURE__ */ jsxs(Flex, { align: "center", width: "100%", children: [
      /* @__PURE__ */ jsx(Heading, { variant: "heading4", children: `${userName || "\uC54C \uC218 \uC5C6\uC74C"}\uB2D8 ${sessionNumber || "-"}\uD68C\uCC28` }),
      TitleExtra,
      error ? /* @__PURE__ */ jsx(BulletText, { as: "p", color: "red", variant: "caption", children: error }) : null
    ] }),
    /* @__PURE__ */ jsxs(DataList.Root, { children: [
      /* @__PURE__ */ jsxs(DataList.Item, { children: [
        /* @__PURE__ */ jsx(DataList.Label, { children: "\uCF54\uCE6D \uC77C\uC2DC" }),
        /* @__PURE__ */ jsxs(DataList.Value, { children: [
          sessionTimeStr,
          editable ? /* @__PURE__ */ jsxs(Dialog.Root, { children: [
            /* @__PURE__ */ jsx(Dialog.Trigger, { children: renderEditButton() }),
            /* @__PURE__ */ jsx(
              Dialog.Content,
              {
                onOpenAutoFocus: preventDefault,
                style: { overflow: "visible" },
                title: `${sessionNumber}\uD68C\uCC28 \uC138\uC158 \uC77C\uC2DC \uBCC0\uACBD\uD558\uAE30`,
                children: /* @__PURE__ */ jsx(
                  EditCoachingTime,
                  {
                    defaultEndAt: endAt,
                    defaultStartAt: startAt,
                    onClickSave: onSaveDate
                  }
                )
              }
            )
          ] }) : null
        ] })
      ] }),
      /* @__PURE__ */ jsxs(Grid, { columns: { initial: "1", xs: "2" }, style: { gap: "inherit" }, children: [
        /* @__PURE__ */ jsxs(DataList.Item, { children: [
          /* @__PURE__ */ jsx(DataList.Label, { children: "\uC138\uC158 \uCC38\uC5EC \uBC29\uC2DD" }),
          /* @__PURE__ */ jsxs(DataList.Value, { children: [
            sessionType === "offlineCoaching" ? "\uC624\uD504\uB77C\uC778" : "\uC628\uB77C\uC778",
            editable ? /* @__PURE__ */ jsxs(Dialog.Root, { children: [
              /* @__PURE__ */ jsx(Dialog.Trigger, { children: renderEditButton() }),
              /* @__PURE__ */ jsx(
                Dialog.Content,
                {
                  title: `${sessionNumber}\uD68C\uCC28 \uC138\uC158 \uC9C4\uD589 \uBC29\uC2DD \uBCC0\uACBD\uD558\uAE30`,
                  children: /* @__PURE__ */ jsx(
                    EditServiceType,
                    {
                      defaultServiceType: sessionType,
                      onClickSave: onSaveSessionType
                    }
                  )
                }
              )
            ] }) : null
          ] })
        ] }),
        /* @__PURE__ */ jsx(Flex, { gap: "2", justify: "end", children: ExtraButtons })
      ] })
    ] })
  ] }) }));
}

export {
  SessionCard
};
//# sourceMappingURL=chunk-AEHUSHES.js.map