import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import i18nBackend from "i18next-http-backend";
import { D as DEFAULT_LANG } from "./pathname.rental-VYOFVGX6.esm.js";
import * as Yup from "yup";
import dayjs from "dayjs";
import { j as jsxRuntimeExports } from "./jsx-runtime-ClFauRgV.esm.js";
import { r as requireObjectAssign, P as PropTypes } from "./identifier-u4E_J1of.esm.js";
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CcAunmGO.esm.js";
import React__default$1 from "react";
import { g as generateRouteWithId } from "./useAuth-CEQTm2rv.esm.js";
i18n.use(i18nBackend).use(initReactI18next).init({
  fallbackLng: "en",
  lng: DEFAULT_LANG,
  // fallbackLng: {
  //   'ar': ['en'], 
  //   'es': ['en'], 
  //   'default': ['en']
  // },
  fallbackNS: false,
  // Don't fallback to other namespaces
  returnNull: false,
  returnEmptyString: false,
  interpolation: {
    escapeValue: false
  },
  debug: false,
  // Make sure this is false
  saveMissing: false,
  missingKeyHandler: false,
  // Explicitly disable
  missingKeyNoValueFallbackToKey: true,
  // resources: resource,
  resources: {},
  // debug: process.env.NODE_ENV === 'development',
  saveMissingTo: "fallback",
  keySeparator: ".",
  nsSeparator: ":"
});
const getCountry = (code) => {
  const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
  return regionNames.of(code);
};
const DEFAULT_MESSAGES = {
  required: "Date is required",
  invalidDate: "Date must be a valid date",
  pastDate: "Date cannot be in the past",
  futureDate: "Future dates are not allowed",
  todayNotAllowed: "Today's date is not allowed",
  pastTime: "Time cannot be in the past for today's date"
};
const transformDate = (value, originalValue) => {
  if (dayjs.isDayjs(originalValue)) {
    return originalValue.toDate();
  }
  if (originalValue instanceof Date) {
    return originalValue;
  }
  if (typeof originalValue === "string" && originalValue) {
    return dayjs(originalValue).toDate();
  }
  return null;
};
const createDateValidation = (options = {}) => {
  const {
    allowPast = false,
    allowToday = true,
    allowFuture = true,
    requiredMessage = DEFAULT_MESSAGES.required,
    pastDateMessage = DEFAULT_MESSAGES.pastDate,
    futureDateMessage = DEFAULT_MESSAGES.futureDate,
    todayNotAllowedMessage = DEFAULT_MESSAGES.todayNotAllowed,
    invalidDateMessage = DEFAULT_MESSAGES.invalidDate,
    checkTime = false,
    pastTimeMessage = DEFAULT_MESSAGES.pastTime
  } = options;
  return Yup.mixed().transform(transformDate).typeError(invalidDateMessage).required(requiredMessage).test("date-validation", function(value) {
    if (!value) return false;
    const now = dayjs();
    const selectedDateTime = dayjs(value);
    const today = dayjs().startOf("day");
    const selectedDate = dayjs(value).startOf("day");
    if (selectedDate.isBefore(today) && !allowPast) {
      return this.createError({ message: pastDateMessage });
    }
    if (selectedDate.isSame(today)) {
      if (!allowToday) {
        return this.createError({ message: todayNotAllowedMessage });
      }
      if (checkTime && selectedDateTime.isBefore(now)) {
        return this.createError({ message: pastTimeMessage });
      }
    }
    if (selectedDate.isAfter(today) && !allowFuture) {
      return this.createError({ message: futureDateMessage });
    }
    return true;
  });
};
const dateValidation = (requiredMessage, options = {}) => createDateValidation({
  allowPast: false,
  allowToday: true,
  allowFuture: true,
  ...options,
  requiredMessage
});
const futureDateValidation = (requiredMessage) => createDateValidation({
  allowPast: false,
  allowToday: false,
  allowFuture: true,
  requiredMessage,
  pastDateMessage: "Please select a future date"
});
const anyDateValidation = (requiredMessage) => createDateValidation({
  allowPast: true,
  allowToday: true,
  allowFuture: true,
  requiredMessage
});
const pastDateValidation = (requiredMessage) => createDateValidation({
  allowPast: true,
  allowToday: true,
  allowFuture: false,
  requiredMessage,
  futureDateMessage: "Future dates are not allowed"
});
const dateTimeValidation = (requiredMessage) => createDateValidation({
  allowPast: false,
  allowToday: true,
  allowFuture: true,
  checkTime: true,
  requiredMessage
});
const businessDateValidation = (requiredMessage) => {
  return createDateValidation({
    allowPast: false,
    allowToday: true,
    allowFuture: true,
    requiredMessage
  }).test("business-day", "Please select a business day (Monday to Friday)", function(value) {
    if (!value) return false;
    const dayOfWeek = dayjs(value).day();
    return dayOfWeek >= 1 && dayOfWeek <= 5;
  });
};
const dateRangeValidation = (minDate, maxDate, requiredMessage) => {
  return Yup.mixed().transform(transformDate).typeError(DEFAULT_MESSAGES.invalidDate).required(requiredMessage || DEFAULT_MESSAGES.required).test("date-range", function(value) {
    if (!value) return false;
    const selected = dayjs(value);
    const min = dayjs(minDate);
    const max = dayjs(maxDate);
    if (selected.isBefore(min)) {
      return this.createError({
        message: `Date must be after ${min.format("MMM DD, YYYY")}`
      });
    }
    if (selected.isAfter(max)) {
      return this.createError({
        message: `Date must be before ${max.format("MMM DD, YYYY")}`
      });
    }
    return true;
  });
};
const createCustomMessages = (overrides) => ({
  ...DEFAULT_MESSAGES,
  ...overrides
});
const conditionalDateValidation = (condition, validationSchema) => {
  return Yup.mixed().when("$root", {
    is: condition,
    then: validationSchema,
    otherwise: Yup.mixed().notRequired()
  });
};
const COMMON_DATE_VALIDATIONS = {
  // Rental/Order dates
  rental: (msg) => dateValidation(msg || "Rental date is required")
};
const fileSize = (size) => {
  let sizeCategory;
  const absSize = Math.abs(size);
  switch (true) {
    case absSize < 1024:
      sizeCategory = `${(size / 1024).toFixed(2)} Byte`;
      break;
    case (absSize >= 1024 && absSize < 1024 * 1024):
      sizeCategory = `${(size / 1024).toFixed(2)} KB`;
      break;
    case (absSize >= 1024 * 1024 && absSize < 1024 * 1024 * 1024):
      sizeCategory = `${(size / (1024 * 1024)).toFixed(2)} MB`;
      break;
    default:
      sizeCategory = `${(size / (1024 * 1024 * 1024)).toFixed(2)} GB`;
  }
  return sizeCategory;
};
const REPORT_PERMISSION_KEY_MAP = {
  "hrms/reports": "reports-hrms",
  "inventory/reports": "reports-inventory",
  "sales/reports": "reports-sales",
  "rental/reports": "reports-rental",
  "manufacturing/reports": "reports-manufacturing",
  "purchase/reports": "reports-purchase",
  "accounts-and-finance/reports": "reports-accounts-and-finance"
};
const getPermissionOperations = (permissionEntry) => Object.values(permissionEntry || {}).flat().map((p) => {
  var _a;
  return (_a = p.identity) == null ? void 0 : _a.operation;
}).filter((operation) => Boolean(operation));
const getPermissionKeyForSubModule = (subModuleName) => REPORT_PERMISSION_KEY_MAP[subModuleName] ?? subModuleName.split("/").pop() ?? "";
const shouldExpandChildSubModules = (moduleName, subModuleName) => {
  return moduleName === "hrms" || subModuleName in REPORT_PERMISSION_KEY_MAP;
};
const hasNestedModulePath = (value) => {
  if (!value) return false;
  if (Array.isArray(value)) {
    return value.some((item) => item.includes("/"));
  }
  return value.includes("/");
};
class StorageUtils {
  /**
   * Retrieves and parses user data from localStorage
   * @returns Parsed user data or null if not found
   */
  static getUserData() {
    try {
      const userData = localStorage.getItem("_u_data");
      return userData ? JSON.parse(userData) : null;
    } catch (error) {
      console.error("Error parsing user data:", error);
      return null;
    }
  }
  /**
   * Retrieves and parses role permissions from localStorage
   * @returns Parsed permissions object
   */
  static getRolePermissions() {
    try {
      const permissions = localStorage.getItem("role-permission");
      return permissions ? JSON.parse(permissions) : {};
    } catch (error) {
      console.error("Error parsing role permissions:", error);
      return {};
    }
  }
}
class ModuleAccessService {
  /**
   * Filters modules by allowed module names and adds dashboard sub-module
   * @param moduleNames - Array of allowed module names
   * @param userData - User data containing module access
   * @returns Filtered modules with dashboard added
   */
  static getAccessibleSubModules(moduleNames, userData, permissions) {
    if (!(userData == null ? void 0 : userData.module_access)) {
      return [];
    }
    return userData.module_access.filter((module) => moduleNames.includes(module.module_name)).map((module) => {
      return {
        ...module,
        sub_modules: [
          ...(module.sub_modules || []).flatMap((subModule) => {
            if (!shouldExpandChildSubModules(module.module_name, subModule.sub_module_name)) {
              return [subModule];
            }
            const permissionKey = getPermissionKeyForSubModule(subModule.sub_module_name);
            const permissionEntry = permissions[permissionKey];
            const childSubModules = getPermissionOperations(permissionEntry).map(
              (operation) => ({
                sub_module_name: `${subModule.sub_module_name}/${operation}`
              })
            );
            return [subModule, ...childSubModules];
          }),
          { sub_module_name: "dashboard" }
        ]
      };
    });
  }
  /**
   * Extracts unique sub-module names from modules
   * @param modules - Array of module access objects
   * @returns Set of unique sub-module names
   */
  static extractSubModuleNames(modules) {
    return new Set(
      modules.flatMap(
        (module) => (module.sub_modules || []).map((subModule) => subModule.sub_module_name)
      )
    );
  }
  /**
   * Matches sub-module names with permission keys
   * @param subModuleNames - Set of sub-module names
   * @param permissions - Permission object
   * @returns Set of matching sub-module names
   */
  static getMatchingSubModules(subModuleNames, permissions) {
    const permissionKeys = Object.keys(permissions);
    const _hrmsPermissionKeys = permissionKeys == null ? void 0 : permissionKeys.map((v) => v.replace(/(\/-p.*$|-p$)/i, ""));
    const matchingModules = Array.from(subModuleNames).filter((subModuleName) => {
      const matchingReportKey = Object.entries(REPORT_PERMISSION_KEY_MAP).find(
        ([reportPath]) => subModuleName === reportPath || subModuleName.startsWith(`${reportPath}/`)
      );
      if (matchingReportKey) {
        const [reportPath, permissionKey] = matchingReportKey;
        const reportOperations = getPermissionOperations(permissions[permissionKey]);
        if (!reportOperations.length) return false;
        const reportRoutePath = subModuleName.replace(`${reportPath}/`, "").replace(reportPath, "");
        if (!reportRoutePath) return true;
        return reportOperations.some(
          (operation) => operation === reportRoutePath || operation === ":nop" || operation === ":param" || operation === "*" || operation.endsWith("*") && reportRoutePath.startsWith(operation.slice(0, -1))
        );
      }
      const segments = subModuleName.split("/");
      if (segments[0] === "hrms") {
        const matchedKeyIndex = segments.findIndex(
          (segment) => _hrmsPermissionKeys.includes(segment)
        );
        if (matchedKeyIndex === -1) return false;
        const matchedKey = segments[matchedKeyIndex];
        const childSegment = segments[matchedKeyIndex + 1];
        if (!childSegment) return true;
        const permissionEntry = permissions[matchedKey];
        if (!permissionEntry) return false;
        const allOperations = Object.values(permissionEntry).flat().map((p) => {
          var _a;
          return (_a = p.identity) == null ? void 0 : _a.operation;
        });
        return allOperations.some(
          (op) => op === childSegment || // exact: "generate" === "generate"
          op === ":nop" || // wildcard: list operation
          op === ":param"
          // wildcard: single resource operation
        );
      } else {
        const lastPart = subModuleName.split("/").pop() || "";
        return permissionKeys.some((permKey) => permKey.startsWith(lastPart));
      }
    });
    return new Set(matchingModules);
  }
}
class MenuFilterService {
  static checkSubModuleAccess(bacSubModuleName, accessibleSubModules) {
    if (!bacSubModuleName) return false;
    if (Array.isArray(bacSubModuleName)) {
      return bacSubModuleName.some((name) => accessibleSubModules.has(name));
    }
    return accessibleSubModules.has(bacSubModuleName);
  }
  static filterHrmsSubmenu(menu, accessibleSubModules) {
    return menu.map((item) => {
      if (item.submenu && item.submenu.length > 0) {
        const filteredSubmenu = this.filterHrmsSubmenu(item.submenu, accessibleSubModules);
        const hasValidSubModule = this.checkSubModuleAccess(item.bacSubModuleName, accessibleSubModules);
        if (filteredSubmenu.length > 0 || hasValidSubModule) {
          return { ...item, submenu: filteredSubmenu };
        }
        return null;
      }
      return this.checkSubModuleAccess(item.bacSubModuleName, accessibleSubModules) ? item : null;
    }).filter((item) => item !== null);
  }
  /**
   * Recursively filters menu items based on accessible sub-modules
   * @param menu - Array of menu items
   * @param accessibleSubModules - Set of accessible sub-module names
   * @returns Filtered menu array
   */
  static filterMenuByAccess(menu, accessibleSubModules) {
    return menu.filter((item) => {
      const hasValidSubModule = item.bacSubModuleName && !Array.isArray(item.bacSubModuleName) ? accessibleSubModules.has(item.bacSubModuleName) : false;
      let hasValidSubmenu = false;
      if (item.submenu && item.submenu.length > 0) {
        item.submenu = item.submenu.some(
          (child) => hasNestedModulePath(child.bacSubModuleName)
        ) ? this.filterHrmsSubmenu(item.submenu, accessibleSubModules) : this.filterMenuByAccess(item.submenu, accessibleSubModules);
        hasValidSubmenu = item.submenu.length > 0;
      }
      return hasValidSubModule || hasValidSubmenu;
    });
  }
}
class MenuFilter {
  /**
   * Filters menu based on user permissions and module access
   * @param menu - Menu items to filter
   * @param allowedModules - Array of allowed module names
   * @returns Filtered menu items
   */
  static filterByModuleAccess(menu, allowedModules) {
    const userData = StorageUtils.getUserData();
    const permissions = StorageUtils.getRolePermissions();
    const accessibleModules = ModuleAccessService.getAccessibleSubModules(
      allowedModules,
      userData,
      permissions
    );
    const subModuleNames = ModuleAccessService.extractSubModuleNames(
      accessibleModules
    );
    const matchingSubModules = ModuleAccessService.getMatchingSubModules(
      subModuleNames,
      permissions
    );
    return MenuFilterService.filterMenuByAccess(menu, matchingSubModules);
  }
}
function _interopDefault$1(ex) {
  return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex;
}
var React = React__default$1;
var React__default = _interopDefault$1(React);
function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }
  return obj;
}
function _inheritsLoose(subClass, superClass) {
  subClass.prototype = Object.create(superClass.prototype);
  subClass.prototype.constructor = subClass;
  subClass.__proto__ = superClass;
}
var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
function withSideEffect(reducePropsToState3, handleStateChangeOnClient, mapStateOnServer3) {
  if (typeof reducePropsToState3 !== "function") {
    throw new Error("Expected reducePropsToState to be a function.");
  }
  if (typeof handleStateChangeOnClient !== "function") {
    throw new Error("Expected handleStateChangeOnClient to be a function.");
  }
  if (typeof mapStateOnServer3 !== "undefined" && typeof mapStateOnServer3 !== "function") {
    throw new Error("Expected mapStateOnServer to either be undefined or a function.");
  }
  function getDisplayName(WrappedComponent) {
    return WrappedComponent.displayName || WrappedComponent.name || "Component";
  }
  return function wrap(WrappedComponent) {
    if (typeof WrappedComponent !== "function") {
      throw new Error("Expected WrappedComponent to be a React component.");
    }
    var mountedInstances = [];
    var state;
    function emitChange() {
      state = reducePropsToState3(mountedInstances.map(function(instance) {
        return instance.props;
      }));
      if (SideEffect.canUseDOM) {
        handleStateChangeOnClient(state);
      } else if (mapStateOnServer3) {
        state = mapStateOnServer3(state);
      }
    }
    var SideEffect = /* @__PURE__ */ function(_PureComponent) {
      _inheritsLoose(SideEffect2, _PureComponent);
      function SideEffect2() {
        return _PureComponent.apply(this, arguments) || this;
      }
      SideEffect2.peek = function peek() {
        return state;
      };
      SideEffect2.rewind = function rewind() {
        if (SideEffect2.canUseDOM) {
          throw new Error("You may only call rewind() on the server. Call peek() to read the current state.");
        }
        var recordedState = state;
        state = void 0;
        mountedInstances = [];
        return recordedState;
      };
      var _proto = SideEffect2.prototype;
      _proto.UNSAFE_componentWillMount = function UNSAFE_componentWillMount() {
        mountedInstances.push(this);
        emitChange();
      };
      _proto.componentDidUpdate = function componentDidUpdate() {
        emitChange();
      };
      _proto.componentWillUnmount = function componentWillUnmount() {
        var index = mountedInstances.indexOf(this);
        mountedInstances.splice(index, 1);
        emitChange();
      };
      _proto.render = function render() {
        return React__default.createElement(WrappedComponent, this.props);
      };
      return SideEffect2;
    }(React.PureComponent);
    _defineProperty(SideEffect, "displayName", "SideEffect(" + getDisplayName(WrappedComponent) + ")");
    _defineProperty(SideEffect, "canUseDOM", canUseDOM);
    return SideEffect;
  };
}
var lib = withSideEffect;
const withSideEffect$1 = /* @__PURE__ */ getDefaultExportFromCjs(lib);
var hasElementType = typeof Element !== "undefined";
var hasMap = typeof Map === "function";
var hasSet = typeof Set === "function";
var hasArrayBuffer = typeof ArrayBuffer === "function" && !!ArrayBuffer.isView;
function equal(a, b) {
  if (a === b) return true;
  if (a && b && typeof a == "object" && typeof b == "object") {
    if (a.constructor !== b.constructor) return false;
    var length, i, keys;
    if (Array.isArray(a)) {
      length = a.length;
      if (length != b.length) return false;
      for (i = length; i-- !== 0; )
        if (!equal(a[i], b[i])) return false;
      return true;
    }
    var it;
    if (hasMap && a instanceof Map && b instanceof Map) {
      if (a.size !== b.size) return false;
      it = a.entries();
      while (!(i = it.next()).done)
        if (!b.has(i.value[0])) return false;
      it = a.entries();
      while (!(i = it.next()).done)
        if (!equal(i.value[1], b.get(i.value[0]))) return false;
      return true;
    }
    if (hasSet && a instanceof Set && b instanceof Set) {
      if (a.size !== b.size) return false;
      it = a.entries();
      while (!(i = it.next()).done)
        if (!b.has(i.value[0])) return false;
      return true;
    }
    if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
      length = a.length;
      if (length != b.length) return false;
      for (i = length; i-- !== 0; )
        if (a[i] !== b[i]) return false;
      return true;
    }
    if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
    if (a.valueOf !== Object.prototype.valueOf && typeof a.valueOf === "function" && typeof b.valueOf === "function") return a.valueOf() === b.valueOf();
    if (a.toString !== Object.prototype.toString && typeof a.toString === "function" && typeof b.toString === "function") return a.toString() === b.toString();
    keys = Object.keys(a);
    length = keys.length;
    if (length !== Object.keys(b).length) return false;
    for (i = length; i-- !== 0; )
      if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
    if (hasElementType && a instanceof Element) return false;
    for (i = length; i-- !== 0; ) {
      if ((keys[i] === "_owner" || keys[i] === "__v" || keys[i] === "__o") && a.$$typeof) {
        continue;
      }
      if (!equal(a[keys[i]], b[keys[i]])) return false;
    }
    return true;
  }
  return a !== a && b !== b;
}
var reactFastCompare = function isEqual(a, b) {
  try {
    return equal(a, b);
  } catch (error) {
    if ((error.message || "").match(/stack|recursion/i)) {
      console.warn("react-fast-compare cannot handle circular refs");
      return false;
    }
    throw error;
  }
};
const isEqual2 = /* @__PURE__ */ getDefaultExportFromCjs(reactFastCompare);
var objectAssignExports = requireObjectAssign();
const objectAssign = /* @__PURE__ */ getDefaultExportFromCjs(objectAssignExports);
var ATTRIBUTE_NAMES = {
  BODY: "bodyAttributes",
  HTML: "htmlAttributes",
  TITLE: "titleAttributes"
};
var TAG_NAMES = {
  BASE: "base",
  BODY: "body",
  HEAD: "head",
  HTML: "html",
  LINK: "link",
  META: "meta",
  NOSCRIPT: "noscript",
  SCRIPT: "script",
  STYLE: "style",
  TITLE: "title"
};
var VALID_TAG_NAMES = Object.keys(TAG_NAMES).map(function(name) {
  return TAG_NAMES[name];
});
var TAG_PROPERTIES = {
  CHARSET: "charset",
  CSS_TEXT: "cssText",
  HREF: "href",
  HTTPEQUIV: "http-equiv",
  INNER_HTML: "innerHTML",
  ITEM_PROP: "itemprop",
  NAME: "name",
  PROPERTY: "property",
  REL: "rel",
  SRC: "src",
  TARGET: "target"
};
var REACT_TAG_MAP = {
  accesskey: "accessKey",
  charset: "charSet",
  class: "className",
  contenteditable: "contentEditable",
  contextmenu: "contextMenu",
  "http-equiv": "httpEquiv",
  itemprop: "itemProp",
  tabindex: "tabIndex"
};
var HELMET_PROPS = {
  DEFAULT_TITLE: "defaultTitle",
  DEFER: "defer",
  ENCODE_SPECIAL_CHARACTERS: "encodeSpecialCharacters",
  ON_CHANGE_CLIENT_STATE: "onChangeClientState",
  TITLE_TEMPLATE: "titleTemplate"
};
var HTML_TAG_MAP = Object.keys(REACT_TAG_MAP).reduce(function(obj, key) {
  obj[REACT_TAG_MAP[key]] = key;
  return obj;
}, {});
var SELF_CLOSING_TAGS = [TAG_NAMES.NOSCRIPT, TAG_NAMES.SCRIPT, TAG_NAMES.STYLE];
var HELMET_ATTRIBUTE = "data-react-helmet";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
  return typeof obj;
} : function(obj) {
  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var classCallCheck = function(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
};
var createClass = /* @__PURE__ */ function() {
  function defineProperties(target, props) {
    for (var i = 0; i < props.length; i++) {
      var descriptor = props[i];
      descriptor.enumerable = descriptor.enumerable || false;
      descriptor.configurable = true;
      if ("value" in descriptor) descriptor.writable = true;
      Object.defineProperty(target, descriptor.key, descriptor);
    }
  }
  return function(Constructor, protoProps, staticProps) {
    if (protoProps) defineProperties(Constructor.prototype, protoProps);
    if (staticProps) defineProperties(Constructor, staticProps);
    return Constructor;
  };
}();
var _extends = Object.assign || function(target) {
  for (var i = 1; i < arguments.length; i++) {
    var source = arguments[i];
    for (var key in source) {
      if (Object.prototype.hasOwnProperty.call(source, key)) {
        target[key] = source[key];
      }
    }
  }
  return target;
};
var inherits = function(subClass, superClass) {
  if (typeof superClass !== "function" && superClass !== null) {
    throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  }
  subClass.prototype = Object.create(superClass && superClass.prototype, {
    constructor: {
      value: subClass,
      enumerable: false,
      writable: true,
      configurable: true
    }
  });
  if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var objectWithoutProperties = function(obj, keys) {
  var target = {};
  for (var i in obj) {
    if (keys.indexOf(i) >= 0) continue;
    if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
    target[i] = obj[i];
  }
  return target;
};
var possibleConstructorReturn = function(self, call) {
  if (!self) {
    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  }
  return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var encodeSpecialCharacters = function encodeSpecialCharacters2(str) {
  var encode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
  if (encode === false) {
    return String(str);
  }
  return String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
};
var getTitleFromPropsList = function getTitleFromPropsList2(propsList) {
  var innermostTitle = getInnermostProperty(propsList, TAG_NAMES.TITLE);
  var innermostTemplate = getInnermostProperty(propsList, HELMET_PROPS.TITLE_TEMPLATE);
  if (innermostTemplate && innermostTitle) {
    return innermostTemplate.replace(/%s/g, function() {
      return Array.isArray(innermostTitle) ? innermostTitle.join("") : innermostTitle;
    });
  }
  var innermostDefaultTitle = getInnermostProperty(propsList, HELMET_PROPS.DEFAULT_TITLE);
  return innermostTitle || innermostDefaultTitle || void 0;
};
var getOnChangeClientState = function getOnChangeClientState2(propsList) {
  return getInnermostProperty(propsList, HELMET_PROPS.ON_CHANGE_CLIENT_STATE) || function() {
  };
};
var getAttributesFromPropsList = function getAttributesFromPropsList2(tagType, propsList) {
  return propsList.filter(function(props) {
    return typeof props[tagType] !== "undefined";
  }).map(function(props) {
    return props[tagType];
  }).reduce(function(tagAttrs, current) {
    return _extends({}, tagAttrs, current);
  }, {});
};
var getBaseTagFromPropsList = function getBaseTagFromPropsList2(primaryAttributes, propsList) {
  return propsList.filter(function(props) {
    return typeof props[TAG_NAMES.BASE] !== "undefined";
  }).map(function(props) {
    return props[TAG_NAMES.BASE];
  }).reverse().reduce(function(innermostBaseTag, tag) {
    if (!innermostBaseTag.length) {
      var keys = Object.keys(tag);
      for (var i = 0; i < keys.length; i++) {
        var attributeKey = keys[i];
        var lowerCaseAttributeKey = attributeKey.toLowerCase();
        if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && tag[lowerCaseAttributeKey]) {
          return innermostBaseTag.concat(tag);
        }
      }
    }
    return innermostBaseTag;
  }, []);
};
var getTagsFromPropsList = function getTagsFromPropsList2(tagName, primaryAttributes, propsList) {
  var approvedSeenTags = {};
  return propsList.filter(function(props) {
    if (Array.isArray(props[tagName])) {
      return true;
    }
    if (typeof props[tagName] !== "undefined") {
      warn("Helmet: " + tagName + ' should be of type "Array". Instead found type "' + _typeof(props[tagName]) + '"');
    }
    return false;
  }).map(function(props) {
    return props[tagName];
  }).reverse().reduce(function(approvedTags, instanceTags) {
    var instanceSeenTags = {};
    instanceTags.filter(function(tag) {
      var primaryAttributeKey = void 0;
      var keys2 = Object.keys(tag);
      for (var i2 = 0; i2 < keys2.length; i2++) {
        var attributeKey2 = keys2[i2];
        var lowerCaseAttributeKey = attributeKey2.toLowerCase();
        if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && !(primaryAttributeKey === TAG_PROPERTIES.REL && tag[primaryAttributeKey].toLowerCase() === "canonical") && !(lowerCaseAttributeKey === TAG_PROPERTIES.REL && tag[lowerCaseAttributeKey].toLowerCase() === "stylesheet")) {
          primaryAttributeKey = lowerCaseAttributeKey;
        }
        if (primaryAttributes.indexOf(attributeKey2) !== -1 && (attributeKey2 === TAG_PROPERTIES.INNER_HTML || attributeKey2 === TAG_PROPERTIES.CSS_TEXT || attributeKey2 === TAG_PROPERTIES.ITEM_PROP)) {
          primaryAttributeKey = attributeKey2;
        }
      }
      if (!primaryAttributeKey || !tag[primaryAttributeKey]) {
        return false;
      }
      var value = tag[primaryAttributeKey].toLowerCase();
      if (!approvedSeenTags[primaryAttributeKey]) {
        approvedSeenTags[primaryAttributeKey] = {};
      }
      if (!instanceSeenTags[primaryAttributeKey]) {
        instanceSeenTags[primaryAttributeKey] = {};
      }
      if (!approvedSeenTags[primaryAttributeKey][value]) {
        instanceSeenTags[primaryAttributeKey][value] = true;
        return true;
      }
      return false;
    }).reverse().forEach(function(tag) {
      return approvedTags.push(tag);
    });
    var keys = Object.keys(instanceSeenTags);
    for (var i = 0; i < keys.length; i++) {
      var attributeKey = keys[i];
      var tagUnion = objectAssign({}, approvedSeenTags[attributeKey], instanceSeenTags[attributeKey]);
      approvedSeenTags[attributeKey] = tagUnion;
    }
    return approvedTags;
  }, []).reverse();
};
var getInnermostProperty = function getInnermostProperty2(propsList, property) {
  for (var i = propsList.length - 1; i >= 0; i--) {
    var props = propsList[i];
    if (props.hasOwnProperty(property)) {
      return props[property];
    }
  }
  return null;
};
var reducePropsToState = function reducePropsToState2(propsList) {
  return {
    baseTag: getBaseTagFromPropsList([TAG_PROPERTIES.HREF, TAG_PROPERTIES.TARGET], propsList),
    bodyAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.BODY, propsList),
    defer: getInnermostProperty(propsList, HELMET_PROPS.DEFER),
    encode: getInnermostProperty(propsList, HELMET_PROPS.ENCODE_SPECIAL_CHARACTERS),
    htmlAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.HTML, propsList),
    linkTags: getTagsFromPropsList(TAG_NAMES.LINK, [TAG_PROPERTIES.REL, TAG_PROPERTIES.HREF], propsList),
    metaTags: getTagsFromPropsList(TAG_NAMES.META, [TAG_PROPERTIES.NAME, TAG_PROPERTIES.CHARSET, TAG_PROPERTIES.HTTPEQUIV, TAG_PROPERTIES.PROPERTY, TAG_PROPERTIES.ITEM_PROP], propsList),
    noscriptTags: getTagsFromPropsList(TAG_NAMES.NOSCRIPT, [TAG_PROPERTIES.INNER_HTML], propsList),
    onChangeClientState: getOnChangeClientState(propsList),
    scriptTags: getTagsFromPropsList(TAG_NAMES.SCRIPT, [TAG_PROPERTIES.SRC, TAG_PROPERTIES.INNER_HTML], propsList),
    styleTags: getTagsFromPropsList(TAG_NAMES.STYLE, [TAG_PROPERTIES.CSS_TEXT], propsList),
    title: getTitleFromPropsList(propsList),
    titleAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.TITLE, propsList)
  };
};
var rafPolyfill = function() {
  var clock = Date.now();
  return function(callback) {
    var currentTime = Date.now();
    if (currentTime - clock > 16) {
      clock = currentTime;
      callback(currentTime);
    } else {
      setTimeout(function() {
        rafPolyfill(callback);
      }, 0);
    }
  };
}();
var cafPolyfill = function cafPolyfill2(id) {
  return clearTimeout(id);
};
var requestAnimationFrame = typeof window !== "undefined" ? window.requestAnimationFrame && window.requestAnimationFrame.bind(window) || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || rafPolyfill : global.requestAnimationFrame || rafPolyfill;
var cancelAnimationFrame = typeof window !== "undefined" ? window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || cafPolyfill : global.cancelAnimationFrame || cafPolyfill;
var warn = function warn2(msg) {
  return console && typeof console.warn === "function" && console.warn(msg);
};
var _helmetCallback = null;
var handleClientStateChange = function handleClientStateChange2(newState) {
  if (_helmetCallback) {
    cancelAnimationFrame(_helmetCallback);
  }
  if (newState.defer) {
    _helmetCallback = requestAnimationFrame(function() {
      commitTagChanges(newState, function() {
        _helmetCallback = null;
      });
    });
  } else {
    commitTagChanges(newState);
    _helmetCallback = null;
  }
};
var commitTagChanges = function commitTagChanges2(newState, cb) {
  var baseTag = newState.baseTag, bodyAttributes = newState.bodyAttributes, htmlAttributes = newState.htmlAttributes, linkTags = newState.linkTags, metaTags = newState.metaTags, noscriptTags = newState.noscriptTags, onChangeClientState = newState.onChangeClientState, scriptTags = newState.scriptTags, styleTags = newState.styleTags, title = newState.title, titleAttributes = newState.titleAttributes;
  updateAttributes(TAG_NAMES.BODY, bodyAttributes);
  updateAttributes(TAG_NAMES.HTML, htmlAttributes);
  updateTitle(title, titleAttributes);
  var tagUpdates = {
    baseTag: updateTags(TAG_NAMES.BASE, baseTag),
    linkTags: updateTags(TAG_NAMES.LINK, linkTags),
    metaTags: updateTags(TAG_NAMES.META, metaTags),
    noscriptTags: updateTags(TAG_NAMES.NOSCRIPT, noscriptTags),
    scriptTags: updateTags(TAG_NAMES.SCRIPT, scriptTags),
    styleTags: updateTags(TAG_NAMES.STYLE, styleTags)
  };
  var addedTags = {};
  var removedTags = {};
  Object.keys(tagUpdates).forEach(function(tagType) {
    var _tagUpdates$tagType = tagUpdates[tagType], newTags = _tagUpdates$tagType.newTags, oldTags = _tagUpdates$tagType.oldTags;
    if (newTags.length) {
      addedTags[tagType] = newTags;
    }
    if (oldTags.length) {
      removedTags[tagType] = tagUpdates[tagType].oldTags;
    }
  });
  cb && cb();
  onChangeClientState(newState, addedTags, removedTags);
};
var flattenArray = function flattenArray2(possibleArray) {
  return Array.isArray(possibleArray) ? possibleArray.join("") : possibleArray;
};
var updateTitle = function updateTitle2(title, attributes) {
  if (typeof title !== "undefined" && document.title !== title) {
    document.title = flattenArray(title);
  }
  updateAttributes(TAG_NAMES.TITLE, attributes);
};
var updateAttributes = function updateAttributes2(tagName, attributes) {
  var elementTag = document.getElementsByTagName(tagName)[0];
  if (!elementTag) {
    return;
  }
  var helmetAttributeString = elementTag.getAttribute(HELMET_ATTRIBUTE);
  var helmetAttributes = helmetAttributeString ? helmetAttributeString.split(",") : [];
  var attributesToRemove = [].concat(helmetAttributes);
  var attributeKeys = Object.keys(attributes);
  for (var i = 0; i < attributeKeys.length; i++) {
    var attribute = attributeKeys[i];
    var value = attributes[attribute] || "";
    if (elementTag.getAttribute(attribute) !== value) {
      elementTag.setAttribute(attribute, value);
    }
    if (helmetAttributes.indexOf(attribute) === -1) {
      helmetAttributes.push(attribute);
    }
    var indexToSave = attributesToRemove.indexOf(attribute);
    if (indexToSave !== -1) {
      attributesToRemove.splice(indexToSave, 1);
    }
  }
  for (var _i = attributesToRemove.length - 1; _i >= 0; _i--) {
    elementTag.removeAttribute(attributesToRemove[_i]);
  }
  if (helmetAttributes.length === attributesToRemove.length) {
    elementTag.removeAttribute(HELMET_ATTRIBUTE);
  } else if (elementTag.getAttribute(HELMET_ATTRIBUTE) !== attributeKeys.join(",")) {
    elementTag.setAttribute(HELMET_ATTRIBUTE, attributeKeys.join(","));
  }
};
var updateTags = function updateTags2(type, tags) {
  var headElement = document.head || document.querySelector(TAG_NAMES.HEAD);
  var tagNodes = headElement.querySelectorAll(type + "[" + HELMET_ATTRIBUTE + "]");
  var oldTags = Array.prototype.slice.call(tagNodes);
  var newTags = [];
  var indexToDelete = void 0;
  if (tags && tags.length) {
    tags.forEach(function(tag) {
      var newElement = document.createElement(type);
      for (var attribute in tag) {
        if (tag.hasOwnProperty(attribute)) {
          if (attribute === TAG_PROPERTIES.INNER_HTML) {
            newElement.innerHTML = tag.innerHTML;
          } else if (attribute === TAG_PROPERTIES.CSS_TEXT) {
            if (newElement.styleSheet) {
              newElement.styleSheet.cssText = tag.cssText;
            } else {
              newElement.appendChild(document.createTextNode(tag.cssText));
            }
          } else {
            var value = typeof tag[attribute] === "undefined" ? "" : tag[attribute];
            newElement.setAttribute(attribute, value);
          }
        }
      }
      newElement.setAttribute(HELMET_ATTRIBUTE, "true");
      if (oldTags.some(function(existingTag, index) {
        indexToDelete = index;
        return newElement.isEqualNode(existingTag);
      })) {
        oldTags.splice(indexToDelete, 1);
      } else {
        newTags.push(newElement);
      }
    });
  }
  oldTags.forEach(function(tag) {
    return tag.parentNode.removeChild(tag);
  });
  newTags.forEach(function(tag) {
    return headElement.appendChild(tag);
  });
  return {
    oldTags,
    newTags
  };
};
var generateElementAttributesAsString = function generateElementAttributesAsString2(attributes) {
  return Object.keys(attributes).reduce(function(str, key) {
    var attr = typeof attributes[key] !== "undefined" ? key + '="' + attributes[key] + '"' : "" + key;
    return str ? str + " " + attr : attr;
  }, "");
};
var generateTitleAsString = function generateTitleAsString2(type, title, attributes, encode) {
  var attributeString = generateElementAttributesAsString(attributes);
  var flattenedTitle = flattenArray(title);
  return attributeString ? "<" + type + " " + HELMET_ATTRIBUTE + '="true" ' + attributeString + ">" + encodeSpecialCharacters(flattenedTitle, encode) + "</" + type + ">" : "<" + type + " " + HELMET_ATTRIBUTE + '="true">' + encodeSpecialCharacters(flattenedTitle, encode) + "</" + type + ">";
};
var generateTagsAsString = function generateTagsAsString2(type, tags, encode) {
  return tags.reduce(function(str, tag) {
    var attributeHtml = Object.keys(tag).filter(function(attribute) {
      return !(attribute === TAG_PROPERTIES.INNER_HTML || attribute === TAG_PROPERTIES.CSS_TEXT);
    }).reduce(function(string, attribute) {
      var attr = typeof tag[attribute] === "undefined" ? attribute : attribute + '="' + encodeSpecialCharacters(tag[attribute], encode) + '"';
      return string ? string + " " + attr : attr;
    }, "");
    var tagContent = tag.innerHTML || tag.cssText || "";
    var isSelfClosing = SELF_CLOSING_TAGS.indexOf(type) === -1;
    return str + "<" + type + " " + HELMET_ATTRIBUTE + '="true" ' + attributeHtml + (isSelfClosing ? "/>" : ">" + tagContent + "</" + type + ">");
  }, "");
};
var convertElementAttributestoReactProps = function convertElementAttributestoReactProps2(attributes) {
  var initProps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  return Object.keys(attributes).reduce(function(obj, key) {
    obj[REACT_TAG_MAP[key] || key] = attributes[key];
    return obj;
  }, initProps);
};
var convertReactPropstoHtmlAttributes = function convertReactPropstoHtmlAttributes2(props) {
  var initAttributes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  return Object.keys(props).reduce(function(obj, key) {
    obj[HTML_TAG_MAP[key] || key] = props[key];
    return obj;
  }, initAttributes);
};
var generateTitleAsReactComponent = function generateTitleAsReactComponent2(type, title, attributes) {
  var _initProps;
  var initProps = (_initProps = {
    key: title
  }, _initProps[HELMET_ATTRIBUTE] = true, _initProps);
  var props = convertElementAttributestoReactProps(attributes, initProps);
  return [React__default$1.createElement(TAG_NAMES.TITLE, props, title)];
};
var generateTagsAsReactComponent = function generateTagsAsReactComponent2(type, tags) {
  return tags.map(function(tag, i) {
    var _mappedTag;
    var mappedTag = (_mappedTag = {
      key: i
    }, _mappedTag[HELMET_ATTRIBUTE] = true, _mappedTag);
    Object.keys(tag).forEach(function(attribute) {
      var mappedAttribute = REACT_TAG_MAP[attribute] || attribute;
      if (mappedAttribute === TAG_PROPERTIES.INNER_HTML || mappedAttribute === TAG_PROPERTIES.CSS_TEXT) {
        var content = tag.innerHTML || tag.cssText;
        mappedTag.dangerouslySetInnerHTML = { __html: content };
      } else {
        mappedTag[mappedAttribute] = tag[attribute];
      }
    });
    return React__default$1.createElement(type, mappedTag);
  });
};
var getMethodsForTag = function getMethodsForTag2(type, tags, encode) {
  switch (type) {
    case TAG_NAMES.TITLE:
      return {
        toComponent: function toComponent() {
          return generateTitleAsReactComponent(type, tags.title, tags.titleAttributes);
        },
        toString: function toString() {
          return generateTitleAsString(type, tags.title, tags.titleAttributes, encode);
        }
      };
    case ATTRIBUTE_NAMES.BODY:
    case ATTRIBUTE_NAMES.HTML:
      return {
        toComponent: function toComponent() {
          return convertElementAttributestoReactProps(tags);
        },
        toString: function toString() {
          return generateElementAttributesAsString(tags);
        }
      };
    default:
      return {
        toComponent: function toComponent() {
          return generateTagsAsReactComponent(type, tags);
        },
        toString: function toString() {
          return generateTagsAsString(type, tags, encode);
        }
      };
  }
};
var mapStateOnServer = function mapStateOnServer2(_ref) {
  var baseTag = _ref.baseTag, bodyAttributes = _ref.bodyAttributes, encode = _ref.encode, htmlAttributes = _ref.htmlAttributes, linkTags = _ref.linkTags, metaTags = _ref.metaTags, noscriptTags = _ref.noscriptTags, scriptTags = _ref.scriptTags, styleTags = _ref.styleTags, _ref$title = _ref.title, title = _ref$title === void 0 ? "" : _ref$title, titleAttributes = _ref.titleAttributes;
  return {
    base: getMethodsForTag(TAG_NAMES.BASE, baseTag, encode),
    bodyAttributes: getMethodsForTag(ATTRIBUTE_NAMES.BODY, bodyAttributes, encode),
    htmlAttributes: getMethodsForTag(ATTRIBUTE_NAMES.HTML, htmlAttributes, encode),
    link: getMethodsForTag(TAG_NAMES.LINK, linkTags, encode),
    meta: getMethodsForTag(TAG_NAMES.META, metaTags, encode),
    noscript: getMethodsForTag(TAG_NAMES.NOSCRIPT, noscriptTags, encode),
    script: getMethodsForTag(TAG_NAMES.SCRIPT, scriptTags, encode),
    style: getMethodsForTag(TAG_NAMES.STYLE, styleTags, encode),
    title: getMethodsForTag(TAG_NAMES.TITLE, { title, titleAttributes }, encode)
  };
};
var Helmet = function Helmet2(Component) {
  var _class, _temp;
  return _temp = _class = function(_React$Component) {
    inherits(HelmetWrapper, _React$Component);
    function HelmetWrapper() {
      classCallCheck(this, HelmetWrapper);
      return possibleConstructorReturn(this, _React$Component.apply(this, arguments));
    }
    HelmetWrapper.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
      return !isEqual2(this.props, nextProps);
    };
    HelmetWrapper.prototype.mapNestedChildrenToProps = function mapNestedChildrenToProps(child, nestedChildren) {
      if (!nestedChildren) {
        return null;
      }
      switch (child.type) {
        case TAG_NAMES.SCRIPT:
        case TAG_NAMES.NOSCRIPT:
          return {
            innerHTML: nestedChildren
          };
        case TAG_NAMES.STYLE:
          return {
            cssText: nestedChildren
          };
      }
      throw new Error("<" + child.type + " /> elements are self-closing and can not contain children. Refer to our API for more information.");
    };
    HelmetWrapper.prototype.flattenArrayTypeChildren = function flattenArrayTypeChildren(_ref) {
      var _babelHelpers$extends;
      var child = _ref.child, arrayTypeChildren = _ref.arrayTypeChildren, newChildProps = _ref.newChildProps, nestedChildren = _ref.nestedChildren;
      return _extends({}, arrayTypeChildren, (_babelHelpers$extends = {}, _babelHelpers$extends[child.type] = [].concat(arrayTypeChildren[child.type] || [], [_extends({}, newChildProps, this.mapNestedChildrenToProps(child, nestedChildren))]), _babelHelpers$extends));
    };
    HelmetWrapper.prototype.mapObjectTypeChildren = function mapObjectTypeChildren(_ref2) {
      var _babelHelpers$extends2, _babelHelpers$extends3;
      var child = _ref2.child, newProps = _ref2.newProps, newChildProps = _ref2.newChildProps, nestedChildren = _ref2.nestedChildren;
      switch (child.type) {
        case TAG_NAMES.TITLE:
          return _extends({}, newProps, (_babelHelpers$extends2 = {}, _babelHelpers$extends2[child.type] = nestedChildren, _babelHelpers$extends2.titleAttributes = _extends({}, newChildProps), _babelHelpers$extends2));
        case TAG_NAMES.BODY:
          return _extends({}, newProps, {
            bodyAttributes: _extends({}, newChildProps)
          });
        case TAG_NAMES.HTML:
          return _extends({}, newProps, {
            htmlAttributes: _extends({}, newChildProps)
          });
      }
      return _extends({}, newProps, (_babelHelpers$extends3 = {}, _babelHelpers$extends3[child.type] = _extends({}, newChildProps), _babelHelpers$extends3));
    };
    HelmetWrapper.prototype.mapArrayTypeChildrenToProps = function mapArrayTypeChildrenToProps(arrayTypeChildren, newProps) {
      var newFlattenedProps = _extends({}, newProps);
      Object.keys(arrayTypeChildren).forEach(function(arrayChildName) {
        var _babelHelpers$extends4;
        newFlattenedProps = _extends({}, newFlattenedProps, (_babelHelpers$extends4 = {}, _babelHelpers$extends4[arrayChildName] = arrayTypeChildren[arrayChildName], _babelHelpers$extends4));
      });
      return newFlattenedProps;
    };
    HelmetWrapper.prototype.warnOnInvalidChildren = function warnOnInvalidChildren(child, nestedChildren) {
      if (process.env.NODE_ENV !== "production") {
        if (!VALID_TAG_NAMES.some(function(name) {
          return child.type === name;
        })) {
          if (typeof child.type === "function") {
            return warn("You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.");
          }
          return warn("Only elements types " + VALID_TAG_NAMES.join(", ") + " are allowed. Helmet does not support rendering <" + child.type + "> elements. Refer to our API for more information.");
        }
        if (nestedChildren && typeof nestedChildren !== "string" && (!Array.isArray(nestedChildren) || nestedChildren.some(function(nestedChild) {
          return typeof nestedChild !== "string";
        }))) {
          throw new Error("Helmet expects a string as a child of <" + child.type + ">. Did you forget to wrap your children in braces? ( <" + child.type + ">{``}</" + child.type + "> ) Refer to our API for more information.");
        }
      }
      return true;
    };
    HelmetWrapper.prototype.mapChildrenToProps = function mapChildrenToProps(children, newProps) {
      var _this2 = this;
      var arrayTypeChildren = {};
      React__default$1.Children.forEach(children, function(child) {
        if (!child || !child.props) {
          return;
        }
        var _child$props = child.props, nestedChildren = _child$props.children, childProps = objectWithoutProperties(_child$props, ["children"]);
        var newChildProps = convertReactPropstoHtmlAttributes(childProps);
        _this2.warnOnInvalidChildren(child, nestedChildren);
        switch (child.type) {
          case TAG_NAMES.LINK:
          case TAG_NAMES.META:
          case TAG_NAMES.NOSCRIPT:
          case TAG_NAMES.SCRIPT:
          case TAG_NAMES.STYLE:
            arrayTypeChildren = _this2.flattenArrayTypeChildren({
              child,
              arrayTypeChildren,
              newChildProps,
              nestedChildren
            });
            break;
          default:
            newProps = _this2.mapObjectTypeChildren({
              child,
              newProps,
              newChildProps,
              nestedChildren
            });
            break;
        }
      });
      newProps = this.mapArrayTypeChildrenToProps(arrayTypeChildren, newProps);
      return newProps;
    };
    HelmetWrapper.prototype.render = function render() {
      var _props = this.props, children = _props.children, props = objectWithoutProperties(_props, ["children"]);
      var newProps = _extends({}, props);
      if (children) {
        newProps = this.mapChildrenToProps(children, newProps);
      }
      return React__default$1.createElement(Component, newProps);
    };
    createClass(HelmetWrapper, null, [{
      key: "canUseDOM",
      // Component.peek comes from react-side-effect:
      // For testing, you may use a static peek() method available on the returned component.
      // It lets you get the current state without resetting the mounted instance stack.
      // Don’t use it for anything other than testing.
      /**
       * @param {Object} base: {"target": "_blank", "href": "http://mysite.com/"}
       * @param {Object} bodyAttributes: {"className": "root"}
       * @param {String} defaultTitle: "Default Title"
       * @param {Boolean} defer: true
       * @param {Boolean} encodeSpecialCharacters: true
       * @param {Object} htmlAttributes: {"lang": "en", "amp": undefined}
       * @param {Array} link: [{"rel": "canonical", "href": "http://mysite.com/example"}]
       * @param {Array} meta: [{"name": "description", "content": "Test description"}]
       * @param {Array} noscript: [{"innerHTML": "<img src='http://mysite.com/js/test.js'"}]
       * @param {Function} onChangeClientState: "(newState) => console.log(newState)"
       * @param {Array} script: [{"type": "text/javascript", "src": "http://mysite.com/js/test.js"}]
       * @param {Array} style: [{"type": "text/css", "cssText": "div { display: block; color: blue; }"}]
       * @param {String} title: "Title"
       * @param {Object} titleAttributes: {"itemprop": "name"}
       * @param {String} titleTemplate: "MySite.com - %s"
       */
      set: function set$$1(canUseDOM2) {
        Component.canUseDOM = canUseDOM2;
      }
    }]);
    return HelmetWrapper;
  }(React__default$1.Component), _class.propTypes = {
    base: PropTypes.object,
    bodyAttributes: PropTypes.object,
    children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
    defaultTitle: PropTypes.string,
    defer: PropTypes.bool,
    encodeSpecialCharacters: PropTypes.bool,
    htmlAttributes: PropTypes.object,
    link: PropTypes.arrayOf(PropTypes.object),
    meta: PropTypes.arrayOf(PropTypes.object),
    noscript: PropTypes.arrayOf(PropTypes.object),
    onChangeClientState: PropTypes.func,
    script: PropTypes.arrayOf(PropTypes.object),
    style: PropTypes.arrayOf(PropTypes.object),
    title: PropTypes.string,
    titleAttributes: PropTypes.object,
    titleTemplate: PropTypes.string
  }, _class.defaultProps = {
    defer: true,
    encodeSpecialCharacters: true
  }, _class.peek = Component.peek, _class.rewind = function() {
    var mappedState = Component.rewind();
    if (!mappedState) {
      mappedState = mapStateOnServer({
        baseTag: [],
        bodyAttributes: {},
        htmlAttributes: {},
        linkTags: [],
        metaTags: [],
        noscriptTags: [],
        scriptTags: [],
        styleTags: [],
        title: "",
        titleAttributes: {}
      });
    }
    return mappedState;
  }, _temp;
};
var NullComponent = function NullComponent2() {
  return null;
};
var HelmetSideEffects = withSideEffect$1(reducePropsToState, handleClientStateChange, mapStateOnServer)(NullComponent);
var HelmetExport = Helmet(HelmetSideEffects);
HelmetExport.renderStatic = HelmetExport.rewind;
const MetaComponent = (props) => {
  const canonicalURL = props.location ? `${props.location.protocol}//${props.location.host}${window.location.pathname}` : "";
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(HelmetExport, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx("title", { children: props.title }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("meta", { name: "description", content: props.description }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("meta", { name: "keywords", content: props.keywords }),
    props.location && /* @__PURE__ */ jsxRuntimeExports.jsx("link", { rel: "canonical", href: `${canonicalURL}` })
  ] });
};
MetaComponent.propTypes = {
  title: PropTypes.string,
  keywords: PropTypes.string,
  description: PropTypes.string,
  image: PropTypes.string,
  schema: PropTypes.arrayOf(PropTypes.object),
  location: PropTypes.object
};
({
  data: PropTypes.arrayOf(PropTypes.object)
});
const migrateToPathWithId = (redirectionLink, idField = "id") => {
  return {
    redirectionPathWithId: `${redirectionLink}/:id`,
    idField
  };
};
const migrateRoutesToUseParams = (routes) => {
  const updatedRoutes = { ...routes };
  Object.keys(updatedRoutes).forEach((key) => {
    if (key.startsWith("VIEW_") || key.startsWith("EDIT_") || key.startsWith("DETAIL_") || key.includes("_VIEW_") || key.includes("_EDIT_") || key.includes("_DETAIL_")) {
      if (!updatedRoutes[key].includes(":")) {
        updatedRoutes[key] = `${updatedRoutes[key]}/:id`;
      }
    }
  });
  return updatedRoutes;
};
const createParameterizedNavigationHandler = (navigate, basePath, idExtractor = (row) => row.id) => {
  return (row) => {
    const id = idExtractor(row);
    navigate(generateRouteWithId(basePath, id));
  };
};
const updateTableConfigForParameterizedNavigation = (tableConfig, pathWithIdField, idField = "id") => {
  const { ...rest } = tableConfig;
  return {
    ...rest,
    redirectionPathWithId: pathWithIdField,
    idField
  };
};
export {
  COMMON_DATE_VALIDATIONS as C,
  MenuFilter as M,
  StorageUtils as S,
  MenuFilterService as a,
  MetaComponent as b,
  ModuleAccessService as c,
  anyDateValidation as d,
  businessDateValidation as e,
  conditionalDateValidation as f,
  createCustomMessages as g,
  createDateValidation as h,
  createParameterizedNavigationHandler as i,
  dateRangeValidation as j,
  dateTimeValidation as k,
  dateValidation as l,
  fileSize as m,
  futureDateValidation as n,
  getCountry as o,
  migrateRoutesToUseParams as p,
  migrateToPathWithId as q,
  pastDateValidation as r,
  updateTableConfigForParameterizedNavigation as u
};
//# sourceMappingURL=migration-utils-CAWeXGji.esm.js.map
