(shadow.inset ? 1 : -1) * shadow.spread.number, shadow.spread.number * (shadow.inset ? -2 : 2), shadow.spread.number * (shadow.inset ? -2 : 2)); if (shadow.inset) { _this.path(borderBoxArea); _this.ctx.clip(); _this.mask(shadowPaintingArea); } else { _this.mask(borderBoxArea); _this.ctx.clip(); _this.path(shadowPaintingArea); } _this.ctx.shadowOffsetX = shadow.offsetX.number + maskOffset; _this.ctx.shadowOffsetY = shadow.offsetY.number; _this.ctx.shadowColor = asString(shadow.color); _this.ctx.shadowBlur = shadow.blur.number; _this.ctx.fillStyle = shadow.inset ? asString(shadow.color) : "rgba(0,0,0,1)"; _this.ctx.fill(); _this.ctx.restore(); }); _a.label = 2; case 2: side = 0; _i = 0, borders_1 = borders; _a.label = 3; case 3: if (!(_i < borders_1.length)) return [3, 13]; border = borders_1[_i]; if (!(border.style !== 0 && !isTransparent(border.color) && border.width > 0)) return [3, 11]; if (!(border.style === 2)) return [3, 5]; return [4, this.renderDashedDottedBorder( border.color, border.width, side, paint.curves, 2 /* DASHED */ )]; case 4: _a.sent(); return [3, 11]; case 5: if (!(border.style === 3)) return [3, 7]; return [4, this.renderDashedDottedBorder( border.color, border.width, side, paint.curves, 3 /* DOTTED */ )]; case 6: _a.sent(); return [3, 11]; case 7: if (!(border.style === 4)) return [3, 9]; return [4, this.renderDoubleBorder(border.color, border.width, side, paint.curves)]; case 8: _a.sent(); return [3, 11]; case 9: return [4, this.renderSolidBorder(border.color, side, paint.curves)]; case 10: _a.sent(); _a.label = 11; case 11: side++; _a.label = 12; case 12: _i++; return [3, 3]; case 13: return [ 2 /*return*/ ]; } }); }); }; CanvasRenderer2.prototype.renderDashedDottedBorder = function(color2, width, side, curvePoints, style) { return __awaiter(this, void 0, void 0, function() { var strokePaths, boxPaths, startX, startY, endX, endY, length, dashLength, spaceLength, useLineDash, multiplier, numberOfDashes, minSpace, maxSpace, path1, path2, path1, path2; return __generator(this, function(_a) { this.ctx.save(); strokePaths = parsePathForBorderStroke(curvePoints, side); boxPaths = parsePathForBorder(curvePoints, side); if (style === 2) { this.path(boxPaths); this.ctx.clip(); } if (isBezierCurve(boxPaths[0])) { startX = boxPaths[0].start.x; startY = boxPaths[0].start.y; } else { startX = boxPaths[0].x; startY = boxPaths[0].y; } if (isBezierCurve(boxPaths[1])) { endX = boxPaths[1].end.x; endY = boxPaths[1].end.y; } else { endX = boxPaths[1].x; endY = boxPaths[1].y; } if (side === 0 || side === 2) { length = Math.abs(startX - endX); } else { length = Math.abs(startY - endY); } this.ctx.beginPath(); if (style === 3) { this.formatPath(strokePaths); } else { this.formatPath(boxPaths.slice(0, 2)); } dashLength = width < 3 ? width * 3 : width * 2; spaceLength = width < 3 ? width * 2 : width; if (style === 3) { dashLength = width; spaceLength = width; } useLineDash = true; if (length <= dashLength * 2) { useLineDash = false; } else if (length <= dashLength * 2 + spaceLength) { multiplier = length / (2 * dashLength + spaceLength); dashLength *= multiplier; spaceLength *= multiplier; } else { numberOfDashes = Math.floor((length + spaceLength) / (dashLength + spaceLength)); minSpace = (length - numberOfDashes * dashLength) / (numberOfDashes - 1); maxSpace = (length - (numberOfDashes + 1) * dashLength) / numberOfDashes; spaceLength = maxSpace <= 0 || Math.abs(spaceLength - minSpace) < Math.abs(spaceLength - maxSpace) ? minSpace : maxSpace; } if (useLineDash) { if (style === 3) { this.ctx.setLineDash([0, dashLength + spaceLength]); } else { this.ctx.setLineDash([dashLength, spaceLength]); } } if (style === 3) { this.ctx.lineCap = "round"; this.ctx.lineWidth = width; } else { this.ctx.lineWidth = width * 2 + 1.1; } this.ctx.strokeStyle = asString(color2); this.ctx.stroke(); this.ctx.setLineDash([]); if (style === 2) { if (isBezierCurve(boxPaths[0])) { path1 = boxPaths[3]; path2 = boxPaths[0]; this.ctx.beginPath(); this.formatPath([new Vector(path1.end.x, path1.end.y), new Vector(path2.start.x, path2.start.y)]); this.ctx.stroke(); } if (isBezierCurve(boxPaths[1])) { path1 = boxPaths[1]; path2 = boxPaths[2]; this.ctx.beginPath(); this.formatPath([new Vector(path1.end.x, path1.end.y), new Vector(path2.start.x, path2.start.y)]); this.ctx.stroke(); } } this.ctx.restore(); return [ 2 /*return*/ ]; }); }); }; CanvasRenderer2.prototype.render = function(element) { return __awaiter(this, void 0, void 0, function() { var stack; return __generator(this, function(_a) { switch (_a.label) { case 0: if (this.options.backgroundColor) { this.ctx.fillStyle = asString(this.options.backgroundColor); this.ctx.fillRect(this.options.x, this.options.y, this.options.width, this.options.height); } stack = parseStackingContexts(element); return [4, this.renderStack(stack)]; case 1: _a.sent(); this.applyEffects([]); return [2, this.canvas]; } }); }); }; return CanvasRenderer2; }(Renderer) ); var isTextInputElement = function(container) { if (container instanceof TextareaElementContainer) { return true; } else if (container instanceof SelectElementContainer) { return true; } else if (container instanceof InputElementContainer && container.type !== RADIO && container.type !== CHECKBOX) { return true; } return false; }; var calculateBackgroundCurvedPaintingArea = function(clip, curves) { switch (clip) { case 0: return calculateBorderBoxPath(curves); case 2: return calculateContentBoxPath(curves); case 1: default: return calculatePaddingBoxPath(curves); } }; var canvasTextAlign = function(textAlign2) { switch (textAlign2) { case 1: return "center"; case 2: return "right"; case 0: default: return "left"; } }; var iOSBrokenFonts = ["-apple-system", "system-ui"]; var fixIOSSystemFonts = function(fontFamilies) { return /iPhone OS 15_(0|1)/.test(window.navigator.userAgent) ? fontFamilies.filter(function(fontFamily2) { return iOSBrokenFonts.indexOf(fontFamily2) === -1; }) : fontFamilies; }; var ForeignObjectRenderer = ( /** @class */ function(_super) { __extends(ForeignObjectRenderer2, _super); function ForeignObjectRenderer2(context, options) { var _this = _super.call(this, context, options) || this; _this.canvas = options.canvas ? options.canvas : document.createElement("canvas"); _this.ctx = _this.canvas.getContext("2d"); _this.options = options; _this.canvas.width = Math.floor(options.width * options.scale); _this.canvas.height = Math.floor(options.height * options.scale); _this.canvas.style.width = options.width + "px"; _this.canvas.style.height = options.height + "px"; _this.ctx.scale(_this.options.scale, _this.options.scale); _this.ctx.translate(-options.x, -options.y); _this.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (" + options.width + "x" + options.height + " at " + options.x + "," + options.y + ") with scale " + options.scale); return _this; } ForeignObjectRenderer2.prototype.render = function(element) { return __awaiter(this, void 0, void 0, function() { var svg, img; return __generator(this, function(_a) { switch (_a.label) { case 0: svg = createForeignObjectSVG(this.options.width * this.options.scale, this.options.height * this.options.scale, this.options.scale, this.options.scale, element); return [4, loadSerializedSVG(svg)]; case 1: img = _a.sent(); if (this.options.backgroundColor) { this.ctx.fillStyle = asString(this.options.backgroundColor); this.ctx.fillRect(0, 0, this.options.width * this.options.scale, this.options.height * this.options.scale); } this.ctx.drawImage(img, -this.options.x * this.options.scale, -this.options.y * this.options.scale); return [2, this.canvas]; } }); }); }; return ForeignObjectRenderer2; }(Renderer) ); var loadSerializedSVG = function(svg) { return new Promise(function(resolve, reject) { var img = new Image(); img.onload = function() { resolve(img); }; img.onerror = reject; img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg)); }); }; var Logger = ( /** @class */ function() { function Logger2(_a) { var id = _a.id, enabled = _a.enabled; this.id = id; this.enabled = enabled; this.start = Date.now(); } Logger2.prototype.debug = function() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (this.enabled) { if (typeof window !== "undefined" && window.console && typeof console.debug === "function") { console.debug.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args)); } else { this.info.apply(this, args); } } }; Logger2.prototype.getTime = function() { return Date.now() - this.start; }; Logger2.prototype.info = function() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (this.enabled) { if (typeof window !== "undefined" && window.console && typeof console.info === "function") { console.info.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args)); } } }; Logger2.prototype.warn = function() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (this.enabled) { if (typeof window !== "undefined" && window.console && typeof console.warn === "function") { console.warn.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args)); } else { this.info.apply(this, args); } } }; Logger2.prototype.error = function() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (this.enabled) { if (typeof window !== "undefined" && window.console && typeof console.error === "function") { console.error.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args)); } else { this.info.apply(this, args); } } }; Logger2.instances = {}; return Logger2; }() ); var Context = ( /** @class */ function() { function Context2(options, windowBounds) { var _a; this.windowBounds = windowBounds; this.instanceName = "#" + Context2.instanceCount++; this.logger = new Logger({ id: this.instanceName, enabled: options.logging }); this.cache = (_a = options.cache) !== null && _a !== void 0 ? _a : new Cache(this, options); } Context2.instanceCount = 1; return Context2; }() ); var html2canvas = function(element, options) { if (options === void 0) { options = {}; } return renderElement(element, options); }; if (typeof window !== "undefined") { CacheStorage.setContext(window); } var renderElement = function(element, opts) { return __awaiter(void 0, void 0, void 0, function() { var ownerDocument, defaultView, resourceOptions, contextOptions, windowOptions, windowBounds, context, foreignObjectRendering, cloneOptions, documentCloner, clonedElement, container, _a, width, height, left, top, backgroundColor2, renderOptions, canvas, renderer, root, renderer; var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t; return __generator(this, function(_u) { switch (_u.label) { case 0: if (!element || typeof element !== "object") { return [2, Promise.reject("Invalid element provided as first argument")]; } ownerDocument = element.ownerDocument; if (!ownerDocument) { throw new Error("Element is not attached to a Document"); } defaultView = ownerDocument.defaultView; if (!defaultView) { throw new Error("Document is not attached to a Window"); } resourceOptions = { allowTaint: (_b = opts.allowTaint) !== null && _b !== void 0 ? _b : false, imageTimeout: (_c = opts.imageTimeout) !== null && _c !== void 0 ? _c : 15e3, proxy: opts.proxy, useCORS: (_d = opts.useCORS) !== null && _d !== void 0 ? _d : false }; contextOptions = __assign({ logging: (_e = opts.logging) !== null && _e !== void 0 ? _e : true, cache: opts.cache }, resourceOptions); windowOptions = { windowWidth: (_f = opts.windowWidth) !== null && _f !== void 0 ? _f : defaultView.innerWidth, windowHeight: (_g = opts.windowHeight) !== null && _g !== void 0 ? _g : defaultView.innerHeight, scrollX: (_h = opts.scrollX) !== null && _h !== void 0 ? _h : defaultView.pageXOffset, scrollY: (_j = opts.scrollY) !== null && _j !== void 0 ? _j : defaultView.pageYOffset }; windowBounds = new Bounds(windowOptions.scrollX, windowOptions.scrollY, windowOptions.windowWidth, windowOptions.windowHeight); context = new Context(contextOptions, windowBounds); foreignObjectRendering = (_k = opts.foreignObjectRendering) !== null && _k !== void 0 ? _k : false; cloneOptions = { allowTaint: (_l = opts.allowTaint) !== null && _l !== void 0 ? _l : false, onclone: opts.onclone, ignoreElements: opts.ignoreElements, inlineImages: foreignObjectRendering, copyStyles: foreignObjectRendering }; context.logger.debug("Starting document clone with size " + windowBounds.width + "x" + windowBounds.height + " scrolled to " + -windowBounds.left + "," + -windowBounds.top); documentCloner = new DocumentCloner(context, element, cloneOptions); clonedElement = documentCloner.clonedReferenceElement; if (!clonedElement) { return [2, Promise.reject("Unable to find element in cloned iframe")]; } return [4, documentCloner.toIFrame(ownerDocument, windowBounds)]; case 1: container = _u.sent(); _a = isBodyElement(clonedElement) || isHTMLElement(clonedElement) ? parseDocumentSize(clonedElement.ownerDocument) : parseBounds(context, clonedElement), width = _a.width, height = _a.height, left = _a.left, top = _a.top; backgroundColor2 = parseBackgroundColor(context, clonedElement, opts.backgroundColor); renderOptions = { canvas: opts.canvas, backgroundColor: backgroundColor2, scale: (_o = (_m = opts.scale) !== null && _m !== void 0 ? _m : defaultView.devicePixelRatio) !== null && _o !== void 0 ? _o : 1, x: ((_p = opts.x) !== null && _p !== void 0 ? _p : 0) + left, y: ((_q = opts.y) !== null && _q !== void 0 ? _q : 0) + top, width: (_r = opts.width) !== null && _r !== void 0 ? _r : Math.ceil(width), height: (_s = opts.height) !== null && _s !== void 0 ? _s : Math.ceil(height) }; if (!foreignObjectRendering) return [3, 3]; context.logger.debug("Document cloned, using foreign object rendering"); renderer = new ForeignObjectRenderer(context, renderOptions); return [4, renderer.render(clonedElement)]; case 2: canvas = _u.sent(); return [3, 5]; case 3: context.logger.debug("Document cloned, element located at " + left + "," + top + " with size " + width + "x" + height + " using computed rendering"); context.logger.debug("Starting DOM parsing"); root = parseTree(context, clonedElement); if (backgroundColor2 === root.styles.backgroundColor) { root.styles.backgroundColor = COLORS.TRANSPARENT; } context.logger.debug("Starting renderer for element at " + renderOptions.x + "," + renderOptions.y + " with size " + renderOptions.width + "x" + renderOptions.height); renderer = new CanvasRenderer(context, renderOptions); return [4, renderer.render(root)]; case 4: canvas = _u.sent(); _u.label = 5; case 5: if ((_t = opts.removeContainer) !== null && _t !== void 0 ? _t : true) { if (!DocumentCloner.destroy(container)) { context.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore"); } } context.logger.debug("Finished rendering"); return [2, canvas]; } }); }); }; var parseBackgroundColor = function(context, element, backgroundColorOverride) { var ownerDocument = element.ownerDocument; var documentBackgroundColor = ownerDocument.documentElement ? parseColor(context, getComputedStyle(ownerDocument.documentElement).backgroundColor) : COLORS.TRANSPARENT; var bodyBackgroundColor = ownerDocument.body ? parseColor(context, getComputedStyle(ownerDocument.body).backgroundColor) : COLORS.TRANSPARENT; var defaultBackgroundColor = typeof backgroundColorOverride === "string" ? parseColor(context, backgroundColorOverride) : backgroundColorOverride === null ? COLORS.TRANSPARENT : 4294967295; return element === ownerDocument.documentElement ? isTransparent(documentBackgroundColor) ? isTransparent(bodyBackgroundColor) ? defaultBackgroundColor : bodyBackgroundColor : documentBackgroundColor : defaultBackgroundColor; }; var html2canvas_esm_default = html2canvas; export { html2canvas_esm_default }; /*! Bundled license information: html2canvas/dist/html2canvas.esm.js: (*! * html2canvas 1.4.1 * Copyright (c) 2022 Niklas von Hertzen * Released under MIT License *) (*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** *) */ //# sourceMappingURL=chunk-73R7ELJW.js.map Ә