import { jsx, jsxs } from "react/jsx-runtime";
import { aV as SetCache, aW as cacheHas, aX as isArrayLikeObject, aY as baseRest, aZ as arrayMap, a_ as Stack, a$ as baseIsEqual, b0 as isObject, b1 as keys, b2 as castPath, b3 as toKey, b4 as isLength, b5 as isIndex, b6 as isArray, b7 as isArguments, b8 as isKey, aH as baseGet, b9 as identity, ba as Set, bb as setToArray, L as useSitemap, F as manifest, bc as RxHamburgerMenu } from "./use-page-data.CMUQyNAA.js";
import "@sinclair/typebox";
import { b as useBrickStyle } from "./use-section-style.DjjgfIQS.js";
import { T as TextContent } from "./TextContent.fGn2nGQK.js";
import { a as tx } from "./twind.DdSZmZu6.js";
import { B as BrickRoot } from "./BrickRoot.D_a_fRJm.js";
import { g as get } from "./get.DbXiVauf.js";
function baseFindIndex(array, predicate, fromIndex, fromRight) {
  var length = array.length, index = fromIndex + -1;
  while (++index < length) {
    if (predicate(array[index], index, array)) {
      return index;
    }
  }
  return -1;
}
function baseIsNaN(value) {
  return value !== value;
}
function strictIndexOf(array, value, fromIndex) {
  var index = fromIndex - 1, length = array.length;
  while (++index < length) {
    if (array[index] === value) {
      return index;
    }
  }
  return -1;
}
function baseIndexOf(array, value, fromIndex) {
  return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
}
function arrayIncludes(array, value) {
  var length = array == null ? 0 : array.length;
  return !!length && baseIndexOf(array, value, 0) > -1;
}
var nativeMin = Math.min;
function baseIntersection(arrays, iteratee, comparator) {
  var includes = arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array(othLength), maxLength = Infinity, result = [];
  while (othIndex--) {
    var array = arrays[othIndex];
    maxLength = nativeMin(array.length, maxLength);
    caches[othIndex] = length >= 120 && array.length >= 120 ? new SetCache(othIndex && array) : void 0;
  }
  array = arrays[0];
  var index = -1, seen = caches[0];
  outer:
    while (++index < length && result.length < maxLength) {
      var value = array[index], computed = value;
      value = value !== 0 ? value : 0;
      if (!(seen ? cacheHas(seen, computed) : includes(result, computed))) {
        othIndex = othLength;
        while (--othIndex) {
          var cache = caches[othIndex];
          if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed))) {
            continue outer;
          }
        }
        if (seen) {
          seen.push(computed);
        }
        result.push(value);
      }
    }
  return result;
}
function castArrayLikeObject(value) {
  return isArrayLikeObject(value) ? value : [];
}
var intersection = baseRest(function(arrays) {
  var mapped = arrayMap(arrays, castArrayLikeObject);
  return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped) : [];
});
var COMPARE_PARTIAL_FLAG$1 = 1, COMPARE_UNORDERED_FLAG$1 = 2;
function baseIsMatch(object, source, matchData, customizer) {
  var index = matchData.length, length = index;
  if (object == null) {
    return !length;
  }
  object = Object(object);
  while (index--) {
    var data = matchData[index];
    if (data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
      return false;
    }
  }
  while (++index < length) {
    data = matchData[index];
    var key = data[0], objValue = object[key], srcValue = data[1];
    if (data[2]) {
      if (objValue === void 0 && !(key in object)) {
        return false;
      }
    } else {
      var stack = new Stack();
      var result;
      if (!(result === void 0 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) {
        return false;
      }
    }
  }
  return true;
}
function isStrictComparable(value) {
  return value === value && !isObject(value);
}
function getMatchData(object) {
  var result = keys(object), length = result.length;
  while (length--) {
    var key = result[length], value = object[key];
    result[length] = [key, value, isStrictComparable(value)];
  }
  return result;
}
function matchesStrictComparable(key, srcValue) {
  return function(object) {
    if (object == null) {
      return false;
    }
    return object[key] === srcValue && (srcValue !== void 0 || key in Object(object));
  };
}
function baseMatches(source) {
  var matchData = getMatchData(source);
  if (matchData.length == 1 && matchData[0][2]) {
    return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  }
  return function(object) {
    return object === source || baseIsMatch(object, source, matchData);
  };
}
function baseHasIn(object, key) {
  return object != null && key in Object(object);
}
function hasPath(object, path, hasFunc) {
  path = castPath(path, object);
  var index = -1, length = path.length, result = false;
  while (++index < length) {
    var key = toKey(path[index]);
    if (!(result = object != null && hasFunc(object, key))) {
      break;
    }
    object = object[key];
  }
  if (result || ++index != length) {
    return result;
  }
  length = object == null ? 0 : object.length;
  return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
}
function hasIn(object, path) {
  return object != null && hasPath(object, path, baseHasIn);
}
var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
function baseMatchesProperty(path, srcValue) {
  if (isKey(path) && isStrictComparable(srcValue)) {
    return matchesStrictComparable(toKey(path), srcValue);
  }
  return function(object) {
    var objValue = get(object, path);
    return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  };
}
function baseProperty(key) {
  return function(object) {
    return object == null ? void 0 : object[key];
  };
}
function basePropertyDeep(path) {
  return function(object) {
    return baseGet(object, path);
  };
}
function property(path) {
  return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
}
function baseIteratee(value) {
  if (typeof value == "function") {
    return value;
  }
  if (value == null) {
    return identity;
  }
  if (typeof value == "object") {
    return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
  }
  return property(value);
}
function noop() {
}
var INFINITY = 1 / 0;
var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY) ? noop : function(values) {
  return new Set(values);
};
var LARGE_ARRAY_SIZE = 200;
function baseUniq(array, iteratee, comparator) {
  var index = -1, includes = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result;
  if (length >= LARGE_ARRAY_SIZE) {
    var set = iteratee ? null : createSet(array);
    if (set) {
      return setToArray(set);
    }
    isCommon = false;
    includes = cacheHas;
    seen = new SetCache();
  } else {
    seen = iteratee ? [] : result;
  }
  outer:
    while (++index < length) {
      var value = array[index], computed = iteratee ? iteratee(value) : value;
      value = value !== 0 ? value : 0;
      if (isCommon && computed === computed) {
        var seenIndex = seen.length;
        while (seenIndex--) {
          if (seen[seenIndex] === computed) {
            continue outer;
          }
        }
        if (iteratee) {
          seen.push(computed);
        }
        result.push(value);
      } else if (!includes(seen, computed, comparator)) {
        if (seen !== result) {
          seen.push(computed);
        }
        result.push(value);
      }
    }
  return result;
}
function uniqBy(array, iteratee) {
  return array && array.length ? baseUniq(array, baseIteratee(iteratee)) : [];
}
function Navbar({ brick, editable }) {
  const classes = useBrickStyle(brick);
  const props = brick.props;
  const pages = useSitemap();
  const navItems = pages.filter((p) => intersection(p.tags, props.linksTagsFilter ?? []).length > 0).map((p) => ({
    urlOrPageId: p.id,
    label: p.label
  })) ?? [];
  const allItems = uniqBy(
    [...navItems, ...props.staticNavItems ?? []].map((item) => {
      const href = pages.find((p) => p.id === item.urlOrPageId)?.path ?? item.urlOrPageId;
      return {
        href,
        label: item.label
      };
    }),
    (item) => item.href
  );
  const onClickNav = (e) => {
    if (editable) {
      e.preventDefault();
    }
  };
  return /* @__PURE__ */ jsx(
    BrickRoot,
    {
      brick,
      editable,
      manifest,
      as: "header",
      "data-brick-group": "container",
      "data-no-section-padding": true,
      className: tx("flex px-4 brick basis-full h-[60px]", Object.values(classes)),
      children: /* @__PURE__ */ jsxs(
        "div",
        {
          className: tx(
            "flex flex-1 items-center justify-between @lg:justify-start",
            props.linksPosition !== "center" && "@lg:gap-4"
          ),
          children: [
            /* @__PURE__ */ jsxs("div", { className: tx("flex items-center gap-3"), "data-brick-group": "brand", "data-brick-menu-offset": "70", children: [
              props.logo?.src && /* @__PURE__ */ jsx(
                "img",
                {
                  src: props.logo.src,
                  alt: props.logo.alt ?? "Logo",
                  className: `h-full max-h-[60px] w-auto flex-1`
                }
              ),
              props.brand && !props.hideBrand && /* @__PURE__ */ jsx(
                TextContent,
                {
                  as: "h1",
                  propPath: "brand.name",
                  className: tx("text-2xl font-bold flex-1"),
                  brickId: brick.id,
                  content: props.brand,
                  rawContent: props.brand,
                  editable,
                  noTextAlign: true,
                  noTextType: true,
                  noTextStrike: true,
                  inline: true
                }
              )
            ] }),
            /* @__PURE__ */ jsx(
              "nav",
              {
                "data-brick-group": "navigation",
                className: tx(
                  "hidden @desktop:flex items-center gap-2",
                  props.linksPosition === "right" && "ml-auto",
                  props.linksPosition === "center" && "mx-auto"
                ),
                children: allItems.map((item, index) => {
                  return /* @__PURE__ */ jsx(
                    "a",
                    {
                      onClick: onClickNav,
                      href: item.href,
                      className: tx("font-semibold py-2 px-4 self-stretch rounded-md", "hover:brightness-125"),
                      children: item.label
                    },
                    index
                  );
                })
              }
            ),
            /* @__PURE__ */ jsx("div", { role: "menu", className: "ml-auto @desktop:hidden items-center gap-4", "data-brick-group": "actions", children: /* @__PURE__ */ jsx(RxHamburgerMenu, { className: "w-6 h-6" }) })
          ]
        }
      )
    }
  );
}
export {
  Navbar as default
};
//# sourceMappingURL=navbar.DTftpYwt.js.map
