import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{m as t}from"./vendor-dnd-C1cICjTT.js";import{s as n}from"./vendor-markdown-Db1-9wH7.js";import{i as r}from"./api-DwzfFfgX.js";var i=e(t(),1),a=n(),o=!1;function s(e){return String(e).padStart(2,`0`)}function c(e){if(!e)return``;let t=new Date(e),n=t.getTime();return Number.isFinite(n)?`${t.getUTCFullYear()}-${s(t.getUTCMonth()+1)}-${s(t.getUTCDate())} ${s(t.getUTCHours())}:${s(t.getUTCMinutes())} UTC`:``}function l(e){let t=Math.max(0,Date.now()-new Date(e).getTime());return t<6e4?1e3:t<60*6e4?3e4:t<1440*6e4?6e4:5*6e4}function u(e){let t=(0,i.useMemo)(()=>c(e),[e]),[n,a]=(0,i.useState)(o),[,s]=(0,i.useState)(0);return(0,i.useEffect)(()=>{if(!e){o=!0,a(!0);return}let t,n=!1,r=()=>{n||(s(e=>e+1),t=window.setTimeout(r,l(e)))};return o=!0,a(!0),r(),()=>{n=!0,t!==void 0&&window.clearTimeout(t)}},[e]),e?n?r(e):t:``}function d({timestamp:e,className:t,style:n,title:r,prefix:o=``,suffix:s=``,emptyFallback:l=null}){let d=u(e),f=(0,i.useMemo)(()=>c(e),[e]);return d?(0,a.jsxs)(`time`,{className:t,style:n,dateTime:e??void 0,title:r??f,suppressHydrationWarning:!0,children:[o,d,s]}):(0,a.jsx)(a.Fragment,{children:l})}function f(e){return!!e?.closest(`button,input,textarea,select,a,[data-no-row-activate="true"],[data-sidebar-row-action="true"]`)}function p(e,t={}){let n=t.delayMs??520,r=t.moveTolerancePx??12,a=(0,i.useRef)(null),o=(0,i.useRef)(null),s=(0,i.useRef)(0),c=(0,i.useRef)(null),l=(0,i.useRef)(null),u=(0,i.useRef)(null),d=(0,i.useCallback)(()=>{c.current?.(),c.current=null},[]),p=(0,i.useCallback)(()=>{if(c.current||typeof document>`u`)return;let e=document.body.style,t=e.userSelect,n=e.getPropertyValue(`-webkit-user-select`),r=e.getPropertyValue(`-webkit-touch-callout`);e.userSelect=`none`,e.setProperty(`-webkit-user-select`,`none`),e.setProperty(`-webkit-touch-callout`,`none`),c.current=()=>{e.userSelect=t,e.setProperty(`-webkit-user-select`,n),e.setProperty(`-webkit-touch-callout`,r),window.getSelection()?.removeAllRanges()}},[]),m=(0,i.useCallback)(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},[]),h=(0,i.useCallback)(()=>{l.current?.(),l.current=null},[]),g=(0,i.useCallback)(()=>{m(),o.current=null,d(),h()},[m,d,h]);return{onPointerDown:(0,i.useCallback)(i=>{if(t.disabled||i.pointerType===`mouse`||i.button!==0||f(i.target)){g();return}let c={x:i.clientX,y:i.clientY,pointerId:i.pointerId};o.current=c,m(),p(),u.current&&=(window.clearTimeout(u.current.timer),u.current.remove(),null);let _=e=>{e.preventDefault(),e.stopPropagation()};window.addEventListener(`contextmenu`,_,!0);let v=()=>window.removeEventListener(`contextmenu`,_,!0);u.current={remove:v,timer:window.setTimeout(()=>{v(),u.current=null},n+900)},h();let y=e=>{let t=e.touches[0];t&&Math.hypot(t.clientX-c.x,t.clientY-c.y)>r&&g()},b=()=>g();window.addEventListener(`touchmove`,y,{passive:!0,capture:!0}),window.addEventListener(`scroll`,b,{passive:!0,capture:!0}),l.current=()=>{window.removeEventListener(`touchmove`,y,!0),window.removeEventListener(`scroll`,b,!0)},a.current=window.setTimeout(()=>{a.current=null;let t=o.current;!t||t.pointerId!==c.pointerId||(s.current=performance.now()+900,window.getSelection()?.removeAllRanges(),navigator.vibrate?.(12),d(),h(),e({x:c.x,y:c.y}))},n)},[g,m,n,p,r,e,t.disabled,d,h]),onPointerMove:(0,i.useCallback)(e=>{let t=o.current;!t||t.pointerId!==e.pointerId||Math.hypot(e.clientX-t.x,e.clientY-t.y)>r&&g()},[g,r]),onPointerUp:g,onPointerCancel:g,onClickCapture:(0,i.useCallback)(e=>{performance.now()>s.current||(e.preventDefault(),e.stopPropagation())},[])}}export{d as n,c as r,p as t};