"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/BreadcrumbMenu/breadcrumbStore.ts
var breadcrumbStore_exports = {};
__export(breadcrumbStore_exports, {
  useBreadcrumb: () => useBreadcrumb,
  useBreadcrumbStore: () => useBreadcrumbStore
});
module.exports = __toCommonJS(breadcrumbStore_exports);
var import_zustand = require("zustand");
var useBreadcrumbStore = (0, import_zustand.create)((set, get) => ({
  breadcrumbs: {},
  setBreadcrumbs: (namespace, items) => {
    set((state) => ({
      breadcrumbs: {
        ...state.breadcrumbs,
        [namespace]: items
      }
    }));
  },
  addBreadcrumb: (namespace, item) => {
    set((state) => {
      const current = state.breadcrumbs[namespace] || [];
      return {
        breadcrumbs: {
          ...state.breadcrumbs,
          [namespace]: [...current, item]
        }
      };
    });
  },
  updateBreadcrumb: (namespace, itemId, updates) => {
    set((state) => {
      const current = state.breadcrumbs[namespace] || [];
      return {
        breadcrumbs: {
          ...state.breadcrumbs,
          [namespace]: current.map(
            (item) => item.id === itemId ? { ...item, ...updates } : item
          )
        }
      };
    });
  },
  removeBreadcrumbFrom: (namespace, itemId) => {
    set((state) => {
      const current = state.breadcrumbs[namespace] || [];
      const index = current.findIndex((item) => item.id === itemId);
      if (index === -1) return state;
      return {
        breadcrumbs: {
          ...state.breadcrumbs,
          [namespace]: current.slice(0, index)
        }
      };
    });
  },
  sliceBreadcrumbs: (namespace, index) => {
    set((state) => {
      const current = state.breadcrumbs[namespace] || [];
      return {
        breadcrumbs: {
          ...state.breadcrumbs,
          [namespace]: current.slice(0, index + 1)
        }
      };
    });
  },
  clearBreadcrumbs: (namespace) => {
    set((state) => {
      const { [namespace]: _, ...rest } = state.breadcrumbs;
      return {
        breadcrumbs: rest
      };
    });
  },
  getBreadcrumbs: (namespace) => {
    return get().breadcrumbs[namespace] || [];
  }
}));
var useBreadcrumb = (namespace) => {
  const store = useBreadcrumbStore();
  const breadcrumbs = store.breadcrumbs[namespace] || [];
  return {
    breadcrumbs,
    /**
     * Define todos os breadcrumbs de uma vez
     */
    setBreadcrumbs: (items) => {
      store.setBreadcrumbs(namespace, items);
    },
    /**
     * Adiciona um novo breadcrumb ao final
     */
    addBreadcrumb: (item) => {
      store.addBreadcrumb(namespace, item);
    },
    /**
     * Atualiza um breadcrumb existente
     */
    updateBreadcrumb: (itemId, updates) => {
      store.updateBreadcrumb(namespace, itemId, updates);
    },
    /**
     * Remove um breadcrumb e todos os seguintes
     */
    removeBreadcrumbFrom: (itemId) => {
      store.removeBreadcrumbFrom(namespace, itemId);
    },
    /**
     * Mantém apenas os breadcrumbs até o índice especificado (inclusivo)
     */
    sliceBreadcrumbs: (index) => {
      store.sliceBreadcrumbs(namespace, index);
    },
    /**
     * Limpa todos os breadcrumbs
     */
    clearBreadcrumbs: () => {
      store.clearBreadcrumbs(namespace);
    }
  };
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useBreadcrumb,
  useBreadcrumbStore
});
//# sourceMappingURL=index.js.map