@cesium/engine 19.0.0 → 20.0.1

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 (135) hide show
  1. package/Build/ThirdParty/Workers/pako_deflate.min.js +3 -3
  2. package/Build/ThirdParty/Workers/pako_inflate.min.js +3 -3
  3. package/Build/ThirdParty/Workers/z-worker-pako.js +49 -42
  4. package/Build/Workers/{chunk-ECWQXDZY.js → chunk-2K5PKWLP.js} +16 -16
  5. package/Build/Workers/{chunk-T7C73J6H.js → chunk-2MEON5V4.js} +4 -4
  6. package/Build/Workers/{chunk-AZPKFL5X.js → chunk-4MCKK5XE.js} +5 -5
  7. package/Build/Workers/{chunk-Q2QXUN33.js → chunk-4Z7AGRTU.js} +2 -2
  8. package/Build/Workers/{chunk-SOYVF5RC.js → chunk-7FEVXX5D.js} +2 -2
  9. package/Build/Workers/{chunk-RIQM3XY5.js → chunk-7MCEUVPM.js} +4 -4
  10. package/Build/Workers/{chunk-25USKS4R.js → chunk-7P7R7ERW.js} +6 -6
  11. package/Build/Workers/{chunk-MUL374P3.js → chunk-CTU7LCVZ.js} +4 -4
  12. package/Build/Workers/{chunk-DPFAUGBE.js → chunk-CZGSJ6ZG.js} +2 -2
  13. package/Build/Workers/{chunk-ESDVZ4QL.js → chunk-D4VFVSGU.js} +10 -10
  14. package/Build/Workers/{chunk-JZVUMRYA.js → chunk-DAGWF5MM.js} +13 -13
  15. package/Build/Workers/{chunk-VCCR35R6.js → chunk-DAZVD3AH.js} +11 -11
  16. package/Build/Workers/{chunk-GVO3YIU2.js → chunk-DJCPJJSP.js} +4 -4
  17. package/Build/Workers/{chunk-DXYAD4ED.js → chunk-DNMSVJ4S.js} +1 -1
  18. package/Build/Workers/{chunk-Y3PM6G2V.js → chunk-E2533KCN.js} +3 -3
  19. package/Build/Workers/{chunk-RZJA77TX.js → chunk-ECGKCTPM.js} +6 -6
  20. package/Build/Workers/{chunk-PAH73ETP.js → chunk-HKHD5FDM.js} +5 -5
  21. package/Build/Workers/{chunk-6T2PQKYP.js → chunk-HSVZWLJD.js} +4 -4
  22. package/Build/Workers/{chunk-IE2BEHLE.js → chunk-HZ22ZI3Q.js} +12 -12
  23. package/Build/Workers/{chunk-SO2Z6H6F.js → chunk-IQKHPQNT.js} +2 -2
  24. package/Build/Workers/{chunk-SVGHDIZG.js → chunk-JHTZDMN6.js} +5 -5
  25. package/Build/Workers/{chunk-ETCPCGKC.js → chunk-JIXKGUWR.js} +2 -2
  26. package/Build/Workers/{chunk-DNCRKMCI.js → chunk-JVNWWKXF.js} +6 -6
  27. package/Build/Workers/{chunk-AABNX23Q.js → chunk-L7PWWHKM.js} +5 -5
  28. package/Build/Workers/{chunk-SXMHGVZ7.js → chunk-LF74EILW.js} +12 -12
  29. package/Build/Workers/{chunk-23FRF5ZP.js → chunk-LHZKPI55.js} +9 -9
  30. package/Build/Workers/{chunk-E6NMEKSS.js → chunk-LSYTMSIQ.js} +5 -4
  31. package/Build/Workers/{chunk-GO3IRH6U.js → chunk-LYKXQPGW.js} +6 -6
  32. package/Build/Workers/{chunk-MBDKO456.js → chunk-LZZA3PAR.js} +5 -5
  33. package/Build/Workers/{chunk-34DFERFC.js → chunk-M4FSVD3C.js} +12 -12
  34. package/Build/Workers/{chunk-NMAT4IJ6.js → chunk-O4DA3KRB.js} +7 -7
  35. package/Build/Workers/{chunk-HHHBRTSW.js → chunk-O7KDJVRH.js} +9 -9
  36. package/Build/Workers/{chunk-XUYCCEG6.js → chunk-OWV4L2GH.js} +5 -5
  37. package/Build/Workers/{chunk-ZNEIUXBK.js → chunk-OYFINQQA.js} +7 -7
  38. package/Build/Workers/{chunk-4QWLEG4L.js → chunk-PFUF2QIK.js} +14 -14
  39. package/Build/Workers/{chunk-37IYBZDZ.js → chunk-QFMJIXCL.js} +9 -9
  40. package/Build/Workers/{chunk-5VPO47LB.js → chunk-QWHUQ4B7.js} +8 -8
  41. package/Build/Workers/{chunk-KTDHOEXR.js → chunk-RB3XS7EZ.js} +1 -1
  42. package/Build/Workers/{chunk-HJ6KFRM7.js → chunk-RP4KKY2E.js} +16 -16
  43. package/Build/Workers/{chunk-Y6LLFNXN.js → chunk-SLPWFCXZ.js} +10 -10
  44. package/Build/Workers/{chunk-WUMTX3FI.js → chunk-UUXKGCBU.js} +8 -8
  45. package/Build/Workers/{chunk-EV4PBU7O.js → chunk-UXIZVXIR.js} +1 -1
  46. package/Build/Workers/{chunk-YPNIIVIF.js → chunk-V65LOTF3.js} +6 -6
  47. package/Build/Workers/{chunk-K5VGMGFM.js → chunk-VQLQAENU.js} +7 -7
  48. package/Build/Workers/{chunk-W32QSECR.js → chunk-WJ5THCIZ.js} +6 -6
  49. package/Build/Workers/{chunk-4NRFVAG2.js → chunk-WNEY4A5P.js} +5 -5
  50. package/Build/Workers/{chunk-UPU755HO.js → chunk-XMIVNU5H.js} +12 -12
  51. package/Build/Workers/{chunk-5YCDPN3O.js → chunk-YNRRVRHO.js} +1 -1
  52. package/Build/Workers/{chunk-NKM2EV46.js → chunk-YVAOKOKX.js} +1 -1
  53. package/Build/Workers/{chunk-FQNSMOZT.js → chunk-YW2UXIBU.js} +4 -4
  54. package/Build/Workers/{chunk-DAHXCIOX.js → chunk-ZBLPNAYB.js} +8 -8
  55. package/Build/Workers/{chunk-C36VNKTH.js → chunk-ZJGO7T2S.js} +4 -4
  56. package/Build/Workers/combineGeometry.js +21 -21
  57. package/Build/Workers/createBoxGeometry.js +15 -15
  58. package/Build/Workers/createBoxOutlineGeometry.js +13 -13
  59. package/Build/Workers/createCircleGeometry.js +23 -23
  60. package/Build/Workers/createCircleOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
  62. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
  63. package/Build/Workers/createCorridorGeometry.js +26 -26
  64. package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
  65. package/Build/Workers/createCylinderGeometry.js +17 -17
  66. package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
  67. package/Build/Workers/createEllipseGeometry.js +23 -23
  68. package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
  69. package/Build/Workers/createEllipsoidGeometry.js +16 -16
  70. package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
  71. package/Build/Workers/createFrustumGeometry.js +15 -15
  72. package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
  73. package/Build/Workers/createGeometry.js +21 -21
  74. package/Build/Workers/createGroundPolylineGeometry.js +19 -19
  75. package/Build/Workers/createPlaneGeometry.js +13 -13
  76. package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
  77. package/Build/Workers/createPolygonGeometry.js +29 -29
  78. package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
  79. package/Build/Workers/createPolylineGeometry.js +22 -22
  80. package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
  81. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
  82. package/Build/Workers/createRectangleGeometry.js +24 -24
  83. package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
  84. package/Build/Workers/createSimplePolylineGeometry.js +20 -20
  85. package/Build/Workers/createSphereGeometry.js +16 -16
  86. package/Build/Workers/createSphereOutlineGeometry.js +15 -15
  87. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  88. package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
  89. package/Build/Workers/createVectorTileGeometries.js +21 -21
  90. package/Build/Workers/createVectorTilePoints.js +11 -11
  91. package/Build/Workers/createVectorTilePolygons.js +19 -19
  92. package/Build/Workers/createVectorTilePolylines.js +12 -12
  93. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
  94. package/Build/Workers/createVerticesFromHeightmap.js +25 -25
  95. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
  96. package/Build/Workers/createWallGeometry.js +21 -21
  97. package/Build/Workers/createWallOutlineGeometry.js +20 -20
  98. package/Build/Workers/decodeDraco.js +10 -10
  99. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  100. package/Build/Workers/decodeI3S.js +9 -9
  101. package/Build/Workers/gaussianSplatSorter.js +4 -4
  102. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  103. package/Build/Workers/transcodeKTX2.js +17 -16
  104. package/Build/Workers/transferTypedArrayTest.js +1 -1
  105. package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
  106. package/Source/Core/Ellipsoid.js +9 -0
  107. package/Source/Core/Ion.js +1 -1
  108. package/Source/Core/IonResource.js +14 -8
  109. package/Source/Scene/ArcGisMapService.js +1 -1
  110. package/Source/Scene/BingMapsImageryProvider.js +1 -1
  111. package/Source/Scene/Cesium3DTileContentFactory.js +7 -16
  112. package/Source/Scene/Cesium3DTileset.js +1 -1
  113. package/Source/Scene/GaussianSplat3DTileContent.js +253 -9
  114. package/Source/Scene/GaussianSplatPrimitive.js +167 -15
  115. package/Source/Scene/GltfLoader.js +20 -2
  116. package/Source/Scene/GltfVertexBufferLoader.js +56 -2
  117. package/Source/Scene/ITwinData.js +37 -76
  118. package/Source/Scene/Model/Model.js +3 -0
  119. package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +8 -2
  120. package/Source/Scene/Model/ModelUtility.js +1 -0
  121. package/Source/Scene/Model/PntsLoader.js +7 -3
  122. package/Source/Scene/PntsParser.js +6 -3
  123. package/Source/Scene/PrimitiveLoadPlan.js +1 -1
  124. package/Source/Scene/VertexAttributeSemantic.js +4 -2
  125. package/Source/Scene/WebMapServiceImageryProvider.js +3 -2
  126. package/Source/Scene/WebMapTileServiceImageryProvider.js +0 -22
  127. package/Source/Scene/getMeshPrimitives.js +72 -0
  128. package/Source/Shaders/PrimitiveGaussianSplatFS.glsl +5 -5
  129. package/Source/Shaders/PrimitiveGaussianSplatFS.js +5 -5
  130. package/Source/Shaders/PrimitiveGaussianSplatVS.glsl +102 -5
  131. package/Source/Shaders/PrimitiveGaussianSplatVS.js +102 -5
  132. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  133. package/index.d.ts +109 -1
  134. package/index.js +245 -244
  135. package/package.json +3 -3
@@ -90,6 +90,9 @@ PntsParser.parse = function (arrayBuffer, byteOffset) {
90
90
  byteOffset,
91
91
  batchTableJsonByteLength,
92
92
  );
93
+ if (Object.keys(batchTableJson).length === 0) {
94
+ batchTableJson = undefined;
95
+ }
93
96
  byteOffset += batchTableJsonByteLength;
94
97
 
95
98
  if (batchTableBinaryByteLength > 0) {
@@ -99,6 +102,8 @@ PntsParser.parse = function (arrayBuffer, byteOffset) {
99
102
  byteOffset,
100
103
  batchTableBinaryByteLength,
101
104
  );
105
+ // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed
106
+ batchTableBinary = new Uint8Array(batchTableBinary);
102
107
  byteOffset += batchTableBinaryByteLength;
103
108
  }
104
109
  }
@@ -175,9 +180,7 @@ PntsParser.parse = function (arrayBuffer, byteOffset) {
175
180
  parsedContent.batchLength = batchLength;
176
181
  }
177
182
 
178
- if (defined(batchTableBinary)) {
179
- // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed
180
- batchTableBinary = new Uint8Array(batchTableBinary);
183
+ if (defined(batchTableJson) || defined(batchTableBinary)) {
181
184
  parsedContent.batchTableJson = batchTableJson;
182
185
  parsedContent.batchTableBinary = batchTableBinary;
183
186
  }
@@ -160,7 +160,7 @@ function PrimitiveLoadPlan(primitive) {
160
160
 
161
161
  /**
162
162
  * Set this true to indicate that the primitive has the
163
- * KHR_gaussian_splatting extension and needs to be post-processed
163
+ * KHR_gaussian_splatting and KHR_gaussian_splatting_compression_spz_2 extension and needs to be post-processed
164
164
  *
165
165
  * @type {boolean}
166
166
  * @private
@@ -79,14 +79,14 @@ const VertexAttributeSemantic = {
79
79
  * @type {string}
80
80
  * @constant
81
81
  */
82
- SCALE: "_SCALE",
82
+ SCALE: "KHR_gaussian_splatting:SCALE",
83
83
  /**
84
84
  * Gaussian Splat Rotation
85
85
  *
86
86
  * @type {string}
87
87
  * @constant
88
88
  */
89
- ROTATION: "_ROTATION",
89
+ ROTATION: "KHR_gaussian_splatting:ROTATION",
90
90
  };
91
91
 
92
92
  function semanticToVariableName(semantic) {
@@ -192,8 +192,10 @@ VertexAttributeSemantic.fromGltfSemantic = function (gltfSemantic) {
192
192
  return VertexAttributeSemantic.WEIGHTS;
193
193
  case "_FEATURE_ID":
194
194
  return VertexAttributeSemantic.FEATURE_ID;
195
+ case "KHR_gaussian_splatting:SCALE":
195
196
  case "_SCALE":
196
197
  return VertexAttributeSemantic.SCALE;
198
+ case "KHR_gaussian_splatting:ROTATION":
197
199
  case "_ROTATION":
198
200
  return VertexAttributeSemantic.ROTATION;
199
201
  }
@@ -88,12 +88,13 @@ const excludesReverseAxis = [
88
88
  * @see WebMapTileServiceImageryProvider
89
89
  * @see UrlTemplateImageryProvider
90
90
  *
91
- * @see {@link http://resources.esri.com/help/9.3/arcgisserver/apis/rest/|ArcGIS Server REST API}
91
+ * @see {@link https://enterprise.arcgis.com/en/server/latest/publish-services/linux/wms-services.htm|ArcGIS Server WMS Services}
92
92
  * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
93
93
  *
94
94
  * @example
95
+ * // WMS servers operated by the US government https://apps.nationalmap.gov/services/
95
96
  * const provider = new Cesium.WebMapServiceImageryProvider({
96
- * url : 'https://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer',
97
+ * url : 'https://basemap.nationalmap.gov:443/arcgis/services/USGSHydroCached/MapServer/WMSServer',
97
98
  * layers : '0',
98
99
  * proxy: new Cesium.DefaultProxy('/proxy/')
99
100
  * });
@@ -4,7 +4,6 @@ import Frozen from "../Core/Frozen.js";
4
4
  import defined from "../Core/defined.js";
5
5
  import DeveloperError from "../Core/DeveloperError.js";
6
6
  import Event from "../Core/Event.js";
7
- import Rectangle from "../Core/Rectangle.js";
8
7
  import Resource from "../Core/Resource.js";
9
8
  import WebMercatorTilingScheme from "../Core/WebMercatorTilingScheme.js";
10
9
  import ImageryProvider from "./ImageryProvider.js";
@@ -208,27 +207,6 @@ function WebMapTileServiceImageryProvider(options) {
208
207
  });
209
208
  }
210
209
 
211
- // Check the number of tiles at the minimum level. If it's more than four,
212
- // throw an exception, because starting at the higher minimum
213
- // level will cause too many tiles to be downloaded and rendered.
214
- const swTile = this._tilingScheme.positionToTileXY(
215
- Rectangle.southwest(this._rectangle),
216
- this._minimumLevel,
217
- );
218
- const neTile = this._tilingScheme.positionToTileXY(
219
- Rectangle.northeast(this._rectangle),
220
- this._minimumLevel,
221
- );
222
- const tileCount =
223
- (Math.abs(neTile.x - swTile.x) + 1) * (Math.abs(neTile.y - swTile.y) + 1);
224
- //>>includeStart('debug', pragmas.debug);
225
- if (tileCount > 4) {
226
- throw new DeveloperError(
227
- `The imagery provider's rectangle and minimumLevel indicate that there are ${tileCount} tiles at the minimum level. Imagery providers with more than four tiles at the minimum level are not supported.`,
228
- );
229
- }
230
- //>>includeEnd('debug');
231
-
232
210
  this._errorEvent = new Event();
233
211
 
234
212
  const credit = options.credit;
@@ -0,0 +1,72 @@
1
+ import addAllToArray from "../Core/addAllToArray.js";
2
+ import defined from "../Core/defined.js";
3
+ import Frozen from "../Core/Frozen.js";
4
+ import WebGLConstants from "../Core/WebGLConstants.js";
5
+
6
+ /**
7
+ * Get an array of primitives for a given mesh. If the EXT_mesh_primitive_restart extension is present, use it to combine groups of primitives.
8
+ * If the extension is not present or its spec is violated, return the original mesh.primitives.
9
+ * @param {object} mesh A mesh from the glTF meshes array
10
+ * @returns {object[]} An array of mesh primitives
11
+ * @private
12
+ */
13
+ function getMeshPrimitives(mesh) {
14
+ const meshExtensions = mesh.extensions ?? Frozen.EMPTY_OBJECT;
15
+ const primitiveRestartExtension = meshExtensions.EXT_mesh_primitive_restart;
16
+ const meshPrimitives = mesh.primitives;
17
+
18
+ if (!defined(primitiveRestartExtension)) {
19
+ return meshPrimitives;
20
+ }
21
+
22
+ // Note: per the spec, any violation of the extension's specification should cause us to fall back to mesh.primitives, if detecting the violation is feasible.
23
+
24
+ // Start with a copy of mesh.primitives. For each group, replace the first primitive in the group with a primitive representing the entire group,
25
+ // and set the rest of the primitives in the group to `undefined`.
26
+ // This allows us to identify which remaining primitives do not use primitive restart, and any errors involving a primitive appearing in more than one group.
27
+ const primitives = [];
28
+ addAllToArray(primitives, meshPrimitives);
29
+ for (const group of primitiveRestartExtension.primitiveGroups) {
30
+ // Spec: the group must not be empty and all indices must be valid array indices into mesh.primitives.
31
+ const firstPrimitiveIndex = group.primitives[0];
32
+ if (!defined(firstPrimitiveIndex) || !meshPrimitives[firstPrimitiveIndex]) {
33
+ return meshPrimitives;
34
+ }
35
+
36
+ const primitive = {
37
+ ...meshPrimitives[firstPrimitiveIndex],
38
+ indices: group.indices,
39
+ };
40
+
41
+ // Spec: primitive restart only supported for these topologies.
42
+ switch (primitive.mode) {
43
+ case WebGLConstants.TRIANGLE_FAN:
44
+ case WebGLConstants.TRIANGLE_STRIP:
45
+ case WebGLConstants.LINE_STRIP:
46
+ case WebGLConstants.LINE_LOOP:
47
+ break;
48
+ default:
49
+ return meshPrimitives;
50
+ }
51
+
52
+ for (const primitiveIndex of group.primitives) {
53
+ const thisPrimitive = primitives[primitiveIndex];
54
+
55
+ // Spec: all primitives must use indexed geometry and a given primitive may appear in at most one group.
56
+ // Spec: all primitives must have same topology.
57
+ if (
58
+ !defined(thisPrimitive?.indices) ||
59
+ thisPrimitive.mode !== primitive.mode
60
+ ) {
61
+ return meshPrimitives;
62
+ }
63
+
64
+ primitives[primitiveIndex] = undefined;
65
+ }
66
+
67
+ primitives[firstPrimitiveIndex] = primitive;
68
+ }
69
+
70
+ return primitives.filter(defined);
71
+ }
72
+ export default getMeshPrimitives;
@@ -8,11 +8,11 @@ void main() {
8
8
  if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;
9
9
  if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
10
10
 
11
- mediump float A = dot(v_vertPos, v_vertPos);
12
- if(A > 1.0) {
11
+ float A = -dot(v_vertPos, v_vertPos);
12
+ if (A < -4.) {
13
13
  discard;
14
14
  }
15
- mediump float scale = 4.0;
16
- mediump float B = exp(-A * scale) * (v_splatColor.a);
17
- out_FragColor = vec4(v_splatColor.rgb * B, B);
15
+
16
+ float B = exp(A * 4.) * v_splatColor.a ;
17
+ out_FragColor = vec4(v_splatColor.rgb * B , B);
18
18
  }
@@ -9,12 +9,12 @@ void main() {\n\
9
9
  if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;\n\
10
10
  if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;\n\
11
11
  \n\
12
- mediump float A = dot(v_vertPos, v_vertPos);\n\
13
- if(A > 1.0) {\n\
12
+ float A = -dot(v_vertPos, v_vertPos);\n\
13
+ if (A < -4.) {\n\
14
14
  discard;\n\
15
15
  }\n\
16
- mediump float scale = 4.0;\n\
17
- mediump float B = exp(-A * scale) * (v_splatColor.a);\n\
18
- out_FragColor = vec4(v_splatColor.rgb * B, B);\n\
16
+ \n\
17
+ float B = exp(A * 4.) * v_splatColor.a ;\n\
18
+ out_FragColor = vec4(v_splatColor.rgb * B , B);\n\
19
19
  }\n\
20
20
  ";
@@ -7,18 +7,110 @@
7
7
  //
8
8
  // Discards splats outside the view frustum or with negligible screen size.
9
9
  //
10
+ #if defined(HAS_SPHERICAL_HARMONICS)
11
+ const uint coefficientCount[3] = uint[3](3u,8u,15u);
12
+ const float SH_C1 = 0.48860251;
13
+ const float SH_C2[5] = float[5](
14
+ 1.092548430,
15
+ -1.09254843,
16
+ 0.315391565,
17
+ -1.09254843,
18
+ 0.546274215
19
+ );
20
+
21
+ const float SH_C3[7] = float[7](
22
+ -0.59004358,
23
+ 2.890611442,
24
+ -0.45704579,
25
+ 0.373176332,
26
+ -0.45704579,
27
+ 1.445305721,
28
+ -0.59004358
29
+ );
30
+
31
+ //Retrieve SH coefficient. Currently RG32UI format
32
+ uvec2 loadSHCoeff(uint splatID, int index) {
33
+ ivec2 shTexSize = textureSize(u_sphericalHarmonicsTexture, 0);
34
+ uint dims = coefficientCount[uint(u_sphericalHarmonicsDegree)-1u];
35
+ uint splatsPerRow = uint(shTexSize.x) / dims;
36
+ uint shIndex = (splatID%splatsPerRow) * dims + uint(index);
37
+ ivec2 shPosCoord = ivec2(shIndex, splatID / splatsPerRow);
38
+ return texelFetch(u_sphericalHarmonicsTexture, shPosCoord, 0).rg;
39
+ }
40
+
41
+ //Unpack RG32UI half float coefficients to vec3
42
+ vec3 halfToVec3(uvec2 packed) {
43
+ return vec3(unpackHalf2x16(packed.x), unpackHalf2x16(packed.y).x);
44
+ }
45
+
46
+ vec3 loadAndExpandSHCoeff(uint splatID, int index) {
47
+ uvec2 coeff = loadSHCoeff(splatID, index);
48
+ return halfToVec3(coeff);
49
+ }
50
+
51
+ vec3 evaluateSH(uint splatID, vec3 viewDir) {
52
+ vec3 result = vec3(0.0);
53
+ int coeffIndex = 0;
54
+ float x = viewDir.x, y = viewDir.y, z = viewDir.z;
55
+
56
+ if (u_sphericalHarmonicsDegree >= 1.) {
57
+ vec3 sh1 = loadAndExpandSHCoeff(splatID, coeffIndex++);
58
+ vec3 sh2 = loadAndExpandSHCoeff(splatID, coeffIndex++);
59
+ vec3 sh3 = loadAndExpandSHCoeff(splatID, coeffIndex++);
60
+ result += -SH_C1 * y * sh1 + SH_C1 * z * sh2 - SH_C1 * x * sh3;
61
+
62
+ if (u_sphericalHarmonicsDegree >= 2.) {
63
+ float xx = x * x;
64
+ float yy = y * y;
65
+ float zz = z * z;
66
+ float xy = x * y;
67
+ float yz = y * z;
68
+ float xz = x * z;
69
+
70
+ vec3 sh4 = loadAndExpandSHCoeff(splatID, coeffIndex++);
71
+ vec3 sh5 = loadAndExpandSHCoeff(splatID, coeffIndex++);
72
+ vec3 sh6 = loadAndExpandSHCoeff(splatID, coeffIndex++);
73
+ vec3 sh7 = loadAndExpandSHCoeff(splatID, coeffIndex++);
74
+ vec3 sh8 = loadAndExpandSHCoeff(splatID, coeffIndex++);
75
+ result += SH_C2[0] * xy * sh4 +
76
+ SH_C2[1] * yz * sh5 +
77
+ SH_C2[2] * (2.0f * zz - xx - yy) * sh6 +
78
+ SH_C2[3] * xz * sh7 +
79
+ SH_C2[4] * (xx - yy) * sh8;
80
+
81
+ if (u_sphericalHarmonicsDegree >= 3.) {
82
+ vec3 sh9 = loadAndExpandSHCoeff(splatID, coeffIndex++);
83
+ vec3 sh10 = loadAndExpandSHCoeff(splatID, coeffIndex++);
84
+ vec3 sh11 = loadAndExpandSHCoeff(splatID, coeffIndex++);
85
+ vec3 sh12 = loadAndExpandSHCoeff(splatID, coeffIndex++);
86
+ vec3 sh13 = loadAndExpandSHCoeff(splatID, coeffIndex++);
87
+ vec3 sh14 = loadAndExpandSHCoeff(splatID, coeffIndex++);
88
+ vec3 sh15 = loadAndExpandSHCoeff(splatID, coeffIndex++);
89
+ result += SH_C3[0] * y * (3.0f * xx - yy) * sh9 +
90
+ SH_C3[1] * xy * z * sh10 +
91
+ SH_C3[2] * y * (4.0f * zz - xx - yy) * sh11 +
92
+ SH_C3[3] * z * (2.0f * zz - 3.0f * xx - 3.0f * yy) * sh12 +
93
+ SH_C3[4] * x * (4.0f * zz - xx - yy) * sh13 +
94
+ SH_C3[5] * z * (xx - yy) * sh14 +
95
+ SH_C3[6] * x * (xx - 3.0f * yy) * sh15;
96
+ }
97
+ }
98
+ }
99
+ return result;
100
+ }
101
+ #endif
10
102
 
11
103
  // Transforms and projects splat covariance into screen space and extracts the major and minor axes of the Gaussian ellipsoid
12
104
  // which is used to calculate the vertex position in clip space.
13
105
  vec4 calcCovVectors(vec3 viewPos, mat3 Vrk) {
14
106
  vec4 t = vec4(viewPos, 1.0);
15
- float focal = czm_viewport.z * czm_projection[0][0];
107
+ vec2 focal = vec2(czm_projection[0][0] * czm_viewport.z, czm_projection[1][1] * czm_viewport.w);
16
108
 
17
- float J1 = focal / t.z;
18
- vec2 J2 = -J1 / t.z * t.xy;
109
+ vec2 J1 = focal / t.z;
110
+ vec2 J2 = -focal * vec2(t.x, t.y) / (t.z * t.z);
19
111
  mat3 J = mat3(
20
- J1, 0.0, J2.x,
21
- 0.0, J1, J2.y,
112
+ J1.x, 0.0, J2.x,
113
+ 0.0, J1.y, J2.y,
22
114
  0.0, 0.0, 0.0
23
115
  );
24
116
 
@@ -87,6 +179,11 @@ void main() {
87
179
 
88
180
  v_vertPos = corner ;
89
181
  v_splatColor = vec4(covariance.w & 0xffu, (covariance.w >> 8) & 0xffu, (covariance.w >> 16) & 0xffu, (covariance.w >> 24) & 0xffu) / 255.0;
182
+ #if defined(HAS_SPHERICAL_HARMONICS)
183
+ vec4 splatWC = czm_inverseView * splatViewPos;
184
+ vec3 viewDirModel = normalize(u_inverseModelRotation * (splatWC.xyz - u_cameraPositionWC.xyz));
90
185
 
186
+ v_splatColor.rgb += evaluateSH(texIdx, viewDirModel).rgb;
187
+ #endif
91
188
  v_splitDirection = u_splitDirection;
92
189
  }
@@ -8,18 +8,110 @@ export default "//\n\
8
8
  //\n\
9
9
  // Discards splats outside the view frustum or with negligible screen size.\n\
10
10
  //\n\
11
+ #if defined(HAS_SPHERICAL_HARMONICS)\n\
12
+ const uint coefficientCount[3] = uint[3](3u,8u,15u);\n\
13
+ const float SH_C1 = 0.48860251;\n\
14
+ const float SH_C2[5] = float[5](\n\
15
+ 1.092548430,\n\
16
+ -1.09254843,\n\
17
+ 0.315391565,\n\
18
+ -1.09254843,\n\
19
+ 0.546274215\n\
20
+ );\n\
21
+ \n\
22
+ const float SH_C3[7] = float[7](\n\
23
+ -0.59004358,\n\
24
+ 2.890611442,\n\
25
+ -0.45704579,\n\
26
+ 0.373176332,\n\
27
+ -0.45704579,\n\
28
+ 1.445305721,\n\
29
+ -0.59004358\n\
30
+ );\n\
31
+ \n\
32
+ //Retrieve SH coefficient. Currently RG32UI format\n\
33
+ uvec2 loadSHCoeff(uint splatID, int index) {\n\
34
+ ivec2 shTexSize = textureSize(u_sphericalHarmonicsTexture, 0);\n\
35
+ uint dims = coefficientCount[uint(u_sphericalHarmonicsDegree)-1u];\n\
36
+ uint splatsPerRow = uint(shTexSize.x) / dims;\n\
37
+ uint shIndex = (splatID%splatsPerRow) * dims + uint(index);\n\
38
+ ivec2 shPosCoord = ivec2(shIndex, splatID / splatsPerRow);\n\
39
+ return texelFetch(u_sphericalHarmonicsTexture, shPosCoord, 0).rg;\n\
40
+ }\n\
41
+ \n\
42
+ //Unpack RG32UI half float coefficients to vec3\n\
43
+ vec3 halfToVec3(uvec2 packed) {\n\
44
+ return vec3(unpackHalf2x16(packed.x), unpackHalf2x16(packed.y).x);\n\
45
+ }\n\
46
+ \n\
47
+ vec3 loadAndExpandSHCoeff(uint splatID, int index) {\n\
48
+ uvec2 coeff = loadSHCoeff(splatID, index);\n\
49
+ return halfToVec3(coeff);\n\
50
+ }\n\
51
+ \n\
52
+ vec3 evaluateSH(uint splatID, vec3 viewDir) {\n\
53
+ vec3 result = vec3(0.0);\n\
54
+ int coeffIndex = 0;\n\
55
+ float x = viewDir.x, y = viewDir.y, z = viewDir.z;\n\
56
+ \n\
57
+ if (u_sphericalHarmonicsDegree >= 1.) {\n\
58
+ vec3 sh1 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
59
+ vec3 sh2 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
60
+ vec3 sh3 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
61
+ result += -SH_C1 * y * sh1 + SH_C1 * z * sh2 - SH_C1 * x * sh3;\n\
62
+ \n\
63
+ if (u_sphericalHarmonicsDegree >= 2.) {\n\
64
+ float xx = x * x;\n\
65
+ float yy = y * y;\n\
66
+ float zz = z * z;\n\
67
+ float xy = x * y;\n\
68
+ float yz = y * z;\n\
69
+ float xz = x * z;\n\
70
+ \n\
71
+ vec3 sh4 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
72
+ vec3 sh5 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
73
+ vec3 sh6 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
74
+ vec3 sh7 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
75
+ vec3 sh8 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
76
+ result += SH_C2[0] * xy * sh4 +\n\
77
+ SH_C2[1] * yz * sh5 +\n\
78
+ SH_C2[2] * (2.0f * zz - xx - yy) * sh6 +\n\
79
+ SH_C2[3] * xz * sh7 +\n\
80
+ SH_C2[4] * (xx - yy) * sh8;\n\
81
+ \n\
82
+ if (u_sphericalHarmonicsDegree >= 3.) {\n\
83
+ vec3 sh9 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
84
+ vec3 sh10 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
85
+ vec3 sh11 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
86
+ vec3 sh12 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
87
+ vec3 sh13 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
88
+ vec3 sh14 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
89
+ vec3 sh15 = loadAndExpandSHCoeff(splatID, coeffIndex++);\n\
90
+ result += SH_C3[0] * y * (3.0f * xx - yy) * sh9 +\n\
91
+ SH_C3[1] * xy * z * sh10 +\n\
92
+ SH_C3[2] * y * (4.0f * zz - xx - yy) * sh11 +\n\
93
+ SH_C3[3] * z * (2.0f * zz - 3.0f * xx - 3.0f * yy) * sh12 +\n\
94
+ SH_C3[4] * x * (4.0f * zz - xx - yy) * sh13 +\n\
95
+ SH_C3[5] * z * (xx - yy) * sh14 +\n\
96
+ SH_C3[6] * x * (xx - 3.0f * yy) * sh15;\n\
97
+ }\n\
98
+ }\n\
99
+ }\n\
100
+ return result;\n\
101
+ }\n\
102
+ #endif\n\
11
103
  \n\
12
104
  // Transforms and projects splat covariance into screen space and extracts the major and minor axes of the Gaussian ellipsoid\n\
13
105
  // which is used to calculate the vertex position in clip space.\n\
14
106
  vec4 calcCovVectors(vec3 viewPos, mat3 Vrk) {\n\
15
107
  vec4 t = vec4(viewPos, 1.0);\n\
16
- float focal = czm_viewport.z * czm_projection[0][0];\n\
108
+ vec2 focal = vec2(czm_projection[0][0] * czm_viewport.z, czm_projection[1][1] * czm_viewport.w);\n\
17
109
  \n\
18
- float J1 = focal / t.z;\n\
19
- vec2 J2 = -J1 / t.z * t.xy;\n\
110
+ vec2 J1 = focal / t.z;\n\
111
+ vec2 J2 = -focal * vec2(t.x, t.y) / (t.z * t.z);\n\
20
112
  mat3 J = mat3(\n\
21
- J1, 0.0, J2.x,\n\
22
- 0.0, J1, J2.y,\n\
113
+ J1.x, 0.0, J2.x,\n\
114
+ 0.0, J1.y, J2.y,\n\
23
115
  0.0, 0.0, 0.0\n\
24
116
  );\n\
25
117
  \n\
@@ -88,6 +180,11 @@ void main() {\n\
88
180
  \n\
89
181
  v_vertPos = corner ;\n\
90
182
  v_splatColor = vec4(covariance.w & 0xffu, (covariance.w >> 8) & 0xffu, (covariance.w >> 16) & 0xffu, (covariance.w >> 24) & 0xffu) / 255.0;\n\
183
+ #if defined(HAS_SPHERICAL_HARMONICS)\n\
184
+ vec4 splatWC = czm_inverseView * splatViewPos;\n\
185
+ vec3 viewDirModel = normalize(u_inverseModelRotation * (splatWC.xyz - u_cameraPositionWC.xyz));\n\
91
186
  \n\
187
+ v_splatColor.rgb += evaluateSH(texIdx, viewDirModel).rgb;\n\
188
+ #endif\n\
92
189
  v_splitDirection = u_splitDirection;\n\
93
190
  }";
@@ -1 +1 @@
1
- !function(){"use strict";const{Array:e,Object:t,Number:n,Math:s,Error:r,Uint8Array:a,Uint16Array:o,Uint32Array:i,Int32Array:c,Map:l,DataView:u,Promise:h,TextEncoder:p,crypto:f,postMessage:d,TransformStream:g,ReadableStream:w,WritableStream:y,CompressionStream:m,DecompressionStream:_}=self,b=void 0,S="undefined",v="function";class k{constructor(e){return class extends g{constructor(t,n){const s=new e(n);super({transform(e,t){t.enqueue(s.append(e))},flush(e){const t=s.flush();t&&e.enqueue(t)}})}}}}const z=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;z[e]=t}class D{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,s=0|e.length;s>n;n++)t=t>>>8^z[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class C extends g{constructor(){let e;const t=new D;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new a(4);new u(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const I={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],s=I.getPartial(n);return 32===s?e.concat(t):I._shiftRight(t,s,0|n,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+I.getPartial(n)},clamp(e,t){if(32*e.length<t)return e;const n=(e=e.slice(0,s.ceil(t/32))).length;return t&=31,n>0&&t&&(e[n-1]=I.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>s.round(e/1099511627776)||32,_shiftRight(e,t,n,s){for(void 0===s&&(s=[]);t>=32;t-=32)s.push(n),n=0;if(0===t)return s.concat(e);for(let r=0;r<e.length;r++)s.push(n|e[r]>>>t),n=e[r]<<32-t;const r=e.length?e[e.length-1]:0,a=I.getPartial(r);return s.push(I.partial(t+a&31,t+a>32?n:s.pop(),1)),s}},A={bytes:{fromBits(e){const t=I.bitLength(e)/8,n=new a(t);let s;for(let r=0;t>r;r++)3&r||(s=e[r/4]),n[r]=s>>>24,s<<=8;return n},toBits(e){const t=[];let n,s=0;for(n=0;n<e.length;n++)s=s<<8|e[n],3&~n||(t.push(s),s=0);return 3&n&&t.push(I.partial(8*(3&n),s)),t}}},q=class{constructor(e){const t=this;t.blockSize=512,t._init=[1732584193,4023233417,2562383102,271733878,3285377520],t._key=[1518500249,1859775393,2400959708,3395469782],e?(t._h=e._h.slice(0),t._buffer=e._buffer.slice(0),t._length=e._length):t.reset()}reset(){const e=this;return e._h=e._init.slice(0),e._buffer=[],e._length=0,e}update(e){const t=this;"string"==typeof e&&(e=A.utf8String.toBits(e));const n=t._buffer=I.concat(t._buffer,e),s=t._length,a=t._length=s+I.bitLength(e);if(a>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const o=new i(n);let c=0;for(let e=t.blockSize+s-(t.blockSize+s&t.blockSize-1);a>=e;e+=t.blockSize)t._block(o.subarray(16*c,16*(c+1))),c+=1;return n.splice(0,16*c),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=I.concat(t,[I.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(s.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,s){return e>19?e>39?e>59?e>79?void 0:t^n^s:t&n|t&s|n&s:t^n^s:t&n|~t&s}_S(e,t){return t<<e|t>>>32-e}_block(t){const n=this,r=n._h,a=e(80);for(let e=0;16>e;e++)a[e]=t[e];let o=r[0],i=r[1],c=r[2],l=r[3],u=r[4];for(let e=0;79>=e;e++){16>e||(a[e]=n._S(1,a[e-3]^a[e-8]^a[e-14]^a[e-16]));const t=n._S(5,o)+n._f(e,i,c,l)+u+a[e]+n._key[s.floor(e/20)]|0;u=l,l=c,c=n._S(30,i),i=o,o=t}r[0]=r[0]+o|0,r[1]=r[1]+i|0,r[2]=r[2]+c|0,r[3]=r[3]+l|0,r[4]=r[4]+u|0}},R={getRandomValues(e){const t=new i(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(s.random()>.5?1:-1))};for(let r,a=0;a<e.length;a+=4){const e=n(4294967296*(r||s.random()));r=987654071*e(),t[a/4]=4294967296*e()|0}return e}},H={importKey:e=>new H.hmacSha1(A.bytes.toBits(e)),pbkdf2(e,t,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const a=1+(s>>5)<<2;let o,i,c,l,h;const p=new ArrayBuffer(a),f=new u(p);let d=0;const g=I;for(t=A.bytes.toBits(t),h=1;(a||1)>d;h++){for(o=i=e.encrypt(g.concat(t,[h])),c=1;n>c;c++)for(i=e.encrypt(i),l=0;l<i.length;l++)o[l]^=i[l];for(c=0;(a||1)>d&&c<o.length;c++)f.setInt32(d,o[c]),d+=4}return p.slice(0,s/8)},hmacSha1:class{constructor(e){const t=this,n=t._hash=q,s=[[],[]];t._baseHash=[new n,new n];const r=t._baseHash[0].blockSize/32;e.length>r&&(e=(new n).update(e).finalize());for(let t=0;r>t;t++)s[0][t]=909522486^e[t],s[1][t]=1549556828^e[t];t._baseHash[0].update(s[0]),t._baseHash[1].update(s[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new r("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},P=typeof f!=S&&typeof f.getRandomValues==v,B="Invalid password",K="Invalid signature",T="zipjs-abort-check-password";function V(e){return P?f.getRandomValues(e):R.getRandomValues(e)}const x=16,E={name:"PBKDF2"},U=t.assign({hash:{name:"HMAC"}},E),W=t.assign({iterations:1e3,hash:{name:"SHA-1"}},E),M=["deriveBits"],N=[8,12,16],O=[16,24,32],L=10,F=[0,0,0,0],j=typeof f!=S,G=j&&f.subtle,X=j&&typeof G!=S,J=A.bytes,Q=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],s=t._tables[1],a=e.length;let o,i,c,l=1;if(4!==a&&6!==a&&8!==a)throw new r("invalid aes key size");for(t._key=[i=e.slice(0),c=[]],o=a;4*a+28>o;o++){let e=i[o-1];(o%a===0||8===a&&o%a===4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],o%a===0&&(e=e<<8^e>>>24^l<<24,l=l<<1^283*(l>>7))),i[o]=i[o-a]^e}for(let e=0;o;e++,o--){const t=i[3&e?o:o-4];c[e]=4>=o||4>e?t:s[0][n[t>>>24]]^s[1][n[t>>16&255]]^s[2][n[t>>8&255]]^s[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],s=t[4],r=[],a=[];let o,i,c,l;for(let e=0;256>e;e++)a[(r[e]=e<<1^283*(e>>7))^e]=e;for(let u=o=0;!n[u];u^=i||1,o=a[o]||1){let a=o^o<<1^o<<2^o<<3^o<<4;a=a>>8^255&a^99,n[u]=a,s[a]=u,l=r[c=r[i=r[u]]];let h=16843009*l^65537*c^257*i^16843008*u,p=257*r[a]^16843008*a;for(let n=0;4>n;n++)e[n][u]=p=p<<24^p>>>8,t[n][a]=h=h<<24^h>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new r("invalid aes block size");const n=this._key[t],s=n.length/4-2,a=[0,0,0,0],o=this._tables[t],i=o[0],c=o[1],l=o[2],u=o[3],h=o[4];let p,f,d,g=e[0]^n[0],w=e[t?3:1]^n[1],y=e[2]^n[2],m=e[t?1:3]^n[3],_=4;for(let e=0;s>e;e++)p=i[g>>>24]^c[w>>16&255]^l[y>>8&255]^u[255&m]^n[_],f=i[w>>>24]^c[y>>16&255]^l[m>>8&255]^u[255&g]^n[_+1],d=i[y>>>24]^c[m>>16&255]^l[g>>8&255]^u[255&w]^n[_+2],m=i[m>>>24]^c[g>>16&255]^l[w>>8&255]^u[255&y]^n[_+3],_+=4,g=p,w=f,y=d;for(let e=0;4>e;e++)a[t?3&-e:e]=h[g>>>24]<<24^h[w>>16&255]<<16^h[y>>8&255]<<8^h[255&m]^n[_++],p=g,g=w,w=y,y=m,m=p;return a}},Y=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255&~(e>>24))e+=1<<24;else{let t=e>>16&255,n=e>>8&255,s=255&e;255===t?(t=0,255===n?(n=0,255===s?s=0:++s):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=s}return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let s;if(!(s=t.length))return[];const r=I.bitLength(t);for(let r=0;s>r;r+=4){this.incCounter(n);const s=e.encrypt(n);t[r]^=s[0],t[r+1]^=s[1],t[r+2]^=s[2],t[r+3]^=s[3]}return I.clamp(t,r)}},Z=H.hmacSha1;let $=j&&X&&typeof G.importKey==v,ee=j&&X&&typeof G.deriveBits==v;class te extends g{constructor({password:e,rawPassword:n,signed:s,encryptionStrength:o,checkPasswordOnly:i}){super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:ae(e,n),signed:s,strength:o-1,pending:new a})},async transform(e,t){const n=this,{password:s,strength:o,resolveReady:c,ready:l}=n;s?(await(async(e,t,n,s)=>{const a=await re(e,t,n,ie(s,0,N[t])),o=ie(s,N[t]);if(a[0]!=o[0]||a[1]!=o[1])throw new r(B)})(n,o,s,ie(e,0,N[o]+2)),e=ie(e,N[o]+2),i?t.error(new r(T)):c()):await l;const u=new a(e.length-L-(e.length-L)%x);t.enqueue(se(n,e,u,0,L,!0))},async flush(e){const{signed:t,ctr:n,hmac:s,pending:o,ready:i}=this;if(s&&n){await i;const c=ie(o,0,o.length-L),l=ie(o,o.length-L);let u=new a;if(c.length){const e=le(J,c);s.update(e);const t=n.update(e);u=ce(J,t)}if(t){const e=ie(ce(J,s.digest()),0,L);for(let t=0;L>t;t++)if(e[t]!=l[t])throw new r(K)}e.enqueue(u)}}})}}class ne extends g{constructor({password:e,rawPassword:n,encryptionStrength:s}){let r;super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:ae(e,n),strength:s-1,pending:new a})},async transform(e,t){const n=this,{password:s,strength:r,resolveReady:o,ready:i}=n;let c=new a;s?(c=await(async(e,t,n)=>{const s=V(new a(N[t]));return oe(s,await re(e,t,n,s))})(n,r,s),o()):await i;const l=new a(c.length+e.length-e.length%x);l.set(c,0),t.enqueue(se(n,e,l,c.length,0))},async flush(e){const{ctr:t,hmac:n,pending:s,ready:o}=this;if(n&&t){await o;let i=new a;if(s.length){const e=t.update(le(J,s));n.update(e),i=ce(J,e)}r.signature=ce(J,n.digest()).slice(0,L),e.enqueue(oe(i,r.signature))}}}),r=this}}function se(e,t,n,s,r,o){const{ctr:i,hmac:c,pending:l}=e,u=t.length-r;let h;for(l.length&&(t=oe(l,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new a(t)).set(n,0)}return e})(n,u-u%x)),h=0;u-x>=h;h+=x){const e=le(J,ie(t,h,h+x));o&&c.update(e);const r=i.update(e);o||c.update(r),n.set(ce(J,r),h+s)}return e.pending=ie(t,h),n}async function re(n,s,r,o){n.password=null;const i=await(async(e,t,n,s,r)=>{if(!$)return H.importKey(t);try{return await G.importKey("raw",t,n,!1,r)}catch(e){return $=!1,H.importKey(t)}})(0,r,U,0,M),c=await(async(e,t,n)=>{if(!ee)return H.pbkdf2(t,e.salt,W.iterations,n);try{return await G.deriveBits(e,t,n)}catch(s){return ee=!1,H.pbkdf2(t,e.salt,W.iterations,n)}})(t.assign({salt:o},W),i,8*(2*O[s]+2)),l=new a(c),u=le(J,ie(l,0,O[s])),h=le(J,ie(l,O[s],2*O[s])),p=ie(l,2*O[s]);return t.assign(n,{keys:{key:u,authentication:h,passwordVerification:p},ctr:new Y(new Q(u),e.from(F)),hmac:new Z(h)}),p}function ae(e,t){return t===b?(e=>{if(typeof p==S){const t=new a((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new p).encode(e)})(e):t}function oe(e,t){let n=e;return e.length+t.length&&(n=new a(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function ie(e,t,n){return e.subarray(t,n)}function ce(e,t){return e.fromBits(t)}function le(e,t){return e.toBits(t)}class ue extends g{constructor({password:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){t.assign(this,{password:e,passwordVerification:n}),de(this,e)},transform(e,t){const n=this;if(n.password){const t=pe(n,e.subarray(0,12));if(n.password=null,t[11]!=n.passwordVerification)throw new r(B);e=e.subarray(12)}s?t.error(new r(T)):t.enqueue(pe(n,e))}})}}class he extends g{constructor({password:e,passwordVerification:n}){super({start(){t.assign(this,{password:e,passwordVerification:n}),de(this,e)},transform(e,t){const n=this;let s,r;if(n.password){n.password=null;const t=V(new a(12));t[11]=n.passwordVerification,s=new a(e.length+t.length),s.set(fe(n,t),0),r=12}else s=new a(e.length),r=0;s.set(fe(n,e),r),t.enqueue(s)}})}}function pe(e,t){const n=new a(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],ge(e,n[s]);return n}function fe(e,t){const n=new a(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],ge(e,t[s]);return n}function de(e,n){const s=[305419896,591751049,878082192];t.assign(e,{keys:s,crcKey0:new D(s[0]),crcKey2:new D(s[2])});for(let t=0;t<n.length;t++)ge(e,n.charCodeAt(t))}function ge(e,t){let[n,r,a]=e.keys;e.crcKey0.append([t]),n=~e.crcKey0.get(),r=me(s.imul(me(r+ye(n)),134775813)+1),e.crcKey2.append([r>>>24]),a=~e.crcKey2.get(),e.keys=[n,r,a]}function we(e){const t=2|e.keys[2];return ye(s.imul(t,1^t)>>>8)}function ye(e){return 255&e}function me(e){return 4294967295&e}class _e extends g{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:s}){super({});const{compressed:r,encrypted:a,useCompressionStream:o,zipCrypto:i,signed:c,level:l}=e,h=this;let p,f,d=super.readable;a&&!i||!c||(p=new C,d=ke(d,p)),r&&(d=ve(d,o,{level:l,chunkSize:t},s,n)),a&&(i?d=ke(d,new he(e)):(f=new ne(e),d=ke(d,f))),Se(h,d,()=>{let e;a&&!i&&(e=f.signature),a&&!i||!c||(e=new u(p.value.buffer).getUint32(0)),h.signature=e})}}class be extends g{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:s}){super({});const{zipCrypto:a,encrypted:o,signed:i,signature:c,compressed:l,useCompressionStream:h}=e;let p,f,d=super.readable;o&&(a?d=ke(d,new ue(e)):(f=new te(e),d=ke(d,f))),l&&(d=ve(d,h,{chunkSize:t},s,n)),o&&!a||!i||(p=new C,d=ke(d,p)),Se(this,d,()=>{if((!o||a)&&i){const e=new u(p.value.buffer);if(c!=e.getUint32(0,!1))throw new r(K)}})}}function Se(e,n,s){n=ke(n,new g({flush:s})),t.defineProperty(e,"readable",{get:()=>n})}function ve(e,t,n,s,r){return ke(e,new(t&&s?s:r)("deflate-raw",n))}function ke(e,t){return e.pipeThrough(t)}const ze="data",De="close";class Ce extends g{constructor(e,n){super({});const s=this,{codecType:a}=e;let o;a.startsWith("deflate")?o=_e:a.startsWith("inflate")&&(o=be),s.outputSize=0;let i=0;const c=new o(e,n),l=super.readable,u=new g({transform(e,t){e&&e.length&&(i+=e.length,t.enqueue(e))},flush(){t.assign(s,{inputSize:i})}}),h=new g({transform(t,n){if(t&&t.length&&(n.enqueue(t),s.outputSize+=t.length,e.outputSize&&s.outputSize>e.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:e}=c;t.assign(s,{signature:e,inputSize:i})}});t.defineProperty(s,"readable",{get:()=>l.pipeThrough(u).pipeThrough(c).pipeThrough(h)})}}class Ie extends g{constructor(e){let t;super({transform:function n(s,r){if(t){const e=new a(t.length+s.length);e.set(t),e.set(s,t.length),s=e,t=null}s.length>e?(r.enqueue(s.slice(0,e)),n(s.slice(e),r)):t=s},flush(e){t&&t.length&&e.enqueue(t)}})}}const Ae=new l,qe=new l;let Re,He=0,Pe=!0;async function Be(e){try{const{options:t,scripts:s,config:r}=e;if(s&&s.length)try{Pe?importScripts.apply(b,s):await Ke(s)}catch(e){Pe=!1,await Ke(s)}self.initCodec&&self.initCodec(),r.CompressionStreamNative=self.CompressionStream,r.DecompressionStreamNative=self.DecompressionStream,self.Deflate&&(r.CompressionStream=new k(self.Deflate)),self.Inflate&&(r.DecompressionStream=new k(self.Inflate));const a={highWaterMark:1},o=e.readable||new w({async pull(e){const t=new h(e=>Ae.set(He,e));Te({type:"pull",messageId:He}),He=(He+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await t;e.enqueue(s),r&&e.close()}},a),i=e.writable||new y({async write(e){let t;const s=new h(e=>t=e);qe.set(He,t),Te({type:ze,value:e,messageId:He}),He=(He+1)%n.MAX_SAFE_INTEGER,await s}},a),c=new Ce(t,r);Re=new AbortController;const{signal:l}=Re;await o.pipeThrough(c).pipeThrough(new Ie(r.chunkSize)).pipeTo(i,{signal:l,preventClose:!0,preventAbort:!0}),await i.getWriter().close();const{signature:u,inputSize:p,outputSize:f}=c;Te({type:De,result:{signature:u,inputSize:p,outputSize:f}})}catch(e){e.outputSize=0,Ve(e)}}async function Ke(e){for(const t of e)await import(t)}function Te(e){let{value:t}=e;if(t)if(t.length)try{t=new a(t),e.value=t.buffer,d(e,[e.value])}catch(t){d(e)}else d(e);else d(e)}function Ve(e=new r("Unknown error")){const{message:t,stack:n,code:s,name:a,outputSize:o}=e;d({error:{message:t,stack:n,code:s,name:a,outputSize:o}})}function xe(e,n,s){return class{constructor(r){const o=this;var i,c;i=r,c="level",(typeof t.hasOwn===v?t.hasOwn(i,c):i.hasOwnProperty(c))&&r.level===b&&delete r.level,o.codec=new e(t.assign({},n,r)),s(o.codec,e=>{if(o.pendingData){const t=o.pendingData;o.pendingData=new a(t.length+e.length);const{pendingData:n}=o;n.set(t,0),n.set(e,t.length)}else o.pendingData=new a(e)})}append(e){return this.codec.push(e),r(this)}flush(){return this.codec.push(new a,!0),r(this)}};function r(e){if(e.pendingData){const t=e.pendingData;return e.pendingData=null,t}return new a}}addEventListener("message",({data:e})=>{const{type:t,messageId:n,value:s,done:r}=e;try{if("start"==t&&Be(e),t==ze){const e=Ae.get(n);Ae.delete(n),e({value:new a(s),done:r})}if("ack"==t){const e=qe.get(n);qe.delete(n),e()}t==De&&Re.abort()}catch(e){Ve(e)}}),self.initCodec=()=>{const{Deflate:e,Inflate:t}=((e,t={},n)=>({Deflate:xe(e.Deflate,t.deflate,n),Inflate:xe(e.Inflate,t.inflate,n)}))(pako,{deflate:{raw:!0},inflate:{raw:!0}},(e,t)=>e.onData=t);self.Deflate=e,self.Inflate=t}}();
1
+ !function(){"use strict";const{Array:e,Object:t,Number:n,Math:s,Error:r,Uint8Array:a,Uint16Array:o,Uint32Array:i,Int32Array:c,Map:l,DataView:u,Promise:h,TextEncoder:p,crypto:f,postMessage:d,TransformStream:g,ReadableStream:w,WritableStream:y,CompressionStream:m,DecompressionStream:_}=self,b=void 0,S="undefined",v="function";class k{constructor(e){return class extends g{constructor(t,n){const s=new e(n);super({transform(e,t){t.enqueue(s.append(e))},flush(e){const t=s.flush();t&&e.enqueue(t)}})}}}}const z=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;z[e]=t}class D{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,s=0|e.length;s>n;n++)t=t>>>8^z[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class C extends g{constructor(){let e;const t=new D;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new a(4);new u(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const I={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],s=I.getPartial(n);return 32===s?e.concat(t):I._shiftRight(t,s,0|n,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+I.getPartial(n)},clamp(e,t){if(32*e.length<t)return e;const n=(e=e.slice(0,s.ceil(t/32))).length;return t&=31,n>0&&t&&(e[n-1]=I.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>s.round(e/1099511627776)||32,_shiftRight(e,t,n,s){for(void 0===s&&(s=[]);t>=32;t-=32)s.push(n),n=0;if(0===t)return s.concat(e);for(let r=0;r<e.length;r++)s.push(n|e[r]>>>t),n=e[r]<<32-t;const r=e.length?e[e.length-1]:0,a=I.getPartial(r);return s.push(I.partial(t+a&31,t+a>32?n:s.pop(),1)),s}},A={bytes:{fromBits(e){const t=I.bitLength(e)/8,n=new a(t);let s;for(let r=0;t>r;r++)3&r||(s=e[r/4]),n[r]=s>>>24,s<<=8;return n},toBits(e){const t=[];let n,s=0;for(n=0;n<e.length;n++)s=s<<8|e[n],3&~n||(t.push(s),s=0);return 3&n&&t.push(I.partial(8*(3&n),s)),t}}},q=class{constructor(e){const t=this;t.blockSize=512,t._init=[1732584193,4023233417,2562383102,271733878,3285377520],t._key=[1518500249,1859775393,2400959708,3395469782],e?(t._h=e._h.slice(0),t._buffer=e._buffer.slice(0),t._length=e._length):t.reset()}reset(){const e=this;return e._h=e._init.slice(0),e._buffer=[],e._length=0,e}update(e){const t=this;"string"==typeof e&&(e=A.utf8String.toBits(e));const n=t._buffer=I.concat(t._buffer,e),s=t._length,a=t._length=s+I.bitLength(e);if(a>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const o=new i(n);let c=0;for(let e=t.blockSize+s-(t.blockSize+s&t.blockSize-1);a>=e;e+=t.blockSize)t._block(o.subarray(16*c,16*(c+1))),c+=1;return n.splice(0,16*c),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=I.concat(t,[I.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(s.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,s){return e>19?e>39?e>59?e>79?void 0:t^n^s:t&n|t&s|n&s:t^n^s:t&n|~t&s}_S(e,t){return t<<e|t>>>32-e}_block(t){const n=this,r=n._h,a=e(80);for(let e=0;16>e;e++)a[e]=t[e];let o=r[0],i=r[1],c=r[2],l=r[3],u=r[4];for(let e=0;79>=e;e++){16>e||(a[e]=n._S(1,a[e-3]^a[e-8]^a[e-14]^a[e-16]));const t=n._S(5,o)+n._f(e,i,c,l)+u+a[e]+n._key[s.floor(e/20)]|0;u=l,l=c,c=n._S(30,i),i=o,o=t}r[0]=r[0]+o|0,r[1]=r[1]+i|0,r[2]=r[2]+c|0,r[3]=r[3]+l|0,r[4]=r[4]+u|0}},R={getRandomValues(e){const t=new i(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(s.random()>.5?1:-1))};for(let r,a=0;a<e.length;a+=4){const e=n(4294967296*(r||s.random()));r=987654071*e(),t[a/4]=4294967296*e()|0}return e}},H={importKey:e=>new H.hmacSha1(A.bytes.toBits(e)),pbkdf2(e,t,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const a=1+(s>>5)<<2;let o,i,c,l,h;const p=new ArrayBuffer(a),f=new u(p);let d=0;const g=I;for(t=A.bytes.toBits(t),h=1;(a||1)>d;h++){for(o=i=e.encrypt(g.concat(t,[h])),c=1;n>c;c++)for(i=e.encrypt(i),l=0;l<i.length;l++)o[l]^=i[l];for(c=0;(a||1)>d&&c<o.length;c++)f.setInt32(d,o[c]),d+=4}return p.slice(0,s/8)},hmacSha1:class{constructor(e){const t=this,n=t._hash=q,s=[[],[]];t._baseHash=[new n,new n];const r=t._baseHash[0].blockSize/32;e.length>r&&(e=(new n).update(e).finalize());for(let t=0;r>t;t++)s[0][t]=909522486^e[t],s[1][t]=1549556828^e[t];t._baseHash[0].update(s[0]),t._baseHash[1].update(s[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new r("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},P=typeof f!=S&&typeof f.getRandomValues==v,B="Invalid password",K="Invalid signature",T="zipjs-abort-check-password";function V(e){return P?f.getRandomValues(e):R.getRandomValues(e)}const x=16,E={name:"PBKDF2"},U=t.assign({hash:{name:"HMAC"}},E),W=t.assign({iterations:1e3,hash:{name:"SHA-1"}},E),M=["deriveBits"],N=[8,12,16],O=[16,24,32],L=10,F=[0,0,0,0],j=typeof f!=S,G=j&&f.subtle,X=j&&typeof G!=S,J=A.bytes,Q=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],s=t._tables[1],a=e.length;let o,i,c,l=1;if(4!==a&&6!==a&&8!==a)throw new r("invalid aes key size");for(t._key=[i=e.slice(0),c=[]],o=a;4*a+28>o;o++){let e=i[o-1];(o%a===0||8===a&&o%a===4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],o%a===0&&(e=e<<8^e>>>24^l<<24,l=l<<1^283*(l>>7))),i[o]=i[o-a]^e}for(let e=0;o;e++,o--){const t=i[3&e?o:o-4];c[e]=4>=o||4>e?t:s[0][n[t>>>24]]^s[1][n[t>>16&255]]^s[2][n[t>>8&255]]^s[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],s=t[4],r=[],a=[];let o,i,c,l;for(let e=0;256>e;e++)a[(r[e]=e<<1^283*(e>>7))^e]=e;for(let u=o=0;!n[u];u^=i||1,o=a[o]||1){let a=o^o<<1^o<<2^o<<3^o<<4;a=a>>8^255&a^99,n[u]=a,s[a]=u,l=r[c=r[i=r[u]]];let h=16843009*l^65537*c^257*i^16843008*u,p=257*r[a]^16843008*a;for(let n=0;4>n;n++)e[n][u]=p=p<<24^p>>>8,t[n][a]=h=h<<24^h>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new r("invalid aes block size");const n=this._key[t],s=n.length/4-2,a=[0,0,0,0],o=this._tables[t],i=o[0],c=o[1],l=o[2],u=o[3],h=o[4];let p,f,d,g=e[0]^n[0],w=e[t?3:1]^n[1],y=e[2]^n[2],m=e[t?1:3]^n[3],_=4;for(let e=0;s>e;e++)p=i[g>>>24]^c[w>>16&255]^l[y>>8&255]^u[255&m]^n[_],f=i[w>>>24]^c[y>>16&255]^l[m>>8&255]^u[255&g]^n[_+1],d=i[y>>>24]^c[m>>16&255]^l[g>>8&255]^u[255&w]^n[_+2],m=i[m>>>24]^c[g>>16&255]^l[w>>8&255]^u[255&y]^n[_+3],_+=4,g=p,w=f,y=d;for(let e=0;4>e;e++)a[t?3&-e:e]=h[g>>>24]<<24^h[w>>16&255]<<16^h[y>>8&255]<<8^h[255&m]^n[_++],p=g,g=w,w=y,y=m,m=p;return a}},Y=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255&~(e>>24))e+=1<<24;else{let t=e>>16&255,n=e>>8&255,s=255&e;255===t?(t=0,255===n?(n=0,255===s?s=0:++s):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=s}return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let s;if(!(s=t.length))return[];const r=I.bitLength(t);for(let r=0;s>r;r+=4){this.incCounter(n);const s=e.encrypt(n);t[r]^=s[0],t[r+1]^=s[1],t[r+2]^=s[2],t[r+3]^=s[3]}return I.clamp(t,r)}},Z=H.hmacSha1;let $=j&&X&&typeof G.importKey==v,ee=j&&X&&typeof G.deriveBits==v;class te extends g{constructor({password:e,rawPassword:n,signed:s,encryptionStrength:o,checkPasswordOnly:i}){super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:ae(e,n),signed:s,strength:o-1,pending:new a})},async transform(e,t){const n=this,{password:s,strength:o,resolveReady:c,ready:l}=n;s?(await(async(e,t,n,s)=>{const a=await re(e,t,n,ie(s,0,N[t])),o=ie(s,N[t]);if(a[0]!=o[0]||a[1]!=o[1])throw new r(B)})(n,o,s,ie(e,0,N[o]+2)),e=ie(e,N[o]+2),i?t.error(new r(T)):c()):await l;const u=new a(e.length-L-(e.length-L)%x);t.enqueue(se(n,e,u,0,L,!0))},async flush(e){const{signed:t,ctr:n,hmac:s,pending:o,ready:i}=this;if(s&&n){await i;const c=ie(o,0,o.length-L),l=ie(o,o.length-L);let u=new a;if(c.length){const e=le(J,c);s.update(e);const t=n.update(e);u=ce(J,t)}if(t){const e=ie(ce(J,s.digest()),0,L);for(let t=0;L>t;t++)if(e[t]!=l[t])throw new r(K)}e.enqueue(u)}}})}}class ne extends g{constructor({password:e,rawPassword:n,encryptionStrength:s}){let r;super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:ae(e,n),strength:s-1,pending:new a})},async transform(e,t){const n=this,{password:s,strength:r,resolveReady:o,ready:i}=n;let c=new a;s?(c=await(async(e,t,n)=>{const s=V(new a(N[t]));return oe(s,await re(e,t,n,s))})(n,r,s),o()):await i;const l=new a(c.length+e.length-e.length%x);l.set(c,0),t.enqueue(se(n,e,l,c.length,0))},async flush(e){const{ctr:t,hmac:n,pending:s,ready:o}=this;if(n&&t){await o;let i=new a;if(s.length){const e=t.update(le(J,s));n.update(e),i=ce(J,e)}r.signature=ce(J,n.digest()).slice(0,L),e.enqueue(oe(i,r.signature))}}}),r=this}}function se(e,t,n,s,r,o){const{ctr:i,hmac:c,pending:l}=e,u=t.length-r;let h;for(l.length&&(t=oe(l,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new a(t)).set(n,0)}return e})(n,u-u%x)),h=0;u-x>=h;h+=x){const e=le(J,ie(t,h,h+x));o&&c.update(e);const r=i.update(e);o||c.update(r),n.set(ce(J,r),h+s)}return e.pending=ie(t,h),n}async function re(n,s,r,o){n.password=null;const i=await(async(e,t,n,s,r)=>{if(!$)return H.importKey(t);try{return await G.importKey("raw",t,n,!1,r)}catch(e){return $=!1,H.importKey(t)}})(0,r,U,0,M),c=await(async(e,t,n)=>{if(!ee)return H.pbkdf2(t,e.salt,W.iterations,n);try{return await G.deriveBits(e,t,n)}catch(s){return ee=!1,H.pbkdf2(t,e.salt,W.iterations,n)}})(t.assign({salt:o},W),i,8*(2*O[s]+2)),l=new a(c),u=le(J,ie(l,0,O[s])),h=le(J,ie(l,O[s],2*O[s])),p=ie(l,2*O[s]);return t.assign(n,{keys:{key:u,authentication:h,passwordVerification:p},ctr:new Y(new Q(u),e.from(F)),hmac:new Z(h)}),p}function ae(e,t){return t===b?(e=>{if(typeof p==S){const t=new a((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new p).encode(e)})(e):t}function oe(e,t){let n=e;return e.length+t.length&&(n=new a(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function ie(e,t,n){return e.subarray(t,n)}function ce(e,t){return e.fromBits(t)}function le(e,t){return e.toBits(t)}class ue extends g{constructor({password:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){t.assign(this,{password:e,passwordVerification:n}),de(this,e)},transform(e,t){const n=this;if(n.password){const t=pe(n,e.subarray(0,12));if(n.password=null,t.at(-1)!=n.passwordVerification)throw new r(B);e=e.subarray(12)}s?t.error(new r(T)):t.enqueue(pe(n,e))}})}}class he extends g{constructor({password:e,passwordVerification:n}){super({start(){t.assign(this,{password:e,passwordVerification:n}),de(this,e)},transform(e,t){const n=this;let s,r;if(n.password){n.password=null;const t=V(new a(12));t[11]=n.passwordVerification,s=new a(e.length+t.length),s.set(fe(n,t),0),r=12}else s=new a(e.length),r=0;s.set(fe(n,e),r),t.enqueue(s)}})}}function pe(e,t){const n=new a(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],ge(e,n[s]);return n}function fe(e,t){const n=new a(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],ge(e,t[s]);return n}function de(e,n){const s=[305419896,591751049,878082192];t.assign(e,{keys:s,crcKey0:new D(s[0]),crcKey2:new D(s[2])});for(let t=0;t<n.length;t++)ge(e,n.charCodeAt(t))}function ge(e,t){let[n,r,a]=e.keys;e.crcKey0.append([t]),n=~e.crcKey0.get(),r=me(s.imul(me(r+ye(n)),134775813)+1),e.crcKey2.append([r>>>24]),a=~e.crcKey2.get(),e.keys=[n,r,a]}function we(e){const t=2|e.keys[2];return ye(s.imul(t,1^t)>>>8)}function ye(e){return 255&e}function me(e){return 4294967295&e}const _e="deflate-raw";class be extends g{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:s}){super({});const{compressed:r,encrypted:a,useCompressionStream:o,zipCrypto:i,signed:c,level:l}=e,h=this;let p,f,d=super.readable;a&&!i||!c||(p=new C,d=ze(d,p)),r&&(d=ke(d,o,{level:l,chunkSize:t},s,n)),a&&(i?d=ze(d,new he(e)):(f=new ne(e),d=ze(d,f))),ve(h,d,()=>{let e;a&&!i&&(e=f.signature),a&&!i||!c||(e=new u(p.value.buffer).getUint32(0)),h.signature=e})}}class Se extends g{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:s}){super({});const{zipCrypto:a,encrypted:o,signed:i,signature:c,compressed:l,useCompressionStream:h}=e;let p,f,d=super.readable;o&&(a?d=ze(d,new ue(e)):(f=new te(e),d=ze(d,f))),l&&(d=ke(d,h,{chunkSize:t},s,n)),o&&!a||!i||(p=new C,d=ze(d,p)),ve(this,d,()=>{if((!o||a)&&i){const e=new u(p.value.buffer);if(c!=e.getUint32(0,!1))throw new r(K)}})}}function ve(e,n,s){n=ze(n,new g({flush:s})),t.defineProperty(e,"readable",{get:()=>n})}function ke(e,t,n,s,r){try{e=ze(e,new(t&&s?s:r)(_e,n))}catch(s){if(!t)throw s;e=ze(e,new r(_e,n))}return e}function ze(e,t){return e.pipeThrough(t)}const De="data",Ce="close";class Ie extends g{constructor(e,n){super({});const s=this,{codecType:a}=e;let o;a.startsWith("deflate")?o=be:a.startsWith("inflate")&&(o=Se),s.outputSize=0;let i=0;const c=new o(e,n),l=super.readable,u=new g({transform(e,t){e&&e.length&&(i+=e.length,t.enqueue(e))},flush(){t.assign(s,{inputSize:i})}}),h=new g({transform(t,n){if(t&&t.length&&(n.enqueue(t),s.outputSize+=t.length,e.outputSize&&s.outputSize>e.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:e}=c;t.assign(s,{signature:e,inputSize:i})}});t.defineProperty(s,"readable",{get:()=>l.pipeThrough(u).pipeThrough(c).pipeThrough(h)})}}class Ae extends g{constructor(e){let t;super({transform:function n(s,r){if(t){const e=new a(t.length+s.length);e.set(t),e.set(s,t.length),s=e,t=null}s.length>e?(r.enqueue(s.slice(0,e)),n(s.slice(e),r)):t=s},flush(e){t&&t.length&&e.enqueue(t)}})}}const qe=new l,Re=new l;let He,Pe=0,Be=!0;async function Ke(e){try{const{options:t,scripts:s,config:r}=e;if(s&&s.length)try{Be?importScripts.apply(b,s):await Te(s)}catch(e){Be=!1,await Te(s)}self.initCodec&&self.initCodec(),r.CompressionStreamNative=self.CompressionStream,r.DecompressionStreamNative=self.DecompressionStream,self.Deflate&&(r.CompressionStream=new k(self.Deflate)),self.Inflate&&(r.DecompressionStream=new k(self.Inflate));const a={highWaterMark:1},o=e.readable||new w({async pull(e){const t=new h(e=>qe.set(Pe,e));Ve({type:"pull",messageId:Pe}),Pe=(Pe+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await t;e.enqueue(s),r&&e.close()}},a),i=e.writable||new y({async write(e){let t;const s=new h(e=>t=e);Re.set(Pe,t),Ve({type:De,value:e,messageId:Pe}),Pe=(Pe+1)%n.MAX_SAFE_INTEGER,await s}},a),c=new Ie(t,r);He=new AbortController;const{signal:l}=He;await o.pipeThrough(c).pipeThrough(new Ae(r.chunkSize)).pipeTo(i,{signal:l,preventClose:!0,preventAbort:!0}),await i.getWriter().close();const{signature:u,inputSize:p,outputSize:f}=c;Ve({type:Ce,result:{signature:u,inputSize:p,outputSize:f}})}catch(e){e.outputSize=0,xe(e)}}async function Te(e){for(const t of e)await import(t)}function Ve(e){let{value:t}=e;if(t)if(t.length)try{t=new a(t),e.value=t.buffer,d(e,[e.value])}catch(t){d(e)}else d(e);else d(e)}function xe(e=new r("Unknown error")){const{message:t,stack:n,code:s,name:a,outputSize:o}=e;d({error:{message:t,stack:n,code:s,name:a,outputSize:o}})}function Ee(e,n,s){return class{constructor(r){const o=this;var i,c;i=r,c="level",(typeof t.hasOwn===v?t.hasOwn(i,c):i.hasOwnProperty(c))&&r.level===b&&delete r.level,o.codec=new e(t.assign({},n,r)),s(o.codec,e=>{if(o.pendingData){const t=o.pendingData;o.pendingData=new a(t.length+e.length);const{pendingData:n}=o;n.set(t,0),n.set(e,t.length)}else o.pendingData=new a(e)})}append(e){return this.codec.push(e),r(this)}flush(){return this.codec.push(new a,!0),r(this)}};function r(e){if(e.pendingData){const t=e.pendingData;return e.pendingData=null,t}return new a}}addEventListener("message",({data:e})=>{const{type:t,messageId:n,value:s,done:r}=e;try{if("start"==t&&Ke(e),t==De){const e=qe.get(n);qe.delete(n),e({value:new a(s),done:r})}if("ack"==t){const e=Re.get(n);Re.delete(n),e()}t==Ce&&He.abort()}catch(e){xe(e)}}),self.initCodec=()=>{const{Deflate:e,Inflate:t}=((e,t={},n)=>({Deflate:Ee(e.Deflate,t.deflate,n),Inflate:Ee(e.Inflate,t.inflate,n)}))(pako,{deflate:{raw:!0},inflate:{raw:!0}},(e,t)=>e.onData=t);self.Deflate=e,self.Inflate=t}}();