"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../utils/is-html-element.mjs.js"),s=require("../drag/state/is-active.mjs.js"),t=require("../utils/is-node-or-child.mjs.js"),r=require("../utils/is-primary-pointer.mjs.js"),i=require("../utils/setup.mjs.js"),n=require("./utils/is-keyboard-accessible.mjs.js"),o=require("./utils/keyboard.mjs.js"),a=require("./utils/state.mjs.js");function u(e){return r.isPrimaryPointer(e)&&!s.isDragActive()}const d=new WeakSet;exports.press=function(s,r){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const[c,p,j]=i.setupGesture(s,l),m=e=>{const s=e.currentTarget;if(!u(e))return;if(d.has(e))return;a.isPressing.add(s),l.stopPropagation&&d.add(e);const i=r(s,e),n=(e,t)=>{window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",c),a.isPressing.has(s)&&a.isPressing.delete(s),u(e)&&"function"==typeof i&&i(e,{success:t})},o=e=>{n(e,s===window||s===document||l.useGlobalTarget||t.isNodeOrChild(s,e.target))},c=e=>{n(e,!1)};window.addEventListener("pointerup",o,p),window.addEventListener("pointercancel",c,p)};return c.forEach((s=>{(l.useGlobalTarget?window:s).addEventListener("pointerdown",m,p),e.isHTMLElement(s)&&(s.addEventListener("focus",(e=>o.enableKeyboardPress(e,p))),n.isElementKeyboardAccessible(s)||s.hasAttribute("tabindex")||(s.tabIndex=0))})),j};
//# sourceMappingURL=index.mjs.js.map
