UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 35.2 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./control-ui-connection-D5QrEAFW.css","./control-ui-boot-shared-styles-BorAdMVO.css"])))=>i.map(i=>d[i]); import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Aa as t,Hc as n,Tc as r,in as i,ln as a,lo as o,lu as s,uu as c,wa as l,xa as u}from"./control-ui-connection-Bfj9beF_.js";import{Dy as d,Ey as f,QA as p,Sy as m,ZA as h,_j as ee,aO as te,by as ne,hj as re,iO as ie,lO as ae,sO as oe,xy as se,yy as ce}from"./control-ui-boot-shared-DFTSUQQ0.js";import{F as le,J as g,O as _,S as ue,U as de,W as fe,b as v,c as pe,d as y,f as b,g as x,gt as me,j as S,l as C,m as he,n as ge,o as w,p as T,s as _e,u as ve,w as ye,x as E}from"./solid-runtime-C416s-HC.js";import{t as be}from"./route-controls-runtime-Bx6nx3QW.js";import{_ as xe,a as D,b as Se,c as O,d as Ce,g as we,h as k,i as Te,n as A,o as j,r as M,s as Ee,t as De,u as N,v as Oe,x as ke,y as Ae}from"./lobster-pet-identity-Cg5EqPlD.js";import{a as P,d as je,i as Me,l as Ne,n as Pe,o as Fe,r as Ie,s as Le,t as F,u as Re}from"./lobster-dex-Mq9Rr_vU.js";import{n as ze}from"./lobster-pet-audio-waE6qgq0.js";function Be(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function Ve(e){return Be(`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`)}function He(e){return Ve(e)%16==3}function Ue(){return(Ue=e((()=>{})))()}function We(e,t,n=new Date){return e===`busy`||e===`offline`?at[e]:rt(n)?L.sleepy:t?L[t]:null}function Ge(e){return e===`error`?`droop`:e===`aborted`?`startle`:`cheer`}function Ke(e){return e<.06?`balloon`:e<.13?`bubble`:`walk`}function qe(e){return j((e^12317)>>>0)()<.12}function Je(e){return j((e^30485)>>>0)()<.04}function Ye(e,t){return(Object.hasOwn(R,e)?R[e]:void 0)??t?.[e]?.crossMs??12e3}function Xe(e,{critters:t=[],strangers:n=!0}={}){let r=j((e^3243)>>>0),i=r()*1e3,a=[[`crab`,15],[`snail`,12],[`duck`,12],[`jellyfish`,11],...n?[[`stranger`,45]]:[],...t.map(e=>[e,20])],o=0,s=a.find(([,e])=>(o+=e,i<o))?.[0];return s?{kind:s,atMs:Math.round(2500+r()*6500),direction:r()<.5?1:-1,floor:r()<.55,hops:r()<.35&&s!==`snail`}:null}function Ze(e){return j((e^57811)>>>0)()<.015}function Qe(e,t){if(t.length===0)return null;let n=j((e^61982)>>>0);return n()>=.08?null:t[Math.floor(n()*t.length)]??null}function $e(e,t){let n=Ie(),r={elder:!1,oldFriend:!1,friendName:null,dexComplete:N.every(e=>n.has(e.id)),look:t};if(Ze(e))return{...r,elder:!0,look:{...t,scale:3,accessory:`barnacle`,personality:`sleepy`,clawSize:`mighty`,crusherSide:null}};if(t.palette.id===`retro`||t.palette.id===`goldenretro`)return r;let i=Qe(e,[...n].filter(e=>N.some(t=>t.id===e)).toSorted()),a=i?N.find(e=>e.id===i):void 0;return a?{...r,oldFriend:!0,friendName:Me().get(a.id)?.name??null,look:{...t,palette:a,chimeraParts:a.id===`chimera`?De(a).chimeraParts:null}}:r}function et(e,t){return e.elder?`Methuselah`:e.friendName??D(e.look,t)}function tt(e){let t=j((e^45175)>>>0);return t()>=.03?null:{atMs:Math.round(3500+t()*6500),spotPct:Math.round(15+t()*70),fortuneIndex:Math.floor(t()*H.length)}}function nt(e){try{let n=t();if(!n)return!1;let r=n.getItem(U);return r!==e&&(n.setItem(U,e),r!==null)}catch{return!1}}function rt(e=new Date){let t=e.getHours();return t>=22||t<6}function I(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var it,L,at,ot,R,z,B,V,H,U;function W(){return(W=e((()=>{P(),M(),Ce(),it={wave:1400,snip:1e3,hop:750,spin:950,peek:1700,nap:4400,bubble:2600,scuttle:1250,startle:750,cheer:1300,molt:2600,pet:1500,droop:1600,sweep:1800},L={sleepy:{delayMs:[6e3,12e3],acts:[[`nap`,40],[`bubble`,20],[`wave`,12],[`scuttle`,12],[`peek`,10],[`hop`,6]]},zoomy:{delayMs:[2800,6e3],acts:[[`scuttle`,42],[`hop`,22],[`spin`,12],[`peek`,12],[`wave`,12]]},friendly:{delayMs:[3600,7500],acts:[[`wave`,32],[`snip`,22],[`scuttle`,18],[`hop`,14],[`bubble`,14]]},showoff:{delayMs:[3600,7500],acts:[[`spin`,24],[`snip`,22],[`peek`,20],[`hop`,18],[`wave`,16]]}},at={busy:{delayMs:[2200,4500],acts:[[`scuttle`,40],[`hop`,20],[`snip`,20],[`wave`,12],[`spin`,8]]},offline:{delayMs:[2800,5600],acts:[[`scuttle`,55],[`peek`,30],[`hop`,15]]}},ot={walk:450,balloon:1250,bubble:700},R={stranger:11e3,crab:11e3,snail:9e4,duck:14e3,jellyfish:16e3,penguin:13e3,fedora:9e3},z=[1800,7500],B=[9e4,3e5],V=[18e5,36e5],H=[`the tide returns every branch to shore`,`molt before you feel ready`,`a shell is just armor you outgrew`,`somewhere, a test is green because of you`,`swim sideways when forward fails`,`the reef remembers kind commits`,`even the deep keeps a night light`,`barnacles are only patient passengers`,`no current lasts forever`,`bury your treasure in version control`,`the crab was a lobster all along`,`small claws, firm grip`,`rest is also progress`,`what washes away was never pinned`],U=`openclaw.control.lobsterpet.gatewayVersion.v1`})))()}var G;function K(){return(K=e((()=>{G=class{constructor(e=()=>{}){this.onFire=e,this.pending=new Map}has(e){return this.pending.has(e)}schedule(e,t,n){this.pending.set(e,window.setTimeout(()=>{this.pending.delete(e),n(),this.onFire()},t))}clear(...e){for(let t of e){let e=this.pending.get(t);e!==void 0&&(window.clearTimeout(e),this.pending.delete(t))}}}})))()}var st;function ct(){return(ct=e((()=>{W(),K(),st=class{constructor(e){this.hooks=e,this.timers=new G,this.audioCtx=null,this.pokeTimes=[],this.lastGazeAt=0,this.bindSprite=e=>{this.sprite=e},this.handleHoldStart=e=>{e.button!==0||I()||(this.handleHoldCancel(),this.timers.schedule(`holdTimer`,600,()=>{this.hooks.onGrumpyChange(!1),this.playChirp(`pet`),this.hooks.onAct(`pet`)}))},this.handleHoldEnd=e=>{if(e.button===0&&this.timers.has(`holdTimer`)){this.handleHoldCancel(),this.playChirp(`poke`);let e=Date.now();if(this.pokeTimes=[...this.pokeTimes.filter(t=>e-t<6e3),e],this.pokeTimes.length>=10&&this.hooks.canHuff()){this.pokeTimes=[],this.hooks.onGrumpyChange(!1),this.hooks.onHuff();return}this.pokeTimes.length>=3&&(this.hooks.onGrumpyChange(!0),this.timers.clear(`grumpyTimer`),this.timers.schedule(`grumpyTimer`,6e4,()=>{this.hooks.onGrumpyChange(!1)})),this.hooks.onAct(`startle`)}},this.handleHoldCancel=()=>this.timers.clear(`holdTimer`),this.handleGaze=e=>{if(!this.hooks.canGaze()||I())return;let t=Date.now();if(t-this.lastGazeAt<120)return;this.lastGazeAt=t;let n=this.sprite;if(!n?.isConnected)return;let r=n.getBoundingClientRect(),i=r.left+r.width/2;this.hooks.onFacing(e.clientX<i?-1:1)}}connect(){this.stopGaze=o(document,`pointermove`,this.handleGaze,{passive:!0})}dispose(){this.stopGaze?.(),this.stopGaze=void 0,this.sprite=void 0,this.handleHoldCancel(),this.timers.clear(`grumpyTimer`),this.audioCtx&&=(this.audioCtx.close().catch(()=>{}),null)}suspend(){this.handleHoldCancel(),this.timers.clear(`grumpyTimer`),this.hooks.onGrumpyChange(!1)}playChirp(e){this.audioCtx=ze(this.audioCtx,this.hooks.soundsEnabled(),e)}}})))()}function lt(e){return e.hop?1100:Math.max(850,Math.min(2600,Math.abs(e.to.x-e.from.x)*8))}function ut(e,t,n,r){let i=e,a=null;for(let e of n.toSorted((e,t)=>e.left-t.left)){let n=Math.min(t,e.left-r);n>i&&(!a||n-i>a[1]-a[0])&&(a=[i,n]),i=Math.max(i,e.right+r)}return t>i&&(!a||t-i>a[1]-a[0])&&(a=[i,t]),a}function dt(e){let{composer:t,footer:n,editor:r}=e,i={top:null,floor:null,passage:null};if(t.width<=0||t.height<=0)return i;let a=ft+(e.twins?28:0),o=ut(t.left+a,t.right-a,e.topObstacles.filter(e=>e.height>0&&e.bottom>t.top-pt&&e.top<t.top),a),s=o?{start:o[0]-t.left,end:o[1]-t.left,y:0}:null;if(!n||n.height<=0)return{...i,top:s};let c=Math.min(t.bottom-8,n.bottom-5);if(c-48<(r?.bottom??t.top))return{...i,top:s};let l=ut(Math.max(t.left,n.left)+a,Math.min(t.right,n.right)-a,e.controls.filter(e=>e.width>0&&e.height>0&&e.top<c&&e.bottom>c-48),a),u=l&&l[1]-l[0]>=24?{start:l[0]-t.left,end:l[1]-t.left,y:c-t.top}:null,d=Math.max(s?.start??1/0,u?.start??1/0,e.placeholderRight-t.left+a),f=Math.min(s?.end??-1/0,u?.end??-1/0);return{top:s,floor:u,passage:f-d>=28?[d,f]:null}}function q(e,t){return{x:e?e.start+(e.end-e.start)*t/100:0,y:e?.y??0}}var ft,pt,mt;function J(){return(J=e((()=>{ft=38,pt=88,mt=class{constructor(e,t,n,r){this.host=e,this.elements=t,this.twins=n,this.notify=r,this.scene={top:null,floor:null,passage:null},this.resize=null,this.mutation=null,this.active=!1,this.frame=null,this.observed=[],this.scheduleMeasure=()=>{this.active&&this.frame===null&&(this.frame=requestAnimationFrame(()=>this.measure()))}}planWalk(e,t,n){let r=this.scene[e];if(!r)return null;let i=Math.round(n*100);return Math.abs(i-t)<4&&(i=t>50?0:100),{anchor:e,spotPct:i,facing:i<t?-1:1,travel:{from:q(r,t),to:q(r,i),hop:!1}}}planHop(e,t){let{passage:n,floor:r}=this.scene,i=this.scene[e];if(!n||!r||!i)return null;let a=q(i,t),o=(n[0]+n[1])/2;if(a.x<n[0]||a.x>n[1])return{anchor:e,spotPct:(o-i.start)/(i.end-i.start)*100,facing:o<a.x?-1:1,travel:{from:a,to:{x:o,y:i.y},hop:!1}};let s=e===`top`?`floor`:`top`,c=this.scene[s];if(!c)return null;let l=a.x<o?n[1]:n[0];return{anchor:s,spotPct:(l-c.start)/(c.end-c.start)*100,facing:l<a.x?-1:1,travel:{from:a,to:{x:l,y:c.y},hop:!0}}}connect(){this.active=!0,this.resize=new ResizeObserver(()=>this.measure());let e=this.elements()?.root;e&&(this.mutation=new MutationObserver(e=>{e.some(e=>e.target.isConnected&&e.target!==this.host&&!this.host.contains(e.target)&&!(e.target instanceof Element?e.target:e.target.parentElement)?.closest(`[popover]`))&&this.scheduleMeasure()}),this.mutation.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`,`aria-label`]})),this.scheduleMeasure()}dispose(){this.active=!1,this.frame!==null&&(cancelAnimationFrame(this.frame),this.frame=null),this.resize?.disconnect(),this.resize=null,this.mutation?.disconnect(),this.mutation=null,this.observed=[]}measure(){if(this.frame!==null&&(cancelAnimationFrame(this.frame),this.frame=null),!this.active||!this.host.isConnected)return;let e=this.elements();if(!e)return;let{composer:t,footer:n,editor:r,controls:i,obstacles:a}=e,o=[t,...i,...a,n,r];if(o.length!==this.observed.length||o.some((e,t)=>e!==this.observed[t])){this.resize?.disconnect();for(let e of o)this.resize?.observe(e);this.observed=o}let s=r.getBoundingClientRect(),c=s.left,l=getComputedStyle(r),u=r.getAttribute(`aria-label`)??r.placeholder,d=Number.parseFloat(l.fontSize)||16,f=u.length*d*.65;if(typeof CanvasRenderingContext2D<`u`){let e=document.createElement(`canvas`).getContext(`2d`);e&&(e.font=l.font,f=e.measureText(u).width)}c+=Math.min(s.width,f+(Number.parseFloat(l.paddingLeft)||0));let p=dt({composer:t.getBoundingClientRect(),footer:n.getBoundingClientRect(),controls:i.map(e=>e.getBoundingClientRect()),topObstacles:a.map(e=>e.getBoundingClientRect()),editor:s,placeholderRight:c,twins:this.twins()});this.host.toggleAttribute(`data-scene-ready`,p.top!==null),JSON.stringify(p)!==JSON.stringify(this.scene)&&(this.scene=p,this.notify())}}})))()}var ht;function gt(){return(gt=e((()=>{r(),W(),K(),ht=class{constructor(e,t){this.notify=e,this.hooks=t,this.passer=null,this.bottle=null,this.connected=!1,this.timers=new G,this.seed=null,this.passerConsumed=!1,this.crossingMs=0,this.openBottle=()=>{this.bottle&&!this.bottle.opened&&(this.bottle={...this.bottle,opened:!0},this.armBottleEbb(12e4),this.notify())}}connect(){this.connected=!0}update(){this.hooks.visitsEnabled()||(this.clearTimers(),this.passer=null,this.bottle=null)}dispose(){this.connected=!1,this.clearTimers(),this.passer=null,this.bottle=null,this.notify()}reset(e){if(e!==this.seed&&(this.seed=e,this.passerConsumed=!1),this.clearTimers(),this.passer=null,this.bottle=null,this.connected&&this.hooks.visitsEnabled()){this.schedulePasser(e);let t=tt(e);if(!t)return;this.timers.schedule(`bottleTimer`,t.atMs,()=>{this.connected&&this.hooks.visitsEnabled()&&(this.bottle={spotPct:t.spotPct,opened:!1,fortune:n(H[t.fortuneIndex],`lobster bottle fortune`)},this.notify(),this.armBottleEbb(3e5))})}}replanPasser(e){let t=this.passer,n=this.hooks.passerOptions(),r=t&&[`stranger`,`crab`,`snail`,`duck`,`jellyfish`].includes(t.kind);if(t&&(t.kind!==`stranger`||n.strangers!==!1||n.critters?.includes(t.kind))&&(r||n.critters?.includes(t.kind)))return;let i=this.passer!==null;this.clearPasserTimers(),this.passer=null,i&&this.hooks.onPasserDone(),this.connected&&this.hooks.visitsEnabled()&&this.schedulePasser(e)}passerCrossMs(){return this.passer?this.crossingMs:0}clearTimers(){this.clearPasserTimers(),this.timers.clear(`bottleTimer`,`bottleEndTimer`)}clearPasserTimers(){this.timers.clear(`passerTimer`,`passerEndTimer`,`passerWatchTimer`)}schedulePasser(e){if(this.passerConsumed)return;let t=Xe(e,this.hooks.passerOptions());t&&!I()&&this.timers.schedule(`passerTimer`,t.atMs,()=>{if(this.passerConsumed=!0,!this.connected||!this.hooks.visitsEnabled()||document.hidden||I())return;this.hooks.onPasserStart(t),this.passer=t,this.crossingMs=Ye(t.kind,this.hooks.passerOptions().critterArtwork),this.notify();let e=this.passerCrossMs();this.hooks.onPasserFacing(t.direction===1?-1:1),this.timers.schedule(`passerWatchTimer`,e/2,()=>{this.hooks.onPasserFacing(t.direction),this.hooks.onPasserMidCross(),this.notify()}),this.timers.schedule(`passerEndTimer`,e,()=>{this.passer=null,this.notify(),this.hooks.onPasserDone()})})}armBottleEbb(e){this.timers.clear(`bottleEndTimer`),this.timers.schedule(`bottleEndTimer`,e,()=>{this.bottle=null,this.notify()})}}})))()}var _t;function vt(){return(vt=e((()=>{Ue(),i(),P(),be(),M(),ct(),W(),J(),K(),gt(),_t=class{constructor(e,t,n){this.host=e,this.disableVisits=t,this.inputs=n,this.act=null,this.spotPct=80,this.facing=1,this.entering=!1,this.entrance=`walk`,this.presence=`out`,this.anchor=`top`,this.geometry=new mt(this.host,()=>this.host.composerElements?.()??null,()=>this.inputs.residentEnabled&&this.twinPlanned,()=>this.refresh()),this.travel=null,this.travelScene=this.geometry.scene,this.motionRng=j(0),this.passerAnchor=`top`,this.passerHops=!1,this.shellAnchor=`top`,this.scheduledVisiting=!1,this.dismissed=!1,this.dismissMenuPosition=null,this.grumpy=!1,this.vigil=!1,this.outcomePresenceOwner=null,this.movingDay=!1,this.movingDayChecked=!1,this.anniversary=!1,this.sailorDay=!1,this.identity=null,this.entranceRng=j(0),this.traffic=new ht(()=>this.refresh(),{visitsEnabled:()=>this.inputs.visitsEnabled&&!this.dismissed,passerOptions:()=>({critters:this.inputs.critters,strangers:this.inputs.residentEnabled,critterArtwork:this.inputs.critterArtwork}),onPasserStart:e=>{this.passerAnchor=e.floor&&this.inputs.floorEnabled&&this.geometry.scene.floor?`floor`:`top`,this.passerHops=this.passerAnchor===`floor`&&e.hops&&this.geometry.scene.passage!==null},onPasserFacing:e=>{this.presence===`in`&&this.act!==`scuttle`&&!this.vigil&&(this.facing=e)},onPasserMidCross:()=>{let e=this.familiarity.tier===`friend`?`wave`:this.familiarity.tier===`shy`?`peek`:null;e===null||this.presence!==`in`||this.act!==null||this.vigil||this.inputs.mode!==`idle`||I()||this.performAct(e)},onPasserDone:()=>this.scheduleNextAct()}),this.interactions=new st({soundsEnabled:()=>this.inputs.soundsEnabled,canHuff:()=>this.inputs.mode!==`offline`,canGaze:()=>this.presence===`in`&&this.act===null&&!this.vigil,onGrumpyChange:e=>{this.grumpy=e,this.refresh()},onAct:e=>{this.performAct(e),this.refresh()},onFacing:e=>{this.facing=e,this.refresh()},onHuff:()=>{this.timers.clear(`visitTimer`,`leaveTimer`),this.scheduledVisiting=!1,this.armArrival(O(this.visitRng,V[0],V[1])),this.refresh()}}),this.shellVisible=!1,this.shellSpotPct=50,this.shellScale=2,this.molted=!1,this.moltPlanned=!1,this.twinPlanned=!1,this.familiarity={tier:`regular`,wary:!1,visits:0,shoos:0},this.greetedThisLoad=!1,this.look=null,this.rng=j(0),this.visitRng=j(0),this.timers=new G(()=>this.refresh()),this.restartPending=!1,this.active=!1,this.handleVisibilityChange=()=>{document.hidden?(this.outcomePresenceOwner=null,this.clearActTimers(),this.act=null):this.scheduleNextAct(),this.refresh()},this.openDismissMenu=e=>{this.inputs.residentEnabled&&this.inputs.visitsEnabled&&(e.preventDefault(),e.stopPropagation(),this.interactions.handleHoldCancel(),this.dismissMenuPosition={x:e.clientX,y:e.clientY},this.refresh())}}connect(){this.look=null,this.active=!0,this.geometry.connect(),this.traffic.connect(),this.interactions.connect(),this.stopVisibility=o(document,`visibilitychange`,this.handleVisibilityChange)}dispose(){this.active=!1,this.stopVisibility?.(),this.stopVisibility=void 0,this.clearActTimers(),this.restartPending=!1,this.scheduledVisiting=!1,this.presence=`out`,this.act=null,this.timers.clear(`visitTimer`,`leaveTimer`,`shellTimer`,`vigilTimer`),this.geometry.dispose(),this.traffic.dispose(),this.interactions.dispose()}subscribe(e){return this.render=e,()=>{this.render=void 0}}publish(){this.render?.()}update(e){let t=this.inputs;this.inputs=e,this.reconcile(t),this.active&&this.publish()}refresh(){this.active&&(this.reconcile(),this.publish())}wantsVisible(){return this.inputs.visitsEnabled&&this.inputs.residentEnabled&&!this.dismissed&&(this.inputs.mode===`offline`||this.vigil||this.outcomePresenceOwner!==null||this.scheduledVisiting)}reconcile(e=this.inputs){if(!this.active)return;let t=this.look===null||!Object.is(e.seed,this.inputs.seed);if(t)this.look=A(this.inputs.seed),this.rng=j(this.inputs.seed^2654435769),this.motionRng=j(this.inputs.seed^987138),this.visitRng=j(this.inputs.seed^99282957),this.entranceRng=j((this.inputs.seed^57978)>>>0),this.identity=$e(this.inputs.seed,this.look),this.look=this.identity.look,this.spotPct=this.look.spotPct,this.facing=this.look.facing,this.clearActTimers(),this.act=null,this.dismissed=!1,this.dismissMenuPosition=null,this.presence=`out`,this.molted=!1,this.shellVisible=!1,this.timers.clear(`shellTimer`),this.moltPlanned=qe(this.inputs.seed)&&!this.identity.elder,this.twinPlanned=Je(this.inputs.seed),this.geometry.scheduleMeasure(),this.familiarity=Pe(),this.sailorDay=He(new Date),this.greetedThisLoad=!1,this.scheduleVisits(),this.traffic.reset(this.inputs.seed),this.vigil=!1,this.outcomePresenceOwner=null,this.trackVigil();else if(e.mode!==this.inputs.mode){let t=e.mode===`busy`&&this.inputs.mode===`idle`,n=t&&this.vigil?`vigil`:null;if(this.trackVigil(),this.presence===`in`&&!I()){let e=Ge(this.inputs.runOutcome);this.performAct(t?e:`startle`,n)}}(e.visitsEnabled!==this.inputs.visitsEnabled||e.residentEnabled!==this.inputs.residentEnabled)&&(this.inputs.visitsEnabled&&!e.visitsEnabled&&(this.dismissed=!1,this.traffic.reset(this.inputs.seed)),!this.inputs.visitsEnabled||!this.inputs.residentEnabled?(this.clearActTimers(),this.timers.clear(`visitTimer`,`leaveTimer`),this.interactions.suspend(),this.timers.clear(`shellTimer`,`vigilTimer`),this.shellVisible=!1,this.vigil=!1,this.outcomePresenceOwner=null,this.dismissMenuPosition=null,this.scheduledVisiting=!1,this.presence=`out`,this.act=null,this.entering=!1,this.restartPending=!1):(!e.visitsEnabled||!e.residentEnabled)&&(this.scheduleVisits(),this.trackVigil()));let n=e.critters??[],r=this.inputs.critters??[],i=e.critters!==this.inputs.critters&&(n.length!==r.length||n.some((e,t)=>e!==r[t]));!t&&(e.residentEnabled!==this.inputs.residentEnabled||i)&&(this.traffic.replanPasser(this.inputs.seed),this.geometry.scheduleMeasure()),this.inputs.residentEnabled&&!this.movingDayChecked&&this.inputs.gatewayVersion&&(this.movingDayChecked=!0,this.movingDay=nt(this.inputs.gatewayVersion)),this.host.toggleAttribute(`data-dex-complete`,(this.identity?.dexComplete??!1)&&this.inputs.visitsEnabled&&this.inputs.residentEnabled&&!this.dismissed),((!this.inputs.floorEnabled||!this.geometry.scene.floor)&&this.anchor===`floor`||this.travel&&this.travelScene!==this.geometry.scene)&&(this.clearActTimers(),this.act=null,this.anchor=`top`,this.restartPending=this.presence===`in`),this.host.setAttribute(`data-spot`,this.anchor),this.host.toggleAttribute(`data-floor-enabled`,this.inputs.floorEnabled),this.reconcilePresence(),this.traffic.update(),this.active&&this.restartPending&&(this.restartPending=!1,this.timers.schedule(`enterTimer`,ot[this.entrance],()=>{this.entering=!1,!this.greetedThisLoad&&(this.familiarity.tier===`friend`||this.identity?.oldFriend===!0)&&this.presence===`in`&&!I()&&(this.greetedThisLoad=!0,this.performAct(`wave`))}),this.scheduleNextAct())}reconcilePresence(){let e=this.wantsVisible();e&&this.presence!==`in`?(this.timers.clear(`leaveTimer`),this.presence===`out`&&(this.anchor=`top`,this.spotPct=Math.round(O(this.visitRng,12,88)),this.facing=this.visitRng()<.5?1:-1,this.entrance=Ke(this.entranceRng()),this.look&&(this.anniversary=Fe(Me().get(this.look.palette.id)?.firstSeenAt??null,new Date),je(this.look.palette.id,{name:this.identity?et(this.identity,this.inputs.seed):D(this.look,this.inputs.seed),shiny:this.look.shiny}),Ne())),this.presence=`in`,this.entering=!I(),this.restartPending=!0):!e&&this.presence===`in`&&(this.dismissMenuPosition=null,this.outcomePresenceOwner=null,this.clearActTimers(),this.act=null,this.entering=!1,this.presence=`leaving`,this.timers.schedule(`leaveTimer`,350,()=>{this.presence=`out`}))}trackVigil(){this.timers.clear(`vigilTimer`),this.inputs.mode===`busy`&&this.inputs.visitsEnabled&&this.inputs.residentEnabled&&!this.dismissed?this.timers.schedule(`vigilTimer`,6e5,()=>{this.vigil=!0,this.clearActTimers(),this.act=null}):this.vigil=!1}dismiss(e){this.dismissMenuPosition=null,this.dismissed=!0,Re(),e&&(this.inputs={...this.inputs,visitsEnabled:!1},this.disableVisits(),a({lobsterPetVisits:!1}),this.inputs.onVisitsDisabled()),this.refresh()}clearActTimers(){this.travel=null,this.timers.clear(`idleTimer`,`actEndTimer`,`enterTimer`)}scheduleVisits(){if(this.timers.clear(`visitTimer`,`leaveTimer`),this.scheduledVisiting=!1,!this.inputs.visitsEnabled||!this.inputs.residentEnabled||this.visitRng()<.5)return;let e=F[this.familiarity.tier];this.armArrival(O(this.visitRng,z[0],z[1])*e.firstDelayMul)}armArrival(e){this.active&&this.inputs.visitsEnabled&&this.inputs.residentEnabled&&this.timers.schedule(`visitTimer`,e,()=>{this.scheduledVisiting=!0;let e=O(this.visitRng,B[0],B[1])*F[this.familiarity.tier].stayMul;this.timers.schedule(`visitTimer`,e,()=>{this.scheduledVisiting=!1;let e=F[this.familiarity.tier],t=this.familiarity.wary?F.waryGapMul:1;this.armArrival(O(this.visitRng,V[0],V[1])*e.gapMul*t)})})}scheduleNextAct(){if(!this.active||!this.inputs.visitsEnabled||!this.inputs.residentEnabled||!this.look||this.presence!==`in`||this.vigil||this.traffic.passer!==null||this.timers.has(`idleTimer`)||this.timers.has(`actEndTimer`)||I())return;let e=We(this.inputs.mode,this.look.personality);if(!e)return;let t=O(this.rng,e.delayMs[0],e.delayMs[1]);this.timers.schedule(`idleTimer`,t,()=>{let e=We(this.inputs.mode,this.look?.personality??null);e&&!document.hidden&&this.presence===`in`&&this.traffic.passer===null&&(this.moltPlanned&&!this.molted&&this.inputs.mode===`idle`?this.performAct(`molt`):this.performAct(Ee(this.rng,e.acts)))})}performAct(e,t=null){if(!this.inputs.visitsEnabled||!this.inputs.residentEnabled||this.presence!==`in`)return;this.clearActTimers(),this.outcomePresenceOwner=t,this.entering=!1,e===`hop`?this.startFloorHop():e===`scuttle`&&this.applyMove(this.geometry.planWalk(this.anchor,this.spotPct,this.rng()));let n=this.travel?lt(this.travel):it[e];this.act=this.travel&&!this.travel.hop?`scuttle`:e,this.timers.schedule(`actEndTimer`,n+(this.twinPlanned?180:0),()=>{this.act=null,this.travel=null,e===`molt`&&(this.molted=!0,this.look&&=(this.shellScale=this.look.scale,{...this.look,scale:this.look.scale<2?2:2.5}),this.shellSpotPct=this.spotPct,this.shellAnchor=this.anchor,this.shellVisible=!0,this.spotPct=Math.min(100,Math.max(0,this.spotPct+this.facing*9)),this.timers.clear(`shellTimer`),this.timers.schedule(`shellTimer`,6e4,()=>{this.shellVisible=!1})),e===`droop`?this.performAct(`sweep`,t):(this.outcomePresenceOwner=null,this.wantsVisible()&&this.scheduleNextAct())})}applyMove(e){e&&(this.anchor=e.anchor,this.spotPct=e.spotPct,this.facing=e.facing,this.travel=e.travel,this.travelScene=this.geometry.scene)}startFloorHop(){!this.inputs.floorEnabled||this.identity?.elder||this.anchor===`top`&&this.motionRng()>=.45||this.applyMove(this.geometry.planHop(this.anchor,this.spotPct))}scene(){let e=this.look;if(!e)return null;let t=this.identity,n=t?.elder?`old as the tides`:t?.oldFriend?`an old friend`:null;return{look:e,mode:this.inputs.mode,presence:this.presence,shellVisible:this.shellVisible,shellAnchor:this.shellAnchor,scene:this.geometry.scene,travel:this.travel,floorEnabled:this.inputs.floorEnabled,visitsEnabled:this.inputs.visitsEnabled,residentEnabled:this.inputs.residentEnabled,critterArtwork:this.inputs.critterArtwork,dismissed:this.dismissed,passer:this.traffic.passer?{kind:this.traffic.passer.kind,direction:this.traffic.passer.direction,crossMs:this.traffic.passerCrossMs(),anchor:this.passerAnchor,hops:this.passerHops}:null,twinPlanned:this.twinPlanned,anniversary:this.anniversary,entering:this.entering,entrance:this.entrance,grumpy:this.grumpy,vigil:this.vigil,elder:t?.elder??!1,act:this.act,spotPct:this.spotPct,facing:this.facing,anchor:this.anchor,shellScale:this.shellScale,shellSpotPct:this.shellSpotPct,familiarityVisits:this.familiarity.visits,seed:this.inputs.seed,movingDay:this.movingDay,sailorDay:this.sailorDay,nameOverride:t?et(t,this.inputs.seed):null,flavor:n,bottle:this.traffic.bottle,onPointerDown:this.interactions.handleHoldStart,onSprite:this.interactions.bindSprite,onPointerUp:this.interactions.handleHoldEnd,onPointerCancel:this.interactions.handleHoldCancel,onContextMenu:this.openDismissMenu,onBottleOpen:this.traffic.openBottle}}snapshot(){return{scene:this.scene(),menuPosition:this.dismissMenuPosition}}closeMenu(){this.dismissMenuPosition=null,this.refresh()}}})))()}function yt(e,t){for(let n=1;n<=24;n++){let r=A(e+n*7919>>>0);if(r.palette.id!==t)return r}return A(e+1>>>0)}function Y(e,t,n,r){return[Te(e),`--lob-scale:${t}`,`--lob-x:${n}%`,`--lob-face:${r}`].join(`;`)}function bt(e){return S(_,{get when(){return e.scene},children:e=>S(St,g(e))})}function xt(e){let t=le(()=>{let t=e,n=e.twin,r=t.scene[t.anchor]??t.scene.top,i=t.anniversary&&t.look.accessory!==`party`?{...t.look,accessory:`party`}:t.look,a=[`lobster-pet`,`lobster-pet--${t.mode}`,`lobster-pet--palette-${t.look.palette.id}`,n?`lobster-pet--twin`:``,i.accessory===`party`?`lobster-pet--party`:``,t.look.shiny?`lobster-pet--shiny`:``,t.elder?`lobster-pet--elder`:``,t.presence===`leaving`?`lobster-pet--away`:``,t.entering?`lobster-pet--entering`:``,t.entering&&t.entrance!==`walk`?`lobster-pet--enter-${t.entrance}`:``,t.grumpy?`lobster-pet--grumpy`:``,t.vigil?`lobster-pet--vigil`:``,t.act?`lobster-pet--act-${t.act}`:``],o=q(r,t.spotPct);n&&(o.x=Math.max(r.start,Math.min(r.end,o.x-t.facing*28)));let s=n?t.look.scale*.55:t.look.scale,c=`${Y(t.look,s,t.spotPct,t.facing)};--lob-x:${o.x}px;--lob-y:${o.y}px${n?`;--lob-act-delay:0.18s`:``}`,l=t.travel,u=l?`--lob-from-x:${l.from.x-l.to.x}px;--lob-from-y:${l.from.y-l.to.y}px;--lob-travel-ms:${lt(l)}ms${n?`;animation-delay:0.18s`:``}`:``,d=Le(t.familiarityVisits),f=t.nameOverride??D(t.look,t.seed),p=d?`${d} ${f}`:f,m=t.look.shiny?`✦ ${p}`:p,h=t.movingDay&&!n;return{dressed:i,classes:a,style:c,travel:l,travelStyle:u,bindle:h,title:n?`${m} Jr.`:h?`${m} · just moved in`:t.flavor?`${m} · ${t.flavor}`:m}});var n=Dt(),r=n.firstChild,i=r.firstChild,a=i.firstChild,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling;return r._$$contextmenu=t=>e.onContextMenu(t),r.addEventListener(`pointerleave`,()=>e.onPointerCancel()),r.addEventListener(`pointercancel`,()=>e.onPointerCancel()),r._$$pointerup=t=>e.onPointerUp(t),r._$$pointerdown=t=>{t.button===2&&t.preventDefault(),e.onPointerDown(t)},he(()=>t=>{e.twin||e.onSprite?.(t)},r),y(i,S(k,{get look(){return t().dressed},get grumpy(){return e.grumpy},get bindle(){return t().bindle},get sailorCap(){return e.sailorDay}}),a),y(i,S(_,{get when(){return b(()=>!!e.entering)()?e.entrance===`balloon`:e.entering},get children(){return S(xe,{})}}),o),y(i,S(_,{get when(){return b(()=>!!e.entering)()?e.entrance===`bubble`:e.entering},get children(){return wt()}}),s),y(i,S(_,{get when(){return e.look.shiny},get children(){return[Tt(),Et()]}}),c),C(()=>({e:T([`lobster-pet__motion`,t().travel&&`lobster-pet__motion--${t().travel?.hop?`hop`:`walk`}`]),t:T(t().travelStyle),a:T(t().classes),o:T(t().style),i:t().title}),({e,t,a:i,o:a,i:o},s)=>{w(n,e,s?.e),v(n,t,s?.t),w(r,i,s?.a),v(r,a,s?.o),o!==s?.i&&x(r,`title`,o)}),n}function St(e){let t=le(()=>{let t=e.residentEnabled&&e.presence!==`out`,n=e.residentEnabled&&e.shellVisible&&e.visitsEnabled&&!e.dismissed&&(e.shellAnchor===`top`||e.floorEnabled&&e.scene.floor!==null),r=e.passer&&!te(e.passer.kind)?e.critterArtwork?.[e.passer.kind]:void 0,i=e.passer?.kind===`stranger`&&!r,a=e.passer!==null&&e.visitsEnabled&&(e.residentEnabled||!i)&&!e.dismissed&&(e.passer.anchor===`top`||e.floorEnabled&&e.scene.floor!==null),o=e.bottle!==null&&e.visitsEnabled&&!e.dismissed,s=Y(e.look,e.shellScale,e.shellSpotPct,e.facing),c=q(e.scene[e.shellAnchor],e.shellSpotPct),l=i?yt(e.seed,e.look.palette.id):e.look,u=e.passer?[`lobster-pet lobster-pet--passer`,i?`lobster-pet--palette-${l.palette.id}`:`lobster-pet--${e.passer.kind}`,i&&l.shiny?`lobster-pet--shiny`:``,e.passer.direction===1?`lobster-pet--passer-ltr`:`lobster-pet--passer-rtl`,e.passer.hops&&e.scene.passage?`lobster-pet--passer-hop`:``]:``,d=e.passer?e.scene[e.passer.anchor]:null,f=e.passer?.hops&&e.scene.passage?e.scene.passage:[d?.start??0,d?.end??0],p=e.passer?.direction===1?f[0]:f[1],m=e.passer?.direction===1?f[1]:f[0];return{showSprites:t,showShell:n,showPasser:a,showBottle:o,shellStyle:s,shellPoint:c,passerLook:l,passerArtwork:r,stranger:i,passerClasses:u,passerStyle:e.passer?`${Ct(e.passer.kind,e.passer.direction,l,!!r)};--lob-cross:${e.passer.crossMs}ms;--lob-cross-from:${p}px;--lob-cross-to:${m}px;--lob-y:${d?.y??0}px`:``,passerSprite:e.passer&&Object.hasOwn(X,e.passer.kind)?X[e.passer.kind]:void 0,passerTitle:e.passer&&Object.hasOwn(Z,e.passer.kind)?Z[e.passer.kind]:void 0,bottlePoint:q(e.scene.top,e.bottle?.spotPct??50)}}),n=pe(()=>t().passerSprite);return S(_,{get when(){return e.scene.top},get children(){return[S(_,{get when(){return t().showShell},get children(){var n=Ot(),r=n.firstChild;return y(r,S(k,{get look(){return e.look},shell:!0})),C(()=>`${t().shellStyle};--lob-x:${t().shellPoint.x}px;--lob-y:${t().shellPoint.y}px`,(e,t)=>{v(n,e,t)}),n}}),S(_,{get when(){return b(()=>!!t().showBottle)()?e.bottle:t().showBottle},children:n=>(()=>{var r=At();return r._$$pointerdown=()=>e.onBottleOpen(),y(r,S(Oe,{get opened(){return n().opened}})),C(()=>({e:!!n().opened,t:`--lob-x:${t().bottlePoint.x}px`,a:n().opened?n().fortune:`a message in a bottle`}),({e,t,a:n},i)=>{e!==i?.e&&r.classList.toggle(`lobster-bottle--open`,e),v(r,t,i?.t),n!==i?.a&&x(r,`title`,n)}),r})()}),S(_,{get when(){return t().showSprites},get children(){return S(xt,g(e,{twin:!1}))}}),S(_,{get when(){return b(()=>!!t().showSprites)()?e.twinPlanned:t().showSprites},get children(){return S(xt,g(e,{twin:!0}))}}),S(_,{get when(){return t().showPasser},get children(){var r=kt(),i=r.firstChild;return y(i,S(_,{get when(){return t().passerArtwork},get fallback(){return S(_,{get when(){return t().stranger},get fallback(){return S(n,{})},get children(){return S(k,{get look(){return t().passerLook},standalone:!0})}})},children:e=>S(f,{get url(){return e().url},class:`lobster-pet__svg`})})),C(()=>({e:T(t().passerClasses),t:T(t().passerStyle),a:t().passerArtwork?.title??t().passerTitle??e.passer?.kind}),({e,t,a:n},i)=>{w(r,e,i?.e),v(r,t,i?.t),n!==i?.a&&x(r,`title`,n)}),r}})]}})}function Ct(e,t,n,r){if(r)return`--lob-scale:1.8;--lob-w:1;--lob-h:1;--lob-face:${t}`;if(e===`stranger`)return Y(n,Math.min(n.scale,2),0,t);if(te(e))return m(e,t);let i={crab:`--lob-scale:2;--lob-w:1;--lob-h:0.82;--lob-face:1`,snail:`--lob-scale:1.7;--lob-w:1;--lob-h:0.9;--lob-face:${t}`,duck:`--lob-scale:1.9;--lob-w:1;--lob-h:1;--lob-face:${t}`,jellyfish:`--lob-scale:1.7;--lob-w:0.9;--lob-h:1.1;--lob-face:1`};return(Object.hasOwn(i,e)?i[e]:void 0)??`--lob-scale:1.8;--lob-w:1;--lob-h:1;--lob-face:${t}`}var wt,Tt,Et,Dt,Ot,kt,At,X,Z;function jt(){return(jt=e((()=>{ve(),de(),ie(),P(),we(),M(),J(),ke(),d(),se(),wt=E(`<span class=lobster-pet__entry-bubble>`),Tt=E(`<span class=lobster-pet__sparkle style=--i:0;left:12%;bottom:64%>✦`),Et=E(`<span class=lobster-pet__sparkle style=--i:1;left:76%;bottom:82%>✦`),Dt=E(`<div><div aria-hidden=true><div class=lobster-pet__body><!><!><!><span class=lobster-pet__z style=--i:0>z</span><span class=lobster-pet__z style=--i:1>z</span><span class=lobster-pet__z style=--i:2>Z</span><span class=lobster-pet__bubble style=--i:0></span><span class=lobster-pet__bubble style=--i:1></span><span class=lobster-pet__bubble style=--i:2></span><span class=lobster-pet__heart>♥</span><svg class=lobster-pet__broom viewBox="0 0 24 40"aria-hidden=true><path d="M12 2 L12 24"stroke=#8a5a2b stroke-width=3 stroke-linecap=round></path><path d="M6 24 L18 24 L21 38 L3 38 Z"fill=#e8b04b></path><path d="M7.5 28 L6.5 36 M12 28 L12 36 M16.5 28 L17.5 36"stroke=#b6791f stroke-width=1.5>`),Ot=E(`<div class="lobster-pet lobster-pet--shell"aria-hidden=true><div class=lobster-pet__body>`),kt=E(`<div aria-hidden=true><div class=lobster-pet__body>`),At=E(`<div class=lobster-bottle aria-hidden=true>`),X={...Ae,...ce},Z={...Se,...ne},_e([`pointerdown`,`pointerup`,`contextmenu`])})))()}var Mt,Nt,Q,$,Pt;function Ft(){return(Ft=e((()=>{ve(),de(),u(),re(),p(),vt(),jt(),ae(),c(),Mt=E(`<div class=lobster-pet-dismiss-menu style="position:fixed;right:1rem;bottom:1rem;width:min(320px, calc(100vw - 2rem));z-index:var(--z-dropdown)">`),Nt=fe(()=>s(()=>import(`./lobster-pet-dismiss-menu-Cf-p9Ys3.js`),__vite__mapDeps([0,1]),import.meta.url),{export:`LobsterPetDismissMenu`},`src/components/lobster-pet-dismiss-menu.tsx`),Q=new WeakMap,$=new WeakMap,Pt=h(`openclaw-lobster-pet`,(e,t)=>{let n=Q.get(t)??new _t(t,()=>t.visitsEnabled=!1,e);Q.set(t,n);let r=ee(n,e=>e.snapshot()).read;return me(()=>{let r=!0,i=!1;return $.set(t,()=>{i||(i=!0,me(()=>{i=!1,r&&n.update({...e})}))}),n.connect(),n.update({...e}),()=>{r=!1,$.delete(t),n.dispose()}}),[S(bt,{get scene(){return r().scene}}),S(_,{get when(){return r().menuPosition},children:e=>S(ue,{fallback:(e,t)=>S(ge,{get children(){var r=Mt();return y(r,S(oe,{get error(){return e()},get subtitle(){return l(`quickSettings.appearance.lobsterVisits`)},onRetry:()=>t(),onClose:()=>n.closeMenu(),inline:!0})),r}}),get children(){return S(ye,{get children(){return S(Nt,{get position(){return e()},onDismiss:e=>n.dismiss(e),onClose:()=>n.closeMenu()})}})}})})]},{propertyChanged:e=>$.get(e)?.(),properties:{composerElements:{default:void 0,attribute:!1},seed:{default:0,attribute:!1},mode:{default:`idle`,attribute:!1},visitsEnabled:{default:!0,attribute:!1},residentEnabled:{default:!0,attribute:!1},critters:{default:void 0,attribute:!1},critterArtwork:{default:void 0,attribute:!1},floorEnabled:{default:!1,attribute:!1},runOutcome:{default:`ok`,attribute:!1},soundsEnabled:{default:!1,attribute:!1},gatewayVersion:{default:null,attribute:!1},onVisitsDisabled:{default:()=>void 0,attribute:!1}}})})))()}Ft();export{Pt as LobsterPet};