@alwith/module-auth 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/oauth.js +1 -1
  2. package/dist/pets/assets.js +1 -1
  3. package/dist/pets/core/engine.js +1 -1
  4. package/dist/pets/core/host.d.ts +27 -23
  5. package/dist/pets/core/lib/account-state.js +1 -1
  6. package/dist/pets/core/lib/gacha-pools.js +1 -1
  7. package/dist/pets/core/lib/pet-animation-sync.d.ts +1 -1
  8. package/dist/pets/core/lib/pet-drag.d.ts +1 -1
  9. package/dist/pets/core/lib/pet-presentation.d.ts +1 -1
  10. package/dist/pets/core/lib/presentation-readiness.js +1 -1
  11. package/dist/pets/core/lib/rarity.js +1 -1
  12. package/dist/pets/core/lib/resource-sync.js +1 -1
  13. package/dist/pets/core/lib/settings.js +1 -1
  14. package/dist/pets/core/lib/vibemon-resources.js +1 -1
  15. package/dist/pets/core/types.d.ts +1 -4
  16. package/dist/pets/host.d.ts +10 -10
  17. package/dist/pets/react/assets.js +1 -1
  18. package/dist/pets/react/components/album-view.js +1 -1
  19. package/dist/pets/react/components/back-to-home.js +1 -1
  20. package/dist/pets/react/components/equip-view.js +1 -1
  21. package/dist/pets/react/components/gem-balance.js +1 -1
  22. package/dist/pets/react/components/home-view.js +1 -1
  23. package/dist/pets/react/components/insufficient-points-dialog.js +1 -1
  24. package/dist/pets/react/components/loading-view.js +1 -1
  25. package/dist/pets/react/components/lounge-burst.css +0 -2
  26. package/dist/pets/react/components/onboarding-guide.js +1 -1
  27. package/dist/pets/react/components/pet-bubble-background.js +1 -1
  28. package/dist/pets/react/components/pet-window.js +1 -1
  29. package/dist/pets/react/components/pull-overlay.js +1 -1
  30. package/dist/pets/react/components/pull-view.js +1 -1
  31. package/dist/pets/react/components/quick-reply.js +2 -2
  32. package/dist/pets/react/components/single-pet-toast.js +1 -1
  33. package/dist/pets/react/components/vibemon-header.js +1 -1
  34. package/dist/pets/react/components/vibemon-page.js +1 -1
  35. package/dist/pets/react/components/video-fader.d.ts +1 -4
  36. package/dist/pets/react/components/video-fader.js +1 -1
  37. package/dist/pets/react/components/wish-button.js +1 -1
  38. package/dist/pets/react/ui/button.js +1 -1
  39. package/dist/pets/react/ui/card.d.ts +1 -1
  40. package/dist/pets/react/ui/card.js +1 -1
  41. package/dist/pets/react/ui/input-group.d.ts +1 -1
  42. package/dist/pets/react/ui/input-group.js +1 -1
  43. package/dist/pets/selection.d.ts +1 -1
  44. package/dist/pets/selection.js +1 -1
  45. package/dist/state.d.ts +1 -1
  46. package/dist/state.js +1 -1
  47. package/dist/token-storage.d.ts +9 -9
  48. package/dist/token-storage.js +1 -1
  49. package/package.json +3 -3
package/dist/oauth.js CHANGED
@@ -1 +1 @@
1
- function r(e){let n="";for(let o of e)n+=String.fromCharCode(o);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function a(){let e=new Uint8Array(32);return crypto.getRandomValues(e),r(e)}async function u(e){let n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return r(new Uint8Array(n))}var t=null;function c(e){t=e}function s(){let e=t;return t=null,e}function I(){t=null}var i=[["OAUTH_SESSION_EXPIRED","signIn.oauthSessionExpired"],["OAUTH_VERIFICATION_FAILED","signIn.oauthVerificationFailed"],["OAUTH_EMAIL_REQUIRED","signIn.oauthEmailRequired"],["OAUTH_IDENTITY_CONFLICT","signIn.oauthIdentityConflict"],["OAUTH_RATE_LIMITED","signIn.tooManyRequests"],["OAUTH_PROVIDER_UNAVAILABLE","signIn.oauthProviderUnavailable"],["OAUTH_CONFIG_UNAVAILABLE","signIn.oauthConfigUnavailable"],["ACCOUNT_DISABLED","signIn.accountDisabled"]];function l(e){for(let[n,o]of i)if(e.includes(n))return o;return"signIn.signInFailed"}export{I as clearOAuthState,u as computeCodeChallenge,a as generateCodeVerifier,l as oauthErrorKey,c as storeOAuthState,s as takeOAuthState};
1
+ function r(e){let n="";for(let o of e)n+=String.fromCharCode(o);return btoa(n).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function a(){let e=new Uint8Array(32);return crypto.getRandomValues(e),r(e)}async function u(e){let n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return r(new Uint8Array(n))}var t=null;function l(e){t=e}function c(){let e=t;return t=null,e}function s(){t=null}var i=[["OAUTH_SESSION_EXPIRED","signIn.oauthSessionExpired"],["OAUTH_VERIFICATION_FAILED","signIn.oauthVerificationFailed"],["OAUTH_EMAIL_REQUIRED","signIn.oauthEmailRequired"],["OAUTH_IDENTITY_CONFLICT","signIn.oauthIdentityConflict"],["OAUTH_RATE_LIMITED","signIn.tooManyRequests"],["OAUTH_PROVIDER_UNAVAILABLE","signIn.oauthProviderUnavailable"],["OAUTH_CONFIG_UNAVAILABLE","signIn.oauthConfigUnavailable"],["ACCOUNT_DISABLED","signIn.accountDisabled"]];function I(e){for(let[n,o]of i)if(e.includes(n))return o;return"signIn.signInFailed"}export{s as clearOAuthState,u as computeCodeChallenge,a as generateCodeVerifier,I as oauthErrorKey,l as storeOAuthState,c as takeOAuthState};
@@ -1 +1 @@
1
- import{createPetClient as R}from"./client.js";import{accountKey as g,assertAccount as c}from"./host.js";import{createPetResources as h}from"./resources.js";import{createPetSelection as q}from"./selection.js";function F(t){let d=R(t),u=h(t),o=null,l=!1,a=0,s=null,y="",v=!1,V=0,f=new Set;function i(){V++;for(let e of f)e()}function r(){if(v)throw Error("Vibemon asset service disposed");let e=t.account(),n=e===null?"":`${g(e)}/${e.revision}`;if(y!==n)y=n,o=null,l=!1,a++,s=null,u.cancel();return e}async function m(e){let n=r(),S=e===void 0?++a:a,w=await d.getMyVibemons(e);if(n===null)throw Error("Sign in to use Vibemon");if(c(t,n),r(),e===void 0&&S===a)o=w,l=!0,await t.storage.set(`vibemon.owned.${g(n)}`,w),c(t,n),i();return w}async function C(){let e=r();if(e===null)return null;if(l)return o;let n=await t.storage.get(`vibemon.owned.${g(e)}`);return c(t,e),o=n??null,i(),o}async function p(){let e=r(),n=await d.getVibemonCatalog();if(e===null)throw Error("Sign in to use Vibemon");return c(t,e),r(),s=n,i(),n}let E=q(t,async(e)=>{if(r(),l&&o!==null&&o.some((n)=>n.vibemon_uuid===e))return o;return m()});return{...d,getMyVibemons:m,getVibemonCatalog:p,resources:u,restoreOwned:C,get revision(){return V},snapshot:()=>({account:r(),owned:o,catalog:s}),invalidate(){r(),i()},subscribe(e){return f.add(e),()=>{f.delete(e)}},selection:{get:E.get,async select(e){r(),await E.select(e),i()}},async ensureResource(e){let n=r();if(n===null)throw Error("Sign in to use Vibemon");if(!(o??await m()).some((b)=>b.vibemon_uuid===e))throw Error("This account does not own this Vibemon");let P=(s??await p()).find((b)=>b.uuid===e);if(!P)throw Error("Vibemon resource is not in the catalog");return c(t,n),u.ensure(P)},dispose(){v=!0,o=null,s=null,u.dispose(),i(),f.clear()}}}export{F as createPetAssets};
1
+ import{createPetClient as R}from"./client.js";import{accountKey as g,assertAccount as c}from"./host.js";import{createPetResources as h}from"./resources.js";import{createPetSelection as q}from"./selection.js";function F(t){let d=R(t),u=h(t),o=null,l=!1,a=0,s=null,y="",v=!1,V=0,f=new Set;function i(){V++;for(let e of f)e()}function r(){if(v)throw Error("Vibemon asset service disposed");let e=t.account(),n=e===null?"":`${g(e)}/${e.revision}`;if(y!==n)y=n,o=null,l=!1,a++,s=null,u.cancel();return e}async function m(e){let n=r(),S=e===void 0?++a:a,w=await d.getMyVibemons(e);if(n===null)throw Error("Sign in to use Vibemon");if(c(t,n),r(),e===void 0&&S===a)o=w,l=!0,await t.storage.set(`vibemon.owned.${g(n)}`,w),c(t,n),i();return w}async function C(){let e=r();if(e===null)return null;if(l)return o;let n=await t.storage.get(`vibemon.owned.${g(e)}`);return c(t,e),o=n??null,i(),o}async function p(){let e=r(),n=await d.getVibemonCatalog();if(e===null)throw Error("Sign in to use Vibemon");return c(t,e),r(),s=n,i(),n}let E=q(t,async(e)=>{if(r(),l&&o?.some((n)=>n.vibemon_uuid===e))return o;return m()});return{...d,getMyVibemons:m,getVibemonCatalog:p,resources:u,restoreOwned:C,get revision(){return V},snapshot:()=>({account:r(),owned:o,catalog:s}),invalidate(){r(),i()},subscribe(e){return f.add(e),()=>{f.delete(e)}},selection:{get:E.get,async select(e){r(),await E.select(e),i()}},async ensureResource(e){let n=r();if(n===null)throw Error("Sign in to use Vibemon");if(!(o??await m()).some((b)=>b.vibemon_uuid===e))throw Error("This account does not own this Vibemon");let P=(s??await p()).find((b)=>b.uuid===e);if(!P)throw Error("Vibemon resource is not in the catalog");return c(t,n),u.ensure(P)},dispose(){v=!0,o=null,s=null,u.dispose(),i(),f.clear()}}}export{F as createPetAssets};
@@ -1 +1 @@
1
- import{availableMonitors as a,getCurrentWindow as o}from"./lib/window-frame.js";import{moveVibemonWindow as h}from"./lib/window-frame.js";var d=60000,l=24,u=90;class c{currentBehavior="idle";flipped=!1;position={x:200,y:200};targetPosition=null;screenBounds={x:0,y:0,width:1920,height:1080};behaviorTimer=null;sleepTimer=null;moveTimerId=null;isDragging=!1;isPresenting=!1;isHatching=!1;destroyed=!1;suspended=!1;behaviorBeforeDrag="idle";working=!1;sessionAnimation=null;onStateChange;onNotification;config;constructor(i,e,t){this.config=i,this.onStateChange=e,this.onNotification=t}stateOf(i){return this.config.behaviorMap[i]??this.config.behaviorMap.idle}async start(i){if(await this.updateScreenBounds(),i===void 0){let e=await o().outerPosition();this.position={x:e.x,y:e.y}}else if(i){let e=await o().outerSize();if((await a()).some((n)=>i.x+e.width>n.position.x&&i.x<n.position.x+n.size.width&&i.y+e.height>n.position.y&&i.y<n.position.y+n.size.height))this.position={x:i.x,y:i.y};else{let n=this.screenBounds.x+this.screenBounds.width-e.width,r=this.screenBounds.y+this.screenBounds.height-e.height;this.position={x:Math.min(Math.max(i.x,this.screenBounds.x),n),y:Math.min(Math.max(i.y,this.screenBounds.y),r)}}await h(this.position.x,this.position.y)}else{let e=await o().outerSize(),t=await o().scaleFactor(),s=Math.round(l*t),n=Math.round(u*t);this.position={x:this.screenBounds.x+this.screenBounds.width-e.width-s,y:this.screenBounds.y+this.screenBounds.height-e.height-n},await h(this.position.x,this.position.y)}if(this.setBehavior("idle"),this.sessionAnimation!==null)this.applySessionAnimation();this.resetSleepTimer()}destroy(){if(this.destroyed=!0,this.behaviorTimer)clearTimeout(this.behaviorTimer);if(this.sleepTimer)clearTimeout(this.sleepTimer);if(this.moveTimerId)clearInterval(this.moveTimerId)}suspend(){if(this.suspended=!0,this.cancelMovement(),this.targetPosition=null,this.sleepTimer)clearTimeout(this.sleepTimer);this.sleepTimer=null}resume(){if(this.destroyed)throw Error("Cannot resume a destroyed Vibemon engine");if(this.suspended=!1,this.sessionAnimation!==null)this.applySessionAnimation();else this.setBehavior(this.restBehavior());this.resetSleepTimer()}async presentAt(i){if(this.isDragging||this.isPresenting||this.destroyed)throw Error("Vibemon cannot be presented right now");this.isPresenting=!0,this.cancelMovement(),this.targetPosition=null;try{if(this.position=await i(),this.destroyed)throw Error("Vibemon engine changed during presentation")}finally{if(this.isPresenting=!1,!this.destroyed&&!this.suspended){if(this.sessionAnimation!==null)this.applySessionAnimation();else if(this.currentBehavior!=="wait"&&this.currentBehavior!=="error")this.setBehavior(this.restBehavior());this.resetSleepTimer()}}}restBehavior(){return this.working?"sit":"idle"}setWorking(i){if(this.working===i)return;if(this.working=i,this.destroyed||this.suspended||this.isDragging)return;let e=this.currentBehavior==="idle"||this.currentBehavior==="sit"||this.currentBehavior==="sleep",t=this.restBehavior();if(e&&t!==this.currentBehavior)this.setBehavior(t),this.resetSleepTimer()}setSessionState(i,e,t){let s=this.sessionAnimation;if(s!==null&&s.sessionId===i&&s.state===e&&s.failed===t)return;if(this.sessionAnimation={sessionId:i,state:e,failed:t},this.setWorking(e==="running"&&!t),s!==null&&s.sessionId===i&&s.state==="done"&&e==="idle"&&!t&&this.currentBehavior==="jump"&&this.behaviorTimer!==null)return;if(!this.destroyed&&!this.suspended&&!this.isDragging&&!this.isPresenting)this.applySessionAnimation()}applySessionAnimation(){let i=this.sessionAnimation;if(i===null)throw Error("Session animation requires a Runtime snapshot");let e=i.failed?"task-error":i.state==="running"?"running":i.state==="requires_action"?"info":i.state==="done"?"task-complete":"idle";this.handleNotification({type:e,message:"",sourceWindow:""})}handleNotification(i){if(this.suspended)return;if(this.isHatching)return;if(this.onNotification(i),this.resetSleepTimer(),this.behaviorTimer)clearTimeout(this.behaviorTimer);if(this.currentBehavior==="sleep"){this.setBehavior("scared"),this.behaviorTimer=setTimeout(()=>{if(!this.destroyed&&!this.isDragging&&!this.isPresenting)if(this.sessionAnimation!==null)this.applySessionAnimation();else this.handleNotification(i)},500);return}if(this.cancelMovement(),i.type==="info"){this.setBehavior("wait");return}if(i.type==="task-error"){this.setBehavior(this.config.behaviorMap.error?"error":"wait");return}if(i.type==="running"){this.setBehavior("sit");return}if(i.type==="task-complete"){this.setBehavior("jump");let e=this.config.states.find((s)=>s.id===this.stateOf("jump")),t=e?e.frames/e.fps*1000:800;this.behaviorTimer=setTimeout(()=>{if(!this.destroyed&&!this.isDragging)this.setBehavior(this.restBehavior())},t);return}this.setBehavior(this.restBehavior())}handleClick(){if(this.isHatching)return;this.resetSleepTimer()}dismissError(){if(this.currentBehavior!=="error")return;this.cancelMovement(),this.setBehavior(this.restBehavior()),this.resetSleepTimer()}flipForDirection(i){return this.config.facing==="left"?!i:i}handleDragStart(i){if(this.isPresenting)throw Error("Vibemon presentation is in progress");if(this.isHatching)return;if(this.behaviorBeforeDrag=this.currentBehavior,this.isDragging=!0,this.cancelMovement(),this.resetSleepTimer(),i!==void 0)this.flipped=this.flipForDirection(i);this.setBehavior("scared")}setFacing(i){let e=this.flipForDirection(i);if(this.flipped===e)return;this.flipped=e,this.onStateChange(this.stateOf(this.currentBehavior),this.flipped,!1)}handleDragEnd(){if(this.destroyed)return;if(this.isDragging=!1,this.cancelMovement(),this.flipped=!1,this.sessionAnimation!==null)this.applySessionAnimation();else if(this.behaviorBeforeDrag==="wait"||this.behaviorBeforeDrag==="error")this.setBehavior(this.behaviorBeforeDrag);else this.setBehavior(this.restBehavior());this.syncPositionFromWindow()}debugSpeed=8;setDebugSpeed(i){this.debugSpeed=i}stop(){this.cancelMovement(),this.setBehavior("idle")}debugSetBehavior(i){if(this.cancelMovement(),i in this.config.behaviorMap)this.setBehavior(i);else this.currentBehavior="idle",this.onStateChange(i,this.flipped,!0)}getDebugSpeed(){return this.debugSpeed}async debugRun(){this.cancelMovement(),await this.syncPositionFromWindow();let i=await o().outerSize(),e=[{x:this.screenBounds.x,y:this.screenBounds.y},{x:this.screenBounds.x+this.screenBounds.width-i.width,y:this.screenBounds.y},{x:this.screenBounds.x+this.screenBounds.width-i.width,y:this.screenBounds.y+this.screenBounds.height-i.height},{x:this.screenBounds.x,y:this.screenBounds.y+this.screenBounds.height-i.height}],t=0,s=()=>{if(this.destroyed)return;let n=e[t%e.length];t++;let r=n.x-this.position.x;if(Math.abs(r)>1)this.flipped=r<0;this.setBehavior("run"),this.startMovement(n,this.debugSpeed,s)};s()}setBehavior(i){this.currentBehavior=i,this.onStateChange(this.stateOf(i),this.flipped,!0)}async syncPositionFromWindow(){if(this.destroyed)return;let i;try{i=await o().outerPosition()}catch(e){if(this.destroyed)return;throw e}if(this.destroyed)return;this.position={x:i.x,y:i.y}}async updateScreenBounds(){let i=await a();if(i.length>0){let e=i[0];this.screenBounds={x:e.position.x,y:e.position.y,width:e.size.width,height:e.size.height}}}startMovement(i,e,t){if(this.isPresenting||this.suspended)return;this.cancelMovement(),this.targetPosition=i,this.moveTimerId=setInterval(()=>{if(this.destroyed||this.isDragging||!this.targetPosition||this.currentBehavior!=="run"){if(this.moveTimerId)clearInterval(this.moveTimerId);this.moveTimerId=null;return}let s=this.targetPosition.x-this.position.x,n=this.targetPosition.y-this.position.y,r=Math.sqrt(s*s+n*n);if(r<e){if(this.position={...this.targetPosition},this.targetPosition=null,this.moveTimerId)clearInterval(this.moveTimerId),this.moveTimerId=null;if(h(this.position.x,this.position.y),t)t();else this.setBehavior("idle");return}this.position.x+=s/r*e,this.position.y+=n/r*e,h(this.position.x,this.position.y)},16)}cancelMovement(){if(this.moveTimerId)clearInterval(this.moveTimerId),this.moveTimerId=null;if(this.behaviorTimer)clearTimeout(this.behaviorTimer),this.behaviorTimer=null}resetSleepTimer(){if(this.sleepTimer)clearTimeout(this.sleepTimer);if(this.suspended)return;this.sleepTimer=setTimeout(()=>{if(!this.destroyed&&!this.isDragging&&this.currentBehavior==="idle")this.cancelMovement(),this.setBehavior("sleep")},d)}}export{c as VibemonEngine};
1
+ import{availableMonitors as a,getCurrentWindow as o,moveVibemonWindow as h}from"./lib/window-frame.js";var d=60000,l=24,u=90;class c{currentBehavior="idle";flipped=!1;position={x:200,y:200};targetPosition=null;screenBounds={x:0,y:0,width:1920,height:1080};behaviorTimer=null;sleepTimer=null;moveTimerId=null;isDragging=!1;isPresenting=!1;isHatching=!1;destroyed=!1;suspended=!1;behaviorBeforeDrag="idle";working=!1;sessionAnimation=null;onStateChange;onNotification;config;constructor(i,e,t){this.config=i,this.onStateChange=e,this.onNotification=t}stateOf(i){return this.config.behaviorMap[i]??this.config.behaviorMap.idle}async start(i){if(await this.updateScreenBounds(),i===void 0){let e=await o().outerPosition();this.position={x:e.x,y:e.y}}else if(i){let e=await o().outerSize();if((await a()).some((n)=>i.x+e.width>n.position.x&&i.x<n.position.x+n.size.width&&i.y+e.height>n.position.y&&i.y<n.position.y+n.size.height))this.position={x:i.x,y:i.y};else{let n=this.screenBounds.x+this.screenBounds.width-e.width,r=this.screenBounds.y+this.screenBounds.height-e.height;this.position={x:Math.min(Math.max(i.x,this.screenBounds.x),n),y:Math.min(Math.max(i.y,this.screenBounds.y),r)}}await h(this.position.x,this.position.y)}else{let e=await o().outerSize(),t=await o().scaleFactor(),s=Math.round(l*t),n=Math.round(u*t);this.position={x:this.screenBounds.x+this.screenBounds.width-e.width-s,y:this.screenBounds.y+this.screenBounds.height-e.height-n},await h(this.position.x,this.position.y)}if(this.setBehavior("idle"),this.sessionAnimation!==null)this.applySessionAnimation();this.resetSleepTimer()}destroy(){if(this.destroyed=!0,this.behaviorTimer)clearTimeout(this.behaviorTimer);if(this.sleepTimer)clearTimeout(this.sleepTimer);if(this.moveTimerId)clearInterval(this.moveTimerId)}suspend(){if(this.suspended=!0,this.cancelMovement(),this.targetPosition=null,this.sleepTimer)clearTimeout(this.sleepTimer);this.sleepTimer=null}resume(){if(this.destroyed)throw Error("Cannot resume a destroyed Vibemon engine");if(this.suspended=!1,this.sessionAnimation!==null)this.applySessionAnimation();else this.setBehavior(this.restBehavior());this.resetSleepTimer()}async presentAt(i){if(this.isDragging||this.isPresenting||this.destroyed)throw Error("Vibemon cannot be presented right now");this.isPresenting=!0,this.cancelMovement(),this.targetPosition=null;try{if(this.position=await i(),this.destroyed)throw Error("Vibemon engine changed during presentation")}finally{if(this.isPresenting=!1,!this.destroyed&&!this.suspended){if(this.sessionAnimation!==null)this.applySessionAnimation();else if(this.currentBehavior!=="wait"&&this.currentBehavior!=="error")this.setBehavior(this.restBehavior());this.resetSleepTimer()}}}restBehavior(){return this.working?"sit":"idle"}setWorking(i){if(this.working===i)return;if(this.working=i,this.destroyed||this.suspended||this.isDragging)return;let e=this.currentBehavior==="idle"||this.currentBehavior==="sit"||this.currentBehavior==="sleep",t=this.restBehavior();if(e&&t!==this.currentBehavior)this.setBehavior(t),this.resetSleepTimer()}setSessionState(i,e,t){let s=this.sessionAnimation;if(s!==null&&s.sessionId===i&&s.state===e&&s.failed===t)return;if(this.sessionAnimation={sessionId:i,state:e,failed:t},this.setWorking(e==="running"&&!t),s!==null&&s.sessionId===i&&s.state==="done"&&e==="idle"&&!t&&this.currentBehavior==="jump"&&this.behaviorTimer!==null)return;if(!this.destroyed&&!this.suspended&&!this.isDragging&&!this.isPresenting)this.applySessionAnimation()}applySessionAnimation(){let i=this.sessionAnimation;if(i===null)throw Error("Session animation requires a Runtime snapshot");let e=i.failed?"task-error":i.state==="running"?"running":i.state==="requires_action"?"info":i.state==="done"?"task-complete":"idle";this.handleNotification({type:e,message:"",sourceWindow:""})}handleNotification(i){if(this.suspended)return;if(this.isHatching)return;if(this.onNotification(i),this.resetSleepTimer(),this.behaviorTimer)clearTimeout(this.behaviorTimer);if(this.currentBehavior==="sleep"){this.setBehavior("scared"),this.behaviorTimer=setTimeout(()=>{if(!this.destroyed&&!this.isDragging&&!this.isPresenting)if(this.sessionAnimation!==null)this.applySessionAnimation();else this.handleNotification(i)},500);return}if(this.cancelMovement(),i.type==="info"){this.setBehavior("wait");return}if(i.type==="task-error"){this.setBehavior(this.config.behaviorMap.error?"error":"wait");return}if(i.type==="running"){this.setBehavior("sit");return}if(i.type==="task-complete"){this.setBehavior("jump");let e=this.config.states.find((s)=>s.id===this.stateOf("jump")),t=e?e.frames/e.fps*1000:800;this.behaviorTimer=setTimeout(()=>{if(!this.destroyed&&!this.isDragging)this.setBehavior(this.restBehavior())},t);return}this.setBehavior(this.restBehavior())}handleClick(){if(this.isHatching)return;this.resetSleepTimer()}dismissError(){if(this.currentBehavior!=="error")return;this.cancelMovement(),this.setBehavior(this.restBehavior()),this.resetSleepTimer()}flipForDirection(i){return this.config.facing==="left"?!i:i}handleDragStart(i){if(this.isPresenting)throw Error("Vibemon presentation is in progress");if(this.isHatching)return;if(this.behaviorBeforeDrag=this.currentBehavior,this.isDragging=!0,this.cancelMovement(),this.resetSleepTimer(),i!==void 0)this.flipped=this.flipForDirection(i);this.setBehavior("scared")}setFacing(i){let e=this.flipForDirection(i);if(this.flipped===e)return;this.flipped=e,this.onStateChange(this.stateOf(this.currentBehavior),this.flipped,!1)}handleDragEnd(){if(this.destroyed)return;if(this.isDragging=!1,this.cancelMovement(),this.flipped=!1,this.sessionAnimation!==null)this.applySessionAnimation();else if(this.behaviorBeforeDrag==="wait"||this.behaviorBeforeDrag==="error")this.setBehavior(this.behaviorBeforeDrag);else this.setBehavior(this.restBehavior());this.syncPositionFromWindow()}debugSpeed=8;setDebugSpeed(i){this.debugSpeed=i}stop(){this.cancelMovement(),this.setBehavior("idle")}debugSetBehavior(i){if(this.cancelMovement(),i in this.config.behaviorMap)this.setBehavior(i);else this.currentBehavior="idle",this.onStateChange(i,this.flipped,!0)}getDebugSpeed(){return this.debugSpeed}async debugRun(){this.cancelMovement(),await this.syncPositionFromWindow();let i=await o().outerSize(),e=[{x:this.screenBounds.x,y:this.screenBounds.y},{x:this.screenBounds.x+this.screenBounds.width-i.width,y:this.screenBounds.y},{x:this.screenBounds.x+this.screenBounds.width-i.width,y:this.screenBounds.y+this.screenBounds.height-i.height},{x:this.screenBounds.x,y:this.screenBounds.y+this.screenBounds.height-i.height}],t=0,s=()=>{if(this.destroyed)return;let n=e[t%e.length];t++;let r=n.x-this.position.x;if(Math.abs(r)>1)this.flipped=r<0;this.setBehavior("run"),this.startMovement(n,this.debugSpeed,s)};s()}setBehavior(i){this.currentBehavior=i,this.onStateChange(this.stateOf(i),this.flipped,!0)}async syncPositionFromWindow(){if(this.destroyed)return;let i;try{i=await o().outerPosition()}catch(e){if(this.destroyed)return;throw e}if(this.destroyed)return;this.position={x:i.x,y:i.y}}async updateScreenBounds(){let i=await a();if(i.length>0){let e=i[0];this.screenBounds={x:e.position.x,y:e.position.y,width:e.size.width,height:e.size.height}}}startMovement(i,e,t){if(this.isPresenting||this.suspended)return;this.cancelMovement(),this.targetPosition=i,this.moveTimerId=setInterval(()=>{if(this.destroyed||this.isDragging||!this.targetPosition||this.currentBehavior!=="run"){if(this.moveTimerId)clearInterval(this.moveTimerId);this.moveTimerId=null;return}let s=this.targetPosition.x-this.position.x,n=this.targetPosition.y-this.position.y,r=Math.hypot(s,n);if(r<e){if(this.position={...this.targetPosition},this.targetPosition=null,this.moveTimerId)clearInterval(this.moveTimerId),this.moveTimerId=null;if(h(this.position.x,this.position.y),t)t();else this.setBehavior("idle");return}this.position.x+=s/r*e,this.position.y+=n/r*e,h(this.position.x,this.position.y)},16)}cancelMovement(){if(this.moveTimerId)clearInterval(this.moveTimerId),this.moveTimerId=null;if(this.behaviorTimer)clearTimeout(this.behaviorTimer),this.behaviorTimer=null}resetSleepTimer(){if(this.sleepTimer)clearTimeout(this.sleepTimer);if(this.suspended)return;this.sleepTimer=setTimeout(()=>{if(!this.destroyed&&!this.isDragging&&this.currentBehavior==="idle")this.cancelMovement(),this.setBehavior("sleep")},d)}}export{c as VibemonEngine};
@@ -53,13 +53,13 @@ export interface PetPrompt {
53
53
  }[];
54
54
  }
55
55
  export interface PetSessionHost {
56
- snapshot(): PetObservation | null;
57
- subscribe(listener: (value: PetObservation | null) => void): () => void;
58
- send(binding: PetBinding, requestId: string, text: string): Promise<void>;
59
- answer(binding: PetBinding, requestId: string, token: string, optionId: string): Promise<void>;
60
- openChat(binding: PetBinding | null): Promise<void>;
61
- activate(): Promise<void>;
62
- select(binding: PetBinding, sessionId: string): Promise<void>;
56
+ snapshot: () => PetObservation | null;
57
+ subscribe: (listener: (value: PetObservation | null) => void) => () => void;
58
+ send: (binding: PetBinding, requestId: string, text: string) => Promise<void>;
59
+ answer: (binding: PetBinding, requestId: string, token: string, optionId: string) => Promise<void>;
60
+ openChat: (binding: PetBinding | null) => Promise<void>;
61
+ activate: () => Promise<void>;
62
+ select: (binding: PetBinding, sessionId: string) => Promise<void>;
63
63
  }
64
64
  export interface Monitor {
65
65
  position: {
@@ -73,34 +73,38 @@ export interface Monitor {
73
73
  scaleFactor: number;
74
74
  }
75
75
  export interface PetWindowHost {
76
- call<T>(action: string, payload?: Record<string, unknown>): Promise<T>;
77
- openPet(options?: {
76
+ call: <T>(action: string, payload?: Record<string, unknown>) => Promise<T>;
77
+ openPet: (options?: {
78
78
  trusted?: boolean;
79
- }): Promise<"shown" | "unavailable">;
80
- closePet(): Promise<void>;
81
- openRecharge(): Promise<void>;
82
- geometry(listener: () => void): Promise<() => void>;
83
- moved(listener: (position: {
79
+ }) => Promise<"shown" | "unavailable">;
80
+ closePet: () => Promise<void>;
81
+ openRecharge: () => Promise<void>;
82
+ geometry: (listener: () => void) => Promise<() => void>;
83
+ moved: (listener: (position: {
84
84
  x: number;
85
85
  y: number;
86
- }) => void): Promise<() => void>;
87
- commands(listener: (command: {
86
+ }) => void) => Promise<() => void>;
87
+ commands: (listener: (command: {
88
88
  type: "present" | "reload" | "suspend" | "bubble-close" | "bubble-open" | "bubble-interact" | "close";
89
89
  petId: string;
90
90
  requestId: string;
91
- }) => Promise<void>): () => void;
91
+ }) => Promise<void>) => () => void;
92
92
  }
93
93
  export interface VibemonHost {
94
94
  sessionIcons?: SessionIcons;
95
- account(): PetAccount | null;
95
+ account: () => PetAccount | null;
96
96
  assets: PetAssets;
97
97
  storage: PetStorage;
98
- subscribeStorage(listener: () => void): () => void;
98
+ subscribeStorage: (listener: () => void) => () => void;
99
99
  sessions: PetSessionHost;
100
100
  windows: PetWindowHost;
101
- synchronizeResources?(): Promise<void>;
102
- resourcesSynchronized?(updated: ReadonlySet<string>): Promise<void>;
103
- onError(error: unknown): void;
101
+ synchronizeResources?: () => Promise<void>;
102
+ resourcesSynchronized?: (updated: ReadonlySet<string>) => Promise<void>;
103
+ onResourceSyncError?: (error: unknown, context: {
104
+ phase: "catalog" | "resource";
105
+ petId?: string;
106
+ }) => void;
107
+ onError: (error: unknown) => void;
104
108
  }
105
109
  export declare function configureVibemon(value: VibemonHost): () => void;
106
110
  export declare function vibemonHost(): VibemonHost;
@@ -108,5 +112,5 @@ export declare function sameBinding(left: PetBinding, right: PetBinding): boolea
108
112
  export interface SpriteResource {
109
113
  config: VibemonSpriteConfig;
110
114
  spriteUrl: string;
111
- dispose(): void;
115
+ dispose: () => void;
112
116
  }
@@ -1 +1 @@
1
- import{accountKey as m,assertAccount as r}from"../../index.js";import{vibemonHost as l}from"../host.js";import{getSettingSync as a,refreshSettings as d,setSetting as b,updateSettingCache as S}from"./settings.js";var c={pet:"",enabled:!1,position:null};function f(){let n=l().account();return n===null?null:m(n)}function p(){let n=f();return n===null?c:a("vibemon.accounts")[n]??c}var x=async()=>p();async function g(n){let t=l(),i=t.account(),e=f();if(i===null||e===null)throw Error("Sign in to use Vibemon");if(n.pet!==void 0){let o=a("vibemon.accounts");S("vibemon.accounts",{...o,[e]:{...o[e]??c,pet:n.pet}});try{await t.assets.selection.select(n.pet||null)}finally{await d()}}r(t,i);let{enabled:s,position:u}=n;if(s!==void 0||u!==void 0){let o=a("vibemon.accounts");await b("vibemon.accounts",{...o,[e]:{...o[e]??c,...s!==void 0?{enabled:s}:{},...u!==void 0?{position:u}:{}}})}r(t,i)}async function V(n,t){if(t||p().pet==="")await g({pet:n})}export{p as currentState,V as equipVibemonAfterDraw,f as getVibemonScopeSync,x as getVibemonState,g as updateVibemonState};
1
+ import{accountKey as m,assertAccount as r}from"../../index.js";import{vibemonHost as l}from"../host.js";import{getSettingSync as a,refreshSettings as d,setSetting as b,updateSettingCache as S}from"./settings.js";var c={pet:"",enabled:!1,position:null};function f(){let n=l().account();return n===null?null:m(n)}function p(){let n=f();return n===null?c:a("vibemon.accounts")[n]??c}var x=()=>Promise.try(()=>p());async function g(n){let t=l(),i=t.account(),e=f();if(i===null||e===null)throw Error("Sign in to use Vibemon");if(n.pet!==void 0){let o=a("vibemon.accounts");S("vibemon.accounts",{...o,[e]:{...o[e]??c,pet:n.pet}});try{await t.assets.selection.select(n.pet||null)}finally{await d()}}r(t,i);let{enabled:s,position:u}=n;if(s!==void 0||u!==void 0){let o=a("vibemon.accounts");await b("vibemon.accounts",{...o,[e]:{...o[e]??c,...s!==void 0?{enabled:s}:{},...u!==void 0?{position:u}:{}}})}r(t,i)}async function V(n,t){if(t||p().pet==="")await g({pet:n})}export{p as currentState,V as equipVibemonAfterDraw,f as getVibemonScopeSync,x as getVibemonState,g as updateVibemonState};
@@ -1 +1 @@
1
- import{getActiveGachaPools as c,getGachaPoolDetail as l}from"./endpoints.js";var s={SSR:5,SR:4,R:3,UC:2,C:1};function d(r){let e=r.items.filter((o)=>o.reward_type==="VIBEMON"&&o.status===1),t=e[0];if(t===void 0)throw Error(`[vibemon] gacha pool ${r.uuid} has no active Vibemon item`);return e.slice(1).reduce((o,n)=>{if(s[n.rarity_code]-s[o.rarity_code]>0)return n;return o},t)}function a(r,e,t){if(r===null)throw Error(`[vibemon] gacha pool ${e} featured Vibemon is missing ${t}`);return r}function _(r,e){if(e.uuid!==r.uuid)throw Error(`[vibemon] gacha pool detail UUID ${e.uuid} does not match catalog UUID ${r.uuid}`);if(e.multi_count!==10)throw Error(`[vibemon] gacha pool ${e.uuid} multi_count must be 10, received ${e.multi_count}`);let t=d(e);return{poolUuid:e.uuid,name:e.name,sidebarSelectedImageUrl:a(t.vibemon_sidebar_selected_url,e.uuid,"vibemon_sidebar_selected_url"),sidebarHoverImageUrl:a(t.vibemon_sidebar_hover_url,e.uuid,"vibemon_sidebar_hover_url"),sidebarUnselectedImageUrl:a(t.vibemon_sidebar_unselected_url,e.uuid,"vibemon_sidebar_unselected_url"),pageBackgroundImageUrl:a(t.vibemon_background_url,e.uuid,"vibemon_background_url"),poolCardImageUrl:a(t.vibemon_pool_card_url,e.uuid,"vibemon_pool_card_url"),status:e.status===1?"ACTIVE":"UNAVAILABLE",startsAt:r.start_time,endsAt:r.end_time,singlePrice:e.next_single_actual_cost??r.single_cost,multiPrice:e.next_multi_actual_cost??r.multi_cost,currencyType:r.currency_type,canDraw:e.status===1,isDefault:r.is_default===1}}function f(r,e){if(r.length===0)throw Error("[vibemon] active gacha pool catalog is empty");let t=new Map(e.map((n)=>[n.uuid,n]));return{pools:[...r].sort((n,i)=>n.sort_order-i.sort_order).map((n)=>{let i=t.get(n.uuid);if(i===void 0)throw Error(`[vibemon] gacha pool ${n.uuid} is missing its detail response`);return _(n,i)})}}function b(r){let e=r.pools.flatMap((t)=>[t.sidebarSelectedImageUrl,t.sidebarHoverImageUrl,t.sidebarUnselectedImageUrl,t.poolCardImageUrl]);return[...new Set(e)]}async function h(){let e=[...await c()].sort((o,n)=>o.sort_order-n.sort_order),t=await Promise.all(e.map((o)=>l(o.uuid)));return f(e,t)}function u(r,e,t){let o=Date.parse(e);if(Number.isNaN(o))throw Error(`[vibemon] gacha pool ${r.poolUuid} has invalid ${t}: ${e}`);return o}function m(r,e){if(r.status==="UNAVAILABLE")return r.status;if(r.startsAt!==null&&e<u(r,r.startsAt,"startsAt"))return"UPCOMING";if(r.endsAt!==null&&e>=u(r,r.endsAt,"endsAt"))return"ENDED";return r.status}function v(r){let e=r.find((o)=>o.isDefault);if(e!==void 0)return e;let t=r[0];if(t===void 0)throw Error("[vibemon] gacha pool catalog has no visible pools");return t}function p(r,e){return r.filter((t)=>m(t,e)!=="ENDED")}export{f as createGachaPoolCatalog,b as gachaPoolImageUrls,v as getDefaultGachaPool,p as getVisibleGachaPools,h as loadGachaPoolCatalog,m as resolveGachaPoolStatus};
1
+ import{getActiveGachaPools as c,getGachaPoolDetail as l}from"./endpoints.js";var u={SSR:5,SR:4,R:3,UC:2,C:1};function d(r){let e=r.items.filter((o)=>o.reward_type==="VIBEMON"&&o.status===1),t=e[0];if(t===void 0)throw Error(`[vibemon] gacha pool ${r.uuid} has no active Vibemon item`);return e.slice(1).reduce((o,n)=>{if(u[n.rarity_code]-u[o.rarity_code]>0)return n;return o},t)}function a(r,e,t){if(r===null)throw Error(`[vibemon] gacha pool ${e} featured Vibemon is missing ${t}`);return r}function _(r,e){if(e.uuid!==r.uuid)throw Error(`[vibemon] gacha pool detail UUID ${e.uuid} does not match catalog UUID ${r.uuid}`);if(e.multi_count!==10)throw Error(`[vibemon] gacha pool ${e.uuid} multi_count must be 10, received ${e.multi_count}`);let t=d(e);return{poolUuid:e.uuid,name:e.name,sidebarSelectedImageUrl:a(t.vibemon_sidebar_selected_url,e.uuid,"vibemon_sidebar_selected_url"),sidebarHoverImageUrl:a(t.vibemon_sidebar_hover_url,e.uuid,"vibemon_sidebar_hover_url"),sidebarUnselectedImageUrl:a(t.vibemon_sidebar_unselected_url,e.uuid,"vibemon_sidebar_unselected_url"),pageBackgroundImageUrl:a(t.vibemon_background_url,e.uuid,"vibemon_background_url"),poolCardImageUrl:a(t.vibemon_pool_card_url,e.uuid,"vibemon_pool_card_url"),status:e.status===1?"ACTIVE":"UNAVAILABLE",startsAt:r.start_time,endsAt:r.end_time,singlePrice:e.next_single_actual_cost??r.single_cost,multiPrice:e.next_multi_actual_cost??r.multi_cost,currencyType:r.currency_type,canDraw:e.status===1,isDefault:r.is_default===1}}function f(r,e){if(r.length===0)throw Error("[vibemon] active gacha pool catalog is empty");let t=new Map(e.map((n)=>[n.uuid,n]));return{pools:[...r].toSorted((n,i)=>n.sort_order-i.sort_order).map((n)=>{let i=t.get(n.uuid);if(i===void 0)throw Error(`[vibemon] gacha pool ${n.uuid} is missing its detail response`);return _(n,i)})}}function b(r){let e=r.pools.flatMap((t)=>[t.sidebarSelectedImageUrl,t.sidebarHoverImageUrl,t.sidebarUnselectedImageUrl,t.poolCardImageUrl]);return[...new Set(e)]}async function h(){let e=[...await c()].toSorted((o,n)=>o.sort_order-n.sort_order),t=await Promise.all(e.map((o)=>l(o.uuid)));return f(e,t)}function s(r,e,t){let o=Date.parse(e);if(Number.isNaN(o))throw Error(`[vibemon] gacha pool ${r.poolUuid} has invalid ${t}: ${e}`);return o}function m(r,e){if(r.status==="UNAVAILABLE")return r.status;if(r.startsAt!==null&&e<s(r,r.startsAt,"startsAt"))return"UPCOMING";if(r.endsAt!==null&&e>=s(r,r.endsAt,"endsAt"))return"ENDED";return r.status}function v(r){let e=r.find((o)=>o.isDefault);if(e!==void 0)return e;let t=r[0];if(t===void 0)throw Error("[vibemon] gacha pool catalog has no visible pools");return t}function p(r,e){return r.filter((t)=>m(t,e)!=="ENDED")}export{f as createGachaPoolCatalog,b as gachaPoolImageUrls,v as getDefaultGachaPool,p as getVisibleGachaPools,h as loadGachaPoolCatalog,m as resolveGachaPoolStatus};
@@ -1,5 +1,5 @@
1
- import type { RunState } from "./runtime-types.js";
2
1
  import type { VibemonEngine } from "../engine.js";
2
+ import type { RunState } from "./runtime-types.js";
3
3
  export declare class PetAnimationSync {
4
4
  private engine;
5
5
  private states;
@@ -1,3 +1,3 @@
1
- import type { PetWindowHost } from "../host.js";
2
1
  import type { VibemonEngine } from "../engine.js";
2
+ import type { PetWindowHost } from "../host.js";
3
3
  export declare function dragPet(windows: Pick<PetWindowHost, "call" | "moved">, engine: Pick<VibemonEngine, "handleDragStart" | "setFacing" | "handleDragEnd">, movingLeft: boolean): Promise<void>;
@@ -1,5 +1,5 @@
1
- import type { PetWindowHost } from "../host.js";
2
1
  import type { VibemonEngine } from "../engine.js";
2
+ import type { PetWindowHost } from "../host.js";
3
3
  import type { PresentationReadiness } from "./presentation-readiness.js";
4
4
  type PresentationEngine = Pick<VibemonEngine, "resume" | "presentAt">;
5
5
  export declare function presentVibemon<T extends PresentationEngine>(ready: PresentationReadiness<T>, windows: Pick<PetWindowHost, "call">, petId: string): Promise<void>;
@@ -1 +1 @@
1
- class c{current=null;listeners=new Set;begin(r,n){this.current={petId:r,generation:n,value:null,drawn:!1,error:null},this.notify()}positioned(r,n,e){let t=this.current;if(t===null||t.petId!==r||t.generation!==n)return;t.value=e,this.notify()}drawn(r,n){let e=this.current;if(e===null||e.petId!==r||e.generation!==n||e.drawn)return;e.drawn=!0,this.notify()}requireFreshFrame(r){if(this.current===null||this.current.petId!==r)throw Error("Vibemon resource changed");this.current.drawn=!1,this.notify()}fail(r,n,e){let t=this.current;if(t===null||t.petId!==r||t.generation!==n)return;t.error=e,this.notify()}invalidate(){if(this.current===null)return;this.current.error=Error("Vibemon resource was unloaded"),this.notify()}reset(){this.invalidate(),this.current=null,this.notify()}assertReady(r,n){let e=this.current;if(e===null||e.petId!==r||e.value!==n||!e.drawn||e.error!==null)throw Error("Vibemon resource changed during presentation")}notify(){for(let r of this.listeners)r()}waitingStage(){let r=this.current;if(r===null)return"resource-loading";if(r.value===null)return"initial-position";if(!r.drawn)return"canvas-frame";return"ready"}wait(r,n){let e=this.current?.generation;return new Promise((t,a)=>{let u=()=>{clearTimeout(l),this.listeners.delete(o)},s=(i)=>{u(),a(i)},o=()=>{if(Date.now()>=n){s(Error(`Vibemon presentation timed out [stage=${this.waitingStage()}]`));return}let i=this.current;if(!i)return;if(e===void 0)e=i.generation;if(i.petId!==r||e!==void 0&&e!==i.generation)s(Error("Vibemon resource changed during presentation"));else if(i.error)s(i.error);else if(i.drawn&&i.value!==null)u(),t(i.value)},l=setTimeout(()=>s(Error(`Vibemon presentation timed out [stage=${this.waitingStage()}]`)),Math.max(0,n-Date.now()));this.listeners.add(o),o()})}}export{c as PresentationReadiness};
1
+ class l{current=null;listeners=new Set;begin(e,t){this.current={petId:e,generation:t,value:null,drawn:!1,error:null},this.notify()}positioned(e,t,r){let i=this.current;if(i?.petId!==e||i.generation!==t)return;i.value=r,this.notify()}drawn(e,t){let r=this.current;if(r?.petId!==e||r.generation!==t||r.drawn)return;r.drawn=!0,this.notify()}requireFreshFrame(e){if(this.current?.petId!==e)throw Error("Vibemon resource changed");this.current.drawn=!1,this.notify()}fail(e,t,r){let i=this.current;if(i?.petId!==e||i.generation!==t)return;i.error=r,this.notify()}invalidate(){if(this.current===null)return;this.current.error=Error("Vibemon resource was unloaded"),this.notify()}reset(){this.invalidate(),this.current=null,this.notify()}assertReady(e,t){let r=this.current;if(r?.petId!==e||r.value!==t||!r.drawn||r.error!==null)throw Error("Vibemon resource changed during presentation")}notify(){for(let e of this.listeners)e()}waitingStage(){let e=this.current;if(e===null)return"resource-loading";if(e.value===null)return"initial-position";if(!e.drawn)return"canvas-frame";return"ready"}wait(e,t){let r=this.current?.generation;return new Promise((i,u)=>{let a=()=>{clearTimeout(c),this.listeners.delete(o)},s=(n)=>{a(),u(n)},o=()=>{if(Date.now()>=t){s(Error(`Vibemon presentation timed out [stage=${this.waitingStage()}]`));return}let n=this.current;if(!n)return;if(r??=n.generation,n.petId!==e||r!==void 0&&r!==n.generation)s(Error("Vibemon resource changed during presentation"));else if(n.error)s(n.error);else if(n.drawn&&n.value!==null)a(),i(n.value)},c=setTimeout(()=>s(Error(`Vibemon presentation timed out [stage=${this.waitingStage()}]`)),Math.max(0,t-Date.now()));this.listeners.add(o),o()})}}export{l as PresentationReadiness};
@@ -1 +1 @@
1
- var n=["SSR","SR","R","UC","C"],e=(t)=>{let r=n.indexOf(t);return r===-1?n.length:r};function R(t){return[...t].sort((r,o)=>e(r.rarity_code)-e(o.rarity_code))}export{R as sortByRarityDesc};
1
+ var n=["SSR","SR","R","UC","C"],e=(r)=>{let t=n.indexOf(r);return t===-1?n.length:t};function R(r){return[...r].toSorted((t,o)=>e(t.rarity_code)-e(o.rarity_code))}export{R as sortByRarityDesc};
@@ -1 +1 @@
1
- import{createStore as h}from"zustand/vanilla";import{accountKey as y}from"../../index.js";import{vibemonHost as m}from"../host.js";var l=h(()=>({status:"idle"})),w=()=>l.getState().status,S=(e)=>l.setState({status:e}),x=(e)=>l.subscribe((o)=>e(o.status)),n=null;async function R(){let e=m();if(e.synchronizeResources!==void 0)return e.synchronizeResources();let o=e.account();if(o===null)return;let i=`${y(o)}/${o.revision}`,r=()=>{let t=e.account();return t!==null&&`${y(t)}/${t.revision}`===i};if(n?.scope===i)return n.operation;let s=(t)=>{if(r())S(t)},a=(async()=>{s("checking");try{let t=await e.assets.getVibemonCatalog();if(!r())return;let u=new Set,f=0,d=!1;if(await Promise.all(Array.from({length:Math.min(6,t.length)},async()=>{while(r()&&f<t.length){let c=t[f++];try{if((await e.assets.resources.inspect(c.uuid))?.version===c.resource_version)continue;s("updating"),await e.assets.resources.ensure(c),u.add(c.uuid)}catch(p){if(d=!0,r())e.onError(p)}}})),r())await e.resourcesSynchronized?.(u);s(d?"error":u.size===0?"idle":"done")}catch(t){if(s("error"),r())e.onError(t)}})();n={scope:i,operation:a};try{await a}finally{if(n?.operation===a)n=null}}export{S as observeResourceSync,w as resourceSyncStatus,x as subscribeResourceSync,R as syncVibemonResources,l as vibemonSyncStore};
1
+ import{createStore as m}from"zustand/vanilla";import{accountKey as h}from"../../index.js";import{vibemonHost as S}from"../host.js";var l=m(()=>({status:"idle"})),R=()=>l.getState().status,g=(e)=>l.setState({status:e}),x=(e)=>l.subscribe((s)=>e(s.status)),c=null;async function z(){let e=S();if(e.synchronizeResources!==void 0)return e.synchronizeResources();let s=e.account();if(s===null)return;let a=`${h(s)}/${s.revision}`,o=()=>{let r=e.account();return r!==null&&`${h(r)}/${r.revision}`===a};if(c?.scope===a)return c.operation;let i=(r)=>{if(o())g(r)},d=(r,n)=>{if(!o())return;if(e.onResourceSyncError)e.onResourceSyncError(r,n);else console.warn("[vibemon] resource sync failed",n,r)},u=(async()=>{i("checking");try{let r=await e.assets.getVibemonCatalog();if(!o())return;let n=new Set,f=0,p=!1;if(await Promise.all(Array.from({length:Math.min(6,r.length)},async()=>{while(o()&&f<r.length){let t=r[f++];try{if((await e.assets.resources.inspect(t.uuid))?.version===t.resource_version)continue;i("updating"),await e.assets.resources.ensure(t),n.add(t.uuid)}catch(y){p=!0,d(y,{phase:"resource",petId:t.uuid})}}})),o())try{await e.resourcesSynchronized?.(n)}catch(t){if(o())e.onError(t)}i(p?"error":n.size===0?"idle":"done")}catch(r){i("error"),d(r,{phase:"catalog"})}})();c={scope:a,operation:u};try{await u}finally{if(c?.operation===u)c=null}}export{g as observeResourceSync,R as resourceSyncStatus,x as subscribeResourceSync,z as syncVibemonResources,l as vibemonSyncStore};
@@ -1 +1 @@
1
- import{vibemonHost as s}from"../host.js";var e={"vibemon.accounts":{},"vibemon.introSeen":{},"vibemon.albumHasUnseen":{},"vibemon.onboardingStep":{}},i=new Set,r=0;async function c(){let t=++r,n=s(),a=await Promise.all(Object.keys(e).map(async(o)=>[o,await n.storage.get(o)??{}]));if(r!==t)return;e=Object.fromEntries(a);for(let o of i)o()}async function p(){let t=s().subscribeStorage(()=>{c().catch(s().onError)});return await c(),()=>{r++,t()}}var b=(t)=>(i.add(t),()=>{i.delete(t)}),u=(t)=>e[t],f=async(t)=>e[t];function S(t,n){r++,e={...e,[t]:n};for(let a of i)a()}async function m(t,n){await s().storage.set(t,n),await c()}export{f as getSetting,u as getSettingSync,p as initializeSettings,c as refreshSettings,m as setSetting,b as subscribeSettings,S as updateSettingCache};
1
+ import{vibemonHost as s}from"../host.js";var e={"vibemon.accounts":{},"vibemon.introSeen":{},"vibemon.albumHasUnseen":{},"vibemon.onboardingStep":{}},i=new Set,r=0;async function c(){let t=++r,n=s(),a=await Promise.all(Object.keys(e).map(async(o)=>[o,await n.storage.get(o)??{}]));if(r!==t)return;e=Object.fromEntries(a);for(let o of i)o()}async function p(){let t=s().subscribeStorage(()=>{c().catch(s().onError)});return await c(),()=>{r++,t()}}var b=(t)=>(i.add(t),()=>{i.delete(t)}),u=(t)=>e[t],f=(t)=>Promise.resolve(e[t]);function m(t,n){r++,e={...e,[t]:n};for(let a of i)a()}async function S(t,n){await s().storage.set(t,n),await c()}export{f as getSetting,u as getSettingSync,p as initializeSettings,c as refreshSettings,S as setSetting,b as subscribeSettings,m as updateSettingCache};
@@ -1 +1 @@
1
- import{vibemonHost as c}from"../host.js";import{spriteConfig as a}from"./sprite-config.js";async function l(e){return await c().assets.resources.inspect(e)!==null}async function b(e){let o=c().assets,t=await o.resources.cached(e)??await o.ensureResource(e),s=t.sheet,n=s[0]===137&&s[1]===80,r=URL.createObjectURL(new Blob([s.slice().buffer],{type:n?"image/png":"image/webp"}));return{config:a(e,t),spriteUrl:r,dispose:()=>URL.revokeObjectURL(r)}}export{b as loadVibemonResource,l as verifyVibemonResource};
1
+ import{vibemonHost as n}from"../host.js";import{spriteConfig as a}from"./sprite-config.js";async function b(e){return await n().assets.resources.inspect(e)!==null}async function f(e){let o=n().assets,t=await o.resources.cached(e)??await o.ensureResource(e),s=t.sheet,c=s[0]===137&&s[1]===80,r=URL.createObjectURL(new Blob([new Uint8Array(s).buffer],{type:c?"image/png":"image/webp"}));return{config:a(e,t),spriteUrl:r,dispose:()=>URL.revokeObjectURL(r)}}export{f as loadVibemonResource,b as verifyVibemonResource};
@@ -38,10 +38,7 @@ export interface VibemonSpriteConfig {
38
38
  license?: string;
39
39
  attribution?: string;
40
40
  behaviorMap: VibemonBehaviorMap;
41
- hatchSequence?: [
42
- string,
43
- number
44
- ][];
41
+ hatchSequence?: [string, number][];
45
42
  states: VibemonSpriteState[];
46
43
  }
47
44
  export interface VibemonNotification {
@@ -4,22 +4,22 @@ export interface PetAccount {
4
4
  revision: number;
5
5
  }
6
6
  export interface PetStorage {
7
- get<T>(key: string): Promise<T | null | undefined>;
8
- set(key: string, value: unknown): Promise<void>;
7
+ get: <T>(key: string) => Promise<T | null | undefined>;
8
+ set: (key: string, value: unknown) => Promise<void>;
9
9
  }
10
10
  export interface PetResourceIO {
11
- exists(path: string): Promise<boolean>;
12
- read(path: string): Promise<Uint8Array | null>;
13
- write(path: string, bytes: Uint8Array): Promise<void>;
14
- replace(temporary: string, destination: string): Promise<void>;
15
- remove(path: string): Promise<void>;
11
+ exists: (path: string) => Promise<boolean>;
12
+ read: (path: string) => Promise<Uint8Array | null>;
13
+ write: (path: string, bytes: Uint8Array) => Promise<void>;
14
+ replace: (temporary: string, destination: string) => Promise<void>;
15
+ remove: (path: string) => Promise<void>;
16
16
  }
17
17
  export interface PetAssetsHost {
18
- account(): PetAccount | null;
19
- request<T>(path: string, method: "GET" | "POST", body?: unknown): Promise<T>;
18
+ account: () => PetAccount | null;
19
+ request: <T>(path: string, method: "GET" | "POST", body?: unknown) => Promise<T>;
20
20
  storage: PetStorage;
21
21
  resources: PetResourceIO;
22
- download(url: string, signal: AbortSignal): Promise<Uint8Array>;
22
+ download: (url: string, signal: AbortSignal) => Promise<Uint8Array>;
23
23
  }
24
24
  export declare function accountKey(account: PetAccount): string;
25
25
  export declare function assertAccount(host: Pick<PetAssetsHost, "account">, expected: PetAccount): void;
@@ -1 +1 @@
1
- import o from"../../../assets/pets/vibemon/home/home-bg.webp?url";import r from"../../../assets/pets/vibemon/home/intro.mp4?url&no-inline";import t from"../../../assets/pets/vibemon/home/pull.mp4?url&no-inline";import e from"../../../assets/pets/vibemon/home/pull.webm?url&no-inline";import m from"../../../assets/pets/vibemon/guide/arrow.svg?url";import p from"../../../assets/pets/vibemon/guide/bubble-texture-home.png?url";import i from"../../../assets/pets/vibemon/guide/bubble-texture-pull.png?url";import l from"../../../assets/pets/vibemon/guide/mascot.png?url";import n from"../../../assets/pets/vibemon/guide/hand.svg?url";import u from"../../../assets/pets/vibemon/guide/hand-shape.svg?url";import c from"../../../assets/pets/vibemon/guide/hand-sheen.png?url";import s from"../../../assets/pets/vibemon/guide/ring.svg?url";import a from"../../../assets/pets/vibemon/album/arrow.svg?url";import f from"../../../assets/pets/vibemon/album/book.webp?url";import d from"../../../assets/pets/vibemon/album/page-bg.webp?url";import g from"../../../assets/pets/vibemon/equip/page-bg.webp?url";import x from"../../../assets/pets/vibemon/equip/single-pet-toast.png?url";import U from"../../../assets/pets/vibemon/loading/background.webp?url";import h from"../../../assets/pets/vibemon/loading/logo.webp?url";import b from"../../../assets/pets/vibemon/multi-draw/bg-sr.png?url";import B from"../../../assets/pets/vibemon/multi-draw/bg-ssr.png?url";import k from"../../../assets/pets/card-draw/wish.webp?url";import P from"../../../assets/pets/card-draw/wish-default.png?url";import w from"../../../assets/pets/card-draw/new-tag.svg?url";import H from"../../../assets/pets/card-draw/not-enough-dialog.png?url";import A from"../../../assets/pets/card-draw/dialog-close.png?url";import v from"../../../assets/pets/card-draw/empty-pet.png?url";import T from"../../../assets/pets/card-draw/gem.svg?url";import I from"../../../assets/pets/card-draw/gem-plus.svg?url";import V from"../../../assets/pets/card-draw/pull-texture.png?url";import D from"../../../assets/pets/card-draw/pull-gem.svg?url";import S from"../../../assets/pets/card-draw/pull-page-background.png?url";import W from"../../../assets/pets/card-draw/pull-back-transparent.png?url";import C from"../../../assets/pets/card-draw/pull-vibemon-icon-transparent.png?url";import M from"../../../assets/pets/card-draw/pull-album-icon-transparent.png?url";import q from"../../../assets/pets/card-draw/album-icon.png?url";import y from"../../../assets/pets/card-draw/placeholder-card.png?url";import G from"../../../assets/pets/card-draw/result-aura.webp?url";import L from"../../../assets/pets/vibemon/home/vibemon-icon.png?url";import R from"../../../assets/pets/vibemon/home/vibemon-icon-hover.png?url";import j from"../../../assets/pets/vibemon/home/vibemon-text.png?url";import z from"../../../assets/pets/vibemon/home/wish-icon.png?url";import E from"../../../assets/pets/vibemon/home/wish-icon-hover.png?url";import F from"../../../assets/pets/vibemon/home/wish-text.png?url";import J from"../../../assets/pets/vibemon/home/album-icon.png?url";import K from"../../../assets/pets/vibemon/home/album-icon-hover.png?url";import N from"../../../assets/pets/vibemon/home/album-text.png?url";import O from"../../../assets/pets/card-draw/proceed-default.png?url";import Q from"../../../assets/pets/card-draw/proceed-hover.png?url";import X from"../../../assets/pets/card-draw/proceed-active.png?url";var Qo={vibemon:{icon:L,hover:R,text:j},wish:{icon:z,hover:E,text:F},album:{icon:J,hover:K,text:N}},Xo={default:O,hover:Q,active:X},Yo=o,Zo=r,_o=t,$o=e,or=m,rr=p,tr=i,er=l,mr=n,pr=u,ir=c,lr=s,nr=a,ur=f,cr=d,sr=g,ar=x,fr=U,dr=h,gr=b,xr=B,Ur=k,hr=P,br=w,Br=H,kr=A,Pr=v,wr=T,Hr=I,Ar=V,vr=D,Tr=S,Ir=W,Vr=C,Dr=M,Sr=q,Wr=y,Cr=G;export{nr as albumArrow,ur as albumBook,Sr as albumIcon,cr as albumPageBackground,kr as dialogClose,Pr as emptyPet,sr as equipPageBackground,wr as gem,Hr as gemPlus,or as guideArrow,mr as guideHand,pr as guideHandShape,ir as guideHandSheen,rr as guideHomeTexture,er as guideMascot,tr as guidePullTexture,lr as guideRing,Yo as homeBackground,Qo as homeHotspotAssets,Br as insufficientPointsDialog,Zo as introVideo,fr as loadingBackground,dr as loadingLogo,gr as multiDrawSrBackground,xr as multiDrawSsrBackground,br as newTag,Wr as placeholderCard,Xo as proceedButtonAssets,Dr as pullAlbumIcon,Ir as pullBack,vr as pullGem,Tr as pullPageBackground,Ar as pullTexture,Vr as pullVibemonIcon,_o as pullVideoMp4,$o as pullVideoWebm,Cr as resultAura,ar as singlePetToast,hr as wishDefault,Ur as wishHover};
1
+ import o from"../../../assets/pets/card-draw/album-icon.png?url";import r from"../../../assets/pets/card-draw/dialog-close.png?url";import t from"../../../assets/pets/card-draw/empty-pet.png?url";import e from"../../../assets/pets/card-draw/gem-plus.svg?url";import m from"../../../assets/pets/card-draw/gem.svg?url";import p from"../../../assets/pets/card-draw/new-tag.svg?url";import i from"../../../assets/pets/card-draw/not-enough-dialog.png?url";import l from"../../../assets/pets/card-draw/placeholder-card.png?url";import n from"../../../assets/pets/card-draw/proceed-active.png?url";import u from"../../../assets/pets/card-draw/proceed-default.png?url";import c from"../../../assets/pets/card-draw/proceed-hover.png?url";import s from"../../../assets/pets/card-draw/pull-album-icon-transparent.png?url";import a from"../../../assets/pets/card-draw/pull-back-transparent.png?url";import f from"../../../assets/pets/card-draw/pull-gem.svg?url";import d from"../../../assets/pets/card-draw/pull-page-background.png?url";import g from"../../../assets/pets/card-draw/pull-texture.png?url";import x from"../../../assets/pets/card-draw/pull-vibemon-icon-transparent.png?url";import U from"../../../assets/pets/card-draw/result-aura.webp?url";import h from"../../../assets/pets/card-draw/wish-default.png?url";import b from"../../../assets/pets/card-draw/wish.webp?url";import B from"../../../assets/pets/vibemon/album/arrow.svg?url";import k from"../../../assets/pets/vibemon/album/book.webp?url";import P from"../../../assets/pets/vibemon/album/page-bg.webp?url";import w from"../../../assets/pets/vibemon/equip/page-bg.webp?url";import H from"../../../assets/pets/vibemon/equip/single-pet-toast.png?url";import A from"../../../assets/pets/vibemon/guide/arrow.svg?url";import v from"../../../assets/pets/vibemon/guide/bubble-texture-home.png?url";import T from"../../../assets/pets/vibemon/guide/bubble-texture-pull.png?url";import I from"../../../assets/pets/vibemon/guide/hand-shape.svg?url";import V from"../../../assets/pets/vibemon/guide/hand-sheen.png?url";import D from"../../../assets/pets/vibemon/guide/hand.svg?url";import S from"../../../assets/pets/vibemon/guide/mascot.png?url";import W from"../../../assets/pets/vibemon/guide/ring.svg?url";import C from"../../../assets/pets/vibemon/home/album-icon-hover.png?url";import M from"../../../assets/pets/vibemon/home/album-icon.png?url";import q from"../../../assets/pets/vibemon/home/album-text.png?url";import y from"../../../assets/pets/vibemon/home/home-bg.webp?url";import G from"../../../assets/pets/vibemon/home/intro.mp4?url&no-inline";import L from"../../../assets/pets/vibemon/home/pull.mp4?url&no-inline";import R from"../../../assets/pets/vibemon/home/pull.webm?url&no-inline";import j from"../../../assets/pets/vibemon/home/vibemon-icon-hover.png?url";import z from"../../../assets/pets/vibemon/home/vibemon-icon.png?url";import E from"../../../assets/pets/vibemon/home/vibemon-text.png?url";import F from"../../../assets/pets/vibemon/home/wish-icon-hover.png?url";import J from"../../../assets/pets/vibemon/home/wish-icon.png?url";import K from"../../../assets/pets/vibemon/home/wish-text.png?url";import N from"../../../assets/pets/vibemon/loading/background.webp?url";import O from"../../../assets/pets/vibemon/loading/logo.webp?url";import Q from"../../../assets/pets/vibemon/multi-draw/bg-sr.png?url";import X from"../../../assets/pets/vibemon/multi-draw/bg-ssr.png?url";var Qo={vibemon:{icon:z,hover:j,text:E},wish:{icon:J,hover:F,text:K},album:{icon:M,hover:C,text:q}},Xo={default:u,hover:c,active:n},Yo=y,Zo=G,_o=L,$o=R,or=A,rr=v,tr=T,er=S,mr=D,pr=I,ir=V,lr=W,nr=B,ur=k,cr=P,sr=w,ar=H,fr=N,dr=O,gr=Q,xr=X,Ur=b,hr=h,br=p,Br=i,kr=r,Pr=t,wr=m,Hr=e,Ar=g,vr=f,Tr=d,Ir=a,Vr=x,Dr=s,Sr=o,Wr=l,Cr=U;export{nr as albumArrow,ur as albumBook,Sr as albumIcon,cr as albumPageBackground,kr as dialogClose,Pr as emptyPet,sr as equipPageBackground,wr as gem,Hr as gemPlus,or as guideArrow,mr as guideHand,pr as guideHandShape,ir as guideHandSheen,rr as guideHomeTexture,er as guideMascot,tr as guidePullTexture,lr as guideRing,Yo as homeBackground,Qo as homeHotspotAssets,Br as insufficientPointsDialog,Zo as introVideo,fr as loadingBackground,dr as loadingLogo,gr as multiDrawSrBackground,xr as multiDrawSsrBackground,br as newTag,Wr as placeholderCard,Xo as proceedButtonAssets,Dr as pullAlbumIcon,Ir as pullBack,vr as pullGem,Tr as pullPageBackground,Ar as pullTexture,Vr as pullVibemonIcon,_o as pullVideoMp4,$o as pullVideoWebm,Cr as resultAura,ar as singlePetToast,hr as wishDefault,Ur as wishHover};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as i,Fragment as c}from"react/jsx-runtime";import{albumArrow as C,albumBook as x,albumPageBackground as k}from"../assets.js";import{Loader2 as y}from"lucide-react";import{useMemo as N,useState as V}from"react";import{Button as _}from"../ui/button.js";import{cardThumb as A}from"../lib/card-image.js";import{sortByRarityDesc as P}from"../../core/lib/rarity.js";import{cn as f}from"../lib/utils.js";import{VibemonEmptyState as B}from"./vibemon-empty-state.js";import{VibemonHeader as M}from"./vibemon-header.js";import{VibemonScene as j}from"./vibemon-scene.js";var l=8;function h({direction:r,disabled:t,onClick:a}){let o=r==="previous";return e(_,{"aria-label":o?"Previous album page":"Next album page",disabled:t,onClick:a,className:f("absolute top-[55.870%] z-20 size-[2.917cqw] bg-transparent p-0 shadow-none transition-none hover:bg-transparent disabled:opacity-100",o?"left-[20.521%]":"left-[76.563%]"),children:e("img",{src:C,alt:"",className:f("h-[63.9%] w-[46.2%] max-w-none select-none",o&&"-scale-x-100",t&&"opacity-50")})})}function E(){return i("div",{className:"relative h-full w-full",children:[e("svg",{viewBox:"0 0 200 288",preserveAspectRatio:"none","aria-hidden":!0,className:"absolute inset-0 h-full w-full opacity-25",children:e("rect",{x:"6.16",y:"7.76",width:"187.69",height:"272.47",rx:"14",fill:"none",stroke:"#8687CE",strokeWidth:"5",strokeDasharray:"25 25"})}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"67",height:"80",viewBox:"0 0 67 80",fill:"none",className:"absolute top-[50%] left-[50%] h-[27.5%] w-[33.1%] max-w-none translate-x-[-50%] translate-y-[-50%] select-none",children:e("path",{d:"M46.2449 32.0803V22.6882C46.2449 15.4054 40.3462 9.50669 33.0634 9.50669C25.7807 9.50669 19.882 15.415 19.882 22.6977V32.0899H46.2449V32.0803ZM9.69759 32.1853L9.68804 31.8894V21.5714C9.68804 15.854 11.9597 10.3657 16.0067 6.3187C20.0538 2.27168 25.5325 0 31.2595 0H34.877C46.789 0 56.4388 9.65941 56.4388 21.5619V32.1853C61.9939 32.9584 66.1269 37.7118 66.1269 43.3242V67.9786C66.1269 74.1923 61.0967 79.2224 54.883 79.2224H11.2439C5.03015 79.2224 0 74.1923 0 67.9786V43.3337C0 37.7213 4.13293 32.968 9.69759 32.1853ZM30.4672 57.5747V64.9242C30.4672 66.3559 31.6317 67.5204 33.0634 67.5204C34.4952 67.5204 35.6596 66.3559 35.6596 64.9242V57.5747C38.8572 56.3243 40.7184 52.974 40.0789 49.6047C39.4394 46.2258 36.4996 43.7823 33.0634 43.7823C29.6273 43.7823 26.6779 46.2258 26.048 49.6047C25.4084 52.974 27.2697 56.3243 30.4672 57.5747Z",fill:"#8687CE",fillOpacity:"0.25"})})]})}function S({cards:r}){return i(c,{children:[e("img",{src:x,alt:"","aria-hidden":!0,className:"pointer-events-none absolute top-[14.158%] left-[14.583%] h-[79.313%] w-[74.067%] max-w-none select-none",style:{maskImage:"linear-gradient(to bottom, rgba(255,255,255,0.8) 0%, #fff 25.66%, #fff 93.71%, rgba(255,255,255,0.2) 100%)",WebkitMaskImage:"linear-gradient(to bottom, rgba(255,255,255,0.8) 0%, #fff 25.66%, #fff 93.71%, rgba(255,255,255,0.2) 100%)"}}),e("div",{"data-testid":"album-book",className:"absolute top-[32.917%] left-[25.729%] grid h-[50.574%] w-[48.542%] grid-cols-4 grid-rows-2 gap-x-[4.721%] gap-y-[4.943%]",children:r.map((t,a)=>e("div",{className:"relative",children:t?e("img",{src:A(t.gacha_url??t.cover_url),alt:`${t.name} ${t.rarity_name} card`,className:"h-full w-full object-contain drop-shadow-[0_8px_9px_rgba(15,8,64,0.24)] select-none"}):e(E,{})},t?`${t.vibemon_uuid}-${a}`:`locked-${a}`))})]})}function T({onBack:r,onWish:t,onEquip:a,ownedCards:o,ownedLoaded:g,availablePoints:b,pointsLoaded:w}){let[v,u]=V(0),m=N(()=>P(o).flatMap((p)=>Array.from({length:p.duplicate_count},()=>p)),[o]),s=Math.ceil(m.length/l),n=s===0?0:Math.min(v,s-1),d=[...m.slice(n*l,(n+1)*l)];while(d.length<l)d.push(null);return i(j,{backdrop:i(c,{children:[e("img",{src:k,alt:"","aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full object-cover select-none"}),e("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 bg-[#422053]/20"})]}),children:[e(M,{onBack:r,onWish:t,sectionAction:{kind:"equip",onClick:a},availablePoints:b,pointsLoaded:w}),!g?e("div",{"data-testid":"vibemon-owned-loading",className:"absolute inset-0 flex items-center justify-center text-[#DCC9FF]",children:e(y,{className:"size-8 animate-spin"})}):m.length===0?e(B,{onWish:t}):i(c,{children:[e(S,{cards:d}),s>1&&i(c,{children:[e(h,{direction:"previous",disabled:n===0,onClick:()=>u(n-1)}),e(h,{direction:"next",disabled:n>=s-1,onClick:()=>u(n+1)})]})]})]})}export{T as AlbumView};
1
+ import{jsx as e,jsxs as i,Fragment as c}from"react/jsx-runtime";import{Loader2 as C}from"lucide-react";import{useMemo as x,useState as k}from"react";import{sortByRarityDesc as y}from"../../core/lib/rarity.js";import{albumArrow as N,albumBook as V,albumPageBackground as _}from"../assets.js";import{cardThumb as A}from"../lib/card-image.js";import{cn as f}from"../lib/utils.js";import{Button as P}from"../ui/button.js";import{VibemonEmptyState as B}from"./vibemon-empty-state.js";import{VibemonHeader as M}from"./vibemon-header.js";import{VibemonScene as j}from"./vibemon-scene.js";var l=8;function h({direction:r,disabled:t,onClick:a}){let o=r==="previous";return e(P,{"aria-label":o?"Previous album page":"Next album page",disabled:t,onClick:a,className:f("absolute top-[55.870%] z-20 size-[2.917cqw] bg-transparent p-0 shadow-none transition-none hover:bg-transparent disabled:opacity-100",o?"left-[20.521%]":"left-[76.563%]"),children:e("img",{src:N,alt:"",className:f("h-[63.9%] w-[46.2%] max-w-none select-none",o&&"-scale-x-100",t&&"opacity-50")})})}function E(){return i("div",{className:"relative h-full w-full",children:[e("svg",{viewBox:"0 0 200 288",preserveAspectRatio:"none","aria-hidden":!0,className:"absolute inset-0 h-full w-full opacity-25",children:e("rect",{x:"6.16",y:"7.76",width:"187.69",height:"272.47",rx:"14",fill:"none",stroke:"#8687CE",strokeWidth:"5",strokeDasharray:"25 25"})}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"67",height:"80",viewBox:"0 0 67 80",fill:"none",className:"absolute top-[50%] left-[50%] h-[27.5%] w-[33.1%] max-w-none translate-x-[-50%] translate-y-[-50%] select-none",children:e("path",{d:"M46.2449 32.0803V22.6882C46.2449 15.4054 40.3462 9.50669 33.0634 9.50669C25.7807 9.50669 19.882 15.415 19.882 22.6977V32.0899H46.2449V32.0803ZM9.69759 32.1853L9.68804 31.8894V21.5714C9.68804 15.854 11.9597 10.3657 16.0067 6.3187C20.0538 2.27168 25.5325 0 31.2595 0H34.877C46.789 0 56.4388 9.65941 56.4388 21.5619V32.1853C61.9939 32.9584 66.1269 37.7118 66.1269 43.3242V67.9786C66.1269 74.1923 61.0967 79.2224 54.883 79.2224H11.2439C5.03015 79.2224 0 74.1923 0 67.9786V43.3337C0 37.7213 4.13293 32.968 9.69759 32.1853ZM30.4672 57.5747V64.9242C30.4672 66.3559 31.6317 67.5204 33.0634 67.5204C34.4952 67.5204 35.6596 66.3559 35.6596 64.9242V57.5747C38.8572 56.3243 40.7184 52.974 40.0789 49.6047C39.4394 46.2258 36.4996 43.7823 33.0634 43.7823C29.6273 43.7823 26.6779 46.2258 26.048 49.6047C25.4084 52.974 27.2697 56.3243 30.4672 57.5747Z",fill:"#8687CE",fillOpacity:"0.25"})})]})}function S({cards:r}){return i(c,{children:[e("img",{src:V,alt:"","aria-hidden":!0,className:"pointer-events-none absolute top-[14.158%] left-[14.583%] h-[79.313%] w-[74.067%] max-w-none select-none",style:{maskImage:"linear-gradient(to bottom, rgba(255,255,255,0.8) 0%, #fff 25.66%, #fff 93.71%, rgba(255,255,255,0.2) 100%)",WebkitMaskImage:"linear-gradient(to bottom, rgba(255,255,255,0.8) 0%, #fff 25.66%, #fff 93.71%, rgba(255,255,255,0.2) 100%)"}}),e("div",{"data-testid":"album-book",className:"absolute top-[32.917%] left-[25.729%] grid h-[50.574%] w-[48.542%] grid-cols-4 grid-rows-2 gap-x-[4.721%] gap-y-[4.943%]",children:r.map((t,a)=>e("div",{className:"relative",children:t?e("img",{src:A(t.gacha_url??t.cover_url),alt:`${t.name} ${t.rarity_name} card`,className:"h-full w-full object-contain drop-shadow-[0_8px_9px_rgba(15,8,64,0.24)] select-none"}):e(E,{})},t?`${t.vibemon_uuid}-${a}`:`locked-${a}`))})]})}function T({onBack:r,onWish:t,onEquip:a,ownedCards:o,ownedLoaded:g,availablePoints:b,pointsLoaded:w}){let[v,u]=k(0),m=x(()=>y(o).flatMap((p)=>Array.from({length:p.duplicate_count},()=>p)),[o]),s=Math.ceil(m.length/l),n=s===0?0:Math.min(v,s-1),d=[...m.slice(n*l,(n+1)*l)];while(d.length<l)d.push(null);return i(j,{backdrop:i(c,{children:[e("img",{src:_,alt:"","aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full object-cover select-none"}),e("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 bg-[#422053]/20"})]}),children:[e(M,{onBack:r,onWish:t,sectionAction:{kind:"equip",onClick:a},availablePoints:b,pointsLoaded:w}),!g?e("div",{"data-testid":"vibemon-owned-loading",className:"absolute inset-0 flex items-center justify-center text-[#DCC9FF]",children:e(C,{className:"size-8 animate-spin"})}):m.length===0?e(B,{onWish:t}):i(c,{children:[e(S,{cards:d}),s>1&&i(c,{children:[e(h,{direction:"previous",disabled:n===0,onClick:()=>u(n-1)}),e(h,{direction:"next",disabled:n>=s-1,onClick:()=>u(n+1)})]})]})]})}export{T as AlbumView};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{Button as i}from"../ui/button.js";import{cn as l}from"../lib/utils.js";function d({onClick:n,className:a,disabled:t=!1,label:o="Home",iconSrc:s}){return r(i,{variant:"ghost",className:l("h-auto gap-2 p-0 text-[#8A55C5]/80 hover:bg-transparent hover:text-[#8A55C5]/80",a),disabled:t,onClick:n,children:[s===void 0?e("svg",{viewBox:"0 0 28 28",fill:"none","aria-hidden":"true",className:"size-7 shrink-0",children:e("path",{d:"M12.5709 8.57642V3.93455C12.5867 3.8165 12.5756 3.69641 12.5382 3.5833C12.5009 3.4702 12.4384 3.36704 12.3555 3.28158C12.2055 3.1325 12.0026 3.04883 11.7911 3.04883C11.5796 3.04883 11.3767 3.1325 11.2267 3.28158L3.36348 11.9028C3.21724 12.0686 3.13655 12.2821 3.13655 12.5031C3.13655 12.7242 3.21724 12.9377 3.36348 13.1035L11.1838 21.6749C11.4769 21.9248 12.0112 22.0656 12.3557 21.7208C12.534 21.5431 12.6114 21.3927 12.5857 21.1608V16.4383C17.0974 16.4383 21.2356 19.2604 22.8549 23.2291C23.0887 23.8033 23.9213 23.7437 24.066 23.1416C24.2809 22.2415 24.3892 21.3193 24.3886 20.3938C24.3908 13.8674 19.1001 8.57642 12.5709 8.57642Z",fill:"currentColor"})}):e("img",{src:s,alt:"",className:"size-7 shrink-0"}),e("span",{className:"text-[20px] leading-none font-semibold select-none",children:o})]})}export{d as BackToHome};
1
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{cn as i}from"../lib/utils.js";import{Button as l}from"../ui/button.js";function d({onClick:n,className:a,disabled:t=!1,label:o="Home",iconSrc:s}){return r(l,{variant:"ghost",className:i("h-auto gap-2 p-0 text-[#8A55C5]/80 hover:bg-transparent hover:text-[#8A55C5]/80",a),disabled:t,onClick:n,children:[s===void 0?e("svg",{viewBox:"0 0 28 28",fill:"none","aria-hidden":"true",className:"size-7 shrink-0",children:e("path",{d:"M12.5709 8.57642V3.93455C12.5867 3.8165 12.5756 3.69641 12.5382 3.5833C12.5009 3.4702 12.4384 3.36704 12.3555 3.28158C12.2055 3.1325 12.0026 3.04883 11.7911 3.04883C11.5796 3.04883 11.3767 3.1325 11.2267 3.28158L3.36348 11.9028C3.21724 12.0686 3.13655 12.2821 3.13655 12.5031C3.13655 12.7242 3.21724 12.9377 3.36348 13.1035L11.1838 21.6749C11.4769 21.9248 12.0112 22.0656 12.3557 21.7208C12.534 21.5431 12.6114 21.3927 12.5857 21.1608V16.4383C17.0974 16.4383 21.2356 19.2604 22.8549 23.2291C23.0887 23.8033 23.9213 23.7437 24.066 23.1416C24.2809 22.2415 24.3892 21.3193 24.3886 20.3938C24.3908 13.8674 19.1001 8.57642 12.5709 8.57642Z",fill:"currentColor"})}):e("img",{src:s,alt:"",className:"size-7 shrink-0"}),e("span",{className:"text-[20px] leading-none font-semibold select-none",children:o})]})}export{d as BackToHome};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as l,Fragment as V}from"react/jsx-runtime";import{equipPageBackground as j,pullTexture as P}from"../assets.js";import{Loader2 as w}from"lucide-react";import{useCallback as T,useEffect as R,useState as g}from"react";import{useTranslation as B}from"react-i18next";import{toast as y}from"sonner";import{Button as C}from"../ui/button.js";import{openVibemonWindow as D}from"../../core/lib/window-manager.js";import{getVibemonState as I,updateVibemonState as m,useVibemonState as z}from"../lib/account-state.js";import{cardThumb as L}from"../lib/card-image.js";import{sortByRarityDesc as O}from"../../core/lib/rarity.js";import{useVibemonSyncStore as U}from"../lib/resource-sync.js";import{verifyVibemonResource as W}from"../../core/lib/vibemon-resources.js";import{SinglePetToast as A}from"./single-pet-toast.js";import{VibemonEmptyState as G}from"./vibemon-empty-state.js";import{VibemonHeader as H}from"./vibemon-header.js";import{VibemonScene as Y}from"./vibemon-scene.js";async function J(e,i){let{pet:s}=await I();if(!s){if(e.length!==1)return;let n=e.find((a)=>i[a.vibemon_uuid]);if(n)await m({pet:n.vibemon_uuid});return}if(i[s])return;let r=e.find((n)=>i[n.vibemon_uuid]);if(r)await m({pet:r.vibemon_uuid})}function K(e){if(e.icon_url===null)throw Error(`[vibemon] owned Vibemon ${e.vibemon_uuid} is missing icon_url`);return e.icon_url}function M(e){if(e.background_url===null)throw Error(`[vibemon] owned Vibemon ${e.vibemon_uuid} is missing background_url`);return e.background_url}function Q({item:e,isCurrent:i,isDownloaded:s,onSelectedClick:r,onEquip:n}){return l("div",{"data-testid":"equip-list-item",className:"relative h-[10.673cqw] w-full shrink-0",children:[l("div",{className:"absolute top-[10.302%] left-[4.878%] h-[78.079%] w-[94.309%]",children:[t("img",{src:M(e),alt:"","aria-hidden":!0,className:"absolute inset-0 h-full w-full max-w-none rounded-[1.667cqw] object-cover select-none"}),l("div",{className:"absolute top-[29.638%] left-[9.914%] w-[65.259%]",children:[t("div",{className:"truncate text-[1.875cqw] leading-[1.278] text-white",style:{fontFamily:"Outfit, system-ui, sans-serif",fontWeight:900},children:e.name}),t("div",{className:"mt-[0.104cqw] truncate text-[1.042cqw] leading-[1.25] font-medium text-white",style:{fontFamily:"Outfit, system-ui, sans-serif"},children:e.description===null?e.rarity_name:e.description})]}),l(C,{"aria-label":i?"selected":"select",disabled:!s,onClick:i?r:n,style:{backgroundColor:"#5536CC"},className:"absolute top-[31.756%] left-[70.690%] h-[41.25%] w-[17.241%] overflow-hidden rounded-full border-0 p-0 shadow-none drop-shadow-[0_0.25cqh_0_rgba(0,0,0,0.5)] transition-none hover:brightness-105 active:translate-y-0 disabled:opacity-100",children:[t("img",{src:P,alt:"",className:"pointer-events-none absolute inset-0 size-full max-w-none rounded-[inherit] object-bottom opacity-5 mix-blend-difference select-none"}),i&&t("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 bg-[#5D508B]"}),t("span",{"aria-hidden":!0,className:"absolute inset-0 shadow-[inset_0_0.2cqh_0.07cqh_0_white]"}),t("span",{className:"relative text-[1.458cqw] leading-normal font-normal text-white",style:{fontFamily:'"Grow Year", system-ui, sans-serif'},children:i?"selected":"select"})]})]}),t("div",{className:"absolute top-0 left-0 size-[7.917cqw] overflow-hidden rounded-full",children:t("img",{src:L(K(e)),alt:`${e.name} portrait`,className:"h-full w-full object-cover select-none"})})]})}function X({items:e,currentId:i,downloaded:s,onSelectedClick:r,onEquip:n}){return t("div",{className:"flex flex-col gap-[0.833cqw]",children:O(e).map((a)=>t(Q,{item:a,isCurrent:a.vibemon_uuid===i,isDownloaded:s[a.vibemon_uuid],onSelectedClick:r,onEquip:()=>n(a.vibemon_uuid)},a.vibemon_uuid))})}function he({onBack:e,onWish:i,onAlbum:s,albumHasUnseen:r,ownedCards:n,ownedLoaded:a,availablePoints:_,pointsLoaded:x}){let{i18n:q}=B("common"),u=q.getFixedT("en","common"),{pet:N}=z(),d=U((o)=>o.status==="checking"||o.status==="updating"),[f,k]=g({}),[S,b]=g(0),p=T(()=>b(0),[]);R(()=>{let o=!1;return(async()=>{let c=await Promise.all(n.map(async(v)=>[v.vibemon_uuid,await W(v.vibemon_uuid)]));if(o)return;let h=Object.fromEntries(c);if(k(h),!d)await J(n,h)})(),()=>{o=!0}},[n,d]);let E=async(o)=>{p();try{if(await m({pet:o}),await D({trusted:!0})==="unavailable")y.error(u("vibemon.actionFailed"))}catch(c){console.warn("[vibemon] equip failed",c),y.error(u("vibemon.actionFailed"))}},F=n.some((o)=>f[o.vibemon_uuid]);return l(Y,{backdrop:l(V,{children:[t("img",{src:j,alt:"","aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full object-cover opacity-10 select-none"}),t("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0",style:{background:"linear-gradient(180deg, rgba(0,0,0,0.3) 0%, rgba(102,102,102,0) 100%)"}})]}),children:[t(H,{onBack:e,onWish:i,sectionAction:{kind:"album",onClick:s,hasUnseen:r},availablePoints:_,pointsLoaded:x}),!a?t("div",{"data-testid":"vibemon-owned-loading",className:"absolute inset-0 flex items-center justify-center text-[#DCC9FF]",children:t(w,{className:"size-8 animate-spin"})}):n.length===0?t(G,{onWish:i}):d&&!F?l("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-[#DCC9FF]",children:[t(w,{className:"size-8 animate-spin"}),t("div",{className:"text-sm",children:u("vibemon.syncPreparing")})]}):t("div",{className:"absolute top-[17.167%] left-[17.969%] h-[77.833%] w-[64.063%] [scrollbar-width:none] overflow-y-auto overscroll-y-contain [&::-webkit-scrollbar]:hidden",children:t(X,{items:n,currentId:N,downloaded:f,onSelectedClick:()=>b((o)=>o+1),onEquip:(o)=>void E(o)})}),t(A,{requestId:S,onClose:p})]})}export{X as EquipList,he as EquipView};
1
+ import{jsx as t,jsxs as l,Fragment as V}from"react/jsx-runtime";import{Loader2 as w}from"lucide-react";import{useCallback as j,useEffect as P,useState as g}from"react";import{useTranslation as T}from"react-i18next";import{toast as y}from"sonner";import{sortByRarityDesc as R}from"../../core/lib/rarity.js";import{verifyVibemonResource as B}from"../../core/lib/vibemon-resources.js";import{openVibemonWindow as C}from"../../core/lib/window-manager.js";import{equipPageBackground as D,pullTexture as I}from"../assets.js";import{getVibemonState as z,updateVibemonState as m,useVibemonState as L}from"../lib/account-state.js";import{cardThumb as O}from"../lib/card-image.js";import{useVibemonSyncStore as U}from"../lib/resource-sync.js";import{Button as W}from"../ui/button.js";import{SinglePetToast as A}from"./single-pet-toast.js";import{VibemonEmptyState as G}from"./vibemon-empty-state.js";import{VibemonHeader as H}from"./vibemon-header.js";import{VibemonScene as Y}from"./vibemon-scene.js";async function J(e,i){let{pet:s}=await z();if(!s){if(e.length!==1)return;let n=e.find((a)=>i[a.vibemon_uuid]);if(n)await m({pet:n.vibemon_uuid});return}if(i[s])return;let r=e.find((n)=>i[n.vibemon_uuid]);if(r)await m({pet:r.vibemon_uuid})}function K(e){if(e.icon_url===null)throw Error(`[vibemon] owned Vibemon ${e.vibemon_uuid} is missing icon_url`);return e.icon_url}function M(e){if(e.background_url===null)throw Error(`[vibemon] owned Vibemon ${e.vibemon_uuid} is missing background_url`);return e.background_url}function Q({item:e,isCurrent:i,isDownloaded:s,onSelectedClick:r,onEquip:n}){return l("div",{"data-testid":"equip-list-item",className:"relative h-[10.673cqw] w-full shrink-0",children:[l("div",{className:"absolute top-[10.302%] left-[4.878%] h-[78.079%] w-[94.309%]",children:[t("img",{src:M(e),alt:"","aria-hidden":!0,className:"absolute inset-0 h-full w-full max-w-none rounded-[1.667cqw] object-cover select-none"}),l("div",{className:"absolute top-[29.638%] left-[9.914%] w-[65.259%]",children:[t("div",{className:"truncate text-[1.875cqw] leading-[1.278] text-white",style:{fontFamily:"Outfit, system-ui, sans-serif",fontWeight:900},children:e.name}),t("div",{className:"mt-[0.104cqw] truncate text-[1.042cqw] leading-[1.25] font-medium text-white",style:{fontFamily:"Outfit, system-ui, sans-serif"},children:e.description??e.rarity_name})]}),l(W,{"aria-label":i?"selected":"select",disabled:!s,onClick:i?r:n,style:{backgroundColor:"#5536CC"},className:"absolute top-[31.756%] left-[70.690%] h-[41.25%] w-[17.241%] overflow-hidden rounded-full border-0 p-0 shadow-none drop-shadow-[0_0.25cqh_0_rgba(0,0,0,0.5)] transition-none hover:brightness-105 active:translate-y-0 disabled:opacity-100",children:[t("img",{src:I,alt:"",className:"pointer-events-none absolute inset-0 size-full max-w-none rounded-[inherit] object-bottom opacity-5 mix-blend-difference select-none"}),i&&t("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 bg-[#5D508B]"}),t("span",{"aria-hidden":!0,className:"absolute inset-0 shadow-[inset_0_0.2cqh_0.07cqh_0_white]"}),t("span",{className:"relative text-[1.458cqw] leading-normal font-normal text-white",style:{fontFamily:'"Grow Year", system-ui, sans-serif'},children:i?"selected":"select"})]})]}),t("div",{className:"absolute top-0 left-0 size-[7.917cqw] overflow-hidden rounded-full",children:t("img",{src:O(K(e)),alt:`${e.name} portrait`,className:"h-full w-full object-cover select-none"})})]})}function X({items:e,currentId:i,downloaded:s,onSelectedClick:r,onEquip:n}){return t("div",{className:"flex flex-col gap-[0.833cqw]",children:R(e).map((a)=>t(Q,{item:a,isCurrent:a.vibemon_uuid===i,isDownloaded:s[a.vibemon_uuid],onSelectedClick:r,onEquip:()=>n(a.vibemon_uuid)},a.vibemon_uuid))})}function he({onBack:e,onWish:i,onAlbum:s,albumHasUnseen:r,ownedCards:n,ownedLoaded:a,availablePoints:_,pointsLoaded:x}){let{i18n:q}=T("common"),u=q.getFixedT("en","common"),{pet:N}=L(),d=U((o)=>o.status==="checking"||o.status==="updating"),[f,k]=g({}),[S,b]=g(0),p=j(()=>b(0),[]);P(()=>{let o=!1;return(async()=>{let c=await Promise.all(n.map(async(v)=>[v.vibemon_uuid,await B(v.vibemon_uuid)]));if(o)return;let h=Object.fromEntries(c);if(k(h),!d)await J(n,h)})(),()=>{o=!0}},[n,d]);let E=async(o)=>{p();try{if(await m({pet:o}),await C({trusted:!0})==="unavailable")y.error(u("vibemon.actionFailed"))}catch(c){console.warn("[vibemon] equip failed",c),y.error(u("vibemon.actionFailed"))}},F=n.some((o)=>f[o.vibemon_uuid]);return l(Y,{backdrop:l(V,{children:[t("img",{src:D,alt:"","aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full object-cover opacity-10 select-none"}),t("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0",style:{background:"linear-gradient(180deg, rgba(0,0,0,0.3) 0%, rgba(102,102,102,0) 100%)"}})]}),children:[t(H,{onBack:e,onWish:i,sectionAction:{kind:"album",onClick:s,hasUnseen:r},availablePoints:_,pointsLoaded:x}),!a?t("div",{"data-testid":"vibemon-owned-loading",className:"absolute inset-0 flex items-center justify-center text-[#DCC9FF]",children:t(w,{className:"size-8 animate-spin"})}):n.length===0?t(G,{onWish:i}):d&&!F?l("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-[#DCC9FF]",children:[t(w,{className:"size-8 animate-spin"}),t("div",{className:"text-sm",children:u("vibemon.syncPreparing")})]}):t("div",{className:"absolute top-[17.167%] left-[17.969%] h-[77.833%] w-[64.063%] [scrollbar-width:none] overflow-y-auto overscroll-y-contain [&::-webkit-scrollbar]:hidden",children:t(X,{items:n,currentId:N,downloaded:f,onSelectedClick:()=>b((o)=>o+1),onEquip:(o)=>void E(o)})}),t(A,{requestId:S,onClose:p})]})}export{X as EquipList,he as EquipView};
@@ -1 +1 @@
1
- import{jsx as a,jsxs as m}from"react/jsx-runtime";import{gem as n,gemPlus as o}from"../assets.js";import{Loader2 as i}from"lucide-react";import{Button as d}from"../ui/button.js";import{Card as c}from"../ui/card.js";import{cn as p}from"../lib/utils.js";function N({amount:e,onAdd:s,loaded:t=!0,disabled:r=!1,className:l}){return m(c,{className:p("flex h-11 w-fit min-w-[137px] flex-row items-center gap-0 rounded-full border-0 bg-[#F4EFFF] px-1.5 py-0 ring-0",l),children:[a("img",{"data-slot":"gem-balance-icon",src:n,alt:"",className:"me-0.5 size-8 shrink-0"}),a("span",{"data-slot":"gem-balance-amount",className:"flex-1 text-start text-xl leading-none font-bold text-[#2A3472] tabular-nums",children:t?e:a(i,{className:"size-4 animate-spin text-[#2A3472]/50"})}),a(d,{"data-slot":"gem-balance-add",variant:"ghost",className:"ms-[14px] size-8 shrink-0 rounded-full p-0 hover:bg-transparent","aria-label":"Add gems",disabled:r,onClick:s,children:a("img",{"data-slot":"gem-balance-add-icon",src:o,alt:"",className:"size-8"})})]})}export{N as GemBalance};
1
+ import{jsx as a,jsxs as m}from"react/jsx-runtime";import{Loader2 as n}from"lucide-react";import{gem as o,gemPlus as i}from"../assets.js";import{cn as d}from"../lib/utils.js";import{Button as c}from"../ui/button.js";import{Card as p}from"../ui/card.js";function N({amount:e,onAdd:s,loaded:t=!0,disabled:r=!1,className:l}){return m(p,{className:d("flex h-11 w-fit min-w-[137px] flex-row items-center gap-0 rounded-full border-0 bg-[#F4EFFF] px-1.5 py-0 ring-0",l),children:[a("img",{"data-slot":"gem-balance-icon",src:o,alt:"",className:"me-0.5 size-8 shrink-0"}),a("span",{"data-slot":"gem-balance-amount",className:"flex-1 text-start text-xl leading-none font-bold text-[#2A3472] tabular-nums",children:t?e:a(n,{className:"size-4 animate-spin text-[#2A3472]/50"})}),a(c,{"data-slot":"gem-balance-add",variant:"ghost",className:"ms-[14px] size-8 shrink-0 rounded-full p-0 hover:bg-transparent","aria-label":"Add gems",disabled:r,onClick:s,children:a("img",{"data-slot":"gem-balance-add-icon",src:i,alt:"",className:"size-8"})})]})}export{N as GemBalance};
@@ -1 +1 @@
1
- import{jsx as l,jsxs as c}from"react/jsx-runtime";import{homeBackground as b,homeHotspotAssets as m}from"../assets.js";import{useLayoutEffect as p,useRef as g,useState as f}from"react";import{Button as x}from"../ui/button.js";import{HomeWishGuide as w,OnboardingScrim as v}from"./onboarding-guide.js";var d=1.778723404255319,y="#120E18",r={x1:0.3,x2:0.8,y1:0.56,y2:1},N=r.x2-r.x1,S=r.y2-r.y1,E=(r.x1+r.x2)/2,k=0.8;function M(t,n){let a=Math.max(t,n*d),s=Math.min(t/N,n/S*d),e=Math.max(Math.min(a,s),k*a),o=e/d,i=e<=t?(t-e)/2:Math.min(0,Math.max(t-e,t/2-E*e)),h=o<=n?(n-o)/2:n-o;return{width:e,height:o,left:i,top:h}}function C(t){let[n,a]=f({width:0,height:0,left:0,top:0});return p(()=>{let s=t.current;if(!s)return;let e=new ResizeObserver(([o])=>{let{width:i,height:h}=o.contentRect;a(M(i,h))});return e.observe(s),()=>e.disconnect()},[t]),n}var _={vibemon:{box:{left:"15.75%",top:"68.40%",width:"16.60%"},label:{left:"30.80%",top:"88.00%",width:"9.2%"}},wish:{box:{left:"50.40%",top:"58.40%",width:"14.50%"},label:{left:"54.00%",top:"84.50%",width:"6.8%"}},album:{box:{left:"75.80%",top:"64.65%",width:"20.20%"},label:{left:"74.60%",top:"73.20%",width:"7.2%"}}};function u({assetKey:t,onClick:n,highlighted:a,disabled:s}){let[e,o]=f(!1),i=_[t];return c("div",{className:`pointer-events-none absolute inset-0 ${a?"z-30":""}`,children:[c(x,{variant:"ghost",className:"pointer-events-auto absolute h-auto p-0 hover:bg-transparent dark:hover:bg-transparent",style:i.box,"aria-label":t==="vibemon"?"Vibémon":t==="wish"?"Wish":"Album",disabled:s,onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[l("img",{src:m[t].icon,alt:"",className:"block w-full select-none",style:{opacity:e?0:1}}),l("img",{src:m[t].hover,alt:"","aria-hidden":!0,className:"absolute inset-0 h-full w-full select-none",style:{opacity:e?1:0}})]}),l("img",{src:m[t].text,alt:"","aria-hidden":!0,className:"pointer-events-none absolute transition-opacity duration-200 select-none",style:{...i.label}})]})}function L({onDraw:t,onBackpack:n,onEquip:a,guideActive:s}){let e=g(null),o=C(e);return c("div",{ref:e,className:"relative h-full w-full overflow-hidden",children:[l("div",{className:"absolute inset-0",style:{background:y}}),c("div",{"data-testid":"vibemon-home-stage",className:"[container-type:size] absolute",style:{width:o.width,height:o.height,left:o.left,top:o.top},children:[l("img",{src:b,alt:"",className:"block h-full w-full select-none"}),c("div",{className:"pointer-events-none absolute inset-0",children:[l(u,{assetKey:"vibemon",onClick:a,highlighted:!1,disabled:s}),l(u,{assetKey:"wish",onClick:t,highlighted:s,disabled:!1}),l(u,{assetKey:"album",onClick:n,highlighted:!1,disabled:s})]}),s&&l(v,{}),s&&l(w,{})]})]})}export{L as HomeView};
1
+ import{jsx as l,jsxs as c}from"react/jsx-runtime";import{useLayoutEffect as b,useRef as p,useState as f}from"react";import{homeBackground as g,homeHotspotAssets as m}from"../assets.js";import{Button as x}from"../ui/button.js";import{HomeWishGuide as w,OnboardingScrim as v}from"./onboarding-guide.js";var d=1.778723404255319,y="#120E18",r={x1:0.3,x2:0.8,y1:0.56,y2:1},N=r.x2-r.x1,S=r.y2-r.y1,E=(r.x1+r.x2)/2,k=0.8;function M(t,n){let a=Math.max(t,n*d),s=Math.min(t/N,n/S*d),e=Math.max(Math.min(a,s),k*a),o=e/d,i=e<=t?(t-e)/2:Math.min(0,Math.max(t-e,t/2-E*e)),h=o<=n?(n-o)/2:n-o;return{width:e,height:o,left:i,top:h}}function C(t){let[n,a]=f({width:0,height:0,left:0,top:0});return b(()=>{let s=t.current;if(!s)return;let e=new ResizeObserver(([o])=>{let{width:i,height:h}=o.contentRect;a(M(i,h))});return e.observe(s),()=>e.disconnect()},[t]),n}var _={vibemon:{box:{left:"15.75%",top:"68.40%",width:"16.60%"},label:{left:"30.80%",top:"88.00%",width:"9.2%"}},wish:{box:{left:"50.40%",top:"58.40%",width:"14.50%"},label:{left:"54.00%",top:"84.50%",width:"6.8%"}},album:{box:{left:"75.80%",top:"64.65%",width:"20.20%"},label:{left:"74.60%",top:"73.20%",width:"7.2%"}}};function u({assetKey:t,onClick:n,highlighted:a,disabled:s}){let[e,o]=f(!1),i=_[t];return c("div",{className:`pointer-events-none absolute inset-0 ${a?"z-30":""}`,children:[c(x,{variant:"ghost",className:"pointer-events-auto absolute h-auto p-0 hover:bg-transparent dark:hover:bg-transparent",style:i.box,"aria-label":t==="vibemon"?"Vibémon":t==="wish"?"Wish":"Album",disabled:s,onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[l("img",{src:m[t].icon,alt:"",className:"block w-full select-none",style:{opacity:e?0:1}}),l("img",{src:m[t].hover,alt:"","aria-hidden":!0,className:"absolute inset-0 h-full w-full select-none",style:{opacity:e?1:0}})]}),l("img",{src:m[t].text,alt:"","aria-hidden":!0,className:"pointer-events-none absolute transition-opacity duration-200 select-none",style:{...i.label}})]})}function L({onDraw:t,onBackpack:n,onEquip:a,guideActive:s}){let e=p(null),o=C(e);return c("div",{ref:e,className:"relative h-full w-full overflow-hidden",children:[l("div",{className:"absolute inset-0",style:{background:y}}),c("div",{"data-testid":"vibemon-home-stage",className:"[container-type:size] absolute",style:{width:o.width,height:o.height,left:o.left,top:o.top},children:[l("img",{src:g,alt:"",className:"block h-full w-full select-none"}),c("div",{className:"pointer-events-none absolute inset-0",children:[l(u,{assetKey:"vibemon",onClick:a,highlighted:!1,disabled:s}),l(u,{assetKey:"wish",onClick:t,highlighted:s,disabled:!1}),l(u,{assetKey:"album",onClick:n,highlighted:!1,disabled:s})]}),s&&l(v,{}),s&&l(w,{})]})]})}export{L as HomeView};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as a}from"react/jsx-runtime";import{dialogClose as i,insufficientPointsDialog as r,proceedButtonAssets as l}from"../assets.js";import{useState as c}from"react";import{Button as n}from"../ui/button.js";function d({onClose:s,onProceed:o}){return t("div",{className:"absolute inset-0 z-50 flex cursor-default items-center justify-center bg-black/80 p-0",onClick:(e)=>{if(e.target===e.currentTarget)s()},onKeyDown:(e)=>{if(e.key==="Escape")s()},children:a("div",{className:"relative",children:[t("img",{src:r,alt:"",className:"pointer-events-none max-w-none select-none",style:{width:326.24,height:201.03}}),t(n,{variant:"ghost",className:"absolute h-auto p-0 hover:bg-transparent",style:{top:-7.07,right:-11.3},onClick:s,children:t("img",{src:i,alt:"",className:"max-w-none select-none",style:{width:26,height:26}})}),t(u,{onClick:o})]})})}function u({onClick:s}){let[o,e]=c("default");return t(n,{variant:"ghost",className:"absolute h-auto -translate-x-1/2 p-0 hover:bg-transparent",style:{bottom:30,left:"50%"},title:"",onClick:s,onMouseEnter:()=>e("hover"),onMouseLeave:()=>e("default"),onMouseDown:()=>e("active"),onMouseUp:()=>e("hover"),children:t("img",{src:l[o],alt:"",className:"max-w-none select-none",style:{width:144,height:36}})})}export{d as InsufficientPointsDialog};
1
+ import{jsx as t,jsxs as a}from"react/jsx-runtime";import{useState as i}from"react";import{dialogClose as r,insufficientPointsDialog as l,proceedButtonAssets as c}from"../assets.js";import{Button as n}from"../ui/button.js";function d({onClose:s,onProceed:o}){return t("div",{className:"absolute inset-0 z-50 flex cursor-default items-center justify-center bg-black/80 p-0",onClick:(e)=>{if(e.target===e.currentTarget)s()},onKeyDown:(e)=>{if(e.key==="Escape")s()},children:a("div",{className:"relative",children:[t("img",{src:l,alt:"",className:"pointer-events-none max-w-none select-none",style:{width:326.24,height:201.03}}),t(n,{variant:"ghost",className:"absolute h-auto p-0 hover:bg-transparent",style:{top:-7.07,right:-11.3},onClick:s,children:t("img",{src:r,alt:"",className:"max-w-none select-none",style:{width:26,height:26}})}),t(u,{onClick:o})]})})}function u({onClick:s}){let[o,e]=i("default");return t(n,{variant:"ghost",className:"absolute h-auto -translate-x-1/2 p-0 hover:bg-transparent",style:{bottom:30,left:"50%"},title:"",onClick:s,onMouseEnter:()=>e("hover"),onMouseLeave:()=>e("default"),onMouseDown:()=>e("active"),onMouseUp:()=>e("hover"),children:t("img",{src:c[o],alt:"",className:"max-w-none select-none",style:{width:144,height:36}})})}export{d as InsufficientPointsDialog};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as a}from"react/jsx-runtime";import{loadingBackground as w,loadingLogo as h}from"../assets.js";import{useEffect as x,useRef as f,useState as b}from"react";import{advanceLoadingProgress as v}from"../../core/lib/loading-progress.js";import{VibemonScene as _}from"./vibemon-scene.js";var q=98.902;function j({progress:s,onFinished:i}){let[o,g]=b(0),l=f(s);l.current=s;let c=f(i);c.current=i,x(()=>{let r=0,m=performance.now(),t=0,d=(u)=>{let p=Math.min((u-m)/1000,0.1);if(m=u,t=v(t,l.current,p),g(t),t>=1){c.current();return}r=requestAnimationFrame(d)};return r=requestAnimationFrame(d),()=>cancelAnimationFrame(r)},[]);let n=Math.round(o*100);return a(_,{backdrop:e("img",{src:w,alt:"","aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full object-cover select-none"}),children:[e("img",{src:h,alt:"Vibémon",className:"pointer-events-none absolute top-[17.140%] left-[22.049%] h-[56.559%] w-[55.903%] max-w-none select-none"}),a("div",{"data-testid":"vibemon-loading-progress",role:"progressbar","aria-label":`Loading ${n}%`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,className:"absolute top-[83.050%] left-1/2 flex w-[52.083%] -translate-x-1/2 flex-col gap-[0.625cqw]",children:[e("p",{className:"text-right text-[1.458cqw] leading-normal tracking-[0.08em] text-white",style:{fontFamily:'"Grow Year", system-ui, sans-serif'},children:"LOADING..."}),a("div",{className:"flex flex-col items-center gap-[0.625cqw]",children:[e("div",{className:"relative h-[2.292cqw] w-full rounded-full bg-[#3B138F] shadow-[inset_0_0.052cqw_0.365cqw_0_rgba(0,0,0,0.25)]",children:e("div",{"data-testid":"vibemon-loading-progress-fill",className:"absolute top-[9.091%] left-[0.549%] h-[81.818%] min-w-[3.6%] rounded-full bg-[linear-gradient(180deg,#FFE16C_0%,#FFB638_100%)] shadow-[inset_0_0.208cqw_0.156cqw_0_rgba(255,255,255,0.87)]",style:{width:`${o*q}%`}})}),a("p",{className:"text-center text-[1.458cqw] leading-normal text-white",style:{fontFamily:'"Grow Year", system-ui, sans-serif'},children:[n,"%"]})]})]})]})}export{j as VibemonLoadingView};
1
+ import{jsx as e,jsxs as a}from"react/jsx-runtime";import{useEffect as w,useRef as f,useState as h}from"react";import{advanceLoadingProgress as x}from"../../core/lib/loading-progress.js";import{loadingBackground as b,loadingLogo as v}from"../assets.js";import{VibemonScene as _}from"./vibemon-scene.js";var q=98.902;function j({progress:s,onFinished:i}){let[o,g]=h(0),l=f(s);l.current=s;let c=f(i);c.current=i,w(()=>{let r=0,m=performance.now(),t=0,d=(u)=>{let p=Math.min((u-m)/1000,0.1);if(m=u,t=x(t,l.current,p),g(t),t>=1){c.current();return}r=requestAnimationFrame(d)};return r=requestAnimationFrame(d),()=>cancelAnimationFrame(r)},[]);let n=Math.round(o*100);return a(_,{backdrop:e("img",{src:b,alt:"","aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full object-cover select-none"}),children:[e("img",{src:v,alt:"Vibémon",className:"pointer-events-none absolute top-[17.140%] left-[22.049%] h-[56.559%] w-[55.903%] max-w-none select-none"}),a("div",{"data-testid":"vibemon-loading-progress",role:"progressbar","aria-label":`Loading ${n}%`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,className:"absolute top-[83.050%] left-1/2 flex w-[52.083%] -translate-x-1/2 flex-col gap-[0.625cqw]",children:[e("p",{className:"text-right text-[1.458cqw] leading-normal tracking-[0.08em] text-white",style:{fontFamily:'"Grow Year", system-ui, sans-serif'},children:"LOADING..."}),a("div",{className:"flex flex-col items-center gap-[0.625cqw]",children:[e("div",{className:"relative h-[2.292cqw] w-full rounded-full bg-[#3B138F] shadow-[inset_0_0.052cqw_0.365cqw_0_rgba(0,0,0,0.25)]",children:e("div",{"data-testid":"vibemon-loading-progress-fill",className:"absolute top-[9.091%] left-[0.549%] h-[81.818%] min-w-[3.6%] rounded-full bg-[linear-gradient(180deg,#FFE16C_0%,#FFB638_100%)] shadow-[inset_0_0.208cqw_0.156cqw_0_rgba(255,255,255,0.87)]",style:{width:`${o*q}%`}})}),a("p",{className:"text-center text-[1.458cqw] leading-normal text-white",style:{fontFamily:'"Grow Year", system-ui, sans-serif'},children:[n,"%"]})]})]})]})}export{j as VibemonLoadingView};
@@ -1,6 +1,4 @@
1
-
2
1
  @keyframes alwith-vibemon-burst {
3
-
4
2
  0% {
5
3
  background-position-x: 0;
6
4
  }
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{guideArrow as p,guideHand as w,guideHandShape as c,guideHandSheen as N,guideHomeTexture as y,guideMascot as x,guidePullTexture as v,guideRing as _}from"../assets.js";import{motion as g,useReducedMotion as b}from"motion/react";import{cn as L}from"../lib/utils.js";var k=2128.456,I=1920,d=(t)=>`${t/k*100}cqw`,a=(t)=>`${t/I*100}cqw`;function R(){return e("div",{"data-testid":"vibemon-onboarding-scrim","aria-hidden":!0,className:"absolute inset-0 z-20 bg-black/50",style:{boxShadow:"0 0 0 100vmax rgba(0,0,0,0.5)"}})}var S=8,B=32,u=160,H={width:687,height:94,textLeft:184.457,mascotLeft:20.273,mascotTop:-70.384,texture:y,length:d},z={width:712,height:94,textLeft:185.29,mascotLeft:20.96,mascotTop:-70.46,texture:v,length:a};function f({design:t,className:i,children:n}){let s=t.length;return o("div",{className:L("absolute -translate-x-1/2 -translate-y-1/2",i),style:{width:s(t.width),height:s(t.height)},children:[e("div",{className:"absolute inset-0 rounded-full border-white bg-[#8546DD] bg-[length:100%_100%] [background-origin:border-box]",style:{borderWidth:s(S),backgroundImage:`url("${t.texture}")`}}),e("p",{className:"absolute top-1/2 -translate-y-1/2 leading-normal whitespace-nowrap text-white",style:{left:s(t.textLeft),fontFamily:'"Lilita One", system-ui, sans-serif',fontSize:s(B)},children:n}),e("img",{src:x,alt:"",className:"absolute max-w-none select-none",style:{left:s(t.mascotLeft),top:s(t.mascotTop),width:s(u),height:s(u)}})]})}var m=42;function E(){let t=b(),i="absolute top-[56.381%] left-[57.735%] -translate-x-1/2 -translate-y-1/2",n={width:d(m),height:d(m)},s=e("span",{className:"absolute inset-0 rotate-180",children:e("span",{className:"absolute inset-[6.35%_-0.84%_-3.12%_-0.84%]",children:e("img",{src:p,alt:"",className:"block h-full w-full max-w-none select-none"})})});if(t)return e("div",{"data-node-id":"1566:3898","data-testid":"vibemon-home-guide-arrow",className:"absolute top-[56.381%] left-[57.735%] -translate-x-1/2 -translate-y-1/2",style:n,children:s});return e(g.div,{"data-node-id":"1566:3898","data-testid":"vibemon-home-guide-arrow",className:"absolute top-[56.381%] left-[57.735%] -translate-x-1/2 -translate-y-1/2",style:n,initial:{y:0},animate:{y:["0%","21.1%"]},transition:{y:{duration:0.401,times:[0,1],ease:"easeInOut",repeat:1/0}},children:s})}function G(){return o("div",{"data-testid":"vibemon-home-wish-guide",className:"pointer-events-none absolute inset-0 z-40",children:[e(f,{design:H,className:"top-[18.400%] left-[54.614%]",children:"Your first card is waiting inside!"}),e(E,{})]})}var h=109.551,l={left:20.179,top:18.317,width:69.1953,height:70.918},r={left:25.672,top:2.065,size:43.219};function O(){let t=b(),i={left:a(r.left),top:a(r.top),width:a(r.size),height:a(r.size)},n=e("span",{className:"absolute inset-[-578.45%]",children:e("img",{src:_,alt:"",className:"block h-full w-full max-w-none select-none"})});return o("div",{className:"relative",style:{width:a(h),height:a(h)},children:[t?e("span",{"data-node-id":"1550:4234","data-testid":"vibemon-pool-guide-ring",className:"absolute",style:i,children:n}):e(g.span,{"data-node-id":"1550:4234","data-testid":"vibemon-pool-guide-ring",className:"absolute",style:i,initial:{scaleX:1.6,scaleY:1.6},animate:{scaleX:[1.6,1.014,1],scaleY:[1.6,1.014,1]},transition:{scaleX:{duration:0.61,times:[0,0.82,1],ease:"linear",repeat:1/0},scaleY:{duration:0.61,times:[0,0.82,1],ease:"linear",repeat:1/0}},children:n}),o("span",{"data-node-id":"1550:4236",className:"absolute",style:{left:a(l.left),top:a(l.top),width:a(l.width),height:a(l.height)},children:[e("img",{src:w,alt:"",className:"absolute inset-0 block h-full w-full max-w-none select-none"}),e("span",{className:"absolute inset-0",style:{backgroundImage:`url("${N}")`,backgroundSize:"100% 100%",WebkitMaskImage:`url("${c}")`,WebkitMaskSize:"100% 100%",maskImage:`url("${c}")`,maskSize:"100% 100%"}})]})]})}function U(){let t=(i)=>({width:a(i),height:a(i)});return o("div",{"data-testid":"vibemon-free-draw-guide",className:"pointer-events-none absolute inset-0 z-40",children:[e(f,{design:z,className:"top-[79.004%] left-[57.240%] z-2",children:"Draw a card, find your companion!"}),e("span",{className:"absolute top-[82.184%] left-[68.358%] z-1 -translate-x-1/2 -translate-y-1/2 rounded-full bg-white",style:t(34.461)}),e("span",{className:"absolute top-[85.459%] left-[67.288%] z-1 -translate-x-1/2 -translate-y-1/2 rounded-full bg-white",style:t(15.354)}),e("div",{className:"absolute top-[95.437%] left-[64.490%] -translate-x-1/2 -translate-y-1/2",children:e(O,{})})]})}export{U as FreeDrawGuide,G as HomeWishGuide,R as OnboardingScrim};
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{motion as g,useReducedMotion as b}from"motion/react";import{guideArrow as p,guideHand as w,guideHandShape as c,guideHandSheen as N,guideHomeTexture as y,guideMascot as x,guidePullTexture as v,guideRing as _}from"../assets.js";import{cn as L}from"../lib/utils.js";var k=2128.456,I=1920,d=(t)=>`${t/k*100}cqw`,a=(t)=>`${t/I*100}cqw`;function R(){return e("div",{"data-testid":"vibemon-onboarding-scrim","aria-hidden":!0,className:"absolute inset-0 z-20 bg-black/50",style:{boxShadow:"0 0 0 100vmax rgba(0,0,0,0.5)"}})}var S=8,B=32,u=160,H={width:687,height:94,textLeft:184.457,mascotLeft:20.273,mascotTop:-70.384,texture:y,length:d},z={width:712,height:94,textLeft:185.29,mascotLeft:20.96,mascotTop:-70.46,texture:v,length:a};function f({design:t,className:i,children:n}){let s=t.length;return o("div",{className:L("absolute -translate-x-1/2 -translate-y-1/2",i),style:{width:s(t.width),height:s(t.height)},children:[e("div",{className:"absolute inset-0 rounded-full border-white bg-[#8546DD] bg-[length:100%_100%] [background-origin:border-box]",style:{borderWidth:s(S),backgroundImage:`url("${t.texture}")`}}),e("p",{className:"absolute top-1/2 -translate-y-1/2 leading-normal whitespace-nowrap text-white",style:{left:s(t.textLeft),fontFamily:'"Lilita One", system-ui, sans-serif',fontSize:s(B)},children:n}),e("img",{src:x,alt:"",className:"absolute max-w-none select-none",style:{left:s(t.mascotLeft),top:s(t.mascotTop),width:s(u),height:s(u)}})]})}var m=42;function E(){let t=b(),i="absolute top-[56.381%] left-[57.735%] -translate-x-1/2 -translate-y-1/2",n={width:d(m),height:d(m)},s=e("span",{className:"absolute inset-0 rotate-180",children:e("span",{className:"absolute inset-[6.35%_-0.84%_-3.12%_-0.84%]",children:e("img",{src:p,alt:"",className:"block h-full w-full max-w-none select-none"})})});if(t)return e("div",{"data-node-id":"1566:3898","data-testid":"vibemon-home-guide-arrow",className:"absolute top-[56.381%] left-[57.735%] -translate-x-1/2 -translate-y-1/2",style:n,children:s});return e(g.div,{"data-node-id":"1566:3898","data-testid":"vibemon-home-guide-arrow",className:"absolute top-[56.381%] left-[57.735%] -translate-x-1/2 -translate-y-1/2",style:n,initial:{y:0},animate:{y:["0%","21.1%"]},transition:{y:{duration:0.401,times:[0,1],ease:"easeInOut",repeat:1/0}},children:s})}function G(){return o("div",{"data-testid":"vibemon-home-wish-guide",className:"pointer-events-none absolute inset-0 z-40",children:[e(f,{design:H,className:"top-[18.400%] left-[54.614%]",children:"Your first card is waiting inside!"}),e(E,{})]})}var h=109.551,l={left:20.179,top:18.317,width:69.1953,height:70.918},r={left:25.672,top:2.065,size:43.219};function O(){let t=b(),i={left:a(r.left),top:a(r.top),width:a(r.size),height:a(r.size)},n=e("span",{className:"absolute inset-[-578.45%]",children:e("img",{src:_,alt:"",className:"block h-full w-full max-w-none select-none"})});return o("div",{className:"relative",style:{width:a(h),height:a(h)},children:[t?e("span",{"data-node-id":"1550:4234","data-testid":"vibemon-pool-guide-ring",className:"absolute",style:i,children:n}):e(g.span,{"data-node-id":"1550:4234","data-testid":"vibemon-pool-guide-ring",className:"absolute",style:i,initial:{scaleX:1.6,scaleY:1.6},animate:{scaleX:[1.6,1.014,1],scaleY:[1.6,1.014,1]},transition:{scaleX:{duration:0.61,times:[0,0.82,1],ease:"linear",repeat:1/0},scaleY:{duration:0.61,times:[0,0.82,1],ease:"linear",repeat:1/0}},children:n}),o("span",{"data-node-id":"1550:4236",className:"absolute",style:{left:a(l.left),top:a(l.top),width:a(l.width),height:a(l.height)},children:[e("img",{src:w,alt:"",className:"absolute inset-0 block h-full w-full max-w-none select-none"}),e("span",{className:"absolute inset-0",style:{backgroundImage:`url("${N}")`,backgroundSize:"100% 100%",WebkitMaskImage:`url("${c}")`,WebkitMaskSize:"100% 100%",maskImage:`url("${c}")`,maskSize:"100% 100%"}})]})]})}function U(){let t=(i)=>({width:a(i),height:a(i)});return o("div",{"data-testid":"vibemon-free-draw-guide",className:"pointer-events-none absolute inset-0 z-40",children:[e(f,{design:z,className:"top-[79.004%] left-[57.240%] z-2",children:"Draw a card, find your companion!"}),e("span",{className:"absolute top-[82.184%] left-[68.358%] z-1 -translate-x-1/2 -translate-y-1/2 rounded-full bg-white",style:t(34.461)}),e("span",{className:"absolute top-[85.459%] left-[67.288%] z-1 -translate-x-1/2 -translate-y-1/2 rounded-full bg-white",style:t(15.354)}),e("div",{className:"absolute top-[95.437%] left-[64.490%] -translate-x-1/2 -translate-y-1/2",children:e(O,{})})]})}export{U as FreeDrawGuide,G as HomeWishGuide,R as OnboardingScrim};
@@ -1 +1 @@
1
- import{jsx as P}from"react/jsx-runtime";import{useEffect as k,useState as S}from"react";import{vibemonHost as q}from"../../core/host.js";import{backdropSvgPath as R,bubbleOutline as C,scaleBackdropPath as L}from"../../core/lib/bubble-outline.js";var F=Promise.resolve();function d(a){let c=F,t;F=new Promise((r)=>{t=r}),(async()=>{await c;try{await a()}finally{t()}})()}function J({cardRef:a,opacity:c=0.65,radius:t=20,enabled:r=!0}){let e=q(),[x,O]=S([]);return k(()=>()=>{d(async()=>{await e.windows.call("bubble-blur",{enabled:!1,radius:1,path:null}).catch(e.onError)})},[]),k(()=>{let n=a.current;if(n===null)throw Error("Pet bubble background requires its card");let N={scaleFactor:()=>e.windows.call("scale")},u=!1,i=null,b=null,m=async()=>{if(u)return;let l=await N.scaleFactor();if(u)return;let o=n.getBoundingClientRect();if(o.width<=1||o.height<=1)return;let B=getComputedStyle(n),f=Number.parseFloat(B.borderTopLeftRadius);if(!Number.isFinite(f))throw Error("Pet bubble corner radius must resolve to pixels");let h=n.parentElement;if(h===null)throw Error("Pet bubble card requires its container");let v=Number.parseFloat(getComputedStyle(h).paddingBottom);if(!Number.isFinite(v))throw Error("Pet bubble tail spacing must resolve to pixels");let g=C(o.left+0.5,o.top+0.5,o.width-1,o.height-1,f-0.5,v);O(g);let y=r?L(g,window.devicePixelRatio/l):null,E=JSON.stringify([r,t,y]);if(E===b)return;await e.windows.call("bubble-blur",{enabled:r,radius:t,path:y}),b=E},s=()=>{if(u||i!==null)return;i=requestAnimationFrame(()=>{i=null,d(()=>m().catch(e.onError))})};d(()=>m().catch(e.onError));let w=new ResizeObserver(s);w.observe(n);let p=new MutationObserver(s);for(let l of[document.documentElement,document.body,n])p.observe(l,{attributes:!0,attributeFilter:["class","style"]});window.addEventListener("resize",s);let z=e.windows.geometry(s);return()=>{if(u=!0,i!==null)cancelAnimationFrame(i);w.disconnect(),p.disconnect(),window.removeEventListener("resize",s),z.then((l)=>l()).catch(e.onError)}},[a,r,t,e]),P("svg",{"aria-hidden":!0,"data-pet-bubble-background":!0,className:"pointer-events-none fixed inset-0 size-full overflow-visible",children:P("path",{d:R(x),fill:"var(--popover)",fillOpacity:c,stroke:"var(--border)",strokeOpacity:c,strokeWidth:1})})}export{J as PetBubbleBackground};
1
+ import{jsx as P}from"react/jsx-runtime";import{useEffect as k,useEffectEvent as q,useState as R}from"react";import{vibemonHost as C}from"../../core/host.js";import{backdropSvgPath as L,bubbleOutline as j,scaleBackdropPath as A}from"../../core/lib/bubble-outline.js";var F=Promise.resolve();function d(a){let c=F,t;F=new Promise((r)=>{t=r}),(async()=>{await c;try{await a()}finally{t()}})()}function T({cardRef:a,opacity:c=0.65,radius:t=20,enabled:r=!0}){let e=C(),[x,O]=R([]),B=q(()=>{d(async()=>{await e.windows.call("bubble-blur",{enabled:!1,radius:1,path:null}).catch(e.onError)})});return k(()=>()=>B(),[]),k(()=>{let n=a.current;if(n===null)throw Error("Pet bubble background requires its card");let N={scaleFactor:()=>e.windows.call("scale")},u=!1,i=null,b=null,m=async()=>{if(u)return;let l=await N.scaleFactor();if(u)return;let o=n.getBoundingClientRect();if(o.width<=1||o.height<=1)return;let S=getComputedStyle(n),p=Number.parseFloat(S.borderTopLeftRadius);if(!Number.isFinite(p))throw Error("Pet bubble corner radius must resolve to pixels");let h=n.parentElement;if(h===null)throw Error("Pet bubble card requires its container");let v=Number.parseFloat(getComputedStyle(h).paddingBottom);if(!Number.isFinite(v))throw Error("Pet bubble tail spacing must resolve to pixels");let g=j(o.left+0.5,o.top+0.5,o.width-1,o.height-1,p-0.5,v);O(g);let y=r?A(g,window.devicePixelRatio/l):null,E=JSON.stringify([r,t,y]);if(E===b)return;await e.windows.call("bubble-blur",{enabled:r,radius:t,path:y}),b=E},s=()=>{if(u||i!==null)return;i=requestAnimationFrame(()=>{i=null,d(()=>m().catch(e.onError))})};d(()=>m().catch(e.onError));let w=new ResizeObserver(s);w.observe(n);let f=new MutationObserver(s);for(let l of[document.documentElement,document.body,n])f.observe(l,{attributes:!0,attributeFilter:["class","style"]});window.addEventListener("resize",s);let z=e.windows.geometry(s);return()=>{if(u=!0,i!==null)cancelAnimationFrame(i);w.disconnect(),f.disconnect(),window.removeEventListener("resize",s),z.then((l)=>l()).catch(e.onError)}},[a,r,t,e]),P("svg",{"aria-hidden":!0,"data-pet-bubble-background":!0,className:"pointer-events-none fixed inset-0 size-full overflow-visible",children:P("path",{d:L(x),fill:"var(--popover)",fillOpacity:c,stroke:"var(--border)",strokeOpacity:c,strokeWidth:1})})}export{T as PetBubbleBackground};
@@ -1 +1 @@
1
- import{jsx as E,jsxs as A}from"react/jsx-runtime";import{useEffect as I,useRef as m,useState as l}from"react";import{vibemonHost as C}from"../../core/host.js";import{useVibemonState as N}from"../lib/account-state.js";import{loadVibemonResource as U}from"../../core/lib/vibemon-resources.js";import{PetAnimationSync as X}from"../../core/lib/pet-animation-sync.js";import{PetBubbleState as O}from"../../core/lib/pet-bubble-state.js";import{PresentationReadiness as W}from"../../core/lib/presentation-readiness.js";import{presentVibemon as B}from"../../core/lib/pet-presentation.js";import{dragPet as F}from"../../core/lib/pet-drag.js";import{DEFAULT_VIBEMON_WINDOW_SIZE as P}from"../../core/types.js";import{VibemonEngine as Y}from"../../core/engine.js";import{SpriteRenderer as H}from"./sprite-renderer.js";import"./lounge-burst.css";function ce(){let t=C(),u=N(),[a,x]=l(null),f=a?.resource??null,[g,S]=l({state:"idle",flipped:!1,tick:0}),[D,R]=l(!0),[k,v]=l(!1),[z,V]=l(0),s=m(null),h=m(0),[r]=l(()=>new W),[c]=l(()=>new X),[i]=l(()=>new O((e)=>{t.windows.call("bubble",{visible:e}).catch(t.onError)}));I(()=>{if(!u.pet)return;let e=u.pet,n=++h.current;r.begin(e,n),x(null);let d=!1,p=null;return(async()=>{if(p=await U(e),d){p.dispose();return}if(await t.windows.call("resize",{size:p.config.windowSize??P}),d)return;let o=new Y(p.config,(_,j,M)=>{if(d)return;S((T)=>({state:_,flipped:j,tick:T.tick+(M?1:0)}))},()=>{});if(s.current=o,c.attach(o),await o.start(u.position),d){o.destroy();return}if(r.positioned(e,n,o),x({resource:p,petId:e,generation:n}),await r.wait(e,Date.now()+15000),!d)await t.windows.call("ready",{petId:e})})().catch((o)=>{if(d||h.current!==n)return;r.fail(e,n,o instanceof Error?o:Error(String(o))),t.onError(o)}),()=>{d=!0,r.invalidate(),c.attach(null),s.current?.destroy(),s.current=null,p?.dispose()}},[u.pet,t,r,c,z]),I(()=>{let e=(n)=>{if(n===null){c.bind(null,!1),i.bind(null,-1);return}c.bind(n.binding.sessionId,n.error!==null,n.binding.bindingRevision),c.update([{sessionId:n.binding.sessionId,state:n.state}],n.source),c.prompt(n.binding.sessionId,n.binding.bindingRevision,n.prompt!==null),i.bind(n.binding.sessionId,n.binding.bindingRevision),i.owner(n.owner),i.update(n.state,n.prompt?.token??null,n.surfaceVisible)};return e(t.sessions.snapshot()),t.sessions.subscribe(e)},[t,c,i]),I(()=>t.windows.commands(async(e)=>{if(e.type==="reload"){if(e.petId!==u.pet)throw Error("The selected pet changed");h.current++,r.reset(),V((n)=>n+1);return}if(e.type==="bubble-open"){i.open();return}if(e.type==="bubble-interact"){i.interact();return}if(e.type==="close"){s.current?.destroy(),i.close(),v(!0),await t.windows.call("sound"),await new Promise((n)=>setTimeout(n,470)),await t.windows.call("hide");return}if(e.type==="bubble-close"){i.close();return}if(e.type==="suspend"){s.current?.suspend(),R(!1),i.close(),await t.windows.call("hide");return}R(!0),await B(r,t.windows,e.petId)}),[t,i,r,u.pet]);let w=m(0),b=m(null);if(f===null)return null;let y=f.config.windowSize??P;return A("div",{className:"relative flex h-full w-full items-end justify-center select-none",onPointerDown:(e)=>{if(e.button!==0)return;b.current={x:e.screenX,y:e.screenY}},onPointerMove:(e)=>{let n=b.current;if(n===null||Math.hypot(e.screenX-n.x,e.screenY-n.y)<4)return;if(b.current=null,s.current===null)throw Error("The pet engine is unavailable");F(t.windows,s.current,e.screenX<n.x).catch(t.onError)},onPointerUp:()=>{b.current=null},onContextMenu:(e)=>{e.preventDefault(),t.windows.call("menu").catch(t.onError)},children:[E("div",{style:{width:y,height:y,visibility:k?"hidden":"visible"},children:E(H,{config:f.config,spriteUrl:f.spriteUrl,stateId:g.state,flipped:g.flipped,animTick:g.tick,active:D,onDrawFrame:()=>{if(a!==null)r.drawn(a.petId,a.generation)},onRenderError:(e)=>{if(a!==null)r.fail(a.petId,a.generation,e);t.onError(e)},onMouseDown:()=>{},onClick:()=>{s.current?.handleClick();let e=Date.now();if(e-w.current<350&&e-w.current>50)i.close(),t.sessions.activate().catch(t.onError),w.current=0;else w.current=e}})}),k&&E("div",{className:"alwith-vibemon-burst pointer-events-none",style:{position:"fixed",left:"50%",bottom:0,width:280,height:280,transform:`translateX(-50%) scale(${y/280})`,transformOrigin:"center bottom",zIndex:20}})]})}export{ce as PetWindow};
1
+ import{jsx as E,jsxs as C}from"react/jsx-runtime";import{useEffect as I,useEffectEvent as N,useRef as m,useState as l}from"react";import{VibemonEngine as U}from"../../core/engine.js";import{vibemonHost as X}from"../../core/host.js";import{PetAnimationSync as O}from"../../core/lib/pet-animation-sync.js";import{PetBubbleState as W}from"../../core/lib/pet-bubble-state.js";import{dragPet as B}from"../../core/lib/pet-drag.js";import{presentVibemon as F}from"../../core/lib/pet-presentation.js";import{PresentationReadiness as Y}from"../../core/lib/presentation-readiness.js";import{loadVibemonResource as H}from"../../core/lib/vibemon-resources.js";import{DEFAULT_VIBEMON_WINDOW_SIZE as k}from"../../core/types.js";import{useVibemonState as L}from"../lib/account-state.js";import{SpriteRenderer as Z}from"./sprite-renderer.js";import"./lounge-burst.css";function ae(){let t=X(),u=L(),[a,x]=l(null),f=a?.resource??null,[g,S]=l({state:"idle",flipped:!1,tick:0}),[v,P]=l(!0),[R,D]=l(!1),[z,V]=l(0),s=m(null),h=m(0),[r]=l(()=>new Y),[c]=l(()=>new O),[i]=l(()=>new W((e)=>{t.windows.call("bubble",{visible:e}).catch(t.onError)})),_=N(()=>u.position);I(()=>{if(!u.pet)return;let e=u.pet,n=++h.current;r.begin(e,n),x(null);let d=!1,p=null;return(async()=>{if(p=await H(e),d){p.dispose();return}if(await t.windows.call("resize",{size:p.config.windowSize??k}),d)return;let o=new U(p.config,(j,M,T)=>{if(d)return;S((A)=>({state:j,flipped:M,tick:A.tick+(T?1:0)}))},()=>{});if(s.current=o,c.attach(o),await o.start(_()),d){o.destroy();return}if(r.positioned(e,n,o),x({resource:p,petId:e,generation:n}),await r.wait(e,Date.now()+15000),!d)await t.windows.call("ready",{petId:e})})().catch((o)=>{if(d||h.current!==n)return;r.fail(e,n,o instanceof Error?o:Error(String(o))),t.onError(o)}),()=>{d=!0,r.invalidate(),c.attach(null),s.current?.destroy(),s.current=null,p?.dispose()}},[u.pet,t,r,c,z]),I(()=>{let e=(n)=>{if(n===null){c.bind(null,!1),i.bind(null,-1);return}c.bind(n.binding.sessionId,n.error!==null,n.binding.bindingRevision),c.update([{sessionId:n.binding.sessionId,state:n.state}],n.source),c.prompt(n.binding.sessionId,n.binding.bindingRevision,n.prompt!==null),i.bind(n.binding.sessionId,n.binding.bindingRevision),i.owner(n.owner),i.update(n.state,n.prompt?.token??null,n.surfaceVisible)};return e(t.sessions.snapshot()),t.sessions.subscribe(e)},[t,c,i]),I(()=>t.windows.commands(async(e)=>{if(e.type==="reload"){if(e.petId!==u.pet)throw Error("The selected pet changed");h.current++,r.reset(),V((n)=>n+1);return}if(e.type==="bubble-open"){i.open();return}if(e.type==="bubble-interact"){i.interact();return}if(e.type==="close"){s.current?.destroy(),i.close(),D(!0),await t.windows.call("sound"),await new Promise((n)=>setTimeout(n,470)),await t.windows.call("hide");return}if(e.type==="bubble-close"){i.close();return}if(e.type==="suspend"){s.current?.suspend(),P(!1),i.close(),await t.windows.call("hide");return}P(!0),await F(r,t.windows,e.petId)}),[t,i,r,u.pet]);let w=m(0),b=m(null);if(f===null)return null;let y=f.config.windowSize??k;return C("div",{className:"relative flex h-full w-full items-end justify-center select-none",onPointerDown:(e)=>{if(e.button!==0)return;b.current={x:e.screenX,y:e.screenY}},onPointerMove:(e)=>{let n=b.current;if(n===null||Math.hypot(e.screenX-n.x,e.screenY-n.y)<4)return;if(b.current=null,s.current===null)throw Error("The pet engine is unavailable");B(t.windows,s.current,e.screenX<n.x).catch(t.onError)},onPointerUp:()=>{b.current=null},onContextMenu:(e)=>{e.preventDefault(),t.windows.call("menu").catch(t.onError)},children:[E("div",{style:{width:y,height:y,visibility:R?"hidden":"visible"},children:E(Z,{config:f.config,spriteUrl:f.spriteUrl,stateId:g.state,flipped:g.flipped,animTick:g.tick,active:v,onDrawFrame:()=>{if(a!==null)r.drawn(a.petId,a.generation)},onRenderError:(e)=>{if(a!==null)r.fail(a.petId,a.generation,e);t.onError(e)},onMouseDown:()=>{},onClick:()=>{s.current?.handleClick();let e=Date.now();if(e-w.current<350&&e-w.current>50)i.close(),t.sessions.activate().catch(t.onError),w.current=0;else w.current=e}})}),R&&E("div",{className:"alwith-vibemon-burst pointer-events-none",style:{position:"fixed",left:"50%",bottom:0,width:280,height:280,transform:`translateX(-50%) scale(${y/280})`,transformOrigin:"center bottom",zIndex:20}})]})}export{ae as PetWindow};
@@ -1 +1 @@
1
- import{jsx as n,jsxs as d,Fragment as M}from"react/jsx-runtime";import{multiDrawSrBackground as H,multiDrawSsrBackground as J,newTag as F,pullTexture as A,resultAura as Q}from"../assets.js";import{motion as y,useInView as X}from"motion/react";import{useEffect as E,useRef as L,useState as p}from"react";import{Button as O}from"../ui/button.js";import{cardThumb as D}from"../lib/card-image.js";import{cn as Z}from"../lib/utils.js";import{PULL_VIDEO_SOURCES as ee}from"./pull-video.js";import{VideoFader as te}from"./video-fader.js";var u=300,l=500,N=400,ne=1920,U=10,P=1474,G=[0.6,0.7,0.8,0.9,1,1,0.9,0.8,0.7,0.6],ae=1.1269,C=[12,14,16,18,20,18,16,14,12].map((e)=>e*ae),k=(P-C.reduce((e,t)=>e+t,0))/G.reduce((e,t)=>e+t,0),ie=(()=>{let e=0;return G.map((t,i)=>{let s=k*t,a=e+s/2-P/2;if(e+=s,i<C.length)e+=C[i];return{scale:t,x:a}})})(),I={R:null,SR:H,SSR:J},S=(e)=>`${e/ne*100}cqw`,B={R:"r",SR:"sr",SSR:"ssr"},z={"white-card":{scrim:"linear-gradient(0deg, rgba(0,0,0,0.20) 0%, rgba(0,0,0,0.20) 100%), linear-gradient(180.83deg, rgba(1,24,30,0.90) 58.198%, rgba(86,209,251,0.90) 153.35%)",button:"#82D6EB",textureOpacity:"opacity-68"},r:{scrim:"linear-gradient(0deg, rgba(0,0,0,0.20) 0%, rgba(0,0,0,0.20) 100%), linear-gradient(180.83deg, rgba(1,24,30,0.90) 58.198%, rgba(86,209,251,0.90) 153.35%)",button:"#82D6EB",textureOpacity:"opacity-68"},sr:{scrim:"linear-gradient(0deg, rgba(0,0,0,0.20) 0%, rgba(0,0,0,0.20) 100%), linear-gradient(180.83deg, rgba(22,1,30,0.90) 59.16%, rgba(192,106,255,0.90) 153.35%)",button:"#C16AFF",textureOpacity:"opacity-68"},ssr:{scrim:"linear-gradient(0deg, rgba(0,0,0,0.20) 0%, rgba(0,0,0,0.20) 100%), linear-gradient(180.83deg, rgba(33,15,0,0.90) 65.36%, rgba(255,172,47,0.90) 153.35%)",button:"#FFAF32",textureOpacity:"opacity-100"}},re={r:"linear-gradient(0deg, rgba(0, 0, 0, 0.20) 0%, rgba(0, 0, 0, 0.20) 100%), linear-gradient(181deg, rgba(0, 17, 35, 0.90) 65.37%, rgba(21, 166, 226, 0.90) 153.35%)",sr:"linear-gradient(0deg, rgba(0, 0, 0, 0.20) 0%, rgba(0, 0, 0, 0.20) 100%), linear-gradient(181deg, rgba(24, 7, 45, 0.90) 65.37%, rgba(156, 63, 224, 0.90) 153.35%)",ssr:"linear-gradient(0deg, rgba(0, 0, 0, 0.20) 0%, rgba(0, 0, 0, 0.20) 100%), linear-gradient(181deg, rgba(33, 15, 0, 0.90) 65.37%, rgba(255, 172, 47, 0.90) 153.35%)"},W=(e)=>{if(e.some((t)=>t.kind==="card"&&t.rarity==="SSR"))return"ssr";if(e.some((t)=>t.kind==="card"&&t.rarity==="SR"))return"sr";return"r"};function xe({phase:e,drawnRewards:t,onVideoStarted:i,onPullDone:s,onPullFailed:a,onResultConfirmed:o}){let r=L(null),g=X(r),[w,_]=p(document.visibilityState==="visible");E(()=>{let f=()=>_(document.visibilityState==="visible");return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[]);let[h,q]=p(!1),[x,v]=p("flat"),b=L(!1);E(()=>{if(e!=="idle")return;b.current=!1,q(!1),v("flat")},[e]);let m=t.length>1,c=m?null:t[0],T=m?W(t):null,V=m&&t.some((f)=>f.kind==="card"),R=c?c.kind==="white-card"?"white-card":B[c.rarity]:null,K=()=>{if(!m||x!=="flat"||b.current)return;if(b.current=!0,!V){v("fly"),setTimeout(()=>o(!1),u);return}v("gather"),setTimeout(()=>v("fly"),N),setTimeout(()=>o(!0),N+l)},j=()=>{if(!c||h||b.current)return;b.current=!0,q(!0);let f=c.kind==="card"?l:u;setTimeout(()=>o(c.kind==="card"),f)},Y=m?x!=="fly":!h;return d("div",{ref:r,"data-presentation-state":e,className:"[container-type:size] absolute inset-0 z-50 overflow-hidden bg-transparent transition-colors duration-300",style:{pointerEvents:e==="idle"?"none":"auto"},children:[n("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 transition-opacity duration-300",style:{background:e!=="result"?"rgba(1,10,21,1)":T?re[T]:R?z[R].scrim:"rgba(1,10,21,0.82)",opacity:e==="result"&&Y?1:0}}),e==="result"&&(m?n(me,{rewards:t,stage:x,onConfirm:K}):c?n(ue,{reward:c,onConfirm:j,closing:h}):null),n(te,{sources:ee,playing:e==="video-waiting"||e==="video-playing",active:g&&w,background:"rgba(1,10,21,1)",onFirstFrame:i,onComplete:s,onError:a})]})}var se={default:"#FFAF32",hover:"#FFC15F",press:"#ECA029"};function oe({onConfirm:e}){let[t,i]=p(!1),[s,a]=p(!1),o=s?"press":t?"hover":"default";return d(O,{"aria-label":"Confirm",onClick:e,"data-visual-state":o,onPointerEnter:()=>i(!0),onPointerLeave:()=>{i(!1),a(!1)},onPointerDown:()=>a(!0),onPointerUp:()=>a(!1),onPointerCancel:()=>a(!1),onKeyDown:(r)=>{if(r.key===" "||r.key==="Enter")a(!0)},onKeyUp:(r)=>{if(r.key===" "||r.key==="Enter")a(!1)},onBlur:()=>{i(!1),a(!1)},style:{backgroundColor:se[o]},className:"relative h-full w-full overflow-hidden rounded-full border-0 p-0 shadow-none drop-shadow-[0_0.417cqh_0_rgba(0,0,0,0.51)] transition-none active:translate-y-0",children:[n("img",{src:A,alt:"",className:"pointer-events-none absolute top-[-560.71%] left-[-20.34%] h-[741.76%] w-[160.31%] max-w-none mix-blend-soft-light select-none"}),n("span",{"aria-hidden":!0,className:"absolute inset-0 shadow-[inset_0_0.2cqh_0.07cqh_0_white]"}),n("span",{className:"relative text-[1.458cqw] leading-normal font-normal text-[#403C80]",style:{fontFamily:'"Grow Year", system-ui, sans-serif',WebkitTextStroke:"0.25cqw white",paintOrder:"stroke fill"},children:"Confirm"})]})}function le({tone:e,onConfirm:t}){let i=z[e];return d(O,{"aria-label":"Confirm",onClick:t,style:{backgroundColor:i.button},className:"relative h-full w-full overflow-hidden rounded-full border-0 p-0 shadow-none drop-shadow-[0_0.417cqh_0_rgba(0,0,0,0.51)] transition-none hover:brightness-105 active:translate-y-0",children:[n("img",{src:A,alt:"",className:Z("pointer-events-none absolute top-[-560.71%] left-[-20.34%] h-[741.76%] w-[160.31%] max-w-none mix-blend-soft-light select-none",i.textureOpacity)}),n("span",{"aria-hidden":!0,className:"absolute inset-0 shadow-[inset_0_0.2cqh_0.07cqh_0_white]"}),n("span",{className:"relative text-[1.458cqw] leading-normal font-normal text-[#403C80]",style:{fontFamily:'"Grow Year", system-ui, sans-serif',WebkitTextStroke:"0.25cqw white",paintOrder:"stroke fill"},children:"Confirm"})]})}function ce({reward:e}){return n("img",{src:e.singleImageUrl,alt:`Gacha Gem ×${e.exchangePoints}`,className:"block h-auto w-full max-w-none select-none"})}function ue({reward:e,onConfirm:t,closing:i}){let s=e.kind==="white-card"?"white-card":B[e.rarity];return n("div",{"data-testid":"single-draw-result","data-result-tone":s,className:"absolute inset-0 z-10",children:d("div",{className:"[container-type:size] absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",style:{width:"min(100cqw, 160cqh)",aspectRatio:"8 / 5"},children:[n(y.div,{"aria-hidden":!0,className:"pointer-events-none absolute top-[43.810%] left-[52.655%] aspect-square w-[31.656%] -translate-x-1/2 -translate-y-1/2",animate:{opacity:i?0:0.62},transition:{duration:u/1000},children:n("img",{src:Q,alt:"",className:"h-full w-full max-w-none [animation:spin_2s_linear_infinite] select-none"})}),n("div",{className:`absolute -translate-x-1/2 ${e.kind==="card"?"top-[20.396%] left-[52.551%]":"top-[43.810%] left-[52.656%] -translate-y-1/2"}`,children:n(y.div,{className:"relative",style:{width:e.kind==="card"?"20.833cqw":"13.75cqw"},initial:!1,animate:i?e.kind==="card"?{x:["0cqw","14cqw","29cqw"],y:["0cqh","-34cqh","-37cqh"],scale:[1,0.14],opacity:[1,1,0]}:{x:0,y:0,scale:0.94,opacity:0}:{x:0,y:0,scale:1,opacity:1},transition:i&&e.kind==="card"?{x:{duration:l/1000,ease:"linear",times:[0,0.5,1]},y:{duration:l/1000,ease:"linear",times:[0,0.5,1]},scale:{duration:l/1000,ease:"linear"},opacity:{duration:l/1000,ease:"linear",times:[0,0.7,1]}}:{duration:i?u/1000:0},children:e.kind==="card"?d(M,{children:[n("img",{src:D(e.singleImageUrl),alt:`${e.vibemonName} ${e.rarity} card`,className:"h-auto w-full max-w-none select-none"}),e.isNew&&n("img",{src:F,alt:"New",className:"pointer-events-none absolute top-[0.202%] right-[2.504%] z-10 h-auto w-[22.5%] max-w-none select-none"})]}):n(ce,{reward:e})})}),n(y.div,{className:"absolute top-[71.667%] left-[52.656%] h-[6.5%] w-[18.542%] -translate-x-1/2",animate:{opacity:i?0:1},transition:{duration:u/1000},style:{pointerEvents:i?"none":"auto"},children:n(le,{tone:s,onConfirm:t})})]})})}function de({reward:e}){return n("img",{src:e.multiImageUrl,alt:`Gacha Gem ×${e.exchangePoints}`,className:"pointer-events-none block h-auto w-full max-w-none select-none"})}function me({rewards:e,stage:t,onConfirm:i}){if(e.length!==U)throw Error(`[vibemon] ten-draw result must contain ${U} rewards, received ${e.length}`);let s=W(e);return n("div",{"data-testid":"multi-draw-result","data-result-tone":s,className:"absolute inset-0 z-10 overflow-hidden",children:d("div",{"data-testid":"multi-result-stage",className:"[container-type:size] absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",style:{width:"min(100cqw, 160cqh)",aspectRatio:"8 / 5"},children:[n("div",{"data-testid":"multi-result-group",className:"absolute top-[17.833%] left-[11.615%] h-[55%] w-[76.77%]",children:e.map((a,o)=>{let r=ie[o],g={x:S(r.x),y:"0cqh",scale:r.scale,opacity:1},w=a.kind==="card"?`${a.drawIndex}-${a.vibemonUuid}`:`${a.drawIndex}-white-card`,_=a.kind==="card"?{x:"0cqw",y:"0cqh",scale:1,opacity:1}:{...g,opacity:0},h=a.kind==="card"?{x:["0cqw","17cqw","34cqw"],y:["0cqh","-40cqh","-38cqh"],scale:[1,0.08],opacity:[1,1,0]}:{...g,opacity:0};return n("div",{className:"absolute inset-y-0 left-1/2 flex items-center",style:{width:S(k),marginLeft:S(-k/2),zIndex:t==="flat"?10-Math.abs(o-4.5):e.length-o},children:n(y.div,{"data-result-index":o,"data-result-scale":r.scale,className:"relative w-full",initial:!1,animate:t==="flat"?g:t==="gather"?_:h,transition:t==="gather"?{duration:a.kind==="card"?N/1000:u/1000,ease:"easeIn"}:t==="fly"?a.kind==="card"?{x:{duration:l/1000,ease:"linear",times:[0,0.5,1]},y:{duration:l/1000,ease:"linear",times:[0,0.5,1]},scale:{duration:l/1000,ease:"linear"},opacity:{duration:l/1000,ease:"linear",times:[0,0.7,1]}}:{duration:u/1000}:{duration:0},children:a.kind==="card"?d(M,{children:[I[a.rarity]!==null&&n("img",{src:I[a.rarity]??void 0,alt:"","aria-hidden":!0,"data-testid":`multi-card-band-${a.rarity}`,className:"pointer-events-none absolute top-1/2 left-0 h-auto w-full max-w-none -translate-y-1/2 select-none"}),n("img",{src:D(a.multiImageUrl),alt:`${a.vibemonName} ${a.rarity} card`,className:"pointer-events-none relative block h-auto w-full max-w-none select-none"}),a.isNew&&n("img",{src:F,alt:"New",className:"pointer-events-none absolute top-0 right-[-5.85%] z-10 h-auto w-[44.21%] max-w-none -translate-y-1/2 select-none"})]}):n(de,{reward:a})})},w)})}),n(y.div,{className:"absolute top-[78%] left-[40.729%] h-[6.5%] w-[18.542%]",style:{pointerEvents:t==="flat"?"auto":"none"},animate:{opacity:t==="flat"?1:0},transition:{duration:u/1000},children:n(oe,{onConfirm:i})})]})})}export{xe as PullOverlay};
1
+ import{jsx as n,jsxs as d,Fragment as M}from"react/jsx-runtime";import{motion as y,useInView as H}from"motion/react";import{useEffect as E,useRef as L,useState as p}from"react";import{multiDrawSrBackground as J,multiDrawSsrBackground as Q,newTag as F,pullTexture as A,resultAura as X}from"../assets.js";import{cardThumb as O}from"../lib/card-image.js";import{cn as Z}from"../lib/utils.js";import{Button as D}from"../ui/button.js";import{PULL_VIDEO_SOURCES as ee}from"./pull-video.js";import{VideoFader as te}from"./video-fader.js";var u=300,l=500,N=400,ne=1920,U=10,P=1474,G=[0.6,0.7,0.8,0.9,1,1,0.9,0.8,0.7,0.6],ae=1.1269,C=[12,14,16,18,20,18,16,14,12].map((e)=>e*ae),k=(P-C.reduce((e,t)=>e+t,0))/G.reduce((e,t)=>e+t,0),ie=(()=>{let e=0;return G.map((t,i)=>{let s=k*t,a=e+s/2-P/2;if(e+=s,i<C.length)e+=C[i];return{scale:t,x:a}})})(),I={R:null,SR:J,SSR:Q},S=(e)=>`${e/ne*100}cqw`,B={R:"r",SR:"sr",SSR:"ssr"},z={"white-card":{scrim:"linear-gradient(0deg, rgba(0,0,0,0.20) 0%, rgba(0,0,0,0.20) 100%), linear-gradient(180.83deg, rgba(1,24,30,0.90) 58.198%, rgba(86,209,251,0.90) 153.35%)",button:"#82D6EB",textureOpacity:"opacity-68"},r:{scrim:"linear-gradient(0deg, rgba(0,0,0,0.20) 0%, rgba(0,0,0,0.20) 100%), linear-gradient(180.83deg, rgba(1,24,30,0.90) 58.198%, rgba(86,209,251,0.90) 153.35%)",button:"#82D6EB",textureOpacity:"opacity-68"},sr:{scrim:"linear-gradient(0deg, rgba(0,0,0,0.20) 0%, rgba(0,0,0,0.20) 100%), linear-gradient(180.83deg, rgba(22,1,30,0.90) 59.16%, rgba(192,106,255,0.90) 153.35%)",button:"#C16AFF",textureOpacity:"opacity-68"},ssr:{scrim:"linear-gradient(0deg, rgba(0,0,0,0.20) 0%, rgba(0,0,0,0.20) 100%), linear-gradient(180.83deg, rgba(33,15,0,0.90) 65.36%, rgba(255,172,47,0.90) 153.35%)",button:"#FFAF32",textureOpacity:"opacity-100"}},re={r:"linear-gradient(0deg, rgba(0, 0, 0, 0.20) 0%, rgba(0, 0, 0, 0.20) 100%), linear-gradient(181deg, rgba(0, 17, 35, 0.90) 65.37%, rgba(21, 166, 226, 0.90) 153.35%)",sr:"linear-gradient(0deg, rgba(0, 0, 0, 0.20) 0%, rgba(0, 0, 0, 0.20) 100%), linear-gradient(181deg, rgba(24, 7, 45, 0.90) 65.37%, rgba(156, 63, 224, 0.90) 153.35%)",ssr:"linear-gradient(0deg, rgba(0, 0, 0, 0.20) 0%, rgba(0, 0, 0, 0.20) 100%), linear-gradient(181deg, rgba(33, 15, 0, 0.90) 65.37%, rgba(255, 172, 47, 0.90) 153.35%)"},W=(e)=>{if(e.some((t)=>t.kind==="card"&&t.rarity==="SSR"))return"ssr";if(e.some((t)=>t.kind==="card"&&t.rarity==="SR"))return"sr";return"r"};function xe({phase:e,drawnRewards:t,onVideoStarted:i,onPullDone:s,onPullFailed:a,onResultConfirmed:o}){let r=L(null),g=H(r),[w,_]=p(document.visibilityState==="visible");E(()=>{let f=()=>_(document.visibilityState==="visible");return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[]);let[h,q]=p(!1),[x,v]=p("flat"),b=L(!1);E(()=>{if(e!=="idle")return;b.current=!1,q(!1),v("flat")},[e]);let m=t.length>1,c=m?null:t[0],T=m?W(t):null,V=m&&t.some((f)=>f.kind==="card"),R=c?c.kind==="white-card"?"white-card":B[c.rarity]:null,K=()=>{if(!m||x!=="flat"||b.current)return;if(b.current=!0,!V){v("fly"),setTimeout(()=>o(!1),u);return}v("gather"),setTimeout(()=>v("fly"),N),setTimeout(()=>o(!0),N+l)},j=()=>{if(!c||h||b.current)return;b.current=!0,q(!0);let f=c.kind==="card"?l:u;setTimeout(()=>o(c.kind==="card"),f)},Y=m?x!=="fly":!h;return d("div",{ref:r,"data-presentation-state":e,className:"[container-type:size] absolute inset-0 z-50 overflow-hidden bg-transparent transition-colors duration-300",style:{pointerEvents:e==="idle"?"none":"auto"},children:[n("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 transition-opacity duration-300",style:{background:e!=="result"?"rgba(1,10,21,1)":T?re[T]:R?z[R].scrim:"rgba(1,10,21,0.82)",opacity:e==="result"&&Y?1:0}}),e==="result"&&(m?n(me,{rewards:t,stage:x,onConfirm:K}):c?n(ue,{reward:c,onConfirm:j,closing:h}):null),n(te,{sources:ee,playing:e==="video-waiting"||e==="video-playing",active:g&&w,background:"rgba(1,10,21,1)",onFirstFrame:i,onComplete:s,onError:a})]})}var se={default:"#FFAF32",hover:"#FFC15F",press:"#ECA029"};function oe({onConfirm:e}){let[t,i]=p(!1),[s,a]=p(!1),o=s?"press":t?"hover":"default";return d(D,{"aria-label":"Confirm",onClick:e,"data-visual-state":o,onPointerEnter:()=>i(!0),onPointerLeave:()=>{i(!1),a(!1)},onPointerDown:()=>a(!0),onPointerUp:()=>a(!1),onPointerCancel:()=>a(!1),onKeyDown:(r)=>{if(r.key===" "||r.key==="Enter")a(!0)},onKeyUp:(r)=>{if(r.key===" "||r.key==="Enter")a(!1)},onBlur:()=>{i(!1),a(!1)},style:{backgroundColor:se[o]},className:"relative h-full w-full overflow-hidden rounded-full border-0 p-0 shadow-none drop-shadow-[0_0.417cqh_0_rgba(0,0,0,0.51)] transition-none active:translate-y-0",children:[n("img",{src:A,alt:"",className:"pointer-events-none absolute top-[-560.71%] left-[-20.34%] h-[741.76%] w-[160.31%] max-w-none mix-blend-soft-light select-none"}),n("span",{"aria-hidden":!0,className:"absolute inset-0 shadow-[inset_0_0.2cqh_0.07cqh_0_white]"}),n("span",{className:"relative text-[1.458cqw] leading-normal font-normal text-[#403C80]",style:{fontFamily:'"Grow Year", system-ui, sans-serif',WebkitTextStroke:"0.25cqw white",paintOrder:"stroke fill"},children:"Confirm"})]})}function le({tone:e,onConfirm:t}){let i=z[e];return d(D,{"aria-label":"Confirm",onClick:t,style:{backgroundColor:i.button},className:"relative h-full w-full overflow-hidden rounded-full border-0 p-0 shadow-none drop-shadow-[0_0.417cqh_0_rgba(0,0,0,0.51)] transition-none hover:brightness-105 active:translate-y-0",children:[n("img",{src:A,alt:"",className:Z("pointer-events-none absolute top-[-560.71%] left-[-20.34%] h-[741.76%] w-[160.31%] max-w-none mix-blend-soft-light select-none",i.textureOpacity)}),n("span",{"aria-hidden":!0,className:"absolute inset-0 shadow-[inset_0_0.2cqh_0.07cqh_0_white]"}),n("span",{className:"relative text-[1.458cqw] leading-normal font-normal text-[#403C80]",style:{fontFamily:'"Grow Year", system-ui, sans-serif',WebkitTextStroke:"0.25cqw white",paintOrder:"stroke fill"},children:"Confirm"})]})}function ce({reward:e}){return n("img",{src:e.singleImageUrl,alt:`Gacha Gem ×${e.exchangePoints}`,className:"block h-auto w-full max-w-none select-none"})}function ue({reward:e,onConfirm:t,closing:i}){let s=e.kind==="white-card"?"white-card":B[e.rarity];return n("div",{"data-testid":"single-draw-result","data-result-tone":s,className:"absolute inset-0 z-10",children:d("div",{className:"[container-type:size] absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",style:{width:"min(100cqw, 160cqh)",aspectRatio:"8 / 5"},children:[n(y.div,{"aria-hidden":!0,className:"pointer-events-none absolute top-[43.810%] left-[52.655%] aspect-square w-[31.656%] -translate-x-1/2 -translate-y-1/2",animate:{opacity:i?0:0.62},transition:{duration:u/1000},children:n("img",{src:X,alt:"",className:"h-full w-full max-w-none [animation:spin_2s_linear_infinite] select-none"})}),n("div",{className:`absolute -translate-x-1/2 ${e.kind==="card"?"top-[20.396%] left-[52.551%]":"top-[43.810%] left-[52.656%] -translate-y-1/2"}`,children:n(y.div,{className:"relative",style:{width:e.kind==="card"?"20.833cqw":"13.75cqw"},initial:!1,animate:i?e.kind==="card"?{x:["0cqw","14cqw","29cqw"],y:["0cqh","-34cqh","-37cqh"],scale:[1,0.14],opacity:[1,1,0]}:{x:0,y:0,scale:0.94,opacity:0}:{x:0,y:0,scale:1,opacity:1},transition:i&&e.kind==="card"?{x:{duration:l/1000,ease:"linear",times:[0,0.5,1]},y:{duration:l/1000,ease:"linear",times:[0,0.5,1]},scale:{duration:l/1000,ease:"linear"},opacity:{duration:l/1000,ease:"linear",times:[0,0.7,1]}}:{duration:i?u/1000:0},children:e.kind==="card"?d(M,{children:[n("img",{src:O(e.singleImageUrl),alt:`${e.vibemonName} ${e.rarity} card`,className:"h-auto w-full max-w-none select-none"}),e.isNew&&n("img",{src:F,alt:"New",className:"pointer-events-none absolute top-[0.202%] right-[2.504%] z-10 h-auto w-[22.5%] max-w-none select-none"})]}):n(ce,{reward:e})})}),n(y.div,{className:"absolute top-[71.667%] left-[52.656%] h-[6.5%] w-[18.542%] -translate-x-1/2",animate:{opacity:i?0:1},transition:{duration:u/1000},style:{pointerEvents:i?"none":"auto"},children:n(le,{tone:s,onConfirm:t})})]})})}function de({reward:e}){return n("img",{src:e.multiImageUrl,alt:`Gacha Gem ×${e.exchangePoints}`,className:"pointer-events-none block h-auto w-full max-w-none select-none"})}function me({rewards:e,stage:t,onConfirm:i}){if(e.length!==U)throw Error(`[vibemon] ten-draw result must contain ${U} rewards, received ${e.length}`);let s=W(e);return n("div",{"data-testid":"multi-draw-result","data-result-tone":s,className:"absolute inset-0 z-10 overflow-hidden",children:d("div",{"data-testid":"multi-result-stage",className:"[container-type:size] absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",style:{width:"min(100cqw, 160cqh)",aspectRatio:"8 / 5"},children:[n("div",{"data-testid":"multi-result-group",className:"absolute top-[17.833%] left-[11.615%] h-[55%] w-[76.77%]",children:e.map((a,o)=>{let r=ie[o],g={x:S(r.x),y:"0cqh",scale:r.scale,opacity:1},w=a.kind==="card"?`${a.drawIndex}-${a.vibemonUuid}`:`${a.drawIndex}-white-card`,_=a.kind==="card"?{x:"0cqw",y:"0cqh",scale:1,opacity:1}:{...g,opacity:0},h=a.kind==="card"?{x:["0cqw","17cqw","34cqw"],y:["0cqh","-40cqh","-38cqh"],scale:[1,0.08],opacity:[1,1,0]}:{...g,opacity:0};return n("div",{className:"absolute inset-y-0 left-1/2 flex items-center",style:{width:S(k),marginLeft:S(-k/2),zIndex:t==="flat"?10-Math.abs(o-4.5):e.length-o},children:n(y.div,{"data-result-index":o,"data-result-scale":r.scale,className:"relative w-full",initial:!1,animate:t==="flat"?g:t==="gather"?_:h,transition:t==="gather"?{duration:a.kind==="card"?N/1000:u/1000,ease:"easeIn"}:t==="fly"?a.kind==="card"?{x:{duration:l/1000,ease:"linear",times:[0,0.5,1]},y:{duration:l/1000,ease:"linear",times:[0,0.5,1]},scale:{duration:l/1000,ease:"linear"},opacity:{duration:l/1000,ease:"linear",times:[0,0.7,1]}}:{duration:u/1000}:{duration:0},children:a.kind==="card"?d(M,{children:[I[a.rarity]!==null&&n("img",{src:I[a.rarity]??void 0,alt:"","aria-hidden":!0,"data-testid":`multi-card-band-${a.rarity}`,className:"pointer-events-none absolute top-1/2 left-0 h-auto w-full max-w-none -translate-y-1/2 select-none"}),n("img",{src:O(a.multiImageUrl),alt:`${a.vibemonName} ${a.rarity} card`,className:"pointer-events-none relative block h-auto w-full max-w-none select-none"}),a.isNew&&n("img",{src:F,alt:"New",className:"pointer-events-none absolute top-0 right-[-5.85%] z-10 h-auto w-[44.21%] max-w-none -translate-y-1/2 select-none"})]}):n(de,{reward:a})})},w)})}),n(y.div,{className:"absolute top-[78%] left-[40.729%] h-[6.5%] w-[18.542%]",style:{pointerEvents:t==="flat"?"auto":"none"},animate:{opacity:t==="flat"?1:0},transition:{duration:u/1000},children:n(oe,{onConfirm:i})})]})})}export{xe as PullOverlay};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as s}from"react/jsx-runtime";import{pullAlbumIcon as A,pullBack as j,pullGem as G,pullPageBackground as O,pullTexture as M,pullVibemonIcon as L}from"../assets.js";import{motion as V}from"motion/react";import{useEffect as H,useMemo as R,useState as w}from"react";import{Button as P}from"../ui/button.js";import{getDefaultGachaPool as K,getVisibleGachaPools as X,resolveGachaPoolStatus as W}from"../../core/lib/gacha-pools.js";import{openAccountUrl as E}from"../../core/lib/recharge.js";import{cn as v}from"../lib/utils.js";import{BackToHome as Y}from"./back-to-home.js";import{GemBalance as J}from"./gem-balance.js";import{InsufficientPointsDialog as Q}from"./insufficient-points-dialog.js";import{FreeDrawGuide as Z,OnboardingScrim as ee}from"./onboarding-guide.js";var te="linear-gradient(180deg, #0C0C77 1.7234%, #171B6A 25.125%, #A67FFB 97.583%, #957FFB 116.28%)",ae=250,le={1:{default:"bg-[#82D6EB]",hover:"bg-[#A3E1F0]",press:"bg-[#5AC8E3]"},10:{default:"bg-[#FFD932]",hover:"bg-[#FFE46B]",press:"bg-[#FACE0B]"}};function _({drawCount:t,price:a,onClick:c,disabled:r,label:d}){let p=t===1,[b,u]=w(!1),[m,l]=w(!1),o=m?"press":b?"hover":"default",f=p?`X ${a}`:`X ${a}`;return s(P,{className:"relative h-[8.5cqh] w-full overflow-visible rounded-none border-0 bg-transparent p-0 shadow-none transition-none hover:bg-transparent active:translate-y-0 disabled:opacity-45","aria-label":d,disabled:r,"data-visual-state":o,onPointerEnter:()=>u(!0),onPointerLeave:()=>{u(!1),l(!1)},onPointerDown:()=>l(!0),onPointerUp:()=>l(!1),onPointerCancel:()=>l(!1),onKeyDown:(h)=>{if(h.key===" "||h.key==="Enter")l(!0)},onKeyUp:(h)=>{if(h.key===" "||h.key==="Enter")l(!1)},onBlur:()=>{u(!1),l(!1)},onClick:c,children:[s("span",{className:"absolute top-[2.092cqh] left-0 h-[6.408cqh] w-full overflow-hidden rounded-[6.25cqw] drop-shadow-[0_0.417cqh_0_rgba(0,0,0,0.51)]",children:[e("span",{"data-slot":"pull-button-surface",className:v("absolute inset-0",le[t][o])}),e("img",{src:M,alt:"",className:v("pointer-events-none absolute top-[-560.71%] left-[-20.34%] h-[741.76%] w-[160.31%] max-w-none select-none",p?"opacity-68 mix-blend-soft-light":"opacity-18 mix-blend-color-burn")}),e("span",{className:"absolute inset-0 shadow-[inset_0_0.2cqh_0.07cqh_0_white]"}),s("span",{"data-slot":"pull-button-label",className:"absolute inset-0 flex items-center justify-center text-[1.458cqw] leading-normal font-normal text-[#403C80]",style:{fontFamily:'"Grow Year", system-ui, sans-serif',WebkitTextStroke:"0.25cqw white",paintOrder:"stroke fill"},children:["PULL X",t]})]}),s("span",{className:"absolute top-0 left-1/2 flex h-[4.422cqh] -translate-x-1/2 items-center whitespace-nowrap",children:[e("span",{className:"me-[-0.375cqw] flex size-[2.763cqw] shrink-0 items-center justify-center",children:e("img",{"data-testid":"pull-button-gem",src:G,alt:"",className:"size-[1.682cqw] max-w-none -scale-y-100 rotate-[21.86deg] select-none"})}),e("span",{"data-slot":"pull-button-price","data-text":f,className:"relative scale-y-98 -skew-x-10 text-[1cqw] leading-normal font-semibold tracking-[0.1cqw] text-transparent before:absolute before:inset-0 before:text-white before:content-[attr(data-text)] before:[-webkit-text-stroke:0.25cqw_#FFFFFF] after:absolute after:inset-0 after:bg-gradient-to-b after:from-[#9645CF] after:to-[#878FFF] after:bg-clip-text after:text-transparent after:content-[attr(data-text)]",style:{fontFamily:'"PingFang SC", sans-serif'},children:f})]})]})}var oe=["unselected","hover","selected"],ne=(t,a)=>a==="selected"?t.sidebarSelectedImageUrl:a==="hover"?t.sidebarHoverImageUrl:t.sidebarUnselectedImageUrl;function se({pool:t,selected:a,disabled:c,onSelect:r}){let[d,p]=w(!1),[b,u]=w(!1),m=a?"selected":d||b?"hover":"unselected";return e(P,{id:`pool-tab-${t.poolUuid}`,role:"tab","aria-selected":a,"aria-controls":"gacha-pool-banner","aria-label":t.name,disabled:c,onClick:r,onPointerEnter:()=>p(!0),onPointerLeave:()=>p(!1),onFocus:()=>u(!0),onBlur:()=>u(!1),"data-visual-state":m,className:v("relative h-[14.167cqh] w-full shrink-0 justify-start overflow-visible rounded-none border-0 bg-transparent p-0 shadow-none transition-none hover:bg-transparent active:translate-y-0 disabled:opacity-100",a?"z-20":"z-0"),children:oe.map((l)=>e("img",{src:ne(t,l),alt:"","aria-hidden":!0,className:v("pointer-events-none absolute bottom-0 left-0 h-auto w-full max-w-none select-none",m===l?"opacity-100":"opacity-0")},l))})}function re(t,a){if(a==="UPCOMING"){if(t.startsAt===null)throw Error(`Upcoming gacha pool ${t.poolUuid} is missing startsAt`);return{label:"Starts in",at:t.startsAt}}if(a==="ACTIVE"&&t.endsAt!==null)return{label:"Time remaining",at:t.endsAt};return null}function ie({pool:t,status:a,nowMs:c}){let r=re(t,a);if(r===null)return null;let d=Math.floor((Date.parse(r.at)-c)/1000),p=Math.floor(d/86400),b=Math.floor(d%86400/3600),u=Math.floor(d%3600/60),m=d%60,l=[{value:p,unit:"d"},{value:b,unit:"h"},{value:u,unit:"m"},{value:m,unit:"s"}];return e("div",{role:"timer","aria-label":r.label,className:"absolute bottom-[6.8%] left-[4.4%] flex min-w-[28%] items-center gap-[1.5%] rounded-lg bg-black/24 px-[1.2%] py-[0.8%] text-white backdrop-blur-sm",children:l.map(({value:o,unit:f})=>s("span",{className:"flex items-center gap-[0.35em]",children:[e("span",{className:"min-w-[2.1em] rounded-md bg-black/28 px-[0.35em] py-[0.25em] text-center text-[clamp(9px,0.82cqw,16px)] leading-none font-bold tabular-nums",children:String(o).padStart(2,"0")}),e("span",{className:"text-[clamp(8px,0.58cqw,12px)] font-medium text-white/75",children:f})]},f))})}function ce(t,a){let c=t.find((r)=>r.poolUuid===a);if(c!==void 0)return c;return B(t)}function B(t){let a=t[0];if(a===void 0)throw Error("Gacha pool catalog has no visible pools");return a}function qe({onBack:t,onAlbum:a,onEquip:c,isFirstDraw:r,onSingleDraw:d,onMultiDraw:p,drawDisabled:b,albumHasUnseen:u,availablePoints:m,pointsLoaded:l,guideActive:o,poolCatalog:f}){let[h,x]=w(!1),[S,z]=w(B(f.pools).poolUuid),[N,D]=w(Date.now);H(()=>{let i=window.setInterval(()=>D(Date.now()),1000);return()=>window.clearInterval(i)},[]);let q=R(()=>X(f.pools,N),[f.pools,N]),y=K(q),n=o?y:ce(q,S),U=W(n,N),k=r&&n.poolUuid===y.poolUuid,F=n.singlePrice,C=b||!n.canDraw||U!=="ACTIVE",I=()=>{if(!k&&l&&m<F){x(!0);return}d(n.poolUuid)},T=()=>{if(l&&m<n.multiPrice){x(!0);return}p(n.poolUuid)};return s("div",{className:"[container-type:size] relative h-full w-full overflow-hidden",style:{background:te},children:[e("div",{className:"absolute inset-0 flex items-center justify-center",children:s("div",{"data-testid":"vibemon-pull-stage",className:"[container-type:size] relative",style:{width:"min(100cqw, 160cqh)",aspectRatio:"8 / 5"},children:[s("div",{"aria-hidden":!0,className:"pointer-events-none absolute top-[-51.213%] left-[48.958%] h-[172.145%] w-[143.454%] -translate-x-1/2",children:[e("img",{"data-testid":"vibemon-pool-page-background",src:O,alt:"",className:"absolute inset-0 h-full w-full max-w-none object-cover opacity-60 mix-blend-color-burn select-none"}),e("div",{className:"absolute inset-0 bg-black/40"})]}),e(Y,{onClick:t,disabled:o,label:"Back",iconSrc:j,className:"absolute top-[5%] left-[6.25%] z-10 gap-[0.729cqw] text-[#BCACE0] hover:text-[#BCACE0] [&_img]:size-[3.021cqw] [&_span]:text-[1.667cqw]"}),s("div",{className:"absolute top-[5%] right-[6.25%] z-10 flex h-[5.5cqh] items-center gap-[2.292cqw]",children:[e(P,{"aria-label":"Vibémon",disabled:o,onClick:c,className:"size-[3.333cqw] bg-transparent p-0 hover:bg-transparent",children:e("img",{src:L,alt:"",className:"size-full object-contain"})}),s(P,{"aria-label":"Album",disabled:o,onClick:a,className:"relative size-[3.333cqw] bg-transparent p-0 hover:bg-transparent",children:[e("img",{src:A,alt:"",className:"size-full object-contain"}),u&&e("span",{className:"absolute top-0 right-0 size-2 rounded-full bg-[#F74640]"})]}),e(J,{amount:m,onAdd:E,loaded:l,disabled:o,className:"h-[5.5cqh] min-w-0 rounded-[7.813cqw] py-0 pr-[0.417cqw] pl-[0.729cqw] [&_[data-slot=gem-balance-add-icon]]:size-[2.5cqw] [&>[data-slot=gem-balance-add]]:ms-[1.094cqw] [&>[data-slot=gem-balance-add]]:size-[2.5cqw] [&>[data-slot=gem-balance-amount]]:text-[1.563cqw] [&>[data-slot=gem-balance-icon]]:me-[0.156cqw] [&>[data-slot=gem-balance-icon]]:size-[2.5cqw]"})]}),e("div",{role:"tablist","aria-label":"Card pools",className:"absolute top-[19.816%] left-[6.25%] flex w-[12.5%] flex-col",children:q.map((i)=>e(se,{pool:i,selected:i.poolUuid===n.poolUuid,disabled:o||b,onSelect:()=>z(i.poolUuid)},i.poolUuid))}),s("div",{id:"gacha-pool-banner",role:"tabpanel","aria-labelledby":`pool-tab-${n.poolUuid}`,className:"absolute top-[16.667%] left-[14.583%] z-10 h-[66.667%] w-[79.167%] overflow-hidden rounded-[1.042cqw]",children:[q.map((i)=>{let g=i.poolUuid===n.poolUuid;return e(V.img,{src:i.poolCardImageUrl,alt:g?`${i.name} pool`:"","aria-hidden":!g,className:"absolute inset-0 h-full w-full object-cover select-none",style:{zIndex:g?1:0},initial:!1,animate:{opacity:g?1:0},transition:{duration:ae/1000,ease:g?"easeOut":"easeIn"}},i.poolUuid)}),e(ie,{pool:n,status:U,nowMs:N})]}),s("div",{className:"absolute top-[86.098%] left-[54.427%] flex gap-[2.24cqw]",children:[e("div",{className:v("w-[18.542cqw]",o&&"relative z-30"),children:e(_,{drawCount:1,price:F,label:"Pull once",disabled:C,onClick:I})}),e("div",{className:"w-[18.542cqw]",children:e(_,{drawCount:10,price:n.multiPrice,label:"Pull ten times",disabled:o||k||C,onClick:T})})]}),o&&e(ee,{}),o&&e(Z,{})]})}),h&&e(Q,{onClose:()=>x(!1),onProceed:()=>{E(),x(!1)}})]})}export{qe as PullView};
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import{motion as A}from"motion/react";import{useEffect as j,useMemo as G,useState as w}from"react";import{getDefaultGachaPool as O,getVisibleGachaPools as M,resolveGachaPoolStatus as L}from"../../core/lib/gacha-pools.js";import{openAccountUrl as E}from"../../core/lib/recharge.js";import{pullAlbumIcon as V,pullBack as H,pullGem as R,pullPageBackground as K,pullTexture as X,pullVibemonIcon as W}from"../assets.js";import{cn as v}from"../lib/utils.js";import{Button as P}from"../ui/button.js";import{BackToHome as Y}from"./back-to-home.js";import{GemBalance as J}from"./gem-balance.js";import{InsufficientPointsDialog as Q}from"./insufficient-points-dialog.js";import{FreeDrawGuide as Z,OnboardingScrim as ee}from"./onboarding-guide.js";var te="linear-gradient(180deg, #0C0C77 1.7234%, #171B6A 25.125%, #A67FFB 97.583%, #957FFB 116.28%)",ae=250,le={1:{default:"bg-[#82D6EB]",hover:"bg-[#A3E1F0]",press:"bg-[#5AC8E3]"},10:{default:"bg-[#FFD932]",hover:"bg-[#FFE46B]",press:"bg-[#FACE0B]"}};function _({drawCount:t,price:a,onClick:c,disabled:r,label:d}){let p=t===1,[b,u]=w(!1),[m,l]=w(!1),o=m?"press":b?"hover":"default",f=p?`X ${a}`:`X ${a}`;return s(P,{className:"relative h-[8.5cqh] w-full overflow-visible rounded-none border-0 bg-transparent p-0 shadow-none transition-none hover:bg-transparent active:translate-y-0 disabled:opacity-45","aria-label":d,disabled:r,"data-visual-state":o,onPointerEnter:()=>u(!0),onPointerLeave:()=>{u(!1),l(!1)},onPointerDown:()=>l(!0),onPointerUp:()=>l(!1),onPointerCancel:()=>l(!1),onKeyDown:(h)=>{if(h.key===" "||h.key==="Enter")l(!0)},onKeyUp:(h)=>{if(h.key===" "||h.key==="Enter")l(!1)},onBlur:()=>{u(!1),l(!1)},onClick:c,children:[s("span",{className:"absolute top-[2.092cqh] left-0 h-[6.408cqh] w-full overflow-hidden rounded-[6.25cqw] drop-shadow-[0_0.417cqh_0_rgba(0,0,0,0.51)]",children:[e("span",{"data-slot":"pull-button-surface",className:v("absolute inset-0",le[t][o])}),e("img",{src:X,alt:"",className:v("pointer-events-none absolute top-[-560.71%] left-[-20.34%] h-[741.76%] w-[160.31%] max-w-none select-none",p?"opacity-68 mix-blend-soft-light":"opacity-18 mix-blend-color-burn")}),e("span",{className:"absolute inset-0 shadow-[inset_0_0.2cqh_0.07cqh_0_white]"}),s("span",{"data-slot":"pull-button-label",className:"absolute inset-0 flex items-center justify-center text-[1.458cqw] leading-normal font-normal text-[#403C80]",style:{fontFamily:'"Grow Year", system-ui, sans-serif',WebkitTextStroke:"0.25cqw white",paintOrder:"stroke fill"},children:["PULL X",t]})]}),s("span",{className:"absolute top-0 left-1/2 flex h-[4.422cqh] -translate-x-1/2 items-center whitespace-nowrap",children:[e("span",{className:"me-[-0.375cqw] flex size-[2.763cqw] shrink-0 items-center justify-center",children:e("img",{"data-testid":"pull-button-gem",src:R,alt:"",className:"size-[1.682cqw] max-w-none -scale-y-100 rotate-[21.86deg] select-none"})}),e("span",{"data-slot":"pull-button-price","data-text":f,className:"relative scale-y-98 -skew-x-10 text-[1cqw] leading-normal font-semibold tracking-[0.1cqw] text-transparent before:absolute before:inset-0 before:text-white before:content-[attr(data-text)] before:[-webkit-text-stroke:0.25cqw_#FFFFFF] after:absolute after:inset-0 after:bg-gradient-to-b after:from-[#9645CF] after:to-[#878FFF] after:bg-clip-text after:text-transparent after:content-[attr(data-text)]",style:{fontFamily:'"PingFang SC", sans-serif'},children:f})]})]})}var oe=["unselected","hover","selected"],ne=(t,a)=>a==="selected"?t.sidebarSelectedImageUrl:a==="hover"?t.sidebarHoverImageUrl:t.sidebarUnselectedImageUrl;function se({pool:t,selected:a,disabled:c,onSelect:r}){let[d,p]=w(!1),[b,u]=w(!1),m=a?"selected":d||b?"hover":"unselected";return e(P,{id:`pool-tab-${t.poolUuid}`,role:"tab","aria-selected":a,"aria-controls":"gacha-pool-banner","aria-label":t.name,disabled:c,onClick:r,onPointerEnter:()=>p(!0),onPointerLeave:()=>p(!1),onFocus:()=>u(!0),onBlur:()=>u(!1),"data-visual-state":m,className:v("relative h-[14.167cqh] w-full shrink-0 justify-start overflow-visible rounded-none border-0 bg-transparent p-0 shadow-none transition-none hover:bg-transparent active:translate-y-0 disabled:opacity-100",a?"z-20":"z-0"),children:oe.map((l)=>e("img",{src:ne(t,l),alt:"","aria-hidden":!0,className:v("pointer-events-none absolute bottom-0 left-0 h-auto w-full max-w-none select-none",m===l?"opacity-100":"opacity-0")},l))})}function re(t,a){if(a==="UPCOMING"){if(t.startsAt===null)throw Error(`Upcoming gacha pool ${t.poolUuid} is missing startsAt`);return{label:"Starts in",at:t.startsAt}}if(a==="ACTIVE"&&t.endsAt!==null)return{label:"Time remaining",at:t.endsAt};return null}function ie({pool:t,status:a,nowMs:c}){let r=re(t,a);if(r===null)return null;let d=Math.floor((Date.parse(r.at)-c)/1000),p=Math.floor(d/86400),b=Math.floor(d%86400/3600),u=Math.floor(d%3600/60),m=d%60,l=[{value:p,unit:"d"},{value:b,unit:"h"},{value:u,unit:"m"},{value:m,unit:"s"}];return e("div",{role:"timer","aria-label":r.label,className:"absolute bottom-[6.8%] left-[4.4%] flex min-w-[28%] items-center gap-[1.5%] rounded-lg bg-black/24 px-[1.2%] py-[0.8%] text-white backdrop-blur-sm",children:l.map(({value:o,unit:f})=>s("span",{className:"flex items-center gap-[0.35em]",children:[e("span",{className:"min-w-[2.1em] rounded-md bg-black/28 px-[0.35em] py-[0.25em] text-center text-[clamp(9px,0.82cqw,16px)] leading-none font-bold tabular-nums",children:String(o).padStart(2,"0")}),e("span",{className:"text-[clamp(8px,0.58cqw,12px)] font-medium text-white/75",children:f})]},f))})}function ce(t,a){let c=t.find((r)=>r.poolUuid===a);if(c!==void 0)return c;return B(t)}function B(t){let a=t[0];if(a===void 0)throw Error("Gacha pool catalog has no visible pools");return a}function qe({onBack:t,onAlbum:a,onEquip:c,isFirstDraw:r,onSingleDraw:d,onMultiDraw:p,drawDisabled:b,albumHasUnseen:u,availablePoints:m,pointsLoaded:l,guideActive:o,poolCatalog:f}){let[h,x]=w(!1),[S,z]=w(B(f.pools).poolUuid),[N,D]=w(Date.now);j(()=>{let i=window.setInterval(()=>D(Date.now()),1000);return()=>window.clearInterval(i)},[]);let q=G(()=>M(f.pools,N),[f.pools,N]),y=O(q),n=o?y:ce(q,S),U=L(n,N),k=r&&n.poolUuid===y.poolUuid,F=n.singlePrice,C=b||!n.canDraw||U!=="ACTIVE",I=()=>{if(!k&&l&&m<F){x(!0);return}d(n.poolUuid)},T=()=>{if(l&&m<n.multiPrice){x(!0);return}p(n.poolUuid)};return s("div",{className:"[container-type:size] relative h-full w-full overflow-hidden",style:{background:te},children:[e("div",{className:"absolute inset-0 flex items-center justify-center",children:s("div",{"data-testid":"vibemon-pull-stage",className:"[container-type:size] relative",style:{width:"min(100cqw, 160cqh)",aspectRatio:"8 / 5"},children:[s("div",{"aria-hidden":!0,className:"pointer-events-none absolute top-[-51.213%] left-[48.958%] h-[172.145%] w-[143.454%] -translate-x-1/2",children:[e("img",{"data-testid":"vibemon-pool-page-background",src:K,alt:"",className:"absolute inset-0 h-full w-full max-w-none object-cover opacity-60 mix-blend-color-burn select-none"}),e("div",{className:"absolute inset-0 bg-black/40"})]}),e(Y,{onClick:t,disabled:o,label:"Back",iconSrc:H,className:"absolute top-[5%] left-[6.25%] z-10 gap-[0.729cqw] text-[#BCACE0] hover:text-[#BCACE0] [&_img]:size-[3.021cqw] [&_span]:text-[1.667cqw]"}),s("div",{className:"absolute top-[5%] right-[6.25%] z-10 flex h-[5.5cqh] items-center gap-[2.292cqw]",children:[e(P,{"aria-label":"Vibémon",disabled:o,onClick:c,className:"size-[3.333cqw] bg-transparent p-0 hover:bg-transparent",children:e("img",{src:W,alt:"",className:"size-full object-contain"})}),s(P,{"aria-label":"Album",disabled:o,onClick:a,className:"relative size-[3.333cqw] bg-transparent p-0 hover:bg-transparent",children:[e("img",{src:V,alt:"",className:"size-full object-contain"}),u&&e("span",{className:"absolute top-0 right-0 size-2 rounded-full bg-[#F74640]"})]}),e(J,{amount:m,onAdd:E,loaded:l,disabled:o,className:"h-[5.5cqh] min-w-0 rounded-[7.813cqw] py-0 pr-[0.417cqw] pl-[0.729cqw] [&_[data-slot=gem-balance-add-icon]]:size-[2.5cqw] [&>[data-slot=gem-balance-add]]:ms-[1.094cqw] [&>[data-slot=gem-balance-add]]:size-[2.5cqw] [&>[data-slot=gem-balance-amount]]:text-[1.563cqw] [&>[data-slot=gem-balance-icon]]:me-[0.156cqw] [&>[data-slot=gem-balance-icon]]:size-[2.5cqw]"})]}),e("div",{role:"tablist","aria-label":"Card pools",className:"absolute top-[19.816%] left-[6.25%] flex w-[12.5%] flex-col",children:q.map((i)=>e(se,{pool:i,selected:i.poolUuid===n.poolUuid,disabled:o||b,onSelect:()=>z(i.poolUuid)},i.poolUuid))}),s("div",{id:"gacha-pool-banner",role:"tabpanel","aria-labelledby":`pool-tab-${n.poolUuid}`,className:"absolute top-[16.667%] left-[14.583%] z-10 h-[66.667%] w-[79.167%] overflow-hidden rounded-[1.042cqw]",children:[q.map((i)=>{let g=i.poolUuid===n.poolUuid;return e(A.img,{src:i.poolCardImageUrl,alt:g?`${i.name} pool`:"","aria-hidden":!g,className:"absolute inset-0 h-full w-full object-cover select-none",style:{zIndex:g?1:0},initial:!1,animate:{opacity:g?1:0},transition:{duration:ae/1000,ease:g?"easeOut":"easeIn"}},i.poolUuid)}),e(ie,{pool:n,status:U,nowMs:N})]}),s("div",{className:"absolute top-[86.098%] left-[54.427%] flex gap-[2.24cqw]",children:[e("div",{className:v("w-[18.542cqw]",o&&"relative z-30"),children:e(_,{drawCount:1,price:F,label:"Pull once",disabled:C,onClick:I})}),e("div",{className:"w-[18.542cqw]",children:e(_,{drawCount:10,price:n.multiPrice,label:"Pull ten times",disabled:o||k||C,onClick:T})})]}),o&&e(ee,{}),o&&e(Z,{})]})}),h&&e(Q,{onClose:()=>x(!1),onProceed:()=>{E(),x(!1)}})]})}export{qe as PullView};
@@ -1,2 +1,2 @@
1
- import{jsx as o,jsxs as v}from"react/jsx-runtime";import{ArrowUpIcon as Fe,CheckIcon as je,PanelsTopLeftIcon as Pe,PencilLineIcon as Ue,XIcon as He}from"lucide-react";import{useCallback as xe,useEffect as ee,useLayoutEffect as ve,useRef as b,useState as p}from"react";import{useTranslation as Oe}from"react-i18next";import{cn as ne}from"cn";import{sameBinding as De,vibemonHost as Ve}from"../../core/host.js";import{Button as te}from"../ui/button.js";import{InputGroup as Ge,InputGroupAddon as We,InputGroupButton as P,InputGroupTextarea as qe}from"../ui/input-group.js";import{advancePetSubmission as Ke}from"../../core/lib/reply-submission.js";import{getVibemonScopeSync as Qe,useVibemonState as Xe}from"../lib/account-state.js";import{PetBubbleBackground as Ye}from"./pet-bubble-background.js";import{SessionIcon as ye}from"./session-icon.js";var oe=18,se=oe/2,Ze={color:"var(--popover-foreground)",borderRadius:16,border:"1px solid var(--border)"},Je=(h)=>h.split(/[\\/]/).filter(Boolean).at(-1)??"",$e=(h,t)=>[Je(h.cwd),h.title||t].filter(Boolean).join(" / ");function mn({maxHeight:h}){let t=Ve(),U=Xe(),ke=Qe(),[Ee,re]=p(320);ee(()=>{let e=!1;if(re(320),h===void 0&&U.pet!=="")t.assets.resources.inspect(U.pet).then((s)=>{if(e)return;let n=s?.config?.bubbleAreaHeight;if(n!==void 0&&(typeof n!=="number"||!Number.isFinite(n)))throw Error("Pet bubble height must be a finite number");re(Math.max(typeof n==="number"?n:0,320))}).catch(t.onError);return()=>{e=!0}},[t,ke,U.pet,h]);let{t:r}=Oe("common"),[i,Ie]=p(()=>t.sessions.snapshot()),[y,H]=p(""),[O,R]=p(!1),[m,k]=p(null),[le,D]=p(!1),[V,ie]=p(!1),[Ne,G]=p(""),[N,W]=p(!1),[Ce,ae]=p(null),ce=b(null),A=b(!1),C=b(!1),u=b(null),q=b(null),g=b(null),ue=b(i),de=b(null),pe=b(null),K=xe((e)=>G(e instanceof Error?e.message:String(e)),[]),l=i?.binding??null,a=i,E=i,M=l?.connectionEpoch??null,S=l?.sessionId??null,Me=l?.bindingRevision??-1,Se=i?.owner??"",Q=i===null||i.access!=="writable"||i.executionId!==null,Te=i!==null,_=xe(()=>{if(g.current?.abort(),g.current=null,W(!1),ae(null),H(""),R(!1),k(null),D(!1),q.current=null,G(""),A.current=!1,C.current=!1,u.current!==null)cancelAnimationFrame(u.current);u.current=null},[]);ee(()=>{let e=(n)=>{let x=ue.current;if(x===null||n===null||!De(x.binding,n.binding))_();if(ue.current=n,n!==null){if(n.state==="running")D(!0);k((I)=>I===null?I:Ke(I,n.state,n.since))}Ie(n)},s=t.sessions.subscribe(e);return e(t.sessions.snapshot()),document.addEventListener("vibemon:dismiss",_),()=>{if(s(),document.removeEventListener("vibemon:dismiss",_),g.current?.abort(),u.current!==null)cancelAnimationFrame(u.current)}},[t,_]);let T=()=>{if(l!==null)t.windows.call("bubble-interact",{binding:l}).catch(t.onError)},B=async(e)=>{if(g.current!==null)return;let s=new AbortController;g.current=s,T(),W(!0),G("");try{await e(s.signal)}catch(n){if(!s.signal.aborted)K(n)}finally{if(g.current===s)g.current=null,W(!1)}},Be=()=>t.windows.call("focus"),ze=(e)=>{if(l===null||i===null)throw Error("Pet conversation unavailable");return T(),t.windows.call("session-menu",{binding:l,candidates:i.candidates,position:e,onSelect:(s)=>B(()=>t.sessions.select(l,s))})},c=i?.state==="running",w=i?.state==="requires_action"||i?.prompt!=null,f=i?.prompt??null,Le=async(e,s,n)=>{if(l===null)throw Error(r("petMode.openToReply"));if(await t.sessions.answer(l,crypto.randomUUID(),e.token,s),!n.aborted)ae(e.token)},me=!N&&!Q&&!c&&!w&&y.trim()!==""&&Te,fe=async(e)=>{if(l===null||E===null)throw Error(r("petMode.openToReply"));let s=y.trim();q.current=E.reply?.messageId??null,k({sessionId:l.sessionId,text:s,startedAt:Date.now(),accepted:!1,sawRunning:!1,completed:!1});try{if(await t.sessions.send(l,crypto.randomUUID(),s),e.aborted)return;k((n)=>n===null?null:{...n,accepted:!0}),H("")}catch(n){if(!e.aborted)k(null);throw n}},X=()=>{if(l!==null)B(async(e)=>{await t.sessions.openChat(l),e.throwIfAborted()})},z=Ne||i?.error,Y=m?.completed||le&&(a?.state==="idle"||a?.state==="done"),F=E!==null&&!c&&!w&&!z&&Y&&E.reply?.messageId!==q.current?E.reply:null,Z=z?null:w?r("runState.requires_action"):c?r("petMode.thinking"):m?.completed?null:m?.accepted?r("petMode.sent"):null,be=m!==null,L=be||le,J=E?.userMessage??null,he=Y&&!c?null:(c||L)&&J!==null&&(m===null||J.timestamp>=m.startedAt)?J.text:be?m.text:null,j=!L&&!c&&!w,d=L&&Y&&!c&&!w&&!z,Re=F?.messageId,Ae=F?.text;ee(()=>{if(!d||V||l===null)return;let e=setTimeout(()=>{t.windows.call("dismiss-result",{binding:l}).catch(t.onError)},1e4);return()=>clearTimeout(e)},[d,V,M,S,Me,Re,Ae,t]);let we=w?320:d?260:c?240:320;ve(()=>{let e=de.current;if(e===null)return;let s=!1,n=()=>{let I=Math.ceil(e.getBoundingClientRect().height)+6;if(!s&&I>=32)t.windows.call("bubble-size",{width:we+se*2,height:I}).catch(t.onError)},x=new ResizeObserver(n);return x.observe(e),n(),()=>{s=!0,x.disconnect()}},[t,we,S]);let ge=a?r(a.windowLabel==="main"?"petMode.openMain":"petMode.openChat"):r("petMode.openFull");ve(()=>{if(y===""){R(!1);return}if(O||L||c)return;if(y.includes(`
2
- `)){R(!0);return}let e=ce.current;if(e===null)return;let s=()=>{let x=Math.ceil(Number.parseFloat(getComputedStyle(e).minHeight));if(e.scrollHeight>x)R(!0)};s();let n=new ResizeObserver(s);return n.observe(e),()=>n.disconnect()},[y,O,L,c]);let _e=j?Ge:"div";return v("div",{ref:de,"data-pet-bubble":!0,className:"relative pb-1.5",style:{paddingTop:se,paddingInline:se},onPointerEnter:()=>ie(!0),onPointerLeave:()=>ie(!1),children:[S!==null&&o(Ye,{cardRef:pe}),S!==null&&v("div",{ref:pe,"data-pet-bubble-card":!0,role:"presentation",onClick:(e)=>{if(d&&e.target.closest("button")===null)X()},style:{...Ze,position:"relative",background:"transparent",borderColor:"transparent",boxShadow:"none",animation:"none",maxHeight:(h??Ee)-6},className:ne("overflow-y-auto p-2",d?"grid cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 px-3":c?"flex flex-col gap-1 py-1.5":"flex flex-col gap-2"),children:[he&&o("p",{className:"line-clamp-2 text-sm break-words whitespace-pre-wrap",children:he}),F!==null&&o("p",{className:"line-clamp-2 text-sm break-words whitespace-pre-wrap",children:F.text}),z&&o("p",{role:"alert",className:"text-muted-foreground text-xs",children:z}),f!==null&&v("section",{"aria-label":r(f.kind==="permission"?"petMode.permission":"petMode.question"),className:"flex min-w-0 flex-col gap-2",children:[o("p",{className:"text-sm break-words whitespace-pre-wrap",children:f.title}),f.detail!==""&&o("pre",{className:"text-muted-foreground max-h-24 overflow-auto text-xs break-words whitespace-pre-wrap",children:f.detail}),f.options.length>0&&!Q?o("div",{className:"flex flex-wrap gap-1",children:f.options.map((e)=>o(te,{size:"xs",className:"h-auto min-h-6 max-w-full whitespace-normal",disabled:N||Ce===f.token,onClick:()=>void B((s)=>Le(f,e.id,s)),children:e.label},e.id))}):o(te,{size:"xs",onClick:X,children:r("petMode.openToAnswer")})]}),v(_e,{className:d?"col-start-1 row-start-2":void 0,children:[j&&o(qe,{ref:ce,rows:1,className:"field-sizing-fixed max-h-[calc(3lh+1rem)] min-h-[calc(1lh+1rem)] min-w-0 overflow-y-auto",style:{height:O?"calc(3lh + 1rem)":"calc(1lh + 1rem)"},value:y,placeholder:r("petMode.placeholder"),"aria-label":r("petMode.placeholder"),disabled:N||Q||!Se||M===null,onChange:(e)=>{T(),H(e.target.value)},onFocus:()=>{T(),Be().catch(K)},onCompositionStart:()=>{if(u.current!==null)cancelAnimationFrame(u.current);u.current=null,C.current=!1,A.current=!0},onCompositionEnd:()=>{if(A.current=!1,C.current=!0,u.current!==null)cancelAnimationFrame(u.current);u.current=requestAnimationFrame(()=>{C.current=!1,u.current=null})},onKeyDown:(e)=>{if(e.key!=="Enter"||e.shiftKey||A.current||e.nativeEvent.isComposing||C.current||e.nativeEvent.keyCode===229)return;if(e.preventDefault(),me)B(fe)}}),v(We,{align:"block-end",className:ne("shrink-0",(d||c)&&"gap-1 p-0"),children:[v("div",{className:ne("flex min-w-0 items-center gap-2",!d&&"flex-1"),children:[Z&&o("p",{role:"status",className:"text-muted-foreground text-xs",children:c&&!w?o("span",{className:"shimmer",children:Z}):Z}),j?v(P,{className:"min-w-0 flex-1 justify-start",title:r("petMode.chooseSession"),"aria-label":r("petMode.chooseSession"),"aria-haspopup":"menu",disabled:N||M===null,onClick:(e)=>{let s=e.currentTarget.getBoundingClientRect();ze({x:s.left,y:s.bottom}).catch(K)},children:[a&&o("span",{role:"img","aria-label":r(a.windowLabel==="main"?"navigation.mainWindow":"navigation.chatWindow"),"data-icon":"inline-start",className:"inline-flex shrink-0",children:o(ye,{name:a.windowLabel,icons:t.sessionIcons})}),o("span",{className:"min-w-0 flex-1 truncate text-start",title:a?[a.cwd,a.title||r("collection.defaultChatTitle")].filter(Boolean).join(" / "):"",children:a?$e(a,r("collection.defaultChatTitle")):""})]}):!c&&o(P,{size:"icon-xs",className:d?"size-5":void 0,title:r("petMode.continue"),"aria-label":r("petMode.continue"),disabled:N||w||m!==null&&!m.accepted,onClick:()=>{T(),k(null),D(!1)},children:o(Ue,{})})]}),j&&o(P,{size:"icon-xs",variant:"default",className:"size-5 shrink-0",title:r("petMode.send"),"aria-label":r("petMode.send"),disabled:!me,onClick:()=>void B(fe),children:o(Fe,{className:"size-3"})}),o(P,{size:"icon-xs",className:"size-5 shrink-0",title:ge,"aria-label":ge,disabled:M===null||!a,onClick:X,children:a&&t.sessionIcons?o(ye,{name:a.windowLabel,icons:t.sessionIcons}):o(Pe,{className:"size-4"})})]})]}),d&&o("span",{role:"img","aria-label":r("petMode.completed"),title:r("petMode.completed"),className:"col-start-2 row-span-2 row-start-1 inline-flex size-7 items-center justify-center rounded-full bg-[var(--vibemon-completed-background)] text-[var(--vibemon-completed-foreground)]",children:o(je,{className:"size-4"})})]}),V&&M!==null&&S!==null&&o(te,{variant:"outline",size:"icon-xs",className:"text-muted-foreground absolute top-1 left-1 cursor-pointer rounded-full",style:{width:oe,height:oe},title:r("close"),"aria-label":r("close"),onClick:()=>void t.windows.call("bubble-close").catch(t.onError),children:o(He,{className:"size-2.5"})})]})}export{mn as PetQuickReply};
1
+ import{jsx as o,jsxs as v}from"react/jsx-runtime";import{cn as ee}from"cn";import{ArrowUpIcon as Pe,CheckIcon as Ue,PanelsTopLeftIcon as He,PencilLineIcon as Oe,XIcon as De}from"lucide-react";import{useCallback as ve,useEffect as ne,useEffectEvent as Ve,useLayoutEffect as ye,useRef as b,useState as p}from"react";import{useTranslation as Ge}from"react-i18next";import{sameBinding as We,vibemonHost as qe}from"../../core/host.js";import{advancePetSubmission as Ke}from"../../core/lib/reply-submission.js";import{getVibemonScopeSync as Qe,useVibemonState as Xe}from"../lib/account-state.js";import{Button as te}from"../ui/button.js";import{InputGroup as Ye,InputGroupAddon as Ze,InputGroupButton as P,InputGroupTextarea as Je}from"../ui/input-group.js";import{PetBubbleBackground as $e}from"./pet-bubble-background.js";import{SessionIcon as ke}from"./session-icon.js";var oe=18,se=oe/2,en={color:"var(--popover-foreground)",borderRadius:16,border:"1px solid var(--border)"},nn=(h)=>h.split(/[\\/]/).findLast(Boolean)??"",tn=(h,t)=>[nn(h.cwd),h.title||t].filter(Boolean).join(" / ");function hn({maxHeight:h}){let t=qe(),U=Xe(),Ee=Qe(),[Ie,re]=p(320);ne(()=>{let e=!1;if(re(320),h===void 0&&U.pet!=="")t.assets.resources.inspect(U.pet).then((s)=>{if(e)return;let n=s?.config?.bubbleAreaHeight;if(n!==void 0&&(typeof n!=="number"||!Number.isFinite(n)))throw Error("Pet bubble height must be a finite number");re(Math.max(typeof n==="number"?n:0,320))}).catch(t.onError);return()=>{e=!0}},[t,Ee,U.pet,h]);let{t:r}=Ge("common"),[i,Ne]=p(()=>t.sessions.snapshot()),[y,H]=p(""),[O,R]=p(!1),[m,k]=p(null),[le,D]=p(!1),[V,ie]=p(!1),[Ce,G]=p(""),[N,W]=p(!1),[Me,ae]=p(null),ce=b(null),A=b(!1),C=b(!1),u=b(null),q=b(null),g=b(null),ue=b(i),de=b(null),pe=b(null),K=ve((e)=>G(e instanceof Error?e.message:String(e)),[]),l=i?.binding??null,a=i,E=i,M=l?.connectionEpoch??null,S=l?.sessionId??null,Se=l?.bindingRevision??-1,Te=i?.owner??"",Q=i?.access!=="writable"||i.executionId!==null,Be=i!==null,_=ve(()=>{if(g.current?.abort(),g.current=null,W(!1),ae(null),H(""),R(!1),k(null),D(!1),q.current=null,G(""),A.current=!1,C.current=!1,u.current!==null)cancelAnimationFrame(u.current);u.current=null},[]);ne(()=>{let e=(n)=>{let x=ue.current;if(x===null||n===null||!We(x.binding,n.binding))_();if(ue.current=n,n!==null){if(n.state==="running")D(!0);k((I)=>I===null?I:Ke(I,n.state,n.since))}Ne(n)},s=t.sessions.subscribe(e);return e(t.sessions.snapshot()),document.addEventListener("vibemon:dismiss",_),()=>{if(s(),document.removeEventListener("vibemon:dismiss",_),g.current?.abort(),u.current!==null)cancelAnimationFrame(u.current)}},[t,_]);let T=()=>{if(l!==null)t.windows.call("bubble-interact",{binding:l}).catch(t.onError)},B=async(e)=>{if(g.current!==null)return;let s=new AbortController;g.current=s,T(),W(!0),G("");try{await e(s.signal)}catch(n){if(!s.signal.aborted)K(n)}finally{if(g.current===s)g.current=null,W(!1)}},Le=()=>t.windows.call("focus"),ze=(e)=>{if(l===null||i===null)throw Error("Pet conversation unavailable");return T(),t.windows.call("session-menu",{binding:l,candidates:i.candidates,position:e,onSelect:(s)=>B(()=>t.sessions.select(l,s))})},c=i?.state==="running",w=i?.state==="requires_action"||i?.prompt!=null,f=i?.prompt??null,Re=async(e,s,n)=>{if(l===null)throw Error(r("petMode.openToReply"));if(await t.sessions.answer(l,crypto.randomUUID(),e.token,s),!n.aborted)ae(e.token)},me=!N&&!Q&&!c&&!w&&y.trim()!==""&&Be,fe=async(e)=>{if(l===null||E===null)throw Error(r("petMode.openToReply"));let s=y.trim();q.current=E.reply?.messageId??null,k({sessionId:l.sessionId,text:s,startedAt:Date.now(),accepted:!1,sawRunning:!1,completed:!1});try{if(await t.sessions.send(l,crypto.randomUUID(),s),e.aborted)return;k((n)=>n===null?null:{...n,accepted:!0}),H("")}catch(n){if(!e.aborted)k(null);throw n}},X=()=>{if(l!==null)B(async(e)=>{await t.sessions.openChat(l),e.throwIfAborted()})},L=Ce||i?.error,Y=m?.completed||le&&(a?.state==="idle"||a?.state==="done"),F=E!==null&&!c&&!w&&!L&&Y&&E.reply?.messageId!==q.current?E.reply:null,Z=L?null:w?r("runState.requires_action"):c?r("petMode.thinking"):m?.completed?null:m?.accepted?r("petMode.sent"):null,be=m!==null,z=be||le,J=E?.userMessage??null,he=Y&&!c?null:(c||z)&&J!==null&&(m===null||J.timestamp>=m.startedAt)?J.text:be?m.text:null,j=!z&&!c&&!w,d=z&&Y&&!c&&!w&&!L,Ae=F?.messageId,_e=F?.text,we=l!==null,Fe=Ve(()=>{if(l!==null)t.windows.call("dismiss-result",{binding:l}).catch(t.onError)});ne(()=>{if(!d||V||!we)return;let e=setTimeout(Fe,1e4);return()=>clearTimeout(e)},[d,V,we,M,S,Se,Ae,_e,t]);let ge=w?320:d?260:c?240:320;ye(()=>{let e=de.current;if(e===null)return;let s=!1,n=()=>{let I=Math.ceil(e.getBoundingClientRect().height)+6;if(!s&&I>=32)t.windows.call("bubble-size",{width:ge+se*2,height:I}).catch(t.onError)},x=new ResizeObserver(n);return x.observe(e),n(),()=>{s=!0,x.disconnect()}},[t,ge,S]);let xe=a?r(a.windowLabel==="main"?"petMode.openMain":"petMode.openChat"):r("petMode.openFull");ye(()=>{if(y===""){R(!1);return}if(O||z||c)return;if(y.includes(`
2
+ `)){R(!0);return}let e=ce.current;if(e===null)return;let s=()=>{let x=Math.ceil(Number.parseFloat(getComputedStyle(e).minHeight));if(e.scrollHeight>x)R(!0)};s();let n=new ResizeObserver(s);return n.observe(e),()=>n.disconnect()},[y,O,z,c]);let je=j?Ye:"div";return v("div",{ref:de,"data-pet-bubble":!0,className:"relative pb-1.5",style:{paddingTop:se,paddingInline:se},onPointerEnter:()=>ie(!0),onPointerLeave:()=>ie(!1),children:[S!==null&&o($e,{cardRef:pe}),S!==null&&v("div",{ref:pe,"data-pet-bubble-card":!0,role:"presentation",onClick:(e)=>{if(d&&e.target.closest("button")===null)X()},style:{...en,position:"relative",background:"transparent",borderColor:"transparent",boxShadow:"none",animation:"none",maxHeight:(h??Ie)-6},className:ee("overflow-y-auto p-2",d?"grid cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 px-3":c?"flex flex-col gap-1 py-1.5":"flex flex-col gap-2"),children:[he&&o("p",{className:"line-clamp-2 text-sm break-words whitespace-pre-wrap",children:he}),F!==null&&o("p",{className:"line-clamp-2 text-sm break-words whitespace-pre-wrap",children:F.text}),L&&o("p",{role:"alert",className:"text-muted-foreground text-xs",children:L}),f!==null&&v("section",{"aria-label":r(f.kind==="permission"?"petMode.permission":"petMode.question"),className:"flex min-w-0 flex-col gap-2",children:[o("p",{className:"text-sm break-words whitespace-pre-wrap",children:f.title}),f.detail!==""&&o("pre",{className:"text-muted-foreground max-h-24 overflow-auto text-xs break-words whitespace-pre-wrap",children:f.detail}),f.options.length>0&&!Q?o("div",{className:"flex flex-wrap gap-1",children:f.options.map((e)=>o(te,{size:"xs",className:"h-auto min-h-6 max-w-full whitespace-normal",disabled:N||Me===f.token,onClick:()=>void B((s)=>Re(f,e.id,s)),children:e.label},e.id))}):o(te,{size:"xs",onClick:X,children:r("petMode.openToAnswer")})]}),v(je,{className:d?"col-start-1 row-start-2":void 0,children:[j&&o(Je,{ref:ce,rows:1,className:"field-sizing-fixed max-h-[calc(3lh+1rem)] min-h-[calc(1lh+1rem)] min-w-0 overflow-y-auto",style:{height:O?"calc(3lh + 1rem)":"calc(1lh + 1rem)"},value:y,placeholder:r("petMode.placeholder"),"aria-label":r("petMode.placeholder"),disabled:N||Q||!Te||M===null,onChange:(e)=>{T(),H(e.target.value)},onFocus:()=>{T(),Le().catch(K)},onCompositionStart:()=>{if(u.current!==null)cancelAnimationFrame(u.current);u.current=null,C.current=!1,A.current=!0},onCompositionEnd:()=>{if(A.current=!1,C.current=!0,u.current!==null)cancelAnimationFrame(u.current);u.current=requestAnimationFrame(()=>{C.current=!1,u.current=null})},onKeyDown:(e)=>{if(e.key!=="Enter"||e.shiftKey||A.current||e.nativeEvent.isComposing||C.current||e.nativeEvent.keyCode===229)return;if(e.preventDefault(),me)B(fe)}}),v(Ze,{align:"block-end",className:ee("shrink-0",(d||c)&&"gap-1 p-0"),children:[v("div",{className:ee("flex min-w-0 items-center gap-2",!d&&"flex-1"),children:[Z&&o("p",{role:"status",className:"text-muted-foreground text-xs",children:c&&!w?o("span",{className:"shimmer",children:Z}):Z}),j?v(P,{className:"min-w-0 flex-1 justify-start",title:r("petMode.chooseSession"),"aria-label":r("petMode.chooseSession"),"aria-haspopup":"menu",disabled:N||M===null,onClick:(e)=>{let s=e.currentTarget.getBoundingClientRect();ze({x:s.left,y:s.bottom}).catch(K)},children:[a&&o("span",{role:"img","aria-label":r(a.windowLabel==="main"?"navigation.mainWindow":"navigation.chatWindow"),"data-icon":"inline-start",className:"inline-flex shrink-0",children:o(ke,{name:a.windowLabel,icons:t.sessionIcons})}),o("span",{className:"min-w-0 flex-1 truncate text-start",title:a?[a.cwd,a.title||r("collection.defaultChatTitle")].filter(Boolean).join(" / "):"",children:a?tn(a,r("collection.defaultChatTitle")):""})]}):!c&&o(P,{size:"icon-xs",className:d?"size-5":void 0,title:r("petMode.continue"),"aria-label":r("petMode.continue"),disabled:N||w||m!==null&&!m.accepted,onClick:()=>{T(),k(null),D(!1)},children:o(Oe,{})})]}),j&&o(P,{size:"icon-xs",variant:"default",className:"size-5 shrink-0",title:r("petMode.send"),"aria-label":r("petMode.send"),disabled:!me,onClick:()=>void B(fe),children:o(Pe,{className:"size-3"})}),o(P,{size:"icon-xs",className:"size-5 shrink-0",title:xe,"aria-label":xe,disabled:M===null||!a,onClick:X,children:a&&t.sessionIcons?o(ke,{name:a.windowLabel,icons:t.sessionIcons}):o(He,{className:"size-4"})})]})]}),d&&o("span",{role:"img","aria-label":r("petMode.completed"),title:r("petMode.completed"),className:"col-start-2 row-span-2 row-start-1 inline-flex size-7 items-center justify-center rounded-full bg-[var(--vibemon-completed-background)] text-[var(--vibemon-completed-foreground)]",children:o(Ue,{className:"size-4"})})]}),V&&M!==null&&S!==null&&o(te,{variant:"outline",size:"icon-xs",className:"text-muted-foreground absolute top-1 left-1 cursor-pointer rounded-full",style:{width:oe,height:oe},title:r("close"),"aria-label":r("close"),onClick:()=>void t.windows.call("bubble-close").catch(t.onError),children:o(De,{className:"size-2.5"})})]})}export{hn as PetQuickReply};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as a}from"react/jsx-runtime";import{singlePetToast as r}from"../assets.js";import{AnimatePresence as l,motion as c,useReducedMotion as u}from"motion/react";import{useEffect as d}from"react";import{Button as p}from"../ui/button.js";var m="This is your only pet. It’s equipped by default and can’t be unequipped ~",f=3000;function x({requestId:t,onClose:i}){let o=u(),n=t>0;return d(()=>{if(t===0)return;let s=window.setTimeout(i,f);return()=>window.clearTimeout(s)},[t,i]),e("div",{className:"pointer-events-none absolute bottom-[7.067%] left-1/2 z-30 h-[4.583cqw] w-[52.604cqw] -translate-x-1/2",children:e(l,{initial:!1,children:n&&a(c.div,{"data-testid":"single-pet-toast",className:"pointer-events-auto relative size-full",initial:{opacity:0,y:o?0:"100%"},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:"100%"},transition:o?{duration:0}:{duration:0.3,ease:[0.16,1,0.3,1]},children:[e("img",{src:r,alt:"","aria-hidden":!0,className:"absolute inset-0 size-full max-w-none select-none"}),e("span",{role:"status",className:"sr-only",children:m}),e(p,{"aria-label":"Close",onClick:i,className:"absolute top-1/4 right-[5.743%] aspect-square h-1/2 rounded-full border-0 bg-transparent p-0 shadow-none transition-none hover:bg-white/10 focus-visible:border-white focus-visible:ring-white/70 active:translate-y-0",children:e("span",{className:"sr-only",children:"Close"})})]})})})}export{f as SINGLE_PET_TOAST_DURATION_MS,m as SINGLE_PET_TOAST_MESSAGE,x as SinglePetToast};
1
+ import{jsx as e,jsxs as a}from"react/jsx-runtime";import{AnimatePresence as r,motion as l,useReducedMotion as c}from"motion/react";import{useEffect as u}from"react";import{singlePetToast as d}from"../assets.js";import{Button as p}from"../ui/button.js";var m="This is your only pet. It’s equipped by default and can’t be unequipped ~",f=3000;function x({requestId:t,onClose:i}){let o=c(),n=t>0;return u(()=>{if(t===0)return;let s=window.setTimeout(i,f);return()=>window.clearTimeout(s)},[t,i]),e("div",{className:"pointer-events-none absolute bottom-[7.067%] left-1/2 z-30 h-[4.583cqw] w-[52.604cqw] -translate-x-1/2",children:e(r,{initial:!1,children:n&&a(l.div,{"data-testid":"single-pet-toast",className:"pointer-events-auto relative size-full",initial:{opacity:0,y:o?0:"100%"},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:"100%"},transition:o?{duration:0}:{duration:0.3,ease:[0.16,1,0.3,1]},children:[e("img",{src:d,alt:"","aria-hidden":!0,className:"absolute inset-0 size-full max-w-none select-none"}),e("span",{role:"status",className:"sr-only",children:m}),e(p,{"aria-label":"Close",onClick:i,className:"absolute top-1/4 right-[5.743%] aspect-square h-1/2 rounded-full border-0 bg-transparent p-0 shadow-none transition-none hover:bg-white/10 focus-visible:border-white focus-visible:ring-white/70 active:translate-y-0",children:e("span",{className:"sr-only",children:"Close"})})]})})})}export{f as SINGLE_PET_TOAST_DURATION_MS,m as SINGLE_PET_TOAST_MESSAGE,x as SinglePetToast};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as s,Fragment as l}from"react/jsx-runtime";import{albumIcon as r,pullBack as m,pullVibemonIcon as i}from"../assets.js";import{useState as d}from"react";import{Button as u}from"../ui/button.js";import{openAccountUrl as p}from"../../core/lib/recharge.js";import{BackToHome as b}from"./back-to-home.js";import{GemBalance as f}from"./gem-balance.js";import{WishButton as g}from"./wish-button.js";function q({action:a}){let[n,o]=d(!1),t=a.kind==="album";return s(u,{"aria-label":t?"Album":"Vibémon",onClick:a.onClick,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),className:"relative size-[3.333cqw] bg-transparent p-0 shadow-none hover:bg-transparent",children:[e("img",{src:t?r:i,alt:"",className:"size-full object-contain transition-transform duration-150 select-none",style:{transform:n?"translateY(-2px) scale(1.05)":"none"}}),t&&a.hasUnseen&&e("span",{className:"absolute top-0 right-0 size-2 rounded-full bg-[#F74640]"})]})}function N({onBack:a,onWish:n,sectionAction:o,availablePoints:t,pointsLoaded:c}){return s(l,{children:[e(b,{onClick:a,label:"Back",iconSrc:m,className:"absolute top-[5.333%] left-[6.25%] z-30 gap-[0.729cqw] text-[#BCACE0] hover:text-[#BCACE0] [&_img]:size-[3.021cqw] [&_span]:text-[1.667cqw]"}),s("div",{className:"absolute top-[5%] right-[6.25%] z-30 flex h-[5.5cqh] items-center gap-[2.292cqw]",children:[e(q,{action:o}),e(g,{onClick:n,className:"size-[3.333cqw]"}),e(f,{amount:t,onAdd:p,loaded:c,className:"h-[5.5cqh] min-w-0 rounded-[7.813cqw] py-0 pr-[0.417cqw] pl-[0.729cqw] [&_[data-slot=gem-balance-add-icon]]:size-[2.5cqw] [&>[data-slot=gem-balance-add]]:ms-[1.094cqw] [&>[data-slot=gem-balance-add]]:size-[2.5cqw] [&>[data-slot=gem-balance-amount]]:text-[1.563cqw] [&>[data-slot=gem-balance-icon]]:me-[0.156cqw] [&>[data-slot=gem-balance-icon]]:size-[2.5cqw]"})]})]})}export{N as VibemonHeader};
1
+ import{jsx as e,jsxs as s,Fragment as l}from"react/jsx-runtime";import{useState as r}from"react";import{openAccountUrl as m}from"../../core/lib/recharge.js";import{albumIcon as i,pullBack as d,pullVibemonIcon as u}from"../assets.js";import{Button as p}from"../ui/button.js";import{BackToHome as b}from"./back-to-home.js";import{GemBalance as f}from"./gem-balance.js";import{WishButton as g}from"./wish-button.js";function q({action:a}){let[n,o]=r(!1),t=a.kind==="album";return s(p,{"aria-label":t?"Album":"Vibémon",onClick:a.onClick,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),className:"relative size-[3.333cqw] bg-transparent p-0 shadow-none hover:bg-transparent",children:[e("img",{src:t?i:u,alt:"",className:"size-full object-contain transition-transform duration-150 select-none",style:{transform:n?"translateY(-2px) scale(1.05)":"none"}}),t&&a.hasUnseen&&e("span",{className:"absolute top-0 right-0 size-2 rounded-full bg-[#F74640]"})]})}function N({onBack:a,onWish:n,sectionAction:o,availablePoints:t,pointsLoaded:c}){return s(l,{children:[e(b,{onClick:a,label:"Back",iconSrc:d,className:"absolute top-[5.333%] left-[6.25%] z-30 gap-[0.729cqw] text-[#BCACE0] hover:text-[#BCACE0] [&_img]:size-[3.021cqw] [&_span]:text-[1.667cqw]"}),s("div",{className:"absolute top-[5%] right-[6.25%] z-30 flex h-[5.5cqh] items-center gap-[2.292cqw]",children:[e(q,{action:o}),e(g,{onClick:n,className:"size-[3.333cqw]"}),e(f,{amount:t,onAdd:m,loaded:c,className:"h-[5.5cqh] min-w-0 rounded-[7.813cqw] py-0 pr-[0.417cqw] pl-[0.729cqw] [&_[data-slot=gem-balance-add-icon]]:size-[2.5cqw] [&>[data-slot=gem-balance-add]]:ms-[1.094cqw] [&>[data-slot=gem-balance-add]]:size-[2.5cqw] [&>[data-slot=gem-balance-amount]]:text-[1.563cqw] [&>[data-slot=gem-balance-icon]]:me-[0.156cqw] [&>[data-slot=gem-balance-icon]]:size-[2.5cqw]"})]})]})}export{N as VibemonHeader};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as M}from"react/jsx-runtime";import{gem as De,gemPlus as Ce,guideArrow as He,guideHand as Ne,guideHandShape as ke,guideHandSheen as Ue,guideHomeTexture as Oe,guideMascot as he,guidePullTexture as Ge,guideRing as qe,homeBackground as Fe,homeHotspotAssets as c,pullAlbumIcon as Me,pullBack as Be,pullGem as Te,pullPageBackground as je,pullTexture as $e,pullVibemonIcon as We}from"../assets.js";import{Loader2 as ze}from"lucide-react";import{useCallback as P,useEffect as h,useRef as S,useState as n}from"react";import{useTranslation as Je}from"react-i18next";import{toast as Ke}from"sonner";import{equipVibemonAfterDraw as Qe,getVibemonScopeSync as A}from"../lib/account-state.js";import{cardThumb as me}from"../lib/card-image.js";import{createDrawReward as Xe}from"../../core/lib/draw-result.js";import{gachaPoolImageUrls as Ye,loadGachaPoolCatalog as Ze}from"../../core/lib/gacha-pools.js";import{preloadImages as fe}from"../../core/lib/preload-images.js";import{syncVibemonResources as eo}from"../lib/resource-sync.js";import{getSetting as pe,getSettingSync as E,setSetting as be}from"../../core/lib/settings.js";import{drawGachaPool as oo,getGachaFirstDraw as no,getMyVibemons as to,getPointAccount as we,markVibemonFirstVisit as ro}from"../../core/lib/endpoints.js";import{consumePendingVibemonView as io,onVibemonViewRequest as ao}from"../../core/lib/view-request.js";import{AlbumView as so}from"./album-view.js";import{EquipView as lo}from"./equip-view.js";import{HomeView as co}from"./home-view.js";import{INTRO_VIDEO_URL as uo,IntroOverlay as mo}from"./intro-overlay.js";import{VibemonLoadingView as fo}from"./loading-view.js";import{PullOverlay as po}from"./pull-overlay.js";import{PullView as wo}from"./pull-view.js";var go=30000,B=[Fe,c.vibemon.icon,c.vibemon.hover,c.vibemon.text,c.wish.icon,c.wish.hover,c.wish.text,c.album.icon,c.album.hover,c.album.text,He,Oe,he],ge=[je,Be,We,Me,$e,Te,De,Ce,Ge,Ne,ke,Ue,he,qe],T=(r)=>{let i=A();return!!(i&&r[i])},j=(r,i)=>{let s=A();if(!s)return;be(r,{...E(r),[s]:i})},W=(r)=>{let i=A();if(!i)return null;return r[i]??null},ho=(r)=>{let i=A();if(!i)return;be("vibemon.onboardingStep",{...E("vibemon.onboardingStep"),[i]:r})};function Mo(){return t("div",{className:"contents",onContextMenu:(r)=>r.preventDefault(),children:t(bo,{})})}function bo(){let{t:r}=Je("vibemon"),[i,s]=n(()=>{let e=W(E("vibemon.onboardingStep"));return e==="free-draw"||e==="view-album"?"pull":"home"}),[I,u]=n("idle"),[f,ve]=n(()=>W(E("vibemon.onboardingStep"))),[p,z]=n(!1),[_,D]=n(!1),[b,Pe]=n([]),[Se,J]=n(null),[R,Ee]=n(!1),[C,K]=n(0),[H,Q]=n(!1),[Ie,Re]=n([]),[Ve,X]=n(!1),[N,ye]=n(null),[V,Y]=n(null),[Z,ee]=n({done:0,total:ge.length}),[Le,xe]=n(!1),[m,v]=n(()=>T(E("vibemon.introSeen"))?"loading":"resolving-intro"),[oe,Ae]=n({done:0,total:B.length}),[ne,_e]=n(null),te=S(!1),y=P((e)=>{ve(e),ho(e)},[]),l=P(()=>s("pull"),[]);h(()=>{if(m!=="loading"||te.current)return;te.current=!0,fe(B,(e)=>{Ae({done:e,total:B.length})}).catch((e)=>{let o=e instanceof Error?e:Error(String(e));_e(o)})},[m]);let re=S(0),ie=S(!1),k=S(!1),w=P(async()=>{let e=++re.current;try{let o=await to();if(e===re.current)Pe(o),Ee(!0),J(null)}catch(o){J(o instanceof Error?o:Error(String(o))),console.warn("[vibemon] getMyVibemons failed",o)}},[]),ae=S(!1),se=S(!1),U=P(async()=>{try{let e=await Ze();ye(e),Y(null);let o=[...new Set([...ge,...Ye(e)])],a=!ae.current;if(a)ee({done:0,total:o.length});if(await fe(o,(L)=>{if(a)ee({done:L,total:o.length})}),a)ae.current=!0,xe(!0)}catch(e){let o=e instanceof Error?e:Error(String(e));console.error("[vibemon] loadGachaPoolCatalog failed",o),Y(o)}},[]);h(()=>{if(m!=="loading"||se.current)return;se.current=!0,U()},[m,U]),h(()=>{let e=()=>{we().then((a)=>{K(a.available_points),Q(!0)}).catch((a)=>console.warn("[vibemon] getPointAccount failed",a))};e();let o=setInterval(e,go);return window.addEventListener("focus",e),()=>{clearInterval(o),window.removeEventListener("focus",e)}},[]),h(()=>{for(let e of b)new Image().src=me(e.gacha_url??e.cover_url)},[b]);let O=()=>{if(_)j("vibemon.albumHasUnseen",!1),D(!1);w(),s("album")},g=P(()=>{w(),s("equip")},[w]);h(()=>{if(ie.current)return;ie.current=!0,w(),Promise.all([no().catch((e)=>(console.warn("[vibemon] getGachaFirstDraw failed",e),{first_draw:!1})),pe("vibemon.albumHasUnseen")]).then(([e,o])=>{if(z(e.first_draw),D(T(o)),!e.first_draw)return;if(W(E("vibemon.onboardingStep"))==="free-draw"){l();return}y("home-wish"),s("home")}),pe("vibemon.introSeen").then((e)=>{if(T(e)){v("loading");return}return ro().then(({first_visit:o})=>{if(j("vibemon.introSeen",!0),o)s("home"),u("intro"),v("intro");else v("loading")})}).catch((e)=>{console.warn("[vibemon] first-visit check failed",e),v("loading")})},[l,w,y]);let[le,de]=n(!1),G=P((e)=>{if(p&&f==="home-wish")return;if(p&&f==="free-draw"){l();return}if(e==="pull")l();else if(e==="equip")g();else de(!0)},[p,f,g,l]);if(h(()=>{let e=io();if(e)G(e);return ao(G)},[G]),h(()=>{if(!le||!R)return;if(de(!1),b.length===0)l();else g()},[le,R,b.length,g,l]),Se!==null)return M("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-3 bg-background p-6 text-foreground",children:[t("p",{children:r("offline.title")}),t("p",{className:"text-sm text-muted-foreground",children:r("offline.description")}),t("button",{type:"button",className:"rounded-md border px-4 py-2",onClick:()=>void w(),children:r("offline.retry")})]});if(m==="resolving-intro")return M("div",{className:"relative flex h-full w-full items-center justify-center overflow-hidden bg-[#120E18]",children:[t("video",{src:uo,preload:"auto",muted:!0,playsInline:!0,"aria-hidden":!0,className:"pointer-events-none absolute top-0 left-0 h-px w-px opacity-0"}),t(ze,{className:"size-10 animate-spin text-white"})]});if(m==="intro")return t("div",{className:"relative h-full w-full overflow-hidden bg-[#120E18]",children:t(mo,{onVideoStart:()=>u("intro"),onDone:()=>{u("idle"),v("loading")}})});if(ne!==null)throw ne;if(m==="loading"&&V!==null)throw V;if(m==="loading"){let e=oe.done+Z.done+(N===null?0:1)+(Le?1:0),o=oe.total+Z.total+2;return t("div",{className:"relative h-full w-full overflow-hidden",children:t(fo,{progress:e/o,onFinished:()=>v("ready")})})}if(i==="home")return t(co,{onDraw:()=>{if(f==="home-wish")y("free-draw");l()},onBackpack:O,onEquip:g,guideActive:p&&f==="home-wish"});if(i==="equip")return t(lo,{onBack:()=>s("home"),onWish:l,onAlbum:O,albumHasUnseen:_,ownedCards:b,ownedLoaded:R,availablePoints:C,pointsLoaded:H});if(i==="album")return t(so,{onBack:()=>s("home"),onWish:l,onEquip:g,ownedCards:b,ownedLoaded:R,availablePoints:C,pointsLoaded:H});if(V!==null)throw V;if(N===null)throw Error("[vibemon] app entered ready state without a gacha pool catalog");let ce=async(e,o)=>{if(k.current||I!=="idle")return;k.current=!0,X(!0);try{let a;try{a=await oo(e,o)}catch(d){console.warn("[vibemon] drawGachaPool failed",d),Ke.error(r("draw.failedNetwork"));return}let L=o==="SINGLE"?1:10;if(a.results.length!==L)throw Error(`[vibemon] ${o} draw response must contain ${L} results, received ${a.results.length}`);let ue=a.results.map(Xe),q=[];for(let[d,F]of a.results.entries()){if(F.reward_type==="WHITE_CARD")continue;q.push(F);let x=ue[d];if(x===void 0||x.kind!=="card")throw Error(`[vibemon] draw result ${F.draw_index} was not mapped to a Vibemon card`);new Image().src=me(o==="SINGLE"?x.singleImageUrl:x.multiImageUrl)}if(Re(ue),z(!1),f==="free-draw")y("view-album");if(u("video-waiting"),q.length>0){let d=q[0];if(d===void 0)throw Error("[vibemon] draw result lost its first Vibemon item");eo(),Qe(d.vibemon_uuid,p),w()}U(),we().then((d)=>{K(d.available_points),Q(!0)}).catch((d)=>console.warn("[vibemon] getPointAccount failed",d))}finally{k.current=!1,X(!1)}};return M("div",{className:"relative h-full w-full",children:[t(wo,{onBack:()=>s("home"),onAlbum:O,onEquip:g,isFirstDraw:p,availablePoints:C,pointsLoaded:H,onSingleDraw:(e)=>void ce(e,"SINGLE"),onMultiDraw:(e)=>void ce(e,"MULTI"),drawDisabled:Ve||I!=="idle",albumHasUnseen:_,guideActive:p&&f==="free-draw",poolCatalog:N}),I!=="intro"&&t(po,{phase:I,drawnRewards:Ie,onVideoStarted:()=>u("video-playing"),onPullDone:()=>u("result"),onPullFailed:()=>u("result"),onResultConfirmed:(e)=>{if(e)j("vibemon.albumHasUnseen",!0),D(!0);u("idle")}})]})}export{Mo as VibemonPage};
1
+ import{jsx as n,jsxs as M}from"react/jsx-runtime";import{Loader2 as De}from"lucide-react";import{useCallback as P,useEffect as h,useRef as S,useState as t}from"react";import{useTranslation as Ce}from"react-i18next";import{toast as He}from"sonner";import{createDrawReward as Ne}from"../../core/lib/draw-result.js";import{drawGachaPool as ke,getGachaFirstDraw as Ue,getMyVibemons as Oe,getPointAccount as me,markVibemonFirstVisit as Ge}from"../../core/lib/endpoints.js";import{gachaPoolImageUrls as qe,loadGachaPoolCatalog as Fe}from"../../core/lib/gacha-pools.js";import{preloadImages as fe}from"../../core/lib/preload-images.js";import{getSetting as pe,getSettingSync as E,setSetting as he}from"../../core/lib/settings.js";import{consumePendingVibemonView as Me,onVibemonViewRequest as Be}from"../../core/lib/view-request.js";import{gem as Te,gemPlus as je,guideArrow as $e,guideHand as We,guideHandShape as ze,guideHandSheen as Je,guideHomeTexture as Ke,guideMascot as be,guidePullTexture as Qe,guideRing as Xe,homeBackground as Ye,homeHotspotAssets as c,pullAlbumIcon as Ze,pullBack as eo,pullGem as oo,pullPageBackground as to,pullTexture as no,pullVibemonIcon as ro}from"../assets.js";import{equipVibemonAfterDraw as io,getVibemonScopeSync as x}from"../lib/account-state.js";import{cardThumb as we}from"../lib/card-image.js";import{syncVibemonResources as ao}from"../lib/resource-sync.js";import{AlbumView as so}from"./album-view.js";import{EquipView as lo}from"./equip-view.js";import{HomeView as co}from"./home-view.js";import{INTRO_VIDEO_URL as uo,IntroOverlay as mo}from"./intro-overlay.js";import{VibemonLoadingView as fo}from"./loading-view.js";import{PullOverlay as po}from"./pull-overlay.js";import{PullView as wo}from"./pull-view.js";var go=30000,B=[Ye,c.vibemon.icon,c.vibemon.hover,c.vibemon.text,c.wish.icon,c.wish.hover,c.wish.text,c.album.icon,c.album.hover,c.album.text,$e,Ke,be],ge=[to,eo,ro,Ze,no,oo,Te,je,Qe,We,ze,Je,be,Xe],T=(r)=>{let i=x();return!!(i&&r[i])},j=(r,i)=>{let s=x();if(!s)return;he(r,{...E(r),[s]:i})},W=(r)=>{let i=x();if(!i)return null;return r[i]??null},ho=(r)=>{let i=x();if(!i)return;he("vibemon.onboardingStep",{...E("vibemon.onboardingStep"),[i]:r})};function Mo(){return n("div",{className:"contents",onContextMenu:(r)=>r.preventDefault(),children:n(bo,{})})}function bo(){let{t:r}=Ce("vibemon"),[i,s]=t(()=>{let e=W(E("vibemon.onboardingStep"));return e==="free-draw"||e==="view-album"?"pull":"home"}),[I,u]=t("idle"),[f,ve]=t(()=>W(E("vibemon.onboardingStep"))),[p,z]=t(!1),[A,_]=t(!1),[b,Pe]=t([]),[Se,J]=t(null),[R,Ee]=t(!1),[D,K]=t(0),[C,Q]=t(!1),[Ie,Re]=t([]),[Ve,X]=t(!1),[H,ye]=t(null),[V,Y]=t(null),[Z,ee]=t({done:0,total:ge.length}),[Le,xe]=t(!1),[m,v]=t(()=>T(E("vibemon.introSeen"))?"loading":"resolving-intro"),[oe,Ae]=t({done:0,total:B.length}),[te,_e]=t(null),ne=S(!1),y=P((e)=>{ve(e),ho(e)},[]),l=P(()=>s("pull"),[]);h(()=>{if(m!=="loading"||ne.current)return;ne.current=!0,fe(B,(e)=>{Ae({done:e,total:B.length})}).catch((e)=>{let o=e instanceof Error?e:Error(String(e));_e(o)})},[m]);let re=S(0),ie=S(!1),N=S(!1),w=P(async()=>{let e=++re.current;try{let o=await Oe();if(e===re.current)Pe(o),Ee(!0),J(null)}catch(o){J(o instanceof Error?o:Error(String(o))),console.warn("[vibemon] getMyVibemons failed",o)}},[]),ae=S(!1),se=S(!1),k=P(async()=>{try{let e=await Fe();ye(e),Y(null);let o=[...new Set([...ge,...qe(e)])],a=!ae.current;if(a)ee({done:0,total:o.length});if(await fe(o,(L)=>{if(a)ee({done:L,total:o.length})}),a)ae.current=!0,xe(!0)}catch(e){let o=e instanceof Error?e:Error(String(e));console.error("[vibemon] loadGachaPoolCatalog failed",o),Y(o)}},[]);h(()=>{if(m!=="loading"||se.current)return;se.current=!0,k()},[m,k]),h(()=>{let e=()=>{me().then((a)=>{K(a.available_points),Q(!0)}).catch((a)=>console.warn("[vibemon] getPointAccount failed",a))};e();let o=setInterval(e,go);return window.addEventListener("focus",e),()=>{clearInterval(o),window.removeEventListener("focus",e)}},[]),h(()=>{for(let e of b)new Image().src=we(e.gacha_url??e.cover_url)},[b]);let U=()=>{if(A)j("vibemon.albumHasUnseen",!1),_(!1);w(),s("album")},g=P(()=>{w(),s("equip")},[w]);h(()=>{if(ie.current)return;ie.current=!0,w(),Promise.all([Ue().catch((e)=>(console.warn("[vibemon] getGachaFirstDraw failed",e),{first_draw:!1})),pe("vibemon.albumHasUnseen")]).then(([e,o])=>{if(z(e.first_draw),_(T(o)),!e.first_draw)return;if(W(E("vibemon.onboardingStep"))==="free-draw"){l();return}y("home-wish"),s("home")}),pe("vibemon.introSeen").then((e)=>{if(T(e)){v("loading");return}return Ge().then(({first_visit:o})=>{if(j("vibemon.introSeen",!0),o)s("home"),u("intro"),v("intro");else v("loading")})}).catch((e)=>{console.warn("[vibemon] first-visit check failed",e),v("loading")})},[l,w,y]);let[le,de]=t(!1),O=P((e)=>{if(p&&f==="home-wish")return;if(p&&f==="free-draw"){l();return}if(e==="pull")l();else if(e==="equip")g();else de(!0)},[p,f,g,l]);if(h(()=>{let e=Me();if(e)O(e);return Be(O)},[O]),h(()=>{if(!le||!R)return;if(de(!1),b.length===0)l();else g()},[le,R,b.length,g,l]),Se!==null)return M("div",{role:"alert",className:"bg-background text-foreground flex h-full flex-col items-center justify-center gap-3 p-6",children:[n("p",{children:r("offline.title")}),n("p",{className:"text-muted-foreground text-sm",children:r("offline.description")}),n("button",{type:"button",className:"rounded-md border px-4 py-2",onClick:()=>void w(),children:r("offline.retry")})]});if(m==="resolving-intro")return M("div",{className:"relative flex h-full w-full items-center justify-center overflow-hidden bg-[#120E18]",children:[n("video",{src:uo,preload:"auto",muted:!0,playsInline:!0,"aria-hidden":!0,className:"pointer-events-none absolute top-0 left-0 h-px w-px opacity-0"}),n(De,{className:"size-10 animate-spin text-white"})]});if(m==="intro")return n("div",{className:"relative h-full w-full overflow-hidden bg-[#120E18]",children:n(mo,{onVideoStart:()=>u("intro"),onDone:()=>{u("idle"),v("loading")}})});if(te!==null)throw te;if(m==="loading"&&V!==null)throw V;if(m==="loading"){let e=oe.done+Z.done+(H===null?0:1)+(Le?1:0),o=oe.total+Z.total+2;return n("div",{className:"relative h-full w-full overflow-hidden",children:n(fo,{progress:e/o,onFinished:()=>v("ready")})})}if(i==="home")return n(co,{onDraw:()=>{if(f==="home-wish")y("free-draw");l()},onBackpack:U,onEquip:g,guideActive:p&&f==="home-wish"});if(i==="equip")return n(lo,{onBack:()=>s("home"),onWish:l,onAlbum:U,albumHasUnseen:A,ownedCards:b,ownedLoaded:R,availablePoints:D,pointsLoaded:C});if(i==="album")return n(so,{onBack:()=>s("home"),onWish:l,onEquip:g,ownedCards:b,ownedLoaded:R,availablePoints:D,pointsLoaded:C});if(V!==null)throw V;if(H===null)throw Error("[vibemon] app entered ready state without a gacha pool catalog");let ce=async(e,o)=>{if(N.current||I!=="idle")return;N.current=!0,X(!0);try{let a;try{a=await ke(e,o)}catch(d){console.warn("[vibemon] drawGachaPool failed",d),He.error(r("draw.failedNetwork"));return}let L=o==="SINGLE"?1:10;if(a.results.length!==L)throw Error(`[vibemon] ${o} draw response must contain ${L} results, received ${a.results.length}`);let ue=a.results.map(Ne),G=[];for(let[d,q]of a.results.entries()){if(q.reward_type==="WHITE_CARD")continue;G.push(q);let F=ue[d];if(F?.kind!=="card")throw Error(`[vibemon] draw result ${q.draw_index} was not mapped to a Vibemon card`);new Image().src=we(o==="SINGLE"?F.singleImageUrl:F.multiImageUrl)}if(Re(ue),z(!1),f==="free-draw")y("view-album");if(u("video-waiting"),G.length>0){let d=G[0];if(d===void 0)throw Error("[vibemon] draw result lost its first Vibemon item");ao(),io(d.vibemon_uuid,p),w()}k(),me().then((d)=>{K(d.available_points),Q(!0)}).catch((d)=>console.warn("[vibemon] getPointAccount failed",d))}finally{N.current=!1,X(!1)}};return M("div",{className:"relative h-full w-full",children:[n(wo,{onBack:()=>s("home"),onAlbum:U,onEquip:g,isFirstDraw:p,availablePoints:D,pointsLoaded:C,onSingleDraw:(e)=>void ce(e,"SINGLE"),onMultiDraw:(e)=>void ce(e,"MULTI"),drawDisabled:Ve||I!=="idle",albumHasUnseen:A,guideActive:p&&f==="free-draw",poolCatalog:H}),I!=="intro"&&n(po,{phase:I,drawnRewards:Ie,onVideoStarted:()=>u("video-playing"),onPullDone:()=>u("result"),onPullFailed:()=>u("result"),onResultConfirmed:(e)=>{if(e)j("vibemon.albumHasUnseen",!0),_(!0);u("idle")}})]})}export{Mo as VibemonPage};
@@ -14,10 +14,7 @@ type VideoFaderProps = {
14
14
  sources?: never;
15
15
  } | {
16
16
  src?: never;
17
- sources: readonly [
18
- VideoSource,
19
- ...VideoSource[]
20
- ];
17
+ sources: readonly [VideoSource, ...VideoSource[]];
21
18
  });
22
19
  export declare function VideoFader({ src, sources, playing, active, background, onFirstFrame, onComplete, onError }: VideoFaderProps): import("react").JSX.Element;
23
20
  export {};
@@ -1 +1 @@
1
- import{jsx as h,jsxs as q}from"react/jsx-runtime";import{useLayoutEffect as D,useRef as t,useState as M}from"react";var z=1,G=100,H=1000;function P({src:i,sources:l,playing:R=!0,active:a=!0,background:k,onFirstFrame:A,onComplete:L,onError:F}){let m=t(null),_=t(null),c=t(0),p=t(!1),I=t(i===void 0?{sources:l}:{src:i});I.current=i===void 0?{sources:l}:{src:i};let[C,y]=M(0),[O,v]=M(!1),n=i===void 0?l.map((e)=>`${e.type}:${e.src}`).join("|"):i,w=t(n),N=t(L),S=t(A),j=t(F);return N.current=L,S.current=A,j.current=F,D(()=>{let e=m.current;if(e===null)throw Error("Video player is not mounted");if(!a)return;if(p.current=!1,w.current!==n)c.current=0;w.current=n;let o=I.current;if("src"in o)e.src=o.src;else{let u=e.querySelectorAll("source");o.sources.forEach((r,d)=>{u[d].setAttribute("src",r.src)})}e.defaultMuted=!0,e.muted=!0;let s=()=>{p.current=!0};return e.addEventListener("error",s),e.load(),()=>{c.current=e.currentTime,e.removeEventListener("error",s),e.pause(),e.removeAttribute("src");for(let u of e.querySelectorAll("source"))u.removeAttribute("src");e.load()}},[n,a]),D(()=>{let e=m.current,o=_.current;if(e===null||o===null)throw Error("Video player is not mounted");if(o.style.opacity="0",y(0),v(!1),!R){if(c.current=0,a)e.pause(),e.currentTime=0;return}if(!a)return;e.currentTime=c.current;let s=!1,u=!1,r=!1,d=!1,E=null,T=null,b=null,V=()=>{if(u||!e.duration)return;if(e.duration-e.currentTime<z)u=!0,y(1)},x=()=>{if(r)return;T=setTimeout(()=>{v(!0),y(0),b=setTimeout(()=>{if(r)return;r=!0,N.current()},H)},G)},f=()=>{if(s||r)return;r=!0,v(!0),j.current()};if(E=e.requestVideoFrameCallback(()=>{if(s||r||d||e.dataset.sourceKey!==n)return;d=!0,o.style.opacity="1",S.current()}),e.addEventListener("timeupdate",V),e.addEventListener("ended",x),e.addEventListener("error",f),p.current)f();else e.play().catch(f);return()=>{if(s=!0,e.removeEventListener("timeupdate",V),e.removeEventListener("ended",x),e.removeEventListener("error",f),E!==null)e.cancelVideoFrameCallback(E);if(T)clearTimeout(T);if(b)clearTimeout(b)}},[n,R,a]),q("div",{ref:_,"data-video-presentation":!0,className:"pointer-events-none absolute inset-0 z-20",style:{opacity:0,background:k},children:[h("video",{ref:m,"data-source-key":n,preload:"auto",muted:!0,playsInline:!0,className:"absolute inset-0 z-20 h-full w-full object-cover",style:{visibility:O?"hidden":"visible"},children:l===void 0?null:l.map((e)=>h("source",{type:e.type},`${e.type}:${e.src}`))}),h("div",{className:"pointer-events-none absolute inset-0 z-20 bg-white transition-opacity duration-1000 ease-in",style:{opacity:C}})]})}export{P as VideoFader};
1
+ import{jsx as h,jsxs as q}from"react/jsx-runtime";import{useLayoutEffect as D,useRef as t,useState as M}from"react";var z=1,G=100,H=1000;function P({src:u,sources:l,playing:R=!0,active:a=!0,background:k,onFirstFrame:A,onComplete:L,onError:F}){let m=t(null),_=t(null),c=t(0),p=t(!1),I=t(u===void 0?{sources:l}:{src:u});I.current=u===void 0?{sources:l}:{src:u};let[C,y]=M(0),[O,v]=M(!1),n=u??l.map((e)=>`${e.type}:${e.src}`).join("|"),w=t(n),N=t(L),S=t(A),j=t(F);return N.current=L,S.current=A,j.current=F,D(()=>{let e=m.current;if(e===null)throw Error("Video player is not mounted");if(!a)return;if(p.current=!1,w.current!==n)c.current=0;w.current=n;let o=I.current;if("src"in o)e.src=o.src;else{let s=e.querySelectorAll("source");o.sources.forEach((r,d)=>{s[d].setAttribute("src",r.src)})}e.defaultMuted=!0,e.muted=!0;let i=()=>{p.current=!0};return e.addEventListener("error",i),e.load(),()=>{c.current=e.currentTime,e.removeEventListener("error",i),e.pause(),e.removeAttribute("src");for(let s of e.querySelectorAll("source"))s.removeAttribute("src");e.load()}},[n,a]),D(()=>{let e=m.current,o=_.current;if(e===null||o===null)throw Error("Video player is not mounted");if(o.style.opacity="0",y(0),v(!1),!R){if(c.current=0,a)e.pause(),e.currentTime=0;return}if(!a)return;e.currentTime=c.current;let i=!1,s=!1,r=!1,d=!1,E=null,T=null,b=null,V=()=>{if(s||!e.duration)return;if(e.duration-e.currentTime<z)s=!0,y(1)},x=()=>{if(r)return;T=setTimeout(()=>{v(!0),y(0),b=setTimeout(()=>{if(r)return;r=!0,N.current()},H)},G)},f=()=>{if(i||r)return;r=!0,v(!0),j.current()};if(E=e.requestVideoFrameCallback(()=>{if(i||r||d||e.dataset.sourceKey!==n)return;d=!0,o.style.opacity="1",S.current()}),e.addEventListener("timeupdate",V),e.addEventListener("ended",x),e.addEventListener("error",f),p.current)f();else e.play().catch(f);return()=>{if(i=!0,e.removeEventListener("timeupdate",V),e.removeEventListener("ended",x),e.removeEventListener("error",f),E!==null)e.cancelVideoFrameCallback(E);if(T)clearTimeout(T);if(b)clearTimeout(b)}},[n,R,a]),q("div",{ref:_,"data-video-presentation":!0,className:"pointer-events-none absolute inset-0 z-20",style:{opacity:0,background:k},children:[h("video",{ref:m,"data-source-key":n,preload:"auto",muted:!0,playsInline:!0,className:"absolute inset-0 z-20 h-full w-full object-cover",style:{visibility:O?"hidden":"visible"},children:l===void 0?null:l.map((e)=>h("source",{type:e.type},`${e.type}:${e.src}`))}),h("div",{className:"pointer-events-none absolute inset-0 z-20 bg-white transition-opacity duration-1000 ease-in",style:{opacity:C}})]})}export{P as VideoFader};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as a}from"react/jsx-runtime";import{newTag as r,wishDefault as i,wishHover as l}from"../assets.js";import{useState as m}from"react";import{Button as c}from"../ui/button.js";import{cn as p}from"../lib/utils.js";function w({onClick:o,className:s}){let[n,e]=m(!1);return a(c,{"aria-label":"Wish",variant:"ghost",className:p("relative size-[64px] p-0 hover:bg-transparent",s),onClick:o,onMouseEnter:()=>e(!0),onMouseLeave:()=>e(!1),children:[t("img",{src:n?l:i,alt:"",className:"absolute top-[5.439%] left-[4.863%] h-[89.122%] w-[90.27%] max-w-none object-contain select-none"}),t("img",{src:r,alt:"",className:"pointer-events-none absolute top-[4.422%] left-[50.578%] h-[26.03%] w-[49.428%] max-w-none select-none"})]})}export{w as WishButton};
1
+ import{jsx as t,jsxs as a}from"react/jsx-runtime";import{useState as r}from"react";import{newTag as i,wishDefault as l,wishHover as m}from"../assets.js";import{cn as c}from"../lib/utils.js";import{Button as p}from"../ui/button.js";function w({onClick:o,className:s}){let[n,e]=r(!1);return a(p,{"aria-label":"Wish",variant:"ghost",className:c("relative size-[64px] p-0 hover:bg-transparent",s),onClick:o,onMouseEnter:()=>e(!0),onMouseLeave:()=>e(!1),children:[t("img",{src:n?m:l,alt:"",className:"absolute top-[5.439%] left-[4.863%] h-[89.122%] w-[90.27%] max-w-none object-contain select-none"}),t("img",{src:i,alt:"",className:"pointer-events-none absolute top-[4.422%] left-[50.578%] h-[26.03%] w-[49.428%] max-w-none select-none"})]})}export{w as WishButton};
@@ -1 +1 @@
1
- import{jsx as a}from"react/jsx-runtime";import{Button as n}from"@base-ui/react/button";import{cva as d}from"class-variance-authority";import{cn as o}from"cn";var s=d("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",lg:"h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-9","icon-xs":"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function g({className:e,variant:r="default",size:i="default",...t}){return a(n,{"data-slot":"button",className:o(s({variant:r,size:i,className:e})),...t})}export{g as Button,s as buttonVariants};
1
+ import{jsx as a}from"react/jsx-runtime";import{Button as n}from"@base-ui/react/button";import{cva as d}from"class-variance-authority";import{cn as o}from"cn";var s=d("group/button focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:ring-3 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:ring-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50 shadow-xs",secondary:"bg-secondary text-secondary-foreground aria-expanded:bg-secondary aria-expanded:text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",lg:"h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-9","icon-xs":"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function g({className:e,variant:r="default",size:i="default",...t}){return a(n,{"data-slot":"button",className:o(s({variant:r,size:i,className:e})),...t})}export{g as Button,s as buttonVariants};
@@ -8,4 +8,4 @@ declare function CardDescription({ className, ...props }: React.ComponentProps<"
8
8
  declare function CardAction({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
9
9
  declare function CardContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
10
10
  declare function CardFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
11
- export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent, };
11
+ export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent };
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{cn as d}from"cn";function c({className:a,size:r="default",...e}){return t("div",{"data-slot":"card","data-size":r,className:d("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 [--card-spacing:--spacing(6)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",a),...e})}function n({className:a,...r}){return t("div",{"data-slot":"card-header",className:d("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",a),...r})}function i({className:a,...r}){return t("div",{"data-slot":"card-title",className:d("font-heading text-base leading-normal font-medium group-data-[size=sm]/card:text-sm",a),...r})}function l({className:a,...r}){return t("div",{"data-slot":"card-description",className:d("text-sm text-muted-foreground",a),...r})}function u({className:a,...r}){return t("div",{"data-slot":"card-action",className:d("col-start-2 row-span-2 row-start-1 self-start justify-self-end",a),...r})}function g({className:a,...r}){return t("div",{"data-slot":"card-content",className:d("flex flex-col gap-3 px-(--card-spacing)",a),...r})}function p({className:a,...r}){return t("div",{"data-slot":"card-footer",className:d("flex items-center rounded-b-xl px-(--card-spacing) [.border-t]:pt-(--card-spacing)",a),...r})}export{c as Card,u as CardAction,g as CardContent,l as CardDescription,p as CardFooter,n as CardHeader,i as CardTitle};
1
+ import{jsx as t}from"react/jsx-runtime";import{cn as d}from"cn";function c({className:a,size:r="default",...e}){return t("div",{"data-slot":"card","data-size":r,className:d("group/card bg-card text-card-foreground ring-foreground/10 flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl py-(--card-spacing) text-sm shadow-xs ring-1 [--card-spacing:--spacing(6)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",a),...e})}function n({className:a,...r}){return t("div",{"data-slot":"card-header",className:d("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",a),...r})}function i({className:a,...r}){return t("div",{"data-slot":"card-title",className:d("font-heading text-base leading-normal font-medium group-data-[size=sm]/card:text-sm",a),...r})}function l({className:a,...r}){return t("div",{"data-slot":"card-description",className:d("text-muted-foreground text-sm",a),...r})}function u({className:a,...r}){return t("div",{"data-slot":"card-action",className:d("col-start-2 row-span-2 row-start-1 self-start justify-self-end",a),...r})}function g({className:a,...r}){return t("div",{"data-slot":"card-content",className:d("flex flex-col gap-3 px-(--card-spacing)",a),...r})}function p({className:a,...r}){return t("div",{"data-slot":"card-footer",className:d("flex items-center rounded-b-xl px-(--card-spacing) [.border-t]:pt-(--card-spacing)",a),...r})}export{c as Card,u as CardAction,g as CardContent,l as CardDescription,p as CardFooter,n as CardHeader,i as CardTitle};
@@ -1,5 +1,5 @@
1
- import * as React from "react";
2
1
  import { type VariantProps } from "class-variance-authority";
2
+ import * as React from "react";
3
3
  import { Button } from "./button.js";
4
4
  declare function InputGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
5
5
  declare const inputGroupAddonVariants: (props?: ({
@@ -1 +1 @@
1
- import{jsx as n}from"react/jsx-runtime";import{cva as s}from"class-variance-authority";import{cn as o}from"cn";import{Button as u}from"./button.js";import{Textarea as l}from"./textarea.js";function m({className:a,...t}){return n("div",{"data-slot":"input-group",role:"group",className:o("group/input-group border-input has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 relative flex h-9 w-full min-w-0 items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-3 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",a),...t})}var d=s("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function x({className:a,align:t="inline-start",...i}){return n("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:o(d({align:t}),a),onClick:(r)=>{if(r.target.closest("button"))return;r.currentTarget.parentElement?.querySelector("input")?.focus()},...i})}var p=s("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function v({className:a,type:t="button",variant:i="ghost",size:r="xs",...e}){return n(u,{type:t,"data-size":r,variant:i,className:o(p({size:r}),a),...e})}function k({className:a,...t}){return n(l,{"data-slot":"input-group-control",className:o("flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent",a),...t})}export{m as InputGroup,x as InputGroupAddon,v as InputGroupButton,k as InputGroupTextarea};
1
+ import{jsx as n}from"react/jsx-runtime";import{cva as s}from"class-variance-authority";import{cn as o}from"cn";import{Button as u}from"./button.js";import{Textarea as l}from"./textarea.js";function m({className:a,...t}){return n("div",{"data-slot":"input-group",role:"group",className:o("group/input-group border-input has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 relative flex h-9 w-full min-w-0 items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-3 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",a),...t})}var d=s("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function x({className:a,align:t="inline-start",...i}){return n("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:o(d({align:t}),a),onClick:(r)=>{if(r.target.closest("button"))return;r.currentTarget.parentElement?.querySelector("input")?.focus()},...i})}var p=s("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function v({className:a,type:t="button",variant:i="ghost",size:r="xs",...e}){return n(u,{type:t,"data-size":r,variant:i,className:o(p({size:r}),a),...e})}function k({className:a,...t}){return n(l,{"data-slot":"input-group-control",className:o("flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent",a),...t})}export{m as InputGroup,x as InputGroupAddon,v as InputGroupButton,k as InputGroupTextarea};
@@ -2,6 +2,6 @@ import { type PetAssetsHost } from "./host.js";
2
2
  export declare function createPetSelection(host: PetAssetsHost, owned: (petId: string) => Promise<readonly {
3
3
  vibemon_uuid: string;
4
4
  }[]>): {
5
- get(): Promise<string | null>;
5
+ get: () => Promise<string | null>;
6
6
  select(petId: string | null): Promise<void>;
7
7
  };
@@ -1 +1 @@
1
- import{accountKey as u,assertAccount as c}from"./host.js";function w(n,s){let a=Promise.resolve();return{async get(){let e=n.account();if(e===null)return null;let t=await n.storage.get("vibemon.accounts");return c(n,e),t?.[u(e)]?.pet||null},async select(e){let t=n.account();if(t===null)throw Error("Sign in to select a Vibemon");if(e!==null&&!(await s(e)).some((o)=>o.vibemon_uuid===e))throw Error("This account does not own the selected Vibemon");c(n,t);let r=a.catch(()=>{}).then(async()=>{c(n,t);let o=await n.storage.get("vibemon.accounts")??{};c(n,t);let i=u(t);await n.storage.set("vibemon.accounts",{...o,[i]:{...o[i],pet:e??""}}),c(n,t)});a=r,await r}}}export{w as createPetSelection};
1
+ import{accountKey as u,assertAccount as c}from"./host.js";function w(n,s){let a=Promise.resolve();return{get:async()=>{let e=n.account();if(e===null)return null;let t=await n.storage.get("vibemon.accounts");return c(n,e),t?.[u(e)]?.pet||null},async select(e){let t=n.account();if(t===null)throw Error("Sign in to select a Vibemon");if(e!==null&&!(await s(e)).some((o)=>o.vibemon_uuid===e))throw Error("This account does not own the selected Vibemon");c(n,t);let r=a.catch(()=>{}).then(async()=>{c(n,t);let o=await n.storage.get("vibemon.accounts")??{};c(n,t);let i=u(t);await n.storage.set("vibemon.accounts",{...o,[i]:{...o[i],pet:e??""}}),c(n,t)});a=r,await r}}}export{w as createPetSelection};
package/dist/state.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { AuthUser, LoginResponse } from "./types.js";
2
1
  import type { createTokenStorage } from "./token-storage.js";
2
+ import type { AuthUser, LoginResponse } from "./types.js";
3
3
  export interface AuthState {
4
4
  user: AuthUser | null;
5
5
  isAuthenticated: boolean;
package/dist/state.js CHANGED
@@ -1 +1 @@
1
- function w(e){let{tokenStorage:l,loadUser:d,saveUser:s,clearAllAuth:f}=e.storage,n=0;return(r,c)=>({user:null,isAuthenticated:!1,isLoading:!0,_initialized:!1,init:()=>{if(c()._initialized)return;r({_initialized:!0}),e.onInit();let a=n;(async()=>{try{let i=await l.getAccess(),t=await l.getRefresh();if(a!==n)return;if(!i||!t){await e.handleUnauthenticated(),r({isLoading:!1});return}let v=e.validateProfile(),o=await d();if(a!==n)return;if(!v){if(o)r({user:o,isAuthenticated:!0}),e.loadProviders();return}if(o)r({user:o,isAuthenticated:!0,isLoading:!1}),e.onSignedIn(o,"restore");e.loadProviders();try{let u=await e.getProfile();if(a!==n)return;let g={user_uuid:u.uuid,nickname:u.nickname,login_email:u.login_email,avatar:u.avatar};r({user:g,isAuthenticated:!0}),await s(g),e.onProfileRestored()}catch{let u=await d();if(a!==n)return;if(u)r({user:u,isAuthenticated:!0});else await f(),e.clearProviders(),r({user:null,isAuthenticated:!1})}if(!o)r({isLoading:!1})}catch(i){console.error("[auth] session restore failed unexpectedly",i)}finally{if(c().isLoading)r({isLoading:!1})}})(),e.subscribeExpired(()=>{n++,e.clearAccountConversation(c().user).then(e.handleUnauthenticated).then((i)=>{if(i)return;r({user:null,isAuthenticated:!1})})}),e.subscribeState((i)=>{if(i.action==="logout")n++,e.clearAccountConversation(c().user).then(e.handleUnauthenticated).then((t)=>{if(t)return;e.clearProviders(),r({user:null,isAuthenticated:!1})});else if(i.action==="login"&&i.user)n++,r({user:i.user,isAuthenticated:!0}),e.loadProviders();else if(i.action==="update"&&i.user)r({user:i.user})})},login:async(a)=>{n++,await l.save(a.access_token,a.refresh_token);let i={user_uuid:a.user_uuid,nickname:a.nickname,login_email:a.login_email};await s(i),r({user:i,isAuthenticated:!0}),e.loadProviders(),await e.broadcast({action:"login",user:i}),e.onSignedIn(i,"login")},logout:async()=>{if(n++,e.clearProviders(),await e.logoutApi(),await e.clearAccountConversation(c().user),await f(),await e.broadcast({action:"logout"}),await e.handleUnauthenticated())return;r({user:null,isAuthenticated:!1})},refreshUser:async()=>{try{let a=await e.getProfile(),i={user_uuid:a.uuid,nickname:a.nickname,login_email:a.login_email,avatar:a.avatar};r({user:i}),await s(i)}catch(a){console.warn("[auth] refreshUser failed",a)}},updateUser:(a)=>{let i=c().user;if(!i)return;let t={...i,...a};r({user:t}),s(t),e.broadcast({action:"update",user:t})}})}export{w as createAuthState};
1
+ function w(e){let{tokenStorage:l,loadUser:d,saveUser:s,clearAllAuth:f}=e.storage,n=0;return(r,o)=>({user:null,isAuthenticated:!1,isLoading:!0,_initialized:!1,init:()=>{if(o()._initialized)return;r({_initialized:!0}),e.onInit();let a=n;(async()=>{try{let i=await l.getAccess(),t=await l.getRefresh();if(a!==n)return;if(!i||!t){await e.handleUnauthenticated(),r({isLoading:!1});return}let v=e.validateProfile(),c=await d();if(a!==n)return;if(!v){if(c)r({user:c,isAuthenticated:!0}),e.loadProviders();return}if(c)r({user:c,isAuthenticated:!0,isLoading:!1}),e.onSignedIn(c,"restore");e.loadProviders();try{let u=await e.getProfile();if(a!==n)return;let g={user_uuid:u.uuid,nickname:u.nickname,login_email:u.login_email,avatar:u.avatar};r({user:g,isAuthenticated:!0}),await s(g),e.onProfileRestored()}catch{let u=await d();if(a!==n)return;if(u)r({user:u,isAuthenticated:!0});else await f(),e.clearProviders(),r({user:null,isAuthenticated:!1})}if(!c)r({isLoading:!1})}catch(i){console.error("[auth] session restore failed unexpectedly",i)}finally{if(o().isLoading)r({isLoading:!1})}})(),e.subscribeExpired(()=>{n++,e.clearAccountConversation(o().user).then(e.handleUnauthenticated).then((i)=>{if(i)return;r({user:null,isAuthenticated:!1})})}),e.subscribeState((i)=>{if(i.action==="logout")n++,e.clearAccountConversation(o().user).then(e.handleUnauthenticated).then((t)=>{if(t)return;e.clearProviders(),r({user:null,isAuthenticated:!1})});else if(i.action==="login"&&i.user)n++,r({user:i.user,isAuthenticated:!0}),e.loadProviders();else if(i.action==="update"&&i.user)r({user:i.user})})},login:async(a)=>{n++,await l.save(a.access_token,a.refresh_token);let i={user_uuid:a.user_uuid,nickname:a.nickname,login_email:a.login_email};await s(i),r({user:i,isAuthenticated:!0}),e.loadProviders(),await e.broadcast({action:"login",user:i}),e.onSignedIn(i,"login")},logout:async()=>{if(n++,e.clearProviders(),await e.logoutApi(),await e.clearAccountConversation(o().user),await f(),await e.broadcast({action:"logout"}),await e.handleUnauthenticated())return;r({user:null,isAuthenticated:!1})},refreshUser:async()=>{try{let a=await e.getProfile(),i={user_uuid:a.uuid,nickname:a.nickname,login_email:a.login_email,avatar:a.avatar};r({user:i}),await s(i)}catch(a){console.warn("[auth] refreshUser failed",a)}},updateUser:(a)=>{let i=o().user;if(!i)return;let t={...i,...a};r({user:t}),s(t),e.broadcast({action:"update",user:t})}})}export{w as createAuthState};
@@ -1,18 +1,18 @@
1
1
  import type { AuthUser } from "./types.js";
2
2
  export interface AuthStore {
3
- get<T>(key: string): Promise<T | undefined>;
4
- set(key: string, value: unknown): Promise<void>;
5
- delete(key: string): Promise<void>;
3
+ get: <T>(key: string) => Promise<T | undefined>;
4
+ set: (key: string, value: unknown) => Promise<void>;
5
+ delete: (key: string) => Promise<void>;
6
6
  }
7
7
  export declare function authStoreName(apiBaseUrl: string): string;
8
8
  export declare function createTokenStorage(store: AuthStore): {
9
9
  tokenStorage: {
10
- save(accessToken: string, refreshToken: string): Promise<void>;
11
- getAccess(): Promise<string>;
12
- getRefresh(): Promise<string>;
13
- updateAccess(token: string): Promise<void>;
14
- clear(): Promise<void>;
15
- getDeviceId(): Promise<string>;
10
+ save: (accessToken: string, refreshToken: string) => Promise<void>;
11
+ getAccess: () => Promise<string>;
12
+ getRefresh: () => Promise<string>;
13
+ updateAccess: (token: string) => Promise<void>;
14
+ clear: () => Promise<void>;
15
+ getDeviceId: () => Promise<string>;
16
16
  };
17
17
  saveUser: (user: AuthUser) => Promise<void>;
18
18
  loadUser: () => Promise<AuthUser | null>;
@@ -1 +1 @@
1
- function r(a){return`auth.${new URL(a).host}`}function u(a){let e={ACCESS:"access_token",REFRESH:"refresh_token",DEVICE_ID:"device_id",USER:"user"},n={async save(t,S){await a.set(e.ACCESS,t),await a.set(e.REFRESH,S)},async getAccess(){return await a.get(e.ACCESS)??""},async getRefresh(){return await a.get(e.REFRESH)??""},async updateAccess(t){await a.set(e.ACCESS,t)},async clear(){await a.delete(e.ACCESS),await a.delete(e.REFRESH)},async getDeviceId(){let t=await a.get(e.DEVICE_ID);if(!t)t=crypto.randomUUID(),await a.set(e.DEVICE_ID,t);return t}};async function i(t){await a.set(e.USER,t)}async function E(){return await a.get(e.USER)??null}async function c(){await a.delete(e.USER)}async function s(){await n.clear(),await c()}return{tokenStorage:n,saveUser:i,loadUser:E,clearUser:c,clearAllAuth:s}}export{r as authStoreName,u as createTokenStorage};
1
+ function r(a){return`auth.${new URL(a).host}`}function u(a){let e={ACCESS:"access_token",REFRESH:"refresh_token",DEVICE_ID:"device_id",USER:"user"},n={save:async(t,S)=>{await a.set(e.ACCESS,t),await a.set(e.REFRESH,S)},getAccess:async()=>await a.get(e.ACCESS)??"",getRefresh:async()=>await a.get(e.REFRESH)??"",updateAccess:async(t)=>{await a.set(e.ACCESS,t)},clear:async()=>{await a.delete(e.ACCESS),await a.delete(e.REFRESH)},getDeviceId:async()=>{let t=await a.get(e.DEVICE_ID);if(!t)t=crypto.randomUUID(),await a.set(e.DEVICE_ID,t);return t}};async function i(t){await a.set(e.USER,t)}async function E(){return await a.get(e.USER)??null}async function c(){await a.delete(e.USER)}async function s(){await n.clear(),await c()}return{tokenStorage:n,saveUser:i,loadUser:E,clearUser:c,clearAllAuth:s}}export{r as authStoreName,u as createTokenStorage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwith/module-auth",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -71,7 +71,7 @@
71
71
  ],
72
72
  "devDependencies": {
73
73
  "typescript": "^7.0.2",
74
- "@types/bun": "^1.4.2",
74
+ "@types/bun": "^1.4.3",
75
75
  "@types/react": "^19.3.0",
76
76
  "@types/react-dom": "^19.3.0"
77
77
  },
@@ -94,7 +94,7 @@
94
94
  "dependencies": {
95
95
  "@base-ui/react": "^1.8.0",
96
96
  "class-variance-authority": "^0.7.1",
97
- "cn": "^0.4.0",
97
+ "cn": "^0.5.0",
98
98
  "lucide-react": "^1.49.0",
99
99
  "motion": "^13.4.6",
100
100
  "react-i18next": "^17.0.15",