@vertexvis/viewer 1.1.1-canary.6 → 1.1.1-testing.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 (170) hide show
  1. package/dist/cjs/{config-Ca0seD16.js → config-qhB9yOkD.js} +3 -3
  2. package/dist/cjs/{config-Ca0seD16.js.map → config-qhB9yOkD.js.map} +1 -1
  3. package/dist/cjs/{entities-CBN2BJKd.js → entities-OgE3KKMo.js} +4 -4
  4. package/dist/cjs/{entities-CBN2BJKd.js.map → entities-OgE3KKMo.js.map} +1 -1
  5. package/dist/cjs/{geometry_pb-DS0HM8ls.js → geometry_pb-CJZxK0hh.js} +3 -3
  6. package/dist/cjs/{geometry_pb-DS0HM8ls.js.map → geometry_pb-CJZxK0hh.js.map} +1 -1
  7. package/dist/cjs/index.cjs.js +5 -5
  8. package/dist/cjs/{png-decoder-Dt3IOAnw.js → png-decoder-BTtMRfiW.js} +23 -32
  9. package/dist/cjs/png-decoder-BTtMRfiW.js.map +1 -0
  10. package/dist/cjs/{queries-B4oPQ5xP.js → queries-DvkzwhnO.js} +4 -4
  11. package/dist/cjs/{queries-B4oPQ5xP.js.map → queries-DvkzwhnO.js.map} +1 -1
  12. package/dist/cjs/{regl-component-DDHBbHhG.js → regl-component-Ctuzdy_i.js} +3 -3
  13. package/dist/cjs/{regl-component-DDHBbHhG.js.map → regl-component-Ctuzdy_i.js.map} +1 -1
  14. package/dist/cjs/{representation_pb-_-8GOu4g.js → representation_pb-Cb20_8yP.js} +3 -3
  15. package/dist/cjs/{representation_pb-_-8GOu4g.js.map → representation_pb-Cb20_8yP.js.map} +1 -1
  16. package/dist/cjs/{streamAttributes-D4FScmnu.js → streamAttributes-BOGFM4R7.js} +3 -3
  17. package/dist/cjs/{streamAttributes-D4FScmnu.js.map → streamAttributes-BOGFM4R7.js.map} +1 -1
  18. package/dist/cjs/tslib.es6-BqRXrZGq.js +40 -0
  19. package/dist/cjs/{tslib.es6-Bu5Kp4WX.js.map → tslib.es6-BqRXrZGq.js.map} +1 -1
  20. package/dist/cjs/vertex-scene-tree-notification-banner_4.cjs.entry.js +1 -1
  21. package/dist/cjs/vertex-scene-tree-table-cell.cjs.entry.js +1 -1
  22. package/dist/cjs/vertex-scene-tree.cjs.entry.js +2 -2
  23. package/dist/cjs/vertex-viewer-dom-element_2.cjs.entry.js +1 -1
  24. package/dist/cjs/vertex-viewer-hit-result-indicator.cjs.entry.js +2 -2
  25. package/dist/cjs/vertex-viewer-measurement-details.cjs.entry.js +3 -3
  26. package/dist/cjs/vertex-viewer-measurement-distance.cjs.entry.js +2 -2
  27. package/dist/cjs/vertex-viewer-measurement-line_2.cjs.entry.js +2 -2
  28. package/dist/cjs/vertex-viewer-measurement-precise.cjs.entry.js +4 -4
  29. package/dist/cjs/vertex-viewer-pin-group.cjs.entry.js +3 -3
  30. package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js +2 -2
  31. package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +1 -1
  32. package/dist/cjs/vertex-viewer.cjs.entry.js +4 -4
  33. package/dist/components/index.js +1 -1
  34. package/dist/components/{p-Tfg7jao4.js → p-B1EwHtiU.js} +2 -2
  35. package/dist/components/p-C-NyjLsm.js +5 -0
  36. package/dist/components/p-C-NyjLsm.js.map +1 -0
  37. package/dist/components/{p-Be_EPOMu.js → p-CNDZjNd7.js} +2 -2
  38. package/dist/components/{p-BNanw3eX.js → p-C_5cRYhA.js} +2 -2
  39. package/dist/components/{p-C-Mdlx-o.js → p-CkYfi_b3.js} +2 -2
  40. package/dist/components/{p-BQQxciHe.js → p-Dks3EzBM.js} +2 -2
  41. package/dist/components/{p-DCxPi7ft.js → p-IbLMJcql.js} +2 -2
  42. package/dist/components/{p-B3jZXFq2.js → p-XydgrVf-.js} +2 -2
  43. package/dist/components/p-Z7U3o7I4.js +5 -0
  44. package/dist/components/{p-Cta7kB-G.js → p-ZzS5zTnx.js} +2 -2
  45. package/dist/components/p-fKH0aLlq.js +5 -0
  46. package/dist/components/p-fKH0aLlq.js.map +1 -0
  47. package/dist/components/{p-C6BUwWB4.js → p-hMIHFP5Q.js} +2 -2
  48. package/dist/components/{p-DpQErze2.js → p-sPEu8FHr.js} +2 -2
  49. package/dist/components/vertex-scene-tree-table-cell.js +1 -1
  50. package/dist/components/vertex-scene-tree-table-layout.js +1 -1
  51. package/dist/components/vertex-scene-tree.js +1 -1
  52. package/dist/components/vertex-viewer-dom-renderer.js +1 -1
  53. package/dist/components/vertex-viewer-hit-result-indicator.js +1 -1
  54. package/dist/components/vertex-viewer-measurement-details.js +1 -1
  55. package/dist/components/vertex-viewer-measurement-distance.js +1 -1
  56. package/dist/components/vertex-viewer-measurement-overlays.js +1 -1
  57. package/dist/components/vertex-viewer-measurement-precise.js +1 -1
  58. package/dist/components/vertex-viewer-pin-group.js +1 -1
  59. package/dist/components/vertex-viewer-pin-tool.js +1 -1
  60. package/dist/components/vertex-viewer-transform-widget.js +1 -1
  61. package/dist/components/vertex-viewer-transform-widget.js.map +1 -1
  62. package/dist/components/vertex-viewer-view-cube.js +1 -1
  63. package/dist/components/vertex-viewer.js +1 -1
  64. package/dist/esm/{config-BHITDQif.js → config-Dukl2tlT.js} +3 -3
  65. package/dist/esm/{config-BHITDQif.js.map → config-Dukl2tlT.js.map} +1 -1
  66. package/dist/esm/{entities-Cj9Pt10J.js → entities-2kVCQNVh.js} +4 -4
  67. package/dist/esm/{entities-Cj9Pt10J.js.map → entities-2kVCQNVh.js.map} +1 -1
  68. package/dist/esm/{geometry_pb-EePgefLR.js → geometry_pb-CAxktHWj.js} +3 -3
  69. package/dist/esm/{geometry_pb-EePgefLR.js.map → geometry_pb-CAxktHWj.js.map} +1 -1
  70. package/dist/esm/index.js +5 -5
  71. package/dist/esm/{png-decoder-gMslGChA.js → png-decoder-Dx1E5Sod.js} +23 -32
  72. package/dist/esm/png-decoder-Dx1E5Sod.js.map +1 -0
  73. package/dist/esm/{queries-CEfTZHMm.js → queries-DM84n6se.js} +4 -4
  74. package/dist/esm/{queries-CEfTZHMm.js.map → queries-DM84n6se.js.map} +1 -1
  75. package/dist/esm/{regl-component-DXn0jg5S.js → regl-component-D-Wlx_GA.js} +3 -3
  76. package/dist/esm/{regl-component-DXn0jg5S.js.map → regl-component-D-Wlx_GA.js.map} +1 -1
  77. package/dist/esm/{representation_pb-DdXEMKrs.js → representation_pb-ZzJjYuoD.js} +3 -3
  78. package/dist/esm/{representation_pb-DdXEMKrs.js.map → representation_pb-ZzJjYuoD.js.map} +1 -1
  79. package/dist/esm/{streamAttributes-BZnxWMmW.js → streamAttributes-C2mLVHk_.js} +3 -3
  80. package/dist/esm/{streamAttributes-BZnxWMmW.js.map → streamAttributes-C2mLVHk_.js.map} +1 -1
  81. package/dist/esm/tslib.es6-C-NyjLsm.js +40 -0
  82. package/dist/esm/{tslib.es6-BzyVljQN.js.map → tslib.es6-C-NyjLsm.js.map} +1 -1
  83. package/dist/esm/vertex-scene-tree-notification-banner_4.entry.js +1 -1
  84. package/dist/esm/vertex-scene-tree-table-cell.entry.js +1 -1
  85. package/dist/esm/vertex-scene-tree.entry.js +2 -2
  86. package/dist/esm/vertex-viewer-dom-element_2.entry.js +1 -1
  87. package/dist/esm/vertex-viewer-hit-result-indicator.entry.js +2 -2
  88. package/dist/esm/vertex-viewer-measurement-details.entry.js +3 -3
  89. package/dist/esm/vertex-viewer-measurement-distance.entry.js +2 -2
  90. package/dist/esm/vertex-viewer-measurement-line_2.entry.js +2 -2
  91. package/dist/esm/vertex-viewer-measurement-precise.entry.js +4 -4
  92. package/dist/esm/vertex-viewer-pin-group.entry.js +3 -3
  93. package/dist/esm/vertex-viewer-transform-widget.entry.js +2 -2
  94. package/dist/esm/vertex-viewer-view-cube.entry.js +1 -1
  95. package/dist/esm/vertex-viewer.entry.js +4 -4
  96. package/dist/viewer/index.esm.js +1 -1
  97. package/dist/viewer/{p-ad4c1175.entry.js → p-08b86996.entry.js} +2 -2
  98. package/dist/viewer/{p-b4bbbebf.entry.js → p-10c40a5e.entry.js} +2 -2
  99. package/dist/viewer/{p-ef596c04.entry.js → p-17e47830.entry.js} +2 -2
  100. package/dist/viewer/{p-ec49e818.entry.js → p-195297bb.entry.js} +2 -2
  101. package/dist/viewer/{p-994602a4.entry.js → p-37a7cbe4.entry.js} +2 -2
  102. package/dist/viewer/{p-9dd4a49a.entry.js → p-484e6990.entry.js} +2 -2
  103. package/dist/viewer/{p-ffd28212.entry.js → p-4a3a05c7.entry.js} +2 -2
  104. package/dist/viewer/{p-210f1777.entry.js → p-515eefc1.entry.js} +2 -2
  105. package/dist/viewer/{p-bfe38f9b.entry.js → p-91b6f9de.entry.js} +2 -2
  106. package/dist/viewer/{p-c46bf3b1.entry.js → p-9386f89b.entry.js} +2 -2
  107. package/dist/viewer/{p-75EpAVwy.js → p-Bi9f5zZC.js} +2 -2
  108. package/dist/viewer/{p-75EpAVwy.js.map → p-Bi9f5zZC.js.map} +1 -1
  109. package/dist/viewer/p-C-NyjLsm.js +5 -0
  110. package/dist/viewer/{p-BzyVljQN.js.map → p-C-NyjLsm.js.map} +1 -1
  111. package/dist/viewer/{p-CT1PhiRV.js → p-CD3U7s8H.js} +2 -2
  112. package/dist/viewer/{p-CT1PhiRV.js.map → p-CD3U7s8H.js.map} +1 -1
  113. package/dist/viewer/{p-BFQ1Tt4Y.js → p-Dl2B5rCE.js} +2 -2
  114. package/dist/viewer/{p-BFQ1Tt4Y.js.map → p-Dl2B5rCE.js.map} +1 -1
  115. package/dist/{components/p-CMBmMRkF.js → viewer/p-Dt9-9vSd.js} +2 -2
  116. package/dist/viewer/{p-BIj2SAwD.js.map → p-Dt9-9vSd.js.map} +1 -1
  117. package/dist/viewer/{p-CT3sclrO.js → p-P0ZprdA-.js} +2 -2
  118. package/dist/viewer/{p-CT3sclrO.js.map → p-P0ZprdA-.js.map} +1 -1
  119. package/dist/viewer/{p-2bb26337.entry.js → p-ae4ec0a8.entry.js} +2 -2
  120. package/dist/viewer/{p-e00839cd.entry.js → p-d709a094.entry.js} +2 -2
  121. package/dist/viewer/{p-7cb94735.entry.js → p-ef02ec4c.entry.js} +2 -2
  122. package/dist/viewer/p-fKH0aLlq.js +5 -0
  123. package/dist/viewer/p-fKH0aLlq.js.map +1 -0
  124. package/dist/viewer/{p-BnXUpT0J.js → p-fXz1xKOD.js} +2 -2
  125. package/dist/viewer/{p-BnXUpT0J.js.map → p-fXz1xKOD.js.map} +1 -1
  126. package/dist/viewer/{p-D4OO4AF0.js → p-vWHX2QSb.js} +2 -2
  127. package/dist/viewer/{p-D4OO4AF0.js.map → p-vWHX2QSb.js.map} +1 -1
  128. package/dist/viewer/viewer.esm.js +1 -1
  129. package/package.json +32 -32
  130. package/dist/cjs/package.json +0 -3
  131. package/dist/cjs/png-decoder-Dt3IOAnw.js.map +0 -1
  132. package/dist/cjs/tslib.es6-Bu5Kp4WX.js +0 -92
  133. package/dist/components/p-BzyVljQN.js +0 -5
  134. package/dist/components/p-BzyVljQN.js.map +0 -1
  135. package/dist/components/p-DaLbXlOV.js +0 -5
  136. package/dist/components/p-DaLbXlOV.js.map +0 -1
  137. package/dist/esm/index.mjs +0 -106
  138. package/dist/esm/loader.mjs +0 -16
  139. package/dist/esm/png-decoder-gMslGChA.js.map +0 -1
  140. package/dist/esm/tslib.es6-BzyVljQN.js +0 -88
  141. package/dist/index.cjs +0 -1
  142. package/dist/viewer/p-BIj2SAwD.js +0 -5
  143. package/dist/viewer/p-BzyVljQN.js +0 -5
  144. package/dist/viewer/p-DaLbXlOV.js +0 -5
  145. package/dist/viewer/p-DaLbXlOV.js.map +0 -1
  146. package/loader/index.cjs +0 -4
  147. /package/dist/components/{p-Tfg7jao4.js.map → p-B1EwHtiU.js.map} +0 -0
  148. /package/dist/components/{p-Be_EPOMu.js.map → p-CNDZjNd7.js.map} +0 -0
  149. /package/dist/components/{p-BNanw3eX.js.map → p-C_5cRYhA.js.map} +0 -0
  150. /package/dist/components/{p-C-Mdlx-o.js.map → p-CkYfi_b3.js.map} +0 -0
  151. /package/dist/components/{p-BQQxciHe.js.map → p-Dks3EzBM.js.map} +0 -0
  152. /package/dist/components/{p-DCxPi7ft.js.map → p-IbLMJcql.js.map} +0 -0
  153. /package/dist/components/{p-B3jZXFq2.js.map → p-XydgrVf-.js.map} +0 -0
  154. /package/dist/components/{p-CMBmMRkF.js.map → p-Z7U3o7I4.js.map} +0 -0
  155. /package/dist/components/{p-Cta7kB-G.js.map → p-ZzS5zTnx.js.map} +0 -0
  156. /package/dist/components/{p-C6BUwWB4.js.map → p-hMIHFP5Q.js.map} +0 -0
  157. /package/dist/components/{p-DpQErze2.js.map → p-sPEu8FHr.js.map} +0 -0
  158. /package/dist/viewer/{p-ad4c1175.entry.js.map → p-08b86996.entry.js.map} +0 -0
  159. /package/dist/viewer/{p-b4bbbebf.entry.js.map → p-10c40a5e.entry.js.map} +0 -0
  160. /package/dist/viewer/{p-ef596c04.entry.js.map → p-17e47830.entry.js.map} +0 -0
  161. /package/dist/viewer/{p-ec49e818.entry.js.map → p-195297bb.entry.js.map} +0 -0
  162. /package/dist/viewer/{p-994602a4.entry.js.map → p-37a7cbe4.entry.js.map} +0 -0
  163. /package/dist/viewer/{p-9dd4a49a.entry.js.map → p-484e6990.entry.js.map} +0 -0
  164. /package/dist/viewer/{p-ffd28212.entry.js.map → p-4a3a05c7.entry.js.map} +0 -0
  165. /package/dist/viewer/{p-210f1777.entry.js.map → p-515eefc1.entry.js.map} +0 -0
  166. /package/dist/viewer/{p-bfe38f9b.entry.js.map → p-91b6f9de.entry.js.map} +0 -0
  167. /package/dist/viewer/{p-c46bf3b1.entry.js.map → p-9386f89b.entry.js.map} +0 -0
  168. /package/dist/viewer/{p-2bb26337.entry.js.map → p-ae4ec0a8.entry.js.map} +0 -0
  169. /package/dist/viewer/{p-e00839cd.entry.js.map → p-d709a094.entry.js.map} +0 -0
  170. /package/dist/viewer/{p-7cb94735.entry.js.map → p-ef02ec4c.entry.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import{h as i,r as t,c as s,H as n,a as o}from"./p-CCVkga9Q.js";import{p as l,v as h,r as e,b as r,a,m as d,h as u,g as v,q as c,e as f,c as w}from"./p-B8a9KIE8.js";import{c as p}from"./p-Dw4-tG-V.js";import{w as x,r as g}from"./p-BxtKMwBH.js";import{T as y}from"./p-IU78UvWI.js";import{A as m,D as b}from"./p-CT1PhiRV.js";import"./p-BAhfr1Nx.js";import{E as z}from"./p-IVh_3-KN.js";import{d as T,T as C,R as D,e as R,r as A,s as P,x as E,A as S,b as I,y as j,z as N,f as U,g as H,h as O,i as V,j as $}from"./p-75EpAVwy.js";import"./p-CG9AChtV.js";import"./p-B4qVkXXt.js";import"./p-D3weipcV.js";import"./p-D3hmsz_I.js";function B(i){if(window.document.activeElement!==i){i.focus();i.setSelectionRange(i.value.length,i.value.length)}}function k(i,t){return t!=null?l.create(i.x-t.left,i.y-t.top):undefined}function F(i,t,s,n){const o=n!=null?h.fromMatrixPosition(n):undefined;if(i!=null&&t!=null&&s!=null&&o!=null){const n=s.transformPointToRay(i,t.image,t.scene.camera);if(t.scene.camera.isOrthographic()){const i=e.at(e.create({origin:o,direction:t.scene.camera.direction}),h.magnitude(t.scene.camera.viewVector)*2);return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,i))}else{return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,o))}}return undefined}function M(i,t,s,n,o,l){return d.multiply(_(t,s,n,o,l),i)}function _(i,t,s,n,o){const l=new b(n);const e=new m(o);const r=()=>e.convertFrom(t-s);const a=()=>l.convertRealValueToWorld(t-s);switch(i){case"x-translate":return d.makeTranslation(h.create(a(),0,0));case"y-translate":return d.makeTranslation(h.create(0,a(),0));case"z-translate":return d.makeTranslation(h.create(0,0,a()));case"x-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.left(),r())));case"y-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.down(),r())));case"z-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.forward(),r())));default:return d.makeIdentity()}}function q(i){switch(i){case"x-rotate":return"xyz";case"y-rotate":return"yzx";case"z-rotate":return"zxy";default:return"xyz"}}function J(i,t,s,n,o){const l=new b(n);const e=new m(o);const r=()=>d.makeRotation(c.fromMatrixRotation(t));const v=()=>d.multiply(d.invert(s),t);const f=()=>h.multiplyByTransformMatrixColumnMajor(h.fromMatrixPosition(v()),r());const w=()=>u.fromRotationMatrix(d.multiply(s,r()),q(i));switch(i){case"x-translate":return l.convertWorldValueToReal(f().x);case"y-translate":return l.convertWorldValueToReal(f().y);case"z-translate":return l.convertWorldValueToReal(f().z);case"x-rotate":return e.convertTo(a.normalizeRadians(w().x));case"y-rotate":return e.convertTo(a.normalizeRadians(w().y));case"z-rotate":return e.convertTo(a.normalizeRadians(w().z));default:return 0}}function K(i,t,s,n,o,l){return X(i,h.subtract(s,t),n,o,l)}function X(i,t,s,n,o){switch(o){case"x-translate":return Y(i,t,h.right());case"y-translate":return Y(i,t,h.up());case"z-translate":return Y(i,t,h.back());case"xy-translate":return Z(i,t,h.create(0,0,1));case"xz-translate":return Z(i,t,h.create(0,1,0));case"yz-translate":return Z(i,t,h.create(1,0,0));case"x-rotate":return L(i,s,h.right(),n);case"y-rotate":return L(i,s,h.up(),n);case"z-rotate":return L(i,s,h.forward(),n);default:return i}}function L(i,t,s,n){const o=G(i,t,s);const l=c.fromAxisAngle(o,n);const h=d.transpose(d.makeRotation(l));return d.multiply(h,i)}function G(i,t,s){const n=d.makeRotation(c.fromMatrixRotation(i));const o=h.multiplyByTransformMatrixRowMajor(s,n);const l=h.multiplyByTransformMatrixRowMajor(h.negate(s),n);return h.dot(t,o)>h.dot(t,l)?s:h.negate(s)}function Y(i,t,s){const n=h.normalize(s);const o=d.makeRotation(c.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.project(t,l);const r=d.makeTranslation(e);return d.multiply(i,r)}function Z(i,t,s){const n=h.normalize(s);const o=d.makeRotation(c.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.fromMatrixPosition(i);const a=r.fromNormalAndCoplanarPoint(l,e);const u=r.projectPoint(a,t);const v=h.add(u,h.scale(a.constant,a.normal));const f=d.makeTranslation(v);return d.multiply(i,f)}function Q(i,t,s){if(s.length===0){throw new Error("Unable to compute input position. At least one shape point must be provided.")}const n=v.pad(t,5);const o=s.map((t=>i.transformNdcPointToViewport(t)));const h=v.topLeft(n);const e=l.add(h,l.create(n.width,0));const r=v.bottomRight(n);const a=l.subtract(r,l.create(n.width,0));const d=l.scale(o.reduce(((i,t)=>l.add(i,t)),l.create()),1/o.length,1/o.length);const u=[e,a,r].reduce(((i,t)=>l.distance(d,t)<l.distance(d,i)?t:i),h);switch(u){case h:return{point:u,placement:"top-left"};case e:return{point:u,placement:"top-right"};case a:return{point:u,placement:"bottom-left"};default:return{point:u,placement:"bottom-right"}}}function W(i,t,s,n,o,l){const h=t==="alt"&&i.altKey||t==="ctrl"&&i.ctrlKey||t==="meta"&&i.metaKey||t==="shift"&&i.shiftKey;if(h&&l!=null&&l>0&&Number.isInteger(l)){const i=s-n;const t=a.toDegrees(i);const h=Math.round(t/l)*l;if(o!=null){const i=Math.round(o/l)*l;const t=o-i;const s=h-t;const e=a.toRadians(s);return e+n}else{const i=a.toRadians(h);return i+n}}else{return s}}const ii=({ref:t,bounds:s,viewport:n,point:o,placement:l,displayUnit:h},e)=>{const r=ni(n,s!==null&&s!==void 0?s:f.create(0,0),o,l);return i("div",{ref:t,class:"widget-input wrapper",style:{...r,height:(s===null||s===void 0?void 0:s.height)!=null?`${s.height}px`:undefined}},e,i("div",{class:"widget-input units"},h.unit.abbreviatedName))};const ti=({ref:t,identifier:s,disabled:n,onChange:o,onIncrement:l,onDecrement:h,onBlur:e,onUndo:r})=>{const a=i=>{if(i.target!=null){const t=Number.parseFloat(i.target.value);if(!Number.isNaN(t)){o===null||o===void 0?void 0:o(Number.parseFloat(i.target.value))}}};const d=i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="ArrowUp"){l===null||l===void 0?void 0:l()}else if(i.key==="ArrowDown"){h===null||h===void 0?void 0:h()}else if(i.key==="z"&&t&&r){i.preventDefault();r()}};return i("input",{ref:t,disabled:n,class:`widget-input ${s}`,type:"text",onChange:a,onKeyDown:d,onBlur:e})};function si(i,t){return Math.min(i,Math.max(0,t))}function ni(i,t,s,n,o=5){const{width:l,height:h}=i.dimensions;const e=t.width+o;const r=t.height+o;function a(i){return`${i}px`}switch(n){case"top-left":return{right:a(si(l-e,l-s.x)),bottom:a(si(h-r,h-s.y))};case"top-right":return{left:a(si(l-e,s.x)),bottom:a(si(h-r,h-s.y))};case"bottom-left":return{right:a(si(l-e,l-s.x)),top:a(si(h-r,s.y))};case"bottom-right":default:return{left:a(si(l-e,s.x)),top:a(si(h-r,s.y))}}}function oi(i,t,s=3,n=1,o=1){return ei(i,t,h.back(),h.up(),s,n,o)}function li(i,t,s=3,n=1,o=1){return ei(i,t,h.right(),h.back(),s,n,o)}function hi(i,t,s=3,n=1,o=1){return ei(i,t,h.right(),h.up(),s,n,o)}function ei(i,t,s,n,o,l=1,r=1){const u=h.multiplyByTransformMatrixRowMajor(h.add(s,n),d.makeRotation(c.fromMatrixRotation(i)));const v=h.multiplyByTransformMatrixRowMajor(s,d.makeRotation(c.fromMatrixRotation(i)));const f=h.multiplyByTransformMatrixRowMajor(n,d.makeRotation(c.fromMatrixRotation(i)));const w=10*r**.25;const p=h.fromMatrixPosition(i);const x=h.add(p,h.scale(o*w,u));const g=e.create({origin:x,direction:v});const y=e.create({origin:x,direction:f});const m=h.cross(v,f);const b=h.rotateAboutAxis(a.toRadians(45),e.at(y,-(o*l)),m,x);const z=h.rotateAboutAxis(a.toRadians(45),e.at(g,o*l),m,x);const C=h.rotateAboutAxis(a.toRadians(45),e.at(y,o*l),m,x);const D=h.rotateAboutAxis(a.toRadians(45),e.at(g,-(o*l)),m,x);return new T(h.dot(v,t.direction)!==-1&&h.dot(f,t.direction)!==-1,b,D,z,C,h.multiplyByTransformMatrixColumnMajor(b,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(D,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(z,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(C,t.projectionViewMatrix))}function ri(i,t,s,n){if(i instanceof C){return ai(i,t,s,n)}return false}function ai(i,t,s,n){return di([i.points.worldLeft,i.points.worldRight,i.points.worldTip],t,s,n)||di([i.points.worldLeft,i.points.worldRight,i.points.worldBase],t,s,n)}function di(i,t,s,n){var o;if(i.length===3){const l=s.transformPointToRay(n,t.image,t.scene.camera);const e=h.subtract(i[1],i[0]);const r=h.subtract(i[2],i[0]);const a=w.epsilon((o=w.fromVectors([l.direction,l.origin,e,r]))!==null&&o!==void 0?o:w.create(e,r));const d=h.cross(l.direction,r);const u=h.dot(e,d);if(!(Math.abs(u)>=a)){return false}const v=h.subtract(l.origin,i[0]);const c=h.dot(v,d)/u;if(c<0||c>1){return false}const f=h.cross(v,e);const p=h.dot(l.direction,f)/u;if(p<0||c+p>1){return false}const x=h.dot(r,f)/u;return!Number.isNaN(x)&&(x>0||t.scene.camera.isOrthographic())}return false}class ui extends D{constructor(i,t={},s={}){var n,o,l,h,e,r,a,d,u,v,c,f,w,p;super(i);this.customization=t;this.disabledAxis={xTranslation:false,yTranslation:false,zTranslation:false,xyTranslation:false,xzTranslation:false,yzTranslation:false,xRotation:false,yRotation:false,zRotation:false};this.axisLines=[];this.rotationLines=[];this.translationMeshes=[];this.rotationMeshes=[];this.hoveredChanged=new z;this.xArrowFillColor=(n=t.colors)===null||n===void 0?void 0:n.xArrow;this.yArrowFillColor=(o=t.colors)===null||o===void 0?void 0:o.yArrow;this.zArrowFillColor=(l=t.colors)===null||l===void 0?void 0:l.zArrow;this.hoveredArrowFillColor=(h=t.colors)===null||h===void 0?void 0:h.hovered;this.outlineColor=(e=t.colors)===null||e===void 0?void 0:e.outline;this.disabledAxis.xTranslation=(r=s.xTranslation)!==null&&r!==void 0?r:false;this.disabledAxis.yTranslation=(a=s.yTranslation)!==null&&a!==void 0?a:false;this.disabledAxis.zTranslation=(d=s.zTranslation)!==null&&d!==void 0?d:false;this.disabledAxis.xyTranslation=(u=s.xyTranslation)!==null&&u!==void 0?u:false;this.disabledAxis.xzTranslation=(v=s.xzTranslation)!==null&&v!==void 0?v:false;this.disabledAxis.yzTranslation=(c=s.yzTranslation)!==null&&c!==void 0?c:false;this.disabledAxis.xRotation=(f=s.xRotation)!==null&&f!==void 0?f:false;this.disabledAxis.yRotation=(w=s.yRotation)!==null&&w!==void 0?w:false;this.disabledAxis.zRotation=(p=s.zRotation)!==null&&p!==void 0?p:false}dispose(){var i;(i=this.reglFrameDisposable)===null||i===void 0?void 0:i.cancel()}getDrawableElements(){return this.drawableElements}getFullBounds(){return this.fullBounds}boundsContainsPoint(i){return this.interactiveBounds!=null&&this.frame!=null&&v.containsPoints(this.interactiveBounds,i)}updateDisabledAxis(i){this.disabledAxis={...this.disabledAxis,...i};this.updateDisabledOnDrawables()}updateCursor(i){this.cursor=i;if(i!=null&&this.frame!=null){this.updateHovered()}else{this.clearHovered()}}updateTransform(i){var t;this.transform=i;if(i!=null&&this.frame!=null){this.updateAndDraw()}else{this.clear();(t=this.reglFrameDisposable)===null||t===void 0?void 0:t.cancel();this.reglFrameDisposable=undefined}}updateColors(i={}){var t,s,n,o,l,h,e,r,a,d,u,v,c,f,w,p;this.xArrowFillColor=(t=i.xArrow)!==null&&t!==void 0?t:this.xArrowFillColor;this.yArrowFillColor=(s=i.yArrow)!==null&&s!==void 0?s:this.yArrowFillColor;this.zArrowFillColor=(n=i.zArrow)!==null&&n!==void 0?n:this.zArrowFillColor;this.twoAxesSquareFillColor=(o=i.twoAxesSquare)!==null&&o!==void 0?o:this.twoAxesSquareFillColor;this.hoveredArrowFillColor=(l=i.hovered)!==null&&l!==void 0?l:this.hoveredArrowFillColor;this.outlineColor=(h=i.outline)!==null&&h!==void 0?h:this.outlineColor;(e=this.xArrow)===null||e===void 0?void 0:e.updateFillColor(this.getXTranslationColor(),true);(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor(this.getYTranslationColor(),true);(a=this.zArrow)===null||a===void 0?void 0:a.updateFillColor(this.getZTranslationColor(),true);(d=this.xRotation)===null||d===void 0?void 0:d.updateFillColor(this.getXRotationColor(),true);(u=this.yRotation)===null||u===void 0?void 0:u.updateFillColor(this.getYRotationColor(),true);(v=this.zRotation)===null||v===void 0?void 0:v.updateFillColor(this.getZRotationColor(),true);(c=this.xyTranslation)===null||c===void 0?void 0:c.updateFillColor(this.getTwoAxesTranslationColor(),true);(f=this.xzTranslation)===null||f===void 0?void 0:f.updateFillColor(this.getTwoAxesTranslationColor(),true);(w=this.yzTranslation)===null||w===void 0?void 0:w.updateFillColor(this.getTwoAxesTranslationColor(),true);(p=this.hoveredElement)===null||p===void 0?void 0:p.updateFillColor(this.hoveredArrowFillColor)}updateScalars(i){this.customization={...this.customization,scalars:i};if(this.transform!=null&&this.frame!=null){this.updateElements(this.transform,this.frame)}}onHoveredChanged(i){return this.hoveredChanged.on(i)}updateDisabledOnDrawables(){var i,t,s,n,o,l,h,e,r,a,d,u,v,c,f;(i=this.xRotation)===null||i===void 0?void 0:i.setDisabled(this.disabledAxis.xRotation);(t=this.xyRotationLine)===null||t===void 0?void 0:t.setDisabled(this.disabledAxis.xRotation);(s=this.xzRotationLine)===null||s===void 0?void 0:s.setDisabled(this.disabledAxis.xRotation);(n=this.yRotation)===null||n===void 0?void 0:n.setDisabled(this.disabledAxis.yRotation);(o=this.yzRotationLine)===null||o===void 0?void 0:o.setDisabled(this.disabledAxis.yRotation);(l=this.yxRotationLine)===null||l===void 0?void 0:l.setDisabled(this.disabledAxis.yRotation);(h=this.zRotation)===null||h===void 0?void 0:h.setDisabled(this.disabledAxis.zRotation);(e=this.zxRotationLine)===null||e===void 0?void 0:e.setDisabled(this.disabledAxis.zRotation);(r=this.zyRotationLine)===null||r===void 0?void 0:r.setDisabled(this.disabledAxis.zRotation);(a=this.xArrow)===null||a===void 0?void 0:a.setDisabled(this.disabledAxis.xTranslation);(d=this.yArrow)===null||d===void 0?void 0:d.setDisabled(this.disabledAxis.yTranslation);(u=this.zArrow)===null||u===void 0?void 0:u.setDisabled(this.disabledAxis.zTranslation);(v=this.xyTranslation)===null||v===void 0?void 0:v.setDisabled(this.disabledAxis.xyTranslation);(c=this.xzTranslation)===null||c===void 0?void 0:c.setDisabled(this.disabledAxis.xzTranslation);(f=this.yzTranslation)===null||f===void 0?void 0:f.setDisabled(this.disabledAxis.yzTranslation);this.updateColors()}updateHovered(){var i,t,s,n,o,l,h,e,r,a;const d=this.hoveredElement;const u=this.frame;if(u!=null){this.hoveredElement=[...this.translationMeshes,...this.rotationMeshes].filter((i=>i.points.valid&&!i.isDisabled())).find((i=>this.cursor!=null?ri(i,u,this.viewport,this.cursor):false));if(this.hoveredElement!==d){this.hoveredChanged.emit(this.hoveredElement);(i=this.hoveredElement)===null||i===void 0?void 0:i.updateFillColor(this.hoveredArrowFillColor);this.clearFillColorOfPreviouslyHovered(d);if(((t=this.hoveredElement)===null||t===void 0?void 0:t.identifier)==="xy-translate"){(s=this.xArrow)===null||s===void 0?void 0:s.updateFillColor(this.hoveredArrowFillColor);(n=this.yArrow)===null||n===void 0?void 0:n.updateFillColor(this.hoveredArrowFillColor)}else if(((o=this.hoveredElement)===null||o===void 0?void 0:o.identifier)==="xz-translate"){(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor(this.hoveredArrowFillColor);(h=this.zArrow)===null||h===void 0?void 0:h.updateFillColor(this.hoveredArrowFillColor)}else if(((e=this.hoveredElement)===null||e===void 0?void 0:e.identifier)==="yz-translate"){(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor(this.hoveredArrowFillColor);(a=this.zArrow)===null||a===void 0?void 0:a.updateFillColor(this.hoveredArrowFillColor)}}}}clearHovered(){const i=this.hoveredElement;this.hoveredElement=undefined;if(this.hoveredElement!==i){this.hoveredChanged.emit(this.hoveredElement);this.clearFillColorOfPreviouslyHovered(i)}}clearFillColorOfPreviouslyHovered(i){var t,s,n,o,l,h,e,r,a,d,u,v;i===null||i===void 0?void 0:i.updateFillColor(i===null||i===void 0?void 0:i.initialFillColor);if((i===null||i===void 0?void 0:i.identifier)==="xy-translate"){(t=this.xArrow)===null||t===void 0?void 0:t.updateFillColor((s=this.xArrow)===null||s===void 0?void 0:s.initialFillColor);(n=this.yArrow)===null||n===void 0?void 0:n.updateFillColor((o=this.yArrow)===null||o===void 0?void 0:o.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="xz-translate"){(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor((h=this.xArrow)===null||h===void 0?void 0:h.initialFillColor);(e=this.zArrow)===null||e===void 0?void 0:e.updateFillColor((r=this.zArrow)===null||r===void 0?void 0:r.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="yz-translate"){(a=this.yArrow)===null||a===void 0?void 0:a.updateFillColor((d=this.yArrow)===null||d===void 0?void 0:d.initialFillColor);(u=this.zArrow)===null||u===void 0?void 0:u.updateFillColor((v=this.zArrow)===null||v===void 0?void 0:v.initialFillColor)}}hasData(){return this.transform!=null}createOrUpdateElements(){if(this.transform!=null&&this.frame!=null){if(this.xArrow==null||this.yArrow==null||this.zArrow==null){this.createElements(this.transform,this.frame)}else{this.updateElements(this.transform,this.frame)}this.interactiveBounds=R(this.viewport,...this.rotationMeshes,...this.translationMeshes);this.fullBounds=R(this.viewport,...this.rotationMeshes,...this.translationMeshes,...this.axisLines)}}createElements(i,t){var s,n,o,l,e,r,a,d,u,v,c,f;this.reglCommand=A({canvas:this.canvasElement,extensions:"angle_instanced_arrays"});const{createShape:w}=P(this.reglCommand);const p=this.computeTriangleSize(h.fromMatrixPosition(i),t);this.xArrow=new C(w,"x-translate",E(i,t.scene.camera,p,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation),this.outlineColor,this.getXTranslationColor());this.xRotation=new C(w,"x-rotate",oi(i,t.scene.camera,p,(n=this.customization.scalars)===null||n===void 0?void 0:n.xRotation,(o=this.customization.scalars)===null||o===void 0?void 0:o.xTranslation),this.outlineColor,this.getXRotationColor());this.xAxis=new S(w,"x-axis",I(i,t.scene.camera,this.xArrow),this.outlineColor,this.getXTranslationColor());this.yArrow=new C(w,"y-translate",j(i,t.scene.camera,p,(l=this.customization.scalars)===null||l===void 0?void 0:l.yTranslation),this.outlineColor,this.getYTranslationColor());this.yRotation=new C(w,"y-rotate",li(i,t.scene.camera,p,(e=this.customization.scalars)===null||e===void 0?void 0:e.yRotation,(r=this.customization.scalars)===null||r===void 0?void 0:r.yTranslation),this.outlineColor,this.getYRotationColor());this.yAxis=new S(w,"y-axis",I(i,t.scene.camera,this.yArrow),this.outlineColor,this.getYTranslationColor());this.zArrow=new C(w,"z-translate",N(i,t.scene.camera,p,(a=this.customization.scalars)===null||a===void 0?void 0:a.zTranslation),this.outlineColor,this.getZTranslationColor());this.zAxis=new S(w,"z-axis",I(i,t.scene.camera,this.zArrow),this.outlineColor,this.getZTranslationColor());this.zRotation=new C(w,"z-rotate",hi(i,t.scene.camera,p,(d=this.customization.scalars)===null||d===void 0?void 0:d.zRotation,(u=this.customization.scalars)===null||u===void 0?void 0:u.zTranslation),this.outlineColor,this.getZRotationColor());this.xyTranslation=new C(w,"xy-translate",U(i,t.scene.camera,p,(v=this.customization.scalars)===null||v===void 0?void 0:v.xyTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.xzTranslation=new C(w,"xz-translate",H(i,t.scene.camera,p,(c=this.customization.scalars)===null||c===void 0?void 0:c.xzTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.yzTranslation=new C(w,"yz-translate",O(i,t.scene.camera,p,(f=this.customization.scalars)===null||f===void 0?void 0:f.yzTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.createRotationLines(w,i,t);this.axisLines=[this.xAxis,this.yAxis,this.zAxis];this.translationMeshes=[this.xArrow,this.yArrow,this.zArrow,this.xyTranslation,this.xzTranslation,this.yzTranslation];this.rotationMeshes=[this.xRotation,this.yRotation,this.zRotation];this.updateDisabledOnDrawables();this.availableElements=[...this.axisLines,...this.rotationLines,...this.translationMeshes,...this.rotationMeshes]}getXRotationColor(){return this.xArrowFillColor}getYRotationColor(){return this.yArrowFillColor}getZRotationColor(){return this.zArrowFillColor}getXTranslationColor(){return this.xArrowFillColor}getYTranslationColor(){return this.yArrowFillColor}getZTranslationColor(){return this.zArrowFillColor}getTwoAxesTranslationColor(){return this.twoAxesSquareFillColor}createRotationLines(i,t,s){var n,o,l,e,r,a;const d=this.computeTriangleSize(h.fromMatrixPosition(t),s);const u=V(s.scene.camera,this.xRotation,(n=this.yArrow)===null||n===void 0?void 0:n.points.worldTip,d);const v=V(s.scene.camera,this.xRotation,(o=this.zArrow)===null||o===void 0?void 0:o.points.worldTip,d);const c=V(s.scene.camera,this.yRotation,(l=this.xArrow)===null||l===void 0?void 0:l.points.worldTip,d);const f=V(s.scene.camera,this.yRotation,(e=this.zArrow)===null||e===void 0?void 0:e.points.worldTip,d);const w=V(s.scene.camera,this.zRotation,(r=this.xArrow)===null||r===void 0?void 0:r.points.worldTip,d);const p=V(s.scene.camera,this.zRotation,(a=this.yArrow)===null||a===void 0?void 0:a.points.worldTip,d);if(u!=null){this.xyRotationLine=new $(i,"xy-rotation-line",u,this.outlineColor)}if(v!=null){this.xzRotationLine=new $(i,"xz-rotation-line",v,this.outlineColor)}if(c!=null){this.yxRotationLine=new $(i,"yx-rotation-line",c,this.outlineColor)}if(f!=null){this.yzRotationLine=new $(i,"yz-rotation-line",f,this.outlineColor)}if(w!=null){this.zxRotationLine=new $(i,"zx-rotation-line",w,this.outlineColor)}if(p!=null){this.zyRotationLine=new $(i,"zy-rotation-line",p,this.outlineColor)}this.rotationLines=[this.xyRotationLine,this.xzRotationLine,this.yxRotationLine,this.yzRotationLine,this.zxRotationLine,this.zyRotationLine].filter((i=>i!=null))}updateElements(i,t){var s,n,o,l,e,r,a,d,u,v,c,f,w,p,x,g,y,m,b,z,T,C,D,R,A,P,S,$,B,k;const F=this.computeTriangleSize(h.fromMatrixPosition(i),t);if(this.xArrow!=null){this.xArrow.updatePoints(E(i,t.scene.camera,F,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation));(n=this.xAxis)===null||n===void 0?void 0:n.updatePoints(I(i,t.scene.camera,this.xArrow))}(o=this.xRotation)===null||o===void 0?void 0:o.updatePoints(oi(i,t.scene.camera,F,(l=this.customization.scalars)===null||l===void 0?void 0:l.xRotation,(e=this.customization.scalars)===null||e===void 0?void 0:e.xTranslation));if(this.yArrow!=null){this.yArrow.updatePoints(j(i,t.scene.camera,F,(r=this.customization.scalars)===null||r===void 0?void 0:r.yTranslation));(a=this.yAxis)===null||a===void 0?void 0:a.updatePoints(I(i,t.scene.camera,this.yArrow))}(d=this.yRotation)===null||d===void 0?void 0:d.updatePoints(li(i,t.scene.camera,F,(u=this.customization.scalars)===null||u===void 0?void 0:u.yRotation,(v=this.customization.scalars)===null||v===void 0?void 0:v.yTranslation));if(this.zArrow!=null){this.zArrow.updatePoints(N(i,t.scene.camera,F,(c=this.customization.scalars)===null||c===void 0?void 0:c.zTranslation));(f=this.zAxis)===null||f===void 0?void 0:f.updatePoints(I(i,t.scene.camera,this.zArrow))}(w=this.zRotation)===null||w===void 0?void 0:w.updatePoints(hi(i,t.scene.camera,F,(p=this.customization.scalars)===null||p===void 0?void 0:p.zRotation,(x=this.customization.scalars)===null||x===void 0?void 0:x.zTranslation));(g=this.xyRotationLine)===null||g===void 0?void 0:g.updatePoints(V(t.scene.camera,this.xRotation,(y=this.yArrow)===null||y===void 0?void 0:y.points.worldTip,F));(m=this.xzRotationLine)===null||m===void 0?void 0:m.updatePoints(V(t.scene.camera,this.xRotation,(b=this.zArrow)===null||b===void 0?void 0:b.points.worldTip,F));(z=this.yxRotationLine)===null||z===void 0?void 0:z.updatePoints(V(t.scene.camera,this.yRotation,(T=this.xArrow)===null||T===void 0?void 0:T.points.worldTip,F));(C=this.yzRotationLine)===null||C===void 0?void 0:C.updatePoints(V(t.scene.camera,this.yRotation,(D=this.zArrow)===null||D===void 0?void 0:D.points.worldTip,F));(R=this.zxRotationLine)===null||R===void 0?void 0:R.updatePoints(V(t.scene.camera,this.zRotation,(A=this.xArrow)===null||A===void 0?void 0:A.points.worldTip,F));(P=this.zyRotationLine)===null||P===void 0?void 0:P.updatePoints(V(t.scene.camera,this.zRotation,(S=this.yArrow)===null||S===void 0?void 0:S.points.worldTip,F));if(this.xyTranslation!=null){this.xyTranslation.updatePoints(U(i,t.scene.camera,F,($=this.customization.scalars)===null||$===void 0?void 0:$.xyTranslation))}if(this.xzTranslation!=null){this.xzTranslation.updatePoints(H(i,t.scene.camera,F,(B=this.customization.scalars)===null||B===void 0?void 0:B.xzTranslation))}if(this.yzTranslation!=null){this.yzTranslation.updatePoints(O(i,t.scene.camera,F,(k=this.customization.scalars)===null||k===void 0?void 0:k.yzTranslation))}}}const vi=()=>`:host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;--viewer-transform-widget-x-axis-arrow-color:var(--x-axis-color);--viewer-transform-widget-y-axis-arrow-color:var(--y-axis-color);--viewer-transform-widget-z-axis-arrow-color:var(--z-axis-color);--viewer-transform-widget-two-axes-square-color:var(--two-axes-color);--viewer-transform-widget-hovered-arrow-color:#ffff00;--viewer-transform-widget-input-width:8em}.widget{position:absolute;top:0;left:0}.widget.hovered{pointer-events:auto}.widget-input.wrapper{position:absolute;pointer-events:auto;display:flex;align-items:center;border:1px solid #444444;border-radius:4px;width:var(--viewer-transform-widget-input-width);text-align:center;background-color:white;box-sizing:border-box}.widget-input.units{position:relative;width:25%;height:100%;padding:0 0.25rem;font-size:0.8125rem;color:#444444}input.widget-input{position:relative;text-align:center;box-sizing:border-box;width:75%;height:100%;outline:none;border-width:0 1px 0 0;border-color:#444444;border-radius:2px 0 0 2px;font-size:0.875rem;color:#444444}input.widget-input.x-translate,input.widget-input.x-rotate{border-left:5px solid var(--viewer-transform-widget-x-axis-arrow-color)}input.widget-input.y-translate,input.widget-input.y-rotate{border-left:5px solid var(--viewer-transform-widget-y-axis-arrow-color)}input.widget-input.z-translate,input.widget-input.z-rotate{border-left:5px solid var(--viewer-transform-widget-z-axis-arrow-color)}input.widget-input:disabled{color:#888888}input.widget-input:focus{outline:none}`;const ci=class{constructor(i){t(this,i);this.positionChanged=s(this,"positionChanged");this.rotationChanged=s(this,"rotationChanged");this.interactionEnded=s(this,"interactionEnded");this.interactionStarted=s(this,"interactionStarted");this.xRotationDisabled=false;this.yRotationDisabled=false;this.zRotationDisabled=false;this.xTranslationDisabled=false;this.yTranslationDisabled=false;this.zTranslationDisabled=false;this.xyTranslationDisabled=false;this.xzTranslationDisabled=false;this.yzTranslationDisabled=false;this.showInputs=true;this.distanceUnit="millimeters";this.angleUnit="degrees";this.decimalPlaces=1;this.rotationSnapKey="shift";this.translationHandleScalar=1;this.rotationHandleScalar=1;this.interactionThrottle=75;this.EXPERIMENTAL_undoKeybindings=false;this.inputValue=0;this.isEndingTransform=false;this.inputShouldFocus=false;this.xArrowColor="#ea3324";this.yArrowColor="#4faf32";this.zArrowColor="#0000ff";this.twoAxesSquareColor="#e0e0e0";this.hoveredColor="#ffff00";this.lastAngle=0;this.handleHoveredDrawableChanged=i=>{this.hovered=i};this.handleViewerFrameDrawn=()=>{this.updatePropsFromViewer()};this.handleViewerDimensionsChange=()=>{x((()=>{if(this.viewer!=null&&this.canvasRef!=null){this.canvasRef.width=this.viewer.viewport.width;this.canvasRef.height=this.viewer.viewport.height;this.updateCanvasBounds(this.canvasRef)}}))};this.handleResize=()=>{if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef)}};this.handleInputResize=()=>{if(this.inputWrapperRef!=null){const i=this.inputWrapperRef;g((()=>{this.inputBounds=i.getBoundingClientRect()}))}};this.handleStyleChange=()=>{g((()=>{const i=window.getComputedStyle(this.hostEl);this.xArrowColor=i.getPropertyValue("--viewer-transform-widget-x-axis-arrow-color").trim();this.yArrowColor=i.getPropertyValue("--viewer-transform-widget-y-axis-arrow-color").trim();this.zArrowColor=i.getPropertyValue("--viewer-transform-widget-z-axis-arrow-color").trim();this.twoAxesSquareColor=i.getPropertyValue("--viewer-transform-widget-two-axes-square-color").trim();this.hoveredColor=i.getPropertyValue("--viewer-transform-widget-hovered-arrow-color").trim();this.getTransformWidget().updateColors({xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,twoAxesSquare:this.twoAxesSquareColor,hovered:this.hoveredColor})}))};this.handlePointerMove=i=>{if(this.dragging==null){const t=k(l.create(i.clientX,i.clientY),this.getCanvasBounds());const s=this.getTransformWidget();if(t!=null&&s.boundsContainsPoint(t)){s.updateCursor(t)}else{s.updateCursor(undefined);this.hovered=undefined}}};this.handleBeginDrag=async i=>{var t,s,n;const o=this.getCanvasBounds();if(this.hovered!=null&&o!=null&&this.viewer!=null&&this.position!=null&&this.viewer.frame!=null){this.dragging=this.hovered;if(this.dragging.identifier!==((t=this.lastDragged)===null||t===void 0?void 0:t.identifier)){this.inputValue=0;this.dragStartTransform=this.currentTransform;this.updateInputPosition();this.updateInputValue()}this.lastDragged=undefined;const h=k(l.create(i.clientX,i.clientY),o);const e=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);this.lastAngle=h!=null?a.fromPoints(e,h):0;this.lastWorldPosition=F(h,(s=this.viewer)===null||s===void 0?void 0:s.frame,(n=this.viewer)===null||n===void 0?void 0:n.viewport,this.currentTransform);this.interactionStarted.emit();window.removeEventListener("pointermove",this.handlePointerMove);window.addEventListener("pointermove",this.handleDragWithTimer);window.addEventListener("pointerup",this.handleEndTransform)}};this.handleDragWithTimer=async i=>{if(i!=null){i.preventDefault();this.lastMouseEvent=i}if(this.interactionTimer==null){this.interactionTimer=window.setTimeout((async()=>{this.interactionTimer=undefined;await this.handleDrag();this.lastMouseEvent=undefined}),this.interactionThrottle)}};this.handleDrag=async()=>{var i,t,s;const n=this.getCanvasBounds();if(this.dragging!=null&&this.lastWorldPosition!=null&&n!=null&&this.viewer!=null&&this.viewer.frame!=null&&this.position!=null&&this.lastMouseEvent!=null){await((i=this.controller)===null||i===void 0?void 0:i.beginTransform());const o=k(l.create(this.lastMouseEvent.clientX,this.lastMouseEvent.clientY),n);const h=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);const e=F(o,(t=this.viewer)===null||t===void 0?void 0:t.frame,(s=this.viewer)===null||s===void 0?void 0:s.viewport,this.currentTransform);if(e!=null&&o!=null&&h!=null){const i=a.fromPoints(h,o);const t=W(this.lastMouseEvent,this.rotationSnapKey,i,this.lastAngle,this.getDisplayedAngle(),this.rotationSnapDegrees);this.transform(this.lastWorldPosition,e,t-this.lastAngle);this.updateInputPosition();this.updateInputValue();this.lastWorldPosition=e;this.lastAngle=t}}};this.handleEndTransform=async i=>{var t,s;const n=k(l.create(i.clientX,i.clientY),this.getCanvasBounds());const o=this.getTransformWidget();this.lastDragged=this.dragging;this.dragging=undefined;this.lastWorldPosition=undefined;this.lastAngle=0;this.updateInputPosition();this.updateInputValue();o.updateCursor(n);o.updateTransform(this.currentTransform);this.beginEndTransform();window.removeEventListener("pointermove",this.handleDragWithTimer);window.removeEventListener("pointerup",this.handleEndTransform);try{const i=(t=this.controller)===null||t===void 0?void 0:t.getCurrentDelta();await((s=this.controller)===null||s===void 0?void 0:s.endTransform());this.interactionEnded.emit(i)}catch(i){console.error("Failed to end transform interaction",i)}window.addEventListener("pointermove",this.handlePointerMove);this.completeEndTransform()};this.handleInputStep=async i=>{if(this.inputValue!=null&&this.lastInputValue!=null){if(this.isModifyingAngleUnits()){const t=new m(this.angleUnit);const s=t.convertFrom(this.lastInputValue);const n=a.normalizeRadians(s+a.toRadians(i));this.inputValue=t.convertTo(n)}else{this.inputValue=this.lastInputValue+i}await this.updateTransformFromInput(this.inputValue)}};this.handleInputChange=async i=>{await this.updateTransformFromInput(i)};this.handleKeyDown=async i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="z"&&t&&this.EXPERIMENTAL_undoKeybindings){i.stopPropagation();await this.EXPERIMENTAL_undo()}};this.updateTransformFromInput=async i=>{var t,s,n;if(this.lastDragged!=null&&this.currentTransform!=null&&this.startingTransform!=null&&this.lastInputValue!=null){this.currentTransform=M(this.currentTransform,this.lastDragged.identifier,i,this.lastInputValue,this.distanceUnit,this.angleUnit);this.updateInputValue();this.lastInputValue=i;await((t=this.controller)===null||t===void 0?void 0:t.beginTransform());this.getTransformWidget().updateTransform(this.currentTransform);await((s=this.controller)===null||s===void 0?void 0:s.updateTransform(d.multiply(d.invert(this.startingTransform),this.currentTransform)));this.updateInputPosition();await((n=this.controller)===null||n===void 0?void 0:n.endTransformDebounced(this.beginEndTransform,this.completeEndTransform))}};this.updatePropsFromViewer=()=>{const{frame:i}=this.viewer||{};if(i!=null){const t=this.getTransformWidget();t.updateFrame(i,this.dragging==null);this.updateInputPosition()}};this.setupTransformWidget=i=>{var t,s;console.debug(`Initializing transform widget. [initial-position=${JSON.stringify(this.position)}, has-initial-frame=${((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null}]`);const n=this.getTranslationScalar();const o=this.getRotationScalar();this.widget=new ui(i,{colors:{xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,twoAxesSquare:this.twoAxesSquareColor,hovered:this.hoveredColor},scalars:{xTranslation:n,yTranslation:n,zTranslation:n,xyTranslation:o,xzTranslation:o,yzTranslation:o,xRotation:o,yRotation:o,zRotation:o}});if(this.rotation!=null){this.currentTransform=this.getTransformForNewRotation(this.rotation);this.startingTransform=this.currentTransform;this.widget.updateTransform(this.currentTransform)}if(this.position!=null){this.currentTransform=this.getTransformForNewPosition(this.position);this.startingTransform=this.currentTransform;this.widget.updateTransform(this.currentTransform)}if(((s=this.viewer)===null||s===void 0?void 0:s.frame)!=null){this.widget.updateFrame(this.viewer.frame,true)}this.handleSettingDisabledAxis();this.hoveredChangeDisposable=this.widget.onHoveredChanged(this.handleHoveredDrawableChanged);return this.widget};this.updateCanvasBounds=i=>{g((()=>{this.canvasBounds=i.getBoundingClientRect();this.getTransformWidget().updateDimensions(i)}))};this.updateInputValue=()=>{var i,t,s;const n=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const o=(n===null||n===void 0?void 0:n.identifier)==="xy-translate"||(n===null||n===void 0?void 0:n.identifier)==="xz-translate"||(n===null||n===void 0?void 0:n.identifier)==="yz-translate";if(n!=null&&this.currentTransform!=null&&this.dragStartTransform!=null&&!o){this.lastInputValue=this.inputValue;this.inputValue=J(n.identifier,this.currentTransform,this.dragStartTransform,this.distanceUnit,this.angleUnit);if(this.inputRef!=null){const i=(s=(t=this.getDisplayedDistance())!==null&&t!==void 0?t:this.getDisplayedAngle())!==null&&s!==void 0?s:0;const n=`${Number.parseFloat(i.toFixed(this.decimalPlaces))}`;this.inputRef.value=n}}};this.updateInputPosition=()=>{var i,t;const s=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const n=(s===null||s===void 0?void 0:s.identifier)==="xy-translate"||(s===null||s===void 0?void 0:s.identifier)==="xz-translate"||(s===null||s===void 0?void 0:s.identifier)==="yz-translate";if(this.showInputs&&((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null&&this.position!=null&&s!=null&&!n){const i=this.getTransformWidget();const t=i.getFullBounds();this.inputPosition=t!=null?Q(this.viewer.viewport,t,s.points.toArray()):undefined}else if(n){this.inputPosition=undefined}};this.beginEndTransform=()=>{const i=this.getTransformWidget();i.updateDisabledAxis({xRotation:true,yRotation:true,zRotation:true,xTranslation:true,yTranslation:true,zTranslation:true,xyTranslation:true,xzTranslation:true,yzTranslation:true});this.isEndingTransform=true};this.completeEndTransform=()=>{const i=this.getTransformWidget();i.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled});this.isEndingTransform=false;this.inputShouldFocus=true;if(this.currentTransform!=null){this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=u.fromRotationMatrix(this.currentTransform)}};this.isModifyingAngleUnits=()=>{var i,t,s;const n=(t=(i=this.dragging)===null||i===void 0?void 0:i.identifier)!==null&&t!==void 0?t:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;return!!(n===null||n===void 0?void 0:n.includes("rotate"))};this.getTranslationScalar=()=>{if(this.translationHandleScalar>0){return this.translationHandleScalar}console.warn("Invalid value provided for translation-handle-scalar. Expected a positive value greater than zero.");return 1};this.getRotationScalar=()=>{if(this.rotationHandleScalar>0){return this.rotationHandleScalar}console.warn("Invalid value provided for rotation-handle-scalar. Expected a positive value greater than zero.");return 1};this.getDisplayedUnits=()=>{if(this.isModifyingAngleUnits()){return new m(this.angleUnit)}return new b(this.distanceUnit)};this.getDisplayedAngle=()=>{if(this.isModifyingAngleUnits()){return this.inputValue}};this.getDisplayedDistance=()=>{var i,t,s;const n=(t=(i=this.dragging)===null||i===void 0?void 0:i.identifier)!==null&&t!==void 0?t:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;if(n===null||n===void 0?void 0:n.includes("translate")){return this.inputValue}};this.getTransformForNewPosition=i=>{if(i!=null){const t=this.currentTransform!=null?this.currentTransform:d.makeIdentity();const s=d.transpose(d.makeRotation(c.fromMatrixRotation(t)));const n=d.makeTranslation(i);return d.multiply(s,n)}};this.getTransformForNewRotation=i=>{const t=this.currentTransform!=null?this.currentTransform:d.makeIdentity();const s=d.makeRotation(c.fromMatrixRotation(t));const n=d.makeRotation(c.fromEuler(i));const o=d.multiply(s,t);return d.multiply(d.transpose(n),o)};this.getCanvasBounds=()=>{if(this.canvasBounds!=null){return this.canvasBounds}else if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef);return this.canvasBounds}};this.getTransformWidget=()=>{if(this.widget==null&&this.canvasRef!=null){return this.setupTransformWidget(this.canvasRef)}else if(this.widget!=null){return this.widget}else{throw new Error("Transform widget was not initialized. The canvas element may not have been initialized.")}}}componentDidLoad(){window.addEventListener("pointermove",this.handlePointerMove);this.canvasResizeObserver=new ResizeObserver(this.handleResize);this.inputResizeObserver=new ResizeObserver(this.handleInputResize);this.hostStyleObserver=new MutationObserver(this.handleStyleChange);if(this.canvasRef!=null){this.canvasResizeObserver.observe(this.canvasRef);this.setupTransformWidget(this.canvasRef)}this.hostStyleObserver.observe(this.hostEl,{attributes:true,attributeFilter:["style"]});this.handleViewerChanged(this.viewer,undefined);this.handleStyleChange()}disconnectedCallback(){var i,t,s,n,o;window.removeEventListener("pointermove",this.handlePointerMove);(i=this.canvasResizeObserver)===null||i===void 0?void 0:i.disconnect();(t=this.inputResizeObserver)===null||t===void 0?void 0:t.disconnect();(s=this.hostStyleObserver)===null||s===void 0?void 0:s.disconnect();(n=this.hoveredChangeDisposable)===null||n===void 0?void 0:n.dispose();(o=this.widget)===null||o===void 0?void 0:o.dispose()}componentDidRender(){if(this.inputShouldFocus&&this.inputRef!=null){B(this.inputRef);this.inputShouldFocus=false}}async EXPERIMENTAL_undo(){var i,t;const s=await((i=this.controller)===null||i===void 0?void 0:i.EXPERIMENTAL_undoTransform());if(this.currentTransform!=null&&s!=null){this.currentTransform=d.multiply(this.currentTransform,s);(t=this.widget)===null||t===void 0?void 0:t.updateTransform(this.currentTransform);this.updateInputPosition();this.updateInputValue();this.lastInputValue=this.inputValue;this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=u.fromRotationMatrix(this.currentTransform)}}handleViewerChanged(i,t){var s;t===null||t===void 0?void 0:t.removeEventListener("frameDrawn",this.handleViewerFrameDrawn);t===null||t===void 0?void 0:t.removeEventListener("dimensionschange",this.handleViewerDimensionsChange);i===null||i===void 0?void 0:i.addEventListener("frameDrawn",this.handleViewerFrameDrawn);i===null||i===void 0?void 0:i.addEventListener("dimensionschange",this.handleViewerDimensionsChange);if((i===null||i===void 0?void 0:i.stream)!=null){(s=this.controller)===null||s===void 0?void 0:s.dispose();this.controller=new y(i.stream)}}handleDisabledPropertyChanged(){var i;(i=this.widget)===null||i===void 0?void 0:i.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}handleTransformHandleScalarChanged(){var i;const t=this.getTranslationScalar();const s=this.getRotationScalar();(i=this.widget)===null||i===void 0?void 0:i.updateScalars({xTranslation:t,yTranslation:t,zTranslation:t,xyTranslation:s,xzTranslation:s,yzTranslation:s,xRotation:s,yRotation:s,zRotation:s})}handleRotationChanged(i,t){var s;const n=i!==null&&i!==void 0?i:u.create();this.currentTransform=this.getTransformForNewRotation(n);this.startingTransform=this.currentTransform;if(i==null&&this.currentTransform!=null&&d.isIdentity(this.currentTransform)){this.currentTransform=undefined;this.startingTransform=this.currentTransform}(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);console.debug(`Updating widget rotation [previous=${JSON.stringify(t)}, current=${JSON.stringify(i)}]`);this.rotationChanged.emit(i)}handlePositionChanged(i,t){var s,n;this.currentTransform=this.getTransformForNewPosition(i);this.startingTransform=this.currentTransform;console.debug(`Updating widget position [previous=${JSON.stringify(t)}, current=${JSON.stringify(i)}]`);(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);if(i==null){this.lastDragged=undefined;this.inputPosition=undefined;(n=this.controller)===null||n===void 0?void 0:n.clearTransform()}this.positionChanged.emit(i)}handleInputFormattingChanged(){this.updateInputValue();this.lastInputValue=this.inputValue}render(){var t,s,o,l,h,e;return i(n,{key:"fdc062cb3cafa311baca827e03a765052e1ab2c8"},i("canvas",{key:"c6c9d413e971ef3db3b3eed7e9ff6c8387fff1d1",ref:i=>{this.canvasRef=i},class:p("widget",{hovered:this.hovered!=null}),tabindex:"0",width:(t=this.viewer)===null||t===void 0?void 0:t.viewport.width,height:(s=this.viewer)===null||s===void 0?void 0:s.viewport.height,onPointerDown:this.handleBeginDrag,onKeyDown:this.handleKeyDown}),this.showInputs&&this.inputPosition&&((o=this.viewer)===null||o===void 0?void 0:o.viewport)&&i(ii,{key:"7eb3550df7db8c95f3597d1bd8d7b05c70e11696",ref:i=>{var t,s;if(i!=null){(t=this.inputResizeObserver)===null||t===void 0?void 0:t.observe(i)}else if(this.inputRef!=null){(s=this.inputResizeObserver)===null||s===void 0?void 0:s.unobserve(this.inputRef)}this.inputWrapperRef=i},bounds:this.inputBounds,viewport:this.viewer.viewport,point:this.inputPosition.point,placement:this.inputPosition.placement,displayUnit:this.getDisplayedUnits()},i(ti,{key:"84e2ff6825856c6d5f0ffff1771861ed6087bedb",ref:i=>{this.inputRef=i},identifier:(h=(l=this.dragging)===null||l===void 0?void 0:l.identifier)!==null&&h!==void 0?h:(e=this.lastDragged)===null||e===void 0?void 0:e.identifier,disabled:this.isEndingTransform,onChange:this.handleInputChange,onIncrement:()=>this.handleInputStep(1),onDecrement:()=>this.handleInputStep(-1),onBlur:()=>{this.inputShouldFocus=false},onUndo:this.EXPERIMENTAL_undoKeybindings?()=>this.EXPERIMENTAL_undo():undefined})))}transform(i,t,s){var n,o;if(this.position!=null&&this.startingTransform!=null&&this.currentTransform!=null&&this.dragging!=null&&this.viewer!=null&&this.viewer.frame!=null){this.currentTransform=K(this.currentTransform,i,t,(n=this.viewer)===null||n===void 0?void 0:n.frame.scene.camera.viewVector,s,this.dragging.identifier);this.getTransformWidget().updateTransform(this.currentTransform);(o=this.controller)===null||o===void 0?void 0:o.updateTransform(d.multiply(d.invert(this.startingTransform),this.currentTransform))}}handleSettingDisabledAxis(){if(this.widget){this.widget.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}else{console.warn("Cannot set disabled values - no widget defined")}}get hostEl(){return o(this)}static get watchers(){return{viewer:[{handleViewerChanged:0}],xTranslationDisabled:[{handleDisabledPropertyChanged:0}],yTranslationDisabled:[{handleDisabledPropertyChanged:0}],zTranslationDisabled:[{handleDisabledPropertyChanged:0}],xyTranslationDisabled:[{handleDisabledPropertyChanged:0}],xzTranslationDisabled:[{handleDisabledPropertyChanged:0}],yzTranslationDisabled:[{handleDisabledPropertyChanged:0}],xRotationDisabled:[{handleDisabledPropertyChanged:0}],yRotationDisabled:[{handleDisabledPropertyChanged:0}],zRotationDisabled:[{handleDisabledPropertyChanged:0}],translationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotation:[{handleRotationChanged:0}],position:[{handlePositionChanged:0}],distanceUnit:[{handleInputFormattingChanged:0}],angleUnit:[{handleInputFormattingChanged:0}],decimalPlaces:[{handleInputFormattingChanged:0}]}}};ci.style=vi();export{ci as vertex_viewer_transform_widget};
5
- //# sourceMappingURL=p-7cb94735.entry.js.map
4
+ import{h as i,r as t,c as s,H as n,a as o}from"./p-CCVkga9Q.js";import{p as l,v as h,r as e,b as r,a,m as d,h as u,g as v,q as c,e as f,c as w}from"./p-B8a9KIE8.js";import{c as p}from"./p-Dw4-tG-V.js";import{w as x,r as g}from"./p-BxtKMwBH.js";import{T as y}from"./p-IU78UvWI.js";import{A as m,D as z}from"./p-CD3U7s8H.js";import"./p-BAhfr1Nx.js";import{E as b}from"./p-IVh_3-KN.js";import{d as T,T as C,R as D,e as R,r as A,s as P,x as S,A as E,b as I,y as j,z as N,f as U,g as H,h as O,i as B,j as $}from"./p-Bi9f5zZC.js";import"./p-CG9AChtV.js";import"./p-B4qVkXXt.js";import"./p-D3weipcV.js";import"./p-D3hmsz_I.js";function k(i){if(window.document.activeElement!==i){i.focus();i.setSelectionRange(i.value.length,i.value.length)}}function F(i,t){return t!=null?l.create(i.x-t.left,i.y-t.top):undefined}function M(i,t,s,n){const o=n!=null?h.fromMatrixPosition(n):undefined;if(i!=null&&t!=null&&s!=null&&o!=null){const n=s.transformPointToRay(i,t.image,t.scene.camera);if(t.scene.camera.isOrthographic()){const i=e.at(e.create({origin:o,direction:t.scene.camera.direction}),h.magnitude(t.scene.camera.viewVector)*2);return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,i))}else{return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,o))}}return undefined}function V(i,t,s,n,o,l){return d.multiply(_(t,s,n,o,l),i)}function _(i,t,s,n,o){const l=new z(n);const e=new m(o);const r=()=>e.convertFrom(t-s);const a=()=>l.convertRealValueToWorld(t-s);switch(i){case"x-translate":return d.makeTranslation(h.create(a(),0,0));case"y-translate":return d.makeTranslation(h.create(0,a(),0));case"z-translate":return d.makeTranslation(h.create(0,0,a()));case"x-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.left(),r())));case"y-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.down(),r())));case"z-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.forward(),r())));default:return d.makeIdentity()}}function q(i){switch(i){case"x-rotate":return"xyz";case"y-rotate":return"yzx";case"z-rotate":return"zxy";default:return"xyz"}}function J(i,t,s,n,o){const l=new z(n);const e=new m(o);const r=()=>d.makeRotation(c.fromMatrixRotation(t));const v=()=>d.multiply(d.invert(s),t);const f=()=>h.multiplyByTransformMatrixColumnMajor(h.fromMatrixPosition(v()),r());const w=()=>u.fromRotationMatrix(d.multiply(s,r()),q(i));switch(i){case"x-translate":return l.convertWorldValueToReal(f().x);case"y-translate":return l.convertWorldValueToReal(f().y);case"z-translate":return l.convertWorldValueToReal(f().z);case"x-rotate":return e.convertTo(a.normalizeRadians(w().x));case"y-rotate":return e.convertTo(a.normalizeRadians(w().y));case"z-rotate":return e.convertTo(a.normalizeRadians(w().z));default:return 0}}function K(i,t,s,n,o,l){return X(i,h.subtract(s,t),n,o,l)}function X(i,t,s,n,o){switch(o){case"x-translate":return G(i,t,h.right());case"y-translate":return G(i,t,h.up());case"z-translate":return G(i,t,h.back());case"xy-translate":return Y(i,t,h.create(0,0,1));case"xz-translate":return Y(i,t,h.create(0,1,0));case"yz-translate":return Y(i,t,h.create(1,0,0));case"x-rotate":return L(i,s,h.right(),n);case"y-rotate":return L(i,s,h.up(),n);case"z-rotate":return L(i,s,h.forward(),n);default:return i}}function L(i,t,s,n){const o=Z(i,t,s);const l=c.fromAxisAngle(o,n);const h=d.transpose(d.makeRotation(l));return d.multiply(h,i)}function Z(i,t,s){const n=d.makeRotation(c.fromMatrixRotation(i));const o=h.multiplyByTransformMatrixRowMajor(s,n);const l=h.multiplyByTransformMatrixRowMajor(h.negate(s),n);return h.dot(t,o)>h.dot(t,l)?s:h.negate(s)}function G(i,t,s){const n=h.normalize(s);const o=d.makeRotation(c.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.project(t,l);const r=d.makeTranslation(e);return d.multiply(i,r)}function Y(i,t,s){const n=h.normalize(s);const o=d.makeRotation(c.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.fromMatrixPosition(i);const a=r.fromNormalAndCoplanarPoint(l,e);const u=r.projectPoint(a,t);const v=h.add(u,h.scale(a.constant,a.normal));const f=d.makeTranslation(v);return d.multiply(i,f)}function Q(i,t,s){if(s.length===0){throw new Error("Unable to compute input position. At least one shape point must be provided.")}const n=v.pad(t,5);const o=s.map((t=>i.transformNdcPointToViewport(t)));const h=v.topLeft(n);const e=l.add(h,l.create(n.width,0));const r=v.bottomRight(n);const a=l.subtract(r,l.create(n.width,0));const d=l.scale(o.reduce(((i,t)=>l.add(i,t)),l.create()),1/o.length,1/o.length);const u=[e,a,r].reduce(((i,t)=>l.distance(d,t)<l.distance(d,i)?t:i),h);switch(u){case h:return{point:u,placement:"top-left"};case e:return{point:u,placement:"top-right"};case a:return{point:u,placement:"bottom-left"};default:return{point:u,placement:"bottom-right"}}}function W(i,t,s,n,o,l){const h=t==="alt"&&i.altKey||t==="ctrl"&&i.ctrlKey||t==="meta"&&i.metaKey||t==="shift"&&i.shiftKey;if(h&&l!=null&&l>0&&Number.isInteger(l)){const i=s-n;const t=a.toDegrees(i);const h=Math.round(t/l)*l;if(o!=null){const i=Math.round(o/l)*l;const t=o-i;const s=h-t;const e=a.toRadians(s);return e+n}else{const i=a.toRadians(h);return i+n}}else{return s}}const ii=({ref:t,bounds:s,viewport:n,point:o,placement:l,displayUnit:h},e)=>{const r=ni(n,s!==null&&s!==void 0?s:f.create(0,0),o,l);return i("div",{ref:t,class:"widget-input wrapper",style:{...r,height:(s===null||s===void 0?void 0:s.height)!=null?`${s.height}px`:undefined}},e,i("div",{class:"widget-input units"},h.unit.abbreviatedName))};const ti=({ref:t,identifier:s,disabled:n,onChange:o,onIncrement:l,onDecrement:h,onBlur:e,onUndo:r})=>{const a=i=>{if(i.target!=null){const t=Number.parseFloat(i.target.value);if(!Number.isNaN(t)){o===null||o===void 0?void 0:o(Number.parseFloat(i.target.value))}}};const d=i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="ArrowUp"){l===null||l===void 0?void 0:l()}else if(i.key==="ArrowDown"){h===null||h===void 0?void 0:h()}else if(i.key==="z"&&t&&r){i.preventDefault();r()}};return i("input",{ref:t,disabled:n,class:`widget-input ${s}`,type:"text",onChange:a,onKeyDown:d,onBlur:e})};function si(i,t){return Math.min(i,Math.max(0,t))}function ni(i,t,s,n,o=5){const{width:l,height:h}=i.dimensions;const e=t.width+o;const r=t.height+o;function a(i){return`${i}px`}switch(n){case"top-left":return{right:a(si(l-e,l-s.x)),bottom:a(si(h-r,h-s.y))};case"top-right":return{left:a(si(l-e,s.x)),bottom:a(si(h-r,h-s.y))};case"bottom-left":return{right:a(si(l-e,l-s.x)),top:a(si(h-r,s.y))};case"bottom-right":default:return{left:a(si(l-e,s.x)),top:a(si(h-r,s.y))}}}function oi(i,t,s=3,n=1,o=1){return ei(i,t,h.back(),h.up(),s,n,o)}function li(i,t,s=3,n=1,o=1){return ei(i,t,h.right(),h.back(),s,n,o)}function hi(i,t,s=3,n=1,o=1){return ei(i,t,h.right(),h.up(),s,n,o)}function ei(i,t,s,n,o,l=1,r=1){const u=h.multiplyByTransformMatrixRowMajor(h.add(s,n),d.makeRotation(c.fromMatrixRotation(i)));const v=h.multiplyByTransformMatrixRowMajor(s,d.makeRotation(c.fromMatrixRotation(i)));const f=h.multiplyByTransformMatrixRowMajor(n,d.makeRotation(c.fromMatrixRotation(i)));const w=10*r**.25;const p=h.fromMatrixPosition(i);const x=h.add(p,h.scale(o*w,u));const g=e.create({origin:x,direction:v});const y=e.create({origin:x,direction:f});const m=h.cross(v,f);const z=h.rotateAboutAxis(a.toRadians(45),e.at(y,-(o*l)),m,x);const b=h.rotateAboutAxis(a.toRadians(45),e.at(g,o*l),m,x);const C=h.rotateAboutAxis(a.toRadians(45),e.at(y,o*l),m,x);const D=h.rotateAboutAxis(a.toRadians(45),e.at(g,-(o*l)),m,x);return new T(h.dot(v,t.direction)!==-1&&h.dot(f,t.direction)!==-1,z,D,b,C,h.multiplyByTransformMatrixColumnMajor(z,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(D,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(b,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(C,t.projectionViewMatrix))}function ri(i,t,s,n){if(i instanceof C){return ai(i,t,s,n)}return false}function ai(i,t,s,n){return di([i.points.worldLeft,i.points.worldRight,i.points.worldTip],t,s,n)||di([i.points.worldLeft,i.points.worldRight,i.points.worldBase],t,s,n)}function di(i,t,s,n){var o;if(i.length===3){const l=s.transformPointToRay(n,t.image,t.scene.camera);const e=h.subtract(i[1],i[0]);const r=h.subtract(i[2],i[0]);const a=w.epsilon((o=w.fromVectors([l.direction,l.origin,e,r]))!==null&&o!==void 0?o:w.create(e,r));const d=h.cross(l.direction,r);const u=h.dot(e,d);if(!(Math.abs(u)>=a)){return false}const v=h.subtract(l.origin,i[0]);const c=h.dot(v,d)/u;if(c<0||c>1){return false}const f=h.cross(v,e);const p=h.dot(l.direction,f)/u;if(p<0||c+p>1){return false}const x=h.dot(r,f)/u;return!Number.isNaN(x)&&(x>0||t.scene.camera.isOrthographic())}return false}class ui extends D{constructor(i,t={},s={}){var n,o,l,h,e,r,a,d,u,v,c,f,w,p;super(i);this.customization=t;this.disabledAxis={xTranslation:false,yTranslation:false,zTranslation:false,xyTranslation:false,xzTranslation:false,yzTranslation:false,xRotation:false,yRotation:false,zRotation:false};this.axisLines=[];this.rotationLines=[];this.translationMeshes=[];this.rotationMeshes=[];this.hoveredChanged=new b;this.xArrowFillColor=(n=t.colors)===null||n===void 0?void 0:n.xArrow;this.yArrowFillColor=(o=t.colors)===null||o===void 0?void 0:o.yArrow;this.zArrowFillColor=(l=t.colors)===null||l===void 0?void 0:l.zArrow;this.hoveredArrowFillColor=(h=t.colors)===null||h===void 0?void 0:h.hovered;this.outlineColor=(e=t.colors)===null||e===void 0?void 0:e.outline;this.disabledAxis.xTranslation=(r=s.xTranslation)!==null&&r!==void 0?r:false;this.disabledAxis.yTranslation=(a=s.yTranslation)!==null&&a!==void 0?a:false;this.disabledAxis.zTranslation=(d=s.zTranslation)!==null&&d!==void 0?d:false;this.disabledAxis.xyTranslation=(u=s.xyTranslation)!==null&&u!==void 0?u:false;this.disabledAxis.xzTranslation=(v=s.xzTranslation)!==null&&v!==void 0?v:false;this.disabledAxis.yzTranslation=(c=s.yzTranslation)!==null&&c!==void 0?c:false;this.disabledAxis.xRotation=(f=s.xRotation)!==null&&f!==void 0?f:false;this.disabledAxis.yRotation=(w=s.yRotation)!==null&&w!==void 0?w:false;this.disabledAxis.zRotation=(p=s.zRotation)!==null&&p!==void 0?p:false}dispose(){var i;(i=this.reglFrameDisposable)===null||i===void 0?void 0:i.cancel()}getDrawableElements(){return this.drawableElements}getFullBounds(){return this.fullBounds}boundsContainsPoint(i){return this.interactiveBounds!=null&&this.frame!=null&&v.containsPoints(this.interactiveBounds,i)}updateDisabledAxis(i){this.disabledAxis={...this.disabledAxis,...i};this.updateDisabledOnDrawables()}updateCursor(i){this.cursor=i;if(i!=null&&this.frame!=null){this.updateHovered()}else{this.clearHovered()}}updateTransform(i){var t;this.transform=i;if(i!=null&&this.frame!=null){this.updateAndDraw()}else{this.clear();(t=this.reglFrameDisposable)===null||t===void 0?void 0:t.cancel();this.reglFrameDisposable=undefined}}updateColors(i={}){var t,s,n,o,l,h,e,r,a,d,u,v,c,f,w,p;this.xArrowFillColor=(t=i.xArrow)!==null&&t!==void 0?t:this.xArrowFillColor;this.yArrowFillColor=(s=i.yArrow)!==null&&s!==void 0?s:this.yArrowFillColor;this.zArrowFillColor=(n=i.zArrow)!==null&&n!==void 0?n:this.zArrowFillColor;this.twoAxesSquareFillColor=(o=i.twoAxesSquare)!==null&&o!==void 0?o:this.twoAxesSquareFillColor;this.hoveredArrowFillColor=(l=i.hovered)!==null&&l!==void 0?l:this.hoveredArrowFillColor;this.outlineColor=(h=i.outline)!==null&&h!==void 0?h:this.outlineColor;(e=this.xArrow)===null||e===void 0?void 0:e.updateFillColor(this.getXTranslationColor(),true);(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor(this.getYTranslationColor(),true);(a=this.zArrow)===null||a===void 0?void 0:a.updateFillColor(this.getZTranslationColor(),true);(d=this.xRotation)===null||d===void 0?void 0:d.updateFillColor(this.getXRotationColor(),true);(u=this.yRotation)===null||u===void 0?void 0:u.updateFillColor(this.getYRotationColor(),true);(v=this.zRotation)===null||v===void 0?void 0:v.updateFillColor(this.getZRotationColor(),true);(c=this.xyTranslation)===null||c===void 0?void 0:c.updateFillColor(this.getTwoAxesTranslationColor(),true);(f=this.xzTranslation)===null||f===void 0?void 0:f.updateFillColor(this.getTwoAxesTranslationColor(),true);(w=this.yzTranslation)===null||w===void 0?void 0:w.updateFillColor(this.getTwoAxesTranslationColor(),true);(p=this.hoveredElement)===null||p===void 0?void 0:p.updateFillColor(this.hoveredArrowFillColor)}updateScalars(i){this.customization={...this.customization,scalars:i};if(this.transform!=null&&this.frame!=null){this.updateElements(this.transform,this.frame)}}onHoveredChanged(i){return this.hoveredChanged.on(i)}updateDisabledOnDrawables(){var i,t,s,n,o,l,h,e,r,a,d,u,v,c,f;(i=this.xRotation)===null||i===void 0?void 0:i.setDisabled(this.disabledAxis.xRotation);(t=this.xyRotationLine)===null||t===void 0?void 0:t.setDisabled(this.disabledAxis.xRotation);(s=this.xzRotationLine)===null||s===void 0?void 0:s.setDisabled(this.disabledAxis.xRotation);(n=this.yRotation)===null||n===void 0?void 0:n.setDisabled(this.disabledAxis.yRotation);(o=this.yzRotationLine)===null||o===void 0?void 0:o.setDisabled(this.disabledAxis.yRotation);(l=this.yxRotationLine)===null||l===void 0?void 0:l.setDisabled(this.disabledAxis.yRotation);(h=this.zRotation)===null||h===void 0?void 0:h.setDisabled(this.disabledAxis.zRotation);(e=this.zxRotationLine)===null||e===void 0?void 0:e.setDisabled(this.disabledAxis.zRotation);(r=this.zyRotationLine)===null||r===void 0?void 0:r.setDisabled(this.disabledAxis.zRotation);(a=this.xArrow)===null||a===void 0?void 0:a.setDisabled(this.disabledAxis.xTranslation);(d=this.yArrow)===null||d===void 0?void 0:d.setDisabled(this.disabledAxis.yTranslation);(u=this.zArrow)===null||u===void 0?void 0:u.setDisabled(this.disabledAxis.zTranslation);(v=this.xyTranslation)===null||v===void 0?void 0:v.setDisabled(this.disabledAxis.xyTranslation);(c=this.xzTranslation)===null||c===void 0?void 0:c.setDisabled(this.disabledAxis.xzTranslation);(f=this.yzTranslation)===null||f===void 0?void 0:f.setDisabled(this.disabledAxis.yzTranslation);this.updateColors()}updateHovered(){var i,t,s,n,o,l,h,e,r,a;const d=this.hoveredElement;const u=this.frame;if(u!=null){this.hoveredElement=[...this.translationMeshes,...this.rotationMeshes].filter((i=>i.points.valid&&!i.isDisabled())).find((i=>this.cursor!=null?ri(i,u,this.viewport,this.cursor):false));if(this.hoveredElement!==d){this.hoveredChanged.emit(this.hoveredElement);(i=this.hoveredElement)===null||i===void 0?void 0:i.updateFillColor(this.hoveredArrowFillColor);this.clearFillColorOfPreviouslyHovered(d);if(((t=this.hoveredElement)===null||t===void 0?void 0:t.identifier)==="xy-translate"){(s=this.xArrow)===null||s===void 0?void 0:s.updateFillColor(this.hoveredArrowFillColor);(n=this.yArrow)===null||n===void 0?void 0:n.updateFillColor(this.hoveredArrowFillColor)}else if(((o=this.hoveredElement)===null||o===void 0?void 0:o.identifier)==="xz-translate"){(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor(this.hoveredArrowFillColor);(h=this.zArrow)===null||h===void 0?void 0:h.updateFillColor(this.hoveredArrowFillColor)}else if(((e=this.hoveredElement)===null||e===void 0?void 0:e.identifier)==="yz-translate"){(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor(this.hoveredArrowFillColor);(a=this.zArrow)===null||a===void 0?void 0:a.updateFillColor(this.hoveredArrowFillColor)}}}}clearHovered(){const i=this.hoveredElement;this.hoveredElement=undefined;if(this.hoveredElement!==i){this.hoveredChanged.emit(this.hoveredElement);this.clearFillColorOfPreviouslyHovered(i)}}clearFillColorOfPreviouslyHovered(i){var t,s,n,o,l,h,e,r,a,d,u,v;i===null||i===void 0?void 0:i.updateFillColor(i===null||i===void 0?void 0:i.initialFillColor);if((i===null||i===void 0?void 0:i.identifier)==="xy-translate"){(t=this.xArrow)===null||t===void 0?void 0:t.updateFillColor((s=this.xArrow)===null||s===void 0?void 0:s.initialFillColor);(n=this.yArrow)===null||n===void 0?void 0:n.updateFillColor((o=this.yArrow)===null||o===void 0?void 0:o.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="xz-translate"){(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor((h=this.xArrow)===null||h===void 0?void 0:h.initialFillColor);(e=this.zArrow)===null||e===void 0?void 0:e.updateFillColor((r=this.zArrow)===null||r===void 0?void 0:r.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="yz-translate"){(a=this.yArrow)===null||a===void 0?void 0:a.updateFillColor((d=this.yArrow)===null||d===void 0?void 0:d.initialFillColor);(u=this.zArrow)===null||u===void 0?void 0:u.updateFillColor((v=this.zArrow)===null||v===void 0?void 0:v.initialFillColor)}}hasData(){return this.transform!=null}createOrUpdateElements(){if(this.transform!=null&&this.frame!=null){if(this.xArrow==null||this.yArrow==null||this.zArrow==null){this.createElements(this.transform,this.frame)}else{this.updateElements(this.transform,this.frame)}this.interactiveBounds=R(this.viewport,...this.rotationMeshes,...this.translationMeshes);this.fullBounds=R(this.viewport,...this.rotationMeshes,...this.translationMeshes,...this.axisLines)}}createElements(i,t){var s,n,o,l,e,r,a,d,u,v,c,f;this.reglCommand=A({canvas:this.canvasElement,extensions:"angle_instanced_arrays"});const{createShape:w}=P(this.reglCommand);const p=this.computeTriangleSize(h.fromMatrixPosition(i),t);this.xArrow=new C(w,"x-translate",S(i,t.scene.camera,p,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation),this.outlineColor,this.getXTranslationColor());this.xRotation=new C(w,"x-rotate",oi(i,t.scene.camera,p,(n=this.customization.scalars)===null||n===void 0?void 0:n.xRotation,(o=this.customization.scalars)===null||o===void 0?void 0:o.xTranslation),this.outlineColor,this.getXRotationColor());this.xAxis=new E(w,"x-axis",I(i,t.scene.camera,this.xArrow),this.outlineColor,this.getXTranslationColor());this.yArrow=new C(w,"y-translate",j(i,t.scene.camera,p,(l=this.customization.scalars)===null||l===void 0?void 0:l.yTranslation),this.outlineColor,this.getYTranslationColor());this.yRotation=new C(w,"y-rotate",li(i,t.scene.camera,p,(e=this.customization.scalars)===null||e===void 0?void 0:e.yRotation,(r=this.customization.scalars)===null||r===void 0?void 0:r.yTranslation),this.outlineColor,this.getYRotationColor());this.yAxis=new E(w,"y-axis",I(i,t.scene.camera,this.yArrow),this.outlineColor,this.getYTranslationColor());this.zArrow=new C(w,"z-translate",N(i,t.scene.camera,p,(a=this.customization.scalars)===null||a===void 0?void 0:a.zTranslation),this.outlineColor,this.getZTranslationColor());this.zAxis=new E(w,"z-axis",I(i,t.scene.camera,this.zArrow),this.outlineColor,this.getZTranslationColor());this.zRotation=new C(w,"z-rotate",hi(i,t.scene.camera,p,(d=this.customization.scalars)===null||d===void 0?void 0:d.zRotation,(u=this.customization.scalars)===null||u===void 0?void 0:u.zTranslation),this.outlineColor,this.getZRotationColor());this.xyTranslation=new C(w,"xy-translate",U(i,t.scene.camera,p,(v=this.customization.scalars)===null||v===void 0?void 0:v.xyTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.xzTranslation=new C(w,"xz-translate",H(i,t.scene.camera,p,(c=this.customization.scalars)===null||c===void 0?void 0:c.xzTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.yzTranslation=new C(w,"yz-translate",O(i,t.scene.camera,p,(f=this.customization.scalars)===null||f===void 0?void 0:f.yzTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.createRotationLines(w,i,t);this.axisLines=[this.xAxis,this.yAxis,this.zAxis];this.translationMeshes=[this.xArrow,this.yArrow,this.zArrow,this.xyTranslation,this.xzTranslation,this.yzTranslation];this.rotationMeshes=[this.xRotation,this.yRotation,this.zRotation];this.updateDisabledOnDrawables();this.availableElements=[...this.axisLines,...this.rotationLines,...this.translationMeshes,...this.rotationMeshes]}getXRotationColor(){return this.xArrowFillColor}getYRotationColor(){return this.yArrowFillColor}getZRotationColor(){return this.zArrowFillColor}getXTranslationColor(){return this.xArrowFillColor}getYTranslationColor(){return this.yArrowFillColor}getZTranslationColor(){return this.zArrowFillColor}getTwoAxesTranslationColor(){return this.twoAxesSquareFillColor}createRotationLines(i,t,s){var n,o,l,e,r,a;const d=this.computeTriangleSize(h.fromMatrixPosition(t),s);const u=B(s.scene.camera,this.xRotation,(n=this.yArrow)===null||n===void 0?void 0:n.points.worldTip,d);const v=B(s.scene.camera,this.xRotation,(o=this.zArrow)===null||o===void 0?void 0:o.points.worldTip,d);const c=B(s.scene.camera,this.yRotation,(l=this.xArrow)===null||l===void 0?void 0:l.points.worldTip,d);const f=B(s.scene.camera,this.yRotation,(e=this.zArrow)===null||e===void 0?void 0:e.points.worldTip,d);const w=B(s.scene.camera,this.zRotation,(r=this.xArrow)===null||r===void 0?void 0:r.points.worldTip,d);const p=B(s.scene.camera,this.zRotation,(a=this.yArrow)===null||a===void 0?void 0:a.points.worldTip,d);if(u!=null){this.xyRotationLine=new $(i,"xy-rotation-line",u,this.outlineColor)}if(v!=null){this.xzRotationLine=new $(i,"xz-rotation-line",v,this.outlineColor)}if(c!=null){this.yxRotationLine=new $(i,"yx-rotation-line",c,this.outlineColor)}if(f!=null){this.yzRotationLine=new $(i,"yz-rotation-line",f,this.outlineColor)}if(w!=null){this.zxRotationLine=new $(i,"zx-rotation-line",w,this.outlineColor)}if(p!=null){this.zyRotationLine=new $(i,"zy-rotation-line",p,this.outlineColor)}this.rotationLines=[this.xyRotationLine,this.xzRotationLine,this.yxRotationLine,this.yzRotationLine,this.zxRotationLine,this.zyRotationLine].filter((i=>i!=null))}updateElements(i,t){var s,n,o,l,e,r,a,d,u,v,c,f,w,p,x,g,y,m,z,b,T,C,D,R,A,P,E,$,k,F;const M=this.computeTriangleSize(h.fromMatrixPosition(i),t);if(this.xArrow!=null){this.xArrow.updatePoints(S(i,t.scene.camera,M,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation));(n=this.xAxis)===null||n===void 0?void 0:n.updatePoints(I(i,t.scene.camera,this.xArrow))}(o=this.xRotation)===null||o===void 0?void 0:o.updatePoints(oi(i,t.scene.camera,M,(l=this.customization.scalars)===null||l===void 0?void 0:l.xRotation,(e=this.customization.scalars)===null||e===void 0?void 0:e.xTranslation));if(this.yArrow!=null){this.yArrow.updatePoints(j(i,t.scene.camera,M,(r=this.customization.scalars)===null||r===void 0?void 0:r.yTranslation));(a=this.yAxis)===null||a===void 0?void 0:a.updatePoints(I(i,t.scene.camera,this.yArrow))}(d=this.yRotation)===null||d===void 0?void 0:d.updatePoints(li(i,t.scene.camera,M,(u=this.customization.scalars)===null||u===void 0?void 0:u.yRotation,(v=this.customization.scalars)===null||v===void 0?void 0:v.yTranslation));if(this.zArrow!=null){this.zArrow.updatePoints(N(i,t.scene.camera,M,(c=this.customization.scalars)===null||c===void 0?void 0:c.zTranslation));(f=this.zAxis)===null||f===void 0?void 0:f.updatePoints(I(i,t.scene.camera,this.zArrow))}(w=this.zRotation)===null||w===void 0?void 0:w.updatePoints(hi(i,t.scene.camera,M,(p=this.customization.scalars)===null||p===void 0?void 0:p.zRotation,(x=this.customization.scalars)===null||x===void 0?void 0:x.zTranslation));(g=this.xyRotationLine)===null||g===void 0?void 0:g.updatePoints(B(t.scene.camera,this.xRotation,(y=this.yArrow)===null||y===void 0?void 0:y.points.worldTip,M));(m=this.xzRotationLine)===null||m===void 0?void 0:m.updatePoints(B(t.scene.camera,this.xRotation,(z=this.zArrow)===null||z===void 0?void 0:z.points.worldTip,M));(b=this.yxRotationLine)===null||b===void 0?void 0:b.updatePoints(B(t.scene.camera,this.yRotation,(T=this.xArrow)===null||T===void 0?void 0:T.points.worldTip,M));(C=this.yzRotationLine)===null||C===void 0?void 0:C.updatePoints(B(t.scene.camera,this.yRotation,(D=this.zArrow)===null||D===void 0?void 0:D.points.worldTip,M));(R=this.zxRotationLine)===null||R===void 0?void 0:R.updatePoints(B(t.scene.camera,this.zRotation,(A=this.xArrow)===null||A===void 0?void 0:A.points.worldTip,M));(P=this.zyRotationLine)===null||P===void 0?void 0:P.updatePoints(B(t.scene.camera,this.zRotation,(E=this.yArrow)===null||E===void 0?void 0:E.points.worldTip,M));if(this.xyTranslation!=null){this.xyTranslation.updatePoints(U(i,t.scene.camera,M,($=this.customization.scalars)===null||$===void 0?void 0:$.xyTranslation))}if(this.xzTranslation!=null){this.xzTranslation.updatePoints(H(i,t.scene.camera,M,(k=this.customization.scalars)===null||k===void 0?void 0:k.xzTranslation))}if(this.yzTranslation!=null){this.yzTranslation.updatePoints(O(i,t.scene.camera,M,(F=this.customization.scalars)===null||F===void 0?void 0:F.yzTranslation))}}}const vi=()=>`:host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;--viewer-transform-widget-x-axis-arrow-color:var(--x-axis-color);--viewer-transform-widget-y-axis-arrow-color:var(--y-axis-color);--viewer-transform-widget-z-axis-arrow-color:var(--z-axis-color);--viewer-transform-widget-two-axes-square-color:var(--two-axes-color);--viewer-transform-widget-hovered-arrow-color:#ffff00;--viewer-transform-widget-input-width:8em}.widget{position:absolute;top:0;left:0}.widget.hovered{pointer-events:auto}.widget-input.wrapper{position:absolute;pointer-events:auto;display:flex;align-items:center;border:1px solid #444444;border-radius:4px;width:var(--viewer-transform-widget-input-width);text-align:center;background-color:white;box-sizing:border-box}.widget-input.units{position:relative;width:25%;height:100%;padding:0 0.25rem;font-size:0.8125rem;color:#444444}input.widget-input{position:relative;text-align:center;box-sizing:border-box;width:75%;height:100%;outline:none;border-width:0 1px 0 0;border-color:#444444;border-radius:2px 0 0 2px;font-size:0.875rem;color:#444444}input.widget-input.x-translate,input.widget-input.x-rotate{border-left:5px solid var(--viewer-transform-widget-x-axis-arrow-color)}input.widget-input.y-translate,input.widget-input.y-rotate{border-left:5px solid var(--viewer-transform-widget-y-axis-arrow-color)}input.widget-input.z-translate,input.widget-input.z-rotate{border-left:5px solid var(--viewer-transform-widget-z-axis-arrow-color)}input.widget-input:disabled{color:#888888}input.widget-input:focus{outline:none}`;const ci=class{constructor(i){t(this,i);this.positionChanged=s(this,"positionChanged");this.rotationChanged=s(this,"rotationChanged");this.interactionEnded=s(this,"interactionEnded");this.interactionStarted=s(this,"interactionStarted");this.xRotationDisabled=false;this.yRotationDisabled=false;this.zRotationDisabled=false;this.xTranslationDisabled=false;this.yTranslationDisabled=false;this.zTranslationDisabled=false;this.xyTranslationDisabled=false;this.xzTranslationDisabled=false;this.yzTranslationDisabled=false;this.showInputs=true;this.distanceUnit="millimeters";this.angleUnit="degrees";this.decimalPlaces=1;this.rotationSnapKey="shift";this.translationHandleScalar=1;this.rotationHandleScalar=1;this.interactionThrottle=75;this.EXPERIMENTAL_undoKeybindings=false;this.inputValue=0;this.isEndingTransform=false;this.inputShouldFocus=false;this.xArrowColor="#ea3324";this.yArrowColor="#4faf32";this.zArrowColor="#0000ff";this.twoAxesSquareColor="#e0e0e0";this.hoveredColor="#ffff00";this.lastAngle=0;this.handleHoveredDrawableChanged=i=>{this.hovered=i};this.handleViewerFrameDrawn=()=>{this.updatePropsFromViewer()};this.handleViewerDimensionsChange=()=>{x((()=>{if(this.viewer!=null&&this.canvasRef!=null){this.canvasRef.width=this.viewer.viewport.width;this.canvasRef.height=this.viewer.viewport.height;this.updateCanvasBounds(this.canvasRef)}}))};this.handleResize=()=>{if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef)}};this.handleInputResize=()=>{if(this.inputWrapperRef!=null){const i=this.inputWrapperRef;g((()=>{this.inputBounds=i.getBoundingClientRect()}))}};this.handleStyleChange=()=>{g((()=>{const i=window.getComputedStyle(this.hostEl);this.xArrowColor=i.getPropertyValue("--viewer-transform-widget-x-axis-arrow-color").trim();this.yArrowColor=i.getPropertyValue("--viewer-transform-widget-y-axis-arrow-color").trim();this.zArrowColor=i.getPropertyValue("--viewer-transform-widget-z-axis-arrow-color").trim();this.twoAxesSquareColor=i.getPropertyValue("--viewer-transform-widget-two-axes-square-color").trim();this.hoveredColor=i.getPropertyValue("--viewer-transform-widget-hovered-arrow-color").trim();this.getTransformWidget().updateColors({xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,twoAxesSquare:this.twoAxesSquareColor,hovered:this.hoveredColor})}))};this.handlePointerMove=i=>{if(this.dragging==null){const t=F(l.create(i.clientX,i.clientY),this.getCanvasBounds());const s=this.getTransformWidget();if(t!=null&&s.boundsContainsPoint(t)){s.updateCursor(t)}else{s.updateCursor(undefined);this.hovered=undefined}}};this.handleBeginDrag=async i=>{var t,s,n;const o=this.getCanvasBounds();if(this.hovered!=null&&o!=null&&this.viewer!=null&&this.position!=null&&this.viewer.frame!=null){this.dragging=this.hovered;if(this.dragging.identifier!==((t=this.lastDragged)===null||t===void 0?void 0:t.identifier)){this.inputValue=0;this.dragStartTransform=this.currentTransform;this.updateInputPosition();this.updateInputValue()}this.lastDragged=undefined;const h=F(l.create(i.clientX,i.clientY),o);const e=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);this.lastAngle=h!=null?a.fromPoints(e,h):0;this.lastWorldPosition=M(h,(s=this.viewer)===null||s===void 0?void 0:s.frame,(n=this.viewer)===null||n===void 0?void 0:n.viewport,this.currentTransform);this.interactionStarted.emit();window.removeEventListener("pointermove",this.handlePointerMove);window.addEventListener("pointermove",this.handleDragWithTimer);window.addEventListener("pointerup",this.handleEndTransform)}};this.handleDragWithTimer=async i=>{if(i!=null){i.preventDefault();this.lastMouseEvent=i}if(this.interactionTimer==null){this.interactionTimer=window.setTimeout((async()=>{this.interactionTimer=undefined;await this.handleDrag();this.lastMouseEvent=undefined}),this.interactionThrottle)}};this.handleDrag=async()=>{var i,t,s;const n=this.getCanvasBounds();if(this.dragging!=null&&this.lastWorldPosition!=null&&n!=null&&this.viewer!=null&&this.viewer.frame!=null&&this.position!=null&&this.lastMouseEvent!=null){await((i=this.controller)===null||i===void 0?void 0:i.beginTransform());const o=F(l.create(this.lastMouseEvent.clientX,this.lastMouseEvent.clientY),n);const h=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);const e=M(o,(t=this.viewer)===null||t===void 0?void 0:t.frame,(s=this.viewer)===null||s===void 0?void 0:s.viewport,this.currentTransform);if(e!=null&&o!=null&&h!=null){const i=a.fromPoints(h,o);const t=W(this.lastMouseEvent,this.rotationSnapKey,i,this.lastAngle,this.getDisplayedAngle(),this.rotationSnapDegrees);this.transform(this.lastWorldPosition,e,t-this.lastAngle);this.updateInputPosition();this.updateInputValue();this.lastWorldPosition=e;this.lastAngle=t}}};this.handleEndTransform=async i=>{var t,s;const n=F(l.create(i.clientX,i.clientY),this.getCanvasBounds());const o=this.getTransformWidget();this.lastDragged=this.dragging;this.dragging=undefined;this.lastWorldPosition=undefined;this.lastAngle=0;this.updateInputPosition();this.updateInputValue();o.updateCursor(n);o.updateTransform(this.currentTransform);this.beginEndTransform();window.removeEventListener("pointermove",this.handleDragWithTimer);window.removeEventListener("pointerup",this.handleEndTransform);try{const i=(t=this.controller)===null||t===void 0?void 0:t.getCurrentDelta();await((s=this.controller)===null||s===void 0?void 0:s.endTransform());this.interactionEnded.emit(i)}catch(i){console.error("Failed to end transform interaction",i)}window.addEventListener("pointermove",this.handlePointerMove);this.completeEndTransform()};this.handleInputStep=async i=>{if(this.inputValue!=null&&this.lastInputValue!=null){if(this.isModifyingAngleUnits()){const t=new m(this.angleUnit);const s=t.convertFrom(this.lastInputValue);const n=a.normalizeRadians(s+a.toRadians(i));this.inputValue=t.convertTo(n)}else{this.inputValue=this.lastInputValue+i}await this.updateTransformFromInput(this.inputValue)}};this.handleInputChange=async i=>{await this.updateTransformFromInput(i)};this.handleKeyDown=async i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="z"&&t&&this.EXPERIMENTAL_undoKeybindings){i.stopPropagation();await this.EXPERIMENTAL_undo()}};this.updateTransformFromInput=async i=>{var t,s,n;if(this.lastDragged!=null&&this.currentTransform!=null&&this.startingTransform!=null&&this.lastInputValue!=null){this.currentTransform=V(this.currentTransform,this.lastDragged.identifier,i,this.lastInputValue,this.distanceUnit,this.angleUnit);this.updateInputValue();this.lastInputValue=i;await((t=this.controller)===null||t===void 0?void 0:t.beginTransform());this.getTransformWidget().updateTransform(this.currentTransform);await((s=this.controller)===null||s===void 0?void 0:s.updateTransform(d.multiply(d.invert(this.startingTransform),this.currentTransform)));this.updateInputPosition();await((n=this.controller)===null||n===void 0?void 0:n.endTransformDebounced(this.beginEndTransform,this.completeEndTransform))}};this.updatePropsFromViewer=()=>{const{frame:i}=this.viewer||{};if(i!=null){const t=this.getTransformWidget();t.updateFrame(i,this.dragging==null);this.updateInputPosition()}};this.setupTransformWidget=i=>{var t,s;console.debug(`Initializing transform widget. [initial-position=${JSON.stringify(this.position)}, has-initial-frame=${((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null}]`);const n=this.getTranslationScalar();const o=this.getRotationScalar();this.widget=new ui(i,{colors:{xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,twoAxesSquare:this.twoAxesSquareColor,hovered:this.hoveredColor},scalars:{xTranslation:n,yTranslation:n,zTranslation:n,xyTranslation:o,xzTranslation:o,yzTranslation:o,xRotation:o,yRotation:o,zRotation:o}});if(this.rotation!=null){this.currentTransform=this.getTransformForNewRotation(this.rotation);this.startingTransform=this.currentTransform;this.widget.updateTransform(this.currentTransform)}if(this.position!=null){this.currentTransform=this.getTransformForNewPosition(this.position);this.startingTransform=this.currentTransform;this.widget.updateTransform(this.currentTransform)}if(((s=this.viewer)===null||s===void 0?void 0:s.frame)!=null){this.widget.updateFrame(this.viewer.frame,true)}this.handleSettingDisabledAxis();this.hoveredChangeDisposable=this.widget.onHoveredChanged(this.handleHoveredDrawableChanged);return this.widget};this.updateCanvasBounds=i=>{g((()=>{this.canvasBounds=i.getBoundingClientRect();this.getTransformWidget().updateDimensions(i)}))};this.updateInputValue=()=>{var i,t,s;const n=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const o=(n===null||n===void 0?void 0:n.identifier)==="xy-translate"||(n===null||n===void 0?void 0:n.identifier)==="xz-translate"||(n===null||n===void 0?void 0:n.identifier)==="yz-translate";if(n!=null&&this.currentTransform!=null&&this.dragStartTransform!=null&&!o){this.lastInputValue=this.inputValue;this.inputValue=J(n.identifier,this.currentTransform,this.dragStartTransform,this.distanceUnit,this.angleUnit);if(this.inputRef!=null){const i=(s=(t=this.getDisplayedDistance())!==null&&t!==void 0?t:this.getDisplayedAngle())!==null&&s!==void 0?s:0;const n=`${Number.parseFloat(i.toFixed(this.decimalPlaces))}`;this.inputRef.value=n}}};this.updateInputPosition=()=>{var i,t;const s=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const n=(s===null||s===void 0?void 0:s.identifier)==="xy-translate"||(s===null||s===void 0?void 0:s.identifier)==="xz-translate"||(s===null||s===void 0?void 0:s.identifier)==="yz-translate";if(this.showInputs&&((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null&&this.position!=null&&s!=null&&!n){const i=this.getTransformWidget();const t=i.getFullBounds();this.inputPosition=t!=null?Q(this.viewer.viewport,t,s.points.toArray()):undefined}else if(n){this.inputPosition=undefined}};this.beginEndTransform=()=>{const i=this.getTransformWidget();i.updateDisabledAxis({xRotation:true,yRotation:true,zRotation:true,xTranslation:true,yTranslation:true,zTranslation:true,xyTranslation:true,xzTranslation:true,yzTranslation:true});this.isEndingTransform=true};this.completeEndTransform=()=>{const i=this.getTransformWidget();i.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled});this.isEndingTransform=false;this.inputShouldFocus=true;if(this.currentTransform!=null){this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=u.fromRotationMatrix(this.currentTransform)}};this.isModifyingAngleUnits=()=>{var i,t,s;const n=(t=(i=this.dragging)===null||i===void 0?void 0:i.identifier)!==null&&t!==void 0?t:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;return!!(n===null||n===void 0?void 0:n.includes("rotate"))};this.getTranslationScalar=()=>{if(this.translationHandleScalar>0){return this.translationHandleScalar}console.warn("Invalid value provided for translation-handle-scalar. Expected a positive value greater than zero.");return 1};this.getRotationScalar=()=>{if(this.rotationHandleScalar>0){return this.rotationHandleScalar}console.warn("Invalid value provided for rotation-handle-scalar. Expected a positive value greater than zero.");return 1};this.getDisplayedUnits=()=>{if(this.isModifyingAngleUnits()){return new m(this.angleUnit)}return new z(this.distanceUnit)};this.getDisplayedAngle=()=>{if(this.isModifyingAngleUnits()){return this.inputValue}};this.getDisplayedDistance=()=>{var i,t,s;const n=(t=(i=this.dragging)===null||i===void 0?void 0:i.identifier)!==null&&t!==void 0?t:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;if(n===null||n===void 0?void 0:n.includes("translate")){return this.inputValue}};this.getTransformForNewPosition=i=>{if(i!=null){const t=this.currentTransform!=null?this.currentTransform:d.makeIdentity();const s=d.transpose(d.makeRotation(c.fromMatrixRotation(t)));const n=d.makeTranslation(i);return d.multiply(s,n)}};this.getTransformForNewRotation=i=>{const t=this.currentTransform!=null?this.currentTransform:d.makeIdentity();const s=d.makeRotation(c.fromMatrixRotation(t));const n=d.makeRotation(c.fromEuler(i));const o=d.multiply(s,t);return d.multiply(d.transpose(n),o)};this.getCanvasBounds=()=>{if(this.canvasBounds!=null){return this.canvasBounds}else if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef);return this.canvasBounds}};this.getTransformWidget=()=>{if(this.widget==null&&this.canvasRef!=null){return this.setupTransformWidget(this.canvasRef)}else if(this.widget!=null){return this.widget}else{throw new Error("Transform widget was not initialized. The canvas element may not have been initialized.")}}}componentDidLoad(){window.addEventListener("pointermove",this.handlePointerMove);this.canvasResizeObserver=new ResizeObserver(this.handleResize);this.inputResizeObserver=new ResizeObserver(this.handleInputResize);this.hostStyleObserver=new MutationObserver(this.handleStyleChange);if(this.canvasRef!=null){this.canvasResizeObserver.observe(this.canvasRef);this.setupTransformWidget(this.canvasRef)}this.hostStyleObserver.observe(this.hostEl,{attributes:true,attributeFilter:["style"]});this.handleViewerChanged(this.viewer,undefined);this.handleStyleChange()}disconnectedCallback(){var i,t,s,n,o;window.removeEventListener("pointermove",this.handlePointerMove);(i=this.canvasResizeObserver)===null||i===void 0?void 0:i.disconnect();(t=this.inputResizeObserver)===null||t===void 0?void 0:t.disconnect();(s=this.hostStyleObserver)===null||s===void 0?void 0:s.disconnect();(n=this.hoveredChangeDisposable)===null||n===void 0?void 0:n.dispose();(o=this.widget)===null||o===void 0?void 0:o.dispose()}componentDidRender(){if(this.inputShouldFocus&&this.inputRef!=null){k(this.inputRef);this.inputShouldFocus=false}}async EXPERIMENTAL_undo(){var i,t;const s=await((i=this.controller)===null||i===void 0?void 0:i.EXPERIMENTAL_undoTransform());if(this.currentTransform!=null&&s!=null){this.currentTransform=d.multiply(this.currentTransform,s);(t=this.widget)===null||t===void 0?void 0:t.updateTransform(this.currentTransform);this.updateInputPosition();this.updateInputValue();this.lastInputValue=this.inputValue;this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=u.fromRotationMatrix(this.currentTransform)}}handleViewerChanged(i,t){var s;t===null||t===void 0?void 0:t.removeEventListener("frameDrawn",this.handleViewerFrameDrawn);t===null||t===void 0?void 0:t.removeEventListener("dimensionschange",this.handleViewerDimensionsChange);i===null||i===void 0?void 0:i.addEventListener("frameDrawn",this.handleViewerFrameDrawn);i===null||i===void 0?void 0:i.addEventListener("dimensionschange",this.handleViewerDimensionsChange);if((i===null||i===void 0?void 0:i.stream)!=null){(s=this.controller)===null||s===void 0?void 0:s.dispose();this.controller=new y(i.stream)}}handleDisabledPropertyChanged(){var i;(i=this.widget)===null||i===void 0?void 0:i.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}handleTransformHandleScalarChanged(){var i;const t=this.getTranslationScalar();const s=this.getRotationScalar();(i=this.widget)===null||i===void 0?void 0:i.updateScalars({xTranslation:t,yTranslation:t,zTranslation:t,xyTranslation:s,xzTranslation:s,yzTranslation:s,xRotation:s,yRotation:s,zRotation:s})}handleRotationChanged(i,t){var s;const n=i!==null&&i!==void 0?i:u.create();this.currentTransform=this.getTransformForNewRotation(n);this.startingTransform=this.currentTransform;if(i==null&&this.currentTransform!=null&&d.isIdentity(this.currentTransform)){this.currentTransform=undefined;this.startingTransform=this.currentTransform}(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);console.debug(`Updating widget rotation [previous=${JSON.stringify(t)}, current=${JSON.stringify(i)}]`);this.rotationChanged.emit(i)}handlePositionChanged(i,t){var s,n;this.currentTransform=this.getTransformForNewPosition(i);this.startingTransform=this.currentTransform;console.debug(`Updating widget position [previous=${JSON.stringify(t)}, current=${JSON.stringify(i)}]`);(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);if(i==null){this.lastDragged=undefined;this.inputPosition=undefined;(n=this.controller)===null||n===void 0?void 0:n.clearTransform()}this.positionChanged.emit(i)}handleInputFormattingChanged(){this.updateInputValue();this.lastInputValue=this.inputValue}render(){var t,s,o,l,h,e;return i(n,{key:"fdc062cb3cafa311baca827e03a765052e1ab2c8"},i("canvas",{key:"c6c9d413e971ef3db3b3eed7e9ff6c8387fff1d1",ref:i=>{this.canvasRef=i},class:p("widget",{hovered:this.hovered!=null}),tabindex:"0",width:(t=this.viewer)===null||t===void 0?void 0:t.viewport.width,height:(s=this.viewer)===null||s===void 0?void 0:s.viewport.height,onPointerDown:this.handleBeginDrag,onKeyDown:this.handleKeyDown}),this.showInputs&&this.inputPosition&&((o=this.viewer)===null||o===void 0?void 0:o.viewport)&&i(ii,{key:"7eb3550df7db8c95f3597d1bd8d7b05c70e11696",ref:i=>{var t,s;if(i!=null){(t=this.inputResizeObserver)===null||t===void 0?void 0:t.observe(i)}else if(this.inputRef!=null){(s=this.inputResizeObserver)===null||s===void 0?void 0:s.unobserve(this.inputRef)}this.inputWrapperRef=i},bounds:this.inputBounds,viewport:this.viewer.viewport,point:this.inputPosition.point,placement:this.inputPosition.placement,displayUnit:this.getDisplayedUnits()},i(ti,{key:"84e2ff6825856c6d5f0ffff1771861ed6087bedb",ref:i=>{this.inputRef=i},identifier:(h=(l=this.dragging)===null||l===void 0?void 0:l.identifier)!==null&&h!==void 0?h:(e=this.lastDragged)===null||e===void 0?void 0:e.identifier,disabled:this.isEndingTransform,onChange:this.handleInputChange,onIncrement:()=>this.handleInputStep(1),onDecrement:()=>this.handleInputStep(-1),onBlur:()=>{this.inputShouldFocus=false},onUndo:this.EXPERIMENTAL_undoKeybindings?()=>this.EXPERIMENTAL_undo():undefined})))}transform(i,t,s){var n,o;if(this.position!=null&&this.startingTransform!=null&&this.currentTransform!=null&&this.dragging!=null&&this.viewer!=null&&this.viewer.frame!=null){this.currentTransform=K(this.currentTransform,i,t,(n=this.viewer)===null||n===void 0?void 0:n.frame.scene.camera.viewVector,s,this.dragging.identifier);this.getTransformWidget().updateTransform(this.currentTransform);(o=this.controller)===null||o===void 0?void 0:o.updateTransform(d.multiply(d.invert(this.startingTransform),this.currentTransform))}}handleSettingDisabledAxis(){if(this.widget){this.widget.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}else{console.warn("Cannot set disabled values - no widget defined")}}get hostEl(){return o(this)}static get watchers(){return{viewer:[{handleViewerChanged:0}],xTranslationDisabled:[{handleDisabledPropertyChanged:0}],yTranslationDisabled:[{handleDisabledPropertyChanged:0}],zTranslationDisabled:[{handleDisabledPropertyChanged:0}],xyTranslationDisabled:[{handleDisabledPropertyChanged:0}],xzTranslationDisabled:[{handleDisabledPropertyChanged:0}],yzTranslationDisabled:[{handleDisabledPropertyChanged:0}],xRotationDisabled:[{handleDisabledPropertyChanged:0}],yRotationDisabled:[{handleDisabledPropertyChanged:0}],zRotationDisabled:[{handleDisabledPropertyChanged:0}],translationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotation:[{handleRotationChanged:0}],position:[{handlePositionChanged:0}],distanceUnit:[{handleInputFormattingChanged:0}],angleUnit:[{handleInputFormattingChanged:0}],decimalPlaces:[{handleInputFormattingChanged:0}]}}};ci.style=vi();export{ci as vertex_viewer_transform_widget};
5
+ //# sourceMappingURL=p-ef02ec4c.entry.js.map
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
+ */
4
+ import{a as t}from"./p-CG9AChtV.js";var e={};var n={};var i={};var r;function s(){if(r)return i;r=1;Object.defineProperty(i,"__esModule",{value:true});i.DefaultSerializer=i.extendSerializer=void 0;function t(t,e){const n=t.deserialize.bind(t);const i=t.serialize.bind(t);return{deserialize(t){return e.deserialize(t,n)},serialize(t){return e.serialize(t,i)}}}i.extendSerializer=t;const e={deserialize(t){return Object.assign(Error(t.message),{name:t.name,stack:t.stack})},serialize(t){return{__error_marker:"$$error",message:t.message,name:t.name,stack:t.stack}}};const n=t=>t&&typeof t==="object"&&"__error_marker"in t&&t.__error_marker==="$$error";i.DefaultSerializer={deserialize(t){if(n(t)){return e.deserialize(t)}else{return t}},serialize(t){if(t instanceof Error){return e.serialize(t)}else{return t}}};return i}var o;function a(){if(o)return n;o=1;Object.defineProperty(n,"__esModule",{value:true});n.serialize=n.deserialize=n.registerSerializer=void 0;const t=s();let e=t.DefaultSerializer;function i(n){e=t.extendSerializer(e,n)}n.registerSerializer=i;function r(t){return e.deserialize(t)}n.deserialize=r;function a(t){return e.serialize(t)}n.serialize=a;return n}var f={};var c={};var u={};var l;function h(){if(l)return u;l=1;Object.defineProperty(u,"__esModule",{value:true});u.getBundleURL=u.getBaseURL=void 0;let t;function e(){if(!t){t=n()}return t}u.getBundleURL=e;function n(){try{throw new Error}catch(t){const e=(""+t.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);if(e){return i(e[0])}}return"/"}function i(t){return(""+t).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)?\/[^/]+(?:\?.*)?$/,"$1")+"/"}u.getBaseURL=i;return u}var d;function y(){if(d)return c;d=1;Object.defineProperty(c,"__esModule",{value:true});c.isWorkerRuntime=c.getWorkerImplementation=c.defaultPoolSize=void 0;const t=h();c.defaultPoolSize=typeof navigator!=="undefined"&&navigator.hardwareConcurrency?navigator.hardwareConcurrency:4;const e=t=>/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(t);function n(t){const e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function i(){if(typeof Worker==="undefined"){return class t{constructor(){throw Error("No web worker implementation available. You might have tried to spawn a worker within a worker in a browser that doesn't support workers in workers.")}}}class i extends Worker{constructor(i,r){var s,o;if(typeof i==="string"&&r&&r._baseURL){i=new URL(i,r._baseURL)}else if(typeof i==="string"&&!e(i)&&t.getBundleURL().match(/^file:\/\//i)){i=new URL(i,t.getBundleURL().replace(/\/[^\/]+$/,"/"));if((s=r===null||r===void 0?void 0:r.CORSWorkaround)!==null&&s!==void 0?s:true){i=n(`importScripts(${JSON.stringify(i)});`)}}if(typeof i==="string"&&e(i)){if((o=r===null||r===void 0?void 0:r.CORSWorkaround)!==null&&o!==void 0?o:true){i=n(`importScripts(${JSON.stringify(i)});`)}}super(i,r)}}class r extends i{constructor(t,e){const n=window.URL.createObjectURL(t);super(n,e)}static fromText(t,e){const n=new window.Blob([t],{type:"text/javascript"});return new r(n,e)}}return{blob:r,default:i}}let r;function s(){if(!r){r=i()}return r}c.getWorkerImplementation=s;function o(){const t=typeof self!=="undefined"&&typeof Window!=="undefined"&&self instanceof Window;return typeof self!=="undefined"&&self.postMessage&&!t?true:false}c.isWorkerRuntime=o;return c}var p={};var w={exports:{}};var b;var m;function g(){if(m)return b;m=1;var t=1e3;var e=t*60;var n=e*60;var i=n*24;var r=i*7;var s=i*365.25;b=function(t,e){e=e||{};var n=typeof t;if(n==="string"&&t.length>0){return o(t)}else if(n==="number"&&isFinite(t)){return e.long?f(t):a(t)}throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function o(o){o=String(o);if(o.length>100){return}var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(!a){return}var f=parseFloat(a[1]);var c=(a[2]||"ms").toLowerCase();switch(c){case"years":case"year":case"yrs":case"yr":case"y":return f*s;case"weeks":case"week":case"w":return f*r;case"days":case"day":case"d":return f*i;case"hours":case"hour":case"hrs":case"hr":case"h":return f*n;case"minutes":case"minute":case"mins":case"min":case"m":return f*e;case"seconds":case"second":case"secs":case"sec":case"s":return f*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return undefined}}function a(r){var s=Math.abs(r);if(s>=i){return Math.round(r/i)+"d"}if(s>=n){return Math.round(r/n)+"h"}if(s>=e){return Math.round(r/e)+"m"}if(s>=t){return Math.round(r/t)+"s"}return r+"ms"}function f(r){var s=Math.abs(r);if(s>=i){return c(r,s,i,"day")}if(s>=n){return c(r,s,n,"hour")}if(s>=e){return c(r,s,e,"minute")}if(s>=t){return c(r,s,t,"second")}return r+" ms"}function c(t,e,n,i){var r=e>=n*1.5;return Math.round(t/n)+" "+i+(r?"s":"")}return b}var _;var v;function k(){if(v)return _;v=1;function t(t){n.debug=n;n.default=n;n.coerce=f;n.disable=o;n.enable=r;n.enabled=a;n.humanize=g();n.destroy=c;Object.keys(t).forEach((e=>{n[e]=t[e]}));n.names=[];n.skips=[];n.formatters={};function e(t){let e=0;for(let n=0;n<t.length;n++){e=(e<<5)-e+t.charCodeAt(n);e|=0}return n.colors[Math.abs(e)%n.colors.length]}n.selectColor=e;function n(t){let e;let r=null;let s;let o;function a(...t){if(!a.enabled){return}const i=a;const r=Number(new Date);const s=r-(e||r);i.diff=s;i.prev=e;i.curr=r;e=r;t[0]=n.coerce(t[0]);if(typeof t[0]!=="string"){t.unshift("%O")}let o=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,((e,r)=>{if(e==="%%"){return"%"}o++;const s=n.formatters[r];if(typeof s==="function"){const n=t[o];e=s.call(i,n);t.splice(o,1);o--}return e}));n.formatArgs.call(i,t);const f=i.log||n.log;f.apply(i,t)}a.namespace=t;a.useColors=n.useColors();a.color=n.selectColor(t);a.extend=i;a.destroy=n.destroy;Object.defineProperty(a,"enabled",{enumerable:true,configurable:false,get:()=>{if(r!==null){return r}if(s!==n.namespaces){s=n.namespaces;o=n.enabled(t)}return o},set:t=>{r=t}});if(typeof n.init==="function"){n.init(a)}return a}function i(t,e){const i=n(this.namespace+(typeof e==="undefined"?":":e)+t);i.log=this.log;return i}function r(t){n.save(t);n.namespaces=t;n.names=[];n.skips=[];const e=(typeof t==="string"?t:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const t of e){if(t[0]==="-"){n.skips.push(t.slice(1))}else{n.names.push(t)}}}function s(t,e){let n=0;let i=0;let r=-1;let s=0;while(n<t.length){if(i<e.length&&(e[i]===t[n]||e[i]==="*")){if(e[i]==="*"){r=i;s=n;i++}else{n++;i++}}else if(r!==-1){i=r+1;s++;n=s}else{return false}}while(i<e.length&&e[i]==="*"){i++}return i===e.length}function o(){const t=[...n.names,...n.skips.map((t=>"-"+t))].join(",");n.enable("");return t}function a(t){for(const e of n.skips){if(s(t,e)){return false}}for(const e of n.names){if(s(t,e)){return true}}return false}function f(t){if(t instanceof Error){return t.stack||t.message}return t}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}n.enable(n.load());return n}_=t;return _}var E;function x(){if(E)return w.exports;E=1;(function(t,e){e.formatArgs=i;e.save=r;e.load=s;e.useColors=n;e.storage=o();e.destroy=(()=>{let t=false;return()=>{if(!t){t=true;console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}}})();e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){if(typeof window!=="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)){return true}if(typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)){return false}let t;return typeof document!=="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!=="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!=="undefined"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(e){e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff);if(!this.useColors){return}const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let i=0;let r=0;e[0].replace(/%[a-zA-Z%]/g,(t=>{if(t==="%%"){return}i++;if(t==="%c"){r=i}}));e.splice(r,0,n)}e.log=console.debug||console.log||(()=>{});function r(t){try{if(t){e.storage.setItem("debug",t)}else{e.storage.removeItem("debug")}}catch(t){}}function s(){let t;try{t=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch(t){}if(!t&&typeof process!=="undefined"&&"env"in process){t=process.env.DEBUG}return t}function o(){try{return localStorage}catch(t){}}t.exports=k()(e);const{formatters:a}=t.exports;a.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}})(w,w.exports);return w.exports}var A=undefined&&undefined.__awaiter||function(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(i.next(t))}catch(t){s(t)}}function a(t){try{f(i["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):r(t.value).then(o,a)}f((i=i.apply(t,e||[])).next())}))};class C{constructor(t){this._baseObserver=t;this._pendingPromises=new Set}complete(){Promise.all(this._pendingPromises).then((()=>this._baseObserver.complete())).catch((t=>this._baseObserver.error(t)))}error(t){this._baseObserver.error(t)}schedule(t){const e=Promise.all(this._pendingPromises);const n=[];const i=t=>n.push(t);const r=Promise.resolve().then((()=>A(this,void 0,void 0,(function*(){yield e;yield t(i);this._pendingPromises.delete(r);for(const t of n){this._baseObserver.next(t)}})))).catch((t=>{this._pendingPromises.delete(r);this._baseObserver.error(t)}));this._pendingPromises.add(r)}}const U=()=>typeof Symbol==="function";const T=t=>U()&&Boolean(Symbol[t]);const O=t=>T(t)?Symbol[t]:"@@"+t;if(!T("asyncIterator")){Symbol.asyncIterator=Symbol.asyncIterator||Symbol.for("Symbol.asyncIterator")}const F=O("iterator");const j=O("observable");const S=O("species");function I(t,e){const n=t[e];if(n==null){return undefined}if(typeof n!=="function"){throw new TypeError(n+" is not a function")}return n}function B(t){let e=t.constructor;if(e!==undefined){e=e[S];if(e===null){e=undefined}}return e!==undefined?e:H}function M(t){return t instanceof H}function R(t){if(R.log){R.log(t)}else{setTimeout((()=>{throw t}),0)}}function P(t){Promise.resolve().then((()=>{try{t()}catch(t){R(t)}}))}function D(t){const e=t._cleanup;if(e===undefined){return}t._cleanup=undefined;if(!e){return}try{if(typeof e==="function"){e()}else{const t=I(e,"unsubscribe");if(t){t.call(e)}}}catch(t){R(t)}}function L(t){t._observer=undefined;t._queue=undefined;t._state="closed"}function z(t){const e=t._queue;if(!e){return}t._queue=undefined;t._state="ready";for(const n of e){$(t,n.type,n.value);if(t._state==="closed"){break}}}function $(t,e,n){t._state="running";const i=t._observer;try{const r=i?I(i,e):undefined;switch(e){case"next":if(r)r.call(i,n);break;case"error":L(t);if(r)r.call(i,n);else throw n;break;case"complete":L(t);if(r)r.call(i);break}}catch(t){R(t)}if(t._state==="closed"){D(t)}else if(t._state==="running"){t._state="ready"}}function N(t,e,n){if(t._state==="closed"){return}if(t._state==="buffering"){t._queue=t._queue||[];t._queue.push({type:e,value:n});return}if(t._state!=="ready"){t._state="buffering";t._queue=[{type:e,value:n}];P((()=>z(t)));return}$(t,e,n)}class Z{constructor(t,e){this._cleanup=undefined;this._observer=t;this._queue=undefined;this._state="initializing";const n=new W(this);try{this._cleanup=e.call(undefined,n)}catch(t){n.error(t)}if(this._state==="initializing"){this._state="ready"}}get closed(){return this._state==="closed"}unsubscribe(){if(this._state!=="closed"){L(this);D(this)}}}class W{constructor(t){this._subscription=t}get closed(){return this._subscription._state==="closed"}next(t){N(this._subscription,"next",t)}error(t){N(this._subscription,"error",t)}complete(){N(this._subscription,"complete")}}class H{constructor(t){if(!(this instanceof H)){throw new TypeError("Observable cannot be called as a function")}if(typeof t!=="function"){throw new TypeError("Observable initializer must be a function")}this._subscriber=t}subscribe(t,e,n){if(typeof t!=="object"||t===null){t={next:t,error:e,complete:n}}return new Z(t,this._subscriber)}pipe(t,...e){let n=this;for(const i of[t,...e]){n=i(n)}return n}tap(t,e,n){const i=typeof t!=="object"||t===null?{next:t,error:e,complete:n}:t;return new H((t=>this.subscribe({next(e){i.next&&i.next(e);t.next(e)},error(e){i.error&&i.error(e);t.error(e)},complete(){i.complete&&i.complete();t.complete()},start(t){i.start&&i.start(t)}})))}forEach(t){return new Promise(((e,n)=>{if(typeof t!=="function"){n(new TypeError(t+" is not a function"));return}function i(){r.unsubscribe();e(undefined)}const r=this.subscribe({next(e){try{t(e,i)}catch(t){n(t);r.unsubscribe()}},error(t){n(t)},complete(){e(undefined)}})}))}map(t){if(typeof t!=="function"){throw new TypeError(t+" is not a function")}const e=B(this);return new e((e=>this.subscribe({next(n){let i=n;try{i=t(n)}catch(t){return e.error(t)}e.next(i)},error(t){e.error(t)},complete(){e.complete()}})))}filter(t){if(typeof t!=="function"){throw new TypeError(t+" is not a function")}const e=B(this);return new e((e=>this.subscribe({next(n){try{if(!t(n))return}catch(t){return e.error(t)}e.next(n)},error(t){e.error(t)},complete(){e.complete()}})))}reduce(t,e){if(typeof t!=="function"){throw new TypeError(t+" is not a function")}const n=B(this);const i=arguments.length>1;let r=false;let s=e;return new n((e=>this.subscribe({next(n){const o=!r;r=true;if(!o||i){try{s=t(s,n)}catch(t){return e.error(t)}}else{s=n}},error(t){e.error(t)},complete(){if(!r&&!i){return e.error(new TypeError("Cannot reduce an empty sequence"))}e.next(s);e.complete()}})))}concat(...t){const e=B(this);return new e((n=>{let i;let r=0;function s(o){i=o.subscribe({next(t){n.next(t)},error(t){n.error(t)},complete(){if(r===t.length){i=undefined;n.complete()}else{s(e.from(t[r++]))}}})}s(this);return()=>{if(i){i.unsubscribe();i=undefined}}}))}flatMap(t){if(typeof t!=="function"){throw new TypeError(t+" is not a function")}const e=B(this);return new e((n=>{const i=[];const r=this.subscribe({next(r){let o;if(t){try{o=t(r)}catch(t){return n.error(t)}}else{o=r}const a=e.from(o).subscribe({next(t){n.next(t)},error(t){n.error(t)},complete(){const t=i.indexOf(a);if(t>=0)i.splice(t,1);s()}});i.push(a)},error(t){n.error(t)},complete(){s()}});function s(){if(r.closed&&i.length===0){n.complete()}}return()=>{i.forEach((t=>t.unsubscribe()));r.unsubscribe()}}))}[j](){return this}static from(t){const e=typeof this==="function"?this:H;if(t==null){throw new TypeError(t+" is not an object")}const n=I(t,j);if(n){const i=n.call(t);if(Object(i)!==i){throw new TypeError(i+" is not an object")}if(M(i)&&i.constructor===e){return i}return new e((t=>i.subscribe(t)))}if(T("iterator")){const n=I(t,F);if(n){return new e((e=>{P((()=>{if(e.closed)return;for(const i of n.call(t)){e.next(i);if(e.closed)return}e.complete()}))}))}}if(Array.isArray(t)){return new e((e=>{P((()=>{if(e.closed)return;for(const n of t){e.next(n);if(e.closed)return}e.complete()}))}))}throw new TypeError(t+" is not observable")}static of(...t){const e=typeof this==="function"?this:H;return new e((e=>{P((()=>{if(e.closed)return;for(const n of t){e.next(n);if(e.closed)return}e.complete()}))}))}static get[S](){return this}}if(U()){Object.defineProperty(H,Symbol("extensions"),{value:{symbol:j,hostReportError:R},configurable:true})}function q(t){if(typeof t==="function"){t()}else if(t&&typeof t.unsubscribe==="function"){t.unsubscribe()}}var K=undefined&&undefined.__awaiter||function(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(i.next(t))}catch(t){s(t)}}function a(t){try{f(i["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):r(t.value).then(o,a)}f((i=i.apply(t,e||[])).next())}))};function Q(t){return e=>new H((n=>{const i=new C(n);const r=e.subscribe({complete(){i.complete()},error(t){i.error(t)},next(e){i.schedule((n=>K(this,void 0,void 0,(function*(){if(yield t(e)){n(e)}}))))}});return()=>q(r)}))}function G(t){return t&&T("asyncIterator")&&t[Symbol.asyncIterator]}function J(t){return t&&T("iterator")&&t[Symbol.iterator]}var V=undefined&&undefined.__awaiter||function(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(i.next(t))}catch(t){s(t)}}function a(t){try{f(i["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):r(t.value).then(o,a)}f((i=i.apply(t,e||[])).next())}))};var Y=undefined&&undefined.__asyncValues||function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof __values==="function"?__values(t):t[Symbol.iterator](),n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n);function i(e){n[e]=t[e]&&function(n){return new Promise((function(i,s){n=t[e](n),r(i,s,n.done,n.value)}))}}function r(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)}};function X(t){return e=>new H((n=>{const i=new C(n);const r=e.subscribe({complete(){i.complete()},error(t){i.error(t)},next(e){i.schedule((n=>V(this,void 0,void 0,(function*(){var i,r;const s=yield t(e);if(J(s)||G(s)){try{for(var o=Y(s),a;a=yield o.next(),!a.done;){const t=a.value;n(t)}}catch(t){i={error:t}}finally{try{if(a&&!a.done&&(r=o.return))yield r.call(o)}finally{if(i)throw i.error}}}else{s.map((t=>n(t)))}}))))}});return()=>q(r)}))}function tt(t){return new H((e=>{let n=0;const i=setInterval((()=>{e.next(n++)}),t);return()=>clearInterval(i)}))}var et=undefined&&undefined.__awaiter||function(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(i.next(t))}catch(t){s(t)}}function a(t){try{f(i["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):r(t.value).then(o,a)}f((i=i.apply(t,e||[])).next())}))};function nt(t){return e=>new H((n=>{const i=new C(n);const r=e.subscribe({complete(){i.complete()},error(t){i.error(t)},next(e){i.schedule((n=>et(this,void 0,void 0,(function*(){const i=yield t(e);n(i)}))))}});return()=>q(r)}))}function it(...t){if(t.length===0){return H.from([])}return new H((e=>{let n=0;const i=t.map((i=>i.subscribe({error(t){e.error(t);r()},next(t){e.next(t)},complete(){if(++n===t.length){e.complete();r()}}})));const r=()=>{i.forEach((t=>q(t)))};return r}))}class rt extends H{constructor(){super((t=>{this._observers.add(t);return()=>this._observers.delete(t)}));this._observers=new Set}next(t){for(const e of this._observers){e.next(t)}}error(t){for(const e of this._observers){e.error(t)}}complete(){for(const t of this._observers){t.complete()}}}function st(t){const e=new rt;let n;let i=0;return new H((r=>{if(!n){n=t.subscribe(e)}const s=e.subscribe(r);i++;return()=>{i--;s.unsubscribe();if(i===0){q(n);n=undefined}}}))}var ot=undefined&&undefined.__awaiter||function(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(i.next(t))}catch(t){s(t)}}function a(t){try{f(i["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):r(t.value).then(o,a)}f((i=i.apply(t,e||[])).next())}))};function at(t,e){return n=>new H((i=>{let r;let s=0;const o=new C(i);const a=n.subscribe({complete(){o.complete()},error(t){o.error(t)},next(n){o.schedule((i=>ot(this,void 0,void 0,(function*(){const o=s===0?typeof e==="undefined"?n:e:r;r=yield t(o,n,s++);i(r)}))))}});return()=>q(a)}))}var ft=Object.freeze({__proto__:null,Observable:H,Subject:rt,filter:Q,flatMap:X,interval:tt,map:nt,merge:it,multicast:st,scan:at,unsubscribe:q});var ct=t(ft);var ut={};var lt;function ht(){if(lt)return ut;lt=1;Object.defineProperty(ut,"__esModule",{value:true});ut.allSettled=void 0;function t(t){return Promise.all(t.map((t=>{const e=t=>({status:"fulfilled",value:t});const n=t=>({status:"rejected",reason:t});const i=Promise.resolve(t);try{return i.then(e,n)}catch(t){return Promise.reject(t)}})))}ut.allSettled=t;return ut}var dt={};var yt;function pt(){if(yt)return dt;yt=1;(function(t){Object.defineProperty(t,"__esModule",{value:true});t.PoolEventType=void 0;(function(t){t["initialized"]="initialized";t["taskCanceled"]="taskCanceled";t["taskCompleted"]="taskCompleted";t["taskFailed"]="taskFailed";t["taskQueued"]="taskQueued";t["taskQueueDrained"]="taskQueueDrained";t["taskStart"]="taskStart";t["terminated"]="terminated"})(t.PoolEventType||(t.PoolEventType={}))})(dt);return dt}var wt={};var bt={};var mt;function gt(){if(mt)return bt;mt=1;Object.defineProperty(bt,"__esModule",{value:true});bt.$worker=bt.$transferable=bt.$terminate=bt.$events=bt.$errors=void 0;bt.$errors=Symbol("thread.errors");bt.$events=Symbol("thread.events");bt.$terminate=Symbol("thread.terminate");bt.$transferable=Symbol("thread.transferable");bt.$worker=Symbol("thread.worker");return bt}var _t;function vt(){if(_t)return wt;_t=1;Object.defineProperty(wt,"__esModule",{value:true});wt.Thread=void 0;const t=gt();function e(t){throw Error(t)}wt.Thread={errors(n){return n[t.$errors]||e("Error observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},events(n){return n[t.$events]||e("Events observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},terminate(e){return e[t.$terminate]()}};return wt}var kt;function Et(){if(kt)return p;kt=1;(function(t){var e=p&&p.__awaiter||function(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(i.next(t))}catch(t){s(t)}}function a(t){try{f(i["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):r(t.value).then(o,a)}f((i=i.apply(t,e||[])).next())}))};var n=p&&p.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(t,"__esModule",{value:true});t.Pool=t.Thread=t.PoolEventType=void 0;const i=n(x());const r=ct;const s=ht();const o=y();const a=pt();Object.defineProperty(t,"PoolEventType",{enumerable:true,get:function(){return a.PoolEventType}});const f=vt();Object.defineProperty(t,"Thread",{enumerable:true,get:function(){return f.Thread}});let c=1;function u(t){const e=[];for(let n=0;n<t;n++){e.push(n)}return e}function l(t){return new Promise((e=>setTimeout(e,t)))}function h(t,e){return t.reduce(((t,n)=>[...t,...e(n)]),[])}function d(t){return t.replace(/\W/g," ").trim().replace(/\s+/g,"-")}function w(t,e){return u(e).map((()=>({init:t(),runningTasks:[]})))}class b{constructor(t,e){this.eventSubject=new r.Subject;this.initErrors=[];this.isClosing=false;this.nextTaskID=1;this.taskQueue=[];const n=typeof e==="number"?{size:e}:e||{};const{size:s=o.defaultPoolSize}=n;this.debug=i.default(`threads:pool:${d(n.name||String(c++))}`);this.options=n;this.workers=w(t,s);this.eventObservable=r.multicast(r.Observable.from(this.eventSubject));Promise.all(this.workers.map((t=>t.init))).then((()=>this.eventSubject.next({type:a.PoolEventType.initialized,size:this.workers.length})),(t=>{this.debug("Error while initializing pool worker:",t);this.eventSubject.error(t);this.initErrors.push(t)}))}findIdlingWorker(){const{concurrency:t=1}=this.options;return this.workers.find((e=>e.runningTasks.length<t))}runPoolTask(t,n){return e(this,void 0,void 0,(function*(){const e=this.workers.indexOf(t)+1;this.debug(`Running task #${n.id} on worker #${e}...`);this.eventSubject.next({type:a.PoolEventType.taskStart,taskID:n.id,workerID:e});try{const i=yield n.run(yield t.init);this.debug(`Task #${n.id} completed successfully`);this.eventSubject.next({type:a.PoolEventType.taskCompleted,returnValue:i,taskID:n.id,workerID:e})}catch(t){this.debug(`Task #${n.id} failed`);this.eventSubject.next({type:a.PoolEventType.taskFailed,taskID:n.id,error:t,workerID:e})}}))}run(t,n){return e(this,void 0,void 0,(function*(){const i=(()=>e(this,void 0,void 0,(function*(){const e=()=>{t.runningTasks=t.runningTasks.filter((t=>t!==i))};yield l(0);try{yield this.runPoolTask(t,n)}finally{e();if(!this.isClosing){this.scheduleWork()}}})))();t.runningTasks.push(i)}))}scheduleWork(){this.debug(`Attempt de-queueing a task in order to run it...`);const t=this.findIdlingWorker();if(!t)return;const e=this.taskQueue.shift();if(!e){this.debug(`Task queue is empty`);this.eventSubject.next({type:a.PoolEventType.taskQueueDrained});return}this.run(t,e)}taskCompletion(t){return new Promise(((e,n)=>{const i=this.events().subscribe((r=>{if(r.type===a.PoolEventType.taskCompleted&&r.taskID===t){i.unsubscribe();e(r.returnValue)}else if(r.type===a.PoolEventType.taskFailed&&r.taskID===t){i.unsubscribe();n(r.error)}else if(r.type===a.PoolEventType.terminated){i.unsubscribe();n(Error("Pool has been terminated before task was run."))}}))}))}settled(t=false){return e(this,void 0,void 0,(function*(){const e=()=>h(this.workers,(t=>t.runningTasks));const n=[];const i=this.eventObservable.subscribe((t=>{if(t.type===a.PoolEventType.taskFailed){n.push(t.error)}}));if(this.initErrors.length>0){return Promise.reject(this.initErrors[0])}if(t&&this.taskQueue.length===0){yield s.allSettled(e());return n}yield new Promise(((t,e)=>{const n=this.eventObservable.subscribe({next(e){if(e.type===a.PoolEventType.taskQueueDrained){n.unsubscribe();t(void 0)}},error:e})}));yield s.allSettled(e());i.unsubscribe();return n}))}completed(t=false){return e(this,void 0,void 0,(function*(){const e=this.settled(t);const n=new Promise(((t,n)=>{const i=this.eventObservable.subscribe({next(r){if(r.type===a.PoolEventType.taskQueueDrained){i.unsubscribe();t(e)}else if(r.type===a.PoolEventType.taskFailed){i.unsubscribe();n(r.error)}},error:n})}));const i=yield Promise.race([e,n]);if(i.length>0){throw i[0]}}))}events(){return this.eventObservable}queue(t){const{maxQueuedJobs:e=Infinity}=this.options;if(this.isClosing){throw Error(`Cannot schedule pool tasks after terminate() has been called.`)}if(this.initErrors.length>0){throw this.initErrors[0]}const n=this.nextTaskID++;const i=this.taskCompletion(n);i.catch((t=>{this.debug(`Task #${n} errored:`,t)}));const r={id:n,run:t,cancel:()=>{if(this.taskQueue.indexOf(r)===-1)return;this.taskQueue=this.taskQueue.filter((t=>t!==r));this.eventSubject.next({type:a.PoolEventType.taskCanceled,taskID:r.id})},then:i.then.bind(i)};if(this.taskQueue.length>=e){throw Error("Maximum number of pool tasks queued. Refusing to queue another one.\n"+"This usually happens for one of two reasons: We are either at peak "+"workload right now or some tasks just won't finish, thus blocking the pool.")}this.debug(`Queueing task #${r.id}...`);this.taskQueue.push(r);this.eventSubject.next({type:a.PoolEventType.taskQueued,taskID:r.id});this.scheduleWork();return r}terminate(t){return e(this,void 0,void 0,(function*(){this.isClosing=true;if(!t){yield this.completed(true)}this.eventSubject.next({type:a.PoolEventType.terminated,remainingQueue:[...this.taskQueue]});this.eventSubject.complete();yield Promise.all(this.workers.map((t=>e(this,void 0,void 0,(function*(){return f.Thread.terminate(yield t.init)})))))}))}}b.EventType=a.PoolEventType;function m(t,e){return new b(t,e)}m.EventType=a.PoolEventType;t.Pool=m})(p);return p}var xt={};var At={};var Ct;function Ut(){if(Ct)return At;Ct=1;Object.defineProperty(At,"__esModule",{value:true});At.createPromiseWithResolver=void 0;const t=()=>undefined;function e(){let e=false;let n;let i=t;const r=new Promise((t=>{if(e){t(n)}else{i=t}}));const s=t=>{e=true;n=t;i(n)};return[r,s]}At.createPromiseWithResolver=e;return At}var Tt={};var Ot;function Ft(){if(Ot)return Tt;Ot=1;(function(t){Object.defineProperty(t,"__esModule",{value:true});t.WorkerEventType=void 0;(function(t){t["internalError"]="internalError";t["message"]="message";t["termination"]="termination"})(t.WorkerEventType||(t.WorkerEventType={}))})(Tt);return Tt}var jt={};var St={};var It;function Bt(){if(It)return St;It=1;Object.defineProperty(St,"__esModule",{value:true});St.ObservablePromise=void 0;const t=ct;const e=()=>undefined;const n=t=>t;const i=t=>Promise.resolve().then(t);function r(t){throw t}function s(t){return t&&typeof t.then==="function"}class o extends t.Observable{constructor(t){super((e=>{const n=this;const i=Object.assign(Object.assign({},e),{complete(){e.complete();n.onCompletion()},error(t){e.error(t);n.onError(t)},next(t){e.next(t);n.onNext(t)}});try{this.initHasRun=true;return t(i)}catch(t){i.error(t)}}));this.initHasRun=false;this.fulfillmentCallbacks=[];this.rejectionCallbacks=[];this.firstValueSet=false;this.state="pending"}onNext(t){if(!this.firstValueSet){this.firstValue=t;this.firstValueSet=true}}onError(t){this.state="rejected";this.rejection=t;for(const e of this.rejectionCallbacks){i((()=>e(t)))}}onCompletion(){this.state="fulfilled";for(const t of this.fulfillmentCallbacks){i((()=>t(this.firstValue)))}}then(t,e){const i=t||n;const s=e||r;let o=false;return new Promise(((t,e)=>{const n=n=>{if(o)return;o=true;try{t(s(n))}catch(t){e(t)}};const r=e=>{try{t(i(e))}catch(t){n(t)}};if(!this.initHasRun){this.subscribe({error:n})}if(this.state==="fulfilled"){return t(i(this.firstValue))}if(this.state==="rejected"){o=true;return t(s(this.rejection))}this.fulfillmentCallbacks.push(r);this.rejectionCallbacks.push(n)}))}catch(t){return this.then(undefined,t)}finally(t){const n=t||e;return this.then((t=>{n();return t}),(()=>n()))}static from(t){if(s(t)){return new o((e=>{const n=t=>{e.next(t);e.complete()};const i=t=>{e.error(t)};t.then(n,i)}))}else{return super.from(t)}}}St.ObservablePromise=o;return St}var Mt={};var Rt;function Pt(){if(Rt)return Mt;Rt=1;Object.defineProperty(Mt,"__esModule",{value:true});Mt.Transfer=Mt.isTransferDescriptor=void 0;const t=gt();function e(t){if(!t||typeof t!=="object")return false;return true}function n(e){return e&&typeof e==="object"&&e[t.$transferable]}Mt.isTransferDescriptor=n;function i(n,i){if(!i){if(!e(n))throw Error();i=[n]}return{[t.$transferable]:true,send:n,transferables:i}}Mt.Transfer=i;return Mt}var Dt={};var Lt;function zt(){if(Lt)return Dt;Lt=1;(function(t){Object.defineProperty(t,"__esModule",{value:true});t.WorkerMessageType=t.MasterMessageType=void 0;(function(t){t["cancel"]="cancel";t["run"]="run"})(t.MasterMessageType||(t.MasterMessageType={}));(function(t){t["error"]="error";t["init"]="init";t["result"]="result";t["running"]="running";t["uncaughtError"]="uncaughtError"})(t.WorkerMessageType||(t.WorkerMessageType={}))})(Dt);return Dt}var $t;function Nt(){if($t)return jt;$t=1;var t=jt&&jt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(jt,"__esModule",{value:true});jt.createProxyModule=jt.createProxyFunction=void 0;const e=t(x());const n=ct;const i=a();const r=Bt();const s=Pt();const o=zt();const f=e.default("threads:master:messages");let c=1;const u=t=>Array.from(new Set(t));const l=t=>t&&t.type===o.WorkerMessageType.error;const h=t=>t&&t.type===o.WorkerMessageType.result;const d=t=>t&&t.type===o.WorkerMessageType.running;function y(t,e){return new n.Observable((n=>{let r;const s=o=>{f("Message from worker:",o.data);if(!o.data||o.data.uid!==e)return;if(d(o.data)){r=o.data.resultType}else if(h(o.data)){if(r==="promise"){if(typeof o.data.payload!=="undefined"){n.next(i.deserialize(o.data.payload))}n.complete();t.removeEventListener("message",s)}else{if(o.data.payload){n.next(i.deserialize(o.data.payload))}if(o.data.complete){n.complete();t.removeEventListener("message",s)}}}else if(l(o.data)){const e=i.deserialize(o.data.error);if(r==="promise"||!r){n.error(e)}else{n.error(e)}t.removeEventListener("message",s)}};t.addEventListener("message",s);return()=>{if(r==="observable"||!r){const n={type:o.MasterMessageType.cancel,uid:e};t.postMessage(n)}t.removeEventListener("message",s)}}))}function p(t){if(t.length===0){return{args:[],transferables:[]}}const e=[];const n=[];for(const r of t){if(s.isTransferDescriptor(r)){e.push(i.serialize(r.send));n.push(...r.transferables)}else{e.push(i.serialize(r))}}return{args:e,transferables:n.length===0?n:u(n)}}function w(t,e){return(...i)=>{const s=c++;const{args:a,transferables:u}=p(i);const l={type:o.MasterMessageType.run,uid:s,method:e,args:a};f("Sending command to run function to worker:",l);try{t.postMessage(l,u)}catch(t){return r.ObservablePromise.from(Promise.reject(t))}return r.ObservablePromise.from(n.multicast(y(t,s)))}}jt.createProxyFunction=w;function b(t,e){const n={};for(const i of e){n[i]=w(t,i)}return n}jt.createProxyModule=b;return jt}var Zt;function Wt(){if(Zt)return xt;Zt=1;var t=xt&&xt.__awaiter||function(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(i.next(t))}catch(t){s(t)}}function a(t){try{f(i["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):r(t.value).then(o,a)}f((i=i.apply(t,e||[])).next())}))};var e=xt&&xt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(xt,"__esModule",{value:true});xt.spawn=void 0;const n=e(x());const i=ct;const r=a();const s=Ut();const o=gt();const f=Ft();const c=Nt();const u=n.default("threads:master:messages");const l=n.default("threads:master:spawn");const h=n.default("threads:master:thread-utils");const d=t=>t&&t.type==="init";const y=t=>t&&t.type==="uncaughtError";const p=typeof process!=="undefined"&&process.env.THREADS_WORKER_INIT_TIMEOUT?Number.parseInt(process.env.THREADS_WORKER_INIT_TIMEOUT,10):1e4;function w(e,n,i){return t(this,void 0,void 0,(function*(){let t;const r=new Promise(((e,r)=>{t=setTimeout((()=>r(Error(i))),n)}));const s=yield Promise.race([e,r]);clearTimeout(t);return s}))}function b(t){return new Promise(((e,n)=>{const i=s=>{u("Message from worker before finishing initialization:",s.data);if(d(s.data)){t.removeEventListener("message",i);e(s.data)}else if(y(s.data)){t.removeEventListener("message",i);n(r.deserialize(s.data.error))}};t.addEventListener("message",i)}))}function m(t,e){return new i.Observable((n=>{const i=t=>{const e={type:f.WorkerEventType.message,data:t.data};n.next(e)};const r=t=>{h("Unhandled promise rejection event in thread:",t);const e={type:f.WorkerEventType.internalError,error:Error(t.reason)};n.next(e)};t.addEventListener("message",i);t.addEventListener("unhandledrejection",r);e.then((()=>{const e={type:f.WorkerEventType.termination};t.removeEventListener("message",i);t.removeEventListener("unhandledrejection",r);n.next(e);n.complete()}))}))}function g(e){const[n,i]=s.createPromiseWithResolver();const r=()=>t(this,void 0,void 0,(function*(){h("Terminating worker");yield e.terminate();i()}));return{terminate:r,termination:n}}function _(t,e,n,i){const r=n.filter((t=>t.type===f.WorkerEventType.internalError)).map((t=>t.error));return Object.assign(t,{[o.$errors]:r,[o.$events]:n,[o.$terminate]:i,[o.$worker]:e})}function v(e,n){return t(this,void 0,void 0,(function*(){l("Initializing new thread");const t=n&&n.timeout?n.timeout:p;const i=yield w(b(e),t,`Timeout: Did not receive an init message from worker after ${t}ms. Make sure the worker calls expose().`);const r=i.exposed;const{termination:s,terminate:o}=g(e);const a=m(e,s);if(r.type==="function"){const t=c.createProxyFunction(e);return _(t,e,a,o)}else if(r.type==="module"){const t=c.createProxyModule(e,r.methods);return _(t,e,a,o)}else{const t=r.type;throw Error(`Worker init message states unexpected type of expose(): ${t}`)}}))}xt.spawn=v;return xt}var Ht;function qt(){if(Ht)return f;Ht=1;(function(t){Object.defineProperty(t,"__esModule",{value:true});t.Worker=t.BlobWorker=t.isWorkerRuntime=t.Thread=t.spawn=t.Pool=void 0;const e=y();Object.defineProperty(t,"isWorkerRuntime",{enumerable:true,get:function(){return e.isWorkerRuntime}});var n=Et();Object.defineProperty(t,"Pool",{enumerable:true,get:function(){return n.Pool}});var i=Wt();Object.defineProperty(t,"spawn",{enumerable:true,get:function(){return i.spawn}});var r=vt();Object.defineProperty(t,"Thread",{enumerable:true,get:function(){return r.Thread}});t.BlobWorker=e.getWorkerImplementation().blob;t.Worker=e.getWorkerImplementation().default})(f);return f}var Kt={};var Qt;var Gt;function Jt(){if(Gt)return Qt;Gt=1;Qt=t=>{if(!t){return false}if(typeof Symbol.observable==="symbol"&&typeof t[Symbol.observable]==="function"){return t===t[Symbol.observable]()}if(typeof t["@@observable"]==="function"){return t===t["@@observable"]()}return false};return Qt}var Vt={};var Yt;function Xt(){if(Yt)return Vt;Yt=1;Object.defineProperty(Vt,"__esModule",{value:true});const t=function t(){const e=typeof self!=="undefined"&&typeof Window!=="undefined"&&self instanceof Window;return typeof self!=="undefined"&&self.postMessage&&!e?true:false};const e=function t(e,n){self.postMessage(e,n)};const n=function t(e){const n=t=>{e(t.data)};const i=()=>{self.removeEventListener("message",n)};self.addEventListener("message",n);return i};Vt.default={isWorkerRuntime:t,postMessageToMaster:e,subscribeToMasterMessages:n};return Vt}var te;function ee(){if(te)return Kt;te=1;(function(t){var e=Kt&&Kt.__awaiter||function(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(i.next(t))}catch(t){s(t)}}function a(t){try{f(i["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):r(t.value).then(o,a)}f((i=i.apply(t,e||[])).next())}))};var n=Kt&&Kt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(t,"__esModule",{value:true});t.expose=t.isWorkerRuntime=t.Transfer=t.registerSerializer=void 0;const i=n(Jt());const r=a();const s=Pt();const o=zt();const f=n(Xt());var c=a();Object.defineProperty(t,"registerSerializer",{enumerable:true,get:function(){return c.registerSerializer}});var u=Pt();Object.defineProperty(t,"Transfer",{enumerable:true,get:function(){return u.Transfer}});t.isWorkerRuntime=f.default.isWorkerRuntime;let l=false;const h=new Map;const d=t=>t&&t.type===o.MasterMessageType.cancel;const y=t=>t&&t.type===o.MasterMessageType.run;const p=t=>i.default(t)||w(t);function w(t){return t&&typeof t==="object"&&typeof t.subscribe==="function"}function b(t){return s.isTransferDescriptor(t)?{payload:t.send,transferables:t.transferables}:{payload:t,transferables:undefined}}function m(){const t={type:o.WorkerMessageType.init,exposed:{type:"function"}};f.default.postMessageToMaster(t)}function g(t){const e={type:o.WorkerMessageType.init,exposed:{type:"module",methods:t}};f.default.postMessageToMaster(e)}function _(t,e){const{payload:n,transferables:i}=b(e);const s={type:o.WorkerMessageType.error,uid:t,error:r.serialize(n)};f.default.postMessageToMaster(s,i)}function v(t,e,n){const{payload:i,transferables:r}=b(n);const s={type:o.WorkerMessageType.result,uid:t,complete:e?true:undefined,payload:i};f.default.postMessageToMaster(s,r)}function k(t,e){const n={type:o.WorkerMessageType.running,uid:t,resultType:e};f.default.postMessageToMaster(n)}function E(t){try{const e={type:o.WorkerMessageType.uncaughtError,error:r.serialize(t)};f.default.postMessageToMaster(e)}catch(e){console.error("Not reporting uncaught error back to master thread as it "+"occured while reporting an uncaught error already."+"\nLatest error:",e,"\nOriginal error:",t)}}function x(t,n,i){return e(this,void 0,void 0,(function*(){let e;try{e=n(...i)}catch(e){return _(t,e)}const s=p(e)?"observable":"promise";k(t,s);if(p(e)){const n=e.subscribe((e=>v(t,false,r.serialize(e))),(e=>{_(t,r.serialize(e));h.delete(t)}),(()=>{v(t,true);h.delete(t)}));h.set(t,n)}else{try{const n=yield e;v(t,true,r.serialize(n))}catch(e){_(t,r.serialize(e))}}}))}function A(t){if(!f.default.isWorkerRuntime()){throw Error("expose() called in the master thread.")}if(l){throw Error("expose() called more than once. This is not possible. Pass an object to expose() if you want to expose multiple functions.")}l=true;if(typeof t==="function"){f.default.subscribeToMasterMessages((e=>{if(y(e)&&!e.method){x(e.uid,t,e.args.map(r.deserialize))}}));m()}else if(typeof t==="object"&&t){f.default.subscribeToMasterMessages((e=>{if(y(e)&&e.method){x(e.uid,t[e.method],e.args.map(r.deserialize))}}));const e=Object.keys(t).filter((e=>typeof t[e]==="function"));g(e)}else{throw Error(`Invalid argument passed to expose(). Expected a function or an object, got: ${t}`)}f.default.subscribeToMasterMessages((t=>{if(d(t)){const e=t.uid;const n=h.get(e);if(n){n.unsubscribe();h.delete(e)}}}))}t.expose=A;if(typeof self!=="undefined"&&typeof self.addEventListener==="function"&&f.default.isWorkerRuntime()){self.addEventListener("error",(t=>{setTimeout((()=>E(t.error||t)),250)}));self.addEventListener("unhandledrejection",(t=>{const e=t.reason;if(e&&typeof e.message==="string"){setTimeout((()=>E(e)),250)}}))}if(typeof process!=="undefined"&&typeof process.on==="function"&&f.default.isWorkerRuntime()){process.on("uncaughtException",(t=>{setTimeout((()=>E(t)),250)}));process.on("unhandledRejection",(t=>{if(t&&typeof t.message==="string"){setTimeout((()=>E(t)),250)}}))}})(Kt);return Kt}var ne;function ie(){if(ne)return e;ne=1;(function(t){var n=e&&e.__createBinding||(Object.create?function(t,e,n,i){if(i===undefined)i=n;Object.defineProperty(t,i,{enumerable:true,get:function(){return e[n]}})}:function(t,e,n,i){if(i===undefined)i=n;t[i]=e[n]});var i=e&&e.__exportStar||function(t,e){for(var i in t)if(i!=="default"&&!Object.prototype.hasOwnProperty.call(e,i))n(e,t,i)};Object.defineProperty(t,"__esModule",{value:true});t.Transfer=t.DefaultSerializer=t.expose=t.registerSerializer=void 0;var r=a();Object.defineProperty(t,"registerSerializer",{enumerable:true,get:function(){return r.registerSerializer}});i(qt(),t);var o=ee();Object.defineProperty(t,"expose",{enumerable:true,get:function(){return o.expose}});var f=s();Object.defineProperty(t,"DefaultSerializer",{enumerable:true,get:function(){return f.DefaultSerializer}});var c=Pt();Object.defineProperty(t,"Transfer",{enumerable:true,get:function(){return c.Transfer}})})(e);return e}var re=ie();class se{constructor(){this.threads=[];this.pools=[]}addThread(t){this.threads.push(t)}addPool(t){this.pools.push(t)}async terminate(t=false){await Promise.all([...this.threads.map((t=>re.Thread.terminate(t))),...this.pools.map((e=>e.terminate(t)))])}}function oe(){if(typeof globalThis!=="undefined"){return globalThis}else if(typeof self!=="undefined"){return self}else if(typeof window!=="undefined"){return window}else if(typeof global!=="undefined"){return global}throw new Error("unable to locate global object")}var ae=oe();function fe(t,e){const n=ae[e];return n!=null&&t instanceof n}function ce(t){return fe(t,"ArrayBuffer")||fe(t,"MessagePort")||fe(t,"ImageBitmap")||fe(t,"OffscreenCanvas")}function ue(t){return fe(t,"Int8Array")||fe(t,"Uint8Array")||fe(t,"Uint8ClampedArray")||fe(t,"Int16Array")||fe(t,"Uint16Array")||fe(t,"Int32Array")||fe(t,"Uint32Array")||fe(t,"Float32Array")||fe(t,"Float64Array")||fe(t,"BigInt64Array")||fe(t,"BigUint64Array")}function le(t){if(ce(t)){return re.Transfer(t)}else if(t!=null&&typeof t==="object"){const e=he(t);return re.Transfer(t,e)}else{return t}}function he(t){if(ce(t)){return[t]}else if(typeof t==="object"){if(Array.isArray(t)){const e=[];t.forEach((t=>e.push(...he(t))));return e}else if(ue(t)){return[t.buffer]}else if(t!=null){return Object.values(t).reduce(((t,e)=>{t.push(...he(e));return t}),[])}else{return[]}}else{return[]}}const de="png-decoder-worker.js";const ye=`!function(){"use strict";const t={deserialize:t=>Object.assign(Error(t.message),{name:t.name,stack:t.stack}),serialize:t=>({__error_marker:"$$error",message:t.message,name:t.name,stack:t.stack})};let e={deserialize(e){return(i=e)&&"object"==typeof i&&"__error_marker"in i&&"$$error"===i.__error_marker?t.deserialize(e):e;var i},serialize:e=>e instanceof Error?t.serialize(e):e};function i(t){return e.deserialize(t)}function n(t){return e.serialize(t)}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}const s=Symbol("thread.transferable");function a(t,e){if(!e){if(!(i=t)||"object"!=typeof i)throw Error();e=[t]}var i;return{[s]:!0,send:t,transferables:e}}var o,h,f,l;!function(t){t.cancel="cancel",t.run="run"}(o||(o={})),function(t){t.error="error",t.init="init",t.result="result",t.running="running",t.uncaughtError="uncaughtError"}(h||(h={}));var d=r(l?f:(l=1,f=t=>!!t&&("symbol"==typeof Symbol.observable&&"function"==typeof t[Symbol.observable]?t===t[Symbol.observable]():"function"==typeof t["@@observable"]&&t===t["@@observable"]())));var c=function(){const t="undefined"!=typeof self&&"undefined"!=typeof Window&&self instanceof Window;return!("undefined"==typeof self||!self.postMessage||t)},u=function(t,e){self.postMessage(t,e)},p=function(t){const e=e=>{t(e.data)};return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}},w=function(t,e,i,n){return new(i||(i=Promise))(function(r,s){function a(t){try{h(n.next(t))}catch(t){s(t)}}function o(t){try{h(n.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(a,o)}h((n=n.apply(t,e||[])).next())})};let b=!1;const _=new Map,g=t=>t&&t.type===o.run,y=t=>d(t)||function(t){return t&&"object"==typeof t&&"function"==typeof t.subscribe}(t);function m(t){return function(t){return t&&"object"==typeof t&&t[s]}(t)?{payload:t.send,transferables:t.transferables}:{payload:t,transferables:void 0}}function k(t,e){const{payload:i,transferables:r}=m(e),s={type:h.error,uid:t,error:n(i)};u(s,r)}function v(t,e,i){const{payload:n,transferables:r}=m(i),s={type:h.result,uid:t,complete:!!e||void 0,payload:n};u(s,r)}function A(t){try{const e={type:h.uncaughtError,error:n(t)};u(e)}catch(e){console.error("Not reporting uncaught error back to master thread as it occured while reporting an uncaught error already.Latest error:",e,"Original error:",t)}}function E(t,e,i){return w(this,void 0,void 0,function*(){let r;try{r=e(...i)}catch(e){return k(t,e)}const s=y(r)?"observable":"promise";if(function(t,e){const i={type:h.running,uid:t,resultType:e};u(i)}(t,s),y(r)){const e=r.subscribe(e=>v(t,!1,n(e)),e=>{k(t,n(e)),_.delete(t)},()=>{v(t,!0),_.delete(t)});_.set(t,e)}else try{const e=yield r;v(t,!0,n(e))}catch(e){k(t,n(e))}})}function x(t){if(!c())throw Error("expose() called in the master thread.");if(b)throw Error("expose() called more than once. This is not possible. Pass an object to expose() if you want to expose multiple functions.");if(b=!0,"function"==typeof t)p(e=>{g(e)&&!e.method&&E(e.uid,t,e.args.map(i))}),function(){const t={type:h.init,exposed:{type:"function"}};u(t)}();else{if("object"!=typeof t||!t)throw Error(\`Invalid argument passed to expose(). Expected a function or an object, got: \${t}\`);p(e=>{g(e)&&e.method&&E(e.uid,t[e.method],e.args.map(i))});!function(t){const e={type:h.init,exposed:{type:"module",methods:t}};u(e)}(Object.keys(t).filter(e=>"function"==typeof t[e]))}p(t=>{if((e=t)&&e.type===o.cancel){const e=t.uid,i=_.get(e);i&&(i.unsubscribe(),_.delete(e))}var e})}"undefined"!=typeof self&&"function"==typeof self.addEventListener&&c()&&(self.addEventListener("error",t=>{setTimeout(()=>A(t.error||t),250)}),self.addEventListener("unhandledrejection",t=>{const e=t.reason;e&&"string"==typeof e.message&&setTimeout(()=>A(e),250)})),"undefined"!=typeof process&&"function"==typeof process.on&&c()&&(process.on("uncaughtException",t=>{setTimeout(()=>A(t),250)}),process.on("unhandledRejection",t=>{t&&"string"==typeof t.message&&setTimeout(()=>A(t),250)}));var U=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();function T(t,e){const i=U[e];return null!=i&&t instanceof i}function B(t){return T(t,"ArrayBuffer")||T(t,"MessagePort")||T(t,"ImageBitmap")||T(t,"OffscreenCanvas")}function O(t){if(B(t))return a(t);if(null!=t&&"object"==typeof t){return a(t,C(t))}return t}function C(t){if(B(t))return[t];if("object"==typeof t){if(Array.isArray(t)){const e=[];return t.forEach(t=>e.push(...C(t))),e}return function(t){return T(t,"Int8Array")||T(t,"Uint8Array")||T(t,"Uint8ClampedArray")||T(t,"Int16Array")||T(t,"Uint16Array")||T(t,"Int32Array")||T(t,"Uint32Array")||T(t,"Float32Array")||T(t,"Float64Array")||T(t,"BigInt64Array")||T(t,"BigUint64Array")}(t)?[t.buffer]:null!=t?Object.values(t).reduce((t,e)=>(t.push(...C(e)),t),[]):[]}return[]}function I(t,e="utf8"){return new TextDecoder(e).decode(t)}const R=new TextEncoder;const S=(()=>{const t=new Uint8Array(4);return!((new Uint32Array(t.buffer)[0]=1)&t[0])})(),D={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class M{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=8192,e={}){let i=!1;"number"==typeof t?t=new ArrayBuffer(t):(i=!0,this.lastWrittenByte=t.byteLength);const n=e.offset?e.offset>>>0:0,r=t.byteLength-n;let s=n;(ArrayBuffer.isView(t)||t instanceof M)&&(t.byteLength!==t.buffer.byteLength&&(s=t.byteOffset+n),t=t.buffer),this.lastWrittenByte=i?r:0,this.buffer=t,this.length=r,this.byteLength=r,this.byteOffset=s,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,s,r),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}back(t=1){return this.offset-=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){const e=2*(this.offset+t),i=new Uint8Array(e);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=e,this.byteLength=e,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){return this.readArray(t,"uint8")}readArray(t,e){const i=D[e].BYTES_PER_ELEMENT*t,n=this.byteOffset+this.offset,r=this.buffer.slice(n,n+i);if(this.littleEndian===S&&"uint8"!==e&&"int8"!==e){const t=new Uint8Array(this.buffer.slice(n,n+i));t.reverse();const r=new D[e](t.buffer);return this.offset+=i,r.reverse(),r}const s=new D[e](r);return this.offset+=i,s}readInt16(){const t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){const t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){const t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){const t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){const t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){const t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readBigInt64(){const t=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,t}readBigUint64(){const t=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let e="";for(let i=0;i<t;i++)e+=this.readChar();return e}readUtf8(t=1){return I(this.readBytes(t))}decodeText(t=1,e="utf8"){return I(this.readBytes(t),e)}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let e=0;e<t.length;e++)this._data.setUint8(this.offset++,t[e]);return this._updateLastWrittenByte(),this}writeInt16(t){return this.ensureAvailable(2),this._data.setInt16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(t){return this.ensureAvailable(2),this._data.setUint16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(t){return this.ensureAvailable(4),this._data.setInt32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(t){return this.ensureAvailable(4),this._data.setUint32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(t){return this.ensureAvailable(4),this._data.setFloat32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(t){return this.ensureAvailable(8),this._data.setFloat64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(t){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(t){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(t){return this.writeUint8(t.charCodeAt(0))}writeChars(t){for(let e=0;e<t.length;e++)this.writeUint8(t.charCodeAt(e));return this}writeUtf8(t){return this.writeBytes(function(t){return R.encode(t)}(t))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function L(t){let e=t.length;for(;--e>=0;)t[e]=0}L(new Array(576));L(new Array(60));L(new Array(512));L(new Array(256));L(new Array(29));L(new Array(30));var F=(t,e,i,n)=>{let r=65535&t,s=t>>>16&65535,a=0;for(;0!==i;){a=i>2e3?2e3:i,i-=a;do{r=r+e[n++]|0,s=s+r|0}while(--a);r%=65521,s%=65521}return r|s<<16};const N=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var Z=(t,e,i,n)=>{const r=N,s=n+i;t^=-1;for(let i=n;i<s;i++)t=t>>>8^r[255&(t^e[i])];return-1^t},$={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},P={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const j=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var z=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)j(i,e)&&(t[e]=i[e])}}return t},W=t=>{let e=0;for(let i=0,n=t.length;i<n;i++)e+=t[i].length;const i=new Uint8Array(e);for(let e=0,n=0,r=t.length;e<r;e++){let r=t[e];i.set(r,n),n+=r.length}return i};let H=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){H=!1}const K=new Uint8Array(256);for(let t=0;t<256;t++)K[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;K[254]=K[254]=1;var G=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,i,n,r,s,a=t.length,o=0;for(r=0;r<a;r++)i=t.charCodeAt(r),55296==(64512&i)&&r+1<a&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(o),s=0,r=0;s<o;r++)i=t.charCodeAt(r),55296==(64512&i)&&r+1<a&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?e[s++]=i:i<2048?(e[s++]=192|i>>>6,e[s++]=128|63&i):i<65536?(e[s++]=224|i>>>12,e[s++]=128|i>>>6&63,e[s++]=128|63&i):(e[s++]=240|i>>>18,e[s++]=128|i>>>12&63,e[s++]=128|i>>>6&63,e[s++]=128|63&i);return e},q=(t,e)=>{const i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,r;const s=new Array(2*i);for(r=0,n=0;n<i;){let e=t[n++];if(e<128){s[r++]=e;continue}let a=K[e];if(a>4)s[r++]=65533,n+=a-1;else{for(e&=2===a?31:3===a?15:7;a>1&&n<i;)e=e<<6|63&t[n++],a--;a>1?s[r++]=65533:e<65536?s[r++]=e:(e-=65536,s[r++]=55296|e>>10&1023,s[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&H)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n<e;n++)i+=String.fromCharCode(t[n]);return i})(s,r)},Y=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+K[t[i]]>e?i:e};var V=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const X=16209;var J=function(t,e){let i,n,r,s,a,o,h,f,l,d,c,u,p,w,b,_,g,y,m,k,v,A,E,x;const U=t.state;i=t.next_in,E=t.input,n=i+(t.avail_in-5),r=t.next_out,x=t.output,s=r-(e-t.avail_out),a=r+(t.avail_out-257),o=U.dmax,h=U.wsize,f=U.whave,l=U.wnext,d=U.window,c=U.hold,u=U.bits,p=U.lencode,w=U.distcode,b=(1<<U.lenbits)-1,_=(1<<U.distbits)-1;t:do{u<15&&(c+=E[i++]<<u,u+=8,c+=E[i++]<<u,u+=8),g=p[c&b];e:for(;;){if(y=g>>>24,c>>>=y,u-=y,y=g>>>16&255,0===y)x[r++]=65535&g;else{if(!(16&y)){if(64&y){if(32&y){U.mode=16191;break t}t.msg="invalid literal/length code",U.mode=X;break t}g=p[(65535&g)+(c&(1<<y)-1)];continue e}for(m=65535&g,y&=15,y&&(u<y&&(c+=E[i++]<<u,u+=8),m+=c&(1<<y)-1,c>>>=y,u-=y),u<15&&(c+=E[i++]<<u,u+=8,c+=E[i++]<<u,u+=8),g=w[c&_];;){if(y=g>>>24,c>>>=y,u-=y,y=g>>>16&255,16&y){if(k=65535&g,y&=15,u<y&&(c+=E[i++]<<u,u+=8,u<y&&(c+=E[i++]<<u,u+=8)),k+=c&(1<<y)-1,k>o){t.msg="invalid distance too far back",U.mode=X;break t}if(c>>>=y,u-=y,y=r-s,k>y){if(y=k-y,y>f&&U.sane){t.msg="invalid distance too far back",U.mode=X;break t}if(v=0,A=d,0===l){if(v+=h-y,y<m){m-=y;do{x[r++]=d[v++]}while(--y);v=r-k,A=x}}else if(l<y){if(v+=h+l-y,y-=l,y<m){m-=y;do{x[r++]=d[v++]}while(--y);if(v=0,l<m){y=l,m-=y;do{x[r++]=d[v++]}while(--y);v=r-k,A=x}}}else if(v+=l-y,y<m){m-=y;do{x[r++]=d[v++]}while(--y);v=r-k,A=x}for(;m>2;)x[r++]=A[v++],x[r++]=A[v++],x[r++]=A[v++],m-=3;m&&(x[r++]=A[v++],m>1&&(x[r++]=A[v++]))}else{v=r-k;do{x[r++]=x[v++],x[r++]=x[v++],x[r++]=x[v++],m-=3}while(m>2);m&&(x[r++]=x[v++],m>1&&(x[r++]=x[v++]))}break}if(64&y){t.msg="invalid distance code",U.mode=X;break t}g=w[(65535&g)+(c&(1<<y)-1)]}}break}}while(i<n&&r<a);m=u>>3,i-=m,u-=m<<3,c&=(1<<u)-1,t.next_in=i,t.next_out=r,t.avail_in=i<n?n-i+5:5-(i-n),t.avail_out=r<a?a-r+257:257-(r-a),U.hold=c,U.bits=u};const Q=15,tt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),et=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),it=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),nt=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var rt=(t,e,i,n,r,s,a,o)=>{const h=o.bits;let f,l,d,c,u,p,w=0,b=0,_=0,g=0,y=0,m=0,k=0,v=0,A=0,E=0,x=null;const U=new Uint16Array(16),T=new Uint16Array(16);let B,O,C,I=null;for(w=0;w<=Q;w++)U[w]=0;for(b=0;b<n;b++)U[e[i+b]]++;for(y=h,g=Q;g>=1&&0===U[g];g--);if(y>g&&(y=g),0===g)return r[s++]=20971520,r[s++]=20971520,o.bits=1,0;for(_=1;_<g&&0===U[_];_++);for(y<_&&(y=_),v=1,w=1;w<=Q;w++)if(v<<=1,v-=U[w],v<0)return-1;if(v>0&&(0===t||1!==g))return-1;for(T[1]=0,w=1;w<Q;w++)T[w+1]=T[w]+U[w];for(b=0;b<n;b++)0!==e[i+b]&&(a[T[e[i+b]]++]=b);if(0===t?(x=I=a,p=20):1===t?(x=tt,I=et,p=257):(x=it,I=nt,p=0),E=0,b=0,w=_,u=s,m=y,k=0,d=-1,A=1<<y,c=A-1,1===t&&A>852||2===t&&A>592)return 1;for(;;){B=w-k,a[b]+1<p?(O=0,C=a[b]):a[b]>=p?(O=I[a[b]-p],C=x[a[b]-p]):(O=96,C=0),f=1<<w-k,l=1<<m,_=l;do{l-=f,r[u+(E>>k)+l]=B<<24|O<<16|C}while(0!==l);for(f=1<<w-1;E&f;)f>>=1;if(0!==f?(E&=f-1,E+=f):E=0,b++,0===--U[w]){if(w===g)break;w=e[i+a[b]]}if(w>y&&(E&c)!==d){for(0===k&&(k=y),u+=_,m=w-k,v=1<<m;m+k<g&&(v-=U[m+k],!(v<=0));)m++,v<<=1;if(A+=1<<m,1===t&&A>852||2===t&&A>592)return 1;d=E&c,r[d]=y<<24|m<<16|u-s}}return 0!==E&&(r[u+E]=w-k<<24|64<<16),o.bits=y,0};const{Z_FINISH:st,Z_BLOCK:at,Z_TREES:ot,Z_OK:ht,Z_STREAM_END:ft,Z_NEED_DICT:lt,Z_STREAM_ERROR:dt,Z_DATA_ERROR:ct,Z_MEM_ERROR:ut,Z_BUF_ERROR:pt,Z_DEFLATED:wt}=P,bt=16180,_t=16190,gt=16191,yt=16192,mt=16194,kt=16199,vt=16200,At=16206,Et=16209,xt=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Ut(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Tt=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<bt||e.mode>16211?1:0},Bt=t=>{if(Tt(t))return dt;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=bt,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,ht},Ot=t=>{if(Tt(t))return dt;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Bt(t)},Ct=(t,e)=>{let i;if(Tt(t))return dt;const n=t.state;return e<0?(i=0,e=-e):(i=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?dt:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,Ot(t))},It=(t,e)=>{if(!t)return dt;const i=new Ut;t.state=i,i.strm=t,i.window=null,i.mode=bt;const n=Ct(t,e);return n!==ht&&(t.state=null),n};let Rt,St,Dt=!0;const Mt=t=>{if(Dt){Rt=new Int32Array(512),St=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(rt(1,t.lens,0,288,Rt,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;rt(2,t.lens,0,32,St,0,t.work,{bits:5}),Dt=!1}t.lencode=Rt,t.lenbits=9,t.distcode=St,t.distbits=5},Lt=(t,e,i,n)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(e.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(e.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0};var Ft={inflateReset:Ot,inflateReset2:Ct,inflateResetKeep:Bt,inflateInit:t=>It(t,15),inflateInit2:It,inflate:(t,e)=>{let i,n,r,s,a,o,h,f,l,d,c,u,p,w,b,_,g,y,m,k,v,A,E=0;const x=new Uint8Array(4);let U,T;const B=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Tt(t)||!t.output||!t.input&&0!==t.avail_in)return dt;i=t.state,i.mode===gt&&(i.mode=yt),a=t.next_out,r=t.output,h=t.avail_out,s=t.next_in,n=t.input,o=t.avail_in,f=i.hold,l=i.bits,d=o,c=h,A=ht;t:for(;;)switch(i.mode){case bt:if(0===i.wrap){i.mode=yt;break}for(;l<16;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}if(2&i.wrap&&35615===f){0===i.wbits&&(i.wbits=15),i.check=0,x[0]=255&f,x[1]=f>>>8&255,i.check=Z(i.check,x,2,0),f=0,l=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&f)<<8)+(f>>8))%31){t.msg="incorrect header check",i.mode=Et;break}if((15&f)!==wt){t.msg="unknown compression method",i.mode=Et;break}if(f>>>=4,l-=4,v=8+(15&f),0===i.wbits&&(i.wbits=v),v>15||v>i.wbits){t.msg="invalid window size",i.mode=Et;break}i.dmax=1<<i.wbits,i.flags=0,t.adler=i.check=1,i.mode=512&f?16189:gt,f=0,l=0;break;case 16181:for(;l<16;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}if(i.flags=f,(255&i.flags)!==wt){t.msg="unknown compression method",i.mode=Et;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=Et;break}i.head&&(i.head.text=f>>8&1),512&i.flags&&4&i.wrap&&(x[0]=255&f,x[1]=f>>>8&255,i.check=Z(i.check,x,2,0)),f=0,l=0,i.mode=16182;case 16182:for(;l<32;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}i.head&&(i.head.time=f),512&i.flags&&4&i.wrap&&(x[0]=255&f,x[1]=f>>>8&255,x[2]=f>>>16&255,x[3]=f>>>24&255,i.check=Z(i.check,x,4,0)),f=0,l=0,i.mode=16183;case 16183:for(;l<16;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}i.head&&(i.head.xflags=255&f,i.head.os=f>>8),512&i.flags&&4&i.wrap&&(x[0]=255&f,x[1]=f>>>8&255,i.check=Z(i.check,x,2,0)),f=0,l=0,i.mode=16184;case 16184:if(1024&i.flags){for(;l<16;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}i.length=f,i.head&&(i.head.extra_len=f),512&i.flags&&4&i.wrap&&(x[0]=255&f,x[1]=f>>>8&255,i.check=Z(i.check,x,2,0)),f=0,l=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(u=i.length,u>o&&(u=o),u&&(i.head&&(v=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+u),v)),512&i.flags&&4&i.wrap&&(i.check=Z(i.check,n,u,s)),o-=u,s+=u,i.length-=u),i.length))break t;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===o)break t;u=0;do{v=n[s+u++],i.head&&v&&i.length<65536&&(i.head.name+=String.fromCharCode(v))}while(v&&u<o);if(512&i.flags&&4&i.wrap&&(i.check=Z(i.check,n,u,s)),o-=u,s+=u,v)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=16187;case 16187:if(4096&i.flags){if(0===o)break t;u=0;do{v=n[s+u++],i.head&&v&&i.length<65536&&(i.head.comment+=String.fromCharCode(v))}while(v&&u<o);if(512&i.flags&&4&i.wrap&&(i.check=Z(i.check,n,u,s)),o-=u,s+=u,v)break t}else i.head&&(i.head.comment=null);i.mode=16188;case 16188:if(512&i.flags){for(;l<16;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}if(4&i.wrap&&f!==(65535&i.check)){t.msg="header crc mismatch",i.mode=Et;break}f=0,l=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=gt;break;case 16189:for(;l<32;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}t.adler=i.check=xt(f),f=0,l=0,i.mode=_t;case _t:if(0===i.havedict)return t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,i.hold=f,i.bits=l,lt;t.adler=i.check=1,i.mode=gt;case gt:if(e===at||e===ot)break t;case yt:if(i.last){f>>>=7&l,l-=7&l,i.mode=At;break}for(;l<3;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}switch(i.last=1&f,f>>>=1,l-=1,3&f){case 0:i.mode=16193;break;case 1:if(Mt(i),i.mode=kt,e===ot){f>>>=2,l-=2;break t}break;case 2:i.mode=16196;break;case 3:t.msg="invalid block type",i.mode=Et}f>>>=2,l-=2;break;case 16193:for(f>>>=7&l,l-=7&l;l<32;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}if((65535&f)!=(f>>>16^65535)){t.msg="invalid stored block lengths",i.mode=Et;break}if(i.length=65535&f,f=0,l=0,i.mode=mt,e===ot)break t;case mt:i.mode=16195;case 16195:if(u=i.length,u){if(u>o&&(u=o),u>h&&(u=h),0===u)break t;r.set(n.subarray(s,s+u),a),o-=u,s+=u,h-=u,a+=u,i.length-=u;break}i.mode=gt;break;case 16196:for(;l<14;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}if(i.nlen=257+(31&f),f>>>=5,l-=5,i.ndist=1+(31&f),f>>>=5,l-=5,i.ncode=4+(15&f),f>>>=4,l-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=Et;break}i.have=0,i.mode=16197;case 16197:for(;i.have<i.ncode;){for(;l<3;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}i.lens[B[i.have++]]=7&f,f>>>=3,l-=3}for(;i.have<19;)i.lens[B[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,U={bits:i.lenbits},A=rt(0,i.lens,0,19,i.lencode,0,i.work,U),i.lenbits=U.bits,A){t.msg="invalid code lengths set",i.mode=Et;break}i.have=0,i.mode=16198;case 16198:for(;i.have<i.nlen+i.ndist;){for(;E=i.lencode[f&(1<<i.lenbits)-1],b=E>>>24,_=E>>>16&255,g=65535&E,!(b<=l);){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}if(g<16)f>>>=b,l-=b,i.lens[i.have++]=g;else{if(16===g){for(T=b+2;l<T;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}if(f>>>=b,l-=b,0===i.have){t.msg="invalid bit length repeat",i.mode=Et;break}v=i.lens[i.have-1],u=3+(3&f),f>>>=2,l-=2}else if(17===g){for(T=b+3;l<T;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}f>>>=b,l-=b,v=0,u=3+(7&f),f>>>=3,l-=3}else{for(T=b+7;l<T;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}f>>>=b,l-=b,v=0,u=11+(127&f),f>>>=7,l-=7}if(i.have+u>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=Et;break}for(;u--;)i.lens[i.have++]=v}}if(i.mode===Et)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=Et;break}if(i.lenbits=9,U={bits:i.lenbits},A=rt(1,i.lens,0,i.nlen,i.lencode,0,i.work,U),i.lenbits=U.bits,A){t.msg="invalid literal/lengths set",i.mode=Et;break}if(i.distbits=6,i.distcode=i.distdyn,U={bits:i.distbits},A=rt(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,U),i.distbits=U.bits,A){t.msg="invalid distances set",i.mode=Et;break}if(i.mode=kt,e===ot)break t;case kt:i.mode=vt;case vt:if(o>=6&&h>=258){t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,i.hold=f,i.bits=l,J(t,c),a=t.next_out,r=t.output,h=t.avail_out,s=t.next_in,n=t.input,o=t.avail_in,f=i.hold,l=i.bits,i.mode===gt&&(i.back=-1);break}for(i.back=0;E=i.lencode[f&(1<<i.lenbits)-1],b=E>>>24,_=E>>>16&255,g=65535&E,!(b<=l);){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}if(_&&!(240&_)){for(y=b,m=_,k=g;E=i.lencode[k+((f&(1<<y+m)-1)>>y)],b=E>>>24,_=E>>>16&255,g=65535&E,!(y+b<=l);){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}f>>>=y,l-=y,i.back+=y}if(f>>>=b,l-=b,i.back+=b,i.length=g,0===_){i.mode=16205;break}if(32&_){i.back=-1,i.mode=gt;break}if(64&_){t.msg="invalid literal/length code",i.mode=Et;break}i.extra=15&_,i.mode=16201;case 16201:if(i.extra){for(T=i.extra;l<T;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}i.length+=f&(1<<i.extra)-1,f>>>=i.extra,l-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;E=i.distcode[f&(1<<i.distbits)-1],b=E>>>24,_=E>>>16&255,g=65535&E,!(b<=l);){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}if(!(240&_)){for(y=b,m=_,k=g;E=i.distcode[k+((f&(1<<y+m)-1)>>y)],b=E>>>24,_=E>>>16&255,g=65535&E,!(y+b<=l);){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}f>>>=y,l-=y,i.back+=y}if(f>>>=b,l-=b,i.back+=b,64&_){t.msg="invalid distance code",i.mode=Et;break}i.offset=g,i.extra=15&_,i.mode=16203;case 16203:if(i.extra){for(T=i.extra;l<T;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}i.offset+=f&(1<<i.extra)-1,f>>>=i.extra,l-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=Et;break}i.mode=16204;case 16204:if(0===h)break t;if(u=c-h,i.offset>u){if(u=i.offset-u,u>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=Et;break}u>i.wnext?(u-=i.wnext,p=i.wsize-u):p=i.wnext-u,u>i.length&&(u=i.length),w=i.window}else w=r,p=a-i.offset,u=i.length;u>h&&(u=h),h-=u,i.length-=u;do{r[a++]=w[p++]}while(--u);0===i.length&&(i.mode=vt);break;case 16205:if(0===h)break t;r[a++]=i.length,h--,i.mode=vt;break;case At:if(i.wrap){for(;l<32;){if(0===o)break t;o--,f|=n[s++]<<l,l+=8}if(c-=h,t.total_out+=c,i.total+=c,4&i.wrap&&c&&(t.adler=i.check=i.flags?Z(i.check,r,c,a-c):F(i.check,r,c,a-c)),c=h,4&i.wrap&&(i.flags?f:xt(f))!==i.check){t.msg="incorrect data check",i.mode=Et;break}f=0,l=0}i.mode=16207;case 16207:if(i.wrap&&i.flags){for(;l<32;){if(0===o)break t;o--,f+=n[s++]<<l,l+=8}if(4&i.wrap&&f!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=Et;break}f=0,l=0}i.mode=16208;case 16208:A=ft;break t;case Et:A=ct;break t;case 16210:return ut;default:return dt}return t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,i.hold=f,i.bits=l,(i.wsize||c!==t.avail_out&&i.mode<Et&&(i.mode<At||e!==st))&&Lt(t,t.output,t.next_out,c-t.avail_out),d-=t.avail_in,c-=t.avail_out,t.total_in+=d,t.total_out+=c,i.total+=c,4&i.wrap&&c&&(t.adler=i.check=i.flags?Z(i.check,r,c,t.next_out-c):F(i.check,r,c,t.next_out-c)),t.data_type=i.bits+(i.last?64:0)+(i.mode===gt?128:0)+(i.mode===kt||i.mode===mt?256:0),(0===d&&0===c||e===st)&&A===ht&&(A=pt),A},inflateEnd:t=>{if(Tt(t))return dt;let e=t.state;return e.window&&(e.window=null),t.state=null,ht},inflateGetHeader:(t,e)=>{if(Tt(t))return dt;const i=t.state;return 2&i.wrap?(i.head=e,e.done=!1,ht):dt},inflateSetDictionary:(t,e)=>{const i=e.length;let n,r,s;return Tt(t)?dt:(n=t.state,0!==n.wrap&&n.mode!==_t?dt:n.mode===_t&&(r=1,r=F(r,e,i,0),r!==n.check)?ct:(s=Lt(t,e,i,i),s?(n.mode=16210,ut):(n.havedict=1,ht)))},inflateInfo:"pako inflate (from Nodeca project)"};var Nt=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Zt=Object.prototype.toString,{Z_NO_FLUSH:$t,Z_FINISH:Pt,Z_OK:jt,Z_STREAM_END:zt,Z_NEED_DICT:Wt,Z_STREAM_ERROR:Ht,Z_DATA_ERROR:Kt,Z_MEM_ERROR:Gt}=P;function qt(t){this.options=z({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new V,this.strm.avail_out=0;let i=Ft.inflateInit2(this.strm,e.windowBits);if(i!==jt)throw new Error($[i]);if(this.header=new Nt,Ft.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=G(e.dictionary):"[object ArrayBuffer]"===Zt.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=Ft.inflateSetDictionary(this.strm,e.dictionary),i!==jt)))throw new Error($[i])}qt.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(a=e===~~e?e:!0===e?Pt:$t,"[object ArrayBuffer]"===Zt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=Ft.inflate(i,a),s===Wt&&r&&(s=Ft.inflateSetDictionary(i,r),s===jt?s=Ft.inflate(i,a):s===Kt&&(s=Wt));i.avail_in>0&&s===zt&&i.state.wrap>0&&0!==t[i.next_in];)Ft.inflateReset(i),s=Ft.inflate(i,a);switch(s){case Ht:case Kt:case Wt:case Gt:return this.onEnd(s),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||s===zt))if("string"===this.options.to){let t=Y(i.output,i.next_out),e=i.next_out-t,r=q(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==jt||0!==o){if(s===zt)return s=Ft.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},qt.prototype.onData=function(t){this.chunks.push(t)},qt.prototype.onEnd=function(t){t===jt&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=W(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Yt={Inflate:qt,inflate:function(t,e){const i=new qt(e);if(i.push(t),i.err)throw i.msg||$[i.err];return i.result}};const{Inflate:Vt,inflate:Xt}=Yt;var Jt=Vt,Qt=Xt;const te=[];for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)1&e?e=3988292384^e>>>1:e>>>=1;te[t]=e}const ee=4294967295;function ie(t,e){return(function(t,e,i){let n=t;for(let t=0;t<i;t++)n=te[255&(n^e[t])]^n>>>8;return n}(ee,t,e)^ee)>>>0}function ne(t,e,i){const n=t.readUint32(),r=ie(new Uint8Array(t.buffer,t.byteOffset+t.offset-e-4,e),e);if(r!==n)throw new Error(\`CRC mismatch for chunk \${i}. Expected \${n}, found \${r}\`)}function re(t,e,i){for(let n=0;n<i;n++)e[n]=t[n]}function se(t,e,i,n){let r=0;for(;r<n;r++)e[r]=t[r];for(;r<i;r++)e[r]=t[r]+e[r-n]&255}function ae(t,e,i,n){let r=0;if(0===i.length)for(;r<n;r++)e[r]=t[r];else for(;r<n;r++)e[r]=t[r]+i[r]&255}function oe(t,e,i,n,r){let s=0;if(0===i.length){for(;s<r;s++)e[s]=t[s];for(;s<n;s++)e[s]=t[s]+(e[s-r]>>1)&255}else{for(;s<r;s++)e[s]=t[s]+(i[s]>>1)&255;for(;s<n;s++)e[s]=t[s]+(e[s-r]+i[s]>>1)&255}}function he(t,e,i,n,r){let s=0;if(0===i.length){for(;s<r;s++)e[s]=t[s];for(;s<n;s++)e[s]=t[s]+e[s-r]&255}else{for(;s<r;s++)e[s]=t[s]+i[s]&255;for(;s<n;s++)e[s]=t[s]+fe(e[s-r],i[s],i[s-r])&255}}function fe(t,e,i){const n=t+e-i,r=Math.abs(n-t),s=Math.abs(n-e),a=Math.abs(n-i);return r<=s&&r<=a?t:s<=a?e:i}function le(t,e,i,n,r,s){switch(t){case 0:re(e,i,r);break;case 1:se(e,i,r,s);break;case 2:ae(e,i,n,r);break;case 3:oe(e,i,n,r,s);break;case 4:he(e,i,n,r,s);break;default:throw new Error(\`Unsupported filter: \${t}\`)}}const de=new Uint16Array([255]),ce=255===new Uint8Array(de.buffer)[0];function ue(t){return(255&t)<<8|t>>8&255}const pe=new Uint16Array([255]),we=255===new Uint8Array(pe.buffer)[0],be=new Uint8Array(0);function _e(t){const{data:e,width:i,height:n,channels:r,depth:s}=t,a=Math.ceil(s/8)*r,o=Math.ceil(s/8*r*i),h=new Uint8Array(n*o);let f,l,d=be,c=0;for(let t=0;t<n;t++){switch(f=e.subarray(c+1,c+1+o),l=h.subarray(t*o,(t+1)*o),e[c]){case 0:re(f,l,o);break;case 1:se(f,l,o,a);break;case 2:ae(f,l,d,o);break;case 3:oe(f,l,d,o,a);break;case 4:he(f,l,d,o,a);break;default:throw new Error(\`Unsupported filter: \${e[c]}\`)}d=l,c+=o+1}if(16===s){const t=new Uint16Array(h.buffer);if(we)for(let e=0;e<t.length;e++)t[e]=ge(t[e]);return t}return h}function ge(t){return(255&t)<<8|t>>8&255}const ye=Uint8Array.of(137,80,78,71,13,10,26,10);function me(t){if(!function(t){if(t.length<ye.length)return!1;for(let e=0;e<ye.length;e++)if(t[e]!==ye[e])return!1;return!0}(t.readBytes(ye.length)))throw new Error("wrong PNG signature")}const ke=new TextDecoder("latin1");function ve(t){if(function(t){if(!Ae.test(t))throw new Error("invalid latin1 text")}(t),0===t.length||t.length>79)throw new Error("keyword length must be between 1 and 79")}const Ae=/^[\0-ÿ]*$/;function Ee(t,e,i){const n=xe(e);t[n]=function(t,e){return ke.decode(t.readBytes(e))}(e,i-n.length-1)}function xe(t){for(t.mark();0!==t.readByte(););const e=t.offset;t.reset();const i=ke.decode(t.readBytes(e-t.offset-1));return t.skip(1),ve(i),i}const Ue=-1,Te=0,Be=2,Oe=3,Ce=4,Ie=6,Re=-1,Se=0,De=-1,Me=0,Le=-1,Fe=0,Ne=1,Ze=0,$e=1,Pe=2,je=0,ze=1;class We extends M{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(t,e={}){super(t);const{checkCrc:i=!1}=e;this._checkCrc=i,this._inflator=new Jt,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=Re,this._filterMethod=De,this._interlaceMethod=Le,this._colorType=Ue,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(me(this);!this._end;){const t=this.readUint32(),e=this.readChars(4);this.decodeChunk(t,e)}return this.decodeImage(),this._png}decodeApng(){for(me(this);!this._end;){const t=this.readUint32(),e=this.readChars(4);this.decodeApngChunk(t,e)}return this.decodeApngImage(),this._apng}decodeChunk(t,e){const i=this.offset;switch(e){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(t);break;case"IDAT":this.decodeIDAT(t);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(t);break;case"iCCP":this.decodeiCCP(t);break;case"tEXt":Ee(this._png.text,this,t);break;case"pHYs":this.decodepHYs();break;default:this.skip(t)}if(this.offset-i!==t)throw new Error(\`Length mismatch while decoding chunk \${e}\`);this._checkCrc?ne(this,t+4,e):this.skip(4)}decodeApngChunk(t,e){const i=this.offset;switch("fdAT"!==e&&"IDAT"!==e&&this._writingDataChunks&&this.pushDataToFrame(),e){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(t);break;default:this.decodeChunk(t,e),this.offset=i+t}if(this.offset-i!==t)throw new Error(\`Length mismatch while decoding chunk \${e}\`);this._checkCrc?ne(this,t+4,e):this.skip(4)}decodeIHDR(){const t=this._png;t.width=this.readUint32(),t.height=this.readUint32(),t.depth=function(t){if(1!==t&&2!==t&&4!==t&&8!==t&&16!==t)throw new Error(\`invalid bit depth: \${t}\`);return t}(this.readUint8());const e=this.readUint8();let i;switch(this._colorType=e,e){case Te:i=1;break;case Be:i=3;break;case Oe:i=1;break;case Ce:i=2;break;case Ie:i=4;break;default:throw new Error(\`Unknown color type: \${e}\`)}if(this._png.channels=i,this._compressionMethod=this.readUint8(),this._compressionMethod!==Se)throw new Error(\`Unsupported compression method: \${this._compressionMethod}\`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const t={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(t)}decodePLTE(t){if(t%3!=0)throw new RangeError(\`PLTE field length must be a multiple of 3. Got \${t}\`);const e=t/3;this._hasPalette=!0;const i=[];this._palette=i;for(let t=0;t<e;t++)i.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(t){this._writingDataChunks=!0;const e=t,i=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,i,e)),this._inflator.err)throw new Error(\`Error while decompressing the data: \${this._inflator.err}\`);this.skip(t)}decodeFDAT(t){this._writingDataChunks=!0;let e=t,i=this.offset+this.byteOffset;if(i+=4,e-=4,this._inflator.push(new Uint8Array(this.buffer,i,e)),this._inflator.err)throw new Error(\`Error while decompressing the data: \${this._inflator.err}\`);this.skip(t)}decodetRNS(t){switch(this._colorType){case Te:case Be:if(t%2!=0)throw new RangeError(\`tRNS chunk length must be a multiple of 2. Got \${t}\`);if(t/2>this._png.width*this._png.height)throw new Error(\`tRNS chunk contains more alpha values than there are pixels (\${t/2} vs \${this._png.width*this._png.height})\`);this._hasTransparency=!0,this._transparency=new Uint16Array(t/2);for(let e=0;e<t/2;e++)this._transparency[e]=this.readUint16();break;case Oe:{if(t>this._palette.length)throw new Error(\`tRNS chunk contains more alpha values than there are palette colors (\${t} vs \${this._palette.length})\`);let e=0;for(;e<t;e++){const t=this.readByte();this._palette[e].push(t)}for(;e<this._palette.length;e++)this._palette[e].push(255);break}default:throw new Error(\`tRNS chunk is not supported for color type \${this._colorType}\`)}}decodeiCCP(t){const e=xe(this),i=this.readUint8();if(i!==Se)throw new Error(\`Unsupported iCCP compression method: \${i}\`);const n=this.readBytes(t-e.length-2);this._png.iccEmbeddedProfile={name:e,profile:Qt(n)}}decodepHYs(){const t=this.readUint32(),e=this.readUint32(),i=this.readByte();this._png.resolution={x:t,y:e,unit:i}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let t=0;t<this._numberOfFrames;t++){const e={sequenceNumber:this._frames[t].sequenceNumber,delayNumber:this._frames[t].delayNumber,delayDenominator:this._frames[t].delayDenominator,data:8===this._apng.depth?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},i=this._frames.at(t);if(i){if(i.data=_e({data:i.data,width:i.width,height:i.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),0===t||0===i.xOffset&&0===i.yOffset&&i.width===this._png.width&&i.height===this._png.height)e.data=i.data;else{const n=this._apng.frames.at(t-1);this.disposeFrame(i,n,e),this.addFrameDataToCanvas(e,i)}this._apng.frames.push(e)}}return this._apng}disposeFrame(t,e,i){switch(t.disposeOp){case Ze:break;case $e:for(let e=0;e<this._png.height;e++)for(let n=0;n<this._png.width;n++){const r=(e*t.width+n)*this._png.channels;for(let t=0;t<this._png.channels;t++)i.data[r+t]=0}break;case Pe:i.data.set(e.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(t,e){const i=1<<this._png.depth,n=(t,i)=>({index:((t+e.yOffset)*this._png.width+e.xOffset+i)*this._png.channels,frameIndex:(t*e.width+i)*this._png.channels});switch(e.blendOp){case je:for(let i=0;i<e.height;i++)for(let r=0;r<e.width;r++){const{index:s,frameIndex:a}=n(i,r);for(let i=0;i<this._png.channels;i++)t.data[s+i]=e.data[a+i]}break;case ze:for(let r=0;r<e.height;r++)for(let s=0;s<e.width;s++){const{index:a,frameIndex:o}=n(r,s);for(let n=0;n<this._png.channels;n++){const r=e.data[o+this._png.channels-1]/i,s=n%(this._png.channels-1)==0?1:e.data[o+n],h=Math.floor(r*s+(1-r)*t.data[a+n]);t.data[a+n]+=h}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){if(this._inflator.err)throw new Error(\`Error while decompressing the data: \${this._inflator.err}\`);const t=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(this._filterMethod!==Me)throw new Error(\`Filter method \${this._filterMethod} not supported\`);if(this._interlaceMethod===Fe)this._png.data=_e({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else{if(this._interlaceMethod!==Ne)throw new Error(\`Interlace method \${this._interlaceMethod} not supported\`);this._png.data=function(t){const{data:e,width:i,height:n,channels:r,depth:s}=t,a=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],o=Math.ceil(s/8)*r,h=new Uint8Array(n*i*o);let f=0;for(let t=0;t<7;t++){const r=a[t],s=Math.ceil((i-r.x)/r.xStep),l=Math.ceil((n-r.y)/r.yStep);if(s<=0||l<=0)continue;const d=s*o,c=new Uint8Array(d);for(let t=0;t<l;t++){const a=e[f++],l=e.subarray(f,f+d);f+=d;const u=new Uint8Array(d);le(a,l,u,c,d,o),c.set(u);for(let e=0;e<s;e++){const s=r.x+e*r.xStep,a=r.y+t*r.yStep;if(!(s>=i||a>=n))for(let t=0;t<o;t++)h[(a*i+s)*o+t]=u[e*o+t]}}}if(16===s){const t=new Uint16Array(h.buffer);if(ce)for(let e=0;e<t.length;e++)t[e]=ue(t[e]);return t}return h}({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth})}this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){const t=this._inflator.result,e=this._frames.at(-1);e?e.data=t:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:Ze,blendOp:je,data:t}),this._inflator=new Jt,this._writingDataChunks=!1}}var He;!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.METRE=1]="METRE"}(He||(He={})),function(t,{expose:e=x}={}){function i(t){return async(...e)=>O(await t(...e))}e("function"==typeof t?i(t):Object.entries(t).reduce((t,[e,n])=>(t[e]=i(n),t),{}))}(async function(t){return e=t instanceof Uint8Array?t:new Uint8Array(t),new We(e,i).decode();var e,i})}();\n`;function pe(){return new se}function we(){return re.BlobWorker.fromText(ye,{name:de})}async function be(t){const e=await re.spawn(we());if(t!=null){t.addThread(e)}return(...t)=>e.apply(null,[...t.map((t=>le(t)))])}function me(t){return re.Pool((()=>be(t.terminate)),t)}export{pe as makeController,we as makeWorker,me as spawnPool,be as spawnWorker};
5
+ //# sourceMappingURL=p-fKH0aLlq.js.map