import{n as e,s as t}from"./rolldown-runtime-Czos8NxU.js";import{El as n,Tl as r,vl as i}from"./app-initial~app-main~worktree-init-v2-page~appgen-settings-page~page~appgen-publication-ter~fzo5ij6p-BKVLyD1q.js";import{An as a,On as o}from"./app-initial~app-main~remote-conversation-page~new-thread-panel-page~onboarding-page~project~okyna5mq-CgvyzQvO.js";import{nx as s,rx as c}from"./app-initial~app-main~new-thread-panel-page-BZHGOlMi.js";var l,u=e((()=>{l=``+new URL(`bsod-spritesheet-v4-BRrRVy1T.webp`,import.meta.url).href})),d,f=e((()=>{d=``+new URL(`codex-spritesheet-v4-Bl6P89d_.webp`,import.meta.url).href})),p,m=e((()=>{p=``+new URL(`dewey-spritesheet-v4-gAYk_M9g.webp`,import.meta.url).href})),h,g=e((()=>{h=``+new URL(`fireball-spritesheet-v4-BtU8R9Qp.webp`,import.meta.url).href})),_,v=e((()=>{_=``+new URL(`hoots-spritesheet-v4-BYSNdvho.webp`,import.meta.url).href})),y,b=e((()=>{y=``+new URL(`null-signal-spritesheet-v4-CCoTR-8t.webp`,import.meta.url).href})),x,S=e((()=>{x=``+new URL(`rocky-spritesheet-v4-3RlTi26B.webp`,import.meta.url).href})),C,w=e((()=>{C=``+new URL(`seedy-spritesheet-v4-CdlE_fn9.webp`,import.meta.url).href})),T,E=e((()=>{T=``+new URL(`stacky-spritesheet-v4-CaUJd4fY.webp`,import.meta.url).href}));function D(e){let t=(0,j.c)(6),{avatarRef:n,isAnimationEnabled:r,prefersReducedMotion:i,state:a}=e,o=r===void 0?!0:r,s=a===void 0?`idle`:a,c,l;t[0]!==n||t[1]!==o||t[2]!==i||t[3]!==s?(c=()=>{let e=n.current;if(e==null)return;let t=O(s,i||!o),r=t.frames,a=0,c=null;if(e.style.backgroundPosition=A(r[a]),r.length===1)return;let l=()=>{c=window.setTimeout(()=>{let n=a+1;if(n>=r.length){if(t.loopStartIndex!=null){a=t.loopStartIndex,e.style.backgroundPosition=A(r[a]),l();return}c=null;return}a=n,e.style.backgroundPosition=A(r[a]),l()},r[a].frameDurationMs)};return l(),()=>{c!=null&&window.clearTimeout(c)}},l=[n,o,i,s],t[0]=n,t[1]=o,t[2]=i,t[3]=s,t[4]=c,t[5]=l):(c=t[4],l=t[5]),(0,M.useEffect)(c,l)}function O(e,t){let n=R[e];if(t)return{frames:[n[0]],loopStartIndex:null};if(e===`idle`)return{frames:L,loopStartIndex:0};let r=[...n,...n,...n];return{frames:[...r,...L],loopStartIndex:r.length}}function k(e,t,n,r){return Array.from({length:t},(i,a)=>({columnIndex:a,frameDurationMs:a===t-1?r:n,rowIndex:e}))}function A(e){return`${e.columnIndex/(N-1)*100}% ${e.rowIndex/(P-1)*100}%`}var j,M,N,P,F,I,L,R,z=e((()=>{j=r(),M=t(n(),1),N=8,P=9,F=6,I=[{rowIndex:0,columnIndex:0,frameDurationMs:280},{rowIndex:0,columnIndex:1,frameDurationMs:110},{rowIndex:0,columnIndex:2,frameDurationMs:110},{rowIndex:0,columnIndex:3,frameDurationMs:140},{rowIndex:0,columnIndex:4,frameDurationMs:140},{rowIndex:0,columnIndex:5,frameDurationMs:320}],L=I.map(e=>({...e,frameDurationMs:e.frameDurationMs*F})),R={failed:k(5,8,140,240),idle:I,jumping:k(4,5,140,280),review:k(8,6,150,280),running:k(7,6,120,220),"running-left":k(2,8,120,220),"running-right":k(1,8,120,220),waving:k(3,4,140,280),waiting:k(6,6,150,260)}})),B=e((()=>{}));function V(e){let t=(0,W.c)(14),{assetRef:n,className:r,spritesheetUrl:i,state:o}=e,c=o===void 0?`idle`:o,l=(0,G.useRef)(null),u=a(),d;t[0]===n?d=t[1]:(d=H(n),t[0]=n,t[1]=d);let f=d,p;t[2]!==u||t[3]!==c?(p={avatarRef:l,prefersReducedMotion:u,state:c},t[2]=u,t[3]=c,t[4]=p):p=t[4],D(p);let m;t[5]===r?m=t[6]:(m=s(`codex-avatar-root`,r),t[5]=r,t[6]=m);let h=`url(${i??q[f]})`,g;t[7]===h?g=t[8]:(g={backgroundImage:h},t[7]=h,t[8]=g);let _;return t[9]!==f||t[10]!==c||t[11]!==m||t[12]!==g?(_=(0,K.jsx)(`div`,{ref:l,className:m,"data-avatar-asset-ref":f,"data-avatar-state":c,style:g,"aria-hidden":`true`,"data-testid":`codex-avatar`}),t[9]=f,t[10]=c,t[11]=m,t[12]=g,t[13]=_):_=t[13],_}function H(e){return U(e)?e:`codex`}function U(e){return e!=null&&Object.hasOwn(q,e)}var W,G,K,q,J=e((()=>{W=r(),c(),o(),G=t(n(),1),u(),f(),m(),g(),v(),b(),S(),w(),E(),z(),B(),K=i(),q={bsod:l,codex:d,dewey:p,fireball:h,hoots:_,"null-signal":y,rocky:x,seedy:C,stacky:T}}));export{J as n,V as t};
//# sourceMappingURL=codex-avatar-CHY0Ofdv.js.map