PageSourceSearch

https://deskpet.ai/assets/use-pet-walk-motion-CsUWy5ud.js

js deskpet.ai collected 2026-10-05 11:57:06 UTC 11,233 bytes, 1 lines download raw bytes

1import{r as i,aG as Q,bE as B,aI as Z,j as l,bF as z,bG as ee,aM as te,aN as O,bH as ne,bI as re,bJ as oe,bK as ae,d as k,v as ce}from"./index-DfDz3_Zo.js";var ie=Object.defineProperty,b=(t,e)=>ie(t,"name",{value:e,configurable:!0}),G="ContextMenu",[se,Ne]=Q(G,[B]),T=B(),[ue,q]=se(G),de=b(t=>{const{__scopeContextMenu:e,children:n,onOpenChange:o,open:r,dir:a,modal:x=!0}=t,u=i.useRef(!1),[s,f]=Z({prop:r,defaultProp:!1,onChange:o,caller:G}),v=T(e);return l.jsx(ue,{scope:e,open:s,onOpenChange:f,modal:x,hasInteractedRef:u,children:l.jsx(z,{...v,dir:a,open:s,onOpenChange:f,modal:x,children:n})})},"ContextMenu"),le="ContextMenuTrigger",xe=i.forwardRef(b(function(e,n){const{__scopeContextMenu:o,disabled:r=!1,...a}=e,x=q(le,o),u=T(o),[s,f]=i.useState({x:0,y:0}),v=i.useMemo(()=>({current:{getBoundingClientRect:b(()=>DOMRect.fromRect({width:0,height:0,...s}),"getBoundingClientRect")}}),[s]),w=i.useRef(0),m=i.useCallback(()=>window.clearTimeout(w.current),[]),P=b(g=>{x.hasInteractedRef.current=!0,f({x:g.clientX,y:g.clientY}),x.onOpenChange(!0)},"handleOpen");return i.useEffect(()=>m,[m]),i.useEffect(()=>
1{r&&m()},[r,m]),l.jsxs(l.Fragment,{children:[l.jsx(ee,{...u,virtualRef:v}),l.jsx(te.span,{"data-state":x.open?"open":"closed","data-disabled":r?"":void 0,...a,ref:n,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:O(e.onContextMenu,g=>{m(),P(g),g.preventDefault()}),onPointerDown:r?e.onPointerDown:O(e.onPointerDown,X(g=>{m(),x.open&&x.onOpenChange(!1),w.current=window.setTimeout(()=>P(g),700)})),onPointerMove:r?e.onPointerMove:O(e.onPointerMove,X(m)),onPointerCancel:r?e.onPointerCancel:O(e.onPointerCancel,X(m)),onPointerUp:r?e.onPointerUp:O(e.onPointerUp,X(m))})]})},"ContextMenuTrigger")),fe=b(t=>{const{__scopeContextMenu:e,...n}=t,o=T(e);return l.jsx(ne,{...o,...n})},"ContextMenuPortal"),he="ContextMenuContent",me=i.forwardRef(b(function(e,n){const{__scopeContextMenu:o,...r}=e,a=q(he,o),x=T(o),u=i.useRef(!1);return l.jsx(re,{...x,...r,ref:n,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),!s.defaultPrevented&&u.current&&s.preventDefault(),u.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),!s.defaultPrevented&&!a.modal&&(u.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"ContextMenuContent")),ge=i.forwardRef(b(function(e,n){const{__scopeContextMenu:o,...r}=e,a=T(o);return l.jsx(oe,{...a,...r,ref:n})},"ContextMenuItem")),pe=i.forwardRef(b(function(e,n){const{__scopeContextMenu:o,...r}=e,a=T(o);return l.jsx(ae,{...a,...r,ref:n})},"ContextMenuSeparator"));function X(t){return e=>e.pointerType!=="mouse"?t(e):void 0}b(X,"whenTouchOrPen");var Me=de,Ce=xe,ve=fe,we=me,Pe=ge,Se=pe;const ye=.21,be=60;function J(t){switch(t){case"walk_left_loop":return"left";case"walk_right_loop":return"right";default:return null}}function _e(t){const n=Math.max(t.minSpeedPxPerSec??be,t.petWidth*(t.widthsPerSec??ye))*t.deltaMs/1e3;return t.direction==="left"?t.x-n:t.x+n}function Re(t){const{x:e,boundsWidth:n,petWidth:o}=t;if(!(n>0)||!(o>0))return{x:e,edge:null};const r=t.edgeMargin,a=Math.max(r,n-o-t.edgeMargin),x=Math.min(Math.max(r,e),a);let u=null;return t.direction==="left"&&e<r?u="left":t.direction==="right"&&e>a&&(u="right"),{x,edge:u}}function H(t){const{boundsWidth:e,petWidth:n}=t;if(!(e>0)||!(n>0))return Math.round(t.x);let o=t.x+n/2;return o=(o%e+e)%e,Math.round(o-n/2)}const y=8;function L(t,e,n,o){if(typeof window>"u"&&!n)return t;const r=e?.offsetWidth||e?.getBoundingClientRect().width||o?.width||192,a=e?.offsetHeight||e?.getBoundingClientRect().height||o?.height||230,x=n?.width??window.innerWidth,u=n?.height??window.innerHeight,s=Math.max(y,x-r-y),f=Math.max(y,u-a-y);return{x:Math.min(Math.max(y,Math.round(t.x)),s),y:Math.min(Math.max(y,Math.round(t.y)),f)}}function $e(t){const e=t.edgeMargin??y,{position:n,prevSize:o,nextSize:r,bounds:a}=t,x=Math.max(e,a.height-r.height-e),u=Math.max(e,a.width-r.width-e),s=n.x+o.width/2,f=Math.min(Math.max(e,Math.round(s-r.width/2)),u),v=n.y+o.height,w=Math.round(v-r.height);return{x:f,y:Math.min(Math.max(e,w),x)}}function ke({getBoundsSize:t,initialPosition:e,placeAt:n,autoPlace:o=!0,originCenter:r=null,fallbackSize:a,horizontalWrap:x=!1,clampOnWindowResize:u=!0}){const[s,f]=i.useState(e),[v,w]=i.useState(!1),[m,P]=i.useState(!1),g=i.useRef(null),M=i.useRef(e),I=i.useRef(null),_=i.useRef(null);M.current=s;const C=i.useCallback((c,d=t())=>{const h=L(c,g.current,d,a);if(!x)return h;const p=g.current?.offsetWidth||g.current?.getBoundingClientRect().width||a?.width||192;return{x:H({x:c.x,boundsWidth:d.width,petWidth:p}),y:h.y}},[a,t,x]),N=r?`${r.x},${r.y}`:null;i.useLayoutEffect(()=>{const c=t();if(c.width<=0||c.height<=0)return;if(r&&N!==I.current){I.current=N;const p=a?.width??0,W=a?.height??0,E=C({x:Math.round(r.x-p/2),y:Math.round(r.y-W/2)},c);M.current=E,f(E),P(!0);return}if(m||r||!o)return;const d=n?{x:Math.max(y,Math.round(c.width*n.x)),y:Math.max(y,Math.round(c.height*n.y)
1)}:e,h=C(d,c);M.current=h,f(h),P(!0)},[o,C,a,t,m,e,r,N,n]),i.useLayoutEffect(()=>{if(!u)return;const c=()=>{f(d=>{const h=C(d);return M.current=h,h})};return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[u,C]);const j=i.useCallback(c=>{c.button===0&&(c.preventDefault(),c.currentTarget.setPointerCapture(c.pointerId),_.current={pointerId:c.pointerId,startClientX:c.clientX,startClientY:c.clientY,startX:M.current.x,startY:M.current.y},w(!0))},[]),R=i.useCallback(c=>{const d=_.current;if(!d||d.pointerId!==c.pointerId)return;c.preventDefault();const h=C({x:d.startX+c.clientX-d.startClientX,y:d.startY+c.clientY-d.startClientY});M.current=h,f(h)},[C]),$=i.useCallback(c=>{const d=_.current;!d||d.pointerId!==c.pointerId||(c.currentTarget.hasPointerCapture(c.pointerId)&&c.currentTarget.releasePointerCapture(c.pointerId),_.current=null,w(!1),f(h=>{const p=C(h);return M.current=p,p}))},[C]),S=i.useMemo(()=>({"--pet-x":`${s.x}px`,"--pet-y":`${s.y}px`}),[s.x,s.y]);return{companionRef:g,petPosition:s,isDragging:v,companionStyle:S,handlePointerDown:j,handlePointerMove:R,finishDrag:$,setPetPosition:f,petPositionRef:M}}function Ee({...t}){return l.jsx(Me,{"data-slot":"context-menu",...t})}function Te({className:t,...e}){return l.jsx(Ce,{"data-slot":"context-menu-trigger",className:k("select-none",t),...e})}function Ie({className:t,...e}){return l.jsx(ve,{children:l.jsx(we,{"data-slot":"context-menu-content",className:k("z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...e})})}function je({className:t,inset:e,variant:n="default",...o}){return l.jsx(Pe,{"data-slot":"context-menu-item","data-inset":e,"data-variant":n,className:k("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",t),...o})}function We({className:t,...e}){return l.jsx(Se,{"data-slot":"context-menu-separator",className:k("-mx-1 my-1 h-px bg-border",t),...e})}function Fe({trigger:t,items:e,onSelect:n,menuTestId:o,disabled:r}){return r?t:l.jsxs(Ee,{children:[l.jsx(Te,{asChild:!0,children:t}),l.jsx(Ie,{className:"z-[2147483647] min-w-44","data-testid":o,children:e.map(a=>l.jsxs(i.Fragment,{children:[a.separatorBefore?l.jsx(We,{}):null,l.jsxs(je,{"data-testid":`${o}-item-${a.id}`,disabled:a.disabled,onSelect:()=>n(a.id),children:[l.jsx("span",{children:a.label}),a.active?l.jsx(ce,{className:"ml-auto size-3.5 opacity-90"}):null]})]},a.id))})]})}function De(t){const e=t.motionConfig?.boxMotion;if(e){if(!e.enabled)return null;const o=e.startAtSec??0,r=e.endAtSec??null,a=Number.isFinite(t.currentTimeSec)?t.currentTimeSec:0;return a<o||r!=null&&a>=r?null:{direction:e.direction,startAtSec:o,endAtSec:r,...e.speedWidthsPerSec!=null?{speedWidthsPerSec:e.speedWidthsPerSec}:{},...e.minSpeedPxPerSec!=null?{minSpeedPxPerSec:e.minSpeedPxPerSec}:{}}
1}const n=J(t.actionKey);return n?{direction:n,startAtSec:0,endAtSec:null}:null}function Ae(t){const e=t.motionConfig?.boxMotion;return e?e.enabled:J(t.actionKey)!=null}function Oe(t){const e=t.mediaUrl?.trim()??"";if(!e)return!0;const n=t.videoSrc?.trim()??"";return n?n===e:!1}function Ye({actionKey:t,motionConfig:e,mediaUrl:n,videoRef:o,enabled:r=!0,isDragging:a,getBoundsSize:x,petSize:u,companionRef:s,petPositionRef:f,setPetPosition:v,onHitEdge:w,horizontalWrap:m=!1}){const P=i.useRef(null),g=i.useRef(null),M=i.useRef(e);M.current=e;const I=i.useRef(n);I.current=n;const _=i.useRef(w);_.current=w,i.useEffect(()=>{if(!r){P.current=null;return}const C=Ae({actionKey:t,motionConfig:M.current});if(P.current&&!C){const S=f.current,c=x(),d=L(S,s.current,c,u),h=m?{x:H({x:S.x,boundsWidth:c.width,petWidth:u.width}),y:d.y}:d;(h.x!==S.x||h.y!==S.y)&&(f.current=h,v(h)),P.current=null,g.current=null}if(!C||a){C||(P.current=null);return}let j=0,R=0;const $=S=>{if(j=window.requestAnimationFrame($),!R){R=S;return}const c=Math.min(48,S-R);if(R=S,c<=0)return;const d=o?.current??null,h=d?.getAttribute("src")??"";if(!Oe({mediaUrl:I.current,videoSrc:h})||d&&(d.paused||d.ended))return;const p=De({actionKey:t,motionConfig:M.current,currentTimeSec:d?.currentTime??0});if(P.current=p?.direction??null,!p)return;const W=f.current,E=x(),K=_e({x:W.x,direction:p.direction,deltaMs:c,petWidth:u.width,...p.speedWidthsPerSec!=null?{widthsPerSec:p.speedWidthsPerSec}:{},...p.minSpeedPxPerSec!=null?{minSpeedPxPerSec:p.minSpeedPxPerSec}:{}}
1),V=L({x:W.x,y:W.y},s.current,E,u);let F,D=null;if(m)F=H({x:K,boundsWidth:E.width,petWidth:u.width});else{const A=Re({x:K,boundsWidth:E.width,petWidth:u.width,edgeMargin:0,direction:p.direction});F=A.x,D=A.edge}const U={x:Math.round(F),y:V.y};if(f.current=U,v(U),D){const A=Date.now(),Y=g.current;(!Y||Y.edge!==D||A-Y.at>=900)&&(g.current={edge:D,at:A},_.current?.(D))}};return j=window.requestAnimationFrame($),()=>{window.cancelAnimationFrame(j)}},[t,s,r,x,a,n,e,w,f,u,v,o,m])}export{Fe as P,Ye as a,L as c,$e as r,ke as u,H as w};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.