@galacean/cli 2.0.0-alpha.12 → 2.0.0-alpha.15

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 (160) hide show
  1. package/dist/cli.bundle.cjs +154 -140
  2. package/dist/viewport-client/_static/Accordion-930aedee.js +1 -0
  3. package/dist/viewport-client/_static/{AmbientLightAsset-f70b95f1.js → AmbientLightAsset-f9c1eb91.js} +2 -2
  4. package/dist/viewport-client/_static/AnimationClipAsset-61699477.js +1 -0
  5. package/dist/viewport-client/_static/AnimatorControllerAsset-1c05f4db.js +1 -0
  6. package/dist/viewport-client/_static/AnimatorStore-6a3679e5.js +1 -0
  7. package/dist/viewport-client/_static/{AssetViewer-bc198e16.js → AssetViewer-0ce46fa1.js} +1 -1
  8. package/dist/viewport-client/_static/AudioAsset-5127eeec.js +1 -0
  9. package/dist/viewport-client/_static/AudioComponent-18a3e59f.js +1 -0
  10. package/dist/viewport-client/_static/{Callout-cb4a55ff.js → Callout-b6ac1af7.js} +1 -1
  11. package/dist/viewport-client/_static/CameraComponent-0a115258.js +1 -0
  12. package/dist/viewport-client/_static/{Component-f923abb1.js → Component-746be670.js} +1 -1
  13. package/dist/viewport-client/_static/DirectLight-4c53e9f6.js +1 -0
  14. package/dist/viewport-client/_static/FontAsset-a3a92f7d.js +5 -0
  15. package/dist/viewport-client/_static/FormItemArray-a2f72cf1.js +6 -0
  16. package/dist/viewport-client/_static/{GlTFAsset-9c68f862.js → GlTFAsset-5f37feef.js} +9 -9
  17. package/dist/viewport-client/_static/IconEdit-2c768a0a.js +6 -0
  18. package/dist/viewport-client/_static/{IconPointFilled-a304fd34.js → IconPointFilled-209638e2.js} +1 -1
  19. package/dist/viewport-client/_static/LightBaseComponent-51d498ea.js +1 -0
  20. package/dist/viewport-client/_static/LottieAnimationComponent-bff0244b.js +1 -0
  21. package/dist/viewport-client/_static/LottieAsset-9d3ef507.js +6 -0
  22. package/dist/viewport-client/_static/MarkdownAsset-a17933fb.js +1 -0
  23. package/dist/viewport-client/_static/MaterialAsset-3b56ac00.js +1 -0
  24. package/dist/viewport-client/_static/MaterialInspector-a36197f2.js +1 -0
  25. package/dist/viewport-client/_static/Menu-0a7dbec0.js +17 -0
  26. package/dist/viewport-client/_static/MeshAsset-2cf47eb2.js +1 -0
  27. package/dist/viewport-client/_static/MeshRendererBaseComponent-4a3af376.js +1 -0
  28. package/dist/viewport-client/_static/MeshRendererComponent-ac4c3954.js +1 -0
  29. package/dist/viewport-client/_static/{MeshThumbnail-49273f71.js → MeshThumbnail-25cd4a13.js} +1 -1
  30. package/dist/viewport-client/_static/ParticleRendererComponent-0a470dee.js +26 -0
  31. package/dist/viewport-client/_static/PhysicsMaterialAsset-d87d35aa.js +1 -0
  32. package/dist/viewport-client/_static/PhysicsStore-c283b2be.js +1 -0
  33. package/dist/viewport-client/_static/PointLight-b7de209f.js +1 -0
  34. package/dist/viewport-client/_static/PostProcessComponent-d4c9ef58.js +6 -0
  35. package/dist/viewport-client/_static/PrefabAsset-d0c0cd25.js +1 -0
  36. package/dist/viewport-client/_static/PrimitiveMesh-35092ad0.js +1 -0
  37. package/dist/viewport-client/_static/ProxyConfigs-ad92ebc7.js +1 -0
  38. package/dist/viewport-client/_static/{ReferencedMaterial-a87818f3.js → ReferencedMaterial-800a1955.js} +1 -1
  39. package/dist/viewport-client/_static/RenderTargetAsset-a003f9f5.js +1 -0
  40. package/dist/viewport-client/_static/SceneAsset-87f2ea92.js +1 -0
  41. package/dist/viewport-client/_static/{ShaderAsset-cb3ff628.js → ShaderAsset-98ce1f70.js} +6 -6
  42. package/dist/viewport-client/_static/ShaderChunkAsset-e9072307.js +5 -0
  43. package/dist/viewport-client/_static/{ShaderUIScriptAsset-d13fa4e2.js → ShaderUIScriptAsset-ac824e68.js} +5 -5
  44. package/dist/viewport-client/_static/SkinnedMeshRendererComponent-5f34bf46.js +1 -0
  45. package/dist/viewport-client/_static/SpineAnimationComponent-7c5db747.js +1 -0
  46. package/dist/viewport-client/_static/SpineSkeletonDataAsset-5b202ba0.js +1 -0
  47. package/dist/viewport-client/_static/SpotLight-2b4e593e.js +1 -0
  48. package/dist/viewport-client/_static/SpriteAsset-4e895da5.js +6 -0
  49. package/dist/viewport-client/_static/SpriteAtlasAsset-c2894c12.js +1 -0
  50. package/dist/viewport-client/_static/SpriteBaseComponent-a75e84c1.js +1 -0
  51. package/dist/viewport-client/_static/SpriteMaskComponent-a31f3384.js +1 -0
  52. package/dist/viewport-client/_static/SpriteRendererComponent-c2123918.js +1 -0
  53. package/dist/viewport-client/_static/{TextBaseComponent-69233798.js → TextBaseComponent-95846acf.js} +2 -2
  54. package/dist/viewport-client/_static/TextRendererComponent-429cf17b.js +1 -0
  55. package/dist/viewport-client/_static/TextureAsset-93475ade.js +36 -0
  56. package/dist/viewport-client/_static/Tooltip-dfde37c6.js +1 -0
  57. package/dist/viewport-client/_static/TrailRendererComponent-112b1618.js +1 -0
  58. package/dist/viewport-client/_static/TransformBaseComponent-a8050787.js +1 -0
  59. package/dist/viewport-client/_static/TransformComponent-c95e25c2.js +1 -0
  60. package/dist/viewport-client/_static/XRReferenceImageAsset-dbf129aa.js +1 -0
  61. package/dist/viewport-client/_static/audio-10589bb4.js +1 -0
  62. package/dist/viewport-client/_static/glTFIO-79bbca27.js +1 -0
  63. package/dist/viewport-client/_static/index-010da0b3.js +1 -0
  64. package/dist/viewport-client/_static/index-07bbf729.js +31 -0
  65. package/dist/viewport-client/_static/index-1e23212d.js +11487 -0
  66. package/dist/viewport-client/_static/index-2cdbb69f.js +1 -0
  67. package/dist/viewport-client/_static/index-31b7a6d3.js +1 -0
  68. package/dist/viewport-client/_static/index-3439012b.js +1 -0
  69. package/dist/viewport-client/_static/index-48760ac4.js +2 -0
  70. package/dist/viewport-client/_static/index-65a103b6.js +1 -0
  71. package/dist/viewport-client/_static/{index-e46ec5b1.js → index-77b1de5c.js} +7 -7
  72. package/dist/viewport-client/_static/index-92830754.js +1 -0
  73. package/dist/viewport-client/_static/{index-237c84cd.js → index-93eab932.js} +3 -3
  74. package/dist/viewport-client/_static/index-b259cf2e.js +1 -0
  75. package/dist/viewport-client/_static/{index-98982ce2.js → index-b2e1cba4.js} +1 -1
  76. package/dist/viewport-client/_static/index-b7bf2586.js +1 -0
  77. package/dist/viewport-client/_static/index-c20fc198.js +1 -0
  78. package/dist/viewport-client/_static/index-dc62ba4b.js +1 -0
  79. package/dist/viewport-client/_static/index-ea9ea505.js +1 -0
  80. package/dist/viewport-client/_static/ktx2-encoder-075abd75.js +1 -0
  81. package/dist/viewport-client/_static/{module-6406b050.js → module-251ecc50.js} +1 -1
  82. package/dist/viewport-client/_static/{module-107b7430.js → module-498119f3.js} +1 -1
  83. package/dist/viewport-client/_static/{module-5c85b07e.js → module-c6e2d190.js} +1 -1
  84. package/dist/viewport-client/_static/postmen-9e1e15bd.js +1 -0
  85. package/dist/viewport-client/index.html +2 -2
  86. package/package.json +1 -1
  87. package/dist/viewport-client/_static/Accordion-4897319b.js +0 -6
  88. package/dist/viewport-client/_static/AnimationClipAsset-01f3deb6.js +0 -1
  89. package/dist/viewport-client/_static/AnimatorControllerAsset-b7424e9c.js +0 -1
  90. package/dist/viewport-client/_static/AnimatorStore-fd98c00e.js +0 -1
  91. package/dist/viewport-client/_static/AssetPreviewer-24e31d97.js +0 -6
  92. package/dist/viewport-client/_static/AudioAsset-eae03324.js +0 -1
  93. package/dist/viewport-client/_static/AudioComponent-44070c2c.js +0 -1
  94. package/dist/viewport-client/_static/CameraComponent-907ac745.js +0 -1
  95. package/dist/viewport-client/_static/CanvasRenderer-9dd98cb3.js +0 -1
  96. package/dist/viewport-client/_static/DirectLight-58f5fe9e.js +0 -1
  97. package/dist/viewport-client/_static/FontAsset-abfb9a8a.js +0 -5
  98. package/dist/viewport-client/_static/FormItemArray-66be8701.js +0 -1
  99. package/dist/viewport-client/_static/IconPlayerPlayFilled-b058c98f.js +0 -6
  100. package/dist/viewport-client/_static/InstanceEditorAsset-a70e73fe.js +0 -1
  101. package/dist/viewport-client/_static/LightBaseComponent-fbc3ae49.js +0 -1
  102. package/dist/viewport-client/_static/LottieAnimationComponent-1c3e02a5.js +0 -1
  103. package/dist/viewport-client/_static/LottieAsset-377c1419.js +0 -1
  104. package/dist/viewport-client/_static/MarkdownAsset-7ea387a9.js +0 -1
  105. package/dist/viewport-client/_static/MaterialAsset-74a15124.js +0 -1
  106. package/dist/viewport-client/_static/MaterialInspector-aec1248b.js +0 -1
  107. package/dist/viewport-client/_static/Menu-cd3be298.js +0 -17
  108. package/dist/viewport-client/_static/MeshAsset-73e2cc8e.js +0 -1
  109. package/dist/viewport-client/_static/MeshRendererBaseComponent-3a0e09ed.js +0 -1
  110. package/dist/viewport-client/_static/MeshRendererComponent-5385d30f.js +0 -1
  111. package/dist/viewport-client/_static/ParticleRendererComponent-5a7b57d9.js +0 -21
  112. package/dist/viewport-client/_static/PhysicsMaterialAsset-a5ac9f82.js +0 -1
  113. package/dist/viewport-client/_static/PhysicsStore-0729e76d.js +0 -1
  114. package/dist/viewport-client/_static/PointLight-0e1d1546.js +0 -1
  115. package/dist/viewport-client/_static/PostProcessComponent-8276d33c.js +0 -1
  116. package/dist/viewport-client/_static/PrefabAsset-1a7edfbd.js +0 -1
  117. package/dist/viewport-client/_static/PrimitiveMesh-3ce6fa2f.js +0 -1
  118. package/dist/viewport-client/_static/ProxyConfigs-4de3304c.js +0 -1
  119. package/dist/viewport-client/_static/RenderTargetAsset-33c0d9e7.js +0 -1
  120. package/dist/viewport-client/_static/SceneAsset-8917c210.js +0 -1
  121. package/dist/viewport-client/_static/ShaderChunkAsset-83f923f4.js +0 -5
  122. package/dist/viewport-client/_static/SkinnedMeshRendererComponent-2a8323bf.js +0 -1
  123. package/dist/viewport-client/_static/SpineAnimationComponent-e733d50f.js +0 -1
  124. package/dist/viewport-client/_static/SpineSkeletonDataAsset-b64a3ee3.js +0 -1
  125. package/dist/viewport-client/_static/SpotLight-ca6c0c3b.js +0 -1
  126. package/dist/viewport-client/_static/SpriteAsset-9a31ec24.js +0 -1
  127. package/dist/viewport-client/_static/SpriteAtlasAsset-a862db46.js +0 -1
  128. package/dist/viewport-client/_static/SpriteBaseComponent-f6f1731f.js +0 -1
  129. package/dist/viewport-client/_static/SpriteMaskComponent-778be04f.js +0 -1
  130. package/dist/viewport-client/_static/SpriteRendererComponent-2b4d153b.js +0 -1
  131. package/dist/viewport-client/_static/TextRendererComponent-130b4e99.js +0 -1
  132. package/dist/viewport-client/_static/TextureAsset-28fedf2a.js +0 -36
  133. package/dist/viewport-client/_static/ThumbnailMixin-35997457.js +0 -1
  134. package/dist/viewport-client/_static/ThumbnailRegistry-495c18c9.js +0 -1
  135. package/dist/viewport-client/_static/Tooltip-33f770ba.js +0 -1
  136. package/dist/viewport-client/_static/TrailRendererComponent-148550b5.js +0 -1
  137. package/dist/viewport-client/_static/TransformBaseComponent-02318c5a.js +0 -1
  138. package/dist/viewport-client/_static/TransformComponent-96106065.js +0 -1
  139. package/dist/viewport-client/_static/ViewerManager-202b570a.js +0 -1
  140. package/dist/viewport-client/_static/XRReferenceImageAsset-6a6adb3b.js +0 -1
  141. package/dist/viewport-client/_static/audio-244358e2.js +0 -1
  142. package/dist/viewport-client/_static/glTFIO-45ff9a17.js +0 -1
  143. package/dist/viewport-client/_static/index-0a8702e2.js +0 -11217
  144. package/dist/viewport-client/_static/index-37c74ae9.js +0 -26
  145. package/dist/viewport-client/_static/index-4cca0201.js +0 -1
  146. package/dist/viewport-client/_static/index-59732f86.js +0 -1
  147. package/dist/viewport-client/_static/index-6c8198f6.js +0 -2
  148. package/dist/viewport-client/_static/index-6f827618.js +0 -1
  149. package/dist/viewport-client/_static/index-803ca489.js +0 -1
  150. package/dist/viewport-client/_static/index-85a6cf6a.js +0 -1
  151. package/dist/viewport-client/_static/index-b3d51f87.js +0 -1
  152. package/dist/viewport-client/_static/index-be6bc38a.js +0 -177
  153. package/dist/viewport-client/_static/index-c403cbcd.js +0 -1
  154. package/dist/viewport-client/_static/index-e73966ae.js +0 -1
  155. package/dist/viewport-client/_static/index-e95b4498.js +0 -1
  156. package/dist/viewport-client/_static/index-f5a67a46.js +0 -1
  157. package/dist/viewport-client/_static/ktx-parse.modern-6c9f771f.js +0 -1
  158. package/dist/viewport-client/_static/ktx2-encoder-1e63c1eb.js +0 -1
  159. package/dist/viewport-client/_static/postmen-45d4c238.js +0 -1
  160. package/dist/viewport-client/_static/utilities-e09052e3.js +0 -11
@@ -1,20 +1,20 @@
1
- var Lt=Object.defineProperty;var $t=(e,t,s)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var w=(e,t,s)=>($t(e,typeof t!="symbol"?t+"":t,s),s);import{eW as Vt,aH as Ut,aT as ht,aD as I,bz as Ft,n as gt,aU as Dt,aV as $e,aE as te,e1 as be,cF as se,by as Ve,aJ as qt,dJ as Ue,o as pt,S as Bt,u as j,J as G,be as Gt,eX as Wt,e as dt,_ as Ht,cY as Xt,eY as Fe,a7 as Kt,O as De,v as Qt,b0 as W,b1 as Jt,cj as Yt}from"./index-0a8702e2.js";import{B as N,P,a as v,A as Ie,b as Pe,K as mt,N as Zt,M as V,E as ie,D as ze,u as ve,R as me,S as es,T as Me,c as yt,d as bt,e as vt,C as ts,f as ss,g as ns,G as Ae,h as qe,F as rs,i as _e}from"./glTFIO-45ff9a17.js";import{a as le}from"./meshopt_simplifier.module-cd99529d.js";import{u as At,I as as,a as is,A as os}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{A as ls}from"./AssetViewer-bc198e16.js";import{M as cs}from"./MaterialAsset-74a15124.js";import{k as fs}from"./ktx2-encoder-1e63c1eb.js";import{n as Be}from"./index-be6bc38a.js";function Ge(e){const t=e%4;return t===0?e:e+(4-t)}function us(e){return e.toLowerCase().endsWith(".png")?"image/png":e.toLowerCase().endsWith(".jpg")||e.toLowerCase().endsWith(".jpeg")?"image/jpeg":e.toLowerCase().endsWith(".webp")?"image/webp":"application/octet-stream"}function _t(e){const{json:t,resources:s}=e,n=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),a=N.pad(N.encodeText(r),32),i=N.toView(new Uint32Array([a.byteLength,1313821514])),l=N.concat([i,a]);n[n.length-1]+=l.byteLength;const o=Object.values(s)[0];if(!o||!o.byteLength)return N.concat([N.toView(n),l]);const u=N.pad(o,0),c=N.toView(new Uint32Array([u.byteLength,5130562])),h=N.concat([c,u]);return n[n.length-1]+=h.byteLength,N.concat([N.toView(n),l,h])}function hs(e){const t=e.json,s=[],n=[];let r=0;function a(h){return h.uri===void 0?void 0:e.resources[h.uri]}const i=t.buffers??[],l=new Map;i.forEach((h,f)=>{const g=a(h);g!==void 0&&(s.push(new Uint8Array(g)),n.push(r),delete h.uri,h.byteLength=g.byteLength,l.set(f,r),r+=Ge(g.byteLength))});let o=i.length;(t.images||[]).forEach(h=>{const f=a(h);if(!f){delete h.uri;return}const g={buffer:0,byteOffset:r,byteLength:f.byteLength};l.set(o++,r),r+=Ge(f.byteLength);const p=t.bufferViews??[];h.bufferView=p.length,h.mimeType=us(h.uri),delete h.uri,p.push(g),s.push(new Uint8Array(f)),n.push(g.byteOffset)});for(const h of t.bufferViews??[])h.byteOffset=(h.byteOffset??0)+(l.get(h.buffer)??0),h.buffer=0;const c=new Uint8Array(r);return s.forEach((h,f)=>{c.set(h,n[f])}),t.buffers=[{byteLength:r}],_t({json:t,resources:{"buffer.bin":c}})}function gs(e){for(var t=new Array(e),s=0;s<e;++s)t[s]=s;return t}var ps=gs;/*!
1
+ var Lt=Object.defineProperty;var $t=(e,t,s)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var w=(e,t,s)=>($t(e,typeof t!="symbol"?t+"":t,s),s);import{eN as Ut,aO as Vt,aQ as ht,aS as I,bN as Ft,q as gt,aR as Dt,aV as $e,aD as te,e5 as be,dQ as se,bM as Ue,aU as qt,dZ as Ve,c7 as Bt,u as pt,S as Gt,x as R,aL as G,br as Wt,eO as Ht,by as Fe,e as dt,_ as Xt,cF as Qt,eP as De,a7 as Kt,O as qe,v as Jt,a$ as W,b0 as Yt,n as Zt,o as es,dr as ts}from"./index-1e23212d.js";import{B as N,P,a as v,A as Ie,b as Pe,K as mt,N as ss,M as U,E as ie,D as ze,u as ve,R as me,S as ns,T as Me,c as yt,d as bt,e as vt,C as rs,f as as,g as is,G as Ae,h as Be,F as os,i as _e}from"./glTFIO-79bbca27.js";import{a as le}from"./meshopt_simplifier.module-cd99529d.js";import{u as At,I as ls}from"./index-92830754.js";import"./postmen-9e1e15bd.js";import{A as cs}from"./AssetViewer-0ce46fa1.js";import{M as fs}from"./MaterialAsset-3b56ac00.js";import{k as us}from"./ktx2-encoder-075abd75.js";function Ge(e){const t=e%4;return t===0?e:e+(4-t)}function hs(e){return e.toLowerCase().endsWith(".png")?"image/png":e.toLowerCase().endsWith(".jpg")||e.toLowerCase().endsWith(".jpeg")?"image/jpeg":e.toLowerCase().endsWith(".webp")?"image/webp":"application/octet-stream"}function _t(e){const{json:t,resources:s}=e,n=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),a=N.pad(N.encodeText(r),32),i=N.toView(new Uint32Array([a.byteLength,1313821514])),l=N.concat([i,a]);n[n.length-1]+=l.byteLength;const o=Object.values(s)[0];if(!o||!o.byteLength)return N.concat([N.toView(n),l]);const u=N.pad(o,0),c=N.toView(new Uint32Array([u.byteLength,5130562])),h=N.concat([c,u]);return n[n.length-1]+=h.byteLength,N.concat([N.toView(n),l,h])}function gs(e){const t=e.json,s=[],n=[];let r=0;function a(h){return h.uri===void 0?void 0:e.resources[h.uri]}const i=t.buffers??[],l=new Map;i.forEach((h,f)=>{const g=a(h);g!==void 0&&(s.push(new Uint8Array(g)),n.push(r),delete h.uri,h.byteLength=g.byteLength,l.set(f,r),r+=Ge(g.byteLength))});let o=i.length;(t.images||[]).forEach(h=>{const f=a(h);if(!f){delete h.uri;return}const g={buffer:0,byteOffset:r,byteLength:f.byteLength};l.set(o++,r),r+=Ge(f.byteLength);const p=t.bufferViews??[];h.bufferView=p.length,h.mimeType=hs(h.uri),delete h.uri,p.push(g),s.push(new Uint8Array(f)),n.push(g.byteOffset)});for(const h of t.bufferViews??[])h.byteOffset=(h.byteOffset??0)+(l.get(h.buffer)??0),h.buffer=0;const c=new Uint8Array(r);return s.forEach((h,f)=>{c.set(h,n[f])}),t.buffers=[{byteLength:r}],_t({json:t,resources:{"buffer.bin":c}})}function ps(e){for(var t=new Array(e),s=0;s<e;++s)t[s]=s;return t}var ds=ps;/*!
2
2
  * Determine if an object is a Buffer
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
- */var ds=function(e){return e!=null&&(Tt(e)||ms(e)||!!e._isBuffer)};function Tt(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function ms(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Tt(e.slice(0,0))}var ys=ps,bs=ds,vs=typeof Float64Array<"u";function As(e,t){return e[0]-t[0]}function _s(){var e=this.stride,t=new Array(e.length),s;for(s=0;s<t.length;++s)t[s]=[Math.abs(e[s]),s];t.sort(As);var n=new Array(t.length);for(s=0;s<n.length;++s)n[s]=t[s][1];return n}function Ts(e,t){var s=["View",t,"d",e].join("");t<0&&(s="View_Nil"+e);var n=e==="generic";if(t===-1){var r="function "+s+"(a){this.data=a;};var proto="+s+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+s+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+s+"(a){return new "+s+"(a);}",m=new Function(r);return m()}else if(t===0){var r="function "+s+"(a,d) {this.data = a;this.offset = d};var proto="+s+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+s+"_copy() {return new "+s+"(this.data,this.offset)};proto.pick=function "+s+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+s+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+s+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+s+"(a,b,c,d){return new "+s+"(a,d)}",m=new Function("TrivialArray",r);return m(ce[e][0])}var r=["'use strict'"],a=ys(t),i=a.map(function(d){return"i"+d}),l="this.offset+"+a.map(function(d){return"this.stride["+d+"]*i"+d}).join("+"),o=a.map(function(d){return"b"+d}).join(","),u=a.map(function(d){return"c"+d}).join(",");r.push("function "+s+"(a,"+o+","+u+",d){this.data=a","this.shape=["+o+"]","this.stride=["+u+"]","this.offset=d|0}","var proto="+s+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),r.push("Object.defineProperty(proto,'size',{get:function "+s+"_size(){return "+a.map(function(d){return"this.shape["+d+"]"}).join("*"),"}})"),t===1?r.push("proto.order=[0]"):(r.push("Object.defineProperty(proto,'order',{get:"),t<4?(r.push("function "+s+"_order(){"),t===2?r.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):t===3&&r.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):r.push("ORDER})")),r.push("proto.set=function "+s+"_set("+i.join(",")+",v){"),n?r.push("return this.data.set("+l+",v)}"):r.push("return this.data["+l+"]=v}"),r.push("proto.get=function "+s+"_get("+i.join(",")+"){"),n?r.push("return this.data.get("+l+")}"):r.push("return this.data["+l+"]}"),r.push("proto.index=function "+s+"_index(",i.join(),"){return "+l+"}"),r.push("proto.hi=function "+s+"_hi("+i.join(",")+"){return new "+s+"(this.data,"+a.map(function(d){return["(typeof i",d,"!=='number'||i",d,"<0)?this.shape[",d,"]:i",d,"|0"].join("")}).join(",")+","+a.map(function(d){return"this.stride["+d+"]"}).join(",")+",this.offset)}");var c=a.map(function(d){return"a"+d+"=this.shape["+d+"]"}),h=a.map(function(d){return"c"+d+"=this.stride["+d+"]"});r.push("proto.lo=function "+s+"_lo("+i.join(",")+"){var b=this.offset,d=0,"+c.join(",")+","+h.join(","));for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){d=i"+f+"|0;b+=c"+f+"*d;a"+f+"-=d}");r.push("return new "+s+"(this.data,"+a.map(function(d){return"a"+d}).join(",")+","+a.map(function(d){return"c"+d}).join(",")+",b)}"),r.push("proto.step=function "+s+"_step("+i.join(",")+"){var "+a.map(function(d){return"a"+d+"=this.shape["+d+"]"}).join(",")+","+a.map(function(d){return"b"+d+"=this.stride["+d+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'){d=i"+f+"|0;if(d<0){c+=b"+f+"*(a"+f+"-1);a"+f+"=ceil(-a"+f+"/d)}else{a"+f+"=ceil(a"+f+"/d)}b"+f+"*=d}");r.push("return new "+s+"(this.data,"+a.map(function(d){return"a"+d}).join(",")+","+a.map(function(d){return"b"+d}).join(",")+",c)}");for(var g=new Array(t),p=new Array(t),f=0;f<t;++f)g[f]="a[i"+f+"]",p[f]="b[i"+f+"]";r.push("proto.transpose=function "+s+"_transpose("+i+"){"+i.map(function(d,y){return d+"=("+d+"===undefined?"+y+":"+d+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+s+"(this.data,"+g.join(",")+","+p.join(",")+",this.offset)}"),r.push("proto.pick=function "+s+"_pick("+i+"){var a=[],b=[],c=this.offset");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){c=(c+this.stride["+f+"]*i"+f+")|0}else{a.push(this.shape["+f+"]);b.push(this.stride["+f+"])}");r.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),r.push("return function construct_"+s+"(data,shape,stride,offset){return new "+s+"(data,"+a.map(function(d){return"shape["+d+"]"}).join(",")+","+a.map(function(d){return"stride["+d+"]"}).join(",")+",offset)}");var m=new Function("CTOR_LIST","ORDER",r.join(`
7
- `));return m(ce[e],_s)}function Es(e){if(bs(e))return"buffer";if(vs)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(e)?"array":"generic"}var ce={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function ws(e,t,s,n){if(e===void 0){var u=ce.array[0];return u([])}else typeof e=="number"&&(e=[e]);t===void 0&&(t=[e.length]);var r=t.length;if(s===void 0){s=new Array(r);for(var a=r-1,i=1;a>=0;--a)s[a]=i,i*=t[a]}if(n===void 0){n=0;for(var a=0;a<r;++a)s[a]<0&&(n-=(t[a]-1)*s[a])}for(var l=Es(e),o=ce[l];o.length<=r+1;)o.push(Ts(l,o.length-1));var u=o[r+1];return u(e,t,s,n)}var Is=ws;const Ms=Vt(Is);var Ns={};function Cs(e,t){for(var s=1,n=e.length,r=e[0],a=e[0],i=1;i<n;++i)if(a=r,r=e[i],t(r,a)){if(i===s){s++;continue}e[s++]=r}return e.length=s,e}function Ss(e){for(var t=1,s=e.length,n=e[0],r=e[0],a=1;a<s;++a,r=n)if(r=n,n=e[a],n!==r){if(a===t){t++;continue}e[t++]=n}return e.length=t,e}function Os(e,t,s){return e.length===0?e:t?(s||e.sort(t),Cs(e,t)):(s||e.sort(),Ss(e))}var xs=Os,js=xs;function Et(e,t,s){var n=e.length,r=t.arrayArgs.length,a=t.indexArgs.length>0,i=[],l=[],o=0,u=0,c,h;for(c=0;c<n;++c)l.push(["i",c,"=0"].join(""));for(h=0;h<r;++h)for(c=0;c<n;++c)u=o,o=e[c],c===0?l.push(["d",h,"s",c,"=t",h,"p",o].join("")):l.push(["d",h,"s",c,"=(t",h,"p",o,"-s",u,"*t",h,"p",u,")"].join(""));for(l.length>0&&i.push("var "+l.join(",")),c=n-1;c>=0;--c)o=e[c],i.push(["for(i",c,"=0;i",c,"<s",o,";++i",c,"){"].join(""));for(i.push(s),c=0;c<n;++c){for(u=o,o=e[c],h=0;h<r;++h)i.push(["p",h,"+=d",h,"s",c].join(""));a&&(c>0&&i.push(["index[",u,"]-=s",u].join("")),i.push(["++index[",o,"]"].join(""))),i.push("}")}return i.join(`
8
- `)}function Rs(e,t,s,n){for(var r=t.length,a=s.arrayArgs.length,i=s.blockSize,l=s.indexArgs.length>0,o=[],u=0;u<a;++u)o.push(["var offset",u,"=p",u].join(""));for(var u=e;u<r;++u)o.push(["for(var j"+u+"=SS[",t[u],"]|0;j",u,">0;){"].join("")),o.push(["if(j",u,"<",i,"){"].join("")),o.push(["s",t[u],"=j",u].join("")),o.push(["j",u,"=0"].join("")),o.push(["}else{s",t[u],"=",i].join("")),o.push(["j",u,"-=",i,"}"].join("")),l&&o.push(["index[",t[u],"]=j",u].join(""));for(var u=0;u<a;++u){for(var c=["offset"+u],h=e;h<r;++h)c.push(["j",h,"*t",u,"p",t[h]].join(""));o.push(["p",u,"=(",c.join("+"),")"].join(""))}o.push(Et(t,s,n));for(var u=e;u<r;++u)o.push("}");return o.join(`
9
- `)}function Ps(e){for(var t=0,s=e[0].length;t<s;){for(var n=1;n<e.length;++n)if(e[n][t]!==e[0][t])return t;++t}return t}function Te(e,t,s){for(var n=e.body,r=[],a=[],i=0;i<e.args.length;++i){var l=e.args[i];if(!(l.count<=0)){var o=new RegExp(l.name,"g"),u="",c=t.arrayArgs.indexOf(i);switch(t.argTypes[i]){case"offset":var h=t.offsetArgIndex.indexOf(i),f=t.offsetArgs[h];c=f.array,u="+q"+h;case"array":u="p"+c+u;var g="l"+i,p="a"+c;if(t.arrayBlockIndices[c]===0)l.count===1?s[c]==="generic"?l.lvalue?(r.push(["var ",g,"=",p,".get(",u,")"].join("")),n=n.replace(o,g),a.push([p,".set(",u,",",g,")"].join(""))):n=n.replace(o,[p,".get(",u,")"].join("")):n=n.replace(o,[p,"[",u,"]"].join("")):s[c]==="generic"?(r.push(["var ",g,"=",p,".get(",u,")"].join("")),n=n.replace(o,g),l.lvalue&&a.push([p,".set(",u,",",g,")"].join(""))):(r.push(["var ",g,"=",p,"[",u,"]"].join("")),n=n.replace(o,g),l.lvalue&&a.push([p,"[",u,"]=",g].join("")));else{for(var m=[l.name],d=[u],y=0;y<Math.abs(t.arrayBlockIndices[c]);y++)m.push("\\s*\\[([^\\]]+)\\]"),d.push("$"+(y+1)+"*t"+c+"b"+y);if(o=new RegExp(m.join(""),"g"),u=d.join("+"),s[c]==="generic")throw new Error("cwise: Generic arrays not supported in combination with blocks!");n=n.replace(o,[p,"[",u,"]"].join(""))}break;case"scalar":n=n.replace(o,"Y"+t.scalarArgs.indexOf(i));break;case"index":n=n.replace(o,"index");break;case"shape":n=n.replace(o,"shape");break}}}return[r.join(`
6
+ */var ms=function(e){return e!=null&&(Tt(e)||ys(e)||!!e._isBuffer)};function Tt(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function ys(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Tt(e.slice(0,0))}var bs=ds,vs=ms,As=typeof Float64Array<"u";function _s(e,t){return e[0]-t[0]}function Ts(){var e=this.stride,t=new Array(e.length),s;for(s=0;s<t.length;++s)t[s]=[Math.abs(e[s]),s];t.sort(_s);var n=new Array(t.length);for(s=0;s<n.length;++s)n[s]=t[s][1];return n}function Es(e,t){var s=["View",t,"d",e].join("");t<0&&(s="View_Nil"+e);var n=e==="generic";if(t===-1){var r="function "+s+"(a){this.data=a;};var proto="+s+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+s+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+s+"(a){return new "+s+"(a);}",m=new Function(r);return m()}else if(t===0){var r="function "+s+"(a,d) {this.data = a;this.offset = d};var proto="+s+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+s+"_copy() {return new "+s+"(this.data,this.offset)};proto.pick=function "+s+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+s+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+s+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+s+"(a,b,c,d){return new "+s+"(a,d)}",m=new Function("TrivialArray",r);return m(ce[e][0])}var r=["'use strict'"],a=bs(t),i=a.map(function(d){return"i"+d}),l="this.offset+"+a.map(function(d){return"this.stride["+d+"]*i"+d}).join("+"),o=a.map(function(d){return"b"+d}).join(","),u=a.map(function(d){return"c"+d}).join(",");r.push("function "+s+"(a,"+o+","+u+",d){this.data=a","this.shape=["+o+"]","this.stride=["+u+"]","this.offset=d|0}","var proto="+s+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),r.push("Object.defineProperty(proto,'size',{get:function "+s+"_size(){return "+a.map(function(d){return"this.shape["+d+"]"}).join("*"),"}})"),t===1?r.push("proto.order=[0]"):(r.push("Object.defineProperty(proto,'order',{get:"),t<4?(r.push("function "+s+"_order(){"),t===2?r.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):t===3&&r.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):r.push("ORDER})")),r.push("proto.set=function "+s+"_set("+i.join(",")+",v){"),n?r.push("return this.data.set("+l+",v)}"):r.push("return this.data["+l+"]=v}"),r.push("proto.get=function "+s+"_get("+i.join(",")+"){"),n?r.push("return this.data.get("+l+")}"):r.push("return this.data["+l+"]}"),r.push("proto.index=function "+s+"_index(",i.join(),"){return "+l+"}"),r.push("proto.hi=function "+s+"_hi("+i.join(",")+"){return new "+s+"(this.data,"+a.map(function(d){return["(typeof i",d,"!=='number'||i",d,"<0)?this.shape[",d,"]:i",d,"|0"].join("")}).join(",")+","+a.map(function(d){return"this.stride["+d+"]"}).join(",")+",this.offset)}");var c=a.map(function(d){return"a"+d+"=this.shape["+d+"]"}),h=a.map(function(d){return"c"+d+"=this.stride["+d+"]"});r.push("proto.lo=function "+s+"_lo("+i.join(",")+"){var b=this.offset,d=0,"+c.join(",")+","+h.join(","));for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){d=i"+f+"|0;b+=c"+f+"*d;a"+f+"-=d}");r.push("return new "+s+"(this.data,"+a.map(function(d){return"a"+d}).join(",")+","+a.map(function(d){return"c"+d}).join(",")+",b)}"),r.push("proto.step=function "+s+"_step("+i.join(",")+"){var "+a.map(function(d){return"a"+d+"=this.shape["+d+"]"}).join(",")+","+a.map(function(d){return"b"+d+"=this.stride["+d+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'){d=i"+f+"|0;if(d<0){c+=b"+f+"*(a"+f+"-1);a"+f+"=ceil(-a"+f+"/d)}else{a"+f+"=ceil(a"+f+"/d)}b"+f+"*=d}");r.push("return new "+s+"(this.data,"+a.map(function(d){return"a"+d}).join(",")+","+a.map(function(d){return"b"+d}).join(",")+",c)}");for(var g=new Array(t),p=new Array(t),f=0;f<t;++f)g[f]="a[i"+f+"]",p[f]="b[i"+f+"]";r.push("proto.transpose=function "+s+"_transpose("+i+"){"+i.map(function(d,y){return d+"=("+d+"===undefined?"+y+":"+d+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+s+"(this.data,"+g.join(",")+","+p.join(",")+",this.offset)}"),r.push("proto.pick=function "+s+"_pick("+i+"){var a=[],b=[],c=this.offset");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){c=(c+this.stride["+f+"]*i"+f+")|0}else{a.push(this.shape["+f+"]);b.push(this.stride["+f+"])}");r.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),r.push("return function construct_"+s+"(data,shape,stride,offset){return new "+s+"(data,"+a.map(function(d){return"shape["+d+"]"}).join(",")+","+a.map(function(d){return"stride["+d+"]"}).join(",")+",offset)}");var m=new Function("CTOR_LIST","ORDER",r.join(`
7
+ `));return m(ce[e],Ts)}function ws(e){if(vs(e))return"buffer";if(As)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(e)?"array":"generic"}var ce={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function Is(e,t,s,n){if(e===void 0){var u=ce.array[0];return u([])}else typeof e=="number"&&(e=[e]);t===void 0&&(t=[e.length]);var r=t.length;if(s===void 0){s=new Array(r);for(var a=r-1,i=1;a>=0;--a)s[a]=i,i*=t[a]}if(n===void 0){n=0;for(var a=0;a<r;++a)s[a]<0&&(n-=(t[a]-1)*s[a])}for(var l=ws(e),o=ce[l];o.length<=r+1;)o.push(Es(l,o.length-1));var u=o[r+1];return u(e,t,s,n)}var Ms=Is;const Ns=Ut(Ms);var Cs={};function Ss(e,t){for(var s=1,n=e.length,r=e[0],a=e[0],i=1;i<n;++i)if(a=r,r=e[i],t(r,a)){if(i===s){s++;continue}e[s++]=r}return e.length=s,e}function Os(e){for(var t=1,s=e.length,n=e[0],r=e[0],a=1;a<s;++a,r=n)if(r=n,n=e[a],n!==r){if(a===t){t++;continue}e[t++]=n}return e.length=t,e}function xs(e,t,s){return e.length===0?e:t?(s||e.sort(t),Ss(e,t)):(s||e.sort(),Os(e))}var Rs=xs,js=Rs;function Et(e,t,s){var n=e.length,r=t.arrayArgs.length,a=t.indexArgs.length>0,i=[],l=[],o=0,u=0,c,h;for(c=0;c<n;++c)l.push(["i",c,"=0"].join(""));for(h=0;h<r;++h)for(c=0;c<n;++c)u=o,o=e[c],c===0?l.push(["d",h,"s",c,"=t",h,"p",o].join("")):l.push(["d",h,"s",c,"=(t",h,"p",o,"-s",u,"*t",h,"p",u,")"].join(""));for(l.length>0&&i.push("var "+l.join(",")),c=n-1;c>=0;--c)o=e[c],i.push(["for(i",c,"=0;i",c,"<s",o,";++i",c,"){"].join(""));for(i.push(s),c=0;c<n;++c){for(u=o,o=e[c],h=0;h<r;++h)i.push(["p",h,"+=d",h,"s",c].join(""));a&&(c>0&&i.push(["index[",u,"]-=s",u].join("")),i.push(["++index[",o,"]"].join(""))),i.push("}")}return i.join(`
8
+ `)}function Ps(e,t,s,n){for(var r=t.length,a=s.arrayArgs.length,i=s.blockSize,l=s.indexArgs.length>0,o=[],u=0;u<a;++u)o.push(["var offset",u,"=p",u].join(""));for(var u=e;u<r;++u)o.push(["for(var j"+u+"=SS[",t[u],"]|0;j",u,">0;){"].join("")),o.push(["if(j",u,"<",i,"){"].join("")),o.push(["s",t[u],"=j",u].join("")),o.push(["j",u,"=0"].join("")),o.push(["}else{s",t[u],"=",i].join("")),o.push(["j",u,"-=",i,"}"].join("")),l&&o.push(["index[",t[u],"]=j",u].join(""));for(var u=0;u<a;++u){for(var c=["offset"+u],h=e;h<r;++h)c.push(["j",h,"*t",u,"p",t[h]].join(""));o.push(["p",u,"=(",c.join("+"),")"].join(""))}o.push(Et(t,s,n));for(var u=e;u<r;++u)o.push("}");return o.join(`
9
+ `)}function zs(e){for(var t=0,s=e[0].length;t<s;){for(var n=1;n<e.length;++n)if(e[n][t]!==e[0][t])return t;++t}return t}function Te(e,t,s){for(var n=e.body,r=[],a=[],i=0;i<e.args.length;++i){var l=e.args[i];if(!(l.count<=0)){var o=new RegExp(l.name,"g"),u="",c=t.arrayArgs.indexOf(i);switch(t.argTypes[i]){case"offset":var h=t.offsetArgIndex.indexOf(i),f=t.offsetArgs[h];c=f.array,u="+q"+h;case"array":u="p"+c+u;var g="l"+i,p="a"+c;if(t.arrayBlockIndices[c]===0)l.count===1?s[c]==="generic"?l.lvalue?(r.push(["var ",g,"=",p,".get(",u,")"].join("")),n=n.replace(o,g),a.push([p,".set(",u,",",g,")"].join(""))):n=n.replace(o,[p,".get(",u,")"].join("")):n=n.replace(o,[p,"[",u,"]"].join("")):s[c]==="generic"?(r.push(["var ",g,"=",p,".get(",u,")"].join("")),n=n.replace(o,g),l.lvalue&&a.push([p,".set(",u,",",g,")"].join(""))):(r.push(["var ",g,"=",p,"[",u,"]"].join("")),n=n.replace(o,g),l.lvalue&&a.push([p,"[",u,"]=",g].join("")));else{for(var m=[l.name],d=[u],y=0;y<Math.abs(t.arrayBlockIndices[c]);y++)m.push("\\s*\\[([^\\]]+)\\]"),d.push("$"+(y+1)+"*t"+c+"b"+y);if(o=new RegExp(m.join(""),"g"),u=d.join("+"),s[c]==="generic")throw new Error("cwise: Generic arrays not supported in combination with blocks!");n=n.replace(o,[p,"[",u,"]"].join(""))}break;case"scalar":n=n.replace(o,"Y"+t.scalarArgs.indexOf(i));break;case"index":n=n.replace(o,"index");break;case"shape":n=n.replace(o,"shape");break}}}return[r.join(`
10
10
  `),n,a.join(`
11
11
  `)].join(`
12
- `).trim()}function zs(e){for(var t=new Array(e.length),s=!0,n=0;n<e.length;++n){var r=e[n],a=r.match(/\d+/);a?a=a[0]:a="",r.charAt(0)===0?t[n]="u"+r.charAt(1)+a:t[n]=r.charAt(0)+a,n>0&&(s=s&&t[n]===t[n-1])}return s?t[0]:t.join("")}function ks(e,t){for(var s=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,n=new Array(e.arrayArgs.length),r=new Array(e.arrayArgs.length),a=0;a<e.arrayArgs.length;++a)r[a]=t[2*a],n[a]=t[2*a+1];for(var i=[],l=[],o=[],u=[],c=[],a=0;a<e.arrayArgs.length;++a){e.arrayBlockIndices[a]<0?(o.push(0),u.push(s),i.push(s),l.push(s+e.arrayBlockIndices[a])):(o.push(e.arrayBlockIndices[a]),u.push(e.arrayBlockIndices[a]+s),i.push(0),l.push(e.arrayBlockIndices[a]));for(var h=[],f=0;f<n[a].length;f++)o[a]<=n[a][f]&&n[a][f]<u[a]&&h.push(n[a][f]-o[a]);c.push(h)}for(var g=["SS"],p=["'use strict'"],m=[],f=0;f<s;++f)m.push(["s",f,"=SS[",f,"]"].join(""));for(var a=0;a<e.arrayArgs.length;++a){g.push("a"+a),g.push("t"+a),g.push("p"+a);for(var f=0;f<s;++f)m.push(["t",a,"p",f,"=t",a,"[",o[a]+f,"]"].join(""));for(var f=0;f<Math.abs(e.arrayBlockIndices[a]);++f)m.push(["t",a,"b",f,"=t",a,"[",i[a]+f,"]"].join(""))}for(var a=0;a<e.scalarArgs.length;++a)g.push("Y"+a);if(e.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),e.indexArgs.length>0){for(var d=new Array(s),a=0;a<s;++a)d[a]="0";m.push(["index=[",d.join(","),"]"].join(""))}for(var a=0;a<e.offsetArgs.length;++a){for(var y=e.offsetArgs[a],T=[],f=0;f<y.offset.length;++f)y.offset[f]!==0&&(y.offset[f]===1?T.push(["t",y.array,"p",f].join("")):T.push([y.offset[f],"*t",y.array,"p",f].join("")));T.length===0?m.push("q"+a+"=0"):m.push(["q",a,"=",T.join("+")].join(""))}var A=js([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));m=m.concat(A),m.length>0&&p.push("var "+m.join(","));for(var a=0;a<e.arrayArgs.length;++a)p.push("p"+a+"|=0");e.pre.body.length>3&&p.push(Te(e.pre,e,r));var b=Te(e.body,e,r),_=Ps(c);_<s?p.push(Rs(_,c[0],e,b)):p.push(Et(c[0],e,b)),e.post.body.length>3&&p.push(Te(e.post,e,r)),e.debug&&console.log("-----Generated cwise routine for ",t,`:
12
+ `).trim()}function ks(e){for(var t=new Array(e.length),s=!0,n=0;n<e.length;++n){var r=e[n],a=r.match(/\d+/);a?a=a[0]:a="",r.charAt(0)===0?t[n]="u"+r.charAt(1)+a:t[n]=r.charAt(0)+a,n>0&&(s=s&&t[n]===t[n-1])}return s?t[0]:t.join("")}function Ls(e,t){for(var s=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,n=new Array(e.arrayArgs.length),r=new Array(e.arrayArgs.length),a=0;a<e.arrayArgs.length;++a)r[a]=t[2*a],n[a]=t[2*a+1];for(var i=[],l=[],o=[],u=[],c=[],a=0;a<e.arrayArgs.length;++a){e.arrayBlockIndices[a]<0?(o.push(0),u.push(s),i.push(s),l.push(s+e.arrayBlockIndices[a])):(o.push(e.arrayBlockIndices[a]),u.push(e.arrayBlockIndices[a]+s),i.push(0),l.push(e.arrayBlockIndices[a]));for(var h=[],f=0;f<n[a].length;f++)o[a]<=n[a][f]&&n[a][f]<u[a]&&h.push(n[a][f]-o[a]);c.push(h)}for(var g=["SS"],p=["'use strict'"],m=[],f=0;f<s;++f)m.push(["s",f,"=SS[",f,"]"].join(""));for(var a=0;a<e.arrayArgs.length;++a){g.push("a"+a),g.push("t"+a),g.push("p"+a);for(var f=0;f<s;++f)m.push(["t",a,"p",f,"=t",a,"[",o[a]+f,"]"].join(""));for(var f=0;f<Math.abs(e.arrayBlockIndices[a]);++f)m.push(["t",a,"b",f,"=t",a,"[",i[a]+f,"]"].join(""))}for(var a=0;a<e.scalarArgs.length;++a)g.push("Y"+a);if(e.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),e.indexArgs.length>0){for(var d=new Array(s),a=0;a<s;++a)d[a]="0";m.push(["index=[",d.join(","),"]"].join(""))}for(var a=0;a<e.offsetArgs.length;++a){for(var y=e.offsetArgs[a],T=[],f=0;f<y.offset.length;++f)y.offset[f]!==0&&(y.offset[f]===1?T.push(["t",y.array,"p",f].join("")):T.push([y.offset[f],"*t",y.array,"p",f].join("")));T.length===0?m.push("q"+a+"=0"):m.push(["q",a,"=",T.join("+")].join(""))}var A=js([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));m=m.concat(A),m.length>0&&p.push("var "+m.join(","));for(var a=0;a<e.arrayArgs.length;++a)p.push("p"+a+"|=0");e.pre.body.length>3&&p.push(Te(e.pre,e,r));var b=Te(e.body,e,r),_=zs(c);_<s?p.push(Ps(_,c[0],e,b)):p.push(Et(c[0],e,b)),e.post.body.length>3&&p.push(Te(e.post,e,r)),e.debug&&console.log("-----Generated cwise routine for ",t,`:
13
13
  `+p.join(`
14
14
  `)+`
15
- ----------`);var E=[e.funcName||"unnamed","_cwise_loop_",n[0].join("s"),"m",_,zs(r)].join(""),x=new Function(["function ",E,"(",g.join(","),"){",p.join(`
16
- `),"} return ",E].join(""));return x()}var Ls=ks,$s=Ls;function Vs(e){var t=["'use strict'","var CACHED={}"],s=[],n=e.funcName+"_cwise_thunk";t.push(["return function ",n,"(",e.shimArgs.join(","),"){"].join(""));for(var r=[],a=[],i=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],l=[],o=[],u=0;u<e.arrayArgs.length;++u){var c=e.arrayArgs[u];s.push(["t",c,"=array",c,".dtype,","r",c,"=array",c,".order"].join("")),r.push("t"+c),r.push("r"+c),a.push("t"+c),a.push("r"+c+".join()"),i.push("array"+c+".data"),i.push("array"+c+".stride"),i.push("array"+c+".offset|0"),u>0&&(l.push("array"+e.arrayArgs[0]+".shape.length===array"+c+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[u]))),o.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+c+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[u])+"]"))}e.arrayArgs.length>1&&(t.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+o.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var u=0;u<e.scalarArgs.length;++u)i.push("scalar"+e.scalarArgs[u]);s.push(["type=[",a.join(","),"].join()"].join("")),s.push("proc=CACHED[type]"),t.push("var "+s.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",r.join(","),"])}","return proc(",i.join(","),")}"].join("")),e.debug&&console.log(`-----Generated thunk:
15
+ ----------`);var E=[e.funcName||"unnamed","_cwise_loop_",n[0].join("s"),"m",_,ks(r)].join(""),x=new Function(["function ",E,"(",g.join(","),"){",p.join(`
16
+ `),"} return ",E].join(""));return x()}var $s=Ls,Us=$s;function Vs(e){var t=["'use strict'","var CACHED={}"],s=[],n=e.funcName+"_cwise_thunk";t.push(["return function ",n,"(",e.shimArgs.join(","),"){"].join(""));for(var r=[],a=[],i=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],l=[],o=[],u=0;u<e.arrayArgs.length;++u){var c=e.arrayArgs[u];s.push(["t",c,"=array",c,".dtype,","r",c,"=array",c,".order"].join("")),r.push("t"+c),r.push("r"+c),a.push("t"+c),a.push("r"+c+".join()"),i.push("array"+c+".data"),i.push("array"+c+".stride"),i.push("array"+c+".offset|0"),u>0&&(l.push("array"+e.arrayArgs[0]+".shape.length===array"+c+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[u]))),o.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+c+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[u])+"]"))}e.arrayArgs.length>1&&(t.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+o.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var u=0;u<e.scalarArgs.length;++u)i.push("scalar"+e.scalarArgs[u]);s.push(["type=[",a.join(","),"].join()"].join("")),s.push("proc=CACHED[type]"),t.push("var "+s.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",r.join(","),"])}","return proc(",i.join(","),")}"].join("")),e.debug&&console.log(`-----Generated thunk:
17
17
  `+t.join(`
18
18
  `)+`
19
19
  ----------`);var h=new Function("compile",t.join(`
20
- `));return h($s.bind(void 0,e))}var Us=Vs,Fs=Us;function Ds(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function qs(e){var t=new Ds;t.pre=e.pre,t.body=e.body,t.post=e.post;var s=e.args.slice(0);t.argTypes=s;for(var n=0;n<s.length;++n){var r=s[n];if(r==="array"||typeof r=="object"&&r.blockIndices){if(t.argTypes[n]="array",t.arrayArgs.push(n),t.arrayBlockIndices.push(r.blockIndices?r.blockIndices:0),t.shimArgs.push("array"+n),n<t.pre.args.length&&t.pre.args[n].count>0)throw new Error("cwise: pre() block may not reference array args");if(n<t.post.args.length&&t.post.args[n].count>0)throw new Error("cwise: post() block may not reference array args")}else if(r==="scalar")t.scalarArgs.push(n),t.shimArgs.push("scalar"+n);else if(r==="index"){if(t.indexArgs.push(n),n<t.pre.args.length&&t.pre.args[n].count>0)throw new Error("cwise: pre() block may not reference array index");if(n<t.body.args.length&&t.body.args[n].lvalue)throw new Error("cwise: body() block may not write to array index");if(n<t.post.args.length&&t.post.args[n].count>0)throw new Error("cwise: post() block may not reference array index")}else if(r==="shape"){if(t.shapeArgs.push(n),n<t.pre.args.length&&t.pre.args[n].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(n<t.body.args.length&&t.body.args[n].lvalue)throw new Error("cwise: body() block may not write to array shape");if(n<t.post.args.length&&t.post.args[n].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof r=="object"&&r.offset)t.argTypes[n]="offset",t.offsetArgs.push({array:r.array,offset:r.offset}),t.offsetArgIndex.push(n);else throw new Error("cwise: Unknown argument type "+s[n])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>s.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>s.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>s.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,Fs(t)}var Bs=qs;(function(e){var t=Bs,s={body:"",args:[],thisVars:[],localVars:[]};function n(f){if(!f)return s;for(var g=0;g<f.args.length;++g){var p=f.args[g];g===0?f.args[g]={name:p,lvalue:!0,rvalue:!!f.rvalue,count:f.count||1}:f.args[g]={name:p,lvalue:!1,rvalue:!0,count:1}}return f.thisVars||(f.thisVars=[]),f.localVars||(f.localVars=[]),f}function r(f){return t({args:f.args,pre:n(f.pre),body:n(f.body),post:n(f.proc),funcName:f.funcName})}function a(f){for(var g=[],p=0;p<f.args.length;++p)g.push("a"+p);var m=new Function("P",["return function ",f.funcName,"_ndarrayops(",g.join(","),") {P(",g.join(","),");return a0}"].join(""));return m(r(f))}var i={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var f in i){var g=i[f];e[f]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:f}),e[f+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+g+"=b"},rvalue:!0,funcName:f+"eq"}),e[f+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:f+"s"}),e[f+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+g+"=s"},rvalue:!0,funcName:f+"seq"})}})();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var f in l){var g=l[f];e[f]=a({args:["array","array"],body:{args:["a","b"],body:"a="+g+"b"},funcName:f}),e[f+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+g+"a"},rvalue:!0,count:2,funcName:f+"eq"})}})();var o={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var f in o){var g=o[f];e[f]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:f}),e[f+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:f+"s"}),e[f+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+g+"b"},rvalue:!0,count:2,funcName:f+"eq"}),e[f+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+g+"s"},rvalue:!0,count:2,funcName:f+"seq"})}})();var u=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var f=0;f<u.length;++f){var g=u[f];e[g]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:g}),e[g+"eq"]=a({args:["array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"eq"})}})();var c=["max","min","atan2","pow"];(function(){for(var f=0;f<c.length;++f){var g=c[f];e[g]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g}),e[g+"s"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g+"s"}),e[g+"eq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"eq"}),e[g+"seq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"seq"})}})();var h=["atan2","pow"];(function(){for(var f=0;f<h.length;++f){var g=h[f];e[g+"op"]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"op"}),e[g+"ops"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"ops"}),e[g+"opeq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"opeq"}),e[g+"opseq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"opseq"})}})(),e.any=t({args:["array"],pre:s,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"}),e.all=t({args:["array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"}),e.sum=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"}),e.prod=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"}),e.norm2squared=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"}),e.norm2=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"}),e.norminf=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),e.norm1=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),e.sup=t({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.inf=t({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.argmin=t({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.argmax=t({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),e.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),e.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),e.equals=t({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})})(Ns);function Gs(e,t){if(!(e instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");const s=new Blob([e],{type:t}),n=URL.createObjectURL(s);return new Promise((r,a)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=function(){URL.revokeObjectURL(n);const o=new OffscreenCanvas(i.width,i.height).getContext("2d");o.drawImage(i,0,0);const u=o.getImageData(0,0,i.width,i.height);r(Ms(new Uint8Array(u.data),[i.width,i.height,4],[4,4*i.width,1],0))},i.onerror=l=>{URL.revokeObjectURL(n),a(l)},i.src=n})}async function Ws(e,t){return Gs(e,t)}function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)({}).hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},B.apply(null,arguments)}P.Mode;function D(e,t){return Object.defineProperty(t,"name",{value:e}),t}function H(e,t){const s=B({},e);for(const n in t)t[n]!==void 0&&(s[n]=t[n]);return s}class Ee{constructor(){this._map=new Map}get size(){return this._map.size}has(t){return this._map.has(t)}add(t,s){let n=this._map.get(t);return n||(n=new Set,this._map.set(t,n)),n.add(s),this}get(t){return this._map.get(t)||new Set}keys(){return this._map.keys()}}const Hs=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function We(e){return Hs.format(e)}function Xs(e,t,s=2){const n=e>t?"–":"+",r="%";return n+(Math.abs(e-t)/e*100).toFixed(s)+r}function Ks(e,t){return`${We(e)} → ${We(t)} (${Xs(e,t)})`}function wt(e){const t=[];for(const s of e.listAttributes())t.push(s);for(const s of e.listTargets())for(const n of s.listAttributes())t.push(n);return Array.from(new Set(t))}function Qs(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}function ee(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function Js(e,t=e){const s=It(e,t);for(let n=0;n<s.length;n++)s[n]=n;return s}function It(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function Mt(e){for(const t in e)return!1;return!0}var fe=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function Ys(e,t){var s=t[0],n=t[1],r=t[2],a=t[3],i=t[4],l=t[5],o=t[6],u=t[7],c=t[8],h=t[9],f=t[10],g=t[11],p=t[12],m=t[13],d=t[14],y=t[15],T=s*l-n*i,A=s*o-r*i,b=s*u-a*i,_=n*o-r*l,E=n*u-a*l,x=r*u-a*o,L=c*m-h*p,X=c*d-f*p,K=c*y-g*p,Q=h*d-f*m,J=h*y-g*m,Y=f*y-g*d,M=T*Y-A*J+b*Q+_*K-E*X+x*L;return M?(M=1/M,e[0]=(l*Y-o*J+u*Q)*M,e[1]=(r*J-n*Y-a*Q)*M,e[2]=(m*x-d*E+y*_)*M,e[3]=(f*E-h*x-g*_)*M,e[4]=(o*K-i*Y-u*X)*M,e[5]=(s*Y-r*K+a*X)*M,e[6]=(d*b-p*x-y*A)*M,e[7]=(c*x-f*b+g*A)*M,e[8]=(i*J-l*K+u*L)*M,e[9]=(n*K-s*J-a*L)*M,e[10]=(p*E-m*b+y*T)*M,e[11]=(h*b-c*E-g*T)*M,e[12]=(l*X-i*Q-o*L)*M,e[13]=(s*Q-n*X+r*L)*M,e[14]=(m*A-p*_-d*T)*M,e[15]=(c*_-h*A+f*T)*M,e):null}function ke(e,t,s){var n=t[0],r=t[1],a=t[2],i=t[3],l=t[4],o=t[5],u=t[6],c=t[7],h=t[8],f=t[9],g=t[10],p=t[11],m=t[12],d=t[13],y=t[14],T=t[15],A=s[0],b=s[1],_=s[2],E=s[3];return e[0]=A*n+b*l+_*h+E*m,e[1]=A*r+b*o+_*f+E*d,e[2]=A*a+b*u+_*g+E*y,e[3]=A*i+b*c+_*p+E*T,A=s[4],b=s[5],_=s[6],E=s[7],e[4]=A*n+b*l+_*h+E*m,e[5]=A*r+b*o+_*f+E*d,e[6]=A*a+b*u+_*g+E*y,e[7]=A*i+b*c+_*p+E*T,A=s[8],b=s[9],_=s[10],E=s[11],e[8]=A*n+b*l+_*h+E*m,e[9]=A*r+b*o+_*f+E*d,e[10]=A*a+b*u+_*g+E*y,e[11]=A*i+b*c+_*p+E*T,A=s[12],b=s[13],_=s[14],E=s[15],e[12]=A*n+b*l+_*h+E*m,e[13]=A*r+b*o+_*f+E*d,e[14]=A*a+b*u+_*g+E*y,e[15]=A*i+b*c+_*p+E*T,e}function Zs(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function en(e,t,s,n){var r=t[0],a=t[1],i=t[2],l=t[3],o=r+r,u=a+a,c=i+i,h=r*o,f=r*u,g=r*c,p=a*u,m=a*c,d=i*c,y=l*o,T=l*u,A=l*c,b=n[0],_=n[1],E=n[2];return e[0]=(1-(p+d))*b,e[1]=(f+A)*b,e[2]=(g-T)*b,e[3]=0,e[4]=(f-A)*_,e[5]=(1-(h+d))*_,e[6]=(m+y)*_,e[7]=0,e[8]=(g+T)*E,e[9]=(m-y)*E,e[10]=(1-(h+p))*E,e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e}function tn(){var e=new fe(3);return fe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function sn(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e}function Ne(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e[2]=Math.min(t[2],s[2]),e}function Ce(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e[2]=Math.max(t[2],s[2]),e}function He(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function nn(e,t,s){var n=t[0],r=t[1],a=t[2],i=s[3]*n+s[7]*r+s[11]*a+s[15];return i=i||1,e[0]=(s[0]*n+s[4]*r+s[8]*a+s[12])/i,e[1]=(s[1]*n+s[5]*r+s[9]*a+s[13])/i,e[2]=(s[2]*n+s[6]*r+s[10]*a+s[14])/i,e}var rn=sn;(function(){var e=tn();return function(t,s,n,r,a,i){var l,o;for(s||(s=3),n||(n=0),r?o=Math.min(r*s+n,t.length):o=t.length,l=n;l<o;l+=s)e[0]=t[l],e[1]=t[l+1],e[2]=t[l+2],a(e,e,i),t[l]=e[0],t[l+1]=e[1],t[l+2]=e[2];return t}})();const F="dedup",we={keepUniqueNames:!1,propertyTypes:[v.ACCESSOR,v.MESH,v.TEXTURE,v.MATERIAL,v.SKIN]};function an(e=we){const t=H(we,e),s=new Set(t.propertyTypes);for(const n of t.propertyTypes)if(!we.propertyTypes.includes(n))throw new Error(`${F}: Unsupported deduplication on type "${n}".`);return D(F,n=>{const r=n.getLogger();s.has(v.ACCESSOR)&&on(n),s.has(v.TEXTURE)&&cn(n,t),s.has(v.MATERIAL)&&fn(n,t),s.has(v.MESH)&&ln(n,t),s.has(v.SKIN)&&un(n,t),r.debug(`${F}: Complete.`)})}function on(e){const t=e.getLogger(),s=new Map,n=new Map,r=new Map,a=new Map,i=e.getRoot().listMeshes();i.forEach(h=>{h.listPrimitives().forEach(f=>{f.listAttributes().forEach(g=>l(g,n)),l(f.getIndices(),s)})});for(const h of e.getRoot().listAnimations())for(const f of h.listSamplers())l(f.getInput(),r),l(f.getOutput(),a);function l(h,f){if(!h)return;const g=[h.getCount(),h.getType(),h.getComponentType(),h.getNormalized(),h.getSparse()].join(":");let p=f.get(g);p||f.set(g,p=new Set),p.add(h)}function o(h,f){for(let g=0;g<h.length;g++){const p=h[g],m=N.toView(p.getArray());if(!f.has(p))for(let d=g+1;d<h.length;d++){const y=h[d];f.has(y)||N.equals(m,N.toView(y.getArray()))&&f.set(y,p)}}}let u=0;const c=new Map;for(const h of[n,s,r,a])for(const f of h.values())u+=f.size,o(Array.from(f),c);t.debug(`${F}: Merged ${c.size} of ${u} accessors.`),i.forEach(h=>{h.listPrimitives().forEach(f=>{f.listAttributes().forEach(p=>{c.has(p)&&f.swap(p,c.get(p))});const g=f.getIndices();g&&c.has(g)&&f.swap(g,c.get(g))})});for(const h of e.getRoot().listAnimations())for(const f of h.listSamplers()){const g=f.getInput(),p=f.getOutput();g&&c.has(g)&&f.swap(g,c.get(g)),p&&c.has(p)&&f.swap(p,c.get(p))}Array.from(c.keys()).forEach(h=>h.dispose())}function ln(e,t){const s=e.getLogger(),n=e.getRoot(),r=new Map;n.listAccessors().forEach((l,o)=>r.set(l,o)),n.listMaterials().forEach((l,o)=>r.set(l,o));const a=n.listMeshes().length,i=new Map;for(const l of n.listMeshes()){const o=[];for(const c of l.listPrimitives())o.push(Nt(c,r));let u="";if(t.keepUniqueNames&&(u+=l.getName()+";"),u+=o.join(";"),i.has(u)){const c=i.get(u);l.listParents().forEach(h=>{h.propertyType!==v.ROOT&&h.swap(l,c)}),l.dispose()}else i.set(u,l)}s.debug(`${F}: Merged ${a-i.size} of ${a} meshes.`)}function cn(e,t){const s=e.getLogger(),n=e.getRoot(),r=n.listTextures(),a=new Map;for(let i=0;i<r.length;i++){const l=r[i],o=l.getImage();if(!a.has(l))for(let u=i+1;u<r.length;u++){const c=r[u],h=c.getImage();if(a.has(c)||l.getMimeType()!==c.getMimeType()||t.keepUniqueNames&&l.getName()!==c.getName())continue;const f=l.getSize(),g=c.getSize();!f||!g||f[0]===g[0]&&f[1]===g[1]&&(!o||!h||N.equals(o,h)&&a.set(c,l))}}s.debug(`${F}: Merged ${a.size} of ${n.listTextures().length} textures.`),Array.from(a.entries()).forEach(([i,l])=>{i.listParents().forEach(o=>{o instanceof me||o.swap(i,l)}),i.dispose()})}function fn(e,t){const s=e.getLogger(),r=e.getRoot().listMaterials(),a=new Map,i=new Map,l=new Set;t.keepUniqueNames||l.add("name");for(let o=0;o<r.length;o++){const u=r[o];if(!a.has(u)&&!Xe(u,i))for(let c=o+1;c<r.length;c++){const h=r[c];a.has(h)||Xe(h,i)||u.equals(h,l)&&a.set(h,u)}}s.debug(`${F}: Merged ${a.size} of ${r.length} materials.`),Array.from(a.entries()).forEach(([o,u])=>{o.listParents().forEach(c=>{c instanceof me||c.swap(o,u)}),o.dispose()})}function un(e,t){const s=e.getLogger(),r=e.getRoot().listSkins(),a=new Map,i=new Set(["joints"]);t.keepUniqueNames||i.add("name");for(let l=0;l<r.length;l++){const o=r[l];if(!a.has(o))for(let u=l+1;u<r.length;u++){const c=r[u];a.has(c)||o.equals(c,i)&&Qs(o.listJoints(),c.listJoints())&&a.set(c,o)}}s.debug(`${F}: Merged ${a.size} of ${r.length} skins.`),Array.from(a.entries()).forEach(([l,o])=>{l.listParents().forEach(u=>{u instanceof me||u.swap(l,o)}),l.dispose()})}function Nt(e,t){const s=[];for(const n of e.listSemantics()){const r=e.getAttribute(n);s.push(n+":"+t.get(r))}if(e instanceof P){const n=e.getIndices();n&&s.push("indices:"+t.get(n));const r=e.getMaterial();r&&s.push("material:"+t.get(r)),s.push("mode:"+e.getMode());for(const a of e.listTargets())s.push("target:"+Nt(a,t))}return s.join(",")}function Xe(e,t){if(t.has(e))return t.get(e);const s=e.getGraph(),n=new Set,r=s.listParentEdges(e);for(;r.length>0;){const a=r.pop();if(a.getAttributes().modifyChild===!0)return t.set(e,!0),!0;const i=a.getChild();if(!n.has(i))for(const l of s.listChildEdges(i))r.push(l)}return t.set(e,!1),!1}function Ct(){var e=new fe(4);return fe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function hn(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e}function gn(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e}function pn(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e[3]=t[3]*s[3],e}function dn(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e}function mn(e){var t=e[0],s=e[1],n=e[2],r=e[3];return Math.hypot(t,s,n,r)}var St=gn,yn=pn,Ot=mn;(function(){var e=Ct();return function(t,s,n,r,a,i){var l,o;for(s||(s=4),n||(n=0),r?o=Math.min(r*s+n,t.length):o=t.length,l=n;l<o;l+=s)e[0]=t[l],e[1]=t[l+1],e[2]=t[l+2],e[3]=t[l+3],a(e,e,i),t[l]=e[0],t[l+1]=e[1],t[l+2]=e[2],t[l+3]=e[3];return t}})();const bn=/color|emissive|diffuse/i;function vn(e){return e.getGraph().listParentEdges(e).some(r=>r.getAttributes().isColor||bn.test(r.getName()))?"srgb":null}function An(e){const t=e.getGraph(),s=new Set,n=new Set;function r(a){const i=new Set;for(const l of t.listChildEdges(a))l.getChild()instanceof Me&&i.add(l.getName()+"Info");for(const l of t.listChildEdges(a)){const o=l.getChild();s.has(o)||(s.add(o),o instanceof yt&&i.has(l.getName())?n.add(o):o instanceof bt&&r(o))}}return r(e),Array.from(n)}function _n(e){const s=ze.fromGraph(e.getGraph()).getRoot(),n=e.getGraph().listParentEdges(e).filter(r=>r.getParent()!==s).map(r=>r.getName());return Array.from(new Set(n))}const q="prune",Se=3/255,Ke={propertyTypes:[v.NODE,v.SKIN,v.MESH,v.CAMERA,v.PRIMITIVE,v.PRIMITIVE_TARGET,v.ANIMATION,v.MATERIAL,v.TEXTURE,v.ACCESSOR,v.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function xt(e=Ke){const t=H(Ke,e),s=new Set(t.propertyTypes),n=t.keepExtras;return D(q,async r=>{const a=r.getLogger(),i=r.getRoot(),l=r.getGraph(),o=new Tn,u=c=>o.dispose(c.target);if(l.addEventListener("node:dispose",u),s.has(v.MESH))for(const c of i.listMeshes())c.listPrimitives().length>0||c.dispose();if(s.has(v.NODE)){if(!t.keepLeaves)for(const c of i.listScenes())jt(l,c,n);for(const c of i.listNodes())S(c,n)}if(s.has(v.SKIN))for(const c of i.listSkins())S(c,n);if(s.has(v.MESH))for(const c of i.listMeshes())S(c,n);if(s.has(v.CAMERA))for(const c of i.listCameras())S(c,n);if(s.has(v.PRIMITIVE)&&Qe(l,v.PRIMITIVE,n),s.has(v.PRIMITIVE_TARGET)&&Qe(l,v.PRIMITIVE_TARGET,n),!t.keepAttributes&&s.has(v.ACCESSOR)){const c=new Map;for(const h of i.listMeshes())for(const f of h.listPrimitives()){const g=f.getMaterial();if(!g)continue;const p=Rt(r,f,g),m=wn(f,p);Je(f,m),f.listTargets().forEach(d=>Je(d,m)),c.has(g)?c.get(g).add(f):c.set(g,new Set([f]))}for(const[h,f]of c)In(h,Array.from(f))}if(!t.keepIndices&&s.has(v.ACCESSOR))for(const c of i.listMeshes())for(const h of c.listPrimitives())En(h);if(s.has(v.ANIMATION))for(const c of i.listAnimations()){for(const h of c.listChannels())h.getTargetNode()||h.dispose();if(c.listChannels().length)c.listSamplers().forEach(h=>S(h,n));else{const h=c.listSamplers();S(c,n),h.forEach(f=>S(f,n))}}if(s.has(v.MATERIAL)&&i.listMaterials().forEach(c=>S(c,n)),s.has(v.TEXTURE)&&(i.listTextures().forEach(c=>S(c,n)),t.keepSolidTextures||await Mn(r)),s.has(v.ACCESSOR)&&i.listAccessors().forEach(c=>S(c,n)),s.has(v.BUFFER)&&i.listBuffers().forEach(c=>S(c,n)),l.removeEventListener("node:dispose",u),o.empty())a.debug(`${q}: No unused properties found.`);else{const c=o.entries().map(([h,f])=>`${h} (${f})`).join(", ");a.info(`${q}: Removed types... ${c}`)}a.debug(`${q}: Complete.`)})}class Tn{constructor(){this.disposed={}}empty(){for(const t in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(t){this.disposed[t.propertyType]=this.disposed[t.propertyType]||0,this.disposed[t.propertyType]++}}function S(e,t){const s=e.listParents().filter(r=>!(r instanceof me||r instanceof Pe)),n=t&&!Mt(e.getExtras());!s.length&&!n&&e.dispose()}function Qe(e,t,s){for(const n of e.listEdges()){const r=n.getParent();r.propertyType===t&&S(r,s)}}function jt(e,t,s){if(t.listChildren().forEach(i=>jt(e,i,s)),t instanceof es)return;const n=e.listParentEdges(t).some(i=>{const l=i.getParent().propertyType;return l!==v.ROOT&&l!==v.SCENE&&l!==v.NODE}),r=e.listChildren(t).length===0,a=s&&!Mt(t.getExtras());r&&!n&&!a&&t.dispose()}function Je(e,t){for(const s of t)e.setAttribute(s,null)}function En(e){const t=e.getIndices(),s=t&&t.getArray(),n=e.listAttributes()[0];if(!(!s||!n)&&t.getCount()===n.getCount()){for(let r=0,a=s.length;r<a;r++)if(r!==s[r])return;e.setIndices(null)}}function wn(e,t){const s=[];for(const n of e.listSemantics())(n==="NORMAL"&&!t.has(n)||n==="TANGENT"&&!t.has(n)||n.startsWith("TEXCOORD_")&&!t.has(n)||n.startsWith("COLOR_")&&n!=="COLOR_0")&&s.push(n);return s}function Rt(e,t,s,n=new Set){const a=e.getGraph().listChildEdges(s),i=new Set;for(const u of a)u.getChild()instanceof Me&&i.add(u.getName());for(const u of a){const c=u.getName(),h=u.getChild();h instanceof yt&&i.has(c.replace(/Info$/,""))&&n.add(`TEXCOORD_${h.getTexCoord()}`),h instanceof Me&&c.match(/normalTexture/i)&&n.add("TANGENT"),h instanceof bt&&Rt(e,t,h,n)}const l=s instanceof vt&&!s.getExtension("KHR_materials_unlit"),o=t.getMode()===P.Mode.POINTS;return l&&!o&&n.add("NORMAL"),n}function In(e,t){const s=An(e),n=new Set(s.map(o=>o.getTexCoord())),r=Array.from(n).sort(),a=new Map(r.map((o,u)=>[o,u])),i=new Map(r.map((o,u)=>[`TEXCOORD_${o}`,`TEXCOORD_${u}`]));for(const o of s){const u=o.getTexCoord();o.setTexCoord(a.get(u))}for(const o of t){const u=o.listSemantics().filter(c=>c.startsWith("TEXCOORD_")).sort();l(o,u),o.listTargets().forEach(c=>l(c,u))}function l(o,u){for(const c of u){const h=o.getAttribute(c);if(!h)continue;const f=i.get(c);f!==c&&(o.setAttribute(f,h),o.setAttribute(c,null))}}}async function Mn(e){const t=e.getRoot(),s=e.getGraph(),n=e.getLogger(),a=t.listTextures().map(async i=>{var l;const o=await Cn(i);if(!o)return;vn(i)==="srgb"&&ts.convertSRGBToLinear(o,o);const u=i.getName()||i.getURI(),c=(l=i.getSize())==null?void 0:l.join("x"),h=_n(i);for(const f of s.listParentEdges(i)){const g=f.getParent();g!==t&&Nn(g,o,f.getName(),n)&&f.dispose()}i.listParents().length===1&&(i.dispose(),n.debug(`${q}: Removed solid-color texture "${u}" (${c}px ${h.join(", ")})`))});await Promise.all(a)}function Nn(e,t,s,n){if(e instanceof vt)switch(s){case"baseColorTexture":return e.setBaseColorFactor(yn(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor(rn([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=Se;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return Ot(St(Ct(),t,[.5,.5,1,1]))<=Se}return n.warn(`${q}: Detected single-color ${s} texture. Pruning ${s} not yet supported.`),!1}async function Cn(e){const t=await Sn(e);if(!t)return null;const s=[1/0,1/0,1/0,1/0],n=[-1/0,-1/0,-1/0,-1/0],r=[0,0,0,0],[a,i]=t.shape;for(let l=0;l<a;l++){for(let o=0;o<i;o++)for(let u=0;u<4;u++)s[u]=Math.min(s[u],t.get(l,o,u)),n[u]=Math.max(n[u],t.get(l,o,u));if(Ot(St(r,n,s))/255>Se)return null}return dn(r,hn(r,n,s),.5/255)}async function Sn(e){try{return await Ws(e.getImage(),e.getMimeType())}catch{return null}}const Ye=2**32-1;var C;(function(e){e.RENDER="render",e.RENDER_CACHED="render-cached",e.UPLOAD="upload",e.UPLOAD_NAIVE="upload-naive",e.DISTINCT="distinct",e.DISTINCT_POSITION="distinct-position",e.UNUSED="unused"})(C||(C={}));function ue(e,t){const s=e.getAttribute("POSITION"),n=e.getIndices();switch(t){case C.RENDER:return n?n.getCount():s.getCount();case C.RENDER_CACHED:return n?new Set(n.getArray()).size:s.getCount();case C.UPLOAD_NAIVE:case C.UPLOAD:return s.getCount();case C.DISTINCT:case C.DISTINCT_POSITION:return On(t);case C.UNUSED:return n?s.getCount()-new Set(n.getArray()).size:0;default:return xn(t)}}function On(e){throw new Error(`Not implemented: ${e}`)}function xn(e){throw new Error(`Unexpected value: ${e}`)}function jn(e,t,s){const n=ze.fromGraph(e.getGraph());(!t||!s)&&([t,s]=Rn(e));const r=e.getIndices(),a=r?r.getArray():null,i=ue(e,C.RENDER),l=n.createAccessor(),o=i,u=It(o,s);for(let h=0;h<o;h++)u[h]=t[a?a[h]:h];e.setIndices(l.setArray(u));const c=wt(e);for(const h of e.listAttributes()){const f=ee(n,h);Oe(h,r,t,f,s),e.swap(h,f)}for(const h of e.listTargets())for(const f of h.listAttributes()){const g=ee(n,f);Oe(f,r,t,g,s),h.swap(f,g)}r&&r.listParents().length===1&&r.dispose();for(const h of c)h.listParents().length===1&&h.dispose();return e}function Oe(e,t,s,n,r){const a=e.getElementSize(),i=e.getArray(),l=t?t.getArray():null,o=t?t.getCount():e.getCount(),u=new i.constructor(r*a),c=new Uint8Array(r);for(let h=0;h<o;h++){const f=l?l[h]:h,g=s[f];if(!c[g]){for(let p=0;p<a;p++)u[g*a+p]=i[f*a+p];c[g]=1}}return n.setArray(u)}function Rn(e){const t=ue(e,C.UPLOAD),s=e.getIndices(),n=s?s.getArray():null;if(!s||!n)return[Js(t,1e6),t];const r=new Uint32Array(t).fill(Ye);let a=0;for(let i=0;i<n.length;i++){const l=n[i];r[l]===Ye&&(r[l]=a++)}return[r,a]}Ie.ComponentType;P.Mode;P.Mode;const ne="reorder",Pn={target:"size",cleanup:!0};function zn(e){const t=H(Pn,e),s=t.encoder;if(!s)throw new Error(`${ne}: encoder dependency required — install "meshoptimizer".`);return D(ne,async n=>{const r=n.getLogger();await s.ready;const a=kn(n);for(const i of a.indicesToAttributes.keys()){let l=i.getArray();l instanceof Uint32Array?l=l.slice():l=new Uint32Array(l);const[o,u]=s.reorderMesh(l,a.indicesToMode.get(i)===P.Mode.TRIANGLES,t.target==="size"),c=ee(n,i);c.setArray(u<=65534?new Uint16Array(l):l);for(const h of a.indicesToAttributes.get(i)){const f=ee(n,h);Oe(h,i,o,f,u);for(const g of a.indicesToPrimitives.get(i)){g.getIndices()===i&&g.swap(i,c),g.swap(h,f);for(const p of g.listTargets())p.swap(h,f)}}}t.cleanup&&await n.transform(xt({propertyTypes:[v.ACCESSOR],keepAttributes:!0,keepIndices:!0})),a.indicesToAttributes.size?r.debug(`${ne}: Complete.`):r.warn(`${ne}: No qualifying primitives found; may need to weld first.`)})}function kn(e){const t=new Map,s=new Ee,n=new Ee,r=new Ee;for(const a of e.getRoot().listMeshes())for(const i of a.listPrimitives()){const l=i.getIndices();if(l){t.set(l,i.getMode()),s.add(l,i);for(const o of wt(i))n.add(l,o),r.add(o,i)}}return{indicesToPrimitives:s,indicesToAttributes:n,indicesToMode:t,attributesToPrimitives:r}}function Ln(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw new Error("Limit must be positive multiple of four.");const s=e.getAttribute("POSITION").getCount(),n=e.listSemantics().filter(u=>u.startsWith("WEIGHTS_")).length,r=new Uint16Array(n*4),a=new Float32Array(n*4),i=new Float32Array(n*4),l=new Uint32Array(n*4),o=new Uint32Array(n*4);for(let u=0;u<s;u++){he(e,u,"WEIGHTS",a),he(e,u,"JOINTS",l);for(let c=0;c<n*4;c++)r[c]=c;r.sort((c,h)=>a[c]>a[h]?-1:1);for(let c=0;c<r.length;c++)i[c]=a[r[c]],o[c]=l[r[c]];ge(e,u,"WEIGHTS",i),ge(e,u,"JOINTS",o)}for(let u=n;u*4>t;u--){const c=e.getAttribute(`WEIGHTS_${u-1}`),h=e.getAttribute(`JOINTS_${u-1}`);e.setAttribute(`WEIGHTS_${u-1}`,null),e.setAttribute(`JOINTS_${u-1}`,null),c.listParents().length===1&&c.dispose(),h.listParents().length===1&&h.dispose()}$n(e)}function $n(e){if(!Vn(e))return;const t=e.getAttribute("POSITION").getCount(),s=e.listSemantics().filter(h=>h.startsWith("WEIGHTS_")).length,n=e.getAttribute("WEIGHTS_0"),r=n.getArray(),a=n.getComponentType(),i=n.getNormalized(),l=i?a:void 0,o=i?V.decodeNormalizedInt(1,a):Number.EPSILON,u=new Uint32Array(s*4).fill(0),c=r.slice(0,s*4).fill(0);for(let h=0;h<t;h++){he(e,h,"JOINTS",u),he(e,h,"WEIGHTS",c,l);let f=Ze(c,l);if(f!==0&&f!==1){if(Math.abs(1-f)>o)for(let g=0;g<c.length;g++)if(i){const p=V.decodeNormalizedInt(c[g],a);c[g]=V.encodeNormalizedInt(p/f,a)}else c[g]/=f;if(f=Ze(c,l),i&&f!==1){for(let g=c.length-1;g>=0;g--)if(c[g]>0){const p=1-f;c[g]+=Math.sign(p)*V.encodeNormalizedInt(Math.abs(p),a);break}}}for(let g=c.length-1;g>=0;g--)c[g]===0&&(u[g]=0);ge(e,h,"JOINTS",u),ge(e,h,"WEIGHTS",c,l)}}function he(e,t,s,n,r){let a;const i=[0,0,0,0];for(let l=0;a=e.getAttribute(`${s}_${l}`);l++){a.getElement(t,i);for(let o=0;o<4;o++)r?n[l*4+o]=V.encodeNormalizedInt(i[o],r):n[l*4+o]=i[o]}return n}function ge(e,t,s,n,r){let a;const i=[0,0,0,0];for(let l=0;a=e.getAttribute(`${s}_${l}`);l++){for(let o=0;o<4;o++)r?i[o]=V.decodeNormalizedInt(n[l*4+o],r):i[o]=n[l*4+o];a.setElement(t,i)}}function Ze(e,t){let s=0;for(let n=0;n<e.length;n++)t?s+=V.decodeNormalizedInt(e[n],t):s+=e[n];return s}function Vn(e){const t=e.listSemantics().filter(r=>r.startsWith("WEIGHTS_")).map(r=>e.getAttribute(r)),s=t.map(r=>r.getNormalized()),n=t.map(r=>r.getComponentType());return new Set(s).size===1&&new Set(n).size===1}const U="quantize",Un=[Int8Array,Int16Array,Int32Array],{TRANSLATION:Fn,ROTATION:Dn,SCALE:qn,WEIGHTS:Bn}=Pe.TargetPath,Gn=[Fn,Dn,qn],oe={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};function Le(e=oe){const t=H(oe,B({patternTargets:e.pattern||oe.pattern},e));return D(U,async s=>{const n=s.getLogger(),r=s.getRoot();let a;t.quantizationVolume==="scene"&&(a=tt(Zn(r.listMeshes().map(st))));for(const l of s.getRoot().listMeshes()){t.quantizationVolume==="mesh"&&(a=tt(st(l))),a&&t.pattern.test("POSITION")&&(Wn(s,l,a),Kn(l,1/a.scale));for(const o of l.listPrimitives()){const u=ue(o,C.RENDER),c=ue(o,C.UPLOAD);u<c/2&&jn(o),et(s,o,a,t);for(const h of o.listTargets())et(s,h,a,t)}}r.listMeshes().flatMap(l=>l.listPrimitives()).some(Pt)&&s.createExtension(mt).setRequired(!0),t.cleanup&&await s.transform(xt({propertyTypes:[v.ACCESSOR,v.SKIN,v.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),an({propertyTypes:[v.ACCESSOR,v.MATERIAL,v.SKIN],keepUniqueNames:!0})),n.debug(`${U}: Complete.`)})}function et(e,t,s,n){const r=t instanceof ss,a=e.getLogger();for(const i of t.listSemantics()){if(!r&&!n.pattern.test(i)||r&&!n.patternTargets.test(i))continue;const l=t.getAttribute(i),{bits:o,ctor:u}=Jn(i,l,a,n);if(!u)continue;if(o<8||o>16)throw new Error(`${U}: Requires bits = 8–16.`);if(l.getComponentSize()<=o/8)continue;const c=l.clone();if(i==="POSITION"){const h=s.scale,f=[];t instanceof P?Ys(f,ye(s)):Zs(f,[1/h,1/h,1/h]);for(let g=0,p=[0,0,0],m=c.getCount();g<m;g++)c.getElement(g,p),c.setElement(g,nn(p,p,f))}Qn(c,u,o),t.setAttribute(i,c)}if(n.normalizeWeights&&t.getAttribute("WEIGHTS_0")&&Ln(t,1/0),t instanceof P&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){const i=t.getIndices();i.setArray(new Uint16Array(i.getArray()))}}function tt(e){const{min:t,max:s}=e,n=Math.max((s[0]-t[0])/2,(s[1]-t[1])/2,(s[2]-t[2])/2);return{offset:[t[0]+(s[0]-t[0])/2,t[1]+(s[1]-t[1])/2,t[2]+(s[2]-t[2])/2],scale:n}}function Wn(e,t,s){const n=ye(s);for(const r of t.listParents()){if(!(r instanceof Zt))continue;const a=r.listParents().filter(f=>f instanceof Pe),i=a.some(f=>Gn.includes(f.getTargetPath())),l=r.listChildren().length>0,o=r.getSkin();if(o){r.setSkin(Hn(o,s));continue}const u=r.getExtension("EXT_mesh_gpu_instancing");if(u){r.setExtension("EXT_mesh_gpu_instancing",Xn(u,s));continue}let c;l||i?(c=e.createNode("").setMesh(t),r.addChild(c).setMesh(null),a.filter(f=>f.getTargetPath()===Bn).forEach(f=>f.setTargetNode(c))):c=r;const h=c.getMatrix();ke(h,h,n),c.setMatrix(h)}}function Hn(e,t){e=e.clone();const s=ye(t),n=e.getInverseBindMatrices().clone(),r=[];for(let a=0,i=n.getCount();a<i;a++)n.getElement(a,r),ke(r,r,s),n.setElement(a,r);return e.setInverseBindMatrices(n)}function Xn(e,t){var s,n,r;if(!e.getAttribute("TRANSLATION")&&!e.getAttribute("ROTATION")&&!e.getAttribute("SCALE"))return e;e=e.clone();const a=(s=e.getAttribute("TRANSLATION"))==null?void 0:s.clone(),i=(n=e.getAttribute("ROTATION"))==null?void 0:n.clone(),l=(r=e.getAttribute("SCALE"))==null?void 0:r.clone(),o=a||i||l,u=[0,0,0],c=[0,0,0,1],h=[1,1,1],f=[0,0,0],g=[0,0,0,1],p=[1,1,1],m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],d=ye(t);for(let y=0,T=o.getCount();y<T;y++)V.compose(a?a.getElement(y,f):u,i?i.getElement(y,g):c,l?l.getElement(y,p):h,m),ke(m,m,d),V.decompose(m,f,g,p),a&&a.setElement(y,f),i&&i.setElement(y,g),l&&l.setElement(y,p);return a&&e.setAttribute("TRANSLATION",a),i&&e.setAttribute("ROTATION",i),l&&e.setAttribute("SCALE",l),e}function Kn(e,t){for(const s of e.listPrimitives()){let n=s.getMaterial();if(!n)continue;let r=n.getExtension("KHR_materials_volume");!r||r.getThicknessFactor()<=0||(r=r.clone().setThicknessFactor(r.getThicknessFactor()*t),n=n.clone().setExtension("KHR_materials_volume",r),s.setMaterial(n))}}function Qn(e,t,s){const n=new t(e.getArray().length),r=Un.includes(t)?1:0,a=s-r,i=t.BYTES_PER_ELEMENT*8-r,l=Math.pow(2,a)-1,o=i-a,u=2*a-i,c=[r>0?-1:0,1];for(let h=0,f=0,g=[];h<e.getCount();h++){e.getElement(h,g);for(let p=0;p<g.length;p++){let m=er(g[p],c);m=Math.round(Math.abs(m)*l),m=m<<o|m>>u,n[f++]=m*Math.sign(g[p])}}e.setArray(n).setNormalized(!0).setSparse(!1)}function Jn(e,t,s,n){const r=t.getMinNormalized([]),a=t.getMaxNormalized([]);let i,l;if(e==="POSITION")i=n.quantizePosition,l=i<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")i=n.quantizeNormal,l=i<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))i=n.quantizeColor,l=i<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(r.some(o=>o<0)||a.some(o=>o>1))return s.warn(`${U}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=n.quantizeTexcoord,l=i<=8?Uint8Array:Uint16Array}else{if(e.startsWith("JOINTS_"))return i=Math.max(...t.getMax([]))<=255?8:16,l=i<=8?Uint8Array:Uint16Array,t.getComponentSize()>i/8&&t.setArray(new l(t.getArray())),{bits:-1};if(e.startsWith("WEIGHTS_")){if(r.some(o=>o<0)||a.some(o=>o>1))return s.warn(`${U}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=n.quantizeWeight,l=i<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(r.some(o=>o<-1)||a.some(o=>o>1))return s.warn(`${U}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};i=n.quantizeGeneric,l=r.some(o=>o<0)?l=i<=8?Int8Array:Int16Array:l=i<=8?Uint8Array:Uint16Array}else throw new Error(`${U}: Unexpected semantic, "${e}".`)}return{bits:i,ctor:l}}function st(e){const t=[],s=[];for(const r of e.listPrimitives()){const a=r.getAttribute("POSITION");a&&t.push(a);for(const i of r.listTargets()){const l=i.getAttribute("POSITION");l&&s.push(l)}}if(t.length===0)throw new Error(`${U}: Missing "POSITION" attribute.`);const n=nt(t,3);if(s.length>0){const{min:r,max:a}=nt(s,3);Ne(n.min,n.min,Ne(r,He(r,r,2),[0,0,0])),Ce(n.max,n.max,Ce(a,He(a,a,2),[0,0,0]))}return n}function Yn(e,t){const s=t.getComponentSize();if(e==="POSITION"||e==="NORMAL"||e==="TANGENT")return s<4;if(e.startsWith("TEXCOORD_")){const n=t.getComponentType(),r=t.getNormalized();return s<4&&!(r&&n===Ie.ComponentType.UNSIGNED_BYTE)&&!(r&&n===Ie.ComponentType.UNSIGNED_SHORT)}return!1}function Pt(e){for(const t of e.listSemantics()){const s=e.getAttribute("POSITION");if(Yn(t,s))return!0}return e.propertyType===v.PRIMITIVE?e.listTargets().some(Pt):!1}function nt(e,t){const s=new Array(t).fill(1/0),n=new Array(t).fill(-1/0),r=[],a=[];for(const i of e){i.getMinNormalized(r),i.getMaxNormalized(a);for(let l=0;l<t;l++)s[l]=Math.min(s[l],r[l]),n[l]=Math.max(n[l],a[l])}return{min:s,max:n}}function Zn(e){const t=e[0];for(const s of e)Ne(t.min,t.min,s.min),Ce(t.max,t.max,s.max);return t}function ye(e){return en([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function er(e,t){return Math.min(Math.max(e,t[0]),t[1])}const tr=B({level:"high"},oe),rt="meshopt";function zt(e){const t=H(tr,e),s=t.encoder;if(!s)throw new Error(`${rt}: encoder dependency required — install "meshoptimizer".`);return D(rt,async n=>{let r,a,i=t.quantizeNormal;n.getRoot().listAccessors().length!==0&&(t.level==="medium"?(r=/.*/,a=/.*/):(r=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR)(_\d+)?$/,a=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR|NORMAL|TANGENT)(_\d+)?$/,i=Math.min(i,8)),await n.transform(zn({encoder:s,target:"size"}),Le(B({},t,{pattern:r,patternTargets:a,quantizeNormal:i}))),n.createExtension(ie).setRequired(!0).setEncoderOptions({method:t.level==="medium"?ie.EncoderMethod.QUANTIZE:ie.EncoderMethod.FILTER}))})}const xe="unweld",sr={};function nr(e=sr){return D(xe,t=>{const s=t.getLogger(),n=new Map;for(const r of t.getRoot().listMeshes())for(const a of r.listPrimitives())rr(a,n);s.debug(`${xe}: Complete.`)})}function rr(e,t=new Map){const s=e.getIndices();if(!s)return;const n=e.getGraph(),r=ze.fromGraph(n),a=r.getLogger(),i=e.getAttribute("POSITION").getCount();for(const o of e.listAttributes())e.swap(o,at(r,o,s,t)),o.listParents().length===1&&o.dispose();for(const o of e.listTargets())for(const u of o.listAttributes())o.swap(u,at(r,u,s,t)),u.listParents().length===1&&u.dispose();const l=e.getAttribute("POSITION").getCount();a.debug(`${xe}: ${Ks(i,l)} vertices.`),e.setIndices(null),s.listParents().length===1&&s.dispose()}function at(e,t,s,n){if(n.has(t)&&n.get(t).has(s))return n.get(t).get(s);const r=t.getArray(),a=r.constructor,i=new a(s.getCount()*t.getElementSize()),l=s.getArray(),o=t.getElementSize();for(let c=0,h=s.getCount();c<h;c++)for(let f=0;f<o;f++)i[c*o+f]=r[l[c]*o+f];n.has(t)||n.set(t,new Map);const u=ee(e,t).setArray(i);return n.get(t).set(s,u),u}var it;(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(it||(it={}));const ar=1e-6;function ir(e,t,s,n=1e-4){const r=t.length/e.length,a=new Array(r).fill(0),i=new Array(r).fill(0),l=new Array(r).fill(0),o=new Array(r).fill(0),u=e.length-1;let c=1;for(let h=1;h<u;++h){const f=e[c-1],g=e[h],p=e[h+1],m=(g-f)/(p-f);let d=!1;if(g!==p&&(h!==1||g!==e[0]))if(Z(t,c-1,o),Z(t,h,i),Z(t,h+1,l),s==="slerp"){const y=cr(a,o,l,m),T=lt(o,i)+lt(i,l);d=!re(i,y,n)||T+Number.EPSILON>=Math.PI}else if(s==="lerp"){const y=lr(a,o,l,m);d=!re(i,y,n)}else s==="step"&&(d=!re(i,o)||!re(i,l));d&&(h!==c&&(e[c]=e[h],ot(t,c,Z(t,h,a))),c++)}return u>0&&(e[c]=e[u],ot(t,c,Z(t,u,a)),c++),c}function Z(e,t,s){for(let n=0,r=s.length;n<r;n++)s[n]=e[t*r+n];return s}function ot(e,t,s){for(let n=0,r=s.length;n<r;n++)e[t*r+n]=s[n]}function re(e,t,s=0){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(Math.abs(e[n]-t[n])>s)return!1;return!0}function or(e,t,s){return e*(1-s)+t*s}function lr(e,t,s,n){for(let r=0;r<t.length;r++)e[r]=or(t[r],s[r],n);return e}function cr(e,t,s,n){let r=t[0],a=t[1],i=t[2],l=t[3],o=s[0],u=s[1],c=s[2],h=s[3],f,g,p,m,d;return g=r*o+a*u+i*c+l*h,g<0&&(g=-g,o=-o,u=-u,c=-c,h=-h),1-g>ar?(f=Math.acos(g),p=Math.sin(f),m=Math.sin((1-n)*f)/p,d=Math.sin(n*f)/p):(m=1-n,d=n),e[0]=m*r+d*o,e[1]=m*a+d*u,e[2]=m*i+d*c,e[3]=m*l+d*h,e}function lt(e,t){const s=fr(e,t);return Math.acos(2*s*s-1)}function fr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}Promise.resolve();P.Mode;var je;(function(e){e.LANCZOS3="lanczos3",e.LANCZOS2="lanczos2"})(je||(je={}));je.LANCZOS3;const $="tangents",ct={overwrite:!1};function ur(e=ct){const t=H(ct,e);if(!t.generateTangents)throw new Error(`${$}: generateTangents callback required — install "mikktspace".`);return D($,s=>{const n=s.getLogger(),r=new Map,a=new Map;let i=0;for(const l of s.getRoot().listMeshes()){const o=l.getName(),u=l.listPrimitives();for(let c=0;c<u.length;c++){const h=u[c];if(!gr(h,n,o,c,t.overwrite))continue;const f=hr(h),g=h.getAttribute("POSITION").getArray(),p=h.getAttribute("NORMAL").getArray(),m=h.getAttribute(f).getArray(),d=r.get(g)||ve();r.set(g,d);const y=r.get(p)||ve();r.set(p,y);const T=r.get(m)||ve();r.set(m,T);const A=h.getAttribute("TANGENT");A&&A.listParents().length===2&&A.dispose();const b=`${d}|${y}|${T}`;let _=a.get(b);if(_){n.debug(`${$}: Found cache for primitive ${c} of mesh "${o}".`),h.setAttribute("TANGENT",_),i++;continue}n.debug(`${$}: Generating for primitive ${c} of mesh "${o}".`);const E=h.getAttribute("POSITION").getBuffer(),x=t.generateTangents(g instanceof Float32Array?g:new Float32Array(g),p instanceof Float32Array?p:new Float32Array(p),m instanceof Float32Array?m:new Float32Array(m));for(let L=3;L<x.length;L+=4)x[L]*=-1;_=s.createAccessor().setBuffer(E).setArray(x).setType("VEC4"),h.setAttribute("TANGENT",_),a.set(b,_),i++}}i?n.debug(`${$}: Complete.`):n.warn(`${$}: No qualifying primitives found. See debug output.`)})}function hr(e){const t=e.getMaterial();if(!t)return"TEXCOORD_0";const s=t.getNormalTextureInfo();if(!s)return"TEXCOORD_0";const r=`TEXCOORD_${s.getTexCoord()}`;return e.getAttribute(r)?r:"TEXCOORD_0"}function gr(e,t,s,n,r){return e.getMode()!==P.Mode.TRIANGLES||!e.getAttribute("POSITION")||!e.getAttribute("NORMAL")||!e.getAttribute("TEXCOORD_0")?(t.debug(`${$}: Skipping primitive ${n} of mesh "${s}": primitives must have attributes=[POSITION, NORMAL, TEXCOORD_0] and mode=TRIANGLES.`),!1):e.getAttribute("TANGENT")&&!r?(t.debug(`${$}: Skipping primitive ${n} of mesh "${s}": TANGENT found.`),!1):e.getIndices()?(t.warn(`${$}: Skipping primitive ${n} of mesh "${s}": primitives must be unwelded.`),!1):!0}async function pr(e,t,s,n={}){var y;const{remapMaterials:r,animationEvents:a,textureOptions:i,optimizeOptions:l}=s,o=await t.readBinary(e),u=o.getRoot().listExtensionsUsed(),c=u.some(T=>T.extensionName==="EXT_meshopt_compression"),h=u.some(T=>T.extensionName==="KHR_mesh_quantization");if((i==null?void 0:i.textureType)==="ktx2"&&n.ktx2Encode){const T=o.getRoot().listTextures();T.length>0&&o.createExtension(ns).setRequired(!0);const A=T.filter(b=>b.getMimeType()!=="image/ktx2");await Promise.all(A.map(async b=>{b.setMimeType("image/ktx2");const _=b.getImage(),E=await n.ktx2Encode(_.buffer,{isUASTC:i.mode==="UASTC",qualityLevel:i.quality??255});b.setImage(E)}))}r&&o.getRoot().listMaterials().forEach((T,A)=>{if(r[A]){const b=o.createExtension(Ae).createGlTFRemapping().setRefId(r[A].refId);T.setExtension(Ae.EXTENSION_NAME,b)}}),a&&o.getRoot().listAnimations().forEach((T,A)=>{if(a[A]){const b=o.createExtension(qe).createAnimationEvent().setEvents(a[A]);T.setExtension(qe.EXTENSION_NAME,b)}});const g=[];l!=null&&l.meshopt&&!c&&(await le.ready,g.push(zt({encoder:le}))),l!=null&&l.meshQuantize&&!h&&g.push(Le({quantizePosition:16,quantizeNormal:12,quantizeTexcoord:14})),g.length>0&&await o.transform(...g);const p=await t.writeJSON(o,{format:rs.GLB});if(n.resolveRef&&r){const T=Ae.EXTENSION_NAME;(y=p.json.materials)==null||y.forEach(A=>{var _;const b=(_=A.extensions)==null?void 0:_[T];if(b!=null&&b.refId){const E=n.resolveRef(b.refId);E&&(A.extensions[T]={url:E.url})}})}return{name:s.name.replace(/\.[^.]+$/,"")+".glb",content:_t(p)}}const ft=Ut("div",{color:"$gray10"}),dr=ht(({asset:e,index:t,originMaterial:s})=>{const{assetStore:n}=At(),r=e.remapMaterials[t];let a=Object.values(n.assets);a=a.filter(l=>l.getMetaConfig().type==="Material"&&!l.isSubAsset);const i=n.assets[r==null?void 0:r.refId];return I.jsx(Ft,{dropLayer:gt.Material,assets:a,customFilter:l=>l.mainId!==e.id,onSelect:l=>{(!i||l.engineObject!==i.engineObject)&&e.replaceMaterial(t,l.getCurrentRef())},onDelete:()=>{r&&e.resetMaterial(t)},onLocate:()=>{r&&r.refId&&n.selectAsset(r.refId)},label:s.name,value:i==null?void 0:i.name,asset:i})}),mr=ht(({asset:e})=>{var l;const t=e.engineObject.materials,{inspectorFacade:s}=At(),n=e.glTFInfo,r=(l=n.issues)==null?void 0:l.messages,{t:a}=Dt();function i(o,u){s.assetChange(e.id,o,u,"asset-meta")}return I.jsxs(I.Fragment,{children:[I.jsxs($e,{title:a("asset.gltf.basic-info"),defaultOpen:!0,children:[n.triangles?I.jsx(te,{label:a("asset.gltf.triangles"),children:I.jsx(be,{value:n.triangles,disabled:!0})}):null,n.drawcall?I.jsx(te,{label:a("asset.gltf.drawcall"),children:I.jsx(be,{value:n.drawcall,disabled:!0})}):null,I.jsx(se,{label:a("asset.gltf.compute-tangents"),value:e.needComputeTangents,onChange:o=>{i("needComputeTangents",o)},checkboxLabel:I.jsx(ft,{children:a("asset.gltf.refresh-tip")})}),I.jsx(se,{label:a("asset.gltf.keep-mesh-data"),value:e.params.keepMeshData,onChange:o=>{e.params={...e.params,keepMeshData:o}},checkboxLabel:I.jsx(ft,{children:a("asset.gltf.refresh-tip")})})]}),I.jsx(Ve,{}),r?I.jsxs(qt.Fragment,{children:[I.jsxs($e,{title:`${a("asset.gltf.issues")}: ${r.length}`,defaultOpen:!1,children:[r.slice(0,15).map((o,u)=>I.jsx(te,{label:o.pointer,children:I.jsx(be,{value:o.message,css:{color:"red"},disabled:!0})},u)),r.length>15?I.jsx(te,{label:"..."}):null]}),I.jsx(Ve,{})]}):null,I.jsx(Ue,{label:a("asset.gltf.remapped-materials"),children:t==null?void 0:t.map((o,u)=>I.jsx(dr,{originMaterial:o,asset:e,index:u},`${e.id}-${u}`))}),I.jsxs(Ue,{label:a("asset.gltf.compression"),children:[!e.optimize.meshopt&&I.jsx(se,{label:a("asset.gltf.quantize"),value:e.optimize.meshQuantize,onChange:o=>{Tracert.click("c351684.d417982",{checked:o}),i("optimize",{...e.optimize,meshQuantize:o})}}),I.jsx(se,{label:a("asset.gltf.meshopt"),value:e.optimize.meshopt,onChange:o=>{Tracert.click("c351684.d417983",{checked:o}),i("optimize",{...e.optimize,meshopt:o})}})]})]})});function pe(e){return/^(?:http|blob|data:|\/)/.test(e)}function kt(e){return/^data:(.+?);base64,/.test(e)}function de(e,t){return t.charAt(0)==="."?ut(e+t):ut(e.substring(0,e.lastIndexOf("/")+1)+t)}function ut(e){const t=[],s=e.split("/");for(let n=0;n<s.length;n++){const r=s[n];if(!(!r||r===".")){if(r===".."){t.length>0&&t.pop();continue}t.push(r)}}return t.join("/")}async function yr(e,t){const s=JSON.parse(await e.text()),n=s.images,r={},a="",i=[];if(n)for(let o=0;o<n.length;o++){const c=n[o].uri;if(c)if(pe(c))i.push(fetch(c).then(h=>h.arrayBuffer()).then(h=>{r[c]=new Uint8Array(h)}));else{const h=de(a,c);i.push(t[h].arrayBuffer().then(f=>{r[c]=new Uint8Array(f)}))}}const l=s.buffers;if(l)for(let o=0;o<l.length;o++){const c=l[o].uri;if(c)if(!pe(c)&&!kt(c)){const h=de(a,c);i.push(t[h].arrayBuffer().then(f=>{r[c]=new Uint8Array(f)}))}else i.push(fetch(c).then(h=>h.arrayBuffer()).then(h=>{r[c]=new Uint8Array(h)}))}return await Promise.all(i),hs({json:s,resources:r})}async function br(e){const t={uploadFiles:[],errors:[]};for(const s in e){const n=e[s],a=n.name.toLowerCase();if(a.endsWith(".glb")||a.endsWith(".fbx"))t.uploadFiles.push({main:n});else if(a.endsWith(".gltf")){const i=await vr(n,e);typeof i=="string"?t.errors.push(i):t.uploadFiles.push(i)}}return t}async function vr(e,t){const s=JSON.parse(await e.text()),n=s.images,r=s.buffers,a="",i={main:e,subFiles:{},postfix:".glb"};if(n)for(let l=0;l<n.length;l++){const u=n[l].uri;if(u&&!pe(u)){const c=de(a,u);if(t[c])i.subFiles[c]=t[c];else return`${u} is not found in the files.`}}if(r)for(let l=0;l<r.length;l++){const u=r[l].uri;if(u&&!pe(u)&&!kt(u)){const c=de(a,u);if(t[c])i.subFiles[c]=t[c];else return`${u} is not found in the files.`}}return i}async function Ar(e,t){const s=e.main,n=s.name.replace(/\.[^.]+$/,".glb");if(s.name.toLocaleLowerCase().endsWith(".gltf")){const r=e.subFiles??{},a=await yr(s,r);return new File([a.buffer],n)}return s}function _r(e){const t=Object.entries(e.remapMaterials).filter(([,s])=>!!s);if(!t.length){e.settleInitCompleted();return}e.onInitComplete(async()=>{try{await Promise.all(t.map(([s,n])=>e.replaceMaterial(Number(s),n,!1)))}catch{}finally{e.settleInitCompleted()}})}async function Tr(e){e.notifySuccess("Success. page will reload, please wait...");try{await e.assetFacade.persistAssetMetaImmediate(e.assetId),e.reload()}catch(t){e.logError("Failed to persist optimize config before reload",t),e.notifyError("Failed to save optimize config, reload canceled.")}}class Re{static update(t,s){!this.entity&&(this.entity=t.createChild("glTF"));const n=this.tempCloneEntity=s.engineObject.instantiateSceneRoot();this.entity.addChild(n)}static clear(){this.entity.clearChildren(),this.tempCloneEntity&&this.tempCloneEntity.destroy()}}w(Re,"entity"),w(Re,"tempCloneEntity");var Er=Object.defineProperty,wr=Object.getOwnPropertyDescriptor,z=(e,t,s,n)=>{for(var r=n>1?void 0:n?wr(t,s):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(r=(n?i(t,s,r):i(r))||r);return n&&r&&Er(t,s,r),r};class R extends ls{constructor(){super();w(this,"animationNames",[]);w(this,"frameTime",0);w(this,"duration",0);w(this,"playing",!1);w(this,"animationIndex",0);w(this,"selectedClip");w(this,"_updateComponent");w(this,"_clips",[]);pt(this)}setViewAsset(s,n){const{animations:r=[]}=s.engineObject;this._clips=r,this.animationIndex=0,this.animationNames=r.map(i=>i.name),this._entity=s.instantiateEngineObject(),n.addChild(this._entity);const a=this;r.length>0&&(this._updateComponent=this._entity.addComponent(class extends Bt{onUpdate(i){a._onUpdate(i)}})),this.duration=0}stopViewAsset(){var s;super.stopViewAsset(),this.frameTime=0,this.pauseAnimation(),(s=this._updateComponent)==null||s.destroy(),this.animationNames=null}selectAnimation(s){this.selectedClip=this._clips[s],this.frameTime=0,this.duration=this.selectedClip.length,this.animationIndex=s,this._sampleAnimation()}setFrameTime(s){this.frameTime=s,this._sampleAnimation()}playAnimation(){this.selectedClip&&(this.playing=!0)}pauseAnimation(){this.playing=!1}_onUpdate(s){!this.playing||!this.selectedClip||!this.duration||(this.frameTime+=s,this.frameTime>this.duration&&(this.frameTime%=this.duration),this._sampleAnimation())}_sampleAnimation(){try{this.selectedClip._sampleAnimation(this._entity.children[0],this.frameTime)}catch(s){console.warn(s)}}}z([j],R.prototype,"animationNames",2);z([j],R.prototype,"frameTime",2);z([j],R.prototype,"duration",2);z([j],R.prototype,"playing",2);z([j],R.prototype,"animationIndex",2);z([G],R.prototype,"selectAnimation",1);z([G],R.prototype,"setFrameTime",1);z([G],R.prototype,"playAnimation",1);z([G],R.prototype,"pauseAnimation",1);z([G],R.prototype,"_onUpdate",1);var Ir=Object.defineProperty,Mr=Object.getOwnPropertyDescriptor,k=(e,t,s,n)=>{for(var r=n>1?void 0:n?Mr(t,s):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(r=(n?i(t,s,r):i(r))||r);return n&&r&&Ir(t,s,r),r};const ae=Yt("gltf");let O=class extends as{constructor(t){super(t);w(this,"exportedUrl","");w(this,"glTFInfo",{drawcall:void 0,triangles:void 0,issues:void 0});w(this,"remapMaterials",{});w(this,"animationEvents",{});w(this,"needComputeTangents",!0);w(this,"fbxUrl",null);w(this,"optimize",{meshopt:!1,meshQuantize:!1});w(this,"params",{keepMeshData:!1});w(this,"initCompleted");w(this,"_rootKey","defaultSceneRoot");w(this,"mappedMaterialsPath",[]);w(this,"_initCompletedResolve");w(this,"_autorunDisposer",null);w(this,"_propertyChangeListeners",new Map);pt(this),this.initCompleted=new Promise(s=>{this._initCompletedResolve=s})}applyMetaFromDomain(t){if(super.applyMetaFromDomain(t),"needComputeTangents"in t&&(this.needComputeTangents=t.needComputeTangents),"optimize"in t&&typeof t.optimize=="object"){const s=t.optimize;this.optimize={...this.optimize,...s}}}async generateSubAssets(){const t=this.engineObject;if(this._subAssets=[],t.meshes)for(let s=0;s<t.meshes.length;s++){const n=t.meshes[s];for(let r=0;r<n.length;r++){const a=await this.root.assetStore.createSubAsset("Mesh",n[r],this.id,`meshes[${s}][${r}]`);this._subAssets.push(a)}}if(t.textures)for(let s=0;s<t.textures.length;s++){const n=await this.root.assetStore.createSubAsset("Texture",t.textures[s],this.id,`textures[${s}]`);this._subAssets.push(n)}if(t.animations){for(let r=0;r<t.animations.length;r++){const a=t.animations[r],i=this.animationEvents[r];i&&i.forEach(o=>{a.addEvent(o.functionName,o.time,o.parameter)});const l=await this.root.assetStore.createSubAsset("AnimationClip",a,this.id,`animations[${r}]`);this._subAssets.push(l)}const s=t.defaultSceneRoot.getComponent(Gt).animatorController,n=await this.root.assetStore.createSubAsset("AnimatorController",s,this.id,"animatorController[0]");this._subAssets.push(n)}if(t.materials)for(let s=0;s<t.materials.length;s++){const n=await this.root.assetStore.createSubAsset("Material",t.materials[s],this.id,`materials[${s}]`);this._subAssets.push(n)}}async initByMain(t,s){const{engine:n,meta:r}=this;this.url=s,this.animationEvents=r.animationEvents||{},this.optimize=r.optimize??this.optimize;let a=this.optimize.meshopt,i=this.optimize.meshQuantize;this._autorunDisposer=Wt(()=>{const o=this.optimize.meshQuantize;i!==o&&(this.optimize.meshQuantize=o,i=o,this._saveMetaAndReload());const u=this.optimize.meshopt;a!==u&&(this.optimize.meshopt=u,a=u,this._saveMetaAndReload())}),this.params=r.params??this.params;let l;try{l=URL.createObjectURL(t),await this.initByUrl(l+"#.glb",n)}finally{l!==void 0&&URL.revokeObjectURL(l)}this.needComputeTangents=r.needComputeTangents??!0,_r({remapMaterials:r.remapMaterials||{},onInitComplete:o=>{this.on("initcomplete",o)},replaceMaterial:async(o,u,c)=>{await this.replaceMaterial(o,u,c)},settleInitCompleted:()=>{this._initCompletedResolve()}}),this.fbxUrl=r.fbxUrl}_saveMetaAndReload(){Tr({assetFacade:this.root.assetFacade,assetId:this.id,reload:()=>window.location.reload(),notifySuccess:t=>Be.success(dt(t)),notifyError:t=>Be.error(t),logError:(t,s)=>ae.error(t,s)})}resetMaterial(t){const s=this._engineObject.materials[t];this._internalReplaceMaterial(t,s),this.remapMaterials[t]=void 0,this.root.assetFacade.persistAssetMeta(this.id)}async replaceMaterial(t,s,n=!0){this.remapMaterials[t]=s;const r=this._findComponentsByMaterialPathIndex(t),a=await this.root.assetStore.getAssetByRef(s);if(a instanceof cs){const i=a.engineObject;r.forEach(({component:c,materialIndex:h})=>{c.setMaterial(h,i)});const l=String(t),o=this._propertyChangeListeners.get(l);o&&a.off("propertychange",o);const u=()=>{this.updateThumbnail()};this._propertyChangeListeners.set(l,u),a.on("propertychange",u)}else ae.warn(`${s.refId} shouldn't be selected`);n&&await this.root.assetFacade.persistAssetMeta(this.id),this.updateThumbnail()}updateAnimationEvents(t,s){this.animationEvents[t]=s,this.root.assetFacade.persistAssetMeta(this.id)}async instantiate(t){await this.initCompleted;const s=t.createByEngineObject(this.instantiateEngineObject());s.isGLTFWrapEntity=!0,s.isPrefabRefEntity=!1,await s.ensureReady();const n=s.selfChildren[0];return n?this.addInstance(n):ae.warn(`[GlTFAsset] instantiate: wrap entity has no child, skip addInstance. asset=${this.id}`),s}destroy(){var s;(s=this._autorunDisposer)==null||s.call(this),this._autorunDisposer=null,this._propertyChangeListeners.clear();const t=this.engineObject;t&&(t._defaultSceneRoot.destroy(),t.destroy()),super.destroy()}instantiateEngineObject(){const t=super.instantiateEngineObject(),s=new Ht(this.engine,this.name.replace(/\.glb$/g,""));return s.addChild(t),this._fixClonedSkins(t),s}_fixClonedSkins(t){const s=t.getComponentsIncludeChildren(Xt,[]);for(const n of s){const r=n.skin;if(r&&r.bones.length>0&&!r._skinMatrices){const a=r.bones;r.bones=a}}}_instantiateEngineObject(){return this.engineObject.instantiateSceneRoot()}_destroyInstances(){this._instances.forEach((t,s)=>{const n=t.entities.get(s);if(n){const r=n.parentEntity;r?r.destroy():n.destroy()}}),this._instances.clear()}_internalReplaceMaterial(t,s){this._findComponentsByMaterialPathIndex(t).forEach(({component:r,materialIndex:a})=>{r.setMaterial(a,s)}),this.updateThumbnail()}_findComponentsByMaterialPathIndex(t){const s=[...this._clonedEntities,this._engineObject.defaultSceneRoot],n=this.mappedMaterialsPath[t],r=[];if(!n)return ae.warn(`${this._name} replaced material not found.(gltf may be replaced either)`),r;for(let a=0;a<s.length;a++){const i=s[a];n.forEach(l=>{const u=Cr(l.entityPath,i).getComponents(Fe,[]);r.push({component:u[l.componentIndex],materialIndex:l.materialIndex})})}return r}async initByUrl(t,s){const n=await s.resourceManager.load({type:Kt.GLTF,url:t,params:this.params});return this.initMappedMaterialPath(n),this.bindEngineObject(n),this._updateDragTempEntity(),await this.generateSubAssets(),await this.initBasicInfo(n),this}async getRemappedMaterial(t){var n;const s=this.remapMaterials[t];return s?(n=await this.root.assetStore.getAssetByRef(s))==null?void 0:n.engineObject:this._engineObject.materials[t]}initMappedMaterialPath(t){const s=t.materials,n=t.defaultSceneRoot;if(s){const r=t.defaultSceneRoot.getComponentsIncludeChildren(De,[]);s.forEach(a=>{const i=[];this.mappedMaterialsPath.push(i);for(let l=0;l<r.length;l++){const o=r[l],u=o.getMaterials(),c=o.entity.getComponents(Fe,[]);for(let h=0;h<u.length;h++)u[h]===a&&i.push({entityPath:Nr(o.entity,n),componentIndex:c.indexOf(o),materialIndex:h})}})}}async initBasicInfo(t){this.glTFInfo.drawcall=t.defaultSceneRoot.getComponentsIncludeChildren(De,[]).length}};k([j,Qt()],O.prototype,"exportedUrl",2);k([W(),j],O.prototype,"remapMaterials",2);k([W()],O.prototype,"animationEvents",2);k([W(),j],O.prototype,"needComputeTangents",2);k([W(),j],O.prototype,"fbxUrl",2);k([W(),j],O.prototype,"optimize",2);k([W(),j],O.prototype,"params",2);k([Jt],O.prototype,"applyMetaFromDomain",1);k([G],O.prototype,"resetMaterial",1);O=k([is({type:"glTF",label:dt("asset.gltf.title"),loaderType:"GLTF",importMenuConfig:{type:os.Upload,tooltip:"请上传模型文件(支持gltf,glb,fbx,obj)或包含模型和资源文件(bin、贴图等)的zip压缩包",accept:".zip,.fbx,.gltf,.glb,application/json",subAccept:".bin,.jpeg,.jpg,.png",multiple:!0},filterUploadFiles:br,preUpload:Ar,extname:"glb",dragLayer:gt.GlTF,customInspector:mr,viewer:R,thumbnail:Re,async preInitialize({main:e,meta:t,name:s}){const n=new Uint8Array(await e.arrayBuffer()),r=await _e.readBinary(n),a=t.optimize||{},i=t.needComputeTangents??!0,l=a.meshQuantize,o=a.meshopt,u=[],c=r.getRoot().listExtensionsUsed(),h=c.some(p=>p.extensionName===mt.EXTENSION_NAME),f=c.some(p=>p.extensionName===ie.EXTENSION_NAME);l&&!h&&u.push(Le({quantizePosition:16,quantizeNormal:12,quantizeTexcoord:14})),o&&!f&&(await le.ready,u.push(zt({encoder:le})));try{i&&(u.push(nr()),u.push(ur({generateTangents:window.mikktspace.generateTangents,overwrite:!0}))),await r.transform(...u)}catch(p){console.error("The gltf-transform plugin encountered some errors when performing meshopt, quantize, or calculating tangents, we have disabled these features automatically.",p)}const g=await _e.writeBinary(r);return new File([g.buffer],s,{type:"model/gltf-binary"})},async bundle({content:e,name:t,meta:s},n,r){var l;const a=new Uint8Array(await e.arrayBuffer()),i=await pr(a,_e,{name:t,remapMaterials:s.remapMaterials,animationEvents:s.animationEvents??{},textureOptions:(l=n.assetOptions)==null?void 0:l.textureOptions,optimizeOptions:s.optimize},{resolveRef:r?o=>r.resolveRef(o):void 0,ktx2Encode:(o,u)=>fs.encode(o,u)});return{name:i.name,content:new Blob([i.content],{type:"model/gltf-binary"})}}})],O);function Nr(e,t){const s=[];for(;e!==t;)s.unshift(e.siblingIndex),e=e.parent;return s}function Cr(e,t){let s=t;for(let n=0;n<e.length;n++)s=s.children[e[n]];return s}const Vr=Object.freeze(Object.defineProperty({__proto__:null,get GlTFAsset(){return O}},Symbol.toStringTag,{value:"Module"}));export{O as G,R as a,Vr as b};
20
+ `));return h(Us.bind(void 0,e))}var Fs=Vs,Ds=Fs;function qs(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function Bs(e){var t=new qs;t.pre=e.pre,t.body=e.body,t.post=e.post;var s=e.args.slice(0);t.argTypes=s;for(var n=0;n<s.length;++n){var r=s[n];if(r==="array"||typeof r=="object"&&r.blockIndices){if(t.argTypes[n]="array",t.arrayArgs.push(n),t.arrayBlockIndices.push(r.blockIndices?r.blockIndices:0),t.shimArgs.push("array"+n),n<t.pre.args.length&&t.pre.args[n].count>0)throw new Error("cwise: pre() block may not reference array args");if(n<t.post.args.length&&t.post.args[n].count>0)throw new Error("cwise: post() block may not reference array args")}else if(r==="scalar")t.scalarArgs.push(n),t.shimArgs.push("scalar"+n);else if(r==="index"){if(t.indexArgs.push(n),n<t.pre.args.length&&t.pre.args[n].count>0)throw new Error("cwise: pre() block may not reference array index");if(n<t.body.args.length&&t.body.args[n].lvalue)throw new Error("cwise: body() block may not write to array index");if(n<t.post.args.length&&t.post.args[n].count>0)throw new Error("cwise: post() block may not reference array index")}else if(r==="shape"){if(t.shapeArgs.push(n),n<t.pre.args.length&&t.pre.args[n].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(n<t.body.args.length&&t.body.args[n].lvalue)throw new Error("cwise: body() block may not write to array shape");if(n<t.post.args.length&&t.post.args[n].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof r=="object"&&r.offset)t.argTypes[n]="offset",t.offsetArgs.push({array:r.array,offset:r.offset}),t.offsetArgIndex.push(n);else throw new Error("cwise: Unknown argument type "+s[n])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>s.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>s.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>s.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,Ds(t)}var Gs=Bs;(function(e){var t=Gs,s={body:"",args:[],thisVars:[],localVars:[]};function n(f){if(!f)return s;for(var g=0;g<f.args.length;++g){var p=f.args[g];g===0?f.args[g]={name:p,lvalue:!0,rvalue:!!f.rvalue,count:f.count||1}:f.args[g]={name:p,lvalue:!1,rvalue:!0,count:1}}return f.thisVars||(f.thisVars=[]),f.localVars||(f.localVars=[]),f}function r(f){return t({args:f.args,pre:n(f.pre),body:n(f.body),post:n(f.proc),funcName:f.funcName})}function a(f){for(var g=[],p=0;p<f.args.length;++p)g.push("a"+p);var m=new Function("P",["return function ",f.funcName,"_ndarrayops(",g.join(","),") {P(",g.join(","),");return a0}"].join(""));return m(r(f))}var i={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var f in i){var g=i[f];e[f]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:f}),e[f+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+g+"=b"},rvalue:!0,funcName:f+"eq"}),e[f+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:f+"s"}),e[f+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+g+"=s"},rvalue:!0,funcName:f+"seq"})}})();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var f in l){var g=l[f];e[f]=a({args:["array","array"],body:{args:["a","b"],body:"a="+g+"b"},funcName:f}),e[f+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+g+"a"},rvalue:!0,count:2,funcName:f+"eq"})}})();var o={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var f in o){var g=o[f];e[f]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:f}),e[f+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:f+"s"}),e[f+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+g+"b"},rvalue:!0,count:2,funcName:f+"eq"}),e[f+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+g+"s"},rvalue:!0,count:2,funcName:f+"seq"})}})();var u=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var f=0;f<u.length;++f){var g=u[f];e[g]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:g}),e[g+"eq"]=a({args:["array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"eq"})}})();var c=["max","min","atan2","pow"];(function(){for(var f=0;f<c.length;++f){var g=c[f];e[g]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g}),e[g+"s"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g+"s"}),e[g+"eq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"eq"}),e[g+"seq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"seq"})}})();var h=["atan2","pow"];(function(){for(var f=0;f<h.length;++f){var g=h[f];e[g+"op"]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"op"}),e[g+"ops"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"ops"}),e[g+"opeq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"opeq"}),e[g+"opseq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"opseq"})}})(),e.any=t({args:["array"],pre:s,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"}),e.all=t({args:["array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"}),e.sum=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"}),e.prod=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"}),e.norm2squared=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"}),e.norm2=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"}),e.norminf=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),e.norm1=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),e.sup=t({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.inf=t({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.argmin=t({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.argmax=t({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),e.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),e.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),e.equals=t({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})})(Cs);function Ws(e,t){if(!(e instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");const s=new Blob([e],{type:t}),n=URL.createObjectURL(s);return new Promise((r,a)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=function(){URL.revokeObjectURL(n);const o=new OffscreenCanvas(i.width,i.height).getContext("2d");o.drawImage(i,0,0);const u=o.getImageData(0,0,i.width,i.height);r(Ns(new Uint8Array(u.data),[i.width,i.height,4],[4,4*i.width,1],0))},i.onerror=l=>{URL.revokeObjectURL(n),a(l)},i.src=n})}async function Hs(e,t){return Ws(e,t)}function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)({}).hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},B.apply(null,arguments)}P.Mode;function D(e,t){return Object.defineProperty(t,"name",{value:e}),t}function H(e,t){const s=B({},e);for(const n in t)t[n]!==void 0&&(s[n]=t[n]);return s}class Ee{constructor(){this._map=new Map}get size(){return this._map.size}has(t){return this._map.has(t)}add(t,s){let n=this._map.get(t);return n||(n=new Set,this._map.set(t,n)),n.add(s),this}get(t){return this._map.get(t)||new Set}keys(){return this._map.keys()}}const Xs=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function We(e){return Xs.format(e)}function Qs(e,t,s=2){const n=e>t?"–":"+",r="%";return n+(Math.abs(e-t)/e*100).toFixed(s)+r}function Ks(e,t){return`${We(e)} → ${We(t)} (${Qs(e,t)})`}function wt(e){const t=[];for(const s of e.listAttributes())t.push(s);for(const s of e.listTargets())for(const n of s.listAttributes())t.push(n);return Array.from(new Set(t))}function Js(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}function ee(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function Ys(e,t=e){const s=It(e,t);for(let n=0;n<s.length;n++)s[n]=n;return s}function It(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function Mt(e){for(const t in e)return!1;return!0}var fe=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function Zs(e,t){var s=t[0],n=t[1],r=t[2],a=t[3],i=t[4],l=t[5],o=t[6],u=t[7],c=t[8],h=t[9],f=t[10],g=t[11],p=t[12],m=t[13],d=t[14],y=t[15],T=s*l-n*i,A=s*o-r*i,b=s*u-a*i,_=n*o-r*l,E=n*u-a*l,x=r*u-a*o,L=c*m-h*p,X=c*d-f*p,Q=c*y-g*p,K=h*d-f*m,J=h*y-g*m,Y=f*y-g*d,M=T*Y-A*J+b*K+_*Q-E*X+x*L;return M?(M=1/M,e[0]=(l*Y-o*J+u*K)*M,e[1]=(r*J-n*Y-a*K)*M,e[2]=(m*x-d*E+y*_)*M,e[3]=(f*E-h*x-g*_)*M,e[4]=(o*Q-i*Y-u*X)*M,e[5]=(s*Y-r*Q+a*X)*M,e[6]=(d*b-p*x-y*A)*M,e[7]=(c*x-f*b+g*A)*M,e[8]=(i*J-l*Q+u*L)*M,e[9]=(n*Q-s*J-a*L)*M,e[10]=(p*E-m*b+y*T)*M,e[11]=(h*b-c*E-g*T)*M,e[12]=(l*X-i*K-o*L)*M,e[13]=(s*K-n*X+r*L)*M,e[14]=(m*A-p*_-d*T)*M,e[15]=(c*_-h*A+f*T)*M,e):null}function ke(e,t,s){var n=t[0],r=t[1],a=t[2],i=t[3],l=t[4],o=t[5],u=t[6],c=t[7],h=t[8],f=t[9],g=t[10],p=t[11],m=t[12],d=t[13],y=t[14],T=t[15],A=s[0],b=s[1],_=s[2],E=s[3];return e[0]=A*n+b*l+_*h+E*m,e[1]=A*r+b*o+_*f+E*d,e[2]=A*a+b*u+_*g+E*y,e[3]=A*i+b*c+_*p+E*T,A=s[4],b=s[5],_=s[6],E=s[7],e[4]=A*n+b*l+_*h+E*m,e[5]=A*r+b*o+_*f+E*d,e[6]=A*a+b*u+_*g+E*y,e[7]=A*i+b*c+_*p+E*T,A=s[8],b=s[9],_=s[10],E=s[11],e[8]=A*n+b*l+_*h+E*m,e[9]=A*r+b*o+_*f+E*d,e[10]=A*a+b*u+_*g+E*y,e[11]=A*i+b*c+_*p+E*T,A=s[12],b=s[13],_=s[14],E=s[15],e[12]=A*n+b*l+_*h+E*m,e[13]=A*r+b*o+_*f+E*d,e[14]=A*a+b*u+_*g+E*y,e[15]=A*i+b*c+_*p+E*T,e}function en(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function tn(e,t,s,n){var r=t[0],a=t[1],i=t[2],l=t[3],o=r+r,u=a+a,c=i+i,h=r*o,f=r*u,g=r*c,p=a*u,m=a*c,d=i*c,y=l*o,T=l*u,A=l*c,b=n[0],_=n[1],E=n[2];return e[0]=(1-(p+d))*b,e[1]=(f+A)*b,e[2]=(g-T)*b,e[3]=0,e[4]=(f-A)*_,e[5]=(1-(h+d))*_,e[6]=(m+y)*_,e[7]=0,e[8]=(g+T)*E,e[9]=(m-y)*E,e[10]=(1-(h+p))*E,e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e}function sn(){var e=new fe(3);return fe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function nn(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e}function Ne(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e[2]=Math.min(t[2],s[2]),e}function Ce(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e[2]=Math.max(t[2],s[2]),e}function He(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function rn(e,t,s){var n=t[0],r=t[1],a=t[2],i=s[3]*n+s[7]*r+s[11]*a+s[15];return i=i||1,e[0]=(s[0]*n+s[4]*r+s[8]*a+s[12])/i,e[1]=(s[1]*n+s[5]*r+s[9]*a+s[13])/i,e[2]=(s[2]*n+s[6]*r+s[10]*a+s[14])/i,e}var an=nn;(function(){var e=sn();return function(t,s,n,r,a,i){var l,o;for(s||(s=3),n||(n=0),r?o=Math.min(r*s+n,t.length):o=t.length,l=n;l<o;l+=s)e[0]=t[l],e[1]=t[l+1],e[2]=t[l+2],a(e,e,i),t[l]=e[0],t[l+1]=e[1],t[l+2]=e[2];return t}})();const F="dedup",we={keepUniqueNames:!1,propertyTypes:[v.ACCESSOR,v.MESH,v.TEXTURE,v.MATERIAL,v.SKIN]};function on(e=we){const t=H(we,e),s=new Set(t.propertyTypes);for(const n of t.propertyTypes)if(!we.propertyTypes.includes(n))throw new Error(`${F}: Unsupported deduplication on type "${n}".`);return D(F,n=>{const r=n.getLogger();s.has(v.ACCESSOR)&&ln(n),s.has(v.TEXTURE)&&fn(n,t),s.has(v.MATERIAL)&&un(n,t),s.has(v.MESH)&&cn(n,t),s.has(v.SKIN)&&hn(n,t),r.debug(`${F}: Complete.`)})}function ln(e){const t=e.getLogger(),s=new Map,n=new Map,r=new Map,a=new Map,i=e.getRoot().listMeshes();i.forEach(h=>{h.listPrimitives().forEach(f=>{f.listAttributes().forEach(g=>l(g,n)),l(f.getIndices(),s)})});for(const h of e.getRoot().listAnimations())for(const f of h.listSamplers())l(f.getInput(),r),l(f.getOutput(),a);function l(h,f){if(!h)return;const g=[h.getCount(),h.getType(),h.getComponentType(),h.getNormalized(),h.getSparse()].join(":");let p=f.get(g);p||f.set(g,p=new Set),p.add(h)}function o(h,f){for(let g=0;g<h.length;g++){const p=h[g],m=N.toView(p.getArray());if(!f.has(p))for(let d=g+1;d<h.length;d++){const y=h[d];f.has(y)||N.equals(m,N.toView(y.getArray()))&&f.set(y,p)}}}let u=0;const c=new Map;for(const h of[n,s,r,a])for(const f of h.values())u+=f.size,o(Array.from(f),c);t.debug(`${F}: Merged ${c.size} of ${u} accessors.`),i.forEach(h=>{h.listPrimitives().forEach(f=>{f.listAttributes().forEach(p=>{c.has(p)&&f.swap(p,c.get(p))});const g=f.getIndices();g&&c.has(g)&&f.swap(g,c.get(g))})});for(const h of e.getRoot().listAnimations())for(const f of h.listSamplers()){const g=f.getInput(),p=f.getOutput();g&&c.has(g)&&f.swap(g,c.get(g)),p&&c.has(p)&&f.swap(p,c.get(p))}Array.from(c.keys()).forEach(h=>h.dispose())}function cn(e,t){const s=e.getLogger(),n=e.getRoot(),r=new Map;n.listAccessors().forEach((l,o)=>r.set(l,o)),n.listMaterials().forEach((l,o)=>r.set(l,o));const a=n.listMeshes().length,i=new Map;for(const l of n.listMeshes()){const o=[];for(const c of l.listPrimitives())o.push(Nt(c,r));let u="";if(t.keepUniqueNames&&(u+=l.getName()+";"),u+=o.join(";"),i.has(u)){const c=i.get(u);l.listParents().forEach(h=>{h.propertyType!==v.ROOT&&h.swap(l,c)}),l.dispose()}else i.set(u,l)}s.debug(`${F}: Merged ${a-i.size} of ${a} meshes.`)}function fn(e,t){const s=e.getLogger(),n=e.getRoot(),r=n.listTextures(),a=new Map;for(let i=0;i<r.length;i++){const l=r[i],o=l.getImage();if(!a.has(l))for(let u=i+1;u<r.length;u++){const c=r[u],h=c.getImage();if(a.has(c)||l.getMimeType()!==c.getMimeType()||t.keepUniqueNames&&l.getName()!==c.getName())continue;const f=l.getSize(),g=c.getSize();!f||!g||f[0]===g[0]&&f[1]===g[1]&&(!o||!h||N.equals(o,h)&&a.set(c,l))}}s.debug(`${F}: Merged ${a.size} of ${n.listTextures().length} textures.`),Array.from(a.entries()).forEach(([i,l])=>{i.listParents().forEach(o=>{o instanceof me||o.swap(i,l)}),i.dispose()})}function un(e,t){const s=e.getLogger(),r=e.getRoot().listMaterials(),a=new Map,i=new Map,l=new Set;t.keepUniqueNames||l.add("name");for(let o=0;o<r.length;o++){const u=r[o];if(!a.has(u)&&!Xe(u,i))for(let c=o+1;c<r.length;c++){const h=r[c];a.has(h)||Xe(h,i)||u.equals(h,l)&&a.set(h,u)}}s.debug(`${F}: Merged ${a.size} of ${r.length} materials.`),Array.from(a.entries()).forEach(([o,u])=>{o.listParents().forEach(c=>{c instanceof me||c.swap(o,u)}),o.dispose()})}function hn(e,t){const s=e.getLogger(),r=e.getRoot().listSkins(),a=new Map,i=new Set(["joints"]);t.keepUniqueNames||i.add("name");for(let l=0;l<r.length;l++){const o=r[l];if(!a.has(o))for(let u=l+1;u<r.length;u++){const c=r[u];a.has(c)||o.equals(c,i)&&Js(o.listJoints(),c.listJoints())&&a.set(c,o)}}s.debug(`${F}: Merged ${a.size} of ${r.length} skins.`),Array.from(a.entries()).forEach(([l,o])=>{l.listParents().forEach(u=>{u instanceof me||u.swap(l,o)}),l.dispose()})}function Nt(e,t){const s=[];for(const n of e.listSemantics()){const r=e.getAttribute(n);s.push(n+":"+t.get(r))}if(e instanceof P){const n=e.getIndices();n&&s.push("indices:"+t.get(n));const r=e.getMaterial();r&&s.push("material:"+t.get(r)),s.push("mode:"+e.getMode());for(const a of e.listTargets())s.push("target:"+Nt(a,t))}return s.join(",")}function Xe(e,t){if(t.has(e))return t.get(e);const s=e.getGraph(),n=new Set,r=s.listParentEdges(e);for(;r.length>0;){const a=r.pop();if(a.getAttributes().modifyChild===!0)return t.set(e,!0),!0;const i=a.getChild();if(!n.has(i))for(const l of s.listChildEdges(i))r.push(l)}return t.set(e,!1),!1}function Ct(){var e=new fe(4);return fe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function gn(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e}function pn(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e}function dn(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e[3]=t[3]*s[3],e}function mn(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e}function yn(e){var t=e[0],s=e[1],n=e[2],r=e[3];return Math.hypot(t,s,n,r)}var St=pn,bn=dn,Ot=yn;(function(){var e=Ct();return function(t,s,n,r,a,i){var l,o;for(s||(s=4),n||(n=0),r?o=Math.min(r*s+n,t.length):o=t.length,l=n;l<o;l+=s)e[0]=t[l],e[1]=t[l+1],e[2]=t[l+2],e[3]=t[l+3],a(e,e,i),t[l]=e[0],t[l+1]=e[1],t[l+2]=e[2],t[l+3]=e[3];return t}})();const vn=/color|emissive|diffuse/i;function An(e){return e.getGraph().listParentEdges(e).some(r=>r.getAttributes().isColor||vn.test(r.getName()))?"srgb":null}function _n(e){const t=e.getGraph(),s=new Set,n=new Set;function r(a){const i=new Set;for(const l of t.listChildEdges(a))l.getChild()instanceof Me&&i.add(l.getName()+"Info");for(const l of t.listChildEdges(a)){const o=l.getChild();s.has(o)||(s.add(o),o instanceof yt&&i.has(l.getName())?n.add(o):o instanceof bt&&r(o))}}return r(e),Array.from(n)}function Tn(e){const s=ze.fromGraph(e.getGraph()).getRoot(),n=e.getGraph().listParentEdges(e).filter(r=>r.getParent()!==s).map(r=>r.getName());return Array.from(new Set(n))}const q="prune",Se=3/255,Qe={propertyTypes:[v.NODE,v.SKIN,v.MESH,v.CAMERA,v.PRIMITIVE,v.PRIMITIVE_TARGET,v.ANIMATION,v.MATERIAL,v.TEXTURE,v.ACCESSOR,v.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function xt(e=Qe){const t=H(Qe,e),s=new Set(t.propertyTypes),n=t.keepExtras;return D(q,async r=>{const a=r.getLogger(),i=r.getRoot(),l=r.getGraph(),o=new En,u=c=>o.dispose(c.target);if(l.addEventListener("node:dispose",u),s.has(v.MESH))for(const c of i.listMeshes())c.listPrimitives().length>0||c.dispose();if(s.has(v.NODE)){if(!t.keepLeaves)for(const c of i.listScenes())Rt(l,c,n);for(const c of i.listNodes())S(c,n)}if(s.has(v.SKIN))for(const c of i.listSkins())S(c,n);if(s.has(v.MESH))for(const c of i.listMeshes())S(c,n);if(s.has(v.CAMERA))for(const c of i.listCameras())S(c,n);if(s.has(v.PRIMITIVE)&&Ke(l,v.PRIMITIVE,n),s.has(v.PRIMITIVE_TARGET)&&Ke(l,v.PRIMITIVE_TARGET,n),!t.keepAttributes&&s.has(v.ACCESSOR)){const c=new Map;for(const h of i.listMeshes())for(const f of h.listPrimitives()){const g=f.getMaterial();if(!g)continue;const p=jt(r,f,g),m=In(f,p);Je(f,m),f.listTargets().forEach(d=>Je(d,m)),c.has(g)?c.get(g).add(f):c.set(g,new Set([f]))}for(const[h,f]of c)Mn(h,Array.from(f))}if(!t.keepIndices&&s.has(v.ACCESSOR))for(const c of i.listMeshes())for(const h of c.listPrimitives())wn(h);if(s.has(v.ANIMATION))for(const c of i.listAnimations()){for(const h of c.listChannels())h.getTargetNode()||h.dispose();if(c.listChannels().length)c.listSamplers().forEach(h=>S(h,n));else{const h=c.listSamplers();S(c,n),h.forEach(f=>S(f,n))}}if(s.has(v.MATERIAL)&&i.listMaterials().forEach(c=>S(c,n)),s.has(v.TEXTURE)&&(i.listTextures().forEach(c=>S(c,n)),t.keepSolidTextures||await Nn(r)),s.has(v.ACCESSOR)&&i.listAccessors().forEach(c=>S(c,n)),s.has(v.BUFFER)&&i.listBuffers().forEach(c=>S(c,n)),l.removeEventListener("node:dispose",u),o.empty())a.debug(`${q}: No unused properties found.`);else{const c=o.entries().map(([h,f])=>`${h} (${f})`).join(", ");a.info(`${q}: Removed types... ${c}`)}a.debug(`${q}: Complete.`)})}class En{constructor(){this.disposed={}}empty(){for(const t in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(t){this.disposed[t.propertyType]=this.disposed[t.propertyType]||0,this.disposed[t.propertyType]++}}function S(e,t){const s=e.listParents().filter(r=>!(r instanceof me||r instanceof Pe)),n=t&&!Mt(e.getExtras());!s.length&&!n&&e.dispose()}function Ke(e,t,s){for(const n of e.listEdges()){const r=n.getParent();r.propertyType===t&&S(r,s)}}function Rt(e,t,s){if(t.listChildren().forEach(i=>Rt(e,i,s)),t instanceof ns)return;const n=e.listParentEdges(t).some(i=>{const l=i.getParent().propertyType;return l!==v.ROOT&&l!==v.SCENE&&l!==v.NODE}),r=e.listChildren(t).length===0,a=s&&!Mt(t.getExtras());r&&!n&&!a&&t.dispose()}function Je(e,t){for(const s of t)e.setAttribute(s,null)}function wn(e){const t=e.getIndices(),s=t&&t.getArray(),n=e.listAttributes()[0];if(!(!s||!n)&&t.getCount()===n.getCount()){for(let r=0,a=s.length;r<a;r++)if(r!==s[r])return;e.setIndices(null)}}function In(e,t){const s=[];for(const n of e.listSemantics())(n==="NORMAL"&&!t.has(n)||n==="TANGENT"&&!t.has(n)||n.startsWith("TEXCOORD_")&&!t.has(n)||n.startsWith("COLOR_")&&n!=="COLOR_0")&&s.push(n);return s}function jt(e,t,s,n=new Set){const a=e.getGraph().listChildEdges(s),i=new Set;for(const u of a)u.getChild()instanceof Me&&i.add(u.getName());for(const u of a){const c=u.getName(),h=u.getChild();h instanceof yt&&i.has(c.replace(/Info$/,""))&&n.add(`TEXCOORD_${h.getTexCoord()}`),h instanceof Me&&c.match(/normalTexture/i)&&n.add("TANGENT"),h instanceof bt&&jt(e,t,h,n)}const l=s instanceof vt&&!s.getExtension("KHR_materials_unlit"),o=t.getMode()===P.Mode.POINTS;return l&&!o&&n.add("NORMAL"),n}function Mn(e,t){const s=_n(e),n=new Set(s.map(o=>o.getTexCoord())),r=Array.from(n).sort(),a=new Map(r.map((o,u)=>[o,u])),i=new Map(r.map((o,u)=>[`TEXCOORD_${o}`,`TEXCOORD_${u}`]));for(const o of s){const u=o.getTexCoord();o.setTexCoord(a.get(u))}for(const o of t){const u=o.listSemantics().filter(c=>c.startsWith("TEXCOORD_")).sort();l(o,u),o.listTargets().forEach(c=>l(c,u))}function l(o,u){for(const c of u){const h=o.getAttribute(c);if(!h)continue;const f=i.get(c);f!==c&&(o.setAttribute(f,h),o.setAttribute(c,null))}}}async function Nn(e){const t=e.getRoot(),s=e.getGraph(),n=e.getLogger(),a=t.listTextures().map(async i=>{var l;const o=await Sn(i);if(!o)return;An(i)==="srgb"&&rs.convertSRGBToLinear(o,o);const u=i.getName()||i.getURI(),c=(l=i.getSize())==null?void 0:l.join("x"),h=Tn(i);for(const f of s.listParentEdges(i)){const g=f.getParent();g!==t&&Cn(g,o,f.getName(),n)&&f.dispose()}i.listParents().length===1&&(i.dispose(),n.debug(`${q}: Removed solid-color texture "${u}" (${c}px ${h.join(", ")})`))});await Promise.all(a)}function Cn(e,t,s,n){if(e instanceof vt)switch(s){case"baseColorTexture":return e.setBaseColorFactor(bn(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor(an([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=Se;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return Ot(St(Ct(),t,[.5,.5,1,1]))<=Se}return n.warn(`${q}: Detected single-color ${s} texture. Pruning ${s} not yet supported.`),!1}async function Sn(e){const t=await On(e);if(!t)return null;const s=[1/0,1/0,1/0,1/0],n=[-1/0,-1/0,-1/0,-1/0],r=[0,0,0,0],[a,i]=t.shape;for(let l=0;l<a;l++){for(let o=0;o<i;o++)for(let u=0;u<4;u++)s[u]=Math.min(s[u],t.get(l,o,u)),n[u]=Math.max(n[u],t.get(l,o,u));if(Ot(St(r,n,s))/255>Se)return null}return mn(r,gn(r,n,s),.5/255)}async function On(e){try{return await Hs(e.getImage(),e.getMimeType())}catch{return null}}const Ye=2**32-1;var C;(function(e){e.RENDER="render",e.RENDER_CACHED="render-cached",e.UPLOAD="upload",e.UPLOAD_NAIVE="upload-naive",e.DISTINCT="distinct",e.DISTINCT_POSITION="distinct-position",e.UNUSED="unused"})(C||(C={}));function ue(e,t){const s=e.getAttribute("POSITION"),n=e.getIndices();switch(t){case C.RENDER:return n?n.getCount():s.getCount();case C.RENDER_CACHED:return n?new Set(n.getArray()).size:s.getCount();case C.UPLOAD_NAIVE:case C.UPLOAD:return s.getCount();case C.DISTINCT:case C.DISTINCT_POSITION:return xn(t);case C.UNUSED:return n?s.getCount()-new Set(n.getArray()).size:0;default:return Rn(t)}}function xn(e){throw new Error(`Not implemented: ${e}`)}function Rn(e){throw new Error(`Unexpected value: ${e}`)}function jn(e,t,s){const n=ze.fromGraph(e.getGraph());(!t||!s)&&([t,s]=Pn(e));const r=e.getIndices(),a=r?r.getArray():null,i=ue(e,C.RENDER),l=n.createAccessor(),o=i,u=It(o,s);for(let h=0;h<o;h++)u[h]=t[a?a[h]:h];e.setIndices(l.setArray(u));const c=wt(e);for(const h of e.listAttributes()){const f=ee(n,h);Oe(h,r,t,f,s),e.swap(h,f)}for(const h of e.listTargets())for(const f of h.listAttributes()){const g=ee(n,f);Oe(f,r,t,g,s),h.swap(f,g)}r&&r.listParents().length===1&&r.dispose();for(const h of c)h.listParents().length===1&&h.dispose();return e}function Oe(e,t,s,n,r){const a=e.getElementSize(),i=e.getArray(),l=t?t.getArray():null,o=t?t.getCount():e.getCount(),u=new i.constructor(r*a),c=new Uint8Array(r);for(let h=0;h<o;h++){const f=l?l[h]:h,g=s[f];if(!c[g]){for(let p=0;p<a;p++)u[g*a+p]=i[f*a+p];c[g]=1}}return n.setArray(u)}function Pn(e){const t=ue(e,C.UPLOAD),s=e.getIndices(),n=s?s.getArray():null;if(!s||!n)return[Ys(t,1e6),t];const r=new Uint32Array(t).fill(Ye);let a=0;for(let i=0;i<n.length;i++){const l=n[i];r[l]===Ye&&(r[l]=a++)}return[r,a]}Ie.ComponentType;P.Mode;P.Mode;const ne="reorder",zn={target:"size",cleanup:!0};function kn(e){const t=H(zn,e),s=t.encoder;if(!s)throw new Error(`${ne}: encoder dependency required — install "meshoptimizer".`);return D(ne,async n=>{const r=n.getLogger();await s.ready;const a=Ln(n);for(const i of a.indicesToAttributes.keys()){let l=i.getArray();l instanceof Uint32Array?l=l.slice():l=new Uint32Array(l);const[o,u]=s.reorderMesh(l,a.indicesToMode.get(i)===P.Mode.TRIANGLES,t.target==="size"),c=ee(n,i);c.setArray(u<=65534?new Uint16Array(l):l);for(const h of a.indicesToAttributes.get(i)){const f=ee(n,h);Oe(h,i,o,f,u);for(const g of a.indicesToPrimitives.get(i)){g.getIndices()===i&&g.swap(i,c),g.swap(h,f);for(const p of g.listTargets())p.swap(h,f)}}}t.cleanup&&await n.transform(xt({propertyTypes:[v.ACCESSOR],keepAttributes:!0,keepIndices:!0})),a.indicesToAttributes.size?r.debug(`${ne}: Complete.`):r.warn(`${ne}: No qualifying primitives found; may need to weld first.`)})}function Ln(e){const t=new Map,s=new Ee,n=new Ee,r=new Ee;for(const a of e.getRoot().listMeshes())for(const i of a.listPrimitives()){const l=i.getIndices();if(l){t.set(l,i.getMode()),s.add(l,i);for(const o of wt(i))n.add(l,o),r.add(o,i)}}return{indicesToPrimitives:s,indicesToAttributes:n,indicesToMode:t,attributesToPrimitives:r}}function $n(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw new Error("Limit must be positive multiple of four.");const s=e.getAttribute("POSITION").getCount(),n=e.listSemantics().filter(u=>u.startsWith("WEIGHTS_")).length,r=new Uint16Array(n*4),a=new Float32Array(n*4),i=new Float32Array(n*4),l=new Uint32Array(n*4),o=new Uint32Array(n*4);for(let u=0;u<s;u++){he(e,u,"WEIGHTS",a),he(e,u,"JOINTS",l);for(let c=0;c<n*4;c++)r[c]=c;r.sort((c,h)=>a[c]>a[h]?-1:1);for(let c=0;c<r.length;c++)i[c]=a[r[c]],o[c]=l[r[c]];ge(e,u,"WEIGHTS",i),ge(e,u,"JOINTS",o)}for(let u=n;u*4>t;u--){const c=e.getAttribute(`WEIGHTS_${u-1}`),h=e.getAttribute(`JOINTS_${u-1}`);e.setAttribute(`WEIGHTS_${u-1}`,null),e.setAttribute(`JOINTS_${u-1}`,null),c.listParents().length===1&&c.dispose(),h.listParents().length===1&&h.dispose()}Un(e)}function Un(e){if(!Vn(e))return;const t=e.getAttribute("POSITION").getCount(),s=e.listSemantics().filter(h=>h.startsWith("WEIGHTS_")).length,n=e.getAttribute("WEIGHTS_0"),r=n.getArray(),a=n.getComponentType(),i=n.getNormalized(),l=i?a:void 0,o=i?U.decodeNormalizedInt(1,a):Number.EPSILON,u=new Uint32Array(s*4).fill(0),c=r.slice(0,s*4).fill(0);for(let h=0;h<t;h++){he(e,h,"JOINTS",u),he(e,h,"WEIGHTS",c,l);let f=Ze(c,l);if(f!==0&&f!==1){if(Math.abs(1-f)>o)for(let g=0;g<c.length;g++)if(i){const p=U.decodeNormalizedInt(c[g],a);c[g]=U.encodeNormalizedInt(p/f,a)}else c[g]/=f;if(f=Ze(c,l),i&&f!==1){for(let g=c.length-1;g>=0;g--)if(c[g]>0){const p=1-f;c[g]+=Math.sign(p)*U.encodeNormalizedInt(Math.abs(p),a);break}}}for(let g=c.length-1;g>=0;g--)c[g]===0&&(u[g]=0);ge(e,h,"JOINTS",u),ge(e,h,"WEIGHTS",c,l)}}function he(e,t,s,n,r){let a;const i=[0,0,0,0];for(let l=0;a=e.getAttribute(`${s}_${l}`);l++){a.getElement(t,i);for(let o=0;o<4;o++)r?n[l*4+o]=U.encodeNormalizedInt(i[o],r):n[l*4+o]=i[o]}return n}function ge(e,t,s,n,r){let a;const i=[0,0,0,0];for(let l=0;a=e.getAttribute(`${s}_${l}`);l++){for(let o=0;o<4;o++)r?i[o]=U.decodeNormalizedInt(n[l*4+o],r):i[o]=n[l*4+o];a.setElement(t,i)}}function Ze(e,t){let s=0;for(let n=0;n<e.length;n++)t?s+=U.decodeNormalizedInt(e[n],t):s+=e[n];return s}function Vn(e){const t=e.listSemantics().filter(r=>r.startsWith("WEIGHTS_")).map(r=>e.getAttribute(r)),s=t.map(r=>r.getNormalized()),n=t.map(r=>r.getComponentType());return new Set(s).size===1&&new Set(n).size===1}const V="quantize",Fn=[Int8Array,Int16Array,Int32Array],{TRANSLATION:Dn,ROTATION:qn,SCALE:Bn,WEIGHTS:Gn}=Pe.TargetPath,Wn=[Dn,qn,Bn],oe={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};function Le(e=oe){const t=H(oe,B({patternTargets:e.pattern||oe.pattern},e));return D(V,async s=>{const n=s.getLogger(),r=s.getRoot();let a;t.quantizationVolume==="scene"&&(a=tt(er(r.listMeshes().map(st))));for(const l of s.getRoot().listMeshes()){t.quantizationVolume==="mesh"&&(a=tt(st(l))),a&&t.pattern.test("POSITION")&&(Hn(s,l,a),Kn(l,1/a.scale));for(const o of l.listPrimitives()){const u=ue(o,C.RENDER),c=ue(o,C.UPLOAD);u<c/2&&jn(o),et(s,o,a,t);for(const h of o.listTargets())et(s,h,a,t)}}r.listMeshes().flatMap(l=>l.listPrimitives()).some(Pt)&&s.createExtension(mt).setRequired(!0),t.cleanup&&await s.transform(xt({propertyTypes:[v.ACCESSOR,v.SKIN,v.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),on({propertyTypes:[v.ACCESSOR,v.MATERIAL,v.SKIN],keepUniqueNames:!0})),n.debug(`${V}: Complete.`)})}function et(e,t,s,n){const r=t instanceof as,a=e.getLogger();for(const i of t.listSemantics()){if(!r&&!n.pattern.test(i)||r&&!n.patternTargets.test(i))continue;const l=t.getAttribute(i),{bits:o,ctor:u}=Yn(i,l,a,n);if(!u)continue;if(o<8||o>16)throw new Error(`${V}: Requires bits = 8–16.`);if(l.getComponentSize()<=o/8)continue;const c=l.clone();if(i==="POSITION"){const h=s.scale,f=[];t instanceof P?Zs(f,ye(s)):en(f,[1/h,1/h,1/h]);for(let g=0,p=[0,0,0],m=c.getCount();g<m;g++)c.getElement(g,p),c.setElement(g,rn(p,p,f))}Jn(c,u,o),t.setAttribute(i,c)}if(n.normalizeWeights&&t.getAttribute("WEIGHTS_0")&&$n(t,1/0),t instanceof P&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){const i=t.getIndices();i.setArray(new Uint16Array(i.getArray()))}}function tt(e){const{min:t,max:s}=e,n=Math.max((s[0]-t[0])/2,(s[1]-t[1])/2,(s[2]-t[2])/2);return{offset:[t[0]+(s[0]-t[0])/2,t[1]+(s[1]-t[1])/2,t[2]+(s[2]-t[2])/2],scale:n}}function Hn(e,t,s){const n=ye(s);for(const r of t.listParents()){if(!(r instanceof ss))continue;const a=r.listParents().filter(f=>f instanceof Pe),i=a.some(f=>Wn.includes(f.getTargetPath())),l=r.listChildren().length>0,o=r.getSkin();if(o){r.setSkin(Xn(o,s));continue}const u=r.getExtension("EXT_mesh_gpu_instancing");if(u){r.setExtension("EXT_mesh_gpu_instancing",Qn(u,s));continue}let c;l||i?(c=e.createNode("").setMesh(t),r.addChild(c).setMesh(null),a.filter(f=>f.getTargetPath()===Gn).forEach(f=>f.setTargetNode(c))):c=r;const h=c.getMatrix();ke(h,h,n),c.setMatrix(h)}}function Xn(e,t){e=e.clone();const s=ye(t),n=e.getInverseBindMatrices().clone(),r=[];for(let a=0,i=n.getCount();a<i;a++)n.getElement(a,r),ke(r,r,s),n.setElement(a,r);return e.setInverseBindMatrices(n)}function Qn(e,t){var s,n,r;if(!e.getAttribute("TRANSLATION")&&!e.getAttribute("ROTATION")&&!e.getAttribute("SCALE"))return e;e=e.clone();const a=(s=e.getAttribute("TRANSLATION"))==null?void 0:s.clone(),i=(n=e.getAttribute("ROTATION"))==null?void 0:n.clone(),l=(r=e.getAttribute("SCALE"))==null?void 0:r.clone(),o=a||i||l,u=[0,0,0],c=[0,0,0,1],h=[1,1,1],f=[0,0,0],g=[0,0,0,1],p=[1,1,1],m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],d=ye(t);for(let y=0,T=o.getCount();y<T;y++)U.compose(a?a.getElement(y,f):u,i?i.getElement(y,g):c,l?l.getElement(y,p):h,m),ke(m,m,d),U.decompose(m,f,g,p),a&&a.setElement(y,f),i&&i.setElement(y,g),l&&l.setElement(y,p);return a&&e.setAttribute("TRANSLATION",a),i&&e.setAttribute("ROTATION",i),l&&e.setAttribute("SCALE",l),e}function Kn(e,t){for(const s of e.listPrimitives()){let n=s.getMaterial();if(!n)continue;let r=n.getExtension("KHR_materials_volume");!r||r.getThicknessFactor()<=0||(r=r.clone().setThicknessFactor(r.getThicknessFactor()*t),n=n.clone().setExtension("KHR_materials_volume",r),s.setMaterial(n))}}function Jn(e,t,s){const n=new t(e.getArray().length),r=Fn.includes(t)?1:0,a=s-r,i=t.BYTES_PER_ELEMENT*8-r,l=Math.pow(2,a)-1,o=i-a,u=2*a-i,c=[r>0?-1:0,1];for(let h=0,f=0,g=[];h<e.getCount();h++){e.getElement(h,g);for(let p=0;p<g.length;p++){let m=tr(g[p],c);m=Math.round(Math.abs(m)*l),m=m<<o|m>>u,n[f++]=m*Math.sign(g[p])}}e.setArray(n).setNormalized(!0).setSparse(!1)}function Yn(e,t,s,n){const r=t.getMinNormalized([]),a=t.getMaxNormalized([]);let i,l;if(e==="POSITION")i=n.quantizePosition,l=i<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")i=n.quantizeNormal,l=i<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))i=n.quantizeColor,l=i<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(r.some(o=>o<0)||a.some(o=>o>1))return s.warn(`${V}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=n.quantizeTexcoord,l=i<=8?Uint8Array:Uint16Array}else{if(e.startsWith("JOINTS_"))return i=Math.max(...t.getMax([]))<=255?8:16,l=i<=8?Uint8Array:Uint16Array,t.getComponentSize()>i/8&&t.setArray(new l(t.getArray())),{bits:-1};if(e.startsWith("WEIGHTS_")){if(r.some(o=>o<0)||a.some(o=>o>1))return s.warn(`${V}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=n.quantizeWeight,l=i<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(r.some(o=>o<-1)||a.some(o=>o>1))return s.warn(`${V}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};i=n.quantizeGeneric,l=r.some(o=>o<0)?l=i<=8?Int8Array:Int16Array:l=i<=8?Uint8Array:Uint16Array}else throw new Error(`${V}: Unexpected semantic, "${e}".`)}return{bits:i,ctor:l}}function st(e){const t=[],s=[];for(const r of e.listPrimitives()){const a=r.getAttribute("POSITION");a&&t.push(a);for(const i of r.listTargets()){const l=i.getAttribute("POSITION");l&&s.push(l)}}if(t.length===0)throw new Error(`${V}: Missing "POSITION" attribute.`);const n=nt(t,3);if(s.length>0){const{min:r,max:a}=nt(s,3);Ne(n.min,n.min,Ne(r,He(r,r,2),[0,0,0])),Ce(n.max,n.max,Ce(a,He(a,a,2),[0,0,0]))}return n}function Zn(e,t){const s=t.getComponentSize();if(e==="POSITION"||e==="NORMAL"||e==="TANGENT")return s<4;if(e.startsWith("TEXCOORD_")){const n=t.getComponentType(),r=t.getNormalized();return s<4&&!(r&&n===Ie.ComponentType.UNSIGNED_BYTE)&&!(r&&n===Ie.ComponentType.UNSIGNED_SHORT)}return!1}function Pt(e){for(const t of e.listSemantics()){const s=e.getAttribute("POSITION");if(Zn(t,s))return!0}return e.propertyType===v.PRIMITIVE?e.listTargets().some(Pt):!1}function nt(e,t){const s=new Array(t).fill(1/0),n=new Array(t).fill(-1/0),r=[],a=[];for(const i of e){i.getMinNormalized(r),i.getMaxNormalized(a);for(let l=0;l<t;l++)s[l]=Math.min(s[l],r[l]),n[l]=Math.max(n[l],a[l])}return{min:s,max:n}}function er(e){const t=e[0];for(const s of e)Ne(t.min,t.min,s.min),Ce(t.max,t.max,s.max);return t}function ye(e){return tn([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function tr(e,t){return Math.min(Math.max(e,t[0]),t[1])}const sr=B({level:"high"},oe),rt="meshopt";function zt(e){const t=H(sr,e),s=t.encoder;if(!s)throw new Error(`${rt}: encoder dependency required — install "meshoptimizer".`);return D(rt,async n=>{let r,a,i=t.quantizeNormal;n.getRoot().listAccessors().length!==0&&(t.level==="medium"?(r=/.*/,a=/.*/):(r=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR)(_\d+)?$/,a=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR|NORMAL|TANGENT)(_\d+)?$/,i=Math.min(i,8)),await n.transform(kn({encoder:s,target:"size"}),Le(B({},t,{pattern:r,patternTargets:a,quantizeNormal:i}))),n.createExtension(ie).setRequired(!0).setEncoderOptions({method:t.level==="medium"?ie.EncoderMethod.QUANTIZE:ie.EncoderMethod.FILTER}))})}const xe="unweld",nr={};function rr(e=nr){return D(xe,t=>{const s=t.getLogger(),n=new Map;for(const r of t.getRoot().listMeshes())for(const a of r.listPrimitives())ar(a,n);s.debug(`${xe}: Complete.`)})}function ar(e,t=new Map){const s=e.getIndices();if(!s)return;const n=e.getGraph(),r=ze.fromGraph(n),a=r.getLogger(),i=e.getAttribute("POSITION").getCount();for(const o of e.listAttributes())e.swap(o,at(r,o,s,t)),o.listParents().length===1&&o.dispose();for(const o of e.listTargets())for(const u of o.listAttributes())o.swap(u,at(r,u,s,t)),u.listParents().length===1&&u.dispose();const l=e.getAttribute("POSITION").getCount();a.debug(`${xe}: ${Ks(i,l)} vertices.`),e.setIndices(null),s.listParents().length===1&&s.dispose()}function at(e,t,s,n){if(n.has(t)&&n.get(t).has(s))return n.get(t).get(s);const r=t.getArray(),a=r.constructor,i=new a(s.getCount()*t.getElementSize()),l=s.getArray(),o=t.getElementSize();for(let c=0,h=s.getCount();c<h;c++)for(let f=0;f<o;f++)i[c*o+f]=r[l[c]*o+f];n.has(t)||n.set(t,new Map);const u=ee(e,t).setArray(i);return n.get(t).set(s,u),u}var it;(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(it||(it={}));const ir=1e-6;function or(e,t,s,n=1e-4){const r=t.length/e.length,a=new Array(r).fill(0),i=new Array(r).fill(0),l=new Array(r).fill(0),o=new Array(r).fill(0),u=e.length-1;let c=1;for(let h=1;h<u;++h){const f=e[c-1],g=e[h],p=e[h+1],m=(g-f)/(p-f);let d=!1;if(g!==p&&(h!==1||g!==e[0]))if(Z(t,c-1,o),Z(t,h,i),Z(t,h+1,l),s==="slerp"){const y=fr(a,o,l,m),T=lt(o,i)+lt(i,l);d=!re(i,y,n)||T+Number.EPSILON>=Math.PI}else if(s==="lerp"){const y=cr(a,o,l,m);d=!re(i,y,n)}else s==="step"&&(d=!re(i,o)||!re(i,l));d&&(h!==c&&(e[c]=e[h],ot(t,c,Z(t,h,a))),c++)}return u>0&&(e[c]=e[u],ot(t,c,Z(t,u,a)),c++),c}function Z(e,t,s){for(let n=0,r=s.length;n<r;n++)s[n]=e[t*r+n];return s}function ot(e,t,s){for(let n=0,r=s.length;n<r;n++)e[t*r+n]=s[n]}function re(e,t,s=0){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(Math.abs(e[n]-t[n])>s)return!1;return!0}function lr(e,t,s){return e*(1-s)+t*s}function cr(e,t,s,n){for(let r=0;r<t.length;r++)e[r]=lr(t[r],s[r],n);return e}function fr(e,t,s,n){let r=t[0],a=t[1],i=t[2],l=t[3],o=s[0],u=s[1],c=s[2],h=s[3],f,g,p,m,d;return g=r*o+a*u+i*c+l*h,g<0&&(g=-g,o=-o,u=-u,c=-c,h=-h),1-g>ir?(f=Math.acos(g),p=Math.sin(f),m=Math.sin((1-n)*f)/p,d=Math.sin(n*f)/p):(m=1-n,d=n),e[0]=m*r+d*o,e[1]=m*a+d*u,e[2]=m*i+d*c,e[3]=m*l+d*h,e}function lt(e,t){const s=ur(e,t);return Math.acos(2*s*s-1)}function ur(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}Promise.resolve();P.Mode;var Re;(function(e){e.LANCZOS3="lanczos3",e.LANCZOS2="lanczos2"})(Re||(Re={}));Re.LANCZOS3;const $="tangents",ct={overwrite:!1};function hr(e=ct){const t=H(ct,e);if(!t.generateTangents)throw new Error(`${$}: generateTangents callback required — install "mikktspace".`);return D($,s=>{const n=s.getLogger(),r=new Map,a=new Map;let i=0;for(const l of s.getRoot().listMeshes()){const o=l.getName(),u=l.listPrimitives();for(let c=0;c<u.length;c++){const h=u[c];if(!pr(h,n,o,c,t.overwrite))continue;const f=gr(h),g=h.getAttribute("POSITION").getArray(),p=h.getAttribute("NORMAL").getArray(),m=h.getAttribute(f).getArray(),d=r.get(g)||ve();r.set(g,d);const y=r.get(p)||ve();r.set(p,y);const T=r.get(m)||ve();r.set(m,T);const A=h.getAttribute("TANGENT");A&&A.listParents().length===2&&A.dispose();const b=`${d}|${y}|${T}`;let _=a.get(b);if(_){n.debug(`${$}: Found cache for primitive ${c} of mesh "${o}".`),h.setAttribute("TANGENT",_),i++;continue}n.debug(`${$}: Generating for primitive ${c} of mesh "${o}".`);const E=h.getAttribute("POSITION").getBuffer(),x=t.generateTangents(g instanceof Float32Array?g:new Float32Array(g),p instanceof Float32Array?p:new Float32Array(p),m instanceof Float32Array?m:new Float32Array(m));for(let L=3;L<x.length;L+=4)x[L]*=-1;_=s.createAccessor().setBuffer(E).setArray(x).setType("VEC4"),h.setAttribute("TANGENT",_),a.set(b,_),i++}}i?n.debug(`${$}: Complete.`):n.warn(`${$}: No qualifying primitives found. See debug output.`)})}function gr(e){const t=e.getMaterial();if(!t)return"TEXCOORD_0";const s=t.getNormalTextureInfo();if(!s)return"TEXCOORD_0";const r=`TEXCOORD_${s.getTexCoord()}`;return e.getAttribute(r)?r:"TEXCOORD_0"}function pr(e,t,s,n,r){return e.getMode()!==P.Mode.TRIANGLES||!e.getAttribute("POSITION")||!e.getAttribute("NORMAL")||!e.getAttribute("TEXCOORD_0")?(t.debug(`${$}: Skipping primitive ${n} of mesh "${s}": primitives must have attributes=[POSITION, NORMAL, TEXCOORD_0] and mode=TRIANGLES.`),!1):e.getAttribute("TANGENT")&&!r?(t.debug(`${$}: Skipping primitive ${n} of mesh "${s}": TANGENT found.`),!1):e.getIndices()?(t.warn(`${$}: Skipping primitive ${n} of mesh "${s}": primitives must be unwelded.`),!1):!0}async function dr(e,t,s,n={}){var y;const{remapMaterials:r,animationEvents:a,textureOptions:i,optimizeOptions:l}=s,o=await t.readBinary(e),u=o.getRoot().listExtensionsUsed(),c=u.some(T=>T.extensionName==="EXT_meshopt_compression"),h=u.some(T=>T.extensionName==="KHR_mesh_quantization");if((i==null?void 0:i.textureType)==="ktx2"&&n.ktx2Encode){const T=o.getRoot().listTextures();T.length>0&&o.createExtension(is).setRequired(!0);const A=T.filter(b=>b.getMimeType()!=="image/ktx2");await Promise.all(A.map(async b=>{b.setMimeType("image/ktx2");const _=b.getImage(),E=await n.ktx2Encode(_.buffer,{isUASTC:i.mode==="UASTC",qualityLevel:i.quality??255});b.setImage(E)}))}r&&o.getRoot().listMaterials().forEach((T,A)=>{if(r[A]){const b=o.createExtension(Ae).createGlTFRemapping().setRefId(r[A].refId);T.setExtension(Ae.EXTENSION_NAME,b)}}),a&&o.getRoot().listAnimations().forEach((T,A)=>{if(a[A]){const b=o.createExtension(Be).createAnimationEvent().setEvents(a[A]);T.setExtension(Be.EXTENSION_NAME,b)}});const g=[];l!=null&&l.meshopt&&!c&&(await le.ready,g.push(zt({encoder:le}))),l!=null&&l.meshQuantize&&!h&&g.push(Le({quantizePosition:16,quantizeNormal:12,quantizeTexcoord:14})),g.length>0&&await o.transform(...g);const p=await t.writeJSON(o,{format:os.GLB});if(n.resolveRef&&r){const T=Ae.EXTENSION_NAME;(y=p.json.materials)==null||y.forEach(A=>{var _;const b=(_=A.extensions)==null?void 0:_[T];if(b!=null&&b.refId){const E=n.resolveRef(b.refId);E&&(A.extensions[T]={url:E.url})}})}return{name:s.name.replace(/\.[^.]+$/,"")+".glb",content:_t(p)}}const ft=Vt("div",{color:"$gray10"}),mr=ht(({asset:e,index:t,originMaterial:s})=>{const{assetStore:n}=At(),r=e.remapMaterials[t];let a=Object.values(n.assets);a=a.filter(l=>l.getMetaConfig().type==="Material"&&!l.isSubAsset);const i=n.assets[r==null?void 0:r.refId];return I.jsx(Ft,{dropLayer:gt.Material,assets:a,customFilter:l=>l.mainId!==e.id,onSelect:l=>{(!i||l.engineObject!==i.engineObject)&&e.replaceMaterial(t,l.getCurrentRef())},onDelete:()=>{r&&e.resetMaterial(t)},onLocate:()=>{r&&r.refId&&n.selectAsset(r.refId)},label:s.name,value:i==null?void 0:i.name,asset:i})}),yr=ht(({asset:e})=>{var l;const t=e.engineObject.materials,{inspectorFacade:s}=At(),n=e.glTFInfo,r=(l=n.issues)==null?void 0:l.messages,{t:a}=Dt();function i(o,u){s.assetChange(e.id,o,u,"asset-meta")}return I.jsxs(I.Fragment,{children:[I.jsxs($e,{title:a("asset.gltf.basic-info"),defaultOpen:!0,children:[n.triangles?I.jsx(te,{label:a("asset.gltf.triangles"),children:I.jsx(be,{value:n.triangles,disabled:!0})}):null,n.drawcall?I.jsx(te,{label:a("asset.gltf.drawcall"),children:I.jsx(be,{value:n.drawcall,disabled:!0})}):null,I.jsx(se,{label:a("asset.gltf.compute-tangents"),value:e.needComputeTangents,onChange:o=>{i("needComputeTangents",o)},checkboxLabel:I.jsx(ft,{children:a("asset.gltf.refresh-tip")})}),I.jsx(se,{label:a("asset.gltf.keep-mesh-data"),value:e.params.keepMeshData,onChange:o=>{e.params={...e.params,keepMeshData:o}},checkboxLabel:I.jsx(ft,{children:a("asset.gltf.refresh-tip")})})]}),I.jsx(Ue,{}),r?I.jsxs(qt.Fragment,{children:[I.jsxs($e,{title:`${a("asset.gltf.issues")}: ${r.length}`,defaultOpen:!1,children:[r.slice(0,15).map((o,u)=>I.jsx(te,{label:o.pointer,children:I.jsx(be,{value:o.message,css:{color:"red"},disabled:!0})},u)),r.length>15?I.jsx(te,{label:"..."}):null]}),I.jsx(Ue,{})]}):null,I.jsx(Ve,{label:a("asset.gltf.remapped-materials"),children:t==null?void 0:t.map((o,u)=>I.jsx(mr,{originMaterial:o,asset:e,index:u},`${e.id}-${u}`))}),I.jsxs(Ve,{label:a("asset.gltf.compression"),children:[!e.optimize.meshopt&&I.jsx(se,{label:a("asset.gltf.quantize"),value:e.optimize.meshQuantize,onChange:o=>{Tracert.click("c351684.d417982",{checked:o}),i("optimize",{...e.optimize,meshQuantize:o})}}),I.jsx(se,{label:a("asset.gltf.meshopt"),value:e.optimize.meshopt,onChange:o=>{Tracert.click("c351684.d417983",{checked:o}),i("optimize",{...e.optimize,meshopt:o})}})]})]})});function pe(e){return/^(?:http|blob|data:|\/)/.test(e)}function kt(e){return/^data:(.+?);base64,/.test(e)}function de(e,t){return t.charAt(0)==="."?ut(e+t):ut(e.substring(0,e.lastIndexOf("/")+1)+t)}function ut(e){const t=[],s=e.split("/");for(let n=0;n<s.length;n++){const r=s[n];if(!(!r||r===".")){if(r===".."){t.length>0&&t.pop();continue}t.push(r)}}return t.join("/")}async function br(e,t){const s=JSON.parse(await e.text()),n=s.images,r={},a="",i=[];if(n)for(let o=0;o<n.length;o++){const c=n[o].uri;if(c)if(pe(c))i.push(fetch(c).then(h=>h.arrayBuffer()).then(h=>{r[c]=new Uint8Array(h)}));else{const h=de(a,c);i.push(t[h].arrayBuffer().then(f=>{r[c]=new Uint8Array(f)}))}}const l=s.buffers;if(l)for(let o=0;o<l.length;o++){const c=l[o].uri;if(c)if(!pe(c)&&!kt(c)){const h=de(a,c);i.push(t[h].arrayBuffer().then(f=>{r[c]=new Uint8Array(f)}))}else i.push(fetch(c).then(h=>h.arrayBuffer()).then(h=>{r[c]=new Uint8Array(h)}))}return await Promise.all(i),gs({json:s,resources:r})}async function vr(e){const t={uploadFiles:[],errors:[]};for(const s in e){const n=e[s],a=n.name.toLowerCase();if(a.endsWith(".glb")||a.endsWith(".fbx"))t.uploadFiles.push({main:n});else if(a.endsWith(".gltf")){const i=await Ar(n,e);typeof i=="string"?t.errors.push(i):t.uploadFiles.push(i)}}return t}async function Ar(e,t){const s=JSON.parse(await e.text()),n=s.images,r=s.buffers,a="",i={main:e,subFiles:{},postfix:".glb"};if(n)for(let l=0;l<n.length;l++){const u=n[l].uri;if(u&&!pe(u)){const c=de(a,u);if(t[c])i.subFiles[c]=t[c];else return`${u} is not found in the files.`}}if(r)for(let l=0;l<r.length;l++){const u=r[l].uri;if(u&&!pe(u)&&!kt(u)){const c=de(a,u);if(t[c])i.subFiles[c]=t[c];else return`${u} is not found in the files.`}}return i}async function _r(e,t){const s=Bt(e.main,"model.gltf"),n=s.name.replace(/\.[^.]+$/,".glb");if(s.name.toLocaleLowerCase().endsWith(".gltf")){const r=e.subFiles??{},a=await br(s,r);return new File([a.buffer],n)}return s}function Tr(e){const t=Object.entries(e.remapMaterials).filter(([,s])=>!!s);if(!t.length){e.settleInitCompleted();return}e.onInitComplete(async()=>{try{await Promise.all(t.map(([s,n])=>e.replaceMaterial(Number(s),n,!1)))}catch{}finally{e.settleInitCompleted()}})}async function Er(e){e.notifySuccess("Success. page will reload, please wait...");try{await e.assetFacade.persistAssetMetaImmediate(e.assetId),e.reload()}catch(t){e.logError("Failed to persist optimize config before reload",t),e.notifyError("Failed to save optimize config, reload canceled.")}}class je{static update(t,s){!this.entity&&(this.entity=t.createChild("glTF"));const n=this.tempCloneEntity=s.engineObject.instantiateSceneRoot();this.entity.addChild(n)}static clear(){this.entity.clearChildren(),this.tempCloneEntity&&this.tempCloneEntity.destroy()}}w(je,"entity"),w(je,"tempCloneEntity");var wr=Object.defineProperty,Ir=Object.getOwnPropertyDescriptor,z=(e,t,s,n)=>{for(var r=n>1?void 0:n?Ir(t,s):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(r=(n?i(t,s,r):i(r))||r);return n&&r&&wr(t,s,r),r};class j extends cs{constructor(){super();w(this,"animationNames",[]);w(this,"frameTime",0);w(this,"duration",0);w(this,"playing",!1);w(this,"animationIndex",0);w(this,"selectedClip");w(this,"_updateComponent");w(this,"_clips",[]);pt(this)}setViewAsset(s,n){const{animations:r=[]}=s.engineObject;this._clips=r,this.animationIndex=0,this.animationNames=r.map(i=>i.name),this._entity=s.instantiateEngineObject(),n.addChild(this._entity);const a=this;r.length>0&&(this._updateComponent=this._entity.addComponent(class extends Gt{onUpdate(i){a._onUpdate(i)}})),this.duration=0}stopViewAsset(){var s;super.stopViewAsset(),this.frameTime=0,this.pauseAnimation(),(s=this._updateComponent)==null||s.destroy(),this.animationNames=null}selectAnimation(s){this.selectedClip=this._clips[s],this.frameTime=0,this.duration=this.selectedClip.length,this.animationIndex=s,this._sampleAnimation()}setFrameTime(s){this.frameTime=s,this._sampleAnimation()}playAnimation(){this.selectedClip&&(this.playing=!0)}pauseAnimation(){this.playing=!1}_onUpdate(s){!this.playing||!this.selectedClip||!this.duration||(this.frameTime+=s,this.frameTime>this.duration&&(this.frameTime%=this.duration),this._sampleAnimation())}_sampleAnimation(){try{this.selectedClip._sampleAnimation(this._entity.children[0],this.frameTime)}catch(s){console.warn(s)}}}z([R],j.prototype,"animationNames",2);z([R],j.prototype,"frameTime",2);z([R],j.prototype,"duration",2);z([R],j.prototype,"playing",2);z([R],j.prototype,"animationIndex",2);z([G],j.prototype,"selectAnimation",1);z([G],j.prototype,"setFrameTime",1);z([G],j.prototype,"playAnimation",1);z([G],j.prototype,"pauseAnimation",1);z([G],j.prototype,"_onUpdate",1);var Mr=Object.defineProperty,Nr=Object.getOwnPropertyDescriptor,k=(e,t,s,n)=>{for(var r=n>1?void 0:n?Nr(t,s):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(r=(n?i(t,s,r):i(r))||r);return n&&r&&Mr(t,s,r),r};const ae=ts("gltf");let O=class extends ls{constructor(t){super(t);w(this,"exportedUrl","");w(this,"glTFInfo",{drawcall:void 0,triangles:void 0,issues:void 0});w(this,"remapMaterials",{});w(this,"animationEvents",{});w(this,"needComputeTangents",!0);w(this,"fbxUrl",null);w(this,"optimize",{meshopt:!1,meshQuantize:!1});w(this,"params",{keepMeshData:!1});w(this,"initCompleted");w(this,"_rootKey","defaultSceneRoot");w(this,"mappedMaterialsPath",[]);w(this,"_initCompletedResolve");w(this,"_autorunDisposer",null);w(this,"_propertyChangeListeners",new Map);pt(this),this.initCompleted=new Promise(s=>{this._initCompletedResolve=s})}applyMetaFromDomain(t){if(super.applyMetaFromDomain(t),"needComputeTangents"in t&&(this.needComputeTangents=t.needComputeTangents),"optimize"in t&&typeof t.optimize=="object"){const s=t.optimize;this.optimize={...this.optimize,...s}}}async generateSubAssets(){const t=this.engineObject;if(this._subAssets=[],t.meshes)for(let s=0;s<t.meshes.length;s++){const n=t.meshes[s];for(let r=0;r<n.length;r++){const a=await this.root.assetStore.createSubAsset("Mesh",n[r],this.id,`meshes[${s}][${r}]`);this._subAssets.push(a)}}if(t.textures)for(let s=0;s<t.textures.length;s++){const n=await this.root.assetStore.createSubAsset("Texture",t.textures[s],this.id,`textures[${s}]`);this._subAssets.push(n)}if(t.animations){for(let r=0;r<t.animations.length;r++){const a=t.animations[r],i=this.animationEvents[r];i&&i.forEach(o=>{a.addEvent(o.functionName,o.time,o.parameter)});const l=await this.root.assetStore.createSubAsset("AnimationClip",a,this.id,`animations[${r}]`);this._subAssets.push(l)}const s=t.defaultSceneRoot.getComponent(Wt).animatorController,n=await this.root.assetStore.createSubAsset("AnimatorController",s,this.id,"animatorController[0]");this._subAssets.push(n)}if(t.materials)for(let s=0;s<t.materials.length;s++){const n=await this.root.assetStore.createSubAsset("Material",t.materials[s],this.id,`materials[${s}]`);this._subAssets.push(n)}}async initByMain(t,s){const{engine:n,meta:r}=this;this.url=s,this.animationEvents=r.animationEvents||{},this.optimize=r.optimize??this.optimize;let a=this.optimize.meshopt,i=this.optimize.meshQuantize;this._autorunDisposer=Ht(()=>{const o=this.optimize.meshQuantize;i!==o&&(this.optimize.meshQuantize=o,i=o,this._saveMetaAndReload());const u=this.optimize.meshopt;a!==u&&(this.optimize.meshopt=u,a=u,this._saveMetaAndReload())}),this.params=r.params??this.params;let l;try{l=URL.createObjectURL(t),await this.initByUrl(l+"#.glb",n)}finally{l!==void 0&&URL.revokeObjectURL(l)}this.needComputeTangents=r.needComputeTangents??!0,Tr({remapMaterials:r.remapMaterials||{},onInitComplete:o=>{this.on("initcomplete",o)},replaceMaterial:async(o,u,c)=>{await this.replaceMaterial(o,u,c)},settleInitCompleted:()=>{this._initCompletedResolve()}}),this.fbxUrl=r.fbxUrl}_saveMetaAndReload(){Er({assetFacade:this.root.assetFacade,assetId:this.id,reload:()=>window.location.reload(),notifySuccess:t=>Fe.success(dt(t)),notifyError:t=>Fe.error(t),logError:(t,s)=>ae.error(t,s)})}resetMaterial(t){const s=this._engineObject.materials[t];this._internalReplaceMaterial(t,s),this.remapMaterials[t]=void 0,this.root.assetFacade.persistAssetMeta(this.id)}async replaceMaterial(t,s,n=!0){this.remapMaterials[t]=s;const r=this._findComponentsByMaterialPathIndex(t),a=await this.root.assetStore.getAssetByRef(s);if(a instanceof fs){const i=a.engineObject;r.forEach(({component:c,materialIndex:h})=>{c.setMaterial(h,i)});const l=String(t),o=this._propertyChangeListeners.get(l);o&&a.off("propertychange",o);const u=()=>{this.updateThumbnail()};this._propertyChangeListeners.set(l,u),a.on("propertychange",u)}else ae.warn(`${s.refId} shouldn't be selected`);n&&await this.root.assetFacade.persistAssetMeta(this.id),this.updateThumbnail()}updateAnimationEvents(t,s){this.animationEvents[t]=s,this.root.assetFacade.persistAssetMeta(this.id)}async instantiate(t){await this.initCompleted;const s=t.createByEngineObject(this.instantiateEngineObject());s.isGLTFWrapEntity=!0,s.isPrefabRefEntity=!1,await s.ensureReady();const n=s.selfChildren[0];return n?this.addInstance(n):ae.warn(`[GlTFAsset] instantiate: wrap entity has no child, skip addInstance. asset=${this.id}`),s}destroy(){var s;(s=this._autorunDisposer)==null||s.call(this),this._autorunDisposer=null,this._propertyChangeListeners.clear();const t=this.engineObject;t&&(t._defaultSceneRoot.destroy(),t.destroy()),super.destroy()}instantiateEngineObject(){const t=super.instantiateEngineObject(),s=new Xt(this.engine,this.name.replace(/\.glb$/g,""));return s.addChild(t),this._fixClonedSkins(t),s}_fixClonedSkins(t){const s=t.getComponentsIncludeChildren(Qt,[]);for(const n of s){const r=n.skin;if(r&&r.bones.length>0&&!r._skinMatrices){const a=r.bones;r.bones=a}}}_instantiateEngineObject(){return this.engineObject.instantiateSceneRoot()}_destroyInstances(){this._instances.forEach((t,s)=>{const n=t.entities.get(s);if(n){const r=n.parentEntity;r?r.destroy():n.destroy()}}),this._instances.clear()}_internalReplaceMaterial(t,s){this._findComponentsByMaterialPathIndex(t).forEach(({component:r,materialIndex:a})=>{r.setMaterial(a,s)}),this.updateThumbnail()}_findComponentsByMaterialPathIndex(t){const s=[...this._clonedEntities,this._engineObject.defaultSceneRoot],n=this.mappedMaterialsPath[t],r=[];if(!n)return ae.warn(`${this._name} replaced material not found.(gltf may be replaced either)`),r;for(let a=0;a<s.length;a++){const i=s[a];n.forEach(l=>{const u=Sr(l.entityPath,i).getComponents(De,[]);r.push({component:u[l.componentIndex],materialIndex:l.materialIndex})})}return r}async initByUrl(t,s){const n=await s.resourceManager.load({type:Kt.GLTF,url:t,params:this.params});return this.initMappedMaterialPath(n),this.bindEngineObject(n),this._updateDragTempEntity(),await this.generateSubAssets(),await this.initBasicInfo(n),this}async getRemappedMaterial(t){var n;const s=this.remapMaterials[t];return s?(n=await this.root.assetStore.getAssetByRef(s))==null?void 0:n.engineObject:this._engineObject.materials[t]}initMappedMaterialPath(t){const s=t.materials,n=t.defaultSceneRoot;if(s){const r=t.defaultSceneRoot.getComponentsIncludeChildren(qe,[]);s.forEach(a=>{const i=[];this.mappedMaterialsPath.push(i);for(let l=0;l<r.length;l++){const o=r[l],u=o.getMaterials(),c=o.entity.getComponents(De,[]);for(let h=0;h<u.length;h++)u[h]===a&&i.push({entityPath:Cr(o.entity,n),componentIndex:c.indexOf(o),materialIndex:h})}})}}async initBasicInfo(t){this.glTFInfo.drawcall=t.defaultSceneRoot.getComponentsIncludeChildren(qe,[]).length}};k([R,Jt()],O.prototype,"exportedUrl",2);k([W(),R],O.prototype,"remapMaterials",2);k([W()],O.prototype,"animationEvents",2);k([W(),R],O.prototype,"needComputeTangents",2);k([W(),R],O.prototype,"fbxUrl",2);k([W(),R],O.prototype,"optimize",2);k([W(),R],O.prototype,"params",2);k([Yt],O.prototype,"applyMetaFromDomain",1);k([G],O.prototype,"resetMaterial",1);O=k([Zt({type:"glTF",label:dt("asset.gltf.title"),loaderType:"GLTF",importMenuConfig:{type:es.Upload,tooltip:"请上传模型文件(支持gltf,glb,fbx,obj)或包含模型和资源文件(bin、贴图等)的zip压缩包",accept:".zip,.fbx,.gltf,.glb,application/json",subAccept:".bin,.jpeg,.jpg,.png",multiple:!0},filterUploadFiles:vr,preUpload:_r,extname:"glb",dragLayer:gt.GlTF,customInspector:yr,viewer:j,thumbnail:je,async preInitialize({main:e,meta:t,name:s}){const n=new Uint8Array(await e.arrayBuffer()),r=await _e.readBinary(n),a=t.optimize||{},i=t.needComputeTangents??!0,l=a.meshQuantize,o=a.meshopt,u=[],c=r.getRoot().listExtensionsUsed(),h=c.some(p=>p.extensionName===mt.EXTENSION_NAME),f=c.some(p=>p.extensionName===ie.EXTENSION_NAME);l&&!h&&u.push(Le({quantizePosition:16,quantizeNormal:12,quantizeTexcoord:14})),o&&!f&&(await le.ready,u.push(zt({encoder:le})));try{i&&(u.push(rr()),u.push(hr({generateTangents:window.mikktspace.generateTangents,overwrite:!0}))),await r.transform(...u)}catch(p){console.error("The gltf-transform plugin encountered some errors when performing meshopt, quantize, or calculating tangents, we have disabled these features automatically.",p)}const g=await _e.writeBinary(r);return new File([g.buffer],s,{type:"model/gltf-binary"})},async bundle({content:e,name:t,meta:s},n,r){var l;const a=new Uint8Array(await e.arrayBuffer()),i=await dr(a,_e,{name:t,remapMaterials:s.remapMaterials,animationEvents:s.animationEvents??{},textureOptions:(l=n.assetOptions)==null?void 0:l.textureOptions,optimizeOptions:s.optimize},{resolveRef:r?o=>r.resolveRef(o):void 0,ktx2Encode:(o,u)=>us.encode(o,u)});return{name:i.name,content:new Blob([i.content],{type:"model/gltf-binary"})}}})],O);function Cr(e,t){const s=[];for(;e!==t;)s.unshift(e.siblingIndex),e=e.parent;return s}function Sr(e,t){let s=t;for(let n=0;n<e.length;n++)s=s.children[e[n]];return s}const Ur=Object.freeze(Object.defineProperty({__proto__:null,get GlTFAsset(){return O}},Symbol.toStringTag,{value:"Module"}));export{O as G,j as a,Ur as b};
@@ -0,0 +1,6 @@
1
+ import{aH as a}from"./index-1e23212d.js";/**
2
+ * @license @tabler/icons-react v3.17.0 - MIT
3
+ *
4
+ * This source code is licensed under the MIT license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */var e=a("outline","edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]);export{e as I};
@@ -1,4 +1,4 @@
1
- import{aC as e}from"./index-0a8702e2.js";/**
1
+ import{aG as e}from"./index-1e23212d.js";/**
2
2
  * @license @tabler/icons-react v3.24.0 - MIT
3
3
  *
4
4
  * This source code is licensed under the MIT license.
@@ -0,0 +1 @@
1
+ var m=Object.defineProperty;var u=(r,e,o)=>e in r?m(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var p=(r,e,o)=>(u(r,typeof e!="symbol"?e+"":e,o),o);import{a as n,s as y,aM as v,p as c,C as g,l as P,f as b,h as f,g as C,E as L,d as _}from"./index-1e23212d.js";import"./index-92830754.js";var x=Object.defineProperty,M=Object.getOwnPropertyDescriptor,h=(r,e,o,l)=>{for(var a=l>1?void 0:l?M(e,o):e,s=r.length-1,i;s>=0;s--)(i=r[s])&&(a=(l?i(e,o,a):i(a))||a);return l&&a&&x(e,o,a),a};const t=[n.Everything,n.Nothing];class d extends L{constructor(){super(...arguments);p(this,"color",{r:1,g:1,b:1,a:1,intensity:1});p(this,"cullingMask",_(n.Everything,t))}}h([y(v()),c({label:"light.color",type:g.Color,mode:"hdr",bindPath:"color"})],d.prototype,"color",2);h([y(P(t)),b(f(t)),c({label:"light.culling-mask",type:g.Select,...C(t),bindPath:"cullingMask"})],d.prototype,"cullingMask",2);export{d as L};
@@ -0,0 +1 @@
1
+ var f=Object.defineProperty;var c=(o,e,t)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(c(o,typeof e!="symbol"?e+"":e,t),t);import{L as g}from"./module-251ecc50.js";import{E as b,p as l,C as a,s}from"./index-1e23212d.js";import"./index-92830754.js";import{c as P}from"./Component-746be670.js";import"./postmen-9e1e15bd.js";var d=Object.defineProperty,L=Object.getOwnPropertyDescriptor,n=(o,e,t,y)=>{for(var i=y>1?void 0:y?L(e,t):e,u=o.length-1,m;u>=0;u--)(m=o[u])&&(i=(y?m(e,t,i):m(i))||i);return y&&i&&d(e,t,i),i};let r=class extends b{constructor(e,t){super(e,t);p(this,"resource",null);p(this,"autoPlay",!0);p(this,"isLooping",!0);p(this,"speed",1);p(this,"priority",0)}};n([l({label:"lottie.resource.label",info:"lottie.resource.info",type:a.AssetPicker,assetType:"Lottie",bindPath:"resource"}),s()],r.prototype,"resource",2);n([l({label:"lottie.auto-play.label",info:"lottie.auto-play.info",type:a.Toggle,bindPath:"autoPlay",onChange(o,e,t){t||o.engineObject.pause()}}),s()],r.prototype,"autoPlay",2);n([l({label:"lottie.is-looping.label",info:"lottie.is-looping.info",type:a.Toggle,bindPath:"isLooping"}),s()],r.prototype,"isLooping",2);n([l({label:"lottie.speed.label",info:"lottie.speed.info",type:a.Number,dragStep:.01,bindPath:"speed"}),s()],r.prototype,"speed",2);n([l({label:"lottie.priority.label",info:"lottie.priority.info",type:a.Number,bindPath:"priority"}),s()],r.prototype,"priority",2);r=n([P({type:"LottieAnimation",external:!0,componentsMenu:{group:"2D",label:"component.lottie-animation.title"}})],r);b.registerCustomEngineComponent("LottieAnimation",g);export{r as LottieAnimationComponent};
@@ -0,0 +1,6 @@
1
+ var H=Object.defineProperty;var K=(i,s,t)=>s in i?H(i,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[s]=t;var c=(i,s,t)=>(K(i,typeof s!="symbol"?s+"":s,t),t);import{aG as Y,j as E,n as q,aO as Z,aR as Q,aS as M,e5 as $,aQ as k,aU as D,aV as tt,aP as et,aX as st,dC as at,c7 as it,by as F,ce as L,u as ot,S as rt,x as P,aL as G,an as B,a0 as x,e as m,_ as nt,cb as V,p as v,C as _,a$ as O,o as lt,q as pt,cd as R}from"./index-1e23212d.js";import{L as J}from"./module-251ecc50.js";import{u as ct}from"./index-92830754.js";import"./postmen-9e1e15bd.js";import{c as mt}from"./SpriteAsset-4e895da5.js";import{A as ut}from"./AssetViewer-0ce46fa1.js";import{c as W,S as dt}from"./SpriteAtlasAsset-c2894c12.js";import{c as ht}from"./TextureAsset-93475ade.js";import"./meshopt_simplifier.module-cd99529d.js";import"./bundlers-9b0d37fc.js";import"./FormItemArray-a2f72cf1.js";import"./Accordion-930aedee.js";import"./IconEdit-2c768a0a.js";import"./enum-58295f88.js";import"./encode-ac4bb64e.js";import"./Tooltip-dfde37c6.js";import"./ktx2-encoder-075abd75.js";import"./TaskQueue-05c94a4d.js";/**
2
+ * @license @tabler/icons-react v3.24.0 - MIT
3
+ *
4
+ * This source code is licensed under the MIT license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */var ft=Y("outline","minus","IconMinus",[["path",{d:"M5 12l14 0",key:"svg-0"}]]),yt=Object.defineProperty,gt=Object.getOwnPropertyDescriptor,wt=(i,s,t,e)=>{for(var a=e>1?void 0:e?gt(s,t):s,o=i.length-1,r;o>=0;o--)(r=i[o])&&(a=(e?r(s,t,a):r(a))||a);return e&&a&&yt(s,t,a),a};let z=class extends E{initByMain(i,s){return Promise.resolve()}};z=wt([q({type:"LottieAnimation",async bundle(i){const s=JSON.parse(await i.content.text());return{content:new Blob([JSON.stringify(s)])}}})],z);const bt=Z("div",{display:"grid",columnGap:"$1",gridColumn:2/-1,gridTemplateColumns:"minmax(0, 4fr) repeat(1, 2fr) repeat(1, auto) repeat(1, 2fr) repeat(1, auto)",marginBottom:"$1"}),vt=function({clip:i,removeClip:s,onClipChange:t}){const{t:e}=Q();return M.jsxs(bt,{children:[M.jsx($,{size:"sm",value:i.name??"",placeholder:e("lottie.clip.name"),onChange:a=>{t({name:a.currentTarget.value})}}),M.jsx($,{size:"sm",value:i.start??"",placeholder:e("lottie.clip.start"),onChange:a=>{t({start:+a.currentTarget.value})}}),M.jsx(ft,{width:12,onClick:s}),M.jsx($,{size:"sm",value:i.end??"",placeholder:e("lottie.clip.end"),onChange:a=>{t({end:+a.currentTarget.value})}})]})},Mt=k(function(i){const s=i.model,t=s.getViewer(),{inspectorFacade:e}=ct(),{t:a}=Q(),[o,r]=D.useState(()=>Array.isArray(s.clips)?[...s.clips]:[]);D.useEffect(()=>{r(Array.isArray(s.clips)?[...s.clips]:[])},[s,s.clips]),D.useEffect(()=>{t==null||t.setClips(o)},[o,t]);const p=n=>{r(n),e.assetChange(s.id,"clips",n,"asset-meta")},l=()=>{p([...o,{}])},d=n=>{n<0||n>=o.length||p(o.filter((u,y)=>y!==n))},h=(n,u)=>{if(n<0||n>=o.length)return;const y={...o[n],...u},C=o.map((A,b)=>b===n?y:A);p(C)};return M.jsxs(tt,{title:a("lottie.clips.title"),defaultOpen:!0,collapsible:!0,children:[o.map((n,u)=>M.jsx(vt,{clip:n,removeClip:()=>d(u),onClipChange:y=>h(u,y)},`${s.id}-${u}`)),M.jsx(et,{align:"h",css:{margin:"0 auto",padding:"$1 0 0 0"},children:M.jsx(st,{size:"sm",variant:"soft",startSlot:M.jsx(at,{size:"14px"}),onClick:l,children:a("lottie.clips.add")})})]})});async function xt(i,s,t={}){try{const e=JSON.parse(i),{assets:a}=e,o=[];for(let p=0,l=a.length;p<l;p++){const d=a[p],{p:h}=d;h&&o.push({name:d.id,src:h})}const r=await mt(o,{width:2048,height:2048,...t});return r.code!==0?(console.log("Atlas Error:",r.msg),r):(e.assets=a.filter(p=>!p.p),r.info.jsonFile=JSON.stringify(e),r)}catch{return{code:11,msg:"Parse lottie file error"}}}async function _t(i){const s={uploadFiles:[],errors:[]};for(const t in i){const e=i[t],a=e.name;if(a.endsWith(".json"))try{const o=await e.text(),r=JSON.parse(o);St(r)&&s.uploadFiles.push({main:e})}catch(o){s.errors.push(X(a,o))}}return s}async function Ct(i,s,t){const e=it(i.main,"lottie.json"),a=await e.text();let o;try{o=JSON.parse(a)}catch(l){return console.error(l),F.error(X(e.name,l)),e}const{nm:r}=o,p=await xt(a);if(p.code===0)try{const{imageFiles:l,atlasFile:d,jsonFile:h}=p.info,n=JSON.parse(d),{atlasItems:u}=n,y=u.length,C=jt(),A=At(r,e.name),b=[];for(let g=0;g<y;++g)l[g]&&b.push(L.uploadBlob(`${A}-${C}-${g}.png`,new Blob([l[g]])));const U=await Promise.all(b);for(let g=0;g<y;++g)u[g].img=U[g].url;const[S,T]=await Promise.all([L.uploadBlob(`${A}-${C}.atlas`,new Blob([JSON.stringify(n)])),L.uploadBlob(`${A}-${C}.json`,new Blob([h]))]),N={jsonUrl:T.url,atlasUrl:S.url};return new File([JSON.stringify(N)],e.name)}catch(l){console.error(l),F.error(`parse lottie file fail ${l}`)}else console.error(p.msg),F.error(p.msg);return e}function St(i){return i.nm&&i.w&&i.h&&i.assets&&i.assets.length>0&&i.layers&&i.layers.length>0}function jt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2,10)}function At(i,s){const t=s.replace(/\.[^.]+$/,"")||"lottie";return(typeof i=="string"&&i.length>0?i:t).trim().replace(/[^\w.-]+/g,"_")||"lottie"}function X(i,s){const t=s instanceof Error?s.message:String(s);return`Failed to parse JSON file "${i}": ${t}`}var Ot=Object.defineProperty,It=Object.getOwnPropertyDescriptor,I=(i,s,t,e)=>{for(var a=e>1?void 0:e?It(s,t):s,o=i.length-1,r;o>=0;o--)(r=i[o])&&(a=(e?r(s,t,a):r(a))||a);return e&&a&&Ot(s,t,a),a};class j extends ut{constructor(){super();c(this,"lottie");c(this,"_updateComponent");c(this,"_lottieAsset");c(this,"playing",!1);c(this,"frameTime",0);c(this,"animationNames",[]);c(this,"animationIndex",0);c(this,"_hasClips",!1);ot(this)}get duration(){const{_lottieAsset:t}=this;return this._hasClips&&t.clips[this.animationIndex]?t.clips[this.animationIndex].end-t.clips[this.animationIndex].start:this._lottieAsset.duration}_setAnimationNames(t){this.animationNames=this._hasClips?t==null?void 0:t.map(e=>e.name):[this._lottieAsset.engineObject.name]}setViewAsset(t,e){const a=t.engineObject,o=e.createChild("lottie_entity"),r=o.addComponent(J);this._entity=o,this.lottie=r,r.resource=a,this._lottieAsset=t,this._hasClips=t.clips&&t.clips.length>0,this._setAnimationNames(t.clips),this.animationIndex=0;const p=this;this._updateComponent=this._entity.addComponent(class extends rt{onUpdate(l){p._onUpdate()}}),this.frameTime=0}getSize(){var t;if((t=this.lottie)!=null&&t.resource){const{width:e,height:a}=this.lottie.resource;return{width:e/100,height:a/100}}return{width:0,height:0}}stopViewAsset(){var t;super.stopViewAsset(),this.lottie=null,(t=this._updateComponent)==null||t.destroy(),this.animationNames=null}setClips(t){this.lottie.resource.setClips(t),this._setAnimationNames(t)}play(t){this.lottie.isLooping=!0,this.lottie.play(t),this.playing=!0}pauseAnimation(){this.lottie.pause(),this.playing=!1}selectAnimation(t){this.animationIndex=t;const e=this._lottieAsset.clips[t];this.play(e==null?void 0:e.name)}playAnimation(){const t=this._lottieAsset.clips[this.animationIndex];this.play(t==null?void 0:t.name)}setFrameTime(t){}_onUpdate(){this.playing&&(this.frameTime=this.lottie.frame)}}I([P],j.prototype,"playing",2);I([P],j.prototype,"frameTime",2);I([P],j.prototype,"animationNames",2);I([P],j.prototype,"animationIndex",2);I([G],j.prototype,"play",1);I([G],j.prototype,"pauseAnimation",1);I([G],j.prototype,"_onUpdate",1);var Ut=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,w=(i,s,t,e)=>{for(var a=e>1?void 0:e?Bt(s,t):s,o=i.length-1,r;o>=0;o--)(r=i[o])&&(a=(e?r(s,t,a):r(a))||a);return e&&a&&Ut(s,t,a),a};let f=class extends E{constructor(s){super(s);c(this,"textureSet",new Set);c(this,"width",0);c(this,"height",0);c(this,"duration",0);c(this,"inPoint",0);c(this,"outPoint",0);c(this,"clips",[]);c(this,"mipmap",!1);c(this,"colorDilate",!1);c(this,"filterMode",B.Bilinear);c(this,"wrapModeU",x.Repeat);c(this,"wrapModeV",x.Repeat);c(this,"runtimeOptions",{overwrite:!1,textureType:"ktx2",mode:"ETC1S",quality:150,isNormal:!1});this.formSchema.addGroup(m("lottie.asset.atlas-export"),["filterMode","wrapModeU","wrapModeV","mipmap","colorDilate"])}destroy(){super.destroy(),this.textureSet.clear(),this.textureSet=null}async initByUploadFile(s){return await this._initByUrl(this.engine,s),this}async initByMain(s){const{engine:t,meta:e}=this;e.runtimeOptions&&(this.runtimeOptions=e.runtimeOptions),this.clips=e.clips||[],this.filterMode=e.filterMode??this.filterMode,this.wrapModeU=e.wrapModeU??this.wrapModeU,this.wrapModeV=e.wrapModeV??this.wrapModeV,this.mipmap=e.mipmap??this.mipmap,this.colorDilate=e.colorDilate??this.colorDilate,await this._initByUrl(t,s);const a=new nt(this.engine),o=a.addComponent(J);o.resource=this.engineObject,this.setDragTempEntity(a)}instantiate(){const s=this.root.sceneStore.createEntity(),t=this.getDragTempEntity(),{position:e,rotation:a}=t.transform,o={components:[{class:"LottieAnimation",id:V(),props:{resource:this.getCurrentRef(),priority:0,defaultState:{}}}],id:s.id,isActive:!0,isClone:!1,name:this.name?this.name:"lottie",transform:{class:"Transform",props:{position:{x:e.x,y:e.y,z:e.z},rotation:{x:a.x,y:a.y,z:a.z},scale:{x:1,y:1,z:1}}}};return s.initByFile(o),s}async _createLottieResource(s,t,e){return(await s.resourceManager.load({urls:[t,e],type:"lottie"})).getComponent(J).resource}async _initByUrl(s,t){const e=JSON.parse(await t.text()),{jsonUrl:a,atlasUrl:o}=e,r=await this._createLottieResource(s,a,o);this.bindEngineObject(r);const{sprites:p}=r.atlas,{textureSet:l}=this;for(let d=0,h=p.length;d<h;++d){const n=p[d].texture;l.has(n)||(l.add(n),n.filterMode=this.filterMode,n.wrapModeU=this.wrapModeU,n.wrapModeV=this.wrapModeV)}return this.width=r.width,this.height=r.height,this.duration=r.duration,this.inPoint=r.inPoint,this.outPoint=r.outPoint,this}};w([v({type:_.Input,disabled:!0,label:m("lottie.asset.width")})],f.prototype,"width",2);w([v({type:_.Input,disabled:!0,label:m("lottie.asset.height")})],f.prototype,"height",2);w([v({type:_.Input,disabled:!0,label:m("lottie.asset.duration")})],f.prototype,"duration",2);w([v({type:_.Input,disabled:!0,label:m("lottie.asset.in-point")})],f.prototype,"inPoint",2);w([v({type:_.Input,disabled:!0,label:m("lottie.asset.out-point")})],f.prototype,"outPoint",2);w([v({disabled:!0,customComponent:Mt}),O()],f.prototype,"clips",2);w([v({label:m("lottie.asset.mipmap"),type:_.Toggle}),O()],f.prototype,"mipmap",2);w([v({label:m("lottie.asset.color-dilate"),type:_.Toggle}),O()],f.prototype,"colorDilate",2);w([v({label:m("lottie.asset.filter-mode.title"),type:_.Select,value:B.Bilinear,options:[{label:m("lottie.asset.filter-mode.point"),value:B.Point},{label:m("lottie.asset.filter-mode.bilinear"),value:B.Bilinear},{label:m("lottie.asset.filter-mode.trilinear"),value:B.Trilinear}],onChange(i,s,t){const{textureSet:e}=i;e.forEach(a=>{a.filterMode=t})}}),O()],f.prototype,"filterMode",2);w([v({label:m("lottie.asset.wrap-mode.u"),type:_.Select,value:x.Repeat,options:[{label:m("lottie.asset.wrap-mode.clamp"),value:x.Clamp},{label:m("lottie.asset.wrap-mode.repeat"),value:x.Repeat},{label:m("lottie.asset.wrap-mode.mirror"),value:x.Mirror}],onChange(i,s,t){const{textureSet:e}=i;e.forEach(a=>{a.wrapModeU=t})}}),O()],f.prototype,"wrapModeU",2);w([v({label:m("lottie.asset.wrap-mode.v"),type:_.Select,value:x.Repeat,options:[{label:m("lottie.asset.wrap-mode.clamp"),value:x.Clamp},{label:m("lottie.asset.wrap-mode.repeat"),value:x.Repeat},{label:m("lottie.asset.wrap-mode.mirror"),value:x.Mirror}],onChange(i,s,t){const{textureSet:e}=i;e.forEach(a=>{a.wrapModeV=t})}}),O()],f.prototype,"wrapModeV",2);w([P,O()],f.prototype,"runtimeOptions",2);f=w([q({type:"Lottie",label:m("asset.lottie.title"),loaderType:"EditorLottie",importMenuConfig:{type:lt.Upload,accept:".json"},viewer:j,filterUploadFiles:_t,preUpload:Ct,dragLayer:pt.Lottie,customInspector:ht,async bundle(i,s,t){var N,g;const e=JSON.parse(await i.content.text()),a=i.meta,{jsonUrl:o,atlasUrl:r}=e,p=R(i.name).split(".")[0],l=i.dependencies||(i.dependencies=[]),d=t.vfs,h=((N=l[0])==null?void 0:N.ref.refId)??V();let n;l[0]||(l[0]={key:"atlasUrl",ref:{refId:h}});let u=d.getFileById(h);u?n=u.meta:(n=W(h,E.getRegisteredAssetMeta(dt).type,s,{ignorePack:!0}),t.addFile({name:p+"_atlas.atlas",assetId:h,url:null,parentId:i.parentId,main:null,meta:n}),u=d.getFileById(h),u.ignoreBundle=!0),n.colorDilate=a.colorDilate,n.filterMode=a.filterMode,n.wrapModeU=a.wrapModeU,n.wrapModeV=a.wrapModeV,n.mipmap=a.mipmap;const y=i.meta.runtimeOptions;let C=s.assetOptions.textureOptions;y!=null&&y.overwrite&&(C=Object.assign({},C,y)),n.runtimeOptions=C;const A=await(await fetch(r)).json();t.updateFile(h,{main:new Blob([JSON.stringify(A)]),meta:n}),await t.bundleSingleFile(u,s),e.atlasUrl="./"+R(u.exportPath);const b=((g=l[1])==null?void 0:g.ref.refId)??V();let U;l[1]||(l[1]={key:"jsonUrl",ref:{refId:b}});let S=d.getFileById(b);S?U=S.meta:(U=W(b,E.getRegisteredAssetMeta(z).type,s),t.addFile({name:p+"_clip.json",assetId:b,url:null,parentId:i.parentId,main:null,meta:U}),S=d.getFileById(b),S.ignoreBundle=!0);const T=await(await fetch(o)).json();return T.lolitaAnimations=a.clips,t.updateFile(b,{main:new Blob([JSON.stringify(T)])}),await t.bundleSingleFile(S,s),e.jsonUrl="./"+R(S.exportPath),{content:new Blob([JSON.stringify(e)])}}})],f);export{f as LottieAsset};
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var u=(e,t,o)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var p=(e,t,o)=>(u(e,typeof t!="symbol"?t+"":t,o),o);import{j as d,u as m,w as b,x as h,n as w,e as f,o as y}from"./index-1e23212d.js";import"./index-92830754.js";import"./postmen-9e1e15bd.js";var v=Object.defineProperty,D=Object.getOwnPropertyDescriptor,l=(e,t,o,r)=>{for(var n=r>1?void 0:r?D(t,o):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(n=(r?a(t,o,n):a(n))||n);return r&&n&&v(t,o,n),n};let i=class extends d{constructor(t){super(t);p(this,"content","");m(this),this.onDoubleClick=this.onDoubleClick.bind(this)}async initByMain(t){this.content=await t.text()}async initByCreation(){return""}getMainData(){return this.content}onDoubleClick(){b(this.root.projectStore.id,this.id)}};l([h],i.prototype,"content",2);i=l([w({type:"Markdown",label:f("asset.markdown.title"),defaultName:"Document.md",extname:"md",importMenuConfig:{type:y.Add},bundle({content:e}){return{content:new Blob([e],{type:"text/markdown; charset=utf-8"})}}})],i);export{i as MarkdownAsset};
@@ -0,0 +1 @@
1
+ var z=Object.defineProperty;var K=(p,e,t)=>e in p?z(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t;var l=(p,e,t)=>(K(p,typeof e!="symbol"?e+"":e,t),t);import{O as V,bX as L,ct as k,cu as G,N as Q,K as H,V as U,B as q,cv as f,j as J,q as N,cw as v,I as M,u as W,cx as x,J as I,ab as b,ac as O,cy as Y,C as P,cz as E,cA as X,z as S,cr as Z,e as w,bQ as ee,_ as te,ao as ae,ap as re,H as B,a8 as se,Q as ne,x as $,aL as m,n as ie,o as oe}from"./index-1e23212d.js";import"./index-92830754.js";import{M as he}from"./MaterialInspector-a36197f2.js";import{A as pe}from"./AssetViewer-0ce46fa1.js";import{E as y,s as F,b as C}from"./ProxyConfigs-ad92ebc7.js";async function de(p){var e;if(p.shaderRef)try{const t=await p.assetStore.getAssetByRef(p.shaderRef);if(!t||t===p.nextShaderAsset)return;(e=t.removeReferencedMaterial)==null||e.call(t,p.material)}catch{}}class ce extends pe{constructor(){super(...arguments);l(this,"_sphereRenderer",null);l(this,"_particleRenderer",null);l(this,"_asset",null);l(this,"_shaderReactionDisposer",null);l(this,"onShaderChange",()=>{const{_asset:t}=this;t.engineObject.shader.name==="particle-shader"?(this._particleRenderer.entity.isActive=!0,this._sphereRenderer.entity.isActive=!1,this._particleRenderer.setMaterial(t.engineObject)):(this._particleRenderer.entity.isActive=!1,this._sphereRenderer.entity.isActive=!0,this._sphereRenderer.setMaterial(t.engineObject))})}setViewAsset(t,a){if(!(t instanceof u))return;const n=a.createChild("material");this._asset=t;const r=this._sphereRenderer=n.createChild("mat").addComponent(V);r.mesh=L.createSphere(a.engine,1,32,!0);const o=this._particleRenderer=n.createChild("pat").addComponent(k);o.generator.main.duration=1e3,o.generator.main.startSpeed.constant=0,this._entity=n,a.addChild(this._entity),this.onShaderChange(),this._shaderReactionDisposer=G(()=>{var i,d;return(d=(i=this._asset)==null?void 0:i.shaderRef)==null?void 0:d.refId},()=>{this.onShaderChange()})}stopViewAsset(){var t;super.stopViewAsset(),(t=this._shaderReactionDisposer)==null||t.call(this),this._shaderReactionDisposer=null,this._asset=null}}class D{static update(e,t){if(!(t instanceof u))return;const a=t.engineObject;if(!a||!a.shader){this.entity&&this.sphereRenderer&&this.particleRenderer&&this.clear();return}this.entity?this.entity.isActive=!0:this.initScene(e),a.shader.name==="particle-shader"?(this.sphereRenderer.entity.isActive=!1,this.particleRenderer.entity.isActive=!0,this.particleRenderer.setMaterial(a),this.particleRenderer.generator._playTime=5):(this.particleRenderer.entity.isActive=!1,this.sphereRenderer.entity.isActive=!0,this.sphereRenderer.setMaterial(a))}static clear(){var e,t;(e=this.sphereRenderer)!=null&&e.entity&&(this.sphereRenderer.entity.isActive=!1),(t=this.particleRenderer)!=null&&t.entity&&(this.particleRenderer.entity.isActive=!1),this.entity&&(this.entity.isActive=!1)}static initScene(e){const t=this.entity=e.createChild("material"),a=this.sphereRenderer=t.createChild("mat").addComponent(V);a.mesh=L.createSphere(e.engine,2,64,!0),this.particleRenderer=t.createChild("pat").addComponent(k),this.particleRenderer.bounds.max.set(.5,.5,.5),this.particleRenderer.bounds.min.set(-.5,-.5,-.5)}}l(D,"entity",null),l(D,"sphereRenderer",null),l(D,"particleRenderer",null);function j(p){return p instanceof Q?{x:p.x,y:p.y}:p instanceof H?{x:p.x,y:p.y,z:p.z}:p instanceof U?{x:p.x,y:p.y,z:p.z,w:p.w}:p instanceof q?{r:p.r,g:p.g,b:p.b,a:p.a}:p}function le(p){switch(p){case f.Color:return"Color";case f.Float:return"Float";case f.Int:return"Integer";case f.Matrix:return"Matrix";case f.Texture:return"Texture";case f.TextureArray:return"TextureArray";case f.Vector2:return"Vector2";case f.Vector3:return"Vector3";case f.Vector4:return"Vector4"}}var ue=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,g=(p,e,t,a)=>{for(var n=a>1?void 0:a?fe(e,t):e,r=p.length-1,o;r>=0;r--)(o=p[r])&&(n=(a?o(e,t,n):o(n))||n);return a&&n&&ue(e,t,n),n};let u=class extends J{constructor(e){super(e);l(this,"acceptDragLayer",N.Texture);l(this,"shaderRef",{refId:null});l(this,"shaderDataKeys",new Set);l(this,"formConfig",null);l(this,"_autoSaveSuppressed",!1);W(this),x(this,{proxyConfigs:[]})}static initBuiltinMaterial(e,t){e.shader=t;const a=e.shaderData;switch(a.disableMacro("MATERIAL_NEED_WORLD_POS"),a.disableMacro("MATERIAL_OMIT_NORMAL"),a.disableMacro("MATERIAL_NEED_TILING_OFFSET"),a.disableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.renderState.depthState.compareFunction=v.Less,t.name){case"unlit":a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"pbr-specular":case"pbr":case"bake-pbr":case"blinn-phong":a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"skybox":e.renderState.rasterState.cullMode=M.Off,e.renderState.depthState.compareFunction=v.LessEqual;break;case"SkyProcedural":a.enableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.renderState.rasterState.cullMode=M.Off,e.renderState.depthState.compareFunction=v.LessEqual;break;case"particle-shader":a.enableMacro("MATERIAL_OMIT_NORMAL");break}}setAutoSaveSuppressed(e){this._autoSaveSuppressed=e}setRenderQueueType(e){this.engineObject.renderState.renderQueueType=e}setBlendStateEnabled(e){this.engineObject.renderState.blendState.targetBlendState.enabled=e}setDepthWriteEnabled(e){this.engineObject.renderState.depthState.writeEnabled=e}setCullMode(e){this.engineObject.renderState.rasterState.cullMode=e}setBlendMode(e){const t=this.engineObject.renderState.blendState.targetBlendState;switch(e){case I.Normal:t.sourceColorBlendFactor=b.SourceAlpha,t.destinationColorBlendFactor=b.OneMinusSourceAlpha,t.sourceAlphaBlendFactor=b.One,t.destinationAlphaBlendFactor=b.OneMinusSourceAlpha,t.colorBlendOperation=O.Add,t.alphaBlendOperation=O.Add;break;case I.Additive:t.sourceColorBlendFactor=b.SourceAlpha,t.destinationColorBlendFactor=b.One,t.sourceAlphaBlendFactor=b.One,t.destinationAlphaBlendFactor=b.OneMinusSourceAlpha,t.colorBlendOperation=O.Add,t.alphaBlendOperation=O.Add;break}}bindShaderAsset(e,t){for(const a of this.shaderDataKeys)this.removePropertyChangeListener(a);return this.shaderDataKeys.clear(),e.onReady().then(async()=>{var n;if(e.shaderScriptRefId){const r=this.root.assetStore.assets[e.shaderScriptRefId.refId];this.isInitCompleted&&(r==null||r.onShaderChange(this._engineObject),t=this._getMainData())}const a=e.properties?Y(e.properties):[];e.isBuiltinShader()&&u.initBuiltinMaterial(this.engineObject,e.engineObject),t=t||this._getMainData(),await this._proxyShaderProps(a,t,this.isInitCompleted),this.refreshFormConfig(a,t),this.refreshAnimatableProperties(a),de({assetStore:this.root.assetStore,shaderRef:this.shaderRef,nextShaderAsset:e,material:this}),e.addReferencedMaterial(this),this.shaderRef={refId:e.id},await this.applyBoundPathChange("shader",P.AssetPicker,this.shaderRef),(n=this.updateThumbnail)==null||n.call(this)})}async _proxyShaderProps(e,t,a=!0){var o;this.proxyConfigs=e;const n=(o=this.extraData)==null?void 0:o.disabledMacros,r=e.map(async i=>{var d;if(this.proxySetter(i),this._virualShaderProps(e),i.bundleType==="macro"){const s=i.macroInfo,h=t.macros.find(c=>c.name===i.prop);if(!E(this,i.prop)){let c;h!=null?(c=h.value,s&&(s.checked=!0)):n!=null&&n.includes(i.prop)?(c=void 0,s&&(s.checked=!1)):c=i.defaultValue,x(this,{[i.prop]:c})}if(a)if(h){const c=h.value??i.defaultValue;c==null?s==null||s.onSwitch(!0,this):await i.onChange(this,i.prop,c)}else!(n!=null&&n.includes(i.prop))&&(s!=null&&s.checked)&&(s==null||s.onSwitch(!0,this))}else{const s=t.shaderData[i.prop];let h=s?s.value:this[i.prop]??i.defaultValue;if(h!=null&&h.refId&&!this.root.assetStore.assets[h.refId]&&(h=void 0),((d=i.uiInfo)==null?void 0:d.type)===y.Color)if(i.uiInfo.mode==="hdr"){const c=h.intensity??1;c!==0&&(h.r/=c,h.g/=c,h.b/=c),h.intensity=c}else h.intensity=1;E(this,i.prop)||x(this,{[i.prop]:h}),a&&this.notifyPropertyChange(i.prop,!1)}});await Promise.all(r)}proxySetter(e){const{prop:t,onChange:a,bundleType:n}=e,r=async(o,i)=>{var s;const d=this._engineObject.shaderData;n==="macro"?d.enableMacro(t,o):await F(this,t,o,e.engineType??((s=e.uiInfo)==null?void 0:s.type)),await a(this,t,o),i!==!1&&!this._autoSaveSuppressed&&(await this.root.assetFacade.persistAssetMain(this.id),this.updateThumbnail())};this.addPropertyChangeListener(t,r),this.shaderDataKeys.add(t)}_virualShaderProps(e){const t=this;e.forEach(a=>{X(t,a.prop)})}refreshFormConfig(e,t){var n,r,o,i,d;const a={root:[],groups:{}};if(t){for(const s of e)if(!((n=s.uiInfo)!=null&&n.hide)){if((r=s.uiInfo)!=null&&r.group){if((o=s.uiInfo)!=null&&o.group){let h=a.groups[s.uiInfo.group];h||(h={type:P.Group,property:s.uiInfo.group,children:[]},a.groups[s.uiInfo.group]=h);const c=s.uiInfo;c.property=s.prop,s.macroInfo&&(c.macroConfig=s.macroInfo),h.children.push(c)}}else{const h=s.uiInfo;h.property=s.prop,s.macroInfo&&(h.macroConfig=s.macroInfo),a.root.push(h)}s.bundleType==="macro"?this[s.prop]=((i=t.macros.find(h=>h.name===s.prop))==null?void 0:i.value)??s.defaultValue:this[s.prop]=((d=t.shaderData[s.prop])==null?void 0:d.value)??s.defaultValue}}this.formConfig=a}refreshAnimatableProperties(e){var t,a,n;this._additionAnimatableProperties.length=0;for(const r of e){if(!r.uiInfo||r.uiInfo.hide||r.bundleType==="macro")continue;let o={};if((r.setPath||r.getPath||r.valueType||r.interpolationType)&&(o={setPath:r.setPath,getPath:r.getPath,valueType:r.valueType,interpolationType:r.interpolationType}),!o.setPath&&!o.getPath&&r.engineType&&(r.bundleType==="shaderData"||!r.bundleType))switch(r.engineType){case y.Float:o={setPath:`shaderData.setFloat('${r.prop}', $value)`,getPath:`shaderData.getFloat('${r.prop}')`,valueType:S.Float};break;case y.Integer:o={setPath:`shaderData.setInt('${r.prop}', $value)`,getPath:`shaderData.getInt('${r.prop}')`,valueType:S.Float,interpolationType:Z.Step};break;case y.Vector2:o={setPath:`shaderData.getVector2('${r.prop}')`,getPath:`shaderData.getVector2('${r.prop}')`,valueType:S.Vector2};break;case y.Vector3:o={setPath:`shaderData.getVector3('${r.prop}')`,getPath:`shaderData.getVector3('${r.prop}')`,valueType:S.Vector3};break;case y.Vector4:o={setPath:`shaderData.getVector4('${r.prop}')`,getPath:`shaderData.getVector4('${r.prop}')`,valueType:S.Vector4};break;case y.Color:o={setPath:`shaderData.getColor('${r.prop}')`,getPath:`shaderData.getColor('${r.prop}')`,valueType:S.Color};break;case y.Boolean:o={setPath:`shaderData.setBoolean('${r.prop}', $value)`,getPath:`shaderData.getBoolean('${r.prop}')`,valueType:S.Boolean};break;case y.Texture:o={setPath:`shaderData.setTexture('${r.prop}', $value)`,getPath:`shaderData.getTexture('${r.prop}')`,valueType:S.ReferResource};break}if(!o.setPath&&!o.getPath){if(r.bundleType==="other")continue;continue}this._additionAnimatableProperties.push({property:r.prop,label:(t=r.uiInfo)!=null&&t.label?w(r.uiInfo.label):r.prop,type:(a=r.uiInfo)==null?void 0:a.type,propertyProxyConfig:o}),(n=r.uiInfo)!=null&&n.label&&(o.label=w(r.uiInfo.label)),ee(this,r.prop,o)}}async initByMain(e){var c;const t=JSON.parse(await e.text());this.shaderRef=t.shaderRef;const a=t.shaderData,n=t.macros,r=t.renderState;if(!t.shaderRef)throw"invalid material";const o=new te(this.engine);this.setDragTempEntity(o);const i=await this.root.assetStore.getAssetByRef(t.shaderRef),d=i.engineObject??ae.find("unlit"),s=new re(this.engine,d);this.bindEngineObject(s);const h=s.shaderData;if(n)for(const R of n)h.enableMacro(R.name,R.value);if(a)for(const R in a){const _=a[R];let A=_.value;if(_.type===y.Color){A={..._.value};const T=_.value.intensity??1;T!==0&&(A.r/=T,A.g/=T,A.b/=T)}F(this,R,A,_.type)}r&&this._parseProperty(s,"renderState",r),await this.bindShaderAsset(i,t),(c=this.updateThumbnail)==null||c.call(this),await this.applyBoundPathChange("name",P.Input,this.name),this._checkSchemaOnInit(t,i)}_checkSchemaOnInit(e,t){e.shader!==t.engineObject.name&&this.root.assetFacade.persistAssetMain(this.id)}initByEngineObject(e){const t=this;this.bindEngineObject(e),t.shader=e.shader.name,t._name=e.name??"";const n=Object.values(this.root.assetStore.assets).filter(d=>d.meta.type==="Shader"&&!!d.meta.builtinShaderName).find(d=>d.meta.builtinShaderName===e.shader.name);switch(this.shaderRef={refId:n.id},t.isTransparent=e.renderState.blendState.targetBlendState.enabled,t.alphaCutoff=e.shaderData.getFloat("material_AlphaCutoff"),e.renderState.rasterState.cullMode){case M.Back:t.renderFace=B.Front;break;case M.Front:t.renderFace=B.Back;break;case M.Off:t.renderFace=B.Double;break}t.blendMode=e.renderState.blendState.targetBlendState.destinationColorBlendFactor===b.One?I.Additive:I.Normal;const r=e.shaderData;r.getProperties().forEach(d=>{const s=r.getPropertyValue(d);if(s instanceof se){const h=this.root.assetStore.engineObjectToAssetMap.get(s);this[d.name]=h==null?void 0:h.getCurrentRef()}else this[d.name]=j(s)});const i=this._getMainData();this._proxyShaderProps(C,i,!1),this.bindShaderAsset(n,i)}afterDelete(){var e;(e=this.engineObject)==null||e.destroy(!0)}rename(e){return this.root.assetFacade.persistAssetMain(this.id),super.rename(e)}_getMainData(e){var i,d;const t=[],a=(e??this.engineObject).shaderData;a.getMacros(t);const n=t.map(({name:s,value:h})=>h===void 0?{name:s}:{name:s,value:h}),r=[],o={};a.getProperties(r);for(const s of r){let h;if(s.type===f.Texture||s.type===f.TextureArray)h=this[s.name];else{const c=a.getPropertyValue(s);h=j(c),((i=this[s.name])==null?void 0:i.intensity)!=null&&(h.intensity=(d=this[s.name])==null?void 0:d.intensity)}h!=null&&(o[s.name]={type:le(s.type),value:h})}return{name:this.name,shader:this.engineObject.shader.name,macros:n,renderState:this.engineObject.renderState,shaderData:o,shaderRef:this.shaderRef}}getMainData(){return JSON.stringify(this._getMainData())}async initByCreation(){var o;const e=new ne(this.engine),t=[];e.shaderData.getMacros(t);const a=t.map(({name:i,value:d})=>d===void 0?{name:i}:{name:i,value:d});this.bindEngineObject(e);const n={};for(const i of C)i.defaultValue&&(n[i.prop]={value:i.defaultValue,type:i.engineType??((o=i.uiInfo)==null?void 0:o.type)});const r={shaderData:n,shaderRef:{refId:"0000501"},name:this.name,shader:e.shader.name,macros:a,renderState:e.renderState};return this._proxyShaderProps(C,r,!1),r}async onSubAssetEdit(){var n;const e=await this.root.assetFacade.createAssetByAdd({assetType:"Material",name:`${this._name}-copied`});this.engineObject.cloneTo(e.engineObject),await e.applyBoundPathChange("name",P.Input,e.name),e.initByEngineObject(e.engineObject),e.updateThumbnail(),await this.root.assetFacade.persistAssetMain(e.id);const t=await this.root.assetStore.getAssetByRef({refId:this.mainId}),a=((n=t.engineObject.materials)==null?void 0:n.indexOf(this._engineObject))??-1;a>=0&&await t.replaceMaterial(a,e.getCurrentRef()),this.root.assetStore.selectAsset(e.id)}saveMainImmediately(){return!this.engineObject||!this.engineObject.shaderData?Promise.resolve(void 0):(this.root.projectStore.setSyncStatus("syncing"),super.saveMainImmediately().then(e=>(e&&this.root.projectStore.setSyncStatus("success"),e)).catch(e=>{throw this.root.projectStore.setSyncStatus("error"),e}))}_parseProperty(e,t,a){if(typeof a=="object")for(const n in a)this._parseProperty(e[t],n,a[n]);else e[t]=a}async _onDrop(e,t){const a="material_BaseTexture";if(a in this){const n=t.getCurrentRef();this[a]=n;const r=C.find(o=>o.prop===a);r&&await r.onChange(this,a,n),await this.root.assetFacade.persistAssetMain(this.id)}this.dropping=!1}async onDropToViewport(){const{sceneStore:e,sceneUIStore:t}=this.root,a=t.hoveredEntityId;if(a){const n=e.entities.get(a);if(n){const r=n.getComponentByTypeName("MeshRenderer"),o=n.getComponentByTypeName("SkinnedMeshRenderer"),i=r||o;i&&this.root.componentFacade.updateComponent(n.id,i.id,{material:this.getCurrentRef()})}}this.root.projectStore.currentViewport.viewport.onDrop()}};g([$],u.prototype,"shaderRef",2);g([$.ref],u.prototype,"formConfig",2);g([m],u.prototype,"bindShaderAsset",1);g([m],u.prototype,"_proxyShaderProps",1);g([m],u.prototype,"proxySetter",1);g([m],u.prototype,"_virualShaderProps",1);g([m],u.prototype,"refreshAnimatableProperties",1);g([m],u.prototype,"_onDrop",1);u=g([ie({type:"Material",label:w("asset.material.title"),loaderType:"Material",extname:"mat",importMenuConfig:{type:oe.Add},customInspector:he,viewer:ce,thumbnail:D,dragLayer:N.Material})],u);const _e=Object.freeze(Object.defineProperty({__proto__:null,get MaterialAsset(){return u}},Symbol.toStringTag,{value:"Module"}));export{u as M,ce as a,_e as b};