"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),r=require("../utils/dom.js"),n=require("./use-document-event.js"),u=((e=u||{})[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e);exports.Action={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},exports.useQuickRelease=function(e,u){let{trigger:l,action:s,close:c,select:o}=u,i=t.useRef(null),a=t.useRef(null),d=t.useRef(null);n.useDocumentEvent(e&&null!==l,"pointerdown",(e=>{r.isNode(null==e?void 0:e.target)&&null!=l&&l.contains(e.target)&&(a.current=e.x,d.current=e.y,i.current=e.timeStamp)})),n.useDocumentEvent(e&&null!==l,"pointerup",(e=>{var t,n;let u=i.current;if(null===u||(i.current=null,!r.isHTMLorSVGElement(e.target))||Math.abs(e.x-(null!=(t=a.current)?t:e.x))<5&&Math.abs(e.y-(null!=(n=d.current)?n:e.y))<5)return;let l=s(e);switch(l.kind){case 0:return;case 1:e.timeStamp-u>200&&(o(l.target),c());break;case 2:c()}}),{capture:!0})};
//# sourceMappingURL=use-quick-release.js.map
