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);

// packages/commands/src/store/reducer.js
var reducer_exports = {};
__export(reducer_exports, {
  default: () => reducer_default
});
module.exports = __toCommonJS(reducer_exports);
var import_data = require("@wordpress/data");
function commands(state = {}, action) {
  switch (action.type) {
    case "REGISTER_COMMAND":
      return {
        ...state,
        [action.name]: {
          name: action.name,
          label: action.label,
          searchLabel: action.searchLabel,
          context: action.context,
          callback: action.callback,
          icon: action.icon,
          keywords: action.keywords
        }
      };
    case "UNREGISTER_COMMAND": {
      const { [action.name]: _, ...remainingState } = state;
      return remainingState;
    }
  }
  return state;
}
function commandLoaders(state = {}, action) {
  switch (action.type) {
    case "REGISTER_COMMAND_LOADER":
      return {
        ...state,
        [action.name]: {
          name: action.name,
          context: action.context,
          hook: action.hook
        }
      };
    case "UNREGISTER_COMMAND_LOADER": {
      const { [action.name]: _, ...remainingState } = state;
      return remainingState;
    }
  }
  return state;
}
function isOpen(state = false, action) {
  switch (action.type) {
    case "OPEN":
      return true;
    case "CLOSE":
      return false;
  }
  return state;
}
function context(state = "root", action) {
  switch (action.type) {
    case "SET_CONTEXT":
      return action.context;
  }
  return state;
}
var reducer = (0, import_data.combineReducers)({
  commands,
  commandLoaders,
  isOpen,
  context
});
var reducer_default = reducer;
//# sourceMappingURL=reducer.cjs.map
