clipoox-render 0.4.7 → 0.4.8

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 (142) hide show
  1. package/package.json +2 -2
  2. package/scripts/render-local.mjs +2367 -1534
  3. package/shared/photocraft/LICENSE.txt +206 -0
  4. package/shared/photocraft/clipoox_photo.js +396 -0
  5. package/shared/photocraft/clipoox_photo_bg.wasm +0 -0
  6. package/web/assets/{FxEmbed-B-D-tbgP.js → FxEmbed-adbxHEBi.js} +1 -1
  7. package/web/assets/ImageStudio-CMxiT1jp.js +3 -0
  8. package/web/assets/ImageStudio-De_DCTrz.css +1 -0
  9. package/web/assets/{MotionEmbed-eB-zRpv9.js → MotionEmbed-CDUIyjk0.js} +1 -1
  10. package/web/assets/{PluginStore-D6UvvVXA.js → PluginStore-By_pdOOg.js} +2 -2
  11. package/web/assets/ShotComposer-DcwWZ-eP.css +1 -0
  12. package/web/assets/ShotComposer-XIbJ4nNm.js +287 -0
  13. package/web/assets/{TemplateEmbed-DZNaQAJ-.js → TemplateEmbed-a01nKECT.js} +1 -1
  14. package/web/assets/{TimelinePlugins-zhB9Uqav.js → TimelinePlugins-CqLMVjuh.js} +4 -4
  15. package/web/assets/TimelineShotFx-QmkyCg31.js +2 -0
  16. package/web/assets/{TransitionEmbed-r_B0toRr.js → TransitionEmbed-Cbwlxfl2.js} +1 -1
  17. package/web/assets/{Whiteboard-f6owS-ne.js → Whiteboard-ChYqIr3v.js} +1 -1
  18. package/web/assets/{aerial-DIj143Yz.js → aerial-CZeCeacv.js} +2 -2
  19. package/web/assets/{agentTools-CoNs1wCQ.js → agentTools-DW2ETnxE.js} +2 -2
  20. package/web/assets/{aiInbetween-ZFNHEXdI.js → aiInbetween-De98iM4m.js} +2 -2
  21. package/web/assets/analyzerRun-D5-g-Vxe.js +1 -0
  22. package/web/assets/{analyzerSandbox-C2rd6s8U.js → analyzerSandbox-E3CdovIk.js} +1 -1
  23. package/web/assets/{api-DJC95K48.js → api-CZoVJ9Fy.js} +87 -87
  24. package/web/assets/auraTrack-ClhHuqlf.js +1 -0
  25. package/web/assets/{breakthrough-DiHiElqL.js → breakthrough-DTpiUIZd.js} +2 -2
  26. package/web/assets/{cameraPresets-DfKERP1j.js → cameraPresets-DD0WmxiI.js} +1 -1
  27. package/web/assets/{cameraTracker-DFjnZ7tw.js → cameraTracker-Df9jWmz6.js} +2 -2
  28. package/web/assets/{captionLayout-CAuhUiW9.js → captionLayout-eiu9QPJu.js} +1 -1
  29. package/web/assets/{clientExport-DyqpYM6h.js → clientExport-BXegTdNc.js} +1 -1
  30. package/web/assets/{clientJobs-BqkjV5Ld.js → clientJobs-eB-lNyin.js} +2 -2
  31. package/web/assets/clipoox_photo_bg-BQ0aVNY0.wasm +0 -0
  32. package/web/assets/depthEstimate-CfwX-tXP.js +1 -0
  33. package/web/assets/{directorTools-CLn4xt6m.js → directorTools-ABbI8m0e.js} +1 -1
  34. package/web/assets/distortFrames-DMnZ8OYh.js +2 -0
  35. package/web/assets/distortGL-DQu0Df2c.js +18 -0
  36. package/web/assets/{domino-BDKBYrNQ.js → domino-trmDBvfH.js} +1 -1
  37. package/web/assets/{editTools-BqKU-ucA.js → editTools-DEFo9Ahv.js} +1 -1
  38. package/web/assets/{engine-B2YPWQZ2.js → engine-Y-GotDIy.js} +1 -1
  39. package/web/assets/exportGlb-BeLpJKJT.js +2 -0
  40. package/web/assets/{faceTracker-DsmLlUZ1.js → faceTracker-BeSFnLM8.js} +1 -1
  41. package/web/assets/{fightDirector-BIVLGhAP.js → fightDirector-Dfz3vu5-.js} +1 -1
  42. package/web/assets/{fightDrama-B_jDQ-cW.js → fightDrama-CNVn69s0.js} +2 -2
  43. package/web/assets/{focusTool-mWs2Eikj.js → focusTool-Dd2UDkiO.js} +1 -1
  44. package/web/assets/{frameSink-DWkHUnvV.js → frameSink-Rj02YES5.js} +3 -3
  45. package/web/assets/{glTransitionSources.generated-BJuEUz3E.js → glTransitionSources.generated-Cs8lVRqs.js} +438 -2
  46. package/web/assets/{gpuCompose-Fi0sIUI9.js → gpuCompose-DkkKH1Ab.js} +1 -1
  47. package/web/assets/gpuExport-DwrXpVGF.js +199 -0
  48. package/web/assets/{handMatte-CvFkZKTL.js → handMatte-B5sUeqKi.js} +1 -1
  49. package/web/assets/{handTracker-CF1hqh09.js → handTracker-CQV-D7va.js} +2 -2
  50. package/web/assets/i18n-ClNt3LKg.js +3 -0
  51. package/web/assets/{index-EegUntr6.js → index-D2u6mD-8.js} +1 -1
  52. package/web/assets/layer-worker-DP0N05Ua.js +5 -0
  53. package/web/assets/library-cb43ZEmy.js +1 -0
  54. package/web/assets/{lottieLayer-Dp_vGTy8.js → lottieLayer-DEw0c3to.js} +4 -4
  55. package/web/assets/main-C_XcvNyC.js +311 -0
  56. package/web/assets/{main-B_MAOvi6.css → main-DlzdW5C4.css} +1 -1
  57. package/web/assets/{mapBake-CEmw-e9Y.js → mapBake-BUWz0cSx.js} +1 -1
  58. package/web/assets/{maskTrack-CADMBJDf.js → maskTrack-GYpJyKFw.js} +1 -1
  59. package/web/assets/matteFixRun-BCVsuSxf.js +1 -0
  60. package/web/assets/{objectLocate-DWsEG8eK.js → objectLocate-CjIlo_u0.js} +1 -1
  61. package/web/assets/{objectSegmenter-oGv8YQbI.js → objectSegmenter-C4T9qgUL.js} +1 -1
  62. package/web/assets/{objectTrack.worker-B6RVfsq4.js → objectTrack.worker-BVvsDmR0.js} +1161 -770
  63. package/web/assets/{pathTracer-DxqKEvC7.js → pathTracer-DgL1_83l.js} +2 -2
  64. package/web/assets/{pendingMatte-Taa0BlLI.js → pendingMatte-DPTe6xoZ.js} +2 -2
  65. package/web/assets/peopleMatte-C1hruEM6.js +1 -0
  66. package/web/assets/{personAi-BebqXrqD.js → personAi-Cjg9KKeH.js} +2 -2
  67. package/web/assets/{personHq-Cyq9HWnW.js → personHq-CBP8v_cw.js} +2 -2
  68. package/web/assets/photo.worker-DK_ulTzR.js +1 -0
  69. package/web/assets/photoRun-lZ2BdSEk.js +2 -0
  70. package/web/assets/photoTools-DmUh69Qk.js +1 -0
  71. package/web/assets/plateCamera-DLqlXhMp.js +1 -0
  72. package/web/assets/{plateCameraMatch-1_DuZ0LV.js → plateCameraMatch-4VUlUMi-.js} +2 -2
  73. package/web/assets/{plateFollow-Ztxwpq5v.js → plateFollow-D2rjnmZA.js} +2 -2
  74. package/web/assets/plateMatte-0tTG7oeO.js +2 -0
  75. package/web/assets/{pluginAutomation-D73Az7HS.js → pluginAutomation-ClFdpcCR.js} +1 -1
  76. package/web/assets/popTools-B38V4wub.js +1 -0
  77. package/web/assets/{poseTracker-b1h08oRY.js → poseTracker-qtuytI-L.js} +1 -1
  78. package/web/assets/{productTools-CoJ_Fnfc.js → productTools-DlC5vWjx.js} +2 -2
  79. package/web/assets/remote-CpkPQOQH.js +989 -0
  80. package/web/assets/{rigTrack-B9r9wrdV.js → rigTrack-BbKqZGs7.js} +1 -1
  81. package/web/assets/{rotoMaskStore-RmW40Pcn.js → rotoMaskStore-BZBJLcCp.js} +1 -1
  82. package/web/assets/{rotoMatte-DisQplSv.js → rotoMatte-BI-vjjrv.js} +1 -1
  83. package/web/assets/rotoscope-DuNcCxQy.js +1 -0
  84. package/web/assets/{sceneTrack-DyVxpl7i.js → sceneTrack-CO4fTjft.js} +1 -1
  85. package/web/assets/sceneTrack-_n6WKKQv.js +1 -0
  86. package/web/assets/{sceneTrack.worker-DKVLLgf9.js → sceneTrack.worker-f2d-WOzw.js} +1207 -816
  87. package/web/assets/{shot-worker-DM5PUQ6g.js → shot-worker-BSmfIXHO.js} +1 -1
  88. package/web/assets/{shotFxAgent-CsW0MAiG.js → shotFxAgent-L2GG88W3.js} +1 -1
  89. package/web/assets/{skin-CXvqtCZI.js → skin-CirUiqcr.js} +1 -1
  90. package/web/assets/{spark.module-B341moK0.js → spark.module-3Q8DniuL.js} +1 -1
  91. package/web/assets/{spellDuel-KCMEFHLA.js → spellDuel-2CDLbiLQ.js} +2 -2
  92. package/web/assets/{store-xR02oY0m.js → store-D3Y663py.js} +1 -1
  93. package/web/assets/{surfaceLight-DBfJxggM.js → surfaceLight--HQj7xhO.js} +1 -1
  94. package/web/assets/{surfacePin-i-X1Dz68.js → surfacePin-BCmgw-40.js} +2 -2
  95. package/web/assets/{textAnimators-CeMuG34D.js → textAnimators-C4eMnVRD.js} +1 -1
  96. package/web/assets/{thumb-DzNl15MN.js → thumb-M9B_goj-.js} +1 -1
  97. package/web/assets/{timeline3d-D0Ws4lcp.js → timeline3d-BcW68fQr.js} +2 -2
  98. package/web/assets/{timeline3dExport-BO--SpAn.js → timeline3dExport-DgnorHLm.js} +1 -1
  99. package/web/assets/timelineComp-Ciu9JCWJ.js +1 -0
  100. package/web/assets/timelineOps-f1WsVbgS.js +526 -0
  101. package/web/assets/{timelineProps-Cm_Irino.js → timelineProps-CE1R11Hx.js} +1 -1
  102. package/web/assets/{timelineText-DjPW2-dd.js → timelineText-Cppd4KB7.js} +1 -1
  103. package/web/assets/{titleArt-BSu80bfN.js → titleArt-D0YI5xT2.js} +3 -3
  104. package/web/assets/{titleFrameBudget-BW-N1-cw.js → titleFrameBudget-h4nOQ5u9.js} +1382 -991
  105. package/web/assets/titleFrames-DnCzi_AI.js +1 -0
  106. package/web/assets/{tool-Bboi3NDg.js → tool-tp6gat1J.js} +1 -1
  107. package/web/assets/{tools-kgYkohv8.js → tools-C07G9KUM.js} +1 -1
  108. package/web/assets/{toonTools-Bxz_HSqT.js → toonTools-Cazx2CL7.js} +2 -2
  109. package/web/assets/{trackAnchor-DK9cEMCf.js → trackAnchor-DoqFDcJB.js} +1 -1
  110. package/web/assets/{userFonts-DSkZHfmh.js → userFonts-BlVEJfDk.js} +1 -1
  111. package/web/assets/{vfxAlpha-B0rNpKZN.js → vfxAlpha-Bp6VgIGN.js} +1 -1
  112. package/web/assets/vfxBackground-BFq44Srn.js +2 -0
  113. package/web/assets/{videoExport-Cu0vw-dL.js → videoExport-Cz02XKtX.js} +1 -1
  114. package/web/assets/{views-CmulxRJP.js → views-CNF3Afse.js} +1 -1
  115. package/web/assets/{weaponDuel-DuuMMfzY.js → weaponDuel-ChqBQo_b.js} +1 -1
  116. package/web/assets/{windowFrames-BP2oDn-n.js → windowFrames-dBMXwGek.js} +1 -1
  117. package/web/layer-worker.html +3 -3
  118. package/web/shot-worker.html +24 -24
  119. package/web/assets/ShotComposer-CoxtWL6A.js +0 -287
  120. package/web/assets/ShotComposer-deLi4grZ.css +0 -1
  121. package/web/assets/TimelineShotFx-muTN__gf.js +0 -2
  122. package/web/assets/analyzerRun-BswbLsRF.js +0 -1
  123. package/web/assets/auraTrack-C9diszRB.js +0 -1
  124. package/web/assets/depthEstimate-HrGq0Ffx.js +0 -1
  125. package/web/assets/distortFrames-D-DK2HlN.js +0 -2
  126. package/web/assets/distortGL-waTJhiOf.js +0 -12
  127. package/web/assets/exportGlb-Cm07JQXt.js +0 -2
  128. package/web/assets/gpuExport-Dlf6YjLs.js +0 -198
  129. package/web/assets/i18n-C9zFX25m.js +0 -3
  130. package/web/assets/layer-worker-Drj-NLVj.js +0 -5
  131. package/web/assets/library-BhH-xsMR.js +0 -1
  132. package/web/assets/main-DAk1Tv1E.js +0 -309
  133. package/web/assets/matteFixRun-BHD3Qnta.js +0 -1
  134. package/web/assets/plateCamera-D1A1iEpf.js +0 -1
  135. package/web/assets/plateMatte-CWT1ymGj.js +0 -2
  136. package/web/assets/remote-kxNNhmis.js +0 -974
  137. package/web/assets/rotoscope-Z8bn-jRs.js +0 -1
  138. package/web/assets/sceneTrack-BKknn180.js +0 -1
  139. package/web/assets/timelineComp-D8PHGHgQ.js +0 -1
  140. package/web/assets/timelineOps-CEGk2t4h.js +0 -525
  141. package/web/assets/titleFrames-BHFaInux.js +0 -1
  142. package/web/assets/vfxBackground-CBTDl1xA.js +0 -2
@@ -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-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)=>{
2
+ import{hw as Dt,jw as Bt,jx as Nt,jy as pn,jz as Ft,jA as mn,jB as gn,N as yn,jC as wn,jD as bn,jE as Mn,_ as U,jF as _n,hv as kn,jG as Sn,jH as An,jI as En,jJ as ft,jK as xn,fO as tt,gn as Tn,fQ as nt,go as vn,fo as V,gh as ct,gp as On,cw as Ce,jL as Ln,gc as rt,jM as Pn,gd as Gt,gq as jn,jN as $n,jO as Cn,jP as Rn,jQ as In,jR as Dn,jS as Bn,jT as Nn,jU as Ht,jV as Fn,jW as Gn,jX as Hn,bt as zn,bD as Wn,jY as qn,jZ as fe,j_ as Un,j$ as Kn,k0 as Vn,k1 as Jn,k2 as Yn,k3 as ce,k4 as Re,k5 as ht,k6 as Xn,k7 as Zn,bz as Qn,k8 as er,k9 as ut,ka as tr,kb as nr,gf as rr,cG as sr,fb as or,ge as zt,b$ as ar,gQ as ir,d_ as oe,il as lr,eE as fr,f9 as cr,cz as we,d$ as Ie,e0 as dt,kc as hr,kd as W,hu as ur,ke as dr}from"./titleFrameBudget-h4nOQ5u9.js";import{g as pr,l as mr,r as gr}from"./rigTrack-BbKqZGs7.js";import{t as le}from"./i18n-ClNt3LKg.js";import{bO as yr,aq as wr,a as br}from"./api-CZoVJ9Fy.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){
@@ -57,7 +57,7 @@ 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
57
57
  if(obj.userData.__clip!==clip){mixer.stopAllAction();action.play();obj.userData.__clip=clip}
58
58
  const d=clip.duration||1,s=(t||0)*(o.speed??1);action.time=o.loop===false?Math.min(d,Math.max(0,s)):((s%d)+d)%d;mixer.update(0);return true}
59
59
  return {asset,texture,sprite,sequence,lut,play}
60
- }`,kr=e=>typeof e=="string"?{uri:e}:e&&typeof e=="object"?e:null,N=1024*1024,I=Object.freeze({packageBytes:200*N,inflatedBytes:400*N,files:400,glbBytes:20*N,triangles:3e5,vertices:2e6,glbImages:16,glbJsonBytes:4*N,nodes:1e4,depth:64,imagePx:4096,textureBytes:8*N,spriteFrames:256,seqFrames:240,seqFrameW:1920,seqFrameH:1080,seqBytes:40*N,lutBytes:12*N,lutSize:65,blendBytes:150*N,videoBytes:40*N,itemBytes:60*N,itemPixelBytes:256*N,uses:24}),Sr=Object.freeze(["model","texture","sprite","sequence","lut","blend","video"]),Ar=Object.freeze(["KHR_materials_emissive_strength","KHR_materials_transmission","KHR_materials_clearcoat","KHR_materials_ior","KHR_materials_specular","KHR_materials_sheen","KHR_materials_volume","KHR_materials_unlit","KHR_materials_iridescence","KHR_materials_anisotropy","KHR_materials_dispersion","KHR_texture_transform","KHR_mesh_quantization","EXT_texture_webp","KHR_lights_punctual"]),Er=["KHR_draco_mesh_compression","EXT_meshopt_compression","KHR_meshopt_compression","KHR_texture_basisu","EXT_mesh_gpu_instancing"],xr=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,Tr=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}\.(png|webp)$/i,vr={glb:"model",png:"texture",webp:"texture",jpg:"texture",jpeg:"texture",cube:"lut",blend:"blend",webm:"video"},F=e=>!!e&&typeof e=="object"&&!Array.isArray(e),D=(e,t=[],n="")=>Object.assign(new Error(n||e),{code:e,args:t.map(String),plugin:!0}),T=(e,t,n=[])=>D("asset",[e,t,...n],`assets/${e}: ${t}${n.length?` (${n.join(", ")})`:""}`),qt=e=>String(e).split(".").pop().toLowerCase();function Or(e){return e.length>24&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10?"image/png":e.length>3&&e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e.length>16&&e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?"image/webp":null}const Be=(e,t)=>e[t]<<8|e[t+1],pt=(e,t)=>(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];function Ut(e){const t=Or(e);if(!t)return null;if(t==="image/png")return String.fromCharCode(e[12],e[13],e[14],e[15])!=="IHDR"?null:{type:t,width:pt(e,16),height:pt(e,20)};if(t==="image/jpeg"){let r=2;for(;r+9<e.length;){if(e[r]!==255){r++;continue}const s=e[r+1];if(s===255){r++;continue}if(s===216||s===1||s>=208&&s<=215){r+=2;continue}const o=Be(e,r+2);if(o<2)return null;if(s>=192&&s<=207&&s!==196&&s!==200&&s!==204)return{type:t,width:Be(e,r+7),height:Be(e,r+5)};r+=2+o}return null}const n=String.fromCharCode(e[12],e[13],e[14],e[15]);if(n==="VP8 "&&e.length>=30)return e[23]!==157||e[24]!==1||e[25]!==42?null:{type:t,width:(e[26]|e[27]<<8)&16383,height:(e[28]|e[29]<<8)&16383};if(n==="VP8L"&&e.length>=25){if(e[20]!==47)return null;const r=e[21]|e[22]<<8|e[23]<<16|e[24]<<24;return{type:t,width:(r&16383)+1,height:(r>>>14&16383)+1}}return n==="VP8X"&&e.length>=30?{type:t,width:1+(e[24]|e[25]<<8|e[26]<<16),height:1+(e[27]|e[28]<<8|e[29]<<16)}:null}const Lr={png:"image/png",webp:"image/webp",jpg:"image/jpeg",jpeg:"image/jpeg"};function mt(e,t,{maxW:n=I.imagePx,maxH:r=I.imagePx,maxBytes:s=I.textureBytes}={}){if(t.length>s)throw T(e,"too_large",[Math.round(s/N)]);const o=Ut(t),a=Lr[qt(e)];if(!o||!a)throw T(e,"not_image");if(o.type!==a)throw T(e,"magic",[o.type.slice(6)]);if(!(o.width>0&&o.height>0))throw T(e,"not_image");if(o.width>n||o.height>r)throw T(e,"image_size",[`${o.width}×${o.height}`,`${n}×${r}`]);return o}const K=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,gt={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},yt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Ye(e,t=0){if(t>40)return"deep";if(Array.isArray(e)){for(const n of e){const r=n&&typeof n=="object"?Ye(n,t+1):null;if(r)return r}return null}if(!F(e))return null;for(const[n,r]of Object.entries(e)){if(n==="__proto__"||n==="constructor"||n==="prototype")return"key";if(n==="uri")return typeof r=="string"?r.slice(0,60):"uri";if(r&&typeof r=="object"){const s=Ye(r,t+1);if(s)return s}}return null}const q=(e,t)=>Number.isInteger(e)&&e>=0&&e<t;function Pr(e,t="model.glb"){const n=I;if(!(e instanceof Uint8Array))throw T(t,"glb_header");if(e.length>n.glbBytes)throw T(t,"too_large",[Math.round(n.glbBytes/N)]);if(e.length<20||K(e,0)!==1179937895)throw T(t,"glb_header");if(K(e,4)!==2)throw T(t,"glb_version",[K(e,4)]);if(K(e,8)!==e.length)throw T(t,"glb_length");const r=K(e,12);if(K(e,16)!==1313821514||r<2||20+r>e.length)throw T(t,"glb_header");if(r>n.glbJsonBytes)throw T(t,"glb_json_large");let s;try{s=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(20,20+r)))}catch{throw T(t,"glb_json")}if(!F(s))throw T(t,"glb_json");let o=0,a=0;const i=20+r+(4-r%4)%4;if(i+8<=e.length){const m=K(e,i);if(K(e,i+4)!==5130562||i+8+m>e.length)throw T(t,"glb_header");o=i+8,a=m}const l=Ye(s);if(l)throw T(t,"glb_uri",[l]);const f=Array.isArray(s.extensionsUsed)?s.extensionsUsed.map(String):[],h=Array.isArray(s.extensionsRequired)?s.extensionsRequired.map(String):[],c=[...f,...h].find(m=>Er.includes(m));if(c)throw T(t,"glb_compressed",[c]);const u=h.find(m=>!Ar.includes(m));if(u)throw T(t,"glb_extension",[u.slice(0,60)]);const d=m=>{const b=s[m];if(b===void 0)return[];if(!Array.isArray(b))throw T(t,"glb_json");return b},k=d("buffers"),E=d("bufferViews"),p=d("accessors"),S=d("meshes"),w=d("nodes"),g=d("images"),_=d("textures"),M=d("scenes"),y=d("animations");if(k.length>1||k.length&&(!F(k[0])||!Number.isInteger(k[0].byteLength)||k[0].byteLength>a))throw T(t,"glb_buffers");if(w.length>n.nodes)throw T(t,"glb_nodes",[n.nodes]);const A=k.length?k[0].byteLength:0;E.forEach((m,b)=>{const O=m?.byteOffset??0,j=m?.byteLength;if(!F(m)||m.buffer!==0||!Number.isInteger(O)||O<0||!Number.isInteger(j)||j<1||O+j>A)throw T(t,"glb_range",[`bufferViews[${b}]`]);if(m.byteStride!==void 0&&!(Number.isInteger(m.byteStride)&&m.byteStride>=4&&m.byteStride<=252))throw T(t,"glb_range",[`bufferViews[${b}]`])}),p.forEach((m,b)=>{if(!F(m)||!gt[m.componentType]||!yt[m.type]||!Number.isInteger(m.count)||m.count<1||m.count>5e6)throw T(t,"glb_range",[`accessors[${b}]`]);if(m.sparse!==void 0)throw T(t,"glb_sparse");if(m.bufferView===void 0)return;if(!q(m.bufferView,E.length))throw T(t,"glb_range",[`accessors[${b}]`]);const O=E[m.bufferView],j=gt[m.componentType]*yt[m.type],B=O.byteStride||j,H=m.byteOffset??0;if(!Number.isInteger(H)||H<0||H+(m.count-1)*B+j>O.byteLength)throw T(t,"glb_range",[`accessors[${b}]`])});const P=S.map((m,b)=>{if(!F(m)||!Array.isArray(m.primitives)||!m.primitives.length)throw T(t,"glb_range",[`meshes[${b}]`]);let O=0,j=0;for(const B of m.primitives){if(!F(B)||!F(B.attributes)||!q(B.attributes.POSITION,p.length))throw T(t,"glb_range",[`meshes[${b}]`]);for(const it of Object.values(B.attributes))if(!q(it,p.length))throw T(t,"glb_range",[`meshes[${b}]`]);if(B.indices!==void 0&&!q(B.indices,p.length))throw T(t,"glb_range",[`meshes[${b}]`]);if(B.material!==void 0&&!(Number.isInteger(B.material)&&B.material>=0))throw T(t,"glb_range",[`meshes[${b}]`]);const H=B.indices!==void 0?p[B.indices].count:p[B.attributes.POSITION].count,X=B.mode??4;j+=p[B.attributes.POSITION].count,O+=X===4?Math.floor(H/3):X===5||X===6?Math.max(0,H-2):0}return{tris:O,verts:j}});let L=0,x=0,$=0;const C=(m,b,O)=>{if(!q(m,w.length))throw T(t,"glb_range",["nodes"]);if(b>n.depth||O.has(m))throw T(t,"glb_nodes",[n.depth]);if(++$>n.nodes*4)throw T(t,"glb_nodes",[n.nodes]);const j=w[m];if(!F(j))throw T(t,"glb_range",["nodes"]);if(j.mesh!==void 0){if(!q(j.mesh,S.length))throw T(t,"glb_range",["nodes"]);L+=P[j.mesh].tris,x+=P[j.mesh].verts}if(j.children!==void 0){if(!Array.isArray(j.children))throw T(t,"glb_range",["nodes"]);O.add(m);for(const B of j.children)C(B,b+1,O);O.delete(m)}};if(M.length)for(const m of M){if(!F(m))throw T(t,"glb_json");for(const b of m.nodes??[])C(b,0,new Set)}else P.forEach(m=>{L+=m.tris,x+=m.verts});if(L>n.triangles)throw T(t,"glb_triangles",[L,n.triangles]);if(x>n.vertices)throw T(t,"glb_vertices",[x,n.vertices]);if(g.length>n.glbImages)throw T(t,"glb_images",[g.length,n.glbImages]);const R=g.map((m,b)=>{if(!F(m)||!q(m.bufferView,E.length)||!["image/png","image/jpeg","image/webp"].includes(m.mimeType))throw T(t,"glb_image",[b]);const O=E[m.bufferView],j=o+(O.byteOffset??0),B=e.subarray(j,j+O.byteLength),H=Ut(B);if(!H||H.type!==m.mimeType)throw T(t,"glb_image",[b]);if(H.width>n.imagePx||H.height>n.imagePx)throw T(t,"image_size",[`${H.width}×${H.height}`,`${n.imagePx}×${n.imagePx}`]);return H});_.forEach((m,b)=>{if(!F(m))throw T(t,"glb_range",[`textures[${b}]`]);const O=m.extensions?.EXT_texture_webp?.source??m.source;if(O!==void 0&&!q(O,g.length))throw T(t,"glb_range",[`textures[${b}]`])});const v=y.map((m,b)=>{if(!F(m)||!Array.isArray(m.channels)||!Array.isArray(m.samplers))throw T(t,"glb_range",[`animations[${b}]`]);for(const O of m.samplers)if(!F(O)||!q(O.input,p.length)||!q(O.output,p.length))throw T(t,"glb_range",[`animations[${b}]`]);for(const O of m.channels)if(!F(O)||!q(O.sampler,m.samplers.length)||!F(O.target)||O.target.node!==void 0&&!q(O.target.node,w.length))throw T(t,"glb_range",[`animations[${b}]`]);return typeof m.name=="string"&&m.name?m.name.slice(0,60):`Animation ${b+1}`});return{bytes:e.length,triangles:L,vertices:x,meshes:S.length,nodes:w.length,images:R,animations:v,pixelBytes:R.reduce((m,b)=>m+b.width*b.height*4,0)}}const Kt=[67,88,83,81];function jr(e){const t=new Uint8Array(8+e.length*4),n=new DataView(t.buffer);t.set(Kt,0),n.setUint32(4,e.length,!0),e.forEach((o,a)=>n.setUint32(8+a*4,o.length,!0));const r=new Uint8Array(t.length+e.reduce((o,a)=>o+a.length,0));r.set(t,0);let s=t.length;for(const o of e)r.set(o,s),s+=o.length;return r}function $r(e){if(!(e instanceof Uint8Array)||e.length<8||Kt.some((s,o)=>e[o]!==s))throw D("asset",["sequence","seq_format"]);const t=K(e,4);if(t<1||t>I.seqFrames||8+t*4>e.length)throw D("asset",["sequence","seq_format"]);const n=[];let r=8+t*4;for(let s=0;s<t;s++){const o=K(e,8+s*4);if(o<1||r+o>e.length)throw D("asset",["sequence","seq_format"]);n.push(e.subarray(r,r+o)),r+=o}if(r!==e.length)throw D("asset",["sequence","seq_format"]);return n}function Cr(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>I.files)throw D("manifest_field",["assets","length"],`manifest.assets: up to ${I.files} entries`);const t=new Set;return e.map((n,r)=>{const s=`assets[${r}]`;if(typeof n=="string"&&(n={name:n}),!F(n)||Object.keys(n).some(f=>!["name","kind","sprite","fps"].includes(f)))throw D("unknown_key",[s]);if(typeof n.name!="string"||!xr.test(n.name))throw D("manifest_field",[`${s}.name`,"format"],`${s}.name: a file name under assets/ like "jet.glb" (a-z 0-9 . _ -)`);const o=t.has(n.name.toLowerCase());if(t.add(n.name.toLowerCase()),o)throw D("manifest_field",[`${s}.name`,"duplicate"]);const a=vr[qt(n.name)];let i=n.kind??a;if(n.kind!==void 0&&!Sr.includes(n.kind))throw D("manifest_field",[`${s}.kind`,"format"]);if(i==="sequence"){if(n.name.includes("."))throw D("manifest_field",[`${s}.name`,"format"],`${s}: a sequence is a folder name (no extension)`)}else if(a){if(i==="sprite"?a!=="texture":i!==a)throw D("manifest_field",[`${s}.kind`,"format"])}else throw D("manifest_field",[`${s}.name`,"format"],`${s}.name: .glb · .png · .webp · .jpg · .cube · .blend · .webm`);const l={name:n.name,kind:i};if(i==="sprite"){const f=n.sprite;if(!F(f)||Object.keys(f).some(d=>!["cols","rows","frames","fps"].includes(d)))throw D("manifest_field",[`${s}.sprite`,"type"]);const h=(d,k,E)=>Number.isInteger(d)&&d>=k&&d<=E;if(!h(f.cols,1,64)||!h(f.rows,1,64)||f.cols*f.rows>I.spriteFrames)throw D("manifest_field",[`${s}.sprite`,"range"]);const c=f.frames??f.cols*f.rows;if(!h(c,1,f.cols*f.rows))throw D("manifest_field",[`${s}.sprite.frames`,"range"]);const u=f.fps??24;if(!h(u,1,60))throw D("manifest_field",[`${s}.sprite.fps`,"range"]);l.sprite={cols:f.cols,rows:f.rows,frames:c,fps:u}}else if(n.sprite!==void 0)throw D("unknown_key",[`${s}.sprite`]);if(i==="sequence"){const f=n.fps??24;if(!(Number.isInteger(f)&&f>=1&&f<=60))throw D("manifest_field",[`${s}.fps`,"range"]);l.fps=f}else if(n.fps!==void 0)throw D("unknown_key",[`${s}.fps`]);return l})}function uo(e,t){const n=new Map(e.map(s=>[s.name,[]])),r=new Map(e.map(s=>[s.name,s]));for(const s of t){if(!s.startsWith("assets/"))continue;const o=s.slice(7),a=o.split("/");if(a.length===1&&r.has(a[0])&&r.get(a[0]).kind!=="sequence"){n.get(a[0]).push(s);continue}if(a.length===2&&r.get(a[0])?.kind==="sequence"&&Tr.test(a[1])){n.get(a[0]).push(s);continue}throw D("extra_file",[s.slice(0,80)])}for(const[s,o]of n){if(!o.length)throw D("no_entry",[`assets/${s}`]);o.sort()}return n}function po(e,t,n){const{name:r,kind:s}=e;if(s==="model"){const h=n(t[0]);return{stored:h,facts:Pr(h,r)}}if(s==="texture"||s==="sprite"){const h=n(t[0]),c=mt(r,h);return{stored:h,facts:{bytes:h.length,width:c.width,height:c.height,type:c.type,pixelBytes:c.width*c.height*4*1}}}if(s==="lut"){const h=n(t[0]);if(h.length>I.lutBytes)throw T(r,"too_large",[Math.round(I.lutBytes/N)]);let c;try{c=new TextDecoder("utf-8",{fatal:!0}).decode(h)}catch{throw T(r,"lut")}let u;try{u=Dt(c)}catch(d){throw T(r,"lut",[String(d.message).slice(0,80)])}if(u.size>I.lutSize)throw T(r,"lut_size",[u.size,I.lutSize]);return{stored:h,facts:{bytes:h.length,size:u.size,pixelBytes:0}}}if(s==="blend"){const h=n(t[0]);if(h.length>I.blendBytes)throw T(r,"too_large",[Math.round(I.blendBytes/N)]);const c=h.length>12&&String.fromCharCode(...h.subarray(0,7))==="BLENDER",u=h.length>4&&h[0]===40&&h[1]===181&&h[2]===47&&h[3]===253,d=h.length>2&&h[0]===31&&h[1]===139;if(!c&&!u&&!d)throw T(r,"format");return{stored:h,facts:{bytes:h.length,pixelBytes:0}}}if(s==="video"){const h=n(t[0]);if(h.length>I.videoBytes)throw T(r,"too_large",[Math.round(I.videoBytes/N)]);if(!(h.length>40&&h[0]===26&&h[1]===69&&h[2]===223&&h[3]===163&&String.fromCharCode(...h.subarray(0,64)).includes("webm")))throw T(r,"format");return{stored:h,facts:{bytes:h.length,pixelBytes:0}}}if(t.length>I.seqFrames)throw T(r,"seq_frames",[t.length,I.seqFrames]);let o=0,a=0,i=0;const l=[];for(const h of t){const c=n(h);if(i+=c.length,i>I.seqBytes)throw T(r,"too_large",[Math.round(I.seqBytes/N)]);const u=mt(`${r}/${h.split("/").pop()}`,c,{maxW:I.seqFrameW,maxH:I.seqFrameH});if(l.length&&(u.width!==o||u.height!==a))throw T(r,"seq_size");o=u.width,a=u.height,l.push(c)}const f=jr(l);return{stored:f,facts:{bytes:f.length,frames:l.length,width:o,height:a,pixelBytes:o*a*4*l.length}}}function mo(e,t,n){if(e===void 0)return[];if(!Array.isArray(e)||e.length>I.uses||e.some(o=>typeof o!="string"))throw D("manifest_field",["uses","length"],`${n}: uses lists up to ${I.uses} asset names`);if(new Set(e).size!==e.length)throw D("manifest_field",["uses","duplicate"]);const r=new Map(t.map(o=>[o.name,o]));for(const o of e)if(!r.has(o))throw D("use_asset",[n,o.slice(0,64)],`${n}: uses "${o.slice(0,64)}" but the pack has no such asset`);const s=e.map(o=>r.get(o)).filter(o=>o.bytes!==void 0);if(s.length===e.length){const o=s.reduce((i,l)=>i+l.bytes,0),a=s.reduce((i,l)=>i+(l.pixelBytes||0),0);if(o>I.itemBytes)throw D("item_budget",[n,Math.round(o/N),Math.round(I.itemBytes/N)],`${n}: its assets are ${Math.round(o/N)} MB (max ${Math.round(I.itemBytes/N)} MB per item)`);if(a>I.itemPixelBytes)throw D("item_pixels",[n,Math.round(a/N),Math.round(I.itemPixelBytes/N)],`${n}: its pictures decode to ${Math.round(a/N)} MB (max ${Math.round(I.itemPixelBytes/N)} MB per item)`)}return[...e]}function go(e){const[t]=Cr([{name:e?.name,kind:e?.kind,...e?.sprite?{sprite:e.sprite}:{},...e?.fps!==void 0?{fps:e.fps}:{}}]);if(!Number.isInteger(e.bytes)||e.bytes<1||!/^[a-f0-9]{64}$/.test(String(e.sha256))||!(Number.isFinite(e.pixelBytes)&&e.pixelBytes>=0))throw D("bad_package");const n=F(e.facts)?e.facts:{};return{...t,bytes:e.bytes,sha256:e.sha256,pixelBytes:e.pixelBytes,facts:n}}const Vt=4e3,Jt=9e4,Yt=2e4,Xt="WEBGL_UNAVAILABLE",Rr=`const SPACE_PROJECT=${pn.toString()};${Bt}self.__MOTION_STICKERS=new Map();let ASSETS=new Map();const DECODE=${Wt};const M=Object.freeze({...${Nt},...(${Mr})({get:n=>ASSETS.get(n)})});const FONTS=Object.freeze(${JSON.stringify(Ft)});let render=null,key=null,canvas=null,ctx=null,ready=Promise.resolve()
60
+ }`,kr=e=>typeof e=="string"?{uri:e}:e&&typeof e=="object"?e:null,N=1024*1024,I=Object.freeze({packageBytes:200*N,inflatedBytes:400*N,files:400,glbBytes:20*N,triangles:3e5,vertices:2e6,glbImages:16,glbJsonBytes:4*N,nodes:1e4,depth:64,imagePx:4096,textureBytes:8*N,spriteFrames:256,seqFrames:240,seqFrameW:1920,seqFrameH:1080,seqBytes:40*N,lutBytes:12*N,lutSize:65,blendBytes:150*N,videoBytes:40*N,itemBytes:60*N,itemPixelBytes:256*N,uses:24}),Sr=Object.freeze(["model","texture","sprite","sequence","lut","blend","video"]),Ar=Object.freeze(["KHR_materials_emissive_strength","KHR_materials_transmission","KHR_materials_clearcoat","KHR_materials_ior","KHR_materials_specular","KHR_materials_sheen","KHR_materials_volume","KHR_materials_unlit","KHR_materials_iridescence","KHR_materials_anisotropy","KHR_materials_dispersion","KHR_texture_transform","KHR_mesh_quantization","EXT_texture_webp","KHR_lights_punctual"]),Er=["KHR_draco_mesh_compression","EXT_meshopt_compression","KHR_meshopt_compression","KHR_texture_basisu","EXT_mesh_gpu_instancing"],xr=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,Tr=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}\.(png|webp)$/i,vr={glb:"model",png:"texture",webp:"texture",jpg:"texture",jpeg:"texture",cube:"lut",blend:"blend",webm:"video"},F=e=>!!e&&typeof e=="object"&&!Array.isArray(e),D=(e,t=[],n="")=>Object.assign(new Error(n||e),{code:e,args:t.map(String),plugin:!0}),T=(e,t,n=[])=>D("asset",[e,t,...n],`assets/${e}: ${t}${n.length?` (${n.join(", ")})`:""}`),qt=e=>String(e).split(".").pop().toLowerCase();function Or(e){return e.length>24&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10?"image/png":e.length>3&&e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e.length>16&&e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?"image/webp":null}const Be=(e,t)=>e[t]<<8|e[t+1],pt=(e,t)=>(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];function Ut(e){const t=Or(e);if(!t)return null;if(t==="image/png")return String.fromCharCode(e[12],e[13],e[14],e[15])!=="IHDR"?null:{type:t,width:pt(e,16),height:pt(e,20)};if(t==="image/jpeg"){let r=2;for(;r+9<e.length;){if(e[r]!==255){r++;continue}const s=e[r+1];if(s===255){r++;continue}if(s===216||s===1||s>=208&&s<=215){r+=2;continue}const o=Be(e,r+2);if(o<2)return null;if(s>=192&&s<=207&&s!==196&&s!==200&&s!==204)return{type:t,width:Be(e,r+7),height:Be(e,r+5)};r+=2+o}return null}const n=String.fromCharCode(e[12],e[13],e[14],e[15]);if(n==="VP8 "&&e.length>=30)return e[23]!==157||e[24]!==1||e[25]!==42?null:{type:t,width:(e[26]|e[27]<<8)&16383,height:(e[28]|e[29]<<8)&16383};if(n==="VP8L"&&e.length>=25){if(e[20]!==47)return null;const r=e[21]|e[22]<<8|e[23]<<16|e[24]<<24;return{type:t,width:(r&16383)+1,height:(r>>>14&16383)+1}}return n==="VP8X"&&e.length>=30?{type:t,width:1+(e[24]|e[25]<<8|e[26]<<16),height:1+(e[27]|e[28]<<8|e[29]<<16)}:null}const Lr={png:"image/png",webp:"image/webp",jpg:"image/jpeg",jpeg:"image/jpeg"};function mt(e,t,{maxW:n=I.imagePx,maxH:r=I.imagePx,maxBytes:s=I.textureBytes}={}){if(t.length>s)throw T(e,"too_large",[Math.round(s/N)]);const o=Ut(t),a=Lr[qt(e)];if(!o||!a)throw T(e,"not_image");if(o.type!==a)throw T(e,"magic",[o.type.slice(6)]);if(!(o.width>0&&o.height>0))throw T(e,"not_image");if(o.width>n||o.height>r)throw T(e,"image_size",[`${o.width}×${o.height}`,`${n}×${r}`]);return o}const K=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,gt={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},yt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Ye(e,t=0){if(t>40)return"deep";if(Array.isArray(e)){for(const n of e){const r=n&&typeof n=="object"?Ye(n,t+1):null;if(r)return r}return null}if(!F(e))return null;for(const[n,r]of Object.entries(e)){if(n==="__proto__"||n==="constructor"||n==="prototype")return"key";if(n==="uri")return typeof r=="string"?r.slice(0,60):"uri";if(r&&typeof r=="object"){const s=Ye(r,t+1);if(s)return s}}return null}const q=(e,t)=>Number.isInteger(e)&&e>=0&&e<t;function Pr(e,t="model.glb"){const n=I;if(!(e instanceof Uint8Array))throw T(t,"glb_header");if(e.length>n.glbBytes)throw T(t,"too_large",[Math.round(n.glbBytes/N)]);if(e.length<20||K(e,0)!==1179937895)throw T(t,"glb_header");if(K(e,4)!==2)throw T(t,"glb_version",[K(e,4)]);if(K(e,8)!==e.length)throw T(t,"glb_length");const r=K(e,12);if(K(e,16)!==1313821514||r<2||20+r>e.length)throw T(t,"glb_header");if(r>n.glbJsonBytes)throw T(t,"glb_json_large");let s;try{s=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(20,20+r)))}catch{throw T(t,"glb_json")}if(!F(s))throw T(t,"glb_json");let o=0,a=0;const i=20+r+(4-r%4)%4;if(i+8<=e.length){const m=K(e,i);if(K(e,i+4)!==5130562||i+8+m>e.length)throw T(t,"glb_header");o=i+8,a=m}const l=Ye(s);if(l)throw T(t,"glb_uri",[l]);const f=Array.isArray(s.extensionsUsed)?s.extensionsUsed.map(String):[],h=Array.isArray(s.extensionsRequired)?s.extensionsRequired.map(String):[],c=[...f,...h].find(m=>Er.includes(m));if(c)throw T(t,"glb_compressed",[c]);const u=h.find(m=>!Ar.includes(m));if(u)throw T(t,"glb_extension",[u.slice(0,60)]);const d=m=>{const b=s[m];if(b===void 0)return[];if(!Array.isArray(b))throw T(t,"glb_json");return b},k=d("buffers"),E=d("bufferViews"),p=d("accessors"),S=d("meshes"),w=d("nodes"),g=d("images"),_=d("textures"),M=d("scenes"),y=d("animations");if(k.length>1||k.length&&(!F(k[0])||!Number.isInteger(k[0].byteLength)||k[0].byteLength>a))throw T(t,"glb_buffers");if(w.length>n.nodes)throw T(t,"glb_nodes",[n.nodes]);const A=k.length?k[0].byteLength:0;E.forEach((m,b)=>{const O=m?.byteOffset??0,j=m?.byteLength;if(!F(m)||m.buffer!==0||!Number.isInteger(O)||O<0||!Number.isInteger(j)||j<1||O+j>A)throw T(t,"glb_range",[`bufferViews[${b}]`]);if(m.byteStride!==void 0&&!(Number.isInteger(m.byteStride)&&m.byteStride>=4&&m.byteStride<=252))throw T(t,"glb_range",[`bufferViews[${b}]`])}),p.forEach((m,b)=>{if(!F(m)||!gt[m.componentType]||!yt[m.type]||!Number.isInteger(m.count)||m.count<1||m.count>5e6)throw T(t,"glb_range",[`accessors[${b}]`]);if(m.sparse!==void 0)throw T(t,"glb_sparse");if(m.bufferView===void 0)return;if(!q(m.bufferView,E.length))throw T(t,"glb_range",[`accessors[${b}]`]);const O=E[m.bufferView],j=gt[m.componentType]*yt[m.type],B=O.byteStride||j,H=m.byteOffset??0;if(!Number.isInteger(H)||H<0||H+(m.count-1)*B+j>O.byteLength)throw T(t,"glb_range",[`accessors[${b}]`])});const P=S.map((m,b)=>{if(!F(m)||!Array.isArray(m.primitives)||!m.primitives.length)throw T(t,"glb_range",[`meshes[${b}]`]);let O=0,j=0;for(const B of m.primitives){if(!F(B)||!F(B.attributes)||!q(B.attributes.POSITION,p.length))throw T(t,"glb_range",[`meshes[${b}]`]);for(const it of Object.values(B.attributes))if(!q(it,p.length))throw T(t,"glb_range",[`meshes[${b}]`]);if(B.indices!==void 0&&!q(B.indices,p.length))throw T(t,"glb_range",[`meshes[${b}]`]);if(B.material!==void 0&&!(Number.isInteger(B.material)&&B.material>=0))throw T(t,"glb_range",[`meshes[${b}]`]);const H=B.indices!==void 0?p[B.indices].count:p[B.attributes.POSITION].count,X=B.mode??4;j+=p[B.attributes.POSITION].count,O+=X===4?Math.floor(H/3):X===5||X===6?Math.max(0,H-2):0}return{tris:O,verts:j}});let L=0,x=0,$=0;const C=(m,b,O)=>{if(!q(m,w.length))throw T(t,"glb_range",["nodes"]);if(b>n.depth||O.has(m))throw T(t,"glb_nodes",[n.depth]);if(++$>n.nodes*4)throw T(t,"glb_nodes",[n.nodes]);const j=w[m];if(!F(j))throw T(t,"glb_range",["nodes"]);if(j.mesh!==void 0){if(!q(j.mesh,S.length))throw T(t,"glb_range",["nodes"]);L+=P[j.mesh].tris,x+=P[j.mesh].verts}if(j.children!==void 0){if(!Array.isArray(j.children))throw T(t,"glb_range",["nodes"]);O.add(m);for(const B of j.children)C(B,b+1,O);O.delete(m)}};if(M.length)for(const m of M){if(!F(m))throw T(t,"glb_json");for(const b of m.nodes??[])C(b,0,new Set)}else P.forEach(m=>{L+=m.tris,x+=m.verts});if(L>n.triangles)throw T(t,"glb_triangles",[L,n.triangles]);if(x>n.vertices)throw T(t,"glb_vertices",[x,n.vertices]);if(g.length>n.glbImages)throw T(t,"glb_images",[g.length,n.glbImages]);const R=g.map((m,b)=>{if(!F(m)||!q(m.bufferView,E.length)||!["image/png","image/jpeg","image/webp"].includes(m.mimeType))throw T(t,"glb_image",[b]);const O=E[m.bufferView],j=o+(O.byteOffset??0),B=e.subarray(j,j+O.byteLength),H=Ut(B);if(!H||H.type!==m.mimeType)throw T(t,"glb_image",[b]);if(H.width>n.imagePx||H.height>n.imagePx)throw T(t,"image_size",[`${H.width}×${H.height}`,`${n.imagePx}×${n.imagePx}`]);return H});_.forEach((m,b)=>{if(!F(m))throw T(t,"glb_range",[`textures[${b}]`]);const O=m.extensions?.EXT_texture_webp?.source??m.source;if(O!==void 0&&!q(O,g.length))throw T(t,"glb_range",[`textures[${b}]`])});const v=y.map((m,b)=>{if(!F(m)||!Array.isArray(m.channels)||!Array.isArray(m.samplers))throw T(t,"glb_range",[`animations[${b}]`]);for(const O of m.samplers)if(!F(O)||!q(O.input,p.length)||!q(O.output,p.length))throw T(t,"glb_range",[`animations[${b}]`]);for(const O of m.channels)if(!F(O)||!q(O.sampler,m.samplers.length)||!F(O.target)||O.target.node!==void 0&&!q(O.target.node,w.length))throw T(t,"glb_range",[`animations[${b}]`]);return typeof m.name=="string"&&m.name?m.name.slice(0,60):`Animation ${b+1}`});return{bytes:e.length,triangles:L,vertices:x,meshes:S.length,nodes:w.length,images:R,animations:v,pixelBytes:R.reduce((m,b)=>m+b.width*b.height*4,0)}}const Kt=[67,88,83,81];function jr(e){const t=new Uint8Array(8+e.length*4),n=new DataView(t.buffer);t.set(Kt,0),n.setUint32(4,e.length,!0),e.forEach((o,a)=>n.setUint32(8+a*4,o.length,!0));const r=new Uint8Array(t.length+e.reduce((o,a)=>o+a.length,0));r.set(t,0);let s=t.length;for(const o of e)r.set(o,s),s+=o.length;return r}function $r(e){if(!(e instanceof Uint8Array)||e.length<8||Kt.some((s,o)=>e[o]!==s))throw D("asset",["sequence","seq_format"]);const t=K(e,4);if(t<1||t>I.seqFrames||8+t*4>e.length)throw D("asset",["sequence","seq_format"]);const n=[];let r=8+t*4;for(let s=0;s<t;s++){const o=K(e,8+s*4);if(o<1||r+o>e.length)throw D("asset",["sequence","seq_format"]);n.push(e.subarray(r,r+o)),r+=o}if(r!==e.length)throw D("asset",["sequence","seq_format"]);return n}function Cr(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>I.files)throw D("manifest_field",["assets","length"],`manifest.assets: up to ${I.files} entries`);const t=new Set;return e.map((n,r)=>{const s=`assets[${r}]`;if(typeof n=="string"&&(n={name:n}),!F(n)||Object.keys(n).some(f=>!["name","kind","sprite","fps"].includes(f)))throw D("unknown_key",[s]);if(typeof n.name!="string"||!xr.test(n.name))throw D("manifest_field",[`${s}.name`,"format"],`${s}.name: a file name under assets/ like "jet.glb" (a-z 0-9 . _ -)`);const o=t.has(n.name.toLowerCase());if(t.add(n.name.toLowerCase()),o)throw D("manifest_field",[`${s}.name`,"duplicate"]);const a=vr[qt(n.name)];let i=n.kind??a;if(n.kind!==void 0&&!Sr.includes(n.kind))throw D("manifest_field",[`${s}.kind`,"format"]);if(i==="sequence"){if(n.name.includes("."))throw D("manifest_field",[`${s}.name`,"format"],`${s}: a sequence is a folder name (no extension)`)}else if(a){if(i==="sprite"?a!=="texture":i!==a)throw D("manifest_field",[`${s}.kind`,"format"])}else throw D("manifest_field",[`${s}.name`,"format"],`${s}.name: .glb · .png · .webp · .jpg · .cube · .blend · .webm`);const l={name:n.name,kind:i};if(i==="sprite"){const f=n.sprite;if(!F(f)||Object.keys(f).some(d=>!["cols","rows","frames","fps"].includes(d)))throw D("manifest_field",[`${s}.sprite`,"type"]);const h=(d,k,E)=>Number.isInteger(d)&&d>=k&&d<=E;if(!h(f.cols,1,64)||!h(f.rows,1,64)||f.cols*f.rows>I.spriteFrames)throw D("manifest_field",[`${s}.sprite`,"range"]);const c=f.frames??f.cols*f.rows;if(!h(c,1,f.cols*f.rows))throw D("manifest_field",[`${s}.sprite.frames`,"range"]);const u=f.fps??24;if(!h(u,1,60))throw D("manifest_field",[`${s}.sprite.fps`,"range"]);l.sprite={cols:f.cols,rows:f.rows,frames:c,fps:u}}else if(n.sprite!==void 0)throw D("unknown_key",[`${s}.sprite`]);if(i==="sequence"){const f=n.fps??24;if(!(Number.isInteger(f)&&f>=1&&f<=60))throw D("manifest_field",[`${s}.fps`,"range"]);l.fps=f}else if(n.fps!==void 0)throw D("unknown_key",[`${s}.fps`]);return l})}function uo(e,t){const n=new Map(e.map(s=>[s.name,[]])),r=new Map(e.map(s=>[s.name,s]));for(const s of t){if(!s.startsWith("assets/"))continue;const o=s.slice(7),a=o.split("/");if(a.length===1&&r.has(a[0])&&r.get(a[0]).kind!=="sequence"){n.get(a[0]).push(s);continue}if(a.length===2&&r.get(a[0])?.kind==="sequence"&&Tr.test(a[1])){n.get(a[0]).push(s);continue}throw D("extra_file",[s.slice(0,80)])}for(const[s,o]of n){if(!o.length)throw D("no_entry",[`assets/${s}`]);o.sort()}return n}function po(e,t,n){const{name:r,kind:s}=e;if(s==="model"){const h=n(t[0]);return{stored:h,facts:Pr(h,r)}}if(s==="texture"||s==="sprite"){const h=n(t[0]),c=mt(r,h);return{stored:h,facts:{bytes:h.length,width:c.width,height:c.height,type:c.type,pixelBytes:c.width*c.height*4*1}}}if(s==="lut"){const h=n(t[0]);if(h.length>I.lutBytes)throw T(r,"too_large",[Math.round(I.lutBytes/N)]);let c;try{c=new TextDecoder("utf-8",{fatal:!0}).decode(h)}catch{throw T(r,"lut")}let u;try{u=Dt(c)}catch(d){throw T(r,"lut",[String(d.message).slice(0,80)])}if(u.size>I.lutSize)throw T(r,"lut_size",[u.size,I.lutSize]);return{stored:h,facts:{bytes:h.length,size:u.size,pixelBytes:0}}}if(s==="blend"){const h=n(t[0]);if(h.length>I.blendBytes)throw T(r,"too_large",[Math.round(I.blendBytes/N)]);const c=h.length>12&&String.fromCharCode(...h.subarray(0,7))==="BLENDER",u=h.length>4&&h[0]===40&&h[1]===181&&h[2]===47&&h[3]===253,d=h.length>2&&h[0]===31&&h[1]===139;if(!c&&!u&&!d)throw T(r,"format");return{stored:h,facts:{bytes:h.length,pixelBytes:0}}}if(s==="video"){const h=n(t[0]);if(h.length>I.videoBytes)throw T(r,"too_large",[Math.round(I.videoBytes/N)]);if(!(h.length>40&&h[0]===26&&h[1]===69&&h[2]===223&&h[3]===163&&String.fromCharCode(...h.subarray(0,64)).includes("webm")))throw T(r,"format");return{stored:h,facts:{bytes:h.length,pixelBytes:0}}}if(t.length>I.seqFrames)throw T(r,"seq_frames",[t.length,I.seqFrames]);let o=0,a=0,i=0;const l=[];for(const h of t){const c=n(h);if(i+=c.length,i>I.seqBytes)throw T(r,"too_large",[Math.round(I.seqBytes/N)]);const u=mt(`${r}/${h.split("/").pop()}`,c,{maxW:I.seqFrameW,maxH:I.seqFrameH});if(l.length&&(u.width!==o||u.height!==a))throw T(r,"seq_size");o=u.width,a=u.height,l.push(c)}const f=jr(l);return{stored:f,facts:{bytes:f.length,frames:l.length,width:o,height:a,pixelBytes:o*a*4*l.length}}}function mo(e,t,n){if(e===void 0)return[];if(!Array.isArray(e)||e.length>I.uses||e.some(o=>typeof o!="string"))throw D("manifest_field",["uses","length"],`${n}: uses lists up to ${I.uses} asset names`);if(new Set(e).size!==e.length)throw D("manifest_field",["uses","duplicate"]);const r=new Map(t.map(o=>[o.name,o]));for(const o of e)if(!r.has(o))throw D("use_asset",[n,o.slice(0,64)],`${n}: uses "${o.slice(0,64)}" but the pack has no such asset`);const s=e.map(o=>r.get(o)).filter(o=>o.bytes!==void 0);if(s.length===e.length){const o=s.reduce((i,l)=>i+l.bytes,0),a=s.reduce((i,l)=>i+(l.pixelBytes||0),0);if(o>I.itemBytes)throw D("item_budget",[n,Math.round(o/N),Math.round(I.itemBytes/N)],`${n}: its assets are ${Math.round(o/N)} MB (max ${Math.round(I.itemBytes/N)} MB per item)`);if(a>I.itemPixelBytes)throw D("item_pixels",[n,Math.round(a/N),Math.round(I.itemPixelBytes/N)],`${n}: its pictures decode to ${Math.round(a/N)} MB (max ${Math.round(I.itemPixelBytes/N)} MB per item)`)}return[...e]}function go(e){const[t]=Cr([{name:e?.name,kind:e?.kind,...e?.sprite?{sprite:e.sprite}:{},...e?.fps!==void 0?{fps:e.fps}:{}}]);if(!Number.isInteger(e.bytes)||e.bytes<1||!/^[a-f0-9]{64}$/.test(String(e.sha256))||!(Number.isFinite(e.pixelBytes)&&e.pixelBytes>=0))throw D("bad_package");const n=F(e.facts)?e.facts:{};return{...t,bytes:e.bytes,sha256:e.sha256,pixelBytes:e.pixelBytes,facts:n}}const Vt=4e3,Jt=9e4,Yt=2e4,Xt="WEBGL_UNAVAILABLE",Rr=`const SPACE_PROJECT=${pn.toString()};${Bt}self.__MOTION_STICKERS=new Map();let ASSETS=new Map();const DECODE=${Wt};const M=Object.freeze({...${Nt},...(${Mr})({get:n=>ASSETS.get(n)})});const FONTS=Object.freeze(${JSON.stringify(Ft)});let render=null,key=null,canvas=null,ctx=null,cpu=false,ready=Promise.resolve()
61
61
  self.onmessage=async e=>{const m=e.data
62
62
  if(m.type==='fonts'){ready=Promise.all(m.fonts.map(async f=>{try{const ff=new FontFace(f.family,f.data,{weight:f.weight,style:f.style});await ff.load();self.fonts.add(ff)}catch(x){}}));return}
63
63
  if(m.type==='stickers'){const prev=ready;ready=prev.then(()=>Promise.all(m.items.map(async s=>{try{if(!self.__MOTION_STICKERS.has(s.id))self.__MOTION_STICKERS.set(s.id,await createImageBitmap(new Blob([s.data],{type:'image/webp'})))}catch(x){}})));return}
@@ -69,7 +69,7 @@ self.onmessage=async e=>{const m=e.data
69
69
  const fn=new Function('M','"use strict";'+m.code+'\\n;return typeof render==="function"?render:null')(M)
70
70
  if(!fn)throw Error('Motion code must define function render(ctx, t, env)')
71
71
  render=fn}
72
- if(!canvas||canvas.width!==m.width||canvas.height!==m.height){canvas=new OffscreenCanvas(m.width,m.height);ctx=canvas.getContext('2d')}
72
+ if(!canvas||canvas.width!==m.width||canvas.height!==m.height||cpu!==!!m.cpu){cpu=!!m.cpu;canvas=new OffscreenCanvas(m.width,m.height);ctx=canvas.getContext('2d',cpu?{willReadFrequently:true}:undefined)}
73
73
  ctx.setTransform(1,0,0,1,0,0);ctx.globalAlpha=1;ctx.globalCompositeOperation='source-over';ctx.filter='none';ctx.shadowBlur=0;ctx.shadowColor='transparent'
74
74
  ctx.clearRect(0,0,m.width,m.height);ctx.save();MOTION_FRAME_CLOCK(m.t,m.fps)
75
75
  const S=m.space,project=S?(x,y,z)=>SPACE_PROJECT(S,x,y,z,m.width):null
@@ -154,7 +154,7 @@ onmessage=e=>{if(e.source!==parent)return;const m=e.data
154
154
  const timer=setTimeout(()=>kill(m.layer,'Motion code took longer than '+ms/1000+'s for one frame (endless loop?)'),ms)
155
155
  inflight.set(m.req,{layer:m.layer,timer});x.w.postMessage(m)}
156
156
  parent.postMessage({type:'boot'},'*')
157
- <\/script>`;let G=null,ee=null,Br=0;const Ae=new Map,Ee=new Map;function Nr(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)+":"+e.length}let te=null;function Fr(){return te||(te=Promise.all(bn.map(async t=>{const n=await fetch(Mn+t.file);if(!n.ok)throw Error(t.file);return{family:t.family,weight:t.weight,style:t.style,data:await n.arrayBuffer()}})).catch(()=>(te=null,[])),te)}let Ne=null,be=null;function Gr(){return Ne??=Promise.all([U(()=>import("./three-D7Ssject.js"),[]),U(()=>import("./RoomEnvironment-grxZ6k9f.js"),[])]).then(([e,t])=>({src:e.default,room:_n(t.default)})).catch(e=>{throw Ne=null,e}),Ne}function Hr(){return be??=Gr().then(e=>{G?.contentWindow?.postMessage({type:"three",src:e.src,room:e.room},"*")}).catch(e=>{throw be=null,e}),be}let Fe=null,Me=null;function zr(){return Fe??=Promise.all([U(()=>import("./opentype-D4-4HGq7.js"),[]),...Object.entries(Sn).map(async([e,t])=>{const n=await fetch(t);if(!n.ok)throw Error(`Font ${n.status}`);return{key:e,data:await n.arrayBuffer()}})]).then(([e,...t])=>({src:e.default,fonts:t})).catch(e=>{throw Fe=null,e}),Fe}function Wr(){return Me??=zr().then(e=>{G?.contentWindow?.postMessage({type:"glyphs",src:e.src,fonts:e.fonts.map(t=>({key:t.key,data:t.data.slice(0)}))},"*")}).catch(e=>{throw Me=null,e}),Me}const Ge=new Map;let _e=new Map;function qr(e){return Promise.all(e.map(t=>{let n=_e.get(t);if(!n){let r=Ge.get(t);r||(r=fetch(mr(t)).then(s=>s.ok?s.arrayBuffer():null).catch(()=>null),Ge.set(t,r)),n=r.then(s=>{if(!s){Ge.delete(t),_e.delete(t);return}G?.contentWindow?.postMessage({type:"stickers",items:[{id:t,data:s.slice(0)}]},"*")}),_e.set(t,n)}return n}))}let He=null,ke=null;function Ur(){return He??=Promise.all([U(()=>import("./GLTFLoader-DYtnVu-I.js"),[]),U(()=>import("./BufferGeometryUtils-_ZXHoOh1.js"),[]),U(()=>import("./SkeletonUtils-CfWUgbiL.js"),[])]).then(([e,t,n])=>{const r=De(e.default),s=De(t.default),o=De(n.default);if(!r||!s||!o)throw Error("GLTFLoader shape changed");return{gltf:r,bgu:s,skel:o}}).catch(e=>{throw He=null,e}),He}function Kr(){return ke??=Ur().then(e=>{G?.contentWindow?.postMessage({type:"gltf",...e},"*")}).catch(e=>{throw ke=null,e}),ke}const xe=new Map,J=new Map;function yo(e,t){const n=t.slice().buffer;xe.set(e,n),J.delete(`local:${e}`)}function wo(e){for(const t of[...xe.keys()])t.startsWith(e)&&(xe.delete(t),J.delete(`local:${t}`))}let ne=null;function Vr(e){if(!ne){const t={uris:new Set,run:Promise.resolve({})};t.run=new Promise(n=>setTimeout(n,0)).then(()=>(ne=null,yr([...t.uris]))),ne=t}return ne.uris.add(e),ne.run.then(t=>{const n=t[e];if(!n)throw Error(le("Không tải được tài nguyên của lớp plug-in ({0}).",[e.split("/").pop()||"?"]));return n})}function Jr(e){let t=J.get(e);return t||(t=e.startsWith("local:")?Promise.resolve().then(()=>{const n=xe.get(e.slice(6));if(!n)throw Error("local asset missing");return n}):Vr(e).then(n=>fetch(n)).then(n=>{if(!n.ok)throw Error(le("Không tải được tài nguyên của lớp plug-in ({0}).",[e.split("/").pop()||"?"]));return n.arrayBuffer()}),J.set(e,t),t.catch(()=>J.delete(e)),J.size>64&&J.delete(J.keys().next().value)),t}async function Yr(e,t){const n=kr(t),r=await Jr(n.uri),s=new Uint8Array(r),o={...n.grid?{grid:n.grid}:{},...n.fps?{fps:n.fps}:{}};if(s[0]===103&&s[1]===108&&s[2]===84&&s[3]===70)return{name:e,kind:"model",data:r.slice(0)};if(s[0]===67&&s[1]===88&&s[2]===83&&s[3]===81)return{name:e,kind:"sequence",frames:$r(s).map(a=>a.slice().buffer),...o};if(/\.cube$/i.test(e)||/\.cube$/i.test(n.uri)){const a=kn(Dt(new TextDecoder().decode(s)));return{name:e,kind:"lut",size:a.size,data:a.data.buffer.slice(0)}}return{name:e,kind:"image",data:r.slice(0),...o}}const Te=new Map;async function Xr(e,t,n){const r=t.assets;if(!r||!Object.keys(r).length)return;const s=JSON.stringify(r);if(Te.get(e)===s)return;n&&await Kr().catch(()=>{throw Error(le("Không tải được bộ đọc mô hình 3D — kiểm tra mạng rồi thử lại."))});const a=(await Promise.all(Object.entries(r).map(([i,l])=>Yr(i,l)))).map(i=>i.kind==="lut"?{...i,data:new Float32Array(i.data)}:i);G?.contentWindow?.postMessage({type:"assets",layer:e,items:a},"*"),Te.set(e,s)}function Zr(){if(ee&&G?.isConnected)return ee;G?.remove(),Ee.clear(),ae.clear(),_e=new Map,be=null,Me=null,ke=null,Te.clear();const e=document.createElement("iframe");return G=e,e.setAttribute("sandbox","allow-scripts"),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.title="motion-sandbox",e.style.cssText="position:fixed;width:1px;height:1px;left:-10px;top:-10px;border:0;opacity:0;pointer-events:none",e.srcdoc=Dr,ee=new Promise((t,n)=>{const r=window.setTimeout(()=>{window.removeEventListener("message",s),G===e&&(G.remove(),G=null,ee=null),n(Error("Motion sandbox did not start"))},8e3),s=o=>{o.source===e.contentWindow&&o.data?.type==="boot"&&(window.clearTimeout(r),window.removeEventListener("message",s),Fr().then(a=>{e.contentWindow?.postMessage({type:"fonts",fonts:a},"*"),t()}))};window.addEventListener("message",s)}),document.body.appendChild(e),ee}window.addEventListener("message",e=>{if(!G||e.source!==G.contentWindow||e.data?.type!=="frame")return;const t=Ae.get(e.data.req);t&&(Ae.delete(e.data.req),window.clearTimeout(t.timer),e.data.bmp?t.resolve(e.data.bmp):t.reject(Error(e.data.error===Xt?le("Trình duyệt không chạy được WebGL nên không vẽ được lớp Motion 3D. Hãy bật tăng tốc phần cứng hoặc dùng Chrome / Edge bản mới."):String(e.data.error||"Motion frame failed"))))});const ae=new Map,ve=new Map,Qr=1500;let Oe=Promise.resolve(),wt=Promise.resolve(),Xe=0,Ze=-1/0;async function es(){for(;;){const e=Oe;if(await e,e!==Oe)continue;const t=Ze+Qr-performance.now();if(!Xe&&t<=0)return;await new Promise(n=>window.setTimeout(n,Math.max(100,t)))}}async function bo(e){await Zr();const t=yn(e.motion.code),n=e.motion.kind==="three",r=Nr(e.motion.assets?t+"\0"+JSON.stringify(e.motion.assets):t);n&&await Hr(),await Xr(e.layer,e.motion,n),n&&wn(t)&&await Wr().catch(()=>{throw Error(le("Không tải được phông chữ cho chữ 3D nổi — kiểm tra mạng rồi thử lại."))});const s=n?[]:pr(t,e.motion.params||{});if(s.length&&await qr(s),!n)return Qe(e,t,r);if(!e.background){Xe++,Ze=performance.now();try{return await bt(e,t,r)}finally{Xe--,Ze=performance.now()}}return bt(e,t,r)}function bt(e,t,n){const r=n+"|"+JSON.stringify(e.motion.params||{})+"|"+e.width+"x"+e.height;if(ae.get(e.layer)===r)return Qe(e,t,n);const s=ve.get(e.layer)??0,o=G,a=()=>{if((ve.get(e.layer)??0)!==s||G!==o)throw Error("dropped");return Qe(e,t,n).then(l=>(G===o&&ae.set(e.layer,r),l),l=>{throw ae.delete(e.layer),l})};if(e.background){const l=wt.then(es).then(a);return wt=l.catch(()=>{}),l}const i=Oe.then(a);return Oe=i.catch(()=>{}),i}function Qe(e,t,n){const r=e.motion.kind==="three",s=++Br,o=Ee.get(e.layer)!==n;return Ee.set(e.layer,n),new Promise((a,i)=>{const l=window.setTimeout(()=>{Ae.delete(s),i(Error("Motion frame timed out"))},(r?Jt:o?Yt:Vt)+2e3);Ae.set(s,{resolve:a,reject:i,timer:l}),G.contentWindow.postMessage({type:"frame",req:s,layer:e.layer,key:n,code:t,params:e.motion.params||{},t:e.t,width:e.width,height:e.height,duration:e.duration,fps:e.fps??30,...r?{kind:"three",surface:e.surface??null}:{space:e.space??null}},"*")})}function Mo(e){ve.set(e,(ve.get(e)??0)+1),ae.delete(e),Te.delete(e),G?.contentWindow&&Ee.delete(e)&&G.contentWindow.postMessage({type:"drop",layer:e},"*")}function z(e,t){let n=Math.imul(e^2654435769,2246822507)^Math.imul(t+1,3266489909);return n^=n>>>13,n=Math.imul(n,668265263),n^=n>>>16,(n>>>0)/4294967296}const Zt=(e,t)=>{const n=Math.floor(e),r=e-n,s=r*r*(3-2*r);return(z(n,t)*(1-s)+z(n+1,t)*s)*2-1},Qt=e=>{let t=7;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0},he=new Map;function en(e,t,n,r){const s=`${e}|${t.toFixed(2)}|${n%7}|${r}`;let o=he.get(s);if(o)return o;he.size>64&&he.clear();const a=128,i=n%7;o=Object.assign(document.createElement("canvas"),{width:a,height:a});const l=o.getContext("2d"),f=l.createImageData(a,a),[h,c,u]=[1,3,5].map(p=>parseInt(e.slice(p,p+2),16)),d=new Float32Array(a*a);for(let p=0;p<a*a;p++)d[p]=z(p,i+9);const k=(p,S)=>d[(S+a)%a*a+(p+a)%a],E=r?1-t*.35:t*.4;for(let p=0;p<a;p++)for(let S=0;S<a;S++){let w=0;for(let M=-1;M<=1;M++)for(let y=-1;y<=1;y++)w+=k(S+y,p+M);const g=Math.min(1,Math.max(0,((w/9-.5)*2.4+.5)*.6+.4*k(S,p))),_=(p*a+S)*4;f.data[_]=h,f.data[_+1]=c,f.data[_+2]=u,f.data[_+3]=g>E?r?Math.round(160+95*(g-E)/(1-E+1e-6)):255:0}return l.putImageData(f,0,0),he.set(s,o),o}function ts(e,t,n,r=0){return e.createPattern(en(t,Math.max(0,Math.min(1,n)),r,!1),"repeat")??t}function ue(e,t,n,r=0){return e.createPattern(en(t,Math.max(0,Math.min(1,n)),r,!0),"repeat")??t}function tn(e,t,n,r,s,o){const a=r.amount??.5,i=r.scale??1,l=r.color??En(s,null),[f,h,c,u]=n,d=(f+c)/2,k=(h+u)/2,E=Math.hypot(c-f,u-h)/2+4,p=(r.angle??0)*Math.PI/180;e.save(),r.type==="riso"&&(e.save(),e.globalAlpha*=.42*a,e.globalCompositeOperation="multiply",e.translate(4*i,-3*i),e.fillStyle=l,e.fill(t),e.restore()),e.clip(t);const S=(w,g,_,M)=>{e.save(),e.globalAlpha*=M,e.strokeStyle=l,e.lineWidth=_,e.lineCap="butt",e.translate(d,k),e.rotate(w),e.beginPath();for(let y=-E;y<=E;y+=g){const A=Zt(y/g,o+5)*g*.12;e.moveTo(-E,y+A),e.lineTo(E,y-A)}e.stroke(),e.restore()};switch(r.type){case"hatch":S(p,13*i,1.4+a*2.6,.35+a*.55);break;case"crosshatch":S(p,12*i,1.2+a*2,.3+a*.5),S(p+Math.PI/2,12*i,1.2+a*2,.25+a*.45);break;case"halftone":case"riso":{const w=(r.type==="riso"?9:12)*i;e.save(),e.fillStyle=l,e.globalAlpha*=r.type==="riso"?.5:.85,e.translate(d,k),e.rotate(p),e.beginPath();for(let g=-E;g<=E;g+=w)for(let _=-E;_<=E;_+=w){const M=.25+.75*Math.max(0,Math.min(1,(_+g)/(2*E)+.5)),y=w*.5*Math.sqrt(a*M);y>.3&&(e.moveTo(_+y,g),e.arc(_,g,y,0,Math.PI*2))}e.fill(),e.restore(),r.type==="riso"&&(e.globalAlpha*=.5,e.fillStyle=ue(e,"#ffffff",.3+a*.4,o),e.fillRect(f-4,h-4,c-f+8,u-h+8));break}case"grain":e.globalAlpha*=.3+a*.3,e.fillStyle=ue(e,l,.2+a*.5,o),e.fillRect(f-4,h-4,c-f+8,u-h+8);break;case"stipple":{const w=10*i,g=Math.min(4e3,Math.round((c-f)*(u-h)/(w*w)*a*1.6));e.fillStyle=l,e.globalAlpha*=.8,e.beginPath();for(let _=0;_<g;_++){const M=f+z(_,o+1)*(c-f),y=h+z(_,o+2)*(u-h),A=.9+z(_,o+3)*1.4*i;e.moveTo(M+A,y),e.arc(M,y,A,0,Math.PI*2)}e.fill();break}case"wash":{for(let w=0;w<3;w++){const g=f+(c-f)*(.2+.6*z(w,o+4)),_=h+(u-h)*(.2+.6*z(w,o+6)),M=Math.max(8,Math.min(c-f,u-h)*(.35+.3*z(w,o+8))),y=e.createRadialGradient(g,_,0,g,_,M);y.addColorStop(0,l),y.addColorStop(1,l+"00"),e.save(),e.globalAlpha*=.22*a,e.fillStyle=y,e.fillRect(g-M,_-M,M*2,M*2),e.restore()}e.save(),e.globalAlpha*=.5*a,e.strokeStyle=l,e.lineWidth=7*i,e.lineJoin="round",e.stroke(t),e.restore(),e.globalAlpha*=.25,e.fillStyle=ue(e,l,.3,o),e.fillRect(f-4,h-4,c-f+8,u-h+8);break}case"paper":{e.save(),e.globalAlpha*=.2+a*.2,e.fillStyle=ue(e,l,.2+a*.4,o),e.fillRect(f-4,h-4,c-f+8,u-h+8),e.restore();const w=Math.min(900,Math.round((c-f)*(u-h)/4e3*a*i));e.strokeStyle=l,e.lineWidth=.7,e.globalAlpha*=.18,e.beginPath();for(let g=0;g<w;g++){const _=f+z(g,o+11)*(c-f),M=h+z(g,o+12)*(u-h),y=z(g,o+13)*Math.PI*2,A=6+z(g,o+14)*14;e.moveTo(_,M),e.quadraticCurveTo(_+Math.cos(y+.6)*A*.6,M+Math.sin(y+.6)*A*.6,_+Math.cos(y)*A,M+Math.sin(y)*A)}e.stroke();break}case"grid":{const w=40*i;e.strokeStyle=l,e.beginPath();const g=Math.floor(f/w)*w,_=Math.floor(h/w)*w;for(let M=g;M<=c;M+=w)e.moveTo(M,h),e.lineTo(M,u);for(let M=_;M<=u;M+=w)e.moveTo(f,M),e.lineTo(c,M);e.lineWidth=1.2,e.globalAlpha*=.35*a+.1,e.stroke(),e.beginPath();for(let M=Math.floor(f/(w*5))*w*5;M<=c;M+=w*5)e.moveTo(M,h),e.lineTo(M,u);for(let M=Math.floor(h/(w*5))*w*5;M<=u;M+=w*5)e.moveTo(f,M),e.lineTo(c,M);e.lineWidth=2.4,e.stroke();break}}e.restore()}const nn=(e,t,n,r)=>t*Zt(e/38,r+n*977);function ns(e,t,n,r){const s=Math.floor(n*t.fps+1e-6),o=Qt(r)+(t.seed??0)*131|0;return e.map((a,i)=>{const l=An(a.pts,a.closed,10);if(l.length<2)return a;const f=[];let h=0;const c=a.closed&&l.length>2?l.length-1:l.length;for(let u=0;u<c;u++){u&&(h+=Math.hypot(l[u][0]-l[u-1][0],l[u][1]-l[u-1][1]));const d=l[Math.max(0,u-1)],k=l[Math.min(l.length-1,u+1)],E=k[0]-d[0],p=k[1]-d[1],S=Math.hypot(E,p)||1,w=nn(h,t.amount,s,o+i*17);f.push([l[u][0]-p/S*w,l[u][1]+E/S*w])}return{pts:f,closed:a.closed}})}const de=new Map;function rn(e,t,n,r){const s=Math.floor(n*t.fps+1e-6),o=`${s}|${r}|${t.amount}|${e}`;let a=de.get(o);if(a)return a;de.size>600&&de.clear();const i=as(e);if(a=new Path2D,!i.L)return a.addPath(new Path2D(e)),a;const l=new Set;let f=0;const h=c=>{if(!(c-f+1<2)){for(let d=f;d<=c;d++){const k=Math.max(f,d-1),E=Math.min(c,d+1),p=i.xs[E]-i.xs[k],S=i.ys[E]-i.ys[k],w=Math.hypot(p,S)||1,g=nn(i.ss[d],t.amount,s,r),_=i.xs[d]-S/w*g,M=i.ys[d]+p/w*g;d===f?a.moveTo(_,M):a.lineTo(_,M)}Math.hypot(i.xs[c]-i.xs[f],i.ys[c]-i.ys[f])<i.step*2&&(a.closePath(),l.add(f))}};for(let c=1;c<i.ss.length;c++)Math.hypot(i.xs[c]-i.xs[c-1],i.ys[c]-i.ys[c-1])>i.step*3&&(h(c-1),f=c);return h(i.ss.length-1),de.set(o,a),a}const pe=new Map,rs=e=>{let t=pe.get(e);return t||(pe.size>2e3&&pe.clear(),t=new Path2D(e),pe.set(e,t)),t},Mt=e=>{const t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)};function ss(e,t,n,r,s,o){const a=t.params,i={...a,parts:a.rig?gr(t,r):a.parts??[]},l=t.stroke,f=t.fill,h=f.type!=="none",c=M=>!!l&&l.width>0&&M.line!==!1&&(M.fill===null||i.outline!==!1),u=Math.max(0,Math.min(1,n.end)-Math.max(0,n.start)),d=u>=1&&!n.offset,k=i.parts.map(M=>d?1:Math.max(1,Le(M.d))),E=i.parts.map((M,y)=>c(M)?k[y]:d?1:Math.max(40,k[y]*.35)),p=E.reduce((M,y)=>M+y,0)||1,S=Math.max(0,n.start)*p,w=S+u*p,g=Qt(t.id)+(o?.seed??0)*131;let _=0;i.parts.forEach((M,y)=>{const A=E[y],P=_;_=_+A;const x=d?1:Math.max(0,Math.min(1,(w-P)/A))-Math.max(0,Math.min(1,(S-P)/A));if(x<=0)return;const $=o?rn(M.d,o,r,g+y*29):rs(M.d),C=v=>{if(!c(M)||!l)return;e.globalAlpha=s*t.opacity*(l.opacity??1)*(M.o??1);const m=Le(M.d),b=d?m:m*x,O=l.width*(M.lw??1)*(v?2:1);if(l.hand){const j={...l.hand,...o?{boil:Math.max(l.hand.boil??0,o.fps)}:{}};ot(e,M.d,{color:l.color,width:O,from:d?0:Math.max(0,(S-P)/A)*m,len:b,hand:j,time:r})}else e.strokeStyle=l.color,e.lineWidth=O,e.lineCap=l.cap??"round",e.lineJoin=l.join??"round",d||!m?e.setLineDash([]):(e.setLineDash([b,m*2]),e.lineDashOffset=-Math.max(0,(S-P)/A)*m),e.stroke($),e.setLineDash([])},R=h&&!!M.fill;if(R&&C(!0),R){if(e.globalAlpha=s*t.opacity*(f.opacity??1)*(M.o??1)*(d?1:c(M)?Mt((x-.6)/.4):Mt(x)),e.globalAlpha>0){e.fillStyle=M.fill,M.eo?e.fill($,"evenodd"):e.fill($);const v=f.texture;v&&(e.save(),M.eo&&e.clip($,"evenodd"),tn(e,$,os(M.d),v,M.fill,g+y),e.restore())}}else C(!1)})}const me=new Map;function os(e){let t=me.get(e);if(t)return t;const n=e.match(/-?\d*\.?\d+(?:e[-+]?\d+)?/gi)?.map(Number)??[];let r=1/0,s=1/0,o=-1/0,a=-1/0;for(let i=0;i+1<n.length;i+=2)r=Math.min(r,n[i]),o=Math.max(o,n[i]),s=Math.min(s,n[i+1]),a=Math.max(a,n[i+1]);return t=Number.isFinite(r)?[r,s,o,a]:[-50,-50,50,50],me.size>2e3&&me.clear(),me.set(e,t),t}const re=new Map;function st(e){let t=re.get(e);if(t)return t;re.size>400&&re.clear();const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",e);let r=0;try{r=n.getTotalLength()}catch{r=0}if(!Number.isFinite(r)||r<=0)return t={xs:new Float32Array(0),ys:new Float32Array(0),ss:new Float32Array(0),L:0,step:1},re.set(e,t),t;const s=Math.max(1.5,r/900),o=Math.ceil(r/s)+1,a=new Float32Array(o),i=new Float32Array(o),l=new Float32Array(o);for(let f=0;f<o;f++){const h=Math.min(r,f*s),c=n.getPointAtLength(h);a[f]=c.x,i[f]=c.y,l[f]=h}return t={xs:a,ys:i,ss:l,L:r,step:s},re.set(e,t),t}const Le=e=>st(e).L,as=e=>st(e);function _t(e,t){let n=Math.imul(e^2654435769,2246822507)^Math.imul(t+1,3266489909);return n^=n>>>13,n=Math.imul(n,668265263),n^=n>>>16,(n>>>0)/4294967296*2-1}function kt(e,t){const n=Math.floor(e),r=e-n,s=r*r*(3-2*r);return _t(n,t)*(1-s)+_t(n+1,t)*s}const St=e=>{const t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)};function At(e,t,n,r,s,o,a,i,l,f=0){if(r-n+1<2)return;const c=t.ss[r]-t.ss[n],u=[],d=[],k=Math.max(.001,Math.min(c*.15,s*3)),E=Math.max(.001,Math.min(c*.22,s*4));for(let p=n;p<=r;p++){const S=Math.max(n,p-1),w=Math.min(r,p+1),g=t.xs[w]-t.xs[S],_=t.ys[w]-t.ys[S],M=Math.hypot(g,_)||1,y=-_/M,A=g/M,P=t.ss[p],L=P-t.ss[n],x=kt(P/(s*3+24),a)*o.wobble*s,$=1+o.press*kt(P/(s*6+48),a+7),C=o.tip+(1-o.tip)*Math.min(St(L/k),St((c-L)/E)),R=Math.max(.15,s/2*$*C),v=t.xs[p]+y*x,m=t.ys[p]+A*x;u.push(v+y*R,m+A*R),d.push(v-y*R,m-A*R)}e.beginPath(),e.moveTo(u[0],u[1]);for(let p=2;p<u.length;p+=2)e.lineTo(u[p],u[p+1]);for(let p=d.length-2;p>=0;p-=2)e.lineTo(d[p],d[p+1]);if(e.closePath(),e.fill(),f>0){const p=e.globalAlpha;e.globalAlpha=p*f,e.lineWidth=Math.max(.4,s*.07),e.lineJoin="round",e.strokeStyle=e.fillStyle,e.stroke(),e.globalAlpha=p}}function ot(e,t,n){const r=st(t);if(!r.L||n.len<=0)return;let s=ft[n.hand.style]??xn[n.hand.style]??ft.marker;(n.hand.taper!==void 0||n.hand.press!==void 0)&&(s={...s,...n.hand.taper!==void 0?{tip:Math.max(.02,1-n.hand.taper)}:{},...n.hand.press!==void 0?{press:n.hand.press*.6}:{}});const o=Math.max(.5,n.width*s.width),a=n.hand.boil?Math.floor(n.time*n.hand.boil+1e-6):0,i=(n.hand.seed??0)*131+a*977|0,l=r.L,f=Math.max(0,Math.min(l,n.from)),h=Math.min(l,n.len),c=f+h<=l+1e-6?[[f,Math.min(l,f+h)]]:[[f,l],[0,f+h-l]],u=e.globalAlpha;e.save(),e.fillStyle=s.grain?ts(e,n.color,s.grain,n.hand.seed??0):n.color;const d=s.wet?[[1,s.alpha*.5,i],[.9,s.alpha*.4,i+11],[1.08,s.alpha*.3,i+23]]:[[1,s.alpha,i]];s.retrace&&d.push([.45,s.alpha*.35,i+3]);for(const[k,E,p]of d){e.globalAlpha=u*E;for(const[S,w]of c){let g=-1;for(let _=0;_<r.ss.length;_++){const M=r.ss[_]>=S-1e-6&&r.ss[_]<=w+1e-6,y=g>=0&&_>g&&Math.hypot(r.xs[_]-r.xs[_-1],r.ys[_]-r.ys[_-1])>r.step*3;g>=0&&(!M||y)&&(At(e,r,g,_-1,o*k,s,p,!0,!0,s.wet?.5:0),g=-1),M&&g<0&&(g=_)}g>=0&&At(e,r,g,r.ss.length-1,o*k,s,p,!0,!0,s.wet?.5:0)}}e.restore()}const _o=e=>"paths"in e?e.trim?.offset??0:0,sn=1280,Se=720,ko=e=>e&&"size"in e&&e.size?{W:e.size[0],H:e.size[1]}:e?.square?{W:Se,H:Se}:{W:sn,H:Se},Et=new Map;function on(e){let t=Et.get(e);if(t===void 0){const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",e);try{t=n.getTotalLength()}catch{t=0}Et.set(e,t=Number.isFinite(t)?t:0)}return t}function So(e,t,n,r=sn,s=Se,o=0){const a=Math.min(r,s)/V,i=(r-V*a)/2,l=(s-V*a)/2;if(tt(t)){const c=t.step&&t.step>1?Tn(o,t.step):o,u=t.boil&&t.boil.amount>0?t.boil:null,d=t.items.map(E=>nt(E,c)),k=vn(t.items,d);e.save(),e.translate(i,l),e.scale(a,a),t.items.forEach((E,p)=>{if(E.hidden||E.span&&(o<E.span[0]-1e-6||o>=E.span[1]-1e-6))return;const S=k.get(E.id);S?(e.save(),e.transform(...S),xt(e,d[p],n,c,a,u),e.restore()):xt(e,d[p],n,c,a,u)}),e.restore();return}const f=Math.max(0,Math.min(1,n.end)-Math.max(0,n.start)),h=n.offset??0;e.save(),e.translate(i,l),e.scale(a,a);for(const c of t.paths){const u=new Path2D(c.d),d=c.opacity??1;if(e.filter=c.blur?`blur(${(c.blur*a).toFixed(2)}px)`:"none",c.fill&&f>0&&(e.globalAlpha=Math.min(1,f)*d,e.fillStyle=c.fill,c.rule?e.fill(u,c.rule):e.fill(u),e.globalAlpha=1),!c.stroke||f<=0)continue;if(e.globalAlpha=d,c.hand){const w=Le(c.d);ot(e,c.d,{color:c.stroke,width:c.strokeWidth??18,from:((n.start+h)%1+1)%1*w,len:f*w,hand:c.hand,time:o}),e.globalAlpha=1;continue}if(e.strokeStyle=c.stroke,e.lineWidth=c.strokeWidth??18,e.lineCap=c.cap??"round",e.lineJoin="round",f>=1&&h===0){e.setLineDash([]),e.stroke(u),e.globalAlpha=1;continue}const k=on(c.d);if(!k)continue;const E=((n.start+h)%1+1)%1*k,p=f*k,S=Math.min(p,k-E);e.setLineDash([S,k*2]),e.lineDashOffset=-E,e.stroke(u),p>S&&(e.setLineDash([p-S,k*2]),e.lineDashOffset=0,e.stroke(u))}e.setLineDash([]),e.globalAlpha=1,e.filter="none",e.restore()}const is={add:"source-over",subtract:"destination-out",intersect:"destination-in",exclude:"xor"};function xt(e,t,n,r,s=1,o=null){const a=o&&!t.params.d&&t.type!=="art"?ns(ct(t,r),o,r,t.id):ct(t,r),i=t.fill,l=t.stroke,f=On(t.ops,n),h=t.params.d?o?rn(t.params.d,o,r,t.id.length*131+t.id.charCodeAt(t.id.length-1)):new Path2D(t.params.d):new Path2D(a.map(E=>Ce(E.pts,E.closed)).join(" ")),c=Math.max(0,Math.min(1,f.end)-Math.max(0,f.start)),u=f.offset??0,d=!(c>=1&&u===0),k=Ln(t.ops);e.save(),k&&(e.globalCompositeOperation=is[k]),e.transform(...rt(t));for(const E of Pn(t.ops)){if(e.save(),e.transform(...E.m),t.type==="art"){c>0&&ss(e,t,f,r,E.alpha,o),e.setLineDash([]),e.filter="none",e.restore();continue}if(i.type!=="none"&&c>0&&t.type!=="line"&&(e.globalAlpha=t.opacity*(i.opacity??1)*Math.min(1,c)*E.alpha,e.fillStyle=ls(e,t,r),e.fill(h),i.texture&&tn(e,h,Gt(t,r),i.texture,i.color??i.stops?.[0]?.[0]??"#c6f432",t.id.length*97+t.id.charCodeAt(0))),l&&l.width>0&&c>0)if(e.globalAlpha=t.opacity*(l.opacity??1)*E.alpha,e.strokeStyle=l.color,e.lineWidth=l.width,e.lineCap=l.cap??"round",e.lineJoin=l.join??"round",e.miterLimit=10,l.blur&&(e.filter=`blur(${(l.blur*s*Math.abs(t.scale[0]||1)).toFixed(2)}px)`),l.hand){const p=o?{...l.hand,boil:Math.max(l.hand.boil??0,o.fps)}:l.hand;for(const S of t.params.d?[t.params.d]:a.map(w=>Ce(w.pts,w.closed))){const w=Le(S);ot(e,S,{color:l.color,width:l.width,from:((f.start+u)%1+1)%1*w,len:c*w,hand:p,time:r})}}else if(!d)l.dash&&l.dash[0]+l.dash[1]>0?(e.setLineDash(l.dash),e.lineDashOffset=-(l.dashOffset??0)):e.setLineDash([]),e.stroke(h);else if(t.params.d&&t.params.box){const p=on(t.params.d);if(p){const S=((f.start+u)%1+1)%1*p,w=c*p,g=Math.min(w,p-S);e.setLineDash([g,p*2]),e.lineDashOffset=-S,e.stroke(h),w>g&&(e.setLineDash([w-g,p*2]),e.lineDashOffset=0,e.stroke(h))}}else for(const p of t.params.d?[]:a){const S=jn(p.pts,p.closed);if(!S)continue;const w=new Path2D(Ce(p.pts,p.closed)),g=((f.start+u)%1+1)%1*S,_=c*S,M=Math.min(_,S-g),y=A=>{const P=l.dash;if(!P||P[0]+P[1]<=0)return[A,S*2];const L=P[0]+P[1],x=[];let $=0;for(let C=((l.dashOffset??0)%L+L)%L-L;C<A&&x.length<4e3;C+=L){const R=Math.max(0,C),v=Math.min(A,C+P[0]);v<=R||(x.length?x.push(R-$,v-R):(R>0&&x.push(0,R),x.push(v-R)),$=v)}return x.length?[...x,S*2]:[0,S*2]};e.setLineDash(y(M)),e.lineDashOffset=-g,e.stroke(w),_>M&&(e.setLineDash(y(_-M)),e.lineDashOffset=0,e.stroke(w))}e.setLineDash([]),e.filter="none",e.restore()}e.restore()}function ls(e,t,n){const r=t.fill;if(r.type==="color"||!r.stops)return r.color??"#c6f432";const[s,o,a,i]=Gt(t,n),l=s+(a-s)*(r.cx??.5),f=o+(i-o)*(r.cy??.5);let h;if(r.type==="radial")h=e.createRadialGradient(l,f,0,l,f,Math.max(1,Math.hypot(a-s,i-o)/2));else{const c=(r.angle??0)*Math.PI/180,u=Math.cos(c),d=Math.sin(c),k=Math.abs(u)*(a-s)/2+Math.abs(d)*(i-o)/2;h=e.createLinearGradient(l-u*k,f-d*k,l+u*k,f+d*k)}for(const[c,u]of r.stops)h.addColorStop(u,c);return h}function Ao(e,t,n,r,s){const o=-r/2,a=-s/2,i=Math.max(0,Math.min(1,n));if(e.beginPath(),t==="wipe-left")e.rect(o,a,r*i,s);else if(t==="wipe-right")e.rect(o+r*(1-i),a,r*i,s);else if(t==="wipe-down")e.rect(o,a,r,s*i);else if(t==="wipe-up")e.rect(o,a+s*(1-i),r,s*i);else if(t==="iris")e.arc(0,0,i*Math.hypot(r,s)/2,0,Math.PI*2);else if(t==="split-h")e.rect(-r*i/2,a,r*i,s);else if(t==="split-v")e.rect(o,-s*i/2,r,s*i);else if(t==="split-h-edges"){const l=r*i/2;e.rect(o,a,l,s),e.rect(r/2-l,a,l,s)}else if(t==="watercolor")if(i>=1)e.rect(o,a,r,s);else{const l=$n(i)*Math.hypot(r,s)/2;for(let f=0;f<256;f++){const h=f/256*Math.PI*2,c=l*(1+Cn(h)),u=Math.sin(h)*c,d=-Math.cos(h)*c;f?e.lineTo(u,d):e.moveTo(u,d)}e.closePath()}else if(i>=1&&/^(torn|blocks)/.test(t))e.rect(o,a,r,s);else if(t==="torn"||t==="torn-back"){const l=Rn(t==="torn"?i:1-i),f=In().map(c=>[o+(l-Dn(c))*r,a+c*s]),h=t==="torn"?o-r:o+2*r;e.moveTo(h,a);for(const[c,u]of f)e.lineTo(c,u);e.lineTo(h,a+s),e.closePath()}else if(t==="blocks"||t==="blocks-back"){const l=Bn.n,f=Math.max(r,s)/800;for(let h=0;h<l;h++)for(let c=0;c<l;c++){const u=Nn(c,h);(t==="blocks"?u<i:u>=1-i)&&e.rect(o+c*r/l-f,a+h*s/l-f,r/l+2*f,s/l+2*f)}}else e.moveTo(0,0),e.arc(0,0,Math.hypot(r,s),-Math.PI/2,-Math.PI/2+i*Math.PI*2),e.closePath();e.clip()}let Tt=null;const fs=()=>Tt??=Promise.all(Gn.map(async e=>{const t=await fetch(e.url);if(!t.ok)throw Error(`Font ${e.url}: HTTP ${t.status}`);return{name:e.name,weight:e.weight,style:"normal",data:await t.arrayBuffer()}})).catch(e=>{throw Tt=null,e});let vt=null;const cs=()=>vt??=U(()=>import("./index-DxdDhmLR.js"),__vite__mapDeps([0,1,2])).then(e=>e.default).catch(e=>{throw vt=null,e}),hs=48,ze=new Map,We=new Map,an=(e,t,n)=>(e.set(t,n),e.size>hs&&e.delete(e.keys().next().value),n);function us(e){const t=Ht(e);return ze.get(t)??an(ze,t,(async()=>{const[n,r]=await Promise.all([cs(),fs()]);return n(Fn(e),{width:e.width,height:e.height,fonts:r})})().catch(n=>{throw ze.delete(t),n}))}const ds=e=>Math.min(2,2560/Math.max(e.width,e.height));function Eo(e){const t=Ht(e);return We.get(t)??an(We,t,(async()=>{const n=await us(e),r=new Image,s=ds(e);r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await r.decode();const o=Object.assign(document.createElement("canvas"),{width:Math.round(e.width*s),height:Math.round(e.height*s)}),a=o.getContext("2d");if(!a)throw Error("Canvas unavailable");return a.drawImage(r,0,0,o.width,o.height),o})().catch(n=>{throw We.delete(t),n}))}const ps=Object.freeze({dark:"dark",light:"positron",atlas:"liberty",neon:"dark",lime:"dark",paper:"positron",mono:"positron",satellite:"positron"}),ms="https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless_3857/default/g/{z}/{y}/{x}.jpg",gs=14,ys="EOxCloudless 2016 https://cloudless.eox.at by EOX IT Services GmbH (Contains modified Copernicus Sentinel data 2016)",ie=Object.freeze({source:"sentinel",tiles:ms,maxzoom:gs,credit:ys}),ws="Powered by Esri · Source: Esri, Vantor, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community",ge=(e,t,n,r,s,o,a,i,l,f,h,c)=>({bg:e,land:t,park:n,water:r,waterLine:s,building:o,road:a,roadMajor:i,rail:l,boundary:f,text:h,halo:c}),bs=Object.freeze({neon:ge("#070b1a","#0b1226","#0c1a2a","#02040c","#0a2a55","#121c3a","#1b3b7a","#00e5ff","#233060","#ff2fd0","#bfe9ff","#050814"),lime:ge("#0b0d0a","#0f120d","#121a10","#050605","#1d2a16","#171c13","#2a3322","#c6ff3d","#2a3322","#9bcc2e","#e9ffc4","#070806"),paper:ge("#efe4cc","#e9dcc0","#d8d3a6","#b9cfc9","#9fbab4","#dccaa5","#fbf5e6","#c98f4a","#b8a888","#8a5a3c","#4a3a28","#f4ead4"),mono:ge("#f2f2f2","#ececec","#e2e2e2","#cfcfcf","#bdbdbd","#dedede","#ffffff","#9a9a9a","#c8c8c8","#6e6e6e","#3a3a3a","#f7f7f7")}),Ms=/motorway|trunk|primary|major/;function ln(e){const t=e["source-layer"]??"",n=e.id??"";return e.type==="background"?"bg":e.type==="symbol"?"label":t==="water"?"water":t==="waterway"?"waterLine":t==="park"||t==="landcover"?"park":t==="landuse"||t==="aeroway"?e.type==="line"?"road":"land":t==="building"?"building":t==="transportation"?/rail|transit/.test(n)?"rail":Ms.test(n)?"roadMajor":"road":t==="boundary"?"boundary":"other"}function _s(e,t){const n=ln(e),r={...e.paint??{}};if(n==="other")return e.type==="raster"||e.type==="hillshade"?null:e;if(n==="label")return r["text-color"]=t.text,r["text-halo-color"]=t.halo,{...e,paint:r};const s=n==="bg"?t.bg:t[n];return e.type==="background"?r["background-color"]=s:e.type==="fill"?(r["fill-color"]=s,delete r["fill-pattern"],"fill-outline-color"in r&&(r["fill-outline-color"]=s)):e.type==="fill-extrusion"?(r["fill-extrusion-color"]=s,delete r["fill-extrusion-pattern"]):e.type==="line"&&(r["line-color"]=s,delete r["line-pattern"]),{...e,paint:r}}function ks(e,t=ie){const n=[];for(const r of e.layers){const s=ln(r);if(s==="label")n.push({...r,paint:{...r.paint??{},"text-color":"#ffffff","text-halo-color":"rgba(0,0,0,.85)","text-halo-width":1.6}});else if(s==="boundary"&&r.type==="line"){const o=["<=",["get","admin_level"],4];n.push({...r,filter:r.filter?["all",r.filter,o]:o,paint:{...r.paint??{},"line-color":"rgba(255,255,255,.55)"}})}else s==="roadMajor"&&r.type==="line"&&n.push({...r,paint:{...r.paint??{},"line-color":"rgba(255,236,170,.22)"}})}return{...e,sources:{...e.sources,"cx-sat":{type:"raster",tiles:[t.tiles],tileSize:256,maxzoom:t.maxzoom,attribution:t.credit}},layers:[{id:"cx-sat-bg",type:"background",paint:{"background-color":"#0b0f12"}},{id:"cx-sat",type:"raster",source:"cx-sat",paint:{"raster-fade-duration":0}},...n]}}const Ot=Object.freeze({dark:"#30353f",light:"#e4e1da",atlas:"#ddd6cc",neon:"#26367a",lime:"#323d27",paper:"#dccaa5",mono:"#dcdcdc",satellite:"#d6d0c6"});function Lt(e,t=null,n=1){const r=typeof t=="string"&&/^#[0-9a-f]{6}$/i.test(t)?t:Ot[e]??Ot.dark,s=Math.max(0,Math.min(2,Number(n)||1));return"#"+[1,3,5].map(o=>Math.min(255,Math.round(parseInt(r.slice(o,o+2),16)*s)).toString(16).padStart(2,"0")).join("")}function Ss(e,t,n=ie){if(e==="satellite")return ks(t,n??ie);const r=bs[e];return r?{...t,layers:t.layers.map(s=>_s(s,r)).filter(Boolean)}:t}function As(e,t,n=ie){return e==="satellite"?[(n??ie).credit,t]:[t]}function Es(e,t,n){const r=[];for(const s of e){let o="";for(const a of String(s).split(" ")){const i=o?o+" "+a:a;o&&t(i)>n?(r.push(o),o=a):o=i}o&&r.push(o)}return r}const xs=e=>zn[e];function Ts(e,t,n,r,s,o){Hn(e,t,n,r,s,o,xs)}const Pt=Object.fromEntries(Object.entries(ps).map(([e,t])=>[e,`https://tiles.openfreemap.org/styles/${t}`])),vs="OpenFreeMap © OpenMapTiles · Data © OpenStreetMap contributors",Os=[110.8,15.4,113.2,17.4],Ls=[111.2,6,118,12.2],jt=([e,t,n,r])=>[[e,t],[n,t],[n,r],[e,r],[e,t]],$t={type:"MultiPolygon",coordinates:[[jt(Os)],[jt(Ls)]]},Ps=e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{name:e==="vi"?`Quần đảo Hoàng Sa
157
+ <\/script>`;let G=null,ee=null,Br=0;const Ae=new Map,Ee=new Map;function Nr(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)+":"+e.length}let te=null;function Fr(){return te||(te=Promise.all(bn.map(async t=>{const n=await fetch(Mn+t.file);if(!n.ok)throw Error(t.file);return{family:t.family,weight:t.weight,style:t.style,data:await n.arrayBuffer()}})).catch(()=>(te=null,[])),te)}let Ne=null,be=null;function Gr(){return Ne??=Promise.all([U(()=>import("./three-D7Ssject.js"),[]),U(()=>import("./RoomEnvironment-grxZ6k9f.js"),[])]).then(([e,t])=>({src:e.default,room:_n(t.default)})).catch(e=>{throw Ne=null,e}),Ne}function Hr(){return be??=Gr().then(e=>{G?.contentWindow?.postMessage({type:"three",src:e.src,room:e.room},"*")}).catch(e=>{throw be=null,e}),be}let Fe=null,Me=null;function zr(){return Fe??=Promise.all([U(()=>import("./opentype-D4-4HGq7.js"),[]),...Object.entries(Sn).map(async([e,t])=>{const n=await fetch(t);if(!n.ok)throw Error(`Font ${n.status}`);return{key:e,data:await n.arrayBuffer()}})]).then(([e,...t])=>({src:e.default,fonts:t})).catch(e=>{throw Fe=null,e}),Fe}function Wr(){return Me??=zr().then(e=>{G?.contentWindow?.postMessage({type:"glyphs",src:e.src,fonts:e.fonts.map(t=>({key:t.key,data:t.data.slice(0)}))},"*")}).catch(e=>{throw Me=null,e}),Me}const Ge=new Map;let _e=new Map;function qr(e){return Promise.all(e.map(t=>{let n=_e.get(t);if(!n){let r=Ge.get(t);r||(r=fetch(mr(t)).then(s=>s.ok?s.arrayBuffer():null).catch(()=>null),Ge.set(t,r)),n=r.then(s=>{if(!s){Ge.delete(t),_e.delete(t);return}G?.contentWindow?.postMessage({type:"stickers",items:[{id:t,data:s.slice(0)}]},"*")}),_e.set(t,n)}return n}))}let He=null,ke=null;function Ur(){return He??=Promise.all([U(()=>import("./GLTFLoader-DYtnVu-I.js"),[]),U(()=>import("./BufferGeometryUtils-_ZXHoOh1.js"),[]),U(()=>import("./SkeletonUtils-CfWUgbiL.js"),[])]).then(([e,t,n])=>{const r=De(e.default),s=De(t.default),o=De(n.default);if(!r||!s||!o)throw Error("GLTFLoader shape changed");return{gltf:r,bgu:s,skel:o}}).catch(e=>{throw He=null,e}),He}function Kr(){return ke??=Ur().then(e=>{G?.contentWindow?.postMessage({type:"gltf",...e},"*")}).catch(e=>{throw ke=null,e}),ke}const xe=new Map,J=new Map;function yo(e,t){const n=t.slice().buffer;xe.set(e,n),J.delete(`local:${e}`)}function wo(e){for(const t of[...xe.keys()])t.startsWith(e)&&(xe.delete(t),J.delete(`local:${t}`))}let ne=null;function Vr(e){if(!ne){const t={uris:new Set,run:Promise.resolve({})};t.run=new Promise(n=>setTimeout(n,0)).then(()=>(ne=null,yr([...t.uris]))),ne=t}return ne.uris.add(e),ne.run.then(t=>{const n=t[e];if(!n)throw Error(le("Không tải được tài nguyên của lớp plug-in ({0}).",[e.split("/").pop()||"?"]));return n})}function Jr(e){let t=J.get(e);return t||(t=e.startsWith("local:")?Promise.resolve().then(()=>{const n=xe.get(e.slice(6));if(!n)throw Error("local asset missing");return n}):Vr(e).then(n=>fetch(n)).then(n=>{if(!n.ok)throw Error(le("Không tải được tài nguyên của lớp plug-in ({0}).",[e.split("/").pop()||"?"]));return n.arrayBuffer()}),J.set(e,t),t.catch(()=>J.delete(e)),J.size>64&&J.delete(J.keys().next().value)),t}async function Yr(e,t){const n=kr(t),r=await Jr(n.uri),s=new Uint8Array(r),o={...n.grid?{grid:n.grid}:{},...n.fps?{fps:n.fps}:{}};if(s[0]===103&&s[1]===108&&s[2]===84&&s[3]===70)return{name:e,kind:"model",data:r.slice(0)};if(s[0]===67&&s[1]===88&&s[2]===83&&s[3]===81)return{name:e,kind:"sequence",frames:$r(s).map(a=>a.slice().buffer),...o};if(/\.cube$/i.test(e)||/\.cube$/i.test(n.uri)){const a=kn(Dt(new TextDecoder().decode(s)));return{name:e,kind:"lut",size:a.size,data:a.data.buffer.slice(0)}}return{name:e,kind:"image",data:r.slice(0),...o}}const Te=new Map;async function Xr(e,t,n){const r=t.assets;if(!r||!Object.keys(r).length)return;const s=JSON.stringify(r);if(Te.get(e)===s)return;n&&await Kr().catch(()=>{throw Error(le("Không tải được bộ đọc mô hình 3D — kiểm tra mạng rồi thử lại."))});const a=(await Promise.all(Object.entries(r).map(([i,l])=>Yr(i,l)))).map(i=>i.kind==="lut"?{...i,data:new Float32Array(i.data)}:i);G?.contentWindow?.postMessage({type:"assets",layer:e,items:a},"*"),Te.set(e,s)}function Zr(){if(ee&&G?.isConnected)return ee;G?.remove(),Ee.clear(),ae.clear(),_e=new Map,be=null,Me=null,ke=null,Te.clear();const e=document.createElement("iframe");return G=e,e.setAttribute("sandbox","allow-scripts"),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.title="motion-sandbox",e.style.cssText="position:fixed;width:1px;height:1px;left:-10px;top:-10px;border:0;opacity:0;pointer-events:none",e.srcdoc=Dr,ee=new Promise((t,n)=>{const r=window.setTimeout(()=>{window.removeEventListener("message",s),G===e&&(G.remove(),G=null,ee=null),n(Error("Motion sandbox did not start"))},8e3),s=o=>{o.source===e.contentWindow&&o.data?.type==="boot"&&(window.clearTimeout(r),window.removeEventListener("message",s),Fr().then(a=>{e.contentWindow?.postMessage({type:"fonts",fonts:a},"*"),t()}))};window.addEventListener("message",s)}),document.body.appendChild(e),ee}window.addEventListener("message",e=>{if(!G||e.source!==G.contentWindow||e.data?.type!=="frame")return;const t=Ae.get(e.data.req);t&&(Ae.delete(e.data.req),window.clearTimeout(t.timer),e.data.bmp?t.resolve(e.data.bmp):t.reject(Error(e.data.error===Xt?le("Trình duyệt không chạy được WebGL nên không vẽ được lớp Motion 3D. Hãy bật tăng tốc phần cứng hoặc dùng Chrome / Edge bản mới."):String(e.data.error||"Motion frame failed"))))});const ae=new Map,ve=new Map,Qr=1500;let Oe=Promise.resolve(),wt=Promise.resolve(),Xe=0,Ze=-1/0;async function es(){for(;;){const e=Oe;if(await e,e!==Oe)continue;const t=Ze+Qr-performance.now();if(!Xe&&t<=0)return;await new Promise(n=>window.setTimeout(n,Math.max(100,t)))}}async function bo(e){await Zr();const t=yn(e.motion.code),n=e.motion.kind==="three",r=Nr(e.motion.assets?t+"\0"+JSON.stringify(e.motion.assets):t);n&&await Hr(),await Xr(e.layer,e.motion,n),n&&wn(t)&&await Wr().catch(()=>{throw Error(le("Không tải được phông chữ cho chữ 3D nổi — kiểm tra mạng rồi thử lại."))});const s=n?[]:pr(t,e.motion.params||{});if(s.length&&await qr(s),!n)return Qe(e,t,r);if(!e.background){Xe++,Ze=performance.now();try{return await bt(e,t,r)}finally{Xe--,Ze=performance.now()}}return bt(e,t,r)}function bt(e,t,n){const r=n+"|"+JSON.stringify(e.motion.params||{})+"|"+e.width+"x"+e.height;if(ae.get(e.layer)===r)return Qe(e,t,n);const s=ve.get(e.layer)??0,o=G,a=()=>{if((ve.get(e.layer)??0)!==s||G!==o)throw Error("dropped");return Qe(e,t,n).then(l=>(G===o&&ae.set(e.layer,r),l),l=>{throw ae.delete(e.layer),l})};if(e.background){const l=wt.then(es).then(a);return wt=l.catch(()=>{}),l}const i=Oe.then(a);return Oe=i.catch(()=>{}),i}function Qe(e,t,n){const r=e.motion.kind==="three",s=++Br,o=Ee.get(e.layer)!==n;return Ee.set(e.layer,n),new Promise((a,i)=>{const l=window.setTimeout(()=>{Ae.delete(s),i(Error("Motion frame timed out"))},(r?Jt:o?Yt:Vt)+2e3);Ae.set(s,{resolve:a,reject:i,timer:l}),G.contentWindow.postMessage({type:"frame",req:s,layer:e.layer,key:n,code:t,params:e.motion.params||{},t:e.t,width:e.width,height:e.height,duration:e.duration,fps:e.fps??30,...r?{kind:"three",surface:e.surface??null}:{space:e.space??null,cpu:!!e.cpu}},"*")})}function Mo(e){ve.set(e,(ve.get(e)??0)+1),ae.delete(e),Te.delete(e),G?.contentWindow&&Ee.delete(e)&&G.contentWindow.postMessage({type:"drop",layer:e},"*")}function z(e,t){let n=Math.imul(e^2654435769,2246822507)^Math.imul(t+1,3266489909);return n^=n>>>13,n=Math.imul(n,668265263),n^=n>>>16,(n>>>0)/4294967296}const Zt=(e,t)=>{const n=Math.floor(e),r=e-n,s=r*r*(3-2*r);return(z(n,t)*(1-s)+z(n+1,t)*s)*2-1},Qt=e=>{let t=7;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0},he=new Map;function en(e,t,n,r){const s=`${e}|${t.toFixed(2)}|${n%7}|${r}`;let o=he.get(s);if(o)return o;he.size>64&&he.clear();const a=128,i=n%7;o=Object.assign(document.createElement("canvas"),{width:a,height:a});const l=o.getContext("2d"),f=l.createImageData(a,a),[h,c,u]=[1,3,5].map(p=>parseInt(e.slice(p,p+2),16)),d=new Float32Array(a*a);for(let p=0;p<a*a;p++)d[p]=z(p,i+9);const k=(p,S)=>d[(S+a)%a*a+(p+a)%a],E=r?1-t*.35:t*.4;for(let p=0;p<a;p++)for(let S=0;S<a;S++){let w=0;for(let M=-1;M<=1;M++)for(let y=-1;y<=1;y++)w+=k(S+y,p+M);const g=Math.min(1,Math.max(0,((w/9-.5)*2.4+.5)*.6+.4*k(S,p))),_=(p*a+S)*4;f.data[_]=h,f.data[_+1]=c,f.data[_+2]=u,f.data[_+3]=g>E?r?Math.round(160+95*(g-E)/(1-E+1e-6)):255:0}return l.putImageData(f,0,0),he.set(s,o),o}function ts(e,t,n,r=0){return e.createPattern(en(t,Math.max(0,Math.min(1,n)),r,!1),"repeat")??t}function ue(e,t,n,r=0){return e.createPattern(en(t,Math.max(0,Math.min(1,n)),r,!0),"repeat")??t}function tn(e,t,n,r,s,o){const a=r.amount??.5,i=r.scale??1,l=r.color??En(s,null),[f,h,c,u]=n,d=(f+c)/2,k=(h+u)/2,E=Math.hypot(c-f,u-h)/2+4,p=(r.angle??0)*Math.PI/180;e.save(),r.type==="riso"&&(e.save(),e.globalAlpha*=.42*a,e.globalCompositeOperation="multiply",e.translate(4*i,-3*i),e.fillStyle=l,e.fill(t),e.restore()),e.clip(t);const S=(w,g,_,M)=>{e.save(),e.globalAlpha*=M,e.strokeStyle=l,e.lineWidth=_,e.lineCap="butt",e.translate(d,k),e.rotate(w),e.beginPath();for(let y=-E;y<=E;y+=g){const A=Zt(y/g,o+5)*g*.12;e.moveTo(-E,y+A),e.lineTo(E,y-A)}e.stroke(),e.restore()};switch(r.type){case"hatch":S(p,13*i,1.4+a*2.6,.35+a*.55);break;case"crosshatch":S(p,12*i,1.2+a*2,.3+a*.5),S(p+Math.PI/2,12*i,1.2+a*2,.25+a*.45);break;case"halftone":case"riso":{const w=(r.type==="riso"?9:12)*i;e.save(),e.fillStyle=l,e.globalAlpha*=r.type==="riso"?.5:.85,e.translate(d,k),e.rotate(p),e.beginPath();for(let g=-E;g<=E;g+=w)for(let _=-E;_<=E;_+=w){const M=.25+.75*Math.max(0,Math.min(1,(_+g)/(2*E)+.5)),y=w*.5*Math.sqrt(a*M);y>.3&&(e.moveTo(_+y,g),e.arc(_,g,y,0,Math.PI*2))}e.fill(),e.restore(),r.type==="riso"&&(e.globalAlpha*=.5,e.fillStyle=ue(e,"#ffffff",.3+a*.4,o),e.fillRect(f-4,h-4,c-f+8,u-h+8));break}case"grain":e.globalAlpha*=.3+a*.3,e.fillStyle=ue(e,l,.2+a*.5,o),e.fillRect(f-4,h-4,c-f+8,u-h+8);break;case"stipple":{const w=10*i,g=Math.min(4e3,Math.round((c-f)*(u-h)/(w*w)*a*1.6));e.fillStyle=l,e.globalAlpha*=.8,e.beginPath();for(let _=0;_<g;_++){const M=f+z(_,o+1)*(c-f),y=h+z(_,o+2)*(u-h),A=.9+z(_,o+3)*1.4*i;e.moveTo(M+A,y),e.arc(M,y,A,0,Math.PI*2)}e.fill();break}case"wash":{for(let w=0;w<3;w++){const g=f+(c-f)*(.2+.6*z(w,o+4)),_=h+(u-h)*(.2+.6*z(w,o+6)),M=Math.max(8,Math.min(c-f,u-h)*(.35+.3*z(w,o+8))),y=e.createRadialGradient(g,_,0,g,_,M);y.addColorStop(0,l),y.addColorStop(1,l+"00"),e.save(),e.globalAlpha*=.22*a,e.fillStyle=y,e.fillRect(g-M,_-M,M*2,M*2),e.restore()}e.save(),e.globalAlpha*=.5*a,e.strokeStyle=l,e.lineWidth=7*i,e.lineJoin="round",e.stroke(t),e.restore(),e.globalAlpha*=.25,e.fillStyle=ue(e,l,.3,o),e.fillRect(f-4,h-4,c-f+8,u-h+8);break}case"paper":{e.save(),e.globalAlpha*=.2+a*.2,e.fillStyle=ue(e,l,.2+a*.4,o),e.fillRect(f-4,h-4,c-f+8,u-h+8),e.restore();const w=Math.min(900,Math.round((c-f)*(u-h)/4e3*a*i));e.strokeStyle=l,e.lineWidth=.7,e.globalAlpha*=.18,e.beginPath();for(let g=0;g<w;g++){const _=f+z(g,o+11)*(c-f),M=h+z(g,o+12)*(u-h),y=z(g,o+13)*Math.PI*2,A=6+z(g,o+14)*14;e.moveTo(_,M),e.quadraticCurveTo(_+Math.cos(y+.6)*A*.6,M+Math.sin(y+.6)*A*.6,_+Math.cos(y)*A,M+Math.sin(y)*A)}e.stroke();break}case"grid":{const w=40*i;e.strokeStyle=l,e.beginPath();const g=Math.floor(f/w)*w,_=Math.floor(h/w)*w;for(let M=g;M<=c;M+=w)e.moveTo(M,h),e.lineTo(M,u);for(let M=_;M<=u;M+=w)e.moveTo(f,M),e.lineTo(c,M);e.lineWidth=1.2,e.globalAlpha*=.35*a+.1,e.stroke(),e.beginPath();for(let M=Math.floor(f/(w*5))*w*5;M<=c;M+=w*5)e.moveTo(M,h),e.lineTo(M,u);for(let M=Math.floor(h/(w*5))*w*5;M<=u;M+=w*5)e.moveTo(f,M),e.lineTo(c,M);e.lineWidth=2.4,e.stroke();break}}e.restore()}const nn=(e,t,n,r)=>t*Zt(e/38,r+n*977);function ns(e,t,n,r){const s=Math.floor(n*t.fps+1e-6),o=Qt(r)+(t.seed??0)*131|0;return e.map((a,i)=>{const l=An(a.pts,a.closed,10);if(l.length<2)return a;const f=[];let h=0;const c=a.closed&&l.length>2?l.length-1:l.length;for(let u=0;u<c;u++){u&&(h+=Math.hypot(l[u][0]-l[u-1][0],l[u][1]-l[u-1][1]));const d=l[Math.max(0,u-1)],k=l[Math.min(l.length-1,u+1)],E=k[0]-d[0],p=k[1]-d[1],S=Math.hypot(E,p)||1,w=nn(h,t.amount,s,o+i*17);f.push([l[u][0]-p/S*w,l[u][1]+E/S*w])}return{pts:f,closed:a.closed}})}const de=new Map;function rn(e,t,n,r){const s=Math.floor(n*t.fps+1e-6),o=`${s}|${r}|${t.amount}|${e}`;let a=de.get(o);if(a)return a;de.size>600&&de.clear();const i=as(e);if(a=new Path2D,!i.L)return a.addPath(new Path2D(e)),a;const l=new Set;let f=0;const h=c=>{if(!(c-f+1<2)){for(let d=f;d<=c;d++){const k=Math.max(f,d-1),E=Math.min(c,d+1),p=i.xs[E]-i.xs[k],S=i.ys[E]-i.ys[k],w=Math.hypot(p,S)||1,g=nn(i.ss[d],t.amount,s,r),_=i.xs[d]-S/w*g,M=i.ys[d]+p/w*g;d===f?a.moveTo(_,M):a.lineTo(_,M)}Math.hypot(i.xs[c]-i.xs[f],i.ys[c]-i.ys[f])<i.step*2&&(a.closePath(),l.add(f))}};for(let c=1;c<i.ss.length;c++)Math.hypot(i.xs[c]-i.xs[c-1],i.ys[c]-i.ys[c-1])>i.step*3&&(h(c-1),f=c);return h(i.ss.length-1),de.set(o,a),a}const pe=new Map,rs=e=>{let t=pe.get(e);return t||(pe.size>2e3&&pe.clear(),t=new Path2D(e),pe.set(e,t)),t},Mt=e=>{const t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)};function ss(e,t,n,r,s,o){const a=t.params,i={...a,parts:a.rig?gr(t,r):a.parts??[]},l=t.stroke,f=t.fill,h=f.type!=="none",c=M=>!!l&&l.width>0&&M.line!==!1&&(M.fill===null||i.outline!==!1),u=Math.max(0,Math.min(1,n.end)-Math.max(0,n.start)),d=u>=1&&!n.offset,k=i.parts.map(M=>d?1:Math.max(1,Le(M.d))),E=i.parts.map((M,y)=>c(M)?k[y]:d?1:Math.max(40,k[y]*.35)),p=E.reduce((M,y)=>M+y,0)||1,S=Math.max(0,n.start)*p,w=S+u*p,g=Qt(t.id)+(o?.seed??0)*131;let _=0;i.parts.forEach((M,y)=>{const A=E[y],P=_;_=_+A;const x=d?1:Math.max(0,Math.min(1,(w-P)/A))-Math.max(0,Math.min(1,(S-P)/A));if(x<=0)return;const $=o?rn(M.d,o,r,g+y*29):rs(M.d),C=v=>{if(!c(M)||!l)return;e.globalAlpha=s*t.opacity*(l.opacity??1)*(M.o??1);const m=Le(M.d),b=d?m:m*x,O=l.width*(M.lw??1)*(v?2:1);if(l.hand){const j={...l.hand,...o?{boil:Math.max(l.hand.boil??0,o.fps)}:{}};ot(e,M.d,{color:l.color,width:O,from:d?0:Math.max(0,(S-P)/A)*m,len:b,hand:j,time:r})}else e.strokeStyle=l.color,e.lineWidth=O,e.lineCap=l.cap??"round",e.lineJoin=l.join??"round",d||!m?e.setLineDash([]):(e.setLineDash([b,m*2]),e.lineDashOffset=-Math.max(0,(S-P)/A)*m),e.stroke($),e.setLineDash([])},R=h&&!!M.fill;if(R&&C(!0),R){if(e.globalAlpha=s*t.opacity*(f.opacity??1)*(M.o??1)*(d?1:c(M)?Mt((x-.6)/.4):Mt(x)),e.globalAlpha>0){e.fillStyle=M.fill,M.eo?e.fill($,"evenodd"):e.fill($);const v=f.texture;v&&(e.save(),M.eo&&e.clip($,"evenodd"),tn(e,$,os(M.d),v,M.fill,g+y),e.restore())}}else C(!1)})}const me=new Map;function os(e){let t=me.get(e);if(t)return t;const n=e.match(/-?\d*\.?\d+(?:e[-+]?\d+)?/gi)?.map(Number)??[];let r=1/0,s=1/0,o=-1/0,a=-1/0;for(let i=0;i+1<n.length;i+=2)r=Math.min(r,n[i]),o=Math.max(o,n[i]),s=Math.min(s,n[i+1]),a=Math.max(a,n[i+1]);return t=Number.isFinite(r)?[r,s,o,a]:[-50,-50,50,50],me.size>2e3&&me.clear(),me.set(e,t),t}const re=new Map;function st(e){let t=re.get(e);if(t)return t;re.size>400&&re.clear();const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",e);let r=0;try{r=n.getTotalLength()}catch{r=0}if(!Number.isFinite(r)||r<=0)return t={xs:new Float32Array(0),ys:new Float32Array(0),ss:new Float32Array(0),L:0,step:1},re.set(e,t),t;const s=Math.max(1.5,r/900),o=Math.ceil(r/s)+1,a=new Float32Array(o),i=new Float32Array(o),l=new Float32Array(o);for(let f=0;f<o;f++){const h=Math.min(r,f*s),c=n.getPointAtLength(h);a[f]=c.x,i[f]=c.y,l[f]=h}return t={xs:a,ys:i,ss:l,L:r,step:s},re.set(e,t),t}const Le=e=>st(e).L,as=e=>st(e);function _t(e,t){let n=Math.imul(e^2654435769,2246822507)^Math.imul(t+1,3266489909);return n^=n>>>13,n=Math.imul(n,668265263),n^=n>>>16,(n>>>0)/4294967296*2-1}function kt(e,t){const n=Math.floor(e),r=e-n,s=r*r*(3-2*r);return _t(n,t)*(1-s)+_t(n+1,t)*s}const St=e=>{const t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)};function At(e,t,n,r,s,o,a,i,l,f=0){if(r-n+1<2)return;const c=t.ss[r]-t.ss[n],u=[],d=[],k=Math.max(.001,Math.min(c*.15,s*3)),E=Math.max(.001,Math.min(c*.22,s*4));for(let p=n;p<=r;p++){const S=Math.max(n,p-1),w=Math.min(r,p+1),g=t.xs[w]-t.xs[S],_=t.ys[w]-t.ys[S],M=Math.hypot(g,_)||1,y=-_/M,A=g/M,P=t.ss[p],L=P-t.ss[n],x=kt(P/(s*3+24),a)*o.wobble*s,$=1+o.press*kt(P/(s*6+48),a+7),C=o.tip+(1-o.tip)*Math.min(St(L/k),St((c-L)/E)),R=Math.max(.15,s/2*$*C),v=t.xs[p]+y*x,m=t.ys[p]+A*x;u.push(v+y*R,m+A*R),d.push(v-y*R,m-A*R)}e.beginPath(),e.moveTo(u[0],u[1]);for(let p=2;p<u.length;p+=2)e.lineTo(u[p],u[p+1]);for(let p=d.length-2;p>=0;p-=2)e.lineTo(d[p],d[p+1]);if(e.closePath(),e.fill(),f>0){const p=e.globalAlpha;e.globalAlpha=p*f,e.lineWidth=Math.max(.4,s*.07),e.lineJoin="round",e.strokeStyle=e.fillStyle,e.stroke(),e.globalAlpha=p}}function ot(e,t,n){const r=st(t);if(!r.L||n.len<=0)return;let s=ft[n.hand.style]??xn[n.hand.style]??ft.marker;(n.hand.taper!==void 0||n.hand.press!==void 0)&&(s={...s,...n.hand.taper!==void 0?{tip:Math.max(.02,1-n.hand.taper)}:{},...n.hand.press!==void 0?{press:n.hand.press*.6}:{}});const o=Math.max(.5,n.width*s.width),a=n.hand.boil?Math.floor(n.time*n.hand.boil+1e-6):0,i=(n.hand.seed??0)*131+a*977|0,l=r.L,f=Math.max(0,Math.min(l,n.from)),h=Math.min(l,n.len),c=f+h<=l+1e-6?[[f,Math.min(l,f+h)]]:[[f,l],[0,f+h-l]],u=e.globalAlpha;e.save(),e.fillStyle=s.grain?ts(e,n.color,s.grain,n.hand.seed??0):n.color;const d=s.wet?[[1,s.alpha*.5,i],[.9,s.alpha*.4,i+11],[1.08,s.alpha*.3,i+23]]:[[1,s.alpha,i]];s.retrace&&d.push([.45,s.alpha*.35,i+3]);for(const[k,E,p]of d){e.globalAlpha=u*E;for(const[S,w]of c){let g=-1;for(let _=0;_<r.ss.length;_++){const M=r.ss[_]>=S-1e-6&&r.ss[_]<=w+1e-6,y=g>=0&&_>g&&Math.hypot(r.xs[_]-r.xs[_-1],r.ys[_]-r.ys[_-1])>r.step*3;g>=0&&(!M||y)&&(At(e,r,g,_-1,o*k,s,p,!0,!0,s.wet?.5:0),g=-1),M&&g<0&&(g=_)}g>=0&&At(e,r,g,r.ss.length-1,o*k,s,p,!0,!0,s.wet?.5:0)}}e.restore()}const _o=e=>"paths"in e?e.trim?.offset??0:0,sn=1280,Se=720,ko=e=>e&&"size"in e&&e.size?{W:e.size[0],H:e.size[1]}:e?.square?{W:Se,H:Se}:{W:sn,H:Se},Et=new Map;function on(e){let t=Et.get(e);if(t===void 0){const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",e);try{t=n.getTotalLength()}catch{t=0}Et.set(e,t=Number.isFinite(t)?t:0)}return t}function So(e,t,n,r=sn,s=Se,o=0){const a=Math.min(r,s)/V,i=(r-V*a)/2,l=(s-V*a)/2;if(tt(t)){const c=t.step&&t.step>1?Tn(o,t.step):o,u=t.boil&&t.boil.amount>0?t.boil:null,d=t.items.map(E=>nt(E,c)),k=vn(t.items,d);e.save(),e.translate(i,l),e.scale(a,a),t.items.forEach((E,p)=>{if(E.hidden||E.span&&(o<E.span[0]-1e-6||o>=E.span[1]-1e-6))return;const S=k.get(E.id);S?(e.save(),e.transform(...S),xt(e,d[p],n,c,a,u),e.restore()):xt(e,d[p],n,c,a,u)}),e.restore();return}const f=Math.max(0,Math.min(1,n.end)-Math.max(0,n.start)),h=n.offset??0;e.save(),e.translate(i,l),e.scale(a,a);for(const c of t.paths){const u=new Path2D(c.d),d=c.opacity??1;if(e.filter=c.blur?`blur(${(c.blur*a).toFixed(2)}px)`:"none",c.fill&&f>0&&(e.globalAlpha=Math.min(1,f)*d,e.fillStyle=c.fill,c.rule?e.fill(u,c.rule):e.fill(u),e.globalAlpha=1),!c.stroke||f<=0)continue;if(e.globalAlpha=d,c.hand){const w=Le(c.d);ot(e,c.d,{color:c.stroke,width:c.strokeWidth??18,from:((n.start+h)%1+1)%1*w,len:f*w,hand:c.hand,time:o}),e.globalAlpha=1;continue}if(e.strokeStyle=c.stroke,e.lineWidth=c.strokeWidth??18,e.lineCap=c.cap??"round",e.lineJoin="round",f>=1&&h===0){e.setLineDash([]),e.stroke(u),e.globalAlpha=1;continue}const k=on(c.d);if(!k)continue;const E=((n.start+h)%1+1)%1*k,p=f*k,S=Math.min(p,k-E);e.setLineDash([S,k*2]),e.lineDashOffset=-E,e.stroke(u),p>S&&(e.setLineDash([p-S,k*2]),e.lineDashOffset=0,e.stroke(u))}e.setLineDash([]),e.globalAlpha=1,e.filter="none",e.restore()}const is={add:"source-over",subtract:"destination-out",intersect:"destination-in",exclude:"xor"};function xt(e,t,n,r,s=1,o=null){const a=o&&!t.params.d&&t.type!=="art"?ns(ct(t,r),o,r,t.id):ct(t,r),i=t.fill,l=t.stroke,f=On(t.ops,n),h=t.params.d?o?rn(t.params.d,o,r,t.id.length*131+t.id.charCodeAt(t.id.length-1)):new Path2D(t.params.d):new Path2D(a.map(E=>Ce(E.pts,E.closed)).join(" ")),c=Math.max(0,Math.min(1,f.end)-Math.max(0,f.start)),u=f.offset??0,d=!(c>=1&&u===0),k=Ln(t.ops);e.save(),k&&(e.globalCompositeOperation=is[k]),e.transform(...rt(t));for(const E of Pn(t.ops)){if(e.save(),e.transform(...E.m),t.type==="art"){c>0&&ss(e,t,f,r,E.alpha,o),e.setLineDash([]),e.filter="none",e.restore();continue}if(i.type!=="none"&&c>0&&t.type!=="line"&&(e.globalAlpha=t.opacity*(i.opacity??1)*Math.min(1,c)*E.alpha,e.fillStyle=ls(e,t,r),e.fill(h),i.texture&&tn(e,h,Gt(t,r),i.texture,i.color??i.stops?.[0]?.[0]??"#c6f432",t.id.length*97+t.id.charCodeAt(0))),l&&l.width>0&&c>0)if(e.globalAlpha=t.opacity*(l.opacity??1)*E.alpha,e.strokeStyle=l.color,e.lineWidth=l.width,e.lineCap=l.cap??"round",e.lineJoin=l.join??"round",e.miterLimit=10,l.blur&&(e.filter=`blur(${(l.blur*s*Math.abs(t.scale[0]||1)).toFixed(2)}px)`),l.hand){const p=o?{...l.hand,boil:Math.max(l.hand.boil??0,o.fps)}:l.hand;for(const S of t.params.d?[t.params.d]:a.map(w=>Ce(w.pts,w.closed))){const w=Le(S);ot(e,S,{color:l.color,width:l.width,from:((f.start+u)%1+1)%1*w,len:c*w,hand:p,time:r})}}else if(!d)l.dash&&l.dash[0]+l.dash[1]>0?(e.setLineDash(l.dash),e.lineDashOffset=-(l.dashOffset??0)):e.setLineDash([]),e.stroke(h);else if(t.params.d&&t.params.box){const p=on(t.params.d);if(p){const S=((f.start+u)%1+1)%1*p,w=c*p,g=Math.min(w,p-S);e.setLineDash([g,p*2]),e.lineDashOffset=-S,e.stroke(h),w>g&&(e.setLineDash([w-g,p*2]),e.lineDashOffset=0,e.stroke(h))}}else for(const p of t.params.d?[]:a){const S=jn(p.pts,p.closed);if(!S)continue;const w=new Path2D(Ce(p.pts,p.closed)),g=((f.start+u)%1+1)%1*S,_=c*S,M=Math.min(_,S-g),y=A=>{const P=l.dash;if(!P||P[0]+P[1]<=0)return[A,S*2];const L=P[0]+P[1],x=[];let $=0;for(let C=((l.dashOffset??0)%L+L)%L-L;C<A&&x.length<4e3;C+=L){const R=Math.max(0,C),v=Math.min(A,C+P[0]);v<=R||(x.length?x.push(R-$,v-R):(R>0&&x.push(0,R),x.push(v-R)),$=v)}return x.length?[...x,S*2]:[0,S*2]};e.setLineDash(y(M)),e.lineDashOffset=-g,e.stroke(w),_>M&&(e.setLineDash(y(_-M)),e.lineDashOffset=0,e.stroke(w))}e.setLineDash([]),e.filter="none",e.restore()}e.restore()}function ls(e,t,n){const r=t.fill;if(r.type==="color"||!r.stops)return r.color??"#c6f432";const[s,o,a,i]=Gt(t,n),l=s+(a-s)*(r.cx??.5),f=o+(i-o)*(r.cy??.5);let h;if(r.type==="radial")h=e.createRadialGradient(l,f,0,l,f,Math.max(1,Math.hypot(a-s,i-o)/2));else{const c=(r.angle??0)*Math.PI/180,u=Math.cos(c),d=Math.sin(c),k=Math.abs(u)*(a-s)/2+Math.abs(d)*(i-o)/2;h=e.createLinearGradient(l-u*k,f-d*k,l+u*k,f+d*k)}for(const[c,u]of r.stops)h.addColorStop(u,c);return h}function Ao(e,t,n,r,s){const o=-r/2,a=-s/2,i=Math.max(0,Math.min(1,n));if(e.beginPath(),t==="wipe-left")e.rect(o,a,r*i,s);else if(t==="wipe-right")e.rect(o+r*(1-i),a,r*i,s);else if(t==="wipe-down")e.rect(o,a,r,s*i);else if(t==="wipe-up")e.rect(o,a+s*(1-i),r,s*i);else if(t==="iris")e.arc(0,0,i*Math.hypot(r,s)/2,0,Math.PI*2);else if(t==="split-h")e.rect(-r*i/2,a,r*i,s);else if(t==="split-v")e.rect(o,-s*i/2,r,s*i);else if(t==="split-h-edges"){const l=r*i/2;e.rect(o,a,l,s),e.rect(r/2-l,a,l,s)}else if(t==="watercolor")if(i>=1)e.rect(o,a,r,s);else{const l=$n(i)*Math.hypot(r,s)/2;for(let f=0;f<256;f++){const h=f/256*Math.PI*2,c=l*(1+Cn(h)),u=Math.sin(h)*c,d=-Math.cos(h)*c;f?e.lineTo(u,d):e.moveTo(u,d)}e.closePath()}else if(i>=1&&/^(torn|blocks)/.test(t))e.rect(o,a,r,s);else if(t==="torn"||t==="torn-back"){const l=Rn(t==="torn"?i:1-i),f=In().map(c=>[o+(l-Dn(c))*r,a+c*s]),h=t==="torn"?o-r:o+2*r;e.moveTo(h,a);for(const[c,u]of f)e.lineTo(c,u);e.lineTo(h,a+s),e.closePath()}else if(t==="blocks"||t==="blocks-back"){const l=Bn.n,f=Math.max(r,s)/800;for(let h=0;h<l;h++)for(let c=0;c<l;c++){const u=Nn(c,h);(t==="blocks"?u<i:u>=1-i)&&e.rect(o+c*r/l-f,a+h*s/l-f,r/l+2*f,s/l+2*f)}}else e.moveTo(0,0),e.arc(0,0,Math.hypot(r,s),-Math.PI/2,-Math.PI/2+i*Math.PI*2),e.closePath();e.clip()}let Tt=null;const fs=()=>Tt??=Promise.all(Gn.map(async e=>{const t=await fetch(e.url);if(!t.ok)throw Error(`Font ${e.url}: HTTP ${t.status}`);return{name:e.name,weight:e.weight,style:"normal",data:await t.arrayBuffer()}})).catch(e=>{throw Tt=null,e});let vt=null;const cs=()=>vt??=U(()=>import("./index-DxdDhmLR.js"),__vite__mapDeps([0,1,2])).then(e=>e.default).catch(e=>{throw vt=null,e}),hs=48,ze=new Map,We=new Map,an=(e,t,n)=>(e.set(t,n),e.size>hs&&e.delete(e.keys().next().value),n);function us(e){const t=Ht(e);return ze.get(t)??an(ze,t,(async()=>{const[n,r]=await Promise.all([cs(),fs()]);return n(Fn(e),{width:e.width,height:e.height,fonts:r})})().catch(n=>{throw ze.delete(t),n}))}const ds=e=>Math.min(2,2560/Math.max(e.width,e.height));function Eo(e){const t=Ht(e);return We.get(t)??an(We,t,(async()=>{const n=await us(e),r=new Image,s=ds(e);r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await r.decode();const o=Object.assign(document.createElement("canvas"),{width:Math.round(e.width*s),height:Math.round(e.height*s)}),a=o.getContext("2d");if(!a)throw Error("Canvas unavailable");return a.drawImage(r,0,0,o.width,o.height),o})().catch(n=>{throw We.delete(t),n}))}const ps=Object.freeze({dark:"dark",light:"positron",atlas:"liberty",neon:"dark",lime:"dark",paper:"positron",mono:"positron",satellite:"positron"}),ms="https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless_3857/default/g/{z}/{y}/{x}.jpg",gs=14,ys="EOxCloudless 2016 https://cloudless.eox.at by EOX IT Services GmbH (Contains modified Copernicus Sentinel data 2016)",ie=Object.freeze({source:"sentinel",tiles:ms,maxzoom:gs,credit:ys}),ws="Powered by Esri · Source: Esri, Vantor, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community",ge=(e,t,n,r,s,o,a,i,l,f,h,c)=>({bg:e,land:t,park:n,water:r,waterLine:s,building:o,road:a,roadMajor:i,rail:l,boundary:f,text:h,halo:c}),bs=Object.freeze({neon:ge("#070b1a","#0b1226","#0c1a2a","#02040c","#0a2a55","#121c3a","#1b3b7a","#00e5ff","#233060","#ff2fd0","#bfe9ff","#050814"),lime:ge("#0b0d0a","#0f120d","#121a10","#050605","#1d2a16","#171c13","#2a3322","#c6ff3d","#2a3322","#9bcc2e","#e9ffc4","#070806"),paper:ge("#efe4cc","#e9dcc0","#d8d3a6","#b9cfc9","#9fbab4","#dccaa5","#fbf5e6","#c98f4a","#b8a888","#8a5a3c","#4a3a28","#f4ead4"),mono:ge("#f2f2f2","#ececec","#e2e2e2","#cfcfcf","#bdbdbd","#dedede","#ffffff","#9a9a9a","#c8c8c8","#6e6e6e","#3a3a3a","#f7f7f7")}),Ms=/motorway|trunk|primary|major/;function ln(e){const t=e["source-layer"]??"",n=e.id??"";return e.type==="background"?"bg":e.type==="symbol"?"label":t==="water"?"water":t==="waterway"?"waterLine":t==="park"||t==="landcover"?"park":t==="landuse"||t==="aeroway"?e.type==="line"?"road":"land":t==="building"?"building":t==="transportation"?/rail|transit/.test(n)?"rail":Ms.test(n)?"roadMajor":"road":t==="boundary"?"boundary":"other"}function _s(e,t){const n=ln(e),r={...e.paint??{}};if(n==="other")return e.type==="raster"||e.type==="hillshade"?null:e;if(n==="label")return r["text-color"]=t.text,r["text-halo-color"]=t.halo,{...e,paint:r};const s=n==="bg"?t.bg:t[n];return e.type==="background"?r["background-color"]=s:e.type==="fill"?(r["fill-color"]=s,delete r["fill-pattern"],"fill-outline-color"in r&&(r["fill-outline-color"]=s)):e.type==="fill-extrusion"?(r["fill-extrusion-color"]=s,delete r["fill-extrusion-pattern"]):e.type==="line"&&(r["line-color"]=s,delete r["line-pattern"]),{...e,paint:r}}function ks(e,t=ie){const n=[];for(const r of e.layers){const s=ln(r);if(s==="label")n.push({...r,paint:{...r.paint??{},"text-color":"#ffffff","text-halo-color":"rgba(0,0,0,.85)","text-halo-width":1.6}});else if(s==="boundary"&&r.type==="line"){const o=["<=",["get","admin_level"],4];n.push({...r,filter:r.filter?["all",r.filter,o]:o,paint:{...r.paint??{},"line-color":"rgba(255,255,255,.55)"}})}else s==="roadMajor"&&r.type==="line"&&n.push({...r,paint:{...r.paint??{},"line-color":"rgba(255,236,170,.22)"}})}return{...e,sources:{...e.sources,"cx-sat":{type:"raster",tiles:[t.tiles],tileSize:256,maxzoom:t.maxzoom,attribution:t.credit}},layers:[{id:"cx-sat-bg",type:"background",paint:{"background-color":"#0b0f12"}},{id:"cx-sat",type:"raster",source:"cx-sat",paint:{"raster-fade-duration":0}},...n]}}const Ot=Object.freeze({dark:"#30353f",light:"#e4e1da",atlas:"#ddd6cc",neon:"#26367a",lime:"#323d27",paper:"#dccaa5",mono:"#dcdcdc",satellite:"#d6d0c6"});function Lt(e,t=null,n=1){const r=typeof t=="string"&&/^#[0-9a-f]{6}$/i.test(t)?t:Ot[e]??Ot.dark,s=Math.max(0,Math.min(2,Number(n)||1));return"#"+[1,3,5].map(o=>Math.min(255,Math.round(parseInt(r.slice(o,o+2),16)*s)).toString(16).padStart(2,"0")).join("")}function Ss(e,t,n=ie){if(e==="satellite")return ks(t,n??ie);const r=bs[e];return r?{...t,layers:t.layers.map(s=>_s(s,r)).filter(Boolean)}:t}function As(e,t,n=ie){return e==="satellite"?[(n??ie).credit,t]:[t]}function Es(e,t,n){const r=[];for(const s of e){let o="";for(const a of String(s).split(" ")){const i=o?o+" "+a:a;o&&t(i)>n?(r.push(o),o=a):o=i}o&&r.push(o)}return r}const xs=e=>zn[e];function Ts(e,t,n,r,s,o){Hn(e,t,n,r,s,o,xs)}const Pt=Object.fromEntries(Object.entries(ps).map(([e,t])=>[e,`https://tiles.openfreemap.org/styles/${t}`])),vs="OpenFreeMap © OpenMapTiles · Data © OpenStreetMap contributors",Os=[110.8,15.4,113.2,17.4],Ls=[111.2,6,118,12.2],jt=([e,t,n,r])=>[[e,t],[n,t],[n,r],[e,r],[e,t]],$t={type:"MultiPolygon",coordinates:[[jt(Os)],[jt(Ls)]]},Ps=e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{name:e==="vi"?`Quần đảo Hoàng Sa
158
158
  (Việt Nam)`:`Hoang Sa Islands
159
159
  (Viet Nam)`},geometry:{type:"Point",coordinates:[112.1,16.45]}},{type:"Feature",properties:{name:e==="vi"?`Quần đảo Trường Sa
160
160
  (Việt Nam)`:`Truong Sa Islands