import{Interactable as t}from"./Interactable.prod.js";import{matchesSelector as e,nodeContains as n}from"../utils/domUtils.prod.js";import r from"../utils/is.prod.js";import{getWindow as o}from"../utils/window.prod.js";function i(t){return/^(always|never|auto)$/.test(t)?(this.options.preventDefault=t,this):r.bool(t)?(this.options.preventDefault=t?"always":"never",this):this.options.preventDefault}function s({interaction:t,event:e}){t.interactable&&t.interactable.checkAndPreventDefault(e)}export function install(t){const{Interactable:s}=t;s.prototype.preventDefault=i,s.prototype.checkAndPreventDefault=function(n){return((t,n,i)=>{const s=t.options.preventDefault;if("never"!==s)if("always"!==s){if(n.events.supportsPassive&&/^touch(start|move)$/.test(i.type)){const t=o(i.target).document,e=n.getDocOptions(t);if(!e||!e.events||!1!==e.events.passive)return}/^(mouse|pointer|touch)*(down|start)/i.test(i.type)||r.element(i.target)&&e(i.target,"input,select,textarea,[contenteditable=true],[contenteditable=true] *")||i.preventDefault()}else i.preventDefault()})(this,t,n)},t.interactions.docEvents.push({type:"dragstart",listener(e){for(const r of t.interactions.list)if(r.element&&(r.element===e.target||n(r.element,e.target)))return void r.interactable.checkAndPreventDefault(e)}})}export default{id:"core/interactablePreventDefault",install:install,listeners:["down","move","up","cancel"].reduce(((t,e)=>(t["interactions:"+e]=s,t)),{})};
//# sourceMappingURL=interactablePreventDefault.prod.js.map