import { Node_Type } from "./../../ricos-schema/legacy/wix/rich_content/v1/index.js";
const StrikethroughState = {
  Enabled: "enabled",
  Disabled: "disabled"
};
const getInnermostCheckboxListItemAtPos = ($pos) => {
  for (let depth = $pos.depth; depth > 0; depth--) {
    const node = $pos.node(depth);
    if (node.type.name !== Node_Type.LIST_ITEM) {
      continue;
    }
    const parent = $pos.node(depth - 1);
    if (parent.type.name === Node_Type.CHECKBOX_LIST) {
      return { checked: node.attrs.checked === true };
    }
  }
  return null;
};
const getStrikethroughStateAtPosition = ($pos) => getInnermostCheckboxListItemAtPos($pos)?.checked ? StrikethroughState.Disabled : StrikethroughState.Enabled;
const collectStrikethroughStates = (state) => {
  const { from, to } = state.selection;
  if (from === to) {
    return [getStrikethroughStateAtPosition(state.doc.resolve(from))];
  }
  const states = [];
  state.doc.nodesBetween(from, to, (node, pos) => {
    if (!node.isText) {
      return;
    }
    const textFrom = Math.max(from, pos);
    const textTo = Math.min(to, pos + node.nodeSize);
    states.push(getStrikethroughStateAtPosition(state.doc.resolve(textFrom)));
    if (textTo > textFrom + 1) {
      states.push(getStrikethroughStateAtPosition(state.doc.resolve(textTo - 1)));
    }
  });
  return states;
};
const isStrikethroughBlockedByCheckboxListSelection = (state) => {
  const states = collectStrikethroughStates(state);
  return states.length > 0 && states.every((s) => s === StrikethroughState.Disabled);
};
export {
  isStrikethroughBlockedByCheckboxListSelection
};
//# sourceMappingURL=is-strikethrough-blocked-by-checkbox-list-selection.js.map
