openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 2.25 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{lo as t}from"./control-ui-connection-Bfj9beF_.js";import{bE as n,xE as r}from"./control-ui-boot-shared-DFTSUQQ0.js";var i,a,o,s,c;function l(){return(l=e((()=>{n(),i=44,a=.15,o=7,s=1.25,c=class{constructor(e,t){this.host=e,this.requestOpen=t,this.swipe=null,this.stops=[],this.cancel=()=>this.reset(),this.handleStart=e=>{if(this.reset(),!this.canOpen()||e.touches.length!==1)return;let t=e.composedPath(),n=t.find(e=>e instanceof HTMLElement&&e.classList.contains(`content`));if(!n)return;let r=t.slice(0,t.indexOf(n)).some(e=>e instanceof Element?e.matches(`a, button, input, textarea, select, pre, [role='slider'], [contenteditable]:not([contenteditable='false'])`)?!0:e instanceof HTMLElement&&e.scrollWidth>e.clientWidth+1:!1),i=e.touches[0];!r&&i&&(this.swipe={identifier:i.identifier,startX:i.clientX,startY:i.clientY,lockedHorizontal:!1})},this.handleMove=e=>{let t=this.swipe,n=t?Array.from(e.touches).find(e=>e.identifier===t.identifier):void 0;if(!this.canOpen()||!t||e.touches.length!==1||!n){this.cancel();return}let r=n.clientX-t.startX,i=n.clientY-t.startY;if(t.lockedHorizontal){e.preventDefault(),this.openAfterSwipe(r);return}let a=Math.abs(r),c=Math.abs(i);Math.max(a,c)<o||(r>0&&a>=c*s?(t.lockedHorizontal=!0,e.preventDefault(),this.openAfterSwipe(r)):(r<=-7||c>=a*s)&&this.reset())},this.handleEnd=e=>{let t=this.swipe,n=t?Array.from(e.changedTouches).find(e=>e.identifier===t.identifier):void 0;if(!t||!n||!t.lockedHorizontal||!this.canOpen()){this.reset();return}let r=n.clientX-t.startX;this.openAfterSwipe(r),this.reset()}}canOpen(){return r()&&!this.host.navDrawerOpen&&!this.host.onboardingMode&&!document.openClawModalLayers?.size}connect(){this.stops=[t(this.host.element,`touchstart`,this.handleStart,{passive:!0}),t(this.host.element,`touchmove`,this.handleMove,{passive:!1}),t(this.host.element,`touchend`,this.handleEnd,{passive:!0}),t(this.host.element,`touchcancel`,this.cancel,{passive:!0})]}disconnect(){this.stops.forEach(e=>e()),this.reset()}reset(){this.swipe=null}openAfterSwipe(e){let t=this.host.navDrawerElement?.getBoundingClientRect().width??0;e>=Math.max(i,t*a)&&(this.reset(),this.requestOpen())}}})))()}l();export{c as NavDrawerSwipeOwner};