import { a as printRequiredElementError } from './index-50fca186.js';

const GASCO_CONTENT_TAG_NAME = 'GASCO-CONTENT';
const GASCO_CONTENT_ELEMENT_SELECTOR = 'gasco-content';
const GASCO_CONTENT_CLASS_SELECTOR = '.gasco-content-scroll-host';
/**
 * Selector used for implementations reliant on `<gasco-content>` for scroll event changes.
 *
 * Developers should use the `.gasco-content-scroll-host` selector to target the element emitting
 * scroll events. With virtual scroll implementations this will be the host element for
 * the scroll viewport.
 */
const GASCO_CONTENT_SELECTOR = `${GASCO_CONTENT_ELEMENT_SELECTOR}, ${GASCO_CONTENT_CLASS_SELECTOR}`;
const isGascoContent = (el) => el && el.tagName === GASCO_CONTENT_TAG_NAME;
/**
 * Queries the element matching the selector for IonContent.
 * See GASCO_CONTENT_SELECTOR for the selector used.
 */
const findGascoContent = (el) => {
  /**
   * First we try to query the custom scroll host selector in cases where
   * the implementation is using an outer `gasco-content` with an inner custom
   * scroll container.
   */
  const customContentHost = el.querySelector(GASCO_CONTENT_CLASS_SELECTOR);
  if (customContentHost) {
    return customContentHost;
  }
  return el.querySelector(GASCO_CONTENT_SELECTOR);
};
/**
 * Queries the closest element matching the selector for GascoContent.
 */
const findClosestGascoContent = (el) => {
  return el.closest(GASCO_CONTENT_SELECTOR);
};
/**
 * Prints an error informing developers that an implementation requires an element to be used
 * within either the `gasco-content` selector or the `.gasco-content-scroll-host` class.
 */
const printGascoContentErrorMsg = (el) => {
  return printRequiredElementError(el, GASCO_CONTENT_ELEMENT_SELECTOR);
};
/**
 * Several components in Ionic need to prevent scrolling
 * during a gesture (card modal, range, item sliding, etc).
 * Use this utility to account for gasco-content and custom content hosts.
 */
const disableContentScrollY = (contentEl) => {
  if (isGascoContent(contentEl)) {
    const gascoContent = contentEl;
    const initialScrollY = gascoContent.scrollY;
    gascoContent.scrollY = false;
    /**
     * This should be passed into resetContentScrollY
     * so that we can revert gasco-content's scrollY to the
     * correct state. For example, if scrollY = false
     * initially, we do not want to enable scrolling
     * when we call resetContentScrollY.
     */
    return initialScrollY;
  }
  else {
    contentEl.style.setProperty('overflow', 'hidden');
    return true;
  }
};
const resetContentScrollY = (contentEl, initialScrollY) => {
  if (isGascoContent(contentEl)) {
    contentEl.scrollY = initialScrollY;
  }
  else {
    contentEl.style.removeProperty('overflow');
  }
};

export { findClosestGascoContent as a, disableContentScrollY as d, findGascoContent as f, printGascoContentErrorMsg as p, resetContentScrollY as r };
