clipoox-render 0.4.6 → 0.4.7

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 (108) hide show
  1. package/package.json +1 -1
  2. package/scripts/render-local.mjs +999 -848
  3. package/web/assets/{FxEmbed-ROS6C_HI.js → FxEmbed-B-D-tbgP.js} +1 -1
  4. package/web/assets/{MotionEmbed-E2hCysi-.js → MotionEmbed-eB-zRpv9.js} +1 -1
  5. package/web/assets/{PluginStore-CwUSpwPp.js → PluginStore-D6UvvVXA.js} +1 -1
  6. package/web/assets/{ShotComposer-DLxWpdYH.js → ShotComposer-CoxtWL6A.js} +5 -5
  7. package/web/assets/{TemplateEmbed-qG1AXdtf.js → TemplateEmbed-DZNaQAJ-.js} +1 -1
  8. package/web/assets/{TimelinePlugins-CB1b6-Cb.js → TimelinePlugins-zhB9Uqav.js} +3 -3
  9. package/web/assets/{TimelineShotFx-CyHTgJHj.js → TimelineShotFx-muTN__gf.js} +2 -2
  10. package/web/assets/{TransitionEmbed-Dym9P7--.js → TransitionEmbed-r_B0toRr.js} +1 -1
  11. package/web/assets/{Whiteboard-BdGjJZXW.js → Whiteboard-f6owS-ne.js} +1 -1
  12. package/web/assets/{aerial-yLD_gDzw.js → aerial-DIj143Yz.js} +2 -2
  13. package/web/assets/{agentTools-B7g6tXTR.js → agentTools-CoNs1wCQ.js} +2 -2
  14. package/web/assets/{aiInbetween-6eKDYbYS.js → aiInbetween-ZFNHEXdI.js} +2 -2
  15. package/web/assets/{analyzerRun-Cr-_79RH.js → analyzerRun-BswbLsRF.js} +1 -1
  16. package/web/assets/{analyzerSandbox-N92T6amg.js → analyzerSandbox-C2rd6s8U.js} +1 -1
  17. package/web/assets/{api-Dnl2uaKO.js → api-DJC95K48.js} +3 -3
  18. package/web/assets/auraTrack-C9diszRB.js +1 -0
  19. package/web/assets/{breakthrough-DSiuVwEX.js → breakthrough-DiHiElqL.js} +2 -2
  20. package/web/assets/{cameraPresets-Cfn7qhXK.js → cameraPresets-DfKERP1j.js} +1 -1
  21. package/web/assets/{cameraTracker-DHdF8Zqx.js → cameraTracker-DFjnZ7tw.js} +1 -1
  22. package/web/assets/{captionLayout-cckQ7p-t.js → captionLayout-CAuhUiW9.js} +1 -1
  23. package/web/assets/{clientExport-pkLbOmEF.js → clientExport-DyqpYM6h.js} +1 -1
  24. package/web/assets/{clientJobs-CcsLDqFM.js → clientJobs-BqkjV5Ld.js} +2 -2
  25. package/web/assets/{depthEstimate-Cav4MmQ1.js → depthEstimate-HrGq0Ffx.js} +1 -1
  26. package/web/assets/{directorTools-DMsatulF.js → directorTools-CLn4xt6m.js} +1 -1
  27. package/web/assets/{distortFrames-D_v-aSVO.js → distortFrames-D-DK2HlN.js} +2 -2
  28. package/web/assets/{distortGL-vhnBRB59.js → distortGL-waTJhiOf.js} +1 -1
  29. package/web/assets/{domino-DBrinEUu.js → domino-BDKBYrNQ.js} +1 -1
  30. package/web/assets/{editTools-BNnAvCw-.js → editTools-BqKU-ucA.js} +1 -1
  31. package/web/assets/{engine-Co-ivzlQ.js → engine-B2YPWQZ2.js} +1 -1
  32. package/web/assets/{exportGlb-D3PrWUvi.js → exportGlb-Cm07JQXt.js} +1 -1
  33. package/web/assets/{faceTracker-ClR-lS6Y.js → faceTracker-DsmLlUZ1.js} +1 -1
  34. package/web/assets/{fightDirector-BlpVAURl.js → fightDirector-BIVLGhAP.js} +1 -1
  35. package/web/assets/{fightDrama-BK0QidpM.js → fightDrama-B_jDQ-cW.js} +2 -2
  36. package/web/assets/{focusTool-sVOb2GGS.js → focusTool-mWs2Eikj.js} +1 -1
  37. package/web/assets/{frameSink-CSRqCnwI.js → frameSink-DWkHUnvV.js} +3 -3
  38. package/web/assets/{glTransitionSources.generated-q0H-ZbnZ.js → glTransitionSources.generated-BJuEUz3E.js} +1 -1
  39. package/web/assets/{gpuCompose-B5bgbHdQ.js → gpuCompose-Fi0sIUI9.js} +1 -1
  40. package/web/assets/{gpuExport-oA2mUsdm.js → gpuExport-Dlf6YjLs.js} +3 -3
  41. package/web/assets/{handMatte-Dj2taFoC.js → handMatte-CvFkZKTL.js} +1 -1
  42. package/web/assets/{handTracker-c6_rvuwA.js → handTracker-CF1hqh09.js} +2 -2
  43. package/web/assets/{index-Ds_8isyf.js → index-EegUntr6.js} +1 -1
  44. package/web/assets/{layer-worker-ClVZG6ZW.js → layer-worker-Drj-NLVj.js} +3 -3
  45. package/web/assets/library-BhH-xsMR.js +1 -0
  46. package/web/assets/{lottieLayer-Cv8ub9f6.js → lottieLayer-Dp_vGTy8.js} +1 -1
  47. package/web/assets/{main-CwrkBJ63.js → main-DAk1Tv1E.js} +52 -52
  48. package/web/assets/{mapBake-DtQboFIX.js → mapBake-CEmw-e9Y.js} +1 -1
  49. package/web/assets/{maskTrack-D4QZfMWc.js → maskTrack-CADMBJDf.js} +1 -1
  50. package/web/assets/{matteFixRun-CytaeRzS.js → matteFixRun-BHD3Qnta.js} +1 -1
  51. package/web/assets/{objectLocate-XuAcemlO.js → objectLocate-DWsEG8eK.js} +1 -1
  52. package/web/assets/{objectSegmenter-D66spD7o.js → objectSegmenter-oGv8YQbI.js} +1 -1
  53. package/web/assets/{objectTrack.worker-BZS6WZ6l.js → objectTrack.worker-B6RVfsq4.js} +570 -419
  54. package/web/assets/{pathTracer-DykgPkkh.js → pathTracer-DxqKEvC7.js} +2 -2
  55. package/web/assets/{pendingMatte-BWBIWajI.js → pendingMatte-Taa0BlLI.js} +2 -2
  56. package/web/assets/{personAi-EhBknW6X.js → personAi-BebqXrqD.js} +2 -2
  57. package/web/assets/{personHq-Ca351o06.js → personHq-Cyq9HWnW.js} +2 -2
  58. package/web/assets/{plateCamera-BcdXD1uI.js → plateCamera-D1A1iEpf.js} +1 -1
  59. package/web/assets/{plateCameraMatch-GPZl1fQQ.js → plateCameraMatch-1_DuZ0LV.js} +2 -2
  60. package/web/assets/{plateFollow-CJUilsNV.js → plateFollow-Ztxwpq5v.js} +2 -2
  61. package/web/assets/{plateMatte-CoEoVjxZ.js → plateMatte-CWT1ymGj.js} +2 -2
  62. package/web/assets/{pluginAutomation-DAPHWZPN.js → pluginAutomation-D73Az7HS.js} +1 -1
  63. package/web/assets/{poseTracker-CzEKvJph.js → poseTracker-b1h08oRY.js} +1 -1
  64. package/web/assets/{productTools-ce-zyZO0.js → productTools-CoJ_Fnfc.js} +2 -2
  65. package/web/assets/remote-kxNNhmis.js +974 -0
  66. package/web/assets/{rigTrack-DMyqb0pb.js → rigTrack-B9r9wrdV.js} +1 -1
  67. package/web/assets/{rotoMaskStore-pE1AIt3I.js → rotoMaskStore-RmW40Pcn.js} +1 -1
  68. package/web/assets/{rotoMatte-7b7Ow64f.js → rotoMatte-DisQplSv.js} +1 -1
  69. package/web/assets/{rotoscope-BUqNTKLd.js → rotoscope-Z8bn-jRs.js} +1 -1
  70. package/web/assets/{sceneTrack-CA21MCOP.js → sceneTrack-BKknn180.js} +1 -1
  71. package/web/assets/{sceneTrack-DlAH5s74.js → sceneTrack-DyVxpl7i.js} +1 -1
  72. package/web/assets/{sceneTrack.worker-COlhlHRe.js → sceneTrack.worker-DKVLLgf9.js} +570 -419
  73. package/web/assets/{shot-worker-DL1ZoIym.js → shot-worker-DM5PUQ6g.js} +1 -1
  74. package/web/assets/{shotFxAgent-DqngnGFb.js → shotFxAgent-CsW0MAiG.js} +1 -1
  75. package/web/assets/{skin-xFScwS3T.js → skin-CXvqtCZI.js} +1 -1
  76. package/web/assets/{spark.module-DjaIF6J1.js → spark.module-B341moK0.js} +1 -1
  77. package/web/assets/{spellDuel-BYNtnE8f.js → spellDuel-KCMEFHLA.js} +2 -2
  78. package/web/assets/{store-CpqHUcA2.js → store-xR02oY0m.js} +1 -1
  79. package/web/assets/{surfaceLight-C7YI9SV8.js → surfaceLight-DBfJxggM.js} +1 -1
  80. package/web/assets/{surfacePin-CzpUj1Cw.js → surfacePin-i-X1Dz68.js} +2 -2
  81. package/web/assets/{textAnimators-B9vO_hbP.js → textAnimators-CeMuG34D.js} +1 -1
  82. package/web/assets/{thumb-BTFsBS1u.js → thumb-DzNl15MN.js} +1 -1
  83. package/web/assets/{timeline3d-DrFaMPPB.js → timeline3d-D0Ws4lcp.js} +2 -2
  84. package/web/assets/{timeline3dExport-Uo0S0CR0.js → timeline3dExport-BO--SpAn.js} +1 -1
  85. package/web/assets/{timelineComp-i-zdaoB2.js → timelineComp-D8PHGHgQ.js} +1 -1
  86. package/web/assets/{timelineOps-DSSaDsU2.js → timelineOps-CEGk2t4h.js} +20 -20
  87. package/web/assets/{timelineProps-0v-s69pw.js → timelineProps-Cm_Irino.js} +1 -1
  88. package/web/assets/{timelineText-DurRhyuh.js → timelineText-DjPW2-dd.js} +1 -1
  89. package/web/assets/{titleArt-CnC0A7x7.js → titleArt-BSu80bfN.js} +3 -3
  90. package/web/assets/{titleFrameBudget-DsM0V482.js → titleFrameBudget-BW-N1-cw.js} +718 -567
  91. package/web/assets/{titleFrames-C8kvflgT.js → titleFrames-BHFaInux.js} +1 -1
  92. package/web/assets/{tool-D1FpErrX.js → tool-Bboi3NDg.js} +1 -1
  93. package/web/assets/{tools-DIvrRu-5.js → tools-kgYkohv8.js} +1 -1
  94. package/web/assets/{toonTools-D9MNdRty.js → toonTools-Bxz_HSqT.js} +2 -2
  95. package/web/assets/{trackAnchor-XvUuvkWP.js → trackAnchor-DK9cEMCf.js} +1 -1
  96. package/web/assets/{userFonts-Djka6RJX.js → userFonts-DSkZHfmh.js} +1 -1
  97. package/web/assets/{vfxAlpha-B-JzzRI1.js → vfxAlpha-B0rNpKZN.js} +1 -1
  98. package/web/assets/vfxBackground-CBTDl1xA.js +2 -0
  99. package/web/assets/{videoExport-NN-QijHd.js → videoExport-Cu0vw-dL.js} +1 -1
  100. package/web/assets/{views-RQBs4zva.js → views-CmulxRJP.js} +1 -1
  101. package/web/assets/{weaponDuel-DKAEYJjO.js → weaponDuel-DuuMMfzY.js} +1 -1
  102. package/web/assets/{windowFrames-DhhJLIs-.js → windowFrames-BP2oDn-n.js} +1 -1
  103. package/web/layer-worker.html +3 -3
  104. package/web/shot-worker.html +22 -22
  105. package/web/assets/auraTrack-C8eAEIWQ.js +0 -1
  106. package/web/assets/library-BK0QVG4O.js +0 -1
  107. package/web/assets/remote-8XzEAnAJ.js +0 -974
  108. package/web/assets/vfxBackground-b053ziDK.js +0 -2
@@ -1 +1 @@
1
- import{g as kt,l as Ft}from"./matteQuality-9X-jgJrH.js";import{cW as Q,cX as jt}from"./timelineOps-DSSaDsU2.js";import"./titleFrameBudget-DsM0V482.js";import"./sceneTrack-DlAH5s74.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./api-Dnl2uaKO.js";import"./i18n-C9zFX25m.js";import"./index-CKtv7gGE.js";import"./store-CpqHUcA2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const dt=Object.freeze({core:.5,band:.16,ring:.55,sep:22,lo:.1,hi:.78,guideR:2,guideEps:.002,maxW:512,choke:[.5,.66],close:.08,closeArm:.22,chokeAI:[.45,.62],chokeArm:[.22,.4]}),ut=[[0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]],at=[0,1,5,9,13,17];function V(l,t,n,g,A,d,y=255){const a=Math.max(0,Math.floor(Math.min(t[0],n[0])-g)),e=Math.min(A-1,Math.ceil(Math.max(t[0],n[0])+g)),p=Math.max(0,Math.floor(Math.min(t[1],n[1])-g)),M=Math.min(d-1,Math.ceil(Math.max(t[1],n[1])+g)),U=n[0]-t[0],i=n[1]-t[1],f=U*U+i*i||1,c=g*g;for(let m=p;m<=M;m++)for(let o=a;o<=e;o++){const N=o+.5-t[0],z=m+.5-t[1],$=Math.max(0,Math.min(1,(N*U+z*i)/f)),H=N-$*U,B=z-$*i;H*H+B*B<=c&&l[m*A+o]<y&&(l[m*A+o]=y)}return l}function L(l,t,n,g,A=255){const d=t.length;if(d<3)return l;let y=1/0,a=-1/0;for(const p of t)p[1]<y&&(y=p[1]),p[1]>a&&(a=p[1]);y=Math.max(0,Math.floor(y)),a=Math.min(g-1,Math.ceil(a));const e=[];for(let p=y;p<=a;p++){const M=p+.5;e.length=0;for(let i=0,f=d-1;i<d;f=i++){const c=t[f],m=t[i];(c[1]<=M&&m[1]>M||m[1]<=M&&c[1]>M)&&e.push([c[0]+(M-c[1])/(m[1]-c[1])*(m[0]-c[0]),m[1]>c[1]?1:-1])}if(e.length<2)continue;e.sort((i,f)=>i[0]-f[0]);let U=0;for(let i=0;i<e.length-1;i++){if(U+=e[i][1],!U)continue;const f=Math.max(0,Math.ceil(e[i][0]-.5)),c=Math.min(n-1,Math.floor(e[i+1][0]-.5)),m=p*n;for(let o=f;o<=c;o++)l[m+o]<A&&(l[m+o]=A)}}return l}function ht(l,t,n,g){const A=t+1,d=l.map(y=>{const a=new Float64Array(A*(n+1));for(let e=0;e<n;e++){let p=0;for(let M=0;M<t;M++)p+=y[e*t+M],a[(e+1)*A+M+1]=a[e*A+M+1]+p}return a});return(y,a,e)=>{const p=d[y],M=Math.max(0,a-g),U=Math.min(t,a+g+1),i=Math.max(0,e-g),f=Math.min(n,e+g+1);return p[f*A+U]-p[i*A+U]-p[f*A+M]+p[i*A+M]}}function Ct(l,t,n,g,A={}){const{learned:d=null,...y}=A,a={...dt,...y},e=t*n,p=new Uint8Array(e),M=new Uint8Array(e),U=new Uint8Array(e),i=new Uint8Array(e),f=new Uint8Array(e),c=(g||[]).filter(r=>r?.lm?.length>=21);if(!c.length)return new Uint8Array(e);const m=r=>r.map(([h,x])=>[h*t,x*n]);let o=0;for(const r of c){o=Math.max(o,Math.hypot((r.lm[0][0]-r.lm[9][0])*t,(r.lm[0][1]-r.lm[9][1])*n)),L(p,m(Q(r.lm,t,n,{edge:r.edge?r.edge.map(x=>Math.min(0,x)):null,scale:a.core})),t,n),L(i,m(Q(r.lm,t,n,{edge:r.edge})),t,n),L(M,m(Q(r.lm,t,n,{edge:r.edge,grow:a.band})),t,n),L(U,m(Q(r.lm,t,n,{edge:r.edge,grow:a.ring})),t,n);const h=Q(r.lm,t,n,{edge:r.edge,grow:a.band});L(f,m(jt.map(x=>h[x])),t,n)}if(d){const r=new Uint8Array(e),h=new Uint8Array(e);for(const u of c){const s=u.lm.map(([P,E])=>[P*t,E*n]),F=Math.hypot(s[0][0]-s[9][0],s[0][1]-s[9][1]),k=Array.isArray(u.armDir)?u.armDir:[(s[0][0]-s[9][0])/(F||1),(s[0][1]-s[9][1])/(F||1)],j=[s[0][0]+k[0]*4*F,s[0][1]+k[1]*4*F];for(const[P,E]of ut)V(r,s[P],s[E],.45*F,t,n),V(h,s[P],s[E],.08*F,t,n);L(r,at.map(P=>s[P]),t,n),L(h,at.map(P=>s[P]),t,n);const K=[s[0][0]+k[0]*Math.max(t,n)*1.5,s[0][1]+k[1]*Math.max(t,n)*1.5];V(r,s[0],K,1.6*F,t,n),V(h,s[0],j,.12*F,t,n)}const x=new Uint8Array(e);for(const u of c){const s=u.lm.map(([k,j])=>[k*t,j*n]),F=Math.hypot(s[0][0]-s[9][0],s[0][1]-s[9][1]);for(const[k,j]of ut)V(x,s[k],s[j],.45*F,t,n);L(x,at.map(k=>s[k]),t,n)}const I=[];for(let u=0;u<e;u+=2)if(h[u]&&x[u]&&d[u]>.6){const s=u*4;I.push([l[s],l[s+1],l[s+2]])}I.sort((u,s)=>u[0]+u[1]+u[2]-s[0]-s[1]-s[2]);const S=I.length>=30?[0,1,2].map(u=>{const s=I.slice(Math.floor(I.length*u/3),Math.floor(I.length*(u+1)/3));return[0,1,2].map(F=>s.reduce((k,j)=>k+j[F],0)/s.length)}):null,D=new Float32Array(e),T=new Float32Array(e),q=new Float32Array(e),C=new Float32Array(e);for(let u=0;u<e;u++)if(d[u]<.1){const s=u*4;D[u]=1,T[u]=l[s],q[u]=l[s+1],C[u]=l[s+2]}const W=S?ht([D,T,q,C],t,n,Math.max(4,Math.round(o*.6))):null,Z=u=>{if(!S||!x[u])return 1;const s=u%t,F=u/t|0,k=W(0,s,F);if(k<4)return 1;const j=[W(1,s,F)/k,W(2,s,F)/k,W(3,s,F)/k],K=u*4,P=[l[K],l[K+1],l[K+2]];let E=0,et=1/0;for(const it of S){const R=[it[0]-j[0],it[1]-j[1],it[2]-j[2]],lt=R[0]*R[0]+R[1]*R[1]+R[2]*R[2];et=Math.min(et,Math.sqrt(lt)),lt>=1&&(E=Math.max(E,((P[0]-j[0])*R[0]+(P[1]-j[1])*R[1]+(P[2]-j[2])*R[2])/lt))}if(et<a.sep)return 1;const rt=Math.max(0,Math.min(1,(E-.12)/.2));return rt*rt*(3-2*rt)},v=d,G=new Uint8Array(e),[O,J]=a.chokeAI,[gt,Ut]=a.chokeArm;for(let u=0;u<e;u++){if(!r[u])continue;const s=x[u]?O:gt,F=x[u]?J:Ut;if(v[u]<s)continue;const k=Math.max(0,Math.min(1,(v[u]-s)/(F-s)))*Z(u);G[u]=Math.round(255*k*k*(3-2*k))}return pt(G,t,n,{snapped:h,band:r,core:h,arm:f,r:1,rArm:Math.max(2,Math.round(o*a.closeArm)),small:Math.round(.03*o*o)})}const N=[];for(let r=0;r<e;r+=3)if(p[r]){const h=r*4;N.push([l[h],l[h+1],l[h+2]])}if(N.length<12)return i;N.sort((r,h)=>r[0]+r[1]+r[2]-h[0]-h[1]-h[2]);const z=r=>{const h=N.slice(Math.floor(N.length*r/3),Math.floor(N.length*(r+1)/3));return[0,1,2].map(x=>h.reduce((I,S)=>I+S[x],0)/h.length)},$=[z(0),z(1),z(2)],H=new Float32Array(e),B=new Float32Array(e),w=new Float32Array(e),tt=new Float32Array(e);let st=0,ct=0,ft=0,_=0;for(let r=0;r<e;r++)if(U[r]&&!M[r]){const h=r*4;H[r]=1,B[r]=l[h],w[r]=l[h+1],tt[r]=l[h+2],st+=B[r],ct+=w[r],ft+=tt[r],_++}const yt=_?[st/_,ct/_,ft/_]:null,b=ht([H,B,w,tt],t,n,Math.max(3,Math.round(o*.45))),X=new Float32Array(e),nt=new Uint8Array(e);for(let r=0;r<n;r++)for(let h=0;h<t;h++){const x=r*t+h;if(!M[x]&&!(d&&U[x]&&!f[x]&&d[x]>.3))continue;if(nt[x]=1,p[x]){X[x]=1;continue}const I=b(0,h,r),S=I>2?[b(1,h,r)/I,b(2,h,r)/I,b(3,h,r)/I]:yt;if(!S){X[x]=i[x]/255;continue}const D=x*4,T=[l[D],l[D+1],l[D+2]];let q=0,C=1/0;for(const G of $){const O=[G[0]-S[0],G[1]-S[1],G[2]-S[2]],J=O[0]*O[0]+O[1]*O[1]+O[2]*O[2];C=Math.min(C,Math.sqrt(J)),!(J<1)&&(q=Math.max(q,((T[0]-S[0])*O[0]+(T[1]-S[1])*O[1]+(T[2]-S[2])*O[2])/J))}const W=d&&!f[x]?d[x]:null;if(C<a.sep){X[x]=W??i[x]/255;continue}const Z=Math.max(0,Math.min(1,(q-a.lo)/(a.hi-a.lo))),v=Z*Z*(3-2*Z);X[x]=W===null?v:W*v}const xt=kt(X,Ft(l,t,n),t,n,{r:a.guideR,eps:a.guideEps}),ot=new Uint8Array(e),[mt,At]=a.choke;for(let r=0;r<e;r++){if(!nt[r])continue;if(p[r]){ot[r]=255;continue}const h=Math.max(0,Math.min(1,(xt[r]-mt)/(At-mt)));ot[r]=Math.round(255*h*h*(3-2*h))}return pt(ot,t,n,{snapped:i,band:nt,core:p,arm:f,r:Math.max(1,Math.round(o*a.close)),rArm:Math.max(2,Math.round(o*a.closeArm)),small:Math.round(.12*o*o)})}function Mt(l,t,n,g,A,d,y){const a=2*d+1,e=new Uint8Array(n+a),p=new Uint8Array(n+a),M=f=>{const c=Math.max(0,Math.min(n-1,f-d));return l[g+c*A]},U=n+2*d,i=y?(f,c)=>f>c?f:c:(f,c)=>f<c?f:c;for(let f=0;f<U;f+=a){const c=Math.min(U,f+a);e[f]=M(f);for(let m=f+1;m<c;m++)e[m]=i(e[m-1],M(m));p[c-1]=M(c-1);for(let m=c-2;m>=f;m--)p[m]=i(p[m+1],M(m))}for(let f=0;f<n;f++)t[g+f*A]=i(p[f],e[f+2*d]??e[U-1])}function Y(l,t,n,g,A){const d=new Uint8Array(l.length),y=new Uint8Array(l.length);for(let a=0;a<n;a++)Mt(l,d,t,a*t,1,g,A);for(let a=0;a<t;a++)Mt(d,y,n,a,t,g,A);return y}function pt(l,t,n,{snapped:g,band:A,core:d,arm:y,r:a,rArm:e,small:p}){const M=t*n,U=new Uint8Array(M);for(let o=0;o<M;o++)U[o]=l[o]>=128?255:0;const i=Y(Y(U,t,n,a,!0),t,n,a,!1),f=Y(Y(U,t,n,e,!0),t,n,e,!1);for(let o=0;o<M;o++)!U[o]&&A[o]&&(y[o]&&(i[o]||f[o])||!y[o]&&i[o]&&d[o])&&(l[o]=255);It(l,t,n,d,p,y);const c=new Uint8Array(M),m=[];for(let o=0;o<M;o++)d[o]&&l[o]>=64&&m.push(o);for(;m.length;){const o=m.pop();if(c[o]||l[o]<64)continue;c[o]=1;const N=o%t;N>0&&m.push(o-1),N<t-1&&m.push(o+1),o>=t&&m.push(o-t),o<M-t&&m.push(o+t)}for(let o=0;o<M;o++)c[o]||(l[o]=l[o]>=64?0:l[o]);return l}function It(l,t,n,g,A=0,d=null){const y=t*n,a=new Int32Array(y),e=[];for(let i=0;i<t;i++)e.push(i,(n-1)*t+i);for(let i=0;i<n;i++)e.push(i*t,i*t+t-1);const p=(i,f)=>{for(;e.length;){const c=e.pop();if(a[c]||l[c]>=128)continue;a[c]=i,f?.push(c);const m=c%t;m>0&&e.push(c-1),m<t-1&&e.push(c+1),c>=t&&e.push(c-t),c<y-t&&e.push(c+t)}};p(-1);for(let i=0,f=1;i<y;i++){if(a[i]||l[i]>=128)continue;const c=[];e.push(i),p(f++,c);const m=c.length<A&&(!d||c.every(o=>d[o]));for(const o of c)(m||g[o])&&(l[o]=255)}const M=new Uint8Array(y);for(let i=0;i<y;i++)M[i]=a[i]===-1||a[i]>0&&l[i]<128?255:0;const U=Y(M,t,n,2,!0);for(let i=0;i<y;i++)l[i]&&l[i]<255&&!U[i]&&(l[i]=255);return l}function Gt(l,t,n=dt.maxW){const g=Math.min(n,l),A=Math.max(2,Math.round(g*t/l/2)*2);return{w:Math.round(g/2)*2,h:A}}export{dt as HAND_MATTE,V as fillCapsule,L as fillPolygon,Ct as handMatteFrame,Gt as handMatteSize};
1
+ import{g as kt,l as Ft}from"./matteQuality-9X-jgJrH.js";import{cY as Q,cZ as jt}from"./timelineOps-CEGk2t4h.js";import"./titleFrameBudget-BW-N1-cw.js";import"./sceneTrack-DyVxpl7i.js";import"./cameraTracker-DFjnZ7tw.js";import"./textAnimators-CeMuG34D.js";import"./timelineComp-D8PHGHgQ.js";import"./api-DJC95K48.js";import"./i18n-C9zFX25m.js";import"./index-CKtv7gGE.js";import"./store-xR02oY0m.js";import"./rigTrack-B9r9wrdV.js";import"./clientJobs-CuuUyhEy.js";const dt=Object.freeze({core:.5,band:.16,ring:.55,sep:22,lo:.1,hi:.78,guideR:2,guideEps:.002,maxW:512,choke:[.5,.66],close:.08,closeArm:.22,chokeAI:[.45,.62],chokeArm:[.22,.4]}),ut=[[0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]],at=[0,1,5,9,13,17];function V(l,t,n,g,A,d,y=255){const a=Math.max(0,Math.floor(Math.min(t[0],n[0])-g)),e=Math.min(A-1,Math.ceil(Math.max(t[0],n[0])+g)),p=Math.max(0,Math.floor(Math.min(t[1],n[1])-g)),M=Math.min(d-1,Math.ceil(Math.max(t[1],n[1])+g)),U=n[0]-t[0],i=n[1]-t[1],f=U*U+i*i||1,c=g*g;for(let m=p;m<=M;m++)for(let o=a;o<=e;o++){const N=o+.5-t[0],z=m+.5-t[1],$=Math.max(0,Math.min(1,(N*U+z*i)/f)),H=N-$*U,B=z-$*i;H*H+B*B<=c&&l[m*A+o]<y&&(l[m*A+o]=y)}return l}function W(l,t,n,g,A=255){const d=t.length;if(d<3)return l;let y=1/0,a=-1/0;for(const p of t)p[1]<y&&(y=p[1]),p[1]>a&&(a=p[1]);y=Math.max(0,Math.floor(y)),a=Math.min(g-1,Math.ceil(a));const e=[];for(let p=y;p<=a;p++){const M=p+.5;e.length=0;for(let i=0,f=d-1;i<d;f=i++){const c=t[f],m=t[i];(c[1]<=M&&m[1]>M||m[1]<=M&&c[1]>M)&&e.push([c[0]+(M-c[1])/(m[1]-c[1])*(m[0]-c[0]),m[1]>c[1]?1:-1])}if(e.length<2)continue;e.sort((i,f)=>i[0]-f[0]);let U=0;for(let i=0;i<e.length-1;i++){if(U+=e[i][1],!U)continue;const f=Math.max(0,Math.ceil(e[i][0]-.5)),c=Math.min(n-1,Math.floor(e[i+1][0]-.5)),m=p*n;for(let o=f;o<=c;o++)l[m+o]<A&&(l[m+o]=A)}}return l}function ht(l,t,n,g){const A=t+1,d=l.map(y=>{const a=new Float64Array(A*(n+1));for(let e=0;e<n;e++){let p=0;for(let M=0;M<t;M++)p+=y[e*t+M],a[(e+1)*A+M+1]=a[e*A+M+1]+p}return a});return(y,a,e)=>{const p=d[y],M=Math.max(0,a-g),U=Math.min(t,a+g+1),i=Math.max(0,e-g),f=Math.min(n,e+g+1);return p[f*A+U]-p[i*A+U]-p[f*A+M]+p[i*A+M]}}function Ct(l,t,n,g,A={}){const{learned:d=null,...y}=A,a={...dt,...y},e=t*n,p=new Uint8Array(e),M=new Uint8Array(e),U=new Uint8Array(e),i=new Uint8Array(e),f=new Uint8Array(e),c=(g||[]).filter(r=>r?.lm?.length>=21);if(!c.length)return new Uint8Array(e);const m=r=>r.map(([h,x])=>[h*t,x*n]);let o=0;for(const r of c){o=Math.max(o,Math.hypot((r.lm[0][0]-r.lm[9][0])*t,(r.lm[0][1]-r.lm[9][1])*n)),W(p,m(Q(r.lm,t,n,{edge:r.edge?r.edge.map(x=>Math.min(0,x)):null,scale:a.core})),t,n),W(i,m(Q(r.lm,t,n,{edge:r.edge})),t,n),W(M,m(Q(r.lm,t,n,{edge:r.edge,grow:a.band})),t,n),W(U,m(Q(r.lm,t,n,{edge:r.edge,grow:a.ring})),t,n);const h=Q(r.lm,t,n,{edge:r.edge,grow:a.band});W(f,m(jt.map(x=>h[x])),t,n)}if(d){const r=new Uint8Array(e),h=new Uint8Array(e);for(const u of c){const s=u.lm.map(([P,L])=>[P*t,L*n]),F=Math.hypot(s[0][0]-s[9][0],s[0][1]-s[9][1]),k=Array.isArray(u.armDir)?u.armDir:[(s[0][0]-s[9][0])/(F||1),(s[0][1]-s[9][1])/(F||1)],j=[s[0][0]+k[0]*4*F,s[0][1]+k[1]*4*F];for(const[P,L]of ut)V(r,s[P],s[L],.45*F,t,n),V(h,s[P],s[L],.08*F,t,n);W(r,at.map(P=>s[P]),t,n),W(h,at.map(P=>s[P]),t,n);const K=[s[0][0]+k[0]*Math.max(t,n)*1.5,s[0][1]+k[1]*Math.max(t,n)*1.5];V(r,s[0],K,1.6*F,t,n),V(h,s[0],j,.12*F,t,n)}const x=new Uint8Array(e);for(const u of c){const s=u.lm.map(([k,j])=>[k*t,j*n]),F=Math.hypot(s[0][0]-s[9][0],s[0][1]-s[9][1]);for(const[k,j]of ut)V(x,s[k],s[j],.45*F,t,n);W(x,at.map(k=>s[k]),t,n)}const I=[];for(let u=0;u<e;u+=2)if(h[u]&&x[u]&&d[u]>.6){const s=u*4;I.push([l[s],l[s+1],l[s+2]])}I.sort((u,s)=>u[0]+u[1]+u[2]-s[0]-s[1]-s[2]);const S=I.length>=30?[0,1,2].map(u=>{const s=I.slice(Math.floor(I.length*u/3),Math.floor(I.length*(u+1)/3));return[0,1,2].map(F=>s.reduce((k,j)=>k+j[F],0)/s.length)}):null,D=new Float32Array(e),T=new Float32Array(e),q=new Float32Array(e),C=new Float32Array(e);for(let u=0;u<e;u++)if(d[u]<.1){const s=u*4;D[u]=1,T[u]=l[s],q[u]=l[s+1],C[u]=l[s+2]}const E=S?ht([D,T,q,C],t,n,Math.max(4,Math.round(o*.6))):null,Y=u=>{if(!S||!x[u])return 1;const s=u%t,F=u/t|0,k=E(0,s,F);if(k<4)return 1;const j=[E(1,s,F)/k,E(2,s,F)/k,E(3,s,F)/k],K=u*4,P=[l[K],l[K+1],l[K+2]];let L=0,et=1/0;for(const it of S){const R=[it[0]-j[0],it[1]-j[1],it[2]-j[2]],lt=R[0]*R[0]+R[1]*R[1]+R[2]*R[2];et=Math.min(et,Math.sqrt(lt)),lt>=1&&(L=Math.max(L,((P[0]-j[0])*R[0]+(P[1]-j[1])*R[1]+(P[2]-j[2])*R[2])/lt))}if(et<a.sep)return 1;const rt=Math.max(0,Math.min(1,(L-.12)/.2));return rt*rt*(3-2*rt)},v=d,G=new Uint8Array(e),[O,J]=a.chokeAI,[gt,Ut]=a.chokeArm;for(let u=0;u<e;u++){if(!r[u])continue;const s=x[u]?O:gt,F=x[u]?J:Ut;if(v[u]<s)continue;const k=Math.max(0,Math.min(1,(v[u]-s)/(F-s)))*Y(u);G[u]=Math.round(255*k*k*(3-2*k))}return pt(G,t,n,{snapped:h,band:r,core:h,arm:f,r:1,rArm:Math.max(2,Math.round(o*a.closeArm)),small:Math.round(.03*o*o)})}const N=[];for(let r=0;r<e;r+=3)if(p[r]){const h=r*4;N.push([l[h],l[h+1],l[h+2]])}if(N.length<12)return i;N.sort((r,h)=>r[0]+r[1]+r[2]-h[0]-h[1]-h[2]);const z=r=>{const h=N.slice(Math.floor(N.length*r/3),Math.floor(N.length*(r+1)/3));return[0,1,2].map(x=>h.reduce((I,S)=>I+S[x],0)/h.length)},$=[z(0),z(1),z(2)],H=new Float32Array(e),B=new Float32Array(e),w=new Float32Array(e),tt=new Float32Array(e);let st=0,ct=0,ft=0,Z=0;for(let r=0;r<e;r++)if(U[r]&&!M[r]){const h=r*4;H[r]=1,B[r]=l[h],w[r]=l[h+1],tt[r]=l[h+2],st+=B[r],ct+=w[r],ft+=tt[r],Z++}const yt=Z?[st/Z,ct/Z,ft/Z]:null,b=ht([H,B,w,tt],t,n,Math.max(3,Math.round(o*.45))),_=new Float32Array(e),nt=new Uint8Array(e);for(let r=0;r<n;r++)for(let h=0;h<t;h++){const x=r*t+h;if(!M[x]&&!(d&&U[x]&&!f[x]&&d[x]>.3))continue;if(nt[x]=1,p[x]){_[x]=1;continue}const I=b(0,h,r),S=I>2?[b(1,h,r)/I,b(2,h,r)/I,b(3,h,r)/I]:yt;if(!S){_[x]=i[x]/255;continue}const D=x*4,T=[l[D],l[D+1],l[D+2]];let q=0,C=1/0;for(const G of $){const O=[G[0]-S[0],G[1]-S[1],G[2]-S[2]],J=O[0]*O[0]+O[1]*O[1]+O[2]*O[2];C=Math.min(C,Math.sqrt(J)),!(J<1)&&(q=Math.max(q,((T[0]-S[0])*O[0]+(T[1]-S[1])*O[1]+(T[2]-S[2])*O[2])/J))}const E=d&&!f[x]?d[x]:null;if(C<a.sep){_[x]=E??i[x]/255;continue}const Y=Math.max(0,Math.min(1,(q-a.lo)/(a.hi-a.lo))),v=Y*Y*(3-2*Y);_[x]=E===null?v:E*v}const xt=kt(_,Ft(l,t,n),t,n,{r:a.guideR,eps:a.guideEps}),ot=new Uint8Array(e),[mt,At]=a.choke;for(let r=0;r<e;r++){if(!nt[r])continue;if(p[r]){ot[r]=255;continue}const h=Math.max(0,Math.min(1,(xt[r]-mt)/(At-mt)));ot[r]=Math.round(255*h*h*(3-2*h))}return pt(ot,t,n,{snapped:i,band:nt,core:p,arm:f,r:Math.max(1,Math.round(o*a.close)),rArm:Math.max(2,Math.round(o*a.closeArm)),small:Math.round(.12*o*o)})}function Mt(l,t,n,g,A,d,y){const a=2*d+1,e=new Uint8Array(n+a),p=new Uint8Array(n+a),M=f=>{const c=Math.max(0,Math.min(n-1,f-d));return l[g+c*A]},U=n+2*d,i=y?(f,c)=>f>c?f:c:(f,c)=>f<c?f:c;for(let f=0;f<U;f+=a){const c=Math.min(U,f+a);e[f]=M(f);for(let m=f+1;m<c;m++)e[m]=i(e[m-1],M(m));p[c-1]=M(c-1);for(let m=c-2;m>=f;m--)p[m]=i(p[m+1],M(m))}for(let f=0;f<n;f++)t[g+f*A]=i(p[f],e[f+2*d]??e[U-1])}function X(l,t,n,g,A){const d=new Uint8Array(l.length),y=new Uint8Array(l.length);for(let a=0;a<n;a++)Mt(l,d,t,a*t,1,g,A);for(let a=0;a<t;a++)Mt(d,y,n,a,t,g,A);return y}function pt(l,t,n,{snapped:g,band:A,core:d,arm:y,r:a,rArm:e,small:p}){const M=t*n,U=new Uint8Array(M);for(let o=0;o<M;o++)U[o]=l[o]>=128?255:0;const i=X(X(U,t,n,a,!0),t,n,a,!1),f=X(X(U,t,n,e,!0),t,n,e,!1);for(let o=0;o<M;o++)!U[o]&&A[o]&&(y[o]&&(i[o]||f[o])||!y[o]&&i[o]&&d[o])&&(l[o]=255);It(l,t,n,d,p,y);const c=new Uint8Array(M),m=[];for(let o=0;o<M;o++)d[o]&&l[o]>=64&&m.push(o);for(;m.length;){const o=m.pop();if(c[o]||l[o]<64)continue;c[o]=1;const N=o%t;N>0&&m.push(o-1),N<t-1&&m.push(o+1),o>=t&&m.push(o-t),o<M-t&&m.push(o+t)}for(let o=0;o<M;o++)c[o]||(l[o]=l[o]>=64?0:l[o]);return l}function It(l,t,n,g,A=0,d=null){const y=t*n,a=new Int32Array(y),e=[];for(let i=0;i<t;i++)e.push(i,(n-1)*t+i);for(let i=0;i<n;i++)e.push(i*t,i*t+t-1);const p=(i,f)=>{for(;e.length;){const c=e.pop();if(a[c]||l[c]>=128)continue;a[c]=i,f?.push(c);const m=c%t;m>0&&e.push(c-1),m<t-1&&e.push(c+1),c>=t&&e.push(c-t),c<y-t&&e.push(c+t)}};p(-1);for(let i=0,f=1;i<y;i++){if(a[i]||l[i]>=128)continue;const c=[];e.push(i),p(f++,c);const m=c.length<A&&(!d||c.every(o=>d[o]));for(const o of c)(m||g[o])&&(l[o]=255)}const M=new Uint8Array(y);for(let i=0;i<y;i++)M[i]=a[i]===-1||a[i]>0&&l[i]<128?255:0;const U=X(M,t,n,2,!0);for(let i=0;i<y;i++)l[i]&&l[i]<255&&!U[i]&&(l[i]=255);return l}function Gt(l,t,n=dt.maxW){const g=Math.min(n,l),A=Math.max(2,Math.round(g*t/l/2)*2);return{w:Math.round(g/2)*2,h:A}}export{dt as HAND_MATTE,V as fillCapsule,W as fillPolygon,Ct as handMatteFrame,Gt as handMatteSize};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/objectSegmenter-D66spD7o.js","assets/titleFrameBudget-DsM0V482.js","assets/personHq-Ca351o06.js","assets/matteQuality-9X-jgJrH.js","assets/api-Dnl2uaKO.js","assets/i18n-C9zFX25m.js","assets/index-CKtv7gGE.js","assets/cutoutClean-CLYYAuXg.js","assets/handMatte-Dj2taFoC.js","assets/timelineOps-DSSaDsU2.js","assets/sceneTrack-DlAH5s74.js","assets/cameraTracker-DHdF8Zqx.js","assets/textAnimators-B9vO_hbP.js","assets/timelineComp-i-zdaoB2.js","assets/store-CpqHUcA2.js","assets/rigTrack-DMyqb0pb.js","assets/clientJobs-CuuUyhEy.js","assets/matteFixRun-CytaeRzS.js","assets/main-CwrkBJ63.js","assets/remote-8XzEAnAJ.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/rotoMaskStore-pE1AIt3I.js","assets/spark.module-DjaIF6J1.js","assets/userFonts-Djka6RJX.js","assets/lottieLayer-Cv8ub9f6.js","assets/timeline3d-DrFaMPPB.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/glTransitionSources.generated-q0H-ZbnZ.js","assets/clientJobs-CcsLDqFM.js","assets/captionLayout-cckQ7p-t.js","assets/timelineText-DurRhyuh.js","assets/titleArt-CnC0A7x7.js","assets/sceneTrack-CA21MCOP.js","assets/rotoMatte-7b7Ow64f.js","assets/distortGL-vhnBRB59.js","assets/motionBlur-uAm030t9.js","assets/main-B_MAOvi6.css"])))=>i.map(i=>d[i]);
2
- import{b_ as Y,_ as N,a7 as Z,da as tt}from"./titleFrameBudget-DsM0V482.js";import{u as j}from"./store-CpqHUcA2.js";import{t as W}from"./i18n-C9zFX25m.js";import{m as et,g as at,S as X,M as nt}from"./personHq-Ca351o06.js";import{cM as ot,cN as it,cO as Q,cP as rt,cQ as st,cR as K,cS as ct,aw as z,cT as lt,cU as dt,cV as mt}from"./timelineOps-DSSaDsU2.js";import{handMatteSize as ut,handMatteFrame as ht}from"./handMatte-Dj2taFoC.js";import{t as ft}from"./matteQuality-9X-jgJrH.js";import"./index-CKtv7gGE.js";import"./api-Dnl2uaKO.js";import"./sceneTrack-DlAH5s74.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const pt="https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task",wt=`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${X}/wasm`,gt=640;let $=null;async function yt(){if(typeof window<"u"&&window.__handTrackerStub)return{detect:window.__handTrackerStub,close:()=>{}};const{FilesetResolver:d,HandLandmarker:w}=await N(async()=>{const{FilesetResolver:c,HandLandmarker:s}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:c,HandLandmarker:s}},[]);$??=d.forVisionTasks(wt).catch(c=>{throw $=null,c});const a=await w.createFromOptions(await $,{baseOptions:{modelAssetPath:pt,delegate:"CPU"},runningMode:"VIDEO",numHands:2,minHandDetectionConfidence:.5,minHandPresenceConfidence:.5,minTrackingConfidence:.5});let f=0;return{detect:(c,s)=>{f=Math.max(f+1,Math.round(s));const b=a.detectForVideo(c,f);return(b.landmarks??[]).map((m,v)=>({lm:m.map(p=>[p.x,p.y]),label:b.handedness?.[v]?.[0]?.categoryName??"",score:b.handedness?.[v]?.[0]?.score??1}))},close:()=>a.close()}}async function Mt({clip:d,url:w,from:a,duration:f,signal:c,onProgress:s}){const b=f*(d.playbackRate||1),m=b*30<=K.maxFrames?30:15,v=Math.max(2,Math.min(K.maxFrames,Math.round(b*m)+1)),{detect:p,close:C}=await yt(),u=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});u.src=w;try{await new Promise((i,h)=>{u.onloadeddata=()=>i(),u.onerror=()=>h(Error(W("Không đọc được video để bám tay (CORS / định dạng)")))});const x=u.videoWidth||1280,H=u.videoHeight||720,_=Math.min(gt,x),o=Math.max(2,Math.round(_*H/x)),r=Object.assign(document.createElement("canvas"),{width:_,height:o}),y=r.getContext("2d",{willReadFrequently:!0}),E=z(d,a),T=[];let n=[null,null];for(let i=0;i<v;i++){if(c?.aborted)throw new DOMException("Đã huỷ","AbortError");const h=Math.max(0,Math.min(u.duration-1/60,E+i/m));Math.abs(u.currentTime-h)>1e-4&&await new Promise((t,e)=>{const l=window.setTimeout(()=>e(Error(W("Seek video quá lâu"))),8e3);u.onseeked=()=>{window.clearTimeout(l),t()},u.currentTime=h}),y.drawImage(u,0,0,_,o);const S=p(r,(i+1)*1e3/m).filter(t=>Array.isArray(t.lm)&&t.lm.length>=21).slice(0,2),k=[null,null],F=t=>t.label==="Left"?0:t.label==="Right"?1:-1,M=(t,e)=>{const l=n[e];return l?Math.hypot(l.lm[0][0]-t.lm[0][0],l.lm[0][1]-t.lm[0][1]):1/0};if(S.length===2&&F(S[0])===F(S[1])){const t=S[0],e=S[1],l=M(t,0)+M(e,1)<=M(t,1)+M(e,0),[I,A]=Number.isFinite(M(t,0)+M(e,1))||Number.isFinite(M(t,1)+M(e,0))?l?[t,e]:[e,t]:t.lm[0][0]>e.lm[0][0]?[t,e]:[e,t];k[0]={lm:I.lm.map(R=>[R[0],R[1]]),score:I.score},k[1]={lm:A.lm.map(R=>[R[0],R[1]]),score:A.score}}else for(const t of S){let e=F(t);if(e<0&&(e=t.lm[0][0]>.5?0:1),S.length===1){const l=1-e;M(t,l)<.08&&M(t,e)>.15&&(e=l)}k[e]||(k[e]={lm:t.lm.map(l=>[l[0],l[1]]),score:t.score})}if(k.some(Boolean)){const t=y.getImageData(0,0,_,o).data,e=(l,I)=>{const A=(Math.max(0,Math.min(o-1,I))*_+Math.max(0,Math.min(_-1,l)))*4;return[t[A],t[A+1],t[A+2]]};for(const l of k)if(l){const I=dt(l.lm,_,o,e);I&&(l.edge=I)}}T.push(k),n=[k[0]??n[0],k[1]??n[1]],s?.(i+1,v)}return mt({mw:x,mh:H,fps:m,s0:E,frames:T})}finally{u.removeAttribute("src"),u.load(),C()}}let B=null,q=null;async function xt(d,w,a){const f=typeof window<"u"?window.__bodySkinStub:void 0;B??=f?Promise.resolve(f):(async()=>{const{FilesetResolver:p,ImageSegmenter:C}=await N(async()=>{const{FilesetResolver:H,ImageSegmenter:_}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:H,ImageSegmenter:_}},[]),u=await p.forVisionTasks(`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${X}/wasm`),x=await C.createFromOptions(u,{baseOptions:{modelAssetPath:nt,delegate:"CPU"},runningMode:"IMAGE",outputConfidenceMasks:!0,outputCategoryMask:!1});return H=>{const _=x.segment(H);try{const o=_.confidenceMasks?.[2];if(!o)throw Error("no skin mask");return{data:o.getAsFloat32Array().slice(),width:o.width,height:o.height}}finally{_.close()}}})().catch(p=>{throw B=null,p});const c=await B;q??=document.createElement("canvas");const s=960,b=Math.max(2,Math.round(960*d.height/d.width));(q.width!==s||q.height!==b)&&Object.assign(q,{width:s,height:b}),q.getContext("2d").drawImage(d,0,0,s,b);const m=c(q),v=new Float32Array(w*a);for(let p=0;p<a;p++){const C=Math.min(m.height-1,Math.floor((p+.5)/a*m.height))*m.width;for(let u=0;u<w;u++){const x=m.data[C+Math.min(m.width-1,Math.floor((u+.5)/w*m.width))];v[p*w+u]=Math.max(0,Math.min(1,(x-.25)/.4))}}return v}const kt=[0,1,2,3,5,6,7,9,10,11,13,14,15,17,18,19];let G=null;async function bt(d,w,a,f,c,s){const{objectProbability:b}=await N(async()=>{const{objectProbability:o}=await import("./objectSegmenter-D66spD7o.js");return{objectProbability:o}},__vite__mapDeps([0,1,2,3,4,5,6,7])),m=new Float32Array(c*s),v=512;G??=Object.assign(document.createElement("canvas"),{width:v,height:v});const p=G.getContext("2d",{willReadFrequently:!0}),C=async(o,r,y,E,T)=>{p.fillStyle="#000",p.fillRect(0,0,v,v),p.drawImage(d,o,r,y,E,0,0,v,v);const n=await b(G,T.map(h=>({x:(h.x-o)/y,y:(h.y-r)/E})).filter(h=>h.x>0&&h.x<1&&h.y>0&&h.y<1)),i=new Float32Array(c*s);for(let h=0;h<s;h++){const S=((h+.5)/s*a-r)/E;if(S<0||S>=1)continue;const k=Math.floor(S*n.height)*n.width;for(let F=0;F<c;F++){const M=((F+.5)/c*w-o)/y;M<0||M>=1||(i[h*c+F]=n.data[k+Math.floor(M*n.width)])}}return i},{fillCapsule:u,fillPolygon:x}=await N(async()=>{const{fillCapsule:o,fillPolygon:r}=await import("./handMatte-Dj2taFoC.js");return{fillCapsule:o,fillPolygon:r}},__vite__mapDeps([8,3,9,1,10,11,12,13,4,5,6,14,15,16])),H=[],_=await xt(d,c,s);for(const{lm:o}of f){const r=o.map(t=>t[0]*w),y=o.map(t=>t[1]*a),E=Math.hypot(r[0]-r[9],y[0]-y[9])||1,T=kt.map(t=>({x:r[t],y:y[t]}));T.push({x:r[0]+(r[0]-r[9])*.6,y:y[0]+(y[0]-y[9])*.6});const i=await C(...((t,e,l,I=1)=>{const A=Math.min(...t)-l,R=Math.max(...t)+l,O=Math.min(...e)-l,g=Math.max(...e)+l,P=Math.max(R-A,g-O),D=Math.min(w,Math.max(R-A,P/I)),V=Math.min(a,Math.max(g-O,P/I)),L=Math.min(D,V*I),U=Math.min(V,D*I);return[Math.max(0,Math.min(w-L,(A+R)/2-L/2)),Math.max(0,Math.min(a-U,(O+g)/2-U/2)),L,U]})([...r,r[0]+(r[0]-r[9])*3],[...y,y[0]+(y[0]-y[9])*3],.6*E),T);let h=(r[0]-r[9])/E,S=(y[0]-y[9])/E;{const t=r[0]/w*c,e=y[0]/a*s,l=E/w*c;let I=0,A=0,R=0;for(let O=0;O<s;O++)for(let g=0;g<c;g++){if(i[O*c+g]<.5)continue;const P=Math.hypot(g-t,O-e);if(P<1.2*l||P>3*l)continue;const D=g-t,V=O-e;D*h+V*S<-.2*P||(I+=g,A+=O,R++)}if(R>20){const O=I/R-t,g=A/R-e,P=Math.hypot(O,g)||1;(O*h+g*S)/P>Math.cos(75*Math.PI/180)&&(h=O/P,S=g/P)}}H.push([h,S]);const k=new Uint8Array(c*s),F=r.map((t,e)=>[t/w*c,y[e]/a*s]),M=E/w*c;for(const[t,e]of[[1,2],[2,3],[3,4],[5,6],[6,7],[7,8],[9,10],[10,11],[11,12],[13,14],[14,15],[15,16],[17,18],[18,19],[19,20],[0,1],[0,5],[0,17]])u(k,F[t],F[e],.35*M,c,s);x(k,[0,1,5,9,13,17].map(t=>F[t]),c,s);for(let t=0;t<c*s;t++){const e=k[t]?Math.max(i[t],_[t]*.5):_[t];e>m[t]&&(m[t]=e)}}return{map:m,armDirs:H}}async function J({clip:d,url:w,from:a,duration:f,until:c=1/0,refine:s=null,store:b=!0,signal:m,onProgress:v}){if(!d.hands)throw Error(W("Không tìm thấy clip video có tay"));const p=ct(d.hands),C=d.playbackRate||1,u=p.fps,x=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});x.src=w;try{await new Promise((t,e)=>{x.onloadeddata=()=>t(),x.onerror=()=>e(Error(W("Không đọc được video để bám tay (CORS / định dạng)")))});const H=x.videoWidth||p.mw,_=x.videoHeight||p.mh,{w:o,h:r}=ut(H,_),y=Object.assign(document.createElement("canvas"),{width:o,height:r}),E=y.getContext("2d",{willReadFrequently:!0}),T=z(d,a),n=Math.max(1,Math.min(K.maxFrames,Math.round(f*C*u)+1)),i=z(d,c),h=et({mw:H,mh:_,w:o,h:r,fps:u,s0:T},32),S=ft(t=>h.push(t)),k=s?await Z(s):null,F=at(x);let M=!0;for(let t=0;t<n;t++){if(m?.aborted)throw new DOMException("Đã huỷ","AbortError");const e=T+t/u;if(e>i+1e-6){S.push(new Uint8Array(o*r)),v?.(t+1,n);continue}const l=await F(Math.max(0,Math.min(x.duration-1/60,e)));E.drawImage(l,0,0,o,r);const I=Math.max(0,Math.min(p.n-1,Math.round((e-p.s0)*u))),A=[0,1].map(g=>{const P=lt(p,e,g);return P?{lm:P,edge:p.frames[I][g]?.edge??null}:null}).filter(Boolean);let R=null;if(M&&A.length)try{const g=await bt(l,H,_,A,o,r);R=g.map,g.armDirs.forEach((P,D)=>{A[D].armDir=P})}catch(g){M=!1,console.warn("hand cut-out model",g)}let O=A.length?ht(E.getImageData(0,0,o,r).data,o,r,A,{learned:R}):new Uint8Array(o*r);if(k&&s){const g=tt(k,s,e),P=s.w,D=s.h,V=new Uint8Array(o*r);for(let L=0;L<r;L++)for(let U=0;U<o;U++)V[L*o+U]=Math.round(O[L*o+U]*g[Math.min(D-1,Math.floor(L*D/r))*P+Math.min(P-1,Math.floor(U*P/o))]/255);O=V}S.push(O),v?.(t+1,n),t%4===3&&await new Promise(g=>setTimeout(g,0))}return S.finish(),await h.finish({feather:0,grow:0},{store:b})}finally{x.removeAttribute("src"),x.load()}}async function vt(d,w,a){const f=j.getState().clips.find(b=>b.id===d);if(!f||f.kind!=="video")throw Error(W("Không tìm thấy clip video có tay"));if(st(f,w,a))return f;const c=document.querySelector(`video[data-clip-media="${f.id}"]`)?.currentSrc||f.url,s=await Mt({clip:f,url:c,from:w,duration:Math.min(a,K.maxFrames/15/(f.playbackRate||1))});if(!s.data||!/[^A]/.test(s.data.replace(/=+$/,"")))throw Error(W("Không thấy bàn tay nào trong đoạn này"));return j.setState(b=>({clips:b.clips.map(m=>m.id===f.id?{...m,hands:s}:m)})),{...f,hands:s}}const St=d=>new Promise(w=>setTimeout(w,d));async function jt(d,w){const a=w.params??{},f=await vt(String(a.source),a.from??0,a.duration??d.duration),c=j.getState(),{width:s,height:b}=Y(c.timelineFormat);if(a.mode==="attach"){const n=c.clips.find(i=>i.id===d.id)??d;return ot(n,f,{point:a.point,side:a.side,scale:!!a.scale,offset:a.offset??null,W:s,H:b})}if(a.mode==="wipe"){const n=c.clips.find(e=>e.id===d.id)??d,i=c.clips.find(e=>e.id===f.id)??f,h=n.mask,S=it(n,i,{point:a.point,side:a.side,dir:a.dir,feather:a.feather,W:s,H:b,mw:h?.mw,mh:h?.mh}),k=c.clips.find(e=>e.id===a.cutout),F=document.querySelector(`video[data-clip-media="${i.id}"]`)?.currentSrc||i.url;let M=null;if(k)try{M=await J({clip:i,url:F,from:a.from??0,duration:a.duration??d.duration,refine:k.person??null})}catch(e){console.warn("hand matte",e)}const t=M||!k?void 0:Q({...k,hands:i.hands});return j.setState(e=>({clips:e.clips.map(l=>l.id===a.cutout?M?{...l,person:M,mask:void 0}:t?{...l,mask:t}:l:l)})),S.patch}for(let n=0;n<360&&j.getState().clips.find(i=>i.id===a.wall)?.pendingPin;n++)await St(500);const m=j.getState(),v=m.clips.find(n=>n.id===a.wall),p=m.clips.find(n=>n.id===d.id)??d,C=m.clips.find(n=>n.id===f.id)??f;if(!v)throw Error(W("Không còn tường HUD"));const u=rt({wall:v,layer:p,src:C,clips:m.clips,cam:m.timelineCamera,W:s,H:b,events:a.events??null,grab:a.grab??"auto",side:a.side,fly:a.fly}),x=m.clips.find(n=>n.id===a.cutout),H=document.querySelector(`video[data-clip-media="${C.id}"]`)?.currentSrc||C.url,_=(a.matte?m.clips.find(n=>n.id===a.matte)?.person:null)??x?.person??null;let o=null;if(x)try{o=await J({clip:C,url:H,from:a.from??0,duration:a.duration??d.duration,until:u.cutoutUntil,refine:_})}catch(n){console.warn("hand matte",n)}const r=x?.matteFix?.fixes??[],y=o;if(o&&r.length)try{const{fixedMatte:n}=await N(async()=>{const{fixedMatte:i}=await import("./matteFixRun-CytaeRzS.js");return{fixedMatte:i}},__vite__mapDeps([17,14,1,6,5,2,3,4,9,10,11,12,13,15,16,8,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,0,7,35,36,37]));o=await n(o,r,C.hands)}catch(n){console.warn("hand touch-ups",n)}const E=o?void 0:Q(C,{until:u.cutoutUntil}),T=n=>{const i=n.mask?.masks?.find(h=>h.id==="wall");return!i||!n.mask?n:o?{...n,person:o,mask:{...n.mask,masks:[{...i,mode:"add"}]}}:E?{...n,mask:{...E,masks:[...E.masks,{...i,mode:"intersect"}]}}:n};return j.setState(n=>({clips:n.clips.map(i=>i.id===v.id?{...i,motion:u.wall}:i.id===a.cutout?o?{...i,person:o,mask:void 0,...r.length?{matteFix:{auto:y,fixes:r}}:{}}:E?{...i,mask:E}:i:i.id===a.shadow?T(i):i)})),{motion:u.grab}}export{pt as HAND_MODEL_URL,J as buildHandMatte,bt as learnedHands,jt as runHandTrack,Mt as trackHands};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/objectSegmenter-oGv8YQbI.js","assets/titleFrameBudget-BW-N1-cw.js","assets/personHq-Cyq9HWnW.js","assets/matteQuality-9X-jgJrH.js","assets/api-DJC95K48.js","assets/i18n-C9zFX25m.js","assets/index-CKtv7gGE.js","assets/cutoutClean-CLYYAuXg.js","assets/handMatte-CvFkZKTL.js","assets/timelineOps-CEGk2t4h.js","assets/sceneTrack-DyVxpl7i.js","assets/cameraTracker-DFjnZ7tw.js","assets/textAnimators-CeMuG34D.js","assets/timelineComp-D8PHGHgQ.js","assets/store-xR02oY0m.js","assets/rigTrack-B9r9wrdV.js","assets/clientJobs-CuuUyhEy.js","assets/matteFixRun-BHD3Qnta.js","assets/main-DAk1Tv1E.js","assets/remote-kxNNhmis.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/rotoMaskStore-RmW40Pcn.js","assets/spark.module-B341moK0.js","assets/userFonts-DSkZHfmh.js","assets/lottieLayer-Dp_vGTy8.js","assets/timeline3d-D0Ws4lcp.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/glTransitionSources.generated-BJuEUz3E.js","assets/clientJobs-BqkjV5Ld.js","assets/captionLayout-CAuhUiW9.js","assets/timelineText-DjPW2-dd.js","assets/titleArt-BSu80bfN.js","assets/sceneTrack-BKknn180.js","assets/rotoMatte-DisQplSv.js","assets/distortGL-waTJhiOf.js","assets/motionBlur-uAm030t9.js","assets/main-B_MAOvi6.css"])))=>i.map(i=>d[i]);
2
+ import{b_ as Y,_ as N,a7 as Z,da as tt}from"./titleFrameBudget-BW-N1-cw.js";import{u as W}from"./store-xR02oY0m.js";import{t as j}from"./i18n-C9zFX25m.js";import{m as et,g as at,S as J,M as nt}from"./personHq-Cyq9HWnW.js";import{cO as ot,cP as it,cQ as Q,cR as rt,cS as st,cT as K,cU as ct,ay as z,cV as lt,cW as dt,cX as mt}from"./timelineOps-CEGk2t4h.js";import{handMatteSize as ut,handMatteFrame as ht}from"./handMatte-CvFkZKTL.js";import{t as ft}from"./matteQuality-9X-jgJrH.js";import"./index-CKtv7gGE.js";import"./api-DJC95K48.js";import"./sceneTrack-DyVxpl7i.js";import"./cameraTracker-DFjnZ7tw.js";import"./textAnimators-CeMuG34D.js";import"./timelineComp-D8PHGHgQ.js";import"./rigTrack-B9r9wrdV.js";import"./clientJobs-CuuUyhEy.js";const pt="https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task",wt=`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${J}/wasm`,gt=640;let $=null;async function yt(){if(typeof window<"u"&&window.__handTrackerStub)return{detect:window.__handTrackerStub,close:()=>{}};const{FilesetResolver:d,HandLandmarker:w}=await N(async()=>{const{FilesetResolver:c,HandLandmarker:s}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:c,HandLandmarker:s}},[]);$??=d.forVisionTasks(wt).catch(c=>{throw $=null,c});const a=await w.createFromOptions(await $,{baseOptions:{modelAssetPath:pt,delegate:"CPU"},runningMode:"VIDEO",numHands:2,minHandDetectionConfidence:.5,minHandPresenceConfidence:.5,minTrackingConfidence:.5});let f=0;return{detect:(c,s)=>{f=Math.max(f+1,Math.round(s));const b=a.detectForVideo(c,f);return(b.landmarks??[]).map((m,v)=>({lm:m.map(p=>[p.x,p.y]),label:b.handedness?.[v]?.[0]?.categoryName??"",score:b.handedness?.[v]?.[0]?.score??1}))},close:()=>a.close()}}async function Mt({clip:d,url:w,from:a,duration:f,signal:c,onProgress:s}){const b=f*(d.playbackRate||1),m=b*30<=K.maxFrames?30:15,v=Math.max(2,Math.min(K.maxFrames,Math.round(b*m)+1)),{detect:p,close:C}=await yt(),u=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});u.src=w;try{await new Promise((i,h)=>{u.onloadeddata=()=>i(),u.onerror=()=>h(Error(j("Không đọc được video để bám tay (CORS / định dạng)")))});const x=u.videoWidth||1280,H=u.videoHeight||720,_=Math.min(gt,x),o=Math.max(2,Math.round(_*H/x)),r=Object.assign(document.createElement("canvas"),{width:_,height:o}),y=r.getContext("2d",{willReadFrequently:!0}),E=z(d,a),T=[];let n=[null,null];for(let i=0;i<v;i++){if(c?.aborted)throw new DOMException("Đã huỷ","AbortError");const h=Math.max(0,Math.min(u.duration-1/60,E+i/m));Math.abs(u.currentTime-h)>1e-4&&await new Promise((t,e)=>{const l=window.setTimeout(()=>e(Error(j("Seek video quá lâu"))),8e3);u.onseeked=()=>{window.clearTimeout(l),t()},u.currentTime=h}),y.drawImage(u,0,0,_,o);const S=p(r,(i+1)*1e3/m).filter(t=>Array.isArray(t.lm)&&t.lm.length>=21).slice(0,2),k=[null,null],F=t=>t.label==="Left"?0:t.label==="Right"?1:-1,M=(t,e)=>{const l=n[e];return l?Math.hypot(l.lm[0][0]-t.lm[0][0],l.lm[0][1]-t.lm[0][1]):1/0};if(S.length===2&&F(S[0])===F(S[1])){const t=S[0],e=S[1],l=M(t,0)+M(e,1)<=M(t,1)+M(e,0),[I,A]=Number.isFinite(M(t,0)+M(e,1))||Number.isFinite(M(t,1)+M(e,0))?l?[t,e]:[e,t]:t.lm[0][0]>e.lm[0][0]?[t,e]:[e,t];k[0]={lm:I.lm.map(R=>[R[0],R[1]]),score:I.score},k[1]={lm:A.lm.map(R=>[R[0],R[1]]),score:A.score}}else for(const t of S){let e=F(t);if(e<0&&(e=t.lm[0][0]>.5?0:1),S.length===1){const l=1-e;M(t,l)<.08&&M(t,e)>.15&&(e=l)}k[e]||(k[e]={lm:t.lm.map(l=>[l[0],l[1]]),score:t.score})}if(k.some(Boolean)){const t=y.getImageData(0,0,_,o).data,e=(l,I)=>{const A=(Math.max(0,Math.min(o-1,I))*_+Math.max(0,Math.min(_-1,l)))*4;return[t[A],t[A+1],t[A+2]]};for(const l of k)if(l){const I=dt(l.lm,_,o,e);I&&(l.edge=I)}}T.push(k),n=[k[0]??n[0],k[1]??n[1]],s?.(i+1,v)}return mt({mw:x,mh:H,fps:m,s0:E,frames:T})}finally{u.removeAttribute("src"),u.load(),C()}}let B=null,q=null;async function xt(d,w,a){const f=typeof window<"u"?window.__bodySkinStub:void 0;B??=f?Promise.resolve(f):(async()=>{const{FilesetResolver:p,ImageSegmenter:C}=await N(async()=>{const{FilesetResolver:H,ImageSegmenter:_}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:H,ImageSegmenter:_}},[]),u=await p.forVisionTasks(`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${J}/wasm`),x=await C.createFromOptions(u,{baseOptions:{modelAssetPath:nt,delegate:"CPU"},runningMode:"IMAGE",outputConfidenceMasks:!0,outputCategoryMask:!1});return H=>{const _=x.segment(H);try{const o=_.confidenceMasks?.[2];if(!o)throw Error("no skin mask");return{data:o.getAsFloat32Array().slice(),width:o.width,height:o.height}}finally{_.close()}}})().catch(p=>{throw B=null,p});const c=await B;q??=document.createElement("canvas");const s=960,b=Math.max(2,Math.round(960*d.height/d.width));(q.width!==s||q.height!==b)&&Object.assign(q,{width:s,height:b}),q.getContext("2d").drawImage(d,0,0,s,b);const m=c(q),v=new Float32Array(w*a);for(let p=0;p<a;p++){const C=Math.min(m.height-1,Math.floor((p+.5)/a*m.height))*m.width;for(let u=0;u<w;u++){const x=m.data[C+Math.min(m.width-1,Math.floor((u+.5)/w*m.width))];v[p*w+u]=Math.max(0,Math.min(1,(x-.25)/.4))}}return v}const kt=[0,1,2,3,5,6,7,9,10,11,13,14,15,17,18,19];let G=null;async function bt(d,w,a,f,c,s){const{objectProbability:b}=await N(async()=>{const{objectProbability:o}=await import("./objectSegmenter-oGv8YQbI.js");return{objectProbability:o}},__vite__mapDeps([0,1,2,3,4,5,6,7])),m=new Float32Array(c*s),v=512;G??=Object.assign(document.createElement("canvas"),{width:v,height:v});const p=G.getContext("2d",{willReadFrequently:!0}),C=async(o,r,y,E,T)=>{p.fillStyle="#000",p.fillRect(0,0,v,v),p.drawImage(d,o,r,y,E,0,0,v,v);const n=await b(G,T.map(h=>({x:(h.x-o)/y,y:(h.y-r)/E})).filter(h=>h.x>0&&h.x<1&&h.y>0&&h.y<1)),i=new Float32Array(c*s);for(let h=0;h<s;h++){const S=((h+.5)/s*a-r)/E;if(S<0||S>=1)continue;const k=Math.floor(S*n.height)*n.width;for(let F=0;F<c;F++){const M=((F+.5)/c*w-o)/y;M<0||M>=1||(i[h*c+F]=n.data[k+Math.floor(M*n.width)])}}return i},{fillCapsule:u,fillPolygon:x}=await N(async()=>{const{fillCapsule:o,fillPolygon:r}=await import("./handMatte-CvFkZKTL.js");return{fillCapsule:o,fillPolygon:r}},__vite__mapDeps([8,3,9,1,10,11,12,13,4,5,6,14,15,16])),H=[],_=await xt(d,c,s);for(const{lm:o}of f){const r=o.map(t=>t[0]*w),y=o.map(t=>t[1]*a),E=Math.hypot(r[0]-r[9],y[0]-y[9])||1,T=kt.map(t=>({x:r[t],y:y[t]}));T.push({x:r[0]+(r[0]-r[9])*.6,y:y[0]+(y[0]-y[9])*.6});const i=await C(...((t,e,l,I=1)=>{const A=Math.min(...t)-l,R=Math.max(...t)+l,O=Math.min(...e)-l,g=Math.max(...e)+l,P=Math.max(R-A,g-O),D=Math.min(w,Math.max(R-A,P/I)),V=Math.min(a,Math.max(g-O,P/I)),L=Math.min(D,V*I),U=Math.min(V,D*I);return[Math.max(0,Math.min(w-L,(A+R)/2-L/2)),Math.max(0,Math.min(a-U,(O+g)/2-U/2)),L,U]})([...r,r[0]+(r[0]-r[9])*3],[...y,y[0]+(y[0]-y[9])*3],.6*E),T);let h=(r[0]-r[9])/E,S=(y[0]-y[9])/E;{const t=r[0]/w*c,e=y[0]/a*s,l=E/w*c;let I=0,A=0,R=0;for(let O=0;O<s;O++)for(let g=0;g<c;g++){if(i[O*c+g]<.5)continue;const P=Math.hypot(g-t,O-e);if(P<1.2*l||P>3*l)continue;const D=g-t,V=O-e;D*h+V*S<-.2*P||(I+=g,A+=O,R++)}if(R>20){const O=I/R-t,g=A/R-e,P=Math.hypot(O,g)||1;(O*h+g*S)/P>Math.cos(75*Math.PI/180)&&(h=O/P,S=g/P)}}H.push([h,S]);const k=new Uint8Array(c*s),F=r.map((t,e)=>[t/w*c,y[e]/a*s]),M=E/w*c;for(const[t,e]of[[1,2],[2,3],[3,4],[5,6],[6,7],[7,8],[9,10],[10,11],[11,12],[13,14],[14,15],[15,16],[17,18],[18,19],[19,20],[0,1],[0,5],[0,17]])u(k,F[t],F[e],.35*M,c,s);x(k,[0,1,5,9,13,17].map(t=>F[t]),c,s);for(let t=0;t<c*s;t++){const e=k[t]?Math.max(i[t],_[t]*.5):_[t];e>m[t]&&(m[t]=e)}}return{map:m,armDirs:H}}async function X({clip:d,url:w,from:a,duration:f,until:c=1/0,refine:s=null,store:b=!0,signal:m,onProgress:v}){if(!d.hands)throw Error(j("Không tìm thấy clip video có tay"));const p=ct(d.hands),C=d.playbackRate||1,u=p.fps,x=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});x.src=w;try{await new Promise((t,e)=>{x.onloadeddata=()=>t(),x.onerror=()=>e(Error(j("Không đọc được video để bám tay (CORS / định dạng)")))});const H=x.videoWidth||p.mw,_=x.videoHeight||p.mh,{w:o,h:r}=ut(H,_),y=Object.assign(document.createElement("canvas"),{width:o,height:r}),E=y.getContext("2d",{willReadFrequently:!0}),T=z(d,a),n=Math.max(1,Math.min(K.maxFrames,Math.round(f*C*u)+1)),i=z(d,c),h=et({mw:H,mh:_,w:o,h:r,fps:u,s0:T},32),S=ft(t=>h.push(t)),k=s?await Z(s):null,F=at(x);let M=!0;for(let t=0;t<n;t++){if(m?.aborted)throw new DOMException("Đã huỷ","AbortError");const e=T+t/u;if(e>i+1e-6){S.push(new Uint8Array(o*r)),v?.(t+1,n);continue}const l=await F(Math.max(0,Math.min(x.duration-1/60,e)));E.drawImage(l,0,0,o,r);const I=Math.max(0,Math.min(p.n-1,Math.round((e-p.s0)*u))),A=[0,1].map(g=>{const P=lt(p,e,g);return P?{lm:P,edge:p.frames[I][g]?.edge??null}:null}).filter(Boolean);let R=null;if(M&&A.length)try{const g=await bt(l,H,_,A,o,r);R=g.map,g.armDirs.forEach((P,D)=>{A[D].armDir=P})}catch(g){M=!1,console.warn("hand cut-out model",g)}let O=A.length?ht(E.getImageData(0,0,o,r).data,o,r,A,{learned:R}):new Uint8Array(o*r);if(k&&s){const g=tt(k,s,e),P=s.w,D=s.h,V=new Uint8Array(o*r);for(let L=0;L<r;L++)for(let U=0;U<o;U++)V[L*o+U]=Math.round(O[L*o+U]*g[Math.min(D-1,Math.floor(L*D/r))*P+Math.min(P-1,Math.floor(U*P/o))]/255);O=V}S.push(O),v?.(t+1,n),t%4===3&&await new Promise(g=>setTimeout(g,0))}return S.finish(),await h.finish({feather:0,grow:0},{store:b})}finally{x.removeAttribute("src"),x.load()}}async function vt(d,w,a){const f=W.getState().clips.find(b=>b.id===d);if(!f||f.kind!=="video")throw Error(j("Không tìm thấy clip video có tay"));if(st(f,w,a))return f;const c=document.querySelector(`video[data-clip-media="${f.id}"]`)?.currentSrc||f.url,s=await Mt({clip:f,url:c,from:w,duration:Math.min(a,K.maxFrames/15/(f.playbackRate||1))});if(!s.data||!/[^A]/.test(s.data.replace(/=+$/,"")))throw Error(j("Không thấy bàn tay nào trong đoạn này"));return W.setState(b=>({clips:b.clips.map(m=>m.id===f.id?{...m,hands:s}:m)})),{...f,hands:s}}const St=d=>new Promise(w=>setTimeout(w,d));async function Wt(d,w){const a=w.params??{},f=await vt(String(a.source),a.from??0,a.duration??d.duration),c=W.getState(),{width:s,height:b}=Y(c.timelineFormat);if(a.mode==="attach"){const n=c.clips.find(i=>i.id===d.id)??d;return ot(n,f,{point:a.point,side:a.side,scale:!!a.scale,offset:a.offset??null,W:s,H:b})}if(a.mode==="wipe"){const n=c.clips.find(e=>e.id===d.id)??d,i=c.clips.find(e=>e.id===f.id)??f,h=n.mask,S=it(n,i,{point:a.point,side:a.side,dir:a.dir,feather:a.feather,W:s,H:b,mw:h?.mw,mh:h?.mh}),k=c.clips.find(e=>e.id===a.cutout),F=document.querySelector(`video[data-clip-media="${i.id}"]`)?.currentSrc||i.url;let M=null;if(k)try{M=await X({clip:i,url:F,from:a.from??0,duration:a.duration??d.duration,refine:k.person??null})}catch(e){console.warn("hand matte",e)}const t=M||!k?void 0:Q({...k,hands:i.hands});return W.setState(e=>({clips:e.clips.map(l=>l.id===a.cutout?M?{...l,person:M,mask:void 0}:t?{...l,mask:t}:l:l)})),S.patch}for(let n=0;n<360&&W.getState().clips.find(i=>i.id===a.wall)?.pendingPin;n++)await St(500);const m=W.getState(),v=m.clips.find(n=>n.id===a.wall),p=m.clips.find(n=>n.id===d.id)??d,C=m.clips.find(n=>n.id===f.id)??f;if(!v)throw Error(j("Không còn tường HUD"));const u=rt({wall:v,layer:p,src:C,clips:m.clips,cam:m.timelineCamera,W:s,H:b,events:a.events??null,grab:a.grab??"auto",side:a.side,fly:a.fly}),x=m.clips.find(n=>n.id===a.cutout),H=document.querySelector(`video[data-clip-media="${C.id}"]`)?.currentSrc||C.url,_=(a.matte?m.clips.find(n=>n.id===a.matte)?.person:null)??x?.person??null;let o=null;if(x)try{o=await X({clip:C,url:H,from:a.from??0,duration:a.duration??d.duration,until:u.cutoutUntil,refine:_})}catch(n){console.warn("hand matte",n)}const r=x?.matteFix?.fixes??[],y=o;if(o&&r.length)try{const{fixedMatte:n}=await N(async()=>{const{fixedMatte:i}=await import("./matteFixRun-BHD3Qnta.js");return{fixedMatte:i}},__vite__mapDeps([17,14,1,6,5,2,3,4,9,10,11,12,13,15,16,8,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,0,7,35,36,37]));o=await n(o,r,C.hands)}catch(n){console.warn("hand touch-ups",n)}const E=o?void 0:Q(C,{until:u.cutoutUntil}),T=n=>{const i=n.mask?.masks?.find(h=>h.id==="wall");return!i||!n.mask?n:o?{...n,person:o,mask:{...n.mask,masks:[{...i,mode:"add"}]}}:E?{...n,mask:{...E,masks:[...E.masks,{...i,mode:"intersect"}]}}:n};return W.setState(n=>({clips:n.clips.map(i=>i.id===v.id?{...i,motion:u.wall}:i.id===a.cutout?o?{...i,person:o,mask:void 0,...r.length?{matteFix:{auto:y,fixes:r}}:{}}:E?{...i,mask:E}:i:i.id===a.shadow?T(i):i)})),{motion:u.grab}}export{pt as HAND_MODEL_URL,X as buildHandMatte,bt as learnedHands,Wt as runHandTrack,Mt as trackHands};
@@ -1,4 +1,4 @@
1
- import{Box3 as de,Matrix4 as $,BufferAttribute as te,Vector3 as C,Line3 as ge,Plane as br,Vector2 as Y,Triangle as Ye,BackSide as Tr,DoubleSide as wr,REVISION as Sr,Ray as Kr,FrontSide as oi,UnsignedIntType as lt,FloatType as G,DataTexture as Z,NearestFilter as N,IntType as qt,UnsignedByteType as ci,UnsignedShortType as Zr,ByteType as Di,ShortType as Jr,RGBAFormat as L,RGBAIntegerFormat as li,RGIntegerFormat as _r,RedIntegerFormat as en,RGFormat as Ar,RedFormat as Et,BufferGeometry as Ke,Matrix3 as tn,Vector4 as Ze,MeshBasicMaterial as rn,Mesh as nn,ShaderMaterial as Nt,NoBlending as Je,WebGLRenderTarget as Qe,PerspectiveCamera as Mr,DataUtils as K,HalfFloatType as ee,LinearFilter as oe,RepeatWrapping as we,ClampToEdgeWrapping as Se,Source as sn,Quaternion as an,DataArrayTexture as on,WebGLArrayRenderTarget as cn,Color as et,NoToneMapping as ln,NormalBlending as Ir,EquirectangularReflectionMapping as Ti,Spherical as un,LinearMipMapLinearFilter as fn,Clock as hn,Scene as dn,AdditiveBlending as mn,Camera as pn,SpotLight as gn,RectAreaLight as vn,PMREMGenerator as xn,MeshStandardMaterial as yn,TangentSpaceNormalMap as Ei}from"./three.module-Bx43vjkH.js";import{eK as De}from"./remote-8XzEAnAJ.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./titleFrameBudget-DsM0V482.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const Pr=0,bn=1,Rr=2,Bi=2,Gt=1.25,zi=1,j=32,O=j/4,wi=65535,Tn=wi<<16,Dt=Math.pow(2,-24),Si=Symbol("SKIP_GENERATION"),Fr={strategy:Pr,maxDepth:40,targetLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Si]:!1};function z(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function ui(n){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=n[i+3]-n[i];s>t&&(t=s,e=i)}return e}function Ni(n,e,t){for(let i=0;i<3;i++){const s=e[n+2*i],a=e[n+2*i+1],r=s-a,c=s+a;r<t[i]&&(t[i]=r),c>t[i+3]&&(t[i+3]=c)}}function $t(n){const e=n[3]-n[0],t=n[4]-n[1],i=n[5]-n[2];return 2*(e*t+t*i+i*e)}function k(n,e){return e[n+15]===wi}function H(n,e){return e[n+6]}function q(n,e){return e[n+14]}function W(n){return n+O}function V(n,e){const t=e[n+6];return n+t*O}function kt(n,e){return e[n+7]}function Yt(n,e,t,i,s){let a=1/0,r=1/0,c=1/0,l=-1/0,h=-1/0,f=-1/0,u=1/0,o=1/0,m=1/0,g=-1/0,x=-1/0,d=-1/0;const b=n.offset||0;for(let p=(e-b)*6,v=(e+t-b)*6;p<v;p+=6){const y=n[p+0],T=n[p+1],A=y-T,w=y+T;A<a&&(a=A),w>l&&(l=w),y<u&&(u=y),y>g&&(g=y);const M=n[p+2],I=n[p+3],_=M-I,P=M+I;_<r&&(r=_),P>h&&(h=P),M<o&&(o=M),M>x&&(x=M);const S=n[p+4],R=n[p+5],F=S-R,D=S+R;F<c&&(c=F),D>f&&(f=D),S<m&&(m=S),S>d&&(d=S)}i[0]=a,i[1]=r,i[2]=c,i[3]=l,i[4]=h,i[5]=f,s[0]=u,s[1]=o,s[2]=m,s[3]=g,s[4]=x,s[5]=d}const he=8,_i=8,jt=new Int32Array(he),ue=new Float32Array(he*6),ze=new Float32Array(he*6),ne=new Float32Array(6),ft=new Float32Array(6),ye=new Int32Array(_i),ki=new Float32Array(_i*6);function wn(n,e,t,i){for(let s=0;s<3;s++){const a=e[n+2*s],r=e[n+2*s+1],c=a-r,l=a+r;c<t[i+s]&&(t[i+s]=c),l>t[i+s+3]&&(t[i+s+3]=l)}}function Oi(n,e){const t=n[e+3]-n[e],i=n[e+4]-n[e+1],s=n[e+5]-n[e+2];return 2*(t*i+i*s+s*t)}function Sn(n,e,t,i,s,a){let r=-1,c=0;if(a===Pr)r=ui(e),r!==-1&&(c=(e[r]+e[r+3])/2);else if(a===bn)r=ui(n),r!==-1&&(c=_n(t,i,s,r));else if(a===Rr){const l=$t(n);let h=Gt*s;const f=t.offset||0,u=(i-f)*6,o=(i+s-f)*6;for(let m=0;m<3;m++){const g=e[m],b=(e[m+3]-g)/he;if(s<_i){for(let p=0;p<s;p++){const v=u+p*6,y=t[v+2*m];let T=p;for(;T>0&&t[ye[T-1]+2*m]>y;)ye[T]=ye[T-1],T--;ye[T]=v}for(let p=0;p<3;p++)ne[p]=1/0,ne[p+3]=-1/0,ft[p]=1/0,ft[p+3]=-1/0;for(let p=s-1;p>=0;p--)Ni(ye[p],t,ft),ki.set(ft,p*6);for(let p=0;p<s-1;p++){Ni(ye[p],t,ne);const v=t[ye[p+1]+2*m];if(t[ye[p]+2*m]===v)continue;const y=p+1,T=s-y,A=$t(ne)/l,w=Oi(ki,y*6)/l,M=zi+Gt*(A*y+w*T);M<h&&(r=m,h=M,c=v)}}else{for(let y=0;y<he;y++){jt[y]=0;for(let T=0;T<3;T++)ue[y*6+T]=1/0,ue[y*6+T+3]=-1/0}for(let y=u;y<o;y+=6){let w=~~((t[y+2*m]-g)/b);w>=he&&(w=he-1),jt[w]++,wn(y,t,ue,w*6)}const p=(he-1)*6;for(let y=0;y<6;y++)ze[p+y]=ue[p+y];for(let y=he-2;y>=0;y--){const T=y*6,A=T+6;for(let w=0;w<3;w++)ze[T+w]=Math.min(ue[T+w],ze[A+w]),ze[T+w+3]=Math.max(ue[T+w+3],ze[A+w+3])}let v=0;for(let y=0;y<he-1;y++){const T=y*6,A=jt[y];if(A!==0)for(let P=0;P<3;P++)v===0?(ne[P]=ue[T+P],ne[P+3]=ue[T+P+3]):(ne[P]=Math.min(ne[P],ue[T+P]),ne[P+3]=Math.max(ne[P+3],ue[T+P+3]));v+=A;let w=0,M=0;v!==0&&(w=$t(ne)/l);const I=s-v;I!==0&&(M=Oi(ze,T+6)/l);const _=zi+Gt*(w*v+M*I);_<h&&(r=m,h=_,c=g+b+y*b)}}}}else console.warn(`BVH: Invalid build strategy value ${a} used.`);return{axis:r,pos:c}}function _n(n,e,t,i){let s=0;const a=n.offset;for(let r=e,c=e+t;r<c;r++)s+=n[(r-a)*6+i*2];return s/t}function An(n,e,t,i,s,a){let r=i,c=i+s-1;const l=a.pos,h=a.axis*2,f=t.offset||0;for(;;){for(;r<=c&&t[(r-f)*6+h]<l;)r++;for(;r<=c&&t[(c-f)*6+h]>=l;)c--;if(r<c){for(let u=0;u<e;u++){let o=n[r*e+u];n[r*e+u]=n[c*e+u],n[c*e+u]=o}for(let u=0;u<6;u++){const o=r-f,m=c-f,g=t[o*6+u];t[o*6+u]=t[m*6+u],t[m*6+u]=g}r++,c--}else return r}}const Mn=Math.pow(2,32),Ne=new Float32Array(6),ht=new Float32Array(6);function In(n,e,t,i,s,a){const{maxDepth:r,verbose:c,targetLeafSize:l,_strictLeafSize:h=1/0,strategy:f,onProgress:u,useSharedArrayBuffer:o=!1}=s,m=n.primitiveBuffer,g=n.primitiveBufferStride,x=o?SharedArrayBuffer:ArrayBuffer,d=new x(j*Math.max(1,2*Math.ceil(i)-1)),b=new Float32Array(d),p=new Uint32Array(d),v=new Uint16Array(d);let y=0,T=!1;return Yt(e,t,i,Ne,ht),M(t,i,0),d.slice(0,y*j);function A(I){u&&u((I-a.offset)/a.count)}function w(I,_,P){const S=I*2;p[I+6]=_,v[S+14]=P,v[S+15]=wi,A(_+P)}function M(I,_,P){const S=y++,R=S*O;b.set(Ne,R),!T&&P>=r&&(T=!0,c&&console.warn(`BVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`));const F=_>h;if(_<=l&&!F||P>=r){w(R,I,_);return}const D=Sn(Ne,ht,e,I,_,f);let E=D.axis===-1?-1:An(m,g,e,I,_,D);if(D.axis===-1||E===I||E===I+_){if(!F){w(R,I,_);return}D.axis=Math.max(0,ui(Ne)),E=I+Math.max(1,Math.floor(_/2))}p[R+7]=D.axis;const le=E-I;Yt(e,I,le,Ne,ht),M(I,le,P+1);const me=y-S;if(me>Mn)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");p[R+6]=me;const xe=_-le;Yt(e,E,xe,Ne,ht),M(E,xe,P+1)}}function Pn(n,e){const t=n.getRootRanges(e.range),i=t[0],s=t[t.length-1],a={offset:i.offset,count:s.offset+s.count-i.offset},r=new Float32Array(6*a.count);r.offset=a.offset,n.computePrimitiveBounds(a.offset,a.count,r),n._roots=t.map(c=>In(n,r,c.offset,c.count,e,a))}class Ai{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Rn{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const B=new Rn;let Te,Xe;const ke=[],dt=new Ai(()=>new de);function Fn(n,e,t,i,s,a){Te=dt.getPrimitive(),Xe=dt.getPrimitive(),ke.push(Te,Xe),B.setBuffer(n._roots[e]);const r=fi(0,n.geometry,t,i,s,a);B.clearBuffer(),dt.releasePrimitive(Te),dt.releasePrimitive(Xe),ke.pop(),ke.pop();const c=ke.length;return c>0&&(Xe=ke[c-1],Te=ke[c-2]),r}function fi(n,e,t,i,s=null,a=0,r=0){const{float32Array:c,uint16Array:l,uint32Array:h}=B;let f=n*2;if(k(f,l)){const o=H(n,h),m=q(f,l);return z(n,c,Te),i(o,m,!1,r,a+n/O,Te)}else{let _=function(S){const{uint16Array:R,uint32Array:F}=B;let D=S*2;for(;!k(D,R);)S=W(S),D=S*2;return H(S,F)},P=function(S){const{uint16Array:R,uint32Array:F}=B;let D=S*2;for(;!k(D,R);)S=V(S,F),D=S*2;return H(S,F)+q(D,R)};const o=W(n),m=V(n,h);let g=o,x=m,d,b,p,v;if(s&&(p=Te,v=Xe,z(g,c,p),z(x,c,v),d=s(p),b=s(v),b<d)){g=m,x=o;const S=d;d=b,b=S,p=v}p||(p=Te,z(g,c,p));const y=k(g*2,l),T=t(p,y,d,r+1,a+g/O);let A;if(T===Bi){const S=_(g),F=P(g)-S;A=i(S,F,!0,r+1,a+g/O,p)}else A=T&&fi(g,e,t,i,s,a,r+1);if(A)return!0;v=Xe,z(x,c,v);const w=k(x*2,l),M=t(v,w,b,r+1,a+x/O);let I;if(M===Bi){const S=_(x),F=P(x)-S;I=i(S,F,!0,r+1,a+x/O,v)}else I=M&&fi(x,e,t,i,s,a,r+1);return!!I}}const ut=new B.constructor,Bt=new B.constructor,be=new Ai(()=>new de),Oe=new de,Ue=new de,Xt=new de,Qt=new de;let Kt=!1;function Cn(n,e,t,i){if(Kt)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Kt=!0;const s=n._roots,a=e._roots;let r,c=0,l=0;const h=new $().copy(t).invert();for(let f=0,u=s.length;f<u;f++){ut.setBuffer(s[f]),l=0;const o=be.getPrimitive();z(0,ut.float32Array,o),o.applyMatrix4(h);for(let m=0,g=a.length;m<g&&(Bt.setBuffer(a[m]),r=ae(0,0,t,h,i,c,l,0,0,o),Bt.clearBuffer(),l+=a[m].byteLength/j,!r);m++);if(be.releasePrimitive(o),ut.clearBuffer(),c+=s[f].byteLength/j,r)break}return Kt=!1,r}function ae(n,e,t,i,s,a=0,r=0,c=0,l=0,h=null,f=!1){let u,o;f?(u=Bt,o=ut):(u=ut,o=Bt);const m=u.float32Array,g=u.uint32Array,x=u.uint16Array,d=o.float32Array,b=o.uint32Array,p=o.uint16Array,v=n*2,y=e*2,T=k(v,x),A=k(y,p);let w=!1;if(A&&T)f?w=s(H(e,b),q(e*2,p),H(n,g),q(n*2,x),l,r+e/O,c,a+n/O):w=s(H(n,g),q(n*2,x),H(e,b),q(e*2,p),c,a+n/O,l,r+e/O);else if(A){const M=be.getPrimitive();z(e,d,M),M.applyMatrix4(t);const I=W(n),_=V(n,g);z(I,m,Oe),z(_,m,Ue);const P=M.intersectsBox(Oe),S=M.intersectsBox(Ue);w=P&&ae(e,I,i,t,s,r,a,l,c+1,M,!f)||S&&ae(e,_,i,t,s,r,a,l,c+1,M,!f),be.releasePrimitive(M)}else{const M=W(e),I=V(e,b);z(M,d,Xt),z(I,d,Qt);const _=h.intersectsBox(Xt),P=h.intersectsBox(Qt);if(_&&P)w=ae(n,M,t,i,s,a,r,c,l+1,h,f)||ae(n,I,t,i,s,a,r,c,l+1,h,f);else if(_)if(T)w=ae(n,M,t,i,s,a,r,c,l+1,h,f);else{const S=be.getPrimitive();S.copy(Xt).applyMatrix4(t);const R=W(n),F=V(n,g);z(R,m,Oe),z(F,m,Ue);const D=S.intersectsBox(Oe),E=S.intersectsBox(Ue);w=D&&ae(M,R,i,t,s,r,a,l,c+1,S,!f)||E&&ae(M,F,i,t,s,r,a,l,c+1,S,!f),be.releasePrimitive(S)}else if(P)if(T)w=ae(n,I,t,i,s,a,r,c,l+1,h,f);else{const S=be.getPrimitive();S.copy(Qt).applyMatrix4(t);const R=W(n),F=V(n,g);z(R,m,Oe),z(F,m,Ue);const D=S.intersectsBox(Oe),E=S.intersectsBox(Ue);w=D&&ae(I,R,i,t,s,r,a,l,c+1,S,!f)||E&&ae(I,F,i,t,s,r,a,l,c+1,S,!f),be.releasePrimitive(S)}}return w}const Zt=new class{constructor(){let n=null,e=null,t=null,i=!1;this.root=null,this.buffer=null,this.uint32Array=null,this.uint16Array=null,this.setBVH=(a,r)=>{if(i)throw new Error("BVHTraversalHelper: cannot call setBVH during an active traversal.");this.root=r,this.buffer=n=a._roots[r],this.uint16Array=t=new Uint16Array(n),this.uint32Array=e=new Uint32Array(n)},this.reset=()=>{this.root=null,this.buffer=n=null,this.uint16Array=t=null,this.uint32Array=e=null},this.getRangeStart=a=>{let r=a*2;for(;!k(r,t);)a=W(a),r=a*2;return H(a,e)},this.getRangeEnd=a=>{let r=a*2;for(;!k(r,t);)a=V(a,e),r=a*2;return H(a,e)+q(r,t)};const s=(a,r,c)=>{const l=r*2,h=k(l,t);if(!a(c,h,r)&&!h){const u=W(r),o=V(r,e);s(a,u,c+1),s(a,o,c+1)}};this.traverseBuffer=a=>{if(i)throw new Error("BVHTraversalHelper: cannot start a traversal during an active traversal.");i=!0;try{s(a,0,0)}finally{i=!1}},this.traverse=a=>{this.traverseBuffer((r,c,l)=>{if(c){const h=l*2,f=e[l+6],u=t[h+14];return a(r,c,new Float32Array(n,l*4,6),f,u)}else{const h=kt(l,e);return a(r,c,new Float32Array(n,l*4,6),h)}})}}},Ui=new de,Le=new Float32Array(6);class Dn{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...Fr,...e},"maxLeafSize"in e&&(console.warn('BVH: "maxLeafSize" option has been deprecated. Use "targetLeafSize", instead.'),e={...e,targetLeafSize:e.maxLeafSize}),Pn(this,e)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(e,t,i,s){let a=1/0,r=1/0,c=1/0,l=-1/0,h=-1/0,f=-1/0;for(let u=e,o=e+t;u<o;u++){this.writePrimitiveBounds(u,Le,0);const[m,g,x,d,b,p]=Le;m<a&&(a=m),d>l&&(l=d),g<r&&(r=g),b>h&&(h=b),x<c&&(c=x),p>f&&(f=p)}return i[s+0]=a,i[s+1]=r,i[s+2]=c,i[s+3]=l,i[s+4]=h,i[s+5]=f,i}computePrimitiveBounds(e,t,i){const s=i.offset||0;for(let a=e,r=e+t;a<r;a++){this.writePrimitiveBounds(a,Le,0);const[c,l,h,f,u,o]=Le,m=(c+f)/2,g=(l+u)/2,x=(h+o)/2,d=(f-c)/2,b=(u-l)/2,p=(o-h)/2,v=(a-s)*6;i[v+0]=m,i[v+1]=d+(Math.abs(m)+d)*Dt,i[v+2]=g,i[v+3]=b+(Math.abs(g)+b)*Dt,i[v+4]=x,i[v+5]=p+(Math.abs(x)+p)*Dt}return i}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let i=0,s=t.length;i<s;i++)t[i]+=e;else{const i=this._roots;for(let s=0;s<i.length;s++){const a=i[s],r=new Uint32Array(a),c=new Uint16Array(a),l=a.byteLength/j;for(let h=0;h<l;h++){const f=O*h,u=2*f;k(u,c)&&(r[f+6]+=e)}}}}traverse(e,t=0){Zt.setBVH(this,t),Zt.traverse(e),Zt.reset()}refit(){const e=this._roots;for(let t=0,i=e.length;t<i;t++){const s=e[t],a=new Uint32Array(s),r=new Uint16Array(s),c=new Float32Array(s),l=s.byteLength/j;for(let h=l-1;h>=0;h--){const f=h*O,u=f*2;if(k(u,r)){const m=H(f,a),g=q(u,r);this.writePrimitiveRangeBounds(m,g,Le,0),c.set(Le,f)}else{const m=W(f),g=V(f,a);for(let x=0;x<3;x++){const d=c[m+x],b=c[m+x+3],p=c[g+x],v=c[g+x+3];c[f+x]=d<p?d:p,c[f+x+3]=b>v?b:v}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{z(0,new Float32Array(i),Ui),e.union(Ui)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:i,intersectsRange:s,intersectsPrimitive:a,scratchPrimitive:r,iterate:c}=e;if(s&&a){const u=s;s=(o,m,g,x,d)=>u(o,m,g,x,d)?!0:c(o,m,this,a,g,x,r)}else s||(a?s=(u,o,m,g)=>c(u,o,this,a,m,g,r):s=(u,o,m)=>m);let l=!1,h=0;const f=this._roots;for(let u=0,o=f.length;u<o;u++){const m=f[u];if(l=Fn(this,u,i,s,t,h),l)break;h+=m.byteLength/j}return l}bvhcast(e,t,i){let{intersectsRanges:s}=i;return Cn(this,e,t,s)}}function En(){return typeof SharedArrayBuffer<"u"}function Ot(n){return n.index?n.index.count:n.attributes.position.count}function Ut(n){return Ot(n)/3}function Cr(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function Bn(n,e){if(!n.index){const t=n.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=Cr(t,i);n.setIndex(new te(s,1));for(let a=0;a<t;a++)s[a]=a}}function zn(n,e,t){const i=Ot(n)/t,s=e||n.drawRange,a=s.start/t,r=(s.start+s.count)/t,c=Math.max(0,a),l=Math.min(i,r)-c;return{offset:Math.floor(c),count:Math.floor(l)}}function Nn(n,e){return n.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function Li(n,e,t){const i=zn(n,e,t),s=Nn(n,t);if(!s.length)return[i];const a=[],r=i.offset,c=i.offset+i.count,l=Ot(n)/t,h=[];for(const o of s){const{offset:m,count:g}=o,x=m,d=isFinite(g)?g:l-m,b=m+d;x<c&&b>r&&(h.push({pos:Math.max(r,x),isStart:!0}),h.push({pos:Math.min(c,b),isStart:!1}))}h.sort((o,m)=>o.pos!==m.pos?o.pos-m.pos:o.type==="end"?-1:1);let f=0,u=null;for(const o of h){const m=o.pos;f!==0&&m!==u&&a.push({offset:u,count:m-u}),f+=o.isStart?1:-1,u=m}return a}function kn(n,e){const t=n[n.length-1],i=t.offset+t.count>2**16,s=n.reduce((h,f)=>h+f.count,0),a=i?4:2,r=e?new SharedArrayBuffer(s*a):new ArrayBuffer(s*a),c=i?new Uint32Array(r):new Uint16Array(r);let l=0;for(let h=0;h<n.length;h++){const{offset:f,count:u}=n[h];for(let o=0;o<u;o++)c[l+o]=f+o;l+=u}return c}class On extends Dn{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(t.useSharedArrayBuffer&&!En())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...Fr,...t},t[Si]||this.init(t)}init(e){const{geometry:t,primitiveStride:i}=this;if(e.indirect){const s=Li(t,e.range,i),a=kn(s,e.useSharedArrayBuffer);this._indirectBuffer=a}else Bn(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new de))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Li(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class ve{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let a=0,r=e.length;a<r;a++){const l=e[a][t];i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let a=0,r=t.length;a<r;a++){const c=t[a],l=e.dot(c);i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}ve.prototype.setFromBox=(function(){const n=new C;return function(t,i){const s=i.min,a=i.max;let r=1/0,c=-1/0;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let f=0;f<=1;f++){n.x=s.x*l+a.x*(1-l),n.y=s.y*h+a.y*(1-h),n.z=s.z*f+a.z*(1-f);const u=t.dot(n);r=Math.min(u,r),c=Math.max(u,c)}this.min=r,this.max=c}})();const Un=(function(){const n=new C,e=new C,t=new C;return function(s,a,r){const c=s.start,l=n,h=a.start,f=e;t.subVectors(c,h),n.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const u=t.dot(f),o=f.dot(l),m=f.dot(f),g=t.dot(l),d=l.dot(l)*m-o*o;let b,p;d!==0?b=(u*o-g*m)/d:b=0,p=(u+b*o)/m,r.x=b,r.y=p}})(),Mi=(function(){const n=new Y,e=new C,t=new C;return function(s,a,r,c){Un(s,a,n);let l=n.x,h=n.y;if(l>=0&&l<=1&&h>=0&&h<=1){s.at(l,r),a.at(h,c);return}else if(l>=0&&l<=1){h<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,r);return}else if(h>=0&&h<=1){l<0?s.at(0,r):s.at(1,r),a.closestPointToPoint(r,!0,c);return}else{let f;l<0?f=s.start:f=s.end;let u;h<0?u=a.start:u=a.end;const o=e,m=t;if(s.closestPointToPoint(u,!0,e),a.closestPointToPoint(f,!0,t),o.distanceToSquared(u)<=m.distanceToSquared(f)){r.copy(o),c.copy(u);return}else{r.copy(f),c.copy(m);return}}}})(),Ln=(function(){const n=new C,e=new C,t=new br,i=new ge;return function(a,r){const{radius:c,center:l}=a,{a:h,b:f,c:u}=r;if(i.start=h,i.end=f,i.closestPointToPoint(l,!0,n).distanceTo(l)<=c||(i.start=h,i.end=u,i.closestPointToPoint(l,!0,n).distanceTo(l)<=c)||(i.start=f,i.end=u,i.closestPointToPoint(l,!0,n).distanceTo(l)<=c))return!0;const x=r.getPlane(t);if(Math.abs(x.distanceToPoint(l))<=c){const b=x.projectPoint(l,e);if(r.containsPoint(b))return!0}return!1}})(),Hn=["x","y","z"],pe=1e-15,Hi=pe*pe;function J(n){return Math.abs(n)<pe}class ce extends Ye{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new C),this.satBounds=new Array(4).fill().map(()=>new ve),this.points=[this.a,this.b,this.c],this.plane=new br,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new ge,this.needsUpdate=!0}intersectsSphere(e){return Ln(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,a=this.satAxes,r=this.satBounds,c=a[0],l=r[0];this.getNormal(c),l.setFromPoints(c,s);const h=a[1],f=r[1];h.subVectors(e,t),f.setFromPoints(h,s);const u=a[2],o=r[2];u.subVectors(t,i),o.setFromPoints(u,s);const m=a[3],g=r[3];m.subVectors(i,e),g.setFromPoints(m,s);const x=h.length(),d=u.length(),b=m.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,x<pe?d<pe||b<pe?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(i)):d<pe?b<pe?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):b<pe&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(i),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}ce.prototype.closestPointToSegment=(function(){const n=new C,e=new C,t=new ge;return function(s,a=null,r=null){this.needsUpdate&&this.update();const{start:c,end:l}=s,h=this.points;let f,u=1/0;const o=this.plane.distanceToPoint(c),m=this.plane.distanceToPoint(l);if(o*m<0&&this.plane.intersectLine(s,n)!==null&&this.containsPoint(n))return a&&a.copy(n),r&&r.copy(n),0;for(let g=0;g<3;g++){const x=(g+1)%3;t.start.copy(h[g]),t.end.copy(h[x]),Mi(t,s,n,e),f=n.distanceToSquared(e),f<u&&(u=f,a&&a.copy(n),r&&r.copy(e))}return this.closestPointToPoint(c,n),f=c.distanceToSquared(n),f<u&&(u=f,a&&a.copy(n),r&&r.copy(c)),this.closestPointToPoint(l,n),f=l.distanceToSquared(n),f<u&&(u=f,a&&a.copy(n),r&&r.copy(l)),Math.sqrt(u)}})();ce.prototype.intersectsTriangle=(function(){const n=new ce,e=new ve,t=new ve,i=new C,s=new C,a=new C,r=new C,c=new ge,l=new ge,h=new C,f=new Y,u=new Y;function o(v,y,T,A){const w=i;!v.isDegenerateIntoPoint&&!v.isDegenerateIntoSegment?w.copy(v.plane.normal):w.copy(y.plane.normal);const M=v.satBounds,I=v.satAxes;for(let S=1;S<4;S++){const R=M[S],F=I[S];if(e.setFromPoints(F,y.points),R.isSeparated(e)||(r.copy(w).cross(F),e.setFromPoints(r,v.points),t.setFromPoints(r,y.points),e.isSeparated(t)))return!1}const _=y.satBounds,P=y.satAxes;for(let S=1;S<4;S++){const R=_[S],F=P[S];if(e.setFromPoints(F,v.points),R.isSeparated(e)||(r.crossVectors(w,F),e.setFromPoints(r,v.points),t.setFromPoints(r,y.points),e.isSeparated(t)))return!1}return T&&(A||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),T.start.set(0,0,0),T.end.set(0,0,0)),!0}function m(v,y,T,A,w,M,I,_,P,S,R){let F=I/(I-_);S.x=A+(w-A)*F,R.start.subVectors(y,v).multiplyScalar(F).add(v),F=I/(I-P),S.y=A+(M-A)*F,R.end.subVectors(T,v).multiplyScalar(F).add(v)}function g(v,y,T,A,w,M,I,_,P,S,R){if(w>0)m(v.c,v.a,v.b,A,y,T,P,I,_,S,R);else if(M>0)m(v.b,v.a,v.c,T,y,A,_,I,P,S,R);else if(_*P>0||I!=0)m(v.a,v.b,v.c,y,T,A,I,_,P,S,R);else if(_!=0)m(v.b,v.a,v.c,T,y,A,_,I,P,S,R);else if(P!=0)m(v.c,v.a,v.b,A,y,T,P,I,_,S,R);else return!0;return!1}function x(v,y,T,A){const w=y.degenerateSegment,M=v.plane.distanceToPoint(w.start),I=v.plane.distanceToPoint(w.end);return J(M)?J(I)?o(v,y,T,A):(T&&(T.start.copy(w.start),T.end.copy(w.start)),v.containsPoint(w.start)):J(I)?(T&&(T.start.copy(w.end),T.end.copy(w.end)),v.containsPoint(w.end)):v.plane.intersectLine(w,i)!=null?(T&&(T.start.copy(i),T.end.copy(i)),v.containsPoint(i)):!1}function d(v,y,T){const A=y.a;return J(v.plane.distanceToPoint(A))&&v.containsPoint(A)?(T&&(T.start.copy(A),T.end.copy(A)),!0):!1}function b(v,y,T){const A=v.degenerateSegment,w=y.a;return A.closestPointToPoint(w,!0,i),w.distanceToSquared(i)<Hi?(T&&(T.start.copy(w),T.end.copy(w)),!0):!1}function p(v,y,T,A){if(v.isDegenerateIntoSegment)if(y.isDegenerateIntoSegment){const w=v.degenerateSegment,M=y.degenerateSegment,I=s,_=a;w.delta(I),M.delta(_);const P=i.subVectors(M.start,w.start),S=I.x*_.y-I.y*_.x;if(J(S))return!1;const R=(P.x*_.y-P.y*_.x)/S,F=-(I.x*P.y-I.y*P.x)/S;if(R<0||R>1||F<0||F>1)return!1;const D=w.start.z+I.z*R,E=M.start.z+_.z*F;return J(D-E)?(T&&(T.start.copy(w.start).addScaledVector(I,R),T.end.copy(w.start).addScaledVector(I,R)),!0):!1}else return y.isDegenerateIntoPoint?b(v,y,T):x(y,v,T,A);else{if(v.isDegenerateIntoPoint)return y.isDegenerateIntoPoint?y.a.distanceToSquared(v.a)<Hi?(T&&(T.start.copy(v.a),T.end.copy(v.a)),!0):!1:y.isDegenerateIntoSegment?b(y,v,T):d(y,v,T);if(y.isDegenerateIntoPoint)return d(v,y,T);if(y.isDegenerateIntoSegment)return x(v,y,T,A)}}return function(y,T=null,A=!1){this.needsUpdate&&this.update(),y.isExtendedTriangle?y.needsUpdate&&y.update():(n.copy(y),n.update(),y=n);const w=p(this,y,T,A);if(w!==void 0)return w;const M=this.plane,I=y.plane;let _=I.distanceToPoint(this.a),P=I.distanceToPoint(this.b),S=I.distanceToPoint(this.c);J(_)&&(_=0),J(P)&&(P=0),J(S)&&(S=0);const R=_*P,F=_*S;if(R>0&&F>0)return!1;let D=M.distanceToPoint(y.a),E=M.distanceToPoint(y.b),le=M.distanceToPoint(y.c);J(D)&&(D=0),J(E)&&(E=0),J(le)&&(le=0);const me=D*E,xe=D*le;if(me>0&&xe>0)return!1;s.copy(M.normal),a.copy(I.normal);const Ee=s.cross(a);let _e=0,Wt=Math.abs(Ee.x);const Ci=Math.abs(Ee.y);Ci>Wt&&(Wt=Ci,_e=1),Math.abs(Ee.z)>Wt&&(_e=2);const Be=Hn[_e],Gr=this.a[Be],$r=this.b[Be],Yr=this.c[Be],jr=y.a[Be],Xr=y.b[Be],Qr=y.c[Be];if(g(this,Gr,$r,Yr,R,F,_,P,S,f,c))return o(this,y,T,A);if(g(y,jr,Xr,Qr,me,xe,D,E,le,u,l))return o(this,y,T,A);if(f.y<f.x){const Vt=f.y;f.y=f.x,f.x=Vt,h.copy(c.start),c.start.copy(c.end),c.end.copy(h)}if(u.y<u.x){const Vt=u.y;u.y=u.x,u.x=Vt,h.copy(l.start),l.start.copy(l.end),l.end.copy(h)}return f.y<u.x||u.y<f.x?!1:(T&&(u.x>f.x?T.start.copy(l.start):T.start.copy(c.start),u.y<f.y?T.end.copy(l.end):T.end.copy(c.end)),!0)}})();ce.prototype.distanceToPoint=(function(){const n=new C;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}})();ce.prototype.distanceToTriangle=(function(){const n=new C,e=new C,t=["a","b","c"],i=new ge,s=new ge;return function(r,c=null,l=null){const h=c||l?i:null;if(this.intersectsTriangle(r,h,!0))return(c||l)&&(c&&h.getCenter(c),l&&h.getCenter(l)),0;let f=1/0;for(let u=0;u<3;u++){let o;const m=t[u],g=r[m];this.closestPointToPoint(g,n),o=g.distanceToSquared(n),o<f&&(f=o,c&&c.copy(n),l&&l.copy(g));const x=this[m];r.closestPointToPoint(x,n),o=x.distanceToSquared(n),o<f&&(f=o,c&&c.copy(x),l&&l.copy(n))}for(let u=0;u<3;u++){const o=t[u],m=t[(u+1)%3];i.set(this[o],this[m]);for(let g=0;g<3;g++){const x=t[g],d=t[(g+1)%3];s.set(r[x],r[d]),Mi(i,s,n,e);const b=n.distanceToSquared(e);b<f&&(f=b,c&&c.copy(n),l&&l.copy(e))}}return Math.sqrt(f)}})();class X{constructor(e,t,i){this.isOrientedBox=!0,this.min=new C,this.max=new C,this.matrix=new $,this.invMatrix=new $,this.points=new Array(8).fill().map(()=>new C),this.satAxes=new Array(3).fill().map(()=>new C),this.satBounds=new Array(3).fill().map(()=>new ve),this.alignedSatBounds=new Array(3).fill().map(()=>new ve),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}X.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let h=0;h<=1;h++)for(let f=0;f<=1;f++)for(let u=0;u<=1;u++){const o=1*h|2*f|4*u,m=s[o];m.x=h?i.x:t.x,m.y=f?i.y:t.y,m.z=u?i.z:t.z,m.applyMatrix4(e)}const a=this.satBounds,r=this.satAxes,c=s[0];for(let h=0;h<3;h++){const f=r[h],u=a[h],o=1<<h,m=s[o];f.subVectors(c,m),u.setFromPoints(f,s)}const l=this.alignedSatBounds;l[0].setFromPointsField(s,"x"),l[1].setFromPointsField(s,"y"),l[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();X.prototype.intersectsBox=(function(){const n=new ve;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,a=this.satBounds,r=this.satAxes,c=this.alignedSatBounds;if(n.min=i.x,n.max=s.x,c[0].isSeparated(n)||(n.min=i.y,n.max=s.y,c[1].isSeparated(n))||(n.min=i.z,n.max=s.z,c[2].isSeparated(n)))return!1;for(let l=0;l<3;l++){const h=r[l],f=a[l];if(n.setFromBox(h,t),f.isSeparated(n))return!1}return!0}})();X.prototype.intersectsTriangle=(function(){const n=new ce,e=new Array(3),t=new ve,i=new ve,s=new C;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(n.copy(r),n.update(),r=n);const c=this.satBounds,l=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let o=0;o<3;o++){const m=c[o],g=l[o];if(t.setFromPoints(g,e),m.isSeparated(t))return!1}const h=r.satBounds,f=r.satAxes,u=this.points;for(let o=0;o<3;o++){const m=h[o],g=f[o];if(t.setFromPoints(g,u),m.isSeparated(t))return!1}for(let o=0;o<3;o++){const m=l[o];for(let g=0;g<4;g++){const x=f[g];if(s.crossVectors(m,x),t.setFromPoints(s,e),i.setFromPoints(s,u),t.isSeparated(i))return!1}}return!0}})();X.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})();X.prototype.distanceToPoint=(function(){const n=new C;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}})();X.prototype.distanceToBox=(function(){const n=["x","y","z"],e=new Array(12).fill().map(()=>new ge),t=new Array(12).fill().map(()=>new ge),i=new C,s=new C;return function(r,c=0,l=null,h=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(l||h)&&(r.getCenter(s),this.closestPointToPoint(s,i),r.closestPointToPoint(i,s),l&&l.copy(i),h&&h.copy(s)),0;const f=c*c,u=r.min,o=r.max,m=this.points;let g=1/0;for(let d=0;d<8;d++){const b=m[d];s.copy(b).clamp(u,o);const p=b.distanceToSquared(s);if(p<g&&(g=p,l&&l.copy(b),h&&h.copy(s),p<f))return Math.sqrt(p)}let x=0;for(let d=0;d<3;d++)for(let b=0;b<=1;b++)for(let p=0;p<=1;p++){const v=(d+1)%3,y=(d+2)%3,T=b<<v|p<<y,A=1<<d|b<<v|p<<y,w=m[T],M=m[A];e[x].set(w,M);const _=n[d],P=n[v],S=n[y],R=t[x],F=R.start,D=R.end;F[_]=u[_],F[P]=b?u[P]:o[P],F[S]=p?u[S]:o[S],D[_]=o[_],D[P]=b?u[P]:o[P],D[S]=p?u[S]:o[S],x++}for(let d=0;d<=1;d++)for(let b=0;b<=1;b++)for(let p=0;p<=1;p++){s.x=d?o.x:u.x,s.y=b?o.y:u.y,s.z=p?o.z:u.z,this.closestPointToPoint(s,i);const v=s.distanceToSquared(i);if(v<g&&(g=v,l&&l.copy(i),h&&h.copy(s),v<f))return Math.sqrt(v)}for(let d=0;d<12;d++){const b=e[d];for(let p=0;p<12;p++){const v=t[p];Mi(b,v,i,s);const y=i.distanceToSquared(s);if(y<g&&(g=y,l&&l.copy(i),h&&h.copy(s),y<f))return Math.sqrt(y)}}return Math.sqrt(g)}})();class Wn extends Ai{constructor(){super(()=>new ce)}}const ie=new Wn,it=new C,Jt=new C;function Vn(n,e,t={},i=0,s=1/0){const a=i*i,r=s*s;let c=1/0,l=null;if(n.shapecast({boundsTraverseOrder:f=>(it.copy(e).clamp(f.min,f.max),it.distanceToSquared(e)),intersectsBounds:(f,u,o)=>o<c&&o<r,intersectsTriangle:(f,u)=>{f.closestPointToPoint(e,it);const o=e.distanceToSquared(it);return o<c&&(Jt.copy(it),c=o,l=u),o<a}}),c===1/0)return null;const h=Math.sqrt(c);return t.point?t.point.copy(Jt):t.point=Jt.clone(),t.distance=h,t.faceIndex=l,t}const mt=parseInt(Sr)>=169,qn=parseInt(Sr)<=161,Ae=new C,Me=new C,Ie=new C,pt=new Y,gt=new Y,vt=new Y,Wi=new C,Vi=new C,qi=new C,rt=new C;function Gn(n,e,t,i,s,a,r,c){let l;if(a===Tr?l=n.intersectTriangle(i,t,e,!0,s):l=n.intersectTriangle(e,t,i,a!==wr,s),l===null)return null;const h=n.origin.distanceTo(s);return h<r||h>c?null:{distance:h,point:s.clone()}}function Gi(n,e,t,i,s,a,r,c,l,h,f){Ae.fromBufferAttribute(e,a),Me.fromBufferAttribute(e,r),Ie.fromBufferAttribute(e,c);const u=Gn(n,Ae,Me,Ie,rt,l,h,f);if(u){if(i){pt.fromBufferAttribute(i,a),gt.fromBufferAttribute(i,r),vt.fromBufferAttribute(i,c),u.uv=new Y;const m=Ye.getInterpolation(rt,Ae,Me,Ie,pt,gt,vt,u.uv);mt||(u.uv=m)}if(s){pt.fromBufferAttribute(s,a),gt.fromBufferAttribute(s,r),vt.fromBufferAttribute(s,c),u.uv1=new Y;const m=Ye.getInterpolation(rt,Ae,Me,Ie,pt,gt,vt,u.uv1);mt||(u.uv1=m),qn&&(u.uv2=u.uv1)}if(t){Wi.fromBufferAttribute(t,a),Vi.fromBufferAttribute(t,r),qi.fromBufferAttribute(t,c),u.normal=new C;const m=Ye.getInterpolation(rt,Ae,Me,Ie,Wi,Vi,qi,u.normal);u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1),mt||(u.normal=m)}const o={a,b:r,c,normal:new C,materialIndex:0};if(Ye.getNormal(Ae,Me,Ie,o.normal),u.face=o,u.faceIndex=a,mt){const m=new C;Ye.getBarycoord(rt,Ae,Me,Ie,m),u.barycoord=m}}return u}function $i(n){return n&&n.isMaterial?n.side:n}function Lt(n,e,t,i,s,a,r){const c=i*3;let l=c+0,h=c+1,f=c+2;const{index:u,groups:o}=n;n.index&&(l=u.getX(l),h=u.getX(h),f=u.getX(f));const{position:m,normal:g,uv:x,uv1:d}=n.attributes;if(Array.isArray(e)){const b=i*3;for(let p=0,v=o.length;p<v;p++){const{start:y,count:T,materialIndex:A}=o[p];if(b>=y&&b<y+T){const w=$i(e[A]),M=Gi(t,m,g,x,d,l,h,f,w,a,r);if(M)if(M.faceIndex=i,M.face.materialIndex=A,s)s.push(M);else return M}}}else{const b=$i(e),p=Gi(t,m,g,x,d,l,h,f,b,a,r);if(p)if(p.faceIndex=i,p.face.materialIndex=0,s)s.push(p);else return p}return null}function U(n,e,t,i){const s=n.a,a=n.b,r=n.c;let c=e,l=e+1,h=e+2;t&&(c=t.getX(c),l=t.getX(l),h=t.getX(h)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(l),a.y=i.getY(l),a.z=i.getZ(l),r.x=i.getX(h),r.y=i.getY(h),r.z=i.getZ(h)}function $n(n,e,t,i,s,a,r,c){const{geometry:l,_indirectBuffer:h}=n;for(let f=i,u=i+s;f<u;f++)Lt(l,e,t,f,a,r,c)}function Yn(n,e,t,i,s,a,r){const{geometry:c,_indirectBuffer:l}=n;let h=1/0,f=null;for(let u=i,o=i+s;u<o;u++){let m;m=Lt(c,e,t,u,null,a,r),m&&m.distance<h&&(f=m,h=m.distance)}return f}function jn(n,e,t,i,s,a,r){const{geometry:c}=t,{index:l}=c,h=c.attributes.position;for(let f=n,u=e+n;f<u;f++){let o;if(o=f,U(r,o*3,l,h),r.needsUpdate=!0,i(r,o,s,a))return!0}return!1}function Xn(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,r,c,l,h=0;const f=n._roots;for(let o=0,m=f.length;o<m;o++)a=f[o],r=new Uint32Array(a),c=new Uint16Array(a),l=new Float32Array(a),u(0,h),h+=a.byteLength;function u(o,m,g=!1){const x=o*2;if(k(x,c)){const d=H(o,r),b=q(x,c);let p=1/0,v=1/0,y=1/0,T=-1/0,A=-1/0,w=-1/0;for(let M=3*d,I=3*(d+b);M<I;M++){let _=i[M];const P=s.getX(_),S=s.getY(_),R=s.getZ(_);P<p&&(p=P),P>T&&(T=P),S<v&&(v=S),S>A&&(A=S),R<y&&(y=R),R>w&&(w=R)}return l[o+0]!==p||l[o+1]!==v||l[o+2]!==y||l[o+3]!==T||l[o+4]!==A||l[o+5]!==w?(l[o+0]=p,l[o+1]=v,l[o+2]=y,l[o+3]=T,l[o+4]=A,l[o+5]=w,!0):!1}else{const d=W(o),b=V(o,r);let p=g,v=!1,y=!1;if(e){if(!p){const _=d/O+m/j,P=b/O+m/j;v=e.has(_),y=e.has(P),p=!v&&!y}}else v=!0,y=!0;const T=p||v,A=p||y;let w=!1;T&&(w=u(d,m,p));let M=!1;A&&(M=u(b,m,p));const I=w||M;if(I)for(let _=0;_<3;_++){const P=d+_,S=b+_,R=l[P],F=l[P+3],D=l[S],E=l[S+3];l[o+_]=R<D?R:D,l[o+_+3]=F>E?F:E}return I}}}function re(n,e,t,i,s){let a,r,c,l,h,f;const u=1/t.direction.x,o=1/t.direction.y,m=1/t.direction.z,g=t.origin.x,x=t.origin.y,d=t.origin.z;let b=e[n],p=e[n+3],v=e[n+1],y=e[n+3+1],T=e[n+2],A=e[n+3+2];return u>=0?(a=(b-g)*u,r=(p-g)*u):(a=(p-g)*u,r=(b-g)*u),o>=0?(c=(v-x)*o,l=(y-x)*o):(c=(y-x)*o,l=(v-x)*o),a>l||c>r||((c>a||isNaN(a))&&(a=c),(l<r||isNaN(r))&&(r=l),m>=0?(h=(T-d)*m,f=(A-d)*m):(h=(A-d)*m,f=(T-d)*m),a>f||h>r)?!1:((h>a||a!==a)&&(a=h),(f<r||r!==r)&&(r=f),a<=s&&r>=i)}function Qn(n,e,t,i,s,a,r,c){const{geometry:l,_indirectBuffer:h}=n;for(let f=i,u=i+s;f<u;f++){let o=h?h[f]:f;Lt(l,e,t,o,a,r,c)}}function Kn(n,e,t,i,s,a,r){const{geometry:c,_indirectBuffer:l}=n;let h=1/0,f=null;for(let u=i,o=i+s;u<o;u++){let m;m=Lt(c,e,t,l?l[u]:u,null,a,r),m&&m.distance<h&&(f=m,h=m.distance)}return f}function Zn(n,e,t,i,s,a,r){const{geometry:c}=t,{index:l}=c,h=c.attributes.position;for(let f=n,u=e+n;f<u;f++){let o;if(o=t.resolveTriangleIndex(f),U(r,o*3,l,h),r.needsUpdate=!0,i(r,o,s,a))return!0}return!1}function Jn(n,e,t,i,s,a,r){B.setBuffer(n._roots[e]),re(0,B.float32Array,i,a,r)&&hi(0,n,t,i,s,a,r),B.clearBuffer()}function hi(n,e,t,i,s,a,r){const{float32Array:c,uint16Array:l,uint32Array:h}=B,f=n*2;if(k(f,l)){const o=H(n,h),m=q(f,l);$n(e,t,i,o,m,s,a,r)}else{const o=W(n);re(o,c,i,a,r)&&hi(o,e,t,i,s,a,r);const m=V(n,h);re(m,c,i,a,r)&&hi(m,e,t,i,s,a,r)}}const es=["x","y","z"];function ts(n,e,t,i,s,a){B.setBuffer(n._roots[e]);let r=null;return re(0,B.float32Array,i,s,a)&&(r=di(0,n,t,i,s,a)),B.clearBuffer(),r}function di(n,e,t,i,s,a){const{float32Array:r,uint16Array:c,uint32Array:l}=B;let h=n*2;if(k(h,c)){const u=H(n,l),o=q(h,c);return Yn(e,t,i,u,o,s,a)}else{const u=kt(n,l),o=es[u],g=i.direction[o]>=0;let x,d;g?(x=W(n),d=V(n,l)):(x=V(n,l),d=W(n));const p=re(x,r,i,s,a)?di(x,e,t,i,s,a):null;if(p){const T=p.point[o];if(g?T<=r[d+u]:T>=r[d+u+3])return p}const y=re(d,r,i,s,a)?di(d,e,t,i,s,a):null;return p&&y?p.distance<=y.distance?p:y:p||y||null}}const xt=new de,He=new ce,We=new ce,nt=new $,Yi=new X,yt=new X;function is(n,e,t,i){B.setBuffer(n._roots[e]);const s=mi(0,n,t,i);return B.clearBuffer(),s}function mi(n,e,t,i,s=null){const{float32Array:a,uint16Array:r,uint32Array:c}=B;let l=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Yi.set(t.boundingBox.min,t.boundingBox.max,i),s=Yi),k(l,r)){const f=e.geometry,u=f.index,o=f.attributes.position,m=t.index,g=t.attributes.position,x=H(n,c),d=q(l,r);if(nt.copy(i).invert(),t.boundsTree)return z(n,a,yt),yt.matrix.copy(nt),yt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:p=>yt.intersectsBox(p),intersectsTriangle:p=>{p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let v=x*3,y=(d+x)*3;v<y;v+=3)if(U(We,v,u,o),We.needsUpdate=!0,p.intersectsTriangle(We))return!0;return!1}});{const b=Ut(t);for(let p=x*3,v=(d+x)*3;p<v;p+=3){U(He,p,u,o),He.a.applyMatrix4(nt),He.b.applyMatrix4(nt),He.c.applyMatrix4(nt),He.needsUpdate=!0;for(let y=0,T=b*3;y<T;y+=3)if(U(We,y,m,g),We.needsUpdate=!0,He.intersectsTriangle(We))return!0}}}else{const f=W(n),u=V(n,c);return z(f,a,xt),!!(s.intersectsBox(xt)&&mi(f,e,t,i,s)||(z(u,a,xt),s.intersectsBox(xt)&&mi(u,e,t,i,s)))}}const bt=new $,ei=new X,st=new X,rs=new C,ns=new C,ss=new C,as=new C;function os(n,e,t,i={},s={},a=0,r=1/0){e.boundingBox||e.computeBoundingBox(),ei.set(e.boundingBox.min,e.boundingBox.max,t),ei.needsUpdate=!0;const c=n.geometry,l=c.attributes.position,h=c.index,f=e.attributes.position,u=e.index,o=ie.getPrimitive(),m=ie.getPrimitive();let g=rs,x=ns,d=null,b=null;s&&(d=ss,b=as);let p=1/0,v=null,y=null;return bt.copy(t).invert(),st.matrix.copy(bt),n.shapecast({boundsTraverseOrder:T=>ei.distanceToBox(T),intersectsBounds:(T,A,w)=>w<p&&w<r?(A&&(st.min.copy(T.min),st.max.copy(T.max),st.needsUpdate=!0),!0):!1,intersectsRange:(T,A)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:M=>st.distanceToBox(M),intersectsBounds:(M,I,_)=>_<p&&_<r,intersectsRange:(M,I)=>{for(let _=M,P=M+I;_<P;_++){U(m,3*_,u,f),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let S=T,R=T+A;S<R;S++){U(o,3*S,h,l),o.needsUpdate=!0;const F=o.distanceToTriangle(m,g,d);if(F<p&&(x.copy(g),b&&b.copy(d),p=F,v=S,y=_),F<a)return!0}}}});{const w=Ut(e);for(let M=0,I=w;M<I;M++){U(m,3*M,u,f),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let _=T,P=T+A;_<P;_++){U(o,3*_,h,l),o.needsUpdate=!0;const S=o.distanceToTriangle(m,g,d);if(S<p&&(x.copy(g),b&&b.copy(d),p=S,v=_,y=M),S<a)return!0}}}}}),ie.releasePrimitive(o),ie.releasePrimitive(m),p===1/0?null:(i.point?i.point.copy(x):i.point=x.clone(),i.distance=p,i.faceIndex=v,s&&(s.point?s.point.copy(b):s.point=b.clone(),s.point.applyMatrix4(bt),x.applyMatrix4(bt),s.distance=x.sub(s.point).length(),s.faceIndex=y),i)}function cs(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,r,c,l,h=0;const f=n._roots;for(let o=0,m=f.length;o<m;o++)a=f[o],r=new Uint32Array(a),c=new Uint16Array(a),l=new Float32Array(a),u(0,h),h+=a.byteLength;function u(o,m,g=!1){const x=o*2;if(k(x,c)){const d=H(o,r),b=q(x,c);let p=1/0,v=1/0,y=1/0,T=-1/0,A=-1/0,w=-1/0;for(let M=d,I=d+b;M<I;M++){const _=3*n.resolveTriangleIndex(M);for(let P=0;P<3;P++){let S=_+P;S=i?i[S]:S;const R=s.getX(S),F=s.getY(S),D=s.getZ(S);R<p&&(p=R),R>T&&(T=R),F<v&&(v=F),F>A&&(A=F),D<y&&(y=D),D>w&&(w=D)}}return l[o+0]!==p||l[o+1]!==v||l[o+2]!==y||l[o+3]!==T||l[o+4]!==A||l[o+5]!==w?(l[o+0]=p,l[o+1]=v,l[o+2]=y,l[o+3]=T,l[o+4]=A,l[o+5]=w,!0):!1}else{const d=W(o),b=V(o,r);let p=g,v=!1,y=!1;if(e){if(!p){const _=d/O+m/j,P=b/O+m/j;v=e.has(_),y=e.has(P),p=!v&&!y}}else v=!0,y=!0;const T=p||v,A=p||y;let w=!1;T&&(w=u(d,m,p));let M=!1;A&&(M=u(b,m,p));const I=w||M;if(I)for(let _=0;_<3;_++){const P=d+_,S=b+_,R=l[P],F=l[P+3],D=l[S],E=l[S+3];l[o+_]=R<D?R:D,l[o+_+3]=F>E?F:E}return I}}}function ls(n,e,t,i,s,a,r){B.setBuffer(n._roots[e]),re(0,B.float32Array,i,a,r)&&pi(0,n,t,i,s,a,r),B.clearBuffer()}function pi(n,e,t,i,s,a,r){const{float32Array:c,uint16Array:l,uint32Array:h}=B,f=n*2;if(k(f,l)){const o=H(n,h),m=q(f,l);Qn(e,t,i,o,m,s,a,r)}else{const o=W(n);re(o,c,i,a,r)&&pi(o,e,t,i,s,a,r);const m=V(n,h);re(m,c,i,a,r)&&pi(m,e,t,i,s,a,r)}}const us=["x","y","z"];function fs(n,e,t,i,s,a){B.setBuffer(n._roots[e]);let r=null;return re(0,B.float32Array,i,s,a)&&(r=gi(0,n,t,i,s,a)),B.clearBuffer(),r}function gi(n,e,t,i,s,a){const{float32Array:r,uint16Array:c,uint32Array:l}=B;let h=n*2;if(k(h,c)){const u=H(n,l),o=q(h,c);return Kn(e,t,i,u,o,s,a)}else{const u=kt(n,l),o=us[u],g=i.direction[o]>=0;let x,d;g?(x=W(n),d=V(n,l)):(x=V(n,l),d=W(n));const p=re(x,r,i,s,a)?gi(x,e,t,i,s,a):null;if(p){const T=p.point[o];if(g?T<=r[d+u]:T>=r[d+u+3])return p}const y=re(d,r,i,s,a)?gi(d,e,t,i,s,a):null;return p&&y?p.distance<=y.distance?p:y:p||y||null}}const Tt=new de,Ve=new ce,qe=new ce,at=new $,ji=new X,wt=new X;function hs(n,e,t,i){B.setBuffer(n._roots[e]);const s=vi(0,n,t,i);return B.clearBuffer(),s}function vi(n,e,t,i,s=null){const{float32Array:a,uint16Array:r,uint32Array:c}=B;let l=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),ji.set(t.boundingBox.min,t.boundingBox.max,i),s=ji),k(l,r)){const f=e.geometry,u=f.index,o=f.attributes.position,m=t.index,g=t.attributes.position,x=H(n,c),d=q(l,r);if(at.copy(i).invert(),t.boundsTree)return z(n,a,wt),wt.matrix.copy(at),wt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:p=>wt.intersectsBox(p),intersectsTriangle:p=>{p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let v=x,y=d+x;v<y;v++)if(U(qe,3*e.resolveTriangleIndex(v),u,o),qe.needsUpdate=!0,p.intersectsTriangle(qe))return!0;return!1}});{const b=Ut(t);for(let p=x,v=d+x;p<v;p++){const y=e.resolveTriangleIndex(p);U(Ve,3*y,u,o),Ve.a.applyMatrix4(at),Ve.b.applyMatrix4(at),Ve.c.applyMatrix4(at),Ve.needsUpdate=!0;for(let T=0,A=b*3;T<A;T+=3)if(U(qe,T,m,g),qe.needsUpdate=!0,Ve.intersectsTriangle(qe))return!0}}}else{const f=W(n),u=V(n,c);return z(f,a,Tt),!!(s.intersectsBox(Tt)&&vi(f,e,t,i,s)||(z(u,a,Tt),s.intersectsBox(Tt)&&vi(u,e,t,i,s)))}}const St=new $,ti=new X,ot=new X,ds=new C,ms=new C,ps=new C,gs=new C;function vs(n,e,t,i={},s={},a=0,r=1/0){e.boundingBox||e.computeBoundingBox(),ti.set(e.boundingBox.min,e.boundingBox.max,t),ti.needsUpdate=!0;const c=n.geometry,l=c.attributes.position,h=c.index,f=e.attributes.position,u=e.index,o=ie.getPrimitive(),m=ie.getPrimitive();let g=ds,x=ms,d=null,b=null;s&&(d=ps,b=gs);let p=1/0,v=null,y=null;return St.copy(t).invert(),ot.matrix.copy(St),n.shapecast({boundsTraverseOrder:T=>ti.distanceToBox(T),intersectsBounds:(T,A,w)=>w<p&&w<r?(A&&(ot.min.copy(T.min),ot.max.copy(T.max),ot.needsUpdate=!0),!0):!1,intersectsRange:(T,A)=>{if(e.boundsTree){const w=e.boundsTree;return w.shapecast({boundsTraverseOrder:M=>ot.distanceToBox(M),intersectsBounds:(M,I,_)=>_<p&&_<r,intersectsRange:(M,I)=>{for(let _=M,P=M+I;_<P;_++){const S=w.resolveTriangleIndex(_);U(m,3*S,u,f),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=T,F=T+A;R<F;R++){const D=n.resolveTriangleIndex(R);U(o,3*D,h,l),o.needsUpdate=!0;const E=o.distanceToTriangle(m,g,d);if(E<p&&(x.copy(g),b&&b.copy(d),p=E,v=R,y=_),E<a)return!0}}}})}else{const w=Ut(e);for(let M=0,I=w;M<I;M++){U(m,3*M,u,f),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let _=T,P=T+A;_<P;_++){const S=n.resolveTriangleIndex(_);U(o,3*S,h,l),o.needsUpdate=!0;const R=o.distanceToTriangle(m,g,d);if(R<p&&(x.copy(g),b&&b.copy(d),p=R,v=_,y=M),R<a)return!0}}}}}),ie.releasePrimitive(o),ie.releasePrimitive(m),p===1/0?null:(i.point?i.point.copy(x):i.point=x.clone(),i.distance=p,i.faceIndex=v,s&&(s.point?s.point.copy(b):s.point=b.clone(),s.point.applyMatrix4(St),x.applyMatrix4(St),s.distance=x.sub(s.point).length(),s.faceIndex=y),i)}function Xi(n,e,t){return n===null?null:(n.point.applyMatrix4(e.matrixWorld),n.distance=n.point.distanceTo(t.ray.origin),n.object=e,n)}const _t=new X,At=new Kr,Qi=new C,Ki=new $,Zi=new C,ii=["getX","getY","getZ"];class zt extends On{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,a=e._indirectBuffer,r=i.getIndex(),c={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(c.roots=s.map(l=>l.slice()),c.index=r?r.array.slice():null,c.indirectBuffer=a?a.slice():null):(c.roots=s,c.index=r?r.array:null,c.indirectBuffer=a),c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:a,indirectBuffer:r}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),l(a));const c=new zt(t,{...i,[Si]:!0});if(c._roots=a,c._indirectBuffer=r||null,i.setIndex){const h=t.getIndex();if(h===null){const f=new te(e.index,1,!1);t.setIndex(f)}else h.array!==s&&(h.array.set(s),h.needsUpdate=!0)}return c;function l(h){for(let f=0;f<h.length;f++){const u=h[f],o=new Uint32Array(u),m=new Uint16Array(u);for(let g=0,x=u.byteLength/j;g<x;g++){const d=O*g,b=2*d;k(b,m)||(o[d+6]=o[d+6]/O-g)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use "targetLeafSize", instead.'),t={...t,targetLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,i){const s=this.geometry,a=this._indirectBuffer,r=s.attributes.position,c=s.index?s.index.array:null,h=(a?a[e]:e)*3;let f=h+0,u=h+1,o=h+2;c&&(f=c[f],u=c[u],o=c[o]);for(let m=0;m<3;m++){const g=r[ii[m]](f),x=r[ii[m]](u),d=r[ii[m]](o);let b=g;x<b&&(b=x),d<b&&(b=d);let p=g;x>p&&(p=x),d>p&&(p=d),t[i+m]=b,t[i+m+3]=p}return t}computePrimitiveBounds(e,t,i){const s=this.geometry,a=this._indirectBuffer,r=s.attributes.position,c=s.index?s.index.array:null,l=r.normalized;if(e<0||t+e-i.offset>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const h=r.array,f=r.offset||0;let u=3;r.isInterleavedBufferAttribute&&(u=r.data.stride);const o=["getX","getY","getZ"],m=i.offset;for(let g=e,x=e+t;g<x;g++){const b=(a?a[g]:g)*3,p=(g-m)*6;let v=b+0,y=b+1,T=b+2;c&&(v=c[v],y=c[y],T=c[T]),l||(v=v*u+f,y=y*u+f,T=T*u+f);for(let A=0;A<3;A++){let w,M,I;l?(w=r[o[A]](v),M=r[o[A]](y),I=r[o[A]](T)):(w=h[v+A],M=h[y+A],I=h[T+A]);let _=w;M<_&&(_=M),I<_&&(_=I);let P=w;M>P&&(P=M),I>P&&(P=I);const S=(P-_)/2,R=A*2;i[p+R+0]=_+S,i[p+R+1]=S+(Math.abs(_)+S)*Dt}}return i}raycastObject3D(e,t,i=[]){const{material:s}=e;if(s===void 0)return;Ki.copy(e.matrixWorld).invert(),At.copy(t.ray).applyMatrix4(Ki),Zi.setFromMatrixScale(e.matrixWorld),Qi.copy(At.direction).multiply(Zi);const a=Qi.length(),r=t.near/a,c=t.far/a;if(t.firstHitOnly===!0){let l=this.raycastFirst(At,s,r,c);l=Xi(l,e,t),l&&i.push(l)}else{const l=this.raycast(At,s,r,c);for(let h=0,f=l.length;h<f;h++){const u=Xi(l[h],e,t);u&&i.push(u)}}return i}refit(e=null){return(this.indirect?cs:Xn)(this,e)}raycast(e,t=oi,i=0,s=1/0){const a=this._roots,r=[],c=this.indirect?ls:Jn;for(let l=0,h=a.length;l<h;l++)c(this,l,t,e,r,i,s);return r}raycastFirst(e,t=oi,i=0,s=1/0){const a=this._roots;let r=null;const c=this.indirect?fs:ts;for(let l=0,h=a.length;l<h;l++){const f=c(this,l,t,e,i,s);f!=null&&(r==null||f.distance<r.distance)&&(r=f)}return r}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?hs:is;for(let r=0,c=s.length;r<c&&(i=a(this,r,e,t),!i);r++);return i}shapecast(e){const t=ie.getPrimitive(),i=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?Zn:jn});return ie.releasePrimitive(t),i}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const r=ie.getPrimitive(),c=this.geometry.index,l=this.geometry.attributes.position,h=this.indirect?g=>{const x=this.resolveTriangleIndex(g);U(r,x*3,c,l)}:g=>{U(r,g*3,c,l)},f=ie.getPrimitive(),u=e.geometry.index,o=e.geometry.attributes.position,m=e.indirect?g=>{const x=e.resolveTriangleIndex(g);U(f,x*3,u,o)}:g=>{U(f,g*3,u,o)};if(a){if(!(e instanceof zt))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const g=(x,d,b,p,v,y,T,A)=>{for(let w=b,M=b+p;w<M;w++){m(w),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let I=x,_=x+d;I<_;I++)if(h(I),r.needsUpdate=!0,a(r,f,I,w,v,y,T,A))return!0}return!1};if(s){const x=s;s=function(d,b,p,v,y,T,A,w){return x(d,b,p,v,y,T,A,w)?!0:g(d,b,p,v,y,T,A,w)}}else s=g}return super.bvhcast(e,t,{intersectsRanges:s})}intersectsBox(e,t){return _t.set(e.min,e.max,t),_t.needsUpdate=!0,this.shapecast({intersectsBounds:i=>_t.intersectsBox(i),intersectsTriangle:i=>_t.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},a=0,r=1/0){return(this.indirect?vs:os)(this,e,t,i,s,a,r)}closestPointToPoint(e,t={},i=0,s=1/0){return Vn(this,e,t,i,s)}}function xs(n){switch(n){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function ys(n){switch(n){case 1:return Et;case 2:return Ar;case 3:return L;case 4:return L}}function Ji(n){switch(n){case 1:return en;case 2:return _r;case 3:return li;case 4:return li}}class Dr extends Z{constructor(){super(),this.minFilter=N,this.magFilter=N,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const t=this.overrideItemSize,i=e.itemSize,s=e.count;if(t!==null){if(i*s%t!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");e.itemSize=t,e.count=s*i/t}const a=e.itemSize,r=e.count,c=e.normalized,l=e.array.constructor,h=l.BYTES_PER_ELEMENT;let f=this._forcedType,u=a;if(f===null)switch(l){case Float32Array:f=G;break;case Uint8Array:case Uint16Array:case Uint32Array:f=lt;break;case Int8Array:case Int16Array:case Int32Array:f=qt;break}let o,m,g,x,d=xs(a);switch(f){case G:g=1,m=ys(a),c&&h===1?(x=l,d+="8",l===Uint8Array?o=ci:(o=Di,d+="_SNORM")):(x=Float32Array,d+="32F",o=G);break;case qt:d+=h*8+"I",g=c?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,m=Ji(a),h===1?(x=Int8Array,o=Di):h===2?(x=Int16Array,o=Jr):(x=Int32Array,o=qt);break;case lt:d+=h*8+"UI",g=c?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,m=Ji(a),h===1?(x=Uint8Array,o=ci):h===2?(x=Uint16Array,o=Zr):(x=Uint32Array,o=lt);break}u===3&&(m===L||m===li)&&(u=4);const b=Math.ceil(Math.sqrt(r))||1,p=u*b*b,v=new x(p),y=e.normalized;e.normalized=!1;for(let T=0;T<r;T++){const A=u*T;v[A]=e.getX(T)/g,a>=2&&(v[A+1]=e.getY(T)/g),a>=3&&(v[A+2]=e.getZ(T)/g,u===4&&(v[A+3]=1)),a>=4&&(v[A+3]=e.getW(T)/g)}e.normalized=y,this.internalFormat=d,this.format=m,this.type=o,this.image.width=b,this.image.height=b,this.image.data=v,this.needsUpdate=!0,this.dispose(),e.itemSize=i,e.count=s}}class Er extends Dr{constructor(){super(),this._forcedType=lt}}class Br extends Dr{constructor(){super(),this._forcedType=G}}class zr{constructor(){this.index=new Er,this.position=new Br,this.bvhBounds=new Z,this.bvhContents=new Z,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:t}=e;if(Ts(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(t.attributes.position),e.indirect){const i=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==i.length)if(t.index)this._cachedIndexAttr=t.index.clone();else{const s=Cr(Ot(t));this._cachedIndexAttr=new te(s,1,!1)}bs(t,i,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(t.index)}dispose(){const{index:e,position:t,bvhBounds:i,bvhContents:s}=this;e&&e.dispose(),t&&t.dispose(),i&&i.dispose(),s&&s.dispose()}}function bs(n,e,t){const i=t.array,s=n.index?n.index.array:null;for(let a=0,r=e.length;a<r;a++){const c=3*a,l=3*e[a];for(let h=0;h<3;h++)i[c+h]=s?s[l+h]:l+h}}function Ts(n,e,t){const i=n._roots;if(i.length!==1)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const s=i[0],a=new Uint16Array(s),r=new Uint32Array(s),c=new Float32Array(s),l=s.byteLength/j,h=2*Math.ceil(Math.sqrt(l/2)),f=new Float32Array(4*h*h),u=Math.ceil(Math.sqrt(l)),o=new Uint32Array(2*u*u);for(let m=0;m<l;m++){const g=m*j/4,x=g*2,d=g;for(let b=0;b<3;b++)f[8*m+0+b]=c[d+0+b],f[8*m+4+b]=c[d+3+b];if(k(x,a)){const b=q(x,a),p=H(g,r),v=Tn|b;o[m*2+0]=v,o[m*2+1]=p}else{const b=r[g+6],p=kt(g,r);o[m*2+0]=p,o[m*2+1]=b}}e.image.data=f,e.image.width=h,e.image.height=h,e.format=L,e.type=G,e.internalFormat="RGBA32F",e.minFilter=N,e.magFilter=N,e.generateMipmaps=!1,e.needsUpdate=!0,e.dispose(),t.image.data=o,t.image.width=u,t.image.height=u,t.format=_r,t.type=lt,t.internalFormat="RG32UI",t.minFilter=N,t.magFilter=N,t.generateMipmaps=!1,t.needsUpdate=!0,t.dispose()}const Nr=`
1
+ import{Box3 as de,Matrix4 as $,BufferAttribute as te,Vector3 as C,Line3 as ge,Plane as br,Vector2 as Y,Triangle as Ye,BackSide as Tr,DoubleSide as wr,REVISION as Sr,Ray as Kr,FrontSide as oi,UnsignedIntType as lt,FloatType as G,DataTexture as Z,NearestFilter as N,IntType as qt,UnsignedByteType as ci,UnsignedShortType as Zr,ByteType as Di,ShortType as Jr,RGBAFormat as L,RGBAIntegerFormat as li,RGIntegerFormat as _r,RedIntegerFormat as en,RGFormat as Ar,RedFormat as Et,BufferGeometry as Ke,Matrix3 as tn,Vector4 as Ze,MeshBasicMaterial as rn,Mesh as nn,ShaderMaterial as Nt,NoBlending as Je,WebGLRenderTarget as Qe,PerspectiveCamera as Mr,DataUtils as K,HalfFloatType as ee,LinearFilter as oe,RepeatWrapping as we,ClampToEdgeWrapping as Se,Source as sn,Quaternion as an,DataArrayTexture as on,WebGLArrayRenderTarget as cn,Color as et,NoToneMapping as ln,NormalBlending as Ir,EquirectangularReflectionMapping as Ti,Spherical as un,LinearMipMapLinearFilter as fn,Clock as hn,Scene as dn,AdditiveBlending as mn,Camera as pn,SpotLight as gn,RectAreaLight as vn,PMREMGenerator as xn,MeshStandardMaterial as yn,TangentSpaceNormalMap as Ei}from"./three.module-Bx43vjkH.js";import{eK as De}from"./remote-kxNNhmis.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-DJC95K48.js";import"./titleFrameBudget-BW-N1-cw.js";import"./gltfLoader-U0Eebg7v.js";import"./store-xR02oY0m.js";import"./rotoMaskStore-RmW40Pcn.js";import"./sceneTrack-DyVxpl7i.js";import"./timelineOps-CEGk2t4h.js";import"./cameraTracker-DFjnZ7tw.js";import"./textAnimators-CeMuG34D.js";import"./timelineComp-D8PHGHgQ.js";import"./rigTrack-B9r9wrdV.js";import"./clientJobs-CuuUyhEy.js";const Pr=0,bn=1,Rr=2,Bi=2,Gt=1.25,zi=1,j=32,O=j/4,wi=65535,Tn=wi<<16,Dt=Math.pow(2,-24),Si=Symbol("SKIP_GENERATION"),Fr={strategy:Pr,maxDepth:40,targetLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Si]:!1};function z(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function ui(n){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=n[i+3]-n[i];s>t&&(t=s,e=i)}return e}function Ni(n,e,t){for(let i=0;i<3;i++){const s=e[n+2*i],a=e[n+2*i+1],r=s-a,c=s+a;r<t[i]&&(t[i]=r),c>t[i+3]&&(t[i+3]=c)}}function $t(n){const e=n[3]-n[0],t=n[4]-n[1],i=n[5]-n[2];return 2*(e*t+t*i+i*e)}function k(n,e){return e[n+15]===wi}function H(n,e){return e[n+6]}function q(n,e){return e[n+14]}function W(n){return n+O}function V(n,e){const t=e[n+6];return n+t*O}function kt(n,e){return e[n+7]}function Yt(n,e,t,i,s){let a=1/0,r=1/0,c=1/0,l=-1/0,h=-1/0,f=-1/0,u=1/0,o=1/0,m=1/0,g=-1/0,x=-1/0,d=-1/0;const b=n.offset||0;for(let p=(e-b)*6,v=(e+t-b)*6;p<v;p+=6){const y=n[p+0],T=n[p+1],A=y-T,w=y+T;A<a&&(a=A),w>l&&(l=w),y<u&&(u=y),y>g&&(g=y);const M=n[p+2],I=n[p+3],_=M-I,P=M+I;_<r&&(r=_),P>h&&(h=P),M<o&&(o=M),M>x&&(x=M);const S=n[p+4],R=n[p+5],F=S-R,D=S+R;F<c&&(c=F),D>f&&(f=D),S<m&&(m=S),S>d&&(d=S)}i[0]=a,i[1]=r,i[2]=c,i[3]=l,i[4]=h,i[5]=f,s[0]=u,s[1]=o,s[2]=m,s[3]=g,s[4]=x,s[5]=d}const he=8,_i=8,jt=new Int32Array(he),ue=new Float32Array(he*6),ze=new Float32Array(he*6),ne=new Float32Array(6),ft=new Float32Array(6),ye=new Int32Array(_i),ki=new Float32Array(_i*6);function wn(n,e,t,i){for(let s=0;s<3;s++){const a=e[n+2*s],r=e[n+2*s+1],c=a-r,l=a+r;c<t[i+s]&&(t[i+s]=c),l>t[i+s+3]&&(t[i+s+3]=l)}}function Oi(n,e){const t=n[e+3]-n[e],i=n[e+4]-n[e+1],s=n[e+5]-n[e+2];return 2*(t*i+i*s+s*t)}function Sn(n,e,t,i,s,a){let r=-1,c=0;if(a===Pr)r=ui(e),r!==-1&&(c=(e[r]+e[r+3])/2);else if(a===bn)r=ui(n),r!==-1&&(c=_n(t,i,s,r));else if(a===Rr){const l=$t(n);let h=Gt*s;const f=t.offset||0,u=(i-f)*6,o=(i+s-f)*6;for(let m=0;m<3;m++){const g=e[m],b=(e[m+3]-g)/he;if(s<_i){for(let p=0;p<s;p++){const v=u+p*6,y=t[v+2*m];let T=p;for(;T>0&&t[ye[T-1]+2*m]>y;)ye[T]=ye[T-1],T--;ye[T]=v}for(let p=0;p<3;p++)ne[p]=1/0,ne[p+3]=-1/0,ft[p]=1/0,ft[p+3]=-1/0;for(let p=s-1;p>=0;p--)Ni(ye[p],t,ft),ki.set(ft,p*6);for(let p=0;p<s-1;p++){Ni(ye[p],t,ne);const v=t[ye[p+1]+2*m];if(t[ye[p]+2*m]===v)continue;const y=p+1,T=s-y,A=$t(ne)/l,w=Oi(ki,y*6)/l,M=zi+Gt*(A*y+w*T);M<h&&(r=m,h=M,c=v)}}else{for(let y=0;y<he;y++){jt[y]=0;for(let T=0;T<3;T++)ue[y*6+T]=1/0,ue[y*6+T+3]=-1/0}for(let y=u;y<o;y+=6){let w=~~((t[y+2*m]-g)/b);w>=he&&(w=he-1),jt[w]++,wn(y,t,ue,w*6)}const p=(he-1)*6;for(let y=0;y<6;y++)ze[p+y]=ue[p+y];for(let y=he-2;y>=0;y--){const T=y*6,A=T+6;for(let w=0;w<3;w++)ze[T+w]=Math.min(ue[T+w],ze[A+w]),ze[T+w+3]=Math.max(ue[T+w+3],ze[A+w+3])}let v=0;for(let y=0;y<he-1;y++){const T=y*6,A=jt[y];if(A!==0)for(let P=0;P<3;P++)v===0?(ne[P]=ue[T+P],ne[P+3]=ue[T+P+3]):(ne[P]=Math.min(ne[P],ue[T+P]),ne[P+3]=Math.max(ne[P+3],ue[T+P+3]));v+=A;let w=0,M=0;v!==0&&(w=$t(ne)/l);const I=s-v;I!==0&&(M=Oi(ze,T+6)/l);const _=zi+Gt*(w*v+M*I);_<h&&(r=m,h=_,c=g+b+y*b)}}}}else console.warn(`BVH: Invalid build strategy value ${a} used.`);return{axis:r,pos:c}}function _n(n,e,t,i){let s=0;const a=n.offset;for(let r=e,c=e+t;r<c;r++)s+=n[(r-a)*6+i*2];return s/t}function An(n,e,t,i,s,a){let r=i,c=i+s-1;const l=a.pos,h=a.axis*2,f=t.offset||0;for(;;){for(;r<=c&&t[(r-f)*6+h]<l;)r++;for(;r<=c&&t[(c-f)*6+h]>=l;)c--;if(r<c){for(let u=0;u<e;u++){let o=n[r*e+u];n[r*e+u]=n[c*e+u],n[c*e+u]=o}for(let u=0;u<6;u++){const o=r-f,m=c-f,g=t[o*6+u];t[o*6+u]=t[m*6+u],t[m*6+u]=g}r++,c--}else return r}}const Mn=Math.pow(2,32),Ne=new Float32Array(6),ht=new Float32Array(6);function In(n,e,t,i,s,a){const{maxDepth:r,verbose:c,targetLeafSize:l,_strictLeafSize:h=1/0,strategy:f,onProgress:u,useSharedArrayBuffer:o=!1}=s,m=n.primitiveBuffer,g=n.primitiveBufferStride,x=o?SharedArrayBuffer:ArrayBuffer,d=new x(j*Math.max(1,2*Math.ceil(i)-1)),b=new Float32Array(d),p=new Uint32Array(d),v=new Uint16Array(d);let y=0,T=!1;return Yt(e,t,i,Ne,ht),M(t,i,0),d.slice(0,y*j);function A(I){u&&u((I-a.offset)/a.count)}function w(I,_,P){const S=I*2;p[I+6]=_,v[S+14]=P,v[S+15]=wi,A(_+P)}function M(I,_,P){const S=y++,R=S*O;b.set(Ne,R),!T&&P>=r&&(T=!0,c&&console.warn(`BVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`));const F=_>h;if(_<=l&&!F||P>=r){w(R,I,_);return}const D=Sn(Ne,ht,e,I,_,f);let E=D.axis===-1?-1:An(m,g,e,I,_,D);if(D.axis===-1||E===I||E===I+_){if(!F){w(R,I,_);return}D.axis=Math.max(0,ui(Ne)),E=I+Math.max(1,Math.floor(_/2))}p[R+7]=D.axis;const le=E-I;Yt(e,I,le,Ne,ht),M(I,le,P+1);const me=y-S;if(me>Mn)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");p[R+6]=me;const xe=_-le;Yt(e,E,xe,Ne,ht),M(E,xe,P+1)}}function Pn(n,e){const t=n.getRootRanges(e.range),i=t[0],s=t[t.length-1],a={offset:i.offset,count:s.offset+s.count-i.offset},r=new Float32Array(6*a.count);r.offset=a.offset,n.computePrimitiveBounds(a.offset,a.count,r),n._roots=t.map(c=>In(n,r,c.offset,c.count,e,a))}class Ai{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Rn{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const B=new Rn;let Te,Xe;const ke=[],dt=new Ai(()=>new de);function Fn(n,e,t,i,s,a){Te=dt.getPrimitive(),Xe=dt.getPrimitive(),ke.push(Te,Xe),B.setBuffer(n._roots[e]);const r=fi(0,n.geometry,t,i,s,a);B.clearBuffer(),dt.releasePrimitive(Te),dt.releasePrimitive(Xe),ke.pop(),ke.pop();const c=ke.length;return c>0&&(Xe=ke[c-1],Te=ke[c-2]),r}function fi(n,e,t,i,s=null,a=0,r=0){const{float32Array:c,uint16Array:l,uint32Array:h}=B;let f=n*2;if(k(f,l)){const o=H(n,h),m=q(f,l);return z(n,c,Te),i(o,m,!1,r,a+n/O,Te)}else{let _=function(S){const{uint16Array:R,uint32Array:F}=B;let D=S*2;for(;!k(D,R);)S=W(S),D=S*2;return H(S,F)},P=function(S){const{uint16Array:R,uint32Array:F}=B;let D=S*2;for(;!k(D,R);)S=V(S,F),D=S*2;return H(S,F)+q(D,R)};const o=W(n),m=V(n,h);let g=o,x=m,d,b,p,v;if(s&&(p=Te,v=Xe,z(g,c,p),z(x,c,v),d=s(p),b=s(v),b<d)){g=m,x=o;const S=d;d=b,b=S,p=v}p||(p=Te,z(g,c,p));const y=k(g*2,l),T=t(p,y,d,r+1,a+g/O);let A;if(T===Bi){const S=_(g),F=P(g)-S;A=i(S,F,!0,r+1,a+g/O,p)}else A=T&&fi(g,e,t,i,s,a,r+1);if(A)return!0;v=Xe,z(x,c,v);const w=k(x*2,l),M=t(v,w,b,r+1,a+x/O);let I;if(M===Bi){const S=_(x),F=P(x)-S;I=i(S,F,!0,r+1,a+x/O,v)}else I=M&&fi(x,e,t,i,s,a,r+1);return!!I}}const ut=new B.constructor,Bt=new B.constructor,be=new Ai(()=>new de),Oe=new de,Ue=new de,Xt=new de,Qt=new de;let Kt=!1;function Cn(n,e,t,i){if(Kt)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Kt=!0;const s=n._roots,a=e._roots;let r,c=0,l=0;const h=new $().copy(t).invert();for(let f=0,u=s.length;f<u;f++){ut.setBuffer(s[f]),l=0;const o=be.getPrimitive();z(0,ut.float32Array,o),o.applyMatrix4(h);for(let m=0,g=a.length;m<g&&(Bt.setBuffer(a[m]),r=ae(0,0,t,h,i,c,l,0,0,o),Bt.clearBuffer(),l+=a[m].byteLength/j,!r);m++);if(be.releasePrimitive(o),ut.clearBuffer(),c+=s[f].byteLength/j,r)break}return Kt=!1,r}function ae(n,e,t,i,s,a=0,r=0,c=0,l=0,h=null,f=!1){let u,o;f?(u=Bt,o=ut):(u=ut,o=Bt);const m=u.float32Array,g=u.uint32Array,x=u.uint16Array,d=o.float32Array,b=o.uint32Array,p=o.uint16Array,v=n*2,y=e*2,T=k(v,x),A=k(y,p);let w=!1;if(A&&T)f?w=s(H(e,b),q(e*2,p),H(n,g),q(n*2,x),l,r+e/O,c,a+n/O):w=s(H(n,g),q(n*2,x),H(e,b),q(e*2,p),c,a+n/O,l,r+e/O);else if(A){const M=be.getPrimitive();z(e,d,M),M.applyMatrix4(t);const I=W(n),_=V(n,g);z(I,m,Oe),z(_,m,Ue);const P=M.intersectsBox(Oe),S=M.intersectsBox(Ue);w=P&&ae(e,I,i,t,s,r,a,l,c+1,M,!f)||S&&ae(e,_,i,t,s,r,a,l,c+1,M,!f),be.releasePrimitive(M)}else{const M=W(e),I=V(e,b);z(M,d,Xt),z(I,d,Qt);const _=h.intersectsBox(Xt),P=h.intersectsBox(Qt);if(_&&P)w=ae(n,M,t,i,s,a,r,c,l+1,h,f)||ae(n,I,t,i,s,a,r,c,l+1,h,f);else if(_)if(T)w=ae(n,M,t,i,s,a,r,c,l+1,h,f);else{const S=be.getPrimitive();S.copy(Xt).applyMatrix4(t);const R=W(n),F=V(n,g);z(R,m,Oe),z(F,m,Ue);const D=S.intersectsBox(Oe),E=S.intersectsBox(Ue);w=D&&ae(M,R,i,t,s,r,a,l,c+1,S,!f)||E&&ae(M,F,i,t,s,r,a,l,c+1,S,!f),be.releasePrimitive(S)}else if(P)if(T)w=ae(n,I,t,i,s,a,r,c,l+1,h,f);else{const S=be.getPrimitive();S.copy(Qt).applyMatrix4(t);const R=W(n),F=V(n,g);z(R,m,Oe),z(F,m,Ue);const D=S.intersectsBox(Oe),E=S.intersectsBox(Ue);w=D&&ae(I,R,i,t,s,r,a,l,c+1,S,!f)||E&&ae(I,F,i,t,s,r,a,l,c+1,S,!f),be.releasePrimitive(S)}}return w}const Zt=new class{constructor(){let n=null,e=null,t=null,i=!1;this.root=null,this.buffer=null,this.uint32Array=null,this.uint16Array=null,this.setBVH=(a,r)=>{if(i)throw new Error("BVHTraversalHelper: cannot call setBVH during an active traversal.");this.root=r,this.buffer=n=a._roots[r],this.uint16Array=t=new Uint16Array(n),this.uint32Array=e=new Uint32Array(n)},this.reset=()=>{this.root=null,this.buffer=n=null,this.uint16Array=t=null,this.uint32Array=e=null},this.getRangeStart=a=>{let r=a*2;for(;!k(r,t);)a=W(a),r=a*2;return H(a,e)},this.getRangeEnd=a=>{let r=a*2;for(;!k(r,t);)a=V(a,e),r=a*2;return H(a,e)+q(r,t)};const s=(a,r,c)=>{const l=r*2,h=k(l,t);if(!a(c,h,r)&&!h){const u=W(r),o=V(r,e);s(a,u,c+1),s(a,o,c+1)}};this.traverseBuffer=a=>{if(i)throw new Error("BVHTraversalHelper: cannot start a traversal during an active traversal.");i=!0;try{s(a,0,0)}finally{i=!1}},this.traverse=a=>{this.traverseBuffer((r,c,l)=>{if(c){const h=l*2,f=e[l+6],u=t[h+14];return a(r,c,new Float32Array(n,l*4,6),f,u)}else{const h=kt(l,e);return a(r,c,new Float32Array(n,l*4,6),h)}})}}},Ui=new de,Le=new Float32Array(6);class Dn{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...Fr,...e},"maxLeafSize"in e&&(console.warn('BVH: "maxLeafSize" option has been deprecated. Use "targetLeafSize", instead.'),e={...e,targetLeafSize:e.maxLeafSize}),Pn(this,e)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(e,t,i,s){let a=1/0,r=1/0,c=1/0,l=-1/0,h=-1/0,f=-1/0;for(let u=e,o=e+t;u<o;u++){this.writePrimitiveBounds(u,Le,0);const[m,g,x,d,b,p]=Le;m<a&&(a=m),d>l&&(l=d),g<r&&(r=g),b>h&&(h=b),x<c&&(c=x),p>f&&(f=p)}return i[s+0]=a,i[s+1]=r,i[s+2]=c,i[s+3]=l,i[s+4]=h,i[s+5]=f,i}computePrimitiveBounds(e,t,i){const s=i.offset||0;for(let a=e,r=e+t;a<r;a++){this.writePrimitiveBounds(a,Le,0);const[c,l,h,f,u,o]=Le,m=(c+f)/2,g=(l+u)/2,x=(h+o)/2,d=(f-c)/2,b=(u-l)/2,p=(o-h)/2,v=(a-s)*6;i[v+0]=m,i[v+1]=d+(Math.abs(m)+d)*Dt,i[v+2]=g,i[v+3]=b+(Math.abs(g)+b)*Dt,i[v+4]=x,i[v+5]=p+(Math.abs(x)+p)*Dt}return i}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let i=0,s=t.length;i<s;i++)t[i]+=e;else{const i=this._roots;for(let s=0;s<i.length;s++){const a=i[s],r=new Uint32Array(a),c=new Uint16Array(a),l=a.byteLength/j;for(let h=0;h<l;h++){const f=O*h,u=2*f;k(u,c)&&(r[f+6]+=e)}}}}traverse(e,t=0){Zt.setBVH(this,t),Zt.traverse(e),Zt.reset()}refit(){const e=this._roots;for(let t=0,i=e.length;t<i;t++){const s=e[t],a=new Uint32Array(s),r=new Uint16Array(s),c=new Float32Array(s),l=s.byteLength/j;for(let h=l-1;h>=0;h--){const f=h*O,u=f*2;if(k(u,r)){const m=H(f,a),g=q(u,r);this.writePrimitiveRangeBounds(m,g,Le,0),c.set(Le,f)}else{const m=W(f),g=V(f,a);for(let x=0;x<3;x++){const d=c[m+x],b=c[m+x+3],p=c[g+x],v=c[g+x+3];c[f+x]=d<p?d:p,c[f+x+3]=b>v?b:v}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{z(0,new Float32Array(i),Ui),e.union(Ui)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:i,intersectsRange:s,intersectsPrimitive:a,scratchPrimitive:r,iterate:c}=e;if(s&&a){const u=s;s=(o,m,g,x,d)=>u(o,m,g,x,d)?!0:c(o,m,this,a,g,x,r)}else s||(a?s=(u,o,m,g)=>c(u,o,this,a,m,g,r):s=(u,o,m)=>m);let l=!1,h=0;const f=this._roots;for(let u=0,o=f.length;u<o;u++){const m=f[u];if(l=Fn(this,u,i,s,t,h),l)break;h+=m.byteLength/j}return l}bvhcast(e,t,i){let{intersectsRanges:s}=i;return Cn(this,e,t,s)}}function En(){return typeof SharedArrayBuffer<"u"}function Ot(n){return n.index?n.index.count:n.attributes.position.count}function Ut(n){return Ot(n)/3}function Cr(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function Bn(n,e){if(!n.index){const t=n.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=Cr(t,i);n.setIndex(new te(s,1));for(let a=0;a<t;a++)s[a]=a}}function zn(n,e,t){const i=Ot(n)/t,s=e||n.drawRange,a=s.start/t,r=(s.start+s.count)/t,c=Math.max(0,a),l=Math.min(i,r)-c;return{offset:Math.floor(c),count:Math.floor(l)}}function Nn(n,e){return n.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function Li(n,e,t){const i=zn(n,e,t),s=Nn(n,t);if(!s.length)return[i];const a=[],r=i.offset,c=i.offset+i.count,l=Ot(n)/t,h=[];for(const o of s){const{offset:m,count:g}=o,x=m,d=isFinite(g)?g:l-m,b=m+d;x<c&&b>r&&(h.push({pos:Math.max(r,x),isStart:!0}),h.push({pos:Math.min(c,b),isStart:!1}))}h.sort((o,m)=>o.pos!==m.pos?o.pos-m.pos:o.type==="end"?-1:1);let f=0,u=null;for(const o of h){const m=o.pos;f!==0&&m!==u&&a.push({offset:u,count:m-u}),f+=o.isStart?1:-1,u=m}return a}function kn(n,e){const t=n[n.length-1],i=t.offset+t.count>2**16,s=n.reduce((h,f)=>h+f.count,0),a=i?4:2,r=e?new SharedArrayBuffer(s*a):new ArrayBuffer(s*a),c=i?new Uint32Array(r):new Uint16Array(r);let l=0;for(let h=0;h<n.length;h++){const{offset:f,count:u}=n[h];for(let o=0;o<u;o++)c[l+o]=f+o;l+=u}return c}class On extends Dn{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(t.useSharedArrayBuffer&&!En())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...Fr,...t},t[Si]||this.init(t)}init(e){const{geometry:t,primitiveStride:i}=this;if(e.indirect){const s=Li(t,e.range,i),a=kn(s,e.useSharedArrayBuffer);this._indirectBuffer=a}else Bn(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new de))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Li(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class ve{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let a=0,r=e.length;a<r;a++){const l=e[a][t];i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let a=0,r=t.length;a<r;a++){const c=t[a],l=e.dot(c);i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}ve.prototype.setFromBox=(function(){const n=new C;return function(t,i){const s=i.min,a=i.max;let r=1/0,c=-1/0;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let f=0;f<=1;f++){n.x=s.x*l+a.x*(1-l),n.y=s.y*h+a.y*(1-h),n.z=s.z*f+a.z*(1-f);const u=t.dot(n);r=Math.min(u,r),c=Math.max(u,c)}this.min=r,this.max=c}})();const Un=(function(){const n=new C,e=new C,t=new C;return function(s,a,r){const c=s.start,l=n,h=a.start,f=e;t.subVectors(c,h),n.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const u=t.dot(f),o=f.dot(l),m=f.dot(f),g=t.dot(l),d=l.dot(l)*m-o*o;let b,p;d!==0?b=(u*o-g*m)/d:b=0,p=(u+b*o)/m,r.x=b,r.y=p}})(),Mi=(function(){const n=new Y,e=new C,t=new C;return function(s,a,r,c){Un(s,a,n);let l=n.x,h=n.y;if(l>=0&&l<=1&&h>=0&&h<=1){s.at(l,r),a.at(h,c);return}else if(l>=0&&l<=1){h<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,r);return}else if(h>=0&&h<=1){l<0?s.at(0,r):s.at(1,r),a.closestPointToPoint(r,!0,c);return}else{let f;l<0?f=s.start:f=s.end;let u;h<0?u=a.start:u=a.end;const o=e,m=t;if(s.closestPointToPoint(u,!0,e),a.closestPointToPoint(f,!0,t),o.distanceToSquared(u)<=m.distanceToSquared(f)){r.copy(o),c.copy(u);return}else{r.copy(f),c.copy(m);return}}}})(),Ln=(function(){const n=new C,e=new C,t=new br,i=new ge;return function(a,r){const{radius:c,center:l}=a,{a:h,b:f,c:u}=r;if(i.start=h,i.end=f,i.closestPointToPoint(l,!0,n).distanceTo(l)<=c||(i.start=h,i.end=u,i.closestPointToPoint(l,!0,n).distanceTo(l)<=c)||(i.start=f,i.end=u,i.closestPointToPoint(l,!0,n).distanceTo(l)<=c))return!0;const x=r.getPlane(t);if(Math.abs(x.distanceToPoint(l))<=c){const b=x.projectPoint(l,e);if(r.containsPoint(b))return!0}return!1}})(),Hn=["x","y","z"],pe=1e-15,Hi=pe*pe;function J(n){return Math.abs(n)<pe}class ce extends Ye{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new C),this.satBounds=new Array(4).fill().map(()=>new ve),this.points=[this.a,this.b,this.c],this.plane=new br,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new ge,this.needsUpdate=!0}intersectsSphere(e){return Ln(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,a=this.satAxes,r=this.satBounds,c=a[0],l=r[0];this.getNormal(c),l.setFromPoints(c,s);const h=a[1],f=r[1];h.subVectors(e,t),f.setFromPoints(h,s);const u=a[2],o=r[2];u.subVectors(t,i),o.setFromPoints(u,s);const m=a[3],g=r[3];m.subVectors(i,e),g.setFromPoints(m,s);const x=h.length(),d=u.length(),b=m.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,x<pe?d<pe||b<pe?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(i)):d<pe?b<pe?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):b<pe&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(i),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}ce.prototype.closestPointToSegment=(function(){const n=new C,e=new C,t=new ge;return function(s,a=null,r=null){this.needsUpdate&&this.update();const{start:c,end:l}=s,h=this.points;let f,u=1/0;const o=this.plane.distanceToPoint(c),m=this.plane.distanceToPoint(l);if(o*m<0&&this.plane.intersectLine(s,n)!==null&&this.containsPoint(n))return a&&a.copy(n),r&&r.copy(n),0;for(let g=0;g<3;g++){const x=(g+1)%3;t.start.copy(h[g]),t.end.copy(h[x]),Mi(t,s,n,e),f=n.distanceToSquared(e),f<u&&(u=f,a&&a.copy(n),r&&r.copy(e))}return this.closestPointToPoint(c,n),f=c.distanceToSquared(n),f<u&&(u=f,a&&a.copy(n),r&&r.copy(c)),this.closestPointToPoint(l,n),f=l.distanceToSquared(n),f<u&&(u=f,a&&a.copy(n),r&&r.copy(l)),Math.sqrt(u)}})();ce.prototype.intersectsTriangle=(function(){const n=new ce,e=new ve,t=new ve,i=new C,s=new C,a=new C,r=new C,c=new ge,l=new ge,h=new C,f=new Y,u=new Y;function o(v,y,T,A){const w=i;!v.isDegenerateIntoPoint&&!v.isDegenerateIntoSegment?w.copy(v.plane.normal):w.copy(y.plane.normal);const M=v.satBounds,I=v.satAxes;for(let S=1;S<4;S++){const R=M[S],F=I[S];if(e.setFromPoints(F,y.points),R.isSeparated(e)||(r.copy(w).cross(F),e.setFromPoints(r,v.points),t.setFromPoints(r,y.points),e.isSeparated(t)))return!1}const _=y.satBounds,P=y.satAxes;for(let S=1;S<4;S++){const R=_[S],F=P[S];if(e.setFromPoints(F,v.points),R.isSeparated(e)||(r.crossVectors(w,F),e.setFromPoints(r,v.points),t.setFromPoints(r,y.points),e.isSeparated(t)))return!1}return T&&(A||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),T.start.set(0,0,0),T.end.set(0,0,0)),!0}function m(v,y,T,A,w,M,I,_,P,S,R){let F=I/(I-_);S.x=A+(w-A)*F,R.start.subVectors(y,v).multiplyScalar(F).add(v),F=I/(I-P),S.y=A+(M-A)*F,R.end.subVectors(T,v).multiplyScalar(F).add(v)}function g(v,y,T,A,w,M,I,_,P,S,R){if(w>0)m(v.c,v.a,v.b,A,y,T,P,I,_,S,R);else if(M>0)m(v.b,v.a,v.c,T,y,A,_,I,P,S,R);else if(_*P>0||I!=0)m(v.a,v.b,v.c,y,T,A,I,_,P,S,R);else if(_!=0)m(v.b,v.a,v.c,T,y,A,_,I,P,S,R);else if(P!=0)m(v.c,v.a,v.b,A,y,T,P,I,_,S,R);else return!0;return!1}function x(v,y,T,A){const w=y.degenerateSegment,M=v.plane.distanceToPoint(w.start),I=v.plane.distanceToPoint(w.end);return J(M)?J(I)?o(v,y,T,A):(T&&(T.start.copy(w.start),T.end.copy(w.start)),v.containsPoint(w.start)):J(I)?(T&&(T.start.copy(w.end),T.end.copy(w.end)),v.containsPoint(w.end)):v.plane.intersectLine(w,i)!=null?(T&&(T.start.copy(i),T.end.copy(i)),v.containsPoint(i)):!1}function d(v,y,T){const A=y.a;return J(v.plane.distanceToPoint(A))&&v.containsPoint(A)?(T&&(T.start.copy(A),T.end.copy(A)),!0):!1}function b(v,y,T){const A=v.degenerateSegment,w=y.a;return A.closestPointToPoint(w,!0,i),w.distanceToSquared(i)<Hi?(T&&(T.start.copy(w),T.end.copy(w)),!0):!1}function p(v,y,T,A){if(v.isDegenerateIntoSegment)if(y.isDegenerateIntoSegment){const w=v.degenerateSegment,M=y.degenerateSegment,I=s,_=a;w.delta(I),M.delta(_);const P=i.subVectors(M.start,w.start),S=I.x*_.y-I.y*_.x;if(J(S))return!1;const R=(P.x*_.y-P.y*_.x)/S,F=-(I.x*P.y-I.y*P.x)/S;if(R<0||R>1||F<0||F>1)return!1;const D=w.start.z+I.z*R,E=M.start.z+_.z*F;return J(D-E)?(T&&(T.start.copy(w.start).addScaledVector(I,R),T.end.copy(w.start).addScaledVector(I,R)),!0):!1}else return y.isDegenerateIntoPoint?b(v,y,T):x(y,v,T,A);else{if(v.isDegenerateIntoPoint)return y.isDegenerateIntoPoint?y.a.distanceToSquared(v.a)<Hi?(T&&(T.start.copy(v.a),T.end.copy(v.a)),!0):!1:y.isDegenerateIntoSegment?b(y,v,T):d(y,v,T);if(y.isDegenerateIntoPoint)return d(v,y,T);if(y.isDegenerateIntoSegment)return x(v,y,T,A)}}return function(y,T=null,A=!1){this.needsUpdate&&this.update(),y.isExtendedTriangle?y.needsUpdate&&y.update():(n.copy(y),n.update(),y=n);const w=p(this,y,T,A);if(w!==void 0)return w;const M=this.plane,I=y.plane;let _=I.distanceToPoint(this.a),P=I.distanceToPoint(this.b),S=I.distanceToPoint(this.c);J(_)&&(_=0),J(P)&&(P=0),J(S)&&(S=0);const R=_*P,F=_*S;if(R>0&&F>0)return!1;let D=M.distanceToPoint(y.a),E=M.distanceToPoint(y.b),le=M.distanceToPoint(y.c);J(D)&&(D=0),J(E)&&(E=0),J(le)&&(le=0);const me=D*E,xe=D*le;if(me>0&&xe>0)return!1;s.copy(M.normal),a.copy(I.normal);const Ee=s.cross(a);let _e=0,Wt=Math.abs(Ee.x);const Ci=Math.abs(Ee.y);Ci>Wt&&(Wt=Ci,_e=1),Math.abs(Ee.z)>Wt&&(_e=2);const Be=Hn[_e],Gr=this.a[Be],$r=this.b[Be],Yr=this.c[Be],jr=y.a[Be],Xr=y.b[Be],Qr=y.c[Be];if(g(this,Gr,$r,Yr,R,F,_,P,S,f,c))return o(this,y,T,A);if(g(y,jr,Xr,Qr,me,xe,D,E,le,u,l))return o(this,y,T,A);if(f.y<f.x){const Vt=f.y;f.y=f.x,f.x=Vt,h.copy(c.start),c.start.copy(c.end),c.end.copy(h)}if(u.y<u.x){const Vt=u.y;u.y=u.x,u.x=Vt,h.copy(l.start),l.start.copy(l.end),l.end.copy(h)}return f.y<u.x||u.y<f.x?!1:(T&&(u.x>f.x?T.start.copy(l.start):T.start.copy(c.start),u.y<f.y?T.end.copy(l.end):T.end.copy(c.end)),!0)}})();ce.prototype.distanceToPoint=(function(){const n=new C;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}})();ce.prototype.distanceToTriangle=(function(){const n=new C,e=new C,t=["a","b","c"],i=new ge,s=new ge;return function(r,c=null,l=null){const h=c||l?i:null;if(this.intersectsTriangle(r,h,!0))return(c||l)&&(c&&h.getCenter(c),l&&h.getCenter(l)),0;let f=1/0;for(let u=0;u<3;u++){let o;const m=t[u],g=r[m];this.closestPointToPoint(g,n),o=g.distanceToSquared(n),o<f&&(f=o,c&&c.copy(n),l&&l.copy(g));const x=this[m];r.closestPointToPoint(x,n),o=x.distanceToSquared(n),o<f&&(f=o,c&&c.copy(x),l&&l.copy(n))}for(let u=0;u<3;u++){const o=t[u],m=t[(u+1)%3];i.set(this[o],this[m]);for(let g=0;g<3;g++){const x=t[g],d=t[(g+1)%3];s.set(r[x],r[d]),Mi(i,s,n,e);const b=n.distanceToSquared(e);b<f&&(f=b,c&&c.copy(n),l&&l.copy(e))}}return Math.sqrt(f)}})();class X{constructor(e,t,i){this.isOrientedBox=!0,this.min=new C,this.max=new C,this.matrix=new $,this.invMatrix=new $,this.points=new Array(8).fill().map(()=>new C),this.satAxes=new Array(3).fill().map(()=>new C),this.satBounds=new Array(3).fill().map(()=>new ve),this.alignedSatBounds=new Array(3).fill().map(()=>new ve),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}X.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let h=0;h<=1;h++)for(let f=0;f<=1;f++)for(let u=0;u<=1;u++){const o=1*h|2*f|4*u,m=s[o];m.x=h?i.x:t.x,m.y=f?i.y:t.y,m.z=u?i.z:t.z,m.applyMatrix4(e)}const a=this.satBounds,r=this.satAxes,c=s[0];for(let h=0;h<3;h++){const f=r[h],u=a[h],o=1<<h,m=s[o];f.subVectors(c,m),u.setFromPoints(f,s)}const l=this.alignedSatBounds;l[0].setFromPointsField(s,"x"),l[1].setFromPointsField(s,"y"),l[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();X.prototype.intersectsBox=(function(){const n=new ve;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,a=this.satBounds,r=this.satAxes,c=this.alignedSatBounds;if(n.min=i.x,n.max=s.x,c[0].isSeparated(n)||(n.min=i.y,n.max=s.y,c[1].isSeparated(n))||(n.min=i.z,n.max=s.z,c[2].isSeparated(n)))return!1;for(let l=0;l<3;l++){const h=r[l],f=a[l];if(n.setFromBox(h,t),f.isSeparated(n))return!1}return!0}})();X.prototype.intersectsTriangle=(function(){const n=new ce,e=new Array(3),t=new ve,i=new ve,s=new C;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(n.copy(r),n.update(),r=n);const c=this.satBounds,l=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let o=0;o<3;o++){const m=c[o],g=l[o];if(t.setFromPoints(g,e),m.isSeparated(t))return!1}const h=r.satBounds,f=r.satAxes,u=this.points;for(let o=0;o<3;o++){const m=h[o],g=f[o];if(t.setFromPoints(g,u),m.isSeparated(t))return!1}for(let o=0;o<3;o++){const m=l[o];for(let g=0;g<4;g++){const x=f[g];if(s.crossVectors(m,x),t.setFromPoints(s,e),i.setFromPoints(s,u),t.isSeparated(i))return!1}}return!0}})();X.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})();X.prototype.distanceToPoint=(function(){const n=new C;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}})();X.prototype.distanceToBox=(function(){const n=["x","y","z"],e=new Array(12).fill().map(()=>new ge),t=new Array(12).fill().map(()=>new ge),i=new C,s=new C;return function(r,c=0,l=null,h=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(l||h)&&(r.getCenter(s),this.closestPointToPoint(s,i),r.closestPointToPoint(i,s),l&&l.copy(i),h&&h.copy(s)),0;const f=c*c,u=r.min,o=r.max,m=this.points;let g=1/0;for(let d=0;d<8;d++){const b=m[d];s.copy(b).clamp(u,o);const p=b.distanceToSquared(s);if(p<g&&(g=p,l&&l.copy(b),h&&h.copy(s),p<f))return Math.sqrt(p)}let x=0;for(let d=0;d<3;d++)for(let b=0;b<=1;b++)for(let p=0;p<=1;p++){const v=(d+1)%3,y=(d+2)%3,T=b<<v|p<<y,A=1<<d|b<<v|p<<y,w=m[T],M=m[A];e[x].set(w,M);const _=n[d],P=n[v],S=n[y],R=t[x],F=R.start,D=R.end;F[_]=u[_],F[P]=b?u[P]:o[P],F[S]=p?u[S]:o[S],D[_]=o[_],D[P]=b?u[P]:o[P],D[S]=p?u[S]:o[S],x++}for(let d=0;d<=1;d++)for(let b=0;b<=1;b++)for(let p=0;p<=1;p++){s.x=d?o.x:u.x,s.y=b?o.y:u.y,s.z=p?o.z:u.z,this.closestPointToPoint(s,i);const v=s.distanceToSquared(i);if(v<g&&(g=v,l&&l.copy(i),h&&h.copy(s),v<f))return Math.sqrt(v)}for(let d=0;d<12;d++){const b=e[d];for(let p=0;p<12;p++){const v=t[p];Mi(b,v,i,s);const y=i.distanceToSquared(s);if(y<g&&(g=y,l&&l.copy(i),h&&h.copy(s),y<f))return Math.sqrt(y)}}return Math.sqrt(g)}})();class Wn extends Ai{constructor(){super(()=>new ce)}}const ie=new Wn,it=new C,Jt=new C;function Vn(n,e,t={},i=0,s=1/0){const a=i*i,r=s*s;let c=1/0,l=null;if(n.shapecast({boundsTraverseOrder:f=>(it.copy(e).clamp(f.min,f.max),it.distanceToSquared(e)),intersectsBounds:(f,u,o)=>o<c&&o<r,intersectsTriangle:(f,u)=>{f.closestPointToPoint(e,it);const o=e.distanceToSquared(it);return o<c&&(Jt.copy(it),c=o,l=u),o<a}}),c===1/0)return null;const h=Math.sqrt(c);return t.point?t.point.copy(Jt):t.point=Jt.clone(),t.distance=h,t.faceIndex=l,t}const mt=parseInt(Sr)>=169,qn=parseInt(Sr)<=161,Ae=new C,Me=new C,Ie=new C,pt=new Y,gt=new Y,vt=new Y,Wi=new C,Vi=new C,qi=new C,rt=new C;function Gn(n,e,t,i,s,a,r,c){let l;if(a===Tr?l=n.intersectTriangle(i,t,e,!0,s):l=n.intersectTriangle(e,t,i,a!==wr,s),l===null)return null;const h=n.origin.distanceTo(s);return h<r||h>c?null:{distance:h,point:s.clone()}}function Gi(n,e,t,i,s,a,r,c,l,h,f){Ae.fromBufferAttribute(e,a),Me.fromBufferAttribute(e,r),Ie.fromBufferAttribute(e,c);const u=Gn(n,Ae,Me,Ie,rt,l,h,f);if(u){if(i){pt.fromBufferAttribute(i,a),gt.fromBufferAttribute(i,r),vt.fromBufferAttribute(i,c),u.uv=new Y;const m=Ye.getInterpolation(rt,Ae,Me,Ie,pt,gt,vt,u.uv);mt||(u.uv=m)}if(s){pt.fromBufferAttribute(s,a),gt.fromBufferAttribute(s,r),vt.fromBufferAttribute(s,c),u.uv1=new Y;const m=Ye.getInterpolation(rt,Ae,Me,Ie,pt,gt,vt,u.uv1);mt||(u.uv1=m),qn&&(u.uv2=u.uv1)}if(t){Wi.fromBufferAttribute(t,a),Vi.fromBufferAttribute(t,r),qi.fromBufferAttribute(t,c),u.normal=new C;const m=Ye.getInterpolation(rt,Ae,Me,Ie,Wi,Vi,qi,u.normal);u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1),mt||(u.normal=m)}const o={a,b:r,c,normal:new C,materialIndex:0};if(Ye.getNormal(Ae,Me,Ie,o.normal),u.face=o,u.faceIndex=a,mt){const m=new C;Ye.getBarycoord(rt,Ae,Me,Ie,m),u.barycoord=m}}return u}function $i(n){return n&&n.isMaterial?n.side:n}function Lt(n,e,t,i,s,a,r){const c=i*3;let l=c+0,h=c+1,f=c+2;const{index:u,groups:o}=n;n.index&&(l=u.getX(l),h=u.getX(h),f=u.getX(f));const{position:m,normal:g,uv:x,uv1:d}=n.attributes;if(Array.isArray(e)){const b=i*3;for(let p=0,v=o.length;p<v;p++){const{start:y,count:T,materialIndex:A}=o[p];if(b>=y&&b<y+T){const w=$i(e[A]),M=Gi(t,m,g,x,d,l,h,f,w,a,r);if(M)if(M.faceIndex=i,M.face.materialIndex=A,s)s.push(M);else return M}}}else{const b=$i(e),p=Gi(t,m,g,x,d,l,h,f,b,a,r);if(p)if(p.faceIndex=i,p.face.materialIndex=0,s)s.push(p);else return p}return null}function U(n,e,t,i){const s=n.a,a=n.b,r=n.c;let c=e,l=e+1,h=e+2;t&&(c=t.getX(c),l=t.getX(l),h=t.getX(h)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(l),a.y=i.getY(l),a.z=i.getZ(l),r.x=i.getX(h),r.y=i.getY(h),r.z=i.getZ(h)}function $n(n,e,t,i,s,a,r,c){const{geometry:l,_indirectBuffer:h}=n;for(let f=i,u=i+s;f<u;f++)Lt(l,e,t,f,a,r,c)}function Yn(n,e,t,i,s,a,r){const{geometry:c,_indirectBuffer:l}=n;let h=1/0,f=null;for(let u=i,o=i+s;u<o;u++){let m;m=Lt(c,e,t,u,null,a,r),m&&m.distance<h&&(f=m,h=m.distance)}return f}function jn(n,e,t,i,s,a,r){const{geometry:c}=t,{index:l}=c,h=c.attributes.position;for(let f=n,u=e+n;f<u;f++){let o;if(o=f,U(r,o*3,l,h),r.needsUpdate=!0,i(r,o,s,a))return!0}return!1}function Xn(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,r,c,l,h=0;const f=n._roots;for(let o=0,m=f.length;o<m;o++)a=f[o],r=new Uint32Array(a),c=new Uint16Array(a),l=new Float32Array(a),u(0,h),h+=a.byteLength;function u(o,m,g=!1){const x=o*2;if(k(x,c)){const d=H(o,r),b=q(x,c);let p=1/0,v=1/0,y=1/0,T=-1/0,A=-1/0,w=-1/0;for(let M=3*d,I=3*(d+b);M<I;M++){let _=i[M];const P=s.getX(_),S=s.getY(_),R=s.getZ(_);P<p&&(p=P),P>T&&(T=P),S<v&&(v=S),S>A&&(A=S),R<y&&(y=R),R>w&&(w=R)}return l[o+0]!==p||l[o+1]!==v||l[o+2]!==y||l[o+3]!==T||l[o+4]!==A||l[o+5]!==w?(l[o+0]=p,l[o+1]=v,l[o+2]=y,l[o+3]=T,l[o+4]=A,l[o+5]=w,!0):!1}else{const d=W(o),b=V(o,r);let p=g,v=!1,y=!1;if(e){if(!p){const _=d/O+m/j,P=b/O+m/j;v=e.has(_),y=e.has(P),p=!v&&!y}}else v=!0,y=!0;const T=p||v,A=p||y;let w=!1;T&&(w=u(d,m,p));let M=!1;A&&(M=u(b,m,p));const I=w||M;if(I)for(let _=0;_<3;_++){const P=d+_,S=b+_,R=l[P],F=l[P+3],D=l[S],E=l[S+3];l[o+_]=R<D?R:D,l[o+_+3]=F>E?F:E}return I}}}function re(n,e,t,i,s){let a,r,c,l,h,f;const u=1/t.direction.x,o=1/t.direction.y,m=1/t.direction.z,g=t.origin.x,x=t.origin.y,d=t.origin.z;let b=e[n],p=e[n+3],v=e[n+1],y=e[n+3+1],T=e[n+2],A=e[n+3+2];return u>=0?(a=(b-g)*u,r=(p-g)*u):(a=(p-g)*u,r=(b-g)*u),o>=0?(c=(v-x)*o,l=(y-x)*o):(c=(y-x)*o,l=(v-x)*o),a>l||c>r||((c>a||isNaN(a))&&(a=c),(l<r||isNaN(r))&&(r=l),m>=0?(h=(T-d)*m,f=(A-d)*m):(h=(A-d)*m,f=(T-d)*m),a>f||h>r)?!1:((h>a||a!==a)&&(a=h),(f<r||r!==r)&&(r=f),a<=s&&r>=i)}function Qn(n,e,t,i,s,a,r,c){const{geometry:l,_indirectBuffer:h}=n;for(let f=i,u=i+s;f<u;f++){let o=h?h[f]:f;Lt(l,e,t,o,a,r,c)}}function Kn(n,e,t,i,s,a,r){const{geometry:c,_indirectBuffer:l}=n;let h=1/0,f=null;for(let u=i,o=i+s;u<o;u++){let m;m=Lt(c,e,t,l?l[u]:u,null,a,r),m&&m.distance<h&&(f=m,h=m.distance)}return f}function Zn(n,e,t,i,s,a,r){const{geometry:c}=t,{index:l}=c,h=c.attributes.position;for(let f=n,u=e+n;f<u;f++){let o;if(o=t.resolveTriangleIndex(f),U(r,o*3,l,h),r.needsUpdate=!0,i(r,o,s,a))return!0}return!1}function Jn(n,e,t,i,s,a,r){B.setBuffer(n._roots[e]),re(0,B.float32Array,i,a,r)&&hi(0,n,t,i,s,a,r),B.clearBuffer()}function hi(n,e,t,i,s,a,r){const{float32Array:c,uint16Array:l,uint32Array:h}=B,f=n*2;if(k(f,l)){const o=H(n,h),m=q(f,l);$n(e,t,i,o,m,s,a,r)}else{const o=W(n);re(o,c,i,a,r)&&hi(o,e,t,i,s,a,r);const m=V(n,h);re(m,c,i,a,r)&&hi(m,e,t,i,s,a,r)}}const es=["x","y","z"];function ts(n,e,t,i,s,a){B.setBuffer(n._roots[e]);let r=null;return re(0,B.float32Array,i,s,a)&&(r=di(0,n,t,i,s,a)),B.clearBuffer(),r}function di(n,e,t,i,s,a){const{float32Array:r,uint16Array:c,uint32Array:l}=B;let h=n*2;if(k(h,c)){const u=H(n,l),o=q(h,c);return Yn(e,t,i,u,o,s,a)}else{const u=kt(n,l),o=es[u],g=i.direction[o]>=0;let x,d;g?(x=W(n),d=V(n,l)):(x=V(n,l),d=W(n));const p=re(x,r,i,s,a)?di(x,e,t,i,s,a):null;if(p){const T=p.point[o];if(g?T<=r[d+u]:T>=r[d+u+3])return p}const y=re(d,r,i,s,a)?di(d,e,t,i,s,a):null;return p&&y?p.distance<=y.distance?p:y:p||y||null}}const xt=new de,He=new ce,We=new ce,nt=new $,Yi=new X,yt=new X;function is(n,e,t,i){B.setBuffer(n._roots[e]);const s=mi(0,n,t,i);return B.clearBuffer(),s}function mi(n,e,t,i,s=null){const{float32Array:a,uint16Array:r,uint32Array:c}=B;let l=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Yi.set(t.boundingBox.min,t.boundingBox.max,i),s=Yi),k(l,r)){const f=e.geometry,u=f.index,o=f.attributes.position,m=t.index,g=t.attributes.position,x=H(n,c),d=q(l,r);if(nt.copy(i).invert(),t.boundsTree)return z(n,a,yt),yt.matrix.copy(nt),yt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:p=>yt.intersectsBox(p),intersectsTriangle:p=>{p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let v=x*3,y=(d+x)*3;v<y;v+=3)if(U(We,v,u,o),We.needsUpdate=!0,p.intersectsTriangle(We))return!0;return!1}});{const b=Ut(t);for(let p=x*3,v=(d+x)*3;p<v;p+=3){U(He,p,u,o),He.a.applyMatrix4(nt),He.b.applyMatrix4(nt),He.c.applyMatrix4(nt),He.needsUpdate=!0;for(let y=0,T=b*3;y<T;y+=3)if(U(We,y,m,g),We.needsUpdate=!0,He.intersectsTriangle(We))return!0}}}else{const f=W(n),u=V(n,c);return z(f,a,xt),!!(s.intersectsBox(xt)&&mi(f,e,t,i,s)||(z(u,a,xt),s.intersectsBox(xt)&&mi(u,e,t,i,s)))}}const bt=new $,ei=new X,st=new X,rs=new C,ns=new C,ss=new C,as=new C;function os(n,e,t,i={},s={},a=0,r=1/0){e.boundingBox||e.computeBoundingBox(),ei.set(e.boundingBox.min,e.boundingBox.max,t),ei.needsUpdate=!0;const c=n.geometry,l=c.attributes.position,h=c.index,f=e.attributes.position,u=e.index,o=ie.getPrimitive(),m=ie.getPrimitive();let g=rs,x=ns,d=null,b=null;s&&(d=ss,b=as);let p=1/0,v=null,y=null;return bt.copy(t).invert(),st.matrix.copy(bt),n.shapecast({boundsTraverseOrder:T=>ei.distanceToBox(T),intersectsBounds:(T,A,w)=>w<p&&w<r?(A&&(st.min.copy(T.min),st.max.copy(T.max),st.needsUpdate=!0),!0):!1,intersectsRange:(T,A)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:M=>st.distanceToBox(M),intersectsBounds:(M,I,_)=>_<p&&_<r,intersectsRange:(M,I)=>{for(let _=M,P=M+I;_<P;_++){U(m,3*_,u,f),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let S=T,R=T+A;S<R;S++){U(o,3*S,h,l),o.needsUpdate=!0;const F=o.distanceToTriangle(m,g,d);if(F<p&&(x.copy(g),b&&b.copy(d),p=F,v=S,y=_),F<a)return!0}}}});{const w=Ut(e);for(let M=0,I=w;M<I;M++){U(m,3*M,u,f),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let _=T,P=T+A;_<P;_++){U(o,3*_,h,l),o.needsUpdate=!0;const S=o.distanceToTriangle(m,g,d);if(S<p&&(x.copy(g),b&&b.copy(d),p=S,v=_,y=M),S<a)return!0}}}}}),ie.releasePrimitive(o),ie.releasePrimitive(m),p===1/0?null:(i.point?i.point.copy(x):i.point=x.clone(),i.distance=p,i.faceIndex=v,s&&(s.point?s.point.copy(b):s.point=b.clone(),s.point.applyMatrix4(bt),x.applyMatrix4(bt),s.distance=x.sub(s.point).length(),s.faceIndex=y),i)}function cs(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,r,c,l,h=0;const f=n._roots;for(let o=0,m=f.length;o<m;o++)a=f[o],r=new Uint32Array(a),c=new Uint16Array(a),l=new Float32Array(a),u(0,h),h+=a.byteLength;function u(o,m,g=!1){const x=o*2;if(k(x,c)){const d=H(o,r),b=q(x,c);let p=1/0,v=1/0,y=1/0,T=-1/0,A=-1/0,w=-1/0;for(let M=d,I=d+b;M<I;M++){const _=3*n.resolveTriangleIndex(M);for(let P=0;P<3;P++){let S=_+P;S=i?i[S]:S;const R=s.getX(S),F=s.getY(S),D=s.getZ(S);R<p&&(p=R),R>T&&(T=R),F<v&&(v=F),F>A&&(A=F),D<y&&(y=D),D>w&&(w=D)}}return l[o+0]!==p||l[o+1]!==v||l[o+2]!==y||l[o+3]!==T||l[o+4]!==A||l[o+5]!==w?(l[o+0]=p,l[o+1]=v,l[o+2]=y,l[o+3]=T,l[o+4]=A,l[o+5]=w,!0):!1}else{const d=W(o),b=V(o,r);let p=g,v=!1,y=!1;if(e){if(!p){const _=d/O+m/j,P=b/O+m/j;v=e.has(_),y=e.has(P),p=!v&&!y}}else v=!0,y=!0;const T=p||v,A=p||y;let w=!1;T&&(w=u(d,m,p));let M=!1;A&&(M=u(b,m,p));const I=w||M;if(I)for(let _=0;_<3;_++){const P=d+_,S=b+_,R=l[P],F=l[P+3],D=l[S],E=l[S+3];l[o+_]=R<D?R:D,l[o+_+3]=F>E?F:E}return I}}}function ls(n,e,t,i,s,a,r){B.setBuffer(n._roots[e]),re(0,B.float32Array,i,a,r)&&pi(0,n,t,i,s,a,r),B.clearBuffer()}function pi(n,e,t,i,s,a,r){const{float32Array:c,uint16Array:l,uint32Array:h}=B,f=n*2;if(k(f,l)){const o=H(n,h),m=q(f,l);Qn(e,t,i,o,m,s,a,r)}else{const o=W(n);re(o,c,i,a,r)&&pi(o,e,t,i,s,a,r);const m=V(n,h);re(m,c,i,a,r)&&pi(m,e,t,i,s,a,r)}}const us=["x","y","z"];function fs(n,e,t,i,s,a){B.setBuffer(n._roots[e]);let r=null;return re(0,B.float32Array,i,s,a)&&(r=gi(0,n,t,i,s,a)),B.clearBuffer(),r}function gi(n,e,t,i,s,a){const{float32Array:r,uint16Array:c,uint32Array:l}=B;let h=n*2;if(k(h,c)){const u=H(n,l),o=q(h,c);return Kn(e,t,i,u,o,s,a)}else{const u=kt(n,l),o=us[u],g=i.direction[o]>=0;let x,d;g?(x=W(n),d=V(n,l)):(x=V(n,l),d=W(n));const p=re(x,r,i,s,a)?gi(x,e,t,i,s,a):null;if(p){const T=p.point[o];if(g?T<=r[d+u]:T>=r[d+u+3])return p}const y=re(d,r,i,s,a)?gi(d,e,t,i,s,a):null;return p&&y?p.distance<=y.distance?p:y:p||y||null}}const Tt=new de,Ve=new ce,qe=new ce,at=new $,ji=new X,wt=new X;function hs(n,e,t,i){B.setBuffer(n._roots[e]);const s=vi(0,n,t,i);return B.clearBuffer(),s}function vi(n,e,t,i,s=null){const{float32Array:a,uint16Array:r,uint32Array:c}=B;let l=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),ji.set(t.boundingBox.min,t.boundingBox.max,i),s=ji),k(l,r)){const f=e.geometry,u=f.index,o=f.attributes.position,m=t.index,g=t.attributes.position,x=H(n,c),d=q(l,r);if(at.copy(i).invert(),t.boundsTree)return z(n,a,wt),wt.matrix.copy(at),wt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:p=>wt.intersectsBox(p),intersectsTriangle:p=>{p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let v=x,y=d+x;v<y;v++)if(U(qe,3*e.resolveTriangleIndex(v),u,o),qe.needsUpdate=!0,p.intersectsTriangle(qe))return!0;return!1}});{const b=Ut(t);for(let p=x,v=d+x;p<v;p++){const y=e.resolveTriangleIndex(p);U(Ve,3*y,u,o),Ve.a.applyMatrix4(at),Ve.b.applyMatrix4(at),Ve.c.applyMatrix4(at),Ve.needsUpdate=!0;for(let T=0,A=b*3;T<A;T+=3)if(U(qe,T,m,g),qe.needsUpdate=!0,Ve.intersectsTriangle(qe))return!0}}}else{const f=W(n),u=V(n,c);return z(f,a,Tt),!!(s.intersectsBox(Tt)&&vi(f,e,t,i,s)||(z(u,a,Tt),s.intersectsBox(Tt)&&vi(u,e,t,i,s)))}}const St=new $,ti=new X,ot=new X,ds=new C,ms=new C,ps=new C,gs=new C;function vs(n,e,t,i={},s={},a=0,r=1/0){e.boundingBox||e.computeBoundingBox(),ti.set(e.boundingBox.min,e.boundingBox.max,t),ti.needsUpdate=!0;const c=n.geometry,l=c.attributes.position,h=c.index,f=e.attributes.position,u=e.index,o=ie.getPrimitive(),m=ie.getPrimitive();let g=ds,x=ms,d=null,b=null;s&&(d=ps,b=gs);let p=1/0,v=null,y=null;return St.copy(t).invert(),ot.matrix.copy(St),n.shapecast({boundsTraverseOrder:T=>ti.distanceToBox(T),intersectsBounds:(T,A,w)=>w<p&&w<r?(A&&(ot.min.copy(T.min),ot.max.copy(T.max),ot.needsUpdate=!0),!0):!1,intersectsRange:(T,A)=>{if(e.boundsTree){const w=e.boundsTree;return w.shapecast({boundsTraverseOrder:M=>ot.distanceToBox(M),intersectsBounds:(M,I,_)=>_<p&&_<r,intersectsRange:(M,I)=>{for(let _=M,P=M+I;_<P;_++){const S=w.resolveTriangleIndex(_);U(m,3*S,u,f),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=T,F=T+A;R<F;R++){const D=n.resolveTriangleIndex(R);U(o,3*D,h,l),o.needsUpdate=!0;const E=o.distanceToTriangle(m,g,d);if(E<p&&(x.copy(g),b&&b.copy(d),p=E,v=R,y=_),E<a)return!0}}}})}else{const w=Ut(e);for(let M=0,I=w;M<I;M++){U(m,3*M,u,f),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let _=T,P=T+A;_<P;_++){const S=n.resolveTriangleIndex(_);U(o,3*S,h,l),o.needsUpdate=!0;const R=o.distanceToTriangle(m,g,d);if(R<p&&(x.copy(g),b&&b.copy(d),p=R,v=_,y=M),R<a)return!0}}}}}),ie.releasePrimitive(o),ie.releasePrimitive(m),p===1/0?null:(i.point?i.point.copy(x):i.point=x.clone(),i.distance=p,i.faceIndex=v,s&&(s.point?s.point.copy(b):s.point=b.clone(),s.point.applyMatrix4(St),x.applyMatrix4(St),s.distance=x.sub(s.point).length(),s.faceIndex=y),i)}function Xi(n,e,t){return n===null?null:(n.point.applyMatrix4(e.matrixWorld),n.distance=n.point.distanceTo(t.ray.origin),n.object=e,n)}const _t=new X,At=new Kr,Qi=new C,Ki=new $,Zi=new C,ii=["getX","getY","getZ"];class zt extends On{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,a=e._indirectBuffer,r=i.getIndex(),c={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(c.roots=s.map(l=>l.slice()),c.index=r?r.array.slice():null,c.indirectBuffer=a?a.slice():null):(c.roots=s,c.index=r?r.array:null,c.indirectBuffer=a),c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:a,indirectBuffer:r}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),l(a));const c=new zt(t,{...i,[Si]:!0});if(c._roots=a,c._indirectBuffer=r||null,i.setIndex){const h=t.getIndex();if(h===null){const f=new te(e.index,1,!1);t.setIndex(f)}else h.array!==s&&(h.array.set(s),h.needsUpdate=!0)}return c;function l(h){for(let f=0;f<h.length;f++){const u=h[f],o=new Uint32Array(u),m=new Uint16Array(u);for(let g=0,x=u.byteLength/j;g<x;g++){const d=O*g,b=2*d;k(b,m)||(o[d+6]=o[d+6]/O-g)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use "targetLeafSize", instead.'),t={...t,targetLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,i){const s=this.geometry,a=this._indirectBuffer,r=s.attributes.position,c=s.index?s.index.array:null,h=(a?a[e]:e)*3;let f=h+0,u=h+1,o=h+2;c&&(f=c[f],u=c[u],o=c[o]);for(let m=0;m<3;m++){const g=r[ii[m]](f),x=r[ii[m]](u),d=r[ii[m]](o);let b=g;x<b&&(b=x),d<b&&(b=d);let p=g;x>p&&(p=x),d>p&&(p=d),t[i+m]=b,t[i+m+3]=p}return t}computePrimitiveBounds(e,t,i){const s=this.geometry,a=this._indirectBuffer,r=s.attributes.position,c=s.index?s.index.array:null,l=r.normalized;if(e<0||t+e-i.offset>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const h=r.array,f=r.offset||0;let u=3;r.isInterleavedBufferAttribute&&(u=r.data.stride);const o=["getX","getY","getZ"],m=i.offset;for(let g=e,x=e+t;g<x;g++){const b=(a?a[g]:g)*3,p=(g-m)*6;let v=b+0,y=b+1,T=b+2;c&&(v=c[v],y=c[y],T=c[T]),l||(v=v*u+f,y=y*u+f,T=T*u+f);for(let A=0;A<3;A++){let w,M,I;l?(w=r[o[A]](v),M=r[o[A]](y),I=r[o[A]](T)):(w=h[v+A],M=h[y+A],I=h[T+A]);let _=w;M<_&&(_=M),I<_&&(_=I);let P=w;M>P&&(P=M),I>P&&(P=I);const S=(P-_)/2,R=A*2;i[p+R+0]=_+S,i[p+R+1]=S+(Math.abs(_)+S)*Dt}}return i}raycastObject3D(e,t,i=[]){const{material:s}=e;if(s===void 0)return;Ki.copy(e.matrixWorld).invert(),At.copy(t.ray).applyMatrix4(Ki),Zi.setFromMatrixScale(e.matrixWorld),Qi.copy(At.direction).multiply(Zi);const a=Qi.length(),r=t.near/a,c=t.far/a;if(t.firstHitOnly===!0){let l=this.raycastFirst(At,s,r,c);l=Xi(l,e,t),l&&i.push(l)}else{const l=this.raycast(At,s,r,c);for(let h=0,f=l.length;h<f;h++){const u=Xi(l[h],e,t);u&&i.push(u)}}return i}refit(e=null){return(this.indirect?cs:Xn)(this,e)}raycast(e,t=oi,i=0,s=1/0){const a=this._roots,r=[],c=this.indirect?ls:Jn;for(let l=0,h=a.length;l<h;l++)c(this,l,t,e,r,i,s);return r}raycastFirst(e,t=oi,i=0,s=1/0){const a=this._roots;let r=null;const c=this.indirect?fs:ts;for(let l=0,h=a.length;l<h;l++){const f=c(this,l,t,e,i,s);f!=null&&(r==null||f.distance<r.distance)&&(r=f)}return r}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?hs:is;for(let r=0,c=s.length;r<c&&(i=a(this,r,e,t),!i);r++);return i}shapecast(e){const t=ie.getPrimitive(),i=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?Zn:jn});return ie.releasePrimitive(t),i}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const r=ie.getPrimitive(),c=this.geometry.index,l=this.geometry.attributes.position,h=this.indirect?g=>{const x=this.resolveTriangleIndex(g);U(r,x*3,c,l)}:g=>{U(r,g*3,c,l)},f=ie.getPrimitive(),u=e.geometry.index,o=e.geometry.attributes.position,m=e.indirect?g=>{const x=e.resolveTriangleIndex(g);U(f,x*3,u,o)}:g=>{U(f,g*3,u,o)};if(a){if(!(e instanceof zt))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const g=(x,d,b,p,v,y,T,A)=>{for(let w=b,M=b+p;w<M;w++){m(w),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let I=x,_=x+d;I<_;I++)if(h(I),r.needsUpdate=!0,a(r,f,I,w,v,y,T,A))return!0}return!1};if(s){const x=s;s=function(d,b,p,v,y,T,A,w){return x(d,b,p,v,y,T,A,w)?!0:g(d,b,p,v,y,T,A,w)}}else s=g}return super.bvhcast(e,t,{intersectsRanges:s})}intersectsBox(e,t){return _t.set(e.min,e.max,t),_t.needsUpdate=!0,this.shapecast({intersectsBounds:i=>_t.intersectsBox(i),intersectsTriangle:i=>_t.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},a=0,r=1/0){return(this.indirect?vs:os)(this,e,t,i,s,a,r)}closestPointToPoint(e,t={},i=0,s=1/0){return Vn(this,e,t,i,s)}}function xs(n){switch(n){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function ys(n){switch(n){case 1:return Et;case 2:return Ar;case 3:return L;case 4:return L}}function Ji(n){switch(n){case 1:return en;case 2:return _r;case 3:return li;case 4:return li}}class Dr extends Z{constructor(){super(),this.minFilter=N,this.magFilter=N,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const t=this.overrideItemSize,i=e.itemSize,s=e.count;if(t!==null){if(i*s%t!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");e.itemSize=t,e.count=s*i/t}const a=e.itemSize,r=e.count,c=e.normalized,l=e.array.constructor,h=l.BYTES_PER_ELEMENT;let f=this._forcedType,u=a;if(f===null)switch(l){case Float32Array:f=G;break;case Uint8Array:case Uint16Array:case Uint32Array:f=lt;break;case Int8Array:case Int16Array:case Int32Array:f=qt;break}let o,m,g,x,d=xs(a);switch(f){case G:g=1,m=ys(a),c&&h===1?(x=l,d+="8",l===Uint8Array?o=ci:(o=Di,d+="_SNORM")):(x=Float32Array,d+="32F",o=G);break;case qt:d+=h*8+"I",g=c?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,m=Ji(a),h===1?(x=Int8Array,o=Di):h===2?(x=Int16Array,o=Jr):(x=Int32Array,o=qt);break;case lt:d+=h*8+"UI",g=c?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,m=Ji(a),h===1?(x=Uint8Array,o=ci):h===2?(x=Uint16Array,o=Zr):(x=Uint32Array,o=lt);break}u===3&&(m===L||m===li)&&(u=4);const b=Math.ceil(Math.sqrt(r))||1,p=u*b*b,v=new x(p),y=e.normalized;e.normalized=!1;for(let T=0;T<r;T++){const A=u*T;v[A]=e.getX(T)/g,a>=2&&(v[A+1]=e.getY(T)/g),a>=3&&(v[A+2]=e.getZ(T)/g,u===4&&(v[A+3]=1)),a>=4&&(v[A+3]=e.getW(T)/g)}e.normalized=y,this.internalFormat=d,this.format=m,this.type=o,this.image.width=b,this.image.height=b,this.image.data=v,this.needsUpdate=!0,this.dispose(),e.itemSize=i,e.count=s}}class Er extends Dr{constructor(){super(),this._forcedType=lt}}class Br extends Dr{constructor(){super(),this._forcedType=G}}class zr{constructor(){this.index=new Er,this.position=new Br,this.bvhBounds=new Z,this.bvhContents=new Z,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:t}=e;if(Ts(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(t.attributes.position),e.indirect){const i=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==i.length)if(t.index)this._cachedIndexAttr=t.index.clone();else{const s=Cr(Ot(t));this._cachedIndexAttr=new te(s,1,!1)}bs(t,i,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(t.index)}dispose(){const{index:e,position:t,bvhBounds:i,bvhContents:s}=this;e&&e.dispose(),t&&t.dispose(),i&&i.dispose(),s&&s.dispose()}}function bs(n,e,t){const i=t.array,s=n.index?n.index.array:null;for(let a=0,r=e.length;a<r;a++){const c=3*a,l=3*e[a];for(let h=0;h<3;h++)i[c+h]=s?s[l+h]:l+h}}function Ts(n,e,t){const i=n._roots;if(i.length!==1)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const s=i[0],a=new Uint16Array(s),r=new Uint32Array(s),c=new Float32Array(s),l=s.byteLength/j,h=2*Math.ceil(Math.sqrt(l/2)),f=new Float32Array(4*h*h),u=Math.ceil(Math.sqrt(l)),o=new Uint32Array(2*u*u);for(let m=0;m<l;m++){const g=m*j/4,x=g*2,d=g;for(let b=0;b<3;b++)f[8*m+0+b]=c[d+0+b],f[8*m+4+b]=c[d+3+b];if(k(x,a)){const b=q(x,a),p=H(g,r),v=Tn|b;o[m*2+0]=v,o[m*2+1]=p}else{const b=r[g+6],p=kt(g,r);o[m*2+0]=p,o[m*2+1]=b}}e.image.data=f,e.image.width=h,e.image.height=h,e.format=L,e.type=G,e.internalFormat="RGBA32F",e.minFilter=N,e.magFilter=N,e.generateMipmaps=!1,e.needsUpdate=!0,e.dispose(),t.image.data=o,t.image.width=u,t.image.height=u,t.format=_r,t.type=lt,t.internalFormat="RG32UI",t.minFilter=N,t.magFilter=N,t.generateMipmaps=!1,t.needsUpdate=!0,t.dispose()}const Nr=`
2
2
 
3
3
  // A stack of uint32 indices can can store the indices for
4
4
  // a perfectly balanced tree with a depth up to 31. Lower stack
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMaskStore-pE1AIt3I.js","assets/titleFrameBudget-DsM0V482.js","assets/sceneTrack-DlAH5s74.js","assets/api-Dnl2uaKO.js","assets/i18n-C9zFX25m.js","assets/index-CKtv7gGE.js","assets/timeline3dExport-Uo0S0CR0.js","assets/timeline3d-DrFaMPPB.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/frameSink-CSRqCnwI.js","assets/titleFrames-C8kvflgT.js","assets/titleArt-CnC0A7x7.js","assets/textAnimators-B9vO_hbP.js","assets/lottieLayer-Cv8ub9f6.js","assets/rigTrack-DMyqb0pb.js","assets/rotoMatte-7b7Ow64f.js","assets/store-CpqHUcA2.js","assets/windowFrames-DhhJLIs-.js","assets/gpuExport-oA2mUsdm.js","assets/glTransitionSources.generated-q0H-ZbnZ.js","assets/timelineComp-i-zdaoB2.js","assets/gpuCompose-B5bgbHdQ.js","assets/motionBlur-uAm030t9.js","assets/distortGL-vhnBRB59.js","assets/id3-arvEpAg7.js","assets/output-p-Q7qous.js","assets/clientExport-pkLbOmEF.js","assets/distortFrames-D_v-aSVO.js","assets/engine-Co-ivzlQ.js","assets/store-Cug4GGcP.js","assets/conversion-4rhF3xRJ.js","assets/pendingMatte-BWBIWajI.js","assets/timelineOps-DSSaDsU2.js","assets/cameraTracker-DHdF8Zqx.js","assets/clientJobs-CuuUyhEy.js","assets/personHq-Ca351o06.js","assets/matteQuality-9X-jgJrH.js","assets/surfacePin-CzpUj1Cw.js","assets/sceneTrack-CA21MCOP.js","assets/surfaceLight-C7YI9SV8.js","assets/clientJobs-CcsLDqFM.js"])))=>i.map(i=>d[i]);
2
- import{_ as w,b_ as I,iF as O}from"./titleFrameBudget-DsM0V482.js";import{FrameSink as R,SKIPPED_FRAME as F}from"./frameSink-CSRqCnwI.js";class $ extends R{want;next=new Map;last=new Map;out={};constructor(c){super({put:async()=>{throw Error("a pick sink keeps its frames")}}),this.want=new Map;for(const[u,a]of Object.entries(c))for(const[s,r]of Object.entries(a||{}))this.want.set(`${u}
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMaskStore-RmW40Pcn.js","assets/titleFrameBudget-BW-N1-cw.js","assets/sceneTrack-DyVxpl7i.js","assets/api-DJC95K48.js","assets/i18n-C9zFX25m.js","assets/index-CKtv7gGE.js","assets/timeline3dExport-BO--SpAn.js","assets/timeline3d-D0Ws4lcp.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/frameSink-DWkHUnvV.js","assets/titleFrames-BHFaInux.js","assets/titleArt-BSu80bfN.js","assets/textAnimators-CeMuG34D.js","assets/lottieLayer-Dp_vGTy8.js","assets/rigTrack-B9r9wrdV.js","assets/rotoMatte-DisQplSv.js","assets/store-xR02oY0m.js","assets/windowFrames-BP2oDn-n.js","assets/gpuExport-Dlf6YjLs.js","assets/glTransitionSources.generated-BJuEUz3E.js","assets/timelineComp-D8PHGHgQ.js","assets/gpuCompose-Fi0sIUI9.js","assets/motionBlur-uAm030t9.js","assets/distortGL-waTJhiOf.js","assets/id3-arvEpAg7.js","assets/output-p-Q7qous.js","assets/clientExport-DyqpYM6h.js","assets/distortFrames-D-DK2HlN.js","assets/engine-B2YPWQZ2.js","assets/store-Cug4GGcP.js","assets/conversion-4rhF3xRJ.js","assets/pendingMatte-Taa0BlLI.js","assets/timelineOps-CEGk2t4h.js","assets/cameraTracker-DFjnZ7tw.js","assets/clientJobs-CuuUyhEy.js","assets/personHq-Cyq9HWnW.js","assets/matteQuality-9X-jgJrH.js","assets/surfacePin-i-X1Dz68.js","assets/sceneTrack-BKknn180.js","assets/surfaceLight-DBfJxggM.js","assets/clientJobs-BqkjV5Ld.js"])))=>i.map(i=>d[i]);
2
+ import{_ as w,b_ as I,iF as O}from"./titleFrameBudget-BW-N1-cw.js";import{FrameSink as R,SKIPPED_FRAME as F}from"./frameSink-DWkHUnvV.js";class $ extends R{want;next=new Map;last=new Map;out={};constructor(c){super({put:async()=>{throw Error("a pick sink keeps its frames")}}),this.want=new Map;for(const[u,a]of Object.entries(c))for(const[s,r]of Object.entries(a||{}))this.want.set(`${u}
3
3
  ${s}`,new Set(r));this.wants=(u,a,s)=>{const r=this.want.get(`${u}
4
4
  ${a}`);return!!r&&(s===void 0||r.has(s))}}async push(c,u,a){const s=`${c}
5
- ${u}`,r=this.next.get(s)??0;if(this.next.set(s,r+1),a===F)return;const n=a==="="?this.last.get(s):a;n!==void 0&&(this.last.set(s,n),this.want.get(s)?.has(r)&&(((this.out[c]??={})[u]??={})[r]=n))}picked(){return this.out}}const b=(o,c)=>Object.keys(o[c]||{}).length>0,D={async frames({clips:o,format:c,camera:u=null,want:a}){const{unpackMasks:s}=await w(async()=>{const{unpackMasks:e}=await import("./rotoMaskStore-pE1AIt3I.js");return{unpackMasks:e}},__vite__mapDeps([0,1,2,3,4,5])),r=await s(o);o=r.clips;const n=new $(a),_={},k=I(c).fps,l=n.wants,p=async(e,m,h)=>{for(const y of m){n.wants=(E,v,d)=>E===e&&v===y&&l(E,v,d);try{await h()}catch(E){_[y]=String(E?.message||E).slice(0,200)}finally{n.wants=l}}},t=e=>Object.keys(a[e]||{});if(b(a,"modelFrames")){const{render3DFrames:e}=await w(async()=>{const{render3DFrames:m}=await import("./timeline3dExport-Uo0S0CR0.js");return{render3DFrames:m}},__vite__mapDeps([6,1,7,8,9,3,4,5,10,11]));await p("modelFrames",t("modelFrames"),()=>e(o,c,n,void 0,u))}if(b(a,"titleFrames")){const{renderTitleFrames:e}=await w(async()=>{const{renderTitleFrames:h}=await import("./titleFrames-C8kvflgT.js");return{renderTitleFrames:h}},__vite__mapDeps([12,1,13,14,15,16,4,5,3,11])),m=[...o,...O(o)];await p("titleFrames",t("titleFrames"),()=>e(m,c,n,void 0,u))}if(b(a,"matteFrames")){const e=await w(()=>import("./rotoMatte-7b7Ow64f.js").then(h=>h.r),__vite__mapDeps([17,1,3,4,5,18])),m=[...o,...e.maskedCopies(o)];await p("matteFrames",t("matteFrames"),()=>e.renderMatteFrames(m,k,n))}if(b(a,"windowFrames")){const e=await w(()=>import("./windowFrames-DhhJLIs-.js"),__vite__mapDeps([19,1,17,3,4,5,18]));await p("windowFrames",t("windowFrames"),()=>e.renderWindowFrames(o,k,n))}return{frames:n.picked(),failed:_,missingMasks:r.missing}},async gpuExport({clips:o,format:c,tracks:u={},camera:a=null,encode:s=null,range:r,only:n,name:_="film.mp4",softwareEncoder:k=!1}){const{unpackMasks:l}=await w(async()=>{const{unpackMasks:i}=await import("./rotoMaskStore-pE1AIt3I.js");return{unpackMasks:i}},__vite__mapDeps([0,1,2,3,4,5])),p=await l(o);if(p.missing)throw Object.assign(new Error(`${p.missing} stored Roto mask(s) / track(s) could not be read`),{name:"MissingMasks"});o=p.clips;const t=await w(()=>import("./gpuExport-oA2mUsdm.js"),__vite__mapDeps([20,1,21,3,4,5,22,23,24,25,26,27]));if(k){if(n!=="video"||!await t.canEncodeH264(c))throw Object.assign(new Error("no H.264 encoder in this browser"),{name:"NoEncoder"})}else if(!await t.gpuExportSupported(c,s))throw Object.assign(new Error("no hardware video encoder in this browser"),{name:"NoEncoder"});const{softwareRetry:e}=await w(async()=>{const{softwareRetry:i}=await import("./clientExport-pkLbOmEF.js");return{softwareRetry:i}},__vite__mapDeps([28,1,22])),m=i=>{try{window.__clipooxProgress?.(i)}catch{}};let h=k;const y=`/__clipoox/out/${encodeURIComponent(_)}`,E=()=>new WritableStream({async write(i){const g=await fetch(`${y}?at=${i.position}`,{method:"PATCH",body:i.data});if(!g.ok)throw new Error(`the film could not be handed over (${g.status})`)}}),v=i=>t.exportOnGpu(o,{format:c,encode:s,tracks:u,camera:a,onProgress:m,software:i,liveMotion:!0,range:r,only:n,sink:E()}),d=i=>{const g=i instanceof Error?`${i.name}: ${i.message}`:String(i);return new Error(`${t.gpuExportStage()||"start"}${r?` (frames ${r.from}–${r.to})`:""}: ${g}`)},f=await v(k).catch(i=>{if(!e(i,t.gpuExportStage(),s))throw d(i);return h=!0,v(!0).catch(g=>{throw d(g)})});let P="";try{const i=document.createElement("canvas").getContext("webgl2"),g=i?.getExtension("WEBGL_debug_renderer_info");P=String(g&&i?i.getParameter(g.UNMASKED_RENDERER_WEBGL):"").slice(0,120)}catch{}return{ms:f.ms,software:h,gpu:P}},async distort({clips:o,format:c,tracks:u={}}){const{unpackMasks:a}=await w(async()=>{const{unpackMasks:t}=await import("./rotoMaskStore-pE1AIt3I.js");return{unpackMasks:t}},__vite__mapDeps([0,1,2,3,4,5])),s=await a(o);if(s.missing)throw Object.assign(new Error(`${s.missing} stored Roto mask(s) / track(s) could not be read`),{name:"MissingMasks"});let r=0;const n=async t=>{const e=`chunk-${r++}.json`,m=await fetch(`/__clipoox/chunk/${e}`,{method:"POST",body:JSON.stringify(t)});if(!m.ok)throw new Error(`the frames could not be handed over (${m.status})`);return e},{FrameSink:_}=await w(async()=>{const{FrameSink:t}=await import("./frameSink-CSRqCnwI.js");return{FrameSink:t}},__vite__mapDeps([11,1])),{distortForServer:k}=await w(async()=>{const{distortForServer:t}=await import("./distortFrames-D_v-aSVO.js");return{distortForServer:t}},__vite__mapDeps([29,1,25,26])),l=new _({put:n,inlineLimit:0}),p=await k(s.clips,c,l,void 0,u);return{clips:p.clips,tracks:p.tracks,frames:await l.finish()}},async upscale({url:o,kind:c,scale:u=2,model:a="photo",name:s="upscaled.bin"}){const r=await w(()=>import("./engine-Co-ivzlQ.js"),__vite__mapDeps([30,1,31,26,27,32])),n=t=>{try{window.__clipooxProgress?.(t.fraction)}catch{}},_=c==="video"?await r.upscaleVideo(o,{model:a,onProgress:n}):await r.upscaleImage(o,{scale:u,model:a,onProgress:n}),k=`/__clipoox/out/${encodeURIComponent(s)}`,l=new Uint8Array(await _.blob.arrayBuffer()),p=8<<20;for(let t=0;t<l.length;t+=p){const e=await fetch(`${k}?at=${t}`,{method:"PATCH",body:l.subarray(t,Math.min(l.length,t+p))});if(!e.ok)throw new Error(`the file could not be handed over (${e.status})`)}return{width:_.width,height:_.height,duration:_.duration??null,type:_.blob.type,bytes:l.length,backend:_.backend,seconds:_.seconds,soundDropped:!!_.soundDropped}},async runClientJobs({clips:o,format:c,tracks:u={},camera:a=null,only:s}){const[{useStore:r},{unpackMasks:n,packMasks:_},{runPendingMattes:k},{runSurfacePins:l},{runPendingClientJobs:p}]=await Promise.all([w(()=>import("./store-CpqHUcA2.js").then(d=>d.d),__vite__mapDeps([18,1,5])),w(()=>import("./rotoMaskStore-pE1AIt3I.js"),__vite__mapDeps([0,1,2,3,4,5])),w(()=>import("./pendingMatte-BWBIWajI.js"),__vite__mapDeps([33,1,34,2,35,14,22,3,4,5,18,16,36,37,38])),w(()=>import("./surfacePin-CzpUj1Cw.js"),__vite__mapDeps([39,1,40,2,4,5,35,14,38,41,18])),w(()=>import("./clientJobs-CcsLDqFM.js"),__vite__mapDeps([42,1,5,18,4,3,36]))]),t=await n(o);r.setState({clips:t.clips,timelineFormat:c,timelineTracks:u,timelineCamera:a??void 0});const e=d=>!s?.length||s.includes(d),m=[],h=d=>{try{window.__clipooxProgress?.(d)}catch{}};if(h(.05),e("person-matte")||e("object-matte")||e("person-matte-hq")){const d=await k();for(const f of d)m.push({kind:"person-matte",clipId:f.clipId,ok:f.ok,message:f.message})}if(h(.4),e("surface-track")){const d=await l();for(const f of d)m.push({kind:"surface-track",clipId:f.clipId,ok:f.ok,message:f.message})}h(.7);const y=await p({only:s});for(const d of y)m.push({kind:d.kind,clipId:d.clipId,ok:d.ok,message:d.error||"done"});h(.95);const E=r.getState(),v=await _(E.clips);return h(1),{clips:v,timelineTracks:E.timelineTracks,timelineCamera:E.timelineCamera??null,results:m}}};window.__layerWorker=D;
5
+ ${u}`,r=this.next.get(s)??0;if(this.next.set(s,r+1),a===F)return;const n=a==="="?this.last.get(s):a;n!==void 0&&(this.last.set(s,n),this.want.get(s)?.has(r)&&(((this.out[c]??={})[u]??={})[r]=n))}picked(){return this.out}}const b=(o,c)=>Object.keys(o[c]||{}).length>0,D={async frames({clips:o,format:c,camera:u=null,want:a}){const{unpackMasks:s}=await w(async()=>{const{unpackMasks:e}=await import("./rotoMaskStore-RmW40Pcn.js");return{unpackMasks:e}},__vite__mapDeps([0,1,2,3,4,5])),r=await s(o);o=r.clips;const n=new $(a),_={},k=I(c).fps,l=n.wants,p=async(e,m,h)=>{for(const y of m){n.wants=(E,v,d)=>E===e&&v===y&&l(E,v,d);try{await h()}catch(E){_[y]=String(E?.message||E).slice(0,200)}finally{n.wants=l}}},t=e=>Object.keys(a[e]||{});if(b(a,"modelFrames")){const{render3DFrames:e}=await w(async()=>{const{render3DFrames:m}=await import("./timeline3dExport-BO--SpAn.js");return{render3DFrames:m}},__vite__mapDeps([6,1,7,8,9,3,4,5,10,11]));await p("modelFrames",t("modelFrames"),()=>e(o,c,n,void 0,u))}if(b(a,"titleFrames")){const{renderTitleFrames:e}=await w(async()=>{const{renderTitleFrames:h}=await import("./titleFrames-BHFaInux.js");return{renderTitleFrames:h}},__vite__mapDeps([12,1,13,14,15,16,4,5,3,11])),m=[...o,...O(o)];await p("titleFrames",t("titleFrames"),()=>e(m,c,n,void 0,u))}if(b(a,"matteFrames")){const e=await w(()=>import("./rotoMatte-DisQplSv.js").then(h=>h.r),__vite__mapDeps([17,1,3,4,5,18])),m=[...o,...e.maskedCopies(o)];await p("matteFrames",t("matteFrames"),()=>e.renderMatteFrames(m,k,n))}if(b(a,"windowFrames")){const e=await w(()=>import("./windowFrames-BP2oDn-n.js"),__vite__mapDeps([19,1,17,3,4,5,18]));await p("windowFrames",t("windowFrames"),()=>e.renderWindowFrames(o,k,n))}return{frames:n.picked(),failed:_,missingMasks:r.missing}},async gpuExport({clips:o,format:c,tracks:u={},camera:a=null,encode:s=null,range:r,only:n,name:_="film.mp4",softwareEncoder:k=!1}){const{unpackMasks:l}=await w(async()=>{const{unpackMasks:i}=await import("./rotoMaskStore-RmW40Pcn.js");return{unpackMasks:i}},__vite__mapDeps([0,1,2,3,4,5])),p=await l(o);if(p.missing)throw Object.assign(new Error(`${p.missing} stored Roto mask(s) / track(s) could not be read`),{name:"MissingMasks"});o=p.clips;const t=await w(()=>import("./gpuExport-Dlf6YjLs.js"),__vite__mapDeps([20,1,21,3,4,5,22,23,24,25,26,27]));if(k){if(n!=="video"||!await t.canEncodeH264(c))throw Object.assign(new Error("no H.264 encoder in this browser"),{name:"NoEncoder"})}else if(!await t.gpuExportSupported(c,s))throw Object.assign(new Error("no hardware video encoder in this browser"),{name:"NoEncoder"});const{softwareRetry:e}=await w(async()=>{const{softwareRetry:i}=await import("./clientExport-DyqpYM6h.js");return{softwareRetry:i}},__vite__mapDeps([28,1,22])),m=i=>{try{window.__clipooxProgress?.(i)}catch{}};let h=k;const y=`/__clipoox/out/${encodeURIComponent(_)}`,E=()=>new WritableStream({async write(i){const g=await fetch(`${y}?at=${i.position}`,{method:"PATCH",body:i.data});if(!g.ok)throw new Error(`the film could not be handed over (${g.status})`)}}),v=i=>t.exportOnGpu(o,{format:c,encode:s,tracks:u,camera:a,onProgress:m,software:i,liveMotion:!0,range:r,only:n,sink:E()}),d=i=>{const g=i instanceof Error?`${i.name}: ${i.message}`:String(i);return new Error(`${t.gpuExportStage()||"start"}${r?` (frames ${r.from}–${r.to})`:""}: ${g}`)},f=await v(k).catch(i=>{if(!e(i,t.gpuExportStage(),s))throw d(i);return h=!0,v(!0).catch(g=>{throw d(g)})});let P="";try{const i=document.createElement("canvas").getContext("webgl2"),g=i?.getExtension("WEBGL_debug_renderer_info");P=String(g&&i?i.getParameter(g.UNMASKED_RENDERER_WEBGL):"").slice(0,120)}catch{}return{ms:f.ms,software:h,gpu:P}},async distort({clips:o,format:c,tracks:u={}}){const{unpackMasks:a}=await w(async()=>{const{unpackMasks:t}=await import("./rotoMaskStore-RmW40Pcn.js");return{unpackMasks:t}},__vite__mapDeps([0,1,2,3,4,5])),s=await a(o);if(s.missing)throw Object.assign(new Error(`${s.missing} stored Roto mask(s) / track(s) could not be read`),{name:"MissingMasks"});let r=0;const n=async t=>{const e=`chunk-${r++}.json`,m=await fetch(`/__clipoox/chunk/${e}`,{method:"POST",body:JSON.stringify(t)});if(!m.ok)throw new Error(`the frames could not be handed over (${m.status})`);return e},{FrameSink:_}=await w(async()=>{const{FrameSink:t}=await import("./frameSink-DWkHUnvV.js");return{FrameSink:t}},__vite__mapDeps([11,1])),{distortForServer:k}=await w(async()=>{const{distortForServer:t}=await import("./distortFrames-D-DK2HlN.js");return{distortForServer:t}},__vite__mapDeps([29,1,25,26])),l=new _({put:n,inlineLimit:0}),p=await k(s.clips,c,l,void 0,u);return{clips:p.clips,tracks:p.tracks,frames:await l.finish()}},async upscale({url:o,kind:c,scale:u=2,model:a="photo",name:s="upscaled.bin"}){const r=await w(()=>import("./engine-B2YPWQZ2.js"),__vite__mapDeps([30,1,31,26,27,32])),n=t=>{try{window.__clipooxProgress?.(t.fraction)}catch{}},_=c==="video"?await r.upscaleVideo(o,{model:a,onProgress:n}):await r.upscaleImage(o,{scale:u,model:a,onProgress:n}),k=`/__clipoox/out/${encodeURIComponent(s)}`,l=new Uint8Array(await _.blob.arrayBuffer()),p=8<<20;for(let t=0;t<l.length;t+=p){const e=await fetch(`${k}?at=${t}`,{method:"PATCH",body:l.subarray(t,Math.min(l.length,t+p))});if(!e.ok)throw new Error(`the file could not be handed over (${e.status})`)}return{width:_.width,height:_.height,duration:_.duration??null,type:_.blob.type,bytes:l.length,backend:_.backend,seconds:_.seconds,soundDropped:!!_.soundDropped}},async runClientJobs({clips:o,format:c,tracks:u={},camera:a=null,only:s}){const[{useStore:r},{unpackMasks:n,packMasks:_},{runPendingMattes:k},{runSurfacePins:l},{runPendingClientJobs:p}]=await Promise.all([w(()=>import("./store-xR02oY0m.js").then(d=>d.d),__vite__mapDeps([18,1,5])),w(()=>import("./rotoMaskStore-RmW40Pcn.js"),__vite__mapDeps([0,1,2,3,4,5])),w(()=>import("./pendingMatte-Taa0BlLI.js"),__vite__mapDeps([33,1,34,2,35,14,22,3,4,5,18,16,36,37,38])),w(()=>import("./surfacePin-i-X1Dz68.js"),__vite__mapDeps([39,1,40,2,4,5,35,14,38,41,18])),w(()=>import("./clientJobs-BqkjV5Ld.js"),__vite__mapDeps([42,1,5,18,4,3,36]))]),t=await n(o);r.setState({clips:t.clips,timelineFormat:c,timelineTracks:u,timelineCamera:a??void 0});const e=d=>!s?.length||s.includes(d),m=[],h=d=>{try{window.__clipooxProgress?.(d)}catch{}};if(h(.05),e("person-matte")||e("object-matte")||e("person-matte-hq")){const d=await k();for(const f of d)m.push({kind:"person-matte",clipId:f.clipId,ok:f.ok,message:f.message})}if(h(.4),e("surface-track")){const d=await l();for(const f of d)m.push({kind:"surface-track",clipId:f.clipId,ok:f.ok,message:f.message})}h(.7);const y=await p({only:s});for(const d of y)m.push({kind:d.kind,clipId:d.clipId,ok:d.ok,message:d.error||"done"});h(.95);const E=r.getState(),v=await _(E.clips);return h(1),{clips:v,timelineTracks:E.timelineTracks,timelineCamera:E.timelineCamera??null,results:m}}};window.__layerWorker=D;
@@ -0,0 +1 @@
1
+ import{d6 as f}from"./remote-kxNNhmis.js";import{eM as h,e9 as k,eN as q,eO as v}from"./remote-kxNNhmis.js";import{e as l}from"./skin-CXvqtCZI.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-DJC95K48.js";import"./titleFrameBudget-BW-N1-cw.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-xR02oY0m.js";import"./rotoMaskStore-RmW40Pcn.js";import"./sceneTrack-DyVxpl7i.js";import"./timelineOps-CEGk2t4h.js";import"./cameraTracker-DFjnZ7tw.js";import"./textAnimators-CeMuG34D.js";import"./timelineComp-D8PHGHgQ.js";import"./rigTrack-B9r9wrdV.js";import"./clientJobs-CuuUyhEy.js";async function P(o,m,s,n=2e4){let i;for(const e=Date.now()+n;!i&&Date.now()<e;){const r=o.getStage().items.find(t=>t.id===m);if(!r||r.rig!==s)return!1;i=o.engine()?.objects?.children.find(t=>t.userData.id===m)?.children[0],i||await new Promise(t=>setTimeout(t,150))}if(!i)return!1;const p=f(s,{positions:l(i).positions});let a=!1;return o.setStage(e=>({...e,items:e.items.map(r=>r.id===m&&r.rig===s?(a=!0,{...r,rig:p}):r)})),a}export{P as fitLibraryFingers,h as libraryModelFields,k as libraryModelItem,q as libraryRig,v as wantsFingers};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DxdDhmLR.js","assets/index-CKtv7gGE.js","assets/opentype.module-DcKU8U04.js","assets/gltfLoader-U0Eebg7v.js","assets/three.module-Bx43vjkH.js","assets/lottie_light_canvas-DX9Wf-DS.js"])))=>i.map(i=>d[i]);
2
- import{ht as Dt,jp as Bt,jq as Nt,jr as pn,js as Ft,jt as mn,ju as gn,N as yn,jv as wn,jw as bn,jx as Mn,_ as U,jy as _n,hs as kn,jz as Sn,jA as An,jB as En,jC as ft,jD as xn,fL as tt,gk as Tn,fN as nt,gl as vn,fl as V,ge as ct,gm as On,ct as Ce,jE as Ln,g9 as rt,jF as Pn,ga as Gt,gn as jn,jG as $n,jH as Cn,jI as Rn,jJ as In,jK as Dn,jL as Bn,jM as Nn,jN as Ht,jO as Fn,jP as Gn,jQ as Hn,bt as zn,bD as Wn,jR as qn,jS as fe,jT as Un,jU as Kn,jV as Vn,jW as Jn,jX as Yn,jY as ce,jZ as Re,j_ as ht,j$ as Xn,k0 as Zn,bz as Qn,k1 as er,k2 as ut,k3 as tr,k4 as nr,gc as rr,cD as sr,f8 as or,gb as zt,b$ as ar,gN as ir,dX as oe,ih as lr,eB as fr,f6 as cr,cw as we,dY as Ie,dZ as dt,k5 as hr,k6 as W,hr as ur,k7 as dr}from"./titleFrameBudget-DsM0V482.js";import{g as pr,l as mr,r as gr}from"./rigTrack-DMyqb0pb.js";import{t as le}from"./i18n-C9zFX25m.js";import{bK as yr,ap as wr,s as br}from"./api-Dnl2uaKO.js";function De(e){if(typeof e!="string")return null;const t=(o,a=!1)=>o.split(",").map(i=>i.trim()).filter(Boolean).map(i=>{const[l,f]=i.split(/\s+as\s+/);return a?f?`${f}:${l}`:l:f?`${l}:${f}`:l}).join(",");let n=e.replace(/^import\s*\{([^}]*)\}\s*from\s*['"]three['"];?/m,(o,a)=>`const {${t(a)}}=THREE;`);if(n=n.replace(/^import\s*\{([^}]*)\}\s*from\s*['"]\.\.\/utils\/([A-Za-z]+)\.js['"];?/mg,(o,a,i)=>`const {${t(a)}}=__deps.${i};`),/^\s*import\s/m.test(n))return null;const r=/^export\s*\{([^}]*)\};?[ \t]*$/m,s=r.exec(n);return!s||(n=n.replace(r,`return {${t(s[1],!0)}};`),/^export\s/m.test(n))?null:'"use strict";'+n}const Wt=`async(THREE,items,LOADERS,flip)=>{
2
+ import{ht as Dt,jp as Bt,jq as Nt,jr as pn,js as Ft,jt as mn,ju as gn,N as yn,jv as wn,jw as bn,jx as Mn,_ as U,jy as _n,hs as kn,jz as Sn,jA as An,jB as En,jC as ft,jD as xn,fL as tt,gk as Tn,fN as nt,gl as vn,fl as V,ge as ct,gm as On,ct as Ce,jE as Ln,g9 as rt,jF as Pn,ga as Gt,gn as jn,jG as $n,jH as Cn,jI as Rn,jJ as In,jK as Dn,jL as Bn,jM as Nn,jN as Ht,jO as Fn,jP as Gn,jQ as Hn,bt as zn,bD as Wn,jR as qn,jS as fe,jT as Un,jU as Kn,jV as Vn,jW as Jn,jX as Yn,jY as ce,jZ as Re,j_ as ht,j$ as Xn,k0 as Zn,bz as Qn,k1 as er,k2 as ut,k3 as tr,k4 as nr,gc as rr,cD as sr,f8 as or,gb as zt,b$ as ar,gN as ir,dX as oe,ih as lr,eB as fr,f6 as cr,cw as we,dY as Ie,dZ as dt,k5 as hr,k6 as W,hr as ur,k7 as dr}from"./titleFrameBudget-BW-N1-cw.js";import{g as pr,l as mr,r as gr}from"./rigTrack-B9r9wrdV.js";import{t as le}from"./i18n-C9zFX25m.js";import{bK as yr,ap as wr,s as br}from"./api-DJC95K48.js";function De(e){if(typeof e!="string")return null;const t=(o,a=!1)=>o.split(",").map(i=>i.trim()).filter(Boolean).map(i=>{const[l,f]=i.split(/\s+as\s+/);return a?f?`${f}:${l}`:l:f?`${l}:${f}`:l}).join(",");let n=e.replace(/^import\s*\{([^}]*)\}\s*from\s*['"]three['"];?/m,(o,a)=>`const {${t(a)}}=THREE;`);if(n=n.replace(/^import\s*\{([^}]*)\}\s*from\s*['"]\.\.\/utils\/([A-Za-z]+)\.js['"];?/mg,(o,a,i)=>`const {${t(a)}}=__deps.${i};`),/^\s*import\s/m.test(n))return null;const r=/^export\s*\{([^}]*)\};?[ \t]*$/m,s=r.exec(n);return!s||(n=n.replace(r,`return {${t(s[1],!0)}};`),/^export\s/m.test(n))?null:'"use strict";'+n}const Wt=`async(THREE,items,LOADERS,flip)=>{
3
3
  const out=new Map()
4
4
  const bmp=(data)=>createImageBitmap(new Blob([data]),flip?{imageOrientation:'flipY',premultiplyAlpha:'none'}:{})
5
5
  for(const it of items){