import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
import { Component, useField, SugaredField } from "@contember/binding";
import { FieldFallbackView } from "./FieldFallbackView.js";
const DateFieldView = Component(
  ({ field, locale, format, fallback, fallbackStyle }) => {
    const dateField = useField(field);
    if (dateField.value === null) {
      return /* @__PURE__ */ jsxDEV(FieldFallbackView, { fallback, fallbackStyle }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/DateFieldView.tsx",
        lineNumber: 21,
        columnNumber: 11
      }, globalThis);
    }
    const date = new Date(dateField.value);
    if (locale === void 0) {
      if (format === void 0) {
        return /* @__PURE__ */ jsxDEV(Fragment, { children: date.toLocaleString() }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/DateFieldView.tsx",
          lineNumber: 29,
          columnNumber: 12
        }, globalThis);
      }
      if (typeof format === "function") {
        return /* @__PURE__ */ jsxDEV(Fragment, { children: format(date) }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/DateFieldView.tsx",
          lineNumber: 33,
          columnNumber: 12
        }, globalThis);
      }
    }
    const intl = new Intl.DateTimeFormat(locale ?? "default", { ...format, timeZone: "UTC" });
    return /* @__PURE__ */ jsxDEV(Fragment, { children: intl.format(date) }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/DateFieldView.tsx",
      lineNumber: 38,
      columnNumber: 10
    }, globalThis);
  },
  (props) => /* @__PURE__ */ jsxDEV(Fragment, { children: [
    /* @__PURE__ */ jsxDEV(SugaredField, { field: props.field }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/DateFieldView.tsx",
      lineNumber: 42,
      columnNumber: 4
    }, globalThis),
    /* @__PURE__ */ jsxDEV(FieldFallbackView, { fallback: props.fallback, fallbackStyle: props.fallbackStyle }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/DateFieldView.tsx",
      lineNumber: 43,
      columnNumber: 4
    }, globalThis)
  ] }, void 0, true, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fieldViews/DateFieldView.tsx",
    lineNumber: 41,
    columnNumber: 3
  }, globalThis),
  "DateFieldView"
);
export {
  DateFieldView
};
//# sourceMappingURL=DateFieldView.js.map
