@syncfusion/ej2-pdfviewer
Version:
Essential JS 2 PDF viewer Component
1,367 lines (1,361 loc) • 7.99 MB
JavaScript
import { Property, ChildProperty, Collection, ComplexFactory, createElement, Browser, Complex, isNullOrUndefined, getValue, compile, isBlazor, SanitizeHtmlHelper, initializeTelemetryFeature, Internationalization, initializeCSPTemplate, classList, enableRipple, closest, initializeTelemetry, L10n, Event, NotifyPropertyChanges, Component, Draggable, Droppable, getComponent } from '@syncfusion/ej2-base';
import { NumericTextBox, Slider, ColorPicker, TextBox } from '@syncfusion/ej2-inputs';
import { Dialog, Tooltip } from '@syncfusion/ej2-popups';
import { DropDownButton, SplitButton } from '@syncfusion/ej2-splitbuttons';
import { InPlaceEditor } from '@syncfusion/ej2-inplace-editor';
import { Accordion, ContextMenu as ContextMenu$1, Toolbar as Toolbar$1, Tab, Menu, TreeView } from '@syncfusion/ej2-navigations';
import { Toast } from '@syncfusion/ej2-notifications';
import { MultiSelect, CheckBoxSelection, DropDownList, ComboBox, AutoComplete } from '@syncfusion/ej2-dropdowns';
import { _decode, PdfTrueTypeFont, PdfFontStyle, PdfDocument, PdfSignatureField, PdfFreeTextAnnotation, PdfFontFamily, PdfStandardFont, PdfTextAlignment, PdfAnnotationFlag, PdfRotationAngle, PdfRubberStampAnnotation, PdfBitmap, PdfTextBoxField, PdfComboBoxField, PdfCheckBoxField, PdfListBoxField, PdfRadioButtonListField, PdfListFieldItem, PdfRadioButtonListItem, PdfPath, PdfInkAnnotation, PdfFormFieldVisibility, PdfButtonField, PdfPageImportOptions, _stringToBytes, _ContentParser, PdfPageSettings, PdfMargins, _encode, PdfAnnotationStateModel, PdfAnnotationState, PdfTextMarkupAnnotation, PdfLineAnnotation, PdfSquareAnnotation, PdfRectangleAnnotation, PdfCircleAnnotation, PdfEllipseAnnotation, PdfPolygonAnnotation, PdfPolyLineAnnotation, PdfAngleMeasurementAnnotation, PdfRedactionAnnotation, PdfPopupAnnotation, PdfPermissionFlag, DataFormat, PdfAnnotationExportSettings, PdfTextStyle, PdfUriAnnotation, PdfTextWebLinkAnnotation, PdfDocumentLinkAnnotation, PdfFormFieldExportSettings, PdfAnnotationBorder, PdfBorderEffect, PdfBorderEffectStyle, _PdfDictionary, _PdfName, PdfLineEndingStyle, PdfAnnotationIntent, PdfTextMarkupAnnotationType, PdfTemplate, PdfBrush, PdfPen, PdfLineIntent, PdfCircleMeasurementType, PdfPopupIcon, PdfStringFormat, PdfVerticalAlignment, PdfMeasurementUnit, PdfRubberStampAnnotationIcon, PdfLineCaptionType, PdfBorderStyle, _annotationFlagsToString } from '@syncfusion/ej2-pdf';
import { CheckBox, Button, RadioButton } from '@syncfusion/ej2-buttons';
import { Query } from '@syncfusion/ej2-data';
import { ListView } from '@syncfusion/ej2-lists';
import { PdfRedactor } from '@syncfusion/ej2-pdf-data-extract';
var __extends = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
* @param {Gradient} obj - obj
* @private
* @returns {Object} - Object
*/
var getGradientType = function (obj) {
switch (obj.type) {
case 'Linear':
return LinearGradient;
case 'Radial':
return RadialGradient;
default:
return LinearGradient;
}
};
/**
* @hidden
* Defines the space to be left between an object and its immediate parent
*/
var Margin = /** @__PURE__ @class */ (function (_super) {
__extends(Margin, _super);
function Margin() {
return _super !== null && _super.apply(this, arguments) || this;
}
__decorate([
Property(0)
], Margin.prototype, "left", void 0);
__decorate([
Property(0)
], Margin.prototype, "right", void 0);
__decorate([
Property(0)
], Margin.prototype, "top", void 0);
__decorate([
Property(0)
], Margin.prototype, "bottom", void 0);
return Margin;
}(ChildProperty));
/**
* Defines the different colors and the region of color transitions
* ```html
* <div id='diagram'></div>
* ```
* ```typescript
* let stopscol: StopModel[] = [];
* let stops1: StopModel = { color: 'white', offset: 0, opacity: 0.7 };
* stopscol.push(stops1);
* let stops2: StopModel = { color: 'red', offset: 0, opacity: 0.3 };
* stopscol.push(stops2);
* let gradient: RadialGradientModel = { cx: 50, cy: 50, fx: 50, fy: 50, stops: stopscol, type: 'Radial' };
* let nodes: NodeModel[] = [{ id: 'node1', width: 100, height: 100,
* style: { gradient: gradient }
* }];
* let diagram: Diagram = new Diagram({
* ...
* nodes: nodes,
* ...
* });
* diagram.appendTo('#diagram');
* ```
*/
/**
* @hidden
* Represents a gradient stop that defines a specific color
*/
var Stop = /** @__PURE__ @class */ (function (_super) {
__extends(Stop, _super);
function Stop() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @private
* @returns {string} - Returns the name of class Stop
*/
Stop.prototype.getClassName = function () {
return 'Stop';
};
__decorate([
Property('')
], Stop.prototype, "color", void 0);
__decorate([
Property(0)
], Stop.prototype, "offset", void 0);
__decorate([
Property(1)
], Stop.prototype, "opacity", void 0);
return Stop;
}(ChildProperty));
/**
* @hidden
* Paints the node with a smooth transition from one color to another color
*/
var Gradient = /** @__PURE__ @class */ (function (_super) {
__extends(Gradient, _super);
function Gradient() {
return _super !== null && _super.apply(this, arguments) || this;
}
__decorate([
Collection([], Stop)
], Gradient.prototype, "stops", void 0);
__decorate([
Property('None')
], Gradient.prototype, "type", void 0);
__decorate([
Property('')
], Gradient.prototype, "id", void 0);
return Gradient;
}(ChildProperty));
/**
* Defines the linear gradient of styles
* ```html
* <div id='diagram'></div>
* ```
* ```typescript
* let stopscol: StopModel[] = [];
* let stops1: StopModel = { color: 'white', offset: 0, opacity: 0.7 };
* stopscol.push(stops1);
* let stops2: StopModel = { color: 'red', offset: 0, opacity: 0.3 };
* stopscol.push(stops2);
* let gradient: LinearGradientModel = { x1: 0, x2: 50, y1: 0, y2: 50, stops: stopscol, type: 'Linear' };
* let nodes: NodeModel[] = [{ id: 'node1', width: 100, height: 100,
* style: { gradient: gradient }
* }];
* let diagram: Diagram = new Diagram({
* ...
* nodes: nodes,
* ...
* });
* diagram.appendTo('#diagram');
* ```
*/
/**
* @hidden
* Paints the node with linear color transitions
*/
var LinearGradient = /** @__PURE__ @class */ (function (_super) {
__extends(LinearGradient, _super);
function LinearGradient() {
return _super !== null && _super.apply(this, arguments) || this;
}
__decorate([
Property(0)
], LinearGradient.prototype, "x1", void 0);
__decorate([
Property(0)
], LinearGradient.prototype, "x2", void 0);
__decorate([
Property(0)
], LinearGradient.prototype, "y1", void 0);
__decorate([
Property(0)
], LinearGradient.prototype, "y2", void 0);
return LinearGradient;
}(Gradient));
/**
* A focal point defines the beginning of the gradient, and a circle defines the end point of the gradient
* ```html
* <div id='diagram'></div>
* ```
* ```typescript
* let stopscol: StopModel[] = [];
* let stops1: StopModel = { color: 'white', offset: 0, opacity: 0.7 };
* stopscol.push(stops1);
* let stops2: StopModel = { color: 'red', offset: 0, opacity: 0.3 };
* stopscol.push(stops2);
* let gradient: RadialGradientModel = { cx: 50, cy: 50, fx: 50, fy: 50, stops: stopscol, type: 'Radial' };
* let nodes: NodeModel[] = [{ id: 'node1', width: 100, height: 100,
* style: { gradient: gradient }
* }];
* let diagram: Diagram = new Diagram({
* ...
* nodes: nodes,
* ...
* });
* diagram.appendTo('#diagram');
* ```
*/
/**
* @hidden
*/
var RadialGradient = /** @__PURE__ @class */ (function (_super) {
__extends(RadialGradient, _super);
function RadialGradient() {
return _super !== null && _super.apply(this, arguments) || this;
}
__decorate([
Property(0)
], RadialGradient.prototype, "cx", void 0);
__decorate([
Property(0)
], RadialGradient.prototype, "cy", void 0);
__decorate([
Property(0)
], RadialGradient.prototype, "fx", void 0);
__decorate([
Property(0)
], RadialGradient.prototype, "fy", void 0);
__decorate([
Property(50)
], RadialGradient.prototype, "r", void 0);
return RadialGradient;
}(Gradient));
/**
* @hidden
* Defines the style of shape/path
*/
var ShapeStyle = /** @__PURE__ @class */ (function (_super) {
__extends(ShapeStyle, _super);
function ShapeStyle() {
return _super !== null && _super.apply(this, arguments) || this;
}
__decorate([
Property('white')
], ShapeStyle.prototype, "fill", void 0);
__decorate([
Property('black')
], ShapeStyle.prototype, "strokeColor", void 0);
__decorate([
Property('')
], ShapeStyle.prototype, "strokeDashArray", void 0);
__decorate([
Property(1)
], ShapeStyle.prototype, "strokeWidth", void 0);
__decorate([
Property(1)
], ShapeStyle.prototype, "opacity", void 0);
__decorate([
ComplexFactory(getGradientType)
], ShapeStyle.prototype, "gradient", void 0);
return ShapeStyle;
}(ChildProperty));
/**
* @hidden
* Defines the stroke style of a path
*/
var StrokeStyle = /** @__PURE__ @class */ (function (_super) {
__extends(StrokeStyle, _super);
function StrokeStyle() {
return _super !== null && _super.apply(this, arguments) || this;
}
__decorate([
Property('transparent')
], StrokeStyle.prototype, "fill", void 0);
return StrokeStyle;
}(ShapeStyle));
/**
* @hidden
* Defines the appearance of text
* ```html
* <div id='diagram'></div>
* ```
* ```typescript
* let style: TextStyleModel = { strokeColor: 'black', opacity: 0.5, strokeWidth: 1 };
* let node: NodeModel;
* node = {
* ...
* id: 'node', width: 100, height: 100, offsetX: 100, offsetY: 100,
* annotations : [{
* content: 'text', style: style }];
* ...
* };
* let diagram: Diagram = new Diagram({
* ...
* nodes: [node],
* ...
* });
* diagram.appendTo('#diagram');
* ```
*/
var TextStyle = /** @__PURE__ @class */ (function (_super) {
__extends(TextStyle, _super);
function TextStyle() {
return _super !== null && _super.apply(this, arguments) || this;
}
__decorate([
Property('black')
], TextStyle.prototype, "color", void 0);
__decorate([
Property('Arial')
], TextStyle.prototype, "fontFamily", void 0);
__decorate([
Property(12)
], TextStyle.prototype, "fontSize", void 0);
__decorate([
Property(false)
], TextStyle.prototype, "italic", void 0);
__decorate([
Property(false)
], TextStyle.prototype, "bold", void 0);
__decorate([
Property('CollapseSpace')
], TextStyle.prototype, "whiteSpace", void 0);
__decorate([
Property('WrapWithOverflow')
], TextStyle.prototype, "textWrapping", void 0);
__decorate([
Property('Center')
], TextStyle.prototype, "textAlign", void 0);
__decorate([
Property('None')
], TextStyle.prototype, "textDecoration", void 0);
__decorate([
Property('Wrap')
], TextStyle.prototype, "textOverflow", void 0);
__decorate([
Property('transparent')
], TextStyle.prototype, "fill", void 0);
return TextStyle;
}(ShapeStyle));
/**
* enum module defines the public enumerations
*/
/**
* @hidden
* Defines the container/canvas transform
* Self - Sets the transform type as Self
* Parent - Sets the transform type as Parent
*/
var RotateTransform;
(function (RotateTransform) {
/** Self - Sets the transform type as Self */
RotateTransform[RotateTransform["Self"] = 1] = "Self";
/** Parent - Sets the transform type as Parent */
RotateTransform[RotateTransform["Parent"] = 2] = "Parent";
})(RotateTransform || (RotateTransform = {}));
/**
* @hidden
* Enables/Disables The element actions
* None - Diables all element actions are none
* ElementIsPort - Enable element action is port
* ElementIsGroup - Enable element action as Group
* @private
*/
var ElementAction;
(function (ElementAction) {
/** Disables all element actions are none */
ElementAction[ElementAction["None"] = 0] = "None";
/** Enable the element action is Port */
ElementAction[ElementAction["ElementIsPort"] = 2] = "ElementIsPort";
/** Enable the element action as Group */
ElementAction[ElementAction["ElementIsGroup"] = 4] = "ElementIsGroup";
})(ElementAction || (ElementAction = {}));
/**
* @hidden
* Defines the constraints to enable/disable certain features of connector.
* * None - Interaction of the connectors cannot be done.
* * Select - Selects the connector.
* * Delete - Delete the connector.
* * Drag - Drag the connector.
* * DragSourceEnd - Drag the source end of the connector.
* * DragTargetEnd - Drag the target end of the connector.
* * DragSegmentThump - Drag the segment thumb of the connector.
* * AllowDrop - Allow to drop a node.
* * Bridging - Creates bridge on intersection of two connectors.
* * BridgeObstacle -
* * InheritBridging - Creates bridge on intersection of two connectors.
* * PointerEvents - Sets the pointer events.
* * Tooltip - Displays a tooltip for the connectors.
* * InheritToolTip - Displays a tooltip for the connectors.
* * Interaction - Features of the connector used for interaction.
* * ReadOnly - Enables ReadOnly
* * Default - Default features of the connector.
* @aspNumberEnum
* @IgnoreSingular
*/
var ConnectorConstraints;
(function (ConnectorConstraints) {
/** Disable all connector Constraints. */
ConnectorConstraints[ConnectorConstraints["None"] = 1] = "None";
/** Enables connector to be selected. */
ConnectorConstraints[ConnectorConstraints["Select"] = 2] = "Select";
/** Enables connector to be Deleted. */
ConnectorConstraints[ConnectorConstraints["Delete"] = 4] = "Delete";
/** Enables connector to be Dragged. */
ConnectorConstraints[ConnectorConstraints["Drag"] = 8] = "Drag";
/** Enables connectors source end to be selected. */
ConnectorConstraints[ConnectorConstraints["DragSourceEnd"] = 16] = "DragSourceEnd";
/** Enables connectors target end to be selected. */
ConnectorConstraints[ConnectorConstraints["DragTargetEnd"] = 32] = "DragTargetEnd";
/** Enables control point and end point of every segment in a connector for editing. */
ConnectorConstraints[ConnectorConstraints["DragSegmentThumb"] = 64] = "DragSegmentThumb";
/** Enables AllowDrop constraints to the connector. */
ConnectorConstraints[ConnectorConstraints["AllowDrop"] = 128] = "AllowDrop";
/** Enables bridging to the connector. */
ConnectorConstraints[ConnectorConstraints["Bridging"] = 256] = "Bridging";
/** Enables or Disables Bridge Obstacles with overlapping of connectors. */
ConnectorConstraints[ConnectorConstraints["BridgeObstacle"] = 512] = "BridgeObstacle";
/** Enables bridging to the connector. */
ConnectorConstraints[ConnectorConstraints["InheritBridging"] = 1024] = "InheritBridging";
/** Used to set the pointer events. */
ConnectorConstraints[ConnectorConstraints["PointerEvents"] = 2048] = "PointerEvents";
/** Enables or disables tool tip for the connectors */
ConnectorConstraints[ConnectorConstraints["Tooltip"] = 4096] = "Tooltip";
/** Enables or disables tool tip for the connectors */
ConnectorConstraints[ConnectorConstraints["InheritTooltip"] = 8192] = "InheritTooltip";
/** Enables Interaction. */
ConnectorConstraints[ConnectorConstraints["Interaction"] = 4218] = "Interaction";
/** Enables ReadOnly */
ConnectorConstraints[ConnectorConstraints["ReadOnly"] = 16384] = "ReadOnly";
/** Enables all constraints. */
ConnectorConstraints[ConnectorConstraints["Default"] = 11838] = "Default";
})(ConnectorConstraints || (ConnectorConstraints = {}));
/**
* @hidden
* Enables/Disables the handles of the selector
* Rotate - Enable Rotate Thumb
* ConnectorSource - Enable Connector source point
* ConnectorTarget - Enable Connector target point
* ResizeNorthEast - Enable ResizeNorthEast Resize
* ResizeEast - Enable ResizeEast Resize
* ResizeSouthEast - Enable ResizeSouthEast Resize
* ResizeSouth - Enable ResizeSouth Resize
* ResizeSouthWest - Enable ResizeSouthWest Resize
* ResizeWest - Enable ResizeWest Resize
* ResizeNorthWest - Enable ResizeNorthWest Resize
* ResizeNorth - Enable ResizeNorth Resize
* Default - Enables all constraints
* @private
*/
var ThumbsConstraints;
(function (ThumbsConstraints) {
/** Enable Rotate Thumb */
ThumbsConstraints[ThumbsConstraints["Rotate"] = 2] = "Rotate";
/** Enable Connector source point */
ThumbsConstraints[ThumbsConstraints["ConnectorSource"] = 4] = "ConnectorSource";
/** Enable Connector target point */
ThumbsConstraints[ThumbsConstraints["ConnectorTarget"] = 8] = "ConnectorTarget";
/** Enable ResizeNorthEast Resize */
ThumbsConstraints[ThumbsConstraints["ResizeNorthEast"] = 16] = "ResizeNorthEast";
/** Enable ResizeEast Resize */
ThumbsConstraints[ThumbsConstraints["ResizeEast"] = 32] = "ResizeEast";
/** Enable ResizeSouthEast Resize */
ThumbsConstraints[ThumbsConstraints["ResizeSouthEast"] = 64] = "ResizeSouthEast";
/** Enable ResizeSouth Resize */
ThumbsConstraints[ThumbsConstraints["ResizeSouth"] = 128] = "ResizeSouth";
/** Enable ResizeSouthWest Resize */
ThumbsConstraints[ThumbsConstraints["ResizeSouthWest"] = 256] = "ResizeSouthWest";
/** Enable ResizeWest Resize */
ThumbsConstraints[ThumbsConstraints["ResizeWest"] = 512] = "ResizeWest";
/** Enable ResizeNorthWest Resize */
ThumbsConstraints[ThumbsConstraints["ResizeNorthWest"] = 1024] = "ResizeNorthWest";
/** Enable ResizeNorth Resize */
ThumbsConstraints[ThumbsConstraints["ResizeNorth"] = 2048] = "ResizeNorth";
/** Enables all constraints */
ThumbsConstraints[ThumbsConstraints["Default"] = 4094] = "Default";
})(ThumbsConstraints || (ThumbsConstraints = {}));
/**
* @hidden
* Defines the visibility of the selector handles
* None - Hides all the selector elements
* ConnectorSourceThumb - Shows/hides the source thumb of the connector
* ConnectorTargetThumb - Shows/hides the target thumb of the connector
* ResizeSouthEast - Shows/hides the bottom right resize handle of the selector
* ResizeSouthWest - Shows/hides the bottom left resize handle of the selector
* ResizeNorthEast - Shows/hides the top right resize handle of the selector
* ResizeNorthWest - Shows/hides the top left resize handle of the selector
* ResizeEast - Shows/hides the middle right resize handle of the selector
* ResizeWest - Shows/hides the middle left resize handle of the selector
* ResizeSouth - Shows/hides the bottom center resize handle of the selector
* ResizeNorth - Shows/hides the top center resize handle of the selector
* Rotate - Shows/hides the rotate handle of the selector
* UserHandles - Shows/hides the user handles of the selector
* Resize - Shows/hides all resize handles of the selector
* @aspNumberEnum
* @IgnoreSingular
*/
var SelectorConstraints;
(function (SelectorConstraints) {
/** Hides all the selector elements */
SelectorConstraints[SelectorConstraints["None"] = 1] = "None";
/** Shows/hides the source thumb of the connector */
SelectorConstraints[SelectorConstraints["ConnectorSourceThumb"] = 2] = "ConnectorSourceThumb";
/** Shows/hides the target thumb of the connector */
SelectorConstraints[SelectorConstraints["ConnectorTargetThumb"] = 4] = "ConnectorTargetThumb";
/** Shows/hides the bottom right resize handle of the selector */
SelectorConstraints[SelectorConstraints["ResizeSouthEast"] = 8] = "ResizeSouthEast";
/** Shows/hides the bottom left resize handle of the selector */
SelectorConstraints[SelectorConstraints["ResizeSouthWest"] = 16] = "ResizeSouthWest";
/** Shows/hides the top right resize handle of the selector */
SelectorConstraints[SelectorConstraints["ResizeNorthEast"] = 32] = "ResizeNorthEast";
/** Shows/hides the top left resize handle of the selector */
SelectorConstraints[SelectorConstraints["ResizeNorthWest"] = 64] = "ResizeNorthWest";
/** Shows/hides the middle right resize handle of the selector */
SelectorConstraints[SelectorConstraints["ResizeEast"] = 128] = "ResizeEast";
/** Shows/hides the middle left resize handle of the selector */
SelectorConstraints[SelectorConstraints["ResizeWest"] = 256] = "ResizeWest";
/** Shows/hides the bottom center resize handle of the selector */
SelectorConstraints[SelectorConstraints["ResizeSouth"] = 512] = "ResizeSouth";
/** Shows/hides the top center resize handle of the selector */
SelectorConstraints[SelectorConstraints["ResizeNorth"] = 1024] = "ResizeNorth";
/** Shows/hides the rotate handle of the selector */
SelectorConstraints[SelectorConstraints["Rotate"] = 2048] = "Rotate";
/** Shows/hides the user handles of the selector */
SelectorConstraints[SelectorConstraints["UserHandle"] = 4096] = "UserHandle";
/** Shows/hides the default tooltip of nodes and connectors */
SelectorConstraints[SelectorConstraints["ToolTip"] = 8192] = "ToolTip";
/** Shows/hides all resize handles of the selector */
SelectorConstraints[SelectorConstraints["ResizeAll"] = 2046] = "ResizeAll";
/** Shows all handles of the selector */
SelectorConstraints[SelectorConstraints["All"] = 16382] = "All";
})(SelectorConstraints || (SelectorConstraints = {}));
/** @private */
var NoOfSegments;
(function (NoOfSegments) {
NoOfSegments[NoOfSegments["Zero"] = 0] = "Zero";
NoOfSegments[NoOfSegments["One"] = 1] = "One";
NoOfSegments[NoOfSegments["Two"] = 2] = "Two";
NoOfSegments[NoOfSegments["Three"] = 3] = "Three";
NoOfSegments[NoOfSegments["Four"] = 4] = "Four";
NoOfSegments[NoOfSegments["Five"] = 5] = "Five";
})(NoOfSegments || (NoOfSegments = {}));
/**
* @hidden
* Size defines and processes the size(width/height) of the objects
*/
var Size = /** @__PURE__ @class */ (function () {
function Size(width, height) {
this.width = width;
this.height = height;
}
// /** @private */
// public isEmpty(): boolean {
// return this.height === 0 && this.width === 0;
// }
/**
* @private
* @returns {Size} - Size
*/
Size.prototype.clone = function () {
return new Size(this.width, this.height);
};
return Size;
}());
/**
* @hidden
* Rect defines and processes rectangular regions
*/
var Rect = /** @__PURE__ @class */ (function () {
function Rect(x, y, width, height) {
/**
* Sets the x-coordinate of the starting point of a rectangular region
*
* @default 0
*/
this.x = Number.MAX_VALUE;
/**
* Sets the y-coordinate of the starting point of a rectangular region
*
* @default 0
*/
this.y = Number.MAX_VALUE;
/**
* Sets the width of a rectangular region
*
* @default 0
*/
this.width = 0;
/**
* Sets the height of a rectangular region
*
* @default 0
*/
this.height = 0;
if (x === undefined || y === undefined) {
x = y = Number.MAX_VALUE;
width = height = 0;
}
else {
if (width === undefined) {
width = 0;
}
if (height === undefined) {
height = 0;
}
}
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
Object.defineProperty(Rect.prototype, "left", {
/** @private */
get: function () {
return this.x;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "right", {
/** @private */
get: function () {
return this.x + this.width;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "top", {
/** @private */
get: function () {
return this.y;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "bottom", {
/** @private */
get: function () {
return this.y + this.height;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "topLeft", {
/** @private */
get: function () {
return { x: this.left, y: this.top };
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "topRight", {
/** @private */
get: function () {
return { x: this.right, y: this.top };
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "bottomLeft", {
/** @private */
get: function () {
return { x: this.left, y: this.bottom };
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "bottomRight", {
/** @private */
get: function () {
return { x: this.right, y: this.bottom };
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "middleLeft", {
/** @private */
get: function () {
return { x: this.left, y: this.y + this.height / 2 };
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "middleRight", {
/** @private */
get: function () {
return { x: this.right, y: this.y + this.height / 2 };
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "topCenter", {
/** @private */
get: function () {
return { x: this.x + this.width / 2, y: this.top };
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "bottomCenter", {
/** @private */
get: function () {
return { x: this.x + this.width / 2, y: this.bottom };
},
enumerable: true,
configurable: true
});
Object.defineProperty(Rect.prototype, "center", {
/** @private */
get: function () {
return { x: this.x + this.width / 2, y: this.y + this.height / 2 };
},
enumerable: true,
configurable: true
});
/**
* @param {PointModel} rect1 - rect1
* @param {number} rect2 - rect2
* @private
* @returns {boolean} - boolean
*/
Rect.prototype.equals = function (rect1, rect2) {
return rect1.x === rect2.x && rect1.y === rect2.y && rect1.width === rect2.width && rect1.height === rect2.height;
};
/**
* @param {PointModel} rect - rect
* @private
* @returns {Rect} - Rect
*/
Rect.prototype.uniteRect = function (rect) {
// eslint-disable-next-line use-isnan
var right = Math.max(Number.NaN === this.right || this.x === Number.MAX_VALUE ? rect.right : this.right, rect.right);
var bottom = this.bottom;
this.x = Math.min(this.left, rect.left);
this.y = Math.min(this.top, rect.top);
this.width = right - this.x;
this.height = bottom - this.y;
return this;
};
/**
* @param {PointModel} point - point
* @private
* @returns {void} - void
*/
Rect.prototype.unitePoint = function (point) {
if (this.x === Number.MAX_VALUE) {
this.x = point.x;
this.y = point.y;
return;
}
var x = Math.min(this.left, point.x);
var y = Math.min(this.top, point.y);
var right = Math.max(this.right, point.x);
var bottom = Math.max(this.bottom, point.y);
this.x = x;
this.y = y;
this.width = right - this.x;
this.height = bottom - this.y;
};
/**
* @param {Rect} rect - rect
* @private
* @returns {Rect} - Rect
*/
Rect.prototype.intersection = function (rect) {
if (this.intersects(rect)) {
var left = Math.max(this.left, rect.left);
var top_1 = Math.max(this.top, rect.top);
var right = Math.min(this.right, rect.right);
var bottom = Math.min(this.bottom, rect.bottom);
return new Rect(left, top_1, right - left, bottom - top_1);
}
return Rect.empty;
};
/**
* @param {number} padding - padding
* @private
* @returns {Rect} - Rect
*/
Rect.prototype.Inflate = function (padding) {
this.x -= padding;
this.y -= padding;
this.width += padding * 2;
this.height += padding * 2;
return this;
};
// public Inflate(size: Size): Rect {
// this.x -= size.Width;
// this.y -= size.Height;
// this.width += size.Width * 2;
// this.height += size.Height * 2;
// return this;
// }
// public inflate(width: number, height: number): void {
// this.x -= width;
// this.y -= height;
// this.width += width * 2;
// this.height += height * 2;
// }
/**
* @param {Rect} rect - rect
* @private
* @returns {boolean} - boolean
*/
Rect.prototype.intersects = function (rect) {
if (this.right < rect.left || this.left > rect.right || this.top > rect.bottom || this.bottom < rect.top) {
return false;
}
return true;
};
/**
* @param {Rect} rect - rect
* @private
* @returns {boolean} - boolean
*/
Rect.prototype.containsRect = function (rect) {
return this.left <= rect.left && this.right >= rect.right && this.top <= rect.top && this.bottom >= rect.bottom;
};
/**
* @param {PointModel} point - point
* @param {PointModel} padding - padding
* @private
* @returns {boolean} - boolean
*/
Rect.prototype.containsPoint = function (point, padding) {
if (padding === void 0) { padding = 0; }
return this.left - padding <= point.x && this.right + padding >= point.x
&& this.top - padding <= point.y && this.bottom + padding >= point.y;
};
/**
* @private
* @returns {PointModel[]} - PointModel[]
*/
Rect.prototype.toPoints = function () {
var points = [];
points.push(this.topLeft);
points.push(this.topRight);
points.push(this.bottomLeft);
points.push(this.bottomRight);
return points;
};
/**
* @param {PointModel[]} points - points
* @private
* @returns {Rect} - Rect
*/
Rect.toBounds = function (points) {
var rect = new Rect();
for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
var pt = points_1[_i];
rect.unitePoint(pt);
}
return rect;
};
/**
* @param {number} scaleX - scaleX
* @param {number} scaleY - scaleY
* @private
* @returns {void} - void
*/
Rect.prototype.scale = function (scaleX, scaleY) {
this.width *= scaleX;
this.height *= scaleY;
};
/**
* @param {number} offsetX - offsetX
* @param {number} offsetY - offsetY
* @private
* @returns {void} - void
*/
Rect.prototype.offset = function (offsetX, offsetY) {
this.x += offsetX;
this.y += offsetY;
};
/** @private */
Rect.empty = new Rect(Number.MAX_VALUE, Number.MIN_VALUE, 0, 0);
return Rect;
}());
/**
* @hidden
* Matrix module is used to transform points based on offsets, angle
*/
var MatrixTypes;
(function (MatrixTypes) {
MatrixTypes[MatrixTypes["Identity"] = 0] = "Identity";
MatrixTypes[MatrixTypes["Translation"] = 1] = "Translation";
MatrixTypes[MatrixTypes["Scaling"] = 2] = "Scaling";
MatrixTypes[MatrixTypes["Unknown"] = 4] = "Unknown";
})(MatrixTypes || (MatrixTypes = {}));
/**
* @hidden
* Matrix class
*/
var Matrix = /** @__PURE__ @class */ (function () {
function Matrix(m11, m12, m21, m22, offsetX, offsetY, type) {
this.m11 = m11;
this.m12 = m12;
this.m21 = m21;
this.m22 = m22;
this.offsetX = offsetX;
this.offsetY = offsetY;
// if (type === undefined) {
// this.type = MatrixTypes.Unknown;
// } else {
// this.type = type;
// }
this.type = type;
}
return Matrix;
}());
/**
* @private
* @returns {Matrix} - Matrix
*/
function identityMatrix() {
return new Matrix(1, 0, 0, 1, 0, 0, MatrixTypes.Identity);
}
/**
* @param {Matrix} matrix - matrix
* @param {PointModel} point - point
* @private
* @returns {PointModel} - PointModel
*/
function transformPointByMatrix(matrix, point) {
var pt = multiplyPoint(matrix, point.x, point.y);
return { x: Math.round(pt.x * 100) / 100, y: Math.round(pt.y * 100) / 100 };
}
/**
* @param {Matrix} matrix - matrix
* @param {number} angle - angle
* @param {number} centerX - centerX
* @param {number} centerY - centerY
* @private
* @returns {void} - void
*/
function rotateMatrix(matrix, angle, centerX, centerY) {
angle %= 360.0;
multiplyMatrix(matrix, createRotationRadians(angle * 0.017453292519943295, centerX ? centerX : 0, centerY ? centerY : 0));
}
/**
* @param {number} matrix - matrix
* @param {number} scaleX - scaleX
* @param {number} scaleY - scaleY
* @param {number} centerX - centerX
* @param {number} centerY - centerY
* @private
* @returns {void} - void
*/
function scaleMatrix(matrix, scaleX, scaleY, centerX, centerY) {
if (centerX === void 0) { centerX = 0; }
if (centerY === void 0) { centerY = 0; }
multiplyMatrix(matrix, createScaling(scaleX, scaleY, centerX, centerY));
}
/**
* @param {number} scaleX - scaleX
* @param {number} scaleY - scaleY
* @param {number} centerX - centerX
* @param {number} centerY - centerY
* @private
* @returns {Matrix} - Matrix
*/
function createScaling(scaleX, scaleY, centerX, centerY) {
var result = identityMatrix();
result.type = !(centerX || centerY) ? MatrixTypes.Scaling : MatrixTypes.Scaling | MatrixTypes.Translation;
setMatrix(result, scaleX, 0.0, 0.0, scaleY, centerX - scaleX * centerX, centerY - scaleY * centerY);
return result;
}
/**
* @param {number} angle - angle
* @param {number} centerX - centerX
* @param {number} centerY - centerY
* @private
* @returns {Matrix} - Matrix
*/
function createRotationRadians(angle, centerX, centerY) {
var result = identityMatrix();
var num = Math.sin(angle);
var num2 = Math.cos(angle);
var offsetX = centerX * (1.0 - num2) + centerY * num;
var offsetY = centerY * (1.0 - num2) - centerX * num;
result.type = MatrixTypes.Unknown;
setMatrix(result, num2, num, -num, num2, offsetX, offsetY);
return result;
}
/**
* @param {number} matrix - matrix
* @param {number} x - x
* @param {number} y - y
* @private
* @returns {PointModel} - PointModel
*/
function multiplyPoint(matrix, x, y) {
switch (matrix.type) {
case MatrixTypes.Identity: break;
case MatrixTypes.Translation:
x += matrix.offsetX;
y += matrix.offsetY;
break;
case MatrixTypes.Scaling:
x *= matrix.m11;
y *= matrix.m22;
break;
case MatrixTypes.Translation | MatrixTypes.Scaling:
x *= matrix.m11;
x += matrix.offsetX;
y *= matrix.m22;
y += matrix.offsetY;
break;
default:
{
var num = y * matrix.m21 + matrix.offsetX;
var num2 = x * matrix.m12 + matrix.offsetY;
x *= matrix.m11;
x += num;
y *= matrix.m22;
y += num2;
break;
}
}
return { x: x, y: y };
}
/**
* @param {Matrix} matrix1 - matrix1
* @param {Matrix} matrix2 - matrix2
* @private
* @returns {void} - void
*/
function multiplyMatrix(matrix1, matrix2) {
var type = matrix1.type;
var type2 = matrix2.type;
if (type2 === MatrixTypes.Identity) {
return;
}
if (type === MatrixTypes.Identity) {
assignMatrix(matrix1, matrix2);
matrix1.type = matrix2.type;
return;
}
if (type2 === MatrixTypes.Translation) {
matrix1.offsetX += matrix2.offsetX;
matrix1.offsetY += matrix2.offsetY;
if (type !== MatrixTypes.Unknown) {
matrix1.type |= MatrixTypes.Translation;
}
return;
}
if (type !== MatrixTypes.Translation) {
var num = type << 4 | type2;
switch (num) {
case 34:
matrix1.m11 *= matrix2.m11;
matrix1.m22 *= matrix2.m22;
return;
case 35:
matrix1.m11 *= matrix2.m11;
matrix1.m22 *= matrix2.m22;
matrix1.offsetX = matrix2.offsetX;
matrix1.offsetY = matrix2.offsetY;
matrix1.type = (MatrixTypes.Translation | MatrixTypes.Scaling);
return;
case 36: break;
default:
{
switch (num) {
case 50:
matrix1.m11 *= matrix2.m11;
matrix1.m22 *= matrix2.m22;
matrix1.offsetX *= matrix2.m11;
matrix1.offsetY *= matrix2.m22;
return;
case 51:
matrix1.m11 *= matrix2.m11;
matrix1.m22 *= matrix2.m22;
matrix1.offsetX = matrix2.m11 * matrix1.offsetX + matrix2.offsetX;
matrix1.offsetY = matrix2.m22 * matrix1.offsetY + matrix2.offsetY;
return;
case 52: break;
default:
switch (num) {
case 66:
case 67:
case 68: break;
default: return;
}
break;
}
break;
}
}
var result = identityMatrix();
var m11New = matrix1.m11 * matrix2.m11 + matrix1.m12 * matrix2.m21;
var m12New = matrix1.m11 * matrix2.m12 + matrix1.m12 * matrix2.m22;
var m21New = matrix1.m21 * matrix2.m11 + matrix1.m22 * matrix2.m21;
var m22New = matrix1.m21 * matrix2.m12 + matrix1.m22 * matrix2.m22;
var offsetX_1 = matrix1.offsetX * matrix2.m11 + matrix1.offsetY * matrix2.m21 + matrix2.offsetX;
var offsetY_1 = matrix1.offsetX * matrix2.m12 + matrix1.offsetY * matrix2.m22 + matrix2.offsetY;
setMatrix(result, m11New, m12New, m21New, m22New, offsetX_1, offsetY_1);
if (result.m21 || result.m12) {
result.type = MatrixTypes.Unknown;
}
else {
if (result.m11 && result.m11 !== 1.0 || result.m22 && result.m22 !== 1.0) {
result.type = MatrixTypes.Scaling;
}
if (result.offsetX || result.offsetY) {
result.type |= MatrixTypes.Translation;
}
if ((result.type & (MatrixTypes.Translation | MatrixTypes.Scaling)) === MatrixTypes.Identity) {
result.type = MatrixTypes.Identity;
}
result.type = MatrixTypes.Scaling | MatrixTypes.Translation;
}
assignMatrix(matrix1, result);
matrix1.type = result.type;
return;
}
var offsetX = matrix1.offsetX;
var offsetY = matrix1.offsetY;
matrix1.offsetX = offsetX * matrix2.m11 + offsetY * matrix2.m21 + matrix2.offsetX;
matrix1.offsetY = offsetX * matrix2.m12 + offsetY * matrix2.m22 + matrix2.offsetY;
if (type2 === MatrixTypes.Unknown) {
matrix1.type = MatrixTypes.Unknown;
return;
}
matrix1.type = (MatrixTypes.Translation | MatrixTypes.Scaling);
}
/**
* @param {number} mat - mat
* @param {number} m11 - m11
* @param {number} m12 - m12
* @param {number} m21 - m21
* @param {number} m22 - m22
* @param {number} x - x
* @param {number} y - y
* @private
* @returns {void} - void
*/
function setMatrix(mat, m11, m12, m21, m22, x, y) {
mat.m11 = m11;
mat.m12 = m12;
mat.m21 = m21;
mat.m22 = m22;
mat.offsetX = x;
mat.offsetY = y;
}
/**
* @param {Matrix} matrix1 - matrix1
* @param {Matrix} matrix2 - matrix2
* @private
* @returns {void} - void
*/
function assignMatrix(matrix1, matrix2) {
matrix1.m11 = matrix2.m11;
matrix1.m12 = matrix2.m12;
matrix1.m21 = matrix2.m21;
matrix1.m22 = matrix2.m22;
matrix1.offsetX = matrix2.offsetX;
matrix1.offsetY = matrix2.offsetY;
matrix1.type = matrix2.type;
}
/**
* @param {SVGElement} node - node
* @private
* @returns {SVGElement[] | HTMLCollection} - child elements
*/
function getChildNode(node) {
var child;
var collection = [];
if (Browser.info.name === 'msie' || Browser.info.name === 'edge') {
for (var i = 0; i < node.childNodes.length; i++) {
child = node.childNodes[parseInt(i.toString(), 10)];
if (child.nodeType === 1) {
collection.push(child);
}
}
}
else {
collection = node.children;
}
return collection;
}
/**
* @param {string} data - data
* @private
* @returns {Rect} - Rect
*/
function measurePath(data) {
var path = 'pathTable';
if (!window[path]) {
window[path] = {};
}
if (data) {
var measureElement = 'measureElement';
window[measureElement].style.visibility = 'visible';
var svg = window[measureElement].children[2];
var element = getChildNode(svg)[0];
element.setAttribute('d', data);
//let bounds: SVGRect = element.getBBox();
var bounds = void 0;
if (window[path][data]) {
bounds = window[path][data];
}
else {
window[path][data] = bounds = element.getBBox();
if ((bounds.x === 0 || bounds.y === 0) && (bounds.width === 0 || bounds.height === 0)) {
window[path][data] = bounds = getBBox(data);
}
}
var svgBounds = new Rect(bounds.x, bounds.y, bounds.width, bounds.height);
window[measureElement].style.visibility = 'hidden';
return svgBounds;
}
return new Rect(0, 0, 0, 0);
}
/**
* @param {string} path - path
* @private
* @returns {any} - Rect
*/
function getBBox(path) {
var xmin = 0;
var xmax = 0;
var ymin = 0;
var ymax = 0;
// tslint:disable-next-line
var currentValue;
// tslint:disable-next-line
var currentpath = path;
currentpath = currentpath.replace(/[a-z].*/g, ' ').replace(/[\sA-Z]+/gi, ' ').trim().split(' ');
for (var i = 0; i < currentpath.length; i++) {
if (currentpath[parseInt(i.toString(), 10)].length > 1) {
currentValue = currentpath[parseInt(i.toString(), 10)].split(',');
xmin = xmax = currentValue[0];
ymin = ymax = currentValue[1];
}
}
for (var i = 0; i < currentpath.length; i++) {
currentValue = currentpath[parseInt(i.toString(), 10)].split(',');
if (!currentValue[1]) {
currentValue[0] = xmin;
currentValue[1] = ymin;
}
xmin = Math.min(xmin, currentValue[0]);
xmax = Math.max(xmax, currentValue[0]);
ymin = Math.min(ymin, currentValue[1]);
ymax = Math.max(ymax, currentValue[1]);
}
return { x: xmin, y: ymin, width: xmax - xmin, height: ymax - ymin };
}
/**
* @param {TextElement} element - element
* @param {number} maxWidth - maxWidth
* @private
* @returns {BaseAttributes} - BaseAttributes
*/
function getTextOptions(element, maxWidth) {
var options = {
fill: element.style.fill, stroke: element.style.strokeColor, angle: element.rotateAngle + element.parentTransform,
pivotX: element.pivot.x, pivotY: element.pivot.y, strokeWidth: element.style.strokeWidth,
dashArray: element.style.strokeDashArray, opacity: element.style.opacity,
visible: element.visible, id: element.id,
width: maxWidth || element.actualSize.width, height: element.actualSize.height,
x: element.offsetX - element.actualSize.width * element.pivot.x + 0.5,
y: element.offsetY - element.actualSize.height * element.pivot.y + 0.5,
relativeMode: element.relativeMode
};
options.fontSize = element.style.fontSize;
options.fontFamily = element.style.fontFamily;
options.textOverflow = element.style.textOverflow;
options.textDecoration = element.style.textDecoration;
options.doWrap = element.doWrap;
options.whiteSpace = whiteSpaceToString(element.style.whiteSpace, element.style.textWrapping);
options.content = element.content;
options.textWrapping = element.style.textWrapping;
options.breakWord = wordBreakToString(element.style.textWrapping);
options.textAlign = textAlignToString(element.style.textAlign);
options.color = element.style.color;
options.italic = element.style.italic;
options.bold = element.style.bold;
if (element.thickness !== undefined) {
options.thickness = element.thickness;
}
options.dashArray = '';
options.strokeWidth = element.style.strokeWidth;
options.fill = '';
return options;
}
/**
* @param {TextAttributes} text - text
* @param {string} textValue - textValue
* @param {number} maxHeight - maxHeight
* @private
* @returns {SubTextElement[]} - array of SubTextElement
*/
function wrapSvgTextEJ2(text, textValue, maxHeight) {
var childNodes = [];
var k = 0;
var txtValue;
var bounds1;
var content = textValue || text.content;
if (text.whiteSpace !== 'nowrap' && text.whiteSpace !== 'pre') {
if (text.breakWord === 'breakall') {
txtValue = '';
txtValue += content[0];
for (k = 0; k < content.length; k++) {
bounds1 = bBoxText(txtValue, text);
if (bounds1 >= text.width && txtValue.length > 0) {
childNodes[childNodes.length] = { text: txtValue, x: 0, dy: 0, width: bounds1 };
txtValue = '';
}
else {
txtValue = txtValue + (content[k + 1] || '');
// if (txtValue.indexOf('\n') > -1) {
// txtValue = txtValue.replace('\n', '');
// }
var width = bBoxText(txtValue, text);
if ((Math.ceil(width) + 2 >= text.width && txtValue.length > 0) || (txtValue.indexOf('\n') > -1)) {
childNodes[childNodes.length] = { text: txtValue, x: 0, dy: 0, width: width };
txtValue = '';
}
if (k === content.length - 1 && txtValue.length > 0) {
childNodes[childNodes.length] = { text: txtValue, x: 0, dy: 0, width: width };
txtValue = '';
}
}
}
}
else {
childNodes = wordWrappingEJ2(text, textValue, maxHeight);
}
}
else {
childNodes[childNodes.length] = { text: content, x: 0, dy: 0, width: bBoxText(content, text) };
}
return childNodes;
}
/**
* @param {TextAttributes} text - text
* @param {string} textValue - textValue
* @param {number} maxHeight - maxHeight
* @private
* @returns {SubTextElement[]} - array of SubTextElement
*/
function wordWrappingEJ2(text, textValue, maxHeight) {
var childNodes = [];
var txtValue = '';
var j = 0;
var i = 0;
var wrap = text.whiteSpace !== 'nowrap' ? true : false;
var content = textValue || text.content;
var bounds1;
var eachLine = content.split('\n');
var words;
var newText;
var height = 0;
var existingWidth;
var existingText;
for (j = 0; j < eachLine.length; j++) {
words = text.textWrapping !== 'NoWrap' ? eachLine[parseInt(j.toString(), 10)].split(' ') : eachLine;
for (i = 0; i < words.l