1import{s as Pt,d as u,E as lt,v as c,i as F,_ as Mt,y as oe,g as n,I as Te,M as Oe,w as Vt,j as v,z as de,c as P,k as V,e as qe,l as g,a as M,o as Ft,S as Ot,u as Dt,J as Lt,n as ve,p as Y,q as X,m as it,a0 as Ze,K as He,h as ke}from"../chunks/scheduler.Dx9oPxnj.js";import{S as At,i as Rt,t as Fe,a as we,c as Xe,h as Ee,j as Nt,g as Ge}from"../chunks/index.UWqWY8CY.js";import{g as Ut}from"../chunks/globals.D0QH3NT1.js";import{e as Pe,u as $e,d as et}from"../chunks/each.LO-GNxEs.js";import{c as Wt}from"../chunks/regl.B9DaSrtT.js";import{h as je,m as Bt,b as jt,j as zt}from"../chunks/handShaders.BZiwU8Qu.js";import{d as Yt}from"../chunks/drawHand.BLuL7IXO.js";import{d as rt,s as nt,f as Me}from"../chunks/index.Cxy3N2Il.js";import{c as Xt}from"../chunks/index.CvmYViMX.js";const Gt=()=>({seo:{title:"Forgotten Dreams Display",description:"Display mode for Webpage of Forgotten Dreams.",imagePath:"/imgs/thumbnails/hands-preview.webp",type:"article"}}),Rs=Object.freeze(Object.defineProperty({__proto__:null,load:Gt},Symbol.toStringTag,{value:"Module"})),ze=2048,Ye=1536;class Jt{mainCanvas;backgroundCanvas;handCanvas;maskBlurCanvas=null;maskBlurCtx=null;bgCtx;handCtx;regl=null;handTexture=null;fbo1=null;fbo2=null;hands=null;camera=null;videoElement=null;caveWall=null;width=0;height=0;handVisible=!1;lastHandVisible=!1;handX=0;handY=0;handWidth=0;handPositions=[];maxHands=2;worldHeight;transparentBackground=!1;_shaderIndex=1;needsFrame=!1;callbacks;config;destroyed=!1;frameCancel=null;constructor(e,t,s,i={},l={}){this.mainCanvas=e,this.backgroundCanvas=t,this.handCanvas=s,this.callbacks=i,this.config=l,this.maxHands=l.maxHands??2,this.worldHeight=l.worldHeight,this.transparentBackground=l.transparentBackground??!1,this.bgCtx=t.getContext("2d"),this.handCtx=s.getContext("2d"),this.handCanvas.width=ze,this.handCanvas.height=Ye,this.handCtx.imageSmoothingEnabled=!0,this.handCtx.imageSmoothingQuality="high",this.maskBlurCanvas=document.createElement("canvas"),this.maskBlurCanvas.width=ze,this.maskBlurCanvas.height=Ye,this.maskBlurCtx=this.maskBlurCanvas.getContext("2d")}get shaderIndex(){return this._shaderIndex}set shaderIndex(e){this._shaderIndex=this.normalizeShaderIndex(e)}get shaderCount(){return je.length}normalizeShaderIndex(e){return(e%je.length+je.length)%je.length}get isHandVisible(){return this.handVisible}get handPosition(){return{x:this.handX,y:this.handY,visible:this.handVisible,width:this.handWidth,id:0}}get allHandPositions(){return this.handPositions}resolveCanvasSize(e,t){if(!this.worldHeight)return{width:e,height:t};if(t<=0)return{width:e,height:this.worldHeight};const s=e/t;return{width:Math.max(1,Math.round(this.worldHeight*s)),height:this.worldHeight}}async init(e,t){const s=this.resolveCanvasSize(e,t);this.width=s.width,this.height=s.height,this.backgroundCanvas.width=s.width,this.backgroundCanvas.height=s.height,this.mainCanvas.width=s.width,this.mainCanvas.height=s.height,this.transparentBackground?this.clearBackgroundLayer():await this.loadCaveWall(),this.regl=Wt({canvas:this.mainCanvas,extensions:["OES_texture_float"],optionalExtensions:["oes_texture_float_linear"]}),this.fbo1=this.regl.framebuffer({width:ze,height:Ye,depthStencil:!1,colorType:"float"}),this.fbo2=this.regl.framebuffer({width:ze,height:Ye,depthStencil:!1,colorType:"float"}),this.handTexture=this.regl.texture({data:this.handCanvas,min:"linear",mag:"linear"}),this.startRenderLoop(),await this.startTrackingHands()}async loadCaveWall(){return new Promise(e=>{this.caveWall=new Image,this.caveWall.src="/imgs/cave-wall-2x.jpg",this.caveWall.onload=()=>{this.drawCaveWall(),e()}})}drawCaveWall(){if(this.transparentBackground){this.clearBackgroundLayer();return}if(!this.caveWall)return;const e=Math.max(this.width/this.caveWall.width,this.height/this.caveWall.height),t=this.caveWall.width*e,s=this.caveWall.height*e,i=(this.width-t)/2,l=(this.height-s)/2;this.bgCtx.drawImage(this.caveWall,i,l,t,s)}clearBackgroundLayer(){this.bgCtx.clearRect(0,0,this.width,this.height)}resize(e,t){const s=this.resolveCanvasSize(e,t);this.width=s.width,this.height=s.height,this.backgroundCanvas.width=s.width,this.backgroundCanvas.height=s.height,this.mainCanvas.width=s.width,this.mainCanvas.height=s.height,this.drawCaveWall()}get worldWidth(){return this.width}get worldHeightPx(){return this.height}clear(){this.drawCaveWall()}captureFrame(){this.needsFrame=!0}redrawCaveWall(){this.drawCaveWall()}
1getBackgroundContext(){return this.bgCtx}startRenderLoop(){if(!this.regl)return;const e=Bt(this.regl),t=jt(this.regl),s=zt(this.regl);this.frameCancel=this.regl.frame(()=>{if(!(this.destroyed||!this.backgroundCanvas||!this.fbo1||!this.fbo2||!this.handTexture))try{if(this.handVisible||this.lastHandVisible){this.handTexture.subimage(this.handCanvas),t({maskTexture:this.handTexture,framebuffer:this.fbo1});let i=this.fbo1,l=this.fbo2,o=Math.floor(Math.max(ze,Ye)/2);for(;o>=1;)s({prevPass:i,framebuffer:l,stepSize:o}),[i,l]=[l,i],o=Math.floor(o/2);e({fragmentShader:je[this._shaderIndex],distanceTexture:i,distanceScale:Math.max(8.5,1.5/this.handWidth),handX:this.handX,handY:this.handY})}this.lastHandVisible=this.handVisible,this.needsFrame&&(this.needsFrame=!1,this.bgCtx.drawImage(this.mainCanvas,0,0,this.width,this.height),this.callbacks.onFrameCaptured?.())}catch(i){console.error("Render error:",i)}})}async startTrackingHands(){this.hands=new window.Hands({locateFile:e=>`https://cdn.jsdelivr.net/npm/@mediapipe/hands/${e}`}),this.hands.setOptions({maxNumHands:this.maxHands,modelComplexity:1,minDetectionConfidence:.7,minTrackingConfidence:.7}),this.hands.onResults(this.handleResults.bind(this)),await this.hands.initialize(),this.callbacks.onHandsLoaded?.(),this.videoElement=document.createElement("video"),this.camera=new window.Camera(this.videoElement,{onFrame:async()=>{this.destroyed||await this.hands.send({image:this.videoElement})},width:1024,height:768}),this.camera.start()}handleResults(e){if(this.handCtx){if(this.handVisible=e.multiHandLandmarks.length>0,this.handPositions=[],this.handCtx.save(),this.handCtx.scale(-1,-1),this.handCtx.translate(-this.handCanvas.width,-this.handCanvas.height),this.handCtx.fillStyle="black",this.handCtx.fillRect(0,0,this.handCanvas.width,this.handCanvas.height),this.handCtx.fillStyle="white",this.handCtx.fillRect(0,1,this.handCanvas.width,this.handCanvas.height-2),e.multiHandLandmarks)for(let t=0;t<e.multiHandLandmarks.length;t++){const s=e.multiHandLandmarks[t],i=.25,l=.2,o=s.map(k=>{const T=s[0].x,x=s[0].y;return{x:T+(k.x-T)*i,y:x+(k.y-x)*i-l,z:k.z*i}}),h=o[0],f=o[5],_=Math.hypot(h.x-f.x,h.y-f.y),C=[0,1,2,5,9,13,17],L=1-C.reduce((k,T)=>k+o[T].x,0)/C.length,y=1-C.reduce((k,T)=>k+o[T].y,0)/C.length;t===0&&(this.handX=L,this.handY=y,this.handWidth=_),this.handPositions.push({x:L,y,visible:!0,width:_,id:t}),Yt(this.handCtx,o,"black")}this.handCtx.restore(),this.callbacks.onHandUpdate?.({x:this.handX,y:this.handY,visible:this.handVisible,width:this.handWidth,id:0}),this.callbacks.onHandsUpdate?.(this.handPositions)}}destroy(){this.destroyed||(this.destroyed=!0,this.frameCancel&&(this.frameCancel.cancel(),this.frameCancel=null),this.fbo1&&(this.fbo1.destroy(),this.fbo1=null),this.fbo2&&(this.fbo2.destroy(),this.fbo2=null),this.handTexture&&(this.handTexture.destroy(),this.handTexture=null),this.camera&&(this.camera.stop(),this.camera=null),this.hands&&(this.hands.close(),this.hands=null),this.regl&&(this.regl.destroy(),this.regl=null))}}const Kt={holdDuration:3e3,stillThreshold:.025,resetThreshold:.1,smoothingFactor:.25};class Qt{config;smoothedX=0;smoothedY=0;hasInitialized=!1;holdStartTime=null;anchorX=0;anchorY=0;isLockedOut=!1;lockoutAnchorX=0;lockoutAnchorY=0;constructor(e={}){this.config={...Kt,...e}}update(e,t,s){const i=performance.now();if(!s)return this.holdStartTime=null,{isHolding:!1,holdProgress:0,shouldStamp:!1,isLockedOut:this.isLockedOut,smoothedPosition:{x:this.smoothedX,y:this.smoothedY}};this.hasInitialized||(this.smoothedX=e,this.smoothedY=t,this.hasInitialized=!0);const l=this.config.smoothingFactor;if(this.smoothedX=l*e+(1-l)*this.smoothedX,this.smoothedY=l*t+(1-l)*this.smoothedY,this.isLockedOut&&Math.hypot(this.smoothedX-this.lockoutAnchorX,this.smoothedY-this.lockoutAnchorY)>this.config.resetThreshold&&(this.isLockedOut=!1),this.isLockedOut)return{isHolding:!1,holdProgress:0,shouldStamp:!1,isLockedOut:!0,smoothedPosition:{x:this.smoothedX,y:this.smoothedY}};this.holdStartTime!==null&&Math.hypot(this.smoothedX-this.anchorX,this.smoothedY-this.anchorY)>this.config.stillThreshold&&(this.holdStartTime=null),this.holdStartTime===null&&(this.holdStartTime=i,this.anchorX=this.smoothedX,this.anchorY=this.smoothedY);const o=i-this.holdStartTime,h=Math.min(1,o/this.config.holdDuration),f=h>=1;return f&&(this.isLockedOut=!0,this.lockoutAnchorX=this.smoothedX,this.lockoutAnchorY=this.smoothedY,this.holdStartTime=null),{isHolding:h>0&&h<1,holdProgress:f?0:h,shouldStamp:f,isLockedOut:this.isLockedOut,smoothedPosition:{x:this.smoothedX,y:this.smoothedY}}}reset(){this.holdStartTime=null,this.isLockedOut=!1,this.hasInitialized=!1}setConfig(e){this.config={...this.config,...e}}}const Je="forgotten-dreams-viewport-v2",tt="forgotten-dreams-meta-v2",Zt=.9,$t=.6,es="image/webp",ts="webp",ss=.92,as=typeof import.meta<"u"&&!1;function ls(a){if(!(a instanceof Error))return!1;const e=a.name,t=a.code;return e==="QuotaExceededError"||e==="NS_ERROR_DOM_QUOTA_REACHED"||t===22||t===1014}function is(a){return new Promise((e,t)=>
1{const s=new FileReader;s.onload=()=>e(s.result),s.onerror=()=>t(s.error),s.readAsDataURL(a)})}async function ns(a){if(typeof localStorage>"u")return;const e={width:a.width,height:a.height,savedAt:Date.now()};try{localStorage.removeItem(Je),localStorage.removeItem(tt)}catch{}await ot(a,Zt,e)||await ot(a,$t,e)||console.warn("[persistence] viewport too large to save - clear other localStorage data on this origin or lower VIEWPORT_QUALITY")}async function ot(a,e,t){const s=await Ht(a,"image/webp",e);if(!s)return!1;let i;try{i=await is(s)}catch(l){return console.warn("[persistence] blob->dataURL failed:",l),!1}try{return localStorage.setItem(Je,i),localStorage.setItem(tt,JSON.stringify(t)),!0}catch(l){if(ls(l)){try{localStorage.removeItem(Je)}catch{}return!1}return console.warn("[persistence] saveViewport failed:",l),!1}}async function rs(){if(typeof localStorage>"u")return null;const a=localStorage.getItem(Je),e=localStorage.getItem(tt);if(!a||!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return new Promise(s=>{const i=new Image;i.onload=()=>s({image:i,meta:t}),i.onerror=()=>{console.warn("[persistence] failed to decode saved viewport"),s(null)},i.src=a})}function os(){typeof localStorage>"u"||(localStorage.removeItem(Je),localStorage.removeItem(tt))}const xt="/api/cave-slices";async function hs(){try{const a=await fetch(xt);return a.ok?(await a.json()).slices??[]:[]}catch(a){return console.warn("[persistence] fetchSlices failed:",a),[]}}async function cs(a){const e=await Ht(a,es,ss);if(!e)return null;const t=`${Date.now()}.${ts}`,s=new FormData;s.append("file",e,t);try{const i=await fetch(xt,{method:"POST",body:s});return i.ok?(await i.json()).url:(console.warn("[persistence] uploadSlice HTTP",i.status),null)}catch(i){return console.warn("[persistence] uploadSlice failed:",i),null}}function Ht(a,e,t){return new Promise(s=>{a.toBlob(i=>s(i),e,t)})}class ds{w;h;mode;pixelDeltaThreshold;alphaThreshold;referenceData=null;scratch;scratchCtx;constructor(e={}){this.w=e.width??128,this.h=e.height??72,this.mode=e.mode??"alpha",this.pixelDeltaThreshold=e.pixelDeltaThreshold??60,this.alphaThreshold=e.alphaThreshold??32,this.scratch=document.createElement("canvas"),this.scratch.width=this.w,this.scratch.height=this.h,this.scratchCtx=this.scratch.getContext("2d",{willReadFrequently:!0})}calibrate(e){this.mode==="rgb"&&(this.scratchCtx.clearRect(0,0,this.w,this.h),this.scratchCtx.drawImage(e,0,0,this.w,this.h),this.referenceData=this.scratchCtx.getImageData(0,0,this.w,this.h).data)}isCalibrated(){return this.mode==="alpha"||this.referenceData!==null}measure(e){this.scratchCtx.clearRect(0,0,this.w,this.h),this.scratchCtx.drawImage(e,0,0,this.w,this.h);const t=this.scratchCtx.getImageData(0,0,this.w,this.h).data,s=this.w*this.h;if(this.mode==="alpha"){let h=0;const f=this.alphaThreshold;for(let _=3;_<t.length;_+=4)t[_]>f&&h++;return h/s}if(!this.referenceData)return 0;const i=this.referenceData,l=this.pixelDeltaThreshold;let o=0;for(let h=0;h<t.length;h+=4){const f=Math.abs(t[h]-i[h]),_=Math.abs(t[h+1]-i[h+1]),C=Math.abs(t[h+2]-i[h+2]);f+_+C>l&&o++}return o/s}}function us(a){return a<.5?4*a*a*a:1-Math.pow(-2*a+2,3)/2}function fs(a,e){const t=a.getContext("2d");if(!t)return Promise.resolve();const{shiftPx:s,durationMs:i=600,resetBackground:l,onComplete:o}=e,h=document.createElement("canvas");h.width=a.width,h.height=a.height;const f=h.getContext("2d");return f?(f.drawImage(a,0,0),new Promise(_=>{const C=performance.now();function L(y){const k=Math.min(1,(y-C)/i),x=-us(k)*s;l(),t.drawImage(h,x,0),k<1?requestAnimationFrame(L):(l(),t.drawImage(h,-s,0),o?.(),_())}requestAnimationFrame(L)})):Promise.resolve()}function ms(a,e){const t=Math.min(e,a.width),s=document.createElement("canvas");s.width=t,s.height=a.height;const i=s.getContext("2d");return i&&i.drawImage(a,0,0,t,a.height,0,0,t,a.height),s}const{Map:st,document:Ve}=Ut;function ht(a,e,t){const s=a.slice();s[59]=e[t];const i=s[13].get(s[59].id);return s[60]=i,s}function ct(a,e,t){const s=a.slice();s[59]=e[t];const i=s[13].get(s[59].id);s[60]=i;const l=s[22](s[60]?.smoothedPosition??s[59]);s[63]=l;const o=s[59].width*Math.min(s[3],s[4])*2.5;s[64]=o;const h=Math.max(60,s[64]+20);s[65]=h;const f=Math.max(80,Math.min(200,s[64]*1.5));return s[66]=f,s}function dt(a,e,t){const s=a.slice();return s[69]=e[t],s}function ut(a,e,t){const s=a.slice();return s[69]=e[t],s}function ft(a){let e,t='<div class="text-white/80 text-2xl drop-shadow-lg uppercase tracking-widest svelte-1aqs384">cave painting movingâ¦</div>',s,i;return{c(){e=g("div"),e.innerHTML=t,this.h()},l(l){e=v(l,"DIV",{class:!0,"data-svelte-h":!0}),de(e)!=="svelte-11dyijt"&&(e.innerHTML=t),this.h()},h(){n(e,"class","fixed inset-0 flex items-center justify-center pointer-events-none z-50 svelte-1aqs384")},m(l,o){F(l,e,o),i=!0},i(l){i||(l&&Oe(()=>
1{i&&(s||(s=Ee(e,Me,{duration:200},!0)),s.run(1))}),i=!0)},o(l){l&&(s||(s=Ee(e,Me,{duration:200},!1)),s.run(0)),i=!1},d(l){l&&u(e),l&&s&&s.end()}}}function mt(a,e){let t,s,i;return{key:a,first:null,c(){t=g("img"),this.h()},l(l){t=v(l,"IMG",{class:!0,src:!0,alt:!0,loading:!0}),this.h()},h(){n(t,"class","panorama-slice svelte-1aqs384"),Te(t.src,s=e[69])||n(t,"src",s),n(t,"alt",""),n(t,"loading","lazy"),this.first=t},m(l,o){F(l,t,o)},p(l,o){e=l,o[0]&512&&!Te(t.src,s=e[69])&&n(t,"src",s)},i(l){l&&(i||Oe(()=>{i=Nt(t,nt,{duration:600,axis:"x",easing:Xt}),i.start()}))},o:Dt,d(l){l&&u(t)}}}function vt(a){let e,t;return{c(){e=g("img"),this.h()},l(s){e=v(s,"IMG",{class:!0,src:!0,alt:!0}),this.h()},h(){n(e,"class","panorama-slice panorama-live svelte-1aqs384"),Te(e.src,t=a[10])||n(e,"src",t),n(e,"alt","")},m(s,i){F(s,e,i)},p(s,i){i[0]&1024&&!Te(e.src,t=s[10])&&n(e,"src",t)},d(s){s&&u(e)}}}function gt(a){let e,t,s,i,l,o,h,f,_,C,L,y="Ã",k,T,x,w=[],d=new st,b,N,z,R=a[9].length+"",I,W,$=a[9].length===1?"":"s",B,re,ee=a[10]?"+ live":"",G,E,D,O,H,K;function ue(p,r){return p[17]==="black"?gs:vs}let A=ue(a),se=A(a);function ge(p,r){return p[17]==="wall"?_s:ps}let Q=ge(a),q=Q(a),he=Pe(a[9]);const be=p=>p[69];for(let p=0;p<he.length;p+=1){let r=dt(a,he,p),m=be(r);d.set(m,w[p]=pt(m,r))}let U=a[10]&&_t(a);return{c(){e=g("div"),t=g("button"),s=M(),i=g("div"),l=g("button"),se.c(),h=M(),f=g("button"),q.c(),C=M(),L=g("button"),L.textContent=y,k=M(),T=g("div"),x=g("div");for(let p=0;p<w.length;p+=1)w[p].c();b=M(),U&&U.c(),N=M(),z=g("div"),I=X(R),W=X(" slice"),B=X($),re=M(),G=X(ee),E=X(" · click outside or press Esc to close"),this.h()},l(p){e=v(p,"DIV",{class:!0,role:!0,"aria-modal":!0,"aria-label":!0});var r=V(e);t=v(r,"BUTTON",{type:!0,class:!0,"aria-label":!0}),V(t).forEach(u),s=P(r),i=v(r,"DIV",{class:!0});var m=V(i);l=v(m,"BUTTON",{type:!0,class:!0,"aria-label":!0});var Z=V(l);se.l(Z),Z.forEach(u),h=P(m),f=v(m,"BUTTON",{type:!0,class:!0,"aria-label":!0});var pe=V(f);q.l(pe),pe.forEach(u),C=P(m),L=v(m,"BUTTON",{type:!0,class:!0,"aria-label":!0,"data-svelte-h":!0}),de(L)!=="svelte-12wq91n"&&(L.textContent=y),m.forEach(u),k=P(r),T=v(r,"DIV",{class:!0});var fe=V(T);x=v(fe,"DIV",{class:!0});var _e=V(x);for(let De=0;De<w.length;De+=1)w[De].l(_e);b=P(_e),U&&U.l(_e),_e.forEach(u),fe.forEach(u),N=P(r),z=v(r,"DIV",{class:!0});var ie=V(z);I=Y(ie,R),W=Y(ie," slice"),B=Y(ie,$),re=P(ie),G=Y(ie,ee),E=Y(ie," · click outside or press Esc to close"),ie.forEach(u),r.forEach(u),this.h()},h(){n(t,"type","button"),n(t,"class","panorama-modal-backdrop svelte-1aqs384"),n(t,"aria-label","Close panorama"),n(l,"type","button"),n(l,"class","panorama-modal-action svelte-1aqs384"),l.disabled=o=a[17]!==null||a[9].length===0&&!a[10],n(l,"aria-label","Download panorama as JPEG on black background"),n(f,"type","button"),n(f,"class","panorama-modal-action panorama-modal-action-secondary svelte-1aqs384"),f.disabled=_=a[17]!==null||a[9].length===0&&!a[10],n(f,"aria-label","Download panorama as JPEG with cave wall background"),n(L,"type","button"),n(L,"class","panorama-modal-action panorama-modal-close svelte-1aqs384"),n(L,"aria-label","Close panorama"),n(i,"class","panorama-modal-actions svelte-1aqs384"),n(x,"class","panorama-modal-track svelte-1aqs384"),n(T,"class","panorama-modal-scroll svelte-1aqs384"),n(z,"class","panorama-modal-hint svelte-1aqs384"),n(e,"class","panorama-modal svelte-1aqs384"),n(e,"role","dialog"),n(e,"aria-modal","true"),n(e,"aria-label","Full panorama view")},m(p,r){F(p,e,r),c(e,t),c(e,s),c(e,i),c(i,l),se.m(l,null),c(i,h),c(i,f),q.m(f,null),c(i,C),c(i,L),c(e,k),c(e,T),c(T,x);for(let m=0;m<w.length;m+=1)w[m]&&w[m].m(x,null);c(x,b),U&&U.m(x,null),c(e,N),c(e,z),c(z,I),c(z,W),c(z,B),c(z,re),c(z,G),c(z,E),O=!0,H||(K=[oe(t,"click",a[27]),oe(l,"click",a[28]),oe(f,"click",a[29]),oe(L,"click",a[30])],H=!0)},p(p,r){A!==(A=ue(p))&&(se.d(1),se=A(p),se&&(se.c(),se.m(l,null))),(!O||r[0]&132608&&o!==(o=p[17]!==null||p[9].length===0&&!p[10]))&&(l.disabled=o),Q!==(Q=ge(p))&&(q.d(1),q=Q(p),q&&(q.c(),q.m(f,null))),(!O||r[0]&132608&&_!==(_=p[17]!==null||p[9].length===0&&!p[10]))&&(f.disabled=_),r[0]&512&&(he=Pe(p[9]),w=$e(w,r,be,1,p,he,d,x,et,pt,b,dt)),p[10]?U?U.p(p,r):(U=_t(p),U.c(),U.m(x,null)):U&&(U.d(1),U=null),(!O||r[0]&512)&&R!==(R=p[9].length+"")&&ve(I,R),(!O||r[0]&512)&&$!==($=p[9].length===1?"":"s")&&ve(B,$),(!O||r[0]&1024)&&ee!==(ee=p[10]?"+ live":"")&&ve(G,ee)},i(p){O||(p&&Oe(()=>{O&&(D||(D=Ee(e,Me,{duration:220},!0)),D.run(1))}),O=!0)},o(p){p&&(D||(D=Ee(e,Me,{duration:220},!1)),D.run(0)),O=!1},d(p){p&&u(e),se.d(),q.d();for(let r=0;r<w.length;r+=1)w[r].d();U&&U.d(),p&&D&&D.end(),H=!1,Lt(K)}}}function vs(a){let e;return{c(){e=X("JPEG (black)")},l(t){e=Y(t,"JPEG (black)")},m(t,s){F(t,e,s)},d(t){t&&u(e)}}}function gs(a){let e;return{c(){e=X("Stitchingâ¦")},l(t){e=Y(t,"Stitchingâ¦")},m(t,s){F(t,e,s)},d(t){t&&u(e)}}}function ps(a){let e;return{c(){e=X("JPEG (wall)")},l(t){e=Y(t,"JPEG (wall)")},m(t,s){F(t,e,s)},d(t){t&&u(e)}}}function _s(a){let e;return{c(){e=X("Stitchingâ¦")},l(t){e=Y(t,"Stitchingâ¦")},m(t,s){F(t,e,s)},d(t){t&&u(e)}}}function pt(a,e){let t,s;return{key:a,first:null,c(){t=g("img"),this.h()},l(i){t=v(i,"IMG",{class:!0,src:!0,alt:!0,loading:!0}),this.h()},h(){n(t,"class","panorama-modal-slice svelte-1aqs384"),Te(t.src,s=e[69])||n(t,"src",s),n(t,"alt",""),n(t,"loading","lazy"),this.first=t},m(i,l){F(i,t,l)}
1,p(i,l){e=i,l[0]&512&&!Te(t.src,s=e[69])&&n(t,"src",s)},d(i){i&&u(t)}}}function _t(a){let e,t;return{c(){e=g("img"),this.h()},l(s){e=v(s,"IMG",{class:!0,src:!0,alt:!0}),this.h()},h(){n(e,"class","panorama-modal-slice panorama-modal-live svelte-1aqs384"),Te(e.src,t=a[10])||n(e,"src",t),n(e,"alt","")},m(s,i){F(s,e,i)},p(s,i){i[0]&1024&&!Te(e.src,t=s[10])&&n(e,"src",t)},d(s){s&&u(e)}}}function ws(a){let e,t,s=[],i=new st,l,o,h='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-1aqs384"><circle cx="12" cy="12" r="3" class="svelte-1aqs384"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" class="svelte-1aqs384"></path></svg>',f,_,C,L,y=!a[11]&&wt(),k=a[11]&&a[12].length===0&&bt(),T=Pe(a[12]);const x=d=>d[59].id;for(let d=0;d<T.length;d+=1){let b=ct(a,T,d),N=x(b);i.set(N,s[d]=Tt(N,b))}let w=a[15]&&It(a);return{c(){y&&y.c(),e=M(),k&&k.c(),t=M();for(let d=0;d<s.length;d+=1)s[d].c();l=M(),o=g("button"),o.innerHTML=h,f=M(),w&&w.c(),_=qe(),this.h()},l(d){y&&y.l(d),e=P(d),k&&k.l(d),t=P(d);for(let b=0;b<s.length;b+=1)s[b].l(d);l=P(d),o=v(d,"BUTTON",{class:!0,title:!0,"data-svelte-h":!0}),de(o)!=="svelte-74ny07"&&(o.innerHTML=h),f=P(d),w&&w.l(d),_=qe(),this.h()},h(){n(o,"class","settings-button svelte-1aqs384"),n(o,"title","Settings")},m(d,b){y&&y.m(d,b),F(d,e,b),k&&k.m(d,b),F(d,t,b);for(let N=0;N<s.length;N+=1)s[N]&&s[N].m(d,b);F(d,l,b),F(d,o,b),F(d,f,b),w&&w.m(d,b),F(d,_,b),C||(L=oe(o,"click",a[32]),C=!0)},p(d,b){d[11]?y&&(y.d(1),y=null):y||(y=wt(),y.c(),y.m(e.parentNode,e)),d[11]&&d[12].length===0?k||(k=bt(),k.c(),k.m(t.parentNode,t)):k&&(k.d(1),k=null),b[0]&4206616&&(T=Pe(d[12]),s=$e(s,b,x,1,d,T,i,l.parentNode,et,Tt,l,ct)),d[15]?w?(w.p(d,b),b[0]&32768&&we(w,1)):(w=It(d),w.c(),we(w,1),w.m(_.parentNode,_)):w&&(Ge(),Fe(w,1,1,()=>{w=null}),Xe())},d(d){d&&(u(e),u(t),u(l),u(o),u(f),u(_)),y&&y.d(d),k&&k.d(d);for(let b=0;b<s.length;b+=1)s[b].d(d);w&&w.d(d),C=!1,L()}}}function bs(a){let e,t='<h1 class="text-4xl text-center uppercase drop-shadow-lg svelte-1aqs384">This requires a desktop with a webcam</h1> <p class="text-xl text-center drop-shadow-lg svelte-1aqs384">Please visit on a desktop to create your own cave paintings</p>';return{c(){e=g("div"),e.innerHTML=t,this.h()},l(s){e=v(s,"DIV",{class:!0,"data-svelte-h":!0}),de(e)!=="svelte-q736eq"&&(e.innerHTML=t),this.h()},h(){n(e,"class","fixed top-0 left-0 w-full h-full p-8 text-white/80 bg-black/50 flex flex-col justify-center items-center gap-8 svelte-1aqs384")},m(s,i){F(s,e,i)},p:Dt,d(s){s&&u(e)}}}function wt(a){let e,t='<div class="text-white/60 text-3xl drop-shadow-lg animate-pulse svelte-1aqs384">Loading hand tracking...</div>';return{c(){e=g("div"),e.innerHTML=t,this.h()},l(s){e=v(s,"DIV",{class:!0,"data-svelte-h":!0}),de(e)!=="svelte-1uoyr64"&&(e.innerHTML=t),this.h()},h(){n(e,"class","fixed inset-0 flex items-center justify-center pointer-events-none svelte-1aqs384")},m(s,i){F(s,e,i)},d(s){s&&u(e)}}}function bt(a){let e,t='<div class="text-white/50 text-2xl drop-shadow-lg svelte-1aqs384">Show your hand to the camera</div>';return{c(){e=g("div"),e.innerHTML=t,this.h()},l(s){e=v(s,"DIV",{class:!0,"data-svelte-h":!0}),de(e)!=="svelte-1t7kr63"&&(e.innerHTML=t),this.h()},h(){n(e,"class","fixed inset-0 flex items-center justify-center pointer-events-none svelte-1aqs384")},m(s,i){F(s,e,i)},d(s){s&&u(e)}}}function kt(a){let e,t,s,i,l;return{c(){e=g("div"),t=g("div"),s=g("div"),this.h()},l(o){e=v(o,"DIV",{class:!0,style:!0});var h=V(e);t=v(h,"DIV",{class:!0,style:!0});var f=V(t);s=v(f,"DIV",{class:!0,style:!0}
1),V(s).forEach(u),f.forEach(u),h.forEach(u),this.h()},h(){n(s,"class","progress-bar-fill svelte-1aqs384"),ke(s,"width",a[60].holdProgress*100+"%"),n(t,"class","progress-bar-bg svelte-1aqs384"),ke(t,"width",a[66]+"px"),n(e,"class","progress-container svelte-1aqs384"),ke(e,"left",a[63].x+"px"),ke(e,"top",a[63].y+a[65]+"px")},m(o,h){F(o,e,h),c(e,t),c(t,s),l=!0},p(o,h){(!l||h[0]&12288)&&ke(s,"width",o[60].holdProgress*100+"%"),(!l||h[0]&4120)&&ke(t,"width",o[66]+"px"),(!l||h[0]&12288)&&ke(e,"left",o[63].x+"px"),(!l||h[0]&12312)&&ke(e,"top",o[63].y+o[65]+"px")},i(o){l||(o&&Oe(()=>{l&&(i||(i=Ee(e,Me,{duration:150},!0)),i.run(1))}),l=!0)},o(o){o&&(i||(i=Ee(e,Me,{duration:150},!1)),i.run(0)),l=!1},d(o){o&&u(e),o&&i&&i.end()}}}function Ct(a){let e,t,s="move to stamp again",i,l,o;return{c(){e=g("div"),t=g("div"),t.textContent=s,i=M(),this.h()},l(h){e=v(h,"DIV",{class:!0,style:!0});var f=V(e);t=v(f,"DIV",{class:!0,"data-svelte-h":!0}),de(t)!=="svelte-zss1h8"&&(t.textContent=s),i=P(f),f.forEach(u),this.h()},h(){n(t,"class","text-white/40 text-sm svelte-1aqs384"),n(e,"class","lockout-indicator svelte-1aqs384"),ke(e,"left",a[63].x+"px"),ke(e,"top",a[63].y+a[65]+"px")},m(h,f){F(h,e,f),c(e,t),c(e,i),o=!0},p(h,f){(!o||f[0]&12288)&&ke(e,"left",h[63].x+"px"),(!o||f[0]&12312)&&ke(e,"top",h[63].y+h[65]+"px")},i(h){o||(h&&Oe(()=>{o&&(l||(l=Ee(e,Me,{duration:150},!0)),l.run(1))}),o=!0)},o(h){h&&(l||(l=Ee(e,Me,{duration:150},!1)),l.run(0)),o=!1},d(h){h&&u(e),h&&l&&l.end()}}}function Tt(a,e){let t,s,i,l=e[60]&&e[60].holdProgress>0&&kt(e),o=e[60]&&e[60].isLockedOut&&Ct(e);return{key:a,first:null,c(){t=qe(),l&&l.c(),s=M(),o&&o.c(),i=qe(),this.h()},l(h){t=qe(),l&&l.l(h),s=P(h),o&&o.l(h),i=qe(),this.h()},h(){this.first=t},m(h,f){F(h,t,f),l&&l.m(h,f),F(h,s,f),o&&o.m(h,f),F(h,i,f)},p(h,f){e=h,e[60]&&e[60].holdProgress>0?l?(l.p(e,f),f[0]&12288&&we(l,1)):(l=kt(e),l.c(),we(l,1),l.m(s.parentNode,s)):l&&(Ge(),Fe(l,1,1,()=>{l=null}),Xe()),e[60]&&e[60].isLockedOut?o?(o.p(e,f),f[0]&12288&&we(o,1)):(o=Ct(e),o.c(),we(o,1),o.m(i.parentNode,i)):o&&(Ge(),Fe(o,1,1,()=>{o=null}),Xe())},d(h){h&&(u(t),u(s),u(i)),l&&l.d(h),o&&o.d(h)}}}function It(a){let e,t,s="Settings",i,l,o,h="Hold Duration",f,_,C,L,y,k=(a[16].holdDuration/1e3).toFixed(1)+"",T,x,w,d,b,N="Still Threshold",z,R,I,W,$,B=a[16].stillThreshold.toFixed(3)+"",re,ee,G,E,D="Reset Distance",O,H,K,ue,A,se=a[16].resetThreshold.toFixed(2)+"",ge,Q,q,he,be="Smoothing",U,p,r,m,Z,pe=a[16].smoothingFactor.toFixed(2)+"",fe,_e,ie,De="Clear Canvas",Ie,Ce,We,Ke;return{c(){e=g("div"),t=g("h3"),t.textContent=s,i=M(),l=g("div"),o=g("label"),o.textContent=h,f=M(),_=g("div"),C=g("input"),L=M(),y=g("span"),T=X(k),x=X("s"),w=M(),d=g("div"),b=g("label"),b.textContent=N,z=M(),R=g("div"),I=g("input"),W=M(),$=g("span"),re=X(B),ee=M(),G=g("div"),E=g("label"),E.textContent=D,O=M(),H=g("div"),K=g("input"),ue=M(),A=g("span"),ge=X(se),Q=M(),q=g("div"),he=g("label"),he.textContent=be,U=M(),p=g("div"),r=g("input"),m=M(),Z=g("span"),fe=X(pe),_e=M(),ie=g("button"),ie.textContent=De,this.h()},l(ne){e=v(ne,"DIV",{class:!0});var te=V(e);t=v(te,"H3",{class:!0,"data-svelte-h":!0}),de(t)!=="svelte-1u3av9d"&&(t.textContent=s),i=P(te),l=v(te,"DIV",{class:!0});var Ae=V(l);o=v(Ae,"LABEL",{for:!0,class:!0,"data-svelte-h":!0}),de(o)!=="svelte-bp4xbq"&&(o.textContent=h),f=P(Ae),_=v(Ae,"DIV",{class:!0});var Re=V(_);C=v(Re,"INPUT",{id:!0,type:!0,min:!0,max:!0,step:!0,class:!0}),L=P(Re),y=v(Re,"SPAN",{class:!0});var Be=V(y);T=Y(Be,k),x=Y(Be,"s"),Be.forEach(u),Re.forEach(u),Ae.forEach(u),w=P(te),d=v(te,"DIV",{class:!0});var Ne=V(d);b=v(Ne,"LABEL",{for:!0,class:!0,"data-svelte-h":!0}),de(b)!=="svelte-1m8w150"&&(b.textContent=N),z=P(Ne),R=v(Ne,"DIV",{class:!0});var S=V(R);I=v(S,"INPUT",{id:!0,type:!0,min:!0,max:!0,step:!0,class:!0}),W=P(S),$=v(S,"SPAN",{class:!0});var le=V($);re=Y(le,B),le.forEach(u),S.forEach(u),Ne.forEach(u),ee=P(te),G=v(te,"DIV",{class:!0});var J=V(G);E=v(J,"LABEL",{for:!0,class:!0,"data-svelte-h":!0}),de(E)!=="svelte-10l3rh6"&&(E.textContent=D),O=P(J),H=v(J,"DIV",{class:!0});var ae=V(H);K=v(ae,"INPUT",{id:!0,type:!0,min:!0,max:!0,step:!0,class:!0}),ue=P(ae),A=v(ae,"SPAN",{class:!0});var Se=V(A);ge=Y(Se,se),Se.forEach(u),ae.forEach(u),J.forEach(u),Q=P(te),q=v(te,"DIV",{class:!0});var j=V(q);he=v(j,"LABEL",{for:!0,class:!0,"data-svelte-h":!0}),de(he)!=="svelte-1rg1hez"&&(he.textContent=be),U=P(j),p=v(j,"DIV",{class:!0});var ce=V(p);r=v(ce,"INPUT",{id:!0,type:!0,min:!0,max:!0,step:!0,class:!0}),m=P(ce),Z=v(ce,"SPAN",{class:!0});var ye=V(Z);
1fe=Y(ye,pe),ye.forEach(u),ce.forEach(u),j.forEach(u),_e=P(te),ie=v(te,"BUTTON",{class:!0,"data-svelte-h":!0}),de(ie)!=="svelte-16e213r"&&(ie.textContent=De),te.forEach(u),this.h()},h(){n(t,"class","text-lg font-semibold mb-4 text-white/90 svelte-1aqs384"),n(o,"for","holdDuration"),n(o,"class","svelte-1aqs384"),n(C,"id","holdDuration"),n(C,"type","range"),n(C,"min","1000"),n(C,"max","5000"),n(C,"step","100"),n(C,"class","svelte-1aqs384"),n(y,"class","svelte-1aqs384"),n(_,"class","setting-input svelte-1aqs384"),n(l,"class","setting-row svelte-1aqs384"),n(b,"for","stillThreshold"),n(b,"class","svelte-1aqs384"),n(I,"id","stillThreshold"),n(I,"type","range"),n(I,"min","0.01"),n(I,"max","0.1"),n(I,"step","0.005"),n(I,"class","svelte-1aqs384"),n($,"class","svelte-1aqs384"),n(R,"class","setting-input svelte-1aqs384"),n(d,"class","setting-row svelte-1aqs384"),n(E,"for","resetThreshold"),n(E,"class","svelte-1aqs384"),n(K,"id","resetThreshold"),n(K,"type","range"),n(K,"min","0.05"),n(K,"max","0.3"),n(K,"step","0.01"),n(K,"class","svelte-1aqs384"),n(A,"class","svelte-1aqs384"),n(H,"class","setting-input svelte-1aqs384"),n(G,"class","setting-row svelte-1aqs384"),n(he,"for","smoothingFactor"),n(he,"class","svelte-1aqs384"),n(r,"id","smoothingFactor"),n(r,"type","range"),n(r,"min","0.1"),n(r,"max","0.5"),n(r,"step","0.05"),n(r,"class","svelte-1aqs384"),n(Z,"class","svelte-1aqs384"),n(p,"class","setting-input svelte-1aqs384"),n(q,"class","setting-row svelte-1aqs384"),n(ie,"class","clear-button svelte-1aqs384"),n(e,"class","settings-panel svelte-1aqs384")},m(ne,te){F(ne,e,te),c(e,t),c(e,i),c(e,l),c(l,o),c(l,f),c(l,_),c(_,C),He(C,a[16].holdDuration),c(_,L),c(_,y),c(y,T),c(y,x),c(e,w),c(e,d),c(d,b),c(d,z),c(d,R),c(R,I),He(I,a[16].stillThreshold),c(R,W),c(R,$),c($,re),c(e,ee),c(e,G),c(G,E),c(G,O),c(G,H),c(H,K),He(K,a[16].resetThreshold),c(H,ue),c(H,A),c(A,ge),c(e,Q),c(e,q),c(q,he),c(q,U),c(q,p),c(p,r),He(r,a[16].smoothingFactor),c(p,m),c(p,Z),c(Z,fe),c(e,_e),c(e,ie),Ce=!0,We||(Ke=[oe(C,"change",a[33]),oe(C,"input",a[33]),oe(C,"change",a[19]),oe(I,"change",a[34]),oe(I,"input",a[34]),oe(I,"change",a[19]),oe(K,"change",a[35]),oe(K,"input",a[35]),oe(K,"change",a[19]),oe(r,"change",a[36]),oe(r,"input",a[36]),oe(r,"change",a[19]),oe(ie,"click",a[20])],We=!0)},p(ne,te){te[0]&65536&&He(C,ne[16].holdDuration),(!Ce||te[0]&65536)&&k!==(k=(ne[16].holdDuration/1e3).toFixed(1)+"")&&ve(T,k),te[0]&65536&&He(I,ne[16].stillThreshold),(!Ce||te[0]&65536)&&B!==(B=ne[16].stillThreshold.toFixed(3)+"")&&ve(re,B),te[0]&65536&&He(K,ne[16].resetThreshold),(!Ce||te[0]&65536)&&se!==(se=ne[16].resetThreshold.toFixed(2)+"")&&ve(ge,se),te[0]&65536&&He(r,ne[16].smoothingFactor),(!Ce||te[0]&65536)&&pe!==(pe=ne[16].smoothingFactor.toFixed(2)+"")&&ve(fe,pe)},i(ne){Ce||(ne&&Oe(()=>{Ce&&(Ie||(Ie=Ee(e,nt,{duration:200},!0)),Ie.run(1))}),Ce=!0)},o(ne){ne&&(Ie||(Ie=Ee(e,nt,{duration:200},!1)),Ie.run(0)),Ce=!1},d(ne){ne&&u(e),ne&&Ie&&Ie.end(),We=!1,Lt(Ke)}}}function ks(a){let e,t,s,i=a[12].length+"",l,o,h,f,_=(a[8]*100).toFixed(1)+"",C,L,y=(qt*100).toFixed(0)+"",k,T,x,w,d,b=a[9].length+"",N,z,R,I,W,$,B=[],re=new st,ee=Pe(a[12]);const G=E=>E[59].id;for(let E=0;E<ee.length;E+=1){let D=ht(a,ee,E),O=G(D);re.set(O,B[E]=St(O,D))}return{c(){e=g("div"),t=g("div"),s=X("Hands: "),l=X(i),o=M(),h=g("div"),f=X("Coverage: "),C=X(_),L=X("% / "),k=X(y),T=X("%"),x=M(),w=g("div"),d=X("Slices: "),N=X(b),z=M(),R=g("div"),I=X("Shifting: "),W=X(a[7]),$=M();for(let E=0;E<B.length;E+=1)B[E].c();this.h()},l(E){e=v(E,"DIV",{class:!0});var D=V(e);t=v(D,"DIV",{class:!0});var O=V(t);s=Y(O,"Hands: "),l=Y(O,i),O.forEach(u),o=P(D),h=v(D,"DIV",{class:!0});var H=V(h);f=Y(H,"Coverage: "),C=Y(H,_),L=Y(H,"% / "),k=Y(H,y),T=Y(H,"%"),H.forEach(u),x=P(D),w=v(D,"DIV",{class:!0});var K=V(w);
1d=Y(K,"Slices: "),N=Y(K,b),K.forEach(u),z=P(D),R=v(D,"DIV",{class:!0});var ue=V(R);I=Y(ue,"Shifting: "),W=Y(ue,a[7]),ue.forEach(u),$=P(D);for(let A=0;A<B.length;A+=1)B[A].l(D);D.forEach(u),this.h()},h(){n(t,"class","svelte-1aqs384"),n(h,"class","svelte-1aqs384"),n(w,"class","svelte-1aqs384"),n(R,"class","svelte-1aqs384"),n(e,"class","fixed left-4 top-4 font-mono text-xs text-white/60 bg-black/50 p-2 rounded svelte-1aqs384")},m(E,D){F(E,e,D),c(e,t),c(t,s),c(t,l),c(e,o),c(e,h),c(h,f),c(h,C),c(h,L),c(h,k),c(h,T),c(e,x),c(e,w),c(w,d),c(w,N),c(e,z),c(e,R),c(R,I),c(R,W),c(e,$);for(let O=0;O<B.length;O+=1)B[O]&&B[O].m(e,null)},p(E,D){D[0]&4096&&i!==(i=E[12].length+"")&&ve(l,i),D[0]&256&&_!==(_=(E[8]*100).toFixed(1)+"")&&ve(C,_),D[0]&512&&b!==(b=E[9].length+"")&&ve(N,b),D[0]&128&&ve(W,E[7]),D[0]&12288&&(ee=Pe(E[12]),B=$e(B,D,G,1,E,ee,re,e,et,St,null,ht))},d(E){E&&u(e);for(let D=0;D<B.length;D+=1)B[D].d()}}}function St(a,e){let t,s,i,l=e[59].id+"",o,h,f=(e[60]?.holdProgress??0).toFixed(2)+"",_,C,L,y,k=(e[60]?.isLockedOut??!1)+"",T,x;return{key:a,first:null,c(){t=g("div"),s=g("div"),i=X("Hand "),o=X(l),h=X(": Hold "),_=X(f),C=M(),L=g("div"),y=X("Locked: "),T=X(k),x=M(),this.h()},l(w){t=v(w,"DIV",{class:!0});var d=V(t);s=v(d,"DIV",{class:!0});var b=V(s);i=Y(b,"Hand "),o=Y(b,l),h=Y(b,": Hold "),_=Y(b,f),b.forEach(u),C=P(d),L=v(d,"DIV",{class:!0});var N=V(L);y=Y(N,"Locked: "),T=Y(N,k),N.forEach(u),x=P(d),d.forEach(u),this.h()},h(){n(s,"class","svelte-1aqs384"),n(L,"class","svelte-1aqs384"),n(t,"class","mt-1 border-t border-white/20 pt-1 svelte-1aqs384"),this.first=t},m(w,d){F(w,t,d),c(t,s),c(s,i),c(s,o),c(s,h),c(s,_),c(t,C),c(t,L),c(L,y),c(L,T),c(t,x)},p(w,d){e=w,d[0]&4096&&l!==(l=e[59].id+"")&&ve(o,l),d[0]&12288&&f!==(f=(e[60]?.holdProgress??0).toFixed(2)+"")&&ve(_,f),d[0]&12288&&k!==(k=(e[60]?.isLockedOut??!1)+"")&&ve(T,k)},d(w){w&&u(t)}}}function Cs(a){let e,t,s,i,l="",o,h,f="",_,C,L="",y,k,T,x,w,d,b,N,z,R,I,W=[],$=new st,B,re,ee,G,E,D,O,H,K,ue,A=a[7]&&ft(),se=Pe(a[9].slice(-3));const ge=r=>r[69];for(let r=0;r<se.length;r+=1){let m=ut(a,se,r),Z=ge(m);$.set(Z,W[r]=mt(Z,m))}let Q=a[10]&&vt(a),q=a[6]&>(a);function he(r,m){return r[14]?bs:ws}let be=he(a),U=be(a),p=a[18]&&ks(a);return{c(){e=g("link"),t=g("link"),s=g("link"),i=g("script"),i.innerHTML=l,h=g("script"),h.innerHTML=f,C=g("script"),C.innerHTML=L,k=M(),T=g("div"),x=g("canvas"),w=M(),d=g("canvas"),N=M(),A&&A.c(),z=M(),R=g("div"),I=g("button");for(let r=0;r<W.length;r+=1)W[r].c();B=M(),Q&&Q.c(),re=M(),q&&q.c(),ee=M(),G=g("div"),E=g("canvas"),D=M(),U.c(),O=M(),p&&p.c(),H=qe(),this.h()},l(r){const m=Vt("svelte-jpenhh",Ve.head);e=v(m,"LINK",{rel:!0,href:!0,class:!0}),t=v(m,"LINK",{rel:!0,href:!0,crossorigin:!0,class:!0}),s=v(m,"LINK",{href:!0,rel:!0,class:!0}),i=v(m,"SCRIPT",{src:!0,class:!0,"data-svelte-h":!0}),de(i)!=="svelte-1fs8b8t"&&(i.innerHTML=l),h=v(m,"SCRIPT",{src:!0,class:!0,"data-svelte-h":!0}),de(h)!=="svelte-vsq9xz"&&(h.innerHTML=f),C=v(m,"SCRIPT",{src:!0,crossorigin:!0,class:!0,"data-svelte-h":!0}),de(C)!=="svelte-2e0whm"&&(C.innerHTML=L),m.forEach(u),k=P(r),T=v(r,"DIV",{class:!0});var Z=V(T);x=v(Z,"CANVAS",{class:!0}),V(x).forEach(u),w=P(Z),d=v(Z,"CANVAS",{class:!0}),V(d).forEach(u),Z.forEach(u),N=P(r),A&&A.l(r),z=P(r),R=v(r,"DIV",{class:!0});var pe=V(R);I=v(pe,"BUTTON",{type:!0,class:!0,"aria-label":!0});var fe=V(I);for(let ie=0;ie<W.length;ie+=1)W[ie].l(fe);B=P(fe),Q&&Q.l(fe),fe.forEach(u),pe.forEach(u),re=P(r),q&&q.l(r),ee=P(r),G=v(r,"DIV",{class:!0});var _e=V(G);E=v(_e,"CANVAS",{class:!0}),V(E).forEach(u),_e.forEach(u),D=P(r),U.l(r),O=P(r),p&&p.l(r),H=qe(),this.h()},h(){n(e,"rel","preconnect"),n(e,"href","https://fonts.googleapis.com"),n(e,"class","svelte-1aqs384"),n(t,"rel","preconnect"),n(t,"href","https://fonts.gstatic.com"),n(t,"crossorigin","true"),n(t,"class","svelte-1aqs384"),n(s,"href","https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,300..700;1,300..700&display=swap"),n(s,"rel","stylesheet"),n(s,"class","svelte-1aqs384"),Te(i.src,o="https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands.js")||n(i,"src",o),n(i,"class","svelte-1aqs384"),Te(h.src,_="https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js")||n(h,"src",_),n(h,"class","svelte-1aqs384"),Te(C.src,y="https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/drawing_utils.js")||n(C,"src",y),n(C,"crossorigin","anonymous"),n(C,"class","svelte-1aqs384"),n(x,"class","absolute left-0 top-0 h-full w-full svelte-1aqs384"),n(d,"class","relative h-full w-full svelte-1aqs384"),n(T,"class","cave-wrapper h-[100vh] w-[100vw] overflow-hidden svelte-1aqs384"),Oe(()=>a[25].call(T)),lt(T,"cursor-none",!a[5]),n(I,"type","button"),n(I,"class","panorama-track svelte-1aqs384"),n(I,"aria-label","View full panorama"),n(R,"class","panorama-strip svelte-1aqs384"),n(E,"class","w-48 svelte-1aqs384"),n(G,"class","fixed bottom-4 right-4 border border-white bg-black/50 svelte-1aqs384"),lt(G,"hidden",!a[18])},m(r,m){c(Ve.head,e),c(Ve.head,t),c(Ve.head,s),c(Ve.head,i),c(Ve.head,h),c(Ve.head,C),F(r,k,m),F(r,T,m),c(T,x),a[23](x),c(T,w),c(T,d),a[24](d),b=Mt(T,a[25].bind(T)),F(r,N,m),A&&A.m(r,m),F(r,z,m),F(r,R,m),c(R,I);for(let Z=0;Z<W.length;Z+=1)W[Z]&&W[Z].m(I,null);c(I,B),Q&&Q.m(I,null),F(r,re,m),q&&q.m(r,m),F(r,ee,m),F(r,G,m),c(G,E),a[31](E),F(r,D,m),U.m(r,m),F(r,O,m),p&&p.m(r,m),F(r,H,m),K||(ue=oe(I,"click",a[26]),K=!0)},p(r,m){m[0]&32&<(T,"cursor-none",!r[5]),r[7]?A?m[0]&128&&we(A,1):(A=ft(),A.c(),we(A,1),A.m(z.parentNode,z)):A&&(Ge(),Fe(A,1,1,()=>{A=null}),Xe()),m[0]&512&&(se=Pe(r[9].slice(-3)),W=$e(W,m,ge,1,r,se,$,I,et,mt,B,ut)),r[10]?Q?Q.p(r,m):(Q=vt(r),Q.c(),Q.m(I,null)):Q&&(Q.d(1),Q=null),r[6]?q?(q.p(r,m),m[0]&64&&we(q,1)):(q=gt(r),q.c(),we(q,1),q.m(ee.parentNode,ee)):q&&(Ge(),Fe(q,1,1,()=>{q=null}),Xe()),be===(be=he(r))&&U?U.p(r,m):(U.d(1),U=be(r),U&&(U.c(),U.m(O.parentNode,O))),r[18]&&p.p(r,m)},i(r){we(A);for(let m=0;m<se.length;m+=1)we(W[m]);we(q)},o(r){Fe(A),Fe(q)},d(r){r&&(u(k),u(T),u(N),u(z),u(R),u(re),u(ee),u(G),u(D),u(O),u(H)),u(e),u(t),u(s),u(i),u(h),u(C),a[23](null),a[24](null),b(),A&&A.d(r);for(let m=0;m<W.length;m+=1)W[m].d();Q&&Q.d(),q&&q.d(r),a[31](null),U.d(r),p&&p.d(r),K=!1,ue()}}}
1const Ts=1080,qt=.3,Is=1500,Ss=250,ys=700,Es=400,Ds=3e3,yt=500;function Et(a){return new Promise((e,t)=>{const s=new Image;s.crossOrigin="anonymous",s.onload=()=>e(s),s.onerror=t,s.src=a})}function Ls(a,e,t){const s=.3333333333333333;let i,l,o,h,f,_=null,C=null,L=null,y=null,k=null,T=null,x=null,w=!0,d=!1,b=performance.now(),N=!1,z=0,R=[],I=null,W=new Map,$=new Map,B=new Map,re=!1,ee=[],G=new Map,E=!1;const D=!1;let O=!1,H={holdDuration:1e3,stillThreshold:.025,resetThreshold:.025,smoothingFactor:.25,maxHands:4};function K(S){return W.has(S)||W.set(S,new Qt({holdDuration:H.holdDuration,stillThreshold:H.stillThreshold,resetThreshold:H.resetThreshold,smoothingFactor:H.smoothingFactor})),W.get(S)}function ue(S){t(12,ee=S);const le=performance.now();S.length>0&&(b=le);const J=new Set(S.map(j=>j.id)),ae=[];for(const[j,ce]of B.entries())!J.has(j)&&le-ce>yt&&ae.push(j);for(const j of ae)W.delete(j),$.delete(j),G.delete(j),B.delete(j);for(const j of S){const ce=B.get(j.id),ye=$.has(j.id);let Le=!1;if(ye?ce&&le-ce>yt&&(Le=!0):Le=!0,Le&&_){const Ue=Array.from($.values()),xe=Ue.length>0?Ue[0]:Math.floor(Math.random()*_.shaderCount);$.set(j.id,xe),Ue.length===0&&(_.shaderIndex=xe),W.delete(j.id)}B.set(j.id,le)}const Se=new Map;for(const j of S){const ye=K(j.id).update(j.x,j.y,j.visible);if(Se.set(j.id,ye),ye.shouldStamp&&_){const Le=$.get(j.id)??_.shaderIndex;_.shaderIndex=Le,_.captureFrame()}}t(13,G=Se)}function A(){for(const S of W.values())S.setConfig({holdDuration:H.holdDuration,stillThreshold:H.stillThreshold,resetThreshold:H.resetThreshold,smoothingFactor:H.smoothingFactor})}function se(){return new Promise(S=>{if(!l){S(null);return}l.toBlob(le=>S(le?URL.createObjectURL(le):null),"image/webp",.7)})}function ge(){if(!l)return;const S=async()=>{const[le,J]=await Promise.all([ns(l),se()]);if(J){const ae=I;t(10,I=J),ae&&ae.startsWith("blob:")&&URL.revokeObjectURL(ae)}};typeof window.requestIdleCallback=="function"?window.requestIdleCallback(()=>S(),{timeout:1e3}):setTimeout(S,0)}const Q=rt(ge,Es);function q(){Q()}async function he(){if(!l)return;const S=await rs();if(!S)return;const le=l.getContext("2d");le&&le.drawImage(S.image,0,0,l.width,l.height)}function be(){L==null&&(L=setInterval(()=>{!_||!C||!l||N||ee.length>0||performance.now()-b<Is||(t(8,z=C.measure(l)),z>=qt&&p())},Ss))}function U(){L!=null&&(clearInterval(L),L=null)}async function p(){if(!(!_||!l||N)){t(7,N=!0);try{const S=Math.max(1,Math.floor(l.width*s)),le=ms(l,S),J=await cs(le);J&&t(9,R=[...R,J]),await fs(l,{shiftPx:S,durationMs:ys,resetBackground:()=>_?.redrawCaveWall()}),ge()}catch(S){console.error("[shift] failed:",S)}finally{t(7,N=!1),b=performance.now()}}}Ft(async()=>{if(E)return;const S=hs();_=new Jt(i,l,o,{onHandsLoaded:()=>{t(11,re=!0)},onHandsUpdate:ue,onFrameCaptured:q},{maxHands:H.maxHands,worldHeight:Ts,transparentBackground:!0}),await _.init(h,f),C=new ds({mode:"alpha"}),await he(),t(10,I=await se()),t(9,R=await S),be(),y=rt(()=>{if(!_||!l)return;const J=document.createElement("canvas");J.width=l.width,J.height=l.height,J.getContext("2d")?.drawImage(l,0,0),_.resize(h,f),l.getContext("2d")?.drawImage(J,0,0,l.width,l.height)},80),window.addEventListener("resize",y),k=J=>{if(J.code==="Escape"&&d){t(6,d=!1);return}if(J.code!=="Space")return;const ae=J.target;ae&&(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.isContentEditable)||(J.preventDefault(),N||p())},window.addEventListener("keydown",k);const le=()=>{x&&clearTimeout(x),x=setTimeout(()=>{t(5,w=!1)},Ds)};T=()=>{w||t(5,w=!0),le()},window.addEventListener("mousemove",T),le()}),Ot(()=>{U(),y&&(window.removeEventListener("resize",y),y=null),k&&(window.removeEventListener("keydown",k),k=null),T&&(window.removeEventListener("mousemove",T),T=null),x&&(clearTimeout(x),x=null),I&&I.startsWith("blob:")&&(URL.revokeObjectURL(I),t(10,I=null)),_&&_.destroy()});function r(){_?.clear(),os(),I&&I.startsWith("blob:")&&URL.revokeObjectURL(I),t(10,I=null),t(8,z=0)}let m=null;async function Z(S){if(m)return;const le=[...R];if(I&&le.push(I),le.length!==0){t(17,m=S);try{const J=await Promise.all(le.map(Et)),ae=Math.max(...J.map(me=>me.naturalHeight)),Se=J.reduce((me,Qe)=>
1me+Qe.naturalWidth,0),j=document.createElement("canvas");j.width=Se,j.height=ae;const ce=j.getContext("2d");if(!ce)throw new Error("Failed to get 2D context");if(S==="wall")try{const me=await Et("/imgs/cave-wall-2x.jpg"),Qe=me.naturalWidth*(ae/me.naturalHeight);let at=0;for(;at<Se;)ce.drawImage(me,at,0,Qe,ae),at+=Qe}catch{ce.fillStyle="#1a1410",ce.fillRect(0,0,Se,ae)}else ce.fillStyle="#000",ce.fillRect(0,0,Se,ae);let ye=0;for(const me of J)ce.drawImage(me,ye,0,me.naturalWidth,ae),ye+=me.naturalWidth;const Le=await new Promise(me=>j.toBlob(me,"image/jpeg",.92));if(!Le)throw new Error("Failed to encode panorama");const Ue=URL.createObjectURL(Le),xe=document.createElement("a");xe.href=Ue,xe.download=`forgotten-dreams-${S}-${new Date().toISOString().replace(/[:.]/g,"-")}.jpg`,document.body.appendChild(xe),xe.click(),xe.remove(),setTimeout(()=>URL.revokeObjectURL(Ue),1e3)}catch(J){console.error("[download] failed",J)}finally{t(17,m=null)}}}function pe(S){return{x:S.x*h,y:(1-S.y)*f}}function fe(S){it[S?"unshift":"push"](()=>{l=S,t(1,l)})}function _e(S){it[S?"unshift":"push"](()=>{i=S,t(0,i)})}function ie(){h=this.clientWidth,f=this.clientHeight,t(3,h),t(4,f)}const De=()=>t(6,d=!0),Ie=()=>t(6,d=!1),Ce=()=>Z("black"),We=()=>Z("wall"),Ke=()=>t(6,d=!1);function ne(S){it[S?"unshift":"push"](()=>{o=S,t(2,o)})}const te=()=>t(15,O=!O);function Ae(){H.holdDuration=Ze(this.value),t(16,H)}function Re(){H.stillThreshold=Ze(this.value),t(16,H)}function Be(){H.resetThreshold=Ze(this.value),t(16,H)}function Ne(){H.smoothingFactor=Ze(this.value),t(16,H)}return t(14,E=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)),[i,l,o,h,f,w,d,N,z,R,I,re,ee,G,E,O,H,m,D,A,r,Z,pe,fe,_e,ie,De,Ie,Ce,We,Ke,ne,te,Ae,Re,Be,Ne]}class Ns extends At{constructor(e){super(),Rt(this,e,Ls,Cs,Pt,{},null,[-1,-1,-1])}}export{Ns as component,Rs as universal};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.