pacem 0.53.0-selberg → 0.53.0-stevin

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 (57) hide show
  1. package/dist/css/pacem-dark-content.min.css +1 -1
  2. package/dist/css/pacem-dark-shell.min.css +1 -1
  3. package/dist/css/pacem-dark.min.css +1 -1
  4. package/dist/css/pacem-light-content.min.css +1 -1
  5. package/dist/css/pacem-light-shell.min.css +1 -1
  6. package/dist/css/pacem-light.min.css +1 -1
  7. package/dist/css/pacem-phousys-content.min.css +1 -1
  8. package/dist/css/pacem-phousys-shell.min.css +1 -1
  9. package/dist/css/pacem-phousys.min.css +1 -1
  10. package/dist/js/azure-maps.d.ts +1 -1
  11. package/dist/js/pacem-2d.d.ts +1 -2
  12. package/dist/js/pacem-2d.js +15 -14
  13. package/dist/js/pacem-2d.min.js +2 -2
  14. package/dist/js/pacem-3d.d.ts +1 -1
  15. package/dist/js/pacem-3d.js +1 -1
  16. package/dist/js/pacem-3d.min.js +1 -1
  17. package/dist/js/pacem-charts.d.ts +1 -1
  18. package/dist/js/pacem-charts.js +1 -1
  19. package/dist/js/pacem-charts.min.js +1 -1
  20. package/dist/js/pacem-cms.d.ts +1 -1
  21. package/dist/js/pacem-cms.js +1 -1
  22. package/dist/js/pacem-cms.min.js +1 -1
  23. package/dist/js/pacem-core.d.ts +1 -1
  24. package/dist/js/pacem-core.js +1 -1
  25. package/dist/js/pacem-core.min.js +1 -1
  26. package/dist/js/pacem-foundation.d.ts +1 -1
  27. package/dist/js/pacem-foundation.js +1 -1
  28. package/dist/js/pacem-foundation.min.js +1 -1
  29. package/dist/js/pacem-fx.d.ts +1 -1
  30. package/dist/js/pacem-fx.js +1 -1
  31. package/dist/js/pacem-fx.min.js +1 -1
  32. package/dist/js/pacem-logging.d.ts +1 -1
  33. package/dist/js/pacem-logging.js +1 -1
  34. package/dist/js/pacem-logging.min.js +1 -1
  35. package/dist/js/pacem-maps.d.ts +1 -1
  36. package/dist/js/pacem-maps.js +1 -1
  37. package/dist/js/pacem-maps.min.js +1 -1
  38. package/dist/js/pacem-media.d.ts +1 -1
  39. package/dist/js/pacem-media.js +1 -1
  40. package/dist/js/pacem-media.min.js +1 -1
  41. package/dist/js/pacem-networking.d.ts +1 -1
  42. package/dist/js/pacem-networking.js +1 -1
  43. package/dist/js/pacem-networking.min.js +1 -1
  44. package/dist/js/pacem-numerical.d.ts +4 -1
  45. package/dist/js/pacem-numerical.js +47 -1
  46. package/dist/js/pacem-numerical.min.js +2 -2
  47. package/dist/js/pacem-plus.d.ts +1 -1
  48. package/dist/js/pacem-plus.js +1 -1
  49. package/dist/js/pacem-plus.min.js +1 -1
  50. package/dist/js/pacem-scaffolding.d.ts +1 -1
  51. package/dist/js/pacem-scaffolding.js +1 -1
  52. package/dist/js/pacem-scaffolding.min.js +1 -1
  53. package/dist/js/pacem-ui.d.ts +1 -1
  54. package/dist/js/pacem-ui.js +1 -1
  55. package/dist/js/pacem-ui.min.js +1 -1
  56. package/dist/js/swagger-types.d.ts +1 -1
  57. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -382,7 +382,6 @@ declare namespace Pacem.Components.Drawing {
382
382
  requestDraw(item: Pacem.Drawing.Group, redrawContent: boolean): any;
383
383
  private _buildUpDatasourceFromDOM;
384
384
  private _options;
385
- private _size;
386
385
  private _resizeHandler;
387
386
  private _getActualAspectRatio;
388
387
  private _zoomFromValue;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -877,7 +877,7 @@ var Pacem;
877
877
  }
878
878
  getPathData() {
879
879
  const x = this.x, y = this.y, w = this.w, h = this.h;
880
- let r = this.r;
880
+ let r = this.r ?? { rx: { value: 0 }, ry: { value: 0 }, type: CornerType.Rounded };
881
881
  if (!Pacem.Utils.isArray(r)) {
882
882
  r = [r, r, r, r];
883
883
  }
@@ -895,7 +895,7 @@ var Pacem;
895
895
  };
896
896
  }
897
897
  static getPathData(x = NaN, y = NaN, w = NaN, h = NaN, r = null) {
898
- if (Pacem.Utils.isNullOrEmpty(r)) {
898
+ if (!r) {
899
899
  return `M ${x} ${y} h ${w} v ${h} h ${-w} z`;
900
900
  }
901
901
  if (!Pacem.Utils.isArray(r)) {
@@ -1021,7 +1021,7 @@ var Pacem;
1021
1021
  this.#transformMatrix = Pacem.Matrix2D.identity;
1022
1022
  this._options = DEFAULT_STAGE_OPTIONS;
1023
1023
  this._resizeHandler = (evt) => {
1024
- this._size = { width: evt.detail.width, height: evt.detail.height };
1024
+ this.#size = { x: evt.detail.left, y: evt.detail.top, width: evt.detail.width, height: evt.detail.height };
1025
1025
  const adapter = this.adapter;
1026
1026
  if (!Pacem.Utils.isNull(adapter)) {
1027
1027
  this._invalidateSize();
@@ -1057,7 +1057,7 @@ var Pacem;
1057
1057
  if (!opts.panControl) {
1058
1058
  return;
1059
1059
  }
1060
- const size = this._size, vbox = this.viewbox || { x: 0, y: 0, width: size.width, height: size.height }, start = this._getPanPoint(evt);
1060
+ const size = this.#size, vbox = this.viewbox || { x: 0, y: 0, width: size.width, height: size.height }, start = this._getPanPoint(evt);
1061
1061
  if (start) {
1062
1062
  Pacem.avoidHandler(evt);
1063
1063
  this._stage.style.pointerEvents = 'none';
@@ -1087,8 +1087,8 @@ var Pacem;
1087
1087
  return this.#transformMatrix;
1088
1088
  }
1089
1089
  _transformMatrixScale() {
1090
- const sizeObj = Pacem.Utils.extend(this._size || Pacem.Utils.offsetRect(this._stage), { x: 0, y: 0 });
1091
- var origVbox = this.#originalViewBox || { x: 0, y: 0, width: sizeObj.width, height: sizeObj.height };
1090
+ const sizeObj = this.#size || Pacem.Utils.offsetRect(this._stage);
1091
+ var origVbox = this.#originalViewBox || sizeObj;
1092
1092
  const vbox = this.viewbox || origVbox;
1093
1093
  const aspectRatio = this.aspectRatio || 'none';
1094
1094
  const mode = aspectRatio === 'none' ? 'stretch' : (aspectRatio.slice ? 'cover' : 'contain');
@@ -1123,6 +1123,7 @@ var Pacem;
1123
1123
  _buildUpDatasourceFromDOM() {
1124
1124
  this.datasource = (this.items || []).slice();
1125
1125
  }
1126
+ #size;
1126
1127
  _getActualAspectRatio() {
1127
1128
  const aspectRatio = this.aspectRatio || 'none';
1128
1129
  const alignmentX = aspectRatio === 'none' ? 'mid' : aspectRatio.x;
@@ -1131,12 +1132,12 @@ var Pacem;
1131
1132
  return { x: alignmentX, y: alignmentY, slice };
1132
1133
  }
1133
1134
  _zoomFromValue(scale) {
1134
- const sizeObj = this._size;
1135
+ const sizeObj = this.#size;
1135
1136
  if (Pacem.Utils.isNull(sizeObj)) {
1136
1137
  return;
1137
1138
  }
1138
- const sizeRect = Pacem.Utils.extend(sizeObj, { x: 0, y: 0 });
1139
- const origVbox = this.#originalViewBox || { x: 0, y: 0, width: sizeObj.width, height: sizeObj.height }, vbox = this.viewbox || origVbox;
1139
+ const sizeRect = sizeObj;
1140
+ const origVbox = this.#originalViewBox || sizeRect, vbox = this.viewbox || origVbox;
1140
1141
  const aspectRatio = this.aspectRatio || 'none';
1141
1142
  const mode = aspectRatio === 'none' ? 'stretch' : (aspectRatio.slice ? 'cover' : 'contain');
1142
1143
  const actual = Pacem.Rect.findTransform(vbox, sizeRect, mode);
@@ -1154,7 +1155,7 @@ var Pacem;
1154
1155
  if (Pacem.Utils.isNull(pt)) {
1155
1156
  pt = { x: stageRect.x + stageRect.width * .5, y: stageRect.y + stageRect.height * .5 };
1156
1157
  }
1157
- const sizeObj = this._size, vbox = this.viewbox || { x: 0, y: 0, width: sizeObj.width, height: sizeObj.height };
1158
+ const sizeObj = this.#size, vbox = this.viewbox || sizeObj;
1158
1159
  const vsize = Math.min(vbox.width, vbox.height), targetWidth = vsize * scale, targetHeight = vsize * scale;
1159
1160
  if (targetWidth > 0 && targetHeight > 0) {
1160
1161
  const aspectRatio = this._getActualAspectRatio();
@@ -1201,12 +1202,12 @@ var Pacem;
1201
1202
  return null;
1202
1203
  }
1203
1204
  _invalidateSize() {
1204
- this.adapter.invalidateSize(this, this._size);
1205
+ this.adapter.invalidateSize(this, this.#size);
1205
1206
  const prevTransformMatrix = this.#transformMatrix;
1206
1207
  this.#transformMatrix = this.adapter.getTransformMatrix(this);
1207
1208
  this.dispatchEvent(new Pacem.PropertyChangeEvent({ propertyName: 'transformMatrix', currentValue: this.#transformMatrix, oldValue: prevTransformMatrix }));
1208
1209
  this.zoom = this._transformMatrixScale();
1209
- this.dispatchEvent(new Components.ResizeEvent(this._size));
1210
+ this.dispatchEvent(new Components.ResizeEvent(this.#size));
1210
1211
  }
1211
1212
  viewActivatedCallback() {
1212
1213
  super.viewActivatedCallback();
@@ -1323,7 +1324,7 @@ var Pacem;
1323
1324
  Pacem.Debounce(true)
1324
1325
  ], Pacem2DElement.prototype, "_drawDebounced", null);
1325
1326
  Pacem2DElement = __decorate([
1326
- Pacem.CustomElement({ tagName: Pacem.P + '-' + Drawing.TAG_MIDDLE_NAME, shadow: true, template: `<${Pacem.P}-resize></${Pacem.P}-resize><div class="${Pacem.PCSS}-2d" part="container"></div><slot></slot>` })
1327
+ Pacem.CustomElement({ tagName: Pacem.P + '-' + Drawing.TAG_MIDDLE_NAME, shadow: true, template: `<${Pacem.P}-resize watch-position="true"></${Pacem.P}-resize><div class="${Pacem.PCSS}-2d" part="container"></div><slot></slot>` })
1327
1328
  ], Pacem2DElement);
1328
1329
  Drawing.Pacem2DElement = Pacem2DElement;
1329
1330
  })(Drawing = Components.Drawing || (Components.Drawing = {}));
@@ -1,6 +1,6 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
6
- var Pacem,__decorate=this&&this.__decorate||function(t,e,r,i){var n,a=arguments.length,s=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,i);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(s=(a<3?n(s):a>3?n(e,r,s):n(e,r))||s);return a>3&&s&&Object.defineProperty(e,r,s),s};!function(t){!function(e){function r(e){return!t.Utils.isNull(e)&&"stage"in e}function i(t){return r(t)}function n(e){return"stops"in e&&t.Utils.isArray(e.stops)}e.isDrawable=r,e.isUiObject=i,e.isLinearGradient=function(e){return n(e)&&"start"in e&&t.Point.isPoint(e.start)&&"end"in e&&t.Point.isPoint(e.end)},e.isRadialGradient=function(e){return n(e)&&"center"in e&&t.Point.isPoint(e.center)&&"radius"in e&&"number"==typeof e.radius};e.PresentationState=class PresentationState{static combine(e,r,i=null){return{opacity:(e.opacity??1)*(r.opacity??1),transformMatrix:i??t.Matrix2D.multiply(r.transformMatrix,e.transformMatrix),dashArray:e.dashArray??r.dashArray,fill:e.fill??r.fill,lineCap:e.lineCap??r.lineCap,lineJoin:e.lineJoin??r.lineJoin,lineWidth:e.lineWidth??r.lineWidth,stroke:e.stroke??r.stroke}}},e.isPresentationObject=function(t){return i(t)&&("fill"in t||"transformMatrix"in t||"stroke"in t||"lineJoin"in t||"dashArray"in t||"lineWidth"in t||"opacity"in t||"lineCap"in t)},e.isShape=function(t){return i(t)&&"pathData"in t},e.isGroup=function(e){return i(e)&&"childDrawables"in e&&!t.Utils.isNullOrEmpty(e.childDrawables)},e.isText=function(t){return i(t)&&"text"in t&&"string"==typeof t.text},e.isImage=function(t){return i(t)&&"src"in t&&"string"==typeof t.src};class UI2DEvent extends t.CustomUIEvent{constructor(t,e,r,i){super(t,e,r),this.#t=i}#t;get transformMatrix(){return this.#t}project(e={x:this.screenX,y:this.screenY}){return t.Matrix2D.multiply(e,this.#t)}}e.UI2DEvent=UI2DEvent;e.Shape=class Shape{static empty(){return{pathData:"",vertices:[],boundingRect:{x:0,y:0,width:0,height:0}}}};e.DragEvent=class DragEvent extends UI2DEvent{};e.DrawableEvent=class DrawableEvent extends UI2DEvent{constructor(t,e,r,i){super(t,{detail:e,bubbles:!0,cancelable:!0},r,i)}};e.StageEvent=class StageEvent extends UI2DEvent{constructor(t,e,r,i=e.transformMatrix){super(t,{detail:e,bubbles:!0,cancelable:!0},r,i)}}}(t.Drawing||(t.Drawing={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(r){r.TAG_MIDDLE_NAME="2d",r.TWO_PI=2*Math.PI;const i=Math.PI/180;class Pacem2DAdapterElement extends e.PacemEventTarget{constructor(){super(...arguments),this.DefaultShapeValues={stroke:"#000",lineWidth:1,fill:"#fff"}}snapshotElement(e,r,i,n){const a=!t.Utils.isNullOrEmpty(r),s=i??(a?"image/jpeg":null),o=n??(a?.9:null);return t.Utils.snapshotElement(e,r,s,o)}}r.Pacem2DAdapterElement=Pacem2DAdapterElement;class DrawableElement extends e.PacemCrossItemsContainerElement{validate(t){return!1}findContainer(){return this.parent||this.stage}get stage(){return this._scene=this._scene||t.CustomElementUtils.findAncestorOfType(this,r.Pacem2DElement)}get parent(){return this._drawableParent=this._drawableParent||t.CustomElementUtils.findAncestor(this,t=>t instanceof DrawableElement)}disconnectedCallback(){delete this._scene,delete this._drawableParent,super.disconnectedCallback()}propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i&&"hide"===t)this.stage?.draw(this)}}__decorate([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],DrawableElement.prototype,"tag",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],DrawableElement.prototype,"inert",void 0),r.DrawableElement=DrawableElement;class UiElement extends DrawableElement{#t=t.Matrix2D.identity;viewActivatedCallback(){super.viewActivatedCallback(),this._updateTransformMatrix()}propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"rotate":case"scaleX":case"scaleY":case"translateX":case"translateY":this._updateTransformMatrix();case"opacity":this.stage?.draw(this)}}_updateTransformMatrix(){let t=i*(this.rotate??0),e=Math.cos(t),r=Math.sin(t),n=(this.scaleX??1)*e,a=-r,s=r,o=(this.scaleY??1)*e,l=this.translateX??0,c=this.translateY??0;this.#t={a:n,b:a,c:s,d:o,e:l,f:c}}get transformMatrix(){const t=this.#t;return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}}__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"rotate",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"scaleX",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"scaleY",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"translateX",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"translateY",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"opacity",void 0),r.UiElement=UiElement;class PresentationElement extends UiElement{propertyChangedCallback(e,r,i,n){if(super.propertyChangedCallback(e,r,i,n),!n)switch(e){case"stroke":case"lineWidth":case"lineJoin":case"lineCap":case"dashArray":case"fill":t.Utils.isNull(this.stage)||this.stage.draw(this)}}}__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PresentationElement.prototype,"stroke",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PresentationElement.prototype,"fill",void 0),__decorate([t.Watch({emit:!1,converter:{convert:t=>t?.split(",").map(t=>parseInt(t)).filter(t=>!Number.isNaN(t)),convertBack:t=>t?.join(",")}})],PresentationElement.prototype,"dashArray",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],PresentationElement.prototype,"lineWidth",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PresentationElement.prototype,"lineJoin",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PresentationElement.prototype,"lineCap",void 0),r.PresentationElement=PresentationElement;class ShapeElement extends PresentationElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i&&"data"===t)this.stage?.draw(this)}viewActivatedCallback(){super.viewActivatedCallback(),this.recomputeShape()}recomputeShape(){const{pathData:t,vertices:e,boundingRect:r}=this.getShapeGeometry();this.#e=e,this.#r=r,this.data=t}get pathData(){return this.data}#r;get boundingRect(){return this.#r}#e;get vertices(){return this.#e}}__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ShapeElement.prototype,"data",void 0),r.ShapeElement=ShapeElement}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){var r,i;function n(e,r,i,n,a){for(n??=0,a??=0,n%=360,a%=360;n<0;)n+=360;for(;a<n;)a+=360;return(n-a).isCloseTo(0)?function(t,e,r){const i=2*e,n=t.x,a=t.y;return{pathData:`M ${n} ${a} m ${-e},0 a ${e},${r} 0 1,1 ${i},0 a ${e},${r} 0 1,1 ${-i},0`,vertices:[],boundingRect:{x:n-e,y:a-r,width:2*e,height:2*r}}}(e,r,i):function(e,r,i,n,a){const s=Math.PI/180,o=s*n,l=s*a,c=t=>r*i/Math.sqrt(Math.pow(Math.cos(t)*i,2)+Math.pow(Math.sin(t)*r,2)),h=c(o),d=c(l),m=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)}),p=m(h,o),u=m(d,l),g={x:e.x+p.x,y:e.y+p.y},v={x:e.x+u.x,y:e.y+u.y};let y=t.Rect.expand(e,g,v);a<n&&(a+=360),(n<=0&&a>0||a>=360)&&(y=t.Rect.expand(y,{x:e.x+r,y:e.y})),(n<=90&&a>90||a>=450)&&(y=t.Rect.expand(y,{x:e.x,y:e.y+i})),(n<=180&&a>180||a>=540)&&(y=t.Rect.expand(y,{x:e.x-r,y:e.y})),(n<=270&&a>270||a>=630)&&(y=t.Rect.expand(y,{x:e.x,y:e.y-i}));const f=l-o>Math.PI?"1":"0";return{pathData:`M ${g.x} ${g.y} A ${r},${i} 0 ${f},1 ${v.x},${v.y} L ${e.x},${e.y} Z`,vertices:[g,v],boundingRect:y}}(e,r,i,n,a)}let a=r=class PacemEllipseElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"center":case"rx":case"ry":case"start":case"end":this.recomputeShape()}}getPathData(){const e=this.rx,i=this.ry,n=this.center,a=this.start??0,s=this.end??0;return t.Utils.isNull(n)||t.Utils.isNull(e)||t.Utils.isNull(i)?null:r.getPathData(n,e,i,a,s)}getShapeGeometry(){return n(this.center??{x:0,y:0},this.rx??0,this.ry??0,this.start,this.end)}static getPathData(t={x:NaN,y:NaN},e=NaN,r=NaN,i,a){const{pathData:s}=n(t,e,r,i,a);return s}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],a.prototype,"center",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],a.prototype,"rx",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],a.prototype,"ry",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],a.prototype,"start",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],a.prototype,"end",void 0),a=r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-ellipse"})],a),e.PacemEllipseElement=a;let s=i=class PacemCircleElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"center":case"radius":case"start":case"end":this.recomputeShape()}}getPathData(){const e=this.radius,r=this.center;return t.Utils.isNull(r)||t.Utils.isNull(e)?null:i.getPathData(r,e,this.start,this.end)}getShapeGeometry(){const t=this.center??{x:0,y:0},e=this.radius??0;return n(t,e,e,this.start,this.end)}static getPathData(t={x:NaN,y:NaN},e=NaN,r,i){return a.getPathData(t,e,e,r,i)}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],s.prototype,"center",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],s.prototype,"radius",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],s.prototype,"start",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],s.prototype,"end",void 0),s=i=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-circle"})],s),e.PacemCircleElement=s}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){let r=class PacemGroupElement extends e.PresentationElement{validate(t){return t instanceof e.DrawableElement&&t.parent===this}#i=[];get childDrawables(){return this.#i}propertyChangedCallback(e,r,i,n){switch(super.propertyChangedCallback(e,r,i,n),e){case"items":case"datasource":this.#i=i||[];const e=this.stage;t.Utils.isNull(e)||e.draw(this,!0)}}};__decorate([t.Watch({emit:!1})],r.prototype,"datasource",void 0),r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-group"})],r),e.PacemGroupElement=r}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){let r=class PacemImageElement extends e.UiElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"src":case"x":case"y":case"width":case"height":this.stage?.draw(this)}}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"src",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],r.prototype,"x",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],r.prototype,"y",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],r.prototype,"width",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],r.prototype,"height",void 0),r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-image"})],r),e.PacemImageElement=r}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){var r;let i=r=class PacemLineElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"from":case"to":this.recomputeShape()}}getShapeGeometry(){const e=this.from,r=this.to;if(t.Utils.isNull(e)||t.Utils.isNull(r))return t.Drawing.Shape.empty();const i=e.x,n=e.y,a=r.x,s=r.y,o={x:Math.min(i,a),y:Math.min(n,s),width:Math.abs(i-a),height:Math.abs(n-s)};return{pathData:this.getPathData(),vertices:[e,r],boundingRect:o}}getPathData(){const e=this.from,i=this.to;return t.Utils.isNull(e)||t.Utils.isNull(i)?null:r.getPathData(e,i)}static getPathData(t={x:NaN,y:NaN},e={x:NaN,y:NaN}){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],i.prototype,"from",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],i.prototype,"to",void 0),i=r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-line"})],i),e.PacemLineElement=i}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){let r=class PacemPathElement extends e.ShapeElement{constructor(){super(...arguments),this.getPathData=()=>this.d}propertyChangedCallback(t,e,r,i){super.propertyChangedCallback(t,e,r,i),"d"!==t||i||this.recomputeShape()}getShapeGeometry(){return{pathData:this.getPathData(),boundingRect:null,vertices:[]}}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"d",void 0),r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-path"})],r),e.PacemPathElement=r}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){var r;let i=r=class PacemPolygonElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"radius":case"starIndent":case"sides":this.recomputeShape()}}getPathData(){const e=this.sides,i=this.radius,n=this.center;return t.Utils.isNull(e)||t.Utils.isNull(i)?null:r.getPathData(n,i,e,this.starIndent)}getShapeGeometry(){const e=this.center??{x:0,y:0},i=this.radius??0,n=this.sides??3,a=this.starIndent;return n<3?t.Drawing.Shape.empty():r.getShapeGeometry(e,i,n,a)}static getShapeGeometry(t,e,r,i=0){const n={x:t.x,y:t.y-e};let a=`M ${n.x} ${n.y}`;const s=[n],o=2*Math.PI/r,l=.5*o,c=i>0,h=e*Math.cos(l);for(let n=1;n<r;n++){const r=n*o,d=t.x+Math.sin(r)*e,m=t.y-Math.cos(r)*e;if(c){const e=h*(1-i),n=r-l,o=t.x+Math.sin(n)*e,c=t.y-Math.cos(n)*e;a+=` L ${o} ${c} L ${d} ${m}`,s.push({x:o,y:c})}else a+=` L ${d} ${m}`;s.push({x:d,y:m})}if(c){const e=h*(1-i),r=2*Math.PI-l,n=t.x+Math.sin(r)*e,o=t.y-Math.cos(r)*e;a+=` L ${n} ${o}`,s.push({x:n,y:o})}s.push(n);const d=2*e;return{pathData:a+" Z",vertices:s,boundingRect:{x:n.x-e,y:n.y,width:d,height:d}}}static getPathData(t,e,i,n=0){const{pathData:a}=r.getShapeGeometry(t,e,i,n);return a}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],i.prototype,"sides",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],i.prototype,"radius",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],i.prototype,"center",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],i.prototype,"starIndent",void 0),i=r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-polygon"})],i),e.PacemPolygonElement=i}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){var r;const i={convert:e=>{const r=t.parseAsNumericalArray(e);if(r.length%2==0){const t=[];for(let e=0;e<r.length;e+=2)t.push({x:r[e],y:r[e+1]});return t}return JSON.parse(e)},convertBack:t=>JSON.stringify(t)};let n=r=class PacemPolylineElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"points":case"closed":this.recomputeShape()}}static getShapeGeometry(e,r){if(t.Utils.isNullOrEmpty(e))return t.Drawing.Shape.empty();let i="",n=Number.MAX_VALUE,a=Number.MAX_VALUE,s=Number.MIN_VALUE,o=Number.MIN_VALUE;for(let t=0;t<e.length;t++){const{x:r,y:l}=e[t];i+=`${0===t?"M":"L"} ${r} ${l} `,n=Math.min(n,r),s=Math.max(s,r),a=Math.min(a,l),o=Math.max(o,l)}return r&&(i+="Z"),{pathData:i,vertices:e,boundingRect:{x:n,y:a,width:s-n,height:o-a}}}getShapeGeometry(){return r.getShapeGeometry(this.points,this.closed)}getPathData(){const{pathData:t}=this.getShapeGeometry();return t}static getPathData(t,e){const{pathData:i}=r.getShapeGeometry(t,e);return i}};__decorate([t.Watch({emit:!1,converter:i})],n.prototype,"points",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],n.prototype,"closed",void 0),n=r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-polyline"})],n),e.PacemPolylineElement=n}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){var r;function i(t){const e=t[2],r=t[4]??e,i="cut"===t[6]?o.Cut:o.Rounded;return{rx:n(e),ry:n(r),type:i}}function n(t){return{value:parseFloat(t),unit:t.endsWith("%")?"pct":"u"}}function a(t){return`${t.value}${"pct"===t.unit?"%":""}`}const s=/(([\d\.]+%?)(\s*,?\s*([\d\.]+%?))?(\s+(cut|round))?)/g;let o;!function(t){t.Rounded="rounded",t.Cut="cut"}(o=e.CornerType||(e.CornerType={}));let l=r=class PacemRectElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){super.propertyChangedCallback(t,e,r,i),i||"x"!==t&&"y"!==t&&"w"!==t&&"h"!==t&&"r"!==t&&"cornerType"!==t||this.recomputeShape()}getPathData(){const e=this.x,i=this.y,n=this.w,a=this.h;let s=this.r;return t.Utils.isArray(s)||(s=[s,s,s,s]),s=s.map(t=>"number"==typeof t?{rx:{value:t},ry:{value:t},type:this.cornerType}:t),t.Utils.isNull(e)||t.Utils.isNull(i)||t.Utils.isNull(n)||t.Utils.isNull(a)?null:r.getPathData(e,i,n,a,s)}getShapeGeometry(){const t=this.x,e=this.y,r=t+this.w,i=e+this.h;return{pathData:this.getPathData(),vertices:[{x:t,y:e},{x:r,y:e},{x:r,y:i},{x:t,y:i}],boundingRect:{x:t,y:e,width:this.w,height:this.h}}}static getPathData(e=NaN,r=NaN,i=NaN,n=NaN,a=null){if(t.Utils.isNullOrEmpty(a))return`M ${e} ${r} h ${i} v ${n} h ${-i} z`;t.Utils.isArray(a)||(a=[a,a,a,a]);const s=a[0],o=a[1],l=a[2],c=a[3],h=t=>"pct"===t.unit?.01*t.value*i:t.value,d=t=>"pct"===t.unit?.01*t.value*n:t.value,m=h(s.rx),p=d(s.ry),u=h(o.rx),g=d(o.ry),v=h(l.rx),y=d(l.ry),f=h(c.rx),_=d(c.ry);let x=`M ${e},${r+p}`;if("cut"===s.type)x+=` l ${m},${-p}`;else x+=` a ${m} ${p} 0 0 1 ${m} ${-p}`;if(x+=" h "+(i-m-u),"cut"===o.type)x+=` l ${u},${g}`;else x+=` a ${u} ${g} 0 0 1 ${u} ${g}`;if(x+=" v "+(n-g-y),"cut"===l.type)x+=` l ${-v},${y}`;else x+=` a ${v} ${y} 0 0 1 ${-v} ${y}`;if(x+=" h "+-(i-v-f),"cut"===c.type)x+=` l ${-f},${-_}`;else x+=` a ${f} ${_} 0 0 1 ${-f} ${-_}`;return x+" z"}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],l.prototype,"x",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],l.prototype,"y",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],l.prototype,"w",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],l.prototype,"h",void 0),__decorate([t.Watch({emit:!1,converter:{convert:t=>function(t){let e;const r=[];for(;e=s.exec(t);)r.push(e);switch(r.length){case 1:const t=i(r[0]);return[t,t,t,t];case 4:return[i(r[0]),i(r[1]),i(r[2]),i(r[3])];default:return null}}(t),convertBack:t=>function(t){const e=t[0],r=t[1],i=t[2],n=t[3];return`${a(e.rx)},${a(e.ry)} ${a(r.rx)},${a(r.ry)} ${a(i.rx)},${a(i.ry)} ${a(n.rx)},${a(n.ry)}`}(t)}})],l.prototype,"r",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],l.prototype,"cornerType",void 0),l=r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-rect"})],l),e.PacemRectElement=l}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(r){const i=/^\s*[xX]\s*([Mm](in|ax|id))\s*[yY]\s*([Mm](in|ax|id))(\s+(none|slice|meet))?\s*$/,n={convert:t=>{const e=i.exec(t);return e&&e.length>=4?{x:e[1].toLowerCase(),y:e[3].toLowerCase(),slice:"slice"===e[6]}:"none"},convertBack:e=>t.Utils.isNull(e)||"string"==typeof e?"none":`xM${e.x.substr(1)}YM${e.y.substr(1)} ${e.slice?"slice":"meet"}`},a={panControl:!0,zoomControl:!0,panModifiers:[t.EventKeyModifier.AltKey],zoomModifiers:[t.EventKeyModifier.AltKey]};let s=class Pacem2DElement extends e.PacemItemsContainerElement{constructor(){super(...arguments),this.#t=t.Matrix2D.identity,this._options=a,this._resizeHandler=e=>{this._size={width:e.detail.width,height:e.detail.height};const r=this.adapter;t.Utils.isNull(r)||this._invalidateSize()},this._zoomHandler=e=>{const r=this._options;if(r.zoomControl&&t.CustomEventUtils.matchModifiers(e,r.zoomModifiers)){t.avoidHandler(e);const r=1+.1*(e.deltaY<0?-1:1),i=t.Utils.offsetRect(e.currentTarget),n={x:e.clientX,y:e.clientY};this._zoom(r,i,n)}},this._panHandler=e=>{const r=this._panningStart,i=this._getPanPoint(e);if(!t.Utils.isNullOrEmpty(r&&r.point)&&!t.Utils.isNull(i)){t.avoidHandler(e);const n=r.factor,a=r.box,s=r.point;this.viewbox={x:a.x-n*(i.x-s.x),y:a.y-n*(i.y-s.y),width:a.width,height:a.height}}},this._panStartHandler=e=>{if(!this._options.panControl)return;const r=this._size,i=this.viewbox||{x:0,y:0,width:r.width,height:r.height},n=this._getPanPoint(e);if(n){t.avoidHandler(e),this._stage.style.pointerEvents="none";const a=this._getActualAspectRatio(),s=i.width/r.width,o=i.height/r.height,l=a.slice?Math.min(s,o):Math.max(s,o);this._panningStart={point:n,box:i,factor:l}}},this._panEndHandler=t=>{this._stage.style.pointerEvents="",this._panningStart=null}}get stage(){return this._stage}snapshot(e,r,i){const n=this.adapter;return t.Utils.isNull(n)?Promise.resolve(null):n.snapshot(this,e,r,i)}#n;#t;get transformMatrix(){return this.#t}_transformMatrixScale(){const e=t.Utils.extend(this._size||t.Utils.offsetRect(this._stage),{x:0,y:0});var r=this.#n||{x:0,y:0,width:e.width,height:e.height};const i=this.viewbox||r,n=this.aspectRatio||"none",a="none"===n?"stretch":n.slice?"cover":"contain";return t.Rect.findTransform(i,r,a).a}validate(e){return e instanceof r.DrawableElement&&t.Utils.isNull(e.parent)}draw(e,r=!1){const i=this.adapter;if(!this.disabled&&!t.Utils.isNull(i)){let t=new CustomEvent("predraw",{cancelable:!0});this.dispatchEvent(t),t.defaultPrevented||(i.draw(this,e,r),this.dispatchEvent(new CustomEvent("draw")))}}_drawDebounced(e,r=!1){!t.Utils.isNull(e)&&t.Drawing.isGroup(e)?this.draw(e,r):this.draw(e)}requestDraw(t,e=!1){this._drawDebounced(t,e)}_buildUpDatasourceFromDOM(){this.datasource=(this.items||[]).slice()}_getActualAspectRatio(){const t=this.aspectRatio||"none";return{x:"none"===t?"mid":t.x,y:"none"===t?"mid":t.y,slice:"none"!==t&&t.slice}}_zoomFromValue(e){const r=this._size;if(t.Utils.isNull(r))return;const i=t.Utils.extend(r,{x:0,y:0}),n=this.#n||{x:0,y:0,width:r.width,height:r.height},a=this.viewbox||n,s=this.aspectRatio||"none",o="none"===s?"stretch":s.slice?"cover":"contain",l=t.Rect.findTransform(a,i,o),c=t.Rect.findTransform(n,i,o),h=l.a/(c.a*e);this._zoom(h)}_zoom(e,r,i){t.Utils.isNull(r)&&(r=t.Utils.offsetRect(this._stage)),t.Utils.isNull(i)&&(i={x:r.x+.5*r.width,y:r.y+.5*r.height});const n=this._size,a=this.viewbox||{x:0,y:0,width:n.width,height:n.height},s=Math.min(a.width,a.height),o=s*e,l=s*e;if(o>0&&l>0){const t=this._getActualAspectRatio(),e=t.x,n=t.y,s=t.slice,c=a.width/a.height,h=s?Math.max(r.width,r.height):Math.min(r.width,r.height);let d,m;switch(e){case"mid":d=(o-a.width)*(i.x-r.x-.5*(r.width-h))/(h*c);break;case"max":d=(o-a.width)*(i.x-r.x-(r.width-h))/(h*c);break;default:d=(o-a.width)*(i.x-r.x)/(h*c)}switch(n){case"mid":m=(l-a.height)*(i.y-r.y-.5*(r.height-h))/(h*c);break;case"max":m=(l-a.height)*(i.y-r.y-(r.height-h))/(h*c);break;default:m=(l-a.height)*(i.y-r.y)/(h*c)}const p=a.x-d,u=a.y-m;this.viewbox={x:p,y:u,width:o,height:l}}}_getPanPoint(e){const r=this._options;return e instanceof MouseEvent&&t.CustomEventUtils.matchModifiers(e,r.panModifiers)?t.CustomEventUtils.getEventCoordinates(e).page:null}_invalidateSize(){this.adapter.invalidateSize(this,this._size);const r=this.#t;this.#t=this.adapter.getTransformMatrix(this),this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"transformMatrix",currentValue:this.#t,oldValue:r})),this.zoom=this._transformMatrixScale(),this.dispatchEvent(new e.ResizeEvent(this._size))}viewActivatedCallback(){super.viewActivatedCallback();const e=this.adapter;t.Utils.isNull(e)||(e.initialize(this),this._invalidateSize(),this._drawDebounced());const r=this._resize;r.addEventListener(t.Components.ResizeEventName,this._resizeHandler,!1);const i=this._stage;r.target=i;const n={capture:!1,passive:!0};i.addEventListener("wheel",this._zoomHandler,!1),i.addEventListener("mousedown",this._panStartHandler,!1),i.addEventListener("touchstart",this._panStartHandler,n),window.addEventListener("mousemove",this._panHandler,!1),window.addEventListener("mouseup",this._panEndHandler,!1),window.addEventListener("touchmove",this._panHandler,n),window.addEventListener("touchend",this._panEndHandler,n)}propertyChangedCallback(e,r,i,n){switch(super.propertyChangedCallback(e,r,i,n),e){case"adapter":t.Utils.isNull(r)||r.dispose(this),t.Utils.isNull(i)||(i.initialize(this),this._invalidateSize(),this._drawDebounced());break;case"aspectRatio":t.Utils.isNull(this.adapter)||this._invalidateSize();break;case"viewbox":t.Utils.isNull(this.adapter)||this._invalidateSize(),this.#n??=this.viewbox||null;break;case"items":this._buildUpDatasourceFromDOM();break;case"zoom":i!==this._transformMatrixScale()&&this._zoomFromValue(i);break;case"options":this._options=t.Utils.extend({},a,i||{});break;case"disabled":case"datasource":this._drawDebounced()}}disconnectedCallback(){const e=this._resize,r=this._stage;t.Utils.isNull(e)||e.removeEventListener(t.Components.ResizeEventName,this._resizeHandler,!1),t.Utils.isNull(r)||(r.removeEventListener("wheel",this._zoomHandler,!1),r.removeEventListener("mousedown",this._panStartHandler,!1),r.removeEventListener("touchstart",this._panStartHandler),window.removeEventListener("mousemove",this._panHandler,!1),window.removeEventListener("mouseup",this._panEndHandler,!1),window.removeEventListener("touchmove",this._panHandler),window.removeEventListener("touchend",this._panEndHandler)),t.Utils.isNull(this.adapter)||this.adapter.dispose(this),super.disconnectedCallback()}};__decorate([t.Watch({converter:t.PropertyConverters.Element})],s.prototype,"adapter",void 0),__decorate([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Rect})],s.prototype,"viewbox",void 0),__decorate([t.Watch({emit:!1,reflectBack:!0,converter:n})],s.prototype,"aspectRatio",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],s.prototype,"datasource",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],s.prototype,"options",void 0),__decorate([t.Watch({converter:t.PropertyConverters.Number})],s.prototype,"zoom",void 0),__decorate([t.ViewChild("."+t.PCSS+"-2d")],s.prototype,"_stage",void 0),__decorate([t.ViewChild(t.P+"-resize")],s.prototype,"_resize",void 0),__decorate([t.Debounce(!0)],s.prototype,"_drawDebounced",null),s=__decorate([t.CustomElement({tagName:t.P+"-"+r.TAG_MIDDLE_NAME,shadow:!0,template:`<${t.P}-resize></${t.P}-resize><div class="${t.PCSS}-2d" part="container"></div><slot></slot>`})],s),r.Pacem2DElement=s}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){let r=class PacemTextElement extends e.UiElement{propertyChangedCallback(e,r,i,n){if(!n)switch(e){case"text":case"color":case"fontFamily":case"fontSize":case"fontWeight":case"fontStyle":case"anchor":t.Utils.isNull(this.stage)||this.stage.draw(this)}}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"text",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"color",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"fontFamily",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],r.prototype,"fontSize",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"fontWeight",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"fontStyle",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],r.prototype,"anchor",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"textAnchor",void 0),r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-text"})],r),e.PacemTextElement=r}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){e.AdapterUtils=class AdapterUtils{static stageDispatch(e,r,i){e instanceof EventTarget&&e.dispatchEvent(new t.Drawing.StageEvent("stage"+r,e,i,e.transformMatrix))}static isValidViewbox(e){return!t.Utils.isNullOrEmpty(e)&&t.Rect.isRect(e)&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height)}static itemDispatch(e,r,i){if(!t.Utils.isNull(e)){var n,a,s;i instanceof Event?a=i:n={item:e,offset:i},"string"==typeof r?s=r:(s=r.type,a=r.originalEvent);const l=e.stage.transformMatrix,c=()=>i instanceof Event?new t.Drawing.DrawableEvent(s,e,a,l):new t.Drawing.DragEvent(s,{detail:n,cancelable:s===t.UI.DragDropEventType.Init||s===t.UI.DragDropEventType.Drag},a,l),h=i instanceof Event?new t.Drawing.DrawableEvent("item"+s,e,a,l):new t.Drawing.DragEvent("item"+s,{detail:n,cancelable:s===t.UI.DragDropEventType.Init||s===t.UI.DragDropEventType.Drag},a,l);var o=!1;if(e instanceof EventTarget){const t=c();e.dispatchEvent(t),o=t.defaultPrevented}return e.stage.dispatchEvent(h),o||h.defaultPrevented}return!1}}}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){const r="pacem:2d-canvas-scene",i="pacem:2d-parent-matrix",n=t.CustomElementUtils.setAttachedPropertyValue,a=t.CustomElementUtils.getAttachedPropertyValue;function s(e){return"none"===e||t.Utils.isNullOrEmpty(e)}function o(e,r){return t.Utils.isNull(e)?r:e}let l=class PacemCanvasAdapterElement extends e.Pacem2DAdapterElement{constructor(){super(...arguments),this._pointer={page:{x:0,y:0},screen:{x:0,y:0},client:{x:0,y:0}},this._dragInitHandler=r=>{const n=this._hitTarget;if(t.Utils.isNull(n)||!t.Drawing.isUiObject(n)||!n.draggable)return void r.preventDefault();const s=r.detail,o=n,l=n.transformMatrix??t.Matrix2D.identity,c=a(n,i,t.Matrix2D.identity);s.data={item:o,initialTransformMatrix:l,parentMatrix:c};e.AdapterUtils.itemDispatch(o,r,{x:0,y:0})&&r.preventDefault()},this._draggingHandler=r=>{t.avoidHandler(r),this._dragging=!0;const i=r.detail,n=i.data,a=i.currentPosition.x-i.origin.x,s=i.currentPosition.y-i.origin.y,o={x:a*n.parentMatrix.a+n.initialTransformMatrix.e,y:s*n.parentMatrix.d+n.initialTransformMatrix.f},l=n.item.stage.transformMatrix;if(!e.AdapterUtils.itemDispatch(n.item,r,{x:a*l.a+l.e,y:s*l.d+l.f}))if(n.item instanceof t.Components.Drawing.UiElement)n.item.translateX=o.x,n.item.translateY=o.y;else{const e=n.initialTransformMatrix,r={a:e.a,b:e.b,c:e.c,d:e.d,e:o.x,f:o.y};t.Utils.extend(n.item,{transformMatrix:r})}},this._dragEndHandler=t=>{this._dragging=!1;const r=t.detail.data,i=r.item.transformMatrix;e.AdapterUtils.itemDispatch(r.item,t,{x:i.e,y:i.f})},this._mousemoveHandler=i=>{this._scopeEvent=i,this._pointer=t.CustomEventUtils.getEventCoordinates(i);const n=i.srcElement,s=a(n,r);this._requestDraw(s),this._dragging||t.Utils.isNull(this._hitTarget)||e.AdapterUtils.stageDispatch(s,"move",i)},this._mouseDownUpHandler=i=>{this._scopeEvent=i,this._pointer=t.CustomEventUtils.getEventCoordinates(i);const n=i.target;if(n instanceof HTMLCanvasElement){const s=a(n,r),o=this._hitTarget,l=i.type.replace(/^(mouse|touch)/,""),c="end"===l?"click":l;t.Utils.isNull(o)||o.stage!==s?e.AdapterUtils.stageDispatch(s,c,i):e.AdapterUtils.itemDispatch(this._hitTarget,c,i)}},this._scenes=new WeakMap,this._handles=new WeakMap}snapshot(t,e,r,i){const n=this._scenes;if(n.has(t)){const a=n.get(t).context.canvas;return this.snapshotElement(a,e,r,i)}return Promise.resolve(null)}getCanvas(t){const e=this._scenes;if(e.has(t)){return e.get(t).context.canvas}return null}_getScreenInverseMatrix(e,r){return t.Matrix2D.invert({a:e.a,b:e.b,c:e.c,d:e.d,e:e.e+r.x,f:e.f+r.y})}getTransformMatrix(e){const r=this._scenes;return r.has(e)?r.get(e).screenInverseMatrix:t.Matrix2D.identity}viewActivatedCallback(){super.viewActivatedCallback();const e=this._dragger=document.createElement(t.P+"-drag-drop");e.mode=t.UI.DragDataMode.Copy,e.dropBehavior=t.UI.DropBehavior.None,e.spillBehavior=t.UI.DropTargetMissedBehavior.None;const r=document.createElement("div");r.hidden=!0,e.floater=r;t.CustomElementUtils.findAncestorShell(this).appendChild(e),e.addEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(t.UI.DragDropEventType.Drag,this._draggingHandler,!1),e.addEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1)}disconnectedCallback(){const e=this._dragger;t.Utils.isNull(e)||(e.removeEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Drag,this._draggingHandler,!1),e.removeEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.remove()),super.disconnectedCallback()}invalidateSize(r,i){const n=this._scenes;if(!t.Utils.isNull(r)&&!t.Utils.isNullOrEmpty(i)&&n.has(r)){const a=n.get(r),s=a.context;s.canvas.width=i.width,s.canvas.height=i.height;const o=a.offset=t.Utils.offsetRect(s.canvas),l={x:0,y:0,width:i.width,height:i.height},c=r.aspectRatio,h=r.viewbox;if(e.AdapterUtils.isValidViewbox(h)){let e="contain",r="center",i="middle";if("object"==typeof c){switch(e=c.slice?"cover":"contain",c.x){case"min":r="left";break;case"max":r="right"}switch(c.y){case"min":i="top";break;case"max":i="bottom"}}const n=t.Rect.findTransform({x:0,y:0,width:h.width,height:h.height},l,e,r,i),s=t.Matrix2D.translate(n,{x:-n.a*h.x,y:-n.a*h.y});a.transformMatrix=s,a.screenInverseMatrix=this._getScreenInverseMatrix(s,o)}else a.transformMatrix=t.Matrix2D.identity}this._requestDraw(r)}getHitTarget(e){const r=this._hitTarget;return t.Utils.isNull(r)||r.stage!==e?null:r}initialize(e){if(t.Utils.isNull(e))throw"Provided scene is null or undefined.";const i=this._scenes,a=this._dragger;if(i.has(e)){const r=i.get(e).context.canvas;return t.Utils.isNull(a)||a.register(r),r}const s=e.stage;s.innerHTML="";const o=document.createElement("canvas");o.setAttribute("part","stage"),n(o,r,e);const l=o.getContext("2d");return o.addEventListener("mousemove",this._mousemoveHandler,!1),o.addEventListener("touchstart",this._mouseDownUpHandler,{passive:!0}),o.addEventListener("touchmove",this._mouseDownUpHandler,{passive:!0}),o.addEventListener("touchend",this._mouseDownUpHandler,{passive:!0}),o.addEventListener("click",this._mouseDownUpHandler,!1),o.addEventListener("mousedown",this._mouseDownUpHandler,!1),o.addEventListener("mouseup",this._mouseDownUpHandler,!1),s.appendChild(o),i.set(e,{context:l,transformMatrix:t.Matrix2D.identity,offset:t.Utils.offsetRect(o),screenInverseMatrix:t.Matrix2D.identity}),t.Utils.isNull(a)||a.register(o),o}dispose(e){const r=this._scenes;if(r.has(e)){var i=r.get(e).context.canvas;const n=this._dragger;t.Utils.isNull(n)||n.unregister(i),i.removeEventListener("click",this._mouseDownUpHandler,!1),i.removeEventListener("touchend",this._mouseDownUpHandler,!1),i.removeEventListener("mousedown",this._mouseDownUpHandler,!1),i.removeEventListener("mouseup",this._mouseDownUpHandler,!1),i.removeEventListener("touchstart",this._mouseDownUpHandler),i.removeEventListener("mousemove",this._mousemoveHandler,!1),i.remove(),r.delete(e)}}_requestDraw(t){const e=this._handles;e.has(t)&&cancelAnimationFrame(e.get(t));e.set(t,(()=>(this.draw(t),requestAnimationFrame(()=>{})))())}#a;draw(e){const r=this._scenes,i=this._handles;if(!t.Utils.isNull(e)){if(e.adapter!==this)return void(r.has(e)&&(r.delete(e),i.get(e)));if(!r.has(e))return void this.initialize(e);i.has(e)&&cancelAnimationFrame(i.get(e));const n=this._hitTarget,a=e.datasource||[];this._hitTarget=null;const s=r.get(e),o=s.context,l=o.canvas;this.#a=getComputedStyle(l),o.resetTransform(),o.clearRect(0,0,l.width,l.height);const c=s.transformMatrix;o.setTransform(c);const h=this._pointer,d=s.offset,m={x:h.page.x-d.x,y:h.page.y-d.y};for(let t of a)this._draw(e,o,t,{transformMatrix:c},m);const p=this._hitTarget;p!=n&&(t.Utils.isNull(n)||(n instanceof Element&&n.dispatchEvent(new t.Drawing.DrawableEvent("out",n,this._scopeEvent,c)),e.dispatchEvent(new t.Drawing.DrawableEvent("itemout",n,this._scopeEvent,c))),t.Utils.isNull(p)||(p instanceof Element&&p.dispatchEvent(new t.Drawing.DrawableEvent("over",p,this._scopeEvent,c)),e.dispatchEvent(new t.Drawing.DrawableEvent("itemover",p,this._scopeEvent,c))))}}_draw(e,r,a,s,o){if(a.stage??=e,t.Drawing.isDrawable(a)&&a.hide)return;let l;t.Drawing.isUiObject(a)&&a.draggable&&!a.hide&&!a.inert&&n(a,i,r.getTransform().inverse()),t.Drawing.isUiObject(a)&&(l=a.transformMatrix,t.Utils.isNull(l)||t.Matrix2D.isIdentity(l)||r.transform(l.a,l.b,l.c,l.d,l.e,l.f));let c=s;if(t.Drawing.isPresentationObject(a)&&(c=t.Drawing.PresentationState.combine(a,s,r.getTransform()),this._setPresentationState(r,c)),t.Drawing.isShape(a)||a instanceof t.Components.Drawing.ShapeElement)this._drawShape(r,a,o);else if(t.Drawing.isText(a)||a instanceof t.Components.Drawing.PacemTextElement)this._drawText(r,a,o);else if(t.Drawing.isImage(a)||a instanceof t.Components.Drawing.PacemImageElement)this._drawImage(r,a,o);else if(t.Drawing.isGroup(a)||a instanceof t.Components.Drawing.PacemGroupElement)for(let t of a.childDrawables||[])this._draw(e,r,t,c,o);t.Drawing.isUiObject(a)&&a.draggable&&!a.hide&&!a.inert&&n(a,"pacem:2d-world-matrix",r.getTransform().inverse()),this._setPresentationState(r,s)}_setPresentationState(e,r){if(e.setTransform(r.transformMatrix),t.Utils.isNullOrEmpty(r.stroke)||s(r.stroke)?e.strokeStyle="transparent":e.strokeStyle=r.stroke,t.Utils.isNullOrEmpty(r.lineWidth)?e.lineWidth=0:e.lineWidth=r.lineWidth,t.Utils.isNullOrEmpty(r.dashArray)?e.setLineDash([]):e.setLineDash(r.dashArray),t.Utils.isNullOrEmpty(r.lineCap)?e.lineCap="butt":e.lineCap=r.lineCap,t.Utils.isNullOrEmpty(r.lineJoin)?e.lineJoin="miter":e.lineJoin=r.lineJoin,"object"!=typeof r.fill||t.Utils.isNullOrEmpty(r.fill))t.Utils.isNullOrEmpty(r.fill)||"string"!=typeof r.fill||s(r.fill)?e.fillStyle="transparent":e.fillStyle=r.fill;else{const{stops:i}=r.fill;let n;if(t.Drawing.isLinearGradient(r.fill)){const{start:t,end:i}=r.fill;n=e.createLinearGradient(t.x,t.y,i.x,i.y)}else{if(!t.Drawing.isRadialGradient(r.fill))throw new Error("Unmanaged gradient type.");{const{center:t,radius:i}=r.fill;n=e.createRadialGradient(t.x,t.y,i,t.x,t.y,i)}}for(let t of i)n.addColorStop(t.offset,t.color);e.fillStyle=n}t.Utils.isNullOrEmpty(r.opacity)?e.globalAlpha=1:e.globalAlpha=r.opacity}_drawImage(e,r,i){const s="pacem:2d-canvas-imagesrc";let l=a(r,s);const c=()=>{let n=l.naturalWidth,a=l.naturalHeight,s=r.width,c=r.height;if(s>0&&c>0||(s>0?c=a*s/n:c>0?s=n*c/a:(s=n,c=a)),!this._dragging&&!r.inert&&!t.Utils.isNull(i)){const t=new Path2D(`M ${r.x} ${r.y} h ${s} v ${c} H ${r.x} Z`);e.isPointInPath(t,i.x,i.y)&&(this._hitTarget=r)}e.globalAlpha=o(r.opacity,1),e.drawImage(l,r.x,r.y,s,c)};t.Utils.isNull(l)?(l=new Image,l.src=r.src,l.onload=()=>{n(r,s,l),c()}):c()}_drawText(e,r,i){const n=this.DefaultShapeValues,a=e.fillStyle=o(r.color,n.stroke),l=(e.getTransform(),r.fontSize>0?`${r.fontSize}px`:this.#a.fontSize),c=r.fontStyle||this.#a.fontStyle,h=r.fontWeight||this.#a.fontWeight;e.font=`${c} ${h} ${l} ${r.fontFamily??this.#a.fontFamily}`,e.textAlign="middle"===r.textAnchor?"center":r.textAnchor,e.fillText(r.text,r.anchor.x,r.anchor.y),e.globalAlpha=o(r.opacity,1);const d=!s(a);if(!this._dragging&&!r.inert&&!t.Utils.isNull(i)){const t=e.measureText(r.text),n=t.width,a=t.actualBoundingBoxAscent+t.actualBoundingBoxDescent,s=r.anchor.x-t.actualBoundingBoxLeft,o=r.anchor.y-t.actualBoundingBoxAscent,l=new Path2D(`M ${s} ${o} h ${n} v ${a} H ${s} z`);d&&e.isPointInPath(l,i.x,i.y)&&(this._hitTarget=r)}}_drawShape(e,r,i){if(t.Utils.isNullOrEmpty(r?.pathData))return;e.beginPath();const n="string"!=typeof e.fillStyle||!s(e.fillStyle),a="string"!=typeof e.strokeStyle||!s(e.strokeStyle);var o=new Path2D(r.pathData);this._dragging||r.inert||t.Utils.isNull(i)||(n&&e.isPointInPath(o,i.x,i.y)||a&&e.isPointInStroke(o,i.x,i.y))&&(this._hitTarget=r),a&&e.stroke(o),n&&e.fill(o);const l=!t.Utils.isNullOrEmpty(r.vertices)&&r.vertices.length>1,c=!t.Utils.isNull(r.markerEnd),h=!t.Utils.isNull(r.markerStart),d=!t.Utils.isNull(r.markerMid);if((c||d||h)&&(l||this.log(t.Logging.LogLevel.Warn,"Not enough vertices were explicited in order to make markers renderable.")),l){const t=e.getTransform();if(h){const t=r.markerEnd,i=r.vertices[1],n=r.vertices[0],a=Math.atan2(n.y-i.y,n.x-i.x);this._drawMarker(e,t,n,a)}if(d){const i=r.markerEnd;for(let n=1;n<r.vertices.length-1;n++){e.setTransform(t);const a=r.vertices[n],s=r.vertices[n+1],o=Math.atan2(s.y-a.y,s.x-a.x);this._drawMarker(e,i,s,o)}}if(c){e.setTransform(t);const i=r.markerEnd,n=r.vertices[r.vertices.length-2],a=r.vertices[r.vertices.length-1],s=Math.atan2(a.y-n.y,a.x-n.x);this._drawMarker(e,i,a,s)}}}_drawMarker(e,r,i,n){const a=this.DefaultShapeValues,l=r.ref?.x||0,c=r.ref?.y||0,h=(r.width||1)*e.lineWidth,d=(r.width||1)*e.lineWidth;let m=r.viewbox,p={x:0,y:0,width:h,height:d};t.Utils.isNull(m)&&(m=p);const u={a:p.width/m.width,d:p.height/m.height};e.translate(i.x,i.y),e.rotate(n),e.scale(u.a,u.d),e.translate(-l,-c),e.fillStyle=o(r.fill,a.fill),e.strokeStyle=o(r.stroke,a.stroke);const g=!s(r.fill),v=!s(r.stroke);var y=new Path2D(r.pathData);g&&e.fill(y),v&&e.stroke(y)}};l=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-canvas-adapter"})],l),e.PacemCanvasAdapterElement=l}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){const r="http://www.w3.org/2000/svg",i="pacem:2-svg-drawable",n="pacem:2d-svg-stage",a=t.CustomElementUtils.getAttachedPropertyValue,s=t.CustomElementUtils.setAttachedPropertyValue,o=t.CustomElementUtils.deleteAttachedPropertyValue;function l(e,r){return t.Utils.isNull(e)?r:e}function c(t,e,r){return r>=t.children.length?(t.appendChild(e),null):t.replaceChild(e,t.children.item(r))}let h=class PacemSvgAdapterElement extends e.Pacem2DAdapterElement{constructor(){super(...arguments),this._hitTarget=null,this._dragInitHandler=r=>{const n=r.detail,s=n.element,o=a(s,i),l=o.stage.transformMatrix,c=o.transformMatrix??t.Matrix2D.identity;n.data={stageTransformMatrix:l,item:o,initialTransformMatrix:c};e.AdapterUtils.itemDispatch(o,r,{x:0,y:0})&&r.preventDefault()},this._draggingHandler=r=>{t.avoidHandler(r),this._dragging=!0;const i=r.detail.element,n=r.detail.data,a=r.detail,s=(a.currentPosition.x-a.origin.x)*n.stageTransformMatrix.a,o=(a.currentPosition.y-a.origin.y)*n.stageTransformMatrix.d,l=s+n.initialTransformMatrix.e,c=o+n.initialTransformMatrix.f,h={x:s+n.stageTransformMatrix.e,y:o+n.stageTransformMatrix.f};if(!e.AdapterUtils.itemDispatch(n.item,r,h)){const t=n.initialTransformMatrix;i.style.transform=`matrix(${t.a},${t.b},${t.c},${t.d},${l},${c})`}},this._dragEndHandler=r=>{this._dragging=!1;const i=r.detail,n=i.element,a=i.data,s=t.Utils.deserializeTransform(n.style),o={x:s.e,y:s.f};if(a.item instanceof t.Components.Drawing.UiElement)a.item.translateX=o.x,a.item.translateY=o.y;else{const e=a.initialTransformMatrix,r={a:e.a,b:e.b,c:e.c,d:e.d,e:o.x,f:o.y};t.Utils.extend(a.item,{transformMatrix:r})}n.style.transform="",e.AdapterUtils.itemDispatch(a.item,r,o)},this._mousemoveHandler=r=>{var s=t.CustomEventUtils.getEventCoordinates(r).client;if(!this._dragging){var o=null;r.target.getRootNode().elementsFromPoint(s.x,s.y).find(t=>(o=a(t,i))&&!o.inert);var l=this._hitTarget,c=o;(t.Utils.isNull(o&&o.stage)||!this._scenes.has(o.stage)||o.inert)&&(c=null);const h=this._hitTarget=c;if(c!==l&&(t.Utils.isNull(l)||(this._dragger.unregister(this._items.get(l)),e.AdapterUtils.itemDispatch(l,"out",r)),t.Utils.isNull(c)||(c.draggable&&this._dragger.register(this._items.get(c)),e.AdapterUtils.itemDispatch(c,"over",r))),t.Utils.isNull(h)){const i=r.currentTarget,s=a(i,n);t.Utils.isNull(s)||e.AdapterUtils.stageDispatch(s,"move",r)}}},this._mouseDownUpHandler=r=>{const i=r.currentTarget;if(i instanceof SVGSVGElement){const s=a(i,n),o=this._hitTarget,l=r.type.replace(/^mouse/,"");t.Utils.isNull(o)||o.stage!==s?e.AdapterUtils.stageDispatch(s,l,r):e.AdapterUtils.itemDispatch(this._hitTarget,l,r)}},this._scenes=new WeakMap,this._markers=new WeakMap,this._gradients=new WeakMap,this._items=new WeakMap}snapshot(t,e,r,i){if(this._scenes.has(t)){const n=this._scenes.get(t);return this.snapshotElement(n,e,r,i)}return Promise.resolve(null)}getTransformMatrix(e){const r=this._scenes;return r.has(e)?r.get(e).getScreenCTM().inverse():t.Matrix2D.identity}viewActivatedCallback(){super.viewActivatedCallback();const e=this._dragger=document.createElement(t.P+"-drag-drop");e.mode=t.UI.DragDataMode.Self;t.CustomElementUtils.findAncestorShell(this).appendChild(e),e.addEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(t.UI.DragDropEventType.Drag,this._draggingHandler,!1),e.addEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1)}disconnectedCallback(){const e=this._dragger;t.Utils.isNull(e)||(e.removeEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Drag,this._draggingHandler,!1),e.removeEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.remove()),super.disconnectedCallback()}invalidateSize(r,i){const n=this._scenes;if(!t.Utils.isNull(r)&&!t.Utils.isNullOrEmpty(i)&&n.has(r)){var a=n.get(r);a.setAttribute("width",i.width+""),a.setAttribute("height",i.height+"");const s=r.viewbox,o=r.aspectRatio;e.AdapterUtils.isValidViewbox(s)?a.setAttribute("viewBox",`${s.x} ${s.y} ${s.width} ${s.height}`):a.removeAttribute("viewBox"),t.Utils.isNullOrEmpty(o)||"string"==typeof o?a.removeAttribute("preserveAspectRatio"):a.setAttribute("preserveAspectRatio",`xM${o.x.substring(1)}YM${o.y.substring(1)} ${o.slice?"slice":"meet"}`)}}initialize(e){if(t.Utils.isNull(e))throw"Provided scene is null or undefined.";const i=this._scenes;if(i.has(e))return i.get(e);const a=e.stage;a.innerHTML="",this._items=new WeakMap;var o=document.createElementNS(r,"svg");o.setAttribute("part","stage"),s(o,n,e),a.appendChild(o),i.set(e,o);return o.addEventListener("mousemove",this._mousemoveHandler,!1),o.addEventListener("click",this._mouseDownUpHandler,!1),o.addEventListener("mousedown",this._mouseDownUpHandler,!1),o.addEventListener("mouseup",this._mouseDownUpHandler,!1),o}dispose(t){const e=this._scenes;if(e.has(t)){var r=e.get(t);r.removeEventListener("mousemove",this._mousemoveHandler),r.removeEventListener("click",this._mouseDownUpHandler),r.removeEventListener("mousedown",this._mouseDownUpHandler),r.removeEventListener("mouseup",this._mouseDownUpHandler),o(r,n),r.remove(),e.delete(t)}}getHitTarget(t){return this._hitTarget}draw(e,r,i=!1){const n=this._scenes,a=this._items;if(!t.Utils.isNull(e))if(e.adapter===this){n.has(e)||this.initialize(e);var s=e.datasource,o=!0,l=n.get(e);!t.Utils.isNull(r)&&a.has(r)&&(s=[r],l=a.get(r).parentNode,o=!1),o&&(l.innerHTML="<defs></defs>",this._markers=new WeakMap),this._draw(e,l,s||[],o,i)}else n.has(e)&&n.delete(e)}_hasItems(e){return t.Drawing.isGroup(e)}_disposeSvg(e){if(!t.Utils.isNull(e)){var r=a(e,i);o(e,i),this._items.delete(r)}}_draw(e,r,n,a,o){const h=this._items;let d=0;if(r.firstElementChild instanceof SVGDefsElement&&d++,!t.Utils.isNullOrEmpty(n))for(let m of n){let n;if(m.stage??=e,h.has(m)?(n=h.get(m),n.parentNode!==r&&this._disposeSvg(c(r,n,d))):(n=this._buildSVGElement(m),s(n,i,m),this._disposeSvg(c(r,n,d)),h.set(m,n)),t.Drawing.isDrawable(m)&&(m.hide?n.setAttribute("display","none"):n.removeAttribute("display"),n.style.transform=""),t.Drawing.isShape(m)){const t=n;t.setAttribute("d",l(m.pathData,"M0,0"));for(let{marker:e,suffix:i}of[{marker:m.markerStart,suffix:"start"},{marker:m.markerEnd,suffix:"end"},{marker:m.markerMid,suffix:"mid"}])if(e){const n=this._ensureMarker(r,e);t.setAttribute("marker-"+i,`url(#${n.id})`)}else t.removeAttribute("marker-"+i)}else if(t.Drawing.isText(m)){const e=n;e.textContent=m.text,e.style.fill=t.Utils.isNullOrEmpty(m.color)?"":m.color,e.style.fontFamily=t.Utils.isNullOrEmpty(m.fontFamily)?"":m.fontFamily,e.style.fontSize=t.Utils.isNull(m.fontSize)?"":m.fontSize+"px",t.Utils.isNullOrEmpty(m.fontWeight)||(e.style.fontWeight=m.fontWeight),t.Utils.isNullOrEmpty(m.fontStyle)||(e.style.fontStyle=m.fontStyle),e.setAttribute("text-anchor",l(m.textAnchor,"start")),t.Utils.isNull(m.anchor)?(e.removeAttribute("x"),e.removeAttribute("y")):(e.setAttribute("x",m.anchor.x.toString()),e.setAttribute("y",m.anchor.y.toString()))}else if(t.Drawing.isImage(m)){const e=n;e.setAttribute("href",m.src),e.setAttribute("preserveAspectRatio","none"),m.width>0?e.setAttribute("width",""+m.width):e.removeAttribute("width"),m.height>0?e.setAttribute("height",""+m.height):e.removeAttribute("height"),t.Utils.isNull(m.x)?e.removeAttribute("x"):e.setAttribute("x",""+m.x),t.Utils.isNull(m.y)?e.removeAttribute("y"):e.setAttribute("y",""+m.y)}if(t.Drawing.isUiObject(m)){const e=m.transformMatrix;t.Utils.isNull(e)||t.Matrix2D.isIdentity(e)?n.removeAttribute("transform"):n.setAttribute("transform",`matrix(${e.a} ${e.b} ${e.c} ${e.d} ${e.e} ${e.f})`);const r=l(m.opacity,1);1===r?n.removeAttribute("opacity"):n.setAttribute("opacity",""+r)}if(t.Drawing.isPresentationObject(m)){if(t.Utils.isNullOrEmpty(m.fill))n.removeAttribute("fill");else if("string"==typeof m.fill)n.setAttribute("fill",m.fill);else{const t=this._ensureGradient(r,m.fill);n.setAttribute("fill",`url(#${t.id})`)}t.Utils.isNullOrEmpty(m.stroke)?n.removeAttribute("stroke"):n.setAttribute("stroke",m.stroke),t.Utils.isNullOrEmpty(m.dashArray)?n.removeAttribute("stroke-dasharray"):n.setAttribute("stroke-dasharray",m.dashArray.join(" ")),t.Utils.isNullOrEmpty(m.lineCap)?n.removeAttribute("stroke-linecap"):n.setAttribute("stroke-linecap",m.lineCap),t.Utils.isNullOrEmpty(m.lineJoin)?n.removeAttribute("stroke-linejoin"):n.setAttribute("stroke-linejoin",m.lineJoin),t.Utils.isNullOrEmpty(m.lineWidth)?n.removeAttribute("stroke-width"):n.setAttribute("stroke-width",""+m.lineWidth)}m.inert?n.style.pointerEvents="none":n.style.pointerEvents="",(a||o)&&this._hasItems(m)&&this._draw(e,n,m.childDrawables,!0,o),d++}if(a)for(let t=r.children.length-1;t>=d;t--){const e=r.children.item(t);this._disposeSvg(e),e.remove()}}_buildSVGElement(e){return t.Drawing.isShape(e)||e instanceof t.Components.Drawing.ShapeElement?document.createElementNS(r,"path"):t.Drawing.isText(e)||e instanceof t.Components.Drawing.PacemTextElement?document.createElementNS(r,"text"):t.Drawing.isImage(e)||e instanceof t.Components.Drawing.PacemImageElement?document.createElementNS(r,"image"):document.createElementNS(r,"g")}_ensureGradient(e,i){const n=this._gradients;n.has(e)||n.set(e,new WeakMap);const a=n.get(e),s=t.Drawing.isLinearGradient(i),o=t.Drawing.isRadialGradient(i);if(a.has(i)){const t=a.get(i);(s&&t instanceof SVGLinearGradientElement||o&&t instanceof SVGRadialGradientElement)&&(t.remove(),a.delete(i))}if(!a.has(i)){let n,o=e;for(;t.Utils.isNull(n=o.querySelector(":scope > defs"));){const t=o.parentElement;if(!(t instanceof SVGElement))break;o=t}if(t.Utils.isNull(n))throw new Error("Must provide a <defs> element.");var l=null;if(s)l=document.createElementNS(r,"linearGradient");else{if(!t.Drawing.isRadialGradient(i))throw new Error("Unmanaged gradient type.");l=document.createElementNS(r,"radialGradient")}l.setAttribute("gradientUnits","userSpaceOnUse"),l.setAttribute("id",`grad-${t.Utils.uniqueCode()}`),n.appendChild(l),a.set(i,l)}const c=a.get(i);s?(c.setAttribute("x1",i.start.x.toString()),c.setAttribute("y1",i.start.y.toString()),c.setAttribute("x2",i.end.x.toString()),c.setAttribute("y2",i.end.y.toString())):o&&(c.setAttribute("cx",i.center.x.toString()),c.setAttribute("cy",i.center.y.toString()),c.setAttribute("r",i.radius.toString()));let h=0;for(let e of i.stops){for(;c.children.length<=h;){const t=document.createElementNS(r,"stop");c.appendChild(t)}const i=c.children.item(h);i.setAttribute("offset",100*e.offset+"%"),i.setAttribute("stop-color",e.color),t.Utils.isNull(e.opacity)||i.setAttribute("stop-opacity",e.opacity.toString()),h++}for(;c.children.length>i.stops.length;){const t=c.children.item(c.children.length-1);c.removeChild(t)}return c}_ensureMarker(e,i){const n=this._markers;n.has(e)||n.set(e,new WeakMap);const a=n.get(e);if(!a.has(i)){const n=document.createElementNS(r,"marker");a.set(i,n);const s=document.createElementNS(r,"path");n.appendChild(s),n.setAttribute("id","mark"+t.Utils.uniqueCode());let o,l=e;for(;t.Utils.isNull(o=l.querySelector(":scope > defs"));){const t=l.parentElement;if(!(t instanceof SVGElement))break;l=t}if(t.Utils.isNull(o))throw new Error("Must provide a <defs> element.");o.appendChild(n)}const s=a.get(i),o=s.firstElementChild;return s.setAttribute("orient","auto-start-reverse"),t.Utils.isNullOrEmpty(i.viewbox)?s.removeAttribute("viewBox"):s.setAttribute("viewBox",`${i.viewbox.x} ${i.viewbox.y} ${i.viewbox.width} ${i.viewbox.height}`),t.Utils.isNullOrEmpty(i.ref)?(s.removeAttribute("refX"),s.removeAttribute("refY")):(s.setAttribute("refX",i.ref.x.toString()),s.setAttribute("refY",i.ref.y.toString())),i.height>0?s.setAttribute("markerHeight",i.height.toString()):s.removeAttribute("markerHeight"),i.width>0?s.setAttribute("markerWidth",i.width.toString()):s.removeAttribute("markerWidth"),o.setAttribute("d",i.pathData),t.Utils.isNullOrEmpty(i.fill)?o.removeAttribute("fill"):o.setAttribute("fill",i.fill),t.Utils.isNullOrEmpty(i.stroke)?o.removeAttribute("stroke"):o.setAttribute("stroke",i.stroke),s}};h=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-svg-adapter"})],h),e.PacemSvgAdapterElement=h}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={}));
6
+ var Pacem,__decorate=this&&this.__decorate||function(t,e,r,i){var a,n=arguments.length,s=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,i);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(s=(n<3?a(s):n>3?a(e,r,s):a(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s};!function(t){!function(e){function r(e){return!t.Utils.isNull(e)&&"stage"in e}function i(t){return r(t)}function a(e){return"stops"in e&&t.Utils.isArray(e.stops)}e.isDrawable=r,e.isUiObject=i,e.isLinearGradient=function(e){return a(e)&&"start"in e&&t.Point.isPoint(e.start)&&"end"in e&&t.Point.isPoint(e.end)},e.isRadialGradient=function(e){return a(e)&&"center"in e&&t.Point.isPoint(e.center)&&"radius"in e&&"number"==typeof e.radius};e.PresentationState=class PresentationState{static combine(e,r,i=null){return{opacity:(e.opacity??1)*(r.opacity??1),transformMatrix:i??t.Matrix2D.multiply(r.transformMatrix,e.transformMatrix),dashArray:e.dashArray??r.dashArray,fill:e.fill??r.fill,lineCap:e.lineCap??r.lineCap,lineJoin:e.lineJoin??r.lineJoin,lineWidth:e.lineWidth??r.lineWidth,stroke:e.stroke??r.stroke}}},e.isPresentationObject=function(t){return i(t)&&("fill"in t||"transformMatrix"in t||"stroke"in t||"lineJoin"in t||"dashArray"in t||"lineWidth"in t||"opacity"in t||"lineCap"in t)},e.isShape=function(t){return i(t)&&"pathData"in t},e.isGroup=function(e){return i(e)&&"childDrawables"in e&&!t.Utils.isNullOrEmpty(e.childDrawables)},e.isText=function(t){return i(t)&&"text"in t&&"string"==typeof t.text},e.isImage=function(t){return i(t)&&"src"in t&&"string"==typeof t.src};class UI2DEvent extends t.CustomUIEvent{constructor(t,e,r,i){super(t,e,r),this.#t=i}#t;get transformMatrix(){return this.#t}project(e={x:this.screenX,y:this.screenY}){return t.Matrix2D.multiply(e,this.#t)}}e.UI2DEvent=UI2DEvent;e.Shape=class Shape{static empty(){return{pathData:"",vertices:[],boundingRect:{x:0,y:0,width:0,height:0}}}};e.DragEvent=class DragEvent extends UI2DEvent{};e.DrawableEvent=class DrawableEvent extends UI2DEvent{constructor(t,e,r,i){super(t,{detail:e,bubbles:!0,cancelable:!0},r,i)}};e.StageEvent=class StageEvent extends UI2DEvent{constructor(t,e,r,i=e.transformMatrix){super(t,{detail:e,bubbles:!0,cancelable:!0},r,i)}}}(t.Drawing||(t.Drawing={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(r){r.TAG_MIDDLE_NAME="2d",r.TWO_PI=2*Math.PI;const i=Math.PI/180;class Pacem2DAdapterElement extends e.PacemEventTarget{constructor(){super(...arguments),this.DefaultShapeValues={stroke:"#000",lineWidth:1,fill:"#fff"}}snapshotElement(e,r,i,a){const n=!t.Utils.isNullOrEmpty(r),s=i??(n?"image/jpeg":null),o=a??(n?.9:null);return t.Utils.snapshotElement(e,r,s,o)}}r.Pacem2DAdapterElement=Pacem2DAdapterElement;class DrawableElement extends e.PacemCrossItemsContainerElement{validate(t){return!1}findContainer(){return this.parent||this.stage}get stage(){return this._scene=this._scene||t.CustomElementUtils.findAncestorOfType(this,r.Pacem2DElement)}get parent(){return this._drawableParent=this._drawableParent||t.CustomElementUtils.findAncestor(this,t=>t instanceof DrawableElement)}disconnectedCallback(){delete this._scene,delete this._drawableParent,super.disconnectedCallback()}propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i&&"hide"===t)this.stage?.draw(this)}}__decorate([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],DrawableElement.prototype,"tag",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],DrawableElement.prototype,"inert",void 0),r.DrawableElement=DrawableElement;class UiElement extends DrawableElement{#t=t.Matrix2D.identity;viewActivatedCallback(){super.viewActivatedCallback(),this._updateTransformMatrix()}propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"rotate":case"scaleX":case"scaleY":case"translateX":case"translateY":this._updateTransformMatrix();case"opacity":this.stage?.draw(this)}}_updateTransformMatrix(){let t=i*(this.rotate??0),e=Math.cos(t),r=Math.sin(t),a=(this.scaleX??1)*e,n=-r,s=r,o=(this.scaleY??1)*e,l=this.translateX??0,c=this.translateY??0;this.#t={a:a,b:n,c:s,d:o,e:l,f:c}}get transformMatrix(){const t=this.#t;return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}}__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"rotate",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"scaleX",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"scaleY",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"translateX",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"translateY",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],UiElement.prototype,"opacity",void 0),r.UiElement=UiElement;class PresentationElement extends UiElement{propertyChangedCallback(e,r,i,a){if(super.propertyChangedCallback(e,r,i,a),!a)switch(e){case"stroke":case"lineWidth":case"lineJoin":case"lineCap":case"dashArray":case"fill":t.Utils.isNull(this.stage)||this.stage.draw(this)}}}__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PresentationElement.prototype,"stroke",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PresentationElement.prototype,"fill",void 0),__decorate([t.Watch({emit:!1,converter:{convert:t=>t?.split(",").map(t=>parseInt(t)).filter(t=>!Number.isNaN(t)),convertBack:t=>t?.join(",")}})],PresentationElement.prototype,"dashArray",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],PresentationElement.prototype,"lineWidth",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PresentationElement.prototype,"lineJoin",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PresentationElement.prototype,"lineCap",void 0),r.PresentationElement=PresentationElement;class ShapeElement extends PresentationElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i&&"data"===t)this.stage?.draw(this)}viewActivatedCallback(){super.viewActivatedCallback(),this.recomputeShape()}recomputeShape(){const{pathData:t,vertices:e,boundingRect:r}=this.getShapeGeometry();this.#e=e,this.#r=r,this.data=t}get pathData(){return this.data}#r;get boundingRect(){return this.#r}#e;get vertices(){return this.#e}}__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ShapeElement.prototype,"data",void 0),r.ShapeElement=ShapeElement}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){var r,i;function a(e,r,i,a,n){for(a??=0,n??=0,a%=360,n%=360;a<0;)a+=360;for(;n<a;)n+=360;return(a-n).isCloseTo(0)?function(t,e,r){const i=2*e,a=t.x,n=t.y;return{pathData:`M ${a} ${n} m ${-e},0 a ${e},${r} 0 1,1 ${i},0 a ${e},${r} 0 1,1 ${-i},0`,vertices:[],boundingRect:{x:a-e,y:n-r,width:2*e,height:2*r}}}(e,r,i):function(e,r,i,a,n){const s=Math.PI/180,o=s*a,l=s*n,c=t=>r*i/Math.sqrt(Math.pow(Math.cos(t)*i,2)+Math.pow(Math.sin(t)*r,2)),h=c(o),d=c(l),m=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)}),p=m(h,o),u=m(d,l),g={x:e.x+p.x,y:e.y+p.y},v={x:e.x+u.x,y:e.y+u.y};let y=t.Rect.expand(e,g,v);n<a&&(n+=360),(a<=0&&n>0||n>=360)&&(y=t.Rect.expand(y,{x:e.x+r,y:e.y})),(a<=90&&n>90||n>=450)&&(y=t.Rect.expand(y,{x:e.x,y:e.y+i})),(a<=180&&n>180||n>=540)&&(y=t.Rect.expand(y,{x:e.x-r,y:e.y})),(a<=270&&n>270||n>=630)&&(y=t.Rect.expand(y,{x:e.x,y:e.y-i}));const f=l-o>Math.PI?"1":"0";return{pathData:`M ${g.x} ${g.y} A ${r},${i} 0 ${f},1 ${v.x},${v.y} L ${e.x},${e.y} Z`,vertices:[g,v],boundingRect:y}}(e,r,i,a,n)}let n=r=class PacemEllipseElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"center":case"rx":case"ry":case"start":case"end":this.recomputeShape()}}getPathData(){const e=this.rx,i=this.ry,a=this.center,n=this.start??0,s=this.end??0;return t.Utils.isNull(a)||t.Utils.isNull(e)||t.Utils.isNull(i)?null:r.getPathData(a,e,i,n,s)}getShapeGeometry(){return a(this.center??{x:0,y:0},this.rx??0,this.ry??0,this.start,this.end)}static getPathData(t={x:NaN,y:NaN},e=NaN,r=NaN,i,n){const{pathData:s}=a(t,e,r,i,n);return s}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],n.prototype,"center",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],n.prototype,"rx",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],n.prototype,"ry",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],n.prototype,"start",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],n.prototype,"end",void 0),n=r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-ellipse"})],n),e.PacemEllipseElement=n;let s=i=class PacemCircleElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"center":case"radius":case"start":case"end":this.recomputeShape()}}getPathData(){const e=this.radius,r=this.center;return t.Utils.isNull(r)||t.Utils.isNull(e)?null:i.getPathData(r,e,this.start,this.end)}getShapeGeometry(){const t=this.center??{x:0,y:0},e=this.radius??0;return a(t,e,e,this.start,this.end)}static getPathData(t={x:NaN,y:NaN},e=NaN,r,i){return n.getPathData(t,e,e,r,i)}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],s.prototype,"center",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],s.prototype,"radius",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],s.prototype,"start",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],s.prototype,"end",void 0),s=i=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-circle"})],s),e.PacemCircleElement=s}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){let r=class PacemGroupElement extends e.PresentationElement{validate(t){return t instanceof e.DrawableElement&&t.parent===this}#i=[];get childDrawables(){return this.#i}propertyChangedCallback(e,r,i,a){switch(super.propertyChangedCallback(e,r,i,a),e){case"items":case"datasource":this.#i=i||[];const e=this.stage;t.Utils.isNull(e)||e.draw(this,!0)}}};__decorate([t.Watch({emit:!1})],r.prototype,"datasource",void 0),r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-group"})],r),e.PacemGroupElement=r}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){let r=class PacemImageElement extends e.UiElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"src":case"x":case"y":case"width":case"height":this.stage?.draw(this)}}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"src",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],r.prototype,"x",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],r.prototype,"y",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],r.prototype,"width",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],r.prototype,"height",void 0),r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-image"})],r),e.PacemImageElement=r}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){var r;let i=r=class PacemLineElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"from":case"to":this.recomputeShape()}}getShapeGeometry(){const e=this.from,r=this.to;if(t.Utils.isNull(e)||t.Utils.isNull(r))return t.Drawing.Shape.empty();const i=e.x,a=e.y,n=r.x,s=r.y,o={x:Math.min(i,n),y:Math.min(a,s),width:Math.abs(i-n),height:Math.abs(a-s)};return{pathData:this.getPathData(),vertices:[e,r],boundingRect:o}}getPathData(){const e=this.from,i=this.to;return t.Utils.isNull(e)||t.Utils.isNull(i)?null:r.getPathData(e,i)}static getPathData(t={x:NaN,y:NaN},e={x:NaN,y:NaN}){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],i.prototype,"from",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],i.prototype,"to",void 0),i=r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-line"})],i),e.PacemLineElement=i}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){let r=class PacemPathElement extends e.ShapeElement{constructor(){super(...arguments),this.getPathData=()=>this.d}propertyChangedCallback(t,e,r,i){super.propertyChangedCallback(t,e,r,i),"d"!==t||i||this.recomputeShape()}getShapeGeometry(){return{pathData:this.getPathData(),boundingRect:null,vertices:[]}}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"d",void 0),r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-path"})],r),e.PacemPathElement=r}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){var r;let i=r=class PacemPolygonElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"radius":case"starIndent":case"sides":this.recomputeShape()}}getPathData(){const e=this.sides,i=this.radius,a=this.center;return t.Utils.isNull(e)||t.Utils.isNull(i)?null:r.getPathData(a,i,e,this.starIndent)}getShapeGeometry(){const e=this.center??{x:0,y:0},i=this.radius??0,a=this.sides??3,n=this.starIndent;return a<3?t.Drawing.Shape.empty():r.getShapeGeometry(e,i,a,n)}static getShapeGeometry(t,e,r,i=0){const a={x:t.x,y:t.y-e};let n=`M ${a.x} ${a.y}`;const s=[a],o=2*Math.PI/r,l=.5*o,c=i>0,h=e*Math.cos(l);for(let a=1;a<r;a++){const r=a*o,d=t.x+Math.sin(r)*e,m=t.y-Math.cos(r)*e;if(c){const e=h*(1-i),a=r-l,o=t.x+Math.sin(a)*e,c=t.y-Math.cos(a)*e;n+=` L ${o} ${c} L ${d} ${m}`,s.push({x:o,y:c})}else n+=` L ${d} ${m}`;s.push({x:d,y:m})}if(c){const e=h*(1-i),r=2*Math.PI-l,a=t.x+Math.sin(r)*e,o=t.y-Math.cos(r)*e;n+=` L ${a} ${o}`,s.push({x:a,y:o})}s.push(a);const d=2*e;return{pathData:n+" Z",vertices:s,boundingRect:{x:a.x-e,y:a.y,width:d,height:d}}}static getPathData(t,e,i,a=0){const{pathData:n}=r.getShapeGeometry(t,e,i,a);return n}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],i.prototype,"sides",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],i.prototype,"radius",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],i.prototype,"center",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],i.prototype,"starIndent",void 0),i=r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-polygon"})],i),e.PacemPolygonElement=i}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){var r;const i={convert:e=>{const r=t.parseAsNumericalArray(e);if(r.length%2==0){const t=[];for(let e=0;e<r.length;e+=2)t.push({x:r[e],y:r[e+1]});return t}return JSON.parse(e)},convertBack:t=>JSON.stringify(t)};let a=r=class PacemPolylineElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){if(super.propertyChangedCallback(t,e,r,i),!i)switch(t){case"points":case"closed":this.recomputeShape()}}static getShapeGeometry(e,r){if(t.Utils.isNullOrEmpty(e))return t.Drawing.Shape.empty();let i="",a=Number.MAX_VALUE,n=Number.MAX_VALUE,s=Number.MIN_VALUE,o=Number.MIN_VALUE;for(let t=0;t<e.length;t++){const{x:r,y:l}=e[t];i+=`${0===t?"M":"L"} ${r} ${l} `,a=Math.min(a,r),s=Math.max(s,r),n=Math.min(n,l),o=Math.max(o,l)}return r&&(i+="Z"),{pathData:i,vertices:e,boundingRect:{x:a,y:n,width:s-a,height:o-n}}}getShapeGeometry(){return r.getShapeGeometry(this.points,this.closed)}getPathData(){const{pathData:t}=this.getShapeGeometry();return t}static getPathData(t,e){const{pathData:i}=r.getShapeGeometry(t,e);return i}};__decorate([t.Watch({emit:!1,converter:i})],a.prototype,"points",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],a.prototype,"closed",void 0),a=r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-polyline"})],a),e.PacemPolylineElement=a}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){var r;function i(t){const e=t[2],r=t[4]??e,i="cut"===t[6]?o.Cut:o.Rounded;return{rx:a(e),ry:a(r),type:i}}function a(t){return{value:parseFloat(t),unit:t.endsWith("%")?"pct":"u"}}function n(t){return`${t.value}${"pct"===t.unit?"%":""}`}const s=/(([\d\.]+%?)(\s*,?\s*([\d\.]+%?))?(\s+(cut|round))?)/g;let o;!function(t){t.Rounded="rounded",t.Cut="cut"}(o=e.CornerType||(e.CornerType={}));let l=r=class PacemRectElement extends e.ShapeElement{propertyChangedCallback(t,e,r,i){super.propertyChangedCallback(t,e,r,i),i||"x"!==t&&"y"!==t&&"w"!==t&&"h"!==t&&"r"!==t&&"cornerType"!==t||this.recomputeShape()}getPathData(){const e=this.x,i=this.y,a=this.w,n=this.h;let s=this.r??{rx:{value:0},ry:{value:0},type:o.Rounded};return t.Utils.isArray(s)||(s=[s,s,s,s]),s=s.map(t=>"number"==typeof t?{rx:{value:t},ry:{value:t},type:this.cornerType}:t),t.Utils.isNull(e)||t.Utils.isNull(i)||t.Utils.isNull(a)||t.Utils.isNull(n)?null:r.getPathData(e,i,a,n,s)}getShapeGeometry(){const t=this.x,e=this.y,r=t+this.w,i=e+this.h;return{pathData:this.getPathData(),vertices:[{x:t,y:e},{x:r,y:e},{x:r,y:i},{x:t,y:i}],boundingRect:{x:t,y:e,width:this.w,height:this.h}}}static getPathData(e=NaN,r=NaN,i=NaN,a=NaN,n=null){if(!n)return`M ${e} ${r} h ${i} v ${a} h ${-i} z`;t.Utils.isArray(n)||(n=[n,n,n,n]);const s=n[0],o=n[1],l=n[2],c=n[3],h=t=>"pct"===t.unit?.01*t.value*i:t.value,d=t=>"pct"===t.unit?.01*t.value*a:t.value,m=h(s.rx),p=d(s.ry),u=h(o.rx),g=d(o.ry),v=h(l.rx),y=d(l.ry),f=h(c.rx),_=d(c.ry);let x=`M ${e},${r+p}`;if("cut"===s.type)x+=` l ${m},${-p}`;else x+=` a ${m} ${p} 0 0 1 ${m} ${-p}`;if(x+=" h "+(i-m-u),"cut"===o.type)x+=` l ${u},${g}`;else x+=` a ${u} ${g} 0 0 1 ${u} ${g}`;if(x+=" v "+(a-g-y),"cut"===l.type)x+=` l ${-v},${y}`;else x+=` a ${v} ${y} 0 0 1 ${-v} ${y}`;if(x+=" h "+-(i-v-f),"cut"===c.type)x+=` l ${-f},${-_}`;else x+=` a ${f} ${_} 0 0 1 ${-f} ${-_}`;return x+" z"}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],l.prototype,"x",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],l.prototype,"y",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],l.prototype,"w",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],l.prototype,"h",void 0),__decorate([t.Watch({emit:!1,converter:{convert:t=>function(t){let e;const r=[];for(;e=s.exec(t);)r.push(e);switch(r.length){case 1:const t=i(r[0]);return[t,t,t,t];case 4:return[i(r[0]),i(r[1]),i(r[2]),i(r[3])];default:return null}}(t),convertBack:t=>function(t){const e=t[0],r=t[1],i=t[2],a=t[3];return`${n(e.rx)},${n(e.ry)} ${n(r.rx)},${n(r.ry)} ${n(i.rx)},${n(i.ry)} ${n(a.rx)},${n(a.ry)}`}(t)}})],l.prototype,"r",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],l.prototype,"cornerType",void 0),l=r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-rect"})],l),e.PacemRectElement=l}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(r){const i=/^\s*[xX]\s*([Mm](in|ax|id))\s*[yY]\s*([Mm](in|ax|id))(\s+(none|slice|meet))?\s*$/,a={convert:t=>{const e=i.exec(t);return e&&e.length>=4?{x:e[1].toLowerCase(),y:e[3].toLowerCase(),slice:"slice"===e[6]}:"none"},convertBack:e=>t.Utils.isNull(e)||"string"==typeof e?"none":`xM${e.x.substr(1)}YM${e.y.substr(1)} ${e.slice?"slice":"meet"}`},n={panControl:!0,zoomControl:!0,panModifiers:[t.EventKeyModifier.AltKey],zoomModifiers:[t.EventKeyModifier.AltKey]};let s=class Pacem2DElement extends e.PacemItemsContainerElement{constructor(){super(...arguments),this.#t=t.Matrix2D.identity,this._options=n,this._resizeHandler=e=>{this.#a={x:e.detail.left,y:e.detail.top,width:e.detail.width,height:e.detail.height};const r=this.adapter;t.Utils.isNull(r)||this._invalidateSize()},this._zoomHandler=e=>{const r=this._options;if(r.zoomControl&&t.CustomEventUtils.matchModifiers(e,r.zoomModifiers)){t.avoidHandler(e);const r=1+.1*(e.deltaY<0?-1:1),i=t.Utils.offsetRect(e.currentTarget),a={x:e.clientX,y:e.clientY};this._zoom(r,i,a)}},this._panHandler=e=>{const r=this._panningStart,i=this._getPanPoint(e);if(!t.Utils.isNullOrEmpty(r&&r.point)&&!t.Utils.isNull(i)){t.avoidHandler(e);const a=r.factor,n=r.box,s=r.point;this.viewbox={x:n.x-a*(i.x-s.x),y:n.y-a*(i.y-s.y),width:n.width,height:n.height}}},this._panStartHandler=e=>{if(!this._options.panControl)return;const r=this.#a,i=this.viewbox||{x:0,y:0,width:r.width,height:r.height},a=this._getPanPoint(e);if(a){t.avoidHandler(e),this._stage.style.pointerEvents="none";const n=this._getActualAspectRatio(),s=i.width/r.width,o=i.height/r.height,l=n.slice?Math.min(s,o):Math.max(s,o);this._panningStart={point:a,box:i,factor:l}}},this._panEndHandler=t=>{this._stage.style.pointerEvents="",this._panningStart=null}}get stage(){return this._stage}snapshot(e,r,i){const a=this.adapter;return t.Utils.isNull(a)?Promise.resolve(null):a.snapshot(this,e,r,i)}#n;#t;get transformMatrix(){return this.#t}_transformMatrixScale(){const e=this.#a||t.Utils.offsetRect(this._stage);var r=this.#n||e;const i=this.viewbox||r,a=this.aspectRatio||"none",n="none"===a?"stretch":a.slice?"cover":"contain";return t.Rect.findTransform(i,r,n).a}validate(e){return e instanceof r.DrawableElement&&t.Utils.isNull(e.parent)}draw(e,r=!1){const i=this.adapter;if(!this.disabled&&!t.Utils.isNull(i)){let t=new CustomEvent("predraw",{cancelable:!0});this.dispatchEvent(t),t.defaultPrevented||(i.draw(this,e,r),this.dispatchEvent(new CustomEvent("draw")))}}_drawDebounced(e,r=!1){!t.Utils.isNull(e)&&t.Drawing.isGroup(e)?this.draw(e,r):this.draw(e)}requestDraw(t,e=!1){this._drawDebounced(t,e)}_buildUpDatasourceFromDOM(){this.datasource=(this.items||[]).slice()}#a;_getActualAspectRatio(){const t=this.aspectRatio||"none";return{x:"none"===t?"mid":t.x,y:"none"===t?"mid":t.y,slice:"none"!==t&&t.slice}}_zoomFromValue(e){const r=this.#a;if(t.Utils.isNull(r))return;const i=r,a=this.#n||i,n=this.viewbox||a,s=this.aspectRatio||"none",o="none"===s?"stretch":s.slice?"cover":"contain",l=t.Rect.findTransform(n,i,o),c=t.Rect.findTransform(a,i,o),h=l.a/(c.a*e);this._zoom(h)}_zoom(e,r,i){t.Utils.isNull(r)&&(r=t.Utils.offsetRect(this._stage)),t.Utils.isNull(i)&&(i={x:r.x+.5*r.width,y:r.y+.5*r.height});const a=this.#a,n=this.viewbox||a,s=Math.min(n.width,n.height),o=s*e,l=s*e;if(o>0&&l>0){const t=this._getActualAspectRatio(),e=t.x,a=t.y,s=t.slice,c=n.width/n.height,h=s?Math.max(r.width,r.height):Math.min(r.width,r.height);let d,m;switch(e){case"mid":d=(o-n.width)*(i.x-r.x-.5*(r.width-h))/(h*c);break;case"max":d=(o-n.width)*(i.x-r.x-(r.width-h))/(h*c);break;default:d=(o-n.width)*(i.x-r.x)/(h*c)}switch(a){case"mid":m=(l-n.height)*(i.y-r.y-.5*(r.height-h))/(h*c);break;case"max":m=(l-n.height)*(i.y-r.y-(r.height-h))/(h*c);break;default:m=(l-n.height)*(i.y-r.y)/(h*c)}const p=n.x-d,u=n.y-m;this.viewbox={x:p,y:u,width:o,height:l}}}_getPanPoint(e){const r=this._options;return e instanceof MouseEvent&&t.CustomEventUtils.matchModifiers(e,r.panModifiers)?t.CustomEventUtils.getEventCoordinates(e).page:null}_invalidateSize(){this.adapter.invalidateSize(this,this.#a);const r=this.#t;this.#t=this.adapter.getTransformMatrix(this),this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"transformMatrix",currentValue:this.#t,oldValue:r})),this.zoom=this._transformMatrixScale(),this.dispatchEvent(new e.ResizeEvent(this.#a))}viewActivatedCallback(){super.viewActivatedCallback();const e=this.adapter;t.Utils.isNull(e)||(e.initialize(this),this._invalidateSize(),this._drawDebounced());const r=this._resize;r.addEventListener(t.Components.ResizeEventName,this._resizeHandler,!1);const i=this._stage;r.target=i;const a={capture:!1,passive:!0};i.addEventListener("wheel",this._zoomHandler,!1),i.addEventListener("mousedown",this._panStartHandler,!1),i.addEventListener("touchstart",this._panStartHandler,a),window.addEventListener("mousemove",this._panHandler,!1),window.addEventListener("mouseup",this._panEndHandler,!1),window.addEventListener("touchmove",this._panHandler,a),window.addEventListener("touchend",this._panEndHandler,a)}propertyChangedCallback(e,r,i,a){switch(super.propertyChangedCallback(e,r,i,a),e){case"adapter":t.Utils.isNull(r)||r.dispose(this),t.Utils.isNull(i)||(i.initialize(this),this._invalidateSize(),this._drawDebounced());break;case"aspectRatio":t.Utils.isNull(this.adapter)||this._invalidateSize();break;case"viewbox":t.Utils.isNull(this.adapter)||this._invalidateSize(),this.#n??=this.viewbox||null;break;case"items":this._buildUpDatasourceFromDOM();break;case"zoom":i!==this._transformMatrixScale()&&this._zoomFromValue(i);break;case"options":this._options=t.Utils.extend({},n,i||{});break;case"disabled":case"datasource":this._drawDebounced()}}disconnectedCallback(){const e=this._resize,r=this._stage;t.Utils.isNull(e)||e.removeEventListener(t.Components.ResizeEventName,this._resizeHandler,!1),t.Utils.isNull(r)||(r.removeEventListener("wheel",this._zoomHandler,!1),r.removeEventListener("mousedown",this._panStartHandler,!1),r.removeEventListener("touchstart",this._panStartHandler),window.removeEventListener("mousemove",this._panHandler,!1),window.removeEventListener("mouseup",this._panEndHandler,!1),window.removeEventListener("touchmove",this._panHandler),window.removeEventListener("touchend",this._panEndHandler)),t.Utils.isNull(this.adapter)||this.adapter.dispose(this),super.disconnectedCallback()}};__decorate([t.Watch({converter:t.PropertyConverters.Element})],s.prototype,"adapter",void 0),__decorate([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Rect})],s.prototype,"viewbox",void 0),__decorate([t.Watch({emit:!1,reflectBack:!0,converter:a})],s.prototype,"aspectRatio",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],s.prototype,"datasource",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],s.prototype,"options",void 0),__decorate([t.Watch({converter:t.PropertyConverters.Number})],s.prototype,"zoom",void 0),__decorate([t.ViewChild("."+t.PCSS+"-2d")],s.prototype,"_stage",void 0),__decorate([t.ViewChild(t.P+"-resize")],s.prototype,"_resize",void 0),__decorate([t.Debounce(!0)],s.prototype,"_drawDebounced",null),s=__decorate([t.CustomElement({tagName:t.P+"-"+r.TAG_MIDDLE_NAME,shadow:!0,template:`<${t.P}-resize watch-position="true"></${t.P}-resize><div class="${t.PCSS}-2d" part="container"></div><slot></slot>`})],s),r.Pacem2DElement=s}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){let r=class PacemTextElement extends e.UiElement{propertyChangedCallback(e,r,i,a){if(!a)switch(e){case"text":case"color":case"fontFamily":case"fontSize":case"fontWeight":case"fontStyle":case"anchor":t.Utils.isNull(this.stage)||this.stage.draw(this)}}};__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"text",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"color",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"fontFamily",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],r.prototype,"fontSize",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"fontWeight",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"fontStyle",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.Point})],r.prototype,"anchor",void 0),__decorate([t.Watch({emit:!1,converter:t.PropertyConverters.String})],r.prototype,"textAnchor",void 0),r=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-text"})],r),e.PacemTextElement=r}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){e.AdapterUtils=class AdapterUtils{static stageDispatch(e,r,i){e instanceof EventTarget&&e.dispatchEvent(new t.Drawing.StageEvent("stage"+r,e,i,e.transformMatrix))}static isValidViewbox(e){return!t.Utils.isNullOrEmpty(e)&&t.Rect.isRect(e)&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height)}static itemDispatch(e,r,i){if(!t.Utils.isNull(e)){var a,n,s;i instanceof Event?n=i:a={item:e,offset:i},"string"==typeof r?s=r:(s=r.type,n=r.originalEvent);const l=e.stage.transformMatrix,c=()=>i instanceof Event?new t.Drawing.DrawableEvent(s,e,n,l):new t.Drawing.DragEvent(s,{detail:a,cancelable:s===t.UI.DragDropEventType.Init||s===t.UI.DragDropEventType.Drag},n,l),h=i instanceof Event?new t.Drawing.DrawableEvent("item"+s,e,n,l):new t.Drawing.DragEvent("item"+s,{detail:a,cancelable:s===t.UI.DragDropEventType.Init||s===t.UI.DragDropEventType.Drag},n,l);var o=!1;if(e instanceof EventTarget){const t=c();e.dispatchEvent(t),o=t.defaultPrevented}return e.stage.dispatchEvent(h),o||h.defaultPrevented}return!1}}}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){const r="pacem:2d-canvas-scene",i="pacem:2d-parent-matrix",a=t.CustomElementUtils.setAttachedPropertyValue,n=t.CustomElementUtils.getAttachedPropertyValue;function s(e){return"none"===e||t.Utils.isNullOrEmpty(e)}function o(e,r){return t.Utils.isNull(e)?r:e}let l=class PacemCanvasAdapterElement extends e.Pacem2DAdapterElement{constructor(){super(...arguments),this._pointer={page:{x:0,y:0},screen:{x:0,y:0},client:{x:0,y:0}},this._dragInitHandler=r=>{const a=this._hitTarget;if(t.Utils.isNull(a)||!t.Drawing.isUiObject(a)||!a.draggable)return void r.preventDefault();const s=r.detail,o=a,l=a.transformMatrix??t.Matrix2D.identity,c=n(a,i,t.Matrix2D.identity);s.data={item:o,initialTransformMatrix:l,parentMatrix:c};e.AdapterUtils.itemDispatch(o,r,{x:0,y:0})&&r.preventDefault()},this._draggingHandler=r=>{t.avoidHandler(r),this._dragging=!0;const i=r.detail,a=i.data,n=i.currentPosition.x-i.origin.x,s=i.currentPosition.y-i.origin.y,o={x:n*a.parentMatrix.a+a.initialTransformMatrix.e,y:s*a.parentMatrix.d+a.initialTransformMatrix.f},l=a.item.stage.transformMatrix;if(!e.AdapterUtils.itemDispatch(a.item,r,{x:n*l.a+l.e,y:s*l.d+l.f}))if(a.item instanceof t.Components.Drawing.UiElement)a.item.translateX=o.x,a.item.translateY=o.y;else{const e=a.initialTransformMatrix,r={a:e.a,b:e.b,c:e.c,d:e.d,e:o.x,f:o.y};t.Utils.extend(a.item,{transformMatrix:r})}},this._dragEndHandler=t=>{this._dragging=!1;const r=t.detail.data,i=r.item.transformMatrix;e.AdapterUtils.itemDispatch(r.item,t,{x:i.e,y:i.f})},this._mousemoveHandler=i=>{this._scopeEvent=i,this._pointer=t.CustomEventUtils.getEventCoordinates(i);const a=i.srcElement,s=n(a,r);this._requestDraw(s),this._dragging||t.Utils.isNull(this._hitTarget)||e.AdapterUtils.stageDispatch(s,"move",i)},this._mouseDownUpHandler=i=>{this._scopeEvent=i,this._pointer=t.CustomEventUtils.getEventCoordinates(i);const a=i.target;if(a instanceof HTMLCanvasElement){const s=n(a,r),o=this._hitTarget,l=i.type.replace(/^(mouse|touch)/,""),c="end"===l?"click":l;t.Utils.isNull(o)||o.stage!==s?e.AdapterUtils.stageDispatch(s,c,i):e.AdapterUtils.itemDispatch(this._hitTarget,c,i)}},this._scenes=new WeakMap,this._handles=new WeakMap}snapshot(t,e,r,i){const a=this._scenes;if(a.has(t)){const n=a.get(t).context.canvas;return this.snapshotElement(n,e,r,i)}return Promise.resolve(null)}getCanvas(t){const e=this._scenes;if(e.has(t)){return e.get(t).context.canvas}return null}_getScreenInverseMatrix(e,r){return t.Matrix2D.invert({a:e.a,b:e.b,c:e.c,d:e.d,e:e.e+r.x,f:e.f+r.y})}getTransformMatrix(e){const r=this._scenes;return r.has(e)?r.get(e).screenInverseMatrix:t.Matrix2D.identity}viewActivatedCallback(){super.viewActivatedCallback();const e=this._dragger=document.createElement(t.P+"-drag-drop");e.mode=t.UI.DragDataMode.Copy,e.dropBehavior=t.UI.DropBehavior.None,e.spillBehavior=t.UI.DropTargetMissedBehavior.None;const r=document.createElement("div");r.hidden=!0,e.floater=r;t.CustomElementUtils.findAncestorShell(this).appendChild(e),e.addEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(t.UI.DragDropEventType.Drag,this._draggingHandler,!1),e.addEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1)}disconnectedCallback(){const e=this._dragger;t.Utils.isNull(e)||(e.removeEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Drag,this._draggingHandler,!1),e.removeEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.remove()),super.disconnectedCallback()}invalidateSize(r,i){const a=this._scenes;if(!t.Utils.isNull(r)&&!t.Utils.isNullOrEmpty(i)&&a.has(r)){const n=a.get(r),s=n.context;s.canvas.width=i.width,s.canvas.height=i.height;const o=n.offset=t.Utils.offsetRect(s.canvas),l={x:0,y:0,width:i.width,height:i.height},c=r.aspectRatio,h=r.viewbox;if(e.AdapterUtils.isValidViewbox(h)){let e="contain",r="center",i="middle";if("object"==typeof c){switch(e=c.slice?"cover":"contain",c.x){case"min":r="left";break;case"max":r="right"}switch(c.y){case"min":i="top";break;case"max":i="bottom"}}const a=t.Rect.findTransform({x:0,y:0,width:h.width,height:h.height},l,e,r,i),s=t.Matrix2D.translate(a,{x:-a.a*h.x,y:-a.a*h.y});n.transformMatrix=s,n.screenInverseMatrix=this._getScreenInverseMatrix(s,o)}else n.transformMatrix=t.Matrix2D.identity}this._requestDraw(r)}getHitTarget(e){const r=this._hitTarget;return t.Utils.isNull(r)||r.stage!==e?null:r}initialize(e){if(t.Utils.isNull(e))throw"Provided scene is null or undefined.";const i=this._scenes,n=this._dragger;if(i.has(e)){const r=i.get(e).context.canvas;return t.Utils.isNull(n)||n.register(r),r}const s=e.stage;s.innerHTML="";const o=document.createElement("canvas");o.setAttribute("part","stage"),a(o,r,e);const l=o.getContext("2d");return o.addEventListener("mousemove",this._mousemoveHandler,!1),o.addEventListener("touchstart",this._mouseDownUpHandler,{passive:!0}),o.addEventListener("touchmove",this._mouseDownUpHandler,{passive:!0}),o.addEventListener("touchend",this._mouseDownUpHandler,{passive:!0}),o.addEventListener("click",this._mouseDownUpHandler,!1),o.addEventListener("mousedown",this._mouseDownUpHandler,!1),o.addEventListener("mouseup",this._mouseDownUpHandler,!1),s.appendChild(o),i.set(e,{context:l,transformMatrix:t.Matrix2D.identity,offset:t.Utils.offsetRect(o),screenInverseMatrix:t.Matrix2D.identity}),t.Utils.isNull(n)||n.register(o),o}dispose(e){const r=this._scenes;if(r.has(e)){var i=r.get(e).context.canvas;const a=this._dragger;t.Utils.isNull(a)||a.unregister(i),i.removeEventListener("click",this._mouseDownUpHandler,!1),i.removeEventListener("touchend",this._mouseDownUpHandler,!1),i.removeEventListener("mousedown",this._mouseDownUpHandler,!1),i.removeEventListener("mouseup",this._mouseDownUpHandler,!1),i.removeEventListener("touchstart",this._mouseDownUpHandler),i.removeEventListener("mousemove",this._mousemoveHandler,!1),i.remove(),r.delete(e)}}_requestDraw(t){const e=this._handles;e.has(t)&&cancelAnimationFrame(e.get(t));e.set(t,(()=>(this.draw(t),requestAnimationFrame(()=>{})))())}#s;draw(e){const r=this._scenes,i=this._handles;if(!t.Utils.isNull(e)){if(e.adapter!==this)return void(r.has(e)&&(r.delete(e),i.get(e)));if(!r.has(e))return void this.initialize(e);i.has(e)&&cancelAnimationFrame(i.get(e));const a=this._hitTarget,n=e.datasource||[];this._hitTarget=null;const s=r.get(e),o=s.context,l=o.canvas;this.#s=getComputedStyle(l),o.resetTransform(),o.clearRect(0,0,l.width,l.height);const c=s.transformMatrix;o.setTransform(c);const h=this._pointer,d=s.offset,m={x:h.page.x-d.x,y:h.page.y-d.y};for(let t of n)this._draw(e,o,t,{transformMatrix:c},m);const p=this._hitTarget;p!=a&&(t.Utils.isNull(a)||(a instanceof Element&&a.dispatchEvent(new t.Drawing.DrawableEvent("out",a,this._scopeEvent,c)),e.dispatchEvent(new t.Drawing.DrawableEvent("itemout",a,this._scopeEvent,c))),t.Utils.isNull(p)||(p instanceof Element&&p.dispatchEvent(new t.Drawing.DrawableEvent("over",p,this._scopeEvent,c)),e.dispatchEvent(new t.Drawing.DrawableEvent("itemover",p,this._scopeEvent,c))))}}_draw(e,r,n,s,o){if(n.stage??=e,t.Drawing.isDrawable(n)&&n.hide)return;let l;t.Drawing.isUiObject(n)&&n.draggable&&!n.hide&&!n.inert&&a(n,i,r.getTransform().inverse()),t.Drawing.isUiObject(n)&&(l=n.transformMatrix,t.Utils.isNull(l)||t.Matrix2D.isIdentity(l)||r.transform(l.a,l.b,l.c,l.d,l.e,l.f));let c=s;if(t.Drawing.isPresentationObject(n)&&(c=t.Drawing.PresentationState.combine(n,s,r.getTransform()),this._setPresentationState(r,c)),t.Drawing.isShape(n)||n instanceof t.Components.Drawing.ShapeElement)this._drawShape(r,n,o);else if(t.Drawing.isText(n)||n instanceof t.Components.Drawing.PacemTextElement)this._drawText(r,n,o);else if(t.Drawing.isImage(n)||n instanceof t.Components.Drawing.PacemImageElement)this._drawImage(r,n,o);else if(t.Drawing.isGroup(n)||n instanceof t.Components.Drawing.PacemGroupElement)for(let t of n.childDrawables||[])this._draw(e,r,t,c,o);t.Drawing.isUiObject(n)&&n.draggable&&!n.hide&&!n.inert&&a(n,"pacem:2d-world-matrix",r.getTransform().inverse()),this._setPresentationState(r,s)}_setPresentationState(e,r){if(e.setTransform(r.transformMatrix),t.Utils.isNullOrEmpty(r.stroke)||s(r.stroke)?e.strokeStyle="transparent":e.strokeStyle=r.stroke,t.Utils.isNullOrEmpty(r.lineWidth)?e.lineWidth=0:e.lineWidth=r.lineWidth,t.Utils.isNullOrEmpty(r.dashArray)?e.setLineDash([]):e.setLineDash(r.dashArray),t.Utils.isNullOrEmpty(r.lineCap)?e.lineCap="butt":e.lineCap=r.lineCap,t.Utils.isNullOrEmpty(r.lineJoin)?e.lineJoin="miter":e.lineJoin=r.lineJoin,"object"!=typeof r.fill||t.Utils.isNullOrEmpty(r.fill))t.Utils.isNullOrEmpty(r.fill)||"string"!=typeof r.fill||s(r.fill)?e.fillStyle="transparent":e.fillStyle=r.fill;else{const{stops:i}=r.fill;let a;if(t.Drawing.isLinearGradient(r.fill)){const{start:t,end:i}=r.fill;a=e.createLinearGradient(t.x,t.y,i.x,i.y)}else{if(!t.Drawing.isRadialGradient(r.fill))throw new Error("Unmanaged gradient type.");{const{center:t,radius:i}=r.fill;a=e.createRadialGradient(t.x,t.y,i,t.x,t.y,i)}}for(let t of i)a.addColorStop(t.offset,t.color);e.fillStyle=a}t.Utils.isNullOrEmpty(r.opacity)?e.globalAlpha=1:e.globalAlpha=r.opacity}_drawImage(e,r,i){const s="pacem:2d-canvas-imagesrc";let l=n(r,s);const c=()=>{let a=l.naturalWidth,n=l.naturalHeight,s=r.width,c=r.height;if(s>0&&c>0||(s>0?c=n*s/a:c>0?s=a*c/n:(s=a,c=n)),!this._dragging&&!r.inert&&!t.Utils.isNull(i)){const t=new Path2D(`M ${r.x} ${r.y} h ${s} v ${c} H ${r.x} Z`);e.isPointInPath(t,i.x,i.y)&&(this._hitTarget=r)}e.globalAlpha=o(r.opacity,1),e.drawImage(l,r.x,r.y,s,c)};t.Utils.isNull(l)?(l=new Image,l.src=r.src,l.onload=()=>{a(r,s,l),c()}):c()}_drawText(e,r,i){const a=this.DefaultShapeValues,n=e.fillStyle=o(r.color,a.stroke),l=(e.getTransform(),r.fontSize>0?`${r.fontSize}px`:this.#s.fontSize),c=r.fontStyle||this.#s.fontStyle,h=r.fontWeight||this.#s.fontWeight;e.font=`${c} ${h} ${l} ${r.fontFamily??this.#s.fontFamily}`,e.textAlign="middle"===r.textAnchor?"center":r.textAnchor,e.fillText(r.text,r.anchor.x,r.anchor.y),e.globalAlpha=o(r.opacity,1);const d=!s(n);if(!this._dragging&&!r.inert&&!t.Utils.isNull(i)){const t=e.measureText(r.text),a=t.width,n=t.actualBoundingBoxAscent+t.actualBoundingBoxDescent,s=r.anchor.x-t.actualBoundingBoxLeft,o=r.anchor.y-t.actualBoundingBoxAscent,l=new Path2D(`M ${s} ${o} h ${a} v ${n} H ${s} z`);d&&e.isPointInPath(l,i.x,i.y)&&(this._hitTarget=r)}}_drawShape(e,r,i){if(t.Utils.isNullOrEmpty(r?.pathData))return;e.beginPath();const a="string"!=typeof e.fillStyle||!s(e.fillStyle),n="string"!=typeof e.strokeStyle||!s(e.strokeStyle);var o=new Path2D(r.pathData);this._dragging||r.inert||t.Utils.isNull(i)||(a&&e.isPointInPath(o,i.x,i.y)||n&&e.isPointInStroke(o,i.x,i.y))&&(this._hitTarget=r),n&&e.stroke(o),a&&e.fill(o);const l=!t.Utils.isNullOrEmpty(r.vertices)&&r.vertices.length>1,c=!t.Utils.isNull(r.markerEnd),h=!t.Utils.isNull(r.markerStart),d=!t.Utils.isNull(r.markerMid);if((c||d||h)&&(l||this.log(t.Logging.LogLevel.Warn,"Not enough vertices were explicited in order to make markers renderable.")),l){const t=e.getTransform();if(h){const t=r.markerEnd,i=r.vertices[1],a=r.vertices[0],n=Math.atan2(a.y-i.y,a.x-i.x);this._drawMarker(e,t,a,n)}if(d){const i=r.markerEnd;for(let a=1;a<r.vertices.length-1;a++){e.setTransform(t);const n=r.vertices[a],s=r.vertices[a+1],o=Math.atan2(s.y-n.y,s.x-n.x);this._drawMarker(e,i,s,o)}}if(c){e.setTransform(t);const i=r.markerEnd,a=r.vertices[r.vertices.length-2],n=r.vertices[r.vertices.length-1],s=Math.atan2(n.y-a.y,n.x-a.x);this._drawMarker(e,i,n,s)}}}_drawMarker(e,r,i,a){const n=this.DefaultShapeValues,l=r.ref?.x||0,c=r.ref?.y||0,h=(r.width||1)*e.lineWidth,d=(r.width||1)*e.lineWidth;let m=r.viewbox,p={x:0,y:0,width:h,height:d};t.Utils.isNull(m)&&(m=p);const u={a:p.width/m.width,d:p.height/m.height};e.translate(i.x,i.y),e.rotate(a),e.scale(u.a,u.d),e.translate(-l,-c),e.fillStyle=o(r.fill,n.fill),e.strokeStyle=o(r.stroke,n.stroke);const g=!s(r.fill),v=!s(r.stroke);var y=new Path2D(r.pathData);g&&e.fill(y),v&&e.stroke(y)}};l=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-canvas-adapter"})],l),e.PacemCanvasAdapterElement=l}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){const r="http://www.w3.org/2000/svg",i="pacem:2-svg-drawable",a="pacem:2d-svg-stage",n=t.CustomElementUtils.getAttachedPropertyValue,s=t.CustomElementUtils.setAttachedPropertyValue,o=t.CustomElementUtils.deleteAttachedPropertyValue;function l(e,r){return t.Utils.isNull(e)?r:e}function c(t,e,r){return r>=t.children.length?(t.appendChild(e),null):t.replaceChild(e,t.children.item(r))}let h=class PacemSvgAdapterElement extends e.Pacem2DAdapterElement{constructor(){super(...arguments),this._hitTarget=null,this._dragInitHandler=r=>{const a=r.detail,s=a.element,o=n(s,i),l=o.stage.transformMatrix,c=o.transformMatrix??t.Matrix2D.identity;a.data={stageTransformMatrix:l,item:o,initialTransformMatrix:c};e.AdapterUtils.itemDispatch(o,r,{x:0,y:0})&&r.preventDefault()},this._draggingHandler=r=>{t.avoidHandler(r),this._dragging=!0;const i=r.detail.element,a=r.detail.data,n=r.detail,s=(n.currentPosition.x-n.origin.x)*a.stageTransformMatrix.a,o=(n.currentPosition.y-n.origin.y)*a.stageTransformMatrix.d,l=s+a.initialTransformMatrix.e,c=o+a.initialTransformMatrix.f,h={x:s+a.stageTransformMatrix.e,y:o+a.stageTransformMatrix.f};if(!e.AdapterUtils.itemDispatch(a.item,r,h)){const t=a.initialTransformMatrix;i.style.transform=`matrix(${t.a},${t.b},${t.c},${t.d},${l},${c})`}},this._dragEndHandler=r=>{this._dragging=!1;const i=r.detail,a=i.element,n=i.data,s=t.Utils.deserializeTransform(a.style),o={x:s.e,y:s.f};if(n.item instanceof t.Components.Drawing.UiElement)n.item.translateX=o.x,n.item.translateY=o.y;else{const e=n.initialTransformMatrix,r={a:e.a,b:e.b,c:e.c,d:e.d,e:o.x,f:o.y};t.Utils.extend(n.item,{transformMatrix:r})}a.style.transform="",e.AdapterUtils.itemDispatch(n.item,r,o)},this._mousemoveHandler=r=>{var s=t.CustomEventUtils.getEventCoordinates(r).client;if(!this._dragging){var o=null;r.target.getRootNode().elementsFromPoint(s.x,s.y).find(t=>(o=n(t,i))&&!o.inert);var l=this._hitTarget,c=o;(t.Utils.isNull(o&&o.stage)||!this._scenes.has(o.stage)||o.inert)&&(c=null);const h=this._hitTarget=c;if(c!==l&&(t.Utils.isNull(l)||(this._dragger.unregister(this._items.get(l)),e.AdapterUtils.itemDispatch(l,"out",r)),t.Utils.isNull(c)||(c.draggable&&this._dragger.register(this._items.get(c)),e.AdapterUtils.itemDispatch(c,"over",r))),t.Utils.isNull(h)){const i=r.currentTarget,s=n(i,a);t.Utils.isNull(s)||e.AdapterUtils.stageDispatch(s,"move",r)}}},this._mouseDownUpHandler=r=>{const i=r.currentTarget;if(i instanceof SVGSVGElement){const s=n(i,a),o=this._hitTarget,l=r.type.replace(/^mouse/,"");t.Utils.isNull(o)||o.stage!==s?e.AdapterUtils.stageDispatch(s,l,r):e.AdapterUtils.itemDispatch(this._hitTarget,l,r)}},this._scenes=new WeakMap,this._markers=new WeakMap,this._gradients=new WeakMap,this._items=new WeakMap}snapshot(t,e,r,i){if(this._scenes.has(t)){const a=this._scenes.get(t);return this.snapshotElement(a,e,r,i)}return Promise.resolve(null)}getTransformMatrix(e){const r=this._scenes;return r.has(e)?r.get(e).getScreenCTM().inverse():t.Matrix2D.identity}viewActivatedCallback(){super.viewActivatedCallback();const e=this._dragger=document.createElement(t.P+"-drag-drop");e.mode=t.UI.DragDataMode.Self;t.CustomElementUtils.findAncestorShell(this).appendChild(e),e.addEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(t.UI.DragDropEventType.Drag,this._draggingHandler,!1),e.addEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1)}disconnectedCallback(){const e=this._dragger;t.Utils.isNull(e)||(e.removeEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Drag,this._draggingHandler,!1),e.removeEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.remove()),super.disconnectedCallback()}invalidateSize(r,i){const a=this._scenes;if(!t.Utils.isNull(r)&&!t.Utils.isNullOrEmpty(i)&&a.has(r)){var n=a.get(r);n.setAttribute("width",i.width+""),n.setAttribute("height",i.height+"");const s=r.viewbox,o=r.aspectRatio;e.AdapterUtils.isValidViewbox(s)?n.setAttribute("viewBox",`${s.x} ${s.y} ${s.width} ${s.height}`):n.removeAttribute("viewBox"),t.Utils.isNullOrEmpty(o)||"string"==typeof o?n.removeAttribute("preserveAspectRatio"):n.setAttribute("preserveAspectRatio",`xM${o.x.substring(1)}YM${o.y.substring(1)} ${o.slice?"slice":"meet"}`)}}initialize(e){if(t.Utils.isNull(e))throw"Provided scene is null or undefined.";const i=this._scenes;if(i.has(e))return i.get(e);const n=e.stage;n.innerHTML="",this._items=new WeakMap;var o=document.createElementNS(r,"svg");o.setAttribute("part","stage"),s(o,a,e),n.appendChild(o),i.set(e,o);return o.addEventListener("mousemove",this._mousemoveHandler,!1),o.addEventListener("click",this._mouseDownUpHandler,!1),o.addEventListener("mousedown",this._mouseDownUpHandler,!1),o.addEventListener("mouseup",this._mouseDownUpHandler,!1),o}dispose(t){const e=this._scenes;if(e.has(t)){var r=e.get(t);r.removeEventListener("mousemove",this._mousemoveHandler),r.removeEventListener("click",this._mouseDownUpHandler),r.removeEventListener("mousedown",this._mouseDownUpHandler),r.removeEventListener("mouseup",this._mouseDownUpHandler),o(r,a),r.remove(),e.delete(t)}}getHitTarget(t){return this._hitTarget}draw(e,r,i=!1){const a=this._scenes,n=this._items;if(!t.Utils.isNull(e))if(e.adapter===this){a.has(e)||this.initialize(e);var s=e.datasource,o=!0,l=a.get(e);!t.Utils.isNull(r)&&n.has(r)&&(s=[r],l=n.get(r).parentNode,o=!1),o&&(l.innerHTML="<defs></defs>",this._markers=new WeakMap),this._draw(e,l,s||[],o,i)}else a.has(e)&&a.delete(e)}_hasItems(e){return t.Drawing.isGroup(e)}_disposeSvg(e){if(!t.Utils.isNull(e)){var r=n(e,i);o(e,i),this._items.delete(r)}}_draw(e,r,a,n,o){const h=this._items;let d=0;if(r.firstElementChild instanceof SVGDefsElement&&d++,!t.Utils.isNullOrEmpty(a))for(let m of a){let a;if(m.stage??=e,h.has(m)?(a=h.get(m),a.parentNode!==r&&this._disposeSvg(c(r,a,d))):(a=this._buildSVGElement(m),s(a,i,m),this._disposeSvg(c(r,a,d)),h.set(m,a)),t.Drawing.isDrawable(m)&&(m.hide?a.setAttribute("display","none"):a.removeAttribute("display"),a.style.transform=""),t.Drawing.isShape(m)){const t=a;t.setAttribute("d",l(m.pathData,"M0,0"));for(let{marker:e,suffix:i}of[{marker:m.markerStart,suffix:"start"},{marker:m.markerEnd,suffix:"end"},{marker:m.markerMid,suffix:"mid"}])if(e){const a=this._ensureMarker(r,e);t.setAttribute("marker-"+i,`url(#${a.id})`)}else t.removeAttribute("marker-"+i)}else if(t.Drawing.isText(m)){const e=a;e.textContent=m.text,e.style.fill=t.Utils.isNullOrEmpty(m.color)?"":m.color,e.style.fontFamily=t.Utils.isNullOrEmpty(m.fontFamily)?"":m.fontFamily,e.style.fontSize=t.Utils.isNull(m.fontSize)?"":m.fontSize+"px",t.Utils.isNullOrEmpty(m.fontWeight)||(e.style.fontWeight=m.fontWeight),t.Utils.isNullOrEmpty(m.fontStyle)||(e.style.fontStyle=m.fontStyle),e.setAttribute("text-anchor",l(m.textAnchor,"start")),t.Utils.isNull(m.anchor)?(e.removeAttribute("x"),e.removeAttribute("y")):(e.setAttribute("x",m.anchor.x.toString()),e.setAttribute("y",m.anchor.y.toString()))}else if(t.Drawing.isImage(m)){const e=a;e.setAttribute("href",m.src),e.setAttribute("preserveAspectRatio","none"),m.width>0?e.setAttribute("width",""+m.width):e.removeAttribute("width"),m.height>0?e.setAttribute("height",""+m.height):e.removeAttribute("height"),t.Utils.isNull(m.x)?e.removeAttribute("x"):e.setAttribute("x",""+m.x),t.Utils.isNull(m.y)?e.removeAttribute("y"):e.setAttribute("y",""+m.y)}if(t.Drawing.isUiObject(m)){const e=m.transformMatrix;t.Utils.isNull(e)||t.Matrix2D.isIdentity(e)?a.removeAttribute("transform"):a.setAttribute("transform",`matrix(${e.a} ${e.b} ${e.c} ${e.d} ${e.e} ${e.f})`);const r=l(m.opacity,1);1===r?a.removeAttribute("opacity"):a.setAttribute("opacity",""+r)}if(t.Drawing.isPresentationObject(m)){if(t.Utils.isNullOrEmpty(m.fill))a.removeAttribute("fill");else if("string"==typeof m.fill)a.setAttribute("fill",m.fill);else{const t=this._ensureGradient(r,m.fill);a.setAttribute("fill",`url(#${t.id})`)}t.Utils.isNullOrEmpty(m.stroke)?a.removeAttribute("stroke"):a.setAttribute("stroke",m.stroke),t.Utils.isNullOrEmpty(m.dashArray)?a.removeAttribute("stroke-dasharray"):a.setAttribute("stroke-dasharray",m.dashArray.join(" ")),t.Utils.isNullOrEmpty(m.lineCap)?a.removeAttribute("stroke-linecap"):a.setAttribute("stroke-linecap",m.lineCap),t.Utils.isNullOrEmpty(m.lineJoin)?a.removeAttribute("stroke-linejoin"):a.setAttribute("stroke-linejoin",m.lineJoin),t.Utils.isNullOrEmpty(m.lineWidth)?a.removeAttribute("stroke-width"):a.setAttribute("stroke-width",""+m.lineWidth)}m.inert?a.style.pointerEvents="none":a.style.pointerEvents="",(n||o)&&this._hasItems(m)&&this._draw(e,a,m.childDrawables,!0,o),d++}if(n)for(let t=r.children.length-1;t>=d;t--){const e=r.children.item(t);this._disposeSvg(e),e.remove()}}_buildSVGElement(e){return t.Drawing.isShape(e)||e instanceof t.Components.Drawing.ShapeElement?document.createElementNS(r,"path"):t.Drawing.isText(e)||e instanceof t.Components.Drawing.PacemTextElement?document.createElementNS(r,"text"):t.Drawing.isImage(e)||e instanceof t.Components.Drawing.PacemImageElement?document.createElementNS(r,"image"):document.createElementNS(r,"g")}_ensureGradient(e,i){const a=this._gradients;a.has(e)||a.set(e,new WeakMap);const n=a.get(e),s=t.Drawing.isLinearGradient(i),o=t.Drawing.isRadialGradient(i);if(n.has(i)){const t=n.get(i);(s&&t instanceof SVGLinearGradientElement||o&&t instanceof SVGRadialGradientElement)&&(t.remove(),n.delete(i))}if(!n.has(i)){let a,o=e;for(;t.Utils.isNull(a=o.querySelector(":scope > defs"));){const t=o.parentElement;if(!(t instanceof SVGElement))break;o=t}if(t.Utils.isNull(a))throw new Error("Must provide a <defs> element.");var l=null;if(s)l=document.createElementNS(r,"linearGradient");else{if(!t.Drawing.isRadialGradient(i))throw new Error("Unmanaged gradient type.");l=document.createElementNS(r,"radialGradient")}l.setAttribute("gradientUnits","userSpaceOnUse"),l.setAttribute("id",`grad-${t.Utils.uniqueCode()}`),a.appendChild(l),n.set(i,l)}const c=n.get(i);s?(c.setAttribute("x1",i.start.x.toString()),c.setAttribute("y1",i.start.y.toString()),c.setAttribute("x2",i.end.x.toString()),c.setAttribute("y2",i.end.y.toString())):o&&(c.setAttribute("cx",i.center.x.toString()),c.setAttribute("cy",i.center.y.toString()),c.setAttribute("r",i.radius.toString()));let h=0;for(let e of i.stops){for(;c.children.length<=h;){const t=document.createElementNS(r,"stop");c.appendChild(t)}const i=c.children.item(h);i.setAttribute("offset",100*e.offset+"%"),i.setAttribute("stop-color",e.color),t.Utils.isNull(e.opacity)||i.setAttribute("stop-opacity",e.opacity.toString()),h++}for(;c.children.length>i.stops.length;){const t=c.children.item(c.children.length-1);c.removeChild(t)}return c}_ensureMarker(e,i){const a=this._markers;a.has(e)||a.set(e,new WeakMap);const n=a.get(e);if(!n.has(i)){const a=document.createElementNS(r,"marker");n.set(i,a);const s=document.createElementNS(r,"path");a.appendChild(s),a.setAttribute("id","mark"+t.Utils.uniqueCode());let o,l=e;for(;t.Utils.isNull(o=l.querySelector(":scope > defs"));){const t=l.parentElement;if(!(t instanceof SVGElement))break;l=t}if(t.Utils.isNull(o))throw new Error("Must provide a <defs> element.");o.appendChild(a)}const s=n.get(i),o=s.firstElementChild;return s.setAttribute("orient","auto-start-reverse"),t.Utils.isNullOrEmpty(i.viewbox)?s.removeAttribute("viewBox"):s.setAttribute("viewBox",`${i.viewbox.x} ${i.viewbox.y} ${i.viewbox.width} ${i.viewbox.height}`),t.Utils.isNullOrEmpty(i.ref)?(s.removeAttribute("refX"),s.removeAttribute("refY")):(s.setAttribute("refX",i.ref.x.toString()),s.setAttribute("refY",i.ref.y.toString())),i.height>0?s.setAttribute("markerHeight",i.height.toString()):s.removeAttribute("markerHeight"),i.width>0?s.setAttribute("markerWidth",i.width.toString()):s.removeAttribute("markerWidth"),o.setAttribute("d",i.pathData),t.Utils.isNullOrEmpty(i.fill)?o.removeAttribute("fill"):o.setAttribute("fill",i.fill),t.Utils.isNullOrEmpty(i.stroke)?o.removeAttribute("stroke"):o.setAttribute("stroke",i.stroke),s}};h=__decorate([t.CustomElement({tagName:t.P+"-"+e.TAG_MIDDLE_NAME+"-svg-adapter"})],h),e.PacemSvgAdapterElement=h}(e.Drawing||(e.Drawing={}))}(t.Components||(t.Components={}))}(Pacem||(Pacem={}));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -55,6 +55,8 @@ declare namespace Pacem.Geometry {
55
55
  static inPolygon(p: Point, vertices: Point[], precision: number): any;
56
56
  static area(points: Point[]): number;
57
57
  static area(...points: Point[]): number;
58
+ static convexHull(...points: Point[]): Point[];
59
+ static convexHull(points: Point[]): Point[];
58
60
  }
59
61
  }
60
62
  declare namespace Pacem.Geometry.LinearAlgebra {
@@ -190,6 +192,7 @@ declare namespace Pacem.Geometry {
190
192
  static isCounterClockwise(polygon: Polygon): boolean;
191
193
  static expand(polygon: Polygon, offset: number): Polygon;
192
194
  static area(polygon: Polygon): number;
195
+ static convexHull(polygon: Polygon): Polygon;
193
196
  }
194
197
  }
195
198
  declare namespace Pacem.Mathematics {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -313,6 +313,48 @@ var Pacem;
313
313
  }
314
314
  return Math.abs(retval.roundoff());
315
315
  }
316
+ static convexHull(point, ...points) {
317
+ const pts = [].concat(point).concat(points);
318
+ if (!(pts?.length > 1)) {
319
+ return pts?.slice() ?? [];
320
+ }
321
+ const sorted = pts
322
+ .map(p => ({ x: p.x, y: p.y }))
323
+ .sort((a, b) => a.x === b.x ? a.y - b.y : a.x - b.x);
324
+ const unique = [];
325
+ for (const p of sorted) {
326
+ const last = unique[unique.length - 1];
327
+ if (!last || last.x !== p.x || last.y !== p.y) {
328
+ unique.push(p);
329
+ }
330
+ }
331
+ if (unique.length <= 2) {
332
+ return unique;
333
+ }
334
+ const cross = (o, a, b) => {
335
+ return (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
336
+ };
337
+ const lower = [];
338
+ for (const p of unique) {
339
+ while (lower.length >= 2
340
+ && cross(lower[lower.length - 2], lower[lower.length - 1], p) <= 0) {
341
+ lower.pop();
342
+ }
343
+ lower.push(p);
344
+ }
345
+ const upper = [];
346
+ for (let j = unique.length - 1; j >= 0; j--) {
347
+ const p = unique[j];
348
+ while (upper.length >= 2
349
+ && cross(upper[upper.length - 2], upper[upper.length - 1], p) <= 0) {
350
+ upper.pop();
351
+ }
352
+ upper.push(p);
353
+ }
354
+ lower.pop();
355
+ upper.pop();
356
+ return lower.concat(upper);
357
+ }
316
358
  }
317
359
  Geometry.Utils = Utils;
318
360
  })(Geometry = Pacem.Geometry || (Pacem.Geometry = {}));
@@ -1025,6 +1067,10 @@ var Pacem;
1025
1067
  static area(polygon) {
1026
1068
  return Geometry.Utils.area(polygon.vertices);
1027
1069
  }
1070
+ static convexHull(polygon) {
1071
+ const vertices = Geometry.Utils.convexHull(polygon.vertices);
1072
+ return { vertices };
1073
+ }
1028
1074
  }
1029
1075
  Geometry.Polygon = Polygon;
1030
1076
  })(Geometry = Pacem.Geometry || (Pacem.Geometry = {}));
@@ -1,6 +1,6 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
6
- var Pacem;!function(t){!function(e){!function(e){class Vector{static unit(t){const e={x:t.x,y:t.y};return this.normalize(e),e}static magSqr(t){return t.x*t.x+t.y*t.y}static mag(t){return Math.sqrt(Vector.magSqr(t))}static normalize(t){const e=Vector.mag(t);if(e<=0)throw"Cannot normalize a vector of length 0.";const r=1/e;t.x*=r,t.y*=r}static from(e,r){return t.Point.subtract(e,r)}static dot(t,e){return t.x*e.x+t.y*e.y}static cross(t,e){return t.x*e.y-t.y*e.x}static areClose(t,e){return(e.x-t.x).isCloseTo(0)&&(e.y-t.y).isCloseTo(0)}}e.Vector=Vector}(e.LinearAlgebra||(e.LinearAlgebra={}))}(t.Geometry||(t.Geometry={}))}(Pacem||(Pacem={})),function(t){!function(e){const r=180/Math.PI,n=2*Math.PI,s=e.LinearAlgebra.Vector;function a(e){return t.Point.isPoint(e)}e.Utils=class Utils{static slopeRad(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}static slopeRad2(t,e){return(n+this.slopeRad(t,e))%n}static slopeDeg(t,e){return this.slopeRad(t,e)*r}static slopeDeg2(t,e){return(360+this.slopeDeg(t,e))%360}static intersect(t,e,...r){return Array.isArray(t)&&Array.isArray(e)?this._intersectSegments(t,e,!0):this._intersectRects.apply(this,arguments)}static intersectLines(t,e,r,n){let s,a;if(Array.isArray(t)&&Array.isArray(e)&&2===t.length&&2===e.length&&"number"==typeof t[0]&&"number"==typeof e[0]&&"number"==typeof t[1]&&"number"==typeof e[1]&&(r=e[0],n=e[1],e=t[1],t=t[0]),"number"==typeof t&&"number"==typeof e){s=[{x:0,y:e},{x:1,y:t+e}],a=[{x:0,y:n},{x:1,y:r+n}]}else s=t,a=e;return this._intersectSegments(s,a,!1)}static cramer(t,e){Array.isArray(t)&&(t={a:t[0],b:t[1],c:t[2]}),Array.isArray(e)&&(e={a:e[0],b:e[1],c:e[2]});let r=(t.b*e.c-t.c*e.b)/(t.b*e.a-t.a*e.b),n=(t.c*e.a-t.a*e.c)/(t.b*e.a-t.a*e.b);return{x:-r.roundoff(),y:-n.roundoff()}}static mq(t,e){let r;if(a(t)?r=t:(r=t[0],e=t[1]),r.x===e.x)return[Number.NaN,Number.NaN];const n=(e.y-r.y)/(e.x-r.x);return[n,r.y-n*r.x]}static _intersectSegments(t,e,r){const n=t[0],s=t[1],a=e[0],o=e[1],m=Math.min(n.x,s.x),i=Math.min(n.y,s.y),c=Math.max(n.x,s.x),f=c-m,u=Math.max(n.y,s.y),l=u-i,h=Math.min(a.x,o.x),y=Math.min(a.y,o.y),x=Math.max(a.x,o.x),g=x-h,M=Math.max(a.y,o.y),p=M-y;if(0===f&&0===g)return null;if(0===l&&0===p)return null;const d=t=>t.x<h||t.x>x||t.x<m||t.x>c,b=t=>t.y<y||t.y>M||t.y<i||t.y>u;var z=null;if(0===f){if(r&&(h>m||x<c))return null;const t=this.mq(a,o);z=this.cramer([1,0,-m],[t[0],-1,t[1]]),r&&b(z)&&(z=null)}else if(0===g){if(r&&(m>h||c<x))return null;const t=this.mq(n,s);z=this.cramer([t[0],-1,t[1]],[1,0,-h]),r&&b(z)&&(z=null)}else if(0===l){if(r&&(y>i||M<u))return null;const t=this.mq(a,o);z=this.cramer([0,1,-i],[t[0],-1,t[1]]),r&&d(z)&&(z=null)}else if(0===p){if(r&&(i>y||u<M))return null;const t=this.mq(n,s);z=this.cramer([t[0],-1,t[1]],[0,1,-y]),r&&d(z)&&(z=null)}else{let t;if(!r||(t=this._intersectRects({x:m,y:i,width:f,height:l},{x:h,y:y,width:g,height:p}))&&t.width>0&&t.height>0){const e=this.mq(n,s),m=this.mq(a,o),i=e[0],c=m[0],f=e[1],u=m[1];if(i!==c){let e=(z=this.cramer([i,-1,f],[c,-1,u])).x,n=z.y;r&&(e<t.x||e>t.x+t.width||n<t.y||n>t.y+t.height)&&(z=null)}}}return null===z?null:{x:z.x,y:z.y}}static _intersectRects(...e){return t.Rect.intersect.apply(this,e)}static dot(t,e){return s.dot(t,e)}static cross(t,e){return s.cross(t,e)}static distance(e,r){if(null!=(n=e)&&Array.isArray(n)&&2===n.length&&a(n[0])&&a(n[1]))return t.Point.distance(e[0],e[1]);if(a(r))return t.Point.distance(e,r);{const t=r[0],n=r[1];return Math.abs(t*e.x-e.y+n)/Math.sqrt(Math.pow(t,2)+1)}var n}static inLine(t,e){const r=s.from(e[0],t),n=s.from(t,e[1]);return this.cross(r,n).isCloseTo(0)}static inSegment(t,e){const r=Math.min(e[0].x,e[1].x),n=Math.max(e[0].x,e[1].x),s=Math.min(e[0].y,e[1].y),a=Math.max(e[0].y,e[1].y);return t.x>=r&&t.x<=n&&t.y>=s&&t.y<=a&&this.inLine(t,e)}static inTriangle(e,r){let n;for(let s=0;s<3;s++){const a=r[s],o=r[(s+1)%3],m=t.Point.subtract(o,e),i=t.Point.subtract(a,e),c=this.cross(m,i);if(s>0&&c*n<=0)return!1;n=c}return!0}static inPolygon(t,e,r){if(!(e?.length>=3))throw"Not enough vertices";const n=e.length;if(3===n)return this.inTriangle(t,[e[0],e[1],e[2]]);r>0&&(e=e.map(t=>({x:t.x.roundoff(r),y:t.y.roundoff(r)})),t={x:t.x.roundoff(r),y:t.y.roundoff(r)});let s=Number.MAX_VALUE,a=Number.MAX_VALUE,o=Number.MIN_VALUE,m=Number.MIN_VALUE;for(let t=0;t<n;t++){const r=e[t];s=Math.min(s,r.x),a=Math.min(a,r.y),o=Math.max(o,r.x),m=Math.max(m,r.y)}if(t.x<s||t.x>o||t.y<a||t.y>m)return!1;const i=[{x:s-1,y:t.y},t];let c=0;for(let r=0;r<n;r++){const s=e[r],a=e[(r+1)%n],o=[s,a];if(s.y===t.y){const o=e[(r-1+n)%n];t.x>s.x&&(o.y-t.y)*(a.y-t.y)<0&&c++}else{if(a.y===t.y)continue;null!=this.intersect(o,i)&&c++}}return c%2==1}static area(t,...e){const r=[].concat(t).concat(e);let n=0;const s=r.length;if(s>=3){for(let t=0;t<r.length;t++){const{x:e,y:a}=r[t],o=t===s-1?0:t+1,{x:m,y:i}=r[o];n+=e*i-a*m}n*=.5}return Math.abs(n.roundoff())}}}(t.Geometry||(t.Geometry={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){const r=180/Math.PI,n=1/r;class Vector3D{static from(...t){if(3!==t.length)throw new RangeError("Must provide exactly 3 numbers");return{x:t[0],y:t[1],z:t[2]}}static parse(e){const r=t.parseAsNumericalArray(e);if(r&&3===r.length)return Vector3D.from.apply(null,r);throw new Error(`Cannot parse "${e}" as a valid Vector3D.`)}static i(){return{x:1,y:0,z:0}}static j(){return{x:0,y:1,z:0}}static k(){return{x:0,y:0,z:1}}static zero(){return{x:0,y:0,z:0}}static subtract(t,e){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static add(...t){var e={x:0,y:0,z:0};for(var r of t)e.x+=r.x,e.y+=r.y,e.z+=r.z;return e}static dot(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static scale(t,e,r=e,n=e){return{x:t.x*e,y:t.y*r,z:t.z*n}}static magSqr(t){return t.x*t.x+t.y*t.y+t.z*t.z}static areClose(t,e){return(e.x-t.x).isCloseTo(0)&&(e.y-t.y).isCloseTo(0)&&(e.z-t.z).isCloseTo(0)}static mag(t){return Math.sqrt(Vector3D.magSqr(t))}static negate(t){return{x:-t.x,y:-t.y,z:-t.z}}static unit(t){const e={x:t.x,y:t.y,z:t.z};return this.normalize(e),e}static normalize(t){const e=Vector3D.mag(t);if(e<=0)throw"Cannot normalize a vector of length 0.";const r=1/e;t.x*=r,t.y*=r,t.z*=r}static angleBetween(t,e){let n;const s=Vector3D.unit(t),a=Vector3D.unit(e);if(Vector3D.dot(s,a)<0){const t={x:-s.x-a.x,y:-s.y-a.y,z:-s.z-a.z},e=Vector3D.mag(t);n=Math.PI-2*Math.asin(e/2)}else{const t={x:s.x-a.x,y:s.y-a.y,z:s.z-a.z},e=Vector3D.mag(t);n=2*Math.asin(e/2)}return r*n}}e.Vector3D=Vector3D;class Spherical{static from(t,e,r){return{rho:t.clamp(0,1/0),theta:e.clamp(-180,180),phi:r.clamp(0,360)}}static fromVector(t,e,n){"number"==typeof t&&(t=Vector3D.from(t,e,n));const s=Vector3D.mag(t);if(s.isCloseTo(0))return Spherical.from(0,0,0);const a=Math.atan2(t.x,t.z),o=Math.acos((t.y/s).clamp(-1,1));return Spherical.from(s,a*r,o*r)}static toVector(t){const{rho:e,theta:r,phi:s}=t,a=s*n,o=r*n,m=Math.sin(a)*e;return{x:m*Math.sin(o),y:Math.cos(a)*e,z:m*Math.cos(o)}}static toRotationMatrix(t){const{theta:e,phi:r}=t,s=n*e,a=Math.sin(s),o=Math.cos(s),m=n*r,i=Math.sin(m),c=Math.cos(m);return Matrix3D.from(a*c,a*i,o,0,o*c,o*i,-a,0,-i,c,0,0,0,0,0,1)}}e.Spherical=Spherical;class Matrix3DUtils{static modify(t,e){const{m11:r,m12:n,m13:s,m14:a,m21:o,m22:m,m23:i,m24:c,m31:f,m32:u,m33:l,m34:h,offsetX:y,offsetY:x,offsetZ:g,m44:M}=t,p={m11:r,m12:n,m13:s,m14:a,m21:o,m22:m,m23:i,m24:c,m31:f,m32:u,m33:l,m34:h,offsetX:y,offsetY:x,offsetZ:g,m44:M};return e(p),p}static clone(t){return Matrix3DUtils.modify(t,t=>{})}static multiply(t,e){return Matrix3D.isIdentity(t)?e:Matrix3D.isIdentity(e)?t:Matrix3D.from(t.m11*e.m11+t.m12*e.m21+t.m13*e.m31+t.m14*e.offsetX,t.m11*e.m12+t.m12*e.m22+t.m13*e.m32+t.m14*e.offsetY,t.m11*e.m13+t.m12*e.m23+t.m13*e.m33+t.m14*e.offsetZ,t.m11*e.m14+t.m12*e.m24+t.m13*e.m34+t.m14*e.m44,t.m21*e.m11+t.m22*e.m21+t.m23*e.m31+t.m24*e.offsetX,t.m21*e.m12+t.m22*e.m22+t.m23*e.m32+t.m24*e.offsetY,t.m21*e.m13+t.m22*e.m23+t.m23*e.m33+t.m24*e.offsetZ,t.m21*e.m14+t.m22*e.m24+t.m23*e.m34+t.m24*e.m44,t.m31*e.m11+t.m32*e.m21+t.m33*e.m31+t.m34*e.offsetX,t.m31*e.m12+t.m32*e.m22+t.m33*e.m32+t.m34*e.offsetY,t.m31*e.m13+t.m32*e.m23+t.m33*e.m33+t.m34*e.offsetZ,t.m31*e.m14+t.m32*e.m24+t.m33*e.m34+t.m34*e.m44,t.offsetX*e.m11+t.offsetY*e.m21+t.offsetZ*e.m31+t.m44*e.offsetX,t.offsetX*e.m12+t.offsetY*e.m22+t.offsetZ*e.m32+t.m44*e.offsetY,t.offsetX*e.m13+t.offsetY*e.m23+t.offsetZ*e.m33+t.m44*e.offsetZ,t.offsetX*e.m14+t.offsetY*e.m24+t.offsetZ*e.m34+t.m44*e.m44)}}class Matrix3D{static identity(){return{m11:1,m12:0,m13:0,m14:0,m21:0,m22:1,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,offsetX:0,offsetY:0,offsetZ:0,m44:1}}static from(...t){if(16!==t.length)throw new RangeError("Must provide exactly 16 numbers");return{m11:t[0],m12:t[1],m13:t[2],m14:t[3],m21:t[4],m22:t[5],m23:t[6],m24:t[7],m31:t[8],m32:t[9],m33:t[10],m34:t[11],offsetX:t[12],offsetY:t[13],offsetZ:t[14],m44:t[15]}}static transpose(t){return Matrix3D.from(t.m11,t.m21,t.m31,t.offsetX,t.m12,t.m22,t.m32,t.offsetY,t.m13,t.m23,t.m33,t.offsetZ,t.m14,t.m24,t.m34,t.m44)}static toArray(t){return[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.offsetX,t.offsetY,t.offsetZ,t.m44]}static clone(t,e){return"function"==typeof e?Matrix3DUtils.modify(t,e):Matrix3DUtils.clone(t)}static scale(t,e,r,n){return"number"==typeof e?(r??=e,n??=e):(n=e.z,r=e.y,e=e.x),Matrix3DUtils.modify(t,t=>{t.m11*=e,t.m22*=r,t.m33*=n})}static translate(t,e){return Matrix3DUtils.modify(t,t=>{t.offsetX+=e.x,t.offsetY+=e.y,t.offsetZ+=e.z})}static parse(e){const r=t.parseAsNumericalArray(e);if(r&&16===r.length)return Matrix3D.from.apply(null,r);throw new Error(`Cannot parse "${e}" as a valid Matrix3D.`)}static isIdentity(t){return 1==t.m11&&0==t.m12&&0==t.m13&&0==t.m14&&0==t.m21&&1==t.m22&&0==t.m23&&0==t.m24&&0==t.m31&&0==t.m32&&1==t.m33&&0==t.m34&&0==t.offsetX&&0==t.offsetY&&0==t.offsetZ&&1==t.m44}static isAffine(t){return 0==t.m14&&0==t.m24&&0==t.m34&&1==t.m44}static determinant(t){if(Matrix3D.isIdentity(t))return 1;if(Matrix3D.isAffine(t))return t.m11*(t.m22*t.m33-t.m32*t.m23)-t.m12*(t.m21*t.m33-t.m31*t.m23)+t.m13*(t.m21*t.m32-t.m31*t.m22);{const e=t.m13*t.m24-t.m23*t.m14,r=t.m13*t.m34-t.m33*t.m14,n=t.m13*t.m44-t.offsetZ*t.m14,s=t.m23*t.m34-t.m33*t.m24,a=t.m23*t.m44-t.offsetZ*t.m24,o=t.m33*t.m44-t.offsetZ*t.m34,m=t.m22*r-t.m32*e-t.m12*s,i=t.m12*a-t.m22*n+t.offsetY*e,c=t.m32*n-t.offsetY*r-t.m12*o,f=t.m22*o-t.m32*a+t.offsetY*s;return t.offsetX*m+t.m31*i+t.m21*c+t.m11*f}}static multiply(...t){if(0===t.length)throw new ReferenceError("Matrix not provided.");const e=Array.from(t);let r=e[0];for(let t=1;t<e.length;t++)r=Matrix3DUtils.multiply(r,e[t]);return r}static invert(t){if(Matrix3D.isAffine(t)){const e=Matrix3D.determinant(t);if(0==e)return null;const r=t.m12*t.m23-t.m22*t.m13,n=t.m32*t.m13-t.m12*t.m33,s=t.m22*t.m33-t.m32*t.m23,a=t.m21*t.m13-t.m11*t.m23,o=t.m11*t.m33-t.m31*t.m13,m=t.m31*t.m23-t.m21*t.m33,i=t.m11*t.m22-t.m21*t.m12,c=t.m11*t.m32-t.m31*t.m12,f=t.m11*t.offsetY-t.offsetX*t.m12,u=t.m21*t.m32-t.m31*t.m22,l=t.m21*t.offsetY-t.offsetX*t.m22,h=t.m31*t.offsetY-t.offsetX*t.m32,y=t.m23*f-t.offsetZ*i-t.m13*l,x=t.m13*h-t.m33*f+t.offsetZ*c,g=t.m33*l-t.offsetZ*u-t.m23*h,M=i,p=-c,d=u,b=1/e;return Matrix3D.from(s*b,n*b,r*b,0,m*b,o*b,a*b,0,d*b,p*b,M*b,0,g*b,x*b,y*b,1)}{const e=Matrix3D.determinant(t);if(0==e)return null;const r=t.m33*t.m44-t.m34*t.offsetZ,n=t.m32*t.m44-t.m34*t.offsetY,s=t.m31*t.m44-t.m34*t.offsetX,a=t.m32*t.offsetZ-t.m33*t.offsetY,o=t.m31*t.offsetZ-t.m33*t.offsetX,m=t.m31*t.offsetY-t.m32*t.offsetX,i=t.m33*t.m44-t.m34*t.offsetZ,c=t.m32*t.m44-t.m34*t.offsetY,f=t.m31*t.m44-t.m34*t.offsetX,u=t.m32*t.offsetZ-t.m33*t.offsetY,l=t.m31*t.offsetZ-t.m33*t.offsetX,h=t.m31*t.offsetY-t.m32*t.offsetX,y=t.m23*t.m44-t.m24*t.offsetZ,x=t.m22*t.m44-t.m24*t.offsetY,g=t.m21*t.m44-t.m24*t.offsetX,M=t.m22*t.offsetZ-t.m23*t.offsetY,p=t.m21*t.offsetZ-t.m23*t.offsetX,d=t.m21*t.offsetY-t.m22*t.offsetX,b=t.m23*t.m34-t.m24*t.m33,z=t.m22*t.m34-t.m24*t.m32,w=t.m21*t.m34-t.m24*t.m31,A=t.m22*t.m33-t.m23*t.m32,v=t.m21*t.m33-t.m23*t.m31,D=t.m21*t.m32-t.m22*t.m31,N=t.m22*r-t.m23*n+t.m24*a,P=-(t.m21*r-t.m23*s+t.m24*o),C=t.m21*n-t.m22*s+t.m24*m,V=-(t.m21*a-t.m22*o+t.m23*m),X=-(t.m12*i-t.m13*c+t.m14*u),q=t.m11*i-t.m13*f+t.m14*l,U=-(t.m11*c-t.m12*f+t.m14*h),Y=t.m11*u-t.m12*l+t.m13*h,Z=t.m12*y-t.m13*x+t.m14*M,S=-(t.m11*y-t.m13*g+t.m14*p),L=t.m11*x-t.m12*g+t.m14*d,E=-(t.m11*M-t.m12*p+t.m13*d),Q=-(t.m12*b-t.m13*z+t.m14*A),T=t.m11*b-t.m13*w+t.m14*v,I=-(t.m11*z-t.m12*w+t.m14*D),R=t.m11*A-t.m12*v+t.m13*D,_=1/e;return Matrix3D.from(N*_,X*_,Z*_,Q*_,P*_,q*_,S*_,T*_,C*_,U*_,L*_,I*_,V*_,Y*_,E*_,R*_)}}static transform(t,e){var r={x:t.x,y:t.y,z:t.z};if(!Matrix3D.isIdentity(e)){var n=r.x,s=r.y,a=r.z;if(r.x=n*e.m11+s*e.m21+a*e.m31+e.offsetX,r.y=n*e.m12+s*e.m22+a*e.m32+e.offsetY,r.z=n*e.m13+s*e.m23+a*e.m33+e.offsetZ,!Matrix3D.isAffine(e)){var o=n*e.m14+s*e.m24+a*e.m34+e.m44;0!=o&&(r.x/=o,r.y/=o,r.z/=o)}}return r}}e.Matrix3D=Matrix3D;class Quaternion{static identity(){return Quaternion.from(0,0,0,1)}static from(...t){if(4!==t.length)throw new RangeError("Must provide exactly 4 numbers");return{x:t[0],y:t[1],z:t[2],w:t[3]}}static parse(e){const r=t.parseAsNumericalArray(e);if(r&&4===r.length)return Quaternion.from.apply(null,r);throw new Error(`Cannot parse "${e}" as a valid Quaternion.`)}static fromVectors(t,e){Vector3D.normalize(t),Vector3D.normalize(e);const r=(t,e,r,n)=>{const s=Quaternion.from(t,e,r,n);return Quaternion.normalize(s),s};let n=Vector3D.dot(t,e)+1;return n.isCloseTo(0)?Math.abs(t.x)>Math.abs(t.z)?r(-t.y,t.x,0,0):r(0,-t.z,t.y,0):r(t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z,t.x*e.y-t.y*e.x,n)}static normalize(t){const e=Quaternion.mag(t);if(e.isCloseTo(0))t.x=t.y=t.z=0,t.w=1;else{const r=1/e;t.x*=r,t.y*=r,t.z*=r,t.w*=r}}static unit(t){const e=Quaternion.from(t.x,t.y,t.z,t.w);return Quaternion.normalize(e),e}static fromAxisAngle(t,e){var r=n*(e%=360),s=Vector3D.mag(t);if(0==s)throw new RangeError("Invalid argument");var a=Math.sin(.5*r)/s,o=t.x*a,m=t.y*a,i=t.z*a;return Quaternion.from(o,m,i,Math.cos(.5*r))}static fromRotationMatrix(t){const e=t.m11+t.m22+t.m33+t.m44;if(e>0){const r=.5/Math.sqrt(e),n=.25/r,s=(t.m23-t.m32)*r,a=(t.m31-t.m13)*r,o=(t.m12-t.m21)*r;return Quaternion.from(s,a,o,n)}if(t.m11>t.m22&&t.m11>t.m22){const e=.5/Math.sqrt(t.m44+t.m11-t.m22-t.m33),r=(t.m23-t.m32)*e,n=.25/e,s=(t.m12+t.m21)*e,a=(t.m31+t.m13)*e;return Quaternion.from(n,s,a,r)}if(t.m22>t.m33){const e=.5/Math.sqrt(t.m44+t.m22-t.m11-t.m33),r=(t.m23+t.m32)*e,n=.25/e,s=(t.m12+t.m21)*e,a=(t.m31-t.m13)*e;return Quaternion.from(s,n,r,a)}{const e=.5/Math.sqrt(t.m44+t.m33-t.m11-t.m22),r=(t.m23+t.m32)*e,n=.25/e,s=(t.m12-t.m21)*e,a=(t.m31-t.m13)*e;return Quaternion.from(a,r,n,s)}}static conjugate(t){return Quaternion.from(-t.x,-t.y,-t.z,t.w)}static mag(t){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w)}static norm(t){return t.x*t.x+t.y*t.y+t.z*t.z}static axis(t){return 0==t.x&&0==t.y&&0==t.z?Vector3D.j():Vector3D.unit(t)}static transform(t,e){Quaternion.normalize(e);const r=Vector3D.cross(e,t),n=Vector3D.scale(r,2),s=Vector3D.cross(e,n);return{x:t.x+e.w*n.x+s.x,y:t.y+e.w*n.y+s.y,z:t.z+e.w*n.z+s.z}}static angle(t){let e=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z),r=t.w;if(e>Number.MAX_VALUE){const n=Math.max(Math.abs(t.x),Math.max(Math.abs(t.y),Math.abs(t.z))),s=t.x/n,a=t.y/n,o=t.z/n;e=Math.sqrt(s*s+a*a+o*o),r/=n}return 114.59155902616465*Math.atan2(e,r)}static toRotationMatrix(t){var e=Matrix3D.identity(),r=t.x,n=t.y,s=t.z,a=t.w;return e.m11=1-2*n*n-2*s*s,e.m12=2*r*n+2*a*s,e.m13=2*r*s-2*a*n,e.m21=2*r*n-2*a*s,e.m22=1-2*r*r-2*s*s,e.m23=2*n*s+2*a*r,e.m31=2*a*n+2*r*s,e.m32=2*n*s-2*a*r,e.m33=1-2*r*r-2*n*n,e}static invert(t){const e=Quaternion.unit(t);return Quaternion.conjugate(e)}static multiply(t,e){return Quaternion.from(t.w*e.x+t.x+e.w+t.y*e.z-t.z*e.y,t.w*e.y-t.x*e.z+t.y*e.w+t.z*e.x,t.w*e.z+t.x*e.y-t.y*e.x+t.z*e.w,t.w*e.w-t.x*e.x-t.y*e.y-t.z*e.z)}static dot(t,e){return Quaternion.multiply(t,Quaternion.conjugate(e)).w}}e.Quaternion=Quaternion}(e.LinearAlgebra||(e.LinearAlgebra={}))}(t.Geometry||(t.Geometry={}))}(Pacem||(Pacem={})),function(t){!function(e){const r=t.Geometry.LinearAlgebra.Vector3D;t.Geometry.LinearAlgebra.Matrix3D;e.Utils3D=class Utils3D{static intersect(t,e){const[n,s]=t,a=r.subtract(n,s),[o,m,i]=e,c=r.subtract(o,m),f=r.subtract(o,i),u=r.cross(a,f),l=r.dot(c,u);if(l.isCloseTo(0))return null;const h=1/l,y=r.subtract(n,o),x=h*r.dot(y,u);if(x<0||x>1)return null;const g=r.cross(y,c),M=h*r.dot(a,g);if(M<0||x+M>1)return null;const p=h*r.dot(f,g);return p<0||p.isCloseTo(0)?null:r.add(n,r.scale(a,p))}}}(t.Geometry||(t.Geometry={}))}(Pacem||(Pacem={})),function(t){!function(e){class Polygon{static isPolygon(e){return function(e){let r;return"vertices"in e&&Array.isArray(e.vertices)&&(r=e.vertices).length>=3&&r.every(e=>t.Point.isPoint(e))}(e)}static from(...t){return{vertices:Array.from(t)}}static contains(t,r){return e.Utils.inPolygon(r,t.vertices,12)}static centroid(t){const e=Polygon.boundingBox(t);return{x:e.x+e.width/2,y:e.y+e.height/2}}static boundingBox(t){let e=Number.MAX_VALUE,r=Number.MAX_VALUE,n=-Number.MAX_VALUE,s=-Number.MAX_VALUE;const{vertices:a}=t;a.length;for(let t of a)e=Math.min(e,t.x),r=Math.min(r,t.y),n=Math.max(n,t.x),s=Math.max(s,t.y);return{x:e,y:r,width:n-e,height:s-r}}static sides(t){const{vertices:e}=t,r=[];for(let t=1;t<=e.length;t++){const n=e[t%e.length],s=e[t-1];r.push([s,n])}return r}static isConvex(e){const{vertices:r}=e,n=r.length;if(n<=3)return!0;let s=0;for(let e=0;e<r.length;e++){const a=r[(e-1+n)%n],o=r[e],m=r[(e+1)%n],i=t.Angle.angleBetween(o,a,m);if(0!==s){if(s!=Math.sign(i))return!1}else s=Math.sign(i)}return!0}static isSelfIntersecting(r){const{vertices:n}=r;if(n.length<=3)return!1;const s=Polygon.sides(r);for(let r of s)for(let n of s){if(n===r||n[0]===r[1]||r[0]===n[1])continue;const s=e.Utils.intersect(n,r);if(!t.NullChecker.isNull(s))return!0}return!1}static isCounterClockwise(e){const{vertices:[r,n,s]}=e;return t.Angle.angleBetween(n,r,s)>0}static expand(r,n){const{vertices:s}=r,a=s.length,o=[];for(let r=0;r<s.length;r++){const m=s[(r-1+a)%a],i=s[r],c=s[(r+1)%a],f=t.Angle.angleBetween(i,m,c),u=-n/Math.sin(Math.abs(f)/2),l=t.Matrix2D.scale(t.Matrix2D.identity,u),h=t.Point.subtract(i,m);e.LinearAlgebra.Vector.normalize(h);const y=t.Point.subtract(i,c);e.LinearAlgebra.Vector.normalize(y);const x=t.Point.add(h,y);e.LinearAlgebra.Vector.normalize(x);const g=t.Matrix2D.multiply(x,l);o.push(t.Point.add(i,{x:g.x.roundoff(),y:g.y.roundoff()}))}return{vertices:o}}static area(t){return e.Utils.area(t.vertices)}}e.Polygon=Polygon}(t.Geometry||(t.Geometry={}))}(Pacem||(Pacem={})),function(t){!function(t){function e(t){return"number"==typeof t&&(t={real:t,img:0}),t}var r;function n(t,e){const r={};return Object.defineProperty(r,"real",{value:t,writable:!1}),Object.defineProperty(r,"img",{value:e,writable:!1}),r}function s(){return r||(r=n(Number.NaN,Number.NaN))}t.Complex=class Complex{static build(t,e){return this.isComplex(t)?t:(e??=0,"number"!=typeof t||"number"!=typeof e?s():n(t,e||0))}static add(t,r){const s=e(t),a=e(r);return n(s.real+a.real,s.img+a.img)}static subtract(t,r){const s=e(t),a=e(r);return n(s.real-a.real,s.img-a.img)}static multiply(t,r){const s=e(t),a=e(r);return n(s.real*a.real-s.img*a.img,s.real*a.img+s.img*a.real)}static divide(t,r){const a=e(t),o=e(r),m=this.absSquare(o).roundoff();if(0===m)return s();const i=1/m;return n(i*(a.real*o.real+a.img*o.img),i*(a.img*o.real-a.real*o.img))}static absSquare(t){const r=e(t);return Math.pow(r.real,2)+Math.pow(r.img,2)}static modulus(t){return Math.sqrt(this.absSquare(t))}static isComplex(t){return null!=t&&"object"==typeof t&&"real"in t&&"img"in t&&"number"==typeof t.real&&"number"==typeof t.img}static conjugate(t){return n((t=e(t)).real,0==Math.abs(t.img)?0:-t.img)}static equals(t,e){const r=this.build(t),n=this.build(e);return!(!this.isComplex(t)||!this.isComplex(e))&&(r.real===n.real&&r.img===n.img)}static get NaC(){return s()}}}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={})),function(t){!function(t){!function(e){const r={};function n(e,n){const s=r[n]=r[n]||{};return s[e]=s[e]||function(e,r){const n=2*Math.PI*e/r;return t.Complex.build(Math.cos(n),Math.sin(n))}(e,n)}function s(e){const r=[],a=e.length;if(1===a)return[t.Complex.build(e[0])];const o=s(e.filter((t,e)=>e%2==0)),m=s(e.filter((t,e)=>e%2==1));for(var i=0;i<a/2;i++){const e=o[i],s=t.Complex.multiply(n(i,a),m[i]);r[i]=t.Complex.add(e,s),r[i+a/2]=t.Complex.subtract(e,s)}return r}e.Fourier=class Fourier{static transform(t,e=!0){return(r=(t=t||[]).length)>0&&!(r&r-1)?this.fft(t,e):this.dft(t,e);var r}static invert(t,e=!0){return this.idft(t||[],e)}static dft(e,r=!0){const s=(e||[])?.length,a=r?1/Math.sqrt(s):1,o=[];for(let r=0;r<s;r++){o.push({real:0,img:0});for(let m=0;m<s;m++){const i=n(r*m,s),c=t.Complex.multiply(e[m],i),f=t.Complex.multiply(c,a);o[r]=t.Complex.add(o[r],f)}}return o}static idft(e,r=!0){const n=e.map(e=>t.Complex.build(e.img,e.real));return this.transform(n,r).map(e=>t.Complex.build(e.img,e.real))}static fft(e,r=!0){const n=s(e);if(!r)return n;const a=1/Math.sqrt(e.length);return n.map(e=>t.Complex.multiply(e,a))}}}(t.DataAnalysis||(t.DataAnalysis={}))}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={})),function(t){!function(t){!function(t){const e=Math.sqrt(Math.PI);function r(t){const e=Math.abs(t),r=1/(1+.5*e),n=r*Math.exp(-e*e-1.26551223+r*(1.00002368+r*(.37409196+r*(.09678418+r*(r*(.27886807+r*(r*(1.48851587+r*(.17087277*r-.82215223))-1.13520398))-.18628806)))));return t>=0?n:2-n}class Gaussian{constructor(t,e){this.mean=t,this.stdev=Math.abs(e),this.variance=Math.pow(e,2)}mean;stdev;variance;static get normal(){return n}weight(t){return Math.exp(-.5*Math.pow(this._z(t),2))}probabilityDensity(t){const r=this.stdev*Math.SQRT2*e;return this.weight(t)/r}_z(t){return(t-this.mean)/this.stdev}probability(t){return.5*r(-this._z(t)/Math.SQRT2)}}t.Gaussian=Gaussian;const n=new Gaussian(0,1)}(t.DataAnalysis||(t.DataAnalysis={}))}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={})),function(t){!function(t){!function(t){class Lagrangian{constructor(...t){this.#t=Array.from(t)||[]}#t;#e;_unsafeCreate(){const t=this.#t||[];let e,r="var ljs = [];\n";for(let n=0;n<t.length;n++){const s=t[n],a=s.x;if(null!=e&&e>=a)throw new Error("Invalid function provided.");e=a,r+=`ljs.push( ${s.y}`;for(let e=0;e<t.length;e++)if(e!==n){const n=t[e];r+=` * ((x - ${n.x})/${a-n.x})`}r+=");\n"}r+="return ljs.reduce((prev, next) => prev + next, 0);",this.#e=new Function("x",r)}_compute(t){const e=this.#t||[];let r;const n=[];for(let s=0;s<e.length;s++){const a=e[s].x;if(null!=r&&r>=a)throw new Error("Invalid function provided.");r=a;let o=e[s].y;for(let r=0;r<e.length;r++)if(r!==s){const n=e[r];o*=(t-n.x)/(a-n.x)}n.push(o)}return n.reduce((t,e)=>t+e,0)}interpolate(t){return"function"==typeof this.#e?this.#e.apply(null,[t]):this._compute(t)}static create(...t){const e=(arguments.length>0&&Array.isArray(arguments[0])?arguments[0]:Array.from(t)).map((t,e)=>"number"==typeof t?{x:e,y:t}:t),r=new(Function.prototype.bind.apply(Lagrangian,[null].concat(e)));try{r._unsafeCreate()}catch(t){}return r}}t.Lagrangian=Lagrangian}(t.DataAnalysis||(t.DataAnalysis={}))}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){const r="0123456789abcdefghijklmnopqrstuvwxyz",n="Radix out of range: possible values go between positive 1 exclusive and 36 inclusive";class Utils{static lcd(...e){if(t.NullChecker.isNullOrEmpty(e)||e.length<=1)throw"Insufficient set of numbers.";function r(t,e){return e?r(e,t%e):0===e?t:NaN}function n(t,e){return t*e/r(t,e)}let s=Math.round(e[0]);for(let t=1;t<e.length;t++)s=n(s,Math.round(e[t]));return s}static gcd(t,e){return t=Math.round(t),e=Math.round(e),0===t?e:Utils.gcd(e%t,t)}static rebaseInt(e,r,n){return t.Numbers.rebase(e,r,n)}static rebaseFloat(t,e,r,n=12){const s=Utils.rebaseFloat10ToN,a=Utils.rebaseFloatNTo10;if(10===e){const e=parseFloat(t.toString());return r%1==0?Utils.rebaseFloat10ToNIntBase(e,r,n):s(e,r,n)}if(10===r)return a(t.toString(),e,n);return s(a(t.toString(),e,n+1),r,n)}static rebaseFloatNTo10(t,e,s=12){const a=r;if(e<=1||e>a.length)throw new Error(n);const o=(t??"0").toString().toLowerCase(),m=Number.NaN;if("0"===o)return 0;const i=/^([-+]?) *([\da-z]+)?(.[\da-z]+)?$/.exec(o);if(i.length<2)return m;const c="-"===i[1]?-1:1,f=i[2]||"0",u=i[3]||".0";let l=0,h=0;for(let t of f+u.substr(1)){const r=a.indexOf(t);if(-1===r||r>=e)return m;l+=r*Math.pow(e,f.length-h-1),h++}return c*l}static rebaseFloat10ToNIntBase(t,e,s=12){const a=r;if(e<=1||e>36)throw new Error(n);const o=e;let m=Math.abs(t??0);if(0===m||Number.isNaN(m))return t.toString();let i=(m%1).roundoff(),c="";for(;;){let t=m/o,e=Math.floor(t),r=(m-e*o).roundoff(),n=Math.floor(r);if(c=n>=36?`[${n}]`+c:a[n]+c,e<=0)break;m=e}if(c=c.replace(/^0+/,""),c||="0",0===i)return c;let f="";do{m=(i*o).roundoff();const t=Math.floor(m),e=(m-t).roundoff();t>=36?f=`[${t}]`:f+=a[t],i=e}while(!i.isCloseTo(0)&&f.length<s);return/^0*$/.test(f)?c:(Math.sign(t)<0?"-":"")+c+"."+f.replace(/0+$/,"")}static rebaseFloat10ToN(e,s,a=12){const o=r;if(s<=1||s>o.length)throw new Error(n);const m=s;let i=Math.abs(e??0);if(0===i||Number.isNaN(i))return e.toString();let c=Math.sign(e)<0?"-":"",f=[],u=[];for(let t=0;t<20;t++)f.push("0"),u.push("0");const l=m%1==0?m:Math.ceil(m);function h(t,e,r){const n=t?f:u,s=n[e]=n[e]||"0",a=o.indexOf(s)+r,m=a%l,i=Math.floor(a/l);return n[e]=o[m],i>0&&(t?h(t,e+1,i):0===e?h(!0,0,i):h(!1,e-1,i)),i}let y=0;for(;;){const e=Math.floor(t.Numbers.log(i,m)),r=e>=0;if(h(r,r?e:Math.abs(1+e),1),i=(i-Math.pow(m,e).roundoff()).roundoff(),r||y++,0===i||y>=100){const t=c+(f.reverse().map(t=>t||"0").join("").replace(/^0+/,"")||"0"),e=u.map(t=>t||"0").join("").substr(0,a).replace(/0+$/,"");return/^0*$/.test(e)?t:t+"."+e}}}}e.Utils=Utils}(e.NumberTheory||(e.NumberTheory={}))}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={})),function(t){!function(t){!function(t){const e=(t,e)=>t;function r(t,r=e){return t.reduce((t,e,n)=>t+r(e,n),0)}function n(t,n=e){return r(t,n)/t.length}function s(t,r=e,s=!1){const a=n(t,r);return t.reduce((t,e)=>Math.pow(e-a,2)+t,0)/(t.length-(s?1:0))}function a(t,r=e,n=!1){const a=s(t,r,n);return Math.sqrt(a)}function o(t,e){return(r,n,s,a)=>{let o=r,m=n,i=t(o,m),c=e(o,m),f=s(i),u=s(c);for(;m-o>a;)f<u?(m=c,c=i,u=f,i=t(o,m),f=s(i)):(o=i,i=c,f=u,c=e(o,m),u=s(c));return.5*(i+c)}}t.Utils=class Utils{static sum(t,e){return r(t,e)}static mean(t,e){return n(t,e)}static median(t,r){return function(t,r=e){const n=t.slice(0),s=n.length;n.sort((t,e)=>r(t)-r(e));const a=Math.ceil(n.length/2)-1;return s%2==1?n[a]:.5*(n[a+1]+n[a])}(t,r)}static mode(t,r){return function(t,r=e){const n=Object.groupBy(t,r);let s,a=0;for(let t in n){const e=n[t].length;e>a&&(s=parseInt(t),a=e)}return s}(t,r)}static var(t,e){return s(t,e,!0)}static varp(t,e){return s(t,e,!1)}static stdevp(t,e){return a(t,e,!1)}static stdev(t,e){return a(t,e,!0)}static correlation(t,r,s,a){return function(t,r,s=e,a=e){const o=Array.isArray(r);if(o&&r.length!==t.length)throw new Error("Sets must be of the same length.");const m=t.length,i=t,c=o?r:t,f=o?s:r,u=o?a:s,l=n(i,f),h=n(c,u);let y=0,x=0,g=0;for(let t=0;t<m;t++){const e=i[t],r=c[t],n=f(e,t)-l,s=u(r,t)-h;y+=n*s,x+=n*n,g+=s*s}return y/Math.sqrt(x*g)}(t,r,s,a)}static linearRegression(t,r,n,s){return function(t,r,n=e,s=e){const a=Array.isArray(r);if(a&&r.length!==t.length)throw new Error("Sets must be of the same length.");const o=t,m=a?r:t,i=a?n:r,c=i??(t=>t.x),f=(a?s:i)??(t=>t.y),u=t.length;let l=0,h=0,y=0,x=0,g=0;for(let t=0;t<u;t++){const e=o[t],r=m[t],n=c(e,t),s=f(r,t);l+=n*s,h+=n,y+=s,x+=n*n,g+=s*s}const M=(u*l-h*y)/(u*x-Math.pow(h,2));return[M,(y-M*h)/u]}(t,r,n,s)}static gaussian(e,r){return new t.Gaussian(e,r)}};t.SearchFunctions={linear:(t=2)=>function(t){if(t<=1)throw new RangeError("segments must be a number grater than 1.");return(e,r,n,s=.001)=>o((e,r)=>e+(r-e)/t,(e,r)=>r-(r-e)/t)(e,r,n,s)}(t),goldenRatio:(t,e,r,n=.001)=>o((t,e)=>e-(e-t)/1.618,(t,e)=>t+(e-t)/1.618)(t,e,r,n),gaussian:(t,e,r,n=.001)=>{var s=null,a=null;const m=(t,e)=>(a??=e-t,s??=a/Math.sqrt(12),s*(e-t)/a);return o((t,e)=>Math.max(t,(e+t)/2-m(t,e)),(t,e)=>Math.min(e,(e+t)/2+m(t,e)))(t,e,r,n)}}}(t.DataAnalysis||(t.DataAnalysis={}))}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={}));
6
+ var Pacem;!function(t){!function(e){!function(e){class Vector{static unit(t){const e={x:t.x,y:t.y};return this.normalize(e),e}static magSqr(t){return t.x*t.x+t.y*t.y}static mag(t){return Math.sqrt(Vector.magSqr(t))}static normalize(t){const e=Vector.mag(t);if(e<=0)throw"Cannot normalize a vector of length 0.";const r=1/e;t.x*=r,t.y*=r}static from(e,r){return t.Point.subtract(e,r)}static dot(t,e){return t.x*e.x+t.y*e.y}static cross(t,e){return t.x*e.y-t.y*e.x}static areClose(t,e){return(e.x-t.x).isCloseTo(0)&&(e.y-t.y).isCloseTo(0)}}e.Vector=Vector}(e.LinearAlgebra||(e.LinearAlgebra={}))}(t.Geometry||(t.Geometry={}))}(Pacem||(Pacem={})),function(t){!function(e){const r=180/Math.PI,n=2*Math.PI,s=e.LinearAlgebra.Vector;function a(e){return t.Point.isPoint(e)}e.Utils=class Utils{static slopeRad(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}static slopeRad2(t,e){return(n+this.slopeRad(t,e))%n}static slopeDeg(t,e){return this.slopeRad(t,e)*r}static slopeDeg2(t,e){return(360+this.slopeDeg(t,e))%360}static intersect(t,e,...r){return Array.isArray(t)&&Array.isArray(e)?this._intersectSegments(t,e,!0):this._intersectRects.apply(this,arguments)}static intersectLines(t,e,r,n){let s,a;if(Array.isArray(t)&&Array.isArray(e)&&2===t.length&&2===e.length&&"number"==typeof t[0]&&"number"==typeof e[0]&&"number"==typeof t[1]&&"number"==typeof e[1]&&(r=e[0],n=e[1],e=t[1],t=t[0]),"number"==typeof t&&"number"==typeof e){s=[{x:0,y:e},{x:1,y:t+e}],a=[{x:0,y:n},{x:1,y:r+n}]}else s=t,a=e;return this._intersectSegments(s,a,!1)}static cramer(t,e){Array.isArray(t)&&(t={a:t[0],b:t[1],c:t[2]}),Array.isArray(e)&&(e={a:e[0],b:e[1],c:e[2]});let r=(t.b*e.c-t.c*e.b)/(t.b*e.a-t.a*e.b),n=(t.c*e.a-t.a*e.c)/(t.b*e.a-t.a*e.b);return{x:-r.roundoff(),y:-n.roundoff()}}static mq(t,e){let r;if(a(t)?r=t:(r=t[0],e=t[1]),r.x===e.x)return[Number.NaN,Number.NaN];const n=(e.y-r.y)/(e.x-r.x);return[n,r.y-n*r.x]}static _intersectSegments(t,e,r){const n=t[0],s=t[1],a=e[0],o=e[1],i=Math.min(n.x,s.x),m=Math.min(n.y,s.y),c=Math.max(n.x,s.x),f=c-i,u=Math.max(n.y,s.y),l=u-m,h=Math.min(a.x,o.x),y=Math.min(a.y,o.y),x=Math.max(a.x,o.x),g=x-h,M=Math.max(a.y,o.y),p=M-y;if(0===f&&0===g)return null;if(0===l&&0===p)return null;const d=t=>t.x<h||t.x>x||t.x<i||t.x>c,b=t=>t.y<y||t.y>M||t.y<m||t.y>u;var z=null;if(0===f){if(r&&(h>i||x<c))return null;const t=this.mq(a,o);z=this.cramer([1,0,-i],[t[0],-1,t[1]]),r&&b(z)&&(z=null)}else if(0===g){if(r&&(i>h||c<x))return null;const t=this.mq(n,s);z=this.cramer([t[0],-1,t[1]],[1,0,-h]),r&&b(z)&&(z=null)}else if(0===l){if(r&&(y>m||M<u))return null;const t=this.mq(a,o);z=this.cramer([0,1,-m],[t[0],-1,t[1]]),r&&d(z)&&(z=null)}else if(0===p){if(r&&(m>y||u<M))return null;const t=this.mq(n,s);z=this.cramer([t[0],-1,t[1]],[0,1,-y]),r&&d(z)&&(z=null)}else{let t;if(!r||(t=this._intersectRects({x:i,y:m,width:f,height:l},{x:h,y:y,width:g,height:p}))&&t.width>0&&t.height>0){const e=this.mq(n,s),i=this.mq(a,o),m=e[0],c=i[0],f=e[1],u=i[1];if(m!==c){let e=(z=this.cramer([m,-1,f],[c,-1,u])).x,n=z.y;r&&(e<t.x||e>t.x+t.width||n<t.y||n>t.y+t.height)&&(z=null)}}}return null===z?null:{x:z.x,y:z.y}}static _intersectRects(...e){return t.Rect.intersect.apply(this,e)}static dot(t,e){return s.dot(t,e)}static cross(t,e){return s.cross(t,e)}static distance(e,r){if(null!=(n=e)&&Array.isArray(n)&&2===n.length&&a(n[0])&&a(n[1]))return t.Point.distance(e[0],e[1]);if(a(r))return t.Point.distance(e,r);{const t=r[0],n=r[1];return Math.abs(t*e.x-e.y+n)/Math.sqrt(Math.pow(t,2)+1)}var n}static inLine(t,e){const r=s.from(e[0],t),n=s.from(t,e[1]);return this.cross(r,n).isCloseTo(0)}static inSegment(t,e){const r=Math.min(e[0].x,e[1].x),n=Math.max(e[0].x,e[1].x),s=Math.min(e[0].y,e[1].y),a=Math.max(e[0].y,e[1].y);return t.x>=r&&t.x<=n&&t.y>=s&&t.y<=a&&this.inLine(t,e)}static inTriangle(e,r){let n;for(let s=0;s<3;s++){const a=r[s],o=r[(s+1)%3],i=t.Point.subtract(o,e),m=t.Point.subtract(a,e),c=this.cross(i,m);if(s>0&&c*n<=0)return!1;n=c}return!0}static inPolygon(t,e,r){if(!(e?.length>=3))throw"Not enough vertices";const n=e.length;if(3===n)return this.inTriangle(t,[e[0],e[1],e[2]]);r>0&&(e=e.map(t=>({x:t.x.roundoff(r),y:t.y.roundoff(r)})),t={x:t.x.roundoff(r),y:t.y.roundoff(r)});let s=Number.MAX_VALUE,a=Number.MAX_VALUE,o=Number.MIN_VALUE,i=Number.MIN_VALUE;for(let t=0;t<n;t++){const r=e[t];s=Math.min(s,r.x),a=Math.min(a,r.y),o=Math.max(o,r.x),i=Math.max(i,r.y)}if(t.x<s||t.x>o||t.y<a||t.y>i)return!1;const m=[{x:s-1,y:t.y},t];let c=0;for(let r=0;r<n;r++){const s=e[r],a=e[(r+1)%n],o=[s,a];if(s.y===t.y){const o=e[(r-1+n)%n];t.x>s.x&&(o.y-t.y)*(a.y-t.y)<0&&c++}else{if(a.y===t.y)continue;null!=this.intersect(o,m)&&c++}}return c%2==1}static area(t,...e){const r=[].concat(t).concat(e);let n=0;const s=r.length;if(s>=3){for(let t=0;t<r.length;t++){const{x:e,y:a}=r[t],o=t===s-1?0:t+1,{x:i,y:m}=r[o];n+=e*m-a*i}n*=.5}return Math.abs(n.roundoff())}static convexHull(t,...e){const r=[].concat(t).concat(e);if(!(r?.length>1))return r?.slice()??[];const n=r.map(t=>({x:t.x,y:t.y})).sort((t,e)=>t.x===e.x?t.y-e.y:t.x-e.x),s=[];for(const t of n){const e=s[s.length-1];e&&e.x===t.x&&e.y===t.y||s.push(t)}if(s.length<=2)return s;const a=(t,e,r)=>(e.x-t.x)*(r.y-t.y)-(e.y-t.y)*(r.x-t.x),o=[];for(const t of s){for(;o.length>=2&&a(o[o.length-2],o[o.length-1],t)<=0;)o.pop();o.push(t)}const i=[];for(let t=s.length-1;t>=0;t--){const e=s[t];for(;i.length>=2&&a(i[i.length-2],i[i.length-1],e)<=0;)i.pop();i.push(e)}return o.pop(),i.pop(),o.concat(i)}}}(t.Geometry||(t.Geometry={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){const r=180/Math.PI,n=1/r;class Vector3D{static from(...t){if(3!==t.length)throw new RangeError("Must provide exactly 3 numbers");return{x:t[0],y:t[1],z:t[2]}}static parse(e){const r=t.parseAsNumericalArray(e);if(r&&3===r.length)return Vector3D.from.apply(null,r);throw new Error(`Cannot parse "${e}" as a valid Vector3D.`)}static i(){return{x:1,y:0,z:0}}static j(){return{x:0,y:1,z:0}}static k(){return{x:0,y:0,z:1}}static zero(){return{x:0,y:0,z:0}}static subtract(t,e){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static add(...t){var e={x:0,y:0,z:0};for(var r of t)e.x+=r.x,e.y+=r.y,e.z+=r.z;return e}static dot(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static scale(t,e,r=e,n=e){return{x:t.x*e,y:t.y*r,z:t.z*n}}static magSqr(t){return t.x*t.x+t.y*t.y+t.z*t.z}static areClose(t,e){return(e.x-t.x).isCloseTo(0)&&(e.y-t.y).isCloseTo(0)&&(e.z-t.z).isCloseTo(0)}static mag(t){return Math.sqrt(Vector3D.magSqr(t))}static negate(t){return{x:-t.x,y:-t.y,z:-t.z}}static unit(t){const e={x:t.x,y:t.y,z:t.z};return this.normalize(e),e}static normalize(t){const e=Vector3D.mag(t);if(e<=0)throw"Cannot normalize a vector of length 0.";const r=1/e;t.x*=r,t.y*=r,t.z*=r}static angleBetween(t,e){let n;const s=Vector3D.unit(t),a=Vector3D.unit(e);if(Vector3D.dot(s,a)<0){const t={x:-s.x-a.x,y:-s.y-a.y,z:-s.z-a.z},e=Vector3D.mag(t);n=Math.PI-2*Math.asin(e/2)}else{const t={x:s.x-a.x,y:s.y-a.y,z:s.z-a.z},e=Vector3D.mag(t);n=2*Math.asin(e/2)}return r*n}}e.Vector3D=Vector3D;class Spherical{static from(t,e,r){return{rho:t.clamp(0,1/0),theta:e.clamp(-180,180),phi:r.clamp(0,360)}}static fromVector(t,e,n){"number"==typeof t&&(t=Vector3D.from(t,e,n));const s=Vector3D.mag(t);if(s.isCloseTo(0))return Spherical.from(0,0,0);const a=Math.atan2(t.x,t.z),o=Math.acos((t.y/s).clamp(-1,1));return Spherical.from(s,a*r,o*r)}static toVector(t){const{rho:e,theta:r,phi:s}=t,a=s*n,o=r*n,i=Math.sin(a)*e;return{x:i*Math.sin(o),y:Math.cos(a)*e,z:i*Math.cos(o)}}static toRotationMatrix(t){const{theta:e,phi:r}=t,s=n*e,a=Math.sin(s),o=Math.cos(s),i=n*r,m=Math.sin(i),c=Math.cos(i);return Matrix3D.from(a*c,a*m,o,0,o*c,o*m,-a,0,-m,c,0,0,0,0,0,1)}}e.Spherical=Spherical;class Matrix3DUtils{static modify(t,e){const{m11:r,m12:n,m13:s,m14:a,m21:o,m22:i,m23:m,m24:c,m31:f,m32:u,m33:l,m34:h,offsetX:y,offsetY:x,offsetZ:g,m44:M}=t,p={m11:r,m12:n,m13:s,m14:a,m21:o,m22:i,m23:m,m24:c,m31:f,m32:u,m33:l,m34:h,offsetX:y,offsetY:x,offsetZ:g,m44:M};return e(p),p}static clone(t){return Matrix3DUtils.modify(t,t=>{})}static multiply(t,e){return Matrix3D.isIdentity(t)?e:Matrix3D.isIdentity(e)?t:Matrix3D.from(t.m11*e.m11+t.m12*e.m21+t.m13*e.m31+t.m14*e.offsetX,t.m11*e.m12+t.m12*e.m22+t.m13*e.m32+t.m14*e.offsetY,t.m11*e.m13+t.m12*e.m23+t.m13*e.m33+t.m14*e.offsetZ,t.m11*e.m14+t.m12*e.m24+t.m13*e.m34+t.m14*e.m44,t.m21*e.m11+t.m22*e.m21+t.m23*e.m31+t.m24*e.offsetX,t.m21*e.m12+t.m22*e.m22+t.m23*e.m32+t.m24*e.offsetY,t.m21*e.m13+t.m22*e.m23+t.m23*e.m33+t.m24*e.offsetZ,t.m21*e.m14+t.m22*e.m24+t.m23*e.m34+t.m24*e.m44,t.m31*e.m11+t.m32*e.m21+t.m33*e.m31+t.m34*e.offsetX,t.m31*e.m12+t.m32*e.m22+t.m33*e.m32+t.m34*e.offsetY,t.m31*e.m13+t.m32*e.m23+t.m33*e.m33+t.m34*e.offsetZ,t.m31*e.m14+t.m32*e.m24+t.m33*e.m34+t.m34*e.m44,t.offsetX*e.m11+t.offsetY*e.m21+t.offsetZ*e.m31+t.m44*e.offsetX,t.offsetX*e.m12+t.offsetY*e.m22+t.offsetZ*e.m32+t.m44*e.offsetY,t.offsetX*e.m13+t.offsetY*e.m23+t.offsetZ*e.m33+t.m44*e.offsetZ,t.offsetX*e.m14+t.offsetY*e.m24+t.offsetZ*e.m34+t.m44*e.m44)}}class Matrix3D{static identity(){return{m11:1,m12:0,m13:0,m14:0,m21:0,m22:1,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,offsetX:0,offsetY:0,offsetZ:0,m44:1}}static from(...t){if(16!==t.length)throw new RangeError("Must provide exactly 16 numbers");return{m11:t[0],m12:t[1],m13:t[2],m14:t[3],m21:t[4],m22:t[5],m23:t[6],m24:t[7],m31:t[8],m32:t[9],m33:t[10],m34:t[11],offsetX:t[12],offsetY:t[13],offsetZ:t[14],m44:t[15]}}static transpose(t){return Matrix3D.from(t.m11,t.m21,t.m31,t.offsetX,t.m12,t.m22,t.m32,t.offsetY,t.m13,t.m23,t.m33,t.offsetZ,t.m14,t.m24,t.m34,t.m44)}static toArray(t){return[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.offsetX,t.offsetY,t.offsetZ,t.m44]}static clone(t,e){return"function"==typeof e?Matrix3DUtils.modify(t,e):Matrix3DUtils.clone(t)}static scale(t,e,r,n){return"number"==typeof e?(r??=e,n??=e):(n=e.z,r=e.y,e=e.x),Matrix3DUtils.modify(t,t=>{t.m11*=e,t.m22*=r,t.m33*=n})}static translate(t,e){return Matrix3DUtils.modify(t,t=>{t.offsetX+=e.x,t.offsetY+=e.y,t.offsetZ+=e.z})}static parse(e){const r=t.parseAsNumericalArray(e);if(r&&16===r.length)return Matrix3D.from.apply(null,r);throw new Error(`Cannot parse "${e}" as a valid Matrix3D.`)}static isIdentity(t){return 1==t.m11&&0==t.m12&&0==t.m13&&0==t.m14&&0==t.m21&&1==t.m22&&0==t.m23&&0==t.m24&&0==t.m31&&0==t.m32&&1==t.m33&&0==t.m34&&0==t.offsetX&&0==t.offsetY&&0==t.offsetZ&&1==t.m44}static isAffine(t){return 0==t.m14&&0==t.m24&&0==t.m34&&1==t.m44}static determinant(t){if(Matrix3D.isIdentity(t))return 1;if(Matrix3D.isAffine(t))return t.m11*(t.m22*t.m33-t.m32*t.m23)-t.m12*(t.m21*t.m33-t.m31*t.m23)+t.m13*(t.m21*t.m32-t.m31*t.m22);{const e=t.m13*t.m24-t.m23*t.m14,r=t.m13*t.m34-t.m33*t.m14,n=t.m13*t.m44-t.offsetZ*t.m14,s=t.m23*t.m34-t.m33*t.m24,a=t.m23*t.m44-t.offsetZ*t.m24,o=t.m33*t.m44-t.offsetZ*t.m34,i=t.m22*r-t.m32*e-t.m12*s,m=t.m12*a-t.m22*n+t.offsetY*e,c=t.m32*n-t.offsetY*r-t.m12*o,f=t.m22*o-t.m32*a+t.offsetY*s;return t.offsetX*i+t.m31*m+t.m21*c+t.m11*f}}static multiply(...t){if(0===t.length)throw new ReferenceError("Matrix not provided.");const e=Array.from(t);let r=e[0];for(let t=1;t<e.length;t++)r=Matrix3DUtils.multiply(r,e[t]);return r}static invert(t){if(Matrix3D.isAffine(t)){const e=Matrix3D.determinant(t);if(0==e)return null;const r=t.m12*t.m23-t.m22*t.m13,n=t.m32*t.m13-t.m12*t.m33,s=t.m22*t.m33-t.m32*t.m23,a=t.m21*t.m13-t.m11*t.m23,o=t.m11*t.m33-t.m31*t.m13,i=t.m31*t.m23-t.m21*t.m33,m=t.m11*t.m22-t.m21*t.m12,c=t.m11*t.m32-t.m31*t.m12,f=t.m11*t.offsetY-t.offsetX*t.m12,u=t.m21*t.m32-t.m31*t.m22,l=t.m21*t.offsetY-t.offsetX*t.m22,h=t.m31*t.offsetY-t.offsetX*t.m32,y=t.m23*f-t.offsetZ*m-t.m13*l,x=t.m13*h-t.m33*f+t.offsetZ*c,g=t.m33*l-t.offsetZ*u-t.m23*h,M=m,p=-c,d=u,b=1/e;return Matrix3D.from(s*b,n*b,r*b,0,i*b,o*b,a*b,0,d*b,p*b,M*b,0,g*b,x*b,y*b,1)}{const e=Matrix3D.determinant(t);if(0==e)return null;const r=t.m33*t.m44-t.m34*t.offsetZ,n=t.m32*t.m44-t.m34*t.offsetY,s=t.m31*t.m44-t.m34*t.offsetX,a=t.m32*t.offsetZ-t.m33*t.offsetY,o=t.m31*t.offsetZ-t.m33*t.offsetX,i=t.m31*t.offsetY-t.m32*t.offsetX,m=t.m33*t.m44-t.m34*t.offsetZ,c=t.m32*t.m44-t.m34*t.offsetY,f=t.m31*t.m44-t.m34*t.offsetX,u=t.m32*t.offsetZ-t.m33*t.offsetY,l=t.m31*t.offsetZ-t.m33*t.offsetX,h=t.m31*t.offsetY-t.m32*t.offsetX,y=t.m23*t.m44-t.m24*t.offsetZ,x=t.m22*t.m44-t.m24*t.offsetY,g=t.m21*t.m44-t.m24*t.offsetX,M=t.m22*t.offsetZ-t.m23*t.offsetY,p=t.m21*t.offsetZ-t.m23*t.offsetX,d=t.m21*t.offsetY-t.m22*t.offsetX,b=t.m23*t.m34-t.m24*t.m33,z=t.m22*t.m34-t.m24*t.m32,w=t.m21*t.m34-t.m24*t.m31,A=t.m22*t.m33-t.m23*t.m32,v=t.m21*t.m33-t.m23*t.m31,D=t.m21*t.m32-t.m22*t.m31,N=t.m22*r-t.m23*n+t.m24*a,P=-(t.m21*r-t.m23*s+t.m24*o),C=t.m21*n-t.m22*s+t.m24*i,V=-(t.m21*a-t.m22*o+t.m23*i),X=-(t.m12*m-t.m13*c+t.m14*u),q=t.m11*m-t.m13*f+t.m14*l,U=-(t.m11*c-t.m12*f+t.m14*h),Y=t.m11*u-t.m12*l+t.m13*h,Z=t.m12*y-t.m13*x+t.m14*M,S=-(t.m11*y-t.m13*g+t.m14*p),L=t.m11*x-t.m12*g+t.m14*d,E=-(t.m11*M-t.m12*p+t.m13*d),Q=-(t.m12*b-t.m13*z+t.m14*A),T=t.m11*b-t.m13*w+t.m14*v,I=-(t.m11*z-t.m12*w+t.m14*D),R=t.m11*A-t.m12*v+t.m13*D,_=1/e;return Matrix3D.from(N*_,X*_,Z*_,Q*_,P*_,q*_,S*_,T*_,C*_,U*_,L*_,I*_,V*_,Y*_,E*_,R*_)}}static transform(t,e){var r={x:t.x,y:t.y,z:t.z};if(!Matrix3D.isIdentity(e)){var n=r.x,s=r.y,a=r.z;if(r.x=n*e.m11+s*e.m21+a*e.m31+e.offsetX,r.y=n*e.m12+s*e.m22+a*e.m32+e.offsetY,r.z=n*e.m13+s*e.m23+a*e.m33+e.offsetZ,!Matrix3D.isAffine(e)){var o=n*e.m14+s*e.m24+a*e.m34+e.m44;0!=o&&(r.x/=o,r.y/=o,r.z/=o)}}return r}}e.Matrix3D=Matrix3D;class Quaternion{static identity(){return Quaternion.from(0,0,0,1)}static from(...t){if(4!==t.length)throw new RangeError("Must provide exactly 4 numbers");return{x:t[0],y:t[1],z:t[2],w:t[3]}}static parse(e){const r=t.parseAsNumericalArray(e);if(r&&4===r.length)return Quaternion.from.apply(null,r);throw new Error(`Cannot parse "${e}" as a valid Quaternion.`)}static fromVectors(t,e){Vector3D.normalize(t),Vector3D.normalize(e);const r=(t,e,r,n)=>{const s=Quaternion.from(t,e,r,n);return Quaternion.normalize(s),s};let n=Vector3D.dot(t,e)+1;return n.isCloseTo(0)?Math.abs(t.x)>Math.abs(t.z)?r(-t.y,t.x,0,0):r(0,-t.z,t.y,0):r(t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z,t.x*e.y-t.y*e.x,n)}static normalize(t){const e=Quaternion.mag(t);if(e.isCloseTo(0))t.x=t.y=t.z=0,t.w=1;else{const r=1/e;t.x*=r,t.y*=r,t.z*=r,t.w*=r}}static unit(t){const e=Quaternion.from(t.x,t.y,t.z,t.w);return Quaternion.normalize(e),e}static fromAxisAngle(t,e){var r=n*(e%=360),s=Vector3D.mag(t);if(0==s)throw new RangeError("Invalid argument");var a=Math.sin(.5*r)/s,o=t.x*a,i=t.y*a,m=t.z*a;return Quaternion.from(o,i,m,Math.cos(.5*r))}static fromRotationMatrix(t){const e=t.m11+t.m22+t.m33+t.m44;if(e>0){const r=.5/Math.sqrt(e),n=.25/r,s=(t.m23-t.m32)*r,a=(t.m31-t.m13)*r,o=(t.m12-t.m21)*r;return Quaternion.from(s,a,o,n)}if(t.m11>t.m22&&t.m11>t.m22){const e=.5/Math.sqrt(t.m44+t.m11-t.m22-t.m33),r=(t.m23-t.m32)*e,n=.25/e,s=(t.m12+t.m21)*e,a=(t.m31+t.m13)*e;return Quaternion.from(n,s,a,r)}if(t.m22>t.m33){const e=.5/Math.sqrt(t.m44+t.m22-t.m11-t.m33),r=(t.m23+t.m32)*e,n=.25/e,s=(t.m12+t.m21)*e,a=(t.m31-t.m13)*e;return Quaternion.from(s,n,r,a)}{const e=.5/Math.sqrt(t.m44+t.m33-t.m11-t.m22),r=(t.m23+t.m32)*e,n=.25/e,s=(t.m12-t.m21)*e,a=(t.m31-t.m13)*e;return Quaternion.from(a,r,n,s)}}static conjugate(t){return Quaternion.from(-t.x,-t.y,-t.z,t.w)}static mag(t){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w)}static norm(t){return t.x*t.x+t.y*t.y+t.z*t.z}static axis(t){return 0==t.x&&0==t.y&&0==t.z?Vector3D.j():Vector3D.unit(t)}static transform(t,e){Quaternion.normalize(e);const r=Vector3D.cross(e,t),n=Vector3D.scale(r,2),s=Vector3D.cross(e,n);return{x:t.x+e.w*n.x+s.x,y:t.y+e.w*n.y+s.y,z:t.z+e.w*n.z+s.z}}static angle(t){let e=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z),r=t.w;if(e>Number.MAX_VALUE){const n=Math.max(Math.abs(t.x),Math.max(Math.abs(t.y),Math.abs(t.z))),s=t.x/n,a=t.y/n,o=t.z/n;e=Math.sqrt(s*s+a*a+o*o),r/=n}return 114.59155902616465*Math.atan2(e,r)}static toRotationMatrix(t){var e=Matrix3D.identity(),r=t.x,n=t.y,s=t.z,a=t.w;return e.m11=1-2*n*n-2*s*s,e.m12=2*r*n+2*a*s,e.m13=2*r*s-2*a*n,e.m21=2*r*n-2*a*s,e.m22=1-2*r*r-2*s*s,e.m23=2*n*s+2*a*r,e.m31=2*a*n+2*r*s,e.m32=2*n*s-2*a*r,e.m33=1-2*r*r-2*n*n,e}static invert(t){const e=Quaternion.unit(t);return Quaternion.conjugate(e)}static multiply(t,e){return Quaternion.from(t.w*e.x+t.x+e.w+t.y*e.z-t.z*e.y,t.w*e.y-t.x*e.z+t.y*e.w+t.z*e.x,t.w*e.z+t.x*e.y-t.y*e.x+t.z*e.w,t.w*e.w-t.x*e.x-t.y*e.y-t.z*e.z)}static dot(t,e){return Quaternion.multiply(t,Quaternion.conjugate(e)).w}}e.Quaternion=Quaternion}(e.LinearAlgebra||(e.LinearAlgebra={}))}(t.Geometry||(t.Geometry={}))}(Pacem||(Pacem={})),function(t){!function(e){const r=t.Geometry.LinearAlgebra.Vector3D;t.Geometry.LinearAlgebra.Matrix3D;e.Utils3D=class Utils3D{static intersect(t,e){const[n,s]=t,a=r.subtract(n,s),[o,i,m]=e,c=r.subtract(o,i),f=r.subtract(o,m),u=r.cross(a,f),l=r.dot(c,u);if(l.isCloseTo(0))return null;const h=1/l,y=r.subtract(n,o),x=h*r.dot(y,u);if(x<0||x>1)return null;const g=r.cross(y,c),M=h*r.dot(a,g);if(M<0||x+M>1)return null;const p=h*r.dot(f,g);return p<0||p.isCloseTo(0)?null:r.add(n,r.scale(a,p))}}}(t.Geometry||(t.Geometry={}))}(Pacem||(Pacem={})),function(t){!function(e){class Polygon{static isPolygon(e){return function(e){let r;return"vertices"in e&&Array.isArray(e.vertices)&&(r=e.vertices).length>=3&&r.every(e=>t.Point.isPoint(e))}(e)}static from(...t){return{vertices:Array.from(t)}}static contains(t,r){return e.Utils.inPolygon(r,t.vertices,12)}static centroid(t){const e=Polygon.boundingBox(t);return{x:e.x+e.width/2,y:e.y+e.height/2}}static boundingBox(t){let e=Number.MAX_VALUE,r=Number.MAX_VALUE,n=-Number.MAX_VALUE,s=-Number.MAX_VALUE;const{vertices:a}=t;a.length;for(let t of a)e=Math.min(e,t.x),r=Math.min(r,t.y),n=Math.max(n,t.x),s=Math.max(s,t.y);return{x:e,y:r,width:n-e,height:s-r}}static sides(t){const{vertices:e}=t,r=[];for(let t=1;t<=e.length;t++){const n=e[t%e.length],s=e[t-1];r.push([s,n])}return r}static isConvex(e){const{vertices:r}=e,n=r.length;if(n<=3)return!0;let s=0;for(let e=0;e<r.length;e++){const a=r[(e-1+n)%n],o=r[e],i=r[(e+1)%n],m=t.Angle.angleBetween(o,a,i);if(0!==s){if(s!=Math.sign(m))return!1}else s=Math.sign(m)}return!0}static isSelfIntersecting(r){const{vertices:n}=r;if(n.length<=3)return!1;const s=Polygon.sides(r);for(let r of s)for(let n of s){if(n===r||n[0]===r[1]||r[0]===n[1])continue;const s=e.Utils.intersect(n,r);if(!t.NullChecker.isNull(s))return!0}return!1}static isCounterClockwise(e){const{vertices:[r,n,s]}=e;return t.Angle.angleBetween(n,r,s)>0}static expand(r,n){const{vertices:s}=r,a=s.length,o=[];for(let r=0;r<s.length;r++){const i=s[(r-1+a)%a],m=s[r],c=s[(r+1)%a],f=t.Angle.angleBetween(m,i,c),u=-n/Math.sin(Math.abs(f)/2),l=t.Matrix2D.scale(t.Matrix2D.identity,u),h=t.Point.subtract(m,i);e.LinearAlgebra.Vector.normalize(h);const y=t.Point.subtract(m,c);e.LinearAlgebra.Vector.normalize(y);const x=t.Point.add(h,y);e.LinearAlgebra.Vector.normalize(x);const g=t.Matrix2D.multiply(x,l);o.push(t.Point.add(m,{x:g.x.roundoff(),y:g.y.roundoff()}))}return{vertices:o}}static area(t){return e.Utils.area(t.vertices)}static convexHull(t){return{vertices:e.Utils.convexHull(t.vertices)}}}e.Polygon=Polygon}(t.Geometry||(t.Geometry={}))}(Pacem||(Pacem={})),function(t){!function(t){function e(t){return"number"==typeof t&&(t={real:t,img:0}),t}var r;function n(t,e){const r={};return Object.defineProperty(r,"real",{value:t,writable:!1}),Object.defineProperty(r,"img",{value:e,writable:!1}),r}function s(){return r||(r=n(Number.NaN,Number.NaN))}t.Complex=class Complex{static build(t,e){return this.isComplex(t)?t:(e??=0,"number"!=typeof t||"number"!=typeof e?s():n(t,e||0))}static add(t,r){const s=e(t),a=e(r);return n(s.real+a.real,s.img+a.img)}static subtract(t,r){const s=e(t),a=e(r);return n(s.real-a.real,s.img-a.img)}static multiply(t,r){const s=e(t),a=e(r);return n(s.real*a.real-s.img*a.img,s.real*a.img+s.img*a.real)}static divide(t,r){const a=e(t),o=e(r),i=this.absSquare(o).roundoff();if(0===i)return s();const m=1/i;return n(m*(a.real*o.real+a.img*o.img),m*(a.img*o.real-a.real*o.img))}static absSquare(t){const r=e(t);return Math.pow(r.real,2)+Math.pow(r.img,2)}static modulus(t){return Math.sqrt(this.absSquare(t))}static isComplex(t){return null!=t&&"object"==typeof t&&"real"in t&&"img"in t&&"number"==typeof t.real&&"number"==typeof t.img}static conjugate(t){return n((t=e(t)).real,0==Math.abs(t.img)?0:-t.img)}static equals(t,e){const r=this.build(t),n=this.build(e);return!(!this.isComplex(t)||!this.isComplex(e))&&(r.real===n.real&&r.img===n.img)}static get NaC(){return s()}}}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={})),function(t){!function(t){!function(e){const r={};function n(e,n){const s=r[n]=r[n]||{};return s[e]=s[e]||function(e,r){const n=2*Math.PI*e/r;return t.Complex.build(Math.cos(n),Math.sin(n))}(e,n)}function s(e){const r=[],a=e.length;if(1===a)return[t.Complex.build(e[0])];const o=s(e.filter((t,e)=>e%2==0)),i=s(e.filter((t,e)=>e%2==1));for(var m=0;m<a/2;m++){const e=o[m],s=t.Complex.multiply(n(m,a),i[m]);r[m]=t.Complex.add(e,s),r[m+a/2]=t.Complex.subtract(e,s)}return r}e.Fourier=class Fourier{static transform(t,e=!0){return(r=(t=t||[]).length)>0&&!(r&r-1)?this.fft(t,e):this.dft(t,e);var r}static invert(t,e=!0){return this.idft(t||[],e)}static dft(e,r=!0){const s=(e||[])?.length,a=r?1/Math.sqrt(s):1,o=[];for(let r=0;r<s;r++){o.push({real:0,img:0});for(let i=0;i<s;i++){const m=n(r*i,s),c=t.Complex.multiply(e[i],m),f=t.Complex.multiply(c,a);o[r]=t.Complex.add(o[r],f)}}return o}static idft(e,r=!0){const n=e.map(e=>t.Complex.build(e.img,e.real));return this.transform(n,r).map(e=>t.Complex.build(e.img,e.real))}static fft(e,r=!0){const n=s(e);if(!r)return n;const a=1/Math.sqrt(e.length);return n.map(e=>t.Complex.multiply(e,a))}}}(t.DataAnalysis||(t.DataAnalysis={}))}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={})),function(t){!function(t){!function(t){const e=Math.sqrt(Math.PI);function r(t){const e=Math.abs(t),r=1/(1+.5*e),n=r*Math.exp(-e*e-1.26551223+r*(1.00002368+r*(.37409196+r*(.09678418+r*(r*(.27886807+r*(r*(1.48851587+r*(.17087277*r-.82215223))-1.13520398))-.18628806)))));return t>=0?n:2-n}class Gaussian{constructor(t,e){this.mean=t,this.stdev=Math.abs(e),this.variance=Math.pow(e,2)}mean;stdev;variance;static get normal(){return n}weight(t){return Math.exp(-.5*Math.pow(this._z(t),2))}probabilityDensity(t){const r=this.stdev*Math.SQRT2*e;return this.weight(t)/r}_z(t){return(t-this.mean)/this.stdev}probability(t){return.5*r(-this._z(t)/Math.SQRT2)}}t.Gaussian=Gaussian;const n=new Gaussian(0,1)}(t.DataAnalysis||(t.DataAnalysis={}))}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={})),function(t){!function(t){!function(t){class Lagrangian{constructor(...t){this.#t=Array.from(t)||[]}#t;#e;_unsafeCreate(){const t=this.#t||[];let e,r="var ljs = [];\n";for(let n=0;n<t.length;n++){const s=t[n],a=s.x;if(null!=e&&e>=a)throw new Error("Invalid function provided.");e=a,r+=`ljs.push( ${s.y}`;for(let e=0;e<t.length;e++)if(e!==n){const n=t[e];r+=` * ((x - ${n.x})/${a-n.x})`}r+=");\n"}r+="return ljs.reduce((prev, next) => prev + next, 0);",this.#e=new Function("x",r)}_compute(t){const e=this.#t||[];let r;const n=[];for(let s=0;s<e.length;s++){const a=e[s].x;if(null!=r&&r>=a)throw new Error("Invalid function provided.");r=a;let o=e[s].y;for(let r=0;r<e.length;r++)if(r!==s){const n=e[r];o*=(t-n.x)/(a-n.x)}n.push(o)}return n.reduce((t,e)=>t+e,0)}interpolate(t){return"function"==typeof this.#e?this.#e.apply(null,[t]):this._compute(t)}static create(...t){const e=(arguments.length>0&&Array.isArray(arguments[0])?arguments[0]:Array.from(t)).map((t,e)=>"number"==typeof t?{x:e,y:t}:t),r=new(Function.prototype.bind.apply(Lagrangian,[null].concat(e)));try{r._unsafeCreate()}catch(t){}return r}}t.Lagrangian=Lagrangian}(t.DataAnalysis||(t.DataAnalysis={}))}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={})),function(t){!function(e){!function(e){const r="0123456789abcdefghijklmnopqrstuvwxyz",n="Radix out of range: possible values go between positive 1 exclusive and 36 inclusive";class Utils{static lcd(...e){if(t.NullChecker.isNullOrEmpty(e)||e.length<=1)throw"Insufficient set of numbers.";function r(t,e){return e?r(e,t%e):0===e?t:NaN}function n(t,e){return t*e/r(t,e)}let s=Math.round(e[0]);for(let t=1;t<e.length;t++)s=n(s,Math.round(e[t]));return s}static gcd(t,e){return t=Math.round(t),e=Math.round(e),0===t?e:Utils.gcd(e%t,t)}static rebaseInt(e,r,n){return t.Numbers.rebase(e,r,n)}static rebaseFloat(t,e,r,n=12){const s=Utils.rebaseFloat10ToN,a=Utils.rebaseFloatNTo10;if(10===e){const e=parseFloat(t.toString());return r%1==0?Utils.rebaseFloat10ToNIntBase(e,r,n):s(e,r,n)}if(10===r)return a(t.toString(),e,n);return s(a(t.toString(),e,n+1),r,n)}static rebaseFloatNTo10(t,e,s=12){const a=r;if(e<=1||e>a.length)throw new Error(n);const o=(t??"0").toString().toLowerCase(),i=Number.NaN;if("0"===o)return 0;const m=/^([-+]?) *([\da-z]+)?(.[\da-z]+)?$/.exec(o);if(m.length<2)return i;const c="-"===m[1]?-1:1,f=m[2]||"0",u=m[3]||".0";let l=0,h=0;for(let t of f+u.substr(1)){const r=a.indexOf(t);if(-1===r||r>=e)return i;l+=r*Math.pow(e,f.length-h-1),h++}return c*l}static rebaseFloat10ToNIntBase(t,e,s=12){const a=r;if(e<=1||e>36)throw new Error(n);const o=e;let i=Math.abs(t??0);if(0===i||Number.isNaN(i))return t.toString();let m=(i%1).roundoff(),c="";for(;;){let t=i/o,e=Math.floor(t),r=(i-e*o).roundoff(),n=Math.floor(r);if(c=n>=36?`[${n}]`+c:a[n]+c,e<=0)break;i=e}if(c=c.replace(/^0+/,""),c||="0",0===m)return c;let f="";do{i=(m*o).roundoff();const t=Math.floor(i),e=(i-t).roundoff();t>=36?f=`[${t}]`:f+=a[t],m=e}while(!m.isCloseTo(0)&&f.length<s);return/^0*$/.test(f)?c:(Math.sign(t)<0?"-":"")+c+"."+f.replace(/0+$/,"")}static rebaseFloat10ToN(e,s,a=12){const o=r;if(s<=1||s>o.length)throw new Error(n);const i=s;let m=Math.abs(e??0);if(0===m||Number.isNaN(m))return e.toString();let c=Math.sign(e)<0?"-":"",f=[],u=[];for(let t=0;t<20;t++)f.push("0"),u.push("0");const l=i%1==0?i:Math.ceil(i);function h(t,e,r){const n=t?f:u,s=n[e]=n[e]||"0",a=o.indexOf(s)+r,i=a%l,m=Math.floor(a/l);return n[e]=o[i],m>0&&(t?h(t,e+1,m):0===e?h(!0,0,m):h(!1,e-1,m)),m}let y=0;for(;;){const e=Math.floor(t.Numbers.log(m,i)),r=e>=0;if(h(r,r?e:Math.abs(1+e),1),m=(m-Math.pow(i,e).roundoff()).roundoff(),r||y++,0===m||y>=100){const t=c+(f.reverse().map(t=>t||"0").join("").replace(/^0+/,"")||"0"),e=u.map(t=>t||"0").join("").substr(0,a).replace(/0+$/,"");return/^0*$/.test(e)?t:t+"."+e}}}}e.Utils=Utils}(e.NumberTheory||(e.NumberTheory={}))}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={})),function(t){!function(t){!function(t){const e=(t,e)=>t;function r(t,r=e){return t.reduce((t,e,n)=>t+r(e,n),0)}function n(t,n=e){return r(t,n)/t.length}function s(t,r=e,s=!1){const a=n(t,r);return t.reduce((t,e)=>Math.pow(e-a,2)+t,0)/(t.length-(s?1:0))}function a(t,r=e,n=!1){const a=s(t,r,n);return Math.sqrt(a)}function o(t,e){return(r,n,s,a)=>{let o=r,i=n,m=t(o,i),c=e(o,i),f=s(m),u=s(c);for(;i-o>a;)f<u?(i=c,c=m,u=f,m=t(o,i),f=s(m)):(o=m,m=c,f=u,c=e(o,i),u=s(c));return.5*(m+c)}}t.Utils=class Utils{static sum(t,e){return r(t,e)}static mean(t,e){return n(t,e)}static median(t,r){return function(t,r=e){const n=t.slice(0),s=n.length;n.sort((t,e)=>r(t)-r(e));const a=Math.ceil(n.length/2)-1;return s%2==1?n[a]:.5*(n[a+1]+n[a])}(t,r)}static mode(t,r){return function(t,r=e){const n=Object.groupBy(t,r);let s,a=0;for(let t in n){const e=n[t].length;e>a&&(s=parseInt(t),a=e)}return s}(t,r)}static var(t,e){return s(t,e,!0)}static varp(t,e){return s(t,e,!1)}static stdevp(t,e){return a(t,e,!1)}static stdev(t,e){return a(t,e,!0)}static correlation(t,r,s,a){return function(t,r,s=e,a=e){const o=Array.isArray(r);if(o&&r.length!==t.length)throw new Error("Sets must be of the same length.");const i=t.length,m=t,c=o?r:t,f=o?s:r,u=o?a:s,l=n(m,f),h=n(c,u);let y=0,x=0,g=0;for(let t=0;t<i;t++){const e=m[t],r=c[t],n=f(e,t)-l,s=u(r,t)-h;y+=n*s,x+=n*n,g+=s*s}return y/Math.sqrt(x*g)}(t,r,s,a)}static linearRegression(t,r,n,s){return function(t,r,n=e,s=e){const a=Array.isArray(r);if(a&&r.length!==t.length)throw new Error("Sets must be of the same length.");const o=t,i=a?r:t,m=a?n:r,c=m??(t=>t.x),f=(a?s:m)??(t=>t.y),u=t.length;let l=0,h=0,y=0,x=0,g=0;for(let t=0;t<u;t++){const e=o[t],r=i[t],n=c(e,t),s=f(r,t);l+=n*s,h+=n,y+=s,x+=n*n,g+=s*s}const M=(u*l-h*y)/(u*x-Math.pow(h,2));return[M,(y-M*h)/u]}(t,r,n,s)}static gaussian(e,r){return new t.Gaussian(e,r)}};t.SearchFunctions={linear:(t=2)=>function(t){if(t<=1)throw new RangeError("segments must be a number grater than 1.");return(e,r,n,s=.001)=>o((e,r)=>e+(r-e)/t,(e,r)=>r-(r-e)/t)(e,r,n,s)}(t),goldenRatio:(t,e,r,n=.001)=>o((t,e)=>e-(e-t)/1.618,(t,e)=>t+(e-t)/1.618)(t,e,r,n),gaussian:(t,e,r,n=.001)=>{var s=null,a=null;const i=(t,e)=>(a??=e-t,s??=a/Math.sqrt(12),s*(e-t)/a);return o((t,e)=>Math.max(t,(e+t)/2-i(t,e)),(t,e)=>Math.min(e,(e+t)/2+i(t,e)))(t,e,r,n)}}}(t.DataAnalysis||(t.DataAnalysis={}))}(t.Mathematics||(t.Mathematics={}))}(Pacem||(Pacem={}));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * pacem v0.53.0-selberg (https://js.pacem.it)
2
+ * pacem v0.53.0-stevin (https://js.pacem.it)
3
3
  * Copyright 2026 Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.53.0-selberg",
2
+ "version": "0.53.0-stevin",
3
3
  "name": "pacem",
4
4
  "homepage": "https://js.pacem.it",
5
5
  "repository": {