"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var modal_mobile_exports = {};
__export(modal_mobile_exports, {
  ModalMobile: () => ModalMobile
});
module.exports = __toCommonJS(modal_mobile_exports);
var import_design_system = require("@wix/design-system");
var import_react = __toESM(require("react"));
var import_ricos_context = require("./../../../ricos-context/index.js");
var import_ui_components = require("./../../../ui-components/index.js");
var import_data_hooks = require("../data-hooks/data-hooks.js");
var import_attributes_mobile = require("./attributes/attributes-mobile.js");
var import_footer = require("./footer.js");
var import_section_mobile = require("./section/section-mobile.js");
var import_type_select = require("./type-select.js");
var import_use_link_modal_state = require("./use-link-modal-state.js");
var import_web_address = require("./web-address.js");
const ModalMobile = ({
  initialValue,
  enabledLinkTypes: enabledLinkTypesProp,
  onClose,
  onSave,
  onUnlink
}) => {
  const { t } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  const {
    link,
    linkType,
    submitError,
    enabledLinkTypes,
    onChangeAttributes,
    onChangeWebAddress,
    onClickUnlink,
    onSelectSection,
    onSelectType,
    onSubmit,
    onValidateWebAddress
  } = (0, import_use_link_modal_state.useLinkModalState)({
    initialValue,
    onClose,
    onSave,
    onUnlink,
    enabledLinkTypes: enabledLinkTypesProp
  });
  return /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.Panel,
    {
      dataHook: import_data_hooks.MODAL_ROOT,
      closeButtonProps: { onClick: onClose },
      skin: "floating",
      width: "100%"
    },
    /* @__PURE__ */ import_react.default.createElement(import_ui_components.PanelHeader, { title: t("LinkSettings_Modal_Title") }),
    /* @__PURE__ */ import_react.default.createElement(import_design_system.SidePanel.Content, { noPadding: true }, /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { boxSizing: "border-box", direction: "vertical", gap: "SP3", height: "100%", padding: 0 }, /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { padding: "SP3", paddingBottom: 0 }, enabledLinkTypes && enabledLinkTypes.length === 1 ? null : /* @__PURE__ */ import_react.default.createElement(
      import_type_select.TypeSelect,
      {
        autoFocus: false,
        onSelect: onSelectType,
        showSitePages: false,
        t,
        type: linkType,
        enabledLinkTypes
      }
    )), linkType === "section" ? /* @__PURE__ */ import_react.default.createElement(import_section_mobile.SectionMobile, { link, onSelect: onSelectSection, t }) : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { direction: "vertical", paddingLeft: "SP3", paddingRight: "SP3" }, /* @__PURE__ */ import_react.default.createElement(
      import_web_address.WebAddress,
      {
        autoFocus: true,
        link,
        onChangeUrl: onChangeWebAddress,
        onValidateUrl: onValidateWebAddress,
        submitError,
        t
      }
    )), /* @__PURE__ */ import_react.default.createElement(import_design_system.Divider, null), /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { direction: "vertical", padding: "SP3" }, /* @__PURE__ */ import_react.default.createElement(import_attributes_mobile.AttributesMobile, { link, onChange: onChangeAttributes, t }))))),
    /* @__PURE__ */ import_react.default.createElement(import_design_system.SidePanel.Footer, { showDivider: true }, /* @__PURE__ */ import_react.default.createElement(
      import_footer.Footer,
      {
        onClickCancel: onClose,
        onClickSave: onSubmit,
        onClickUnlink,
        showUnlink: Boolean(initialValue?.url || initialValue?.anchor),
        t
      }
    ))
  );
};
//# sourceMappingURL=modal-mobile.js.map
