diff --git a/.gitattributes b/.gitattributes index 8b07bdd40ed96025b398ec1a37fde56c0cd95f7e..6099603deb0129051811535ba703d574480dfb67 100644 --- a/.gitattributes +++ b/.gitattributes @@ -39,3 +39,9 @@ node_modules/@jimp/plugin-color/src/images/qr.jpg filter=lfs diff=lfs merge=lfs node_modules/@jimp/plugin-print/fonts/open-sans/open-sans-128-black/open-sans-128-black.png filter=lfs diff=lfs merge=lfs -text node_modules/@jimp/plugin-print/fonts/open-sans/open-sans-128-white/open-sans-128-white.png filter=lfs diff=lfs merge=lfs -text node_modules/@jimp/plugin-threshold/src/__image_snapshots__/index-test-ts-src-index-test-ts-threshold-defines-default-threshold-for-lighter-backgrounds-1-snap.png filter=lfs diff=lfs merge=lfs -text +node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text +node_modules/@rolldown/binding-linux-x64-musl/rolldown-binding.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text +node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text +node_modules/@rollup/rollup-linux-x64-musl/rollup.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text +node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text +node_modules/@swc/core-linux-x64-musl/swc.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/clearance.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/clearance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e0096919c7f194edfcce000e88a0f830c348a417 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/clearance.d.ts @@ -0,0 +1,17 @@ +import { ClassList } from "./class_list"; +import { SecurityCategory } from "./security_category"; +/** + * ```asn1 + * Clearance ::= SEQUENCE { + * policyId OBJECT IDENTIFIER, + * classList ClassList DEFAULT {unclassified}, + * securityCategories SET OF SecurityCategory OPTIONAL + * } + * ``` + */ +export declare class Clearance { + policyId: string; + classList: ClassList; + securityCategories?: SecurityCategory[]; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/holder.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/holder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..47c8504f617ef9ec60a3047dc4094f9fad3d336a --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/holder.d.ts @@ -0,0 +1,23 @@ +import { GeneralNames } from "@peculiar/asn1-x509"; +import { IssuerSerial } from "./issuer_serial"; +import { ObjectDigestInfo } from "./object_digest_info"; +/** + * ```asn1 + * Holder ::= SEQUENCE { + * baseCertificateID [0] IssuerSerial OPTIONAL, + * -- the issuer and serial number of + * -- the holder's Public Key Certificate + * entityName [1] GeneralNames OPTIONAL, + * -- the name of the claimant or role + * objectDigestInfo [2] ObjectDigestInfo OPTIONAL + * -- used to directly authenticate the + * -- holder, for example, an executable + * } + * ``` + */ +export declare class Holder { + baseCertificateID?: IssuerSerial; + entityName?: GeneralNames; + objectDigestInfo?: ObjectDigestInfo; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/ietf_attr_syntax.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/ietf_attr_syntax.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..483fb2fe549c0e785d1bd140a4d42d606ed1e5cb --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/ietf_attr_syntax.d.ts @@ -0,0 +1,33 @@ +import { OctetString } from "@peculiar/asn1-schema"; +import { GeneralNames } from "@peculiar/asn1-x509"; +/** + * ```asn1 + * CHOICE { + * octets OCTET STRING, + * oid OBJECT IDENTIFIER, + * string UTF8String + * ``` + */ +export declare class IetfAttrSyntaxValueChoices { + cotets?: OctetString; + oid?: string; + string?: string; + constructor(params?: Partial); +} +/** + * ```asn1 + * IetfAttrSyntax ::= SEQUENCE { + * policyAuthority[0] GeneralNames OPTIONAL, + * values SEQUENCE OF CHOICE { + * octets OCTET STRING, + * oid OBJECT IDENTIFIER, + * string UTF8String + * } + * } + * ``` + */ +export declare class IetfAttrSyntax { + policyAuthority?: GeneralNames; + values: IetfAttrSyntaxValueChoices[]; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/index.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..af99aa78e11984c08b3ba74115fdcf80b39246b3 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/index.d.ts @@ -0,0 +1,20 @@ +export * from "./aa_clear_attrs"; +export * from "./aa_controls"; +export * from "./attr_cert_issuer"; +export * from "./attr_cert_validity_period"; +export * from "./attr_spec"; +export * from "./attribute_certificate"; +export * from "./attribute_certificate_info"; +export * from "./class_list"; +export * from "./clearance"; +export * from "./holder"; +export * from "./ietf_attr_syntax"; +export * from "./issuer_serial"; +export * from "./object_digest_info"; +export * from "./object_identifiers"; +export * from "./proxy_info"; +export * from "./role_syntax"; +export * from "./security_category"; +export * from "./svce_auth_info"; +export * from "./target"; +export * from "./v2_form"; diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/issuer_serial.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/issuer_serial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bca8f229f3cb3d0592be1e3c10e1f4bdd77e97ee --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/issuer_serial.d.ts @@ -0,0 +1,16 @@ +import { GeneralNames, CertificateSerialNumber, UniqueIdentifier } from "@peculiar/asn1-x509"; +/** + * ```asn1 + * IssuerSerial ::= SEQUENCE { + * issuer GeneralNames, + * serial CertificateSerialNumber, + * issuerUID UniqueIdentifier OPTIONAL + * } + * ``` + */ +export declare class IssuerSerial { + issuer: GeneralNames; + serial: CertificateSerialNumber; + issuerUID: UniqueIdentifier; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/object_digest_info.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/object_digest_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c1018cefc5d7e3a421a1cb98d860ac1bcca7599 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/object_digest_info.d.ts @@ -0,0 +1,28 @@ +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +export declare enum DigestedObjectType { + publicKey = 0, + publicKeyCert = 1, + otherObjectTypes = 2 +} +/** + * ```asn1 + * ObjectDigestInfo ::= SEQUENCE { + * digestedObjectType ENUMERATED { + * publicKey (0), + * publicKeyCert (1), + * otherObjectTypes (2) }, + * -- otherObjectTypes MUST NOT + * -- MUST NOT be used in this profile + * otherObjectTypeID OBJECT IDENTIFIER OPTIONAL, + * digestAlgorithm AlgorithmIdentifier, + * objectDigest BIT STRING + * } + * ``` + */ +export declare class ObjectDigestInfo { + digestedObjectType: DigestedObjectType; + otherObjectTypeID?: string; + digestAlgorithm: AlgorithmIdentifier; + objectDigest: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/object_identifiers.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/object_identifiers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b9aae89084ce47d0e0daf057c0caad6c46b6f0e6 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/object_identifiers.d.ts @@ -0,0 +1,80 @@ +/** + * ```asn1 + * id-pe-ac-auditIdentity OBJECT IDENTIFIER ::= { id-pe 4 } + * ``` + */ +export declare const id_pe_ac_auditIdentity = "1.3.6.1.5.5.7.1.4"; +/** + * ```asn1 + * id-pe-aaControls OBJECT IDENTIFIER ::= { id-pe 6 } + * ``` + */ +export declare const id_pe_aaControls = "1.3.6.1.5.5.7.1.6"; +/** + * ```asn1 + * id-pe-ac-proxying OBJECT IDENTIFIER ::= { id-pe 10 } + * ``` + */ +export declare const id_pe_ac_proxying = "1.3.6.1.5.5.7.1.10"; +/** + * ```asn1 + * id-ce-targetInformation OBJECT IDENTIFIER ::= { id-ce 55 } + * ``` + */ +export declare const id_ce_targetInformation = "2.5.29.55"; +/** + * ```asn1 + * id-aca OBJECT IDENTIFIER ::= { id-pkix 10 } + * ``` + */ +export declare const id_aca = "1.3.6.1.5.5.7.10"; +/** + * ```asn1 + * id-aca-authenticationInfo OBJECT IDENTIFIER ::= { id-aca 1 } + * ``` + */ +export declare const id_aca_authenticationInfo = "1.3.6.1.5.5.7.10.1"; +/** + * ```asn1 + * id-aca-accessIdentity OBJECT IDENTIFIER ::= { id-aca 2 } + * ``` + */ +export declare const id_aca_accessIdentity = "1.3.6.1.5.5.7.10.2"; +/** + * ```asn1 + * id-aca-chargingIdentity OBJECT IDENTIFIER ::= { id-aca 3 } + * ``` + */ +export declare const id_aca_chargingIdentity = "1.3.6.1.5.5.7.10.3"; +/** + * ```asn1 + * id-aca-group OBJECT IDENTIFIER ::= { id-aca 4 } + * ``` + */ +export declare const id_aca_group = "1.3.6.1.5.5.7.10.4"; +/** + * ```asn1 + * id-aca-encAttrs OBJECT IDENTIFIER ::= { id-aca 6 } + * ``` + */ +export declare const id_aca_encAttrs = "1.3.6.1.5.5.7.10.6"; +/** + * ```asn1 + * id-at OBJECT IDENTIFIER ::= { joint-iso-ccitt(2) ds(5) 4 } + * ``` + */ +export declare const id_at = "2.5.4"; +/** + * ```asn1 + * id-at-role OBJECT IDENTIFIER ::= { id-at 72} + * ``` + */ +export declare const id_at_role = "2.5.4.72"; +/** + * ```asn1 + * id-at-clearance OBJECT IDENTIFIER ::= + * { joint-iso-ccitt(2) ds(5) module(1) + * selected-attribute-types(5) clearance (55) } + * ``` + */ +export declare const id_at_clearance = "2.5.1.5.55"; diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/proxy_info.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/proxy_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4fb695e3ea2d22d243a1491cd9ee427f7d5ca70d --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/proxy_info.d.ts @@ -0,0 +1,10 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { Targets } from "./target"; +/** + * ```asn1 + * ProxyInfo ::= SEQUENCE OF Targets + * ``` + */ +export declare class ProxyInfo extends AsnArray { + constructor(items?: Targets[]); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/role_syntax.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/role_syntax.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c94bd119a8f384a0d748e726b09990ef58c8c53 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/role_syntax.d.ts @@ -0,0 +1,14 @@ +import { GeneralNames, GeneralName } from "@peculiar/asn1-x509"; +/** + * ```asn1 + * RoleSyntax ::= SEQUENCE { + * roleAuthority [0] GeneralNames OPTIONAL, + * roleName [1] GeneralName + * } + * ``` + */ +export declare class RoleSyntax { + roleAuthority?: GeneralNames; + roleName?: GeneralName; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/security_category.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/security_category.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e169e5afd31751c86991484ee925f453cde14360 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/security_category.d.ts @@ -0,0 +1,13 @@ +/** + * ```asn1 + * SecurityCategory ::= SEQUENCE { + * type [0] IMPLICIT OBJECT IDENTIFIER, + * value [1] ANY DEFINED BY type + * } + * ``` + */ +export declare class SecurityCategory { + type: string; + value: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/svce_auth_info.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/svce_auth_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3597ae372db72f044e580d2bed39e79a2840159f --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/svce_auth_info.d.ts @@ -0,0 +1,17 @@ +import { OctetString } from "@peculiar/asn1-schema"; +import { GeneralName } from "@peculiar/asn1-x509"; +/** + * ```asn1 + * SvceAuthInfo ::= SEQUENCE { + * service GeneralName, + * ident GeneralName, + * authInfo OCTET STRING OPTIONAL + * } + * ``` + */ +export declare class SvceAuthInfo { + service: GeneralName; + ident: GeneralName; + authInfo?: OctetString; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/target.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/target.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e84febebb1a3b1a9d8cae0eecec6d356534eb09b --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/target.d.ts @@ -0,0 +1,42 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { GeneralName } from "@peculiar/asn1-x509"; +import { IssuerSerial } from "./issuer_serial"; +import { ObjectDigestInfo } from "./object_digest_info"; +/** + * ```asn1 + * TargetCert ::= SEQUENCE { + * targetCertificate IssuerSerial, + * targetName GeneralName OPTIONAL, + * certDigestInfo ObjectDigestInfo OPTIONAL + * } + * ``` + */ +export declare class TargetCert { + targetCertificate: IssuerSerial; + targetName?: GeneralName; + certDigestInfo?: ObjectDigestInfo; + constructor(params?: Partial); +} +/** + * ```asn1 + * Target ::= CHOICE { + * targetName [0] GeneralName, + * targetGroup [1] GeneralName, + * targetCert [2] TargetCert + * } + * ``` + */ +export declare class Target { + targetName?: GeneralName; + targetGroup?: GeneralName; + targetCert?: TargetCert; + constructor(params?: Partial); +} +/** + * ```asn1 + * Targets ::= SEQUENCE OF Target + * ``` + */ +export declare class Targets extends AsnArray { + constructor(items?: Target[]); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/v2_form.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/v2_form.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ce3af257b1a1c637daf4bf5e51075f1a6525643c --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/v2_form.d.ts @@ -0,0 +1,21 @@ +import { GeneralNames } from "@peculiar/asn1-x509"; +import { IssuerSerial } from "./issuer_serial"; +import { ObjectDigestInfo } from "./object_digest_info"; +/** + * ```asn1 + * V2Form ::= SEQUENCE { + * issuerName GeneralNames OPTIONAL, + * baseCertificateID [0] IssuerSerial OPTIONAL, + * objectDigestInfo [1] ObjectDigestInfo OPTIONAL + * -- issuerName MUST be present in this profile + * -- baseCertificateID and objectDigestInfo MUST + * -- NOT be present in this profile + * } + * ``` + */ +export declare class V2Form { + issuerName?: GeneralNames; + baseCertificateID?: IssuerSerial; + objectDigestInfo?: ObjectDigestInfo; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/package.json b/node_modules/@peculiar/asn1-x509-attr/package.json new file mode 100644 index 0000000000000000000000000000000000000000..898fed0cbc1e8dcb7042dad6246f0460ce3b87de --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/package.json @@ -0,0 +1,61 @@ +{ + "name": "@peculiar/asn1-x509-attr", + "version": "2.8.0", + "description": "ASN.1 schema for X.509 attribute certificates defined in RFC 5755.", + "keywords": [ + "asn", + "asn1", + "x509", + "attribute-certificate", + "rfc5755" + ], + "author": "PeculiarVentures, LLC", + "license": "MIT", + "files": [ + "build/**/*.{js,d.ts}", + "build/es2015/package.json", + "LICENSE", + "README.md" + ], + "main": "build/cjs/index.js", + "module": "build/es2015/index.js", + "types": "build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/es2015/index.js", + "require": "./build/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/asn1-schema", + "directory": "packages/x509-attr" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/asn1-schema/issues" + }, + "homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/x509-attr#readme", + "scripts": { + "clear": "rimraf build", + "build": "npm run build:module && npm run build:types", + "build:module": "npm run build:cjs && npm run build:es2015", + "build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs", + "build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015", + "postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015", + "prebuild:types": "rimraf build/types", + "build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly", + "rebuild": "npm run clear && npm run build", + "test": "mocha" + }, + "dependencies": { + "@peculiar/asn1-schema": "^2.8.0", + "@peculiar/asn1-x509": "^2.8.0", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } +} diff --git a/node_modules/@peculiar/utils/LICENSE b/node_modules/@peculiar/utils/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..5c99cc6dbe1a2774ff399a160b54fdf54d84d067 --- /dev/null +++ b/node_modules/@peculiar/utils/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017-2026 Peculiar Ventures, LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/utils/README.md b/node_modules/@peculiar/utils/README.md new file mode 100644 index 0000000000000000000000000000000000000000..086b004ba41c5034cc38c00b70c11c61623a2c13 --- /dev/null +++ b/node_modules/@peculiar/utils/README.md @@ -0,0 +1,299 @@ +# @peculiar/utils + +[![npm version](https://img.shields.io/npm/v/%40peculiar%2Futils.svg)](https://www.npmjs.com/package/@peculiar/utils) +[![Test](https://github.com/PeculiarVentures/pvtsutils/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/PeculiarVentures/pvtsutils/actions/workflows/test.yml) +[![Coverage Status](https://coveralls.io/repos/github/PeculiarVentures/pvtsutils/badge.svg?branch=master)](https://coveralls.io/github/PeculiarVentures/pvtsutils?branch=master) +[![License: MIT](https://img.shields.io/github/license/PeculiarVentures/pvtsutils.svg)](https://github.com/PeculiarVentures/pvtsutils/blob/master/LICENSE) + +Modern byte, text, converter registry, and PEM utilities for TypeScript projects. + +The package is designed around a modular v2 API: + +- multi-entry exports for tree-shake-friendly imports; +- `encode` and `decode` terminology; +- an extensible runtime converter registry; +- generic PEM helpers without PKI-specific parsing; +- a legacy compatibility layer for historical `pvtsutils` consumers. + +## Install + +```bash +npm install @peculiar/utils +``` + +## Entry Points + +```ts +import { bytes } from "@peculiar/utils"; +import { hex, base64, base64url } from "@peculiar/utils/encoding"; +import { pem } from "@peculiar/utils/pem"; +import { convert, createConverterRegistry, defaultConverters } from "@peculiar/utils/converters"; +import { Convert } from "@peculiar/utils/legacy"; +``` + +## Bytes Helpers + +`@peculiar/utils/bytes` stays focused on stateless byte sequence utilities. It does not include stateful readers, writers, ASN.1 parsing, PDF parsing, or other structured binary readers. For structured binary parsing, use a dedicated binary reader package. + +```ts +import { bytes } from "@peculiar/utils"; + +const offset = bytes.indexOf(new Uint8Array([0x25, 0x25, 0x45, 0x4f, 0x46]), "%%EOF", { + encoding: "ascii", +}); + +const suffix = bytes.endsWith(new Uint8Array([0x25, 0x25, 0x45, 0x4f, 0x46]), "%%EOF", { + encoding: "ascii", +}); +``` + +### Find `startxref` In A PDF Tail + +```ts +import { lastIndexOf } from "@peculiar/utils/bytes"; + +const tailStart = Math.max(0, pdf.byteLength - 4096); + +const offset = lastIndexOf(pdf, "startxref", { + encoding: "ascii", + start: pdf.byteLength, + end: tailStart, +}); + +if (offset === -1) { + throw new Error("PDF startxref marker not found"); +} +``` + +### Find `startxref` Via `tail` + +```ts +import { lastIndexOf, tail } from "@peculiar/utils/bytes"; + +const pdfTail = tail(pdf, 4096); + +const localOffset = lastIndexOf(pdfTail, "startxref", { + encoding: "ascii", +}); + +const offset = + localOffset === -1 + ? -1 + : pdf.byteLength - pdfTail.byteLength + localOffset; +``` + +### Check Prefixes And Suffixes + +```ts +import { bytes } from "@peculiar/utils"; + +bytes.startsWith(data, "-----BEGIN", { encoding: "ascii" }); +bytes.endsWith(data, "%%EOF", { encoding: "ascii" }); +``` + +### Compare Byte Sequences + +```ts +import { bytes } from "@peculiar/utils"; + +const result = bytes.compare(a, b); + +if (result === 0) { + console.log("equal"); +} +``` + +## Convert API + +The default `convert` facade is a convenience singleton backed by the built-in registry. + +```ts +import { convert } from "@peculiar/utils/converters"; + +const bytes = convert.decode("base64", "AQID"); +const text = convert.encode("hex", bytes, { case: "upper" }); +``` + +Deprecated `convert.to(...)` and `convert.from(...)` aliases are still available for temporary migration, but the primary v2 API is `encode` and `decode`. + +## Transcode + +Direct text-to-text transcoding goes through the registry without a manual intermediate step. + +```ts +import { convert } from "@peculiar/utils/converters"; +import { hex } from "@peculiar/utils/encoding"; + +const pemText = convert.transcode("AQID", { + from: "base64", + to: "pem", + toOptions: { + label: "CERTIFICATE", + }, +}); + +const hexText = convert.transcode(pemText, { + from: "pem", + fromOptions: { label: "CERTIFICATE" }, + to: "hex", + toOptions: hex.formats.colonUpper, +}); +``` + +There is intentionally no chain API. + +## Hex Formatting + +The `hex` codec accepts common input styles and can format output explicitly. + +```ts +import { hex } from "@peculiar/utils/encoding"; + +hex.decode("0102030405060708090a0b0c"); +hex.decode("01020304 05060708 090a0b0c"); +hex.decode("01:02:03:04:05:06:07:08:09:0A:0B:0C"); +hex.decode("0x0102030405060708090a0b0c"); + +hex.encode(new Uint8Array([1, 2, 3, 4]), hex.formats.colonUpper); +hex.encode(new Uint8Array([1, 2, 3, 4]), { + prefix: "0x", + group: { + size: 2, + separator: " ", + }, +}); +``` + +Available presets: + +- `hex.formats.compact` +- `hex.formats.upper` +- `hex.formats.colon` +- `hex.formats.colonUpper` +- `hex.formats.groupsOf4` +- `hex.formats.prefixed` + +## Preserve Formatting + +Use `parse` and `format` when you want to keep the original visual style of a hex string. + +```ts +import { hex } from "@peculiar/utils/encoding"; + +const parsed = hex.parse("01:02:03:04:05:06"); + +parsed.bytes; +parsed.format; +parsed.normalized; + +const updated = hex.format(new Uint8Array([0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]), parsed.format); +``` + +The same capabilities are available through the registry facade: + +```ts +import { convert } from "@peculiar/utils/converters"; + +const parsed = convert.parse("hex", "01:02:03:04"); +const formatted = convert.format("hex", new Uint8Array([0xaa, 0xbb, 0xcc, 0xdd]), parsed.format); +``` + +## PEM Helpers + +PEM support stays generic. The package does not parse ASN.1, validate PKI semantics, or handle encrypted PEM containers. + +```ts +import { pem } from "@peculiar/utils/pem"; + +const text = pem.encode("CERTIFICATE", new Uint8Array([1, 2, 3])); +const blocks = pem.decode(text); +const block = pem.find(text, "CERTIFICATE"); +const matches = pem.findAll(text, "CERTIFICATE"); + +const bundle = pem.encodeMany([ + { label: "CERTIFICATE", data: new Uint8Array([1, 2, 3]) }, + { label: "PRIVATE KEY", data: new Uint8Array([4, 5, 6]) }, +]); +``` + +## Safe Decode And Detection + +```ts +import { convert } from "@peculiar/utils/converters"; + +const result = convert.tryDecode("hex", "01:02:03"); + +if (result.ok) { + console.log(result.bytes); +} else { + console.error(result.error); +} + +const candidates = convert.detect("-----BEGIN DATA-----\nAQID\n-----END DATA-----\n", { + formats: ["pem", "base64", "hex"], +}); +``` + +## Custom Registries + +Applications can create isolated registries instead of mutating global state. + +```ts +import { createConverterRegistry, defaultConverters } from "@peculiar/utils/converters"; + +const registry = createConverterRegistry(defaultConverters); + +registry.register({ + name: "base58btc", + aliases: ["b58"], + encode(data) { + return base58btcEncode(data); + }, + decode(text) { + return base58btcDecode(text); + }, +}); +``` + +Name and alias conflicts throw by default. Use `{ override: true }` only when replacement is intentional. + +## Typed Converter Options + +Built-in converters expose typed options through the registry facade. + +```ts +import { convert } from "@peculiar/utils/converters"; + +convert.encode("hex", new Uint8Array([1, 2, 3]), { + case: "upper", +}); +``` + +Wrong options are rejected by TypeScript: + +```ts +convert.encode("hex", new Uint8Array([1, 2, 3]), { + label: "CERTIFICATE", +}); +``` + +Custom converters can extend the options map via module augmentation: + +```ts +declare module "@peculiar/utils/converters" { + interface ConverterOptionsMap { + base58btc: { + encode: Base58EncodeOptions; + decode: Base58DecodeOptions; + }; + } +} +``` + +## Legacy Compatibility + +The old `pvtsutils`-style surface is preserved under the legacy entry point. + +```ts +import { BufferSourceConverter, Convert, assign, combine, isEqual } from "@peculiar/utils/legacy"; +``` diff --git a/node_modules/@peculiar/utils/build/cjs/bytes/buffer-source.js b/node_modules/@peculiar/utils/build/cjs/bytes/buffer-source.js new file mode 100644 index 0000000000000000000000000000000000000000..0fd58520168bcbecb8132fbcf486110a03cba5c3 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/bytes/buffer-source.js @@ -0,0 +1,115 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isArrayBuffer = isArrayBuffer; +exports.isSharedArrayBuffer = isSharedArrayBuffer; +exports.isArrayBufferLike = isArrayBufferLike; +exports.isArrayBufferView = isArrayBufferView; +exports.isBufferSource = isBufferSource; +exports.assertBufferSource = assertBufferSource; +exports.toUint8Array = toUint8Array; +exports.toUint8ArrayCopy = toUint8ArrayCopy; +exports.toArrayBuffer = toArrayBuffer; +exports.toArrayBufferLike = toArrayBufferLike; +exports.toView = toView; +exports.toViewCopy = toViewCopy; +const ARRAY_BUFFER_TAG = "[object ArrayBuffer]"; +const SHARED_ARRAY_BUFFER_TAG = "[object SharedArrayBuffer]"; +function tagOf(value) { + return Object.prototype.toString.call(value); +} +function isDataViewConstructor(type) { + return type === DataView || type.prototype instanceof DataView; +} +function bytesPerElement(type) { + if (isDataViewConstructor(type)) { + return 1; + } + const value = type.BYTES_PER_ELEMENT; + return value ?? 1; +} +function isArrayBufferViewLike(value) { + if (ArrayBuffer.isView(value)) { + return true; + } + if (!value || typeof value !== "object") { + return false; + } + const view = value; + return typeof view.byteOffset === "number" + && typeof view.byteLength === "number" + && isArrayBufferLike(view.buffer); +} +function copyBytes(data) { + const view = toUint8Array(data); + const copy = new Uint8Array(view.byteLength); + copy.set(view); + return copy; +} +function isArrayBuffer(value) { + return tagOf(value) === ARRAY_BUFFER_TAG; +} +function isSharedArrayBuffer(value) { + return typeof SharedArrayBuffer !== "undefined" && tagOf(value) === SHARED_ARRAY_BUFFER_TAG; +} +function isArrayBufferLike(value) { + return isArrayBuffer(value) || isSharedArrayBuffer(value); +} +function isArrayBufferView(value) { + return isArrayBufferViewLike(value); +} +function isBufferSource(value) { + return isArrayBufferLike(value) || isArrayBufferView(value); +} +function assertBufferSource(value) { + if (!isBufferSource(value)) { + throw new TypeError("Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView"); + } +} +function toUint8Array(data) { + assertBufferSource(data); + if (isArrayBufferLike(data)) { + return new Uint8Array(data); + } + return new Uint8Array(data.buffer, data.byteOffset, data.byteLength); +} +function toUint8ArrayCopy(data) { + return copyBytes(data); +} +function toArrayBuffer(data) { + assertBufferSource(data); + if (isArrayBuffer(data)) { + return data; + } + const buffer = new ArrayBuffer(data.byteLength); + new Uint8Array(buffer).set(toUint8Array(data)); + return buffer; +} +function toArrayBufferLike(data) { + assertBufferSource(data); + if (isArrayBufferLike(data)) { + return data; + } + if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) { + return data.buffer; + } + return copyBytes(data).buffer; +} +function toView(data, type) { + assertBufferSource(data); + if (ArrayBuffer.isView(data) && data.constructor === type) { + return data; + } + const view = toUint8Array(data); + const elementSize = bytesPerElement(type); + if (view.byteOffset % elementSize !== 0 || view.byteLength % elementSize !== 0) { + throw new RangeError(`Cannot create ${type.name} over unaligned byte range`); + } + if (isDataViewConstructor(type)) { + return new type(view.buffer, view.byteOffset, view.byteLength); + } + return new type(view.buffer, view.byteOffset, view.byteLength / elementSize); +} +function toViewCopy(data, type) { + const copy = toUint8ArrayCopy(data); + return toView(copy, type); +} diff --git a/node_modules/@peculiar/utils/build/cjs/bytes/concat.js b/node_modules/@peculiar/utils/build/cjs/bytes/concat.js new file mode 100644 index 0000000000000000000000000000000000000000..69b8f124d931d2f9ceec76e834336a4946555ac3 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/bytes/concat.js @@ -0,0 +1,41 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.concatToUint8Array = concatToUint8Array; +exports.concat = concat; +const buffer_source_js_1 = require("./buffer-source.js"); +function concatToUint8Array(buffers) { + const views = []; + let length = 0; + for (const buffer of buffers) { + const view = (0, buffer_source_js_1.toUint8Array)(buffer); + views.push(view); + length += view.byteLength; + } + const result = new Uint8Array(length); + let offset = 0; + for (const view of views) { + result.set(view, offset); + offset += view.byteLength; + } + return result; +} +function concat(first, second, ...rest) { + let buffers; + let type; + if (typeof second === "function") { + buffers = Array.from(first); + type = second; + } + else if ((0, buffer_source_js_1.isBufferSource)(first)) { + buffers = [first, second, ...rest].filter(buffer_source_js_1.isBufferSource); + } + else { + buffers = Array.from(first); + if (second) { + buffers.push(second); + } + buffers.push(...rest); + } + const bytes = concatToUint8Array(buffers); + return type ? (0, buffer_source_js_1.toView)(bytes, type) : bytes.buffer; +} diff --git a/node_modules/@peculiar/utils/build/cjs/bytes/equal.js b/node_modules/@peculiar/utils/build/cjs/bytes/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..c3ebcaddc6adae86d90b104484323dbd7790f775 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/bytes/equal.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.equal = equal; +const buffer_source_js_1 = require("./buffer-source.js"); +function equal(a, b, options = {}) { + const left = (0, buffer_source_js_1.toUint8Array)(a); + const right = (0, buffer_source_js_1.toUint8Array)(b); + if (!options.constantTime && left.byteLength !== right.byteLength) { + return false; + } + const length = Math.max(left.byteLength, right.byteLength); + let diff = left.byteLength ^ right.byteLength; + for (let i = 0; i < length; i++) { + diff |= (left[i] ?? 0) ^ (right[i] ?? 0); + } + return diff === 0; +} diff --git a/node_modules/@peculiar/utils/build/cjs/bytes/index.js b/node_modules/@peculiar/utils/build/cjs/bytes/index.js new file mode 100644 index 0000000000000000000000000000000000000000..46973ab850fac8931c7905b39a870bb7a33d123d --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/bytes/index.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.tail = exports.startsWith = exports.slice = exports.lastIndexOf = exports.indexOf = exports.includes = exports.endsWith = exports.copy = exports.compare = exports.equal = exports.concatToUint8Array = exports.concat = exports.toViewCopy = exports.toView = exports.toUint8ArrayCopy = exports.toUint8Array = exports.toArrayBufferLike = exports.toArrayBuffer = exports.isSharedArrayBuffer = exports.isBufferSource = exports.isArrayBufferView = exports.isArrayBufferLike = exports.isArrayBuffer = exports.assertBufferSource = void 0; +var buffer_source_js_1 = require("./buffer-source.js"); +Object.defineProperty(exports, "assertBufferSource", { enumerable: true, get: function () { return buffer_source_js_1.assertBufferSource; } }); +Object.defineProperty(exports, "isArrayBuffer", { enumerable: true, get: function () { return buffer_source_js_1.isArrayBuffer; } }); +Object.defineProperty(exports, "isArrayBufferLike", { enumerable: true, get: function () { return buffer_source_js_1.isArrayBufferLike; } }); +Object.defineProperty(exports, "isArrayBufferView", { enumerable: true, get: function () { return buffer_source_js_1.isArrayBufferView; } }); +Object.defineProperty(exports, "isBufferSource", { enumerable: true, get: function () { return buffer_source_js_1.isBufferSource; } }); +Object.defineProperty(exports, "isSharedArrayBuffer", { enumerable: true, get: function () { return buffer_source_js_1.isSharedArrayBuffer; } }); +Object.defineProperty(exports, "toArrayBuffer", { enumerable: true, get: function () { return buffer_source_js_1.toArrayBuffer; } }); +Object.defineProperty(exports, "toArrayBufferLike", { enumerable: true, get: function () { return buffer_source_js_1.toArrayBufferLike; } }); +Object.defineProperty(exports, "toUint8Array", { enumerable: true, get: function () { return buffer_source_js_1.toUint8Array; } }); +Object.defineProperty(exports, "toUint8ArrayCopy", { enumerable: true, get: function () { return buffer_source_js_1.toUint8ArrayCopy; } }); +Object.defineProperty(exports, "toView", { enumerable: true, get: function () { return buffer_source_js_1.toView; } }); +Object.defineProperty(exports, "toViewCopy", { enumerable: true, get: function () { return buffer_source_js_1.toViewCopy; } }); +var concat_js_1 = require("./concat.js"); +Object.defineProperty(exports, "concat", { enumerable: true, get: function () { return concat_js_1.concat; } }); +Object.defineProperty(exports, "concatToUint8Array", { enumerable: true, get: function () { return concat_js_1.concatToUint8Array; } }); +var equal_js_1 = require("./equal.js"); +Object.defineProperty(exports, "equal", { enumerable: true, get: function () { return equal_js_1.equal; } }); +var sequence_js_1 = require("./sequence.js"); +Object.defineProperty(exports, "compare", { enumerable: true, get: function () { return sequence_js_1.compare; } }); +Object.defineProperty(exports, "copy", { enumerable: true, get: function () { return sequence_js_1.copy; } }); +Object.defineProperty(exports, "endsWith", { enumerable: true, get: function () { return sequence_js_1.endsWith; } }); +Object.defineProperty(exports, "includes", { enumerable: true, get: function () { return sequence_js_1.includes; } }); +Object.defineProperty(exports, "indexOf", { enumerable: true, get: function () { return sequence_js_1.indexOf; } }); +Object.defineProperty(exports, "lastIndexOf", { enumerable: true, get: function () { return sequence_js_1.lastIndexOf; } }); +Object.defineProperty(exports, "slice", { enumerable: true, get: function () { return sequence_js_1.slice; } }); +Object.defineProperty(exports, "startsWith", { enumerable: true, get: function () { return sequence_js_1.startsWith; } }); +Object.defineProperty(exports, "tail", { enumerable: true, get: function () { return sequence_js_1.tail; } }); diff --git a/node_modules/@peculiar/utils/build/cjs/bytes/sequence.js b/node_modules/@peculiar/utils/build/cjs/bytes/sequence.js new file mode 100644 index 0000000000000000000000000000000000000000..2aec515a1151b65942ad05d782bde7bf23fadf6a --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/bytes/sequence.js @@ -0,0 +1,161 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.indexOf = indexOf; +exports.lastIndexOf = lastIndexOf; +exports.includes = includes; +exports.startsWith = startsWith; +exports.endsWith = endsWith; +exports.slice = slice; +exports.tail = tail; +exports.copy = copy; +exports.compare = compare; +const buffer_source_js_1 = require("./buffer-source.js"); +function clampIndex(value, fallback, length) { + const normalized = Number.isFinite(value) ? Math.trunc(value) : fallback; + if (normalized <= 0) { + return 0; + } + if (normalized >= length) { + return length; + } + return normalized; +} +function normalizeForwardRange(length, options) { + const start = clampIndex(options?.start, 0, length); + const end = clampIndex(options?.end, length, length); + return end >= start ? [start, end] : [start, start]; +} +function normalizeReverseRange(length, options) { + const start = clampIndex(options?.start, length, length); + const end = clampIndex(options?.end, 0, length); + return start >= end ? [end, start] : [start, start]; +} +function normalizeSliceIndex(value, fallback, length) { + const normalized = Number.isFinite(value) ? Math.trunc(value) : fallback; + if (normalized < 0) { + return Math.max(length + normalized, 0); + } + if (normalized > length) { + return length; + } + return normalized; +} +function encodeAscii(text) { + const bytes = new Uint8Array(text.length); + for (let i = 0; i < text.length; i++) { + bytes[i] = text.charCodeAt(i) & 0xff; + } + return bytes; +} +function encodeUtf8(text) { + return new TextEncoder().encode(text); +} +function toPatternBytes(pattern, options) { + if (typeof pattern === "string") { + return options?.encoding === "utf8" ? encodeUtf8(pattern) : encodeAscii(pattern); + } + return (0, buffer_source_js_1.toUint8Array)(pattern); +} +function bytesEqualAt(data, pattern, offset) { + for (let index = 0; index < pattern.byteLength; index++) { + if (data[offset + index] !== pattern[index]) { + return false; + } + } + return true; +} +function indexOf(data, pattern, options) { + const bytes = (0, buffer_source_js_1.toUint8Array)(data); + const needle = toPatternBytes(pattern, options); + const [start, end] = normalizeForwardRange(bytes.byteLength, options); + if (needle.byteLength === 0) { + return start; + } + const lastOffset = end - needle.byteLength; + if (lastOffset < start) { + return -1; + } + for (let offset = start; offset <= lastOffset; offset++) { + if (bytesEqualAt(bytes, needle, offset)) { + return offset; + } + } + return -1; +} +function lastIndexOf(data, pattern, options) { + const bytes = (0, buffer_source_js_1.toUint8Array)(data); + const needle = toPatternBytes(pattern, options); + const [end, start] = normalizeReverseRange(bytes.byteLength, options); + if (needle.byteLength === 0) { + return start; + } + const firstOffset = start - needle.byteLength; + if (firstOffset < end) { + return -1; + } + for (let offset = firstOffset; offset >= end; offset--) { + if (bytesEqualAt(bytes, needle, offset)) { + return offset; + } + } + return -1; +} +function includes(data, pattern, options) { + return indexOf(data, pattern, options) !== -1; +} +function startsWith(data, pattern, options) { + const bytes = (0, buffer_source_js_1.toUint8Array)(data); + const needle = toPatternBytes(pattern, options); + if (needle.byteLength > bytes.byteLength) { + return false; + } + return bytesEqualAt(bytes, needle, 0); +} +function endsWith(data, pattern, options) { + const bytes = (0, buffer_source_js_1.toUint8Array)(data); + const needle = toPatternBytes(pattern, options); + if (needle.byteLength > bytes.byteLength) { + return false; + } + return bytesEqualAt(bytes, needle, bytes.byteLength - needle.byteLength); +} +function slice(data, start, end) { + const bytes = (0, buffer_source_js_1.toUint8Array)(data); + const normalizedStart = normalizeSliceIndex(start, 0, bytes.byteLength); + const normalizedEnd = normalizeSliceIndex(end, bytes.byteLength, bytes.byteLength); + if (normalizedEnd <= normalizedStart) { + return bytes.subarray(normalizedStart, normalizedStart); + } + return bytes.subarray(normalizedStart, normalizedEnd); +} +function tail(data, length) { + const bytes = (0, buffer_source_js_1.toUint8Array)(data); + const normalizedLength = Number.isFinite(length) ? Math.max(0, Math.trunc(length)) : 0; + if (normalizedLength >= bytes.byteLength) { + return bytes; + } + return bytes.subarray(bytes.byteLength - normalizedLength); +} +function copy(data) { + return (0, buffer_source_js_1.toUint8ArrayCopy)(data); +} +function compare(a, b) { + const left = (0, buffer_source_js_1.toUint8Array)(a); + const right = (0, buffer_source_js_1.toUint8Array)(b); + const limit = Math.min(left.byteLength, right.byteLength); + for (let index = 0; index < limit; index++) { + if (left[index] < right[index]) { + return -1; + } + if (left[index] > right[index]) { + return 1; + } + } + if (left.byteLength < right.byteLength) { + return -1; + } + if (left.byteLength > right.byteLength) { + return 1; + } + return 0; +} diff --git a/node_modules/@peculiar/utils/build/cjs/bytes/types.js b/node_modules/@peculiar/utils/build/cjs/bytes/types.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/bytes/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@peculiar/utils/build/cjs/converters/convert.js b/node_modules/@peculiar/utils/build/cjs/converters/convert.js new file mode 100644 index 0000000000000000000000000000000000000000..874f1c362d62bf33fb411aa14ca440146470ed8c --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/converters/convert.js @@ -0,0 +1,74 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.convert = void 0; +const index_js_1 = require("../bytes/index.js"); +const index_js_2 = require("../encoding/index.js"); +const defaults_js_1 = require("./defaults.js"); +function encode(name, data, ...args) { + return defaults_js_1.defaultConverterRegistry.encode(name, data, ...args); +} +function decode(name, text, ...args) { + return defaults_js_1.defaultConverterRegistry.decode(name, text, ...args); +} +function tryDecode(name, text, ...args) { + return defaults_js_1.defaultConverterRegistry.tryDecode(name, text, ...args); +} +function normalize(name, text, ...args) { + return defaults_js_1.defaultConverterRegistry.normalize(name, text, ...args); +} +function parse(name, text, ...args) { + return defaults_js_1.defaultConverterRegistry.parse(name, text, ...args); +} +function format(name, data, value) { + return defaults_js_1.defaultConverterRegistry.format(name, data, value); +} +function transcode(text, options) { + return defaults_js_1.defaultConverterRegistry.transcode(text, options); +} +function detect(text, options) { + return defaults_js_1.defaultConverterRegistry.detect(text, options); +} +function normalizeEncodingName(encoding) { + return encoding.toLowerCase(); +} +exports.convert = { + encode, + decode, + tryDecode, + normalize, + parse, + format, + transcode, + detect, + to(format, data, ...args) { + return encode(format, data, ...args); + }, + from(format, text, ...args) { + return decode(format, text, ...args); + }, + toString(data, encoding = "utf8") { + return encode(encoding, data); + }, + fromString(text, encoding = "utf8") { + if (normalizeEncodingName(encoding) === "hex") { + return (0, index_js_1.toArrayBuffer)(index_js_2.hex.decode(text, { allowOddLength: true })); + } + return (0, index_js_1.toArrayBuffer)(decode(encoding, text)); + }, + toBase64: index_js_2.base64.encode, + fromBase64: (text) => (0, index_js_1.toArrayBuffer)(index_js_2.base64.decode(text)), + toBase64Url: index_js_2.base64url.encode, + fromBase64Url: (text) => (0, index_js_1.toArrayBuffer)(index_js_2.base64url.decode(text)), + toHex: index_js_2.hex.encode, + fromHex: (text) => (0, index_js_1.toArrayBuffer)(index_js_2.hex.decode(text, { allowOddLength: true })), + toBinary: index_js_2.binary.encode, + fromBinary: (text) => (0, index_js_1.toArrayBuffer)(index_js_2.binary.decode(text)), + toUtf8String: index_js_2.utf8.decode, + fromUtf8String: (text) => (0, index_js_1.toArrayBuffer)(index_js_2.utf8.encode(text)), + toUtf16String: (data, littleEndian = false) => index_js_2.utf16.decode(data, { littleEndian }), + fromUtf16String: (text, littleEndian = false) => (0, index_js_1.toArrayBuffer)(index_js_2.utf16.encode(text, { littleEndian })), + isHex: index_js_2.hex.is, + isBase64: index_js_2.base64.is, + isBase64Url: index_js_2.base64url.is, + formatString: index_js_2.base64.normalize, +}; diff --git a/node_modules/@peculiar/utils/build/cjs/converters/defaults.js b/node_modules/@peculiar/utils/build/cjs/converters/defaults.js new file mode 100644 index 0000000000000000000000000000000000000000..8fa14f5b809317e24f4489465f1fcc4434a107e1 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/converters/defaults.js @@ -0,0 +1,72 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.defaultConverterRegistry = exports.defaultConverters = exports.utf16leConverter = exports.utf16beConverter = exports.utf8Converter = exports.base64urlConverter = exports.base64Converter = exports.hexConverter = exports.binaryConverter = exports.pemConverter = void 0; +const index_js_1 = require("../encoding/index.js"); +const index_js_2 = require("../pem/index.js"); +var index_js_3 = require("../pem/index.js"); +Object.defineProperty(exports, "pemConverter", { enumerable: true, get: function () { return index_js_3.pemConverter; } }); +const registry_js_1 = require("./registry.js"); +exports.binaryConverter = { + name: "binary", + aliases: ["latin1"], + encode: index_js_1.binary.encode, + decode: index_js_1.binary.decode, + is: index_js_1.binary.is, +}; +exports.hexConverter = { + name: "hex", + encode: index_js_1.hex.encode, + decode: index_js_1.hex.decode, + format: index_js_1.hex.format, + is: index_js_1.hex.is, + normalize: index_js_1.hex.normalize, + parse: index_js_1.hex.parse, +}; +exports.base64Converter = { + name: "base64", + aliases: ["b64"], + encode: index_js_1.base64.encode, + decode: index_js_1.base64.decode, + is: index_js_1.base64.is, + normalize: index_js_1.base64.normalize, +}; +exports.base64urlConverter = { + name: "base64url", + aliases: ["base64-url", "b64url"], + encode: index_js_1.base64url.encode, + decode: index_js_1.base64url.decode, + is: index_js_1.base64url.is, + normalize: index_js_1.base64url.normalize, +}; +exports.utf8Converter = { + name: "utf8", + aliases: ["utf-8"], + encode: (data) => index_js_1.utf8.decode(data), + decode: (text) => index_js_1.utf8.encode(text), + is: (text) => typeof text === "string", +}; +exports.utf16beConverter = { + name: "utf16be", + aliases: ["utf16", "utf-16", "utf-16be"], + encode: (data) => index_js_1.utf16.decode(data), + decode: (text) => index_js_1.utf16.encode(text), + is: (text) => typeof text === "string", +}; +exports.utf16leConverter = { + name: "utf16le", + aliases: ["utf-16le", "ucs2", "usc2"], + encode: (data) => index_js_1.utf16.decode(data, { littleEndian: true }), + decode: (text) => index_js_1.utf16.encode(text, { littleEndian: true }), + is: (text) => typeof text === "string", +}; +exports.defaultConverters = [ + exports.binaryConverter, + exports.hexConverter, + exports.base64Converter, + exports.base64urlConverter, + exports.utf8Converter, + exports.utf16beConverter, + exports.utf16leConverter, + index_js_2.pemConverter, +]; +exports.defaultConverterRegistry = (0, registry_js_1.createConverterRegistry)(exports.defaultConverters); diff --git a/node_modules/@peculiar/utils/build/cjs/converters/index.js b/node_modules/@peculiar/utils/build/cjs/converters/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a211ff1bd58c9d2ab586e0dd3e869d587686cd21 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/converters/index.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.convert = exports.utf8Converter = exports.utf16leConverter = exports.utf16beConverter = exports.pemConverter = exports.hexConverter = exports.defaultConverters = exports.defaultConverterRegistry = exports.binaryConverter = exports.base64urlConverter = exports.base64Converter = exports.createConverterRegistry = void 0; +var registry_js_1 = require("./registry.js"); +Object.defineProperty(exports, "createConverterRegistry", { enumerable: true, get: function () { return registry_js_1.createConverterRegistry; } }); +var defaults_js_1 = require("./defaults.js"); +Object.defineProperty(exports, "base64Converter", { enumerable: true, get: function () { return defaults_js_1.base64Converter; } }); +Object.defineProperty(exports, "base64urlConverter", { enumerable: true, get: function () { return defaults_js_1.base64urlConverter; } }); +Object.defineProperty(exports, "binaryConverter", { enumerable: true, get: function () { return defaults_js_1.binaryConverter; } }); +Object.defineProperty(exports, "defaultConverterRegistry", { enumerable: true, get: function () { return defaults_js_1.defaultConverterRegistry; } }); +Object.defineProperty(exports, "defaultConverters", { enumerable: true, get: function () { return defaults_js_1.defaultConverters; } }); +Object.defineProperty(exports, "hexConverter", { enumerable: true, get: function () { return defaults_js_1.hexConverter; } }); +Object.defineProperty(exports, "pemConverter", { enumerable: true, get: function () { return defaults_js_1.pemConverter; } }); +Object.defineProperty(exports, "utf16beConverter", { enumerable: true, get: function () { return defaults_js_1.utf16beConverter; } }); +Object.defineProperty(exports, "utf16leConverter", { enumerable: true, get: function () { return defaults_js_1.utf16leConverter; } }); +Object.defineProperty(exports, "utf8Converter", { enumerable: true, get: function () { return defaults_js_1.utf8Converter; } }); +var convert_js_1 = require("./convert.js"); +Object.defineProperty(exports, "convert", { enumerable: true, get: function () { return convert_js_1.convert; } }); diff --git a/node_modules/@peculiar/utils/build/cjs/converters/registry.js b/node_modules/@peculiar/utils/build/cjs/converters/registry.js new file mode 100644 index 0000000000000000000000000000000000000000..04be0a7a499e0f0fc9296a62a631e913d31bc459 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/converters/registry.js @@ -0,0 +1,188 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createConverterRegistry = createConverterRegistry; +function keyOf(name) { + return name.trim().toLowerCase(); +} +function toError(error) { + return error instanceof Error ? error : new Error(String(error)); +} +function removeConverter(converters, primaryNames, converter) { + for (const alias of [converter.name, ...(converter.aliases ?? [])]) { + converters.delete(keyOf(alias)); + } + primaryNames.delete(keyOf(converter.name)); +} +function requireCapability(converter, name, capability) { + const method = converter[capability]; + if (typeof method !== "function") { + throw new Error(`Converter '${name}' does not support ${capability}()`); + } + return method; +} +function detectConfidence(name, text, converter) { + const normalizedName = keyOf(converter.name || name); + const trimmed = text.trim(); + if (!trimmed) { + return 0; + } + let accepted = false; + if (converter.is) { + accepted = converter.is(text); + } + let decodable = false; + try { + converter.decode(text); + decodable = true; + } + catch { + decodable = false; + } + if (!accepted && !decodable) { + return 0; + } + switch (normalizedName) { + case "pem": + return /-----BEGIN [^-]+-----/.test(text) ? 1 : 0; + case "hex": { + const compact = trimmed.replace(/^0x/i, "").replace(/[\s:.-]/g, ""); + if (!compact || /[^0-9a-f]/i.test(compact) || compact.length % 2 !== 0) { + return 0; + } + if (/^0x/i.test(trimmed) || /[:\s.-]/.test(trimmed)) { + return 0.95; + } + if (/[a-f]/.test(trimmed) || /[A-F]/.test(trimmed)) { + return 0.8; + } + return 0.45; + } + case "base64url": + if (/[-_]/.test(trimmed)) { + return 0.95; + } + if (/=/.test(trimmed)) { + return 0.1; + } + return 0.6; + case "base64": + if (/[+/=]/.test(trimmed)) { + return 0.9; + } + return 0.55; + case "binary": + case "utf8": + case "utf16be": + case "utf16le": + return 0; + default: + return accepted && decodable ? 0.75 : 0.5; + } +} +function createConverterRegistry(initialConverters = []) { + const converters = new Map(); + const primaryNames = new Set(); + const api = { + register(converter, options = {}) { + if (!converter.name || !keyOf(converter.name)) { + throw new TypeError("Converter name is required"); + } + const names = [...new Set([converter.name, ...(converter.aliases ?? [])].map(keyOf))]; + const conflicts = new Set(); + for (const name of names) { + const existing = converters.get(name); + if (!existing) { + continue; + } + if (!options.override) { + throw new Error(`Converter '${name}' is already registered`); + } + conflicts.add(existing); + } + for (const conflicting of conflicts) { + removeConverter(converters, primaryNames, conflicting); + } + for (const name of names) { + converters.set(name, converter); + } + primaryNames.add(keyOf(converter.name)); + return this; + }, + unregister(name) { + const converter = converters.get(keyOf(name)); + if (!converter) { + return false; + } + removeConverter(converters, primaryNames, converter); + return true; + }, + has(name) { + return converters.has(keyOf(name)); + }, + get(name) { + const converter = converters.get(keyOf(name)); + if (!converter) { + throw new Error(`Converter '${name}' is not registered`); + } + return converter; + }, + list() { + return [...primaryNames].map((name) => this.get(name)); + }, + encode(name, data, options) { + return this.get(name).encode(data, options); + }, + decode(name, text, options) { + return this.get(name).decode(text, options); + }, + tryDecode(name, text, options) { + try { + return { ok: true, bytes: this.decode(name, text, options) }; + } + catch (error) { + return { ok: false, error: toError(error) }; + } + }, + normalize(name, text, options) { + const converter = this.get(name); + return requireCapability(converter, name, "normalize").call(converter, text, options); + }, + parse(name, text, options) { + const converter = this.get(name); + return requireCapability(converter, name, "parse").call(converter, text, options); + }, + format(name, data, format) { + const converter = this.get(name); + return requireCapability(converter, name, "format").call(converter, data, format); + }, + transcode(text, options) { + const bytes = this.decode(options.from, text, options.fromOptions); + return this.encode(options.to, bytes, options.toOptions); + }, + detect(text, options = {}) { + const formatNames = options.formats?.length + ? options.formats.map((name) => String(name)) + : this.list() + .map((converter) => converter.name) + .filter((name) => !["binary", "utf8", "utf16be", "utf16le"].includes(keyOf(name))); + const detections = new Map(); + for (const requestedName of formatNames) { + const converter = this.get(requestedName); + const confidence = detectConfidence(requestedName, text, converter); + if (confidence <= 0) { + continue; + } + const format = converter.name; + const current = detections.get(format); + if (!current || confidence > current.confidence) { + detections.set(format, { format, confidence }); + } + } + return [...detections.values()].sort((left, right) => right.confidence - left.confidence); + }, + }; + for (const converter of initialConverters) { + api.register(converter); + } + return api; +} diff --git a/node_modules/@peculiar/utils/build/cjs/converters/types.js b/node_modules/@peculiar/utils/build/cjs/converters/types.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/converters/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@peculiar/utils/build/cjs/encoding/base64.js b/node_modules/@peculiar/utils/build/cjs/encoding/base64.js new file mode 100644 index 0000000000000000000000000000000000000000..3fbecb042f167c089bde5e0a085838dccf9946cb --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/encoding/base64.js @@ -0,0 +1,48 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.base64 = void 0; +exports.normalize = normalize; +exports.pad = pad; +exports.is = is; +exports.encode = encode; +exports.decode = decode; +const index_js_1 = require("../bytes/index.js"); +const binary_js_1 = require("./binary.js"); +const BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/; +function nodeBuffer() { + return globalThis.Buffer; +} +function normalize(text) { + return text.replace(/[\n\r\t ]/g, ""); +} +function pad(text) { + const remainder = text.length % 4; + return remainder ? text + "=".repeat(4 - remainder) : text; +} +function is(text) { + if (typeof text !== "string") { + return false; + } + const normalized = normalize(text); + return normalized === "" || BASE64_REGEX.test(normalized); +} +function encode(data, _options) { + const bytes = (0, index_js_1.toUint8Array)(data); + const buffer = nodeBuffer(); + if (buffer) { + return buffer.from(bytes).toString("base64"); + } + return btoa((0, binary_js_1.encode)(bytes)); +} +function decode(text, _options) { + const normalized = normalize(text); + if (!is(normalized)) { + throw new TypeError("Input is not valid Base64 text"); + } + const buffer = nodeBuffer(); + if (buffer) { + return new Uint8Array(buffer.from(normalized, "base64")); + } + return (0, binary_js_1.decode)(atob(normalized)); +} +exports.base64 = { encode, decode, is, normalize, pad }; diff --git a/node_modules/@peculiar/utils/build/cjs/encoding/base64url.js b/node_modules/@peculiar/utils/build/cjs/encoding/base64url.js new file mode 100644 index 0000000000000000000000000000000000000000..0382c9fd2c9c24ee67c71da18cf610cc3654b773 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/encoding/base64url.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.base64url = void 0; +exports.normalize = normalize; +exports.is = is; +exports.encode = encode; +exports.decode = decode; +const base64_js_1 = require("./base64.js"); +const BASE64URL_REGEX = /^[A-Za-z0-9_-]*$/; +function normalize(text) { + return text.replace(/[\n\r\t ]/g, ""); +} +function is(text) { + return typeof text === "string" && BASE64URL_REGEX.test(normalize(text)); +} +function encode(data, _options) { + return base64_js_1.base64.encode(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, ""); +} +function decode(text, _options) { + const normalized = normalize(text); + if (!is(normalized)) { + throw new TypeError("Input is not valid Base64Url text"); + } + return base64_js_1.base64.decode(base64_js_1.base64.pad(normalized.replace(/-/g, "+").replace(/_/g, "/"))); +} +exports.base64url = { encode, decode, is, normalize }; diff --git a/node_modules/@peculiar/utils/build/cjs/encoding/binary.js b/node_modules/@peculiar/utils/build/cjs/encoding/binary.js new file mode 100644 index 0000000000000000000000000000000000000000..67396776c2022b1f5313df2bcd2929ff7721498c --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/encoding/binary.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.binary = void 0; +exports.encode = encode; +exports.decode = decode; +exports.is = is; +const index_js_1 = require("../bytes/index.js"); +function encode(data) { + const bytes = (0, index_js_1.toUint8Array)(data); + let result = ""; + for (const byte of bytes) { + result += String.fromCharCode(byte); + } + return result; +} +function decode(text) { + const result = new Uint8Array(text.length); + for (let i = 0; i < text.length; i++) { + result[i] = text.charCodeAt(i) & 0xff; + } + return result; +} +function is(text) { + return typeof text === "string"; +} +exports.binary = { encode, decode, is }; diff --git a/node_modules/@peculiar/utils/build/cjs/encoding/hex.js b/node_modules/@peculiar/utils/build/cjs/encoding/hex.js new file mode 100644 index 0000000000000000000000000000000000000000..46a030021c046821f9f076cd17768df47400df58 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/encoding/hex.js @@ -0,0 +1,229 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.hex = exports.formats = void 0; +exports.normalize = normalize; +exports.is = is; +exports.encode = encode; +exports.decode = decode; +exports.parse = parse; +exports.format = format; +const index_js_1 = require("../bytes/index.js"); +const HEX_CHARACTER_REGEX = /^[0-9a-f]$/i; +const COMMON_SEPARATORS = [" ", "\t", "\n", "\r", ":", "-", "."]; +function resolveSeparators(options) { + if (options.separators === "none") { + return []; + } + if (!options.separators || options.separators === "common") { + return COMMON_SEPARATORS; + } + return options.separators; +} +function validateSeparator(separator) { + if (!separator) { + throw new TypeError("Hex separators must be non-empty strings"); + } +} +function matchSeparator(text, index, separators) { + for (const separator of separators) { + if (text.startsWith(separator, index)) { + return separator; + } + } + return undefined; +} +function detectCase(text) { + const hasUpper = /[A-F]/.test(text); + const hasLower = /[a-f]/.test(text); + return hasUpper && !hasLower ? "upper" : "lower"; +} +function detectLineSeparator(text) { + const match = /\r\n|\n/.exec(text); + if (!match) { + return undefined; + } + return match[0] === "\r\n" ? "\r\n" : "\n"; +} +function compactForDetection(text) { + return text.replace(/[^0-9a-f]/gi, ""); +} +function detectGroup(text) { + const segments = text.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g) ?? []; + if (segments.length < 3) { + return undefined; + } + const hexSegments = segments.filter((_, index) => index % 2 === 0); + const separators = segments.filter((_, index) => index % 2 === 1); + const separator = separators[0]; + if (!separator || separators.some((item) => item !== separator)) { + return undefined; + } + if (hexSegments.some((segment) => segment.length === 0 || segment.length % 2 !== 0)) { + return undefined; + } + const firstLength = hexSegments[0]?.length ?? 0; + if (!firstLength) { + return undefined; + } + if (hexSegments.slice(0, -1).some((segment) => segment.length !== firstLength)) { + return undefined; + } + if ((hexSegments[hexSegments.length - 1]?.length ?? 0) > firstLength) { + return undefined; + } + return { + size: firstLength / 2, + separator, + }; +} +function detectFormat(text) { + const trimmed = text.trim(); + const prefix = /^0x/i.test(trimmed) ? "0x" : ""; + const body = prefix ? trimmed.slice(2) : trimmed; + const lineSeparator = detectLineSeparator(body); + const lines = body.split(/\r\n|\n/).filter((line) => line.length > 0); + const sampleLine = lines[0]?.trim() ?? ""; + const group = detectGroup(sampleLine); + const format = { + case: detectCase(trimmed), + prefix, + }; + if (group) { + format.group = group; + } + if (lineSeparator && lines.length > 1) { + const firstLineBytes = compactForDetection(lines[0] ?? "").length / 2; + if (firstLineBytes > 0 && lines.slice(0, -1).every((line) => compactForDetection(line).length / 2 === firstLineBytes)) { + format.line = { + bytesPerLine: firstLineBytes, + separator: lineSeparator, + }; + } + } + return format; +} +function normalizeText(text, options) { + const allowPrefix = options.allowPrefix ?? true; + const separators = [...resolveSeparators(options)].sort((left, right) => right.length - left.length); + for (const separator of separators) { + validateSeparator(separator); + } + let working = text.trim(); + if (/^0x/i.test(working)) { + if (!allowPrefix) { + throw new TypeError("Hexadecimal text must not include a 0x prefix"); + } + working = working.slice(2); + } + let normalized = ""; + let lastTokenWasSeparator = false; + for (let index = 0; index < working.length;) { + const character = working[index] ?? ""; + if (HEX_CHARACTER_REGEX.test(character)) { + normalized += character; + lastTokenWasSeparator = false; + index += 1; + continue; + } + const separator = matchSeparator(working, index, separators); + if (!separator) { + throw new TypeError("Input is not valid hexadecimal text"); + } + if (options.strict && (lastTokenWasSeparator || normalized.length === 0)) { + throw new TypeError("Hexadecimal text contains misplaced separators"); + } + lastTokenWasSeparator = true; + index += separator.length; + } + if (options.strict && lastTokenWasSeparator && normalized.length > 0) { + throw new TypeError("Hexadecimal text must not end with a separator"); + } + if (normalized.length % 2 !== 0) { + if (!options.allowOddLength) { + throw new TypeError("Hexadecimal text must contain an even number of characters"); + } + normalized = `0${normalized}`; + } + return normalized.toLowerCase(); +} +function groupPairs(pairs, group) { + if (!group) { + return pairs.join(""); + } + if (!Number.isInteger(group.size) || group.size < 1) { + throw new RangeError("Hex group size must be a positive integer"); + } + const chunks = []; + for (let index = 0; index < pairs.length; index += group.size) { + chunks.push(pairs.slice(index, index + group.size).join("")); + } + return chunks.join(group.separator); +} +function normalize(text, options = {}) { + return normalizeText(text, options); +} +function is(text, options = {}) { + if (typeof text !== "string") { + return false; + } + try { + normalize(text, options); + return true; + } + catch { + return false; + } +} +function encode(data, options = {}) { + const bytes = (0, index_js_1.toUint8Array)(data); + const casing = options.case ?? "lower"; + const pairs = Array.from(bytes, (byte) => { + const text = byte.toString(16).padStart(2, "0"); + return casing === "upper" ? text.toUpperCase() : text; + }); + let body = ""; + if (options.line) { + const bytesPerLine = options.line.bytesPerLine; + if (!Number.isInteger(bytesPerLine) || bytesPerLine < 1) { + throw new RangeError("Hex bytesPerLine must be a positive integer"); + } + const separator = options.line.separator ?? "\n"; + const lines = []; + for (let index = 0; index < pairs.length; index += bytesPerLine) { + lines.push(groupPairs(pairs.slice(index, index + bytesPerLine), options.group)); + } + body = lines.join(separator); + } + else { + body = groupPairs(pairs, options.group); + } + return `${options.prefix ?? ""}${body}`; +} +function decode(text, options = {}) { + const normalized = normalize(text, options); + const result = new Uint8Array(normalized.length / 2); + for (let i = 0; i < normalized.length; i += 2) { + result[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16); + } + return result; +} +function parse(text, options = {}) { + const normalized = normalize(text, options); + return { + bytes: decode(normalized), + format: detectFormat(text), + normalized, + }; +} +function format(data, value) { + return encode(data, value); +} +exports.formats = { + compact: Object.freeze({}), + upper: Object.freeze({ case: "upper" }), + colon: Object.freeze({ group: { size: 1, separator: ":" } }), + colonUpper: Object.freeze({ case: "upper", group: { size: 1, separator: ":" } }), + groupsOf4: Object.freeze({ group: { size: 4, separator: " " } }), + prefixed: Object.freeze({ prefix: "0x" }), +}; +exports.hex = { encode, decode, format, formats: exports.formats, is, normalize, parse }; diff --git a/node_modules/@peculiar/utils/build/cjs/encoding/index.js b/node_modules/@peculiar/utils/build/cjs/encoding/index.js new file mode 100644 index 0000000000000000000000000000000000000000..27bc6ba9dea662e6f032a2a3aab3ec9bd3f48b9d --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/encoding/index.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.base64url = exports.base64 = exports.utf16 = exports.utf8 = exports.hex = exports.binary = void 0; +const tslib_1 = require("tslib"); +exports.binary = tslib_1.__importStar(require("./binary.js")); +exports.hex = tslib_1.__importStar(require("./hex.js")); +exports.utf8 = tslib_1.__importStar(require("./utf8.js")); +exports.utf16 = tslib_1.__importStar(require("./utf16.js")); +exports.base64 = tslib_1.__importStar(require("./base64.js")); +exports.base64url = tslib_1.__importStar(require("./base64url.js")); diff --git a/node_modules/@peculiar/utils/build/cjs/encoding/utf16.js b/node_modules/@peculiar/utils/build/cjs/encoding/utf16.js new file mode 100644 index 0000000000000000000000000000000000000000..5a5e625e2f95a6ea9f7ef806ee0376f9cbec256f --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/encoding/utf16.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.utf16 = void 0; +exports.encode = encode; +exports.decode = decode; +const index_js_1 = require("../bytes/index.js"); +function encode(text, options = {}) { + const result = new ArrayBuffer(text.length * 2); + const view = new DataView(result); + for (let i = 0; i < text.length; i++) { + view.setUint16(i * 2, text.charCodeAt(i), options.littleEndian ?? false); + } + return new Uint8Array(result); +} +function decode(data, options = {}) { + const buffer = (0, index_js_1.toArrayBuffer)(data); + const view = new DataView(buffer); + let result = ""; + for (let i = 0; i < buffer.byteLength; i += 2) { + result += String.fromCharCode(view.getUint16(i, options.littleEndian ?? false)); + } + return result; +} +exports.utf16 = { encode, decode }; diff --git a/node_modules/@peculiar/utils/build/cjs/encoding/utf8.js b/node_modules/@peculiar/utils/build/cjs/encoding/utf8.js new file mode 100644 index 0000000000000000000000000000000000000000..1b1326d176fa9dd949fe76d092e5ffbf851a8780 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/encoding/utf8.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.utf8 = void 0; +exports.encode = encode; +exports.decode = decode; +const index_js_1 = require("../bytes/index.js"); +function encode(text) { + return new TextEncoder().encode(text); +} +function decode(data) { + return new TextDecoder("utf-8", { fatal: false }).decode((0, index_js_1.toUint8Array)(data)); +} +exports.utf8 = { encode, decode }; diff --git a/node_modules/@peculiar/utils/build/cjs/index.js b/node_modules/@peculiar/utils/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e211eb6b1afe2cbc7f7839a651ed8239bec0bea5 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/index.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bytes = void 0; +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./bytes/index.js"), exports); +exports.bytes = tslib_1.__importStar(require("./bytes/index.js")); +tslib_1.__exportStar(require("./encoding/index.js"), exports); +tslib_1.__exportStar(require("./pem/index.js"), exports); +tslib_1.__exportStar(require("./converters/index.js"), exports); +tslib_1.__exportStar(require("./legacy/index.js"), exports); diff --git a/node_modules/@peculiar/utils/build/cjs/legacy/buffer-source-converter.js b/node_modules/@peculiar/utils/build/cjs/legacy/buffer-source-converter.js new file mode 100644 index 0000000000000000000000000000000000000000..1b77091ee0a182a5b170e9a3aaeaf81be7f9e70c --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/legacy/buffer-source-converter.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BufferSourceConverter = void 0; +const index_js_1 = require("../bytes/index.js"); +class BufferSourceConverter { + static isArrayBuffer(data) { + return (0, index_js_1.isArrayBuffer)(data); + } + static toArrayBuffer(data) { + return (0, index_js_1.toArrayBuffer)(data); + } + static toUint8Array(data) { + return (0, index_js_1.toUint8Array)(data); + } + static toView(data, type) { + return (0, index_js_1.toView)(data, type); + } + static isBufferSource(data) { + return (0, index_js_1.isBufferSource)(data); + } + static isArrayBufferView(data) { + return (0, index_js_1.isArrayBufferView)(data); + } + static isEqual(a, b) { + return (0, index_js_1.equal)(a, b); + } + static concat(first, second, ...rest) { + if (Array.isArray(first)) { + return typeof second === "function" + ? (0, index_js_1.concat)(first, second) + : (0, index_js_1.concat)(first); + } + const buffers = [first, second, ...rest].filter(Boolean); + return (0, index_js_1.concat)(buffers); + } +} +exports.BufferSourceConverter = BufferSourceConverter; diff --git a/node_modules/@peculiar/utils/build/cjs/legacy/convert.js b/node_modules/@peculiar/utils/build/cjs/legacy/convert.js new file mode 100644 index 0000000000000000000000000000000000000000..04d1068028fea4db0daf5bf97fdfb90079938de1 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/legacy/convert.js @@ -0,0 +1,72 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Convert = void 0; +const index_js_1 = require("../converters/index.js"); +function normalizeTextEncoding(encoding) { + return encoding === "ascii" ? "binary" : encoding; +} +class Convert { + static DEFAULT_UTF8_ENCODING = "utf8"; + static isHex(data) { + return index_js_1.convert.isHex(data); + } + static isBase64(data) { + return index_js_1.convert.isBase64(data); + } + static isBase64Url(data) { + return index_js_1.convert.isBase64Url(data); + } + static ToString(buffer, enc = "utf8") { + return index_js_1.convert.toString(buffer, enc); + } + static FromString(str, enc = "utf8") { + if (!str) { + return new ArrayBuffer(0); + } + return index_js_1.convert.fromString(str, enc); + } + static ToBase64(buffer) { + return index_js_1.convert.toBase64(buffer); + } + static FromBase64(base64) { + return index_js_1.convert.fromBase64(base64); + } + static FromBase64Url(base64url) { + return index_js_1.convert.fromBase64Url(base64url); + } + static ToBase64Url(data) { + return index_js_1.convert.toBase64Url(data); + } + static FromUtf8String(text, encoding = Convert.DEFAULT_UTF8_ENCODING) { + return index_js_1.convert.fromString(text, normalizeTextEncoding(encoding)); + } + static ToUtf8String(buffer, encoding = Convert.DEFAULT_UTF8_ENCODING) { + return index_js_1.convert.toString(buffer, normalizeTextEncoding(encoding)); + } + static FromBinary(text) { + return index_js_1.convert.fromBinary(text); + } + static ToBinary(buffer) { + return index_js_1.convert.toBinary(buffer); + } + static ToHex(buffer) { + return index_js_1.convert.toHex(buffer); + } + static FromHex(hexString) { + return index_js_1.convert.fromHex(hexString); + } + static ToUtf16String(buffer, littleEndian = false) { + return index_js_1.convert.toUtf16String(buffer, littleEndian); + } + static FromUtf16String(text, littleEndian = false) { + return index_js_1.convert.fromUtf16String(text, littleEndian); + } + static Base64Padding(base64) { + const padCount = 4 - (base64.length % 4); + return padCount < 4 ? base64 + "=".repeat(padCount) : base64; + } + static formatString(data) { + return index_js_1.convert.formatString(data); + } +} +exports.Convert = Convert; diff --git a/node_modules/@peculiar/utils/build/cjs/legacy/functions.js b/node_modules/@peculiar/utils/build/cjs/legacy/functions.js new file mode 100644 index 0000000000000000000000000000000000000000..26c96acfe0764986ca26fa1086a15ecdc73e93cc --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/legacy/functions.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.assign = assign; +exports.combine = combine; +exports.isEqual = isEqual; +const index_js_1 = require("../bytes/index.js"); +function assign(target, ...sources) { + for (const source of sources) { + if (!source) { + continue; + } + for (const prop in source) { + target[prop] = source[prop]; + } + } + return target; +} +function combine(...buf) { + return (0, index_js_1.concat)(buf); +} +function isEqual(bytes1, bytes2) { + return (0, index_js_1.equal)(bytes1, bytes2); +} diff --git a/node_modules/@peculiar/utils/build/cjs/legacy/index.js b/node_modules/@peculiar/utils/build/cjs/legacy/index.js new file mode 100644 index 0000000000000000000000000000000000000000..568ae85fa7b96fbb02c5c331c79b0c7e455456f5 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/legacy/index.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isEqual = exports.combine = exports.assign = exports.Convert = exports.BufferSourceConverter = void 0; +var buffer_source_converter_js_1 = require("./buffer-source-converter.js"); +Object.defineProperty(exports, "BufferSourceConverter", { enumerable: true, get: function () { return buffer_source_converter_js_1.BufferSourceConverter; } }); +var convert_js_1 = require("./convert.js"); +Object.defineProperty(exports, "Convert", { enumerable: true, get: function () { return convert_js_1.Convert; } }); +var functions_js_1 = require("./functions.js"); +Object.defineProperty(exports, "assign", { enumerable: true, get: function () { return functions_js_1.assign; } }); +Object.defineProperty(exports, "combine", { enumerable: true, get: function () { return functions_js_1.combine; } }); +Object.defineProperty(exports, "isEqual", { enumerable: true, get: function () { return functions_js_1.isEqual; } }); diff --git a/node_modules/@peculiar/utils/build/cjs/package.json b/node_modules/@peculiar/utils/build/cjs/package.json new file mode 100644 index 0000000000000000000000000000000000000000..5bbefffbabee392d1855491b84dc0a716b6a3bf2 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/node_modules/@peculiar/utils/build/cjs/pem/index.js b/node_modules/@peculiar/utils/build/cjs/pem/index.js new file mode 100644 index 0000000000000000000000000000000000000000..f94d30c18ccb62c312e802cc0e7e78aed6d5b456 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/pem/index.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.pemConverter = exports.pem = exports.parse = exports.format = exports.findAll = exports.find = exports.encodeMany = exports.encode = exports.decodeFirst = exports.decode = void 0; +var pem_js_1 = require("./pem.js"); +Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return pem_js_1.decode; } }); +Object.defineProperty(exports, "decodeFirst", { enumerable: true, get: function () { return pem_js_1.decodeFirst; } }); +Object.defineProperty(exports, "encode", { enumerable: true, get: function () { return pem_js_1.encode; } }); +Object.defineProperty(exports, "encodeMany", { enumerable: true, get: function () { return pem_js_1.encodeMany; } }); +Object.defineProperty(exports, "find", { enumerable: true, get: function () { return pem_js_1.find; } }); +Object.defineProperty(exports, "findAll", { enumerable: true, get: function () { return pem_js_1.findAll; } }); +Object.defineProperty(exports, "format", { enumerable: true, get: function () { return pem_js_1.format; } }); +Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return pem_js_1.parse; } }); +Object.defineProperty(exports, "pem", { enumerable: true, get: function () { return pem_js_1.pem; } }); +Object.defineProperty(exports, "pemConverter", { enumerable: true, get: function () { return pem_js_1.pemConverter; } }); diff --git a/node_modules/@peculiar/utils/build/cjs/pem/pem.js b/node_modules/@peculiar/utils/build/cjs/pem/pem.js new file mode 100644 index 0000000000000000000000000000000000000000..f272a0dba8f8057153bf2f86b77818b5ab6ad516 --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/pem/pem.js @@ -0,0 +1,140 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.pemConverter = exports.pem = void 0; +exports.encode = encode; +exports.encodeMany = encodeMany; +exports.decode = decode; +exports.find = find; +exports.findAll = findAll; +exports.decodeFirst = decodeFirst; +exports.parse = parse; +exports.format = format; +const base64_js_1 = require("../encoding/base64.js"); +const LABEL_REGEX = /^[A-Z0-9][A-Z0-9 ._-]*[A-Z0-9]$/i; +const PEM_BLOCK_REGEX = /-----BEGIN ([^-]+)-----([\s\S]*?)-----END \1-----/g; +function assertLabel(label) { + if (!LABEL_REGEX.test(label)) { + throw new TypeError(`Invalid PEM label '${label}'`); + } +} +function wrap(text, lineLength) { + const result = []; + for (let i = 0; i < text.length; i += lineLength) { + result.push(text.slice(i, i + lineLength)); + } + return result; +} +function parseBody(body) { + const normalized = body.trim().replace(/\r\n/g, "\n"); + const lines = normalized.split("\n").map((line) => line.trim()).filter(Boolean); + const headers = {}; + let index = 0; + for (; index < lines.length; index++) { + const line = lines[index]; + const separator = line.indexOf(":"); + if (separator <= 0) { + break; + } + headers[line.slice(0, separator).trim()] = line.slice(separator + 1).trim(); + } + return { + headers: Object.keys(headers).length ? headers : undefined, + base64Lines: lines.slice(index), + base64Text: lines.slice(index).join(""), + }; +} +function detectNewline(text) { + return /\r\n/.test(text) ? "\r\n" : "\n"; +} +function collectBlocks(text, options = {}) { + const blocks = []; + const requestedLabel = options.label; + let match; + PEM_BLOCK_REGEX.lastIndex = 0; + while ((match = PEM_BLOCK_REGEX.exec(text))) { + const label = match[1].trim(); + if (requestedLabel && label !== requestedLabel) { + continue; + } + assertLabel(label); + const parsed = parseBody(match[2]); + blocks.push({ + label, + data: base64_js_1.base64.decode(parsed.base64Text), + headers: parsed.headers, + lineLength: parsed.base64Lines[0]?.length ?? 64, + newline: detectNewline(match[0]), + }); + } + if (options.strict && blocks.length === 0) { + throw new TypeError(requestedLabel + ? `No PEM block with label '${requestedLabel}' was found` + : "No PEM blocks were found"); + } + return blocks; +} +function encode(label, data, options = {}) { + assertLabel(label); + const lineLength = options.lineLength ?? 64; + if (!Number.isInteger(lineLength) || lineLength < 1) { + throw new RangeError("PEM lineLength must be a positive integer"); + } + const newline = options.newline ?? "\n"; + const lines = [`-----BEGIN ${label}-----`]; + if (options.headers) { + for (const [name, value] of Object.entries(options.headers)) { + lines.push(`${name}: ${value}`); + } + lines.push(""); + } + lines.push(...wrap(base64_js_1.base64.encode(data), lineLength)); + lines.push(`-----END ${label}-----`); + return `${lines.join(newline)}${newline}`; +} +function encodeMany(blocks, options = {}) { + return blocks.map((block) => encode(block.label, block.data, { ...options, headers: block.headers ?? options.headers })).join(""); +} +function decode(text, options = {}) { + return collectBlocks(text, options).map(({ lineLength: _lineLength, newline: _newline, ...block }) => block); +} +function find(text, label) { + return decode(text, { label })[0]; +} +function findAll(text, label) { + return decode(text, { label }); +} +function decodeFirst(text, label) { + const [block] = decode(text, { label, strict: true }); + return block.data; +} +function parse(text, options = {}) { + const [block] = collectBlocks(text, { ...options, strict: true }); + const format = { + label: block.label, + headers: block.headers, + lineLength: block.lineLength, + newline: block.newline, + }; + return { + bytes: block.data, + format, + normalized: encode(block.label, block.data, format), + }; +} +function format(data, value) { + return encode(value.label, data, value); +} +exports.pem = { decode, decodeFirst, encode, encodeMany, find, findAll, format, parse }; +exports.pemConverter = { + name: "pem", + encode: (data, options) => { + if (!options?.label) { + throw new TypeError("PEM label is required"); + } + return encode(options.label, data, options); + }, + decode: (text, options) => decodeFirst(text, options?.label), + format, + is: (text) => typeof text === "string" && /-----BEGIN [^-]+-----/.test(text), + parse, +}; diff --git a/node_modules/@peculiar/utils/build/cjs/pem/types.js b/node_modules/@peculiar/utils/build/cjs/pem/types.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/node_modules/@peculiar/utils/build/cjs/pem/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@peculiar/utils/build/esm/bytes/buffer-source.js b/node_modules/@peculiar/utils/build/esm/bytes/buffer-source.js new file mode 100644 index 0000000000000000000000000000000000000000..1d3f94751b323d45c44faf94d190284970574129 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/bytes/buffer-source.js @@ -0,0 +1,101 @@ +const ARRAY_BUFFER_TAG = "[object ArrayBuffer]"; +const SHARED_ARRAY_BUFFER_TAG = "[object SharedArrayBuffer]"; +function tagOf(value) { + return Object.prototype.toString.call(value); +} +function isDataViewConstructor(type) { + return type === DataView || type.prototype instanceof DataView; +} +function bytesPerElement(type) { + if (isDataViewConstructor(type)) { + return 1; + } + const value = type.BYTES_PER_ELEMENT; + return value ?? 1; +} +function isArrayBufferViewLike(value) { + if (ArrayBuffer.isView(value)) { + return true; + } + if (!value || typeof value !== "object") { + return false; + } + const view = value; + return typeof view.byteOffset === "number" + && typeof view.byteLength === "number" + && isArrayBufferLike(view.buffer); +} +function copyBytes(data) { + const view = toUint8Array(data); + const copy = new Uint8Array(view.byteLength); + copy.set(view); + return copy; +} +export function isArrayBuffer(value) { + return tagOf(value) === ARRAY_BUFFER_TAG; +} +export function isSharedArrayBuffer(value) { + return typeof SharedArrayBuffer !== "undefined" && tagOf(value) === SHARED_ARRAY_BUFFER_TAG; +} +export function isArrayBufferLike(value) { + return isArrayBuffer(value) || isSharedArrayBuffer(value); +} +export function isArrayBufferView(value) { + return isArrayBufferViewLike(value); +} +export function isBufferSource(value) { + return isArrayBufferLike(value) || isArrayBufferView(value); +} +export function assertBufferSource(value) { + if (!isBufferSource(value)) { + throw new TypeError("Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView"); + } +} +export function toUint8Array(data) { + assertBufferSource(data); + if (isArrayBufferLike(data)) { + return new Uint8Array(data); + } + return new Uint8Array(data.buffer, data.byteOffset, data.byteLength); +} +export function toUint8ArrayCopy(data) { + return copyBytes(data); +} +export function toArrayBuffer(data) { + assertBufferSource(data); + if (isArrayBuffer(data)) { + return data; + } + const buffer = new ArrayBuffer(data.byteLength); + new Uint8Array(buffer).set(toUint8Array(data)); + return buffer; +} +export function toArrayBufferLike(data) { + assertBufferSource(data); + if (isArrayBufferLike(data)) { + return data; + } + if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) { + return data.buffer; + } + return copyBytes(data).buffer; +} +export function toView(data, type) { + assertBufferSource(data); + if (ArrayBuffer.isView(data) && data.constructor === type) { + return data; + } + const view = toUint8Array(data); + const elementSize = bytesPerElement(type); + if (view.byteOffset % elementSize !== 0 || view.byteLength % elementSize !== 0) { + throw new RangeError(`Cannot create ${type.name} over unaligned byte range`); + } + if (isDataViewConstructor(type)) { + return new type(view.buffer, view.byteOffset, view.byteLength); + } + return new type(view.buffer, view.byteOffset, view.byteLength / elementSize); +} +export function toViewCopy(data, type) { + const copy = toUint8ArrayCopy(data); + return toView(copy, type); +} diff --git a/node_modules/@peculiar/utils/build/esm/bytes/concat.js b/node_modules/@peculiar/utils/build/esm/bytes/concat.js new file mode 100644 index 0000000000000000000000000000000000000000..0a2742774779b925710a80806cb52091214a4034 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/bytes/concat.js @@ -0,0 +1,37 @@ +import { isBufferSource, toUint8Array, toView } from "./buffer-source.js"; +export function concatToUint8Array(buffers) { + const views = []; + let length = 0; + for (const buffer of buffers) { + const view = toUint8Array(buffer); + views.push(view); + length += view.byteLength; + } + const result = new Uint8Array(length); + let offset = 0; + for (const view of views) { + result.set(view, offset); + offset += view.byteLength; + } + return result; +} +export function concat(first, second, ...rest) { + let buffers; + let type; + if (typeof second === "function") { + buffers = Array.from(first); + type = second; + } + else if (isBufferSource(first)) { + buffers = [first, second, ...rest].filter(isBufferSource); + } + else { + buffers = Array.from(first); + if (second) { + buffers.push(second); + } + buffers.push(...rest); + } + const bytes = concatToUint8Array(buffers); + return type ? toView(bytes, type) : bytes.buffer; +} diff --git a/node_modules/@peculiar/utils/build/esm/bytes/equal.js b/node_modules/@peculiar/utils/build/esm/bytes/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..53adbec18388d378e34374f55ca5c699bafac06f --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/bytes/equal.js @@ -0,0 +1,14 @@ +import { toUint8Array } from "./buffer-source.js"; +export function equal(a, b, options = {}) { + const left = toUint8Array(a); + const right = toUint8Array(b); + if (!options.constantTime && left.byteLength !== right.byteLength) { + return false; + } + const length = Math.max(left.byteLength, right.byteLength); + let diff = left.byteLength ^ right.byteLength; + for (let i = 0; i < length; i++) { + diff |= (left[i] ?? 0) ^ (right[i] ?? 0); + } + return diff === 0; +} diff --git a/node_modules/@peculiar/utils/build/esm/bytes/index.js b/node_modules/@peculiar/utils/build/esm/bytes/index.js new file mode 100644 index 0000000000000000000000000000000000000000..77e4f3bddaeb0cf976d8f07ebd5d493de0c59f4d --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/bytes/index.js @@ -0,0 +1,4 @@ +export { assertBufferSource, isArrayBuffer, isArrayBufferLike, isArrayBufferView, isBufferSource, isSharedArrayBuffer, toArrayBuffer, toArrayBufferLike, toUint8Array, toUint8ArrayCopy, toView, toViewCopy, } from "./buffer-source.js"; +export { concat, concatToUint8Array } from "./concat.js"; +export { equal } from "./equal.js"; +export { compare, copy, endsWith, includes, indexOf, lastIndexOf, slice, startsWith, tail, } from "./sequence.js"; diff --git a/node_modules/@peculiar/utils/build/esm/bytes/sequence.js b/node_modules/@peculiar/utils/build/esm/bytes/sequence.js new file mode 100644 index 0000000000000000000000000000000000000000..df18490cb378b7d4e69deec3e038056e27a6fbd9 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/bytes/sequence.js @@ -0,0 +1,150 @@ +import { toUint8Array, toUint8ArrayCopy } from "./buffer-source.js"; +function clampIndex(value, fallback, length) { + const normalized = Number.isFinite(value) ? Math.trunc(value) : fallback; + if (normalized <= 0) { + return 0; + } + if (normalized >= length) { + return length; + } + return normalized; +} +function normalizeForwardRange(length, options) { + const start = clampIndex(options?.start, 0, length); + const end = clampIndex(options?.end, length, length); + return end >= start ? [start, end] : [start, start]; +} +function normalizeReverseRange(length, options) { + const start = clampIndex(options?.start, length, length); + const end = clampIndex(options?.end, 0, length); + return start >= end ? [end, start] : [start, start]; +} +function normalizeSliceIndex(value, fallback, length) { + const normalized = Number.isFinite(value) ? Math.trunc(value) : fallback; + if (normalized < 0) { + return Math.max(length + normalized, 0); + } + if (normalized > length) { + return length; + } + return normalized; +} +function encodeAscii(text) { + const bytes = new Uint8Array(text.length); + for (let i = 0; i < text.length; i++) { + bytes[i] = text.charCodeAt(i) & 0xff; + } + return bytes; +} +function encodeUtf8(text) { + return new TextEncoder().encode(text); +} +function toPatternBytes(pattern, options) { + if (typeof pattern === "string") { + return options?.encoding === "utf8" ? encodeUtf8(pattern) : encodeAscii(pattern); + } + return toUint8Array(pattern); +} +function bytesEqualAt(data, pattern, offset) { + for (let index = 0; index < pattern.byteLength; index++) { + if (data[offset + index] !== pattern[index]) { + return false; + } + } + return true; +} +export function indexOf(data, pattern, options) { + const bytes = toUint8Array(data); + const needle = toPatternBytes(pattern, options); + const [start, end] = normalizeForwardRange(bytes.byteLength, options); + if (needle.byteLength === 0) { + return start; + } + const lastOffset = end - needle.byteLength; + if (lastOffset < start) { + return -1; + } + for (let offset = start; offset <= lastOffset; offset++) { + if (bytesEqualAt(bytes, needle, offset)) { + return offset; + } + } + return -1; +} +export function lastIndexOf(data, pattern, options) { + const bytes = toUint8Array(data); + const needle = toPatternBytes(pattern, options); + const [end, start] = normalizeReverseRange(bytes.byteLength, options); + if (needle.byteLength === 0) { + return start; + } + const firstOffset = start - needle.byteLength; + if (firstOffset < end) { + return -1; + } + for (let offset = firstOffset; offset >= end; offset--) { + if (bytesEqualAt(bytes, needle, offset)) { + return offset; + } + } + return -1; +} +export function includes(data, pattern, options) { + return indexOf(data, pattern, options) !== -1; +} +export function startsWith(data, pattern, options) { + const bytes = toUint8Array(data); + const needle = toPatternBytes(pattern, options); + if (needle.byteLength > bytes.byteLength) { + return false; + } + return bytesEqualAt(bytes, needle, 0); +} +export function endsWith(data, pattern, options) { + const bytes = toUint8Array(data); + const needle = toPatternBytes(pattern, options); + if (needle.byteLength > bytes.byteLength) { + return false; + } + return bytesEqualAt(bytes, needle, bytes.byteLength - needle.byteLength); +} +export function slice(data, start, end) { + const bytes = toUint8Array(data); + const normalizedStart = normalizeSliceIndex(start, 0, bytes.byteLength); + const normalizedEnd = normalizeSliceIndex(end, bytes.byteLength, bytes.byteLength); + if (normalizedEnd <= normalizedStart) { + return bytes.subarray(normalizedStart, normalizedStart); + } + return bytes.subarray(normalizedStart, normalizedEnd); +} +export function tail(data, length) { + const bytes = toUint8Array(data); + const normalizedLength = Number.isFinite(length) ? Math.max(0, Math.trunc(length)) : 0; + if (normalizedLength >= bytes.byteLength) { + return bytes; + } + return bytes.subarray(bytes.byteLength - normalizedLength); +} +export function copy(data) { + return toUint8ArrayCopy(data); +} +export function compare(a, b) { + const left = toUint8Array(a); + const right = toUint8Array(b); + const limit = Math.min(left.byteLength, right.byteLength); + for (let index = 0; index < limit; index++) { + if (left[index] < right[index]) { + return -1; + } + if (left[index] > right[index]) { + return 1; + } + } + if (left.byteLength < right.byteLength) { + return -1; + } + if (left.byteLength > right.byteLength) { + return 1; + } + return 0; +} diff --git a/node_modules/@peculiar/utils/build/esm/bytes/types.js b/node_modules/@peculiar/utils/build/esm/bytes/types.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/bytes/types.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@peculiar/utils/build/esm/converters/convert.js b/node_modules/@peculiar/utils/build/esm/converters/convert.js new file mode 100644 index 0000000000000000000000000000000000000000..901b477d85422b1dd32d943d9c36d228a964c650 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/converters/convert.js @@ -0,0 +1,71 @@ +import { toArrayBuffer } from "../bytes/index.js"; +import { base64, base64url, binary, hex, utf8, utf16 } from "../encoding/index.js"; +import { defaultConverterRegistry } from "./defaults.js"; +function encode(name, data, ...args) { + return defaultConverterRegistry.encode(name, data, ...args); +} +function decode(name, text, ...args) { + return defaultConverterRegistry.decode(name, text, ...args); +} +function tryDecode(name, text, ...args) { + return defaultConverterRegistry.tryDecode(name, text, ...args); +} +function normalize(name, text, ...args) { + return defaultConverterRegistry.normalize(name, text, ...args); +} +function parse(name, text, ...args) { + return defaultConverterRegistry.parse(name, text, ...args); +} +function format(name, data, value) { + return defaultConverterRegistry.format(name, data, value); +} +function transcode(text, options) { + return defaultConverterRegistry.transcode(text, options); +} +function detect(text, options) { + return defaultConverterRegistry.detect(text, options); +} +function normalizeEncodingName(encoding) { + return encoding.toLowerCase(); +} +export const convert = { + encode, + decode, + tryDecode, + normalize, + parse, + format, + transcode, + detect, + to(format, data, ...args) { + return encode(format, data, ...args); + }, + from(format, text, ...args) { + return decode(format, text, ...args); + }, + toString(data, encoding = "utf8") { + return encode(encoding, data); + }, + fromString(text, encoding = "utf8") { + if (normalizeEncodingName(encoding) === "hex") { + return toArrayBuffer(hex.decode(text, { allowOddLength: true })); + } + return toArrayBuffer(decode(encoding, text)); + }, + toBase64: base64.encode, + fromBase64: (text) => toArrayBuffer(base64.decode(text)), + toBase64Url: base64url.encode, + fromBase64Url: (text) => toArrayBuffer(base64url.decode(text)), + toHex: hex.encode, + fromHex: (text) => toArrayBuffer(hex.decode(text, { allowOddLength: true })), + toBinary: binary.encode, + fromBinary: (text) => toArrayBuffer(binary.decode(text)), + toUtf8String: utf8.decode, + fromUtf8String: (text) => toArrayBuffer(utf8.encode(text)), + toUtf16String: (data, littleEndian = false) => utf16.decode(data, { littleEndian }), + fromUtf16String: (text, littleEndian = false) => toArrayBuffer(utf16.encode(text, { littleEndian })), + isHex: hex.is, + isBase64: base64.is, + isBase64Url: base64url.is, + formatString: base64.normalize, +}; diff --git a/node_modules/@peculiar/utils/build/esm/converters/defaults.js b/node_modules/@peculiar/utils/build/esm/converters/defaults.js new file mode 100644 index 0000000000000000000000000000000000000000..ba22db8ad0bbcf84dfe19fc34e9f4c1469c236f2 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/converters/defaults.js @@ -0,0 +1,68 @@ +import { base64, base64url, binary, hex, utf8, utf16 } from "../encoding/index.js"; +import { pemConverter } from "../pem/index.js"; +export { pemConverter } from "../pem/index.js"; +import { createConverterRegistry } from "./registry.js"; +export const binaryConverter = { + name: "binary", + aliases: ["latin1"], + encode: binary.encode, + decode: binary.decode, + is: binary.is, +}; +export const hexConverter = { + name: "hex", + encode: hex.encode, + decode: hex.decode, + format: hex.format, + is: hex.is, + normalize: hex.normalize, + parse: hex.parse, +}; +export const base64Converter = { + name: "base64", + aliases: ["b64"], + encode: base64.encode, + decode: base64.decode, + is: base64.is, + normalize: base64.normalize, +}; +export const base64urlConverter = { + name: "base64url", + aliases: ["base64-url", "b64url"], + encode: base64url.encode, + decode: base64url.decode, + is: base64url.is, + normalize: base64url.normalize, +}; +export const utf8Converter = { + name: "utf8", + aliases: ["utf-8"], + encode: (data) => utf8.decode(data), + decode: (text) => utf8.encode(text), + is: (text) => typeof text === "string", +}; +export const utf16beConverter = { + name: "utf16be", + aliases: ["utf16", "utf-16", "utf-16be"], + encode: (data) => utf16.decode(data), + decode: (text) => utf16.encode(text), + is: (text) => typeof text === "string", +}; +export const utf16leConverter = { + name: "utf16le", + aliases: ["utf-16le", "ucs2", "usc2"], + encode: (data) => utf16.decode(data, { littleEndian: true }), + decode: (text) => utf16.encode(text, { littleEndian: true }), + is: (text) => typeof text === "string", +}; +export const defaultConverters = [ + binaryConverter, + hexConverter, + base64Converter, + base64urlConverter, + utf8Converter, + utf16beConverter, + utf16leConverter, + pemConverter, +]; +export const defaultConverterRegistry = createConverterRegistry(defaultConverters); diff --git a/node_modules/@peculiar/utils/build/esm/converters/index.js b/node_modules/@peculiar/utils/build/esm/converters/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b9ab6876f9a6568aee6229e97de548d318cdb73c --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/converters/index.js @@ -0,0 +1,3 @@ +export { createConverterRegistry } from "./registry.js"; +export { base64Converter, base64urlConverter, binaryConverter, defaultConverterRegistry, defaultConverters, hexConverter, pemConverter, utf16beConverter, utf16leConverter, utf8Converter, } from "./defaults.js"; +export { convert } from "./convert.js"; diff --git a/node_modules/@peculiar/utils/build/esm/converters/registry.js b/node_modules/@peculiar/utils/build/esm/converters/registry.js new file mode 100644 index 0000000000000000000000000000000000000000..b0237da472a2fa6f7e75d6907a3910635ccdc00b --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/converters/registry.js @@ -0,0 +1,185 @@ +function keyOf(name) { + return name.trim().toLowerCase(); +} +function toError(error) { + return error instanceof Error ? error : new Error(String(error)); +} +function removeConverter(converters, primaryNames, converter) { + for (const alias of [converter.name, ...(converter.aliases ?? [])]) { + converters.delete(keyOf(alias)); + } + primaryNames.delete(keyOf(converter.name)); +} +function requireCapability(converter, name, capability) { + const method = converter[capability]; + if (typeof method !== "function") { + throw new Error(`Converter '${name}' does not support ${capability}()`); + } + return method; +} +function detectConfidence(name, text, converter) { + const normalizedName = keyOf(converter.name || name); + const trimmed = text.trim(); + if (!trimmed) { + return 0; + } + let accepted = false; + if (converter.is) { + accepted = converter.is(text); + } + let decodable = false; + try { + converter.decode(text); + decodable = true; + } + catch { + decodable = false; + } + if (!accepted && !decodable) { + return 0; + } + switch (normalizedName) { + case "pem": + return /-----BEGIN [^-]+-----/.test(text) ? 1 : 0; + case "hex": { + const compact = trimmed.replace(/^0x/i, "").replace(/[\s:.-]/g, ""); + if (!compact || /[^0-9a-f]/i.test(compact) || compact.length % 2 !== 0) { + return 0; + } + if (/^0x/i.test(trimmed) || /[:\s.-]/.test(trimmed)) { + return 0.95; + } + if (/[a-f]/.test(trimmed) || /[A-F]/.test(trimmed)) { + return 0.8; + } + return 0.45; + } + case "base64url": + if (/[-_]/.test(trimmed)) { + return 0.95; + } + if (/=/.test(trimmed)) { + return 0.1; + } + return 0.6; + case "base64": + if (/[+/=]/.test(trimmed)) { + return 0.9; + } + return 0.55; + case "binary": + case "utf8": + case "utf16be": + case "utf16le": + return 0; + default: + return accepted && decodable ? 0.75 : 0.5; + } +} +export function createConverterRegistry(initialConverters = []) { + const converters = new Map(); + const primaryNames = new Set(); + const api = { + register(converter, options = {}) { + if (!converter.name || !keyOf(converter.name)) { + throw new TypeError("Converter name is required"); + } + const names = [...new Set([converter.name, ...(converter.aliases ?? [])].map(keyOf))]; + const conflicts = new Set(); + for (const name of names) { + const existing = converters.get(name); + if (!existing) { + continue; + } + if (!options.override) { + throw new Error(`Converter '${name}' is already registered`); + } + conflicts.add(existing); + } + for (const conflicting of conflicts) { + removeConverter(converters, primaryNames, conflicting); + } + for (const name of names) { + converters.set(name, converter); + } + primaryNames.add(keyOf(converter.name)); + return this; + }, + unregister(name) { + const converter = converters.get(keyOf(name)); + if (!converter) { + return false; + } + removeConverter(converters, primaryNames, converter); + return true; + }, + has(name) { + return converters.has(keyOf(name)); + }, + get(name) { + const converter = converters.get(keyOf(name)); + if (!converter) { + throw new Error(`Converter '${name}' is not registered`); + } + return converter; + }, + list() { + return [...primaryNames].map((name) => this.get(name)); + }, + encode(name, data, options) { + return this.get(name).encode(data, options); + }, + decode(name, text, options) { + return this.get(name).decode(text, options); + }, + tryDecode(name, text, options) { + try { + return { ok: true, bytes: this.decode(name, text, options) }; + } + catch (error) { + return { ok: false, error: toError(error) }; + } + }, + normalize(name, text, options) { + const converter = this.get(name); + return requireCapability(converter, name, "normalize").call(converter, text, options); + }, + parse(name, text, options) { + const converter = this.get(name); + return requireCapability(converter, name, "parse").call(converter, text, options); + }, + format(name, data, format) { + const converter = this.get(name); + return requireCapability(converter, name, "format").call(converter, data, format); + }, + transcode(text, options) { + const bytes = this.decode(options.from, text, options.fromOptions); + return this.encode(options.to, bytes, options.toOptions); + }, + detect(text, options = {}) { + const formatNames = options.formats?.length + ? options.formats.map((name) => String(name)) + : this.list() + .map((converter) => converter.name) + .filter((name) => !["binary", "utf8", "utf16be", "utf16le"].includes(keyOf(name))); + const detections = new Map(); + for (const requestedName of formatNames) { + const converter = this.get(requestedName); + const confidence = detectConfidence(requestedName, text, converter); + if (confidence <= 0) { + continue; + } + const format = converter.name; + const current = detections.get(format); + if (!current || confidence > current.confidence) { + detections.set(format, { format, confidence }); + } + } + return [...detections.values()].sort((left, right) => right.confidence - left.confidence); + }, + }; + for (const converter of initialConverters) { + api.register(converter); + } + return api; +} diff --git a/node_modules/@peculiar/utils/build/esm/converters/types.js b/node_modules/@peculiar/utils/build/esm/converters/types.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/converters/types.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@peculiar/utils/build/esm/encoding/base64.js b/node_modules/@peculiar/utils/build/esm/encoding/base64.js new file mode 100644 index 0000000000000000000000000000000000000000..b442aa38102007efd276b26b6e46b50e90b182b9 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/encoding/base64.js @@ -0,0 +1,40 @@ +import { toUint8Array } from "../bytes/index.js"; +import { encode as encodeBinary, decode as decodeBinary } from "./binary.js"; +const BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/; +function nodeBuffer() { + return globalThis.Buffer; +} +export function normalize(text) { + return text.replace(/[\n\r\t ]/g, ""); +} +export function pad(text) { + const remainder = text.length % 4; + return remainder ? text + "=".repeat(4 - remainder) : text; +} +export function is(text) { + if (typeof text !== "string") { + return false; + } + const normalized = normalize(text); + return normalized === "" || BASE64_REGEX.test(normalized); +} +export function encode(data, _options) { + const bytes = toUint8Array(data); + const buffer = nodeBuffer(); + if (buffer) { + return buffer.from(bytes).toString("base64"); + } + return btoa(encodeBinary(bytes)); +} +export function decode(text, _options) { + const normalized = normalize(text); + if (!is(normalized)) { + throw new TypeError("Input is not valid Base64 text"); + } + const buffer = nodeBuffer(); + if (buffer) { + return new Uint8Array(buffer.from(normalized, "base64")); + } + return decodeBinary(atob(normalized)); +} +export const base64 = { encode, decode, is, normalize, pad }; diff --git a/node_modules/@peculiar/utils/build/esm/encoding/base64url.js b/node_modules/@peculiar/utils/build/esm/encoding/base64url.js new file mode 100644 index 0000000000000000000000000000000000000000..e12f3fa2885b921fbddbad79c2fe4b92e67ada5f --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/encoding/base64url.js @@ -0,0 +1,19 @@ +import { base64 } from "./base64.js"; +const BASE64URL_REGEX = /^[A-Za-z0-9_-]*$/; +export function normalize(text) { + return text.replace(/[\n\r\t ]/g, ""); +} +export function is(text) { + return typeof text === "string" && BASE64URL_REGEX.test(normalize(text)); +} +export function encode(data, _options) { + return base64.encode(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, ""); +} +export function decode(text, _options) { + const normalized = normalize(text); + if (!is(normalized)) { + throw new TypeError("Input is not valid Base64Url text"); + } + return base64.decode(base64.pad(normalized.replace(/-/g, "+").replace(/_/g, "/"))); +} +export const base64url = { encode, decode, is, normalize }; diff --git a/node_modules/@peculiar/utils/build/esm/encoding/binary.js b/node_modules/@peculiar/utils/build/esm/encoding/binary.js new file mode 100644 index 0000000000000000000000000000000000000000..05fe7866cacf545c1c79d27f67fb3ec1508f2d2a --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/encoding/binary.js @@ -0,0 +1,20 @@ +import { toUint8Array } from "../bytes/index.js"; +export function encode(data) { + const bytes = toUint8Array(data); + let result = ""; + for (const byte of bytes) { + result += String.fromCharCode(byte); + } + return result; +} +export function decode(text) { + const result = new Uint8Array(text.length); + for (let i = 0; i < text.length; i++) { + result[i] = text.charCodeAt(i) & 0xff; + } + return result; +} +export function is(text) { + return typeof text === "string"; +} +export const binary = { encode, decode, is }; diff --git a/node_modules/@peculiar/utils/build/esm/encoding/hex.js b/node_modules/@peculiar/utils/build/esm/encoding/hex.js new file mode 100644 index 0000000000000000000000000000000000000000..61bebf61ce22b8482e8552e3e7b9a42029f38ee4 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/encoding/hex.js @@ -0,0 +1,220 @@ +import { toUint8Array } from "../bytes/index.js"; +const HEX_CHARACTER_REGEX = /^[0-9a-f]$/i; +const COMMON_SEPARATORS = [" ", "\t", "\n", "\r", ":", "-", "."]; +function resolveSeparators(options) { + if (options.separators === "none") { + return []; + } + if (!options.separators || options.separators === "common") { + return COMMON_SEPARATORS; + } + return options.separators; +} +function validateSeparator(separator) { + if (!separator) { + throw new TypeError("Hex separators must be non-empty strings"); + } +} +function matchSeparator(text, index, separators) { + for (const separator of separators) { + if (text.startsWith(separator, index)) { + return separator; + } + } + return undefined; +} +function detectCase(text) { + const hasUpper = /[A-F]/.test(text); + const hasLower = /[a-f]/.test(text); + return hasUpper && !hasLower ? "upper" : "lower"; +} +function detectLineSeparator(text) { + const match = /\r\n|\n/.exec(text); + if (!match) { + return undefined; + } + return match[0] === "\r\n" ? "\r\n" : "\n"; +} +function compactForDetection(text) { + return text.replace(/[^0-9a-f]/gi, ""); +} +function detectGroup(text) { + const segments = text.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g) ?? []; + if (segments.length < 3) { + return undefined; + } + const hexSegments = segments.filter((_, index) => index % 2 === 0); + const separators = segments.filter((_, index) => index % 2 === 1); + const separator = separators[0]; + if (!separator || separators.some((item) => item !== separator)) { + return undefined; + } + if (hexSegments.some((segment) => segment.length === 0 || segment.length % 2 !== 0)) { + return undefined; + } + const firstLength = hexSegments[0]?.length ?? 0; + if (!firstLength) { + return undefined; + } + if (hexSegments.slice(0, -1).some((segment) => segment.length !== firstLength)) { + return undefined; + } + if ((hexSegments[hexSegments.length - 1]?.length ?? 0) > firstLength) { + return undefined; + } + return { + size: firstLength / 2, + separator, + }; +} +function detectFormat(text) { + const trimmed = text.trim(); + const prefix = /^0x/i.test(trimmed) ? "0x" : ""; + const body = prefix ? trimmed.slice(2) : trimmed; + const lineSeparator = detectLineSeparator(body); + const lines = body.split(/\r\n|\n/).filter((line) => line.length > 0); + const sampleLine = lines[0]?.trim() ?? ""; + const group = detectGroup(sampleLine); + const format = { + case: detectCase(trimmed), + prefix, + }; + if (group) { + format.group = group; + } + if (lineSeparator && lines.length > 1) { + const firstLineBytes = compactForDetection(lines[0] ?? "").length / 2; + if (firstLineBytes > 0 && lines.slice(0, -1).every((line) => compactForDetection(line).length / 2 === firstLineBytes)) { + format.line = { + bytesPerLine: firstLineBytes, + separator: lineSeparator, + }; + } + } + return format; +} +function normalizeText(text, options) { + const allowPrefix = options.allowPrefix ?? true; + const separators = [...resolveSeparators(options)].sort((left, right) => right.length - left.length); + for (const separator of separators) { + validateSeparator(separator); + } + let working = text.trim(); + if (/^0x/i.test(working)) { + if (!allowPrefix) { + throw new TypeError("Hexadecimal text must not include a 0x prefix"); + } + working = working.slice(2); + } + let normalized = ""; + let lastTokenWasSeparator = false; + for (let index = 0; index < working.length;) { + const character = working[index] ?? ""; + if (HEX_CHARACTER_REGEX.test(character)) { + normalized += character; + lastTokenWasSeparator = false; + index += 1; + continue; + } + const separator = matchSeparator(working, index, separators); + if (!separator) { + throw new TypeError("Input is not valid hexadecimal text"); + } + if (options.strict && (lastTokenWasSeparator || normalized.length === 0)) { + throw new TypeError("Hexadecimal text contains misplaced separators"); + } + lastTokenWasSeparator = true; + index += separator.length; + } + if (options.strict && lastTokenWasSeparator && normalized.length > 0) { + throw new TypeError("Hexadecimal text must not end with a separator"); + } + if (normalized.length % 2 !== 0) { + if (!options.allowOddLength) { + throw new TypeError("Hexadecimal text must contain an even number of characters"); + } + normalized = `0${normalized}`; + } + return normalized.toLowerCase(); +} +function groupPairs(pairs, group) { + if (!group) { + return pairs.join(""); + } + if (!Number.isInteger(group.size) || group.size < 1) { + throw new RangeError("Hex group size must be a positive integer"); + } + const chunks = []; + for (let index = 0; index < pairs.length; index += group.size) { + chunks.push(pairs.slice(index, index + group.size).join("")); + } + return chunks.join(group.separator); +} +export function normalize(text, options = {}) { + return normalizeText(text, options); +} +export function is(text, options = {}) { + if (typeof text !== "string") { + return false; + } + try { + normalize(text, options); + return true; + } + catch { + return false; + } +} +export function encode(data, options = {}) { + const bytes = toUint8Array(data); + const casing = options.case ?? "lower"; + const pairs = Array.from(bytes, (byte) => { + const text = byte.toString(16).padStart(2, "0"); + return casing === "upper" ? text.toUpperCase() : text; + }); + let body = ""; + if (options.line) { + const bytesPerLine = options.line.bytesPerLine; + if (!Number.isInteger(bytesPerLine) || bytesPerLine < 1) { + throw new RangeError("Hex bytesPerLine must be a positive integer"); + } + const separator = options.line.separator ?? "\n"; + const lines = []; + for (let index = 0; index < pairs.length; index += bytesPerLine) { + lines.push(groupPairs(pairs.slice(index, index + bytesPerLine), options.group)); + } + body = lines.join(separator); + } + else { + body = groupPairs(pairs, options.group); + } + return `${options.prefix ?? ""}${body}`; +} +export function decode(text, options = {}) { + const normalized = normalize(text, options); + const result = new Uint8Array(normalized.length / 2); + for (let i = 0; i < normalized.length; i += 2) { + result[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16); + } + return result; +} +export function parse(text, options = {}) { + const normalized = normalize(text, options); + return { + bytes: decode(normalized), + format: detectFormat(text), + normalized, + }; +} +export function format(data, value) { + return encode(data, value); +} +export const formats = { + compact: Object.freeze({}), + upper: Object.freeze({ case: "upper" }), + colon: Object.freeze({ group: { size: 1, separator: ":" } }), + colonUpper: Object.freeze({ case: "upper", group: { size: 1, separator: ":" } }), + groupsOf4: Object.freeze({ group: { size: 4, separator: " " } }), + prefixed: Object.freeze({ prefix: "0x" }), +}; +export const hex = { encode, decode, format, formats, is, normalize, parse }; diff --git a/node_modules/@peculiar/utils/build/esm/encoding/index.js b/node_modules/@peculiar/utils/build/esm/encoding/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c89396f6df7e085f1084dd5cc6b4a44ebbc87277 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/encoding/index.js @@ -0,0 +1,6 @@ +export * as binary from "./binary.js"; +export * as hex from "./hex.js"; +export * as utf8 from "./utf8.js"; +export * as utf16 from "./utf16.js"; +export * as base64 from "./base64.js"; +export * as base64url from "./base64url.js"; diff --git a/node_modules/@peculiar/utils/build/esm/encoding/utf16.js b/node_modules/@peculiar/utils/build/esm/encoding/utf16.js new file mode 100644 index 0000000000000000000000000000000000000000..4a80e24de9933dacad7b5f56910d69f654e40b8b --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/encoding/utf16.js @@ -0,0 +1,19 @@ +import { toArrayBuffer } from "../bytes/index.js"; +export function encode(text, options = {}) { + const result = new ArrayBuffer(text.length * 2); + const view = new DataView(result); + for (let i = 0; i < text.length; i++) { + view.setUint16(i * 2, text.charCodeAt(i), options.littleEndian ?? false); + } + return new Uint8Array(result); +} +export function decode(data, options = {}) { + const buffer = toArrayBuffer(data); + const view = new DataView(buffer); + let result = ""; + for (let i = 0; i < buffer.byteLength; i += 2) { + result += String.fromCharCode(view.getUint16(i, options.littleEndian ?? false)); + } + return result; +} +export const utf16 = { encode, decode }; diff --git a/node_modules/@peculiar/utils/build/esm/encoding/utf8.js b/node_modules/@peculiar/utils/build/esm/encoding/utf8.js new file mode 100644 index 0000000000000000000000000000000000000000..03d8ed528bc5d6a989ac73820ed083446d1f2c72 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/encoding/utf8.js @@ -0,0 +1,8 @@ +import { toUint8Array } from "../bytes/index.js"; +export function encode(text) { + return new TextEncoder().encode(text); +} +export function decode(data) { + return new TextDecoder("utf-8", { fatal: false }).decode(toUint8Array(data)); +} +export const utf8 = { encode, decode }; diff --git a/node_modules/@peculiar/utils/build/esm/index.js b/node_modules/@peculiar/utils/build/esm/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9c736ed6e13c11dc3c9cc9ef2720439c6f007c74 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/index.js @@ -0,0 +1,6 @@ +export * from "./bytes/index.js"; +export * as bytes from "./bytes/index.js"; +export * from "./encoding/index.js"; +export * from "./pem/index.js"; +export * from "./converters/index.js"; +export * from "./legacy/index.js"; diff --git a/node_modules/@peculiar/utils/build/esm/legacy/buffer-source-converter.js b/node_modules/@peculiar/utils/build/esm/legacy/buffer-source-converter.js new file mode 100644 index 0000000000000000000000000000000000000000..d2e40ac5163080d87fc70380b4f0c9afb1f71ba2 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/legacy/buffer-source-converter.js @@ -0,0 +1,33 @@ +import { concat, equal, isArrayBuffer, isArrayBufferView, isBufferSource, toArrayBuffer, toUint8Array, toView, } from "../bytes/index.js"; +export class BufferSourceConverter { + static isArrayBuffer(data) { + return isArrayBuffer(data); + } + static toArrayBuffer(data) { + return toArrayBuffer(data); + } + static toUint8Array(data) { + return toUint8Array(data); + } + static toView(data, type) { + return toView(data, type); + } + static isBufferSource(data) { + return isBufferSource(data); + } + static isArrayBufferView(data) { + return isArrayBufferView(data); + } + static isEqual(a, b) { + return equal(a, b); + } + static concat(first, second, ...rest) { + if (Array.isArray(first)) { + return typeof second === "function" + ? concat(first, second) + : concat(first); + } + const buffers = [first, second, ...rest].filter(Boolean); + return concat(buffers); + } +} diff --git a/node_modules/@peculiar/utils/build/esm/legacy/convert.js b/node_modules/@peculiar/utils/build/esm/legacy/convert.js new file mode 100644 index 0000000000000000000000000000000000000000..8f5db1f8eec0d5a051f94d7b6969579900f54b28 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/legacy/convert.js @@ -0,0 +1,68 @@ +import { convert } from "../converters/index.js"; +function normalizeTextEncoding(encoding) { + return encoding === "ascii" ? "binary" : encoding; +} +export class Convert { + static DEFAULT_UTF8_ENCODING = "utf8"; + static isHex(data) { + return convert.isHex(data); + } + static isBase64(data) { + return convert.isBase64(data); + } + static isBase64Url(data) { + return convert.isBase64Url(data); + } + static ToString(buffer, enc = "utf8") { + return convert.toString(buffer, enc); + } + static FromString(str, enc = "utf8") { + if (!str) { + return new ArrayBuffer(0); + } + return convert.fromString(str, enc); + } + static ToBase64(buffer) { + return convert.toBase64(buffer); + } + static FromBase64(base64) { + return convert.fromBase64(base64); + } + static FromBase64Url(base64url) { + return convert.fromBase64Url(base64url); + } + static ToBase64Url(data) { + return convert.toBase64Url(data); + } + static FromUtf8String(text, encoding = Convert.DEFAULT_UTF8_ENCODING) { + return convert.fromString(text, normalizeTextEncoding(encoding)); + } + static ToUtf8String(buffer, encoding = Convert.DEFAULT_UTF8_ENCODING) { + return convert.toString(buffer, normalizeTextEncoding(encoding)); + } + static FromBinary(text) { + return convert.fromBinary(text); + } + static ToBinary(buffer) { + return convert.toBinary(buffer); + } + static ToHex(buffer) { + return convert.toHex(buffer); + } + static FromHex(hexString) { + return convert.fromHex(hexString); + } + static ToUtf16String(buffer, littleEndian = false) { + return convert.toUtf16String(buffer, littleEndian); + } + static FromUtf16String(text, littleEndian = false) { + return convert.fromUtf16String(text, littleEndian); + } + static Base64Padding(base64) { + const padCount = 4 - (base64.length % 4); + return padCount < 4 ? base64 + "=".repeat(padCount) : base64; + } + static formatString(data) { + return convert.formatString(data); + } +} diff --git a/node_modules/@peculiar/utils/build/esm/legacy/functions.js b/node_modules/@peculiar/utils/build/esm/legacy/functions.js new file mode 100644 index 0000000000000000000000000000000000000000..160c366e929bf134ed1e118f6009657cac22c524 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/legacy/functions.js @@ -0,0 +1,18 @@ +import { concat, equal } from "../bytes/index.js"; +export function assign(target, ...sources) { + for (const source of sources) { + if (!source) { + continue; + } + for (const prop in source) { + target[prop] = source[prop]; + } + } + return target; +} +export function combine(...buf) { + return concat(buf); +} +export function isEqual(bytes1, bytes2) { + return equal(bytes1, bytes2); +} diff --git a/node_modules/@peculiar/utils/build/esm/legacy/index.js b/node_modules/@peculiar/utils/build/esm/legacy/index.js new file mode 100644 index 0000000000000000000000000000000000000000..afd7a355773ec18f05458ca84c1399988e35c43c --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/legacy/index.js @@ -0,0 +1,3 @@ +export { BufferSourceConverter } from "./buffer-source-converter.js"; +export { Convert } from "./convert.js"; +export { assign, combine, isEqual } from "./functions.js"; diff --git a/node_modules/@peculiar/utils/build/esm/pem/index.js b/node_modules/@peculiar/utils/build/esm/pem/index.js new file mode 100644 index 0000000000000000000000000000000000000000..dfadeb715ad38d8b2c601d6aee3e0301d8f32cf8 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/pem/index.js @@ -0,0 +1 @@ +export { decode, decodeFirst, encode, encodeMany, find, findAll, format, parse, pem, pemConverter } from "./pem.js"; diff --git a/node_modules/@peculiar/utils/build/esm/pem/pem.js b/node_modules/@peculiar/utils/build/esm/pem/pem.js new file mode 100644 index 0000000000000000000000000000000000000000..5ad65bca9bec9b3e5b1cffebb7e680ac2c082340 --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/pem/pem.js @@ -0,0 +1,129 @@ +import { base64 } from "../encoding/base64.js"; +const LABEL_REGEX = /^[A-Z0-9][A-Z0-9 ._-]*[A-Z0-9]$/i; +const PEM_BLOCK_REGEX = /-----BEGIN ([^-]+)-----([\s\S]*?)-----END \1-----/g; +function assertLabel(label) { + if (!LABEL_REGEX.test(label)) { + throw new TypeError(`Invalid PEM label '${label}'`); + } +} +function wrap(text, lineLength) { + const result = []; + for (let i = 0; i < text.length; i += lineLength) { + result.push(text.slice(i, i + lineLength)); + } + return result; +} +function parseBody(body) { + const normalized = body.trim().replace(/\r\n/g, "\n"); + const lines = normalized.split("\n").map((line) => line.trim()).filter(Boolean); + const headers = {}; + let index = 0; + for (; index < lines.length; index++) { + const line = lines[index]; + const separator = line.indexOf(":"); + if (separator <= 0) { + break; + } + headers[line.slice(0, separator).trim()] = line.slice(separator + 1).trim(); + } + return { + headers: Object.keys(headers).length ? headers : undefined, + base64Lines: lines.slice(index), + base64Text: lines.slice(index).join(""), + }; +} +function detectNewline(text) { + return /\r\n/.test(text) ? "\r\n" : "\n"; +} +function collectBlocks(text, options = {}) { + const blocks = []; + const requestedLabel = options.label; + let match; + PEM_BLOCK_REGEX.lastIndex = 0; + while ((match = PEM_BLOCK_REGEX.exec(text))) { + const label = match[1].trim(); + if (requestedLabel && label !== requestedLabel) { + continue; + } + assertLabel(label); + const parsed = parseBody(match[2]); + blocks.push({ + label, + data: base64.decode(parsed.base64Text), + headers: parsed.headers, + lineLength: parsed.base64Lines[0]?.length ?? 64, + newline: detectNewline(match[0]), + }); + } + if (options.strict && blocks.length === 0) { + throw new TypeError(requestedLabel + ? `No PEM block with label '${requestedLabel}' was found` + : "No PEM blocks were found"); + } + return blocks; +} +export function encode(label, data, options = {}) { + assertLabel(label); + const lineLength = options.lineLength ?? 64; + if (!Number.isInteger(lineLength) || lineLength < 1) { + throw new RangeError("PEM lineLength must be a positive integer"); + } + const newline = options.newline ?? "\n"; + const lines = [`-----BEGIN ${label}-----`]; + if (options.headers) { + for (const [name, value] of Object.entries(options.headers)) { + lines.push(`${name}: ${value}`); + } + lines.push(""); + } + lines.push(...wrap(base64.encode(data), lineLength)); + lines.push(`-----END ${label}-----`); + return `${lines.join(newline)}${newline}`; +} +export function encodeMany(blocks, options = {}) { + return blocks.map((block) => encode(block.label, block.data, { ...options, headers: block.headers ?? options.headers })).join(""); +} +export function decode(text, options = {}) { + return collectBlocks(text, options).map(({ lineLength: _lineLength, newline: _newline, ...block }) => block); +} +export function find(text, label) { + return decode(text, { label })[0]; +} +export function findAll(text, label) { + return decode(text, { label }); +} +export function decodeFirst(text, label) { + const [block] = decode(text, { label, strict: true }); + return block.data; +} +export function parse(text, options = {}) { + const [block] = collectBlocks(text, { ...options, strict: true }); + const format = { + label: block.label, + headers: block.headers, + lineLength: block.lineLength, + newline: block.newline, + }; + return { + bytes: block.data, + format, + normalized: encode(block.label, block.data, format), + }; +} +export function format(data, value) { + return encode(value.label, data, value); +} +export const pem = { decode, decodeFirst, encode, encodeMany, find, findAll, format, parse }; +export const pemConverter = { + name: "pem", + encode: (data, options) => { + if (!options?.label) { + throw new TypeError("PEM label is required"); + } + return encode(options.label, data, options); + }, + decode: (text, options) => decodeFirst(text, options?.label), + format, + is: (text) => typeof text === "string" && /-----BEGIN [^-]+-----/.test(text), + parse, +}; diff --git a/node_modules/@peculiar/utils/build/esm/pem/types.js b/node_modules/@peculiar/utils/build/esm/pem/types.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@peculiar/utils/build/esm/pem/types.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@peculiar/utils/build/types/bytes/buffer-source.d.ts b/node_modules/@peculiar/utils/build/types/bytes/buffer-source.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e03d7eb23f49d5e01d7cba3e36be915a004e49df --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/bytes/buffer-source.d.ts @@ -0,0 +1,25 @@ +import type { ArrayBufferViewLike, BufferSourceLike, ViewConstructor } from "./types.js"; +/** Checks whether a value is an ArrayBuffer. */ +export declare function isArrayBuffer(value: unknown): value is ArrayBuffer; +/** Checks whether a value is a SharedArrayBuffer. */ +export declare function isSharedArrayBuffer(value: unknown): value is SharedArrayBuffer; +/** Checks whether a value is an ArrayBuffer-like object. */ +export declare function isArrayBufferLike(value: unknown): value is ArrayBufferLike; +/** Checks whether a value is an ArrayBufferView. */ +export declare function isArrayBufferView(value: unknown): value is ArrayBufferViewLike; +/** Checks whether a value can be treated as a buffer source. */ +export declare function isBufferSource(value: unknown): value is BufferSourceLike; +/** Throws when a value is not a supported buffer source. */ +export declare function assertBufferSource(value: unknown): asserts value is BufferSourceLike; +/** Returns a Uint8Array view over the input without copying. */ +export declare function toUint8Array(data: BufferSourceLike): Uint8Array; +/** Returns a copied Uint8Array for the input buffer source. */ +export declare function toUint8ArrayCopy(data: BufferSourceLike): Uint8Array; +/** Returns the underlying ArrayBuffer, copying when required. */ +export declare function toArrayBuffer(data: BufferSourceLike): ArrayBuffer; +/** Returns an ArrayBuffer-like value, copying only when needed. */ +export declare function toArrayBufferLike(data: BufferSourceLike): ArrayBufferLike; +/** Casts buffer data into the requested view type. */ +export declare function toView(data: BufferSourceLike, type: ViewConstructor): T; +/** Copies buffer data into the requested view type. */ +export declare function toViewCopy(data: BufferSourceLike, type: ViewConstructor): T; diff --git a/node_modules/@peculiar/utils/build/types/bytes/concat.d.ts b/node_modules/@peculiar/utils/build/types/bytes/concat.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1dfbed9008dd810f9070eed79af1ce7c8a956b34 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/bytes/concat.d.ts @@ -0,0 +1,7 @@ +import type { ArrayBufferViewLike, BufferSourceLike, ViewConstructor } from "./types.js"; +/** Concatenates buffer sources into a new Uint8Array. */ +export declare function concatToUint8Array(buffers: Iterable): Uint8Array; +/** Concatenates buffer sources and returns either an ArrayBufferLike or a typed view. */ +export declare function concat(...buffers: BufferSourceLike[]): ArrayBufferLike; +export declare function concat(buffers: Iterable): ArrayBufferLike; +export declare function concat(buffers: Iterable, type: ViewConstructor): T; diff --git a/node_modules/@peculiar/utils/build/types/bytes/equal.d.ts b/node_modules/@peculiar/utils/build/types/bytes/equal.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8632ef9e766d05ed55273a11c6fbcb9404a63066 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/bytes/equal.d.ts @@ -0,0 +1,7 @@ +import type { BufferSourceLike } from "./types.js"; +/** Options that control how byte comparisons are performed. */ +export interface EqualOptions { + constantTime?: boolean; +} +/** Compares two buffer sources for byte equality. */ +export declare function equal(a: BufferSourceLike, b: BufferSourceLike, options?: EqualOptions): boolean; diff --git a/node_modules/@peculiar/utils/build/types/bytes/index.d.ts b/node_modules/@peculiar/utils/build/types/bytes/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..99d5d132f9b908dcd6e2c5f68dd39cfe7922d7c9 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/bytes/index.d.ts @@ -0,0 +1,8 @@ +/** Barrel export for buffer-related types and helpers. */ +export type { ArrayBufferViewLike, ArrayBufferViewConstructor, BufferSource, BufferSourceLike, DataViewConstructorLike, StrictBufferSource, ViewConstructor, } from "./types.js"; +export { assertBufferSource, isArrayBuffer, isArrayBufferLike, isArrayBufferView, isBufferSource, isSharedArrayBuffer, toArrayBuffer, toArrayBufferLike, toUint8Array, toUint8ArrayCopy, toView, toViewCopy, } from "./buffer-source.js"; +export { concat, concatToUint8Array } from "./concat.js"; +export type { EqualOptions } from "./equal.js"; +export { equal } from "./equal.js"; +export type { BytePattern, ByteSearchOptions } from "./sequence.js"; +export { compare, copy, endsWith, includes, indexOf, lastIndexOf, slice, startsWith, tail, } from "./sequence.js"; diff --git a/node_modules/@peculiar/utils/build/types/bytes/sequence.d.ts b/node_modules/@peculiar/utils/build/types/bytes/sequence.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c4b6131a81156f2902391b31f5caef11438e78b3 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/bytes/sequence.d.ts @@ -0,0 +1,48 @@ +import type { BufferSourceLike } from "./types.js"; +/** String or byte pattern accepted by the byte search helpers. */ +export type BytePattern = BufferSourceLike | string; +/** Options shared by the stateless byte search helpers. */ +export interface ByteSearchOptions { + /** + * Start offset for forward search. + * For reverse search this is the upper bound / starting point. + */ + start?: number; + /** + * End offset, exclusive. + * For reverse search this is the lower bound. + */ + end?: number; + /** + * Encoding used when pattern is a string. + * Defaults to ASCII for marker-style byte searches. + */ + encoding?: "ascii" | "utf8"; +} +/** + * Searches for the first occurrence of a byte pattern within the requested range. + * Returns the absolute byte offset or `-1` when the pattern is not found. + */ +export declare function indexOf(data: BufferSourceLike, pattern: BytePattern, options?: ByteSearchOptions): number; +/** + * Searches backwards for the last occurrence of a byte pattern within the requested range. + * Returns the absolute byte offset or `-1` when the pattern is not found. + */ +export declare function lastIndexOf(data: BufferSourceLike, pattern: BytePattern, options?: ByteSearchOptions): number; +/** Returns `true` when the pattern exists anywhere in the requested range. */ +export declare function includes(data: BufferSourceLike, pattern: BytePattern, options?: ByteSearchOptions): boolean; +/** Returns `true` when the byte sequence starts with the requested pattern. */ +export declare function startsWith(data: BufferSourceLike, pattern: BytePattern, options?: Pick): boolean; +/** Returns `true` when the byte sequence ends with the requested pattern. */ +export declare function endsWith(data: BufferSourceLike, pattern: BytePattern, options?: Pick): boolean; +/** + * Returns a Uint8Array view over the requested byte range. + * Negative indexes follow `Array.prototype.slice` semantics. + */ +export declare function slice(data: BufferSourceLike, start?: number, end?: number): Uint8Array; +/** Returns the last `length` bytes of the input as a Uint8Array view. */ +export declare function tail(data: BufferSourceLike, length: number): Uint8Array; +/** Returns a new Uint8Array copy that never shares memory with the input. */ +export declare function copy(data: BufferSourceLike): Uint8Array; +/** Compares two byte sequences lexicographically. */ +export declare function compare(a: BufferSourceLike, b: BufferSourceLike): -1 | 0 | 1; diff --git a/node_modules/@peculiar/utils/build/types/bytes/types.d.ts b/node_modules/@peculiar/utils/build/types/bytes/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..858b8e0b1e2f1bbee488176d7ca0764965ad9f4d --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/bytes/types.d.ts @@ -0,0 +1,29 @@ +/** Describes a buffer-backed view with offset and length metadata. */ +export interface ArrayBufferViewLike { + readonly buffer: TBuffer; + readonly byteOffset: number; + readonly byteLength: number; +} +/** A buffer source backed by either an ArrayBuffer-like value or a view. */ +export type BufferSourceLike = ArrayBufferLike | ArrayBufferViewLike; +/** Historical BufferSource alias preserved for compatibility. */ +export type BufferSource = BufferSourceLike; +/** A strict buffer source limited to ArrayBuffer and ArrayBuffer-backed views. */ +export type StrictBufferSource = ArrayBuffer | ArrayBufferViewLike; +/** Constructor shape for typed array-like views. */ +export interface ArrayBufferViewConstructor { + readonly prototype: T; + readonly BYTES_PER_ELEMENT?: number; + readonly name: string; + new (length: number): T; + new (array: ArrayLike): T; + new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): T; +} +/** Constructor shape for DataView-like views. */ +export interface DataViewConstructorLike { + readonly prototype: T; + readonly name: string; + new (buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): T; +} +/** A constructor that can create a typed view over buffer data. */ +export type ViewConstructor = ArrayBufferViewConstructor | DataViewConstructorLike; diff --git a/node_modules/@peculiar/utils/build/types/converters/convert.d.ts b/node_modules/@peculiar/utils/build/types/converters/convert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4e91a24eb099c075a2b8fbbba62034729d79350e --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/converters/convert.d.ts @@ -0,0 +1,65 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +import type { DecodeOptionsFor, DetectOptions, EncodeOptionsFor, FormatDetection, FormatFor, OptionsArgument, ParsedBytes, TranscodeOptions, DecodeResult } from "./types.js"; +/** Text encodings supported by the legacy converter facade. */ +export type BufferEncoding = "utf8" | "utf-8" | "binary" | "latin1" | "base64" | "base64url" | "base64-url" | "hex" | "utf16" | "utf16be" | "utf16le" | string; +/** Public converter facade backed by the default registry. */ +export interface ConvertFacade { + /** Encodes bytes with a named converter. */ + encode(name: TName, data: BufferSourceLike, ...args: OptionsArgument>): string; + /** Decodes text with a named converter. */ + decode(name: TName, text: string, ...args: OptionsArgument>): Uint8Array; + /** Safely decodes text with a named converter. */ + tryDecode(name: TName, text: string, ...args: OptionsArgument>): DecodeResult; + /** Normalizes text with a named converter. */ + normalize(name: TName, text: string, ...args: OptionsArgument>): string; + /** Parses text while preserving formatting metadata. */ + parse(name: TName, text: string, ...args: OptionsArgument>): ParsedBytes>; + /** Formats bytes using preserved formatting metadata. */ + format(name: TName, data: BufferSourceLike, format: FormatFor): string; + /** Converts text directly between registered formats. */ + transcode(text: string, options: TranscodeOptions): string; + /** Detects likely formats for an input string. */ + detect(text: string, options?: DetectOptions): FormatDetection[]; + /** @deprecated Use encode() instead. */ + to(format: TName, data: BufferSourceLike, ...args: OptionsArgument>): string; + /** @deprecated Use decode() instead. */ + from(format: TName, text: string, ...args: OptionsArgument>): Uint8Array; + /** Converts buffer data to a string using a known encoding. */ + toString(data: BufferSourceLike, encoding?: BufferEncoding): string; + /** Converts a string to bytes using a known encoding. */ + fromString(text: string, encoding?: BufferEncoding): ArrayBufferLike; + /** Encodes bytes as Base64 text. */ + toBase64(data: BufferSourceLike): string; + /** Decodes Base64 text into bytes. */ + fromBase64(text: string): ArrayBufferLike; + /** Encodes bytes as Base64Url text. */ + toBase64Url(data: BufferSourceLike): string; + /** Decodes Base64Url text into bytes. */ + fromBase64Url(text: string): ArrayBufferLike; + /** Encodes bytes as hexadecimal text. */ + toHex(data: BufferSourceLike): string; + /** Decodes hexadecimal text into bytes. */ + fromHex(text: string): ArrayBufferLike; + /** Encodes bytes as binary text. */ + toBinary(data: BufferSourceLike): string; + /** Decodes binary text into bytes. */ + fromBinary(text: string): ArrayBufferLike; + /** Decodes UTF-8 bytes into text. */ + toUtf8String(data: BufferSourceLike): string; + /** Encodes UTF-8 text into bytes. */ + fromUtf8String(text: string): ArrayBufferLike; + /** Decodes UTF-16 bytes into text. */ + toUtf16String(data: BufferSourceLike, littleEndian?: boolean): string; + /** Encodes UTF-16 text into bytes. */ + fromUtf16String(text: string, littleEndian?: boolean): ArrayBufferLike; + /** Checks whether a value is hexadecimal text. */ + isHex(text: unknown): text is string; + /** Checks whether a value is Base64 text. */ + isBase64(text: unknown): text is string; + /** Checks whether a value is Base64Url text. */ + isBase64Url(text: unknown): text is string; + /** Normalizes whitespace in a Base64-style string. */ + formatString(text: string): string; +} +/** Converter helpers for common text and binary encodings. */ +export declare const convert: ConvertFacade; diff --git a/node_modules/@peculiar/utils/build/types/converters/defaults.d.ts b/node_modules/@peculiar/utils/build/types/converters/defaults.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..632505407b1c65f078f188fc18e16f2b8bbdf0a1 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/converters/defaults.d.ts @@ -0,0 +1,22 @@ +export { pemConverter } from "../pem/index.js"; +import type { Converter } from "./types.js"; +/** Converter for binary text where each character maps to one byte. */ +export declare const binaryConverter: Converter; +/** Converter for hexadecimal text. */ +export declare const hexConverter: Converter; +/** Converter for standard Base64 text. */ +export declare const base64Converter: Converter; +/** Converter for URL-safe Base64 text. */ +export declare const base64urlConverter: Converter; +/** Converter for UTF-8 text. */ +export declare const utf8Converter: Converter; +/** Converter for big-endian UTF-16 text. */ +export declare const utf16beConverter: Converter; +/** Converter for little-endian UTF-16 text. */ +export declare const utf16leConverter: Converter; +/** The built-in converter set shipped with the package. */ +export declare const defaultConverters: readonly [Converter, Converter, Converter, Converter, Converter, Converter, Converter, Converter]; +/** The default registry preloaded with the built-in converters. */ +export declare const defaultConverterRegistry: import("./types.js").ConverterRegistry; diff --git a/node_modules/@peculiar/utils/build/types/converters/index.d.ts b/node_modules/@peculiar/utils/build/types/converters/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9f9fa2c36326eadb40aeb9ea16b2007bd9706d72 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/converters/index.d.ts @@ -0,0 +1,6 @@ +/** Barrel export for converter registry types and default codecs. */ +export type { ByteDecoder, ByteEncoder, Converter, ConverterOptionsMap, ConverterRegistry, DecodeOptionsFor, DecodeResult, DetectOptions, EncodeOptionsFor, FormatDetection, FormatFor, OptionsArgument, ParsedBytes, RegisterOptions, TranscodeOptions, } from "./types.js"; +export { createConverterRegistry } from "./registry.js"; +export { base64Converter, base64urlConverter, binaryConverter, defaultConverterRegistry, defaultConverters, hexConverter, pemConverter, utf16beConverter, utf16leConverter, utf8Converter, } from "./defaults.js"; +export type { BufferEncoding, ConvertFacade } from "./convert.js"; +export { convert } from "./convert.js"; diff --git a/node_modules/@peculiar/utils/build/types/converters/registry.d.ts b/node_modules/@peculiar/utils/build/types/converters/registry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..969f9c0f5074d2373a1e0149ba5ffc2ab5961b60 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/converters/registry.d.ts @@ -0,0 +1,3 @@ +import type { Converter, ConverterRegistry } from "./types.js"; +/** Creates a converter registry and optionally seeds it with converters. */ +export declare function createConverterRegistry(initialConverters?: Iterable): ConverterRegistry; diff --git a/node_modules/@peculiar/utils/build/types/converters/types.d.ts b/node_modules/@peculiar/utils/build/types/converters/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1a0447514a48c583f9fa1a349fd1dc9be9797a15 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/converters/types.d.ts @@ -0,0 +1,141 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +import type { Base64DecodeOptions, Base64EncodeOptions } from "../encoding/base64.js"; +import type { Base64UrlDecodeOptions, Base64UrlEncodeOptions } from "../encoding/base64url.js"; +import type { HexDecodeOptions, HexEncodeOptions, HexFormat } from "../encoding/hex.js"; +import type { PemDecodeOptions, PemEncodeOptions, PemFormat } from "../pem/types.js"; +/** Converts buffer data into text using encoder-specific options. */ +export type ByteEncoder = (data: BufferSourceLike, options?: TOptions) => string; +/** Converts text back into bytes using decoder-specific options. */ +export type ByteDecoder = (text: string, options?: TOptions) => Uint8Array; +/** Parsed text that preserves both decoded bytes and the detected format metadata. */ +export interface ParsedBytes { + /** Decoded bytes. */ + readonly bytes: Uint8Array; + /** Detected formatting metadata. */ + readonly format: TFormat; + /** Canonical normalized text representation. */ + readonly normalized: string; +} +/** Result of a safe decode operation that does not throw. */ +export type DecodeResult = { + ok: true; + bytes: Uint8Array; +} | { + ok: false; + error: Error; +}; +/** Ranked format detection candidate. */ +export interface FormatDetection { + /** Registered converter name. */ + readonly format: string; + /** Confidence score in the range from 0 to 1. */ + readonly confidence: number; +} +/** Open interface that standard and user converters can augment with typed options. */ +export interface ConverterOptionsMap { + base64: { + decode: Base64DecodeOptions; + encode: Base64EncodeOptions; + }; + base64url: { + decode: Base64UrlDecodeOptions; + encode: Base64UrlEncodeOptions; + }; + hex: { + decode: HexDecodeOptions; + encode: HexEncodeOptions; + format: HexFormat; + }; + pem: { + decode: PemDecodeOptions; + encode: PemEncodeOptions & { + label: string; + }; + format: PemFormat; + }; +} +type KnownConverterName = Extract; +type EmptyObject = Record; +type RequiredKeys = { + [TKey in keyof T]-?: EmptyObject extends Pick ? never : TKey; +}[keyof T]; +type NonUndefined = Exclude; +type CapabilityOptions = TName extends KnownConverterName ? ConverterOptionsMap[TName] extends Record ? TOptions : unknown : unknown; +/** Resolves typed encode options for a known converter name. */ +export type EncodeOptionsFor = CapabilityOptions; +/** Resolves typed decode options for a known converter name. */ +export type DecodeOptionsFor = CapabilityOptions; +/** Resolves typed format metadata for a known converter name. */ +export type FormatFor = CapabilityOptions; +/** Builds an optional or required options tuple depending on the options type. */ +export type OptionsArgument = [TOptions] extends [never] ? [] : unknown extends TOptions ? [options?: TOptions] : [NonUndefined] extends [object] ? RequiredKeys> extends never ? [options?: TOptions] : [options: TOptions] : [options: TOptions]; +/** Options for direct format-to-format transcoding. */ +export interface TranscodeOptions { + /** Source format name. */ + readonly from: TFrom; + /** Source decoder options. */ + readonly fromOptions?: DecodeOptionsFor; + /** Destination format name. */ + readonly to: TTo; + /** Destination encoder options. */ + readonly toOptions?: EncodeOptionsFor; +} +/** Options for ranked format detection. */ +export interface DetectOptions { + /** Formats to check. Defaults to the registered non-generic codecs. */ + readonly formats?: readonly TName[]; +} +/** Describes a named text converter with optional aliases and validation. */ +export interface Converter { + /** The primary converter name. */ + readonly name: string; + /** Additional names that resolve to the same converter. */ + readonly aliases?: readonly string[]; + /** Encodes buffer data into text. */ + readonly encode: ByteEncoder; + /** Decodes text into bytes. */ + readonly decode: ByteDecoder; + /** Normalizes input text into the canonical representation accepted by the converter. */ + readonly normalize?: (text: string, options?: TDecodeOptions) => string; + /** Parses text into bytes while preserving formatting metadata. */ + readonly parse?: (text: string, options?: TDecodeOptions) => ParsedBytes; + /** Formats bytes using previously detected formatting metadata. */ + readonly format?: (data: BufferSourceLike, format: TFormat) => string; + /** Checks whether a text value is accepted by the converter. */ + readonly is?: (text: unknown) => text is string; +} +/** Options that control how a converter is registered. */ +export interface RegisterOptions { + /** Replaces an existing converter with the same name or alias. */ + override?: boolean; +} +/** Registry API for looking up, registering, and using converters. */ +export interface ConverterRegistry { + /** Registers a converter. */ + register(converter: Converter, options?: RegisterOptions): this; + /** Removes a converter by name or alias. */ + unregister(name: string): boolean; + /** Checks whether a converter is registered. */ + has(name: string): boolean; + /** Returns a registered converter. */ + get(name: string): Converter; + /** Returns the list of primary registered converters. */ + list(): readonly Converter[]; + /** Encodes buffer data with a named converter. */ + encode(name: TName, data: BufferSourceLike, ...args: OptionsArgument>): string; + /** Decodes text with a named converter. */ + decode(name: TName, text: string, ...args: OptionsArgument>): Uint8Array; + /** Safely decodes text with a named converter without throwing. */ + tryDecode(name: TName, text: string, ...args: OptionsArgument>): DecodeResult; + /** Normalizes text with a named converter. */ + normalize(name: TName, text: string, ...args: OptionsArgument>): string; + /** Parses text with a named converter. */ + parse(name: TName, text: string, ...args: OptionsArgument>): ParsedBytes>; + /** Formats bytes with a named converter using preserved formatting metadata. */ + format(name: TName, data: BufferSourceLike, format: FormatFor): string; + /** Converts text directly from one registered format to another. */ + transcode(text: string, options: TranscodeOptions): string; + /** Detects likely formats for the provided text. */ + detect(text: string, options?: DetectOptions): FormatDetection[]; +} +export {}; diff --git a/node_modules/@peculiar/utils/build/types/encoding/base64.d.ts b/node_modules/@peculiar/utils/build/types/encoding/base64.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9390bf588a97c3222a25d9b8dcebd66ef8acea15 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/encoding/base64.d.ts @@ -0,0 +1,27 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +/** Options that control Base64 encoding. */ +export interface Base64EncodeOptions { + readonly __base64EncodeOptionsBrand?: never; +} +/** Options that control Base64 decoding. */ +export interface Base64DecodeOptions { + readonly __base64DecodeOptionsBrand?: never; +} +/** Removes whitespace from Base64 text. */ +export declare function normalize(text: string): string; +/** Pads Base64 text to a multiple of four characters. */ +export declare function pad(text: string): string; +/** Checks whether a value is valid Base64 text. */ +export declare function is(text: unknown): text is string; +/** Encodes buffer data as Base64 text. */ +export declare function encode(data: BufferSourceLike, _options?: Base64EncodeOptions): string; +/** Decodes Base64 text into bytes. */ +export declare function decode(text: string, _options?: Base64DecodeOptions): Uint8Array; +/** Base64 codec helpers. */ +export declare const base64: { + readonly encode: typeof encode; + readonly decode: typeof decode; + readonly is: typeof is; + readonly normalize: typeof normalize; + readonly pad: typeof pad; +}; diff --git a/node_modules/@peculiar/utils/build/types/encoding/base64url.d.ts b/node_modules/@peculiar/utils/build/types/encoding/base64url.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9704c8f31e1d1f5ef739f7f5eb479dc7c8dec20e --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/encoding/base64url.d.ts @@ -0,0 +1,24 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +/** Options that control Base64Url encoding. */ +export interface Base64UrlEncodeOptions { + readonly __base64UrlEncodeOptionsBrand?: never; +} +/** Options that control Base64Url decoding. */ +export interface Base64UrlDecodeOptions { + readonly __base64UrlDecodeOptionsBrand?: never; +} +/** Removes whitespace from Base64Url text. */ +export declare function normalize(text: string): string; +/** Checks whether a value is valid Base64Url text. */ +export declare function is(text: unknown): text is string; +/** Encodes buffer data as Base64Url text. */ +export declare function encode(data: BufferSourceLike, _options?: Base64UrlEncodeOptions): string; +/** Decodes Base64Url text into bytes. */ +export declare function decode(text: string, _options?: Base64UrlDecodeOptions): Uint8Array; +/** Base64Url codec helpers. */ +export declare const base64url: { + readonly encode: typeof encode; + readonly decode: typeof decode; + readonly is: typeof is; + readonly normalize: typeof normalize; +}; diff --git a/node_modules/@peculiar/utils/build/types/encoding/binary.d.ts b/node_modules/@peculiar/utils/build/types/encoding/binary.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..660f17fdc05f43f48d0e15829403fd8ac4544063 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/encoding/binary.d.ts @@ -0,0 +1,13 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +/** Encodes bytes as a one-byte-per-character string. */ +export declare function encode(data: BufferSourceLike): string; +/** Decodes a one-byte-per-character string into bytes. */ +export declare function decode(text: string): Uint8Array; +/** Checks whether a value is a string suitable for binary text handling. */ +export declare function is(text: unknown): text is string; +/** Binary codec helpers. */ +export declare const binary: { + readonly encode: typeof encode; + readonly decode: typeof decode; + readonly is: typeof is; +}; diff --git a/node_modules/@peculiar/utils/build/types/encoding/hex.d.ts b/node_modules/@peculiar/utils/build/types/encoding/hex.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbbc1bd814cb0f877df7318d6f55ec952e14d53f --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/encoding/hex.d.ts @@ -0,0 +1,76 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +import type { ParsedBytes } from "../converters/types.js"; +/** Hex casing modes used by format-aware helpers. */ +export type HexCase = "lower" | "upper"; +/** Options that control hexadecimal decoding. */ +export interface HexDecodeOptions { + allowPrefix?: boolean; + allowOddLength?: boolean; + separators?: readonly string[] | "common" | "none"; + strict?: boolean; +} +/** Grouping information for formatted hexadecimal output. */ +export interface HexGroupFormat { + size: number; + separator: string; +} +/** Line wrapping information for formatted hexadecimal output. */ +export interface HexLineFormat { + bytesPerLine: number; + separator?: "\n" | "\r\n"; +} +/** Options that control hexadecimal encoding. */ +export interface HexEncodeOptions { + case?: HexCase; + prefix?: "" | "0x"; + group?: HexGroupFormat; + line?: HexLineFormat; +} +/** Preserved formatting metadata for parsed hexadecimal text. */ +export interface HexFormat { + case: HexCase; + prefix: "" | "0x"; + group?: HexGroupFormat; + line?: { + bytesPerLine: number; + separator: "\n" | "\r\n"; + }; +} +/** Removes separators and normalizes hexadecimal text. */ +export declare function normalize(text: string, options?: HexDecodeOptions): string; +/** Checks whether a value is normalized hexadecimal text. */ +export declare function is(text: unknown, options?: HexDecodeOptions): text is string; +/** Encodes buffer data as formatted hexadecimal text. */ +export declare function encode(data: BufferSourceLike, options?: HexEncodeOptions): string; +/** Decodes hexadecimal text into bytes. */ +export declare function decode(text: string, options?: HexDecodeOptions): Uint8Array; +/** Parses hexadecimal text into bytes plus detected formatting metadata. */ +export declare function parse(text: string, options?: HexDecodeOptions): ParsedBytes; +/** Formats bytes using preserved hexadecimal formatting metadata. */ +export declare function format(data: BufferSourceLike, value: HexFormat): string; +/** Reusable hexadecimal formatting presets. */ +export declare const formats: { + readonly compact: Readonly; + readonly upper: Readonly; + readonly colon: Readonly; + readonly colonUpper: Readonly; + readonly groupsOf4: Readonly; + readonly prefixed: Readonly; +}; +/** Hexadecimal codec helpers. */ +export declare const hex: { + readonly encode: typeof encode; + readonly decode: typeof decode; + readonly format: typeof format; + readonly formats: { + readonly compact: Readonly; + readonly upper: Readonly; + readonly colon: Readonly; + readonly colonUpper: Readonly; + readonly groupsOf4: Readonly; + readonly prefixed: Readonly; + }; + readonly is: typeof is; + readonly normalize: typeof normalize; + readonly parse: typeof parse; +}; diff --git a/node_modules/@peculiar/utils/build/types/encoding/index.d.ts b/node_modules/@peculiar/utils/build/types/encoding/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..051a9514205e55e6acf6a9ab9269cb9c1aef985e --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/encoding/index.d.ts @@ -0,0 +1,7 @@ +/** Barrel export for binary and text encoding helpers. */ +export * as binary from "./binary.js"; +export * as hex from "./hex.js"; +export * as utf8 from "./utf8.js"; +export * as utf16 from "./utf16.js"; +export * as base64 from "./base64.js"; +export * as base64url from "./base64url.js"; diff --git a/node_modules/@peculiar/utils/build/types/encoding/utf16.d.ts b/node_modules/@peculiar/utils/build/types/encoding/utf16.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..84267ec85be3dfe63dac3ee02df27a82e5a94cf7 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/encoding/utf16.d.ts @@ -0,0 +1,14 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +/** Options that control UTF-16 endianness. */ +export interface Utf16Options { + littleEndian?: boolean; +} +/** Encodes UTF-16 text into bytes. */ +export declare function encode(text: string, options?: Utf16Options): Uint8Array; +/** Decodes UTF-16 bytes into text. */ +export declare function decode(data: BufferSourceLike, options?: Utf16Options): string; +/** UTF-16 codec helpers. */ +export declare const utf16: { + readonly encode: typeof encode; + readonly decode: typeof decode; +}; diff --git a/node_modules/@peculiar/utils/build/types/encoding/utf8.d.ts b/node_modules/@peculiar/utils/build/types/encoding/utf8.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39602682deed3c87bc6c09fc6fbcfc6551a609b6 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/encoding/utf8.d.ts @@ -0,0 +1,10 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +/** Encodes UTF-8 text into bytes. */ +export declare function encode(text: string): Uint8Array; +/** Decodes UTF-8 bytes into text. */ +export declare function decode(data: BufferSourceLike): string; +/** UTF-8 codec helpers. */ +export declare const utf8: { + readonly encode: typeof encode; + readonly decode: typeof decode; +}; diff --git a/node_modules/@peculiar/utils/build/types/index.d.ts b/node_modules/@peculiar/utils/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..16a9ec10d8410b21821410b261268a2ab67fa382 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/index.d.ts @@ -0,0 +1,7 @@ +/** Public entry point for bytes, encodings, PEM helpers, converters, and legacy compatibility APIs. */ +export * from "./bytes/index.js"; +export * as bytes from "./bytes/index.js"; +export * from "./encoding/index.js"; +export * from "./pem/index.js"; +export * from "./converters/index.js"; +export * from "./legacy/index.js"; diff --git a/node_modules/@peculiar/utils/build/types/legacy/buffer-source-converter.d.ts b/node_modules/@peculiar/utils/build/types/legacy/buffer-source-converter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bc1c494bad44d7bdf0e58c3070c3cecf024b84c0 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/legacy/buffer-source-converter.d.ts @@ -0,0 +1,24 @@ +import type { ArrayBufferViewConstructor, ArrayBufferViewLike, BufferSourceLike, ViewConstructor } from "../bytes/index.js"; +/** Legacy static helpers for buffer source conversion. + * @deprecated Use functions from `@peculiar/utils/bytes` instead. + */ +export declare class BufferSourceConverter { + /** Checks whether a value is an ArrayBuffer. */ + static isArrayBuffer(data: unknown): data is ArrayBuffer; + /** Converts buffer data to an ArrayBuffer. */ + static toArrayBuffer(data: BufferSourceLike): ArrayBuffer; + /** Converts buffer data to a Uint8Array view. */ + static toUint8Array(data: BufferSourceLike): Uint8Array; + /** Converts buffer data into the requested view type. */ + static toView(data: BufferSourceLike, type: ViewConstructor): T; + /** Checks whether a value can be treated as a buffer source. */ + static isBufferSource(data: unknown): data is BufferSourceLike; + /** Checks whether a value is an ArrayBufferView. */ + static isArrayBufferView(data: unknown): data is ArrayBufferViewLike; + /** Compares two buffer sources for byte equality. */ + static isEqual(a: BufferSourceLike, b: BufferSourceLike): boolean; + /** Concatenates buffer sources into an ArrayBuffer or a typed view. */ + static concat(...buffers: BufferSourceLike[]): ArrayBufferLike; + static concat(buffers: BufferSourceLike[]): ArrayBufferLike; + static concat(buffers: BufferSourceLike[], type: ArrayBufferViewConstructor): T; +} diff --git a/node_modules/@peculiar/utils/build/types/legacy/convert.d.ts b/node_modules/@peculiar/utils/build/types/legacy/convert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..73a051d10a06cdcd9d12cd7dd5c9e1ef2898ee96 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/legacy/convert.d.ts @@ -0,0 +1,52 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +import { type BufferEncoding } from "../converters/index.js"; +import type { Utf16Options } from "../encoding/utf16.js"; +/** Legacy text encodings accepted by the deprecated facade. */ +export type TextEncoding = "ascii" | "utf8" | "utf16" | "utf16be" | "utf16le" | "usc2"; +/** + * Legacy converter facade that mirrors the historical API surface. + * @deprecated Use the camelCase `convert` object or specific encoding modules instead. + */ +export declare class Convert { + /** Default UTF-8 encoding used by the legacy facade. */ + static DEFAULT_UTF8_ENCODING: TextEncoding; + /** Checks whether the input is hexadecimal text. */ + static isHex(data: unknown): data is string; + /** Checks whether the input is Base64 text. */ + static isBase64(data: unknown): data is string; + /** Checks whether the input is Base64Url text. */ + static isBase64Url(data: unknown): data is string; + /** Converts buffer data to text. */ + static ToString(buffer: BufferSourceLike, enc?: BufferEncoding): string; + /** Converts text to bytes. */ + static FromString(str: string, enc?: BufferEncoding): ArrayBufferLike; + /** Encodes bytes as Base64 text. */ + static ToBase64(buffer: BufferSourceLike): string; + /** Decodes Base64 text into bytes. */ + static FromBase64(base64: string): ArrayBufferLike; + /** Decodes Base64Url text into bytes. */ + static FromBase64Url(base64url: string): ArrayBufferLike; + /** Encodes bytes as Base64Url text. */ + static ToBase64Url(data: BufferSourceLike): string; + /** Converts UTF-8 or UTF-16 text to bytes. */ + static FromUtf8String(text: string, encoding?: TextEncoding): ArrayBufferLike; + /** Converts bytes to UTF-8 or UTF-16 text. */ + static ToUtf8String(buffer: BufferSourceLike, encoding?: TextEncoding): string; + /** Decodes binary text into bytes. */ + static FromBinary(text: string): ArrayBufferLike; + /** Encodes bytes as binary text. */ + static ToBinary(buffer: BufferSourceLike): string; + /** Encodes bytes as hexadecimal text. */ + static ToHex(buffer: BufferSourceLike): string; + /** Decodes hexadecimal text into bytes. */ + static FromHex(hexString: string): ArrayBufferLike; + /** Converts UTF-16 bytes into text. */ + static ToUtf16String(buffer: BufferSourceLike, littleEndian?: boolean): string; + /** Converts UTF-16 text into bytes. */ + static FromUtf16String(text: string, littleEndian?: boolean): ArrayBufferLike; + protected static Base64Padding(base64: string): string; + /** Normalizes whitespace in Base64-style text. */ + static formatString(data: string): string; +} +/** Legacy text encoding aliases re-exported for compatibility. */ +export type { BufferEncoding, Utf16Options }; diff --git a/node_modules/@peculiar/utils/build/types/legacy/functions.d.ts b/node_modules/@peculiar/utils/build/types/legacy/functions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..133b382b2ce96b97364d1333aae3e5f00c002a96 --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/legacy/functions.d.ts @@ -0,0 +1,16 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +/** + * Assigns own properties from source objects into the target object. + * @deprecated Prefer object spread or Object.assign. + */ +export declare function assign(target: T, ...sources: (Partial | undefined | null)[]): T; +/** + * Concatenates buffer sources into a single ArrayBuffer. + * @deprecated Use `concat` from `@peculiar/utils/bytes` instead. + */ +export declare function combine(...buf: BufferSourceLike[]): ArrayBufferLike; +/** + * Compares two buffer sources for equality. + * @deprecated Use `equal` from `@peculiar/utils/bytes` instead. + */ +export declare function isEqual(bytes1: BufferSourceLike, bytes2: BufferSourceLike): boolean; diff --git a/node_modules/@peculiar/utils/build/types/legacy/index.d.ts b/node_modules/@peculiar/utils/build/types/legacy/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..84f01b43e887a5b85dda85c1cf6edc245be0ab1c --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/legacy/index.d.ts @@ -0,0 +1,5 @@ +/** Barrel export for the deprecated compatibility layer. */ +export { BufferSourceConverter } from "./buffer-source-converter.js"; +export { Convert } from "./convert.js"; +export type { BufferEncoding, TextEncoding } from "./convert.js"; +export { assign, combine, isEqual } from "./functions.js"; diff --git a/node_modules/@peculiar/utils/build/types/pem/index.d.ts b/node_modules/@peculiar/utils/build/types/pem/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..370d5200de971233b81e970b1d37096312850efe --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/pem/index.d.ts @@ -0,0 +1,3 @@ +/** Barrel export for PEM helpers, codecs, and related types. */ +export type { PemBlock, PemCodec, PemDecodeOptions, PemEncodeBlock, PemEncodeOptions, PemFormat } from "./types.js"; +export { decode, decodeFirst, encode, encodeMany, find, findAll, format, parse, pem, pemConverter } from "./pem.js"; diff --git a/node_modules/@peculiar/utils/build/types/pem/pem.d.ts b/node_modules/@peculiar/utils/build/types/pem/pem.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..68cc8be29b069eb4067c7d195eac08069e4f77df --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/pem/pem.d.ts @@ -0,0 +1,34 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +import type { ParsedBytes, Converter } from "../converters/types.js"; +import type { PemBlock, PemDecodeOptions, PemEncodeBlock, PemEncodeOptions, PemFormat } from "./types.js"; +/** Encodes buffer data into a PEM block. */ +export declare function encode(label: string, data: BufferSourceLike, options?: PemEncodeOptions): string; +/** Encodes multiple PEM blocks into one PEM bundle. */ +export declare function encodeMany(blocks: readonly PemEncodeBlock[], options?: PemEncodeOptions): string; +/** Decodes PEM text into the contained blocks. */ +export declare function decode(text: string, options?: PemDecodeOptions): PemBlock[]; +/** Finds the first PEM block with the requested label. */ +export declare function find(text: string, label: string): PemBlock | undefined; +/** Finds all PEM blocks with the requested label. */ +export declare function findAll(text: string, label: string): PemBlock[]; +/** Decodes the first matching PEM block. */ +export declare function decodeFirst(text: string, label?: string): Uint8Array; +/** Parses the first matching PEM block and preserves its formatting metadata. */ +export declare function parse(text: string, options?: PemDecodeOptions): ParsedBytes; +/** Formats bytes with preserved PEM metadata. */ +export declare function format(data: BufferSourceLike, value: PemFormat): string; +/** PEM codec helpers. */ +export declare const pem: { + readonly decode: typeof decode; + readonly decodeFirst: typeof decodeFirst; + readonly encode: typeof encode; + readonly encodeMany: typeof encodeMany; + readonly find: typeof find; + readonly findAll: typeof findAll; + readonly format: typeof format; + readonly parse: typeof parse; +}; +/** Converter wrapper for PEM text. */ +export declare const pemConverter: Converter; diff --git a/node_modules/@peculiar/utils/build/types/pem/types.d.ts b/node_modules/@peculiar/utils/build/types/pem/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..43ca01d8eccffaffd1e9d03116b2b579a32c926a --- /dev/null +++ b/node_modules/@peculiar/utils/build/types/pem/types.d.ts @@ -0,0 +1,48 @@ +import type { BufferSourceLike } from "../bytes/index.js"; +import type { ParsedBytes } from "../converters/types.js"; +/** Represents a decoded PEM block with label, data, and optional headers. */ +export interface PemBlock { + readonly label: string; + readonly data: Uint8Array; + readonly headers?: Readonly>; +} +/** Options that control PEM encoding. */ +export interface PemEncodeOptions { + lineLength?: number; + newline?: "\n" | "\r\n"; + headers?: Readonly>; +} +/** Options that control PEM decoding. */ +export interface PemDecodeOptions { + label?: string; + strict?: boolean; +} +/** Format metadata that can be reused to re-encode PEM text. */ +export interface PemFormat extends PemEncodeOptions { + readonly label: string; +} +/** Input block used by multi-block PEM encoding helpers. */ +export interface PemEncodeBlock { + readonly label: string; + readonly data: BufferSourceLike; + readonly headers?: Readonly>; +} +/** Encodes and decodes PEM blocks. */ +export interface PemCodec { + /** Encodes a buffer source into a PEM block. */ + encode(label: string, data: BufferSourceLike, options?: PemEncodeOptions): string; + /** Encodes multiple PEM blocks into a single string. */ + encodeMany(blocks: readonly PemEncodeBlock[], options?: PemEncodeOptions): string; + /** Decodes PEM text into blocks. */ + decode(text: string, options?: PemDecodeOptions): PemBlock[]; + /** Decodes the first matching PEM block. */ + decodeFirst(text: string, label?: string): Uint8Array; + /** Finds the first PEM block with the requested label. */ + find(text: string, label: string): PemBlock | undefined; + /** Finds all PEM blocks with the requested label. */ + findAll(text: string, label: string): PemBlock[]; + /** Parses the first matching PEM block and preserves the detected formatting. */ + parse(text: string, options?: PemDecodeOptions): ParsedBytes; + /** Formats bytes with previously detected PEM metadata. */ + format(data: BufferSourceLike, format: PemFormat): string; +} diff --git a/node_modules/@peculiar/utils/package.json b/node_modules/@peculiar/utils/package.json new file mode 100644 index 0000000000000000000000000000000000000000..c4bcc49f25d5b6f4c51de5328e8ed7fc4a48672f --- /dev/null +++ b/node_modules/@peculiar/utils/package.json @@ -0,0 +1,111 @@ +{ + "name": "@peculiar/utils", + "version": "2.0.3", + "description": "Modern byte, encoding, converter registry, and PEM utilities for TypeScript projects.", + "type": "module", + "main": "./build/cjs/index.js", + "module": "./build/esm/index.js", + "types": "./build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/esm/index.js", + "require": "./build/cjs/index.js" + }, + "./bytes": { + "types": "./build/types/bytes/index.d.ts", + "import": "./build/esm/bytes/index.js", + "require": "./build/cjs/bytes/index.js" + }, + "./encoding": { + "types": "./build/types/encoding/index.d.ts", + "import": "./build/esm/encoding/index.js", + "require": "./build/cjs/encoding/index.js" + }, + "./encoding/*": { + "types": "./build/types/encoding/*.d.ts", + "import": "./build/esm/encoding/*.js", + "require": "./build/cjs/encoding/*.js" + }, + "./converters": { + "types": "./build/types/converters/index.d.ts", + "import": "./build/esm/converters/index.js", + "require": "./build/cjs/converters/index.js" + }, + "./pem": { + "types": "./build/types/pem/index.d.ts", + "import": "./build/esm/pem/index.js", + "require": "./build/cjs/pem/index.js" + }, + "./legacy": { + "types": "./build/types/legacy/index.d.ts", + "import": "./build/esm/legacy/index.js", + "require": "./build/cjs/legacy/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "build/cjs/**/*.js", + "build/cjs/package.json", + "build/esm/**/*.js", + "build/types/**/*.d.ts", + "README.md", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "vitest run", + "coverage": "vitest run --coverage", + "clear": "rimraf build", + "rebuild": "npm run clear && npm run build", + "build": "node scripts/prune-legacy-build-outputs.mjs && tsc -p tsconfig.build.types.json && tsc -p tsconfig.build.esm.json && tsc -p tsconfig.build.cjs.json && node scripts/write-cjs-package-json.mjs", + "prepack": "npm run build", + "publish:manual": "npm run check && npm run build && npm publish --ignore-scripts", + "lint:check": "eslint . --fix-dry-run", + "check": "npm run lint:check && tsc --noEmit && npm test", + "lint": "eslint .", + "lint:fix": "eslint . --fix" + }, + "keywords": [ + "typescript", + "utils", + "buffer", + "bytes", + "convert", + "encoding", + "base64", + "base64url", + "hex", + "utf8", + "utf16", + "pem", + "pki", + "peculiar" + ], + "author": "PeculiarVentures", + "contributors": [ + "Miroshin Stepan" + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/pvtsutils" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/pvtsutils/issues" + }, + "homepage": "https://github.com/PeculiarVentures/pvtsutils#readme", + "dependencies": { + "tslib": "^2.8.1" + }, + "devDependencies": { + "@peculiar/eslint-config-base": "^0.2.9", + "@types/node": "^25.6.0", + "@vitest/coverage-v8": "^4.1.5", + "rimraf": "^6.1.3", + "typescript": "^6.0.3", + "vitest": "^4.1.5" + } +} diff --git a/node_modules/@peculiar/x509/LICENSE b/node_modules/@peculiar/x509/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..448def39e337f249111fb8090fa8eef6ec02bcca --- /dev/null +++ b/node_modules/@peculiar/x509/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Peculiar Ventures. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/x509/README.md b/node_modules/@peculiar/x509/README.md new file mode 100644 index 0000000000000000000000000000000000000000..748cea7d1a6718db4f399e970b52e5aaecb05ee9 --- /dev/null +++ b/node_modules/@peculiar/x509/README.md @@ -0,0 +1,220 @@ +

+ @peculiar/x509 +

+ +
+ +![NPM License](https://img.shields.io/npm/l/@peculiar/x509) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/PeculiarVentures/x509/test.yml?label=test) +[![npm version](https://img.shields.io/npm/v/@peculiar/x509.svg)](https://www.npmjs.com/package/@peculiar/x509) +![Coveralls](https://img.shields.io/coverallsCoverage/github/PeculiarVentures/x509) +[![npm downloads](https://img.shields.io/npm/dm/@peculiar/x509.svg)](https://www.npmjs.com/package/@peculiar/x509) + +
+ +- [About](#about) +- [Installation](#installation) +- [Documentation](#documentation) +- [Usage](#usage) + - [Browser](#browser) + - [Set crypto provider for Node.js](#set-crypto-provider-for-nodejs) + - [Create a self-signed certificate](#create-a-self-signed-certificate) + - [Parse a X509 certificate](#parse-a-x509-certificate) + - [Create a PKCS#10 certificate request](#create-a-pkcs10-certificate-request) + - [Decoded X509 certificate](#decoded-x509-certificate) + - [Build a certificate chain](#build-a-certificate-chain) + - [Export a list of X509 certificates to PKCS#7 format](#export-a-list-of-x509-certificates-to-pkcs7-format) + +## About + +`@peculiar/x509` is an easy to use TypeScript/Javascript library based on `@peculiar/asn1-schema` that makes generating X.509 Certificates and Certificate Requests as well as validating certificate chains easy. + +## Installation + +``` +npm install @peculiar/x509 +``` + +## Documentation + +[https://peculiarventures.github.io/x509/](https://peculiarventures.github.io/x509/) + +## Usage + +### Browser + +Every release of `@peculiar/x509` will have new build of `./build/x509.js` for use in the browser. To get access to module classes use `x509` global variable. + +> WARN: We recommend hosting and controlling your own copy for security reasons + +```html + +``` + +A simple web application examples + - [Generate X509 certificate](https://codesandbox.io/s/generate-cert-fjwfh) + - [Generate PKCS#10 certificate request](https://codesandbox.io/s/generate-csr-0qhed) + +### Set crypto provider for Node.js + +In some cases you may want to use a different cryptographic implementation, for example when you want to work with an object that supports a cryptographic algorithm not supported by the platform you are on. + +In these cases you can set a custom provider, these providers need to be compatible with the WebCrypto API, for example on NodeJS you can use `@peculiar/webcrypto` to allow `@peculiar/x509` to work the same as it does in browser! + +```js +import * as x509 from "@peculiar/x509"; +import { Crypto } from "@peculiar/webcrypto"; + +const crypto = new Crypto(); +x509.cryptoProvider.set(crypto); +``` + +### Create a self-signed certificate +```js +const alg = { + name: "RSASSA-PKCS1-v1_5", + hash: "SHA-256", + publicExponent: new Uint8Array([1, 0, 1]), + modulusLength: 2048, +}; +const keys = await crypto.subtle.generateKey(alg, false, ["sign", "verify"]); +const cert = await x509.X509CertificateGenerator.createSelfSigned({ + serialNumber: "01", + name: "CN=Test", + notBefore: new Date("2020/01/01"), + notAfter: new Date("2020/01/02"), + signingAlgorithm: alg, + keys, + extensions: [ + new x509.BasicConstraintsExtension(true, 2, true), + new x509.ExtendedKeyUsageExtension(["1.2.3.4.5.6.7", "2.3.4.5.6.7.8"], true), + new x509.KeyUsagesExtension(x509.KeyUsageFlags.keyCertSign | x509.KeyUsageFlags.cRLSign, true), + await x509.SubjectKeyIdentifierExtension.create(keys.publicKey), + ] +}); + +console.log(cert.toString("pem")); // Certificate in PEM format +``` + +### Parse a x509 certificate +```js +const base64 = "MIIDljCCAn6gAwIBAgIOSETcxtRwD...S+kAFXIwugUGYEnTWp0m5bAn5NlD314IEOg4mnS8Q=="; + +const cert = new x509.X509Certificate(base64); +console.log(cert.subject); // CN=Test, O=PeculiarVentures LLC +``` + +### Create a PKCS#10 certificate request +```js +const alg = { + name: "ECDSA", + namedCurve: "P-384", + hash: "SHA-384", +} +const keys = await crypto.subtle.generateKey(alg, false, ["sign", "verify"]); +const csr = await x509.Pkcs10CertificateRequestGenerator.create({ + name: "CN=Test", + keys, + signingAlgorithm: alg, + extensions: [ + new x509.KeyUsagesExtension(x509.KeyUsageFlags.digitalSignature | x509.KeyUsageFlags.keyEncipherment), + ], + attributes: [ + new x509.ChallengePasswordAttribute("password"), + ] +}); + +console.log(csr.toString("base64")); // Certificate request in Base64 format +``` + +### Decoded X509 certificate +```js +X509Certificate { + rawData: ArrayBuffer { + [Uint8Contents]: <30 82 02 fc 30 82 01 e4 a0 03 02 01 02 02 01 01 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 0f 31 0d 30 0b 06 03 55 04 03 13 04 54 65 73 74 30 1e 17 0d 31 39 31 32 33 31 32 31 30 30 30 30 5a 17 0d 32 30 30 31 30 31 32 31 30 30 30 30 5a 30 0f 31 0d 30 0b 06 03 55 04 03 13 04 54 65 73 74 30 82 01 ... 668 more bytes>, + byteLength: 768 + }, + tbs: ArrayBuffer { + [Uint8Contents]: <30 82 01 e4 a0 03 02 01 02 02 01 01 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 0f 31 0d 30 0b 06 03 55 04 03 13 04 54 65 73 74 30 1e 17 0d 31 39 31 32 33 31 32 31 30 30 30 30 5a 17 0d 32 30 30 31 30 31 32 31 30 30 30 30 5a 30 0f 31 0d 30 0b 06 03 55 04 03 13 04 54 65 73 74 30 82 01 22 30 0d 06 ... 388 more bytes>, + byteLength: 488 + }, + serialNumber: '01', + subject: 'CN=Test', + issuer: 'CN=Test', + signatureAlgorithm: { name: 'RSASSA-PKCS1-v1_5', hash: { name: 'SHA-256' } }, + signature: ArrayBuffer { + [Uint8Contents]: <2e 78 fb 4b f6 c8 a1 9d b4 d1 8b 22 80 20 c1 68 46 39 a6 11 d1 a9 7a 13 03 8d 1e 0e 5e 87 b5 33 2a ba 44 1b 96 6d 91 e7 fd c0 ce b7 93 fe e4 df d3 d0 57 7c 9a eb 7e 3e 8b ed c6 07 ad 80 df fd 8f f7 ce 26 07 db 0e 9f af e6 cb 70 02 2d 17 9f f5 c1 0d ef d6 cf 1d ec 78 a0 dd 5d 46 2a 60 08 71 74 2c 26 ... 156 more bytes>, + byteLength: 256 + }, + notBefore: 2019-12-31T21:00:00.000Z, + notAfter: 2020-01-01T21:00:00.000Z, + extensions: Extensions(4) [ + BasicConstraintsExtension { + rawData: [ArrayBuffer], + type: '2.5.29.19', + critical: true, + value: [ArrayBuffer], + ca: true, + pathLength: 2 + }, + ExtendedKeyUsageExtension { + rawData: [ArrayBuffer], + type: '2.5.29.37', + critical: true, + value: [ArrayBuffer], + usages: [ExtendedKeyUsage] + }, + KeyUsagesExtension { + rawData: [ArrayBuffer], + type: '2.5.29.15', + critical: true, + value: [ArrayBuffer], + usages: 96 + }, + SubjectKeyIdentifierExtension { + rawData: [ArrayBuffer], + type: '2.5.29.14', + critical: false, + value: [ArrayBuffer], + keyId: 'f525754650a3dee83f8bd777ee3b53ecc2c8d726' + } + ], + publicKey: PublicKey { + rawData: ArrayBuffer { + [Uint8Contents]: <30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 82 01 0f 00 30 82 01 0a 02 82 01 01 00 b6 f4 f1 cf dd 26 a1 23 45 b6 6e 4e ec 3e 20 8a 3f 90 ec 84 46 49 87 a2 05 c5 eb da ac 84 37 eb a3 bf 46 b5 8e 82 75 25 8a 80 19 10 79 13 c0 13 6c 29 df 56 44 1c ec f8 7b 34 0a f2 13 41 b5 53 98 e1 f5 ... 194 more bytes>, + byteLength: 294 + }, + algorithm: { + name: 'RSASSA-PKCS1-v1_5', + publicExponent: [Uint8Array], + modulusLength: 2048 + } + } +} +``` + +### Build a certificate chain +```js +const chain = new x509.X509ChainBuilder({ + certificates: [ + new x509.X509Certificate(raw1), + new x509.X509Certificate(raw2), + // ... + new x509.X509Certificate(rawN), + ], +}); + +const cert = x509.X509Certificate(raw); +const items = await chain.build(cert); +console.log(items); // [ X509Certificate, X509Certificate, X509Certificate ] +``` + +### Export a list of X509 certificates to PKCS#7 format +```js +const certs = new x509.X509Certificates([ + new x509.X509Certificate("MIIDljCCAn6gAwIBAgIOSETcxtRwD...S+kAFXIwugUGYEnTWp0m5bAn5NlD314IEOg4mnS8Q=="), + new x509.X509Certificate("MIIDljCCAn6gAwIBAgIOSETcxtRwD...w8Y/o+hk3QzNBVa3ZUvzDhVAmamQflvw3lXMm/JG4U="), +]); + +console.log(certs.export("base64")); // "MIICTAYJKoZIhvcNAQcCoIICPTCCAjkCAQAxADACBgCgggIq...F7EZPNo3pjbfznpIilRMRrmwf5dkgCdSKDdE94xAA=="); +``` diff --git a/node_modules/@peculiar/x509/build/index.d.ts b/node_modules/@peculiar/x509/build/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7338ed4b33b0d370f43f9f6e0345fa488423f261 --- /dev/null +++ b/node_modules/@peculiar/x509/build/index.d.ts @@ -0,0 +1,1746 @@ +/*! + * MIT License + * + * Copyright (c) Peculiar Ventures. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +import * as asn1X509 from '@peculiar/asn1-x509'; +import { Extension as Extension$1, SubjectPublicKeyInfo, Attribute as Attribute$1, AlgorithmIdentifier, Name as Name$1, Certificate, RevokedCertificate, CertificateList, Version } from '@peculiar/asn1-x509'; +import * as asn1Rsa from '@peculiar/asn1-rsa'; +import { CertificationRequest } from '@peculiar/asn1-csr'; +import { BufferSource as BufferSource$1 } from 'pvtsutils'; + +interface TextObjectConvertible { + /** + * Returns the object in textual representation + */ + toTextObject(): TextObject; +} +type TextObjectItemType = string | number | boolean | Date | BufferSource | TextObject | TextObject[] | TextObjectConvertible; +declare const NAME: unique symbol; +declare const VALUE: unique symbol; +declare class TextObject { + static NAME: typeof NAME; + static VALUE: typeof VALUE; + [key: string | symbol]: TextObjectItemType; + [NAME]: string; + [VALUE]: string; + constructor(name: string, items?: Record, value?: string); +} +interface AlgorithmSerializer { + toTextObject(alg: asn1X509.AlgorithmIdentifier): TextObject; +} +declare abstract class DefaultAlgorithmSerializer { + static toTextObject(alg: asn1X509.AlgorithmIdentifier): TextObject; +} +declare abstract class OidSerializer { + static items: Record; + static toString(oid: string): string; +} +declare abstract class TextConverter { + static oidSerializer: typeof OidSerializer; + static algorithmSerializer: AlgorithmSerializer; + static serialize(obj: TextObject): string; + private static pad; + private static serializeObj; + private static serializeBufferSource; + static serializeAlgorithm(alg: asn1X509.AlgorithmIdentifier): TextObject; +} + +type AsnDataStringFormat = "asn" | "text" | "hex" | "base64" | "base64url"; +/** + * Represents an ASN.1 data + */ +declare abstract class AsnData implements TextObjectConvertible { + #private; + static NAME: string; + /** + * Gets a DER encoded buffer + */ + get rawData(): ArrayBuffer; + /** + * ASN.1 object + */ + protected readonly asn: T; + /** + * Creates a new instance + * @param raw DER encoded buffer + * @param type ASN.1 convertible class for `@peculiar/asn1-schema` schema + */ + constructor(raw: BufferSource, type: new () => T); + /** + * ASN.1 object + * @param asn + */ + constructor(asn: T); + /** + * Occurs on instance initialization + * @param asn ASN.1 object + */ + protected abstract onInit(asn: T): void; + /** + * Returns `true` if ASN.1 data is equal to another ASN.1 data, otherwise `false` + * @param data Any data + */ + equal(data: any): data is this; + toString(format?: AsnDataStringFormat): string; + protected getTextName(): string; + toTextObject(): TextObject; + protected toTextObjectEmpty(value?: string): TextObject; +} + +/** + * Represents the certificate extension + */ +declare class Extension extends AsnData { + /** + * Gets an extension identifier + */ + type: string; + /** + * Indicates where extension is critical + */ + critical: boolean; + /** + * Gets a DER encoded value of extension + */ + value: ArrayBuffer; + /** + * Creates a new instance from DER encoded Buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param type Extension identifier + * @param critical Indicates where extension is critical + * @param value DER encoded value of extension + */ + constructor(type: string, critical: boolean, value: BufferSource); + protected onInit(asn: Extension$1): void; + toTextObject(): TextObject; + toTextObjectWithoutValue(): TextObject; +} + +interface JsonGeneralName { + type: GeneralNameType; + value: string; +} +declare const DNS = "dns"; +declare const DN = "dn"; +declare const EMAIL = "email"; +declare const IP = "ip"; +declare const URL = "url"; +declare const GUID = "guid"; +declare const UPN = "upn"; +declare const REGISTERED_ID = "id"; +type GeneralNameType = typeof DNS | typeof DN | typeof EMAIL | typeof GUID | typeof IP | typeof URL | typeof UPN | typeof REGISTERED_ID; +/** + * Represents ASN.1 type of GeneralName. + * + * This class doesn't support no standard string format is + * defined for otherName, X.400 name, EDI party name, or any other type of names. + */ +declare class GeneralName extends AsnData { + /** + * Type of the storing value + */ + type: GeneralNameType; + /** + * Text representation of ASN.1 GeneralName + */ + value: string; + constructor(type: GeneralNameType, value: string); + constructor(asn: asn1X509.GeneralName); + constructor(raw: BufferSource); + /** + * Occurs on instance initialization + * @param asn + * + * @throws Throws error if ASN.1 GeneralName contains + * unsupported value (eg otherName, X400 address, EDI party name) + */ + protected onInit(asn: asn1X509.GeneralName): void; + toJSON(): JsonGeneralName; + toTextObject(): TextObject; +} +type JsonGeneralNames = JsonGeneralName[]; +declare class GeneralNames extends AsnData { + static NAME: string; + items: readonly GeneralName[]; + constructor(json: JsonGeneralNames); + constructor(asn: asn1X509.GeneralNames | asn1X509.GeneralName[]); + constructor(raw: BufferSource); + protected onInit(asn: asn1X509.GeneralNames): void; + toJSON(): JsonGeneralNames; + toTextObject(): TextObject; +} + +type AsnExportType = "pem" | AsnDataStringFormat; +type AsnEncodedType = BufferSource | string; +declare abstract class PemData extends AsnData { + static isAsnEncoded(data: any): data is AsnEncodedType; + /** + * Converts encoded raw to ArrayBuffer. Supported formats are HEX, DER, Base64, Base64Url, PEM + * @param raw Encoded data + */ + static toArrayBuffer(raw: BufferSource | string): ArrayBuffer; + /** + * PEM tag + */ + protected abstract readonly tag: string; + /** + * Creates a new instance + * @param raw Encoded buffer (DER, PEM, HEX, Base64, Base64Url) + * @param type ASN.1 convertible class for `@peculiar/asn1-schema` schema + */ + constructor(raw: AsnEncodedType, type: new () => T); + /** + * Creates a new instance + * @param asn ASN.1 object + */ + constructor(asn: T); + /** + * Returns encoded object in PEM format + */ + toString(): string; + /** + * Returns encoded object in selected format + * @param format hex, base64, base64url, pem, asn, text + */ + toString(format: AsnExportType): string; +} + +interface IPublicKeyContainer { + publicKey: PublicKey; +} +/** + * Public key type. Represents a public key in different formats. + */ +type PublicKeyType = PublicKey | CryptoKey | IPublicKeyContainer | BufferSource; +/** + * Representation of Subject Public Key Info + */ +declare class PublicKey extends PemData { + /** + * Creates a new instance from a public key data + * @param data Public key data + * @param crypto Crypto provider. Default is from CryptoProvider + */ + static create(data: PublicKeyType, crypto?: Crypto): Promise; + protected readonly tag: string; + /** + * Gets a key algorithm + */ + algorithm: Algorithm; + /** + * Creates a new instance from ASN.1 + * @param asn ASN.1 object + */ + constructor(asn: SubjectPublicKeyInfo); + /** + * Creates a new instance + * @param raw Encoded buffer (DER, PEM, HEX, Base64, Base64Url) + */ + constructor(raw: AsnEncodedType); + /** + * Returns a public CryptoKey + * @param crypto Crypto provider. Default is from CryptoProvider + */ + export(crypto?: Crypto): Promise; + /** + * Returns a public CryptoKey with specified parameters + * @param algorithm Algorithm + * @param keyUsages A list of key usages + * @param crypto Crypto provider. Default is from CryptoProvider + */ + export(algorithm: Algorithm | EcKeyImportParams | RsaHashedImportParams, keyUsages: KeyUsage[], crypto?: Crypto): Promise; + protected onInit(asn: SubjectPublicKeyInfo): void; + /** + * Returns a SHA-1 public key thumbprint + * @param crypto Crypto provider. Default is from CryptoProvider + */ + getThumbprint(crypto?: Crypto): Promise; + /** + * Returns a public key thumbprint for specified mechanism + * @param algorithm Hash algorithm + * @param crypto Crypto provider. Default is from CryptoProvider + */ + getThumbprint(algorithm: globalThis.AlgorithmIdentifier, crypto?: Crypto): Promise; + /** + * Returns Subject Key Identifier as specified in {@link https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.2 RFC5280} + * @param crypto Crypto provider. Default is from CryptoProvider + */ + getKeyIdentifier(crypto?: Crypto): Promise; + /** + * Returns Subject Key Identifier for specified algorithm + * @param algorithm Hash algorithm + * @param crypto Crypto provider. Default is from CryptoProvider + */ + getKeyIdentifier(algorithm: globalThis.AlgorithmIdentifier, crypto?: Crypto): Promise; + toTextObject(): TextObject; +} + +interface CertificateIdentifier { + /** + * Name + */ + name: asn1X509.GeneralName[] | asn1X509.GeneralNames | GeneralNames; + /** + * Hexadecimal string + */ + serialNumber: string; +} +/** + * Represents the Authority Key Identifier certificate extension + */ +declare class AuthorityKeyIdentifierExtension extends Extension { + static NAME: string; + /** + * Creates authority key identifier extension from certificate identifier + * @param certId Certificate identifier + * @param critical Indicates where extension is critical. Default is `false` + * @param crypto WebCrypto provider. Default is from CryptoProvider + */ + static create(certId: CertificateIdentifier, critical?: boolean, crypto?: Crypto): Promise; + /** + * Creates authority key identifier extension from public key data + * @param publicKey Public key data + * @param critical Indicates where extension is critical. Default is `false` + * @param crypto WebCrypto provider. Default is from CryptoProvider + */ + static create(publicKey: PublicKeyType, critical?: boolean, crypto?: Crypto): Promise; + /** + * Gets a hexadecimal representation of key identifier + */ + keyId?: string; + /** + * Gets a certificate identifier in the issuer name and serial number + */ + certId?: CertificateIdentifier; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param identifier Hexadecimal representation of key identifier + * @param critical Indicates where extension is critical. Default is `false` + */ + constructor(identifier: string, critical?: boolean); + /** + * Creates a new instance + * @param id Certificate identifier in the issuer name and serial number + * @param critical Indicates where extension is critical. Default is `false` + */ + constructor(id: CertificateIdentifier, critical?: boolean); + protected onInit(asn: asn1X509.Extension): void; + toTextObject(): TextObject; +} + +/** + * Represents the Basic Constraints certificate extension + */ +declare class BasicConstraintsExtension extends Extension { + static NAME: string; + /** + * Indicates whether the certified public key may be used + * to verify certificate signatures + */ + readonly ca: boolean; + /** + * Gets a maximum number of non-self-issued intermediate certificates that may + * follow this certificate in a valid certification path + */ + readonly pathLength?: number; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param ca + * @param pathLength + * @param critical + */ + constructor(ca: boolean, pathLength?: number, critical?: boolean); + toTextObject(): TextObject; +} + +declare enum ExtendedKeyUsage { + serverAuth = "1.3.6.1.5.5.7.3.1", + clientAuth = "1.3.6.1.5.5.7.3.2", + codeSigning = "1.3.6.1.5.5.7.3.3", + emailProtection = "1.3.6.1.5.5.7.3.4", + timeStamping = "1.3.6.1.5.5.7.3.8", + ocspSigning = "1.3.6.1.5.5.7.3.9" +} +type ExtendedKeyUsageType = asn1X509.ExtendedKeyUsage | string; +/** + * Represents the Extended Key Usage certificate extension + */ +declare class ExtendedKeyUsageExtension extends Extension { + static NAME: string; + /** + * Gets a list of purposes for which the certified public key may be used + */ + readonly usages: ExtendedKeyUsageType[]; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param usages + * @param critical + */ + constructor(usages: ExtendedKeyUsageType[], critical?: boolean); + toTextObject(): TextObject; +} + +/** + * X509 key usages flags + */ +declare enum KeyUsageFlags { + digitalSignature = 1, + nonRepudiation = 2, + keyEncipherment = 4, + dataEncipherment = 8, + keyAgreement = 16, + keyCertSign = 32, + cRLSign = 64, + encipherOnly = 128, + decipherOnly = 256 +} +/** + * Represents the Key Usage certificate extension + */ +declare class KeyUsagesExtension extends Extension { + static NAME: string; + /** + * Gets a key usages flag + */ + readonly usages: KeyUsageFlags; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param usages + * @param critical + */ + constructor(usages: KeyUsageFlags, critical?: boolean); + toTextObject(): TextObject; +} + +/** + * Represents the Subject Key Identifier certificate extension + */ +declare class SubjectKeyIdentifierExtension extends Extension { + static NAME: string; + /** + * Creates subject key identifier extension from public key data + * @param publicKey Public key data + * @param critical Indicates where extension is critical. Default is `false` + * @param crypto WebCrypto provider. Default is from CryptoProvider + */ + static create(publicKey: PublicKeyType, critical?: boolean, crypto?: Crypto): Promise; + /** + * Gets hexadecimal representation of key identifier + */ + readonly keyId: string; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param keyId Hexadecimal representation of key identifier + * @param critical Indicates where extension is critical. Default is `false` + */ + constructor(keyId: string, critical?: boolean); + toTextObject(): TextObject; +} + +/** + * Represents the Subject Alternative Name certificate extension + */ +declare class SubjectAlternativeNameExtension extends Extension { + names: GeneralNames; + static NAME: string; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param data JSON representation of SAN + * @param critical Indicates where extension is critical. Default is `false` + */ + constructor(data?: JsonGeneralNames, critical?: boolean); + onInit(asn: asn1X509.Extension): void; + toTextObject(): TextObject; +} + +/** + * Represents the Certificate Policy extension + */ +declare class CertificatePolicyExtension extends Extension { + static NAME: string; + /** + * Gets the list of certificate policies + */ + readonly policies: readonly string[]; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param policies + * @param critical + */ + constructor(policies: string[], critical?: boolean); + toTextObject(): TextObject; +} + +/** + * Represents the CRL Distribution Points extension + */ +declare class CRLDistributionPointsExtension extends Extension { + static NAME: string; + distributionPoints: asn1X509.DistributionPoint[]; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param value The value of the extension + * @param critical Indicates whether the extension is critical. Default is `false` + */ + constructor(value: asn1X509.DistributionPoint[], critical?: boolean); + /** + * Creates a new instance from an array of URLs + * @param urls An array of URLs to be used as distribution points. + * @param critical Indicates whether the extension is critical. Default is `false` + */ + constructor(urls: string[], critical?: boolean); + protected onInit(asn: asn1X509.Extension): void; + toTextObject(): TextObject; +} + +type AccessItemTypes = GeneralName | GeneralName[] | string | string[]; +interface AuthorityInfoAccessParams { + ocsp?: AccessItemTypes; + caIssuers?: AccessItemTypes; + timeStamping?: AccessItemTypes; + caRepository?: AccessItemTypes; +} +/** + * Represents the Authority Info Access certificate extension + */ +declare class AuthorityInfoAccessExtension extends Extension { + static NAME: string; + ocsp: GeneralName[]; + caIssuers: GeneralName[]; + timeStamping: GeneralName[]; + caRepository: GeneralName[]; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param value The value of the extension + * @param critical Indicates whether the extension is critical. Default is `false` + */ + constructor(value: asn1X509.AuthorityInfoAccessSyntax, critical?: boolean); + /** + * Creates a new instance + * @param params The value of the extension + * @param critical Indicates whether the extension is critical. Default is `false` + */ + constructor(params: AuthorityInfoAccessParams, critical?: boolean); + protected onInit(asn: asn1X509.Extension): void; + toTextObject(): TextObject; +} + +/** + * Represents the Issuer Alternative Name certificate extension + */ +declare class IssuerAlternativeNameExtension extends Extension { + names: GeneralNames; + static NAME: string; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param data JSON representation of IAN + * @param critical Indicates where extension is critical. Default is `false` + */ + constructor(data?: JsonGeneralNames, critical?: boolean); + onInit(asn: asn1X509.Extension): void; + toTextObject(): TextObject; +} + +/** + * Static class to manage X509 extensions + */ +declare class ExtensionFactory { + private static items; + /** + * Registers a new X509 Extension class. If id already exists replaces it + * @param id Extension identifier + * @param type Extension class + * + * @example + * ```js + * ExtensionFactory.register( + * asnX509.id_ce_basicConstraints, + * extensions.BasicConstraintsExtension, + * ); + * ``` + */ + static register(id: string, type: any): void; + /** + * Returns X509 Extension based on it's identifier + * @param data DER encoded buffer + * + * @example + * ```js + * const ext = ExtensionFactory.create(asnExtRaw); + * ``` + */ + static create(data: BufferSource): Extension; +} + +/** + * Represents the Attribute structure + */ +declare class Attribute extends AsnData { + static NAME: string; + /** + * Gets an attribute identifier + */ + type: string; + /** + * Gets a list of DER encoded attribute values + */ + values: ArrayBuffer[]; + /** + * Crates a new instance + * @param type Attribute identifier + * @param values List of DER encoded attribute values + */ + constructor(type: string, values?: BufferSource[]); + /** + * Crates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + protected onInit(asn: Attribute$1): void; + toTextObject(): TextObject; + toTextObjectWithoutValue(): TextObject; +} + +declare class ChallengePasswordAttribute extends Attribute { + static NAME: string; + password: string; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param value + */ + constructor(value: string); + protected onInit(asn: asn1X509.Attribute): void; + toTextObject(): TextObject; +} + +declare class ExtensionsAttribute extends Attribute { + static NAME: string; + items: Extension[]; + /** + * Creates a new instance from DER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance + * @param extensions + */ + constructor(extensions: Extension[]); + protected onInit(asn: asn1X509.Attribute): void; + toTextObject(): TextObject; +} + +/** + * Static class to manage X509 attributes + */ +declare class AttributeFactory { + private static items; + /** + * Registers a new X509 Attribute class. If id already exists replaces it + * @param id Attribute identifier + * @param type Attribute class + * + * @example + * ```js + * AttributeFactory.register(asnPkcs9.id_pkcs9_at_challengePassword, ChallengePasswordAttribute); + * ``` + */ + static register(id: string, type: any): void; + /** + * Returns X509 Attribute based on it's identifier + * @param data DER encoded buffer + * + * @example + * ```js + * const attr = AttributeFactory.create(asnAttrRaw); + * ``` + */ + static create(data: BufferSource): Attribute; +} + +/** + * Dependency injection identifier for `IAsnSignatureFormatter` interface + */ +declare const diAsnSignatureFormatter = "crypto.signatureFormatter"; +/** + * Provides mechanism to convert ASN.1 signature value to WebCrypto and back + * + * To register it's implementation in global use `tsyringe` container + * @example + * ``` + * import { container } from "tsyringe"; + * + * container.registerSingleton(diAsnSignatureFormatter, AsnDefaultSignatureFormatter); + * ``` + */ +interface IAsnSignatureFormatter { + /** + * Converts ASN.1 signature to WebCrypto format + * @param algorithm Key and signing algorithm + * @param signature ASN.1 signature value in DER format + */ + toAsnSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null; + /** + * Converts WebCrypto signature to ASN.1 DER encoded signature value + * @param algorithm + * @param signature + */ + toWebSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null; +} +declare class AsnDefaultSignatureFormatter implements IAsnSignatureFormatter { + toAsnSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null; + toWebSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null; +} + +interface UnknownAlgorithm extends Algorithm { + name: string; + parameters?: ArrayBuffer | null; +} +interface IAlgorithm { + /** + * Converts WebCrypto algorithm to ASN.1 algorithm + * @param alg WebCrypto algorithm + * @returns ASN.1 algorithm or null + */ + toAsnAlgorithm(alg: Algorithm): AlgorithmIdentifier | null; + /** + * Converts ASN.1 algorithm to WebCrypto algorithm + * @param alg ASN.1 algorithm + * @returns WebCrypto algorithm or null + */ + toWebAlgorithm(alg: AlgorithmIdentifier): Algorithm | null; +} +/** + * Dependency Injection algorithm identifier + */ +declare const diAlgorithm = "crypto.algorithm"; +declare class AlgorithmProvider { + /** + * Returns all registered algorithm providers + */ + getAlgorithms(): IAlgorithm[]; + /** + * Converts WebCrypto algorithm to ASN.1 algorithm + * @param alg WebCrypto algorithm + * @returns ASN.1 algorithm + * @throws Error whenever cannot convert an algorithm + */ + toAsnAlgorithm(alg: Algorithm): AlgorithmIdentifier; + /** + * ConvertsASN.1 algorithm to WebCrypto algorithm + * @param alg ASN.1 algorithm + * @returns algorithm + */ + toWebAlgorithm(alg: AlgorithmIdentifier): Algorithm; +} +declare const diAlgorithmProvider = "crypto.algorithmProvider"; + +interface HashedAlgorithm extends Algorithm { + hash: Algorithm; +} + +/** + * RSA algorithm provider + */ +declare class RsaAlgorithm implements IAlgorithm { + static createPssParams(hash: unknown, saltLength: number): asn1Rsa.RsaSaPssParams | null; + static getHashAlgorithm(alg: unknown): AlgorithmIdentifier | null; + toAsnAlgorithm(alg: Algorithm): AlgorithmIdentifier | null; + toWebAlgorithm(alg: AlgorithmIdentifier): Algorithm | HashedAlgorithm | null; +} + +/** + * EC algorithm provider + */ +declare class EcAlgorithm implements IAlgorithm { + static SECP256K1: string; + toAsnAlgorithm(alg: HashedAlgorithm | EcKeyGenParams): AlgorithmIdentifier | null; + toWebAlgorithm(alg: AlgorithmIdentifier): HashedAlgorithm | EcKeyGenParams | null; +} + +/** + * SHA algorithm provider + */ +declare class ShaAlgorithm implements IAlgorithm { + toAsnAlgorithm(alg: Algorithm): AlgorithmIdentifier | null; + toWebAlgorithm(alg: AlgorithmIdentifier): Algorithm | null; +} + +declare class AsnEcSignatureFormatter implements IAsnSignatureFormatter { + static namedCurveSize: Map; + static defaultNamedCurveSize: number; + private addPadding; + private removePadding; + toAsnSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null; + toWebSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null; +} + +declare const idX25519 = "1.3.101.110"; +declare const idX448 = "1.3.101.111"; +declare const idEd25519 = "1.3.101.112"; +declare const idEd448 = "1.3.101.113"; +/** + * ECDH-ES and EdDSA algorithm provider + */ +declare class EdAlgorithm implements IAlgorithm { + toAsnAlgorithm(alg: EcKeyGenParams): AlgorithmIdentifier | null; + toWebAlgorithm(alg: AlgorithmIdentifier): HashedAlgorithm | EcKeyGenParams | Algorithm | null; +} + +type IdOrName = Record; +declare class NameIdentifier { + private items; + constructor(names?: Record); + get(idOrName: string): string | null; + findId(idOrName: string): string | null; + register(id: string, name: string): void; +} +/** + * JSON representation of Attribute and Value + */ +type JsonAttributeAndStringValue = Record; +interface JsonAttributeObject { + ia5String?: string; + utf8String?: string; + universalString?: string; + bmpString?: string; + printableString?: string; +} +type JsonAttributeAndObjectValue = Record; +type JsonAttributeAndValue = JsonAttributeAndStringValue | JsonAttributeAndObjectValue; +/** + * JSON array of Attribute and Value + */ +type JsonName = JsonAttributeAndStringValue[]; +type JsonNameParams = JsonAttributeAndValue[]; +/** + * UTF-8 String Representation of Distinguished Names + * + * https://tools.ietf.org/html/rfc2253 + */ +declare class Name { + private extraNames; + /** + * Returns `true` if text is ASCII otherwise `false` + * @param text Text + * @returns + */ + static isASCII(text: string): boolean; + /** + * Checks if a given string is a printable string. + * A printable string contains only printable ASCII characters. + * + * @param text - The string to be checked. + * @returns True if the string is a printable string, false otherwise. + */ + static isPrintableString(text: string): boolean; + /** + * ASN.1 Name + */ + private asn; + /** + * Creates a new instance + * @param data + * @param extraNames Extra identifiers for name customization + * @example + * const text = "URL=http://some.url.com, IP=192.168.0.1, GUID={8ee13e53-2c1c-42bb-8df7-39927c0bdbb6}"; + * const name = new x509.Name(text, { + * "Email": "1.2.3.4.5.1", + * "IP": "1.2.3.4.5.2", + * "GUID": "1.2.3.4.5.3", + * }); + */ + constructor(data: BufferSource | Name$1 | string | JsonNameParams, extraNames?: IdOrName); + /** + * Returns a list of string values filtered by specified id or name + * @param idOrName ObjectIdentifier or string name + * @returns Returns a list of strings. Returns an empty list if there are not any + * values for specified id/name. + */ + getField(idOrName: string): string[]; + private getName; + /** + * Returns string serialized Name + */ + toString(): string; + /** + * Returns a JSON representation of the Name + */ + toJSON(): JsonName; + /** + * Creates AsnName object from string + * @param data + */ + private fromString; + /** + * Creates AsnName from JSON + * @param data + */ + private fromJSON; + /** + * Gets the OID for a given type name + * @param type The type name + * @returns The OID string + */ + private getTypeOid; + /** + * Creates an AttributeTypeAndValue object + * @param type The type OID + * @param value The value + * @returns The AttributeTypeAndValue object + */ + private createAttribute; + /** + * Processes a string value by unescaping and replacing special characters + * @param value The string value + * @returns The processed string value + */ + private processStringValue; + /** + * Returns Name in DER encoded format + */ + toArrayBuffer(): ArrayBuffer; + /** + * Returns a SHA-1 thumbprint + * @param crypto Crypto provider. Default is from CryptoProvider + */ + getThumbprint(crypto?: Crypto): Promise; + /** + * Returns a thumbprint for specified mechanism + * @param algorithm Hash algorithm + * @param crypto Crypto provider. Default is from CryptoProvider + */ + getThumbprint(algorithm: globalThis.AlgorithmIdentifier, crypto?: Crypto): Promise; +} + +interface PemHeader { + key: string; + value: string; +} +/** + * Represents PEM structure + */ +interface PemStruct { + /** + * Type + */ + type: string; + /** + * Headers + */ + headers: PemHeader[]; + /** + * Decoded message data + */ + rawData: ArrayBuffer; +} +type AtLeast = Partial & Pick; +type PemStructEncodeParams = AtLeast; +/** + * Represents PEM Converter. + */ +declare class PemConverter { + static CertificateTag: string; + static CrlTag: string; + static CertificateRequestTag: string; + static PublicKeyTag: string; + static PrivateKeyTag: string; + static isPem(data: any): data is string; + static decodeWithHeaders(pem: string): PemStruct[]; + /** + * Decodes PEM to a list of raws + * @param pem message in PEM format + */ + static decode(pem: string): ArrayBuffer[]; + /** + * Decodes PEM and returns first item from the list + * @param pem message in PEM format + * @throw Throws RangeError if list of decoded items is empty + */ + static decodeFirst(pem: string): ArrayBuffer; + /** + * Encodes a list of PemStruct in PEM format + * @param structs A list of PemStruct + * @param tag PEM tag + */ + static encode(structs: PemStructEncodeParams[]): string; + /** + * Encodes a raw data in PEM format + * @param rawData Raw data + * @param tag PEM tag + */ + static encode(rawData: BufferSource, tag: string): string; + /** + * Encodes a list of raws in PEM format + * @param raws A list of raws + * @param tag PEM tag + */ + static encode(rawData: BufferSource[], tag: string): string; + /** + * Encodes PEMStruct in PEM block + * @param pem PEM structure for encoding + * @returns Returns PEM encoded block + */ + private static encodeStruct; +} + +/** + * Representation of PKCS10 Certificate Request + */ +declare class Pkcs10CertificateRequest extends PemData implements IPublicKeyContainer { + #private; + static NAME: string; + protected readonly tag: string; + /** + * Gets the subject value from the certificate as an Name + */ + get subjectName(): Name; + /** + * Gets a string subject name + */ + get subject(): string; + /** + * Gets a signature algorithm + */ + get signatureAlgorithm(): HashedAlgorithm; + /** + * Gets a signature + */ + get signature(): ArrayBuffer; + /** + * Gets a public key of CSR + */ + get publicKey(): PublicKey; + /** + * Gets a list fo CSR attributes + */ + get attributes(): Attribute[]; + /** + * Gets a list of CSR extensions + */ + get extensions(): Extension[]; + /** + * Gets the ToBeSigned block + */ + private get tbs(); + /** + * Creates a new instance fromDER encoded buffer + * @param raw DER encoded buffer + */ + constructor(raw: AsnEncodedType); + /** + * Creates a new instance from ASN.1 CertificationRequest + * @param asn ASN.1 CertificationRequest + */ + constructor(asn: CertificationRequest); + protected onInit(_asn: CertificationRequest): void; + /** + * Returns attribute of the specified type + * @param type Attribute identifier + * @returns Attribute or null + */ + getAttribute(type: string): Attribute | null; + /** + * Returns a list of attributes of the specified type + * @param type Attribute identifier + */ + getAttributes(type: string): Attribute[]; + /** + * Returns extension of the specified type + * @param type Extension identifier + * @returns Extension or null + */ + getExtension(type: string): Extension | null; + /** + * Returns a list of extension of the specified type + * @param type Extension identifier + */ + getExtensions(type: string): Extension[]; + /** + * Validates CSR signature + * @param crypto Crypto provider. Default is from CryptoProvider + */ + verify(crypto?: Crypto): Promise; + toTextObject(): TextObject; +} + +type Pkcs10CertificateRequestCreateParamsName = string | JsonName | Name; +/** + * Pkcs10CertificateRequest create parameters + */ +interface Pkcs10CertificateRequestCreateParams { + /** + * Subject name + */ + name?: Pkcs10CertificateRequestCreateParamsName; + /** + * Extensions + */ + extensions?: Extension[]; + /** + * Attributes + */ + attributes?: Attribute[]; + /** + * Signing algorithm + */ + signingAlgorithm: Algorithm | EcdsaParams; + /** + * Crypto key pair + */ + keys: CryptoKeyPair; +} +/** + * Generator of PKCS10 certificate requests + */ +declare class Pkcs10CertificateRequestGenerator { + /** + * Creates a new PKCS10 Certificate request + * @param params Create parameters + * @param crypto Crypto provider. Default is from CryptoProvider + */ + static create(params: Pkcs10CertificateRequestCreateParams, crypto?: Crypto): Promise; +} + +type MapForEachCallback = (value: Crypto, key: string, map: Map) => void; +/** + * Crypto provider + */ +declare class CryptoProvider { + static DEFAULT: string; + private items; + /** + * Returns `true` if data is CryptoKeyPair + * @param data + */ + static isCryptoKeyPair(data: any): data is CryptoKeyPair; + static isCryptoKey(data: any): data is CryptoKey; + /** + * Creates a new instance + */ + constructor(); + clear(): void; + delete(key: string): boolean; + forEach(callbackfn: MapForEachCallback, thisArg?: any): void; + has(key: string): boolean; + get size(): number; + entries(): IterableIterator<[string, Crypto]>; + keys(): IterableIterator; + values(): IterableIterator; + [Symbol.iterator](): IterableIterator<[string, Crypto]>; + [Symbol.toStringTag]: string; + /** + * Returns default crypto + * @throws Error whenever default provider not set + */ + get(): Crypto; + /** + * Returns crypto by name + * @param key Crypto name + * @throws Error whenever provider with specified identifier does not exist + */ + get(key: string): Crypto; + /** + * Sets default crypto + * @param value + */ + set(value: Crypto): this; + /** + * Sets crypto with specified identifier + * @param key Identifier + * @param value crypto provider + */ + set(key: string, value: Crypto): this; +} +/** + * Singleton crypto provider + */ +declare const cryptoProvider: CryptoProvider; + +/** + * Verification params of X509 certificate + */ +interface X509CertificateVerifyParams { + date?: Date; + publicKey?: PublicKeyType; + signatureOnly?: boolean; +} +/** + * Representation of X509 certificate + */ +declare class X509Certificate extends PemData implements IPublicKeyContainer { + #private; + static NAME: string; + protected readonly tag: string; + /** + * Gets a public key of the certificate + */ + get publicKey(): PublicKey; + /** + * Gets a hexadecimal string of the serial number + */ + get serialNumber(): string; + /** + * Gets the subject value from the certificate as an Name + */ + get subjectName(): Name; + /** + * Gets a string subject name + */ + get subject(): string; + /** + * Gets the issuer value from the certificate as an Name + */ + get issuerName(): Name; + /** + * Gets a string issuer name + */ + get issuer(): string; + /** + * Gets a date before which certificate can't be used + */ + get notBefore(): Date; + /** + * Gets a date after which certificate can't be used + */ + get notAfter(): Date; + /** + * Gets a signature algorithm + */ + get signatureAlgorithm(): HashedAlgorithm; + /** + * Gets a signature + */ + get signature(): ArrayBuffer; + /** + * Gets a list of certificate extensions + */ + get extensions(): Extension[]; + /** + * Gets a private key of the certificate + */ + privateKey?: CryptoKey; + /** + * Gets the ToBeSigned block + */ + private get tbs(); + /** + * Creates a new instance from ASN.1 Certificate object + * @param asn ASN.1 Certificate object + */ + constructor(asn: Certificate); + /** + * Creates a new instance + * @param raw Encoded buffer (DER, PEM, HEX, Base64, Base64Url) + */ + constructor(raw: AsnEncodedType); + protected onInit(_asn: Certificate): void; + /** + * Returns an extension of specified type + * @param type Extension identifier + * @returns Extension or null + */ + getExtension(type: string): T | null; + /** + * Returns an extension of specified type + * @param type Extension type + * @returns Extension or null + */ + getExtension(type: new (raw: BufferSource) => T): T | null; + /** + * Returns a list of extensions of specified type + * @param type Extension identifier + */ + getExtensions(type: string): T[]; + /** + * Returns a list of extensions of specified type + * @param type Extension type + */ + getExtensions(type: new (raw: BufferSource) => T): T[]; + /** + * Validates a certificate signature + * @param params Verification parameters + * @param crypto Crypto provider. Default is from CryptoProvider + */ + verify(params?: X509CertificateVerifyParams, crypto?: Crypto): Promise; + /** + * Returns a SHA-1 certificate thumbprint + * @param crypto Crypto provider. Default is from CryptoProvider + */ + getThumbprint(crypto?: Crypto): Promise; + /** + * Returns a certificate thumbprint for specified mechanism + * @param algorithm Hash algorithm + * @param crypto Crypto provider. Default is from CryptoProvider + */ + getThumbprint(algorithm: globalThis.AlgorithmIdentifier, crypto?: Crypto): Promise; + isSelfSigned(crypto?: Crypto): Promise; + toTextObject(): TextObject; +} + +type X509CertificatesExportType = AsnExportType | "pem-chain"; +/** + * X509 Certificate collection + */ +declare class X509Certificates extends Array implements TextObjectConvertible { + /** + * Creates a new instance + */ + constructor(); + /** + * Creates a new instance from encoded PKCS7 buffer + * @param raw Encoded PKCS7 buffer. Supported formats are DER, PEM, HEX, Base64, or Base64Url + */ + constructor(raw: AsnEncodedType); + /** + * Creates a new instance form X509 certificate + * @param cert X509 certificate + */ + constructor(cert: X509Certificate); + /** + * Creates a new instance from a list of x509 certificates + * @param certs List of x509 certificates + */ + constructor(certs: X509Certificate[]); + /** + * Returns encoded object in PEM format + */ + export(): string; + /** + * Returns encoded object in DER format + * @param format `der` format + */ + export(format: "raw"): ArrayBuffer; + /** + * Returns encoded object in selected format + * @param format `hex`, `base64`, `base64url`, `pem`. Default is `pem` + */ + export(format?: AsnExportType): string; + /** + * Import certificates from encoded PKCS7 data. Supported formats are HEX, DER, + * Base64, Base64Url, PEM + * @param data + */ + import(data: AsnEncodedType): void; + /** + * Removes all items from collection + */ + clear(): void; + toString(format?: X509CertificatesExportType): string; + toTextObject(): TextObject; +} + +interface X509ChainBuilderParams { + certificates?: X509Certificate[]; +} +/** + * Represents a chain-building engine for X509Certificate certificates + * @example + * ```js + * const chain = new x509.X509ChainBuilder({ + * certificates: [ + * new x509.X509Certificate(raw1), + * new x509.X509Certificate(raw2), + * // ... + * new x509.X509Certificate(rawN), + * ], + * }); + * + * const cert = x509.X509Certificate(raw); + * const items = await chain.build(cert); + * ``` + */ +declare class X509ChainBuilder { + certificates: X509Certificate[]; + constructor(params?: X509ChainBuilderParams); + build(cert: X509Certificate, crypto?: Crypto): Promise; + private findIssuer; +} + +type X509CertificateCreateParamsName = string | JsonName | Name; +/** + * Base arguments for certificate creation + */ +interface X509CertificateCreateParamsBase { + /** + * Hexadecimal serial number. If not specified, random value will be generated + */ + serialNumber?: string; + /** + * Date before which certificate can't be used. Default is current date + */ + notBefore?: Date; + /** + * Date after which certificate can't be used. Default is 1 year from now + */ + notAfter?: Date; + /** + * List of extensions + */ + extensions?: Extension[]; + /** + * Signing algorithm. Default is SHA-256 with key algorithm + */ + signingAlgorithm?: Algorithm | EcdsaParams; +} +/** + * Common parameters for X509 Certificate generation + */ +interface X509CertificateCreateCommonParams extends X509CertificateCreateParamsBase { + subject?: X509CertificateCreateParamsName; + issuer?: X509CertificateCreateParamsName; +} +/** + * Parameters for X509 Certificate generation with private key + */ +interface X509CertificateCreateWithKeyParams extends X509CertificateCreateCommonParams { + publicKey: PublicKeyType; + signingKey: CryptoKey; +} +/** + * Parameters for X509 Certificate generation with existing signature value + */ +interface X509CertificateCreateWithSignatureParams extends X509CertificateCreateCommonParams { + /** + * Signature for manually initialized certificates + */ + signature: BufferSource$1; + /** + * Manual signing requires CryptoKey that includes signature algorithm + */ + publicKey: PublicKeyType; +} +type X509CertificateCreateParams = X509CertificateCreateWithKeyParams | X509CertificateCreateWithSignatureParams; +/** + * Parameters for self-signed X509 Certificate generation + */ +interface X509CertificateCreateSelfSignedParams extends X509CertificateCreateParamsBase { + name?: X509CertificateCreateParamsName; + keys: CryptoKeyPair; +} +/** + * Generator of X509 certificates + */ +declare class X509CertificateGenerator { + /** + * Creates a self-signed certificate + * @param params Parameters + * @param crypto Crypto provider. Default is from CryptoProvider + */ + static createSelfSigned(params: X509CertificateCreateSelfSignedParams, crypto?: Crypto): Promise; + /** + * Creates a certificate signed by private key + * @param params Parameters + * @param crypto Crypto provider. Default is from CryptoProvider + */ + static create(params: X509CertificateCreateParams, crypto?: Crypto): Promise; +} + +/** + * Reason Code + * The reasonCode is a non-critical CRL entry extension that identifies + * the reason for the certificate revocation. + */ +declare enum X509CrlReason { + unspecified = 0, + keyCompromise = 1, + cACompromise = 2, + affiliationChanged = 3, + superseded = 4, + cessationOfOperation = 5, + certificateHold = 6, + removeFromCRL = 8, + privilegeWithdrawn = 9, + aACompromise = 10 +} +/** + * Representation of X509CrlEntry + */ +declare class X509CrlEntry extends AsnData { + #private; + /** + * Gets a hexadecimal string of the serial number, the userCertificate + */ + get serialNumber(): string; + /** + * Gets the revocation date + */ + get revocationDate(): Date; + /** + * Gets the reason code + */ + get reason(): X509CrlReason | undefined; + /** + * Gets the invalidity Date + * The invalidity date is a non-critical CRL entry extension that + * provides the date on which it is known or suspected that the private + * key was compromised or that the certificate otherwise became invalid. + */ + get invalidity(): Date | undefined; + /** + * Gets crl entry extensions + */ + get extensions(): Extension[]; + /** + * Creates a new instance from DER encoded Buffer + * @param raw DER encoded buffer + */ + constructor(raw: BufferSource); + /** + * Creates a new instance from ASN.1 object + * @param asn ASN.1 object + */ + constructor(asn: RevokedCertificate); + /** + * Creates a new instance + * @param serialNumber Serial number of certificate + * @param revocationDate Revocation date + * @param extensions List of crl extensions + */ + constructor(serialNumber: string, revocationDate: Date, extensions: Extension[]); + protected onInit(_asn: RevokedCertificate): void; +} + +interface X509CrlVerifyParams { + publicKey: CryptoKey | PublicKey | X509Certificate; +} +/** + * Representation of X.509 Certificate Revocation List (CRL) + */ +declare class X509Crl extends PemData { + #private; + protected readonly tag: string; + /** + * Gets a version + */ + get version(): Version | undefined; + /** + * Gets a signature algorithm + */ + get signatureAlgorithm(): HashedAlgorithm; + /** + * Gets a signature + */ + get signature(): ArrayBuffer; + /** + * Gets a string issuer name + */ + get issuer(): string; + /** + * Gets the issuer value from the crl as an Name + */ + get issuerName(): Name; + /** + * Gets a thisUpdate date from the CRL + */ + get thisUpdate(): Date; + /** + * Gets a nextUpdate date from the CRL + */ + get nextUpdate(): Date | undefined; + /** + * Gets a crlEntries from the CRL + * + * @remarks + * Reading this property parses all revoked certificates, which can be slow for large CRLs. + * Use findRevoked() for efficient searching of specific certificates. + */ + get entries(): readonly X509CrlEntry[]; + /** + * Gets a list of crl extensions + */ + get extensions(): Extension[]; + /** + * Gets the ToBeSigned block + */ + private get tbs(); + /** + * Gets the signature algorithm from tbsCertList + */ + private get tbsCertListSignatureAlgorithm(); + /** + * Gets the signature algorithm from CertificateList + */ + private get certListSignatureAlgorithm(); + /** + * Creates a new instance from ASN.1 CertificateList object + * @param asn ASN.1 CertificateList object + */ + constructor(asn: CertificateList); + /** + * Creates a new instance + * @param raw Encoded buffer (DER, PEM, HEX, Base64, Base64Url) + */ + constructor(raw: AsnEncodedType); + protected onInit(_asn: CertificateList): void; + /** + * Returns an extension of specified type + * @param type Extension identifier + * @returns Extension or null + */ + getExtension(type: string): T | null; + /** + * Returns an extension of specified type + * @param type Extension type + * @returns Extension or null + */ + getExtension(type: new (raw: BufferSource) => T): T | null; + /** + * Returns a list of extensions of specified type + * @param type Extension identifier + */ + getExtensions(type: string): T[]; + /** + * Returns a list of extensions of specified type + * @param type Extension type + */ + getExtensions(type: new (raw: BufferSource) => T): T[]; + /** + * Validates a crl signature + * @param params Verification parameters + * @param crypto Crypto provider. Default is from CryptoProvider + */ + verify(params: X509CrlVerifyParams, crypto?: Crypto): Promise; + /** + * Returns a SHA-1 certificate thumbprint + * @param crypto Crypto provider. Default is from CryptoProvider + */ + getThumbprint(crypto?: Crypto): Promise; + /** + * Returns a certificate thumbprint for specified mechanism + * @param algorithm Hash algorithm + * @param crypto Crypto provider. Default is from CryptoProvider + */ + getThumbprint(algorithm: globalThis.AlgorithmIdentifier, crypto?: Crypto): Promise; + /** + * Gets the CRL entry, with the given X509Certificate or certificate serialNumber. + * + * @param certOrSerialNumber certificate | serialNumber + */ + findRevoked(certOrSerialNumber: X509Certificate | string): X509CrlEntry | null; +} + +interface X509CrlEntryParams { + /** + * Hexadecimal serial number + */ + serialNumber: string; + revocationDate?: Date; + reason?: X509CrlReason; + invalidity?: Date; + issuer?: X509CertificateCreateParamsName; + extensions?: Extension[]; +} +/** + * Base arguments for crl creation + */ +interface X509CrlCreateParamsBase { + issuer: X509CertificateCreateParamsName; + thisUpdate?: Date; + /** + * Signing algorithm + */ + signingAlgorithm: Algorithm | EcdsaParams; +} +/** + * Parameters for X509 CRL generation + */ +interface X509CrlCreateParams extends X509CrlCreateParamsBase { + nextUpdate?: Date; + extensions?: Extension[]; + entries?: X509CrlEntryParams[]; + signingKey: CryptoKey; +} +/** + * Generator of X509 crl + */ +declare class X509CrlGenerator { + /** + * Creates a crl signed by private key + * @param params Parameters + * @param crypto Crypto provider. Default is from CryptoProvider + */ + static create(params: X509CrlCreateParams, crypto?: Crypto): Promise; +} + +export { AlgorithmProvider, AsnData, AsnDefaultSignatureFormatter, AsnEcSignatureFormatter, Attribute, AttributeFactory, AuthorityInfoAccessExtension, AuthorityKeyIdentifierExtension, BasicConstraintsExtension, CRLDistributionPointsExtension, CertificatePolicyExtension, ChallengePasswordAttribute, CryptoProvider, DN, DNS, DefaultAlgorithmSerializer, EMAIL, EcAlgorithm, EdAlgorithm, ExtendedKeyUsage, ExtendedKeyUsageExtension, Extension, ExtensionFactory, ExtensionsAttribute, GUID, GeneralName, GeneralNames, IP, IssuerAlternativeNameExtension, KeyUsageFlags, KeyUsagesExtension, Name, NameIdentifier, OidSerializer, PemConverter, PemData, Pkcs10CertificateRequest, Pkcs10CertificateRequestGenerator, PublicKey, REGISTERED_ID, RsaAlgorithm, ShaAlgorithm, SubjectAlternativeNameExtension, SubjectKeyIdentifierExtension, TextConverter, TextObject, UPN, URL, X509Certificate, X509CertificateGenerator, X509Certificates, X509ChainBuilder, X509Crl, X509CrlEntry, X509CrlGenerator, X509CrlReason, cryptoProvider, diAlgorithm, diAlgorithmProvider, diAsnSignatureFormatter, idEd25519, idEd448, idX25519, idX448 }; +export type { AccessItemTypes, AlgorithmSerializer, AsnDataStringFormat, AsnEncodedType, AsnExportType, AuthorityInfoAccessParams, CertificateIdentifier, ExtendedKeyUsageType, GeneralNameType, HashedAlgorithm, IAlgorithm, IAsnSignatureFormatter, IPublicKeyContainer, IdOrName, JsonAttributeAndObjectValue, JsonAttributeAndStringValue, JsonAttributeAndValue, JsonAttributeObject, JsonGeneralName, JsonGeneralNames, JsonName, JsonNameParams, MapForEachCallback, PemHeader, PemStruct, PemStructEncodeParams, Pkcs10CertificateRequestCreateParams, Pkcs10CertificateRequestCreateParamsName, PublicKeyType, TextObjectConvertible, TextObjectItemType, UnknownAlgorithm, X509CertificateCreateCommonParams, X509CertificateCreateParams, X509CertificateCreateParamsBase, X509CertificateCreateParamsName, X509CertificateCreateSelfSignedParams, X509CertificateCreateWithKeyParams, X509CertificateCreateWithSignatureParams, X509CertificateVerifyParams, X509CertificatesExportType, X509ChainBuilderParams, X509CrlCreateParams, X509CrlCreateParamsBase, X509CrlEntryParams, X509CrlVerifyParams }; diff --git a/node_modules/@peculiar/x509/build/x509.cjs.js b/node_modules/@peculiar/x509/build/x509.cjs.js new file mode 100644 index 0000000000000000000000000000000000000000..9b4ad1d8c23c56dbffd1a68702f2eb828a97f25f --- /dev/null +++ b/node_modules/@peculiar/x509/build/x509.cjs.js @@ -0,0 +1,3445 @@ +/*! + * MIT License + * + * Copyright (c) Peculiar Ventures. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +'use strict'; + +require('reflect-metadata'); +var asn1Schema = require('@peculiar/asn1-schema'); +var asn1X509 = require('@peculiar/asn1-x509'); +var pvtsutils = require('pvtsutils'); +var tslib = require('tslib'); +var asn1Cms = require('@peculiar/asn1-cms'); +var asn1Ecc = require('@peculiar/asn1-ecc'); +var asn1Rsa = require('@peculiar/asn1-rsa'); +var tsyringe = require('tsyringe'); +var asnPkcs9 = require('@peculiar/asn1-pkcs9'); +var asn1Csr = require('@peculiar/asn1-csr'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var asn1X509__namespace = /*#__PURE__*/_interopNamespaceDefault(asn1X509); +var asn1Cms__namespace = /*#__PURE__*/_interopNamespaceDefault(asn1Cms); +var asn1Ecc__namespace = /*#__PURE__*/_interopNamespaceDefault(asn1Ecc); +var asn1Rsa__namespace = /*#__PURE__*/_interopNamespaceDefault(asn1Rsa); +var asnPkcs9__namespace = /*#__PURE__*/_interopNamespaceDefault(asnPkcs9); + +const diAlgorithm = "crypto.algorithm"; +class AlgorithmProvider { + getAlgorithms() { + return tsyringe.container.resolveAll(diAlgorithm); + } + toAsnAlgorithm(alg) { + ({ ...alg }); + for (const algorithm of this.getAlgorithms()) { + const res = algorithm.toAsnAlgorithm(alg); + if (res) { + return res; + } + } + if (/^[0-9.]+$/.test(alg.name)) { + const res = new asn1X509.AlgorithmIdentifier({ algorithm: alg.name }); + if ("parameters" in alg) { + const unknown = alg; + res.parameters = unknown.parameters; + } + return res; + } + throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm"); + } + toWebAlgorithm(alg) { + for (const algorithm of this.getAlgorithms()) { + const res = algorithm.toWebAlgorithm(alg); + if (res) { + return res; + } + } + const unknown = { + name: alg.algorithm, + parameters: alg.parameters, + }; + return unknown; + } +} +const diAlgorithmProvider = "crypto.algorithmProvider"; +tsyringe.container.registerSingleton(diAlgorithmProvider, AlgorithmProvider); + +var EcAlgorithm_1; +const idVersionOne = "1.3.36.3.3.2.8.1.1"; +const idBrainpoolP160r1 = `${idVersionOne}.1`; +const idBrainpoolP160t1 = `${idVersionOne}.2`; +const idBrainpoolP192r1 = `${idVersionOne}.3`; +const idBrainpoolP192t1 = `${idVersionOne}.4`; +const idBrainpoolP224r1 = `${idVersionOne}.5`; +const idBrainpoolP224t1 = `${idVersionOne}.6`; +const idBrainpoolP256r1 = `${idVersionOne}.7`; +const idBrainpoolP256t1 = `${idVersionOne}.8`; +const idBrainpoolP320r1 = `${idVersionOne}.9`; +const idBrainpoolP320t1 = `${idVersionOne}.10`; +const idBrainpoolP384r1 = `${idVersionOne}.11`; +const idBrainpoolP384t1 = `${idVersionOne}.12`; +const idBrainpoolP512r1 = `${idVersionOne}.13`; +const idBrainpoolP512t1 = `${idVersionOne}.14`; +const brainpoolP160r1 = "brainpoolP160r1"; +const brainpoolP160t1 = "brainpoolP160t1"; +const brainpoolP192r1 = "brainpoolP192r1"; +const brainpoolP192t1 = "brainpoolP192t1"; +const brainpoolP224r1 = "brainpoolP224r1"; +const brainpoolP224t1 = "brainpoolP224t1"; +const brainpoolP256r1 = "brainpoolP256r1"; +const brainpoolP256t1 = "brainpoolP256t1"; +const brainpoolP320r1 = "brainpoolP320r1"; +const brainpoolP320t1 = "brainpoolP320t1"; +const brainpoolP384r1 = "brainpoolP384r1"; +const brainpoolP384t1 = "brainpoolP384t1"; +const brainpoolP512r1 = "brainpoolP512r1"; +const brainpoolP512t1 = "brainpoolP512t1"; +const ECDSA = "ECDSA"; +exports.EcAlgorithm = EcAlgorithm_1 = class EcAlgorithm { + toAsnAlgorithm(alg) { + switch (alg.name.toLowerCase()) { + case ECDSA.toLowerCase(): + if ("hash" in alg) { + const hash = typeof alg.hash === "string" ? alg.hash : alg.hash.name; + switch (hash.toLowerCase()) { + case "sha-1": + return asn1Ecc__namespace.ecdsaWithSHA1; + case "sha-256": + return asn1Ecc__namespace.ecdsaWithSHA256; + case "sha-384": + return asn1Ecc__namespace.ecdsaWithSHA384; + case "sha-512": + return asn1Ecc__namespace.ecdsaWithSHA512; + } + } + else if ("namedCurve" in alg) { + let parameters = ""; + switch (alg.namedCurve) { + case "P-256": + parameters = asn1Ecc__namespace.id_secp256r1; + break; + case "K-256": + parameters = EcAlgorithm_1.SECP256K1; + break; + case "P-384": + parameters = asn1Ecc__namespace.id_secp384r1; + break; + case "P-521": + parameters = asn1Ecc__namespace.id_secp521r1; + break; + case brainpoolP160r1: + parameters = idBrainpoolP160r1; + break; + case brainpoolP160t1: + parameters = idBrainpoolP160t1; + break; + case brainpoolP192r1: + parameters = idBrainpoolP192r1; + break; + case brainpoolP192t1: + parameters = idBrainpoolP192t1; + break; + case brainpoolP224r1: + parameters = idBrainpoolP224r1; + break; + case brainpoolP224t1: + parameters = idBrainpoolP224t1; + break; + case brainpoolP256r1: + parameters = idBrainpoolP256r1; + break; + case brainpoolP256t1: + parameters = idBrainpoolP256t1; + break; + case brainpoolP320r1: + parameters = idBrainpoolP320r1; + break; + case brainpoolP320t1: + parameters = idBrainpoolP320t1; + break; + case brainpoolP384r1: + parameters = idBrainpoolP384r1; + break; + case brainpoolP384t1: + parameters = idBrainpoolP384t1; + break; + case brainpoolP512r1: + parameters = idBrainpoolP512r1; + break; + case brainpoolP512t1: + parameters = idBrainpoolP512t1; + break; + } + if (parameters) { + return new asn1X509.AlgorithmIdentifier({ + algorithm: asn1Ecc__namespace.id_ecPublicKey, + parameters: asn1Schema.AsnConvert.serialize(new asn1Ecc__namespace.ECParameters({ namedCurve: parameters })), + }); + } + } + } + return null; + } + toWebAlgorithm(alg) { + switch (alg.algorithm) { + case asn1Ecc__namespace.id_ecdsaWithSHA1: + return { + name: ECDSA, hash: { name: "SHA-1" }, + }; + case asn1Ecc__namespace.id_ecdsaWithSHA256: + return { + name: ECDSA, hash: { name: "SHA-256" }, + }; + case asn1Ecc__namespace.id_ecdsaWithSHA384: + return { + name: ECDSA, hash: { name: "SHA-384" }, + }; + case asn1Ecc__namespace.id_ecdsaWithSHA512: + return { + name: ECDSA, hash: { name: "SHA-512" }, + }; + case asn1Ecc__namespace.id_ecPublicKey: { + if (!alg.parameters) { + throw new TypeError("Cannot get required parameters from EC algorithm"); + } + const parameters = asn1Schema.AsnConvert.parse(alg.parameters, asn1Ecc__namespace.ECParameters); + switch (parameters.namedCurve) { + case asn1Ecc__namespace.id_secp256r1: + return { + name: ECDSA, namedCurve: "P-256", + }; + case EcAlgorithm_1.SECP256K1: + return { + name: ECDSA, namedCurve: "K-256", + }; + case asn1Ecc__namespace.id_secp384r1: + return { + name: ECDSA, namedCurve: "P-384", + }; + case asn1Ecc__namespace.id_secp521r1: + return { + name: ECDSA, namedCurve: "P-521", + }; + case idBrainpoolP160r1: + return { + name: ECDSA, namedCurve: brainpoolP160r1, + }; + case idBrainpoolP160t1: + return { + name: ECDSA, namedCurve: brainpoolP160t1, + }; + case idBrainpoolP192r1: + return { + name: ECDSA, namedCurve: brainpoolP192r1, + }; + case idBrainpoolP192t1: + return { + name: ECDSA, namedCurve: brainpoolP192t1, + }; + case idBrainpoolP224r1: + return { + name: ECDSA, namedCurve: brainpoolP224r1, + }; + case idBrainpoolP224t1: + return { + name: ECDSA, namedCurve: brainpoolP224t1, + }; + case idBrainpoolP256r1: + return { + name: ECDSA, namedCurve: brainpoolP256r1, + }; + case idBrainpoolP256t1: + return { + name: ECDSA, namedCurve: brainpoolP256t1, + }; + case idBrainpoolP320r1: + return { + name: ECDSA, namedCurve: brainpoolP320r1, + }; + case idBrainpoolP320t1: + return { + name: ECDSA, namedCurve: brainpoolP320t1, + }; + case idBrainpoolP384r1: + return { + name: ECDSA, namedCurve: brainpoolP384r1, + }; + case idBrainpoolP384t1: + return { + name: ECDSA, namedCurve: brainpoolP384t1, + }; + case idBrainpoolP512r1: + return { + name: ECDSA, namedCurve: brainpoolP512r1, + }; + case idBrainpoolP512t1: + return { + name: ECDSA, namedCurve: brainpoolP512t1, + }; + } + } + } + return null; + } +}; +exports.EcAlgorithm.SECP256K1 = "1.3.132.0.10"; +exports.EcAlgorithm = EcAlgorithm_1 = tslib.__decorate([ + tsyringe.injectable() +], exports.EcAlgorithm); +tsyringe.container.registerSingleton(diAlgorithm, exports.EcAlgorithm); + +const NAME = Symbol("name"); +const VALUE = Symbol("value"); +class TextObject { + constructor(name, items = {}, value = "") { + this[NAME] = name; + this[VALUE] = value; + for (const key in items) { + this[key] = items[key]; + } + } +} +TextObject.NAME = NAME; +TextObject.VALUE = VALUE; +class DefaultAlgorithmSerializer { + static toTextObject(alg) { + const obj = new TextObject("Algorithm Identifier", {}, OidSerializer.toString(alg.algorithm)); + if (alg.parameters) { + switch (alg.algorithm) { + case asn1Ecc__namespace.id_ecPublicKey: { + const ecAlg = new exports.EcAlgorithm().toWebAlgorithm(alg); + if (ecAlg && "namedCurve" in ecAlg) { + obj["Named Curve"] = ecAlg.namedCurve; + } + else { + obj["Parameters"] = alg.parameters; + } + break; + } + default: + obj["Parameters"] = alg.parameters; + } + } + return obj; + } +} +class OidSerializer { + static toString(oid) { + const name = this.items[oid]; + if (name) { + return name; + } + return oid; + } +} +OidSerializer.items = { + [asn1Rsa__namespace.id_sha1]: "sha1", + [asn1Rsa__namespace.id_sha224]: "sha224", + [asn1Rsa__namespace.id_sha256]: "sha256", + [asn1Rsa__namespace.id_sha384]: "sha384", + [asn1Rsa__namespace.id_sha512]: "sha512", + [asn1Rsa__namespace.id_rsaEncryption]: "rsaEncryption", + [asn1Rsa__namespace.id_sha1WithRSAEncryption]: "sha1WithRSAEncryption", + [asn1Rsa__namespace.id_sha224WithRSAEncryption]: "sha224WithRSAEncryption", + [asn1Rsa__namespace.id_sha256WithRSAEncryption]: "sha256WithRSAEncryption", + [asn1Rsa__namespace.id_sha384WithRSAEncryption]: "sha384WithRSAEncryption", + [asn1Rsa__namespace.id_sha512WithRSAEncryption]: "sha512WithRSAEncryption", + [asn1Ecc__namespace.id_ecPublicKey]: "ecPublicKey", + [asn1Ecc__namespace.id_ecdsaWithSHA1]: "ecdsaWithSHA1", + [asn1Ecc__namespace.id_ecdsaWithSHA224]: "ecdsaWithSHA224", + [asn1Ecc__namespace.id_ecdsaWithSHA256]: "ecdsaWithSHA256", + [asn1Ecc__namespace.id_ecdsaWithSHA384]: "ecdsaWithSHA384", + [asn1Ecc__namespace.id_ecdsaWithSHA512]: "ecdsaWithSHA512", + [asn1X509__namespace.id_kp_serverAuth]: "TLS WWW server authentication", + [asn1X509__namespace.id_kp_clientAuth]: "TLS WWW client authentication", + [asn1X509__namespace.id_kp_codeSigning]: "Code Signing", + [asn1X509__namespace.id_kp_emailProtection]: "E-mail Protection", + [asn1X509__namespace.id_kp_timeStamping]: "Time Stamping", + [asn1X509__namespace.id_kp_OCSPSigning]: "OCSP Signing", + [asn1Cms__namespace.id_signedData]: "Signed Data", +}; +class TextConverter { + static serialize(obj) { + return this.serializeObj(obj).join("\n"); + } + static pad(deep = 0) { + return "".padStart(2 * deep, " "); + } + static serializeObj(obj, deep = 0) { + const res = []; + let pad = this.pad(deep++); + let value = ""; + const objValue = obj[TextObject.VALUE]; + if (objValue) { + value = ` ${objValue}`; + } + res.push(`${pad}${obj[TextObject.NAME]}:${value}`); + pad = this.pad(deep); + for (const key in obj) { + if (typeof key === "symbol") { + continue; + } + const value = obj[key]; + const keyValue = key ? `${key}: ` : ""; + if (typeof value === "string" + || typeof value === "number" + || typeof value === "boolean") { + res.push(`${pad}${keyValue}${value}`); + } + else if (value instanceof Date) { + res.push(`${pad}${keyValue}${value.toUTCString()}`); + } + else if (Array.isArray(value)) { + for (const obj of value) { + obj[TextObject.NAME] = key; + res.push(...this.serializeObj(obj, deep)); + } + } + else if (value instanceof TextObject) { + value[TextObject.NAME] = key; + res.push(...this.serializeObj(value, deep)); + } + else if (pvtsutils.BufferSourceConverter.isBufferSource(value)) { + if (key) { + res.push(`${pad}${keyValue}`); + res.push(...this.serializeBufferSource(value, deep + 1)); + } + else { + res.push(...this.serializeBufferSource(value, deep)); + } + } + else if ("toTextObject" in value) { + const obj = value.toTextObject(); + obj[TextObject.NAME] = key; + res.push(...this.serializeObj(obj, deep)); + } + else { + throw new TypeError("Cannot serialize data in text format. Unsupported type."); + } + } + return res; + } + static serializeBufferSource(buffer, deep = 0) { + const pad = this.pad(deep); + const view = pvtsutils.BufferSourceConverter.toUint8Array(buffer); + const res = []; + for (let i = 0; i < view.length;) { + const row = []; + for (let j = 0; j < 16 && i < view.length; j++) { + if (j === 8) { + row.push(""); + } + const hex = view[i++].toString(16).padStart(2, "0"); + row.push(hex); + } + res.push(`${pad}${row.join(" ")}`); + } + return res; + } + static serializeAlgorithm(alg) { + return this.algorithmSerializer.toTextObject(alg); + } +} +TextConverter.oidSerializer = OidSerializer; +TextConverter.algorithmSerializer = DefaultAlgorithmSerializer; + +var _AsnData_rawData; +class AsnData { + get rawData() { + if (!tslib.__classPrivateFieldGet(this, _AsnData_rawData, "f")) { + tslib.__classPrivateFieldSet(this, _AsnData_rawData, asn1Schema.AsnConvert.serialize(this.asn), "f"); + } + return tslib.__classPrivateFieldGet(this, _AsnData_rawData, "f"); + } + constructor(...args) { + _AsnData_rawData.set(this, void 0); + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + this.asn = asn1Schema.AsnConvert.parse(args[0], args[1]); + tslib.__classPrivateFieldSet(this, _AsnData_rawData, pvtsutils.BufferSourceConverter.toArrayBuffer(args[0]), "f"); + this.onInit(this.asn); + } + else { + this.asn = args[0]; + this.onInit(this.asn); + } + } + equal(data) { + if (data instanceof AsnData) { + return pvtsutils.isEqual(data.rawData, this.rawData); + } + return false; + } + toString(format = "text") { + switch (format) { + case "asn": + return asn1Schema.AsnConvert.toString(this.rawData); + case "text": + return TextConverter.serialize(this.toTextObject()); + case "hex": + return pvtsutils.Convert.ToHex(this.rawData); + case "base64": + return pvtsutils.Convert.ToBase64(this.rawData); + case "base64url": + return pvtsutils.Convert.ToBase64Url(this.rawData); + default: + throw TypeError("Argument 'format' is unsupported value"); + } + } + getTextName() { + const constructor = this.constructor; + return constructor.NAME; + } + toTextObject() { + const obj = this.toTextObjectEmpty(); + obj[""] = this.rawData; + return obj; + } + toTextObjectEmpty(value) { + return new TextObject(this.getTextName(), {}, value); + } +} +_AsnData_rawData = new WeakMap(); +AsnData.NAME = "ASN"; + +class Extension extends AsnData { + constructor(...args) { + let raw; + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + raw = pvtsutils.BufferSourceConverter.toArrayBuffer(args[0]); + } + else { + raw = asn1Schema.AsnConvert.serialize(new asn1X509.Extension({ + extnID: args[0], + critical: args[1], + extnValue: new asn1Schema.OctetString(pvtsutils.BufferSourceConverter.toArrayBuffer(args[2])), + })); + } + super(raw, asn1X509.Extension); + } + onInit(asn) { + this.type = asn.extnID; + this.critical = asn.critical; + this.value = asn.extnValue.buffer; + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj[""] = this.value; + return obj; + } + toTextObjectWithoutValue() { + const obj = this.toTextObjectEmpty(this.critical ? "critical" : undefined); + if (obj[TextObject.NAME] === Extension.NAME) { + obj[TextObject.NAME] = OidSerializer.toString(this.type); + } + return obj; + } +} + +var _a; +class CryptoProvider { + static isCryptoKeyPair(data) { + return data && data.privateKey && data.publicKey; + } + static isCryptoKey(data) { + return data && data.usages && data.type && data.algorithm && data.extractable !== undefined; + } + constructor() { + this.items = new Map(); + this[_a] = "CryptoProvider"; + if (typeof self !== "undefined" && typeof crypto !== "undefined") { + this.set(CryptoProvider.DEFAULT, crypto); + } + else if (typeof global !== "undefined" && global.crypto && global.crypto.subtle) { + this.set(CryptoProvider.DEFAULT, global.crypto); + } + } + clear() { + this.items.clear(); + } + delete(key) { + return this.items.delete(key); + } + forEach(callbackfn, thisArg) { + return this.items.forEach(callbackfn, thisArg); + } + has(key) { + return this.items.has(key); + } + get size() { + return this.items.size; + } + entries() { + return this.items.entries(); + } + keys() { + return this.items.keys(); + } + values() { + return this.items.values(); + } + [Symbol.iterator]() { + return this.items[Symbol.iterator](); + } + get(key = CryptoProvider.DEFAULT) { + const crypto = this.items.get(key.toLowerCase()); + if (!crypto) { + throw new Error(`Cannot get Crypto by name '${key}'`); + } + return crypto; + } + set(key, value) { + if (typeof key === "string") { + if (!value) { + throw new TypeError("Argument 'value' is required"); + } + this.items.set(key.toLowerCase(), value); + } + else { + this.items.set(CryptoProvider.DEFAULT, key); + } + return this; + } +} +_a = Symbol.toStringTag; +CryptoProvider.DEFAULT = "default"; +const cryptoProvider = new CryptoProvider(); + +const OID_REGEX = /^[0-2](?:\.[1-9][0-9]*)+$/; +function isOID(id) { + return new RegExp(OID_REGEX).test(id); +} +class NameIdentifier { + constructor(names = {}) { + this.items = {}; + for (const id in names) { + this.register(id, names[id]); + } + } + get(idOrName) { + return this.items[idOrName] || null; + } + findId(idOrName) { + if (!isOID(idOrName)) { + return this.get(idOrName); + } + return idOrName; + } + register(id, name) { + this.items[id] = name; + this.items[name] = id; + } +} +const names = new NameIdentifier(); +names.register("CN", "2.5.4.3"); +names.register("L", "2.5.4.7"); +names.register("ST", "2.5.4.8"); +names.register("O", "2.5.4.10"); +names.register("OU", "2.5.4.11"); +names.register("C", "2.5.4.6"); +names.register("DC", "0.9.2342.19200300.100.1.25"); +names.register("E", "1.2.840.113549.1.9.1"); +names.register("G", "2.5.4.42"); +names.register("I", "2.5.4.43"); +names.register("SN", "2.5.4.4"); +names.register("T", "2.5.4.12"); +function replaceUnknownCharacter(text, char) { + return `\\${pvtsutils.Convert.ToHex(pvtsutils.Convert.FromUtf8String(char)).toUpperCase()}`; +} +function escape(data) { + return data + .replace(/([,+"\\<>;])/g, "\\$1") + .replace(/^([ #])/, "\\$1") + .replace(/([ ]$)/, "\\$1") + .replace(/([\r\n\t])/, replaceUnknownCharacter); +} +class Name { + static isASCII(text) { + for (let i = 0; i < text.length; i++) { + const code = text.charCodeAt(i); + if (code > 0xFF) { + return false; + } + } + return true; + } + static isPrintableString(text) { + return /^[A-Za-z0-9 '()+,-./:=?]*$/g.test(text); + } + constructor(data, extraNames = {}) { + this.extraNames = new NameIdentifier(); + this.asn = new asn1X509.Name(); + for (const key in extraNames) { + if (Object.prototype.hasOwnProperty.call(extraNames, key)) { + const value = extraNames[key]; + this.extraNames.register(key, value); + } + } + if (typeof data === "string") { + this.asn = this.fromString(data); + } + else if (data instanceof asn1X509.Name) { + this.asn = data; + } + else if (pvtsutils.BufferSourceConverter.isBufferSource(data)) { + this.asn = asn1Schema.AsnConvert.parse(data, asn1X509.Name); + } + else { + this.asn = this.fromJSON(data); + } + } + getField(idOrName) { + const id = this.extraNames.findId(idOrName) || names.findId(idOrName); + const res = []; + for (const name of this.asn) { + for (const rdn of name) { + if (rdn.type === id) { + res.push(rdn.value.toString()); + } + } + } + return res; + } + getName(idOrName) { + return this.extraNames.get(idOrName) || names.get(idOrName); + } + toString() { + return this.asn.map((rdn) => rdn.map((o) => { + const type = this.getName(o.type) || o.type; + const value = o.value.anyValue + ? `#${pvtsutils.Convert.ToHex(o.value.anyValue)}` + : escape(o.value.toString()); + return `${type}=${value}`; + }) + .join("+")) + .join(", "); + } + toJSON() { + var _a; + const json = []; + for (const rdn of this.asn) { + const jsonItem = {}; + for (const attr of rdn) { + const type = this.getName(attr.type) || attr.type; + (_a = jsonItem[type]) !== null && _a !== void 0 ? _a : (jsonItem[type] = []); + jsonItem[type].push(attr.value.anyValue ? `#${pvtsutils.Convert.ToHex(attr.value.anyValue)}` : attr.value.toString()); + } + json.push(jsonItem); + } + return json; + } + fromString(data) { + const asn = new asn1X509.Name(); + const regex = /(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+"\\](?=[,+]|$))|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g; + let matches = null; + let level = ","; + while (matches = regex.exec(`${data},`)) { + let [, type, value] = matches; + const lastChar = value[value.length - 1]; + if (lastChar === "," || lastChar === "+") { + value = value.slice(0, value.length - 1); + matches[3] = lastChar; + } + const next = matches[3]; + type = this.getTypeOid(type); + const attr = this.createAttribute(type, value); + if (level === "+") { + asn[asn.length - 1].push(attr); + } + else { + asn.push(new asn1X509.RelativeDistinguishedName([attr])); + } + level = next; + } + return asn; + } + fromJSON(data) { + const asn = new asn1X509.Name(); + for (const item of data) { + const asnRdn = new asn1X509.RelativeDistinguishedName(); + for (const type in item) { + const typeId = this.getTypeOid(type); + const values = item[type]; + for (const value of values) { + const asnAttr = this.createAttribute(typeId, value); + asnRdn.push(asnAttr); + } + } + asn.push(asnRdn); + } + return asn; + } + getTypeOid(type) { + if (!/[\d.]+/.test(type)) { + type = this.getName(type) || ""; + } + if (!type) { + throw new Error(`Cannot get OID for name type '${type}'`); + } + return type; + } + createAttribute(type, value) { + const attr = new asn1X509.AttributeTypeAndValue({ type }); + if (typeof value === "object") { + for (const key in value) { + switch (key) { + case "ia5String": + attr.value.ia5String = value[key]; + break; + case "utf8String": + attr.value.utf8String = value[key]; + break; + case "universalString": + attr.value.universalString = value[key]; + break; + case "bmpString": + attr.value.bmpString = value[key]; + break; + case "printableString": + attr.value.printableString = value[key]; + break; + } + } + } + else if (value[0] === "#") { + attr.value.anyValue = pvtsutils.Convert.FromHex(value.slice(1)); + } + else { + const processedValue = this.processStringValue(value); + if (type === this.getName("E") || type === this.getName("DC")) { + attr.value.ia5String = processedValue; + } + else { + if (Name.isPrintableString(processedValue)) { + attr.value.printableString = processedValue; + } + else { + attr.value.utf8String = processedValue; + } + } + } + return attr; + } + processStringValue(value) { + const quotedMatches = /"(.*?[^\\])?"/.exec(value); + if (quotedMatches) { + value = quotedMatches[1]; + } + return value + .replace(/\\0a/ig, "\n") + .replace(/\\0d/ig, "\r") + .replace(/\\0g/ig, "\t") + .replace(/\\(.)/g, "$1"); + } + toArrayBuffer() { + return asn1Schema.AsnConvert.serialize(this.asn); + } + async getThumbprint(...args) { + var _a; + let crypto; + let algorithm = "SHA-1"; + if (args.length >= 1 && !((_a = args[0]) === null || _a === void 0 ? void 0 : _a.subtle)) { + algorithm = args[0] || algorithm; + crypto = args[1] || cryptoProvider.get(); + } + else { + crypto = args[0] || cryptoProvider.get(); + } + return await crypto.subtle.digest(algorithm, this.toArrayBuffer()); + } +} + +const ERR_GN_CONSTRUCTOR = "Cannot initialize GeneralName from ASN.1 data."; +const ERR_GN_STRING_FORMAT = `${ERR_GN_CONSTRUCTOR} Unsupported string format in use.`; +const ERR_GUID = `${ERR_GN_CONSTRUCTOR} Value doesn't match to GUID regular expression.`; +const GUID_REGEX = /^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i; +const id_GUID = "1.3.6.1.4.1.311.25.1"; +const id_UPN = "1.3.6.1.4.1.311.20.2.3"; +const DNS = "dns"; +const DN = "dn"; +const EMAIL = "email"; +const IP = "ip"; +const URL = "url"; +const GUID = "guid"; +const UPN = "upn"; +const REGISTERED_ID = "id"; +class GeneralName extends AsnData { + constructor(...args) { + let name; + if (args.length === 2) { + switch (args[0]) { + case DN: { + const derName = new Name(args[1]).toArrayBuffer(); + const asnName = asn1Schema.AsnConvert.parse(derName, asn1X509__namespace.Name); + name = new asn1X509__namespace.GeneralName({ directoryName: asnName }); + break; + } + case DNS: + name = new asn1X509__namespace.GeneralName({ dNSName: args[1] }); + break; + case EMAIL: + name = new asn1X509__namespace.GeneralName({ rfc822Name: args[1] }); + break; + case GUID: { + const matches = new RegExp(GUID_REGEX, "i").exec(args[1]); + if (!matches) { + throw new Error("Cannot parse GUID value. Value doesn't match to regular expression"); + } + const hex = matches + .slice(1) + .map((o, i) => { + if (i < 3) { + return pvtsutils.Convert.ToHex(new Uint8Array(pvtsutils.Convert.FromHex(o)).reverse()); + } + return o; + }) + .join(""); + name = new asn1X509__namespace.GeneralName({ + otherName: new asn1X509__namespace.OtherName({ + typeId: id_GUID, + value: asn1Schema.AsnConvert.serialize(new asn1Schema.OctetString(pvtsutils.Convert.FromHex(hex))), + }), + }); + break; + } + case IP: + name = new asn1X509__namespace.GeneralName({ iPAddress: args[1] }); + break; + case REGISTERED_ID: + name = new asn1X509__namespace.GeneralName({ registeredID: args[1] }); + break; + case UPN: { + name = new asn1X509__namespace.GeneralName({ + otherName: new asn1X509__namespace.OtherName({ + typeId: id_UPN, + value: asn1Schema.AsnConvert.serialize(asn1Schema.AsnUtf8StringConverter.toASN(args[1])), + }), + }); + break; + } + case URL: + name = new asn1X509__namespace.GeneralName({ uniformResourceIdentifier: args[1] }); + break; + default: + throw new Error("Cannot create GeneralName. Unsupported type of the name"); + } + } + else if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + name = asn1Schema.AsnConvert.parse(args[0], asn1X509__namespace.GeneralName); + } + else { + name = args[0]; + } + super(name); + } + onInit(asn) { + if (asn.dNSName != undefined) { + this.type = DNS; + this.value = asn.dNSName; + } + else if (asn.rfc822Name != undefined) { + this.type = EMAIL; + this.value = asn.rfc822Name; + } + else if (asn.iPAddress != undefined) { + this.type = IP; + this.value = asn.iPAddress; + } + else if (asn.uniformResourceIdentifier != undefined) { + this.type = URL; + this.value = asn.uniformResourceIdentifier; + } + else if (asn.registeredID != undefined) { + this.type = REGISTERED_ID; + this.value = asn.registeredID; + } + else if (asn.directoryName != undefined) { + this.type = DN; + this.value = new Name(asn.directoryName).toString(); + } + else if (asn.otherName != undefined) { + if (asn.otherName.typeId === id_GUID) { + this.type = GUID; + const guid = asn1Schema.AsnConvert.parse(asn.otherName.value, asn1Schema.OctetString); + const matches = new RegExp(GUID_REGEX, "i").exec(pvtsutils.Convert.ToHex(guid)); + if (!matches) { + throw new Error(ERR_GUID); + } + this.value = matches + .slice(1) + .map((o, i) => { + if (i < 3) { + return pvtsutils.Convert.ToHex(new Uint8Array(pvtsutils.Convert.FromHex(o)).reverse()); + } + return o; + }) + .join("-"); + } + else if (asn.otherName.typeId === id_UPN) { + this.type = UPN; + this.value = asn1Schema.AsnConvert.parse(asn.otherName.value, asn1X509__namespace.DirectoryString).toString(); + } + else { + throw new Error(ERR_GN_STRING_FORMAT); + } + } + else { + throw new Error(ERR_GN_STRING_FORMAT); + } + } + toJSON() { + return { + type: this.type, + value: this.value, + }; + } + toTextObject() { + let type; + switch (this.type) { + case DN: + case DNS: + case GUID: + case IP: + case REGISTERED_ID: + case UPN: + case URL: + type = this.type.toUpperCase(); + break; + case EMAIL: + type = "Email"; + break; + default: + throw new Error("Unsupported GeneralName type"); + } + let value = this.value; + if (this.type === REGISTERED_ID) { + value = OidSerializer.toString(value); + } + return new TextObject(type, undefined, value); + } +} +class GeneralNames extends AsnData { + constructor(params) { + let names; + if (params instanceof asn1X509__namespace.GeneralNames) { + names = params; + } + else if (Array.isArray(params)) { + const items = []; + for (const name of params) { + if (name instanceof asn1X509__namespace.GeneralName) { + items.push(name); + } + else { + const asnName = asn1Schema.AsnConvert.parse(new GeneralName(name.type, name.value).rawData, asn1X509__namespace.GeneralName); + items.push(asnName); + } + } + names = new asn1X509__namespace.GeneralNames(items); + } + else if (pvtsutils.BufferSourceConverter.isBufferSource(params)) { + names = asn1Schema.AsnConvert.parse(params, asn1X509__namespace.GeneralNames); + } + else { + throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments"); + } + super(names); + } + onInit(asn) { + const items = []; + for (const asnName of asn) { + let name = null; + try { + name = new GeneralName(asnName); + } + catch { + continue; + } + items.push(name); + } + this.items = items; + } + toJSON() { + return this.items.map((o) => o.toJSON()); + } + toTextObject() { + const res = super.toTextObjectEmpty(); + for (const name of this.items) { + const nameObj = name.toTextObject(); + let field = res[nameObj[TextObject.NAME]]; + if (!Array.isArray(field)) { + field = []; + res[nameObj[TextObject.NAME]] = field; + } + field.push(nameObj); + } + return res; + } +} +GeneralNames.NAME = "GeneralNames"; + +const rPaddingTag = "-{5}"; +const rEolChars = "\\n"; +const rNameTag = `[^${rEolChars}]+`; +const rBeginTag = `${rPaddingTag}BEGIN (${rNameTag}(?=${rPaddingTag}))${rPaddingTag}`; +const rEndTag = `${rPaddingTag}END \\1${rPaddingTag}`; +const rEolGroup = "\\n"; +const rHeaderKey = `[^:${rEolChars}]+`; +const rHeaderValue = `(?:[^${rEolChars}]+${rEolGroup}(?: +[^${rEolChars}]+${rEolGroup})*)`; +const rBase64Chars = "[a-zA-Z0-9=+/]+"; +const rBase64 = `(?:${rBase64Chars}${rEolGroup})+`; +const rPem = `${rBeginTag}${rEolGroup}(?:((?:${rHeaderKey}: ${rHeaderValue})+))?${rEolGroup}?(${rBase64})${rEndTag}`; +class PemConverter { + static isPem(data) { + return typeof data === "string" + && new RegExp(rPem, "g").test(data.replace(/\r/g, "")); + } + static decodeWithHeaders(pem) { + pem = pem.replace(/\r/g, ""); + const pattern = new RegExp(rPem, "g"); + const res = []; + let matches = null; + while (matches = pattern.exec(pem)) { + const base64 = matches[3] + .replace(new RegExp(`[${rEolChars}]+`, "g"), ""); + const pemStruct = { + type: matches[1], + headers: [], + rawData: pvtsutils.Convert.FromBase64(base64), + }; + const headersString = matches[2]; + if (headersString) { + const headers = headersString.split(new RegExp(rEolGroup, "g")); + let lastHeader = null; + for (const header of headers) { + const [key, value] = header.split(/:(.*)/); + if (value === undefined) { + if (!lastHeader) { + throw new Error("Cannot parse PEM string. Incorrect header value"); + } + lastHeader.value += key.trim(); + } + else { + if (lastHeader) { + pemStruct.headers.push(lastHeader); + } + lastHeader = { + key, value: value.trim(), + }; + } + } + if (lastHeader) { + pemStruct.headers.push(lastHeader); + } + } + res.push(pemStruct); + } + return res; + } + static decode(pem) { + const blocks = this.decodeWithHeaders(pem); + return blocks.map((o) => o.rawData); + } + static decodeFirst(pem) { + const items = this.decode(pem); + if (!items.length) { + throw new RangeError("PEM string doesn't contain any objects"); + } + return items[0]; + } + static encode(rawData, tag) { + if (Array.isArray(rawData)) { + const raws = new Array(); + if (tag) { + rawData.forEach((element) => { + if (!pvtsutils.BufferSourceConverter.isBufferSource(element)) { + throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource"); + } + raws.push(this.encodeStruct({ + type: tag, + rawData: pvtsutils.BufferSourceConverter.toArrayBuffer(element), + })); + }); + } + else { + rawData.forEach((element) => { + if (!("type" in element)) { + throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut"); + } + raws.push(this.encodeStruct(element)); + }); + } + return raws.join("\n"); + } + else { + if (!tag) { + throw new Error("Required argument 'tag' is missed"); + } + return this.encodeStruct({ + type: tag, + rawData: pvtsutils.BufferSourceConverter.toArrayBuffer(rawData), + }); + } + } + static encodeStruct(pem) { + var _a; + const upperCaseType = pem.type.toLocaleUpperCase(); + const res = []; + res.push(`-----BEGIN ${upperCaseType}-----`); + if ((_a = pem.headers) === null || _a === void 0 ? void 0 : _a.length) { + for (const header of pem.headers) { + res.push(`${header.key}: ${header.value}`); + } + res.push(""); + } + const base64 = pvtsutils.Convert.ToBase64(pem.rawData); + let sliced; + let offset = 0; + const rows = Array(); + while (offset < base64.length) { + if (base64.length - offset < 64) { + sliced = base64.substring(offset); + } + else { + sliced = base64.substring(offset, offset + 64); + offset += 64; + } + if (sliced.length !== 0) { + rows.push(sliced); + if (sliced.length < 64) { + break; + } + } + else { + break; + } + } + res.push(...rows); + res.push(`-----END ${upperCaseType}-----`); + return res.join("\n"); + } +} +PemConverter.CertificateTag = "CERTIFICATE"; +PemConverter.CrlTag = "CRL"; +PemConverter.CertificateRequestTag = "CERTIFICATE REQUEST"; +PemConverter.PublicKeyTag = "PUBLIC KEY"; +PemConverter.PrivateKeyTag = "PRIVATE KEY"; + +class PemData extends AsnData { + static isAsnEncoded(data) { + return pvtsutils.BufferSourceConverter.isBufferSource(data) || typeof data === "string"; + } + static toArrayBuffer(raw) { + if (typeof raw === "string") { + if (PemConverter.isPem(raw)) { + return PemConverter.decode(raw)[0]; + } + else if (pvtsutils.Convert.isHex(raw)) { + return pvtsutils.Convert.FromHex(raw); + } + else if (pvtsutils.Convert.isBase64(raw)) { + return pvtsutils.Convert.FromBase64(raw); + } + else if (pvtsutils.Convert.isBase64Url(raw)) { + return pvtsutils.Convert.FromBase64Url(raw); + } + else { + throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url"); + } + } + else { + const buffer = pvtsutils.BufferSourceConverter.toUint8Array(raw); + if (buffer.length > 0 && buffer[0] === 0x30) { + return pvtsutils.BufferSourceConverter.toArrayBuffer(raw); + } + const stringRaw = pvtsutils.Convert.ToBinary(raw); + if (PemConverter.isPem(stringRaw)) { + return PemConverter.decode(stringRaw)[0]; + } + else if (pvtsutils.Convert.isHex(stringRaw)) { + return pvtsutils.Convert.FromHex(stringRaw); + } + else if (pvtsutils.Convert.isBase64(stringRaw)) { + return pvtsutils.Convert.FromBase64(stringRaw); + } + else if (pvtsutils.Convert.isBase64Url(stringRaw)) { + return pvtsutils.Convert.FromBase64Url(stringRaw); + } + throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url"); + } + } + constructor(...args) { + if (PemData.isAsnEncoded(args[0])) { + super(PemData.toArrayBuffer(args[0]), args[1]); + } + else { + super(args[0]); + } + } + toString(format = "pem") { + switch (format) { + case "pem": + return PemConverter.encode(this.rawData, this.tag); + default: + return super.toString(format); + } + } +} + +class PublicKey extends PemData { + static async create(data, crypto = cryptoProvider.get()) { + if (data instanceof PublicKey) { + return data; + } + else if (CryptoProvider.isCryptoKey(data)) { + if (data.type !== "public") { + throw new TypeError("Public key is required"); + } + const spki = await crypto.subtle.exportKey("spki", data); + return new PublicKey(spki); + } + else if (data.publicKey) { + return data.publicKey; + } + else if (pvtsutils.BufferSourceConverter.isBufferSource(data)) { + return new PublicKey(data); + } + else { + throw new TypeError("Unsupported PublicKeyType"); + } + } + constructor(param) { + if (PemData.isAsnEncoded(param)) { + super(param, asn1X509.SubjectPublicKeyInfo); + } + else { + super(param); + } + this.tag = PemConverter.PublicKeyTag; + } + async export(...args) { + let crypto; + let keyUsages = ["verify"]; + let algorithm = { + hash: "SHA-256", ...this.algorithm, + }; + if (args.length > 1) { + algorithm = args[0] || algorithm; + keyUsages = args[1] || keyUsages; + crypto = args[2] || cryptoProvider.get(); + } + else { + crypto = args[0] || cryptoProvider.get(); + } + let raw = this.rawData; + const asnSpki = asn1Schema.AsnConvert.parse(this.rawData, asn1X509.SubjectPublicKeyInfo); + if (asnSpki.algorithm.algorithm === asn1Rsa.id_RSASSA_PSS) { + raw = convertSpkiToRsaPkcs1(asnSpki, raw); + } + return crypto.subtle.importKey("spki", raw, algorithm, true, keyUsages); + } + onInit(asn) { + const algProv = tsyringe.container.resolve(diAlgorithmProvider); + const algorithm = this.algorithm = algProv.toWebAlgorithm(asn.algorithm); + switch (asn.algorithm.algorithm) { + case asn1Rsa.id_rsaEncryption: + { + const rsaPublicKey = asn1Schema.AsnConvert.parse(asn.subjectPublicKey, asn1Rsa.RSAPublicKey); + const modulus = pvtsutils.BufferSourceConverter.toUint8Array(rsaPublicKey.modulus); + algorithm.publicExponent = pvtsutils.BufferSourceConverter.toUint8Array(rsaPublicKey.publicExponent); + algorithm.modulusLength = (!modulus[0] ? modulus.slice(1) : modulus).byteLength << 3; + break; + } + } + } + async getThumbprint(...args) { + var _a; + let crypto; + let algorithm = "SHA-1"; + if (args.length >= 1 && !((_a = args[0]) === null || _a === void 0 ? void 0 : _a.subtle)) { + algorithm = args[0] || algorithm; + crypto = args[1] || cryptoProvider.get(); + } + else { + crypto = args[0] || cryptoProvider.get(); + } + return await crypto.subtle.digest(algorithm, this.rawData); + } + async getKeyIdentifier(...args) { + let crypto; + let algorithm = "SHA-1"; + if (args.length === 1) { + if (typeof args[0] === "string") { + algorithm = args[0]; + crypto = cryptoProvider.get(); + } + else { + crypto = args[0]; + } + } + else if (args.length === 2) { + algorithm = args[0]; + crypto = args[1]; + } + else { + crypto = cryptoProvider.get(); + } + const asn = asn1Schema.AsnConvert.parse(this.rawData, asn1X509.SubjectPublicKeyInfo); + return await crypto.subtle.digest(algorithm, asn.subjectPublicKey); + } + toTextObject() { + const obj = this.toTextObjectEmpty(); + const asn = asn1Schema.AsnConvert.parse(this.rawData, asn1X509.SubjectPublicKeyInfo); + obj["Algorithm"] = TextConverter.serializeAlgorithm(asn.algorithm); + switch (asn.algorithm.algorithm) { + case asn1Ecc.id_ecPublicKey: + obj["EC Point"] = asn.subjectPublicKey; + break; + case asn1Rsa.id_rsaEncryption: + default: + obj["Raw Data"] = asn.subjectPublicKey; + } + return obj; + } +} +function convertSpkiToRsaPkcs1(asnSpki, raw) { + asnSpki.algorithm = new asn1X509.AlgorithmIdentifier({ + algorithm: asn1Rsa.id_rsaEncryption, + parameters: null, + }); + raw = asn1Schema.AsnConvert.serialize(asnSpki); + return raw; +} + +class AuthorityKeyIdentifierExtension extends Extension { + static async create(param, critical = false, crypto = cryptoProvider.get()) { + if ("name" in param && "serialNumber" in param) { + return new AuthorityKeyIdentifierExtension(param, critical); + } + const key = await PublicKey.create(param, crypto); + const id = await key.getKeyIdentifier(crypto); + return new AuthorityKeyIdentifierExtension(pvtsutils.Convert.ToHex(id), critical); + } + constructor(...args) { + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else if (typeof args[0] === "string") { + const value = new asn1X509__namespace.AuthorityKeyIdentifier({ keyIdentifier: new asn1X509__namespace.KeyIdentifier(pvtsutils.Convert.FromHex(args[0])) }); + super(asn1X509__namespace.id_ce_authorityKeyIdentifier, args[1], asn1Schema.AsnConvert.serialize(value)); + } + else { + const certId = args[0]; + const certIdName = certId.name instanceof GeneralNames + ? asn1Schema.AsnConvert.parse(certId.name.rawData, asn1X509__namespace.GeneralNames) + : certId.name; + const value = new asn1X509__namespace.AuthorityKeyIdentifier({ + authorityCertIssuer: certIdName, + authorityCertSerialNumber: pvtsutils.Convert.FromHex(certId.serialNumber), + }); + super(asn1X509__namespace.id_ce_authorityKeyIdentifier, args[1], asn1Schema.AsnConvert.serialize(value)); + } + } + onInit(asn) { + super.onInit(asn); + const aki = asn1Schema.AsnConvert.parse(asn.extnValue, asn1X509__namespace.AuthorityKeyIdentifier); + if (aki.keyIdentifier) { + this.keyId = pvtsutils.Convert.ToHex(aki.keyIdentifier); + } + if (aki.authorityCertIssuer || aki.authorityCertSerialNumber) { + this.certId = { + name: aki.authorityCertIssuer || [], + serialNumber: aki.authorityCertSerialNumber ? pvtsutils.Convert.ToHex(aki.authorityCertSerialNumber) : "", + }; + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const asn = asn1Schema.AsnConvert.parse(this.value, asn1X509__namespace.AuthorityKeyIdentifier); + if (asn.authorityCertIssuer) { + obj["Authority Issuer"] = new GeneralNames(asn.authorityCertIssuer).toTextObject(); + } + if (asn.authorityCertSerialNumber) { + obj["Authority Serial Number"] = asn.authorityCertSerialNumber; + } + if (asn.keyIdentifier) { + obj[""] = asn.keyIdentifier; + } + return obj; + } +} +AuthorityKeyIdentifierExtension.NAME = "Authority Key Identifier"; + +class BasicConstraintsExtension extends Extension { + constructor(...args) { + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + const value = asn1Schema.AsnConvert.parse(this.value, asn1X509.BasicConstraints); + this.ca = value.cA; + this.pathLength = value.pathLenConstraint; + } + else { + const value = new asn1X509.BasicConstraints({ + cA: args[0], + pathLenConstraint: args[1], + }); + super(asn1X509.id_ce_basicConstraints, args[2], asn1Schema.AsnConvert.serialize(value)); + this.ca = args[0]; + this.pathLength = args[1]; + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + if (this.ca) { + obj["CA"] = this.ca; + } + if (this.pathLength !== undefined) { + obj["Path Length"] = this.pathLength; + } + return obj; + } +} +BasicConstraintsExtension.NAME = "Basic Constraints"; + +exports.ExtendedKeyUsage = void 0; +(function (ExtendedKeyUsage) { + ExtendedKeyUsage["serverAuth"] = "1.3.6.1.5.5.7.3.1"; + ExtendedKeyUsage["clientAuth"] = "1.3.6.1.5.5.7.3.2"; + ExtendedKeyUsage["codeSigning"] = "1.3.6.1.5.5.7.3.3"; + ExtendedKeyUsage["emailProtection"] = "1.3.6.1.5.5.7.3.4"; + ExtendedKeyUsage["timeStamping"] = "1.3.6.1.5.5.7.3.8"; + ExtendedKeyUsage["ocspSigning"] = "1.3.6.1.5.5.7.3.9"; +})(exports.ExtendedKeyUsage || (exports.ExtendedKeyUsage = {})); +class ExtendedKeyUsageExtension extends Extension { + constructor(...args) { + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + const value = asn1Schema.AsnConvert.parse(this.value, asn1X509__namespace.ExtendedKeyUsage); + this.usages = value.map((o) => o); + } + else { + const value = new asn1X509__namespace.ExtendedKeyUsage(args[0]); + super(asn1X509__namespace.id_ce_extKeyUsage, args[1], asn1Schema.AsnConvert.serialize(value)); + this.usages = args[0]; + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj[""] = this.usages.map((o) => OidSerializer.toString(o)).join(", "); + return obj; + } +} +ExtendedKeyUsageExtension.NAME = "Extended Key Usages"; + +exports.KeyUsageFlags = void 0; +(function (KeyUsageFlags) { + KeyUsageFlags[KeyUsageFlags["digitalSignature"] = 1] = "digitalSignature"; + KeyUsageFlags[KeyUsageFlags["nonRepudiation"] = 2] = "nonRepudiation"; + KeyUsageFlags[KeyUsageFlags["keyEncipherment"] = 4] = "keyEncipherment"; + KeyUsageFlags[KeyUsageFlags["dataEncipherment"] = 8] = "dataEncipherment"; + KeyUsageFlags[KeyUsageFlags["keyAgreement"] = 16] = "keyAgreement"; + KeyUsageFlags[KeyUsageFlags["keyCertSign"] = 32] = "keyCertSign"; + KeyUsageFlags[KeyUsageFlags["cRLSign"] = 64] = "cRLSign"; + KeyUsageFlags[KeyUsageFlags["encipherOnly"] = 128] = "encipherOnly"; + KeyUsageFlags[KeyUsageFlags["decipherOnly"] = 256] = "decipherOnly"; +})(exports.KeyUsageFlags || (exports.KeyUsageFlags = {})); +class KeyUsagesExtension extends Extension { + constructor(...args) { + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + const value = asn1Schema.AsnConvert.parse(this.value, asn1X509.KeyUsage); + this.usages = value.toNumber(); + } + else { + const value = new asn1X509.KeyUsage(args[0]); + super(asn1X509.id_ce_keyUsage, args[1], asn1Schema.AsnConvert.serialize(value)); + this.usages = args[0]; + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const asn = asn1Schema.AsnConvert.parse(this.value, asn1X509.KeyUsage); + obj[""] = asn.toJSON().join(", "); + return obj; + } +} +KeyUsagesExtension.NAME = "Key Usages"; + +class SubjectKeyIdentifierExtension extends Extension { + static async create(publicKey, critical = false, crypto = cryptoProvider.get()) { + const key = await PublicKey.create(publicKey, crypto); + const id = await key.getKeyIdentifier(crypto); + return new SubjectKeyIdentifierExtension(pvtsutils.Convert.ToHex(id), critical); + } + constructor(...args) { + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + const value = asn1Schema.AsnConvert.parse(this.value, asn1X509__namespace.SubjectKeyIdentifier); + this.keyId = pvtsutils.Convert.ToHex(value); + } + else { + const identifier = typeof args[0] === "string" + ? pvtsutils.Convert.FromHex(args[0]) + : args[0]; + const value = new asn1X509__namespace.SubjectKeyIdentifier(identifier); + super(asn1X509__namespace.id_ce_subjectKeyIdentifier, args[1], asn1Schema.AsnConvert.serialize(value)); + this.keyId = pvtsutils.Convert.ToHex(identifier); + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const asn = asn1Schema.AsnConvert.parse(this.value, asn1X509__namespace.SubjectKeyIdentifier); + obj[""] = asn; + return obj; + } +} +SubjectKeyIdentifierExtension.NAME = "Subject Key Identifier"; + +class SubjectAlternativeNameExtension extends Extension { + constructor(...args) { + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else { + super(asn1X509__namespace.id_ce_subjectAltName, args[1], new GeneralNames(args[0] || []).rawData); + } + } + onInit(asn) { + super.onInit(asn); + const value = asn1Schema.AsnConvert.parse(asn.extnValue, asn1X509__namespace.SubjectAlternativeName); + this.names = new GeneralNames(value); + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const namesObj = this.names.toTextObject(); + for (const key in namesObj) { + obj[key] = namesObj[key]; + } + return obj; + } +} +SubjectAlternativeNameExtension.NAME = "Subject Alternative Name"; + +class ExtensionFactory { + static register(id, type) { + this.items.set(id, type); + } + static create(data) { + const extension = new Extension(data); + const Type = this.items.get(extension.type); + if (Type) { + return new Type(data); + } + return extension; + } +} +ExtensionFactory.items = new Map(); + +class CertificatePolicyExtension extends Extension { + constructor(...args) { + var _a; + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + const asnPolicies = asn1Schema.AsnConvert.parse(this.value, asn1X509__namespace.CertificatePolicies); + this.policies = asnPolicies.map((o) => o.policyIdentifier); + } + else { + const policies = args[0]; + const critical = (_a = args[1]) !== null && _a !== void 0 ? _a : false; + const value = new asn1X509__namespace.CertificatePolicies(policies.map((o) => (new asn1X509__namespace.PolicyInformation({ policyIdentifier: o })))); + super(asn1X509__namespace.id_ce_certificatePolicies, critical, asn1Schema.AsnConvert.serialize(value)); + this.policies = policies; + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj["Policy"] = this.policies.map((o) => new TextObject("", {}, OidSerializer.toString(o))); + return obj; + } +} +CertificatePolicyExtension.NAME = "Certificate Policies"; +ExtensionFactory.register(asn1X509__namespace.id_ce_certificatePolicies, CertificatePolicyExtension); + +class CRLDistributionPointsExtension extends Extension { + constructor(...args) { + var _a; + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else if (Array.isArray(args[0]) && typeof args[0][0] === "string") { + const urls = args[0]; + const dps = urls.map((url) => { + return new asn1X509__namespace.DistributionPoint({ + distributionPoint: new asn1X509__namespace.DistributionPointName({ fullName: [new asn1X509__namespace.GeneralName({ uniformResourceIdentifier: url })] }), + }); + }); + const value = new asn1X509__namespace.CRLDistributionPoints(dps); + super(asn1X509__namespace.id_ce_cRLDistributionPoints, args[1], asn1Schema.AsnConvert.serialize(value)); + } + else { + const value = new asn1X509__namespace.CRLDistributionPoints(args[0]); + super(asn1X509__namespace.id_ce_cRLDistributionPoints, args[1], asn1Schema.AsnConvert.serialize(value)); + } + (_a = this.distributionPoints) !== null && _a !== void 0 ? _a : (this.distributionPoints = []); + } + onInit(asn) { + super.onInit(asn); + const crlExt = asn1Schema.AsnConvert.parse(asn.extnValue, asn1X509__namespace.CRLDistributionPoints); + this.distributionPoints = crlExt; + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj["Distribution Point"] = this.distributionPoints.map((dp) => { + var _a; + const dpObj = {}; + if (dp.distributionPoint) { + dpObj[""] = (_a = dp.distributionPoint.fullName) === null || _a === void 0 ? void 0 : _a.map((name) => new GeneralName(name).toString()).join(", "); + } + if (dp.reasons) { + dpObj["Reasons"] = dp.reasons.toString(); + } + if (dp.cRLIssuer) { + dpObj["CRL Issuer"] = dp.cRLIssuer.map((issuer) => issuer.toString()).join(", "); + } + return dpObj; + }); + return obj; + } +} +CRLDistributionPointsExtension.NAME = "CRL Distribution Points"; + +class AuthorityInfoAccessExtension extends Extension { + constructor(...args) { + var _a, _b, _c, _d; + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else if (args[0] instanceof asn1X509__namespace.AuthorityInfoAccessSyntax) { + const value = new asn1X509__namespace.AuthorityInfoAccessSyntax(args[0]); + super(asn1X509__namespace.id_pe_authorityInfoAccess, args[1], asn1Schema.AsnConvert.serialize(value)); + } + else { + const params = args[0]; + const value = new asn1X509__namespace.AuthorityInfoAccessSyntax(); + addAccessDescriptions(value, params, asn1X509__namespace.id_ad_ocsp, "ocsp"); + addAccessDescriptions(value, params, asn1X509__namespace.id_ad_caIssuers, "caIssuers"); + addAccessDescriptions(value, params, asn1X509__namespace.id_ad_timeStamping, "timeStamping"); + addAccessDescriptions(value, params, asn1X509__namespace.id_ad_caRepository, "caRepository"); + super(asn1X509__namespace.id_pe_authorityInfoAccess, args[1], asn1Schema.AsnConvert.serialize(value)); + } + (_a = this.ocsp) !== null && _a !== void 0 ? _a : (this.ocsp = []); + (_b = this.caIssuers) !== null && _b !== void 0 ? _b : (this.caIssuers = []); + (_c = this.timeStamping) !== null && _c !== void 0 ? _c : (this.timeStamping = []); + (_d = this.caRepository) !== null && _d !== void 0 ? _d : (this.caRepository = []); + } + onInit(asn) { + super.onInit(asn); + this.ocsp = []; + this.caIssuers = []; + this.timeStamping = []; + this.caRepository = []; + const aia = asn1Schema.AsnConvert.parse(asn.extnValue, asn1X509__namespace.AuthorityInfoAccessSyntax); + aia.forEach((accessDescription) => { + switch (accessDescription.accessMethod) { + case asn1X509__namespace.id_ad_ocsp: + this.ocsp.push(new GeneralName(accessDescription.accessLocation)); + break; + case asn1X509__namespace.id_ad_caIssuers: + this.caIssuers.push(new GeneralName(accessDescription.accessLocation)); + break; + case asn1X509__namespace.id_ad_timeStamping: + this.timeStamping.push(new GeneralName(accessDescription.accessLocation)); + break; + case asn1X509__namespace.id_ad_caRepository: + this.caRepository.push(new GeneralName(accessDescription.accessLocation)); + break; + } + }); + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + if (this.ocsp.length) { + addUrlsToObject(obj, "OCSP", this.ocsp); + } + if (this.caIssuers.length) { + addUrlsToObject(obj, "CA Issuers", this.caIssuers); + } + if (this.timeStamping.length) { + addUrlsToObject(obj, "Time Stamping", this.timeStamping); + } + if (this.caRepository.length) { + addUrlsToObject(obj, "CA Repository", this.caRepository); + } + return obj; + } +} +AuthorityInfoAccessExtension.NAME = "Authority Info Access"; +function addUrlsToObject(obj, key, urls) { + if (urls.length === 1) { + obj[key] = urls[0].toTextObject(); + } + else { + const names = new TextObject(""); + urls.forEach((name, index) => { + const nameObj = name.toTextObject(); + const indexedKey = `${nameObj[TextObject.NAME]} ${index + 1}`; + let field = names[indexedKey]; + if (!Array.isArray(field)) { + field = []; + names[indexedKey] = field; + } + field.push(nameObj); + }); + obj[key] = names; + } +} +function addAccessDescriptions(value, params, method, key) { + const items = params[key]; + if (items) { + const array = Array.isArray(items) ? items : [items]; + array.forEach((url) => { + if (typeof url === "string") { + url = new GeneralName("url", url); + } + value.push(new asn1X509__namespace.AccessDescription({ + accessMethod: method, + accessLocation: asn1Schema.AsnConvert.parse(url.rawData, asn1X509__namespace.GeneralName), + })); + }); + } +} + +class IssuerAlternativeNameExtension extends Extension { + constructor(...args) { + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else { + super(asn1X509__namespace.id_ce_issuerAltName, args[1], new GeneralNames(args[0] || []).rawData); + } + } + onInit(asn) { + super.onInit(asn); + const value = asn1Schema.AsnConvert.parse(asn.extnValue, asn1X509__namespace.GeneralNames); + this.names = new GeneralNames(value); + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const namesObj = this.names.toTextObject(); + for (const key in namesObj) { + obj[key] = namesObj[key]; + } + return obj; + } +} +IssuerAlternativeNameExtension.NAME = "Issuer Alternative Name"; + +class Attribute extends AsnData { + constructor(...args) { + let raw; + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + raw = pvtsutils.BufferSourceConverter.toArrayBuffer(args[0]); + } + else { + const type = args[0]; + const values = Array.isArray(args[1]) + ? args[1].map((o) => pvtsutils.BufferSourceConverter.toArrayBuffer(o)) + : []; + raw = asn1Schema.AsnConvert.serialize(new asn1X509.Attribute({ + type, values, + })); + } + super(raw, asn1X509.Attribute); + } + onInit(asn) { + this.type = asn.type; + this.values = asn.values; + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj["Value"] = this.values.map((o) => new TextObject("", { "": o })); + return obj; + } + toTextObjectWithoutValue() { + const obj = this.toTextObjectEmpty(); + if (obj[TextObject.NAME] === Attribute.NAME) { + obj[TextObject.NAME] = OidSerializer.toString(this.type); + } + return obj; + } +} +Attribute.NAME = "Attribute"; + +class ChallengePasswordAttribute extends Attribute { + constructor(...args) { + var _a; + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else { + const value = new asnPkcs9__namespace.ChallengePassword({ printableString: args[0] }); + super(asnPkcs9__namespace.id_pkcs9_at_challengePassword, [asn1Schema.AsnConvert.serialize(value)]); + } + (_a = this.password) !== null && _a !== void 0 ? _a : (this.password = ""); + } + onInit(asn) { + super.onInit(asn); + if (this.values[0]) { + const value = asn1Schema.AsnConvert.parse(this.values[0], asnPkcs9__namespace.ChallengePassword); + this.password = value.toString(); + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj[TextObject.VALUE] = this.password; + return obj; + } +} +ChallengePasswordAttribute.NAME = "Challenge Password"; + +class ExtensionsAttribute extends Attribute { + constructor(...args) { + var _a; + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else { + const extensions = args[0]; + const value = new asn1X509__namespace.Extensions(); + for (const extension of extensions) { + value.push(asn1Schema.AsnConvert.parse(extension.rawData, asn1X509__namespace.Extension)); + } + super(asnPkcs9__namespace.id_pkcs9_at_extensionRequest, [asn1Schema.AsnConvert.serialize(value)]); + } + (_a = this.items) !== null && _a !== void 0 ? _a : (this.items = []); + } + onInit(asn) { + super.onInit(asn); + if (this.values[0]) { + const value = asn1Schema.AsnConvert.parse(this.values[0], asn1X509__namespace.Extensions); + this.items = value.map((o) => ExtensionFactory.create(asn1Schema.AsnConvert.serialize(o))); + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const extensions = this.items.map((o) => o.toTextObject()); + for (const extension of extensions) { + obj[extension[TextObject.NAME]] = extension; + } + return obj; + } +} +ExtensionsAttribute.NAME = "Extensions"; + +class AttributeFactory { + static register(id, type) { + this.items.set(id, type); + } + static create(data) { + const attribute = new Attribute(data); + const Type = this.items.get(attribute.type); + if (Type) { + return new Type(data); + } + return attribute; + } +} +AttributeFactory.items = new Map(); + +const diAsnSignatureFormatter = "crypto.signatureFormatter"; +class AsnDefaultSignatureFormatter { + toAsnSignature(algorithm, signature) { + return pvtsutils.BufferSourceConverter.toArrayBuffer(signature); + } + toWebSignature(algorithm, signature) { + return pvtsutils.BufferSourceConverter.toArrayBuffer(signature); + } +} + +var RsaAlgorithm_1; +exports.RsaAlgorithm = RsaAlgorithm_1 = class RsaAlgorithm { + static createPssParams(hash, saltLength) { + const hashAlgorithm = RsaAlgorithm_1.getHashAlgorithm(hash); + if (!hashAlgorithm) { + return null; + } + return new asn1Rsa__namespace.RsaSaPssParams({ + hashAlgorithm, + maskGenAlgorithm: new asn1X509.AlgorithmIdentifier({ + algorithm: asn1Rsa__namespace.id_mgf1, + parameters: asn1Schema.AsnConvert.serialize(hashAlgorithm), + }), + saltLength, + }); + } + static getHashAlgorithm(alg) { + const algProv = tsyringe.container.resolve(diAlgorithmProvider); + if (typeof alg === "string") { + return algProv.toAsnAlgorithm({ name: alg }); + } + if (typeof alg === "object" && alg && "name" in alg) { + return algProv.toAsnAlgorithm(alg); + } + return null; + } + toAsnAlgorithm(alg) { + switch (alg.name.toLowerCase()) { + case "rsassa-pkcs1-v1_5": + if ("hash" in alg) { + let hash; + if (typeof alg.hash === "string") { + hash = alg.hash; + } + else if (alg.hash && typeof alg.hash === "object" + && "name" in alg.hash && typeof alg.hash.name === "string") { + hash = alg.hash.name.toUpperCase(); + } + else { + throw new Error("Cannot get hash algorithm name"); + } + switch (hash.toLowerCase()) { + case "sha-1": + return new asn1X509.AlgorithmIdentifier({ + algorithm: asn1Rsa__namespace.id_sha1WithRSAEncryption, parameters: null, + }); + case "sha-256": + return new asn1X509.AlgorithmIdentifier({ + algorithm: asn1Rsa__namespace.id_sha256WithRSAEncryption, parameters: null, + }); + case "sha-384": + return new asn1X509.AlgorithmIdentifier({ + algorithm: asn1Rsa__namespace.id_sha384WithRSAEncryption, parameters: null, + }); + case "sha-512": + return new asn1X509.AlgorithmIdentifier({ + algorithm: asn1Rsa__namespace.id_sha512WithRSAEncryption, parameters: null, + }); + } + } + else { + return new asn1X509.AlgorithmIdentifier({ + algorithm: asn1Rsa__namespace.id_rsaEncryption, parameters: null, + }); + } + break; + case "rsa-pss": + if ("hash" in alg) { + if (!("saltLength" in alg && typeof alg.saltLength === "number")) { + throw new Error("Cannot get 'saltLength' from 'alg' argument"); + } + const pssParams = RsaAlgorithm_1.createPssParams(alg.hash, alg.saltLength); + if (!pssParams) { + throw new Error("Cannot create PSS parameters"); + } + return new asn1X509.AlgorithmIdentifier({ + algorithm: asn1Rsa__namespace.id_RSASSA_PSS, parameters: asn1Schema.AsnConvert.serialize(pssParams), + }); + } + else { + return new asn1X509.AlgorithmIdentifier({ + algorithm: asn1Rsa__namespace.id_RSASSA_PSS, parameters: null, + }); + } + } + return null; + } + toWebAlgorithm(alg) { + switch (alg.algorithm) { + case asn1Rsa__namespace.id_rsaEncryption: + return { name: "RSASSA-PKCS1-v1_5" }; + case asn1Rsa__namespace.id_sha1WithRSAEncryption: + return { + name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-1" }, + }; + case asn1Rsa__namespace.id_sha256WithRSAEncryption: + return { + name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-256" }, + }; + case asn1Rsa__namespace.id_sha384WithRSAEncryption: + return { + name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-384" }, + }; + case asn1Rsa__namespace.id_sha512WithRSAEncryption: + return { + name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-512" }, + }; + case asn1Rsa__namespace.id_RSASSA_PSS: + if (alg.parameters) { + const pssParams = asn1Schema.AsnConvert.parse(alg.parameters, asn1Rsa__namespace.RsaSaPssParams); + const algProv = tsyringe.container.resolve(diAlgorithmProvider); + const hashAlg = algProv.toWebAlgorithm(pssParams.hashAlgorithm); + return { + name: "RSA-PSS", + hash: hashAlg, + saltLength: pssParams.saltLength, + }; + } + else { + return { name: "RSA-PSS" }; + } + } + return null; + } +}; +exports.RsaAlgorithm = RsaAlgorithm_1 = tslib.__decorate([ + tsyringe.injectable() +], exports.RsaAlgorithm); +tsyringe.container.registerSingleton(diAlgorithm, exports.RsaAlgorithm); + +exports.ShaAlgorithm = class ShaAlgorithm { + toAsnAlgorithm(alg) { + switch (alg.name.toLowerCase()) { + case "sha-1": + return new asn1X509.AlgorithmIdentifier({ algorithm: asn1Rsa.id_sha1 }); + case "sha-256": + return new asn1X509.AlgorithmIdentifier({ algorithm: asn1Rsa.id_sha256 }); + case "sha-384": + return new asn1X509.AlgorithmIdentifier({ algorithm: asn1Rsa.id_sha384 }); + case "sha-512": + return new asn1X509.AlgorithmIdentifier({ algorithm: asn1Rsa.id_sha512 }); + } + return null; + } + toWebAlgorithm(alg) { + switch (alg.algorithm) { + case asn1Rsa.id_sha1: + return { name: "SHA-1" }; + case asn1Rsa.id_sha256: + return { name: "SHA-256" }; + case asn1Rsa.id_sha384: + return { name: "SHA-384" }; + case asn1Rsa.id_sha512: + return { name: "SHA-512" }; + } + return null; + } +}; +exports.ShaAlgorithm = tslib.__decorate([ + tsyringe.injectable() +], exports.ShaAlgorithm); +tsyringe.container.registerSingleton(diAlgorithm, exports.ShaAlgorithm); + +class AsnEcSignatureFormatter { + addPadding(pointSize, data) { + const bytes = pvtsutils.BufferSourceConverter.toUint8Array(data); + const res = new Uint8Array(pointSize); + res.set(bytes, pointSize - bytes.length); + return res.buffer; + } + removePadding(data, positive = false) { + let bytes = pvtsutils.BufferSourceConverter.toUint8Array(data); + for (let i = 0; i < bytes.length; i++) { + if (!bytes[i]) { + continue; + } + bytes = bytes.slice(i); + break; + } + if (positive && bytes[0] > 127) { + const result = new Uint8Array(bytes.length + 1); + result.set(bytes, 1); + return result.buffer; + } + return bytes.buffer; + } + toAsnSignature(algorithm, signature) { + if (algorithm.name === "ECDSA") { + const namedCurve = algorithm.namedCurve; + const pointSize = AsnEcSignatureFormatter.namedCurveSize.get(namedCurve) + || AsnEcSignatureFormatter.defaultNamedCurveSize; + const ecSignature = new asn1Ecc.ECDSASigValue(); + const uint8Signature = pvtsutils.BufferSourceConverter.toUint8Array(signature); + ecSignature.r = this.removePadding(uint8Signature.slice(0, pointSize), true); + ecSignature.s = this.removePadding(uint8Signature.slice(pointSize, pointSize + pointSize), true); + return asn1Schema.AsnConvert.serialize(ecSignature); + } + return null; + } + toWebSignature(algorithm, signature) { + if (algorithm.name === "ECDSA") { + const ecSigValue = asn1Schema.AsnConvert.parse(signature, asn1Ecc.ECDSASigValue); + const namedCurve = algorithm.namedCurve; + const pointSize = AsnEcSignatureFormatter.namedCurveSize.get(namedCurve) + || AsnEcSignatureFormatter.defaultNamedCurveSize; + const r = this.addPadding(pointSize, this.removePadding(ecSigValue.r)); + const s = this.addPadding(pointSize, this.removePadding(ecSigValue.s)); + return pvtsutils.combine(r, s); + } + return null; + } +} +AsnEcSignatureFormatter.namedCurveSize = new Map(); +AsnEcSignatureFormatter.defaultNamedCurveSize = 32; + +const idX25519 = "1.3.101.110"; +const idX448 = "1.3.101.111"; +const idEd25519 = "1.3.101.112"; +const idEd448 = "1.3.101.113"; +exports.EdAlgorithm = class EdAlgorithm { + toAsnAlgorithm(alg) { + let algorithm = null; + switch (alg.name.toLowerCase()) { + case "ed25519": + algorithm = idEd25519; + break; + case "x25519": + algorithm = idX25519; + break; + case "eddsa": + switch (alg.namedCurve.toLowerCase()) { + case "ed25519": + algorithm = idEd25519; + break; + case "ed448": + algorithm = idEd448; + break; + } + break; + case "ecdh-es": + switch (alg.namedCurve.toLowerCase()) { + case "x25519": + algorithm = idX25519; + break; + case "x448": + algorithm = idX448; + break; + } + } + if (algorithm) { + return new asn1X509.AlgorithmIdentifier({ algorithm }); + } + return null; + } + toWebAlgorithm(alg) { + switch (alg.algorithm) { + case idEd25519: + return { name: "Ed25519" }; + case idEd448: + return { + name: "EdDSA", namedCurve: "Ed448", + }; + case idX25519: + return { name: "X25519" }; + case idX448: + return { + name: "ECDH-ES", namedCurve: "X448", + }; + } + return null; + } +}; +exports.EdAlgorithm = tslib.__decorate([ + tsyringe.injectable() +], exports.EdAlgorithm); +tsyringe.container.registerSingleton(diAlgorithm, exports.EdAlgorithm); + +var _Pkcs10CertificateRequest_tbs, _Pkcs10CertificateRequest_subjectName, _Pkcs10CertificateRequest_subject, _Pkcs10CertificateRequest_signatureAlgorithm, _Pkcs10CertificateRequest_signature, _Pkcs10CertificateRequest_publicKey, _Pkcs10CertificateRequest_attributes, _Pkcs10CertificateRequest_extensions; +class Pkcs10CertificateRequest extends PemData { + get subjectName() { + if (!tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_subjectName, "f")) { + tslib.__classPrivateFieldSet(this, _Pkcs10CertificateRequest_subjectName, new Name(this.asn.certificationRequestInfo.subject), "f"); + } + return tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_subjectName, "f"); + } + get subject() { + if (!tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_subject, "f")) { + tslib.__classPrivateFieldSet(this, _Pkcs10CertificateRequest_subject, this.subjectName.toString(), "f"); + } + return tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_subject, "f"); + } + get signatureAlgorithm() { + if (!tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_signatureAlgorithm, "f")) { + const algProv = tsyringe.container.resolve(diAlgorithmProvider); + tslib.__classPrivateFieldSet(this, _Pkcs10CertificateRequest_signatureAlgorithm, algProv.toWebAlgorithm(this.asn.signatureAlgorithm), "f"); + } + return tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_signatureAlgorithm, "f"); + } + get signature() { + if (!tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_signature, "f")) { + tslib.__classPrivateFieldSet(this, _Pkcs10CertificateRequest_signature, this.asn.signature, "f"); + } + return tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_signature, "f"); + } + get publicKey() { + if (!tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_publicKey, "f")) { + tslib.__classPrivateFieldSet(this, _Pkcs10CertificateRequest_publicKey, new PublicKey(this.asn.certificationRequestInfo.subjectPKInfo), "f"); + } + return tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_publicKey, "f"); + } + get attributes() { + if (!tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_attributes, "f")) { + tslib.__classPrivateFieldSet(this, _Pkcs10CertificateRequest_attributes, this.asn.certificationRequestInfo.attributes + .map((o) => AttributeFactory.create(asn1Schema.AsnConvert.serialize(o))), "f"); + } + return tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_attributes, "f"); + } + get extensions() { + if (!tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_extensions, "f")) { + tslib.__classPrivateFieldSet(this, _Pkcs10CertificateRequest_extensions, [], "f"); + const extensions = this.getAttribute(asnPkcs9.id_pkcs9_at_extensionRequest); + if (extensions instanceof ExtensionsAttribute) { + tslib.__classPrivateFieldSet(this, _Pkcs10CertificateRequest_extensions, extensions.items, "f"); + } + } + return tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_extensions, "f"); + } + get tbs() { + if (!tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_tbs, "f")) { + tslib.__classPrivateFieldSet(this, _Pkcs10CertificateRequest_tbs, this.asn.certificationRequestInfoRaw + || asn1Schema.AsnConvert.serialize(this.asn.certificationRequestInfo), "f"); + } + return tslib.__classPrivateFieldGet(this, _Pkcs10CertificateRequest_tbs, "f"); + } + constructor(param) { + const args = PemData.isAsnEncoded(param) ? [param, asn1Csr.CertificationRequest] : [param]; + super(args[0], args[1]); + _Pkcs10CertificateRequest_tbs.set(this, void 0); + _Pkcs10CertificateRequest_subjectName.set(this, void 0); + _Pkcs10CertificateRequest_subject.set(this, void 0); + _Pkcs10CertificateRequest_signatureAlgorithm.set(this, void 0); + _Pkcs10CertificateRequest_signature.set(this, void 0); + _Pkcs10CertificateRequest_publicKey.set(this, void 0); + _Pkcs10CertificateRequest_attributes.set(this, void 0); + _Pkcs10CertificateRequest_extensions.set(this, void 0); + this.tag = PemConverter.CertificateRequestTag; + } + onInit(_asn) { + } + getAttribute(type) { + for (const attr of this.attributes) { + if (attr.type === type) { + return attr; + } + } + return null; + } + getAttributes(type) { + return this.attributes.filter((o) => o.type === type); + } + getExtension(type) { + for (const ext of this.extensions) { + if (ext.type === type) { + return ext; + } + } + return null; + } + getExtensions(type) { + return this.extensions.filter((o) => o.type === type); + } + async verify(crypto = cryptoProvider.get()) { + const algorithm = { + ...this.publicKey.algorithm, ...this.signatureAlgorithm, + }; + const publicKey = await this.publicKey.export(algorithm, ["verify"], crypto); + const signatureFormatters = tsyringe.container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let signature = null; + for (const signatureFormatter of signatureFormatters) { + signature = signatureFormatter.toWebSignature(algorithm, this.signature); + if (signature) { + break; + } + } + if (!signature) { + throw Error("Cannot convert WebCrypto signature value to ASN.1 format"); + } + const ok = await crypto.subtle.verify(this.signatureAlgorithm, publicKey, signature, this.tbs); + return ok; + } + toTextObject() { + const obj = this.toTextObjectEmpty(); + const req = asn1Schema.AsnConvert.parse(this.rawData, asn1Csr.CertificationRequest); + const tbs = req.certificationRequestInfo; + const data = new TextObject("", { + Version: `${asn1X509.Version[tbs.version]} (${tbs.version})`, + Subject: this.subject, + "Subject Public Key Info": this.publicKey, + }); + if (this.attributes.length) { + const attrs = new TextObject(""); + for (const ext of this.attributes) { + const attrObj = ext.toTextObject(); + attrs[attrObj[TextObject.NAME]] = attrObj; + } + data["Attributes"] = attrs; + } + obj["Data"] = data; + obj["Signature"] = new TextObject("", { + Algorithm: TextConverter.serializeAlgorithm(req.signatureAlgorithm), + "": req.signature, + }); + return obj; + } +} +_Pkcs10CertificateRequest_tbs = new WeakMap(), _Pkcs10CertificateRequest_subjectName = new WeakMap(), _Pkcs10CertificateRequest_subject = new WeakMap(), _Pkcs10CertificateRequest_signatureAlgorithm = new WeakMap(), _Pkcs10CertificateRequest_signature = new WeakMap(), _Pkcs10CertificateRequest_publicKey = new WeakMap(), _Pkcs10CertificateRequest_attributes = new WeakMap(), _Pkcs10CertificateRequest_extensions = new WeakMap(); +Pkcs10CertificateRequest.NAME = "PKCS#10 Certificate Request"; + +class Pkcs10CertificateRequestGenerator { + static async create(params, crypto = cryptoProvider.get()) { + if (!params.keys.privateKey) { + throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty"); + } + if (!params.keys.publicKey) { + throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty"); + } + const spki = await crypto.subtle.exportKey("spki", params.keys.publicKey); + const asnReq = new asn1Csr.CertificationRequest({ + certificationRequestInfo: new asn1Csr.CertificationRequestInfo({ subjectPKInfo: asn1Schema.AsnConvert.parse(spki, asn1X509.SubjectPublicKeyInfo) }), + }); + if (params.name) { + const name = params.name instanceof Name + ? params.name + : new Name(params.name); + asnReq.certificationRequestInfo.subject = asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509.Name); + } + if (params.attributes) { + for (const o of params.attributes) { + asnReq.certificationRequestInfo.attributes.push(asn1Schema.AsnConvert.parse(o.rawData, asn1X509.Attribute)); + } + } + if (params.extensions && params.extensions.length) { + const attr = new asn1X509.Attribute({ type: asnPkcs9.id_pkcs9_at_extensionRequest }); + const extensions = new asn1X509.Extensions(); + for (const o of params.extensions) { + extensions.push(asn1Schema.AsnConvert.parse(o.rawData, asn1X509.Extension)); + } + attr.values.push(asn1Schema.AsnConvert.serialize(extensions)); + asnReq.certificationRequestInfo.attributes.push(attr); + } + const signingAlgorithm = { + ...params.signingAlgorithm, ...params.keys.privateKey.algorithm, + }; + const algProv = tsyringe.container.resolve(diAlgorithmProvider); + asnReq.signatureAlgorithm = algProv.toAsnAlgorithm(signingAlgorithm); + const tbs = asn1Schema.AsnConvert.serialize(asnReq.certificationRequestInfo); + const signature = await crypto.subtle.sign(signingAlgorithm, params.keys.privateKey, tbs); + const signatureFormatters = tsyringe.container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let asnSignature = null; + for (const signatureFormatter of signatureFormatters) { + asnSignature = signatureFormatter.toAsnSignature(signingAlgorithm, signature); + if (asnSignature) { + break; + } + } + if (!asnSignature) { + throw Error("Cannot convert WebCrypto signature value to ASN.1 format"); + } + asnReq.signature = asnSignature; + return new Pkcs10CertificateRequest(asn1Schema.AsnConvert.serialize(asnReq)); + } +} + +var _X509Certificate_tbs, _X509Certificate_serialNumber, _X509Certificate_subjectName, _X509Certificate_subject, _X509Certificate_issuerName, _X509Certificate_issuer, _X509Certificate_notBefore, _X509Certificate_notAfter, _X509Certificate_signatureAlgorithm, _X509Certificate_signature, _X509Certificate_extensions, _X509Certificate_publicKey; +class X509Certificate extends PemData { + get publicKey() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_publicKey, "f")) { + tslib.__classPrivateFieldSet(this, _X509Certificate_publicKey, new PublicKey(this.asn.tbsCertificate.subjectPublicKeyInfo), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_publicKey, "f"); + } + get serialNumber() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_serialNumber, "f")) { + const tbs = this.asn.tbsCertificate; + let serialNumberBytes = new Uint8Array(tbs.serialNumber); + if (serialNumberBytes.length > 1 + && serialNumberBytes[0] === 0x00 + && serialNumberBytes[1] > 0x7F) { + serialNumberBytes = serialNumberBytes.slice(1); + } + tslib.__classPrivateFieldSet(this, _X509Certificate_serialNumber, pvtsutils.Convert.ToHex(serialNumberBytes), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_serialNumber, "f"); + } + get subjectName() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_subjectName, "f")) { + tslib.__classPrivateFieldSet(this, _X509Certificate_subjectName, new Name(this.asn.tbsCertificate.subject), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_subjectName, "f"); + } + get subject() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_subject, "f")) { + tslib.__classPrivateFieldSet(this, _X509Certificate_subject, this.subjectName.toString(), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_subject, "f"); + } + get issuerName() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_issuerName, "f")) { + tslib.__classPrivateFieldSet(this, _X509Certificate_issuerName, new Name(this.asn.tbsCertificate.issuer), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_issuerName, "f"); + } + get issuer() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_issuer, "f")) { + tslib.__classPrivateFieldSet(this, _X509Certificate_issuer, this.issuerName.toString(), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_issuer, "f"); + } + get notBefore() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_notBefore, "f")) { + const notBefore = this.asn.tbsCertificate.validity.notBefore.utcTime + || this.asn.tbsCertificate.validity.notBefore.generalTime; + if (!notBefore) { + throw new Error("Cannot get 'notBefore' value"); + } + tslib.__classPrivateFieldSet(this, _X509Certificate_notBefore, notBefore, "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_notBefore, "f"); + } + get notAfter() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_notAfter, "f")) { + const notAfter = this.asn.tbsCertificate.validity.notAfter.utcTime + || this.asn.tbsCertificate.validity.notAfter.generalTime; + if (!notAfter) { + throw new Error("Cannot get 'notAfter' value"); + } + tslib.__classPrivateFieldSet(this, _X509Certificate_notAfter, notAfter, "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_notAfter, "f"); + } + get signatureAlgorithm() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_signatureAlgorithm, "f")) { + const algProv = tsyringe.container.resolve(diAlgorithmProvider); + tslib.__classPrivateFieldSet(this, _X509Certificate_signatureAlgorithm, algProv + .toWebAlgorithm(this.asn.signatureAlgorithm), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_signatureAlgorithm, "f"); + } + get signature() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_signature, "f")) { + tslib.__classPrivateFieldSet(this, _X509Certificate_signature, this.asn.signatureValue, "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_signature, "f"); + } + get extensions() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_extensions, "f")) { + tslib.__classPrivateFieldSet(this, _X509Certificate_extensions, [], "f"); + if (this.asn.tbsCertificate.extensions) { + tslib.__classPrivateFieldSet(this, _X509Certificate_extensions, this.asn.tbsCertificate.extensions.map((o) => (ExtensionFactory.create(asn1Schema.AsnConvert.serialize(o)))), "f"); + } + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_extensions, "f"); + } + get tbs() { + if (!tslib.__classPrivateFieldGet(this, _X509Certificate_tbs, "f")) { + tslib.__classPrivateFieldSet(this, _X509Certificate_tbs, this.asn.tbsCertificateRaw || asn1Schema.AsnConvert.serialize(this.asn.tbsCertificate), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Certificate_tbs, "f"); + } + constructor(param) { + const args = PemData.isAsnEncoded(param) ? [param, asn1X509.Certificate] : [param]; + super(args[0], args[1]); + _X509Certificate_tbs.set(this, void 0); + _X509Certificate_serialNumber.set(this, void 0); + _X509Certificate_subjectName.set(this, void 0); + _X509Certificate_subject.set(this, void 0); + _X509Certificate_issuerName.set(this, void 0); + _X509Certificate_issuer.set(this, void 0); + _X509Certificate_notBefore.set(this, void 0); + _X509Certificate_notAfter.set(this, void 0); + _X509Certificate_signatureAlgorithm.set(this, void 0); + _X509Certificate_signature.set(this, void 0); + _X509Certificate_extensions.set(this, void 0); + _X509Certificate_publicKey.set(this, void 0); + this.tag = PemConverter.CertificateTag; + } + onInit(_asn) { + } + getExtension(type) { + for (const ext of this.extensions) { + if (typeof type === "string") { + if (ext.type === type) { + return ext; + } + } + else { + if (ext instanceof type) { + return ext; + } + } + } + return null; + } + getExtensions(type) { + return this.extensions.filter((o) => { + if (typeof type === "string") { + return o.type === type; + } + else { + return o instanceof type; + } + }); + } + async verify(params = {}, crypto = cryptoProvider.get()) { + let keyAlgorithm; + let publicKey; + const paramsKey = params.publicKey; + try { + if (!paramsKey) { + keyAlgorithm = { + ...this.publicKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = await this.publicKey.export(keyAlgorithm, ["verify"], crypto); + } + else if ("publicKey" in paramsKey) { + keyAlgorithm = { + ...paramsKey.publicKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = await paramsKey.publicKey.export(keyAlgorithm, ["verify"], crypto); + } + else if (paramsKey instanceof PublicKey) { + keyAlgorithm = { + ...paramsKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = await paramsKey.export(keyAlgorithm, ["verify"], crypto); + } + else if (pvtsutils.BufferSourceConverter.isBufferSource(paramsKey)) { + const key = new PublicKey(paramsKey); + keyAlgorithm = { + ...key.algorithm, ...this.signatureAlgorithm, + }; + publicKey = await key.export(keyAlgorithm, ["verify"], crypto); + } + else { + keyAlgorithm = { + ...paramsKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = paramsKey; + } + } + catch { + return false; + } + const signatureFormatters = tsyringe.container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let signature = null; + for (const signatureFormatter of signatureFormatters) { + signature = signatureFormatter.toWebSignature(keyAlgorithm, this.signature); + if (signature) { + break; + } + } + if (!signature) { + throw Error("Cannot convert ASN.1 signature value to WebCrypto format"); + } + const ok = await crypto.subtle.verify(this.signatureAlgorithm, publicKey, signature, this.tbs); + if (params.signatureOnly) { + return ok; + } + else { + const date = params.date || new Date(); + const time = date.getTime(); + return ok && this.notBefore.getTime() < time && time < this.notAfter.getTime(); + } + } + async getThumbprint(...args) { + let crypto; + let algorithm = "SHA-1"; + if (args[0]) { + if (!args[0].subtle) { + algorithm = args[0] || algorithm; + crypto = args[1]; + } + else { + crypto = args[0]; + } + } + crypto !== null && crypto !== void 0 ? crypto : (crypto = cryptoProvider.get()); + return await crypto.subtle.digest(algorithm, this.rawData); + } + async isSelfSigned(crypto = cryptoProvider.get()) { + return this.subject === this.issuer && await this.verify({ signatureOnly: true }, crypto); + } + toTextObject() { + const obj = this.toTextObjectEmpty(); + const cert = asn1Schema.AsnConvert.parse(this.rawData, asn1X509.Certificate); + const tbs = cert.tbsCertificate; + const data = new TextObject("", { + Version: `${asn1X509.Version[tbs.version]} (${tbs.version})`, + "Serial Number": tbs.serialNumber, + "Signature Algorithm": TextConverter.serializeAlgorithm(tbs.signature), + Issuer: this.issuer, + Validity: new TextObject("", { + "Not Before": tbs.validity.notBefore.getTime(), + "Not After": tbs.validity.notAfter.getTime(), + }), + Subject: this.subject, + "Subject Public Key Info": this.publicKey, + }); + if (tbs.issuerUniqueID) { + data["Issuer Unique ID"] = tbs.issuerUniqueID; + } + if (tbs.subjectUniqueID) { + data["Subject Unique ID"] = tbs.subjectUniqueID; + } + if (this.extensions.length) { + const extensions = new TextObject(""); + for (const ext of this.extensions) { + const extObj = ext.toTextObject(); + extensions[extObj[TextObject.NAME]] = extObj; + } + data["Extensions"] = extensions; + } + obj["Data"] = data; + obj["Signature"] = new TextObject("", { + Algorithm: TextConverter.serializeAlgorithm(cert.signatureAlgorithm), + "": cert.signatureValue, + }); + return obj; + } +} +_X509Certificate_tbs = new WeakMap(), _X509Certificate_serialNumber = new WeakMap(), _X509Certificate_subjectName = new WeakMap(), _X509Certificate_subject = new WeakMap(), _X509Certificate_issuerName = new WeakMap(), _X509Certificate_issuer = new WeakMap(), _X509Certificate_notBefore = new WeakMap(), _X509Certificate_notAfter = new WeakMap(), _X509Certificate_signatureAlgorithm = new WeakMap(), _X509Certificate_signature = new WeakMap(), _X509Certificate_extensions = new WeakMap(), _X509Certificate_publicKey = new WeakMap(); +X509Certificate.NAME = "Certificate"; + +class X509Certificates extends Array { + constructor(param) { + super(); + if (PemData.isAsnEncoded(param)) { + this.import(param); + } + else if (param instanceof X509Certificate) { + this.push(param); + } + else if (Array.isArray(param)) { + for (const item of param) { + this.push(item); + } + } + } + export(format) { + const signedData = new asn1Cms__namespace.SignedData(); + signedData.version = 1; + signedData.encapContentInfo.eContentType = asn1Cms__namespace.id_data; + signedData.encapContentInfo.eContent = new asn1Cms__namespace.EncapsulatedContent({ single: new asn1Schema.OctetString() }); + signedData.certificates = new asn1Cms__namespace.CertificateSet(this.map((o) => new asn1Cms__namespace.CertificateChoices({ certificate: asn1Schema.AsnConvert.parse(o.rawData, asn1X509.Certificate) }))); + const cms = new asn1Cms__namespace.ContentInfo({ + contentType: asn1Cms__namespace.id_signedData, + content: asn1Schema.AsnConvert.serialize(signedData), + }); + const raw = asn1Schema.AsnConvert.serialize(cms); + if (format === "raw") { + return raw; + } + return this.toString(format); + } + import(data) { + const raw = PemData.toArrayBuffer(data); + const cms = asn1Schema.AsnConvert.parse(raw, asn1Cms__namespace.ContentInfo); + if (cms.contentType !== asn1Cms__namespace.id_signedData) { + throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object."); + } + const signedData = asn1Schema.AsnConvert.parse(cms.content, asn1Cms__namespace.SignedData); + this.clear(); + for (const item of signedData.certificates || []) { + if (item.certificate) { + this.push(new X509Certificate(item.certificate)); + } + } + } + clear() { + while (this.pop()) { + } + } + toString(format = "pem") { + const raw = this.export("raw"); + switch (format) { + case "pem": + return PemConverter.encode(raw, "CMS"); + case "pem-chain": + return this + .map((o) => o.toString("pem")) + .join("\n"); + case "asn": + return asn1Schema.AsnConvert.toString(raw); + case "hex": + return pvtsutils.Convert.ToHex(raw); + case "base64": + return pvtsutils.Convert.ToBase64(raw); + case "base64url": + return pvtsutils.Convert.ToBase64Url(raw); + case "text": + return TextConverter.serialize(this.toTextObject()); + default: + throw TypeError("Argument 'format' is unsupported value"); + } + } + toTextObject() { + const contentInfo = asn1Schema.AsnConvert.parse(this.export("raw"), asn1Cms__namespace.ContentInfo); + const signedData = asn1Schema.AsnConvert.parse(contentInfo.content, asn1Cms__namespace.SignedData); + const obj = new TextObject("X509Certificates", { + "Content Type": OidSerializer.toString(contentInfo.contentType), + Content: new TextObject("", { + Version: `${asn1Cms__namespace.CMSVersion[signedData.version]} (${signedData.version})`, + Certificates: new TextObject("", { Certificate: this.map((o) => o.toTextObject()) }), + }), + }); + return obj; + } +} + +class X509ChainBuilder { + constructor(params = {}) { + this.certificates = []; + if (params.certificates) { + this.certificates = params.certificates; + } + } + async build(cert, crypto = cryptoProvider.get()) { + const chain = new X509Certificates(cert); + let current = cert; + while (current = await this.findIssuer(current, crypto)) { + const thumbprint = await current.getThumbprint(crypto); + for (const item of chain) { + const thumbprint2 = await item.getThumbprint(crypto); + if (pvtsutils.isEqual(thumbprint, thumbprint2)) { + throw new Error("Cannot build a certificate chain. Circular dependency."); + } + } + chain.push(current); + } + return chain; + } + async findIssuer(cert, crypto = cryptoProvider.get()) { + if (!await cert.isSelfSigned(crypto)) { + const akiExt = cert.getExtension(asn1X509__namespace.id_ce_authorityKeyIdentifier); + for (const item of this.certificates) { + if (item.subject !== cert.issuer) { + continue; + } + if (akiExt) { + if (akiExt.keyId) { + const skiExt = item.getExtension(asn1X509__namespace.id_ce_subjectKeyIdentifier); + if (skiExt && skiExt.keyId !== akiExt.keyId) { + continue; + } + } + else if (akiExt.certId) { + const sanExt = item.getExtension(asn1X509__namespace.id_ce_subjectAltName); + if (sanExt + && !(akiExt.certId.serialNumber === item.serialNumber && pvtsutils.isEqual(asn1Schema.AsnConvert.serialize(akiExt.certId.name), asn1Schema.AsnConvert.serialize(sanExt)))) { + continue; + } + } + } + try { + const algorithm = { + ...item.publicKey.algorithm, ...cert.signatureAlgorithm, + }; + const publicKey = await item.publicKey.export(algorithm, ["verify"], crypto); + const ok = await cert.verify({ + publicKey, signatureOnly: true, + }, crypto); + if (!ok) { + continue; + } + } + catch { + continue; + } + return item; + } + } + return null; + } +} + +function generateCertificateSerialNumber(input, crypto = cryptoProvider.get()) { + const inputView = pvtsutils.BufferSourceConverter.toUint8Array(pvtsutils.Convert.FromHex(input || "")); + let serialNumber = inputView && inputView.length && inputView.some((o) => o > 0) + ? new Uint8Array(inputView) + : undefined; + if (!serialNumber) { + serialNumber = crypto.getRandomValues(new Uint8Array(16)); + } + let firstNonZero = 0; + while (firstNonZero < serialNumber.length - 1 && serialNumber[firstNonZero] === 0) { + firstNonZero++; + } + serialNumber = serialNumber.slice(firstNonZero); + if (serialNumber[0] > 0x7F) { + const newSerialNumber = new Uint8Array(serialNumber.length + 1); + newSerialNumber[0] = 0x00; + newSerialNumber.set(serialNumber, 1); + serialNumber = newSerialNumber; + } + return serialNumber.buffer; +} + +class X509CertificateGenerator { + static async createSelfSigned(params, crypto = cryptoProvider.get()) { + if (!params.keys.privateKey) { + throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty"); + } + if (!params.keys.publicKey) { + throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty"); + } + return this.create({ + serialNumber: params.serialNumber, + subject: params.name, + issuer: params.name, + notBefore: params.notBefore, + notAfter: params.notAfter, + publicKey: params.keys.publicKey, + signingKey: params.keys.privateKey, + signingAlgorithm: params.signingAlgorithm, + extensions: params.extensions, + }, crypto); + } + static async create(params, crypto = cryptoProvider.get()) { + var _a; + let spki; + if (params.publicKey instanceof PublicKey) { + spki = params.publicKey.rawData; + } + else if ("publicKey" in params.publicKey) { + spki = params.publicKey.publicKey.rawData; + } + else if (pvtsutils.BufferSourceConverter.isBufferSource(params.publicKey)) { + spki = params.publicKey; + } + else { + spki = await crypto.subtle.exportKey("spki", params.publicKey); + } + const serialNumber = generateCertificateSerialNumber(params.serialNumber, crypto); + const notBefore = params.notBefore || new Date(); + const notAfter = params.notAfter || new Date(notBefore.getTime() + 31536000000); + const asnX509 = new asn1X509__namespace.Certificate({ + tbsCertificate: new asn1X509__namespace.TBSCertificate({ + version: asn1X509__namespace.Version.v3, + serialNumber, + validity: new asn1X509__namespace.Validity({ + notBefore, + notAfter, + }), + extensions: new asn1X509__namespace.Extensions(((_a = params.extensions) === null || _a === void 0 ? void 0 : _a.map((o) => asn1Schema.AsnConvert.parse(o.rawData, asn1X509__namespace.Extension))) || []), + subjectPublicKeyInfo: asn1Schema.AsnConvert.parse(spki, asn1X509__namespace.SubjectPublicKeyInfo), + }), + }); + if (params.subject) { + const name = params.subject instanceof Name + ? params.subject + : new Name(params.subject); + asnX509.tbsCertificate.subject = asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name); + } + if (params.issuer) { + const name = params.issuer instanceof Name + ? params.issuer + : new Name(params.issuer); + asnX509.tbsCertificate.issuer = asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name); + } + const defaultSigningAlgorithm = { hash: "SHA-256" }; + const signatureAlgorithm = ("signingKey" in params) + ? { + ...defaultSigningAlgorithm, ...params.signingAlgorithm, ...params.signingKey.algorithm, + } + : { + ...defaultSigningAlgorithm, ...params.signingAlgorithm, + }; + const algProv = tsyringe.container.resolve(diAlgorithmProvider); + asnX509.tbsCertificate.signature = asnX509.signatureAlgorithm = algProv + .toAsnAlgorithm(signatureAlgorithm); + const tbs = asn1Schema.AsnConvert.serialize(asnX509.tbsCertificate); + const signatureValue = ("signingKey" in params) + ? await crypto.subtle.sign(signatureAlgorithm, params.signingKey, tbs) + : params.signature; + const signatureFormatters = tsyringe.container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let asnSignature = null; + for (const signatureFormatter of signatureFormatters) { + asnSignature = signatureFormatter.toAsnSignature(signatureAlgorithm, signatureValue); + if (asnSignature) { + break; + } + } + if (!asnSignature) { + throw Error("Cannot convert ASN.1 signature value to WebCrypto format"); + } + asnX509.signatureValue = asnSignature; + return new X509Certificate(asn1Schema.AsnConvert.serialize(asnX509)); + } +} + +var _X509CrlEntry_serialNumber, _X509CrlEntry_revocationDate, _X509CrlEntry_reason, _X509CrlEntry_invalidity, _X509CrlEntry_extensions; +exports.X509CrlReason = void 0; +(function (X509CrlReason) { + X509CrlReason[X509CrlReason["unspecified"] = 0] = "unspecified"; + X509CrlReason[X509CrlReason["keyCompromise"] = 1] = "keyCompromise"; + X509CrlReason[X509CrlReason["cACompromise"] = 2] = "cACompromise"; + X509CrlReason[X509CrlReason["affiliationChanged"] = 3] = "affiliationChanged"; + X509CrlReason[X509CrlReason["superseded"] = 4] = "superseded"; + X509CrlReason[X509CrlReason["cessationOfOperation"] = 5] = "cessationOfOperation"; + X509CrlReason[X509CrlReason["certificateHold"] = 6] = "certificateHold"; + X509CrlReason[X509CrlReason["removeFromCRL"] = 8] = "removeFromCRL"; + X509CrlReason[X509CrlReason["privilegeWithdrawn"] = 9] = "privilegeWithdrawn"; + X509CrlReason[X509CrlReason["aACompromise"] = 10] = "aACompromise"; +})(exports.X509CrlReason || (exports.X509CrlReason = {})); +class X509CrlEntry extends AsnData { + get serialNumber() { + if (!tslib.__classPrivateFieldGet(this, _X509CrlEntry_serialNumber, "f")) { + tslib.__classPrivateFieldSet(this, _X509CrlEntry_serialNumber, pvtsutils.Convert.ToHex(this.asn.userCertificate), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509CrlEntry_serialNumber, "f"); + } + get revocationDate() { + if (!tslib.__classPrivateFieldGet(this, _X509CrlEntry_revocationDate, "f")) { + tslib.__classPrivateFieldSet(this, _X509CrlEntry_revocationDate, this.asn.revocationDate.getTime(), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509CrlEntry_revocationDate, "f"); + } + get reason() { + if (tslib.__classPrivateFieldGet(this, _X509CrlEntry_reason, "f") === undefined) { + void this.extensions; + } + return tslib.__classPrivateFieldGet(this, _X509CrlEntry_reason, "f"); + } + get invalidity() { + if (tslib.__classPrivateFieldGet(this, _X509CrlEntry_invalidity, "f") === undefined) { + void this.extensions; + } + return tslib.__classPrivateFieldGet(this, _X509CrlEntry_invalidity, "f"); + } + get extensions() { + if (!tslib.__classPrivateFieldGet(this, _X509CrlEntry_extensions, "f")) { + tslib.__classPrivateFieldSet(this, _X509CrlEntry_extensions, [], "f"); + if (this.asn.crlEntryExtensions) { + tslib.__classPrivateFieldSet(this, _X509CrlEntry_extensions, this.asn.crlEntryExtensions.map((o) => { + const extension = ExtensionFactory.create(asn1Schema.AsnConvert.serialize(o)); + switch (extension.type) { + case asn1X509.id_ce_cRLReasons: + if (tslib.__classPrivateFieldGet(this, _X509CrlEntry_reason, "f") === undefined) { + tslib.__classPrivateFieldSet(this, _X509CrlEntry_reason, asn1Schema.AsnConvert + .parse(extension.value, asn1X509.CRLReason).reason, "f"); + } + break; + case asn1X509.id_ce_invalidityDate: + if (tslib.__classPrivateFieldGet(this, _X509CrlEntry_invalidity, "f") === undefined) { + tslib.__classPrivateFieldSet(this, _X509CrlEntry_invalidity, asn1Schema.AsnConvert.parse(extension.value, asn1X509.InvalidityDate).value, "f"); + } + break; + } + return extension; + }), "f"); + } + } + return tslib.__classPrivateFieldGet(this, _X509CrlEntry_extensions, "f"); + } + constructor(...args) { + let raw; + if (pvtsutils.BufferSourceConverter.isBufferSource(args[0])) { + raw = pvtsutils.BufferSourceConverter.toArrayBuffer(args[0]); + } + else if (typeof args[0] === "string") { + raw = asn1Schema.AsnConvert.serialize(new asn1X509.RevokedCertificate({ + userCertificate: generateCertificateSerialNumber(args[0]), + revocationDate: new asn1X509.Time(args[1]), + crlEntryExtensions: args[2], + })); + } + else if (args[0] instanceof asn1X509.RevokedCertificate) { + raw = args[0]; + } + if (!raw) { + throw new TypeError("Cannot create X509CrlEntry instance. Wrong constructor arguments."); + } + super(raw, asn1X509.RevokedCertificate); + _X509CrlEntry_serialNumber.set(this, void 0); + _X509CrlEntry_revocationDate.set(this, void 0); + _X509CrlEntry_reason.set(this, void 0); + _X509CrlEntry_invalidity.set(this, void 0); + _X509CrlEntry_extensions.set(this, void 0); + } + onInit(_asn) { + } +} +_X509CrlEntry_serialNumber = new WeakMap(), _X509CrlEntry_revocationDate = new WeakMap(), _X509CrlEntry_reason = new WeakMap(), _X509CrlEntry_invalidity = new WeakMap(), _X509CrlEntry_extensions = new WeakMap(); + +var _X509Crl_tbs, _X509Crl_signatureAlgorithm, _X509Crl_issuerName, _X509Crl_thisUpdate, _X509Crl_nextUpdate, _X509Crl_entries, _X509Crl_extensions; +class X509Crl extends PemData { + get version() { + return this.asn.tbsCertList.version; + } + get signatureAlgorithm() { + if (!tslib.__classPrivateFieldGet(this, _X509Crl_signatureAlgorithm, "f")) { + const algProv = tsyringe.container.resolve(diAlgorithmProvider); + tslib.__classPrivateFieldSet(this, _X509Crl_signatureAlgorithm, algProv + .toWebAlgorithm(this.asn.signatureAlgorithm), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Crl_signatureAlgorithm, "f"); + } + get signature() { + return this.asn.signature; + } + get issuer() { + return this.issuerName.toString(); + } + get issuerName() { + if (!tslib.__classPrivateFieldGet(this, _X509Crl_issuerName, "f")) { + tslib.__classPrivateFieldSet(this, _X509Crl_issuerName, new Name(this.asn.tbsCertList.issuer), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Crl_issuerName, "f"); + } + get thisUpdate() { + if (!tslib.__classPrivateFieldGet(this, _X509Crl_thisUpdate, "f")) { + const thisUpdate = this.asn.tbsCertList.thisUpdate.getTime(); + if (!thisUpdate) { + throw new Error("Cannot get 'thisUpdate' value"); + } + tslib.__classPrivateFieldSet(this, _X509Crl_thisUpdate, thisUpdate, "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Crl_thisUpdate, "f"); + } + get nextUpdate() { + var _a; + if (tslib.__classPrivateFieldGet(this, _X509Crl_nextUpdate, "f") === undefined) { + tslib.__classPrivateFieldSet(this, _X509Crl_nextUpdate, ((_a = this.asn.tbsCertList.nextUpdate) === null || _a === void 0 ? void 0 : _a.getTime()) || undefined, "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Crl_nextUpdate, "f"); + } + get entries() { + var _a; + if (!tslib.__classPrivateFieldGet(this, _X509Crl_entries, "f")) { + tslib.__classPrivateFieldSet(this, _X509Crl_entries, ((_a = this.asn.tbsCertList + .revokedCertificates) === null || _a === void 0 ? void 0 : _a.map((o) => new X509CrlEntry(o))) || [], "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Crl_entries, "f"); + } + get extensions() { + if (!tslib.__classPrivateFieldGet(this, _X509Crl_extensions, "f")) { + tslib.__classPrivateFieldSet(this, _X509Crl_extensions, [], "f"); + if (this.asn.tbsCertList.crlExtensions) { + tslib.__classPrivateFieldSet(this, _X509Crl_extensions, this.asn.tbsCertList.crlExtensions.map((o) => ExtensionFactory.create(asn1Schema.AsnConvert.serialize(o))), "f"); + } + } + return tslib.__classPrivateFieldGet(this, _X509Crl_extensions, "f"); + } + get tbs() { + if (!tslib.__classPrivateFieldGet(this, _X509Crl_tbs, "f")) { + tslib.__classPrivateFieldSet(this, _X509Crl_tbs, this.asn.tbsCertListRaw || asn1Schema.AsnConvert.serialize(this.asn.tbsCertList), "f"); + } + return tslib.__classPrivateFieldGet(this, _X509Crl_tbs, "f"); + } + get tbsCertListSignatureAlgorithm() { + return this.asn.tbsCertList.signature; + } + get certListSignatureAlgorithm() { + return this.asn.signatureAlgorithm; + } + constructor(param) { + super(param, PemData.isAsnEncoded(param) ? asn1X509.CertificateList : undefined); + this.tag = PemConverter.CrlTag; + _X509Crl_tbs.set(this, void 0); + _X509Crl_signatureAlgorithm.set(this, void 0); + _X509Crl_issuerName.set(this, void 0); + _X509Crl_thisUpdate.set(this, void 0); + _X509Crl_nextUpdate.set(this, void 0); + _X509Crl_entries.set(this, void 0); + _X509Crl_extensions.set(this, void 0); + } + onInit(_asn) { + } + getExtension(type) { + for (const ext of this.extensions) { + if (typeof type === "string") { + if (ext.type === type) { + return ext; + } + } + else { + if (ext instanceof type) { + return ext; + } + } + } + return null; + } + getExtensions(type) { + return this.extensions.filter((o) => { + if (typeof type === "string") { + return o.type === type; + } + else { + return o instanceof type; + } + }); + } + async verify(params, crypto = cryptoProvider.get()) { + if (!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm)) { + throw new Error("algorithm identifier in the sequence tbsCertList and CertificateList mismatch"); + } + let keyAlgorithm; + let publicKey; + const paramsKey = params.publicKey; + try { + if (paramsKey instanceof X509Certificate) { + keyAlgorithm = { + ...paramsKey.publicKey.algorithm, + ...paramsKey.signatureAlgorithm, + }; + publicKey = await paramsKey.publicKey.export(keyAlgorithm, ["verify"]); + } + else if (paramsKey instanceof PublicKey) { + keyAlgorithm = { + ...paramsKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = await paramsKey.export(keyAlgorithm, ["verify"]); + } + else { + keyAlgorithm = { + ...paramsKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = paramsKey; + } + } + catch { + return false; + } + const signatureFormatters = tsyringe.container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let signature = null; + for (const signatureFormatter of signatureFormatters) { + signature = signatureFormatter.toWebSignature(keyAlgorithm, this.signature); + if (signature) { + break; + } + } + if (!signature) { + throw Error("Cannot convert ASN.1 signature value to WebCrypto format"); + } + return await crypto.subtle.verify(this.signatureAlgorithm, publicKey, signature, this.tbs); + } + async getThumbprint(...args) { + let crypto; + let algorithm = "SHA-1"; + if (args[0]) { + if (!args[0].subtle) { + algorithm = args[0] || algorithm; + crypto = args[1]; + } + else { + crypto = args[0]; + } + } + crypto !== null && crypto !== void 0 ? crypto : (crypto = cryptoProvider.get()); + return await crypto.subtle.digest(algorithm, this.rawData); + } + findRevoked(certOrSerialNumber) { + const serialNumber = typeof certOrSerialNumber === "string" ? certOrSerialNumber : certOrSerialNumber.serialNumber; + const serialBuffer = generateCertificateSerialNumber(serialNumber); + for (const revoked of this.asn.tbsCertList.revokedCertificates || []) { + if (pvtsutils.BufferSourceConverter.isEqual(revoked.userCertificate, serialBuffer)) { + return new X509CrlEntry(asn1Schema.AsnConvert.serialize(revoked)); + } + } + return null; + } +} +_X509Crl_tbs = new WeakMap(), _X509Crl_signatureAlgorithm = new WeakMap(), _X509Crl_issuerName = new WeakMap(), _X509Crl_thisUpdate = new WeakMap(), _X509Crl_nextUpdate = new WeakMap(), _X509Crl_entries = new WeakMap(), _X509Crl_extensions = new WeakMap(); + +class X509CrlGenerator { + static async create(params, crypto = cryptoProvider.get()) { + var _a; + const name = params.issuer instanceof Name + ? params.issuer + : new Name(params.issuer); + const asnX509Crl = new asn1X509__namespace.CertificateList({ + tbsCertList: new asn1X509__namespace.TBSCertList({ + version: asn1X509__namespace.Version.v2, + issuer: asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name), + thisUpdate: new asn1X509.Time(params.thisUpdate || new Date()), + }), + }); + if (params.nextUpdate) { + asnX509Crl.tbsCertList.nextUpdate = new asn1X509.Time(params.nextUpdate); + } + if (params.extensions && params.extensions.length) { + asnX509Crl.tbsCertList.crlExtensions = new asn1X509__namespace.Extensions(params.extensions.map((o) => asn1Schema.AsnConvert.parse(o.rawData, asn1X509__namespace.Extension)) || []); + } + if (params.entries && params.entries.length) { + asnX509Crl.tbsCertList.revokedCertificates = []; + for (const entry of params.entries) { + const userCertificate = PemData.toArrayBuffer(entry.serialNumber); + const index = asnX509Crl.tbsCertList.revokedCertificates + .findIndex((cert) => pvtsutils.isEqual(cert.userCertificate, userCertificate)); + if (index > -1) { + throw new Error(`Certificate serial number ${entry.serialNumber} already exists in tbsCertList`); + } + const revokedCert = new asn1X509.RevokedCertificate({ + userCertificate: userCertificate, + revocationDate: new asn1X509.Time(entry.revocationDate || new Date()), + }); + if ("extensions" in entry && ((_a = entry.extensions) === null || _a === void 0 ? void 0 : _a.length)) { + revokedCert.crlEntryExtensions = entry.extensions.map((o) => (asn1Schema.AsnConvert.parse(o.rawData, asn1X509__namespace.Extension))); + } + else { + revokedCert.crlEntryExtensions = []; + } + if (!(entry instanceof X509CrlEntry)) { + if (entry.reason) { + revokedCert.crlEntryExtensions.push(new asn1X509__namespace.Extension({ + extnID: asn1X509__namespace.id_ce_cRLReasons, + critical: false, + extnValue: new asn1Schema.OctetString(asn1Schema.AsnConvert.serialize(new asn1X509__namespace.CRLReason(entry.reason))), + })); + } + if (entry.invalidity) { + revokedCert.crlEntryExtensions.push(new asn1X509__namespace.Extension({ + extnID: asn1X509__namespace.id_ce_invalidityDate, + critical: false, + extnValue: new asn1Schema.OctetString(asn1Schema.AsnConvert.serialize(new asn1X509__namespace.InvalidityDate(entry.invalidity))), + })); + } + if (entry.issuer) { + const name = params.issuer instanceof Name + ? params.issuer + : new Name(params.issuer); + revokedCert.crlEntryExtensions.push(new asn1X509__namespace.Extension({ + extnID: asn1X509__namespace.id_ce_certificateIssuer, + critical: false, + extnValue: new asn1Schema.OctetString(asn1Schema.AsnConvert.serialize(asn1Schema.AsnConvert.parse(name.toArrayBuffer(), asn1X509__namespace.Name))), + })); + } + } + asnX509Crl.tbsCertList.revokedCertificates.push(revokedCert); + } + } + const signingAlgorithm = { + ...params.signingAlgorithm, ...params.signingKey.algorithm, + }; + const algProv = tsyringe.container.resolve(diAlgorithmProvider); + asnX509Crl.tbsCertList.signature = asnX509Crl.signatureAlgorithm = algProv + .toAsnAlgorithm(signingAlgorithm); + const tbs = asn1Schema.AsnConvert.serialize(asnX509Crl.tbsCertList); + const signature = await crypto.subtle.sign(signingAlgorithm, params.signingKey, tbs); + const signatureFormatters = tsyringe.container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let asnSignature = null; + for (const signatureFormatter of signatureFormatters) { + asnSignature = signatureFormatter.toAsnSignature(signingAlgorithm, signature); + if (asnSignature) { + break; + } + } + if (!asnSignature) { + throw Error("Cannot convert ASN.1 signature value to WebCrypto format"); + } + asnX509Crl.signature = asnSignature; + return new X509Crl(asn1Schema.AsnConvert.serialize(asnX509Crl)); + } +} + +ExtensionFactory.register(asn1X509__namespace.id_ce_basicConstraints, BasicConstraintsExtension); +ExtensionFactory.register(asn1X509__namespace.id_ce_extKeyUsage, ExtendedKeyUsageExtension); +ExtensionFactory.register(asn1X509__namespace.id_ce_keyUsage, KeyUsagesExtension); +ExtensionFactory.register(asn1X509__namespace.id_ce_subjectKeyIdentifier, SubjectKeyIdentifierExtension); +ExtensionFactory.register(asn1X509__namespace.id_ce_authorityKeyIdentifier, AuthorityKeyIdentifierExtension); +ExtensionFactory.register(asn1X509__namespace.id_ce_subjectAltName, SubjectAlternativeNameExtension); +ExtensionFactory.register(asn1X509__namespace.id_ce_cRLDistributionPoints, CRLDistributionPointsExtension); +ExtensionFactory.register(asn1X509__namespace.id_pe_authorityInfoAccess, AuthorityInfoAccessExtension); +ExtensionFactory.register(asn1X509__namespace.id_ce_issuerAltName, IssuerAlternativeNameExtension); +AttributeFactory.register(asnPkcs9__namespace.id_pkcs9_at_challengePassword, ChallengePasswordAttribute); +AttributeFactory.register(asnPkcs9__namespace.id_pkcs9_at_extensionRequest, ExtensionsAttribute); +tsyringe.container.registerSingleton(diAsnSignatureFormatter, AsnDefaultSignatureFormatter); +tsyringe.container.registerSingleton(diAsnSignatureFormatter, AsnEcSignatureFormatter); +AsnEcSignatureFormatter.namedCurveSize.set("P-256", 32); +AsnEcSignatureFormatter.namedCurveSize.set("K-256", 32); +AsnEcSignatureFormatter.namedCurveSize.set("P-384", 48); +AsnEcSignatureFormatter.namedCurveSize.set("P-521", 66); + +exports.AlgorithmProvider = AlgorithmProvider; +exports.AsnData = AsnData; +exports.AsnDefaultSignatureFormatter = AsnDefaultSignatureFormatter; +exports.AsnEcSignatureFormatter = AsnEcSignatureFormatter; +exports.Attribute = Attribute; +exports.AttributeFactory = AttributeFactory; +exports.AuthorityInfoAccessExtension = AuthorityInfoAccessExtension; +exports.AuthorityKeyIdentifierExtension = AuthorityKeyIdentifierExtension; +exports.BasicConstraintsExtension = BasicConstraintsExtension; +exports.CRLDistributionPointsExtension = CRLDistributionPointsExtension; +exports.CertificatePolicyExtension = CertificatePolicyExtension; +exports.ChallengePasswordAttribute = ChallengePasswordAttribute; +exports.CryptoProvider = CryptoProvider; +exports.DN = DN; +exports.DNS = DNS; +exports.DefaultAlgorithmSerializer = DefaultAlgorithmSerializer; +exports.EMAIL = EMAIL; +exports.ExtendedKeyUsageExtension = ExtendedKeyUsageExtension; +exports.Extension = Extension; +exports.ExtensionFactory = ExtensionFactory; +exports.ExtensionsAttribute = ExtensionsAttribute; +exports.GUID = GUID; +exports.GeneralName = GeneralName; +exports.GeneralNames = GeneralNames; +exports.IP = IP; +exports.IssuerAlternativeNameExtension = IssuerAlternativeNameExtension; +exports.KeyUsagesExtension = KeyUsagesExtension; +exports.Name = Name; +exports.NameIdentifier = NameIdentifier; +exports.OidSerializer = OidSerializer; +exports.PemConverter = PemConverter; +exports.PemData = PemData; +exports.Pkcs10CertificateRequest = Pkcs10CertificateRequest; +exports.Pkcs10CertificateRequestGenerator = Pkcs10CertificateRequestGenerator; +exports.PublicKey = PublicKey; +exports.REGISTERED_ID = REGISTERED_ID; +exports.SubjectAlternativeNameExtension = SubjectAlternativeNameExtension; +exports.SubjectKeyIdentifierExtension = SubjectKeyIdentifierExtension; +exports.TextConverter = TextConverter; +exports.TextObject = TextObject; +exports.UPN = UPN; +exports.URL = URL; +exports.X509Certificate = X509Certificate; +exports.X509CertificateGenerator = X509CertificateGenerator; +exports.X509Certificates = X509Certificates; +exports.X509ChainBuilder = X509ChainBuilder; +exports.X509Crl = X509Crl; +exports.X509CrlEntry = X509CrlEntry; +exports.X509CrlGenerator = X509CrlGenerator; +exports.cryptoProvider = cryptoProvider; +exports.diAlgorithm = diAlgorithm; +exports.diAlgorithmProvider = diAlgorithmProvider; +exports.diAsnSignatureFormatter = diAsnSignatureFormatter; +exports.idEd25519 = idEd25519; +exports.idEd448 = idEd448; +exports.idX25519 = idX25519; +exports.idX448 = idX448; diff --git a/node_modules/@peculiar/x509/build/x509.es.js b/node_modules/@peculiar/x509/build/x509.es.js new file mode 100644 index 0000000000000000000000000000000000000000..c3059f43c9241a9ff106af312ca9fa971c8c79be --- /dev/null +++ b/node_modules/@peculiar/x509/build/x509.es.js @@ -0,0 +1,3368 @@ +/*! + * MIT License + * + * Copyright (c) Peculiar Ventures. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +import 'reflect-metadata'; +import { AsnConvert, OctetString, AsnUtf8StringConverter } from '@peculiar/asn1-schema'; +import * as asn1X509 from '@peculiar/asn1-x509'; +import { AlgorithmIdentifier, Extension as Extension$1, Name as Name$1, RelativeDistinguishedName, AttributeTypeAndValue, SubjectPublicKeyInfo, BasicConstraints, id_ce_basicConstraints, KeyUsage, id_ce_keyUsage, Attribute as Attribute$1, Version, Extensions, Certificate, id_ce_invalidityDate, InvalidityDate, id_ce_cRLReasons, CRLReason, RevokedCertificate, Time, CertificateList } from '@peculiar/asn1-x509'; +import { BufferSourceConverter, isEqual, Convert, combine } from 'pvtsutils'; +import { __decorate, __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib'; +import * as asn1Cms from '@peculiar/asn1-cms'; +import * as asn1Ecc from '@peculiar/asn1-ecc'; +import { id_ecPublicKey, ECDSASigValue } from '@peculiar/asn1-ecc'; +import * as asn1Rsa from '@peculiar/asn1-rsa'; +import { id_RSASSA_PSS, id_rsaEncryption, RSAPublicKey, id_sha512, id_sha384, id_sha256, id_sha1 } from '@peculiar/asn1-rsa'; +import { container, injectable } from 'tsyringe'; +import * as asnPkcs9 from '@peculiar/asn1-pkcs9'; +import { id_pkcs9_at_extensionRequest } from '@peculiar/asn1-pkcs9'; +import { CertificationRequest, CertificationRequestInfo } from '@peculiar/asn1-csr'; + +const diAlgorithm = "crypto.algorithm"; +class AlgorithmProvider { + getAlgorithms() { + return container.resolveAll(diAlgorithm); + } + toAsnAlgorithm(alg) { + ({ ...alg }); + for (const algorithm of this.getAlgorithms()) { + const res = algorithm.toAsnAlgorithm(alg); + if (res) { + return res; + } + } + if (/^[0-9.]+$/.test(alg.name)) { + const res = new AlgorithmIdentifier({ algorithm: alg.name }); + if ("parameters" in alg) { + const unknown = alg; + res.parameters = unknown.parameters; + } + return res; + } + throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm"); + } + toWebAlgorithm(alg) { + for (const algorithm of this.getAlgorithms()) { + const res = algorithm.toWebAlgorithm(alg); + if (res) { + return res; + } + } + const unknown = { + name: alg.algorithm, + parameters: alg.parameters, + }; + return unknown; + } +} +const diAlgorithmProvider = "crypto.algorithmProvider"; +container.registerSingleton(diAlgorithmProvider, AlgorithmProvider); + +var EcAlgorithm_1; +const idVersionOne = "1.3.36.3.3.2.8.1.1"; +const idBrainpoolP160r1 = `${idVersionOne}.1`; +const idBrainpoolP160t1 = `${idVersionOne}.2`; +const idBrainpoolP192r1 = `${idVersionOne}.3`; +const idBrainpoolP192t1 = `${idVersionOne}.4`; +const idBrainpoolP224r1 = `${idVersionOne}.5`; +const idBrainpoolP224t1 = `${idVersionOne}.6`; +const idBrainpoolP256r1 = `${idVersionOne}.7`; +const idBrainpoolP256t1 = `${idVersionOne}.8`; +const idBrainpoolP320r1 = `${idVersionOne}.9`; +const idBrainpoolP320t1 = `${idVersionOne}.10`; +const idBrainpoolP384r1 = `${idVersionOne}.11`; +const idBrainpoolP384t1 = `${idVersionOne}.12`; +const idBrainpoolP512r1 = `${idVersionOne}.13`; +const idBrainpoolP512t1 = `${idVersionOne}.14`; +const brainpoolP160r1 = "brainpoolP160r1"; +const brainpoolP160t1 = "brainpoolP160t1"; +const brainpoolP192r1 = "brainpoolP192r1"; +const brainpoolP192t1 = "brainpoolP192t1"; +const brainpoolP224r1 = "brainpoolP224r1"; +const brainpoolP224t1 = "brainpoolP224t1"; +const brainpoolP256r1 = "brainpoolP256r1"; +const brainpoolP256t1 = "brainpoolP256t1"; +const brainpoolP320r1 = "brainpoolP320r1"; +const brainpoolP320t1 = "brainpoolP320t1"; +const brainpoolP384r1 = "brainpoolP384r1"; +const brainpoolP384t1 = "brainpoolP384t1"; +const brainpoolP512r1 = "brainpoolP512r1"; +const brainpoolP512t1 = "brainpoolP512t1"; +const ECDSA = "ECDSA"; +let EcAlgorithm = EcAlgorithm_1 = class EcAlgorithm { + toAsnAlgorithm(alg) { + switch (alg.name.toLowerCase()) { + case ECDSA.toLowerCase(): + if ("hash" in alg) { + const hash = typeof alg.hash === "string" ? alg.hash : alg.hash.name; + switch (hash.toLowerCase()) { + case "sha-1": + return asn1Ecc.ecdsaWithSHA1; + case "sha-256": + return asn1Ecc.ecdsaWithSHA256; + case "sha-384": + return asn1Ecc.ecdsaWithSHA384; + case "sha-512": + return asn1Ecc.ecdsaWithSHA512; + } + } + else if ("namedCurve" in alg) { + let parameters = ""; + switch (alg.namedCurve) { + case "P-256": + parameters = asn1Ecc.id_secp256r1; + break; + case "K-256": + parameters = EcAlgorithm_1.SECP256K1; + break; + case "P-384": + parameters = asn1Ecc.id_secp384r1; + break; + case "P-521": + parameters = asn1Ecc.id_secp521r1; + break; + case brainpoolP160r1: + parameters = idBrainpoolP160r1; + break; + case brainpoolP160t1: + parameters = idBrainpoolP160t1; + break; + case brainpoolP192r1: + parameters = idBrainpoolP192r1; + break; + case brainpoolP192t1: + parameters = idBrainpoolP192t1; + break; + case brainpoolP224r1: + parameters = idBrainpoolP224r1; + break; + case brainpoolP224t1: + parameters = idBrainpoolP224t1; + break; + case brainpoolP256r1: + parameters = idBrainpoolP256r1; + break; + case brainpoolP256t1: + parameters = idBrainpoolP256t1; + break; + case brainpoolP320r1: + parameters = idBrainpoolP320r1; + break; + case brainpoolP320t1: + parameters = idBrainpoolP320t1; + break; + case brainpoolP384r1: + parameters = idBrainpoolP384r1; + break; + case brainpoolP384t1: + parameters = idBrainpoolP384t1; + break; + case brainpoolP512r1: + parameters = idBrainpoolP512r1; + break; + case brainpoolP512t1: + parameters = idBrainpoolP512t1; + break; + } + if (parameters) { + return new AlgorithmIdentifier({ + algorithm: asn1Ecc.id_ecPublicKey, + parameters: AsnConvert.serialize(new asn1Ecc.ECParameters({ namedCurve: parameters })), + }); + } + } + } + return null; + } + toWebAlgorithm(alg) { + switch (alg.algorithm) { + case asn1Ecc.id_ecdsaWithSHA1: + return { + name: ECDSA, hash: { name: "SHA-1" }, + }; + case asn1Ecc.id_ecdsaWithSHA256: + return { + name: ECDSA, hash: { name: "SHA-256" }, + }; + case asn1Ecc.id_ecdsaWithSHA384: + return { + name: ECDSA, hash: { name: "SHA-384" }, + }; + case asn1Ecc.id_ecdsaWithSHA512: + return { + name: ECDSA, hash: { name: "SHA-512" }, + }; + case asn1Ecc.id_ecPublicKey: { + if (!alg.parameters) { + throw new TypeError("Cannot get required parameters from EC algorithm"); + } + const parameters = AsnConvert.parse(alg.parameters, asn1Ecc.ECParameters); + switch (parameters.namedCurve) { + case asn1Ecc.id_secp256r1: + return { + name: ECDSA, namedCurve: "P-256", + }; + case EcAlgorithm_1.SECP256K1: + return { + name: ECDSA, namedCurve: "K-256", + }; + case asn1Ecc.id_secp384r1: + return { + name: ECDSA, namedCurve: "P-384", + }; + case asn1Ecc.id_secp521r1: + return { + name: ECDSA, namedCurve: "P-521", + }; + case idBrainpoolP160r1: + return { + name: ECDSA, namedCurve: brainpoolP160r1, + }; + case idBrainpoolP160t1: + return { + name: ECDSA, namedCurve: brainpoolP160t1, + }; + case idBrainpoolP192r1: + return { + name: ECDSA, namedCurve: brainpoolP192r1, + }; + case idBrainpoolP192t1: + return { + name: ECDSA, namedCurve: brainpoolP192t1, + }; + case idBrainpoolP224r1: + return { + name: ECDSA, namedCurve: brainpoolP224r1, + }; + case idBrainpoolP224t1: + return { + name: ECDSA, namedCurve: brainpoolP224t1, + }; + case idBrainpoolP256r1: + return { + name: ECDSA, namedCurve: brainpoolP256r1, + }; + case idBrainpoolP256t1: + return { + name: ECDSA, namedCurve: brainpoolP256t1, + }; + case idBrainpoolP320r1: + return { + name: ECDSA, namedCurve: brainpoolP320r1, + }; + case idBrainpoolP320t1: + return { + name: ECDSA, namedCurve: brainpoolP320t1, + }; + case idBrainpoolP384r1: + return { + name: ECDSA, namedCurve: brainpoolP384r1, + }; + case idBrainpoolP384t1: + return { + name: ECDSA, namedCurve: brainpoolP384t1, + }; + case idBrainpoolP512r1: + return { + name: ECDSA, namedCurve: brainpoolP512r1, + }; + case idBrainpoolP512t1: + return { + name: ECDSA, namedCurve: brainpoolP512t1, + }; + } + } + } + return null; + } +}; +EcAlgorithm.SECP256K1 = "1.3.132.0.10"; +EcAlgorithm = EcAlgorithm_1 = __decorate([ + injectable() +], EcAlgorithm); +container.registerSingleton(diAlgorithm, EcAlgorithm); + +const NAME = Symbol("name"); +const VALUE = Symbol("value"); +class TextObject { + constructor(name, items = {}, value = "") { + this[NAME] = name; + this[VALUE] = value; + for (const key in items) { + this[key] = items[key]; + } + } +} +TextObject.NAME = NAME; +TextObject.VALUE = VALUE; +class DefaultAlgorithmSerializer { + static toTextObject(alg) { + const obj = new TextObject("Algorithm Identifier", {}, OidSerializer.toString(alg.algorithm)); + if (alg.parameters) { + switch (alg.algorithm) { + case asn1Ecc.id_ecPublicKey: { + const ecAlg = new EcAlgorithm().toWebAlgorithm(alg); + if (ecAlg && "namedCurve" in ecAlg) { + obj["Named Curve"] = ecAlg.namedCurve; + } + else { + obj["Parameters"] = alg.parameters; + } + break; + } + default: + obj["Parameters"] = alg.parameters; + } + } + return obj; + } +} +class OidSerializer { + static toString(oid) { + const name = this.items[oid]; + if (name) { + return name; + } + return oid; + } +} +OidSerializer.items = { + [asn1Rsa.id_sha1]: "sha1", + [asn1Rsa.id_sha224]: "sha224", + [asn1Rsa.id_sha256]: "sha256", + [asn1Rsa.id_sha384]: "sha384", + [asn1Rsa.id_sha512]: "sha512", + [asn1Rsa.id_rsaEncryption]: "rsaEncryption", + [asn1Rsa.id_sha1WithRSAEncryption]: "sha1WithRSAEncryption", + [asn1Rsa.id_sha224WithRSAEncryption]: "sha224WithRSAEncryption", + [asn1Rsa.id_sha256WithRSAEncryption]: "sha256WithRSAEncryption", + [asn1Rsa.id_sha384WithRSAEncryption]: "sha384WithRSAEncryption", + [asn1Rsa.id_sha512WithRSAEncryption]: "sha512WithRSAEncryption", + [asn1Ecc.id_ecPublicKey]: "ecPublicKey", + [asn1Ecc.id_ecdsaWithSHA1]: "ecdsaWithSHA1", + [asn1Ecc.id_ecdsaWithSHA224]: "ecdsaWithSHA224", + [asn1Ecc.id_ecdsaWithSHA256]: "ecdsaWithSHA256", + [asn1Ecc.id_ecdsaWithSHA384]: "ecdsaWithSHA384", + [asn1Ecc.id_ecdsaWithSHA512]: "ecdsaWithSHA512", + [asn1X509.id_kp_serverAuth]: "TLS WWW server authentication", + [asn1X509.id_kp_clientAuth]: "TLS WWW client authentication", + [asn1X509.id_kp_codeSigning]: "Code Signing", + [asn1X509.id_kp_emailProtection]: "E-mail Protection", + [asn1X509.id_kp_timeStamping]: "Time Stamping", + [asn1X509.id_kp_OCSPSigning]: "OCSP Signing", + [asn1Cms.id_signedData]: "Signed Data", +}; +class TextConverter { + static serialize(obj) { + return this.serializeObj(obj).join("\n"); + } + static pad(deep = 0) { + return "".padStart(2 * deep, " "); + } + static serializeObj(obj, deep = 0) { + const res = []; + let pad = this.pad(deep++); + let value = ""; + const objValue = obj[TextObject.VALUE]; + if (objValue) { + value = ` ${objValue}`; + } + res.push(`${pad}${obj[TextObject.NAME]}:${value}`); + pad = this.pad(deep); + for (const key in obj) { + if (typeof key === "symbol") { + continue; + } + const value = obj[key]; + const keyValue = key ? `${key}: ` : ""; + if (typeof value === "string" + || typeof value === "number" + || typeof value === "boolean") { + res.push(`${pad}${keyValue}${value}`); + } + else if (value instanceof Date) { + res.push(`${pad}${keyValue}${value.toUTCString()}`); + } + else if (Array.isArray(value)) { + for (const obj of value) { + obj[TextObject.NAME] = key; + res.push(...this.serializeObj(obj, deep)); + } + } + else if (value instanceof TextObject) { + value[TextObject.NAME] = key; + res.push(...this.serializeObj(value, deep)); + } + else if (BufferSourceConverter.isBufferSource(value)) { + if (key) { + res.push(`${pad}${keyValue}`); + res.push(...this.serializeBufferSource(value, deep + 1)); + } + else { + res.push(...this.serializeBufferSource(value, deep)); + } + } + else if ("toTextObject" in value) { + const obj = value.toTextObject(); + obj[TextObject.NAME] = key; + res.push(...this.serializeObj(obj, deep)); + } + else { + throw new TypeError("Cannot serialize data in text format. Unsupported type."); + } + } + return res; + } + static serializeBufferSource(buffer, deep = 0) { + const pad = this.pad(deep); + const view = BufferSourceConverter.toUint8Array(buffer); + const res = []; + for (let i = 0; i < view.length;) { + const row = []; + for (let j = 0; j < 16 && i < view.length; j++) { + if (j === 8) { + row.push(""); + } + const hex = view[i++].toString(16).padStart(2, "0"); + row.push(hex); + } + res.push(`${pad}${row.join(" ")}`); + } + return res; + } + static serializeAlgorithm(alg) { + return this.algorithmSerializer.toTextObject(alg); + } +} +TextConverter.oidSerializer = OidSerializer; +TextConverter.algorithmSerializer = DefaultAlgorithmSerializer; + +var _AsnData_rawData; +class AsnData { + get rawData() { + if (!__classPrivateFieldGet(this, _AsnData_rawData, "f")) { + __classPrivateFieldSet(this, _AsnData_rawData, AsnConvert.serialize(this.asn), "f"); + } + return __classPrivateFieldGet(this, _AsnData_rawData, "f"); + } + constructor(...args) { + _AsnData_rawData.set(this, void 0); + if (BufferSourceConverter.isBufferSource(args[0])) { + this.asn = AsnConvert.parse(args[0], args[1]); + __classPrivateFieldSet(this, _AsnData_rawData, BufferSourceConverter.toArrayBuffer(args[0]), "f"); + this.onInit(this.asn); + } + else { + this.asn = args[0]; + this.onInit(this.asn); + } + } + equal(data) { + if (data instanceof AsnData) { + return isEqual(data.rawData, this.rawData); + } + return false; + } + toString(format = "text") { + switch (format) { + case "asn": + return AsnConvert.toString(this.rawData); + case "text": + return TextConverter.serialize(this.toTextObject()); + case "hex": + return Convert.ToHex(this.rawData); + case "base64": + return Convert.ToBase64(this.rawData); + case "base64url": + return Convert.ToBase64Url(this.rawData); + default: + throw TypeError("Argument 'format' is unsupported value"); + } + } + getTextName() { + const constructor = this.constructor; + return constructor.NAME; + } + toTextObject() { + const obj = this.toTextObjectEmpty(); + obj[""] = this.rawData; + return obj; + } + toTextObjectEmpty(value) { + return new TextObject(this.getTextName(), {}, value); + } +} +_AsnData_rawData = new WeakMap(); +AsnData.NAME = "ASN"; + +class Extension extends AsnData { + constructor(...args) { + let raw; + if (BufferSourceConverter.isBufferSource(args[0])) { + raw = BufferSourceConverter.toArrayBuffer(args[0]); + } + else { + raw = AsnConvert.serialize(new Extension$1({ + extnID: args[0], + critical: args[1], + extnValue: new OctetString(BufferSourceConverter.toArrayBuffer(args[2])), + })); + } + super(raw, Extension$1); + } + onInit(asn) { + this.type = asn.extnID; + this.critical = asn.critical; + this.value = asn.extnValue.buffer; + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj[""] = this.value; + return obj; + } + toTextObjectWithoutValue() { + const obj = this.toTextObjectEmpty(this.critical ? "critical" : undefined); + if (obj[TextObject.NAME] === Extension.NAME) { + obj[TextObject.NAME] = OidSerializer.toString(this.type); + } + return obj; + } +} + +var _a; +class CryptoProvider { + static isCryptoKeyPair(data) { + return data && data.privateKey && data.publicKey; + } + static isCryptoKey(data) { + return data && data.usages && data.type && data.algorithm && data.extractable !== undefined; + } + constructor() { + this.items = new Map(); + this[_a] = "CryptoProvider"; + if (typeof self !== "undefined" && typeof crypto !== "undefined") { + this.set(CryptoProvider.DEFAULT, crypto); + } + else if (typeof global !== "undefined" && global.crypto && global.crypto.subtle) { + this.set(CryptoProvider.DEFAULT, global.crypto); + } + } + clear() { + this.items.clear(); + } + delete(key) { + return this.items.delete(key); + } + forEach(callbackfn, thisArg) { + return this.items.forEach(callbackfn, thisArg); + } + has(key) { + return this.items.has(key); + } + get size() { + return this.items.size; + } + entries() { + return this.items.entries(); + } + keys() { + return this.items.keys(); + } + values() { + return this.items.values(); + } + [Symbol.iterator]() { + return this.items[Symbol.iterator](); + } + get(key = CryptoProvider.DEFAULT) { + const crypto = this.items.get(key.toLowerCase()); + if (!crypto) { + throw new Error(`Cannot get Crypto by name '${key}'`); + } + return crypto; + } + set(key, value) { + if (typeof key === "string") { + if (!value) { + throw new TypeError("Argument 'value' is required"); + } + this.items.set(key.toLowerCase(), value); + } + else { + this.items.set(CryptoProvider.DEFAULT, key); + } + return this; + } +} +_a = Symbol.toStringTag; +CryptoProvider.DEFAULT = "default"; +const cryptoProvider = new CryptoProvider(); + +const OID_REGEX = /^[0-2](?:\.[1-9][0-9]*)+$/; +function isOID(id) { + return new RegExp(OID_REGEX).test(id); +} +class NameIdentifier { + constructor(names = {}) { + this.items = {}; + for (const id in names) { + this.register(id, names[id]); + } + } + get(idOrName) { + return this.items[idOrName] || null; + } + findId(idOrName) { + if (!isOID(idOrName)) { + return this.get(idOrName); + } + return idOrName; + } + register(id, name) { + this.items[id] = name; + this.items[name] = id; + } +} +const names = new NameIdentifier(); +names.register("CN", "2.5.4.3"); +names.register("L", "2.5.4.7"); +names.register("ST", "2.5.4.8"); +names.register("O", "2.5.4.10"); +names.register("OU", "2.5.4.11"); +names.register("C", "2.5.4.6"); +names.register("DC", "0.9.2342.19200300.100.1.25"); +names.register("E", "1.2.840.113549.1.9.1"); +names.register("G", "2.5.4.42"); +names.register("I", "2.5.4.43"); +names.register("SN", "2.5.4.4"); +names.register("T", "2.5.4.12"); +function replaceUnknownCharacter(text, char) { + return `\\${Convert.ToHex(Convert.FromUtf8String(char)).toUpperCase()}`; +} +function escape(data) { + return data + .replace(/([,+"\\<>;])/g, "\\$1") + .replace(/^([ #])/, "\\$1") + .replace(/([ ]$)/, "\\$1") + .replace(/([\r\n\t])/, replaceUnknownCharacter); +} +class Name { + static isASCII(text) { + for (let i = 0; i < text.length; i++) { + const code = text.charCodeAt(i); + if (code > 0xFF) { + return false; + } + } + return true; + } + static isPrintableString(text) { + return /^[A-Za-z0-9 '()+,-./:=?]*$/g.test(text); + } + constructor(data, extraNames = {}) { + this.extraNames = new NameIdentifier(); + this.asn = new Name$1(); + for (const key in extraNames) { + if (Object.prototype.hasOwnProperty.call(extraNames, key)) { + const value = extraNames[key]; + this.extraNames.register(key, value); + } + } + if (typeof data === "string") { + this.asn = this.fromString(data); + } + else if (data instanceof Name$1) { + this.asn = data; + } + else if (BufferSourceConverter.isBufferSource(data)) { + this.asn = AsnConvert.parse(data, Name$1); + } + else { + this.asn = this.fromJSON(data); + } + } + getField(idOrName) { + const id = this.extraNames.findId(idOrName) || names.findId(idOrName); + const res = []; + for (const name of this.asn) { + for (const rdn of name) { + if (rdn.type === id) { + res.push(rdn.value.toString()); + } + } + } + return res; + } + getName(idOrName) { + return this.extraNames.get(idOrName) || names.get(idOrName); + } + toString() { + return this.asn.map((rdn) => rdn.map((o) => { + const type = this.getName(o.type) || o.type; + const value = o.value.anyValue + ? `#${Convert.ToHex(o.value.anyValue)}` + : escape(o.value.toString()); + return `${type}=${value}`; + }) + .join("+")) + .join(", "); + } + toJSON() { + var _a; + const json = []; + for (const rdn of this.asn) { + const jsonItem = {}; + for (const attr of rdn) { + const type = this.getName(attr.type) || attr.type; + (_a = jsonItem[type]) !== null && _a !== void 0 ? _a : (jsonItem[type] = []); + jsonItem[type].push(attr.value.anyValue ? `#${Convert.ToHex(attr.value.anyValue)}` : attr.value.toString()); + } + json.push(jsonItem); + } + return json; + } + fromString(data) { + const asn = new Name$1(); + const regex = /(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+"\\](?=[,+]|$))|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g; + let matches = null; + let level = ","; + while (matches = regex.exec(`${data},`)) { + let [, type, value] = matches; + const lastChar = value[value.length - 1]; + if (lastChar === "," || lastChar === "+") { + value = value.slice(0, value.length - 1); + matches[3] = lastChar; + } + const next = matches[3]; + type = this.getTypeOid(type); + const attr = this.createAttribute(type, value); + if (level === "+") { + asn[asn.length - 1].push(attr); + } + else { + asn.push(new RelativeDistinguishedName([attr])); + } + level = next; + } + return asn; + } + fromJSON(data) { + const asn = new Name$1(); + for (const item of data) { + const asnRdn = new RelativeDistinguishedName(); + for (const type in item) { + const typeId = this.getTypeOid(type); + const values = item[type]; + for (const value of values) { + const asnAttr = this.createAttribute(typeId, value); + asnRdn.push(asnAttr); + } + } + asn.push(asnRdn); + } + return asn; + } + getTypeOid(type) { + if (!/[\d.]+/.test(type)) { + type = this.getName(type) || ""; + } + if (!type) { + throw new Error(`Cannot get OID for name type '${type}'`); + } + return type; + } + createAttribute(type, value) { + const attr = new AttributeTypeAndValue({ type }); + if (typeof value === "object") { + for (const key in value) { + switch (key) { + case "ia5String": + attr.value.ia5String = value[key]; + break; + case "utf8String": + attr.value.utf8String = value[key]; + break; + case "universalString": + attr.value.universalString = value[key]; + break; + case "bmpString": + attr.value.bmpString = value[key]; + break; + case "printableString": + attr.value.printableString = value[key]; + break; + } + } + } + else if (value[0] === "#") { + attr.value.anyValue = Convert.FromHex(value.slice(1)); + } + else { + const processedValue = this.processStringValue(value); + if (type === this.getName("E") || type === this.getName("DC")) { + attr.value.ia5String = processedValue; + } + else { + if (Name.isPrintableString(processedValue)) { + attr.value.printableString = processedValue; + } + else { + attr.value.utf8String = processedValue; + } + } + } + return attr; + } + processStringValue(value) { + const quotedMatches = /"(.*?[^\\])?"/.exec(value); + if (quotedMatches) { + value = quotedMatches[1]; + } + return value + .replace(/\\0a/ig, "\n") + .replace(/\\0d/ig, "\r") + .replace(/\\0g/ig, "\t") + .replace(/\\(.)/g, "$1"); + } + toArrayBuffer() { + return AsnConvert.serialize(this.asn); + } + async getThumbprint(...args) { + var _a; + let crypto; + let algorithm = "SHA-1"; + if (args.length >= 1 && !((_a = args[0]) === null || _a === void 0 ? void 0 : _a.subtle)) { + algorithm = args[0] || algorithm; + crypto = args[1] || cryptoProvider.get(); + } + else { + crypto = args[0] || cryptoProvider.get(); + } + return await crypto.subtle.digest(algorithm, this.toArrayBuffer()); + } +} + +const ERR_GN_CONSTRUCTOR = "Cannot initialize GeneralName from ASN.1 data."; +const ERR_GN_STRING_FORMAT = `${ERR_GN_CONSTRUCTOR} Unsupported string format in use.`; +const ERR_GUID = `${ERR_GN_CONSTRUCTOR} Value doesn't match to GUID regular expression.`; +const GUID_REGEX = /^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i; +const id_GUID = "1.3.6.1.4.1.311.25.1"; +const id_UPN = "1.3.6.1.4.1.311.20.2.3"; +const DNS = "dns"; +const DN = "dn"; +const EMAIL = "email"; +const IP = "ip"; +const URL = "url"; +const GUID = "guid"; +const UPN = "upn"; +const REGISTERED_ID = "id"; +class GeneralName extends AsnData { + constructor(...args) { + let name; + if (args.length === 2) { + switch (args[0]) { + case DN: { + const derName = new Name(args[1]).toArrayBuffer(); + const asnName = AsnConvert.parse(derName, asn1X509.Name); + name = new asn1X509.GeneralName({ directoryName: asnName }); + break; + } + case DNS: + name = new asn1X509.GeneralName({ dNSName: args[1] }); + break; + case EMAIL: + name = new asn1X509.GeneralName({ rfc822Name: args[1] }); + break; + case GUID: { + const matches = new RegExp(GUID_REGEX, "i").exec(args[1]); + if (!matches) { + throw new Error("Cannot parse GUID value. Value doesn't match to regular expression"); + } + const hex = matches + .slice(1) + .map((o, i) => { + if (i < 3) { + return Convert.ToHex(new Uint8Array(Convert.FromHex(o)).reverse()); + } + return o; + }) + .join(""); + name = new asn1X509.GeneralName({ + otherName: new asn1X509.OtherName({ + typeId: id_GUID, + value: AsnConvert.serialize(new OctetString(Convert.FromHex(hex))), + }), + }); + break; + } + case IP: + name = new asn1X509.GeneralName({ iPAddress: args[1] }); + break; + case REGISTERED_ID: + name = new asn1X509.GeneralName({ registeredID: args[1] }); + break; + case UPN: { + name = new asn1X509.GeneralName({ + otherName: new asn1X509.OtherName({ + typeId: id_UPN, + value: AsnConvert.serialize(AsnUtf8StringConverter.toASN(args[1])), + }), + }); + break; + } + case URL: + name = new asn1X509.GeneralName({ uniformResourceIdentifier: args[1] }); + break; + default: + throw new Error("Cannot create GeneralName. Unsupported type of the name"); + } + } + else if (BufferSourceConverter.isBufferSource(args[0])) { + name = AsnConvert.parse(args[0], asn1X509.GeneralName); + } + else { + name = args[0]; + } + super(name); + } + onInit(asn) { + if (asn.dNSName != undefined) { + this.type = DNS; + this.value = asn.dNSName; + } + else if (asn.rfc822Name != undefined) { + this.type = EMAIL; + this.value = asn.rfc822Name; + } + else if (asn.iPAddress != undefined) { + this.type = IP; + this.value = asn.iPAddress; + } + else if (asn.uniformResourceIdentifier != undefined) { + this.type = URL; + this.value = asn.uniformResourceIdentifier; + } + else if (asn.registeredID != undefined) { + this.type = REGISTERED_ID; + this.value = asn.registeredID; + } + else if (asn.directoryName != undefined) { + this.type = DN; + this.value = new Name(asn.directoryName).toString(); + } + else if (asn.otherName != undefined) { + if (asn.otherName.typeId === id_GUID) { + this.type = GUID; + const guid = AsnConvert.parse(asn.otherName.value, OctetString); + const matches = new RegExp(GUID_REGEX, "i").exec(Convert.ToHex(guid)); + if (!matches) { + throw new Error(ERR_GUID); + } + this.value = matches + .slice(1) + .map((o, i) => { + if (i < 3) { + return Convert.ToHex(new Uint8Array(Convert.FromHex(o)).reverse()); + } + return o; + }) + .join("-"); + } + else if (asn.otherName.typeId === id_UPN) { + this.type = UPN; + this.value = AsnConvert.parse(asn.otherName.value, asn1X509.DirectoryString).toString(); + } + else { + throw new Error(ERR_GN_STRING_FORMAT); + } + } + else { + throw new Error(ERR_GN_STRING_FORMAT); + } + } + toJSON() { + return { + type: this.type, + value: this.value, + }; + } + toTextObject() { + let type; + switch (this.type) { + case DN: + case DNS: + case GUID: + case IP: + case REGISTERED_ID: + case UPN: + case URL: + type = this.type.toUpperCase(); + break; + case EMAIL: + type = "Email"; + break; + default: + throw new Error("Unsupported GeneralName type"); + } + let value = this.value; + if (this.type === REGISTERED_ID) { + value = OidSerializer.toString(value); + } + return new TextObject(type, undefined, value); + } +} +class GeneralNames extends AsnData { + constructor(params) { + let names; + if (params instanceof asn1X509.GeneralNames) { + names = params; + } + else if (Array.isArray(params)) { + const items = []; + for (const name of params) { + if (name instanceof asn1X509.GeneralName) { + items.push(name); + } + else { + const asnName = AsnConvert.parse(new GeneralName(name.type, name.value).rawData, asn1X509.GeneralName); + items.push(asnName); + } + } + names = new asn1X509.GeneralNames(items); + } + else if (BufferSourceConverter.isBufferSource(params)) { + names = AsnConvert.parse(params, asn1X509.GeneralNames); + } + else { + throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments"); + } + super(names); + } + onInit(asn) { + const items = []; + for (const asnName of asn) { + let name = null; + try { + name = new GeneralName(asnName); + } + catch { + continue; + } + items.push(name); + } + this.items = items; + } + toJSON() { + return this.items.map((o) => o.toJSON()); + } + toTextObject() { + const res = super.toTextObjectEmpty(); + for (const name of this.items) { + const nameObj = name.toTextObject(); + let field = res[nameObj[TextObject.NAME]]; + if (!Array.isArray(field)) { + field = []; + res[nameObj[TextObject.NAME]] = field; + } + field.push(nameObj); + } + return res; + } +} +GeneralNames.NAME = "GeneralNames"; + +const rPaddingTag = "-{5}"; +const rEolChars = "\\n"; +const rNameTag = `[^${rEolChars}]+`; +const rBeginTag = `${rPaddingTag}BEGIN (${rNameTag}(?=${rPaddingTag}))${rPaddingTag}`; +const rEndTag = `${rPaddingTag}END \\1${rPaddingTag}`; +const rEolGroup = "\\n"; +const rHeaderKey = `[^:${rEolChars}]+`; +const rHeaderValue = `(?:[^${rEolChars}]+${rEolGroup}(?: +[^${rEolChars}]+${rEolGroup})*)`; +const rBase64Chars = "[a-zA-Z0-9=+/]+"; +const rBase64 = `(?:${rBase64Chars}${rEolGroup})+`; +const rPem = `${rBeginTag}${rEolGroup}(?:((?:${rHeaderKey}: ${rHeaderValue})+))?${rEolGroup}?(${rBase64})${rEndTag}`; +class PemConverter { + static isPem(data) { + return typeof data === "string" + && new RegExp(rPem, "g").test(data.replace(/\r/g, "")); + } + static decodeWithHeaders(pem) { + pem = pem.replace(/\r/g, ""); + const pattern = new RegExp(rPem, "g"); + const res = []; + let matches = null; + while (matches = pattern.exec(pem)) { + const base64 = matches[3] + .replace(new RegExp(`[${rEolChars}]+`, "g"), ""); + const pemStruct = { + type: matches[1], + headers: [], + rawData: Convert.FromBase64(base64), + }; + const headersString = matches[2]; + if (headersString) { + const headers = headersString.split(new RegExp(rEolGroup, "g")); + let lastHeader = null; + for (const header of headers) { + const [key, value] = header.split(/:(.*)/); + if (value === undefined) { + if (!lastHeader) { + throw new Error("Cannot parse PEM string. Incorrect header value"); + } + lastHeader.value += key.trim(); + } + else { + if (lastHeader) { + pemStruct.headers.push(lastHeader); + } + lastHeader = { + key, value: value.trim(), + }; + } + } + if (lastHeader) { + pemStruct.headers.push(lastHeader); + } + } + res.push(pemStruct); + } + return res; + } + static decode(pem) { + const blocks = this.decodeWithHeaders(pem); + return blocks.map((o) => o.rawData); + } + static decodeFirst(pem) { + const items = this.decode(pem); + if (!items.length) { + throw new RangeError("PEM string doesn't contain any objects"); + } + return items[0]; + } + static encode(rawData, tag) { + if (Array.isArray(rawData)) { + const raws = new Array(); + if (tag) { + rawData.forEach((element) => { + if (!BufferSourceConverter.isBufferSource(element)) { + throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource"); + } + raws.push(this.encodeStruct({ + type: tag, + rawData: BufferSourceConverter.toArrayBuffer(element), + })); + }); + } + else { + rawData.forEach((element) => { + if (!("type" in element)) { + throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut"); + } + raws.push(this.encodeStruct(element)); + }); + } + return raws.join("\n"); + } + else { + if (!tag) { + throw new Error("Required argument 'tag' is missed"); + } + return this.encodeStruct({ + type: tag, + rawData: BufferSourceConverter.toArrayBuffer(rawData), + }); + } + } + static encodeStruct(pem) { + var _a; + const upperCaseType = pem.type.toLocaleUpperCase(); + const res = []; + res.push(`-----BEGIN ${upperCaseType}-----`); + if ((_a = pem.headers) === null || _a === void 0 ? void 0 : _a.length) { + for (const header of pem.headers) { + res.push(`${header.key}: ${header.value}`); + } + res.push(""); + } + const base64 = Convert.ToBase64(pem.rawData); + let sliced; + let offset = 0; + const rows = Array(); + while (offset < base64.length) { + if (base64.length - offset < 64) { + sliced = base64.substring(offset); + } + else { + sliced = base64.substring(offset, offset + 64); + offset += 64; + } + if (sliced.length !== 0) { + rows.push(sliced); + if (sliced.length < 64) { + break; + } + } + else { + break; + } + } + res.push(...rows); + res.push(`-----END ${upperCaseType}-----`); + return res.join("\n"); + } +} +PemConverter.CertificateTag = "CERTIFICATE"; +PemConverter.CrlTag = "CRL"; +PemConverter.CertificateRequestTag = "CERTIFICATE REQUEST"; +PemConverter.PublicKeyTag = "PUBLIC KEY"; +PemConverter.PrivateKeyTag = "PRIVATE KEY"; + +class PemData extends AsnData { + static isAsnEncoded(data) { + return BufferSourceConverter.isBufferSource(data) || typeof data === "string"; + } + static toArrayBuffer(raw) { + if (typeof raw === "string") { + if (PemConverter.isPem(raw)) { + return PemConverter.decode(raw)[0]; + } + else if (Convert.isHex(raw)) { + return Convert.FromHex(raw); + } + else if (Convert.isBase64(raw)) { + return Convert.FromBase64(raw); + } + else if (Convert.isBase64Url(raw)) { + return Convert.FromBase64Url(raw); + } + else { + throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url"); + } + } + else { + const buffer = BufferSourceConverter.toUint8Array(raw); + if (buffer.length > 0 && buffer[0] === 0x30) { + return BufferSourceConverter.toArrayBuffer(raw); + } + const stringRaw = Convert.ToBinary(raw); + if (PemConverter.isPem(stringRaw)) { + return PemConverter.decode(stringRaw)[0]; + } + else if (Convert.isHex(stringRaw)) { + return Convert.FromHex(stringRaw); + } + else if (Convert.isBase64(stringRaw)) { + return Convert.FromBase64(stringRaw); + } + else if (Convert.isBase64Url(stringRaw)) { + return Convert.FromBase64Url(stringRaw); + } + throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url"); + } + } + constructor(...args) { + if (PemData.isAsnEncoded(args[0])) { + super(PemData.toArrayBuffer(args[0]), args[1]); + } + else { + super(args[0]); + } + } + toString(format = "pem") { + switch (format) { + case "pem": + return PemConverter.encode(this.rawData, this.tag); + default: + return super.toString(format); + } + } +} + +class PublicKey extends PemData { + static async create(data, crypto = cryptoProvider.get()) { + if (data instanceof PublicKey) { + return data; + } + else if (CryptoProvider.isCryptoKey(data)) { + if (data.type !== "public") { + throw new TypeError("Public key is required"); + } + const spki = await crypto.subtle.exportKey("spki", data); + return new PublicKey(spki); + } + else if (data.publicKey) { + return data.publicKey; + } + else if (BufferSourceConverter.isBufferSource(data)) { + return new PublicKey(data); + } + else { + throw new TypeError("Unsupported PublicKeyType"); + } + } + constructor(param) { + if (PemData.isAsnEncoded(param)) { + super(param, SubjectPublicKeyInfo); + } + else { + super(param); + } + this.tag = PemConverter.PublicKeyTag; + } + async export(...args) { + let crypto; + let keyUsages = ["verify"]; + let algorithm = { + hash: "SHA-256", ...this.algorithm, + }; + if (args.length > 1) { + algorithm = args[0] || algorithm; + keyUsages = args[1] || keyUsages; + crypto = args[2] || cryptoProvider.get(); + } + else { + crypto = args[0] || cryptoProvider.get(); + } + let raw = this.rawData; + const asnSpki = AsnConvert.parse(this.rawData, SubjectPublicKeyInfo); + if (asnSpki.algorithm.algorithm === id_RSASSA_PSS) { + raw = convertSpkiToRsaPkcs1(asnSpki, raw); + } + return crypto.subtle.importKey("spki", raw, algorithm, true, keyUsages); + } + onInit(asn) { + const algProv = container.resolve(diAlgorithmProvider); + const algorithm = this.algorithm = algProv.toWebAlgorithm(asn.algorithm); + switch (asn.algorithm.algorithm) { + case id_rsaEncryption: + { + const rsaPublicKey = AsnConvert.parse(asn.subjectPublicKey, RSAPublicKey); + const modulus = BufferSourceConverter.toUint8Array(rsaPublicKey.modulus); + algorithm.publicExponent = BufferSourceConverter.toUint8Array(rsaPublicKey.publicExponent); + algorithm.modulusLength = (!modulus[0] ? modulus.slice(1) : modulus).byteLength << 3; + break; + } + } + } + async getThumbprint(...args) { + var _a; + let crypto; + let algorithm = "SHA-1"; + if (args.length >= 1 && !((_a = args[0]) === null || _a === void 0 ? void 0 : _a.subtle)) { + algorithm = args[0] || algorithm; + crypto = args[1] || cryptoProvider.get(); + } + else { + crypto = args[0] || cryptoProvider.get(); + } + return await crypto.subtle.digest(algorithm, this.rawData); + } + async getKeyIdentifier(...args) { + let crypto; + let algorithm = "SHA-1"; + if (args.length === 1) { + if (typeof args[0] === "string") { + algorithm = args[0]; + crypto = cryptoProvider.get(); + } + else { + crypto = args[0]; + } + } + else if (args.length === 2) { + algorithm = args[0]; + crypto = args[1]; + } + else { + crypto = cryptoProvider.get(); + } + const asn = AsnConvert.parse(this.rawData, SubjectPublicKeyInfo); + return await crypto.subtle.digest(algorithm, asn.subjectPublicKey); + } + toTextObject() { + const obj = this.toTextObjectEmpty(); + const asn = AsnConvert.parse(this.rawData, SubjectPublicKeyInfo); + obj["Algorithm"] = TextConverter.serializeAlgorithm(asn.algorithm); + switch (asn.algorithm.algorithm) { + case id_ecPublicKey: + obj["EC Point"] = asn.subjectPublicKey; + break; + case id_rsaEncryption: + default: + obj["Raw Data"] = asn.subjectPublicKey; + } + return obj; + } +} +function convertSpkiToRsaPkcs1(asnSpki, raw) { + asnSpki.algorithm = new AlgorithmIdentifier({ + algorithm: id_rsaEncryption, + parameters: null, + }); + raw = AsnConvert.serialize(asnSpki); + return raw; +} + +class AuthorityKeyIdentifierExtension extends Extension { + static async create(param, critical = false, crypto = cryptoProvider.get()) { + if ("name" in param && "serialNumber" in param) { + return new AuthorityKeyIdentifierExtension(param, critical); + } + const key = await PublicKey.create(param, crypto); + const id = await key.getKeyIdentifier(crypto); + return new AuthorityKeyIdentifierExtension(Convert.ToHex(id), critical); + } + constructor(...args) { + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else if (typeof args[0] === "string") { + const value = new asn1X509.AuthorityKeyIdentifier({ keyIdentifier: new asn1X509.KeyIdentifier(Convert.FromHex(args[0])) }); + super(asn1X509.id_ce_authorityKeyIdentifier, args[1], AsnConvert.serialize(value)); + } + else { + const certId = args[0]; + const certIdName = certId.name instanceof GeneralNames + ? AsnConvert.parse(certId.name.rawData, asn1X509.GeneralNames) + : certId.name; + const value = new asn1X509.AuthorityKeyIdentifier({ + authorityCertIssuer: certIdName, + authorityCertSerialNumber: Convert.FromHex(certId.serialNumber), + }); + super(asn1X509.id_ce_authorityKeyIdentifier, args[1], AsnConvert.serialize(value)); + } + } + onInit(asn) { + super.onInit(asn); + const aki = AsnConvert.parse(asn.extnValue, asn1X509.AuthorityKeyIdentifier); + if (aki.keyIdentifier) { + this.keyId = Convert.ToHex(aki.keyIdentifier); + } + if (aki.authorityCertIssuer || aki.authorityCertSerialNumber) { + this.certId = { + name: aki.authorityCertIssuer || [], + serialNumber: aki.authorityCertSerialNumber ? Convert.ToHex(aki.authorityCertSerialNumber) : "", + }; + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const asn = AsnConvert.parse(this.value, asn1X509.AuthorityKeyIdentifier); + if (asn.authorityCertIssuer) { + obj["Authority Issuer"] = new GeneralNames(asn.authorityCertIssuer).toTextObject(); + } + if (asn.authorityCertSerialNumber) { + obj["Authority Serial Number"] = asn.authorityCertSerialNumber; + } + if (asn.keyIdentifier) { + obj[""] = asn.keyIdentifier; + } + return obj; + } +} +AuthorityKeyIdentifierExtension.NAME = "Authority Key Identifier"; + +class BasicConstraintsExtension extends Extension { + constructor(...args) { + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + const value = AsnConvert.parse(this.value, BasicConstraints); + this.ca = value.cA; + this.pathLength = value.pathLenConstraint; + } + else { + const value = new BasicConstraints({ + cA: args[0], + pathLenConstraint: args[1], + }); + super(id_ce_basicConstraints, args[2], AsnConvert.serialize(value)); + this.ca = args[0]; + this.pathLength = args[1]; + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + if (this.ca) { + obj["CA"] = this.ca; + } + if (this.pathLength !== undefined) { + obj["Path Length"] = this.pathLength; + } + return obj; + } +} +BasicConstraintsExtension.NAME = "Basic Constraints"; + +var ExtendedKeyUsage; +(function (ExtendedKeyUsage) { + ExtendedKeyUsage["serverAuth"] = "1.3.6.1.5.5.7.3.1"; + ExtendedKeyUsage["clientAuth"] = "1.3.6.1.5.5.7.3.2"; + ExtendedKeyUsage["codeSigning"] = "1.3.6.1.5.5.7.3.3"; + ExtendedKeyUsage["emailProtection"] = "1.3.6.1.5.5.7.3.4"; + ExtendedKeyUsage["timeStamping"] = "1.3.6.1.5.5.7.3.8"; + ExtendedKeyUsage["ocspSigning"] = "1.3.6.1.5.5.7.3.9"; +})(ExtendedKeyUsage || (ExtendedKeyUsage = {})); +class ExtendedKeyUsageExtension extends Extension { + constructor(...args) { + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + const value = AsnConvert.parse(this.value, asn1X509.ExtendedKeyUsage); + this.usages = value.map((o) => o); + } + else { + const value = new asn1X509.ExtendedKeyUsage(args[0]); + super(asn1X509.id_ce_extKeyUsage, args[1], AsnConvert.serialize(value)); + this.usages = args[0]; + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj[""] = this.usages.map((o) => OidSerializer.toString(o)).join(", "); + return obj; + } +} +ExtendedKeyUsageExtension.NAME = "Extended Key Usages"; + +var KeyUsageFlags; +(function (KeyUsageFlags) { + KeyUsageFlags[KeyUsageFlags["digitalSignature"] = 1] = "digitalSignature"; + KeyUsageFlags[KeyUsageFlags["nonRepudiation"] = 2] = "nonRepudiation"; + KeyUsageFlags[KeyUsageFlags["keyEncipherment"] = 4] = "keyEncipherment"; + KeyUsageFlags[KeyUsageFlags["dataEncipherment"] = 8] = "dataEncipherment"; + KeyUsageFlags[KeyUsageFlags["keyAgreement"] = 16] = "keyAgreement"; + KeyUsageFlags[KeyUsageFlags["keyCertSign"] = 32] = "keyCertSign"; + KeyUsageFlags[KeyUsageFlags["cRLSign"] = 64] = "cRLSign"; + KeyUsageFlags[KeyUsageFlags["encipherOnly"] = 128] = "encipherOnly"; + KeyUsageFlags[KeyUsageFlags["decipherOnly"] = 256] = "decipherOnly"; +})(KeyUsageFlags || (KeyUsageFlags = {})); +class KeyUsagesExtension extends Extension { + constructor(...args) { + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + const value = AsnConvert.parse(this.value, KeyUsage); + this.usages = value.toNumber(); + } + else { + const value = new KeyUsage(args[0]); + super(id_ce_keyUsage, args[1], AsnConvert.serialize(value)); + this.usages = args[0]; + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const asn = AsnConvert.parse(this.value, KeyUsage); + obj[""] = asn.toJSON().join(", "); + return obj; + } +} +KeyUsagesExtension.NAME = "Key Usages"; + +class SubjectKeyIdentifierExtension extends Extension { + static async create(publicKey, critical = false, crypto = cryptoProvider.get()) { + const key = await PublicKey.create(publicKey, crypto); + const id = await key.getKeyIdentifier(crypto); + return new SubjectKeyIdentifierExtension(Convert.ToHex(id), critical); + } + constructor(...args) { + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + const value = AsnConvert.parse(this.value, asn1X509.SubjectKeyIdentifier); + this.keyId = Convert.ToHex(value); + } + else { + const identifier = typeof args[0] === "string" + ? Convert.FromHex(args[0]) + : args[0]; + const value = new asn1X509.SubjectKeyIdentifier(identifier); + super(asn1X509.id_ce_subjectKeyIdentifier, args[1], AsnConvert.serialize(value)); + this.keyId = Convert.ToHex(identifier); + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const asn = AsnConvert.parse(this.value, asn1X509.SubjectKeyIdentifier); + obj[""] = asn; + return obj; + } +} +SubjectKeyIdentifierExtension.NAME = "Subject Key Identifier"; + +class SubjectAlternativeNameExtension extends Extension { + constructor(...args) { + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else { + super(asn1X509.id_ce_subjectAltName, args[1], new GeneralNames(args[0] || []).rawData); + } + } + onInit(asn) { + super.onInit(asn); + const value = AsnConvert.parse(asn.extnValue, asn1X509.SubjectAlternativeName); + this.names = new GeneralNames(value); + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const namesObj = this.names.toTextObject(); + for (const key in namesObj) { + obj[key] = namesObj[key]; + } + return obj; + } +} +SubjectAlternativeNameExtension.NAME = "Subject Alternative Name"; + +class ExtensionFactory { + static register(id, type) { + this.items.set(id, type); + } + static create(data) { + const extension = new Extension(data); + const Type = this.items.get(extension.type); + if (Type) { + return new Type(data); + } + return extension; + } +} +ExtensionFactory.items = new Map(); + +class CertificatePolicyExtension extends Extension { + constructor(...args) { + var _a; + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + const asnPolicies = AsnConvert.parse(this.value, asn1X509.CertificatePolicies); + this.policies = asnPolicies.map((o) => o.policyIdentifier); + } + else { + const policies = args[0]; + const critical = (_a = args[1]) !== null && _a !== void 0 ? _a : false; + const value = new asn1X509.CertificatePolicies(policies.map((o) => (new asn1X509.PolicyInformation({ policyIdentifier: o })))); + super(asn1X509.id_ce_certificatePolicies, critical, AsnConvert.serialize(value)); + this.policies = policies; + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj["Policy"] = this.policies.map((o) => new TextObject("", {}, OidSerializer.toString(o))); + return obj; + } +} +CertificatePolicyExtension.NAME = "Certificate Policies"; +ExtensionFactory.register(asn1X509.id_ce_certificatePolicies, CertificatePolicyExtension); + +class CRLDistributionPointsExtension extends Extension { + constructor(...args) { + var _a; + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else if (Array.isArray(args[0]) && typeof args[0][0] === "string") { + const urls = args[0]; + const dps = urls.map((url) => { + return new asn1X509.DistributionPoint({ + distributionPoint: new asn1X509.DistributionPointName({ fullName: [new asn1X509.GeneralName({ uniformResourceIdentifier: url })] }), + }); + }); + const value = new asn1X509.CRLDistributionPoints(dps); + super(asn1X509.id_ce_cRLDistributionPoints, args[1], AsnConvert.serialize(value)); + } + else { + const value = new asn1X509.CRLDistributionPoints(args[0]); + super(asn1X509.id_ce_cRLDistributionPoints, args[1], AsnConvert.serialize(value)); + } + (_a = this.distributionPoints) !== null && _a !== void 0 ? _a : (this.distributionPoints = []); + } + onInit(asn) { + super.onInit(asn); + const crlExt = AsnConvert.parse(asn.extnValue, asn1X509.CRLDistributionPoints); + this.distributionPoints = crlExt; + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj["Distribution Point"] = this.distributionPoints.map((dp) => { + var _a; + const dpObj = {}; + if (dp.distributionPoint) { + dpObj[""] = (_a = dp.distributionPoint.fullName) === null || _a === void 0 ? void 0 : _a.map((name) => new GeneralName(name).toString()).join(", "); + } + if (dp.reasons) { + dpObj["Reasons"] = dp.reasons.toString(); + } + if (dp.cRLIssuer) { + dpObj["CRL Issuer"] = dp.cRLIssuer.map((issuer) => issuer.toString()).join(", "); + } + return dpObj; + }); + return obj; + } +} +CRLDistributionPointsExtension.NAME = "CRL Distribution Points"; + +class AuthorityInfoAccessExtension extends Extension { + constructor(...args) { + var _a, _b, _c, _d; + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else if (args[0] instanceof asn1X509.AuthorityInfoAccessSyntax) { + const value = new asn1X509.AuthorityInfoAccessSyntax(args[0]); + super(asn1X509.id_pe_authorityInfoAccess, args[1], AsnConvert.serialize(value)); + } + else { + const params = args[0]; + const value = new asn1X509.AuthorityInfoAccessSyntax(); + addAccessDescriptions(value, params, asn1X509.id_ad_ocsp, "ocsp"); + addAccessDescriptions(value, params, asn1X509.id_ad_caIssuers, "caIssuers"); + addAccessDescriptions(value, params, asn1X509.id_ad_timeStamping, "timeStamping"); + addAccessDescriptions(value, params, asn1X509.id_ad_caRepository, "caRepository"); + super(asn1X509.id_pe_authorityInfoAccess, args[1], AsnConvert.serialize(value)); + } + (_a = this.ocsp) !== null && _a !== void 0 ? _a : (this.ocsp = []); + (_b = this.caIssuers) !== null && _b !== void 0 ? _b : (this.caIssuers = []); + (_c = this.timeStamping) !== null && _c !== void 0 ? _c : (this.timeStamping = []); + (_d = this.caRepository) !== null && _d !== void 0 ? _d : (this.caRepository = []); + } + onInit(asn) { + super.onInit(asn); + this.ocsp = []; + this.caIssuers = []; + this.timeStamping = []; + this.caRepository = []; + const aia = AsnConvert.parse(asn.extnValue, asn1X509.AuthorityInfoAccessSyntax); + aia.forEach((accessDescription) => { + switch (accessDescription.accessMethod) { + case asn1X509.id_ad_ocsp: + this.ocsp.push(new GeneralName(accessDescription.accessLocation)); + break; + case asn1X509.id_ad_caIssuers: + this.caIssuers.push(new GeneralName(accessDescription.accessLocation)); + break; + case asn1X509.id_ad_timeStamping: + this.timeStamping.push(new GeneralName(accessDescription.accessLocation)); + break; + case asn1X509.id_ad_caRepository: + this.caRepository.push(new GeneralName(accessDescription.accessLocation)); + break; + } + }); + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + if (this.ocsp.length) { + addUrlsToObject(obj, "OCSP", this.ocsp); + } + if (this.caIssuers.length) { + addUrlsToObject(obj, "CA Issuers", this.caIssuers); + } + if (this.timeStamping.length) { + addUrlsToObject(obj, "Time Stamping", this.timeStamping); + } + if (this.caRepository.length) { + addUrlsToObject(obj, "CA Repository", this.caRepository); + } + return obj; + } +} +AuthorityInfoAccessExtension.NAME = "Authority Info Access"; +function addUrlsToObject(obj, key, urls) { + if (urls.length === 1) { + obj[key] = urls[0].toTextObject(); + } + else { + const names = new TextObject(""); + urls.forEach((name, index) => { + const nameObj = name.toTextObject(); + const indexedKey = `${nameObj[TextObject.NAME]} ${index + 1}`; + let field = names[indexedKey]; + if (!Array.isArray(field)) { + field = []; + names[indexedKey] = field; + } + field.push(nameObj); + }); + obj[key] = names; + } +} +function addAccessDescriptions(value, params, method, key) { + const items = params[key]; + if (items) { + const array = Array.isArray(items) ? items : [items]; + array.forEach((url) => { + if (typeof url === "string") { + url = new GeneralName("url", url); + } + value.push(new asn1X509.AccessDescription({ + accessMethod: method, + accessLocation: AsnConvert.parse(url.rawData, asn1X509.GeneralName), + })); + }); + } +} + +class IssuerAlternativeNameExtension extends Extension { + constructor(...args) { + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else { + super(asn1X509.id_ce_issuerAltName, args[1], new GeneralNames(args[0] || []).rawData); + } + } + onInit(asn) { + super.onInit(asn); + const value = AsnConvert.parse(asn.extnValue, asn1X509.GeneralNames); + this.names = new GeneralNames(value); + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const namesObj = this.names.toTextObject(); + for (const key in namesObj) { + obj[key] = namesObj[key]; + } + return obj; + } +} +IssuerAlternativeNameExtension.NAME = "Issuer Alternative Name"; + +class Attribute extends AsnData { + constructor(...args) { + let raw; + if (BufferSourceConverter.isBufferSource(args[0])) { + raw = BufferSourceConverter.toArrayBuffer(args[0]); + } + else { + const type = args[0]; + const values = Array.isArray(args[1]) + ? args[1].map((o) => BufferSourceConverter.toArrayBuffer(o)) + : []; + raw = AsnConvert.serialize(new Attribute$1({ + type, values, + })); + } + super(raw, Attribute$1); + } + onInit(asn) { + this.type = asn.type; + this.values = asn.values; + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj["Value"] = this.values.map((o) => new TextObject("", { "": o })); + return obj; + } + toTextObjectWithoutValue() { + const obj = this.toTextObjectEmpty(); + if (obj[TextObject.NAME] === Attribute.NAME) { + obj[TextObject.NAME] = OidSerializer.toString(this.type); + } + return obj; + } +} +Attribute.NAME = "Attribute"; + +class ChallengePasswordAttribute extends Attribute { + constructor(...args) { + var _a; + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else { + const value = new asnPkcs9.ChallengePassword({ printableString: args[0] }); + super(asnPkcs9.id_pkcs9_at_challengePassword, [AsnConvert.serialize(value)]); + } + (_a = this.password) !== null && _a !== void 0 ? _a : (this.password = ""); + } + onInit(asn) { + super.onInit(asn); + if (this.values[0]) { + const value = AsnConvert.parse(this.values[0], asnPkcs9.ChallengePassword); + this.password = value.toString(); + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + obj[TextObject.VALUE] = this.password; + return obj; + } +} +ChallengePasswordAttribute.NAME = "Challenge Password"; + +class ExtensionsAttribute extends Attribute { + constructor(...args) { + var _a; + if (BufferSourceConverter.isBufferSource(args[0])) { + super(args[0]); + } + else { + const extensions = args[0]; + const value = new asn1X509.Extensions(); + for (const extension of extensions) { + value.push(AsnConvert.parse(extension.rawData, asn1X509.Extension)); + } + super(asnPkcs9.id_pkcs9_at_extensionRequest, [AsnConvert.serialize(value)]); + } + (_a = this.items) !== null && _a !== void 0 ? _a : (this.items = []); + } + onInit(asn) { + super.onInit(asn); + if (this.values[0]) { + const value = AsnConvert.parse(this.values[0], asn1X509.Extensions); + this.items = value.map((o) => ExtensionFactory.create(AsnConvert.serialize(o))); + } + } + toTextObject() { + const obj = this.toTextObjectWithoutValue(); + const extensions = this.items.map((o) => o.toTextObject()); + for (const extension of extensions) { + obj[extension[TextObject.NAME]] = extension; + } + return obj; + } +} +ExtensionsAttribute.NAME = "Extensions"; + +class AttributeFactory { + static register(id, type) { + this.items.set(id, type); + } + static create(data) { + const attribute = new Attribute(data); + const Type = this.items.get(attribute.type); + if (Type) { + return new Type(data); + } + return attribute; + } +} +AttributeFactory.items = new Map(); + +const diAsnSignatureFormatter = "crypto.signatureFormatter"; +class AsnDefaultSignatureFormatter { + toAsnSignature(algorithm, signature) { + return BufferSourceConverter.toArrayBuffer(signature); + } + toWebSignature(algorithm, signature) { + return BufferSourceConverter.toArrayBuffer(signature); + } +} + +var RsaAlgorithm_1; +let RsaAlgorithm = RsaAlgorithm_1 = class RsaAlgorithm { + static createPssParams(hash, saltLength) { + const hashAlgorithm = RsaAlgorithm_1.getHashAlgorithm(hash); + if (!hashAlgorithm) { + return null; + } + return new asn1Rsa.RsaSaPssParams({ + hashAlgorithm, + maskGenAlgorithm: new AlgorithmIdentifier({ + algorithm: asn1Rsa.id_mgf1, + parameters: AsnConvert.serialize(hashAlgorithm), + }), + saltLength, + }); + } + static getHashAlgorithm(alg) { + const algProv = container.resolve(diAlgorithmProvider); + if (typeof alg === "string") { + return algProv.toAsnAlgorithm({ name: alg }); + } + if (typeof alg === "object" && alg && "name" in alg) { + return algProv.toAsnAlgorithm(alg); + } + return null; + } + toAsnAlgorithm(alg) { + switch (alg.name.toLowerCase()) { + case "rsassa-pkcs1-v1_5": + if ("hash" in alg) { + let hash; + if (typeof alg.hash === "string") { + hash = alg.hash; + } + else if (alg.hash && typeof alg.hash === "object" + && "name" in alg.hash && typeof alg.hash.name === "string") { + hash = alg.hash.name.toUpperCase(); + } + else { + throw new Error("Cannot get hash algorithm name"); + } + switch (hash.toLowerCase()) { + case "sha-1": + return new AlgorithmIdentifier({ + algorithm: asn1Rsa.id_sha1WithRSAEncryption, parameters: null, + }); + case "sha-256": + return new AlgorithmIdentifier({ + algorithm: asn1Rsa.id_sha256WithRSAEncryption, parameters: null, + }); + case "sha-384": + return new AlgorithmIdentifier({ + algorithm: asn1Rsa.id_sha384WithRSAEncryption, parameters: null, + }); + case "sha-512": + return new AlgorithmIdentifier({ + algorithm: asn1Rsa.id_sha512WithRSAEncryption, parameters: null, + }); + } + } + else { + return new AlgorithmIdentifier({ + algorithm: asn1Rsa.id_rsaEncryption, parameters: null, + }); + } + break; + case "rsa-pss": + if ("hash" in alg) { + if (!("saltLength" in alg && typeof alg.saltLength === "number")) { + throw new Error("Cannot get 'saltLength' from 'alg' argument"); + } + const pssParams = RsaAlgorithm_1.createPssParams(alg.hash, alg.saltLength); + if (!pssParams) { + throw new Error("Cannot create PSS parameters"); + } + return new AlgorithmIdentifier({ + algorithm: asn1Rsa.id_RSASSA_PSS, parameters: AsnConvert.serialize(pssParams), + }); + } + else { + return new AlgorithmIdentifier({ + algorithm: asn1Rsa.id_RSASSA_PSS, parameters: null, + }); + } + } + return null; + } + toWebAlgorithm(alg) { + switch (alg.algorithm) { + case asn1Rsa.id_rsaEncryption: + return { name: "RSASSA-PKCS1-v1_5" }; + case asn1Rsa.id_sha1WithRSAEncryption: + return { + name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-1" }, + }; + case asn1Rsa.id_sha256WithRSAEncryption: + return { + name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-256" }, + }; + case asn1Rsa.id_sha384WithRSAEncryption: + return { + name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-384" }, + }; + case asn1Rsa.id_sha512WithRSAEncryption: + return { + name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-512" }, + }; + case asn1Rsa.id_RSASSA_PSS: + if (alg.parameters) { + const pssParams = AsnConvert.parse(alg.parameters, asn1Rsa.RsaSaPssParams); + const algProv = container.resolve(diAlgorithmProvider); + const hashAlg = algProv.toWebAlgorithm(pssParams.hashAlgorithm); + return { + name: "RSA-PSS", + hash: hashAlg, + saltLength: pssParams.saltLength, + }; + } + else { + return { name: "RSA-PSS" }; + } + } + return null; + } +}; +RsaAlgorithm = RsaAlgorithm_1 = __decorate([ + injectable() +], RsaAlgorithm); +container.registerSingleton(diAlgorithm, RsaAlgorithm); + +let ShaAlgorithm = class ShaAlgorithm { + toAsnAlgorithm(alg) { + switch (alg.name.toLowerCase()) { + case "sha-1": + return new AlgorithmIdentifier({ algorithm: id_sha1 }); + case "sha-256": + return new AlgorithmIdentifier({ algorithm: id_sha256 }); + case "sha-384": + return new AlgorithmIdentifier({ algorithm: id_sha384 }); + case "sha-512": + return new AlgorithmIdentifier({ algorithm: id_sha512 }); + } + return null; + } + toWebAlgorithm(alg) { + switch (alg.algorithm) { + case id_sha1: + return { name: "SHA-1" }; + case id_sha256: + return { name: "SHA-256" }; + case id_sha384: + return { name: "SHA-384" }; + case id_sha512: + return { name: "SHA-512" }; + } + return null; + } +}; +ShaAlgorithm = __decorate([ + injectable() +], ShaAlgorithm); +container.registerSingleton(diAlgorithm, ShaAlgorithm); + +class AsnEcSignatureFormatter { + addPadding(pointSize, data) { + const bytes = BufferSourceConverter.toUint8Array(data); + const res = new Uint8Array(pointSize); + res.set(bytes, pointSize - bytes.length); + return res.buffer; + } + removePadding(data, positive = false) { + let bytes = BufferSourceConverter.toUint8Array(data); + for (let i = 0; i < bytes.length; i++) { + if (!bytes[i]) { + continue; + } + bytes = bytes.slice(i); + break; + } + if (positive && bytes[0] > 127) { + const result = new Uint8Array(bytes.length + 1); + result.set(bytes, 1); + return result.buffer; + } + return bytes.buffer; + } + toAsnSignature(algorithm, signature) { + if (algorithm.name === "ECDSA") { + const namedCurve = algorithm.namedCurve; + const pointSize = AsnEcSignatureFormatter.namedCurveSize.get(namedCurve) + || AsnEcSignatureFormatter.defaultNamedCurveSize; + const ecSignature = new ECDSASigValue(); + const uint8Signature = BufferSourceConverter.toUint8Array(signature); + ecSignature.r = this.removePadding(uint8Signature.slice(0, pointSize), true); + ecSignature.s = this.removePadding(uint8Signature.slice(pointSize, pointSize + pointSize), true); + return AsnConvert.serialize(ecSignature); + } + return null; + } + toWebSignature(algorithm, signature) { + if (algorithm.name === "ECDSA") { + const ecSigValue = AsnConvert.parse(signature, ECDSASigValue); + const namedCurve = algorithm.namedCurve; + const pointSize = AsnEcSignatureFormatter.namedCurveSize.get(namedCurve) + || AsnEcSignatureFormatter.defaultNamedCurveSize; + const r = this.addPadding(pointSize, this.removePadding(ecSigValue.r)); + const s = this.addPadding(pointSize, this.removePadding(ecSigValue.s)); + return combine(r, s); + } + return null; + } +} +AsnEcSignatureFormatter.namedCurveSize = new Map(); +AsnEcSignatureFormatter.defaultNamedCurveSize = 32; + +const idX25519 = "1.3.101.110"; +const idX448 = "1.3.101.111"; +const idEd25519 = "1.3.101.112"; +const idEd448 = "1.3.101.113"; +let EdAlgorithm = class EdAlgorithm { + toAsnAlgorithm(alg) { + let algorithm = null; + switch (alg.name.toLowerCase()) { + case "ed25519": + algorithm = idEd25519; + break; + case "x25519": + algorithm = idX25519; + break; + case "eddsa": + switch (alg.namedCurve.toLowerCase()) { + case "ed25519": + algorithm = idEd25519; + break; + case "ed448": + algorithm = idEd448; + break; + } + break; + case "ecdh-es": + switch (alg.namedCurve.toLowerCase()) { + case "x25519": + algorithm = idX25519; + break; + case "x448": + algorithm = idX448; + break; + } + } + if (algorithm) { + return new AlgorithmIdentifier({ algorithm }); + } + return null; + } + toWebAlgorithm(alg) { + switch (alg.algorithm) { + case idEd25519: + return { name: "Ed25519" }; + case idEd448: + return { + name: "EdDSA", namedCurve: "Ed448", + }; + case idX25519: + return { name: "X25519" }; + case idX448: + return { + name: "ECDH-ES", namedCurve: "X448", + }; + } + return null; + } +}; +EdAlgorithm = __decorate([ + injectable() +], EdAlgorithm); +container.registerSingleton(diAlgorithm, EdAlgorithm); + +var _Pkcs10CertificateRequest_tbs, _Pkcs10CertificateRequest_subjectName, _Pkcs10CertificateRequest_subject, _Pkcs10CertificateRequest_signatureAlgorithm, _Pkcs10CertificateRequest_signature, _Pkcs10CertificateRequest_publicKey, _Pkcs10CertificateRequest_attributes, _Pkcs10CertificateRequest_extensions; +class Pkcs10CertificateRequest extends PemData { + get subjectName() { + if (!__classPrivateFieldGet(this, _Pkcs10CertificateRequest_subjectName, "f")) { + __classPrivateFieldSet(this, _Pkcs10CertificateRequest_subjectName, new Name(this.asn.certificationRequestInfo.subject), "f"); + } + return __classPrivateFieldGet(this, _Pkcs10CertificateRequest_subjectName, "f"); + } + get subject() { + if (!__classPrivateFieldGet(this, _Pkcs10CertificateRequest_subject, "f")) { + __classPrivateFieldSet(this, _Pkcs10CertificateRequest_subject, this.subjectName.toString(), "f"); + } + return __classPrivateFieldGet(this, _Pkcs10CertificateRequest_subject, "f"); + } + get signatureAlgorithm() { + if (!__classPrivateFieldGet(this, _Pkcs10CertificateRequest_signatureAlgorithm, "f")) { + const algProv = container.resolve(diAlgorithmProvider); + __classPrivateFieldSet(this, _Pkcs10CertificateRequest_signatureAlgorithm, algProv.toWebAlgorithm(this.asn.signatureAlgorithm), "f"); + } + return __classPrivateFieldGet(this, _Pkcs10CertificateRequest_signatureAlgorithm, "f"); + } + get signature() { + if (!__classPrivateFieldGet(this, _Pkcs10CertificateRequest_signature, "f")) { + __classPrivateFieldSet(this, _Pkcs10CertificateRequest_signature, this.asn.signature, "f"); + } + return __classPrivateFieldGet(this, _Pkcs10CertificateRequest_signature, "f"); + } + get publicKey() { + if (!__classPrivateFieldGet(this, _Pkcs10CertificateRequest_publicKey, "f")) { + __classPrivateFieldSet(this, _Pkcs10CertificateRequest_publicKey, new PublicKey(this.asn.certificationRequestInfo.subjectPKInfo), "f"); + } + return __classPrivateFieldGet(this, _Pkcs10CertificateRequest_publicKey, "f"); + } + get attributes() { + if (!__classPrivateFieldGet(this, _Pkcs10CertificateRequest_attributes, "f")) { + __classPrivateFieldSet(this, _Pkcs10CertificateRequest_attributes, this.asn.certificationRequestInfo.attributes + .map((o) => AttributeFactory.create(AsnConvert.serialize(o))), "f"); + } + return __classPrivateFieldGet(this, _Pkcs10CertificateRequest_attributes, "f"); + } + get extensions() { + if (!__classPrivateFieldGet(this, _Pkcs10CertificateRequest_extensions, "f")) { + __classPrivateFieldSet(this, _Pkcs10CertificateRequest_extensions, [], "f"); + const extensions = this.getAttribute(id_pkcs9_at_extensionRequest); + if (extensions instanceof ExtensionsAttribute) { + __classPrivateFieldSet(this, _Pkcs10CertificateRequest_extensions, extensions.items, "f"); + } + } + return __classPrivateFieldGet(this, _Pkcs10CertificateRequest_extensions, "f"); + } + get tbs() { + if (!__classPrivateFieldGet(this, _Pkcs10CertificateRequest_tbs, "f")) { + __classPrivateFieldSet(this, _Pkcs10CertificateRequest_tbs, this.asn.certificationRequestInfoRaw + || AsnConvert.serialize(this.asn.certificationRequestInfo), "f"); + } + return __classPrivateFieldGet(this, _Pkcs10CertificateRequest_tbs, "f"); + } + constructor(param) { + const args = PemData.isAsnEncoded(param) ? [param, CertificationRequest] : [param]; + super(args[0], args[1]); + _Pkcs10CertificateRequest_tbs.set(this, void 0); + _Pkcs10CertificateRequest_subjectName.set(this, void 0); + _Pkcs10CertificateRequest_subject.set(this, void 0); + _Pkcs10CertificateRequest_signatureAlgorithm.set(this, void 0); + _Pkcs10CertificateRequest_signature.set(this, void 0); + _Pkcs10CertificateRequest_publicKey.set(this, void 0); + _Pkcs10CertificateRequest_attributes.set(this, void 0); + _Pkcs10CertificateRequest_extensions.set(this, void 0); + this.tag = PemConverter.CertificateRequestTag; + } + onInit(_asn) { + } + getAttribute(type) { + for (const attr of this.attributes) { + if (attr.type === type) { + return attr; + } + } + return null; + } + getAttributes(type) { + return this.attributes.filter((o) => o.type === type); + } + getExtension(type) { + for (const ext of this.extensions) { + if (ext.type === type) { + return ext; + } + } + return null; + } + getExtensions(type) { + return this.extensions.filter((o) => o.type === type); + } + async verify(crypto = cryptoProvider.get()) { + const algorithm = { + ...this.publicKey.algorithm, ...this.signatureAlgorithm, + }; + const publicKey = await this.publicKey.export(algorithm, ["verify"], crypto); + const signatureFormatters = container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let signature = null; + for (const signatureFormatter of signatureFormatters) { + signature = signatureFormatter.toWebSignature(algorithm, this.signature); + if (signature) { + break; + } + } + if (!signature) { + throw Error("Cannot convert WebCrypto signature value to ASN.1 format"); + } + const ok = await crypto.subtle.verify(this.signatureAlgorithm, publicKey, signature, this.tbs); + return ok; + } + toTextObject() { + const obj = this.toTextObjectEmpty(); + const req = AsnConvert.parse(this.rawData, CertificationRequest); + const tbs = req.certificationRequestInfo; + const data = new TextObject("", { + Version: `${Version[tbs.version]} (${tbs.version})`, + Subject: this.subject, + "Subject Public Key Info": this.publicKey, + }); + if (this.attributes.length) { + const attrs = new TextObject(""); + for (const ext of this.attributes) { + const attrObj = ext.toTextObject(); + attrs[attrObj[TextObject.NAME]] = attrObj; + } + data["Attributes"] = attrs; + } + obj["Data"] = data; + obj["Signature"] = new TextObject("", { + Algorithm: TextConverter.serializeAlgorithm(req.signatureAlgorithm), + "": req.signature, + }); + return obj; + } +} +_Pkcs10CertificateRequest_tbs = new WeakMap(), _Pkcs10CertificateRequest_subjectName = new WeakMap(), _Pkcs10CertificateRequest_subject = new WeakMap(), _Pkcs10CertificateRequest_signatureAlgorithm = new WeakMap(), _Pkcs10CertificateRequest_signature = new WeakMap(), _Pkcs10CertificateRequest_publicKey = new WeakMap(), _Pkcs10CertificateRequest_attributes = new WeakMap(), _Pkcs10CertificateRequest_extensions = new WeakMap(); +Pkcs10CertificateRequest.NAME = "PKCS#10 Certificate Request"; + +class Pkcs10CertificateRequestGenerator { + static async create(params, crypto = cryptoProvider.get()) { + if (!params.keys.privateKey) { + throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty"); + } + if (!params.keys.publicKey) { + throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty"); + } + const spki = await crypto.subtle.exportKey("spki", params.keys.publicKey); + const asnReq = new CertificationRequest({ + certificationRequestInfo: new CertificationRequestInfo({ subjectPKInfo: AsnConvert.parse(spki, SubjectPublicKeyInfo) }), + }); + if (params.name) { + const name = params.name instanceof Name + ? params.name + : new Name(params.name); + asnReq.certificationRequestInfo.subject = AsnConvert.parse(name.toArrayBuffer(), Name$1); + } + if (params.attributes) { + for (const o of params.attributes) { + asnReq.certificationRequestInfo.attributes.push(AsnConvert.parse(o.rawData, Attribute$1)); + } + } + if (params.extensions && params.extensions.length) { + const attr = new Attribute$1({ type: id_pkcs9_at_extensionRequest }); + const extensions = new Extensions(); + for (const o of params.extensions) { + extensions.push(AsnConvert.parse(o.rawData, Extension$1)); + } + attr.values.push(AsnConvert.serialize(extensions)); + asnReq.certificationRequestInfo.attributes.push(attr); + } + const signingAlgorithm = { + ...params.signingAlgorithm, ...params.keys.privateKey.algorithm, + }; + const algProv = container.resolve(diAlgorithmProvider); + asnReq.signatureAlgorithm = algProv.toAsnAlgorithm(signingAlgorithm); + const tbs = AsnConvert.serialize(asnReq.certificationRequestInfo); + const signature = await crypto.subtle.sign(signingAlgorithm, params.keys.privateKey, tbs); + const signatureFormatters = container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let asnSignature = null; + for (const signatureFormatter of signatureFormatters) { + asnSignature = signatureFormatter.toAsnSignature(signingAlgorithm, signature); + if (asnSignature) { + break; + } + } + if (!asnSignature) { + throw Error("Cannot convert WebCrypto signature value to ASN.1 format"); + } + asnReq.signature = asnSignature; + return new Pkcs10CertificateRequest(AsnConvert.serialize(asnReq)); + } +} + +var _X509Certificate_tbs, _X509Certificate_serialNumber, _X509Certificate_subjectName, _X509Certificate_subject, _X509Certificate_issuerName, _X509Certificate_issuer, _X509Certificate_notBefore, _X509Certificate_notAfter, _X509Certificate_signatureAlgorithm, _X509Certificate_signature, _X509Certificate_extensions, _X509Certificate_publicKey; +class X509Certificate extends PemData { + get publicKey() { + if (!__classPrivateFieldGet(this, _X509Certificate_publicKey, "f")) { + __classPrivateFieldSet(this, _X509Certificate_publicKey, new PublicKey(this.asn.tbsCertificate.subjectPublicKeyInfo), "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_publicKey, "f"); + } + get serialNumber() { + if (!__classPrivateFieldGet(this, _X509Certificate_serialNumber, "f")) { + const tbs = this.asn.tbsCertificate; + let serialNumberBytes = new Uint8Array(tbs.serialNumber); + if (serialNumberBytes.length > 1 + && serialNumberBytes[0] === 0x00 + && serialNumberBytes[1] > 0x7F) { + serialNumberBytes = serialNumberBytes.slice(1); + } + __classPrivateFieldSet(this, _X509Certificate_serialNumber, Convert.ToHex(serialNumberBytes), "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_serialNumber, "f"); + } + get subjectName() { + if (!__classPrivateFieldGet(this, _X509Certificate_subjectName, "f")) { + __classPrivateFieldSet(this, _X509Certificate_subjectName, new Name(this.asn.tbsCertificate.subject), "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_subjectName, "f"); + } + get subject() { + if (!__classPrivateFieldGet(this, _X509Certificate_subject, "f")) { + __classPrivateFieldSet(this, _X509Certificate_subject, this.subjectName.toString(), "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_subject, "f"); + } + get issuerName() { + if (!__classPrivateFieldGet(this, _X509Certificate_issuerName, "f")) { + __classPrivateFieldSet(this, _X509Certificate_issuerName, new Name(this.asn.tbsCertificate.issuer), "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_issuerName, "f"); + } + get issuer() { + if (!__classPrivateFieldGet(this, _X509Certificate_issuer, "f")) { + __classPrivateFieldSet(this, _X509Certificate_issuer, this.issuerName.toString(), "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_issuer, "f"); + } + get notBefore() { + if (!__classPrivateFieldGet(this, _X509Certificate_notBefore, "f")) { + const notBefore = this.asn.tbsCertificate.validity.notBefore.utcTime + || this.asn.tbsCertificate.validity.notBefore.generalTime; + if (!notBefore) { + throw new Error("Cannot get 'notBefore' value"); + } + __classPrivateFieldSet(this, _X509Certificate_notBefore, notBefore, "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_notBefore, "f"); + } + get notAfter() { + if (!__classPrivateFieldGet(this, _X509Certificate_notAfter, "f")) { + const notAfter = this.asn.tbsCertificate.validity.notAfter.utcTime + || this.asn.tbsCertificate.validity.notAfter.generalTime; + if (!notAfter) { + throw new Error("Cannot get 'notAfter' value"); + } + __classPrivateFieldSet(this, _X509Certificate_notAfter, notAfter, "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_notAfter, "f"); + } + get signatureAlgorithm() { + if (!__classPrivateFieldGet(this, _X509Certificate_signatureAlgorithm, "f")) { + const algProv = container.resolve(diAlgorithmProvider); + __classPrivateFieldSet(this, _X509Certificate_signatureAlgorithm, algProv + .toWebAlgorithm(this.asn.signatureAlgorithm), "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_signatureAlgorithm, "f"); + } + get signature() { + if (!__classPrivateFieldGet(this, _X509Certificate_signature, "f")) { + __classPrivateFieldSet(this, _X509Certificate_signature, this.asn.signatureValue, "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_signature, "f"); + } + get extensions() { + if (!__classPrivateFieldGet(this, _X509Certificate_extensions, "f")) { + __classPrivateFieldSet(this, _X509Certificate_extensions, [], "f"); + if (this.asn.tbsCertificate.extensions) { + __classPrivateFieldSet(this, _X509Certificate_extensions, this.asn.tbsCertificate.extensions.map((o) => (ExtensionFactory.create(AsnConvert.serialize(o)))), "f"); + } + } + return __classPrivateFieldGet(this, _X509Certificate_extensions, "f"); + } + get tbs() { + if (!__classPrivateFieldGet(this, _X509Certificate_tbs, "f")) { + __classPrivateFieldSet(this, _X509Certificate_tbs, this.asn.tbsCertificateRaw || AsnConvert.serialize(this.asn.tbsCertificate), "f"); + } + return __classPrivateFieldGet(this, _X509Certificate_tbs, "f"); + } + constructor(param) { + const args = PemData.isAsnEncoded(param) ? [param, Certificate] : [param]; + super(args[0], args[1]); + _X509Certificate_tbs.set(this, void 0); + _X509Certificate_serialNumber.set(this, void 0); + _X509Certificate_subjectName.set(this, void 0); + _X509Certificate_subject.set(this, void 0); + _X509Certificate_issuerName.set(this, void 0); + _X509Certificate_issuer.set(this, void 0); + _X509Certificate_notBefore.set(this, void 0); + _X509Certificate_notAfter.set(this, void 0); + _X509Certificate_signatureAlgorithm.set(this, void 0); + _X509Certificate_signature.set(this, void 0); + _X509Certificate_extensions.set(this, void 0); + _X509Certificate_publicKey.set(this, void 0); + this.tag = PemConverter.CertificateTag; + } + onInit(_asn) { + } + getExtension(type) { + for (const ext of this.extensions) { + if (typeof type === "string") { + if (ext.type === type) { + return ext; + } + } + else { + if (ext instanceof type) { + return ext; + } + } + } + return null; + } + getExtensions(type) { + return this.extensions.filter((o) => { + if (typeof type === "string") { + return o.type === type; + } + else { + return o instanceof type; + } + }); + } + async verify(params = {}, crypto = cryptoProvider.get()) { + let keyAlgorithm; + let publicKey; + const paramsKey = params.publicKey; + try { + if (!paramsKey) { + keyAlgorithm = { + ...this.publicKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = await this.publicKey.export(keyAlgorithm, ["verify"], crypto); + } + else if ("publicKey" in paramsKey) { + keyAlgorithm = { + ...paramsKey.publicKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = await paramsKey.publicKey.export(keyAlgorithm, ["verify"], crypto); + } + else if (paramsKey instanceof PublicKey) { + keyAlgorithm = { + ...paramsKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = await paramsKey.export(keyAlgorithm, ["verify"], crypto); + } + else if (BufferSourceConverter.isBufferSource(paramsKey)) { + const key = new PublicKey(paramsKey); + keyAlgorithm = { + ...key.algorithm, ...this.signatureAlgorithm, + }; + publicKey = await key.export(keyAlgorithm, ["verify"], crypto); + } + else { + keyAlgorithm = { + ...paramsKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = paramsKey; + } + } + catch { + return false; + } + const signatureFormatters = container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let signature = null; + for (const signatureFormatter of signatureFormatters) { + signature = signatureFormatter.toWebSignature(keyAlgorithm, this.signature); + if (signature) { + break; + } + } + if (!signature) { + throw Error("Cannot convert ASN.1 signature value to WebCrypto format"); + } + const ok = await crypto.subtle.verify(this.signatureAlgorithm, publicKey, signature, this.tbs); + if (params.signatureOnly) { + return ok; + } + else { + const date = params.date || new Date(); + const time = date.getTime(); + return ok && this.notBefore.getTime() < time && time < this.notAfter.getTime(); + } + } + async getThumbprint(...args) { + let crypto; + let algorithm = "SHA-1"; + if (args[0]) { + if (!args[0].subtle) { + algorithm = args[0] || algorithm; + crypto = args[1]; + } + else { + crypto = args[0]; + } + } + crypto !== null && crypto !== void 0 ? crypto : (crypto = cryptoProvider.get()); + return await crypto.subtle.digest(algorithm, this.rawData); + } + async isSelfSigned(crypto = cryptoProvider.get()) { + return this.subject === this.issuer && await this.verify({ signatureOnly: true }, crypto); + } + toTextObject() { + const obj = this.toTextObjectEmpty(); + const cert = AsnConvert.parse(this.rawData, Certificate); + const tbs = cert.tbsCertificate; + const data = new TextObject("", { + Version: `${Version[tbs.version]} (${tbs.version})`, + "Serial Number": tbs.serialNumber, + "Signature Algorithm": TextConverter.serializeAlgorithm(tbs.signature), + Issuer: this.issuer, + Validity: new TextObject("", { + "Not Before": tbs.validity.notBefore.getTime(), + "Not After": tbs.validity.notAfter.getTime(), + }), + Subject: this.subject, + "Subject Public Key Info": this.publicKey, + }); + if (tbs.issuerUniqueID) { + data["Issuer Unique ID"] = tbs.issuerUniqueID; + } + if (tbs.subjectUniqueID) { + data["Subject Unique ID"] = tbs.subjectUniqueID; + } + if (this.extensions.length) { + const extensions = new TextObject(""); + for (const ext of this.extensions) { + const extObj = ext.toTextObject(); + extensions[extObj[TextObject.NAME]] = extObj; + } + data["Extensions"] = extensions; + } + obj["Data"] = data; + obj["Signature"] = new TextObject("", { + Algorithm: TextConverter.serializeAlgorithm(cert.signatureAlgorithm), + "": cert.signatureValue, + }); + return obj; + } +} +_X509Certificate_tbs = new WeakMap(), _X509Certificate_serialNumber = new WeakMap(), _X509Certificate_subjectName = new WeakMap(), _X509Certificate_subject = new WeakMap(), _X509Certificate_issuerName = new WeakMap(), _X509Certificate_issuer = new WeakMap(), _X509Certificate_notBefore = new WeakMap(), _X509Certificate_notAfter = new WeakMap(), _X509Certificate_signatureAlgorithm = new WeakMap(), _X509Certificate_signature = new WeakMap(), _X509Certificate_extensions = new WeakMap(), _X509Certificate_publicKey = new WeakMap(); +X509Certificate.NAME = "Certificate"; + +class X509Certificates extends Array { + constructor(param) { + super(); + if (PemData.isAsnEncoded(param)) { + this.import(param); + } + else if (param instanceof X509Certificate) { + this.push(param); + } + else if (Array.isArray(param)) { + for (const item of param) { + this.push(item); + } + } + } + export(format) { + const signedData = new asn1Cms.SignedData(); + signedData.version = 1; + signedData.encapContentInfo.eContentType = asn1Cms.id_data; + signedData.encapContentInfo.eContent = new asn1Cms.EncapsulatedContent({ single: new OctetString() }); + signedData.certificates = new asn1Cms.CertificateSet(this.map((o) => new asn1Cms.CertificateChoices({ certificate: AsnConvert.parse(o.rawData, Certificate) }))); + const cms = new asn1Cms.ContentInfo({ + contentType: asn1Cms.id_signedData, + content: AsnConvert.serialize(signedData), + }); + const raw = AsnConvert.serialize(cms); + if (format === "raw") { + return raw; + } + return this.toString(format); + } + import(data) { + const raw = PemData.toArrayBuffer(data); + const cms = AsnConvert.parse(raw, asn1Cms.ContentInfo); + if (cms.contentType !== asn1Cms.id_signedData) { + throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object."); + } + const signedData = AsnConvert.parse(cms.content, asn1Cms.SignedData); + this.clear(); + for (const item of signedData.certificates || []) { + if (item.certificate) { + this.push(new X509Certificate(item.certificate)); + } + } + } + clear() { + while (this.pop()) { + } + } + toString(format = "pem") { + const raw = this.export("raw"); + switch (format) { + case "pem": + return PemConverter.encode(raw, "CMS"); + case "pem-chain": + return this + .map((o) => o.toString("pem")) + .join("\n"); + case "asn": + return AsnConvert.toString(raw); + case "hex": + return Convert.ToHex(raw); + case "base64": + return Convert.ToBase64(raw); + case "base64url": + return Convert.ToBase64Url(raw); + case "text": + return TextConverter.serialize(this.toTextObject()); + default: + throw TypeError("Argument 'format' is unsupported value"); + } + } + toTextObject() { + const contentInfo = AsnConvert.parse(this.export("raw"), asn1Cms.ContentInfo); + const signedData = AsnConvert.parse(contentInfo.content, asn1Cms.SignedData); + const obj = new TextObject("X509Certificates", { + "Content Type": OidSerializer.toString(contentInfo.contentType), + Content: new TextObject("", { + Version: `${asn1Cms.CMSVersion[signedData.version]} (${signedData.version})`, + Certificates: new TextObject("", { Certificate: this.map((o) => o.toTextObject()) }), + }), + }); + return obj; + } +} + +class X509ChainBuilder { + constructor(params = {}) { + this.certificates = []; + if (params.certificates) { + this.certificates = params.certificates; + } + } + async build(cert, crypto = cryptoProvider.get()) { + const chain = new X509Certificates(cert); + let current = cert; + while (current = await this.findIssuer(current, crypto)) { + const thumbprint = await current.getThumbprint(crypto); + for (const item of chain) { + const thumbprint2 = await item.getThumbprint(crypto); + if (isEqual(thumbprint, thumbprint2)) { + throw new Error("Cannot build a certificate chain. Circular dependency."); + } + } + chain.push(current); + } + return chain; + } + async findIssuer(cert, crypto = cryptoProvider.get()) { + if (!await cert.isSelfSigned(crypto)) { + const akiExt = cert.getExtension(asn1X509.id_ce_authorityKeyIdentifier); + for (const item of this.certificates) { + if (item.subject !== cert.issuer) { + continue; + } + if (akiExt) { + if (akiExt.keyId) { + const skiExt = item.getExtension(asn1X509.id_ce_subjectKeyIdentifier); + if (skiExt && skiExt.keyId !== akiExt.keyId) { + continue; + } + } + else if (akiExt.certId) { + const sanExt = item.getExtension(asn1X509.id_ce_subjectAltName); + if (sanExt + && !(akiExt.certId.serialNumber === item.serialNumber && isEqual(AsnConvert.serialize(akiExt.certId.name), AsnConvert.serialize(sanExt)))) { + continue; + } + } + } + try { + const algorithm = { + ...item.publicKey.algorithm, ...cert.signatureAlgorithm, + }; + const publicKey = await item.publicKey.export(algorithm, ["verify"], crypto); + const ok = await cert.verify({ + publicKey, signatureOnly: true, + }, crypto); + if (!ok) { + continue; + } + } + catch { + continue; + } + return item; + } + } + return null; + } +} + +function generateCertificateSerialNumber(input, crypto = cryptoProvider.get()) { + const inputView = BufferSourceConverter.toUint8Array(Convert.FromHex(input || "")); + let serialNumber = inputView && inputView.length && inputView.some((o) => o > 0) + ? new Uint8Array(inputView) + : undefined; + if (!serialNumber) { + serialNumber = crypto.getRandomValues(new Uint8Array(16)); + } + let firstNonZero = 0; + while (firstNonZero < serialNumber.length - 1 && serialNumber[firstNonZero] === 0) { + firstNonZero++; + } + serialNumber = serialNumber.slice(firstNonZero); + if (serialNumber[0] > 0x7F) { + const newSerialNumber = new Uint8Array(serialNumber.length + 1); + newSerialNumber[0] = 0x00; + newSerialNumber.set(serialNumber, 1); + serialNumber = newSerialNumber; + } + return serialNumber.buffer; +} + +class X509CertificateGenerator { + static async createSelfSigned(params, crypto = cryptoProvider.get()) { + if (!params.keys.privateKey) { + throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty"); + } + if (!params.keys.publicKey) { + throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty"); + } + return this.create({ + serialNumber: params.serialNumber, + subject: params.name, + issuer: params.name, + notBefore: params.notBefore, + notAfter: params.notAfter, + publicKey: params.keys.publicKey, + signingKey: params.keys.privateKey, + signingAlgorithm: params.signingAlgorithm, + extensions: params.extensions, + }, crypto); + } + static async create(params, crypto = cryptoProvider.get()) { + var _a; + let spki; + if (params.publicKey instanceof PublicKey) { + spki = params.publicKey.rawData; + } + else if ("publicKey" in params.publicKey) { + spki = params.publicKey.publicKey.rawData; + } + else if (BufferSourceConverter.isBufferSource(params.publicKey)) { + spki = params.publicKey; + } + else { + spki = await crypto.subtle.exportKey("spki", params.publicKey); + } + const serialNumber = generateCertificateSerialNumber(params.serialNumber, crypto); + const notBefore = params.notBefore || new Date(); + const notAfter = params.notAfter || new Date(notBefore.getTime() + 31536000000); + const asnX509 = new asn1X509.Certificate({ + tbsCertificate: new asn1X509.TBSCertificate({ + version: asn1X509.Version.v3, + serialNumber, + validity: new asn1X509.Validity({ + notBefore, + notAfter, + }), + extensions: new asn1X509.Extensions(((_a = params.extensions) === null || _a === void 0 ? void 0 : _a.map((o) => AsnConvert.parse(o.rawData, asn1X509.Extension))) || []), + subjectPublicKeyInfo: AsnConvert.parse(spki, asn1X509.SubjectPublicKeyInfo), + }), + }); + if (params.subject) { + const name = params.subject instanceof Name + ? params.subject + : new Name(params.subject); + asnX509.tbsCertificate.subject = AsnConvert.parse(name.toArrayBuffer(), asn1X509.Name); + } + if (params.issuer) { + const name = params.issuer instanceof Name + ? params.issuer + : new Name(params.issuer); + asnX509.tbsCertificate.issuer = AsnConvert.parse(name.toArrayBuffer(), asn1X509.Name); + } + const defaultSigningAlgorithm = { hash: "SHA-256" }; + const signatureAlgorithm = ("signingKey" in params) + ? { + ...defaultSigningAlgorithm, ...params.signingAlgorithm, ...params.signingKey.algorithm, + } + : { + ...defaultSigningAlgorithm, ...params.signingAlgorithm, + }; + const algProv = container.resolve(diAlgorithmProvider); + asnX509.tbsCertificate.signature = asnX509.signatureAlgorithm = algProv + .toAsnAlgorithm(signatureAlgorithm); + const tbs = AsnConvert.serialize(asnX509.tbsCertificate); + const signatureValue = ("signingKey" in params) + ? await crypto.subtle.sign(signatureAlgorithm, params.signingKey, tbs) + : params.signature; + const signatureFormatters = container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let asnSignature = null; + for (const signatureFormatter of signatureFormatters) { + asnSignature = signatureFormatter.toAsnSignature(signatureAlgorithm, signatureValue); + if (asnSignature) { + break; + } + } + if (!asnSignature) { + throw Error("Cannot convert ASN.1 signature value to WebCrypto format"); + } + asnX509.signatureValue = asnSignature; + return new X509Certificate(AsnConvert.serialize(asnX509)); + } +} + +var _X509CrlEntry_serialNumber, _X509CrlEntry_revocationDate, _X509CrlEntry_reason, _X509CrlEntry_invalidity, _X509CrlEntry_extensions; +var X509CrlReason; +(function (X509CrlReason) { + X509CrlReason[X509CrlReason["unspecified"] = 0] = "unspecified"; + X509CrlReason[X509CrlReason["keyCompromise"] = 1] = "keyCompromise"; + X509CrlReason[X509CrlReason["cACompromise"] = 2] = "cACompromise"; + X509CrlReason[X509CrlReason["affiliationChanged"] = 3] = "affiliationChanged"; + X509CrlReason[X509CrlReason["superseded"] = 4] = "superseded"; + X509CrlReason[X509CrlReason["cessationOfOperation"] = 5] = "cessationOfOperation"; + X509CrlReason[X509CrlReason["certificateHold"] = 6] = "certificateHold"; + X509CrlReason[X509CrlReason["removeFromCRL"] = 8] = "removeFromCRL"; + X509CrlReason[X509CrlReason["privilegeWithdrawn"] = 9] = "privilegeWithdrawn"; + X509CrlReason[X509CrlReason["aACompromise"] = 10] = "aACompromise"; +})(X509CrlReason || (X509CrlReason = {})); +class X509CrlEntry extends AsnData { + get serialNumber() { + if (!__classPrivateFieldGet(this, _X509CrlEntry_serialNumber, "f")) { + __classPrivateFieldSet(this, _X509CrlEntry_serialNumber, Convert.ToHex(this.asn.userCertificate), "f"); + } + return __classPrivateFieldGet(this, _X509CrlEntry_serialNumber, "f"); + } + get revocationDate() { + if (!__classPrivateFieldGet(this, _X509CrlEntry_revocationDate, "f")) { + __classPrivateFieldSet(this, _X509CrlEntry_revocationDate, this.asn.revocationDate.getTime(), "f"); + } + return __classPrivateFieldGet(this, _X509CrlEntry_revocationDate, "f"); + } + get reason() { + if (__classPrivateFieldGet(this, _X509CrlEntry_reason, "f") === undefined) { + void this.extensions; + } + return __classPrivateFieldGet(this, _X509CrlEntry_reason, "f"); + } + get invalidity() { + if (__classPrivateFieldGet(this, _X509CrlEntry_invalidity, "f") === undefined) { + void this.extensions; + } + return __classPrivateFieldGet(this, _X509CrlEntry_invalidity, "f"); + } + get extensions() { + if (!__classPrivateFieldGet(this, _X509CrlEntry_extensions, "f")) { + __classPrivateFieldSet(this, _X509CrlEntry_extensions, [], "f"); + if (this.asn.crlEntryExtensions) { + __classPrivateFieldSet(this, _X509CrlEntry_extensions, this.asn.crlEntryExtensions.map((o) => { + const extension = ExtensionFactory.create(AsnConvert.serialize(o)); + switch (extension.type) { + case id_ce_cRLReasons: + if (__classPrivateFieldGet(this, _X509CrlEntry_reason, "f") === undefined) { + __classPrivateFieldSet(this, _X509CrlEntry_reason, AsnConvert + .parse(extension.value, CRLReason).reason, "f"); + } + break; + case id_ce_invalidityDate: + if (__classPrivateFieldGet(this, _X509CrlEntry_invalidity, "f") === undefined) { + __classPrivateFieldSet(this, _X509CrlEntry_invalidity, AsnConvert.parse(extension.value, InvalidityDate).value, "f"); + } + break; + } + return extension; + }), "f"); + } + } + return __classPrivateFieldGet(this, _X509CrlEntry_extensions, "f"); + } + constructor(...args) { + let raw; + if (BufferSourceConverter.isBufferSource(args[0])) { + raw = BufferSourceConverter.toArrayBuffer(args[0]); + } + else if (typeof args[0] === "string") { + raw = AsnConvert.serialize(new RevokedCertificate({ + userCertificate: generateCertificateSerialNumber(args[0]), + revocationDate: new Time(args[1]), + crlEntryExtensions: args[2], + })); + } + else if (args[0] instanceof RevokedCertificate) { + raw = args[0]; + } + if (!raw) { + throw new TypeError("Cannot create X509CrlEntry instance. Wrong constructor arguments."); + } + super(raw, RevokedCertificate); + _X509CrlEntry_serialNumber.set(this, void 0); + _X509CrlEntry_revocationDate.set(this, void 0); + _X509CrlEntry_reason.set(this, void 0); + _X509CrlEntry_invalidity.set(this, void 0); + _X509CrlEntry_extensions.set(this, void 0); + } + onInit(_asn) { + } +} +_X509CrlEntry_serialNumber = new WeakMap(), _X509CrlEntry_revocationDate = new WeakMap(), _X509CrlEntry_reason = new WeakMap(), _X509CrlEntry_invalidity = new WeakMap(), _X509CrlEntry_extensions = new WeakMap(); + +var _X509Crl_tbs, _X509Crl_signatureAlgorithm, _X509Crl_issuerName, _X509Crl_thisUpdate, _X509Crl_nextUpdate, _X509Crl_entries, _X509Crl_extensions; +class X509Crl extends PemData { + get version() { + return this.asn.tbsCertList.version; + } + get signatureAlgorithm() { + if (!__classPrivateFieldGet(this, _X509Crl_signatureAlgorithm, "f")) { + const algProv = container.resolve(diAlgorithmProvider); + __classPrivateFieldSet(this, _X509Crl_signatureAlgorithm, algProv + .toWebAlgorithm(this.asn.signatureAlgorithm), "f"); + } + return __classPrivateFieldGet(this, _X509Crl_signatureAlgorithm, "f"); + } + get signature() { + return this.asn.signature; + } + get issuer() { + return this.issuerName.toString(); + } + get issuerName() { + if (!__classPrivateFieldGet(this, _X509Crl_issuerName, "f")) { + __classPrivateFieldSet(this, _X509Crl_issuerName, new Name(this.asn.tbsCertList.issuer), "f"); + } + return __classPrivateFieldGet(this, _X509Crl_issuerName, "f"); + } + get thisUpdate() { + if (!__classPrivateFieldGet(this, _X509Crl_thisUpdate, "f")) { + const thisUpdate = this.asn.tbsCertList.thisUpdate.getTime(); + if (!thisUpdate) { + throw new Error("Cannot get 'thisUpdate' value"); + } + __classPrivateFieldSet(this, _X509Crl_thisUpdate, thisUpdate, "f"); + } + return __classPrivateFieldGet(this, _X509Crl_thisUpdate, "f"); + } + get nextUpdate() { + var _a; + if (__classPrivateFieldGet(this, _X509Crl_nextUpdate, "f") === undefined) { + __classPrivateFieldSet(this, _X509Crl_nextUpdate, ((_a = this.asn.tbsCertList.nextUpdate) === null || _a === void 0 ? void 0 : _a.getTime()) || undefined, "f"); + } + return __classPrivateFieldGet(this, _X509Crl_nextUpdate, "f"); + } + get entries() { + var _a; + if (!__classPrivateFieldGet(this, _X509Crl_entries, "f")) { + __classPrivateFieldSet(this, _X509Crl_entries, ((_a = this.asn.tbsCertList + .revokedCertificates) === null || _a === void 0 ? void 0 : _a.map((o) => new X509CrlEntry(o))) || [], "f"); + } + return __classPrivateFieldGet(this, _X509Crl_entries, "f"); + } + get extensions() { + if (!__classPrivateFieldGet(this, _X509Crl_extensions, "f")) { + __classPrivateFieldSet(this, _X509Crl_extensions, [], "f"); + if (this.asn.tbsCertList.crlExtensions) { + __classPrivateFieldSet(this, _X509Crl_extensions, this.asn.tbsCertList.crlExtensions.map((o) => ExtensionFactory.create(AsnConvert.serialize(o))), "f"); + } + } + return __classPrivateFieldGet(this, _X509Crl_extensions, "f"); + } + get tbs() { + if (!__classPrivateFieldGet(this, _X509Crl_tbs, "f")) { + __classPrivateFieldSet(this, _X509Crl_tbs, this.asn.tbsCertListRaw || AsnConvert.serialize(this.asn.tbsCertList), "f"); + } + return __classPrivateFieldGet(this, _X509Crl_tbs, "f"); + } + get tbsCertListSignatureAlgorithm() { + return this.asn.tbsCertList.signature; + } + get certListSignatureAlgorithm() { + return this.asn.signatureAlgorithm; + } + constructor(param) { + super(param, PemData.isAsnEncoded(param) ? CertificateList : undefined); + this.tag = PemConverter.CrlTag; + _X509Crl_tbs.set(this, void 0); + _X509Crl_signatureAlgorithm.set(this, void 0); + _X509Crl_issuerName.set(this, void 0); + _X509Crl_thisUpdate.set(this, void 0); + _X509Crl_nextUpdate.set(this, void 0); + _X509Crl_entries.set(this, void 0); + _X509Crl_extensions.set(this, void 0); + } + onInit(_asn) { + } + getExtension(type) { + for (const ext of this.extensions) { + if (typeof type === "string") { + if (ext.type === type) { + return ext; + } + } + else { + if (ext instanceof type) { + return ext; + } + } + } + return null; + } + getExtensions(type) { + return this.extensions.filter((o) => { + if (typeof type === "string") { + return o.type === type; + } + else { + return o instanceof type; + } + }); + } + async verify(params, crypto = cryptoProvider.get()) { + if (!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm)) { + throw new Error("algorithm identifier in the sequence tbsCertList and CertificateList mismatch"); + } + let keyAlgorithm; + let publicKey; + const paramsKey = params.publicKey; + try { + if (paramsKey instanceof X509Certificate) { + keyAlgorithm = { + ...paramsKey.publicKey.algorithm, + ...paramsKey.signatureAlgorithm, + }; + publicKey = await paramsKey.publicKey.export(keyAlgorithm, ["verify"]); + } + else if (paramsKey instanceof PublicKey) { + keyAlgorithm = { + ...paramsKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = await paramsKey.export(keyAlgorithm, ["verify"]); + } + else { + keyAlgorithm = { + ...paramsKey.algorithm, ...this.signatureAlgorithm, + }; + publicKey = paramsKey; + } + } + catch { + return false; + } + const signatureFormatters = container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let signature = null; + for (const signatureFormatter of signatureFormatters) { + signature = signatureFormatter.toWebSignature(keyAlgorithm, this.signature); + if (signature) { + break; + } + } + if (!signature) { + throw Error("Cannot convert ASN.1 signature value to WebCrypto format"); + } + return await crypto.subtle.verify(this.signatureAlgorithm, publicKey, signature, this.tbs); + } + async getThumbprint(...args) { + let crypto; + let algorithm = "SHA-1"; + if (args[0]) { + if (!args[0].subtle) { + algorithm = args[0] || algorithm; + crypto = args[1]; + } + else { + crypto = args[0]; + } + } + crypto !== null && crypto !== void 0 ? crypto : (crypto = cryptoProvider.get()); + return await crypto.subtle.digest(algorithm, this.rawData); + } + findRevoked(certOrSerialNumber) { + const serialNumber = typeof certOrSerialNumber === "string" ? certOrSerialNumber : certOrSerialNumber.serialNumber; + const serialBuffer = generateCertificateSerialNumber(serialNumber); + for (const revoked of this.asn.tbsCertList.revokedCertificates || []) { + if (BufferSourceConverter.isEqual(revoked.userCertificate, serialBuffer)) { + return new X509CrlEntry(AsnConvert.serialize(revoked)); + } + } + return null; + } +} +_X509Crl_tbs = new WeakMap(), _X509Crl_signatureAlgorithm = new WeakMap(), _X509Crl_issuerName = new WeakMap(), _X509Crl_thisUpdate = new WeakMap(), _X509Crl_nextUpdate = new WeakMap(), _X509Crl_entries = new WeakMap(), _X509Crl_extensions = new WeakMap(); + +class X509CrlGenerator { + static async create(params, crypto = cryptoProvider.get()) { + var _a; + const name = params.issuer instanceof Name + ? params.issuer + : new Name(params.issuer); + const asnX509Crl = new asn1X509.CertificateList({ + tbsCertList: new asn1X509.TBSCertList({ + version: asn1X509.Version.v2, + issuer: AsnConvert.parse(name.toArrayBuffer(), asn1X509.Name), + thisUpdate: new Time(params.thisUpdate || new Date()), + }), + }); + if (params.nextUpdate) { + asnX509Crl.tbsCertList.nextUpdate = new Time(params.nextUpdate); + } + if (params.extensions && params.extensions.length) { + asnX509Crl.tbsCertList.crlExtensions = new asn1X509.Extensions(params.extensions.map((o) => AsnConvert.parse(o.rawData, asn1X509.Extension)) || []); + } + if (params.entries && params.entries.length) { + asnX509Crl.tbsCertList.revokedCertificates = []; + for (const entry of params.entries) { + const userCertificate = PemData.toArrayBuffer(entry.serialNumber); + const index = asnX509Crl.tbsCertList.revokedCertificates + .findIndex((cert) => isEqual(cert.userCertificate, userCertificate)); + if (index > -1) { + throw new Error(`Certificate serial number ${entry.serialNumber} already exists in tbsCertList`); + } + const revokedCert = new RevokedCertificate({ + userCertificate: userCertificate, + revocationDate: new Time(entry.revocationDate || new Date()), + }); + if ("extensions" in entry && ((_a = entry.extensions) === null || _a === void 0 ? void 0 : _a.length)) { + revokedCert.crlEntryExtensions = entry.extensions.map((o) => (AsnConvert.parse(o.rawData, asn1X509.Extension))); + } + else { + revokedCert.crlEntryExtensions = []; + } + if (!(entry instanceof X509CrlEntry)) { + if (entry.reason) { + revokedCert.crlEntryExtensions.push(new asn1X509.Extension({ + extnID: asn1X509.id_ce_cRLReasons, + critical: false, + extnValue: new OctetString(AsnConvert.serialize(new asn1X509.CRLReason(entry.reason))), + })); + } + if (entry.invalidity) { + revokedCert.crlEntryExtensions.push(new asn1X509.Extension({ + extnID: asn1X509.id_ce_invalidityDate, + critical: false, + extnValue: new OctetString(AsnConvert.serialize(new asn1X509.InvalidityDate(entry.invalidity))), + })); + } + if (entry.issuer) { + const name = params.issuer instanceof Name + ? params.issuer + : new Name(params.issuer); + revokedCert.crlEntryExtensions.push(new asn1X509.Extension({ + extnID: asn1X509.id_ce_certificateIssuer, + critical: false, + extnValue: new OctetString(AsnConvert.serialize(AsnConvert.parse(name.toArrayBuffer(), asn1X509.Name))), + })); + } + } + asnX509Crl.tbsCertList.revokedCertificates.push(revokedCert); + } + } + const signingAlgorithm = { + ...params.signingAlgorithm, ...params.signingKey.algorithm, + }; + const algProv = container.resolve(diAlgorithmProvider); + asnX509Crl.tbsCertList.signature = asnX509Crl.signatureAlgorithm = algProv + .toAsnAlgorithm(signingAlgorithm); + const tbs = AsnConvert.serialize(asnX509Crl.tbsCertList); + const signature = await crypto.subtle.sign(signingAlgorithm, params.signingKey, tbs); + const signatureFormatters = container + .resolveAll(diAsnSignatureFormatter) + .reverse(); + let asnSignature = null; + for (const signatureFormatter of signatureFormatters) { + asnSignature = signatureFormatter.toAsnSignature(signingAlgorithm, signature); + if (asnSignature) { + break; + } + } + if (!asnSignature) { + throw Error("Cannot convert ASN.1 signature value to WebCrypto format"); + } + asnX509Crl.signature = asnSignature; + return new X509Crl(AsnConvert.serialize(asnX509Crl)); + } +} + +ExtensionFactory.register(asn1X509.id_ce_basicConstraints, BasicConstraintsExtension); +ExtensionFactory.register(asn1X509.id_ce_extKeyUsage, ExtendedKeyUsageExtension); +ExtensionFactory.register(asn1X509.id_ce_keyUsage, KeyUsagesExtension); +ExtensionFactory.register(asn1X509.id_ce_subjectKeyIdentifier, SubjectKeyIdentifierExtension); +ExtensionFactory.register(asn1X509.id_ce_authorityKeyIdentifier, AuthorityKeyIdentifierExtension); +ExtensionFactory.register(asn1X509.id_ce_subjectAltName, SubjectAlternativeNameExtension); +ExtensionFactory.register(asn1X509.id_ce_cRLDistributionPoints, CRLDistributionPointsExtension); +ExtensionFactory.register(asn1X509.id_pe_authorityInfoAccess, AuthorityInfoAccessExtension); +ExtensionFactory.register(asn1X509.id_ce_issuerAltName, IssuerAlternativeNameExtension); +AttributeFactory.register(asnPkcs9.id_pkcs9_at_challengePassword, ChallengePasswordAttribute); +AttributeFactory.register(asnPkcs9.id_pkcs9_at_extensionRequest, ExtensionsAttribute); +container.registerSingleton(diAsnSignatureFormatter, AsnDefaultSignatureFormatter); +container.registerSingleton(diAsnSignatureFormatter, AsnEcSignatureFormatter); +AsnEcSignatureFormatter.namedCurveSize.set("P-256", 32); +AsnEcSignatureFormatter.namedCurveSize.set("K-256", 32); +AsnEcSignatureFormatter.namedCurveSize.set("P-384", 48); +AsnEcSignatureFormatter.namedCurveSize.set("P-521", 66); + +export { AlgorithmProvider, AsnData, AsnDefaultSignatureFormatter, AsnEcSignatureFormatter, Attribute, AttributeFactory, AuthorityInfoAccessExtension, AuthorityKeyIdentifierExtension, BasicConstraintsExtension, CRLDistributionPointsExtension, CertificatePolicyExtension, ChallengePasswordAttribute, CryptoProvider, DN, DNS, DefaultAlgorithmSerializer, EMAIL, EcAlgorithm, EdAlgorithm, ExtendedKeyUsage, ExtendedKeyUsageExtension, Extension, ExtensionFactory, ExtensionsAttribute, GUID, GeneralName, GeneralNames, IP, IssuerAlternativeNameExtension, KeyUsageFlags, KeyUsagesExtension, Name, NameIdentifier, OidSerializer, PemConverter, PemData, Pkcs10CertificateRequest, Pkcs10CertificateRequestGenerator, PublicKey, REGISTERED_ID, RsaAlgorithm, ShaAlgorithm, SubjectAlternativeNameExtension, SubjectKeyIdentifierExtension, TextConverter, TextObject, UPN, URL, X509Certificate, X509CertificateGenerator, X509Certificates, X509ChainBuilder, X509Crl, X509CrlEntry, X509CrlGenerator, X509CrlReason, cryptoProvider, diAlgorithm, diAlgorithmProvider, diAsnSignatureFormatter, idEd25519, idEd448, idX25519, idX448 }; diff --git a/node_modules/@peculiar/x509/build/x509.js b/node_modules/@peculiar/x509/build/x509.js new file mode 100644 index 0000000000000000000000000000000000000000..727eee7bbbf083343b63d329130748c0da1f0762 --- /dev/null +++ b/node_modules/@peculiar/x509/build/x509.js @@ -0,0 +1,61 @@ +/*! + * MIT License + * + * Copyright (c) Peculiar Ventures. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +var x509=function(e){"use strict";var t,r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={};!function(){return t||(t=1,function(e){!function(){var t="object"==typeof globalThis?globalThis:"object"==typeof r?r:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),i=n(e);function n(e,t){return function(r,i){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:i}),t&&t(r,i)}}void 0!==t.Reflect&&(i=n(t.Reflect,i)),function(e,t){var r=Object.prototype.hasOwnProperty,i="function"==typeof Symbol,n=i&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",s=i&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!o&&!a,l={create:o?function(){return he(Object.create(null))}:a?function(){return he({__proto__:null})}:function(){return he({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),h="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),p="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:le(),f="function"==typeof WeakMap?WeakMap:ue(),y=i?Symbol.for("@reflect-metadata:registry"):void 0,d=ne(),g=se(d);function v(e,t,r,i){if(D(r)){if(!z(e))throw new TypeError;if(!G(t))throw new TypeError;return E(e,t)}if(!z(e))throw new TypeError;if(!M(t))throw new TypeError;if(!M(i)&&!D(i)&&!L(i))throw new TypeError;return L(i)&&(i=void 0),O(e,t,r=W(r),i)}function m(e,t){function r(r,i){if(!M(r))throw new TypeError;if(!D(i)&&!J(i))throw new TypeError;U(e,t,r,i)}return r}function w(e,t,r,i){if(!M(r))throw new TypeError;return D(i)||(i=W(i)),U(e,t,r,i)}function b(e,t,r){if(!M(t))throw new TypeError;return D(r)||(r=W(r)),N(e,t,r)}function A(e,t,r){if(!M(t))throw new TypeError;return D(r)||(r=W(r)),I(e,t,r)}function S(e,t,r){if(!M(t))throw new TypeError;return D(r)||(r=W(r)),T(e,t,r)}function x(e,t,r){if(!M(t))throw new TypeError;return D(r)||(r=W(r)),j(e,t,r)}function B(e,t){if(!M(e))throw new TypeError;return D(t)||(t=W(t)),P(e,t)}function k(e,t){if(!M(e))throw new TypeError;return D(t)||(t=W(t)),R(e,t)}function C(e,t,r){if(!M(t))throw new TypeError;if(D(r)||(r=W(r)),!M(t))throw new TypeError;D(r)||(r=W(r));var i=ae(t,r,!1);return!D(i)&&i.OrdinaryDeleteMetadata(e,t,r)}function E(e,t){for(var r=e.length-1;r>=0;--r){var i=(0,e[r])(t);if(!D(i)&&!L(i)){if(!G(i))throw new TypeError;t=i}}return t}function O(e,t,r,i){for(var n=e.length-1;n>=0;--n){var s=(0,e[n])(t,r,i);if(!D(s)&&!L(s)){if(!M(s))throw new TypeError;i=s}}return i}function N(e,t,r){if(I(e,t,r))return!0;var i=re(t);return!L(i)&&N(e,i,r)}function I(e,t,r){var i=ae(t,r,!1);return!D(i)&&F(i.OrdinaryHasOwnMetadata(e,t,r))}function T(e,t,r){if(I(e,t,r))return j(e,t,r);var i=re(t);return L(i)?void 0:T(e,i,r)}function j(e,t,r){var i=ae(t,r,!1);if(!D(i))return i.OrdinaryGetOwnMetadata(e,t,r)}function U(e,t,r,i){ae(r,i,!0).OrdinaryDefineOwnMetadata(e,t,r,i)}function P(e,t){var r=R(e,t),i=re(e);if(null===i)return r;var n=P(i,t);if(n.length<=0)return r;if(r.length<=0)return n;for(var s=new p,o=[],a=0,c=r;a=0&&e=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}();return function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var i=this._keys.length,n=r+1;n=0;i--)r+=e[e.length-1-i]*Math.pow(2,t*i);return r}function y(e,t,r=-1){const i=r;let n=e,s=0,o=Math.pow(2,t);for(let r=1;r<8;r++){if(e=0;e--){const r=Math.pow(2,e*t);o[s-e-1]=Math.floor(n/r),n-=o[s-e-1]*r}return e}o*=Math.pow(2,t)}return new ArrayBuffer(0)}function d(...e){let t=0,r=0;for(const r of e)t+=r.length;const i=new ArrayBuffer(t),n=new Uint8Array(i);for(const t of e)n.set(t,r),r+=t.length;return n}function g(){const e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const t=255===e[0]&&128&e[1],r=0===e[0]&&!(128&e[1]);(t||r)&&this.warnings.push("Needlessly long format")}const t=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(t);for(let e=0;e=s.length)return this.error="End of input reached before message was fully decoded",-1;if(e===r){r+=255;const e=new Uint8Array(r);for(let r=0;r8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const a=t+1,c=i.subarray(a,a+o);return 0===c[o-1]&&this.warnings.push("Needlessly long encoded length"),this.length=f(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,t+this.blockLength}toBER(e=!1){let t,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),!1===e&&(r=new Uint8Array(t),r[0]=128),t;if(this.longFormUsed){const i=y(this.length,8);if(i.byteLength>127)return this.error="Too big length",E;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const n=new Uint8Array(i);r=new Uint8Array(t),r[0]=128|i.byteLength;for(let e=0;e=37&&!1===n.idBlock.isHexOnly)return n.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:n};switch(n.idBlock.tagNumber){case 0:if(n.idBlock.isConstructed&&n.lenBlock.length>0)return n.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:n};a=D.EndOfContent;break;case 1:a=D.Boolean;break;case 2:a=D.Integer;break;case 3:a=D.BitString;break;case 4:a=D.OctetString;break;case 5:a=D.Null;break;case 6:a=D.ObjectIdentifier;break;case 10:a=D.Enumerated;break;case 12:a=D.Utf8String;break;case 13:a=D.RelativeObjectIdentifier;break;case 14:a=D.TIME;break;case 15:return n.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:n};case 16:a=D.Sequence;break;case 17:a=D.Set;break;case 18:a=D.NumericString;break;case 19:a=D.PrintableString;break;case 20:a=D.TeletexString;break;case 21:a=D.VideotexString;break;case 22:a=D.IA5String;break;case 23:a=D.UTCTime;break;case 24:a=D.GeneralizedTime;break;case 25:a=D.GraphicString;break;case 26:a=D.VisibleString;break;case 27:a=D.GeneralString;break;case 28:a=D.UniversalString;break;case 29:a=D.CharacterString;break;case 30:a=D.BmpString;break;case 31:a=D.DATE;break;case 32:a=D.TimeOfDay;break;case 33:a=D.DateTime;break;case 34:a=D.Duration;break;default:{const e=n.idBlock.isConstructed?new D.Constructed:new D.Primitive;e.idBlock=n.idBlock,e.lenBlock=n.lenBlock,e.warnings=n.warnings,n=e}}}else a=n.idBlock.isConstructed?D.Constructed:D.Primitive;return n=function(e,t){if(e instanceof t)return e;const r=new t;return r.idBlock=e.idBlock,r.lenBlock=e.lenBlock,r.warnings=e.warnings,r.valueBeforeDecodeView=e.valueBeforeDecodeView,r}(n,a),o=n.fromBER(e,t,n.lenBlock.isIndefiniteForm?r:n.lenBlock.length),n.valueBeforeDecodeView=e.subarray(i,i+n.blockLength),{offset:o,result:n}}function X(e){if(!e.byteLength){const e=new L({},P);return e.error="Input buffer has zero length",{offset:-1,result:e}}return J(n.toUint8Array(e).slice(),0,e.byteLength)}function Z(e,t){return e?1:t}K=G,D.Primitive=K,G.NAME="PRIMITIVE";class Y extends P{constructor({value:e=[],isIndefiniteForm:t=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,r){const i=n.toUint8Array(e);if(!b(this,i,t,r))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+r),0===this.valueBeforeDecodeView.length)return this.warnings.push("Zero buffer length"),t;let s=t;for(;Z(this.isIndefiniteForm,r)>0;){const e=J(i,s,r);if(-1===e.offset)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(s=e.offset,this.blockLength+=e.result.blockLength,r-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===N)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===N?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const r=t||new A;for(let t=0;t` ${e}`).join("\n"));const t=3===this.idBlock.tagClass?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :\n${e.join("\n")}`:`${t} :`}}F=Q,D.Constructed=F,Q.NAME="CONSTRUCTED";class ee extends P{fromBER(e,t,r){return t}toBER(e){return E}}ee.override="EndOfContentValueBlock";class te extends L{constructor(e={}){super(e,ee),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}_=te,D.EndOfContent=_,te.NAME=N;class re extends L{constructor(e={}){super(e,P),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,t+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+r}toBER(e,t){const r=new ArrayBuffer(2);if(!e){const e=new Uint8Array(r);e[0]=5,e[1]=0}return t&&t.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}W=re,D.Null=W,re.NAME="NULL";class ie extends(j(P)){get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=n.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,r){const i=n.toUint8Array(e);return b(this,i,t,r)?(this.valueHexView=i.subarray(t,t+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,g.call(this),this.blockLength=r,t+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}ie.NAME="BooleanValueBlock";class ne extends L{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,ie),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}z=ne,D.Boolean=z,ne.NAME="BOOLEAN";class se extends(j(Y)){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Y.prototype.fromBER.call(this,e,t,r),-1===i)return i;for(let e=0;e0&&r.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=r.unusedBits}return i}const s=n.toUint8Array(e);if(!b(this,s,t,r))return-1;const o=s.subarray(t,t+r);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const e=o.subarray(1);try{if(e.byteLength){const t=J(e,0,e.byteLength);-1!==t.offset&&t.offset===r-1&&(this.value=[t.result])}}catch(e){}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+r}toBER(e,t){if(this.isConstructed)return Y.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return E;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}var ce;ae.NAME="BitStringValueBlock";let le=class extends L{constructor({idBlock:e={},lenBlock:t={},...r}={}){var i,n;null!==(i=r.isConstructed)&&void 0!==i||(r.isConstructed=!!(null===(n=r.value)||void 0===n?void 0:n.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},ae),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Q.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const r of t)e.push(r.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};var ue,he,pe,fe,ye,de,ge;function ve(e,t){const r=new Uint8Array([0]),i=new Uint8Array(e),n=new Uint8Array(t);let s=i.slice(0);const o=s.length-1,a=n.slice(0),c=a.length-1;let l=0;let u=0;for(let e=c=0;e--,u++){if(!0==u=s.length)s=d(new Uint8Array([l%10]),s);else s[o-u]=l%10}return r[0]>0&&(s=d(r,s)),s}function me(e){if(e>=S.length)for(let t=S.length;t<=e;t++){const e=new Uint8Array([0]);let r=S[t-1].slice(0);for(let t=r.length-1;t>=0;t--){const i=new Uint8Array([(r[t]<<1)+e[0]]);e[0]=i[0]/10,r[t]=i[0]%10}e[0]>0&&(r=d(e,r)),S.push(r)}return S[e]}function we(e,t){let r=0;const i=new Uint8Array(e),n=new Uint8Array(t),s=i.slice(0),o=s.length-1,a=n.slice(0),c=a.length-1;let l,u=0;for(let e=c;e>=0;e--,u++)if(l=s[o-u]-a[c-u]-r,!0==l<0)r=1,s[o-u]=l+10;else r=0,s[o-u]=l;if(r>0)for(let e=o-c+1;e>=0;e--,u++){if(l=s[o-u]-r,!(l<0)){r=0,s[o-u]=l;break}r=1,s[o-u]=l+10}return s.slice()}ce=le,D.BitString=ce,le.NAME=T;class be extends(j(P)){setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=g.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),void 0!==e&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(function(e){const t=e<0?-1*e:e;let r=128;for(let i=1;i<8;i++){if(t<=r){if(e<0){const e=y(r-t,8,i);return new Uint8Array(e)[0]|=128,e}let n=y(t,8,i),s=new Uint8Array(n);if(128&s[0]){const e=n.slice(0),t=new Uint8Array(e);n=new ArrayBuffer(n.byteLength+1),s=new Uint8Array(n);for(let r=0;r1&&(i=s.length+1),this.valueHexView=s.subarray(i-s.length)),n}toDER(e=!1){const t=this.valueHexView;switch(!0){case!!(128&t[0]):{const e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case 0===t[0]&&!(128&t[1]):this.valueHexView=this.valueHexView.subarray(1)}return this.toBER(e)}fromBER(e,t,r){const i=super.fromBER(e,t,r);return-1===i||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=8*this.valueHexView.length-1;let t,r=new Uint8Array(8*this.valueHexView.length/3),i=0;const n=this.valueHexView;let s="",o=!1;for(let o=n.byteLength-1;o>=0;o--){t=n[o];for(let n=0;n<8;n++){if(!(1&~t))if(i===e)r=we(me(i),r),s="-";else r=ve(r,me(i));i++,t>>=1}}for(let e=0;e0;){const t=new xe;if(i=t.fromBER(e,i,r),-1===i)return this.blockLength=0,this.error=t.error,i;0===this.value.length&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return i}toBER(e){const t=[];for(let r=0;rNumber.MAX_SAFE_INTEGER){m();const t=BigInt(i);e.valueBigInt=t}else if(e.valueDec=parseInt(i,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,n=!0),this.value.push(e)}}while(-1!==r)}toString(){let e="",t=!1;for(let r=0;r0;){const t=new Ce;if(i=t.fromBER(e,i,r),-1===i)return this.blockLength=0,this.error=t.error,i;this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return i}toBER(e,t){const r=[];for(let t=0;t4)continue;const s=4-n.length;for(let e=n.length-1;e>=0;e--)r[4*i+e+s]=n[e]}this.valueBlock.value=e}}it.NAME="UniversalStringValueBlock";class nt extends it{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}De=nt,D.UniversalString=De,nt.NAME="UniversalString";class st extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Le=st,D.NumericString=Le,st.NAME="NumericString";class ot extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}He=ot,D.PrintableString=He,ot.NAME="PrintableString";class at extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Me=at,D.TeletexString=Me,at.NAME="TeletexString";class ct extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}$e=ct,D.VideotexString=$e,ct.NAME="VideotexString";class lt extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Ke=lt,D.IA5String=Ke,lt.NAME="IA5String";class ut extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Fe=ut,D.GraphicString=Fe,ut.NAME="GraphicString";class ht extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}_e=ht,D.VisibleString=_e,ht.NAME="VisibleString";class pt extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}We=pt,D.GeneralString=We,pt.NAME="GeneralString";class ft extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}ze=ft,D.CharacterString=ze,ft.NAME="CharacterString";class yt extends ht{constructor({value:e,valueDate:t,...r}={}){if(super(r),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let t=0;t=50?1900+r:2e3+r,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e="iso"){if("iso"===e){const e=new Array(7);return e[0]=v(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=v(this.month,2),e[2]=v(this.day,2),e[3]=v(this.hour,2),e[4]=v(this.minute,2),e[5]=v(this.second,2),e[6]="Z",e.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}qe=yt,D.UTCTime=qe,yt.NAME="UTCTime";class dt extends yt{constructor(e={}){var t;super(e),null!==(t=this.millisecond)&&void 0!==t||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){const e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t,r=!1,i="",n="",s=0,o=0,a=0;if("Z"===e[e.length-1])i=e.substring(0,e.length-1),r=!0;else{const t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw new Error("Wrong input string for conversion");i=e}if(r){if(-1!==i.indexOf("+"))throw new Error("Wrong input string for conversion");if(-1!==i.indexOf("-"))throw new Error("Wrong input string for conversion")}else{let e=1,t=i.indexOf("+"),r="";if(-1===t&&(t=i.indexOf("-"),e=-1),-1!==t){if(r=i.substring(t+1),i=i.substring(0,t),2!==r.length&&4!==r.length)throw new Error("Wrong input string for conversion");let n=parseInt(r.substring(0,2),10);if(isNaN(n.valueOf()))throw new Error("Wrong input string for conversion");if(o=e*n,4===r.length){if(n=parseInt(r.substring(2,4),10),isNaN(n.valueOf()))throw new Error("Wrong input string for conversion");a=e*n}}}let c=i.indexOf(".");if(-1===c&&(c=i.indexOf(",")),-1!==c){const e=new Number(`0${i.substring(c)}`);if(isNaN(e.valueOf()))throw new Error("Wrong input string for conversion");s=e.valueOf(),n=i.substring(0,c)}else n=i;switch(!0){case 8===n.length:if(t=/(\d{4})(\d{2})(\d{2})/gi,-1!==c)throw new Error("Wrong input string for conversion");break;case 10===n.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*s;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 12===n.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*s;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 14===n.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){const e=1e3*s;this.millisecond=Math.floor(e)}break;default:throw new Error("Wrong input string for conversion")}const l=t.exec(n);if(null===l)throw new Error("Wrong input string for conversion");for(let e=1;e0&&r.valueBlock.value[0]instanceof xt&&(s=t.valueBlock.value.length),0===s)return{verified:!0,result:e};if(0===t.valueBlock.value.length&&0!==r.valueBlock.value.length){let t=!0;for(let e=0;e=t.valueBlock.value.length){if(!1===r.valueBlock.value[o].optional){const t={verified:!1,result:e};return e.error="Inconsistent length between ASN.1 data and schema",r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&(delete e[r.name],t.name=r.name)),t}}else if(r.valueBlock.value[0]instanceof xt){if(n=Bt(e,t.valueBlock.value[o],r.valueBlock.value[0].value),!1===n.verified){if(!r.valueBlock.value[0].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&delete e[r.name]),n;i++}if(B in r.valueBlock.value[0]&&r.valueBlock.value[0].name.length>0){let i={};i="local"in r.valueBlock.value[0]&&r.valueBlock.value[0].local?t:e,void 0===i[r.valueBlock.value[0].name]&&(i[r.valueBlock.value[0].name]=[]),i[r.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(n=Bt(e,t.valueBlock.value[o-i],r.valueBlock.value[o]),!1===n.verified){if(!r.valueBlock.value[o].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&delete e[r.name]),n;i++}if(!1===n.verified){const t={verified:!1,result:e};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&(delete e[r.name],t.name=r.name)),t}return{verified:!0,result:e}}if(r.primitiveSchema&&k in t.valueBlock){const i=J(t.valueBlock.valueHexView);if(-1===i.offset){const t={verified:!1,result:i.result};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&(delete e[r.name],t.name=r.name)),t}return Bt(e,i.result,r.primitiveSchema)}return{verified:!0,result:e}}var kt,Ct,Et=Object.freeze({__proto__:null,Any:At,BaseBlock:L,BaseStringBlock:M,BitString:le,BmpString:rt,Boolean:ne,CharacterString:ft,Choice:St,Constructed:Q,DATE:gt,DateTime:mt,Duration:wt,EndOfContent:te,Enumerated:Se,GeneralString:pt,GeneralizedTime:dt,GraphicString:ut,HexBlock:j,IA5String:lt,Integer:Ae,Null:re,NumericString:st,ObjectIdentifier:ke,OctetString:oe,Primitive:G,PrintableString:ot,RawData:class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=n.toUint8Array(e)}constructor({data:e=O}={}){this.dataView=n.toUint8Array(e)}fromBER(e,t,r){const i=t+r;return this.dataView=n.toUint8Array(e).subarray(t,i),i}toBER(e){return this.dataView.slice().buffer}},RelativeObjectIdentifier:Oe,Repeated:xt,Sequence:Ne,Set:Ie,TIME:bt,TeletexString:at,TimeOfDay:vt,UTCTime:yt,UniversalString:nt,Utf8String:et,ValueBlock:P,VideotexString:ct,ViewWriter:A,VisibleString:ht,compareSchema:Bt,fromBER:X,verifySchema:function(e,t){if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const r=J(n.toUint8Array(e));return-1===r.offset?{verified:!1,result:r.result}:Bt(r.result,r.result,t)}});!function(e){e[e.Sequence=0]="Sequence",e[e.Set=1]="Set",e[e.Choice=2]="Choice"}(kt||(kt={})),function(e){e[e.Any=1]="Any",e[e.Boolean=2]="Boolean",e[e.OctetString=3]="OctetString",e[e.BitString=4]="BitString",e[e.Integer=5]="Integer",e[e.Enumerated=6]="Enumerated",e[e.ObjectIdentifier=7]="ObjectIdentifier",e[e.Utf8String=8]="Utf8String",e[e.BmpString=9]="BmpString",e[e.UniversalString=10]="UniversalString",e[e.NumericString=11]="NumericString",e[e.PrintableString=12]="PrintableString",e[e.TeletexString=13]="TeletexString",e[e.VideotexString=14]="VideotexString",e[e.IA5String=15]="IA5String",e[e.GraphicString=16]="GraphicString",e[e.VisibleString=17]="VisibleString",e[e.GeneralString=18]="GeneralString",e[e.CharacterString=19]="CharacterString",e[e.UTCTime=20]="UTCTime",e[e.GeneralizedTime=21]="GeneralizedTime",e[e.DATE=22]="DATE",e[e.TimeOfDay=23]="TimeOfDay",e[e.DateTime=24]="DateTime",e[e.Duration=25]="Duration",e[e.TIME=26]="TIME",e[e.Null=27]="Null"}(Ct||(Ct={}));class Ot{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if("number"==typeof e)this.fromNumber(e);else{if(!n.isBufferSource(e))throw TypeError("Unsupported type of 'params' argument for BitString");this.unusedBits=t,this.value=n.toArrayBuffer(e)}}fromASN(e){if(!(e instanceof le))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new le({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new le({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const r of t)e+=r.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const r=t.length+7>>3;this.unusedBits=(r<<3)-t.length;const i=new Uint8Array(r);t=t.padStart(r<<3,"0").split("").reverse().join("");let n=0;for(;ne instanceof re?null:e.valueBeforeDecodeView,toASN:e=>{if(null===e)return new re;const t=X(e);if(t.result.error)throw new Error(t.result.error);return t.result}},Tt={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new Ae({value:+e})},jt={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new Se({value:e})},Ut={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new Ae({valueHex:e})},Pt={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new le({valueHex:e})},Rt={fromASN:e=>e.valueBlock.toString(),toASN:e=>new ke({value:e})},Vt={fromASN:e=>e.valueBlock.value,toASN:e=>new ne({value:e})},Dt={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new oe({valueHex:e})},Lt={fromASN:e=>new Nt(e.getValue()),toASN:e=>e.toASN()};function Ht(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}const Mt=Ht(et),$t=Ht(rt),Kt=Ht(nt),Ft=Ht(st),_t=Ht(ot),Wt=Ht(at),zt=Ht(ct),qt=Ht(lt),Gt=Ht(ut),Jt=Ht(ht),Xt=Ht(pt),Zt=Ht(ft),Yt={fromASN:e=>e.toDate(),toASN:e=>new yt({valueDate:e})},Qt={fromASN:e=>e.toDate(),toASN:e=>new dt({valueDate:e})},er={fromASN:()=>null,toASN:()=>new re};function tr(e){switch(e){case Ct.Any:return It;case Ct.BitString:return Pt;case Ct.BmpString:return $t;case Ct.Boolean:return Vt;case Ct.CharacterString:return Zt;case Ct.Enumerated:return jt;case Ct.GeneralString:return Xt;case Ct.GeneralizedTime:return Qt;case Ct.GraphicString:return Gt;case Ct.IA5String:return qt;case Ct.Integer:return Tt;case Ct.Null:return er;case Ct.NumericString:return Ft;case Ct.ObjectIdentifier:return Rt;case Ct.OctetString:return Dt;case Ct.PrintableString:return _t;case Ct.TeletexString:return Wt;case Ct.UTCTime:return Yt;case Ct.UniversalString:return Kt;case Ct.Utf8String:return Mt;case Ct.VideotexString:return zt;case Ct.VisibleString:return Jt;default:return null}}function rr(e){return"function"==typeof e&&e.prototype?!(!e.prototype.toASN||!e.prototype.fromASN)||rr(e.prototype):!!(e&&"object"==typeof e&&"toASN"in e&&"fromASN"in e)}function ir(e){var t;if(e){const r=Object.getPrototypeOf(e);return(null===(t=null==r?void 0:r.prototype)||void 0===t?void 0:t.constructor)===Array||ir(r)}return!1}function nr(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let t=0;tt=>{let r;sr.has(t)?r=sr.get(t):(r=sr.createDefault(t),sr.set(t,r)),Object.assign(r,e)},ar=e=>(t,r)=>{let i;sr.has(t.constructor)?i=sr.get(t.constructor):(i=sr.createDefault(t.constructor),sr.set(t.constructor,i));const n=Object.assign({},e);if("number"==typeof n.type&&!n.converter){const i=tr(e.type);if(!i)throw new Error(`Cannot get default converter for property '${r}' of ${t.constructor.name}`);n.converter=i}n.raw=e.raw,i.items[r]=n};class cr extends Error{constructor(){super(...arguments),this.schemas=[]}}class lr{static parse(e,t){const r=X(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,t)}static fromASN(e,t){try{if(rr(t)){return(new t).fromASN(e)}const r=sr.get(t);sr.cache(t);let i=r.schema;const n=this.handleChoiceTypes(e,r,t,i);if(null==n?void 0:n.result)return n.result;(null==n?void 0:n.targetSchema)&&(i=n.targetSchema);const s=this.handleSequenceTypes(e,r,t,i),o=new t;return ir(t)?this.handleArrayTypes(e,r,t):(this.processSchemaItems(r,s,o),o)}catch(e){throw e instanceof cr&&e.schemas.push(t.name),e}}static handleChoiceTypes(e,t,r,i){if(e.constructor===Q&&t.type===kt.Choice&&3===e.idBlock.tagClass)for(const i in t.items){const n=t.items[i];if(n.context===e.idBlock.tagNumber&&n.implicit&&"function"==typeof n.type&&sr.has(n.type)){const t=sr.get(n.type);if(t&&t.type===kt.Sequence){const t=new Ne;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in t.valueBlock){t.valueBlock.value=e.valueBlock.value;const s=this.fromASN(t,n.type),o=new r;return o[i]=s,{result:o}}}}}else if(e.constructor===Q&&t.type!==kt.Choice){const r=new Q({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(const r in t.items)delete e[r];return{targetSchema:r}}return null}static handleSequenceTypes(e,t,r,i){if(t.type===kt.Sequence){const t=Bt({},e,i);if(!t.verified)throw new cr(`Data does not match to ${r.name} ASN1 schema.${t.result.error?` ${t.result.error}`:""}`);return t}{const t=Bt({},e,i);if(!t.verified)throw new cr(`Data does not match to ${r.name} ASN1 schema.${t.result.error?` ${t.result.error}`:""}`);return t}}static processRepeatedField(e,t,r){let i=e.slice(t);if(1===i.length&&"Sequence"===i[0].constructor.name){const e=i[0];e.valueBlock&&e.valueBlock.value&&Array.isArray(e.valueBlock.value)&&(i=e.valueBlock.value)}if("number"==typeof r.type){const e=tr(r.type);if(!e)throw new Error(`No converter for ASN.1 type ${r.type}`);return i.filter(e=>e&&e.valueBlock).map(t=>{try{return e.fromASN(t)}catch(e){return}}).filter(e=>void 0!==e)}return i.filter(e=>e&&e.valueBlock).map(e=>{try{return this.fromASN(e,r.type)}catch(e){return}}).filter(e=>void 0!==e)}static processPrimitiveField(e,t){const r=tr(t.type);if(!r)throw new Error(`No converter for ASN.1 type ${t.type}`);return r.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&"function"==typeof e.type&&sr.has(e.type)&&sr.get(e.type).type===kt.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(e){if(e instanceof cr&&/Wrong values for Choice type/.test(e.message))return{processed:!1};throw e}}static handleArrayTypes(e,t,r){if(!("value"in e.valueBlock)||!Array.isArray(e.valueBlock.value))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const i=t.itemType;if("number"==typeof i){const t=tr(i);if(!t)throw new Error(`Cannot get default converter for array item of ${r.name} ASN1 schema`);return r.from(e.valueBlock.value,e=>t.fromASN(e))}return r.from(e.valueBlock.value,e=>this.fromASN(e,i))}static processSchemaItems(e,t,r){for(const i in e.items){const n=t.result[i];if(!n)continue;const s=e.items[i],o=s.type;let a;a="number"==typeof o||rr(o)?this.processPrimitiveSchemaItem(n,s,o):this.processComplexSchemaItem(n,s,o),a&&"object"==typeof a&&"value"in a&&"raw"in a?(r[i]=a.value,r[`${i}Raw`]=a.raw):r[i]=a}}static processPrimitiveSchemaItem(e,t,r){var i;const n=null!==(i=t.converter)&&void 0!==i?i:rr(r)?new r:null;if(!n)throw new Error("Converter is empty");return t.repeated?this.processRepeatedPrimitiveItem(e,t,n):this.processSinglePrimitiveItem(e,t,r,n)}static processRepeatedPrimitiveItem(e,t,r){if(t.implicit){const i=new("sequence"===t.repeated?Ne:Ie);i.valueBlock=e.valueBlock;const n=X(i.toBER(!1));if(-1===n.offset)throw new Error(`Cannot parse the child item. ${n.result.error}`);if(!("value"in n.result.valueBlock)||!Array.isArray(n.result.valueBlock.value))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const s=n.result.valueBlock.value;return Array.from(s,e=>r.fromASN(e))}return Array.from(e,e=>r.fromASN(e))}static processSinglePrimitiveItem(e,t,r,i){let n=e;if(t.implicit){let e;if(rr(r))e=(new r).toSchema("");else{const t=Ct[r],i=Et[t];if(!i)throw new Error(`Cannot get '${t}' class from asn1js module`);e=new i}e.valueBlock=n.valueBlock,n=X(e.toBER(!1)).result}return i.fromASN(n)}static processComplexSchemaItem(e,t,r){if(t.repeated){if(!Array.isArray(e))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");return Array.from(e,e=>this.fromASN(e,r))}{const i=this.handleImplicitTagging(e,t,r);if(!this.isOptionalChoiceField(t)){const n=this.fromASN(i,r);return t.raw?{value:n,raw:e.valueBeforeDecodeView}:n}try{return this.fromASN(i,r)}catch(e){if(e instanceof cr&&/Wrong values for Choice type/.test(e.message))return;throw e}}}static handleImplicitTagging(e,t,r){if(t.implicit&&"number"==typeof t.context){const t=sr.get(r);if(t.type===kt.Sequence){const t=new Ne;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}else if(t.type===kt.Set){const t=new Ie;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}}return e}}class ur{static serialize(e){return e instanceof L?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&"object"==typeof e&&rr(e))return e.toASN();if(!e||"object"!=typeof e)throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,r=sr.get(t);sr.cache(t);let i,n=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if("number"==typeof r.itemType){const i=tr(r.itemType);if(!i)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);n=e.map(e=>i.toASN(e))}else n=e.map(e=>this.toAsnItem({type:r.itemType},"[]",t,e))}else for(const i in r.items){const s=r.items[i],o=e[i];if(void 0===o||s.defaultValue===o||"object"==typeof s.defaultValue&&"object"==typeof o&&nr(this.serialize(s.defaultValue),this.serialize(o)))continue;const a=ur.toAsnItem(s,i,t,o);if("number"==typeof s.context)if(s.implicit)if(s.repeated||"number"!=typeof s.type&&!rr(s.type))n.push(new Q({optional:s.optional,idBlock:{tagClass:3,tagNumber:s.context},value:a.valueBlock.value}));else{const e={};e.valueHex=a instanceof re?a.valueBeforeDecodeView:a.valueBlock.toBER(),n.push(new G({optional:s.optional,idBlock:{tagClass:3,tagNumber:s.context},...e}))}else n.push(new Q({optional:s.optional,idBlock:{tagClass:3,tagNumber:s.context},value:[a]}));else s.repeated?n=n.concat(a):n.push(a)}switch(r.type){case kt.Sequence:i=new Ne({value:n});break;case kt.Set:i=new Ie({value:n});break;case kt.Choice:if(!n[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);i=n[0]}return i}static toAsnItem(e,t,r,i){let n;if("number"==typeof e.type){const s=e.converter;if(!s)throw new Error(`Property '${t}' doesn't have converter for type ${Ct[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const t=Array.from(i,e=>s.toASN(e));n=new("sequence"===e.repeated?Ne:Ie)({value:t})}else n=s.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const t=Array.from(i,e=>this.toASN(e));n=new("sequence"===e.repeated?Ne:Ie)({value:t})}else n=this.toASN(i);return n}}class hr extends Array{constructor(e=[]){if("number"==typeof e)super(e);else{super();for(const t of e)this.push(t)}}}class pr{static serialize(e){return ur.serialize(e)}static parse(e,t){return lr.parse(e,t)}static toString(e){const t=X(n.isBufferSource(e)?n.toArrayBuffer(e):pr.serialize(e));if(-1===t.offset)throw new Error(`Cannot decode ASN.1 data. ${t.result.error}`);return t.result.toString()}}var fr,yr,dr,gr=function(e,t){return gr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},gr(e,t)};function vr(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}gr(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function mr(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function wr(e,t,r,i){return new(r||(r=Promise))(function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,a)}c((i=i.apply(e,t||[])).next())})}function br(e,t){var r,i,n,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Sr(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}function xr(){for(var e=[],t=0;t{const t=parseInt(e,10);if(isNaN(t)||t<0||t>255)throw new Error("Invalid IPv4 address part");return t})}static parseIPv6(e){const t=this.expandIPv6(e).split(":");if(8!==t.length)throw new Error("Invalid IPv6 address");return t.reduce((e,t)=>{const r=parseInt(t,16);if(isNaN(r)||r<0||r>65535)throw new Error("Invalid IPv6 address part");return e.push(r>>8&255),e.push(255&r),e},[])}static expandIPv6(e){if(!e.includes("::"))return e;const t=e.split("::");if(t.length>2)throw new Error("Invalid IPv6 address");const r=t[0]?t[0].split(":"):[],i=t[1]?t[1].split(":"):[],n=8-(r.length+i.length);if(n<0)throw new Error("Invalid IPv6 address");return[...r,...Array(n).fill("0"),...i].join(":")}static formatIPv6(e){const t=[];for(let r=0;r<16;r+=2)t.push((e[r]<<8|e[r+1]).toString(16));return this.compressIPv6(t.join(":"))}static compressIPv6(e){const t=e.split(":");let r=-1,i=0,n=-1,s=0;for(let e=0;ei&&(r=n,i=s),n=-1,s=0);if(s>i&&(r=n,i=s),i>1){return`${t.slice(0,r).join(":")}::${t.slice(r+i).join(":")}`}return e}static parseCIDR(e){const[t,r]=e.split("/"),i=parseInt(r,10);if(this.isIPv4(t)){if(i<0||i>32)throw new Error("Invalid IPv4 prefix length");return[this.parseIPv4(t),i]}if(i<0||i>128)throw new Error("Invalid IPv6 prefix length");return[this.parseIPv6(t),i]}static decodeIP(e){if(64===e.length&&0===parseInt(e,16))return"::/0";if(16!==e.length)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((e,t)=>e+ +t,0);let r=e.slice(0,8).replace(/(.{2})/g,e=>`${parseInt(e,16)}.`);return r=r.slice(0,-1),`${r}/${t}`}static toString(e){const t=new Uint8Array(e);if(4===t.length)return Array.from(t).join(".");if(16===t.length)return this.formatIPv6(t);if(8===t.length||32===t.length){const e=t.length/2,r=t.slice(0,e),i=t.slice(e);if(t.every(e=>0===e))return 8===t.length?"0.0.0.0/0":"::/0";const n=i.reduce((e,t)=>e+(t.toString(2).match(/1/g)||[]).length,0);if(8===t.length){return`${Array.from(r).join(".")}/${n}`}return`${this.formatIPv6(r)}/${n}`}return this.decodeIP(h.ToHex(e))}static fromString(e){if(e.includes("/")){const[t,r]=this.parseCIDR(e),i=new Uint8Array(t.length);let n=r;for(let e=0;e=8?(i[e]=255,n-=8):n>0&&(i[e]=255<<8-n,n=0);const s=new Uint8Array(2*t.length);return s.set(t,0),s.set(i,t.length),s.buffer}const t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}}let Er=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};mr([ar({type:Ct.TeletexString})],Er.prototype,"teletexString",void 0),mr([ar({type:Ct.PrintableString})],Er.prototype,"printableString",void 0),mr([ar({type:Ct.UniversalString})],Er.prototype,"universalString",void 0),mr([ar({type:Ct.Utf8String})],Er.prototype,"utf8String",void 0),mr([ar({type:Ct.BmpString})],Er.prototype,"bmpString",void 0),Er=mr([or({type:kt.Choice})],Er);let Or=class extends Er{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?h.ToHex(this.anyValue):super.toString())}};mr([ar({type:Ct.IA5String})],Or.prototype,"ia5String",void 0),mr([ar({type:Ct.Any})],Or.prototype,"anyValue",void 0),Or=mr([or({type:kt.Choice})],Or);class Nr{constructor(e={}){this.type="",this.value=new Or,Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Nr.prototype,"type",void 0),mr([ar({type:Or})],Nr.prototype,"value",void 0);let Ir=fr=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,fr.prototype)}};Ir=fr=mr([or({type:kt.Set,itemType:Nr})],Ir);let Tr=yr=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,yr.prototype)}};Tr=yr=mr([or({type:kt.Sequence,itemType:Ir})],Tr);let jr=dr=class extends Tr{constructor(e){super(e),Object.setPrototypeOf(this,dr.prototype)}};jr=dr=mr([or({type:kt.Sequence})],jr);const Ur={fromASN:e=>Cr.toString(Dt.fromASN(e)),toASN:e=>Dt.toASN(Cr.fromString(e))};class Pr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Pr.prototype,"typeId",void 0),mr([ar({type:Ct.Any,context:0})],Pr.prototype,"value",void 0);class Rr{constructor(e={}){this.partyName=new Er,Object.assign(this,e)}}mr([ar({type:Er,optional:!0,context:0,implicit:!0})],Rr.prototype,"nameAssigner",void 0),mr([ar({type:Er,context:1,implicit:!0})],Rr.prototype,"partyName",void 0);let Vr=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Pr,context:0,implicit:!0})],Vr.prototype,"otherName",void 0),mr([ar({type:Ct.IA5String,context:1,implicit:!0})],Vr.prototype,"rfc822Name",void 0),mr([ar({type:Ct.IA5String,context:2,implicit:!0})],Vr.prototype,"dNSName",void 0),mr([ar({type:Ct.Any,context:3,implicit:!0})],Vr.prototype,"x400Address",void 0),mr([ar({type:jr,context:4,implicit:!1})],Vr.prototype,"directoryName",void 0),mr([ar({type:Rr,context:5})],Vr.prototype,"ediPartyName",void 0),mr([ar({type:Ct.IA5String,context:6,implicit:!0})],Vr.prototype,"uniformResourceIdentifier",void 0),mr([ar({type:Ct.OctetString,context:7,implicit:!0,converter:Ur})],Vr.prototype,"iPAddress",void 0),mr([ar({type:Ct.ObjectIdentifier,context:8,implicit:!0})],Vr.prototype,"registeredID",void 0),Vr=mr([or({type:kt.Choice})],Vr);const Dr="1.3.6.1.5.5.7",Lr=`${Dr}.3`,Hr=`${Dr}.48`,Mr=`${Hr}.1`,$r=`${Hr}.2`,Kr=`${Hr}.3`,Fr=`${Hr}.5`,_r="2.5.29";var Wr;const zr=`${`${Dr}.1`}.1`;class qr{constructor(e={}){this.accessMethod="",this.accessLocation=new Vr,Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],qr.prototype,"accessMethod",void 0),mr([ar({type:Vr})],qr.prototype,"accessLocation",void 0);let Gr=Wr=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Wr.prototype)}};Gr=Wr=mr([or({type:kt.Sequence,itemType:qr})],Gr);const Jr=`${_r}.35`;class Xr extends Nt{}class Zr{constructor(e={}){e&&Object.assign(this,e)}}mr([ar({type:Xr,context:0,optional:!0,implicit:!0})],Zr.prototype,"keyIdentifier",void 0),mr([ar({type:Vr,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Zr.prototype,"authorityCertIssuer",void 0),mr([ar({type:Ct.Integer,context:2,optional:!0,implicit:!0,converter:Ut})],Zr.prototype,"authorityCertSerialNumber",void 0);const Yr=`${_r}.19`;class Qr{constructor(e={}){this.cA=!1,Object.assign(this,e)}}var ei;mr([ar({type:Ct.Boolean,defaultValue:!1})],Qr.prototype,"cA",void 0),mr([ar({type:Ct.Integer,optional:!0})],Qr.prototype,"pathLenConstraint",void 0);let ti=ei=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,ei.prototype)}};var ri;ti=ei=mr([or({type:kt.Sequence,itemType:Vr})],ti);const ii=`${_r}.29`;let ni=ri=class extends ti{constructor(e){super(e),Object.setPrototypeOf(this,ri.prototype)}};var si;ni=ri=mr([or({type:kt.Sequence})],ni);const oi=`${_r}.32`;let ai=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};mr([ar({type:Ct.IA5String})],ai.prototype,"ia5String",void 0),mr([ar({type:Ct.VisibleString})],ai.prototype,"visibleString",void 0),mr([ar({type:Ct.BmpString})],ai.prototype,"bmpString",void 0),mr([ar({type:Ct.Utf8String})],ai.prototype,"utf8String",void 0),ai=mr([or({type:kt.Choice})],ai);class ci{constructor(e={}){this.organization=new ai,this.noticeNumbers=[],Object.assign(this,e)}}mr([ar({type:ai})],ci.prototype,"organization",void 0),mr([ar({type:Ct.Integer,repeated:"sequence"})],ci.prototype,"noticeNumbers",void 0);class li{constructor(e={}){Object.assign(this,e)}}mr([ar({type:ci,optional:!0})],li.prototype,"noticeRef",void 0),mr([ar({type:ai,optional:!0})],li.prototype,"explicitText",void 0);let ui=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Ct.IA5String})],ui.prototype,"cPSuri",void 0),mr([ar({type:li})],ui.prototype,"userNotice",void 0),ui=mr([or({type:kt.Choice})],ui);class hi{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],hi.prototype,"policyQualifierId",void 0),mr([ar({type:Ct.Any})],hi.prototype,"qualifier",void 0);class pi{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],pi.prototype,"policyIdentifier",void 0),mr([ar({type:hi,repeated:"sequence",optional:!0})],pi.prototype,"policyQualifiers",void 0);let fi=si=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,si.prototype)}};fi=si=mr([or({type:kt.Sequence,itemType:pi})],fi);let yi=class{constructor(e=0){this.value=e}};mr([ar({type:Ct.Integer})],yi.prototype,"value",void 0),yi=mr([or({type:kt.Choice})],yi);let di=class extends yi{};var gi;di=mr([or({type:kt.Choice})],di);const vi=`${_r}.31`;var mi;!function(e){e[e.unused=1]="unused",e[e.keyCompromise=2]="keyCompromise",e[e.cACompromise=4]="cACompromise",e[e.affiliationChanged=8]="affiliationChanged",e[e.superseded=16]="superseded",e[e.cessationOfOperation=32]="cessationOfOperation",e[e.certificateHold=64]="certificateHold",e[e.privilegeWithdrawn=128]="privilegeWithdrawn",e[e.aACompromise=256]="aACompromise"}(mi||(mi={}));class wi extends Ot{toJSON(){const e=[],t=this.toNumber();return t&mi.aACompromise&&e.push("aACompromise"),t&mi.affiliationChanged&&e.push("affiliationChanged"),t&mi.cACompromise&&e.push("cACompromise"),t&mi.certificateHold&&e.push("certificateHold"),t&mi.cessationOfOperation&&e.push("cessationOfOperation"),t&mi.keyCompromise&&e.push("keyCompromise"),t&mi.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&mi.superseded&&e.push("superseded"),t&mi.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let bi=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Vr,context:0,repeated:"sequence",implicit:!0})],bi.prototype,"fullName",void 0),mr([ar({type:Ir,context:1,implicit:!0})],bi.prototype,"nameRelativeToCRLIssuer",void 0),bi=mr([or({type:kt.Choice})],bi);class Ai{constructor(e={}){Object.assign(this,e)}}mr([ar({type:bi,context:0,optional:!0})],Ai.prototype,"distributionPoint",void 0),mr([ar({type:wi,context:1,optional:!0,implicit:!0})],Ai.prototype,"reasons",void 0),mr([ar({type:Vr,context:2,optional:!0,repeated:"sequence",implicit:!0})],Ai.prototype,"cRLIssuer",void 0);let Si=gi=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,gi.prototype)}};var xi;Si=gi=mr([or({type:kt.Sequence,itemType:Ai})],Si);let Bi=xi=class extends Si{constructor(e){super(e),Object.setPrototypeOf(this,xi.prototype)}};Bi=xi=mr([or({type:kt.Sequence,itemType:Ai})],Bi);class ki{constructor(e={}){this.onlyContainsUserCerts=ki.ONLY,this.onlyContainsCACerts=ki.ONLY,this.indirectCRL=ki.ONLY,this.onlyContainsAttributeCerts=ki.ONLY,Object.assign(this,e)}}ki.ONLY=!1,mr([ar({type:bi,context:0,optional:!0})],ki.prototype,"distributionPoint",void 0),mr([ar({type:Ct.Boolean,context:1,defaultValue:ki.ONLY,implicit:!0})],ki.prototype,"onlyContainsUserCerts",void 0),mr([ar({type:Ct.Boolean,context:2,defaultValue:ki.ONLY,implicit:!0})],ki.prototype,"onlyContainsCACerts",void 0),mr([ar({type:wi,context:3,optional:!0,implicit:!0})],ki.prototype,"onlySomeReasons",void 0),mr([ar({type:Ct.Boolean,context:4,defaultValue:ki.ONLY,implicit:!0})],ki.prototype,"indirectCRL",void 0),mr([ar({type:Ct.Boolean,context:5,defaultValue:ki.ONLY,implicit:!0})],ki.prototype,"onlyContainsAttributeCerts",void 0);const Ci=`${_r}.21`;var Ei;!function(e){e[e.unspecified=0]="unspecified",e[e.keyCompromise=1]="keyCompromise",e[e.cACompromise=2]="cACompromise",e[e.affiliationChanged=3]="affiliationChanged",e[e.superseded=4]="superseded",e[e.cessationOfOperation=5]="cessationOfOperation",e[e.certificateHold=6]="certificateHold",e[e.removeFromCRL=8]="removeFromCRL",e[e.privilegeWithdrawn=9]="privilegeWithdrawn",e[e.aACompromise=10]="aACompromise"}(Ei||(Ei={}));let Oi=class{constructor(e=Ei.unspecified){this.reason=Ei.unspecified,this.reason=e}toJSON(){return Ei[this.reason]}toString(){return this.toJSON()}};var Ni;mr([ar({type:Ct.Enumerated})],Oi.prototype,"reason",void 0),Oi=mr([or({type:kt.Choice})],Oi);const Ii=`${_r}.37`;let Ti=Ni=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Ni.prototype)}};Ti=Ni=mr([or({type:kt.Sequence,itemType:Ct.ObjectIdentifier})],Ti);const ji=`${Lr}.1`,Ui=`${Lr}.2`,Pi=`${Lr}.3`,Ri=`${Lr}.4`,Vi=`${Lr}.8`,Di=`${Lr}.9`;let Li=class{constructor(e=new ArrayBuffer(0)){this.value=e}};mr([ar({type:Ct.Integer,converter:Ut})],Li.prototype,"value",void 0),Li=mr([or({type:kt.Choice})],Li);const Hi=`${_r}.24`;let Mi=class{constructor(e){this.value=new Date,e&&(this.value=e)}};var $i;mr([ar({type:Ct.GeneralizedTime})],Mi.prototype,"value",void 0),Mi=mr([or({type:kt.Choice})],Mi);const Ki=`${_r}.18`;let Fi=$i=class extends ti{constructor(e){super(e),Object.setPrototypeOf(this,$i.prototype)}};Fi=$i=mr([or({type:kt.Sequence})],Fi);const _i=`${_r}.15`;var Wi,zi;!function(e){e[e.digitalSignature=1]="digitalSignature",e[e.nonRepudiation=2]="nonRepudiation",e[e.keyEncipherment=4]="keyEncipherment",e[e.dataEncipherment=8]="dataEncipherment",e[e.keyAgreement=16]="keyAgreement",e[e.keyCertSign=32]="keyCertSign",e[e.cRLSign=64]="cRLSign",e[e.encipherOnly=128]="encipherOnly",e[e.decipherOnly=256]="decipherOnly"}(Wi||(Wi={}));class qi extends Ot{toJSON(){const e=this.toNumber(),t=[];return e&Wi.cRLSign&&t.push("crlSign"),e&Wi.dataEncipherment&&t.push("dataEncipherment"),e&Wi.decipherOnly&&t.push("decipherOnly"),e&Wi.digitalSignature&&t.push("digitalSignature"),e&Wi.encipherOnly&&t.push("encipherOnly"),e&Wi.keyAgreement&&t.push("keyAgreement"),e&Wi.keyCertSign&&t.push("keyCertSign"),e&Wi.keyEncipherment&&t.push("keyEncipherment"),e&Wi.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}class Gi{constructor(e={}){this.base=new Vr,this.minimum=0,Object.assign(this,e)}}mr([ar({type:Vr})],Gi.prototype,"base",void 0),mr([ar({type:Ct.Integer,context:0,defaultValue:0,implicit:!0})],Gi.prototype,"minimum",void 0),mr([ar({type:Ct.Integer,context:1,optional:!0,implicit:!0})],Gi.prototype,"maximum",void 0);let Ji=zi=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,zi.prototype)}};Ji=zi=mr([or({type:kt.Sequence,itemType:Gi})],Ji);class Xi{constructor(e={}){Object.assign(this,e)}}mr([ar({type:Ji,context:0,optional:!0,implicit:!0})],Xi.prototype,"permittedSubtrees",void 0),mr([ar({type:Ji,context:1,optional:!0,implicit:!0})],Xi.prototype,"excludedSubtrees",void 0);class Zi{constructor(e={}){Object.assign(this,e)}}var Yi;mr([ar({type:Ct.Integer,context:0,implicit:!0,optional:!0,converter:Ut})],Zi.prototype,"requireExplicitPolicy",void 0),mr([ar({type:Ct.Integer,context:1,implicit:!0,optional:!0,converter:Ut})],Zi.prototype,"inhibitPolicyMapping",void 0);class Qi{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Qi.prototype,"issuerDomainPolicy",void 0),mr([ar({type:Ct.ObjectIdentifier})],Qi.prototype,"subjectDomainPolicy",void 0);let en=Yi=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Yi.prototype)}};var tn;en=Yi=mr([or({type:kt.Sequence,itemType:Qi})],en);const rn=`${_r}.17`;let nn=tn=class extends ti{constructor(e){super(e),Object.setPrototypeOf(this,tn.prototype)}};nn=tn=mr([or({type:kt.Sequence})],nn);let sn=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};var on;mr([ar({type:Ct.ObjectIdentifier})],sn.prototype,"type",void 0),mr([ar({type:Ct.Any,repeated:"set"})],sn.prototype,"values",void 0);let an=on=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,on.prototype)}};an=on=mr([or({type:kt.Sequence,itemType:sn})],an);const cn=`${_r}.14`;class ln extends Xr{}class un{constructor(e={}){Object.assign(this,e)}}var hn,pn;mr([ar({type:Ct.GeneralizedTime,context:0,implicit:!0,optional:!0})],un.prototype,"notBefore",void 0),mr([ar({type:Ct.GeneralizedTime,context:1,implicit:!0,optional:!0})],un.prototype,"notAfter",void 0),function(e){e[e.keyUpdateAllowed=1]="keyUpdateAllowed",e[e.newExtensions=2]="newExtensions",e[e.pKIXCertificate=4]="pKIXCertificate"}(hn||(hn={}));class fn extends Ot{toJSON(){const e=[],t=this.toNumber();return t&hn.pKIXCertificate&&e.push("pKIXCertificate"),t&hn.newExtensions&&e.push("newExtensions"),t&hn.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class yn{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new fn,Object.assign(this,e)}}mr([ar({type:Ct.GeneralString})],yn.prototype,"entrustVers",void 0),mr([ar({type:fn})],yn.prototype,"entrustInfoFlags",void 0);let dn=pn=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,pn.prototype)}};dn=pn=mr([or({type:kt.Sequence,itemType:qr})],dn);class gn{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof gn&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&p(e.parameters,this.parameters)||e.parameters===this.parameters)}}mr([ar({type:Ct.ObjectIdentifier})],gn.prototype,"algorithm",void 0),mr([ar({type:Ct.Any,optional:!0})],gn.prototype,"parameters",void 0);class vn{constructor(e={}){this.algorithm=new gn,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:gn})],vn.prototype,"algorithm",void 0),mr([ar({type:Ct.BitString})],vn.prototype,"subjectPublicKey",void 0);let mn=class{constructor(e){if(e)if("string"==typeof e||"number"==typeof e||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};mr([ar({type:Ct.UTCTime})],mn.prototype,"utcTime",void 0),mr([ar({type:Ct.GeneralizedTime})],mn.prototype,"generalTime",void 0),mn=mr([or({type:kt.Choice})],mn);class wn{constructor(e){this.notBefore=new mn(new Date),this.notAfter=new mn(new Date),e&&(this.notBefore=new mn(e.notBefore),this.notAfter=new mn(e.notAfter))}}var bn;mr([ar({type:mn})],wn.prototype,"notBefore",void 0),mr([ar({type:mn})],wn.prototype,"notAfter",void 0);let An=class e{constructor(t={}){this.extnID="",this.critical=e.CRITICAL,this.extnValue=new Nt,Object.assign(this,t)}};An.CRITICAL=!1,mr([ar({type:Ct.ObjectIdentifier})],An.prototype,"extnID",void 0),mr([ar({type:Ct.Boolean,defaultValue:An.CRITICAL})],An.prototype,"critical",void 0),mr([ar({type:Nt})],An.prototype,"extnValue",void 0);let Sn=bn=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,bn.prototype)}};var xn;Sn=bn=mr([or({type:kt.Sequence,itemType:An})],Sn),function(e){e[e.v1=0]="v1",e[e.v2=1]="v2",e[e.v3=2]="v3"}(xn||(xn={}));class Bn{constructor(e={}){this.version=xn.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new gn,this.issuer=new jr,this.validity=new wn,this.subject=new jr,this.subjectPublicKeyInfo=new vn,Object.assign(this,e)}}mr([ar({type:Ct.Integer,context:0,defaultValue:xn.v1})],Bn.prototype,"version",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Bn.prototype,"serialNumber",void 0),mr([ar({type:gn})],Bn.prototype,"signature",void 0),mr([ar({type:jr})],Bn.prototype,"issuer",void 0),mr([ar({type:wn})],Bn.prototype,"validity",void 0),mr([ar({type:jr})],Bn.prototype,"subject",void 0),mr([ar({type:vn})],Bn.prototype,"subjectPublicKeyInfo",void 0),mr([ar({type:Ct.BitString,context:1,implicit:!0,optional:!0})],Bn.prototype,"issuerUniqueID",void 0),mr([ar({type:Ct.BitString,context:2,implicit:!0,optional:!0})],Bn.prototype,"subjectUniqueID",void 0),mr([ar({type:Sn,context:3,optional:!0})],Bn.prototype,"extensions",void 0);class kn{constructor(e={}){this.tbsCertificate=new Bn,this.signatureAlgorithm=new gn,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Bn,raw:!0})],kn.prototype,"tbsCertificate",void 0),mr([ar({type:gn})],kn.prototype,"signatureAlgorithm",void 0),mr([ar({type:Ct.BitString})],kn.prototype,"signatureValue",void 0);class Cn{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new mn,Object.assign(this,e)}}mr([ar({type:Ct.Integer,converter:Ut})],Cn.prototype,"userCertificate",void 0),mr([ar({type:mn})],Cn.prototype,"revocationDate",void 0),mr([ar({type:An,optional:!0,repeated:"sequence"})],Cn.prototype,"crlEntryExtensions",void 0);class En{constructor(e={}){this.signature=new gn,this.issuer=new jr,this.thisUpdate=new mn,Object.assign(this,e)}}mr([ar({type:Ct.Integer,optional:!0})],En.prototype,"version",void 0),mr([ar({type:gn})],En.prototype,"signature",void 0),mr([ar({type:jr})],En.prototype,"issuer",void 0),mr([ar({type:mn})],En.prototype,"thisUpdate",void 0),mr([ar({type:mn,optional:!0})],En.prototype,"nextUpdate",void 0),mr([ar({type:Cn,repeated:"sequence",optional:!0})],En.prototype,"revokedCertificates",void 0),mr([ar({type:An,optional:!0,context:0,repeated:"sequence"})],En.prototype,"crlExtensions",void 0);class On{constructor(e={}){this.tbsCertList=new En,this.signatureAlgorithm=new gn,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:En,raw:!0})],On.prototype,"tbsCertList",void 0),mr([ar({type:gn})],On.prototype,"signatureAlgorithm",void 0),mr([ar({type:Ct.BitString})],On.prototype,"signature",void 0);class Nn{constructor(e={}){this.issuer=new jr,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:jr})],Nn.prototype,"issuer",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Nn.prototype,"serialNumber",void 0);let In=class{constructor(e={}){Object.assign(this,e)}};var Tn;mr([ar({type:ln,context:0,implicit:!0})],In.prototype,"subjectKeyIdentifier",void 0),mr([ar({type:Nn})],In.prototype,"issuerAndSerialNumber",void 0),In=mr([or({type:kt.Choice})],In),function(e){e[e.v0=0]="v0",e[e.v1=1]="v1",e[e.v2=2]="v2",e[e.v3=3]="v3",e[e.v4=4]="v4",e[e.v5=5]="v5"}(Tn||(Tn={}));let jn=class extends gn{};jn=mr([or({type:kt.Sequence})],jn);let Un=class extends gn{};Un=mr([or({type:kt.Sequence})],Un);let Pn=class extends gn{};Pn=mr([or({type:kt.Sequence})],Pn);let Rn=class extends gn{};Rn=mr([or({type:kt.Sequence})],Rn);let Vn=class extends gn{};Vn=mr([or({type:kt.Sequence})],Vn);let Dn=class extends gn{};Dn=mr([or({type:kt.Sequence})],Dn);let Ln=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};var Hn;mr([ar({type:Ct.ObjectIdentifier})],Ln.prototype,"attrType",void 0),mr([ar({type:Ct.Any,repeated:"set"})],Ln.prototype,"attrValues",void 0);class Mn{constructor(e={}){this.version=Tn.v0,this.sid=new In,this.digestAlgorithm=new jn,this.signatureAlgorithm=new Un,this.signature=new Nt,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Mn.prototype,"version",void 0),mr([ar({type:In})],Mn.prototype,"sid",void 0),mr([ar({type:jn})],Mn.prototype,"digestAlgorithm",void 0),mr([ar({type:Ln,repeated:"set",context:0,implicit:!0,optional:!0,raw:!0})],Mn.prototype,"signedAttrs",void 0),mr([ar({type:Un})],Mn.prototype,"signatureAlgorithm",void 0),mr([ar({type:Nt})],Mn.prototype,"signature",void 0),mr([ar({type:Ln,repeated:"set",context:1,implicit:!0,optional:!0})],Mn.prototype,"unsignedAttrs",void 0);let $n=Hn=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Hn.prototype)}};$n=Hn=mr([or({type:kt.Set,itemType:Mn})],$n);let Kn=class extends Mn{};Kn=mr([or({type:kt.Sequence})],Kn);let Fn=class extends mn{};Fn=mr([or({type:kt.Choice})],Fn);class _n{constructor(e={}){this.acIssuer=new Vr,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}var Wn;mr([ar({type:Vr})],_n.prototype,"acIssuer",void 0),mr([ar({type:Ct.Integer})],_n.prototype,"acSerial",void 0),mr([ar({type:sn,repeated:"sequence"})],_n.prototype,"attrs",void 0);let zn=Wn=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Wn.prototype)}};zn=Wn=mr([or({type:kt.Sequence,itemType:Ct.ObjectIdentifier})],zn);class qn{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}mr([ar({type:Ct.Integer,optional:!0})],qn.prototype,"pathLenConstraint",void 0),mr([ar({type:zn,implicit:!0,context:0,optional:!0})],qn.prototype,"permittedAttrs",void 0),mr([ar({type:zn,implicit:!0,context:1,optional:!0})],qn.prototype,"excludedAttrs",void 0),mr([ar({type:Ct.Boolean,defaultValue:!0})],qn.prototype,"permitUnSpecified",void 0);class Gn{constructor(e={}){this.issuer=new ti,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}var Jn;mr([ar({type:ti})],Gn.prototype,"issuer",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Gn.prototype,"serial",void 0),mr([ar({type:Ct.BitString,optional:!0})],Gn.prototype,"issuerUID",void 0),function(e){e[e.publicKey=0]="publicKey",e[e.publicKeyCert=1]="publicKeyCert",e[e.otherObjectTypes=2]="otherObjectTypes"}(Jn||(Jn={}));class Xn{constructor(e={}){this.digestedObjectType=Jn.publicKey,this.digestAlgorithm=new gn,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.Enumerated})],Xn.prototype,"digestedObjectType",void 0),mr([ar({type:Ct.ObjectIdentifier,optional:!0})],Xn.prototype,"otherObjectTypeID",void 0),mr([ar({type:gn})],Xn.prototype,"digestAlgorithm",void 0),mr([ar({type:Ct.BitString})],Xn.prototype,"objectDigest",void 0);class Zn{constructor(e={}){Object.assign(this,e)}}mr([ar({type:ti,optional:!0})],Zn.prototype,"issuerName",void 0),mr([ar({type:Gn,context:0,implicit:!0,optional:!0})],Zn.prototype,"baseCertificateID",void 0),mr([ar({type:Xn,context:1,implicit:!0,optional:!0})],Zn.prototype,"objectDigestInfo",void 0);let Yn=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Vr,repeated:"sequence"})],Yn.prototype,"v1Form",void 0),mr([ar({type:Zn,context:0,implicit:!0})],Yn.prototype,"v2Form",void 0),Yn=mr([or({type:kt.Choice})],Yn);class Qn{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}mr([ar({type:Ct.GeneralizedTime})],Qn.prototype,"notBeforeTime",void 0),mr([ar({type:Ct.GeneralizedTime})],Qn.prototype,"notAfterTime",void 0);class es{constructor(e={}){Object.assign(this,e)}}var ts,rs,is;mr([ar({type:Gn,implicit:!0,context:0,optional:!0})],es.prototype,"baseCertificateID",void 0),mr([ar({type:ti,implicit:!0,context:1,optional:!0})],es.prototype,"entityName",void 0),mr([ar({type:Xn,implicit:!0,context:2,optional:!0})],es.prototype,"objectDigestInfo",void 0),function(e){e[e.v2=1]="v2"}(ts||(ts={}));class ns{constructor(e={}){this.version=ts.v2,this.holder=new es,this.issuer=new Yn,this.signature=new gn,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Qn,this.attributes=[],Object.assign(this,e)}}mr([ar({type:Ct.Integer})],ns.prototype,"version",void 0),mr([ar({type:es})],ns.prototype,"holder",void 0),mr([ar({type:Yn})],ns.prototype,"issuer",void 0),mr([ar({type:gn})],ns.prototype,"signature",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ns.prototype,"serialNumber",void 0),mr([ar({type:Qn})],ns.prototype,"attrCertValidityPeriod",void 0),mr([ar({type:sn,repeated:"sequence"})],ns.prototype,"attributes",void 0),mr([ar({type:Ct.BitString,optional:!0})],ns.prototype,"issuerUniqueID",void 0),mr([ar({type:Sn,optional:!0})],ns.prototype,"extensions",void 0);class ss{constructor(e={}){this.acinfo=new ns,this.signatureAlgorithm=new gn,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:ns})],ss.prototype,"acinfo",void 0),mr([ar({type:gn})],ss.prototype,"signatureAlgorithm",void 0),mr([ar({type:Ct.BitString})],ss.prototype,"signatureValue",void 0),function(e){e[e.unmarked=1]="unmarked",e[e.unclassified=2]="unclassified",e[e.restricted=4]="restricted",e[e.confidential=8]="confidential",e[e.secret=16]="secret",e[e.topSecret=32]="topSecret"}(rs||(rs={}));class os extends Ot{}class as{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier,implicit:!0,context:0})],as.prototype,"type",void 0),mr([ar({type:Ct.Any,implicit:!0,context:1})],as.prototype,"value",void 0);class cs{constructor(e={}){this.policyId="",this.classList=new os(rs.unclassified),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],cs.prototype,"policyId",void 0),mr([ar({type:os,defaultValue:new os(rs.unclassified)})],cs.prototype,"classList",void 0),mr([ar({type:as,repeated:"set"})],cs.prototype,"securityCategories",void 0);class ls{constructor(e={}){Object.assign(this,e)}}mr([ar({type:Nt})],ls.prototype,"cotets",void 0),mr([ar({type:Ct.ObjectIdentifier})],ls.prototype,"oid",void 0),mr([ar({type:Ct.Utf8String})],ls.prototype,"string",void 0);class us{constructor(e={}){this.values=[],Object.assign(this,e)}}mr([ar({type:ti,implicit:!0,context:0,optional:!0})],us.prototype,"policyAuthority",void 0),mr([ar({type:ls,repeated:"sequence"})],us.prototype,"values",void 0);class hs{constructor(e={}){this.targetCertificate=new Gn,Object.assign(this,e)}}mr([ar({type:Gn})],hs.prototype,"targetCertificate",void 0),mr([ar({type:Vr,optional:!0})],hs.prototype,"targetName",void 0),mr([ar({type:Xn,optional:!0})],hs.prototype,"certDigestInfo",void 0);let ps=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Vr,context:0,implicit:!0})],ps.prototype,"targetName",void 0),mr([ar({type:Vr,context:1,implicit:!0})],ps.prototype,"targetGroup",void 0),mr([ar({type:hs,context:2,implicit:!0})],ps.prototype,"targetCert",void 0),ps=mr([or({type:kt.Choice})],ps);let fs=is=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,is.prototype)}};var ys;fs=is=mr([or({type:kt.Sequence,itemType:ps})],fs);let ds=ys=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,ys.prototype)}};ds=ys=mr([or({type:kt.Sequence,itemType:fs})],ds);class gs{constructor(e={}){Object.assign(this,e)}}mr([ar({type:ti,implicit:!0,context:0,optional:!0})],gs.prototype,"roleAuthority",void 0),mr([ar({type:Vr,implicit:!0,context:1})],gs.prototype,"roleName",void 0);class vs{constructor(e={}){this.service=new Vr,this.ident=new Vr,Object.assign(this,e)}}var ms;mr([ar({type:Vr})],vs.prototype,"service",void 0),mr([ar({type:Vr})],vs.prototype,"ident",void 0),mr([ar({type:Nt,optional:!0})],vs.prototype,"authInfo",void 0);class ws{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],ws.prototype,"otherCertFormat",void 0),mr([ar({type:Ct.Any})],ws.prototype,"otherCert",void 0);let bs=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:kn})],bs.prototype,"certificate",void 0),mr([ar({type:ss,context:2,implicit:!0})],bs.prototype,"v2AttrCert",void 0),mr([ar({type:ws,context:3,implicit:!0})],bs.prototype,"other",void 0),bs=mr([or({type:kt.Choice})],bs);let As=ms=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,ms.prototype)}};As=ms=mr([or({type:kt.Set,itemType:bs})],As);class Ss{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Ss.prototype,"contentType",void 0),mr([ar({type:Ct.Any,context:0})],Ss.prototype,"content",void 0);let xs=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Nt})],xs.prototype,"single",void 0),mr([ar({type:Ct.Any})],xs.prototype,"any",void 0),xs=mr([or({type:kt.Choice})],xs);class Bs{constructor(e={}){this.eContentType="",Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Bs.prototype,"eContentType",void 0),mr([ar({type:xs,context:0,optional:!0})],Bs.prototype,"eContent",void 0);let ks=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Nt,context:0,implicit:!0,optional:!0})],ks.prototype,"value",void 0),mr([ar({type:Nt,converter:Lt,context:0,implicit:!0,optional:!0,repeated:"sequence"})],ks.prototype,"constructedValue",void 0),ks=mr([or({type:kt.Choice})],ks);class Cs{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new Rn,Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Cs.prototype,"contentType",void 0),mr([ar({type:Rn})],Cs.prototype,"contentEncryptionAlgorithm",void 0),mr([ar({type:ks,optional:!0})],Cs.prototype,"encryptedContent",void 0);class Es{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}var Os;mr([ar({type:Ct.ObjectIdentifier})],Es.prototype,"keyAttrId",void 0),mr([ar({type:Ct.Any,optional:!0})],Es.prototype,"keyAttr",void 0);class Ns{constructor(e={}){this.subjectKeyIdentifier=new ln,Object.assign(this,e)}}mr([ar({type:ln})],Ns.prototype,"subjectKeyIdentifier",void 0),mr([ar({type:Ct.GeneralizedTime,optional:!0})],Ns.prototype,"date",void 0),mr([ar({type:Es,optional:!0})],Ns.prototype,"other",void 0);let Is=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Ns,context:0,implicit:!0,optional:!0})],Is.prototype,"rKeyId",void 0),mr([ar({type:Nn,optional:!0})],Is.prototype,"issuerAndSerialNumber",void 0),Is=mr([or({type:kt.Choice})],Is);class Ts{constructor(e={}){this.rid=new Is,this.encryptedKey=new Nt,Object.assign(this,e)}}mr([ar({type:Is})],Ts.prototype,"rid",void 0),mr([ar({type:Nt})],Ts.prototype,"encryptedKey",void 0);let js=Os=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Os.prototype)}};js=Os=mr([or({type:kt.Sequence,itemType:Ts})],js);class Us{constructor(e={}){this.algorithm=new gn,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:gn})],Us.prototype,"algorithm",void 0),mr([ar({type:Ct.BitString})],Us.prototype,"publicKey",void 0);let Ps=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:ln,context:0,implicit:!0,optional:!0})],Ps.prototype,"subjectKeyIdentifier",void 0),mr([ar({type:Us,context:1,implicit:!0,optional:!0})],Ps.prototype,"originatorKey",void 0),mr([ar({type:Nn,optional:!0})],Ps.prototype,"issuerAndSerialNumber",void 0),Ps=mr([or({type:kt.Choice})],Ps);class Rs{constructor(e={}){this.version=Tn.v3,this.originator=new Ps,this.keyEncryptionAlgorithm=new Pn,this.recipientEncryptedKeys=new js,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Rs.prototype,"version",void 0),mr([ar({type:Ps,context:0})],Rs.prototype,"originator",void 0),mr([ar({type:Nt,context:1,optional:!0})],Rs.prototype,"ukm",void 0),mr([ar({type:Pn})],Rs.prototype,"keyEncryptionAlgorithm",void 0),mr([ar({type:js})],Rs.prototype,"recipientEncryptedKeys",void 0);let Vs=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:ln,context:0,implicit:!0})],Vs.prototype,"subjectKeyIdentifier",void 0),mr([ar({type:Nn})],Vs.prototype,"issuerAndSerialNumber",void 0),Vs=mr([or({type:kt.Choice})],Vs);class Ds{constructor(e={}){this.version=Tn.v0,this.rid=new Vs,this.keyEncryptionAlgorithm=new Pn,this.encryptedKey=new Nt,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Ds.prototype,"version",void 0),mr([ar({type:Vs})],Ds.prototype,"rid",void 0),mr([ar({type:Pn})],Ds.prototype,"keyEncryptionAlgorithm",void 0),mr([ar({type:Nt})],Ds.prototype,"encryptedKey",void 0);class Ls{constructor(e={}){this.keyIdentifier=new Nt,Object.assign(this,e)}}mr([ar({type:Nt})],Ls.prototype,"keyIdentifier",void 0),mr([ar({type:Ct.GeneralizedTime,optional:!0})],Ls.prototype,"date",void 0),mr([ar({type:Es,optional:!0})],Ls.prototype,"other",void 0);class Hs{constructor(e={}){this.version=Tn.v4,this.kekid=new Ls,this.keyEncryptionAlgorithm=new Pn,this.encryptedKey=new Nt,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Hs.prototype,"version",void 0),mr([ar({type:Ls})],Hs.prototype,"kekid",void 0),mr([ar({type:Pn})],Hs.prototype,"keyEncryptionAlgorithm",void 0),mr([ar({type:Nt})],Hs.prototype,"encryptedKey",void 0);class Ms{constructor(e={}){this.version=Tn.v0,this.keyEncryptionAlgorithm=new Pn,this.encryptedKey=new Nt,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Ms.prototype,"version",void 0),mr([ar({type:Dn,context:0,optional:!0})],Ms.prototype,"keyDerivationAlgorithm",void 0),mr([ar({type:Pn})],Ms.prototype,"keyEncryptionAlgorithm",void 0),mr([ar({type:Nt})],Ms.prototype,"encryptedKey",void 0);class $s{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],$s.prototype,"oriType",void 0),mr([ar({type:Ct.Any})],$s.prototype,"oriValue",void 0);let Ks=class{constructor(e={}){Object.assign(this,e)}};var Fs;mr([ar({type:Ds,optional:!0})],Ks.prototype,"ktri",void 0),mr([ar({type:Rs,context:1,implicit:!0,optional:!0})],Ks.prototype,"kari",void 0),mr([ar({type:Hs,context:2,implicit:!0,optional:!0})],Ks.prototype,"kekri",void 0),mr([ar({type:Ms,context:3,implicit:!0,optional:!0})],Ks.prototype,"pwri",void 0),mr([ar({type:$s,context:4,implicit:!0,optional:!0})],Ks.prototype,"ori",void 0),Ks=mr([or({type:kt.Choice})],Ks);let _s=Fs=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Fs.prototype)}};var Ws;_s=Fs=mr([or({type:kt.Set,itemType:Ks})],_s);class zs{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],zs.prototype,"otherRevInfoFormat",void 0),mr([ar({type:Ct.Any})],zs.prototype,"otherRevInfo",void 0);let qs=class{constructor(e={}){this.other=new zs,Object.assign(this,e)}};mr([ar({type:zs,context:1,implicit:!0})],qs.prototype,"other",void 0),qs=mr([or({type:kt.Choice})],qs);let Gs=Ws=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Ws.prototype)}};Gs=Ws=mr([or({type:kt.Set,itemType:qs})],Gs);class Js{constructor(e={}){Object.assign(this,e)}}var Xs;mr([ar({type:As,context:0,implicit:!0,optional:!0})],Js.prototype,"certs",void 0),mr([ar({type:Gs,context:1,implicit:!0,optional:!0})],Js.prototype,"crls",void 0);let Zs=Xs=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Xs.prototype)}};Zs=Xs=mr([or({type:kt.Set,itemType:Ln})],Zs);class Ys{constructor(e={}){this.version=Tn.v0,this.recipientInfos=new _s,this.encryptedContentInfo=new Cs,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Ys.prototype,"version",void 0),mr([ar({type:Js,context:0,implicit:!0,optional:!0})],Ys.prototype,"originatorInfo",void 0),mr([ar({type:_s})],Ys.prototype,"recipientInfos",void 0),mr([ar({type:Cs})],Ys.prototype,"encryptedContentInfo",void 0),mr([ar({type:Zs,context:1,implicit:!0,optional:!0})],Ys.prototype,"unprotectedAttrs",void 0);const Qs="1.2.840.113549.1.7.2";var eo;let to=eo=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,eo.prototype)}};to=eo=mr([or({type:kt.Set,itemType:jn})],to);class ro{constructor(e={}){this.version=Tn.v0,this.digestAlgorithms=new to,this.encapContentInfo=new Bs,this.signerInfos=new $n,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],ro.prototype,"version",void 0),mr([ar({type:to})],ro.prototype,"digestAlgorithms",void 0),mr([ar({type:Bs})],ro.prototype,"encapContentInfo",void 0),mr([ar({type:As,context:0,implicit:!0,optional:!0})],ro.prototype,"certificates",void 0),mr([ar({type:Gs,context:1,implicit:!0,optional:!0})],ro.prototype,"crls",void 0),mr([ar({type:$n})],ro.prototype,"signerInfos",void 0);const io="1.2.840.10045.2.1",no="1.2.840.10045.4.1",so="1.2.840.10045.4.3.1",oo="1.2.840.10045.4.3.2",ao="1.2.840.10045.4.3.3",co="1.2.840.10045.4.3.4",lo="1.2.840.10045.3.1.7",uo="1.3.132.0.34",ho="1.3.132.0.35";function po(e){return new gn({algorithm:e})}const fo=po(no);po(so);const yo=po(oo),go=po(ao),vo=po(co);let mo=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Ct.ObjectIdentifier})],mo.prototype,"fieldType",void 0),mr([ar({type:Ct.Any})],mo.prototype,"parameters",void 0),mo=mr([or({type:kt.Sequence})],mo);let wo=class{constructor(e={}){Object.assign(this,e)}};var bo;mr([ar({type:Ct.OctetString})],wo.prototype,"a",void 0),mr([ar({type:Ct.OctetString})],wo.prototype,"b",void 0),mr([ar({type:Ct.BitString,optional:!0})],wo.prototype,"seed",void 0),wo=mr([or({type:kt.Sequence})],wo),function(e){e[e.ecpVer1=1]="ecpVer1"}(bo||(bo={}));let Ao=class{constructor(e={}){this.version=bo.ecpVer1,Object.assign(this,e)}};mr([ar({type:Ct.Integer})],Ao.prototype,"version",void 0),mr([ar({type:mo})],Ao.prototype,"fieldID",void 0),mr([ar({type:wo})],Ao.prototype,"curve",void 0),mr([ar({type:class extends Nt{}})],Ao.prototype,"base",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Ao.prototype,"order",void 0),mr([ar({type:Ct.Integer,optional:!0})],Ao.prototype,"cofactor",void 0),Ao=mr([or({type:kt.Sequence})],Ao);let So=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Ct.ObjectIdentifier})],So.prototype,"namedCurve",void 0),mr([ar({type:Ct.Null})],So.prototype,"implicitCurve",void 0),mr([ar({type:Ao})],So.prototype,"specifiedCurve",void 0),So=mr([or({type:kt.Choice})],So);class xo{constructor(e={}){this.version=1,this.privateKey=new Nt,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],xo.prototype,"version",void 0),mr([ar({type:Nt})],xo.prototype,"privateKey",void 0),mr([ar({type:So,context:0,optional:!0})],xo.prototype,"parameters",void 0),mr([ar({type:Ct.BitString,context:1,optional:!0})],xo.prototype,"publicKey",void 0);class Bo{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.Integer,converter:Ut})],Bo.prototype,"r",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Bo.prototype,"s",void 0);const ko="1.2.840.113549.1.1",Co=`${ko}.1`,Eo=`${ko}.7`,Oo=`${ko}.9`,No=`${ko}.10`,Io=`${ko}.2`,To=`${ko}.4`,jo=`${ko}.5`,Uo=`${ko}.14`,Po=`${ko}.11`,Ro=`${ko}.12`,Vo=`${ko}.13`,Do=`${ko}.15`,Lo=`${ko}.16`,Ho="1.3.14.3.2.26",Mo="2.16.840.1.101.3.4.2.4",$o="2.16.840.1.101.3.4.2.1",Ko="2.16.840.1.101.3.4.2.2",Fo="2.16.840.1.101.3.4.2.3",_o=`${ko}.8`;function Wo(e){return new gn({algorithm:e,parameters:null})}Wo("1.2.840.113549.2.2"),Wo("1.2.840.113549.2.5");const zo=Wo(Ho);Wo(Mo),Wo($o),Wo(Ko),Wo(Fo),Wo("2.16.840.1.101.3.4.2.5"),Wo("2.16.840.1.101.3.4.2.6");const qo=new gn({algorithm:_o,parameters:pr.serialize(zo)}),Go=new gn({algorithm:Oo,parameters:pr.serialize(Dt.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Wo(Co),Wo(Io),Wo(To),Wo(jo),Wo(Do),Wo(Lo),Wo(Ro),Wo(Vo),Wo(Do),Wo(Lo);class Jo{constructor(e={}){this.hashAlgorithm=new gn(zo),this.maskGenAlgorithm=new gn({algorithm:_o,parameters:pr.serialize(zo)}),this.pSourceAlgorithm=new gn(Go),Object.assign(this,e)}}mr([ar({type:gn,context:0,defaultValue:zo})],Jo.prototype,"hashAlgorithm",void 0),mr([ar({type:gn,context:1,defaultValue:qo})],Jo.prototype,"maskGenAlgorithm",void 0),mr([ar({type:gn,context:2,defaultValue:Go})],Jo.prototype,"pSourceAlgorithm",void 0),new gn({algorithm:Eo,parameters:pr.serialize(new Jo)});class Xo{constructor(e={}){this.hashAlgorithm=new gn(zo),this.maskGenAlgorithm=new gn({algorithm:_o,parameters:pr.serialize(zo)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}mr([ar({type:gn,context:0,defaultValue:zo})],Xo.prototype,"hashAlgorithm",void 0),mr([ar({type:gn,context:1,defaultValue:qo})],Xo.prototype,"maskGenAlgorithm",void 0),mr([ar({type:Ct.Integer,context:2,defaultValue:20})],Xo.prototype,"saltLength",void 0),mr([ar({type:Ct.Integer,context:3,defaultValue:1})],Xo.prototype,"trailerField",void 0),new gn({algorithm:No,parameters:pr.serialize(new Xo)});class Zo{constructor(e={}){this.digestAlgorithm=new gn,this.digest=new Nt,Object.assign(this,e)}}var Yo;mr([ar({type:gn})],Zo.prototype,"digestAlgorithm",void 0),mr([ar({type:Nt})],Zo.prototype,"digest",void 0);class Qo{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.Integer,converter:Ut})],Qo.prototype,"prime",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Qo.prototype,"exponent",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Qo.prototype,"coefficient",void 0);let ea=Yo=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Yo.prototype)}};ea=Yo=mr([or({type:kt.Sequence,itemType:Qo})],ea);class ta{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.Integer})],ta.prototype,"version",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"modulus",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"publicExponent",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"privateExponent",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"prime1",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"prime2",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"exponent1",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"exponent2",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"coefficient",void 0),mr([ar({type:ea,optional:!0})],ta.prototype,"otherPrimeInfos",void 0);class ra{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}var ia;mr([ar({type:Ct.Integer,converter:Ut})],ra.prototype,"modulus",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ra.prototype,"publicExponent",void 0),function(e){e[e.Transient=0]="Transient",e[e.Singleton=1]="Singleton",e[e.ResolutionScoped=2]="ResolutionScoped",e[e.ContainerScoped=3]="ContainerScoped"}(ia||(ia={}));var na=ia;function sa(e){return!!e.useClass}function oa(e){return!!e.useFactory}var aa=function(){function e(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return e.prototype.createProxy=function(e){var t,r=this,i=!1;return new Proxy({},this.createHandler(function(){return i||(t=e(r.wrap()),i=!0),t}))},e.prototype.createHandler=function(e){var t={};return this.reflectMethods.forEach(function(r){t[r]=function(){for(var t=[],i=0;i0},e.prototype.clear=function(){this._registryMap.clear()},e.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},e}(),fa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return vr(t,e),t}(pa),ya=function(){this.scopedResolutions=new Map};function da(e,t,r){var i,n,s=Sr(e.toString().match(/constructor\(([\w, ]+)\)/)||[],2)[1],o=function(e,t){return null===e?"at position #"+t:'"'+e.split(",")[t].trim()+'" at position #'+t}(void 0===s?null:s,t);return i="Cannot inject the dependency "+o+' of "'+e.name+'" constructor. Reason:',void 0===n&&(n=" "),xr([i],r.message.split("\n").map(function(e){return n+e})).join("\n")}var ga=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return vr(t,e),t}(pa),va=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return vr(t,e),t}(pa),ma=function(){this.preResolution=new ga,this.postResolution=new va},wa=new Map,ba=function(){function e(e){this.parent=e,this._registry=new fa,this.interceptors=new ma,this.disposed=!1,this.disposables=new Set}return e.prototype.register=function(e,t,r){var i;if(void 0===r&&(r={lifecycle:na.Transient}),this.ensureNotDisposed(),i=function(e){return sa(e)||ha(e)||ua(e)||oa(e)}(t)?t:{useClass:t},ua(i))for(var n=[e],s=i;null!=s;){var o=s.useToken;if(n.includes(o))throw new Error("Token registration cycle detected! "+xr(n,[o]).join(" -> "));n.push(o);var a=this._registry.get(o);s=a&&ua(a.provider)?a.provider:null}if((r.lifecycle===na.Singleton||r.lifecycle==na.ContainerScoped||r.lifecycle==na.ResolutionScoped)&&(ha(i)||oa(i)))throw new Error('Cannot use lifecycle "'+na[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:r}),this},e.prototype.registerType=function(e,t){return this.ensureNotDisposed(),ca(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},e.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},e.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),ca(e)){if(ca(t))return this.register(e,{useToken:t},{lifecycle:na.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:na.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return t&&!ca(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:na.Singleton})},e.prototype.resolve=function(e,t,r){void 0===t&&(t=new ya),void 0===r&&(r=!1),this.ensureNotDisposed();var i=this.getRegistration(e);if(!i&&ca(e)){if(r)return;throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"Single"),i){var n=this.resolveRegistration(i,t);return this.executePostResolutionInterceptor(e,n,"Single"),n}if(function(e){return"function"==typeof e||e instanceof aa}(e)){n=this.construct(e,t);return this.executePostResolutionInterceptor(e,n,"Single"),n}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},e.prototype.executePreResolutionInterceptor=function(e,t){var r,i;if(this.interceptors.preResolution.has(e)){var n=[];try{for(var s=Ar(this.interceptors.preResolution.getAll(e)),o=s.next();!o.done;o=s.next()){var a=o.value;"Once"!=a.options.frequency&&n.push(a),a.callback(e,t)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,n)}},e.prototype.executePostResolutionInterceptor=function(e,t,r){var i,n;if(this.interceptors.postResolution.has(e)){var s=[];try{for(var o=Ar(this.interceptors.postResolution.getAll(e)),a=o.next();!a.done;a=o.next()){var c=a.value;"Once"!=c.options.frequency&&s.push(c),c.callback(e,t,r)}}catch(e){i={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,s)}},e.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===na.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var r,i=e.options.lifecycle===na.Singleton,n=e.options.lifecycle===na.ContainerScoped,s=i||n;return r=ha(e.provider)?e.provider.useValue:ua(e.provider)?s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):sa(e.provider)?s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):oa(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t),e.options.lifecycle===na.ResolutionScoped&&t.scopedResolutions.set(e,r),r},e.prototype.resolveAll=function(e,t,r){var i=this;void 0===t&&(t=new ya),void 0===r&&(r=!1),this.ensureNotDisposed();var n=this.getAllRegistrations(e);if(!n&&ca(e)){if(r)return[];throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"All"),n){var s=n.map(function(e){return i.resolveRegistration(e,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var o=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,o,"All"),o},e.prototype.isRegistered=function(e,t){return void 0===t&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},e.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},e.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var r=Ar(this._registry.entries()),i=r.next();!i.done;i=r.next()){var n=Sr(i.value,2),s=n[0],o=n[1];this._registry.setAll(s,o.filter(function(e){return!ha(e.provider)}).map(function(e){return e.instance=void 0,e}))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.createChildContainer=function(){var t,r;this.ensureNotDisposed();var i=new e(this);try{for(var n=Ar(this._registry.entries()),s=n.next();!s.done;s=n.next()){var o=Sr(s.value,2),a=o[0],c=o[1];c.some(function(e){return e.options.lifecycle===na.ContainerScoped})&&i._registry.setAll(a,c.map(function(e){return e.options.lifecycle===na.ContainerScoped?{provider:e.provider,options:e.options}:e}))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return i},e.prototype.beforeResolution=function(e,t,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:r})},e.prototype.afterResolution=function(e,t,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:r})},e.prototype.dispose=function(){return wr(this,void 0,void 0,function(){var e;return br(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(t){var r=t.dispose();r&&e.push(r)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},e.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},e.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},e.prototype.construct=function(e,t){var r=this;if(e instanceof aa)return e.createProxy(function(e){return r.resolve(e,t)});var i,n=function(){var i=wa.get(e);if(!i||0===i.length){if(0===e.length)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var n=i.map(r.resolveParams(t,e));return new(e.bind.apply(e,xr([void 0],n)))}();return"function"!=typeof(i=n).dispose||i.dispose.length>0||this.disposables.add(n),n},e.prototype.resolveParams=function(e,t){var r=this;return function(i,n){var s,o,a,c;try{return"object"==typeof(c=i)&&"token"in c&&"multiple"in c?la(i)?i.multiple?(s=r.resolve(i.transform)).transform.apply(s,xr([r.resolveAll(i.token,new ya,i.isOptional)],i.transformArgs)):(o=r.resolve(i.transform)).transform.apply(o,xr([r.resolve(i.token,e,i.isOptional)],i.transformArgs)):i.multiple?r.resolveAll(i.token,new ya,i.isOptional):r.resolve(i.token,e,i.isOptional):la(i)?(a=r.resolve(i.transform,e)).transform.apply(a,xr([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(e){throw new Error(da(t,n,e))}}},e.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},e}(),Aa=new ba;function Sa(e){return function(e){wa.set(e,function(e){var t=Reflect.getMetadata("design:paramtypes",e)||[],r=Reflect.getOwnMetadata("injectionTokens",e)||{};return Object.keys(r).forEach(function(e){t[+e]=r[e]}),t}(e))}}if("undefined"==typeof Reflect||!Reflect.getMetadata)throw new Error("tsyringe requires a reflect polyfill. Please add 'import \"reflect-metadata\"' to the top of your entry point.");const xa="crypto.algorithm";class Ba{getAlgorithms(){return Aa.resolveAll(xa)}toAsnAlgorithm(e){for(const t of this.getAlgorithms()){const r=t.toAsnAlgorithm(e);if(r)return r}if(/^[0-9.]+$/.test(e.name)){const t=new gn({algorithm:e.name});if("parameters"in e){const r=e;t.parameters=r.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const t of this.getAlgorithms()){const r=t.toWebAlgorithm(e);if(r)return r}return{name:e.algorithm,parameters:e.parameters}}}const ka="crypto.algorithmProvider";var Ca;Aa.registerSingleton(ka,Ba);const Ea="1.3.36.3.3.2.8.1.1",Oa=`${Ea}.1`,Na=`${Ea}.2`,Ia=`${Ea}.3`,Ta=`${Ea}.4`,ja=`${Ea}.5`,Ua=`${Ea}.6`,Pa=`${Ea}.7`,Ra=`${Ea}.8`,Va=`${Ea}.9`,Da=`${Ea}.10`,La=`${Ea}.11`,Ha=`${Ea}.12`,Ma=`${Ea}.13`,$a=`${Ea}.14`,Ka="brainpoolP160r1",Fa="brainpoolP160t1",_a="brainpoolP192r1",Wa="brainpoolP192t1",za="brainpoolP224r1",qa="brainpoolP224t1",Ga="brainpoolP256r1",Ja="brainpoolP256t1",Xa="brainpoolP320r1",Za="brainpoolP320t1",Ya="brainpoolP384r1",Qa="brainpoolP384t1",ec="brainpoolP512r1",tc="brainpoolP512t1",rc="ECDSA";e.EcAlgorithm=Ca=class{toAsnAlgorithm(e){if(e.name.toLowerCase()===rc.toLowerCase())if("hash"in e){switch(("string"==typeof e.hash?e.hash:e.hash.name).toLowerCase()){case"sha-1":return fo;case"sha-256":return yo;case"sha-384":return go;case"sha-512":return vo}}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=lo;break;case"K-256":t=Ca.SECP256K1;break;case"P-384":t=uo;break;case"P-521":t=ho;break;case Ka:t=Oa;break;case Fa:t=Na;break;case _a:t=Ia;break;case Wa:t=Ta;break;case za:t=ja;break;case qa:t=Ua;break;case Ga:t=Pa;break;case Ja:t=Ra;break;case Xa:t=Va;break;case Za:t=Da;break;case Ya:t=La;break;case Qa:t=Ha;break;case ec:t=Ma;break;case tc:t=$a}if(t)return new gn({algorithm:io,parameters:pr.serialize(new So({namedCurve:t}))})}return null}toWebAlgorithm(e){switch(e.algorithm){case no:return{name:rc,hash:{name:"SHA-1"}};case oo:return{name:rc,hash:{name:"SHA-256"}};case ao:return{name:rc,hash:{name:"SHA-384"}};case co:return{name:rc,hash:{name:"SHA-512"}};case io:if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(pr.parse(e.parameters,So).namedCurve){case lo:return{name:rc,namedCurve:"P-256"};case Ca.SECP256K1:return{name:rc,namedCurve:"K-256"};case uo:return{name:rc,namedCurve:"P-384"};case ho:return{name:rc,namedCurve:"P-521"};case Oa:return{name:rc,namedCurve:Ka};case Na:return{name:rc,namedCurve:Fa};case Ia:return{name:rc,namedCurve:_a};case Ta:return{name:rc,namedCurve:Wa};case ja:return{name:rc,namedCurve:za};case Ua:return{name:rc,namedCurve:qa};case Pa:return{name:rc,namedCurve:Ga};case Ra:return{name:rc,namedCurve:Ja};case Va:return{name:rc,namedCurve:Xa};case Da:return{name:rc,namedCurve:Za};case La:return{name:rc,namedCurve:Ya};case Ha:return{name:rc,namedCurve:Qa};case Ma:return{name:rc,namedCurve:ec};case $a:return{name:rc,namedCurve:tc}}}return null}},e.EcAlgorithm.SECP256K1="1.3.132.0.10",e.EcAlgorithm=Ca=mr([Sa()],e.EcAlgorithm),Aa.registerSingleton(xa,e.EcAlgorithm);const ic=Symbol("name"),nc=Symbol("value");class sc{constructor(e,t={},r=""){this[ic]=e,this[nc]=r;for(const e in t)this[e]=t[e]}}sc.NAME=ic,sc.VALUE=nc;class oc{static toTextObject(t){const r=new sc("Algorithm Identifier",{},ac.toString(t.algorithm));if(t.parameters)switch(t.algorithm){case io:{const i=(new e.EcAlgorithm).toWebAlgorithm(t);i&&"namedCurve"in i?r["Named Curve"]=i.namedCurve:r.Parameters=t.parameters;break}default:r.Parameters=t.parameters}return r}}class ac{static toString(e){const t=this.items[e];return t||e}}ac.items={[Ho]:"sha1",[Mo]:"sha224",[$o]:"sha256",[Ko]:"sha384",[Fo]:"sha512",[Co]:"rsaEncryption",[jo]:"sha1WithRSAEncryption",[Uo]:"sha224WithRSAEncryption",[Po]:"sha256WithRSAEncryption",[Ro]:"sha384WithRSAEncryption",[Vo]:"sha512WithRSAEncryption",[io]:"ecPublicKey",[no]:"ecdsaWithSHA1",[so]:"ecdsaWithSHA224",[oo]:"ecdsaWithSHA256",[ao]:"ecdsaWithSHA384",[co]:"ecdsaWithSHA512",[ji]:"TLS WWW server authentication",[Ui]:"TLS WWW client authentication",[Pi]:"Code Signing",[Ri]:"E-mail Protection",[Vi]:"Time Stamping",[Di]:"OCSP Signing",[Qs]:"Signed Data"};class cc{static serialize(e){return this.serializeObj(e).join("\n")}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const r=[];let i=this.pad(t++),s="";const o=e[sc.VALUE];o&&(s=` ${o}`),r.push(`${i}${e[sc.NAME]}:${s}`),i=this.pad(t);for(const s in e){if("symbol"==typeof s)continue;const o=e[s],a=s?`${s}: `:"";if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)r.push(`${i}${a}${o}`);else if(o instanceof Date)r.push(`${i}${a}${o.toUTCString()}`);else if(Array.isArray(o))for(const e of o)e[sc.NAME]=s,r.push(...this.serializeObj(e,t));else if(o instanceof sc)o[sc.NAME]=s,r.push(...this.serializeObj(o,t));else if(n.isBufferSource(o))s?(r.push(`${i}${a}`),r.push(...this.serializeBufferSource(o,t+1))):r.push(...this.serializeBufferSource(o,t));else{if(!("toTextObject"in o))throw new TypeError("Cannot serialize data in text format. Unsupported type.");{const e=o.toTextObject();e[sc.NAME]=s,r.push(...this.serializeObj(e,t))}}}return r}static serializeBufferSource(e,t=0){const r=this.pad(t),i=n.toUint8Array(e),s=[];for(let e=0;e255)return!1}return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,t={}){this.extraNames=new gc,this.asn=new jr;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const r=t[e];this.extraNames.register(e,r)}"string"==typeof e?this.asn=this.fromString(e):e instanceof jr?this.asn=e:n.isBufferSource(e)?this.asn=pr.parse(e,jr):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||vc.findId(e),r=[];for(const e of this.asn)for(const i of e)i.type===t&&r.push(i.value.toString());return r}getName(e){return this.extraNames.get(e)||vc.get(e)}toString(){return this.asn.map(e=>e.map(e=>`${this.getName(e.type)||e.type}=${e.value.anyValue?`#${h.ToHex(e.value.anyValue)}`:e.value.toString().replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,mc)}`).join("+")).join(", ")}toJSON(){var e;const t=[];for(const r of this.asn){const i={};for(const t of r){const r=this.getName(t.type)||t.type;null!==(e=i[r])&&void 0!==e||(i[r]=[]),i[r].push(t.value.anyValue?`#${h.ToHex(t.value.anyValue)}`:t.value.toString())}t.push(i)}return t}fromString(e){const t=new jr,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+"\\](?=[,+]|$))|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,n=",";for(;i=r.exec(`${e},`);){let[,e,r]=i;const s=r[r.length-1];","!==s&&"+"!==s||(r=r.slice(0,r.length-1),i[3]=s);const o=i[3];e=this.getTypeOid(e);const a=this.createAttribute(e,r);"+"===n?t[t.length-1].push(a):t.push(new Ir([a])),n=o}return t}fromJSON(e){const t=new jr;for(const r of e){const e=new Ir;for(const t in r){const i=this.getTypeOid(t),n=r[t];for(const t of n){const r=this.createAttribute(i,t);e.push(r)}}t.push(e)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,t){const r=new Nr({type:e});if("object"==typeof t)for(const e in t)switch(e){case"ia5String":r.value.ia5String=t[e];break;case"utf8String":r.value.utf8String=t[e];break;case"universalString":r.value.universalString=t[e];break;case"bmpString":r.value.bmpString=t[e];break;case"printableString":r.value.printableString=t[e]}else if("#"===t[0])r.value.anyValue=h.FromHex(t.slice(1));else{const i=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?r.value.ia5String=i:wc.isPrintableString(i)?r.value.printableString=i:r.value.utf8String=i}return r}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/gi,"\n").replace(/\\0d/gi,"\r").replace(/\\0g/gi,"\t").replace(/\\(.)/g,"$1")}toArrayBuffer(){return pr.serialize(this.asn)}async getThumbprint(...e){var t;let r,i="SHA-1";return e.length>=1&&!(null===(t=e[0])||void 0===t?void 0:t.subtle)?(i=e[0]||i,r=e[1]||yc.get()):r=e[0]||yc.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const bc="Cannot initialize GeneralName from ASN.1 data.",Ac=`${bc} Unsupported string format in use.`,Sc=`${bc} Value doesn't match to GUID regular expression.`,xc=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Bc="1.3.6.1.4.1.311.25.1",kc="1.3.6.1.4.1.311.20.2.3",Cc="dns",Ec="dn",Oc="email",Nc="ip",Ic="url",Tc="guid",jc="upn",Uc="id";class Pc extends hc{constructor(...e){let t;if(2===e.length)switch(e[0]){case Ec:{const r=new wc(e[1]).toArrayBuffer(),i=pr.parse(r,jr);t=new Vr({directoryName:i});break}case Cc:t=new Vr({dNSName:e[1]});break;case Oc:t=new Vr({rfc822Name:e[1]});break;case Tc:{const r=new RegExp(xc,"i").exec(e[1]);if(!r)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=r.slice(1).map((e,t)=>t<3?h.ToHex(new Uint8Array(h.FromHex(e)).reverse()):e).join("");t=new Vr({otherName:new Pr({typeId:Bc,value:pr.serialize(new Nt(h.FromHex(i)))})});break}case Nc:t=new Vr({iPAddress:e[1]});break;case Uc:t=new Vr({registeredID:e[1]});break;case jc:t=new Vr({otherName:new Pr({typeId:kc,value:pr.serialize(Mt.toASN(e[1]))})});break;case Ic:t=new Vr({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else t=n.isBufferSource(e[0])?pr.parse(e[0],Vr):e[0];super(t)}onInit(e){if(null!=e.dNSName)this.type=Cc,this.value=e.dNSName;else if(null!=e.rfc822Name)this.type=Oc,this.value=e.rfc822Name;else if(null!=e.iPAddress)this.type=Nc,this.value=e.iPAddress;else if(null!=e.uniformResourceIdentifier)this.type=Ic,this.value=e.uniformResourceIdentifier;else if(null!=e.registeredID)this.type=Uc,this.value=e.registeredID;else if(null!=e.directoryName)this.type=Ec,this.value=new wc(e.directoryName).toString();else{if(null==e.otherName)throw new Error(Ac);if(e.otherName.typeId===Bc){this.type=Tc;const t=pr.parse(e.otherName.value,Nt),r=new RegExp(xc,"i").exec(h.ToHex(t));if(!r)throw new Error(Sc);this.value=r.slice(1).map((e,t)=>t<3?h.ToHex(new Uint8Array(h.FromHex(e)).reverse()):e).join("-")}else{if(e.otherName.typeId!==kc)throw new Error(Ac);this.type=jc,this.value=pr.parse(e.otherName.value,Er).toString()}}}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Ec:case Cc:case Tc:case Nc:case Uc:case jc:case Ic:e=this.type.toUpperCase();break;case Oc:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===Uc&&(t=ac.toString(t)),new sc(e,void 0,t)}}class Rc extends hc{constructor(e){let t;if(e instanceof ti)t=e;else if(Array.isArray(e)){const r=[];for(const t of e)if(t instanceof Vr)r.push(t);else{const e=pr.parse(new Pc(t.type,t.value).rawData,Vr);r.push(e)}t=new ti(r)}else{if(!n.isBufferSource(e))throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");t=pr.parse(e,ti)}super(t)}onInit(e){const t=[];for(const r of e){let e=null;try{e=new Pc(r)}catch(e){continue}t.push(e)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const r=t.toTextObject();let i=e[r[sc.NAME]];Array.isArray(i)||(i=[],e[r[sc.NAME]]=i),i.push(r)}return e}}Rc.NAME="GeneralNames";const Vc="-{5}",Dc="\\n",Lc="\\n",Hc=`${`${Vc}BEGIN (${`[^${Dc}]+`}(?=${Vc}))${Vc}`}${Lc}(?:((?:${`[^:${Dc}]+`}: ${`(?:[^${Dc}]+${Lc}(?: +[^${Dc}]+${Lc})*)`})+))?${Lc}?(${`(?:[a-zA-Z0-9=+/]+${Lc})+`})${`${Vc}END \\1${Vc}`}`;class Mc{static isPem(e){return"string"==typeof e&&new RegExp(Hc,"g").test(e.replace(/\r/g,""))}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Hc,"g"),r=[];let i=null;for(;i=t.exec(e);){const e=i[3].replace(new RegExp(`[${Dc}]+`,"g"),""),t={type:i[1],headers:[],rawData:h.FromBase64(e)},n=i[2];if(n){const e=n.split(new RegExp(Lc,"g"));let r=null;for(const i of e){const[e,n]=i.split(/:(.*)/);if(void 0===n){if(!r)throw new Error("Cannot parse PEM string. Incorrect header value");r.value+=e.trim()}else r&&t.headers.push(r),r={key:e,value:n.trim()}}r&&t.headers.push(r)}r.push(t)}return r}static decode(e){return this.decodeWithHeaders(e).map(e=>e.rawData)}static decodeFirst(e){const t=this.decode(e);if(!t.length)throw new RangeError("PEM string doesn't contain any objects");return t[0]}static encode(e,t){if(Array.isArray(e)){const r=new Array;return t?e.forEach(e=>{if(!n.isBufferSource(e))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:t,rawData:n.toArrayBuffer(e)}))}):e.forEach(e=>{if(!("type"in e))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(e))}),r.join("\n")}if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:n.toArrayBuffer(e)})}static encodeStruct(e){var t;const r=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${r}-----`),null===(t=e.headers)||void 0===t?void 0:t.length){for(const t of e.headers)i.push(`${t.key}: ${t.value}`);i.push("")}const n=h.ToBase64(e.rawData);let s,o=0;const a=Array();for(;o0&&48===t[0])return n.toArrayBuffer(e);const r=h.ToBinary(e);if(Mc.isPem(r))return Mc.decode(r)[0];if(h.isHex(r))return h.FromHex(r);if(h.isBase64(r))return h.FromBase64(r);if(h.isBase64Url(r))return h.FromBase64Url(r);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}}constructor(...e){$c.isAsnEncoded(e[0])?super($c.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){return"pem"===e?Mc.encode(this.rawData,this.tag):super.toString(e)}}class Kc extends $c{static async create(e,t=yc.get()){if(e instanceof Kc)return e;if(fc.isCryptoKey(e)){if("public"!==e.type)throw new TypeError("Public key is required");const r=await t.subtle.exportKey("spki",e);return new Kc(r)}if(e.publicKey)return e.publicKey;if(n.isBufferSource(e))return new Kc(e);throw new TypeError("Unsupported PublicKeyType")}constructor(e){$c.isAsnEncoded(e)?super(e,vn):super(e),this.tag=Mc.PublicKeyTag}async export(...e){let t,r=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,r=e[1]||r,t=e[2]||yc.get()):t=e[0]||yc.get();let n=this.rawData;const s=pr.parse(this.rawData,vn);return s.algorithm.algorithm===No&&(n=function(e,t){return e.algorithm=new gn({algorithm:Co,parameters:null}),t=pr.serialize(e),t}(s,n)),t.subtle.importKey("spki",n,i,!0,r)}onInit(e){const t=Aa.resolve(ka),r=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Co:{const t=pr.parse(e.subjectPublicKey,ra),i=n.toUint8Array(t.modulus);r.publicExponent=n.toUint8Array(t.publicExponent),r.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let r,i="SHA-1";return e.length>=1&&!(null===(t=e[0])||void 0===t?void 0:t.subtle)?(i=e[0]||i,r=e[1]||yc.get()):r=e[0]||yc.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let t,r="SHA-1";1===e.length?"string"==typeof e[0]?(r=e[0],t=yc.get()):t=e[0]:2===e.length?(r=e[0],t=e[1]):t=yc.get();const i=pr.parse(this.rawData,vn);return await t.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=pr.parse(this.rawData,vn);if(e.Algorithm=cc.serializeAlgorithm(t.algorithm),t.algorithm.algorithm===io)e["EC Point"]=t.subjectPublicKey;else e["Raw Data"]=t.subjectPublicKey;return e}}class Fc extends pc{static async create(e,t=!1,r=yc.get()){if("name"in e&&"serialNumber"in e)return new Fc(e,t);const i=await Kc.create(e,r),n=await i.getKeyIdentifier(r);return new Fc(h.ToHex(n),t)}constructor(...e){if(n.isBufferSource(e[0]))super(e[0]);else if("string"==typeof e[0]){const t=new Zr({keyIdentifier:new Xr(h.FromHex(e[0]))});super(Jr,e[1],pr.serialize(t))}else{const t=e[0],r=t.name instanceof Rc?pr.parse(t.name.rawData,ti):t.name,i=new Zr({authorityCertIssuer:r,authorityCertSerialNumber:h.FromHex(t.serialNumber)});super(Jr,e[1],pr.serialize(i))}}onInit(e){super.onInit(e);const t=pr.parse(e.extnValue,Zr);t.keyIdentifier&&(this.keyId=h.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?h.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=pr.parse(this.value,Zr);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Rc(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Fc.NAME="Authority Key Identifier";class _c extends pc{constructor(...e){if(n.isBufferSource(e[0])){super(e[0]);const t=pr.parse(this.value,Qr);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new Qr({cA:e[0],pathLenConstraint:e[1]});super(Yr,e[2],pr.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),void 0!==this.pathLength&&(e["Path Length"]=this.pathLength),e}}_c.NAME="Basic Constraints",e.ExtendedKeyUsage=void 0,function(e){e.serverAuth="1.3.6.1.5.5.7.3.1",e.clientAuth="1.3.6.1.5.5.7.3.2",e.codeSigning="1.3.6.1.5.5.7.3.3",e.emailProtection="1.3.6.1.5.5.7.3.4",e.timeStamping="1.3.6.1.5.5.7.3.8",e.ocspSigning="1.3.6.1.5.5.7.3.9"}(e.ExtendedKeyUsage||(e.ExtendedKeyUsage={}));class Wc extends pc{constructor(...e){if(n.isBufferSource(e[0])){super(e[0]);const t=pr.parse(this.value,Ti);this.usages=t.map(e=>e)}else{const t=new Ti(e[0]);super(Ii,e[1],pr.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(e=>ac.toString(e)).join(", "),e}}Wc.NAME="Extended Key Usages",e.KeyUsageFlags=void 0,function(e){e[e.digitalSignature=1]="digitalSignature",e[e.nonRepudiation=2]="nonRepudiation",e[e.keyEncipherment=4]="keyEncipherment",e[e.dataEncipherment=8]="dataEncipherment",e[e.keyAgreement=16]="keyAgreement",e[e.keyCertSign=32]="keyCertSign",e[e.cRLSign=64]="cRLSign",e[e.encipherOnly=128]="encipherOnly",e[e.decipherOnly=256]="decipherOnly"}(e.KeyUsageFlags||(e.KeyUsageFlags={}));class zc extends pc{constructor(...e){if(n.isBufferSource(e[0])){super(e[0]);const t=pr.parse(this.value,qi);this.usages=t.toNumber()}else{const t=new qi(e[0]);super(_i,e[1],pr.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=pr.parse(this.value,qi);return e[""]=t.toJSON().join(", "),e}}zc.NAME="Key Usages";class qc extends pc{static async create(e,t=!1,r=yc.get()){const i=await Kc.create(e,r),n=await i.getKeyIdentifier(r);return new qc(h.ToHex(n),t)}constructor(...e){if(n.isBufferSource(e[0])){super(e[0]);const t=pr.parse(this.value,ln);this.keyId=h.ToHex(t)}else{const t="string"==typeof e[0]?h.FromHex(e[0]):e[0],r=new ln(t);super(cn,e[1],pr.serialize(r)),this.keyId=h.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=pr.parse(this.value,ln);return e[""]=t,e}}qc.NAME="Subject Key Identifier";class Gc extends pc{constructor(...e){n.isBufferSource(e[0])?super(e[0]):super(rn,e[1],new Rc(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=pr.parse(e.extnValue,nn);this.names=new Rc(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const r in t)e[r]=t[r];return e}}Gc.NAME="Subject Alternative Name";class Jc{static register(e,t){this.items.set(e,t)}static create(e){const t=new pc(e),r=this.items.get(t.type);return r?new r(e):t}}Jc.items=new Map;class Xc extends pc{constructor(...e){var t;if(n.isBufferSource(e[0])){super(e[0]);const t=pr.parse(this.value,fi);this.policies=t.map(e=>e.policyIdentifier)}else{const r=e[0],i=null!==(t=e[1])&&void 0!==t&&t,n=new fi(r.map(e=>new pi({policyIdentifier:e})));super(oi,i,pr.serialize(n)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(e=>new sc("",{},ac.toString(e))),e}}Xc.NAME="Certificate Policies",Jc.register(oi,Xc);class Zc extends pc{constructor(...e){var t;if(n.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&"string"==typeof e[0][0]){const t=e[0].map(e=>new Ai({distributionPoint:new bi({fullName:[new Vr({uniformResourceIdentifier:e})]})})),r=new Si(t);super(vi,e[1],pr.serialize(r))}else{const t=new Si(e[0]);super(vi,e[1],pr.serialize(t))}null!==(t=this.distributionPoints)&&void 0!==t||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=pr.parse(e.extnValue,Si);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(e=>{var t;const r={};return e.distributionPoint&&(r[""]=null===(t=e.distributionPoint.fullName)||void 0===t?void 0:t.map(e=>new Pc(e).toString()).join(", ")),e.reasons&&(r.Reasons=e.reasons.toString()),e.cRLIssuer&&(r["CRL Issuer"]=e.cRLIssuer.map(e=>e.toString()).join(", ")),r}),e}}Zc.NAME="CRL Distribution Points";class Yc extends pc{constructor(...e){var t,r,i,s;if(n.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Gr){const t=new Gr(e[0]);super(zr,e[1],pr.serialize(t))}else{const t=e[0],r=new Gr;el(r,t,Mr,"ocsp"),el(r,t,$r,"caIssuers"),el(r,t,Kr,"timeStamping"),el(r,t,Fr,"caRepository"),super(zr,e[1],pr.serialize(r))}null!==(t=this.ocsp)&&void 0!==t||(this.ocsp=[]),null!==(r=this.caIssuers)&&void 0!==r||(this.caIssuers=[]),null!==(i=this.timeStamping)&&void 0!==i||(this.timeStamping=[]),null!==(s=this.caRepository)&&void 0!==s||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[];pr.parse(e.extnValue,Gr).forEach(e=>{switch(e.accessMethod){case Mr:this.ocsp.push(new Pc(e.accessLocation));break;case $r:this.caIssuers.push(new Pc(e.accessLocation));break;case Kr:this.timeStamping.push(new Pc(e.accessLocation));break;case Fr:this.caRepository.push(new Pc(e.accessLocation))}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Qc(e,"OCSP",this.ocsp),this.caIssuers.length&&Qc(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Qc(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Qc(e,"CA Repository",this.caRepository),e}}function Qc(e,t,r){if(1===r.length)e[t]=r[0].toTextObject();else{const i=new sc("");r.forEach((e,t)=>{const r=e.toTextObject(),n=`${r[sc.NAME]} ${t+1}`;let s=i[n];Array.isArray(s)||(s=[],i[n]=s),s.push(r)}),e[t]=i}}function el(e,t,r,i){const n=t[i];if(n){(Array.isArray(n)?n:[n]).forEach(t=>{"string"==typeof t&&(t=new Pc("url",t)),e.push(new qr({accessMethod:r,accessLocation:pr.parse(t.rawData,Vr)}))})}}Yc.NAME="Authority Info Access";class tl extends pc{constructor(...e){n.isBufferSource(e[0])?super(e[0]):super(Ki,e[1],new Rc(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=pr.parse(e.extnValue,ti);this.names=new Rc(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const r in t)e[r]=t[r];return e}}var rl;tl.NAME="Issuer Alternative Name";class il{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}mr([ar({type:Ct.ObjectIdentifier})],il.prototype,"attrId",void 0),mr([ar({type:Ct.Any,repeated:"set"})],il.prototype,"attrValues",void 0);let nl=rl=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,rl.prototype)}};var sl;nl=rl=mr([or({type:kt.Sequence,itemType:il})],nl);let ol=sl=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,sl.prototype)}};ol=sl=mr([or({type:kt.Sequence,itemType:Ss})],ol);class al{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],al.prototype,"certId",void 0),mr([ar({type:Ct.Any,context:0})],al.prototype,"certValue",void 0);class cl{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],cl.prototype,"crlId",void 0),mr([ar({type:Ct.Any,context:0})],cl.prototype,"crltValue",void 0);class ll extends Nt{}let ul=class{constructor(e={}){this.encryptionAlgorithm=new gn,this.encryptedData=new ll,Object.assign(this,e)}};var hl,pl;mr([ar({type:gn})],ul.prototype,"encryptionAlgorithm",void 0),mr([ar({type:ll})],ul.prototype,"encryptedData",void 0),function(e){e[e.v1=0]="v1"}(pl||(pl={}));class fl extends Nt{}let yl=hl=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,hl.prototype)}};yl=hl=mr([or({type:kt.Sequence,itemType:sn})],yl);class dl{constructor(e={}){this.version=pl.v1,this.privateKeyAlgorithm=new gn,this.privateKey=new fl,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],dl.prototype,"version",void 0),mr([ar({type:gn})],dl.prototype,"privateKeyAlgorithm",void 0),mr([ar({type:fl})],dl.prototype,"privateKey",void 0),mr([ar({type:yl,implicit:!0,context:0,optional:!0})],dl.prototype,"attributes",void 0);let gl=class extends dl{};gl=mr([or({type:kt.Sequence})],gl);let vl=class extends ul{};vl=mr([or({type:kt.Sequence})],vl);class ml{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],ml.prototype,"secretTypeId",void 0),mr([ar({type:Ct.Any,context:0})],ml.prototype,"secretValue",void 0);class wl{constructor(e={}){this.mac=new Zo,this.macSalt=new Nt,this.iterations=1,Object.assign(this,e)}}mr([ar({type:Zo})],wl.prototype,"mac",void 0),mr([ar({type:Nt})],wl.prototype,"macSalt",void 0),mr([ar({type:Ct.Integer,defaultValue:1})],wl.prototype,"iterations",void 0);class bl{constructor(e={}){this.version=3,this.authSafe=new Ss,this.macData=new wl,Object.assign(this,e)}}var Al;mr([ar({type:Ct.Integer})],bl.prototype,"version",void 0),mr([ar({type:Ss})],bl.prototype,"authSafe",void 0),mr([ar({type:wl,optional:!0})],bl.prototype,"macData",void 0);class Sl{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Sl.prototype,"bagId",void 0),mr([ar({type:Ct.Any,context:0})],Sl.prototype,"bagValue",void 0),mr([ar({type:il,repeated:"set",optional:!0})],Sl.prototype,"bagAttributes",void 0);let xl=Al=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Al.prototype)}};var Bl,kl,Cl;xl=Al=mr([or({type:kt.Sequence,itemType:Sl})],xl);const El="1.2.840.113549.1.9",Ol=`${El}.7`,Nl=`${El}.14`;let Il=class extends Er{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};mr([ar({type:Ct.IA5String})],Il.prototype,"ia5String",void 0),Il=mr([or({type:kt.Choice})],Il);let Tl=class extends Ss{};Tl=mr([or({type:kt.Sequence})],Tl);let jl=class extends bl{};jl=mr([or({type:kt.Sequence})],jl);let Ul=class extends ul{};Ul=mr([or({type:kt.Sequence})],Ul);let Pl=class{constructor(e=""){this.value=e}toString(){return this.value}};mr([ar({type:Ct.IA5String})],Pl.prototype,"value",void 0),Pl=mr([or({type:kt.Choice})],Pl);let Rl=class extends Il{};Rl=mr([or({type:kt.Choice})],Rl);let Vl=class extends Er{};Vl=mr([or({type:kt.Choice})],Vl);let Dl=class{constructor(e=new Date){this.value=e}};mr([ar({type:Ct.GeneralizedTime})],Dl.prototype,"value",void 0),Dl=mr([or({type:kt.Choice})],Dl);let Ll=class extends Er{};Ll=mr([or({type:kt.Choice})],Ll);let Hl=class{constructor(e="M"){this.value=e}toString(){return this.value}};mr([ar({type:Ct.PrintableString})],Hl.prototype,"value",void 0),Hl=mr([or({type:kt.Choice})],Hl);let Ml=class{constructor(e=""){this.value=e}toString(){return this.value}};mr([ar({type:Ct.PrintableString})],Ml.prototype,"value",void 0),Ml=mr([or({type:kt.Choice})],Ml);let $l=class extends Ml{};$l=mr([or({type:kt.Choice})],$l);let Kl=class extends Er{};Kl=mr([or({type:kt.Choice})],Kl);let Fl=class{constructor(e=""){this.value=e}toString(){return this.value}};mr([ar({type:Ct.ObjectIdentifier})],Fl.prototype,"value",void 0),Fl=mr([or({type:kt.Choice})],Fl);let _l=class extends mn{};_l=mr([or({type:kt.Choice})],_l);let Wl=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};mr([ar({type:Ct.Integer})],Wl.prototype,"value",void 0),Wl=mr([or({type:kt.Choice})],Wl);let zl=class extends Mn{};zl=mr([or({type:kt.Sequence})],zl);let ql=class extends Er{};ql=mr([or({type:kt.Choice})],ql);let Gl=Bl=class extends Sn{constructor(e){super(e),Object.setPrototypeOf(this,Bl.prototype)}};Gl=Bl=mr([or({type:kt.Sequence})],Gl);let Jl=kl=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,kl.prototype)}};Jl=kl=mr([or({type:kt.Set,itemType:Ln})],Jl);let Xl=class{constructor(e=""){this.value=e}toString(){return this.value}};mr([ar({type:Ct.BmpString})],Xl.prototype,"value",void 0),Xl=mr([or({type:kt.Choice})],Xl);let Zl=class extends gn{};Zl=mr([or({type:kt.Sequence})],Zl);let Yl=Cl=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Cl.prototype)}};Yl=Cl=mr([or({type:kt.Sequence,itemType:Zl})],Yl);class Ql extends hc{constructor(...e){let t;if(n.isBufferSource(e[0]))t=n.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(e=>n.toArrayBuffer(e)):[];t=pr.serialize(new sn({type:r,values:i}))}super(t,sn)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(e=>new sc("",{"":e})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[sc.NAME]===Ql.NAME&&(e[sc.NAME]=ac.toString(this.type)),e}}Ql.NAME="Attribute";class eu extends Ql{constructor(...e){var t;if(n.isBufferSource(e[0]))super(e[0]);else{const t=new ql({printableString:e[0]});super(Ol,[pr.serialize(t)])}null!==(t=this.password)&&void 0!==t||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const e=pr.parse(this.values[0],ql);this.password=e.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[sc.VALUE]=this.password,e}}eu.NAME="Challenge Password";class tu extends Ql{constructor(...e){var t;if(n.isBufferSource(e[0]))super(e[0]);else{const t=e[0],r=new Sn;for(const e of t)r.push(pr.parse(e.rawData,An));super(Nl,[pr.serialize(r)])}null!==(t=this.items)&&void 0!==t||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const e=pr.parse(this.values[0],Sn);this.items=e.map(e=>Jc.create(pr.serialize(e)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(e=>e.toTextObject());for(const r of t)e[r[sc.NAME]]=r;return e}}tu.NAME="Extensions";class ru{static register(e,t){this.items.set(e,t)}static create(e){const t=new Ql(e),r=this.items.get(t.type);return r?new r(e):t}}ru.items=new Map;const iu="crypto.signatureFormatter";class nu{toAsnSignature(e,t){return n.toArrayBuffer(t)}toWebSignature(e,t){return n.toArrayBuffer(t)}}var su;e.RsaAlgorithm=su=class{static createPssParams(e,t){const r=su.getHashAlgorithm(e);return r?new Xo({hashAlgorithm:r,maskGenAlgorithm:new gn({algorithm:_o,parameters:pr.serialize(r)}),saltLength:t}):null}static getHashAlgorithm(e){const t=Aa.resolve(ka);return"string"==typeof e?t.toAsnAlgorithm({name:e}):"object"==typeof e&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if(!("hash"in e))return new gn({algorithm:Co,parameters:null});{let t;if("string"==typeof e.hash)t=e.hash;else{if(!e.hash||"object"!=typeof e.hash||!("name"in e.hash)||"string"!=typeof e.hash.name)throw new Error("Cannot get hash algorithm name");t=e.hash.name.toUpperCase()}switch(t.toLowerCase()){case"sha-1":return new gn({algorithm:jo,parameters:null});case"sha-256":return new gn({algorithm:Po,parameters:null});case"sha-384":return new gn({algorithm:Ro,parameters:null});case"sha-512":return new gn({algorithm:Vo,parameters:null})}}break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e)||"number"!=typeof e.saltLength)throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=su.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new gn({algorithm:No,parameters:pr.serialize(t)})}return new gn({algorithm:No,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Co:return{name:"RSASSA-PKCS1-v1_5"};case jo:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Po:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Ro:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Vo:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case No:if(e.parameters){const t=pr.parse(e.parameters,Xo);return{name:"RSA-PSS",hash:Aa.resolve(ka).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}return{name:"RSA-PSS"}}return null}},e.RsaAlgorithm=su=mr([Sa()],e.RsaAlgorithm),Aa.registerSingleton(xa,e.RsaAlgorithm),e.ShaAlgorithm=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new gn({algorithm:Ho});case"sha-256":return new gn({algorithm:$o});case"sha-384":return new gn({algorithm:Ko});case"sha-512":return new gn({algorithm:Fo})}return null}toWebAlgorithm(e){switch(e.algorithm){case Ho:return{name:"SHA-1"};case $o:return{name:"SHA-256"};case Ko:return{name:"SHA-384"};case Fo:return{name:"SHA-512"}}return null}},e.ShaAlgorithm=mr([Sa()],e.ShaAlgorithm),Aa.registerSingleton(xa,e.ShaAlgorithm);class ou{addPadding(e,t){const r=n.toUint8Array(t),i=new Uint8Array(e);return i.set(r,e-r.length),i.buffer}removePadding(e,t=!1){let r=n.toUint8Array(e);for(let e=0;e127){const e=new Uint8Array(r.length+1);return e.set(r,1),e.buffer}return r.buffer}toAsnSignature(e,t){if("ECDSA"===e.name){const r=e.namedCurve,i=ou.namedCurveSize.get(r)||ou.defaultNamedCurveSize,s=new Bo,o=n.toUint8Array(t);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),pr.serialize(s)}return null}toWebSignature(e,t){if("ECDSA"===e.name){const r=pr.parse(t,Bo),i=e.namedCurve,n=ou.namedCurveSize.get(i)||ou.defaultNamedCurveSize;return function(...e){const t=e.map(e=>e.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(t);let i=0;return e.map(e=>new Uint8Array(e)).forEach(e=>{for(const t of e)r[i++]=t}),r.buffer}(this.addPadding(n,this.removePadding(r.r)),this.addPadding(n,this.removePadding(r.s)))}return null}}ou.namedCurveSize=new Map,ou.defaultNamedCurveSize=32;const au="1.3.101.110",cu="1.3.101.111",lu="1.3.101.112",uu="1.3.101.113";var hu;e.EdAlgorithm=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=lu;break;case"x25519":t=au;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=lu;break;case"ed448":t=uu}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=au;break;case"x448":t=cu}}return t?new gn({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case lu:return{name:"Ed25519"};case uu:return{name:"EdDSA",namedCurve:"Ed448"};case au:return{name:"X25519"};case cu:return{name:"ECDH-ES",namedCurve:"X448"}}return null}},e.EdAlgorithm=mr([Sa()],e.EdAlgorithm),Aa.registerSingleton(xa,e.EdAlgorithm);let pu=hu=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,hu.prototype)}};pu=hu=mr([or({type:kt.Sequence,itemType:sn})],pu);class fu{constructor(e={}){this.version=0,this.subject=new jr,this.subjectPKInfo=new vn,this.attributes=new pu,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],fu.prototype,"version",void 0),mr([ar({type:jr})],fu.prototype,"subject",void 0),mr([ar({type:vn})],fu.prototype,"subjectPKInfo",void 0),mr([ar({type:pu,implicit:!0,context:0,optional:!0})],fu.prototype,"attributes",void 0);class yu{constructor(e={}){this.certificationRequestInfo=new fu,this.signatureAlgorithm=new gn,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}var du,gu,vu,mu,wu,bu,Au,Su,xu,Bu,ku,Cu,Eu,Ou,Nu,Iu,Tu,ju,Uu,Pu,Ru,Vu,Du,Lu,Hu,Mu,$u,Ku,Fu,_u,Wu,zu,qu;mr([ar({type:fu,raw:!0})],yu.prototype,"certificationRequestInfo",void 0),mr([ar({type:gn})],yu.prototype,"signatureAlgorithm",void 0),mr([ar({type:Ct.BitString})],yu.prototype,"signature",void 0);class Gu extends $c{get subjectName(){return Br(this,gu,"f")||kr(this,gu,new wc(this.asn.certificationRequestInfo.subject),"f"),Br(this,gu,"f")}get subject(){return Br(this,vu,"f")||kr(this,vu,this.subjectName.toString(),"f"),Br(this,vu,"f")}get signatureAlgorithm(){if(!Br(this,mu,"f")){const e=Aa.resolve(ka);kr(this,mu,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return Br(this,mu,"f")}get signature(){return Br(this,wu,"f")||kr(this,wu,this.asn.signature,"f"),Br(this,wu,"f")}get publicKey(){return Br(this,bu,"f")||kr(this,bu,new Kc(this.asn.certificationRequestInfo.subjectPKInfo),"f"),Br(this,bu,"f")}get attributes(){return Br(this,Au,"f")||kr(this,Au,this.asn.certificationRequestInfo.attributes.map(e=>ru.create(pr.serialize(e))),"f"),Br(this,Au,"f")}get extensions(){if(!Br(this,Su,"f")){kr(this,Su,[],"f");const e=this.getAttribute(Nl);e instanceof tu&&kr(this,Su,e.items,"f")}return Br(this,Su,"f")}get tbs(){return Br(this,du,"f")||kr(this,du,this.asn.certificationRequestInfoRaw||pr.serialize(this.asn.certificationRequestInfo),"f"),Br(this,du,"f")}constructor(e){const t=$c.isAsnEncoded(e)?[e,yu]:[e];super(t[0],t[1]),du.set(this,void 0),gu.set(this,void 0),vu.set(this,void 0),mu.set(this,void 0),wu.set(this,void 0),bu.set(this,void 0),Au.set(this,void 0),Su.set(this,void 0),this.tag=Mc.CertificateRequestTag}onInit(e){}getAttribute(e){for(const t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(const t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=yc.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(t,["verify"],e),i=Aa.resolveAll(iu).reverse();let n=null;for(const e of i)if(n=e.toWebSignature(t,this.signature),n)break;if(!n)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,r,n,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=pr.parse(this.rawData,yu),r=t.certificationRequestInfo,i=new sc("",{Version:`${xn[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const e=new sc("");for(const t of this.attributes){const r=t.toTextObject();e[r[sc.NAME]]=r}i.Attributes=e}return e.Data=i,e.Signature=new sc("",{Algorithm:cc.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}du=new WeakMap,gu=new WeakMap,vu=new WeakMap,mu=new WeakMap,wu=new WeakMap,bu=new WeakMap,Au=new WeakMap,Su=new WeakMap,Gu.NAME="PKCS#10 Certificate Request";class Ju extends $c{get publicKey(){return Br(this,Pu,"f")||kr(this,Pu,new Kc(this.asn.tbsCertificate.subjectPublicKeyInfo),"f"),Br(this,Pu,"f")}get serialNumber(){if(!Br(this,Bu,"f")){const e=this.asn.tbsCertificate;let t=new Uint8Array(e.serialNumber);t.length>1&&0===t[0]&&t[1]>127&&(t=t.slice(1)),kr(this,Bu,h.ToHex(t),"f")}return Br(this,Bu,"f")}get subjectName(){return Br(this,ku,"f")||kr(this,ku,new wc(this.asn.tbsCertificate.subject),"f"),Br(this,ku,"f")}get subject(){return Br(this,Cu,"f")||kr(this,Cu,this.subjectName.toString(),"f"),Br(this,Cu,"f")}get issuerName(){return Br(this,Eu,"f")||kr(this,Eu,new wc(this.asn.tbsCertificate.issuer),"f"),Br(this,Eu,"f")}get issuer(){return Br(this,Ou,"f")||kr(this,Ou,this.issuerName.toString(),"f"),Br(this,Ou,"f")}get notBefore(){if(!Br(this,Nu,"f")){const e=this.asn.tbsCertificate.validity.notBefore.utcTime||this.asn.tbsCertificate.validity.notBefore.generalTime;if(!e)throw new Error("Cannot get 'notBefore' value");kr(this,Nu,e,"f")}return Br(this,Nu,"f")}get notAfter(){if(!Br(this,Iu,"f")){const e=this.asn.tbsCertificate.validity.notAfter.utcTime||this.asn.tbsCertificate.validity.notAfter.generalTime;if(!e)throw new Error("Cannot get 'notAfter' value");kr(this,Iu,e,"f")}return Br(this,Iu,"f")}get signatureAlgorithm(){if(!Br(this,Tu,"f")){const e=Aa.resolve(ka);kr(this,Tu,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return Br(this,Tu,"f")}get signature(){return Br(this,ju,"f")||kr(this,ju,this.asn.signatureValue,"f"),Br(this,ju,"f")}get extensions(){return Br(this,Uu,"f")||(kr(this,Uu,[],"f"),this.asn.tbsCertificate.extensions&&kr(this,Uu,this.asn.tbsCertificate.extensions.map(e=>Jc.create(pr.serialize(e))),"f")),Br(this,Uu,"f")}get tbs(){return Br(this,xu,"f")||kr(this,xu,this.asn.tbsCertificateRaw||pr.serialize(this.asn.tbsCertificate),"f"),Br(this,xu,"f")}constructor(e){const t=$c.isAsnEncoded(e)?[e,kn]:[e];super(t[0],t[1]),xu.set(this,void 0),Bu.set(this,void 0),ku.set(this,void 0),Cu.set(this,void 0),Eu.set(this,void 0),Ou.set(this,void 0),Nu.set(this,void 0),Iu.set(this,void 0),Tu.set(this,void 0),ju.set(this,void 0),Uu.set(this,void 0),Pu.set(this,void 0),this.tag=Mc.CertificateTag}onInit(e){}getExtension(e){for(const t of this.extensions)if("string"==typeof e){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>"string"==typeof e?t.type===e:t instanceof e)}async verify(e={},t=yc.get()){let r,i;const s=e.publicKey;try{if(s)if("publicKey"in s)r={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(r,["verify"],t);else if(s instanceof Kc)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],t);else if(n.isBufferSource(s)){const e=new Kc(s);r={...e.algorithm,...this.signatureAlgorithm},i=await e.export(r,["verify"],t)}else r={...s.algorithm,...this.signatureAlgorithm},i=s;else r={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(r,["verify"],t)}catch(e){return!1}const o=Aa.resolveAll(iu).reverse();let a=null;for(const e of o)if(a=e.toWebSignature(r,this.signature),a)break;if(!a)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const c=await t.subtle.verify(this.signatureAlgorithm,i,a,this.tbs);if(e.signatureOnly)return c;{const t=(e.date||new Date).getTime();return c&&this.notBefore.getTime()new bs({certificate:pr.parse(e.rawData,kn)})));const r=new Ss({contentType:Qs,content:pr.serialize(t)}),i=pr.serialize(r);return"raw"===e?i:this.toString(e)}import(e){const t=$c.toArrayBuffer(e),r=pr.parse(t,Ss);if(r.contentType!==Qs)throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object.");const i=pr.parse(r.content,ro);this.clear();for(const e of i.certificates||[])e.certificate&&this.push(new Ju(e.certificate))}clear(){for(;this.pop(););}toString(e="pem"){const t=this.export("raw");switch(e){case"pem":return Mc.encode(t,"CMS");case"pem-chain":return this.map(e=>e.toString("pem")).join("\n");case"asn":return pr.toString(t);case"hex":return h.ToHex(t);case"base64":return h.ToBase64(t);case"base64url":return h.ToBase64Url(t);case"text":return cc.serialize(this.toTextObject());default:throw TypeError("Argument 'format' is unsupported value")}}toTextObject(){const e=pr.parse(this.export("raw"),Ss),t=pr.parse(e.content,ro);return new sc("X509Certificates",{"Content Type":ac.toString(e.contentType),Content:new sc("",{Version:`${Tn[t.version]} (${t.version})`,Certificates:new sc("",{Certificate:this.map(e=>e.toTextObject())})})})}}function Zu(e,t=yc.get()){const r=n.toUint8Array(h.FromHex(e||""));let i=r&&r.length&&r.some(e=>e>0)?new Uint8Array(r):void 0;i||(i=t.getRandomValues(new Uint8Array(16)));let s=0;for(;s127){const e=new Uint8Array(i.length+1);e[0]=0,e.set(i,1),i=e}return i.buffer}e.X509CrlReason=void 0,(Mu=e.X509CrlReason||(e.X509CrlReason={}))[Mu.unspecified=0]="unspecified",Mu[Mu.keyCompromise=1]="keyCompromise",Mu[Mu.cACompromise=2]="cACompromise",Mu[Mu.affiliationChanged=3]="affiliationChanged",Mu[Mu.superseded=4]="superseded",Mu[Mu.cessationOfOperation=5]="cessationOfOperation",Mu[Mu.certificateHold=6]="certificateHold",Mu[Mu.removeFromCRL=8]="removeFromCRL",Mu[Mu.privilegeWithdrawn=9]="privilegeWithdrawn",Mu[Mu.aACompromise=10]="aACompromise";class Yu extends hc{get serialNumber(){return Br(this,Ru,"f")||kr(this,Ru,h.ToHex(this.asn.userCertificate),"f"),Br(this,Ru,"f")}get revocationDate(){return Br(this,Vu,"f")||kr(this,Vu,this.asn.revocationDate.getTime(),"f"),Br(this,Vu,"f")}get reason(){return void 0===Br(this,Du,"f")&&this.extensions,Br(this,Du,"f")}get invalidity(){return void 0===Br(this,Lu,"f")&&this.extensions,Br(this,Lu,"f")}get extensions(){return Br(this,Hu,"f")||(kr(this,Hu,[],"f"),this.asn.crlEntryExtensions&&kr(this,Hu,this.asn.crlEntryExtensions.map(e=>{const t=Jc.create(pr.serialize(e));switch(t.type){case Ci:void 0===Br(this,Du,"f")&&kr(this,Du,pr.parse(t.value,Oi).reason,"f");break;case Hi:void 0===Br(this,Lu,"f")&&kr(this,Lu,pr.parse(t.value,Mi).value,"f")}return t}),"f")),Br(this,Hu,"f")}constructor(...e){let t;if(n.isBufferSource(e[0])?t=n.toArrayBuffer(e[0]):"string"==typeof e[0]?t=pr.serialize(new Cn({userCertificate:Zu(e[0]),revocationDate:new mn(e[1]),crlEntryExtensions:e[2]})):e[0]instanceof Cn&&(t=e[0]),!t)throw new TypeError("Cannot create X509CrlEntry instance. Wrong constructor arguments.");super(t,Cn),Ru.set(this,void 0),Vu.set(this,void 0),Du.set(this,void 0),Lu.set(this,void 0),Hu.set(this,void 0)}onInit(e){}}Ru=new WeakMap,Vu=new WeakMap,Du=new WeakMap,Lu=new WeakMap,Hu=new WeakMap;class Qu extends $c{get version(){return this.asn.tbsCertList.version}get signatureAlgorithm(){if(!Br(this,Ku,"f")){const e=Aa.resolve(ka);kr(this,Ku,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return Br(this,Ku,"f")}get signature(){return this.asn.signature}get issuer(){return this.issuerName.toString()}get issuerName(){return Br(this,Fu,"f")||kr(this,Fu,new wc(this.asn.tbsCertList.issuer),"f"),Br(this,Fu,"f")}get thisUpdate(){if(!Br(this,_u,"f")){const e=this.asn.tbsCertList.thisUpdate.getTime();if(!e)throw new Error("Cannot get 'thisUpdate' value");kr(this,_u,e,"f")}return Br(this,_u,"f")}get nextUpdate(){var e;return void 0===Br(this,Wu,"f")&&kr(this,Wu,(null===(e=this.asn.tbsCertList.nextUpdate)||void 0===e?void 0:e.getTime())||void 0,"f"),Br(this,Wu,"f")}get entries(){var e;return Br(this,zu,"f")||kr(this,zu,(null===(e=this.asn.tbsCertList.revokedCertificates)||void 0===e?void 0:e.map(e=>new Yu(e)))||[],"f"),Br(this,zu,"f")}get extensions(){return Br(this,qu,"f")||(kr(this,qu,[],"f"),this.asn.tbsCertList.crlExtensions&&kr(this,qu,this.asn.tbsCertList.crlExtensions.map(e=>Jc.create(pr.serialize(e))),"f")),Br(this,qu,"f")}get tbs(){return Br(this,$u,"f")||kr(this,$u,this.asn.tbsCertListRaw||pr.serialize(this.asn.tbsCertList),"f"),Br(this,$u,"f")}get tbsCertListSignatureAlgorithm(){return this.asn.tbsCertList.signature}get certListSignatureAlgorithm(){return this.asn.signatureAlgorithm}constructor(e){super(e,$c.isAsnEncoded(e)?On:void 0),this.tag=Mc.CrlTag,$u.set(this,void 0),Ku.set(this,void 0),Fu.set(this,void 0),_u.set(this,void 0),Wu.set(this,void 0),zu.set(this,void 0),qu.set(this,void 0)}onInit(e){}getExtension(e){for(const t of this.extensions)if("string"==typeof e){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>"string"==typeof e?t.type===e:t instanceof e)}async verify(e,t=yc.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw new Error("algorithm identifier in the sequence tbsCertList and CertificateList mismatch");let r,i;const n=e.publicKey;try{n instanceof Ju?(r={...n.publicKey.algorithm,...n.signatureAlgorithm},i=await n.publicKey.export(r,["verify"])):n instanceof Kc?(r={...n.algorithm,...this.signatureAlgorithm},i=await n.export(r,["verify"])):(r={...n.algorithm,...this.signatureAlgorithm},i=n)}catch(e){return!1}const s=Aa.resolveAll(iu).reverse();let o=null;for(const e of s)if(o=e.toWebSignature(r,this.signature),o)break;if(!o)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return await t.subtle.verify(this.signatureAlgorithm,i,o,this.tbs)}async getThumbprint(...e){let t,r="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(r=e[0]||r,t=e[1])),null!=t||(t=yc.get()),await t.subtle.digest(r,this.rawData)}findRevoked(e){const t=Zu("string"==typeof e?e:e.serialNumber);for(const e of this.asn.tbsCertList.revokedCertificates||[])if(n.isEqual(e.userCertificate,t))return new Yu(pr.serialize(e));return null}}$u=new WeakMap,Ku=new WeakMap,Fu=new WeakMap,_u=new WeakMap,Wu=new WeakMap,zu=new WeakMap,qu=new WeakMap;return Jc.register(Yr,_c),Jc.register(Ii,Wc),Jc.register(_i,zc),Jc.register(cn,qc),Jc.register(Jr,Fc),Jc.register(rn,Gc),Jc.register(vi,Zc),Jc.register(zr,Yc),Jc.register(Ki,tl),ru.register(Ol,eu),ru.register(Nl,tu),Aa.registerSingleton(iu,nu),Aa.registerSingleton(iu,ou),ou.namedCurveSize.set("P-256",32),ou.namedCurveSize.set("K-256",32),ou.namedCurveSize.set("P-384",48),ou.namedCurveSize.set("P-521",66),e.AlgorithmProvider=Ba,e.AsnData=hc,e.AsnDefaultSignatureFormatter=nu,e.AsnEcSignatureFormatter=ou,e.Attribute=Ql,e.AttributeFactory=ru,e.AuthorityInfoAccessExtension=Yc,e.AuthorityKeyIdentifierExtension=Fc,e.BasicConstraintsExtension=_c,e.CRLDistributionPointsExtension=Zc,e.CertificatePolicyExtension=Xc,e.ChallengePasswordAttribute=eu,e.CryptoProvider=fc,e.DN=Ec,e.DNS=Cc,e.DefaultAlgorithmSerializer=oc,e.EMAIL=Oc,e.ExtendedKeyUsageExtension=Wc,e.Extension=pc,e.ExtensionFactory=Jc,e.ExtensionsAttribute=tu,e.GUID=Tc,e.GeneralName=Pc,e.GeneralNames=Rc,e.IP=Nc,e.IssuerAlternativeNameExtension=tl,e.KeyUsagesExtension=zc,e.Name=wc,e.NameIdentifier=gc,e.OidSerializer=ac,e.PemConverter=Mc,e.PemData=$c,e.Pkcs10CertificateRequest=Gu,e.Pkcs10CertificateRequestGenerator=class{static async create(e,t=yc.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");const r=await t.subtle.exportKey("spki",e.keys.publicKey),i=new yu({certificationRequestInfo:new fu({subjectPKInfo:pr.parse(r,vn)})});if(e.name){const t=e.name instanceof wc?e.name:new wc(e.name);i.certificationRequestInfo.subject=pr.parse(t.toArrayBuffer(),jr)}if(e.attributes)for(const t of e.attributes)i.certificationRequestInfo.attributes.push(pr.parse(t.rawData,sn));if(e.extensions&&e.extensions.length){const t=new sn({type:Nl}),r=new Sn;for(const t of e.extensions)r.push(pr.parse(t.rawData,An));t.values.push(pr.serialize(r)),i.certificationRequestInfo.attributes.push(t)}const n={...e.signingAlgorithm,...e.keys.privateKey.algorithm},s=Aa.resolve(ka);i.signatureAlgorithm=s.toAsnAlgorithm(n);const o=pr.serialize(i.certificationRequestInfo),a=await t.subtle.sign(n,e.keys.privateKey,o),c=Aa.resolveAll(iu).reverse();let l=null;for(const e of c)if(l=e.toAsnSignature(n,a),l)break;if(!l)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return i.signature=l,new Gu(pr.serialize(i))}},e.PublicKey=Kc,e.REGISTERED_ID=Uc,e.SubjectAlternativeNameExtension=Gc,e.SubjectKeyIdentifierExtension=qc,e.TextConverter=cc,e.TextObject=sc,e.UPN=jc,e.URL=Ic,e.X509Certificate=Ju,e.X509CertificateGenerator=class{static async createSelfSigned(e,t=yc.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=yc.get()){var r;let i;i=e.publicKey instanceof Kc?e.publicKey.rawData:"publicKey"in e.publicKey?e.publicKey.publicKey.rawData:n.isBufferSource(e.publicKey)?e.publicKey:await t.subtle.exportKey("spki",e.publicKey);const s=Zu(e.serialNumber,t),o=e.notBefore||new Date,a=e.notAfter||new Date(o.getTime()+31536e6),c=new kn({tbsCertificate:new Bn({version:xn.v3,serialNumber:s,validity:new wn({notBefore:o,notAfter:a}),extensions:new Sn((null===(r=e.extensions)||void 0===r?void 0:r.map(e=>pr.parse(e.rawData,An)))||[]),subjectPublicKeyInfo:pr.parse(i,vn)})});if(e.subject){const t=e.subject instanceof wc?e.subject:new wc(e.subject);c.tbsCertificate.subject=pr.parse(t.toArrayBuffer(),jr)}if(e.issuer){const t=e.issuer instanceof wc?e.issuer:new wc(e.issuer);c.tbsCertificate.issuer=pr.parse(t.toArrayBuffer(),jr)}const l={hash:"SHA-256"},u="signingKey"in e?{...l,...e.signingAlgorithm,...e.signingKey.algorithm}:{...l,...e.signingAlgorithm},h=Aa.resolve(ka);c.tbsCertificate.signature=c.signatureAlgorithm=h.toAsnAlgorithm(u);const p=pr.serialize(c.tbsCertificate),f="signingKey"in e?await t.subtle.sign(u,e.signingKey,p):e.signature,y=Aa.resolveAll(iu).reverse();let d=null;for(const e of y)if(d=e.toAsnSignature(u,f),d)break;if(!d)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=d,new Ju(pr.serialize(c))}},e.X509Certificates=Xu,e.X509ChainBuilder=class{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=yc.get()){const r=new Xu(e);let i=e;for(;i=await this.findIssuer(i,t);){const e=await i.getThumbprint(t);for(const i of r){if(p(e,await i.getThumbprint(t)))throw new Error("Cannot build a certificate chain. Circular dependency.")}r.push(i)}return r}async findIssuer(e,t=yc.get()){if(!await e.isSelfSigned(t)){const r=e.getExtension(Jr);for(const i of this.certificates)if(i.subject===e.issuer){if(r)if(r.keyId){const e=i.getExtension(cn);if(e&&e.keyId!==r.keyId)continue}else if(r.certId){const e=i.getExtension(rn);if(e&&(r.certId.serialNumber!==i.serialNumber||!p(pr.serialize(r.certId.name),pr.serialize(e))))continue}try{const r={...i.publicKey.algorithm,...e.signatureAlgorithm},n=await i.publicKey.export(r,["verify"],t);if(!await e.verify({publicKey:n,signatureOnly:!0},t))continue}catch(e){continue}return i}}return null}},e.X509Crl=Qu,e.X509CrlEntry=Yu,e.X509CrlGenerator=class{static async create(e,t=yc.get()){var r;const i=e.issuer instanceof wc?e.issuer:new wc(e.issuer),n=new On({tbsCertList:new En({version:xn.v2,issuer:pr.parse(i.toArrayBuffer(),jr),thisUpdate:new mn(e.thisUpdate||new Date)})});if(e.nextUpdate&&(n.tbsCertList.nextUpdate=new mn(e.nextUpdate)),e.extensions&&e.extensions.length&&(n.tbsCertList.crlExtensions=new Sn(e.extensions.map(e=>pr.parse(e.rawData,An))||[])),e.entries&&e.entries.length){n.tbsCertList.revokedCertificates=[];for(const t of e.entries){const i=$c.toArrayBuffer(t.serialNumber);if(n.tbsCertList.revokedCertificates.findIndex(e=>p(e.userCertificate,i))>-1)throw new Error(`Certificate serial number ${t.serialNumber} already exists in tbsCertList`);const s=new Cn({userCertificate:i,revocationDate:new mn(t.revocationDate||new Date)});if("extensions"in t&&(null===(r=t.extensions)||void 0===r?void 0:r.length)?s.crlEntryExtensions=t.extensions.map(e=>pr.parse(e.rawData,An)):s.crlEntryExtensions=[],!(t instanceof Yu)&&(t.reason&&s.crlEntryExtensions.push(new An({extnID:Ci,critical:!1,extnValue:new Nt(pr.serialize(new Oi(t.reason)))})),t.invalidity&&s.crlEntryExtensions.push(new An({extnID:Hi,critical:!1,extnValue:new Nt(pr.serialize(new Mi(t.invalidity)))})),t.issuer)){const t=e.issuer instanceof wc?e.issuer:new wc(e.issuer);s.crlEntryExtensions.push(new An({extnID:ii,critical:!1,extnValue:new Nt(pr.serialize(pr.parse(t.toArrayBuffer(),jr)))}))}n.tbsCertList.revokedCertificates.push(s)}}const s={...e.signingAlgorithm,...e.signingKey.algorithm},o=Aa.resolve(ka);n.tbsCertList.signature=n.signatureAlgorithm=o.toAsnAlgorithm(s);const a=pr.serialize(n.tbsCertList),c=await t.subtle.sign(s,e.signingKey,a),l=Aa.resolveAll(iu).reverse();let u=null;for(const e of l)if(u=e.toAsnSignature(s,c),u)break;if(!u)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return n.signature=u,new Qu(pr.serialize(n))}},e.cryptoProvider=yc,e.diAlgorithm=xa,e.diAlgorithmProvider=ka,e.diAsnSignatureFormatter=iu,e.idEd25519=lu,e.idEd448=uu,e.idX25519=au,e.idX448=cu,e}({}); diff --git a/node_modules/@peculiar/x509/package.json b/node_modules/@peculiar/x509/package.json new file mode 100644 index 0000000000000000000000000000000000000000..05424c34b9c57ab64b859ef14d96ac988c913ddf --- /dev/null +++ b/node_modules/@peculiar/x509/package.json @@ -0,0 +1,94 @@ +{ + "name": "@peculiar/x509", + "version": "1.14.3", + "description": "@peculiar/x509 is an easy to use TypeScript/Javascript library based on @peculiar/asn1-schema that makes generating X.509 Certificates and Certificate Requests as well as validating certificate chains easy", + "main": "build/x509.cjs.js", + "module": "build/x509.es.js", + "unpkg": "build/x509.js", + "types": "build/index.d.ts", + "scripts": { + "test": "vitest run", + "test:watch": "vitest", + "lint": "eslint", + "lint:fix": "eslint --fix", + "build": "npm run build:module", + "build:module": "rollup -c", + "rebuild": "npm run clear && npm run build", + "coverage": "vitest run --coverage", + "coveralls": "vitest run --coverage && cat coverage/lcov.info | coveralls", + "pub": "npm run pub:patch", + "pub:patch": "npm version patch && npm run git:push", + "pub:minor": "npm version minor && npm run git:push", + "pub:major": "npm version major && npm run git:push", + "git:push": "git push --follow-tags" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/PeculiarVentures/x509.git" + }, + "keywords": [ + "x509", + "certificate", + "csr", + "pkcs10", + "pkcs7", + "cms", + "rsa", + "ec" + ], + "author": "Peculiar Ventures LLC", + "contributors": [ + "Miroshin Stepan" + ], + "license": "MIT", + "bugs": { + "url": "https://github.com/PeculiarVentures/x509/issues" + }, + "homepage": "https://github.com/PeculiarVentures/x509#readme", + "files": [ + "build/**/*.{ts,js}", + "README.md", + "LICENSE" + ], + "devDependencies": { + "@babel/core": "^7.28.5", + "@babel/preset-env": "^7.28.5", + "@peculiar/eslint-config-base": "^0.2.8", + "@peculiar/webcrypto": "^1.5.0", + "@rollup/plugin-babel": "^6.1.0", + "@rollup/plugin-commonjs": "^29.0.0", + "@rollup/plugin-node-resolve": "^16.0.3", + "@rollup/plugin-terser": "^0.4.4", + "@types/node": "^24.10.1", + "@vitest/coverage-v8": "^4.0.9", + "rimraf": "^6.1.0", + "rollup": "^4.53.2", + "rollup-plugin-dts": "^6.2.3", + "rollup-plugin-typescript2": "^0.36.0", + "typescript": "^5.9.3", + "vitest": "^4.0.9" + }, + "dependencies": { + "@peculiar/asn1-cms": "^2.6.0", + "@peculiar/asn1-csr": "^2.6.0", + "@peculiar/asn1-ecc": "^2.6.0", + "@peculiar/asn1-pkcs9": "^2.6.0", + "@peculiar/asn1-rsa": "^2.6.0", + "@peculiar/asn1-schema": "^2.6.0", + "@peculiar/asn1-x509": "^2.6.0", + "pvtsutils": "^1.3.6", + "reflect-metadata": "^0.2.2", + "tslib": "^2.8.1", + "tsyringe": "^4.10.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "devEngines": { + "packageManager": { + "name": "npm", + "version": ">=10", + "onFail": "error" + } + } +} diff --git a/node_modules/@pkgr/core/index.d.cts b/node_modules/@pkgr/core/index.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..94b401853a1d74579654a711544dfd9ccdcadb7d --- /dev/null +++ b/node_modules/@pkgr/core/index.d.cts @@ -0,0 +1,3 @@ +import * as core from './lib/index.js' + +export = core diff --git a/node_modules/@pkgr/core/lib/constants.d.ts b/node_modules/@pkgr/core/lib/constants.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb8054471e853306fd26dd06ef9af7bb1f7b3866 --- /dev/null +++ b/node_modules/@pkgr/core/lib/constants.d.ts @@ -0,0 +1,6 @@ +/// +export interface CjsRequire extends NodeJS.Require { + (id: string): T; +} +export declare const cjsRequire: CjsRequire; +export declare const EXTENSIONS: string[]; diff --git a/node_modules/@pkgr/core/lib/constants.js b/node_modules/@pkgr/core/lib/constants.js new file mode 100644 index 0000000000000000000000000000000000000000..8e0ecd786eccfcf91e80b4eea52047be46d7478e --- /dev/null +++ b/node_modules/@pkgr/core/lib/constants.js @@ -0,0 +1,9 @@ +import { createRequire } from 'node:module'; +export const cjsRequire = typeof require === 'function' ? require : createRequire(import.meta.url); +const DEFAULT_EXTENSIONS = cjsRequire.extensions + ? + Object.keys(cjsRequire.extensions) + : + ['.js', '.json', '.node']; +export const EXTENSIONS = ['.ts', '.tsx', ...DEFAULT_EXTENSIONS]; +//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/node_modules/@pkgr/core/lib/constants.js.map b/node_modules/@pkgr/core/lib/constants.js.map new file mode 100644 index 0000000000000000000000000000000000000000..18ee906f65785a8899f8ee5b29fbe2dab3eda498 --- /dev/null +++ b/node_modules/@pkgr/core/lib/constants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAM3C,MAAM,CAAC,MAAM,UAAU,GACrB,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAG1E,MAAM,kBAAkB,GAAG,UAAU,CAAC,UAAU;IAC9C,CAAC;QACC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IACpC,CAAC;QACC,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;AAE7B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAAC,CAAA"} \ No newline at end of file diff --git a/node_modules/@pkgr/core/lib/helpers.d.ts b/node_modules/@pkgr/core/lib/helpers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f2b24b40d39a6dd911b55bc46211415b2c5fec9 --- /dev/null +++ b/node_modules/@pkgr/core/lib/helpers.d.ts @@ -0,0 +1,19 @@ +import { type Stats } from 'node:fs'; +export declare const tryPkg: (pkg: string) => string | undefined; +export declare const isPkgAvailable: (pkg: string) => boolean; +export type FileTypeBase = 'blockDevice' | 'characterDevice' | 'directory' | 'FIFO' | 'file' | 'socket' | 'symbolicLink'; +export type FileType = Capitalize | FileTypeBase; +export type FileTypes = FileType | FileType[] | boolean | 'any'; +export declare const tryFileStats: (filename?: string[] | string, type?: FileTypes, base?: string) => { + filepath: string; + stats: Stats; +} | undefined; +export declare const tryFile: (filename?: string[] | string, type?: FileTypes, base?: string) => string; +export declare const tryExtensions: (filepath: string, extensions?: string[]) => string; +export interface FindUpOptions { + entry?: string; + search?: string[] | string; + type?: FileTypes; + stop?: string; +} +export declare const findUp: (entryOrOptions?: FindUpOptions | string, options?: FindUpOptions) => string; diff --git a/node_modules/@pkgr/core/lib/helpers.js b/node_modules/@pkgr/core/lib/helpers.js new file mode 100644 index 0000000000000000000000000000000000000000..652a1a656834fa26d2da9e3f565faef1376929f3 --- /dev/null +++ b/node_modules/@pkgr/core/lib/helpers.js @@ -0,0 +1,67 @@ +import fs, {} from 'node:fs'; +import path from 'node:path'; +import { EXTENSIONS, cjsRequire } from './constants.js'; +export const tryPkg = (pkg) => { + try { + return cjsRequire.resolve(pkg); + } + catch { } +}; +export const isPkgAvailable = (pkg) => Boolean(tryPkg(pkg)); +const ANY_FILE_TYPES = new Set(['any', true]); +const isAnyFileType = (type) => ANY_FILE_TYPES.has(type); +export const tryFileStats = (filename, type = 'file', base = process.cwd()) => { + if (!type) { + type = 'file'; + } + if (typeof filename === 'string') { + const filepath = path.resolve(base, filename); + let stats; + try { + stats = fs.statSync(filepath, { throwIfNoEntry: false }); + } + catch { } + return stats && + (isAnyFileType(type) || + (Array.isArray(type) ? type : [type]).some(type => stats[`is${type[0].toUpperCase()}${type.slice(1)}`]())) + ? { filepath, stats } + : undefined; + } + for (const file of filename ?? []) { + const result = tryFileStats(file, type, base); + if (result) { + return result; + } + } +}; +export const tryFile = (filename, type = 'file', base) => tryFileStats(filename, type, base)?.filepath ?? ''; +export const tryExtensions = (filepath, extensions = EXTENSIONS) => { + const ext = [...extensions, ''].find(ext => tryFile(filepath + ext)); + return ext == null ? '' : filepath + ext; +}; +export const findUp = (entryOrOptions, options) => { + if (typeof entryOrOptions === 'string') { + options = { + entry: entryOrOptions, + ...options, + }; + } + else if (entryOrOptions) { + options = options ? { ...entryOrOptions, ...options } : entryOrOptions; + } + let { entry = process.cwd(), search = 'package.json', type, stop, } = options ?? {}; + search = Array.isArray(search) ? search : [search]; + do { + const searched = tryFile(search, type, entry); + if (searched) { + return searched; + } + const lastEntry = entry; + entry = path.dirname(entry); + if (entry === lastEntry) { + break; + } + } while (!stop || entry !== stop); + return ''; +}; +//# sourceMappingURL=helpers.js.map \ No newline at end of file diff --git a/node_modules/@pkgr/core/lib/helpers.js.map b/node_modules/@pkgr/core/lib/helpers.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e0ad8d2e07e539c3732229c4cf9d3bd498a1a0c6 --- /dev/null +++ b/node_modules/@pkgr/core/lib/helpers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAc,MAAM,SAAS,CAAA;AACxC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEvD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,EAAE;IACpC,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAChC,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AAenE,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;AAE7C,MAAM,aAAa,GAAG,CAAC,IAAe,EAAwB,EAAE,CAC9D,cAAc,CAAC,GAAG,CAAC,IAAwB,CAAC,CAAA;AAE9C,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,QAA4B,EAC5B,OAAkB,MAAM,EACxB,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EAC4B,EAAE;IAClD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,GAAG,MAAM,CAAA;IACf,CAAC;IAED,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QAC7C,IAAI,KAAwB,CAAA;QAC5B,IAAI,CAAC;YACH,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAA;QAC1D,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QACV,OAAO,KAAK;YACV,CAAC,aAAa,CAAC,IAAI,CAAC;gBAClB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAChD,KAAK,CACH,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAqC,CAChF,EAAE,CACJ,CAAC;YACJ,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE;YACrB,CAAC,CAAC,SAAS,CAAA;IACf,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,QAAQ,IAAI,EAAE,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QAC7C,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAA;QACf,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,QAA4B,EAC5B,OAAkB,MAAM,EACxB,IAAa,EACL,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,QAAQ,IAAI,EAAE,CAAA;AAE/D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAE,UAAU,GAAG,UAAU,EAAE,EAAE;IACzE,MAAM,GAAG,GAAG,CAAC,GAAG,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAA;IACpE,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAA;AAC1C,CAAC,CAAA;AASD,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,cAAuC,EACvC,OAAuB,EACvB,EAAE;IACF,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,GAAG;YACR,KAAK,EAAE,cAAc;YACrB,GAAG,OAAO;SACX,CAAA;IACH,CAAC;SAAM,IAAI,cAAc,EAAE,CAAC;QAC1B,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,cAAc,CAAA;IACxE,CAAC;IAED,IAAI,EACF,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,EACrB,MAAM,GAAG,cAAc,EACvB,IAAI,EACJ,IAAI,GACL,GAAG,OAAO,IAAI,EAAE,CAAA;IAEjB,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAElD,GAAG,CAAC;QACF,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;QAC7C,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,MAAM,SAAS,GAAG,KAAK,CAAA;QACvB,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC3B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAK;QACP,CAAC;IACH,CAAC,QAAQ,CAAC,IAAI,IAAI,KAAK,KAAK,IAAI,EAAC;IAEjC,OAAO,EAAE,CAAA;AACX,CAAC,CAAA"} \ No newline at end of file diff --git a/node_modules/@pkgr/core/lib/index.cjs b/node_modules/@pkgr/core/lib/index.cjs new file mode 100644 index 0000000000000000000000000000000000000000..149e20288fd745ad145b5c45509fce24edc457c6 --- /dev/null +++ b/node_modules/@pkgr/core/lib/index.cjs @@ -0,0 +1,91 @@ +'use strict'; + +var node_module = require('node:module'); +var fs = require('node:fs'); +var path = require('node:path'); + +var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; +const cjsRequire = typeof require === "function" ? require : node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))); +const DEFAULT_EXTENSIONS = cjsRequire.extensions ? ( + // eslint-disable-next-line sonarjs/deprecation + Object.keys(cjsRequire.extensions) +) : ( + // `require.extensions` could be `undefined` - #430 + [".js", ".json", ".node"] +); +const EXTENSIONS = [".ts", ".tsx", ...DEFAULT_EXTENSIONS]; + +const tryPkg = (pkg) => { + try { + return cjsRequire.resolve(pkg); + } catch { + } +}; +const isPkgAvailable = (pkg) => Boolean(tryPkg(pkg)); +const ANY_FILE_TYPES = /* @__PURE__ */ new Set(["any", true]); +const isAnyFileType = (type) => ANY_FILE_TYPES.has(type); +const tryFileStats = (filename, type = "file", base = process.cwd()) => { + if (!type) { + type = "file"; + } + if (typeof filename === "string") { + const filepath = path.resolve(base, filename); + let stats; + try { + stats = fs.statSync(filepath, { throwIfNoEntry: false }); + } catch { + } + return stats && (isAnyFileType(type) || (Array.isArray(type) ? type : [type]).some( + (type2) => stats[`is${type2[0].toUpperCase()}${type2.slice(1)}`]() + )) ? { filepath, stats } : void 0; + } + for (const file of filename ?? []) { + const result = tryFileStats(file, type, base); + if (result) { + return result; + } + } +}; +const tryFile = (filename, type = "file", base) => tryFileStats(filename, type, base)?.filepath ?? ""; +const tryExtensions = (filepath, extensions = EXTENSIONS) => { + const ext = [...extensions, ""].find((ext2) => tryFile(filepath + ext2)); + return ext == null ? "" : filepath + ext; +}; +const findUp = (entryOrOptions, options) => { + if (typeof entryOrOptions === "string") { + options = { + entry: entryOrOptions, + ...options + }; + } else if (entryOrOptions) { + options = options ? { ...entryOrOptions, ...options } : entryOrOptions; + } + let { + entry = process.cwd(), + search = "package.json", + type, + stop + } = options ?? {}; + search = Array.isArray(search) ? search : [search]; + do { + const searched = tryFile(search, type, entry); + if (searched) { + return searched; + } + const lastEntry = entry; + entry = path.dirname(entry); + if (entry === lastEntry) { + break; + } + } while (!stop || entry !== stop); + return ""; +}; + +exports.EXTENSIONS = EXTENSIONS; +exports.cjsRequire = cjsRequire; +exports.findUp = findUp; +exports.isPkgAvailable = isPkgAvailable; +exports.tryExtensions = tryExtensions; +exports.tryFile = tryFile; +exports.tryFileStats = tryFileStats; +exports.tryPkg = tryPkg; diff --git a/node_modules/@pkgr/core/lib/index.d.ts b/node_modules/@pkgr/core/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d6045d9fb747a02f33fed15c07960a12f38ad12 --- /dev/null +++ b/node_modules/@pkgr/core/lib/index.d.ts @@ -0,0 +1,2 @@ +export * from './constants.js'; +export * from './helpers.js'; diff --git a/node_modules/@pkgr/core/lib/index.js b/node_modules/@pkgr/core/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e54355320647f55926adb859639e096880e5c822 --- /dev/null +++ b/node_modules/@pkgr/core/lib/index.js @@ -0,0 +1,3 @@ +export * from './constants.js'; +export * from './helpers.js'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@pkgr/core/lib/index.js.map b/node_modules/@pkgr/core/lib/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e7c22031589608390cf8c24a579c8a9338659fe5 --- /dev/null +++ b/node_modules/@pkgr/core/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA"} \ No newline at end of file diff --git a/node_modules/@pkgr/core/package.json b/node_modules/@pkgr/core/package.json new file mode 100644 index 0000000000000000000000000000000000000000..35b08d113a6c6163a1f90fb48a5024a86110cafb --- /dev/null +++ b/node_modules/@pkgr/core/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pkgr/core", + "version": "0.3.6", + "type": "module", + "description": "Shared core module for `@pkgr` packages or any package else", + "repository": "git+https://github.com/un-ts/pkgr.git", + "homepage": "https://github.com/un-ts/pkgr/blob/master/packages/core", + "author": "JounQin (https://www.1stG.me)", + "funding": "https://opencollective.com/pkgr", + "license": "MIT", + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "main": "./lib/index.cjs", + "types": "./index.d.cts", + "module": "./lib/index.js", + "exports": { + ".": { + "import": { + "types": "./lib/index.d.ts", + "default": "./lib/index.js" + }, + "require": { + "types": "./index.d.cts", + "default": "./lib/index.cjs" + } + }, + "./package.json": "./package.json" + }, + "files": [ + "index.d.cts", + "lib" + ], + "publishConfig": { + "access": "public" + }, + "sideEffects": false +} diff --git a/node_modules/@playwright/test/LICENSE b/node_modules/@playwright/test/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..df112373eb2e23e459bf93ec412be1764dc5a38b --- /dev/null +++ b/node_modules/@playwright/test/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Portions Copyright (c) Microsoft Corporation. + Portions Copyright 2017 Google Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/node_modules/@playwright/test/NOTICE b/node_modules/@playwright/test/NOTICE new file mode 100644 index 0000000000000000000000000000000000000000..814ec1696f7ad36c1b524fb6adeef14b4b367fec --- /dev/null +++ b/node_modules/@playwright/test/NOTICE @@ -0,0 +1,5 @@ +Playwright +Copyright (c) Microsoft Corporation + +This software contains code derived from the Puppeteer project (https://github.com/puppeteer/puppeteer), +available under the Apache 2.0 license (https://github.com/puppeteer/puppeteer/blob/master/LICENSE). diff --git a/node_modules/@playwright/test/README.md b/node_modules/@playwright/test/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d3abb8ffa03be5735676d55bc0596fdc402dbf9f --- /dev/null +++ b/node_modules/@playwright/test/README.md @@ -0,0 +1,318 @@ +# 🎭 Playwright + +[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) [![Chromium version](https://img.shields.io/badge/chromium-149.0.7827.55-blue.svg?logo=google-chrome)](https://www.chromium.org/Home) [![Firefox version](https://img.shields.io/badge/firefox-151.0-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/) [![WebKit version](https://img.shields.io/badge/webkit-26.5-blue.svg?logo=safari)](https://webkit.org/) [![Join Discord](https://img.shields.io/badge/join-discord-informational)](https://aka.ms/playwright/discord) + +## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright) + +Playwright is a framework for web automation and testing. It drives Chromium, Firefox, and WebKit with a single API — in your tests, in your scripts, and as a tool for AI agents. + +## Get Started + +Choose the path that fits your workflow: + +| | Best for | Install | +|---|---|---| +| **[Playwright Test](#playwright-test)** | End-to-end testing | `npm init playwright@latest` | +| **[Playwright CLI](#playwright-cli)** | Coding agents (Claude Code, Copilot) | `npm i -g @playwright/cli@latest` | +| **[Playwright MCP](#playwright-mcp)** | AI agents and LLM-driven automation | `npx @playwright/mcp@latest` | +| **[Playwright Library](#playwright-library)** | Browser automation scripts | `npm i playwright` | +| **[VS Code Extension](#vs-code-extension)** | Test authoring and debugging in VS Code | [Install from Marketplace](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) | + +--- + +## Playwright Test + +Playwright Test is a full-featured test runner built for end-to-end testing. It runs tests across Chromium, Firefox, and WebKit with full browser isolation, auto-waiting, and web-first assertions. + +### Install + +```bash +npm init playwright@latest +``` + +Or add manually: + +```bash +npm i -D @playwright/test +npx playwright install +``` + +### Write a test + +```TypeScript +import { test, expect } from '@playwright/test'; + +test('has title', async ({ page }) => { + await page.goto('https://playwright.dev/'); + await expect(page).toHaveTitle(/Playwright/); +}); + +test('get started link', async ({ page }) => { + await page.goto('https://playwright.dev/'); + await page.getByRole('link', { name: 'Get started' }).click(); + await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); +}); +``` + +### Run tests + +```bash +npx playwright test +``` + +Tests run in parallel across all configured browsers, in headless mode by default. Each test gets a fresh browser context — full isolation with near-zero overhead. + +### Key capabilities + +**Auto-wait and web-first assertions.** No artificial timeouts. Playwright waits for elements to be actionable, and assertions automatically retry until conditions are met. + +**Locators.** Find elements with resilient locators that mirror how users see the page: + +```TypeScript +page.getByRole('button', { name: 'Submit' }) +page.getByLabel('Email') +page.getByPlaceholder('Search...') +page.getByTestId('login-form') +``` + +**Test isolation.** Each test runs in its own browser context — equivalent to a fresh browser profile. Save authentication state once and reuse it across tests: + +```TypeScript +// Save state after login +await page.context().storageState({ path: 'auth.json' }); + +// Reuse in other tests +test.use({ storageState: 'auth.json' }); +``` + +**Tracing.** Capture execution traces, screenshots, and videos on failure. Inspect every action, DOM snapshot, network request, and console message in the [Trace Viewer](https://playwright.dev/docs/trace-viewer): + +```TypeScript +// playwright.config.ts +export default defineConfig({ + use: { + trace: 'on-first-retry', + }, +}); +``` + +```bash +npx playwright show-trace trace.zip +``` + + + +**Parallelism.** Tests run in parallel by default across all configured browsers. + +[Full testing documentation](https://playwright.dev/docs/intro) + +--- + +## Playwright CLI + +[Playwright CLI](https://github.com/microsoft/playwright-cli) is a command-line interface for browser automation designed for coding agents. It's more token-efficient than MCP — commands avoid loading large tool schemas and accessibility trees into the model context. + +### Install + +```bash +npm install -g @playwright/cli@latest +``` + +Optionally install skills for richer agent integration: + +```bash +playwright-cli install --skills +``` + +### Usage + +Point your coding agent at a task: + +``` +Test the "add todo" flow on https://demo.playwright.dev/todomvc using playwright-cli. +Take screenshots for all successful and failing scenarios. +``` + +Or run commands directly: + +```bash +playwright-cli open https://demo.playwright.dev/todomvc/ --headed +playwright-cli type "Buy groceries" +playwright-cli press Enter +playwright-cli screenshot +``` + +### Session monitoring + +Use `playwright-cli show` to open a visual dashboard with live screencast previews of all running browser sessions. Click any session to zoom in and take remote control. + +```bash +playwright-cli show +``` + + + +[Full CLI documentation](https://playwright.dev/agent-cli/introduction) | [GitHub](https://github.com/microsoft/playwright-cli) + +--- + +## Playwright MCP + +The [Playwright MCP server](https://github.com/microsoft/playwright-mcp) gives AI agents full browser control through the [Model Context Protocol](https://modelcontextprotocol.io). Agents interact with pages using structured accessibility snapshots — no vision models or screenshots required. + +### Setup + +Add to your MCP client (VS Code, Cursor, Claude Desktop, Windsurf, etc.): + +```json +{ + "mcpServers": { + "playwright": { + "command": "npx", + "args": ["@playwright/mcp@latest"] + } + } +} +``` + +**One-click install for VS Code:** + +[Install in VS Code](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522playwright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D) + +**For Claude Code:** + +```bash +claude mcp add playwright npx @playwright/mcp@latest +``` + +### How it works + +Ask your AI assistant to interact with any web page: + +``` +Navigate to https://demo.playwright.dev/todomvc and add a few todo items. +``` + +The agent sees the page as a structured accessibility tree: + +``` +- heading "todos" [level=1] +- textbox "What needs to be done?" [ref=e5] +- listitem: + - checkbox "Toggle Todo" [ref=e10] + - text: "Buy groceries" +``` + +It uses element refs like `e5` and `e10` to click, type, and interact — deterministically and without visual ambiguity. Tools cover navigation, form filling, screenshots, network mocking, storage management, and more. + +[Full MCP documentation](https://playwright.dev/mcp/introduction) | [GitHub](https://github.com/microsoft/playwright-mcp) + +--- + +## Playwright Library + +Use `playwright` as a library for browser automation scripts — web scraping, PDF generation, screenshot capture, and any workflow that needs programmatic browser control without a test runner. + +### Install + +```bash +npm i playwright +``` + +### Examples + +**Take a screenshot:** + +```TypeScript +import { chromium } from 'playwright'; + +const browser = await chromium.launch(); +const page = await browser.newPage(); +await page.goto('https://playwright.dev/'); +await page.screenshot({ path: 'screenshot.png' }); +await browser.close(); +``` + +**Generate a PDF:** + +```TypeScript +import { chromium } from 'playwright'; + +const browser = await chromium.launch(); +const page = await browser.newPage(); +await page.goto('https://playwright.dev/'); +await page.pdf({ path: 'page.pdf', format: 'A4' }); +await browser.close(); +``` + +**Emulate a mobile device:** + +```TypeScript +import { chromium, devices } from 'playwright'; + +const browser = await chromium.launch(); +const context = await browser.newContext(devices['iPhone 15']); +const page = await context.newPage(); +await page.goto('https://playwright.dev/'); +await page.screenshot({ path: 'mobile.png' }); +await browser.close(); +``` + +**Intercept network requests:** + +```TypeScript +import { chromium } from 'playwright'; + +const browser = await chromium.launch(); +const page = await browser.newPage(); +await page.route('**/*.{png,jpg,jpeg}', route => route.abort()); +await page.goto('https://playwright.dev/'); +await browser.close(); +``` + +[Library documentation](https://playwright.dev/docs/library) | [API reference](https://playwright.dev/docs/api/class-playwright) + +--- + +## VS Code Extension + +The [Playwright VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) brings test running, debugging, and code generation directly into your editor. + + + +**Run and debug tests** from the editor with a single click. Set breakpoints, inspect variables, and step through test execution with a live browser view. + +**Generate tests with CodeGen.** Click "Record new" to open a browser — navigate and interact with your app while Playwright writes the test code for you. + +**Pick locators.** Hover over any element in the browser to see the best available locator, then click to copy it to your clipboard. + +**Trace Viewer integration.** Enable "Show Trace Viewer" in the sidebar to get a full execution trace after each test run — DOM snapshots, network requests, console logs, and screenshots at every step. + +[Install the extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) | [VS Code guide](https://playwright.dev/docs/getting-started-vscode) + +--- + +## Cross-Browser Support + +| | Linux | macOS | Windows | +| :--- | :---: | :---: | :---: | +| Chromium1 149.0.7827.55 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| WebKit 26.5 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Firefox 151.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | + +Headless and headed execution on all platforms. 1 Uses [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing) by default. + +## Other Languages + +Playwright is also available for [Python](https://playwright.dev/python/docs/intro), [.NET](https://playwright.dev/dotnet/docs/intro), and [Java](https://playwright.dev/java/docs/intro). + +## Resources + +* [Documentation](https://playwright.dev) +* [API reference](https://playwright.dev/docs/api/class-playwright) +* [MCP server](https://github.com/microsoft/playwright-mcp) +* [CLI for coding agents](https://github.com/microsoft/playwright-cli) +* [VS Code extension](https://github.com/microsoft/playwright-vscode) +* [Contribution guide](CONTRIBUTING.md) +* [Changelog](https://github.com/microsoft/playwright/releases) +* [Discord](https://aka.ms/playwright/discord) diff --git a/node_modules/@playwright/test/cli.js b/node_modules/@playwright/test/cli.js new file mode 100644 index 0000000000000000000000000000000000000000..e42facb076f4b05f009186346d05d39c2d9b784d --- /dev/null +++ b/node_modules/@playwright/test/cli.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const { program } = require('playwright/lib/program'); +program.parse(process.argv); diff --git a/node_modules/@playwright/test/index.d.ts b/node_modules/@playwright/test/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8d99c91500c65b4b9d762b900dedf5e6000cf257 --- /dev/null +++ b/node_modules/@playwright/test/index.d.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from 'playwright/test'; +export { default } from 'playwright/test'; diff --git a/node_modules/@playwright/test/index.js b/node_modules/@playwright/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8536f063904ffa04a91240061ce1cf2c4c855b79 --- /dev/null +++ b/node_modules/@playwright/test/index.js @@ -0,0 +1,17 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module.exports = require('playwright/test'); diff --git a/node_modules/@playwright/test/index.mjs b/node_modules/@playwright/test/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8d99c91500c65b4b9d762b900dedf5e6000cf257 --- /dev/null +++ b/node_modules/@playwright/test/index.mjs @@ -0,0 +1,18 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from 'playwright/test'; +export { default } from 'playwright/test'; diff --git a/node_modules/@playwright/test/package.json b/node_modules/@playwright/test/package.json new file mode 100644 index 0000000000000000000000000000000000000000..16ee688abb92e6a2d4796d6a1d9cab9ed4aa0064 --- /dev/null +++ b/node_modules/@playwright/test/package.json @@ -0,0 +1,35 @@ +{ + "name": "@playwright/test", + "version": "1.61.0", + "description": "A high-level API to automate web browsers", + "repository": { + "type": "git", + "url": "git+https://github.com/microsoft/playwright.git" + }, + "homepage": "https://playwright.dev", + "engines": { + "node": ">=18" + }, + "author": { + "name": "Microsoft Corporation" + }, + "license": "Apache-2.0", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./index.mjs", + "require": "./index.js", + "default": "./index.js" + }, + "./cli": "./cli.js", + "./package.json": "./package.json", + "./reporter": "./reporter.js" + }, + "bin": { + "playwright": "cli.js" + }, + "scripts": {}, + "dependencies": { + "playwright": "1.61.0" + } +} diff --git a/node_modules/@playwright/test/reporter.d.ts b/node_modules/@playwright/test/reporter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..806d13fb09e73f0dc1f4e129a2889b9e6bac3a8d --- /dev/null +++ b/node_modules/@playwright/test/reporter.d.ts @@ -0,0 +1,17 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from 'playwright/types/testReporter'; diff --git a/node_modules/@playwright/test/reporter.js b/node_modules/@playwright/test/reporter.js new file mode 100644 index 0000000000000000000000000000000000000000..485e880a66229eb7290fd274e35b8acf4a4a8ecd --- /dev/null +++ b/node_modules/@playwright/test/reporter.js @@ -0,0 +1,17 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// We only export types in reporter.d.ts. diff --git a/node_modules/@playwright/test/reporter.mjs b/node_modules/@playwright/test/reporter.mjs new file mode 100644 index 0000000000000000000000000000000000000000..485e880a66229eb7290fd274e35b8acf4a4a8ecd --- /dev/null +++ b/node_modules/@playwright/test/reporter.mjs @@ -0,0 +1,17 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// We only export types in reporter.d.ts. diff --git a/node_modules/@quansync/fs/LICENSE b/node_modules/@quansync/fs/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..8701f9fe69eb9e01d8a4ade1c51bc5b8a4a7e315 --- /dev/null +++ b/node_modules/@quansync/fs/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright © 2025-PRESENT Kevin Deng (https://github.com/sxzz) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@quansync/fs/README.md b/node_modules/@quansync/fs/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a69b4cca3391b00a8259a3618697c90f276d43cc --- /dev/null +++ b/node_modules/@quansync/fs/README.md @@ -0,0 +1,50 @@ +# @quansync/fs + +[![npm version][npm-version-src]][npm-version-href] +[![npm downloads][npm-downloads-src]][npm-downloads-href] +[![Unit Test][unit-test-src]][unit-test-href] + +Filesystem utilities for [quansync](https://github.com/quansync-dev/quansync). + +## Install + +```bash +npm i @quansync/fs +``` + +## Usage + +```ts +import { readFile } from '@quansync/fs' +import { quansync } from 'quansync' + +const resultAsync = await readFile('/path', 'utf8') +const resultSync = readFile.sync('/path', 'utf8') + +const readFileTrimmed = quansync(function* (id: string) { + const text = yield* readFile(id, 'utf8').trim() + return text +}) +const readFileTrimmedSync = readFileTrimmed.sync +``` + +## Sponsors + +

+ + + +

+ +## License + +[MIT](./LICENSE) License © 2025-PRESENT [Kevin Deng](https://github.com/sxzz) + + + +[npm-version-src]: https://img.shields.io/npm/v/@quansync/fs.svg +[npm-version-href]: https://npmjs.com/package/@quansync/fs +[npm-downloads-src]: https://img.shields.io/npm/dm/@quansync/fs +[npm-downloads-href]: https://www.npmcharts.com/compare/@quansync/fs?interval=30 +[unit-test-src]: https://github.com/quansync-dev/fs/actions/workflows/unit-test.yml/badge.svg +[unit-test-href]: https://github.com/quansync-dev/fs/actions/workflows/unit-test.yml diff --git a/node_modules/@quansync/fs/package.json b/node_modules/@quansync/fs/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b30200071601bdb7159fef5536d077d5799231bd --- /dev/null +++ b/node_modules/@quansync/fs/package.json @@ -0,0 +1,57 @@ +{ + "name": "@quansync/fs", + "type": "module", + "version": "1.0.0", + "description": "Filesystem utilities for Quansync", + "author": "Kevin Deng ", + "license": "MIT", + "funding": "https://github.com/sponsors/sxzz", + "homepage": "https://github.com/quansync-dev/fs#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/quansync-dev/fs.git" + }, + "bugs": { + "url": "https://github.com/quansync-dev/fs/issues" + }, + "exports": { + ".": "./dist/index.mjs", + "./package.json": "./package.json" + }, + "main": "./dist/index.mjs", + "module": "./dist/index.mjs", + "types": "./dist/index.d.mts", + "files": [ + "dist" + ], + "publishConfig": { + "access": "public" + }, + "dependencies": { + "quansync": "^1.0.0" + }, + "devDependencies": { + "@sxzz/eslint-config": "^7.4.1", + "@sxzz/prettier-config": "^2.2.6", + "@types/node": "^24.10.1", + "@typescript/native-preview": "7.0.0-dev.20251202.1", + "bumpp": "^10.3.2", + "eslint": "^9.39.1", + "prettier": "^3.7.3", + "tsdown": "^0.17.0-beta.5", + "tsx": "^4.21.0", + "typescript": "^5.9.3", + "vitest": "^4.0.15" + }, + "prettier": "@sxzz/prettier-config", + "scripts": { + "lint": "eslint --cache .", + "lint:fix": "pnpm run lint --fix", + "build": "tsdown", + "dev": "tsdown --watch", + "test": "vitest", + "typecheck": "tsgo --noEmit", + "format": "prettier --cache --write .", + "release": "bumpp" + } +} \ No newline at end of file diff --git a/node_modules/@react-leaflet/core/LICENSE.md b/node_modules/@react-leaflet/core/LICENSE.md new file mode 100644 index 0000000000000000000000000000000000000000..e5faf9677f27ef9af91233bb813504ff3f6a9107 --- /dev/null +++ b/node_modules/@react-leaflet/core/LICENSE.md @@ -0,0 +1,33 @@ +@react-leaflet/core Copyright 2020 Paul Le Cam and contributors (“Licensor”) + +Hippocratic License Version Number: 2.1. + +Purpose. The purpose of this License is for the Licensor named above to permit the Licensee (as defined below) broad permission, if consistent with Human Rights Laws and Human Rights Principles (as each is defined below), to use and work with the Software (as defined below) within the full scope of Licensor’s copyright and patent rights, if any, in the Software, while ensuring attribution and protecting the Licensor from liability. + +Permission and Conditions. The Licensor grants permission by this license (“License”), free of charge, to the extent of Licensor’s rights under applicable copyright and patent law, to any person or entity (the “Licensee”) obtaining a copy of this software and associated documentation files (the “Software”), to do everything with the Software that would otherwise infringe (i) the Licensor’s copyright in the Software or (ii) any patent claims to the Software that the Licensor can license or becomes able to license, subject to all of the following terms and conditions: + +- Acceptance. This License is automatically offered to every person and entity subject to its terms and conditions. Licensee accepts this License and agrees to its terms and conditions by taking any action with the Software that, absent this License, would infringe any intellectual property right held by Licensor. + +- Notice. Licensee must ensure that everyone who gets a copy of any part of this Software from Licensee, with or without changes, also receives the License and the above copyright notice (and if included by the Licensor, patent, trademark and attribution notice). Licensee must cause any modified versions of the Software to carry prominent notices stating that Licensee changed the Software. For clarity, although Licensee is free to create modifications of the Software and distribute only the modified portion created by Licensee with additional or different terms, the portion of the Software not modified must be distributed pursuant to this License. If anyone notifies Licensee in writing that Licensee has not complied with this Notice section, Licensee can keep this License by taking all practical steps to comply within 30 days after the notice. If Licensee does not do so, Licensee’s License (and all rights licensed hereunder) shall end immediately. + +- Compliance with Human Rights Principles and Human Rights Laws. + + 1. Human Rights Principles. + + (a) Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights and the United Nations Global Compact that define recognized principles of international human rights (the “Human Rights Principles”). Licensee shall use the Software in a manner consistent with Human Rights Principles. + + (b) Unless the Licensor and Licensee agree otherwise, any dispute, controversy, or claim arising out of or relating to (i) Section 1(a) regarding Human Rights Principles, including the breach of Section 1(a), termination of this License for breach of the Human Rights Principles, or invalidity of Section 1(a) or (ii) a determination of whether any Law is consistent or in conflict with Human Rights Principles pursuant to Section 2, below, shall be settled by arbitration in accordance with the Hague Rules on Business and Human Rights Arbitration (the “Rules”); provided, however, that Licensee may elect not to participate in such arbitration, in which event this License (and all rights licensed hereunder) shall end immediately. The number of arbitrators shall be one unless the Rules require otherwise. + + Unless both the Licensor and Licensee agree to the contrary: (1) All documents and information concerning the arbitration shall be public and may be disclosed by any party; (2) The repository referred to under Article 43 of the Rules shall make available to the public in a timely manner all documents concerning the arbitration which are communicated to it, including all submissions of the parties, all evidence admitted into the record of the proceedings, all transcripts or other recordings of hearings and all orders, decisions and awards of the arbitral tribunal, subject only to the arbitral tribunal's powers to take such measures as may be necessary to safeguard the integrity of the arbitral process pursuant to Articles 18, 33, 41 and 42 of the Rules; and (3) Article 26(6) of the Rules shall not apply. + + 2. Human Rights Laws. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any Human Rights Laws. “Human Rights Laws” means any applicable laws, regulations, or rules (collectively, “Laws”) that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights; provided, however, that such Laws are consistent and not in conflict with Human Rights Principles (a dispute over the consistency or a conflict between Laws and Human Rights Principles shall be determined by arbitration as stated above). Where the Human Rights Laws of more than one jurisdiction are applicable or in conflict with respect to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply. + + 3. Indemnity. Licensee shall hold harmless and indemnify Licensor (and any other contributor) against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensor’s reasonable attorneys’ fees, arising out of or relating to Licensee’s use of the Software in violation of Human Rights Laws or Human Rights Principles. + +- Failure to Comply. Any failure of Licensee to act according to the terms and conditions of this License is both a breach of the License and an infringement of the intellectual property rights of the Licensor (subject to exceptions under Laws, e.g., fair use). In the event of a breach or infringement, the terms and conditions of this License may be enforced by Licensor under the Laws of any jurisdiction to which Licensee is subject. Licensee also agrees that the Licensor may enforce the terms and conditions of this License against Licensee through specific performance (or similar remedy under Laws) to the extent permitted by Laws. For clarity, except in the event of a breach of this License, infringement, or as otherwise stated in this License, Licensor may not terminate this License with Licensee. + +- Enforceability and Interpretation. If any term or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction; provided, however, subject to a court modification pursuant to the immediately following sentence, if any term or provision of this License pertaining to Human Rights Laws or Human Rights Principles is deemed invalid, illegal, or unenforceable against Licensee by a court of competent jurisdiction, all rights in the Software granted to Licensee shall be deemed null and void as between Licensor and Licensee. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by Laws, the court may modify this License to affect the original purpose that the Software be used in compliance with Human Rights Principles and Human Rights Laws as closely as possible. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party. + +- Disclaimer. TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES “AS IS,” WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR AND ANY OTHER CONTRIBUTOR SHALL NOT BE LIABLE TO ANYONE FOR ANY DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY KIND OF LEGAL CLAIM. + +This Hippocratic License is an Ethical Source license (https://ethicalsource.dev) and is offered for use by licensors and licensees at their own risk, on an “AS IS” basis, and with no warranties express or implied, to the maximum extent permitted by Laws. diff --git a/node_modules/@react-leaflet/core/README.md b/node_modules/@react-leaflet/core/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2c689b302b33eb26d679e5938e6ba44315779bd1 --- /dev/null +++ b/node_modules/@react-leaflet/core/README.md @@ -0,0 +1,3 @@ +# React Leaflet core + +[Documentation](https://react-leaflet.js.org/docs/core-introduction) diff --git a/node_modules/@react-leaflet/core/lib/attribution.d.ts b/node_modules/@react-leaflet/core/lib/attribution.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..61bb09bcb55565fb77468f03187726b48b4a844d --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/attribution.d.ts @@ -0,0 +1,2 @@ +import type { Map as LeafletMap } from 'leaflet'; +export declare function useAttribution(map: LeafletMap, attribution: string | null | undefined): void; diff --git a/node_modules/@react-leaflet/core/lib/attribution.js b/node_modules/@react-leaflet/core/lib/attribution.js new file mode 100644 index 0000000000000000000000000000000000000000..bce46abd6557c2b2d27b2b529500e78d5e9c10c5 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/attribution.js @@ -0,0 +1,18 @@ +import { useEffect, useRef } from 'react'; +export function useAttribution(map, attribution) { + const attributionRef = useRef(attribution); + useEffect(function updateAttribution() { + if (attribution !== attributionRef.current && map.attributionControl != null) { + if (attributionRef.current != null) { + map.attributionControl.removeAttribution(attributionRef.current); + } + if (attribution != null) { + map.attributionControl.addAttribution(attribution); + } + } + attributionRef.current = attribution; + }, [ + map, + attribution + ]); +} diff --git a/node_modules/@react-leaflet/core/lib/circle.d.ts b/node_modules/@react-leaflet/core/lib/circle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4d56c55a412e48c60d106008b4ab3f6a3836f5b --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/circle.d.ts @@ -0,0 +1,12 @@ +import type { CircleMarkerOptions, CircleOptions, LatLngExpression, Circle as LeafletCircle, CircleMarker as LeafletCircleMarker } from 'leaflet'; +import type { ReactNode } from 'react'; +import type { PathProps } from './path.js'; +export interface CircleMarkerProps extends CircleMarkerOptions, PathProps { + center: LatLngExpression; + children?: ReactNode; +} +export interface CircleProps extends CircleOptions, PathProps { + center: LatLngExpression; + children?: ReactNode; +} +export declare function updateCircle

(layer: LeafletCircle

| LeafletCircleMarker

, props: P, prevProps: P): void; diff --git a/node_modules/@react-leaflet/core/lib/circle.js b/node_modules/@react-leaflet/core/lib/circle.js new file mode 100644 index 0000000000000000000000000000000000000000..f5e20aeb072e0fc3fbe02b70e9381c763cc98da0 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/circle.js @@ -0,0 +1,8 @@ +export function updateCircle(layer, props, prevProps) { + if (props.center !== prevProps.center) { + layer.setLatLng(props.center); + } + if (props.radius != null && props.radius !== prevProps.radius) { + layer.setRadius(props.radius); + } +} diff --git a/node_modules/@react-leaflet/core/lib/component.d.ts b/node_modules/@react-leaflet/core/lib/component.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0869fdd19060d2f40717febf17c900df72a16ac --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/component.d.ts @@ -0,0 +1,11 @@ +import React, { type PropsWithoutRef, type RefObject, type ReactNode } from 'react'; +import type { DivOverlay, DivOverlayHook } from './div-overlay.js'; +import type { LeafletElement } from './element.js'; +type ElementHook = (props: P) => RefObject>; +export type PropsWithChildren = PropsWithoutRef<{ + children?: ReactNode; +}>; +export declare function createContainerComponent(useElement: ElementHook>): React.ForwardRefExoticComponent & React.RefAttributes>; +export declare function createDivOverlayComponent(useElement: ReturnType>>): React.ForwardRefExoticComponent & React.RefAttributes>; +export declare function createLeafComponent(useElement: ElementHook>): React.ForwardRefExoticComponent & React.RefAttributes>; +export {}; diff --git a/node_modules/@react-leaflet/core/lib/component.js b/node_modules/@react-leaflet/core/lib/component.js new file mode 100644 index 0000000000000000000000000000000000000000..d1cc750ce372bf99ae5bd10617b14082df619db0 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/component.js @@ -0,0 +1,43 @@ +import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react'; +import { createPortal } from 'react-dom'; +import { LeafletContext } from './context.js'; +export function createContainerComponent(useElement) { + function ContainerComponent(props, forwardedRef) { + const { instance, context } = useElement(props).current; + useImperativeHandle(forwardedRef, ()=>instance); + const { children } = props; + return children == null ? null : /*#__PURE__*/ React.createElement(LeafletContext, { + value: context + }, children); + } + return /*#__PURE__*/ forwardRef(ContainerComponent); +} +export function createDivOverlayComponent(useElement) { + function OverlayComponent(props, forwardedRef) { + const [isOpen, setOpen] = useState(false); + const { instance } = useElement(props, setOpen).current; + useImperativeHandle(forwardedRef, ()=>instance); + // biome-ignore lint/correctness/useExhaustiveDependencies: update overlay when children change + useEffect(function updateOverlay() { + if (isOpen) { + instance.update(); + } + }, [ + instance, + isOpen, + props.children + ]); + // @ts-ignore _contentNode missing in type definition + const contentNode = instance._contentNode; + return contentNode ? /*#__PURE__*/ createPortal(props.children, contentNode) : null; + } + return /*#__PURE__*/ forwardRef(OverlayComponent); +} +export function createLeafComponent(useElement) { + function LeafComponent(props, forwardedRef) { + const { instance } = useElement(props).current; + useImperativeHandle(forwardedRef, ()=>instance); + return null; + } + return /*#__PURE__*/ forwardRef(LeafComponent); +} diff --git a/node_modules/@react-leaflet/core/lib/context.d.ts b/node_modules/@react-leaflet/core/lib/context.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..55cc089b5ed9b61988dbd7734ccb2e156a23ea68 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/context.d.ts @@ -0,0 +1,25 @@ +import type { Control, Layer, LayerGroup, Map as LeafletMap } from 'leaflet'; +export declare const CONTEXT_VERSION = 1; +export type ControlledLayer = { + addLayer(layer: Layer): void; + removeLayer(layer: Layer): void; +}; +export type LeafletContextInterface = Readonly<{ + __version: number; + map: LeafletMap; + layerContainer?: ControlledLayer | LayerGroup; + layersControl?: Control.Layers; + overlayContainer?: Layer; + pane?: string; +}>; +export declare function createLeafletContext(map: LeafletMap): LeafletContextInterface; +export declare function extendContext(source: LeafletContextInterface, extra: Partial): LeafletContextInterface; +export declare const LeafletContext: import("react").Context | null>; +export declare function useLeafletContext(): LeafletContextInterface; diff --git a/node_modules/@react-leaflet/core/lib/context.js b/node_modules/@react-leaflet/core/lib/context.js new file mode 100644 index 0000000000000000000000000000000000000000..9fc6a2c6124b0b27795ba290fa8908298a53f415 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/context.js @@ -0,0 +1,22 @@ +import { createContext, use } from 'react'; +export const CONTEXT_VERSION = 1; +export function createLeafletContext(map) { + return Object.freeze({ + __version: CONTEXT_VERSION, + map + }); +} +export function extendContext(source, extra) { + return Object.freeze({ + ...source, + ...extra + }); +} +export const LeafletContext = createContext(null); +export function useLeafletContext() { + const context = use(LeafletContext); + if (context == null) { + throw new Error('No context provided: useLeafletContext() can only be used in a descendant of '); + } + return context; +} diff --git a/node_modules/@react-leaflet/core/lib/control.d.ts b/node_modules/@react-leaflet/core/lib/control.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa7d5987504ece6017ad9de4007839597073eb3d --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/control.d.ts @@ -0,0 +1,3 @@ +import type { Control, ControlOptions } from 'leaflet'; +import type { ElementHook } from './element.js'; +export declare function createControlHook(useElement: ElementHook): (props: P) => ReturnType>; diff --git a/node_modules/@react-leaflet/core/lib/control.js b/node_modules/@react-leaflet/core/lib/control.js new file mode 100644 index 0000000000000000000000000000000000000000..7e798e3cfba95fa47d03ac738dc0b198baf12683 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/control.js @@ -0,0 +1,30 @@ +import { useEffect, useRef } from 'react'; +import { useLeafletContext } from './context.js'; +export function createControlHook(useElement) { + return function useLeafletControl(props) { + const context = useLeafletContext(); + const elementRef = useElement(props, context); + const { instance } = elementRef.current; + const positionRef = useRef(props.position); + const { position } = props; + useEffect(function addControl() { + instance.addTo(context.map); + return function removeControl() { + instance.remove(); + }; + }, [ + context.map, + instance + ]); + useEffect(function updateControl() { + if (position != null && position !== positionRef.current) { + instance.setPosition(position); + positionRef.current = position; + } + }, [ + instance, + position + ]); + return elementRef; + }; +} diff --git a/node_modules/@react-leaflet/core/lib/div-overlay.d.ts b/node_modules/@react-leaflet/core/lib/div-overlay.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a05e3072717b84a61e9a7e0f070fcd2836d15b8e --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/div-overlay.d.ts @@ -0,0 +1,9 @@ +import type { Popup, Tooltip } from 'leaflet'; +import { type LeafletContextInterface } from './context.js'; +import type { ElementHook, LeafletElement } from './element.js'; +import type { LayerProps } from './layer.js'; +export type DivOverlay = Popup | Tooltip; +export type SetOpenFunc = (open: boolean) => void; +export type DivOverlayLifecycleHook = (element: LeafletElement, context: LeafletContextInterface, props: P, setOpen: SetOpenFunc) => void; +export type DivOverlayHook = (useElement: ElementHook, useLifecycle: DivOverlayLifecycleHook) => (props: P, setOpen: SetOpenFunc) => ReturnType>; +export declare function createDivOverlayHook(useElement: ElementHook, useLifecycle: DivOverlayLifecycleHook): (props: P, setOpen: SetOpenFunc) => ReturnType>; diff --git a/node_modules/@react-leaflet/core/lib/div-overlay.js b/node_modules/@react-leaflet/core/lib/div-overlay.js new file mode 100644 index 0000000000000000000000000000000000000000..965951131bc6a452cea3cebf4609b56d629bf7d1 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/div-overlay.js @@ -0,0 +1,14 @@ +import { useAttribution } from './attribution.js'; +import { useLeafletContext } from './context.js'; +import { useEventHandlers } from './events.js'; +import { withPane } from './pane.js'; +export function createDivOverlayHook(useElement, useLifecycle) { + return function useDivOverlay(props, setOpen) { + const context = useLeafletContext(); + const elementRef = useElement(withPane(props, context), context); + useAttribution(context.map, props.attribution); + useEventHandlers(elementRef.current, props.eventHandlers); + useLifecycle(elementRef.current, context, props, setOpen); + return elementRef; + }; +} diff --git a/node_modules/@react-leaflet/core/lib/dom.d.ts b/node_modules/@react-leaflet/core/lib/dom.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..25a720f986307ed52678d8f86756aac2644003c1 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/dom.d.ts @@ -0,0 +1,3 @@ +export declare function addClassName(element: HTMLElement, className: string): void; +export declare function removeClassName(element: HTMLElement, className: string): void; +export declare function updateClassName(element?: HTMLElement, prevClassName?: string, nextClassName?: string): void; diff --git a/node_modules/@react-leaflet/core/lib/dom.js b/node_modules/@react-leaflet/core/lib/dom.js new file mode 100644 index 0000000000000000000000000000000000000000..2a29092213eb4832425bdd794dcb2f5cf6cce1dd --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/dom.js @@ -0,0 +1,24 @@ +import { DomUtil } from 'leaflet'; +function splitClassName(className) { + return className.split(' ').filter(Boolean); +} +export function addClassName(element, className) { + for (const cls of splitClassName(className)){ + DomUtil.addClass(element, cls); + } +} +export function removeClassName(element, className) { + for (const cls of splitClassName(className)){ + DomUtil.removeClass(element, cls); + } +} +export function updateClassName(element, prevClassName, nextClassName) { + if (element != null && nextClassName !== prevClassName) { + if (prevClassName != null && prevClassName.length > 0) { + removeClassName(element, prevClassName); + } + if (nextClassName != null && nextClassName.length > 0) { + addClassName(element, nextClassName); + } + } +} diff --git a/node_modules/@react-leaflet/core/lib/element.d.ts b/node_modules/@react-leaflet/core/lib/element.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6e55fb8e7e94c28248c7158d2c5c1a5ff25c353a --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/element.d.ts @@ -0,0 +1,10 @@ +import { type RefObject } from 'react'; +import type { LeafletContextInterface } from './context.js'; +export type LeafletElement = Readonly<{ + instance: T; + context: LeafletContextInterface; + container?: C | null; +}>; +export declare function createElementObject(instance: T, context: LeafletContextInterface, container?: C | null): LeafletElement; +export type ElementHook = (props: P, context: LeafletContextInterface) => RefObject>; +export declare function createElementHook(createElement: (props: P, context: LeafletContextInterface) => LeafletElement, updateElement?: (instance: E, props: P, prevProps: P) => void): (props: P, context: LeafletContextInterface) => ReturnType>; diff --git a/node_modules/@react-leaflet/core/lib/element.js b/node_modules/@react-leaflet/core/lib/element.js new file mode 100644 index 0000000000000000000000000000000000000000..5a1088301ce0f1b23c9b7bb3189e73488c7cd56e --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/element.js @@ -0,0 +1,34 @@ +import { useEffect, useRef } from 'react'; +export function createElementObject(instance, context, container) { + return Object.freeze({ + instance, + context, + container + }); +} +export function createElementHook(createElement, updateElement) { + if (updateElement == null) { + return function useImmutableLeafletElement(props, context) { + const elementRef = useRef(undefined); + if (!elementRef.current) elementRef.current = createElement(props, context); + return elementRef; + }; + } + return function useMutableLeafletElement(props, context) { + const elementRef = useRef(undefined); + if (!elementRef.current) elementRef.current = createElement(props, context); + const propsRef = useRef(props); + const { instance } = elementRef.current; + useEffect(function updateElementProps() { + if (propsRef.current !== props) { + updateElement(instance, props, propsRef.current); + propsRef.current = props; + } + }, [ + instance, + props, + updateElement + ]); + return elementRef; + }; +} diff --git a/node_modules/@react-leaflet/core/lib/events.d.ts b/node_modules/@react-leaflet/core/lib/events.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba8f4310da23171a6de2a7df945cef63319a1806 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/events.d.ts @@ -0,0 +1,6 @@ +import type { Evented, LeafletEventHandlerFnMap } from 'leaflet'; +import type { LeafletElement } from './element.js'; +export type EventedProps = { + eventHandlers?: LeafletEventHandlerFnMap; +}; +export declare function useEventHandlers(element: LeafletElement, eventHandlers: LeafletEventHandlerFnMap | null | undefined): void; diff --git a/node_modules/@react-leaflet/core/lib/events.js b/node_modules/@react-leaflet/core/lib/events.js new file mode 100644 index 0000000000000000000000000000000000000000..77eea9fde209785b5560b856f4f1bf5ded9a4ed6 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/events.js @@ -0,0 +1,19 @@ +import { useEffect, useRef } from 'react'; +export function useEventHandlers(element, eventHandlers) { + const eventHandlersRef = useRef(undefined); + useEffect(function addEventHandlers() { + if (eventHandlers != null) { + element.instance.on(eventHandlers); + } + eventHandlersRef.current = eventHandlers; + return function removeEventHandlers() { + if (eventHandlersRef.current != null) { + element.instance.off(eventHandlersRef.current); + } + eventHandlersRef.current = null; + }; + }, [ + element, + eventHandlers + ]); +} diff --git a/node_modules/@react-leaflet/core/lib/generic.d.ts b/node_modules/@react-leaflet/core/lib/generic.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7dec7823afa6289ddeca104cff83d3ffcb48c111 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/generic.d.ts @@ -0,0 +1,18 @@ +import type { Control, ControlOptions, FeatureGroup, Layer, Path } from 'leaflet'; +import type { PropsWithoutRef } from 'react'; +import { type PropsWithChildren } from './component.js'; +import type { LeafletContextInterface } from './context.js'; +import { type DivOverlay, type DivOverlayLifecycleHook } from './div-overlay.js'; +import { type LeafletElement } from './element.js'; +import { type LayerProps } from './layer.js'; +import { type PathProps } from './path.js'; +interface LayerWithChildrenProps extends LayerProps, PropsWithChildren { +} +interface PathWithChildrenProps extends PathProps, PropsWithChildren { +} +export declare function createControlComponent(createInstance: (props: PropsWithoutRef

) => E): import("react").ForwardRefExoticComponent & import("react").RefAttributes>; +export declare function createLayerComponent(createElement: (props: PropsWithoutRef

, context: LeafletContextInterface) => LeafletElement, updateElement?: (instance: E, props: PropsWithoutRef

, prevProps: PropsWithoutRef

) => void): import("react").ForwardRefExoticComponent & import("react").RefAttributes>; +export declare function createOverlayComponent(createElement: (props: PropsWithoutRef

, context: LeafletContextInterface) => LeafletElement, useLifecycle: DivOverlayLifecycleHook>): import("react").ForwardRefExoticComponent & import("react").RefAttributes>; +export declare function createPathComponent(createElement: (props: PropsWithoutRef

, context: LeafletContextInterface) => LeafletElement, updateElement?: (instance: E, props: PropsWithoutRef

, prevProps: PropsWithoutRef

) => void): import("react").ForwardRefExoticComponent & import("react").RefAttributes>; +export declare function createTileLayerComponent(createElement: (props: PropsWithoutRef

, context: LeafletContextInterface) => LeafletElement, updateElement?: (instance: E, props: PropsWithoutRef

, prevProps: PropsWithoutRef

) => void): import("react").ForwardRefExoticComponent & import("react").RefAttributes>; +export {}; diff --git a/node_modules/@react-leaflet/core/lib/generic.js b/node_modules/@react-leaflet/core/lib/generic.js new file mode 100644 index 0000000000000000000000000000000000000000..f98463eb45456a2c1a4dfa76c37ba77d5f0dc390 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/generic.js @@ -0,0 +1,34 @@ +import { createContainerComponent, createDivOverlayComponent, createLeafComponent } from './component.js'; +import { createControlHook } from './control.js'; +import { createDivOverlayHook } from './div-overlay.js'; +import { createElementHook, createElementObject } from './element.js'; +import { createLayerHook } from './layer.js'; +import { createPathHook } from './path.js'; +export function createControlComponent(createInstance) { + function createElement(props, context) { + return createElementObject(createInstance(props), context); + } + const useElement = createElementHook(createElement); + const useControl = createControlHook(useElement); + return createLeafComponent(useControl); +} +export function createLayerComponent(createElement, updateElement) { + const useElement = createElementHook(createElement, updateElement); + const useLayer = createLayerHook(useElement); + return createContainerComponent(useLayer); +} +export function createOverlayComponent(createElement, useLifecycle) { + const useElement = createElementHook(createElement); + const useOverlay = createDivOverlayHook(useElement, useLifecycle); + return createDivOverlayComponent(useOverlay); +} +export function createPathComponent(createElement, updateElement) { + const useElement = createElementHook(createElement, updateElement); + const usePath = createPathHook(useElement); + return createContainerComponent(usePath); +} +export function createTileLayerComponent(createElement, updateElement) { + const useElement = createElementHook(createElement, updateElement); + const useLayer = createLayerHook(useElement); + return createLeafComponent(useLayer); +} diff --git a/node_modules/@react-leaflet/core/lib/grid-layer.d.ts b/node_modules/@react-leaflet/core/lib/grid-layer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b676e902ed21a4749714e7aa2836a7e7ee60cf8b --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/grid-layer.d.ts @@ -0,0 +1,2 @@ +import type { GridLayer, GridLayerOptions } from 'leaflet'; +export declare function updateGridLayer(layer: E, props: P, prevProps: P): void; diff --git a/node_modules/@react-leaflet/core/lib/grid-layer.js b/node_modules/@react-leaflet/core/lib/grid-layer.js new file mode 100644 index 0000000000000000000000000000000000000000..aa7a08db38022d64887362a6a5246cec6bd95439 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/grid-layer.js @@ -0,0 +1,9 @@ +export function updateGridLayer(layer, props, prevProps) { + const { opacity, zIndex } = props; + if (opacity != null && opacity !== prevProps.opacity) { + layer.setOpacity(opacity); + } + if (zIndex != null && zIndex !== prevProps.zIndex) { + layer.setZIndex(zIndex); + } +} diff --git a/node_modules/@react-leaflet/core/lib/index.d.ts b/node_modules/@react-leaflet/core/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..366bb23d07ff2ea7ed1f61acac09541980989a99 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/index.d.ts @@ -0,0 +1,15 @@ +export { useAttribution } from './attribution.js'; +export { type CircleMarkerProps, type CircleProps, updateCircle, } from './circle.js'; +export { createContainerComponent, createDivOverlayComponent, createLeafComponent, } from './component.js'; +export { CONTEXT_VERSION, type LeafletContextInterface, LeafletContext, createLeafletContext, extendContext, useLeafletContext, } from './context.js'; +export { createControlHook } from './control.js'; +export { type DivOverlayHook, type DivOverlayLifecycleHook, type SetOpenFunc, createDivOverlayHook, } from './div-overlay.js'; +export { addClassName, removeClassName, updateClassName } from './dom.js'; +export { type ElementHook, type LeafletElement, createElementHook, createElementObject, } from './element.js'; +export { type EventedProps, useEventHandlers } from './events.js'; +export { createControlComponent, createLayerComponent, createOverlayComponent, createPathComponent, createTileLayerComponent, } from './generic.js'; +export { updateGridLayer } from './grid-layer.js'; +export { type InteractiveLayerProps, type LayerProps, createLayerHook, useLayerLifecycle, } from './layer.js'; +export { type MediaOverlayProps, updateMediaOverlay } from './media-overlay.js'; +export { withPane } from './pane.js'; +export { type PathProps, createPathHook, usePathOptions } from './path.js'; diff --git a/node_modules/@react-leaflet/core/lib/index.js b/node_modules/@react-leaflet/core/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e174cffc2e83cdbdca09805a8a63f1c6ce26c849 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/index.js @@ -0,0 +1,15 @@ +export { useAttribution } from './attribution.js'; +export { updateCircle } from './circle.js'; +export { createContainerComponent, createDivOverlayComponent, createLeafComponent } from './component.js'; +export { CONTEXT_VERSION, LeafletContext, createLeafletContext, extendContext, useLeafletContext } from './context.js'; +export { createControlHook } from './control.js'; +export { createDivOverlayHook } from './div-overlay.js'; +export { addClassName, removeClassName, updateClassName } from './dom.js'; +export { createElementHook, createElementObject } from './element.js'; +export { useEventHandlers } from './events.js'; +export { createControlComponent, createLayerComponent, createOverlayComponent, createPathComponent, createTileLayerComponent } from './generic.js'; +export { updateGridLayer } from './grid-layer.js'; +export { createLayerHook, useLayerLifecycle } from './layer.js'; +export { updateMediaOverlay } from './media-overlay.js'; +export { withPane } from './pane.js'; +export { createPathHook, usePathOptions } from './path.js'; diff --git a/node_modules/@react-leaflet/core/lib/layer.d.ts b/node_modules/@react-leaflet/core/lib/layer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f508d278445649fcfc294eb4d962b4ad03f594fb --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/layer.d.ts @@ -0,0 +1,10 @@ +import type { InteractiveLayerOptions, Layer, LayerOptions } from 'leaflet'; +import { type LeafletContextInterface } from './context.js'; +import type { ElementHook, LeafletElement } from './element.js'; +import { type EventedProps } from './events.js'; +export interface LayerProps extends EventedProps, LayerOptions { +} +export interface InteractiveLayerProps extends LayerProps, InteractiveLayerOptions { +} +export declare function useLayerLifecycle(element: LeafletElement, context: LeafletContextInterface): void; +export declare function createLayerHook(useElement: ElementHook): (props: P) => ReturnType>; diff --git a/node_modules/@react-leaflet/core/lib/layer.js b/node_modules/@react-leaflet/core/lib/layer.js new file mode 100644 index 0000000000000000000000000000000000000000..6364b3ad25cbd141208e12e09d4d20cfa122a572 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/layer.js @@ -0,0 +1,28 @@ +import { useEffect } from 'react'; +import { useAttribution } from './attribution.js'; +import { useLeafletContext } from './context.js'; +import { useEventHandlers } from './events.js'; +import { withPane } from './pane.js'; +export function useLayerLifecycle(element, context) { + useEffect(function addLayer() { + const container = context.layerContainer ?? context.map; + container.addLayer(element.instance); + return function removeLayer() { + context.layerContainer?.removeLayer(element.instance); + context.map.removeLayer(element.instance); + }; + }, [ + context, + element + ]); +} +export function createLayerHook(useElement) { + return function useLayer(props) { + const context = useLeafletContext(); + const elementRef = useElement(withPane(props, context), context); + useAttribution(context.map, props.attribution); + useEventHandlers(elementRef.current, props.eventHandlers); + useLayerLifecycle(elementRef.current, context); + return elementRef; + }; +} diff --git a/node_modules/@react-leaflet/core/lib/media-overlay.d.ts b/node_modules/@react-leaflet/core/lib/media-overlay.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a1f645a277b0ee13d76939f23fb81a96dcf41c8 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/media-overlay.d.ts @@ -0,0 +1,6 @@ +import { type ImageOverlayOptions, type LatLngBoundsExpression, type ImageOverlay as LeafletImageOverlay, type SVGOverlay as LeafletSVGOverlay, type VideoOverlay as LeafletVideoOverlay } from 'leaflet'; +import type { InteractiveLayerProps } from './layer.js'; +export interface MediaOverlayProps extends ImageOverlayOptions, InteractiveLayerProps { + bounds: LatLngBoundsExpression; +} +export declare function updateMediaOverlay(overlay: E, props: P, prevProps: P): void; diff --git a/node_modules/@react-leaflet/core/lib/media-overlay.js b/node_modules/@react-leaflet/core/lib/media-overlay.js new file mode 100644 index 0000000000000000000000000000000000000000..fc03a12e74b8c5d334de7c948d3d996bb95872ab --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/media-overlay.js @@ -0,0 +1,13 @@ +import { LatLngBounds } from 'leaflet'; +export function updateMediaOverlay(overlay, props, prevProps) { + if (props.bounds instanceof LatLngBounds && props.bounds !== prevProps.bounds) { + overlay.setBounds(props.bounds); + } + if (props.opacity != null && props.opacity !== prevProps.opacity) { + overlay.setOpacity(props.opacity); + } + if (props.zIndex != null && props.zIndex !== prevProps.zIndex) { + // @ts-ignore missing in definition but inherited from ImageOverlay + overlay.setZIndex(props.zIndex); + } +} diff --git a/node_modules/@react-leaflet/core/lib/pane.d.ts b/node_modules/@react-leaflet/core/lib/pane.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a8946ea1f4f981fef1617616d9b27c4099cbc647 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/pane.d.ts @@ -0,0 +1,3 @@ +import type { LayerOptions } from 'leaflet'; +import type { LeafletContextInterface } from './context.js'; +export declare function withPane

(props: P, context: LeafletContextInterface): P; diff --git a/node_modules/@react-leaflet/core/lib/pane.js b/node_modules/@react-leaflet/core/lib/pane.js new file mode 100644 index 0000000000000000000000000000000000000000..5673a2cfb93e08d5e0e5a2d9d50c7d0c778e9c00 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/pane.js @@ -0,0 +1,7 @@ +export function withPane(props, context) { + const pane = props.pane ?? context.pane; + return pane ? { + ...props, + pane + } : props; +} diff --git a/node_modules/@react-leaflet/core/lib/path.d.ts b/node_modules/@react-leaflet/core/lib/path.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..befbfee539984c34767024a4957cad39b91fc0f0 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/path.d.ts @@ -0,0 +1,8 @@ +import type { FeatureGroup, Path, PathOptions } from 'leaflet'; +import type { ElementHook, LeafletElement } from './element.js'; +import { type InteractiveLayerProps } from './layer.js'; +export interface PathProps extends InteractiveLayerProps { + pathOptions?: PathOptions; +} +export declare function usePathOptions(element: LeafletElement, props: PathProps): void; +export declare function createPathHook(useElement: ElementHook): (props: P) => ReturnType>; diff --git a/node_modules/@react-leaflet/core/lib/path.js b/node_modules/@react-leaflet/core/lib/path.js new file mode 100644 index 0000000000000000000000000000000000000000..5f2f7260647d9f423915ffcad3c94ce735bd8559 --- /dev/null +++ b/node_modules/@react-leaflet/core/lib/path.js @@ -0,0 +1,28 @@ +import { useEffect, useRef } from 'react'; +import { useLeafletContext } from './context.js'; +import { useEventHandlers } from './events.js'; +import { useLayerLifecycle } from './layer.js'; +import { withPane } from './pane.js'; +export function usePathOptions(element, props) { + const optionsRef = useRef(undefined); + useEffect(function updatePathOptions() { + if (props.pathOptions !== optionsRef.current) { + const options = props.pathOptions ?? {}; + element.instance.setStyle(options); + optionsRef.current = options; + } + }, [ + element, + props + ]); +} +export function createPathHook(useElement) { + return function usePath(props) { + const context = useLeafletContext(); + const elementRef = useElement(withPane(props, context), context); + useEventHandlers(elementRef.current, props.eventHandlers); + useLayerLifecycle(elementRef.current, context); + usePathOptions(elementRef.current, props); + return elementRef; + }; +} diff --git a/node_modules/@react-leaflet/core/package.json b/node_modules/@react-leaflet/core/package.json new file mode 100644 index 0000000000000000000000000000000000000000..86ce7f318ea90753f04632c783f35ffd09d4d6ce --- /dev/null +++ b/node_modules/@react-leaflet/core/package.json @@ -0,0 +1,66 @@ +{ + "name": "@react-leaflet/core", + "version": "3.0.0", + "description": "React Leaflet core", + "repository": { + "type": "git", + "url": "https://github.com/PaulLeCam/react-leaflet.git" + }, + "keywords": [ + "react-component", + "react", + "leaflet", + "map" + ], + "author": "Paul Le Cam ", + "license": "Hippocratic-2.1", + "bugs": { + "url": "https://github.com/PaulLeCam/react-leaflet/issues" + }, + "homepage": "https://react-leaflet.js.org/docs/core-introduction", + "type": "module", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "exports": { + ".": "./lib/index.js" + }, + "files": [ + "lib/*" + ], + "sideEffects": false, + "peerDependencies": { + "leaflet": "^1.9.0", + "react": "^19.0.0", + "react-dom": "^19.0.0" + }, + "devDependencies": { + "@types/react": "^19.0.1", + "@types/react-dom": "^19.0.2" + }, + "jest": { + "extensionsToTreatAsEsm": [ + ".ts", + ".tsx" + ], + "resolver": "ts-jest-resolver", + "testEnvironment": "jsdom", + "transform": { + "^.+\\.(t|j)sx?$": [ + "@swc/jest", + { + "root": "../.." + } + ] + } + }, + "scripts": { + "build:clean": "del lib", + "build:js": "swc src -d ./lib --config-file ../../.swcrc --strip-leading-paths", + "build:types": "tsc --emitDeclarationOnly", + "build": "pnpm run build:clean && pnpm run build:types && pnpm run build:js", + "test:types": "tsc --noEmit", + "test:unit": "cross-env NODE_ENV=test jest", + "test": "pnpm run test:types && pnpm run test:unit", + "start": "pnpm run test && pnpm run build" + } +} \ No newline at end of file diff --git a/node_modules/@react-pdf/fns/README.md b/node_modules/@react-pdf/fns/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c60ef0fe5c9ea71ed3473b3d71acb99822ca2ce3 --- /dev/null +++ b/node_modules/@react-pdf/fns/README.md @@ -0,0 +1,306 @@ +

+ +

+ +# @react-pdf/fns + +> Lightweight utility functions for react-pdf + +A collection of functional programming utilities used internally by react-pdf. Zero dependencies, tree-shakeable, and fully typed. + +## Installation + +```bash +yarn add @react-pdf/fns +``` + +## Table of Contents + +- [adjust](#adjust) +- [asyncCompose](#asynccompose) +- [capitalize](#capitalize) +- [castArray](#castarray) +- [compose](#compose) +- [dropLast](#droplast) +- [evolve](#evolve) +- [get](#get) +- [isNil](#isnil) +- [last](#last) +- [mapValues](#mapvalues) +- [matchPercent](#matchpercent) +- [omit](#omit) +- [parseFloat](#parsefloat) +- [pick](#pick) +- [repeat](#repeat) +- [reverse](#reverse) +- [upperFirst](#upperfirst) +- [without](#without) + +## Functions + +### adjust + +Applies a function to the value at the given index of an array. + +```js +import { adjust } from '@react-pdf/fns'; + +adjust(1, (x) => x * 2, [1, 2, 3]); // => [1, 4, 3] +adjust(-1, (x) => x + 10, [1, 2, 3]); // => [1, 2, 13] +``` + +--- + +### asyncCompose + +Performs right-to-left function composition with async functions support. `asyncCompose(f, g, h)(x)` is equivalent to `await f(await g(await h(x)))`. + +```js +import { asyncCompose } from '@react-pdf/fns'; + +const addAsync = async (x) => x + 1; +const double = (x) => x * 2; + +const fn = asyncCompose(double, addAsync); +await fn(5); // => 12 +``` + +--- + +### capitalize + +Capitalizes the first letter of each word in a string. + +```js +import { capitalize } from '@react-pdf/fns'; + +capitalize('hello world'); // => 'Hello World' +capitalize('foo bar baz'); // => 'Foo Bar Baz' +``` + +--- + +### castArray + +Wraps a value in an array if it isn't one already. + +```js +import { castArray } from '@react-pdf/fns'; + +castArray('foo'); // => ['foo'] +castArray(['foo']); // => ['foo'] +castArray(123); // => [123] +``` + +--- + +### compose + +Performs right-to-left function composition. `compose(f, g, h)(x)` is equivalent to `f(g(h(x)))`. + +```js +import { compose } from '@react-pdf/fns'; + +const add1 = (x) => x + 1; +const double = (x) => x * 2; + +const fn = compose(double, add1); +fn(5); // => 12 +``` + +--- + +### dropLast + +Drops the last element from an array or string. + +```js +import { dropLast } from '@react-pdf/fns'; + +dropLast([1, 2, 3]); // => [1, 2] +dropLast('hello'); // => 'hell' +``` + +--- + +### evolve + +Applies transformations to an object's values based on a transformation map. + +```js +import { evolve } from '@react-pdf/fns'; + +evolve( + { count: (n) => n + 1, name: (s) => s.toUpperCase() }, + { name: 'item', count: 5 }, +); +// => { name: 'ITEM', count: 6 } +``` + +--- + +### get + +Retrieves a value at a given path from an object with a default fallback. + +```js +import { get } from '@react-pdf/fns'; + +get({ a: { b: 1 } }, ['a', 'b'], 0); // => 1 +get({ a: { b: 1 } }, ['a', 'c'], 0); // => 0 +get({ a: { b: 1 } }, 'a', {}); // => { b: 1 } +``` + +--- + +### isNil + +Checks if a value is `null` or `undefined`. + +```js +import { isNil } from '@react-pdf/fns'; + +isNil(null); // => true +isNil(undefined); // => true +isNil(0); // => false +isNil(''); // => false +``` + +--- + +### last + +Returns the last element of an array or last character of a string. + +```js +import { last } from '@react-pdf/fns'; + +last([1, 2, 3]); // => 3 +last('abc'); // => 'c' +last([]); // => undefined +``` + +--- + +### mapValues + +Maps over the values of an object, applying a function to each value. + +```js +import { mapValues } from '@react-pdf/fns'; + +mapValues({ a: 1, b: 2 }, (v) => v * 2); // => { a: 2, b: 4 } +mapValues({ x: 'foo', y: 'bar' }, (v, k) => `${k}:${v}`); +// => { x: 'x:foo', y: 'y:bar' } +``` + +--- + +### matchPercent + +Parses a percentage string and returns both the numeric value and decimal percent. + +```js +import { matchPercent } from '@react-pdf/fns'; + +matchPercent('50%'); // => { value: 50, percent: 0.5 } +matchPercent('-25%'); // => { value: -25, percent: -0.25 } +matchPercent('abc'); // => null +``` + +--- + +### omit + +Creates a new object excluding specified keys. + +```js +import { omit } from '@react-pdf/fns'; + +omit('b', { a: 1, b: 2, c: 3 }); // => { a: 1, c: 3 } +omit(['a', 'c'], { a: 1, b: 2, c: 3 }); // => { b: 2 } +``` + +--- + +### parseFloat + +Parses a string to a float. Non-string values pass through unchanged. + +```js +import { parseFloat } from '@react-pdf/fns'; + +parseFloat('3.14'); // => 3.14 +parseFloat('10px'); // => 10 +parseFloat(42); // => 42 +parseFloat(null); // => null +``` + +--- + +### pick + +Creates a new object with only the specified keys. + +```js +import { pick } from '@react-pdf/fns'; + +pick(['a', 'c'], { a: 1, b: 2, c: 3 }); // => { a: 1, c: 3 } +pick(['x'], { a: 1, b: 2 }); // => {} +``` + +--- + +### repeat + +Creates an array with an element repeated a specified number of times. + +```js +import { repeat } from '@react-pdf/fns'; + +repeat('a', 3); // => ['a', 'a', 'a'] +repeat(0, 4); // => [0, 0, 0, 0] +``` + +--- + +### reverse + +Returns a new array with elements in reverse order (does not mutate original). + +```js +import { reverse } from '@react-pdf/fns'; + +reverse([1, 2, 3]); // => [3, 2, 1] +reverse(['a', 'b', 'c']); // => ['c', 'b', 'a'] +``` + +--- + +### upperFirst + +Converts the first character of a string to uppercase. + +```js +import { upperFirst } from '@react-pdf/fns'; + +upperFirst('hello'); // => 'Hello' +upperFirst('hELLO'); // => 'HELLO' +``` + +--- + +### without + +Returns a new array excluding the specified values. + +```js +import { without } from '@react-pdf/fns'; + +without([2, 4], [1, 2, 3, 4, 5]); // => [1, 3, 5] +without(['b'], ['a', 'b', 'c']); // => ['a', 'c'] +``` + +## License + +MIT diff --git a/node_modules/@react-pdf/fns/lib/index.d.ts b/node_modules/@react-pdf/fns/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad44b3a1fad3e36d1d542c4ccf509db871a71aaf --- /dev/null +++ b/node_modules/@react-pdf/fns/lib/index.d.ts @@ -0,0 +1,253 @@ +/** + * Applies a function to the value at the given index of an array + * + * @param index + * @param fn + * @param collection + * @returns Copy of the array with the element at the given index replaced with the result of the function application. + */ +declare const adjust: (index: number, fn: (value: T) => T, collection: T[]) => T[]; + +type Fn$1 = (arg: any, ...args: any[]) => Promise | any; +type ComposedInput$1 = T extends [ + ...any, + (arg: infer A, ...args: any[]) => Promise | any +] ? A : never; +type ComposedOutput$1 = T extends [ + (arg: any, ...args: any[]) => Promise | infer R, + ...any +] ? R : never; +/** + * Performs right-to-left function composition with async functions support. + * asyncCompose(f, g, h)(x) is equivalent to f(g(h(x))), awaiting each result. + * + * @param fns - Functions to compose (can be sync or async) + * @returns Composed async function that applies functions from right to left + */ +declare const asyncCompose: (...fns: T) => (value: ComposedInput$1, ...args: Parameters extends [any, ...infer Rest] ? Rest : []) => Promise>; + +/** + * Capitalize first letter of each word + * + * @param value - Any string + * @returns Capitalized string + */ +declare const capitalize: (value?: string | null) => string | null | undefined; + +/** + * Casts value to array + * + * @template T - The type of the value. + * @param value - The value to cast into an array. + * @returns The value as-is if already an array, otherwise wrapped in an array. + */ +declare const castArray: (value: T | T[]) => T[]; + +type Fn = (arg: any, ...args: any[]) => any; +type ComposedInput = T extends [ + ...any, + (arg: infer A, ...args: any[]) => any +] ? A : never; +type ComposedOutput = T extends [ + (arg: any, ...args: any[]) => infer R, + ...any +] ? R : never; +/** + * Performs right-to-left function composition. + * compose(f, g, h)(x) is equivalent to f(g(h(x))) + * + * @param fns - Functions to compose + * @returns Composed function that applies functions from right to left + */ +declare const compose: (...fns: T) => (value: ComposedInput, ...args: any[]) => ComposedOutput; + +/** + * Drops the last element from an array or string. + * + * @param value - The array or string to drop the last element from + * @returns A new array or string with the last element removed + */ +declare function dropLast(value: string): string; +declare function dropLast(value: T[]): T[]; + +/** + * Applies a set of transformations to an object and returns a new object with the transformed values. + * + * @example + * evolve({ count: (n) => n + 1 }, { name: 'item', count: 5 }) + * // => { name: 'item', count: 6 } + * + * @param transformations - The transformations to apply + * @param object - The object to transform + * @returns The transformed object + */ +declare function evolve>(transformations: Partial<{ + [K in keyof T]: (value: T[K]) => T[K]; +}>, object: T): T; + +/** + * Retrieves the value at a given path from an object. + * + * @example + * get({ a: { b: 1 } }, ['a', 'b'], 0) // => 1 + * get({ a: { b: 1 } }, ['a', 'c'], 0) // => 0 + * + * @param target - The object to retrieve the value from + * @param path - The path of the value to retrieve + * @param defaultValue - The default value to return if the path does not exist + * @returns The value at the given path, or the default value if the path does not exist + */ +declare const get: (target: any, path: (string | number)[] | string | number, defaultValue: any) => any; + +/** + * Checks if a value is null or undefined. + * + * @example + * isNil(null) // => true + * isNil(undefined) // => true + * isNil(0) // => false + * + * @param value - The value to check + * @returns True if the value is null or undefined, false otherwise + */ +declare const isNil: (value: unknown) => value is null | undefined; + +/** + * Returns the last element of an array or last character of a string. + * + * @example + * last([1, 2, 3]) // => 3 + * last('abc') // => 'c' + * last([]) // => undefined + * last('') // => '' + * + * @param value - The array or string + * @returns The last element/character, or undefined for empty arrays + */ +declare function last(value: string): string; +declare function last(value: T[]): T | undefined; + +type IteratorFn = (value: any, key: string, index: number) => any; +/** + * Maps over the values of an object and applies a function to each value. + * + * @example + * mapValues({ a: 1, b: 2 }, (v) => v * 2) // => { a: 2, b: 4 } + * + * @param object - The object to map over + * @param fn - The function to apply to each value + * @returns A new object with the mapped values + */ +declare const mapValues: (object: Record, fn: IteratorFn) => Record; + +interface PercentMatch { + percent: number; + value: number; +} +/** + * Parses a percentage string and returns both the numeric value and decimal percent. + * + * @example + * matchPercent('50%') // => { value: 50, percent: 0.5 } + * matchPercent('-25%') // => { value: -25, percent: -0.25 } + * matchPercent('abc') // => null + * + * @param value - The value to parse + * @returns Object with value and percent, or null if not a valid percentage + */ +declare const matchPercent: (value: string | number | null) => PercentMatch | null; + +/** + * Creates a new object by omitting specified keys from the original object. + * + * @example + * omit('b', { a: 1, b: 2, c: 3 }) // => { a: 1, c: 3 } + * omit(['a', 'c'], { a: 1, b: 2, c: 3 }) // => { b: 2 } + * + * @param keys - The key or keys to omit + * @param object - The original object + * @returns The new object without the omitted keys + */ +declare const omit: (keys: string | string[], object: Record) => Record; + +/** + * Picks the specified keys from an object and returns a new object with only those keys. + * + * @example + * pick(['a', 'c'], { a: 1, b: 2, c: 3 }) // => { a: 1, c: 3 } + * pick(['x'], { a: 1, b: 2 }) // => {} + * + * @param keys - The keys to pick from the object + * @param object - The object to pick the keys from + * @returns A new object with only the picked keys + */ +declare const pick: (keys: (string | number)[], object: Record) => Record; + +/** + * Repeats an element a specified number of times. + * + * @example + * repeat('a', 3) // => ['a', 'a', 'a'] + * repeat(0, 4) // => [0, 0, 0, 0] + * repeat('x') // => [] + * + * @param element - Element to be repeated + * @param length - Number of times to repeat element (default: 0) + * @returns Array with the element repeated + */ +declare const repeat: (element: T, length?: number) => T[]; + +/** + * Returns a new array with elements in reverse order. Does not mutate the original. + * + * @example + * reverse([1, 2, 3]) // => [3, 2, 1] + * reverse(['a', 'b']) // => ['b', 'a'] + * + * @param array - Array to be reversed + * @returns New array with elements reversed + */ +declare const reverse: (array: T[]) => T[]; + +/** + * Converts the first character of a string to uppercase. Does not affect other characters. + * + * @example + * upperFirst('hello') // => 'Hello' + * upperFirst('hELLO') // => 'HELLO' + * upperFirst('') // => '' + * upperFirst(null) // => null + * + * @param value - The string to transform + * @returns String with first character uppercased, or the original value if null/undefined/empty + */ +declare const upperFirst: (value: T) => T extends string ? string : T; + +/** + * Returns a new array excluding the specified values. + * + * @example + * without([2, 4], [1, 2, 3, 4, 5]) // => [1, 3, 5] + * without(['b'], ['a', 'b', 'c']) // => ['a', 'c'] + * + * @param exclude - Values to exclude from the array + * @param array - Array to filter + * @returns A new array without the excluded values + */ +declare const without: (exclude: T[], array: T[]) => T[]; + +/** + * Parse a string or number to a float. Non-string values pass through unchanged. + * + * @example + * parseFloat('3.14') // => 3.14 + * parseFloat(42) // => 42 + * parseFloat('10px') // => 10 + * parseFloat(null) // => null + * + * @param value - The value to parse + * @returns Parsed float for strings, original value otherwise + */ +declare const parseFloat: (value: T) => T extends string ? number : T; + +export { adjust, asyncCompose, capitalize, castArray, compose, dropLast, evolve, get, isNil, last, mapValues, matchPercent, omit, parseFloat, pick, repeat, reverse, upperFirst, without }; diff --git a/node_modules/@react-pdf/fns/lib/index.js b/node_modules/@react-pdf/fns/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..703affaaf0d82ed22303f1c48c0626f040c4bd64 --- /dev/null +++ b/node_modules/@react-pdf/fns/lib/index.js @@ -0,0 +1,324 @@ +/** + * Applies a function to the value at the given index of an array + * + * @param index + * @param fn + * @param collection + * @returns Copy of the array with the element at the given index replaced with the result of the function application. + */ +const adjust = (index, fn, collection) => { + if (index >= collection.length) + return collection; + if (index < 0 && Math.abs(index) > collection.length) + return collection; + const i = index < 0 ? collection.length + index : index; + return Object.assign([], collection, { [i]: fn(collection[i]) }); +}; + +/* eslint-disable no-await-in-loop */ +/** + * Performs right-to-left function composition with async functions support. + * asyncCompose(f, g, h)(x) is equivalent to f(g(h(x))), awaiting each result. + * + * @param fns - Functions to compose (can be sync or async) + * @returns Composed async function that applies functions from right to left + */ +const asyncCompose = (...fns) => async (value, ...args) => { + let result = value; + for (let i = fns.length - 1; i >= 0; i -= 1) { + result = await fns[i](result, ...args); + } + return result; +}; + +/** + * Capitalize first letter of each word + * + * @param value - Any string + * @returns Capitalized string + */ +const capitalize = (value) => { + if (!value) + return value; + return value.replace(/(^|\s)\S/g, (l) => l.toUpperCase()); +}; + +/** + * Casts value to array + * + * @template T - The type of the value. + * @param value - The value to cast into an array. + * @returns The value as-is if already an array, otherwise wrapped in an array. + */ +const castArray = (value) => { + return Array.isArray(value) ? value : [value]; +}; + +/** + * Performs right-to-left function composition. + * compose(f, g, h)(x) is equivalent to f(g(h(x))) + * + * @param fns - Functions to compose + * @returns Composed function that applies functions from right to left + */ +const compose = (...fns) => (value, ...args) => { + let result = value; + for (let i = fns.length - 1; i >= 0; i -= 1) { + result = fns[i](result, ...args); + } + return result; +}; + +function dropLast(value) { + return value.slice(0, -1); +} + +/** + * Applies a set of transformations to an object and returns a new object with the transformed values. + * + * @example + * evolve({ count: (n) => n + 1 }, { name: 'item', count: 5 }) + * // => { name: 'item', count: 6 } + * + * @param transformations - The transformations to apply + * @param object - The object to transform + * @returns The transformed object + */ +function evolve(transformations, object) { + const result = Object.create(null); + const keys = Object.keys(object); + for (let i = 0; i < keys.length; i += 1) { + const key = keys[i]; + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + continue; + } + const transformation = transformations[key]; + if (typeof transformation === 'function') { + result[key] = transformation(object[key]); + } + else { + result[key] = object[key]; + } + } + return result; +} + +/** + * Checks if a value is null or undefined. + * + * @example + * isNil(null) // => true + * isNil(undefined) // => true + * isNil(0) // => false + * + * @param value - The value to check + * @returns True if the value is null or undefined, false otherwise + */ +const isNil = (value) => value === null || value === undefined; + +/** + * Retrieves the value at a given path from an object. + * + * @example + * get({ a: { b: 1 } }, ['a', 'b'], 0) // => 1 + * get({ a: { b: 1 } }, ['a', 'c'], 0) // => 0 + * + * @param target - The object to retrieve the value from + * @param path - The path of the value to retrieve + * @param defaultValue - The default value to return if the path does not exist + * @returns The value at the given path, or the default value if the path does not exist + */ +const get = (target, path, defaultValue) => { + if (isNil(target)) + return defaultValue; + const _path = castArray(path); + let result = target; + for (let i = 0; i < _path.length; i += 1) { + if (isNil(result)) + return defaultValue; + result = result[_path[i]]; + } + return isNil(result) ? defaultValue : result; +}; + +function last(value) { + return value === '' ? '' : value[value.length - 1]; +} + +/** + * Maps over the values of an object and applies a function to each value. + * + * @example + * mapValues({ a: 1, b: 2 }, (v) => v * 2) // => { a: 2, b: 4 } + * + * @param object - The object to map over + * @param fn - The function to apply to each value + * @returns A new object with the mapped values + */ +const mapValues = (object, fn) => { + const result = {}; + const entries = Object.entries(object); + for (let i = 0; i < entries.length; i += 1) { + const [key, value] = entries[i]; + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + continue; + } + result[key] = fn(value, key, i); + } + return result; +}; + +const PERCENT_REGEX = /(-?\d+\.?\d*)%/; +/** + * Parses a percentage string and returns both the numeric value and decimal percent. + * + * @example + * matchPercent('50%') // => { value: 50, percent: 0.5 } + * matchPercent('-25%') // => { value: -25, percent: -0.25 } + * matchPercent('abc') // => null + * + * @param value - The value to parse + * @returns Object with value and percent, or null if not a valid percentage + */ +const matchPercent = (value) => { + const match = PERCENT_REGEX.exec(`${value}`); + if (match) { + const numericValue = parseFloat(match[1]); + const percent = numericValue / 100; + return { percent, value: numericValue }; + } + return null; +}; + +/** + * Creates a new object by omitting specified keys from the original object. + * + * @example + * omit('b', { a: 1, b: 2, c: 3 }) // => { a: 1, c: 3 } + * omit(['a', 'c'], { a: 1, b: 2, c: 3 }) // => { b: 2 } + * + * @param keys - The key or keys to omit + * @param object - The original object + * @returns The new object without the omitted keys + */ +const omit = (keys, object) => { + const _keys = castArray(keys); + const copy = { ...object }; + for (let i = 0; i < _keys.length; i += 1) { + delete copy[_keys[i]]; + } + return copy; +}; + +/** + * Picks the specified keys from an object and returns a new object with only those keys. + * + * @example + * pick(['a', 'c'], { a: 1, b: 2, c: 3 }) // => { a: 1, c: 3 } + * pick(['x'], { a: 1, b: 2 }) // => {} + * + * @param keys - The keys to pick from the object + * @param object - The object to pick the keys from + * @returns A new object with only the picked keys + */ +const pick = (keys, object) => { + const result = {}; + for (let i = 0; i < keys.length; i += 1) { + const key = keys[i]; + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + continue; + } + if (key in object) + result[key] = object[key]; + } + return result; +}; + +/** + * Repeats an element a specified number of times. + * + * @example + * repeat('a', 3) // => ['a', 'a', 'a'] + * repeat(0, 4) // => [0, 0, 0, 0] + * repeat('x') // => [] + * + * @param element - Element to be repeated + * @param length - Number of times to repeat element (default: 0) + * @returns Array with the element repeated + */ +const repeat = (element, length = 0) => { + const result = new Array(length); + for (let i = 0; i < length; i += 1) { + result[i] = element; + } + return result; +}; + +/** + * Returns a new array with elements in reverse order. Does not mutate the original. + * + * @example + * reverse([1, 2, 3]) // => [3, 2, 1] + * reverse(['a', 'b']) // => ['b', 'a'] + * + * @param array - Array to be reversed + * @returns New array with elements reversed + */ +const reverse = (array) => array.slice().reverse(); + +/** + * Converts the first character of a string to uppercase. Does not affect other characters. + * + * @example + * upperFirst('hello') // => 'Hello' + * upperFirst('hELLO') // => 'HELLO' + * upperFirst('') // => '' + * upperFirst(null) // => null + * + * @param value - The string to transform + * @returns String with first character uppercased, or the original value if null/undefined/empty + */ +const upperFirst = (value) => { + if (!value) + return value; + return (value.charAt(0).toUpperCase() + value.slice(1)); +}; + +/** + * Returns a new array excluding the specified values. + * + * @example + * without([2, 4], [1, 2, 3, 4, 5]) // => [1, 3, 5] + * without(['b'], ['a', 'b', 'c']) // => ['a', 'c'] + * + * @param exclude - Values to exclude from the array + * @param array - Array to filter + * @returns A new array without the excluded values + */ +const without = (exclude, array) => { + const result = []; + for (let i = 0; i < array.length; i += 1) { + const value = array[i]; + if (!exclude.includes(value)) + result.push(value); + } + return result; +}; + +/** + * Parse a string or number to a float. Non-string values pass through unchanged. + * + * @example + * parseFloat('3.14') // => 3.14 + * parseFloat(42) // => 42 + * parseFloat('10px') // => 10 + * parseFloat(null) // => null + * + * @param value - The value to parse + * @returns Parsed float for strings, original value otherwise + */ +const parseFloat$1 = (value) => { + return (typeof value === 'string' ? Number.parseFloat(value) : value); +}; + +export { adjust, asyncCompose, capitalize, castArray, compose, dropLast, evolve, get, isNil, last, mapValues, matchPercent, omit, parseFloat$1 as parseFloat, pick, repeat, reverse, upperFirst, without }; diff --git a/node_modules/@react-pdf/fns/package.json b/node_modules/@react-pdf/fns/package.json new file mode 100644 index 0000000000000000000000000000000000000000..74f5a3ffc81cbe7bc6afbd2b3110c859585a799c --- /dev/null +++ b/node_modules/@react-pdf/fns/package.json @@ -0,0 +1,25 @@ +{ + "name": "@react-pdf/fns", + "version": "3.1.3", + "license": "MIT", + "description": "React-pdf helper functions", + "author": "Diego Muracciole ", + "homepage": "https://github.com/diegomura/react-pdf#readme", + "type": "module", + "main": "./lib/index.js", + "types": "./lib/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/diegomura/react-pdf.git", + "directory": "packages/fns" + }, + "scripts": { + "test": "vitest", + "build": "rollup -c", + "watch": "rollup -c -w", + "typecheck": "tsc --noEmit" + }, + "files": [ + "lib" + ] +} diff --git a/node_modules/@react-pdf/font/README.md b/node_modules/@react-pdf/font/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7897a10013672455aec7670fcf6bfd03fd1566a2 --- /dev/null +++ b/node_modules/@react-pdf/font/README.md @@ -0,0 +1,313 @@ +

+ +

+ +# @react-pdf/font + +Font registration, loading, and resolution library for react-pdf. Handles TTF, WOFF, and WOFF2 fonts from various sources including local files, remote URLs, and base64 data URIs. Includes built-in support for PDF standard fonts. + +## Installation + +```bash +yarn add @react-pdf/font +``` + +## Usage + +```js +import FontStore from '@react-pdf/font'; + +const fontStore = new FontStore(); + +// Register a custom font +fontStore.register({ + family: 'Roboto', + src: 'https://example.com/fonts/Roboto-Regular.ttf', +}); + +// Load the font +await fontStore.load({ + fontFamily: 'Roboto', + fontStyle: 'normal', + fontWeight: 400, +}); +``` + +## Font Sources + +The library supports multiple font source types: + +### Remote URL + +```js +fontStore.register({ + family: 'Open Sans', + src: 'https://example.com/fonts/OpenSans-Regular.ttf', +}); +``` + +With custom request options: + +```js +fontStore.register({ + family: 'Open Sans', + src: 'https://example.com/fonts/OpenSans-Regular.ttf', + method: 'GET', + headers: { + Authorization: 'Bearer token', + }, + body: null, +}); +``` + +### Local File (Node.js) + +```js +fontStore.register({ + family: 'Custom Font', + src: '/path/to/font.ttf', +}); +``` + +> **Note:** Local file resolution is only available in Node.js environments. + +### Base64 Data URI + +```js +fontStore.register({ + family: 'Embedded Font', + src: 'data:font/ttf;base64,AAEAAAALAIAAAwAwT1MvMg...', +}); +``` + +## Registering Font Families + +### Single Font + +```js +fontStore.register({ + family: 'Roboto', + src: 'https://example.com/fonts/Roboto-Regular.ttf', + fontWeight: 400, + fontStyle: 'normal', +}); +``` + +### Multiple Weights and Styles (Bulk Registration) + +```js +fontStore.register({ + family: 'Roboto', + fonts: [ + { src: 'https://example.com/fonts/Roboto-Regular.ttf', fontWeight: 400 }, + { src: 'https://example.com/fonts/Roboto-Bold.ttf', fontWeight: 700 }, + { + src: 'https://example.com/fonts/Roboto-Italic.ttf', + fontWeight: 400, + fontStyle: 'italic', + }, + { + src: 'https://example.com/fonts/Roboto-BoldItalic.ttf', + fontWeight: 700, + fontStyle: 'italic', + }, + ], +}); +``` + +## Standard Fonts + +The following PDF standard fonts are pre-registered and available without any additional setup: + +- **Helvetica** (with Bold, Oblique, and BoldOblique variants) +- **Courier** (with Bold, Oblique, and BoldOblique variants) +- **Times-Roman** (with Bold, Italic, and BoldItalic variants) + +Helvetica variants are pre-loaded by default, so no explicit `load()` call is needed for them. + +```js +// Standard fonts are ready to use immediately +const font = fontStore.getFont({ + fontFamily: 'Helvetica', + fontWeight: 700, + fontStyle: 'normal', +}); +``` + +## Font Weight Resolution + +The library implements CSS font-weight resolution rules. You can specify font weights as numbers or keywords: + +| Keyword | Numeric Value | +| -------------------------- | ------------- | +| `thin`, `hairline` | 100 | +| `ultralight`, `extralight` | 200 | +| `light` | 300 | +| `normal` | 400 | +| `medium` | 500 | +| `semibold`, `demibold` | 600 | +| `bold` | 700 | +| `ultrabold`, `extrabold` | 800 | +| `heavy`, `black` | 900 | + +When an exact weight match isn't available, the library uses CSS fallback rules to find the closest available weight. + +## Emoji Support + +Register an emoji source to enable emoji rendering: + +```js +// Using a URL pattern (must end with trailing slash) +fontStore.registerEmojiSource({ + url: 'https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/', + format: 'png', +}); + +// Using a custom builder function +fontStore.registerEmojiSource({ + builder: (code) => `https://example.com/emojis/${code}.png`, +}); +``` + +The `code` parameter passed to the builder is a hyphen-separated string of hex code points (e.g., `1f44d` for 👍 or `1f44d-1f3ff` for 👍🏿). + +Set `withVariationSelectors: true` if your emoji source requires variation selectors in the code points. + +## Hyphenation + +Register a hyphenation callback for text wrapping: + +```js +import hyphenationCallback from 'hyphen/en'; + +fontStore.registerHyphenationCallback(hyphenationCallback); +``` + +## API Reference + +### FontStore + +#### `register(data: SingleLoad | BulkLoad)` + +Register a font or font family. + +#### `load(descriptor: FontDescriptor): Promise` + +Load a specific font variant. + +#### `getFont(descriptor: FontDescriptor): FontSource` + +Get a font source matching the descriptor. + +#### `registerEmojiSource(source: EmojiSource)` + +Register an emoji image source. + +#### `registerHyphenationCallback(callback: HyphenationCallback)` + +Register a hyphenation callback function. + +#### `reset()` + +Reset all loaded font data (keeps registrations). + +#### `clear()` + +Clear all font registrations, emoji source, and hyphenation callback. + +#### `getRegisteredFontFamilies(): string[]` + +Get list of registered font family names. + +#### `getRegisteredFonts(): Record` + +Get all registered font families with their sources. + +#### `getEmojiSource(): EmojiSource | null` + +Get the registered emoji source, if any. + +#### `getHyphenationCallback(): HyphenationCallback | null` + +Get the registered hyphenation callback, if any. + +## Types + +### FontDescriptor + +```ts +type FontDescriptor = { + fontFamily: string; + fontStyle?: 'normal' | 'italic' | 'oblique'; + fontWeight?: FontWeight; +}; +``` + +### FontWeight + +```ts +type FontWeight = + | number + | 'thin' + | 'hairline' + | 'ultralight' + | 'extralight' + | 'light' + | 'normal' + | 'medium' + | 'semibold' + | 'demibold' + | 'bold' + | 'ultrabold' + | 'extrabold' + | 'heavy' + | 'black'; +``` + +### SingleLoad + +```ts +type SingleLoad = { + family: string; + src: string; + fontStyle?: 'normal' | 'italic' | 'oblique'; + fontWeight?: FontWeight; + postscriptName?: string; + method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; + headers?: Record; + body?: any; +}; +``` + +### BulkLoad + +```ts +type BulkLoad = { + family: string; + fonts: FontSource[]; +}; +``` + +### EmojiSource + +```ts +type EmojiSource = + | { url: string; format?: string; withVariationSelectors?: boolean } + | { builder: (code: string) => string; withVariationSelectors?: boolean }; +``` + +### HyphenationCallback + +```ts +type HyphenationCallback = (word: string) => string[]; +``` + +## Supported Font Formats + +- **TTF** - TrueType Font +- **WOFF** - Web Open Font Format +- **WOFF2** - Web Open Font Format 2.0 + +## License + +MIT diff --git a/node_modules/@react-pdf/font/lib/index.browser.js b/node_modules/@react-pdf/font/lib/index.browser.js new file mode 100644 index 0000000000000000000000000000000000000000..4b00feca6a46435268e61364d2b74552f4c56c2f --- /dev/null +++ b/node_modules/@react-pdf/font/lib/index.browser.js @@ -0,0 +1,501 @@ +import 'is-url'; +import * as fontkit from 'fontkit'; +import PDFDocument from '@react-pdf/pdfkit'; + +// @ts-expect-error ts being silly +const STANDARD_FONTS = [ + 'Courier', + 'Courier-Bold', + 'Courier-Oblique', + 'Courier-BoldOblique', + 'Helvetica', + 'Helvetica-Bold', + 'Helvetica-Oblique', + 'Helvetica-BoldOblique', + 'Times-Roman', + 'Times-Bold', + 'Times-Italic', + 'Times-BoldItalic', +]; +// Create a shared lightweight document for accessing standard font instances. +// Standard fonts are created once and cached, so this is negligible overhead. +let _sharedDoc = null; +const openStandardFont = (src) => { + if (!_sharedDoc) { + _sharedDoc = new PDFDocument({ autoFirstPage: false }); + } + _sharedDoc.font(src); + return _sharedDoc._font; +}; +class StandardFont { + name; + src; + fullName; + familyName; + subfamilyName; + postscriptName; + copyright; + version; + underlinePosition; + underlineThickness; + italicAngle; + bbox; + 'OS/2'; + hhea; + numGlyphs; + characterSet; + availableFeatures; + type; + constructor(src) { + this.name = src; + this.fullName = src; + this.familyName = src; + this.subfamilyName = src; + this.type = 'STANDARD'; + this.postscriptName = src; + this.availableFeatures = []; + this.copyright = ''; + this.version = 1; + this.underlinePosition = -100; + this.underlineThickness = 50; + this.italicAngle = 0; + this.bbox = {}; + this['OS/2'] = {}; + this.hhea = {}; + this.numGlyphs = 0; + this.characterSet = []; + this.src = openStandardFont(src); + } + encode(str) { + const [encoded, positions] = this.src.encode(str); + // Soft hyphens (U+00AD) should have zero width for line breaking purposes. + // Upstream pdfkit maps them to 'hyphen' in AFM data, so we override here. + for (let i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 0x00ad) { + positions[i].advanceWidth = 0; + } + } + return [encoded, positions]; + } + layout(str) { + const [encoded, positions] = this.encode(str); + const glyphs = encoded.map((g, i) => { + const glyph = this.getGlyph(parseInt(g, 16)); + glyph.advanceWidth = positions[i].advanceWidth; + return glyph; + }); + const advanceWidth = positions.reduce((acc, p) => acc + p.advanceWidth, 0); + return { + positions, + glyphs, + script: 'latin', + language: 'dflt', + direction: 'ltr', + features: {}, + advanceWidth, + advanceHeight: 0, + bbox: undefined, + }; + } + glyphForCodePoint(codePoint) { + const glyph = this.getGlyph(codePoint); + glyph.advanceWidth = 400; + return glyph; + } + getGlyph(id) { + return { + id, + codePoints: [id], + isLigature: false, + name: this.src.font.characterToGlyph(id), + _font: this.src, + // @ts-expect-error assign proper value + advanceWidth: undefined, + }; + } + hasGlyphForCodePoint(codePoint) { + return this.src.font.characterToGlyph(codePoint) !== '.notdef'; + } + // Based on empirical observation + get ascent() { + return 900; + } + // Based on empirical observation + get capHeight() { + switch (this.name) { + case 'Times-Roman': + case 'Times-Bold': + case 'Times-Italic': + case 'Times-BoldItalic': + return 650; + case 'Courier': + case 'Courier-Bold': + case 'Courier-Oblique': + case 'Courier-BoldOblique': + return 550; + default: + return 690; + } + } + // Based on empirical observation + get xHeight() { + switch (this.name) { + case 'Times-Roman': + case 'Times-Bold': + case 'Times-Italic': + case 'Times-BoldItalic': + return 440; + case 'Courier': + case 'Courier-Bold': + case 'Courier-Oblique': + case 'Courier-BoldOblique': + return 390; + default: + return 490; + } + } + // Based on empirical observation + get descent() { + switch (this.name) { + case 'Times-Roman': + case 'Times-Bold': + case 'Times-Italic': + case 'Times-BoldItalic': + return -220; + case 'Courier': + case 'Courier-Bold': + case 'Courier-Oblique': + case 'Courier-BoldOblique': + return -230; + default: + return -200; + } + } + get lineGap() { + return 0; + } + get unitsPerEm() { + return 1000; + } + stringsForGlyph() { + throw new Error('Method not implemented.'); + } + glyphsForString() { + throw new Error('Method not implemented.'); + } + widthOfGlyph() { + throw new Error('Method not implemented.'); + } + getAvailableFeatures() { + throw new Error('Method not implemented.'); + } + createSubset() { + throw new Error('Method not implemented.'); + } + getVariation() { + throw new Error('Method not implemented.'); + } + getFont() { + throw new Error('Method not implemented.'); + } + getName() { + throw new Error('Method not implemented.'); + } + setDefaultLanguage() { + throw new Error('Method not implemented.'); + } +} + +const fetchFont = async (src, options) => { + const response = await fetch(src, options); + if (!response.ok) { + throw new Error(`Failed to fetch font from ${src}: ${response.status} ${response.statusText}`); + } + const data = await response.arrayBuffer(); + return new Uint8Array(data); +}; +const isDataUrl = (dataUrl) => { + const commaIndex = dataUrl.indexOf(','); + if (commaIndex === -1) + return false; + const header = dataUrl.substring(0, commaIndex); + const hasDataPrefix = header.startsWith('data:'); + const hasBase64Prefix = header.includes(';base64'); + return hasDataPrefix && hasBase64Prefix; +}; +class FontSource { + src; + fontFamily; + fontStyle; + fontWeight; + data; + options; + loadResultPromise; + constructor(src, fontFamily, fontStyle, fontWeight, options) { + this.src = src; + this.fontFamily = fontFamily; + this.fontStyle = fontStyle || 'normal'; + this.fontWeight = fontWeight || 400; + this.data = null; + this.options = options || {}; + this.loadResultPromise = null; + } + async _load() { + const { postscriptName } = this.options; + let data = null; + if (STANDARD_FONTS.includes(this.src)) { + data = new StandardFont(this.src); + } + else if (isDataUrl(this.src)) { + const raw = this.src.split(',')[1]; + const uint8Array = new Uint8Array(atob(raw) + .split('') + .map((c) => c.charCodeAt(0))); + data = fontkit.create(uint8Array, postscriptName); + } + else { + const { headers, body, method = 'GET' } = this.options; + const buffer = await fetchFont(this.src, { method, body, headers }); + data = fontkit.create(buffer, postscriptName); + } + if (data && 'fonts' in data) { + throw new Error('Font collection is not supported'); + } + this.data = data; + } + async load() { + if (this.loadResultPromise === null) { + this.loadResultPromise = this._load(); + } + return this.loadResultPromise; + } +} + +const FONT_WEIGHTS = { + thin: 100, + hairline: 100, + ultralight: 200, + extralight: 200, + light: 300, + normal: 400, + medium: 500, + semibold: 600, + demibold: 600, + bold: 700, + ultrabold: 800, + extrabold: 800, + heavy: 900, + black: 900, +}; +const resolveFontWeight = (value) => { + return typeof value === 'string' ? FONT_WEIGHTS[value] : value; +}; +const sortByFontWeight = (a, b) => a.fontWeight - b.fontWeight; +class FontFamily { + family; + sources; + static create(family) { + return new FontFamily(family); + } + constructor(family) { + this.family = family; + this.sources = []; + } + register({ src, fontWeight, fontStyle, ...options }) { + const numericFontWeight = fontWeight + ? resolveFontWeight(fontWeight) + : undefined; + this.sources.push(new FontSource(src, this.family, fontStyle, numericFontWeight, options)); + } + resolve(descriptor) { + const { fontWeight = 400, fontStyle = 'normal' } = descriptor; + const styleSources = this.sources.filter((s) => s.fontStyle === fontStyle); + const exactFit = styleSources.find((s) => s.fontWeight === fontWeight); + if (exactFit) + return exactFit; + // Weight resolution. https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#Fallback_weights + let font = null; + const numericFontWeight = resolveFontWeight(fontWeight); + if (numericFontWeight >= 400 && numericFontWeight <= 500) { + const leftOffset = styleSources.filter((s) => s.fontWeight <= numericFontWeight); + const rightOffset = styleSources.filter((s) => s.fontWeight > 500); + const fit = styleSources.filter((s) => s.fontWeight >= numericFontWeight && s.fontWeight <= 500); + font = fit[0] || leftOffset[leftOffset.length - 1] || rightOffset[0]; + } + const lt = styleSources + .filter((s) => s.fontWeight < numericFontWeight) + .sort(sortByFontWeight); + const gt = styleSources + .filter((s) => s.fontWeight > numericFontWeight) + .sort(sortByFontWeight); + if (numericFontWeight < 400) { + font = lt[lt.length - 1] || gt[0]; + } + if (numericFontWeight > 500) { + font = gt[0] || lt[lt.length - 1]; + } + if (!font) { + throw new Error(`Could not resolve font for ${this.family}, fontWeight ${fontWeight}, fontStyle ${fontStyle}`); + } + return font; + } +} + +class FontStore { + fontFamilies = {}; + emojiSource = null; + constructor() { + this.register({ + family: 'Helvetica', + fonts: [ + { src: 'Helvetica', fontStyle: 'normal', fontWeight: 400 }, + { src: 'Helvetica-Bold', fontStyle: 'normal', fontWeight: 700 }, + { src: 'Helvetica-Oblique', fontStyle: 'italic', fontWeight: 400 }, + { src: 'Helvetica-BoldOblique', fontStyle: 'italic', fontWeight: 700 }, + ], + }); + this.register({ + family: 'Courier', + fonts: [ + { src: 'Courier', fontStyle: 'normal', fontWeight: 400 }, + { src: 'Courier-Bold', fontStyle: 'normal', fontWeight: 700 }, + { src: 'Courier-Oblique', fontStyle: 'italic', fontWeight: 400 }, + { src: 'Courier-BoldOblique', fontStyle: 'italic', fontWeight: 700 }, + ], + }); + this.register({ + family: 'Times-Roman', + fonts: [ + { src: 'Times-Roman', fontStyle: 'normal', fontWeight: 400 }, + { src: 'Times-Bold', fontStyle: 'normal', fontWeight: 700 }, + { src: 'Times-Italic', fontStyle: 'italic', fontWeight: 400 }, + { src: 'Times-BoldItalic', fontStyle: 'italic', fontWeight: 700 }, + ], + }); + // For backwards compatibility + this.register({ + family: 'Helvetica-Bold', + src: 'Helvetica-Bold', + }); + this.register({ + family: 'Helvetica-Oblique', + src: 'Helvetica-Oblique', + }); + this.register({ + family: 'Helvetica-BoldOblique', + src: 'Helvetica-BoldOblique', + }); + this.register({ + family: 'Courier-Bold', + src: 'Courier-Bold', + }); + this.register({ + family: 'Courier-Oblique', + src: 'Courier-Oblique', + }); + this.register({ + family: 'Courier-BoldOblique', + src: 'Courier-BoldOblique', + }); + this.register({ + family: 'Times-Bold', + src: 'Times-Bold', + }); + this.register({ + family: 'Times-Italic', + src: 'Times-Italic', + }); + this.register({ + family: 'Times-BoldItalic', + src: 'Times-BoldItalic', + }); + // Load default fonts + this.load({ + fontFamily: 'Helvetica', + fontStyle: 'normal', + fontWeight: 400, + }); + this.load({ + fontFamily: 'Helvetica', + fontStyle: 'normal', + fontWeight: 700, + }); + this.load({ + fontFamily: 'Helvetica', + fontStyle: 'italic', + fontWeight: 400, + }); + this.load({ + fontFamily: 'Helvetica', + fontStyle: 'italic', + fontWeight: 700, + }); + } + hyphenationCallback = null; + register = (data) => { + const { family } = data; + if (!this.fontFamilies[family]) { + this.fontFamilies[family] = FontFamily.create(family); + } + // Bulk loading + if ('fonts' in data) { + for (let i = 0; i < data.fonts.length; i += 1) { + const { src, fontStyle, fontWeight, ...options } = data.fonts[i]; + this.fontFamilies[family].register({ + src, + fontStyle, + fontWeight, + ...options, + }); + } + } + else { + const { src, fontStyle, fontWeight, ...options } = data; + this.fontFamilies[family].register({ + src, + fontStyle, + fontWeight, + ...options, + }); + } + }; + registerEmojiSource = (emojiSource) => { + this.emojiSource = emojiSource; + }; + registerHyphenationCallback = (callback) => { + this.hyphenationCallback = callback; + }; + getFont = (descriptor) => { + const { fontFamily } = descriptor; + if (!this.fontFamilies[fontFamily]) { + throw new Error(`Font family not registered: ${fontFamily}. Please register it calling Font.register() method.`); + } + return this.fontFamilies[fontFamily].resolve(descriptor); + }; + load = async (descriptor) => { + const font = this.getFont(descriptor); + if (font) + await font.load(); + }; + reset = () => { + const keys = Object.keys(this.fontFamilies); + for (let i = 0; i < keys.length; i += 1) { + const key = keys[i]; + for (let j = 0; j < this.fontFamilies[key].sources.length; j++) { + const fontSource = this.fontFamilies[key].sources[j]; + fontSource.data = null; + } + } + }; + clear = () => { + this.fontFamilies = {}; + this.emojiSource = null; + this.hyphenationCallback = null; + }; + getRegisteredFonts = () => this.fontFamilies; + getEmojiSource = () => this.emojiSource; + getHyphenationCallback = () => this.hyphenationCallback; + getRegisteredFontFamilies = () => Object.keys(this.fontFamilies); +} + +export { FontStore as default }; diff --git a/node_modules/@react-pdf/font/lib/index.d.ts b/node_modules/@react-pdf/font/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2551391a5d5c134dcc5799e83e1c3a8de6bdd61c --- /dev/null +++ b/node_modules/@react-pdf/font/lib/index.d.ts @@ -0,0 +1,87 @@ +import * as fontkit from 'fontkit'; + +type Font = Omit & { + type: 'TTF' | 'WOFF' | 'WOFF2' | 'STANDARD'; + encode?: (string: string) => number[]; +}; +type FontStyle = 'normal' | 'italic' | 'oblique'; +type FontWeight = number | 'thin' | 'hairline' | 'ultralight' | 'extralight' | 'light' | 'normal' | 'medium' | 'semibold' | 'demibold' | 'bold' | 'ultrabold' | 'extrabold' | 'heavy' | 'black'; +type FontDescriptor = { + fontFamily: string; + fontStyle?: FontStyle; + fontWeight?: FontWeight; +}; +type RemoteOptions = { + method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; + headers?: Record; + body?: any; +}; +type FontSourceOptions = { + postscriptName?: string; +} & RemoteOptions; +type FontSource$1 = { + src: string; + fontStyle?: FontStyle; + fontWeight?: FontWeight; +} & FontSourceOptions; +type SingleLoad = { + family: string; +} & FontSource$1; +type BulkLoad = { + family: string; + fonts: FontSource$1[]; +}; +interface EmojiSourceUrl { + url: string; + format?: string; + withVariationSelectors?: boolean; +} +interface EmojiSourceBuilder { + builder: (code: string) => string; + withVariationSelectors?: boolean; +} +type EmojiSource = EmojiSourceUrl | EmojiSourceBuilder; +type HyphenationCallback = (word: string) => string[]; + +declare class FontSource { + src: string; + fontFamily: string; + fontStyle: FontStyle; + fontWeight: number; + data: Font | null; + options: FontSourceOptions; + loadResultPromise: Promise | null; + constructor(src: string, fontFamily: string, fontStyle?: FontStyle, fontWeight?: number, options?: FontSourceOptions); + _load(): Promise; + load(): Promise; +} + +declare class FontFamily { + family: string; + sources: FontSource[]; + static create(family: string): FontFamily; + constructor(family: string); + register({ src, fontWeight, fontStyle, ...options }: Omit): void; + resolve(descriptor: FontDescriptor): FontSource; +} + +declare class FontStore { + fontFamilies: Record; + emojiSource: EmojiSource | null; + constructor(); + hyphenationCallback: HyphenationCallback | null; + register: (data: SingleLoad | BulkLoad) => void; + registerEmojiSource: (emojiSource: EmojiSource) => void; + registerHyphenationCallback: (callback: HyphenationCallback) => void; + getFont: (descriptor: FontDescriptor) => FontSource; + load: (descriptor: FontDescriptor) => Promise; + reset: () => void; + clear: () => void; + getRegisteredFonts: () => Record; + getEmojiSource: () => EmojiSource | null; + getHyphenationCallback: () => HyphenationCallback | null; + getRegisteredFontFamilies: () => string[]; +} +type FontStoreType = FontStore; + +export { type BulkLoad, type EmojiSource, type Font, type FontDescriptor, type FontSource$1 as FontSource, type FontSourceOptions, type FontStoreType, type FontStyle, type FontWeight, type HyphenationCallback, type RemoteOptions, type SingleLoad, FontStore as default }; diff --git a/node_modules/@react-pdf/font/lib/index.js b/node_modules/@react-pdf/font/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b51eb0a87466add975efb650b94767a803159177 --- /dev/null +++ b/node_modules/@react-pdf/font/lib/index.js @@ -0,0 +1,504 @@ +import isUrl from 'is-url'; +import * as fontkit from 'fontkit'; +import PDFDocument from '@react-pdf/pdfkit'; + +// @ts-expect-error ts being silly +const STANDARD_FONTS = [ + 'Courier', + 'Courier-Bold', + 'Courier-Oblique', + 'Courier-BoldOblique', + 'Helvetica', + 'Helvetica-Bold', + 'Helvetica-Oblique', + 'Helvetica-BoldOblique', + 'Times-Roman', + 'Times-Bold', + 'Times-Italic', + 'Times-BoldItalic', +]; +// Create a shared lightweight document for accessing standard font instances. +// Standard fonts are created once and cached, so this is negligible overhead. +let _sharedDoc = null; +const openStandardFont = (src) => { + if (!_sharedDoc) { + _sharedDoc = new PDFDocument({ autoFirstPage: false }); + } + _sharedDoc.font(src); + return _sharedDoc._font; +}; +class StandardFont { + name; + src; + fullName; + familyName; + subfamilyName; + postscriptName; + copyright; + version; + underlinePosition; + underlineThickness; + italicAngle; + bbox; + 'OS/2'; + hhea; + numGlyphs; + characterSet; + availableFeatures; + type; + constructor(src) { + this.name = src; + this.fullName = src; + this.familyName = src; + this.subfamilyName = src; + this.type = 'STANDARD'; + this.postscriptName = src; + this.availableFeatures = []; + this.copyright = ''; + this.version = 1; + this.underlinePosition = -100; + this.underlineThickness = 50; + this.italicAngle = 0; + this.bbox = {}; + this['OS/2'] = {}; + this.hhea = {}; + this.numGlyphs = 0; + this.characterSet = []; + this.src = openStandardFont(src); + } + encode(str) { + const [encoded, positions] = this.src.encode(str); + // Soft hyphens (U+00AD) should have zero width for line breaking purposes. + // Upstream pdfkit maps them to 'hyphen' in AFM data, so we override here. + for (let i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 0x00ad) { + positions[i].advanceWidth = 0; + } + } + return [encoded, positions]; + } + layout(str) { + const [encoded, positions] = this.encode(str); + const glyphs = encoded.map((g, i) => { + const glyph = this.getGlyph(parseInt(g, 16)); + glyph.advanceWidth = positions[i].advanceWidth; + return glyph; + }); + const advanceWidth = positions.reduce((acc, p) => acc + p.advanceWidth, 0); + return { + positions, + glyphs, + script: 'latin', + language: 'dflt', + direction: 'ltr', + features: {}, + advanceWidth, + advanceHeight: 0, + bbox: undefined, + }; + } + glyphForCodePoint(codePoint) { + const glyph = this.getGlyph(codePoint); + glyph.advanceWidth = 400; + return glyph; + } + getGlyph(id) { + return { + id, + codePoints: [id], + isLigature: false, + name: this.src.font.characterToGlyph(id), + _font: this.src, + // @ts-expect-error assign proper value + advanceWidth: undefined, + }; + } + hasGlyphForCodePoint(codePoint) { + return this.src.font.characterToGlyph(codePoint) !== '.notdef'; + } + // Based on empirical observation + get ascent() { + return 900; + } + // Based on empirical observation + get capHeight() { + switch (this.name) { + case 'Times-Roman': + case 'Times-Bold': + case 'Times-Italic': + case 'Times-BoldItalic': + return 650; + case 'Courier': + case 'Courier-Bold': + case 'Courier-Oblique': + case 'Courier-BoldOblique': + return 550; + default: + return 690; + } + } + // Based on empirical observation + get xHeight() { + switch (this.name) { + case 'Times-Roman': + case 'Times-Bold': + case 'Times-Italic': + case 'Times-BoldItalic': + return 440; + case 'Courier': + case 'Courier-Bold': + case 'Courier-Oblique': + case 'Courier-BoldOblique': + return 390; + default: + return 490; + } + } + // Based on empirical observation + get descent() { + switch (this.name) { + case 'Times-Roman': + case 'Times-Bold': + case 'Times-Italic': + case 'Times-BoldItalic': + return -220; + case 'Courier': + case 'Courier-Bold': + case 'Courier-Oblique': + case 'Courier-BoldOblique': + return -230; + default: + return -200; + } + } + get lineGap() { + return 0; + } + get unitsPerEm() { + return 1000; + } + stringsForGlyph() { + throw new Error('Method not implemented.'); + } + glyphsForString() { + throw new Error('Method not implemented.'); + } + widthOfGlyph() { + throw new Error('Method not implemented.'); + } + getAvailableFeatures() { + throw new Error('Method not implemented.'); + } + createSubset() { + throw new Error('Method not implemented.'); + } + getVariation() { + throw new Error('Method not implemented.'); + } + getFont() { + throw new Error('Method not implemented.'); + } + getName() { + throw new Error('Method not implemented.'); + } + setDefaultLanguage() { + throw new Error('Method not implemented.'); + } +} + +const fetchFont = async (src, options) => { + const response = await fetch(src, options); + if (!response.ok) { + throw new Error(`Failed to fetch font from ${src}: ${response.status} ${response.statusText}`); + } + const data = await response.arrayBuffer(); + return new Uint8Array(data); +}; +const isDataUrl = (dataUrl) => { + const commaIndex = dataUrl.indexOf(','); + if (commaIndex === -1) + return false; + const header = dataUrl.substring(0, commaIndex); + const hasDataPrefix = header.startsWith('data:'); + const hasBase64Prefix = header.includes(';base64'); + return hasDataPrefix && hasBase64Prefix; +}; +class FontSource { + src; + fontFamily; + fontStyle; + fontWeight; + data; + options; + loadResultPromise; + constructor(src, fontFamily, fontStyle, fontWeight, options) { + this.src = src; + this.fontFamily = fontFamily; + this.fontStyle = fontStyle || 'normal'; + this.fontWeight = fontWeight || 400; + this.data = null; + this.options = options || {}; + this.loadResultPromise = null; + } + async _load() { + const { postscriptName } = this.options; + let data = null; + if (STANDARD_FONTS.includes(this.src)) { + data = new StandardFont(this.src); + } + else if (isDataUrl(this.src)) { + const raw = this.src.split(',')[1]; + const uint8Array = new Uint8Array(atob(raw) + .split('') + .map((c) => c.charCodeAt(0))); + data = fontkit.create(uint8Array, postscriptName); + } + else if (isUrl(this.src)) { + const { headers, body, method = 'GET' } = this.options; + const buffer = await fetchFont(this.src, { method, body, headers }); + data = fontkit.create(buffer, postscriptName); + } + else { + data = await fontkit.open(this.src, postscriptName); + } + if (data && 'fonts' in data) { + throw new Error('Font collection is not supported'); + } + this.data = data; + } + async load() { + if (this.loadResultPromise === null) { + this.loadResultPromise = this._load(); + } + return this.loadResultPromise; + } +} + +const FONT_WEIGHTS = { + thin: 100, + hairline: 100, + ultralight: 200, + extralight: 200, + light: 300, + normal: 400, + medium: 500, + semibold: 600, + demibold: 600, + bold: 700, + ultrabold: 800, + extrabold: 800, + heavy: 900, + black: 900, +}; +const resolveFontWeight = (value) => { + return typeof value === 'string' ? FONT_WEIGHTS[value] : value; +}; +const sortByFontWeight = (a, b) => a.fontWeight - b.fontWeight; +class FontFamily { + family; + sources; + static create(family) { + return new FontFamily(family); + } + constructor(family) { + this.family = family; + this.sources = []; + } + register({ src, fontWeight, fontStyle, ...options }) { + const numericFontWeight = fontWeight + ? resolveFontWeight(fontWeight) + : undefined; + this.sources.push(new FontSource(src, this.family, fontStyle, numericFontWeight, options)); + } + resolve(descriptor) { + const { fontWeight = 400, fontStyle = 'normal' } = descriptor; + const styleSources = this.sources.filter((s) => s.fontStyle === fontStyle); + const exactFit = styleSources.find((s) => s.fontWeight === fontWeight); + if (exactFit) + return exactFit; + // Weight resolution. https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#Fallback_weights + let font = null; + const numericFontWeight = resolveFontWeight(fontWeight); + if (numericFontWeight >= 400 && numericFontWeight <= 500) { + const leftOffset = styleSources.filter((s) => s.fontWeight <= numericFontWeight); + const rightOffset = styleSources.filter((s) => s.fontWeight > 500); + const fit = styleSources.filter((s) => s.fontWeight >= numericFontWeight && s.fontWeight <= 500); + font = fit[0] || leftOffset[leftOffset.length - 1] || rightOffset[0]; + } + const lt = styleSources + .filter((s) => s.fontWeight < numericFontWeight) + .sort(sortByFontWeight); + const gt = styleSources + .filter((s) => s.fontWeight > numericFontWeight) + .sort(sortByFontWeight); + if (numericFontWeight < 400) { + font = lt[lt.length - 1] || gt[0]; + } + if (numericFontWeight > 500) { + font = gt[0] || lt[lt.length - 1]; + } + if (!font) { + throw new Error(`Could not resolve font for ${this.family}, fontWeight ${fontWeight}, fontStyle ${fontStyle}`); + } + return font; + } +} + +class FontStore { + fontFamilies = {}; + emojiSource = null; + constructor() { + this.register({ + family: 'Helvetica', + fonts: [ + { src: 'Helvetica', fontStyle: 'normal', fontWeight: 400 }, + { src: 'Helvetica-Bold', fontStyle: 'normal', fontWeight: 700 }, + { src: 'Helvetica-Oblique', fontStyle: 'italic', fontWeight: 400 }, + { src: 'Helvetica-BoldOblique', fontStyle: 'italic', fontWeight: 700 }, + ], + }); + this.register({ + family: 'Courier', + fonts: [ + { src: 'Courier', fontStyle: 'normal', fontWeight: 400 }, + { src: 'Courier-Bold', fontStyle: 'normal', fontWeight: 700 }, + { src: 'Courier-Oblique', fontStyle: 'italic', fontWeight: 400 }, + { src: 'Courier-BoldOblique', fontStyle: 'italic', fontWeight: 700 }, + ], + }); + this.register({ + family: 'Times-Roman', + fonts: [ + { src: 'Times-Roman', fontStyle: 'normal', fontWeight: 400 }, + { src: 'Times-Bold', fontStyle: 'normal', fontWeight: 700 }, + { src: 'Times-Italic', fontStyle: 'italic', fontWeight: 400 }, + { src: 'Times-BoldItalic', fontStyle: 'italic', fontWeight: 700 }, + ], + }); + // For backwards compatibility + this.register({ + family: 'Helvetica-Bold', + src: 'Helvetica-Bold', + }); + this.register({ + family: 'Helvetica-Oblique', + src: 'Helvetica-Oblique', + }); + this.register({ + family: 'Helvetica-BoldOblique', + src: 'Helvetica-BoldOblique', + }); + this.register({ + family: 'Courier-Bold', + src: 'Courier-Bold', + }); + this.register({ + family: 'Courier-Oblique', + src: 'Courier-Oblique', + }); + this.register({ + family: 'Courier-BoldOblique', + src: 'Courier-BoldOblique', + }); + this.register({ + family: 'Times-Bold', + src: 'Times-Bold', + }); + this.register({ + family: 'Times-Italic', + src: 'Times-Italic', + }); + this.register({ + family: 'Times-BoldItalic', + src: 'Times-BoldItalic', + }); + // Load default fonts + this.load({ + fontFamily: 'Helvetica', + fontStyle: 'normal', + fontWeight: 400, + }); + this.load({ + fontFamily: 'Helvetica', + fontStyle: 'normal', + fontWeight: 700, + }); + this.load({ + fontFamily: 'Helvetica', + fontStyle: 'italic', + fontWeight: 400, + }); + this.load({ + fontFamily: 'Helvetica', + fontStyle: 'italic', + fontWeight: 700, + }); + } + hyphenationCallback = null; + register = (data) => { + const { family } = data; + if (!this.fontFamilies[family]) { + this.fontFamilies[family] = FontFamily.create(family); + } + // Bulk loading + if ('fonts' in data) { + for (let i = 0; i < data.fonts.length; i += 1) { + const { src, fontStyle, fontWeight, ...options } = data.fonts[i]; + this.fontFamilies[family].register({ + src, + fontStyle, + fontWeight, + ...options, + }); + } + } + else { + const { src, fontStyle, fontWeight, ...options } = data; + this.fontFamilies[family].register({ + src, + fontStyle, + fontWeight, + ...options, + }); + } + }; + registerEmojiSource = (emojiSource) => { + this.emojiSource = emojiSource; + }; + registerHyphenationCallback = (callback) => { + this.hyphenationCallback = callback; + }; + getFont = (descriptor) => { + const { fontFamily } = descriptor; + if (!this.fontFamilies[fontFamily]) { + throw new Error(`Font family not registered: ${fontFamily}. Please register it calling Font.register() method.`); + } + return this.fontFamilies[fontFamily].resolve(descriptor); + }; + load = async (descriptor) => { + const font = this.getFont(descriptor); + if (font) + await font.load(); + }; + reset = () => { + const keys = Object.keys(this.fontFamilies); + for (let i = 0; i < keys.length; i += 1) { + const key = keys[i]; + for (let j = 0; j < this.fontFamilies[key].sources.length; j++) { + const fontSource = this.fontFamilies[key].sources[j]; + fontSource.data = null; + } + } + }; + clear = () => { + this.fontFamilies = {}; + this.emojiSource = null; + this.hyphenationCallback = null; + }; + getRegisteredFonts = () => this.fontFamilies; + getEmojiSource = () => this.emojiSource; + getHyphenationCallback = () => this.hyphenationCallback; + getRegisteredFontFamilies = () => Object.keys(this.fontFamilies); +} + +export { FontStore as default }; diff --git a/node_modules/@react-pdf/font/package.json b/node_modules/@react-pdf/font/package.json new file mode 100644 index 0000000000000000000000000000000000000000..f166d7a7fc8905d83f309b6ffeb1671c04305c61 --- /dev/null +++ b/node_modules/@react-pdf/font/package.json @@ -0,0 +1,38 @@ +{ + "name": "@react-pdf/font", + "version": "4.0.8", + "license": "MIT", + "description": "Register font and emoji source for react-pdf document", + "author": "Diego Muracciole ", + "homepage": "https://github.com/diegomura/react-pdf#readme", + "repository": { + "type": "git", + "url": "https://github.com/diegomura/react-pdf.git", + "directory": "packages/font" + }, + "type": "module", + "main": "./lib/index.js", + "types": "./lib/index.d.ts", + "browser": { + "./lib/index.js": "./lib/index.browser.js" + }, + "scripts": { + "test": "vitest", + "build": "rimraf ./lib && rollup -c", + "watch": "rimraf ./lib && rollup -c -w", + "typecheck": "tsc --noEmit" + }, + "dependencies": { + "@react-pdf/pdfkit": "^5.1.1", + "@react-pdf/types": "^2.11.1", + "fontkit": "^2.0.2", + "is-url": "^1.2.4" + }, + "files": [ + "lib" + ], + "devDependencies": { + "@types/fontkit": "^2.0.7", + "@types/is-url": "^1.2.32" + } +} diff --git a/node_modules/@react-pdf/image/README.md b/node_modules/@react-pdf/image/README.md new file mode 100644 index 0000000000000000000000000000000000000000..53cea22a2d88b15fc8d95f784c75e61f3f115825 --- /dev/null +++ b/node_modules/@react-pdf/image/README.md @@ -0,0 +1,168 @@ +

+ +

+ +# @react-pdf/image + +Image parsing and resolution library for react-pdf. Handles PNG and JPEG images from various sources including local files, remote URLs, base64 data URIs, buffers, and blobs. + +## Installation + +```bash +yarn add @react-pdf/image +``` + +## Usage + +```js +import resolveImage from '@react-pdf/image'; + +const image = await resolveImage({ uri: './path/to/image.png' }); + +console.log(image.width); // Image width in pixels +console.log(image.height); // Image height in pixels +console.log(image.format); // 'png' or 'jpeg' +console.log(image.data); // Buffer containing image data +``` + +## Image Sources + +The library supports multiple image source types: + +### Local File + +```js +const image = await resolveImage({ uri: './image.png' }); +// or +const image = await resolveImage({ uri: '/absolute/path/to/image.jpg' }); +``` + +> **Note:** Local file resolution is only available in Node.js environments. + +### Remote URL + +```js +const image = await resolveImage({ uri: 'https://example.com/image.png' }); +``` + +With custom request options: + +```js +const image = await resolveImage({ + uri: 'https://example.com/image.png', + method: 'GET', + headers: { + Authorization: 'Bearer token', + }, + body: null, + credentials: 'include', +}); +``` + +### Base64 Data URI + +```js +const image = await resolveImage({ + uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==', +}); +``` + +### Buffer + +```js +import fs from 'fs'; + +const buffer = fs.readFileSync('./image.png'); +const image = await resolveImage(buffer); +``` + +### Blob (Browser) + +```js +const response = await fetch('https://example.com/image.png'); +const blob = await response.blob(); +const image = await resolveImage(blob); +``` + +### Data Object + +```js +const image = await resolveImage({ + data: imageBuffer, + format: 'png', // 'png', 'jpg', or 'jpeg' +}); +``` + +## Caching + +Images are cached by default to avoid redundant processing. You can disable caching for individual requests: + +```js +const image = await resolveImage({ uri: './image.png' }, { cache: false }); +``` + +The cache has a default limit of 30 entries and uses LRU (Least Recently Used) eviction. + +## Types + +### Image + +The resolved image object: + +```ts +interface Image { + width: number; + height: number; + data: Buffer; + format: 'jpeg' | 'png'; + key?: string; +} +``` + +### ImageSrc + +All supported image source types: + +```ts +type ImageSrc = + | Blob + | Buffer + | DataImageSrc + | LocalImageSrc + | RemoteImageSrc + | Base64ImageSrc; + +type DataImageSrc = { + data: Buffer; + format: 'jpg' | 'jpeg' | 'png'; +}; + +type LocalImageSrc = { + uri: string; + format?: 'jpg' | 'jpeg' | 'png'; +}; + +type RemoteImageSrc = { + uri: string; + method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; + headers?: Record; + format?: 'jpg' | 'jpeg' | 'png'; + body?: any; + credentials?: 'omit' | 'same-origin' | 'include'; +}; + +type Base64ImageSrc = { + uri: `data:image${string}`; +}; +``` + +## Supported Formats + +- **PNG** - Portable Network Graphics +- **JPEG/JPG** - Joint Photographic Experts Group + +JPEG images with EXIF orientation data are automatically handled, with width and height adjusted accordingly. + +## License + +MIT diff --git a/node_modules/@react-pdf/image/lib/index.browser.js b/node_modules/@react-pdf/image/lib/index.browser.js new file mode 100644 index 0000000000000000000000000000000000000000..f3102aa855cc84db94452cfc17a27f02feec4f93 --- /dev/null +++ b/node_modules/@react-pdf/image/lib/index.browser.js @@ -0,0 +1,2259 @@ +import _PNG from 'png-js'; +import _JPEG from 'jay-peg'; +import { parseSvg } from '@react-pdf/svg'; + +var global$1 = (typeof global !== "undefined" ? global : + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : {}); + +var lookup = []; +var revLookup = []; +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; +var inited = false; +function init () { + inited = true; + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i]; + revLookup[code.charCodeAt(i)] = i; + } + + revLookup['-'.charCodeAt(0)] = 62; + revLookup['_'.charCodeAt(0)] = 63; +} + +function toByteArray (b64) { + if (!inited) { + init(); + } + var i, j, l, tmp, placeHolders, arr; + var len = b64.length; + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0; + + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(len * 3 / 4 - placeHolders); + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len; + + var L = 0; + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]; + arr[L++] = (tmp >> 16) & 0xFF; + arr[L++] = (tmp >> 8) & 0xFF; + arr[L++] = tmp & 0xFF; + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4); + arr[L++] = tmp & 0xFF; + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2); + arr[L++] = (tmp >> 8) & 0xFF; + arr[L++] = tmp & 0xFF; + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp; + var output = []; + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]); + output.push(tripletToBase64(tmp)); + } + return output.join('') +} + +function fromByteArray (uint8) { + if (!inited) { + init(); + } + var tmp; + var len = uint8.length; + var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes + var output = ''; + var parts = []; + var maxChunkLength = 16383; // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))); + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1]; + output += lookup[tmp >> 2]; + output += lookup[(tmp << 4) & 0x3F]; + output += '=='; + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]); + output += lookup[tmp >> 10]; + output += lookup[(tmp >> 4) & 0x3F]; + output += lookup[(tmp << 2) & 0x3F]; + output += '='; + } + + parts.push(output); + + return parts.join('') +} + +function read (buffer, offset, isLE, mLen, nBytes) { + var e, m; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i = isLE ? (nBytes - 1) : 0; + var d = isLE ? -1 : 1; + var s = buffer[offset + i]; + + i += d; + + e = s & ((1 << (-nBits)) - 1); + s >>= (-nBits); + nBits += eLen; + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1); + e >>= (-nBits); + nBits += mLen; + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen); + e = e - eBias; + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +function write (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0); + var i = isLE ? 0 : (nBytes - 1); + var d = isLE ? 1 : -1; + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; + + value = Math.abs(value); + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0; + e = eMax; + } else { + e = Math.floor(Math.log(value) / Math.LN2); + if (value * (c = Math.pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen); + e = e + eBias; + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e = 0; + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128; +} + +var toString = {}.toString; + +var isArray = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + + +var INSPECT_MAX_BYTES = 50; + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ +Buffer.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined + ? global$1.TYPED_ARRAY_SUPPORT + : true; + +/* + * Export kMaxLength after typed array support is determined. + */ +kMaxLength(); + +function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff +} + +function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length); + that.__proto__ = Buffer.prototype; + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length); + } + that.length = length; + } + + return that +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from(this, arg, encodingOrOffset, length) +} + +Buffer.poolSize = 8192; // not used by this implementation + +// TODO: Legacy, not needed anymore. Remove in next major version. +Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype; + return arr +}; + +function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) +}; + +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype; + Buffer.__proto__ = Uint8Array; + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) ; +} + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (that, size, fill, encoding) { + assertSize(size); + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) +}; + +function allocUnsafe (that, size) { + assertSize(size); + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0); + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0; + } + } + return that +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) +}; +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) +}; + +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8'; + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0; + that = createBuffer(that, length); + + var actual = that.write(string, encoding); + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual); + } + + return that +} + +function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0; + that = createBuffer(that, length); + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255; + } + return that +} + +function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength; // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array); + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset); + } else { + array = new Uint8Array(array, byteOffset, length); + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = array; + that.__proto__ = Buffer.prototype; + } else { + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array); + } + return that +} + +function fromObject (that, obj) { + if (internalIsBuffer(obj)) { + var len = checked(obj.length) | 0; + that = createBuffer(that, len); + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len); + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') +} + +function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 +} +Buffer.isBuffer = isBuffer$1; +function internalIsBuffer (b) { + return !!(b != null && b._isBuffer) +} + +Buffer.compare = function compare (a, b) { + if (!internalIsBuffer(a) || !internalIsBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +}; + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +}; + +Buffer.concat = function concat (list, length) { + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i; + if (length === undefined) { + length = 0; + for (i = 0; i < list.length; ++i) { + length += list[i].length; + } + } + + var buffer = Buffer.allocUnsafe(length); + var pos = 0; + for (i = 0; i < list.length; ++i) { + var buf = list[i]; + if (!internalIsBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos); + pos += buf.length; + } + return buffer +}; + +function byteLength (string, encoding) { + if (internalIsBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string; + } + + var len = string.length; + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false; + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } +} +Buffer.byteLength = byteLength; + +function slowToString (encoding, start, end) { + var loweredCase = false; + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0; + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length; + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0; + start >>>= 0; + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8'; + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase(); + loweredCase = true; + } + } +} + +// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +// Buffer instances. +Buffer.prototype._isBuffer = true; + +function swap (b, n, m) { + var i = b[n]; + b[n] = b[m]; + b[m] = i; +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length; + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1); + } + return this +}; + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length; + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3); + swap(this, i + 1, i + 2); + } + return this +}; + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length; + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7); + swap(this, i + 1, i + 6); + swap(this, i + 2, i + 5); + swap(this, i + 3, i + 4); + } + return this +}; + +Buffer.prototype.toString = function toString () { + var length = this.length | 0; + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +}; + +Buffer.prototype.equals = function equals (b) { + if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +}; + +Buffer.prototype.inspect = function inspect () { + var str = ''; + var max = INSPECT_MAX_BYTES; + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' '); + if (this.length > max) str += ' ... '; + } + return '' +}; + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!internalIsBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0; + } + if (end === undefined) { + end = target ? target.length : 0; + } + if (thisStart === undefined) { + thisStart = 0; + } + if (thisEnd === undefined) { + thisEnd = this.length; + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0; + end >>>= 0; + thisStart >>>= 0; + thisEnd >>>= 0; + + if (this === target) return 0 + + var x = thisEnd - thisStart; + var y = end - start; + var len = Math.min(x, y); + + var thisCopy = this.slice(thisStart, thisEnd); + var targetCopy = target.slice(start, end); + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i]; + y = targetCopy[i]; + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +}; + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset; + byteOffset = 0; + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff; + } else if (byteOffset < -2147483648) { + byteOffset = -2147483648; + } + byteOffset = +byteOffset; // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1); + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset; + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1; + } else if (byteOffset < 0) { + if (dir) byteOffset = 0; + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding); + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (internalIsBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF; // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1; + var arrLength = arr.length; + var valLength = val.length; + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase(); + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2; + arrLength /= 2; + valLength /= 2; + byteOffset /= 2; + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i; + if (dir) { + var foundIndex = -1; + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i; + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex; + foundIndex = -1; + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; + for (i = byteOffset; i >= 0; i--) { + var found = true; + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false; + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +}; + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +}; + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +}; + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0; + var remaining = buf.length - offset; + if (!length) { + length = remaining; + } else { + length = Number(length); + if (length > remaining) { + length = remaining; + } + } + + // must be an even number of digits + var strLen = string.length; + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2; + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16); + if (isNaN(parsed)) return i + buf[offset + i] = parsed; + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8'; + length = this.length; + offset = 0; + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset; + length = this.length; + offset = 0; + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0; + if (isFinite(length)) { + length = length | 0; + if (encoding === undefined) encoding = 'utf8'; + } else { + encoding = length; + length = undefined; + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset; + if (length === undefined || length > remaining) length = remaining; + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8'; + + var loweredCase = false; + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } +}; + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +}; + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return fromByteArray(buf) + } else { + return fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end); + var res = []; + + var i = start; + while (i < end) { + var firstByte = buf[i]; + var codePoint = null; + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1; + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint; + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte; + } + break + case 2: + secondByte = buf[i + 1]; + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F); + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint; + } + } + break + case 3: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F); + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint; + } + } + break + case 4: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + fourthByte = buf[i + 3]; + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F); + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint; + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD; + bytesPerSequence = 1; + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000; + res.push(codePoint >>> 10 & 0x3FF | 0xD800); + codePoint = 0xDC00 | codePoint & 0x3FF; + } + + res.push(codePoint); + i += bytesPerSequence; + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000; + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length; + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = ''; + var i = 0; + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ); + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F); + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]); + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length; + + if (!start || start < 0) start = 0; + if (!end || end < 0 || end > len) end = len; + + var out = ''; + for (var i = start; i < end; ++i) { + out += toHex(buf[i]); + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end); + var res = ''; + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length; + start = ~~start; + end = end === undefined ? len : ~~end; + + if (start < 0) { + start += len; + if (start < 0) start = 0; + } else if (start > len) { + start = len; + } + + if (end < 0) { + end += len; + if (end < 0) end = 0; + } else if (end > len) { + end = len; + } + + if (end < start) end = start; + + var newBuf; + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = this.subarray(start, end); + newBuf.__proto__ = Buffer.prototype; + } else { + var sliceLen = end - start; + newBuf = new Buffer(sliceLen, undefined); + for (var i = 0; i < sliceLen; ++i) { + newBuf[i] = this[i + start]; + } + } + + return newBuf +}; + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + var val = this[offset]; + var mul = 1; + var i = 0; + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + + return val +}; + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) { + checkOffset(offset, byteLength, this.length); + } + + var val = this[offset + --byteLength]; + var mul = 1; + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul; + } + + return val +}; + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length); + return this[offset] +}; + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + return this[offset] | (this[offset + 1] << 8) +}; + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + return (this[offset] << 8) | this[offset + 1] +}; + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +}; + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +}; + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + var val = this[offset]; + var mul = 1; + var i = 0; + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + mul *= 0x80; + + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + + return val +}; + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + var i = byteLength; + var mul = 1; + var val = this[offset + --i]; + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul; + } + mul *= 0x80; + + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + + return val +}; + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length); + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +}; + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset] | (this[offset + 1] << 8); + return (val & 0x8000) ? val | 0xFFFF0000 : val +}; + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset + 1] | (this[offset] << 8); + return (val & 0x8000) ? val | 0xFFFF0000 : val +}; + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +}; + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +}; + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + return read(this, offset, true, 23, 4) +}; + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + return read(this, offset, false, 23, 4) +}; + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length); + return read(this, offset, true, 52, 8) +}; + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length); + return read(this, offset, false, 52, 8) +}; + +function checkInt (buf, value, offset, ext, max, min) { + if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var mul = 1; + var i = 0; + this[offset] = value & 0xFF; + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF; + } + + return offset + byteLength +}; + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var i = byteLength - 1; + var mul = 1; + this[offset + i] = value & 0xFF; + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF; + } + + return offset + byteLength +}; + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); + this[offset] = (value & 0xff); + return offset + 1 +}; + +function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1; + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8; + } +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff); + this[offset + 1] = (value >>> 8); + } else { + objectWriteUInt16(this, value, offset, true); + } + return offset + 2 +}; + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8); + this[offset + 1] = (value & 0xff); + } else { + objectWriteUInt16(this, value, offset, false); + } + return offset + 2 +}; + +function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1; + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff; + } +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24); + this[offset + 2] = (value >>> 16); + this[offset + 1] = (value >>> 8); + this[offset] = (value & 0xff); + } else { + objectWriteUInt32(this, value, offset, true); + } + return offset + 4 +}; + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24); + this[offset + 1] = (value >>> 16); + this[offset + 2] = (value >>> 8); + this[offset + 3] = (value & 0xff); + } else { + objectWriteUInt32(this, value, offset, false); + } + return offset + 4 +}; + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = 0; + var mul = 1; + var sub = 0; + this[offset] = value & 0xFF; + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1; + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF; + } + + return offset + byteLength +}; + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = byteLength - 1; + var mul = 1; + var sub = 0; + this[offset + i] = value & 0xFF; + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1; + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF; + } + + return offset + byteLength +}; + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128); + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); + if (value < 0) value = 0xff + value + 1; + this[offset] = (value & 0xff); + return offset + 1 +}; + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff); + this[offset + 1] = (value >>> 8); + } else { + objectWriteUInt16(this, value, offset, true); + } + return offset + 2 +}; + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8); + this[offset + 1] = (value & 0xff); + } else { + objectWriteUInt16(this, value, offset, false); + } + return offset + 2 +}; + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff); + this[offset + 1] = (value >>> 8); + this[offset + 2] = (value >>> 16); + this[offset + 3] = (value >>> 24); + } else { + objectWriteUInt32(this, value, offset, true); + } + return offset + 4 +}; + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648); + if (value < 0) value = 0xffffffff + value + 1; + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24); + this[offset + 1] = (value >>> 16); + this[offset + 2] = (value >>> 8); + this[offset + 3] = (value & 0xff); + } else { + objectWriteUInt32(this, value, offset, false); + } + return offset + 4 +}; + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4); + } + write(buf, value, offset, littleEndian, 23, 4); + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +}; + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +}; + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8); + } + write(buf, value, offset, littleEndian, 52, 8); + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +}; + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +}; + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0; + if (!end && end !== 0) end = this.length; + if (targetStart >= target.length) targetStart = target.length; + if (!targetStart) targetStart = 0; + if (end > 0 && end < start) end = start; + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length; + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start; + } + + var len = end - start; + var i; + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start]; + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start]; + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ); + } + + return len +}; + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start; + start = 0; + end = this.length; + } else if (typeof end === 'string') { + encoding = end; + end = this.length; + } + if (val.length === 1) { + var code = val.charCodeAt(0); + if (code < 256) { + val = code; + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255; + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0; + end = end === undefined ? this.length : end >>> 0; + + if (!val) val = 0; + + var i; + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val; + } + } else { + var bytes = internalIsBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()); + var len = bytes.length; + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len]; + } + } + + return this +}; + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g; + +function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, ''); + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '='; + } + return str +} + +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity; + var codePoint; + var length = string.length; + var leadSurrogate = null; + var bytes = []; + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i); + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue + } + + // valid lead + leadSurrogate = codePoint; + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + leadSurrogate = codePoint; + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + } + + leadSurrogate = null; + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint); + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ); + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ); + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ); + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = []; + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF); + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo; + var byteArray = []; + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i); + hi = c >> 8; + lo = c % 256; + byteArray.push(lo); + byteArray.push(hi); + } + + return byteArray +} + + +function base64ToBytes (str) { + return toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i]; + } + return i +} + +function isnan (val) { + return val !== val // eslint-disable-line no-self-compare +} + + +// the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence +// The _isBuffer check is for Safari 5-7 support, because it's missing +// Object.prototype.constructor. Remove this eventually +function isBuffer$1(obj) { + return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj)) +} + +function isFastBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +} + +// For Node v0.10 support. Remove this eventually. +function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0)) +} + +class PNG { + data; + width; + height; + format; + constructor(data) { + const png = new _PNG(data); + this.data = data; + this.width = png.width; + this.height = png.height; + this.format = 'png'; + } + static isValid(data) { + return (data && + Buffer.isBuffer(data) && + data[0] === 137 && + data[1] === 80 && + data[2] === 78 && + data[3] === 71 && + data[4] === 13 && + data[5] === 10 && + data[6] === 26 && + data[7] === 10); + } +} + +class JPEG { + data; + width; + height; + format; + constructor(data) { + this.data = data; + this.format = 'jpeg'; + this.width = 0; + this.height = 0; + if (data.readUInt16BE(0) !== 0xffd8) { + throw new Error('SOI not found in JPEG'); + } + const markers = _JPEG.decode(this.data); + let orientation; + for (let i = 0; i < markers.length; i += 1) { + const marker = markers[i]; + if (marker.name === 'EXIF' && marker.entries.orientation) { + orientation = marker.entries.orientation; + } + if (marker.name === 'SOF') { + this.width ||= marker.width; + this.height ||= marker.height; + } + } + if (orientation > 4) { + [this.width, this.height] = [this.height, this.width]; + } + } + static isValid(data) { + return data && Buffer.isBuffer(data) && data.readUInt16BE(0) === 0xffd8; + } +} + +const UNIT_TO_PT = { + px: 72 / 96, + pt: 1, + in: 72, + cm: 72 / 2.54, + mm: 72 / 25.4, +}; +function parseNumber(value) { + if (typeof value !== 'string') + return undefined; + const match = value.match(/^(-?\d*\.?\d+)(px|pt|in|cm|mm)?$/); + if (!match) + return undefined; + const num = parseFloat(match[1]); + const unit = match[2]; + if (!unit) + return num; + return num * (UNIT_TO_PT[unit] ?? 1); +} +function parseViewBox(value) { + if (typeof value !== 'string') + return undefined; + const parts = value + .trim() + .split(/[\s,]+/) + .map(Number); + if (parts.length !== 4 || parts.some(isNaN)) + return undefined; + return { + minX: parts[0], + minY: parts[1], + maxX: parts[2], + maxY: parts[3], + }; +} +class SVG { + data; + width; + height; + format; + constructor(data) { + const svgString = data.toString('utf-8'); + const parsed = parseSvg(svgString); + const viewBox = parseViewBox(parsed.props.viewBox); + this.data = parsed; + this.format = 'svg'; + this.width = parseNumber(parsed.props.width) ?? viewBox?.maxX ?? 0; + this.height = parseNumber(parsed.props.height) ?? viewBox?.maxY ?? 0; + } + static isValid(data) { + if (!Buffer.isBuffer(data)) + return false; + const str = data.toString('utf-8').trimStart(); + return str.startsWith(' { + let cache = new Map(); + return { + get: (key) => key ? cache.get(key) ?? undefined : null, + set: (key, value) => { + cache.delete(key); + if (cache.size >= limit) { + const firstKey = cache.keys().next().value; + cache.delete(firstKey); + } + cache.set(key, value); + }, + reset: () => { + cache = new Map(); + }, + length: () => cache.size, + }; +}; + +const IMAGE_CACHE = createCache({ limit: 30 }); +const isBuffer = Buffer.isBuffer; +const isBlob = (src) => { + return typeof Blob !== 'undefined' && src instanceof Blob; +}; +const isDataImageSrc = (src) => { + return 'data' in src; +}; +const isDataUri = (imageSrc) => 'uri' in imageSrc && imageSrc.uri.startsWith('data:'); +const fetchRemoteFile = async (src) => { + const { method = 'GET', headers, body, credentials } = src; + const response = await fetch(src.uri, { + method, + headers, + body, + credentials, + }); + const buffer = await response.arrayBuffer(); + return Buffer.from(buffer); +}; +const isValidFormat = (format) => { + const lower = format.toLowerCase(); + return (lower === 'jpg' || + lower === 'jpeg' || + lower === 'png' || + lower === 'svg' || + lower === 'svg+xml'); +}; +const getImageFormat = (buffer) => { + let format; + if (JPEG.isValid(buffer)) { + format = 'jpg'; + } + else if (PNG.isValid(buffer)) { + format = 'png'; + } + else if (SVG.isValid(buffer)) { + format = 'svg'; + } + return format; +}; +function getImage(body, format) { + switch (format.toLowerCase()) { + case 'jpg': + case 'jpeg': + return new JPEG(body); + case 'png': + return new PNG(body); + case 'svg': + case 'svg+xml': + return new SVG(body); + default: + return null; + } +} +const resolveBase64Image = async ({ uri }) => { + const match = /^data:image\/([a-zA-Z+]*);base64,([^"]*)/g.exec(uri); + if (!match) + throw new Error(`Invalid base64 image: ${uri}`); + const format = match[1]; + const data = match[2]; + if (!isValidFormat(format)) + throw new Error(`Base64 image invalid format: ${format}`); + return getImage(Buffer.from(data, 'base64'), format); +}; +const resolveImageFromData = async (src) => { + if (src.data && src.format) { + return getImage(src.data, src.format); + } + throw new Error(`Invalid data given for local file: ${JSON.stringify(src)}`); +}; +const resolveBufferImage = async (buffer) => { + const format = getImageFormat(buffer); + if (format) { + return getImage(buffer, format); + } + return null; +}; +const resolveBlobImage = async (blob) => { + const { type } = blob; + if (!type || type === 'application/octet-stream') { + const arrayBuffer = await blob.arrayBuffer(); + const buffer = Buffer.from(arrayBuffer); + return resolveBufferImage(buffer); + } + if (!type.startsWith('image/')) { + throw new Error(`Invalid blob type: ${type}`); + } + const format = type.replace('image/', ''); + if (!isValidFormat(format)) { + throw new Error(`Invalid blob type: ${type}`); + } + const buffer = await blob.arrayBuffer(); + return getImage(Buffer.from(buffer), format); +}; +const resolveImageFromUrl = async (src) => { + const data = await fetchRemoteFile(src); + const format = getImageFormat(data); + if (!format) { + throw new Error('Not valid image extension'); + } + return getImage(data, format); +}; +const getCacheKey = (src) => { + if (isBlob(src) || isBuffer(src)) + return null; + if (isDataImageSrc(src)) + return src.data?.toString('base64') ?? null; + return src.uri; +}; +const resolveImage = (src, { cache = true } = {}) => { + let image; + const cacheKey = getCacheKey(src); + if (isBlob(src)) { + image = resolveBlobImage(src); + } + else if (isBuffer(src)) { + image = resolveBufferImage(src); + } + else if (cache && IMAGE_CACHE.get(cacheKey)) { + return IMAGE_CACHE.get(cacheKey); + } + else if (isDataUri(src)) { + image = resolveBase64Image(src); + } + else if (isDataImageSrc(src)) { + image = resolveImageFromData(src); + } + else { + image = resolveImageFromUrl(src); + } + if (cache && cacheKey) { + IMAGE_CACHE.set(cacheKey, image); + } + return image; +}; + +export { resolveImage as default }; diff --git a/node_modules/@react-pdf/image/lib/index.d.ts b/node_modules/@react-pdf/image/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9018c916ee1926dcc5b7b45366c24cb53cfb35b5 --- /dev/null +++ b/node_modules/@react-pdf/image/lib/index.d.ts @@ -0,0 +1,45 @@ +/// +import { SvgNode } from '@react-pdf/svg'; + +interface RasterImage { + width: number; + height: number; + data: Buffer; + format: 'jpeg' | 'png'; + key?: string; +} +interface SvgImage { + width: number; + height: number; + data: SvgNode; + format: 'svg'; + key?: string; +} +type Image = RasterImage | SvgImage; +type ImageFormat = 'jpg' | 'jpeg' | 'png' | 'svg'; +type DataImageSrc = { + data: Buffer; + format: ImageFormat; +}; +type LocalImageSrc = { + uri: string; + format?: ImageFormat; +}; +type RemoteImageSrc = { + uri: string; + method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; + headers?: Record; + format?: ImageFormat; + body?: any; + credentials?: 'omit' | 'same-origin' | 'include'; +}; +type Base64ImageSrc = { + uri: `data:image${string}`; +}; +type ImageSrc = Blob | Buffer | DataImageSrc | LocalImageSrc | RemoteImageSrc | Base64ImageSrc; + +declare const resolveImage: (src: ImageSrc, { cache }?: { + cache?: boolean | undefined; +}) => Promise | null | undefined; + +export { type Image, type ImageSrc, type RasterImage, type SvgImage, resolveImage as default }; diff --git a/node_modules/@react-pdf/image/lib/index.js b/node_modules/@react-pdf/image/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..170d4b6428c0e942961548cdcb3081eb77947a18 --- /dev/null +++ b/node_modules/@react-pdf/image/lib/index.js @@ -0,0 +1,305 @@ +import fs from 'fs'; +import url from 'url'; +import path from 'path'; +import _PNG from 'png-js'; +import _JPEG from 'jay-peg'; +import { parseSvg } from '@react-pdf/svg'; + +class PNG { + data; + width; + height; + format; + constructor(data) { + const png = new _PNG(data); + this.data = data; + this.width = png.width; + this.height = png.height; + this.format = 'png'; + } + static isValid(data) { + return (data && + Buffer.isBuffer(data) && + data[0] === 137 && + data[1] === 80 && + data[2] === 78 && + data[3] === 71 && + data[4] === 13 && + data[5] === 10 && + data[6] === 26 && + data[7] === 10); + } +} + +class JPEG { + data; + width; + height; + format; + constructor(data) { + this.data = data; + this.format = 'jpeg'; + this.width = 0; + this.height = 0; + if (data.readUInt16BE(0) !== 0xffd8) { + throw new Error('SOI not found in JPEG'); + } + const markers = _JPEG.decode(this.data); + let orientation; + for (let i = 0; i < markers.length; i += 1) { + const marker = markers[i]; + if (marker.name === 'EXIF' && marker.entries.orientation) { + orientation = marker.entries.orientation; + } + if (marker.name === 'SOF') { + this.width ||= marker.width; + this.height ||= marker.height; + } + } + if (orientation > 4) { + [this.width, this.height] = [this.height, this.width]; + } + } + static isValid(data) { + return data && Buffer.isBuffer(data) && data.readUInt16BE(0) === 0xffd8; + } +} + +const UNIT_TO_PT = { + px: 72 / 96, + pt: 1, + in: 72, + cm: 72 / 2.54, + mm: 72 / 25.4, +}; +function parseNumber(value) { + if (typeof value !== 'string') + return undefined; + const match = value.match(/^(-?\d*\.?\d+)(px|pt|in|cm|mm)?$/); + if (!match) + return undefined; + const num = parseFloat(match[1]); + const unit = match[2]; + if (!unit) + return num; + return num * (UNIT_TO_PT[unit] ?? 1); +} +function parseViewBox(value) { + if (typeof value !== 'string') + return undefined; + const parts = value + .trim() + .split(/[\s,]+/) + .map(Number); + if (parts.length !== 4 || parts.some(isNaN)) + return undefined; + return { + minX: parts[0], + minY: parts[1], + maxX: parts[2], + maxY: parts[3], + }; +} +class SVG { + data; + width; + height; + format; + constructor(data) { + const svgString = data.toString('utf-8'); + const parsed = parseSvg(svgString); + const viewBox = parseViewBox(parsed.props.viewBox); + this.data = parsed; + this.format = 'svg'; + this.width = parseNumber(parsed.props.width) ?? viewBox?.maxX ?? 0; + this.height = parseNumber(parsed.props.height) ?? viewBox?.maxY ?? 0; + } + static isValid(data) { + if (!Buffer.isBuffer(data)) + return false; + const str = data.toString('utf-8').trimStart(); + return str.startsWith(' { + let cache = new Map(); + return { + get: (key) => key ? cache.get(key) ?? undefined : null, + set: (key, value) => { + cache.delete(key); + if (cache.size >= limit) { + const firstKey = cache.keys().next().value; + cache.delete(firstKey); + } + cache.set(key, value); + }, + reset: () => { + cache = new Map(); + }, + length: () => cache.size, + }; +}; + +const IMAGE_CACHE = createCache({ limit: 30 }); +const isBuffer = Buffer.isBuffer; +const isBlob = (src) => { + return typeof Blob !== 'undefined' && src instanceof Blob; +}; +const isDataImageSrc = (src) => { + return 'data' in src; +}; +const isDataUri = (imageSrc) => 'uri' in imageSrc && imageSrc.uri.startsWith('data:'); +const getAbsoluteLocalPath = (src) => { + const { protocol, auth, host, port, hostname, path: pathname, } = url.parse(src); + const absolutePath = pathname ? path.resolve(src) : undefined; + if ((protocol && protocol !== 'file:') || auth || host || port || hostname) { + return undefined; + } + return absolutePath; +}; +const fetchLocalFile = (src) => new Promise((resolve, reject) => { + try { + if (false) ; + const absolutePath = getAbsoluteLocalPath(src.uri); + if (!absolutePath) { + reject(new Error(`Cannot fetch non-local path: ${src.uri}`)); + return; + } + fs.readFile(absolutePath, (err, data) => err ? reject(err) : resolve(data)); + } + catch (err) { + reject(err); + } +}); +const fetchRemoteFile = async (src) => { + const { method = 'GET', headers, body, credentials } = src; + const response = await fetch(src.uri, { + method, + headers, + body, + credentials, + }); + const buffer = await response.arrayBuffer(); + return Buffer.from(buffer); +}; +const isValidFormat = (format) => { + const lower = format.toLowerCase(); + return (lower === 'jpg' || + lower === 'jpeg' || + lower === 'png' || + lower === 'svg' || + lower === 'svg+xml'); +}; +const getImageFormat = (buffer) => { + let format; + if (JPEG.isValid(buffer)) { + format = 'jpg'; + } + else if (PNG.isValid(buffer)) { + format = 'png'; + } + else if (SVG.isValid(buffer)) { + format = 'svg'; + } + return format; +}; +function getImage(body, format) { + switch (format.toLowerCase()) { + case 'jpg': + case 'jpeg': + return new JPEG(body); + case 'png': + return new PNG(body); + case 'svg': + case 'svg+xml': + return new SVG(body); + default: + return null; + } +} +const resolveBase64Image = async ({ uri }) => { + const match = /^data:image\/([a-zA-Z+]*);base64,([^"]*)/g.exec(uri); + if (!match) + throw new Error(`Invalid base64 image: ${uri}`); + const format = match[1]; + const data = match[2]; + if (!isValidFormat(format)) + throw new Error(`Base64 image invalid format: ${format}`); + return getImage(Buffer.from(data, 'base64'), format); +}; +const resolveImageFromData = async (src) => { + if (src.data && src.format) { + return getImage(src.data, src.format); + } + throw new Error(`Invalid data given for local file: ${JSON.stringify(src)}`); +}; +const resolveBufferImage = async (buffer) => { + const format = getImageFormat(buffer); + if (format) { + return getImage(buffer, format); + } + return null; +}; +const resolveBlobImage = async (blob) => { + const { type } = blob; + if (!type || type === 'application/octet-stream') { + const arrayBuffer = await blob.arrayBuffer(); + const buffer = Buffer.from(arrayBuffer); + return resolveBufferImage(buffer); + } + if (!type.startsWith('image/')) { + throw new Error(`Invalid blob type: ${type}`); + } + const format = type.replace('image/', ''); + if (!isValidFormat(format)) { + throw new Error(`Invalid blob type: ${type}`); + } + const buffer = await blob.arrayBuffer(); + return getImage(Buffer.from(buffer), format); +}; +const resolveImageFromUrl = async (src) => { + const data = getAbsoluteLocalPath(src.uri) + ? await fetchLocalFile(src) + : await fetchRemoteFile(src); + const format = getImageFormat(data); + if (!format) { + throw new Error('Not valid image extension'); + } + return getImage(data, format); +}; +const getCacheKey = (src) => { + if (isBlob(src) || isBuffer(src)) + return null; + if (isDataImageSrc(src)) + return src.data?.toString('base64') ?? null; + return src.uri; +}; +const resolveImage = (src, { cache = true } = {}) => { + let image; + const cacheKey = getCacheKey(src); + if (isBlob(src)) { + image = resolveBlobImage(src); + } + else if (isBuffer(src)) { + image = resolveBufferImage(src); + } + else if (cache && IMAGE_CACHE.get(cacheKey)) { + return IMAGE_CACHE.get(cacheKey); + } + else if (isDataUri(src)) { + image = resolveBase64Image(src); + } + else if (isDataImageSrc(src)) { + image = resolveImageFromData(src); + } + else { + image = resolveImageFromUrl(src); + } + if (cache && cacheKey) { + IMAGE_CACHE.set(cacheKey, image); + } + return image; +}; + +export { resolveImage as default }; diff --git a/node_modules/@react-pdf/image/package.json b/node_modules/@react-pdf/image/package.json new file mode 100644 index 0000000000000000000000000000000000000000..128c929b2b7c163db912ea5fbbe612558847e139 --- /dev/null +++ b/node_modules/@react-pdf/image/package.json @@ -0,0 +1,33 @@ +{ + "name": "@react-pdf/image", + "version": "3.1.0", + "license": "MIT", + "description": "Parses the images in png or jpeg format for react-pdf document", + "author": "Diego Muracciole ", + "homepage": "https://github.com/diegomura/react-pdf#readme", + "type": "module", + "main": "./lib/index.js", + "types": "./lib/index.d.ts", + "browser": { + "./lib/index.js": "./lib/index.browser.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/diegomura/react-pdf.git", + "directory": "packages/image" + }, + "scripts": { + "test": "vitest", + "build": "rimraf ./lib && rollup -c", + "watch": "rimraf ./lib && rollup -c -w", + "typecheck": "tsc --noEmit" + }, + "dependencies": { + "@react-pdf/svg": "^1.1.0", + "jay-peg": "^1.1.1", + "png-js": "^2.0.0" + }, + "files": [ + "lib" + ] +} diff --git a/node_modules/@react-pdf/layout/README.md b/node_modules/@react-pdf/layout/README.md new file mode 100644 index 0000000000000000000000000000000000000000..fff8ba5adfad6a41a42b0537e27d989d512fca98 --- /dev/null +++ b/node_modules/@react-pdf/layout/README.md @@ -0,0 +1,5 @@ +

+ +

+ +# @react-pdf/layout diff --git a/node_modules/@react-pdf/layout/lib/index.d.ts b/node_modules/@react-pdf/layout/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0f096cc3faef7db7f6b56ee9b96bf449d35ac355 --- /dev/null +++ b/node_modules/@react-pdf/layout/lib/index.d.ts @@ -0,0 +1,977 @@ +/// +/// +import { Style, SafeStyle, Transform } from '@react-pdf/stylesheet'; +import { YogaNode } from 'yoga-layout/load'; +import * as React from 'react'; +import * as P from '@react-pdf/primitives'; +import { Paragraph } from '@react-pdf/textkit'; +import { SrcSet, Sizes, HitSlop } from '@react-pdf/types'; +import { Image } from '@react-pdf/image'; +import { HyphenationCallback } from '@react-pdf/font'; + +interface LineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x1: string | number; + x2: string | number; + y1: string | number; + y2: string | number; +} +interface SafeLineProps extends SafeSVGPresentationAttributes { + style?: SafeSVGPresentationAttributes; + x1: number; + x2: number; + y1: number; + y2: number; +} +type LineNode = { + type: typeof P.Line; + props: LineProps; + style?: Style | Style[]; + box?: never; + origin?: never; + yogaNode?: never; + children?: never[]; +}; +type SafeLineNode = Omit & { + style: SafeStyle; + props: SafeLineProps; +}; + +interface PolylineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; +} +interface SafePolylineProps extends SafeSVGPresentationAttributes { + style?: SafeSVGPresentationAttributes; + points: string; +} +type PolylineNode = { + type: typeof P.Polyline; + props: PolylineProps; + style?: Style | Style[]; + box?: never; + origin?: never; + yogaNode?: never; + children?: never[]; +}; +type SafePolylineNode = Omit & { + style: SafeStyle; + props: SafePolylineProps; +}; + +interface PolygonProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; +} +interface SafePolygonProps extends SafeSVGPresentationAttributes { + style?: SafeSVGPresentationAttributes; + points: string; +} +type PolygonNode = { + type: typeof P.Polygon; + props: PolygonProps; + style?: Style | Style[]; + box?: never; + origin?: never; + yogaNode?: never; + children?: never[]; +}; +type SafePolygonNode = Omit & { + style: SafeStyle; + props: SafePolygonProps; +}; + +interface PathProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + d: string; +} +interface SafePathProps extends SafeSVGPresentationAttributes { + style?: SafeSVGPresentationAttributes; + d: string; +} +type PathNode = { + type: typeof P.Path; + props: PathProps; + style?: Style | Style[]; + box?: never; + origin?: never; + yogaNode?: never; + children?: never[]; +}; +type SafePathNode = Omit & { + style: SafeStyle; + props: SafePathProps; +}; + +interface RectProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x?: string | number; + y?: string | number; + width: string | number; + height: string | number; + rx?: string | number; + ry?: string | number; +} +interface SafeRectProps extends SafeSVGPresentationAttributes { + style?: SafeSVGPresentationAttributes; + x?: number; + y?: number; + width: number; + height: number; + rx?: number; + ry?: number; +} +type RectNode = { + type: typeof P.Rect; + props: RectProps; + style?: Style | Style[]; + box?: never; + origin?: never; + yogaNode?: never; + children?: never[]; +}; +type SafeRectNode = Omit & { + style: SafeStyle; + props: SafeRectProps; +}; + +interface CircleProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + r: string | number; +} +interface SafeCircleProps extends SafeSVGPresentationAttributes { + style?: SafeSVGPresentationAttributes; + cx?: number; + cy?: number; + r: number; +} +type CircleNode = { + type: typeof P.Circle; + props: CircleProps; + style?: Style | Style[]; + box?: never; + origin?: Origin; + yogaNode?: never; + children?: never[]; +}; +type SafeCircleNode = Omit & { + style: SafeStyle; + props: SafeCircleProps; +}; + +interface EllipseProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + rx: string | number; + ry: string | number; +} +interface SafeEllipseProps extends SafeSVGPresentationAttributes { + style?: SafeSVGPresentationAttributes; + cx?: number; + cy?: number; + rx: number; + ry: number; +} +type EllipseNode = { + type: typeof P.Ellipse; + props: EllipseProps; + style?: Style | Style[]; + box?: never; + origin?: never; + yogaNode?: never; + children?: never[]; +}; +type SafeEllipseNode = Omit & { + style: SafeStyle; + props: SafeEllipseProps; +}; + +interface ClipPathProps { + id?: string; +} +type ClipPathNode = { + type: typeof P.ClipPath; + props: ClipPathProps; + style: never; + box?: never; + origin?: never; + yogaNode?: never; + children?: (LineNode | PolylineNode | PolygonNode | PathNode | RectNode | CircleNode | EllipseNode)[]; +}; +type SafeClipPathNode = Omit & { + children?: (SafeLineNode | SafePolylineNode | SafePolygonNode | SafePathNode | SafeRectNode | SafeCircleNode | SafeEllipseNode)[]; +}; + +interface StopProps { + offset: string | number; + stopColor: string; + stopOpacity?: string | number; +} +interface StopSafeProps { + offset: number; + stopColor: string; + stopOpacity?: number; +} +type StopNode = { + type: typeof P.Stop; + props: StopProps; + style?: never; + box?: never; + origin?: never; + yogaNode?: never; + children?: never[]; +}; +type SafeStopNode = Omit & { + props: StopSafeProps; +}; + +interface LinearGradientProps { + id: string; + x1?: string | number; + x2?: string | number; + y1?: string | number; + y2?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; +} +interface SafeLinearGradientProps { + id: string; + x1?: number; + x2?: number; + y1?: number; + y2?: number; + xlinkHref?: string; + gradientTransform?: Transform[]; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; +} +type LinearGradientNode = { + type: typeof P.LinearGradient; + props: LinearGradientProps; + style?: never; + box?: never; + origin?: never; + yogaNode?: never; + children?: StopNode[]; +}; +type SafeLinearGradientNode = Omit & { + props: SafeLinearGradientProps; + children?: SafeStopNode[]; +}; + +type TextInstanceNode = { + type: typeof P.TextInstance; + props?: never; + style?: never; + box?: never; + origin?: never; + children?: never[]; + yogaNode?: never; + value: string; +}; +type SafeTextInstanceNode = TextInstanceNode; + +interface TspanProps extends SVGPresentationAttributes { + x?: string | number; + y?: string | number; +} +interface SafeTspanProps extends SafeSVGPresentationAttributes { + x?: number; + y?: number; +} +type TspanNode = { + type: typeof P.Tspan; + props: TspanProps; + style?: Style | Style[]; + box?: never; + origin?: never; + yogaNode?: never; + lines?: Paragraph; + children?: TextInstanceNode[]; +}; +type SafeTspanNode = Omit & { + style: SafeStyle; + props: SafeTspanProps; + children?: SafeTextInstanceNode[]; +}; + +type HTTPMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; +type SourceURL = string; +type SourceBuffer = Buffer; +type SourceBlob = Blob; +type SourceDataBuffer = { + data: Buffer; + format: 'png' | 'jpg'; +}; +type SourceURLObject = { + uri: string; + method?: HTTPMethod; + body?: any; + headers?: any; + credentials?: 'omit' | 'same-origin' | 'include'; +}; +type Source = SourceURL | SourceBuffer | SourceBlob | SourceDataBuffer | SourceURLObject | undefined; +type SourceFactory = () => Source; +type SourceAsync = Promise; +type SourceAsyncFactory = () => Promise; +type SourceObject = Source | SourceFactory | SourceAsync | SourceAsyncFactory; +interface BaseImageProps extends NodeProps { + cache?: boolean; + x?: number; + y?: number; + srcSet?: SrcSet; + sizes?: Sizes; +} +interface ImageWithSrcProp extends BaseImageProps { + src: SourceObject; + source?: never; +} +interface ImageWithSourceProp extends BaseImageProps { + source: SourceObject; + src?: never; +} +type ImageProps = ImageWithSrcProp | ImageWithSourceProp; +type ImageNode = { + type: typeof P.Image; + props: ImageProps; + image?: Image; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: never[]; +}; +type SafeImageNode = Omit & { + style: SafeStyle; +}; + +interface TextProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + render?: RenderProp; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + /** + * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + orphans?: number; + /** + * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container.. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + widows?: number; + x?: number; + y?: number; +} +type TextNode = { + type: typeof P.Text; + props: TextProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + lines?: Paragraph; + alignOffset?: number; + children?: (TextNode | TextInstanceNode | ImageNode | TspanNode)[]; +}; +type SafeTextNode = Omit & { + style: SafeStyle; + children?: (SafeTextNode | SafeTextInstanceNode | SafeImageNode | SafeTspanNode)[]; +}; + +interface GProps extends SVGPresentationAttributes { + style?: Style | Style[]; +} +interface SafeGProps extends SafeSVGPresentationAttributes { + style?: Style; +} +type GNode = { + type: typeof P.G; + props: GProps; + style?: Style | Style[]; + box?: never; + origin?: never; + yogaNode?: never; + children?: (LineNode | PolylineNode | PolygonNode | PathNode | RectNode | CircleNode | EllipseNode | ImageNode | TextNode | TspanNode | GNode)[]; +}; +type SafeGNode = Omit & { + style: SafeStyle; + props: SafeGProps; + children?: (SafeLineNode | SafePolylineNode | SafePolygonNode | SafePathNode | SafeRectNode | SafeCircleNode | SafeEllipseNode | SafeImageNode | SafeTextNode | SafeTspanNode | SafeGNode)[]; +}; + +interface RadialGradientProps { + id: string; + cx?: string | number; + cy?: string | number; + fr?: string | number; + fx?: string | number; + fy?: string | number; + r?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; +} +interface SafeRadialGradientProps { + id: string; + cx?: number; + cy?: number; + fr?: number; + fx?: number; + fy?: number; + r?: number; + xlinkHref?: string; + gradientTransform?: Transform[]; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; +} +type RadialGradientNode = { + type: typeof P.RadialGradient; + props: RadialGradientProps; + style?: never; + box?: never; + origin?: never; + yogaNode?: never; + children?: StopNode[]; +}; +type SafeRadialGradientNode = Omit & { + props: SafeRadialGradientProps; + children?: SafeStopNode[]; +}; + +type DefsNode = { + type: typeof P.Defs; + props?: never; + style?: never; + box?: never; + origin?: never; + yogaNode?: never; + children?: (ClipPathNode | LinearGradientNode | RadialGradientNode | MarkerNode)[]; +}; +type Defs = Record; +type SafeDefsNode = Omit & { + children?: (SafeClipPathNode | SafeLinearGradientNode | SafeRadialGradientNode | SafeMarkerNode)[]; +}; +type SafeDefs = Record; + +type Viewbox = { + minX: number; + minY: number; + maxX: number; + maxY: number; +}; +type PreserveAspectRatio = { + align: 'none' | 'xMinYMin' | 'xMidYMin' | 'xMaxYMin' | 'xMinYMid' | 'xMidYMid' | 'xMaxYMid' | 'xMinYMax' | 'xMidYMax' | 'xMaxYMax'; + meetOrSlice: 'meet' | 'slice'; +}; +interface SvgProps extends NodeProps, SVGPresentationAttributes { + width?: string | number; + height?: string | number; + viewBox?: string | Viewbox; + preserveAspectRatio?: string; +} +interface SvgSafeProps extends NodeProps, SafeSVGPresentationAttributes { + width?: string | number; + height?: string | number; + viewBox?: Viewbox; + preserveAspectRatio?: PreserveAspectRatio; +} +type SvgNode = { + type: typeof P.Svg; + props: SvgProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: (LineNode | PolylineNode | PolygonNode | PathNode | RectNode | CircleNode | EllipseNode | ImageNode | TextNode | TspanNode | GNode | DefsNode)[]; +}; +type SafeSvgNode = Omit & { + style: SafeStyle; + props: SvgSafeProps; + children?: (SafeLineNode | SafePolylineNode | SafePolygonNode | SafePathNode | SafeRectNode | SafeCircleNode | SafeEllipseNode | SafeImageNode | SafeTextNode | SafeTspanNode | SafeGNode | SafeDefsNode)[]; +}; + +type MarkerOrient = 'auto' | 'auto-start-reverse' | number; +interface MarkerProps { + id: string; + viewBox?: string; + refX?: string | number; + refY?: string | number; + markerWidth?: string | number; + markerHeight?: string | number; + orient?: MarkerOrient; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; +} +interface SafeMarkerProps { + id: string; + viewBox?: Viewbox; + refX?: number; + refY?: number; + markerWidth?: number; + markerHeight?: number; + orient?: MarkerOrient; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; +} +type MarkerNode = { + type: typeof P.Marker; + props: MarkerProps; + style?: never; + box?: never; + origin?: never; + yogaNode?: never; + children?: (LineNode | PolylineNode | PolygonNode | PathNode | RectNode | CircleNode | EllipseNode | GNode)[]; +}; +type SafeMarkerNode = Omit & { + props: SafeMarkerProps; + children?: (SafeLineNode | SafePolylineNode | SafePolygonNode | SafePathNode | SafeRectNode | SafeCircleNode | SafeEllipseNode | SafeGNode)[]; +}; + +type YogaInstance = { + node: { + create: () => YogaNode; + }; +}; +type Box = { + width: number; + height: number; + top: number; + left: number; + right: number; + bottom: number; + marginTop?: number; + marginRight?: number; + marginBottom?: number; + marginLeft?: number; + paddingTop?: number; + paddingRight?: number; + paddingBottom?: number; + paddingLeft?: number; + borderTopWidth?: number; + borderRightWidth?: number; + borderBottomWidth?: number; + borderLeftWidth?: number; +}; +type Origin = { + left: number; + top: number; +}; +interface Bookmark { + title: string; + top?: number; + left?: number; + zoom?: number; + fit?: true | false; + expanded?: true | false; + parent?: number; + ref?: number; +} +type DynamicPageProps = { + pageNumber: number; + totalPages?: number; + subPageNumber?: number; + subPageTotalPages?: number; +}; +type RenderProp = (props: DynamicPageProps) => React.ReactNode | null | undefined; +type NodeProps = { + id?: string; + /** + * Render component in all wrapped pages. + * @see https://react-pdf.org/advanced#fixed-components + */ + fixed?: boolean; + /** + * Force the wrapping algorithm to start a new page when rendering the + * element. + * @see https://react-pdf.org/advanced#page-breaks + */ + break?: boolean; + /** + * Hint that no page wrapping should occur between all sibling elements following the element within n points + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + minPresenceAhead?: number; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + /** + * Bookmark for the element. + * @see https://react-pdf.org/advanced#bookmarks + */ + bookmark?: string | Bookmark; +}; +type FillRule = 'nonzero' | 'evenodd'; +type TextAnchor = 'start' | 'middle' | 'end'; +type StrokeLinecap = 'butt' | 'round' | 'square'; +type StrokeLinejoin = 'butt' | 'round' | 'square' | 'miter' | 'bevel'; +type Visibility = 'visible' | 'hidden' | 'collapse'; +type DominantBaseline = 'auto' | 'middle' | 'central' | 'hanging' | 'mathematical' | 'text-after-edge' | 'text-before-edge'; +type SVGPresentationAttributes = { + fill?: string; + color?: string; + stroke?: string; + transform?: string; + strokeDasharray?: string; + opacity?: string | number; + strokeWidth?: string | number; + fillOpacity?: string | number; + fillRule?: FillRule; + strokeOpacity?: string | number; + textAnchor?: TextAnchor; + strokeLinecap?: StrokeLinecap; + strokeLinejoin?: StrokeLinejoin; + visibility?: Visibility; + clipPath?: string; + dominantBaseline?: DominantBaseline; + markerStart?: string; + markerMid?: string; + markerEnd?: string; +}; +type SafeSVGPresentationAttributes = { + fill?: string | SafeLinearGradientNode | SafeRadialGradientNode; + color?: string; + stroke?: string; + transform?: Transform[]; + strokeDasharray?: string; + opacity?: number; + strokeWidth?: number; + fillOpacity?: number; + fillRule?: FillRule; + strokeOpacity?: number; + textAnchor?: TextAnchor; + strokeLinecap?: StrokeLinecap; + strokeLinejoin?: StrokeLinejoin; + visibility?: Visibility; + clipPath?: SafeClipPathNode; + dominantBaseline?: DominantBaseline; + markerStart?: SafeMarkerNode; + markerMid?: SafeMarkerNode; + markerEnd?: SafeMarkerNode; +}; +interface FormCommonProps extends NodeProps { + name?: string; + required?: boolean; + noExport?: boolean; + readOnly?: boolean; + value?: number | string; + defaultValue?: number | string; +} + +interface CanvasProps extends NodeProps { + paint: (painter: any, availableWidth?: number, availableHeight?: number) => null; +} +type CanvasNode = { + type: typeof P.Canvas; + props: CanvasProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: never[]; +}; +type SafeCanvasNode = Omit & { + style: SafeStyle; +}; + +interface CheckboxProps extends FormCommonProps { + backgroundColor?: string; + borderColor?: string; + checked?: boolean; + onState?: string; + offState?: string; + xMark?: boolean; +} +type CheckboxNode = { + type: typeof P.Checkbox; + props: CheckboxProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: never[]; +}; +type SafeCheckboxNode = Omit & { + style: SafeStyle; +}; + +interface LinkProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + href?: string; + src?: string; + hitSlop?: HitSlop; + render?: RenderProp; +} +type LinkNode = { + type: typeof P.Link; + props: LinkProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: (ViewNode | ImageNode | TextNode | TextInstanceNode)[]; +}; +type SafeLinkNode = Omit & { + style: SafeStyle; + children?: (SafeViewNode | SafeImageNode | SafeTextNode | SafeTextInstanceNode)[]; +}; + +interface TextInputFormatting { + type: 'date' | 'time' | 'percent' | 'number' | 'zip' | 'zipPlus4' | 'phone' | 'ssn'; + param?: string; + nDec?: number; + sepComma?: boolean; + negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed'; + currency?: string; + currencyPrepend?: boolean; +} +interface TextInputProps extends FormCommonProps { + align?: 'left' | 'center' | 'right'; + multiline?: boolean; + /** + * The text will be masked (e.g. with asterisks). + */ + password?: boolean; + /** + * If set, text entered in the field is not spell-checked + */ + noSpell?: boolean; + format?: TextInputFormatting; + /** + * Sets the fontSize (default or 0 means auto sizing) + */ + fontSize?: number; + /** + * Sets the maximum length (characters) of the text in the field + */ + maxLength?: number; +} +type TextInputNode = { + type: typeof P.TextInput; + props: TextInputProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: never[]; +}; +type SafeTextInputNode = Omit & { + style: SafeStyle; +}; + +interface FieldSetProps extends NodeProps { + name: string; +} +type FieldSetNode = { + type: typeof P.FieldSet; + props: FieldSetProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: (TextNode | ViewNode | TextInputNode)[]; +}; +type SafeFieldSetNode = Omit & { + style: SafeStyle; + children?: (SafeTextNode | SafeViewNode | SafeTextInputNode)[]; +}; + +interface SelectAndListProps extends FormCommonProps { + sort?: boolean; + edit?: boolean; + multiSelect?: boolean; + noSpell?: boolean; + select?: string[]; +} +type SelectNode = { + type: typeof P.Select; + props: SelectAndListProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: never; + children?: never[]; +}; +type SafeSelectNode = Omit & { + style: SafeStyle; +}; +type ListNode = { + type: typeof P.List; + props: SelectAndListProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: never[]; +}; +type SafeListNode = Omit & { + style: SafeStyle; +}; + +type NoteNode = { + type: typeof P.Note; + props: NodeProps; + style?: Style | Style[]; + box?: never; + origin?: never; + yogaNode?: never; + children?: TextInstanceNode[]; +}; +type SafeNoteNode = Omit & { + style: SafeStyle; + children?: SafeTextInstanceNode[]; +}; + +interface ViewProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + render?: RenderProp; +} +type ViewNode = { + type: typeof P.View; + props: ViewProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: (ViewNode | ImageNode | ImageBackgroundNode | TextNode | LinkNode | CanvasNode | FieldSetNode | TextInputNode | SelectNode | ListNode | CheckboxNode | NoteNode)[]; +}; +type SafeViewNode = Omit & { + style: SafeStyle; + children?: (SafeViewNode | SafeImageNode | SafeImageBackgroundNode | SafeTextNode | SafeLinkNode | SafeCanvasNode | SafeFieldSetNode | SafeTextInputNode | SafeSelectNode | SafeListNode | SafeCanvasNode | SafeNoteNode)[]; +}; + +interface BaseImageBackgroundProps extends NodeProps { + cache?: boolean; + srcSet?: SrcSet; + sizes?: Sizes; + imageStyle?: Style; + wrap?: boolean; +} +interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps { + src: SourceObject; + source?: never; +} +interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps { + source: SourceObject; + src?: never; +} +type ImageBackgroundProps = ImageBackgroundWithSrcProp | ImageBackgroundWithSourceProp; +type ImageBackgroundNode = { + type: typeof P.ImageBackground; + props: ImageBackgroundProps; + image?: Image; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: (ViewNode | ImageNode | TextNode | LinkNode | CanvasNode | FieldSetNode | TextInputNode | SelectNode | ListNode | CheckboxNode | NoteNode)[]; +}; +type SafeImageBackgroundNode = Omit & { + style: SafeStyle; + children?: (SafeViewNode | SafeImageNode | SafeTextNode | SafeLinkNode | SafeCanvasNode | SafeFieldSetNode | SafeTextInputNode | SafeSelectNode | SafeListNode | SafeCheckboxNode | SafeNoteNode)[]; +}; + +type Orientation = 'portrait' | 'landscape'; +type StandardPageSize = '4A0' | '2A0' | 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6' | 'A7' | 'A8' | 'A9' | 'A10' | 'B0' | 'B1' | 'B2' | 'B3' | 'B4' | 'B5' | 'B6' | 'B7' | 'B8' | 'B9' | 'B10' | 'C0' | 'C1' | 'C2' | 'C3' | 'C4' | 'C5' | 'C6' | 'C7' | 'C8' | 'C9' | 'C10' | 'RA0' | 'RA1' | 'RA2' | 'RA3' | 'RA4' | 'SRA0' | 'SRA1' | 'SRA2' | 'SRA3' | 'SRA4' | 'EXECUTIVE' | 'FOLIO' | 'LEGAL' | 'LETTER' | 'TABLOID' | 'ID1'; +type StaticSize = number | string; +type PageSize = number | StandardPageSize | [StaticSize] | [StaticSize, StaticSize] | { + width: StaticSize; + height?: StaticSize; +}; +interface PageProps extends NodeProps { + /** + * Enable page wrapping for this page. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + size?: PageSize; + orientation?: Orientation; + dpi?: number; +} +type PageNode = { + type: typeof P.Page; + props: PageProps; + style?: Style | Style[]; + box?: Box; + origin?: Origin; + yogaNode?: YogaNode; + children?: (ViewNode | ImageNode | ImageBackgroundNode | TextNode | LinkNode | CanvasNode | FieldSetNode | TextInputNode | SelectNode | ListNode | CheckboxNode | NoteNode)[]; +}; +type SafePageNode = Omit & { + style: SafeStyle; + children?: (SafeViewNode | SafeImageNode | SafeImageBackgroundNode | SafeTextNode | SafeLinkNode | SafeCanvasNode | SafeFieldSetNode | SafeTextInputNode | SafeSelectNode | SafeListNode | SafeCheckboxNode | SafeNoteNode)[]; +}; + +type PDFVersion = '1.3' | '1.4' | '1.5' | '1.6' | '1.7' | '1.7ext3'; +type PageLayout = 'singlePage' | 'oneColumn' | 'twoColumnLeft' | 'twoColumnRight' | 'twoPageLeft' | 'twoPageRight'; +type PageMode = 'useNone' | 'useOutlines' | 'useThumbs' | 'fullScreen' | 'useOC' | 'useAttachments'; +interface OnRenderProps { + blob?: Blob; +} +type Permissions = { + printing?: 'lowResolution' | 'highResolution'; + modifying?: boolean; + copying?: boolean; + annotating?: boolean; + fillingForms?: boolean; + contentAccessibility?: boolean; + documentAssembly?: boolean; +}; +type DocumentProps = { + bookmark?: never; + title?: string; + author?: string; + subject?: string; + creator?: string; + keywords?: string; + producer?: string; + language?: string; + creationDate?: Date; + modificationDate?: Date; + pdfVersion?: PDFVersion; + pageMode?: PageMode; + pageLayout?: PageLayout; + ownerPassword?: string; + userPassword?: string; + permissions?: Permissions; + onRender?: (props: OnRenderProps) => any; +}; +type DocumentNode = { + type: typeof P.Document; + props: DocumentProps; + box?: never; + origin?: never; + style?: Style | Style[]; + yoga?: YogaInstance; + yogaNode?: never; + children: PageNode[]; +}; +type SafeDocumentNode = Omit & { + style: SafeStyle; + children: SafePageNode[]; +}; + +type Node = DocumentNode | PageNode | ImageNode | ImageBackgroundNode | SvgNode | CircleNode | ClipPathNode | DefsNode | EllipseNode | GNode | LineNode | LinearGradientNode | MarkerNode | PathNode | PolygonNode | PolylineNode | RadialGradientNode | RectNode | StopNode | TspanNode | ViewNode | LinkNode | TextNode | TextInstanceNode | NoteNode | CanvasNode | FieldSetNode | TextInputNode | SelectNode | ListNode | CheckboxNode; +type SafeNode = SafeDocumentNode | SafePageNode | SafeImageNode | SafeImageBackgroundNode | SafeSvgNode | SafeCircleNode | SafeClipPathNode | SafeDefsNode | SafeEllipseNode | SafeGNode | SafeLineNode | SafeLinearGradientNode | SafeMarkerNode | SafePathNode | SafePolygonNode | SafePolylineNode | SafeRadialGradientNode | SafeRectNode | SafeStopNode | SafeTspanNode | SafeViewNode | SafeLinkNode | SafeTextNode | SafeTextInstanceNode | SafeNoteNode | SafeCanvasNode | SafeFieldSetNode | SafeTextInputNode | SafeSelectNode | SafeListNode | SafeCheckboxNode; + +declare const layout: (value: DocumentNode) => Promise; + +export { type Bookmark, type Box, type CanvasNode, type CheckboxNode, type CircleNode, type ClipPathNode, type Defs, type DefsNode, type DocumentNode, type DocumentProps, type DominantBaseline, type DynamicPageProps, type EllipseNode, type FieldSetNode, type FillRule, type FormCommonProps, type GNode, type ImageBackgroundNode, type ImageBackgroundProps, type ImageNode, type ImageProps, type LineNode, type LinearGradientNode, type LinkNode, type ListNode, type MarkerNode, type Node, type NodeProps, type NoteNode, type OnRenderProps, type Orientation, type Origin, type PDFVersion, type PageLayout, type PageMode, type PageNode, type PageSize, type PathNode, type Permissions, type PolygonNode, type PolylineNode, type PreserveAspectRatio, type RadialGradientNode, type RectNode, type RenderProp, type SVGPresentationAttributes, type SafeCanvasNode, type SafeCheckboxNode, type SafeCircleNode, type SafeClipPathNode, type SafeDefs, type SafeDefsNode, type SafeDocumentNode, type SafeEllipseNode, type SafeFieldSetNode, type SafeGNode, type SafeImageBackgroundNode, type SafeImageNode, type SafeLineNode, type SafeLinearGradientNode, type SafeLinkNode, type SafeListNode, type SafeMarkerNode, type SafeNode, type SafeNoteNode, type SafePageNode, type SafePathNode, type SafePolygonNode, type SafePolylineNode, type SafeRadialGradientNode, type SafeRectNode, type SafeSVGPresentationAttributes, type SafeSelectNode, type SafeStopNode, type SafeSvgNode, type SafeTextInputNode, type SafeTextInstanceNode, type SafeTextNode, type SafeTspanNode, type SafeViewNode, type SelectNode, type SourceObject, type StandardPageSize, type StopNode, type StrokeLinecap, type StrokeLinejoin, type SvgNode, type TextAnchor, type TextInputNode, type TextInstanceNode, type TextNode, type TspanNode, type ViewNode, type Viewbox, type Visibility, type YogaInstance, layout as default }; diff --git a/node_modules/@react-pdf/layout/lib/index.js b/node_modules/@react-pdf/layout/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b7ea5e30fddb9bdef0034c00f28bbd4f0dee584a --- /dev/null +++ b/node_modules/@react-pdf/layout/lib/index.js @@ -0,0 +1,3298 @@ +import { upperFirst, capitalize, parseFloat as parseFloat$1, without, pick, compose, evolve, mapValues, matchPercent, castArray, isNil, omit, asyncCompose } from '@react-pdf/fns'; +import * as P from '@react-pdf/primitives'; +import resolveStyle, { transformColor, flatten } from '@react-pdf/stylesheet'; +import layoutEngine, { fontSubstitution, wordHyphenation, scriptItemizer, textDecoration, justification, linebreaker, bidi, fromFragments } from '@react-pdf/textkit'; +import * as Yoga from 'yoga-layout/load'; +import { loadYoga as loadYoga$1 } from 'yoga-layout/load'; +import emojiRegex from 'emoji-regex-xs'; +import resolveImage from '@react-pdf/image'; + +/** + * Apply transformation to text string + * + * @param {string} text + * @param {string} transformation type + * @returns {string} transformed text + */ +const transformText = (text, transformation) => { + switch (transformation) { + case 'uppercase': + return text.toUpperCase(); + case 'lowercase': + return text.toLowerCase(); + case 'capitalize': + return capitalize(text); + case 'upperfirst': + return upperFirst(text); + default: + return text; + } +}; + +const isTspan = (node) => node.type === P.Tspan; +const isTextInstance$4 = (node) => node.type === P.TextInstance; +const engines$1 = { + bidi, + linebreaker, + justification, + textDecoration, + scriptItemizer, + wordHyphenation, + fontSubstitution, +}; +const engine$1 = layoutEngine(engines$1); +const getFragments$1 = (fontStore, instance) => { + if (!instance) + return [{ string: '' }]; + const fragments = []; + const { fill = 'black', fontFamily = 'Helvetica', fontWeight, fontStyle, fontSize = 18, textDecorationColor, textDecorationStyle, textTransform, opacity, } = instance.props; + const _textDecoration = instance.props.textDecoration; + const fontFamilies = typeof fontFamily === 'string' ? [fontFamily] : [...(fontFamily || [])]; + // Fallback font + fontFamilies.push('Helvetica'); + const font = fontFamilies.map((fontFamilyName) => { + const opts = { fontFamily: fontFamilyName, fontWeight, fontStyle }; + const obj = fontStore.getFont(opts); + return obj?.data; + }); + const attributes = { + font, + opacity, + fontSize, + color: fill, + underlineStyle: textDecorationStyle, + underline: _textDecoration === 'underline' || + _textDecoration === 'underline line-through' || + _textDecoration === 'line-through underline', + underlineColor: textDecorationColor || fill, + strike: _textDecoration === 'line-through' || + _textDecoration === 'underline line-through' || + _textDecoration === 'line-through underline', + strikeStyle: textDecorationStyle, + strikeColor: textDecorationColor || fill, + }; + for (let i = 0; i < instance.children.length; i += 1) { + const child = instance.children[i]; + if (isTextInstance$4(child)) { + fragments.push({ + string: transformText(child.value, textTransform), + attributes, + }); + } + else if (child) { + fragments.push(...getFragments$1(fontStore, child)); + } + } + return fragments; +}; +const getAttributedString$1 = (fontStore, instance) => fromFragments(getFragments$1(fontStore, instance)); +const AlmostInfinity = 999999999999; +const shrinkWhitespaceFactor = { before: -0.5, after: -0.5 }; +const layoutTspan = (fontStore) => (node, xOffset) => { + const attributedString = getAttributedString$1(fontStore, node); + const x = node.props.x === undefined ? xOffset : node.props.x; + const y = node.props?.y || 0; + const container = { x, y, width: AlmostInfinity, height: AlmostInfinity }; + const hyphenationCallback = node.props.hyphenationCallback || + fontStore?.getHyphenationCallback() || + null; + const layoutOptions = { hyphenationCallback, shrinkWhitespaceFactor }; + const lines = engine$1(attributedString, container, layoutOptions).flat(); + return Object.assign({}, node, { lines }); +}; +// Consecutive TSpan elements should be joined with a space +const joinTSpanLines = (node) => { + const children = node.children.map((child, index) => { + if (!isTspan(child)) + return child; + const textInstance = child.children[0]; + if (child.props.x === undefined && + index < node.children.length - 1 && + textInstance?.value) { + return Object.assign({}, child, { + children: [{ ...textInstance, value: `${textInstance.value} ` }], + }); + } + return child; + }, []); + return Object.assign({}, node, { children }); +}; +const layoutText$1 = (fontStore, node) => { + if (!node.children) + return node; + let currentXOffset = node.props?.x || 0; + const layoutFn = layoutTspan(fontStore); + const joinedNode = joinTSpanLines(node); + const children = joinedNode.children.map((child) => { + const childWithLayout = layoutFn(child, currentXOffset); + currentXOffset += childWithLayout.lines[0].xAdvance; + return childWithLayout; + }); + return Object.assign({}, node, { children }); +}; + +const isDefs$1 = (node) => node.type === P.Defs; +const getDefs = (node) => { + const children = node.children || []; + const defs = children.find(isDefs$1); + const values = defs?.children || []; + return values.reduce((acc, value) => { + const id = value.props?.id; + if (id) + acc[id] = value; + return acc; + }, {}); +}; + +const isNotDefs = (node) => node.type !== P.Defs; +const detachDefs = (node) => { + if (!node.children) + return node; + const children = node.children.filter(isNotDefs); + return Object.assign({}, node, { children }); +}; +const URL_REGEX$1 = /url\(['"]?#([^'"]+)['"]?\)/; +const replaceDef = (defs, value) => { + if (!value) + return undefined; + if (!URL_REGEX$1.test(value)) + return value; + const match = value.match(URL_REGEX$1); + return defs[match[1]]; +}; +const parseNodeDefs = (defs) => (node) => { + const props = node.props; + const fill = `fill` in props ? replaceDef(defs, props?.fill) : undefined; + const clipPath = `clipPath` in props + ? replaceDef(defs, props?.clipPath) + : undefined; + const markerStart = `markerStart` in props + ? replaceDef(defs, props?.markerStart) + : undefined; + const markerMid = `markerMid` in props + ? replaceDef(defs, props?.markerMid) + : undefined; + const markerEnd = `markerEnd` in props + ? replaceDef(defs, props?.markerEnd) + : undefined; + const newProps = Object.assign({}, node.props, { + fill, + clipPath, + markerStart, + markerMid, + markerEnd, + }); + const children = node.children + ? node.children.map(parseNodeDefs(defs)) + : undefined; + return Object.assign({}, node, { props: newProps, children }); +}; +const parseDefs = (root) => { + if (!root.children) + return root; + const defs = getDefs(root); + const children = root.children.map(parseNodeDefs(defs)); + return Object.assign({}, root, { children }); +}; +const replaceDefs = (node) => { + return detachDefs(parseDefs(node)); +}; + +const parseViewbox = (value) => { + if (!value) + return null; + if (typeof value !== 'string') + return value; + const values = value.split(/[,\s]+/).map(parseFloat$1); + if (values.length !== 4) + return null; + return { minX: values[0], minY: values[1], maxX: values[2], maxY: values[3] }; +}; + +const getContainer$1 = (node) => { + const viewbox = parseViewbox(node.props.viewBox); + if (viewbox) { + return { width: viewbox.maxX, height: viewbox.maxY }; + } + if (node.props.width && node.props.height) { + return { + width: parseFloat$1(node.props.width), + height: parseFloat$1(node.props.height), + }; + } + return { width: 0, height: 0 }; +}; + +const BASE_SVG_INHERITED_PROPS = [ + 'x', + 'y', + 'clipPath', + 'clipRule', + 'opacity', + 'fill', + 'fillOpacity', + 'fillRule', + 'stroke', + 'strokeLinecap', + 'strokeLinejoin', + 'strokeOpacity', + 'strokeWidth', + 'textAnchor', + 'dominantBaseline', + 'color', + 'fontFamily', + 'fontSize', + 'fontStyle', + 'fontWeight', + 'letterSpacing', + 'opacity', + 'textDecoration', + 'lineHeight', + 'textAlign', + 'visibility', + 'wordSpacing', +]; +// Do not inherit "x" for elements from parent +const TEXT_SVG_INHERITED_PROPS = without(['x'], BASE_SVG_INHERITED_PROPS); +const SVG_INHERITED_PROPS = { + [P.Text]: TEXT_SVG_INHERITED_PROPS, +}; +const getInheritProps = (node) => { + const props = node.props || {}; + const svgInheritedProps = SVG_INHERITED_PROPS[node.type] ?? BASE_SVG_INHERITED_PROPS; + return pick(svgInheritedProps, props); +}; +const inheritProps = (node) => { + if (!node.children) + return node; + const inheritedProps = getInheritProps(node); + const children = node.children.map((child) => { + const props = Object.assign({}, inheritedProps, child.props || {}); + const newChild = Object.assign({}, child, { props }); + return inheritProps(newChild); + }); + return Object.assign({}, node, { children }); +}; + +const parseAspectRatio = (value) => { + if (typeof value !== 'string') + return value; + const match = value + .replace(/[\s\r\t\n]+/gm, ' ') + .replace(/^defer\s/, '') + .split(' '); + const align = (match[0] || 'xMidYMid'); + const meetOrSlice = (match[1] || + 'meet'); + return { align, meetOrSlice }; +}; + +const isMarker = (node) => node.type === P.Marker; +const STYLE_PROPS = [ + 'width', + 'height', + 'color', + 'stroke', + 'strokeWidth', + 'opacity', + 'fillOpacity', + 'strokeOpacity', + 'fill', + 'fillRule', + 'clipPath', + 'offset', + 'transform', + 'strokeLinejoin', + 'strokeLinecap', + 'strokeDasharray', + 'gradientUnits', + 'gradientTransform', + 'stopColor', + 'stopOpacity', +]; +const VERTICAL_PROPS = ['y', 'y1', 'y2', 'height', 'cy', 'ry']; +const HORIZONTAL_PROPS = ['x', 'x1', 'x2', 'width', 'cx', 'rx']; +const isSvg$3 = (node) => node.type === P.Svg; +const isText$5 = (node) => node.type === P.Text; +const isTextInstance$3 = (node) => node.type === P.TextInstance; +const transformPercent = (container) => (props) => mapValues(props, (value, key) => { + const match = matchPercent(value); + if (match && VERTICAL_PROPS.includes(key)) { + return match.percent * container.height; + } + if (match && HORIZONTAL_PROPS.includes(key)) { + return match.percent * container.width; + } + return value; +}); +const parsePercent = (value) => { + const match = matchPercent(value); + return match ? match.percent : parseFloat$1(value); +}; +const parseTransform = (container) => (value) => { + return resolveStyle(container, { transform: value }).transform; +}; +// Skip transformColor for url() references (gradients, patterns) +const URL_REGEX = /^url\(/; +const transformColorSafe = (value) => { + if (typeof value === 'string' && URL_REGEX.test(value)) { + return value; + } + return transformColor(value); +}; +const parseProps = (container) => (node) => { + let props = transformPercent(container)(node.props); + props = evolve({ + x: parseFloat$1, + x1: parseFloat$1, + x2: parseFloat$1, + y: parseFloat$1, + y1: parseFloat$1, + y2: parseFloat$1, + r: parseFloat$1, + rx: parseFloat$1, + ry: parseFloat$1, + cx: parseFloat$1, + cy: parseFloat$1, + width: parseFloat$1, + height: parseFloat$1, + fontSize: parseFloat$1, + strokeWidth: parseFloat$1, + strokeMiterlimit: parseFloat$1, + strokeDashoffset: parseFloat$1, + offset: parsePercent, + fill: transformColorSafe, + fillOpacity: parsePercent, + opacity: parsePercent, + stroke: transformColorSafe, + strokeOpacity: parsePercent, + stopOpacity: parsePercent, + stopColor: transformColor, + transform: parseTransform(container), + gradientTransform: parseTransform(container), + }, props); + return Object.assign({}, node, { props }); +}; +// SVG spec: if rx is specified but ry is not, ry defaults to rx (and vice versa) +const resolveRectRadius = (node) => { + if (node.type !== P.Rect || !node.props) + return node; + const { rx, ry } = node.props; + // If both are specified or neither is specified, no change needed + if ((rx && ry) || (!rx && !ry)) + return node; + const newProps = Object.assign({}, node.props, { + rx: rx ?? ry, + ry: ry ?? rx, + }); + return Object.assign({}, node, { props: newProps }); +}; +const mergeStyles$1 = (node) => { + const style = node.style || {}; + const props = Object.assign({}, style, node.props); + return Object.assign({}, node, { props }); +}; +const removeNoneValues = (node) => { + const removeNone = (value) => (value === 'none' ? null : value); + const props = mapValues(node.props, removeNone); + return Object.assign({}, node, { props }); +}; +const pickStyleProps = (node) => { + const props = node.props || {}; + const styleProps = pick(STYLE_PROPS, props); + const style = Object.assign({}, styleProps, node.style || {}); + return Object.assign({}, node, { style }); +}; +const parseSvgProps = (node) => { + const props = evolve({ + width: parseFloat$1, + height: parseFloat$1, + viewBox: parseViewbox, + preserveAspectRatio: parseAspectRatio, + }, node.props); + return Object.assign({}, node, { props }); +}; +const wrapBetweenTspan = (node) => ({ + type: P.Tspan, + props: {}, + style: {}, + children: [node], +}); +const addMissingTspan = (node) => { + if (!isText$5(node)) + return node; + if (!node.children) + return node; + const resolveChild = (child) => isTextInstance$3(child) ? wrapBetweenTspan(child) : child; + const children = node.children.map(resolveChild); + return Object.assign({}, node, { children }); +}; +const parseText = (fontStore) => (node) => { + if (isText$5(node)) + return layoutText$1(fontStore, node); + if (!node.children) + return node; + const children = node.children.map(parseText(fontStore)); + return Object.assign({}, node, { children }); +}; +const resolveSvgNode = (container) => compose(parseProps(container), resolveRectRadius, pickStyleProps, addMissingTspan, removeNoneValues, mergeStyles$1); +// Gradient transforms typically don't use percentages, so use minimal container +const ZERO_CONTAINER = { width: 0, height: 0 }; +const parseGradientTransform = parseTransform(ZERO_CONTAINER); +// Process DEFS children (LINEAR_GRADIENT, RADIAL_GRADIENT, STOP) without container-based percent transform +const parseDefsProps = (node) => { + const props = evolve({ + // Gradient coordinates (percent becomes 0-1 range) + x1: parsePercent, + y1: parsePercent, + x2: parsePercent, + y2: parsePercent, + cx: parsePercent, + cy: parsePercent, + fx: parsePercent, + fy: parsePercent, + r: parsePercent, + gradientTransform: parseGradientTransform, + // Stop properties + offset: parsePercent, + stopColor: transformColor, + stopOpacity: parsePercent, + // Marker properties + refX: parseFloat$1, + refY: parseFloat$1, + markerWidth: parseFloat$1, + markerHeight: parseFloat$1, + viewBox: parseViewbox, + }, node.props || {}); + return Object.assign({}, node, { props }); +}; +const getMarkerContainer = (node) => { + const props = node.props || {}; + const viewBox = 'viewBox' in props + ? props.viewBox + : null; + if (viewBox) { + return { width: viewBox.maxX, height: viewBox.maxY }; + } + const markerWidth = 'markerWidth' in props ? props.markerWidth : 3; + const markerHeight = 'markerHeight' in props ? props.markerHeight : 3; + return { width: markerWidth, height: markerHeight }; +}; +const resolveMarkerChildren = (node) => { + if (!node.children) + return node; + const container = getMarkerContainer(node); + const resolveChild = compose(resolveChildren(container), resolveSvgNode(container)); + const children = node.children.map(resolveChild); + return Object.assign({}, node, { children }); +}; +const resolveDefsChildren = (node) => { + if (!node.children) + return node; + const children = node.children.map((child) => { + const parsed = parseDefsProps(child); + if (isMarker(parsed)) + return resolveMarkerChildren(parsed); + return resolveDefsChildren(parsed); + }); + return Object.assign({}, node, { children }); +}; +const isDefs = (node) => node.type === P.Defs; +const resolveChildren = (container) => (node) => { + if (!node.children) + return node; + const resolveChild = compose(resolveChildren(container), resolveSvgNode(container)); + // Process DEFS separately without container-based percent transform + const children = node.children.map((child) => isDefs(child) ? resolveDefsChildren(child) : resolveChild(child)); + return Object.assign({}, node, { children }); +}; +const buildXLinksIndex = (node) => { + const idIndex = {}; + const listToExplore = node.children?.slice(0) || []; + while (listToExplore.length > 0) { + const child = listToExplore.shift(); + if (child.props && 'id' in child.props) { + idIndex[child.props.id] = child; + } + if (child.children) + listToExplore.push(...child.children); + } + return idIndex; +}; +const replaceXLinks = (node, idIndex) => { + if (node.props && 'xlinkHref' in node.props) { + const linkedNode = idIndex[node.props.xlinkHref.replace(/^#/, '')]; + // No node to extend from + if (!linkedNode) + return node; + const newProps = Object.assign({}, linkedNode.props, node.props); + delete newProps.xlinkHref; + return Object.assign({}, linkedNode, { props: newProps }); + } + const children = node.children?.map((child) => replaceXLinks(child, idIndex)); + return Object.assign({}, node, { children }); +}; +const resolveXLinks = (node) => { + const idIndex = buildXLinksIndex(node); + return replaceXLinks(node, idIndex); +}; +const resolveSvgRoot = (node, fontStore) => { + const container = getContainer$1(node); + return compose(replaceDefs, parseText(fontStore), parseSvgProps, pickStyleProps, inheritProps, resolveChildren(container), resolveXLinks)(node); +}; +const isSvgImage = (node) => node.type === P.Image && node.image?.format === 'svg'; +function convertParsedNode(node) { + return { + type: node.type, + props: node.props, + style: {}, + children: node.children?.map(convertParsedNode), + ...('value' in node && { value: node.value }), + }; +} +function convertToSvgNode(imageNode) { + const image = imageNode.image; + const width = imageNode.style?.width ?? image.width; + const height = imageNode.style?.height ?? image.height; + const viewBox = parseViewbox(image.data.props.viewBox); + return { + type: P.Svg, + props: { + width, + height, + viewBox, + preserveAspectRatio: { align: 'xMidYMid', meetOrSlice: 'meet' }, + }, + style: { ...imageNode.style, width, height }, + box: imageNode.box, + origin: imageNode.origin, + yogaNode: imageNode.yogaNode, + children: image.data.children.map(convertParsedNode), + }; +} +/** + * Pre-process SVG nodes so they can be rendered in the next steps. + * Also converts Image nodes containing SVG data into SvgNodes. + * + * @param node - Root node + * @param fontStore - Font store + * @returns Root node + */ +const resolveSvg = (node, fontStore) => { + const resolved = isSvgImage(node) ? convertToSvgNode(node) : node; + if (!('children' in resolved)) + return resolved; + const resolveChild = (child) => resolveSvg(child, fontStore); + const root = isSvg$3(resolved) ? resolveSvgRoot(resolved, fontStore) : resolved; + const children = root.children?.map(resolveChild); + return Object.assign({}, root, { children }); +}; + +let instancePromise; +const loadYoga = async () => { + // Yoga WASM binaries must be asynchronously compiled and loaded + // to prevent Event emitter memory leak warnings, Yoga must be loaded only once + const instance = await (instancePromise ??= loadYoga$1()); + const config = instance.Config.create(); + config.setPointScaleFactor(0); + const node = { create: () => instance.Node.createWithConfig(config) }; + return { node }; +}; + +const resolveYoga = async (root) => { + const yoga = await loadYoga(); + return Object.assign({}, root, { yoga }); +}; + +const getZIndex = (node) => node.style.zIndex; +const shouldSort = (node) => node.type !== P.Document && node.type !== P.Svg; +const sortZIndex = (a, b) => { + const za = getZIndex(a); + const zb = getZIndex(b); + if (!za && !zb) + return 0; + if (!za) + return 1; + if (!zb) + return -1; + return zb - za; +}; +/** + * Sort children by zIndex value + * + * @param node + * @returns Node + */ +const resolveNodeZIndex = (node) => { + if (!node.children) + return node; + const sortedChildren = shouldSort(node) + ? node.children.sort(sortZIndex) + : node.children; + const children = sortedChildren.map(resolveNodeZIndex); + return Object.assign({}, node, { children }); +}; +/** + * Sort children by zIndex value + * + * @param node + * @returns Node + */ +const resolveZIndex = (root) => resolveNodeZIndex(root); + +/* eslint-disable no-console */ +// Caches emoji images data +const emojis = {}; +const regex = emojiRegex(); +/** + * When an emoji as no variations, it might still have 2 parts, + * the canonical emoji and an empty string. + * ex. + * (no color) Array.from('❤️') => ["❤", "️"] + * (w/ color) Array.from('👍🏿') => ["👍", "🏿"] + * + * The empty string needs to be removed otherwise the generated + * url will be incorect. + */ +const removeVariationSelectors = (x) => x !== '️'; +const getCodePoints = (string, withVariationSelectors = false) => Array.from(string) + .filter(withVariationSelectors ? () => true : removeVariationSelectors) + .map((char) => char.codePointAt(0).toString(16)) + .join('-'); +const buildEmojiUrl = (emoji, source) => { + if ('builder' in source) { + return source.builder(getCodePoints(emoji, source.withVariationSelectors)); + } + const { url, format = 'png', withVariationSelectors } = source; + return `${url}${getCodePoints(emoji, withVariationSelectors)}.${format}`; +}; +const fetchEmojis = (string, source) => { + if (!source) + return []; + const promises = []; + Array.from(string.matchAll(regex)).forEach((match) => { + const emoji = match[0]; + if (!emojis[emoji] || emojis[emoji].loading) { + const emojiUrl = buildEmojiUrl(emoji, source); + emojis[emoji] = { loading: true }; + promises.push(resolveImage({ uri: emojiUrl }) + .then((image) => { + emojis[emoji].loading = false; + emojis[emoji].data = image.data; + }) + .catch((e) => { + console.warn(e, 'Failed to load emoji image'); + emojis[emoji].loading = false; + })); + } + }); + return promises; +}; +const embedEmojis = (fragments) => { + const result = []; + for (let i = 0; i < fragments.length; i += 1) { + const fragment = fragments[i]; + let lastIndex = 0; + Array.from(fragment.string.matchAll(regex)).forEach((match) => { + const { index } = match; + const emoji = match[0]; + const emojiSize = fragment.attributes.fontSize; + const chunk = fragment.string.slice(lastIndex, index + match[0].length); + // If emoji image was found, we create a new fragment with the + // correct attachment and object substitution character; + if (emojis[emoji] && emojis[emoji].data) { + result.push({ + string: chunk.replace(match[0], String.fromCharCode(0xfffc)), + attributes: { + ...fragment.attributes, + attachment: { + width: emojiSize, + height: emojiSize, + yOffset: Math.floor(emojiSize * 0.1), + image: emojis[emoji].data, + }, + }, + }); + } + else { + // If no emoji data, we try to use emojis in the font + result.push({ + string: chunk, + attributes: fragment.attributes, + }); + } + lastIndex = index + emoji.length; + }); + if (lastIndex < fragment.string.length) { + result.push({ + string: fragment.string.slice(lastIndex), + attributes: fragment.attributes, + }); + } + } + return result; +}; + +/** + * Parses an HTML-compatible srcSet string into structured entries. + * Only width descriptors (e.g. "300w") are supported. + */ +const parseSrcSet = (srcSet) => { + return srcSet + .split(',') + .map((entry) => entry.trim()) + .filter(Boolean) + .reduce((acc, entry) => { + const parts = entry.split(/\s+/); + const uri = parts[0]; + const descriptor = parts[1]; + if (descriptor && descriptor.endsWith('w')) { + const width = parseFloat(descriptor); + if (!Number.isNaN(width)) + acc.push({ uri, width }); + } + return acc; + }, []); +}; +/** + * Selects the most appropriate image source from a parsed srcSet + * based on the target display width. + * + * Picks the smallest source that is >= targetWidth, + * or the largest available if none are large enough. + */ +const selectSource = (entries, targetWidth) => { + if (entries.length === 0) + return ''; + const sorted = [...entries].sort((a, b) => a.width - b.width); + const match = sorted.find((e) => e.width >= targetWidth); + return match ? match.uri : sorted[sorted.length - 1].uri; +}; +// TODO: Unify with page/getSize.ts parseValue/transformUnit into a shared unit parser +/** + * Parses a CSS length value into points. + * Supports: px, pt (default), in, mm, cm, vw, %. + * vw and % are resolved relative to containerWidth. + */ +const parseLength = (value, containerWidth) => { + const match = /^(-?\d*\.?\d+)\s*(px|pt|in|mm|cm|vw|%)?$/i.exec(value.trim()); + if (!match) + return undefined; + const num = parseFloat(match[1]); + if (Number.isNaN(num)) + return undefined; + const unit = match[2]?.toLowerCase(); + switch (unit) { + case 'in': + return num * 72; + case 'mm': + return num * (72 / 25.4); + case 'cm': + return num * (72 / 2.54); + case 'px': + return num; + case 'vw': + return (num / 100) * containerWidth; + case '%': + return (num / 100) * containerWidth; + case 'pt': + default: + return num; + } +}; +/** + * Evaluates a media condition like "(min-width: 600px)" or "(max-width: 400px)" + * against the container width. + */ +const matchesCondition = (condition, containerWidth) => { + const match = /\(\s*(min-width|max-width)\s*:\s*(-?\d*\.?\d+)\s*(px|pt|in|mm|cm|vw|%)?\s*\)/i.exec(condition); + if (!match) + return false; + const feature = match[1].toLowerCase(); + const threshold = parseLength(`${match[2]}${match[3] || ''}`, containerWidth); + if (threshold == null) + return false; + if (feature === 'min-width') + return containerWidth >= threshold; + if (feature === 'max-width') + return containerWidth <= threshold; + return false; +}; +/** + * Parses sizes attribute to get the target display width. + * + * Accepts a number (used directly as points) or a string. + * For strings, evaluates media conditions against containerWidth + * and returns the first matching entry's length value. + * + * Format: "(media-condition) length, (media-condition) length, default-length" + */ +const parseSizes = (sizes, containerWidth) => { + if (sizes == null) + return undefined; + if (typeof sizes === 'number') + return sizes; + const entries = sizes.split(',').map((s) => s.trim()); + for (const entry of entries) { + const conditionMatch = /^\(([^)]+)\)\s+(.+)$/.exec(entry); + if (conditionMatch) { + const condition = `(${conditionMatch[1]})`; + const lengthStr = conditionMatch[2]; + if (matchesCondition(condition, containerWidth)) { + return parseLength(lengthStr, containerWidth); + } + } + else { + return parseLength(entry, containerWidth); + } + } + return undefined; +}; +/** + * Get image source, resolving srcSet if present. + * + * @param node - Image node + * @param pageWidth - Page width for srcSet resolution + * @returns Image src + */ +const getSource = (node, pageWidth) => { + const { srcSet, sizes } = node.props; + if (srcSet) { + const entries = parseSrcSet(srcSet); + if (entries.length > 0) { + const targetWidth = parseSizes(sizes, pageWidth) || pageWidth; + const uri = selectSource(entries, targetWidth); + if (uri) + return uri; + } + } + if (node.props.src) + return node.props.src; + if (node.props.source) + return node.props.source; +}; + +/** + * Resolves `src` to `@react-pdf/image` interface. + * + * Also it handles factories and async sources. + * + * @param src + * @returns Resolved src + */ +const resolveSource = async (src) => { + const source = typeof src === 'function' ? await src() : await src; + return typeof source === 'string' ? { uri: source } : source; +}; + +/** + * Fetches image and appends data to node. + * Ideally this fn should be immutable. + * + * @param node - Image or ImageBackground node + * @param pageWidth - Page width for srcSet resolution + */ +const fetchImage = async (node, pageWidth) => { + const { cache } = node.props; + const src = getSource(node, pageWidth); + if (!src) { + console.warn(false, 'Image should receive either a "src" or "source" prop'); + return; + } + try { + const source = await resolveSource(src); + if (!source) { + throw new Error(`Image's "src" or "source" prop returned ${source}`); + } + node.image = await resolveImage(source, { cache }); + if (Buffer.isBuffer(source) || source instanceof Blob) + return; + node.image.key = 'data' in source ? source.data.toString() : source.uri; + } + catch (e) { + console.warn(e.message); + } +}; + +const isImage$2 = (node) => node.type === P.Image; +const isImageBackground = (node) => node.type === P.ImageBackground; +/** + * Get all asset promises that need to be resolved + * + * @param fontStore - Font store + * @param node - Root node + * @returns Asset promises + */ +const fetchAssets = (fontStore, node, pageWidth) => { + const promises = []; + const listToExplore = [node]; + const emojiSource = fontStore ? fontStore.getEmojiSource() : null; + while (listToExplore.length > 0) { + const n = listToExplore.shift(); + if (isImage$2(n) || isImageBackground(n)) { + promises.push(fetchImage(n, pageWidth)); + } + if (fontStore && n.style?.fontFamily) { + const fontFamilies = castArray(n.style.fontFamily); + promises.push(...fontFamilies.map((fontFamily) => fontStore.load({ + fontFamily, + fontStyle: n.style.fontStyle, + fontWeight: n.style.fontWeight, + }))); + } + if (typeof n === 'string') { + promises.push(...fetchEmojis(n, emojiSource)); + } + if ('value' in n && typeof n.value === 'string') { + promises.push(...fetchEmojis(n.value, emojiSource)); + } + if (n.children) { + n.children.forEach((childNode) => { + listToExplore.push(childNode); + }); + } + } + return promises; +}; +/** + * Fetch assets for a page + * + * @param fontStore - Font store + * @param page - Page node + * @returns Asset promises + */ +const fetchPageAssets = (fontStore, page) => { + const pageWidth = page.style?.width; + return page.children + ?.map((child) => fetchAssets(fontStore, child, pageWidth)) + .flat(); +}; +/** + * Fetch image, font and emoji assets in parallel. + * Layout process will not be resumed until promise resolves. + * + * @param node root node + * @param fontStore font store + * @returns Root node + */ +const resolveAssets = async (node, fontStore) => { + const promises = node.children + .map((page) => fetchPageAssets(fontStore, page)) + .flat(); + await Promise.all(promises); + return node; +}; + +const isLink$1 = (node) => node.type === P.Link; +const DEFAULT_LINK_STYLES = { + color: 'blue', + textDecoration: 'underline', +}; +/** + * Computes styles using stylesheet + * + * @param container + * @param node - Document node + * @returns Computed styles + */ +const computeStyle = (container, node) => { + let baseStyle = [node.style]; + if (isLink$1(node)) { + baseStyle = Array.isArray(node.style) + ? [DEFAULT_LINK_STYLES, ...node.style] + : [DEFAULT_LINK_STYLES, node.style]; + } + return resolveStyle(container, baseStyle); +}; +/** + * Resolves node styles + * + * @param container + * @returns Resolve node styles + */ +const resolveNodeStyles = (container) => (node) => { + const style = computeStyle(container, node); + if (!node.children) + return Object.assign({}, node, { style }); + const children = node.children.map(resolveNodeStyles(container)); + return Object.assign({}, node, { style, children }); +}; +/** + * Resolves page styles + * + * @param page Document page + * @returns Document page with resolved styles + */ +const resolvePageStyles = (page) => { + const dpi = page.props?.dpi || 72; + const style = page.style; + const width = page.box?.width || style.width; + const height = page.box?.height || style.height; + const orientation = page.props?.orientation || 'portrait'; + const remBase = style?.fontSize || 18; + const container = { width, height, orientation, dpi, remBase }; + return resolveNodeStyles(container)(page); +}; +/** + * Resolves document styles + * + * @param root - Document root + * @returns Document root with resolved styles + */ +const resolveStyles = (root) => { + if (!root.children) + return root; + const children = root.children.map(resolvePageStyles); + return Object.assign({}, root, { children }); +}; + +const getTransformStyle = (s) => (node) => isNil(node.style?.[s]) ? '50%' : node.style?.[s] ?? null; +/** + * Get node origin + * + * @param node + * @returns {{ left?: number, top?: number }} node origin + */ +const getOrigin = (node) => { + if (!node.box) + return null; + const { left, top, width, height } = node.box; + const transformOriginX = getTransformStyle('transformOriginX')(node); + const transformOriginY = getTransformStyle('transformOriginY')(node); + const percentX = matchPercent(transformOriginX); + const percentY = matchPercent(transformOriginY); + const offsetX = percentX ? width * percentX.percent : transformOriginX; + const offsetY = percentY ? height * percentY.percent : transformOriginY; + if (isNil(offsetX) || typeof offsetX === 'string') + throw new Error(`Invalid origin offsetX: ${offsetX}`); + if (isNil(offsetY) || typeof offsetY === 'string') + throw new Error(`Invalid origin offsetY: ${offsetY}`); + return { left: left + offsetX, top: top + offsetY }; +}; + +/** + * Resolve node origin + * + * @param node + * @returns Node with origin attribute + */ +const resolveNodeOrigin = (node) => { + const origin = getOrigin(node); + const newNode = Object.assign({}, node, { origin }); + if (!node.children) + return newNode; + const children = node.children.map(resolveNodeOrigin); + return Object.assign({}, newNode, { children }); +}; +/** + * Resolve document origins + * + * @param root - Document root + * @returns Document root + */ +const resolveOrigin = (root) => { + if (!root.children) + return root; + const children = root.children.map(resolveNodeOrigin); + return Object.assign({}, root, { children }); +}; + +/** + * Normalize bookmark value, expanding a plain string title into a full + * bookmark object with default fit and expanded values + * + * @param bookmark - Bookmark value + * @returns Normalized bookmark object + */ +const getBookmarkValue = (bookmark) => { + return typeof bookmark === 'string' + ? { title: bookmark, fit: false, expanded: false } + : bookmark; +}; +/** + * Traverse document tree and resolve bookmark hierarchy, assigning each + * bookmark a ref index and a reference to its nearest bookmark ancestor + * + * @param node - Document node + * @returns Document node with resolved bookmarks + */ +const resolveBookmarks = (node) => { + let refs = 0; + const listToExplore = (node.children || []).map((value) => ({ + value, + parent: null, + })); + while (listToExplore.length > 0) { + const element = listToExplore.shift(); + if (!element) + break; + const child = element.value; + let parent = element.parent; + if (child.props && 'bookmark' in child.props && child.props.bookmark) { + const bookmark = getBookmarkValue(child.props.bookmark); + const ref = refs++; + const newHierarchy = { ref, parent: parent?.ref, ...bookmark }; + child.props.bookmark = newHierarchy; + parent = newHierarchy; + } + if (child.children) { + child.children.forEach((childNode) => { + listToExplore.push({ value: childNode, parent }); + }); + } + } + return node; +}; + +const VALID_ORIENTATIONS = ['portrait', 'landscape']; +/** + * Get page orientation. Defaults to portrait + * + * @param page - Page object + * @returns Page orientation + */ +const getOrientation = (page) => { + const value = page.props?.orientation || 'portrait'; + return VALID_ORIENTATIONS.includes(value) ? value : 'portrait'; +}; + +/** + * Return true if page is landscape + * + * @param page - Page instance + * @returns Is page landscape + */ +const isLandscape = (page) => getOrientation(page) === 'landscape'; + +// Page sizes for 72dpi. 72dpi is used internally by pdfkit. +const PAGE_SIZES = { + '4A0': [4767.87, 6740.79], + '2A0': [3370.39, 4767.87], + A0: [2383.94, 3370.39], + A1: [1683.78, 2383.94], + A2: [1190.55, 1683.78], + A3: [841.89, 1190.55], + A4: [595.28, 841.89], + A5: [419.53, 595.28], + A6: [297.64, 419.53], + A7: [209.76, 297.64], + A8: [147.4, 209.76], + A9: [104.88, 147.4], + A10: [73.7, 104.88], + B0: [2834.65, 4008.19], + B1: [2004.09, 2834.65], + B2: [1417.32, 2004.09], + B3: [1000.63, 1417.32], + B4: [708.66, 1000.63], + B5: [498.9, 708.66], + B6: [354.33, 498.9], + B7: [249.45, 354.33], + B8: [175.75, 249.45], + B9: [124.72, 175.75], + B10: [87.87, 124.72], + C0: [2599.37, 3676.54], + C1: [1836.85, 2599.37], + C2: [1298.27, 1836.85], + C3: [918.43, 1298.27], + C4: [649.13, 918.43], + C5: [459.21, 649.13], + C6: [323.15, 459.21], + C7: [229.61, 323.15], + C8: [161.57, 229.61], + C9: [113.39, 161.57], + C10: [79.37, 113.39], + RA0: [2437.8, 3458.27], + RA1: [1729.13, 2437.8], + RA2: [1218.9, 1729.13], + RA3: [864.57, 1218.9], + RA4: [609.45, 864.57], + SRA0: [2551.18, 3628.35], + SRA1: [1814.17, 2551.18], + SRA2: [1275.59, 1814.17], + SRA3: [907.09, 1275.59], + SRA4: [637.8, 907.09], + EXECUTIVE: [521.86, 756.0], + FOLIO: [612.0, 936.0], + LEGAL: [612.0, 1008.0], + LETTER: [612.0, 792.0], + TABLOID: [792.0, 1224.0], + ID1: [153, 243], +}; +/** + * Parses scalar value in value and unit pairs + * + * @param value - Scalar value + * @returns Parsed value + */ +const parseValue = (value) => { + if (typeof value === 'number') + return { value, unit: undefined }; + const match = /^(-?\d*\.?\d+)(in|mm|cm|pt|px)?$/g.exec(value); + return match + ? { value: parseFloat(match[1]), unit: match[2] || 'pt' } + : { value, unit: undefined }; +}; +/** + * Transform given scalar value to 72dpi equivalent of size + * + * @param value - Styles value + * @param inputDpi - User defined dpi + * @returns Transformed value + */ +const transformUnit = (value, inputDpi) => { + if (!value || value === 'auto') + return undefined; + const scalar = parseValue(value); + const outputDpi = 72; + const mmFactor = (1 / 25.4) * outputDpi; + const cmFactor = (1 / 2.54) * outputDpi; + if (typeof scalar.value === 'string') + throw new Error(`Invalid page size: ${value}`); + switch (scalar.unit) { + case 'in': + return scalar.value * outputDpi; + case 'mm': + return scalar.value * mmFactor; + case 'cm': + return scalar.value * cmFactor; + case 'px': + return Math.round(scalar.value * (outputDpi / inputDpi)); + default: + return scalar.value; + } +}; +const transformUnits = ({ width, height }, dpi) => { + const result = { width: transformUnit(width, dpi) || 0 }; + const h = transformUnit(height, dpi); + if (h !== undefined) + result.height = h; + return result; +}; +/** + * Transforms array into size object + * + * @param v - Values array + * @returns Size object with width and height + */ +const toSizeObject = (v) => ({ + width: v[0], + height: v[1], +}); +/** + * Flip size object + * + * @param v - Size object + * @returns Flipped size object + */ +const flipSizeObject = (v) => { + const result = { width: v.height || 0 }; + if (v.width !== undefined) + result.height = v.width; + return result; +}; +/** + * Returns size object from a given string + * + * @param v - Page size string + * @returns Size object with width and height + */ +const getStringSize = (v) => { + return toSizeObject(PAGE_SIZES[v.toUpperCase()]); +}; +/** + * Returns size object from a single number + * + * @param n - Page size number + * @returns Size object with width and height + */ +const getNumberSize = (n) => toSizeObject([n, n]); +/** + * Return page size in an object { width, height } + * + * @param page - Page node + * @returns Size object with width and height + */ +const getSize = (page) => { + const value = page.props?.size || 'A4'; + const dpi = page.props?.dpi || 72; + let size; + if (typeof value === 'string') { + size = getStringSize(value); + } + else if (Array.isArray(value)) { + size = transformUnits(toSizeObject(value), dpi); + } + else if (typeof value === 'number') { + size = transformUnits(getNumberSize(value), dpi); + } + else { + size = transformUnits(value, dpi); + } + return isLandscape(page) ? flipSizeObject(size) : size; +}; + +/** + * Resolves page size + * + * @param page + * @returns Page with resolved size in style attribute + */ +const resolvePageSize = (page) => { + const size = getSize(page); + const style = flatten(page.style || {}); + return { ...page, style: { ...style, ...size } }; +}; +/** + * Resolves page sizes + * + * @param root -Document root + * @returns Document root with resolved page sizes + */ +const resolvePageSizes = (root) => { + if (!root.children) + return root; + const children = root.children.map(resolvePageSize); + return Object.assign({}, root, { children }); +}; + +const isFixed = (node) => { + if (!node.props) + return false; + return 'fixed' in node.props ? node.props.fixed === true : false; +}; + +/** + * Get line index at given height + * + * @param node + * @param height + */ +const lineIndexAtHeight = (node, height) => { + let y = 0; + if (!node.lines) + return 0; + for (let i = 0; i < node.lines.length; i += 1) { + const line = node.lines[i]; + if (y + line.box.height > height) + return i; + y += line.box.height; + } + return node.lines.length; +}; + +/** + * Get height for given text line index + * + * @param node + * @param index + */ +const heightAtLineIndex = (node, index) => { + let counter = 0; + if (!node.lines) + return counter; + for (let i = 0; i < index; i += 1) { + const line = node.lines[i]; + if (!line) + break; + counter += line.box.height; + } + return counter; +}; + +const getLineBreak = (node, height) => { + const top = node.box?.top || 0; + const widows = node.props.widows || 2; + const orphans = node.props.orphans || 2; + const linesQuantity = node.lines.length; + const slicedLine = lineIndexAtHeight(node, height - top); + if (slicedLine === 0) { + return 0; + } + if (linesQuantity < orphans) { + return linesQuantity; + } + if (slicedLine < orphans || linesQuantity < orphans + widows) { + return 0; + } + if (linesQuantity === orphans + widows) { + return orphans; + } + if (linesQuantity - slicedLine < widows) { + return linesQuantity - widows; + } + return slicedLine; +}; +// Also receives contentArea in case it's needed +const splitText = (node, height) => { + const slicedLineIndex = getLineBreak(node, height); + const currentHeight = heightAtLineIndex(node, slicedLineIndex); + const nextHeight = node.box.height - currentHeight; + const current = Object.assign({}, node, { + box: { + ...node.box, + height: currentHeight, + borderBottomWidth: 0, + }, + style: { + ...node.style, + marginBottom: 0, + paddingBottom: 0, + borderBottomWidth: 0, + borderBottomLeftRadius: 0, + borderBottomRightRadius: 0, + }, + lines: node.lines.slice(0, slicedLineIndex), + }); + const next = Object.assign({}, node, { + box: { + ...node.box, + top: 0, + height: nextHeight, + borderTopWidth: 0, + }, + style: { + ...node.style, + marginTop: 0, + paddingTop: 0, + borderTopWidth: 0, + borderTopLeftRadius: 0, + borderTopRightRadius: 0, + }, + lines: node.lines.slice(slicedLineIndex), + }); + return [current, next]; +}; + +const getTop$1 = (node) => node.box?.top || 0; +const hasFixedHeight = (node) => !isNil(node.style?.height); +const splitNode = (node, height) => { + if (!node) + return [null, null]; + const nodeTop = getTop$1(node); + const current = Object.assign({}, node, { + box: { + ...node.box, + borderBottomWidth: 0, + }, + style: { + ...node.style, + marginBottom: 0, + paddingBottom: 0, + borderBottomWidth: 0, + borderBottomLeftRadius: 0, + borderBottomRightRadius: 0, + }, + }); + current.style.height = height - nodeTop; + const nextHeight = hasFixedHeight(node) + ? node.box.height - (height - nodeTop) + : null; + const next = Object.assign({}, node, { + box: { + ...node.box, + top: 0, + borderTopWidth: 0, + }, + style: { + ...node.style, + marginTop: 0, + paddingTop: 0, + borderTopWidth: 0, + borderTopLeftRadius: 0, + borderTopRightRadius: 0, + }, + props: { + ...node.props, + bookmark: null, + }, + }); + if (nextHeight) { + next.style.height = nextHeight; + } + return [current, next]; +}; + +const NON_WRAP_TYPES = [P.Svg, P.Note, P.Image, P.Canvas]; +const getWrap = (node) => { + if (NON_WRAP_TYPES.includes(node.type)) + return false; + if (!node.props) + return true; + return 'wrap' in node.props ? node.props.wrap : true; +}; + +const getComputedPadding = (node, edge) => { + const { yogaNode } = node; + return yogaNode ? yogaNode.getComputedPadding(edge) : null; +}; +/** + * Get Yoga computed paddings. Zero otherwise + * + * @param node + * @returns paddings + */ +const getPadding = (node) => { + const { style, box } = node; + const paddingTop = getComputedPadding(node, Yoga.Edge.Top) || + box?.paddingTop || + style?.paddingTop || + 0; + const paddingRight = getComputedPadding(node, Yoga.Edge.Right) || + box?.paddingRight || + style?.paddingRight || + 0; + const paddingBottom = getComputedPadding(node, Yoga.Edge.Bottom) || + box?.paddingBottom || + style?.paddingBottom || + 0; + const paddingLeft = getComputedPadding(node, Yoga.Edge.Left) || + box?.paddingLeft || + style?.paddingLeft || + 0; + return { paddingTop, paddingRight, paddingBottom, paddingLeft }; +}; + +const getWrapArea = (page) => { + const height = page.style?.height; + const { paddingBottom } = getPadding(page); + return height - paddingBottom; +}; + +const getContentArea = (page) => { + const height = page.style?.height; + const { paddingTop, paddingBottom } = getPadding(page); + return height - paddingBottom - paddingTop; +}; + +const isString = (value) => typeof value === 'string'; +const isNumber = (value) => typeof value === 'number'; +const isBoolean = (value) => typeof value === 'boolean'; +const isFragment = (value) => value && value.type === Symbol.for('react.fragment'); +/** + * Transforms a react element instance to internal element format. + * + * Can return multiple instances in the case of arrays or fragments. + * + * @param element - React element + * @returns Parsed React elements + */ +const createInstances = (element) => { + if (!element) + return []; + if (Array.isArray(element)) { + return element.reduce((acc, el) => acc.concat(createInstances(el)), []); + } + if (isBoolean(element)) { + return []; + } + if (isString(element) || isNumber(element)) { + return [{ type: P.TextInstance, value: `${element}` }]; + } + if (isFragment(element)) { + // @ts-expect-error figure out why this is complains + return createInstances(element.props.children); + } + if (!isString(element.type)) { + // @ts-expect-error figure out why this is complains + return createInstances(element.type(element.props)); + } + const { type, props: { style = {}, children, ...props }, } = element; + const nextChildren = castArray(children).reduce((acc, child) => acc.concat(createInstances(child)), []); + return [ + { + type, + style, + props, + children: nextChildren, + }, + ]; +}; + +const getBreak = (node) => 'break' in node.props ? node.props.break : false; +const getMinPresenceAhead = (node) => 'minPresenceAhead' in node.props ? node.props.minPresenceAhead : 0; +const getFurthestEnd = (elements) => { + if (elements.length === 0) + return null; + return Math.max(...elements.map((node) => node.box.top + node.box.height)); +}; +const getEndOfMinPresenceAhead = (child) => { + return (child.box.top + + child.box.height + + child.box.marginBottom + + getMinPresenceAhead(child)); +}; +const getEndOfPresence = (child, futureElements) => { + const afterMinPresenceAhead = getEndOfMinPresenceAhead(child); + const nonFixedFuture = futureElements.filter((node) => !('fixed' in node.props)); + const endOfFurthestFutureElement = getFurthestEnd(nonFixedFuture); + // When there are no future non-fixed siblings, use only minPresenceAhead + if (endOfFurthestFutureElement === null) + return afterMinPresenceAhead; + return Math.min(afterMinPresenceAhead, endOfFurthestFutureElement); +}; +const shouldBreak = (child, futureElements, height, previousElements) => { + if ('fixed' in child.props) + return false; + const shouldSplit = height < child.box.top + child.box.height; + const canWrap = getWrap(child); + // Calculate the y coordinate where the desired presence of the child ends + const endOfPresence = getEndOfPresence(child, futureElements); + // If the child is already at the top of the page, breaking won't improve its presence + // (as long as react-pdf does not support breaking into differently sized containers) + const breakingImprovesPresence = previousElements.filter((node) => !isFixed(node)).length > 0; + return (getBreak(child) || + (shouldSplit && !canWrap) || + (!shouldSplit && endOfPresence > height && breakingImprovesPresence)); +}; + +const IGNORABLE_CODEPOINTS = [ + 8232, // LINE_SEPARATOR + 8233, // PARAGRAPH_SEPARATOR + 8288, // WORD_JOINER +]; +const buildSubsetForFont = (font) => IGNORABLE_CODEPOINTS.reduce((acc, codePoint) => { + if (font && + font.hasGlyphForCodePoint && + font.hasGlyphForCodePoint(codePoint)) { + return acc; + } + return [...acc, String.fromCharCode(codePoint)]; +}, []); +const ignoreChars = (fragments) => fragments.map((fragment) => { + const charSubset = buildSubsetForFont(fragment.attributes.font[0]); + const subsetRegex = new RegExp(charSubset.join('|')); + return { + string: fragment.string.replace(subsetRegex, ''), + attributes: fragment.attributes, + }; +}); + +const PREPROCESSORS = [ignoreChars, embedEmojis]; +const isImage$1 = (node) => node.type === P.Image; +const isRasterImage = (node) => !!node.image && node.image.format !== 'svg'; +const isTextInstance$2 = (node) => node.type === P.TextInstance; +/** + * Get textkit fragments of given node object + * + * @param fontStore - Font store + * @param instance - Node + * @param parentLink - Parent link + * @param level - Fragment level + * @returns Text fragments + */ +const getFragments = (fontStore, instance, parentLink = null, level = 0) => { + if (!instance) + return [{ string: '' }]; + let fragments = []; + const { color = 'black', direction = 'ltr', fontFamily = 'Helvetica', fontWeight, fontStyle, fontSize = 18, textAlign, lineHeight, textDecoration, textDecorationColor, textDecorationStyle, textTransform, letterSpacing, textIndent, opacity, verticalAlign, } = instance.style; + const fontFamilies = typeof fontFamily === 'string' ? [fontFamily] : [...(fontFamily || [])]; + // Fallback font + fontFamilies.push('Helvetica'); + const font = fontFamilies.map((fontFamilyName) => { + const opts = { fontFamily: fontFamilyName, fontWeight, fontStyle }; + const obj = fontStore.getFont(opts); + return obj?.data; + }); + // Don't pass main background color to textkit. Will be rendered by the render package instead + const backgroundColor = level === 0 ? null : instance.style.backgroundColor; + const attributes = { + font, + color, + opacity, + fontSize, + lineHeight, + direction, + verticalAlign, + backgroundColor, + indent: textIndent, + characterSpacing: letterSpacing, + strikeStyle: textDecorationStyle, + underlineStyle: textDecorationStyle, + underline: textDecoration === 'underline' || + textDecoration === 'underline line-through' || + textDecoration === 'line-through underline', + strike: textDecoration === 'line-through' || + textDecoration === 'underline line-through' || + textDecoration === 'line-through underline', + strikeColor: textDecorationColor || color, + underlineColor: textDecorationColor || color, + // @ts-expect-error allow this props access + link: parentLink || instance.props?.src || instance.props?.href, + align: textAlign || (direction === 'rtl' ? 'right' : 'left'), + }; + for (let i = 0; i < instance.children.length; i += 1) { + const child = instance.children[i]; + if (isImage$1(child) && isRasterImage(child)) { + fragments.push({ + string: String.fromCharCode(0xfffc), + attributes: { + ...attributes, + attachment: { + width: (child.style.width || fontSize), + height: (child.style.height || fontSize), + image: child.image.data, + }, + }, + }); + } + else if (isTextInstance$2(child)) { + fragments.push({ + string: transformText(child.value, textTransform), + attributes, + }); + } + else if (child && !isImage$1(child)) { + fragments.push(...getFragments(fontStore, child, attributes.link, level + 1)); + } + } + for (let i = 0; i < PREPROCESSORS.length; i += 1) { + const preprocessor = PREPROCESSORS[i]; + fragments = preprocessor(fragments); + } + return fragments; +}; +/** + * Get textkit attributed string from text node + * + * @param fontStore - Font store + * @param instance Node + * @returns Attributed string + */ +const getAttributedString = (fontStore, instance) => { + const fragments = getFragments(fontStore, instance); + return fromFragments(fragments); +}; + +const engines = { + bidi, + linebreaker, + justification, + textDecoration, + scriptItemizer, + wordHyphenation, + fontSubstitution, +}; +const engine = layoutEngine(engines); +const getMaxLines = (node) => node.style?.maxLines; +const getTextOverflow = (node) => node.style?.textOverflow; +/** + * Get layout container for specific text node + * + * @param {number} width + * @param {number} height + * @param {Object} node + * @returns {Object} layout container + */ +const getContainer = (width, height, node) => { + const maxLines = getMaxLines(node); + const textOverflow = getTextOverflow(node); + return { + x: 0, + y: 0, + width, + maxLines, + height: height || Infinity, + truncateMode: textOverflow, + }; +}; +/** + * Get text layout options for specific text node + * + * @param {Object} node instance + * @returns {Object} layout options + */ +const getLayoutOptions = (fontStore, node) => ({ + hyphenationPenalty: node.props.hyphenationPenalty, + shrinkWhitespaceFactor: { before: -0.5, after: -0.5 }, + hyphenationCallback: node.props.hyphenationCallback || + fontStore?.getHyphenationCallback() || + null, +}); +/** + * Get text lines for given node + * + * @param node - Node + * @param width - Container width + * @param height - Container height + * @param fontStore - Font store + * @returns Layout lines + */ +const layoutText = (node, width, height, fontStore) => { + const attributedString = getAttributedString(fontStore, node); + const container = getContainer(width, height, node); + const options = getLayoutOptions(fontStore, node); + const lines = engine(attributedString, container, options); + return lines.reduce((acc, line) => [...acc, ...line], []); +}; + +const isSvg$2 = (node) => node.type === P.Svg; +const isText$4 = (node) => node.type === P.Text; +const shouldIterate = (node) => !isSvg$2(node) && !isText$4(node); +const shouldLayoutText = (node) => isText$4(node) && !node.lines; +/** + * Performs text layout on text node if wasn't calculated before. + * Text layout is usually performed on Yoga's layout process (via setMeasureFunc), + * but we need to layout those nodes with fixed width and height. + * + * @param node + * @returns Layout node + */ +const resolveTextLayout = (node, fontStore) => { + if (shouldLayoutText(node)) { + const width = node.box.width - (node.box.paddingRight + node.box.paddingLeft); + const height = node.box.height - (node.box.paddingTop + node.box.paddingBottom); + node.lines = layoutText(node, width, height, fontStore); + } + if (shouldIterate(node)) { + if (!node.children) + return node; + const mapChild = (child) => resolveTextLayout(child, fontStore); + const children = node.children.map(mapChild); + return Object.assign({}, node, { children }); + } + return node; +}; + +const BASE_INHERITABLE_PROPERTIES = [ + 'color', + 'fontFamily', + 'fontSize', + 'fontStyle', + 'fontWeight', + 'letterSpacing', + 'opacity', + 'textDecoration', + 'textTransform', + 'lineHeight', + 'textAlign', + 'visibility', + 'wordSpacing', +]; +const TEXT_INHERITABLE_PROPERTIES = [ + ...BASE_INHERITABLE_PROPERTIES, + 'backgroundColor', +]; +const isType$2 = (type) => (node) => node.type === type; +const isSvg$1 = isType$2(P.Svg); +const isText$3 = isType$2(P.Text); +// Merge style values +const mergeValues = (styleName, value, inheritedValue) => { + switch (styleName) { + case 'textDecoration': { + // merge not none and not false textDecoration values to one rule + return [inheritedValue, value].filter((v) => v && v !== 'none').join(' '); + } + default: + return value; + } +}; +// Merge inherited and node styles +const merge = (inheritedStyles, style) => { + const mergedStyles = { ...inheritedStyles }; + Object.entries(style).forEach(([styleName, value]) => { + mergedStyles[styleName] = mergeValues(styleName, value, inheritedStyles[styleName]); + }); + return mergedStyles; +}; +/** + * Merges styles with node + * + * @param inheritedStyles - Style object + * @returns Merge styles function + */ +const mergeStyles = (inheritedStyles) => (node) => { + const style = merge(inheritedStyles, node.style || {}); + return Object.assign({}, node, { style }); +}; +/** + * Inherit style values from the root to the leafs + * + * @param node - Document root + * @returns Document root with inheritance + * + */ +const resolveInheritance = (node) => { + if (isSvg$1(node)) + return node; + if (!('children' in node)) + return node; + const inheritableProperties = isText$3(node) + ? TEXT_INHERITABLE_PROPERTIES + : BASE_INHERITABLE_PROPERTIES; + const inheritStyles = pick(inheritableProperties, node.style || {}); + const resolveChild = compose(resolveInheritance, mergeStyles(inheritStyles)); + const children = node.children.map(resolveChild); + return Object.assign({}, node, { children }); +}; + +const getComputedMargin = (node, edge) => { + const { yogaNode } = node; + return yogaNode ? yogaNode.getComputedMargin(edge) : null; +}; +/** + * Get Yoga computed magins. Zero otherwise + * + * @param node + * @returns Margins + */ +const getMargin = (node) => { + const { style, box } = node; + const marginTop = getComputedMargin(node, Yoga.Edge.Top) || + box?.marginTop || + style?.marginTop || + 0; + const marginRight = getComputedMargin(node, Yoga.Edge.Right) || + box?.marginRight || + style?.marginRight || + 0; + const marginBottom = getComputedMargin(node, Yoga.Edge.Bottom) || + box?.marginBottom || + style?.marginBottom || + 0; + const marginLeft = getComputedMargin(node, Yoga.Edge.Left) || + box?.marginLeft || + style?.marginLeft || + 0; + return { marginTop, marginRight, marginBottom, marginLeft }; +}; + +/** + * Get Yoga computed position. Zero otherwise + * + * @param node + * @returns Position + */ +const getPosition = (node) => { + const { yogaNode } = node; + return { + top: yogaNode?.getComputedTop() || 0, + right: yogaNode?.getComputedRight() || 0, + bottom: yogaNode?.getComputedBottom() || 0, + left: yogaNode?.getComputedLeft() || 0, + }; +}; + +const DEFAULT_DIMENSION = { + width: 0, + height: 0, +}; +/** + * Get Yoga computed dimensions. Zero otherwise + * + * @param node + * @returns Dimensions + */ +const getDimension = (node) => { + const { yogaNode } = node; + if (!yogaNode) + return DEFAULT_DIMENSION; + return { + width: yogaNode.getComputedWidth(), + height: yogaNode.getComputedHeight(), + }; +}; + +const getComputedBorder = (yogaNode, edge) => (yogaNode ? yogaNode.getComputedBorder(edge) : 0); +/** + * Get Yoga computed border width. Zero otherwise + * + * @param node + * @returns Border widths + */ +const getBorderWidth = (node) => { + const { yogaNode } = node; + return { + borderTopWidth: getComputedBorder(yogaNode, Yoga.Edge.Top), + borderRightWidth: getComputedBorder(yogaNode, Yoga.Edge.Right), + borderBottomWidth: getComputedBorder(yogaNode, Yoga.Edge.Bottom), + borderLeftWidth: getComputedBorder(yogaNode, Yoga.Edge.Left), + }; +}; + +/** + * Set display attribute to node's Yoga instance + * + * @param value - Display + * @returns Node instance wrapper + */ +const setDisplay = (value) => (node) => { + const { yogaNode } = node; + if (yogaNode) { + yogaNode.setDisplay(value === 'none' ? Yoga.Display.None : Yoga.Display.Flex); + } + return node; +}; + +const OVERFLOW = { + hidden: Yoga.Overflow.Hidden, + scroll: Yoga.Overflow.Scroll, +}; +/** + * Set overflow attribute to node's Yoga instance + * + * @param value - Overflow value + * @returns Node instance wrapper + */ +const setOverflow = (value) => (node) => { + const { yogaNode } = node; + if (!isNil(value) && yogaNode) { + const overflow = OVERFLOW[value] || Yoga.Overflow.Visible; + yogaNode.setOverflow(overflow); + } + return node; +}; + +const FLEX_WRAP = { + wrap: Yoga.Wrap.Wrap, + 'wrap-reverse': Yoga.Wrap.WrapReverse, +}; +/** + * Set flex wrap attribute to node's Yoga instance + * + * @param value - Flex wrap value + * @returns Node instance wrapper + */ +const setFlexWrap = (value) => (node) => { + const { yogaNode } = node; + if (yogaNode) { + const flexWrap = FLEX_WRAP[value] || Yoga.Wrap.NoWrap; + yogaNode.setFlexWrap(flexWrap); + } + return node; +}; + +/** + * Set generic yoga attribute to node's Yoga instance, handing `auto`, edges and percentage cases + * + * @param attr - Property + * @param edge - Edge + * @returns Node instance wrapper + */ +const setYogaValue = (attr, edge) => (value) => (node) => { + const { yogaNode } = node; + if (!isNil(value) && yogaNode) { + const hasEdge = !isNil(edge); + const fixedMethod = `set${upperFirst(attr)}`; + const autoMethod = `${fixedMethod}Auto`; + const percentMethod = `${fixedMethod}Percent`; + const percent = matchPercent(value); + if (percent && !yogaNode[percentMethod]) { + throw new Error(`You can't pass percentage values to ${attr} property`); + } + if (percent) { + if (hasEdge) { + yogaNode[percentMethod]?.(edge, percent.value); + } + else { + yogaNode[percentMethod]?.(percent.value); + } + } + else if (value === 'auto') { + if (hasEdge) { + yogaNode[autoMethod]?.(edge); + } + else { + yogaNode[autoMethod]?.(); + } + } + else if (hasEdge) { + yogaNode[fixedMethod]?.(edge, value); + } + else { + yogaNode[fixedMethod]?.(value); + } + } + return node; +}; + +/** + * Set flex grow attribute to node's Yoga instance + * + * @param value - Flex grow value + * @returns Node instance wrapper + */ +const setFlexGrow = (value) => (node) => { + return setYogaValue('flexGrow')(value || 0)(node); +}; + +/** + * Set flex basis attribute to node's Yoga instance + * + * @param flex - Basis value + * @param node - Node instance + * @returns Node instance + */ +const setFlexBasis = setYogaValue('flexBasis'); + +const ALIGN = { + 'flex-start': Yoga.Align.FlexStart, + center: Yoga.Align.Center, + 'flex-end': Yoga.Align.FlexEnd, + stretch: Yoga.Align.Stretch, + baseline: Yoga.Align.Baseline, + 'space-between': Yoga.Align.SpaceBetween, + 'space-around': Yoga.Align.SpaceAround, + 'space-evenly': Yoga.Align.SpaceEvenly, +}; +/** + * Set generic align attribute to node's Yoga instance + * + * @param attr - Specific align property + * @param value - Specific align value + * @param node - Node + * @returns Node + */ +const setAlign = (attr) => (value) => (node) => { + const { yogaNode } = node; + const defaultValue = attr === 'items' ? Yoga.Align.Stretch : Yoga.Align.Auto; + if (yogaNode) { + const align = ALIGN[value] || defaultValue; + yogaNode[`setAlign${upperFirst(attr)}`](align); + } + return node; +}; + +/** + * Set align self attribute to node's Yoga instance + * + * @param align - Value + * @param node - Node instance + * @returns Node instance + */ +const setAlignSelf = setAlign('self'); + +/** + * Set align items attribute to node's Yoga instance + * + * @param align - Value + * @param node - Node instance + * @returns Node instance + */ +const setAlignItems = setAlign('items'); + +/** + * Set flex shrink attribute to node's Yoga instance + * + * @param value - Flex shrink value + * @returns Node instance wrapper + */ +const setFlexShrink = (value) => (node) => { + return setYogaValue('flexShrink')(value || 1)(node); +}; + +/** + * Set aspect ratio attribute to node's Yoga instance + * + * @param value - Ratio + * @returns Node instance + */ +const setAspectRatio = (value) => (node) => { + const { yogaNode } = node; + if (!isNil(value) && yogaNode) { + yogaNode.setAspectRatio(value); + } + return node; +}; + +/** + * Set align content attribute to node's Yoga instance + * + * @param align - Value + * @param node - Instance + * @returns Node instance + */ +const setAlignContent = setAlign('content'); + +const POSITION = { + absolute: Yoga.PositionType.Absolute, + relative: Yoga.PositionType.Relative, + static: Yoga.PositionType.Static, +}; +/** + * Set position type attribute to node's Yoga instance + * + * @param value - Position position type + * @returns Node instance + */ +const setPositionType = (value) => (node) => { + const { yogaNode } = node; + if (!isNil(value) && yogaNode) { + yogaNode.setPositionType(POSITION[value]); + } + return node; +}; + +const FLEX_DIRECTIONS = { + row: Yoga.FlexDirection.Row, + 'row-reverse': Yoga.FlexDirection.RowReverse, + 'column-reverse': Yoga.FlexDirection.ColumnReverse, +}; +/** + * Set flex direction attribute to node's Yoga instance + * + * @param value - Flex direction value + * @returns Node instance wrapper + */ +const setFlexDirection = (value) => (node) => { + const { yogaNode } = node; + if (yogaNode) { + const flexDirection = FLEX_DIRECTIONS[value] || Yoga.FlexDirection.Column; + yogaNode.setFlexDirection(flexDirection); + } + return node; +}; + +const JUSTIFY_CONTENT = { + center: Yoga.Justify.Center, + 'flex-end': Yoga.Justify.FlexEnd, + 'space-between': Yoga.Justify.SpaceBetween, + 'space-around': Yoga.Justify.SpaceAround, + 'space-evenly': Yoga.Justify.SpaceEvenly, +}; +/** + * Set justify content attribute to node's Yoga instance + * + * @param value - Justify content value + * @returns Node instance wrapper + */ +const setJustifyContent = (value) => (node) => { + const { yogaNode } = node; + if (!isNil(value) && yogaNode) { + const justifyContent = JUSTIFY_CONTENT[value] || Yoga.Justify.FlexStart; + yogaNode.setJustifyContent(justifyContent); + } + return node; +}; + +/** + * Set margin top attribute to node's Yoga instance + * + * @param margin - Margin top + * @param node - Node instance + * @returns Node instance + */ +const setMarginTop = setYogaValue('margin', Yoga.Edge.Top); +/** + * Set margin right attribute to node's Yoga instance + * + * @param margin - Margin right + * @param node - Node instance + * @returns Node instance + */ +const setMarginRight = setYogaValue('margin', Yoga.Edge.Right); +/** + * Set margin bottom attribute to node's Yoga instance + * + * @param margin - Margin bottom + * @param node - Node instance + * @returns Node instance + */ +const setMarginBottom = setYogaValue('margin', Yoga.Edge.Bottom); +/** + * Set margin left attribute to node's Yoga instance + * + * @param margin - Margin left + * @param node - Node instance + * @returns Node instance + */ +const setMarginLeft = setYogaValue('margin', Yoga.Edge.Left); + +/** + * Set padding top attribute to node's Yoga instance + * + * @param padding - Padding top + * @param node - Node instance + * @returns Node instance + */ +const setPaddingTop = setYogaValue('padding', Yoga.Edge.Top); +/** + * Set padding right attribute to node's Yoga instance + * + * @param padding - Padding right + * @param node - Node instance + * @returns Node instance + */ +const setPaddingRight = setYogaValue('padding', Yoga.Edge.Right); +/** + * Set padding bottom attribute to node's Yoga instance + * + * @param padding - Padding bottom + * @param node Node instance + * @returns Node instance + */ +const setPaddingBottom = setYogaValue('padding', Yoga.Edge.Bottom); +/** + * Set padding left attribute to node's Yoga instance + * + * @param padding - Padding left + * @param node - Node instance + * @returns Node instance + */ +const setPaddingLeft = setYogaValue('padding', Yoga.Edge.Left); + +/** + * Set border top attribute to node's Yoga instance + * + * @param border - Border top width + * @param node - Node instance + * @returns Node instance + */ +const setBorderTop = setYogaValue('border', Yoga.Edge.Top); +/** + * Set border right attribute to node's Yoga instance + * + * @param border - Border right width + * @param node - Node instance + * @returns Node instance + */ +const setBorderRight = setYogaValue('border', Yoga.Edge.Right); +/** + * Set border bottom attribute to node's Yoga instance + * + * @param border - Border bottom width + * @param node - Node instance + * @returns Node instance + */ +const setBorderBottom = setYogaValue('border', Yoga.Edge.Bottom); +/** + * Set border left attribute to node's Yoga instance + * + * @param border - Border left width + * @param node - Node instance + * @returns Node instance + */ +const setBorderLeft = setYogaValue('border', Yoga.Edge.Left); + +/** + * Set position top attribute to node's Yoga instance + * + * @param position - Position top + * @param node - Node instance + * @returns Node instance + */ +const setPositionTop = setYogaValue('position', Yoga.Edge.Top); +/** + * Set position right attribute to node's Yoga instance + * + * @param position - Position right + * @param node - Node instance + * @returns Node instance + */ +const setPositionRight = setYogaValue('position', Yoga.Edge.Right); +/** + * Set position bottom attribute to node's Yoga instance + * + * @param position - Position bottom + * @param node - Node instance + * @returns Node instance + */ +const setPositionBottom = setYogaValue('position', Yoga.Edge.Bottom); +/** + * Set position left attribute to node's Yoga instance + * + * @param position - Position left + * @param node - Node instance + * @returns Node instance + */ +const setPositionLeft = setYogaValue('position', Yoga.Edge.Left); + +/** + * Set width to node's Yoga instance + * + * @param width - Width + * @param node - Node instance + * @returns Node instance + */ +const setWidth = setYogaValue('width'); +/** + * Set min width to node's Yoga instance + * + * @param min - Width + * @param node - Node instance + * @returns Node instance + */ +const setMinWidth = setYogaValue('minWidth'); +/** + * Set max width to node's Yoga instance + * + * @param max - Width + * @param node - Node instance + * @returns Node instance + */ +const setMaxWidth = setYogaValue('maxWidth'); +/** + * Set height to node's Yoga instance + * + * @param height - Height + * @param node - Node instance + * @returns Node instance + */ +const setHeight = setYogaValue('height'); +/** + * Set min height to node's Yoga instance + * + * @param min - Height + * @param node - Node instance + * @returns Node instance + */ +const setMinHeight = setYogaValue('minHeight'); +/** + * Set max height to node's Yoga instance + * + * @param max - Height + * @param node - Node instance + * @returns Node instance + */ +const setMaxHeight = setYogaValue('maxHeight'); + +/** + * Set rowGap value to node's Yoga instance + * + * @param value - Gap value + * @returns Node instance wrapper + */ +const setRowGap = setYogaValue('gap', Yoga.Gutter.Row); +/** + * Set columnGap value to node's Yoga instance + * + * @param value - Gap value + * @returns Node instance wrapper + */ +const setColumnGap = setYogaValue('gap', Yoga.Gutter.Column); + +const getAspectRatio = (viewbox) => { + if (!viewbox) + return null; + if (typeof viewbox === 'string') + return null; + return (viewbox.maxX - viewbox.minX) / (viewbox.maxY - viewbox.minY); +}; +/** + * Yoga svg measure function + * + * @param page + * @param node + * @returns Measure svg + */ +const measureCanvas$1 = (page, node) => (width, widthMode, height, heightMode) => { + const aspectRatio = getAspectRatio(node.props.viewBox) || 1; + if (widthMode === Yoga.MeasureMode.Exactly || + widthMode === Yoga.MeasureMode.AtMost) { + return { width, height: width / aspectRatio }; + } + if (heightMode === Yoga.MeasureMode.Exactly) { + return { width: height * aspectRatio }; + } + return {}; +}; + +/** + * Get lines width (if any) + * + * @param node + * @returns Lines width + */ +const linesWidth = (node) => { + if (!node.lines) + return 0; + return Math.max(0, ...node.lines.map((line) => line.xAdvance)); +}; + +/** + * Get lines height (if any) + * + * @param node + * @returns Lines height + */ +const linesHeight = (node) => { + if (!node.lines) + return -1; + return node.lines.reduce((acc, line) => acc + line.box.height, 0); +}; + +const ALIGNMENT_FACTORS = { center: 0.5, right: 1 }; +/** + * Yoga text measure function + * + * @param page + * @param node + * @param fontStore + * @returns {MeasureText} measure text function + */ +const measureText = (page, node, fontStore) => (width, widthMode, height) => { + if (widthMode === Yoga.MeasureMode.Exactly) { + if (!node.lines) + node.lines = layoutText(node, width, height, fontStore); + return { height: linesHeight(node), width }; + } + if (widthMode === Yoga.MeasureMode.AtMost) { + const alignFactor = ALIGNMENT_FACTORS[node.style?.textAlign] || 0; + if (!node.lines) { + node.lines = layoutText(node, width, height, fontStore); + node.alignOffset = (width - linesWidth(node)) * alignFactor; // Compensate align in variable width containers + } + return { + height: linesHeight(node), + width: Math.min(width, linesWidth(node)), + }; + } + return {}; +}; + +/** + * Get image ratio + * + * @param node - Image node + * @returns Image ratio + */ +const getRatio = (node) => { + return node.image?.data ? node.image.width / node.image.height : 1; +}; + +/** + * Checks if page has auto height + * + * @param page + * @returns Is page height auto + */ +const isHeightAuto = (page) => isNil(page.box?.height); + +const SAFETY_HEIGHT$1 = 10; +/** + * Yoga image measure function + * + * @param page - Page + * @param node - Node + * @returns Measure image + */ +const measureImage = (page, node) => (width, widthMode, height, heightMode) => { + const imageRatio = getRatio(node); + const imageMargin = getMargin(node); + const pagePadding = getPadding(page); + // TODO: Check image percentage margins + const pageArea = isHeightAuto(page) + ? Infinity + : (page.box?.height || 0) - + pagePadding.paddingTop - + pagePadding.paddingBottom - + imageMargin.marginTop - + imageMargin.marginBottom - + SAFETY_HEIGHT$1; + // Skip measure if image data not present yet + if (!node.image) + return { width: 0, height: 0 }; + if (widthMode === Yoga.MeasureMode.Exactly && + heightMode === Yoga.MeasureMode.Undefined) { + const scaledHeight = width / imageRatio; + return { height: Math.min(pageArea, scaledHeight) }; + } + if (heightMode === Yoga.MeasureMode.Exactly && + (widthMode === Yoga.MeasureMode.AtMost || + widthMode === Yoga.MeasureMode.Undefined)) { + return { width: Math.min(height * imageRatio, width) }; + } + if (widthMode === Yoga.MeasureMode.Exactly && + heightMode === Yoga.MeasureMode.AtMost) { + const scaledHeight = width / imageRatio; + return { height: Math.min(height, pageArea, scaledHeight) }; + } + if (widthMode === Yoga.MeasureMode.AtMost && + heightMode === Yoga.MeasureMode.AtMost) { + if (imageRatio > 1) { + return { + width, + height: Math.min(width / imageRatio, height), + }; + } + return { + height, + width: Math.min(height * imageRatio, width), + }; + } + return { height, width }; +}; + +const SAFETY_HEIGHT = 10; +const getMax = (values) => Math.max(-Infinity, ...values); +/** + * Helper object to predict canvas size + * TODO: Implement remaining functions (as close as possible); + */ +const measureCtx = () => { + const ctx = {}; + const points = []; + const nil = () => ctx; + const addPoint = (x, y) => points.push([x, y]); + const moveTo = (x, y) => { + addPoint(x, y); + return ctx; + }; + const rect = (x, y, w, h) => { + addPoint(x, y); + addPoint(x + w, y); + addPoint(x, y + h); + addPoint(x + w, y + h); + return ctx; + }; + const ellipse = (x, y, rx, ry) => { + ry = ry || rx; + addPoint(x - rx, y - ry); + addPoint(x + rx, y - ry); + addPoint(x + rx, y + ry); + addPoint(x - rx, y + ry); + return ctx; + }; + const polygon = (...pts) => { + points.push(...pts); + return ctx; + }; + // Change dimensions + ctx.rect = rect; + ctx.moveTo = moveTo; + ctx.lineTo = moveTo; + ctx.circle = ellipse; + ctx.polygon = polygon; + ctx.ellipse = ellipse; + ctx.roundedRect = rect; + // To be implemented + ctx.text = nil; + ctx.path = nil; + ctx.lineWidth = nil; + ctx.bezierCurveTo = nil; + ctx.quadraticCurveTo = nil; + ctx.scale = nil; + ctx.rotate = nil; + ctx.translate = nil; + // These don't change dimensions + ctx.dash = nil; + ctx.clip = nil; + ctx.save = nil; + ctx.fill = nil; + ctx.font = nil; + ctx.stroke = nil; + ctx.lineCap = nil; + ctx.opacity = nil; + ctx.restore = nil; + ctx.lineJoin = nil; + ctx.fontSize = nil; + ctx.fillColor = nil; + ctx.miterLimit = nil; + ctx.strokeColor = nil; + ctx.fillOpacity = nil; + ctx.strokeOpacity = nil; + ctx.linearGradient = nil; + ctx.radialGradient = nil; + ctx.getWidth = () => getMax(points.map((p) => p[0])); + ctx.getHeight = () => getMax(points.map((p) => p[1])); + return ctx; +}; +/** + * @typedef {Function} MeasureCanvas + * @returns {{ width: number, height: number }} canvas width and height + */ +/** + * Yoga canvas measure function + * + * @param {Object} page + * @param {Object} node + * @returns {MeasureCanvas} measure canvas + */ +const measureCanvas = (page, node) => () => { + const imageMargin = getMargin(node); + const pagePadding = getPadding(page); + // TODO: Check image percentage margins + const pageArea = isHeightAuto(page) + ? Infinity + : (page.box?.height || 0) - + pagePadding.paddingTop - + pagePadding.paddingBottom - + imageMargin.marginTop - + imageMargin.marginBottom - + SAFETY_HEIGHT; + const ctx = measureCtx(); + node.props.paint(ctx); + const width = ctx.getWidth(); + const height = Math.min(pageArea, ctx.getHeight()); + return { width, height }; +}; + +const isType$1 = (type) => (node) => node.type === type; +const isSvg = isType$1(P.Svg); +const isText$2 = isType$1(P.Text); +const isNote = isType$1(P.Note); +const isPage = isType$1(P.Page); +const isImage = isType$1(P.Image); +const isCanvas = isType$1(P.Canvas); +const isTextInstance$1 = isType$1(P.TextInstance); +const setNodeHeight = (node) => { + const value = isPage(node) ? node.box?.height : node.style?.height; + return setHeight(value); +}; +/** + * Set styles valeus into yoga node before layout calculation + * + * @param node + */ +const setYogaValues = (node) => { + compose(setNodeHeight(node), setWidth(node.style.width), setMinWidth(node.style.minWidth), setMaxWidth(node.style.maxWidth), setMinHeight(node.style.minHeight), setMaxHeight(node.style.maxHeight), setMarginTop(node.style.marginTop), setMarginRight(node.style.marginRight), setMarginBottom(node.style.marginBottom), setMarginLeft(node.style.marginLeft), setPaddingTop(node.style.paddingTop), setPaddingRight(node.style.paddingRight), setPaddingBottom(node.style.paddingBottom), setPaddingLeft(node.style.paddingLeft), setPositionType(node.style.position), setPositionTop(node.style.top), setPositionRight(node.style.right), setPositionBottom(node.style.bottom), setPositionLeft(node.style.left), setBorderTop(node.style.borderTopWidth), setBorderRight(node.style.borderRightWidth), setBorderBottom(node.style.borderBottomWidth), setBorderLeft(node.style.borderLeftWidth), setDisplay(node.style.display), setFlexDirection(node.style.flexDirection), setAlignSelf(node.style.alignSelf), setAlignContent(node.style.alignContent), setAlignItems(node.style.alignItems), setJustifyContent(node.style.justifyContent), setFlexWrap(node.style.flexWrap), setOverflow(node.style.overflow), setAspectRatio(node.style.aspectRatio), setFlexBasis(node.style.flexBasis), setFlexGrow(node.style.flexGrow), setFlexShrink(node.style.flexShrink), setRowGap(node.style.rowGap), setColumnGap(node.style.columnGap))(node); +}; +/** + * Inserts child into parent' yoga node + * + * @param parent parent + * @returns Insert yoga nodes + */ +const insertYogaNodes = (parent) => (child) => { + parent.insertChild(child.yogaNode, parent.getChildCount()); + return child; +}; +const setMeasureFunc = (node, page, fontStore) => { + const { yogaNode } = node; + if (isText$2(node)) { + yogaNode.setMeasureFunc(measureText(page, node, fontStore)); + } + if (isImage(node)) { + yogaNode.setMeasureFunc(measureImage(page, node)); + } + if (isCanvas(node)) { + yogaNode.setMeasureFunc(measureCanvas(page, node)); + } + if (isSvg(node)) { + yogaNode.setMeasureFunc(measureCanvas$1(page, node)); + } + return node; +}; +const isLayoutElement = (node) => !isText$2(node) && !isNote(node) && !isSvg(node); +/** + * @typedef {Function} CreateYogaNodes + * @param {Object} node + * @returns {Object} node with appended yoga node + */ +/** + * Creates and add yoga node to document tree + * Handles measure function for text and image nodes + * + * @returns Create yoga nodes + */ +const createYogaNodes = (page, fontStore, yoga) => (node) => { + const yogaNode = yoga.node.create(); + const result = Object.assign({}, node, { yogaNode }); + setYogaValues(result); + if (isLayoutElement(node) && node.children) { + const resolveChild = compose(insertYogaNodes(yogaNode), createYogaNodes(page, fontStore, yoga)); + result.children = node.children.map(resolveChild); + } + setMeasureFunc(result, page, fontStore); + return result; +}; +/** + * Performs yoga calculation + * + * @param page - Page node + * @returns Page node + */ +const calculateLayout = (page) => { + page.yogaNode.calculateLayout(); + return page; +}; +/** + * Saves Yoga layout result into 'box' attribute of node + * + * @param node + * @returns Node with box data + */ +const persistDimensions = (node) => { + if (isTextInstance$1(node)) + return node; + const box = Object.assign(getPadding(node), getMargin(node), getBorderWidth(node), getPosition(node), getDimension(node)); + const newNode = Object.assign({}, node, { box }); + if (!node.children) + return newNode; + const children = node.children.map(persistDimensions); + return Object.assign({}, newNode, { children }); +}; +/** + * Removes yoga node from document tree + * + * @param node + * @returns Node without yoga node + */ +const destroyYogaNodes = (node) => { + const newNode = Object.assign({}, node); + delete newNode.yogaNode; + if (!node.children) + return newNode; + const children = node.children.map(destroyYogaNodes); + return Object.assign({}, newNode, { children }); +}; +/** + * Free yoga node from document tree + * + * @param node + * @returns Node without yoga node + */ +const freeYogaNodes = (node) => { + if (node.yogaNode) + node.yogaNode.freeRecursive(); + return node; +}; +/** + * Calculates page object layout using Yoga. + * Takes node values from 'box' and 'style' attributes, and persist them back into 'box' + * Destroy yoga values at the end. + * + * @param page - Object + * @returns Page object with correct 'box' layout attributes + */ +const resolvePageDimensions = (page, fontStore, yoga) => { + if (isNil(page)) + return null; + return compose(destroyYogaNodes, freeYogaNodes, persistDimensions, calculateLayout, createYogaNodes(page, fontStore, yoga))(page); +}; +/** + * Calculates root object layout using Yoga. + * + * @param node - Root object + * @param fontStore - Font store + * @returns Root object with correct 'box' layout attributes + */ +const resolveDimensions = (node, fontStore) => { + if (!node.children) + return node; + const resolveChild = (child) => resolvePageDimensions(child, fontStore, node.yoga); + const children = node.children.map(resolveChild); + return Object.assign({}, node, { children }); +}; + +const isText$1 = (node) => node.type === P.Text; +// Prevent splitting elements by low decimal numbers +const SAFETY_THRESHOLD = 0.001; +const assingChildren = (children, node) => Object.assign({}, node, { children }); +const getTop = (node) => node.box?.top || 0; +const allFixed = (nodes) => nodes.every(isFixed); +const isDynamic = (node) => node.props && 'render' in node.props; +const relayoutPage = compose(resolveTextLayout, resolvePageDimensions, resolveInheritance, resolvePageStyles); +const warnUnavailableSpace = (node) => { + console.warn(`Node of type ${node.type} can't wrap between pages and it's bigger than available page height`); +}; +const splitNodes = (height, contentArea, nodes) => { + const currentChildren = []; + const nextChildren = []; + for (let i = 0; i < nodes.length; i += 1) { + const child = nodes[i]; + const futureNodes = nodes.slice(i + 1); + const futureFixedNodes = futureNodes.filter(isFixed); + const nodeTop = getTop(child); + const nodeHeight = child.box.height; + const isOutside = height <= nodeTop; + const shouldBreak$1 = shouldBreak(child, futureNodes, height, currentChildren); + const shouldSplit = height + SAFETY_THRESHOLD < nodeTop + nodeHeight; + const canWrap = getWrap(child); + const fitsInsidePage = nodeHeight <= contentArea; + if (isFixed(child)) { + nextChildren.push(child); + currentChildren.push(child); + continue; + } + if (isOutside) { + const box = Object.assign({}, child.box, { top: child.box.top - height }); + const next = Object.assign({}, child, { box }); + nextChildren.push(next); + continue; + } + if (!fitsInsidePage && !canWrap) { + currentChildren.push(child); + nextChildren.push(...futureNodes); + warnUnavailableSpace(child); + break; + } + if (shouldBreak$1) { + const box = Object.assign({}, child.box, { top: child.box.top - height }); + const props = Object.assign({}, child.props, { + wrap: true, + break: false, + }); + const next = Object.assign({}, child, { box, props }); + currentChildren.push(...futureFixedNodes); + nextChildren.push(next, ...futureNodes); + break; + } + if (shouldSplit) { + const [currentChild, nextChild] = split(child, height, contentArea); + // All children are moved to the next page, it doesn't make sense to show the parent on the current page + if (child.children.length > 0 && currentChild.children.length === 0) { + // But if the current page is empty then we can just include the parent on the current page + if (currentChildren.length === 0) { + currentChildren.push(child, ...futureFixedNodes); + nextChildren.push(...futureNodes); + } + else { + const box = Object.assign({}, child.box, { + top: child.box.top - height, + }); + const next = Object.assign({}, child, { box }); + currentChildren.push(...futureFixedNodes); + nextChildren.push(next, ...futureNodes); + } + break; + } + if (currentChild) + currentChildren.push(currentChild); + if (nextChild) + nextChildren.push(nextChild); + continue; + } + currentChildren.push(child); + } + return [currentChildren, nextChildren]; +}; +const splitChildren = (height, contentArea, node) => { + const children = node.children || []; + const availableHeight = height - getTop(node); + return splitNodes(availableHeight, contentArea, children); +}; +const splitView = (node, height, contentArea) => { + const [currentNode, nextNode] = splitNode(node, height); + const [currentChilds, nextChildren] = splitChildren(height, contentArea, node); + return [ + assingChildren(currentChilds, currentNode), + assingChildren(nextChildren, nextNode), + ]; +}; +const split = (node, height, contentArea) => isText$1(node) ? splitText(node, height) : splitView(node, height, contentArea); +const shouldResolveDynamicNodes = (node) => { + const children = node.children || []; + return isDynamic(node) || children.some(shouldResolveDynamicNodes); +}; +const resolveDynamicNodes = (props, node) => { + const isNodeDynamic = isDynamic(node); + // Call render prop on dynamic nodes and append result to children + const resolveChildren = (children = []) => { + if (isNodeDynamic) { + const res = node.props.render(props); + return (createInstances(res) + .filter(Boolean) + // @ts-expect-error rework dynamic nodes. conflicting types + .map((n) => resolveDynamicNodes(props, n))); + } + return children.map((c) => resolveDynamicNodes(props, c)); + }; + // We reset dynamic text box so it can be computed again later on + const resetHeight = isNodeDynamic && isText$1(node); + const box = resetHeight ? { ...node.box, height: 0 } : node.box; + const children = resolveChildren(node.children); + // @ts-expect-error handle text here specifically + const lines = isNodeDynamic ? null : node.lines; + return Object.assign({}, node, { box, lines, children }); +}; +const resolveDynamicPage = (props, page, fontStore, yoga) => { + if (shouldResolveDynamicNodes(page)) { + const resolvedPage = resolveDynamicNodes(props, page); + return relayoutPage(resolvedPage, fontStore, yoga); + } + return page; +}; +const splitPage = (page, pageNumber, fontStore, yoga) => { + const wrapArea = getWrapArea(page); + const contentArea = getContentArea(page); + const dynamicPage = resolveDynamicPage({ pageNumber }, page, fontStore, yoga); + const height = page.style.height; + const [currentChilds, nextChilds] = splitNodes(wrapArea, contentArea, dynamicPage.children); + const relayout = (node) => + // @ts-expect-error rework pagination + relayoutPage(node, fontStore, yoga); + const currentBox = { ...page.box, height }; + const currentPage = relayout(Object.assign({}, page, { box: currentBox, children: currentChilds })); + if (nextChilds.length === 0 || allFixed(nextChilds)) + return [currentPage, null]; + const nextBox = omit('height', page.box); + const nextProps = omit('bookmark', page.props); + const nextPage = relayout(Object.assign({}, page, { + props: nextProps, + box: nextBox, + children: nextChilds, + })); + return [currentPage, nextPage]; +}; +const resolvePageIndices = (fontStore, yoga, page, pageNumber, pages) => { + const totalPages = pages.length; + const props = { + totalPages, + pageNumber: pageNumber + 1, + subPageNumber: page.subPageNumber + 1, + subPageTotalPages: page.subPageTotalPages, + }; + return resolveDynamicPage(props, page, fontStore, yoga); +}; +const assocSubPageData = (subpages) => { + return subpages.map((page, i) => ({ + ...page, + subPageNumber: i, + subPageTotalPages: subpages.length, + })); +}; +const dissocSubPageData = (page) => { + return omit(['subPageNumber', 'subPageTotalPages'], page); +}; +const paginate = (page, pageNumber, fontStore, yoga) => { + if (!page) + return []; + if (page.props?.wrap === false) + return [page]; + let splittedPage = splitPage(page, pageNumber, fontStore, yoga); + const pages = [splittedPage[0]]; + let nextPage = splittedPage[1]; + while (nextPage !== null) { + splittedPage = splitPage(nextPage, pageNumber + pages.length, fontStore, yoga); + pages.push(splittedPage[0]); + nextPage = splittedPage[1]; + } + return pages; +}; +/** + * Performs pagination. This is the step responsible of breaking the whole document + * into pages following pagiation rules, such as `fixed`, `break` and dynamic nodes. + * + * @param root - Document node + * @param fontStore - Font store + * @returns Layout node + */ +const resolvePagination = (root, fontStore) => { + let pages = []; + let pageNumber = 1; + for (let i = 0; i < root.children.length; i += 1) { + const page = root.children[i]; + let subpages = paginate(page, pageNumber, fontStore, root.yoga); + subpages = assocSubPageData(subpages); + pageNumber += subpages.length; + pages = pages.concat(subpages); + } + pages = pages.map((...args) => dissocSubPageData(resolvePageIndices(fontStore, root.yoga, ...args))); + return assingChildren(pages, root); +}; + +/** + * Translates page percentage horizontal paddings in fixed ones + * + * @param container - Page container + * @returns Resolve page horizontal padding + */ +const resolvePageHorizontalPadding = (container) => (value) => { + const match = matchPercent(value); + const width = container.width; + return match ? match.percent * width : value; +}; +/** + * Translates page percentage vertical paddings in fixed ones + * + * @param container - Page container + * @returns Resolve page vertical padding + */ +const resolvePageVerticalPadding = (container) => (value) => { + const match = matchPercent(value); + const height = container.height; + return match ? match.percent * height : value; +}; +/** + * Translates page percentage paddings in fixed ones + * + * @param page + * @returns Page with fixed paddings + */ +const resolvePagePaddings = (page) => { + const container = page.style; + const style = evolve({ + paddingTop: resolvePageVerticalPadding(container), + paddingLeft: resolvePageHorizontalPadding(container), + paddingRight: resolvePageHorizontalPadding(container), + paddingBottom: resolvePageVerticalPadding(container), + }, page.style); + return Object.assign({}, page, { style }); +}; +/** + * Translates all pages percentage paddings in fixed ones + * This has to be computed from pages calculated size and not by Yoga + * because at this point we didn't performed pagination yet. + * + * @param root - Document root + * @returns Document root with translated page paddings + */ +const resolvePagesPaddings = (root) => { + if (!root.children) + return root; + const children = root.children.map(resolvePagePaddings); + return Object.assign({}, root, { children }); +}; + +const resolveRadius = (box) => (value) => { + if (!value) + return undefined; + const match = matchPercent(value); + return match ? match.percent * Math.min(box.width, box.height) : value; +}; +/** + * Transforms percent border radius into fixed values + * + * @param node + * @returns Node + */ +const resolvePercentRadius = (node) => { + const style = evolve({ + borderTopLeftRadius: resolveRadius(node.box), + borderTopRightRadius: resolveRadius(node.box), + borderBottomRightRadius: resolveRadius(node.box), + borderBottomLeftRadius: resolveRadius(node.box), + }, node.style || {}); + const newNode = Object.assign({}, node, { style }); + if (!node.children) + return newNode; + const children = node.children.map(resolvePercentRadius); + return Object.assign({}, newNode, { children }); +}; + +/** + * Transform percent height into fixed + * + * @param height + * @returns Height + */ +const transformHeight = (pageArea, height) => { + const match = matchPercent(height); + return match ? match.percent * pageArea : height; +}; +/** + * Get page area (height minus paddings) + * + * @param page + * @returns Page area + */ +const getPageArea = (page) => { + const pageHeight = page.style.height; + const pagePaddingTop = (page.style?.paddingTop || 0); + const pagePaddingBottom = (page.style?.paddingBottom || 0); + return pageHeight - pagePaddingTop - pagePaddingBottom; +}; +/** + * Transform node percent height to fixed + * + * @param page + * @param node + * @returns Transformed node + */ +const resolveNodePercentHeight = (page, node) => { + if (isNil(page.style?.height)) + return node; + if (isNil(node.style?.height)) + return node; + const pageArea = getPageArea(page); + const height = transformHeight(pageArea, node.style.height); + const style = Object.assign({}, node.style, { height }); + return Object.assign({}, node, { style }); +}; +/** + * Transform page immediate children with percent height to fixed + * + * @param page + * @returns Transformed page + */ +const resolvePagePercentHeight = (page) => { + if (!page.children) + return page; + const resolveChild = (child) => resolveNodePercentHeight(page, child); + const children = page.children.map(resolveChild); + return Object.assign({}, page, { children }); +}; +/** + * Transform all page immediate children with percent height to fixed. + * This is needed for computing correct dimensions on pre-pagination layout. + * + * @param root - Document root + * @returns Transformed document root + */ +const resolvePercentHeight = (root) => { + if (!root.children) + return root; + const children = root.children.map(resolvePagePercentHeight); + return Object.assign({}, root, { children }); +}; + +const isType = (type) => (node) => node.type === type; +const isLink = isType(P.Link); +const isText = isType(P.Text); +const isTextInstance = isType(P.TextInstance); +/** + * Checks if node has render prop + * + * @param node + * @returns Has render prop? + */ +const hasRenderProp = (node) => 'render' in node.props; +/** + * Checks if node is text type (Text or TextInstance) + * + * @param node + * @returns Are all children text instances? + */ +const isTextType = (node) => isText(node) || isTextInstance(node); +/** + * Checks if is tet link that needs to be wrapped in Text + * + * @param node + * @returns Are all children text instances? + */ +const isTextLink = (node) => { + const children = node.children || []; + // Text string inside a Link + if (children.every(isTextInstance)) + return true; + // Text node inside a Link + if (children.every(isText)) + return false; + return children.every(isTextType); +}; +/** + * Wraps node children inside Text node + * + * @param node + * @returns Node with intermediate Text child + */ +const wrapText = (node) => { + const textElement = { + type: P.Text, + props: {}, + style: {}, + box: {}, + children: node.children, + }; + return Object.assign({}, node, { children: [textElement] }); +}; +const transformLink = (node) => { + if (!isLink(node)) + return node; + // If has render prop substitute the instance by a Text, that will + // ultimately render the inline Link via the textkit PDF renderer. + if (hasRenderProp(node)) + return Object.assign({}, node, { type: P.Text }); + // If is a text link (either contains Text or TextInstance), wrap it + // inside a Text element so styles are applied correctly + if (isTextLink(node)) + return wrapText(node); + return node; +}; +/** + * Transforms Link layout to correctly render text and dynamic rendered links + * + * @param node + * @returns Node with link substitution + */ +const resolveLinkSubstitution = (node) => { + if (!node.children) + return node; + const resolveChild = compose(transformLink, resolveLinkSubstitution); + const children = node.children.map(resolveChild); + return Object.assign({}, node, { children }); +}; + +const layout = asyncCompose(resolveZIndex, resolveOrigin, resolveAssets, resolvePagination, resolveTextLayout, resolvePercentRadius, resolveDimensions, resolveSvg, resolveAssets, resolveInheritance, resolvePercentHeight, resolvePagesPaddings, resolveStyles, resolveLinkSubstitution, resolveBookmarks, resolvePageSizes, resolveYoga); + +export { layout as default }; diff --git a/node_modules/@react-pdf/layout/package.json b/node_modules/@react-pdf/layout/package.json new file mode 100644 index 0000000000000000000000000000000000000000..5f31fac944b88a48ab628d11244a1bdebff66508 --- /dev/null +++ b/node_modules/@react-pdf/layout/package.json @@ -0,0 +1,36 @@ +{ + "name": "@react-pdf/layout", + "version": "4.6.1", + "license": "MIT", + "description": "Resolve document component's layout", + "author": "Diego Muracciole ", + "homepage": "https://github.com/diegomura/react-pdf#readme", + "type": "module", + "main": "./lib/index.js", + "types": "./lib/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/diegomura/react-pdf.git", + "directory": "packages/layout" + }, + "scripts": { + "test": "vitest", + "build": "rimraf ./lib && rollup -c", + "watch": "rimraf ./lib && rollup -c -w", + "typecheck": "tsc --noEmit" + }, + "dependencies": { + "@react-pdf/fns": "3.1.3", + "@react-pdf/image": "^3.1.0", + "@react-pdf/primitives": "^4.3.0", + "@react-pdf/stylesheet": "^6.2.1", + "@react-pdf/textkit": "^6.3.0", + "@react-pdf/types": "^2.11.1", + "emoji-regex-xs": "^1.0.0", + "queue": "^6.0.1", + "yoga-layout": "^3.2.1" + }, + "files": [ + "lib" + ] +} diff --git a/node_modules/@react-pdf/pdfkit/LICENSE b/node_modules/@react-pdf/pdfkit/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..5f5982ee81b9f832d48fcd6a516bf98ef539f5c9 --- /dev/null +++ b/node_modules/@react-pdf/pdfkit/LICENSE @@ -0,0 +1,8 @@ +MIT LICENSE +Copyright (c) 2014 Devon Govett + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/@react-pdf/pdfkit/README.md b/node_modules/@react-pdf/pdfkit/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0627d5f88515d6b5e042ee92ef17132bd5178522 --- /dev/null +++ b/node_modules/@react-pdf/pdfkit/README.md @@ -0,0 +1,73 @@ +

+ +

+ +# @react-pdf/pdfkit + +A JavaScript PDF generation library for Node and the browser. + +## Acknowledges + +This project is a fork of [pdfkit](https://github.com/foliojs/pdfkit) by @devongovett and continued under the scope of this project since it has react-pdf specific features. Any recongnition should go to him and the original project mantainers. + +## Description + +PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable documents easy. +It's written in CoffeeScript, but you can choose to use the API in plain 'ol JavaScript if you like. The API embraces +chainability, and includes both low level functions as well as abstractions for higher level functionality. The PDFKit API +is designed to be simple, so generating complex documents is often as simple as a few function calls. + +Check out some of the [documentation and examples](http://pdfkit.org/docs/getting_started.html) to see for yourself! +You can also read the guide as a [self-generated PDF](http://pdfkit.org/docs/guide.pdf) with example output displayed inline. +If you'd like to see how it was generated, check out the README in the [docs](https://github.com/devongovett/pdfkit/tree/master/docs) +folder. + +You can also try out an interactive in-browser demo of PDFKit [here](http://pdfkit.org/demo/browser.html). + +## Installation + +Installation uses the [npm](http://npmjs.org/) package manager. Just type the following command after installing npm. + + npm install @react-pdf/pdfkit + +## Features + +- Vector graphics + - HTML5 canvas-like API + - Path operations + - SVG path parser for easy path creation + - Transformations + - Linear and radial gradients +- Text + - Line wrapping + - Text alignments + - Bulleted lists +- Font embedding + - Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collections (.ttc), and Datafork TrueType (.dfont) fonts + - Font subsetting + - See [fontkit](http://github.com/devongovett/fontkit) for more details on advanced glyph layout support. +- Image embedding + - Supports JPEG and PNG files (including indexed PNGs, and PNGs with transparency) +- Annotations + - Links + - Notes + - Highlights + - Underlines + - etc. + +## Coming soon! + +- Patterns fills +- Outlines +- PDF Security +- Higher level APIs for creating tables and laying out content +- More performance optimizations +- Even more awesomeness, perhaps written by you! Please fork this repository and send me pull requests. + +## Documentation + +For complete API documentation and more examples, see the [PDFKit website](http://pdfkit.org/). + +## License + +PDFKit is available under the MIT license. diff --git a/node_modules/@react-pdf/pdfkit/lib/pdfkit.browser.js b/node_modules/@react-pdf/pdfkit/lib/pdfkit.browser.js new file mode 100644 index 0000000000000000000000000000000000000000..67511169d9143b1acb2a197f5bec034cd588a072 --- /dev/null +++ b/node_modules/@react-pdf/pdfkit/lib/pdfkit.browser.js @@ -0,0 +1,50030 @@ +import require$$1$2 from 'pako/lib/zlib/zstream.js'; +import require$$2 from 'pako/lib/zlib/deflate.js'; +import require$$3$1 from 'pako/lib/zlib/inflate.js'; +import require$$4$1 from 'pako/lib/zlib/constants.js'; +import md5 from 'js-md5'; +import { cbc, ecb } from '@noble/ciphers/aes'; +import * as fontkit from 'fontkit'; +import LineBreaker from 'linebreak'; +import _JPEG from 'jay-peg'; +import PNG from 'png-js'; + +var global$1 = (typeof global !== "undefined" ? global : + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : {}); + +var lookup = []; +var revLookup = []; +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; +var inited = false; +function init () { + inited = true; + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i]; + revLookup[code.charCodeAt(i)] = i; + } + + revLookup['-'.charCodeAt(0)] = 62; + revLookup['_'.charCodeAt(0)] = 63; +} + +function toByteArray (b64) { + if (!inited) { + init(); + } + var i, j, l, tmp, placeHolders, arr; + var len = b64.length; + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0; + + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(len * 3 / 4 - placeHolders); + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len; + + var L = 0; + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]; + arr[L++] = (tmp >> 16) & 0xFF; + arr[L++] = (tmp >> 8) & 0xFF; + arr[L++] = tmp & 0xFF; + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4); + arr[L++] = tmp & 0xFF; + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2); + arr[L++] = (tmp >> 8) & 0xFF; + arr[L++] = tmp & 0xFF; + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp; + var output = []; + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]); + output.push(tripletToBase64(tmp)); + } + return output.join('') +} + +function fromByteArray (uint8) { + if (!inited) { + init(); + } + var tmp; + var len = uint8.length; + var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes + var output = ''; + var parts = []; + var maxChunkLength = 16383; // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))); + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1]; + output += lookup[tmp >> 2]; + output += lookup[(tmp << 4) & 0x3F]; + output += '=='; + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]); + output += lookup[tmp >> 10]; + output += lookup[(tmp >> 4) & 0x3F]; + output += lookup[(tmp << 2) & 0x3F]; + output += '='; + } + + parts.push(output); + + return parts.join('') +} + +function read (buffer, offset, isLE, mLen, nBytes) { + var e, m; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i = isLE ? (nBytes - 1) : 0; + var d = isLE ? -1 : 1; + var s = buffer[offset + i]; + + i += d; + + e = s & ((1 << (-nBits)) - 1); + s >>= (-nBits); + nBits += eLen; + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1); + e >>= (-nBits); + nBits += mLen; + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen); + e = e - eBias; + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +function write (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0); + var i = isLE ? 0 : (nBytes - 1); + var d = isLE ? 1 : -1; + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; + + value = Math.abs(value); + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0; + e = eMax; + } else { + e = Math.floor(Math.log(value) / Math.LN2); + if (value * (c = Math.pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen); + e = e + eBias; + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e = 0; + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128; +} + +var toString = {}.toString; + +var isArray$1 = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + + +var INSPECT_MAX_BYTES = 50; + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ +Buffer$2.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined + ? global$1.TYPED_ARRAY_SUPPORT + : true; + +/* + * Export kMaxLength after typed array support is determined. + */ +var _kMaxLength = kMaxLength(); + +function kMaxLength () { + return Buffer$2.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff +} + +function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length); + that.__proto__ = Buffer$2.prototype; + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer$2(length); + } + that.length = length; + } + + return that +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer$2 (arg, encodingOrOffset, length) { + if (!Buffer$2.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$2)) { + return new Buffer$2(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from$1(this, arg, encodingOrOffset, length) +} + +Buffer$2.poolSize = 8192; // not used by this implementation + +// TODO: Legacy, not needed anymore. Remove in next major version. +Buffer$2._augment = function (arr) { + arr.__proto__ = Buffer$2.prototype; + return arr +}; + +function from$1 (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer$2.from = function (value, encodingOrOffset, length) { + return from$1(null, value, encodingOrOffset, length) +}; + +if (Buffer$2.TYPED_ARRAY_SUPPORT) { + Buffer$2.prototype.__proto__ = Uint8Array.prototype; + Buffer$2.__proto__ = Uint8Array; + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer$2[Symbol.species] === Buffer$2) ; +} + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (that, size, fill, encoding) { + assertSize(size); + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer$2.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) +}; + +function allocUnsafe (that, size) { + assertSize(size); + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0); + if (!Buffer$2.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0; + } + } + return that +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer$2.allocUnsafe = function (size) { + return allocUnsafe(null, size) +}; +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer$2.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) +}; + +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8'; + } + + if (!Buffer$2.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0; + that = createBuffer(that, length); + + var actual = that.write(string, encoding); + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual); + } + + return that +} + +function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0; + that = createBuffer(that, length); + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255; + } + return that +} + +function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength; // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array); + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset); + } else { + array = new Uint8Array(array, byteOffset, length); + } + + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = array; + that.__proto__ = Buffer$2.prototype; + } else { + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array); + } + return that +} + +function fromObject (that, obj) { + if (internalIsBuffer(obj)) { + var len = checked(obj.length) | 0; + that = createBuffer(that, len); + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len); + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray$1(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') +} + +function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0; + } + return Buffer$2.alloc(+length) +} +Buffer$2.isBuffer = isBuffer$1; +function internalIsBuffer (b) { + return !!(b != null && b._isBuffer) +} + +Buffer$2.compare = function compare (a, b) { + if (!internalIsBuffer(a) || !internalIsBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +}; + +Buffer$2.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +}; + +Buffer$2.concat = function concat (list, length) { + if (!isArray$1(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer$2.alloc(0) + } + + var i; + if (length === undefined) { + length = 0; + for (i = 0; i < list.length; ++i) { + length += list[i].length; + } + } + + var buffer = Buffer$2.allocUnsafe(length); + var pos = 0; + for (i = 0; i < list.length; ++i) { + var buf = list[i]; + if (!internalIsBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos); + pos += buf.length; + } + return buffer +}; + +function byteLength (string, encoding) { + if (internalIsBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string; + } + + var len = string.length; + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false; + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes$1(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes$1(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } +} +Buffer$2.byteLength = byteLength; + +function slowToString (encoding, start, end) { + var loweredCase = false; + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0; + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length; + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0; + start >>>= 0; + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8'; + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase(); + loweredCase = true; + } + } +} + +// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +// Buffer instances. +Buffer$2.prototype._isBuffer = true; + +function swap (b, n, m) { + var i = b[n]; + b[n] = b[m]; + b[m] = i; +} + +Buffer$2.prototype.swap16 = function swap16 () { + var len = this.length; + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1); + } + return this +}; + +Buffer$2.prototype.swap32 = function swap32 () { + var len = this.length; + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3); + swap(this, i + 1, i + 2); + } + return this +}; + +Buffer$2.prototype.swap64 = function swap64 () { + var len = this.length; + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7); + swap(this, i + 1, i + 6); + swap(this, i + 2, i + 5); + swap(this, i + 3, i + 4); + } + return this +}; + +Buffer$2.prototype.toString = function toString () { + var length = this.length | 0; + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +}; + +Buffer$2.prototype.equals = function equals (b) { + if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer$2.compare(this, b) === 0 +}; + +Buffer$2.prototype.inspect = function inspect () { + var str = ''; + var max = INSPECT_MAX_BYTES; + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' '); + if (this.length > max) str += ' ... '; + } + return '' +}; + +Buffer$2.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!internalIsBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0; + } + if (end === undefined) { + end = target ? target.length : 0; + } + if (thisStart === undefined) { + thisStart = 0; + } + if (thisEnd === undefined) { + thisEnd = this.length; + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0; + end >>>= 0; + thisStart >>>= 0; + thisEnd >>>= 0; + + if (this === target) return 0 + + var x = thisEnd - thisStart; + var y = end - start; + var len = Math.min(x, y); + + var thisCopy = this.slice(thisStart, thisEnd); + var targetCopy = target.slice(start, end); + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i]; + y = targetCopy[i]; + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +}; + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset; + byteOffset = 0; + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff; + } else if (byteOffset < -2147483648) { + byteOffset = -2147483648; + } + byteOffset = +byteOffset; // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1); + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset; + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1; + } else if (byteOffset < 0) { + if (dir) byteOffset = 0; + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer$2.from(val, encoding); + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (internalIsBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF; // Search for a byte value [0-255] + if (Buffer$2.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1; + var arrLength = arr.length; + var valLength = val.length; + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase(); + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2; + arrLength /= 2; + valLength /= 2; + byteOffset /= 2; + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i; + if (dir) { + var foundIndex = -1; + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i; + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex; + foundIndex = -1; + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; + for (i = byteOffset; i >= 0; i--) { + var found = true; + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false; + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer$2.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +}; + +Buffer$2.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +}; + +Buffer$2.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +}; + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0; + var remaining = buf.length - offset; + if (!length) { + length = remaining; + } else { + length = Number(length); + if (length > remaining) { + length = remaining; + } + } + + // must be an even number of digits + var strLen = string.length; + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2; + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16); + if (isNaN(parsed)) return i + buf[offset + i] = parsed; + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes$1(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer$2.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8'; + length = this.length; + offset = 0; + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset; + length = this.length; + offset = 0; + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0; + if (isFinite(length)) { + length = length | 0; + if (encoding === undefined) encoding = 'utf8'; + } else { + encoding = length; + length = undefined; + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset; + if (length === undefined || length > remaining) length = remaining; + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8'; + + var loweredCase = false; + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } +}; + +Buffer$2.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +}; + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return fromByteArray(buf) + } else { + return fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end); + var res = []; + + var i = start; + while (i < end) { + var firstByte = buf[i]; + var codePoint = null; + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1; + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint; + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte; + } + break + case 2: + secondByte = buf[i + 1]; + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F); + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint; + } + } + break + case 3: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F); + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint; + } + } + break + case 4: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + fourthByte = buf[i + 3]; + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F); + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint; + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD; + bytesPerSequence = 1; + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000; + res.push(codePoint >>> 10 & 0x3FF | 0xD800); + codePoint = 0xDC00 | codePoint & 0x3FF; + } + + res.push(codePoint); + i += bytesPerSequence; + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000; + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length; + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = ''; + var i = 0; + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ); + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F); + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]); + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length; + + if (!start || start < 0) start = 0; + if (!end || end < 0 || end > len) end = len; + + var out = ''; + for (var i = start; i < end; ++i) { + out += toHex$1(buf[i]); + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end); + var res = ''; + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); + } + return res +} + +Buffer$2.prototype.slice = function slice (start, end) { + var len = this.length; + start = ~~start; + end = end === undefined ? len : ~~end; + + if (start < 0) { + start += len; + if (start < 0) start = 0; + } else if (start > len) { + start = len; + } + + if (end < 0) { + end += len; + if (end < 0) end = 0; + } else if (end > len) { + end = len; + } + + if (end < start) end = start; + + var newBuf; + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + newBuf = this.subarray(start, end); + newBuf.__proto__ = Buffer$2.prototype; + } else { + var sliceLen = end - start; + newBuf = new Buffer$2(sliceLen, undefined); + for (var i = 0; i < sliceLen; ++i) { + newBuf[i] = this[i + start]; + } + } + + return newBuf +}; + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer$2.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + var val = this[offset]; + var mul = 1; + var i = 0; + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + + return val +}; + +Buffer$2.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) { + checkOffset(offset, byteLength, this.length); + } + + var val = this[offset + --byteLength]; + var mul = 1; + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul; + } + + return val +}; + +Buffer$2.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length); + return this[offset] +}; + +Buffer$2.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + return this[offset] | (this[offset + 1] << 8) +}; + +Buffer$2.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + return (this[offset] << 8) | this[offset + 1] +}; + +Buffer$2.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +}; + +Buffer$2.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +}; + +Buffer$2.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + var val = this[offset]; + var mul = 1; + var i = 0; + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + mul *= 0x80; + + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + + return val +}; + +Buffer$2.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + var i = byteLength; + var mul = 1; + var val = this[offset + --i]; + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul; + } + mul *= 0x80; + + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + + return val +}; + +Buffer$2.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length); + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +}; + +Buffer$2.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset] | (this[offset + 1] << 8); + return (val & 0x8000) ? val | 0xFFFF0000 : val +}; + +Buffer$2.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset + 1] | (this[offset] << 8); + return (val & 0x8000) ? val | 0xFFFF0000 : val +}; + +Buffer$2.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +}; + +Buffer$2.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +}; + +Buffer$2.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + return read(this, offset, true, 23, 4) +}; + +Buffer$2.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + return read(this, offset, false, 23, 4) +}; + +Buffer$2.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length); + return read(this, offset, true, 52, 8) +}; + +Buffer$2.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length); + return read(this, offset, false, 52, 8) +}; + +function checkInt (buf, value, offset, ext, max, min) { + if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer$2.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var mul = 1; + var i = 0; + this[offset] = value & 0xFF; + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF; + } + + return offset + byteLength +}; + +Buffer$2.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var i = byteLength - 1; + var mul = 1; + this[offset + i] = value & 0xFF; + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF; + } + + return offset + byteLength +}; + +Buffer$2.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); + if (!Buffer$2.TYPED_ARRAY_SUPPORT) value = Math.floor(value); + this[offset] = (value & 0xff); + return offset + 1 +}; + +function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1; + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8; + } +} + +Buffer$2.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff); + this[offset + 1] = (value >>> 8); + } else { + objectWriteUInt16(this, value, offset, true); + } + return offset + 2 +}; + +Buffer$2.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8); + this[offset + 1] = (value & 0xff); + } else { + objectWriteUInt16(this, value, offset, false); + } + return offset + 2 +}; + +function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1; + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff; + } +} + +Buffer$2.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24); + this[offset + 2] = (value >>> 16); + this[offset + 1] = (value >>> 8); + this[offset] = (value & 0xff); + } else { + objectWriteUInt32(this, value, offset, true); + } + return offset + 4 +}; + +Buffer$2.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24); + this[offset + 1] = (value >>> 16); + this[offset + 2] = (value >>> 8); + this[offset + 3] = (value & 0xff); + } else { + objectWriteUInt32(this, value, offset, false); + } + return offset + 4 +}; + +Buffer$2.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = 0; + var mul = 1; + var sub = 0; + this[offset] = value & 0xFF; + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1; + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF; + } + + return offset + byteLength +}; + +Buffer$2.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = byteLength - 1; + var mul = 1; + var sub = 0; + this[offset + i] = value & 0xFF; + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1; + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF; + } + + return offset + byteLength +}; + +Buffer$2.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128); + if (!Buffer$2.TYPED_ARRAY_SUPPORT) value = Math.floor(value); + if (value < 0) value = 0xff + value + 1; + this[offset] = (value & 0xff); + return offset + 1 +}; + +Buffer$2.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768); + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff); + this[offset + 1] = (value >>> 8); + } else { + objectWriteUInt16(this, value, offset, true); + } + return offset + 2 +}; + +Buffer$2.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768); + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8); + this[offset + 1] = (value & 0xff); + } else { + objectWriteUInt16(this, value, offset, false); + } + return offset + 2 +}; + +Buffer$2.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648); + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff); + this[offset + 1] = (value >>> 8); + this[offset + 2] = (value >>> 16); + this[offset + 3] = (value >>> 24); + } else { + objectWriteUInt32(this, value, offset, true); + } + return offset + 4 +}; + +Buffer$2.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648); + if (value < 0) value = 0xffffffff + value + 1; + if (Buffer$2.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24); + this[offset + 1] = (value >>> 16); + this[offset + 2] = (value >>> 8); + this[offset + 3] = (value & 0xff); + } else { + objectWriteUInt32(this, value, offset, false); + } + return offset + 4 +}; + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4); + } + write(buf, value, offset, littleEndian, 23, 4); + return offset + 4 +} + +Buffer$2.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +}; + +Buffer$2.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +}; + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8); + } + write(buf, value, offset, littleEndian, 52, 8); + return offset + 8 +} + +Buffer$2.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +}; + +Buffer$2.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +}; + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer$2.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0; + if (!end && end !== 0) end = this.length; + if (targetStart >= target.length) targetStart = target.length; + if (!targetStart) targetStart = 0; + if (end > 0 && end < start) end = start; + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length; + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start; + } + + var len = end - start; + var i; + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start]; + } + } else if (len < 1000 || !Buffer$2.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start]; + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ); + } + + return len +}; + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer$2.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start; + start = 0; + end = this.length; + } else if (typeof end === 'string') { + encoding = end; + end = this.length; + } + if (val.length === 1) { + var code = val.charCodeAt(0); + if (code < 256) { + val = code; + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer$2.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255; + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0; + end = end === undefined ? this.length : end >>> 0; + + if (!val) val = 0; + + var i; + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val; + } + } else { + var bytes = internalIsBuffer(val) + ? val + : utf8ToBytes$1(new Buffer$2(val, encoding).toString()); + var len = bytes.length; + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len]; + } + } + + return this +}; + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g; + +function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, ''); + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '='; + } + return str +} + +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} + +function toHex$1 (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes$1 (string, units) { + units = units || Infinity; + var codePoint; + var length = string.length; + var leadSurrogate = null; + var bytes = []; + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i); + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue + } + + // valid lead + leadSurrogate = codePoint; + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + leadSurrogate = codePoint; + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + } + + leadSurrogate = null; + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint); + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ); + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ); + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ); + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = []; + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF); + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo; + var byteArray = []; + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i); + hi = c >> 8; + lo = c % 256; + byteArray.push(lo); + byteArray.push(hi); + } + + return byteArray +} + + +function base64ToBytes (str) { + return toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i]; + } + return i +} + +function isnan (val) { + return val !== val // eslint-disable-line no-self-compare +} + + +// the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence +// The _isBuffer check is for Safari 5-7 support, because it's missing +// Object.prototype.constructor. Remove this eventually +function isBuffer$1(obj) { + return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj)) +} + +function isFastBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +} + +// For Node v0.10 support. Remove this eventually. +function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0)) +} + +var _polyfillNode_buffer = /*#__PURE__*/Object.freeze({ + __proto__: null, + Buffer: Buffer$2, + INSPECT_MAX_BYTES: INSPECT_MAX_BYTES, + SlowBuffer: SlowBuffer, + isBuffer: isBuffer$1, + kMaxLength: _kMaxLength +}); + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (n.__esModule) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + if (this instanceof a) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var readableBrowser = {exports: {}}; + +var _registry = {}; + +// shim for using process in browser +// based off https://github.com/defunctzombie/node-process/blob/master/browser.js + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +var cachedSetTimeout = defaultSetTimout; +var cachedClearTimeout = defaultClearTimeout; +if (typeof global$1.setTimeout === 'function') { + cachedSetTimeout = setTimeout; +} +if (typeof global$1.clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; +} + +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} +function nextTick(fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +} +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +var title = 'browser'; +var platform = 'browser'; +var browser$1 = true; +var env = {}; +var argv = []; +var version = ''; // empty string to avoid regexp issues +var versions = {}; +var release = {}; +var config$1 = {}; + +function noop$2() {} + +var on = noop$2; +var addListener = noop$2; +var once$2 = noop$2; +var off = noop$2; +var removeListener = noop$2; +var removeAllListeners = noop$2; +var emit = noop$2; + +function binding$1(name) { + throw new Error('process.binding is not supported'); +} + +function cwd () { return '/' } +function chdir (dir) { + throw new Error('process.chdir is not supported'); +}function umask() { return 0; } + +// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js +var performance = global$1.performance || {}; +var performanceNow = + performance.now || + performance.mozNow || + performance.msNow || + performance.oNow || + performance.webkitNow || + function(){ return (new Date()).getTime() }; + +// generate timestamp or delta +// see http://nodejs.org/api/process.html#process_process_hrtime +function hrtime(previousTimestamp){ + var clocktime = performanceNow.call(performance)*1e-3; + var seconds = Math.floor(clocktime); + var nanoseconds = Math.floor((clocktime%1)*1e9); + if (previousTimestamp) { + seconds = seconds - previousTimestamp[0]; + nanoseconds = nanoseconds - previousTimestamp[1]; + if (nanoseconds<0) { + seconds--; + nanoseconds += 1e9; + } + } + return [seconds,nanoseconds] +} + +var startTime = new Date(); +function uptime() { + var currentTime = new Date(); + var dif = currentTime - startTime; + return dif / 1000; +} + +var browser$1$1 = { + nextTick: nextTick, + title: title, + browser: browser$1, + env: env, + argv: argv, + version: version, + versions: versions, + on: on, + addListener: addListener, + once: once$2, + off: off, + removeListener: removeListener, + removeAllListeners: removeAllListeners, + emit: emit, + binding: binding$1, + cwd: cwd, + chdir: chdir, + umask: umask, + hrtime: hrtime, + platform: platform, + release: release, + config: config$1, + uptime: uptime +}; + +var domain; + +// This constructor is used to store event handlers. Instantiating this is +// faster than explicitly calling `Object.create(null)` to get a "clean" empty +// object (tested with v8 v4.9). +function EventHandlers() {} +EventHandlers.prototype = Object.create(null); + +function EventEmitter() { + EventEmitter.init.call(this); +} + +// nodejs oddity +// require('events') === require('events').EventEmitter +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.usingDomains = false; + +EventEmitter.prototype.domain = undefined; +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +EventEmitter.init = function() { + this.domain = null; + if (EventEmitter.usingDomains) { + // if there is an active domain, then attach to it. + if (domain.active && !(this instanceof domain.Domain)) { + this.domain = domain.active; + } + } + + if (!this._events || this._events === Object.getPrototypeOf(this)._events) { + this._events = new EventHandlers(); + this._eventsCount = 0; + } + + this._maxListeners = this._maxListeners || undefined; +}; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { + if (typeof n !== 'number' || n < 0 || isNaN(n)) + throw new TypeError('"n" argument must be a positive number'); + this._maxListeners = n; + return this; +}; + +function $getMaxListeners(that) { + if (that._maxListeners === undefined) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; +} + +EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return $getMaxListeners(this); +}; + +// These standalone emit* functions are used to optimize calling of event +// handlers for fast cases because emit() itself often has a variable number of +// arguments and can be deoptimized because of that. These functions always have +// the same number of arguments and thus do not get deoptimized, so the code +// inside them can execute faster. +function emitNone(handler, isFn, self) { + if (isFn) + handler.call(self); + else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + listeners[i].call(self); + } +} +function emitOne(handler, isFn, self, arg1) { + if (isFn) + handler.call(self, arg1); + else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + listeners[i].call(self, arg1); + } +} +function emitTwo(handler, isFn, self, arg1, arg2) { + if (isFn) + handler.call(self, arg1, arg2); + else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + listeners[i].call(self, arg1, arg2); + } +} +function emitThree(handler, isFn, self, arg1, arg2, arg3) { + if (isFn) + handler.call(self, arg1, arg2, arg3); + else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + listeners[i].call(self, arg1, arg2, arg3); + } +} + +function emitMany(handler, isFn, self, args) { + if (isFn) + handler.apply(self, args); + else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + listeners[i].apply(self, args); + } +} + +EventEmitter.prototype.emit = function emit(type) { + var er, handler, len, args, i, events, domain; + var doError = (type === 'error'); + + events = this._events; + if (events) + doError = (doError && events.error == null); + else if (!doError) + return false; + + domain = this.domain; + + // If there is no 'error' event listener then throw. + if (doError) { + er = arguments[1]; + if (domain) { + if (!er) + er = new Error('Uncaught, unspecified "error" event'); + er.domainEmitter = this; + er.domain = domain; + er.domainThrown = false; + domain.emit('error', er); + } else if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + return false; + } + + handler = events[type]; + + if (!handler) + return false; + + var isFn = typeof handler === 'function'; + len = arguments.length; + switch (len) { + // fast cases + case 1: + emitNone(handler, isFn, this); + break; + case 2: + emitOne(handler, isFn, this, arguments[1]); + break; + case 3: + emitTwo(handler, isFn, this, arguments[1], arguments[2]); + break; + case 4: + emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]); + break; + // slower + default: + args = new Array(len - 1); + for (i = 1; i < len; i++) + args[i - 1] = arguments[i]; + emitMany(handler, isFn, this, args); + } + + return true; +}; + +function _addListener(target, type, listener, prepend) { + var m; + var events; + var existing; + + if (typeof listener !== 'function') + throw new TypeError('"listener" argument must be a function'); + + events = target._events; + if (!events) { + events = target._events = new EventHandlers(); + target._eventsCount = 0; + } else { + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (events.newListener) { + target.emit('newListener', type, + listener.listener ? listener.listener : listener); + + // Re-assign `events` because a newListener handler could have caused the + // this._events to be assigned to a new object + events = target._events; + } + existing = events[type]; + } + + if (!existing) { + // Optimize the case of one listener. Don't need the extra array object. + existing = events[type] = listener; + ++target._eventsCount; + } else { + if (typeof existing === 'function') { + // Adding the second element, need to change to array. + existing = events[type] = prepend ? [listener, existing] : + [existing, listener]; + } else { + // If we've already got an array, just append. + if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + } + + // Check for listener leak + if (!existing.warned) { + m = $getMaxListeners(target); + if (m && m > 0 && existing.length > m) { + existing.warned = true; + var w = new Error('Possible EventEmitter memory leak detected. ' + + existing.length + ' ' + type + ' listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit'); + w.name = 'MaxListenersExceededWarning'; + w.emitter = target; + w.type = type; + w.count = existing.length; + emitWarning(w); + } + } + } + + return target; +} +function emitWarning(e) { + typeof console.warn === 'function' ? console.warn(e) : console.log(e); +} +EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); + }; + +function _onceWrap(target, type, listener) { + var fired = false; + function g() { + target.removeListener(type, g); + if (!fired) { + fired = true; + listener.apply(target, arguments); + } + } + g.listener = listener; + return g; +} + +EventEmitter.prototype.once = function once(type, listener) { + if (typeof listener !== 'function') + throw new TypeError('"listener" argument must be a function'); + this.on(type, _onceWrap(this, type, listener)); + return this; +}; + +EventEmitter.prototype.prependOnceListener = + function prependOnceListener(type, listener) { + if (typeof listener !== 'function') + throw new TypeError('"listener" argument must be a function'); + this.prependListener(type, _onceWrap(this, type, listener)); + return this; + }; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = + function removeListener(type, listener) { + var list, events, position, i, originalListener; + + if (typeof listener !== 'function') + throw new TypeError('"listener" argument must be a function'); + + events = this._events; + if (!events) + return this; + + list = events[type]; + if (!list) + return this; + + if (list === listener || (list.listener && list.listener === listener)) { + if (--this._eventsCount === 0) + this._events = new EventHandlers(); + else { + delete events[type]; + if (events.removeListener) + this.emit('removeListener', type, list.listener || listener); + } + } else if (typeof list !== 'function') { + position = -1; + + for (i = list.length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + originalListener = list[i].listener; + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list[0] = undefined; + if (--this._eventsCount === 0) { + this._events = new EventHandlers(); + return this; + } else { + delete events[type]; + } + } else { + spliceOne(list, position); + } + + if (events.removeListener) + this.emit('removeListener', type, originalListener || listener); + } + + return this; + }; + +// Alias for removeListener added in NodeJS 10.0 +// https://nodejs.org/api/events.html#events_emitter_off_eventname_listener +EventEmitter.prototype.off = function(type, listener){ + return this.removeListener(type, listener); +}; + +EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events; + + events = this._events; + if (!events) + return this; + + // not listening for removeListener, no need to emit + if (!events.removeListener) { + if (arguments.length === 0) { + this._events = new EventHandlers(); + this._eventsCount = 0; + } else if (events[type]) { + if (--this._eventsCount === 0) + this._events = new EventHandlers(); + else + delete events[type]; + } + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + var keys = Object.keys(events); + for (var i = 0, key; i < keys.length; ++i) { + key = keys[i]; + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = new EventHandlers(); + this._eventsCount = 0; + return this; + } + + listeners = events[type]; + + if (typeof listeners === 'function') { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + do { + this.removeListener(type, listeners[listeners.length - 1]); + } while (listeners[0]); + } + + return this; + }; + +EventEmitter.prototype.listeners = function listeners(type) { + var evlistener; + var ret; + var events = this._events; + + if (!events) + ret = []; + else { + evlistener = events[type]; + if (!evlistener) + ret = []; + else if (typeof evlistener === 'function') + ret = [evlistener.listener || evlistener]; + else + ret = unwrapListeners(evlistener); + } + + return ret; +}; + +EventEmitter.listenerCount = function(emitter, type) { + if (typeof emitter.listenerCount === 'function') { + return emitter.listenerCount(type); + } else { + return listenerCount.call(emitter, type); + } +}; + +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type) { + var events = this._events; + + if (events) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { + return 1; + } else if (evlistener) { + return evlistener.length; + } + } + + return 0; +} + +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; +}; + +// About 1.5x faster than the two-arg version of Array#splice(). +function spliceOne(list, index) { + for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) + list[i] = list[k]; + list.pop(); +} + +function arrayClone(arr, i) { + var copy = new Array(i); + while (i--) + copy[i] = arr[i]; + return copy; +} + +function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i = 0; i < ret.length; ++i) { + ret[i] = arr[i].listener || arr[i]; + } + return ret; +} + +var _polyfillNode_events = /*#__PURE__*/Object.freeze({ + __proto__: null, + EventEmitter: EventEmitter, + default: EventEmitter +}); + +var require$$1$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_events); + +var streamBrowser = require$$1$1.EventEmitter; + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_buffer); + +var inherits$2; +if (typeof Object.create === 'function'){ + inherits$2 = function inherits(ctor, superCtor) { + // implementation from standard node.js 'util' module + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + inherits$2 = function inherits(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + }; +} + +var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || + function getOwnPropertyDescriptors(obj) { + var keys = Object.keys(obj); + var descriptors = {}; + for (var i = 0; i < keys.length; i++) { + descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]); + } + return descriptors; + }; + +var formatRegExp = /%[sdj%]/g; +function format(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect$1(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject$1(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect$1(x); + } + } + return str; +} + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +function deprecate$1(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global$1.process)) { + return function() { + return deprecate$1(fn, msg).apply(this, arguments); + }; + } + + if (browser$1$1.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (browser$1$1.throwDeprecation) { + throw new Error(msg); + } else if (browser$1$1.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +} + +var debugs = {}; +var debugEnviron; +function debuglog(set) { + if (isUndefined(debugEnviron)) + debugEnviron = browser$1$1.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = 0; + debugs[set] = function() { + var msg = format.apply(null, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; +} + +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect$1(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + _extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect$1.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect$1.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect$1.styles[styleType]; + + if (style) { + return '\u001b[' + inspect$1.colors[style][0] + 'm' + str + + '\u001b[' + inspect$1.colors[style][1] + 'm'; + } else { + return str; + } +} + + +function stylizeNoColor(str, styleType) { + return str; +} + + +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== inspect$1 && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var length = output.reduce(function(prev, cur) { + if (cur.indexOf('\n') >= 0) ; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} + +function isNull(arg) { + return arg === null; +} + +function isNullOrUndefined(arg) { + return arg == null; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isString(arg) { + return typeof arg === 'string'; +} + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} + +function isUndefined(arg) { + return arg === void 0; +} + +function isRegExp(re) { + return isObject$1(re) && objectToString(re) === '[object RegExp]'; +} + +function isObject$1(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isDate(d) { + return isObject$1(d) && objectToString(d) === '[object Date]'; +} + +function isError(e) { + return isObject$1(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} + +function isBuffer(maybeBuf) { + return Buffer$2.isBuffer(maybeBuf); +} + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad$1(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad$1(d.getHours()), + pad$1(d.getMinutes()), + pad$1(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +function log() { + console.log('%s - %s', timestamp(), format.apply(null, arguments)); +} + +function _extend(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject$1(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +} +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined; + +function promisify(original) { + if (typeof original !== 'function') + throw new TypeError('The "original" argument must be of type Function'); + + if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) { + var fn = original[kCustomPromisifiedSymbol]; + if (typeof fn !== 'function') { + throw new TypeError('The "util.promisify.custom" argument must be of type Function'); + } + Object.defineProperty(fn, kCustomPromisifiedSymbol, { + value: fn, enumerable: false, writable: false, configurable: true + }); + return fn; + } + + function fn() { + var promiseResolve, promiseReject; + var promise = new Promise(function (resolve, reject) { + promiseResolve = resolve; + promiseReject = reject; + }); + + var args = []; + for (var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + args.push(function (err, value) { + if (err) { + promiseReject(err); + } else { + promiseResolve(value); + } + }); + + try { + original.apply(this, args); + } catch (err) { + promiseReject(err); + } + + return promise; + } + + Object.setPrototypeOf(fn, Object.getPrototypeOf(original)); + + if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, { + value: fn, enumerable: false, writable: false, configurable: true + }); + return Object.defineProperties( + fn, + getOwnPropertyDescriptors(original) + ); +} + +promisify.custom = kCustomPromisifiedSymbol; + +function callbackifyOnRejected(reason, cb) { + // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M). + // Because `null` is a special error value in callbacks which means "no error + // occurred", we error-wrap so the callback consumer can distinguish between + // "the promise rejected with null" or "the promise fulfilled with undefined". + if (!reason) { + var newReason = new Error('Promise was rejected with a falsy value'); + newReason.reason = reason; + reason = newReason; + } + return cb(reason); +} + +function callbackify(original) { + if (typeof original !== 'function') { + throw new TypeError('The "original" argument must be of type Function'); + } + + // We DO NOT return the promise as it gives the user a false sense that + // the promise is actually somehow related to the callback's execution + // and that the callback throwing will reject the promise. + function callbackified() { + var args = []; + for (var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + + var maybeCb = args.pop(); + if (typeof maybeCb !== 'function') { + throw new TypeError('The last argument must be of type Function'); + } + var self = this; + var cb = function() { + return maybeCb.apply(self, arguments); + }; + // In true node style we process the callback on `nextTick` with all the + // implications (stack, `uncaughtException`, `async_hooks`) + original.apply(this, args) + .then(function(ret) { browser$1$1.nextTick(cb.bind(null, null, ret)); }, + function(rej) { browser$1$1.nextTick(callbackifyOnRejected.bind(null, rej, cb)); }); + } + + Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original)); + Object.defineProperties(callbackified, getOwnPropertyDescriptors(original)); + return callbackified; +} + +var _polyfillNode_util = { + inherits: inherits$2, + _extend: _extend, + log: log, + isBuffer: isBuffer, + isPrimitive: isPrimitive, + isFunction: isFunction, + isError: isError, + isDate: isDate, + isObject: isObject$1, + isRegExp: isRegExp, + isUndefined: isUndefined, + isSymbol: isSymbol, + isString: isString, + isNumber: isNumber, + isNullOrUndefined: isNullOrUndefined, + isNull: isNull, + isBoolean: isBoolean, + isArray: isArray, + inspect: inspect$1, + deprecate: deprecate$1, + format: format, + debuglog: debuglog, + promisify: promisify, + callbackify: callbackify, +}; + +var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + _extend: _extend, + callbackify: callbackify, + debuglog: debuglog, + default: _polyfillNode_util, + deprecate: deprecate$1, + format: format, + inherits: inherits$2, + inspect: inspect$1, + isArray: isArray, + isBoolean: isBoolean, + isBuffer: isBuffer, + isDate: isDate, + isError: isError, + isFunction: isFunction, + isNull: isNull, + isNullOrUndefined: isNullOrUndefined, + isNumber: isNumber, + isObject: isObject$1, + isPrimitive: isPrimitive, + isRegExp: isRegExp, + isString: isString, + isSymbol: isSymbol, + isUndefined: isUndefined, + log: log, + promisify: promisify +}); + +var require$$3 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1); + +var buffer_list; +var hasRequiredBuffer_list; +function requireBuffer_list() { + if (hasRequiredBuffer_list) return buffer_list; + hasRequiredBuffer_list = 1; + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + return keys; + } + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + return target; + } + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + return Constructor; + } + var _require = require$$0, + Buffer = _require.Buffer; + var _require2 = require$$3, + inspect = _require2.inspect; + var custom = inspect && inspect.custom || 'inspect'; + function copyBuffer(src, target, offset) { + Buffer.prototype.copy.call(src, target, offset); + } + buffer_list = /*#__PURE__*/ + function () { + function BufferList() { + _classCallCheck(this, BufferList); + this.head = null; + this.tail = null; + this.length = 0; + } + _createClass(BufferList, [{ + key: "push", + value: function push(v) { + var entry = { + data: v, + next: null + }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + } + }, { + key: "unshift", + value: function unshift(v) { + var entry = { + data: v, + next: this.head + }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + } + }, { + key: "shift", + value: function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + } + }, { + key: "clear", + value: function clear() { + this.head = this.tail = null; + this.length = 0; + } + }, { + key: "join", + value: function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + } + return ret; + } + }, { + key: "concat", + value: function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + return ret; + } // Consumes a specified amount of bytes or characters from the buffered data. + }, { + key: "consume", + value: function consume(n, hasStrings) { + var ret; + if (n < this.head.data.length) { + // `slice` is the same for buffers and strings. + ret = this.head.data.slice(0, n); + this.head.data = this.head.data.slice(n); + } else if (n === this.head.data.length) { + // First chunk is a perfect match. + ret = this.shift(); + } else { + // Result spans more than one buffer. + ret = hasStrings ? this._getString(n) : this._getBuffer(n); + } + return ret; + } + }, { + key: "first", + value: function first() { + return this.head.data; + } // Consumes a specified amount of characters from the buffered data. + }, { + key: "_getString", + value: function _getString(n) { + var p = this.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + this.length -= c; + return ret; + } // Consumes a specified amount of bytes from the buffered data. + }, { + key: "_getBuffer", + value: function _getBuffer(n) { + var ret = Buffer.allocUnsafe(n); + var p = this.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + this.length -= c; + return ret; + } // Make sure the linked list only shows the minimal necessary information. + }, { + key: custom, + value: function value(_, options) { + return inspect(this, _objectSpread({}, options, { + // Only inspect one level. + depth: 0, + // It should not recurse. + customInspect: false + })); + } + }]); + return BufferList; + }(); + return buffer_list; +} + +function destroy(err, cb) { + var _this = this; + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err) { + if (!this._writableState) { + browser$1$1.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + browser$1$1.nextTick(emitErrorNT, this, err); + } + } + return this; + } // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + if (this._readableState) { + this._readableState.destroyed = true; + } // if this is a duplex stream mark the writable part as destroyed as well + + if (this._writableState) { + this._writableState.destroyed = true; + } + this._destroy(err || null, function (err) { + if (!cb && err) { + if (!_this._writableState) { + browser$1$1.nextTick(emitErrorAndCloseNT, _this, err); + } else if (!_this._writableState.errorEmitted) { + _this._writableState.errorEmitted = true; + browser$1$1.nextTick(emitErrorAndCloseNT, _this, err); + } else { + browser$1$1.nextTick(emitCloseNT, _this); + } + } else if (cb) { + browser$1$1.nextTick(emitCloseNT, _this); + cb(err); + } else { + browser$1$1.nextTick(emitCloseNT, _this); + } + }); + return this; +} +function emitErrorAndCloseNT(self, err) { + emitErrorNT(self, err); + emitCloseNT(self); +} +function emitCloseNT(self) { + if (self._writableState && !self._writableState.emitClose) return; + if (self._readableState && !self._readableState.emitClose) return; + self.emit('close'); +} +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } +} +function emitErrorNT(self, err) { + self.emit('error', err); +} +function errorOrDestroy$2(stream, err) { + // We have tests that rely on errors being emitted + // in the same tick, so changing this is semver major. + // For now when you opt-in to autoDestroy we allow + // the error to be emitted nextTick. In a future + // semver major update we should change the default to this. + var rState = stream._readableState; + var wState = stream._writableState; + if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err); +} +var destroy_1 = { + destroy: destroy, + undestroy: undestroy, + errorOrDestroy: errorOrDestroy$2 +}; + +var errorsBrowser = {}; + +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} +var codes = {}; +function createErrorType(code, message, Base) { + if (!Base) { + Base = Error; + } + function getMessage(arg1, arg2, arg3) { + if (typeof message === 'string') { + return message; + } else { + return message(arg1, arg2, arg3); + } + } + var NodeError = /*#__PURE__*/ + function (_Base) { + _inheritsLoose(NodeError, _Base); + function NodeError(arg1, arg2, arg3) { + return _Base.call(this, getMessage(arg1, arg2, arg3)) || this; + } + return NodeError; + }(Base); + NodeError.prototype.name = Base.name; + NodeError.prototype.code = code; + codes[code] = NodeError; +} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js + +function oneOf(expected, thing) { + if (Array.isArray(expected)) { + var len = expected.length; + expected = expected.map(function (i) { + return String(i); + }); + if (len > 2) { + return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1]; + } else if (len === 2) { + return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); + } else { + return "of ".concat(thing, " ").concat(expected[0]); + } + } else { + return "of ".concat(thing, " ").concat(String(expected)); + } +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith + +function startsWith(str, search, pos) { + return str.substr(0 , search.length) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith + +function endsWith(str, search, this_len) { + if (this_len === undefined || this_len > str.length) { + this_len = str.length; + } + return str.substring(this_len - search.length, this_len) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes + +function includes(str, search, start) { + if (typeof start !== 'number') { + start = 0; + } + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } +} +createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { + return 'The value "' + value + '" is invalid for option "' + name + '"'; +}, TypeError); +createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { + // determiner: 'must be' or 'must not be' + var determiner; + if (typeof expected === 'string' && startsWith(expected, 'not ')) { + determiner = 'must not be'; + expected = expected.replace(/^not /, ''); + } else { + determiner = 'must be'; + } + var msg; + if (endsWith(name, ' argument')) { + // For cases like 'first argument' + msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } else { + var type = includes(name, '.') ? 'property' : 'argument'; + msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } + msg += ". Received type ".concat(typeof actual); + return msg; +}, TypeError); +createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); +createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { + return 'The ' + name + ' method is not implemented'; +}); +createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); +createErrorType('ERR_STREAM_DESTROYED', function (name) { + return 'Cannot call ' + name + ' after a stream was destroyed'; +}); +createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); +createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); +createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); +createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); +createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { + return 'Unknown encoding: ' + arg; +}, TypeError); +createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); +errorsBrowser.codes = codes; + +var ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE; +function highWaterMarkFrom(options, isDuplex, duplexKey) { + return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; +} +function getHighWaterMark$2(state, options, duplexKey, isDuplex) { + var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); + if (hwm != null) { + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { + var name = isDuplex ? duplexKey : 'highWaterMark'; + throw new ERR_INVALID_OPT_VALUE(name, hwm); + } + return Math.floor(hwm); + } // Default value + + return state.objectMode ? 16 : 16 * 1024; +} +var state = { + getHighWaterMark: getHighWaterMark$2 +}; + +var inherits; +if (typeof Object.create === 'function'){ + inherits = function inherits(ctor, superCtor) { + // implementation from standard node.js 'util' module + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + inherits = function inherits(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + }; +} +var inherits$1 = inherits; + +var _polyfillNode_inherits = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: inherits$1 +}); + +var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_inherits); + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var isBufferEncoding = Buffer$2.isEncoding + || function(encoding) { + switch (encoding && encoding.toLowerCase()) { + case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; + default: return false; + } + }; + + +function assertEncoding(encoding) { + if (encoding && !isBufferEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. CESU-8 is handled as part of the UTF-8 encoding. +// +// @TODO Handling all encodings inside a single object makes it very difficult +// to reason about this code, so it should be split up in the future. +// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code +// points as used by CESU-8. +function StringDecoder$1(encoding) { + this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); + assertEncoding(encoding); + switch (this.encoding) { + case 'utf8': + // CESU-8 represents each of Surrogate Pair by 3-bytes + this.surrogateSize = 3; + break; + case 'ucs2': + case 'utf16le': + // UTF-16 represents each of Surrogate Pair by 2-bytes + this.surrogateSize = 2; + this.detectIncompleteChar = utf16DetectIncompleteChar; + break; + case 'base64': + // Base-64 stores 3 bytes in 4 chars, and pads the remainder. + this.surrogateSize = 3; + this.detectIncompleteChar = base64DetectIncompleteChar; + break; + default: + this.write = passThroughWrite; + return; + } + + // Enough space to store all bytes of a single character. UTF-8 needs 4 + // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). + this.charBuffer = new Buffer$2(6); + // Number of bytes received for the current incomplete multi-byte character. + this.charReceived = 0; + // Number of bytes expected for the current incomplete multi-byte character. + this.charLength = 0; +} + +// write decodes the given buffer and returns it as JS string that is +// guaranteed to not contain any partial multi-byte characters. Any partial +// character found at the end of the buffer is buffered up, and will be +// returned when calling write again with the remaining bytes. +// +// Note: Converting a Buffer containing an orphan surrogate to a String +// currently works, but converting a String to a Buffer (via `new Buffer`, or +// Buffer#write) will replace incomplete surrogates with the unicode +// replacement character. See https://codereview.chromium.org/121173009/ . +StringDecoder$1.prototype.write = function(buffer) { + var charStr = ''; + // if our last write ended with an incomplete multibyte character + while (this.charLength) { + // determine how many remaining bytes this buffer has to offer for this char + var available = (buffer.length >= this.charLength - this.charReceived) ? + this.charLength - this.charReceived : + buffer.length; + + // add the new bytes to the char buffer + buffer.copy(this.charBuffer, this.charReceived, 0, available); + this.charReceived += available; + + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } + + // remove bytes belonging to the current character from the buffer + buffer = buffer.slice(available, buffer.length); + + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); + + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + var charCode = charStr.charCodeAt(charStr.length - 1); + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + this.charLength += this.surrogateSize; + charStr = ''; + continue; + } + this.charReceived = this.charLength = 0; + + // if there are no more bytes in this buffer, just emit our char + if (buffer.length === 0) { + return charStr; + } + break; + } + + // determine and set charLength / charReceived + this.detectIncompleteChar(buffer); + + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); + end -= this.charReceived; + } + + charStr += buffer.toString(this.encoding, 0, end); + + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + var size = this.surrogateSize; + this.charLength += size; + this.charReceived += size; + this.charBuffer.copy(this.charBuffer, size, 0, size); + buffer.copy(this.charBuffer, 0, 0, size); + return charStr.substring(0, end); + } + + // or just emit the charStr + return charStr; +}; + +// detectIncompleteChar determines if there is an incomplete UTF-8 character at +// the end of the given buffer. If so, it sets this.charLength to the byte +// length that character, and sets this.charReceived to the number of bytes +// that are available for this character. +StringDecoder$1.prototype.detectIncompleteChar = function(buffer) { + // determine how many bytes we have to check at the end of this buffer + var i = (buffer.length >= 3) ? 3 : buffer.length; + + // Figure out if one of the last i bytes of our buffer announces an + // incomplete char. + for (; i > 0; i--) { + var c = buffer[buffer.length - i]; + + // See http://en.wikipedia.org/wiki/UTF-8#Description + + // 110XXXXX + if (i == 1 && c >> 5 == 0x06) { + this.charLength = 2; + break; + } + + // 1110XXXX + if (i <= 2 && c >> 4 == 0x0E) { + this.charLength = 3; + break; + } + + // 11110XXX + if (i <= 3 && c >> 3 == 0x1E) { + this.charLength = 4; + break; + } + } + this.charReceived = i; +}; + +StringDecoder$1.prototype.end = function(buffer) { + var res = ''; + if (buffer && buffer.length) + res = this.write(buffer); + + if (this.charReceived) { + var cr = this.charReceived; + var buf = this.charBuffer; + var enc = this.encoding; + res += buf.slice(0, cr).toString(enc); + } + + return res; +}; + +function passThroughWrite(buffer) { + return buffer.toString(this.encoding); +} + +function utf16DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 2; + this.charLength = this.charReceived ? 2 : 0; +} + +function base64DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 3; + this.charLength = this.charReceived ? 3 : 0; +} + +var _polyfillNode_string_decoder = /*#__PURE__*/Object.freeze({ + __proto__: null, + StringDecoder: StringDecoder$1 +}); + +var require$$10 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_string_decoder); + +var ERR_STREAM_PREMATURE_CLOSE = errorsBrowser.codes.ERR_STREAM_PREMATURE_CLOSE; +function once$1(callback) { + var called = false; + return function () { + if (called) return; + called = true; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + callback.apply(this, args); + }; +} +function noop$1() {} +function isRequest$1(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} +function eos$1(stream, opts, callback) { + if (typeof opts === 'function') return eos$1(stream, null, opts); + if (!opts) opts = {}; + callback = once$1(callback || noop$1); + var readable = opts.readable || opts.readable !== false && stream.readable; + var writable = opts.writable || opts.writable !== false && stream.writable; + var onlegacyfinish = function onlegacyfinish() { + if (!stream.writable) onfinish(); + }; + var writableEnded = stream._writableState && stream._writableState.finished; + var onfinish = function onfinish() { + writable = false; + writableEnded = true; + if (!readable) callback.call(stream); + }; + var readableEnded = stream._readableState && stream._readableState.endEmitted; + var onend = function onend() { + readable = false; + readableEnded = true; + if (!writable) callback.call(stream); + }; + var onerror = function onerror(err) { + callback.call(stream, err); + }; + var onclose = function onclose() { + var err; + if (readable && !readableEnded) { + if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + if (writable && !writableEnded) { + if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + }; + var onrequest = function onrequest() { + stream.req.on('finish', onfinish); + }; + if (isRequest$1(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest();else stream.on('request', onrequest); + } else if (writable && !stream._writableState) { + // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); + return function () { + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; +} +var endOfStream = eos$1; + +var async_iterator; +var hasRequiredAsync_iterator; +function requireAsync_iterator() { + if (hasRequiredAsync_iterator) return async_iterator; + hasRequiredAsync_iterator = 1; + var _Object$setPrototypeO; + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + var finished = endOfStream; + var kLastResolve = Symbol('lastResolve'); + var kLastReject = Symbol('lastReject'); + var kError = Symbol('error'); + var kEnded = Symbol('ended'); + var kLastPromise = Symbol('lastPromise'); + var kHandlePromise = Symbol('handlePromise'); + var kStream = Symbol('stream'); + function createIterResult(value, done) { + return { + value: value, + done: done + }; + } + function readAndResolve(iter) { + var resolve = iter[kLastResolve]; + if (resolve !== null) { + var data = iter[kStream].read(); // we defer if data is null + // we can be expecting either 'end' or + // 'error' + + if (data !== null) { + iter[kLastPromise] = null; + iter[kLastResolve] = null; + iter[kLastReject] = null; + resolve(createIterResult(data, false)); + } + } + } + function onReadable(iter) { + // we wait for the next tick, because it might + // emit an error with process.nextTick + browser$1$1.nextTick(readAndResolve, iter); + } + function wrapForNext(lastPromise, iter) { + return function (resolve, reject) { + lastPromise.then(function () { + if (iter[kEnded]) { + resolve(createIterResult(undefined, true)); + return; + } + iter[kHandlePromise](resolve, reject); + }, reject); + }; + } + var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); + var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { + get stream() { + return this[kStream]; + }, + next: function next() { + var _this = this; + + // if we have detected an error in the meanwhile + // reject straight away + var error = this[kError]; + if (error !== null) { + return Promise.reject(error); + } + if (this[kEnded]) { + return Promise.resolve(createIterResult(undefined, true)); + } + if (this[kStream].destroyed) { + // We need to defer via nextTick because if .destroy(err) is + // called, the error will be emitted via nextTick, and + // we cannot guarantee that there is no error lingering around + // waiting to be emitted. + return new Promise(function (resolve, reject) { + browser$1$1.nextTick(function () { + if (_this[kError]) { + reject(_this[kError]); + } else { + resolve(createIterResult(undefined, true)); + } + }); + }); + } // if we have multiple next() calls + // we will wait for the previous Promise to finish + // this logic is optimized to support for await loops, + // where next() is only called once at a time + + var lastPromise = this[kLastPromise]; + var promise; + if (lastPromise) { + promise = new Promise(wrapForNext(lastPromise, this)); + } else { + // fast path needed to support multiple this.push() + // without triggering the next() queue + var data = this[kStream].read(); + if (data !== null) { + return Promise.resolve(createIterResult(data, false)); + } + promise = new Promise(this[kHandlePromise]); + } + this[kLastPromise] = promise; + return promise; + } + }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () { + return this; + }), _defineProperty(_Object$setPrototypeO, "return", function _return() { + var _this2 = this; + + // destroy(err, cb) is a private API + // we can guarantee we have that here, because we control the + // Readable class this is attached to + return new Promise(function (resolve, reject) { + _this2[kStream].destroy(null, function (err) { + if (err) { + reject(err); + return; + } + resolve(createIterResult(undefined, true)); + }); + }); + }), _Object$setPrototypeO), AsyncIteratorPrototype); + var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) { + var _Object$create; + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { + value: stream, + writable: true + }), _defineProperty(_Object$create, kLastResolve, { + value: null, + writable: true + }), _defineProperty(_Object$create, kLastReject, { + value: null, + writable: true + }), _defineProperty(_Object$create, kError, { + value: null, + writable: true + }), _defineProperty(_Object$create, kEnded, { + value: stream._readableState.endEmitted, + writable: true + }), _defineProperty(_Object$create, kHandlePromise, { + value: function value(resolve, reject) { + var data = iterator[kStream].read(); + if (data) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(data, false)); + } else { + iterator[kLastResolve] = resolve; + iterator[kLastReject] = reject; + } + }, + writable: true + }), _Object$create)); + iterator[kLastPromise] = null; + finished(stream, function (err) { + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { + var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise + // returned by next() and store the error + + if (reject !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + reject(err); + } + iterator[kError] = err; + return; + } + var resolve = iterator[kLastResolve]; + if (resolve !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(undefined, true)); + } + iterator[kEnded] = true; + }); + stream.on('readable', onReadable.bind(null, iterator)); + return iterator; + }; + async_iterator = createReadableStreamAsyncIterator; + return async_iterator; +} + +var fromBrowser; +var hasRequiredFromBrowser; +function requireFromBrowser() { + if (hasRequiredFromBrowser) return fromBrowser; + hasRequiredFromBrowser = 1; + fromBrowser = function () { + throw new Error('Readable.from is not available in the browser'); + }; + return fromBrowser; +} + +const Registry$4 = _registry; +Registry$4.Readable = Readable; +Readable.ReadableState = ReadableState; +/**/ + +require$$1$1.EventEmitter; +var EElistenerCount = function EElistenerCount(emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ + +var Stream$1 = streamBrowser; +/**/ + +var Buffer$1 = require$$0.Buffer; +var OurUint8Array$1 = commonjsGlobal.Uint8Array || function () {}; +function _uint8ArrayToBuffer$1(chunk) { + return Buffer$1.from(chunk); +} +function _isUint8Array$1(obj) { + return Buffer$1.isBuffer(obj) || obj instanceof OurUint8Array$1; +} +/**/ + +var debugUtil = require$$3; +var debug; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function debug() {}; +} +/**/ + +var BufferList = requireBuffer_list(); +var destroyImpl$1 = destroy_1; +var _require$1 = state, + getHighWaterMark$1 = _require$1.getHighWaterMark; +var _require$codes$3 = errorsBrowser.codes, + ERR_INVALID_ARG_TYPE$1 = _require$codes$3.ERR_INVALID_ARG_TYPE, + ERR_STREAM_PUSH_AFTER_EOF = _require$codes$3.ERR_STREAM_PUSH_AFTER_EOF, + ERR_METHOD_NOT_IMPLEMENTED$2 = _require$codes$3.ERR_METHOD_NOT_IMPLEMENTED, + ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes$3.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance. + +var StringDecoder; +var createReadableStreamAsyncIterator; +var from; +require$$1(Readable, Stream$1); +var errorOrDestroy$1 = destroyImpl$1.errorOrDestroy; +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} +function ReadableState(options, stream, isDuplex) { + options = options || {}; // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Registry$4.Duplex; // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + + this.highWaterMark = getHighWaterMark$1(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + + this.sync = true; // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + this.paused = true; // Should close be emitted on destroy. Defaults to true. + + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish') + + this.autoDestroy = !!options.autoDestroy; // has it been destroyed + + this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + + this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s + + this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled + + this.readingMore = false; + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = require$$10.StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} +function Readable(options) { + if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside + // the ReadableState constructor, at least with V8 6.5 + + var isDuplex = this instanceof Registry$4.Duplex; + this._readableState = new ReadableState(options, this, isDuplex); // legacy + + this.readable = true; + if (options) { + if (typeof options.read === 'function') this._read = options.read; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + Stream$1.call(this); +} +Object.defineProperty(Readable.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + this._readableState.destroyed = value; + } +}); +Readable.prototype.destroy = destroyImpl$1.destroy; +Readable.prototype._undestroy = destroyImpl$1.undestroy; +Readable.prototype._destroy = function (err, cb) { + cb(err); +}; // Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. + +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer$1.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; // Unshift should *always* be something directly out of read() + +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + debug('readableAddChunk', chunk); + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + errorOrDestroy$1(stream, er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer$1.prototype) { + chunk = _uint8ArrayToBuffer$1(chunk); + } + if (addToFront) { + if (state.endEmitted) errorOrDestroy$1(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true); + } else if (state.ended) { + errorOrDestroy$1(stream, new ERR_STREAM_PUSH_AFTER_EOF()); + } else if (state.destroyed) { + return false; + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + maybeReadMore(stream, state); + } + } // We can push more data if we are below the highWaterMark. + // Also, if we have no data yet, we can stand some more bytes. + // This is to work around cases where hwm=0, such as the repl. + + return !state.ended && (state.length < state.highWaterMark || state.length === 0); +} +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + state.awaitDrain = 0; + stream.emit('data', chunk); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); +} +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array$1(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE$1('chunk', ['string', 'Buffer', 'Uint8Array'], chunk); + } + return er; +} +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; // backwards compatibility. + +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require$$10.StringDecoder; + var decoder = new StringDecoder(enc); + this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8 + + this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers: + + var p = this._readableState.buffer.head; + var content = ''; + while (p !== null) { + content += decoder.write(p.data); + p = p.next; + } + this._readableState.buffer.clear(); + if (content !== '') this._readableState.buffer.push(content); + this._readableState.length = content.length; + return this; +}; // Don't raise the hwm > 1GB + +var MAX_HWM = 0x40000000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} // This function is designed to be inlinable, so please take care when making +// changes to the function body. + +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } // If we're asking for more than the current hwm, then raise the hwm. + + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; // Don't have enough + + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} // you can override either this method, or the async _read(n) below. + +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + + if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up. + + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + // if we need a readable event, then we need to do some reading. + + var doRead = state.needReadable; + debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some + + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; // if the length is currently zero, then we *need* a readable event. + + if (state.length === 0) state.needReadable = true; // call internal read method + + this._read(state.highWaterMark); + state.sync = false; // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + + if (!state.reading) n = howMuchToRead(nOrig, state); + } + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + if (ret === null) { + state.needReadable = state.length <= state.highWaterMark; + n = 0; + } else { + state.length -= n; + state.awaitDrain = 0; + } + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick. + + if (nOrig !== n && state.ended) endReadable(this); + } + if (ret !== null) this.emit('data', ret); + return ret; +}; +function onEofChunk(stream, state) { + debug('onEofChunk'); + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + if (state.sync) { + // if we are sync, wait until next tick to emit the data. + // Otherwise we risk emitting data in the flow() + // the readable code triggers during a read() call + emitReadable(stream); + } else { + // emit 'readable' now to make sure it gets picked up. + state.needReadable = false; + if (!state.emittedReadable) { + state.emittedReadable = true; + emitReadable_(stream); + } + } +} // Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. + +function emitReadable(stream) { + var state = stream._readableState; + debug('emitReadable', state.needReadable, state.emittedReadable); + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + browser$1$1.nextTick(emitReadable_, stream); + } +} +function emitReadable_(stream) { + var state = stream._readableState; + debug('emitReadable_', state.destroyed, state.length, state.ended); + if (!state.destroyed && (state.length || state.ended)) { + stream.emit('readable'); + state.emittedReadable = false; + } // The stream needs another readable event if + // 1. It is not flowing, as the flow mechanism will take + // care of it. + // 2. It is not ended. + // 3. It is below the highWaterMark, so we can schedule + // another readable later. + + state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; + flow(stream); +} // at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. + +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + browser$1$1.nextTick(maybeReadMore_, stream, state); + } +} +function maybeReadMore_(stream, state) { + // Attempt to read more data if we should. + // + // The conditions for reading more data are (one of): + // - Not enough data buffered (state.length < state.highWaterMark). The loop + // is responsible for filling the buffer with enough data if such data + // is available. If highWaterMark is 0 and we are not in the flowing mode + // we should _not_ attempt to buffer any extra data. We'll get more data + // when the stream consumer calls read() instead. + // - No data in the buffer, and the stream is in flowing mode. In this mode + // the loop below is responsible for ensuring read() is called. Failing to + // call read here would abort the flow and there's no other mechanism for + // continuing the flow if the stream consumer has just subscribed to the + // 'data' event. + // + // In addition to the above conditions to keep reading data, the following + // conditions prevent the data from being read: + // - The stream has ended (state.ended). + // - There is already a pending 'read' operation (state.reading). This is a + // case where the the stream has called the implementation defined _read() + // method, but they are processing the call asynchronously and have _not_ + // called push() with new data. In this case we skip performing more + // read()s. The execution ends in this method again after the _read() ends + // up calling push() with more data. + while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { + var len = state.length; + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break; + } + state.readingMore = false; +} // abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. + +Readable.prototype._read = function (n) { + errorOrDestroy$1(this, new ERR_METHOD_NOT_IMPLEMENTED$2('_read()')); +}; +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== browser$1$1.stdout && dest !== browser$1$1.stderr; + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) browser$1$1.nextTick(endFn);else src.once('end', endFn); + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + function onend() { + debug('onend'); + dest.end(); + } // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + var cleanedUp = false; + function cleanup() { + debug('cleanup'); // cleanup event handlers once the pipe is broken + + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + cleanedUp = true; // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + debug('dest.write', ret); + if (ret === false) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', state.awaitDrain); + state.awaitDrain++; + } + src.pause(); + } + } // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) errorOrDestroy$1(dest, er); + } // Make sure our error handler is attached before userland ones. + + prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once. + + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } // tell the dest that it's being piped to + + dest.emit('pipe', src); // start the flow if it hasn't been started already. + + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + return dest; +}; +function pipeOnDrain(src) { + return function pipeOnDrainFunctionResult() { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { + hasUnpiped: false + }; // if we're not piping anywhere, then do nothing. + + if (state.pipesCount === 0) return this; // just one destination. most common case. + + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + if (!dest) dest = state.pipes; // got a match. + + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, { + hasUnpiped: false + }); + } + return this; + } // try to find the right one. + + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + dest.emit('unpipe', this, unpipeInfo); + return this; +}; // set up data events if they are asked for +// Ensure readable listeners eventually get something + +Readable.prototype.on = function (ev, fn) { + var res = Stream$1.prototype.on.call(this, ev, fn); + var state = this._readableState; + if (ev === 'data') { + // update readableListening so that resume() may be a no-op + // a few lines down. This is needed to support once('readable'). + state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused + + if (state.flowing !== false) this.resume(); + } else if (ev === 'readable') { + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.flowing = false; + state.emittedReadable = false; + debug('on readable', state.length, state.reading); + if (state.length) { + emitReadable(this); + } else if (!state.reading) { + browser$1$1.nextTick(nReadingNextTick, this); + } + } + } + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; +Readable.prototype.removeListener = function (ev, fn) { + var res = Stream$1.prototype.removeListener.call(this, ev, fn); + if (ev === 'readable') { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + browser$1$1.nextTick(updateReadableListening, this); + } + return res; +}; +Readable.prototype.removeAllListeners = function (ev) { + var res = Stream$1.prototype.removeAllListeners.apply(this, arguments); + if (ev === 'readable' || ev === undefined) { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + browser$1$1.nextTick(updateReadableListening, this); + } + return res; +}; +function updateReadableListening(self) { + var state = self._readableState; + state.readableListening = self.listenerCount('readable') > 0; + if (state.resumeScheduled && !state.paused) { + // flowing needs to be set to true now, otherwise + // the upcoming resume will not flow. + state.flowing = true; // crude way to check if we should resume + } else if (self.listenerCount('data') > 0) { + self.resume(); + } +} +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} // pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. + +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); // we flow only if there is no one listening + // for readable, but we still have to call + // resume() + + state.flowing = !state.readableListening; + resume(this, state); + } + state.paused = false; + return this; +}; +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + browser$1$1.nextTick(resume_, stream, state); + } +} +function resume_(stream, state) { + debug('resume', state.reading); + if (!state.reading) { + stream.read(0); + } + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (this._readableState.flowing !== false) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + this._readableState.paused = true; + return this; +}; +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) { + } +} // wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. + +Readable.prototype.wrap = function (stream) { + var _this = this; + var state = this._readableState; + var paused = false; + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + _this.push(null); + }); + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode + + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); // proxy all the other methods. + // important when wrapping filters and duplexes. + + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function methodWrap(method) { + return function methodWrapReturnFunction() { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } // proxy certain important events. + + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } // when we try to consume some more bytes, simply unpause the + // underlying stream. + + this._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + return this; +}; +if (typeof Symbol === 'function') { + Readable.prototype[Symbol.asyncIterator] = function () { + if (createReadableStreamAsyncIterator === undefined) { + createReadableStreamAsyncIterator = requireAsync_iterator(); + } + return createReadableStreamAsyncIterator(this); + }; +} +Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.highWaterMark; + } +}); +Object.defineProperty(Readable.prototype, 'readableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState && this._readableState.buffer; + } +}); +Object.defineProperty(Readable.prototype, 'readableFlowing', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.flowing; + }, + set: function set(state) { + if (this._readableState) { + this._readableState.flowing = state; + } + } +}); // exposed for testing purposes only. + +Readable._fromList = fromList; +Object.defineProperty(Readable.prototype, 'readableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.length; + } +}); // Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. + +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = state.buffer.consume(n, state.decoder); + } + return ret; +} +function endReadable(stream) { + var state = stream._readableState; + debug('endReadable', state.endEmitted); + if (!state.endEmitted) { + state.ended = true; + browser$1$1.nextTick(endReadableNT, state, stream); + } +} +function endReadableNT(state, stream) { + debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift. + + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the writable side is ready for autoDestroy as well + var wState = stream._writableState; + if (!wState || wState.autoDestroy && wState.finished) { + stream.destroy(); + } + } + } +} +if (typeof Symbol === 'function') { + Readable.from = function (iterable, opts) { + if (from === undefined) { + from = requireFromBrowser(); + } + return from(Readable, iterable, opts); + }; +} +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} + +/** + * Module exports. + */ + +var browser = deprecate; + +/** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ + +function deprecate(fn, msg) { + if (config('noDeprecation')) { + return fn; + } + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + return deprecated; +} + +/** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ + +function config(name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!commonjsGlobal.localStorage) return false; + } catch (_) { + return false; + } + var val = commonjsGlobal.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; +} + +const Registry$3 = _registry; +Registry$3.Writable = Writable; +// there will be only 2 of these for each stream + +function CorkedRequest(state) { + var _this = this; + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + +/**/ + +/**/ + +Writable.WritableState = WritableState; +/**/ + +var internalUtil = { + deprecate: browser +}; +/**/ + +/**/ + +var Stream = streamBrowser; +/**/ + +var Buffer = require$$0.Buffer; +var OurUint8Array = commonjsGlobal.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} +var destroyImpl = destroy_1; +var _require = state, + getHighWaterMark = _require.getHighWaterMark; +var _require$codes$2 = errorsBrowser.codes, + ERR_INVALID_ARG_TYPE = _require$codes$2.ERR_INVALID_ARG_TYPE, + ERR_METHOD_NOT_IMPLEMENTED$1 = _require$codes$2.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK$1 = _require$codes$2.ERR_MULTIPLE_CALLBACK, + ERR_STREAM_CANNOT_PIPE = _require$codes$2.ERR_STREAM_CANNOT_PIPE, + ERR_STREAM_DESTROYED$1 = _require$codes$2.ERR_STREAM_DESTROYED, + ERR_STREAM_NULL_VALUES = _require$codes$2.ERR_STREAM_NULL_VALUES, + ERR_STREAM_WRITE_AFTER_END = _require$codes$2.ERR_STREAM_WRITE_AFTER_END, + ERR_UNKNOWN_ENCODING = _require$codes$2.ERR_UNKNOWN_ENCODING; +var errorOrDestroy = destroyImpl.errorOrDestroy; +require$$1(Writable, Stream); +function nop() {} +function WritableState(options, stream, isDuplex) { + options = options || {}; // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream, + // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. + + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Registry$3.Duplex; // object stream flag to indicate whether or not this stream + // contains buffers or objects. + + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + + this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called + + this.finalCalled = false; // drain event flag. + + this.needDrain = false; // at the start of calling end() + + this.ending = false; // when end() has been called, and returned + + this.ended = false; // when 'finish' is emitted + + this.finished = false; // has it been destroyed + + this.destroyed = false; // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + + this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + + this.length = 0; // a flag to see when we're in the middle of a write. + + this.writing = false; // when true all writes will be buffered until .uncork() call + + this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + + this.sync = true; // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + + this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb) + + this.onwrite = function (er) { + onwrite(stream, er); + }; // the callback that the user supplies to write(chunk,encoding,cb) + + this.writecb = null; // the amount that is being written when _write is called. + + this.writelen = 0; + this.bufferedRequest = null; + this.lastBufferedRequest = null; // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + + this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + + this.prefinished = false; // True if the error was already emitted and should not be thrown again + + this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true. + + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end') + + this.autoDestroy = !!options.autoDestroy; // count buffered requests + + this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + + this.corkedRequestsFree = new CorkedRequest(this); +} +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function writableStateBufferGetter() { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); // Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. + +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function value(object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function realHasInstance(object) { + return object instanceof this; + }; +} +function Writable(options) { + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + // Checking for a Stream.Duplex instance is faster here instead of inside + // the WritableState constructor, at least with V8 6.5 + + var isDuplex = this instanceof Registry$3.Duplex; + if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); + this._writableState = new WritableState(options, this, isDuplex); // legacy. + + this.writable = true; + if (options) { + if (typeof options.write === 'function') this._write = options.write; + if (typeof options.writev === 'function') this._writev = options.writev; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + if (typeof options.final === 'function') this._final = options.final; + } + Stream.call(this); +} // Otherwise people can pipe Writable streams, which is just wrong. + +Writable.prototype.pipe = function () { + errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); +}; +function writeAfterEnd(stream, cb) { + var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb + + errorOrDestroy(stream, er); + browser$1$1.nextTick(cb, er); +} // Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. + +function validChunk(stream, state, chunk, cb) { + var er; + if (chunk === null) { + er = new ERR_STREAM_NULL_VALUES(); + } else if (typeof chunk !== 'string' && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); + } + if (er) { + errorOrDestroy(stream, er); + browser$1$1.nextTick(cb, er); + return false; + } + return true; +} +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + if (typeof cb !== 'function') cb = nop; + if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + return ret; +}; +Writable.prototype.cork = function () { + this._writableState.corked++; +}; +Writable.prototype.uncork = function () { + var state = this._writableState; + if (state.corked) { + state.corked--; + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; +Object.defineProperty(Writable.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + return chunk; +} +Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } +}); // if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. + +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } + var len = state.objectMode ? 1 : chunk.length; + state.length += len; + var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. + + if (!ret) state.needDrain = true; + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + return ret; +} +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED$1('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + browser$1$1.nextTick(cb, er); // this can emit finish, and it will always happen + // after error + + browser$1$1.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + errorOrDestroy(stream, er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + errorOrDestroy(stream, er); // this can emit finish, but finish must + // always follow error + + finishMaybe(stream, state); + } +} +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK$1(); + onwriteStateUpdate(state); + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state) || stream.destroyed; + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + if (sync) { + browser$1$1.nextTick(afterWrite, stream, state, finished, cb); + } else { + afterWrite(stream, state, finished, cb); + } + } +} +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} // Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. + +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} // if there's something in the buffer waiting, then process it + +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + buffer.allBuffers = allBuffers; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + + if (state.writing) { + break; + } + } + if (entry === null) state.lastBufferedRequest = null; + } + state.bufferedRequest = entry; + state.bufferProcessing = false; +} +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED$1('_write()')); +}; +Writable.prototype._writev = null; +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks + + if (state.corked) { + state.corked = 1; + this.uncork(); + } // ignore unnecessary end() calls. + + if (!state.ending) endWritable(this, state, cb); + return this; +}; +Object.defineProperty(Writable.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + errorOrDestroy(stream, err); + } + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish$1(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function' && !state.destroyed) { + state.pendingcb++; + state.finalCalled = true; + browser$1$1.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } + } +} +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish$1(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the readable side is ready for autoDestroy as well + var rState = stream._readableState; + if (!rState || rState.autoDestroy && rState.endEmitted) { + stream.destroy(); + } + } + } + } + return need; +} +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) browser$1$1.nextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } // reuse the free corkReq. + + state.corkedRequestsFree.next = corkReq; +} +Object.defineProperty(Writable.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._writableState === undefined) { + return false; + } + return this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + this._writableState.destroyed = value; + } +}); +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + cb(err); +}; + +/**/ + +var objectKeys$1 = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + } + return keys; +}; +/**/ + +const Registry$2 = _registry; +Registry$2.Duplex = Duplex; +require$$1(Duplex, Registry$2.Readable); +{ + // Allow the keys array to be GC'ed. + var keys = objectKeys$1(Registry$2.Writable.prototype); + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Registry$2.Writable.prototype[method]; + } +} +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + Registry$2.Readable.call(this, options); + Registry$2.Writable.call(this, options); + this.allowHalfOpen = true; + if (options) { + if (options.readable === false) this.readable = false; + if (options.writable === false) this.writable = false; + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once('end', onend); + } + } +} +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } +}); +Object.defineProperty(Duplex.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); +Object.defineProperty(Duplex.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); // the no-half-open enforcer + +function onend() { + // If the writable side ended, then we're ok. + if (this._writableState.ended) return; // no more data can be written. + // But allow more writes to happen in this tick. + + browser$1$1.nextTick(onEndNT, this); +} +function onEndNT(self) { + self.end(); +} +Object.defineProperty(Duplex.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +const Registry$1 = _registry; +Registry$1.Transform = Transform$1; +var _require$codes$1 = errorsBrowser.codes, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes$1.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes$1.ERR_MULTIPLE_CALLBACK, + ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes$1.ERR_TRANSFORM_ALREADY_TRANSFORMING, + ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes$1.ERR_TRANSFORM_WITH_LENGTH_0; +require$$1(Transform$1, Registry$1.Duplex); +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + var cb = ts.writecb; + if (cb === null) { + return this.emit('error', new ERR_MULTIPLE_CALLBACK()); + } + ts.writechunk = null; + ts.writecb = null; + if (data != null) + // single equals check for both `null` and `undefined` + this.push(data); + cb(er); + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } +} +function Transform$1(options) { + if (!(this instanceof Transform$1)) return new Transform$1(options); + Registry$1.Duplex.call(this, options); + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; // start out asking for a readable event once data is transformed. + + this._readableState.needReadable = true; // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + + this._readableState.sync = false; + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + if (typeof options.flush === 'function') this._flush = options.flush; + } // When the writable side finishes, then flush out anything remaining. + + this.on('prefinish', prefinish); +} +function prefinish() { + var _this = this; + if (typeof this._flush === 'function' && !this._readableState.destroyed) { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } +} +Transform$1.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Registry$1.Duplex.prototype.push.call(this, chunk, encoding); +}; // This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. + +Transform$1.prototype._transform = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); +}; +Transform$1.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; // Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. + +Transform$1.prototype._read = function (n) { + var ts = this._transformState; + if (ts.writechunk !== null && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; +Transform$1.prototype._destroy = function (err, cb) { + Registry$1.Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + }); +}; +function done(stream, er, data) { + if (er) return stream.emit('error', er); + if (data != null) + // single equals check for both `null` and `undefined` + stream.push(data); // TODO(BridgeAR): Write a test for these two error cases + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + + if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); + return stream.push(null); +} + +const Registry = _registry; +Registry.PassThrough = PassThrough; +require$$1(PassThrough, Registry.Transform); +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + Transform.call(this, options); +} +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; + +var eos; +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + callback.apply(void 0, arguments); + }; +} +var _require$codes = errorsBrowser.codes, + ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; +function noop(err) { + // Rethrow the error if it exists to avoid swallowing it + if (err) throw err; +} +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} +function destroyer(stream, reading, writing, callback) { + callback = once(callback); + var closed = false; + stream.on('close', function () { + closed = true; + }); + if (eos === undefined) eos = endOfStream; + eos(stream, { + readable: reading, + writable: writing + }, function (err) { + if (err) return callback(err); + closed = true; + callback(); + }); + var destroyed = false; + return function (err) { + if (closed) return; + if (destroyed) return; + destroyed = true; // request.destroy just do .end - .abort is what we want + + if (isRequest(stream)) return stream.abort(); + if (typeof stream.destroy === 'function') return stream.destroy(); + callback(err || new ERR_STREAM_DESTROYED('pipe')); + }; +} +function call(fn) { + fn(); +} +function pipe(from, to) { + return from.pipe(to); +} +function popCallback(streams) { + if (!streams.length) return noop; + if (typeof streams[streams.length - 1] !== 'function') return noop; + return streams.pop(); +} +function pipeline() { + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { + streams[_key] = arguments[_key]; + } + var callback = popCallback(streams); + if (Array.isArray(streams[0])) streams = streams[0]; + if (streams.length < 2) { + throw new ERR_MISSING_ARGS('streams'); + } + var error; + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1; + var writing = i > 0; + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err; + if (err) destroys.forEach(call); + if (reading) return; + destroys.forEach(call); + callback(error); + }); + }); + return streams.reduce(pipe); +} +var pipeline_1 = pipeline; + +(function (module, exports) { + const Registry = _registry; + exports = module.exports = Registry.Readable; + exports.Stream = Registry.Readable; + exports.Readable = Registry.Readable; + exports.Writable = Registry.Writable; + exports.Duplex = Registry.Duplex; + exports.Transform = Registry.Transform; + exports.PassThrough = Registry.PassThrough; + exports.finished = endOfStream; + exports.pipeline = pipeline_1; +})(readableBrowser, readableBrowser.exports); +var readableBrowserExports = readableBrowser.exports; +var stream = /*@__PURE__*/getDefaultExportFromCjs(readableBrowserExports); + +var lib = {}; + +var binding = {}; + +function compare(a, b) { + if (a === b) { + return 0; + } + + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) { + return -1; + } + if (y < x) { + return 1; + } + return 0; +} +var hasOwn = Object.prototype.hasOwnProperty; + +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + if (hasOwn.call(obj, key)) keys.push(key); + } + return keys; +}; +var pSlice = Array.prototype.slice; +var _functionsHaveNames; +function functionsHaveNames() { + if (typeof _functionsHaveNames !== 'undefined') { + return _functionsHaveNames; + } + return _functionsHaveNames = (function () { + return function foo() {}.name === 'foo'; + }()); +} +function pToString (obj) { + return Object.prototype.toString.call(obj); +} +function isView(arrbuf) { + if (isBuffer$1(arrbuf)) { + return false; + } + if (typeof global$1.ArrayBuffer !== 'function') { + return false; + } + if (typeof ArrayBuffer.isView === 'function') { + return ArrayBuffer.isView(arrbuf); + } + if (!arrbuf) { + return false; + } + if (arrbuf instanceof DataView) { + return true; + } + if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { + return true; + } + return false; +} +// 1. The assert module provides functions that throw +// AssertionError's when particular conditions are not met. The +// assert module must conform to the following interface. + +function assert(value, message) { + if (!value) fail(value, true, message, '==', ok); +} + +// 2. The AssertionError is defined in assert. +// new assert.AssertionError({ message: message, +// actual: actual, +// expected: expected }) + +var regex = /\s*function\s+([^\(\s]*)\s*/; +// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js +function getName(func) { + if (!isFunction(func)) { + return; + } + if (functionsHaveNames()) { + return func.name; + } + var str = func.toString(); + var match = str.match(regex); + return match && match[1]; +} +assert.AssertionError = AssertionError; +function AssertionError(options) { + this.name = 'AssertionError'; + this.actual = options.actual; + this.expected = options.expected; + this.operator = options.operator; + if (options.message) { + this.message = options.message; + this.generatedMessage = false; + } else { + this.message = getMessage(this); + this.generatedMessage = true; + } + var stackStartFunction = options.stackStartFunction || fail; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, stackStartFunction); + } else { + // non v8 browsers so we can have a stacktrace + var err = new Error(); + if (err.stack) { + var out = err.stack; + + // try to strip useless frames + var fn_name = getName(stackStartFunction); + var idx = out.indexOf('\n' + fn_name); + if (idx >= 0) { + // once we have located the function frame + // we need to strip out everything before it (and its line) + var next_line = out.indexOf('\n', idx + 1); + out = out.substring(next_line + 1); + } + + this.stack = out; + } + } +} + +// assert.AssertionError instanceof Error +inherits$2(AssertionError, Error); + +function truncate(s, n) { + if (typeof s === 'string') { + return s.length < n ? s : s.slice(0, n); + } else { + return s; + } +} +function inspect(something) { + if (functionsHaveNames() || !isFunction(something)) { + return inspect$1(something); + } + var rawname = getName(something); + var name = rawname ? ': ' + rawname : ''; + return '[Function' + name + ']'; +} +function getMessage(self) { + return truncate(inspect(self.actual), 128) + ' ' + + self.operator + ' ' + + truncate(inspect(self.expected), 128); +} + +// At present only the three keys mentioned above are used and +// understood by the spec. Implementations or sub modules can pass +// other keys to the AssertionError's constructor - they will be +// ignored. + +// 3. All of the following functions must throw an AssertionError +// when a corresponding condition is not met, with a message that +// may be undefined if not provided. All assertion methods provide +// both the actual and expected values to the assertion error for +// display purposes. + +function fail(actual, expected, message, operator, stackStartFunction) { + throw new AssertionError({ + message: message, + actual: actual, + expected: expected, + operator: operator, + stackStartFunction: stackStartFunction + }); +} + +// EXTENSION! allows for well behaved errors defined elsewhere. +assert.fail = fail; + +// 4. Pure assertion tests whether a value is truthy, as determined +// by !!guard. +// assert.ok(guard, message_opt); +// This statement is equivalent to assert.equal(true, !!guard, +// message_opt);. To test strictly for the value true, use +// assert.strictEqual(true, guard, message_opt);. + +function ok(value, message) { + if (!value) fail(value, true, message, '==', ok); +} +assert.ok = ok; + +// 5. The equality assertion tests shallow, coercive equality with +// ==. +// assert.equal(actual, expected, message_opt); +assert.equal = equal; +function equal(actual, expected, message) { + if (actual != expected) fail(actual, expected, message, '==', equal); +} + +// 6. The non-equality assertion tests for whether two objects are not equal +// with != assert.notEqual(actual, expected, message_opt); +assert.notEqual = notEqual; +function notEqual(actual, expected, message) { + if (actual == expected) { + fail(actual, expected, message, '!=', notEqual); + } +} + +// 7. The equivalence assertion tests a deep equality relation. +// assert.deepEqual(actual, expected, message_opt); +assert.deepEqual = deepEqual; +function deepEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, false)) { + fail(actual, expected, message, 'deepEqual', deepEqual); + } +} +assert.deepStrictEqual = deepStrictEqual; +function deepStrictEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'deepStrictEqual', deepStrictEqual); + } +} + +function _deepEqual(actual, expected, strict, memos) { + // 7.1. All identical values are equivalent, as determined by ===. + if (actual === expected) { + return true; + } else if (isBuffer$1(actual) && isBuffer$1(expected)) { + return compare(actual, expected) === 0; + + // 7.2. If the expected value is a Date object, the actual value is + // equivalent if it is also a Date object that refers to the same time. + } else if (isDate(actual) && isDate(expected)) { + return actual.getTime() === expected.getTime(); + + // 7.3 If the expected value is a RegExp object, the actual value is + // equivalent if it is also a RegExp object with the same source and + // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). + } else if (isRegExp(actual) && isRegExp(expected)) { + return actual.source === expected.source && + actual.global === expected.global && + actual.multiline === expected.multiline && + actual.lastIndex === expected.lastIndex && + actual.ignoreCase === expected.ignoreCase; + + // 7.4. Other pairs that do not both pass typeof value == 'object', + // equivalence is determined by ==. + } else if ((actual === null || typeof actual !== 'object') && + (expected === null || typeof expected !== 'object')) { + return strict ? actual === expected : actual == expected; + + // If both values are instances of typed arrays, wrap their underlying + // ArrayBuffers in a Buffer each to increase performance + // This optimization requires the arrays to have the same type as checked by + // Object.prototype.toString (aka pToString). Never perform binary + // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their + // bit patterns are not identical. + } else if (isView(actual) && isView(expected) && + pToString(actual) === pToString(expected) && + !(actual instanceof Float32Array || + actual instanceof Float64Array)) { + return compare(new Uint8Array(actual.buffer), + new Uint8Array(expected.buffer)) === 0; + + // 7.5 For all other Object pairs, including Array objects, equivalence is + // determined by having the same number of owned properties (as verified + // with Object.prototype.hasOwnProperty.call), the same set of keys + // (although not necessarily the same order), equivalent values for every + // corresponding key, and an identical 'prototype' property. Note: this + // accounts for both named and indexed properties on Arrays. + } else if (isBuffer$1(actual) !== isBuffer$1(expected)) { + return false; + } else { + memos = memos || {actual: [], expected: []}; + + var actualIndex = memos.actual.indexOf(actual); + if (actualIndex !== -1) { + if (actualIndex === memos.expected.indexOf(expected)) { + return true; + } + } + + memos.actual.push(actual); + memos.expected.push(expected); + + return objEquiv(actual, expected, strict, memos); + } +} + +function isArguments(object) { + return Object.prototype.toString.call(object) == '[object Arguments]'; +} + +function objEquiv(a, b, strict, actualVisitedObjects) { + if (a === null || a === undefined || b === null || b === undefined) + return false; + // if one is a primitive, the other must be same + if (isPrimitive(a) || isPrimitive(b)) + return a === b; + if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) + return false; + var aIsArgs = isArguments(a); + var bIsArgs = isArguments(b); + if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) + return false; + if (aIsArgs) { + a = pSlice.call(a); + b = pSlice.call(b); + return _deepEqual(a, b, strict); + } + var ka = objectKeys(a); + var kb = objectKeys(b); + var key, i; + // having the same number of owned properties (keys incorporates + // hasOwnProperty) + if (ka.length !== kb.length) + return false; + //the same set of keys (although not necessarily the same order), + ka.sort(); + kb.sort(); + //~~~cheap key test + for (i = ka.length - 1; i >= 0; i--) { + if (ka[i] !== kb[i]) + return false; + } + //equivalent values for every corresponding key, and + //~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) + return false; + } + return true; +} + +// 8. The non-equivalence assertion tests for any deep inequality. +// assert.notDeepEqual(actual, expected, message_opt); +assert.notDeepEqual = notDeepEqual; +function notDeepEqual(actual, expected, message) { + if (_deepEqual(actual, expected, false)) { + fail(actual, expected, message, 'notDeepEqual', notDeepEqual); + } +} + +assert.notDeepStrictEqual = notDeepStrictEqual; +function notDeepStrictEqual(actual, expected, message) { + if (_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); + } +} + + +// 9. The strict equality assertion tests strict equality, as determined by ===. +// assert.strictEqual(actual, expected, message_opt); +assert.strictEqual = strictEqual; +function strictEqual(actual, expected, message) { + if (actual !== expected) { + fail(actual, expected, message, '===', strictEqual); + } +} + +// 10. The strict non-equality assertion tests for strict inequality, as +// determined by !==. assert.notStrictEqual(actual, expected, message_opt); +assert.notStrictEqual = notStrictEqual; +function notStrictEqual(actual, expected, message) { + if (actual === expected) { + fail(actual, expected, message, '!==', notStrictEqual); + } +} + +function expectedException(actual, expected) { + if (!actual || !expected) { + return false; + } + + if (Object.prototype.toString.call(expected) == '[object RegExp]') { + return expected.test(actual); + } + + try { + if (actual instanceof expected) { + return true; + } + } catch (e) { + // Ignore. The instanceof check doesn't work for arrow functions. + } + + if (Error.isPrototypeOf(expected)) { + return false; + } + + return expected.call({}, actual) === true; +} + +function _tryBlock(block) { + var error; + try { + block(); + } catch (e) { + error = e; + } + return error; +} + +function _throws(shouldThrow, block, expected, message) { + var actual; + + if (typeof block !== 'function') { + throw new TypeError('"block" argument must be a function'); + } + + if (typeof expected === 'string') { + message = expected; + expected = null; + } + + actual = _tryBlock(block); + + message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + + (message ? ' ' + message : '.'); + + if (shouldThrow && !actual) { + fail(actual, expected, 'Missing expected exception' + message); + } + + var userProvidedMessage = typeof message === 'string'; + var isUnwantedException = !shouldThrow && isError(actual); + var isUnexpectedException = !shouldThrow && actual && !expected; + + if ((isUnwantedException && + userProvidedMessage && + expectedException(actual, expected)) || + isUnexpectedException) { + fail(actual, expected, 'Got unwanted exception' + message); + } + + if ((shouldThrow && actual && expected && + !expectedException(actual, expected)) || (!shouldThrow && actual)) { + throw actual; + } +} + +// 11. Expected to throw an error: +// assert.throws(block, Error_opt, message_opt); +assert.throws = throws; +function throws(block, /*optional*/error, /*optional*/message) { + _throws(true, block, error, message); +} + +// EXTENSION! This is annoying to write outside this module. +assert.doesNotThrow = doesNotThrow; +function doesNotThrow(block, /*optional*/error, /*optional*/message) { + _throws(false, block, error, message); +} + +assert.ifError = ifError; +function ifError(err) { + if (err) throw err; +} + +var _polyfillNode_assert = /*#__PURE__*/Object.freeze({ + __proto__: null, + AssertionError: AssertionError, + assert: ok, + deepEqual: deepEqual, + deepStrictEqual: deepStrictEqual, + default: assert, + doesNotThrow: doesNotThrow, + equal: equal, + fail: fail, + ifError: ifError, + notDeepEqual: notDeepEqual, + notDeepStrictEqual: notDeepStrictEqual, + notEqual: notEqual, + notStrictEqual: notStrictEqual, + ok: ok, + strictEqual: strictEqual, + throws: throws +}); + +var require$$4 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_assert); + +(function (exports) { + + /* eslint camelcase: "off" */ + var assert = require$$4; + var Zstream = require$$1$2; + var zlib_deflate = require$$2; + var zlib_inflate = require$$3$1; + var constants = require$$4$1; + for (var key in constants) { + exports[key] = constants[key]; + } + + // zlib modes + exports.NONE = 0; + exports.DEFLATE = 1; + exports.INFLATE = 2; + exports.GZIP = 3; + exports.GUNZIP = 4; + exports.DEFLATERAW = 5; + exports.INFLATERAW = 6; + exports.UNZIP = 7; + var GZIP_HEADER_ID1 = 0x1f; + var GZIP_HEADER_ID2 = 0x8b; + + /** + * Emulate Node's zlib C++ layer for use by the JS layer in index.js + */ + function Zlib(mode) { + if (typeof mode !== 'number' || mode < exports.DEFLATE || mode > exports.UNZIP) { + throw new TypeError('Bad argument'); + } + this.dictionary = null; + this.err = 0; + this.flush = 0; + this.init_done = false; + this.level = 0; + this.memLevel = 0; + this.mode = mode; + this.strategy = 0; + this.windowBits = 0; + this.write_in_progress = false; + this.pending_close = false; + this.gzip_id_bytes_read = 0; + } + Zlib.prototype.close = function () { + if (this.write_in_progress) { + this.pending_close = true; + return; + } + this.pending_close = false; + assert(this.init_done, 'close before init'); + assert(this.mode <= exports.UNZIP); + if (this.mode === exports.DEFLATE || this.mode === exports.GZIP || this.mode === exports.DEFLATERAW) { + zlib_deflate.deflateEnd(this.strm); + } else if (this.mode === exports.INFLATE || this.mode === exports.GUNZIP || this.mode === exports.INFLATERAW || this.mode === exports.UNZIP) { + zlib_inflate.inflateEnd(this.strm); + } + this.mode = exports.NONE; + this.dictionary = null; + }; + Zlib.prototype.write = function (flush, input, in_off, in_len, out, out_off, out_len) { + return this._write(true, flush, input, in_off, in_len, out, out_off, out_len); + }; + Zlib.prototype.writeSync = function (flush, input, in_off, in_len, out, out_off, out_len) { + return this._write(false, flush, input, in_off, in_len, out, out_off, out_len); + }; + Zlib.prototype._write = function (async, flush, input, in_off, in_len, out, out_off, out_len) { + assert.equal(arguments.length, 8); + assert(this.init_done, 'write before init'); + assert(this.mode !== exports.NONE, 'already finalized'); + assert.equal(false, this.write_in_progress, 'write already in progress'); + assert.equal(false, this.pending_close, 'close is pending'); + this.write_in_progress = true; + assert.equal(false, flush === undefined, 'must provide flush value'); + this.write_in_progress = true; + if (flush !== exports.Z_NO_FLUSH && flush !== exports.Z_PARTIAL_FLUSH && flush !== exports.Z_SYNC_FLUSH && flush !== exports.Z_FULL_FLUSH && flush !== exports.Z_FINISH && flush !== exports.Z_BLOCK) { + throw new Error('Invalid flush value'); + } + if (input == null) { + input = Buffer$2.alloc(0); + in_len = 0; + in_off = 0; + } + this.strm.avail_in = in_len; + this.strm.input = input; + this.strm.next_in = in_off; + this.strm.avail_out = out_len; + this.strm.output = out; + this.strm.next_out = out_off; + this.flush = flush; + if (!async) { + // sync version + this._process(); + if (this._checkError()) { + return this._afterSync(); + } + return; + } + + // async version + var self = this; + browser$1$1.nextTick(function () { + self._process(); + self._after(); + }); + return this; + }; + Zlib.prototype._afterSync = function () { + var avail_out = this.strm.avail_out; + var avail_in = this.strm.avail_in; + this.write_in_progress = false; + return [avail_in, avail_out]; + }; + Zlib.prototype._process = function () { + var next_expected_header_byte = null; + + // If the avail_out is left at 0, then it means that it ran out + // of room. If there was avail_out left over, then it means + // that all of the input was consumed. + switch (this.mode) { + case exports.DEFLATE: + case exports.GZIP: + case exports.DEFLATERAW: + this.err = zlib_deflate.deflate(this.strm, this.flush); + break; + case exports.UNZIP: + if (this.strm.avail_in > 0) { + next_expected_header_byte = this.strm.next_in; + } + switch (this.gzip_id_bytes_read) { + case 0: + if (next_expected_header_byte === null) { + break; + } + if (this.strm.input[next_expected_header_byte] === GZIP_HEADER_ID1) { + this.gzip_id_bytes_read = 1; + next_expected_header_byte++; + if (this.strm.avail_in === 1) { + // The only available byte was already read. + break; + } + } else { + this.mode = exports.INFLATE; + break; + } + + // fallthrough + case 1: + if (next_expected_header_byte === null) { + break; + } + if (this.strm.input[next_expected_header_byte] === GZIP_HEADER_ID2) { + this.gzip_id_bytes_read = 2; + this.mode = exports.GUNZIP; + } else { + // There is no actual difference between INFLATE and INFLATERAW + // (after initialization). + this.mode = exports.INFLATE; + } + break; + default: + throw new Error('invalid number of gzip magic number bytes read'); + } + + // fallthrough + case exports.INFLATE: + case exports.GUNZIP: + case exports.INFLATERAW: + this.err = zlib_inflate.inflate(this.strm, this.flush + + // If data was encoded with dictionary + ); + if (this.err === exports.Z_NEED_DICT && this.dictionary) { + // Load it + this.err = zlib_inflate.inflateSetDictionary(this.strm, this.dictionary); + if (this.err === exports.Z_OK) { + // And try to decode again + this.err = zlib_inflate.inflate(this.strm, this.flush); + } else if (this.err === exports.Z_DATA_ERROR) { + // Both inflateSetDictionary() and inflate() return Z_DATA_ERROR. + // Make it possible for After() to tell a bad dictionary from bad + // input. + this.err = exports.Z_NEED_DICT; + } + } + while (this.strm.avail_in > 0 && this.mode === exports.GUNZIP && this.err === exports.Z_STREAM_END && this.strm.next_in[0] !== 0x00) { + // Bytes remain in input buffer. Perhaps this is another compressed + // member in the same archive, or just trailing garbage. + // Trailing zero bytes are okay, though, since they are frequently + // used for padding. + + this.reset(); + this.err = zlib_inflate.inflate(this.strm, this.flush); + } + break; + default: + throw new Error('Unknown mode ' + this.mode); + } + }; + Zlib.prototype._checkError = function () { + // Acceptable error states depend on the type of zlib stream. + switch (this.err) { + case exports.Z_OK: + case exports.Z_BUF_ERROR: + if (this.strm.avail_out !== 0 && this.flush === exports.Z_FINISH) { + this._error('unexpected end of file'); + return false; + } + break; + case exports.Z_STREAM_END: + // normal statuses, not fatal + break; + case exports.Z_NEED_DICT: + if (this.dictionary == null) { + this._error('Missing dictionary'); + } else { + this._error('Bad dictionary'); + } + return false; + default: + // something else. + this._error('Zlib error'); + return false; + } + return true; + }; + Zlib.prototype._after = function () { + if (!this._checkError()) { + return; + } + var avail_out = this.strm.avail_out; + var avail_in = this.strm.avail_in; + this.write_in_progress = false; + + // call the write() cb + this.callback(avail_in, avail_out); + if (this.pending_close) { + this.close(); + } + }; + Zlib.prototype._error = function (message) { + if (this.strm.msg) { + message = this.strm.msg; + } + this.onerror(message, this.err + + // no hope of rescue. + ); + this.write_in_progress = false; + if (this.pending_close) { + this.close(); + } + }; + Zlib.prototype.init = function (windowBits, level, memLevel, strategy, dictionary) { + assert(arguments.length === 4 || arguments.length === 5, 'init(windowBits, level, memLevel, strategy, [dictionary])'); + assert(windowBits >= 8 && windowBits <= 15, 'invalid windowBits'); + assert(level >= -1 && level <= 9, 'invalid compression level'); + assert(memLevel >= 1 && memLevel <= 9, 'invalid memlevel'); + assert(strategy === exports.Z_FILTERED || strategy === exports.Z_HUFFMAN_ONLY || strategy === exports.Z_RLE || strategy === exports.Z_FIXED || strategy === exports.Z_DEFAULT_STRATEGY, 'invalid strategy'); + this._init(level, windowBits, memLevel, strategy, dictionary); + this._setDictionary(); + }; + Zlib.prototype.params = function () { + throw new Error('deflateParams Not supported'); + }; + Zlib.prototype.reset = function () { + this._reset(); + this._setDictionary(); + }; + Zlib.prototype._init = function (level, windowBits, memLevel, strategy, dictionary) { + this.level = level; + this.windowBits = windowBits; + this.memLevel = memLevel; + this.strategy = strategy; + this.flush = exports.Z_NO_FLUSH; + this.err = exports.Z_OK; + if (this.mode === exports.GZIP || this.mode === exports.GUNZIP) { + this.windowBits += 16; + } + if (this.mode === exports.UNZIP) { + this.windowBits += 32; + } + if (this.mode === exports.DEFLATERAW || this.mode === exports.INFLATERAW) { + this.windowBits = -1 * this.windowBits; + } + this.strm = new Zstream(); + switch (this.mode) { + case exports.DEFLATE: + case exports.GZIP: + case exports.DEFLATERAW: + this.err = zlib_deflate.deflateInit2(this.strm, this.level, exports.Z_DEFLATED, this.windowBits, this.memLevel, this.strategy); + break; + case exports.INFLATE: + case exports.GUNZIP: + case exports.INFLATERAW: + case exports.UNZIP: + this.err = zlib_inflate.inflateInit2(this.strm, this.windowBits); + break; + default: + throw new Error('Unknown mode ' + this.mode); + } + if (this.err !== exports.Z_OK) { + this._error('Init error'); + } + this.dictionary = dictionary; + this.write_in_progress = false; + this.init_done = true; + }; + Zlib.prototype._setDictionary = function () { + if (this.dictionary == null) { + return; + } + this.err = exports.Z_OK; + switch (this.mode) { + case exports.DEFLATE: + case exports.DEFLATERAW: + this.err = zlib_deflate.deflateSetDictionary(this.strm, this.dictionary); + break; + } + if (this.err !== exports.Z_OK) { + this._error('Failed to set dictionary'); + } + }; + Zlib.prototype._reset = function () { + this.err = exports.Z_OK; + switch (this.mode) { + case exports.DEFLATE: + case exports.DEFLATERAW: + case exports.GZIP: + this.err = zlib_deflate.deflateReset(this.strm); + break; + case exports.INFLATE: + case exports.INFLATERAW: + case exports.GUNZIP: + this.err = zlib_inflate.inflateReset(this.strm); + break; + } + if (this.err !== exports.Z_OK) { + this._error('Failed to reset stream'); + } + }; + exports.Zlib = Zlib; +})(binding); + +(function (exports) { + + var Buffer = require$$0.Buffer; + var Transform = readableBrowserExports.Transform; + var binding$1 = binding; + var util = require$$3; + var assert = require$$4.ok; + var kMaxLength = require$$0.kMaxLength; + var kRangeErrorMessage = 'Cannot create final Buffer. It would be larger ' + 'than 0x' + kMaxLength.toString(16) + ' bytes'; + + // zlib doesn't provide these, so kludge them in following the same + // const naming scheme zlib uses. + binding$1.Z_MIN_WINDOWBITS = 8; + binding$1.Z_MAX_WINDOWBITS = 15; + binding$1.Z_DEFAULT_WINDOWBITS = 15; + + // fewer than 64 bytes per chunk is stupid. + // technically it could work with as few as 8, but even 64 bytes + // is absurdly low. Usually a MB or more is best. + binding$1.Z_MIN_CHUNK = 64; + binding$1.Z_MAX_CHUNK = Infinity; + binding$1.Z_DEFAULT_CHUNK = 16 * 1024; + binding$1.Z_MIN_MEMLEVEL = 1; + binding$1.Z_MAX_MEMLEVEL = 9; + binding$1.Z_DEFAULT_MEMLEVEL = 8; + binding$1.Z_MIN_LEVEL = -1; + binding$1.Z_MAX_LEVEL = 9; + binding$1.Z_DEFAULT_LEVEL = binding$1.Z_DEFAULT_COMPRESSION; + + // expose all the zlib constants + var bkeys = Object.keys(binding$1); + for (var bk = 0; bk < bkeys.length; bk++) { + var bkey = bkeys[bk]; + if (bkey.match(/^Z/)) { + Object.defineProperty(exports, bkey, { + enumerable: true, + value: binding$1[bkey], + writable: false + }); + } + } + + // translation table for return codes. + var codes = { + Z_OK: binding$1.Z_OK, + Z_STREAM_END: binding$1.Z_STREAM_END, + Z_NEED_DICT: binding$1.Z_NEED_DICT, + Z_ERRNO: binding$1.Z_ERRNO, + Z_STREAM_ERROR: binding$1.Z_STREAM_ERROR, + Z_DATA_ERROR: binding$1.Z_DATA_ERROR, + Z_MEM_ERROR: binding$1.Z_MEM_ERROR, + Z_BUF_ERROR: binding$1.Z_BUF_ERROR, + Z_VERSION_ERROR: binding$1.Z_VERSION_ERROR + }; + var ckeys = Object.keys(codes); + for (var ck = 0; ck < ckeys.length; ck++) { + var ckey = ckeys[ck]; + codes[codes[ckey]] = ckey; + } + Object.defineProperty(exports, 'codes', { + enumerable: true, + value: Object.freeze(codes), + writable: false + }); + exports.Deflate = Deflate; + exports.Inflate = Inflate; + exports.Gzip = Gzip; + exports.Gunzip = Gunzip; + exports.DeflateRaw = DeflateRaw; + exports.InflateRaw = InflateRaw; + exports.Unzip = Unzip; + exports.createDeflate = function (o) { + return new Deflate(o); + }; + exports.createInflate = function (o) { + return new Inflate(o); + }; + exports.createDeflateRaw = function (o) { + return new DeflateRaw(o); + }; + exports.createInflateRaw = function (o) { + return new InflateRaw(o); + }; + exports.createGzip = function (o) { + return new Gzip(o); + }; + exports.createGunzip = function (o) { + return new Gunzip(o); + }; + exports.createUnzip = function (o) { + return new Unzip(o); + }; + + // Convenience methods. + // compress/decompress a string or buffer in one step. + exports.deflate = function (buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new Deflate(opts), buffer, callback); + }; + exports.deflateSync = function (buffer, opts) { + return zlibBufferSync(new Deflate(opts), buffer); + }; + exports.gzip = function (buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new Gzip(opts), buffer, callback); + }; + exports.gzipSync = function (buffer, opts) { + return zlibBufferSync(new Gzip(opts), buffer); + }; + exports.deflateRaw = function (buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new DeflateRaw(opts), buffer, callback); + }; + exports.deflateRawSync = function (buffer, opts) { + return zlibBufferSync(new DeflateRaw(opts), buffer); + }; + exports.unzip = function (buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new Unzip(opts), buffer, callback); + }; + exports.unzipSync = function (buffer, opts) { + return zlibBufferSync(new Unzip(opts), buffer); + }; + exports.inflate = function (buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new Inflate(opts), buffer, callback); + }; + exports.inflateSync = function (buffer, opts) { + return zlibBufferSync(new Inflate(opts), buffer); + }; + exports.gunzip = function (buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new Gunzip(opts), buffer, callback); + }; + exports.gunzipSync = function (buffer, opts) { + return zlibBufferSync(new Gunzip(opts), buffer); + }; + exports.inflateRaw = function (buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new InflateRaw(opts), buffer, callback); + }; + exports.inflateRawSync = function (buffer, opts) { + return zlibBufferSync(new InflateRaw(opts), buffer); + }; + function zlibBuffer(engine, buffer, callback) { + var buffers = []; + var nread = 0; + engine.on('error', onError); + engine.on('end', onEnd); + engine.end(buffer); + flow(); + function flow() { + var chunk; + while (null !== (chunk = engine.read())) { + buffers.push(chunk); + nread += chunk.length; + } + engine.once('readable', flow); + } + function onError(err) { + engine.removeListener('end', onEnd); + engine.removeListener('readable', flow); + callback(err); + } + function onEnd() { + var buf; + var err = null; + if (nread >= kMaxLength) { + err = new RangeError(kRangeErrorMessage); + } else { + buf = Buffer.concat(buffers, nread); + } + buffers = []; + engine.close(); + callback(err, buf); + } + } + function zlibBufferSync(engine, buffer) { + if (typeof buffer === 'string') buffer = Buffer.from(buffer); + if (!Buffer.isBuffer(buffer)) throw new TypeError('Not a string or buffer'); + var flushFlag = engine._finishFlushFlag; + return engine._processChunk(buffer, flushFlag); + } + + // generic zlib + // minimal 2-byte header + function Deflate(opts) { + if (!(this instanceof Deflate)) return new Deflate(opts); + Zlib.call(this, opts, binding$1.DEFLATE); + } + function Inflate(opts) { + if (!(this instanceof Inflate)) return new Inflate(opts); + Zlib.call(this, opts, binding$1.INFLATE); + } + + // gzip - bigger header, same deflate compression + function Gzip(opts) { + if (!(this instanceof Gzip)) return new Gzip(opts); + Zlib.call(this, opts, binding$1.GZIP); + } + function Gunzip(opts) { + if (!(this instanceof Gunzip)) return new Gunzip(opts); + Zlib.call(this, opts, binding$1.GUNZIP); + } + + // raw - no header + function DeflateRaw(opts) { + if (!(this instanceof DeflateRaw)) return new DeflateRaw(opts); + Zlib.call(this, opts, binding$1.DEFLATERAW); + } + function InflateRaw(opts) { + if (!(this instanceof InflateRaw)) return new InflateRaw(opts); + Zlib.call(this, opts, binding$1.INFLATERAW); + } + + // auto-detect header. + function Unzip(opts) { + if (!(this instanceof Unzip)) return new Unzip(opts); + Zlib.call(this, opts, binding$1.UNZIP); + } + function isValidFlushFlag(flag) { + return flag === binding$1.Z_NO_FLUSH || flag === binding$1.Z_PARTIAL_FLUSH || flag === binding$1.Z_SYNC_FLUSH || flag === binding$1.Z_FULL_FLUSH || flag === binding$1.Z_FINISH || flag === binding$1.Z_BLOCK; + } + + // the Zlib class they all inherit from + // This thing manages the queue of requests, and returns + // true or false if there is anything in the queue when + // you call the .write() method. + + function Zlib(opts, mode) { + var _this = this; + this._opts = opts = opts || {}; + this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK; + Transform.call(this, opts); + if (opts.flush && !isValidFlushFlag(opts.flush)) { + throw new Error('Invalid flush flag: ' + opts.flush); + } + if (opts.finishFlush && !isValidFlushFlag(opts.finishFlush)) { + throw new Error('Invalid flush flag: ' + opts.finishFlush); + } + this._flushFlag = opts.flush || binding$1.Z_NO_FLUSH; + this._finishFlushFlag = typeof opts.finishFlush !== 'undefined' ? opts.finishFlush : binding$1.Z_FINISH; + if (opts.chunkSize) { + if (opts.chunkSize < exports.Z_MIN_CHUNK || opts.chunkSize > exports.Z_MAX_CHUNK) { + throw new Error('Invalid chunk size: ' + opts.chunkSize); + } + } + if (opts.windowBits) { + if (opts.windowBits < exports.Z_MIN_WINDOWBITS || opts.windowBits > exports.Z_MAX_WINDOWBITS) { + throw new Error('Invalid windowBits: ' + opts.windowBits); + } + } + if (opts.level) { + if (opts.level < exports.Z_MIN_LEVEL || opts.level > exports.Z_MAX_LEVEL) { + throw new Error('Invalid compression level: ' + opts.level); + } + } + if (opts.memLevel) { + if (opts.memLevel < exports.Z_MIN_MEMLEVEL || opts.memLevel > exports.Z_MAX_MEMLEVEL) { + throw new Error('Invalid memLevel: ' + opts.memLevel); + } + } + if (opts.strategy) { + if (opts.strategy != exports.Z_FILTERED && opts.strategy != exports.Z_HUFFMAN_ONLY && opts.strategy != exports.Z_RLE && opts.strategy != exports.Z_FIXED && opts.strategy != exports.Z_DEFAULT_STRATEGY) { + throw new Error('Invalid strategy: ' + opts.strategy); + } + } + if (opts.dictionary) { + if (!Buffer.isBuffer(opts.dictionary)) { + throw new Error('Invalid dictionary: it should be a Buffer instance'); + } + } + this._handle = new binding$1.Zlib(mode); + var self = this; + this._hadError = false; + this._handle.onerror = function (message, errno) { + // there is no way to cleanly recover. + // continuing only obscures problems. + _close(self); + self._hadError = true; + var error = new Error(message); + error.errno = errno; + error.code = exports.codes[errno]; + self.emit('error', error); + }; + var level = exports.Z_DEFAULT_COMPRESSION; + if (typeof opts.level === 'number') level = opts.level; + var strategy = exports.Z_DEFAULT_STRATEGY; + if (typeof opts.strategy === 'number') strategy = opts.strategy; + this._handle.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS, level, opts.memLevel || exports.Z_DEFAULT_MEMLEVEL, strategy, opts.dictionary); + this._buffer = Buffer.allocUnsafe(this._chunkSize); + this._offset = 0; + this._level = level; + this._strategy = strategy; + this.once('end', this.close); + Object.defineProperty(this, '_closed', { + get: function () { + return !_this._handle; + }, + configurable: true, + enumerable: true + }); + } + util.inherits(Zlib, Transform); + Zlib.prototype.params = function (level, strategy, callback) { + if (level < exports.Z_MIN_LEVEL || level > exports.Z_MAX_LEVEL) { + throw new RangeError('Invalid compression level: ' + level); + } + if (strategy != exports.Z_FILTERED && strategy != exports.Z_HUFFMAN_ONLY && strategy != exports.Z_RLE && strategy != exports.Z_FIXED && strategy != exports.Z_DEFAULT_STRATEGY) { + throw new TypeError('Invalid strategy: ' + strategy); + } + if (this._level !== level || this._strategy !== strategy) { + var self = this; + this.flush(binding$1.Z_SYNC_FLUSH, function () { + assert(self._handle, 'zlib binding closed'); + self._handle.params(level, strategy); + if (!self._hadError) { + self._level = level; + self._strategy = strategy; + if (callback) callback(); + } + }); + } else { + browser$1$1.nextTick(callback); + } + }; + Zlib.prototype.reset = function () { + assert(this._handle, 'zlib binding closed'); + return this._handle.reset(); + }; + + // This is the _flush function called by the transform class, + // internally, when the last chunk has been written. + Zlib.prototype._flush = function (callback) { + this._transform(Buffer.alloc(0), '', callback); + }; + Zlib.prototype.flush = function (kind, callback) { + var _this2 = this; + var ws = this._writableState; + if (typeof kind === 'function' || kind === undefined && !callback) { + callback = kind; + kind = binding$1.Z_FULL_FLUSH; + } + if (ws.ended) { + if (callback) browser$1$1.nextTick(callback); + } else if (ws.ending) { + if (callback) this.once('end', callback); + } else if (ws.needDrain) { + if (callback) { + this.once('drain', function () { + return _this2.flush(kind, callback); + }); + } + } else { + this._flushFlag = kind; + this.write(Buffer.alloc(0), '', callback); + } + }; + Zlib.prototype.close = function (callback) { + _close(this, callback); + browser$1$1.nextTick(emitCloseNT, this); + }; + function _close(engine, callback) { + if (callback) browser$1$1.nextTick(callback); + + // Caller may invoke .close after a zlib error (which will null _handle). + if (!engine._handle) return; + engine._handle.close(); + engine._handle = null; + } + function emitCloseNT(self) { + self.emit('close'); + } + Zlib.prototype._transform = function (chunk, encoding, cb) { + var flushFlag; + var ws = this._writableState; + var ending = ws.ending || ws.ended; + var last = ending && (!chunk || ws.length === chunk.length); + if (chunk !== null && !Buffer.isBuffer(chunk)) return cb(new Error('invalid input')); + if (!this._handle) return cb(new Error('zlib binding closed')); + + // If it's the last chunk, or a final flush, we use the Z_FINISH flush flag + // (or whatever flag was provided using opts.finishFlush). + // If it's explicitly flushing at some other time, then we use + // Z_FULL_FLUSH. Otherwise, use Z_NO_FLUSH for maximum compression + // goodness. + if (last) flushFlag = this._finishFlushFlag;else { + flushFlag = this._flushFlag; + // once we've flushed the last of the queue, stop flushing and + // go back to the normal behavior. + if (chunk.length >= ws.length) { + this._flushFlag = this._opts.flush || binding$1.Z_NO_FLUSH; + } + } + this._processChunk(chunk, flushFlag, cb); + }; + Zlib.prototype._processChunk = function (chunk, flushFlag, cb) { + var availInBefore = chunk && chunk.length; + var availOutBefore = this._chunkSize - this._offset; + var inOff = 0; + var self = this; + var async = typeof cb === 'function'; + if (!async) { + var buffers = []; + var nread = 0; + var error; + this.on('error', function (er) { + error = er; + }); + assert(this._handle, 'zlib binding closed'); + do { + var res = this._handle.writeSync(flushFlag, chunk, + // in + inOff, + // in_off + availInBefore, + // in_len + this._buffer, + // out + this._offset, + //out_off + availOutBefore); // out_len + } while (!this._hadError && callback(res[0], res[1])); + if (this._hadError) { + throw error; + } + if (nread >= kMaxLength) { + _close(this); + throw new RangeError(kRangeErrorMessage); + } + var buf = Buffer.concat(buffers, nread); + _close(this); + return buf; + } + assert(this._handle, 'zlib binding closed'); + var req = this._handle.write(flushFlag, chunk, + // in + inOff, + // in_off + availInBefore, + // in_len + this._buffer, + // out + this._offset, + //out_off + availOutBefore); // out_len + + req.buffer = chunk; + req.callback = callback; + function callback(availInAfter, availOutAfter) { + // When the callback is used in an async write, the callback's + // context is the `req` object that was created. The req object + // is === this._handle, and that's why it's important to null + // out the values after they are done being used. `this._handle` + // can stay in memory longer than the callback and buffer are needed. + if (this) { + this.buffer = null; + this.callback = null; + } + if (self._hadError) return; + var have = availOutBefore - availOutAfter; + assert(have >= 0, 'have should not go down'); + if (have > 0) { + var out = self._buffer.slice(self._offset, self._offset + have); + self._offset += have; + // serve some output to the consumer. + if (async) { + self.push(out); + } else { + buffers.push(out); + nread += out.length; + } + } + + // exhausted the output buffer, or used all the input create a new one. + if (availOutAfter === 0 || self._offset >= self._chunkSize) { + availOutBefore = self._chunkSize; + self._offset = 0; + self._buffer = Buffer.allocUnsafe(self._chunkSize); + } + if (availOutAfter === 0) { + // Not actually done. Need to reprocess. + // Also, update the availInBefore to the availInAfter value, + // so that if we have to hit it a third (fourth, etc.) time, + // it'll have the correct byte counts. + inOff += availInBefore - availInAfter; + availInBefore = availInAfter; + if (!async) return true; + var newReq = self._handle.write(flushFlag, chunk, inOff, availInBefore, self._buffer, self._offset, self._chunkSize); + newReq.callback = callback; // this same function + newReq.buffer = chunk; + return; + } + if (!async) return false; + + // finished with the chunk. + cb(); + } + }; + util.inherits(Deflate, Zlib); + util.inherits(Inflate, Zlib); + util.inherits(Gzip, Zlib); + util.inherits(Gunzip, Zlib); + util.inherits(DeflateRaw, Zlib); + util.inherits(InflateRaw, Zlib); + util.inherits(Unzip, Zlib); +})(lib); +var zlib = /*@__PURE__*/getDefaultExportFromCjs(lib); + +class PDFReference extends stream.Writable { + constructor(document, id, data) { + super({ + decodeStrings: false + }); + this.finalize = this.finalize.bind(this); + this.document = document; + this.id = id; + if (data == null) { + data = {}; + } + this.data = data; + this.gen = 0; + this.deflate = null; + this.compress = this.document.compress && !this.data.Filter; + this.uncompressedLength = 0; + this.chunks = []; + } + initDeflate() { + this.data.Filter = 'FlateDecode'; + this.deflate = zlib.createDeflate(); + this.deflate.on('data', chunk => { + this.chunks.push(chunk); + return this.data.Length += chunk.length; + }); + return this.deflate.on('end', this.finalize); + } + _write(chunk, encoding, callback) { + if (!(chunk instanceof Uint8Array)) { + chunk = Buffer$2.from(chunk + '\n', 'binary'); + } + this.uncompressedLength += chunk.length; + if (this.data.Length == null) { + this.data.Length = 0; + } + if (this.compress) { + if (!this.deflate) { + this.initDeflate(); + } + this.deflate.write(chunk); + } else { + this.chunks.push(chunk); + this.data.Length += chunk.length; + } + return callback(); + } + end() { + super.end(...arguments); + if (this.deflate) { + return this.deflate.end(); + } + return this.finalize(); + } + finalize() { + this.offset = this.document._offset; + const encryptFn = this.document._security ? this.document._security.getEncryptFn(this.id, this.gen) : null; + if (this.chunks.length) { + let buffer = Buffer$2.concat(this.chunks); + if (encryptFn) { + buffer = encryptFn(buffer); + } + this.data.Length = buffer.length; + this.document._write(`${this.id} ${this.gen} obj`); + this.document._write(PDFObject.convert(this.data, encryptFn)); + this.document._write('stream'); + this.document._write(buffer); + this.chunks.length = 0; + this.document._write('\nendstream'); + } else { + this.document._write(`${this.id} ${this.gen} obj`); + this.document._write(PDFObject.convert(this.data, encryptFn)); + } + this.document._write('endobj'); + return this.document._refEnd(this); + } + toString() { + return `${this.id} ${this.gen} R`; + } +} + +/* +PDFTree - abstract base class for name and number tree objects +*/ + +class PDFTree { + constructor(options) { + if (options === void 0) { + options = {}; + } + this._items = {}; + // disable /Limits output for this tree + this.limits = typeof options.limits === 'boolean' ? options.limits : true; + } + add(key, val) { + return this._items[key] = val; + } + get(key) { + return this._items[key]; + } + toString() { + // Needs to be sorted by key + const sortedKeys = Object.keys(this._items).sort((a, b) => this._compareKeys(a, b)); + const out = ['<<']; + if (this.limits && sortedKeys.length > 1) { + const first = sortedKeys[0], + last = sortedKeys[sortedKeys.length - 1]; + out.push(` /Limits ${PDFObject.convert([this._dataForKey(first), this._dataForKey(last)])}`); + } + out.push(` /${this._keysName()} [`); + for (let key of sortedKeys) { + out.push(` ${PDFObject.convert(this._dataForKey(key))} ${PDFObject.convert(this._items[key])}`); + } + out.push(']'); + out.push('>>'); + return out.join('\n'); + } + _compareKeys( /*a, b*/ + ) { + throw new Error('Must be implemented by subclasses'); + } + _keysName() { + throw new Error('Must be implemented by subclasses'); + } + _dataForKey( /*k*/ + ) { + throw new Error('Must be implemented by subclasses'); + } +} + +/* +PDFNameTree - represents a name tree object +*/ + +class PDFNameTree extends PDFTree { + _compareKeys(a, b) { + return a.localeCompare(b); + } + _keysName() { + return 'Names'; + } + _dataForKey(k) { + return new String(k); + } +} + +const pad = (str, length) => (Array(length + 1).join('0') + str).slice(-length); +const escapableRe = /[\n\r\t\b\f()\\]/g; +const escapable = { + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\b': '\\b', + '\f': '\\f', + '\\': '\\\\', + '(': '\\(', + ')': '\\)' +}; + +// Convert little endian UTF-16 to big endian +const swapBytes = function (buff) { + const l = buff.length; + if (l & 0x01) { + throw new Error('Buffer length must be even'); + } else { + for (let i = 0, end = l - 1; i < end; i += 2) { + const a = buff[i]; + buff[i] = buff[i + 1]; + buff[i + 1] = a; + } + } + return buff; +}; +class PDFObject { + static convert(object, encryptFn) { + if (encryptFn === void 0) { + encryptFn = null; + } + // String literals are converted to the PDF name type + if (typeof object === 'string') { + return `/${object}`; + } + + // String objects are converted to PDF strings (UTF-16) + if (object instanceof String) { + let string = object; + // Detect if this is a unicode string + let isUnicode = false; + for (let i = 0, end = string.length; i < end; i++) { + if (string.charCodeAt(i) > 0x7f) { + isUnicode = true; + break; + } + } + + // If so, encode it as big endian UTF-16 + let stringBuffer; + if (isUnicode) { + stringBuffer = swapBytes(Buffer$2.from(`\ufeff${string}`, 'utf16le')); + } else { + stringBuffer = Buffer$2.from(string.valueOf(), 'ascii'); + } + + // Encrypt the string when necessary + if (encryptFn) { + string = encryptFn(stringBuffer).toString('binary'); + } else { + string = stringBuffer.toString('binary'); + } + + // Escape characters as required by the spec + string = string.replace(escapableRe, c => escapable[c]); + return `(${string})`; + + // Buffers are converted to PDF hex strings + } + if (Buffer$2.isBuffer(object)) { + return `<${object.toString('hex')}>`; + } + if (object instanceof PDFReference || object instanceof PDFNameTree) { + return object.toString(); + } + if (object instanceof Date) { + let string = `D:${pad(object.getUTCFullYear(), 4)}` + pad(object.getUTCMonth() + 1, 2) + pad(object.getUTCDate(), 2) + pad(object.getUTCHours(), 2) + pad(object.getUTCMinutes(), 2) + pad(object.getUTCSeconds(), 2) + 'Z'; + + // Encrypt the string when necessary + if (encryptFn) { + string = encryptFn(Buffer$2.from(string, 'ascii')).toString('binary'); + string = string.replace(escapableRe, c => escapable[c]); + } + return `(${string})`; + } + if (Array.isArray(object)) { + const items = Array.from(object).map(e => PDFObject.convert(e, encryptFn)).join(' '); + return `[${items}]`; + } + if ({}.toString.call(object) === '[object Object]') { + const out = ['<<']; + for (let key in object) { + const val = object[key]; + out.push(`/${key} ${PDFObject.convert(val, encryptFn)}`); + } + out.push('>>'); + return out.join('\n'); + } + if (typeof object === 'number') { + return PDFObject.number(object); + } + return `${object}`; + } + static number(n) { + if (n > -1e21 && n < 1e21) { + return Math.round(n * 1e6) / 1e6; + } + throw new Error(`unsupported number: ${n}`); + } +} + +/* +PDFPage - represents a single page in the PDF document +By Devon Govett +*/ + +/** + * @type {SideDefinition} + */ +const DEFAULT_MARGINS = { + top: 72, + left: 72, + bottom: 72, + right: 72 +}; +const SIZES = { + '4A0': [4767.87, 6740.79], + '2A0': [3370.39, 4767.87], + A0: [2383.94, 3370.39], + A1: [1683.78, 2383.94], + A2: [1190.55, 1683.78], + A3: [841.89, 1190.55], + A4: [595.28, 841.89], + A5: [419.53, 595.28], + A6: [297.64, 419.53], + A7: [209.76, 297.64], + A8: [147.4, 209.76], + A9: [104.88, 147.4], + A10: [73.7, 104.88], + B0: [2834.65, 4008.19], + B1: [2004.09, 2834.65], + B2: [1417.32, 2004.09], + B3: [1000.63, 1417.32], + B4: [708.66, 1000.63], + B5: [498.9, 708.66], + B6: [354.33, 498.9], + B7: [249.45, 354.33], + B8: [175.75, 249.45], + B9: [124.72, 175.75], + B10: [87.87, 124.72], + C0: [2599.37, 3676.54], + C1: [1836.85, 2599.37], + C2: [1298.27, 1836.85], + C3: [918.43, 1298.27], + C4: [649.13, 918.43], + C5: [459.21, 649.13], + C6: [323.15, 459.21], + C7: [229.61, 323.15], + C8: [161.57, 229.61], + C9: [113.39, 161.57], + C10: [79.37, 113.39], + RA0: [2437.8, 3458.27], + RA1: [1729.13, 2437.8], + RA2: [1218.9, 1729.13], + RA3: [864.57, 1218.9], + RA4: [609.45, 864.57], + SRA0: [2551.18, 3628.35], + SRA1: [1814.17, 2551.18], + SRA2: [1275.59, 1814.17], + SRA3: [907.09, 1275.59], + SRA4: [637.8, 907.09], + EXECUTIVE: [521.86, 756.0], + FOLIO: [612.0, 936.0], + LEGAL: [612.0, 1008.0], + LETTER: [612.0, 792.0], + TABLOID: [792.0, 1224.0] +}; +class PDFPage { + constructor(document, options) { + if (options === void 0) { + options = {}; + } + this.document = document; + this._options = options; + this.size = options.size || 'letter'; + this.layout = options.layout || 'portrait'; + this.userUnit = options.userUnit || 1.0; + + // process margins + if (typeof options.margin === 'number') { + this.margins = { + top: options.margin, + left: options.margin, + bottom: options.margin, + right: options.margin + }; + + // default to 1 inch margins + } else { + this.margins = options.margins || DEFAULT_MARGINS; + } + + // calculate page dimensions + const dimensions = Array.isArray(this.size) ? this.size : SIZES[this.size.toUpperCase()]; + this.width = dimensions[this.layout === 'portrait' ? 0 : 1]; + this.height = dimensions[this.layout === 'portrait' ? 1 : 0]; + this.content = this.document.ref(); + if (options.font) document.font(options.font, options.fontFamily); + if (options.fontSize) document.fontSize(options.fontSize); + + // Initialize the Font, XObject, and ExtGState dictionaries + this.resources = this.document.ref({ + ProcSet: ['PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'] + }); + + // The page dictionary + this.dictionary = this.document.ref({ + Type: 'Page', + Parent: this.document._root.data.Pages, + MediaBox: [0, 0, this.width, this.height], + Contents: this.content, + Resources: this.resources, + UserUnit: this.userUnit + }); + this.markings = []; + } + + // Lazily create these objects + get fonts() { + const data = this.resources.data; + return data.Font != null ? data.Font : data.Font = {}; + } + get xobjects() { + const data = this.resources.data; + return data.XObject != null ? data.XObject : data.XObject = {}; + } + get ext_gstates() { + const data = this.resources.data; + return data.ExtGState != null ? data.ExtGState : data.ExtGState = {}; + } + get patterns() { + const data = this.resources.data; + return data.Pattern != null ? data.Pattern : data.Pattern = {}; + } + get colorSpaces() { + const data = this.resources.data; + return data.ColorSpace || (data.ColorSpace = {}); + } + get annotations() { + const data = this.dictionary.data; + return data.Annots != null ? data.Annots : data.Annots = []; + } + get structParentTreeKey() { + const data = this.dictionary.data; + return data.StructParents != null ? data.StructParents : data.StructParents = this.document.createStructParentTreeNextKey(); + } + maxY() { + return this.height - this.margins.bottom; + } + write(chunk) { + return this.content.write(chunk); + } + + // Set tab order if document is tagged for accessibility. + _setTabOrder() { + if (!this.dictionary.Tabs && this.document.hasMarkInfoDictionary()) { + this.dictionary.data.Tabs = 'S'; + } + } + end() { + this._setTabOrder(); + this.dictionary.end(); + this.resources.data.ColorSpace = this.resources.data.ColorSpace || {}; + for (let color of Object.values(this.document.spotColors)) { + this.resources.data.ColorSpace[color.id] = color; + } + this.resources.end(); + return this.content.end(); + } +} + +function md5Hash(data) { + return new Uint8Array(md5.arrayBuffer(data)); +} +function md5Hex(data) { + return md5(data); +} + +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. +// node.js versions earlier than v19 don't declare it in global scope. +// For node.js, package.json#exports field mapping rewrites import +// from `crypto` to `cryptoNode`, which imports native module. +// Makes the utils un-importable in browsers without a bundler. +// Once node.js 18 is deprecated (2025-04-30), we can just drop the import. +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +function isBytes(a) { + return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'; +} +/** Asserts something is Uint8Array. */ +function abytes(b) { + if (!isBytes(b)) throw new Error('Uint8Array expected'); + for (var _len = arguments.length, lengths = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + lengths[_key - 1] = arguments[_key]; + } + if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length); +} +/** Asserts a hash instance has not been destroyed / finished */ +function aexists(instance, checkFinished) { + if (checkFinished === void 0) { + checkFinished = true; + } + if (instance.destroyed) throw new Error('Hash instance has been destroyed'); + if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); +} +/** Asserts output is properly-sized byte array */ +function aoutput(out, instance) { + abytes(out); + const min = instance.outputLen; + if (out.length < min) { + throw new Error('digestInto() expects output buffer of length at least ' + min); + } +} +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +function clean() { + for (var _len2 = arguments.length, arrays = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + arrays[_key2] = arguments[_key2]; + } + for (let i = 0; i < arrays.length; i++) { + arrays[i].fill(0); + } +} +/** Create DataView of an array for easy byte-level manipulation. */ +function createView(arr) { + return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); +} +/** The rotate right (circular right shift) operation for uint32 */ +function rotr(word, shift) { + return word << 32 - shift | word >>> shift; +} +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99]) + */ +function utf8ToBytes(str) { + if (typeof str !== 'string') throw new Error('string expected'); + return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 +} +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +function toBytes(data) { + if (typeof data === 'string') data = utf8ToBytes(data); + abytes(data); + return data; +} +/** For runtime check if class implements interface */ +class Hash {} +/** Wraps hash function, creating an interface on top of it */ +function createHasher(hashCons) { + const hashC = msg => hashCons().update(toBytes(msg)).digest(); + const tmp = hashCons(); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = () => hashCons(); + return hashC; +} + +/** + * Internal Merkle-Damgard hash utils. + * @module + */ +/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */ +function setBigUint64(view, byteOffset, value, isLE) { + if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE); + const _32n = BigInt(32); + const _u32_max = BigInt(0xffffffff); + const wh = Number(value >> _32n & _u32_max); + const wl = Number(value & _u32_max); + const h = isLE ? 4 : 0; + const l = isLE ? 0 : 4; + view.setUint32(byteOffset + h, wh, isLE); + view.setUint32(byteOffset + l, wl, isLE); +} +/** Choice: a ? b : c */ +function Chi(a, b, c) { + return a & b ^ ~a & c; +} +/** Majority function, true if any two inputs is true. */ +function Maj(a, b, c) { + return a & b ^ a & c ^ b & c; +} +/** + * Merkle-Damgard hash construction base class. + * Could be used to create MD5, RIPEMD, SHA1, SHA2. + */ +class HashMD extends Hash { + constructor(blockLen, outputLen, padOffset, isLE) { + super(); + this.finished = false; + this.length = 0; + this.pos = 0; + this.destroyed = false; + this.blockLen = blockLen; + this.outputLen = outputLen; + this.padOffset = padOffset; + this.isLE = isLE; + this.buffer = new Uint8Array(blockLen); + this.view = createView(this.buffer); + } + update(data) { + aexists(this); + data = toBytes(data); + abytes(data); + const { + view, + buffer, + blockLen + } = this; + const len = data.length; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input, cast it to view and process + if (take === blockLen) { + const dataView = createView(data); + for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.process(view, 0); + this.pos = 0; + } + } + this.length += data.length; + this.roundClean(); + return this; + } + digestInto(out) { + aexists(this); + aoutput(out, this); + this.finished = true; + // Padding + // We can avoid allocation of buffer for padding completely if it + // was previously not allocated here. But it won't change performance. + const { + buffer, + view, + blockLen, + isLE + } = this; + let { + pos + } = this; + // append the bit '1' to the message + buffer[pos++] = 0b10000000; + clean(this.buffer.subarray(pos)); + // we have less than padOffset left in buffer, so we cannot put length in + // current block, need process it and pad again + if (this.padOffset > blockLen - pos) { + this.process(view, 0); + pos = 0; + } + // Pad until full block byte with zeros + for (let i = pos; i < blockLen; i++) buffer[i] = 0; + // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that + // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen. + // So we just write lowest 64 bits of that value. + setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE); + this.process(view, 0); + const oview = createView(out); + const len = this.outputLen; + // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT + if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit'); + const outLen = len / 4; + const state = this.get(); + if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state'); + for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE); + } + digest() { + const { + buffer, + outputLen + } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } + _cloneInto(to) { + to || (to = new this.constructor()); + to.set(...this.get()); + const { + blockLen, + buffer, + length, + finished, + destroyed, + pos + } = this; + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + if (length % blockLen) to.buffer.set(buffer); + return to; + } + clone() { + return this._cloneInto(); + } +} +/** + * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53. + * Check out `test/misc/sha2-gen-iv.js` for recomputation guide. + */ +/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */ +const SHA256_IV = /* @__PURE__ */Uint32Array.from([0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]); + +/** + * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256. + * SHA256 is the fastest hash implementable in JS, even faster than Blake3. + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + */ +/** + * Round constants: + * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311) + */ +// prettier-ignore +const SHA256_K = /* @__PURE__ */Uint32Array.from([0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2]); +/** Reusable temporary buffer. "W" comes straight from spec. */ +const SHA256_W = /* @__PURE__ */new Uint32Array(64); +class SHA256 extends HashMD { + constructor(outputLen) { + if (outputLen === void 0) { + outputLen = 32; + } + super(64, outputLen, 8, false); + // We cannot use array here since array allows indexing by variable + // which means optimizer/compiler cannot use registers. + this.A = SHA256_IV[0] | 0; + this.B = SHA256_IV[1] | 0; + this.C = SHA256_IV[2] | 0; + this.D = SHA256_IV[3] | 0; + this.E = SHA256_IV[4] | 0; + this.F = SHA256_IV[5] | 0; + this.G = SHA256_IV[6] | 0; + this.H = SHA256_IV[7] | 0; + } + get() { + const { + A, + B, + C, + D, + E, + F, + G, + H + } = this; + return [A, B, C, D, E, F, G, H]; + } + // prettier-ignore + set(A, B, C, D, E, F, G, H) { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + this.E = E | 0; + this.F = F | 0; + this.G = G | 0; + this.H = H | 0; + } + process(view, offset) { + // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array + for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false); + for (let i = 16; i < 64; i++) { + const W15 = SHA256_W[i - 15]; + const W2 = SHA256_W[i - 2]; + const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3; + const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10; + SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0; + } + // Compression function main loop, 64 rounds + let { + A, + B, + C, + D, + E, + F, + G, + H + } = this; + for (let i = 0; i < 64; i++) { + const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25); + const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0; + const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22); + const T2 = sigma0 + Maj(A, B, C) | 0; + H = G; + G = F; + F = E; + E = D + T1 | 0; + D = C; + C = B; + B = A; + A = T1 + T2 | 0; + } + // Add the compressed chunk to the current hash value + A = A + this.A | 0; + B = B + this.B | 0; + C = C + this.C | 0; + D = D + this.D | 0; + E = E + this.E | 0; + F = F + this.F | 0; + G = G + this.G | 0; + H = H + this.H | 0; + this.set(A, B, C, D, E, F, G, H); + } + roundClean() { + clean(SHA256_W); + } + destroy() { + this.set(0, 0, 0, 0, 0, 0, 0, 0); + clean(this.buffer); + } +} +/** + * SHA2-256 hash function from RFC 4634. + * + * It is the fastest JS hash, even faster than Blake3. + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + */ +const sha256 = /* @__PURE__ */createHasher(() => new SHA256()); + +function sha256Hash(data) { + return sha256(data); +} + +function aesCbcEncrypt(data, key, iv, padding) { + if (padding === void 0) { + padding = true; + } + return cbc(key, iv, { + disablePadding: !padding + }).encrypt(data); +} +function aesEcbEncrypt(data, key) { + return ecb(key, { + disablePadding: true + }).encrypt(data); +} + +// RC4 (for legacy PDF 1.3-1.5) +function rc4(data, key) { + const s = new Uint8Array(256); + for (let i = 0; i < 256; i++) { + s[i] = i; + } + let j = 0; + for (let i = 0; i < 256; i++) { + j = j + s[i] + key[i % key.length] & 0xff; + [s[i], s[j]] = [s[j], s[i]]; + } + const output = new Uint8Array(data.length); + for (let i = 0, j = 0, k = 0; k < data.length; k++) { + i = i + 1 & 0xff; + j = j + s[i] & 0xff; + [s[i], s[j]] = [s[j], s[i]]; + output[k] = data[k] ^ s[s[i] + s[j] & 0xff]; + } + return output; +} + +function randomBytes(length) { + const bytes = new Uint8Array(length); + globalThis.crypto.getRandomValues(bytes); + return bytes; +} + +/** + * Check if value is in a range group. + * @param {number} value + * @param {number[]} rangeGroup + * @returns {boolean} + */ +function inRange(value, rangeGroup) { + if (value < rangeGroup[0]) return false; + let startRange = 0; + let endRange = rangeGroup.length / 2; + while (startRange <= endRange) { + const middleRange = Math.floor((startRange + endRange) / 2); + + // actual array index + const arrayIndex = middleRange * 2; + + // Check if value is in range pointed by actual index + if (value >= rangeGroup[arrayIndex] && value <= rangeGroup[arrayIndex + 1]) { + return true; + } + if (value > rangeGroup[arrayIndex + 1]) { + // Search Right Side Of Array + startRange = middleRange + 1; + } else { + // Search Left Side Of Array + endRange = middleRange - 1; + } + } + return false; +} + +// prettier-ignore-start +/** + * A.1 Unassigned code points in Unicode 3.2 + * @link https://tools.ietf.org/html/rfc3454#appendix-A.1 + */ +const unassigned_code_points = [0x0221, 0x0221, 0x0234, 0x024f, 0x02ae, 0x02af, 0x02ef, 0x02ff, 0x0350, 0x035f, 0x0370, 0x0373, 0x0376, 0x0379, 0x037b, 0x037d, 0x037f, 0x0383, 0x038b, 0x038b, 0x038d, 0x038d, 0x03a2, 0x03a2, 0x03cf, 0x03cf, 0x03f7, 0x03ff, 0x0487, 0x0487, 0x04cf, 0x04cf, 0x04f6, 0x04f7, 0x04fa, 0x04ff, 0x0510, 0x0530, 0x0557, 0x0558, 0x0560, 0x0560, 0x0588, 0x0588, 0x058b, 0x0590, 0x05a2, 0x05a2, 0x05ba, 0x05ba, 0x05c5, 0x05cf, 0x05eb, 0x05ef, 0x05f5, 0x060b, 0x060d, 0x061a, 0x061c, 0x061e, 0x0620, 0x0620, 0x063b, 0x063f, 0x0656, 0x065f, 0x06ee, 0x06ef, 0x06ff, 0x06ff, 0x070e, 0x070e, 0x072d, 0x072f, 0x074b, 0x077f, 0x07b2, 0x0900, 0x0904, 0x0904, 0x093a, 0x093b, 0x094e, 0x094f, 0x0955, 0x0957, 0x0971, 0x0980, 0x0984, 0x0984, 0x098d, 0x098e, 0x0991, 0x0992, 0x09a9, 0x09a9, 0x09b1, 0x09b1, 0x09b3, 0x09b5, 0x09ba, 0x09bb, 0x09bd, 0x09bd, 0x09c5, 0x09c6, 0x09c9, 0x09ca, 0x09ce, 0x09d6, 0x09d8, 0x09db, 0x09de, 0x09de, 0x09e4, 0x09e5, 0x09fb, 0x0a01, 0x0a03, 0x0a04, 0x0a0b, 0x0a0e, 0x0a11, 0x0a12, 0x0a29, 0x0a29, 0x0a31, 0x0a31, 0x0a34, 0x0a34, 0x0a37, 0x0a37, 0x0a3a, 0x0a3b, 0x0a3d, 0x0a3d, 0x0a43, 0x0a46, 0x0a49, 0x0a4a, 0x0a4e, 0x0a58, 0x0a5d, 0x0a5d, 0x0a5f, 0x0a65, 0x0a75, 0x0a80, 0x0a84, 0x0a84, 0x0a8c, 0x0a8c, 0x0a8e, 0x0a8e, 0x0a92, 0x0a92, 0x0aa9, 0x0aa9, 0x0ab1, 0x0ab1, 0x0ab4, 0x0ab4, 0x0aba, 0x0abb, 0x0ac6, 0x0ac6, 0x0aca, 0x0aca, 0x0ace, 0x0acf, 0x0ad1, 0x0adf, 0x0ae1, 0x0ae5, 0x0af0, 0x0b00, 0x0b04, 0x0b04, 0x0b0d, 0x0b0e, 0x0b11, 0x0b12, 0x0b29, 0x0b29, 0x0b31, 0x0b31, 0x0b34, 0x0b35, 0x0b3a, 0x0b3b, 0x0b44, 0x0b46, 0x0b49, 0x0b4a, 0x0b4e, 0x0b55, 0x0b58, 0x0b5b, 0x0b5e, 0x0b5e, 0x0b62, 0x0b65, 0x0b71, 0x0b81, 0x0b84, 0x0b84, 0x0b8b, 0x0b8d, 0x0b91, 0x0b91, 0x0b96, 0x0b98, 0x0b9b, 0x0b9b, 0x0b9d, 0x0b9d, 0x0ba0, 0x0ba2, 0x0ba5, 0x0ba7, 0x0bab, 0x0bad, 0x0bb6, 0x0bb6, 0x0bba, 0x0bbd, 0x0bc3, 0x0bc5, 0x0bc9, 0x0bc9, 0x0bce, 0x0bd6, 0x0bd8, 0x0be6, 0x0bf3, 0x0c00, 0x0c04, 0x0c04, 0x0c0d, 0x0c0d, 0x0c11, 0x0c11, 0x0c29, 0x0c29, 0x0c34, 0x0c34, 0x0c3a, 0x0c3d, 0x0c45, 0x0c45, 0x0c49, 0x0c49, 0x0c4e, 0x0c54, 0x0c57, 0x0c5f, 0x0c62, 0x0c65, 0x0c70, 0x0c81, 0x0c84, 0x0c84, 0x0c8d, 0x0c8d, 0x0c91, 0x0c91, 0x0ca9, 0x0ca9, 0x0cb4, 0x0cb4, 0x0cba, 0x0cbd, 0x0cc5, 0x0cc5, 0x0cc9, 0x0cc9, 0x0cce, 0x0cd4, 0x0cd7, 0x0cdd, 0x0cdf, 0x0cdf, 0x0ce2, 0x0ce5, 0x0cf0, 0x0d01, 0x0d04, 0x0d04, 0x0d0d, 0x0d0d, 0x0d11, 0x0d11, 0x0d29, 0x0d29, 0x0d3a, 0x0d3d, 0x0d44, 0x0d45, 0x0d49, 0x0d49, 0x0d4e, 0x0d56, 0x0d58, 0x0d5f, 0x0d62, 0x0d65, 0x0d70, 0x0d81, 0x0d84, 0x0d84, 0x0d97, 0x0d99, 0x0db2, 0x0db2, 0x0dbc, 0x0dbc, 0x0dbe, 0x0dbf, 0x0dc7, 0x0dc9, 0x0dcb, 0x0dce, 0x0dd5, 0x0dd5, 0x0dd7, 0x0dd7, 0x0de0, 0x0df1, 0x0df5, 0x0e00, 0x0e3b, 0x0e3e, 0x0e5c, 0x0e80, 0x0e83, 0x0e83, 0x0e85, 0x0e86, 0x0e89, 0x0e89, 0x0e8b, 0x0e8c, 0x0e8e, 0x0e93, 0x0e98, 0x0e98, 0x0ea0, 0x0ea0, 0x0ea4, 0x0ea4, 0x0ea6, 0x0ea6, 0x0ea8, 0x0ea9, 0x0eac, 0x0eac, 0x0eba, 0x0eba, 0x0ebe, 0x0ebf, 0x0ec5, 0x0ec5, 0x0ec7, 0x0ec7, 0x0ece, 0x0ecf, 0x0eda, 0x0edb, 0x0ede, 0x0eff, 0x0f48, 0x0f48, 0x0f6b, 0x0f70, 0x0f8c, 0x0f8f, 0x0f98, 0x0f98, 0x0fbd, 0x0fbd, 0x0fcd, 0x0fce, 0x0fd0, 0x0fff, 0x1022, 0x1022, 0x1028, 0x1028, 0x102b, 0x102b, 0x1033, 0x1035, 0x103a, 0x103f, 0x105a, 0x109f, 0x10c6, 0x10cf, 0x10f9, 0x10fa, 0x10fc, 0x10ff, 0x115a, 0x115e, 0x11a3, 0x11a7, 0x11fa, 0x11ff, 0x1207, 0x1207, 0x1247, 0x1247, 0x1249, 0x1249, 0x124e, 0x124f, 0x1257, 0x1257, 0x1259, 0x1259, 0x125e, 0x125f, 0x1287, 0x1287, 0x1289, 0x1289, 0x128e, 0x128f, 0x12af, 0x12af, 0x12b1, 0x12b1, 0x12b6, 0x12b7, 0x12bf, 0x12bf, 0x12c1, 0x12c1, 0x12c6, 0x12c7, 0x12cf, 0x12cf, 0x12d7, 0x12d7, 0x12ef, 0x12ef, 0x130f, 0x130f, 0x1311, 0x1311, 0x1316, 0x1317, 0x131f, 0x131f, 0x1347, 0x1347, 0x135b, 0x1360, 0x137d, 0x139f, 0x13f5, 0x1400, 0x1677, 0x167f, 0x169d, 0x169f, 0x16f1, 0x16ff, 0x170d, 0x170d, 0x1715, 0x171f, 0x1737, 0x173f, 0x1754, 0x175f, 0x176d, 0x176d, 0x1771, 0x1771, 0x1774, 0x177f, 0x17dd, 0x17df, 0x17ea, 0x17ff, 0x180f, 0x180f, 0x181a, 0x181f, 0x1878, 0x187f, 0x18aa, 0x1dff, 0x1e9c, 0x1e9f, 0x1efa, 0x1eff, 0x1f16, 0x1f17, 0x1f1e, 0x1f1f, 0x1f46, 0x1f47, 0x1f4e, 0x1f4f, 0x1f58, 0x1f58, 0x1f5a, 0x1f5a, 0x1f5c, 0x1f5c, 0x1f5e, 0x1f5e, 0x1f7e, 0x1f7f, 0x1fb5, 0x1fb5, 0x1fc5, 0x1fc5, 0x1fd4, 0x1fd5, 0x1fdc, 0x1fdc, 0x1ff0, 0x1ff1, 0x1ff5, 0x1ff5, 0x1fff, 0x1fff, 0x2053, 0x2056, 0x2058, 0x205e, 0x2064, 0x2069, 0x2072, 0x2073, 0x208f, 0x209f, 0x20b2, 0x20cf, 0x20eb, 0x20ff, 0x213b, 0x213c, 0x214c, 0x2152, 0x2184, 0x218f, 0x23cf, 0x23ff, 0x2427, 0x243f, 0x244b, 0x245f, 0x24ff, 0x24ff, 0x2614, 0x2615, 0x2618, 0x2618, 0x267e, 0x267f, 0x268a, 0x2700, 0x2705, 0x2705, 0x270a, 0x270b, 0x2728, 0x2728, 0x274c, 0x274c, 0x274e, 0x274e, 0x2753, 0x2755, 0x2757, 0x2757, 0x275f, 0x2760, 0x2795, 0x2797, 0x27b0, 0x27b0, 0x27bf, 0x27cf, 0x27ec, 0x27ef, 0x2b00, 0x2e7f, 0x2e9a, 0x2e9a, 0x2ef4, 0x2eff, 0x2fd6, 0x2fef, 0x2ffc, 0x2fff, 0x3040, 0x3040, 0x3097, 0x3098, 0x3100, 0x3104, 0x312d, 0x3130, 0x318f, 0x318f, 0x31b8, 0x31ef, 0x321d, 0x321f, 0x3244, 0x3250, 0x327c, 0x327e, 0x32cc, 0x32cf, 0x32ff, 0x32ff, 0x3377, 0x337a, 0x33de, 0x33df, 0x33ff, 0x33ff, 0x4db6, 0x4dff, 0x9fa6, 0x9fff, 0xa48d, 0xa48f, 0xa4c7, 0xabff, 0xd7a4, 0xd7ff, 0xfa2e, 0xfa2f, 0xfa6b, 0xfaff, 0xfb07, 0xfb12, 0xfb18, 0xfb1c, 0xfb37, 0xfb37, 0xfb3d, 0xfb3d, 0xfb3f, 0xfb3f, 0xfb42, 0xfb42, 0xfb45, 0xfb45, 0xfbb2, 0xfbd2, 0xfd40, 0xfd4f, 0xfd90, 0xfd91, 0xfdc8, 0xfdcf, 0xfdfd, 0xfdff, 0xfe10, 0xfe1f, 0xfe24, 0xfe2f, 0xfe47, 0xfe48, 0xfe53, 0xfe53, 0xfe67, 0xfe67, 0xfe6c, 0xfe6f, 0xfe75, 0xfe75, 0xfefd, 0xfefe, 0xff00, 0xff00, 0xffbf, 0xffc1, 0xffc8, 0xffc9, 0xffd0, 0xffd1, 0xffd8, 0xffd9, 0xffdd, 0xffdf, 0xffe7, 0xffe7, 0xffef, 0xfff8, 0x10000, 0x102ff, 0x1031f, 0x1031f, 0x10324, 0x1032f, 0x1034b, 0x103ff, 0x10426, 0x10427, 0x1044e, 0x1cfff, 0x1d0f6, 0x1d0ff, 0x1d127, 0x1d129, 0x1d1de, 0x1d3ff, 0x1d455, 0x1d455, 0x1d49d, 0x1d49d, 0x1d4a0, 0x1d4a1, 0x1d4a3, 0x1d4a4, 0x1d4a7, 0x1d4a8, 0x1d4ad, 0x1d4ad, 0x1d4ba, 0x1d4ba, 0x1d4bc, 0x1d4bc, 0x1d4c1, 0x1d4c1, 0x1d4c4, 0x1d4c4, 0x1d506, 0x1d506, 0x1d50b, 0x1d50c, 0x1d515, 0x1d515, 0x1d51d, 0x1d51d, 0x1d53a, 0x1d53a, 0x1d53f, 0x1d53f, 0x1d545, 0x1d545, 0x1d547, 0x1d549, 0x1d551, 0x1d551, 0x1d6a4, 0x1d6a7, 0x1d7ca, 0x1d7cd, 0x1d800, 0x1fffd, 0x2a6d7, 0x2f7ff, 0x2fa1e, 0x2fffd, 0x30000, 0x3fffd, 0x40000, 0x4fffd, 0x50000, 0x5fffd, 0x60000, 0x6fffd, 0x70000, 0x7fffd, 0x80000, 0x8fffd, 0x90000, 0x9fffd, 0xa0000, 0xafffd, 0xb0000, 0xbfffd, 0xc0000, 0xcfffd, 0xd0000, 0xdfffd, 0xe0000, 0xe0000, 0xe0002, 0xe001f, 0xe0080, 0xefffd]; +// prettier-ignore-end + +const isUnassignedCodePoint = character => inRange(character, unassigned_code_points); + +// prettier-ignore-start +/** + * B.1 Commonly mapped to nothing + * @link https://tools.ietf.org/html/rfc3454#appendix-B.1 + */ +const commonly_mapped_to_nothing = [0x00ad, 0x00ad, 0x034f, 0x034f, 0x1806, 0x1806, 0x180b, 0x180b, 0x180c, 0x180c, 0x180d, 0x180d, 0x200b, 0x200b, 0x200c, 0x200c, 0x200d, 0x200d, 0x2060, 0x2060, 0xfe00, 0xfe00, 0xfe01, 0xfe01, 0xfe02, 0xfe02, 0xfe03, 0xfe03, 0xfe04, 0xfe04, 0xfe05, 0xfe05, 0xfe06, 0xfe06, 0xfe07, 0xfe07, 0xfe08, 0xfe08, 0xfe09, 0xfe09, 0xfe0a, 0xfe0a, 0xfe0b, 0xfe0b, 0xfe0c, 0xfe0c, 0xfe0d, 0xfe0d, 0xfe0e, 0xfe0e, 0xfe0f, 0xfe0f, 0xfeff, 0xfeff]; +// prettier-ignore-end + +const isCommonlyMappedToNothing = character => inRange(character, commonly_mapped_to_nothing); + +// prettier-ignore-start +/** + * C.1.2 Non-ASCII space characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.1.2 + */ +const non_ASCII_space_characters = [0x00a0, 0x00a0 /* NO-BREAK SPACE */, 0x1680, 0x1680 /* OGHAM SPACE MARK */, 0x2000, 0x2000 /* EN QUAD */, 0x2001, 0x2001 /* EM QUAD */, 0x2002, 0x2002 /* EN SPACE */, 0x2003, 0x2003 /* EM SPACE */, 0x2004, 0x2004 /* THREE-PER-EM SPACE */, 0x2005, 0x2005 /* FOUR-PER-EM SPACE */, 0x2006, 0x2006 /* SIX-PER-EM SPACE */, 0x2007, 0x2007 /* FIGURE SPACE */, 0x2008, 0x2008 /* PUNCTUATION SPACE */, 0x2009, 0x2009 /* THIN SPACE */, 0x200a, 0x200a /* HAIR SPACE */, 0x200b, 0x200b /* ZERO WIDTH SPACE */, 0x202f, 0x202f /* NARROW NO-BREAK SPACE */, 0x205f, 0x205f /* MEDIUM MATHEMATICAL SPACE */, 0x3000, 0x3000 /* IDEOGRAPHIC SPACE */]; +// prettier-ignore-end + +const isNonASCIISpaceCharacter = character => inRange(character, non_ASCII_space_characters); + +// prettier-ignore-start +const non_ASCII_controls_characters = [ +/** + * C.2.2 Non-ASCII control characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.2 + */ +0x0080, 0x009f /* [CONTROL CHARACTERS] */, 0x06dd, 0x06dd /* ARABIC END OF AYAH */, 0x070f, 0x070f /* SYRIAC ABBREVIATION MARK */, 0x180e, 0x180e /* MONGOLIAN VOWEL SEPARATOR */, 0x200c, 0x200c /* ZERO WIDTH NON-JOINER */, 0x200d, 0x200d /* ZERO WIDTH JOINER */, 0x2028, 0x2028 /* LINE SEPARATOR */, 0x2029, 0x2029 /* PARAGRAPH SEPARATOR */, 0x2060, 0x2060 /* WORD JOINER */, 0x2061, 0x2061 /* FUNCTION APPLICATION */, 0x2062, 0x2062 /* INVISIBLE TIMES */, 0x2063, 0x2063 /* INVISIBLE SEPARATOR */, 0x206a, 0x206f /* [CONTROL CHARACTERS] */, 0xfeff, 0xfeff /* ZERO WIDTH NO-BREAK SPACE */, 0xfff9, 0xfffc /* [CONTROL CHARACTERS] */, 0x1d173, 0x1d17a /* [MUSICAL CONTROL CHARACTERS] */]; +const non_character_codepoints = [ +/** + * C.4 Non-character code points + * @link https://tools.ietf.org/html/rfc3454#appendix-C.4 + */ +0xfdd0, 0xfdef /* [NONCHARACTER CODE POINTS] */, 0xfffe, 0xffff /* [NONCHARACTER CODE POINTS] */, 0x1fffe, 0x1ffff /* [NONCHARACTER CODE POINTS] */, 0x2fffe, 0x2ffff /* [NONCHARACTER CODE POINTS] */, 0x3fffe, 0x3ffff /* [NONCHARACTER CODE POINTS] */, 0x4fffe, 0x4ffff /* [NONCHARACTER CODE POINTS] */, 0x5fffe, 0x5ffff /* [NONCHARACTER CODE POINTS] */, 0x6fffe, 0x6ffff /* [NONCHARACTER CODE POINTS] */, 0x7fffe, 0x7ffff /* [NONCHARACTER CODE POINTS] */, 0x8fffe, 0x8ffff /* [NONCHARACTER CODE POINTS] */, 0x9fffe, 0x9ffff /* [NONCHARACTER CODE POINTS] */, 0xafffe, 0xaffff /* [NONCHARACTER CODE POINTS] */, 0xbfffe, 0xbffff /* [NONCHARACTER CODE POINTS] */, 0xcfffe, 0xcffff /* [NONCHARACTER CODE POINTS] */, 0xdfffe, 0xdffff /* [NONCHARACTER CODE POINTS] */, 0xefffe, 0xeffff /* [NONCHARACTER CODE POINTS] */, 0x10fffe, 0x10ffff /* [NONCHARACTER CODE POINTS] */]; + +/** + * 2.3. Prohibited Output + */ +const prohibited_characters = [ +/** + * C.2.1 ASCII control characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.1 + */ +0, 0x001f /* [CONTROL CHARACTERS] */, 0x007f, 0x007f /* DELETE */, +/** + * C.8 Change display properties or are deprecated + * @link https://tools.ietf.org/html/rfc3454#appendix-C.8 + */ +0x0340, 0x0340 /* COMBINING GRAVE TONE MARK */, 0x0341, 0x0341 /* COMBINING ACUTE TONE MARK */, 0x200e, 0x200e /* LEFT-TO-RIGHT MARK */, 0x200f, 0x200f /* RIGHT-TO-LEFT MARK */, 0x202a, 0x202a /* LEFT-TO-RIGHT EMBEDDING */, 0x202b, 0x202b /* RIGHT-TO-LEFT EMBEDDING */, 0x202c, 0x202c /* POP DIRECTIONAL FORMATTING */, 0x202d, 0x202d /* LEFT-TO-RIGHT OVERRIDE */, 0x202e, 0x202e /* RIGHT-TO-LEFT OVERRIDE */, 0x206a, 0x206a /* INHIBIT SYMMETRIC SWAPPING */, 0x206b, 0x206b /* ACTIVATE SYMMETRIC SWAPPING */, 0x206c, 0x206c /* INHIBIT ARABIC FORM SHAPING */, 0x206d, 0x206d /* ACTIVATE ARABIC FORM SHAPING */, 0x206e, 0x206e /* NATIONAL DIGIT SHAPES */, 0x206f, 0x206f /* NOMINAL DIGIT SHAPES */, +/** + * C.7 Inappropriate for canonical representation + * @link https://tools.ietf.org/html/rfc3454#appendix-C.7 + */ +0x2ff0, 0x2ffb /* [IDEOGRAPHIC DESCRIPTION CHARACTERS] */, +/** + * C.5 Surrogate codes + * @link https://tools.ietf.org/html/rfc3454#appendix-C.5 + */ +0xd800, 0xdfff, +/** + * C.3 Private use + * @link https://tools.ietf.org/html/rfc3454#appendix-C.3 + */ +0xe000, 0xf8ff /* [PRIVATE USE, PLANE 0] */, +/** + * C.6 Inappropriate for plain text + * @link https://tools.ietf.org/html/rfc3454#appendix-C.6 + */ +0xfff9, 0xfff9 /* INTERLINEAR ANNOTATION ANCHOR */, 0xfffa, 0xfffa /* INTERLINEAR ANNOTATION SEPARATOR */, 0xfffb, 0xfffb /* INTERLINEAR ANNOTATION TERMINATOR */, 0xfffc, 0xfffc /* OBJECT REPLACEMENT CHARACTER */, 0xfffd, 0xfffd /* REPLACEMENT CHARACTER */, +/** + * C.9 Tagging characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.9 + */ +0xe0001, 0xe0001 /* LANGUAGE TAG */, 0xe0020, 0xe007f /* [TAGGING CHARACTERS] */, +/** + * C.3 Private use + * @link https://tools.ietf.org/html/rfc3454#appendix-C.3 + */ + +0xf0000, 0xffffd /* [PRIVATE USE, PLANE 15] */, 0x100000, 0x10fffd /* [PRIVATE USE, PLANE 16] */]; +// prettier-ignore-end + +const isProhibitedCharacter = character => inRange(character, non_ASCII_space_characters) || inRange(character, prohibited_characters) || inRange(character, non_ASCII_controls_characters) || inRange(character, non_character_codepoints); + +// prettier-ignore-start +/** + * D.1 Characters with bidirectional property "R" or "AL" + * @link https://tools.ietf.org/html/rfc3454#appendix-D.1 + */ +const bidirectional_r_al = [0x05be, 0x05be, 0x05c0, 0x05c0, 0x05c3, 0x05c3, 0x05d0, 0x05ea, 0x05f0, 0x05f4, 0x061b, 0x061b, 0x061f, 0x061f, 0x0621, 0x063a, 0x0640, 0x064a, 0x066d, 0x066f, 0x0671, 0x06d5, 0x06dd, 0x06dd, 0x06e5, 0x06e6, 0x06fa, 0x06fe, 0x0700, 0x070d, 0x0710, 0x0710, 0x0712, 0x072c, 0x0780, 0x07a5, 0x07b1, 0x07b1, 0x200f, 0x200f, 0xfb1d, 0xfb1d, 0xfb1f, 0xfb28, 0xfb2a, 0xfb36, 0xfb38, 0xfb3c, 0xfb3e, 0xfb3e, 0xfb40, 0xfb41, 0xfb43, 0xfb44, 0xfb46, 0xfbb1, 0xfbd3, 0xfd3d, 0xfd50, 0xfd8f, 0xfd92, 0xfdc7, 0xfdf0, 0xfdfc, 0xfe70, 0xfe74, 0xfe76, 0xfefc]; +// prettier-ignore-end + +const isBidirectionalRAL = character => inRange(character, bidirectional_r_al); + +// prettier-ignore-start +/** + * D.2 Characters with bidirectional property "L" + * @link https://tools.ietf.org/html/rfc3454#appendix-D.2 + */ +const bidirectional_l = [0x0041, 0x005a, 0x0061, 0x007a, 0x00aa, 0x00aa, 0x00b5, 0x00b5, 0x00ba, 0x00ba, 0x00c0, 0x00d6, 0x00d8, 0x00f6, 0x00f8, 0x0220, 0x0222, 0x0233, 0x0250, 0x02ad, 0x02b0, 0x02b8, 0x02bb, 0x02c1, 0x02d0, 0x02d1, 0x02e0, 0x02e4, 0x02ee, 0x02ee, 0x037a, 0x037a, 0x0386, 0x0386, 0x0388, 0x038a, 0x038c, 0x038c, 0x038e, 0x03a1, 0x03a3, 0x03ce, 0x03d0, 0x03f5, 0x0400, 0x0482, 0x048a, 0x04ce, 0x04d0, 0x04f5, 0x04f8, 0x04f9, 0x0500, 0x050f, 0x0531, 0x0556, 0x0559, 0x055f, 0x0561, 0x0587, 0x0589, 0x0589, 0x0903, 0x0903, 0x0905, 0x0939, 0x093d, 0x0940, 0x0949, 0x094c, 0x0950, 0x0950, 0x0958, 0x0961, 0x0964, 0x0970, 0x0982, 0x0983, 0x0985, 0x098c, 0x098f, 0x0990, 0x0993, 0x09a8, 0x09aa, 0x09b0, 0x09b2, 0x09b2, 0x09b6, 0x09b9, 0x09be, 0x09c0, 0x09c7, 0x09c8, 0x09cb, 0x09cc, 0x09d7, 0x09d7, 0x09dc, 0x09dd, 0x09df, 0x09e1, 0x09e6, 0x09f1, 0x09f4, 0x09fa, 0x0a05, 0x0a0a, 0x0a0f, 0x0a10, 0x0a13, 0x0a28, 0x0a2a, 0x0a30, 0x0a32, 0x0a33, 0x0a35, 0x0a36, 0x0a38, 0x0a39, 0x0a3e, 0x0a40, 0x0a59, 0x0a5c, 0x0a5e, 0x0a5e, 0x0a66, 0x0a6f, 0x0a72, 0x0a74, 0x0a83, 0x0a83, 0x0a85, 0x0a8b, 0x0a8d, 0x0a8d, 0x0a8f, 0x0a91, 0x0a93, 0x0aa8, 0x0aaa, 0x0ab0, 0x0ab2, 0x0ab3, 0x0ab5, 0x0ab9, 0x0abd, 0x0ac0, 0x0ac9, 0x0ac9, 0x0acb, 0x0acc, 0x0ad0, 0x0ad0, 0x0ae0, 0x0ae0, 0x0ae6, 0x0aef, 0x0b02, 0x0b03, 0x0b05, 0x0b0c, 0x0b0f, 0x0b10, 0x0b13, 0x0b28, 0x0b2a, 0x0b30, 0x0b32, 0x0b33, 0x0b36, 0x0b39, 0x0b3d, 0x0b3e, 0x0b40, 0x0b40, 0x0b47, 0x0b48, 0x0b4b, 0x0b4c, 0x0b57, 0x0b57, 0x0b5c, 0x0b5d, 0x0b5f, 0x0b61, 0x0b66, 0x0b70, 0x0b83, 0x0b83, 0x0b85, 0x0b8a, 0x0b8e, 0x0b90, 0x0b92, 0x0b95, 0x0b99, 0x0b9a, 0x0b9c, 0x0b9c, 0x0b9e, 0x0b9f, 0x0ba3, 0x0ba4, 0x0ba8, 0x0baa, 0x0bae, 0x0bb5, 0x0bb7, 0x0bb9, 0x0bbe, 0x0bbf, 0x0bc1, 0x0bc2, 0x0bc6, 0x0bc8, 0x0bca, 0x0bcc, 0x0bd7, 0x0bd7, 0x0be7, 0x0bf2, 0x0c01, 0x0c03, 0x0c05, 0x0c0c, 0x0c0e, 0x0c10, 0x0c12, 0x0c28, 0x0c2a, 0x0c33, 0x0c35, 0x0c39, 0x0c41, 0x0c44, 0x0c60, 0x0c61, 0x0c66, 0x0c6f, 0x0c82, 0x0c83, 0x0c85, 0x0c8c, 0x0c8e, 0x0c90, 0x0c92, 0x0ca8, 0x0caa, 0x0cb3, 0x0cb5, 0x0cb9, 0x0cbe, 0x0cbe, 0x0cc0, 0x0cc4, 0x0cc7, 0x0cc8, 0x0cca, 0x0ccb, 0x0cd5, 0x0cd6, 0x0cde, 0x0cde, 0x0ce0, 0x0ce1, 0x0ce6, 0x0cef, 0x0d02, 0x0d03, 0x0d05, 0x0d0c, 0x0d0e, 0x0d10, 0x0d12, 0x0d28, 0x0d2a, 0x0d39, 0x0d3e, 0x0d40, 0x0d46, 0x0d48, 0x0d4a, 0x0d4c, 0x0d57, 0x0d57, 0x0d60, 0x0d61, 0x0d66, 0x0d6f, 0x0d82, 0x0d83, 0x0d85, 0x0d96, 0x0d9a, 0x0db1, 0x0db3, 0x0dbb, 0x0dbd, 0x0dbd, 0x0dc0, 0x0dc6, 0x0dcf, 0x0dd1, 0x0dd8, 0x0ddf, 0x0df2, 0x0df4, 0x0e01, 0x0e30, 0x0e32, 0x0e33, 0x0e40, 0x0e46, 0x0e4f, 0x0e5b, 0x0e81, 0x0e82, 0x0e84, 0x0e84, 0x0e87, 0x0e88, 0x0e8a, 0x0e8a, 0x0e8d, 0x0e8d, 0x0e94, 0x0e97, 0x0e99, 0x0e9f, 0x0ea1, 0x0ea3, 0x0ea5, 0x0ea5, 0x0ea7, 0x0ea7, 0x0eaa, 0x0eab, 0x0ead, 0x0eb0, 0x0eb2, 0x0eb3, 0x0ebd, 0x0ebd, 0x0ec0, 0x0ec4, 0x0ec6, 0x0ec6, 0x0ed0, 0x0ed9, 0x0edc, 0x0edd, 0x0f00, 0x0f17, 0x0f1a, 0x0f34, 0x0f36, 0x0f36, 0x0f38, 0x0f38, 0x0f3e, 0x0f47, 0x0f49, 0x0f6a, 0x0f7f, 0x0f7f, 0x0f85, 0x0f85, 0x0f88, 0x0f8b, 0x0fbe, 0x0fc5, 0x0fc7, 0x0fcc, 0x0fcf, 0x0fcf, 0x1000, 0x1021, 0x1023, 0x1027, 0x1029, 0x102a, 0x102c, 0x102c, 0x1031, 0x1031, 0x1038, 0x1038, 0x1040, 0x1057, 0x10a0, 0x10c5, 0x10d0, 0x10f8, 0x10fb, 0x10fb, 0x1100, 0x1159, 0x115f, 0x11a2, 0x11a8, 0x11f9, 0x1200, 0x1206, 0x1208, 0x1246, 0x1248, 0x1248, 0x124a, 0x124d, 0x1250, 0x1256, 0x1258, 0x1258, 0x125a, 0x125d, 0x1260, 0x1286, 0x1288, 0x1288, 0x128a, 0x128d, 0x1290, 0x12ae, 0x12b0, 0x12b0, 0x12b2, 0x12b5, 0x12b8, 0x12be, 0x12c0, 0x12c0, 0x12c2, 0x12c5, 0x12c8, 0x12ce, 0x12d0, 0x12d6, 0x12d8, 0x12ee, 0x12f0, 0x130e, 0x1310, 0x1310, 0x1312, 0x1315, 0x1318, 0x131e, 0x1320, 0x1346, 0x1348, 0x135a, 0x1361, 0x137c, 0x13a0, 0x13f4, 0x1401, 0x1676, 0x1681, 0x169a, 0x16a0, 0x16f0, 0x1700, 0x170c, 0x170e, 0x1711, 0x1720, 0x1731, 0x1735, 0x1736, 0x1740, 0x1751, 0x1760, 0x176c, 0x176e, 0x1770, 0x1780, 0x17b6, 0x17be, 0x17c5, 0x17c7, 0x17c8, 0x17d4, 0x17da, 0x17dc, 0x17dc, 0x17e0, 0x17e9, 0x1810, 0x1819, 0x1820, 0x1877, 0x1880, 0x18a8, 0x1e00, 0x1e9b, 0x1ea0, 0x1ef9, 0x1f00, 0x1f15, 0x1f18, 0x1f1d, 0x1f20, 0x1f45, 0x1f48, 0x1f4d, 0x1f50, 0x1f57, 0x1f59, 0x1f59, 0x1f5b, 0x1f5b, 0x1f5d, 0x1f5d, 0x1f5f, 0x1f7d, 0x1f80, 0x1fb4, 0x1fb6, 0x1fbc, 0x1fbe, 0x1fbe, 0x1fc2, 0x1fc4, 0x1fc6, 0x1fcc, 0x1fd0, 0x1fd3, 0x1fd6, 0x1fdb, 0x1fe0, 0x1fec, 0x1ff2, 0x1ff4, 0x1ff6, 0x1ffc, 0x200e, 0x200e, 0x2071, 0x2071, 0x207f, 0x207f, 0x2102, 0x2102, 0x2107, 0x2107, 0x210a, 0x2113, 0x2115, 0x2115, 0x2119, 0x211d, 0x2124, 0x2124, 0x2126, 0x2126, 0x2128, 0x2128, 0x212a, 0x212d, 0x212f, 0x2131, 0x2133, 0x2139, 0x213d, 0x213f, 0x2145, 0x2149, 0x2160, 0x2183, 0x2336, 0x237a, 0x2395, 0x2395, 0x249c, 0x24e9, 0x3005, 0x3007, 0x3021, 0x3029, 0x3031, 0x3035, 0x3038, 0x303c, 0x3041, 0x3096, 0x309d, 0x309f, 0x30a1, 0x30fa, 0x30fc, 0x30ff, 0x3105, 0x312c, 0x3131, 0x318e, 0x3190, 0x31b7, 0x31f0, 0x321c, 0x3220, 0x3243, 0x3260, 0x327b, 0x327f, 0x32b0, 0x32c0, 0x32cb, 0x32d0, 0x32fe, 0x3300, 0x3376, 0x337b, 0x33dd, 0x33e0, 0x33fe, 0x3400, 0x4db5, 0x4e00, 0x9fa5, 0xa000, 0xa48c, 0xac00, 0xd7a3, 0xd800, 0xfa2d, 0xfa30, 0xfa6a, 0xfb00, 0xfb06, 0xfb13, 0xfb17, 0xff21, 0xff3a, 0xff41, 0xff5a, 0xff66, 0xffbe, 0xffc2, 0xffc7, 0xffca, 0xffcf, 0xffd2, 0xffd7, 0xffda, 0xffdc, 0x10300, 0x1031e, 0x10320, 0x10323, 0x10330, 0x1034a, 0x10400, 0x10425, 0x10428, 0x1044d, 0x1d000, 0x1d0f5, 0x1d100, 0x1d126, 0x1d12a, 0x1d166, 0x1d16a, 0x1d172, 0x1d183, 0x1d184, 0x1d18c, 0x1d1a9, 0x1d1ae, 0x1d1dd, 0x1d400, 0x1d454, 0x1d456, 0x1d49c, 0x1d49e, 0x1d49f, 0x1d4a2, 0x1d4a2, 0x1d4a5, 0x1d4a6, 0x1d4a9, 0x1d4ac, 0x1d4ae, 0x1d4b9, 0x1d4bb, 0x1d4bb, 0x1d4bd, 0x1d4c0, 0x1d4c2, 0x1d4c3, 0x1d4c5, 0x1d505, 0x1d507, 0x1d50a, 0x1d50d, 0x1d514, 0x1d516, 0x1d51c, 0x1d51e, 0x1d539, 0x1d53b, 0x1d53e, 0x1d540, 0x1d544, 0x1d546, 0x1d546, 0x1d54a, 0x1d550, 0x1d552, 0x1d6a3, 0x1d6a8, 0x1d7c9, 0x20000, 0x2a6d6, 0x2f800, 0x2fa1d, 0xf0000, 0xffffd, 0x100000, 0x10fffd]; +// prettier-ignore-end + +const isBidirectionalL = character => inRange(character, bidirectional_l); + +// 2.1. Mapping + +/** + * non-ASCII space characters [StringPrep, C.1.2] that can be + * mapped to SPACE (U+0020) + */ +const mapping2space = isNonASCIISpaceCharacter; + +/** + * the "commonly mapped to nothing" characters [StringPrep, B.1] + * that can be mapped to nothing. + */ +const mapping2nothing = isCommonlyMappedToNothing; + +// utils +const getCodePoint = character => character.codePointAt(0); +const first = x => x[0]; +const last = x => x[x.length - 1]; + +/** + * Convert provided string into an array of Unicode Code Points. + * Based on https://stackoverflow.com/a/21409165/1556249 + * and https://www.npmjs.com/package/code-point-at. + * @param {string} input + * @returns {number[]} + */ +function toCodePoints(input) { + const codepoints = []; + const size = input.length; + for (let i = 0; i < size; i += 1) { + const before = input.charCodeAt(i); + if (before >= 0xd800 && before <= 0xdbff && size > i + 1) { + const next = input.charCodeAt(i + 1); + if (next >= 0xdc00 && next <= 0xdfff) { + codepoints.push((before - 0xd800) * 0x400 + next - 0xdc00 + 0x10000); + i += 1; + continue; + } + } + codepoints.push(before); + } + return codepoints; +} + +/** + * SASLprep. + * @param {string} input + * @param {Object} opts + * @param {boolean} opts.allowUnassigned + * @returns {string} + */ +function saslprep(input, opts) { + if (opts === void 0) { + opts = {}; + } + if (typeof input !== 'string') { + throw new TypeError('Expected string.'); + } + if (input.length === 0) { + return ''; + } + + // 1. Map + const mapped_input = toCodePoints(input) + // 1.1 mapping to space + .map(character => mapping2space(character) ? 0x20 : character) + // 1.2 mapping to nothing + .filter(character => !mapping2nothing(character)); + + // 2. Normalize + const normalized_input = String.fromCodePoint.apply(null, mapped_input).normalize('NFKC'); + const normalized_map = toCodePoints(normalized_input); + + // 3. Prohibit + const hasProhibited = normalized_map.some(isProhibitedCharacter); + if (hasProhibited) { + throw new Error('Prohibited character, see https://tools.ietf.org/html/rfc4013#section-2.3'); + } + + // Unassigned Code Points + if (opts.allowUnassigned !== true) { + const hasUnassigned = normalized_map.some(isUnassignedCodePoint); + if (hasUnassigned) { + throw new Error('Unassigned code point, see https://tools.ietf.org/html/rfc4013#section-2.5'); + } + } + + // 4. check bidi + + const hasBidiRAL = normalized_map.some(isBidirectionalRAL); + const hasBidiL = normalized_map.some(isBidirectionalL); + + // 4.1 If a string contains any RandALCat character, the string MUST NOT + // contain any LCat character. + if (hasBidiRAL && hasBidiL) { + throw new Error('String must not contain RandALCat and LCat at the same time,' + ' see https://tools.ietf.org/html/rfc3454#section-6'); + } + + /** + * 4.2 If a string contains any RandALCat character, a RandALCat + * character MUST be the first character of the string, and a + * RandALCat character MUST be the last character of the string. + */ + + const isFirstBidiRAL = isBidirectionalRAL(getCodePoint(first(normalized_input))); + const isLastBidiRAL = isBidirectionalRAL(getCodePoint(last(normalized_input))); + if (hasBidiRAL && !(isFirstBidiRAL && isLastBidiRAL)) { + throw new Error('Bidirectional RandALCat character must be the first and the last' + ' character of the string, see https://tools.ietf.org/html/rfc3454#section-6'); + } + return normalized_input; +} + +function concatBytes() { + for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) { + arrays[_key] = arguments[_key]; + } + const length = arrays.reduce((a, b) => a + b.length, 0); + const result = new Uint8Array(length); + let offset = 0; + for (const arr of arrays) { + result.set(arr, offset); + offset += arr.length; + } + return result; +} +class PDFSecurity { + static generateFileID(info) { + if (info === void 0) { + info = {}; + } + let infoStr = `${info.CreationDate.getTime()}\n`; + for (let key in info) { + // eslint-disable-next-line no-prototype-builtins + if (!info.hasOwnProperty(key)) { + continue; + } + infoStr += `${key}: ${info[key].valueOf()}\n`; + } + return Buffer$2.from(md5Hash(infoStr)); + } + static generateRandomWordArray(bytes) { + return randomBytes(bytes); + } + static create(document, options) { + if (options === void 0) { + options = {}; + } + if (!options.ownerPassword && !options.userPassword) { + return null; + } + return new PDFSecurity(document, options); + } + constructor(document, options) { + if (options === void 0) { + options = {}; + } + if (!options.ownerPassword && !options.userPassword) { + throw new Error('None of owner password and user password is defined.'); + } + this.document = document; + this._setupEncryption(options); + } + _setupEncryption(options) { + switch (options.pdfVersion) { + case '1.4': + case '1.5': + this.version = 2; + break; + case '1.6': + case '1.7': + this.version = 4; + break; + case '1.7ext3': + this.version = 5; + break; + default: + this.version = 1; + break; + } + const encDict = { + Filter: 'Standard' + }; + switch (this.version) { + case 1: + case 2: + case 4: + this._setupEncryptionV1V2V4(this.version, encDict, options); + break; + case 5: + this._setupEncryptionV5(encDict, options); + break; + } + this.dictionary = this.document.ref(encDict); + } + _setupEncryptionV1V2V4(v, encDict, options) { + let r, permissions; + switch (v) { + case 1: + r = 2; + this.keyBits = 40; + permissions = getPermissionsR2(options.permissions); + break; + case 2: + r = 3; + this.keyBits = 128; + permissions = getPermissionsR3(options.permissions); + break; + case 4: + r = 4; + this.keyBits = 128; + permissions = getPermissionsR3(options.permissions); + break; + } + const paddedUserPassword = processPasswordR2R3R4(options.userPassword); + const paddedOwnerPassword = options.ownerPassword ? processPasswordR2R3R4(options.ownerPassword) : paddedUserPassword; + const ownerPasswordEntry = getOwnerPasswordR2R3R4(r, this.keyBits, paddedUserPassword, paddedOwnerPassword); + this.encryptionKey = getEncryptionKeyR2R3R4(r, this.keyBits, this.document._id, paddedUserPassword, ownerPasswordEntry, permissions); + let userPasswordEntry; + if (r === 2) { + userPasswordEntry = getUserPasswordR2(this.encryptionKey); + } else { + userPasswordEntry = getUserPasswordR3R4(this.document._id, this.encryptionKey); + } + encDict.V = v; + if (v >= 2) { + encDict.Length = this.keyBits; + } + if (v === 4) { + encDict.CF = { + StdCF: { + AuthEvent: 'DocOpen', + CFM: 'AESV2', + Length: this.keyBits / 8 + } + }; + encDict.StmF = 'StdCF'; + encDict.StrF = 'StdCF'; + } + encDict.R = r; + encDict.O = Buffer$2.from(ownerPasswordEntry); + encDict.U = Buffer$2.from(userPasswordEntry); + encDict.P = permissions; + } + _setupEncryptionV5(encDict, options) { + this.keyBits = 256; + const permissions = getPermissionsR3(options.permissions); + const processedUserPassword = processPasswordR5(options.userPassword); + const processedOwnerPassword = options.ownerPassword ? processPasswordR5(options.ownerPassword) : processedUserPassword; + this.encryptionKey = getEncryptionKeyR5(PDFSecurity.generateRandomWordArray); + const userPasswordEntry = getUserPasswordR5(processedUserPassword, PDFSecurity.generateRandomWordArray); + const userKeySalt = userPasswordEntry.slice(40, 48); + const userEncryptionKeyEntry = getUserEncryptionKeyR5(processedUserPassword, userKeySalt, this.encryptionKey); + const ownerPasswordEntry = getOwnerPasswordR5(processedOwnerPassword, userPasswordEntry, PDFSecurity.generateRandomWordArray); + const ownerKeySalt = ownerPasswordEntry.slice(40, 48); + const ownerEncryptionKeyEntry = getOwnerEncryptionKeyR5(processedOwnerPassword, ownerKeySalt, userPasswordEntry, this.encryptionKey); + const permsEntry = getEncryptedPermissionsR5(permissions, this.encryptionKey, PDFSecurity.generateRandomWordArray); + encDict.V = 5; + encDict.Length = this.keyBits; + encDict.CF = { + StdCF: { + AuthEvent: 'DocOpen', + CFM: 'AESV3', + Length: this.keyBits / 8 + } + }; + encDict.StmF = 'StdCF'; + encDict.StrF = 'StdCF'; + encDict.R = 5; + encDict.O = Buffer$2.from(ownerPasswordEntry); + encDict.OE = Buffer$2.from(ownerEncryptionKeyEntry); + encDict.U = Buffer$2.from(userPasswordEntry); + encDict.UE = Buffer$2.from(userEncryptionKeyEntry); + encDict.P = permissions; + encDict.Perms = Buffer$2.from(permsEntry); + } + getEncryptFn(obj, gen) { + let digest; + if (this.version < 5) { + // Create 5-byte object/generation number suffix + const suffix = new Uint8Array([obj & 0xff, obj >> 8 & 0xff, obj >> 16 & 0xff, gen & 0xff, gen >> 8 & 0xff]); + digest = concatBytes(this.encryptionKey, suffix); + } + if (this.version === 1 || this.version === 2) { + let key = md5Hash(digest); + const keyLen = Math.min(16, this.keyBits / 8 + 5); + key = key.slice(0, keyLen); + return buffer => Buffer$2.from(rc4(new Uint8Array(buffer), key)); + } + let key; + if (this.version === 4) { + // Append "sAlT" marker for AES + const saltMarker = new Uint8Array([0x73, 0x41, 0x6c, 0x54]); + key = md5Hash(concatBytes(digest, saltMarker)); + } else { + key = this.encryptionKey; + } + const iv = PDFSecurity.generateRandomWordArray(16); + return buffer => { + const encrypted = aesCbcEncrypt(new Uint8Array(buffer), key, iv, true); + return Buffer$2.from(concatBytes(iv, encrypted)); + }; + } + end() { + this.dictionary.end(); + } +} +function getPermissionsR2(permissionObject) { + if (permissionObject === void 0) { + permissionObject = {}; + } + let permissions = 0xffffffc0 >> 0; + if (permissionObject.printing) { + permissions |= 0b000000000100; + } + if (permissionObject.modifying) { + permissions |= 0b000000001000; + } + if (permissionObject.copying) { + permissions |= 0b000000010000; + } + if (permissionObject.annotating) { + permissions |= 0b000000100000; + } + return permissions; +} +function getPermissionsR3(permissionObject) { + if (permissionObject === void 0) { + permissionObject = {}; + } + let permissions = 0xfffff0c0 >> 0; + if (permissionObject.printing === 'lowResolution') { + permissions |= 0b000000000100; + } + if (permissionObject.printing === 'highResolution') { + permissions |= 0b100000000100; + } + if (permissionObject.modifying) { + permissions |= 0b000000001000; + } + if (permissionObject.copying) { + permissions |= 0b000000010000; + } + if (permissionObject.annotating) { + permissions |= 0b000000100000; + } + if (permissionObject.fillingForms) { + permissions |= 0b000100000000; + } + if (permissionObject.contentAccessibility) { + permissions |= 0b001000000000; + } + if (permissionObject.documentAssembly) { + permissions |= 0b010000000000; + } + return permissions; +} +function getUserPasswordR2(encryptionKey) { + return rc4(processPasswordR2R3R4(), encryptionKey); +} +function getUserPasswordR3R4(documentId, encryptionKey) { + const key = encryptionKey.slice(); + let cipher = md5Hash(concatBytes(processPasswordR2R3R4(), new Uint8Array(documentId))); + for (let i = 0; i < 20; i++) { + const xorKey = new Uint8Array(key.length); + for (let j = 0; j < key.length; j++) { + xorKey[j] = encryptionKey[j] ^ i; + } + cipher = rc4(cipher, xorKey); + } + // Pad to 32 bytes + const result = new Uint8Array(32); + result.set(cipher); + return result; +} +function getOwnerPasswordR2R3R4(r, keyBits, paddedUserPassword, paddedOwnerPassword) { + let digest = paddedOwnerPassword; + let round = r >= 3 ? 51 : 1; + for (let i = 0; i < round; i++) { + digest = md5Hash(digest); + } + const keyLen = keyBits / 8; + let key = digest.slice(0, keyLen); + let cipher = paddedUserPassword; + round = r >= 3 ? 20 : 1; + for (let i = 0; i < round; i++) { + const xorKey = new Uint8Array(keyLen); + for (let j = 0; j < keyLen; j++) { + xorKey[j] = key[j] ^ i; + } + cipher = rc4(cipher, xorKey); + } + return cipher; +} +function getEncryptionKeyR2R3R4(r, keyBits, documentId, paddedUserPassword, ownerPasswordEntry, permissions) { + // Build input: password + owner entry + permissions (LSB first) + document ID + const permBytes = new Uint8Array([permissions & 0xff, permissions >> 8 & 0xff, permissions >> 16 & 0xff, permissions >> 24 & 0xff]); + let key = concatBytes(paddedUserPassword, ownerPasswordEntry, permBytes, new Uint8Array(documentId)); + const round = r >= 3 ? 51 : 1; + const keyLen = keyBits / 8; + for (let i = 0; i < round; i++) { + key = md5Hash(key); + key = key.slice(0, keyLen); + } + return key; +} +function getUserPasswordR5(processedUserPassword, generateRandomWordArray) { + const validationSalt = generateRandomWordArray(8); + const keySalt = generateRandomWordArray(8); + const hash = sha256Hash(concatBytes(processedUserPassword, validationSalt)); + return concatBytes(hash, validationSalt, keySalt); +} +function getUserEncryptionKeyR5(processedUserPassword, userKeySalt, encryptionKey) { + const key = sha256Hash(concatBytes(processedUserPassword, userKeySalt)); + const iv = new Uint8Array(16); // Zero IV + return aesCbcEncrypt(encryptionKey, key, iv, false); +} +function getOwnerPasswordR5(processedOwnerPassword, userPasswordEntry, generateRandomWordArray) { + const validationSalt = generateRandomWordArray(8); + const keySalt = generateRandomWordArray(8); + const hash = sha256Hash(concatBytes(processedOwnerPassword, validationSalt, userPasswordEntry)); + return concatBytes(hash, validationSalt, keySalt); +} +function getOwnerEncryptionKeyR5(processedOwnerPassword, ownerKeySalt, userPasswordEntry, encryptionKey) { + const key = sha256Hash(concatBytes(processedOwnerPassword, ownerKeySalt, userPasswordEntry)); + const iv = new Uint8Array(16); // Zero IV + return aesCbcEncrypt(encryptionKey, key, iv, false); +} +function getEncryptionKeyR5(generateRandomWordArray) { + return generateRandomWordArray(32); +} +function getEncryptedPermissionsR5(permissions, encryptionKey, generateRandomWordArray) { + // Build 16-byte block: permissions (4 bytes LSB) + 0xFFFFFFFF (4 bytes) + "adbT" (4 bytes) + random (4 bytes) + const data = new Uint8Array(16); + // Permissions (LSB first) + data[0] = permissions & 0xff; + data[1] = permissions >> 8 & 0xff; + data[2] = permissions >> 16 & 0xff; + data[3] = permissions >> 24 & 0xff; + // 0xFFFFFFFF + data[4] = 0xff; + data[5] = 0xff; + data[6] = 0xff; + data[7] = 0xff; + // "adbT" = 0x54616462 (but stored as individual bytes) + data[8] = 0x54; // 'T' + data[9] = 0x61; // 'a' + data[10] = 0x64; // 'd' + data[11] = 0x62; // 'b' + // Random 4 bytes + const randomPart = generateRandomWordArray(4); + data.set(randomPart, 12); + return aesEcbEncrypt(data, encryptionKey); +} +function processPasswordR2R3R4(password) { + if (password === void 0) { + password = ''; + } + const out = new Uint8Array(32); + const length = password.length; + let index = 0; + while (index < length && index < 32) { + const code = password.charCodeAt(index); + if (code > 0xff) { + throw new Error('Password contains one or more invalid characters.'); + } + out[index] = code; + index++; + } + while (index < 32) { + out[index] = PASSWORD_PADDING[index - length]; + index++; + } + return out; +} +function processPasswordR5(password) { + if (password === void 0) { + password = ''; + } + password = unescape(encodeURIComponent(saslprep(password))); + const length = Math.min(127, password.length); + const out = new Uint8Array(length); + for (let i = 0; i < length; i++) { + out[i] = password.charCodeAt(i); + } + return out; +} +const PASSWORD_PADDING = [0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a]; + +const { + number: number$2 +} = PDFObject; +let PDFGradient$1 = class PDFGradient { + constructor(doc) { + this.doc = doc; + this.stops = []; + this.embedded = false; + this.transform = [1, 0, 0, 1, 0, 0]; + } + stop(pos, color, opacity) { + if (opacity == null) { + opacity = 1; + } + color = this.doc._normalizeColor(color); + if (this.stops.length === 0) { + if (color.length === 3) { + this._colorSpace = 'DeviceRGB'; + } else if (color.length === 4) { + this._colorSpace = 'DeviceCMYK'; + } else if (color.length === 1) { + this._colorSpace = 'DeviceGray'; + } else { + throw new Error('Unknown color space'); + } + } else if (this._colorSpace === 'DeviceRGB' && color.length !== 3 || this._colorSpace === 'DeviceCMYK' && color.length !== 4 || this._colorSpace === 'DeviceGray' && color.length !== 1) { + throw new Error('All gradient stops must use the same color space'); + } + opacity = Math.max(0, Math.min(1, opacity)); + this.stops.push([pos, color, opacity]); + return this; + } + setTransform(m11, m12, m21, m22, dx, dy) { + this.transform = [m11, m12, m21, m22, dx, dy]; + return this; + } + embed(m) { + let fn; + const stopsLength = this.stops.length; + if (stopsLength === 0) { + return; + } + this.embedded = true; + this.matrix = m; + + // if the last stop comes before 100%, add a copy at 100% + const last = this.stops[stopsLength - 1]; + if (last[0] < 1) { + this.stops.push([1, last[1], last[2]]); + } + const bounds = []; + const encode = []; + const stops = []; + for (let i = 0; i < stopsLength - 1; i++) { + encode.push(0, 1); + if (i + 2 !== stopsLength) { + bounds.push(this.stops[i + 1][0]); + } + fn = this.doc.ref({ + FunctionType: 2, + Domain: [0, 1], + C0: this.stops[i + 0][1], + C1: this.stops[i + 1][1], + N: 1 + }); + stops.push(fn); + fn.end(); + } + + // if there are only two stops, we don't need a stitching function + if (stopsLength === 1) { + fn = stops[0]; + } else { + fn = this.doc.ref({ + FunctionType: 3, + // stitching function + Domain: [0, 1], + Functions: stops, + Bounds: bounds, + Encode: encode + }); + fn.end(); + } + this.id = `Sh${++this.doc._gradCount}`; + const shader = this.shader(fn); + shader.end(); + const pattern = this.doc.ref({ + Type: 'Pattern', + PatternType: 2, + Shading: shader, + Matrix: this.matrix.map(number$2) + }); + pattern.end(); + if (this.stops.some(stop => stop[2] < 1)) { + let grad = this.opacityGradient(); + grad._colorSpace = 'DeviceGray'; + for (let stop of this.stops) { + grad.stop(stop[0], [stop[2]]); + } + grad = grad.embed(this.matrix); + const pageBBox = [0, 0, this.doc.page.width, this.doc.page.height]; + const form = this.doc.ref({ + Type: 'XObject', + Subtype: 'Form', + FormType: 1, + BBox: pageBBox, + Group: { + Type: 'Group', + S: 'Transparency', + CS: 'DeviceGray' + }, + Resources: { + ProcSet: ['PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'], + Pattern: { + Sh1: grad + } + } + }); + form.write('/Pattern cs /Sh1 scn'); + form.end(`${pageBBox.join(' ')} re f`); + const gstate = this.doc.ref({ + Type: 'ExtGState', + SMask: { + Type: 'Mask', + S: 'Luminosity', + G: form + } + }); + gstate.end(); + const opacityPattern = this.doc.ref({ + Type: 'Pattern', + PatternType: 1, + PaintType: 1, + TilingType: 2, + BBox: pageBBox, + XStep: pageBBox[2], + YStep: pageBBox[3], + Resources: { + ProcSet: ['PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'], + Pattern: { + Sh1: pattern + }, + ExtGState: { + Gs1: gstate + } + } + }); + opacityPattern.write('/Gs1 gs /Pattern cs /Sh1 scn'); + opacityPattern.end(`${pageBBox.join(' ')} re f`); + this.doc.page.patterns[this.id] = opacityPattern; + } else { + this.doc.page.patterns[this.id] = pattern; + } + return pattern; + } + apply(stroke) { + // apply gradient transform to existing document ctm + const [m0, m1, m2, m3, m4, m5] = this.doc._ctm; + const [m11, m12, m21, m22, dx, dy] = this.transform; + const m = [m0 * m11 + m2 * m12, m1 * m11 + m3 * m12, m0 * m21 + m2 * m22, m1 * m21 + m3 * m22, m0 * dx + m2 * dy + m4, m1 * dx + m3 * dy + m5]; + if (!this.embedded || m.join(' ') !== this.matrix.join(' ')) { + this.embed(m); + } + this.doc._setColorSpace('Pattern', stroke); + const op = stroke ? 'SCN' : 'scn'; + return this.doc.addContent(`/${this.id} ${op}`); + } +}; +let PDFLinearGradient$1 = class PDFLinearGradient extends PDFGradient$1 { + constructor(doc, x1, y1, x2, y2) { + super(doc); + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + } + shader(fn) { + return this.doc.ref({ + ShadingType: 2, + ColorSpace: this._colorSpace, + Coords: [this.x1, this.y1, this.x2, this.y2], + Function: fn, + Extend: [true, true] + }); + } + opacityGradient() { + return new PDFLinearGradient(this.doc, this.x1, this.y1, this.x2, this.y2); + } +}; +let PDFRadialGradient$1 = class PDFRadialGradient extends PDFGradient$1 { + constructor(doc, x1, y1, r1, x2, y2, r2) { + super(doc); + this.doc = doc; + this.x1 = x1; + this.y1 = y1; + this.r1 = r1; + this.x2 = x2; + this.y2 = y2; + this.r2 = r2; + } + shader(fn) { + return this.doc.ref({ + ShadingType: 3, + ColorSpace: this._colorSpace, + Coords: [this.x1, this.y1, this.r1, this.x2, this.y2, this.r2], + Function: fn, + Extend: [true, true] + }); + } + opacityGradient() { + return new PDFRadialGradient(this.doc, this.x1, this.y1, this.r1, this.x2, this.y2, this.r2); + } +}; +var Gradient = { + PDFGradient: PDFGradient$1, + PDFLinearGradient: PDFLinearGradient$1, + PDFRadialGradient: PDFRadialGradient$1 +}; + +/* +PDF tiling pattern support. Uncolored only. + */ + +const underlyingColorSpaces = ['DeviceCMYK', 'DeviceRGB']; +let PDFTilingPattern$1 = class PDFTilingPattern { + constructor(doc, bBox, xStep, yStep, stream) { + this.doc = doc; + this.bBox = bBox; + this.xStep = xStep; + this.yStep = yStep; + this.stream = stream; + } + createPattern() { + // no resources needed for our current usage + // required entry + const resources = this.doc.ref(); + resources.end(); + // apply default transform matrix (flipped in the default doc._ctm) + // see document.js & gradient.js + const [m0, m1, m2, m3, m4, m5] = this.doc._ctm; + const [m11, m12, m21, m22, dx, dy] = [1, 0, 0, 1, 0, 0]; + const m = [m0 * m11 + m2 * m12, m1 * m11 + m3 * m12, m0 * m21 + m2 * m22, m1 * m21 + m3 * m22, m0 * dx + m2 * dy + m4, m1 * dx + m3 * dy + m5]; + const pattern = this.doc.ref({ + Type: 'Pattern', + PatternType: 1, + // tiling + PaintType: 2, + // 1-colored, 2-uncolored + TilingType: 2, + // 2-no distortion + BBox: this.bBox, + XStep: this.xStep, + YStep: this.yStep, + Matrix: m.map(v => +v.toFixed(5)), + Resources: resources + }); + pattern.end(this.stream); + return pattern; + } + embedPatternColorSpaces() { + // map each pattern to an underlying color space + // and embed on each page + underlyingColorSpaces.forEach(csName => { + const csId = this.getPatternColorSpaceId(csName); + if (this.doc.page.colorSpaces[csId]) return; + const cs = this.doc.ref(['Pattern', csName]); + cs.end(); + this.doc.page.colorSpaces[csId] = cs; + }); + } + getPatternColorSpaceId(underlyingColorspace) { + return `CsP${underlyingColorspace}`; + } + embed() { + if (!this.id) { + this.doc._patternCount = this.doc._patternCount + 1; + this.id = 'P' + this.doc._patternCount; + this.pattern = this.createPattern(); + } + + // patterns are embedded in each page + if (!this.doc.page.patterns[this.id]) { + this.doc.page.patterns[this.id] = this.pattern; + } + } + apply(stroke, patternColor) { + // do any embedding/creating that might be needed + this.embedPatternColorSpaces(); + this.embed(); + const normalizedColor = this.doc._normalizeColor(patternColor); + if (!normalizedColor) throw Error(`invalid pattern color. (value: ${patternColor})`); + + // select one of the pattern color spaces + const csId = this.getPatternColorSpaceId(this.doc._getColorSpace(normalizedColor)); + this.doc._setColorSpace(csId, stroke); + + // stroke/fill using the pattern and color (in the above underlying color space) + const op = stroke ? 'SCN' : 'scn'; + return this.doc.addContent(`${normalizedColor.join(' ')} /${this.id} ${op}`); + } +}; +var pattern = { + PDFTilingPattern: PDFTilingPattern$1 +}; + +class SpotColor { + constructor(doc, name, C, M, Y, K) { + this.id = 'CS' + Object.keys(doc.spotColors).length; + this.name = name; + this.values = [C, M, Y, K]; + this.ref = doc.ref(['Separation', this.name, 'DeviceCMYK', { + Range: [0, 1, 0, 1, 0, 1, 0, 1], + C0: [0, 0, 0, 0], + C1: this.values.map(value => value / 100), + FunctionType: 2, + Domain: [0, 1], + N: 1 + }]); + this.ref.end(); + } + toString() { + return `${this.ref.id} 0 R`; + } +} + +const { + PDFGradient, + PDFLinearGradient, + PDFRadialGradient +} = Gradient; +const { + PDFTilingPattern +} = pattern; +var ColorMixin = { + initColor() { + this.spotColors = {}; + // The opacity dictionaries + this._opacityRegistry = {}; + this._opacityCount = 0; + this._patternCount = 0; + return this._gradCount = 0; + }, + _normalizeColor(color) { + if (typeof color === 'string') { + if (color.charAt(0) === '#') { + if (color.length === 4) { + color = color.replace(/#([0-9A-F])([0-9A-F])([0-9A-F])/i, '#$1$1$2$2$3$3'); + } + const hex = parseInt(color.slice(1), 16); + color = [hex >> 16, hex >> 8 & 0xff, hex & 0xff]; + } else if (namedColors[color]) { + color = namedColors[color]; + } else if (this.spotColors[color]) { + return this.spotColors[color]; + } + } + if (Array.isArray(color)) { + // RGB + if (color.length === 3) { + color = color.map(part => part / 255); + // CMYK + } else if (color.length === 4) { + color = color.map(part => part / 100); + } + return color; + } + return null; + }, + _setColor(color, stroke) { + if (color instanceof PDFGradient) { + color.apply(stroke); + return true; + // see if tiling pattern, decode & apply it it + } else if (Array.isArray(color) && color[0] instanceof PDFTilingPattern) { + color[0].apply(stroke, color[1]); + return true; + } + // any other case should be a normal color and not a pattern + return this._setColorCore(color, stroke); + }, + _setColorCore(color, stroke) { + color = this._normalizeColor(color); + if (!color) { + return false; + } + const op = stroke ? 'SCN' : 'scn'; + const space = this._getColorSpace(color); + this._setColorSpace(space, stroke); + if (color instanceof SpotColor) { + this.page.colorSpaces[color.id] = color.ref; + this.addContent(`1 ${op}`); + } else { + this.addContent(`${color.join(' ')} ${op}`); + } + return true; + }, + _setColorSpace(space, stroke) { + const op = stroke ? 'CS' : 'cs'; + return this.addContent(`/${space} ${op}`); + }, + _getColorSpace(color) { + if (color instanceof SpotColor) { + return color.id; + } + return color.length === 4 ? 'DeviceCMYK' : 'DeviceRGB'; + }, + fillColor(color, opacity) { + const set = this._setColor(color, false); + if (set) { + this.fillOpacity(opacity); + } + + // save this for text wrapper, which needs to reset + // the fill color on new pages + this._fillColor = [color, opacity]; + return this; + }, + strokeColor(color, opacity) { + const set = this._setColor(color, true); + if (set) { + this.strokeOpacity(opacity); + } + return this; + }, + opacity(opacity) { + this._doOpacity(opacity, opacity); + return this; + }, + fillOpacity(opacity) { + this._doOpacity(opacity, null); + return this; + }, + strokeOpacity(opacity) { + this._doOpacity(null, opacity); + return this; + }, + _doOpacity(fillOpacity, strokeOpacity) { + let dictionary, name; + if (fillOpacity == null && strokeOpacity == null) { + return; + } + if (fillOpacity != null) { + fillOpacity = Math.max(0, Math.min(1, fillOpacity)); + } + if (strokeOpacity != null) { + strokeOpacity = Math.max(0, Math.min(1, strokeOpacity)); + } + const key = `${fillOpacity}_${strokeOpacity}`; + if (this._opacityRegistry[key]) { + [dictionary, name] = this._opacityRegistry[key]; + } else { + dictionary = { + Type: 'ExtGState' + }; + if (fillOpacity != null) { + dictionary.ca = fillOpacity; + } + if (strokeOpacity != null) { + dictionary.CA = strokeOpacity; + } + dictionary = this.ref(dictionary); + dictionary.end(); + const id = ++this._opacityCount; + name = `Gs${id}`; + this._opacityRegistry[key] = [dictionary, name]; + } + this.page.ext_gstates[name] = dictionary; + return this.addContent(`/${name} gs`); + }, + linearGradient(x1, y1, x2, y2) { + return new PDFLinearGradient(this, x1, y1, x2, y2); + }, + radialGradient(x1, y1, r1, x2, y2, r2) { + return new PDFRadialGradient(this, x1, y1, r1, x2, y2, r2); + }, + pattern(bbox, xStep, yStep, stream) { + return new PDFTilingPattern(this, bbox, xStep, yStep, stream); + }, + addSpotColor(name, C, M, Y, K) { + const color = new SpotColor(this, name, C, M, Y, K); + this.spotColors[name] = color; + return this; + } +}; +var namedColors = { + aliceblue: [240, 248, 255], + antiquewhite: [250, 235, 215], + aqua: [0, 255, 255], + aquamarine: [127, 255, 212], + azure: [240, 255, 255], + beige: [245, 245, 220], + bisque: [255, 228, 196], + black: [0, 0, 0], + blanchedalmond: [255, 235, 205], + blue: [0, 0, 255], + blueviolet: [138, 43, 226], + brown: [165, 42, 42], + burlywood: [222, 184, 135], + cadetblue: [95, 158, 160], + chartreuse: [127, 255, 0], + chocolate: [210, 105, 30], + coral: [255, 127, 80], + cornflowerblue: [100, 149, 237], + cornsilk: [255, 248, 220], + crimson: [220, 20, 60], + cyan: [0, 255, 255], + darkblue: [0, 0, 139], + darkcyan: [0, 139, 139], + darkgoldenrod: [184, 134, 11], + darkgray: [169, 169, 169], + darkgreen: [0, 100, 0], + darkgrey: [169, 169, 169], + darkkhaki: [189, 183, 107], + darkmagenta: [139, 0, 139], + darkolivegreen: [85, 107, 47], + darkorange: [255, 140, 0], + darkorchid: [153, 50, 204], + darkred: [139, 0, 0], + darksalmon: [233, 150, 122], + darkseagreen: [143, 188, 143], + darkslateblue: [72, 61, 139], + darkslategray: [47, 79, 79], + darkslategrey: [47, 79, 79], + darkturquoise: [0, 206, 209], + darkviolet: [148, 0, 211], + deeppink: [255, 20, 147], + deepskyblue: [0, 191, 255], + dimgray: [105, 105, 105], + dimgrey: [105, 105, 105], + dodgerblue: [30, 144, 255], + firebrick: [178, 34, 34], + floralwhite: [255, 250, 240], + forestgreen: [34, 139, 34], + fuchsia: [255, 0, 255], + gainsboro: [220, 220, 220], + ghostwhite: [248, 248, 255], + gold: [255, 215, 0], + goldenrod: [218, 165, 32], + gray: [128, 128, 128], + grey: [128, 128, 128], + green: [0, 128, 0], + greenyellow: [173, 255, 47], + honeydew: [240, 255, 240], + hotpink: [255, 105, 180], + indianred: [205, 92, 92], + indigo: [75, 0, 130], + ivory: [255, 255, 240], + khaki: [240, 230, 140], + lavender: [230, 230, 250], + lavenderblush: [255, 240, 245], + lawngreen: [124, 252, 0], + lemonchiffon: [255, 250, 205], + lightblue: [173, 216, 230], + lightcoral: [240, 128, 128], + lightcyan: [224, 255, 255], + lightgoldenrodyellow: [250, 250, 210], + lightgray: [211, 211, 211], + lightgreen: [144, 238, 144], + lightgrey: [211, 211, 211], + lightpink: [255, 182, 193], + lightsalmon: [255, 160, 122], + lightseagreen: [32, 178, 170], + lightskyblue: [135, 206, 250], + lightslategray: [119, 136, 153], + lightslategrey: [119, 136, 153], + lightsteelblue: [176, 196, 222], + lightyellow: [255, 255, 224], + lime: [0, 255, 0], + limegreen: [50, 205, 50], + linen: [250, 240, 230], + magenta: [255, 0, 255], + maroon: [128, 0, 0], + mediumaquamarine: [102, 205, 170], + mediumblue: [0, 0, 205], + mediumorchid: [186, 85, 211], + mediumpurple: [147, 112, 219], + mediumseagreen: [60, 179, 113], + mediumslateblue: [123, 104, 238], + mediumspringgreen: [0, 250, 154], + mediumturquoise: [72, 209, 204], + mediumvioletred: [199, 21, 133], + midnightblue: [25, 25, 112], + mintcream: [245, 255, 250], + mistyrose: [255, 228, 225], + moccasin: [255, 228, 181], + navajowhite: [255, 222, 173], + navy: [0, 0, 128], + oldlace: [253, 245, 230], + olive: [128, 128, 0], + olivedrab: [107, 142, 35], + orange: [255, 165, 0], + orangered: [255, 69, 0], + orchid: [218, 112, 214], + palegoldenrod: [238, 232, 170], + palegreen: [152, 251, 152], + paleturquoise: [175, 238, 238], + palevioletred: [219, 112, 147], + papayawhip: [255, 239, 213], + peachpuff: [255, 218, 185], + peru: [205, 133, 63], + pink: [255, 192, 203], + plum: [221, 160, 221], + powderblue: [176, 224, 230], + purple: [128, 0, 128], + red: [255, 0, 0], + rosybrown: [188, 143, 143], + royalblue: [65, 105, 225], + saddlebrown: [139, 69, 19], + salmon: [250, 128, 114], + sandybrown: [244, 164, 96], + seagreen: [46, 139, 87], + seashell: [255, 245, 238], + sienna: [160, 82, 45], + silver: [192, 192, 192], + skyblue: [135, 206, 235], + slateblue: [106, 90, 205], + slategray: [112, 128, 144], + slategrey: [112, 128, 144], + snow: [255, 250, 250], + springgreen: [0, 255, 127], + steelblue: [70, 130, 180], + tan: [210, 180, 140], + teal: [0, 128, 128], + thistle: [216, 191, 216], + tomato: [255, 99, 71], + turquoise: [64, 224, 208], + violet: [238, 130, 238], + wheat: [245, 222, 179], + white: [255, 255, 255], + whitesmoke: [245, 245, 245], + yellow: [255, 255, 0], + yellowgreen: [154, 205, 50] +}; + +let cx; +let cy; +let px; +let py; +let sx; +let sy; +cx = cy = px = py = sx = sy = 0; + +// parseDataPath copy pasted from svgo +// https://github.com/svg/svgo/blob/e4918ccdd1a2b5831defe0f00c1286744b479448/lib/path.js + +/** + * @typedef {'M' | 'm' | 'Z' | 'z' | 'L' | 'l' | 'H' | 'h' | 'V' | 'v' | 'C' | 'c' | 'S' | 's' | 'Q' | 'q' | 'T' | 't' | 'A' | 'a'} PathDataCommand + */ + +/** + * @typedef {Object} PathDataItem + * @property {PathDataCommand} command + * @property {number[]} args + */ + +const argsCountPerCommand = { + M: 2, + m: 2, + Z: 0, + z: 0, + L: 2, + l: 2, + H: 1, + h: 1, + V: 1, + v: 1, + C: 6, + c: 6, + S: 4, + s: 4, + Q: 4, + q: 4, + T: 2, + t: 2, + A: 7, + a: 7 +}; + +/** + * @type {(c: string) => c is PathDataCommand} + */ +const isCommand = c => { + return c in argsCountPerCommand; +}; + +/** + * @type {(c: string) => boolean} + */ +const isWsp = c => { + const codePoint = c.codePointAt(0); + return codePoint === 0x20 || codePoint === 0x9 || codePoint === 0xd || codePoint === 0xa; +}; + +/** + * @type {(c: string) => boolean} + */ +const isDigit = c => { + const codePoint = c.codePointAt(0); + if (codePoint == null) { + return false; + } + return 48 <= codePoint && codePoint <= 57; +}; + +/** + * @typedef {'none' | 'sign' | 'whole' | 'decimal_point' | 'decimal' | 'e' | 'exponent_sign' | 'exponent'} ReadNumberState + */ + +/** + * @type {(string: string, cursor: number) => [number, number | null]} + */ +const readNumber = (string, cursor) => { + let i = cursor; + let value = ''; + let state = /** @type {ReadNumberState} */'none'; + for (; i < string.length; i += 1) { + const c = string[i]; + if (c === '+' || c === '-') { + if (state === 'none') { + state = 'sign'; + value += c; + continue; + } + if (state === 'e') { + state = 'exponent_sign'; + value += c; + continue; + } + } + if (isDigit(c)) { + if (state === 'none' || state === 'sign' || state === 'whole') { + state = 'whole'; + value += c; + continue; + } + if (state === 'decimal_point' || state === 'decimal') { + state = 'decimal'; + value += c; + continue; + } + if (state === 'e' || state === 'exponent_sign' || state === 'exponent') { + state = 'exponent'; + value += c; + continue; + } + } + if (c === '.') { + if (state === 'none' || state === 'sign' || state === 'whole') { + state = 'decimal_point'; + value += c; + continue; + } + } + if (c === 'E' || c === 'e') { + if (state === 'whole' || state === 'decimal_point' || state === 'decimal') { + state = 'e'; + value += c; + continue; + } + } + break; + } + const number = Number.parseFloat(value); + if (Number.isNaN(number)) { + return [cursor, null]; + } + // step back to delegate iteration to parent loop + return [i - 1, number]; +}; + +/** + * @type {(string: string) => Array} + */ +const parsePathData = string => { + /** + * @type {Array} + */ + const pathData = []; + /** + * @type {null | PathDataCommand} + */ + let command = null; + let args = /** @type {number[]} */[]; + let argsCount = 0; + let canHaveComma = false; + let hadComma = false; + for (let i = 0; i < string.length; i += 1) { + const c = string.charAt(i); + if (isWsp(c)) { + continue; + } + // allow comma only between arguments + if (canHaveComma && c === ',') { + if (hadComma) { + break; + } + hadComma = true; + continue; + } + if (isCommand(c)) { + if (hadComma) { + return pathData; + } + if (command == null) { + // moveto should be leading command + if (c !== 'M' && c !== 'm') { + return pathData; + } + } else { + // stop if previous command arguments are not flushed + if (args.length !== 0) { + return pathData; + } + } + command = c; + args = []; + argsCount = argsCountPerCommand[command]; + canHaveComma = false; + // flush command without arguments + if (argsCount === 0) { + pathData.push({ + command, + args + }); + } + continue; + } + // avoid parsing arguments if no command detected + if (command == null) { + return pathData; + } + // read next argument + let newCursor = i; + let number = null; + if (command === 'A' || command === 'a') { + const position = args.length; + if (position === 0 || position === 1) { + // allow only positive number without sign as first two arguments + if (c !== '+' && c !== '-') { + [newCursor, number] = readNumber(string, i); + } + } + if (position === 2 || position === 5 || position === 6) { + [newCursor, number] = readNumber(string, i); + } + if (position === 3 || position === 4) { + // read flags + if (c === '0') { + number = 0; + } + if (c === '1') { + number = 1; + } + } + } else { + [newCursor, number] = readNumber(string, i); + } + if (number == null) { + return pathData; + } + args.push(number); + canHaveComma = true; + hadComma = false; + i = newCursor; + // flush arguments when necessary count is reached + if (args.length === argsCount) { + pathData.push({ + command, + args + }); + // subsequent moveto coordinates are threated as implicit lineto commands + if (command === 'M') { + command = 'L'; + } + if (command === 'm') { + command = 'l'; + } + args = []; + } + } + return pathData; +}; +const apply = function (commands, doc) { + // current point, control point, and subpath starting point + cx = cy = px = py = sx = sy = 0; + + // run the commands + for (let i = 0; i < commands.length; i++) { + const { + command, + args + } = commands[i]; + if (typeof runners[command] === 'function') { + runners[command](doc, args); + } + } +}; +const runners = { + M(doc, a) { + cx = a[0]; + cy = a[1]; + px = py = null; + sx = cx; + sy = cy; + return doc.moveTo(cx, cy); + }, + m(doc, a) { + cx += a[0]; + cy += a[1]; + px = py = null; + sx = cx; + sy = cy; + return doc.moveTo(cx, cy); + }, + C(doc, a) { + cx = a[4]; + cy = a[5]; + px = a[2]; + py = a[3]; + return doc.bezierCurveTo(...a); + }, + c(doc, a) { + doc.bezierCurveTo(a[0] + cx, a[1] + cy, a[2] + cx, a[3] + cy, a[4] + cx, a[5] + cy); + px = cx + a[2]; + py = cy + a[3]; + cx += a[4]; + return cy += a[5]; + }, + S(doc, a) { + if (px === null) { + px = cx; + py = cy; + } + doc.bezierCurveTo(cx - (px - cx), cy - (py - cy), a[0], a[1], a[2], a[3]); + px = a[0]; + py = a[1]; + cx = a[2]; + return cy = a[3]; + }, + s(doc, a) { + if (px === null) { + px = cx; + py = cy; + } + doc.bezierCurveTo(cx - (px - cx), cy - (py - cy), cx + a[0], cy + a[1], cx + a[2], cy + a[3]); + px = cx + a[0]; + py = cy + a[1]; + cx += a[2]; + return cy += a[3]; + }, + Q(doc, a) { + px = a[0]; + py = a[1]; + cx = a[2]; + cy = a[3]; + return doc.quadraticCurveTo(a[0], a[1], cx, cy); + }, + q(doc, a) { + doc.quadraticCurveTo(a[0] + cx, a[1] + cy, a[2] + cx, a[3] + cy); + px = cx + a[0]; + py = cy + a[1]; + cx += a[2]; + return cy += a[3]; + }, + T(doc, a) { + if (px === null) { + px = cx; + py = cy; + } else { + px = cx - (px - cx); + py = cy - (py - cy); + } + doc.quadraticCurveTo(px, py, a[0], a[1]); + cx = a[0]; + return cy = a[1]; + }, + t(doc, a) { + if (px === null) { + px = cx; + py = cy; + } else { + px = cx - (px - cx); + py = cy - (py - cy); + } + doc.quadraticCurveTo(px, py, cx + a[0], cy + a[1]); + cx += a[0]; + return cy += a[1]; + }, + A(doc, a) { + solveArc(doc, cx, cy, a); + cx = a[5]; + return cy = a[6]; + }, + a(doc, a) { + a[5] += cx; + a[6] += cy; + solveArc(doc, cx, cy, a); + cx = a[5]; + return cy = a[6]; + }, + L(doc, a) { + cx = a[0]; + cy = a[1]; + px = py = null; + return doc.lineTo(cx, cy); + }, + l(doc, a) { + cx += a[0]; + cy += a[1]; + px = py = null; + return doc.lineTo(cx, cy); + }, + H(doc, a) { + cx = a[0]; + px = py = null; + return doc.lineTo(cx, cy); + }, + h(doc, a) { + cx += a[0]; + px = py = null; + return doc.lineTo(cx, cy); + }, + V(doc, a) { + cy = a[0]; + px = py = null; + return doc.lineTo(cx, cy); + }, + v(doc, a) { + cy += a[0]; + px = py = null; + return doc.lineTo(cx, cy); + }, + Z(doc) { + doc.closePath(); + cx = sx; + return cy = sy; + }, + z(doc) { + doc.closePath(); + cx = sx; + return cy = sy; + } +}; +const solveArc = function (doc, x, y, coords) { + const [rx, ry, rot, large, sweep, ex, ey] = coords; + const segs = arcToSegments(ex, ey, rx, ry, large, sweep, rot, x, y); + for (let seg of segs) { + const bez = segmentToBezier(...seg); + doc.bezierCurveTo(...bez); + } +}; + +// from Inkscape svgtopdf, thanks! +const arcToSegments = function (x, y, rx, ry, large, sweep, rotateX, ox, oy) { + const th = rotateX * (Math.PI / 180); + const sin_th = Math.sin(th); + const cos_th = Math.cos(th); + rx = Math.abs(rx); + ry = Math.abs(ry); + px = cos_th * (ox - x) * 0.5 + sin_th * (oy - y) * 0.5; + py = cos_th * (oy - y) * 0.5 - sin_th * (ox - x) * 0.5; + let pl = px * px / (rx * rx) + py * py / (ry * ry); + if (pl > 1) { + pl = Math.sqrt(pl); + rx *= pl; + ry *= pl; + } + const a00 = cos_th / rx; + const a01 = sin_th / rx; + const a10 = -sin_th / ry; + const a11 = cos_th / ry; + const x0 = a00 * ox + a01 * oy; + const y0 = a10 * ox + a11 * oy; + const x1 = a00 * x + a01 * y; + const y1 = a10 * x + a11 * y; + const d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0); + let sfactor_sq = 1 / d - 0.25; + if (sfactor_sq < 0) { + sfactor_sq = 0; + } + let sfactor = Math.sqrt(sfactor_sq); + if (sweep === large) { + sfactor = -sfactor; + } + const xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0); + const yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0); + const th0 = Math.atan2(y0 - yc, x0 - xc); + const th1 = Math.atan2(y1 - yc, x1 - xc); + let th_arc = th1 - th0; + if (th_arc < 0 && sweep === 1) { + th_arc += 2 * Math.PI; + } else if (th_arc > 0 && sweep === 0) { + th_arc -= 2 * Math.PI; + } + const segments = Math.ceil(Math.abs(th_arc / (Math.PI * 0.5 + 0.001))); + const result = []; + for (let i = 0; i < segments; i++) { + const th2 = th0 + i * th_arc / segments; + const th3 = th0 + (i + 1) * th_arc / segments; + result[i] = [xc, yc, th2, th3, rx, ry, sin_th, cos_th]; + } + return result; +}; +const segmentToBezier = function (cx, cy, th0, th1, rx, ry, sin_th, cos_th) { + const a00 = cos_th * rx; + const a01 = -sin_th * ry; + const a10 = sin_th * rx; + const a11 = cos_th * ry; + const th_half = 0.5 * (th1 - th0); + const t = 8 / 3 * Math.sin(th_half * 0.5) * Math.sin(th_half * 0.5) / Math.sin(th_half); + const x1 = cx + Math.cos(th0) - t * Math.sin(th0); + const y1 = cy + Math.sin(th0) + t * Math.cos(th0); + const x3 = cx + Math.cos(th1); + const y3 = cy + Math.sin(th1); + const x2 = x3 + t * Math.sin(th1); + const y2 = y3 - t * Math.cos(th1); + return [a00 * x1 + a01 * y1, a10 * x1 + a11 * y1, a00 * x2 + a01 * y2, a10 * x2 + a11 * y2, a00 * x3 + a01 * y3, a10 * x3 + a11 * y3]; +}; +class SVGPath { + static apply(doc, path) { + const commands = parsePathData(path); + apply(commands, doc); + } +} + +const { + number: number$1 +} = PDFObject; + +// This constant is used to approximate a symmetrical arc using a cubic +// Bezier curve. +const KAPPA = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0); +var VectorMixin = { + initVector() { + this._ctm = [1, 0, 0, 1, 0, 0]; // current transformation matrix + return this._ctmStack = []; + }, + save() { + this._ctmStack.push(this._ctm.slice()); + // TODO: save/restore colorspace and styles so not setting it unnessesarily all the time? + return this.addContent('q'); + }, + restore() { + this._ctm = this._ctmStack.pop() || [1, 0, 0, 1, 0, 0]; + return this.addContent('Q'); + }, + closePath() { + return this.addContent('h'); + }, + lineWidth(w) { + return this.addContent(`${number$1(w)} w`); + }, + _CAP_STYLES: { + BUTT: 0, + ROUND: 1, + SQUARE: 2 + }, + lineCap(c) { + if (typeof c === 'string') { + c = this._CAP_STYLES[c.toUpperCase()]; + } + return this.addContent(`${c} J`); + }, + _JOIN_STYLES: { + MITER: 0, + ROUND: 1, + BEVEL: 2 + }, + lineJoin(j) { + if (typeof j === 'string') { + j = this._JOIN_STYLES[j.toUpperCase()]; + } + return this.addContent(`${j} j`); + }, + miterLimit(m) { + return this.addContent(`${number$1(m)} M`); + }, + dash(length, options) { + if (options === void 0) { + options = {}; + } + const originalLength = length; + if (!Array.isArray(length)) { + length = [length, options.space || length]; + } + const valid = length.every(x => Number.isFinite(x) && x > 0); + if (!valid) { + throw new Error(`dash(${JSON.stringify(originalLength)}, ${JSON.stringify(options)}) invalid, lengths must be numeric and greater than zero`); + } + length = length.map(number$1).join(' '); + return this.addContent(`[${length}] ${number$1(options.phase || 0)} d`); + }, + undash() { + return this.addContent('[] 0 d'); + }, + moveTo(x, y) { + return this.addContent(`${number$1(x)} ${number$1(y)} m`); + }, + lineTo(x, y) { + return this.addContent(`${number$1(x)} ${number$1(y)} l`); + }, + bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) { + return this.addContent(`${number$1(cp1x)} ${number$1(cp1y)} ${number$1(cp2x)} ${number$1(cp2y)} ${number$1(x)} ${number$1(y)} c`); + }, + quadraticCurveTo(cpx, cpy, x, y) { + return this.addContent(`${number$1(cpx)} ${number$1(cpy)} ${number$1(x)} ${number$1(y)} v`); + }, + rect(x, y, w, h) { + return this.addContent(`${number$1(x)} ${number$1(y)} ${number$1(w)} ${number$1(h)} re`); + }, + roundedRect(x, y, w, h, r) { + if (r == null) { + r = 0; + } + r = Math.min(r, 0.5 * w, 0.5 * h); + + // amount to inset control points from corners (see `ellipse`) + const c = r * (1.0 - KAPPA); + this.moveTo(x + r, y); + this.lineTo(x + w - r, y); + this.bezierCurveTo(x + w - c, y, x + w, y + c, x + w, y + r); + this.lineTo(x + w, y + h - r); + this.bezierCurveTo(x + w, y + h - c, x + w - c, y + h, x + w - r, y + h); + this.lineTo(x + r, y + h); + this.bezierCurveTo(x + c, y + h, x, y + h - c, x, y + h - r); + this.lineTo(x, y + r); + this.bezierCurveTo(x, y + c, x + c, y, x + r, y); + return this.closePath(); + }, + ellipse(x, y, r1, r2) { + // based on http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas/2173084#2173084 + if (r2 == null) { + r2 = r1; + } + x -= r1; + y -= r2; + const ox = r1 * KAPPA; + const oy = r2 * KAPPA; + const xe = x + r1 * 2; + const ye = y + r2 * 2; + const xm = x + r1; + const ym = y + r2; + this.moveTo(x, ym); + this.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y); + this.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym); + this.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye); + this.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym); + return this.closePath(); + }, + circle(x, y, radius) { + return this.ellipse(x, y, radius); + }, + arc(x, y, radius, startAngle, endAngle, anticlockwise) { + if (anticlockwise == null) { + anticlockwise = false; + } + const TWO_PI = 2.0 * Math.PI; + const HALF_PI = 0.5 * Math.PI; + let deltaAng = endAngle - startAngle; + if (Math.abs(deltaAng) > TWO_PI) { + // draw only full circle if more than that is specified + deltaAng = TWO_PI; + } else if (deltaAng !== 0 && anticlockwise !== deltaAng < 0) { + // necessary to flip direction of rendering + const dir = anticlockwise ? -1 : 1; + deltaAng = dir * TWO_PI + deltaAng; + } + const numSegs = Math.ceil(Math.abs(deltaAng) / HALF_PI); + const segAng = deltaAng / numSegs; + const handleLen = segAng / HALF_PI * KAPPA * radius; + let curAng = startAngle; + + // component distances between anchor point and control point + let deltaCx = -Math.sin(curAng) * handleLen; + let deltaCy = Math.cos(curAng) * handleLen; + + // anchor point + let ax = x + Math.cos(curAng) * radius; + let ay = y + Math.sin(curAng) * radius; + + // calculate and render segments + this.moveTo(ax, ay); + for (let segIdx = 0; segIdx < numSegs; segIdx++) { + // starting control point + const cp1x = ax + deltaCx; + const cp1y = ay + deltaCy; + + // step angle + curAng += segAng; + + // next anchor point + ax = x + Math.cos(curAng) * radius; + ay = y + Math.sin(curAng) * radius; + + // next control point delta + deltaCx = -Math.sin(curAng) * handleLen; + deltaCy = Math.cos(curAng) * handleLen; + + // ending control point + const cp2x = ax - deltaCx; + const cp2y = ay - deltaCy; + + // render segment + this.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, ax, ay); + } + return this; + }, + polygon() { + for (var _len = arguments.length, points = new Array(_len), _key = 0; _key < _len; _key++) { + points[_key] = arguments[_key]; + } + this.moveTo(...(points.shift() || [])); + for (let point of points) { + this.lineTo(...(point || [])); + } + return this.closePath(); + }, + path(path) { + SVGPath.apply(this, path); + return this; + }, + _windingRule(rule) { + if (/even-?odd/.test(rule)) { + return '*'; + } + return ''; + }, + fill(color, rule) { + if (/(even-?odd)|(non-?zero)/.test(color)) { + rule = color; + color = null; + } + if (color) { + this.fillColor(color); + } + return this.addContent(`f${this._windingRule(rule)}`); + }, + stroke(color) { + if (color) { + this.strokeColor(color); + } + return this.addContent('S'); + }, + fillAndStroke(fillColor, strokeColor, rule) { + if (strokeColor == null) { + strokeColor = fillColor; + } + const isFillRule = /(even-?odd)|(non-?zero)/; + if (isFillRule.test(fillColor)) { + rule = fillColor; + fillColor = null; + } + if (isFillRule.test(strokeColor)) { + rule = strokeColor; + strokeColor = fillColor; + } + if (fillColor) { + this.fillColor(fillColor); + this.strokeColor(strokeColor); + } + return this.addContent(`B${this._windingRule(rule)}`); + }, + clip(rule) { + return this.addContent(`W${this._windingRule(rule)} n`); + }, + transform(m11, m12, m21, m22, dx, dy) { + // keep track of the current transformation matrix + if (m11 === 1 && m12 === 0 && m21 === 0 && m22 === 1 && dx === 0 && dy === 0) { + // Ignore identity transforms + return this; + } + const m = this._ctm; + const [m0, m1, m2, m3, m4, m5] = m; + m[0] = m0 * m11 + m2 * m12; + m[1] = m1 * m11 + m3 * m12; + m[2] = m0 * m21 + m2 * m22; + m[3] = m1 * m21 + m3 * m22; + m[4] = m0 * dx + m2 * dy + m4; + m[5] = m1 * dx + m3 * dy + m5; + const values = [m11, m12, m21, m22, dx, dy].map(v => number$1(v)).join(' '); + return this.addContent(`${values} cm`); + }, + translate(x, y) { + return this.transform(1, 0, 0, 1, x, y); + }, + rotate(angle, options) { + if (options === void 0) { + options = {}; + } + let y; + const rad = angle * Math.PI / 180; + const cos = Math.cos(rad); + const sin = Math.sin(rad); + let x = y = 0; + if (options.origin != null) { + [x, y] = options.origin; + const x1 = x * cos - y * sin; + const y1 = x * sin + y * cos; + x -= x1; + y -= y1; + } + return this.transform(cos, sin, -sin, cos, x, y); + }, + scale(xFactor, yFactor, options) { + if (options === void 0) { + options = {}; + } + let y; + if (yFactor == null) { + yFactor = xFactor; + } + if (typeof yFactor === 'object') { + options = yFactor; + yFactor = xFactor; + } + let x = y = 0; + if (options.origin != null) { + [x, y] = options.origin; + x -= xFactor * x; + y -= yFactor * y; + } + return this.transform(xFactor, 0, 0, yFactor, x, y); + } +}; + +var fs = {}; + +const range = (left, right, inclusive) => { + let range = []; + let end = right + 1 ; + for (let i = left; i < end ; i++ ) { + range.push(i); + } + return range; +}; + +const WIN_ANSI_MAP = { + 402: 131, + 8211: 150, + 8212: 151, + 8216: 145, + 8217: 146, + 8218: 130, + 8220: 147, + 8221: 148, + 8222: 132, + 8224: 134, + 8225: 135, + 8226: 149, + 8230: 133, + 8364: 128, + 8240: 137, + 8249: 139, + 8250: 155, + 710: 136, + 8482: 153, + 338: 140, + 339: 156, + 732: 152, + 352: 138, + 353: 154, + 376: 159, + 381: 142, + 382: 158 +}; +const characters = `\ +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef + +space exclam quotedbl numbersign +dollar percent ampersand quotesingle +parenleft parenright asterisk plus +comma hyphen period slash +zero one two three +four five six seven +eight nine colon semicolon +less equal greater question + +at A B C +D E F G +H I J K +L M N O +P Q R S +T U V W +X Y Z bracketleft +backslash bracketright asciicircum underscore + +grave a b c +d e f g +h i j k +l m n o +p q r s +t u v w +x y z braceleft +bar braceright asciitilde .notdef + +Euro .notdef quotesinglbase florin +quotedblbase ellipsis dagger daggerdbl +circumflex perthousand Scaron guilsinglleft +OE .notdef Zcaron .notdef +.notdef quoteleft quoteright quotedblleft +quotedblright bullet endash emdash +tilde trademark scaron guilsinglright +oe .notdef zcaron ydieresis + +space exclamdown cent sterling +currency yen brokenbar section +dieresis copyright ordfeminine guillemotleft +logicalnot softhyphen registered macron +degree plusminus twosuperior threesuperior +acute mu paragraph periodcentered +cedilla onesuperior ordmasculine guillemotright +onequarter onehalf threequarters questiondown + +Agrave Aacute Acircumflex Atilde +Adieresis Aring AE Ccedilla +Egrave Eacute Ecircumflex Edieresis +Igrave Iacute Icircumflex Idieresis +Eth Ntilde Ograve Oacute +Ocircumflex Otilde Odieresis multiply +Oslash Ugrave Uacute Ucircumflex +Udieresis Yacute Thorn germandbls + +agrave aacute acircumflex atilde +adieresis aring ae ccedilla +egrave eacute ecircumflex edieresis +igrave iacute icircumflex idieresis +eth ntilde ograve oacute +ocircumflex otilde odieresis divide +oslash ugrave uacute ucircumflex +udieresis yacute thorn ydieresis\ +`.split(/\s+/); +function parse(contents) { + const obj = { + attributes: {}, + glyphWidths: {}, + kernPairs: {} + }; + let section = ''; + for (let line of contents.split('\n')) { + var match; + var a; + if (match = line.match(/^Start(\w+)/)) { + section = match[1]; + continue; + } else if (match = line.match(/^End(\w+)/)) { + section = ''; + continue; + } + switch (section) { + case 'FontMetrics': + match = line.match(/(^\w+)\s+(.*)/); + var key = match[1]; + var value = match[2]; + if (a = obj.attributes[key]) { + if (!Array.isArray(a)) { + a = obj.attributes[key] = [a]; + } + a.push(value); + } else { + obj.attributes[key] = value; + } + break; + case 'CharMetrics': + if (!/^CH?\s/.test(line)) { + continue; + } + var name = line.match(/\bN\s+(\.?\w+)\s*;/)[1]; + obj.glyphWidths[name] = +line.match(/\bWX\s+(\d+)\s*;/)[1]; + break; + case 'KernPairs': + match = line.match(/^KPX\s+(\.?\w+)\s+(\.?\w+)\s+(-?\d+)/); + if (match) { + obj.kernPairs[match[1] + match[2]] = parseInt(match[3]); + } + break; + } + } + return obj; +} +class AFMFont { + static open(filename) { + { + throw new Error('AFMFont.open not available on browser build'); + } + } + static fromJson(json) { + return new AFMFont(json); + } + constructor(contents) { + if (typeof contents === 'string') { + this.contents = contents; + this.parse(); + } else { + this.attributes = contents.attributes; + this.glyphWidths = contents.glyphWidths; + this.kernPairs = contents.kernPairs; + } + this.charWidths = range(0, 255).map(i => this.glyphWidths[characters[i]]); + this.bbox = Array.from(this.attributes.FontBBox.split(/\s+/)).map(e => +e); + this.ascender = +(this.attributes.Ascender || 0); + this.descender = +(this.attributes.Descender || 0); + this.xHeight = +(this.attributes.XHeight || 0); + this.capHeight = +(this.attributes.CapHeight || 0); + this.lineGap = this.bbox[3] - this.bbox[1] - (this.ascender - this.descender); + } + parse() { + const parsed = parse(this.contents); + this.attributes = parsed.attributes; + this.glyphWidths = parsed.glyphWidths; + this.kernPairs = parsed.kernPairs; + } + encodeText(text) { + const res = []; + for (let i = 0, end = text.length, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { + let char = text.charCodeAt(i); + char = WIN_ANSI_MAP[char] || char; + res.push(char.toString(16)); + } + return res; + } + glyphsForString(string) { + const glyphs = []; + for (let i = 0, end = string.length, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { + const charCode = string.charCodeAt(i); + glyphs.push(this.characterToGlyph(charCode)); + } + return glyphs; + } + characterToGlyph(character) { + return characters[WIN_ANSI_MAP[character] || character] || '.notdef'; + } + widthOfGlyph(glyph) { + return this.glyphWidths[glyph] || 0; + } + getKernPair(left, right) { + return this.kernPairs[left + right] || 0; + } + advancesForGlyphs(glyphs) { + const advances = []; + for (let index = 0; index < glyphs.length; index++) { + const left = glyphs[index]; + const right = glyphs[index + 1]; + advances.push(this.widthOfGlyph(left) + this.getKernPair(left, right)); + } + return advances; + } +} + +var attributes = [ + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:43:52 1997", + "UniqueID 43052", + "VMusage 37169 48194" + ], + FontName: "Helvetica-Bold", + FullName: "Helvetica Bold", + FamilyName: "Helvetica", + Weight: "Bold", + ItalicAngle: "0", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-170 -228 1003 962 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "718", + XHeight: "532", + Ascender: "718", + Descender: "-207", + StdHW: "118", + StdVW: "140" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:45:12 1997", + "UniqueID 43053", + "VMusage 14482 68586" + ], + FontName: "Helvetica-BoldOblique", + FullName: "Helvetica Bold Oblique", + FamilyName: "Helvetica", + Weight: "Bold", + ItalicAngle: "-12", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-174 -228 1114 962", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "718", + XHeight: "532", + Ascender: "718", + Descender: "-207", + StdHW: "118", + StdVW: "140" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:44:31 1997", + "UniqueID 43055", + "VMusage 14960 69346" + ], + FontName: "Helvetica-Oblique", + FullName: "Helvetica Oblique", + FamilyName: "Helvetica", + Weight: "Medium", + ItalicAngle: "-12", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-170 -225 1116 931 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "718", + XHeight: "523", + Ascender: "718", + Descender: "-207", + StdHW: "76", + StdVW: "88" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:38:23 1997", + "UniqueID 43054", + "VMusage 37069 48094" + ], + FontName: "Helvetica", + FullName: "Helvetica", + FamilyName: "Helvetica", + Weight: "Medium", + ItalicAngle: "0", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-166 -225 1000 931 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "718", + XHeight: "523", + Ascender: "718", + Descender: "-207", + StdHW: "76", + StdVW: "88" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:52:56 1997", + "UniqueID 43065", + "VMusage 41636 52661" + ], + FontName: "Times-Bold", + FullName: "Times Bold", + FamilyName: "Times", + Weight: "Bold", + ItalicAngle: "0", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-168 -218 1000 935 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "676", + XHeight: "461", + Ascender: "683", + Descender: "-217", + StdHW: "44", + StdVW: "139" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 13:04:06 1997", + "UniqueID 43066", + "VMusage 45874 56899" + ], + FontName: "Times-BoldItalic", + FullName: "Times Bold Italic", + FamilyName: "Times", + Weight: "Bold", + ItalicAngle: "-15", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-200 -218 996 921", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "669", + XHeight: "462", + Ascender: "683", + Descender: "-217", + StdHW: "42", + StdVW: "121" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:56:55 1997", + "UniqueID 43067", + "VMusage 47727 58752" + ], + FontName: "Times-Italic", + FullName: "Times Italic", + FamilyName: "Times", + Weight: "Medium", + ItalicAngle: "-15.5", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-169 -217 1010 883 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "653", + XHeight: "441", + Ascender: "683", + Descender: "-217", + StdHW: "32", + StdVW: "76" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:49:17 1997", + "UniqueID 43068", + "VMusage 43909 54934" + ], + FontName: "Times-Roman", + FullName: "Times Roman", + FamilyName: "Times", + Weight: "Roman", + ItalicAngle: "0", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-168 -218 1000 898 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "662", + XHeight: "450", + Ascender: "683", + Descender: "-217", + StdHW: "28", + StdVW: "84" + }, + { + Comment: [ + "Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Mon Jun 23 16:28:00 1997", + "UniqueID 43048", + "VMusage 41139 52164" + ], + FontName: "Courier-Bold", + FullName: "Courier Bold", + FamilyName: "Courier", + Weight: "Bold", + ItalicAngle: "0", + IsFixedPitch: "true", + CharacterSet: "ExtendedRoman", + FontBBox: "-113 -250 749 801 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "003.000", + Notice: "Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "562", + XHeight: "439", + Ascender: "629", + Descender: "-157", + StdHW: "84", + StdVW: "106" + }, + { + Comment: [ + "Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Mon Jun 23 16:28:46 1997", + "UniqueID 43049", + "VMusage 17529 79244" + ], + FontName: "Courier-BoldOblique", + FullName: "Courier Bold Oblique", + FamilyName: "Courier", + Weight: "Bold", + ItalicAngle: "-12", + IsFixedPitch: "true", + CharacterSet: "ExtendedRoman", + FontBBox: "-57 -250 869 801", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "003.000", + Notice: "Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "562", + XHeight: "439", + Ascender: "629", + Descender: "-157", + StdHW: "84", + StdVW: "106" + }, + { + Comment: [ + "Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 17:37:52 1997", + "UniqueID 43051", + "VMusage 16248 75829" + ], + FontName: "Courier-Oblique", + FullName: "Courier Oblique", + FamilyName: "Courier", + Weight: "Medium", + ItalicAngle: "-12", + IsFixedPitch: "true", + CharacterSet: "ExtendedRoman", + FontBBox: "-27 -250 849 805 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "003.000", + Notice: "Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "562", + XHeight: "426", + Ascender: "629", + Descender: "-157", + StdHW: "51", + StdVW: "51" + }, + { + Comment: [ + "Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 17:27:09 1997", + "UniqueID 43050", + "VMusage 39754 50779" + ], + FontName: "Courier", + FullName: "Courier", + FamilyName: "Courier", + Weight: "Medium", + ItalicAngle: "0", + IsFixedPitch: "true", + CharacterSet: "ExtendedRoman", + FontBBox: "-23 -250 715 805 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "003.000", + Notice: "Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "562", + XHeight: "426", + Ascender: "629", + Descender: "-157", + StdHW: "51", + StdVW: "51" + } +]; +var glyphWidths = { + space: [ + 278, + 278, + 278, + 278, + 250, + 250, + 250, + 250, + 600, + 600, + 600, + 600 + ], + exclam: [ + 333, + 333, + 278, + 278, + 333, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + quotedbl: [ + 474, + 474, + 355, + 355, + 555, + 555, + 420, + 408, + 600, + 600, + 600, + 600 + ], + numbersign: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + dollar: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + percent: [ + 889, + 889, + 889, + 889, + 1000, + 833, + 833, + 833, + 600, + 600, + 600, + 600 + ], + ampersand: [ + 722, + 722, + 667, + 667, + 833, + 778, + 778, + 778, + 600, + 600, + 600, + 600 + ], + quoteright: [ + 278, + 278, + 222, + 222, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + parenleft: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + parenright: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + asterisk: [ + 389, + 389, + 389, + 389, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + plus: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + comma: [ + 278, + 278, + 278, + 278, + 250, + 250, + 250, + 250, + 600, + 600, + 600, + 600 + ], + hyphen: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + period: [ + 278, + 278, + 278, + 278, + 250, + 250, + 250, + 250, + 600, + 600, + 600, + 600 + ], + slash: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + zero: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + one: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + two: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + three: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + four: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + five: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + six: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + seven: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + eight: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + nine: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + colon: [ + 333, + 333, + 278, + 278, + 333, + 333, + 333, + 278, + 600, + 600, + 600, + 600 + ], + semicolon: [ + 333, + 333, + 278, + 278, + 333, + 333, + 333, + 278, + 600, + 600, + 600, + 600 + ], + less: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + equal: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + greater: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + question: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + at: [ + 975, + 975, + 1015, + 1015, + 930, + 832, + 920, + 921, + 600, + 600, + 600, + 600 + ], + A: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + B: [ + 722, + 722, + 667, + 667, + 667, + 667, + 611, + 667, + 600, + 600, + 600, + 600 + ], + C: [ + 722, + 722, + 722, + 722, + 722, + 667, + 667, + 667, + 600, + 600, + 600, + 600 + ], + D: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + E: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + F: [ + 611, + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 600, + 600, + 600, + 600 + ], + G: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + H: [ + 722, + 722, + 722, + 722, + 778, + 778, + 722, + 722, + 600, + 600, + 600, + 600 + ], + I: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + J: [ + 556, + 556, + 500, + 500, + 500, + 500, + 444, + 389, + 600, + 600, + 600, + 600 + ], + K: [ + 722, + 722, + 667, + 667, + 778, + 667, + 667, + 722, + 600, + 600, + 600, + 600 + ], + L: [ + 611, + 611, + 556, + 556, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + M: [ + 833, + 833, + 833, + 833, + 944, + 889, + 833, + 889, + 600, + 600, + 600, + 600 + ], + N: [ + 722, + 722, + 722, + 722, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + O: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + P: [ + 667, + 667, + 667, + 667, + 611, + 611, + 611, + 556, + 600, + 600, + 600, + 600 + ], + Q: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + R: [ + 722, + 722, + 722, + 722, + 722, + 667, + 611, + 667, + 600, + 600, + 600, + 600 + ], + S: [ + 667, + 667, + 667, + 667, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + T: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + U: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + V: [ + 667, + 667, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + W: [ + 944, + 944, + 944, + 944, + 1000, + 889, + 833, + 944, + 600, + 600, + 600, + 600 + ], + X: [ + 667, + 667, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Y: [ + 667, + 667, + 667, + 667, + 722, + 611, + 556, + 722, + 600, + 600, + 600, + 600 + ], + Z: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + bracketleft: [ + 333, + 333, + 278, + 278, + 333, + 333, + 389, + 333, + 600, + 600, + 600, + 600 + ], + backslash: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + bracketright: [ + 333, + 333, + 278, + 278, + 333, + 333, + 389, + 333, + 600, + 600, + 600, + 600 + ], + asciicircum: [ + 584, + 584, + 469, + 469, + 581, + 570, + 422, + 469, + 600, + 600, + 600, + 600 + ], + underscore: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + quoteleft: [ + 278, + 278, + 222, + 222, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + a: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + b: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + c: [ + 556, + 556, + 500, + 500, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + d: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + e: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + f: [ + 333, + 333, + 278, + 278, + 333, + 333, + 278, + 333, + 600, + 600, + 600, + 600 + ], + g: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + h: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + i: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + j: [ + 278, + 278, + 222, + 222, + 333, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + k: [ + 556, + 556, + 500, + 500, + 556, + 500, + 444, + 500, + 600, + 600, + 600, + 600 + ], + l: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + m: [ + 889, + 889, + 833, + 833, + 833, + 778, + 722, + 778, + 600, + 600, + 600, + 600 + ], + n: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + o: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + p: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + q: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + r: [ + 389, + 389, + 333, + 333, + 444, + 389, + 389, + 333, + 600, + 600, + 600, + 600 + ], + s: [ + 556, + 556, + 500, + 500, + 389, + 389, + 389, + 389, + 600, + 600, + 600, + 600 + ], + t: [ + 333, + 333, + 278, + 278, + 333, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + u: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + v: [ + 556, + 556, + 500, + 500, + 500, + 444, + 444, + 500, + 600, + 600, + 600, + 600 + ], + w: [ + 778, + 778, + 722, + 722, + 722, + 667, + 667, + 722, + 600, + 600, + 600, + 600 + ], + x: [ + 556, + 556, + 500, + 500, + 500, + 500, + 444, + 500, + 600, + 600, + 600, + 600 + ], + y: [ + 556, + 556, + 500, + 500, + 500, + 444, + 444, + 500, + 600, + 600, + 600, + 600 + ], + z: [ + 500, + 500, + 500, + 500, + 444, + 389, + 389, + 444, + 600, + 600, + 600, + 600 + ], + braceleft: [ + 389, + 389, + 334, + 334, + 394, + 348, + 400, + 480, + 600, + 600, + 600, + 600 + ], + bar: [ + 280, + 280, + 260, + 260, + 220, + 220, + 275, + 200, + 600, + 600, + 600, + 600 + ], + braceright: [ + 389, + 389, + 334, + 334, + 394, + 348, + 400, + 480, + 600, + 600, + 600, + 600 + ], + asciitilde: [ + 584, + 584, + 584, + 584, + 520, + 570, + 541, + 541, + 600, + 600, + 600, + 600 + ], + exclamdown: [ + 333, + 333, + 333, + 333, + 333, + 389, + 389, + 333, + 600, + 600, + 600, + 600 + ], + cent: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + sterling: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + fraction: [ + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 600, + 600, + 600, + 600 + ], + yen: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + florin: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + section: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + currency: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + quotesingle: [ + 238, + 238, + 191, + 191, + 278, + 278, + 214, + 180, + 600, + 600, + 600, + 600 + ], + quotedblleft: [ + 500, + 500, + 333, + 333, + 500, + 500, + 556, + 444, + 600, + 600, + 600, + 600 + ], + guillemotleft: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + guilsinglleft: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + guilsinglright: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + fi: [ + 611, + 611, + 500, + 500, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + fl: [ + 611, + 611, + 500, + 500, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + endash: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + dagger: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + daggerdbl: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + periodcentered: [ + 278, + 278, + 278, + 278, + 250, + 250, + 250, + 250, + 600, + 600, + 600, + 600 + ], + paragraph: [ + 556, + 556, + 537, + 537, + 540, + 500, + 523, + 453, + 600, + 600, + 600, + 600 + ], + bullet: [ + 350, + 350, + 350, + 350, + 350, + 350, + 350, + 350, + 600, + 600, + 600, + 600 + ], + quotesinglbase: [ + 278, + 278, + 222, + 222, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + quotedblbase: [ + 500, + 500, + 333, + 333, + 500, + 500, + 556, + 444, + 600, + 600, + 600, + 600 + ], + quotedblright: [ + 500, + 500, + 333, + 333, + 500, + 500, + 556, + 444, + 600, + 600, + 600, + 600 + ], + guillemotright: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + ellipsis: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 889, + 1000, + 600, + 600, + 600, + 600 + ], + perthousand: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 600, + 600, + 600, + 600 + ], + questiondown: [ + 611, + 611, + 611, + 611, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + grave: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + acute: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + circumflex: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + tilde: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + macron: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + breve: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + dotaccent: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + dieresis: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + ring: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + cedilla: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + hungarumlaut: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + ogonek: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + caron: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + emdash: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 889, + 1000, + 600, + 600, + 600, + 600 + ], + AE: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 944, + 889, + 889, + 600, + 600, + 600, + 600 + ], + ordfeminine: [ + 370, + 370, + 370, + 370, + 300, + 266, + 276, + 276, + 600, + 600, + 600, + 600 + ], + Lslash: [ + 611, + 611, + 556, + 556, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + Oslash: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + OE: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 944, + 944, + 889, + 600, + 600, + 600, + 600 + ], + ordmasculine: [ + 365, + 365, + 365, + 365, + 330, + 300, + 310, + 310, + 600, + 600, + 600, + 600 + ], + ae: [ + 889, + 889, + 889, + 889, + 722, + 722, + 667, + 667, + 600, + 600, + 600, + 600 + ], + dotlessi: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + lslash: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + oslash: [ + 611, + 611, + 611, + 611, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + oe: [ + 944, + 944, + 944, + 944, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + germandbls: [ + 611, + 611, + 611, + 611, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Idieresis: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + eacute: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + abreve: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + uhungarumlaut: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + ecaron: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + Ydieresis: [ + 667, + 667, + 667, + 667, + 722, + 611, + 556, + 722, + 600, + 600, + 600, + 600 + ], + divide: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + Yacute: [ + 667, + 667, + 667, + 667, + 722, + 611, + 556, + 722, + 600, + 600, + 600, + 600 + ], + Acircumflex: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + aacute: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Ucircumflex: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + yacute: [ + 556, + 556, + 500, + 500, + 500, + 444, + 444, + 500, + 600, + 600, + 600, + 600 + ], + scommaaccent: [ + 556, + 556, + 500, + 500, + 389, + 389, + 389, + 389, + 600, + 600, + 600, + 600 + ], + ecircumflex: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + Uring: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Udieresis: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + aogonek: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Uacute: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + uogonek: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Edieresis: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + Dcroat: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + commaaccent: [ + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 600, + 600, + 600, + 600 + ], + copyright: [ + 737, + 737, + 737, + 737, + 747, + 747, + 760, + 760, + 600, + 600, + 600, + 600 + ], + Emacron: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + ccaron: [ + 556, + 556, + 500, + 500, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + aring: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Ncommaaccent: [ + 722, + 722, + 722, + 722, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + lacute: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + agrave: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Tcommaaccent: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + Cacute: [ + 722, + 722, + 722, + 722, + 722, + 667, + 667, + 667, + 600, + 600, + 600, + 600 + ], + atilde: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Edotaccent: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + scaron: [ + 556, + 556, + 500, + 500, + 389, + 389, + 389, + 389, + 600, + 600, + 600, + 600 + ], + scedilla: [ + 556, + 556, + 500, + 500, + 389, + 389, + 389, + 389, + 600, + 600, + 600, + 600 + ], + iacute: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + lozenge: [ + 494, + 494, + 471, + 471, + 494, + 494, + 471, + 471, + 600, + 600, + 600, + 600 + ], + Rcaron: [ + 722, + 722, + 722, + 722, + 722, + 667, + 611, + 667, + 600, + 600, + 600, + 600 + ], + Gcommaaccent: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + ucircumflex: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + acircumflex: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Amacron: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + rcaron: [ + 389, + 389, + 333, + 333, + 444, + 389, + 389, + 333, + 600, + 600, + 600, + 600 + ], + ccedilla: [ + 556, + 556, + 500, + 500, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + Zdotaccent: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + Thorn: [ + 667, + 667, + 667, + 667, + 611, + 611, + 611, + 556, + 600, + 600, + 600, + 600 + ], + Omacron: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Racute: [ + 722, + 722, + 722, + 722, + 722, + 667, + 611, + 667, + 600, + 600, + 600, + 600 + ], + Sacute: [ + 667, + 667, + 667, + 667, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + dcaron: [ + 743, + 743, + 643, + 643, + 672, + 608, + 544, + 588, + 600, + 600, + 600, + 600 + ], + Umacron: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + uring: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + threesuperior: [ + 333, + 333, + 333, + 333, + 300, + 300, + 300, + 300, + 600, + 600, + 600, + 600 + ], + Ograve: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Agrave: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Abreve: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + multiply: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + uacute: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Tcaron: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + partialdiff: [ + 494, + 494, + 476, + 476, + 494, + 494, + 476, + 476, + 600, + 600, + 600, + 600 + ], + ydieresis: [ + 556, + 556, + 500, + 500, + 500, + 444, + 444, + 500, + 600, + 600, + 600, + 600 + ], + Nacute: [ + 722, + 722, + 722, + 722, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + icircumflex: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + Ecircumflex: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + adieresis: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + edieresis: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + cacute: [ + 556, + 556, + 500, + 500, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + nacute: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + umacron: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Ncaron: [ + 722, + 722, + 722, + 722, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + Iacute: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + plusminus: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + brokenbar: [ + 280, + 280, + 260, + 260, + 220, + 220, + 275, + 200, + 600, + 600, + 600, + 600 + ], + registered: [ + 737, + 737, + 737, + 737, + 747, + 747, + 760, + 760, + 600, + 600, + 600, + 600 + ], + Gbreve: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Idotaccent: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + summation: [ + 600, + 600, + 600, + 600, + 600, + 600, + 600, + 600, + 600, + 600, + 600, + 600 + ], + Egrave: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + racute: [ + 389, + 389, + 333, + 333, + 444, + 389, + 389, + 333, + 600, + 600, + 600, + 600 + ], + omacron: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Zacute: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + Zcaron: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + greaterequal: [ + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 600, + 600, + 600, + 600 + ], + Eth: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Ccedilla: [ + 722, + 722, + 722, + 722, + 722, + 667, + 667, + 667, + 600, + 600, + 600, + 600 + ], + lcommaaccent: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + tcaron: [ + 389, + 389, + 317, + 317, + 416, + 366, + 300, + 326, + 600, + 600, + 600, + 600 + ], + eogonek: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + Uogonek: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Aacute: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Adieresis: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + egrave: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + zacute: [ + 500, + 500, + 500, + 500, + 444, + 389, + 389, + 444, + 600, + 600, + 600, + 600 + ], + iogonek: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + Oacute: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + oacute: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + amacron: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + sacute: [ + 556, + 556, + 500, + 500, + 389, + 389, + 389, + 389, + 600, + 600, + 600, + 600 + ], + idieresis: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + Ocircumflex: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Ugrave: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Delta: [ + 612, + 612, + 612, + 612, + 612, + 612, + 612, + 612, + 600, + 600, + 600, + 600 + ], + thorn: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + twosuperior: [ + 333, + 333, + 333, + 333, + 300, + 300, + 300, + 300, + 600, + 600, + 600, + 600 + ], + Odieresis: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + mu: [ + 611, + 611, + 556, + 556, + 556, + 576, + 500, + 500, + 600, + 600, + 600, + 600 + ], + igrave: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + ohungarumlaut: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Eogonek: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + dcroat: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + threequarters: [ + 834, + 834, + 834, + 834, + 750, + 750, + 750, + 750, + 600, + 600, + 600, + 600 + ], + Scedilla: [ + 667, + 667, + 667, + 667, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + lcaron: [ + 400, + 400, + 299, + 299, + 394, + 382, + 300, + 344, + 600, + 600, + 600, + 600 + ], + Kcommaaccent: [ + 722, + 722, + 667, + 667, + 778, + 667, + 667, + 722, + 600, + 600, + 600, + 600 + ], + Lacute: [ + 611, + 611, + 556, + 556, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + trademark: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 980, + 980, + 600, + 600, + 600, + 600 + ], + edotaccent: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + Igrave: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + Imacron: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + Lcaron: [ + 611, + 611, + 556, + 556, + 667, + 611, + 611, + 611, + 600, + 600, + 600, + 600 + ], + onehalf: [ + 834, + 834, + 834, + 834, + 750, + 750, + 750, + 750, + 600, + 600, + 600, + 600 + ], + lessequal: [ + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 600, + 600, + 600, + 600 + ], + ocircumflex: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + ntilde: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Uhungarumlaut: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Eacute: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + emacron: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + gbreve: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + onequarter: [ + 834, + 834, + 834, + 834, + 750, + 750, + 750, + 750, + 600, + 600, + 600, + 600 + ], + Scaron: [ + 667, + 667, + 667, + 667, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + Scommaaccent: [ + 667, + 667, + 667, + 667, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + Ohungarumlaut: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + degree: [ + 400, + 400, + 400, + 400, + 400, + 400, + 400, + 400, + 600, + 600, + 600, + 600 + ], + ograve: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Ccaron: [ + 722, + 722, + 722, + 722, + 722, + 667, + 667, + 667, + 600, + 600, + 600, + 600 + ], + ugrave: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + radical: [ + 549, + 549, + 453, + 453, + 549, + 549, + 453, + 453, + 600, + 600, + 600, + 600 + ], + Dcaron: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + rcommaaccent: [ + 389, + 389, + 333, + 333, + 444, + 389, + 389, + 333, + 600, + 600, + 600, + 600 + ], + Ntilde: [ + 722, + 722, + 722, + 722, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + otilde: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Rcommaaccent: [ + 722, + 722, + 722, + 722, + 722, + 667, + 611, + 667, + 600, + 600, + 600, + 600 + ], + Lcommaaccent: [ + 611, + 611, + 556, + 556, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + Atilde: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Aogonek: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Aring: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Otilde: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + zdotaccent: [ + 500, + 500, + 500, + 500, + 444, + 389, + 389, + 444, + 600, + 600, + 600, + 600 + ], + Ecaron: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + Iogonek: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + kcommaaccent: [ + 556, + 556, + 500, + 500, + 556, + 500, + 444, + 500, + 600, + 600, + 600, + 600 + ], + minus: [ + 584, + 584, + 584, + 584, + 570, + 606, + 675, + 564, + 600, + 600, + 600, + 600 + ], + Icircumflex: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + ncaron: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + tcommaaccent: [ + 333, + 333, + 278, + 278, + 333, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + logicalnot: [ + 584, + 584, + 584, + 584, + 570, + 606, + 675, + 564, + 600, + 600, + 600, + 600 + ], + odieresis: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + udieresis: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + notequal: [ + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 600, + 600, + 600, + 600 + ], + gcommaaccent: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + eth: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + zcaron: [ + 500, + 500, + 500, + 500, + 444, + 389, + 389, + 444, + 600, + 600, + 600, + 600 + ], + ncommaaccent: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + onesuperior: [ + 333, + 333, + 333, + 333, + 300, + 300, + 300, + 300, + 600, + 600, + 600, + 600 + ], + imacron: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + Euro: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ] +}; +var kernPairs = { + AC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + ACacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + ACcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + ACcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + ATcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + ATcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Au: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Auacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Audieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Augrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Auhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Auogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Auring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Av: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Aw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Ay: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Ayacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Aydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AacuteC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AacuteCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AacuteCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AacuteCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AacuteG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AacuteGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AacuteGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AacuteO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AacuteT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AacuteTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AacuteTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AacuteU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AacuteW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AacuteY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AacuteYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AacuteYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Aacuteu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacutev: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Aacutew: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Aacutey: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Aacuteyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Aacuteydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AbreveC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AbreveCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AbreveCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AbreveCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AbreveG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AbreveGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AbreveGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AbreveO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AbreveT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AbreveTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AbreveTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AbreveU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AbreveW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AbreveY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AbreveYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AbreveYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Abreveu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abrevev: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Abrevew: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Abrevey: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Abreveyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Abreveydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AcircumflexC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AcircumflexCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AcircumflexCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AcircumflexCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AcircumflexG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AcircumflexGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AcircumflexGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AcircumflexO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AcircumflexT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AcircumflexTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AcircumflexTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AcircumflexU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AcircumflexW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AcircumflexY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AcircumflexYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AcircumflexYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Acircumflexu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexv: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Acircumflexw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Acircumflexy: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Acircumflexyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Acircumflexydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AdieresisC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AdieresisCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AdieresisCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AdieresisCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AdieresisG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AdieresisGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AdieresisGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AdieresisO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AdieresisT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AdieresisTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AdieresisTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AdieresisU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AdieresisW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AdieresisY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AdieresisYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AdieresisYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Adieresisu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisv: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Adieresisw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Adieresisy: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Adieresisyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Adieresisydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AgraveC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AgraveCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AgraveCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AgraveCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AgraveG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AgraveGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AgraveGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AgraveO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AgraveT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AgraveTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AgraveTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AgraveU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AgraveW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AgraveY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AgraveYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AgraveYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Agraveu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agravev: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Agravew: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Agravey: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Agraveyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Agraveydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AmacronC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AmacronCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AmacronCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AmacronCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AmacronG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AmacronGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AmacronGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AmacronO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AmacronT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AmacronTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AmacronTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AmacronU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AmacronW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AmacronY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AmacronYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AmacronYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Amacronu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronv: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Amacronw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Amacrony: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Amacronyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Amacronydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AogonekC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AogonekCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AogonekCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AogonekCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AogonekG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AogonekGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AogonekGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AogonekO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AogonekT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AogonekTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AogonekTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AogonekU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AogonekW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AogonekY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AogonekYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AogonekYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Aogoneku: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekv: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Aogonekw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -52 + ], + Aogoneky: [ + -30, + -30, + -40, + -40, + -34, + -34, + -55, + -52 + ], + Aogonekyacute: [ + -30, + -30, + -40, + -40, + -34, + -34, + -55, + -52 + ], + Aogonekydieresis: [ + -30, + -30, + -40, + -40, + -34, + -34, + -55, + -52 + ], + AringC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AringCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AringCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AringCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AringG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AringGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AringGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AringO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AringT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AringTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AringTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AringU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AringW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AringY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AringYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AringYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Aringu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringv: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Aringw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Aringy: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Aringyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Aringydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AtildeC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AtildeCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AtildeCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AtildeCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AtildeG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AtildeGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AtildeGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AtildeO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AtildeT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AtildeTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AtildeTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AtildeU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AtildeW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AtildeY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AtildeYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AtildeYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Atildeu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildev: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Atildew: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Atildey: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Atildeyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Atildeydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + BA: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAacute: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAbreve: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAcircumflex: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAdieresis: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAgrave: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAmacron: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAogonek: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAring: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAtilde: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BU: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUacute: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUcircumflex: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUdieresis: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUgrave: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUhungarumlaut: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUmacron: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUogonek: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUring: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + DA: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAacute: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAbreve: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAcircumflex: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAdieresis: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAgrave: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAmacron: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAogonek: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAring: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAtilde: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DV: [ + -40, + -40, + -70, + -70, + -40, + -50, + -40, + -40 + ], + DW: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -30 + ], + DY: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DYacute: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DYdieresis: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + Dcomma: [ + -30, + -30, + -70, + -70 + ], + Dperiod: [ + -30, + -30, + -70, + -70, + -20 + ], + DcaronA: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAacute: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAbreve: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAcircumflex: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAdieresis: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAgrave: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAmacron: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAogonek: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAring: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAtilde: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronV: [ + -40, + -40, + -70, + -70, + -40, + -50, + -40, + -40 + ], + DcaronW: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -30 + ], + DcaronY: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DcaronYacute: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DcaronYdieresis: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + Dcaroncomma: [ + -30, + -30, + -70, + -70 + ], + Dcaronperiod: [ + -30, + -30, + -70, + -70, + -20 + ], + DcroatA: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAacute: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAbreve: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAcircumflex: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAdieresis: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAgrave: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAmacron: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAogonek: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAring: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAtilde: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatV: [ + -40, + -40, + -70, + -70, + -40, + -50, + -40, + -40 + ], + DcroatW: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -30 + ], + DcroatY: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DcroatYacute: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DcroatYdieresis: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + Dcroatcomma: [ + -30, + -30, + -70, + -70 + ], + Dcroatperiod: [ + -30, + -30, + -70, + -70, + -20 + ], + FA: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAacute: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAbreve: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAcircumflex: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAdieresis: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAgrave: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAmacron: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAogonek: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAring: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAtilde: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + Fa: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Faacute: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Fabreve: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Facircumflex: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Fadieresis: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Fagrave: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Famacron: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Faogonek: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Faring: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Fatilde: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Fcomma: [ + -100, + -100, + -150, + -150, + -92, + -129, + -135, + -80 + ], + Fperiod: [ + -100, + -100, + -150, + -150, + -110, + -129, + -135, + -80 + ], + JA: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAacute: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAbreve: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAcircumflex: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAdieresis: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAgrave: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAmacron: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAogonek: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAring: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAtilde: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + Jcomma: [ + -20, + -20, + -30, + -30, + 0, + -10, + -25 + ], + Jperiod: [ + -20, + -20, + -30, + -30, + -20, + -10, + -25 + ], + Ju: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Juacute: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Jucircumflex: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Judieresis: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Jugrave: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Juhungarumlaut: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Jumacron: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Juogonek: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Juring: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + KO: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOacute: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOcircumflex: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOdieresis: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOgrave: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOhungarumlaut: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOmacron: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOslash: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOtilde: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + Ke: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Keacute: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kecaron: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kecircumflex: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kedieresis: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kedotaccent: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kegrave: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kemacron: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Keogonek: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Ko: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Koacute: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kocircumflex: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kodieresis: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kograve: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kohungarumlaut: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Komacron: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Koslash: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kotilde: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Ku: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kuacute: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kucircumflex: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kudieresis: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kugrave: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kuhungarumlaut: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kumacron: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kuogonek: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kuring: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Ky: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + Kyacute: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + Kydieresis: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + KcommaaccentO: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOacute: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOcircumflex: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOdieresis: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOgrave: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOhungarumlaut: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOmacron: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOslash: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOtilde: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + Kcommaaccente: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccenteacute: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentecaron: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentecircumflex: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentedieresis: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentedotaccent: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentegrave: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentemacron: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccenteogonek: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccento: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentoacute: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentocircumflex: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentodieresis: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentograve: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentohungarumlaut: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentomacron: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentoslash: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentotilde: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentu: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentuacute: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentucircumflex: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentudieresis: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentugrave: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentuhungarumlaut: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentumacron: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentuogonek: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccenturing: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccenty: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + Kcommaaccentyacute: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + Kcommaaccentydieresis: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + LT: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LTcaron: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LTcommaaccent: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LV: [ + -110, + -110, + -110, + -110, + -92, + -37, + -55, + -100 + ], + LW: [ + -80, + -80, + -70, + -70, + -92, + -37, + -55, + -74 + ], + LY: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LYacute: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LYdieresis: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + Lquotedblright: [ + -140, + -140, + -140, + -140, + -20 + ], + Lquoteright: [ + -140, + -140, + -160, + -160, + -110, + -55, + -37, + -92 + ], + Ly: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lyacute: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lydieresis: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + LacuteT: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LacuteTcaron: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LacuteTcommaaccent: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LacuteV: [ + -110, + -110, + -110, + -110, + -92, + -37, + -55, + -100 + ], + LacuteW: [ + -80, + -80, + -70, + -70, + -92, + -37, + -55, + -74 + ], + LacuteY: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LacuteYacute: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LacuteYdieresis: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + Lacutequotedblright: [ + -140, + -140, + -140, + -140, + -20 + ], + Lacutequoteright: [ + -140, + -140, + -160, + -160, + -110, + -55, + -37, + -92 + ], + Lacutey: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lacuteyacute: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lacuteydieresis: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + LcommaaccentT: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LcommaaccentTcaron: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LcommaaccentTcommaaccent: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LcommaaccentV: [ + -110, + -110, + -110, + -110, + -92, + -37, + -55, + -100 + ], + LcommaaccentW: [ + -80, + -80, + -70, + -70, + -92, + -37, + -55, + -74 + ], + LcommaaccentY: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LcommaaccentYacute: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LcommaaccentYdieresis: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + Lcommaaccentquotedblright: [ + -140, + -140, + -140, + -140, + -20 + ], + Lcommaaccentquoteright: [ + -140, + -140, + -160, + -160, + -110, + -55, + -37, + -92 + ], + Lcommaaccenty: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lcommaaccentyacute: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lcommaaccentydieresis: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + LslashT: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LslashTcaron: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LslashTcommaaccent: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LslashV: [ + -110, + -110, + -110, + -110, + -92, + -37, + -55, + -100 + ], + LslashW: [ + -80, + -80, + -70, + -70, + -92, + -37, + -55, + -74 + ], + LslashY: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LslashYacute: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LslashYdieresis: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + Lslashquotedblright: [ + -140, + -140, + -140, + -140, + -20 + ], + Lslashquoteright: [ + -140, + -140, + -160, + -160, + -110, + -55, + -37, + -92 + ], + Lslashy: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lslashyacute: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lslashydieresis: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + OA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Ocomma: [ + -40, + -40, + -40, + -40 + ], + Operiod: [ + -40, + -40, + -40, + -40 + ], + OacuteA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OacuteTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OacuteTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OacuteV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OacuteW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OacuteX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OacuteY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OacuteYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OacuteYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Oacutecomma: [ + -40, + -40, + -40, + -40 + ], + Oacuteperiod: [ + -40, + -40, + -40, + -40 + ], + OcircumflexA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OcircumflexTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OcircumflexTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OcircumflexV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OcircumflexW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OcircumflexX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OcircumflexY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OcircumflexYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OcircumflexYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Ocircumflexcomma: [ + -40, + -40, + -40, + -40 + ], + Ocircumflexperiod: [ + -40, + -40, + -40, + -40 + ], + OdieresisA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OdieresisTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OdieresisTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OdieresisV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OdieresisW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OdieresisX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OdieresisY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OdieresisYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OdieresisYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Odieresiscomma: [ + -40, + -40, + -40, + -40 + ], + Odieresisperiod: [ + -40, + -40, + -40, + -40 + ], + OgraveA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OgraveTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OgraveTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OgraveV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OgraveW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OgraveX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OgraveY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OgraveYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OgraveYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Ogravecomma: [ + -40, + -40, + -40, + -40 + ], + Ograveperiod: [ + -40, + -40, + -40, + -40 + ], + OhungarumlautA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OhungarumlautTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OhungarumlautTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OhungarumlautV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OhungarumlautW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OhungarumlautX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OhungarumlautY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OhungarumlautYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OhungarumlautYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Ohungarumlautcomma: [ + -40, + -40, + -40, + -40 + ], + Ohungarumlautperiod: [ + -40, + -40, + -40, + -40 + ], + OmacronA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OmacronTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OmacronTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OmacronV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OmacronW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OmacronX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OmacronY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OmacronYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OmacronYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Omacroncomma: [ + -40, + -40, + -40, + -40 + ], + Omacronperiod: [ + -40, + -40, + -40, + -40 + ], + OslashA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OslashTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OslashTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OslashV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OslashW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OslashX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OslashY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OslashYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OslashYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Oslashcomma: [ + -40, + -40, + -40, + -40 + ], + Oslashperiod: [ + -40, + -40, + -40, + -40 + ], + OtildeA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OtildeTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OtildeTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OtildeV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OtildeW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OtildeX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OtildeY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OtildeYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OtildeYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Otildecomma: [ + -40, + -40, + -40, + -40 + ], + Otildeperiod: [ + -40, + -40, + -40, + -40 + ], + PA: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAacute: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAbreve: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAcircumflex: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAdieresis: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAgrave: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAmacron: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAogonek: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAring: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAtilde: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + Pa: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Paacute: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Pabreve: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Pacircumflex: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Padieresis: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Pagrave: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Pamacron: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Paogonek: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Paring: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Patilde: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Pcomma: [ + -120, + -120, + -180, + -180, + -92, + -129, + -135, + -111 + ], + Pe: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Peacute: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pecaron: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pecircumflex: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pedieresis: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pedotaccent: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pegrave: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pemacron: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Peogonek: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Po: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Poacute: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Pocircumflex: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Podieresis: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Pograve: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Pohungarumlaut: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Pomacron: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Poslash: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Potilde: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Pperiod: [ + -120, + -120, + -180, + -180, + -110, + -129, + -135, + -111 + ], + QU: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUacute: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUcircumflex: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUdieresis: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUgrave: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUhungarumlaut: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUmacron: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUogonek: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUring: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + Qcomma: [ + 20, + 20 + ], + Qperiod: [ + 20, + 20, + 0, + 0, + -20 + ], + RO: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROacute: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROcircumflex: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROdieresis: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROgrave: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROhungarumlaut: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROmacron: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROslash: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROtilde: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RT: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RTcaron: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RTcommaaccent: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RU: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUacute: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUcircumflex: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUdieresis: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUgrave: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUhungarumlaut: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUmacron: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUogonek: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUring: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RV: [ + -50, + -50, + -50, + -50, + -55, + -18, + -18, + -80 + ], + RW: [ + -40, + -40, + -30, + -30, + -35, + -18, + -18, + -55 + ], + RY: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RYacute: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RYdieresis: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RacuteO: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOacute: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOcircumflex: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOdieresis: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOgrave: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOhungarumlaut: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOmacron: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOslash: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOtilde: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteT: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RacuteTcaron: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RacuteTcommaaccent: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RacuteU: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUacute: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUcircumflex: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUdieresis: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUgrave: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUhungarumlaut: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUmacron: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUogonek: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUring: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteV: [ + -50, + -50, + -50, + -50, + -55, + -18, + -18, + -80 + ], + RacuteW: [ + -40, + -40, + -30, + -30, + -35, + -18, + -18, + -55 + ], + RacuteY: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RacuteYacute: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RacuteYdieresis: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcaronO: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOacute: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOcircumflex: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOdieresis: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOgrave: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOhungarumlaut: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOmacron: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOslash: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOtilde: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronT: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcaronTcaron: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcaronTcommaaccent: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcaronU: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUacute: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUcircumflex: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUdieresis: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUgrave: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUhungarumlaut: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUmacron: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUogonek: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUring: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronV: [ + -50, + -50, + -50, + -50, + -55, + -18, + -18, + -80 + ], + RcaronW: [ + -40, + -40, + -30, + -30, + -35, + -18, + -18, + -55 + ], + RcaronY: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcaronYacute: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcaronYdieresis: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcommaaccentO: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOacute: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOcircumflex: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOdieresis: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOgrave: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOhungarumlaut: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOmacron: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOslash: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOtilde: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentT: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcommaaccentTcaron: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcommaaccentTcommaaccent: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcommaaccentU: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUacute: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUcircumflex: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUdieresis: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUgrave: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUhungarumlaut: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUmacron: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUogonek: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUring: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentV: [ + -50, + -50, + -50, + -50, + -55, + -18, + -18, + -80 + ], + RcommaaccentW: [ + -40, + -40, + -30, + -30, + -35, + -18, + -18, + -55 + ], + RcommaaccentY: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcommaaccentYacute: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcommaaccentYdieresis: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + TA: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAacute: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAbreve: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAcircumflex: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAdieresis: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAgrave: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAmacron: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAogonek: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAring: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAtilde: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TO: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOacute: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOcircumflex: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOdieresis: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOgrave: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOhungarumlaut: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOmacron: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOslash: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOtilde: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + Ta: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Taacute: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tabreve: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -80 + ], + Tacircumflex: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -80 + ], + Tadieresis: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tagrave: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tamacron: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Taogonek: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Taring: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tatilde: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Tcolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -55, + -50 + ], + Tcomma: [ + -80, + -80, + -120, + -120, + -74, + -92, + -74, + -74 + ], + Te: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Teacute: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tecaron: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tecircumflex: [ + -60, + -60, + -120, + -120, + -92, + -92, + -52, + -70 + ], + Tedieresis: [ + -60, + -60, + -120, + -120, + -52, + -52, + -52, + -30 + ], + Tedotaccent: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tegrave: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -70 + ], + Temacron: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -30 + ], + Teogonek: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Thyphen: [ + -120, + -120, + -140, + -140, + -92, + -92, + -74, + -92 + ], + To: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Toacute: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tocircumflex: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Todieresis: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tograve: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tohungarumlaut: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tomacron: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Toslash: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Totilde: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Tperiod: [ + -80, + -80, + -120, + -120, + -90, + -92, + -74, + -74 + ], + Tr: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tracute: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Trcommaaccent: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tsemicolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -65, + -55 + ], + Tu: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tuacute: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tucircumflex: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tudieresis: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tugrave: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tuhungarumlaut: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tumacron: [ + -90, + -90, + -60, + -60, + -92, + -37, + -55, + -45 + ], + Tuogonek: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Turing: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tw: [ + -60, + -60, + -120, + -120, + -74, + -37, + -74, + -80 + ], + Ty: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tyacute: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tydieresis: [ + -60, + -60, + -60, + -60, + -34, + -37, + -34, + -80 + ], + TcaronA: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAacute: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAbreve: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAcircumflex: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAdieresis: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAgrave: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAmacron: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAogonek: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAring: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAtilde: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronO: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOacute: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOcircumflex: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOdieresis: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOgrave: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOhungarumlaut: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOmacron: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOslash: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOtilde: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + Tcarona: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcaronaacute: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcaronabreve: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -80 + ], + Tcaronacircumflex: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -80 + ], + Tcaronadieresis: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tcaronagrave: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tcaronamacron: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Tcaronaogonek: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcaronaring: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcaronatilde: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Tcaroncolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -55, + -50 + ], + Tcaroncomma: [ + -80, + -80, + -120, + -120, + -74, + -92, + -74, + -74 + ], + Tcarone: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcaroneacute: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcaronecaron: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcaronecircumflex: [ + -60, + -60, + -120, + -120, + -92, + -92, + -52, + -30 + ], + Tcaronedieresis: [ + -60, + -60, + -120, + -120, + -52, + -52, + -52, + -30 + ], + Tcaronedotaccent: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcaronegrave: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -70 + ], + Tcaronemacron: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -30 + ], + Tcaroneogonek: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcaronhyphen: [ + -120, + -120, + -140, + -140, + -92, + -92, + -74, + -92 + ], + Tcarono: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronoacute: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronocircumflex: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronodieresis: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronograve: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronohungarumlaut: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronomacron: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Tcaronoslash: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronotilde: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Tcaronperiod: [ + -80, + -80, + -120, + -120, + -90, + -92, + -74, + -74 + ], + Tcaronr: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcaronracute: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcaronrcommaaccent: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcaronsemicolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -65, + -55 + ], + Tcaronu: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronuacute: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronucircumflex: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronudieresis: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronugrave: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronuhungarumlaut: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronumacron: [ + -90, + -90, + -60, + -60, + -92, + -37, + -55, + -45 + ], + Tcaronuogonek: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronuring: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronw: [ + -60, + -60, + -120, + -120, + -74, + -37, + -74, + -80 + ], + Tcarony: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tcaronyacute: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tcaronydieresis: [ + -60, + -60, + -60, + -60, + -34, + -37, + -34, + -80 + ], + TcommaaccentA: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAacute: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAbreve: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAcircumflex: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAdieresis: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAgrave: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAmacron: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAogonek: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAring: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAtilde: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentO: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOacute: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOcircumflex: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOdieresis: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOgrave: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOhungarumlaut: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOmacron: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOslash: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOtilde: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + Tcommaaccenta: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcommaaccentaacute: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcommaaccentabreve: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -80 + ], + Tcommaaccentacircumflex: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -80 + ], + Tcommaaccentadieresis: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tcommaaccentagrave: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tcommaaccentamacron: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Tcommaaccentaogonek: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcommaaccentaring: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcommaaccentatilde: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Tcommaaccentcolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -55, + -50 + ], + Tcommaaccentcomma: [ + -80, + -80, + -120, + -120, + -74, + -92, + -74, + -74 + ], + Tcommaaccente: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcommaaccenteacute: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcommaaccentecaron: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcommaaccentecircumflex: [ + -60, + -60, + -120, + -120, + -92, + -92, + -52, + -30 + ], + Tcommaaccentedieresis: [ + -60, + -60, + -120, + -120, + -52, + -52, + -52, + -30 + ], + Tcommaaccentedotaccent: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcommaaccentegrave: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -30 + ], + Tcommaaccentemacron: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -70 + ], + Tcommaaccenteogonek: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcommaaccenthyphen: [ + -120, + -120, + -140, + -140, + -92, + -92, + -74, + -92 + ], + Tcommaaccento: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentoacute: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentocircumflex: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentodieresis: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentograve: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentohungarumlaut: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentomacron: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Tcommaaccentoslash: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentotilde: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Tcommaaccentperiod: [ + -80, + -80, + -120, + -120, + -90, + -92, + -74, + -74 + ], + Tcommaaccentr: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcommaaccentracute: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcommaaccentrcommaaccent: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcommaaccentsemicolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -65, + -55 + ], + Tcommaaccentu: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentuacute: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentucircumflex: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentudieresis: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentugrave: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentuhungarumlaut: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentumacron: [ + -90, + -90, + -60, + -60, + -92, + -37, + -55, + -45 + ], + Tcommaaccentuogonek: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccenturing: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentw: [ + -60, + -60, + -120, + -120, + -74, + -37, + -74, + -80 + ], + Tcommaaccenty: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tcommaaccentyacute: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tcommaaccentydieresis: [ + -60, + -60, + -60, + -60, + -34, + -37, + -34, + -80 + ], + UA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Ucomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Uperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UacuteA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Uacutecomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Uacuteperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UcircumflexA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Ucircumflexcomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Ucircumflexperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UdieresisA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Udieresiscomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Udieresisperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UgraveA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Ugravecomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Ugraveperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UhungarumlautA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Uhungarumlautcomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Uhungarumlautperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UmacronA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Umacroncomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Umacronperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UogonekA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Uogonekcomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Uogonekperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UringA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Uringcomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Uringperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + VA: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAacute: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAbreve: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAcircumflex: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAdieresis: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAgrave: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAmacron: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAogonek: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAring: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAtilde: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VG: [ + -50, + -50, + -40, + -40, + -30, + -10, + 0, + -15 + ], + VGbreve: [ + -50, + -50, + -40, + -40, + -30, + -10, + 0, + -15 + ], + VGcommaaccent: [ + -50, + -50, + -40, + -40, + -30, + -10, + 0, + -15 + ], + VO: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOacute: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOcircumflex: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOdieresis: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOgrave: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOhungarumlaut: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOmacron: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOslash: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOtilde: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + Va: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -111 + ], + Vaacute: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -111 + ], + Vabreve: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -111 + ], + Vacircumflex: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -71 + ], + Vadieresis: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -71 + ], + Vagrave: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -71 + ], + Vamacron: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -71 + ], + Vaogonek: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -111 + ], + Varing: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -111 + ], + Vatilde: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -71 + ], + Vcolon: [ + -40, + -40, + -40, + -40, + -92, + -74, + -65, + -74 + ], + Vcomma: [ + -120, + -120, + -125, + -125, + -129, + -129, + -129, + -129 + ], + Ve: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -111 + ], + Veacute: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -111 + ], + Vecaron: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -71 + ], + Vecircumflex: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -71 + ], + Vedieresis: [ + -50, + -50, + -80, + -80, + -100, + -71, + -71, + -71 + ], + Vedotaccent: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -111 + ], + Vegrave: [ + -50, + -50, + -80, + -80, + -100, + -71, + -71, + -71 + ], + Vemacron: [ + -50, + -50, + -80, + -80, + -100, + -71, + -71, + -71 + ], + Veogonek: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -111 + ], + Vhyphen: [ + -80, + -80, + -80, + -80, + -74, + -70, + -55, + -100 + ], + Vo: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -129 + ], + Voacute: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -129 + ], + Vocircumflex: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -129 + ], + Vodieresis: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -89 + ], + Vograve: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -89 + ], + Vohungarumlaut: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -129 + ], + Vomacron: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -89 + ], + Voslash: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -129 + ], + Votilde: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -89 + ], + Vperiod: [ + -120, + -120, + -125, + -125, + -145, + -129, + -129, + -129 + ], + Vsemicolon: [ + -40, + -40, + -40, + -40, + -92, + -74, + -74, + -74 + ], + Vu: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vuacute: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vucircumflex: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vudieresis: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vugrave: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vuhungarumlaut: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vumacron: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vuogonek: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vuring: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + WA: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAacute: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAbreve: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAcircumflex: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAdieresis: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAgrave: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAmacron: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAogonek: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAring: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAtilde: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WO: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOacute: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOcircumflex: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOdieresis: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOgrave: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOhungarumlaut: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOmacron: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOslash: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOtilde: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + Wa: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Waacute: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wabreve: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wacircumflex: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wadieresis: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wagrave: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wamacron: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Waogonek: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Waring: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Watilde: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wcolon: [ + -10, + -10, + 0, + 0, + -55, + -55, + -65, + -37 + ], + Wcomma: [ + -80, + -80, + -80, + -80, + -92, + -74, + -92, + -92 + ], + We: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Weacute: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Wecaron: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Wecircumflex: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Wedieresis: [ + -35, + -35, + -30, + -30, + -65, + -50, + -52, + -40 + ], + Wedotaccent: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Wegrave: [ + -35, + -35, + -30, + -30, + -65, + -50, + -52, + -40 + ], + Wemacron: [ + -35, + -35, + -30, + -30, + -65, + -50, + -52, + -40 + ], + Weogonek: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Whyphen: [ + -40, + -40, + -40, + -40, + -37, + -50, + -37, + -65 + ], + Wo: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Woacute: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wocircumflex: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wodieresis: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wograve: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wohungarumlaut: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Womacron: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Woslash: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wotilde: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wperiod: [ + -80, + -80, + -80, + -80, + -92, + -74, + -92, + -92 + ], + Wsemicolon: [ + -10, + -10, + 0, + 0, + -55, + -55, + -65, + -37 + ], + Wu: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wuacute: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wucircumflex: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wudieresis: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wugrave: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wuhungarumlaut: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wumacron: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wuogonek: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wuring: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wy: [ + -20, + -20, + -20, + -20, + -60, + -55, + -70, + -73 + ], + Wyacute: [ + -20, + -20, + -20, + -20, + -60, + -55, + -70, + -73 + ], + Wydieresis: [ + -20, + -20, + -20, + -20, + -60, + -55, + -70, + -73 + ], + YA: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAacute: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAbreve: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAcircumflex: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAdieresis: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAgrave: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAmacron: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAogonek: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAring: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAtilde: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YO: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOacute: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOcircumflex: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOdieresis: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOgrave: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOhungarumlaut: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOmacron: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOslash: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOtilde: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + Ya: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yaacute: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yabreve: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -100 + ], + Yacircumflex: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yadieresis: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Yagrave: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Yamacron: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -60 + ], + Yaogonek: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yaring: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yatilde: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Ycolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Ycomma: [ + -100, + -100, + -140, + -140, + -92, + -92, + -92, + -129 + ], + Ye: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yeacute: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yecaron: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yecircumflex: [ + -80, + -80, + -140, + -140, + -111, + -71, + -92, + -100 + ], + Yedieresis: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Yedotaccent: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yegrave: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Yemacron: [ + -80, + -80, + -70, + -70, + -71, + -71, + -52, + -60 + ], + Yeogonek: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yo: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yoacute: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yocircumflex: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yodieresis: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yograve: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yohungarumlaut: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yomacron: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yoslash: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yotilde: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yperiod: [ + -100, + -100, + -140, + -140, + -92, + -74, + -92, + -129 + ], + Ysemicolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Yu: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yuacute: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yucircumflex: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yudieresis: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yugrave: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yuhungarumlaut: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yumacron: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yuogonek: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yuring: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + YacuteA: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAacute: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAbreve: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAcircumflex: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAdieresis: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAgrave: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAmacron: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAogonek: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAring: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAtilde: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteO: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOacute: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOcircumflex: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOdieresis: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOgrave: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOhungarumlaut: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOmacron: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOslash: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOtilde: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + Yacutea: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yacuteaacute: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yacuteabreve: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -100 + ], + Yacuteacircumflex: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yacuteadieresis: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Yacuteagrave: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Yacuteamacron: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -60 + ], + Yacuteaogonek: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yacutearing: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yacuteatilde: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -60 + ], + Yacutecolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Yacutecomma: [ + -100, + -100, + -140, + -140, + -92, + -92, + -92, + -129 + ], + Yacutee: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yacuteeacute: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yacuteecaron: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yacuteecircumflex: [ + -80, + -80, + -140, + -140, + -111, + -71, + -92, + -100 + ], + Yacuteedieresis: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Yacuteedotaccent: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yacuteegrave: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Yacuteemacron: [ + -80, + -80, + -70, + -70, + -71, + -71, + -52, + -60 + ], + Yacuteeogonek: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yacuteo: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yacuteoacute: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yacuteocircumflex: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yacuteodieresis: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yacuteograve: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yacuteohungarumlaut: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yacuteomacron: [ + -100, + -100, + -70, + -70, + -111, + -111, + -92, + -70 + ], + Yacuteoslash: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yacuteotilde: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yacuteperiod: [ + -100, + -100, + -140, + -140, + -92, + -74, + -92, + -129 + ], + Yacutesemicolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Yacuteu: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yacuteuacute: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yacuteucircumflex: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yacuteudieresis: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yacuteugrave: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yacuteuhungarumlaut: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yacuteumacron: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yacuteuogonek: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yacuteuring: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + YdieresisA: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAacute: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAbreve: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAcircumflex: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAdieresis: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAgrave: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAmacron: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAogonek: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAring: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAtilde: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisO: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOacute: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOcircumflex: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOdieresis: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOgrave: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOhungarumlaut: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOmacron: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOslash: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOtilde: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + Ydieresisa: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Ydieresisaacute: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Ydieresisabreve: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -100 + ], + Ydieresisacircumflex: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Ydieresisadieresis: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Ydieresisagrave: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Ydieresisamacron: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -60 + ], + Ydieresisaogonek: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Ydieresisaring: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Ydieresisatilde: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -100 + ], + Ydieresiscolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Ydieresiscomma: [ + -100, + -100, + -140, + -140, + -92, + -92, + -92, + -129 + ], + Ydieresise: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Ydieresiseacute: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Ydieresisecaron: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Ydieresisecircumflex: [ + -80, + -80, + -140, + -140, + -111, + -71, + -92, + -100 + ], + Ydieresisedieresis: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Ydieresisedotaccent: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Ydieresisegrave: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Ydieresisemacron: [ + -80, + -80, + -70, + -70, + -71, + -71, + -52, + -60 + ], + Ydieresiseogonek: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Ydieresiso: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Ydieresisoacute: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Ydieresisocircumflex: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Ydieresisodieresis: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Ydieresisograve: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Ydieresisohungarumlaut: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Ydieresisomacron: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Ydieresisoslash: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Ydieresisotilde: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Ydieresisperiod: [ + -100, + -100, + -140, + -140, + -92, + -74, + -92, + -129 + ], + Ydieresissemicolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Ydieresisu: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Ydieresisuacute: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Ydieresisucircumflex: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Ydieresisudieresis: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Ydieresisugrave: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Ydieresisuhungarumlaut: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Ydieresisumacron: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Ydieresisuogonek: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Ydieresisuring: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + ag: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + agbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + agcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + av: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + aw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + ay: [ + -20, + -20, + -30, + -30 + ], + ayacute: [ + -20, + -20, + -30, + -30 + ], + aydieresis: [ + -20, + -20, + -30, + -30 + ], + aacuteg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aacutegbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aacutegcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aacutev: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + aacutew: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + aacutey: [ + -20, + -20, + -30, + -30 + ], + aacuteyacute: [ + -20, + -20, + -30, + -30 + ], + aacuteydieresis: [ + -20, + -20, + -30, + -30 + ], + abreveg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + abrevegbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + abrevegcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + abrevev: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + abrevew: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + abrevey: [ + -20, + -20, + -30, + -30 + ], + abreveyacute: [ + -20, + -20, + -30, + -30 + ], + abreveydieresis: [ + -20, + -20, + -30, + -30 + ], + acircumflexg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + acircumflexgbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + acircumflexgcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + acircumflexv: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + acircumflexw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + acircumflexy: [ + -20, + -20, + -30, + -30 + ], + acircumflexyacute: [ + -20, + -20, + -30, + -30 + ], + acircumflexydieresis: [ + -20, + -20, + -30, + -30 + ], + adieresisg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + adieresisgbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + adieresisgcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + adieresisv: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + adieresisw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + adieresisy: [ + -20, + -20, + -30, + -30 + ], + adieresisyacute: [ + -20, + -20, + -30, + -30 + ], + adieresisydieresis: [ + -20, + -20, + -30, + -30 + ], + agraveg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + agravegbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + agravegcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + agravev: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + agravew: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + agravey: [ + -20, + -20, + -30, + -30 + ], + agraveyacute: [ + -20, + -20, + -30, + -30 + ], + agraveydieresis: [ + -20, + -20, + -30, + -30 + ], + amacrong: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + amacrongbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + amacrongcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + amacronv: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + amacronw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + amacrony: [ + -20, + -20, + -30, + -30 + ], + amacronyacute: [ + -20, + -20, + -30, + -30 + ], + amacronydieresis: [ + -20, + -20, + -30, + -30 + ], + aogonekg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aogonekgbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aogonekgcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aogonekv: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + aogonekw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + aogoneky: [ + -20, + -20, + -30, + -30 + ], + aogonekyacute: [ + -20, + -20, + -30, + -30 + ], + aogonekydieresis: [ + -20, + -20, + -30, + -30 + ], + aringg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aringgbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aringgcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aringv: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + aringw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + aringy: [ + -20, + -20, + -30, + -30 + ], + aringyacute: [ + -20, + -20, + -30, + -30 + ], + aringydieresis: [ + -20, + -20, + -30, + -30 + ], + atildeg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + atildegbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + atildegcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + atildev: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + atildew: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + atildey: [ + -20, + -20, + -30, + -30 + ], + atildeyacute: [ + -20, + -20, + -30, + -30 + ], + atildeydieresis: [ + -20, + -20, + -30, + -30 + ], + bl: [ + -10, + -10, + -20, + -20 + ], + blacute: [ + -10, + -10, + -20, + -20 + ], + blcommaaccent: [ + -10, + -10, + -20, + -20 + ], + blslash: [ + -10, + -10, + -20, + -20 + ], + bu: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + buacute: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + bucircumflex: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + budieresis: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + bugrave: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + buhungarumlaut: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + bumacron: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + buogonek: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + buring: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + bv: [ + -20, + -20, + -20, + -20, + -15, + 0, + 0, + -15 + ], + by: [ + -20, + -20, + -20, + -20 + ], + byacute: [ + -20, + -20, + -20, + -20 + ], + bydieresis: [ + -20, + -20, + -20, + -20 + ], + ch: [ + -10, + -10, + 0, + 0, + 0, + -10, + -15 + ], + ck: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + ckcommaaccent: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + cl: [ + -20, + -20 + ], + clacute: [ + -20, + -20 + ], + clcommaaccent: [ + -20, + -20 + ], + clslash: [ + -20, + -20 + ], + cy: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + cyacute: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + cydieresis: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + cacuteh: [ + -10, + -10, + 0, + 0, + 0, + -10, + -15 + ], + cacutek: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + cacutekcommaaccent: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + cacutel: [ + -20, + -20 + ], + cacutelacute: [ + -20, + -20 + ], + cacutelcommaaccent: [ + -20, + -20 + ], + cacutelslash: [ + -20, + -20 + ], + cacutey: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + cacuteyacute: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + cacuteydieresis: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccaronh: [ + -10, + -10, + 0, + 0, + 0, + -10, + -15 + ], + ccaronk: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + ccaronkcommaaccent: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + ccaronl: [ + -20, + -20 + ], + ccaronlacute: [ + -20, + -20 + ], + ccaronlcommaaccent: [ + -20, + -20 + ], + ccaronlslash: [ + -20, + -20 + ], + ccarony: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccaronyacute: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccaronydieresis: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccedillah: [ + -10, + -10, + 0, + 0, + 0, + -10, + -15 + ], + ccedillak: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + ccedillakcommaaccent: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + ccedillal: [ + -20, + -20 + ], + ccedillalacute: [ + -20, + -20 + ], + ccedillalcommaaccent: [ + -20, + -20 + ], + ccedillalslash: [ + -20, + -20 + ], + ccedillay: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccedillayacute: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccedillaydieresis: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + colonspace: [ + -40, + -40, + -50, + -50 + ], + commaquotedblright: [ + -120, + -120, + -100, + -100, + -45, + -95, + -140, + -70 + ], + commaquoteright: [ + -120, + -120, + -100, + -100, + -55, + -95, + -140, + -70 + ], + commaspace: [ + -40, + -40 + ], + dd: [ + -10, + -10 + ], + ddcroat: [ + -10, + -10 + ], + dv: [ + -15, + -15 + ], + dw: [ + -15, + -15, + 0, + 0, + -15 + ], + dy: [ + -15, + -15 + ], + dyacute: [ + -15, + -15 + ], + dydieresis: [ + -15, + -15 + ], + dcroatd: [ + -10, + -10 + ], + dcroatdcroat: [ + -10, + -10 + ], + dcroatv: [ + -15, + -15 + ], + dcroatw: [ + -15, + -15, + 0, + 0, + -15 + ], + dcroaty: [ + -15, + -15 + ], + dcroatyacute: [ + -15, + -15 + ], + dcroatydieresis: [ + -15, + -15 + ], + ecomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + eperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + ev: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + ew: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + ex: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + ey: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eacutecomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + eacuteperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + eacutev: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + eacutew: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + eacutex: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + eacutey: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eacuteyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eacuteydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecaroncomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + ecaronperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + ecaronv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + ecaronw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + ecaronx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + ecarony: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecaronyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecaronydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecircumflexcomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + ecircumflexperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + ecircumflexv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + ecircumflexw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + ecircumflexx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + ecircumflexy: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecircumflexyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecircumflexydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edieresiscomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + edieresisperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + edieresisv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + edieresisw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + edieresisx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + edieresisy: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edieresisyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edieresisydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edotaccentcomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + edotaccentperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + edotaccentv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + edotaccentw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + edotaccentx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + edotaccenty: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edotaccentyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edotaccentydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + egravecomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + egraveperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + egravev: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + egravew: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + egravex: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + egravey: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + egraveyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + egraveydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + emacroncomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + emacronperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + emacronv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + emacronw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + emacronx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + emacrony: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + emacronyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + emacronydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eogonekcomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + eogonekperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + eogonekv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + eogonekw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + eogonekx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + eogoneky: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eogonekyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eogonekydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + fcomma: [ + -10, + -10, + -30, + -30, + -15, + -10, + -10 + ], + fe: [ + -10, + -10, + -30, + -30, + 0, + -10 + ], + feacute: [ + -10, + -10, + -30, + -30, + 0, + -10 + ], + fecaron: [ + -10, + -10, + -30, + -30 + ], + fecircumflex: [ + -10, + -10, + -30, + -30 + ], + fedieresis: [ + -10, + -10, + -30, + -30 + ], + fedotaccent: [ + -10, + -10, + -30, + -30, + 0, + -10 + ], + fegrave: [ + -10, + -10, + -30, + -30 + ], + femacron: [ + -10, + -10, + -30, + -30 + ], + feogonek: [ + -10, + -10, + -30, + -30, + 0, + -10 + ], + fo: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + foacute: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + focircumflex: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + fodieresis: [ + -20, + -20, + -30, + -30, + -25 + ], + fograve: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + fohungarumlaut: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + fomacron: [ + -20, + -20, + -30, + -30, + -25 + ], + foslash: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + fotilde: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + fperiod: [ + -10, + -10, + -30, + -30, + -15, + -10, + -15 + ], + fquotedblright: [ + 30, + 30, + 60, + 60, + 50 + ], + fquoteright: [ + 30, + 30, + 50, + 50, + 55, + 55, + 92, + 55 + ], + ge: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + geacute: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gecaron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gecircumflex: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gedieresis: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gedotaccent: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gegrave: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gemacron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + geogonek: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + ggbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + ggcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gbrevee: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveeacute: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveecaron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveecircumflex: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveedieresis: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveedotaccent: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveegrave: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveemacron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveeogonek: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gbrevegbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gbrevegcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccente: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccenteacute: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentecaron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentecircumflex: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentedieresis: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentedotaccent: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentegrave: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentemacron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccenteogonek: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentgbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentgcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + hy: [ + -20, + -20, + -30, + -30, + -15, + 0, + 0, + -5 + ], + hyacute: [ + -20, + -20, + -30, + -30, + -15, + 0, + 0, + -5 + ], + hydieresis: [ + -20, + -20, + -30, + -30, + -15, + 0, + 0, + -5 + ], + ko: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + koacute: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kocircumflex: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kodieresis: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kograve: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kohungarumlaut: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + komacron: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + koslash: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kotilde: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccento: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentoacute: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentocircumflex: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentodieresis: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentograve: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentohungarumlaut: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentomacron: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentoslash: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentotilde: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + lw: [ + -15, + -15, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ly: [ + -15, + -15 + ], + lyacute: [ + -15, + -15 + ], + lydieresis: [ + -15, + -15 + ], + lacutew: [ + -15, + -15, + 0, + 0, + 0, + 0, + 0, + -10 + ], + lacutey: [ + -15, + -15 + ], + lacuteyacute: [ + -15, + -15 + ], + lacuteydieresis: [ + -15, + -15 + ], + lcommaaccentw: [ + -15, + -15, + 0, + 0, + 0, + 0, + 0, + -10 + ], + lcommaaccenty: [ + -15, + -15 + ], + lcommaaccentyacute: [ + -15, + -15 + ], + lcommaaccentydieresis: [ + -15, + -15 + ], + lslashw: [ + -15, + -15, + 0, + 0, + 0, + 0, + 0, + -10 + ], + lslashy: [ + -15, + -15 + ], + lslashyacute: [ + -15, + -15 + ], + lslashydieresis: [ + -15, + -15 + ], + mu: [ + -20, + -20, + -10, + -10 + ], + muacute: [ + -20, + -20, + -10, + -10 + ], + mucircumflex: [ + -20, + -20, + -10, + -10 + ], + mudieresis: [ + -20, + -20, + -10, + -10 + ], + mugrave: [ + -20, + -20, + -10, + -10 + ], + muhungarumlaut: [ + -20, + -20, + -10, + -10 + ], + mumacron: [ + -20, + -20, + -10, + -10 + ], + muogonek: [ + -20, + -20, + -10, + -10 + ], + muring: [ + -20, + -20, + -10, + -10 + ], + my: [ + -30, + -30, + -15, + -15 + ], + myacute: [ + -30, + -30, + -15, + -15 + ], + mydieresis: [ + -30, + -30, + -15, + -15 + ], + nu: [ + -10, + -10, + -10, + -10 + ], + nuacute: [ + -10, + -10, + -10, + -10 + ], + nucircumflex: [ + -10, + -10, + -10, + -10 + ], + nudieresis: [ + -10, + -10, + -10, + -10 + ], + nugrave: [ + -10, + -10, + -10, + -10 + ], + nuhungarumlaut: [ + -10, + -10, + -10, + -10 + ], + numacron: [ + -10, + -10, + -10, + -10 + ], + nuogonek: [ + -10, + -10, + -10, + -10 + ], + nuring: [ + -10, + -10, + -10, + -10 + ], + nv: [ + -40, + -40, + -20, + -20, + -40, + -40, + -40, + -40 + ], + ny: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + nyacute: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + nydieresis: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + nacuteu: [ + -10, + -10, + -10, + -10 + ], + nacuteuacute: [ + -10, + -10, + -10, + -10 + ], + nacuteucircumflex: [ + -10, + -10, + -10, + -10 + ], + nacuteudieresis: [ + -10, + -10, + -10, + -10 + ], + nacuteugrave: [ + -10, + -10, + -10, + -10 + ], + nacuteuhungarumlaut: [ + -10, + -10, + -10, + -10 + ], + nacuteumacron: [ + -10, + -10, + -10, + -10 + ], + nacuteuogonek: [ + -10, + -10, + -10, + -10 + ], + nacuteuring: [ + -10, + -10, + -10, + -10 + ], + nacutev: [ + -40, + -40, + -20, + -20, + -40, + -40, + -40, + -40 + ], + nacutey: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + nacuteyacute: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + nacuteydieresis: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncaronu: [ + -10, + -10, + -10, + -10 + ], + ncaronuacute: [ + -10, + -10, + -10, + -10 + ], + ncaronucircumflex: [ + -10, + -10, + -10, + -10 + ], + ncaronudieresis: [ + -10, + -10, + -10, + -10 + ], + ncaronugrave: [ + -10, + -10, + -10, + -10 + ], + ncaronuhungarumlaut: [ + -10, + -10, + -10, + -10 + ], + ncaronumacron: [ + -10, + -10, + -10, + -10 + ], + ncaronuogonek: [ + -10, + -10, + -10, + -10 + ], + ncaronuring: [ + -10, + -10, + -10, + -10 + ], + ncaronv: [ + -40, + -40, + -20, + -20, + -40, + -40, + -40, + -40 + ], + ncarony: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncaronyacute: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncaronydieresis: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncommaaccentu: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentuacute: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentucircumflex: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentudieresis: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentugrave: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentuhungarumlaut: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentumacron: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentuogonek: [ + -10, + -10, + -10, + -10 + ], + ncommaaccenturing: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentv: [ + -40, + -40, + -20, + -20, + -40, + -40, + -40, + -40 + ], + ncommaaccenty: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncommaaccentyacute: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncommaaccentydieresis: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ntildeu: [ + -10, + -10, + -10, + -10 + ], + ntildeuacute: [ + -10, + -10, + -10, + -10 + ], + ntildeucircumflex: [ + -10, + -10, + -10, + -10 + ], + ntildeudieresis: [ + -10, + -10, + -10, + -10 + ], + ntildeugrave: [ + -10, + -10, + -10, + -10 + ], + ntildeuhungarumlaut: [ + -10, + -10, + -10, + -10 + ], + ntildeumacron: [ + -10, + -10, + -10, + -10 + ], + ntildeuogonek: [ + -10, + -10, + -10, + -10 + ], + ntildeuring: [ + -10, + -10, + -10, + -10 + ], + ntildev: [ + -40, + -40, + -20, + -20, + -40, + -40, + -40, + -40 + ], + ntildey: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ntildeyacute: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ntildeydieresis: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ov: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + ow: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + ox: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + oy: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oacutev: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + oacutew: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + oacutex: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + oacutey: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oacuteyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oacuteydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ocircumflexv: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + ocircumflexw: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + ocircumflexx: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + ocircumflexy: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ocircumflexyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ocircumflexydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + odieresisv: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + odieresisw: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + odieresisx: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + odieresisy: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + odieresisyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + odieresisydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ogravev: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + ogravew: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + ogravex: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + ogravey: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ograveyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ograveydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ohungarumlautv: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + ohungarumlautw: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + ohungarumlautx: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + ohungarumlauty: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ohungarumlautyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ohungarumlautydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + omacronv: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + omacronw: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + omacronx: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + omacrony: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + omacronyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + omacronydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oslashv: [ + -20, + -20, + -70, + -70, + -10, + -15, + -10, + -15 + ], + oslashw: [ + -15, + -15, + -70, + -70, + -10, + -25, + 0, + -25 + ], + oslashx: [ + -30, + -30, + -85, + -85, + 0, + -10 + ], + oslashy: [ + -20, + -20, + -70, + -70, + 0, + -10, + 0, + -10 + ], + oslashyacute: [ + -20, + -20, + -70, + -70, + 0, + -10, + 0, + -10 + ], + oslashydieresis: [ + -20, + -20, + -70, + -70, + 0, + -10, + 0, + -10 + ], + otildev: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + otildew: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + otildex: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + otildey: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + otildeyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + otildeydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + py: [ + -15, + -15, + -30, + -30, + 0, + 0, + 0, + -10 + ], + pyacute: [ + -15, + -15, + -30, + -30, + 0, + 0, + 0, + -10 + ], + pydieresis: [ + -15, + -15, + -30, + -30, + 0, + 0, + 0, + -10 + ], + periodquotedblright: [ + -120, + -120, + -100, + -100, + -55, + -95, + -140, + -70 + ], + periodquoteright: [ + -120, + -120, + -100, + -100, + -55, + -95, + -140, + -70 + ], + periodspace: [ + -40, + -40, + -60, + -60 + ], + quotedblrightspace: [ + -80, + -80, + -40, + -40 + ], + quoteleftquoteleft: [ + -46, + -46, + -57, + -57, + -63, + -74, + -111, + -74 + ], + quoterightd: [ + -80, + -80, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterightdcroat: [ + -80, + -80, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterightl: [ + -20, + -20, + 0, + 0, + 0, + 0, + 0, + -10 + ], + quoterightlacute: [ + -20, + -20, + 0, + 0, + 0, + 0, + 0, + -10 + ], + quoterightlcommaaccent: [ + -20, + -20, + 0, + 0, + 0, + 0, + 0, + -10 + ], + quoterightlslash: [ + -20, + -20, + 0, + 0, + 0, + 0, + 0, + -10 + ], + quoterightquoteright: [ + -46, + -46, + -57, + -57, + -63, + -74, + -111, + -74 + ], + quoterightr: [ + -40, + -40, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterightracute: [ + -40, + -40, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterightrcaron: [ + -40, + -40, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterightrcommaaccent: [ + -40, + -40, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterights: [ + -60, + -60, + -50, + -50, + -37, + -74, + -40, + -55 + ], + quoterightsacute: [ + -60, + -60, + -50, + -50, + -37, + -74, + -40, + -55 + ], + quoterightscaron: [ + -60, + -60, + -50, + -50, + -37, + -74, + -40, + -55 + ], + quoterightscedilla: [ + -60, + -60, + -50, + -50, + -37, + -74, + -40, + -55 + ], + quoterightscommaaccent: [ + -60, + -60, + -50, + -50, + -37, + -74, + -40, + -55 + ], + quoterightspace: [ + -80, + -80, + -70, + -70, + -74, + -74, + -111, + -74 + ], + quoterightv: [ + -20, + -20, + 0, + 0, + -20, + -15, + -10, + -50 + ], + rc: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rccaron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rccedilla: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcomma: [ + -60, + -60, + -50, + -50, + -92, + -65, + -111, + -40 + ], + rd: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rdcroat: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rg: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rgbreve: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rgcommaaccent: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rhyphen: [ + -20, + -20, + 0, + 0, + -37, + 0, + -20, + -20 + ], + ro: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + roacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rocircumflex: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rodieresis: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rograve: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rohungarumlaut: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + romacron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + roslash: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rotilde: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rperiod: [ + -60, + -60, + -50, + -50, + -100, + -65, + -111, + -55 + ], + rq: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rs: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rsacute: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rscaron: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rscedilla: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rscommaaccent: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rt: [ + 20, + 20, + 40, + 40 + ], + rtcommaaccent: [ + 20, + 20, + 40, + 40 + ], + rv: [ + 10, + 10, + 30, + 30, + -10 + ], + ry: [ + 10, + 10, + 30, + 30 + ], + ryacute: [ + 10, + 10, + 30, + 30 + ], + rydieresis: [ + 10, + 10, + 30, + 30 + ], + racutec: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + racutecacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + racuteccaron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + racuteccedilla: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + racutecomma: [ + -60, + -60, + -50, + -50, + -92, + -65, + -111, + -40 + ], + racuted: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + racutedcroat: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + racuteg: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + racutegbreve: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + racutegcommaaccent: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + racutehyphen: [ + -20, + -20, + 0, + 0, + -37, + 0, + -20, + -20 + ], + racuteo: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteoacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteocircumflex: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteodieresis: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteograve: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteohungarumlaut: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteomacron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteoslash: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteotilde: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteperiod: [ + -60, + -60, + -50, + -50, + -100, + -65, + -111, + -55 + ], + racuteq: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + racutes: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + racutesacute: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + racutescaron: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + racutescedilla: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + racutescommaaccent: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + racutet: [ + 20, + 20, + 40, + 40 + ], + racutetcommaaccent: [ + 20, + 20, + 40, + 40 + ], + racutev: [ + 10, + 10, + 30, + 30, + -10 + ], + racutey: [ + 10, + 10, + 30, + 30 + ], + racuteyacute: [ + 10, + 10, + 30, + 30 + ], + racuteydieresis: [ + 10, + 10, + 30, + 30 + ], + rcaronc: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcaroncacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcaronccaron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcaronccedilla: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcaroncomma: [ + -60, + -60, + -50, + -50, + -92, + -65, + -111, + -40 + ], + rcarond: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rcarondcroat: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rcarong: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcarongbreve: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcarongcommaaccent: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcaronhyphen: [ + -20, + -20, + 0, + 0, + -37, + 0, + -20, + -20 + ], + rcarono: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronoacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronocircumflex: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronodieresis: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronograve: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronohungarumlaut: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronomacron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronoslash: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronotilde: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronperiod: [ + -60, + -60, + -50, + -50, + -100, + -65, + -111, + -55 + ], + rcaronq: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcarons: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcaronsacute: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcaronscaron: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcaronscedilla: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcaronscommaaccent: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcaront: [ + 20, + 20, + 40, + 40 + ], + rcarontcommaaccent: [ + 20, + 20, + 40, + 40 + ], + rcaronv: [ + 10, + 10, + 30, + 30, + -10 + ], + rcarony: [ + 10, + 10, + 30, + 30 + ], + rcaronyacute: [ + 10, + 10, + 30, + 30 + ], + rcaronydieresis: [ + 10, + 10, + 30, + 30 + ], + rcommaaccentc: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentcacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentccaron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentccedilla: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentcomma: [ + -60, + -60, + -50, + -50, + -92, + -65, + -111, + -40 + ], + rcommaaccentd: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rcommaaccentdcroat: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rcommaaccentg: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcommaaccentgbreve: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcommaaccentgcommaaccent: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcommaaccenthyphen: [ + -20, + -20, + 0, + 0, + -37, + 0, + -20, + -20 + ], + rcommaaccento: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentoacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentocircumflex: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentodieresis: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentograve: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentohungarumlaut: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentomacron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentoslash: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentotilde: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentperiod: [ + -60, + -60, + -50, + -50, + -100, + -65, + -111, + -55 + ], + rcommaaccentq: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccents: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcommaaccentsacute: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcommaaccentscaron: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcommaaccentscedilla: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcommaaccentscommaaccent: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcommaaccentt: [ + 20, + 20, + 40, + 40 + ], + rcommaaccenttcommaaccent: [ + 20, + 20, + 40, + 40 + ], + rcommaaccentv: [ + 10, + 10, + 30, + 30, + -10 + ], + rcommaaccenty: [ + 10, + 10, + 30, + 30 + ], + rcommaaccentyacute: [ + 10, + 10, + 30, + 30 + ], + rcommaaccentydieresis: [ + 10, + 10, + 30, + 30 + ], + sw: [ + -15, + -15, + -30, + -30 + ], + sacutew: [ + -15, + -15, + -30, + -30 + ], + scaronw: [ + -15, + -15, + -30, + -30 + ], + scedillaw: [ + -15, + -15, + -30, + -30 + ], + scommaaccentw: [ + -15, + -15, + -30, + -30 + ], + semicolonspace: [ + -40, + -40, + -50, + -50 + ], + spaceT: [ + -100, + -100, + -50, + -50, + -30, + 0, + -18, + -18 + ], + spaceTcaron: [ + -100, + -100, + -50, + -50, + -30, + 0, + -18, + -18 + ], + spaceTcommaaccent: [ + -100, + -100, + -50, + -50, + -30, + 0, + -18, + -18 + ], + spaceV: [ + -80, + -80, + -50, + -50, + -45, + -70, + -35, + -50 + ], + spaceW: [ + -80, + -80, + -40, + -40, + -30, + -70, + -40, + -30 + ], + spaceY: [ + -120, + -120, + -90, + -90, + -55, + -70, + -75, + -90 + ], + spaceYacute: [ + -120, + -120, + -90, + -90, + -55, + -70, + -75, + -90 + ], + spaceYdieresis: [ + -120, + -120, + -90, + -90, + -55, + -70, + -75, + -90 + ], + spacequotedblleft: [ + -80, + -80, + -30, + -30 + ], + spacequoteleft: [ + -60, + -60, + -60, + -60 + ], + va: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vaacute: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vabreve: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vacircumflex: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vadieresis: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vagrave: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vamacron: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vaogonek: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + varing: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vatilde: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vcomma: [ + -80, + -80, + -80, + -80, + -55, + -37, + -74, + -65 + ], + vo: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + voacute: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vocircumflex: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vodieresis: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vograve: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vohungarumlaut: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vomacron: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + voslash: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + votilde: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vperiod: [ + -80, + -80, + -80, + -80, + -70, + -37, + -74, + -65 + ], + wcomma: [ + -40, + -40, + -60, + -60, + -55, + -37, + -74, + -65 + ], + wo: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + woacute: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wocircumflex: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wodieresis: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wograve: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wohungarumlaut: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + womacron: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + woslash: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wotilde: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wperiod: [ + -40, + -40, + -60, + -60, + -70, + -37, + -74, + -65 + ], + xe: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xeacute: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xecaron: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xecircumflex: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xedieresis: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xedotaccent: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xegrave: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xemacron: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xeogonek: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + ya: [ + -30, + -30, + -20, + -20 + ], + yaacute: [ + -30, + -30, + -20, + -20 + ], + yabreve: [ + -30, + -30, + -20, + -20 + ], + yacircumflex: [ + -30, + -30, + -20, + -20 + ], + yadieresis: [ + -30, + -30, + -20, + -20 + ], + yagrave: [ + -30, + -30, + -20, + -20 + ], + yamacron: [ + -30, + -30, + -20, + -20 + ], + yaogonek: [ + -30, + -30, + -20, + -20 + ], + yaring: [ + -30, + -30, + -20, + -20 + ], + yatilde: [ + -30, + -30, + -20, + -20 + ], + ycomma: [ + -80, + -80, + -100, + -100, + -55, + -37, + -55, + -65 + ], + ye: [ + -10, + -10, + -20, + -20, + -10 + ], + yeacute: [ + -10, + -10, + -20, + -20, + -10 + ], + yecaron: [ + -10, + -10, + -20, + -20, + -10 + ], + yecircumflex: [ + -10, + -10, + -20, + -20, + -10 + ], + yedieresis: [ + -10, + -10, + -20, + -20, + -10 + ], + yedotaccent: [ + -10, + -10, + -20, + -20, + -10 + ], + yegrave: [ + -10, + -10, + -20, + -20, + -10 + ], + yemacron: [ + -10, + -10, + -20, + -20, + -10 + ], + yeogonek: [ + -10, + -10, + -20, + -20, + -10 + ], + yo: [ + -25, + -25, + -20, + -20, + -25 + ], + yoacute: [ + -25, + -25, + -20, + -20, + -25 + ], + yocircumflex: [ + -25, + -25, + -20, + -20, + -25 + ], + yodieresis: [ + -25, + -25, + -20, + -20, + -25 + ], + yograve: [ + -25, + -25, + -20, + -20, + -25 + ], + yohungarumlaut: [ + -25, + -25, + -20, + -20, + -25 + ], + yomacron: [ + -25, + -25, + -20, + -20, + -25 + ], + yoslash: [ + -25, + -25, + -20, + -20, + -25 + ], + yotilde: [ + -25, + -25, + -20, + -20, + -25 + ], + yperiod: [ + -80, + -80, + -100, + -100, + -70, + -37, + -55, + -65 + ], + yacutea: [ + -30, + -30, + -20, + -20 + ], + yacuteaacute: [ + -30, + -30, + -20, + -20 + ], + yacuteabreve: [ + -30, + -30, + -20, + -20 + ], + yacuteacircumflex: [ + -30, + -30, + -20, + -20 + ], + yacuteadieresis: [ + -30, + -30, + -20, + -20 + ], + yacuteagrave: [ + -30, + -30, + -20, + -20 + ], + yacuteamacron: [ + -30, + -30, + -20, + -20 + ], + yacuteaogonek: [ + -30, + -30, + -20, + -20 + ], + yacutearing: [ + -30, + -30, + -20, + -20 + ], + yacuteatilde: [ + -30, + -30, + -20, + -20 + ], + yacutecomma: [ + -80, + -80, + -100, + -100, + -55, + -37, + -55, + -65 + ], + yacutee: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteeacute: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteecaron: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteecircumflex: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteedieresis: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteedotaccent: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteegrave: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteemacron: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteeogonek: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteo: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteoacute: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteocircumflex: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteodieresis: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteograve: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteohungarumlaut: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteomacron: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteoslash: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteotilde: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteperiod: [ + -80, + -80, + -100, + -100, + -70, + -37, + -55, + -65 + ], + ydieresisa: [ + -30, + -30, + -20, + -20 + ], + ydieresisaacute: [ + -30, + -30, + -20, + -20 + ], + ydieresisabreve: [ + -30, + -30, + -20, + -20 + ], + ydieresisacircumflex: [ + -30, + -30, + -20, + -20 + ], + ydieresisadieresis: [ + -30, + -30, + -20, + -20 + ], + ydieresisagrave: [ + -30, + -30, + -20, + -20 + ], + ydieresisamacron: [ + -30, + -30, + -20, + -20 + ], + ydieresisaogonek: [ + -30, + -30, + -20, + -20 + ], + ydieresisaring: [ + -30, + -30, + -20, + -20 + ], + ydieresisatilde: [ + -30, + -30, + -20, + -20 + ], + ydieresiscomma: [ + -80, + -80, + -100, + -100, + -55, + -37, + -55, + -65 + ], + ydieresise: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresiseacute: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisecaron: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisecircumflex: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisedieresis: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisedotaccent: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisegrave: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisemacron: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresiseogonek: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresiso: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisoacute: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisocircumflex: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisodieresis: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisograve: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisohungarumlaut: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisomacron: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisoslash: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisotilde: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisperiod: [ + -80, + -80, + -100, + -100, + -70, + -37, + -55, + -65 + ], + ze: [ + 10, + 10, + -15, + -15 + ], + zeacute: [ + 10, + 10, + -15, + -15 + ], + zecaron: [ + 10, + 10, + -15, + -15 + ], + zecircumflex: [ + 10, + 10, + -15, + -15 + ], + zedieresis: [ + 10, + 10, + -15, + -15 + ], + zedotaccent: [ + 10, + 10, + -15, + -15 + ], + zegrave: [ + 10, + 10, + -15, + -15 + ], + zemacron: [ + 10, + 10, + -15, + -15 + ], + zeogonek: [ + 10, + 10, + -15, + -15 + ], + zacutee: [ + 10, + 10, + -15, + -15 + ], + zacuteeacute: [ + 10, + 10, + -15, + -15 + ], + zacuteecaron: [ + 10, + 10, + -15, + -15 + ], + zacuteecircumflex: [ + 10, + 10, + -15, + -15 + ], + zacuteedieresis: [ + 10, + 10, + -15, + -15 + ], + zacuteedotaccent: [ + 10, + 10, + -15, + -15 + ], + zacuteegrave: [ + 10, + 10, + -15, + -15 + ], + zacuteemacron: [ + 10, + 10, + -15, + -15 + ], + zacuteeogonek: [ + 10, + 10, + -15, + -15 + ], + zcarone: [ + 10, + 10, + -15, + -15 + ], + zcaroneacute: [ + 10, + 10, + -15, + -15 + ], + zcaronecaron: [ + 10, + 10, + -15, + -15 + ], + zcaronecircumflex: [ + 10, + 10, + -15, + -15 + ], + zcaronedieresis: [ + 10, + 10, + -15, + -15 + ], + zcaronedotaccent: [ + 10, + 10, + -15, + -15 + ], + zcaronegrave: [ + 10, + 10, + -15, + -15 + ], + zcaronemacron: [ + 10, + 10, + -15, + -15 + ], + zcaroneogonek: [ + 10, + 10, + -15, + -15 + ], + zdotaccente: [ + 10, + 10, + -15, + -15 + ], + zdotaccenteacute: [ + 10, + 10, + -15, + -15 + ], + zdotaccentecaron: [ + 10, + 10, + -15, + -15 + ], + zdotaccentecircumflex: [ + 10, + 10, + -15, + -15 + ], + zdotaccentedieresis: [ + 10, + 10, + -15, + -15 + ], + zdotaccentedotaccent: [ + 10, + 10, + -15, + -15 + ], + zdotaccentegrave: [ + 10, + 10, + -15, + -15 + ], + zdotaccentemacron: [ + 10, + 10, + -15, + -15 + ], + zdotaccenteogonek: [ + 10, + 10, + -15, + -15 + ], + Bcomma: [ + 0, + 0, + -20, + -20 + ], + Bperiod: [ + 0, + 0, + -20, + -20 + ], + Ccomma: [ + 0, + 0, + -30, + -30 + ], + Cperiod: [ + 0, + 0, + -30, + -30 + ], + Cacutecomma: [ + 0, + 0, + -30, + -30 + ], + Cacuteperiod: [ + 0, + 0, + -30, + -30 + ], + Ccaroncomma: [ + 0, + 0, + -30, + -30 + ], + Ccaronperiod: [ + 0, + 0, + -30, + -30 + ], + Ccedillacomma: [ + 0, + 0, + -30, + -30 + ], + Ccedillaperiod: [ + 0, + 0, + -30, + -30 + ], + Fe: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Feacute: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fecaron: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fecircumflex: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fedieresis: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fedotaccent: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fegrave: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Femacron: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Feogonek: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fo: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Foacute: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Focircumflex: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fodieresis: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fograve: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fohungarumlaut: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fomacron: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Foslash: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fotilde: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fr: [ + 0, + 0, + -45, + -45, + 0, + -50, + -55 + ], + Fracute: [ + 0, + 0, + -45, + -45, + 0, + -50, + -55 + ], + Frcaron: [ + 0, + 0, + -45, + -45, + 0, + -50, + -55 + ], + Frcommaaccent: [ + 0, + 0, + -45, + -45, + 0, + -50, + -55 + ], + Ja: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jaacute: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jabreve: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jacircumflex: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jadieresis: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jagrave: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jamacron: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jaogonek: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jaring: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jatilde: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + LcaronT: [ + 0, + 0, + -110, + -110 + ], + LcaronTcaron: [ + 0, + 0, + -110, + -110 + ], + LcaronTcommaaccent: [ + 0, + 0, + -110, + -110 + ], + LcaronV: [ + 0, + 0, + -110, + -110 + ], + LcaronW: [ + 0, + 0, + -70, + -70 + ], + LcaronY: [ + 0, + 0, + -140, + -140 + ], + LcaronYacute: [ + 0, + 0, + -140, + -140 + ], + LcaronYdieresis: [ + 0, + 0, + -140, + -140 + ], + Lcaronquotedblright: [ + 0, + 0, + -140, + -140 + ], + Lcaronquoteright: [ + 0, + 0, + -160, + -160, + 0, + 0, + 0, + -92 + ], + Lcarony: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -55 + ], + Lcaronyacute: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -55 + ], + Lcaronydieresis: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -55 + ], + Scomma: [ + 0, + 0, + -20, + -20 + ], + Speriod: [ + 0, + 0, + -20, + -20 + ], + Sacutecomma: [ + 0, + 0, + -20, + -20 + ], + Sacuteperiod: [ + 0, + 0, + -20, + -20 + ], + Scaroncomma: [ + 0, + 0, + -20, + -20 + ], + Scaronperiod: [ + 0, + 0, + -20, + -20 + ], + Scedillacomma: [ + 0, + 0, + -20, + -20 + ], + Scedillaperiod: [ + 0, + 0, + -20, + -20 + ], + Scommaaccentcomma: [ + 0, + 0, + -20, + -20 + ], + Scommaaccentperiod: [ + 0, + 0, + -20, + -20 + ], + Trcaron: [ + 0, + 0, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcaronrcaron: [ + 0, + 0, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcommaaccentrcaron: [ + 0, + 0, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Yhyphen: [ + 0, + 0, + -140, + -140, + -92, + -92, + -74, + -111 + ], + Yi: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Yiacute: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Yiogonek: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Yacutehyphen: [ + 0, + 0, + -140, + -140, + -92, + -92, + -74, + -111 + ], + Yacutei: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Yacuteiacute: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Yacuteiogonek: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Ydieresishyphen: [ + 0, + 0, + -140, + -140, + -92, + -92, + -74, + -111 + ], + Ydieresisi: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Ydieresisiacute: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Ydieresisiogonek: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + bb: [ + 0, + 0, + -10, + -10, + -10, + -10 + ], + bcomma: [ + 0, + 0, + -40, + -40 + ], + bperiod: [ + 0, + 0, + -40, + -40, + -40, + -40, + -40, + -40 + ], + ccomma: [ + 0, + 0, + -15, + -15 + ], + cacutecomma: [ + 0, + 0, + -15, + -15 + ], + ccaroncomma: [ + 0, + 0, + -15, + -15 + ], + ccedillacomma: [ + 0, + 0, + -15, + -15 + ], + fa: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + faacute: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + fabreve: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + facircumflex: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + fadieresis: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + fagrave: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + famacron: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + faogonek: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + faring: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + fatilde: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + fdotlessi: [ + 0, + 0, + -28, + -28, + -35, + -30, + -60, + -50 + ], + gr: [ + 0, + 0, + -10, + -10 + ], + gracute: [ + 0, + 0, + -10, + -10 + ], + grcaron: [ + 0, + 0, + -10, + -10 + ], + grcommaaccent: [ + 0, + 0, + -10, + -10 + ], + gbrever: [ + 0, + 0, + -10, + -10 + ], + gbreveracute: [ + 0, + 0, + -10, + -10 + ], + gbrevercaron: [ + 0, + 0, + -10, + -10 + ], + gbrevercommaaccent: [ + 0, + 0, + -10, + -10 + ], + gcommaaccentr: [ + 0, + 0, + -10, + -10 + ], + gcommaaccentracute: [ + 0, + 0, + -10, + -10 + ], + gcommaaccentrcaron: [ + 0, + 0, + -10, + -10 + ], + gcommaaccentrcommaaccent: [ + 0, + 0, + -10, + -10 + ], + ke: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + keacute: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kecaron: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kecircumflex: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kedieresis: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kedotaccent: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kegrave: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kemacron: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + keogonek: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccente: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccenteacute: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentecaron: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentecircumflex: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentedieresis: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentedotaccent: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentegrave: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentemacron: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccenteogonek: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + ocomma: [ + 0, + 0, + -40, + -40 + ], + operiod: [ + 0, + 0, + -40, + -40 + ], + oacutecomma: [ + 0, + 0, + -40, + -40 + ], + oacuteperiod: [ + 0, + 0, + -40, + -40 + ], + ocircumflexcomma: [ + 0, + 0, + -40, + -40 + ], + ocircumflexperiod: [ + 0, + 0, + -40, + -40 + ], + odieresiscomma: [ + 0, + 0, + -40, + -40 + ], + odieresisperiod: [ + 0, + 0, + -40, + -40 + ], + ogravecomma: [ + 0, + 0, + -40, + -40 + ], + ograveperiod: [ + 0, + 0, + -40, + -40 + ], + ohungarumlautcomma: [ + 0, + 0, + -40, + -40 + ], + ohungarumlautperiod: [ + 0, + 0, + -40, + -40 + ], + omacroncomma: [ + 0, + 0, + -40, + -40 + ], + omacronperiod: [ + 0, + 0, + -40, + -40 + ], + oslasha: [ + 0, + 0, + -55, + -55 + ], + oslashaacute: [ + 0, + 0, + -55, + -55 + ], + oslashabreve: [ + 0, + 0, + -55, + -55 + ], + oslashacircumflex: [ + 0, + 0, + -55, + -55 + ], + oslashadieresis: [ + 0, + 0, + -55, + -55 + ], + oslashagrave: [ + 0, + 0, + -55, + -55 + ], + oslashamacron: [ + 0, + 0, + -55, + -55 + ], + oslashaogonek: [ + 0, + 0, + -55, + -55 + ], + oslasharing: [ + 0, + 0, + -55, + -55 + ], + oslashatilde: [ + 0, + 0, + -55, + -55 + ], + oslashb: [ + 0, + 0, + -55, + -55 + ], + oslashc: [ + 0, + 0, + -55, + -55 + ], + oslashcacute: [ + 0, + 0, + -55, + -55 + ], + oslashccaron: [ + 0, + 0, + -55, + -55 + ], + oslashccedilla: [ + 0, + 0, + -55, + -55 + ], + oslashcomma: [ + 0, + 0, + -95, + -95 + ], + oslashd: [ + 0, + 0, + -55, + -55 + ], + oslashdcroat: [ + 0, + 0, + -55, + -55 + ], + oslashe: [ + 0, + 0, + -55, + -55 + ], + oslasheacute: [ + 0, + 0, + -55, + -55 + ], + oslashecaron: [ + 0, + 0, + -55, + -55 + ], + oslashecircumflex: [ + 0, + 0, + -55, + -55 + ], + oslashedieresis: [ + 0, + 0, + -55, + -55 + ], + oslashedotaccent: [ + 0, + 0, + -55, + -55 + ], + oslashegrave: [ + 0, + 0, + -55, + -55 + ], + oslashemacron: [ + 0, + 0, + -55, + -55 + ], + oslasheogonek: [ + 0, + 0, + -55, + -55 + ], + oslashf: [ + 0, + 0, + -55, + -55 + ], + oslashg: [ + 0, + 0, + -55, + -55, + 0, + 0, + -10 + ], + oslashgbreve: [ + 0, + 0, + -55, + -55, + 0, + 0, + -10 + ], + oslashgcommaaccent: [ + 0, + 0, + -55, + -55, + 0, + 0, + -10 + ], + oslashh: [ + 0, + 0, + -55, + -55 + ], + oslashi: [ + 0, + 0, + -55, + -55 + ], + oslashiacute: [ + 0, + 0, + -55, + -55 + ], + oslashicircumflex: [ + 0, + 0, + -55, + -55 + ], + oslashidieresis: [ + 0, + 0, + -55, + -55 + ], + oslashigrave: [ + 0, + 0, + -55, + -55 + ], + oslashimacron: [ + 0, + 0, + -55, + -55 + ], + oslashiogonek: [ + 0, + 0, + -55, + -55 + ], + oslashj: [ + 0, + 0, + -55, + -55 + ], + oslashk: [ + 0, + 0, + -55, + -55 + ], + oslashkcommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslashl: [ + 0, + 0, + -55, + -55 + ], + oslashlacute: [ + 0, + 0, + -55, + -55 + ], + oslashlcommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslashlslash: [ + 0, + 0, + -55, + -55 + ], + oslashm: [ + 0, + 0, + -55, + -55 + ], + oslashn: [ + 0, + 0, + -55, + -55 + ], + oslashnacute: [ + 0, + 0, + -55, + -55 + ], + oslashncaron: [ + 0, + 0, + -55, + -55 + ], + oslashncommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslashntilde: [ + 0, + 0, + -55, + -55 + ], + oslasho: [ + 0, + 0, + -55, + -55 + ], + oslashoacute: [ + 0, + 0, + -55, + -55 + ], + oslashocircumflex: [ + 0, + 0, + -55, + -55 + ], + oslashodieresis: [ + 0, + 0, + -55, + -55 + ], + oslashograve: [ + 0, + 0, + -55, + -55 + ], + oslashohungarumlaut: [ + 0, + 0, + -55, + -55 + ], + oslashomacron: [ + 0, + 0, + -55, + -55 + ], + oslashoslash: [ + 0, + 0, + -55, + -55 + ], + oslashotilde: [ + 0, + 0, + -55, + -55 + ], + oslashp: [ + 0, + 0, + -55, + -55 + ], + oslashperiod: [ + 0, + 0, + -95, + -95 + ], + oslashq: [ + 0, + 0, + -55, + -55 + ], + oslashr: [ + 0, + 0, + -55, + -55 + ], + oslashracute: [ + 0, + 0, + -55, + -55 + ], + oslashrcaron: [ + 0, + 0, + -55, + -55 + ], + oslashrcommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslashs: [ + 0, + 0, + -55, + -55 + ], + oslashsacute: [ + 0, + 0, + -55, + -55 + ], + oslashscaron: [ + 0, + 0, + -55, + -55 + ], + oslashscedilla: [ + 0, + 0, + -55, + -55 + ], + oslashscommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslasht: [ + 0, + 0, + -55, + -55 + ], + oslashtcommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslashu: [ + 0, + 0, + -55, + -55 + ], + oslashuacute: [ + 0, + 0, + -55, + -55 + ], + oslashucircumflex: [ + 0, + 0, + -55, + -55 + ], + oslashudieresis: [ + 0, + 0, + -55, + -55 + ], + oslashugrave: [ + 0, + 0, + -55, + -55 + ], + oslashuhungarumlaut: [ + 0, + 0, + -55, + -55 + ], + oslashumacron: [ + 0, + 0, + -55, + -55 + ], + oslashuogonek: [ + 0, + 0, + -55, + -55 + ], + oslashuring: [ + 0, + 0, + -55, + -55 + ], + oslashz: [ + 0, + 0, + -55, + -55 + ], + oslashzacute: [ + 0, + 0, + -55, + -55 + ], + oslashzcaron: [ + 0, + 0, + -55, + -55 + ], + oslashzdotaccent: [ + 0, + 0, + -55, + -55 + ], + otildecomma: [ + 0, + 0, + -40, + -40 + ], + otildeperiod: [ + 0, + 0, + -40, + -40 + ], + pcomma: [ + 0, + 0, + -35, + -35 + ], + pperiod: [ + 0, + 0, + -35, + -35 + ], + ra: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + raacute: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rabreve: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racircumflex: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + radieresis: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + ragrave: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + ramacron: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + raogonek: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + raring: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + ratilde: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcolon: [ + 0, + 0, + 30, + 30 + ], + ri: [ + 0, + 0, + 15, + 15 + ], + riacute: [ + 0, + 0, + 15, + 15 + ], + ricircumflex: [ + 0, + 0, + 15, + 15 + ], + ridieresis: [ + 0, + 0, + 15, + 15 + ], + rigrave: [ + 0, + 0, + 15, + 15 + ], + rimacron: [ + 0, + 0, + 15, + 15 + ], + riogonek: [ + 0, + 0, + 15, + 15 + ], + rk: [ + 0, + 0, + 15, + 15 + ], + rkcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rl: [ + 0, + 0, + 15, + 15 + ], + rlacute: [ + 0, + 0, + 15, + 15 + ], + rlcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rlslash: [ + 0, + 0, + 15, + 15 + ], + rm: [ + 0, + 0, + 25, + 25 + ], + rn: [ + 0, + 0, + 25, + 25, + -15 + ], + rnacute: [ + 0, + 0, + 25, + 25, + -15 + ], + rncaron: [ + 0, + 0, + 25, + 25, + -15 + ], + rncommaaccent: [ + 0, + 0, + 25, + 25, + -15 + ], + rntilde: [ + 0, + 0, + 25, + 25, + -15 + ], + rp: [ + 0, + 0, + 30, + 30, + -10 + ], + rsemicolon: [ + 0, + 0, + 30, + 30 + ], + ru: [ + 0, + 0, + 15, + 15 + ], + ruacute: [ + 0, + 0, + 15, + 15 + ], + rucircumflex: [ + 0, + 0, + 15, + 15 + ], + rudieresis: [ + 0, + 0, + 15, + 15 + ], + rugrave: [ + 0, + 0, + 15, + 15 + ], + ruhungarumlaut: [ + 0, + 0, + 15, + 15 + ], + rumacron: [ + 0, + 0, + 15, + 15 + ], + ruogonek: [ + 0, + 0, + 15, + 15 + ], + ruring: [ + 0, + 0, + 15, + 15 + ], + racutea: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteaacute: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteabreve: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteacircumflex: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteadieresis: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteagrave: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteamacron: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteaogonek: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racutearing: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteatilde: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racutecolon: [ + 0, + 0, + 30, + 30 + ], + racutei: [ + 0, + 0, + 15, + 15 + ], + racuteiacute: [ + 0, + 0, + 15, + 15 + ], + racuteicircumflex: [ + 0, + 0, + 15, + 15 + ], + racuteidieresis: [ + 0, + 0, + 15, + 15 + ], + racuteigrave: [ + 0, + 0, + 15, + 15 + ], + racuteimacron: [ + 0, + 0, + 15, + 15 + ], + racuteiogonek: [ + 0, + 0, + 15, + 15 + ], + racutek: [ + 0, + 0, + 15, + 15 + ], + racutekcommaaccent: [ + 0, + 0, + 15, + 15 + ], + racutel: [ + 0, + 0, + 15, + 15 + ], + racutelacute: [ + 0, + 0, + 15, + 15 + ], + racutelcommaaccent: [ + 0, + 0, + 15, + 15 + ], + racutelslash: [ + 0, + 0, + 15, + 15 + ], + racutem: [ + 0, + 0, + 25, + 25 + ], + racuten: [ + 0, + 0, + 25, + 25, + -15 + ], + racutenacute: [ + 0, + 0, + 25, + 25, + -15 + ], + racutencaron: [ + 0, + 0, + 25, + 25, + -15 + ], + racutencommaaccent: [ + 0, + 0, + 25, + 25, + -15 + ], + racutentilde: [ + 0, + 0, + 25, + 25, + -15 + ], + racutep: [ + 0, + 0, + 30, + 30, + -10 + ], + racutesemicolon: [ + 0, + 0, + 30, + 30 + ], + racuteu: [ + 0, + 0, + 15, + 15 + ], + racuteuacute: [ + 0, + 0, + 15, + 15 + ], + racuteucircumflex: [ + 0, + 0, + 15, + 15 + ], + racuteudieresis: [ + 0, + 0, + 15, + 15 + ], + racuteugrave: [ + 0, + 0, + 15, + 15 + ], + racuteuhungarumlaut: [ + 0, + 0, + 15, + 15 + ], + racuteumacron: [ + 0, + 0, + 15, + 15 + ], + racuteuogonek: [ + 0, + 0, + 15, + 15 + ], + racuteuring: [ + 0, + 0, + 15, + 15 + ], + rcarona: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronaacute: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronabreve: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronacircumflex: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronadieresis: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronagrave: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronamacron: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronaogonek: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronaring: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronatilde: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaroncolon: [ + 0, + 0, + 30, + 30 + ], + rcaroni: [ + 0, + 0, + 15, + 15 + ], + rcaroniacute: [ + 0, + 0, + 15, + 15 + ], + rcaronicircumflex: [ + 0, + 0, + 15, + 15 + ], + rcaronidieresis: [ + 0, + 0, + 15, + 15 + ], + rcaronigrave: [ + 0, + 0, + 15, + 15 + ], + rcaronimacron: [ + 0, + 0, + 15, + 15 + ], + rcaroniogonek: [ + 0, + 0, + 15, + 15 + ], + rcaronk: [ + 0, + 0, + 15, + 15 + ], + rcaronkcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rcaronl: [ + 0, + 0, + 15, + 15 + ], + rcaronlacute: [ + 0, + 0, + 15, + 15 + ], + rcaronlcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rcaronlslash: [ + 0, + 0, + 15, + 15 + ], + rcaronm: [ + 0, + 0, + 25, + 25 + ], + rcaronn: [ + 0, + 0, + 25, + 25, + -15 + ], + rcaronnacute: [ + 0, + 0, + 25, + 25, + -15 + ], + rcaronncaron: [ + 0, + 0, + 25, + 25, + -15 + ], + rcaronncommaaccent: [ + 0, + 0, + 25, + 25, + -15 + ], + rcaronntilde: [ + 0, + 0, + 25, + 25, + -15 + ], + rcaronp: [ + 0, + 0, + 30, + 30, + -10 + ], + rcaronsemicolon: [ + 0, + 0, + 30, + 30 + ], + rcaronu: [ + 0, + 0, + 15, + 15 + ], + rcaronuacute: [ + 0, + 0, + 15, + 15 + ], + rcaronucircumflex: [ + 0, + 0, + 15, + 15 + ], + rcaronudieresis: [ + 0, + 0, + 15, + 15 + ], + rcaronugrave: [ + 0, + 0, + 15, + 15 + ], + rcaronuhungarumlaut: [ + 0, + 0, + 15, + 15 + ], + rcaronumacron: [ + 0, + 0, + 15, + 15 + ], + rcaronuogonek: [ + 0, + 0, + 15, + 15 + ], + rcaronuring: [ + 0, + 0, + 15, + 15 + ], + rcommaaccenta: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentaacute: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentabreve: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentacircumflex: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentadieresis: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentagrave: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentamacron: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentaogonek: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentaring: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentatilde: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentcolon: [ + 0, + 0, + 30, + 30 + ], + rcommaaccenti: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentiacute: [ + 0, + 0, + 15, + 15 + ], + rcommaaccenticircumflex: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentidieresis: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentigrave: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentimacron: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentiogonek: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentk: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentkcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentl: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentlacute: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentlcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentlslash: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentm: [ + 0, + 0, + 25, + 25 + ], + rcommaaccentn: [ + 0, + 0, + 25, + 25, + -15 + ], + rcommaaccentnacute: [ + 0, + 0, + 25, + 25, + -15 + ], + rcommaaccentncaron: [ + 0, + 0, + 25, + 25, + -15 + ], + rcommaaccentncommaaccent: [ + 0, + 0, + 25, + 25, + -15 + ], + rcommaaccentntilde: [ + 0, + 0, + 25, + 25, + -15 + ], + rcommaaccentp: [ + 0, + 0, + 30, + 30, + -10 + ], + rcommaaccentsemicolon: [ + 0, + 0, + 30, + 30 + ], + rcommaaccentu: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentuacute: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentucircumflex: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentudieresis: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentugrave: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentuhungarumlaut: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentumacron: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentuogonek: [ + 0, + 0, + 15, + 15 + ], + rcommaaccenturing: [ + 0, + 0, + 15, + 15 + ], + scomma: [ + 0, + 0, + -15, + -15 + ], + speriod: [ + 0, + 0, + -15, + -15 + ], + sacutecomma: [ + 0, + 0, + -15, + -15 + ], + sacuteperiod: [ + 0, + 0, + -15, + -15 + ], + scaroncomma: [ + 0, + 0, + -15, + -15 + ], + scaronperiod: [ + 0, + 0, + -15, + -15 + ], + scedillacomma: [ + 0, + 0, + -15, + -15 + ], + scedillaperiod: [ + 0, + 0, + -15, + -15 + ], + scommaaccentcomma: [ + 0, + 0, + -15, + -15 + ], + scommaaccentperiod: [ + 0, + 0, + -15, + -15 + ], + ve: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + veacute: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vecaron: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vecircumflex: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vedieresis: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vedotaccent: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vegrave: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vemacron: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + veogonek: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + wa: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + waacute: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + wabreve: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + wacircumflex: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + wadieresis: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + wagrave: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + wamacron: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + waogonek: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + waring: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + watilde: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + we: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + weacute: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wecaron: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wecircumflex: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wedieresis: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wedotaccent: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wegrave: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wemacron: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + weogonek: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + zo: [ + 0, + 0, + -15, + -15 + ], + zoacute: [ + 0, + 0, + -15, + -15 + ], + zocircumflex: [ + 0, + 0, + -15, + -15 + ], + zodieresis: [ + 0, + 0, + -15, + -15 + ], + zograve: [ + 0, + 0, + -15, + -15 + ], + zohungarumlaut: [ + 0, + 0, + -15, + -15 + ], + zomacron: [ + 0, + 0, + -15, + -15 + ], + zoslash: [ + 0, + 0, + -15, + -15 + ], + zotilde: [ + 0, + 0, + -15, + -15 + ], + zacuteo: [ + 0, + 0, + -15, + -15 + ], + zacuteoacute: [ + 0, + 0, + -15, + -15 + ], + zacuteocircumflex: [ + 0, + 0, + -15, + -15 + ], + zacuteodieresis: [ + 0, + 0, + -15, + -15 + ], + zacuteograve: [ + 0, + 0, + -15, + -15 + ], + zacuteohungarumlaut: [ + 0, + 0, + -15, + -15 + ], + zacuteomacron: [ + 0, + 0, + -15, + -15 + ], + zacuteoslash: [ + 0, + 0, + -15, + -15 + ], + zacuteotilde: [ + 0, + 0, + -15, + -15 + ], + zcarono: [ + 0, + 0, + -15, + -15 + ], + zcaronoacute: [ + 0, + 0, + -15, + -15 + ], + zcaronocircumflex: [ + 0, + 0, + -15, + -15 + ], + zcaronodieresis: [ + 0, + 0, + -15, + -15 + ], + zcaronograve: [ + 0, + 0, + -15, + -15 + ], + zcaronohungarumlaut: [ + 0, + 0, + -15, + -15 + ], + zcaronomacron: [ + 0, + 0, + -15, + -15 + ], + zcaronoslash: [ + 0, + 0, + -15, + -15 + ], + zcaronotilde: [ + 0, + 0, + -15, + -15 + ], + zdotaccento: [ + 0, + 0, + -15, + -15 + ], + zdotaccentoacute: [ + 0, + 0, + -15, + -15 + ], + zdotaccentocircumflex: [ + 0, + 0, + -15, + -15 + ], + zdotaccentodieresis: [ + 0, + 0, + -15, + -15 + ], + zdotaccentograve: [ + 0, + 0, + -15, + -15 + ], + zdotaccentohungarumlaut: [ + 0, + 0, + -15, + -15 + ], + zdotaccentomacron: [ + 0, + 0, + -15, + -15 + ], + zdotaccentoslash: [ + 0, + 0, + -15, + -15 + ], + zdotaccentotilde: [ + 0, + 0, + -15, + -15 + ], + Ap: [ + 0, + 0, + 0, + 0, + -25 + ], + Aquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Aacutep: [ + 0, + 0, + 0, + 0, + -25 + ], + Aacutequoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Abrevep: [ + 0, + 0, + 0, + 0, + -25 + ], + Abrevequoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Acircumflexp: [ + 0, + 0, + 0, + 0, + -25 + ], + Acircumflexquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Adieresisp: [ + 0, + 0, + 0, + 0, + -25 + ], + Adieresisquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Agravep: [ + 0, + 0, + 0, + 0, + -25 + ], + Agravequoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Amacronp: [ + 0, + 0, + 0, + 0, + -25 + ], + Amacronquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Aogonekp: [ + 0, + 0, + 0, + 0, + -25 + ], + Aogonekquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Aringp: [ + 0, + 0, + 0, + 0, + -25 + ], + Aringquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Atildep: [ + 0, + 0, + 0, + 0, + -25 + ], + Atildequoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Je: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jeacute: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jecaron: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jecircumflex: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jedieresis: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jedotaccent: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jegrave: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jemacron: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jeogonek: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jo: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Joacute: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jocircumflex: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jodieresis: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jograve: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Johungarumlaut: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jomacron: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Joslash: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jotilde: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + NA: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAacute: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAbreve: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAcircumflex: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAdieresis: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAgrave: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAmacron: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAogonek: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAring: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAtilde: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteA: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAacute: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAbreve: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAcircumflex: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAdieresis: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAgrave: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAmacron: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAogonek: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAring: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAtilde: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronA: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAacute: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAbreve: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAcircumflex: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAdieresis: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAgrave: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAmacron: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAogonek: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAring: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAtilde: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentA: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAacute: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAbreve: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAcircumflex: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAdieresis: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAgrave: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAmacron: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAogonek: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAring: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAtilde: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeA: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAacute: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAbreve: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAcircumflex: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAdieresis: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAgrave: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAmacron: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAogonek: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAring: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAtilde: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + Ti: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tiacute: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tiogonek: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcaroni: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcaroniacute: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcaroniogonek: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcommaaccenti: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcommaaccentiacute: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcommaaccentiogonek: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Vi: [ + 0, + 0, + 0, + 0, + -37, + -55, + -74, + -60 + ], + Viacute: [ + 0, + 0, + 0, + 0, + -37, + -55, + -74, + -60 + ], + Vicircumflex: [ + 0, + 0, + 0, + 0, + -37, + 0, + -34, + -20 + ], + Vidieresis: [ + 0, + 0, + 0, + 0, + -37, + 0, + -34, + -20 + ], + Vigrave: [ + 0, + 0, + 0, + 0, + -37, + 0, + -34, + -20 + ], + Vimacron: [ + 0, + 0, + 0, + 0, + -37, + 0, + -34, + -20 + ], + Viogonek: [ + 0, + 0, + 0, + 0, + -37, + -55, + -74, + -60 + ], + Wi: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -40 + ], + Wiacute: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -40 + ], + Wiogonek: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -40 + ], + fi: [ + 0, + 0, + 0, + 0, + -25, + 0, + -20, + -20 + ], + gperiod: [ + 0, + 0, + 0, + 0, + -15, + 0, + -15 + ], + gbreveperiod: [ + 0, + 0, + 0, + 0, + -15, + 0, + -15 + ], + gcommaaccentperiod: [ + 0, + 0, + 0, + 0, + -15, + 0, + -15 + ], + iv: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + iacutev: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + icircumflexv: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + idieresisv: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + igravev: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + imacronv: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + iogonekv: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + ky: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + kyacute: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + kydieresis: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + kcommaaccenty: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + kcommaaccentyacute: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + kcommaaccentydieresis: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + quotedblleftA: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAacute: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAbreve: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAcircumflex: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAdieresis: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAgrave: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAmacron: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAogonek: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAring: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAtilde: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftA: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAacute: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAbreve: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAcircumflex: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAdieresis: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAgrave: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAmacron: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAogonek: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAring: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAtilde: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + re: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + reacute: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + recaron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + recircumflex: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + redieresis: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + redotaccent: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + regrave: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + remacron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + reogonek: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racutee: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteeacute: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteecaron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteecircumflex: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteedieresis: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteedotaccent: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteegrave: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteemacron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteeogonek: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcarone: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaroneacute: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronecaron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronecircumflex: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronedieresis: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronedotaccent: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronegrave: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronemacron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaroneogonek: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccente: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccenteacute: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentecaron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentecircumflex: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentedieresis: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentedotaccent: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentegrave: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentemacron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccenteogonek: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + spaceA: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAacute: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAbreve: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAcircumflex: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAdieresis: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAgrave: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAmacron: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAogonek: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAring: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAtilde: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + Fi: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Fiacute: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Ficircumflex: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Fidieresis: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Figrave: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Fimacron: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Fiogonek: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + eb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + eacuteb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + ecaronb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + ecircumflexb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + edieresisb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + edotaccentb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + egraveb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + emacronb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + eogonekb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + ff: [ + 0, + 0, + 0, + 0, + 0, + -18, + -18, + -25 + ], + quoterightt: [ + 0, + 0, + 0, + 0, + 0, + -37, + -30, + -18 + ], + quoterighttcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + -37, + -30, + -18 + ], + Yicircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yidieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yigrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yimacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yacuteicircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yacuteidieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yacuteigrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yacuteimacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Ydieresisicircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Ydieresisidieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Ydieresisigrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Ydieresisimacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + eg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + egbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + egcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eacuteg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eacutegbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eacutegcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecarong: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecarongbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecarongcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecircumflexg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecircumflexgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecircumflexgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edieresisg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edieresisgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edieresisgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edotaccentg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edotaccentgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edotaccentgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + egraveg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + egravegbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + egravegcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + emacrong: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + emacrongbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + emacrongcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eogonekg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eogonekgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eogonekgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + fiogonek: [ + 0, + 0, + 0, + 0, + 0, + 0, + -20 + ], + gcomma: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + gbrevecomma: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentcomma: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + og: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ogbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ogcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + oacuteg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + oacutegbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + oacutegcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ocircumflexg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ocircumflexgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ocircumflexgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + odieresisg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + odieresisgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + odieresisgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ograveg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ogravegbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ogravegcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ohungarumlautg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ohungarumlautgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ohungarumlautgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + omacrong: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + omacrongbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + omacrongcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + otildeg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + otildegbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + otildegcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + fiacute: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -20 + ], + ga: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gaacute: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gabreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gacircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gadieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gagrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gamacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gaogonek: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + garing: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gatilde: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbrevea: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveaacute: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveabreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveacircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveadieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveagrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveamacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveaogonek: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbrevearing: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveatilde: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccenta: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentaacute: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentabreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentacircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentadieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentagrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentamacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentaogonek: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentaring: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentatilde: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ] +}; +var data = { + attributes: attributes, + glyphWidths: glyphWidths, + kernPairs: kernPairs +}; + +const initFont = font => { + return [font.FontName, { + attributes: font, + glyphWidths: {}, + kernPairs: {} + }]; +}; +const expandData = data => { + const { + attributes, + glyphWidths, + kernPairs + } = data; + const fonts = attributes.map(initFont); + Object.keys(glyphWidths).forEach(key => { + glyphWidths[key].forEach((value, index) => { + if (value) fonts[index][1].glyphWidths[key] = value; + }); + }); + Object.keys(kernPairs).forEach(key => { + kernPairs[key].forEach((value, index) => { + if (value) fonts[index][1].kernPairs[key] = value; + }); + }); + return Object.fromEntries(fonts); +}; + +const STANDARD_FONTS = expandData(data); +const createStandardFont = PDFFont => class StandardFont extends PDFFont { + constructor(document, name, id) { + super(); + this.document = document; + this.name = name; + this.id = id; + this.font = AFMFont.fromJson(STANDARD_FONTS[this.name]); + this.ascender = this.font.ascender; + this.descender = this.font.descender; + this.bbox = this.font.bbox; + this.lineGap = this.font.lineGap; + } + embed() { + this.dictionary.data = { + Type: 'Font', + BaseFont: this.name, + Subtype: 'Type1', + Encoding: 'WinAnsiEncoding' + }; + return this.dictionary.end(); + } + encode(text) { + const encoded = this.font.encodeText(text); + const glyphs = this.font.glyphsForString(`${text}`); + const advances = this.font.advancesForGlyphs(glyphs); + const positions = []; + for (let i = 0; i < glyphs.length; i++) { + const glyph = glyphs[i]; + positions.push({ + xAdvance: advances[i], + yAdvance: 0, + xOffset: 0, + yOffset: 0, + advanceWidth: this.font.widthOfGlyph(glyph) + }); + } + return [encoded, positions]; + } + widthOfString(string, size) { + const glyphs = this.font.glyphsForString(`${string}`); + const advances = this.font.advancesForGlyphs(glyphs); + let width = 0; + for (let advance of Array.from(advances)) { + width += advance; + } + const scale = size / 1000; + return width * scale; + } + static isStandardFont(name) { + return name in STANDARD_FONTS; + } +}; + +const toHex = function () { + for (var _len = arguments.length, codePoints = new Array(_len), _key = 0; _key < _len; _key++) { + codePoints[_key] = arguments[_key]; + } + const codes = Array.from(codePoints).map(code => `0000${code.toString(16)}`.slice(-4)); + return codes.join(''); +}; +const createEmbeddedFont = PDFFont => class EmbeddedFont extends PDFFont { + constructor(document, font, id) { + super(); + this.document = document; + this.font = font; + this.id = id; + this.subset = this.font.createSubset(); + this.unicode = [[0]]; + this.widths = [this.font.getGlyph(0).advanceWidth]; + this.name = this.font.postscriptName; + this.scale = 1000 / this.font.unitsPerEm; + this.ascender = this.font.ascent * this.scale; + this.descender = this.font.descent * this.scale; + this.xHeight = this.font.xHeight * this.scale; + this.capHeight = this.font.capHeight * this.scale; + this.lineGap = this.font.lineGap * this.scale; + this.bbox = this.font.bbox; + this.layoutCache = Object.create(null); + } + layoutRun(text, features) { + // passing LTR To force fontkit to not reverse the string + const run = this.font.layout(text, features, undefined, undefined, 'ltr'); + + // Normalize position values + for (let i = 0; i < run.positions.length; i++) { + const position = run.positions[i]; + for (let key in position) { + position[key] *= this.scale; + } + position.advanceWidth = run.glyphs[i].advanceWidth * this.scale; + } + return run; + } + layoutCached(text) { + let cached; + if (cached = this.layoutCache[text]) { + return cached; + } + const run = this.layoutRun(text); + this.layoutCache[text] = run; + return run; + } + layout(text, features, onlyWidth) { + // Skip the cache if any user defined features are applied + if (onlyWidth == null) { + onlyWidth = false; + } + if (features) { + return this.layoutRun(text, features); + } + const glyphs = onlyWidth ? null : []; + const positions = onlyWidth ? null : []; + let advanceWidth = 0; + + // Split the string by words to increase cache efficiency. + // For this purpose, spaces and tabs are a good enough delimeter. + let last = 0; + let index = 0; + while (index <= text.length) { + let needle; + if (index === text.length && last < index || (needle = text.charAt(index), [' ', '\t'].includes(needle))) { + const run = this.layoutCached(text.slice(last, ++index)); + if (!onlyWidth) { + glyphs.push(...Array.from(run.glyphs || [])); + positions.push(...Array.from(run.positions || [])); + } + advanceWidth += run.advanceWidth; + last = index; + } else { + index++; + } + } + return { + glyphs, + positions, + advanceWidth + }; + } + encode(text, features) { + const { + glyphs, + positions + } = this.layout(text, features); + const res = []; + for (let i = 0; i < glyphs.length; i++) { + const glyph = glyphs[i]; + const gid = this.subset.includeGlyph(glyph.id); + res.push(`0000${gid.toString(16)}`.slice(-4)); + if (this.widths[gid] == null) { + this.widths[gid] = glyph.advanceWidth * this.scale; + } + if (this.unicode[gid] == null) { + this.unicode[gid] = glyph.codePoints; + } + } + return [res, positions]; + } + widthOfString(string, size, features) { + const width = this.layout(string, features, true).advanceWidth; + const scale = size / 1000; + return width * scale; + } + embed() { + const isCFF = this.subset.cff != null; + const fontFile = this.document.ref(); + if (isCFF) { + fontFile.data.Subtype = 'CIDFontType0C'; + } + fontFile.end(this.subset.encode()); + const familyClass = ((this.font['OS/2'] != null ? this.font['OS/2'].sFamilyClass : undefined) || 0) >> 8; + let flags = 0; + if (this.font.post.isFixedPitch) { + flags |= 1 << 0; + } + if (1 <= familyClass && familyClass <= 7) { + flags |= 1 << 1; + } + flags |= 1 << 2; // assume the font uses non-latin characters + if (familyClass === 10) { + flags |= 1 << 3; + } + if (this.font.head.macStyle.italic) { + flags |= 1 << 6; + } + + // generate a random tag (6 uppercase letters. 65 is the char code for 'A') + const tag = [0, 1, 2, 3, 4, 5].map(() => String.fromCharCode(Math.random() * 26 + 65)).join(''); + const name = tag + '+' + this.font.postscriptName; + const { + bbox + } = this.font; + const descriptor = this.document.ref({ + Type: 'FontDescriptor', + FontName: name, + Flags: flags, + FontBBox: [bbox.minX * this.scale, bbox.minY * this.scale, bbox.maxX * this.scale, bbox.maxY * this.scale], + ItalicAngle: this.font.italicAngle, + Ascent: this.ascender, + Descent: this.descender, + CapHeight: (this.font.capHeight || this.font.ascent) * this.scale, + XHeight: (this.font.xHeight || 0) * this.scale, + StemV: 0 + }); // not sure how to calculate this + + if (isCFF) { + descriptor.data.FontFile3 = fontFile; + } else { + descriptor.data.FontFile2 = fontFile; + } + descriptor.end(); + const descendantFontData = { + Type: 'Font', + Subtype: 'CIDFontType0', + BaseFont: name, + CIDSystemInfo: { + Registry: new String('Adobe'), + Ordering: new String('Identity'), + Supplement: 0 + }, + FontDescriptor: descriptor, + W: [0, this.widths] + }; + if (!isCFF) { + descendantFontData.Subtype = 'CIDFontType2'; + descendantFontData.CIDToGIDMap = 'Identity'; + } + const descendantFont = this.document.ref(descendantFontData); + descendantFont.end(); + this.dictionary.data = { + Type: 'Font', + Subtype: 'Type0', + BaseFont: name, + Encoding: 'Identity-H', + DescendantFonts: [descendantFont], + ToUnicode: this.toUnicodeCmap() + }; + return this.dictionary.end(); + } + + // Maps the glyph ids encoded in the PDF back to unicode strings + // Because of ligature substitutions and the like, there may be one or more + // unicode characters represented by each glyph. + toUnicodeCmap() { + const cmap = this.document.ref(); + let entries = []; + let unicodeMap = '/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo <<\n /Registry (Adobe)\n /Ordering (UCS)\n /Supplement 0\n>> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000>\nendcodespacerange'; + for (let [index, codePoints] of this.unicode.entries()) { + const encoded = []; + if (entries.length >= 100) { + unicodeMap += '\n' + entries.length + ' beginbfchar\n' + entries.join('\n') + '\nendbfchar'; + entries = []; + } + // encode codePoints to utf16 + for (let value of codePoints) { + if (value > 0xffff) { + value -= 0x10000; + encoded.push(toHex(value >>> 10 & 0x3ff | 0xd800)); + value = 0xdc00 | value & 0x3ff; + } + encoded.push(toHex(value)); + } + entries.push('<' + toHex(index) + '>' + '<' + encoded.join(' ') + '>'); + } + if (entries.length) { + unicodeMap += '\n' + entries.length + ' beginbfchar\n' + entries.join('\n') + '\nendbfchar\n'; + } + unicodeMap += 'endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend'; + cmap.end(unicodeMap); + return cmap; + } +}; + +class PDFFont { + static open(document, src, family, id) { + let font; + if (typeof src === 'string') { + if (StandardFont.isStandardFont(src)) { + return new StandardFont(document, src, id); + } + { + throw new Error(`Can't open ${src} in browser build`); + } + } else if (src instanceof Uint8Array) { + font = fontkit.create(src, family); + } else if (src instanceof ArrayBuffer) { + font = fontkit.create(new Uint8Array(src), family); + } else if (typeof src === 'object') { + font = src; + } + if (font == null) { + throw new Error('Not a supported font format or standard PDF font.'); + } + return new EmbeddedFont(document, font, id); + } + encode() { + throw new Error('Must be implemented by subclasses'); + } + widthOfString() { + throw new Error('Must be implemented by subclasses'); + } + ref() { + return this.dictionary != null ? this.dictionary : this.dictionary = this.document.ref(); + } + finalize() { + if (this.embedded || this.dictionary == null) { + return; + } + this.embed(); + return this.embedded = true; + } + embed() { + throw new Error('Must be implemented by subclasses'); + } + lineHeight(size, includeGap) { + if (includeGap == null) { + includeGap = false; + } + const gap = includeGap ? this.lineGap : 0; + return (this.ascender + gap - this.descender) / 1000 * size; + } +} +const StandardFont = createStandardFont(PDFFont); +const EmbeddedFont = createEmbeddedFont(PDFFont); + +var FontsMixin = { + initFonts() { + // Lookup table for embedded fonts + this._fontFamilies = {}; + this._fontCount = 0; + + // Font state + this._fontSize = 12; + this._font = null; + this._registeredFonts = {}; + + // Set the default font + return this.font('Helvetica'); + }, + font(src, family, size) { + let cacheKey; + let font; + if (typeof family === 'number') { + size = family; + family = null; + } + + // check registered fonts if src is a string + if (typeof src === 'string' && this._registeredFonts[src]) { + cacheKey = src; + ({ + src, + family + } = this._registeredFonts[src]); + } else { + cacheKey = family || src; + if (typeof cacheKey !== 'string') { + cacheKey = null; + } + } + if (size != null) { + this.fontSize(size); + } + + // fast path: check if the font is already in the PDF + if (font = this._fontFamilies[cacheKey]) { + this._font = font; + return this; + } + + // load the font + const id = `F${++this._fontCount}`; + this._font = PDFFont.open(this, src, family, id); + + // check for existing font familes with the same name already in the PDF + // useful if the font was passed as a buffer + if (font = this._fontFamilies[this._font.name]) { + this._font = font; + return this; + } + + // save the font for reuse later + if (cacheKey) { + this._fontFamilies[cacheKey] = this._font; + } + if (this._font.name) { + this._fontFamilies[this._font.name] = this._font; + } + return this; + }, + fontSize(_fontSize) { + this._fontSize = _fontSize; + return this; + }, + currentLineHeight(includeGap) { + if (includeGap == null) { + includeGap = false; + } + return this._font.lineHeight(this._fontSize, includeGap); + }, + registerFont(name, src, family) { + this._registeredFonts[name] = { + src, + family + }; + return this; + } +}; + +function PDFNumber(n) { + // PDF numbers are strictly 32bit + // so convert this number to the nearest 32bit number + // @see ISO 32000-1 Annex C.2 (real numbers) + return Math.fround(n); +} + +/** + * Measurement of size + * + * @typedef {number | `${number}` | `${number}${'em' | 'in' | 'px' | 'cm' | 'mm' | 'pc' | 'ex' | 'ch' | 'rem' | 'vw' | 'vmin' | 'vmax' | '%' | 'pt'}`} Size + */ + +/** + * Measurement of how wide something is, false means 0 and true means 1 + * + * @typedef {Size | boolean} Wideness + */ + +/** + * Side definitions + * - To define all sides, use a single value + * - To define up-down left-right, use a `[Y, X]` array + * - To define each side, use `[top, right, bottom, left]` array + * - Or `{vertical: SideValue, horizontal: SideValue}` + * - Or `{top: SideValue, right: SideValue, bottom: SideValue, left: SideValue}` + * + * @template T + * @typedef {T | [T, T] | [T, T, T, T] | { vertical: T; horizontal: T } | ExpandedSideDefinition} SideDefinition + **/ + +/** + * @template T + * @typedef {{ top: T; right: T; bottom: T; left: T }} ExpandedSideDefinition + */ + +/** + * Convert any side definition into a static structure + * + * @template S + * @template D + * @template O + * @template {S | D} T + * @param {SideDefinition} sides - The sides to convert + * @param {SideDefinition} defaultDefinition - The value to use when no definition is provided + * @param {function(T): O} transformer - The transformation to apply to the sides once normalized + * @returns {ExpandedSideDefinition} + */ +function normalizeSides(sides, defaultDefinition, transformer) { + if (defaultDefinition === void 0) { + defaultDefinition = undefined; + } + if (transformer === void 0) { + transformer = v => v; + } + if (sides === undefined || sides === null || typeof sides === 'object' && Object.keys(sides).length === 0) { + sides = defaultDefinition; + } + if (typeof sides !== 'object' || sides === null) { + sides = [sides, sides, sides, sides]; + } + if (Array.isArray(sides)) { + if (sides.length === 2) { + sides = { + vertical: sides[0], + horizontal: sides[1] + }; + } else { + sides = { + top: sides[0], + right: sides[1], + bottom: sides[2], + left: sides[3] + }; + } + } + if ('vertical' in sides || 'horizontal' in sides) { + sides = { + top: sides.vertical, + right: sides.horizontal, + bottom: sides.vertical, + left: sides.horizontal + }; + } + return { + top: transformer(sides.top), + right: transformer(sides.right), + bottom: transformer(sides.bottom), + left: transformer(sides.left) + }; +} + +/** + * Get cosine in degrees of a + * + * Rounding errors are handled + * @param a + * @returns {number} + */ +function cosine(a) { + if (a === 0) return 1; + if (a === 90) return 0; + if (a === 180) return -1; + if (a === 270) return 0; + return Math.cos(a * Math.PI / 180); +} + +/** + * Get sine in degrees of a + * + * Rounding errors are handled + * @param a + * @returns {number} + */ +function sine(a) { + if (a === 0) return 0; + if (a === 90) return 1; + if (a === 180) return 0; + if (a === 270) return -1; + return Math.sin(a * Math.PI / 180); +} + +const SOFT_HYPHEN = '\u00AD'; +const HYPHEN = '-'; +class LineWrapper extends EventEmitter { + constructor(document, options) { + super(); + this.document = document; + this.horizontalScaling = options.horizontalScaling || 100; + this.indent = (options.indent || 0) * this.horizontalScaling / 100; + this.characterSpacing = (options.characterSpacing || 0) * this.horizontalScaling / 100; + this.wordSpacing = (options.wordSpacing === 0) * this.horizontalScaling / 100; + this.columns = options.columns || 1; + this.columnGap = (options.columnGap != null ? options.columnGap : 18) * this.horizontalScaling / 100; // 1/4 inch + this.lineWidth = (options.width * this.horizontalScaling / 100 - this.columnGap * (this.columns - 1)) / this.columns; + this.spaceLeft = this.lineWidth; + this.startX = this.document.x; + this.startY = this.document.y; + this.column = 1; + this.ellipsis = options.ellipsis; + this.continuedX = 0; + this.features = options.features; + + // calculate the maximum Y position the text can appear at + if (options.height != null) { + this.height = options.height; + this.maxY = PDFNumber(this.startY + options.height); + } else { + this.maxY = PDFNumber(this.document.page.maxY()); + } + + // handle paragraph indents + this.on('firstLine', options => { + // if this is the first line of the text segment, and + // we're continuing where we left off, indent that much + // otherwise use the user specified indent option + const indent = this.continuedX || this.indent; + this.document.x += indent; + this.lineWidth -= indent; + + // if indentAllLines is set to true + // we're not resetting the indentation for this paragraph after the first line + if (options.indentAllLines) { + return; + } + + // otherwise we start the next line without indent + return this.once('line', () => { + this.document.x -= indent; + this.lineWidth += indent; + if (options.continued && !this.continuedX) { + this.continuedX = this.indent; + } + if (!options.continued) { + return this.continuedX = 0; + } + }); + }); + + // handle left aligning last lines of paragraphs + this.on('lastLine', options => { + const { + align + } = options; + if (align === 'justify') { + options.align = 'left'; + } + this.lastLine = true; + return this.once('line', () => { + this.document.y += options.paragraphGap || 0; + options.align = align; + return this.lastLine = false; + }); + }); + } + wordWidth(word) { + return this.document.widthOfString(word, this) + this.characterSpacing + this.wordSpacing; + } + canFit(word, w) { + if (word[word.length - 1] != SOFT_HYPHEN) { + return w <= this.spaceLeft; + } + return w + this.wordWidth(HYPHEN) <= this.spaceLeft; + } + eachWord(text, fn) { + // setup a unicode line breaker + let bk; + const breaker = new LineBreaker(text); + let last = null; + const wordWidths = Object.create(null); + while (bk = breaker.nextBreak()) { + var shouldContinue; + let word = text.slice((last != null ? last.position : undefined) || 0, bk.position); + let w = wordWidths[word] != null ? wordWidths[word] : wordWidths[word] = this.wordWidth(word); + + // if the word is longer than the whole line, chop it up + // TODO: break by grapheme clusters, not JS string characters + if (w > this.lineWidth + this.continuedX) { + // make some fake break objects + let lbk = last; + const fbk = {}; + while (word.length) { + // fit as much of the word as possible into the space we have + var l, mightGrow; + if (w > this.spaceLeft) { + // start our check at the end of our available space - this method is faster than a loop of each character and it resolves + // an issue with long loops when processing massive words, such as a huge number of spaces + l = Math.ceil(this.spaceLeft / (w / word.length)); + w = this.wordWidth(word.slice(0, l)); + mightGrow = w <= this.spaceLeft && l < word.length; + } else { + l = word.length; + } + let mustShrink = w > this.spaceLeft && l > 0; + // shrink or grow word as necessary after our near-guess above + while (mustShrink || mightGrow) { + if (mustShrink) { + w = this.wordWidth(word.slice(0, --l)); + mustShrink = w > this.spaceLeft && l > 0; + } else { + w = this.wordWidth(word.slice(0, ++l)); + mustShrink = w > this.spaceLeft && l > 0; + mightGrow = w <= this.spaceLeft && l < word.length; + } + } + + // check for the edge case where a single character cannot fit into a line. + if (l === 0 && this.spaceLeft === this.lineWidth) { + l = 1; + } + + // send a required break unless this is the last piece and a linebreak is not specified + fbk.required = bk.required || l < word.length; + shouldContinue = fn(word.slice(0, l), w, fbk, lbk); + lbk = { + required: false + }; + + // get the remaining piece of the word + word = word.slice(l); + w = this.wordWidth(word); + if (shouldContinue === false) { + break; + } + } + } else { + // otherwise just emit the break as it was given to us + shouldContinue = fn(word, w, bk, last); + } + if (shouldContinue === false) { + break; + } + last = bk; + } + } + wrap(text, options) { + // override options from previous continued fragments + this.horizontalScaling = options.horizontalScaling || 100; + if (options.indent != null) { + this.indent = options.indent * this.horizontalScaling / 100; + } + if (options.characterSpacing != null) { + this.characterSpacing = options.characterSpacing * this.horizontalScaling / 100; + } + if (options.wordSpacing != null) { + this.wordSpacing = options.wordSpacing * this.horizontalScaling / 100; + } + if (options.ellipsis != null) { + this.ellipsis = options.ellipsis; + } + + // make sure we're actually on the page + // and that the first line of is never by + // itself at the bottom of a page (orphans) + const nextY = this.document.y + this.document.currentLineHeight(true); + if (this.document.y > this.maxY || nextY > this.maxY) { + this.nextSection(); + } + let buffer = ''; + let textWidth = 0; + let wc = 0; + let lc = 0; + let { + y + } = this.document; // used to reset Y pos if options.continued (below) + const emitLine = () => { + options.textWidth = textWidth + this.wordSpacing * (wc - 1); + options.wordCount = wc; + options.lineWidth = this.lineWidth; + ({ + y + } = this.document); + this.emit('line', buffer, options, this); + return lc++; + }; + this.emit('sectionStart', options, this); + this.eachWord(text, (word, w, bk, last) => { + if (last == null || last.required) { + this.emit('firstLine', options, this); + this.spaceLeft = this.lineWidth; + } + if (this.canFit(word, w)) { + buffer += word; + textWidth += w; + wc++; + } + if (bk.required || !this.canFit(word, w)) { + // if the user specified a max height and an ellipsis, and is about to pass the + // max height and max columns after the next line, append the ellipsis + const lh = this.document.currentLineHeight(true); + if (this.height != null && this.ellipsis && PDFNumber(this.document.y + lh * 2) > this.maxY && this.column >= this.columns) { + if (this.ellipsis === true) { + this.ellipsis = '…'; + } // map default ellipsis character + buffer = buffer.replace(/\s+$/, ''); + textWidth = this.wordWidth(buffer + this.ellipsis); + + // remove characters from the buffer until the ellipsis fits + // to avoid infinite loop need to stop while-loop if buffer is empty string + while (buffer && textWidth > this.lineWidth) { + buffer = buffer.slice(0, -1).replace(/\s+$/, ''); + textWidth = this.wordWidth(buffer + this.ellipsis); + } + // need to add ellipsis only if there is enough space for it + if (textWidth <= this.lineWidth) { + buffer = buffer + this.ellipsis; + } + textWidth = this.wordWidth(buffer); + } + if (bk.required) { + if (w > this.spaceLeft) { + emitLine(); + buffer = word; + textWidth = w; + wc = 1; + } + this.emit('lastLine', options, this); + } + + // Previous entry is a soft hyphen - add visible hyphen. + if (buffer[buffer.length - 1] == SOFT_HYPHEN) { + buffer = buffer.slice(0, -1) + HYPHEN; + this.spaceLeft -= this.wordWidth(HYPHEN); + } + emitLine(); + + // if we've reached the edge of the page, + // continue on a new page or column + if (PDFNumber(this.document.y + lh) > this.maxY) { + const shouldContinue = this.nextSection(); + + // stop if we reached the maximum height + if (!shouldContinue) { + wc = 0; + buffer = ''; + return false; + } + } + + // reset the space left and buffer + if (bk.required) { + this.spaceLeft = this.lineWidth; + buffer = ''; + textWidth = 0; + return wc = 0; + } else { + // reset the space left and buffer + this.spaceLeft = this.lineWidth - w; + buffer = word; + textWidth = w; + return wc = 1; + } + } else { + return this.spaceLeft -= w; + } + }); + if (wc > 0) { + this.emit('lastLine', options, this); + emitLine(); + } + this.emit('sectionEnd', options, this); + + // if the wrap is set to be continued, save the X position + // to start the first line of the next segment at, and reset + // the y position + if (options.continued === true) { + if (lc > 1) { + this.continuedX = 0; + } + this.continuedX += options.textWidth || 0; + return this.document.y = y; + } else { + return this.document.x = this.startX; + } + } + nextSection(options) { + this.emit('sectionEnd', options, this); + if (++this.column > this.columns) { + // if a max height was specified by the user, we're done. + // otherwise, the default is to make a new page at the bottom. + if (this.height != null) { + return false; + } + this.document.continueOnNewPage(); + this.column = 1; + this.startY = this.document.page.margins.top; + this.maxY = this.document.page.maxY(); + this.document.x = this.startX; + if (this.document._fillColor) { + this.document.fillColor(...this.document._fillColor); + } + this.emit('pageBreak', options, this); + } else { + this.document.x += this.lineWidth + this.columnGap; + this.document.y = this.startY; + this.emit('columnBreak', options, this); + } + this.emit('sectionStart', options, this); + return true; + } +} + +const { + number +} = PDFObject; +var TextMixin = { + initText() { + this._line = this._line.bind(this); + + // Current coordinates + this.x = 0; + this.y = 0; + return this._lineGap = 0; + }, + lineGap(_lineGap) { + this._lineGap = _lineGap; + return this; + }, + moveDown(lines) { + if (lines == null) { + lines = 1; + } + this.y += this.currentLineHeight(true) * lines + this._lineGap; + return this; + }, + moveUp(lines) { + if (lines == null) { + lines = 1; + } + this.y -= this.currentLineHeight(true) * lines + this._lineGap; + return this; + }, + _text(text, x, y, options, lineCallback) { + options = this._initOptions(x, y, options); + + // Convert text to a string + text = text == null ? '' : `${text}`; + + // if the wordSpacing option is specified, remove multiple consecutive spaces + if (options.wordSpacing) { + text = text.replace(/\s{2,}/g, ' '); + } + const addStructure = () => { + if (options.structParent) { + options.structParent.add(this.struct(options.structType || 'P', [this.markStructureContent(options.structType || 'P')])); + } + }; + + // We can save some bytes if there is no rotation + if (options.rotation !== 0) { + this.save(); + this.rotate(-options.rotation, { + origin: [this.x, this.y] + }); + } + + // word wrapping + if (options.width) { + let wrapper = this._wrapper; + if (!wrapper) { + wrapper = new LineWrapper(this, options); + wrapper.on('line', lineCallback); + wrapper.on('firstLine', addStructure); + } + this._wrapper = options.continued ? wrapper : null; + this._textOptions = options.continued ? options : null; + wrapper.wrap(text, options); + + // render paragraphs as single lines + } else { + for (let line of text.split('\n')) { + addStructure(); + lineCallback(line, options); + } + } + + // Cleanup if there was a rotation + if (options.rotation !== 0) this.restore(); + return this; + }, + text(text, x, y, options) { + return this._text(text, x, y, options, this._line); + }, + widthOfString(string, options) { + if (options === void 0) { + options = {}; + } + const horizontalScaling = options.horizontalScaling || 100; + return (this._font.widthOfString(string, this._fontSize, options.features) + (options.characterSpacing || 0) * (string.length - 1)) * horizontalScaling / 100; + }, + /** + * Compute the bounding box of a string + * based on what will actually be rendered by `doc.text()` + * + * @param string - The string + * @param x - X position of text (defaults to this.x) + * @param y - Y position of text (defaults to this.y) + * @param options - Any text options (The same you would apply to `doc.text()`) + * @returns {{x: number, y: number, width: number, height: number}} + */ + boundsOfString(string, x, y, options) {}, + heightOfString(text, options) { + const { + x, + y + } = this; + options = this._initOptions(options); + options.height = Infinity; // don't break pages + + const lineGap = options.lineGap || this._lineGap || 0; + this._text(text, this.x, this.y, options, () => { + return this.y += this.currentLineHeight(true) + lineGap; + }); + const height = this.y - y; + this.x = x; + this.y = y; + return height; + }, + list(list, x, y, options, wrapper) { + options = this._initOptions(x, y, options); + const listType = options.listType || 'bullet'; + const unit = Math.round(this._font.ascender / 1000 * this._fontSize); + const midLine = unit / 2; + const r = options.bulletRadius || unit / 3; + const indent = options.textIndent || (listType === 'bullet' ? r * 5 : unit * 2); + const itemIndent = options.bulletIndent || (listType === 'bullet' ? r * 8 : unit * 2); + let level = 1; + const items = []; + const levels = []; + const numbers = []; + var flatten = function (list) { + let n = 1; + for (let i = 0; i < list.length; i++) { + const item = list[i]; + if (Array.isArray(item)) { + level++; + flatten(item); + level--; + } else { + items.push(item); + levels.push(level); + if (listType !== 'bullet') { + numbers.push(n++); + } + } + } + }; + flatten(list); + const label = function (n) { + switch (listType) { + case 'numbered': + return `${n}.`; + case 'lettered': + var letter = String.fromCharCode((n - 1) % 26 + 65); + var times = Math.floor((n - 1) / 26 + 1); + var text = Array(times + 1).join(letter); + return `${text}.`; + } + }; + const drawListItem = function (listItem, i) { + wrapper = new LineWrapper(this, options); + wrapper.on('line', this._line); + level = 1; + wrapper.once('firstLine', () => { + let item, itemType, labelType, bodyType; + if (options.structParent) { + if (options.structTypes) { + [itemType, labelType, bodyType] = options.structTypes; + } else { + [itemType, labelType, bodyType] = ['LI', 'Lbl', 'LBody']; + } + } + if (itemType) { + item = this.struct(itemType); + options.structParent.add(item); + } else if (options.structParent) { + item = options.structParent; + } + let l; + if ((l = levels[i++]) !== level) { + const diff = itemIndent * (l - level); + this.x += diff; + wrapper.lineWidth -= diff; + level = l; + } + if (item && (labelType || bodyType)) { + item.add(this.struct(labelType || bodyType, [this.markStructureContent(labelType || bodyType)])); + } + switch (listType) { + case 'bullet': + this.circle(this.x - indent + r, this.y + midLine, r); + this.fill(); + break; + case 'numbered': + case 'lettered': + var text = label(numbers[i - 1]); + this._fragment(text, this.x - indent, this.y, options); + break; + } + if (item && labelType && bodyType) { + item.add(this.struct(bodyType, [this.markStructureContent(bodyType)])); + } + if (item && item !== options.structParent) { + item.end(); + } + }); + wrapper.on('sectionStart', () => { + const pos = indent + itemIndent * (level - 1); + this.x += pos; + return wrapper.lineWidth -= pos; + }); + wrapper.on('sectionEnd', () => { + const pos = indent + itemIndent * (level - 1); + this.x -= pos; + return wrapper.lineWidth += pos; + }); + wrapper.wrap(listItem, options); + }; + for (let i = 0; i < items.length; i++) { + drawListItem.call(this, items[i], i); + } + return this; + }, + _initOptions(x, y, options) { + var _options$rotation; + if (x === void 0) { + x = {}; + } + if (options === void 0) { + options = {}; + } + if (typeof x === 'object') { + options = x; + x = null; + } + + // clone options object + const result = Object.assign({}, options); + + // extend options with previous values for continued text + if (this._textOptions) { + for (let key in this._textOptions) { + const val = this._textOptions[key]; + if (key !== 'continued') { + if (result[key] === undefined) { + result[key] = val; + } + } + } + } + + // Update the current position + if (x != null) { + this.x = x; + } + if (y != null) { + this.y = y; + } + + // wrap to margins if no x or y position passed + if (result.lineBreak !== false) { + if (result.width == null) { + result.width = this.page.width - this.x - this.page.margins.right; + } + result.width = Math.max(result.width, 0); + } + if (!result.columns) { + result.columns = 0; + } + if (result.columnGap == null) { + result.columnGap = 18; + } // 1/4 inch + + // Normalize rotation to between 0 - 360 + result.rotation = Number((_options$rotation = options.rotation) !== null && _options$rotation !== void 0 ? _options$rotation : 0) % 360; + if (result.rotation < 0) result.rotation += 360; + return result; + }, + _line(text, options, wrapper) { + if (options === void 0) { + options = {}; + } + this._fragment(text, this.x, this.y, options); + const lineGap = options.lineGap || this._lineGap || 0; + if (!wrapper) { + return this.x += this.widthOfString(text, options); + } else { + return this.y += this.currentLineHeight(true) + lineGap; + } + }, + _fragment(text, x, y, options) { + let dy, encoded, i, positions, textWidth, words; + text = `${text}`.replace(/\n/g, ''); + if (text.length === 0) { + return; + } + + // handle options + const align = options.align || 'left'; + let wordSpacing = options.wordSpacing || 0; + const characterSpacing = options.characterSpacing || 0; + const horizontalScaling = options.horizontalScaling || 100; + + // text alignments + if (options.width) { + switch (align) { + case 'right': + textWidth = this.widthOfString(text.replace(/\s+$/, ''), options); + x += options.lineWidth - textWidth; + break; + case 'center': + x += options.lineWidth / 2 - options.textWidth / 2; + break; + case 'justify': + // calculate the word spacing value + words = text.trim().split(/\s+/); + textWidth = this.widthOfString(text.replace(/\s+/g, ''), options); + var spaceWidth = this.widthOfString(' ') + characterSpacing; + wordSpacing = Math.max(0, (options.lineWidth - textWidth) / Math.max(1, words.length - 1) - spaceWidth); + break; + } + } + + // text baseline alignments based on http://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling + if (typeof options.baseline === 'number') { + dy = -options.baseline; + } else { + switch (options.baseline) { + case 'svg-middle': + dy = 0.5 * this._font.xHeight; + break; + case 'middle': + case 'svg-central': + dy = 0.5 * (this._font.descender + this._font.ascender); + break; + case 'bottom': + case 'ideographic': + dy = this._font.descender; + break; + case 'alphabetic': + dy = 0; + break; + case 'mathematical': + dy = 0.5 * this._font.ascender; + break; + case 'hanging': + dy = 0.8 * this._font.ascender; + break; + case 'top': + dy = this._font.ascender; + break; + default: + dy = this._font.ascender; + } + dy = dy / 1000 * this._fontSize; + } + + // calculate the actual rendered width of the string after word and character spacing + const renderedWidth = options.textWidth + wordSpacing * (options.wordCount - 1) + characterSpacing * (text.length - 1); + + // create link annotations if the link option is given + if (options.link != null) { + this.link(x, y, renderedWidth, this.currentLineHeight(), options.link); + } + if (options.goTo != null) { + this.goTo(x, y, renderedWidth, this.currentLineHeight(), options.goTo); + } + if (options.destination != null) { + this.addNamedDestination(options.destination, 'XYZ', x, y, null); + } + + // create underline + if (options.underline) { + this.save(); + if (!options.stroke) { + this.strokeColor(...(this._fillColor || [])); + } + const lineWidth = this._fontSize < 10 ? 0.5 : Math.floor(this._fontSize / 10); + this.lineWidth(lineWidth); + let lineY = y + this.currentLineHeight() - lineWidth; + this.moveTo(x, lineY); + this.lineTo(x + renderedWidth, lineY); + this.stroke(); + this.restore(); + } + + // create strikethrough line + if (options.strike) { + this.save(); + if (!options.stroke) { + this.strokeColor(...(this._fillColor || [])); + } + const lineWidth = this._fontSize < 10 ? 0.5 : Math.floor(this._fontSize / 10); + this.lineWidth(lineWidth); + let lineY = y + this.currentLineHeight() / 2; + this.moveTo(x, lineY); + this.lineTo(x + renderedWidth, lineY); + this.stroke(); + this.restore(); + } + this.save(); + + // oblique (angle in degrees or boolean) + if (options.oblique) { + let skew; + if (typeof options.oblique === 'number') { + skew = -Math.tan(options.oblique * Math.PI / 180); + } else { + skew = -0.25; + } + this.transform(1, 0, 0, 1, x, y); + this.transform(1, 0, skew, 1, -skew * dy, 0); + this.transform(1, 0, 0, 1, -x, -y); + } + + // flip coordinate system + this.transform(1, 0, 0, -1, 0, this.page.height); + y = this.page.height - y - dy; + + // add current font to page if necessary + if (this.page.fonts[this._font.id] == null) { + this.page.fonts[this._font.id] = this._font.ref(); + } + + // begin the text object + this.addContent('BT'); + + // text position + this.addContent(`1 0 0 1 ${number(x)} ${number(y)} Tm`); + + // font and font size + this.addContent(`/${this._font.id} ${number(this._fontSize)} Tf`); + + // rendering mode + const mode = options.fill && options.stroke ? 2 : options.stroke ? 1 : 0; + if (mode) { + this.addContent(`${mode} Tr`); + } + + // Character spacing + if (characterSpacing) { + this.addContent(`${number(characterSpacing)} Tc`); + } + + // Horizontal scaling + if (horizontalScaling !== 100) { + this.addContent(`${horizontalScaling} Tz`); + } + + // Add the actual text + // If we have a word spacing value, we need to encode each word separately + // since the normal Tw operator only works on character code 32, which isn't + // used for embedded fonts. + if (wordSpacing) { + words = text.trim().split(/\s+/); + wordSpacing += this.widthOfString(' ') + characterSpacing; + wordSpacing *= 1000 / this._fontSize; + encoded = []; + positions = []; + for (let word of words) { + const [encodedWord, positionsWord] = this._font.encode(word, options.features); + encoded = encoded.concat(encodedWord); + positions = positions.concat(positionsWord); + + // add the word spacing to the end of the word + // clone object because of cache + const space = {}; + const object = positions[positions.length - 1]; + for (let key in object) { + const val = object[key]; + space[key] = val; + } + space.xAdvance += wordSpacing; + positions[positions.length - 1] = space; + } + } else { + [encoded, positions] = this._font.encode(text, options.features); + } + const scale = this._fontSize / 1000; + const commands = []; + let last = 0; + let hadOffset = false; + + // Adds a segment of text to the TJ command buffer + const addSegment = cur => { + if (last < cur) { + const hex = encoded.slice(last, cur).join(''); + const advance = positions[cur - 1].xAdvance - positions[cur - 1].advanceWidth; + commands.push(`<${hex}> ${number(-advance)}`); + } + return last = cur; + }; + + // Flushes the current TJ commands to the output stream + const flush = i => { + addSegment(i); + if (commands.length > 0) { + this.addContent(`[${commands.join(' ')}] TJ`); + return commands.length = 0; + } + }; + for (i = 0; i < positions.length; i++) { + // If we have an x or y offset, we have to break out of the current TJ command + // so we can move the text position. + const pos = positions[i]; + if (pos.xOffset || pos.yOffset) { + // Flush the current buffer + flush(i); + + // Move the text position and flush just the current character + this.addContent(`1 0 0 1 ${number(x + pos.xOffset * scale)} ${number(y + pos.yOffset * scale)} Tm`); + flush(i + 1); + hadOffset = true; + } else { + // If the last character had an offset, reset the text position + if (hadOffset) { + this.addContent(`1 0 0 1 ${number(x)} ${number(y)} Tm`); + hadOffset = false; + } + + // Group segments that don't have any advance adjustments + if (pos.xAdvance - pos.advanceWidth !== 0) { + addSegment(i + 1); + } + } + x += pos.xAdvance * scale; + } + + // Flush any remaining commands + flush(i); + + // end the text object + this.addContent('ET'); + + // restore flipped coordinate system + return this.restore(); + } +}; + +const COLOR_SPACE_MAP = { + 1: 'DeviceGray', + 3: 'DeviceRGB', + 4: 'DeviceCMYK' +}; +class JPEG { + constructor(data, label) { + this.data = data; + this.label = label; + this.orientation = 1; + if (this.data.readUInt16BE(0) !== 0xffd8) { + throw 'SOI not found in JPEG'; + } + const markers = _JPEG.decode(this.data); + for (let i = 0; i < markers.length; i += 1) { + const marker = markers[i]; + if (marker.name === 'EXIF' && marker.entries.orientation) { + this.orientation = marker.entries.orientation; + } + if (marker.name === 'SOF') { + this.bits ||= marker.precision; + this.width ||= marker.width; + this.height ||= marker.height; + this.colorSpace ||= COLOR_SPACE_MAP[marker.numberOfComponents]; + } + } + this.obj = null; + } + embed(document) { + if (this.obj) { + return; + } + this.obj = document.ref({ + Type: 'XObject', + Subtype: 'Image', + BitsPerComponent: this.bits, + Width: this.width, + Height: this.height, + ColorSpace: this.colorSpace, + Filter: 'DCTDecode' + }); + + // add extra decode params for CMYK images. By swapping the + // min and max values from the default, we invert the colors. See + // section 4.8.4 of the spec. + if (this.colorSpace === 'DeviceCMYK') { + this.obj.data['Decode'] = [1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0]; + } + this.obj.end(this.data); + + // free memory + return this.data = null; + } +} + +class PNGImage { + constructor(data, label) { + this.label = label; + this.image = new PNG(data); + this.width = this.image.width; + this.height = this.image.height; + this.imgData = this.image.imgData; + this.obj = null; + } + embed(document) { + let dataDecoded = false; + this.document = document; + if (this.obj) { + return; + } + const hasAlphaChannel = this.image.hasAlphaChannel; + const isInterlaced = this.image.interlaceMethod === 1; + this.obj = this.document.ref({ + Type: 'XObject', + Subtype: 'Image', + BitsPerComponent: hasAlphaChannel ? 8 : this.image.bits, + Width: this.width, + Height: this.height, + Filter: 'FlateDecode' + }); + if (!hasAlphaChannel) { + const params = this.document.ref({ + Predictor: isInterlaced ? 1 : 15, + Colors: this.image.colors, + BitsPerComponent: this.image.bits, + Columns: this.width + }); + this.obj.data['DecodeParms'] = params; + params.end(); + } + if (this.image.palette.length === 0) { + this.obj.data['ColorSpace'] = this.image.colorSpace; + } else { + // embed the color palette in the PDF as an object stream + const palette = this.document.ref(); + palette.end(Buffer$2.from(this.image.palette)); + + // build the color space array for the image + this.obj.data['ColorSpace'] = ['Indexed', 'DeviceRGB', this.image.palette.length / 3 - 1, palette]; + } + + // For PNG color types 0, 2 and 3, the transparency data is stored in + // a dedicated PNG chunk. + if (this.image.transparency.grayscale != null) { + // Use Color Key Masking (spec section 4.8.5) + // An array with N elements, where N is two times the number of color components. + const val = this.image.transparency.grayscale; + this.obj.data['Mask'] = [val, val]; + } else if (this.image.transparency.rgb) { + // Use Color Key Masking (spec section 4.8.5) + // An array with N elements, where N is two times the number of color components. + const { + rgb + } = this.image.transparency; + const mask = []; + for (let x of rgb) { + mask.push(x, x); + } + this.obj.data['Mask'] = mask; + } else if (this.image.transparency.indexed) { + // Create a transparency SMask for the image based on the data + // in the PLTE and tRNS sections. See below for details on SMasks. + dataDecoded = true; + return this.loadIndexedAlphaChannel(); + } else if (hasAlphaChannel) { + // For PNG color types 4 and 6, the transparency data is stored as a alpha + // channel mixed in with the main image data. Separate this data out into an + // SMask object and store it separately in the PDF. + dataDecoded = true; + return this.splitAlphaChannel(); + } + if (isInterlaced && !dataDecoded) { + return this.decodeData(); + } + this.finalize(); + } + finalize() { + if (this.alphaChannel) { + const sMask = this.document.ref({ + Type: 'XObject', + Subtype: 'Image', + Height: this.height, + Width: this.width, + BitsPerComponent: 8, + Filter: 'FlateDecode', + ColorSpace: 'DeviceGray', + Decode: [0, 1] + }); + sMask.end(this.alphaChannel); + this.obj.data['SMask'] = sMask; + } + + // add the actual image data + this.obj.end(this.imgData); + + // free memory + this.image = null; + return this.imgData = null; + } + splitAlphaChannel() { + return this.image.decodePixels(pixels => { + let a, p; + const colorCount = this.image.colors; + const pixelCount = this.width * this.height; + const imgData = Buffer$2.alloc(pixelCount * colorCount); + const alphaChannel = Buffer$2.alloc(pixelCount); + let i = p = a = 0; + const len = pixels.length; + // For 16bit images copy only most significant byte (MSB) - PNG data is always stored in network byte order (MSB first) + const skipByteCount = this.image.bits === 16 ? 1 : 0; + while (i < len) { + for (let colorIndex = 0; colorIndex < colorCount; colorIndex++) { + imgData[p++] = pixels[i++]; + i += skipByteCount; + } + alphaChannel[a++] = pixels[i++]; + i += skipByteCount; + } + this.imgData = zlib.deflateSync(imgData); + this.alphaChannel = zlib.deflateSync(alphaChannel); + return this.finalize(); + }); + } + loadIndexedAlphaChannel() { + const transparency = this.image.transparency.indexed; + const isInterlaced = this.image.interlaceMethod === 1; + return this.image.decodePixels(pixels => { + const alphaChannel = Buffer$2.alloc(this.width * this.height); + let i = 0; + for (let j = 0, end = pixels.length; j < end; j++) { + alphaChannel[i++] = transparency[pixels[j]]; + } + + // For interlaced images, re-encode the decoded pixel data + if (isInterlaced) { + this.imgData = zlib.deflateSync(Buffer$2.from(pixels)); + } + this.alphaChannel = zlib.deflateSync(alphaChannel); + return this.finalize(); + }); + } + decodeData() { + this.image.decodePixels(pixels => { + this.imgData = zlib.deflateSync(pixels); + this.finalize(); + }); + } +} + +class PDFImage { + static open(src, label) { + let data; + if (Buffer$2.isBuffer(src)) { + data = src; + } else if (src instanceof ArrayBuffer) { + data = Buffer$2.from(new Uint8Array(src)); + } else { + const match = /^data:.+?;base64,(.*)$/.exec(src); + if (match) { + data = Buffer$2.from(match[1], 'base64'); + } else { + data = fs.readFileSync(src); + if (!data) { + return; + } + } + } + if (data[0] === 0xff && data[1] === 0xd8) { + return new JPEG(data, label); + } else if (data[0] === 0x89 && data.toString('ascii', 1, 4) === 'PNG') { + return new PNGImage(data, label); + } else { + throw new Error('Unknown image format.'); + } + } +} + +var ImagesMixin = { + initImages() { + this._imageRegistry = {}; + return this._imageCount = 0; + }, + image(src, x, y, options) { + if (options === void 0) { + options = {}; + } + let bh, bp, bw, image, ip, left, left1, rotateAngle, originX, originY; + if (typeof x === 'object') { + options = x; + x = null; + } + + // Ignore orientation based on document options or image options + const ignoreOrientation = options.ignoreOrientation || options.ignoreOrientation !== false && this.options.ignoreOrientation; + x = (left = x != null ? x : options.x) != null ? left : this.x; + y = (left1 = y != null ? y : options.y) != null ? left1 : this.y; + if (typeof src === 'string') { + image = this._imageRegistry[src]; + } + if (!image) { + if (src.width && src.height) { + image = src; + } else { + image = this.openImage(src); + } + } + if (!image.obj) { + image.embed(this); + } + if (this.page.xobjects[image.label] == null) { + this.page.xobjects[image.label] = image.obj; + } + let { + width, + height + } = image; + + // If EXIF orientation calls for it, swap width and height + if (!ignoreOrientation && image.orientation > 4) { + [width, height] = [height, width]; + } + let w = options.width || width; + let h = options.height || height; + if (options.width && !options.height) { + const wp = w / width; + w = width * wp; + h = height * wp; + } else if (options.height && !options.width) { + const hp = h / height; + w = width * hp; + h = height * hp; + } else if (options.scale) { + w = width * options.scale; + h = height * options.scale; + } else if (options.fit) { + [bw, bh] = options.fit; + bp = bw / bh; + ip = width / height; + if (ip > bp) { + w = bw; + h = bw / ip; + } else { + h = bh; + w = bh * ip; + } + } else if (options.cover) { + [bw, bh] = options.cover; + bp = bw / bh; + ip = width / height; + if (ip > bp) { + h = bh; + w = bh * ip; + } else { + w = bw; + h = bw / ip; + } + } + if (options.fit || options.cover) { + if (options.align === 'center') { + x = x + bw / 2 - w / 2; + } else if (options.align === 'right') { + x = x + bw - w; + } + if (options.valign === 'center') { + y = y + bh / 2 - h / 2; + } else if (options.valign === 'bottom') { + y = y + bh - h; + } + } + if (!ignoreOrientation) { + switch (image.orientation) { + // No orientation (need to flip image, though, because of the default transform matrix on the document) + default: + case 1: + h = -h; + y -= h; + rotateAngle = 0; + break; + // Flip Horizontal + case 2: + w = -w; + h = -h; + x -= w; + y -= h; + rotateAngle = 0; + break; + // Rotate 180 degrees + case 3: + originX = x; + originY = y; + h = -h; + x -= w; + rotateAngle = 180; + break; + // Flip vertical + case 4: + // Do nothing, image will be flipped + + break; + // Flip horizontally and rotate 270 degrees CW + case 5: + originX = x; + originY = y; + [w, h] = [h, w]; + y -= h; + rotateAngle = 90; + break; + // Rotate 90 degrees CW + case 6: + originX = x; + originY = y; + [w, h] = [h, w]; + h = -h; + rotateAngle = 90; + break; + // Flip horizontally and rotate 90 degrees CW + case 7: + originX = x; + originY = y; + [w, h] = [h, w]; + h = -h; + w = -w; + x -= w; + rotateAngle = 90; + break; + // Rotate 270 degrees CW + case 8: + originX = x; + originY = y; + [w, h] = [h, w]; + h = -h; + x -= w; + y -= h; + rotateAngle = -90; + break; + } + } else { + h = -h; + y -= h; + rotateAngle = 0; + } + + // create link annotations if the link option is given + if (options.link != null) { + this.link(x, y, w, h, options.link); + } + if (options.goTo != null) { + this.goTo(x, y, w, h, options.goTo); + } + if (options.destination != null) { + this.addNamedDestination(options.destination, 'XYZ', x, y, null); + } + + // Set the current y position to below the image if it is in the document flow + if (this.y === y) { + this.y += h; + } + this.save(); + if (rotateAngle) { + this.rotate(rotateAngle, { + origin: [originX, originY] + }); + } + this.transform(w, 0, 0, h, x, y); + this.addContent(`/${image.label} Do`); + this.restore(); + return this; + }, + openImage(src) { + let image; + if (typeof src === 'string') { + image = this._imageRegistry[src]; + } + if (!image) { + image = PDFImage.open(src, `I${++this._imageCount}`); + if (typeof src === 'string') { + this._imageRegistry[src] = image; + } + } + return image; + } +}; + +var AnnotationsMixin = { + annotate(x, y, w, h, options) { + options.Type = 'Annot'; + options.Rect = this._convertRect(x, y, w, h); + options.Border = [0, 0, 0]; + if (options.Subtype === 'Link' && typeof options.F === 'undefined') { + options.F = 1 << 2; // Print Annotation Flag + } + if (options.Subtype !== 'Link') { + if (options.C == null) { + options.C = this._normalizeColor(options.color || [0, 0, 0]); + } + } // convert colors + delete options.color; + if (typeof options.Dest === 'string') { + options.Dest = new String(options.Dest); + } + + // Capitalize keys + for (let key in options) { + const val = options[key]; + options[key[0].toUpperCase() + key.slice(1)] = val; + } + const ref = this.ref(options); + this.page.annotations.push(ref); + ref.end(); + return this; + }, + note(x, y, w, h, contents, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Text'; + options.Contents = new String(contents); + if (options.Name == null) { + options.Name = 'Comment'; + } + if (options.color == null) { + options.color = [243, 223, 92]; + } + return this.annotate(x, y, w, h, options); + }, + goTo(x, y, w, h, name, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Link'; + options.A = this.ref({ + S: 'GoTo', + D: new String(name) + }); + options.A.end(); + return this.annotate(x, y, w, h, options); + }, + link(x, y, w, h, url, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Link'; + if (typeof url === 'number') { + // Link to a page in the document (the page must already exist) + const pages = this._root.data.Pages.data; + if (url >= 0 && url < pages.Kids.length) { + options.A = this.ref({ + S: 'GoTo', + D: [pages.Kids[url], 'XYZ', null, null, null] + }); + options.A.end(); + } else { + throw new Error(`The document has no page ${url}`); + } + } else { + // Link to an external url + options.A = this.ref({ + S: 'URI', + URI: new String(url) + }); + options.A.end(); + } + return this.annotate(x, y, w, h, options); + }, + _markup(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + const [x1, y1, x2, y2] = this._convertRect(x, y, w, h); + options.QuadPoints = [x1, y2, x2, y2, x1, y1, x2, y1]; + options.Contents = new String(); + return this.annotate(x, y, w, h, options); + }, + highlight(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Highlight'; + if (options.color == null) { + options.color = [241, 238, 148]; + } + return this._markup(x, y, w, h, options); + }, + underline(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Underline'; + return this._markup(x, y, w, h, options); + }, + strike(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'StrikeOut'; + return this._markup(x, y, w, h, options); + }, + lineAnnotation(x1, y1, x2, y2, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Line'; + options.Contents = new String(); + options.L = [x1, this.page.height - y1, x2, this.page.height - y2]; + return this.annotate(x1, y1, x2, y2, options); + }, + rectAnnotation(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Square'; + options.Contents = new String(); + return this.annotate(x, y, w, h, options); + }, + ellipseAnnotation(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Circle'; + options.Contents = new String(); + return this.annotate(x, y, w, h, options); + }, + textAnnotation(x, y, w, h, text, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'FreeText'; + options.Contents = new String(text); + options.DA = new String(); + return this.annotate(x, y, w, h, options); + }, + fileAnnotation(x, y, w, h, file, options) { + if (file === void 0) { + file = {}; + } + if (options === void 0) { + options = {}; + } + // create hidden file + const filespec = this.file(file.src, Object.assign({ + hidden: true + }, file)); + options.Subtype = 'FileAttachment'; + options.FS = filespec; + + // add description from filespec unless description (Contents) has already been set + if (options.Contents) { + options.Contents = new String(options.Contents); + } else if (filespec.data.Desc) { + options.Contents = filespec.data.Desc; + } + return this.annotate(x, y, w, h, options); + }, + _convertRect(x1, y1, w, h) { + // flip y1 and y2 + let y2 = y1; + y1 += h; + + // make x2 + let x2 = x1 + w; + + // apply current transformation matrix to points + const [m0, m1, m2, m3, m4, m5] = this._ctm; + x1 = m0 * x1 + m2 * y1 + m4; + y1 = m1 * x1 + m3 * y1 + m5; + x2 = m0 * x2 + m2 * y2 + m4; + y2 = m1 * x2 + m3 * y2 + m5; + return [x1, y1, x2, y2]; + } +}; + +/* Custom fork start */ +const DEFAULT_OPTIONS = { + top: 0, + left: 0, + zoom: 0, + fit: false, + pageNumber: null, + expanded: false +}; +/* Custom fork end */ + +class PDFOutline { + constructor(document, parent, title, dest, options) { + if (options === void 0) { + options = DEFAULT_OPTIONS; + } + this.document = document; + this.options = options; + this.outlineData = {}; + if (dest !== null) { + /* Custom fork start */ + const destWidth = dest.data.MediaBox[2]; + const destHeight = dest.data.MediaBox[3]; + const top = destHeight - (options.top || 0); + const left = destWidth - (options.left || 0); + const zoom = options.zoom || 0; + this.outlineData['Dest'] = options.fit ? [dest, 'Fit'] : [dest, 'XYZ', left, top, zoom]; + /* Custom fork end */ + } + if (parent !== null) { + this.outlineData['Parent'] = parent; + } + if (title !== null) { + this.outlineData['Title'] = new String(title); + } + this.dictionary = this.document.ref(this.outlineData); + this.children = []; + } + addItem(title, options) { + if (options === void 0) { + options = DEFAULT_OPTIONS; + } + /* Custom fork start */ + const pages = this.document._root.data.Pages.data.Kids; + const dest = options.pageNumber !== null ? pages[options.pageNumber] : this.document.page.dictionary; + /* Custom fork end */ + + const result = new PDFOutline(this.document, this.dictionary, title, dest, options); + this.children.push(result); + return result; + } + endOutline() { + if (this.children.length > 0) { + if (this.options.expanded) { + this.outlineData.Count = this.children.length; + } + const first = this.children[0], + last = this.children[this.children.length - 1]; + this.outlineData.First = first.dictionary; + this.outlineData.Last = last.dictionary; + for (let i = 0, len = this.children.length; i < len; i++) { + const child = this.children[i]; + if (i > 0) { + child.outlineData.Prev = this.children[i - 1].dictionary; + } + if (i < this.children.length - 1) { + child.outlineData.Next = this.children[i + 1].dictionary; + } + child.endOutline(); + } + } + return this.dictionary.end(); + } +} + +var OutlineMixin = { + initOutline() { + return this.outline = new PDFOutline(this, null, null, null); + }, + endOutline() { + this.outline.endOutline(); + if (this.outline.children.length > 0) { + this._root.data.Outlines = this.outline.dictionary; + /* Custom fork start */ + return this._root.data.PageMode = this._root.data.PageMode || 'UseOutlines'; + /* Custom fork end */ + } + } +}; + +/* +PDFStructureContent - a reference to a marked structure content +By Ben Schmidt +*/ + +class PDFStructureContent { + constructor(pageRef, mcid) { + this.refs = [{ + pageRef, + mcid + }]; + } + push(structContent) { + structContent.refs.forEach(ref => this.refs.push(ref)); + } +} + +/* +PDFStructureElement - represents an element in the PDF logical structure tree +By Ben Schmidt +*/ + +class PDFStructureElement { + constructor(document, type, options, children) { + if (options === void 0) { + options = {}; + } + if (children === void 0) { + children = null; + } + this.document = document; + this._attached = false; + this._ended = false; + this._flushed = false; + this.dictionary = document.ref({ + // Type: "StructElem", + S: type + }); + const data = this.dictionary.data; + if (Array.isArray(options) || this._isValidChild(options)) { + children = options; + options = {}; + } + if (typeof options.title !== 'undefined') { + data.T = new String(options.title); + } + if (typeof options.lang !== 'undefined') { + data.Lang = new String(options.lang); + } + if (typeof options.alt !== 'undefined') { + data.Alt = new String(options.alt); + } + if (typeof options.expanded !== 'undefined') { + data.E = new String(options.expanded); + } + if (typeof options.actual !== 'undefined') { + data.ActualText = new String(options.actual); + } + this._children = []; + if (children) { + if (!Array.isArray(children)) { + children = [children]; + } + children.forEach(child => this.add(child)); + this.end(); + } + } + add(child) { + if (this._ended) { + throw new Error(`Cannot add child to already-ended structure element`); + } + if (!this._isValidChild(child)) { + throw new Error(`Invalid structure element child`); + } + if (child instanceof PDFStructureElement) { + child.setParent(this.dictionary); + if (this._attached) { + child.setAttached(); + } + } + if (child instanceof PDFStructureContent) { + this._addContentToParentTree(child); + } + if (typeof child === 'function' && this._attached) { + // _contentForClosure() adds the content to the parent tree + child = this._contentForClosure(child); + } + this._children.push(child); + return this; + } + _addContentToParentTree(content) { + content.refs.forEach(_ref => { + let { + pageRef, + mcid + } = _ref; + const pageStructParents = this.document.getStructParentTree().get(pageRef.data.StructParents); + pageStructParents[mcid] = this.dictionary; + }); + } + setParent(parentRef) { + if (this.dictionary.data.P) { + throw new Error(`Structure element added to more than one parent`); + } + this.dictionary.data.P = parentRef; + this._flush(); + } + setAttached() { + if (this._attached) { + return; + } + this._children.forEach((child, index) => { + if (child instanceof PDFStructureElement) { + child.setAttached(); + } + if (typeof child === 'function') { + this._children[index] = this._contentForClosure(child); + } + }); + this._attached = true; + this._flush(); + } + end() { + if (this._ended) { + return; + } + this._children.filter(child => child instanceof PDFStructureElement).forEach(child => child.end()); + this._ended = true; + this._flush(); + } + _isValidChild(child) { + return child instanceof PDFStructureElement || child instanceof PDFStructureContent || typeof child === 'function'; + } + _contentForClosure(closure) { + const content = this.document.markStructureContent(this.dictionary.data.S); + closure(); + this.document.endMarkedContent(); + this._addContentToParentTree(content); + return content; + } + _isFlushable() { + if (!this.dictionary.data.P || !this._ended) { + return false; + } + return this._children.every(child => { + if (typeof child === 'function') { + return false; + } + if (child instanceof PDFStructureElement) { + return child._isFlushable(); + } + return true; + }); + } + _flush() { + if (this._flushed || !this._isFlushable()) { + return; + } + this.dictionary.data.K = []; + this._children.forEach(child => this._flushChild(child)); + this.dictionary.end(); + + // free memory used by children; the dictionary itself may still be + // referenced by a parent structure element or root, but we can + // at least trim the tree here + this._children = []; + this.dictionary.data.K = null; + this._flushed = true; + } + _flushChild(child) { + if (child instanceof PDFStructureElement) { + this.dictionary.data.K.push(child.dictionary); + } + if (child instanceof PDFStructureContent) { + child.refs.forEach(_ref2 => { + let { + pageRef, + mcid + } = _ref2; + if (!this.dictionary.data.Pg) { + this.dictionary.data.Pg = pageRef; + } + if (this.dictionary.data.Pg === pageRef) { + this.dictionary.data.K.push(mcid); + } else { + this.dictionary.data.K.push({ + Type: 'MCR', + Pg: pageRef, + MCID: mcid + }); + } + }); + } + } +} + +/* +PDFNumberTree - represents a number tree object +*/ + +class PDFNumberTree extends PDFTree { + _compareKeys(a, b) { + return parseInt(a) - parseInt(b); + } + _keysName() { + return 'Nums'; + } + _dataForKey(k) { + return parseInt(k); + } +} + +/* +Markings mixin - support marked content sequences in content streams +By Ben Schmidt +*/ + +var MarkingsMixin = { + initMarkings(options) { + this.structChildren = []; + if (options.tagged) { + this.getMarkInfoDictionary().data.Marked = true; + this.getStructTreeRoot(); + } + }, + markContent(tag, options) { + if (options === void 0) { + options = null; + } + if (tag === 'Artifact' || options && options.mcid) { + let toClose = 0; + this.page.markings.forEach(marking => { + if (toClose || marking.structContent || marking.tag === 'Artifact') { + toClose++; + } + }); + while (toClose--) { + this.endMarkedContent(); + } + } + if (!options) { + this.page.markings.push({ + tag + }); + this.addContent(`/${tag} BMC`); + return this; + } + this.page.markings.push({ + tag, + options + }); + const dictionary = {}; + if (typeof options.mcid !== 'undefined') { + dictionary.MCID = options.mcid; + } + if (tag === 'Artifact') { + if (typeof options.type === 'string') { + dictionary.Type = options.type; + } + if (Array.isArray(options.bbox)) { + dictionary.BBox = [options.bbox[0], this.page.height - options.bbox[3], options.bbox[2], this.page.height - options.bbox[1]]; + } + if (Array.isArray(options.attached) && options.attached.every(val => typeof val === 'string')) { + dictionary.Attached = options.attached; + } + } + if (tag === 'Span') { + if (options.lang) { + dictionary.Lang = new String(options.lang); + } + if (options.alt) { + dictionary.Alt = new String(options.alt); + } + if (options.expanded) { + dictionary.E = new String(options.expanded); + } + if (options.actual) { + dictionary.ActualText = new String(options.actual); + } + } + this.addContent(`/${tag} ${PDFObject.convert(dictionary)} BDC`); + return this; + }, + markStructureContent(tag, options) { + if (options === void 0) { + options = {}; + } + const pageStructParents = this.getStructParentTree().get(this.page.structParentTreeKey); + const mcid = pageStructParents.length; + pageStructParents.push(null); + this.markContent(tag, { + ...options, + mcid + }); + const structContent = new PDFStructureContent(this.page.dictionary, mcid); + this.page.markings.slice(-1)[0].structContent = structContent; + return structContent; + }, + endMarkedContent() { + this.page.markings.pop(); + this.addContent('EMC'); + return this; + }, + struct(type, options, children) { + if (options === void 0) { + options = {}; + } + if (children === void 0) { + children = null; + } + return new PDFStructureElement(this, type, options, children); + }, + addStructure(structElem) { + const structTreeRoot = this.getStructTreeRoot(); + structElem.setParent(structTreeRoot); + structElem.setAttached(); + this.structChildren.push(structElem); + if (!structTreeRoot.data.K) { + structTreeRoot.data.K = []; + } + structTreeRoot.data.K.push(structElem.dictionary); + return this; + }, + initPageMarkings(pageMarkings) { + pageMarkings.forEach(marking => { + if (marking.structContent) { + const structContent = marking.structContent; + const newStructContent = this.markStructureContent(marking.tag, marking.options); + structContent.push(newStructContent); + this.page.markings.slice(-1)[0].structContent = structContent; + } else { + this.markContent(marking.tag, marking.options); + } + }); + }, + endPageMarkings(page) { + const pageMarkings = page.markings; + pageMarkings.forEach(() => page.write('EMC')); + page.markings = []; + return pageMarkings; + }, + getMarkInfoDictionary() { + if (!this._root.data.MarkInfo) { + this._root.data.MarkInfo = this.ref({}); + } + return this._root.data.MarkInfo; + }, + hasMarkInfoDictionary() { + return !!this._root.data.MarkInfo; + }, + getStructTreeRoot() { + if (!this._root.data.StructTreeRoot) { + this._root.data.StructTreeRoot = this.ref({ + Type: 'StructTreeRoot', + ParentTree: new PDFNumberTree(), + ParentTreeNextKey: 0 + }); + } + return this._root.data.StructTreeRoot; + }, + getStructParentTree() { + return this.getStructTreeRoot().data.ParentTree; + }, + createStructParentTreeNextKey() { + // initialise the MarkInfo dictionary + this.getMarkInfoDictionary(); + const structTreeRoot = this.getStructTreeRoot(); + const key = structTreeRoot.data.ParentTreeNextKey++; + structTreeRoot.data.ParentTree.add(key, []); + return key; + }, + endMarkings() { + const structTreeRoot = this._root.data.StructTreeRoot; + if (structTreeRoot) { + structTreeRoot.end(); + this.structChildren.forEach(structElem => structElem.end()); + } + if (this._root.data.MarkInfo) { + this._root.data.MarkInfo.end(); + } + } +}; + +const FIELD_FLAGS = { + readOnly: 1, + required: 2, + noExport: 4, + multiline: 0x1000, + password: 0x2000, + toggleToOffButton: 0x4000, + radioButton: 0x8000, + pushButton: 0x10000, + combo: 0x20000, + edit: 0x40000, + sort: 0x80000, + multiSelect: 0x200000, + noSpell: 0x400000 +}; +const FIELD_JUSTIFY = { + left: 0, + center: 1, + right: 2 +}; +const VALUE_MAP = { + value: 'V', + defaultValue: 'DV' +}; +const FORMAT_SPECIAL = { + zip: '0', + zipPlus4: '1', + zip4: '1', + phone: '2', + ssn: '3' +}; +const FORMAT_DEFAULT = { + number: { + nDec: 0, + sepComma: false, + negStyle: 'MinusBlack', + currency: '', + currencyPrepend: true + }, + percent: { + nDec: 0, + sepComma: false + } +}; +var AcroFormMixin = { + /** + * Must call if adding AcroForms to a document. Must also call font() before + * this method to set the default font. + */ + initForm() { + if (!this._font) { + throw new Error('Must set a font before calling initForm method'); + } + this._acroform = { + fonts: {}, + defaultFont: this._font.name + }; + this._acroform.fonts[this._font.id] = this._font.ref(); + let data = { + Fields: [], + NeedAppearances: true, + DA: new String(`/${this._font.id} 0 Tf 0 g`), + DR: { + Font: {} + } + }; + data.DR.Font[this._font.id] = this._font.ref(); + const AcroForm = this.ref(data); + this._root.data.AcroForm = AcroForm; + return this; + }, + /** + * Called automatically by document.js + */ + endAcroForm() { + if (this._root.data.AcroForm) { + if (!Object.keys(this._acroform.fonts).length && !this._acroform.defaultFont) { + throw new Error('No fonts specified for PDF form'); + } + let fontDict = this._root.data.AcroForm.data.DR.Font; + Object.keys(this._acroform.fonts).forEach(name => { + fontDict[name] = this._acroform.fonts[name]; + }); + this._root.data.AcroForm.data.Fields.forEach(fieldRef => { + this._endChild(fieldRef); + }); + this._root.data.AcroForm.end(); + } + return this; + }, + _endChild(ref) { + if (Array.isArray(ref.data.Kids)) { + ref.data.Kids.forEach(childRef => { + this._endChild(childRef); + }); + ref.end(); + } + return this; + }, + /** + * Creates and adds a form field to the document. Form fields are intermediate + * nodes in a PDF form that are used to specify form name heirarchy and form + * value defaults. + * @param {string} name - field name (T attribute in field dictionary) + * @param {object} options - other attributes to include in field dictionary + */ + formField(name, options) { + if (options === void 0) { + options = {}; + } + let fieldDict = this._fieldDict(name, null, options); + let fieldRef = this.ref(fieldDict); + this._addToParent(fieldRef); + return fieldRef; + }, + /** + * Creates and adds a Form Annotation to the document. Form annotations are + * called Widget annotations internally within a PDF file. + * @param {string} name - form field name (T attribute of widget annotation + * dictionary) + * @param {number} x + * @param {number} y + * @param {number} w + * @param {number} h + * @param {object} options + */ + formAnnotation(name, type, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + let fieldDict = this._fieldDict(name, type, options); + fieldDict.Subtype = 'Widget'; + if (fieldDict.F === undefined) { + fieldDict.F = 4; // print the annotation + } + + // Add Field annot to page, and get it's ref + this.annotate(x, y, w, h, fieldDict); + let annotRef = this.page.annotations[this.page.annotations.length - 1]; + return this._addToParent(annotRef); + }, + formText(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'text', x, y, w, h, options); + }, + formPushButton(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'pushButton', x, y, w, h, options); + }, + formCombo(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'combo', x, y, w, h, options); + }, + formList(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'list', x, y, w, h, options); + }, + formRadioButton(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'radioButton', x, y, w, h, options); + }, + formCheckbox(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'checkbox', x, y, w, h, options); + }, + _addToParent(fieldRef) { + let parent = fieldRef.data.Parent; + if (parent) { + if (!parent.data.Kids) { + parent.data.Kids = []; + } + parent.data.Kids.push(fieldRef); + } else { + this._root.data.AcroForm.data.Fields.push(fieldRef); + } + return this; + }, + _fieldDict(name, type, options) { + if (options === void 0) { + options = {}; + } + if (!this._acroform) { + throw new Error('Call document.initForm() method before adding form elements to document'); + } + let opts = Object.assign({}, options); + if (type !== null) { + opts = this._resolveType(type, options); + } + opts = this._resolveFlags(opts); + opts = this._resolveJustify(opts); + opts = this._resolveFont(opts); + opts = this._resolveStrings(opts); + opts = this._resolveColors(opts); + opts = this._resolveFormat(opts); + opts.T = new String(name); + if (opts.parent) { + opts.Parent = opts.parent; + delete opts.parent; + } + return opts; + }, + _resolveType(type, opts) { + if (type === 'text') { + opts.FT = 'Tx'; + } else if (type === 'pushButton') { + opts.FT = 'Btn'; + opts.pushButton = true; + } else if (type === 'radioButton') { + opts.FT = 'Btn'; + opts.radioButton = true; + } else if (type === 'checkbox') { + opts.FT = 'Btn'; + } else if (type === 'combo') { + opts.FT = 'Ch'; + opts.combo = true; + } else if (type === 'list') { + opts.FT = 'Ch'; + } else { + throw new Error(`Invalid form annotation type '${type}'`); + } + return opts; + }, + _resolveFormat(opts) { + const f = opts.format; + if (f && f.type) { + let fnKeystroke; + let fnFormat; + let params = ''; + if (FORMAT_SPECIAL[f.type] !== undefined) { + fnKeystroke = `AFSpecial_Keystroke`; + fnFormat = `AFSpecial_Format`; + params = FORMAT_SPECIAL[f.type]; + } else { + let format = f.type.charAt(0).toUpperCase() + f.type.slice(1); + fnKeystroke = `AF${format}_Keystroke`; + fnFormat = `AF${format}_Format`; + if (f.type === 'date') { + fnKeystroke += 'Ex'; + params = String(f.param); + } else if (f.type === 'time') { + params = String(f.param); + } else if (f.type === 'number') { + let p = Object.assign({}, FORMAT_DEFAULT.number, f); + params = String([String(p.nDec), p.sepComma ? '0' : '1', '"' + p.negStyle + '"', 'null', '"' + p.currency + '"', String(p.currencyPrepend)].join(',')); + } else if (f.type === 'percent') { + let p = Object.assign({}, FORMAT_DEFAULT.percent, f); + params = String([String(p.nDec), p.sepComma ? '0' : '1'].join(',')); + } + } + opts.AA = opts.AA ? opts.AA : {}; + opts.AA.K = { + S: 'JavaScript', + JS: new String(`${fnKeystroke}(${params});`) + }; + opts.AA.F = { + S: 'JavaScript', + JS: new String(`${fnFormat}(${params});`) + }; + } + delete opts.format; + return opts; + }, + _resolveColors(opts) { + let color = this._normalizeColor(opts.backgroundColor); + if (color) { + if (!opts.MK) { + opts.MK = {}; + } + opts.MK.BG = color; + } + color = this._normalizeColor(opts.borderColor); + if (color) { + if (!opts.MK) { + opts.MK = {}; + } + opts.MK.BC = color; + } + delete opts.backgroundColor; + delete opts.borderColor; + return opts; + }, + _resolveFlags(options) { + let result = 0; + Object.keys(options).forEach(key => { + if (FIELD_FLAGS[key]) { + if (options[key]) { + result |= FIELD_FLAGS[key]; + } + delete options[key]; + } + }); + if (result !== 0) { + options.Ff = options.Ff ? options.Ff : 0; + options.Ff |= result; + } + return options; + }, + _resolveJustify(options) { + let result = 0; + if (options.align !== undefined) { + if (typeof FIELD_JUSTIFY[options.align] === 'number') { + result = FIELD_JUSTIFY[options.align]; + } + delete options.align; + } + if (result !== 0) { + options.Q = result; // default + } + return options; + }, + _resolveFont(options) { + // add current font to document-level AcroForm dict if necessary + if (this._acroform.fonts[this._font.id] == null) { + this._acroform.fonts[this._font.id] = this._font.ref(); + } + + // add current font to field's resource dict (RD) if not the default acroform font + if (this._acroform.defaultFont !== this._font.name) { + options.DR = { + Font: {} + }; + + // Get the fontSize option. If not set use auto sizing + const fontSize = options.fontSize || 0; + options.DR.Font[this._font.id] = this._font.ref(); + options.DA = new String(`/${this._font.id} ${fontSize} Tf 0 g`); + } + return options; + }, + _resolveStrings(options) { + let select = []; + function appendChoices(a) { + if (Array.isArray(a)) { + for (let idx = 0; idx < a.length; idx++) { + if (typeof a[idx] === 'string') { + select.push(new String(a[idx])); + } else { + select.push(a[idx]); + } + } + } + } + appendChoices(options.Opt); + if (options.select) { + appendChoices(options.select); + delete options.select; + } + if (select.length) { + options.Opt = select; + } + Object.keys(VALUE_MAP).forEach(key => { + if (options[key] !== undefined) { + options[VALUE_MAP[key]] = options[key]; + delete options[key]; + } + }); + ['V', 'DV'].forEach(key => { + if (typeof options[key] === 'string') { + options[key] = new String(options[key]); + } + }); + if (options.MK && options.MK.CA) { + options.MK.CA = new String(options.MK.CA); + } + if (options.label) { + options.MK = options.MK ? options.MK : {}; + options.MK.CA = new String(options.label); + delete options.label; + } + return options; + } +}; + +var AttachmentsMixin = { + /** + * Embed contents of `src` in PDF + * @param {Buffer | ArrayBuffer | string} src input Buffer, ArrayBuffer, base64 encoded string or path to file + * @param {object} options + * * options.name: filename to be shown in PDF, will use `src` if none set + * * options.type: filetype to be shown in PDF + * * options.description: description to be shown in PDF + * * options.hidden: if true, do not add attachment to EmbeddedFiles dictionary. Useful for file attachment annotations + * * options.creationDate: override creation date + * * options.modifiedDate: override modified date + * * options.relationship: Relationship between the PDF document and its attached file. Can be 'Alternative', 'Data', 'Source', 'Supplement' or 'Unspecified'. + * @returns filespec reference + */ + file(src, options) { + if (options === void 0) { + options = {}; + } + options.name = options.name || src; + options.relationship = options.relationship || 'Unspecified'; + const refBody = { + Type: 'EmbeddedFile', + Params: {} + }; + let data; + if (!src) { + throw new Error('No src specified'); + } + if (Buffer$2.isBuffer(src)) { + data = src; + } else if (src instanceof ArrayBuffer) { + data = Buffer$2.from(new Uint8Array(src)); + } else { + let match; + if (match = /^data:(.*?);base64,(.*)$/.exec(src)) { + if (match[1]) { + refBody.Subtype = match[1].replace('/', '#2F'); + } + data = Buffer$2.from(match[2], 'base64'); + } else { + data = fs.readFileSync(src); + if (!data) { + throw new Error(`Could not read contents of file at filepath ${src}`); + } + + // update CreationDate and ModDate + const { + birthtime, + ctime + } = fs.statSync(src); + refBody.Params.CreationDate = birthtime; + refBody.Params.ModDate = ctime; + } + } + + // override creation date and modified date + if (options.creationDate instanceof Date) { + refBody.Params.CreationDate = options.creationDate; + } + if (options.modifiedDate instanceof Date) { + refBody.Params.ModDate = options.modifiedDate; + } + // add optional subtype + if (options.type) { + refBody.Subtype = options.type.replace('/', '#2F'); + } + + // add checksum and size information + const checksum = md5Hex(new Uint8Array(data)); + refBody.Params.CheckSum = new String(checksum); + refBody.Params.Size = data.byteLength; + + // save some space when embedding the same file again + // if a file with the same name and metadata exists, reuse its reference + let ref; + if (!this._fileRegistry) this._fileRegistry = {}; + let file = this._fileRegistry[options.name]; + if (file && isEqual(refBody, file)) { + ref = file.ref; + } else { + ref = this.ref(refBody); + ref.end(data); + this._fileRegistry[options.name] = { + ...refBody, + ref + }; + } + // add filespec for embedded file + const fileSpecBody = { + Type: 'Filespec', + AFRelationship: options.relationship, + F: new String(options.name), + EF: { + F: ref + }, + UF: new String(options.name) + }; + if (options.description) { + fileSpecBody.Desc = new String(options.description); + } + const filespec = this.ref(fileSpecBody); + filespec.end(); + if (!options.hidden) { + this.addNamedEmbeddedFile(options.name, filespec); + } + + // Add file to the catalogue to be PDF/A3 compliant + if (this._root.data.AF) { + this._root.data.AF.push(filespec); + } else { + this._root.data.AF = [filespec]; + } + return filespec; + } +}; + +/** check two embedded file metadata objects for equality */ +function isEqual(a, b) { + return a.Subtype === b.Subtype && a.Params.CheckSum.toString() === b.Params.CheckSum.toString() && a.Params.Size === b.Params.Size && a.Params.CreationDate.getTime() === b.Params.CreationDate.getTime() && (a.Params.ModDate === undefined && b.Params.ModDate === undefined || a.Params.ModDate.getTime() === b.Params.ModDate.getTime()); +} + +var __dirname = '/home/runner/work/react-pdf/react-pdf/packages/pdfkit/src/mixins'; + +var PDFA = { + initPDFA(pSubset) { + if (pSubset.charAt(pSubset.length - 3) === '-') { + this.subset_conformance = pSubset.charAt(pSubset.length - 1).toUpperCase(); + this.subset = parseInt(pSubset.charAt(pSubset.length - 2)); + } else { + // Default to Basic conformance when user doesn't specify + this.subset_conformance = 'B'; + this.subset = parseInt(pSubset.charAt(pSubset.length - 1)); + } + }, + endSubset() { + this._addPdfaMetadata(); + this._addColorOutputIntent(); + }, + _addColorOutputIntent() { + const iccProfile = fs.readFileSync(`${__dirname}/data/sRGB_IEC61966_2_1.icc`); + const colorProfileRef = this.ref({ + Length: iccProfile.length, + N: 3 + }); + colorProfileRef.write(iccProfile); + colorProfileRef.end(); + const intentRef = this.ref({ + Type: 'OutputIntent', + S: 'GTS_PDFA1', + Info: new String('sRGB IEC61966-2.1'), + OutputConditionIdentifier: new String('sRGB IEC61966-2.1'), + DestOutputProfile: colorProfileRef + }); + intentRef.end(); + this._root.data.OutputIntents = [intentRef]; + }, + _getPdfaid() { + return ` + + ${this.subset} + ${this.subset_conformance} + + `; + }, + _addPdfaMetadata() { + this.appendXML(this._getPdfaid()); + } +}; + +var PDFUA = { + initPDFUA() { + this.subset = 1; + }, + endSubset() { + this._addPdfuaMetadata(); + }, + _addPdfuaMetadata() { + this.appendXML(this._getPdfuaid()); + }, + _getPdfuaid() { + return ` + + ${this.subset} + + `; + } +}; + +var SubsetMixin = { + _importSubset(subset) { + Object.assign(this, subset); + }, + initSubset(options) { + switch (options.subset) { + case 'PDF/A-1': + case 'PDF/A-1a': + case 'PDF/A-1b': + case 'PDF/A-2': + case 'PDF/A-2a': + case 'PDF/A-2b': + case 'PDF/A-3': + case 'PDF/A-3a': + case 'PDF/A-3b': + this._importSubset(PDFA); + this.initPDFA(options.subset); + break; + case 'PDF/UA': + this._importSubset(PDFUA); + this.initPDFUA(); + break; + } + } +}; + +/** + * @template T + * @typedef {function(number): T} Dynamic + */ + +/** + * @typedef {Object} Font + * @property {PDFFontSource} [src] + * The name of the font + * + * Defaults to the current document font source `doc._fontSrc` + * @property {string} [family] + * The font family of the font + * + * Defaults to the current document font family `doc._fontFamily` + * @property {Size} [size] + * The size of the font + * + * Defaults to the current document font size `doc._fontSize` + */ + +/** + * Measurement of how wide something is, false means 0 and true means 1 + * + * @typedef {Size | boolean} Wideness + */ + +/** + * The value of the text of a cell + * @typedef {string | null | undefined} TableCellText + */ + +/** @typedef {Object} TableCellStyle + * + * @property {TableCellText} [text] + * The text of the table cell + * @property {number} [rowSpan] + * Number of rows the cell spans. + * + * Defaults to `1`. + * @property {number} [colSpan] + * Number of columns the cell spans. + * + * Defaults to `1`. + * @property {SideDefinition} [padding] + * Controls the padding of the cell text + * + * Defaults to `0.25em` + * @property {SideDefinition} [border] + * Controls the thickness of the cells borders. + * + * Defaults to `[1, 1, 1, 1]`. + * @property {SideDefinition} [borderColor] + * Color of the border on each side of the cell. + * + * Defaults to the border color defined by the given table layout, or `black` on all sides. + * @property {Font} [font] + * Font options for the cell + * + * Defaults to the documents current font + * @property {PDFColor} [backgroundColor] + * Set the background color of the cell + * + * Defaults to transparent + * @property {'center' | ExpandedAlign} [align] + * Sets the text alignment of the cells text + * + * Defaults to `{x: 'left', y: 'top'}` + * @property {Size} [textStroke] + * Sets the text stroke width of the cells text + * + * Defaults to `0` + * @property {PDFColor} [textStrokeColor] + * Sets the text stroke color of the cells text + * + * Defaults to `black` + * @property {PDFColor} [textColor] + * Sets the text color of the cells text + * + * Defaults to `black` + * @property {'TH' | 'TD'} [type] + * Sets the cell type (for accessibility) + * + * Defaults to `TD` + * @property {Object} [textOptions] + * Sets any advanced text options passed into the cell renderer + * + * Same as the options you pass to `doc.text()` + * + * Will override any defaults set by the cell if set + * @property {string} [title] + * Sets the accessible title for the cell + * @property {'Column' | 'Row' | 'Both'} [scope] + * Sets the accessible scope for the cell + * @property {string} [id] + * Sets the accessible id for the cell + * + * Defaults to `--` + * @property {boolean} [debug] + * Whether to show the debug lines for the cell + * + * Defaults to `false` + */ +/** @typedef {TableCellText | TableCellStyle} TableCell **/ + +/** + * The width of the column + * + * - `*` distributes equally, filling the whole available space + * - `%` computes the proportion of the max size + * + * Defaults to `*` + * @typedef {Size | '*'} ColumnWidth + */ + +/** + * @typedef {Object} ColumnStyle + * @extends TableCellStyle + * + * @property {ColumnWidth} [width] + * @property {Size} [minWidth] + * The minimum width of the column + * + * Defaults to `0` + * @property {Size} [maxWidth] + * The maximum width of the column + * + * Defaults to `undefined` meaning no max + */ +/** @typedef {ColumnStyle | ColumnWidth} Column **/ + +/** + * @typedef {Object} NormalizedColumnStyle + * @extends ColumnStyle + * + * @property {number | '*'} width + * @property {number} minWidth + * @property {number} maxWidth + */ + +/** + * The height of the row + * + * - A fixed value sets an absolute height for every row. + * - `auto` sets the height based on the text. + * + * `%` values are based on page content height + * + * Defaults to `auto` + * @typedef {Size | 'auto'} RowHeight + */ + +/** + * @typedef {Object} RowStyle + * @extends TableCellStyle + * + * @property {RowHeight} [height] + * @property {Size} [minHeight] + * The minimum height of the row + * + * `%` values are based on page content height + * + * Defaults to `0` + * @property {Size} [maxHeight] + * The maximum height of the row + * + * `%` values are based on page content height + * + * Defaults to `undefined` meaning no max + */ +/** @typedef {RowStyle | RowHeight} Row **/ + +/** + * @typedef {Object} NormalizedRowStyle + * @extends RowStyle + * + * @property {number | 'auto'} height + * @property {number} minHeight + * @property {number} maxHeight + */ + +/** @typedef {'left' | 'center' | 'right' | 'justify'} AlignX **/ +/** @typedef {'top' | 'center' | 'bottom'} AlignY **/ +/** + * @typedef {Object} ExpandedAlign + * @property {AlignX} [x] + * @property {AlignY} [y] + */ + +/** + * @typedef {Object} DefaultTableCellStyle + * + * @extends ColumnStyle + * @extends RowStyle + * @extends TableCellStyle + */ +/** @typedef {TableCellText | DefaultTableCellStyle} DefaultTableCell **/ + +/** + * @typedef {Object} NormalizedDefaultTableCellStyle + * + * @extends NormalizedColumnStyle + * @extends NormalizedRowStyle + * @extends TableCellStyle + */ + +/** + * @typedef {Object} NormalizedTableCellStyle + * + * @extends NormalizedColumnStyle + * @extends NormalizedRowStyle + * @extends TableCellStyle + * + * @property {number} rowIndex + * @property {number} rowSpan + * @property {number} colIndex + * @property {number} colSpan + * + * @property {string} text + * @property {Font} font + * @property {boolean} customFont + * @property {ExpandedSideDefinition} padding + * @property {ExpandedSideDefinition} border + * @property {ExpandedSideDefinition} borderColor + * @property {ExpandedAlign} align + * @property {number} textStroke + * @property {PDFColor} textStrokeColor + * @property {PDFColor} textColor + * @property {number} minWidth + * @property {number} maxWidth + * @property {number} minHeight + * @property {number} maxHeight + * @property {Object} textOptions + */ + +/** + * @typedef {Object} SizedNormalizedTableCellStyle + * + * @extends {NormalizedTableCellStyle} + * + * @property {number} x + * @property {number} y + * @property {number} textX + * @property {number} textY + * @property {number} width + * @property {number} height + * @property {number} textAllocatedWidth + * @property {number} textAllocatedHeight + * @property {{x: number, y: number, width: number, height: number}} textBounds + */ + +/** + * @typedef {Object} Table + * + * @property {Position} [position] + * The position of the table + * + * Defaults to the current document position `{x: doc.x, y: doc.y}` + * @property {Size} [maxWidth] + * The maximum width the table can expand to + * + * Defaults to the remaining content width (offset from the tables position) + * @property {Column | Column[] | Dynamic} [columnStyles] + * Column definitions of the table. + * - A fixed value sets the config for every column + * - Use an array or a callback function to control the column config for each column individually. + * + * Defaults to `auto` + * @property {Row | Row[] | Dynamic} [rowStyles] + * Row definitions of the table. + * - A fixed value sets the config for every column + * - Use an array or a callback function to control the row config of each row individually. + * + * The given values are ignored for rows whose text is higher. + * + * Defaults to `*`. + * @property {DefaultTableCell} [defaultStyle] + * Defaults to apply to every cell + * @property {Iterable>} [data] + * Two-dimensional iterable that defines the table's data. + * + * With the first dimension being the row, and the second being the column + * + * If provided the table will be automatically ended after the last row has been written, + * Otherwise it is up to the user to call `table.end()` or `table.row([], true)` + * @property {PDFStructureElement} [structParent] + * The parent structure to mount to + * + * This will cause the entire table to be enclosed in a Table structure + * with TR and TD/TH for cells + * @property {string} [id] + * Sets the accessible id for the table + * + * Defaults to `table-` + * @property {boolean} [debug] + * Whether to show the debug lines for all the cells + * + * Defaults to `false` + */ + +/** + * Fields exclusive to row styles + * @type {string[]} + */ +const ROW_FIELDS = ['height', 'minHeight', 'maxHeight']; +/** + * Fields exclusive to column styles + * @type {string[]} + */ +const COLUMN_FIELDS = ['width', 'minWidth', 'maxWidth']; +function memoize(fn, maxSize) { + const cache = new Map(); + return function () { + const key = arguments.length <= 0 ? undefined : arguments[0]; + if (!cache.has(key)) { + cache.set(key, fn(...arguments)); + if (cache.size > maxSize) cache.delete(cache.keys().next()); + } + return cache.get(key); + }; +} + +/** + * Simple object check. + * @param item + * @returns {boolean} + */ +function isObject(item) { + return item && typeof item === 'object' && !Array.isArray(item); +} + +/** + * Deep merge two objects. + * + * @template T + * @param {T} target + * @param sources + * @returns {T} + */ +function deepMerge(target) { + if (!isObject(target)) return target; + target = deepClone(target); + for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + sources[_key - 1] = arguments[_key]; + } + for (const source of sources) { + if (isObject(source)) { + for (const key in source) { + if (isObject(source[key])) { + if (!(key in target)) target[key] = {}; + target[key] = deepMerge(target[key], source[key]); + } else if (source[key] !== undefined) { + target[key] = deepClone(source[key]); + } + } + } + } + return target; +} +function deepClone(obj) { + let result = obj; + if (obj && typeof obj == 'object') { + result = Array.isArray(obj) ? [] : {}; + for (const key in obj) result[key] = deepClone(obj[key]); + } + return result; +} + +/** + * Normalize the row config + * @note The context here is the cell not the document + * + * @param {DefaultTableCell} [defaultStyleInternal] + * @returns {{ + * defaultStyle: TableCellStyle, + * defaultRowStyle: RowStyle, + * defaultColStyle: ColumnStyle + * }} + * @private + */ +function normalizedDefaultStyle(defaultStyleInternal) { + let defaultStyle = defaultStyleInternal; + // Force object form + if (typeof defaultStyle !== 'object') defaultStyle = { + text: defaultStyle + }; + const defaultRowStyle = Object.fromEntries(Object.entries(defaultStyle).filter(_ref => { + let [k] = _ref; + return ROW_FIELDS.includes(k); + })); + const defaultColStyle = Object.fromEntries(Object.entries(defaultStyle).filter(_ref2 => { + let [k] = _ref2; + return COLUMN_FIELDS.includes(k); + })); + defaultStyle.padding = normalizeSides(defaultStyle.padding); + defaultStyle.border = normalizeSides(defaultStyle.border); + defaultStyle.borderColor = normalizeSides(defaultStyle.borderColor); + defaultStyle.align = normalizeAlignment(defaultStyle.align); + return { + defaultStyle, + defaultRowStyle, + defaultColStyle + }; +} + +/** + * Normalize the row config + * + * @note The context here is the cell not the document + * + * @this PDFTable + * @memberOf PDFTable + * @param {RowStyle} defaultRowStyle + * @param {Dynamic} rowStyleInternal + * @param {number} i The target row + * @returns {NormalizedRowStyle} + * @private + */ +function normalizedRowStyle(defaultRowStyle, rowStyleInternal, i) { + let rowStyle = rowStyleInternal(i); + // Force object form + if (rowStyle == null || typeof rowStyle !== 'object') { + rowStyle = { + height: rowStyle + }; + } + // Normalize + rowStyle.padding = normalizeSides(rowStyle.padding); + rowStyle.border = normalizeSides(rowStyle.border); + rowStyle.borderColor = normalizeSides(rowStyle.borderColor); + rowStyle.align = normalizeAlignment(rowStyle.align); + + // Merge defaults + rowStyle = deepMerge(defaultRowStyle, rowStyle); + const document = this.document; + const page = document.page; + const contentHeight = page.contentHeight; + if (rowStyle.height == null || rowStyle.height === 'auto') { + rowStyle.height = 'auto'; + } else { + rowStyle.height = document.sizeToPoint(rowStyle.height, 0, page, contentHeight); + } + rowStyle.minHeight = document.sizeToPoint(rowStyle.minHeight, 0, page, contentHeight); + rowStyle.maxHeight = document.sizeToPoint(rowStyle.maxHeight, 0, page, contentHeight); + return rowStyle; +} + +/** + * Normalize the column config + * + * @note The context here is the document not the cell + * + * @param {ColumnStyle} defaultColStyle + * @param {Dynamic} colStyleInternal + * @param {number} i - The target column + * @returns {NormalizedColumnStyle} + * @private + */ +function normalizedColumnStyle(defaultColStyle, colStyleInternal, i) { + let colStyle = colStyleInternal(i); + // Force object form + if (colStyle == null || typeof colStyle !== 'object') { + colStyle = { + width: colStyle + }; + } + // Normalize + colStyle.padding = normalizeSides(colStyle.padding); + colStyle.border = normalizeSides(colStyle.border); + colStyle.borderColor = normalizeSides(colStyle.borderColor); + colStyle.align = normalizeAlignment(colStyle.align); + + // Merge defaults + colStyle = deepMerge(defaultColStyle, colStyle); + if (colStyle.width == null || colStyle.width === '*') { + colStyle.width = '*'; + } else { + colStyle.width = this.document.sizeToPoint(colStyle.width, 0, this.document.page, this._maxWidth // Use table width here for percentage scaling + ); + } + colStyle.minWidth = this.document.sizeToPoint(colStyle.minWidth, 0, this.document.page, this._maxWidth // Use table width here for percentage scaling + ); + colStyle.maxWidth = this.document.sizeToPoint(colStyle.maxWidth, 0, this.document.page, this._maxWidth // Use table width here for percentage scaling + ); + return colStyle; +} +function normalizeAlignment(align) { + return align == null || typeof align === 'string' ? { + x: align, + y: align + } : align; +} + +/** + * Normalize a table + * + * @this PDFTable + * @memberOf PDFTable + * @private + */ +function normalizeTable() { + var _opts$id, _opts$position, _opts$position2; + const doc = this.document; + const opts = this.opts; + + // Normalize config + let index = doc._tableIndex++; + this._id = new String((_opts$id = opts.id) !== null && _opts$id !== void 0 ? _opts$id : `table-${index}`); + this._position = { + x: doc.sizeToPoint((_opts$position = opts.position) === null || _opts$position === void 0 ? void 0 : _opts$position.x, doc.x), + y: doc.sizeToPoint((_opts$position2 = opts.position) === null || _opts$position2 === void 0 ? void 0 : _opts$position2.y, doc.y) + }; + this._maxWidth = doc.sizeToPoint(opts.maxWidth, doc.page.width - doc.page.margins.right - this._position.x); + const { + defaultStyle, + defaultColStyle, + defaultRowStyle + } = normalizedDefaultStyle(opts.defaultStyle); + this._defaultStyle = defaultStyle; + let colStyle; + if (opts.columnStyles) { + if (Array.isArray(opts.columnStyles)) { + colStyle = i => opts.columnStyles[i]; + } else if (typeof opts.columnStyles === 'function') { + // memoize all columns + colStyle = memoize(i => opts.columnStyles(i), Infinity); + } else if (typeof opts.columnStyles === 'object') { + colStyle = () => opts.columnStyles; + } + } + if (!colStyle) colStyle = () => ({}); + this._colStyle = normalizedColumnStyle.bind(this, defaultColStyle, colStyle); + let rowStyle; + if (opts.rowStyles) { + if (Array.isArray(opts.rowStyles)) { + rowStyle = i => opts.rowStyles[i]; + } else if (typeof opts.rowStyles === 'function') { + // Memoize the row configs in a rolling buffer + rowStyle = memoize(i => opts.rowStyles(i), 10); + } else if (typeof opts.rowStyles === 'object') { + rowStyle = () => opts.rowStyles; + } + } + if (!rowStyle) rowStyle = () => ({}); + this._rowStyle = normalizedRowStyle.bind(this, defaultRowStyle, rowStyle); +} + +/** + * Convert text into a string + * - null and undefined are preserved (as they will be ignored) + * - everything else is run through `String()` + * + * @param {*} text + * @returns {string} + * @private + */ +function normalizeText(text) { + // Parse out text + if (text != null) text = `${text}`; + return text; +} + +/** + * Normalize a cell config + * + * @this PDFTable + * @memberOf PDFTable + * @param {TableCellStyle} cell - The cell to mutate + * @param {number} rowIndex - The cells row + * @param {number} colIndex - The cells column + * @returns {NormalizedTableCellStyle} + * @private + */ +function normalizeCell(cell, rowIndex, colIndex) { + var _config$rowSpan, _config$colSpan, _config$align$x, _config$align$y, _config$textStrokeCol, _config$textColor, _config$textOptions, _config$id, _config$type; + const colStyle = this._colStyle(colIndex); + let rowStyle = this._rowStyle(rowIndex); + const font = deepMerge({}, colStyle.font, rowStyle.font, cell.font); + const customFont = Object.values(font).filter(v => v != null).length > 0; + const doc = this.document; + + // Initialize cell context + const rollbackFont = doc._fontSource; + const rollbackFontSize = doc._fontSize; + const rollbackFontFamily = doc._fontFamily; + if (customFont) { + if (font.src) doc.font(font.src, font.family); + if (font.size) doc.fontSize(font.size); + + // Refetch rowStyle to reflect font changes + rowStyle = this._rowStyle(rowIndex); + } + cell.padding = normalizeSides(cell.padding); + cell.border = normalizeSides(cell.border); + cell.borderColor = normalizeSides(cell.borderColor); + + // Cell takes highest priority, then row, then column, then defaultConfig + const config = deepMerge(this._defaultStyle, colStyle, rowStyle, cell); + config.rowIndex = rowIndex; + config.colIndex = colIndex; + config.font = font !== null && font !== void 0 ? font : {}; + config.customFont = customFont; + + // Normalize config + config.text = normalizeText(config.text); + config.rowSpan = (_config$rowSpan = config.rowSpan) !== null && _config$rowSpan !== void 0 ? _config$rowSpan : 1; + config.colSpan = (_config$colSpan = config.colSpan) !== null && _config$colSpan !== void 0 ? _config$colSpan : 1; + config.padding = normalizeSides(config.padding, '0.25em', x => doc.sizeToPoint(x, '0.25em')); + config.border = normalizeSides(config.border, 1, x => doc.sizeToPoint(x, 1)); + config.borderColor = normalizeSides(config.borderColor, 'black', x => x !== null && x !== void 0 ? x : 'black'); + config.align = normalizeAlignment(config.align); + config.align.x = (_config$align$x = config.align.x) !== null && _config$align$x !== void 0 ? _config$align$x : 'left'; + config.align.y = (_config$align$y = config.align.y) !== null && _config$align$y !== void 0 ? _config$align$y : 'top'; + config.textStroke = doc.sizeToPoint(config.textStroke, 0); + config.textStrokeColor = (_config$textStrokeCol = config.textStrokeColor) !== null && _config$textStrokeCol !== void 0 ? _config$textStrokeCol : 'black'; + config.textColor = (_config$textColor = config.textColor) !== null && _config$textColor !== void 0 ? _config$textColor : 'black'; + config.textOptions = (_config$textOptions = config.textOptions) !== null && _config$textOptions !== void 0 ? _config$textOptions : {}; + + // Accessibility settings + config.id = new String((_config$id = config.id) !== null && _config$id !== void 0 ? _config$id : `${this._id}-${rowIndex}-${colIndex}`); + config.type = ((_config$type = config.type) === null || _config$type === void 0 ? void 0 : _config$type.toUpperCase()) === 'TH' ? 'TH' : 'TD'; + if (config.scope) { + config.scope = config.scope.toLowerCase(); + if (config.scope === 'row') config.scope = 'Row';else if (config.scope === 'both') config.scope = 'Both';else if (config.scope === 'column') config.scope = 'Column'; + } + if (typeof this.opts.debug === 'boolean') config.debug = this.opts.debug; + + // Rollback font + if (customFont) doc.font(rollbackFont, rollbackFontFamily, rollbackFontSize); + return config; +} + +/** + * Normalize a row + * + * @this PDFTable + * @memberOf PDFTable + * @param {TableCell[]} row + * @param {number} rowIndex + * @returns {NormalizedTableCellStyle[]} + * @private + */ +function normalizeRow(row, rowIndex) { + if (!this._cellClaim) this._cellClaim = new Set(); + let colIndex = 0; + return row.map(cell => { + // Ensure TableCell + if (cell == null || typeof cell !== 'object') cell = { + text: cell + }; + + // Find the starting column of the cell + // Skipping over the claimed cells + while (this._cellClaim.has(`${rowIndex},${colIndex}`)) { + colIndex++; + } + cell = normalizeCell.call(this, cell, rowIndex, colIndex); + + // Claim any spanning cells + for (let i = 0; i < cell.rowSpan; i++) { + for (let j = 0; j < cell.colSpan; j++) { + this._cellClaim.add(`${rowIndex + i},${colIndex + j}`); + } + } + colIndex += cell.colSpan; + return cell; + }); +} + +/** + * Compute the widths of the columns, ensuring to distribute the star widths + * + * @this PDFTable + * @memberOf PDFTable + * @param {NormalizedTableCellStyle[]} row + * @private + */ +function ensure(row) { + // Width init + /** @type number[] **/ + this._columnWidths = []; + ensureColumnWidths.call(this, row.reduce((a, cell) => a + cell.colSpan, 0)); + + // Height init + /** @type number[] **/ + this._rowHeights = []; + /** @type number[] **/ + this._rowYPos = [this._position.y]; + /** @type {Set} **/ + this._rowBuffer = new Set(); +} + +/** + * Compute the widths of the columns, ensuring to distribute the star widths + * + * @this PDFTable + * @memberOf PDFTable + * @param {number} numCols + * @private + */ +function ensureColumnWidths(numCols) { + // Compute the widths + let starColumnIndexes = []; + let starMinAcc = 0; + let unclaimedWidth = this._maxWidth; + for (let i = 0; i < numCols; i++) { + let col = this._colStyle(i); + if (col.width === '*') { + starColumnIndexes[i] = col; + starMinAcc += col.minWidth; + } else { + unclaimedWidth -= col.width; + this._columnWidths[i] = col.width; + } + } + let starColCount = starColumnIndexes.reduce(x => x + 1, 0); + if (starMinAcc >= unclaimedWidth) { + // case 1 - there's no way to fit all columns within available width + // that's actually pretty bad situation with PDF as we have no horizontal scroll + starColumnIndexes.forEach((cell, i) => { + this._columnWidths[i] = cell.minWidth; + }); + } else if (starColCount > 0) { + // Otherwise we distribute evenly factoring in the cell bounds + starColumnIndexes.forEach((col, i) => { + let starSize = unclaimedWidth / starColCount; + this._columnWidths[i] = Math.max(starSize, col.minWidth); + if (col.maxWidth > 0) { + this._columnWidths[i] = Math.min(this._columnWidths[i], col.maxWidth); + } + unclaimedWidth -= this._columnWidths[i]; + starColCount--; + }); + } + let tempX = this._position.x; + this._columnXPos = Array.from(this._columnWidths, v => { + const t = tempX; + tempX += v; + return t; + }); +} + +/** + * Compute the dimensions of the cells + * + * @this PDFTable + * @memberOf PDFTable + * @param {NormalizedTableCellStyle[]} row + * @param {number} rowIndex + * @returns {{newPage: boolean, toRender: SizedNormalizedTableCellStyle[]}} + * @private + */ +function measure(row, rowIndex) { + // =================== + // Add cells to buffer + // =================== + row.forEach(cell => this._rowBuffer.add(cell)); + if (rowIndex > 0) { + this._rowYPos[rowIndex] = this._rowYPos[rowIndex - 1] + this._rowHeights[rowIndex - 1]; + } + const rowStyle = this._rowStyle(rowIndex); + + // ======================================================== + // Find any cells which are to finish rendering on this row + // ======================================================== + /** @type {SizedNormalizedTableCellStyle[]} */ + let toRender = []; + this._rowBuffer.forEach(cell => { + if (cell.rowIndex + cell.rowSpan - 1 === rowIndex) { + toRender.push(measureCell.call(this, cell, rowStyle.height)); + this._rowBuffer.delete(cell); + } + }); + + // ===================================================== + // Find the shared height for the row based on the cells + // ===================================================== + let rowHeight = rowStyle.height; + if (rowHeight === 'auto') { + // Compute remaining height on cells + rowHeight = toRender.reduce((acc, cell) => { + let minHeight = cell.textBounds.height + cell.padding.top + cell.padding.bottom; + for (let i = 0; i < cell.rowSpan - 1; i++) { + minHeight -= this._rowHeights[cell.rowIndex + i]; + } + return Math.max(acc, minHeight); + }, 0); + } + rowHeight = Math.max(rowHeight, rowStyle.minHeight); + if (rowStyle.maxHeight > 0) { + rowHeight = Math.min(rowHeight, rowStyle.maxHeight); + } + this._rowHeights[rowIndex] = rowHeight; + let newPage = false; + if (rowHeight > this.document.page.contentHeight) { + // We are unable to render this row on a single page, for now we log a warning and disable the newPage + console.warn(new Error(`Row ${rowIndex} requested more than the safe page height, row has been clamped`).stack.slice(7)); + this._rowHeights[rowIndex] = this.document.page.maxY() - this._rowYPos[rowIndex]; + } else if (this._rowYPos[rowIndex] + rowHeight >= this.document.page.maxY()) { + // If row is going to go over the safe page height then move it over to new page + this._rowYPos[rowIndex] = this.document.page.margins.top; + newPage = true; + } + + // ===================================================== + // Re-measure the cells using the know known height + // ===================================================== + return { + newPage, + toRender: toRender.map(cell => measureCell.call(this, cell, rowHeight)) + }; +} + +/** + * Compute the dimensions of the cell and its text + * + * @this PDFTable + * @memberOf PDFTable + * @param {NormalizedTableCellStyle} cell + * @param {number | 'auto'} rowHeight + * @returns {SizedNormalizedTableCellStyle} + * @private + */ +function measureCell(cell, rowHeight) { + var _cell$textOptions$rot; + // ==================== + // Calculate cell width + // ==================== + let cellWidth = 0; + + // Traverse all the columns of the cell + for (let i = 0; i < cell.colSpan; i++) { + cellWidth += this._columnWidths[cell.colIndex + i]; + } + + // ===================== + // Calculate cell height + // ===================== + let cellHeight = rowHeight; + if (cellHeight === 'auto') { + // The cells height is effectively infinite + // (although we clamp it to the page content size) + cellHeight = this.document.page.contentHeight; + } else { + // Add all the spanning rows heights to the cell + for (let i = 0; i < cell.rowSpan - 1; i++) { + cellHeight += this._rowHeights[cell.rowIndex + i]; + } + } + + // Allocated text space + const textAllocatedWidth = cellWidth - cell.padding.left - cell.padding.right; + const textAllocatedHeight = cellHeight - cell.padding.top - cell.padding.bottom; + + // Compute the text bounds + const rotation = (_cell$textOptions$rot = cell.textOptions.rotation) !== null && _cell$textOptions$rot !== void 0 ? _cell$textOptions$rot : 0; + const { + width: textMaxWidth, + height: textMaxHeight + } = computeBounds(rotation, textAllocatedWidth, textAllocatedHeight); + const textOptions = { + // Alignment is handled internally + align: cell.align.x, + ellipsis: true, + // Default make overflowing text ellipsis + stroke: cell.textStroke > 0, + fill: true, + // To fix the stroke issue + width: textMaxWidth, + height: textMaxHeight, + rotation, + // Allow the user to define any custom fields + ...cell.textOptions + }; + + // ======================== + // Calculate text height + // ======================== + + // Compute rendered bounds of the text given the constraints of the cell + let textBounds = { + x: 0, + y: 0, + width: 0, + height: 0 + }; + if (cell.text) { + var _cell$font, _cell$font2, _cell$font3; + const rollbackFont = this.document._fontSource; + const rollbackFontSize = this.document._fontSize; + const rollbackFontFamily = this.document._fontFamily; + if ((_cell$font = cell.font) !== null && _cell$font !== void 0 && _cell$font.src) this.document.font(cell.font.src, (_cell$font2 = cell.font) === null || _cell$font2 === void 0 ? void 0 : _cell$font2.family); + if ((_cell$font3 = cell.font) !== null && _cell$font3 !== void 0 && _cell$font3.size) this.document.fontSize(cell.font.size); + + // We first compute the un-rotated bounds so that we can calculate the width of the text + const unRotatedTextBounds = this.document.boundsOfString(cell.text, 0, 0, { + ...textOptions, + rotation: 0 + }); + textOptions.width = unRotatedTextBounds.width; + textOptions.height = unRotatedTextBounds.height; + + // Then compute the rendered bounds + textBounds = this.document.boundsOfString(cell.text, 0, 0, textOptions); + this.document.font(rollbackFont, rollbackFontFamily, rollbackFontSize); + } + return { + ...cell, + textOptions, + x: this._columnXPos[cell.colIndex], + y: this._rowYPos[cell.rowIndex], + textX: this._columnXPos[cell.colIndex] + cell.padding.left, + textY: this._rowYPos[cell.rowIndex] + cell.padding.top, + width: cellWidth, + height: cellHeight, + textAllocatedHeight, + textAllocatedWidth, + textBounds + }; +} + +/** + * Compute the horizon-locked bounding box of a rect + * + * @param {number} rotation + * @param {number} allocWidth + * @param {number} allocHeight + * + * @returns {{width: number, height: number}} + */ +function computeBounds(rotation, allocWidth, allocHeight) { + let textMaxWidth, textMaxHeight; + + // We use these a lot so pre-compute + const cos = cosine(rotation); + const sin = sine(rotation); + + // <---------------allocWidth----------------> + // A════════════════════F════════════════════B + // ║ ■■ ■ ║ + // ║ ■■ ■ ║ + // ║ ■■ ■ ║ + // ║ ■■ ■ ║ + // ║ ■■ ■ ║ + // ║ ■■ ■ ║ + // ║ ■■░░ ■ ║ + // ║ ■■ ░ ■ ║ + // ║ ■■ Θ ░ ■ ║ + // ║■■ ░ ■ ║ + // E- - - - - - - - - - - - - ■ - - - - - - -║ + // ║■ ■ ║ + // ║■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■║ + // ║ ■ ■║ + // ║ ■ G + // ║ ■ ■■║ + // ║ ■ ■■ ║ + // ║ ■ ■ ║ + // ║ ■ ■■ ║ + // ║ ■ ■ ║ + // ║ ■ ■■ ║ + // ║ ■ ■■ ║ + // ║ ■ ■ ║ + // ║ ■ ■■ ║ + // ║ ■ ■ ║ + // ║ ■ ■■ ║ + // ║ ■ ■■ ║ + // D════════════════════H════════════════════C + // + // Given a rectangle ABCD with a fixed side AB of width allocWidth. + // Find the largest (by area) inscribed rectangle EFGH, + // where the angle Θ is equal to rotation (between 0-90 degrees) + // + // From above we can infer + // > AF = EF * cos(Θ) + // > FB = AB - AF + // > FB = FG * sin(Θ) + // Rearrange + // > FG = FB / sin(Θ) + // Substitute + // > FG = (AB - EF*cos(Θ)) / sin(Θ) + // Area of a rectangle + // > A = EF * FG + // Substitute + // > A = EF * (AB - EF*cos(Θ)) / sin(Θ) + // > dA/dEF = (AB - 2*EF*cos(Θ)) / sin(Θ) + // Find peak at dA/dEF = 0 + // > 0 = (AB - 2*EF*cos(Θ)) / sin(Θ) + // > EF = AB / (2*cos(Θ)) + // Substitute + // > FG = (AB - (AB*cos(Θ)) / (2*cos(Θ))) / sin(Θ) + // > FG = AB / (2*sin(Θ)) + // + // Final outcome + // Length EF = AB / (2*cos(Θ)) + // Length FG = AB / (2*sin(Θ)) + if (rotation === 0 || rotation === 180) { + textMaxWidth = allocWidth; + textMaxHeight = allocHeight; + } else if (rotation === 90 || rotation === 270) { + textMaxWidth = allocHeight; + textMaxHeight = allocWidth; + } else if (rotation < 90 || rotation > 180 && rotation < 270) { + textMaxWidth = allocWidth / (2 * cos); + textMaxHeight = allocWidth / (2 * sin); + } else { + textMaxHeight = allocWidth / (2 * cos); + textMaxWidth = allocWidth / (2 * sin); + } + + // If The bounding box of the text is beyond the allocHeight + // then we need to clamp it and recompute the bounds + // This time we are computing the sizes based on the outer box ABCD + const EF = sin * textMaxWidth; + const FG = cos * textMaxHeight; + if (EF + FG > allocHeight) { + // > AB = EF * cos(Θ) + FG * sin(Θ) + // > BC = BG + GC + // > BG = FG * cos(Θ) + // > GC = EF * sin(Θ) + // > BC = FG * cos(Θ) + EF * sin(Θ) + // > AB = EF * cos(Θ) + FG * sin(Θ) + // Substitution solve + // > EF = (AB*cos(Θ) - BC*sin(Θ)) / (cos^2(Θ)-sin^2(Θ)) + // > FG = (BC*cos(Θ) - AB*sin(Θ)) / (cos^2(Θ)-sin^2(Θ)) + const denominator = cos * cos - sin * sin; + if (rotation === 0 || rotation === 180) { + textMaxWidth = allocWidth; + textMaxHeight = allocHeight; + } else if (rotation === 90 || rotation === 270) { + textMaxWidth = allocHeight; + textMaxHeight = allocWidth; + } else if (rotation < 90 || rotation > 180 && rotation < 270) { + textMaxWidth = (allocWidth * cos - allocHeight * sin) / denominator; + textMaxHeight = (allocHeight * cos - allocWidth * sin) / denominator; + } else { + textMaxHeight = (allocWidth * cos - allocHeight * sin) / denominator; + textMaxWidth = (allocHeight * cos - allocWidth * sin) / denominator; + } + } + return { + width: Math.abs(textMaxWidth), + height: Math.abs(textMaxHeight) + }; +} + +/** + * Add accessibility to a table + * + * @this PDFTable + * @memberOf PDFTable + * @private + */ +function accommodateTable() { + const structParent = this.opts.structParent; + if (structParent) { + this._tableStruct = this.document.struct('Table'); + this._tableStruct.dictionary.data.ID = this._id; + if (structParent instanceof PDFStructureElement) { + structParent.add(this._tableStruct); + } else if (structParent instanceof PDFDocument) { + structParent.addStructure(this._tableStruct); + } + this._headerRowLookup = {}; + this._headerColumnLookup = {}; + } +} + +/** + * Cleanup accessibility on a table + * + * @this PDFTable + * @memberOf PDFTable + * @private + */ +function accommodateCleanup() { + if (this._tableStruct) this._tableStruct.end(); +} + +/** + * Render a row with all its accessibility features + * + * @this PDFTable + * @memberOf PDFTable + * @param {SizedNormalizedTableCellStyle[]} row + * @param {number} rowIndex + * @param {Function} renderCell + * @private + */ +function accessibleRow(row, rowIndex, renderCell) { + const rowStruct = this.document.struct('TR'); + rowStruct.dictionary.data.ID = new String(`${this._id}-${rowIndex}`); + this._tableStruct.add(rowStruct); + row.forEach(cell => renderCell(cell, rowStruct)); + rowStruct.end(); +} + +/** + * Render a cell with all its accessibility features + * + * @this PDFTable + * @memberOf PDFTable + * @param {SizedNormalizedTableCellStyle} cell + * @param {PDFStructureElement} rowStruct + * @param {Function} callback + * @private + */ +function accessibleCell(cell, rowStruct, callback) { + const doc = this.document; + const cellStruct = doc.struct(cell.type, { + title: cell.title + }); + cellStruct.dictionary.data.ID = cell.id; + rowStruct.add(cellStruct); + const padding = cell.padding; + const border = cell.border; + const attributes = { + O: 'Table', + Width: cell.width, + Height: cell.height, + Padding: [padding.top, padding.bottom, padding.left, padding.right], + RowSpan: cell.rowSpan > 1 ? cell.rowSpan : undefined, + ColSpan: cell.colSpan > 1 ? cell.colSpan : undefined, + BorderThickness: [border.top, border.bottom, border.left, border.right] + }; + + // Claim row Headers + if (cell.type === 'TH') { + if (cell.scope === 'Row' || cell.scope === 'Both') { + for (let i = 0; i < cell.rowSpan; i++) { + if (!this._headerRowLookup[cell.rowIndex + i]) { + this._headerRowLookup[cell.rowIndex + i] = []; + } + this._headerRowLookup[cell.rowIndex + i].push(cell.id); + } + attributes.Scope = cell.scope; + } + if (cell.scope === 'Column' || cell.scope === 'Both') { + for (let i = 0; i < cell.colSpan; i++) { + if (!this._headerColumnLookup[cell.colIndex + i]) { + this._headerColumnLookup[cell.colIndex + i] = []; + } + this._headerColumnLookup[cell.colIndex + i].push(cell.id); + } + attributes.Scope = cell.scope; + } + } + + // Find any cells which are marked as headers for this cell + const Headers = new Set([...Array.from({ + length: cell.colSpan + }, (_, i) => this._headerColumnLookup[cell.colIndex + i]).flat(), ...Array.from({ + length: cell.rowSpan + }, (_, i) => this._headerRowLookup[cell.rowIndex + i]).flat()].filter(Boolean)); + if (Headers.size) attributes.Headers = Array.from(Headers); + const normalizeColor = doc._normalizeColor; + if (cell.backgroundColor != null) { + attributes.BackgroundColor = normalizeColor(cell.backgroundColor); + } + const hasBorder = [border.top, border.bottom, border.left, border.right]; + if (hasBorder.some(x => x)) { + const borderColor = cell.borderColor; + attributes.BorderColor = [hasBorder[0] ? normalizeColor(borderColor.top) : null, hasBorder[1] ? normalizeColor(borderColor.bottom) : null, hasBorder[2] ? normalizeColor(borderColor.left) : null, hasBorder[3] ? normalizeColor(borderColor.right) : null]; + } + + // Remove any undefined attributes + Object.keys(attributes).forEach(key => attributes[key] === undefined && delete attributes[key]); + cellStruct.dictionary.data.A = doc.ref(attributes); + cellStruct.add(callback); + cellStruct.end(); + cellStruct.dictionary.data.A.end(); +} + +/** + * Render a cell + * + * @this PDFTable + * @memberOf PDFTable + * @param {SizedNormalizedTableCellStyle[]} row + * @param {number} rowIndex + * @private + */ +function renderRow(row, rowIndex) { + if (this._tableStruct) { + accessibleRow.call(this, row, rowIndex, renderCell.bind(this)); + } else { + row.forEach(cell => renderCell.call(this, cell)); + } + return this._rowYPos[rowIndex] + this._rowHeights[rowIndex]; +} + +/** + * Render a cell + * + * @this PDFTable + * @memberOf PDFTable + * @param {SizedNormalizedTableCellStyle} cell + * @param {PDFStructureElement} rowStruct + * @private + */ +function renderCell(cell, rowStruct) { + const cellRenderer = () => { + // Render cell background + if (cell.backgroundColor != null) { + this.document.save().fillColor(cell.backgroundColor).rect(cell.x, cell.y, cell.width, cell.height).fill().restore(); + } + + // Render border + renderBorder.call(this, cell.border, cell.borderColor, cell.x, cell.y, cell.width, cell.height); + + // Debug cell borders + if (cell.debug) { + this.document.save(); + this.document.dash(1, { + space: 1 + }).lineWidth(1).strokeOpacity(0.3); + + // Debug cell bounds + this.document.rect(cell.x, cell.y, cell.width, cell.height).stroke('green'); + this.document.restore(); + } + + // Render text + if (cell.text) renderCellText.call(this, cell); + }; + if (rowStruct) accessibleCell.call(this, cell, rowStruct, cellRenderer);else cellRenderer(); +} + +/** + * @this PDFTable + * @memberOf PDFTable + * @param {SizedNormalizedTableCellStyle} cell + */ +function renderCellText(cell) { + const doc = this.document; + + // Configure fonts + const rollbackFont = doc._fontSource; + const rollbackFontSize = doc._fontSize; + const rollbackFontFamily = doc._fontFamily; + if (cell.customFont) { + if (cell.font.src) doc.font(cell.font.src, cell.font.family); + if (cell.font.size) doc.fontSize(cell.font.size); + } + const x = cell.textX; + const y = cell.textY; + const Ah = cell.textAllocatedHeight; + const Aw = cell.textAllocatedWidth; + const Cw = cell.textBounds.width; + const Ch = cell.textBounds.height; + const Ox = -cell.textBounds.x; + const Oy = -cell.textBounds.y; + const PxScale = cell.align.x === 'right' ? 1 : cell.align.x === 'center' ? 0.5 : 0; + const Px = (Aw - Cw) * PxScale; + const PyScale = cell.align.y === 'bottom' ? 1 : cell.align.y === 'center' ? 0.5 : 0; + const Py = (Ah - Ch) * PyScale; + const dx = Px + Ox; + const dy = Py + Oy; + if (cell.debug) { + doc.save(); + doc.dash(1, { + space: 1 + }).lineWidth(1).strokeOpacity(0.3); + + // Debug actual text bounds + if (cell.text) { + doc.moveTo(x + Px, y).lineTo(x + Px, y + Ah).moveTo(x + Px + Cw, y).lineTo(x + Px + Cw, y + Ah).stroke('blue').moveTo(x, y + Py).lineTo(x + Aw, y + Py).moveTo(x, y + Py + Ch).lineTo(x + Aw, y + Py + Ch).stroke('green'); + } + // Debug allocated text bounds + doc.rect(x, y, Aw, Ah).stroke('orange'); + doc.restore(); + } + + // Create text mask to cut off any overflowing text + // Mask cuts off at the padding not the actual cell, this is intentional! + doc.save().rect(x, y, Aw, Ah).clip(); + doc.fillColor(cell.textColor).strokeColor(cell.textStrokeColor); + if (cell.textStroke > 0) doc.lineWidth(cell.textStroke); + + // Render the text + doc.text(cell.text, x + dx, y + dy, cell.textOptions); + + // Cleanup + doc.restore(); + if (cell.font) doc.font(rollbackFont, rollbackFontFamily, rollbackFontSize); +} + +/** + * @this PDFTable + * @memberOf PDFTable + * @param {ExpandedSideDefinition} border + * @param {ExpandedSideDefinition} borderColor + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + * @param {number[]} [mask] + * @private + */ +function renderBorder(border, borderColor, x, y, width, height, mask) { + border = Object.fromEntries(Object.entries(border).map(_ref => { + let [k, v] = _ref; + return [k, mask && !mask[k] ? 0 : v]; + })); + const doc = this.document; + if ([border.right, border.bottom, border.left].every(val => val === border.top)) { + if (border.top > 0) { + doc.save().lineWidth(border.top).strokeColor(borderColor.top).rect(x, y, width, height).stroke().restore(); + } + } else { + // Top + if (border.top > 0) { + doc.save().lineWidth(border.top).moveTo(x, y).strokeColor(borderColor.top).lineTo(x + width, y).stroke().restore(); + } + // Right + if (border.right > 0) { + doc.save().lineWidth(border.right).moveTo(x + width, y).strokeColor(borderColor.right).lineTo(x + width, y + height).stroke().restore(); + } + // Bottom + if (border.bottom > 0) { + doc.save().lineWidth(border.bottom).moveTo(x + width, y + height).strokeColor(borderColor.bottom).lineTo(x, y + height).stroke().restore(); + } + // Left + if (border.left > 0) { + doc.save().lineWidth(border.left).moveTo(x, y + height).strokeColor(borderColor.left).lineTo(x, y).stroke().restore(); + } + } +} + +class PDFTable { + /** + * @param {PDFDocument} document + * @param {Table} [opts] + */ + constructor(document, opts) { + if (opts === void 0) { + opts = {}; + } + this.document = document; + this.opts = Object.freeze(opts); + normalizeTable.call(this); + accommodateTable.call(this); + this._currRowIndex = 0; + this._ended = false; + + // Render cells if present + if (opts.data) { + for (const row of opts.data) this.row(row); + return this.end(); + } + } + + /** + * Render a new row in the table + * + * @param {Iterable} row - The cells to render + * @param {boolean} lastRow - Whether this row is the last row + * @returns {this} returns the table, unless lastRow is `true` then returns the `PDFDocument` + */ + row(row, lastRow) { + if (lastRow === void 0) { + lastRow = false; + } + if (this._ended) { + throw new Error(`Table was marked as ended on row ${this._currRowIndex}`); + } + + // Convert the iterable into an array + row = Array.from(row); + // Transform row + row = normalizeRow.call(this, row, this._currRowIndex); + if (this._currRowIndex === 0) ensure.call(this, row); + const { + newPage, + toRender + } = measure.call(this, row, this._currRowIndex); + if (newPage) this.document.continueOnNewPage(); + const yPos = renderRow.call(this, toRender, this._currRowIndex); + + // Position document at base of new row + this.document.x = this._position.x; + this.document.y = yPos; + if (lastRow) return this.end(); + this._currRowIndex++; + return this; + } + + /** + * Indicates to the table that it is finished, + * allowing the table to flush its cell buffer (which should be empty unless there is rowSpans) + * + * @returns {PDFDocument} the document + */ + end() { + // Flush any remaining cells + while ((_this$_rowBuffer = this._rowBuffer) !== null && _this$_rowBuffer !== void 0 && _this$_rowBuffer.size) { + var _this$_rowBuffer; + this.row([]); + } + this._ended = true; + accommodateCleanup.call(this); + return this.document; + } +} + +var TableMixin = { + initTables() { + this._tableIndex = 0; + }, + /** + * @param {Table} [opts] + * @returns {PDFTable} returns the table object unless `data` is set, + * then it returns the underlying document + */ + table(opts) { + return new PDFTable(this, opts); + } +}; + +class PDFMetadata { + constructor() { + this._metadata = ` + + + + `; + } + _closeTags() { + this._metadata = this._metadata.concat(` + + + + `); + } + append(xml, newline) { + if (newline === void 0) { + newline = true; + } + this._metadata = this._metadata.concat(xml); + if (newline) this._metadata = this._metadata.concat('\n'); + } + getXML() { + return this._metadata; + } + getLength() { + return this._metadata.length; + } + end() { + this._closeTags(); + this._metadata = this._metadata.trim(); + } +} + +var MetadataMixin = { + initMetadata() { + this.metadata = new PDFMetadata(); + }, + appendXML(xml, newline) { + if (newline === void 0) { + newline = true; + } + this.metadata.append(xml, newline); + }, + _addInfo() { + this.appendXML(` + + ${this.info.CreationDate.toISOString().split('.')[0] + 'Z'} + ${this.info.Creator} + + `); + if (this.info.Title || this.info.Author || this.info.Subject) { + this.appendXML(` + + `); + if (this.info.Title) { + this.appendXML(` + + + ${this.info.Title} + + + `); + } + if (this.info.Author) { + this.appendXML(` + + + ${this.info.Author} + + + `); + } + if (this.info.Subject) { + this.appendXML(` + + + ${this.info.Subject} + + + `); + } + this.appendXML(` + + `); + } + this.appendXML(` + + ${this.info.Creator}`, false); + if (this.info.Keywords) { + this.appendXML(` + ${this.info.Keywords}`, false); + } + this.appendXML(` + + `); + }, + endMetadata() { + this._addInfo(); + this.metadata.end(); + + /* + Metadata was introduced in PDF 1.4, so adding it to 1.3 + will likely only take up more space. + */ + if (this.version != 1.3) { + this.metadataRef = this.ref({ + length: this.metadata.getLength(), + Type: 'Metadata', + Subtype: 'XML' + }); + this.metadataRef.compress = false; + this.metadataRef.write(Buffer$2.from(this.metadata.getXML(), 'utf-8')); + this.metadataRef.end(); + this._root.data.Metadata = this.metadataRef; + } + } +}; + +class PDFDocument extends stream.Readable { + constructor(options) { + if (options === void 0) { + options = {}; + } + super(options); + this.options = options; + + // PDF version + switch (options.pdfVersion) { + case '1.4': + this.version = 1.4; + break; + case '1.5': + this.version = 1.5; + break; + case '1.6': + this.version = 1.6; + break; + case '1.7': + case '1.7ext3': + this.version = 1.7; + break; + default: + this.version = 1.3; + break; + } + + // Whether streams should be compressed + this.compress = this.options.compress != null ? this.options.compress : true; + this._pageBuffer = []; + this._pageBufferStart = 0; + + // The PDF object store + this._offsets = []; + this._waiting = 0; + this._ended = false; + this._offset = 0; + const Pages = this.ref({ + Type: 'Pages', + Count: 0, + Kids: [] + }); + const Names = this.ref({ + Dests: new PDFNameTree() + }); + this._root = this.ref({ + Type: 'Catalog', + Pages, + Names + }); + if (this.options.lang) { + this._root.data.Lang = new String(this.options.lang); + } + if (this.options.pageLayout) { + const layout = this.options.pageLayout; + this._root.data.PageLayout = layout.charAt(0).toUpperCase() + layout.slice(1); + } + + // The current page + this.page = null; + + // Initialize mixins + this.initMetadata(); + this.initColor(); + this.initVector(); + this.initFonts(options.font); + this.initText(); + this.initImages(); + this.initOutline(); + this.initMarkings(options); + this.initTables(); + this.initSubset(options); + + // Initialize the metadata + this.info = { + Producer: 'PDFKit', + Creator: 'PDFKit', + CreationDate: new Date() + }; + if (this.options.info) { + for (let key in this.options.info) { + const val = this.options.info[key]; + this.info[key] = val; + } + } + if (this.options.displayTitle) { + this._root.data.ViewerPreferences = this.ref({ + DisplayDocTitle: true + }); + } + + // Generate file ID + this._id = PDFSecurity.generateFileID(this.info); + + // Initialize security settings + this._security = PDFSecurity.create(this, options); + + // Write the header + // PDF version + this._write(`%PDF-${this.version}`); + + // 4 binary chars, as recommended by the spec + this._write('%\xFF\xFF\xFF\xFF'); + + // Add the first page + if (this.options.autoFirstPage !== false) { + this.addPage(); + } + } + addPage(options) { + if (options == null) { + ({ + options + } = this); + } + + // end the current page if needed + if (!this.options.bufferPages) { + this.flushPages(); + } + + // create a page object + this.page = new PDFPage(this, options); + this._pageBuffer.push(this.page); + + // add the page to the object store + const pages = this._root.data.Pages.data; + pages.Kids.push(this.page.dictionary); + pages.Count++; + + // reset x and y coordinates + this.x = this.page.margins.left; + this.y = this.page.margins.top; + + // flip PDF coordinate system so that the origin is in + // the top left rather than the bottom left + this._ctm = [1, 0, 0, 1, 0, 0]; + this.transform(1, 0, 0, -1, 0, this.page.height); + this.emit('pageAdded'); + return this; + } + continueOnNewPage(options) { + const pageMarkings = this.endPageMarkings(this.page); + this.addPage(options !== null && options !== void 0 ? options : this.page._options); + this.initPageMarkings(pageMarkings); + return this; + } + bufferedPageRange() { + return { + start: this._pageBufferStart, + count: this._pageBuffer.length + }; + } + switchToPage(n) { + let page; + if (!(page = this._pageBuffer[n - this._pageBufferStart])) { + throw new Error(`switchToPage(${n}) out of bounds, current buffer covers pages ${this._pageBufferStart} to ${this._pageBufferStart + this._pageBuffer.length - 1}`); + } + return this.page = page; + } + flushPages() { + // this local variable exists so we're future-proof against + // reentrant calls to flushPages. + const pages = this._pageBuffer; + this._pageBuffer = []; + this._pageBufferStart += pages.length; + for (let page of pages) { + this.endPageMarkings(page); + page.end(); + } + } + addNamedDestination(name) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + if (args.length === 0) { + args = ['XYZ', null, null, null]; + } + if (args[0] === 'XYZ' && args[2] !== null) { + args[2] = this.page.height - args[2]; + } + args.unshift(this.page.dictionary); + this._root.data.Names.data.Dests.add(name, args); + } + addNamedEmbeddedFile(name, ref) { + if (!this._root.data.Names.data.EmbeddedFiles) { + // disabling /Limits for this tree fixes attachments not showing in Adobe Reader + this._root.data.Names.data.EmbeddedFiles = new PDFNameTree({ + limits: false + }); + } + + // add filespec to EmbeddedFiles + this._root.data.Names.data.EmbeddedFiles.add(name, ref); + } + addNamedJavaScript(name, js) { + if (!this._root.data.Names.data.JavaScript) { + this._root.data.Names.data.JavaScript = new PDFNameTree(); + } + let data = { + JS: new String(js), + S: 'JavaScript' + }; + this._root.data.Names.data.JavaScript.add(name, data); + } + ref(data) { + const ref = new PDFReference(this, this._offsets.length + 1, data); + this._offsets.push(null); // placeholder for this object's offset once it is finalized + this._waiting++; + return ref; + } + _read() {} + // do nothing, but this method is required by node + + _write(data) { + if (!Buffer$2.isBuffer(data)) { + data = Buffer$2.from(data + '\n', 'binary'); + } + this.push(data); + this._offset += data.length; + } + addContent(data) { + this.page.write(data); + return this; + } + _refEnd(ref) { + this._offsets[ref.id - 1] = ref.offset; + if (--this._waiting === 0 && this._ended) { + this._finalize(); + this._ended = false; + } + } + end() { + this.flushPages(); + this._info = this.ref(); + for (let key in this.info) { + let val = this.info[key]; + if (typeof val === 'string') { + val = new String(val); + } + let entry = this.ref(val); + entry.end(); + this._info.data[key] = entry; + } + this._info.end(); + for (let name in this._fontFamilies) { + const font = this._fontFamilies[name]; + font.finalize(); + } + this.endOutline(); + this.endMarkings(); + if (this.subset) { + this.endSubset(); + } + this.endMetadata(); + this._root.end(); + this._root.data.Pages.end(); + this._root.data.Names.end(); + this.endAcroForm(); + if (this._root.data.ViewerPreferences) { + this._root.data.ViewerPreferences.end(); + } + if (this._security) { + this._security.end(); + } + if (this._waiting === 0) { + this._finalize(); + } else { + this._ended = true; + } + } + _finalize() { + // generate xref + const xRefOffset = this._offset; + this._write('xref'); + this._write(`0 ${this._offsets.length + 1}`); + this._write('0000000000 65535 f '); + for (let offset of this._offsets) { + offset = `0000000000${offset}`.slice(-10); + this._write(offset + ' 00000 n '); + } + + // trailer + const trailer = { + Size: this._offsets.length + 1, + Root: this._root, + Info: this._info, + ID: [this._id, this._id] + }; + if (this._security) { + trailer.Encrypt = this._security.dictionary; + } + this._write('trailer'); + this._write(PDFObject.convert(trailer)); + this._write('startxref'); + this._write(`${xRefOffset}`); + this._write('%%EOF'); + + // end the stream + this.push(null); + } + toString() { + return '[object PDFDocument]'; + } +} +const mixin = methods => { + Object.assign(PDFDocument.prototype, methods); +}; +mixin(MetadataMixin); +mixin(ColorMixin); +mixin(VectorMixin); +mixin(FontsMixin); +mixin(TextMixin); +mixin(ImagesMixin); +mixin(AnnotationsMixin); +mixin(OutlineMixin); +mixin(MarkingsMixin); +mixin(AcroFormMixin); +mixin(AttachmentsMixin); +mixin(SubsetMixin); +mixin(TableMixin); +PDFDocument.LineWrapper = LineWrapper; + +export { PDFDocument as default }; diff --git a/node_modules/@react-pdf/pdfkit/lib/pdfkit.js b/node_modules/@react-pdf/pdfkit/lib/pdfkit.js new file mode 100644 index 0000000000000000000000000000000000000000..3619d74e5c24c7533603a9dc41b45fbd4a7465b0 --- /dev/null +++ b/node_modules/@react-pdf/pdfkit/lib/pdfkit.js @@ -0,0 +1,42318 @@ +import stream from 'stream'; +import zlib from 'zlib'; +import md5 from 'js-md5'; +import { cbc, ecb } from '@noble/ciphers/aes'; +import * as fontkit from 'fontkit'; +import fs from 'fs'; +import { EventEmitter } from 'events'; +import LineBreaker from 'linebreak'; +import _JPEG from 'jay-peg'; +import PNG from 'png-js'; + +/* +PDFReference - represents a reference to another object in the PDF object heirarchy +By Devon Govett +*/ + +class PDFReference extends stream.Writable { + constructor(document, id, data) { + super({ + decodeStrings: false + }); + this.finalize = this.finalize.bind(this); + this.document = document; + this.id = id; + if (data == null) { + data = {}; + } + this.data = data; + this.gen = 0; + this.deflate = null; + this.compress = this.document.compress && !this.data.Filter; + this.uncompressedLength = 0; + this.chunks = []; + } + initDeflate() { + this.data.Filter = 'FlateDecode'; + this.deflate = zlib.createDeflate(); + this.deflate.on('data', chunk => { + this.chunks.push(chunk); + return this.data.Length += chunk.length; + }); + return this.deflate.on('end', this.finalize); + } + _write(chunk, encoding, callback) { + if (!(chunk instanceof Uint8Array)) { + chunk = Buffer.from(chunk + '\n', 'binary'); + } + this.uncompressedLength += chunk.length; + if (this.data.Length == null) { + this.data.Length = 0; + } + if (this.compress) { + if (!this.deflate) { + this.initDeflate(); + } + this.deflate.write(chunk); + } else { + this.chunks.push(chunk); + this.data.Length += chunk.length; + } + return callback(); + } + end() { + super.end(...arguments); + if (this.deflate) { + return this.deflate.end(); + } + return this.finalize(); + } + finalize() { + this.offset = this.document._offset; + const encryptFn = this.document._security ? this.document._security.getEncryptFn(this.id, this.gen) : null; + if (this.chunks.length) { + let buffer = Buffer.concat(this.chunks); + if (encryptFn) { + buffer = encryptFn(buffer); + } + this.data.Length = buffer.length; + this.document._write(`${this.id} ${this.gen} obj`); + this.document._write(PDFObject.convert(this.data, encryptFn)); + this.document._write('stream'); + this.document._write(buffer); + this.chunks.length = 0; + this.document._write('\nendstream'); + } else { + this.document._write(`${this.id} ${this.gen} obj`); + this.document._write(PDFObject.convert(this.data, encryptFn)); + } + this.document._write('endobj'); + return this.document._refEnd(this); + } + toString() { + return `${this.id} ${this.gen} R`; + } +} + +/* +PDFTree - abstract base class for name and number tree objects +*/ + +class PDFTree { + constructor(options) { + if (options === void 0) { + options = {}; + } + this._items = {}; + // disable /Limits output for this tree + this.limits = typeof options.limits === 'boolean' ? options.limits : true; + } + add(key, val) { + return this._items[key] = val; + } + get(key) { + return this._items[key]; + } + toString() { + // Needs to be sorted by key + const sortedKeys = Object.keys(this._items).sort((a, b) => this._compareKeys(a, b)); + const out = ['<<']; + if (this.limits && sortedKeys.length > 1) { + const first = sortedKeys[0], + last = sortedKeys[sortedKeys.length - 1]; + out.push(` /Limits ${PDFObject.convert([this._dataForKey(first), this._dataForKey(last)])}`); + } + out.push(` /${this._keysName()} [`); + for (let key of sortedKeys) { + out.push(` ${PDFObject.convert(this._dataForKey(key))} ${PDFObject.convert(this._items[key])}`); + } + out.push(']'); + out.push('>>'); + return out.join('\n'); + } + _compareKeys( /*a, b*/ + ) { + throw new Error('Must be implemented by subclasses'); + } + _keysName() { + throw new Error('Must be implemented by subclasses'); + } + _dataForKey( /*k*/ + ) { + throw new Error('Must be implemented by subclasses'); + } +} + +/* +PDFNameTree - represents a name tree object +*/ + +class PDFNameTree extends PDFTree { + _compareKeys(a, b) { + return a.localeCompare(b); + } + _keysName() { + return 'Names'; + } + _dataForKey(k) { + return new String(k); + } +} + +/* +PDFObject - converts JavaScript types into their corresponding PDF types. +By Devon Govett +*/ + +const pad = (str, length) => (Array(length + 1).join('0') + str).slice(-length); +const escapableRe = /[\n\r\t\b\f()\\]/g; +const escapable = { + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\b': '\\b', + '\f': '\\f', + '\\': '\\\\', + '(': '\\(', + ')': '\\)' +}; + +// Convert little endian UTF-16 to big endian +const swapBytes = function (buff) { + const l = buff.length; + if (l & 0x01) { + throw new Error('Buffer length must be even'); + } else { + for (let i = 0, end = l - 1; i < end; i += 2) { + const a = buff[i]; + buff[i] = buff[i + 1]; + buff[i + 1] = a; + } + } + return buff; +}; +class PDFObject { + static convert(object, encryptFn) { + if (encryptFn === void 0) { + encryptFn = null; + } + // String literals are converted to the PDF name type + if (typeof object === 'string') { + return `/${object}`; + } + + // String objects are converted to PDF strings (UTF-16) + if (object instanceof String) { + let string = object; + // Detect if this is a unicode string + let isUnicode = false; + for (let i = 0, end = string.length; i < end; i++) { + if (string.charCodeAt(i) > 0x7f) { + isUnicode = true; + break; + } + } + + // If so, encode it as big endian UTF-16 + let stringBuffer; + if (isUnicode) { + stringBuffer = swapBytes(Buffer.from(`\ufeff${string}`, 'utf16le')); + } else { + stringBuffer = Buffer.from(string.valueOf(), 'ascii'); + } + + // Encrypt the string when necessary + if (encryptFn) { + string = encryptFn(stringBuffer).toString('binary'); + } else { + string = stringBuffer.toString('binary'); + } + + // Escape characters as required by the spec + string = string.replace(escapableRe, c => escapable[c]); + return `(${string})`; + + // Buffers are converted to PDF hex strings + } + if (Buffer.isBuffer(object)) { + return `<${object.toString('hex')}>`; + } + if (object instanceof PDFReference || object instanceof PDFNameTree) { + return object.toString(); + } + if (object instanceof Date) { + let string = `D:${pad(object.getUTCFullYear(), 4)}` + pad(object.getUTCMonth() + 1, 2) + pad(object.getUTCDate(), 2) + pad(object.getUTCHours(), 2) + pad(object.getUTCMinutes(), 2) + pad(object.getUTCSeconds(), 2) + 'Z'; + + // Encrypt the string when necessary + if (encryptFn) { + string = encryptFn(Buffer.from(string, 'ascii')).toString('binary'); + string = string.replace(escapableRe, c => escapable[c]); + } + return `(${string})`; + } + if (Array.isArray(object)) { + const items = Array.from(object).map(e => PDFObject.convert(e, encryptFn)).join(' '); + return `[${items}]`; + } + if ({}.toString.call(object) === '[object Object]') { + const out = ['<<']; + for (let key in object) { + const val = object[key]; + out.push(`/${key} ${PDFObject.convert(val, encryptFn)}`); + } + out.push('>>'); + return out.join('\n'); + } + if (typeof object === 'number') { + return PDFObject.number(object); + } + return `${object}`; + } + static number(n) { + if (n > -1e21 && n < 1e21) { + return Math.round(n * 1e6) / 1e6; + } + throw new Error(`unsupported number: ${n}`); + } +} + +/* +PDFPage - represents a single page in the PDF document +By Devon Govett +*/ + +/** + * @type {SideDefinition} + */ +const DEFAULT_MARGINS = { + top: 72, + left: 72, + bottom: 72, + right: 72 +}; +const SIZES = { + '4A0': [4767.87, 6740.79], + '2A0': [3370.39, 4767.87], + A0: [2383.94, 3370.39], + A1: [1683.78, 2383.94], + A2: [1190.55, 1683.78], + A3: [841.89, 1190.55], + A4: [595.28, 841.89], + A5: [419.53, 595.28], + A6: [297.64, 419.53], + A7: [209.76, 297.64], + A8: [147.4, 209.76], + A9: [104.88, 147.4], + A10: [73.7, 104.88], + B0: [2834.65, 4008.19], + B1: [2004.09, 2834.65], + B2: [1417.32, 2004.09], + B3: [1000.63, 1417.32], + B4: [708.66, 1000.63], + B5: [498.9, 708.66], + B6: [354.33, 498.9], + B7: [249.45, 354.33], + B8: [175.75, 249.45], + B9: [124.72, 175.75], + B10: [87.87, 124.72], + C0: [2599.37, 3676.54], + C1: [1836.85, 2599.37], + C2: [1298.27, 1836.85], + C3: [918.43, 1298.27], + C4: [649.13, 918.43], + C5: [459.21, 649.13], + C6: [323.15, 459.21], + C7: [229.61, 323.15], + C8: [161.57, 229.61], + C9: [113.39, 161.57], + C10: [79.37, 113.39], + RA0: [2437.8, 3458.27], + RA1: [1729.13, 2437.8], + RA2: [1218.9, 1729.13], + RA3: [864.57, 1218.9], + RA4: [609.45, 864.57], + SRA0: [2551.18, 3628.35], + SRA1: [1814.17, 2551.18], + SRA2: [1275.59, 1814.17], + SRA3: [907.09, 1275.59], + SRA4: [637.8, 907.09], + EXECUTIVE: [521.86, 756.0], + FOLIO: [612.0, 936.0], + LEGAL: [612.0, 1008.0], + LETTER: [612.0, 792.0], + TABLOID: [792.0, 1224.0] +}; +class PDFPage { + constructor(document, options) { + if (options === void 0) { + options = {}; + } + this.document = document; + this._options = options; + this.size = options.size || 'letter'; + this.layout = options.layout || 'portrait'; + this.userUnit = options.userUnit || 1.0; + + // process margins + if (typeof options.margin === 'number') { + this.margins = { + top: options.margin, + left: options.margin, + bottom: options.margin, + right: options.margin + }; + + // default to 1 inch margins + } else { + this.margins = options.margins || DEFAULT_MARGINS; + } + + // calculate page dimensions + const dimensions = Array.isArray(this.size) ? this.size : SIZES[this.size.toUpperCase()]; + this.width = dimensions[this.layout === 'portrait' ? 0 : 1]; + this.height = dimensions[this.layout === 'portrait' ? 1 : 0]; + this.content = this.document.ref(); + if (options.font) document.font(options.font, options.fontFamily); + if (options.fontSize) document.fontSize(options.fontSize); + + // Initialize the Font, XObject, and ExtGState dictionaries + this.resources = this.document.ref({ + ProcSet: ['PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'] + }); + + // The page dictionary + this.dictionary = this.document.ref({ + Type: 'Page', + Parent: this.document._root.data.Pages, + MediaBox: [0, 0, this.width, this.height], + Contents: this.content, + Resources: this.resources, + UserUnit: this.userUnit + }); + this.markings = []; + } + + // Lazily create these objects + get fonts() { + const data = this.resources.data; + return data.Font != null ? data.Font : data.Font = {}; + } + get xobjects() { + const data = this.resources.data; + return data.XObject != null ? data.XObject : data.XObject = {}; + } + get ext_gstates() { + const data = this.resources.data; + return data.ExtGState != null ? data.ExtGState : data.ExtGState = {}; + } + get patterns() { + const data = this.resources.data; + return data.Pattern != null ? data.Pattern : data.Pattern = {}; + } + get colorSpaces() { + const data = this.resources.data; + return data.ColorSpace || (data.ColorSpace = {}); + } + get annotations() { + const data = this.dictionary.data; + return data.Annots != null ? data.Annots : data.Annots = []; + } + get structParentTreeKey() { + const data = this.dictionary.data; + return data.StructParents != null ? data.StructParents : data.StructParents = this.document.createStructParentTreeNextKey(); + } + maxY() { + return this.height - this.margins.bottom; + } + write(chunk) { + return this.content.write(chunk); + } + + // Set tab order if document is tagged for accessibility. + _setTabOrder() { + if (!this.dictionary.Tabs && this.document.hasMarkInfoDictionary()) { + this.dictionary.data.Tabs = 'S'; + } + } + end() { + this._setTabOrder(); + this.dictionary.end(); + this.resources.data.ColorSpace = this.resources.data.ColorSpace || {}; + for (let color of Object.values(this.document.spotColors)) { + this.resources.data.ColorSpace[color.id] = color; + } + this.resources.end(); + return this.content.end(); + } +} + +function md5Hash(data) { + return new Uint8Array(md5.arrayBuffer(data)); +} +function md5Hex(data) { + return md5(data); +} + +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. +// node.js versions earlier than v19 don't declare it in global scope. +// For node.js, package.json#exports field mapping rewrites import +// from `crypto` to `cryptoNode`, which imports native module. +// Makes the utils un-importable in browsers without a bundler. +// Once node.js 18 is deprecated (2025-04-30), we can just drop the import. +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +function isBytes(a) { + return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'; +} +/** Asserts something is Uint8Array. */ +function abytes(b) { + if (!isBytes(b)) throw new Error('Uint8Array expected'); + for (var _len = arguments.length, lengths = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + lengths[_key - 1] = arguments[_key]; + } + if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length); +} +/** Asserts a hash instance has not been destroyed / finished */ +function aexists(instance, checkFinished) { + if (checkFinished === void 0) { + checkFinished = true; + } + if (instance.destroyed) throw new Error('Hash instance has been destroyed'); + if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); +} +/** Asserts output is properly-sized byte array */ +function aoutput(out, instance) { + abytes(out); + const min = instance.outputLen; + if (out.length < min) { + throw new Error('digestInto() expects output buffer of length at least ' + min); + } +} +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +function clean() { + for (var _len2 = arguments.length, arrays = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + arrays[_key2] = arguments[_key2]; + } + for (let i = 0; i < arrays.length; i++) { + arrays[i].fill(0); + } +} +/** Create DataView of an array for easy byte-level manipulation. */ +function createView(arr) { + return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); +} +/** The rotate right (circular right shift) operation for uint32 */ +function rotr(word, shift) { + return word << 32 - shift | word >>> shift; +} +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99]) + */ +function utf8ToBytes(str) { + if (typeof str !== 'string') throw new Error('string expected'); + return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 +} +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +function toBytes(data) { + if (typeof data === 'string') data = utf8ToBytes(data); + abytes(data); + return data; +} +/** For runtime check if class implements interface */ +class Hash {} +/** Wraps hash function, creating an interface on top of it */ +function createHasher(hashCons) { + const hashC = msg => hashCons().update(toBytes(msg)).digest(); + const tmp = hashCons(); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = () => hashCons(); + return hashC; +} + +/** + * Internal Merkle-Damgard hash utils. + * @module + */ +/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */ +function setBigUint64(view, byteOffset, value, isLE) { + if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE); + const _32n = BigInt(32); + const _u32_max = BigInt(0xffffffff); + const wh = Number(value >> _32n & _u32_max); + const wl = Number(value & _u32_max); + const h = isLE ? 4 : 0; + const l = isLE ? 0 : 4; + view.setUint32(byteOffset + h, wh, isLE); + view.setUint32(byteOffset + l, wl, isLE); +} +/** Choice: a ? b : c */ +function Chi(a, b, c) { + return a & b ^ ~a & c; +} +/** Majority function, true if any two inputs is true. */ +function Maj(a, b, c) { + return a & b ^ a & c ^ b & c; +} +/** + * Merkle-Damgard hash construction base class. + * Could be used to create MD5, RIPEMD, SHA1, SHA2. + */ +class HashMD extends Hash { + constructor(blockLen, outputLen, padOffset, isLE) { + super(); + this.finished = false; + this.length = 0; + this.pos = 0; + this.destroyed = false; + this.blockLen = blockLen; + this.outputLen = outputLen; + this.padOffset = padOffset; + this.isLE = isLE; + this.buffer = new Uint8Array(blockLen); + this.view = createView(this.buffer); + } + update(data) { + aexists(this); + data = toBytes(data); + abytes(data); + const { + view, + buffer, + blockLen + } = this; + const len = data.length; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input, cast it to view and process + if (take === blockLen) { + const dataView = createView(data); + for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.process(view, 0); + this.pos = 0; + } + } + this.length += data.length; + this.roundClean(); + return this; + } + digestInto(out) { + aexists(this); + aoutput(out, this); + this.finished = true; + // Padding + // We can avoid allocation of buffer for padding completely if it + // was previously not allocated here. But it won't change performance. + const { + buffer, + view, + blockLen, + isLE + } = this; + let { + pos + } = this; + // append the bit '1' to the message + buffer[pos++] = 0b10000000; + clean(this.buffer.subarray(pos)); + // we have less than padOffset left in buffer, so we cannot put length in + // current block, need process it and pad again + if (this.padOffset > blockLen - pos) { + this.process(view, 0); + pos = 0; + } + // Pad until full block byte with zeros + for (let i = pos; i < blockLen; i++) buffer[i] = 0; + // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that + // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen. + // So we just write lowest 64 bits of that value. + setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE); + this.process(view, 0); + const oview = createView(out); + const len = this.outputLen; + // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT + if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit'); + const outLen = len / 4; + const state = this.get(); + if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state'); + for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE); + } + digest() { + const { + buffer, + outputLen + } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } + _cloneInto(to) { + to || (to = new this.constructor()); + to.set(...this.get()); + const { + blockLen, + buffer, + length, + finished, + destroyed, + pos + } = this; + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + if (length % blockLen) to.buffer.set(buffer); + return to; + } + clone() { + return this._cloneInto(); + } +} +/** + * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53. + * Check out `test/misc/sha2-gen-iv.js` for recomputation guide. + */ +/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */ +const SHA256_IV = /* @__PURE__ */Uint32Array.from([0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]); + +/** + * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256. + * SHA256 is the fastest hash implementable in JS, even faster than Blake3. + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + */ +/** + * Round constants: + * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311) + */ +// prettier-ignore +const SHA256_K = /* @__PURE__ */Uint32Array.from([0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2]); +/** Reusable temporary buffer. "W" comes straight from spec. */ +const SHA256_W = /* @__PURE__ */new Uint32Array(64); +class SHA256 extends HashMD { + constructor(outputLen) { + if (outputLen === void 0) { + outputLen = 32; + } + super(64, outputLen, 8, false); + // We cannot use array here since array allows indexing by variable + // which means optimizer/compiler cannot use registers. + this.A = SHA256_IV[0] | 0; + this.B = SHA256_IV[1] | 0; + this.C = SHA256_IV[2] | 0; + this.D = SHA256_IV[3] | 0; + this.E = SHA256_IV[4] | 0; + this.F = SHA256_IV[5] | 0; + this.G = SHA256_IV[6] | 0; + this.H = SHA256_IV[7] | 0; + } + get() { + const { + A, + B, + C, + D, + E, + F, + G, + H + } = this; + return [A, B, C, D, E, F, G, H]; + } + // prettier-ignore + set(A, B, C, D, E, F, G, H) { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + this.E = E | 0; + this.F = F | 0; + this.G = G | 0; + this.H = H | 0; + } + process(view, offset) { + // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array + for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false); + for (let i = 16; i < 64; i++) { + const W15 = SHA256_W[i - 15]; + const W2 = SHA256_W[i - 2]; + const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3; + const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10; + SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0; + } + // Compression function main loop, 64 rounds + let { + A, + B, + C, + D, + E, + F, + G, + H + } = this; + for (let i = 0; i < 64; i++) { + const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25); + const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0; + const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22); + const T2 = sigma0 + Maj(A, B, C) | 0; + H = G; + G = F; + F = E; + E = D + T1 | 0; + D = C; + C = B; + B = A; + A = T1 + T2 | 0; + } + // Add the compressed chunk to the current hash value + A = A + this.A | 0; + B = B + this.B | 0; + C = C + this.C | 0; + D = D + this.D | 0; + E = E + this.E | 0; + F = F + this.F | 0; + G = G + this.G | 0; + H = H + this.H | 0; + this.set(A, B, C, D, E, F, G, H); + } + roundClean() { + clean(SHA256_W); + } + destroy() { + this.set(0, 0, 0, 0, 0, 0, 0, 0); + clean(this.buffer); + } +} +/** + * SHA2-256 hash function from RFC 4634. + * + * It is the fastest JS hash, even faster than Blake3. + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + */ +const sha256 = /* @__PURE__ */createHasher(() => new SHA256()); + +function sha256Hash(data) { + return sha256(data); +} + +function aesCbcEncrypt(data, key, iv, padding) { + if (padding === void 0) { + padding = true; + } + return cbc(key, iv, { + disablePadding: !padding + }).encrypt(data); +} +function aesEcbEncrypt(data, key) { + return ecb(key, { + disablePadding: true + }).encrypt(data); +} + +// RC4 (for legacy PDF 1.3-1.5) +function rc4(data, key) { + const s = new Uint8Array(256); + for (let i = 0; i < 256; i++) { + s[i] = i; + } + let j = 0; + for (let i = 0; i < 256; i++) { + j = j + s[i] + key[i % key.length] & 0xff; + [s[i], s[j]] = [s[j], s[i]]; + } + const output = new Uint8Array(data.length); + for (let i = 0, j = 0, k = 0; k < data.length; k++) { + i = i + 1 & 0xff; + j = j + s[i] & 0xff; + [s[i], s[j]] = [s[j], s[i]]; + output[k] = data[k] ^ s[s[i] + s[j] & 0xff]; + } + return output; +} + +function randomBytes(length) { + const bytes = new Uint8Array(length); + globalThis.crypto.getRandomValues(bytes); + return bytes; +} + +/** + * Check if value is in a range group. + * @param {number} value + * @param {number[]} rangeGroup + * @returns {boolean} + */ +function inRange(value, rangeGroup) { + if (value < rangeGroup[0]) return false; + let startRange = 0; + let endRange = rangeGroup.length / 2; + while (startRange <= endRange) { + const middleRange = Math.floor((startRange + endRange) / 2); + + // actual array index + const arrayIndex = middleRange * 2; + + // Check if value is in range pointed by actual index + if (value >= rangeGroup[arrayIndex] && value <= rangeGroup[arrayIndex + 1]) { + return true; + } + if (value > rangeGroup[arrayIndex + 1]) { + // Search Right Side Of Array + startRange = middleRange + 1; + } else { + // Search Left Side Of Array + endRange = middleRange - 1; + } + } + return false; +} + +// prettier-ignore-start +/** + * A.1 Unassigned code points in Unicode 3.2 + * @link https://tools.ietf.org/html/rfc3454#appendix-A.1 + */ +const unassigned_code_points = [0x0221, 0x0221, 0x0234, 0x024f, 0x02ae, 0x02af, 0x02ef, 0x02ff, 0x0350, 0x035f, 0x0370, 0x0373, 0x0376, 0x0379, 0x037b, 0x037d, 0x037f, 0x0383, 0x038b, 0x038b, 0x038d, 0x038d, 0x03a2, 0x03a2, 0x03cf, 0x03cf, 0x03f7, 0x03ff, 0x0487, 0x0487, 0x04cf, 0x04cf, 0x04f6, 0x04f7, 0x04fa, 0x04ff, 0x0510, 0x0530, 0x0557, 0x0558, 0x0560, 0x0560, 0x0588, 0x0588, 0x058b, 0x0590, 0x05a2, 0x05a2, 0x05ba, 0x05ba, 0x05c5, 0x05cf, 0x05eb, 0x05ef, 0x05f5, 0x060b, 0x060d, 0x061a, 0x061c, 0x061e, 0x0620, 0x0620, 0x063b, 0x063f, 0x0656, 0x065f, 0x06ee, 0x06ef, 0x06ff, 0x06ff, 0x070e, 0x070e, 0x072d, 0x072f, 0x074b, 0x077f, 0x07b2, 0x0900, 0x0904, 0x0904, 0x093a, 0x093b, 0x094e, 0x094f, 0x0955, 0x0957, 0x0971, 0x0980, 0x0984, 0x0984, 0x098d, 0x098e, 0x0991, 0x0992, 0x09a9, 0x09a9, 0x09b1, 0x09b1, 0x09b3, 0x09b5, 0x09ba, 0x09bb, 0x09bd, 0x09bd, 0x09c5, 0x09c6, 0x09c9, 0x09ca, 0x09ce, 0x09d6, 0x09d8, 0x09db, 0x09de, 0x09de, 0x09e4, 0x09e5, 0x09fb, 0x0a01, 0x0a03, 0x0a04, 0x0a0b, 0x0a0e, 0x0a11, 0x0a12, 0x0a29, 0x0a29, 0x0a31, 0x0a31, 0x0a34, 0x0a34, 0x0a37, 0x0a37, 0x0a3a, 0x0a3b, 0x0a3d, 0x0a3d, 0x0a43, 0x0a46, 0x0a49, 0x0a4a, 0x0a4e, 0x0a58, 0x0a5d, 0x0a5d, 0x0a5f, 0x0a65, 0x0a75, 0x0a80, 0x0a84, 0x0a84, 0x0a8c, 0x0a8c, 0x0a8e, 0x0a8e, 0x0a92, 0x0a92, 0x0aa9, 0x0aa9, 0x0ab1, 0x0ab1, 0x0ab4, 0x0ab4, 0x0aba, 0x0abb, 0x0ac6, 0x0ac6, 0x0aca, 0x0aca, 0x0ace, 0x0acf, 0x0ad1, 0x0adf, 0x0ae1, 0x0ae5, 0x0af0, 0x0b00, 0x0b04, 0x0b04, 0x0b0d, 0x0b0e, 0x0b11, 0x0b12, 0x0b29, 0x0b29, 0x0b31, 0x0b31, 0x0b34, 0x0b35, 0x0b3a, 0x0b3b, 0x0b44, 0x0b46, 0x0b49, 0x0b4a, 0x0b4e, 0x0b55, 0x0b58, 0x0b5b, 0x0b5e, 0x0b5e, 0x0b62, 0x0b65, 0x0b71, 0x0b81, 0x0b84, 0x0b84, 0x0b8b, 0x0b8d, 0x0b91, 0x0b91, 0x0b96, 0x0b98, 0x0b9b, 0x0b9b, 0x0b9d, 0x0b9d, 0x0ba0, 0x0ba2, 0x0ba5, 0x0ba7, 0x0bab, 0x0bad, 0x0bb6, 0x0bb6, 0x0bba, 0x0bbd, 0x0bc3, 0x0bc5, 0x0bc9, 0x0bc9, 0x0bce, 0x0bd6, 0x0bd8, 0x0be6, 0x0bf3, 0x0c00, 0x0c04, 0x0c04, 0x0c0d, 0x0c0d, 0x0c11, 0x0c11, 0x0c29, 0x0c29, 0x0c34, 0x0c34, 0x0c3a, 0x0c3d, 0x0c45, 0x0c45, 0x0c49, 0x0c49, 0x0c4e, 0x0c54, 0x0c57, 0x0c5f, 0x0c62, 0x0c65, 0x0c70, 0x0c81, 0x0c84, 0x0c84, 0x0c8d, 0x0c8d, 0x0c91, 0x0c91, 0x0ca9, 0x0ca9, 0x0cb4, 0x0cb4, 0x0cba, 0x0cbd, 0x0cc5, 0x0cc5, 0x0cc9, 0x0cc9, 0x0cce, 0x0cd4, 0x0cd7, 0x0cdd, 0x0cdf, 0x0cdf, 0x0ce2, 0x0ce5, 0x0cf0, 0x0d01, 0x0d04, 0x0d04, 0x0d0d, 0x0d0d, 0x0d11, 0x0d11, 0x0d29, 0x0d29, 0x0d3a, 0x0d3d, 0x0d44, 0x0d45, 0x0d49, 0x0d49, 0x0d4e, 0x0d56, 0x0d58, 0x0d5f, 0x0d62, 0x0d65, 0x0d70, 0x0d81, 0x0d84, 0x0d84, 0x0d97, 0x0d99, 0x0db2, 0x0db2, 0x0dbc, 0x0dbc, 0x0dbe, 0x0dbf, 0x0dc7, 0x0dc9, 0x0dcb, 0x0dce, 0x0dd5, 0x0dd5, 0x0dd7, 0x0dd7, 0x0de0, 0x0df1, 0x0df5, 0x0e00, 0x0e3b, 0x0e3e, 0x0e5c, 0x0e80, 0x0e83, 0x0e83, 0x0e85, 0x0e86, 0x0e89, 0x0e89, 0x0e8b, 0x0e8c, 0x0e8e, 0x0e93, 0x0e98, 0x0e98, 0x0ea0, 0x0ea0, 0x0ea4, 0x0ea4, 0x0ea6, 0x0ea6, 0x0ea8, 0x0ea9, 0x0eac, 0x0eac, 0x0eba, 0x0eba, 0x0ebe, 0x0ebf, 0x0ec5, 0x0ec5, 0x0ec7, 0x0ec7, 0x0ece, 0x0ecf, 0x0eda, 0x0edb, 0x0ede, 0x0eff, 0x0f48, 0x0f48, 0x0f6b, 0x0f70, 0x0f8c, 0x0f8f, 0x0f98, 0x0f98, 0x0fbd, 0x0fbd, 0x0fcd, 0x0fce, 0x0fd0, 0x0fff, 0x1022, 0x1022, 0x1028, 0x1028, 0x102b, 0x102b, 0x1033, 0x1035, 0x103a, 0x103f, 0x105a, 0x109f, 0x10c6, 0x10cf, 0x10f9, 0x10fa, 0x10fc, 0x10ff, 0x115a, 0x115e, 0x11a3, 0x11a7, 0x11fa, 0x11ff, 0x1207, 0x1207, 0x1247, 0x1247, 0x1249, 0x1249, 0x124e, 0x124f, 0x1257, 0x1257, 0x1259, 0x1259, 0x125e, 0x125f, 0x1287, 0x1287, 0x1289, 0x1289, 0x128e, 0x128f, 0x12af, 0x12af, 0x12b1, 0x12b1, 0x12b6, 0x12b7, 0x12bf, 0x12bf, 0x12c1, 0x12c1, 0x12c6, 0x12c7, 0x12cf, 0x12cf, 0x12d7, 0x12d7, 0x12ef, 0x12ef, 0x130f, 0x130f, 0x1311, 0x1311, 0x1316, 0x1317, 0x131f, 0x131f, 0x1347, 0x1347, 0x135b, 0x1360, 0x137d, 0x139f, 0x13f5, 0x1400, 0x1677, 0x167f, 0x169d, 0x169f, 0x16f1, 0x16ff, 0x170d, 0x170d, 0x1715, 0x171f, 0x1737, 0x173f, 0x1754, 0x175f, 0x176d, 0x176d, 0x1771, 0x1771, 0x1774, 0x177f, 0x17dd, 0x17df, 0x17ea, 0x17ff, 0x180f, 0x180f, 0x181a, 0x181f, 0x1878, 0x187f, 0x18aa, 0x1dff, 0x1e9c, 0x1e9f, 0x1efa, 0x1eff, 0x1f16, 0x1f17, 0x1f1e, 0x1f1f, 0x1f46, 0x1f47, 0x1f4e, 0x1f4f, 0x1f58, 0x1f58, 0x1f5a, 0x1f5a, 0x1f5c, 0x1f5c, 0x1f5e, 0x1f5e, 0x1f7e, 0x1f7f, 0x1fb5, 0x1fb5, 0x1fc5, 0x1fc5, 0x1fd4, 0x1fd5, 0x1fdc, 0x1fdc, 0x1ff0, 0x1ff1, 0x1ff5, 0x1ff5, 0x1fff, 0x1fff, 0x2053, 0x2056, 0x2058, 0x205e, 0x2064, 0x2069, 0x2072, 0x2073, 0x208f, 0x209f, 0x20b2, 0x20cf, 0x20eb, 0x20ff, 0x213b, 0x213c, 0x214c, 0x2152, 0x2184, 0x218f, 0x23cf, 0x23ff, 0x2427, 0x243f, 0x244b, 0x245f, 0x24ff, 0x24ff, 0x2614, 0x2615, 0x2618, 0x2618, 0x267e, 0x267f, 0x268a, 0x2700, 0x2705, 0x2705, 0x270a, 0x270b, 0x2728, 0x2728, 0x274c, 0x274c, 0x274e, 0x274e, 0x2753, 0x2755, 0x2757, 0x2757, 0x275f, 0x2760, 0x2795, 0x2797, 0x27b0, 0x27b0, 0x27bf, 0x27cf, 0x27ec, 0x27ef, 0x2b00, 0x2e7f, 0x2e9a, 0x2e9a, 0x2ef4, 0x2eff, 0x2fd6, 0x2fef, 0x2ffc, 0x2fff, 0x3040, 0x3040, 0x3097, 0x3098, 0x3100, 0x3104, 0x312d, 0x3130, 0x318f, 0x318f, 0x31b8, 0x31ef, 0x321d, 0x321f, 0x3244, 0x3250, 0x327c, 0x327e, 0x32cc, 0x32cf, 0x32ff, 0x32ff, 0x3377, 0x337a, 0x33de, 0x33df, 0x33ff, 0x33ff, 0x4db6, 0x4dff, 0x9fa6, 0x9fff, 0xa48d, 0xa48f, 0xa4c7, 0xabff, 0xd7a4, 0xd7ff, 0xfa2e, 0xfa2f, 0xfa6b, 0xfaff, 0xfb07, 0xfb12, 0xfb18, 0xfb1c, 0xfb37, 0xfb37, 0xfb3d, 0xfb3d, 0xfb3f, 0xfb3f, 0xfb42, 0xfb42, 0xfb45, 0xfb45, 0xfbb2, 0xfbd2, 0xfd40, 0xfd4f, 0xfd90, 0xfd91, 0xfdc8, 0xfdcf, 0xfdfd, 0xfdff, 0xfe10, 0xfe1f, 0xfe24, 0xfe2f, 0xfe47, 0xfe48, 0xfe53, 0xfe53, 0xfe67, 0xfe67, 0xfe6c, 0xfe6f, 0xfe75, 0xfe75, 0xfefd, 0xfefe, 0xff00, 0xff00, 0xffbf, 0xffc1, 0xffc8, 0xffc9, 0xffd0, 0xffd1, 0xffd8, 0xffd9, 0xffdd, 0xffdf, 0xffe7, 0xffe7, 0xffef, 0xfff8, 0x10000, 0x102ff, 0x1031f, 0x1031f, 0x10324, 0x1032f, 0x1034b, 0x103ff, 0x10426, 0x10427, 0x1044e, 0x1cfff, 0x1d0f6, 0x1d0ff, 0x1d127, 0x1d129, 0x1d1de, 0x1d3ff, 0x1d455, 0x1d455, 0x1d49d, 0x1d49d, 0x1d4a0, 0x1d4a1, 0x1d4a3, 0x1d4a4, 0x1d4a7, 0x1d4a8, 0x1d4ad, 0x1d4ad, 0x1d4ba, 0x1d4ba, 0x1d4bc, 0x1d4bc, 0x1d4c1, 0x1d4c1, 0x1d4c4, 0x1d4c4, 0x1d506, 0x1d506, 0x1d50b, 0x1d50c, 0x1d515, 0x1d515, 0x1d51d, 0x1d51d, 0x1d53a, 0x1d53a, 0x1d53f, 0x1d53f, 0x1d545, 0x1d545, 0x1d547, 0x1d549, 0x1d551, 0x1d551, 0x1d6a4, 0x1d6a7, 0x1d7ca, 0x1d7cd, 0x1d800, 0x1fffd, 0x2a6d7, 0x2f7ff, 0x2fa1e, 0x2fffd, 0x30000, 0x3fffd, 0x40000, 0x4fffd, 0x50000, 0x5fffd, 0x60000, 0x6fffd, 0x70000, 0x7fffd, 0x80000, 0x8fffd, 0x90000, 0x9fffd, 0xa0000, 0xafffd, 0xb0000, 0xbfffd, 0xc0000, 0xcfffd, 0xd0000, 0xdfffd, 0xe0000, 0xe0000, 0xe0002, 0xe001f, 0xe0080, 0xefffd]; +// prettier-ignore-end + +const isUnassignedCodePoint = character => inRange(character, unassigned_code_points); + +// prettier-ignore-start +/** + * B.1 Commonly mapped to nothing + * @link https://tools.ietf.org/html/rfc3454#appendix-B.1 + */ +const commonly_mapped_to_nothing = [0x00ad, 0x00ad, 0x034f, 0x034f, 0x1806, 0x1806, 0x180b, 0x180b, 0x180c, 0x180c, 0x180d, 0x180d, 0x200b, 0x200b, 0x200c, 0x200c, 0x200d, 0x200d, 0x2060, 0x2060, 0xfe00, 0xfe00, 0xfe01, 0xfe01, 0xfe02, 0xfe02, 0xfe03, 0xfe03, 0xfe04, 0xfe04, 0xfe05, 0xfe05, 0xfe06, 0xfe06, 0xfe07, 0xfe07, 0xfe08, 0xfe08, 0xfe09, 0xfe09, 0xfe0a, 0xfe0a, 0xfe0b, 0xfe0b, 0xfe0c, 0xfe0c, 0xfe0d, 0xfe0d, 0xfe0e, 0xfe0e, 0xfe0f, 0xfe0f, 0xfeff, 0xfeff]; +// prettier-ignore-end + +const isCommonlyMappedToNothing = character => inRange(character, commonly_mapped_to_nothing); + +// prettier-ignore-start +/** + * C.1.2 Non-ASCII space characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.1.2 + */ +const non_ASCII_space_characters = [0x00a0, 0x00a0 /* NO-BREAK SPACE */, 0x1680, 0x1680 /* OGHAM SPACE MARK */, 0x2000, 0x2000 /* EN QUAD */, 0x2001, 0x2001 /* EM QUAD */, 0x2002, 0x2002 /* EN SPACE */, 0x2003, 0x2003 /* EM SPACE */, 0x2004, 0x2004 /* THREE-PER-EM SPACE */, 0x2005, 0x2005 /* FOUR-PER-EM SPACE */, 0x2006, 0x2006 /* SIX-PER-EM SPACE */, 0x2007, 0x2007 /* FIGURE SPACE */, 0x2008, 0x2008 /* PUNCTUATION SPACE */, 0x2009, 0x2009 /* THIN SPACE */, 0x200a, 0x200a /* HAIR SPACE */, 0x200b, 0x200b /* ZERO WIDTH SPACE */, 0x202f, 0x202f /* NARROW NO-BREAK SPACE */, 0x205f, 0x205f /* MEDIUM MATHEMATICAL SPACE */, 0x3000, 0x3000 /* IDEOGRAPHIC SPACE */]; +// prettier-ignore-end + +const isNonASCIISpaceCharacter = character => inRange(character, non_ASCII_space_characters); + +// prettier-ignore-start +const non_ASCII_controls_characters = [ +/** + * C.2.2 Non-ASCII control characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.2 + */ +0x0080, 0x009f /* [CONTROL CHARACTERS] */, 0x06dd, 0x06dd /* ARABIC END OF AYAH */, 0x070f, 0x070f /* SYRIAC ABBREVIATION MARK */, 0x180e, 0x180e /* MONGOLIAN VOWEL SEPARATOR */, 0x200c, 0x200c /* ZERO WIDTH NON-JOINER */, 0x200d, 0x200d /* ZERO WIDTH JOINER */, 0x2028, 0x2028 /* LINE SEPARATOR */, 0x2029, 0x2029 /* PARAGRAPH SEPARATOR */, 0x2060, 0x2060 /* WORD JOINER */, 0x2061, 0x2061 /* FUNCTION APPLICATION */, 0x2062, 0x2062 /* INVISIBLE TIMES */, 0x2063, 0x2063 /* INVISIBLE SEPARATOR */, 0x206a, 0x206f /* [CONTROL CHARACTERS] */, 0xfeff, 0xfeff /* ZERO WIDTH NO-BREAK SPACE */, 0xfff9, 0xfffc /* [CONTROL CHARACTERS] */, 0x1d173, 0x1d17a /* [MUSICAL CONTROL CHARACTERS] */]; +const non_character_codepoints = [ +/** + * C.4 Non-character code points + * @link https://tools.ietf.org/html/rfc3454#appendix-C.4 + */ +0xfdd0, 0xfdef /* [NONCHARACTER CODE POINTS] */, 0xfffe, 0xffff /* [NONCHARACTER CODE POINTS] */, 0x1fffe, 0x1ffff /* [NONCHARACTER CODE POINTS] */, 0x2fffe, 0x2ffff /* [NONCHARACTER CODE POINTS] */, 0x3fffe, 0x3ffff /* [NONCHARACTER CODE POINTS] */, 0x4fffe, 0x4ffff /* [NONCHARACTER CODE POINTS] */, 0x5fffe, 0x5ffff /* [NONCHARACTER CODE POINTS] */, 0x6fffe, 0x6ffff /* [NONCHARACTER CODE POINTS] */, 0x7fffe, 0x7ffff /* [NONCHARACTER CODE POINTS] */, 0x8fffe, 0x8ffff /* [NONCHARACTER CODE POINTS] */, 0x9fffe, 0x9ffff /* [NONCHARACTER CODE POINTS] */, 0xafffe, 0xaffff /* [NONCHARACTER CODE POINTS] */, 0xbfffe, 0xbffff /* [NONCHARACTER CODE POINTS] */, 0xcfffe, 0xcffff /* [NONCHARACTER CODE POINTS] */, 0xdfffe, 0xdffff /* [NONCHARACTER CODE POINTS] */, 0xefffe, 0xeffff /* [NONCHARACTER CODE POINTS] */, 0x10fffe, 0x10ffff /* [NONCHARACTER CODE POINTS] */]; + +/** + * 2.3. Prohibited Output + */ +const prohibited_characters = [ +/** + * C.2.1 ASCII control characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.1 + */ +0, 0x001f /* [CONTROL CHARACTERS] */, 0x007f, 0x007f /* DELETE */, +/** + * C.8 Change display properties or are deprecated + * @link https://tools.ietf.org/html/rfc3454#appendix-C.8 + */ +0x0340, 0x0340 /* COMBINING GRAVE TONE MARK */, 0x0341, 0x0341 /* COMBINING ACUTE TONE MARK */, 0x200e, 0x200e /* LEFT-TO-RIGHT MARK */, 0x200f, 0x200f /* RIGHT-TO-LEFT MARK */, 0x202a, 0x202a /* LEFT-TO-RIGHT EMBEDDING */, 0x202b, 0x202b /* RIGHT-TO-LEFT EMBEDDING */, 0x202c, 0x202c /* POP DIRECTIONAL FORMATTING */, 0x202d, 0x202d /* LEFT-TO-RIGHT OVERRIDE */, 0x202e, 0x202e /* RIGHT-TO-LEFT OVERRIDE */, 0x206a, 0x206a /* INHIBIT SYMMETRIC SWAPPING */, 0x206b, 0x206b /* ACTIVATE SYMMETRIC SWAPPING */, 0x206c, 0x206c /* INHIBIT ARABIC FORM SHAPING */, 0x206d, 0x206d /* ACTIVATE ARABIC FORM SHAPING */, 0x206e, 0x206e /* NATIONAL DIGIT SHAPES */, 0x206f, 0x206f /* NOMINAL DIGIT SHAPES */, +/** + * C.7 Inappropriate for canonical representation + * @link https://tools.ietf.org/html/rfc3454#appendix-C.7 + */ +0x2ff0, 0x2ffb /* [IDEOGRAPHIC DESCRIPTION CHARACTERS] */, +/** + * C.5 Surrogate codes + * @link https://tools.ietf.org/html/rfc3454#appendix-C.5 + */ +0xd800, 0xdfff, +/** + * C.3 Private use + * @link https://tools.ietf.org/html/rfc3454#appendix-C.3 + */ +0xe000, 0xf8ff /* [PRIVATE USE, PLANE 0] */, +/** + * C.6 Inappropriate for plain text + * @link https://tools.ietf.org/html/rfc3454#appendix-C.6 + */ +0xfff9, 0xfff9 /* INTERLINEAR ANNOTATION ANCHOR */, 0xfffa, 0xfffa /* INTERLINEAR ANNOTATION SEPARATOR */, 0xfffb, 0xfffb /* INTERLINEAR ANNOTATION TERMINATOR */, 0xfffc, 0xfffc /* OBJECT REPLACEMENT CHARACTER */, 0xfffd, 0xfffd /* REPLACEMENT CHARACTER */, +/** + * C.9 Tagging characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.9 + */ +0xe0001, 0xe0001 /* LANGUAGE TAG */, 0xe0020, 0xe007f /* [TAGGING CHARACTERS] */, +/** + * C.3 Private use + * @link https://tools.ietf.org/html/rfc3454#appendix-C.3 + */ + +0xf0000, 0xffffd /* [PRIVATE USE, PLANE 15] */, 0x100000, 0x10fffd /* [PRIVATE USE, PLANE 16] */]; +// prettier-ignore-end + +const isProhibitedCharacter = character => inRange(character, non_ASCII_space_characters) || inRange(character, prohibited_characters) || inRange(character, non_ASCII_controls_characters) || inRange(character, non_character_codepoints); + +// prettier-ignore-start +/** + * D.1 Characters with bidirectional property "R" or "AL" + * @link https://tools.ietf.org/html/rfc3454#appendix-D.1 + */ +const bidirectional_r_al = [0x05be, 0x05be, 0x05c0, 0x05c0, 0x05c3, 0x05c3, 0x05d0, 0x05ea, 0x05f0, 0x05f4, 0x061b, 0x061b, 0x061f, 0x061f, 0x0621, 0x063a, 0x0640, 0x064a, 0x066d, 0x066f, 0x0671, 0x06d5, 0x06dd, 0x06dd, 0x06e5, 0x06e6, 0x06fa, 0x06fe, 0x0700, 0x070d, 0x0710, 0x0710, 0x0712, 0x072c, 0x0780, 0x07a5, 0x07b1, 0x07b1, 0x200f, 0x200f, 0xfb1d, 0xfb1d, 0xfb1f, 0xfb28, 0xfb2a, 0xfb36, 0xfb38, 0xfb3c, 0xfb3e, 0xfb3e, 0xfb40, 0xfb41, 0xfb43, 0xfb44, 0xfb46, 0xfbb1, 0xfbd3, 0xfd3d, 0xfd50, 0xfd8f, 0xfd92, 0xfdc7, 0xfdf0, 0xfdfc, 0xfe70, 0xfe74, 0xfe76, 0xfefc]; +// prettier-ignore-end + +const isBidirectionalRAL = character => inRange(character, bidirectional_r_al); + +// prettier-ignore-start +/** + * D.2 Characters with bidirectional property "L" + * @link https://tools.ietf.org/html/rfc3454#appendix-D.2 + */ +const bidirectional_l = [0x0041, 0x005a, 0x0061, 0x007a, 0x00aa, 0x00aa, 0x00b5, 0x00b5, 0x00ba, 0x00ba, 0x00c0, 0x00d6, 0x00d8, 0x00f6, 0x00f8, 0x0220, 0x0222, 0x0233, 0x0250, 0x02ad, 0x02b0, 0x02b8, 0x02bb, 0x02c1, 0x02d0, 0x02d1, 0x02e0, 0x02e4, 0x02ee, 0x02ee, 0x037a, 0x037a, 0x0386, 0x0386, 0x0388, 0x038a, 0x038c, 0x038c, 0x038e, 0x03a1, 0x03a3, 0x03ce, 0x03d0, 0x03f5, 0x0400, 0x0482, 0x048a, 0x04ce, 0x04d0, 0x04f5, 0x04f8, 0x04f9, 0x0500, 0x050f, 0x0531, 0x0556, 0x0559, 0x055f, 0x0561, 0x0587, 0x0589, 0x0589, 0x0903, 0x0903, 0x0905, 0x0939, 0x093d, 0x0940, 0x0949, 0x094c, 0x0950, 0x0950, 0x0958, 0x0961, 0x0964, 0x0970, 0x0982, 0x0983, 0x0985, 0x098c, 0x098f, 0x0990, 0x0993, 0x09a8, 0x09aa, 0x09b0, 0x09b2, 0x09b2, 0x09b6, 0x09b9, 0x09be, 0x09c0, 0x09c7, 0x09c8, 0x09cb, 0x09cc, 0x09d7, 0x09d7, 0x09dc, 0x09dd, 0x09df, 0x09e1, 0x09e6, 0x09f1, 0x09f4, 0x09fa, 0x0a05, 0x0a0a, 0x0a0f, 0x0a10, 0x0a13, 0x0a28, 0x0a2a, 0x0a30, 0x0a32, 0x0a33, 0x0a35, 0x0a36, 0x0a38, 0x0a39, 0x0a3e, 0x0a40, 0x0a59, 0x0a5c, 0x0a5e, 0x0a5e, 0x0a66, 0x0a6f, 0x0a72, 0x0a74, 0x0a83, 0x0a83, 0x0a85, 0x0a8b, 0x0a8d, 0x0a8d, 0x0a8f, 0x0a91, 0x0a93, 0x0aa8, 0x0aaa, 0x0ab0, 0x0ab2, 0x0ab3, 0x0ab5, 0x0ab9, 0x0abd, 0x0ac0, 0x0ac9, 0x0ac9, 0x0acb, 0x0acc, 0x0ad0, 0x0ad0, 0x0ae0, 0x0ae0, 0x0ae6, 0x0aef, 0x0b02, 0x0b03, 0x0b05, 0x0b0c, 0x0b0f, 0x0b10, 0x0b13, 0x0b28, 0x0b2a, 0x0b30, 0x0b32, 0x0b33, 0x0b36, 0x0b39, 0x0b3d, 0x0b3e, 0x0b40, 0x0b40, 0x0b47, 0x0b48, 0x0b4b, 0x0b4c, 0x0b57, 0x0b57, 0x0b5c, 0x0b5d, 0x0b5f, 0x0b61, 0x0b66, 0x0b70, 0x0b83, 0x0b83, 0x0b85, 0x0b8a, 0x0b8e, 0x0b90, 0x0b92, 0x0b95, 0x0b99, 0x0b9a, 0x0b9c, 0x0b9c, 0x0b9e, 0x0b9f, 0x0ba3, 0x0ba4, 0x0ba8, 0x0baa, 0x0bae, 0x0bb5, 0x0bb7, 0x0bb9, 0x0bbe, 0x0bbf, 0x0bc1, 0x0bc2, 0x0bc6, 0x0bc8, 0x0bca, 0x0bcc, 0x0bd7, 0x0bd7, 0x0be7, 0x0bf2, 0x0c01, 0x0c03, 0x0c05, 0x0c0c, 0x0c0e, 0x0c10, 0x0c12, 0x0c28, 0x0c2a, 0x0c33, 0x0c35, 0x0c39, 0x0c41, 0x0c44, 0x0c60, 0x0c61, 0x0c66, 0x0c6f, 0x0c82, 0x0c83, 0x0c85, 0x0c8c, 0x0c8e, 0x0c90, 0x0c92, 0x0ca8, 0x0caa, 0x0cb3, 0x0cb5, 0x0cb9, 0x0cbe, 0x0cbe, 0x0cc0, 0x0cc4, 0x0cc7, 0x0cc8, 0x0cca, 0x0ccb, 0x0cd5, 0x0cd6, 0x0cde, 0x0cde, 0x0ce0, 0x0ce1, 0x0ce6, 0x0cef, 0x0d02, 0x0d03, 0x0d05, 0x0d0c, 0x0d0e, 0x0d10, 0x0d12, 0x0d28, 0x0d2a, 0x0d39, 0x0d3e, 0x0d40, 0x0d46, 0x0d48, 0x0d4a, 0x0d4c, 0x0d57, 0x0d57, 0x0d60, 0x0d61, 0x0d66, 0x0d6f, 0x0d82, 0x0d83, 0x0d85, 0x0d96, 0x0d9a, 0x0db1, 0x0db3, 0x0dbb, 0x0dbd, 0x0dbd, 0x0dc0, 0x0dc6, 0x0dcf, 0x0dd1, 0x0dd8, 0x0ddf, 0x0df2, 0x0df4, 0x0e01, 0x0e30, 0x0e32, 0x0e33, 0x0e40, 0x0e46, 0x0e4f, 0x0e5b, 0x0e81, 0x0e82, 0x0e84, 0x0e84, 0x0e87, 0x0e88, 0x0e8a, 0x0e8a, 0x0e8d, 0x0e8d, 0x0e94, 0x0e97, 0x0e99, 0x0e9f, 0x0ea1, 0x0ea3, 0x0ea5, 0x0ea5, 0x0ea7, 0x0ea7, 0x0eaa, 0x0eab, 0x0ead, 0x0eb0, 0x0eb2, 0x0eb3, 0x0ebd, 0x0ebd, 0x0ec0, 0x0ec4, 0x0ec6, 0x0ec6, 0x0ed0, 0x0ed9, 0x0edc, 0x0edd, 0x0f00, 0x0f17, 0x0f1a, 0x0f34, 0x0f36, 0x0f36, 0x0f38, 0x0f38, 0x0f3e, 0x0f47, 0x0f49, 0x0f6a, 0x0f7f, 0x0f7f, 0x0f85, 0x0f85, 0x0f88, 0x0f8b, 0x0fbe, 0x0fc5, 0x0fc7, 0x0fcc, 0x0fcf, 0x0fcf, 0x1000, 0x1021, 0x1023, 0x1027, 0x1029, 0x102a, 0x102c, 0x102c, 0x1031, 0x1031, 0x1038, 0x1038, 0x1040, 0x1057, 0x10a0, 0x10c5, 0x10d0, 0x10f8, 0x10fb, 0x10fb, 0x1100, 0x1159, 0x115f, 0x11a2, 0x11a8, 0x11f9, 0x1200, 0x1206, 0x1208, 0x1246, 0x1248, 0x1248, 0x124a, 0x124d, 0x1250, 0x1256, 0x1258, 0x1258, 0x125a, 0x125d, 0x1260, 0x1286, 0x1288, 0x1288, 0x128a, 0x128d, 0x1290, 0x12ae, 0x12b0, 0x12b0, 0x12b2, 0x12b5, 0x12b8, 0x12be, 0x12c0, 0x12c0, 0x12c2, 0x12c5, 0x12c8, 0x12ce, 0x12d0, 0x12d6, 0x12d8, 0x12ee, 0x12f0, 0x130e, 0x1310, 0x1310, 0x1312, 0x1315, 0x1318, 0x131e, 0x1320, 0x1346, 0x1348, 0x135a, 0x1361, 0x137c, 0x13a0, 0x13f4, 0x1401, 0x1676, 0x1681, 0x169a, 0x16a0, 0x16f0, 0x1700, 0x170c, 0x170e, 0x1711, 0x1720, 0x1731, 0x1735, 0x1736, 0x1740, 0x1751, 0x1760, 0x176c, 0x176e, 0x1770, 0x1780, 0x17b6, 0x17be, 0x17c5, 0x17c7, 0x17c8, 0x17d4, 0x17da, 0x17dc, 0x17dc, 0x17e0, 0x17e9, 0x1810, 0x1819, 0x1820, 0x1877, 0x1880, 0x18a8, 0x1e00, 0x1e9b, 0x1ea0, 0x1ef9, 0x1f00, 0x1f15, 0x1f18, 0x1f1d, 0x1f20, 0x1f45, 0x1f48, 0x1f4d, 0x1f50, 0x1f57, 0x1f59, 0x1f59, 0x1f5b, 0x1f5b, 0x1f5d, 0x1f5d, 0x1f5f, 0x1f7d, 0x1f80, 0x1fb4, 0x1fb6, 0x1fbc, 0x1fbe, 0x1fbe, 0x1fc2, 0x1fc4, 0x1fc6, 0x1fcc, 0x1fd0, 0x1fd3, 0x1fd6, 0x1fdb, 0x1fe0, 0x1fec, 0x1ff2, 0x1ff4, 0x1ff6, 0x1ffc, 0x200e, 0x200e, 0x2071, 0x2071, 0x207f, 0x207f, 0x2102, 0x2102, 0x2107, 0x2107, 0x210a, 0x2113, 0x2115, 0x2115, 0x2119, 0x211d, 0x2124, 0x2124, 0x2126, 0x2126, 0x2128, 0x2128, 0x212a, 0x212d, 0x212f, 0x2131, 0x2133, 0x2139, 0x213d, 0x213f, 0x2145, 0x2149, 0x2160, 0x2183, 0x2336, 0x237a, 0x2395, 0x2395, 0x249c, 0x24e9, 0x3005, 0x3007, 0x3021, 0x3029, 0x3031, 0x3035, 0x3038, 0x303c, 0x3041, 0x3096, 0x309d, 0x309f, 0x30a1, 0x30fa, 0x30fc, 0x30ff, 0x3105, 0x312c, 0x3131, 0x318e, 0x3190, 0x31b7, 0x31f0, 0x321c, 0x3220, 0x3243, 0x3260, 0x327b, 0x327f, 0x32b0, 0x32c0, 0x32cb, 0x32d0, 0x32fe, 0x3300, 0x3376, 0x337b, 0x33dd, 0x33e0, 0x33fe, 0x3400, 0x4db5, 0x4e00, 0x9fa5, 0xa000, 0xa48c, 0xac00, 0xd7a3, 0xd800, 0xfa2d, 0xfa30, 0xfa6a, 0xfb00, 0xfb06, 0xfb13, 0xfb17, 0xff21, 0xff3a, 0xff41, 0xff5a, 0xff66, 0xffbe, 0xffc2, 0xffc7, 0xffca, 0xffcf, 0xffd2, 0xffd7, 0xffda, 0xffdc, 0x10300, 0x1031e, 0x10320, 0x10323, 0x10330, 0x1034a, 0x10400, 0x10425, 0x10428, 0x1044d, 0x1d000, 0x1d0f5, 0x1d100, 0x1d126, 0x1d12a, 0x1d166, 0x1d16a, 0x1d172, 0x1d183, 0x1d184, 0x1d18c, 0x1d1a9, 0x1d1ae, 0x1d1dd, 0x1d400, 0x1d454, 0x1d456, 0x1d49c, 0x1d49e, 0x1d49f, 0x1d4a2, 0x1d4a2, 0x1d4a5, 0x1d4a6, 0x1d4a9, 0x1d4ac, 0x1d4ae, 0x1d4b9, 0x1d4bb, 0x1d4bb, 0x1d4bd, 0x1d4c0, 0x1d4c2, 0x1d4c3, 0x1d4c5, 0x1d505, 0x1d507, 0x1d50a, 0x1d50d, 0x1d514, 0x1d516, 0x1d51c, 0x1d51e, 0x1d539, 0x1d53b, 0x1d53e, 0x1d540, 0x1d544, 0x1d546, 0x1d546, 0x1d54a, 0x1d550, 0x1d552, 0x1d6a3, 0x1d6a8, 0x1d7c9, 0x20000, 0x2a6d6, 0x2f800, 0x2fa1d, 0xf0000, 0xffffd, 0x100000, 0x10fffd]; +// prettier-ignore-end + +const isBidirectionalL = character => inRange(character, bidirectional_l); + +// 2.1. Mapping + +/** + * non-ASCII space characters [StringPrep, C.1.2] that can be + * mapped to SPACE (U+0020) + */ +const mapping2space = isNonASCIISpaceCharacter; + +/** + * the "commonly mapped to nothing" characters [StringPrep, B.1] + * that can be mapped to nothing. + */ +const mapping2nothing = isCommonlyMappedToNothing; + +// utils +const getCodePoint = character => character.codePointAt(0); +const first = x => x[0]; +const last = x => x[x.length - 1]; + +/** + * Convert provided string into an array of Unicode Code Points. + * Based on https://stackoverflow.com/a/21409165/1556249 + * and https://www.npmjs.com/package/code-point-at. + * @param {string} input + * @returns {number[]} + */ +function toCodePoints(input) { + const codepoints = []; + const size = input.length; + for (let i = 0; i < size; i += 1) { + const before = input.charCodeAt(i); + if (before >= 0xd800 && before <= 0xdbff && size > i + 1) { + const next = input.charCodeAt(i + 1); + if (next >= 0xdc00 && next <= 0xdfff) { + codepoints.push((before - 0xd800) * 0x400 + next - 0xdc00 + 0x10000); + i += 1; + continue; + } + } + codepoints.push(before); + } + return codepoints; +} + +/** + * SASLprep. + * @param {string} input + * @param {Object} opts + * @param {boolean} opts.allowUnassigned + * @returns {string} + */ +function saslprep(input, opts) { + if (opts === void 0) { + opts = {}; + } + if (typeof input !== 'string') { + throw new TypeError('Expected string.'); + } + if (input.length === 0) { + return ''; + } + + // 1. Map + const mapped_input = toCodePoints(input) + // 1.1 mapping to space + .map(character => mapping2space(character) ? 0x20 : character) + // 1.2 mapping to nothing + .filter(character => !mapping2nothing(character)); + + // 2. Normalize + const normalized_input = String.fromCodePoint.apply(null, mapped_input).normalize('NFKC'); + const normalized_map = toCodePoints(normalized_input); + + // 3. Prohibit + const hasProhibited = normalized_map.some(isProhibitedCharacter); + if (hasProhibited) { + throw new Error('Prohibited character, see https://tools.ietf.org/html/rfc4013#section-2.3'); + } + + // Unassigned Code Points + if (opts.allowUnassigned !== true) { + const hasUnassigned = normalized_map.some(isUnassignedCodePoint); + if (hasUnassigned) { + throw new Error('Unassigned code point, see https://tools.ietf.org/html/rfc4013#section-2.5'); + } + } + + // 4. check bidi + + const hasBidiRAL = normalized_map.some(isBidirectionalRAL); + const hasBidiL = normalized_map.some(isBidirectionalL); + + // 4.1 If a string contains any RandALCat character, the string MUST NOT + // contain any LCat character. + if (hasBidiRAL && hasBidiL) { + throw new Error('String must not contain RandALCat and LCat at the same time,' + ' see https://tools.ietf.org/html/rfc3454#section-6'); + } + + /** + * 4.2 If a string contains any RandALCat character, a RandALCat + * character MUST be the first character of the string, and a + * RandALCat character MUST be the last character of the string. + */ + + const isFirstBidiRAL = isBidirectionalRAL(getCodePoint(first(normalized_input))); + const isLastBidiRAL = isBidirectionalRAL(getCodePoint(last(normalized_input))); + if (hasBidiRAL && !(isFirstBidiRAL && isLastBidiRAL)) { + throw new Error('Bidirectional RandALCat character must be the first and the last' + ' character of the string, see https://tools.ietf.org/html/rfc3454#section-6'); + } + return normalized_input; +} + +/* + PDFSecurity - represents PDF security settings + By Yang Liu + */ + +function concatBytes() { + for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) { + arrays[_key] = arguments[_key]; + } + const length = arrays.reduce((a, b) => a + b.length, 0); + const result = new Uint8Array(length); + let offset = 0; + for (const arr of arrays) { + result.set(arr, offset); + offset += arr.length; + } + return result; +} +class PDFSecurity { + static generateFileID(info) { + if (info === void 0) { + info = {}; + } + let infoStr = `${info.CreationDate.getTime()}\n`; + for (let key in info) { + // eslint-disable-next-line no-prototype-builtins + if (!info.hasOwnProperty(key)) { + continue; + } + infoStr += `${key}: ${info[key].valueOf()}\n`; + } + return Buffer.from(md5Hash(infoStr)); + } + static generateRandomWordArray(bytes) { + return randomBytes(bytes); + } + static create(document, options) { + if (options === void 0) { + options = {}; + } + if (!options.ownerPassword && !options.userPassword) { + return null; + } + return new PDFSecurity(document, options); + } + constructor(document, options) { + if (options === void 0) { + options = {}; + } + if (!options.ownerPassword && !options.userPassword) { + throw new Error('None of owner password and user password is defined.'); + } + this.document = document; + this._setupEncryption(options); + } + _setupEncryption(options) { + switch (options.pdfVersion) { + case '1.4': + case '1.5': + this.version = 2; + break; + case '1.6': + case '1.7': + this.version = 4; + break; + case '1.7ext3': + this.version = 5; + break; + default: + this.version = 1; + break; + } + const encDict = { + Filter: 'Standard' + }; + switch (this.version) { + case 1: + case 2: + case 4: + this._setupEncryptionV1V2V4(this.version, encDict, options); + break; + case 5: + this._setupEncryptionV5(encDict, options); + break; + } + this.dictionary = this.document.ref(encDict); + } + _setupEncryptionV1V2V4(v, encDict, options) { + let r, permissions; + switch (v) { + case 1: + r = 2; + this.keyBits = 40; + permissions = getPermissionsR2(options.permissions); + break; + case 2: + r = 3; + this.keyBits = 128; + permissions = getPermissionsR3(options.permissions); + break; + case 4: + r = 4; + this.keyBits = 128; + permissions = getPermissionsR3(options.permissions); + break; + } + const paddedUserPassword = processPasswordR2R3R4(options.userPassword); + const paddedOwnerPassword = options.ownerPassword ? processPasswordR2R3R4(options.ownerPassword) : paddedUserPassword; + const ownerPasswordEntry = getOwnerPasswordR2R3R4(r, this.keyBits, paddedUserPassword, paddedOwnerPassword); + this.encryptionKey = getEncryptionKeyR2R3R4(r, this.keyBits, this.document._id, paddedUserPassword, ownerPasswordEntry, permissions); + let userPasswordEntry; + if (r === 2) { + userPasswordEntry = getUserPasswordR2(this.encryptionKey); + } else { + userPasswordEntry = getUserPasswordR3R4(this.document._id, this.encryptionKey); + } + encDict.V = v; + if (v >= 2) { + encDict.Length = this.keyBits; + } + if (v === 4) { + encDict.CF = { + StdCF: { + AuthEvent: 'DocOpen', + CFM: 'AESV2', + Length: this.keyBits / 8 + } + }; + encDict.StmF = 'StdCF'; + encDict.StrF = 'StdCF'; + } + encDict.R = r; + encDict.O = Buffer.from(ownerPasswordEntry); + encDict.U = Buffer.from(userPasswordEntry); + encDict.P = permissions; + } + _setupEncryptionV5(encDict, options) { + this.keyBits = 256; + const permissions = getPermissionsR3(options.permissions); + const processedUserPassword = processPasswordR5(options.userPassword); + const processedOwnerPassword = options.ownerPassword ? processPasswordR5(options.ownerPassword) : processedUserPassword; + this.encryptionKey = getEncryptionKeyR5(PDFSecurity.generateRandomWordArray); + const userPasswordEntry = getUserPasswordR5(processedUserPassword, PDFSecurity.generateRandomWordArray); + const userKeySalt = userPasswordEntry.slice(40, 48); + const userEncryptionKeyEntry = getUserEncryptionKeyR5(processedUserPassword, userKeySalt, this.encryptionKey); + const ownerPasswordEntry = getOwnerPasswordR5(processedOwnerPassword, userPasswordEntry, PDFSecurity.generateRandomWordArray); + const ownerKeySalt = ownerPasswordEntry.slice(40, 48); + const ownerEncryptionKeyEntry = getOwnerEncryptionKeyR5(processedOwnerPassword, ownerKeySalt, userPasswordEntry, this.encryptionKey); + const permsEntry = getEncryptedPermissionsR5(permissions, this.encryptionKey, PDFSecurity.generateRandomWordArray); + encDict.V = 5; + encDict.Length = this.keyBits; + encDict.CF = { + StdCF: { + AuthEvent: 'DocOpen', + CFM: 'AESV3', + Length: this.keyBits / 8 + } + }; + encDict.StmF = 'StdCF'; + encDict.StrF = 'StdCF'; + encDict.R = 5; + encDict.O = Buffer.from(ownerPasswordEntry); + encDict.OE = Buffer.from(ownerEncryptionKeyEntry); + encDict.U = Buffer.from(userPasswordEntry); + encDict.UE = Buffer.from(userEncryptionKeyEntry); + encDict.P = permissions; + encDict.Perms = Buffer.from(permsEntry); + } + getEncryptFn(obj, gen) { + let digest; + if (this.version < 5) { + // Create 5-byte object/generation number suffix + const suffix = new Uint8Array([obj & 0xff, obj >> 8 & 0xff, obj >> 16 & 0xff, gen & 0xff, gen >> 8 & 0xff]); + digest = concatBytes(this.encryptionKey, suffix); + } + if (this.version === 1 || this.version === 2) { + let key = md5Hash(digest); + const keyLen = Math.min(16, this.keyBits / 8 + 5); + key = key.slice(0, keyLen); + return buffer => Buffer.from(rc4(new Uint8Array(buffer), key)); + } + let key; + if (this.version === 4) { + // Append "sAlT" marker for AES + const saltMarker = new Uint8Array([0x73, 0x41, 0x6c, 0x54]); + key = md5Hash(concatBytes(digest, saltMarker)); + } else { + key = this.encryptionKey; + } + const iv = PDFSecurity.generateRandomWordArray(16); + return buffer => { + const encrypted = aesCbcEncrypt(new Uint8Array(buffer), key, iv, true); + return Buffer.from(concatBytes(iv, encrypted)); + }; + } + end() { + this.dictionary.end(); + } +} +function getPermissionsR2(permissionObject) { + if (permissionObject === void 0) { + permissionObject = {}; + } + let permissions = 0xffffffc0 >> 0; + if (permissionObject.printing) { + permissions |= 0b000000000100; + } + if (permissionObject.modifying) { + permissions |= 0b000000001000; + } + if (permissionObject.copying) { + permissions |= 0b000000010000; + } + if (permissionObject.annotating) { + permissions |= 0b000000100000; + } + return permissions; +} +function getPermissionsR3(permissionObject) { + if (permissionObject === void 0) { + permissionObject = {}; + } + let permissions = 0xfffff0c0 >> 0; + if (permissionObject.printing === 'lowResolution') { + permissions |= 0b000000000100; + } + if (permissionObject.printing === 'highResolution') { + permissions |= 0b100000000100; + } + if (permissionObject.modifying) { + permissions |= 0b000000001000; + } + if (permissionObject.copying) { + permissions |= 0b000000010000; + } + if (permissionObject.annotating) { + permissions |= 0b000000100000; + } + if (permissionObject.fillingForms) { + permissions |= 0b000100000000; + } + if (permissionObject.contentAccessibility) { + permissions |= 0b001000000000; + } + if (permissionObject.documentAssembly) { + permissions |= 0b010000000000; + } + return permissions; +} +function getUserPasswordR2(encryptionKey) { + return rc4(processPasswordR2R3R4(), encryptionKey); +} +function getUserPasswordR3R4(documentId, encryptionKey) { + const key = encryptionKey.slice(); + let cipher = md5Hash(concatBytes(processPasswordR2R3R4(), new Uint8Array(documentId))); + for (let i = 0; i < 20; i++) { + const xorKey = new Uint8Array(key.length); + for (let j = 0; j < key.length; j++) { + xorKey[j] = encryptionKey[j] ^ i; + } + cipher = rc4(cipher, xorKey); + } + // Pad to 32 bytes + const result = new Uint8Array(32); + result.set(cipher); + return result; +} +function getOwnerPasswordR2R3R4(r, keyBits, paddedUserPassword, paddedOwnerPassword) { + let digest = paddedOwnerPassword; + let round = r >= 3 ? 51 : 1; + for (let i = 0; i < round; i++) { + digest = md5Hash(digest); + } + const keyLen = keyBits / 8; + let key = digest.slice(0, keyLen); + let cipher = paddedUserPassword; + round = r >= 3 ? 20 : 1; + for (let i = 0; i < round; i++) { + const xorKey = new Uint8Array(keyLen); + for (let j = 0; j < keyLen; j++) { + xorKey[j] = key[j] ^ i; + } + cipher = rc4(cipher, xorKey); + } + return cipher; +} +function getEncryptionKeyR2R3R4(r, keyBits, documentId, paddedUserPassword, ownerPasswordEntry, permissions) { + // Build input: password + owner entry + permissions (LSB first) + document ID + const permBytes = new Uint8Array([permissions & 0xff, permissions >> 8 & 0xff, permissions >> 16 & 0xff, permissions >> 24 & 0xff]); + let key = concatBytes(paddedUserPassword, ownerPasswordEntry, permBytes, new Uint8Array(documentId)); + const round = r >= 3 ? 51 : 1; + const keyLen = keyBits / 8; + for (let i = 0; i < round; i++) { + key = md5Hash(key); + key = key.slice(0, keyLen); + } + return key; +} +function getUserPasswordR5(processedUserPassword, generateRandomWordArray) { + const validationSalt = generateRandomWordArray(8); + const keySalt = generateRandomWordArray(8); + const hash = sha256Hash(concatBytes(processedUserPassword, validationSalt)); + return concatBytes(hash, validationSalt, keySalt); +} +function getUserEncryptionKeyR5(processedUserPassword, userKeySalt, encryptionKey) { + const key = sha256Hash(concatBytes(processedUserPassword, userKeySalt)); + const iv = new Uint8Array(16); // Zero IV + return aesCbcEncrypt(encryptionKey, key, iv, false); +} +function getOwnerPasswordR5(processedOwnerPassword, userPasswordEntry, generateRandomWordArray) { + const validationSalt = generateRandomWordArray(8); + const keySalt = generateRandomWordArray(8); + const hash = sha256Hash(concatBytes(processedOwnerPassword, validationSalt, userPasswordEntry)); + return concatBytes(hash, validationSalt, keySalt); +} +function getOwnerEncryptionKeyR5(processedOwnerPassword, ownerKeySalt, userPasswordEntry, encryptionKey) { + const key = sha256Hash(concatBytes(processedOwnerPassword, ownerKeySalt, userPasswordEntry)); + const iv = new Uint8Array(16); // Zero IV + return aesCbcEncrypt(encryptionKey, key, iv, false); +} +function getEncryptionKeyR5(generateRandomWordArray) { + return generateRandomWordArray(32); +} +function getEncryptedPermissionsR5(permissions, encryptionKey, generateRandomWordArray) { + // Build 16-byte block: permissions (4 bytes LSB) + 0xFFFFFFFF (4 bytes) + "adbT" (4 bytes) + random (4 bytes) + const data = new Uint8Array(16); + // Permissions (LSB first) + data[0] = permissions & 0xff; + data[1] = permissions >> 8 & 0xff; + data[2] = permissions >> 16 & 0xff; + data[3] = permissions >> 24 & 0xff; + // 0xFFFFFFFF + data[4] = 0xff; + data[5] = 0xff; + data[6] = 0xff; + data[7] = 0xff; + // "adbT" = 0x54616462 (but stored as individual bytes) + data[8] = 0x54; // 'T' + data[9] = 0x61; // 'a' + data[10] = 0x64; // 'd' + data[11] = 0x62; // 'b' + // Random 4 bytes + const randomPart = generateRandomWordArray(4); + data.set(randomPart, 12); + return aesEcbEncrypt(data, encryptionKey); +} +function processPasswordR2R3R4(password) { + if (password === void 0) { + password = ''; + } + const out = new Uint8Array(32); + const length = password.length; + let index = 0; + while (index < length && index < 32) { + const code = password.charCodeAt(index); + if (code > 0xff) { + throw new Error('Password contains one or more invalid characters.'); + } + out[index] = code; + index++; + } + while (index < 32) { + out[index] = PASSWORD_PADDING[index - length]; + index++; + } + return out; +} +function processPasswordR5(password) { + if (password === void 0) { + password = ''; + } + password = unescape(encodeURIComponent(saslprep(password))); + const length = Math.min(127, password.length); + const out = new Uint8Array(length); + for (let i = 0; i < length; i++) { + out[i] = password.charCodeAt(i); + } + return out; +} +const PASSWORD_PADDING = [0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a]; + +const { + number: number$2 +} = PDFObject; +let PDFGradient$1 = class PDFGradient { + constructor(doc) { + this.doc = doc; + this.stops = []; + this.embedded = false; + this.transform = [1, 0, 0, 1, 0, 0]; + } + stop(pos, color, opacity) { + if (opacity == null) { + opacity = 1; + } + color = this.doc._normalizeColor(color); + if (this.stops.length === 0) { + if (color.length === 3) { + this._colorSpace = 'DeviceRGB'; + } else if (color.length === 4) { + this._colorSpace = 'DeviceCMYK'; + } else if (color.length === 1) { + this._colorSpace = 'DeviceGray'; + } else { + throw new Error('Unknown color space'); + } + } else if (this._colorSpace === 'DeviceRGB' && color.length !== 3 || this._colorSpace === 'DeviceCMYK' && color.length !== 4 || this._colorSpace === 'DeviceGray' && color.length !== 1) { + throw new Error('All gradient stops must use the same color space'); + } + opacity = Math.max(0, Math.min(1, opacity)); + this.stops.push([pos, color, opacity]); + return this; + } + setTransform(m11, m12, m21, m22, dx, dy) { + this.transform = [m11, m12, m21, m22, dx, dy]; + return this; + } + embed(m) { + let fn; + const stopsLength = this.stops.length; + if (stopsLength === 0) { + return; + } + this.embedded = true; + this.matrix = m; + + // if the last stop comes before 100%, add a copy at 100% + const last = this.stops[stopsLength - 1]; + if (last[0] < 1) { + this.stops.push([1, last[1], last[2]]); + } + const bounds = []; + const encode = []; + const stops = []; + for (let i = 0; i < stopsLength - 1; i++) { + encode.push(0, 1); + if (i + 2 !== stopsLength) { + bounds.push(this.stops[i + 1][0]); + } + fn = this.doc.ref({ + FunctionType: 2, + Domain: [0, 1], + C0: this.stops[i + 0][1], + C1: this.stops[i + 1][1], + N: 1 + }); + stops.push(fn); + fn.end(); + } + + // if there are only two stops, we don't need a stitching function + if (stopsLength === 1) { + fn = stops[0]; + } else { + fn = this.doc.ref({ + FunctionType: 3, + // stitching function + Domain: [0, 1], + Functions: stops, + Bounds: bounds, + Encode: encode + }); + fn.end(); + } + this.id = `Sh${++this.doc._gradCount}`; + const shader = this.shader(fn); + shader.end(); + const pattern = this.doc.ref({ + Type: 'Pattern', + PatternType: 2, + Shading: shader, + Matrix: this.matrix.map(number$2) + }); + pattern.end(); + if (this.stops.some(stop => stop[2] < 1)) { + let grad = this.opacityGradient(); + grad._colorSpace = 'DeviceGray'; + for (let stop of this.stops) { + grad.stop(stop[0], [stop[2]]); + } + grad = grad.embed(this.matrix); + const pageBBox = [0, 0, this.doc.page.width, this.doc.page.height]; + const form = this.doc.ref({ + Type: 'XObject', + Subtype: 'Form', + FormType: 1, + BBox: pageBBox, + Group: { + Type: 'Group', + S: 'Transparency', + CS: 'DeviceGray' + }, + Resources: { + ProcSet: ['PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'], + Pattern: { + Sh1: grad + } + } + }); + form.write('/Pattern cs /Sh1 scn'); + form.end(`${pageBBox.join(' ')} re f`); + const gstate = this.doc.ref({ + Type: 'ExtGState', + SMask: { + Type: 'Mask', + S: 'Luminosity', + G: form + } + }); + gstate.end(); + const opacityPattern = this.doc.ref({ + Type: 'Pattern', + PatternType: 1, + PaintType: 1, + TilingType: 2, + BBox: pageBBox, + XStep: pageBBox[2], + YStep: pageBBox[3], + Resources: { + ProcSet: ['PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'], + Pattern: { + Sh1: pattern + }, + ExtGState: { + Gs1: gstate + } + } + }); + opacityPattern.write('/Gs1 gs /Pattern cs /Sh1 scn'); + opacityPattern.end(`${pageBBox.join(' ')} re f`); + this.doc.page.patterns[this.id] = opacityPattern; + } else { + this.doc.page.patterns[this.id] = pattern; + } + return pattern; + } + apply(stroke) { + // apply gradient transform to existing document ctm + const [m0, m1, m2, m3, m4, m5] = this.doc._ctm; + const [m11, m12, m21, m22, dx, dy] = this.transform; + const m = [m0 * m11 + m2 * m12, m1 * m11 + m3 * m12, m0 * m21 + m2 * m22, m1 * m21 + m3 * m22, m0 * dx + m2 * dy + m4, m1 * dx + m3 * dy + m5]; + if (!this.embedded || m.join(' ') !== this.matrix.join(' ')) { + this.embed(m); + } + this.doc._setColorSpace('Pattern', stroke); + const op = stroke ? 'SCN' : 'scn'; + return this.doc.addContent(`/${this.id} ${op}`); + } +}; +let PDFLinearGradient$1 = class PDFLinearGradient extends PDFGradient$1 { + constructor(doc, x1, y1, x2, y2) { + super(doc); + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + } + shader(fn) { + return this.doc.ref({ + ShadingType: 2, + ColorSpace: this._colorSpace, + Coords: [this.x1, this.y1, this.x2, this.y2], + Function: fn, + Extend: [true, true] + }); + } + opacityGradient() { + return new PDFLinearGradient(this.doc, this.x1, this.y1, this.x2, this.y2); + } +}; +let PDFRadialGradient$1 = class PDFRadialGradient extends PDFGradient$1 { + constructor(doc, x1, y1, r1, x2, y2, r2) { + super(doc); + this.doc = doc; + this.x1 = x1; + this.y1 = y1; + this.r1 = r1; + this.x2 = x2; + this.y2 = y2; + this.r2 = r2; + } + shader(fn) { + return this.doc.ref({ + ShadingType: 3, + ColorSpace: this._colorSpace, + Coords: [this.x1, this.y1, this.r1, this.x2, this.y2, this.r2], + Function: fn, + Extend: [true, true] + }); + } + opacityGradient() { + return new PDFRadialGradient(this.doc, this.x1, this.y1, this.r1, this.x2, this.y2, this.r2); + } +}; +var Gradient = { + PDFGradient: PDFGradient$1, + PDFLinearGradient: PDFLinearGradient$1, + PDFRadialGradient: PDFRadialGradient$1 +}; + +/* +PDF tiling pattern support. Uncolored only. + */ + +const underlyingColorSpaces = ['DeviceCMYK', 'DeviceRGB']; +let PDFTilingPattern$1 = class PDFTilingPattern { + constructor(doc, bBox, xStep, yStep, stream) { + this.doc = doc; + this.bBox = bBox; + this.xStep = xStep; + this.yStep = yStep; + this.stream = stream; + } + createPattern() { + // no resources needed for our current usage + // required entry + const resources = this.doc.ref(); + resources.end(); + // apply default transform matrix (flipped in the default doc._ctm) + // see document.js & gradient.js + const [m0, m1, m2, m3, m4, m5] = this.doc._ctm; + const [m11, m12, m21, m22, dx, dy] = [1, 0, 0, 1, 0, 0]; + const m = [m0 * m11 + m2 * m12, m1 * m11 + m3 * m12, m0 * m21 + m2 * m22, m1 * m21 + m3 * m22, m0 * dx + m2 * dy + m4, m1 * dx + m3 * dy + m5]; + const pattern = this.doc.ref({ + Type: 'Pattern', + PatternType: 1, + // tiling + PaintType: 2, + // 1-colored, 2-uncolored + TilingType: 2, + // 2-no distortion + BBox: this.bBox, + XStep: this.xStep, + YStep: this.yStep, + Matrix: m.map(v => +v.toFixed(5)), + Resources: resources + }); + pattern.end(this.stream); + return pattern; + } + embedPatternColorSpaces() { + // map each pattern to an underlying color space + // and embed on each page + underlyingColorSpaces.forEach(csName => { + const csId = this.getPatternColorSpaceId(csName); + if (this.doc.page.colorSpaces[csId]) return; + const cs = this.doc.ref(['Pattern', csName]); + cs.end(); + this.doc.page.colorSpaces[csId] = cs; + }); + } + getPatternColorSpaceId(underlyingColorspace) { + return `CsP${underlyingColorspace}`; + } + embed() { + if (!this.id) { + this.doc._patternCount = this.doc._patternCount + 1; + this.id = 'P' + this.doc._patternCount; + this.pattern = this.createPattern(); + } + + // patterns are embedded in each page + if (!this.doc.page.patterns[this.id]) { + this.doc.page.patterns[this.id] = this.pattern; + } + } + apply(stroke, patternColor) { + // do any embedding/creating that might be needed + this.embedPatternColorSpaces(); + this.embed(); + const normalizedColor = this.doc._normalizeColor(patternColor); + if (!normalizedColor) throw Error(`invalid pattern color. (value: ${patternColor})`); + + // select one of the pattern color spaces + const csId = this.getPatternColorSpaceId(this.doc._getColorSpace(normalizedColor)); + this.doc._setColorSpace(csId, stroke); + + // stroke/fill using the pattern and color (in the above underlying color space) + const op = stroke ? 'SCN' : 'scn'; + return this.doc.addContent(`${normalizedColor.join(' ')} /${this.id} ${op}`); + } +}; +var pattern = { + PDFTilingPattern: PDFTilingPattern$1 +}; + +class SpotColor { + constructor(doc, name, C, M, Y, K) { + this.id = 'CS' + Object.keys(doc.spotColors).length; + this.name = name; + this.values = [C, M, Y, K]; + this.ref = doc.ref(['Separation', this.name, 'DeviceCMYK', { + Range: [0, 1, 0, 1, 0, 1, 0, 1], + C0: [0, 0, 0, 0], + C1: this.values.map(value => value / 100), + FunctionType: 2, + Domain: [0, 1], + N: 1 + }]); + this.ref.end(); + } + toString() { + return `${this.ref.id} 0 R`; + } +} + +const { + PDFGradient, + PDFLinearGradient, + PDFRadialGradient +} = Gradient; +const { + PDFTilingPattern +} = pattern; +var ColorMixin = { + initColor() { + this.spotColors = {}; + // The opacity dictionaries + this._opacityRegistry = {}; + this._opacityCount = 0; + this._patternCount = 0; + return this._gradCount = 0; + }, + _normalizeColor(color) { + if (typeof color === 'string') { + if (color.charAt(0) === '#') { + if (color.length === 4) { + color = color.replace(/#([0-9A-F])([0-9A-F])([0-9A-F])/i, '#$1$1$2$2$3$3'); + } + const hex = parseInt(color.slice(1), 16); + color = [hex >> 16, hex >> 8 & 0xff, hex & 0xff]; + } else if (namedColors[color]) { + color = namedColors[color]; + } else if (this.spotColors[color]) { + return this.spotColors[color]; + } + } + if (Array.isArray(color)) { + // RGB + if (color.length === 3) { + color = color.map(part => part / 255); + // CMYK + } else if (color.length === 4) { + color = color.map(part => part / 100); + } + return color; + } + return null; + }, + _setColor(color, stroke) { + if (color instanceof PDFGradient) { + color.apply(stroke); + return true; + // see if tiling pattern, decode & apply it it + } else if (Array.isArray(color) && color[0] instanceof PDFTilingPattern) { + color[0].apply(stroke, color[1]); + return true; + } + // any other case should be a normal color and not a pattern + return this._setColorCore(color, stroke); + }, + _setColorCore(color, stroke) { + color = this._normalizeColor(color); + if (!color) { + return false; + } + const op = stroke ? 'SCN' : 'scn'; + const space = this._getColorSpace(color); + this._setColorSpace(space, stroke); + if (color instanceof SpotColor) { + this.page.colorSpaces[color.id] = color.ref; + this.addContent(`1 ${op}`); + } else { + this.addContent(`${color.join(' ')} ${op}`); + } + return true; + }, + _setColorSpace(space, stroke) { + const op = stroke ? 'CS' : 'cs'; + return this.addContent(`/${space} ${op}`); + }, + _getColorSpace(color) { + if (color instanceof SpotColor) { + return color.id; + } + return color.length === 4 ? 'DeviceCMYK' : 'DeviceRGB'; + }, + fillColor(color, opacity) { + const set = this._setColor(color, false); + if (set) { + this.fillOpacity(opacity); + } + + // save this for text wrapper, which needs to reset + // the fill color on new pages + this._fillColor = [color, opacity]; + return this; + }, + strokeColor(color, opacity) { + const set = this._setColor(color, true); + if (set) { + this.strokeOpacity(opacity); + } + return this; + }, + opacity(opacity) { + this._doOpacity(opacity, opacity); + return this; + }, + fillOpacity(opacity) { + this._doOpacity(opacity, null); + return this; + }, + strokeOpacity(opacity) { + this._doOpacity(null, opacity); + return this; + }, + _doOpacity(fillOpacity, strokeOpacity) { + let dictionary, name; + if (fillOpacity == null && strokeOpacity == null) { + return; + } + if (fillOpacity != null) { + fillOpacity = Math.max(0, Math.min(1, fillOpacity)); + } + if (strokeOpacity != null) { + strokeOpacity = Math.max(0, Math.min(1, strokeOpacity)); + } + const key = `${fillOpacity}_${strokeOpacity}`; + if (this._opacityRegistry[key]) { + [dictionary, name] = this._opacityRegistry[key]; + } else { + dictionary = { + Type: 'ExtGState' + }; + if (fillOpacity != null) { + dictionary.ca = fillOpacity; + } + if (strokeOpacity != null) { + dictionary.CA = strokeOpacity; + } + dictionary = this.ref(dictionary); + dictionary.end(); + const id = ++this._opacityCount; + name = `Gs${id}`; + this._opacityRegistry[key] = [dictionary, name]; + } + this.page.ext_gstates[name] = dictionary; + return this.addContent(`/${name} gs`); + }, + linearGradient(x1, y1, x2, y2) { + return new PDFLinearGradient(this, x1, y1, x2, y2); + }, + radialGradient(x1, y1, r1, x2, y2, r2) { + return new PDFRadialGradient(this, x1, y1, r1, x2, y2, r2); + }, + pattern(bbox, xStep, yStep, stream) { + return new PDFTilingPattern(this, bbox, xStep, yStep, stream); + }, + addSpotColor(name, C, M, Y, K) { + const color = new SpotColor(this, name, C, M, Y, K); + this.spotColors[name] = color; + return this; + } +}; +var namedColors = { + aliceblue: [240, 248, 255], + antiquewhite: [250, 235, 215], + aqua: [0, 255, 255], + aquamarine: [127, 255, 212], + azure: [240, 255, 255], + beige: [245, 245, 220], + bisque: [255, 228, 196], + black: [0, 0, 0], + blanchedalmond: [255, 235, 205], + blue: [0, 0, 255], + blueviolet: [138, 43, 226], + brown: [165, 42, 42], + burlywood: [222, 184, 135], + cadetblue: [95, 158, 160], + chartreuse: [127, 255, 0], + chocolate: [210, 105, 30], + coral: [255, 127, 80], + cornflowerblue: [100, 149, 237], + cornsilk: [255, 248, 220], + crimson: [220, 20, 60], + cyan: [0, 255, 255], + darkblue: [0, 0, 139], + darkcyan: [0, 139, 139], + darkgoldenrod: [184, 134, 11], + darkgray: [169, 169, 169], + darkgreen: [0, 100, 0], + darkgrey: [169, 169, 169], + darkkhaki: [189, 183, 107], + darkmagenta: [139, 0, 139], + darkolivegreen: [85, 107, 47], + darkorange: [255, 140, 0], + darkorchid: [153, 50, 204], + darkred: [139, 0, 0], + darksalmon: [233, 150, 122], + darkseagreen: [143, 188, 143], + darkslateblue: [72, 61, 139], + darkslategray: [47, 79, 79], + darkslategrey: [47, 79, 79], + darkturquoise: [0, 206, 209], + darkviolet: [148, 0, 211], + deeppink: [255, 20, 147], + deepskyblue: [0, 191, 255], + dimgray: [105, 105, 105], + dimgrey: [105, 105, 105], + dodgerblue: [30, 144, 255], + firebrick: [178, 34, 34], + floralwhite: [255, 250, 240], + forestgreen: [34, 139, 34], + fuchsia: [255, 0, 255], + gainsboro: [220, 220, 220], + ghostwhite: [248, 248, 255], + gold: [255, 215, 0], + goldenrod: [218, 165, 32], + gray: [128, 128, 128], + grey: [128, 128, 128], + green: [0, 128, 0], + greenyellow: [173, 255, 47], + honeydew: [240, 255, 240], + hotpink: [255, 105, 180], + indianred: [205, 92, 92], + indigo: [75, 0, 130], + ivory: [255, 255, 240], + khaki: [240, 230, 140], + lavender: [230, 230, 250], + lavenderblush: [255, 240, 245], + lawngreen: [124, 252, 0], + lemonchiffon: [255, 250, 205], + lightblue: [173, 216, 230], + lightcoral: [240, 128, 128], + lightcyan: [224, 255, 255], + lightgoldenrodyellow: [250, 250, 210], + lightgray: [211, 211, 211], + lightgreen: [144, 238, 144], + lightgrey: [211, 211, 211], + lightpink: [255, 182, 193], + lightsalmon: [255, 160, 122], + lightseagreen: [32, 178, 170], + lightskyblue: [135, 206, 250], + lightslategray: [119, 136, 153], + lightslategrey: [119, 136, 153], + lightsteelblue: [176, 196, 222], + lightyellow: [255, 255, 224], + lime: [0, 255, 0], + limegreen: [50, 205, 50], + linen: [250, 240, 230], + magenta: [255, 0, 255], + maroon: [128, 0, 0], + mediumaquamarine: [102, 205, 170], + mediumblue: [0, 0, 205], + mediumorchid: [186, 85, 211], + mediumpurple: [147, 112, 219], + mediumseagreen: [60, 179, 113], + mediumslateblue: [123, 104, 238], + mediumspringgreen: [0, 250, 154], + mediumturquoise: [72, 209, 204], + mediumvioletred: [199, 21, 133], + midnightblue: [25, 25, 112], + mintcream: [245, 255, 250], + mistyrose: [255, 228, 225], + moccasin: [255, 228, 181], + navajowhite: [255, 222, 173], + navy: [0, 0, 128], + oldlace: [253, 245, 230], + olive: [128, 128, 0], + olivedrab: [107, 142, 35], + orange: [255, 165, 0], + orangered: [255, 69, 0], + orchid: [218, 112, 214], + palegoldenrod: [238, 232, 170], + palegreen: [152, 251, 152], + paleturquoise: [175, 238, 238], + palevioletred: [219, 112, 147], + papayawhip: [255, 239, 213], + peachpuff: [255, 218, 185], + peru: [205, 133, 63], + pink: [255, 192, 203], + plum: [221, 160, 221], + powderblue: [176, 224, 230], + purple: [128, 0, 128], + red: [255, 0, 0], + rosybrown: [188, 143, 143], + royalblue: [65, 105, 225], + saddlebrown: [139, 69, 19], + salmon: [250, 128, 114], + sandybrown: [244, 164, 96], + seagreen: [46, 139, 87], + seashell: [255, 245, 238], + sienna: [160, 82, 45], + silver: [192, 192, 192], + skyblue: [135, 206, 235], + slateblue: [106, 90, 205], + slategray: [112, 128, 144], + slategrey: [112, 128, 144], + snow: [255, 250, 250], + springgreen: [0, 255, 127], + steelblue: [70, 130, 180], + tan: [210, 180, 140], + teal: [0, 128, 128], + thistle: [216, 191, 216], + tomato: [255, 99, 71], + turquoise: [64, 224, 208], + violet: [238, 130, 238], + wheat: [245, 222, 179], + white: [255, 255, 255], + whitesmoke: [245, 245, 245], + yellow: [255, 255, 0], + yellowgreen: [154, 205, 50] +}; + +let cx; +let cy; +let px; +let py; +let sx; +let sy; +cx = cy = px = py = sx = sy = 0; + +// parseDataPath copy pasted from svgo +// https://github.com/svg/svgo/blob/e4918ccdd1a2b5831defe0f00c1286744b479448/lib/path.js + +/** + * @typedef {'M' | 'm' | 'Z' | 'z' | 'L' | 'l' | 'H' | 'h' | 'V' | 'v' | 'C' | 'c' | 'S' | 's' | 'Q' | 'q' | 'T' | 't' | 'A' | 'a'} PathDataCommand + */ + +/** + * @typedef {Object} PathDataItem + * @property {PathDataCommand} command + * @property {number[]} args + */ + +const argsCountPerCommand = { + M: 2, + m: 2, + Z: 0, + z: 0, + L: 2, + l: 2, + H: 1, + h: 1, + V: 1, + v: 1, + C: 6, + c: 6, + S: 4, + s: 4, + Q: 4, + q: 4, + T: 2, + t: 2, + A: 7, + a: 7 +}; + +/** + * @type {(c: string) => c is PathDataCommand} + */ +const isCommand = c => { + return c in argsCountPerCommand; +}; + +/** + * @type {(c: string) => boolean} + */ +const isWsp = c => { + const codePoint = c.codePointAt(0); + return codePoint === 0x20 || codePoint === 0x9 || codePoint === 0xd || codePoint === 0xa; +}; + +/** + * @type {(c: string) => boolean} + */ +const isDigit = c => { + const codePoint = c.codePointAt(0); + if (codePoint == null) { + return false; + } + return 48 <= codePoint && codePoint <= 57; +}; + +/** + * @typedef {'none' | 'sign' | 'whole' | 'decimal_point' | 'decimal' | 'e' | 'exponent_sign' | 'exponent'} ReadNumberState + */ + +/** + * @type {(string: string, cursor: number) => [number, number | null]} + */ +const readNumber = (string, cursor) => { + let i = cursor; + let value = ''; + let state = /** @type {ReadNumberState} */'none'; + for (; i < string.length; i += 1) { + const c = string[i]; + if (c === '+' || c === '-') { + if (state === 'none') { + state = 'sign'; + value += c; + continue; + } + if (state === 'e') { + state = 'exponent_sign'; + value += c; + continue; + } + } + if (isDigit(c)) { + if (state === 'none' || state === 'sign' || state === 'whole') { + state = 'whole'; + value += c; + continue; + } + if (state === 'decimal_point' || state === 'decimal') { + state = 'decimal'; + value += c; + continue; + } + if (state === 'e' || state === 'exponent_sign' || state === 'exponent') { + state = 'exponent'; + value += c; + continue; + } + } + if (c === '.') { + if (state === 'none' || state === 'sign' || state === 'whole') { + state = 'decimal_point'; + value += c; + continue; + } + } + if (c === 'E' || c === 'e') { + if (state === 'whole' || state === 'decimal_point' || state === 'decimal') { + state = 'e'; + value += c; + continue; + } + } + break; + } + const number = Number.parseFloat(value); + if (Number.isNaN(number)) { + return [cursor, null]; + } + // step back to delegate iteration to parent loop + return [i - 1, number]; +}; + +/** + * @type {(string: string) => Array} + */ +const parsePathData = string => { + /** + * @type {Array} + */ + const pathData = []; + /** + * @type {null | PathDataCommand} + */ + let command = null; + let args = /** @type {number[]} */[]; + let argsCount = 0; + let canHaveComma = false; + let hadComma = false; + for (let i = 0; i < string.length; i += 1) { + const c = string.charAt(i); + if (isWsp(c)) { + continue; + } + // allow comma only between arguments + if (canHaveComma && c === ',') { + if (hadComma) { + break; + } + hadComma = true; + continue; + } + if (isCommand(c)) { + if (hadComma) { + return pathData; + } + if (command == null) { + // moveto should be leading command + if (c !== 'M' && c !== 'm') { + return pathData; + } + } else { + // stop if previous command arguments are not flushed + if (args.length !== 0) { + return pathData; + } + } + command = c; + args = []; + argsCount = argsCountPerCommand[command]; + canHaveComma = false; + // flush command without arguments + if (argsCount === 0) { + pathData.push({ + command, + args + }); + } + continue; + } + // avoid parsing arguments if no command detected + if (command == null) { + return pathData; + } + // read next argument + let newCursor = i; + let number = null; + if (command === 'A' || command === 'a') { + const position = args.length; + if (position === 0 || position === 1) { + // allow only positive number without sign as first two arguments + if (c !== '+' && c !== '-') { + [newCursor, number] = readNumber(string, i); + } + } + if (position === 2 || position === 5 || position === 6) { + [newCursor, number] = readNumber(string, i); + } + if (position === 3 || position === 4) { + // read flags + if (c === '0') { + number = 0; + } + if (c === '1') { + number = 1; + } + } + } else { + [newCursor, number] = readNumber(string, i); + } + if (number == null) { + return pathData; + } + args.push(number); + canHaveComma = true; + hadComma = false; + i = newCursor; + // flush arguments when necessary count is reached + if (args.length === argsCount) { + pathData.push({ + command, + args + }); + // subsequent moveto coordinates are threated as implicit lineto commands + if (command === 'M') { + command = 'L'; + } + if (command === 'm') { + command = 'l'; + } + args = []; + } + } + return pathData; +}; +const apply = function (commands, doc) { + // current point, control point, and subpath starting point + cx = cy = px = py = sx = sy = 0; + + // run the commands + for (let i = 0; i < commands.length; i++) { + const { + command, + args + } = commands[i]; + if (typeof runners[command] === 'function') { + runners[command](doc, args); + } + } +}; +const runners = { + M(doc, a) { + cx = a[0]; + cy = a[1]; + px = py = null; + sx = cx; + sy = cy; + return doc.moveTo(cx, cy); + }, + m(doc, a) { + cx += a[0]; + cy += a[1]; + px = py = null; + sx = cx; + sy = cy; + return doc.moveTo(cx, cy); + }, + C(doc, a) { + cx = a[4]; + cy = a[5]; + px = a[2]; + py = a[3]; + return doc.bezierCurveTo(...a); + }, + c(doc, a) { + doc.bezierCurveTo(a[0] + cx, a[1] + cy, a[2] + cx, a[3] + cy, a[4] + cx, a[5] + cy); + px = cx + a[2]; + py = cy + a[3]; + cx += a[4]; + return cy += a[5]; + }, + S(doc, a) { + if (px === null) { + px = cx; + py = cy; + } + doc.bezierCurveTo(cx - (px - cx), cy - (py - cy), a[0], a[1], a[2], a[3]); + px = a[0]; + py = a[1]; + cx = a[2]; + return cy = a[3]; + }, + s(doc, a) { + if (px === null) { + px = cx; + py = cy; + } + doc.bezierCurveTo(cx - (px - cx), cy - (py - cy), cx + a[0], cy + a[1], cx + a[2], cy + a[3]); + px = cx + a[0]; + py = cy + a[1]; + cx += a[2]; + return cy += a[3]; + }, + Q(doc, a) { + px = a[0]; + py = a[1]; + cx = a[2]; + cy = a[3]; + return doc.quadraticCurveTo(a[0], a[1], cx, cy); + }, + q(doc, a) { + doc.quadraticCurveTo(a[0] + cx, a[1] + cy, a[2] + cx, a[3] + cy); + px = cx + a[0]; + py = cy + a[1]; + cx += a[2]; + return cy += a[3]; + }, + T(doc, a) { + if (px === null) { + px = cx; + py = cy; + } else { + px = cx - (px - cx); + py = cy - (py - cy); + } + doc.quadraticCurveTo(px, py, a[0], a[1]); + cx = a[0]; + return cy = a[1]; + }, + t(doc, a) { + if (px === null) { + px = cx; + py = cy; + } else { + px = cx - (px - cx); + py = cy - (py - cy); + } + doc.quadraticCurveTo(px, py, cx + a[0], cy + a[1]); + cx += a[0]; + return cy += a[1]; + }, + A(doc, a) { + solveArc(doc, cx, cy, a); + cx = a[5]; + return cy = a[6]; + }, + a(doc, a) { + a[5] += cx; + a[6] += cy; + solveArc(doc, cx, cy, a); + cx = a[5]; + return cy = a[6]; + }, + L(doc, a) { + cx = a[0]; + cy = a[1]; + px = py = null; + return doc.lineTo(cx, cy); + }, + l(doc, a) { + cx += a[0]; + cy += a[1]; + px = py = null; + return doc.lineTo(cx, cy); + }, + H(doc, a) { + cx = a[0]; + px = py = null; + return doc.lineTo(cx, cy); + }, + h(doc, a) { + cx += a[0]; + px = py = null; + return doc.lineTo(cx, cy); + }, + V(doc, a) { + cy = a[0]; + px = py = null; + return doc.lineTo(cx, cy); + }, + v(doc, a) { + cy += a[0]; + px = py = null; + return doc.lineTo(cx, cy); + }, + Z(doc) { + doc.closePath(); + cx = sx; + return cy = sy; + }, + z(doc) { + doc.closePath(); + cx = sx; + return cy = sy; + } +}; +const solveArc = function (doc, x, y, coords) { + const [rx, ry, rot, large, sweep, ex, ey] = coords; + const segs = arcToSegments(ex, ey, rx, ry, large, sweep, rot, x, y); + for (let seg of segs) { + const bez = segmentToBezier(...seg); + doc.bezierCurveTo(...bez); + } +}; + +// from Inkscape svgtopdf, thanks! +const arcToSegments = function (x, y, rx, ry, large, sweep, rotateX, ox, oy) { + const th = rotateX * (Math.PI / 180); + const sin_th = Math.sin(th); + const cos_th = Math.cos(th); + rx = Math.abs(rx); + ry = Math.abs(ry); + px = cos_th * (ox - x) * 0.5 + sin_th * (oy - y) * 0.5; + py = cos_th * (oy - y) * 0.5 - sin_th * (ox - x) * 0.5; + let pl = px * px / (rx * rx) + py * py / (ry * ry); + if (pl > 1) { + pl = Math.sqrt(pl); + rx *= pl; + ry *= pl; + } + const a00 = cos_th / rx; + const a01 = sin_th / rx; + const a10 = -sin_th / ry; + const a11 = cos_th / ry; + const x0 = a00 * ox + a01 * oy; + const y0 = a10 * ox + a11 * oy; + const x1 = a00 * x + a01 * y; + const y1 = a10 * x + a11 * y; + const d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0); + let sfactor_sq = 1 / d - 0.25; + if (sfactor_sq < 0) { + sfactor_sq = 0; + } + let sfactor = Math.sqrt(sfactor_sq); + if (sweep === large) { + sfactor = -sfactor; + } + const xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0); + const yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0); + const th0 = Math.atan2(y0 - yc, x0 - xc); + const th1 = Math.atan2(y1 - yc, x1 - xc); + let th_arc = th1 - th0; + if (th_arc < 0 && sweep === 1) { + th_arc += 2 * Math.PI; + } else if (th_arc > 0 && sweep === 0) { + th_arc -= 2 * Math.PI; + } + const segments = Math.ceil(Math.abs(th_arc / (Math.PI * 0.5 + 0.001))); + const result = []; + for (let i = 0; i < segments; i++) { + const th2 = th0 + i * th_arc / segments; + const th3 = th0 + (i + 1) * th_arc / segments; + result[i] = [xc, yc, th2, th3, rx, ry, sin_th, cos_th]; + } + return result; +}; +const segmentToBezier = function (cx, cy, th0, th1, rx, ry, sin_th, cos_th) { + const a00 = cos_th * rx; + const a01 = -sin_th * ry; + const a10 = sin_th * rx; + const a11 = cos_th * ry; + const th_half = 0.5 * (th1 - th0); + const t = 8 / 3 * Math.sin(th_half * 0.5) * Math.sin(th_half * 0.5) / Math.sin(th_half); + const x1 = cx + Math.cos(th0) - t * Math.sin(th0); + const y1 = cy + Math.sin(th0) + t * Math.cos(th0); + const x3 = cx + Math.cos(th1); + const y3 = cy + Math.sin(th1); + const x2 = x3 + t * Math.sin(th1); + const y2 = y3 - t * Math.cos(th1); + return [a00 * x1 + a01 * y1, a10 * x1 + a11 * y1, a00 * x2 + a01 * y2, a10 * x2 + a11 * y2, a00 * x3 + a01 * y3, a10 * x3 + a11 * y3]; +}; +class SVGPath { + static apply(doc, path) { + const commands = parsePathData(path); + apply(commands, doc); + } +} + +const { + number: number$1 +} = PDFObject; + +// This constant is used to approximate a symmetrical arc using a cubic +// Bezier curve. +const KAPPA = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0); +var VectorMixin = { + initVector() { + this._ctm = [1, 0, 0, 1, 0, 0]; // current transformation matrix + return this._ctmStack = []; + }, + save() { + this._ctmStack.push(this._ctm.slice()); + // TODO: save/restore colorspace and styles so not setting it unnessesarily all the time? + return this.addContent('q'); + }, + restore() { + this._ctm = this._ctmStack.pop() || [1, 0, 0, 1, 0, 0]; + return this.addContent('Q'); + }, + closePath() { + return this.addContent('h'); + }, + lineWidth(w) { + return this.addContent(`${number$1(w)} w`); + }, + _CAP_STYLES: { + BUTT: 0, + ROUND: 1, + SQUARE: 2 + }, + lineCap(c) { + if (typeof c === 'string') { + c = this._CAP_STYLES[c.toUpperCase()]; + } + return this.addContent(`${c} J`); + }, + _JOIN_STYLES: { + MITER: 0, + ROUND: 1, + BEVEL: 2 + }, + lineJoin(j) { + if (typeof j === 'string') { + j = this._JOIN_STYLES[j.toUpperCase()]; + } + return this.addContent(`${j} j`); + }, + miterLimit(m) { + return this.addContent(`${number$1(m)} M`); + }, + dash(length, options) { + if (options === void 0) { + options = {}; + } + const originalLength = length; + if (!Array.isArray(length)) { + length = [length, options.space || length]; + } + const valid = length.every(x => Number.isFinite(x) && x > 0); + if (!valid) { + throw new Error(`dash(${JSON.stringify(originalLength)}, ${JSON.stringify(options)}) invalid, lengths must be numeric and greater than zero`); + } + length = length.map(number$1).join(' '); + return this.addContent(`[${length}] ${number$1(options.phase || 0)} d`); + }, + undash() { + return this.addContent('[] 0 d'); + }, + moveTo(x, y) { + return this.addContent(`${number$1(x)} ${number$1(y)} m`); + }, + lineTo(x, y) { + return this.addContent(`${number$1(x)} ${number$1(y)} l`); + }, + bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) { + return this.addContent(`${number$1(cp1x)} ${number$1(cp1y)} ${number$1(cp2x)} ${number$1(cp2y)} ${number$1(x)} ${number$1(y)} c`); + }, + quadraticCurveTo(cpx, cpy, x, y) { + return this.addContent(`${number$1(cpx)} ${number$1(cpy)} ${number$1(x)} ${number$1(y)} v`); + }, + rect(x, y, w, h) { + return this.addContent(`${number$1(x)} ${number$1(y)} ${number$1(w)} ${number$1(h)} re`); + }, + roundedRect(x, y, w, h, r) { + if (r == null) { + r = 0; + } + r = Math.min(r, 0.5 * w, 0.5 * h); + + // amount to inset control points from corners (see `ellipse`) + const c = r * (1.0 - KAPPA); + this.moveTo(x + r, y); + this.lineTo(x + w - r, y); + this.bezierCurveTo(x + w - c, y, x + w, y + c, x + w, y + r); + this.lineTo(x + w, y + h - r); + this.bezierCurveTo(x + w, y + h - c, x + w - c, y + h, x + w - r, y + h); + this.lineTo(x + r, y + h); + this.bezierCurveTo(x + c, y + h, x, y + h - c, x, y + h - r); + this.lineTo(x, y + r); + this.bezierCurveTo(x, y + c, x + c, y, x + r, y); + return this.closePath(); + }, + ellipse(x, y, r1, r2) { + // based on http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas/2173084#2173084 + if (r2 == null) { + r2 = r1; + } + x -= r1; + y -= r2; + const ox = r1 * KAPPA; + const oy = r2 * KAPPA; + const xe = x + r1 * 2; + const ye = y + r2 * 2; + const xm = x + r1; + const ym = y + r2; + this.moveTo(x, ym); + this.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y); + this.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym); + this.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye); + this.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym); + return this.closePath(); + }, + circle(x, y, radius) { + return this.ellipse(x, y, radius); + }, + arc(x, y, radius, startAngle, endAngle, anticlockwise) { + if (anticlockwise == null) { + anticlockwise = false; + } + const TWO_PI = 2.0 * Math.PI; + const HALF_PI = 0.5 * Math.PI; + let deltaAng = endAngle - startAngle; + if (Math.abs(deltaAng) > TWO_PI) { + // draw only full circle if more than that is specified + deltaAng = TWO_PI; + } else if (deltaAng !== 0 && anticlockwise !== deltaAng < 0) { + // necessary to flip direction of rendering + const dir = anticlockwise ? -1 : 1; + deltaAng = dir * TWO_PI + deltaAng; + } + const numSegs = Math.ceil(Math.abs(deltaAng) / HALF_PI); + const segAng = deltaAng / numSegs; + const handleLen = segAng / HALF_PI * KAPPA * radius; + let curAng = startAngle; + + // component distances between anchor point and control point + let deltaCx = -Math.sin(curAng) * handleLen; + let deltaCy = Math.cos(curAng) * handleLen; + + // anchor point + let ax = x + Math.cos(curAng) * radius; + let ay = y + Math.sin(curAng) * radius; + + // calculate and render segments + this.moveTo(ax, ay); + for (let segIdx = 0; segIdx < numSegs; segIdx++) { + // starting control point + const cp1x = ax + deltaCx; + const cp1y = ay + deltaCy; + + // step angle + curAng += segAng; + + // next anchor point + ax = x + Math.cos(curAng) * radius; + ay = y + Math.sin(curAng) * radius; + + // next control point delta + deltaCx = -Math.sin(curAng) * handleLen; + deltaCy = Math.cos(curAng) * handleLen; + + // ending control point + const cp2x = ax - deltaCx; + const cp2y = ay - deltaCy; + + // render segment + this.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, ax, ay); + } + return this; + }, + polygon() { + for (var _len = arguments.length, points = new Array(_len), _key = 0; _key < _len; _key++) { + points[_key] = arguments[_key]; + } + this.moveTo(...(points.shift() || [])); + for (let point of points) { + this.lineTo(...(point || [])); + } + return this.closePath(); + }, + path(path) { + SVGPath.apply(this, path); + return this; + }, + _windingRule(rule) { + if (/even-?odd/.test(rule)) { + return '*'; + } + return ''; + }, + fill(color, rule) { + if (/(even-?odd)|(non-?zero)/.test(color)) { + rule = color; + color = null; + } + if (color) { + this.fillColor(color); + } + return this.addContent(`f${this._windingRule(rule)}`); + }, + stroke(color) { + if (color) { + this.strokeColor(color); + } + return this.addContent('S'); + }, + fillAndStroke(fillColor, strokeColor, rule) { + if (strokeColor == null) { + strokeColor = fillColor; + } + const isFillRule = /(even-?odd)|(non-?zero)/; + if (isFillRule.test(fillColor)) { + rule = fillColor; + fillColor = null; + } + if (isFillRule.test(strokeColor)) { + rule = strokeColor; + strokeColor = fillColor; + } + if (fillColor) { + this.fillColor(fillColor); + this.strokeColor(strokeColor); + } + return this.addContent(`B${this._windingRule(rule)}`); + }, + clip(rule) { + return this.addContent(`W${this._windingRule(rule)} n`); + }, + transform(m11, m12, m21, m22, dx, dy) { + // keep track of the current transformation matrix + if (m11 === 1 && m12 === 0 && m21 === 0 && m22 === 1 && dx === 0 && dy === 0) { + // Ignore identity transforms + return this; + } + const m = this._ctm; + const [m0, m1, m2, m3, m4, m5] = m; + m[0] = m0 * m11 + m2 * m12; + m[1] = m1 * m11 + m3 * m12; + m[2] = m0 * m21 + m2 * m22; + m[3] = m1 * m21 + m3 * m22; + m[4] = m0 * dx + m2 * dy + m4; + m[5] = m1 * dx + m3 * dy + m5; + const values = [m11, m12, m21, m22, dx, dy].map(v => number$1(v)).join(' '); + return this.addContent(`${values} cm`); + }, + translate(x, y) { + return this.transform(1, 0, 0, 1, x, y); + }, + rotate(angle, options) { + if (options === void 0) { + options = {}; + } + let y; + const rad = angle * Math.PI / 180; + const cos = Math.cos(rad); + const sin = Math.sin(rad); + let x = y = 0; + if (options.origin != null) { + [x, y] = options.origin; + const x1 = x * cos - y * sin; + const y1 = x * sin + y * cos; + x -= x1; + y -= y1; + } + return this.transform(cos, sin, -sin, cos, x, y); + }, + scale(xFactor, yFactor, options) { + if (options === void 0) { + options = {}; + } + let y; + if (yFactor == null) { + yFactor = xFactor; + } + if (typeof yFactor === 'object') { + options = yFactor; + yFactor = xFactor; + } + let x = y = 0; + if (options.origin != null) { + [x, y] = options.origin; + x -= xFactor * x; + y -= yFactor * y; + } + return this.transform(xFactor, 0, 0, yFactor, x, y); + } +}; + +const range = (left, right, inclusive) => { + let range = []; + let end = right + 1 ; + for (let i = left; i < end ; i++ ) { + range.push(i); + } + return range; +}; + +const WIN_ANSI_MAP = { + 402: 131, + 8211: 150, + 8212: 151, + 8216: 145, + 8217: 146, + 8218: 130, + 8220: 147, + 8221: 148, + 8222: 132, + 8224: 134, + 8225: 135, + 8226: 149, + 8230: 133, + 8364: 128, + 8240: 137, + 8249: 139, + 8250: 155, + 710: 136, + 8482: 153, + 338: 140, + 339: 156, + 732: 152, + 352: 138, + 353: 154, + 376: 159, + 381: 142, + 382: 158 +}; +const characters = `\ +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef +.notdef .notdef .notdef .notdef + +space exclam quotedbl numbersign +dollar percent ampersand quotesingle +parenleft parenright asterisk plus +comma hyphen period slash +zero one two three +four five six seven +eight nine colon semicolon +less equal greater question + +at A B C +D E F G +H I J K +L M N O +P Q R S +T U V W +X Y Z bracketleft +backslash bracketright asciicircum underscore + +grave a b c +d e f g +h i j k +l m n o +p q r s +t u v w +x y z braceleft +bar braceright asciitilde .notdef + +Euro .notdef quotesinglbase florin +quotedblbase ellipsis dagger daggerdbl +circumflex perthousand Scaron guilsinglleft +OE .notdef Zcaron .notdef +.notdef quoteleft quoteright quotedblleft +quotedblright bullet endash emdash +tilde trademark scaron guilsinglright +oe .notdef zcaron ydieresis + +space exclamdown cent sterling +currency yen brokenbar section +dieresis copyright ordfeminine guillemotleft +logicalnot softhyphen registered macron +degree plusminus twosuperior threesuperior +acute mu paragraph periodcentered +cedilla onesuperior ordmasculine guillemotright +onequarter onehalf threequarters questiondown + +Agrave Aacute Acircumflex Atilde +Adieresis Aring AE Ccedilla +Egrave Eacute Ecircumflex Edieresis +Igrave Iacute Icircumflex Idieresis +Eth Ntilde Ograve Oacute +Ocircumflex Otilde Odieresis multiply +Oslash Ugrave Uacute Ucircumflex +Udieresis Yacute Thorn germandbls + +agrave aacute acircumflex atilde +adieresis aring ae ccedilla +egrave eacute ecircumflex edieresis +igrave iacute icircumflex idieresis +eth ntilde ograve oacute +ocircumflex otilde odieresis divide +oslash ugrave uacute ucircumflex +udieresis yacute thorn ydieresis\ +`.split(/\s+/); +function parse(contents) { + const obj = { + attributes: {}, + glyphWidths: {}, + kernPairs: {} + }; + let section = ''; + for (let line of contents.split('\n')) { + var match; + var a; + if (match = line.match(/^Start(\w+)/)) { + section = match[1]; + continue; + } else if (match = line.match(/^End(\w+)/)) { + section = ''; + continue; + } + switch (section) { + case 'FontMetrics': + match = line.match(/(^\w+)\s+(.*)/); + var key = match[1]; + var value = match[2]; + if (a = obj.attributes[key]) { + if (!Array.isArray(a)) { + a = obj.attributes[key] = [a]; + } + a.push(value); + } else { + obj.attributes[key] = value; + } + break; + case 'CharMetrics': + if (!/^CH?\s/.test(line)) { + continue; + } + var name = line.match(/\bN\s+(\.?\w+)\s*;/)[1]; + obj.glyphWidths[name] = +line.match(/\bWX\s+(\d+)\s*;/)[1]; + break; + case 'KernPairs': + match = line.match(/^KPX\s+(\.?\w+)\s+(\.?\w+)\s+(-?\d+)/); + if (match) { + obj.kernPairs[match[1] + match[2]] = parseInt(match[3]); + } + break; + } + } + return obj; +} +class AFMFont { + static open(filename) { + return new AFMFont(fs.readFileSync(filename, 'utf8')); + } + static fromJson(json) { + return new AFMFont(json); + } + constructor(contents) { + if (typeof contents === 'string') { + this.contents = contents; + this.parse(); + } else { + this.attributes = contents.attributes; + this.glyphWidths = contents.glyphWidths; + this.kernPairs = contents.kernPairs; + } + this.charWidths = range(0, 255).map(i => this.glyphWidths[characters[i]]); + this.bbox = Array.from(this.attributes.FontBBox.split(/\s+/)).map(e => +e); + this.ascender = +(this.attributes.Ascender || 0); + this.descender = +(this.attributes.Descender || 0); + this.xHeight = +(this.attributes.XHeight || 0); + this.capHeight = +(this.attributes.CapHeight || 0); + this.lineGap = this.bbox[3] - this.bbox[1] - (this.ascender - this.descender); + } + parse() { + const parsed = parse(this.contents); + this.attributes = parsed.attributes; + this.glyphWidths = parsed.glyphWidths; + this.kernPairs = parsed.kernPairs; + } + encodeText(text) { + const res = []; + for (let i = 0, end = text.length, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { + let char = text.charCodeAt(i); + char = WIN_ANSI_MAP[char] || char; + res.push(char.toString(16)); + } + return res; + } + glyphsForString(string) { + const glyphs = []; + for (let i = 0, end = string.length, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { + const charCode = string.charCodeAt(i); + glyphs.push(this.characterToGlyph(charCode)); + } + return glyphs; + } + characterToGlyph(character) { + return characters[WIN_ANSI_MAP[character] || character] || '.notdef'; + } + widthOfGlyph(glyph) { + return this.glyphWidths[glyph] || 0; + } + getKernPair(left, right) { + return this.kernPairs[left + right] || 0; + } + advancesForGlyphs(glyphs) { + const advances = []; + for (let index = 0; index < glyphs.length; index++) { + const left = glyphs[index]; + const right = glyphs[index + 1]; + advances.push(this.widthOfGlyph(left) + this.getKernPair(left, right)); + } + return advances; + } +} + +var attributes = [ + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:43:52 1997", + "UniqueID 43052", + "VMusage 37169 48194" + ], + FontName: "Helvetica-Bold", + FullName: "Helvetica Bold", + FamilyName: "Helvetica", + Weight: "Bold", + ItalicAngle: "0", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-170 -228 1003 962 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "718", + XHeight: "532", + Ascender: "718", + Descender: "-207", + StdHW: "118", + StdVW: "140" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:45:12 1997", + "UniqueID 43053", + "VMusage 14482 68586" + ], + FontName: "Helvetica-BoldOblique", + FullName: "Helvetica Bold Oblique", + FamilyName: "Helvetica", + Weight: "Bold", + ItalicAngle: "-12", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-174 -228 1114 962", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "718", + XHeight: "532", + Ascender: "718", + Descender: "-207", + StdHW: "118", + StdVW: "140" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:44:31 1997", + "UniqueID 43055", + "VMusage 14960 69346" + ], + FontName: "Helvetica-Oblique", + FullName: "Helvetica Oblique", + FamilyName: "Helvetica", + Weight: "Medium", + ItalicAngle: "-12", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-170 -225 1116 931 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "718", + XHeight: "523", + Ascender: "718", + Descender: "-207", + StdHW: "76", + StdVW: "88" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:38:23 1997", + "UniqueID 43054", + "VMusage 37069 48094" + ], + FontName: "Helvetica", + FullName: "Helvetica", + FamilyName: "Helvetica", + Weight: "Medium", + ItalicAngle: "0", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-166 -225 1000 931 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.Helvetica is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "718", + XHeight: "523", + Ascender: "718", + Descender: "-207", + StdHW: "76", + StdVW: "88" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:52:56 1997", + "UniqueID 43065", + "VMusage 41636 52661" + ], + FontName: "Times-Bold", + FullName: "Times Bold", + FamilyName: "Times", + Weight: "Bold", + ItalicAngle: "0", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-168 -218 1000 935 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "676", + XHeight: "461", + Ascender: "683", + Descender: "-217", + StdHW: "44", + StdVW: "139" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 13:04:06 1997", + "UniqueID 43066", + "VMusage 45874 56899" + ], + FontName: "Times-BoldItalic", + FullName: "Times Bold Italic", + FamilyName: "Times", + Weight: "Bold", + ItalicAngle: "-15", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-200 -218 996 921", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "669", + XHeight: "462", + Ascender: "683", + Descender: "-217", + StdHW: "42", + StdVW: "121" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:56:55 1997", + "UniqueID 43067", + "VMusage 47727 58752" + ], + FontName: "Times-Italic", + FullName: "Times Italic", + FamilyName: "Times", + Weight: "Medium", + ItalicAngle: "-15.5", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-169 -217 1010 883 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "653", + XHeight: "441", + Ascender: "683", + Descender: "-217", + StdHW: "32", + StdVW: "76" + }, + { + Comment: [ + "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 12:49:17 1997", + "UniqueID 43068", + "VMusage 43909 54934" + ], + FontName: "Times-Roman", + FullName: "Times Roman", + FamilyName: "Times", + Weight: "Roman", + ItalicAngle: "0", + IsFixedPitch: "false", + CharacterSet: "ExtendedRoman", + FontBBox: "-168 -218 1000 898 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "002.000", + Notice: "Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.Times is a trademark of Linotype-Hell AG and/or its subsidiaries.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "662", + XHeight: "450", + Ascender: "683", + Descender: "-217", + StdHW: "28", + StdVW: "84" + }, + { + Comment: [ + "Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Mon Jun 23 16:28:00 1997", + "UniqueID 43048", + "VMusage 41139 52164" + ], + FontName: "Courier-Bold", + FullName: "Courier Bold", + FamilyName: "Courier", + Weight: "Bold", + ItalicAngle: "0", + IsFixedPitch: "true", + CharacterSet: "ExtendedRoman", + FontBBox: "-113 -250 749 801 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "003.000", + Notice: "Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "562", + XHeight: "439", + Ascender: "629", + Descender: "-157", + StdHW: "84", + StdVW: "106" + }, + { + Comment: [ + "Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Mon Jun 23 16:28:46 1997", + "UniqueID 43049", + "VMusage 17529 79244" + ], + FontName: "Courier-BoldOblique", + FullName: "Courier Bold Oblique", + FamilyName: "Courier", + Weight: "Bold", + ItalicAngle: "-12", + IsFixedPitch: "true", + CharacterSet: "ExtendedRoman", + FontBBox: "-57 -250 869 801", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "003.000", + Notice: "Copyright (c) 1989, 1990, 1991, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "562", + XHeight: "439", + Ascender: "629", + Descender: "-157", + StdHW: "84", + StdVW: "106" + }, + { + Comment: [ + "Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 17:37:52 1997", + "UniqueID 43051", + "VMusage 16248 75829" + ], + FontName: "Courier-Oblique", + FullName: "Courier Oblique", + FamilyName: "Courier", + Weight: "Medium", + ItalicAngle: "-12", + IsFixedPitch: "true", + CharacterSet: "ExtendedRoman", + FontBBox: "-27 -250 849 805 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "003.000", + Notice: "Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "562", + XHeight: "426", + Ascender: "629", + Descender: "-157", + StdHW: "51", + StdVW: "51" + }, + { + Comment: [ + "Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + "Creation Date: Thu May 1 17:27:09 1997", + "UniqueID 43050", + "VMusage 39754 50779" + ], + FontName: "Courier", + FullName: "Courier", + FamilyName: "Courier", + Weight: "Medium", + ItalicAngle: "0", + IsFixedPitch: "true", + CharacterSet: "ExtendedRoman", + FontBBox: "-23 -250 715 805 ", + UnderlinePosition: "-100", + UnderlineThickness: "50", + Version: "003.000", + Notice: "Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.", + EncodingScheme: "AdobeStandardEncoding", + CapHeight: "562", + XHeight: "426", + Ascender: "629", + Descender: "-157", + StdHW: "51", + StdVW: "51" + } +]; +var glyphWidths = { + space: [ + 278, + 278, + 278, + 278, + 250, + 250, + 250, + 250, + 600, + 600, + 600, + 600 + ], + exclam: [ + 333, + 333, + 278, + 278, + 333, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + quotedbl: [ + 474, + 474, + 355, + 355, + 555, + 555, + 420, + 408, + 600, + 600, + 600, + 600 + ], + numbersign: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + dollar: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + percent: [ + 889, + 889, + 889, + 889, + 1000, + 833, + 833, + 833, + 600, + 600, + 600, + 600 + ], + ampersand: [ + 722, + 722, + 667, + 667, + 833, + 778, + 778, + 778, + 600, + 600, + 600, + 600 + ], + quoteright: [ + 278, + 278, + 222, + 222, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + parenleft: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + parenright: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + asterisk: [ + 389, + 389, + 389, + 389, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + plus: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + comma: [ + 278, + 278, + 278, + 278, + 250, + 250, + 250, + 250, + 600, + 600, + 600, + 600 + ], + hyphen: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + period: [ + 278, + 278, + 278, + 278, + 250, + 250, + 250, + 250, + 600, + 600, + 600, + 600 + ], + slash: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + zero: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + one: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + two: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + three: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + four: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + five: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + six: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + seven: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + eight: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + nine: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + colon: [ + 333, + 333, + 278, + 278, + 333, + 333, + 333, + 278, + 600, + 600, + 600, + 600 + ], + semicolon: [ + 333, + 333, + 278, + 278, + 333, + 333, + 333, + 278, + 600, + 600, + 600, + 600 + ], + less: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + equal: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + greater: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + question: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + at: [ + 975, + 975, + 1015, + 1015, + 930, + 832, + 920, + 921, + 600, + 600, + 600, + 600 + ], + A: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + B: [ + 722, + 722, + 667, + 667, + 667, + 667, + 611, + 667, + 600, + 600, + 600, + 600 + ], + C: [ + 722, + 722, + 722, + 722, + 722, + 667, + 667, + 667, + 600, + 600, + 600, + 600 + ], + D: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + E: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + F: [ + 611, + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 600, + 600, + 600, + 600 + ], + G: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + H: [ + 722, + 722, + 722, + 722, + 778, + 778, + 722, + 722, + 600, + 600, + 600, + 600 + ], + I: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + J: [ + 556, + 556, + 500, + 500, + 500, + 500, + 444, + 389, + 600, + 600, + 600, + 600 + ], + K: [ + 722, + 722, + 667, + 667, + 778, + 667, + 667, + 722, + 600, + 600, + 600, + 600 + ], + L: [ + 611, + 611, + 556, + 556, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + M: [ + 833, + 833, + 833, + 833, + 944, + 889, + 833, + 889, + 600, + 600, + 600, + 600 + ], + N: [ + 722, + 722, + 722, + 722, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + O: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + P: [ + 667, + 667, + 667, + 667, + 611, + 611, + 611, + 556, + 600, + 600, + 600, + 600 + ], + Q: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + R: [ + 722, + 722, + 722, + 722, + 722, + 667, + 611, + 667, + 600, + 600, + 600, + 600 + ], + S: [ + 667, + 667, + 667, + 667, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + T: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + U: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + V: [ + 667, + 667, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + W: [ + 944, + 944, + 944, + 944, + 1000, + 889, + 833, + 944, + 600, + 600, + 600, + 600 + ], + X: [ + 667, + 667, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Y: [ + 667, + 667, + 667, + 667, + 722, + 611, + 556, + 722, + 600, + 600, + 600, + 600 + ], + Z: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + bracketleft: [ + 333, + 333, + 278, + 278, + 333, + 333, + 389, + 333, + 600, + 600, + 600, + 600 + ], + backslash: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + bracketright: [ + 333, + 333, + 278, + 278, + 333, + 333, + 389, + 333, + 600, + 600, + 600, + 600 + ], + asciicircum: [ + 584, + 584, + 469, + 469, + 581, + 570, + 422, + 469, + 600, + 600, + 600, + 600 + ], + underscore: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + quoteleft: [ + 278, + 278, + 222, + 222, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + a: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + b: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + c: [ + 556, + 556, + 500, + 500, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + d: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + e: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + f: [ + 333, + 333, + 278, + 278, + 333, + 333, + 278, + 333, + 600, + 600, + 600, + 600 + ], + g: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + h: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + i: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + j: [ + 278, + 278, + 222, + 222, + 333, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + k: [ + 556, + 556, + 500, + 500, + 556, + 500, + 444, + 500, + 600, + 600, + 600, + 600 + ], + l: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + m: [ + 889, + 889, + 833, + 833, + 833, + 778, + 722, + 778, + 600, + 600, + 600, + 600 + ], + n: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + o: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + p: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + q: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + r: [ + 389, + 389, + 333, + 333, + 444, + 389, + 389, + 333, + 600, + 600, + 600, + 600 + ], + s: [ + 556, + 556, + 500, + 500, + 389, + 389, + 389, + 389, + 600, + 600, + 600, + 600 + ], + t: [ + 333, + 333, + 278, + 278, + 333, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + u: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + v: [ + 556, + 556, + 500, + 500, + 500, + 444, + 444, + 500, + 600, + 600, + 600, + 600 + ], + w: [ + 778, + 778, + 722, + 722, + 722, + 667, + 667, + 722, + 600, + 600, + 600, + 600 + ], + x: [ + 556, + 556, + 500, + 500, + 500, + 500, + 444, + 500, + 600, + 600, + 600, + 600 + ], + y: [ + 556, + 556, + 500, + 500, + 500, + 444, + 444, + 500, + 600, + 600, + 600, + 600 + ], + z: [ + 500, + 500, + 500, + 500, + 444, + 389, + 389, + 444, + 600, + 600, + 600, + 600 + ], + braceleft: [ + 389, + 389, + 334, + 334, + 394, + 348, + 400, + 480, + 600, + 600, + 600, + 600 + ], + bar: [ + 280, + 280, + 260, + 260, + 220, + 220, + 275, + 200, + 600, + 600, + 600, + 600 + ], + braceright: [ + 389, + 389, + 334, + 334, + 394, + 348, + 400, + 480, + 600, + 600, + 600, + 600 + ], + asciitilde: [ + 584, + 584, + 584, + 584, + 520, + 570, + 541, + 541, + 600, + 600, + 600, + 600 + ], + exclamdown: [ + 333, + 333, + 333, + 333, + 333, + 389, + 389, + 333, + 600, + 600, + 600, + 600 + ], + cent: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + sterling: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + fraction: [ + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 600, + 600, + 600, + 600 + ], + yen: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + florin: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + section: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + currency: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + quotesingle: [ + 238, + 238, + 191, + 191, + 278, + 278, + 214, + 180, + 600, + 600, + 600, + 600 + ], + quotedblleft: [ + 500, + 500, + 333, + 333, + 500, + 500, + 556, + 444, + 600, + 600, + 600, + 600 + ], + guillemotleft: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + guilsinglleft: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + guilsinglright: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + fi: [ + 611, + 611, + 500, + 500, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + fl: [ + 611, + 611, + 500, + 500, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + endash: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + dagger: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + daggerdbl: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + periodcentered: [ + 278, + 278, + 278, + 278, + 250, + 250, + 250, + 250, + 600, + 600, + 600, + 600 + ], + paragraph: [ + 556, + 556, + 537, + 537, + 540, + 500, + 523, + 453, + 600, + 600, + 600, + 600 + ], + bullet: [ + 350, + 350, + 350, + 350, + 350, + 350, + 350, + 350, + 600, + 600, + 600, + 600 + ], + quotesinglbase: [ + 278, + 278, + 222, + 222, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + quotedblbase: [ + 500, + 500, + 333, + 333, + 500, + 500, + 556, + 444, + 600, + 600, + 600, + 600 + ], + quotedblright: [ + 500, + 500, + 333, + 333, + 500, + 500, + 556, + 444, + 600, + 600, + 600, + 600 + ], + guillemotright: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + ellipsis: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 889, + 1000, + 600, + 600, + 600, + 600 + ], + perthousand: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 600, + 600, + 600, + 600 + ], + questiondown: [ + 611, + 611, + 611, + 611, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + grave: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + acute: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + circumflex: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + tilde: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + macron: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + breve: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + dotaccent: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + dieresis: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + ring: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + cedilla: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + hungarumlaut: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + ogonek: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + caron: [ + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 333, + 600, + 600, + 600, + 600 + ], + emdash: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 889, + 1000, + 600, + 600, + 600, + 600 + ], + AE: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 944, + 889, + 889, + 600, + 600, + 600, + 600 + ], + ordfeminine: [ + 370, + 370, + 370, + 370, + 300, + 266, + 276, + 276, + 600, + 600, + 600, + 600 + ], + Lslash: [ + 611, + 611, + 556, + 556, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + Oslash: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + OE: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 944, + 944, + 889, + 600, + 600, + 600, + 600 + ], + ordmasculine: [ + 365, + 365, + 365, + 365, + 330, + 300, + 310, + 310, + 600, + 600, + 600, + 600 + ], + ae: [ + 889, + 889, + 889, + 889, + 722, + 722, + 667, + 667, + 600, + 600, + 600, + 600 + ], + dotlessi: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + lslash: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + oslash: [ + 611, + 611, + 611, + 611, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + oe: [ + 944, + 944, + 944, + 944, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + germandbls: [ + 611, + 611, + 611, + 611, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Idieresis: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + eacute: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + abreve: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + uhungarumlaut: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + ecaron: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + Ydieresis: [ + 667, + 667, + 667, + 667, + 722, + 611, + 556, + 722, + 600, + 600, + 600, + 600 + ], + divide: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + Yacute: [ + 667, + 667, + 667, + 667, + 722, + 611, + 556, + 722, + 600, + 600, + 600, + 600 + ], + Acircumflex: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + aacute: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Ucircumflex: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + yacute: [ + 556, + 556, + 500, + 500, + 500, + 444, + 444, + 500, + 600, + 600, + 600, + 600 + ], + scommaaccent: [ + 556, + 556, + 500, + 500, + 389, + 389, + 389, + 389, + 600, + 600, + 600, + 600 + ], + ecircumflex: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + Uring: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Udieresis: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + aogonek: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Uacute: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + uogonek: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Edieresis: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + Dcroat: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + commaaccent: [ + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 600, + 600, + 600, + 600 + ], + copyright: [ + 737, + 737, + 737, + 737, + 747, + 747, + 760, + 760, + 600, + 600, + 600, + 600 + ], + Emacron: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + ccaron: [ + 556, + 556, + 500, + 500, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + aring: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Ncommaaccent: [ + 722, + 722, + 722, + 722, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + lacute: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + agrave: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Tcommaaccent: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + Cacute: [ + 722, + 722, + 722, + 722, + 722, + 667, + 667, + 667, + 600, + 600, + 600, + 600 + ], + atilde: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Edotaccent: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + scaron: [ + 556, + 556, + 500, + 500, + 389, + 389, + 389, + 389, + 600, + 600, + 600, + 600 + ], + scedilla: [ + 556, + 556, + 500, + 500, + 389, + 389, + 389, + 389, + 600, + 600, + 600, + 600 + ], + iacute: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + lozenge: [ + 494, + 494, + 471, + 471, + 494, + 494, + 471, + 471, + 600, + 600, + 600, + 600 + ], + Rcaron: [ + 722, + 722, + 722, + 722, + 722, + 667, + 611, + 667, + 600, + 600, + 600, + 600 + ], + Gcommaaccent: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + ucircumflex: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + acircumflex: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + Amacron: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + rcaron: [ + 389, + 389, + 333, + 333, + 444, + 389, + 389, + 333, + 600, + 600, + 600, + 600 + ], + ccedilla: [ + 556, + 556, + 500, + 500, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + Zdotaccent: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + Thorn: [ + 667, + 667, + 667, + 667, + 611, + 611, + 611, + 556, + 600, + 600, + 600, + 600 + ], + Omacron: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Racute: [ + 722, + 722, + 722, + 722, + 722, + 667, + 611, + 667, + 600, + 600, + 600, + 600 + ], + Sacute: [ + 667, + 667, + 667, + 667, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + dcaron: [ + 743, + 743, + 643, + 643, + 672, + 608, + 544, + 588, + 600, + 600, + 600, + 600 + ], + Umacron: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + uring: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + threesuperior: [ + 333, + 333, + 333, + 333, + 300, + 300, + 300, + 300, + 600, + 600, + 600, + 600 + ], + Ograve: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Agrave: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Abreve: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + multiply: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + uacute: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Tcaron: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + partialdiff: [ + 494, + 494, + 476, + 476, + 494, + 494, + 476, + 476, + 600, + 600, + 600, + 600 + ], + ydieresis: [ + 556, + 556, + 500, + 500, + 500, + 444, + 444, + 500, + 600, + 600, + 600, + 600 + ], + Nacute: [ + 722, + 722, + 722, + 722, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + icircumflex: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + Ecircumflex: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + adieresis: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + edieresis: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + cacute: [ + 556, + 556, + 500, + 500, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + nacute: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + umacron: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Ncaron: [ + 722, + 722, + 722, + 722, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + Iacute: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + plusminus: [ + 584, + 584, + 584, + 584, + 570, + 570, + 675, + 564, + 600, + 600, + 600, + 600 + ], + brokenbar: [ + 280, + 280, + 260, + 260, + 220, + 220, + 275, + 200, + 600, + 600, + 600, + 600 + ], + registered: [ + 737, + 737, + 737, + 737, + 747, + 747, + 760, + 760, + 600, + 600, + 600, + 600 + ], + Gbreve: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Idotaccent: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + summation: [ + 600, + 600, + 600, + 600, + 600, + 600, + 600, + 600, + 600, + 600, + 600, + 600 + ], + Egrave: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + racute: [ + 389, + 389, + 333, + 333, + 444, + 389, + 389, + 333, + 600, + 600, + 600, + 600 + ], + omacron: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Zacute: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + Zcaron: [ + 611, + 611, + 611, + 611, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + greaterequal: [ + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 600, + 600, + 600, + 600 + ], + Eth: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Ccedilla: [ + 722, + 722, + 722, + 722, + 722, + 667, + 667, + 667, + 600, + 600, + 600, + 600 + ], + lcommaaccent: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + tcaron: [ + 389, + 389, + 317, + 317, + 416, + 366, + 300, + 326, + 600, + 600, + 600, + 600 + ], + eogonek: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + Uogonek: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Aacute: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Adieresis: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + egrave: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + zacute: [ + 500, + 500, + 500, + 500, + 444, + 389, + 389, + 444, + 600, + 600, + 600, + 600 + ], + iogonek: [ + 278, + 278, + 222, + 222, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + Oacute: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + oacute: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + amacron: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 444, + 600, + 600, + 600, + 600 + ], + sacute: [ + 556, + 556, + 500, + 500, + 389, + 389, + 389, + 389, + 600, + 600, + 600, + 600 + ], + idieresis: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + Ocircumflex: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Ugrave: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Delta: [ + 612, + 612, + 612, + 612, + 612, + 612, + 612, + 612, + 600, + 600, + 600, + 600 + ], + thorn: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + twosuperior: [ + 333, + 333, + 333, + 333, + 300, + 300, + 300, + 300, + 600, + 600, + 600, + 600 + ], + Odieresis: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + mu: [ + 611, + 611, + 556, + 556, + 556, + 576, + 500, + 500, + 600, + 600, + 600, + 600 + ], + igrave: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + ohungarumlaut: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Eogonek: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + dcroat: [ + 611, + 611, + 556, + 556, + 556, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + threequarters: [ + 834, + 834, + 834, + 834, + 750, + 750, + 750, + 750, + 600, + 600, + 600, + 600 + ], + Scedilla: [ + 667, + 667, + 667, + 667, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + lcaron: [ + 400, + 400, + 299, + 299, + 394, + 382, + 300, + 344, + 600, + 600, + 600, + 600 + ], + Kcommaaccent: [ + 722, + 722, + 667, + 667, + 778, + 667, + 667, + 722, + 600, + 600, + 600, + 600 + ], + Lacute: [ + 611, + 611, + 556, + 556, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + trademark: [ + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 980, + 980, + 600, + 600, + 600, + 600 + ], + edotaccent: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + Igrave: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + Imacron: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + Lcaron: [ + 611, + 611, + 556, + 556, + 667, + 611, + 611, + 611, + 600, + 600, + 600, + 600 + ], + onehalf: [ + 834, + 834, + 834, + 834, + 750, + 750, + 750, + 750, + 600, + 600, + 600, + 600 + ], + lessequal: [ + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 600, + 600, + 600, + 600 + ], + ocircumflex: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + ntilde: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Uhungarumlaut: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + Eacute: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + emacron: [ + 556, + 556, + 556, + 556, + 444, + 444, + 444, + 444, + 600, + 600, + 600, + 600 + ], + gbreve: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + onequarter: [ + 834, + 834, + 834, + 834, + 750, + 750, + 750, + 750, + 600, + 600, + 600, + 600 + ], + Scaron: [ + 667, + 667, + 667, + 667, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + Scommaaccent: [ + 667, + 667, + 667, + 667, + 556, + 556, + 500, + 556, + 600, + 600, + 600, + 600 + ], + Ohungarumlaut: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + degree: [ + 400, + 400, + 400, + 400, + 400, + 400, + 400, + 400, + 600, + 600, + 600, + 600 + ], + ograve: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Ccaron: [ + 722, + 722, + 722, + 722, + 722, + 667, + 667, + 667, + 600, + 600, + 600, + 600 + ], + ugrave: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + radical: [ + 549, + 549, + 453, + 453, + 549, + 549, + 453, + 453, + 600, + 600, + 600, + 600 + ], + Dcaron: [ + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + rcommaaccent: [ + 389, + 389, + 333, + 333, + 444, + 389, + 389, + 333, + 600, + 600, + 600, + 600 + ], + Ntilde: [ + 722, + 722, + 722, + 722, + 722, + 722, + 667, + 722, + 600, + 600, + 600, + 600 + ], + otilde: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + Rcommaaccent: [ + 722, + 722, + 722, + 722, + 722, + 667, + 611, + 667, + 600, + 600, + 600, + 600 + ], + Lcommaaccent: [ + 611, + 611, + 556, + 556, + 667, + 611, + 556, + 611, + 600, + 600, + 600, + 600 + ], + Atilde: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Aogonek: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Aring: [ + 722, + 722, + 667, + 667, + 722, + 667, + 611, + 722, + 600, + 600, + 600, + 600 + ], + Otilde: [ + 778, + 778, + 778, + 778, + 778, + 722, + 722, + 722, + 600, + 600, + 600, + 600 + ], + zdotaccent: [ + 500, + 500, + 500, + 500, + 444, + 389, + 389, + 444, + 600, + 600, + 600, + 600 + ], + Ecaron: [ + 667, + 667, + 667, + 667, + 667, + 667, + 611, + 611, + 600, + 600, + 600, + 600 + ], + Iogonek: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + kcommaaccent: [ + 556, + 556, + 500, + 500, + 556, + 500, + 444, + 500, + 600, + 600, + 600, + 600 + ], + minus: [ + 584, + 584, + 584, + 584, + 570, + 606, + 675, + 564, + 600, + 600, + 600, + 600 + ], + Icircumflex: [ + 278, + 278, + 278, + 278, + 389, + 389, + 333, + 333, + 600, + 600, + 600, + 600 + ], + ncaron: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + tcommaaccent: [ + 333, + 333, + 278, + 278, + 333, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + logicalnot: [ + 584, + 584, + 584, + 584, + 570, + 606, + 675, + 564, + 600, + 600, + 600, + 600 + ], + odieresis: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + udieresis: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + notequal: [ + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 549, + 600, + 600, + 600, + 600 + ], + gcommaaccent: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + eth: [ + 611, + 611, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ], + zcaron: [ + 500, + 500, + 500, + 500, + 444, + 389, + 389, + 444, + 600, + 600, + 600, + 600 + ], + ncommaaccent: [ + 611, + 611, + 556, + 556, + 556, + 556, + 500, + 500, + 600, + 600, + 600, + 600 + ], + onesuperior: [ + 333, + 333, + 333, + 333, + 300, + 300, + 300, + 300, + 600, + 600, + 600, + 600 + ], + imacron: [ + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 278, + 600, + 600, + 600, + 600 + ], + Euro: [ + 556, + 556, + 556, + 556, + 500, + 500, + 500, + 500, + 600, + 600, + 600, + 600 + ] +}; +var kernPairs = { + AC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + ACacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + ACcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + ACcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + ATcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + ATcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Au: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Auacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Audieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Augrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Auhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Auogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Auring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Av: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Aw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Ay: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Ayacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Aydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AacuteC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AacuteCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AacuteCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AacuteCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AacuteG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AacuteGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AacuteGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AacuteO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AacuteQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AacuteT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AacuteTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AacuteTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AacuteU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AacuteV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AacuteW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AacuteY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AacuteYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AacuteYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Aacuteu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacuteuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aacutev: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Aacutew: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Aacutey: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Aacuteyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Aacuteydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AbreveC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AbreveCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AbreveCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AbreveCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AbreveG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AbreveGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AbreveGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AbreveO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AbreveQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AbreveT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AbreveTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AbreveTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AbreveU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AbreveV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AbreveW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AbreveY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AbreveYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AbreveYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Abreveu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abreveuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Abrevev: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Abrevew: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Abrevey: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Abreveyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Abreveydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AcircumflexC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AcircumflexCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AcircumflexCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AcircumflexCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AcircumflexG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AcircumflexGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AcircumflexGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AcircumflexO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AcircumflexQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AcircumflexT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AcircumflexTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AcircumflexTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AcircumflexU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AcircumflexV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AcircumflexW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AcircumflexY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AcircumflexYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AcircumflexYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Acircumflexu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Acircumflexv: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Acircumflexw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Acircumflexy: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Acircumflexyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Acircumflexydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AdieresisC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AdieresisCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AdieresisCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AdieresisCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AdieresisG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AdieresisGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AdieresisGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AdieresisO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AdieresisQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AdieresisT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AdieresisTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AdieresisTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AdieresisU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AdieresisV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AdieresisW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AdieresisY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AdieresisYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AdieresisYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Adieresisu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Adieresisv: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Adieresisw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Adieresisy: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Adieresisyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Adieresisydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AgraveC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AgraveCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AgraveCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AgraveCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AgraveG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AgraveGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AgraveGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AgraveO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AgraveQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AgraveT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AgraveTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AgraveTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AgraveU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AgraveV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AgraveW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AgraveY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AgraveYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AgraveYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Agraveu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agraveuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Agravev: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Agravew: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Agravey: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Agraveyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Agraveydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AmacronC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AmacronCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AmacronCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AmacronCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AmacronG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AmacronGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AmacronGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AmacronO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AmacronQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AmacronT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AmacronTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AmacronTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AmacronU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AmacronV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AmacronW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AmacronY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AmacronYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AmacronYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Amacronu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Amacronv: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Amacronw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Amacrony: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Amacronyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Amacronydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AogonekC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AogonekCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AogonekCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AogonekCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AogonekG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AogonekGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AogonekGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AogonekO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AogonekQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AogonekT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AogonekTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AogonekTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AogonekU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AogonekV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AogonekW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AogonekY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AogonekYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AogonekYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Aogoneku: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aogonekv: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Aogonekw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -52 + ], + Aogoneky: [ + -30, + -30, + -40, + -40, + -34, + -34, + -55, + -52 + ], + Aogonekyacute: [ + -30, + -30, + -40, + -40, + -34, + -34, + -55, + -52 + ], + Aogonekydieresis: [ + -30, + -30, + -40, + -40, + -34, + -34, + -55, + -52 + ], + AringC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AringCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AringCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AringCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AringG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AringGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AringGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AringO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AringQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AringT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AringTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AringTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AringU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AringV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AringW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AringY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AringYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AringYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Aringu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Aringv: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Aringw: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Aringy: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Aringyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Aringydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + AtildeC: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AtildeCacute: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AtildeCcaron: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AtildeCcedilla: [ + -40, + -40, + -30, + -30, + -55, + -65, + -30, + -40 + ], + AtildeG: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AtildeGbreve: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AtildeGcommaaccent: [ + -50, + -50, + -30, + -30, + -55, + -60, + -35, + -40 + ], + AtildeO: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOacute: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOcircumflex: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOdieresis: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOgrave: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOhungarumlaut: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOmacron: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOslash: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeOtilde: [ + -40, + -40, + -30, + -30, + -45, + -50, + -40, + -55 + ], + AtildeQ: [ + -40, + -40, + -30, + -30, + -45, + -55, + -40, + -55 + ], + AtildeT: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AtildeTcaron: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AtildeTcommaaccent: [ + -90, + -90, + -120, + -120, + -95, + -55, + -37, + -111 + ], + AtildeU: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUacute: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUcircumflex: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUdieresis: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUgrave: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUhungarumlaut: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUmacron: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUogonek: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeUring: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -55 + ], + AtildeV: [ + -80, + -80, + -70, + -70, + -145, + -95, + -105, + -135 + ], + AtildeW: [ + -60, + -60, + -50, + -50, + -130, + -100, + -95, + -90 + ], + AtildeY: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AtildeYacute: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + AtildeYdieresis: [ + -110, + -110, + -100, + -100, + -100, + -70, + -55, + -105 + ], + Atildeu: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeuacute: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeucircumflex: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeudieresis: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeugrave: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeuhungarumlaut: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeumacron: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeuogonek: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildeuring: [ + -30, + -30, + -30, + -30, + -50, + -30, + -20 + ], + Atildev: [ + -40, + -40, + -40, + -40, + -100, + -74, + -55, + -74 + ], + Atildew: [ + -30, + -30, + -40, + -40, + -90, + -74, + -55, + -92 + ], + Atildey: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Atildeyacute: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + Atildeydieresis: [ + -30, + -30, + -40, + -40, + -74, + -74, + -55, + -92 + ], + BA: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAacute: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAbreve: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAcircumflex: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAdieresis: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAgrave: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAmacron: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAogonek: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAring: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BAtilde: [ + -30, + -30, + 0, + 0, + -30, + -25, + -25, + -35 + ], + BU: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUacute: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUcircumflex: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUdieresis: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUgrave: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUhungarumlaut: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUmacron: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUogonek: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + BUring: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + DA: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAacute: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAbreve: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAcircumflex: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAdieresis: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAgrave: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAmacron: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAogonek: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAring: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DAtilde: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DV: [ + -40, + -40, + -70, + -70, + -40, + -50, + -40, + -40 + ], + DW: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -30 + ], + DY: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DYacute: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DYdieresis: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + Dcomma: [ + -30, + -30, + -70, + -70 + ], + Dperiod: [ + -30, + -30, + -70, + -70, + -20 + ], + DcaronA: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAacute: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAbreve: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAcircumflex: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAdieresis: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAgrave: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAmacron: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAogonek: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAring: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronAtilde: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcaronV: [ + -40, + -40, + -70, + -70, + -40, + -50, + -40, + -40 + ], + DcaronW: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -30 + ], + DcaronY: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DcaronYacute: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DcaronYdieresis: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + Dcaroncomma: [ + -30, + -30, + -70, + -70 + ], + Dcaronperiod: [ + -30, + -30, + -70, + -70, + -20 + ], + DcroatA: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAacute: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAbreve: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAcircumflex: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAdieresis: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAgrave: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAmacron: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAogonek: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAring: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatAtilde: [ + -40, + -40, + -40, + -40, + -35, + -25, + -35, + -40 + ], + DcroatV: [ + -40, + -40, + -70, + -70, + -40, + -50, + -40, + -40 + ], + DcroatW: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -30 + ], + DcroatY: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DcroatYacute: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + DcroatYdieresis: [ + -70, + -70, + -90, + -90, + -40, + -50, + -40, + -55 + ], + Dcroatcomma: [ + -30, + -30, + -70, + -70 + ], + Dcroatperiod: [ + -30, + -30, + -70, + -70, + -20 + ], + FA: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAacute: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAbreve: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAcircumflex: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAdieresis: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAgrave: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAmacron: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAogonek: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAring: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + FAtilde: [ + -80, + -80, + -80, + -80, + -90, + -100, + -115, + -74 + ], + Fa: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Faacute: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Fabreve: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Facircumflex: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Fadieresis: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Fagrave: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Famacron: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Faogonek: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Faring: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Fatilde: [ + -20, + -20, + -50, + -50, + -25, + -95, + -75, + -15 + ], + Fcomma: [ + -100, + -100, + -150, + -150, + -92, + -129, + -135, + -80 + ], + Fperiod: [ + -100, + -100, + -150, + -150, + -110, + -129, + -135, + -80 + ], + JA: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAacute: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAbreve: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAcircumflex: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAdieresis: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAgrave: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAmacron: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAogonek: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAring: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + JAtilde: [ + -20, + -20, + -20, + -20, + -30, + -25, + -40, + -60 + ], + Jcomma: [ + -20, + -20, + -30, + -30, + 0, + -10, + -25 + ], + Jperiod: [ + -20, + -20, + -30, + -30, + -20, + -10, + -25 + ], + Ju: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Juacute: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Jucircumflex: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Judieresis: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Jugrave: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Juhungarumlaut: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Jumacron: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Juogonek: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + Juring: [ + -20, + -20, + -20, + -20, + -15, + -40, + -35 + ], + KO: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOacute: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOcircumflex: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOdieresis: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOgrave: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOhungarumlaut: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOmacron: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOslash: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KOtilde: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + Ke: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Keacute: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kecaron: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kecircumflex: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kedieresis: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kedotaccent: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kegrave: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kemacron: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Keogonek: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Ko: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Koacute: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kocircumflex: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kodieresis: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kograve: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kohungarumlaut: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Komacron: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Koslash: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kotilde: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Ku: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kuacute: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kucircumflex: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kudieresis: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kugrave: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kuhungarumlaut: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kumacron: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kuogonek: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kuring: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Ky: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + Kyacute: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + Kydieresis: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + KcommaaccentO: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOacute: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOcircumflex: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOdieresis: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOgrave: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOhungarumlaut: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOmacron: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOslash: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + KcommaaccentOtilde: [ + -30, + -30, + -50, + -50, + -30, + -30, + -50, + -30 + ], + Kcommaaccente: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccenteacute: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentecaron: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentecircumflex: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentedieresis: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentedotaccent: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentegrave: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccentemacron: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccenteogonek: [ + -15, + -15, + -40, + -40, + -25, + -25, + -35, + -25 + ], + Kcommaaccento: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentoacute: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentocircumflex: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentodieresis: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentograve: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentohungarumlaut: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentomacron: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentoslash: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentotilde: [ + -35, + -35, + -40, + -40, + -25, + -25, + -40, + -35 + ], + Kcommaaccentu: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentuacute: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentucircumflex: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentudieresis: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentugrave: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentuhungarumlaut: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentumacron: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccentuogonek: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccenturing: [ + -30, + -30, + -30, + -30, + -15, + -20, + -40, + -15 + ], + Kcommaaccenty: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + Kcommaaccentyacute: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + Kcommaaccentydieresis: [ + -40, + -40, + -50, + -50, + -45, + -20, + -40, + -25 + ], + LT: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LTcaron: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LTcommaaccent: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LV: [ + -110, + -110, + -110, + -110, + -92, + -37, + -55, + -100 + ], + LW: [ + -80, + -80, + -70, + -70, + -92, + -37, + -55, + -74 + ], + LY: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LYacute: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LYdieresis: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + Lquotedblright: [ + -140, + -140, + -140, + -140, + -20 + ], + Lquoteright: [ + -140, + -140, + -160, + -160, + -110, + -55, + -37, + -92 + ], + Ly: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lyacute: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lydieresis: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + LacuteT: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LacuteTcaron: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LacuteTcommaaccent: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LacuteV: [ + -110, + -110, + -110, + -110, + -92, + -37, + -55, + -100 + ], + LacuteW: [ + -80, + -80, + -70, + -70, + -92, + -37, + -55, + -74 + ], + LacuteY: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LacuteYacute: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LacuteYdieresis: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + Lacutequotedblright: [ + -140, + -140, + -140, + -140, + -20 + ], + Lacutequoteright: [ + -140, + -140, + -160, + -160, + -110, + -55, + -37, + -92 + ], + Lacutey: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lacuteyacute: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lacuteydieresis: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + LcommaaccentT: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LcommaaccentTcaron: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LcommaaccentTcommaaccent: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LcommaaccentV: [ + -110, + -110, + -110, + -110, + -92, + -37, + -55, + -100 + ], + LcommaaccentW: [ + -80, + -80, + -70, + -70, + -92, + -37, + -55, + -74 + ], + LcommaaccentY: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LcommaaccentYacute: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LcommaaccentYdieresis: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + Lcommaaccentquotedblright: [ + -140, + -140, + -140, + -140, + -20 + ], + Lcommaaccentquoteright: [ + -140, + -140, + -160, + -160, + -110, + -55, + -37, + -92 + ], + Lcommaaccenty: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lcommaaccentyacute: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lcommaaccentydieresis: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + LslashT: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LslashTcaron: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LslashTcommaaccent: [ + -90, + -90, + -110, + -110, + -92, + -18, + -20, + -92 + ], + LslashV: [ + -110, + -110, + -110, + -110, + -92, + -37, + -55, + -100 + ], + LslashW: [ + -80, + -80, + -70, + -70, + -92, + -37, + -55, + -74 + ], + LslashY: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LslashYacute: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + LslashYdieresis: [ + -120, + -120, + -140, + -140, + -92, + -37, + -20, + -100 + ], + Lslashquotedblright: [ + -140, + -140, + -140, + -140, + -20 + ], + Lslashquoteright: [ + -140, + -140, + -160, + -160, + -110, + -55, + -37, + -92 + ], + Lslashy: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lslashyacute: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + Lslashydieresis: [ + -30, + -30, + -30, + -30, + -55, + -37, + -30, + -55 + ], + OA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Ocomma: [ + -40, + -40, + -40, + -40 + ], + Operiod: [ + -40, + -40, + -40, + -40 + ], + OacuteA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OacuteT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OacuteTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OacuteTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OacuteV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OacuteW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OacuteX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OacuteY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OacuteYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OacuteYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Oacutecomma: [ + -40, + -40, + -40, + -40 + ], + Oacuteperiod: [ + -40, + -40, + -40, + -40 + ], + OcircumflexA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OcircumflexT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OcircumflexTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OcircumflexTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OcircumflexV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OcircumflexW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OcircumflexX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OcircumflexY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OcircumflexYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OcircumflexYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Ocircumflexcomma: [ + -40, + -40, + -40, + -40 + ], + Ocircumflexperiod: [ + -40, + -40, + -40, + -40 + ], + OdieresisA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OdieresisT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OdieresisTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OdieresisTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OdieresisV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OdieresisW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OdieresisX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OdieresisY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OdieresisYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OdieresisYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Odieresiscomma: [ + -40, + -40, + -40, + -40 + ], + Odieresisperiod: [ + -40, + -40, + -40, + -40 + ], + OgraveA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OgraveT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OgraveTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OgraveTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OgraveV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OgraveW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OgraveX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OgraveY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OgraveYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OgraveYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Ogravecomma: [ + -40, + -40, + -40, + -40 + ], + Ograveperiod: [ + -40, + -40, + -40, + -40 + ], + OhungarumlautA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OhungarumlautT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OhungarumlautTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OhungarumlautTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OhungarumlautV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OhungarumlautW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OhungarumlautX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OhungarumlautY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OhungarumlautYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OhungarumlautYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Ohungarumlautcomma: [ + -40, + -40, + -40, + -40 + ], + Ohungarumlautperiod: [ + -40, + -40, + -40, + -40 + ], + OmacronA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OmacronT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OmacronTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OmacronTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OmacronV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OmacronW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OmacronX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OmacronY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OmacronYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OmacronYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Omacroncomma: [ + -40, + -40, + -40, + -40 + ], + Omacronperiod: [ + -40, + -40, + -40, + -40 + ], + OslashA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OslashT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OslashTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OslashTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OslashV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OslashW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OslashX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OslashY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OslashYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OslashYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Oslashcomma: [ + -40, + -40, + -40, + -40 + ], + Oslashperiod: [ + -40, + -40, + -40, + -40 + ], + OtildeA: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAacute: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAbreve: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAcircumflex: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAdieresis: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAgrave: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAmacron: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAogonek: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAring: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeAtilde: [ + -50, + -50, + -20, + -20, + -40, + -40, + -55, + -35 + ], + OtildeT: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OtildeTcaron: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OtildeTcommaaccent: [ + -40, + -40, + -40, + -40, + -40, + -40, + -40, + -40 + ], + OtildeV: [ + -50, + -50, + -50, + -50, + -50, + -50, + -50, + -50 + ], + OtildeW: [ + -50, + -50, + -30, + -30, + -50, + -50, + -50, + -35 + ], + OtildeX: [ + -50, + -50, + -60, + -60, + -40, + -40, + -40, + -40 + ], + OtildeY: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OtildeYacute: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + OtildeYdieresis: [ + -70, + -70, + -70, + -70, + -50, + -50, + -50, + -50 + ], + Otildecomma: [ + -40, + -40, + -40, + -40 + ], + Otildeperiod: [ + -40, + -40, + -40, + -40 + ], + PA: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAacute: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAbreve: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAcircumflex: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAdieresis: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAgrave: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAmacron: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAogonek: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAring: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + PAtilde: [ + -100, + -100, + -120, + -120, + -74, + -85, + -90, + -92 + ], + Pa: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Paacute: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Pabreve: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Pacircumflex: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Padieresis: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Pagrave: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Pamacron: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Paogonek: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Paring: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Patilde: [ + -30, + -30, + -40, + -40, + -10, + -40, + -80, + -15 + ], + Pcomma: [ + -120, + -120, + -180, + -180, + -92, + -129, + -135, + -111 + ], + Pe: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Peacute: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pecaron: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pecircumflex: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pedieresis: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pedotaccent: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pegrave: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Pemacron: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Peogonek: [ + -30, + -30, + -50, + -50, + -20, + -50, + -80 + ], + Po: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Poacute: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Pocircumflex: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Podieresis: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Pograve: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Pohungarumlaut: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Pomacron: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Poslash: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Potilde: [ + -40, + -40, + -50, + -50, + -20, + -55, + -80 + ], + Pperiod: [ + -120, + -120, + -180, + -180, + -110, + -129, + -135, + -111 + ], + QU: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUacute: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUcircumflex: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUdieresis: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUgrave: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUhungarumlaut: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUmacron: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUogonek: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + QUring: [ + -10, + -10, + -10, + -10, + -10, + -10, + -10, + -10 + ], + Qcomma: [ + 20, + 20 + ], + Qperiod: [ + 20, + 20, + 0, + 0, + -20 + ], + RO: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROacute: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROcircumflex: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROdieresis: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROgrave: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROhungarumlaut: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROmacron: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROslash: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + ROtilde: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RT: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RTcaron: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RTcommaaccent: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RU: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUacute: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUcircumflex: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUdieresis: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUgrave: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUhungarumlaut: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUmacron: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUogonek: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RUring: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RV: [ + -50, + -50, + -50, + -50, + -55, + -18, + -18, + -80 + ], + RW: [ + -40, + -40, + -30, + -30, + -35, + -18, + -18, + -55 + ], + RY: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RYacute: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RYdieresis: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RacuteO: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOacute: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOcircumflex: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOdieresis: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOgrave: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOhungarumlaut: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOmacron: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOslash: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteOtilde: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RacuteT: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RacuteTcaron: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RacuteTcommaaccent: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RacuteU: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUacute: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUcircumflex: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUdieresis: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUgrave: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUhungarumlaut: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUmacron: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUogonek: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteUring: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RacuteV: [ + -50, + -50, + -50, + -50, + -55, + -18, + -18, + -80 + ], + RacuteW: [ + -40, + -40, + -30, + -30, + -35, + -18, + -18, + -55 + ], + RacuteY: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RacuteYacute: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RacuteYdieresis: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcaronO: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOacute: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOcircumflex: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOdieresis: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOgrave: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOhungarumlaut: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOmacron: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOslash: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronOtilde: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcaronT: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcaronTcaron: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcaronTcommaaccent: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcaronU: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUacute: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUcircumflex: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUdieresis: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUgrave: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUhungarumlaut: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUmacron: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUogonek: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronUring: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcaronV: [ + -50, + -50, + -50, + -50, + -55, + -18, + -18, + -80 + ], + RcaronW: [ + -40, + -40, + -30, + -30, + -35, + -18, + -18, + -55 + ], + RcaronY: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcaronYacute: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcaronYdieresis: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcommaaccentO: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOacute: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOcircumflex: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOdieresis: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOgrave: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOhungarumlaut: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOmacron: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOslash: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentOtilde: [ + -20, + -20, + -20, + -20, + -30, + -40, + -40, + -40 + ], + RcommaaccentT: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcommaaccentTcaron: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcommaaccentTcommaaccent: [ + -20, + -20, + -30, + -30, + -40, + -30, + 0, + -60 + ], + RcommaaccentU: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUacute: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUcircumflex: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUdieresis: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUgrave: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUhungarumlaut: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUmacron: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUogonek: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentUring: [ + -20, + -20, + -40, + -40, + -30, + -40, + -40, + -40 + ], + RcommaaccentV: [ + -50, + -50, + -50, + -50, + -55, + -18, + -18, + -80 + ], + RcommaaccentW: [ + -40, + -40, + -30, + -30, + -35, + -18, + -18, + -55 + ], + RcommaaccentY: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcommaaccentYacute: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + RcommaaccentYdieresis: [ + -50, + -50, + -50, + -50, + -35, + -18, + -18, + -65 + ], + TA: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAacute: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAbreve: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAcircumflex: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAdieresis: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAgrave: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAmacron: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAogonek: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAring: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TAtilde: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TO: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOacute: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOcircumflex: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOdieresis: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOgrave: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOhungarumlaut: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOmacron: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOslash: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TOtilde: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + Ta: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Taacute: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tabreve: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -80 + ], + Tacircumflex: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -80 + ], + Tadieresis: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tagrave: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tamacron: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Taogonek: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Taring: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tatilde: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Tcolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -55, + -50 + ], + Tcomma: [ + -80, + -80, + -120, + -120, + -74, + -92, + -74, + -74 + ], + Te: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Teacute: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tecaron: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tecircumflex: [ + -60, + -60, + -120, + -120, + -92, + -92, + -52, + -70 + ], + Tedieresis: [ + -60, + -60, + -120, + -120, + -52, + -52, + -52, + -30 + ], + Tedotaccent: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tegrave: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -70 + ], + Temacron: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -30 + ], + Teogonek: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Thyphen: [ + -120, + -120, + -140, + -140, + -92, + -92, + -74, + -92 + ], + To: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Toacute: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tocircumflex: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Todieresis: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tograve: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tohungarumlaut: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tomacron: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Toslash: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Totilde: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Tperiod: [ + -80, + -80, + -120, + -120, + -90, + -92, + -74, + -74 + ], + Tr: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tracute: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Trcommaaccent: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tsemicolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -65, + -55 + ], + Tu: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tuacute: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tucircumflex: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tudieresis: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tugrave: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tuhungarumlaut: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tumacron: [ + -90, + -90, + -60, + -60, + -92, + -37, + -55, + -45 + ], + Tuogonek: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Turing: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tw: [ + -60, + -60, + -120, + -120, + -74, + -37, + -74, + -80 + ], + Ty: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tyacute: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tydieresis: [ + -60, + -60, + -60, + -60, + -34, + -37, + -34, + -80 + ], + TcaronA: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAacute: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAbreve: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAcircumflex: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAdieresis: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAgrave: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAmacron: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAogonek: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAring: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronAtilde: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcaronO: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOacute: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOcircumflex: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOdieresis: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOgrave: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOhungarumlaut: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOmacron: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOslash: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcaronOtilde: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + Tcarona: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcaronaacute: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcaronabreve: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -80 + ], + Tcaronacircumflex: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -80 + ], + Tcaronadieresis: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tcaronagrave: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tcaronamacron: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Tcaronaogonek: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcaronaring: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcaronatilde: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Tcaroncolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -55, + -50 + ], + Tcaroncomma: [ + -80, + -80, + -120, + -120, + -74, + -92, + -74, + -74 + ], + Tcarone: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcaroneacute: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcaronecaron: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcaronecircumflex: [ + -60, + -60, + -120, + -120, + -92, + -92, + -52, + -30 + ], + Tcaronedieresis: [ + -60, + -60, + -120, + -120, + -52, + -52, + -52, + -30 + ], + Tcaronedotaccent: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcaronegrave: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -70 + ], + Tcaronemacron: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -30 + ], + Tcaroneogonek: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcaronhyphen: [ + -120, + -120, + -140, + -140, + -92, + -92, + -74, + -92 + ], + Tcarono: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronoacute: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronocircumflex: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronodieresis: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronograve: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronohungarumlaut: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronomacron: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Tcaronoslash: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcaronotilde: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Tcaronperiod: [ + -80, + -80, + -120, + -120, + -90, + -92, + -74, + -74 + ], + Tcaronr: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcaronracute: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcaronrcommaaccent: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcaronsemicolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -65, + -55 + ], + Tcaronu: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronuacute: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronucircumflex: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronudieresis: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronugrave: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronuhungarumlaut: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronumacron: [ + -90, + -90, + -60, + -60, + -92, + -37, + -55, + -45 + ], + Tcaronuogonek: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronuring: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcaronw: [ + -60, + -60, + -120, + -120, + -74, + -37, + -74, + -80 + ], + Tcarony: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tcaronyacute: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tcaronydieresis: [ + -60, + -60, + -60, + -60, + -34, + -37, + -34, + -80 + ], + TcommaaccentA: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAacute: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAbreve: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAcircumflex: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAdieresis: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAgrave: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAmacron: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAogonek: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAring: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentAtilde: [ + -90, + -90, + -120, + -120, + -90, + -55, + -50, + -93 + ], + TcommaaccentO: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOacute: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOcircumflex: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOdieresis: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOgrave: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOhungarumlaut: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOmacron: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOslash: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + TcommaaccentOtilde: [ + -40, + -40, + -40, + -40, + -18, + -18, + -18, + -18 + ], + Tcommaaccenta: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcommaaccentaacute: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcommaaccentabreve: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -80 + ], + Tcommaaccentacircumflex: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -80 + ], + Tcommaaccentadieresis: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tcommaaccentagrave: [ + -80, + -80, + -120, + -120, + -52, + -92, + -92, + -40 + ], + Tcommaaccentamacron: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Tcommaaccentaogonek: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcommaaccentaring: [ + -80, + -80, + -120, + -120, + -92, + -92, + -92, + -80 + ], + Tcommaaccentatilde: [ + -80, + -80, + -60, + -60, + -52, + -92, + -92, + -40 + ], + Tcommaaccentcolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -55, + -50 + ], + Tcommaaccentcomma: [ + -80, + -80, + -120, + -120, + -74, + -92, + -74, + -74 + ], + Tcommaaccente: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcommaaccenteacute: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcommaaccentecaron: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcommaaccentecircumflex: [ + -60, + -60, + -120, + -120, + -92, + -92, + -52, + -30 + ], + Tcommaaccentedieresis: [ + -60, + -60, + -120, + -120, + -52, + -52, + -52, + -30 + ], + Tcommaaccentedotaccent: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcommaaccentegrave: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -30 + ], + Tcommaaccentemacron: [ + -60, + -60, + -60, + -60, + -52, + -52, + -52, + -70 + ], + Tcommaaccenteogonek: [ + -60, + -60, + -120, + -120, + -92, + -92, + -92, + -70 + ], + Tcommaaccenthyphen: [ + -120, + -120, + -140, + -140, + -92, + -92, + -74, + -92 + ], + Tcommaaccento: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentoacute: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentocircumflex: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentodieresis: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentograve: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentohungarumlaut: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentomacron: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Tcommaaccentoslash: [ + -80, + -80, + -120, + -120, + -92, + -95, + -92, + -80 + ], + Tcommaaccentotilde: [ + -80, + -80, + -60, + -60, + -92, + -95, + -92, + -80 + ], + Tcommaaccentperiod: [ + -80, + -80, + -120, + -120, + -90, + -92, + -74, + -74 + ], + Tcommaaccentr: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcommaaccentracute: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcommaaccentrcommaaccent: [ + -80, + -80, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcommaaccentsemicolon: [ + -40, + -40, + -20, + -20, + -74, + -74, + -65, + -55 + ], + Tcommaaccentu: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentuacute: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentucircumflex: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentudieresis: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentugrave: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentuhungarumlaut: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentumacron: [ + -90, + -90, + -60, + -60, + -92, + -37, + -55, + -45 + ], + Tcommaaccentuogonek: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccenturing: [ + -90, + -90, + -120, + -120, + -92, + -37, + -55, + -45 + ], + Tcommaaccentw: [ + -60, + -60, + -120, + -120, + -74, + -37, + -74, + -80 + ], + Tcommaaccenty: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tcommaaccentyacute: [ + -60, + -60, + -120, + -120, + -34, + -37, + -74, + -80 + ], + Tcommaaccentydieresis: [ + -60, + -60, + -60, + -60, + -34, + -37, + -34, + -80 + ], + UA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Ucomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Uperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UacuteA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UacuteAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Uacutecomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Uacuteperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UcircumflexA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UcircumflexAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Ucircumflexcomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Ucircumflexperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UdieresisA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UdieresisAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Udieresiscomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Udieresisperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UgraveA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UgraveAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Ugravecomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Ugraveperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UhungarumlautA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UhungarumlautAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Uhungarumlautcomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Uhungarumlautperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UmacronA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UmacronAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Umacroncomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Umacronperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UogonekA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UogonekAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Uogonekcomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Uogonekperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + UringA: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAacute: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAbreve: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAcircumflex: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAdieresis: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAgrave: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAmacron: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAogonek: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAring: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + UringAtilde: [ + -50, + -50, + -40, + -40, + -60, + -45, + -40, + -40 + ], + Uringcomma: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + Uringperiod: [ + -30, + -30, + -40, + -40, + -50, + 0, + -25 + ], + VA: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAacute: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAbreve: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAcircumflex: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAdieresis: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAgrave: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAmacron: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAogonek: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAring: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VAtilde: [ + -80, + -80, + -80, + -80, + -135, + -85, + -60, + -135 + ], + VG: [ + -50, + -50, + -40, + -40, + -30, + -10, + 0, + -15 + ], + VGbreve: [ + -50, + -50, + -40, + -40, + -30, + -10, + 0, + -15 + ], + VGcommaaccent: [ + -50, + -50, + -40, + -40, + -30, + -10, + 0, + -15 + ], + VO: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOacute: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOcircumflex: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOdieresis: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOgrave: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOhungarumlaut: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOmacron: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOslash: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + VOtilde: [ + -50, + -50, + -40, + -40, + -45, + -30, + -30, + -40 + ], + Va: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -111 + ], + Vaacute: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -111 + ], + Vabreve: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -111 + ], + Vacircumflex: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -71 + ], + Vadieresis: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -71 + ], + Vagrave: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -71 + ], + Vamacron: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -71 + ], + Vaogonek: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -111 + ], + Varing: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -111 + ], + Vatilde: [ + -60, + -60, + -70, + -70, + -92, + -111, + -111, + -71 + ], + Vcolon: [ + -40, + -40, + -40, + -40, + -92, + -74, + -65, + -74 + ], + Vcomma: [ + -120, + -120, + -125, + -125, + -129, + -129, + -129, + -129 + ], + Ve: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -111 + ], + Veacute: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -111 + ], + Vecaron: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -71 + ], + Vecircumflex: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -71 + ], + Vedieresis: [ + -50, + -50, + -80, + -80, + -100, + -71, + -71, + -71 + ], + Vedotaccent: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -111 + ], + Vegrave: [ + -50, + -50, + -80, + -80, + -100, + -71, + -71, + -71 + ], + Vemacron: [ + -50, + -50, + -80, + -80, + -100, + -71, + -71, + -71 + ], + Veogonek: [ + -50, + -50, + -80, + -80, + -100, + -111, + -111, + -111 + ], + Vhyphen: [ + -80, + -80, + -80, + -80, + -74, + -70, + -55, + -100 + ], + Vo: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -129 + ], + Voacute: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -129 + ], + Vocircumflex: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -129 + ], + Vodieresis: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -89 + ], + Vograve: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -89 + ], + Vohungarumlaut: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -129 + ], + Vomacron: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -89 + ], + Voslash: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -129 + ], + Votilde: [ + -90, + -90, + -80, + -80, + -100, + -111, + -111, + -89 + ], + Vperiod: [ + -120, + -120, + -125, + -125, + -145, + -129, + -129, + -129 + ], + Vsemicolon: [ + -40, + -40, + -40, + -40, + -92, + -74, + -74, + -74 + ], + Vu: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vuacute: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vucircumflex: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vudieresis: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vugrave: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vuhungarumlaut: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vumacron: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vuogonek: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + Vuring: [ + -60, + -60, + -70, + -70, + -92, + -55, + -74, + -75 + ], + WA: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAacute: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAbreve: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAcircumflex: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAdieresis: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAgrave: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAmacron: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAogonek: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAring: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WAtilde: [ + -60, + -60, + -50, + -50, + -120, + -74, + -60, + -120 + ], + WO: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOacute: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOcircumflex: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOdieresis: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOgrave: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOhungarumlaut: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOmacron: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOslash: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + WOtilde: [ + -20, + -20, + -20, + -20, + -10, + -15, + -25, + -10 + ], + Wa: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Waacute: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wabreve: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wacircumflex: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wadieresis: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wagrave: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wamacron: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Waogonek: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Waring: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Watilde: [ + -40, + -40, + -40, + -40, + -65, + -85, + -92, + -80 + ], + Wcolon: [ + -10, + -10, + 0, + 0, + -55, + -55, + -65, + -37 + ], + Wcomma: [ + -80, + -80, + -80, + -80, + -92, + -74, + -92, + -92 + ], + We: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Weacute: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Wecaron: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Wecircumflex: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Wedieresis: [ + -35, + -35, + -30, + -30, + -65, + -50, + -52, + -40 + ], + Wedotaccent: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Wegrave: [ + -35, + -35, + -30, + -30, + -65, + -50, + -52, + -40 + ], + Wemacron: [ + -35, + -35, + -30, + -30, + -65, + -50, + -52, + -40 + ], + Weogonek: [ + -35, + -35, + -30, + -30, + -65, + -90, + -92, + -80 + ], + Whyphen: [ + -40, + -40, + -40, + -40, + -37, + -50, + -37, + -65 + ], + Wo: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Woacute: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wocircumflex: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wodieresis: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wograve: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wohungarumlaut: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Womacron: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Woslash: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wotilde: [ + -60, + -60, + -30, + -30, + -75, + -80, + -92, + -80 + ], + Wperiod: [ + -80, + -80, + -80, + -80, + -92, + -74, + -92, + -92 + ], + Wsemicolon: [ + -10, + -10, + 0, + 0, + -55, + -55, + -65, + -37 + ], + Wu: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wuacute: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wucircumflex: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wudieresis: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wugrave: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wuhungarumlaut: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wumacron: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wuogonek: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wuring: [ + -45, + -45, + -30, + -30, + -50, + -55, + -55, + -50 + ], + Wy: [ + -20, + -20, + -20, + -20, + -60, + -55, + -70, + -73 + ], + Wyacute: [ + -20, + -20, + -20, + -20, + -60, + -55, + -70, + -73 + ], + Wydieresis: [ + -20, + -20, + -20, + -20, + -60, + -55, + -70, + -73 + ], + YA: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAacute: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAbreve: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAcircumflex: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAdieresis: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAgrave: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAmacron: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAogonek: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAring: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YAtilde: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YO: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOacute: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOcircumflex: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOdieresis: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOgrave: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOhungarumlaut: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOmacron: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOslash: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YOtilde: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + Ya: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yaacute: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yabreve: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -100 + ], + Yacircumflex: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yadieresis: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Yagrave: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Yamacron: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -60 + ], + Yaogonek: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yaring: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yatilde: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Ycolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Ycomma: [ + -100, + -100, + -140, + -140, + -92, + -92, + -92, + -129 + ], + Ye: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yeacute: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yecaron: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yecircumflex: [ + -80, + -80, + -140, + -140, + -111, + -71, + -92, + -100 + ], + Yedieresis: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Yedotaccent: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yegrave: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Yemacron: [ + -80, + -80, + -70, + -70, + -71, + -71, + -52, + -60 + ], + Yeogonek: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yo: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yoacute: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yocircumflex: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yodieresis: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yograve: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yohungarumlaut: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yomacron: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yoslash: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yotilde: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yperiod: [ + -100, + -100, + -140, + -140, + -92, + -74, + -92, + -129 + ], + Ysemicolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Yu: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yuacute: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yucircumflex: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yudieresis: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yugrave: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yuhungarumlaut: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yumacron: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yuogonek: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yuring: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + YacuteA: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAacute: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAbreve: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAcircumflex: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAdieresis: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAgrave: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAmacron: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAogonek: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAring: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteAtilde: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YacuteO: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOacute: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOcircumflex: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOdieresis: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOgrave: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOhungarumlaut: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOmacron: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOslash: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YacuteOtilde: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + Yacutea: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yacuteaacute: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yacuteabreve: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -100 + ], + Yacuteacircumflex: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yacuteadieresis: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Yacuteagrave: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Yacuteamacron: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -60 + ], + Yacuteaogonek: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yacutearing: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Yacuteatilde: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -60 + ], + Yacutecolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Yacutecomma: [ + -100, + -100, + -140, + -140, + -92, + -92, + -92, + -129 + ], + Yacutee: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yacuteeacute: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yacuteecaron: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yacuteecircumflex: [ + -80, + -80, + -140, + -140, + -111, + -71, + -92, + -100 + ], + Yacuteedieresis: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Yacuteedotaccent: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yacuteegrave: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Yacuteemacron: [ + -80, + -80, + -70, + -70, + -71, + -71, + -52, + -60 + ], + Yacuteeogonek: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Yacuteo: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yacuteoacute: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yacuteocircumflex: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yacuteodieresis: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yacuteograve: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yacuteohungarumlaut: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yacuteomacron: [ + -100, + -100, + -70, + -70, + -111, + -111, + -92, + -70 + ], + Yacuteoslash: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Yacuteotilde: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Yacuteperiod: [ + -100, + -100, + -140, + -140, + -92, + -74, + -92, + -129 + ], + Yacutesemicolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Yacuteu: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yacuteuacute: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yacuteucircumflex: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yacuteudieresis: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yacuteugrave: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yacuteuhungarumlaut: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yacuteumacron: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Yacuteuogonek: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Yacuteuring: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + YdieresisA: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAacute: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAbreve: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAcircumflex: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAdieresis: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAgrave: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAmacron: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAogonek: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAring: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisAtilde: [ + -110, + -110, + -110, + -110, + -110, + -74, + -50, + -120 + ], + YdieresisO: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOacute: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOcircumflex: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOdieresis: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOgrave: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOhungarumlaut: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOmacron: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOslash: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + YdieresisOtilde: [ + -70, + -70, + -85, + -85, + -35, + -25, + -15, + -30 + ], + Ydieresisa: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Ydieresisaacute: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Ydieresisabreve: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -100 + ], + Ydieresisacircumflex: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Ydieresisadieresis: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Ydieresisagrave: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -60 + ], + Ydieresisamacron: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -60 + ], + Ydieresisaogonek: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Ydieresisaring: [ + -90, + -90, + -140, + -140, + -85, + -92, + -92, + -100 + ], + Ydieresisatilde: [ + -90, + -90, + -70, + -70, + -85, + -92, + -92, + -100 + ], + Ydieresiscolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Ydieresiscomma: [ + -100, + -100, + -140, + -140, + -92, + -92, + -92, + -129 + ], + Ydieresise: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Ydieresiseacute: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Ydieresisecaron: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Ydieresisecircumflex: [ + -80, + -80, + -140, + -140, + -111, + -71, + -92, + -100 + ], + Ydieresisedieresis: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Ydieresisedotaccent: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Ydieresisegrave: [ + -80, + -80, + -140, + -140, + -71, + -71, + -52, + -60 + ], + Ydieresisemacron: [ + -80, + -80, + -70, + -70, + -71, + -71, + -52, + -60 + ], + Ydieresiseogonek: [ + -80, + -80, + -140, + -140, + -111, + -111, + -92, + -100 + ], + Ydieresiso: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Ydieresisoacute: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Ydieresisocircumflex: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Ydieresisodieresis: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Ydieresisograve: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Ydieresisohungarumlaut: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Ydieresisomacron: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Ydieresisoslash: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -110 + ], + Ydieresisotilde: [ + -100, + -100, + -140, + -140, + -111, + -111, + -92, + -70 + ], + Ydieresisperiod: [ + -100, + -100, + -140, + -140, + -92, + -74, + -92, + -129 + ], + Ydieresissemicolon: [ + -50, + -50, + -60, + -60, + -92, + -92, + -65, + -92 + ], + Ydieresisu: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Ydieresisuacute: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Ydieresisucircumflex: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Ydieresisudieresis: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Ydieresisugrave: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Ydieresisuhungarumlaut: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Ydieresisumacron: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -71 + ], + Ydieresisuogonek: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + Ydieresisuring: [ + -100, + -100, + -110, + -110, + -92, + -92, + -92, + -111 + ], + ag: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + agbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + agcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + av: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + aw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + ay: [ + -20, + -20, + -30, + -30 + ], + ayacute: [ + -20, + -20, + -30, + -30 + ], + aydieresis: [ + -20, + -20, + -30, + -30 + ], + aacuteg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aacutegbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aacutegcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aacutev: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + aacutew: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + aacutey: [ + -20, + -20, + -30, + -30 + ], + aacuteyacute: [ + -20, + -20, + -30, + -30 + ], + aacuteydieresis: [ + -20, + -20, + -30, + -30 + ], + abreveg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + abrevegbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + abrevegcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + abrevev: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + abrevew: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + abrevey: [ + -20, + -20, + -30, + -30 + ], + abreveyacute: [ + -20, + -20, + -30, + -30 + ], + abreveydieresis: [ + -20, + -20, + -30, + -30 + ], + acircumflexg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + acircumflexgbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + acircumflexgcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + acircumflexv: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + acircumflexw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + acircumflexy: [ + -20, + -20, + -30, + -30 + ], + acircumflexyacute: [ + -20, + -20, + -30, + -30 + ], + acircumflexydieresis: [ + -20, + -20, + -30, + -30 + ], + adieresisg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + adieresisgbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + adieresisgcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + adieresisv: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + adieresisw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + adieresisy: [ + -20, + -20, + -30, + -30 + ], + adieresisyacute: [ + -20, + -20, + -30, + -30 + ], + adieresisydieresis: [ + -20, + -20, + -30, + -30 + ], + agraveg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + agravegbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + agravegcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + agravev: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + agravew: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + agravey: [ + -20, + -20, + -30, + -30 + ], + agraveyacute: [ + -20, + -20, + -30, + -30 + ], + agraveydieresis: [ + -20, + -20, + -30, + -30 + ], + amacrong: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + amacrongbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + amacrongcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + amacronv: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + amacronw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + amacrony: [ + -20, + -20, + -30, + -30 + ], + amacronyacute: [ + -20, + -20, + -30, + -30 + ], + amacronydieresis: [ + -20, + -20, + -30, + -30 + ], + aogonekg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aogonekgbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aogonekgcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aogonekv: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + aogonekw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + aogoneky: [ + -20, + -20, + -30, + -30 + ], + aogonekyacute: [ + -20, + -20, + -30, + -30 + ], + aogonekydieresis: [ + -20, + -20, + -30, + -30 + ], + aringg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aringgbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aringgcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + aringv: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + aringw: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + aringy: [ + -20, + -20, + -30, + -30 + ], + aringyacute: [ + -20, + -20, + -30, + -30 + ], + aringydieresis: [ + -20, + -20, + -30, + -30 + ], + atildeg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + atildegbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + atildegcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + atildev: [ + -15, + -15, + -20, + -20, + -25, + 0, + 0, + -20 + ], + atildew: [ + -15, + -15, + -20, + -20, + 0, + 0, + 0, + -15 + ], + atildey: [ + -20, + -20, + -30, + -30 + ], + atildeyacute: [ + -20, + -20, + -30, + -30 + ], + atildeydieresis: [ + -20, + -20, + -30, + -30 + ], + bl: [ + -10, + -10, + -20, + -20 + ], + blacute: [ + -10, + -10, + -20, + -20 + ], + blcommaaccent: [ + -10, + -10, + -20, + -20 + ], + blslash: [ + -10, + -10, + -20, + -20 + ], + bu: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + buacute: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + bucircumflex: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + budieresis: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + bugrave: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + buhungarumlaut: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + bumacron: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + buogonek: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + buring: [ + -20, + -20, + -20, + -20, + -20, + -20, + -20, + -20 + ], + bv: [ + -20, + -20, + -20, + -20, + -15, + 0, + 0, + -15 + ], + by: [ + -20, + -20, + -20, + -20 + ], + byacute: [ + -20, + -20, + -20, + -20 + ], + bydieresis: [ + -20, + -20, + -20, + -20 + ], + ch: [ + -10, + -10, + 0, + 0, + 0, + -10, + -15 + ], + ck: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + ckcommaaccent: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + cl: [ + -20, + -20 + ], + clacute: [ + -20, + -20 + ], + clcommaaccent: [ + -20, + -20 + ], + clslash: [ + -20, + -20 + ], + cy: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + cyacute: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + cydieresis: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + cacuteh: [ + -10, + -10, + 0, + 0, + 0, + -10, + -15 + ], + cacutek: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + cacutekcommaaccent: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + cacutel: [ + -20, + -20 + ], + cacutelacute: [ + -20, + -20 + ], + cacutelcommaaccent: [ + -20, + -20 + ], + cacutelslash: [ + -20, + -20 + ], + cacutey: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + cacuteyacute: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + cacuteydieresis: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccaronh: [ + -10, + -10, + 0, + 0, + 0, + -10, + -15 + ], + ccaronk: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + ccaronkcommaaccent: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + ccaronl: [ + -20, + -20 + ], + ccaronlacute: [ + -20, + -20 + ], + ccaronlcommaaccent: [ + -20, + -20 + ], + ccaronlslash: [ + -20, + -20 + ], + ccarony: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccaronyacute: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccaronydieresis: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccedillah: [ + -10, + -10, + 0, + 0, + 0, + -10, + -15 + ], + ccedillak: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + ccedillakcommaaccent: [ + -20, + -20, + -20, + -20, + 0, + -10, + -20 + ], + ccedillal: [ + -20, + -20 + ], + ccedillalacute: [ + -20, + -20 + ], + ccedillalcommaaccent: [ + -20, + -20 + ], + ccedillalslash: [ + -20, + -20 + ], + ccedillay: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccedillayacute: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + ccedillaydieresis: [ + -10, + -10, + 0, + 0, + 0, + 0, + 0, + -15 + ], + colonspace: [ + -40, + -40, + -50, + -50 + ], + commaquotedblright: [ + -120, + -120, + -100, + -100, + -45, + -95, + -140, + -70 + ], + commaquoteright: [ + -120, + -120, + -100, + -100, + -55, + -95, + -140, + -70 + ], + commaspace: [ + -40, + -40 + ], + dd: [ + -10, + -10 + ], + ddcroat: [ + -10, + -10 + ], + dv: [ + -15, + -15 + ], + dw: [ + -15, + -15, + 0, + 0, + -15 + ], + dy: [ + -15, + -15 + ], + dyacute: [ + -15, + -15 + ], + dydieresis: [ + -15, + -15 + ], + dcroatd: [ + -10, + -10 + ], + dcroatdcroat: [ + -10, + -10 + ], + dcroatv: [ + -15, + -15 + ], + dcroatw: [ + -15, + -15, + 0, + 0, + -15 + ], + dcroaty: [ + -15, + -15 + ], + dcroatyacute: [ + -15, + -15 + ], + dcroatydieresis: [ + -15, + -15 + ], + ecomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + eperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + ev: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + ew: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + ex: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + ey: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eacutecomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + eacuteperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + eacutev: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + eacutew: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + eacutex: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + eacutey: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eacuteyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eacuteydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecaroncomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + ecaronperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + ecaronv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + ecaronw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + ecaronx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + ecarony: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecaronyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecaronydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecircumflexcomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + ecircumflexperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + ecircumflexv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + ecircumflexw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + ecircumflexx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + ecircumflexy: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecircumflexyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + ecircumflexydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edieresiscomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + edieresisperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + edieresisv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + edieresisw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + edieresisx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + edieresisy: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edieresisyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edieresisydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edotaccentcomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + edotaccentperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + edotaccentv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + edotaccentw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + edotaccentx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + edotaccenty: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edotaccentyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + edotaccentydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + egravecomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + egraveperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + egravev: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + egravew: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + egravex: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + egravey: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + egraveyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + egraveydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + emacroncomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + emacronperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + emacronv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + emacronw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + emacronx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + emacrony: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + emacronyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + emacronydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eogonekcomma: [ + 10, + 10, + -15, + -15, + 0, + 0, + -10 + ], + eogonekperiod: [ + 20, + 20, + -15, + -15, + 0, + 0, + -15 + ], + eogonekv: [ + -15, + -15, + -30, + -30, + -15, + 0, + -15, + -25 + ], + eogonekw: [ + -15, + -15, + -20, + -20, + 0, + 0, + -15, + -25 + ], + eogonekx: [ + -15, + -15, + -30, + -30, + 0, + 0, + -20, + -15 + ], + eogoneky: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eogonekyacute: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + eogonekydieresis: [ + -15, + -15, + -20, + -20, + 0, + 0, + -30, + -15 + ], + fcomma: [ + -10, + -10, + -30, + -30, + -15, + -10, + -10 + ], + fe: [ + -10, + -10, + -30, + -30, + 0, + -10 + ], + feacute: [ + -10, + -10, + -30, + -30, + 0, + -10 + ], + fecaron: [ + -10, + -10, + -30, + -30 + ], + fecircumflex: [ + -10, + -10, + -30, + -30 + ], + fedieresis: [ + -10, + -10, + -30, + -30 + ], + fedotaccent: [ + -10, + -10, + -30, + -30, + 0, + -10 + ], + fegrave: [ + -10, + -10, + -30, + -30 + ], + femacron: [ + -10, + -10, + -30, + -30 + ], + feogonek: [ + -10, + -10, + -30, + -30, + 0, + -10 + ], + fo: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + foacute: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + focircumflex: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + fodieresis: [ + -20, + -20, + -30, + -30, + -25 + ], + fograve: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + fohungarumlaut: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + fomacron: [ + -20, + -20, + -30, + -30, + -25 + ], + foslash: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + fotilde: [ + -20, + -20, + -30, + -30, + -25, + -10 + ], + fperiod: [ + -10, + -10, + -30, + -30, + -15, + -10, + -15 + ], + fquotedblright: [ + 30, + 30, + 60, + 60, + 50 + ], + fquoteright: [ + 30, + 30, + 50, + 50, + 55, + 55, + 92, + 55 + ], + ge: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + geacute: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gecaron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gecircumflex: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gedieresis: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gedotaccent: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gegrave: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gemacron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + geogonek: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + ggbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + ggcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gbrevee: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveeacute: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveecaron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveecircumflex: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveedieresis: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveedotaccent: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveegrave: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveemacron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveeogonek: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gbreveg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gbrevegbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gbrevegcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccente: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccenteacute: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentecaron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentecircumflex: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentedieresis: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentedotaccent: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentegrave: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentemacron: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccenteogonek: [ + 10, + 10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentg: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentgbreve: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentgcommaaccent: [ + -10, + -10, + 0, + 0, + 0, + 0, + -10 + ], + hy: [ + -20, + -20, + -30, + -30, + -15, + 0, + 0, + -5 + ], + hyacute: [ + -20, + -20, + -30, + -30, + -15, + 0, + 0, + -5 + ], + hydieresis: [ + -20, + -20, + -30, + -30, + -15, + 0, + 0, + -5 + ], + ko: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + koacute: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kocircumflex: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kodieresis: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kograve: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kohungarumlaut: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + komacron: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + koslash: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kotilde: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccento: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentoacute: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentocircumflex: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentodieresis: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentograve: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentohungarumlaut: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentomacron: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentoslash: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + kcommaaccentotilde: [ + -15, + -15, + -20, + -20, + -15, + -10, + -10, + -10 + ], + lw: [ + -15, + -15, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ly: [ + -15, + -15 + ], + lyacute: [ + -15, + -15 + ], + lydieresis: [ + -15, + -15 + ], + lacutew: [ + -15, + -15, + 0, + 0, + 0, + 0, + 0, + -10 + ], + lacutey: [ + -15, + -15 + ], + lacuteyacute: [ + -15, + -15 + ], + lacuteydieresis: [ + -15, + -15 + ], + lcommaaccentw: [ + -15, + -15, + 0, + 0, + 0, + 0, + 0, + -10 + ], + lcommaaccenty: [ + -15, + -15 + ], + lcommaaccentyacute: [ + -15, + -15 + ], + lcommaaccentydieresis: [ + -15, + -15 + ], + lslashw: [ + -15, + -15, + 0, + 0, + 0, + 0, + 0, + -10 + ], + lslashy: [ + -15, + -15 + ], + lslashyacute: [ + -15, + -15 + ], + lslashydieresis: [ + -15, + -15 + ], + mu: [ + -20, + -20, + -10, + -10 + ], + muacute: [ + -20, + -20, + -10, + -10 + ], + mucircumflex: [ + -20, + -20, + -10, + -10 + ], + mudieresis: [ + -20, + -20, + -10, + -10 + ], + mugrave: [ + -20, + -20, + -10, + -10 + ], + muhungarumlaut: [ + -20, + -20, + -10, + -10 + ], + mumacron: [ + -20, + -20, + -10, + -10 + ], + muogonek: [ + -20, + -20, + -10, + -10 + ], + muring: [ + -20, + -20, + -10, + -10 + ], + my: [ + -30, + -30, + -15, + -15 + ], + myacute: [ + -30, + -30, + -15, + -15 + ], + mydieresis: [ + -30, + -30, + -15, + -15 + ], + nu: [ + -10, + -10, + -10, + -10 + ], + nuacute: [ + -10, + -10, + -10, + -10 + ], + nucircumflex: [ + -10, + -10, + -10, + -10 + ], + nudieresis: [ + -10, + -10, + -10, + -10 + ], + nugrave: [ + -10, + -10, + -10, + -10 + ], + nuhungarumlaut: [ + -10, + -10, + -10, + -10 + ], + numacron: [ + -10, + -10, + -10, + -10 + ], + nuogonek: [ + -10, + -10, + -10, + -10 + ], + nuring: [ + -10, + -10, + -10, + -10 + ], + nv: [ + -40, + -40, + -20, + -20, + -40, + -40, + -40, + -40 + ], + ny: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + nyacute: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + nydieresis: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + nacuteu: [ + -10, + -10, + -10, + -10 + ], + nacuteuacute: [ + -10, + -10, + -10, + -10 + ], + nacuteucircumflex: [ + -10, + -10, + -10, + -10 + ], + nacuteudieresis: [ + -10, + -10, + -10, + -10 + ], + nacuteugrave: [ + -10, + -10, + -10, + -10 + ], + nacuteuhungarumlaut: [ + -10, + -10, + -10, + -10 + ], + nacuteumacron: [ + -10, + -10, + -10, + -10 + ], + nacuteuogonek: [ + -10, + -10, + -10, + -10 + ], + nacuteuring: [ + -10, + -10, + -10, + -10 + ], + nacutev: [ + -40, + -40, + -20, + -20, + -40, + -40, + -40, + -40 + ], + nacutey: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + nacuteyacute: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + nacuteydieresis: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncaronu: [ + -10, + -10, + -10, + -10 + ], + ncaronuacute: [ + -10, + -10, + -10, + -10 + ], + ncaronucircumflex: [ + -10, + -10, + -10, + -10 + ], + ncaronudieresis: [ + -10, + -10, + -10, + -10 + ], + ncaronugrave: [ + -10, + -10, + -10, + -10 + ], + ncaronuhungarumlaut: [ + -10, + -10, + -10, + -10 + ], + ncaronumacron: [ + -10, + -10, + -10, + -10 + ], + ncaronuogonek: [ + -10, + -10, + -10, + -10 + ], + ncaronuring: [ + -10, + -10, + -10, + -10 + ], + ncaronv: [ + -40, + -40, + -20, + -20, + -40, + -40, + -40, + -40 + ], + ncarony: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncaronyacute: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncaronydieresis: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncommaaccentu: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentuacute: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentucircumflex: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentudieresis: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentugrave: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentuhungarumlaut: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentumacron: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentuogonek: [ + -10, + -10, + -10, + -10 + ], + ncommaaccenturing: [ + -10, + -10, + -10, + -10 + ], + ncommaaccentv: [ + -40, + -40, + -20, + -20, + -40, + -40, + -40, + -40 + ], + ncommaaccenty: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncommaaccentyacute: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ncommaaccentydieresis: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ntildeu: [ + -10, + -10, + -10, + -10 + ], + ntildeuacute: [ + -10, + -10, + -10, + -10 + ], + ntildeucircumflex: [ + -10, + -10, + -10, + -10 + ], + ntildeudieresis: [ + -10, + -10, + -10, + -10 + ], + ntildeugrave: [ + -10, + -10, + -10, + -10 + ], + ntildeuhungarumlaut: [ + -10, + -10, + -10, + -10 + ], + ntildeumacron: [ + -10, + -10, + -10, + -10 + ], + ntildeuogonek: [ + -10, + -10, + -10, + -10 + ], + ntildeuring: [ + -10, + -10, + -10, + -10 + ], + ntildev: [ + -40, + -40, + -20, + -20, + -40, + -40, + -40, + -40 + ], + ntildey: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ntildeyacute: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ntildeydieresis: [ + -20, + -20, + -15, + -15, + 0, + 0, + 0, + -15 + ], + ov: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + ow: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + ox: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + oy: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oacutev: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + oacutew: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + oacutex: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + oacutey: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oacuteyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oacuteydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ocircumflexv: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + ocircumflexw: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + ocircumflexx: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + ocircumflexy: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ocircumflexyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ocircumflexydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + odieresisv: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + odieresisw: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + odieresisx: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + odieresisy: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + odieresisyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + odieresisydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ogravev: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + ogravew: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + ogravex: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + ogravey: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ograveyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ograveydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ohungarumlautv: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + ohungarumlautw: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + ohungarumlautx: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + ohungarumlauty: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ohungarumlautyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + ohungarumlautydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + omacronv: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + omacronw: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + omacronx: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + omacrony: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + omacronyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + omacronydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + oslashv: [ + -20, + -20, + -70, + -70, + -10, + -15, + -10, + -15 + ], + oslashw: [ + -15, + -15, + -70, + -70, + -10, + -25, + 0, + -25 + ], + oslashx: [ + -30, + -30, + -85, + -85, + 0, + -10 + ], + oslashy: [ + -20, + -20, + -70, + -70, + 0, + -10, + 0, + -10 + ], + oslashyacute: [ + -20, + -20, + -70, + -70, + 0, + -10, + 0, + -10 + ], + oslashydieresis: [ + -20, + -20, + -70, + -70, + 0, + -10, + 0, + -10 + ], + otildev: [ + -20, + -20, + -15, + -15, + -10, + -15, + -10, + -15 + ], + otildew: [ + -15, + -15, + -15, + -15, + -10, + -25, + 0, + -25 + ], + otildex: [ + -30, + -30, + -30, + -30, + 0, + -10 + ], + otildey: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + otildeyacute: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + otildeydieresis: [ + -20, + -20, + -30, + -30, + 0, + -10, + 0, + -10 + ], + py: [ + -15, + -15, + -30, + -30, + 0, + 0, + 0, + -10 + ], + pyacute: [ + -15, + -15, + -30, + -30, + 0, + 0, + 0, + -10 + ], + pydieresis: [ + -15, + -15, + -30, + -30, + 0, + 0, + 0, + -10 + ], + periodquotedblright: [ + -120, + -120, + -100, + -100, + -55, + -95, + -140, + -70 + ], + periodquoteright: [ + -120, + -120, + -100, + -100, + -55, + -95, + -140, + -70 + ], + periodspace: [ + -40, + -40, + -60, + -60 + ], + quotedblrightspace: [ + -80, + -80, + -40, + -40 + ], + quoteleftquoteleft: [ + -46, + -46, + -57, + -57, + -63, + -74, + -111, + -74 + ], + quoterightd: [ + -80, + -80, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterightdcroat: [ + -80, + -80, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterightl: [ + -20, + -20, + 0, + 0, + 0, + 0, + 0, + -10 + ], + quoterightlacute: [ + -20, + -20, + 0, + 0, + 0, + 0, + 0, + -10 + ], + quoterightlcommaaccent: [ + -20, + -20, + 0, + 0, + 0, + 0, + 0, + -10 + ], + quoterightlslash: [ + -20, + -20, + 0, + 0, + 0, + 0, + 0, + -10 + ], + quoterightquoteright: [ + -46, + -46, + -57, + -57, + -63, + -74, + -111, + -74 + ], + quoterightr: [ + -40, + -40, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterightracute: [ + -40, + -40, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterightrcaron: [ + -40, + -40, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterightrcommaaccent: [ + -40, + -40, + -50, + -50, + -20, + -15, + -25, + -50 + ], + quoterights: [ + -60, + -60, + -50, + -50, + -37, + -74, + -40, + -55 + ], + quoterightsacute: [ + -60, + -60, + -50, + -50, + -37, + -74, + -40, + -55 + ], + quoterightscaron: [ + -60, + -60, + -50, + -50, + -37, + -74, + -40, + -55 + ], + quoterightscedilla: [ + -60, + -60, + -50, + -50, + -37, + -74, + -40, + -55 + ], + quoterightscommaaccent: [ + -60, + -60, + -50, + -50, + -37, + -74, + -40, + -55 + ], + quoterightspace: [ + -80, + -80, + -70, + -70, + -74, + -74, + -111, + -74 + ], + quoterightv: [ + -20, + -20, + 0, + 0, + -20, + -15, + -10, + -50 + ], + rc: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rccaron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rccedilla: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcomma: [ + -60, + -60, + -50, + -50, + -92, + -65, + -111, + -40 + ], + rd: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rdcroat: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rg: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rgbreve: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rgcommaaccent: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rhyphen: [ + -20, + -20, + 0, + 0, + -37, + 0, + -20, + -20 + ], + ro: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + roacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rocircumflex: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rodieresis: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rograve: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rohungarumlaut: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + romacron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + roslash: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rotilde: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rperiod: [ + -60, + -60, + -50, + -50, + -100, + -65, + -111, + -55 + ], + rq: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rs: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rsacute: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rscaron: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rscedilla: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rscommaaccent: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rt: [ + 20, + 20, + 40, + 40 + ], + rtcommaaccent: [ + 20, + 20, + 40, + 40 + ], + rv: [ + 10, + 10, + 30, + 30, + -10 + ], + ry: [ + 10, + 10, + 30, + 30 + ], + ryacute: [ + 10, + 10, + 30, + 30 + ], + rydieresis: [ + 10, + 10, + 30, + 30 + ], + racutec: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + racutecacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + racuteccaron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + racuteccedilla: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + racutecomma: [ + -60, + -60, + -50, + -50, + -92, + -65, + -111, + -40 + ], + racuted: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + racutedcroat: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + racuteg: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + racutegbreve: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + racutegcommaaccent: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + racutehyphen: [ + -20, + -20, + 0, + 0, + -37, + 0, + -20, + -20 + ], + racuteo: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteoacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteocircumflex: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteodieresis: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteograve: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteohungarumlaut: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteomacron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteoslash: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteotilde: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + racuteperiod: [ + -60, + -60, + -50, + -50, + -100, + -65, + -111, + -55 + ], + racuteq: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + racutes: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + racutesacute: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + racutescaron: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + racutescedilla: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + racutescommaaccent: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + racutet: [ + 20, + 20, + 40, + 40 + ], + racutetcommaaccent: [ + 20, + 20, + 40, + 40 + ], + racutev: [ + 10, + 10, + 30, + 30, + -10 + ], + racutey: [ + 10, + 10, + 30, + 30 + ], + racuteyacute: [ + 10, + 10, + 30, + 30 + ], + racuteydieresis: [ + 10, + 10, + 30, + 30 + ], + rcaronc: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcaroncacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcaronccaron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcaronccedilla: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcaroncomma: [ + -60, + -60, + -50, + -50, + -92, + -65, + -111, + -40 + ], + rcarond: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rcarondcroat: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rcarong: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcarongbreve: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcarongcommaaccent: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcaronhyphen: [ + -20, + -20, + 0, + 0, + -37, + 0, + -20, + -20 + ], + rcarono: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronoacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronocircumflex: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronodieresis: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronograve: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronohungarumlaut: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronomacron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronoslash: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronotilde: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcaronperiod: [ + -60, + -60, + -50, + -50, + -100, + -65, + -111, + -55 + ], + rcaronq: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcarons: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcaronsacute: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcaronscaron: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcaronscedilla: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcaronscommaaccent: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcaront: [ + 20, + 20, + 40, + 40 + ], + rcarontcommaaccent: [ + 20, + 20, + 40, + 40 + ], + rcaronv: [ + 10, + 10, + 30, + 30, + -10 + ], + rcarony: [ + 10, + 10, + 30, + 30 + ], + rcaronyacute: [ + 10, + 10, + 30, + 30 + ], + rcaronydieresis: [ + 10, + 10, + 30, + 30 + ], + rcommaaccentc: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentcacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentccaron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentccedilla: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentcomma: [ + -60, + -60, + -50, + -50, + -92, + -65, + -111, + -40 + ], + rcommaaccentd: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rcommaaccentdcroat: [ + -20, + -20, + 0, + 0, + 0, + 0, + -37 + ], + rcommaaccentg: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcommaaccentgbreve: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcommaaccentgcommaaccent: [ + -15, + -15, + 0, + 0, + -10, + 0, + -37, + -18 + ], + rcommaaccenthyphen: [ + -20, + -20, + 0, + 0, + -37, + 0, + -20, + -20 + ], + rcommaaccento: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentoacute: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentocircumflex: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentodieresis: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentograve: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentohungarumlaut: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentomacron: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentoslash: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentotilde: [ + -20, + -20, + 0, + 0, + -18, + 0, + -45 + ], + rcommaaccentperiod: [ + -60, + -60, + -50, + -50, + -100, + -65, + -111, + -55 + ], + rcommaaccentq: [ + -20, + -20, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccents: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcommaaccentsacute: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcommaaccentscaron: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcommaaccentscedilla: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcommaaccentscommaaccent: [ + -15, + -15, + 0, + 0, + 0, + 0, + -10 + ], + rcommaaccentt: [ + 20, + 20, + 40, + 40 + ], + rcommaaccenttcommaaccent: [ + 20, + 20, + 40, + 40 + ], + rcommaaccentv: [ + 10, + 10, + 30, + 30, + -10 + ], + rcommaaccenty: [ + 10, + 10, + 30, + 30 + ], + rcommaaccentyacute: [ + 10, + 10, + 30, + 30 + ], + rcommaaccentydieresis: [ + 10, + 10, + 30, + 30 + ], + sw: [ + -15, + -15, + -30, + -30 + ], + sacutew: [ + -15, + -15, + -30, + -30 + ], + scaronw: [ + -15, + -15, + -30, + -30 + ], + scedillaw: [ + -15, + -15, + -30, + -30 + ], + scommaaccentw: [ + -15, + -15, + -30, + -30 + ], + semicolonspace: [ + -40, + -40, + -50, + -50 + ], + spaceT: [ + -100, + -100, + -50, + -50, + -30, + 0, + -18, + -18 + ], + spaceTcaron: [ + -100, + -100, + -50, + -50, + -30, + 0, + -18, + -18 + ], + spaceTcommaaccent: [ + -100, + -100, + -50, + -50, + -30, + 0, + -18, + -18 + ], + spaceV: [ + -80, + -80, + -50, + -50, + -45, + -70, + -35, + -50 + ], + spaceW: [ + -80, + -80, + -40, + -40, + -30, + -70, + -40, + -30 + ], + spaceY: [ + -120, + -120, + -90, + -90, + -55, + -70, + -75, + -90 + ], + spaceYacute: [ + -120, + -120, + -90, + -90, + -55, + -70, + -75, + -90 + ], + spaceYdieresis: [ + -120, + -120, + -90, + -90, + -55, + -70, + -75, + -90 + ], + spacequotedblleft: [ + -80, + -80, + -30, + -30 + ], + spacequoteleft: [ + -60, + -60, + -60, + -60 + ], + va: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vaacute: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vabreve: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vacircumflex: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vadieresis: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vagrave: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vamacron: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vaogonek: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + varing: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vatilde: [ + -20, + -20, + -25, + -25, + -10, + 0, + 0, + -25 + ], + vcomma: [ + -80, + -80, + -80, + -80, + -55, + -37, + -74, + -65 + ], + vo: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + voacute: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vocircumflex: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vodieresis: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vograve: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vohungarumlaut: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vomacron: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + voslash: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + votilde: [ + -30, + -30, + -25, + -25, + -10, + -15, + 0, + -20 + ], + vperiod: [ + -80, + -80, + -80, + -80, + -70, + -37, + -74, + -65 + ], + wcomma: [ + -40, + -40, + -60, + -60, + -55, + -37, + -74, + -65 + ], + wo: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + woacute: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wocircumflex: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wodieresis: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wograve: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wohungarumlaut: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + womacron: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + woslash: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wotilde: [ + -20, + -20, + -10, + -10, + -10, + -15, + 0, + -10 + ], + wperiod: [ + -40, + -40, + -60, + -60, + -70, + -37, + -74, + -65 + ], + xe: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xeacute: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xecaron: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xecircumflex: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xedieresis: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xedotaccent: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xegrave: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xemacron: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + xeogonek: [ + -10, + -10, + -30, + -30, + 0, + -10, + 0, + -15 + ], + ya: [ + -30, + -30, + -20, + -20 + ], + yaacute: [ + -30, + -30, + -20, + -20 + ], + yabreve: [ + -30, + -30, + -20, + -20 + ], + yacircumflex: [ + -30, + -30, + -20, + -20 + ], + yadieresis: [ + -30, + -30, + -20, + -20 + ], + yagrave: [ + -30, + -30, + -20, + -20 + ], + yamacron: [ + -30, + -30, + -20, + -20 + ], + yaogonek: [ + -30, + -30, + -20, + -20 + ], + yaring: [ + -30, + -30, + -20, + -20 + ], + yatilde: [ + -30, + -30, + -20, + -20 + ], + ycomma: [ + -80, + -80, + -100, + -100, + -55, + -37, + -55, + -65 + ], + ye: [ + -10, + -10, + -20, + -20, + -10 + ], + yeacute: [ + -10, + -10, + -20, + -20, + -10 + ], + yecaron: [ + -10, + -10, + -20, + -20, + -10 + ], + yecircumflex: [ + -10, + -10, + -20, + -20, + -10 + ], + yedieresis: [ + -10, + -10, + -20, + -20, + -10 + ], + yedotaccent: [ + -10, + -10, + -20, + -20, + -10 + ], + yegrave: [ + -10, + -10, + -20, + -20, + -10 + ], + yemacron: [ + -10, + -10, + -20, + -20, + -10 + ], + yeogonek: [ + -10, + -10, + -20, + -20, + -10 + ], + yo: [ + -25, + -25, + -20, + -20, + -25 + ], + yoacute: [ + -25, + -25, + -20, + -20, + -25 + ], + yocircumflex: [ + -25, + -25, + -20, + -20, + -25 + ], + yodieresis: [ + -25, + -25, + -20, + -20, + -25 + ], + yograve: [ + -25, + -25, + -20, + -20, + -25 + ], + yohungarumlaut: [ + -25, + -25, + -20, + -20, + -25 + ], + yomacron: [ + -25, + -25, + -20, + -20, + -25 + ], + yoslash: [ + -25, + -25, + -20, + -20, + -25 + ], + yotilde: [ + -25, + -25, + -20, + -20, + -25 + ], + yperiod: [ + -80, + -80, + -100, + -100, + -70, + -37, + -55, + -65 + ], + yacutea: [ + -30, + -30, + -20, + -20 + ], + yacuteaacute: [ + -30, + -30, + -20, + -20 + ], + yacuteabreve: [ + -30, + -30, + -20, + -20 + ], + yacuteacircumflex: [ + -30, + -30, + -20, + -20 + ], + yacuteadieresis: [ + -30, + -30, + -20, + -20 + ], + yacuteagrave: [ + -30, + -30, + -20, + -20 + ], + yacuteamacron: [ + -30, + -30, + -20, + -20 + ], + yacuteaogonek: [ + -30, + -30, + -20, + -20 + ], + yacutearing: [ + -30, + -30, + -20, + -20 + ], + yacuteatilde: [ + -30, + -30, + -20, + -20 + ], + yacutecomma: [ + -80, + -80, + -100, + -100, + -55, + -37, + -55, + -65 + ], + yacutee: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteeacute: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteecaron: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteecircumflex: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteedieresis: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteedotaccent: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteegrave: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteemacron: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteeogonek: [ + -10, + -10, + -20, + -20, + -10 + ], + yacuteo: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteoacute: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteocircumflex: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteodieresis: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteograve: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteohungarumlaut: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteomacron: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteoslash: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteotilde: [ + -25, + -25, + -20, + -20, + -25 + ], + yacuteperiod: [ + -80, + -80, + -100, + -100, + -70, + -37, + -55, + -65 + ], + ydieresisa: [ + -30, + -30, + -20, + -20 + ], + ydieresisaacute: [ + -30, + -30, + -20, + -20 + ], + ydieresisabreve: [ + -30, + -30, + -20, + -20 + ], + ydieresisacircumflex: [ + -30, + -30, + -20, + -20 + ], + ydieresisadieresis: [ + -30, + -30, + -20, + -20 + ], + ydieresisagrave: [ + -30, + -30, + -20, + -20 + ], + ydieresisamacron: [ + -30, + -30, + -20, + -20 + ], + ydieresisaogonek: [ + -30, + -30, + -20, + -20 + ], + ydieresisaring: [ + -30, + -30, + -20, + -20 + ], + ydieresisatilde: [ + -30, + -30, + -20, + -20 + ], + ydieresiscomma: [ + -80, + -80, + -100, + -100, + -55, + -37, + -55, + -65 + ], + ydieresise: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresiseacute: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisecaron: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisecircumflex: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisedieresis: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisedotaccent: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisegrave: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresisemacron: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresiseogonek: [ + -10, + -10, + -20, + -20, + -10 + ], + ydieresiso: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisoacute: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisocircumflex: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisodieresis: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisograve: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisohungarumlaut: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisomacron: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisoslash: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisotilde: [ + -25, + -25, + -20, + -20, + -25 + ], + ydieresisperiod: [ + -80, + -80, + -100, + -100, + -70, + -37, + -55, + -65 + ], + ze: [ + 10, + 10, + -15, + -15 + ], + zeacute: [ + 10, + 10, + -15, + -15 + ], + zecaron: [ + 10, + 10, + -15, + -15 + ], + zecircumflex: [ + 10, + 10, + -15, + -15 + ], + zedieresis: [ + 10, + 10, + -15, + -15 + ], + zedotaccent: [ + 10, + 10, + -15, + -15 + ], + zegrave: [ + 10, + 10, + -15, + -15 + ], + zemacron: [ + 10, + 10, + -15, + -15 + ], + zeogonek: [ + 10, + 10, + -15, + -15 + ], + zacutee: [ + 10, + 10, + -15, + -15 + ], + zacuteeacute: [ + 10, + 10, + -15, + -15 + ], + zacuteecaron: [ + 10, + 10, + -15, + -15 + ], + zacuteecircumflex: [ + 10, + 10, + -15, + -15 + ], + zacuteedieresis: [ + 10, + 10, + -15, + -15 + ], + zacuteedotaccent: [ + 10, + 10, + -15, + -15 + ], + zacuteegrave: [ + 10, + 10, + -15, + -15 + ], + zacuteemacron: [ + 10, + 10, + -15, + -15 + ], + zacuteeogonek: [ + 10, + 10, + -15, + -15 + ], + zcarone: [ + 10, + 10, + -15, + -15 + ], + zcaroneacute: [ + 10, + 10, + -15, + -15 + ], + zcaronecaron: [ + 10, + 10, + -15, + -15 + ], + zcaronecircumflex: [ + 10, + 10, + -15, + -15 + ], + zcaronedieresis: [ + 10, + 10, + -15, + -15 + ], + zcaronedotaccent: [ + 10, + 10, + -15, + -15 + ], + zcaronegrave: [ + 10, + 10, + -15, + -15 + ], + zcaronemacron: [ + 10, + 10, + -15, + -15 + ], + zcaroneogonek: [ + 10, + 10, + -15, + -15 + ], + zdotaccente: [ + 10, + 10, + -15, + -15 + ], + zdotaccenteacute: [ + 10, + 10, + -15, + -15 + ], + zdotaccentecaron: [ + 10, + 10, + -15, + -15 + ], + zdotaccentecircumflex: [ + 10, + 10, + -15, + -15 + ], + zdotaccentedieresis: [ + 10, + 10, + -15, + -15 + ], + zdotaccentedotaccent: [ + 10, + 10, + -15, + -15 + ], + zdotaccentegrave: [ + 10, + 10, + -15, + -15 + ], + zdotaccentemacron: [ + 10, + 10, + -15, + -15 + ], + zdotaccenteogonek: [ + 10, + 10, + -15, + -15 + ], + Bcomma: [ + 0, + 0, + -20, + -20 + ], + Bperiod: [ + 0, + 0, + -20, + -20 + ], + Ccomma: [ + 0, + 0, + -30, + -30 + ], + Cperiod: [ + 0, + 0, + -30, + -30 + ], + Cacutecomma: [ + 0, + 0, + -30, + -30 + ], + Cacuteperiod: [ + 0, + 0, + -30, + -30 + ], + Ccaroncomma: [ + 0, + 0, + -30, + -30 + ], + Ccaronperiod: [ + 0, + 0, + -30, + -30 + ], + Ccedillacomma: [ + 0, + 0, + -30, + -30 + ], + Ccedillaperiod: [ + 0, + 0, + -30, + -30 + ], + Fe: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Feacute: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fecaron: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fecircumflex: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fedieresis: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fedotaccent: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fegrave: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Femacron: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Feogonek: [ + 0, + 0, + -30, + -30, + -25, + -100, + -75 + ], + Fo: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Foacute: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Focircumflex: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fodieresis: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fograve: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fohungarumlaut: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fomacron: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Foslash: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fotilde: [ + 0, + 0, + -30, + -30, + -25, + -70, + -105, + -15 + ], + Fr: [ + 0, + 0, + -45, + -45, + 0, + -50, + -55 + ], + Fracute: [ + 0, + 0, + -45, + -45, + 0, + -50, + -55 + ], + Frcaron: [ + 0, + 0, + -45, + -45, + 0, + -50, + -55 + ], + Frcommaaccent: [ + 0, + 0, + -45, + -45, + 0, + -50, + -55 + ], + Ja: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jaacute: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jabreve: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jacircumflex: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jadieresis: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jagrave: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jamacron: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jaogonek: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jaring: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + Jatilde: [ + 0, + 0, + -20, + -20, + -15, + -40, + -35 + ], + LcaronT: [ + 0, + 0, + -110, + -110 + ], + LcaronTcaron: [ + 0, + 0, + -110, + -110 + ], + LcaronTcommaaccent: [ + 0, + 0, + -110, + -110 + ], + LcaronV: [ + 0, + 0, + -110, + -110 + ], + LcaronW: [ + 0, + 0, + -70, + -70 + ], + LcaronY: [ + 0, + 0, + -140, + -140 + ], + LcaronYacute: [ + 0, + 0, + -140, + -140 + ], + LcaronYdieresis: [ + 0, + 0, + -140, + -140 + ], + Lcaronquotedblright: [ + 0, + 0, + -140, + -140 + ], + Lcaronquoteright: [ + 0, + 0, + -160, + -160, + 0, + 0, + 0, + -92 + ], + Lcarony: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -55 + ], + Lcaronyacute: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -55 + ], + Lcaronydieresis: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -55 + ], + Scomma: [ + 0, + 0, + -20, + -20 + ], + Speriod: [ + 0, + 0, + -20, + -20 + ], + Sacutecomma: [ + 0, + 0, + -20, + -20 + ], + Sacuteperiod: [ + 0, + 0, + -20, + -20 + ], + Scaroncomma: [ + 0, + 0, + -20, + -20 + ], + Scaronperiod: [ + 0, + 0, + -20, + -20 + ], + Scedillacomma: [ + 0, + 0, + -20, + -20 + ], + Scedillaperiod: [ + 0, + 0, + -20, + -20 + ], + Scommaaccentcomma: [ + 0, + 0, + -20, + -20 + ], + Scommaaccentperiod: [ + 0, + 0, + -20, + -20 + ], + Trcaron: [ + 0, + 0, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcaronrcaron: [ + 0, + 0, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Tcommaaccentrcaron: [ + 0, + 0, + -120, + -120, + -74, + -37, + -55, + -35 + ], + Yhyphen: [ + 0, + 0, + -140, + -140, + -92, + -92, + -74, + -111 + ], + Yi: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Yiacute: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Yiogonek: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Yacutehyphen: [ + 0, + 0, + -140, + -140, + -92, + -92, + -74, + -111 + ], + Yacutei: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Yacuteiacute: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Yacuteiogonek: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Ydieresishyphen: [ + 0, + 0, + -140, + -140, + -92, + -92, + -74, + -111 + ], + Ydieresisi: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Ydieresisiacute: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + Ydieresisiogonek: [ + 0, + 0, + -20, + -20, + -37, + -55, + -74, + -55 + ], + bb: [ + 0, + 0, + -10, + -10, + -10, + -10 + ], + bcomma: [ + 0, + 0, + -40, + -40 + ], + bperiod: [ + 0, + 0, + -40, + -40, + -40, + -40, + -40, + -40 + ], + ccomma: [ + 0, + 0, + -15, + -15 + ], + cacutecomma: [ + 0, + 0, + -15, + -15 + ], + ccaroncomma: [ + 0, + 0, + -15, + -15 + ], + ccedillacomma: [ + 0, + 0, + -15, + -15 + ], + fa: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + faacute: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + fabreve: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + facircumflex: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + fadieresis: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + fagrave: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + famacron: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + faogonek: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + faring: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + fatilde: [ + 0, + 0, + -30, + -30, + 0, + 0, + 0, + -10 + ], + fdotlessi: [ + 0, + 0, + -28, + -28, + -35, + -30, + -60, + -50 + ], + gr: [ + 0, + 0, + -10, + -10 + ], + gracute: [ + 0, + 0, + -10, + -10 + ], + grcaron: [ + 0, + 0, + -10, + -10 + ], + grcommaaccent: [ + 0, + 0, + -10, + -10 + ], + gbrever: [ + 0, + 0, + -10, + -10 + ], + gbreveracute: [ + 0, + 0, + -10, + -10 + ], + gbrevercaron: [ + 0, + 0, + -10, + -10 + ], + gbrevercommaaccent: [ + 0, + 0, + -10, + -10 + ], + gcommaaccentr: [ + 0, + 0, + -10, + -10 + ], + gcommaaccentracute: [ + 0, + 0, + -10, + -10 + ], + gcommaaccentrcaron: [ + 0, + 0, + -10, + -10 + ], + gcommaaccentrcommaaccent: [ + 0, + 0, + -10, + -10 + ], + ke: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + keacute: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kecaron: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kecircumflex: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kedieresis: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kedotaccent: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kegrave: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kemacron: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + keogonek: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccente: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccenteacute: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentecaron: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentecircumflex: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentedieresis: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentedotaccent: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentegrave: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccentemacron: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + kcommaaccenteogonek: [ + 0, + 0, + -20, + -20, + -10, + -30, + -10, + -10 + ], + ocomma: [ + 0, + 0, + -40, + -40 + ], + operiod: [ + 0, + 0, + -40, + -40 + ], + oacutecomma: [ + 0, + 0, + -40, + -40 + ], + oacuteperiod: [ + 0, + 0, + -40, + -40 + ], + ocircumflexcomma: [ + 0, + 0, + -40, + -40 + ], + ocircumflexperiod: [ + 0, + 0, + -40, + -40 + ], + odieresiscomma: [ + 0, + 0, + -40, + -40 + ], + odieresisperiod: [ + 0, + 0, + -40, + -40 + ], + ogravecomma: [ + 0, + 0, + -40, + -40 + ], + ograveperiod: [ + 0, + 0, + -40, + -40 + ], + ohungarumlautcomma: [ + 0, + 0, + -40, + -40 + ], + ohungarumlautperiod: [ + 0, + 0, + -40, + -40 + ], + omacroncomma: [ + 0, + 0, + -40, + -40 + ], + omacronperiod: [ + 0, + 0, + -40, + -40 + ], + oslasha: [ + 0, + 0, + -55, + -55 + ], + oslashaacute: [ + 0, + 0, + -55, + -55 + ], + oslashabreve: [ + 0, + 0, + -55, + -55 + ], + oslashacircumflex: [ + 0, + 0, + -55, + -55 + ], + oslashadieresis: [ + 0, + 0, + -55, + -55 + ], + oslashagrave: [ + 0, + 0, + -55, + -55 + ], + oslashamacron: [ + 0, + 0, + -55, + -55 + ], + oslashaogonek: [ + 0, + 0, + -55, + -55 + ], + oslasharing: [ + 0, + 0, + -55, + -55 + ], + oslashatilde: [ + 0, + 0, + -55, + -55 + ], + oslashb: [ + 0, + 0, + -55, + -55 + ], + oslashc: [ + 0, + 0, + -55, + -55 + ], + oslashcacute: [ + 0, + 0, + -55, + -55 + ], + oslashccaron: [ + 0, + 0, + -55, + -55 + ], + oslashccedilla: [ + 0, + 0, + -55, + -55 + ], + oslashcomma: [ + 0, + 0, + -95, + -95 + ], + oslashd: [ + 0, + 0, + -55, + -55 + ], + oslashdcroat: [ + 0, + 0, + -55, + -55 + ], + oslashe: [ + 0, + 0, + -55, + -55 + ], + oslasheacute: [ + 0, + 0, + -55, + -55 + ], + oslashecaron: [ + 0, + 0, + -55, + -55 + ], + oslashecircumflex: [ + 0, + 0, + -55, + -55 + ], + oslashedieresis: [ + 0, + 0, + -55, + -55 + ], + oslashedotaccent: [ + 0, + 0, + -55, + -55 + ], + oslashegrave: [ + 0, + 0, + -55, + -55 + ], + oslashemacron: [ + 0, + 0, + -55, + -55 + ], + oslasheogonek: [ + 0, + 0, + -55, + -55 + ], + oslashf: [ + 0, + 0, + -55, + -55 + ], + oslashg: [ + 0, + 0, + -55, + -55, + 0, + 0, + -10 + ], + oslashgbreve: [ + 0, + 0, + -55, + -55, + 0, + 0, + -10 + ], + oslashgcommaaccent: [ + 0, + 0, + -55, + -55, + 0, + 0, + -10 + ], + oslashh: [ + 0, + 0, + -55, + -55 + ], + oslashi: [ + 0, + 0, + -55, + -55 + ], + oslashiacute: [ + 0, + 0, + -55, + -55 + ], + oslashicircumflex: [ + 0, + 0, + -55, + -55 + ], + oslashidieresis: [ + 0, + 0, + -55, + -55 + ], + oslashigrave: [ + 0, + 0, + -55, + -55 + ], + oslashimacron: [ + 0, + 0, + -55, + -55 + ], + oslashiogonek: [ + 0, + 0, + -55, + -55 + ], + oslashj: [ + 0, + 0, + -55, + -55 + ], + oslashk: [ + 0, + 0, + -55, + -55 + ], + oslashkcommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslashl: [ + 0, + 0, + -55, + -55 + ], + oslashlacute: [ + 0, + 0, + -55, + -55 + ], + oslashlcommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslashlslash: [ + 0, + 0, + -55, + -55 + ], + oslashm: [ + 0, + 0, + -55, + -55 + ], + oslashn: [ + 0, + 0, + -55, + -55 + ], + oslashnacute: [ + 0, + 0, + -55, + -55 + ], + oslashncaron: [ + 0, + 0, + -55, + -55 + ], + oslashncommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslashntilde: [ + 0, + 0, + -55, + -55 + ], + oslasho: [ + 0, + 0, + -55, + -55 + ], + oslashoacute: [ + 0, + 0, + -55, + -55 + ], + oslashocircumflex: [ + 0, + 0, + -55, + -55 + ], + oslashodieresis: [ + 0, + 0, + -55, + -55 + ], + oslashograve: [ + 0, + 0, + -55, + -55 + ], + oslashohungarumlaut: [ + 0, + 0, + -55, + -55 + ], + oslashomacron: [ + 0, + 0, + -55, + -55 + ], + oslashoslash: [ + 0, + 0, + -55, + -55 + ], + oslashotilde: [ + 0, + 0, + -55, + -55 + ], + oslashp: [ + 0, + 0, + -55, + -55 + ], + oslashperiod: [ + 0, + 0, + -95, + -95 + ], + oslashq: [ + 0, + 0, + -55, + -55 + ], + oslashr: [ + 0, + 0, + -55, + -55 + ], + oslashracute: [ + 0, + 0, + -55, + -55 + ], + oslashrcaron: [ + 0, + 0, + -55, + -55 + ], + oslashrcommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslashs: [ + 0, + 0, + -55, + -55 + ], + oslashsacute: [ + 0, + 0, + -55, + -55 + ], + oslashscaron: [ + 0, + 0, + -55, + -55 + ], + oslashscedilla: [ + 0, + 0, + -55, + -55 + ], + oslashscommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslasht: [ + 0, + 0, + -55, + -55 + ], + oslashtcommaaccent: [ + 0, + 0, + -55, + -55 + ], + oslashu: [ + 0, + 0, + -55, + -55 + ], + oslashuacute: [ + 0, + 0, + -55, + -55 + ], + oslashucircumflex: [ + 0, + 0, + -55, + -55 + ], + oslashudieresis: [ + 0, + 0, + -55, + -55 + ], + oslashugrave: [ + 0, + 0, + -55, + -55 + ], + oslashuhungarumlaut: [ + 0, + 0, + -55, + -55 + ], + oslashumacron: [ + 0, + 0, + -55, + -55 + ], + oslashuogonek: [ + 0, + 0, + -55, + -55 + ], + oslashuring: [ + 0, + 0, + -55, + -55 + ], + oslashz: [ + 0, + 0, + -55, + -55 + ], + oslashzacute: [ + 0, + 0, + -55, + -55 + ], + oslashzcaron: [ + 0, + 0, + -55, + -55 + ], + oslashzdotaccent: [ + 0, + 0, + -55, + -55 + ], + otildecomma: [ + 0, + 0, + -40, + -40 + ], + otildeperiod: [ + 0, + 0, + -40, + -40 + ], + pcomma: [ + 0, + 0, + -35, + -35 + ], + pperiod: [ + 0, + 0, + -35, + -35 + ], + ra: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + raacute: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rabreve: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racircumflex: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + radieresis: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + ragrave: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + ramacron: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + raogonek: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + raring: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + ratilde: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcolon: [ + 0, + 0, + 30, + 30 + ], + ri: [ + 0, + 0, + 15, + 15 + ], + riacute: [ + 0, + 0, + 15, + 15 + ], + ricircumflex: [ + 0, + 0, + 15, + 15 + ], + ridieresis: [ + 0, + 0, + 15, + 15 + ], + rigrave: [ + 0, + 0, + 15, + 15 + ], + rimacron: [ + 0, + 0, + 15, + 15 + ], + riogonek: [ + 0, + 0, + 15, + 15 + ], + rk: [ + 0, + 0, + 15, + 15 + ], + rkcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rl: [ + 0, + 0, + 15, + 15 + ], + rlacute: [ + 0, + 0, + 15, + 15 + ], + rlcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rlslash: [ + 0, + 0, + 15, + 15 + ], + rm: [ + 0, + 0, + 25, + 25 + ], + rn: [ + 0, + 0, + 25, + 25, + -15 + ], + rnacute: [ + 0, + 0, + 25, + 25, + -15 + ], + rncaron: [ + 0, + 0, + 25, + 25, + -15 + ], + rncommaaccent: [ + 0, + 0, + 25, + 25, + -15 + ], + rntilde: [ + 0, + 0, + 25, + 25, + -15 + ], + rp: [ + 0, + 0, + 30, + 30, + -10 + ], + rsemicolon: [ + 0, + 0, + 30, + 30 + ], + ru: [ + 0, + 0, + 15, + 15 + ], + ruacute: [ + 0, + 0, + 15, + 15 + ], + rucircumflex: [ + 0, + 0, + 15, + 15 + ], + rudieresis: [ + 0, + 0, + 15, + 15 + ], + rugrave: [ + 0, + 0, + 15, + 15 + ], + ruhungarumlaut: [ + 0, + 0, + 15, + 15 + ], + rumacron: [ + 0, + 0, + 15, + 15 + ], + ruogonek: [ + 0, + 0, + 15, + 15 + ], + ruring: [ + 0, + 0, + 15, + 15 + ], + racutea: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteaacute: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteabreve: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteacircumflex: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteadieresis: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteagrave: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteamacron: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteaogonek: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racutearing: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racuteatilde: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + racutecolon: [ + 0, + 0, + 30, + 30 + ], + racutei: [ + 0, + 0, + 15, + 15 + ], + racuteiacute: [ + 0, + 0, + 15, + 15 + ], + racuteicircumflex: [ + 0, + 0, + 15, + 15 + ], + racuteidieresis: [ + 0, + 0, + 15, + 15 + ], + racuteigrave: [ + 0, + 0, + 15, + 15 + ], + racuteimacron: [ + 0, + 0, + 15, + 15 + ], + racuteiogonek: [ + 0, + 0, + 15, + 15 + ], + racutek: [ + 0, + 0, + 15, + 15 + ], + racutekcommaaccent: [ + 0, + 0, + 15, + 15 + ], + racutel: [ + 0, + 0, + 15, + 15 + ], + racutelacute: [ + 0, + 0, + 15, + 15 + ], + racutelcommaaccent: [ + 0, + 0, + 15, + 15 + ], + racutelslash: [ + 0, + 0, + 15, + 15 + ], + racutem: [ + 0, + 0, + 25, + 25 + ], + racuten: [ + 0, + 0, + 25, + 25, + -15 + ], + racutenacute: [ + 0, + 0, + 25, + 25, + -15 + ], + racutencaron: [ + 0, + 0, + 25, + 25, + -15 + ], + racutencommaaccent: [ + 0, + 0, + 25, + 25, + -15 + ], + racutentilde: [ + 0, + 0, + 25, + 25, + -15 + ], + racutep: [ + 0, + 0, + 30, + 30, + -10 + ], + racutesemicolon: [ + 0, + 0, + 30, + 30 + ], + racuteu: [ + 0, + 0, + 15, + 15 + ], + racuteuacute: [ + 0, + 0, + 15, + 15 + ], + racuteucircumflex: [ + 0, + 0, + 15, + 15 + ], + racuteudieresis: [ + 0, + 0, + 15, + 15 + ], + racuteugrave: [ + 0, + 0, + 15, + 15 + ], + racuteuhungarumlaut: [ + 0, + 0, + 15, + 15 + ], + racuteumacron: [ + 0, + 0, + 15, + 15 + ], + racuteuogonek: [ + 0, + 0, + 15, + 15 + ], + racuteuring: [ + 0, + 0, + 15, + 15 + ], + rcarona: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronaacute: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronabreve: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronacircumflex: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronadieresis: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronagrave: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronamacron: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronaogonek: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronaring: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaronatilde: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcaroncolon: [ + 0, + 0, + 30, + 30 + ], + rcaroni: [ + 0, + 0, + 15, + 15 + ], + rcaroniacute: [ + 0, + 0, + 15, + 15 + ], + rcaronicircumflex: [ + 0, + 0, + 15, + 15 + ], + rcaronidieresis: [ + 0, + 0, + 15, + 15 + ], + rcaronigrave: [ + 0, + 0, + 15, + 15 + ], + rcaronimacron: [ + 0, + 0, + 15, + 15 + ], + rcaroniogonek: [ + 0, + 0, + 15, + 15 + ], + rcaronk: [ + 0, + 0, + 15, + 15 + ], + rcaronkcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rcaronl: [ + 0, + 0, + 15, + 15 + ], + rcaronlacute: [ + 0, + 0, + 15, + 15 + ], + rcaronlcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rcaronlslash: [ + 0, + 0, + 15, + 15 + ], + rcaronm: [ + 0, + 0, + 25, + 25 + ], + rcaronn: [ + 0, + 0, + 25, + 25, + -15 + ], + rcaronnacute: [ + 0, + 0, + 25, + 25, + -15 + ], + rcaronncaron: [ + 0, + 0, + 25, + 25, + -15 + ], + rcaronncommaaccent: [ + 0, + 0, + 25, + 25, + -15 + ], + rcaronntilde: [ + 0, + 0, + 25, + 25, + -15 + ], + rcaronp: [ + 0, + 0, + 30, + 30, + -10 + ], + rcaronsemicolon: [ + 0, + 0, + 30, + 30 + ], + rcaronu: [ + 0, + 0, + 15, + 15 + ], + rcaronuacute: [ + 0, + 0, + 15, + 15 + ], + rcaronucircumflex: [ + 0, + 0, + 15, + 15 + ], + rcaronudieresis: [ + 0, + 0, + 15, + 15 + ], + rcaronugrave: [ + 0, + 0, + 15, + 15 + ], + rcaronuhungarumlaut: [ + 0, + 0, + 15, + 15 + ], + rcaronumacron: [ + 0, + 0, + 15, + 15 + ], + rcaronuogonek: [ + 0, + 0, + 15, + 15 + ], + rcaronuring: [ + 0, + 0, + 15, + 15 + ], + rcommaaccenta: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentaacute: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentabreve: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentacircumflex: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentadieresis: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentagrave: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentamacron: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentaogonek: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentaring: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentatilde: [ + 0, + 0, + -10, + -10, + 0, + 0, + -15 + ], + rcommaaccentcolon: [ + 0, + 0, + 30, + 30 + ], + rcommaaccenti: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentiacute: [ + 0, + 0, + 15, + 15 + ], + rcommaaccenticircumflex: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentidieresis: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentigrave: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentimacron: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentiogonek: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentk: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentkcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentl: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentlacute: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentlcommaaccent: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentlslash: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentm: [ + 0, + 0, + 25, + 25 + ], + rcommaaccentn: [ + 0, + 0, + 25, + 25, + -15 + ], + rcommaaccentnacute: [ + 0, + 0, + 25, + 25, + -15 + ], + rcommaaccentncaron: [ + 0, + 0, + 25, + 25, + -15 + ], + rcommaaccentncommaaccent: [ + 0, + 0, + 25, + 25, + -15 + ], + rcommaaccentntilde: [ + 0, + 0, + 25, + 25, + -15 + ], + rcommaaccentp: [ + 0, + 0, + 30, + 30, + -10 + ], + rcommaaccentsemicolon: [ + 0, + 0, + 30, + 30 + ], + rcommaaccentu: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentuacute: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentucircumflex: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentudieresis: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentugrave: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentuhungarumlaut: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentumacron: [ + 0, + 0, + 15, + 15 + ], + rcommaaccentuogonek: [ + 0, + 0, + 15, + 15 + ], + rcommaaccenturing: [ + 0, + 0, + 15, + 15 + ], + scomma: [ + 0, + 0, + -15, + -15 + ], + speriod: [ + 0, + 0, + -15, + -15 + ], + sacutecomma: [ + 0, + 0, + -15, + -15 + ], + sacuteperiod: [ + 0, + 0, + -15, + -15 + ], + scaroncomma: [ + 0, + 0, + -15, + -15 + ], + scaronperiod: [ + 0, + 0, + -15, + -15 + ], + scedillacomma: [ + 0, + 0, + -15, + -15 + ], + scedillaperiod: [ + 0, + 0, + -15, + -15 + ], + scommaaccentcomma: [ + 0, + 0, + -15, + -15 + ], + scommaaccentperiod: [ + 0, + 0, + -15, + -15 + ], + ve: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + veacute: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vecaron: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vecircumflex: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vedieresis: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vedotaccent: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vegrave: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + vemacron: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + veogonek: [ + 0, + 0, + -25, + -25, + -10, + -15, + 0, + -15 + ], + wa: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + waacute: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + wabreve: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + wacircumflex: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + wadieresis: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + wagrave: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + wamacron: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + waogonek: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + waring: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + watilde: [ + 0, + 0, + -15, + -15, + 0, + -10, + 0, + -10 + ], + we: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + weacute: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wecaron: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wecircumflex: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wedieresis: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wedotaccent: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wegrave: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + wemacron: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + weogonek: [ + 0, + 0, + -10, + -10, + 0, + -10 + ], + zo: [ + 0, + 0, + -15, + -15 + ], + zoacute: [ + 0, + 0, + -15, + -15 + ], + zocircumflex: [ + 0, + 0, + -15, + -15 + ], + zodieresis: [ + 0, + 0, + -15, + -15 + ], + zograve: [ + 0, + 0, + -15, + -15 + ], + zohungarumlaut: [ + 0, + 0, + -15, + -15 + ], + zomacron: [ + 0, + 0, + -15, + -15 + ], + zoslash: [ + 0, + 0, + -15, + -15 + ], + zotilde: [ + 0, + 0, + -15, + -15 + ], + zacuteo: [ + 0, + 0, + -15, + -15 + ], + zacuteoacute: [ + 0, + 0, + -15, + -15 + ], + zacuteocircumflex: [ + 0, + 0, + -15, + -15 + ], + zacuteodieresis: [ + 0, + 0, + -15, + -15 + ], + zacuteograve: [ + 0, + 0, + -15, + -15 + ], + zacuteohungarumlaut: [ + 0, + 0, + -15, + -15 + ], + zacuteomacron: [ + 0, + 0, + -15, + -15 + ], + zacuteoslash: [ + 0, + 0, + -15, + -15 + ], + zacuteotilde: [ + 0, + 0, + -15, + -15 + ], + zcarono: [ + 0, + 0, + -15, + -15 + ], + zcaronoacute: [ + 0, + 0, + -15, + -15 + ], + zcaronocircumflex: [ + 0, + 0, + -15, + -15 + ], + zcaronodieresis: [ + 0, + 0, + -15, + -15 + ], + zcaronograve: [ + 0, + 0, + -15, + -15 + ], + zcaronohungarumlaut: [ + 0, + 0, + -15, + -15 + ], + zcaronomacron: [ + 0, + 0, + -15, + -15 + ], + zcaronoslash: [ + 0, + 0, + -15, + -15 + ], + zcaronotilde: [ + 0, + 0, + -15, + -15 + ], + zdotaccento: [ + 0, + 0, + -15, + -15 + ], + zdotaccentoacute: [ + 0, + 0, + -15, + -15 + ], + zdotaccentocircumflex: [ + 0, + 0, + -15, + -15 + ], + zdotaccentodieresis: [ + 0, + 0, + -15, + -15 + ], + zdotaccentograve: [ + 0, + 0, + -15, + -15 + ], + zdotaccentohungarumlaut: [ + 0, + 0, + -15, + -15 + ], + zdotaccentomacron: [ + 0, + 0, + -15, + -15 + ], + zdotaccentoslash: [ + 0, + 0, + -15, + -15 + ], + zdotaccentotilde: [ + 0, + 0, + -15, + -15 + ], + Ap: [ + 0, + 0, + 0, + 0, + -25 + ], + Aquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Aacutep: [ + 0, + 0, + 0, + 0, + -25 + ], + Aacutequoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Abrevep: [ + 0, + 0, + 0, + 0, + -25 + ], + Abrevequoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Acircumflexp: [ + 0, + 0, + 0, + 0, + -25 + ], + Acircumflexquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Adieresisp: [ + 0, + 0, + 0, + 0, + -25 + ], + Adieresisquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Agravep: [ + 0, + 0, + 0, + 0, + -25 + ], + Agravequoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Amacronp: [ + 0, + 0, + 0, + 0, + -25 + ], + Amacronquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Aogonekp: [ + 0, + 0, + 0, + 0, + -25 + ], + Aogonekquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Aringp: [ + 0, + 0, + 0, + 0, + -25 + ], + Aringquoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Atildep: [ + 0, + 0, + 0, + 0, + -25 + ], + Atildequoteright: [ + 0, + 0, + 0, + 0, + -74, + -74, + -37, + -111 + ], + Je: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jeacute: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jecaron: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jecircumflex: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jedieresis: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jedotaccent: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jegrave: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jemacron: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jeogonek: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jo: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Joacute: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jocircumflex: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jodieresis: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jograve: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Johungarumlaut: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jomacron: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Joslash: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + Jotilde: [ + 0, + 0, + 0, + 0, + -15, + -40, + -25 + ], + NA: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAacute: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAbreve: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAcircumflex: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAdieresis: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAgrave: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAmacron: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAogonek: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAring: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NAtilde: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteA: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAacute: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAbreve: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAcircumflex: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAdieresis: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAgrave: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAmacron: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAogonek: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAring: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NacuteAtilde: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronA: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAacute: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAbreve: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAcircumflex: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAdieresis: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAgrave: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAmacron: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAogonek: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAring: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcaronAtilde: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentA: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAacute: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAbreve: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAcircumflex: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAdieresis: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAgrave: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAmacron: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAogonek: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAring: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NcommaaccentAtilde: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeA: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAacute: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAbreve: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAcircumflex: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAdieresis: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAgrave: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAmacron: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAogonek: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAring: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + NtildeAtilde: [ + 0, + 0, + 0, + 0, + -20, + -30, + -27, + -35 + ], + Ti: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tiacute: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tiogonek: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcaroni: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcaroniacute: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcaroniogonek: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcommaaccenti: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcommaaccentiacute: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Tcommaaccentiogonek: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -35 + ], + Vi: [ + 0, + 0, + 0, + 0, + -37, + -55, + -74, + -60 + ], + Viacute: [ + 0, + 0, + 0, + 0, + -37, + -55, + -74, + -60 + ], + Vicircumflex: [ + 0, + 0, + 0, + 0, + -37, + 0, + -34, + -20 + ], + Vidieresis: [ + 0, + 0, + 0, + 0, + -37, + 0, + -34, + -20 + ], + Vigrave: [ + 0, + 0, + 0, + 0, + -37, + 0, + -34, + -20 + ], + Vimacron: [ + 0, + 0, + 0, + 0, + -37, + 0, + -34, + -20 + ], + Viogonek: [ + 0, + 0, + 0, + 0, + -37, + -55, + -74, + -60 + ], + Wi: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -40 + ], + Wiacute: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -40 + ], + Wiogonek: [ + 0, + 0, + 0, + 0, + -18, + -37, + -55, + -40 + ], + fi: [ + 0, + 0, + 0, + 0, + -25, + 0, + -20, + -20 + ], + gperiod: [ + 0, + 0, + 0, + 0, + -15, + 0, + -15 + ], + gbreveperiod: [ + 0, + 0, + 0, + 0, + -15, + 0, + -15 + ], + gcommaaccentperiod: [ + 0, + 0, + 0, + 0, + -15, + 0, + -15 + ], + iv: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + iacutev: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + icircumflexv: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + idieresisv: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + igravev: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + imacronv: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + iogonekv: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -25 + ], + ky: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + kyacute: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + kydieresis: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + kcommaaccenty: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + kcommaaccentyacute: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + kcommaaccentydieresis: [ + 0, + 0, + 0, + 0, + -15, + 0, + -10, + -15 + ], + quotedblleftA: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAacute: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAbreve: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAcircumflex: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAdieresis: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAgrave: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAmacron: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAogonek: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAring: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quotedblleftAtilde: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftA: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAacute: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAbreve: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAcircumflex: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAdieresis: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAgrave: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAmacron: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAogonek: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAring: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + quoteleftAtilde: [ + 0, + 0, + 0, + 0, + -10, + 0, + 0, + -80 + ], + re: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + reacute: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + recaron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + recircumflex: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + redieresis: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + redotaccent: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + regrave: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + remacron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + reogonek: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racutee: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteeacute: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteecaron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteecircumflex: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteedieresis: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteedotaccent: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteegrave: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteemacron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + racuteeogonek: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcarone: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaroneacute: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronecaron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronecircumflex: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronedieresis: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronedotaccent: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronegrave: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaronemacron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcaroneogonek: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccente: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccenteacute: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentecaron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentecircumflex: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentedieresis: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentedotaccent: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentegrave: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccentemacron: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + rcommaaccenteogonek: [ + 0, + 0, + 0, + 0, + -18, + 0, + -37 + ], + spaceA: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAacute: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAbreve: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAcircumflex: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAdieresis: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAgrave: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAmacron: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAogonek: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAring: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + spaceAtilde: [ + 0, + 0, + 0, + 0, + -55, + -37, + -18, + -55 + ], + Fi: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Fiacute: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Ficircumflex: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Fidieresis: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Figrave: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Fimacron: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + Fiogonek: [ + 0, + 0, + 0, + 0, + 0, + -40, + -45 + ], + eb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + eacuteb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + ecaronb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + ecircumflexb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + edieresisb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + edotaccentb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + egraveb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + emacronb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + eogonekb: [ + 0, + 0, + 0, + 0, + 0, + -10 + ], + ff: [ + 0, + 0, + 0, + 0, + 0, + -18, + -18, + -25 + ], + quoterightt: [ + 0, + 0, + 0, + 0, + 0, + -37, + -30, + -18 + ], + quoterighttcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + -37, + -30, + -18 + ], + Yicircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yidieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yigrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yimacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yacuteicircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yacuteidieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yacuteigrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Yacuteimacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Ydieresisicircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Ydieresisidieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Ydieresisigrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + Ydieresisimacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + -34 + ], + eg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + egbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + egcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eacuteg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eacutegbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eacutegcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecarong: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecarongbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecarongcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecircumflexg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecircumflexgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + ecircumflexgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edieresisg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edieresisgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edieresisgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edotaccentg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edotaccentgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + edotaccentgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + egraveg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + egravegbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + egravegcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + emacrong: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + emacrongbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + emacrongcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eogonekg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eogonekgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + eogonekgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -40, + -15 + ], + fiogonek: [ + 0, + 0, + 0, + 0, + 0, + 0, + -20 + ], + gcomma: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + gbrevecomma: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + gcommaaccentcomma: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + og: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ogbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ogcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + oacuteg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + oacutegbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + oacutegcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ocircumflexg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ocircumflexgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ocircumflexgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + odieresisg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + odieresisgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + odieresisgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ograveg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ogravegbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ogravegcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ohungarumlautg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ohungarumlautgbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + ohungarumlautgcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + omacrong: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + omacrongbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + omacrongcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + otildeg: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + otildegbreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + otildegcommaaccent: [ + 0, + 0, + 0, + 0, + 0, + 0, + -10 + ], + fiacute: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -20 + ], + ga: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gaacute: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gabreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gacircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gadieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gagrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gamacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gaogonek: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + garing: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gatilde: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbrevea: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveaacute: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveabreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveacircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveadieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveagrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveamacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveaogonek: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbrevearing: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gbreveatilde: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccenta: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentaacute: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentabreve: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentacircumflex: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentadieresis: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentagrave: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentamacron: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentaogonek: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentaring: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ], + gcommaaccentatilde: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5 + ] +}; +var data = { + attributes: attributes, + glyphWidths: glyphWidths, + kernPairs: kernPairs +}; + +const initFont = font => { + return [font.FontName, { + attributes: font, + glyphWidths: {}, + kernPairs: {} + }]; +}; +const expandData = data => { + const { + attributes, + glyphWidths, + kernPairs + } = data; + const fonts = attributes.map(initFont); + Object.keys(glyphWidths).forEach(key => { + glyphWidths[key].forEach((value, index) => { + if (value) fonts[index][1].glyphWidths[key] = value; + }); + }); + Object.keys(kernPairs).forEach(key => { + kernPairs[key].forEach((value, index) => { + if (value) fonts[index][1].kernPairs[key] = value; + }); + }); + return Object.fromEntries(fonts); +}; + +const STANDARD_FONTS = expandData(data); +const createStandardFont = PDFFont => class StandardFont extends PDFFont { + constructor(document, name, id) { + super(); + this.document = document; + this.name = name; + this.id = id; + this.font = AFMFont.fromJson(STANDARD_FONTS[this.name]); + this.ascender = this.font.ascender; + this.descender = this.font.descender; + this.bbox = this.font.bbox; + this.lineGap = this.font.lineGap; + } + embed() { + this.dictionary.data = { + Type: 'Font', + BaseFont: this.name, + Subtype: 'Type1', + Encoding: 'WinAnsiEncoding' + }; + return this.dictionary.end(); + } + encode(text) { + const encoded = this.font.encodeText(text); + const glyphs = this.font.glyphsForString(`${text}`); + const advances = this.font.advancesForGlyphs(glyphs); + const positions = []; + for (let i = 0; i < glyphs.length; i++) { + const glyph = glyphs[i]; + positions.push({ + xAdvance: advances[i], + yAdvance: 0, + xOffset: 0, + yOffset: 0, + advanceWidth: this.font.widthOfGlyph(glyph) + }); + } + return [encoded, positions]; + } + widthOfString(string, size) { + const glyphs = this.font.glyphsForString(`${string}`); + const advances = this.font.advancesForGlyphs(glyphs); + let width = 0; + for (let advance of Array.from(advances)) { + width += advance; + } + const scale = size / 1000; + return width * scale; + } + static isStandardFont(name) { + return name in STANDARD_FONTS; + } +}; + +const toHex = function () { + for (var _len = arguments.length, codePoints = new Array(_len), _key = 0; _key < _len; _key++) { + codePoints[_key] = arguments[_key]; + } + const codes = Array.from(codePoints).map(code => `0000${code.toString(16)}`.slice(-4)); + return codes.join(''); +}; +const createEmbeddedFont = PDFFont => class EmbeddedFont extends PDFFont { + constructor(document, font, id) { + super(); + this.document = document; + this.font = font; + this.id = id; + this.subset = this.font.createSubset(); + this.unicode = [[0]]; + this.widths = [this.font.getGlyph(0).advanceWidth]; + this.name = this.font.postscriptName; + this.scale = 1000 / this.font.unitsPerEm; + this.ascender = this.font.ascent * this.scale; + this.descender = this.font.descent * this.scale; + this.xHeight = this.font.xHeight * this.scale; + this.capHeight = this.font.capHeight * this.scale; + this.lineGap = this.font.lineGap * this.scale; + this.bbox = this.font.bbox; + this.layoutCache = Object.create(null); + } + layoutRun(text, features) { + // passing LTR To force fontkit to not reverse the string + const run = this.font.layout(text, features, undefined, undefined, 'ltr'); + + // Normalize position values + for (let i = 0; i < run.positions.length; i++) { + const position = run.positions[i]; + for (let key in position) { + position[key] *= this.scale; + } + position.advanceWidth = run.glyphs[i].advanceWidth * this.scale; + } + return run; + } + layoutCached(text) { + let cached; + if (cached = this.layoutCache[text]) { + return cached; + } + const run = this.layoutRun(text); + this.layoutCache[text] = run; + return run; + } + layout(text, features, onlyWidth) { + // Skip the cache if any user defined features are applied + if (onlyWidth == null) { + onlyWidth = false; + } + if (features) { + return this.layoutRun(text, features); + } + const glyphs = onlyWidth ? null : []; + const positions = onlyWidth ? null : []; + let advanceWidth = 0; + + // Split the string by words to increase cache efficiency. + // For this purpose, spaces and tabs are a good enough delimeter. + let last = 0; + let index = 0; + while (index <= text.length) { + let needle; + if (index === text.length && last < index || (needle = text.charAt(index), [' ', '\t'].includes(needle))) { + const run = this.layoutCached(text.slice(last, ++index)); + if (!onlyWidth) { + glyphs.push(...Array.from(run.glyphs || [])); + positions.push(...Array.from(run.positions || [])); + } + advanceWidth += run.advanceWidth; + last = index; + } else { + index++; + } + } + return { + glyphs, + positions, + advanceWidth + }; + } + encode(text, features) { + const { + glyphs, + positions + } = this.layout(text, features); + const res = []; + for (let i = 0; i < glyphs.length; i++) { + const glyph = glyphs[i]; + const gid = this.subset.includeGlyph(glyph.id); + res.push(`0000${gid.toString(16)}`.slice(-4)); + if (this.widths[gid] == null) { + this.widths[gid] = glyph.advanceWidth * this.scale; + } + if (this.unicode[gid] == null) { + this.unicode[gid] = glyph.codePoints; + } + } + return [res, positions]; + } + widthOfString(string, size, features) { + const width = this.layout(string, features, true).advanceWidth; + const scale = size / 1000; + return width * scale; + } + embed() { + const isCFF = this.subset.cff != null; + const fontFile = this.document.ref(); + if (isCFF) { + fontFile.data.Subtype = 'CIDFontType0C'; + } + fontFile.end(this.subset.encode()); + const familyClass = ((this.font['OS/2'] != null ? this.font['OS/2'].sFamilyClass : undefined) || 0) >> 8; + let flags = 0; + if (this.font.post.isFixedPitch) { + flags |= 1 << 0; + } + if (1 <= familyClass && familyClass <= 7) { + flags |= 1 << 1; + } + flags |= 1 << 2; // assume the font uses non-latin characters + if (familyClass === 10) { + flags |= 1 << 3; + } + if (this.font.head.macStyle.italic) { + flags |= 1 << 6; + } + + // generate a random tag (6 uppercase letters. 65 is the char code for 'A') + const tag = [0, 1, 2, 3, 4, 5].map(() => String.fromCharCode(Math.random() * 26 + 65)).join(''); + const name = tag + '+' + this.font.postscriptName; + const { + bbox + } = this.font; + const descriptor = this.document.ref({ + Type: 'FontDescriptor', + FontName: name, + Flags: flags, + FontBBox: [bbox.minX * this.scale, bbox.minY * this.scale, bbox.maxX * this.scale, bbox.maxY * this.scale], + ItalicAngle: this.font.italicAngle, + Ascent: this.ascender, + Descent: this.descender, + CapHeight: (this.font.capHeight || this.font.ascent) * this.scale, + XHeight: (this.font.xHeight || 0) * this.scale, + StemV: 0 + }); // not sure how to calculate this + + if (isCFF) { + descriptor.data.FontFile3 = fontFile; + } else { + descriptor.data.FontFile2 = fontFile; + } + descriptor.end(); + const descendantFontData = { + Type: 'Font', + Subtype: 'CIDFontType0', + BaseFont: name, + CIDSystemInfo: { + Registry: new String('Adobe'), + Ordering: new String('Identity'), + Supplement: 0 + }, + FontDescriptor: descriptor, + W: [0, this.widths] + }; + if (!isCFF) { + descendantFontData.Subtype = 'CIDFontType2'; + descendantFontData.CIDToGIDMap = 'Identity'; + } + const descendantFont = this.document.ref(descendantFontData); + descendantFont.end(); + this.dictionary.data = { + Type: 'Font', + Subtype: 'Type0', + BaseFont: name, + Encoding: 'Identity-H', + DescendantFonts: [descendantFont], + ToUnicode: this.toUnicodeCmap() + }; + return this.dictionary.end(); + } + + // Maps the glyph ids encoded in the PDF back to unicode strings + // Because of ligature substitutions and the like, there may be one or more + // unicode characters represented by each glyph. + toUnicodeCmap() { + const cmap = this.document.ref(); + let entries = []; + let unicodeMap = '/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo <<\n /Registry (Adobe)\n /Ordering (UCS)\n /Supplement 0\n>> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000>\nendcodespacerange'; + for (let [index, codePoints] of this.unicode.entries()) { + const encoded = []; + if (entries.length >= 100) { + unicodeMap += '\n' + entries.length + ' beginbfchar\n' + entries.join('\n') + '\nendbfchar'; + entries = []; + } + // encode codePoints to utf16 + for (let value of codePoints) { + if (value > 0xffff) { + value -= 0x10000; + encoded.push(toHex(value >>> 10 & 0x3ff | 0xd800)); + value = 0xdc00 | value & 0x3ff; + } + encoded.push(toHex(value)); + } + entries.push('<' + toHex(index) + '>' + '<' + encoded.join(' ') + '>'); + } + if (entries.length) { + unicodeMap += '\n' + entries.length + ' beginbfchar\n' + entries.join('\n') + '\nendbfchar\n'; + } + unicodeMap += 'endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend'; + cmap.end(unicodeMap); + return cmap; + } +}; + +class PDFFont { + static open(document, src, family, id) { + let font; + if (typeof src === 'string') { + if (StandardFont.isStandardFont(src)) { + return new StandardFont(document, src, id); + } + { + font = fontkit.openSync(src, family); + } + } else if (src instanceof Uint8Array) { + font = fontkit.create(src, family); + } else if (src instanceof ArrayBuffer) { + font = fontkit.create(new Uint8Array(src), family); + } else if (typeof src === 'object') { + font = src; + } + if (font == null) { + throw new Error('Not a supported font format or standard PDF font.'); + } + return new EmbeddedFont(document, font, id); + } + encode() { + throw new Error('Must be implemented by subclasses'); + } + widthOfString() { + throw new Error('Must be implemented by subclasses'); + } + ref() { + return this.dictionary != null ? this.dictionary : this.dictionary = this.document.ref(); + } + finalize() { + if (this.embedded || this.dictionary == null) { + return; + } + this.embed(); + return this.embedded = true; + } + embed() { + throw new Error('Must be implemented by subclasses'); + } + lineHeight(size, includeGap) { + if (includeGap == null) { + includeGap = false; + } + const gap = includeGap ? this.lineGap : 0; + return (this.ascender + gap - this.descender) / 1000 * size; + } +} +const StandardFont = createStandardFont(PDFFont); +const EmbeddedFont = createEmbeddedFont(PDFFont); + +var FontsMixin = { + initFonts() { + // Lookup table for embedded fonts + this._fontFamilies = {}; + this._fontCount = 0; + + // Font state + this._fontSize = 12; + this._font = null; + this._registeredFonts = {}; + + // Set the default font + return this.font('Helvetica'); + }, + font(src, family, size) { + let cacheKey; + let font; + if (typeof family === 'number') { + size = family; + family = null; + } + + // check registered fonts if src is a string + if (typeof src === 'string' && this._registeredFonts[src]) { + cacheKey = src; + ({ + src, + family + } = this._registeredFonts[src]); + } else { + cacheKey = family || src; + if (typeof cacheKey !== 'string') { + cacheKey = null; + } + } + if (size != null) { + this.fontSize(size); + } + + // fast path: check if the font is already in the PDF + if (font = this._fontFamilies[cacheKey]) { + this._font = font; + return this; + } + + // load the font + const id = `F${++this._fontCount}`; + this._font = PDFFont.open(this, src, family, id); + + // check for existing font familes with the same name already in the PDF + // useful if the font was passed as a buffer + if (font = this._fontFamilies[this._font.name]) { + this._font = font; + return this; + } + + // save the font for reuse later + if (cacheKey) { + this._fontFamilies[cacheKey] = this._font; + } + if (this._font.name) { + this._fontFamilies[this._font.name] = this._font; + } + return this; + }, + fontSize(_fontSize) { + this._fontSize = _fontSize; + return this; + }, + currentLineHeight(includeGap) { + if (includeGap == null) { + includeGap = false; + } + return this._font.lineHeight(this._fontSize, includeGap); + }, + registerFont(name, src, family) { + this._registeredFonts[name] = { + src, + family + }; + return this; + } +}; + +function PDFNumber(n) { + // PDF numbers are strictly 32bit + // so convert this number to the nearest 32bit number + // @see ISO 32000-1 Annex C.2 (real numbers) + return Math.fround(n); +} + +/** + * Measurement of size + * + * @typedef {number | `${number}` | `${number}${'em' | 'in' | 'px' | 'cm' | 'mm' | 'pc' | 'ex' | 'ch' | 'rem' | 'vw' | 'vmin' | 'vmax' | '%' | 'pt'}`} Size + */ + +/** + * Measurement of how wide something is, false means 0 and true means 1 + * + * @typedef {Size | boolean} Wideness + */ + +/** + * Side definitions + * - To define all sides, use a single value + * - To define up-down left-right, use a `[Y, X]` array + * - To define each side, use `[top, right, bottom, left]` array + * - Or `{vertical: SideValue, horizontal: SideValue}` + * - Or `{top: SideValue, right: SideValue, bottom: SideValue, left: SideValue}` + * + * @template T + * @typedef {T | [T, T] | [T, T, T, T] | { vertical: T; horizontal: T } | ExpandedSideDefinition} SideDefinition + **/ + +/** + * @template T + * @typedef {{ top: T; right: T; bottom: T; left: T }} ExpandedSideDefinition + */ + +/** + * Convert any side definition into a static structure + * + * @template S + * @template D + * @template O + * @template {S | D} T + * @param {SideDefinition} sides - The sides to convert + * @param {SideDefinition} defaultDefinition - The value to use when no definition is provided + * @param {function(T): O} transformer - The transformation to apply to the sides once normalized + * @returns {ExpandedSideDefinition} + */ +function normalizeSides(sides, defaultDefinition, transformer) { + if (defaultDefinition === void 0) { + defaultDefinition = undefined; + } + if (transformer === void 0) { + transformer = v => v; + } + if (sides === undefined || sides === null || typeof sides === 'object' && Object.keys(sides).length === 0) { + sides = defaultDefinition; + } + if (typeof sides !== 'object' || sides === null) { + sides = [sides, sides, sides, sides]; + } + if (Array.isArray(sides)) { + if (sides.length === 2) { + sides = { + vertical: sides[0], + horizontal: sides[1] + }; + } else { + sides = { + top: sides[0], + right: sides[1], + bottom: sides[2], + left: sides[3] + }; + } + } + if ('vertical' in sides || 'horizontal' in sides) { + sides = { + top: sides.vertical, + right: sides.horizontal, + bottom: sides.vertical, + left: sides.horizontal + }; + } + return { + top: transformer(sides.top), + right: transformer(sides.right), + bottom: transformer(sides.bottom), + left: transformer(sides.left) + }; +} + +/** + * Get cosine in degrees of a + * + * Rounding errors are handled + * @param a + * @returns {number} + */ +function cosine(a) { + if (a === 0) return 1; + if (a === 90) return 0; + if (a === 180) return -1; + if (a === 270) return 0; + return Math.cos(a * Math.PI / 180); +} + +/** + * Get sine in degrees of a + * + * Rounding errors are handled + * @param a + * @returns {number} + */ +function sine(a) { + if (a === 0) return 0; + if (a === 90) return 1; + if (a === 180) return 0; + if (a === 270) return -1; + return Math.sin(a * Math.PI / 180); +} + +const SOFT_HYPHEN = '\u00AD'; +const HYPHEN = '-'; +class LineWrapper extends EventEmitter { + constructor(document, options) { + super(); + this.document = document; + this.horizontalScaling = options.horizontalScaling || 100; + this.indent = (options.indent || 0) * this.horizontalScaling / 100; + this.characterSpacing = (options.characterSpacing || 0) * this.horizontalScaling / 100; + this.wordSpacing = (options.wordSpacing === 0) * this.horizontalScaling / 100; + this.columns = options.columns || 1; + this.columnGap = (options.columnGap != null ? options.columnGap : 18) * this.horizontalScaling / 100; // 1/4 inch + this.lineWidth = (options.width * this.horizontalScaling / 100 - this.columnGap * (this.columns - 1)) / this.columns; + this.spaceLeft = this.lineWidth; + this.startX = this.document.x; + this.startY = this.document.y; + this.column = 1; + this.ellipsis = options.ellipsis; + this.continuedX = 0; + this.features = options.features; + + // calculate the maximum Y position the text can appear at + if (options.height != null) { + this.height = options.height; + this.maxY = PDFNumber(this.startY + options.height); + } else { + this.maxY = PDFNumber(this.document.page.maxY()); + } + + // handle paragraph indents + this.on('firstLine', options => { + // if this is the first line of the text segment, and + // we're continuing where we left off, indent that much + // otherwise use the user specified indent option + const indent = this.continuedX || this.indent; + this.document.x += indent; + this.lineWidth -= indent; + + // if indentAllLines is set to true + // we're not resetting the indentation for this paragraph after the first line + if (options.indentAllLines) { + return; + } + + // otherwise we start the next line without indent + return this.once('line', () => { + this.document.x -= indent; + this.lineWidth += indent; + if (options.continued && !this.continuedX) { + this.continuedX = this.indent; + } + if (!options.continued) { + return this.continuedX = 0; + } + }); + }); + + // handle left aligning last lines of paragraphs + this.on('lastLine', options => { + const { + align + } = options; + if (align === 'justify') { + options.align = 'left'; + } + this.lastLine = true; + return this.once('line', () => { + this.document.y += options.paragraphGap || 0; + options.align = align; + return this.lastLine = false; + }); + }); + } + wordWidth(word) { + return this.document.widthOfString(word, this) + this.characterSpacing + this.wordSpacing; + } + canFit(word, w) { + if (word[word.length - 1] != SOFT_HYPHEN) { + return w <= this.spaceLeft; + } + return w + this.wordWidth(HYPHEN) <= this.spaceLeft; + } + eachWord(text, fn) { + // setup a unicode line breaker + let bk; + const breaker = new LineBreaker(text); + let last = null; + const wordWidths = Object.create(null); + while (bk = breaker.nextBreak()) { + var shouldContinue; + let word = text.slice((last != null ? last.position : undefined) || 0, bk.position); + let w = wordWidths[word] != null ? wordWidths[word] : wordWidths[word] = this.wordWidth(word); + + // if the word is longer than the whole line, chop it up + // TODO: break by grapheme clusters, not JS string characters + if (w > this.lineWidth + this.continuedX) { + // make some fake break objects + let lbk = last; + const fbk = {}; + while (word.length) { + // fit as much of the word as possible into the space we have + var l, mightGrow; + if (w > this.spaceLeft) { + // start our check at the end of our available space - this method is faster than a loop of each character and it resolves + // an issue with long loops when processing massive words, such as a huge number of spaces + l = Math.ceil(this.spaceLeft / (w / word.length)); + w = this.wordWidth(word.slice(0, l)); + mightGrow = w <= this.spaceLeft && l < word.length; + } else { + l = word.length; + } + let mustShrink = w > this.spaceLeft && l > 0; + // shrink or grow word as necessary after our near-guess above + while (mustShrink || mightGrow) { + if (mustShrink) { + w = this.wordWidth(word.slice(0, --l)); + mustShrink = w > this.spaceLeft && l > 0; + } else { + w = this.wordWidth(word.slice(0, ++l)); + mustShrink = w > this.spaceLeft && l > 0; + mightGrow = w <= this.spaceLeft && l < word.length; + } + } + + // check for the edge case where a single character cannot fit into a line. + if (l === 0 && this.spaceLeft === this.lineWidth) { + l = 1; + } + + // send a required break unless this is the last piece and a linebreak is not specified + fbk.required = bk.required || l < word.length; + shouldContinue = fn(word.slice(0, l), w, fbk, lbk); + lbk = { + required: false + }; + + // get the remaining piece of the word + word = word.slice(l); + w = this.wordWidth(word); + if (shouldContinue === false) { + break; + } + } + } else { + // otherwise just emit the break as it was given to us + shouldContinue = fn(word, w, bk, last); + } + if (shouldContinue === false) { + break; + } + last = bk; + } + } + wrap(text, options) { + // override options from previous continued fragments + this.horizontalScaling = options.horizontalScaling || 100; + if (options.indent != null) { + this.indent = options.indent * this.horizontalScaling / 100; + } + if (options.characterSpacing != null) { + this.characterSpacing = options.characterSpacing * this.horizontalScaling / 100; + } + if (options.wordSpacing != null) { + this.wordSpacing = options.wordSpacing * this.horizontalScaling / 100; + } + if (options.ellipsis != null) { + this.ellipsis = options.ellipsis; + } + + // make sure we're actually on the page + // and that the first line of is never by + // itself at the bottom of a page (orphans) + const nextY = this.document.y + this.document.currentLineHeight(true); + if (this.document.y > this.maxY || nextY > this.maxY) { + this.nextSection(); + } + let buffer = ''; + let textWidth = 0; + let wc = 0; + let lc = 0; + let { + y + } = this.document; // used to reset Y pos if options.continued (below) + const emitLine = () => { + options.textWidth = textWidth + this.wordSpacing * (wc - 1); + options.wordCount = wc; + options.lineWidth = this.lineWidth; + ({ + y + } = this.document); + this.emit('line', buffer, options, this); + return lc++; + }; + this.emit('sectionStart', options, this); + this.eachWord(text, (word, w, bk, last) => { + if (last == null || last.required) { + this.emit('firstLine', options, this); + this.spaceLeft = this.lineWidth; + } + if (this.canFit(word, w)) { + buffer += word; + textWidth += w; + wc++; + } + if (bk.required || !this.canFit(word, w)) { + // if the user specified a max height and an ellipsis, and is about to pass the + // max height and max columns after the next line, append the ellipsis + const lh = this.document.currentLineHeight(true); + if (this.height != null && this.ellipsis && PDFNumber(this.document.y + lh * 2) > this.maxY && this.column >= this.columns) { + if (this.ellipsis === true) { + this.ellipsis = '…'; + } // map default ellipsis character + buffer = buffer.replace(/\s+$/, ''); + textWidth = this.wordWidth(buffer + this.ellipsis); + + // remove characters from the buffer until the ellipsis fits + // to avoid infinite loop need to stop while-loop if buffer is empty string + while (buffer && textWidth > this.lineWidth) { + buffer = buffer.slice(0, -1).replace(/\s+$/, ''); + textWidth = this.wordWidth(buffer + this.ellipsis); + } + // need to add ellipsis only if there is enough space for it + if (textWidth <= this.lineWidth) { + buffer = buffer + this.ellipsis; + } + textWidth = this.wordWidth(buffer); + } + if (bk.required) { + if (w > this.spaceLeft) { + emitLine(); + buffer = word; + textWidth = w; + wc = 1; + } + this.emit('lastLine', options, this); + } + + // Previous entry is a soft hyphen - add visible hyphen. + if (buffer[buffer.length - 1] == SOFT_HYPHEN) { + buffer = buffer.slice(0, -1) + HYPHEN; + this.spaceLeft -= this.wordWidth(HYPHEN); + } + emitLine(); + + // if we've reached the edge of the page, + // continue on a new page or column + if (PDFNumber(this.document.y + lh) > this.maxY) { + const shouldContinue = this.nextSection(); + + // stop if we reached the maximum height + if (!shouldContinue) { + wc = 0; + buffer = ''; + return false; + } + } + + // reset the space left and buffer + if (bk.required) { + this.spaceLeft = this.lineWidth; + buffer = ''; + textWidth = 0; + return wc = 0; + } else { + // reset the space left and buffer + this.spaceLeft = this.lineWidth - w; + buffer = word; + textWidth = w; + return wc = 1; + } + } else { + return this.spaceLeft -= w; + } + }); + if (wc > 0) { + this.emit('lastLine', options, this); + emitLine(); + } + this.emit('sectionEnd', options, this); + + // if the wrap is set to be continued, save the X position + // to start the first line of the next segment at, and reset + // the y position + if (options.continued === true) { + if (lc > 1) { + this.continuedX = 0; + } + this.continuedX += options.textWidth || 0; + return this.document.y = y; + } else { + return this.document.x = this.startX; + } + } + nextSection(options) { + this.emit('sectionEnd', options, this); + if (++this.column > this.columns) { + // if a max height was specified by the user, we're done. + // otherwise, the default is to make a new page at the bottom. + if (this.height != null) { + return false; + } + this.document.continueOnNewPage(); + this.column = 1; + this.startY = this.document.page.margins.top; + this.maxY = this.document.page.maxY(); + this.document.x = this.startX; + if (this.document._fillColor) { + this.document.fillColor(...this.document._fillColor); + } + this.emit('pageBreak', options, this); + } else { + this.document.x += this.lineWidth + this.columnGap; + this.document.y = this.startY; + this.emit('columnBreak', options, this); + } + this.emit('sectionStart', options, this); + return true; + } +} + +const { + number +} = PDFObject; +var TextMixin = { + initText() { + this._line = this._line.bind(this); + + // Current coordinates + this.x = 0; + this.y = 0; + return this._lineGap = 0; + }, + lineGap(_lineGap) { + this._lineGap = _lineGap; + return this; + }, + moveDown(lines) { + if (lines == null) { + lines = 1; + } + this.y += this.currentLineHeight(true) * lines + this._lineGap; + return this; + }, + moveUp(lines) { + if (lines == null) { + lines = 1; + } + this.y -= this.currentLineHeight(true) * lines + this._lineGap; + return this; + }, + _text(text, x, y, options, lineCallback) { + options = this._initOptions(x, y, options); + + // Convert text to a string + text = text == null ? '' : `${text}`; + + // if the wordSpacing option is specified, remove multiple consecutive spaces + if (options.wordSpacing) { + text = text.replace(/\s{2,}/g, ' '); + } + const addStructure = () => { + if (options.structParent) { + options.structParent.add(this.struct(options.structType || 'P', [this.markStructureContent(options.structType || 'P')])); + } + }; + + // We can save some bytes if there is no rotation + if (options.rotation !== 0) { + this.save(); + this.rotate(-options.rotation, { + origin: [this.x, this.y] + }); + } + + // word wrapping + if (options.width) { + let wrapper = this._wrapper; + if (!wrapper) { + wrapper = new LineWrapper(this, options); + wrapper.on('line', lineCallback); + wrapper.on('firstLine', addStructure); + } + this._wrapper = options.continued ? wrapper : null; + this._textOptions = options.continued ? options : null; + wrapper.wrap(text, options); + + // render paragraphs as single lines + } else { + for (let line of text.split('\n')) { + addStructure(); + lineCallback(line, options); + } + } + + // Cleanup if there was a rotation + if (options.rotation !== 0) this.restore(); + return this; + }, + text(text, x, y, options) { + return this._text(text, x, y, options, this._line); + }, + widthOfString(string, options) { + if (options === void 0) { + options = {}; + } + const horizontalScaling = options.horizontalScaling || 100; + return (this._font.widthOfString(string, this._fontSize, options.features) + (options.characterSpacing || 0) * (string.length - 1)) * horizontalScaling / 100; + }, + /** + * Compute the bounding box of a string + * based on what will actually be rendered by `doc.text()` + * + * @param string - The string + * @param x - X position of text (defaults to this.x) + * @param y - Y position of text (defaults to this.y) + * @param options - Any text options (The same you would apply to `doc.text()`) + * @returns {{x: number, y: number, width: number, height: number}} + */ + boundsOfString(string, x, y, options) {}, + heightOfString(text, options) { + const { + x, + y + } = this; + options = this._initOptions(options); + options.height = Infinity; // don't break pages + + const lineGap = options.lineGap || this._lineGap || 0; + this._text(text, this.x, this.y, options, () => { + return this.y += this.currentLineHeight(true) + lineGap; + }); + const height = this.y - y; + this.x = x; + this.y = y; + return height; + }, + list(list, x, y, options, wrapper) { + options = this._initOptions(x, y, options); + const listType = options.listType || 'bullet'; + const unit = Math.round(this._font.ascender / 1000 * this._fontSize); + const midLine = unit / 2; + const r = options.bulletRadius || unit / 3; + const indent = options.textIndent || (listType === 'bullet' ? r * 5 : unit * 2); + const itemIndent = options.bulletIndent || (listType === 'bullet' ? r * 8 : unit * 2); + let level = 1; + const items = []; + const levels = []; + const numbers = []; + var flatten = function (list) { + let n = 1; + for (let i = 0; i < list.length; i++) { + const item = list[i]; + if (Array.isArray(item)) { + level++; + flatten(item); + level--; + } else { + items.push(item); + levels.push(level); + if (listType !== 'bullet') { + numbers.push(n++); + } + } + } + }; + flatten(list); + const label = function (n) { + switch (listType) { + case 'numbered': + return `${n}.`; + case 'lettered': + var letter = String.fromCharCode((n - 1) % 26 + 65); + var times = Math.floor((n - 1) / 26 + 1); + var text = Array(times + 1).join(letter); + return `${text}.`; + } + }; + const drawListItem = function (listItem, i) { + wrapper = new LineWrapper(this, options); + wrapper.on('line', this._line); + level = 1; + wrapper.once('firstLine', () => { + let item, itemType, labelType, bodyType; + if (options.structParent) { + if (options.structTypes) { + [itemType, labelType, bodyType] = options.structTypes; + } else { + [itemType, labelType, bodyType] = ['LI', 'Lbl', 'LBody']; + } + } + if (itemType) { + item = this.struct(itemType); + options.structParent.add(item); + } else if (options.structParent) { + item = options.structParent; + } + let l; + if ((l = levels[i++]) !== level) { + const diff = itemIndent * (l - level); + this.x += diff; + wrapper.lineWidth -= diff; + level = l; + } + if (item && (labelType || bodyType)) { + item.add(this.struct(labelType || bodyType, [this.markStructureContent(labelType || bodyType)])); + } + switch (listType) { + case 'bullet': + this.circle(this.x - indent + r, this.y + midLine, r); + this.fill(); + break; + case 'numbered': + case 'lettered': + var text = label(numbers[i - 1]); + this._fragment(text, this.x - indent, this.y, options); + break; + } + if (item && labelType && bodyType) { + item.add(this.struct(bodyType, [this.markStructureContent(bodyType)])); + } + if (item && item !== options.structParent) { + item.end(); + } + }); + wrapper.on('sectionStart', () => { + const pos = indent + itemIndent * (level - 1); + this.x += pos; + return wrapper.lineWidth -= pos; + }); + wrapper.on('sectionEnd', () => { + const pos = indent + itemIndent * (level - 1); + this.x -= pos; + return wrapper.lineWidth += pos; + }); + wrapper.wrap(listItem, options); + }; + for (let i = 0; i < items.length; i++) { + drawListItem.call(this, items[i], i); + } + return this; + }, + _initOptions(x, y, options) { + var _options$rotation; + if (x === void 0) { + x = {}; + } + if (options === void 0) { + options = {}; + } + if (typeof x === 'object') { + options = x; + x = null; + } + + // clone options object + const result = Object.assign({}, options); + + // extend options with previous values for continued text + if (this._textOptions) { + for (let key in this._textOptions) { + const val = this._textOptions[key]; + if (key !== 'continued') { + if (result[key] === undefined) { + result[key] = val; + } + } + } + } + + // Update the current position + if (x != null) { + this.x = x; + } + if (y != null) { + this.y = y; + } + + // wrap to margins if no x or y position passed + if (result.lineBreak !== false) { + if (result.width == null) { + result.width = this.page.width - this.x - this.page.margins.right; + } + result.width = Math.max(result.width, 0); + } + if (!result.columns) { + result.columns = 0; + } + if (result.columnGap == null) { + result.columnGap = 18; + } // 1/4 inch + + // Normalize rotation to between 0 - 360 + result.rotation = Number((_options$rotation = options.rotation) !== null && _options$rotation !== void 0 ? _options$rotation : 0) % 360; + if (result.rotation < 0) result.rotation += 360; + return result; + }, + _line(text, options, wrapper) { + if (options === void 0) { + options = {}; + } + this._fragment(text, this.x, this.y, options); + const lineGap = options.lineGap || this._lineGap || 0; + if (!wrapper) { + return this.x += this.widthOfString(text, options); + } else { + return this.y += this.currentLineHeight(true) + lineGap; + } + }, + _fragment(text, x, y, options) { + let dy, encoded, i, positions, textWidth, words; + text = `${text}`.replace(/\n/g, ''); + if (text.length === 0) { + return; + } + + // handle options + const align = options.align || 'left'; + let wordSpacing = options.wordSpacing || 0; + const characterSpacing = options.characterSpacing || 0; + const horizontalScaling = options.horizontalScaling || 100; + + // text alignments + if (options.width) { + switch (align) { + case 'right': + textWidth = this.widthOfString(text.replace(/\s+$/, ''), options); + x += options.lineWidth - textWidth; + break; + case 'center': + x += options.lineWidth / 2 - options.textWidth / 2; + break; + case 'justify': + // calculate the word spacing value + words = text.trim().split(/\s+/); + textWidth = this.widthOfString(text.replace(/\s+/g, ''), options); + var spaceWidth = this.widthOfString(' ') + characterSpacing; + wordSpacing = Math.max(0, (options.lineWidth - textWidth) / Math.max(1, words.length - 1) - spaceWidth); + break; + } + } + + // text baseline alignments based on http://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling + if (typeof options.baseline === 'number') { + dy = -options.baseline; + } else { + switch (options.baseline) { + case 'svg-middle': + dy = 0.5 * this._font.xHeight; + break; + case 'middle': + case 'svg-central': + dy = 0.5 * (this._font.descender + this._font.ascender); + break; + case 'bottom': + case 'ideographic': + dy = this._font.descender; + break; + case 'alphabetic': + dy = 0; + break; + case 'mathematical': + dy = 0.5 * this._font.ascender; + break; + case 'hanging': + dy = 0.8 * this._font.ascender; + break; + case 'top': + dy = this._font.ascender; + break; + default: + dy = this._font.ascender; + } + dy = dy / 1000 * this._fontSize; + } + + // calculate the actual rendered width of the string after word and character spacing + const renderedWidth = options.textWidth + wordSpacing * (options.wordCount - 1) + characterSpacing * (text.length - 1); + + // create link annotations if the link option is given + if (options.link != null) { + this.link(x, y, renderedWidth, this.currentLineHeight(), options.link); + } + if (options.goTo != null) { + this.goTo(x, y, renderedWidth, this.currentLineHeight(), options.goTo); + } + if (options.destination != null) { + this.addNamedDestination(options.destination, 'XYZ', x, y, null); + } + + // create underline + if (options.underline) { + this.save(); + if (!options.stroke) { + this.strokeColor(...(this._fillColor || [])); + } + const lineWidth = this._fontSize < 10 ? 0.5 : Math.floor(this._fontSize / 10); + this.lineWidth(lineWidth); + let lineY = y + this.currentLineHeight() - lineWidth; + this.moveTo(x, lineY); + this.lineTo(x + renderedWidth, lineY); + this.stroke(); + this.restore(); + } + + // create strikethrough line + if (options.strike) { + this.save(); + if (!options.stroke) { + this.strokeColor(...(this._fillColor || [])); + } + const lineWidth = this._fontSize < 10 ? 0.5 : Math.floor(this._fontSize / 10); + this.lineWidth(lineWidth); + let lineY = y + this.currentLineHeight() / 2; + this.moveTo(x, lineY); + this.lineTo(x + renderedWidth, lineY); + this.stroke(); + this.restore(); + } + this.save(); + + // oblique (angle in degrees or boolean) + if (options.oblique) { + let skew; + if (typeof options.oblique === 'number') { + skew = -Math.tan(options.oblique * Math.PI / 180); + } else { + skew = -0.25; + } + this.transform(1, 0, 0, 1, x, y); + this.transform(1, 0, skew, 1, -skew * dy, 0); + this.transform(1, 0, 0, 1, -x, -y); + } + + // flip coordinate system + this.transform(1, 0, 0, -1, 0, this.page.height); + y = this.page.height - y - dy; + + // add current font to page if necessary + if (this.page.fonts[this._font.id] == null) { + this.page.fonts[this._font.id] = this._font.ref(); + } + + // begin the text object + this.addContent('BT'); + + // text position + this.addContent(`1 0 0 1 ${number(x)} ${number(y)} Tm`); + + // font and font size + this.addContent(`/${this._font.id} ${number(this._fontSize)} Tf`); + + // rendering mode + const mode = options.fill && options.stroke ? 2 : options.stroke ? 1 : 0; + if (mode) { + this.addContent(`${mode} Tr`); + } + + // Character spacing + if (characterSpacing) { + this.addContent(`${number(characterSpacing)} Tc`); + } + + // Horizontal scaling + if (horizontalScaling !== 100) { + this.addContent(`${horizontalScaling} Tz`); + } + + // Add the actual text + // If we have a word spacing value, we need to encode each word separately + // since the normal Tw operator only works on character code 32, which isn't + // used for embedded fonts. + if (wordSpacing) { + words = text.trim().split(/\s+/); + wordSpacing += this.widthOfString(' ') + characterSpacing; + wordSpacing *= 1000 / this._fontSize; + encoded = []; + positions = []; + for (let word of words) { + const [encodedWord, positionsWord] = this._font.encode(word, options.features); + encoded = encoded.concat(encodedWord); + positions = positions.concat(positionsWord); + + // add the word spacing to the end of the word + // clone object because of cache + const space = {}; + const object = positions[positions.length - 1]; + for (let key in object) { + const val = object[key]; + space[key] = val; + } + space.xAdvance += wordSpacing; + positions[positions.length - 1] = space; + } + } else { + [encoded, positions] = this._font.encode(text, options.features); + } + const scale = this._fontSize / 1000; + const commands = []; + let last = 0; + let hadOffset = false; + + // Adds a segment of text to the TJ command buffer + const addSegment = cur => { + if (last < cur) { + const hex = encoded.slice(last, cur).join(''); + const advance = positions[cur - 1].xAdvance - positions[cur - 1].advanceWidth; + commands.push(`<${hex}> ${number(-advance)}`); + } + return last = cur; + }; + + // Flushes the current TJ commands to the output stream + const flush = i => { + addSegment(i); + if (commands.length > 0) { + this.addContent(`[${commands.join(' ')}] TJ`); + return commands.length = 0; + } + }; + for (i = 0; i < positions.length; i++) { + // If we have an x or y offset, we have to break out of the current TJ command + // so we can move the text position. + const pos = positions[i]; + if (pos.xOffset || pos.yOffset) { + // Flush the current buffer + flush(i); + + // Move the text position and flush just the current character + this.addContent(`1 0 0 1 ${number(x + pos.xOffset * scale)} ${number(y + pos.yOffset * scale)} Tm`); + flush(i + 1); + hadOffset = true; + } else { + // If the last character had an offset, reset the text position + if (hadOffset) { + this.addContent(`1 0 0 1 ${number(x)} ${number(y)} Tm`); + hadOffset = false; + } + + // Group segments that don't have any advance adjustments + if (pos.xAdvance - pos.advanceWidth !== 0) { + addSegment(i + 1); + } + } + x += pos.xAdvance * scale; + } + + // Flush any remaining commands + flush(i); + + // end the text object + this.addContent('ET'); + + // restore flipped coordinate system + return this.restore(); + } +}; + +const COLOR_SPACE_MAP = { + 1: 'DeviceGray', + 3: 'DeviceRGB', + 4: 'DeviceCMYK' +}; +class JPEG { + constructor(data, label) { + this.data = data; + this.label = label; + this.orientation = 1; + if (this.data.readUInt16BE(0) !== 0xffd8) { + throw 'SOI not found in JPEG'; + } + const markers = _JPEG.decode(this.data); + for (let i = 0; i < markers.length; i += 1) { + const marker = markers[i]; + if (marker.name === 'EXIF' && marker.entries.orientation) { + this.orientation = marker.entries.orientation; + } + if (marker.name === 'SOF') { + this.bits ||= marker.precision; + this.width ||= marker.width; + this.height ||= marker.height; + this.colorSpace ||= COLOR_SPACE_MAP[marker.numberOfComponents]; + } + } + this.obj = null; + } + embed(document) { + if (this.obj) { + return; + } + this.obj = document.ref({ + Type: 'XObject', + Subtype: 'Image', + BitsPerComponent: this.bits, + Width: this.width, + Height: this.height, + ColorSpace: this.colorSpace, + Filter: 'DCTDecode' + }); + + // add extra decode params for CMYK images. By swapping the + // min and max values from the default, we invert the colors. See + // section 4.8.4 of the spec. + if (this.colorSpace === 'DeviceCMYK') { + this.obj.data['Decode'] = [1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0]; + } + this.obj.end(this.data); + + // free memory + return this.data = null; + } +} + +class PNGImage { + constructor(data, label) { + this.label = label; + this.image = new PNG(data); + this.width = this.image.width; + this.height = this.image.height; + this.imgData = this.image.imgData; + this.obj = null; + } + embed(document) { + let dataDecoded = false; + this.document = document; + if (this.obj) { + return; + } + const hasAlphaChannel = this.image.hasAlphaChannel; + const isInterlaced = this.image.interlaceMethod === 1; + this.obj = this.document.ref({ + Type: 'XObject', + Subtype: 'Image', + BitsPerComponent: hasAlphaChannel ? 8 : this.image.bits, + Width: this.width, + Height: this.height, + Filter: 'FlateDecode' + }); + if (!hasAlphaChannel) { + const params = this.document.ref({ + Predictor: isInterlaced ? 1 : 15, + Colors: this.image.colors, + BitsPerComponent: this.image.bits, + Columns: this.width + }); + this.obj.data['DecodeParms'] = params; + params.end(); + } + if (this.image.palette.length === 0) { + this.obj.data['ColorSpace'] = this.image.colorSpace; + } else { + // embed the color palette in the PDF as an object stream + const palette = this.document.ref(); + palette.end(Buffer.from(this.image.palette)); + + // build the color space array for the image + this.obj.data['ColorSpace'] = ['Indexed', 'DeviceRGB', this.image.palette.length / 3 - 1, palette]; + } + + // For PNG color types 0, 2 and 3, the transparency data is stored in + // a dedicated PNG chunk. + if (this.image.transparency.grayscale != null) { + // Use Color Key Masking (spec section 4.8.5) + // An array with N elements, where N is two times the number of color components. + const val = this.image.transparency.grayscale; + this.obj.data['Mask'] = [val, val]; + } else if (this.image.transparency.rgb) { + // Use Color Key Masking (spec section 4.8.5) + // An array with N elements, where N is two times the number of color components. + const { + rgb + } = this.image.transparency; + const mask = []; + for (let x of rgb) { + mask.push(x, x); + } + this.obj.data['Mask'] = mask; + } else if (this.image.transparency.indexed) { + // Create a transparency SMask for the image based on the data + // in the PLTE and tRNS sections. See below for details on SMasks. + dataDecoded = true; + return this.loadIndexedAlphaChannel(); + } else if (hasAlphaChannel) { + // For PNG color types 4 and 6, the transparency data is stored as a alpha + // channel mixed in with the main image data. Separate this data out into an + // SMask object and store it separately in the PDF. + dataDecoded = true; + return this.splitAlphaChannel(); + } + if (isInterlaced && !dataDecoded) { + return this.decodeData(); + } + this.finalize(); + } + finalize() { + if (this.alphaChannel) { + const sMask = this.document.ref({ + Type: 'XObject', + Subtype: 'Image', + Height: this.height, + Width: this.width, + BitsPerComponent: 8, + Filter: 'FlateDecode', + ColorSpace: 'DeviceGray', + Decode: [0, 1] + }); + sMask.end(this.alphaChannel); + this.obj.data['SMask'] = sMask; + } + + // add the actual image data + this.obj.end(this.imgData); + + // free memory + this.image = null; + return this.imgData = null; + } + splitAlphaChannel() { + return this.image.decodePixels(pixels => { + let a, p; + const colorCount = this.image.colors; + const pixelCount = this.width * this.height; + const imgData = Buffer.alloc(pixelCount * colorCount); + const alphaChannel = Buffer.alloc(pixelCount); + let i = p = a = 0; + const len = pixels.length; + // For 16bit images copy only most significant byte (MSB) - PNG data is always stored in network byte order (MSB first) + const skipByteCount = this.image.bits === 16 ? 1 : 0; + while (i < len) { + for (let colorIndex = 0; colorIndex < colorCount; colorIndex++) { + imgData[p++] = pixels[i++]; + i += skipByteCount; + } + alphaChannel[a++] = pixels[i++]; + i += skipByteCount; + } + this.imgData = zlib.deflateSync(imgData); + this.alphaChannel = zlib.deflateSync(alphaChannel); + return this.finalize(); + }); + } + loadIndexedAlphaChannel() { + const transparency = this.image.transparency.indexed; + const isInterlaced = this.image.interlaceMethod === 1; + return this.image.decodePixels(pixels => { + const alphaChannel = Buffer.alloc(this.width * this.height); + let i = 0; + for (let j = 0, end = pixels.length; j < end; j++) { + alphaChannel[i++] = transparency[pixels[j]]; + } + + // For interlaced images, re-encode the decoded pixel data + if (isInterlaced) { + this.imgData = zlib.deflateSync(Buffer.from(pixels)); + } + this.alphaChannel = zlib.deflateSync(alphaChannel); + return this.finalize(); + }); + } + decodeData() { + this.image.decodePixels(pixels => { + this.imgData = zlib.deflateSync(pixels); + this.finalize(); + }); + } +} + +/* +PDFImage - embeds images in PDF documents +By Devon Govett +*/ + +class PDFImage { + static open(src, label) { + let data; + if (Buffer.isBuffer(src)) { + data = src; + } else if (src instanceof ArrayBuffer) { + data = Buffer.from(new Uint8Array(src)); + } else { + const match = /^data:.+?;base64,(.*)$/.exec(src); + if (match) { + data = Buffer.from(match[1], 'base64'); + } else { + data = fs.readFileSync(src); + if (!data) { + return; + } + } + } + if (data[0] === 0xff && data[1] === 0xd8) { + return new JPEG(data, label); + } else if (data[0] === 0x89 && data.toString('ascii', 1, 4) === 'PNG') { + return new PNGImage(data, label); + } else { + throw new Error('Unknown image format.'); + } + } +} + +var ImagesMixin = { + initImages() { + this._imageRegistry = {}; + return this._imageCount = 0; + }, + image(src, x, y, options) { + if (options === void 0) { + options = {}; + } + let bh, bp, bw, image, ip, left, left1, rotateAngle, originX, originY; + if (typeof x === 'object') { + options = x; + x = null; + } + + // Ignore orientation based on document options or image options + const ignoreOrientation = options.ignoreOrientation || options.ignoreOrientation !== false && this.options.ignoreOrientation; + x = (left = x != null ? x : options.x) != null ? left : this.x; + y = (left1 = y != null ? y : options.y) != null ? left1 : this.y; + if (typeof src === 'string') { + image = this._imageRegistry[src]; + } + if (!image) { + if (src.width && src.height) { + image = src; + } else { + image = this.openImage(src); + } + } + if (!image.obj) { + image.embed(this); + } + if (this.page.xobjects[image.label] == null) { + this.page.xobjects[image.label] = image.obj; + } + let { + width, + height + } = image; + + // If EXIF orientation calls for it, swap width and height + if (!ignoreOrientation && image.orientation > 4) { + [width, height] = [height, width]; + } + let w = options.width || width; + let h = options.height || height; + if (options.width && !options.height) { + const wp = w / width; + w = width * wp; + h = height * wp; + } else if (options.height && !options.width) { + const hp = h / height; + w = width * hp; + h = height * hp; + } else if (options.scale) { + w = width * options.scale; + h = height * options.scale; + } else if (options.fit) { + [bw, bh] = options.fit; + bp = bw / bh; + ip = width / height; + if (ip > bp) { + w = bw; + h = bw / ip; + } else { + h = bh; + w = bh * ip; + } + } else if (options.cover) { + [bw, bh] = options.cover; + bp = bw / bh; + ip = width / height; + if (ip > bp) { + h = bh; + w = bh * ip; + } else { + w = bw; + h = bw / ip; + } + } + if (options.fit || options.cover) { + if (options.align === 'center') { + x = x + bw / 2 - w / 2; + } else if (options.align === 'right') { + x = x + bw - w; + } + if (options.valign === 'center') { + y = y + bh / 2 - h / 2; + } else if (options.valign === 'bottom') { + y = y + bh - h; + } + } + if (!ignoreOrientation) { + switch (image.orientation) { + // No orientation (need to flip image, though, because of the default transform matrix on the document) + default: + case 1: + h = -h; + y -= h; + rotateAngle = 0; + break; + // Flip Horizontal + case 2: + w = -w; + h = -h; + x -= w; + y -= h; + rotateAngle = 0; + break; + // Rotate 180 degrees + case 3: + originX = x; + originY = y; + h = -h; + x -= w; + rotateAngle = 180; + break; + // Flip vertical + case 4: + // Do nothing, image will be flipped + + break; + // Flip horizontally and rotate 270 degrees CW + case 5: + originX = x; + originY = y; + [w, h] = [h, w]; + y -= h; + rotateAngle = 90; + break; + // Rotate 90 degrees CW + case 6: + originX = x; + originY = y; + [w, h] = [h, w]; + h = -h; + rotateAngle = 90; + break; + // Flip horizontally and rotate 90 degrees CW + case 7: + originX = x; + originY = y; + [w, h] = [h, w]; + h = -h; + w = -w; + x -= w; + rotateAngle = 90; + break; + // Rotate 270 degrees CW + case 8: + originX = x; + originY = y; + [w, h] = [h, w]; + h = -h; + x -= w; + y -= h; + rotateAngle = -90; + break; + } + } else { + h = -h; + y -= h; + rotateAngle = 0; + } + + // create link annotations if the link option is given + if (options.link != null) { + this.link(x, y, w, h, options.link); + } + if (options.goTo != null) { + this.goTo(x, y, w, h, options.goTo); + } + if (options.destination != null) { + this.addNamedDestination(options.destination, 'XYZ', x, y, null); + } + + // Set the current y position to below the image if it is in the document flow + if (this.y === y) { + this.y += h; + } + this.save(); + if (rotateAngle) { + this.rotate(rotateAngle, { + origin: [originX, originY] + }); + } + this.transform(w, 0, 0, h, x, y); + this.addContent(`/${image.label} Do`); + this.restore(); + return this; + }, + openImage(src) { + let image; + if (typeof src === 'string') { + image = this._imageRegistry[src]; + } + if (!image) { + image = PDFImage.open(src, `I${++this._imageCount}`); + if (typeof src === 'string') { + this._imageRegistry[src] = image; + } + } + return image; + } +}; + +var AnnotationsMixin = { + annotate(x, y, w, h, options) { + options.Type = 'Annot'; + options.Rect = this._convertRect(x, y, w, h); + options.Border = [0, 0, 0]; + if (options.Subtype === 'Link' && typeof options.F === 'undefined') { + options.F = 1 << 2; // Print Annotation Flag + } + if (options.Subtype !== 'Link') { + if (options.C == null) { + options.C = this._normalizeColor(options.color || [0, 0, 0]); + } + } // convert colors + delete options.color; + if (typeof options.Dest === 'string') { + options.Dest = new String(options.Dest); + } + + // Capitalize keys + for (let key in options) { + const val = options[key]; + options[key[0].toUpperCase() + key.slice(1)] = val; + } + const ref = this.ref(options); + this.page.annotations.push(ref); + ref.end(); + return this; + }, + note(x, y, w, h, contents, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Text'; + options.Contents = new String(contents); + if (options.Name == null) { + options.Name = 'Comment'; + } + if (options.color == null) { + options.color = [243, 223, 92]; + } + return this.annotate(x, y, w, h, options); + }, + goTo(x, y, w, h, name, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Link'; + options.A = this.ref({ + S: 'GoTo', + D: new String(name) + }); + options.A.end(); + return this.annotate(x, y, w, h, options); + }, + link(x, y, w, h, url, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Link'; + if (typeof url === 'number') { + // Link to a page in the document (the page must already exist) + const pages = this._root.data.Pages.data; + if (url >= 0 && url < pages.Kids.length) { + options.A = this.ref({ + S: 'GoTo', + D: [pages.Kids[url], 'XYZ', null, null, null] + }); + options.A.end(); + } else { + throw new Error(`The document has no page ${url}`); + } + } else { + // Link to an external url + options.A = this.ref({ + S: 'URI', + URI: new String(url) + }); + options.A.end(); + } + return this.annotate(x, y, w, h, options); + }, + _markup(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + const [x1, y1, x2, y2] = this._convertRect(x, y, w, h); + options.QuadPoints = [x1, y2, x2, y2, x1, y1, x2, y1]; + options.Contents = new String(); + return this.annotate(x, y, w, h, options); + }, + highlight(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Highlight'; + if (options.color == null) { + options.color = [241, 238, 148]; + } + return this._markup(x, y, w, h, options); + }, + underline(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Underline'; + return this._markup(x, y, w, h, options); + }, + strike(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'StrikeOut'; + return this._markup(x, y, w, h, options); + }, + lineAnnotation(x1, y1, x2, y2, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Line'; + options.Contents = new String(); + options.L = [x1, this.page.height - y1, x2, this.page.height - y2]; + return this.annotate(x1, y1, x2, y2, options); + }, + rectAnnotation(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Square'; + options.Contents = new String(); + return this.annotate(x, y, w, h, options); + }, + ellipseAnnotation(x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'Circle'; + options.Contents = new String(); + return this.annotate(x, y, w, h, options); + }, + textAnnotation(x, y, w, h, text, options) { + if (options === void 0) { + options = {}; + } + options.Subtype = 'FreeText'; + options.Contents = new String(text); + options.DA = new String(); + return this.annotate(x, y, w, h, options); + }, + fileAnnotation(x, y, w, h, file, options) { + if (file === void 0) { + file = {}; + } + if (options === void 0) { + options = {}; + } + // create hidden file + const filespec = this.file(file.src, Object.assign({ + hidden: true + }, file)); + options.Subtype = 'FileAttachment'; + options.FS = filespec; + + // add description from filespec unless description (Contents) has already been set + if (options.Contents) { + options.Contents = new String(options.Contents); + } else if (filespec.data.Desc) { + options.Contents = filespec.data.Desc; + } + return this.annotate(x, y, w, h, options); + }, + _convertRect(x1, y1, w, h) { + // flip y1 and y2 + let y2 = y1; + y1 += h; + + // make x2 + let x2 = x1 + w; + + // apply current transformation matrix to points + const [m0, m1, m2, m3, m4, m5] = this._ctm; + x1 = m0 * x1 + m2 * y1 + m4; + y1 = m1 * x1 + m3 * y1 + m5; + x2 = m0 * x2 + m2 * y2 + m4; + y2 = m1 * x2 + m3 * y2 + m5; + return [x1, y1, x2, y2]; + } +}; + +/* Custom fork start */ +const DEFAULT_OPTIONS = { + top: 0, + left: 0, + zoom: 0, + fit: false, + pageNumber: null, + expanded: false +}; +/* Custom fork end */ + +class PDFOutline { + constructor(document, parent, title, dest, options) { + if (options === void 0) { + options = DEFAULT_OPTIONS; + } + this.document = document; + this.options = options; + this.outlineData = {}; + if (dest !== null) { + /* Custom fork start */ + const destWidth = dest.data.MediaBox[2]; + const destHeight = dest.data.MediaBox[3]; + const top = destHeight - (options.top || 0); + const left = destWidth - (options.left || 0); + const zoom = options.zoom || 0; + this.outlineData['Dest'] = options.fit ? [dest, 'Fit'] : [dest, 'XYZ', left, top, zoom]; + /* Custom fork end */ + } + if (parent !== null) { + this.outlineData['Parent'] = parent; + } + if (title !== null) { + this.outlineData['Title'] = new String(title); + } + this.dictionary = this.document.ref(this.outlineData); + this.children = []; + } + addItem(title, options) { + if (options === void 0) { + options = DEFAULT_OPTIONS; + } + /* Custom fork start */ + const pages = this.document._root.data.Pages.data.Kids; + const dest = options.pageNumber !== null ? pages[options.pageNumber] : this.document.page.dictionary; + /* Custom fork end */ + + const result = new PDFOutline(this.document, this.dictionary, title, dest, options); + this.children.push(result); + return result; + } + endOutline() { + if (this.children.length > 0) { + if (this.options.expanded) { + this.outlineData.Count = this.children.length; + } + const first = this.children[0], + last = this.children[this.children.length - 1]; + this.outlineData.First = first.dictionary; + this.outlineData.Last = last.dictionary; + for (let i = 0, len = this.children.length; i < len; i++) { + const child = this.children[i]; + if (i > 0) { + child.outlineData.Prev = this.children[i - 1].dictionary; + } + if (i < this.children.length - 1) { + child.outlineData.Next = this.children[i + 1].dictionary; + } + child.endOutline(); + } + } + return this.dictionary.end(); + } +} + +var OutlineMixin = { + initOutline() { + return this.outline = new PDFOutline(this, null, null, null); + }, + endOutline() { + this.outline.endOutline(); + if (this.outline.children.length > 0) { + this._root.data.Outlines = this.outline.dictionary; + /* Custom fork start */ + return this._root.data.PageMode = this._root.data.PageMode || 'UseOutlines'; + /* Custom fork end */ + } + } +}; + +/* +PDFStructureContent - a reference to a marked structure content +By Ben Schmidt +*/ + +class PDFStructureContent { + constructor(pageRef, mcid) { + this.refs = [{ + pageRef, + mcid + }]; + } + push(structContent) { + structContent.refs.forEach(ref => this.refs.push(ref)); + } +} + +/* +PDFStructureElement - represents an element in the PDF logical structure tree +By Ben Schmidt +*/ + +class PDFStructureElement { + constructor(document, type, options, children) { + if (options === void 0) { + options = {}; + } + if (children === void 0) { + children = null; + } + this.document = document; + this._attached = false; + this._ended = false; + this._flushed = false; + this.dictionary = document.ref({ + // Type: "StructElem", + S: type + }); + const data = this.dictionary.data; + if (Array.isArray(options) || this._isValidChild(options)) { + children = options; + options = {}; + } + if (typeof options.title !== 'undefined') { + data.T = new String(options.title); + } + if (typeof options.lang !== 'undefined') { + data.Lang = new String(options.lang); + } + if (typeof options.alt !== 'undefined') { + data.Alt = new String(options.alt); + } + if (typeof options.expanded !== 'undefined') { + data.E = new String(options.expanded); + } + if (typeof options.actual !== 'undefined') { + data.ActualText = new String(options.actual); + } + this._children = []; + if (children) { + if (!Array.isArray(children)) { + children = [children]; + } + children.forEach(child => this.add(child)); + this.end(); + } + } + add(child) { + if (this._ended) { + throw new Error(`Cannot add child to already-ended structure element`); + } + if (!this._isValidChild(child)) { + throw new Error(`Invalid structure element child`); + } + if (child instanceof PDFStructureElement) { + child.setParent(this.dictionary); + if (this._attached) { + child.setAttached(); + } + } + if (child instanceof PDFStructureContent) { + this._addContentToParentTree(child); + } + if (typeof child === 'function' && this._attached) { + // _contentForClosure() adds the content to the parent tree + child = this._contentForClosure(child); + } + this._children.push(child); + return this; + } + _addContentToParentTree(content) { + content.refs.forEach(_ref => { + let { + pageRef, + mcid + } = _ref; + const pageStructParents = this.document.getStructParentTree().get(pageRef.data.StructParents); + pageStructParents[mcid] = this.dictionary; + }); + } + setParent(parentRef) { + if (this.dictionary.data.P) { + throw new Error(`Structure element added to more than one parent`); + } + this.dictionary.data.P = parentRef; + this._flush(); + } + setAttached() { + if (this._attached) { + return; + } + this._children.forEach((child, index) => { + if (child instanceof PDFStructureElement) { + child.setAttached(); + } + if (typeof child === 'function') { + this._children[index] = this._contentForClosure(child); + } + }); + this._attached = true; + this._flush(); + } + end() { + if (this._ended) { + return; + } + this._children.filter(child => child instanceof PDFStructureElement).forEach(child => child.end()); + this._ended = true; + this._flush(); + } + _isValidChild(child) { + return child instanceof PDFStructureElement || child instanceof PDFStructureContent || typeof child === 'function'; + } + _contentForClosure(closure) { + const content = this.document.markStructureContent(this.dictionary.data.S); + closure(); + this.document.endMarkedContent(); + this._addContentToParentTree(content); + return content; + } + _isFlushable() { + if (!this.dictionary.data.P || !this._ended) { + return false; + } + return this._children.every(child => { + if (typeof child === 'function') { + return false; + } + if (child instanceof PDFStructureElement) { + return child._isFlushable(); + } + return true; + }); + } + _flush() { + if (this._flushed || !this._isFlushable()) { + return; + } + this.dictionary.data.K = []; + this._children.forEach(child => this._flushChild(child)); + this.dictionary.end(); + + // free memory used by children; the dictionary itself may still be + // referenced by a parent structure element or root, but we can + // at least trim the tree here + this._children = []; + this.dictionary.data.K = null; + this._flushed = true; + } + _flushChild(child) { + if (child instanceof PDFStructureElement) { + this.dictionary.data.K.push(child.dictionary); + } + if (child instanceof PDFStructureContent) { + child.refs.forEach(_ref2 => { + let { + pageRef, + mcid + } = _ref2; + if (!this.dictionary.data.Pg) { + this.dictionary.data.Pg = pageRef; + } + if (this.dictionary.data.Pg === pageRef) { + this.dictionary.data.K.push(mcid); + } else { + this.dictionary.data.K.push({ + Type: 'MCR', + Pg: pageRef, + MCID: mcid + }); + } + }); + } + } +} + +/* +PDFNumberTree - represents a number tree object +*/ + +class PDFNumberTree extends PDFTree { + _compareKeys(a, b) { + return parseInt(a) - parseInt(b); + } + _keysName() { + return 'Nums'; + } + _dataForKey(k) { + return parseInt(k); + } +} + +/* +Markings mixin - support marked content sequences in content streams +By Ben Schmidt +*/ + +var MarkingsMixin = { + initMarkings(options) { + this.structChildren = []; + if (options.tagged) { + this.getMarkInfoDictionary().data.Marked = true; + this.getStructTreeRoot(); + } + }, + markContent(tag, options) { + if (options === void 0) { + options = null; + } + if (tag === 'Artifact' || options && options.mcid) { + let toClose = 0; + this.page.markings.forEach(marking => { + if (toClose || marking.structContent || marking.tag === 'Artifact') { + toClose++; + } + }); + while (toClose--) { + this.endMarkedContent(); + } + } + if (!options) { + this.page.markings.push({ + tag + }); + this.addContent(`/${tag} BMC`); + return this; + } + this.page.markings.push({ + tag, + options + }); + const dictionary = {}; + if (typeof options.mcid !== 'undefined') { + dictionary.MCID = options.mcid; + } + if (tag === 'Artifact') { + if (typeof options.type === 'string') { + dictionary.Type = options.type; + } + if (Array.isArray(options.bbox)) { + dictionary.BBox = [options.bbox[0], this.page.height - options.bbox[3], options.bbox[2], this.page.height - options.bbox[1]]; + } + if (Array.isArray(options.attached) && options.attached.every(val => typeof val === 'string')) { + dictionary.Attached = options.attached; + } + } + if (tag === 'Span') { + if (options.lang) { + dictionary.Lang = new String(options.lang); + } + if (options.alt) { + dictionary.Alt = new String(options.alt); + } + if (options.expanded) { + dictionary.E = new String(options.expanded); + } + if (options.actual) { + dictionary.ActualText = new String(options.actual); + } + } + this.addContent(`/${tag} ${PDFObject.convert(dictionary)} BDC`); + return this; + }, + markStructureContent(tag, options) { + if (options === void 0) { + options = {}; + } + const pageStructParents = this.getStructParentTree().get(this.page.structParentTreeKey); + const mcid = pageStructParents.length; + pageStructParents.push(null); + this.markContent(tag, { + ...options, + mcid + }); + const structContent = new PDFStructureContent(this.page.dictionary, mcid); + this.page.markings.slice(-1)[0].structContent = structContent; + return structContent; + }, + endMarkedContent() { + this.page.markings.pop(); + this.addContent('EMC'); + return this; + }, + struct(type, options, children) { + if (options === void 0) { + options = {}; + } + if (children === void 0) { + children = null; + } + return new PDFStructureElement(this, type, options, children); + }, + addStructure(structElem) { + const structTreeRoot = this.getStructTreeRoot(); + structElem.setParent(structTreeRoot); + structElem.setAttached(); + this.structChildren.push(structElem); + if (!structTreeRoot.data.K) { + structTreeRoot.data.K = []; + } + structTreeRoot.data.K.push(structElem.dictionary); + return this; + }, + initPageMarkings(pageMarkings) { + pageMarkings.forEach(marking => { + if (marking.structContent) { + const structContent = marking.structContent; + const newStructContent = this.markStructureContent(marking.tag, marking.options); + structContent.push(newStructContent); + this.page.markings.slice(-1)[0].structContent = structContent; + } else { + this.markContent(marking.tag, marking.options); + } + }); + }, + endPageMarkings(page) { + const pageMarkings = page.markings; + pageMarkings.forEach(() => page.write('EMC')); + page.markings = []; + return pageMarkings; + }, + getMarkInfoDictionary() { + if (!this._root.data.MarkInfo) { + this._root.data.MarkInfo = this.ref({}); + } + return this._root.data.MarkInfo; + }, + hasMarkInfoDictionary() { + return !!this._root.data.MarkInfo; + }, + getStructTreeRoot() { + if (!this._root.data.StructTreeRoot) { + this._root.data.StructTreeRoot = this.ref({ + Type: 'StructTreeRoot', + ParentTree: new PDFNumberTree(), + ParentTreeNextKey: 0 + }); + } + return this._root.data.StructTreeRoot; + }, + getStructParentTree() { + return this.getStructTreeRoot().data.ParentTree; + }, + createStructParentTreeNextKey() { + // initialise the MarkInfo dictionary + this.getMarkInfoDictionary(); + const structTreeRoot = this.getStructTreeRoot(); + const key = structTreeRoot.data.ParentTreeNextKey++; + structTreeRoot.data.ParentTree.add(key, []); + return key; + }, + endMarkings() { + const structTreeRoot = this._root.data.StructTreeRoot; + if (structTreeRoot) { + structTreeRoot.end(); + this.structChildren.forEach(structElem => structElem.end()); + } + if (this._root.data.MarkInfo) { + this._root.data.MarkInfo.end(); + } + } +}; + +const FIELD_FLAGS = { + readOnly: 1, + required: 2, + noExport: 4, + multiline: 0x1000, + password: 0x2000, + toggleToOffButton: 0x4000, + radioButton: 0x8000, + pushButton: 0x10000, + combo: 0x20000, + edit: 0x40000, + sort: 0x80000, + multiSelect: 0x200000, + noSpell: 0x400000 +}; +const FIELD_JUSTIFY = { + left: 0, + center: 1, + right: 2 +}; +const VALUE_MAP = { + value: 'V', + defaultValue: 'DV' +}; +const FORMAT_SPECIAL = { + zip: '0', + zipPlus4: '1', + zip4: '1', + phone: '2', + ssn: '3' +}; +const FORMAT_DEFAULT = { + number: { + nDec: 0, + sepComma: false, + negStyle: 'MinusBlack', + currency: '', + currencyPrepend: true + }, + percent: { + nDec: 0, + sepComma: false + } +}; +var AcroFormMixin = { + /** + * Must call if adding AcroForms to a document. Must also call font() before + * this method to set the default font. + */ + initForm() { + if (!this._font) { + throw new Error('Must set a font before calling initForm method'); + } + this._acroform = { + fonts: {}, + defaultFont: this._font.name + }; + this._acroform.fonts[this._font.id] = this._font.ref(); + let data = { + Fields: [], + NeedAppearances: true, + DA: new String(`/${this._font.id} 0 Tf 0 g`), + DR: { + Font: {} + } + }; + data.DR.Font[this._font.id] = this._font.ref(); + const AcroForm = this.ref(data); + this._root.data.AcroForm = AcroForm; + return this; + }, + /** + * Called automatically by document.js + */ + endAcroForm() { + if (this._root.data.AcroForm) { + if (!Object.keys(this._acroform.fonts).length && !this._acroform.defaultFont) { + throw new Error('No fonts specified for PDF form'); + } + let fontDict = this._root.data.AcroForm.data.DR.Font; + Object.keys(this._acroform.fonts).forEach(name => { + fontDict[name] = this._acroform.fonts[name]; + }); + this._root.data.AcroForm.data.Fields.forEach(fieldRef => { + this._endChild(fieldRef); + }); + this._root.data.AcroForm.end(); + } + return this; + }, + _endChild(ref) { + if (Array.isArray(ref.data.Kids)) { + ref.data.Kids.forEach(childRef => { + this._endChild(childRef); + }); + ref.end(); + } + return this; + }, + /** + * Creates and adds a form field to the document. Form fields are intermediate + * nodes in a PDF form that are used to specify form name heirarchy and form + * value defaults. + * @param {string} name - field name (T attribute in field dictionary) + * @param {object} options - other attributes to include in field dictionary + */ + formField(name, options) { + if (options === void 0) { + options = {}; + } + let fieldDict = this._fieldDict(name, null, options); + let fieldRef = this.ref(fieldDict); + this._addToParent(fieldRef); + return fieldRef; + }, + /** + * Creates and adds a Form Annotation to the document. Form annotations are + * called Widget annotations internally within a PDF file. + * @param {string} name - form field name (T attribute of widget annotation + * dictionary) + * @param {number} x + * @param {number} y + * @param {number} w + * @param {number} h + * @param {object} options + */ + formAnnotation(name, type, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + let fieldDict = this._fieldDict(name, type, options); + fieldDict.Subtype = 'Widget'; + if (fieldDict.F === undefined) { + fieldDict.F = 4; // print the annotation + } + + // Add Field annot to page, and get it's ref + this.annotate(x, y, w, h, fieldDict); + let annotRef = this.page.annotations[this.page.annotations.length - 1]; + return this._addToParent(annotRef); + }, + formText(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'text', x, y, w, h, options); + }, + formPushButton(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'pushButton', x, y, w, h, options); + }, + formCombo(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'combo', x, y, w, h, options); + }, + formList(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'list', x, y, w, h, options); + }, + formRadioButton(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'radioButton', x, y, w, h, options); + }, + formCheckbox(name, x, y, w, h, options) { + if (options === void 0) { + options = {}; + } + return this.formAnnotation(name, 'checkbox', x, y, w, h, options); + }, + _addToParent(fieldRef) { + let parent = fieldRef.data.Parent; + if (parent) { + if (!parent.data.Kids) { + parent.data.Kids = []; + } + parent.data.Kids.push(fieldRef); + } else { + this._root.data.AcroForm.data.Fields.push(fieldRef); + } + return this; + }, + _fieldDict(name, type, options) { + if (options === void 0) { + options = {}; + } + if (!this._acroform) { + throw new Error('Call document.initForm() method before adding form elements to document'); + } + let opts = Object.assign({}, options); + if (type !== null) { + opts = this._resolveType(type, options); + } + opts = this._resolveFlags(opts); + opts = this._resolveJustify(opts); + opts = this._resolveFont(opts); + opts = this._resolveStrings(opts); + opts = this._resolveColors(opts); + opts = this._resolveFormat(opts); + opts.T = new String(name); + if (opts.parent) { + opts.Parent = opts.parent; + delete opts.parent; + } + return opts; + }, + _resolveType(type, opts) { + if (type === 'text') { + opts.FT = 'Tx'; + } else if (type === 'pushButton') { + opts.FT = 'Btn'; + opts.pushButton = true; + } else if (type === 'radioButton') { + opts.FT = 'Btn'; + opts.radioButton = true; + } else if (type === 'checkbox') { + opts.FT = 'Btn'; + } else if (type === 'combo') { + opts.FT = 'Ch'; + opts.combo = true; + } else if (type === 'list') { + opts.FT = 'Ch'; + } else { + throw new Error(`Invalid form annotation type '${type}'`); + } + return opts; + }, + _resolveFormat(opts) { + const f = opts.format; + if (f && f.type) { + let fnKeystroke; + let fnFormat; + let params = ''; + if (FORMAT_SPECIAL[f.type] !== undefined) { + fnKeystroke = `AFSpecial_Keystroke`; + fnFormat = `AFSpecial_Format`; + params = FORMAT_SPECIAL[f.type]; + } else { + let format = f.type.charAt(0).toUpperCase() + f.type.slice(1); + fnKeystroke = `AF${format}_Keystroke`; + fnFormat = `AF${format}_Format`; + if (f.type === 'date') { + fnKeystroke += 'Ex'; + params = String(f.param); + } else if (f.type === 'time') { + params = String(f.param); + } else if (f.type === 'number') { + let p = Object.assign({}, FORMAT_DEFAULT.number, f); + params = String([String(p.nDec), p.sepComma ? '0' : '1', '"' + p.negStyle + '"', 'null', '"' + p.currency + '"', String(p.currencyPrepend)].join(',')); + } else if (f.type === 'percent') { + let p = Object.assign({}, FORMAT_DEFAULT.percent, f); + params = String([String(p.nDec), p.sepComma ? '0' : '1'].join(',')); + } + } + opts.AA = opts.AA ? opts.AA : {}; + opts.AA.K = { + S: 'JavaScript', + JS: new String(`${fnKeystroke}(${params});`) + }; + opts.AA.F = { + S: 'JavaScript', + JS: new String(`${fnFormat}(${params});`) + }; + } + delete opts.format; + return opts; + }, + _resolveColors(opts) { + let color = this._normalizeColor(opts.backgroundColor); + if (color) { + if (!opts.MK) { + opts.MK = {}; + } + opts.MK.BG = color; + } + color = this._normalizeColor(opts.borderColor); + if (color) { + if (!opts.MK) { + opts.MK = {}; + } + opts.MK.BC = color; + } + delete opts.backgroundColor; + delete opts.borderColor; + return opts; + }, + _resolveFlags(options) { + let result = 0; + Object.keys(options).forEach(key => { + if (FIELD_FLAGS[key]) { + if (options[key]) { + result |= FIELD_FLAGS[key]; + } + delete options[key]; + } + }); + if (result !== 0) { + options.Ff = options.Ff ? options.Ff : 0; + options.Ff |= result; + } + return options; + }, + _resolveJustify(options) { + let result = 0; + if (options.align !== undefined) { + if (typeof FIELD_JUSTIFY[options.align] === 'number') { + result = FIELD_JUSTIFY[options.align]; + } + delete options.align; + } + if (result !== 0) { + options.Q = result; // default + } + return options; + }, + _resolveFont(options) { + // add current font to document-level AcroForm dict if necessary + if (this._acroform.fonts[this._font.id] == null) { + this._acroform.fonts[this._font.id] = this._font.ref(); + } + + // add current font to field's resource dict (RD) if not the default acroform font + if (this._acroform.defaultFont !== this._font.name) { + options.DR = { + Font: {} + }; + + // Get the fontSize option. If not set use auto sizing + const fontSize = options.fontSize || 0; + options.DR.Font[this._font.id] = this._font.ref(); + options.DA = new String(`/${this._font.id} ${fontSize} Tf 0 g`); + } + return options; + }, + _resolveStrings(options) { + let select = []; + function appendChoices(a) { + if (Array.isArray(a)) { + for (let idx = 0; idx < a.length; idx++) { + if (typeof a[idx] === 'string') { + select.push(new String(a[idx])); + } else { + select.push(a[idx]); + } + } + } + } + appendChoices(options.Opt); + if (options.select) { + appendChoices(options.select); + delete options.select; + } + if (select.length) { + options.Opt = select; + } + Object.keys(VALUE_MAP).forEach(key => { + if (options[key] !== undefined) { + options[VALUE_MAP[key]] = options[key]; + delete options[key]; + } + }); + ['V', 'DV'].forEach(key => { + if (typeof options[key] === 'string') { + options[key] = new String(options[key]); + } + }); + if (options.MK && options.MK.CA) { + options.MK.CA = new String(options.MK.CA); + } + if (options.label) { + options.MK = options.MK ? options.MK : {}; + options.MK.CA = new String(options.label); + delete options.label; + } + return options; + } +}; + +var AttachmentsMixin = { + /** + * Embed contents of `src` in PDF + * @param {Buffer | ArrayBuffer | string} src input Buffer, ArrayBuffer, base64 encoded string or path to file + * @param {object} options + * * options.name: filename to be shown in PDF, will use `src` if none set + * * options.type: filetype to be shown in PDF + * * options.description: description to be shown in PDF + * * options.hidden: if true, do not add attachment to EmbeddedFiles dictionary. Useful for file attachment annotations + * * options.creationDate: override creation date + * * options.modifiedDate: override modified date + * * options.relationship: Relationship between the PDF document and its attached file. Can be 'Alternative', 'Data', 'Source', 'Supplement' or 'Unspecified'. + * @returns filespec reference + */ + file(src, options) { + if (options === void 0) { + options = {}; + } + options.name = options.name || src; + options.relationship = options.relationship || 'Unspecified'; + const refBody = { + Type: 'EmbeddedFile', + Params: {} + }; + let data; + if (!src) { + throw new Error('No src specified'); + } + if (Buffer.isBuffer(src)) { + data = src; + } else if (src instanceof ArrayBuffer) { + data = Buffer.from(new Uint8Array(src)); + } else { + let match; + if (match = /^data:(.*?);base64,(.*)$/.exec(src)) { + if (match[1]) { + refBody.Subtype = match[1].replace('/', '#2F'); + } + data = Buffer.from(match[2], 'base64'); + } else { + data = fs.readFileSync(src); + if (!data) { + throw new Error(`Could not read contents of file at filepath ${src}`); + } + + // update CreationDate and ModDate + const { + birthtime, + ctime + } = fs.statSync(src); + refBody.Params.CreationDate = birthtime; + refBody.Params.ModDate = ctime; + } + } + + // override creation date and modified date + if (options.creationDate instanceof Date) { + refBody.Params.CreationDate = options.creationDate; + } + if (options.modifiedDate instanceof Date) { + refBody.Params.ModDate = options.modifiedDate; + } + // add optional subtype + if (options.type) { + refBody.Subtype = options.type.replace('/', '#2F'); + } + + // add checksum and size information + const checksum = md5Hex(new Uint8Array(data)); + refBody.Params.CheckSum = new String(checksum); + refBody.Params.Size = data.byteLength; + + // save some space when embedding the same file again + // if a file with the same name and metadata exists, reuse its reference + let ref; + if (!this._fileRegistry) this._fileRegistry = {}; + let file = this._fileRegistry[options.name]; + if (file && isEqual(refBody, file)) { + ref = file.ref; + } else { + ref = this.ref(refBody); + ref.end(data); + this._fileRegistry[options.name] = { + ...refBody, + ref + }; + } + // add filespec for embedded file + const fileSpecBody = { + Type: 'Filespec', + AFRelationship: options.relationship, + F: new String(options.name), + EF: { + F: ref + }, + UF: new String(options.name) + }; + if (options.description) { + fileSpecBody.Desc = new String(options.description); + } + const filespec = this.ref(fileSpecBody); + filespec.end(); + if (!options.hidden) { + this.addNamedEmbeddedFile(options.name, filespec); + } + + // Add file to the catalogue to be PDF/A3 compliant + if (this._root.data.AF) { + this._root.data.AF.push(filespec); + } else { + this._root.data.AF = [filespec]; + } + return filespec; + } +}; + +/** check two embedded file metadata objects for equality */ +function isEqual(a, b) { + return a.Subtype === b.Subtype && a.Params.CheckSum.toString() === b.Params.CheckSum.toString() && a.Params.Size === b.Params.Size && a.Params.CreationDate.getTime() === b.Params.CreationDate.getTime() && (a.Params.ModDate === undefined && b.Params.ModDate === undefined || a.Params.ModDate.getTime() === b.Params.ModDate.getTime()); +} + +var PDFA = { + initPDFA(pSubset) { + if (pSubset.charAt(pSubset.length - 3) === '-') { + this.subset_conformance = pSubset.charAt(pSubset.length - 1).toUpperCase(); + this.subset = parseInt(pSubset.charAt(pSubset.length - 2)); + } else { + // Default to Basic conformance when user doesn't specify + this.subset_conformance = 'B'; + this.subset = parseInt(pSubset.charAt(pSubset.length - 1)); + } + }, + endSubset() { + this._addPdfaMetadata(); + this._addColorOutputIntent(); + }, + _addColorOutputIntent() { + const iccProfile = fs.readFileSync(`${__dirname}/data/sRGB_IEC61966_2_1.icc`); + const colorProfileRef = this.ref({ + Length: iccProfile.length, + N: 3 + }); + colorProfileRef.write(iccProfile); + colorProfileRef.end(); + const intentRef = this.ref({ + Type: 'OutputIntent', + S: 'GTS_PDFA1', + Info: new String('sRGB IEC61966-2.1'), + OutputConditionIdentifier: new String('sRGB IEC61966-2.1'), + DestOutputProfile: colorProfileRef + }); + intentRef.end(); + this._root.data.OutputIntents = [intentRef]; + }, + _getPdfaid() { + return ` + + ${this.subset} + ${this.subset_conformance} + + `; + }, + _addPdfaMetadata() { + this.appendXML(this._getPdfaid()); + } +}; + +var PDFUA = { + initPDFUA() { + this.subset = 1; + }, + endSubset() { + this._addPdfuaMetadata(); + }, + _addPdfuaMetadata() { + this.appendXML(this._getPdfuaid()); + }, + _getPdfuaid() { + return ` + + ${this.subset} + + `; + } +}; + +var SubsetMixin = { + _importSubset(subset) { + Object.assign(this, subset); + }, + initSubset(options) { + switch (options.subset) { + case 'PDF/A-1': + case 'PDF/A-1a': + case 'PDF/A-1b': + case 'PDF/A-2': + case 'PDF/A-2a': + case 'PDF/A-2b': + case 'PDF/A-3': + case 'PDF/A-3a': + case 'PDF/A-3b': + this._importSubset(PDFA); + this.initPDFA(options.subset); + break; + case 'PDF/UA': + this._importSubset(PDFUA); + this.initPDFUA(); + break; + } + } +}; + +/** + * @template T + * @typedef {function(number): T} Dynamic + */ + +/** + * @typedef {Object} Font + * @property {PDFFontSource} [src] + * The name of the font + * + * Defaults to the current document font source `doc._fontSrc` + * @property {string} [family] + * The font family of the font + * + * Defaults to the current document font family `doc._fontFamily` + * @property {Size} [size] + * The size of the font + * + * Defaults to the current document font size `doc._fontSize` + */ + +/** + * Measurement of how wide something is, false means 0 and true means 1 + * + * @typedef {Size | boolean} Wideness + */ + +/** + * The value of the text of a cell + * @typedef {string | null | undefined} TableCellText + */ + +/** @typedef {Object} TableCellStyle + * + * @property {TableCellText} [text] + * The text of the table cell + * @property {number} [rowSpan] + * Number of rows the cell spans. + * + * Defaults to `1`. + * @property {number} [colSpan] + * Number of columns the cell spans. + * + * Defaults to `1`. + * @property {SideDefinition} [padding] + * Controls the padding of the cell text + * + * Defaults to `0.25em` + * @property {SideDefinition} [border] + * Controls the thickness of the cells borders. + * + * Defaults to `[1, 1, 1, 1]`. + * @property {SideDefinition} [borderColor] + * Color of the border on each side of the cell. + * + * Defaults to the border color defined by the given table layout, or `black` on all sides. + * @property {Font} [font] + * Font options for the cell + * + * Defaults to the documents current font + * @property {PDFColor} [backgroundColor] + * Set the background color of the cell + * + * Defaults to transparent + * @property {'center' | ExpandedAlign} [align] + * Sets the text alignment of the cells text + * + * Defaults to `{x: 'left', y: 'top'}` + * @property {Size} [textStroke] + * Sets the text stroke width of the cells text + * + * Defaults to `0` + * @property {PDFColor} [textStrokeColor] + * Sets the text stroke color of the cells text + * + * Defaults to `black` + * @property {PDFColor} [textColor] + * Sets the text color of the cells text + * + * Defaults to `black` + * @property {'TH' | 'TD'} [type] + * Sets the cell type (for accessibility) + * + * Defaults to `TD` + * @property {Object} [textOptions] + * Sets any advanced text options passed into the cell renderer + * + * Same as the options you pass to `doc.text()` + * + * Will override any defaults set by the cell if set + * @property {string} [title] + * Sets the accessible title for the cell + * @property {'Column' | 'Row' | 'Both'} [scope] + * Sets the accessible scope for the cell + * @property {string} [id] + * Sets the accessible id for the cell + * + * Defaults to `--` + * @property {boolean} [debug] + * Whether to show the debug lines for the cell + * + * Defaults to `false` + */ +/** @typedef {TableCellText | TableCellStyle} TableCell **/ + +/** + * The width of the column + * + * - `*` distributes equally, filling the whole available space + * - `%` computes the proportion of the max size + * + * Defaults to `*` + * @typedef {Size | '*'} ColumnWidth + */ + +/** + * @typedef {Object} ColumnStyle + * @extends TableCellStyle + * + * @property {ColumnWidth} [width] + * @property {Size} [minWidth] + * The minimum width of the column + * + * Defaults to `0` + * @property {Size} [maxWidth] + * The maximum width of the column + * + * Defaults to `undefined` meaning no max + */ +/** @typedef {ColumnStyle | ColumnWidth} Column **/ + +/** + * @typedef {Object} NormalizedColumnStyle + * @extends ColumnStyle + * + * @property {number | '*'} width + * @property {number} minWidth + * @property {number} maxWidth + */ + +/** + * The height of the row + * + * - A fixed value sets an absolute height for every row. + * - `auto` sets the height based on the text. + * + * `%` values are based on page content height + * + * Defaults to `auto` + * @typedef {Size | 'auto'} RowHeight + */ + +/** + * @typedef {Object} RowStyle + * @extends TableCellStyle + * + * @property {RowHeight} [height] + * @property {Size} [minHeight] + * The minimum height of the row + * + * `%` values are based on page content height + * + * Defaults to `0` + * @property {Size} [maxHeight] + * The maximum height of the row + * + * `%` values are based on page content height + * + * Defaults to `undefined` meaning no max + */ +/** @typedef {RowStyle | RowHeight} Row **/ + +/** + * @typedef {Object} NormalizedRowStyle + * @extends RowStyle + * + * @property {number | 'auto'} height + * @property {number} minHeight + * @property {number} maxHeight + */ + +/** @typedef {'left' | 'center' | 'right' | 'justify'} AlignX **/ +/** @typedef {'top' | 'center' | 'bottom'} AlignY **/ +/** + * @typedef {Object} ExpandedAlign + * @property {AlignX} [x] + * @property {AlignY} [y] + */ + +/** + * @typedef {Object} DefaultTableCellStyle + * + * @extends ColumnStyle + * @extends RowStyle + * @extends TableCellStyle + */ +/** @typedef {TableCellText | DefaultTableCellStyle} DefaultTableCell **/ + +/** + * @typedef {Object} NormalizedDefaultTableCellStyle + * + * @extends NormalizedColumnStyle + * @extends NormalizedRowStyle + * @extends TableCellStyle + */ + +/** + * @typedef {Object} NormalizedTableCellStyle + * + * @extends NormalizedColumnStyle + * @extends NormalizedRowStyle + * @extends TableCellStyle + * + * @property {number} rowIndex + * @property {number} rowSpan + * @property {number} colIndex + * @property {number} colSpan + * + * @property {string} text + * @property {Font} font + * @property {boolean} customFont + * @property {ExpandedSideDefinition} padding + * @property {ExpandedSideDefinition} border + * @property {ExpandedSideDefinition} borderColor + * @property {ExpandedAlign} align + * @property {number} textStroke + * @property {PDFColor} textStrokeColor + * @property {PDFColor} textColor + * @property {number} minWidth + * @property {number} maxWidth + * @property {number} minHeight + * @property {number} maxHeight + * @property {Object} textOptions + */ + +/** + * @typedef {Object} SizedNormalizedTableCellStyle + * + * @extends {NormalizedTableCellStyle} + * + * @property {number} x + * @property {number} y + * @property {number} textX + * @property {number} textY + * @property {number} width + * @property {number} height + * @property {number} textAllocatedWidth + * @property {number} textAllocatedHeight + * @property {{x: number, y: number, width: number, height: number}} textBounds + */ + +/** + * @typedef {Object} Table + * + * @property {Position} [position] + * The position of the table + * + * Defaults to the current document position `{x: doc.x, y: doc.y}` + * @property {Size} [maxWidth] + * The maximum width the table can expand to + * + * Defaults to the remaining content width (offset from the tables position) + * @property {Column | Column[] | Dynamic} [columnStyles] + * Column definitions of the table. + * - A fixed value sets the config for every column + * - Use an array or a callback function to control the column config for each column individually. + * + * Defaults to `auto` + * @property {Row | Row[] | Dynamic} [rowStyles] + * Row definitions of the table. + * - A fixed value sets the config for every column + * - Use an array or a callback function to control the row config of each row individually. + * + * The given values are ignored for rows whose text is higher. + * + * Defaults to `*`. + * @property {DefaultTableCell} [defaultStyle] + * Defaults to apply to every cell + * @property {Iterable>} [data] + * Two-dimensional iterable that defines the table's data. + * + * With the first dimension being the row, and the second being the column + * + * If provided the table will be automatically ended after the last row has been written, + * Otherwise it is up to the user to call `table.end()` or `table.row([], true)` + * @property {PDFStructureElement} [structParent] + * The parent structure to mount to + * + * This will cause the entire table to be enclosed in a Table structure + * with TR and TD/TH for cells + * @property {string} [id] + * Sets the accessible id for the table + * + * Defaults to `table-` + * @property {boolean} [debug] + * Whether to show the debug lines for all the cells + * + * Defaults to `false` + */ + +/** + * Fields exclusive to row styles + * @type {string[]} + */ +const ROW_FIELDS = ['height', 'minHeight', 'maxHeight']; +/** + * Fields exclusive to column styles + * @type {string[]} + */ +const COLUMN_FIELDS = ['width', 'minWidth', 'maxWidth']; +function memoize(fn, maxSize) { + const cache = new Map(); + return function () { + const key = arguments.length <= 0 ? undefined : arguments[0]; + if (!cache.has(key)) { + cache.set(key, fn(...arguments)); + if (cache.size > maxSize) cache.delete(cache.keys().next()); + } + return cache.get(key); + }; +} + +/** + * Simple object check. + * @param item + * @returns {boolean} + */ +function isObject(item) { + return item && typeof item === 'object' && !Array.isArray(item); +} + +/** + * Deep merge two objects. + * + * @template T + * @param {T} target + * @param sources + * @returns {T} + */ +function deepMerge(target) { + if (!isObject(target)) return target; + target = deepClone(target); + for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + sources[_key - 1] = arguments[_key]; + } + for (const source of sources) { + if (isObject(source)) { + for (const key in source) { + if (isObject(source[key])) { + if (!(key in target)) target[key] = {}; + target[key] = deepMerge(target[key], source[key]); + } else if (source[key] !== undefined) { + target[key] = deepClone(source[key]); + } + } + } + } + return target; +} +function deepClone(obj) { + let result = obj; + if (obj && typeof obj == 'object') { + result = Array.isArray(obj) ? [] : {}; + for (const key in obj) result[key] = deepClone(obj[key]); + } + return result; +} + +/** + * Normalize the row config + * @note The context here is the cell not the document + * + * @param {DefaultTableCell} [defaultStyleInternal] + * @returns {{ + * defaultStyle: TableCellStyle, + * defaultRowStyle: RowStyle, + * defaultColStyle: ColumnStyle + * }} + * @private + */ +function normalizedDefaultStyle(defaultStyleInternal) { + let defaultStyle = defaultStyleInternal; + // Force object form + if (typeof defaultStyle !== 'object') defaultStyle = { + text: defaultStyle + }; + const defaultRowStyle = Object.fromEntries(Object.entries(defaultStyle).filter(_ref => { + let [k] = _ref; + return ROW_FIELDS.includes(k); + })); + const defaultColStyle = Object.fromEntries(Object.entries(defaultStyle).filter(_ref2 => { + let [k] = _ref2; + return COLUMN_FIELDS.includes(k); + })); + defaultStyle.padding = normalizeSides(defaultStyle.padding); + defaultStyle.border = normalizeSides(defaultStyle.border); + defaultStyle.borderColor = normalizeSides(defaultStyle.borderColor); + defaultStyle.align = normalizeAlignment(defaultStyle.align); + return { + defaultStyle, + defaultRowStyle, + defaultColStyle + }; +} + +/** + * Normalize the row config + * + * @note The context here is the cell not the document + * + * @this PDFTable + * @memberOf PDFTable + * @param {RowStyle} defaultRowStyle + * @param {Dynamic} rowStyleInternal + * @param {number} i The target row + * @returns {NormalizedRowStyle} + * @private + */ +function normalizedRowStyle(defaultRowStyle, rowStyleInternal, i) { + let rowStyle = rowStyleInternal(i); + // Force object form + if (rowStyle == null || typeof rowStyle !== 'object') { + rowStyle = { + height: rowStyle + }; + } + // Normalize + rowStyle.padding = normalizeSides(rowStyle.padding); + rowStyle.border = normalizeSides(rowStyle.border); + rowStyle.borderColor = normalizeSides(rowStyle.borderColor); + rowStyle.align = normalizeAlignment(rowStyle.align); + + // Merge defaults + rowStyle = deepMerge(defaultRowStyle, rowStyle); + const document = this.document; + const page = document.page; + const contentHeight = page.contentHeight; + if (rowStyle.height == null || rowStyle.height === 'auto') { + rowStyle.height = 'auto'; + } else { + rowStyle.height = document.sizeToPoint(rowStyle.height, 0, page, contentHeight); + } + rowStyle.minHeight = document.sizeToPoint(rowStyle.minHeight, 0, page, contentHeight); + rowStyle.maxHeight = document.sizeToPoint(rowStyle.maxHeight, 0, page, contentHeight); + return rowStyle; +} + +/** + * Normalize the column config + * + * @note The context here is the document not the cell + * + * @param {ColumnStyle} defaultColStyle + * @param {Dynamic} colStyleInternal + * @param {number} i - The target column + * @returns {NormalizedColumnStyle} + * @private + */ +function normalizedColumnStyle(defaultColStyle, colStyleInternal, i) { + let colStyle = colStyleInternal(i); + // Force object form + if (colStyle == null || typeof colStyle !== 'object') { + colStyle = { + width: colStyle + }; + } + // Normalize + colStyle.padding = normalizeSides(colStyle.padding); + colStyle.border = normalizeSides(colStyle.border); + colStyle.borderColor = normalizeSides(colStyle.borderColor); + colStyle.align = normalizeAlignment(colStyle.align); + + // Merge defaults + colStyle = deepMerge(defaultColStyle, colStyle); + if (colStyle.width == null || colStyle.width === '*') { + colStyle.width = '*'; + } else { + colStyle.width = this.document.sizeToPoint(colStyle.width, 0, this.document.page, this._maxWidth // Use table width here for percentage scaling + ); + } + colStyle.minWidth = this.document.sizeToPoint(colStyle.minWidth, 0, this.document.page, this._maxWidth // Use table width here for percentage scaling + ); + colStyle.maxWidth = this.document.sizeToPoint(colStyle.maxWidth, 0, this.document.page, this._maxWidth // Use table width here for percentage scaling + ); + return colStyle; +} +function normalizeAlignment(align) { + return align == null || typeof align === 'string' ? { + x: align, + y: align + } : align; +} + +/** + * Normalize a table + * + * @this PDFTable + * @memberOf PDFTable + * @private + */ +function normalizeTable() { + var _opts$id, _opts$position, _opts$position2; + const doc = this.document; + const opts = this.opts; + + // Normalize config + let index = doc._tableIndex++; + this._id = new String((_opts$id = opts.id) !== null && _opts$id !== void 0 ? _opts$id : `table-${index}`); + this._position = { + x: doc.sizeToPoint((_opts$position = opts.position) === null || _opts$position === void 0 ? void 0 : _opts$position.x, doc.x), + y: doc.sizeToPoint((_opts$position2 = opts.position) === null || _opts$position2 === void 0 ? void 0 : _opts$position2.y, doc.y) + }; + this._maxWidth = doc.sizeToPoint(opts.maxWidth, doc.page.width - doc.page.margins.right - this._position.x); + const { + defaultStyle, + defaultColStyle, + defaultRowStyle + } = normalizedDefaultStyle(opts.defaultStyle); + this._defaultStyle = defaultStyle; + let colStyle; + if (opts.columnStyles) { + if (Array.isArray(opts.columnStyles)) { + colStyle = i => opts.columnStyles[i]; + } else if (typeof opts.columnStyles === 'function') { + // memoize all columns + colStyle = memoize(i => opts.columnStyles(i), Infinity); + } else if (typeof opts.columnStyles === 'object') { + colStyle = () => opts.columnStyles; + } + } + if (!colStyle) colStyle = () => ({}); + this._colStyle = normalizedColumnStyle.bind(this, defaultColStyle, colStyle); + let rowStyle; + if (opts.rowStyles) { + if (Array.isArray(opts.rowStyles)) { + rowStyle = i => opts.rowStyles[i]; + } else if (typeof opts.rowStyles === 'function') { + // Memoize the row configs in a rolling buffer + rowStyle = memoize(i => opts.rowStyles(i), 10); + } else if (typeof opts.rowStyles === 'object') { + rowStyle = () => opts.rowStyles; + } + } + if (!rowStyle) rowStyle = () => ({}); + this._rowStyle = normalizedRowStyle.bind(this, defaultRowStyle, rowStyle); +} + +/** + * Convert text into a string + * - null and undefined are preserved (as they will be ignored) + * - everything else is run through `String()` + * + * @param {*} text + * @returns {string} + * @private + */ +function normalizeText(text) { + // Parse out text + if (text != null) text = `${text}`; + return text; +} + +/** + * Normalize a cell config + * + * @this PDFTable + * @memberOf PDFTable + * @param {TableCellStyle} cell - The cell to mutate + * @param {number} rowIndex - The cells row + * @param {number} colIndex - The cells column + * @returns {NormalizedTableCellStyle} + * @private + */ +function normalizeCell(cell, rowIndex, colIndex) { + var _config$rowSpan, _config$colSpan, _config$align$x, _config$align$y, _config$textStrokeCol, _config$textColor, _config$textOptions, _config$id, _config$type; + const colStyle = this._colStyle(colIndex); + let rowStyle = this._rowStyle(rowIndex); + const font = deepMerge({}, colStyle.font, rowStyle.font, cell.font); + const customFont = Object.values(font).filter(v => v != null).length > 0; + const doc = this.document; + + // Initialize cell context + const rollbackFont = doc._fontSource; + const rollbackFontSize = doc._fontSize; + const rollbackFontFamily = doc._fontFamily; + if (customFont) { + if (font.src) doc.font(font.src, font.family); + if (font.size) doc.fontSize(font.size); + + // Refetch rowStyle to reflect font changes + rowStyle = this._rowStyle(rowIndex); + } + cell.padding = normalizeSides(cell.padding); + cell.border = normalizeSides(cell.border); + cell.borderColor = normalizeSides(cell.borderColor); + + // Cell takes highest priority, then row, then column, then defaultConfig + const config = deepMerge(this._defaultStyle, colStyle, rowStyle, cell); + config.rowIndex = rowIndex; + config.colIndex = colIndex; + config.font = font !== null && font !== void 0 ? font : {}; + config.customFont = customFont; + + // Normalize config + config.text = normalizeText(config.text); + config.rowSpan = (_config$rowSpan = config.rowSpan) !== null && _config$rowSpan !== void 0 ? _config$rowSpan : 1; + config.colSpan = (_config$colSpan = config.colSpan) !== null && _config$colSpan !== void 0 ? _config$colSpan : 1; + config.padding = normalizeSides(config.padding, '0.25em', x => doc.sizeToPoint(x, '0.25em')); + config.border = normalizeSides(config.border, 1, x => doc.sizeToPoint(x, 1)); + config.borderColor = normalizeSides(config.borderColor, 'black', x => x !== null && x !== void 0 ? x : 'black'); + config.align = normalizeAlignment(config.align); + config.align.x = (_config$align$x = config.align.x) !== null && _config$align$x !== void 0 ? _config$align$x : 'left'; + config.align.y = (_config$align$y = config.align.y) !== null && _config$align$y !== void 0 ? _config$align$y : 'top'; + config.textStroke = doc.sizeToPoint(config.textStroke, 0); + config.textStrokeColor = (_config$textStrokeCol = config.textStrokeColor) !== null && _config$textStrokeCol !== void 0 ? _config$textStrokeCol : 'black'; + config.textColor = (_config$textColor = config.textColor) !== null && _config$textColor !== void 0 ? _config$textColor : 'black'; + config.textOptions = (_config$textOptions = config.textOptions) !== null && _config$textOptions !== void 0 ? _config$textOptions : {}; + + // Accessibility settings + config.id = new String((_config$id = config.id) !== null && _config$id !== void 0 ? _config$id : `${this._id}-${rowIndex}-${colIndex}`); + config.type = ((_config$type = config.type) === null || _config$type === void 0 ? void 0 : _config$type.toUpperCase()) === 'TH' ? 'TH' : 'TD'; + if (config.scope) { + config.scope = config.scope.toLowerCase(); + if (config.scope === 'row') config.scope = 'Row';else if (config.scope === 'both') config.scope = 'Both';else if (config.scope === 'column') config.scope = 'Column'; + } + if (typeof this.opts.debug === 'boolean') config.debug = this.opts.debug; + + // Rollback font + if (customFont) doc.font(rollbackFont, rollbackFontFamily, rollbackFontSize); + return config; +} + +/** + * Normalize a row + * + * @this PDFTable + * @memberOf PDFTable + * @param {TableCell[]} row + * @param {number} rowIndex + * @returns {NormalizedTableCellStyle[]} + * @private + */ +function normalizeRow(row, rowIndex) { + if (!this._cellClaim) this._cellClaim = new Set(); + let colIndex = 0; + return row.map(cell => { + // Ensure TableCell + if (cell == null || typeof cell !== 'object') cell = { + text: cell + }; + + // Find the starting column of the cell + // Skipping over the claimed cells + while (this._cellClaim.has(`${rowIndex},${colIndex}`)) { + colIndex++; + } + cell = normalizeCell.call(this, cell, rowIndex, colIndex); + + // Claim any spanning cells + for (let i = 0; i < cell.rowSpan; i++) { + for (let j = 0; j < cell.colSpan; j++) { + this._cellClaim.add(`${rowIndex + i},${colIndex + j}`); + } + } + colIndex += cell.colSpan; + return cell; + }); +} + +/** + * Compute the widths of the columns, ensuring to distribute the star widths + * + * @this PDFTable + * @memberOf PDFTable + * @param {NormalizedTableCellStyle[]} row + * @private + */ +function ensure(row) { + // Width init + /** @type number[] **/ + this._columnWidths = []; + ensureColumnWidths.call(this, row.reduce((a, cell) => a + cell.colSpan, 0)); + + // Height init + /** @type number[] **/ + this._rowHeights = []; + /** @type number[] **/ + this._rowYPos = [this._position.y]; + /** @type {Set} **/ + this._rowBuffer = new Set(); +} + +/** + * Compute the widths of the columns, ensuring to distribute the star widths + * + * @this PDFTable + * @memberOf PDFTable + * @param {number} numCols + * @private + */ +function ensureColumnWidths(numCols) { + // Compute the widths + let starColumnIndexes = []; + let starMinAcc = 0; + let unclaimedWidth = this._maxWidth; + for (let i = 0; i < numCols; i++) { + let col = this._colStyle(i); + if (col.width === '*') { + starColumnIndexes[i] = col; + starMinAcc += col.minWidth; + } else { + unclaimedWidth -= col.width; + this._columnWidths[i] = col.width; + } + } + let starColCount = starColumnIndexes.reduce(x => x + 1, 0); + if (starMinAcc >= unclaimedWidth) { + // case 1 - there's no way to fit all columns within available width + // that's actually pretty bad situation with PDF as we have no horizontal scroll + starColumnIndexes.forEach((cell, i) => { + this._columnWidths[i] = cell.minWidth; + }); + } else if (starColCount > 0) { + // Otherwise we distribute evenly factoring in the cell bounds + starColumnIndexes.forEach((col, i) => { + let starSize = unclaimedWidth / starColCount; + this._columnWidths[i] = Math.max(starSize, col.minWidth); + if (col.maxWidth > 0) { + this._columnWidths[i] = Math.min(this._columnWidths[i], col.maxWidth); + } + unclaimedWidth -= this._columnWidths[i]; + starColCount--; + }); + } + let tempX = this._position.x; + this._columnXPos = Array.from(this._columnWidths, v => { + const t = tempX; + tempX += v; + return t; + }); +} + +/** + * Compute the dimensions of the cells + * + * @this PDFTable + * @memberOf PDFTable + * @param {NormalizedTableCellStyle[]} row + * @param {number} rowIndex + * @returns {{newPage: boolean, toRender: SizedNormalizedTableCellStyle[]}} + * @private + */ +function measure(row, rowIndex) { + // =================== + // Add cells to buffer + // =================== + row.forEach(cell => this._rowBuffer.add(cell)); + if (rowIndex > 0) { + this._rowYPos[rowIndex] = this._rowYPos[rowIndex - 1] + this._rowHeights[rowIndex - 1]; + } + const rowStyle = this._rowStyle(rowIndex); + + // ======================================================== + // Find any cells which are to finish rendering on this row + // ======================================================== + /** @type {SizedNormalizedTableCellStyle[]} */ + let toRender = []; + this._rowBuffer.forEach(cell => { + if (cell.rowIndex + cell.rowSpan - 1 === rowIndex) { + toRender.push(measureCell.call(this, cell, rowStyle.height)); + this._rowBuffer.delete(cell); + } + }); + + // ===================================================== + // Find the shared height for the row based on the cells + // ===================================================== + let rowHeight = rowStyle.height; + if (rowHeight === 'auto') { + // Compute remaining height on cells + rowHeight = toRender.reduce((acc, cell) => { + let minHeight = cell.textBounds.height + cell.padding.top + cell.padding.bottom; + for (let i = 0; i < cell.rowSpan - 1; i++) { + minHeight -= this._rowHeights[cell.rowIndex + i]; + } + return Math.max(acc, minHeight); + }, 0); + } + rowHeight = Math.max(rowHeight, rowStyle.minHeight); + if (rowStyle.maxHeight > 0) { + rowHeight = Math.min(rowHeight, rowStyle.maxHeight); + } + this._rowHeights[rowIndex] = rowHeight; + let newPage = false; + if (rowHeight > this.document.page.contentHeight) { + // We are unable to render this row on a single page, for now we log a warning and disable the newPage + console.warn(new Error(`Row ${rowIndex} requested more than the safe page height, row has been clamped`).stack.slice(7)); + this._rowHeights[rowIndex] = this.document.page.maxY() - this._rowYPos[rowIndex]; + } else if (this._rowYPos[rowIndex] + rowHeight >= this.document.page.maxY()) { + // If row is going to go over the safe page height then move it over to new page + this._rowYPos[rowIndex] = this.document.page.margins.top; + newPage = true; + } + + // ===================================================== + // Re-measure the cells using the know known height + // ===================================================== + return { + newPage, + toRender: toRender.map(cell => measureCell.call(this, cell, rowHeight)) + }; +} + +/** + * Compute the dimensions of the cell and its text + * + * @this PDFTable + * @memberOf PDFTable + * @param {NormalizedTableCellStyle} cell + * @param {number | 'auto'} rowHeight + * @returns {SizedNormalizedTableCellStyle} + * @private + */ +function measureCell(cell, rowHeight) { + var _cell$textOptions$rot; + // ==================== + // Calculate cell width + // ==================== + let cellWidth = 0; + + // Traverse all the columns of the cell + for (let i = 0; i < cell.colSpan; i++) { + cellWidth += this._columnWidths[cell.colIndex + i]; + } + + // ===================== + // Calculate cell height + // ===================== + let cellHeight = rowHeight; + if (cellHeight === 'auto') { + // The cells height is effectively infinite + // (although we clamp it to the page content size) + cellHeight = this.document.page.contentHeight; + } else { + // Add all the spanning rows heights to the cell + for (let i = 0; i < cell.rowSpan - 1; i++) { + cellHeight += this._rowHeights[cell.rowIndex + i]; + } + } + + // Allocated text space + const textAllocatedWidth = cellWidth - cell.padding.left - cell.padding.right; + const textAllocatedHeight = cellHeight - cell.padding.top - cell.padding.bottom; + + // Compute the text bounds + const rotation = (_cell$textOptions$rot = cell.textOptions.rotation) !== null && _cell$textOptions$rot !== void 0 ? _cell$textOptions$rot : 0; + const { + width: textMaxWidth, + height: textMaxHeight + } = computeBounds(rotation, textAllocatedWidth, textAllocatedHeight); + const textOptions = { + // Alignment is handled internally + align: cell.align.x, + ellipsis: true, + // Default make overflowing text ellipsis + stroke: cell.textStroke > 0, + fill: true, + // To fix the stroke issue + width: textMaxWidth, + height: textMaxHeight, + rotation, + // Allow the user to define any custom fields + ...cell.textOptions + }; + + // ======================== + // Calculate text height + // ======================== + + // Compute rendered bounds of the text given the constraints of the cell + let textBounds = { + x: 0, + y: 0, + width: 0, + height: 0 + }; + if (cell.text) { + var _cell$font, _cell$font2, _cell$font3; + const rollbackFont = this.document._fontSource; + const rollbackFontSize = this.document._fontSize; + const rollbackFontFamily = this.document._fontFamily; + if ((_cell$font = cell.font) !== null && _cell$font !== void 0 && _cell$font.src) this.document.font(cell.font.src, (_cell$font2 = cell.font) === null || _cell$font2 === void 0 ? void 0 : _cell$font2.family); + if ((_cell$font3 = cell.font) !== null && _cell$font3 !== void 0 && _cell$font3.size) this.document.fontSize(cell.font.size); + + // We first compute the un-rotated bounds so that we can calculate the width of the text + const unRotatedTextBounds = this.document.boundsOfString(cell.text, 0, 0, { + ...textOptions, + rotation: 0 + }); + textOptions.width = unRotatedTextBounds.width; + textOptions.height = unRotatedTextBounds.height; + + // Then compute the rendered bounds + textBounds = this.document.boundsOfString(cell.text, 0, 0, textOptions); + this.document.font(rollbackFont, rollbackFontFamily, rollbackFontSize); + } + return { + ...cell, + textOptions, + x: this._columnXPos[cell.colIndex], + y: this._rowYPos[cell.rowIndex], + textX: this._columnXPos[cell.colIndex] + cell.padding.left, + textY: this._rowYPos[cell.rowIndex] + cell.padding.top, + width: cellWidth, + height: cellHeight, + textAllocatedHeight, + textAllocatedWidth, + textBounds + }; +} + +/** + * Compute the horizon-locked bounding box of a rect + * + * @param {number} rotation + * @param {number} allocWidth + * @param {number} allocHeight + * + * @returns {{width: number, height: number}} + */ +function computeBounds(rotation, allocWidth, allocHeight) { + let textMaxWidth, textMaxHeight; + + // We use these a lot so pre-compute + const cos = cosine(rotation); + const sin = sine(rotation); + + // <---------------allocWidth----------------> + // A════════════════════F════════════════════B + // ║ ■■ ■ ║ + // ║ ■■ ■ ║ + // ║ ■■ ■ ║ + // ║ ■■ ■ ║ + // ║ ■■ ■ ║ + // ║ ■■ ■ ║ + // ║ ■■░░ ■ ║ + // ║ ■■ ░ ■ ║ + // ║ ■■ Θ ░ ■ ║ + // ║■■ ░ ■ ║ + // E- - - - - - - - - - - - - ■ - - - - - - -║ + // ║■ ■ ║ + // ║■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■ ║ + // ║ ■ ■║ + // ║ ■ ■║ + // ║ ■ G + // ║ ■ ■■║ + // ║ ■ ■■ ║ + // ║ ■ ■ ║ + // ║ ■ ■■ ║ + // ║ ■ ■ ║ + // ║ ■ ■■ ║ + // ║ ■ ■■ ║ + // ║ ■ ■ ║ + // ║ ■ ■■ ║ + // ║ ■ ■ ║ + // ║ ■ ■■ ║ + // ║ ■ ■■ ║ + // D════════════════════H════════════════════C + // + // Given a rectangle ABCD with a fixed side AB of width allocWidth. + // Find the largest (by area) inscribed rectangle EFGH, + // where the angle Θ is equal to rotation (between 0-90 degrees) + // + // From above we can infer + // > AF = EF * cos(Θ) + // > FB = AB - AF + // > FB = FG * sin(Θ) + // Rearrange + // > FG = FB / sin(Θ) + // Substitute + // > FG = (AB - EF*cos(Θ)) / sin(Θ) + // Area of a rectangle + // > A = EF * FG + // Substitute + // > A = EF * (AB - EF*cos(Θ)) / sin(Θ) + // > dA/dEF = (AB - 2*EF*cos(Θ)) / sin(Θ) + // Find peak at dA/dEF = 0 + // > 0 = (AB - 2*EF*cos(Θ)) / sin(Θ) + // > EF = AB / (2*cos(Θ)) + // Substitute + // > FG = (AB - (AB*cos(Θ)) / (2*cos(Θ))) / sin(Θ) + // > FG = AB / (2*sin(Θ)) + // + // Final outcome + // Length EF = AB / (2*cos(Θ)) + // Length FG = AB / (2*sin(Θ)) + if (rotation === 0 || rotation === 180) { + textMaxWidth = allocWidth; + textMaxHeight = allocHeight; + } else if (rotation === 90 || rotation === 270) { + textMaxWidth = allocHeight; + textMaxHeight = allocWidth; + } else if (rotation < 90 || rotation > 180 && rotation < 270) { + textMaxWidth = allocWidth / (2 * cos); + textMaxHeight = allocWidth / (2 * sin); + } else { + textMaxHeight = allocWidth / (2 * cos); + textMaxWidth = allocWidth / (2 * sin); + } + + // If The bounding box of the text is beyond the allocHeight + // then we need to clamp it and recompute the bounds + // This time we are computing the sizes based on the outer box ABCD + const EF = sin * textMaxWidth; + const FG = cos * textMaxHeight; + if (EF + FG > allocHeight) { + // > AB = EF * cos(Θ) + FG * sin(Θ) + // > BC = BG + GC + // > BG = FG * cos(Θ) + // > GC = EF * sin(Θ) + // > BC = FG * cos(Θ) + EF * sin(Θ) + // > AB = EF * cos(Θ) + FG * sin(Θ) + // Substitution solve + // > EF = (AB*cos(Θ) - BC*sin(Θ)) / (cos^2(Θ)-sin^2(Θ)) + // > FG = (BC*cos(Θ) - AB*sin(Θ)) / (cos^2(Θ)-sin^2(Θ)) + const denominator = cos * cos - sin * sin; + if (rotation === 0 || rotation === 180) { + textMaxWidth = allocWidth; + textMaxHeight = allocHeight; + } else if (rotation === 90 || rotation === 270) { + textMaxWidth = allocHeight; + textMaxHeight = allocWidth; + } else if (rotation < 90 || rotation > 180 && rotation < 270) { + textMaxWidth = (allocWidth * cos - allocHeight * sin) / denominator; + textMaxHeight = (allocHeight * cos - allocWidth * sin) / denominator; + } else { + textMaxHeight = (allocWidth * cos - allocHeight * sin) / denominator; + textMaxWidth = (allocHeight * cos - allocWidth * sin) / denominator; + } + } + return { + width: Math.abs(textMaxWidth), + height: Math.abs(textMaxHeight) + }; +} + +/** + * Add accessibility to a table + * + * @this PDFTable + * @memberOf PDFTable + * @private + */ +function accommodateTable() { + const structParent = this.opts.structParent; + if (structParent) { + this._tableStruct = this.document.struct('Table'); + this._tableStruct.dictionary.data.ID = this._id; + if (structParent instanceof PDFStructureElement) { + structParent.add(this._tableStruct); + } else if (structParent instanceof PDFDocument) { + structParent.addStructure(this._tableStruct); + } + this._headerRowLookup = {}; + this._headerColumnLookup = {}; + } +} + +/** + * Cleanup accessibility on a table + * + * @this PDFTable + * @memberOf PDFTable + * @private + */ +function accommodateCleanup() { + if (this._tableStruct) this._tableStruct.end(); +} + +/** + * Render a row with all its accessibility features + * + * @this PDFTable + * @memberOf PDFTable + * @param {SizedNormalizedTableCellStyle[]} row + * @param {number} rowIndex + * @param {Function} renderCell + * @private + */ +function accessibleRow(row, rowIndex, renderCell) { + const rowStruct = this.document.struct('TR'); + rowStruct.dictionary.data.ID = new String(`${this._id}-${rowIndex}`); + this._tableStruct.add(rowStruct); + row.forEach(cell => renderCell(cell, rowStruct)); + rowStruct.end(); +} + +/** + * Render a cell with all its accessibility features + * + * @this PDFTable + * @memberOf PDFTable + * @param {SizedNormalizedTableCellStyle} cell + * @param {PDFStructureElement} rowStruct + * @param {Function} callback + * @private + */ +function accessibleCell(cell, rowStruct, callback) { + const doc = this.document; + const cellStruct = doc.struct(cell.type, { + title: cell.title + }); + cellStruct.dictionary.data.ID = cell.id; + rowStruct.add(cellStruct); + const padding = cell.padding; + const border = cell.border; + const attributes = { + O: 'Table', + Width: cell.width, + Height: cell.height, + Padding: [padding.top, padding.bottom, padding.left, padding.right], + RowSpan: cell.rowSpan > 1 ? cell.rowSpan : undefined, + ColSpan: cell.colSpan > 1 ? cell.colSpan : undefined, + BorderThickness: [border.top, border.bottom, border.left, border.right] + }; + + // Claim row Headers + if (cell.type === 'TH') { + if (cell.scope === 'Row' || cell.scope === 'Both') { + for (let i = 0; i < cell.rowSpan; i++) { + if (!this._headerRowLookup[cell.rowIndex + i]) { + this._headerRowLookup[cell.rowIndex + i] = []; + } + this._headerRowLookup[cell.rowIndex + i].push(cell.id); + } + attributes.Scope = cell.scope; + } + if (cell.scope === 'Column' || cell.scope === 'Both') { + for (let i = 0; i < cell.colSpan; i++) { + if (!this._headerColumnLookup[cell.colIndex + i]) { + this._headerColumnLookup[cell.colIndex + i] = []; + } + this._headerColumnLookup[cell.colIndex + i].push(cell.id); + } + attributes.Scope = cell.scope; + } + } + + // Find any cells which are marked as headers for this cell + const Headers = new Set([...Array.from({ + length: cell.colSpan + }, (_, i) => this._headerColumnLookup[cell.colIndex + i]).flat(), ...Array.from({ + length: cell.rowSpan + }, (_, i) => this._headerRowLookup[cell.rowIndex + i]).flat()].filter(Boolean)); + if (Headers.size) attributes.Headers = Array.from(Headers); + const normalizeColor = doc._normalizeColor; + if (cell.backgroundColor != null) { + attributes.BackgroundColor = normalizeColor(cell.backgroundColor); + } + const hasBorder = [border.top, border.bottom, border.left, border.right]; + if (hasBorder.some(x => x)) { + const borderColor = cell.borderColor; + attributes.BorderColor = [hasBorder[0] ? normalizeColor(borderColor.top) : null, hasBorder[1] ? normalizeColor(borderColor.bottom) : null, hasBorder[2] ? normalizeColor(borderColor.left) : null, hasBorder[3] ? normalizeColor(borderColor.right) : null]; + } + + // Remove any undefined attributes + Object.keys(attributes).forEach(key => attributes[key] === undefined && delete attributes[key]); + cellStruct.dictionary.data.A = doc.ref(attributes); + cellStruct.add(callback); + cellStruct.end(); + cellStruct.dictionary.data.A.end(); +} + +/** + * Render a cell + * + * @this PDFTable + * @memberOf PDFTable + * @param {SizedNormalizedTableCellStyle[]} row + * @param {number} rowIndex + * @private + */ +function renderRow(row, rowIndex) { + if (this._tableStruct) { + accessibleRow.call(this, row, rowIndex, renderCell.bind(this)); + } else { + row.forEach(cell => renderCell.call(this, cell)); + } + return this._rowYPos[rowIndex] + this._rowHeights[rowIndex]; +} + +/** + * Render a cell + * + * @this PDFTable + * @memberOf PDFTable + * @param {SizedNormalizedTableCellStyle} cell + * @param {PDFStructureElement} rowStruct + * @private + */ +function renderCell(cell, rowStruct) { + const cellRenderer = () => { + // Render cell background + if (cell.backgroundColor != null) { + this.document.save().fillColor(cell.backgroundColor).rect(cell.x, cell.y, cell.width, cell.height).fill().restore(); + } + + // Render border + renderBorder.call(this, cell.border, cell.borderColor, cell.x, cell.y, cell.width, cell.height); + + // Debug cell borders + if (cell.debug) { + this.document.save(); + this.document.dash(1, { + space: 1 + }).lineWidth(1).strokeOpacity(0.3); + + // Debug cell bounds + this.document.rect(cell.x, cell.y, cell.width, cell.height).stroke('green'); + this.document.restore(); + } + + // Render text + if (cell.text) renderCellText.call(this, cell); + }; + if (rowStruct) accessibleCell.call(this, cell, rowStruct, cellRenderer);else cellRenderer(); +} + +/** + * @this PDFTable + * @memberOf PDFTable + * @param {SizedNormalizedTableCellStyle} cell + */ +function renderCellText(cell) { + const doc = this.document; + + // Configure fonts + const rollbackFont = doc._fontSource; + const rollbackFontSize = doc._fontSize; + const rollbackFontFamily = doc._fontFamily; + if (cell.customFont) { + if (cell.font.src) doc.font(cell.font.src, cell.font.family); + if (cell.font.size) doc.fontSize(cell.font.size); + } + const x = cell.textX; + const y = cell.textY; + const Ah = cell.textAllocatedHeight; + const Aw = cell.textAllocatedWidth; + const Cw = cell.textBounds.width; + const Ch = cell.textBounds.height; + const Ox = -cell.textBounds.x; + const Oy = -cell.textBounds.y; + const PxScale = cell.align.x === 'right' ? 1 : cell.align.x === 'center' ? 0.5 : 0; + const Px = (Aw - Cw) * PxScale; + const PyScale = cell.align.y === 'bottom' ? 1 : cell.align.y === 'center' ? 0.5 : 0; + const Py = (Ah - Ch) * PyScale; + const dx = Px + Ox; + const dy = Py + Oy; + if (cell.debug) { + doc.save(); + doc.dash(1, { + space: 1 + }).lineWidth(1).strokeOpacity(0.3); + + // Debug actual text bounds + if (cell.text) { + doc.moveTo(x + Px, y).lineTo(x + Px, y + Ah).moveTo(x + Px + Cw, y).lineTo(x + Px + Cw, y + Ah).stroke('blue').moveTo(x, y + Py).lineTo(x + Aw, y + Py).moveTo(x, y + Py + Ch).lineTo(x + Aw, y + Py + Ch).stroke('green'); + } + // Debug allocated text bounds + doc.rect(x, y, Aw, Ah).stroke('orange'); + doc.restore(); + } + + // Create text mask to cut off any overflowing text + // Mask cuts off at the padding not the actual cell, this is intentional! + doc.save().rect(x, y, Aw, Ah).clip(); + doc.fillColor(cell.textColor).strokeColor(cell.textStrokeColor); + if (cell.textStroke > 0) doc.lineWidth(cell.textStroke); + + // Render the text + doc.text(cell.text, x + dx, y + dy, cell.textOptions); + + // Cleanup + doc.restore(); + if (cell.font) doc.font(rollbackFont, rollbackFontFamily, rollbackFontSize); +} + +/** + * @this PDFTable + * @memberOf PDFTable + * @param {ExpandedSideDefinition} border + * @param {ExpandedSideDefinition} borderColor + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + * @param {number[]} [mask] + * @private + */ +function renderBorder(border, borderColor, x, y, width, height, mask) { + border = Object.fromEntries(Object.entries(border).map(_ref => { + let [k, v] = _ref; + return [k, mask && !mask[k] ? 0 : v]; + })); + const doc = this.document; + if ([border.right, border.bottom, border.left].every(val => val === border.top)) { + if (border.top > 0) { + doc.save().lineWidth(border.top).strokeColor(borderColor.top).rect(x, y, width, height).stroke().restore(); + } + } else { + // Top + if (border.top > 0) { + doc.save().lineWidth(border.top).moveTo(x, y).strokeColor(borderColor.top).lineTo(x + width, y).stroke().restore(); + } + // Right + if (border.right > 0) { + doc.save().lineWidth(border.right).moveTo(x + width, y).strokeColor(borderColor.right).lineTo(x + width, y + height).stroke().restore(); + } + // Bottom + if (border.bottom > 0) { + doc.save().lineWidth(border.bottom).moveTo(x + width, y + height).strokeColor(borderColor.bottom).lineTo(x, y + height).stroke().restore(); + } + // Left + if (border.left > 0) { + doc.save().lineWidth(border.left).moveTo(x, y + height).strokeColor(borderColor.left).lineTo(x, y).stroke().restore(); + } + } +} + +class PDFTable { + /** + * @param {PDFDocument} document + * @param {Table} [opts] + */ + constructor(document, opts) { + if (opts === void 0) { + opts = {}; + } + this.document = document; + this.opts = Object.freeze(opts); + normalizeTable.call(this); + accommodateTable.call(this); + this._currRowIndex = 0; + this._ended = false; + + // Render cells if present + if (opts.data) { + for (const row of opts.data) this.row(row); + return this.end(); + } + } + + /** + * Render a new row in the table + * + * @param {Iterable} row - The cells to render + * @param {boolean} lastRow - Whether this row is the last row + * @returns {this} returns the table, unless lastRow is `true` then returns the `PDFDocument` + */ + row(row, lastRow) { + if (lastRow === void 0) { + lastRow = false; + } + if (this._ended) { + throw new Error(`Table was marked as ended on row ${this._currRowIndex}`); + } + + // Convert the iterable into an array + row = Array.from(row); + // Transform row + row = normalizeRow.call(this, row, this._currRowIndex); + if (this._currRowIndex === 0) ensure.call(this, row); + const { + newPage, + toRender + } = measure.call(this, row, this._currRowIndex); + if (newPage) this.document.continueOnNewPage(); + const yPos = renderRow.call(this, toRender, this._currRowIndex); + + // Position document at base of new row + this.document.x = this._position.x; + this.document.y = yPos; + if (lastRow) return this.end(); + this._currRowIndex++; + return this; + } + + /** + * Indicates to the table that it is finished, + * allowing the table to flush its cell buffer (which should be empty unless there is rowSpans) + * + * @returns {PDFDocument} the document + */ + end() { + // Flush any remaining cells + while ((_this$_rowBuffer = this._rowBuffer) !== null && _this$_rowBuffer !== void 0 && _this$_rowBuffer.size) { + var _this$_rowBuffer; + this.row([]); + } + this._ended = true; + accommodateCleanup.call(this); + return this.document; + } +} + +var TableMixin = { + initTables() { + this._tableIndex = 0; + }, + /** + * @param {Table} [opts] + * @returns {PDFTable} returns the table object unless `data` is set, + * then it returns the underlying document + */ + table(opts) { + return new PDFTable(this, opts); + } +}; + +class PDFMetadata { + constructor() { + this._metadata = ` + + + + `; + } + _closeTags() { + this._metadata = this._metadata.concat(` + + + + `); + } + append(xml, newline) { + if (newline === void 0) { + newline = true; + } + this._metadata = this._metadata.concat(xml); + if (newline) this._metadata = this._metadata.concat('\n'); + } + getXML() { + return this._metadata; + } + getLength() { + return this._metadata.length; + } + end() { + this._closeTags(); + this._metadata = this._metadata.trim(); + } +} + +var MetadataMixin = { + initMetadata() { + this.metadata = new PDFMetadata(); + }, + appendXML(xml, newline) { + if (newline === void 0) { + newline = true; + } + this.metadata.append(xml, newline); + }, + _addInfo() { + this.appendXML(` + + ${this.info.CreationDate.toISOString().split('.')[0] + 'Z'} + ${this.info.Creator} + + `); + if (this.info.Title || this.info.Author || this.info.Subject) { + this.appendXML(` + + `); + if (this.info.Title) { + this.appendXML(` + + + ${this.info.Title} + + + `); + } + if (this.info.Author) { + this.appendXML(` + + + ${this.info.Author} + + + `); + } + if (this.info.Subject) { + this.appendXML(` + + + ${this.info.Subject} + + + `); + } + this.appendXML(` + + `); + } + this.appendXML(` + + ${this.info.Creator}`, false); + if (this.info.Keywords) { + this.appendXML(` + ${this.info.Keywords}`, false); + } + this.appendXML(` + + `); + }, + endMetadata() { + this._addInfo(); + this.metadata.end(); + + /* + Metadata was introduced in PDF 1.4, so adding it to 1.3 + will likely only take up more space. + */ + if (this.version != 1.3) { + this.metadataRef = this.ref({ + length: this.metadata.getLength(), + Type: 'Metadata', + Subtype: 'XML' + }); + this.metadataRef.compress = false; + this.metadataRef.write(Buffer.from(this.metadata.getXML(), 'utf-8')); + this.metadataRef.end(); + this._root.data.Metadata = this.metadataRef; + } + } +}; + +/* +PDFDocument - represents an entire PDF document +By Devon Govett +*/ + +class PDFDocument extends stream.Readable { + constructor(options) { + if (options === void 0) { + options = {}; + } + super(options); + this.options = options; + + // PDF version + switch (options.pdfVersion) { + case '1.4': + this.version = 1.4; + break; + case '1.5': + this.version = 1.5; + break; + case '1.6': + this.version = 1.6; + break; + case '1.7': + case '1.7ext3': + this.version = 1.7; + break; + default: + this.version = 1.3; + break; + } + + // Whether streams should be compressed + this.compress = this.options.compress != null ? this.options.compress : true; + this._pageBuffer = []; + this._pageBufferStart = 0; + + // The PDF object store + this._offsets = []; + this._waiting = 0; + this._ended = false; + this._offset = 0; + const Pages = this.ref({ + Type: 'Pages', + Count: 0, + Kids: [] + }); + const Names = this.ref({ + Dests: new PDFNameTree() + }); + this._root = this.ref({ + Type: 'Catalog', + Pages, + Names + }); + if (this.options.lang) { + this._root.data.Lang = new String(this.options.lang); + } + if (this.options.pageLayout) { + const layout = this.options.pageLayout; + this._root.data.PageLayout = layout.charAt(0).toUpperCase() + layout.slice(1); + } + + // The current page + this.page = null; + + // Initialize mixins + this.initMetadata(); + this.initColor(); + this.initVector(); + this.initFonts(options.font); + this.initText(); + this.initImages(); + this.initOutline(); + this.initMarkings(options); + this.initTables(); + this.initSubset(options); + + // Initialize the metadata + this.info = { + Producer: 'PDFKit', + Creator: 'PDFKit', + CreationDate: new Date() + }; + if (this.options.info) { + for (let key in this.options.info) { + const val = this.options.info[key]; + this.info[key] = val; + } + } + if (this.options.displayTitle) { + this._root.data.ViewerPreferences = this.ref({ + DisplayDocTitle: true + }); + } + + // Generate file ID + this._id = PDFSecurity.generateFileID(this.info); + + // Initialize security settings + this._security = PDFSecurity.create(this, options); + + // Write the header + // PDF version + this._write(`%PDF-${this.version}`); + + // 4 binary chars, as recommended by the spec + this._write('%\xFF\xFF\xFF\xFF'); + + // Add the first page + if (this.options.autoFirstPage !== false) { + this.addPage(); + } + } + addPage(options) { + if (options == null) { + ({ + options + } = this); + } + + // end the current page if needed + if (!this.options.bufferPages) { + this.flushPages(); + } + + // create a page object + this.page = new PDFPage(this, options); + this._pageBuffer.push(this.page); + + // add the page to the object store + const pages = this._root.data.Pages.data; + pages.Kids.push(this.page.dictionary); + pages.Count++; + + // reset x and y coordinates + this.x = this.page.margins.left; + this.y = this.page.margins.top; + + // flip PDF coordinate system so that the origin is in + // the top left rather than the bottom left + this._ctm = [1, 0, 0, 1, 0, 0]; + this.transform(1, 0, 0, -1, 0, this.page.height); + this.emit('pageAdded'); + return this; + } + continueOnNewPage(options) { + const pageMarkings = this.endPageMarkings(this.page); + this.addPage(options !== null && options !== void 0 ? options : this.page._options); + this.initPageMarkings(pageMarkings); + return this; + } + bufferedPageRange() { + return { + start: this._pageBufferStart, + count: this._pageBuffer.length + }; + } + switchToPage(n) { + let page; + if (!(page = this._pageBuffer[n - this._pageBufferStart])) { + throw new Error(`switchToPage(${n}) out of bounds, current buffer covers pages ${this._pageBufferStart} to ${this._pageBufferStart + this._pageBuffer.length - 1}`); + } + return this.page = page; + } + flushPages() { + // this local variable exists so we're future-proof against + // reentrant calls to flushPages. + const pages = this._pageBuffer; + this._pageBuffer = []; + this._pageBufferStart += pages.length; + for (let page of pages) { + this.endPageMarkings(page); + page.end(); + } + } + addNamedDestination(name) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + if (args.length === 0) { + args = ['XYZ', null, null, null]; + } + if (args[0] === 'XYZ' && args[2] !== null) { + args[2] = this.page.height - args[2]; + } + args.unshift(this.page.dictionary); + this._root.data.Names.data.Dests.add(name, args); + } + addNamedEmbeddedFile(name, ref) { + if (!this._root.data.Names.data.EmbeddedFiles) { + // disabling /Limits for this tree fixes attachments not showing in Adobe Reader + this._root.data.Names.data.EmbeddedFiles = new PDFNameTree({ + limits: false + }); + } + + // add filespec to EmbeddedFiles + this._root.data.Names.data.EmbeddedFiles.add(name, ref); + } + addNamedJavaScript(name, js) { + if (!this._root.data.Names.data.JavaScript) { + this._root.data.Names.data.JavaScript = new PDFNameTree(); + } + let data = { + JS: new String(js), + S: 'JavaScript' + }; + this._root.data.Names.data.JavaScript.add(name, data); + } + ref(data) { + const ref = new PDFReference(this, this._offsets.length + 1, data); + this._offsets.push(null); // placeholder for this object's offset once it is finalized + this._waiting++; + return ref; + } + _read() {} + // do nothing, but this method is required by node + + _write(data) { + if (!Buffer.isBuffer(data)) { + data = Buffer.from(data + '\n', 'binary'); + } + this.push(data); + this._offset += data.length; + } + addContent(data) { + this.page.write(data); + return this; + } + _refEnd(ref) { + this._offsets[ref.id - 1] = ref.offset; + if (--this._waiting === 0 && this._ended) { + this._finalize(); + this._ended = false; + } + } + end() { + this.flushPages(); + this._info = this.ref(); + for (let key in this.info) { + let val = this.info[key]; + if (typeof val === 'string') { + val = new String(val); + } + let entry = this.ref(val); + entry.end(); + this._info.data[key] = entry; + } + this._info.end(); + for (let name in this._fontFamilies) { + const font = this._fontFamilies[name]; + font.finalize(); + } + this.endOutline(); + this.endMarkings(); + if (this.subset) { + this.endSubset(); + } + this.endMetadata(); + this._root.end(); + this._root.data.Pages.end(); + this._root.data.Names.end(); + this.endAcroForm(); + if (this._root.data.ViewerPreferences) { + this._root.data.ViewerPreferences.end(); + } + if (this._security) { + this._security.end(); + } + if (this._waiting === 0) { + this._finalize(); + } else { + this._ended = true; + } + } + _finalize() { + // generate xref + const xRefOffset = this._offset; + this._write('xref'); + this._write(`0 ${this._offsets.length + 1}`); + this._write('0000000000 65535 f '); + for (let offset of this._offsets) { + offset = `0000000000${offset}`.slice(-10); + this._write(offset + ' 00000 n '); + } + + // trailer + const trailer = { + Size: this._offsets.length + 1, + Root: this._root, + Info: this._info, + ID: [this._id, this._id] + }; + if (this._security) { + trailer.Encrypt = this._security.dictionary; + } + this._write('trailer'); + this._write(PDFObject.convert(trailer)); + this._write('startxref'); + this._write(`${xRefOffset}`); + this._write('%%EOF'); + + // end the stream + this.push(null); + } + toString() { + return '[object PDFDocument]'; + } +} +const mixin = methods => { + Object.assign(PDFDocument.prototype, methods); +}; +mixin(MetadataMixin); +mixin(ColorMixin); +mixin(VectorMixin); +mixin(FontsMixin); +mixin(TextMixin); +mixin(ImagesMixin); +mixin(AnnotationsMixin); +mixin(OutlineMixin); +mixin(MarkingsMixin); +mixin(AcroFormMixin); +mixin(AttachmentsMixin); +mixin(SubsetMixin); +mixin(TableMixin); +PDFDocument.LineWrapper = LineWrapper; + +export { PDFDocument as default }; diff --git a/node_modules/@react-pdf/pdfkit/package.json b/node_modules/@react-pdf/pdfkit/package.json new file mode 100644 index 0000000000000000000000000000000000000000..ef2878bcfe47890e78d02831ac86edcc9dd415f2 --- /dev/null +++ b/node_modules/@react-pdf/pdfkit/package.json @@ -0,0 +1,46 @@ +{ + "name": "@react-pdf/pdfkit", + "version": "5.1.1", + "license": "MIT", + "description": "A PDF generation library for Node.js", + "type": "module", + "main": "./lib/pdfkit.js", + "browser": { + "./lib/pdfkit.js": "./lib/pdfkit.browser.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/diegomura/react-pdf.git", + "directory": "packages/pdfkit" + }, + "author": { + "name": "Devon Govett", + "email": "devongovett@gmail.com", + "url": "http://badassjs.com/" + }, + "scripts": { + "test": "vitest", + "clear": "rimraf ./lib ./src/font/data/*.json", + "parse:afm": "node ./src/font/data/compressData.js", + "build": "npm run clear && npm run parse:afm && rollup -c ", + "watch": "npm run clear && npm run parse:afm && rollup -c -w" + }, + "files": [ + "lib" + ], + "dependencies": { + "@babel/runtime": "^7.20.13", + "browserify-zlib": "^0.2.0", + "@noble/ciphers": "^1.0.0", + "@noble/hashes": "^1.6.0", + "fontkit": "^2.0.2", + "js-md5": "^0.8.3", + "jay-peg": "^1.1.1", + "linebreak": "^1.1.0", + "png-js": "^2.0.0", + "vite-compatible-readable-stream": "^3.6.1" + }, + "devDependencies": { + "iconv-lite": "^0.4.13" + } +} diff --git a/node_modules/@react-pdf/primitives/README.md b/node_modules/@react-pdf/primitives/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d40a66afae9ce86dcfa2bdcc63e2a1bfcaa263ae --- /dev/null +++ b/node_modules/@react-pdf/primitives/README.md @@ -0,0 +1,81 @@ +

+ +

+ +# @react-pdf/primitives + +Internal element type constants for react-pdf. This package defines the primitive node types used throughout the react-pdf rendering pipeline. + +## Installation + +```bash +yarn add @react-pdf/primitives +``` + +## Usage + +```js +import { View, Text, Page, Document } from '@react-pdf/primitives'; + +console.log(View); // 'VIEW' +console.log(Text); // 'TEXT' +console.log(Page); // 'PAGE' +console.log(Document); // 'DOCUMENT' +``` + +These constants are primarily used internally by react-pdf packages to identify element types during the rendering process. + +## Available Primitives + +### Document Structure + +| Export | Value | Description | +| ---------- | ------------ | --------------------------------- | +| `Document` | `'DOCUMENT'` | Root document container | +| `Page` | `'PAGE'` | Individual page within a document | +| `View` | `'VIEW'` | Generic container element | +| `Text` | `'TEXT'` | Text content container | +| `Link` | `'LINK'` | Hyperlink element | +| `Note` | `'NOTE'` | Annotation/note element | +| `Image` | `'IMAGE'` | Image element | +| `Canvas` | `'CANVAS'` | Custom drawing canvas | + +### Form Elements + +| Export | Value | Description | +| ----------- | -------------- | ----------------------------- | +| `FieldSet` | `'FIELD_SET'` | Form field grouping container | +| `TextInput` | `'TEXT_INPUT'` | Text input field | +| `Select` | `'SELECT'` | Dropdown select field | +| `Checkbox` | `'CHECKBOX'` | Checkbox input field | +| `List` | `'LIST'` | List element for forms | + +### SVG Elements + +| Export | Value | Description | +| ---------------- | ------------------- | -------------------------- | +| `Svg` | `'SVG'` | SVG root container | +| `G` | `'G'` | SVG group element | +| `Path` | `'PATH'` | SVG path element | +| `Rect` | `'RECT'` | SVG rectangle element | +| `Line` | `'LINE'` | SVG line element | +| `Circle` | `'CIRCLE'` | SVG circle element | +| `Ellipse` | `'ELLIPSE'` | SVG ellipse element | +| `Polygon` | `'POLYGON'` | SVG polygon element | +| `Polyline` | `'POLYLINE'` | SVG polyline element | +| `Tspan` | `'TSPAN'` | SVG text span element | +| `ClipPath` | `'CLIP_PATH'` | SVG clipping path | +| `Defs` | `'DEFS'` | SVG definitions container | +| `Stop` | `'STOP'` | Gradient stop element | +| `LinearGradient` | `'LINEAR_GRADIENT'` | Linear gradient definition | +| `RadialGradient` | `'RADIAL_GRADIENT'` | Radial gradient definition | + +### Internal Types + +| Export | Value | Description | +| -------------- | ----------------- | --------------------------------------- | +| `TextInstance` | `'TEXT_INSTANCE'` | Internal representation of text content | + +## License + +MIT diff --git a/node_modules/@react-pdf/primitives/lib/index.d.ts b/node_modules/@react-pdf/primitives/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..be27e9f4e09a1bd2c3298bf50e7aea06ce12bef3 --- /dev/null +++ b/node_modules/@react-pdf/primitives/lib/index.d.ts @@ -0,0 +1,33 @@ +declare const G = "G"; +declare const Svg = "SVG"; +declare const View = "VIEW"; +declare const Text = "TEXT"; +declare const Link = "LINK"; +declare const Page = "PAGE"; +declare const Note = "NOTE"; +declare const Path = "PATH"; +declare const Rect = "RECT"; +declare const Line = "LINE"; +declare const FieldSet = "FIELD_SET"; +declare const TextInput = "TEXT_INPUT"; +declare const Select = "SELECT"; +declare const Checkbox = "CHECKBOX"; +declare const List = "LIST"; +declare const Stop = "STOP"; +declare const Defs = "DEFS"; +declare const Image = "IMAGE"; +declare const ImageBackground = "IMAGE_BACKGROUND"; +declare const Tspan = "TSPAN"; +declare const Canvas = "CANVAS"; +declare const Circle = "CIRCLE"; +declare const Ellipse = "ELLIPSE"; +declare const Polygon = "POLYGON"; +declare const Document = "DOCUMENT"; +declare const Polyline = "POLYLINE"; +declare const ClipPath = "CLIP_PATH"; +declare const TextInstance = "TEXT_INSTANCE"; +declare const LinearGradient = "LINEAR_GRADIENT"; +declare const RadialGradient = "RADIAL_GRADIENT"; +declare const Marker = "MARKER"; + +export { Canvas, Checkbox, Circle, ClipPath, Defs, Document, Ellipse, FieldSet, G, Image, ImageBackground, Line, LinearGradient, Link, List, Marker, Note, Page, Path, Polygon, Polyline, RadialGradient, Rect, Select, Stop, Svg, Text, TextInput, TextInstance, Tspan, View }; diff --git a/node_modules/@react-pdf/primitives/lib/index.js b/node_modules/@react-pdf/primitives/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..02d473e85d8ebd442a754f8dd2db0ed2230b4d0f --- /dev/null +++ b/node_modules/@react-pdf/primitives/lib/index.js @@ -0,0 +1,33 @@ +const G = 'G'; +const Svg = 'SVG'; +const View = 'VIEW'; +const Text = 'TEXT'; +const Link = 'LINK'; +const Page = 'PAGE'; +const Note = 'NOTE'; +const Path = 'PATH'; +const Rect = 'RECT'; +const Line = 'LINE'; +const FieldSet = 'FIELD_SET'; +const TextInput = 'TEXT_INPUT'; +const Select = 'SELECT'; +const Checkbox = 'CHECKBOX'; +const List = 'LIST'; +const Stop = 'STOP'; +const Defs = 'DEFS'; +const Image = 'IMAGE'; +const ImageBackground = 'IMAGE_BACKGROUND'; +const Tspan = 'TSPAN'; +const Canvas = 'CANVAS'; +const Circle = 'CIRCLE'; +const Ellipse = 'ELLIPSE'; +const Polygon = 'POLYGON'; +const Document = 'DOCUMENT'; +const Polyline = 'POLYLINE'; +const ClipPath = 'CLIP_PATH'; +const TextInstance = 'TEXT_INSTANCE'; +const LinearGradient = 'LINEAR_GRADIENT'; +const RadialGradient = 'RADIAL_GRADIENT'; +const Marker = 'MARKER'; + +export { Canvas, Checkbox, Circle, ClipPath, Defs, Document, Ellipse, FieldSet, G, Image, ImageBackground, Line, LinearGradient, Link, List, Marker, Note, Page, Path, Polygon, Polyline, RadialGradient, Rect, Select, Stop, Svg, Text, TextInput, TextInstance, Tspan, View }; diff --git a/node_modules/@react-pdf/primitives/package.json b/node_modules/@react-pdf/primitives/package.json new file mode 100644 index 0000000000000000000000000000000000000000..52cf74aa0b32d24da0bd3caf1746634bf729563b --- /dev/null +++ b/node_modules/@react-pdf/primitives/package.json @@ -0,0 +1,25 @@ +{ + "name": "@react-pdf/primitives", + "version": "4.3.0", + "license": "MIT", + "description": "Define uninitialized elements", + "author": "Diego Muracciole ", + "homepage": "https://github.com/diegomura/react-pdf#readme", + "type": "module", + "main": "./lib/index.js", + "types": "./lib/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/diegomura/react-pdf.git", + "directory": "packages/primitives" + }, + "scripts": { + "build": "rimraf ./lib && rollup -c", + "watch": "rimraf ./lib && rollup -c -w", + "test": "vitest", + "typecheck": "tsc --noEmit" + }, + "files": [ + "lib" + ] +} diff --git a/node_modules/@react-pdf/reconciler/README.md b/node_modules/@react-pdf/reconciler/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bf95723f46f3b4d6b9f55ec22fa227d3eed25d43 --- /dev/null +++ b/node_modules/@react-pdf/reconciler/README.md @@ -0,0 +1,5 @@ +

+ +

+ +# @react-pdf/reconciler diff --git a/node_modules/@react-pdf/reconciler/lib/index.d.ts b/node_modules/@react-pdf/reconciler/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..604e998bc84c1dd50b9af93d6d84840a2270439a --- /dev/null +++ b/node_modules/@react-pdf/reconciler/lib/index.d.ts @@ -0,0 +1,3 @@ +declare let renderer: any; + +export { renderer as default }; diff --git a/node_modules/@react-pdf/reconciler/lib/index.js b/node_modules/@react-pdf/reconciler/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..2fc711e3957520f79b6fca89c5a13952ac5ee0df --- /dev/null +++ b/node_modules/@react-pdf/reconciler/lib/index.js @@ -0,0 +1,22 @@ +import React from 'react'; +import createRendererForReact19 from './reconciler-31.js'; +import createRendererForReact19_2 from './reconciler-33.js'; +import createRendererForReact18AndLess from './reconciler-23.js'; + +const [major, minor] = React.version.split('.').map((v) => parseInt(v, 10)); +let renderer; +if (major >= 20 || (major === 19 && minor >= 2)) { + // Use the reconciler built for 19.2, assuming it's compatible with later versions. + renderer = createRendererForReact19_2; +} +else if (major === 19) { + // Use the older 19.x reconciler (for 19.0.x and 19.1.x) + renderer = createRendererForReact19; +} +else { + // Fallback for React 18.x and previous versions. + renderer = createRendererForReact18AndLess; +} +var renderer$1 = renderer; + +export { renderer$1 as default }; diff --git a/node_modules/@react-pdf/reconciler/lib/reconciler-23.js b/node_modules/@react-pdf/reconciler/lib/reconciler-23.js new file mode 100644 index 0000000000000000000000000000000000000000..c681851ae7138740d9d8b2e577af8bf6eebc4561 --- /dev/null +++ b/node_modules/@react-pdf/reconciler/lib/reconciler-23.js @@ -0,0 +1,10 @@ +import e from"object-assign";import t from"react";import*as n from"scheduler";function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var i,a={exports:{}},u=l(n);( +/** @license React v0.23.0 + * react-reconciler.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +i=a).exports=function n(r){var l=e,a=t,o=u;function f(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;npe||(e.current=de[pe],de[pe]=null,pe--)}function he(e,t){pe++,de[pe]=e.current,e.current=t}var ge={},be={current:ge},ye={current:!1},ve=ge;function Te(e,t){var n=e.type.contextTypes;if(!n)return ge;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l,i={};for(l in n)i[l]=t[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function xe(e){return null!=(e=e.childContextTypes)}function Ee(e){me(ye),me(be)}function ke(e){me(ye),me(be)}function Se(e,t,n){if(be.current!==ge)throw Error(f(168));he(be,t),he(ye,n)}function Ce(e,t,n){var r=e.stateNode;if(e=t.childContextTypes,"function"!=typeof r.getChildContext)return n;for(var i in r=r.getChildContext())if(!(i in e))throw Error(f(108,z(t)||"Unknown",i));return l({},n,{},r)}function we(e){var t=e.stateNode;return t=t&&t.__reactInternalMemoizedMergedChildContext||ge,ve=be.current,he(be,t),he(ye,ye.current),!0}function ze(e,t,n){var r=e.stateNode;if(!r)throw Error(f(169));n?(t=Ce(e,t,ve),r.__reactInternalMemoizedMergedChildContext=t,me(ye),me(be),he(be,t)):me(ye),he(ye,n)}var Pe=o.unstable_runWithPriority,_e=o.unstable_scheduleCallback,Ne=o.unstable_cancelCallback,Ue=o.unstable_shouldYield,Re=o.unstable_requestPaint,Ie=o.unstable_now,Me=o.unstable_getCurrentPriorityLevel,Fe=o.unstable_ImmediatePriority,Qe=o.unstable_UserBlockingPriority,De=o.unstable_NormalPriority,We=o.unstable_LowPriority,je=o.unstable_IdlePriority,Oe={},Be=void 0!==Re?Re:function(){},He=null,Ae=null,Le=!1,$e=Ie(),qe=1e4>$e?Ie:function(){return Ie()-$e};function Ve(){switch(Me()){case Fe:return 99;case Qe:return 98;case De:return 97;case We:return 96;case je:return 95;default:throw Error(f(332))}}function Ke(e){switch(e){case 99:return Fe;case 98:return Qe;case 97:return De;case 96:return We;case 95:return je;default:throw Error(f(332))}}function Ge(e,t){return e=Ke(e),Pe(e,t)}function Ye(e,t,n){return e=Ke(e),_e(e,t,n)}function Je(e){return null===He?(He=[e],Ae=_e(Fe,Ze)):He.push(e),Oe}function Xe(){if(null!==Ae){var e=Ae;Ae=null,Ne(e)}Ze()}function Ze(){if(!Le&&null!==He){Le=!0;var e=0;try{var t=He;Ge(99,(function(){for(;e=t&&(On=!0),e.firstContext=null)}function ht(e,t){if(ft!==e&&!1!==t&&0!==t)if("number"==typeof t&&1073741823!==t||(ft=e,t=1073741823),t={context:e,observedBits:t,next:null},null===ot){if(null===ut)throw Error(f(308));ot=t,ut.dependencies={expirationTime:0,firstContext:t,responders:null}}else ot=ot.next=t;return e._currentValue2}var gt=!1;function bt(e){return{baseState:e,firstUpdate:null,lastUpdate:null,firstCapturedUpdate:null,lastCapturedUpdate:null,firstEffect:null,lastEffect:null,firstCapturedEffect:null,lastCapturedEffect:null}}function yt(e){return{baseState:e.baseState,firstUpdate:e.firstUpdate,lastUpdate:e.lastUpdate,firstCapturedUpdate:null,lastCapturedUpdate:null,firstEffect:null,lastEffect:null,firstCapturedEffect:null,lastCapturedEffect:null}}function vt(e,t){return{expirationTime:e,suspenseConfig:t,tag:0,payload:null,callback:null,next:null,nextEffect:null}}function Tt(e,t){null===e.lastUpdate?e.firstUpdate=e.lastUpdate=t:(e.lastUpdate.next=t,e.lastUpdate=t)}function xt(e,t){var n=e.alternate;if(null===n){var r=e.updateQueue,l=null;null===r&&(r=e.updateQueue=bt(e.memoizedState))}else r=e.updateQueue,l=n.updateQueue,null===r?null===l?(r=e.updateQueue=bt(e.memoizedState),l=n.updateQueue=bt(n.memoizedState)):r=e.updateQueue=yt(l):null===l&&(l=n.updateQueue=yt(r));null===l||r===l?Tt(r,t):null===r.lastUpdate||null===l.lastUpdate?(Tt(r,t),Tt(l,t)):(Tt(r,t),l.lastUpdate=t)}function Et(e,t){var n=e.updateQueue;null===(n=null===n?e.updateQueue=bt(e.memoizedState):kt(e,n)).lastCapturedUpdate?n.firstCapturedUpdate=n.lastCapturedUpdate=t:(n.lastCapturedUpdate.next=t,n.lastCapturedUpdate=t)}function kt(e,t){var n=e.alternate;return null!==n&&t===n.updateQueue&&(t=e.updateQueue=yt(t)),t}function St(e,t,n,r,i,a){switch(n.tag){case 1:return"function"==typeof(e=n.payload)?e.call(a,r,i):e;case 3:e.effectTag=-4097&e.effectTag|64;case 0:if(null==(i="function"==typeof(e=n.payload)?e.call(a,r,i):e))break;return l({},r,i);case 2:gt=!0}return r}function Ct(e,t,n,r,l){gt=!1;for(var i=(t=kt(e,t)).baseState,a=null,u=0,o=t.firstUpdate,f=i;null!==o;){var c=o.expirationTime;cd?(p=s,s=null):p=s.sibling;var m=g(l,s,u[d],o);if(null===m){null===s&&(s=p);break}e&&s&&null===m.alternate&&t(l,s),a=i(m,a,d),null===c?f=m:c.sibling=m,c=m,s=p}if(d===u.length)return n(l,s),f;if(null===s){for(;dp?(m=d,d=null):m=d.sibling;var v=g(l,d,y.value,o);if(null===v){null===d&&(d=m);break}e&&d&&null===v.alternate&&t(l,d),a=i(v,a,p),null===s?c=v:s.sibling=v,s=v,d=m}if(y.done)return n(l,d),c;if(null===d){for(;!y.done;p++,y=u.next())null!==(y=h(l,y.value,o))&&(a=i(y,a,p),null===s?c=y:s.sibling=y,s=y);return c}for(d=r(l,d);!y.done;p++,y=u.next())null!==(y=b(d,l,p,y.value,o))&&(e&&null!==y.alternate&&d.delete(null===y.key?p:y.key),a=i(y,a,p),null===s?c=y:s.sibling=y,s=y);return e&&d.forEach((function(e){return t(l,e)})),c}return function(e,r,i,u){var o="object"==typeof i&&null!==i&&i.type===m&&null===i.key;o&&(i=i.props.children);var c="object"==typeof i&&null!==i;if(c)switch(i.$$typeof){case d:e:{for(c=i.key,o=r;null!==o;){if(o.key===c){if(7===o.tag?i.type===m:o.elementType===i.type){n(e,o.sibling),(r=l(o,i.type===m?i.props.children:i.props)).ref=Dt(e,o,i),r.return=e,e=r;break e}n(e,o);break}t(e,o),o=o.sibling}i.type===m?((r=$l(i.props.children,e.mode,u,i.key)).return=e,e=r):((u=Ll(i.type,i.key,i.props,null,e.mode,u)).ref=Dt(e,r,i),u.return=e,e=u)}return a(e);case p:e:{for(o=i.key;null!==r;){if(r.key===o){if(4===r.tag&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),(r=l(r,i.children||[])).return=e,e=r;break e}n(e,r);break}t(e,r),r=r.sibling}(r=Vl(i,e.mode,u)).return=e,e=r}return a(e)}if("string"==typeof i||"number"==typeof i)return i=""+i,null!==r&&6===r.tag?(n(e,r.sibling),(r=l(r,i)).return=e,e=r):(n(e,r),(r=ql(i,e.mode,u)).return=e,e=r),a(e);if(Qt(i))return y(e,r,i,u);if(w(i))return v(e,r,i,u);if(c&&Wt(e,i),void 0===i&&!o)switch(e.tag){case 1:case 0:throw e=e.type,Error(f(152,e.displayName||e.name||"Component"))}return n(e,r)}}var Ot=jt(!0),Bt=jt(!1),Ht={},At={current:Ht},Lt={current:Ht},$t={current:Ht};function qt(e){if(e===Ht)throw Error(f(174));return e}function Vt(e,t){he($t,t),he(Lt,e),he(At,Ht),t=I(t),me(At),he(At,t)}function Kt(e){me(At),me(Lt),me($t)}function Gt(e){var t=qt($t.current),n=qt(At.current);n!==(t=M(n,e.type,t))&&(he(Lt,e),he(At,t))}function Yt(e){Lt.current===e&&(me(At),me(Lt))}var Jt={current:0};function Xt(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||oe(n)||fe(n)))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!=(64&t.effectTag))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function Zt(e,t){return{responder:e,props:t}}var en=c.ReactCurrentDispatcher,tn=c.ReactCurrentBatchConfig,nn=0,rn=null,ln=null,an=null,un=null,on=null,fn=null,cn=0,sn=null,dn=0,pn=!1,mn=null,hn=0;function gn(){throw Error(f(321))}function bn(e,t){if(null===t)return!1;for(var n=0;ncn&&kl(cn=s)):(El(s,o.suspenseConfig),i=o.eagerReducer===e?o.eagerState:e(i,o.action)),a=o,o=o.next}while(null!==o&&o!==r);c||(u=a,l=i),nt(i,t.memoizedState)||(On=!0),t.memoizedState=i,t.baseUpdate=u,t.baseState=l,n.lastRenderedState=i}return[t.memoizedState,n.dispatch]}function Sn(e){var t=Tn();return"function"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e=(e=t.queue={last:null,dispatch:null,lastRenderedReducer:En,lastRenderedState:e}).dispatch=Fn.bind(null,rn,e),[t.memoizedState,e]}function Cn(e){return kn(En)}function wn(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===sn?(sn={lastEffect:null}).lastEffect=e.next=e:null===(t=sn.lastEffect)?sn.lastEffect=e.next=e:(n=t.next,t.next=e,e.next=n,sn.lastEffect=e),e}function zn(e,t,n,r){var l=Tn();dn|=e,l.memoizedState=wn(t,n,void 0,void 0===r?null:r)}function Pn(e,t,n,r){var l=xn();r=void 0===r?null:r;var i=void 0;if(null!==ln){var a=ln.memoizedState;if(i=a.destroy,null!==r&&bn(r,a.deps))return void wn(0,n,i,r)}dn|=e,l.memoizedState=wn(t,n,i,r)}function _n(e,t){return zn(516,192,e,t)}function Nn(e,t){return Pn(516,192,e,t)}function Un(e,t){return"function"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function Rn(){}function In(e,t){return Tn().memoizedState=[e,void 0===t?null:t],e}function Mn(e,t){var n=xn();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&bn(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Fn(e,t,n){if(!(25>hn))throw Error(f(301));var r=e.alternate;if(e===rn||null!==r&&r===rn)if(pn=!0,e={expirationTime:nn,suspenseConfig:null,action:n,eagerReducer:null,eagerState:null,next:null},null===mn&&(mn=new Map),void 0===(n=mn.get(t)))mn.set(t,e);else{for(t=n;null!==t.next;)t=t.next;t.next=e}else{var l=cl(),i=Pt.suspense;i={expirationTime:l=sl(l,e,i),suspenseConfig:i,action:n,eagerReducer:null,eagerState:null,next:null};var a=t.last;if(null===a)i.next=i;else{var u=a.next;null!==u&&(i.next=u),a.next=i}if(t.last=i,0===e.expirationTime&&(null===r||0===r.expirationTime)&&null!==(r=t.lastRenderedReducer))try{var o=t.lastRenderedState,c=r(o,n);if(i.eagerReducer=r,i.eagerState=c,nt(c,o))return}catch(e){}dl(e,l)}}var Qn={readContext:ht,useCallback:gn,useContext:gn,useEffect:gn,useImperativeHandle:gn,useLayoutEffect:gn,useMemo:gn,useReducer:gn,useRef:gn,useState:gn,useDebugValue:gn,useResponder:gn,useDeferredValue:gn,useTransition:gn},Dn={readContext:ht,useCallback:In,useContext:ht,useEffect:_n,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,zn(4,36,Un.bind(null,t,e),n)},useLayoutEffect:function(e,t){return zn(4,36,e,t)},useMemo:function(e,t){var n=Tn();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Tn();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e=(e=r.queue={last:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:t}).dispatch=Fn.bind(null,rn,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},Tn().memoizedState=e},useState:Sn,useDebugValue:Rn,useResponder:Zt,useDeferredValue:function(e,t){var n=Sn(e),r=n[0],l=n[1];return _n((function(){o.unstable_next((function(){var n=tn.suspense;tn.suspense=void 0===t?null:t;try{l(e)}finally{tn.suspense=n}}))}),[e,t]),r},useTransition:function(e){var t=Sn(!1),n=t[0],r=t[1];return[In((function(t){r(!0),o.unstable_next((function(){var n=tn.suspense;tn.suspense=void 0===e?null:e;try{r(!1),t()}finally{tn.suspense=n}}))}),[e,n]),n]}},Wn={readContext:ht,useCallback:Mn,useContext:ht,useEffect:Nn,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,Pn(4,36,Un.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Pn(4,36,e,t)},useMemo:function(e,t){var n=xn();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&bn(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)},useReducer:kn,useRef:function(){return xn().memoizedState},useState:Cn,useDebugValue:Rn,useResponder:Zt,useDeferredValue:function(e,t){var n=Cn(),r=n[0],l=n[1];return Nn((function(){o.unstable_next((function(){var n=tn.suspense;tn.suspense=void 0===t?null:t;try{l(e)}finally{tn.suspense=n}}))}),[e,t]),r},useTransition:function(e){var t=Cn(),n=t[0],r=t[1];return[Mn((function(t){r(!0),o.unstable_next((function(){var n=tn.suspense;tn.suspense=void 0===e?null:e;try{r(!1),t()}finally{tn.suspense=n}}))}),[e,n]),n]}},jn=c.ReactCurrentOwner,On=!1;function Bn(e,t,n,r){t.child=null===e?Bt(t,null,n,r):Ot(t,e.child,n,r)}function Hn(e,t,n,r,l){n=n.render;var i=t.ref;return mt(t,l),r=yn(e,t,n,r,i,l),null===e||On?(t.effectTag|=1,Bn(e,t,r,l),t.child):(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=l&&(e.expirationTime=0),ir(e,t,l))}function An(e,t,n,r,l,i){if(null===e){var a=n.type;return"function"!=typeof a||Hl(a)||void 0!==a.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=Ll(n.type,null,r,null,t.mode,i)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,Ln(e,t,a,r,l,i))}return a=e.child,lt)&&al.set(e,t))}}function pl(e,t){e.expirationTime(e=e.nextKnownPendingLevel)?t:e:t}function hl(e){if(0!==e.lastExpiredTime)e.callbackExpirationTime=1073741823,e.callbackPriority=99,e.callbackNode=Je(bl.bind(null,e));else{var t=ml(e),n=e.callbackNode;if(0===t)null!==n&&(e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90);else{var r=cl();if(r=1073741823===t?99:1===t||2===t?95:0>=(r=10*(1073741821-t)-10*(1073741821-r))?99:250>=r?98:5250>=r?97:95,null!==n){var l=e.callbackPriority;if(e.callbackExpirationTime===t&&l>=r)return;n!==Oe&&Ne(n)}e.callbackExpirationTime=t,e.callbackPriority=r,t=1073741823===t?Je(bl.bind(null,e)):Ye(r,gl.bind(null,e),{timeout:10*(1073741821-t)-qe()}),e.callbackNode=t}}}function gl(e,t){if(fl=0,t)return Xl(e,t=cl()),hl(e),null;var n=ml(e);if(0!==n){if(t=e.callbackNode,(Or&(Rr|Ir))!==Nr)throw Error(f(327));if(Rl(),e===Br&&n===Ar||vl(e,n),null!==Hr){var r=Or;Or|=Rr;for(var l=xl();;)try{Cl();break}catch(t){Tl(e,t)}if(ct(),Or=r,Pr.current=l,Lr===Fr)throw t=$r,vl(e,n),Yl(e,n),hl(e),t;if(null===Hr)switch(l=e.finishedWork=e.current.alternate,e.finishedExpirationTime=n,r=Lr,Br=null,r){case Mr:case Fr:throw Error(f(345));case Qr:Xl(e,2=n){e.lastPingedTime=n,vl(e,n);break}}if(0!==(i=ml(e))&&i!==n)break;if(0!==r&&r!==n){e.lastPingedTime=r;break}e.timeoutHandle=A(_l.bind(null,e),l);break}_l(e);break;case Wr:if(Yl(e,n),n===(r=e.lastSuspendedTime)&&(e.nextKnownPendingLevel=Pl(l)),Yr&&(0===(l=e.lastPingedTime)||l>=n)){e.lastPingedTime=n,vl(e,n);break}if(0!==(l=ml(e))&&l!==n)break;if(0!==r&&r!==n){e.lastPingedTime=r;break}if(1073741823!==Vr?r=10*(1073741821-Vr)-qe():1073741823===qr?r=0:(r=10*(1073741821-qr)-5e3,0>(r=(l=qe())-r)&&(r=0),(n=10*(1073741821-n)-l)<(r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*zr(r/1960))-r)&&(r=n)),10=(r=0|a.busyMinDurationMs)?r=0:(l=0|a.busyDelayMs,r=(i=qe()-(10*(1073741821-i)-(0|a.timeoutMs||5e3)))<=l?0:l+r-i),10 component higher in the tree to provide a loading indicator or placeholder to display."+se(l))}Lr!==jr&&(Lr=Qr),i=fr(i,l),o=r;do{switch(o.tag){case 3:a=i,o.effectTag|=4096,o.expirationTime=t,Et(o,Sr(o,a,t));break e;case 1:a=i;var b=o.type,y=o.stateNode;if(0==(64&o.effectTag)&&("function"==typeof b.getDerivedStateFromError||null!==y&&"function"==typeof y.componentDidCatch&&(null===nl||!nl.has(y)))){o.effectTag|=4096,o.expirationTime=t,Et(o,Cr(o,a,t));break e}}o=o.return}while(null!==o)}Hr=zl(Hr)}catch(e){t=e;continue}break}}function xl(){var e=Pr.current;return Pr.current=Qn,null===e?Qn:e}function El(e,t){eGr&&(Gr=e)}function Sl(){for(;null!==Hr;)Hr=wl(Hr)}function Cl(){for(;null!==Hr&&!Ue();)Hr=wl(Hr)}function wl(e){var t=wr(e.alternate,e,Ar);return e.memoizedProps=e.pendingProps,null===t&&(t=zl(e)),_r.current=null,t}function zl(e){Hr=e;do{var t=Hr.alternate;if(e=Hr.return,0==(2048&Hr.effectTag)){e:{var n=t,r=Ar,l=(t=Hr).pendingProps;switch(t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 20:case 21:break;case 1:case 17:xe(t.type)&&Ee();break;case 3:Kt(),ke(),(l=t.stateNode).pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),null===n||n.child,Jn(t);break;case 5:Yt(t);var i=qt($t.current);if(r=t.type,null!==n&&null!=t.stateNode)Xn(n,t,r,l,i),n.ref!==t.ref&&(t.effectTag|=128);else if(l){n=qt(At.current);var a=D(r,l,i,n,t);Yn(a,t,!1,!1),t.stateNode=a,j(a,r,l,i,n)&&ar(t),null!==t.ref&&(t.effectTag|=128)}else if(null===t.stateNode)throw Error(f(166));break;case 6:if(n&&null!=t.stateNode)Zn(n,t,n.memoizedProps,l);else{if("string"!=typeof l&&null===t.stateNode)throw Error(f(166));n=qt($t.current),i=qt(At.current),t.stateNode=H(l,n,i,t)}break;case 13:if(me(Jt),l=t.memoizedState,0!=(64&t.effectTag)){t.expirationTime=r;break e}l=null!==l,i=!1,null===n?t.memoizedProps.fallback:(i=null!==(r=n.memoizedState),l||null===r||null!==(r=n.child.sibling)&&(null!==(a=t.firstEffect)?(t.firstEffect=r,r.nextEffect=a):(t.firstEffect=t.lastEffect=r,r.nextEffect=null),r.effectTag=8)),l&&!i&&0!=(2&t.mode)&&(null===n&&!0!==t.memoizedProps.unstable_avoidThisFallback||0!=(1&Jt.current)?Lr===Mr&&(Lr=Dr):(Lr!==Mr&&Lr!==Dr||(Lr=Wr),0!==Gr&&null!==Br&&(Yl(Br,Ar),Jl(Br,Gr)))),(l||i)&&(t.effectTag|=4);break;case 4:Kt(),Jn(t);break;case 10:dt(t);break;case 19:if(me(Jt),null===(l=t.memoizedState))break;if(i=0!=(64&t.effectTag),null===(a=l.rendering)){if(i)ur(l,!1);else if(Lr!==Mr||null!==n&&0!=(64&n.effectTag))for(n=t.child;null!==n;){if(null!==(a=Xt(n))){for(t.effectTag|=64,ur(l,!1),null!==(n=a.updateQueue)&&(t.updateQueue=n,t.effectTag|=4),null===l.lastEffect&&(t.firstEffect=null),t.lastEffect=l.lastEffect,n=r,l=t.child;null!==l;)r=n,(i=l).effectTag&=2,i.nextEffect=null,i.firstEffect=null,i.lastEffect=null,null===(a=i.alternate)?(i.childExpirationTime=0,i.expirationTime=r,i.child=null,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null):(i.childExpirationTime=a.childExpirationTime,i.expirationTime=a.expirationTime,i.child=a.child,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,r=a.dependencies,i.dependencies=null===r?null:{expirationTime:r.expirationTime,firstContext:r.firstContext,responders:r.responders}),l=l.sibling;he(Jt,1&Jt.current|2),t=t.child;break e}n=n.sibling}}else{if(!i)if(null!==(n=Xt(a))){if(t.effectTag|=64,i=!0,null!==(n=n.updateQueue)&&(t.updateQueue=n,t.effectTag|=4),ur(l,!0),null===l.tail&&"hidden"===l.tailMode){null!==(t=t.lastEffect=l.lastEffect)&&(t.nextEffect=null);break}}else qe()>l.tailExpiration&&1l&&(l=r),(a=i.childExpirationTime)>l&&(l=a),i=i.sibling;n.childExpirationTime=l}if(null!==t)return t;null!==e&&0==(2048&e.effectTag)&&(null===e.firstEffect&&(e.firstEffect=Hr.firstEffect),null!==Hr.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=Hr.firstEffect),e.lastEffect=Hr.lastEffect),1(e=e.childExpirationTime)?t:e}function _l(e){var t=Ve();return Ge(99,Nl.bind(null,e,t)),null}function Nl(e,t){if(Rl(),(Or&(Rr|Ir))!==Nr)throw Error(f(327));var n=e.finishedWork,r=e.finishedExpirationTime;if(null===n)return null;if(e.finishedWork=null,e.finishedExpirationTime=0,n===e.current)throw Error(f(177));e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90,e.nextKnownPendingLevel=0;var l=Pl(n);if(e.firstPendingTime=l,r<=e.lastSuspendedTime?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:r<=e.firstSuspendedTime&&(e.firstSuspendedTime=r-1),r<=e.lastPingedTime&&(e.lastPingedTime=0),r<=e.lastExpiredTime&&(e.lastExpiredTime=0),e===Br&&(Hr=Br=null,Ar=0),1=n?tr(e,t,n):(he(Jt,1&Jt.current),null!==(t=ir(e,t,n))?t.sibling:null);he(Jt,1&Jt.current);break;case 19:if(r=t.childExpirationTime>=n,0!=(64&e.effectTag)){if(r)return lr(e,t,n);t.effectTag|=64}if(null!==(l=t.memoizedState)&&(l.rendering=null,l.tail=null),he(Jt,Jt.current),!r)return null}return ir(e,t,n)}On=!1}}else On=!1;switch(t.expirationTime=0,t.tag){case 2:if(r=t.type,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,l=Te(t,be.current),mt(t,n),l=yn(null,t,r,e,l,n),t.effectTag|=1,"object"==typeof l&&null!==l&&"function"==typeof l.render&&void 0===l.$$typeof){if(t.tag=1,vn(),xe(r)){var i=!0;we(t)}else i=!1;t.memoizedState=null!==l.state&&void 0!==l.state?l.state:null;var a=r.getDerivedStateFromProps;"function"==typeof a&&Nt(t,r,a,e),l.updater=Ut,t.stateNode=l,l._reactInternalFiber=t,Ft(t,r,e,n),t=Kn(null,t,r,!0,i,n)}else t.tag=0,Bn(null,t,l,n),t=t.child;return t;case 16:if(l=t.elementType,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,function(e){if(-1===e._status){e._status=0;var t=e._ctor;t=t(),e._result=t,t.then((function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)}),(function(t){0===e._status&&(e._status=2,e._result=t)}))}}(l),1!==l._status)throw l._result;switch(l=l._result,t.type=l,i=t.tag=function(e){if("function"==typeof e)return Hl(e)?1:0;if(null!=e){if((e=e.$$typeof)===T)return 11;if(e===k)return 14}return 2}(l),e=it(l,e),i){case 0:t=qn(null,t,l,e,n);break;case 1:t=Vn(null,t,l,e,n);break;case 11:t=Hn(null,t,l,e,n);break;case 14:t=An(null,t,l,it(l.type,e),r,n);break;default:throw Error(f(306,l,""))}return t;case 0:return r=t.type,l=t.pendingProps,qn(e,t,r,l=t.elementType===r?l:it(r,l),n);case 1:return r=t.type,l=t.pendingProps,Vn(e,t,r,l=t.elementType===r?l:it(r,l),n);case 3:if(Gn(t),null===(r=t.updateQueue))throw Error(f(282));if(l=null!==(l=t.memoizedState)?l.element:null,Ct(t,r,t.pendingProps,null,n),(r=t.memoizedState.element)===l)t=ir(e,t,n);else{if((l=t.stateNode.hydrate)&&(l=!1),l)for(n=Bt(t,null,r,n),t.child=n;n;)n.effectTag=-3&n.effectTag|1024,n=n.sibling;else Bn(e,t,r,n);t=t.child}return t;case 5:return Gt(t),r=t.type,l=t.pendingProps,i=null!==e?e.memoizedProps:null,a=l.children,B(r,l)?a=null:null!==i&&B(r,i)&&(t.effectTag|=16),$n(e,t),4&t.mode&&1!==n&&null(r,l)?(t.expirationTime=t.childExpirationTime=1,t=null):(Bn(e,t,a,n),t=t.child),t;case 6:return null;case 13:return tr(e,t,n);case 4:return Vt(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=Ot(t,null,r,n):Bn(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,Hn(e,t,r,l=t.elementType===r?l:it(r,l),n);case 7:return Bn(e,t,t.pendingProps,n),t.child;case 8:case 12:return Bn(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,a=t.memoizedProps,st(t,i=l.value),null!==a){var u=a.value;if(0==(i=nt(u,i)?0:0|("function"==typeof r._calculateChangedBits?r._calculateChangedBits(u,i):1073741823))){if(a.children===l.children&&!ye.current){t=ir(e,t,n);break e}}else for(null!==(u=t.child)&&(u.return=t);null!==u;){var o=u.dependencies;if(null!==o){a=u.child;for(var c=o.firstContext;null!==c;){if(c.context===r&&0!=(c.observedBits&i)){1===u.tag&&((c=vt(n,null)).tag=2,xt(u,c)),u.expirationTime=t&&e<=t}function Yl(e,t){var n=e.firstSuspendedTime,r=e.lastSuspendedTime;nt||0===n)&&(e.lastSuspendedTime=t),t<=e.lastPingedTime&&(e.lastPingedTime=0),t<=e.lastExpiredTime&&(e.lastExpiredTime=0)}function Jl(e,t){t>e.firstPendingTime&&(e.firstPendingTime=t);var n=e.firstSuspendedTime;0!==n&&(t>=n?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:t>=e.lastSuspendedTime&&(e.lastSuspendedTime=t+1),t>e.nextKnownPendingLevel&&(e.nextKnownPendingLevel=t))}function Xl(e,t){var n=e.lastExpiredTime;(0===n||n>t)&&(e.lastExpiredTime=t)}function Zl(e){var t=e._reactInternalFiber;if(void 0===t){if("function"==typeof e.render)throw Error(f(188));throw Error(f(268,Object.keys(e)))}return null===(e=U(t))?null:e.stateNode}function ei(e,t){null!==(e=e.memoizedState)&&null!==e.dehydrated&&e.retryTime{const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r=0;ro({appendChild:e,appendChildToContainer:t,appendInitialChild:e,createInstance:l,createTextInstance:i,insertBefore:a,commitUpdate:r,commitTextUpdate:n,removeChild:u,removeChildFromContainer:s,resetAfterCommit:d,shouldSetTextContent:()=>!1,finalizeInitialChildren:()=>!1,getPublicInstance:e=>e,getRootHostContext:()=>c,getChildHostContext:()=>c,prepareForCommit(){},clearContainer(){},resetTextContent(){},prepareUpdate:(e,t,n,r)=>!f(n,r)});export{s as default}; diff --git a/node_modules/@react-pdf/reconciler/lib/reconciler-31.js b/node_modules/@react-pdf/reconciler/lib/reconciler-31.js new file mode 100644 index 0000000000000000000000000000000000000000..5651bdf318b7cce1b0deef8f6f5fddc357ebd277 --- /dev/null +++ b/node_modules/@react-pdf/reconciler/lib/reconciler-31.js @@ -0,0 +1,19 @@ +import e from"react";import*as n from"scheduler";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(e){if(e.__esModule)return e;var n=e.default;if("function"==typeof n){var t=function e(){return this instanceof e?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}var l,a={exports:{}},o={exports:{}},u=r(n);var i,s,c={exports:{}}; +/** + * @license React + * react-reconciler.development.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */"production"===process.env.NODE_ENV?a.exports=(l||(l=1,(s=o).exports=function(n){function t(e,n,t,r){return new $r(e,n,t,r)}function r(e){var n="https://react.dev/errors/"+e;if(1)":-1--l||s[r]!==c[l]){var f="\n"+s[r].replace(" at new "," at ");return e.displayName&&f.includes("")&&(f=f.replace("",e.displayName)),f}}while(1<=r&&0<=l);break}}}finally{_l=!1,Error.prepareStackTrace=t}return(t=e?e.displayName||e.name:"")?o(t):""}function s(e){switch(e.tag){case 26:case 27:case 5:return o(e.type);case 16:return o("Lazy");case 13:return o("Suspense");case 19:return o("SuspenseList");case 0:case 15:return i(e.type,!1);case 11:return i(e.type.render,!1);case 1:return i(e.type,!0);default:return""}}function c(e){try{var n="";do{n+=s(e),e=e.return}while(e);return n}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}function f(e){return{current:e}}function d(e){0>Na||(e.current=Ta[Na],Ta[Na]=null,Na--)}function p(e,n){Na++,Ta[Na]=e.current,e.current=n}function m(e){var n=42&e;if(0!==n)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194176&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function h(e,n){var t=e.pendingLanes;if(0===t)return 0;var r=0,l=e.suspendedLanes;e=e.pingedLanes;var a=134217727&t;return 0!==a?0!=(t=a&~l)?r=m(t):0!=(e&=a)&&(r=m(e)):0!=(t&=~l)?r=m(t):0!==e&&(r=m(e)),0===r?0:0!==n&&n!==r&&0==(n&l)&&((l=r&-r)>=(e=n&-n)||32===l&&0!=(4194176&e))?n:r}function g(e,n){switch(e){case 1:case 2:case 4:case 8:return n+250;case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;default:return-1}}function y(){var e=Fa;return 0==(4194176&(Fa<<=1))&&(Fa=128),e}function b(){var e=Ma;return 0==(62914560&(Ma<<=1))&&(Ma=4194304),e}function v(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function S(e,n){e.pendingLanes|=n,268435456!==n&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function k(e,n,t){e.pendingLanes|=n,e.suspendedLanes&=~n;var r=31-Ua(n);e.entangledLanes|=n,e.entanglements[r]=1073741824|e.entanglements[r]|4194218&t}function w(e,n){var t=e.entangledLanes|=n;for(e=e.entanglements;t;){var r=31-Ua(t),l=1<d?(p=f,f=null):p=f.sibling;var y=h(t,f,l[d],u);if(null===y){null===f&&(f=p);break}e&&f&&null===y.alternate&&n(t,f),r=i(y,r,d),null===c?s=y:c.sibling=y,c=y,f=p}if(d===l.length)return a(t,f),s;if(null===f){for(;dp?(y=d,d=null):y=d.sibling;var v=h(t,d,b.value,s);if(null===v){null===d&&(d=y);break}e&&d&&null===v.alternate&&n(t,d),l=i(v,l,p),null===f?c=v:f.sibling=v,f=v,d=y}if(b.done)return a(t,d),c;if(null===d){for(;!b.done;p++,b=u.next())null!==(b=m(t,b.value,s))&&(l=i(b,l,p),null===f?c=b:f.sibling=b,f=b);return c}for(d=o(d);!b.done;p++,b=u.next())null!==(b=g(d,t,p,b.value,s))&&(e&&null!==b.alternate&&d.delete(null===b.key?p:b.key),l=i(b,l,p),null===f?c=b:f.sibling=b,f=b);return e&&d.forEach((function(e){return n(t,e)})),c}(t,c,f=b.call(f),d)}if("function"==typeof f.then)return y(t,c,oe(f),d);if(f.$$typeof===yl)return y(t,c,yt(t,f),d);ie(t,f)}return"string"==typeof f&&""!==f||"number"==typeof f||"bigint"==typeof f?(f=""+f,null!==c&&6===c.tag?(a(t,c.sibling),(c=u(c,f)).return=t,t=c):(a(t,c),(c=Zr(f,t.mode,d)).return=t,t=c),s(t)):a(t,c)}return function(e,n,r,l){try{Lo=0;var a=y(e,n,r,l);return No=null,a}catch(n){if(n===Po)throw n;var o=t(29,n,null,e.mode);return o.lanes=l,o.return=e,o}}}function fe(e,n){p(Fo,e=Mu),p(Io,n),Mu=e|n.baseLanes}function de(){p(Fo,Mu),p(Io,Io.current)}function pe(){Mu=Fo.current,d(Io),d(Fo)}function me(e){var n=e.alternate;p(Ho,1&Ho.current),p(Mo,e),null===Wo&&(null===n||null!==Io.current||null!==n.memoizedState)&&(Wo=e)}function he(e){if(22===e.tag){if(p(Ho,Ho.current),p(Mo,e),null===Wo){var n=e.alternate;null!==n&&null!==n.memoizedState&&(Wo=e)}}else ge()}function ge(){p(Ho,Ho.current),p(Mo,Mo.current)}function ye(e){d(Mo),Wo===e&&(Wo=null),d(Ho)}function be(e){for(var n=e;null!==n;){if(13===n.tag){var t=n.memoizedState;if(null!==t&&(null===(t=t.dehydrated)||Sa(t)||ka(t)))return n}else if(19===n.tag&&void 0!==n.memoizedProps.revealOrder){if(0!=(128&n.flags))return n}else if(null!==n.child){n.child.return=n,n=n.child;continue}if(n===e)break;for(;null===n.sibling;){if(null===n.return||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}function ve(){throw Error(r(321))}function Se(e,n){if(null===n)return!1;for(var t=0;ta?a:8);var o,u,i,s=Pl.T,c={};Pl.T=c,Pn(e,!1,n,t);try{var f=l(),d=Pl.S;null!==d&&d(c,f),null!==f&&"object"==typeof f&&"function"==typeof f.then?En(e,n,(o=r,u=[],i={status:"pending",value:null,reason:null,then:function(e){u.push(e)}},f.then((function(){i.status="fulfilled",i.value=o;for(var e=0;eYu&&(n.flags|=128,l=!0,Et(a,!1),n.lanes=4194304)}else{if(!l)if(null!==(e=be(o))){if(n.flags|=128,l=!0,e=e.updateQueue,n.updateQueue=e,Ct(n,e),Et(a,!0),null===a.tail&&"hidden"===a.tailMode&&!o.alternate)return Pt(n),null}else 2*Qa()-a.renderingStartTime>Yu&&536870912!==t&&(n.flags|=128,l=!0,Et(a,!1),n.lanes=4194304);a.isBackwards?(o.sibling=n.child,n.child=o):(null!==(e=a.last)?e.sibling=o:n.child=o,a.last=o)}return null!==a.tail?(n=a.tail,a.rendering=n,a.tail=n.sibling,a.renderingStartTime=Qa(),n.sibling=null,e=Ho.current,p(Ho,l?1&e|2:1&e),n):(Pt(n),null);case 22:case 23:return ye(n),pe(),l=null!==n.memoizedState,null!==e?null!==e.memoizedState!==l&&(n.flags|=8192):l&&(n.flags|=8192),l?0!=(536870912&t)&&0==(128&n.flags)&&(Pt(n),6&n.subtreeFlags&&(n.flags|=8192)):Pt(n),null!==(t=n.updateQueue)&&Ct(n,t.retryQueue),t=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(t=e.memoizedState.cachePool.pool),l=null,null!==n.memoizedState&&null!==n.memoizedState.cachePool&&(l=n.memoizedState.cachePool.pool),l!==t&&(n.flags|=2048),null!==e&&d(hu),null;case 24:return t=null,null!==e&&(t=e.memoizedState.cache),n.memoizedState.cache!==t&&(n.flags|=2048),ct(pu),Pt(n),null;case 25:return null}throw Error(r(156,n.tag))}function Rt(e,n){switch(E(n),n.tag){case 1:return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 3:return ct(pu),_(),0!=(65536&(e=n.flags))&&0==(128&e)?(n.flags=-65537&e|128,n):null;case 26:case 27:case 5:return T(n),null;case 13:if(ye(n),null!==(e=n.memoizedState)&&null!==e.dehydrated&&null===n.alternate)throw Error(r(340));return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 19:return d(Ho),null;case 4:return _(),null;case 10:return ct(n.type),null;case 22:case 23:return ye(n),pe(),null!==e&&d(hu),65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 24:return ct(pu),null;default:return null}}function Tt(e,n){switch(E(n),n.tag){case 3:ct(pu),_();break;case 26:case 27:case 5:T(n);break;case 4:_();break;case 13:ye(n);break;case 19:d(Ho);break;case 10:ct(n.type);break;case 22:case 23:ye(n),pe(),null!==e&&d(hu);break;case 24:ct(pu)}}function Nt(e,n){try{var t=n.updateQueue,r=null!==t?t.lastEffect:null;if(null!==r){var l=r.next;t=l;do{if((t.tag&e)===e){r=void 0;var a=t.create,o=t.inst;r=a(),o.destroy=r}t=t.next}while(t!==l)}}catch(e){jr(n,n.return,e)}}function Lt(e,n,t){try{var r=n.updateQueue,l=null!==r?r.lastEffect:null;if(null!==l){var a=l.next;r=a;do{if((r.tag&e)===e){var o=r.inst,u=o.destroy;if(void 0!==u){o.destroy=void 0,l=n;var i=t;try{u()}catch(e){jr(l,i,e)}}}r=r.next}while(r!==a)}}catch(e){jr(n,n.return,e)}}function Ut(e){var n=e.updateQueue;if(null!==n){var t=e.stateNode;try{ee(n,t)}catch(n){jr(e,e.return,n)}}}function Dt(e,n,t){t.props=Dn(e.type,e.memoizedProps),t.state=e.memoizedState;try{t.componentWillUnmount()}catch(t){jr(e,n,t)}}function It(e,n){try{var t=e.ref;if(null!==t){var r=e.stateNode;switch(e.tag){case 26:case 27:case 5:var l=Tl(r);break;default:l=r}"function"==typeof t?e.refCleanup=t(l):t.current=l}}catch(t){jr(e,n,t)}}function Ft(e,n){var t=e.ref,r=e.refCleanup;if(null!==t)if("function"==typeof r)try{r()}catch(t){jr(e,n,t)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof t)try{t(null)}catch(t){jr(e,n,t)}else t.current=null}function Mt(e){var n=e.type,t=e.memoizedProps,r=e.stateNode;try{ia(r,n,t,e)}catch(n){jr(e,e.return,n)}}function Wt(e){return 5===e.tag||3===e.tag||4===e.tag}function Ht(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||Wt(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function jt(e,n,t){var r=e.tag;if(5===r||6===r)e=e.stateNode,n?fa(t,e,n):oa(t,e);else if(4!==r&&!Ra&&null!==(e=e.child))for(jt(e,n,t),e=e.sibling;null!==e;)jt(e,n,t),e=e.sibling}function At(e,n,t){var r=e.tag;if(5===r||6===r)e=e.stateNode,n?ca(t,e,n):aa(t,e);else if(4!==r&&!Ra&&null!==(e=e.child))for(At(e,n,t),e=e.sibling;null!==e;)At(e,n,t),e=e.sibling}function Qt(e,n,t){var r=t.flags;switch(t.tag){case 0:case 11:case 15:Kt(e,t),4&r&&Nt(5,t);break;case 1:if(Kt(e,t),4&r)if(e=t.stateNode,null===n)try{e.componentDidMount()}catch(e){jr(t,t.return,e)}else{var l=Dn(t.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(l,n,e.__reactInternalSnapshotBeforeUpdate)}catch(e){jr(t,t.return,e)}}64&r&&Ut(t),512&r&&It(t,t.return);break;case 3:if(Kt(e,t),64&r&&null!==(r=t.updateQueue)){if(e=null,null!==t.child)switch(t.child.tag){case 27:case 5:e=Tl(t.child.stateNode);break;case 1:e=t.child.stateNode}try{ee(r,e)}catch(e){jr(t,t.return,e)}}break;case 26:case 27:case 5:Kt(e,t),null===n&&4&r&&Mt(t),512&r&&It(t,t.return);break;case 12:case 13:default:Kt(e,t);break;case 22:if(!(l=null!==t.memoizedState||gu)){n=null!==n&&null!==n.memoizedState||yu;var a=gu,o=yu;gu=l,(yu=n)&&!o?Zt(e,t,0!=(8772&t.subtreeFlags)):Kt(e,t),gu=a,yu=o}512&r&&("manual"===t.memoizedProps.mode?It(t,t.return):Ft(t,t.return))}}function Ot(e){var n=e.alternate;null!==n&&(e.alternate=null,Ot(n)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&null!==(n=e.stateNode)&&Jl(n),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Bt(e,n,t){for(t=t.child;null!==t;)Vt(e,n,t),t=t.sibling}function Vt(e,n,t){switch(t.tag){case 26:case 27:var r,l;case 5:yu||Ft(t,n);case 6:if(r=wu,l=xu,wu=null,Bt(e,n,t),xu=l,null!==(wu=r))if(xu)try{pa(wu,t.stateNode)}catch(e){jr(t,n,e)}else try{da(wu,t.stateNode)}catch(e){jr(t,n,e)}break;case 18:null!==wu&&(xu?Ca(wu,t.stateNode):za(wu,t.stateNode));break;case 4:r=wu,l=xu,wu=t.stateNode.containerInfo,xu=!0,Bt(e,n,t),wu=r,xu=l;break;case 0:case 11:case 14:case 15:yu||Lt(2,t,n),yu||Lt(4,t,n),Bt(e,n,t);break;case 1:yu||(Ft(t,n),"function"==typeof(r=t.stateNode).componentWillUnmount&&Dt(t,n,r)),Bt(e,n,t);break;case 21:Bt(e,n,t);break;case 22:Ft(t,n),yu=(r=yu)||null!==t.memoizedState,Bt(e,n,t),yu=r;break;default:Bt(e,n,t)}}function $t(e,n){var t=function(e){switch(e.tag){case 13:case 19:var n=e.stateNode;return null===n&&(n=e.stateNode=new vu),n;case 22:return null===(n=(e=e.stateNode)._retryCache)&&(n=e._retryCache=new vu),n;default:throw Error(r(435,e.tag))}}(e);n.forEach((function(n){var r=Vr.bind(null,e,n);t.has(n)||(t.add(n),n.then(r,r))}))}function qt(e,n){var t=n.deletions;if(null!==t)for(var l=0;lt?32:t;t=Pl.T;var a=ql();try{if($l(l),Pl.T=null,null===Xu)var o=!1;else{l=ni,ni=null;var u=Xu,i=Zu;if(Xu=null,Zu=0,0!=(6&Ru))throw Error(r(331));var s=Ru;Ru|=4,cr(u.current),rr(u,u.current,i,l),Ru=s,W(0),Ga&&Ga.onPostCommitFiberRoot,o=!0}return o}finally{$l(a),Pl.T=t,Mr(e,n)}}return!1}function Hr(e,n,t){n=C(t,n),null!==(e=Y(e,n=Mn(e.stateNode,n,2),2))&&(S(e,2),M(e))}function jr(e,n,t){if(3===e.tag)Hr(e,e,t);else for(;null!==n;){if(3===n.tag){Hr(n,e,t);break}if(1===n.tag){var r=n.stateNode;if("function"==typeof n.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===Ju||!Ju.has(r))){e=C(t,e),null!==(r=Y(n,t=Wn(2),2))&&(Hn(t,r,n,e),S(r,2),M(r));break}}n=n.return}}function Ar(e,n,t){var r=e.pingCache;if(null===r){r=e.pingCache=new _u;var l=new Set;r.set(n,l)}else void 0===(l=r.get(n))&&(l=new Set,r.set(n,l));l.has(t)||(Fu=!0,l.add(t),e=Qr.bind(null,e,n,t),n.then(e,e))}function Qr(e,n,t){var r=e.pingCache;null!==r&&r.delete(n),e.pingedLanes|=e.suspendedLanes&t,e.warmLanes&=~t,Tu===e&&(Lu&t)===t&&(4===Wu||3===Wu&&(62914560&Lu)===Lu&&300>Qa()-qu?0==(2&Ru)&&wr(e,0):Au|=t,Ou===Lu&&(Ou=0)),M(e)}function Or(e,n){0===n&&(n=b()),null!==(e=D(e,n))&&(S(e,n),M(e))}function Br(e){var n=e.memoizedState,t=0;null!==n&&(t=n.retryLane),Or(e,t)}function Vr(e,n){var t=0;switch(e.tag){case 13:var l=e.stateNode,a=e.memoizedState;null!==a&&(t=a.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(r(314))}null!==l&&l.delete(n),Or(e,t)}function $r(e,n,t,r){this.tag=e,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function qr(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Yr(e,n){var r=e.alternate;return null===r?((r=t(e.tag,n,e.key,e.mode)).elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=31457280&e.flags,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function Gr(e,n){e.flags&=31457282;var t=e.alternate;return null===t?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=t.childLanes,e.lanes=t.lanes,e.child=t.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=t.memoizedProps,e.memoizedState=t.memoizedState,e.updateQueue=t.updateQueue,e.type=t.type,n=t.dependencies,e.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function Jr(e,n,l,a,o,u){var i=0;if(a=e,"function"==typeof e)qr(e)&&(i=1);else if("string"==typeof e)i=5;else e:switch(e){case dl:return Kr(l.children,o,u,n);case pl:i=8,o|=24;break;case ml:return(e=t(12,l,n,2|o)).elementType=ml,e.lanes=u,e;case vl:return(e=t(13,l,n,o)).elementType=vl,e.lanes=u,e;case Sl:return(e=t(19,l,n,o)).elementType=Sl,e.lanes=u,e;case xl:return Xr(l,o,u,n);default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case hl:case yl:i=10;break e;case gl:i=9;break e;case bl:i=11;break e;case kl:i=14;break e;case wl:i=16,a=null;break e}i=29,l=Error(r(130,null===e?"null":typeof e,"")),a=null}return(n=t(i,l,n,o)).elementType=e,n.type=a,n.lanes=u,n}function Kr(e,n,r,l){return(e=t(7,e,l,n)).lanes=r,e}function Xr(e,n,l,a){(e=t(22,e,a,n)).elementType=xl,e.lanes=l;var o={_visibility:1,_pendingVisibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null,_current:null,detach:function(){var e=o._current;if(null===e)throw Error(r(456));if(0==(2&o._pendingVisibility)){var n=D(e,2);null!==n&&(o._pendingVisibility|=2,hr(n,0,2))}},attach:function(){var e=o._current;if(null===e)throw Error(r(456));if(0!=(2&o._pendingVisibility)){var n=D(e,2);null!==n&&(o._pendingVisibility&=-3,hr(n,0,2))}}};return e.stateNode=o,e}function Zr(e,n,r){return(e=t(6,e,null,n)).lanes=r,e}function el(e,n,r){return(n=t(4,null!==e.children?e.children:[],e.key,n)).lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function nl(e,n,t,r,l,a,o,u){this.tag=1,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=Ql,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=v(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.finishedLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=v(0),this.hiddenUpdates=v(null),this.identifierPrefix=r,this.onUncaughtError=l,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=u,this.incompleteTransitions=new Map}function tl(e,n,t,r,l,a){l=function(e){return e?e=La:La}(l),null===r.context?r.context=l:r.pendingContext=l,(r=q(n)).payload={element:t},null!==(a=void 0===a?null:a)&&(r.callback=a),null!==(t=Y(e,r,n))&&(hr(t,0,n),G(t,e,n))}var rl,ll,al={},ol=e,ul=u,il=Object.assign,sl=Symbol.for("react.element"),cl=Symbol.for("react.transitional.element"),fl=Symbol.for("react.portal"),dl=Symbol.for("react.fragment"),pl=Symbol.for("react.strict_mode"),ml=Symbol.for("react.profiler"),hl=Symbol.for("react.provider"),gl=Symbol.for("react.consumer"),yl=Symbol.for("react.context"),bl=Symbol.for("react.forward_ref"),vl=Symbol.for("react.suspense"),Sl=Symbol.for("react.suspense_list"),kl=Symbol.for("react.memo"),wl=Symbol.for("react.lazy"),xl=Symbol.for("react.offscreen"),zl=Symbol.for("react.memo_cache_sentinel"),Cl=Symbol.iterator,El=Symbol.for("react.client.reference"),Pl=ol.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_l=!1,Rl=Array.isArray,Tl=n.getPublicInstance,Nl=n.getRootHostContext,Ll=n.getChildHostContext,Ul=n.prepareForCommit,Dl=n.resetAfterCommit,Il=n.createInstance,Fl=n.appendInitialChild,Ml=n.finalizeInitialChildren,Wl=n.shouldSetTextContent,Hl=n.createTextInstance,jl=null,Al=null,Ql=n.noTimeout,Ol=!0,Bl=null,Vl=null,$l=n.setCurrentUpdatePriority,ql=n.getCurrentUpdatePriority,Yl=n.resolveUpdatePriority;n.resolveEventType,n.resolveEventTimeStamp;var Gl=n.shouldAttemptEagerTransition,Jl=n.detachDeletedInstance;n.requestPostPaintCallback;var Kl=n.maySuspendCommit,Xl=null,Zl=null,ea=null,na=null,ta=null,ra=null,la=null,aa=n.appendChild,oa=n.appendChildToContainer,ua=n.commitTextUpdate,ia=null,sa=n.commitUpdate,ca=n.insertBefore,fa=null,da=n.removeChild,pa=n.removeChildFromContainer,ma=n.resetTextContent,ha=null,ga=null,ya=null,ba=null,va=n.clearContainer,Sa=null,ka=null,wa=null,xa=null,za=null,Ca=null,Ea=null,Pa=null,_a=null,Ra=null,Ta=[],Na=-1,La={},Ua=Math.clz32?Math.clz32:function(e){return 0==(e>>>=0)?32:31-(Da(e)/Ia|0)|0},Da=Math.log,Ia=Math.LN2,Fa=128,Ma=4194304,Wa=ul.unstable_scheduleCallback,Ha=ul.unstable_cancelCallback,ja=ul.unstable_shouldYield,Aa=ul.unstable_requestPaint,Qa=ul.unstable_now,Oa=ul.unstable_ImmediatePriority,Ba=ul.unstable_UserBlockingPriority,Va=ul.unstable_NormalPriority,$a=ul.unstable_IdlePriority,qa=ul.log,Ya=ul.unstable_setDisableYieldValue,Ga=null,Ja="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},Ka=new WeakMap,Xa=[],Za=0,eo=null,no=[],to=0,ro=null,lo=f(null),ao=f(null),oo=f(null),uo=f(null),io=!1,so=null;Error(r(519));var co=[],fo=0,po=0,mo=null,ho=null,go=!1,yo=!1,bo=!1,vo=0,So=null,ko=0,wo=0,xo=null,zo=!1,Co=!1,Eo=Object.prototype.hasOwnProperty,Po=Error(r(460)),_o=Error(r(474)),Ro={then:function(){}},To=null,No=null,Lo=0,Uo=ce(!0),Do=ce(!1),Io=f(null),Fo=f(0),Mo=f(null),Wo=null,Ho=f(0),jo=0,Ao=null,Qo=null,Oo=null,Bo=!1,Vo=!1,$o=!1,qo=0,Yo=0,Go=null,Jo=0,Ko=function(){return{lastEffect:null,events:null,stores:null,memoCache:null}},Xo={readContext:gt,use:Ne,useCallback:ve,useContext:ve,useEffect:ve,useImperativeHandle:ve,useLayoutEffect:ve,useInsertionEffect:ve,useMemo:ve,useReducer:ve,useRef:ve,useState:ve,useDebugValue:ve,useDeferredValue:ve,useTransition:ve,useSyncExternalStore:ve,useId:ve};Xo.useCacheRefresh=ve,Xo.useMemoCache=ve,Xo.useHostTransitionStatus=ve,Xo.useFormState=ve,Xo.useActionState=ve,Xo.useOptimistic=ve;var Zo={readContext:gt,use:Ne,useCallback:function(e,n){return _e().memoizedState=[e,void 0===n?null:n],e},useContext:gt,useEffect:un,useImperativeHandle:function(e,n,t){t=null!=t?t.concat([e]):null,an(4194308,4,dn.bind(null,n,e),t)},useLayoutEffect:function(e,n){return an(4194308,4,e,n)},useInsertionEffect:function(e,n){an(4,2,e,n)},useMemo:function(e,n){var t=_e();n=void 0===n?null:n;var r=e();if($o){z(!0);try{e()}finally{z(!1)}}return t.memoizedState=[r,n],r},useReducer:function(e,n,t){var r=_e();if(void 0!==t){var l=t(n);if($o){z(!0);try{t(n)}finally{z(!1)}}}else l=n;return r.memoizedState=r.baseState=l,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:l},r.queue=e,e=e.dispatch=zn.bind(null,Ao,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},_e().memoizedState=e},useState:function(e){var n=(e=Oe(e)).queue,t=Cn.bind(null,Ao,n);return n.dispatch=t,[e.memoizedState,t]},useDebugValue:mn,useDeferredValue:function(e,n){return yn(_e(),e,n)},useTransition:function(){var e=Oe(!1);return e=vn.bind(null,Ao,e.queue,!0,!1),_e().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,t){var l=Ao,a=_e();if(t=n(),null===Tu)throw Error(r(349));0!=(60&Lu)||We(l,n,t),a.memoizedState=t;var o={value:t,getSnapshot:n};return a.queue=o,un(je.bind(null,l,o,e),[e]),l.flags|=2048,rn(9,He.bind(null,l,o,t,n),{destroy:void 0},null),t},useId:function(){var e=_e(),n=Tu.identifierPrefix;return n=":"+n+"r"+(Jo++).toString(32)+":",e.memoizedState=n},useCacheRefresh:function(){return _e().memoizedState=xn.bind(null,Ao)}};Zo.useMemoCache=Le,Zo.useHostTransitionStatus=Sn,Zo.useFormState=Xe,Zo.useActionState=Xe,Zo.useOptimistic=function(e){var n=_e();n.memoizedState=n.baseState=e;var t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=t,n=Pn.bind(null,Ao,!0,t),t.dispatch=n,[e,n]};var eu={readContext:gt,use:Ne,useCallback:hn,useContext:gt,useEffect:sn,useImperativeHandle:pn,useInsertionEffect:cn,useLayoutEffect:fn,useMemo:gn,useReducer:De,useRef:ln,useState:function(){return De(Ue)},useDebugValue:mn,useDeferredValue:function(e,n){return bn(Re(),Qo.memoizedState,e,n)},useTransition:function(){var e=De(Ue)[0],n=Re().memoizedState;return["boolean"==typeof e?e:Te(e),n]},useSyncExternalStore:Me,useId:kn};eu.useCacheRefresh=wn,eu.useMemoCache=Le,eu.useHostTransitionStatus=Sn,eu.useFormState=Ze,eu.useActionState=Ze,eu.useOptimistic=function(e,n){return Be(Re(),0,e,n)};var nu={readContext:gt,use:Ne,useCallback:hn,useContext:gt,useEffect:sn,useImperativeHandle:pn,useInsertionEffect:cn,useLayoutEffect:fn,useMemo:gn,useReducer:Fe,useRef:ln,useState:function(){return Fe(Ue)},useDebugValue:mn,useDeferredValue:function(e,n){var t=Re();return null===Qo?yn(t,e,n):bn(t,Qo.memoizedState,e,n)},useTransition:function(){var e=Fe(Ue)[0],n=Re().memoizedState;return["boolean"==typeof e?e:Te(e),n]},useSyncExternalStore:Me,useId:kn};nu.useCacheRefresh=wn,nu.useMemoCache=Le,nu.useHostTransitionStatus=Sn,nu.useFormState=tn,nu.useActionState=tn,nu.useOptimistic=function(e,n){var t=Re();return null!==Qo?Be(t,0,e,n):(t.baseState=e,[e,t.queue.dispatch])};var tu={isMounted:function(e){return!!(e=e._reactInternals)&&function(e){var n=e,t=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do{0!=(4098&(n=e).flags)&&(t=n.return),e=n.return}while(e)}return 3===n.tag?t:null}(e)===e},enqueueSetState:function(e,n,t){e=e._reactInternals;var r=pr(),l=q(r);l.payload=n,null!=t&&(l.callback=t),null!==(n=Y(e,l,r))&&(hr(n,0,r),G(n,e,r))},enqueueReplaceState:function(e,n,t){e=e._reactInternals;var r=pr(),l=q(r);l.tag=1,l.payload=n,null!=t&&(l.callback=t),null!==(n=Y(e,l,r))&&(hr(n,0,r),G(n,e,r))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var t=pr(),r=q(t);r.tag=2,null!=n&&(r.callback=n),null!==(n=Y(e,r,t))&&(hr(n,0,t),G(n,e,t))}};"function"==typeof reportError&&reportError;var ru=Error(r(461)),lu=!1,au={dehydrated:null,treeContext:null,retryLane:0},ou=f(null),uu=null,iu=null,su=null,cu="undefined"!=typeof AbortController?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(n,t){e.push(t)}};this.abort=function(){n.aborted=!0,e.forEach((function(e){return e()}))}},fu=ul.unstable_scheduleCallback,du=ul.unstable_NormalPriority,pu={$$typeof:yl,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},mu=Pl.S;Pl.S=function(e,n){"object"==typeof n&&null!==n&&"function"==typeof n.then&&function(e,n){if(null===So){var t=So=[];ko=0,wo=O(),xo={status:"pending",value:void 0,then:function(e){t.push(e)}}}ko++,n.then(B,B)}(0,n),null!==mu&&mu(e,n)};var hu=f(null),gu=!1,yu=!1,bu=!1,vu="function"==typeof WeakSet?WeakSet:Set,Su=null,ku=!1,wu=null,xu=!1,zu=null,Cu=8192,Eu={getCacheForType:function(e){var n=gt(pu),t=n.data.get(e);return void 0===t&&(t=e(),n.data.set(e,t)),t}};if("function"==typeof Symbol&&Symbol.for){var Pu=Symbol.for;Pu("selector.component"),Pu("selector.has_pseudo_class"),Pu("selector.role"),Pu("selector.test_id"),Pu("selector.text")}var _u="function"==typeof WeakMap?WeakMap:Map,Ru=0,Tu=null,Nu=null,Lu=0,Uu=0,Du=null,Iu=!1,Fu=!1,Mu=0,Wu=0,Hu=0,ju=0,Au=0,Qu=0,Ou=0,Bu=null,Vu=null,$u=!1,qu=0,Yu=1/0,Gu=null,Ju=null,Ku=!1,Xu=null,Zu=0,ei=0,ni=null,ti=0,ri=null;return al.createContainer=function(e,n,r,l,a,o,u,i,s,c){return function(e,n,r,l,a,o,u,i,s,c,f,d){return e=new nl(e,n,r,u,i,s,c,null),n=1,!0===o&&(n|=24),o=t(3,null,null,n),e.current=o,o.stateNode=e,(n=vt()).refCount++,e.pooledCache=n,n.refCount++,o.memoizedState={element:l,isDehydrated:r,cache:n},V(o),e}(e,n,!1,null,0,l,o,u,i,s)},al.flushSyncWork=function(){return 0!=(6&Ru)||(W(0),!1)},al.updateContainer=function(e,n,t,r){var l=n.current,a=pr();return tl(l,a,e,n,t,r),a},al.updateContainerSync=function(e,n,t,r){return 0===n.tag&&Wr(),tl(n.current,2,e,n,t,r),2},al},s.exports.default=s.exports,Object.defineProperty(s.exports,"__esModule",{value:!0})),o.exports):a.exports=function(){return i||(i=1,n=c,"production"!==process.env.NODE_ENV&&(n.exports=function(n){function t(e,n,t,r){return new sa(e,n,t,r)}function r(){console.error("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://react.dev/link/rules-of-hooks")}function l(){console.error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().")}function a(){}function o(e){var n=[];return e.forEach((function(e){n.push(e)})),n.sort().join(", ")}function i(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=Ya&&e[Ya]||e["@@iterator"])?e:null}function s(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===Ga?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case Ia:return"Fragment";case Da:return"Portal";case Ma:return"Profiler";case Fa:return"StrictMode";case Qa:return"Suspense";case Oa:return"SuspenseList"}if("object"==typeof e)switch("number"==typeof e.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case ja:return(e.displayName||"Context")+".Provider";case Ha:return(e._context.displayName||"Context")+".Consumer";case Aa:var n=e.render;return(e=e.displayName)||(e=""!==(e=n.displayName||n.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case Ba:return null!==(n=e.displayName||null)?n:s(e.type)||"Memo";case Va:n=e._payload,e=e._init;try{return s(e(n))}catch(e){}}return null}function c(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n._context.displayName||"Context")+".Consumer";case 10:return(n.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=n.render).displayName||e.name||"",n.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 26:case 27:case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return s(n);case 8:return n===Fa?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 14:case 15:if("function"==typeof n)return n.displayName||n.name||null;if("string"==typeof n)return n;break;case 29:if(null!=(n=e._debugInfo))for(var t=n.length-1;0<=t;t--)if("string"==typeof n[t].name)return n[t].name;if(null!==e.return)return c(e.return)}return null}function f(){}function d(e){if(void 0===Xa)try{throw Error()}catch(e){var n=e.stack.trim().match(/\n( *(at )?)/);Xa=n&&n[1]||"",Za=-1)":-1--o||s[a]!==c[o]){var p="\n"+s[a].replace(" at new "," at ");return e.displayName&&p.includes("")&&(p=p.replace("",e.displayName)),"function"==typeof e&&no.set(e,p),p}}while(1<=a&&0<=o);break}}}finally{eo=!1,Ja.H=t,function(){if(0==--Ka){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Na({},e,{value:ka}),info:Na({},e,{value:wa}),warn:Na({},e,{value:xa}),error:Na({},e,{value:za}),group:Na({},e,{value:Ca}),groupCollapsed:Na({},e,{value:Ea}),groupEnd:Na({},e,{value:Pa})})}0>Ka&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=r}return s=(s=e?e.displayName||e.name:"")?d(s):"","function"==typeof e&&no.set(e,s),s}function m(e){switch(e.tag){case 26:case 27:case 5:return d(e.type);case 16:return d("Lazy");case 13:return d("Suspense");case 19:return d("SuspenseList");case 0:case 15:return p(e.type,!1);case 11:return p(e.type.render,!1);case 1:return p(e.type,!0);default:return""}}function h(e){try{var n="";do{n+=m(e);var t=e._debugInfo;if(t)for(var r=t.length-1;0<=r;r--){var l=t[r];if("string"==typeof l.name){var a=n,o=l.env;n=a+d(l.name+(o?" ["+o+"]":""))}}e=e.return}while(e);return n}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}function g(){return null===to?"":h(to)}function y(e,n,t,r,l,a,o){var u=to;Ja.getCurrentStack=null===e?null:g,ro=!1,to=e;try{return n(t,r,l,a,o)}finally{to=u}throw Error("runWithFiberInDEV should never be called in production. This is a bug in React.")}function b(e){return{current:e}}function v(e,n){0>iu?console.error("Unexpected pop."):(n!==uu[iu]&&console.error("Unexpected Fiber popped."),e.current=ou[iu],ou[iu]=null,uu[iu]=null,iu--)}function S(e,n,t){iu++,ou[iu]=e.current,uu[iu]=t,e.current=n}function k(e){var n=42&e;if(0!==n)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194176&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return console.error("Should have found matching lanes. This is a bug in React."),e}}function w(e,n){var t=e.pendingLanes;if(0===t)return 0;var r=0,l=e.suspendedLanes;e=e.pingedLanes;var a=134217727&t;return 0!==a?0!=(t=a&~l)?r=k(t):0!=(e&=a)&&(r=k(e)):0!=(t&=~l)?r=k(t):0!==e&&(r=k(e)),0===r?0:0!==n&&n!==r&&0==(n&l)&&((l=r&-r)>=(e=n&-n)||32===l&&0!=(4194176&e))?n:r}function x(e,n){switch(e){case 1:case 2:case 4:case 8:return n+250;case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return console.error("Should have found matching lanes. This is a bug in React."),-1}}function z(){var e=pu;return 0==(4194176&(pu<<=1))&&(pu=128),e}function C(){var e=mu;return 0==(62914560&(mu<<=1))&&(mu=4194304),e}function E(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function P(e,n){e.pendingLanes|=n,268435456!==n&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function _(e,n,t){e.pendingLanes|=n,e.suspendedLanes&=~n;var r=31-cu(n);e.entangledLanes|=n,e.entanglements[r]=1073741824|e.entanglements[r]|4194218&t}function R(e,n){var t=e.entangledLanes|=n;for(e=e.entanglements;t;){var r=31-cu(t),l=1<qf)throw Zf=Yf=0,ed=Gf=null,Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");Zf>Xf&&(Zf=0,ed=null,console.error("Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.")),null===e.alternate&&0!=(4098&e.flags)&&ua(e);for(var n=e,t=n.return;null!==t;)null===n.alternate&&0!=(4098&n.flags)&&ua(e),t=(n=t).return;return 3===n.tag?n.stateNode:null}function G(){var e=Zu;return Zu=0,e}function J(e){var n=Zu;return Zu=e,n}function K(e){var n=Zu;return Zu+=e,n}function X(e){Xu=Ju(),0>e.actualStartTime&&(e.actualStartTime=Xu)}function Z(e){if(0<=Xu){var n=Ju()-Xu;e.actualDuration+=n,e.selfBaseDuration=n,Xu=-1}}function ee(e){if(0<=Xu){var n=Ju()-Xu;e.actualDuration+=n,Xu=-1}}function ne(){if(0<=Xu){var e=Ju()-Xu;Xu=-1,Zu+=e}}function te(){Xu=Ju()}function re(e){for(var n=e.child;n;)e.actualDuration+=n.actualDuration,n=n.sibling}function le(e){e!==ri&&null===e.next&&(null===ri?ti=ri=e:ri=ri.next=e),oi=!0,null!==Ja.actQueue?ai||(ai=!0,fe(oe)):li||(li=!0,fe(oe))}function ae(e,n){if(!ui&&oi){ui=!0;do{for(var t=!1,r=ti;null!==r;){if(0!==e){var l=r.pendingLanes;if(0===l)var a=0;else{var o=r.suspendedLanes,u=r.pingedLanes;a=(1<<31-cu(42|e)+1)-1,a=201326677&(a&=l&~(o&~u))?201326677&a|1:a?2|a:0}0!==a&&(t=!0,se(r,a))}else a=df,0!=(3&(a=w(r,r===cf?a:0)))&&(t=!0,se(r,a));r=r.next}}while(t);ui=!1}}function oe(){oi=ai=li=!1;var e=0;0!==ii&&(Co()&&(e=ii),ii=0);for(var n=vu(),t=null,r=ti;null!==r;){var l=r.next,a=ue(r,n);0===a?(r.next=null,null===t?ti=l:t.next=l,null===l&&(ri=t)):(t=r,(0!==e||0!=(3&a))&&(oi=!0)),r=l}ae(e)}function ue(e,n){for(var t=e.suspendedLanes,r=e.pingedLanes,l=e.expirationTimes,a=-62914561&e.pendingLanes;0 from render. Or maybe you meant to call this function rather than return it.\n root.render(%s)",n,n,n):console.error("Functions are not valid as a React child. This may happen if you return %s instead of <%s /> from render. Or maybe you meant to call this function rather than return it.\n <%s>{%s}",n,n,t,n,t))}function Me(e,n){var t=c(e)||"Component";ss[t]||(ss[t]=!0,n=String(n),3===e.tag?console.error("Symbols are not valid as a React child.\n root.render(%s)",n):console.error("Symbols are not valid as a React child.\n <%s>%s",t,n,t))}function We(e){function n(n,t){if(e){var r=n.deletions;null===r?(n.deletions=[t],n.flags|=16):r.push(t)}}function r(t,r){if(!e)return null;for(;null!==r;)n(t,r),r=r.sibling;return null}function l(e){for(var n=new Map;null!==e;)null!==e.key?n.set(e.key,e):n.set(e.index,e),e=e.sibling;return n}function o(e,n){return(e=fa(e,n)).index=0,e.sibling=null,e}function u(n,t,r){return n.index=r,e?null!==(r=n.alternate)?(r=r.index)p?(y=d,d=null):y=d.sibling;var v=h(t,d,o[p],i);if(null===v){null===d&&(d=y);break}s=b(t,v,o[p],s),e&&d&&null===v.alternate&&n(t,d),a=u(v,a,p),null===f?c=v:f.sibling=v,f=v,d=y}if(p===o.length)return r(t,d),c;if(null===d){for(;pd?(p=f,f=null):p=f.sibling;var S=h(t,f,v.value,i);if(null===S){null===f&&(f=p);break}y=b(t,S,v.value,y),e&&f&&null===S.alternate&&n(t,f),a=u(S,a,d),null===c?s=S:c.sibling=S,c=S,f=p}if(v.done)return r(t,f),s;if(null===f){for(;!v.done;d++,v=o.next())null!==(f=m(t,v.value,i))&&(y=b(t,f,v.value,y),a=u(f,a,d),null===c?s=f:c.sibling=f,c=f);return s}for(f=l(f);!v.done;d++,v=o.next())null!==(p=g(f,t,d,v.value,i))&&(y=b(t,p,v.value,y),e&&null!==p.alternate&&f.delete(null===p.key?d:p.key),a=u(p,a,d),null===c?s=p:c.sibling=p,c=p);return e&&f.forEach((function(e){return n(t,e)})),s}(t,a,p,f),as=d,t}if("function"==typeof c.then)return d=Ne(c._debugInfo),t=v(t,a,Ue(c),f),as=d,t;if(c.$$typeof===ja)return v(t,a,cr(t,c),f);Ie(t,c)}return"string"==typeof c&&""!==c||"number"==typeof c||"bigint"==typeof c?(d=""+c,null!==a&&6===a.tag?(r(t,a.sibling),(a=o(a,d)).return=t,t=a):(r(t,a),(a=ya(d,t.mode,f)).return=t,a._debugOwner=t,a._debugInfo=as,t=a),s(t)):("function"==typeof c&&Fe(t,c),"symbol"==typeof c&&Me(t,c),r(t,a))}return function(e,n,r,l){var a=as;as=null;try{ls=0;var o=v(e,n,r,l);return rs=null,o}catch(n){if(n===Di)throw n;var u=t(29,n,null,e.mode);u.lanes=l,u.return=e;var i=u._debugInfo=as;if(u._debugOwner=e._debugOwner,null!=i)for(var s=i.length-1;0<=s;s--)if("string"==typeof i[s].stack){u._debugOwner=i[s];break}return u}finally{as=a}}}function He(e,n){var t=Ef;S(ms,t,e),S(ps,n,e),Ef=t|n.baseLanes}function je(e){S(ms,Ef,e),S(ps,ps.current,e)}function Ae(e){Ef=ms.current,v(ps,e),v(ms,e)}function Qe(e){var n=e.alternate;S(vs,vs.current&ys,e),S(hs,e,e),null===gs&&(null===n||null!==ps.current||null!==n.memoizedState)&&(gs=e)}function Oe(e){if(22===e.tag){if(S(vs,vs.current,e),S(hs,e,e),null===gs){var n=e.alternate;null!==n&&null!==n.memoizedState&&(gs=e)}}else Be(e)}function Be(e){S(vs,vs.current,e),S(hs,hs.current,e)}function Ve(e){v(hs,e),gs===e&&(gs=null),v(vs,e)}function $e(e){for(var n=e;null!==n;){if(13===n.tag){var t=n.memoizedState;if(null!==t&&(null===(t=t.dehydrated)||Jo(t)||Ko(t)))return n}else if(19===n.tag&&void 0!==n.memoizedProps.revealOrder){if(0!=(128&n.flags))return n}else if(null!==n.child){n.child.return=n,n=n.child;continue}if(n===e)break;for(;null===n.sibling;){if(null===n.return||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}function qe(){var e=As;null===Qs?Qs=[e]:Qs.push(e)}function Ye(){var e=As;if(null!==Qs&&(Os++,Qs[Os]!==e)){var n=c(Ts);if(!Cs.has(n)&&(Cs.add(n),null!==Qs)){for(var t="",r=0;r<=Os;r++){var l=Qs[r],a=r===Os?e:l;for(l=r+1+". "+l;30>l.length;)l+=" ";t+=l+=a+"\n"}console.error("React has detected a change in the order of Hooks called by %s. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://react.dev/link/rules-of-hooks\n\n Previous render Next render\n ------------------------------------------------------\n%s ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",n,t)}}}function Ge(e){null==e||lo(e)||console.error("%s received a final argument that is not an array (instead, received `%s`). When specified, the final argument must be an array.",As,typeof e)}function Je(){var e=c(Ts);_s.has(e)||(_s.add(e),console.error("ReactDOM.useFormState has been renamed to React.useActionState. Please update %s to use React.useActionState.",e))}function Ke(){throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.")}function Xe(e,n){if(Bs)return!1;if(null===n)return console.error("%s received a final argument during this render, but not during the previous render. Even though the final argument is optional, its type cannot change between renders.",As),!1;e.length!==n.length&&console.error("The final argument passed to %s changed size between renders. The order and size of this array must remain constant.\n\nPrevious: %s\nIncoming: %s",As,"["+n.join(", ")+"]","["+e.join(", ")+"]");for(var t=0;t=js)throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");if(l+=1,Bs=!1,Ls=Ns=null,null!=e.updateQueue){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,null!=a.memoCache&&(a.memoCache.index=0)}Os=-1,Ja.H=Js,a=ji(n,t,r)}while(Ds);return a}function tn(){var e=Ja.H,n=e.useState()[0];return n="function"==typeof n.then?sn(n):n,e=e.useState()[0],(null!==Ns?Ns.memoizedState:null)!==e&&(Ts.flags|=1024),n}function rn(){var e=0!==Fs;return Fs=0,e}function ln(e,n,t){n.updateQueue=e.updateQueue,n.flags=(16&n.mode)!==$u?-201328645&n.flags:-2053&n.flags,e.lanes&=~t}function an(e){if(Us){for(e=e.memoizedState;null!==e;){var n=e.queue;null!==n&&(n.pending=null),e=e.next}Us=!1}Rs=0,Qs=Ls=Ns=Ts=null,Os=-1,As=null,Ds=!1,Ms=Fs=0,Ws=null}function on(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Ls?Ts.memoizedState=Ls=e:Ls=Ls.next=e,Ls}function un(){if(null===Ns){var e=Ts.alternate;e=null!==e?e.memoizedState:null}else e=Ns.next;var n=null===Ls?Ts.memoizedState:Ls.next;if(null!==n)Ls=n,Ns=e;else{if(null===e){if(null===Ts.alternate)throw Error("Update hook called on initial render. This is likely a bug in React. Please file an issue.");throw Error("Rendered more hooks than during the previous render.")}e={memoizedState:(Ns=e).memoizedState,baseState:Ns.baseState,baseQueue:Ns.baseQueue,queue:Ns.queue,next:null},null===Ls?Ts.memoizedState=Ls=e:Ls=Ls.next=e}return Ls}function sn(e){var n=Ms;return Ms+=1,null===Ws&&(Ws={didWarnAboutUncachedPromise:!1,thenables:[]}),e=_e(Ws,e,n),n=Ts,null===(null===Ls?n.memoizedState:Ls.next)&&(n=n.alternate,Ja.H=null!==n&&null!==n.memoizedState?Gs:qs),e}function cn(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return sn(e);if(e.$$typeof===ja)return sr(e)}throw Error("An unsupported type was passed to use(): "+String(e))}function fn(e){var n=null,t=Ts.updateQueue;if(null!==t&&(n=t.memoCache),null==n){var r=Ts.alternate;null!==r&&null!==(r=r.updateQueue)&&null!=(r=r.memoCache)&&(n={data:r.data.map((function(e){return e.slice()})),index:0})}if(null==n&&(n={data:[],index:0}),null===t&&(t=Vs(),Ts.updateQueue=t),t.memoCache=n,void 0===(t=n.data[n.index])||Bs)for(t=n.data[n.index]=Array(e),r=0;ra?a:8);var o,u,i,s=Ja.T,c={};Ja.T=c,yt(e,!1,n,t),c._updatedFibers=new Set;try{var f=l(),d=Ja.S;null!==d&&d(c,f),null!==f&&"object"==typeof f&&"function"==typeof f.then?gt(e,n,(o=r,u=[],i={status:"pending",value:null,reason:null,then:function(e){u.push(e)}},f.then((function(){i.status="fulfilled",i.value=o;for(var e=0;e component appears to have a render method, but doesn't extend React.Component. This is likely to cause errors. Change %s to extend React.Component instead.",a,a),mc[a]=!0)}return 8&n.mode&&xi.recordLegacyContextWarning(n,null),null===e&&(At(n,n.type),t.contextTypes&&(a=s(t)||"Unknown",gc[a]||(gc[a]=!0,console.error("%s uses the legacy contextTypes API which was removed in React 19. Use React.createContext() with React.useContext() instead. (https://react.dev/link/legacy-context)",a)))),ir(n),t=Ze(e,n,t,r,void 0,l),r=rn(),null===e||pc?(n.flags|=1,Nt(e,n,t,l),n.child):(ln(e,n,l),Xt(e,n,l))}function Ht(e,n,t,r,l,a){return ir(n),Os=-1,Bs=null!==e&&e.type!==n.type,n.updateQueue=null,t=nn(n,r,t,l),en(e,n),r=rn(),null===e||pc?(n.flags|=1,Nt(e,n,t,a),n.child):(ln(e,n,a),Xt(e,n,a))}function jt(e,n,t,r,l){var a,o,u;if(ir(n),null===n.stateNode){if(o=su,a=t.contextType,"contextType"in t&&null!==a&&(void 0===a||a.$$typeof!==ja)&&!sc.has(t)&&(sc.add(t),u=void 0===a?" However, it is set to undefined. This can be caused by a typo or by mixing up named and default imports. This can also happen due to a circular dependency, so try moving the createContext() call to a separate file.":"object"!=typeof a?" However, it is set to a "+typeof a+".":a.$$typeof===Ha?" Did you accidentally pass the Context.Consumer instead?":" However, it is set to an object with keys {"+Object.keys(a).join(", ")+"}.",console.error("%s defines an invalid contextType. contextType should point to the Context object returned by React.createContext().%s",s(t)||"Component",u)),"object"==typeof a&&null!==a&&(o=sr(a)),a=new t(r,o),8&n.mode){U(!0);try{a=new t(r,o)}finally{U(!1)}}if(o=n.memoizedState=null!==a.state&&void 0!==a.state?a.state:null,a.updater=fc,n.stateNode=a,a._reactInternals=n,a._reactInternalInstance=ec,"function"==typeof t.getDerivedStateFromProps&&null===o&&(o=s(t)||"Component",tc.has(o)||(tc.add(o),console.error("`%s` uses `getDerivedStateFromProps` but its initial state is %s. This is not recommended. Instead, define the initial state by assigning an object to `this.state` in the constructor of `%s`. This ensures that `getDerivedStateFromProps` arguments have a consistent shape.",o,null===a.state?"null":"undefined",o))),"function"==typeof t.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate){var i=u=o=null;if("function"==typeof a.componentWillMount&&!0!==a.componentWillMount.__suppressDeprecationWarning?o="componentWillMount":"function"==typeof a.UNSAFE_componentWillMount&&(o="UNSAFE_componentWillMount"),"function"==typeof a.componentWillReceiveProps&&!0!==a.componentWillReceiveProps.__suppressDeprecationWarning?u="componentWillReceiveProps":"function"==typeof a.UNSAFE_componentWillReceiveProps&&(u="UNSAFE_componentWillReceiveProps"),"function"==typeof a.componentWillUpdate&&!0!==a.componentWillUpdate.__suppressDeprecationWarning?i="componentWillUpdate":"function"==typeof a.UNSAFE_componentWillUpdate&&(i="UNSAFE_componentWillUpdate"),null!==o||null!==u||null!==i){a=s(t)||"Component";var f="function"==typeof t.getDerivedStateFromProps?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";lc.has(a)||(lc.add(a),console.error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://react.dev/link/unsafe-component-lifecycles",a,f,null!==o?"\n "+o:"",null!==u?"\n "+u:"",null!==i?"\n "+i:""))}}a=n.stateNode,o=s(t)||"Component",a.render||(t.prototype&&"function"==typeof t.prototype.render?console.error("No `render` method found on the %s instance: did you accidentally return an object from the constructor?",o):console.error("No `render` method found on the %s instance: you may have forgotten to define `render`.",o)),!a.getInitialState||a.getInitialState.isReactClassApproved||a.state||console.error("getInitialState was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Did you mean to define a state property instead?",o),a.getDefaultProps&&!a.getDefaultProps.isReactClassApproved&&console.error("getDefaultProps was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Use a static property to define defaultProps instead.",o),a.contextType&&console.error("contextType was defined as an instance property on %s. Use a static property to define contextType instead.",o),t.childContextTypes&&!ic.has(t)&&(ic.add(t),console.error("%s uses the legacy childContextTypes API which was removed in React 19. Use React.createContext() instead. (https://react.dev/link/legacy-context)",o)),t.contextTypes&&!uc.has(t)&&(uc.add(t),console.error("%s uses the legacy contextTypes API which was removed in React 19. Use React.createContext() with static contextType instead. (https://react.dev/link/legacy-context)",o)),"function"==typeof a.componentShouldUpdate&&console.error("%s has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.",o),t.prototype&&t.prototype.isPureReactComponent&&void 0!==a.shouldComponentUpdate&&console.error("%s has a method called shouldComponentUpdate(). shouldComponentUpdate should not be used when extending React.PureComponent. Please extend React.Component if shouldComponentUpdate is used.",s(t)||"A pure component"),"function"==typeof a.componentDidUnmount&&console.error("%s has a method called componentDidUnmount(). But there is no such lifecycle method. Did you mean componentWillUnmount()?",o),"function"==typeof a.componentDidReceiveProps&&console.error("%s has a method called componentDidReceiveProps(). But there is no such lifecycle method. If you meant to update the state in response to changing props, use componentWillReceiveProps(). If you meant to fetch data or run side-effects or mutations after React has updated the UI, use componentDidUpdate().",o),"function"==typeof a.componentWillRecieveProps&&console.error("%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?",o),"function"==typeof a.UNSAFE_componentWillRecieveProps&&console.error("%s has a method called UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?",o),u=a.props!==r,void 0!==a.props&&u&&console.error("When calling super() in `%s`, make sure to pass up the same props that your component's constructor was passed.",o),a.defaultProps&&console.error("Setting defaultProps as an instance property on %s is not supported and will be ignored. Instead, define defaultProps as a static property on %s.",o,o),"function"!=typeof a.getSnapshotBeforeUpdate||"function"==typeof a.componentDidUpdate||rc.has(t)||(rc.add(t),console.error("%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). This component defines getSnapshotBeforeUpdate() only.",s(t))),"function"==typeof a.getDerivedStateFromProps&&console.error("%s: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.",o),"function"==typeof a.getDerivedStateFromError&&console.error("%s: getDerivedStateFromError() is defined as an instance method and will be ignored. Instead, declare it as a static method.",o),"function"==typeof t.getSnapshotBeforeUpdate&&console.error("%s: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.",o),(u=a.state)&&("object"!=typeof u||lo(u))&&console.error("%s.state: must be set to an object or null",o),"function"==typeof a.getChildContext&&"object"!=typeof t.childContextTypes&&console.error("%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().",o),(a=n.stateNode).props=r,a.state=n.memoizedState,a.refs={},me(n),o=t.contextType,a.context="object"==typeof o&&null!==o?sr(o):su,a.state===r&&(o=s(t)||"Component",ac.has(o)||(ac.add(o),console.error("%s: It is not recommended to assign props directly to state because updates to props won't be reflected in state. In most cases, it is better to use props directly.",o))),8&n.mode&&xi.recordLegacyContextWarning(n,a),xi.recordUnsafeLifecycleWarnings(n,a),a.state=n.memoizedState,"function"==typeof(o=t.getDerivedStateFromProps)&&(wt(n,t,o,r),a.state=n.memoizedState),"function"==typeof t.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(o=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),o!==a.state&&(console.error("%s.componentWillMount(): Assigning directly to this.state is deprecated (except inside a component's constructor). Use setState instead.",c(n)||"Component"),fc.enqueueReplaceState(a,a.state,null)),ke(n,r,a,l),Se(),a.state=n.memoizedState),"function"==typeof a.componentDidMount&&(n.flags|=4194308),(16&n.mode)!==$u&&(n.flags|=67108864),a=!0}else if(null===e){a=n.stateNode;var d=n.memoizedProps;u=Ct(t,d),a.props=u;var p=a.context;i=t.contextType,o=su,"object"==typeof i&&null!==i&&(o=sr(i)),i="function"==typeof(f=t.getDerivedStateFromProps)||"function"==typeof a.getSnapshotBeforeUpdate,d=n.pendingProps!==d,i||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(d||p!==o)&&zt(n,a,r,o),bi=!1;var m=n.memoizedState;a.state=m,ke(n,r,a,l),Se(),p=n.memoizedState,d||m!==p||bi?("function"==typeof f&&(wt(n,t,f,r),p=n.memoizedState),(u=bi||xt(n,t,u,r,m,p,o))?(i||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||("function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"==typeof a.componentDidMount&&(n.flags|=4194308),(16&n.mode)!==$u&&(n.flags|=67108864)):("function"==typeof a.componentDidMount&&(n.flags|=4194308),(16&n.mode)!==$u&&(n.flags|=67108864),n.memoizedProps=r,n.memoizedState=p),a.props=r,a.state=p,a.context=o,a=u):("function"==typeof a.componentDidMount&&(n.flags|=4194308),(16&n.mode)!==$u&&(n.flags|=67108864),a=!1)}else{a=n.stateNode,he(e,n),i=Ct(t,o=n.memoizedProps),a.props=i,f=n.pendingProps,m=a.context,p=t.contextType,u=su,"object"==typeof p&&null!==p&&(u=sr(p)),(p="function"==typeof(d=t.getDerivedStateFromProps)||"function"==typeof a.getSnapshotBeforeUpdate)||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(o!==f||m!==u)&&zt(n,a,r,u),bi=!1,m=n.memoizedState,a.state=m,ke(n,r,a,l),Se();var h=n.memoizedState;o!==f||m!==h||bi||null!==e&&null!==e.dependencies&&ur(e.dependencies)?("function"==typeof d&&(wt(n,t,d,r),h=n.memoizedState),(i=bi||xt(n,t,i,r,m,h,u)||null!==e&&null!==e.dependencies&&ur(e.dependencies))?(p||"function"!=typeof a.UNSAFE_componentWillUpdate&&"function"!=typeof a.componentWillUpdate||("function"==typeof a.componentWillUpdate&&a.componentWillUpdate(r,h,u),"function"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,h,u)),"function"==typeof a.componentDidUpdate&&(n.flags|=4),"function"==typeof a.getSnapshotBeforeUpdate&&(n.flags|=1024)):("function"!=typeof a.componentDidUpdate||o===e.memoizedProps&&m===e.memoizedState||(n.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&m===e.memoizedState||(n.flags|=1024),n.memoizedProps=r,n.memoizedState=h),a.props=r,a.state=h,a.context=u,a=i):("function"!=typeof a.componentDidUpdate||o===e.memoizedProps&&m===e.memoizedState||(n.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&m===e.memoizedState||(n.flags|=1024),a=!1)}if(u=a,Mt(e,n),o=0!=(128&n.flags),u||o){if(u=n.stateNode,Ja.getCurrentStack=null===n?null:g,ro=!1,to=n,o&&"function"!=typeof t.getDerivedStateFromError)t=null,Xu=-1;else if(t=Qi(u),8&n.mode){U(!0);try{Qi(u)}finally{U(!1)}}n.flags|=1,null!==e&&o?(n.child=fs(n,e.child,null,l),n.child=fs(n,null,t,l)):Nt(e,n,t,l),n.memoizedState=u.state,e=n.child}else e=Xt(e,n,l);return l=n.stateNode,a&&l.props!==r&&(bc||console.error("It looks like %s is reassigning its own `this.props` while rendering. This is not supported and can lead to confusing bugs.",c(n)||"a component"),bc=!0),e}function At(e,n){n&&n.childContextTypes&&console.error("childContextTypes cannot be defined on a function component.\n %s.childContextTypes = ...",n.displayName||n.name||"Component"),"function"==typeof n.getDerivedStateFromProps&&(e=s(n)||"Unknown",yc[e]||(console.error("%s: Function components do not support getDerivedStateFromProps.",e),yc[e]=!0)),"object"==typeof n.contextType&&null!==n.contextType&&(n=s(n)||"Unknown",hc[n]||(console.error("%s: Function components do not support contextType.",n),hc[n]=!0))}function Qt(e){return{baseLanes:e,cachePool:yr()}}function Ot(e,n,t){return e=null!==e?e.childLanes&~t:0,n&&(e|=Nf),e}function Bt(e,n,t){var r,l,a,o,u=n.pendingProps,i=!1,s=0!=(128&n.flags);if((r=s)||(r=(null===e||null!==e.memoizedState)&&0!=(vs.current&bs)),r&&(i=!0,n.flags&=-129),r=0!=(32&n.flags),n.flags&=-33,null===e)return l=u.children,u=u.fallback,i?(Be(n),l=$t({mode:"hidden",children:l},i=n.mode),u=ha(u,i,t,null),l.return=n,u.return=n,l.sibling=u,n.child=l,(i=n.child).memoizedState=Qt(t),i.childLanes=Ot(e,r,t),n.memoizedState=kc,u):(Qe(n),Vt(n,l));if(null!==(a=e.memoizedState)&&null!==(l=a.dehydrated)){if(s)256&n.flags?(Qe(n),n.flags&=-257,n=qt(e,n,t)):null!==n.memoizedState?(Be(n),n.child=e.child,n.flags|=128,n=null):(Be(n),i=u.fallback,l=n.mode,u=$t({mode:"visible",children:u.children},l),(i=ha(i,l,t,null)).flags|=2,u.return=n,i.return=n,u.sibling=i,n.child=u,fs(n,e.child,null,t),(u=n.child).memoizedState=Qt(t),u.childLanes=Ot(e,r,t),n.memoizedState=kc,n=i);else if(Qe(n),Ko(l))r=(l=Xo(l)).digest,i=l.message,u=l.stack,l=l.componentStack,(i=i?Error(i):Error("The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.")).stack=u||"",i.digest=r,u={value:i,source:null,stack:r=void 0===l?null:l},"string"==typeof r&&Tu.set(i,u),o=u,null===Vu?Vu=[o]:Vu.push(o),n=qt(e,n,t);else if(pc||or(e,n,t,!1),r=0!=(t&e.childLanes),pc||r){if(null!==(r=cf)){if(0!=(42&(u=t&-t)))u=1;else switch(u){case 2:u=1;break;case 8:u=4;break;case 32:u=16;break;case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:u=64;break;case 268435456:u=134217728;break;default:u=0}if(0!==(u=0!=(u&(r.suspendedLanes|t))?0:u)&&u!==a.retryLane)throw a.retryLane=u,$(e,u),Cl(r,e,u),dc}Jo(l)||Ml(),n=qt(e,n,t)}else Jo(l)?(n.flags|=128,n.child=e.child,n=ta.bind(null,e),Zo(l,n),n=null):(e=a.treeContext,(n=Vt(n,u.children)).flags|=4096);return n}return i?(Be(n),i=u.fallback,l=n.mode,s=(a=e.child).sibling,(u=fa(a,{mode:"hidden",children:u.children})).subtreeFlags=31457280&a.subtreeFlags,null!==s?i=fa(s,i):(i=ha(i,l,t,null)).flags|=2,i.return=n,u.return=n,u.sibling=i,n.child=u,u=i,i=n.child,null===(l=e.child.memoizedState)?l=Qt(t):(null!==(a=l.cachePool)?(s=Uc._currentValue2,a=a.parent!==s?{parent:s,pool:s}:a):a=yr(),l={baseLanes:l.baseLanes|t,cachePool:a}),i.memoizedState=l,i.childLanes=Ot(e,r,t),n.memoizedState=kc,u):(Qe(n),e=(t=e.child).sibling,(t=fa(t,{mode:"visible",children:u.children})).return=n,t.sibling=null,null!==e&&(null===(r=n.deletions)?(n.deletions=[e],n.flags|=16):r.push(e)),n.child=t,n.memoizedState=null,t)}function Vt(e,n){return(n=$t({mode:"visible",children:n},e.mode)).return=e,e.child=n}function $t(e,n){return ga(e,n,0,null)}function qt(e,n,t){return fs(n,e.child,null,t),(e=Vt(n,n.pendingProps.children)).flags|=2,n.memoizedState=null,e}function Yt(e,n,t){e.lanes|=n;var r=e.alternate;null!==r&&(r.lanes|=n),lr(e.return,n,t)}function Gt(e,n){var t=lo(e);return e=!t&&"function"==typeof i(e),!t&&!e||(t=t?"array":"iterable",console.error("A nested %s was passed to row #%s in . Wrap it in an additional SuspenseList to configure its revealOrder: ... {%s} ... ",t,n,t),!1)}function Jt(e,n,t,r,l){var a=e.memoizedState;null===a?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:r,tail:t,tailMode:l}:(a.isBackwards=n,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=t,a.tailMode=l)}function Kt(e,n,t){var r=n.pendingProps,l=r.revealOrder,a=r.tail;if(r=r.children,void 0!==l&&"forwards"!==l&&"backwards"!==l&&"together"!==l&&!vc[l])if(vc[l]=!0,"string"==typeof l)switch(l.toLowerCase()){case"together":case"forwards":case"backwards":console.error('"%s" is not a valid value for revealOrder on . Use lowercase "%s" instead.',l,l.toLowerCase());break;case"forward":case"backward":console.error('"%s" is not a valid value for revealOrder on . React uses the -s suffix in the spelling. Use "%ss" instead.',l,l.toLowerCase());break;default:console.error('"%s" is not a supported revealOrder on . Did you mean "together", "forwards" or "backwards"?',l)}else console.error('%s is not a supported value for revealOrder on . Did you mean "together", "forwards" or "backwards"?',l);void 0===a||Sc[a]||("collapsed"!==a&&"hidden"!==a?(Sc[a]=!0,console.error('"%s" is not a supported value for tail on . Did you mean "collapsed" or "hidden"?',a)):"forwards"!==l&&"backwards"!==l&&(Sc[a]=!0,console.error(' is only valid if revealOrder is "forwards" or "backwards". Did you mean to specify revealOrder="forwards"?',a)));e:if(("forwards"===l||"backwards"===l)&&null!=r&&!1!==r)if(lo(r)){for(var o=0;o. This is not useful since it needs multiple rows. Did you mean to pass multiple children or an array?',l);if(Nt(e,n,r,t),0!=((r=vs.current)&bs))r=r&ys|bs,n.flags|=128;else{if(null!==e&&0!=(128&e.flags))e:for(e=n.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Yt(e,t,n);else if(19===e.tag)Yt(e,t,n);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;null===e.sibling;){if(null===e.return||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=ys}switch(S(vs,r,n),l){case"forwards":for(t=n.child,l=null;null!==t;)null!==(e=t.alternate)&&null===$e(e)&&(l=t),t=t.sibling;null===(t=l)?(l=n.child,n.child=null):(l=t.sibling,t.sibling=null),Jt(n,!1,l,t,a);break;case"backwards":for(t=null,l=n.child,n.child=null;null!==l;){if(null!==(e=l.alternate)&&null===$e(e)){n.child=l;break}e=l.sibling,l.sibling=t,t=l,l=e}Jt(n,!0,t,null,a);break;case"together":Jt(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function Xt(e,n,t){if(null!==e&&(n.dependencies=e.dependencies),Xu=-1,_f|=n.lanes,0==(t&n.childLanes)){if(null===e)return null;if(or(e,n,t,!1),0==(t&n.childLanes))return null}if(null!==e&&n.child!==e.child)throw Error("Resuming work not yet implemented.");if(null!==n.child){for(t=fa(e=n.child,e.pendingProps),n.child=t,t.return=n;null!==e.sibling;)e=e.sibling,(t=t.sibling=fa(e,e.pendingProps)).return=n;t.sibling=null}return n.child}function Zt(e,n){return 0!=(e.lanes&n)||!(null===(e=e.dependencies)||!ur(e))}function er(e,n,t){if(n._debugNeedsRemount&&null!==e){t=pa(n.type,n.key,n.pendingProps,n._debugOwner||null,n.mode,n.lanes);var r=n.return;if(null===r)throw Error("Cannot swap the root fiber.");if(e.alternate=null,n.alternate=null,t.index=n.index,t.sibling=n.sibling,t.return=n.return,t.ref=n.ref,t._debugInfo=n._debugInfo,n===r.child)r.child=t;else{var l=r.child;if(null===l)throw Error("Expected parent to have a child.");for(;l.sibling!==n;)if(null===(l=l.sibling))throw Error("Expected to find the previous sibling.");l.sibling=t}return null===(n=r.deletions)?(r.deletions=[e],r.flags|=16):n.push(e),t.flags|=2,t}if(null!==e)if(e.memoizedProps!==n.pendingProps||n.type!==e.type)pc=!0;else{if(!Zt(e,t)&&0==(128&n.flags))return pc=!1,function(e,n,t){switch(n.tag){case 3:W(n,n.stateNode.containerInfo),tr(n,Uc,e.memoizedState.cache);break;case 27:case 5:A(n);break;case 4:W(n,n.stateNode.containerInfo);break;case 10:tr(n,n.type,n.memoizedProps.value);break;case 12:0!=(t&n.childLanes)&&(n.flags|=4),n.flags|=2048;var r=n.stateNode;r.effectDuration=-0,r.passiveEffectDuration=-0;break;case 13:if(null!==(r=n.memoizedState))return null!==r.dehydrated?(Qe(n),n.flags|=128,null):0!=(t&n.child.childLanes)?Bt(e,n,t):(Qe(n),null!==(e=Xt(e,n,t))?e.sibling:null);Qe(n);break;case 19:var l=0!=(128&e.flags);if((r=0!=(t&n.childLanes))||(or(e,n,t,!1),r=0!=(t&n.childLanes)),l){if(r)return Kt(e,n,t);n.flags|=128}if(null!==(l=n.memoizedState)&&(l.rendering=null,l.tail=null,l.lastEffect=null),S(vs,vs.current,n),r)break;return null;case 22:case 23:return n.lanes=0,It(e,n,t);case 24:tr(n,Uc,e.memoizedState.cache)}return Xt(e,n,t)}(e,n,t);pc=0!=(131072&e.flags)}else pc=!1,(r=Bu)&&(F(),r=0!=(1048576&n.flags)),r&&(r=n.index,F(),function(e,n,t){F(),Iu[Fu++]=Wu,Iu[Fu++]=Hu,Iu[Fu++]=Mu,Mu=e;var r=Wu;e=Hu;var l=32-cu(r)-1;r&=~(1<>=o,l-=o,Wu=1<<32-cu(n)+l|t<`. Did you misspell it or forget to pass it?")),tr(n,r,a),Nt(e,n,l.children,t),n.child;case 9:return l=n.type._context,"function"!=typeof(r=n.pendingProps.children)&&console.error("A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it."),ir(n),l=sr(l),r=ji(r,l,void 0),n.flags|=1,Nt(e,n,r,t),n.child;case 14:return Ut(e,n,n.type,n.pendingProps,t);case 15:return Dt(e,n,n.type,n.pendingProps,t);case 19:return Kt(e,n,t);case 22:return It(e,n,t);case 24:return ir(n),r=sr(Uc),null===e?(null===(l=hr())&&(l=cf,a=dr(),l.pooledCache=a,pr(a),null!==a&&(l.pooledCacheLanes|=t),l=a),n.memoizedState={parent:r,cache:l},me(n),tr(n,Uc,l)):(0!=(e.lanes&t)&&(he(e,n),ke(n,null,null,t),Se()),l=e.memoizedState,a=n.memoizedState,l.parent!==r?(l={parent:r,cache:r},n.memoizedState=l,0===n.lanes&&(n.memoizedState=n.updateQueue.baseState=l),tr(n,Uc,r)):(r=a.cache,tr(n,Uc,r),r!==l.cache&&ar(n,[Uc],t,!0))),Nt(e,n,n.pendingProps.children,t),n.child;case 29:throw n.pendingProps}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function nr(){_c=Pc=Ec=null,Rc=!1}function tr(e,n,t){S(xc,n._currentValue2,e),n._currentValue2=t,S(zc,n._currentRenderer2,e),void 0!==n._currentRenderer2&&null!==n._currentRenderer2&&n._currentRenderer2!==Cc&&console.error("Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."),n._currentRenderer2=Cc}function rr(e,n){var t=xc.current;e._currentValue2=t,t=zc.current,v(zc,n),e._currentRenderer2=t,v(xc,n)}function lr(e,n,t){for(;null!==e;){var r=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,null!==r&&(r.childLanes|=n)):null!==r&&(r.childLanes&n)!==n&&(r.childLanes|=n),e===t)break;e=e.return}e!==t&&console.error("Expected to find the propagation root when scheduling context work. This error is likely caused by a bug in React. Please file an issue.")}function ar(e,n,t,r){var l=e.child;for(null!==l&&(l.return=e);null!==l;){var a=l.dependencies;if(null!==a){var o=l.child;a=a.firstContext;e:for(;null!==a;){var u=a;a=l;for(var i=0;ie.refCount&&console.warn("A cache instance was released after it was already freed. This likely indicates a bug in React."),0===e.refCount&&Nc(Lc,(function(){e.controller.abort()}))}function hr(){var e=Ic.current;return null!==e?e:cf.pooledCache}function gr(e,n){S(Ic,null===n?Ic.current:n.pool,e)}function yr(){var e=hr();return null===e?null:{parent:Uc._currentValue2,pool:e}}function br(e){e.flags|=4}function vr(e,n){null!==n&&(e.flags|=4),16384&e.flags&&(n=22!==e.tag?C():536870912,e.lanes|=n)}function Sr(e,n){switch(e.tailMode){case"hidden":n=e.tail;for(var t=null;null!==n;)null!==n.alternate&&(t=n),n=n.sibling;null===t?e.tail=null:t.sibling=null;break;case"collapsed":t=e.tail;for(var r=null;null!==t;)null!==t.alternate&&(r=t),t=t.sibling;null===r?n||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function kr(e){var n=null!==e.alternate&&e.alternate.child===e.child,t=0,r=0;if(n)if((2&e.mode)!==$u){for(var l=e.selfBaseDuration,a=e.child;null!==a;)t|=a.lanes|a.childLanes,r|=31457280&a.subtreeFlags,r|=31457280&a.flags,l+=a.treeBaseDuration,a=a.sibling;e.treeBaseDuration=l}else for(l=e.child;null!==l;)t|=l.lanes|l.childLanes,r|=31457280&l.subtreeFlags,r|=31457280&l.flags,l.return=e,l=l.sibling;else if((2&e.mode)!==$u){l=e.actualDuration,a=e.selfBaseDuration;for(var o=e.child;null!==o;)t|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,l+=o.actualDuration,a+=o.treeBaseDuration,o=o.sibling;e.actualDuration=l,e.treeBaseDuration=a}else for(l=e.child;null!==l;)t|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=t,n}function wr(e,n,t){var r=n.pendingProps;switch(I(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return kr(n),null;case 3:return t=n.stateNode,r=null,null!==e&&(r=e.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),rr(Uc,n),H(n),t.pendingContext&&(t.context=t.pendingContext,t.pendingContext=null),null!==e&&null!==e.child||null===e||e.memoizedState.isDehydrated&&0==(256&n.flags)||(n.flags|=1024,null!==Vu&&(Pl(Vu),Vu=null)),kr(n),null;case 26:var l;case 27:case 5:if(Q(n),t=n.type,null!==e&&null!=n.stateNode)!function(e,n,t,r){e.memoizedProps!==r&&br(n)}(e,n,0,r);else{if(!r){if(null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");return kr(n),null}e=j(),l=M(Qu.current),function(e,n,t,r){for(t=n.child;null!==t;){if(5===t.tag||6===t.tag)fo(e,t.stateNode);else if(4!==t.tag&&!au&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===n)break;for(;null===t.sibling;){if(null===t.return||t.return===n)return;t=t.return}t.sibling.return=t.return,t=t.sibling}}(l=co(t,r,l,e,n),n,!1),n.stateNode=l,po(l,t,r,e)&&br(n)}return kr(n),function(e,n,t){if(Po(n,t)){if(e.flags|=16777216,!_o(n,t)){if(!Dl())throw Mi=Fi,Ii;e.flags|=8192}}else e.flags&=-16777217}(n,n.type,n.pendingProps),null;case 6:if(e&&null!=n.stateNode)(t=e.memoizedProps)!==r&&br(n);else{if("string"!=typeof r&&null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");var a;e=M(Qu.current),t=j(),n.stateNode=ho(r,e,t,n)}return kr(n),null;case 13:if(r=n.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(l=!1,null!==r&&null!==r.dehydrated){if(null===e){if(!l)throw Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");throw Error("Expected prepareToHydrateHostSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.")}0==(128&n.flags)&&(n.memoizedState=null),n.flags|=4,kr(n),(2&n.mode)!==$u&&null!==r&&null!==(l=n.child)&&(n.treeBaseDuration-=l.treeBaseDuration),l=!1}else null!==Vu&&(Pl(Vu),Vu=null),l=!0;if(!l)return 256&n.flags?(Ve(n),n):(Ve(n),null)}return Ve(n),0!=(128&n.flags)?(n.lanes=t,(2&n.mode)!==$u&&re(n),n):(t=null!==r,e=null!==e&&null!==e.memoizedState,t&&(l=null,null!==(r=n.child).alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(l=r.alternate.memoizedState.cachePool.pool),a=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(a=r.memoizedState.cachePool.pool),a!==l&&(r.flags|=2048)),t!==e&&t&&(n.child.flags|=8192),vr(n,n.updateQueue),kr(n),(2&n.mode)!==$u&&t&&null!==(e=n.child)&&(n.treeBaseDuration-=e.treeBaseDuration),null);case 4:return H(n),null===e&&ko(n.stateNode.containerInfo),kr(n),null;case 10:return rr(n.type,n),kr(n),null;case 19:if(v(vs,n),null===(l=n.memoizedState))return kr(n),null;if(r=0!=(128&n.flags),null===(a=l.rendering))if(r)Sr(l,!1);else{if(Pf!==nf||null!==e&&0!=(128&e.flags))for(e=n.child;null!==e;){if(null!==(a=$e(e))){for(n.flags|=128,Sr(l,!1),e=a.updateQueue,n.updateQueue=e,vr(n,e),n.subtreeFlags=0,e=t,t=n.child;null!==t;)da(t,e),t=t.sibling;return S(vs,vs.current&ys|bs,n),n.child}e=e.sibling}null!==l.tail&&vu()>Wf&&(n.flags|=128,r=!0,Sr(l,!1),n.lanes=4194304)}else{if(!r)if(null!==(e=$e(a))){if(n.flags|=128,r=!0,e=e.updateQueue,n.updateQueue=e,vr(n,e),Sr(l,!0),null===l.tail&&"hidden"===l.tailMode&&!a.alternate)return kr(n),null}else 2*vu()-l.renderingStartTime>Wf&&536870912!==t&&(n.flags|=128,r=!0,Sr(l,!1),n.lanes=4194304);l.isBackwards?(a.sibling=n.child,n.child=a):(null!==(e=l.last)?e.sibling=a:n.child=a,l.last=a)}return null!==l.tail?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=vu(),e.sibling=null,t=vs.current,S(vs,t=r?t&ys|bs:t&ys,n),e):(kr(n),null);case 22:case 23:return Ve(n),Ae(n),r=null!==n.memoizedState,null!==e?null!==e.memoizedState!==r&&(n.flags|=8192):r&&(n.flags|=8192),r?0!=(536870912&t)&&0==(128&n.flags)&&(kr(n),6&n.subtreeFlags&&(n.flags|=8192)):kr(n),null!==(t=n.updateQueue)&&vr(n,t.retryQueue),t=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(t=e.memoizedState.cachePool.pool),r=null,null!==n.memoizedState&&null!==n.memoizedState.cachePool&&(r=n.memoizedState.cachePool.pool),r!==t&&(n.flags|=2048),null!==e&&v(Ic,n),null;case 24:return t=null,null!==e&&(t=e.memoizedState.cache),n.memoizedState.cache!==t&&(n.flags|=2048),rr(Uc,n),kr(n),null;case 25:return null}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function xr(e,n){switch(I(n),n.tag){case 1:return 65536&(e=n.flags)?(n.flags=-65537&e|128,(2&n.mode)!==$u&&re(n),n):null;case 3:return rr(Uc,n),H(n),0!=(65536&(e=n.flags))&&0==(128&e)?(n.flags=-65537&e|128,n):null;case 26:case 27:case 5:return Q(n),null;case 13:if(Ve(n),null!==(e=n.memoizedState)&&null!==e.dehydrated&&null===n.alternate)throw Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");return 65536&(e=n.flags)?(n.flags=-65537&e|128,(2&n.mode)!==$u&&re(n),n):null;case 19:return v(vs,n),null;case 4:return H(n),null;case 10:return rr(n.type,n),null;case 22:case 23:return Ve(n),Ae(n),null!==e&&v(Ic,n),65536&(e=n.flags)?(n.flags=-65537&e|128,(2&n.mode)!==$u&&re(n),n):null;case 24:return rr(Uc,n),null;default:return null}}function zr(e,n){switch(I(n),n.tag){case 3:rr(Uc,n),H(n);break;case 26:case 27:case 5:Q(n);break;case 4:H(n);break;case 13:Ve(n);break;case 19:v(vs,n);break;case 10:rr(n.type,n);break;case 22:case 23:Ve(n),Ae(n),null!==e&&v(Ic,n);break;case 24:rr(Uc,n)}}function Cr(e){return(2&e.mode)!==$u}function Er(e,n){Cr(e)?(te(),_r(n,e),ne()):_r(n,e)}function Pr(e,n,t){Cr(e)?(te(),Rr(t,e,n),ne()):Rr(t,e,n)}function _r(e,n){try{var t=n.updateQueue,r=null!==t?t.lastEffect:null;if(null!==r){var l=r.next;t=l;do{var a;(t.tag&e)===e&&((e&zs)!==Ss?null!==Pu&&"function"==typeof Pu.markComponentPassiveEffectMountStarted&&Pu.markComponentPassiveEffectMountStarted(n):(e&xs)!==Ss&&null!==Pu&&"function"==typeof Pu.markComponentLayoutEffectMountStarted&&Pu.markComponentLayoutEffectMountStarted(n),r=void 0,(e&ws)!==Ss&&(nd=!0),r=y(n,Xi,t),(e&ws)!==Ss&&(nd=!1),(e&zs)!==Ss?null!==Pu&&"function"==typeof Pu.markComponentPassiveEffectMountStopped&&Pu.markComponentPassiveEffectMountStopped():(e&xs)!==Ss&&null!==Pu&&"function"==typeof Pu.markComponentLayoutEffectMountStopped&&Pu.markComponentLayoutEffectMountStopped(),void 0!==r&&"function"!=typeof r)&&y(n,(function(e,n){console.error("%s must not return anything besides a function, which is used for clean-up.%s",e,n)}),a=0!=(t.tag&xs)?"useLayoutEffect":0!=(t.tag&ws)?"useInsertionEffect":"useEffect",null===r?" You returned null. If your effect does not require clean up, return undefined (or nothing).":"function"==typeof r.then?"\n\nIt looks like you wrote "+a+"(async () => ...) or returned a Promise. Instead, write the async function inside your effect and call it immediately:\n\n"+a+"(() => {\n async function fetchData() {\n // You can await here\n const response = await MyAPI.getData(someId);\n // ...\n }\n fetchData();\n}, [someId]); // Or [] if effect doesn't need props or state\n\nLearn more about data fetching with Hooks: https://react.dev/link/hooks-data-fetching":" You returned: "+r),t=t.next}while(t!==l)}}catch(e){Xl(n,n.return,e)}}function Rr(e,n,t){try{var r=n.updateQueue,l=null!==r?r.lastEffect:null;if(null!==l){var a=l.next;r=a;do{if((r.tag&e)===e){var o=r.inst,u=o.destroy;void 0!==u&&(o.destroy=void 0,(e&zs)!==Ss?null!==Pu&&"function"==typeof Pu.markComponentPassiveEffectUnmountStarted&&Pu.markComponentPassiveEffectUnmountStarted(n):(e&xs)!==Ss&&null!==Pu&&"function"==typeof Pu.markComponentLayoutEffectUnmountStarted&&Pu.markComponentLayoutEffectUnmountStarted(n),(e&ws)!==Ss&&(nd=!0),y(n,es,n,t,u),(e&ws)!==Ss&&(nd=!1),(e&zs)!==Ss?null!==Pu&&"function"==typeof Pu.markComponentPassiveEffectUnmountStopped&&Pu.markComponentPassiveEffectUnmountStopped():(e&xs)!==Ss&&null!==Pu&&"function"==typeof Pu.markComponentLayoutEffectUnmountStopped&&Pu.markComponentLayoutEffectUnmountStopped())}r=r.next}while(r!==a)}}catch(e){Xl(n,n.return,e)}}function Tr(e,n){Cr(e)?(te(),_r(n,e),ne()):_r(n,e)}function Nr(e,n,t){Cr(e)?(te(),Rr(t,e,n),ne()):Rr(t,e,n)}function Lr(e){var n=e.updateQueue;if(null!==n){var t=e.stateNode;e.type.defaultProps||"ref"in e.memoizedProps||bc||(t.props!==e.memoizedProps&&console.error("Expected %s props to match memoized props before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.",c(e)||"instance"),t.state!==e.memoizedState&&console.error("Expected %s state to match memoized state before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.",c(e)||"instance"));try{y(e,ze,n,t)}catch(n){Xl(e,e.return,n)}}}function Ur(e,n,t){return e.getSnapshotBeforeUpdate(n,t)}function Dr(e,n){var t=n.memoizedProps,r=n.memoizedState;n=e.stateNode,e.type.defaultProps||"ref"in e.memoizedProps||bc||(n.props!==e.memoizedProps&&console.error("Expected %s props to match memoized props before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.",c(e)||"instance"),n.state!==e.memoizedState&&console.error("Expected %s state to match memoized state before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.",c(e)||"instance"));try{var l=Ct(e.type,t,(e.elementType,e.type)),a=y(e,Ur,n,l,r);t=Fc,void 0!==a||t.has(e.type)||(t.add(e.type),y(e,(function(){console.error("%s.getSnapshotBeforeUpdate(): A snapshot value (or null) must be returned. You have returned undefined.",c(e))}))),n.__reactInternalSnapshotBeforeUpdate=a}catch(n){Xl(e,e.return,n)}}function Ir(e,n,t){t.props=Ct(e.type,e.memoizedProps),t.state=e.memoizedState,Cr(e)?(te(),y(e,Ji,e,n,t),ne()):y(e,Ji,e,n,t)}function Fr(e){var n=e.ref;if(null!==n){var t=e.stateNode;switch(e.tag){case 26:case 27:case 5:t=ao(t)}if("function"==typeof n)if(Cr(e))try{te(),e.refCleanup=n(t)}finally{ne()}else e.refCleanup=n(t);else"string"==typeof n?console.error("String refs are no longer supported."):n.hasOwnProperty("current")||console.error("Unexpected ref object provided for %s. Use either a ref-setter function or React.createRef().",c(e)),n.current=t}}function Mr(e,n){try{y(e,Fr,e)}catch(t){Xl(e,n,t)}}function Wr(e,n){var t=e.ref,r=e.refCleanup;if(null!==t)if("function"==typeof r)try{if(Cr(e))try{te(),y(e,r)}finally{ne()}else y(e,r)}catch(t){Xl(e,n,t)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof t)try{if(Cr(e))try{te(),y(e,t,null)}finally{ne()}else y(e,t,null)}catch(t){Xl(e,n,t)}else t.current=null}function Hr(e,n,t,r){var l=e.memoizedProps,a=l.id,o=l.onCommit;l=l.onRender,n=null===n?"mount":"update",ei&&(n="nested-update"),"function"==typeof l&&l(a,n,e.actualDuration,e.treeBaseDuration,e.actualStartTime,t),"function"==typeof o&&o(e.memoizedProps.id,n,r,t)}function jr(e,n,t,r){var l=e.memoizedProps;e=l.id,l=l.onPostCommit,n=null===n?"mount":"update",ei&&(n="nested-update"),"function"==typeof l&&l(e,n,r,t)}function Ar(e){var n=e.type,t=e.memoizedProps,r=e.stateNode;try{y(e,Wo,r,n,t,e)}catch(n){Xl(e,e.return,n)}}function Qr(e){return 5===e.tag||3===e.tag||4===e.tag}function Or(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||Qr(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function Br(e,n,t){var r=e.tag;if(5===r||6===r)e=e.stateNode,n?Ao(t,e,n):Fo(t,e);else if(4!==r&&!au&&null!==(e=e.child))for(Br(e,n,t),e=e.sibling;null!==e;)Br(e,n,t),e=e.sibling}function Vr(e,n,t){var r=e.tag;if(5===r||6===r)e=e.stateNode,n?jo(t,e,n):Io(t,e);else if(4!==r&&!au&&null!==(e=e.child))for(Vr(e,n,t),e=e.sibling;null!==e;)Vr(e,n,t),e=e.sibling}function $r(e){e:{for(var n=e.return;null!==n;){if(Qr(n)){var t=n;break e}n=n.return}throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.")}switch(t.tag){case 27:case 5:n=t.stateNode,32&t.flags&&(Bo(n),t.flags&=-33),Vr(e,t=Or(e),n);break;case 3:case 4:n=t.stateNode.containerInfo,Br(e,t=Or(e),n);break;default:throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.")}}function qr(e,n,t){var r=t.flags;switch(t.tag){case 0:case 11:case 15:tl(e,t),4&r&&Er(t,xs|ks);break;case 1:if(tl(e,t),4&r)if(e=t.stateNode,null===n)t.type.defaultProps||"ref"in t.memoizedProps||bc||(e.props!==t.memoizedProps&&console.error("Expected %s props to match memoized props before componentDidMount. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.",c(t)||"instance"),e.state!==t.memoizedState&&console.error("Expected %s state to match memoized state before componentDidMount. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.",c(t)||"instance")),Cr(t)?(te(),y(t,Bi,t,e),ne()):y(t,Bi,t,e);else{var l=Ct(t.type,n.memoizedProps);n=n.memoizedState,t.type.defaultProps||"ref"in t.memoizedProps||bc||(e.props!==t.memoizedProps&&console.error("Expected %s props to match memoized props before componentDidUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.",c(t)||"instance"),e.state!==t.memoizedState&&console.error("Expected %s state to match memoized state before componentDidUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.",c(t)||"instance")),Cr(t)?(te(),y(t,$i,t,e,l,n,e.__reactInternalSnapshotBeforeUpdate),ne()):y(t,$i,t,e,l,n,e.__reactInternalSnapshotBeforeUpdate)}64&r&&Lr(t),512&r&&Mr(t,t.return);break;case 3:if(n=G(),tl(e,t),64&r&&null!==(r=t.updateQueue)){if(l=null,null!==t.child)switch(t.child.tag){case 27:case 5:l=ao(t.child.stateNode);break;case 1:l=t.child.stateNode}try{y(t,ze,r,l)}catch(e){Xl(t,t.return,e)}}e.effectDuration+=J(n);break;case 26:case 27:case 5:tl(e,t),null===n&&4&r&&Ar(t),512&r&&Mr(t,t.return);break;case 12:if(4&r){r=G(),tl(e,t),(e=t.stateNode).effectDuration+=K(r);try{y(t,Hr,t,n,Ku,e.effectDuration)}catch(e){Xl(t,t.return,e)}}else tl(e,t);break;case 13:default:tl(e,t);break;case 22:if(!(l=null!==t.memoizedState||Mc)){n=null!==n&&null!==n.memoizedState||Wc;var a=Mc,o=Wc;Mc=l,(Wc=n)&&!o?ol(e,t,0!=(8772&t.subtreeFlags)):tl(e,t),Mc=a,Wc=o}512&r&&("manual"===t.memoizedProps.mode?Mr(t,t.return):Wr(t,t.return))}}function Yr(e){var n=e.alternate;null!==n&&(e.alternate=null,Yr(n)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&null!==(n=e.stateNode)&&Eo(n),e.stateNode=null,e._debugOwner=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Gr(e,n,t){for(t=t.child;null!==t;)Jr(e,n,t),t=t.sibling}function Jr(e,n,t){switch(t.tag){case 26:case 27:var r,l;case 5:Wc||Wr(t,n);case 6:if(r=Vc,l=$c,Vc=null,Gr(e,n,t),$c=l,null!==(Vc=r))if($c)try{y(t,Oo,Vc,t.stateNode)}catch(e){Xl(t,n,e)}else try{y(t,Qo,Vc,t.stateNode)}catch(e){Xl(t,n,e)}break;case 18:null!==Vc&&($c?nu(Vc,t.stateNode):eu(Vc,t.stateNode));break;case 4:r=Vc,l=$c,Vc=t.stateNode.containerInfo,$c=!0,Gr(e,n,t),Vc=r,$c=l;break;case 0:case 11:case 14:case 15:Wc||Rr(ws,t,n),Wc||Pr(t,n,xs),Gr(e,n,t);break;case 1:Wc||(Wr(t,n),"function"==typeof(r=t.stateNode).componentWillUnmount&&Ir(t,n,r)),Gr(e,n,t);break;case 21:Gr(e,n,t);break;case 22:Wr(t,n),Wc=(r=Wc)||null!==t.memoizedState,Gr(e,n,t),Wc=r;break;default:Gr(e,n,t)}}function Kr(e,n){var t=function(e){switch(e.tag){case 13:case 19:var n=e.stateNode;return null===n&&(n=e.stateNode=new jc),n;case 22:return null===(n=(e=e.stateNode)._retryCache)&&(n=e._retryCache=new jc),n;default:throw Error("Unexpected Suspense handler tag ("+e.tag+"). This is a bug in React.")}}(e);n.forEach((function(n){var r=ra.bind(null,e,n);if(!t.has(n)){if(t.add(n),_u){if(null===Qc||null===Oc)throw Error("Expected finished root and lanes to be set. This is a bug in React.");ia(Oc,Qc)}n.then(r,r)}}))}function Xr(e,n){var t=n.deletions;if(null!==t)for(var r=0;r {\n /* fire events that update state */\n});\n/* assert on the output */\n\nThis ensures that you're testing the behavior the user would see in the browser. Learn more at https://react.dev/link/wrap-tests-with-act",c(e))}))}(n),e===cf&&((sf&Zc)===Xc&&(Rf|=t),Pf===af&&Tl(e,df,Nf)),le(e)}function El(e,n,t){if((sf&(Zc|ef))!==Xc)throw Error("Should not already be working.");var r=(t=!t&&0==(60&n)&&0==(n&e.expiredLanes))?function(e,n){var t=sf;sf|=Zc;var r=Il(),l=Fl();if(cf!==e||df!==n){if(_u){var a=e.memoizedUpdaters;0t?32:t;t=Ja.T;var l=xo();try{if(wo(r),Ja.T=null,null===Of)var a=!1;else{r=$f,$f=null;var o=Of,u=Bf;if(Of=null,Bf=0,(sf&(Zc|ef))!==Xc)throw Error("Cannot flush passive effects while already rendering.");Jf=!0,Kf=!1,null!==Pu&&"function"==typeof Pu.markPassiveEffectsStarted&&Pu.markPassiveEffectsStarted(u);var i=sf;sf|=ef,bl(o.current),cl(o,o.current,u,r),null!==Pu&&"function"==typeof Pu.markPassiveEffectsStopped&&Pu.markPassiveEffectsStopped(),oa(o),sf=i,ae(0),Kf?o===ed?Zf++:(Zf=0,ed=o):Zf=0,Kf=Jf=!1,Eu&&Eu.onPostCommitFiberRoot;var s=o.current.stateNode;s.effectDuration=0,s.passiveEffectDuration=0,a=!0}return a}finally{wo(l),Ja.T=t,Gl(e,n)}}return!1}function Kl(e,n,t){n=D(t,n),null!==(e=ye(e,n=_t(e.stateNode,n,2),2))&&(P(e,2),le(e))}function Xl(e,n,t){if(nd=!1,3===e.tag)Kl(e,e,t);else{for(;null!==n;){if(3===n.tag)return void Kl(n,e,t);if(1===n.tag){var r=n.stateNode;if("function"==typeof n.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===Af||!Af.has(r)))return e=D(t,e),void(null!==(r=ye(n,t=Rt(2),2))&&(Tt(t,r,n,e),P(r,2),le(r)))}n=n.return}console.error("Internal React error: Attempted to capture a commit phase error inside a detached tree. This indicates a bug in React. Potential causes include deleting the same fiber more than once, committing an already-finished tree, or an inconsistent return pointer.\n\nError message:\n\n%s",t)}}function Zl(e,n,t){var r=e.pingCache;if(null===r){r=e.pingCache=new Kc;var l=new Set;r.set(n,l)}else void 0===(l=r.get(n))&&(l=new Set,r.set(n,l));l.has(t)||(Cf=!0,l.add(t),r=ea.bind(null,e,n,t),_u&&ia(e,t),n.then(r,r))}function ea(e,n,t){var r=e.pingCache;null!==r&&r.delete(n),e.pingedLanes|=e.suspendedLanes&t,e.warmLanes&=~t,wl()&&null===Ja.actQueue&&console.error("A suspended resource finished loading inside a test, but the event was not wrapped in act(...).\n\nWhen testing, code that resolves suspended data should be wrapped into act(...):\n\nact(() => {\n /* finish loading suspended data */\n});\n/* assert on the output */\n\nThis ensures that you're testing the behavior the user would see in the browser. Learn more at https://react.dev/link/wrap-tests-with-act"),cf===e&&(df&t)===t&&(Pf===af||Pf===lf&&(62914560&df)===df&&vu()-Ff",i=" Did you accidentally export a JSX literal instead of a component?"):r=typeof e,(u=l?"number"==typeof l.tag?c(l):"string"==typeof l.name?l.name:null:null)&&(i+="\n\nCheck the render method of `"+u+"`."),u=29,r=Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: "+r+"."+i),i=null}return(n=t(u,r,n,a)).elementType=e,n.type=i,n.lanes=o,n._debugOwner=l,n}function ma(e,n,t){return(n=pa(e.type,e.key,e.props,e._owner,n,t))._debugOwner=e._owner,n}function ha(e,n,r,l){return(e=t(7,e,l,n)).lanes=r,e}function ga(e,n,r,l){(e=t(22,e,l,n)).elementType=$a,e.lanes=r;var a={_visibility:1,_pendingVisibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null,_current:null,detach:function(){var e=a,n=e._current;if(null===n)throw Error("Calling Offscreen.detach before instance handle has been set.");if(0==(2&e._pendingVisibility)){var t=$(n,2);null!==t&&(e._pendingVisibility|=2,Cl(t,n,2))}},attach:function(){var e=a,n=e._current;if(null===n)throw Error("Calling Offscreen.detach before instance handle has been set.");if(0!=(2&e._pendingVisibility)){var t=$(n,2);null!==t&&(e._pendingVisibility&=-3,Cl(t,n,2))}}};return e.stateNode=a,e}function ya(e,n,r){return(e=t(6,e,null,n)).lanes=r,e}function ba(e,n,r){return(n=t(4,null!==e.children?e.children:[],e.key,n)).lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function va(e,n,t,r,l,a,o,u){for(this.tag=1,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=bo,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=E(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.finishedLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=E(0),this.hiddenUpdates=E(null),this.identifierPrefix=r,this.onUncaughtError=l,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=u,this.incompleteTransitions=new Map,this.passiveEffectDuration=this.effectDuration=-0,this.memoizedUpdaters=new Set,e=this.pendingUpdatersLaneMap=[],n=0;31>n;n++)e.push(new Set);this._debugRootType=t?"hydrateRoot()":"createRoot()"}function Sa(e,n,t,r,l,a){l=function(e){return e?e=su:su}(l),null===r.context?r.context=l:r.pendingContext=l,ro&&null!==to&&!cd&&(cd=!0,console.error("Render methods should be a pure function of props and state; triggering nested component updates from render is not allowed. If necessary, trigger nested updates in componentDidUpdate.\n\nCheck the render method of %s.",c(to)||"Unknown")),(r=ge(n)).payload={element:t},null!==(a=void 0===a?null:a)&&("function"!=typeof a&&console.error("Expected the last optional `callback` argument to be a function. Instead received: %s.",a),r.callback=a),null!==(t=ye(e,r,n))&&(Cl(t,e,n),be(t,e,n))}var ka,wa,xa,za,Ca,Ea,Pa,_a={},Ra=e,Ta=u,Na=Object.assign,La=Symbol.for("react.element"),Ua=Symbol.for("react.transitional.element"),Da=Symbol.for("react.portal"),Ia=Symbol.for("react.fragment"),Fa=Symbol.for("react.strict_mode"),Ma=Symbol.for("react.profiler"),Wa=Symbol.for("react.provider"),Ha=Symbol.for("react.consumer"),ja=Symbol.for("react.context"),Aa=Symbol.for("react.forward_ref"),Qa=Symbol.for("react.suspense"),Oa=Symbol.for("react.suspense_list"),Ba=Symbol.for("react.memo"),Va=Symbol.for("react.lazy"),$a=Symbol.for("react.offscreen"),qa=Symbol.for("react.memo_cache_sentinel"),Ya=Symbol.iterator,Ga=Symbol.for("react.client.reference"),Ja=Ra.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ka=0;f.__reactDisabledLog=!0;var Xa,Za,eo=!1,no=new("function"==typeof WeakMap?WeakMap:Map),to=null,ro=!1,lo=Array.isArray,ao=n.getPublicInstance,oo=n.getRootHostContext,uo=n.getChildHostContext,io=n.prepareForCommit,so=n.resetAfterCommit,co=n.createInstance,fo=n.appendInitialChild,po=n.finalizeInitialChildren,mo=n.shouldSetTextContent,ho=n.createTextInstance,go=null,yo=null,bo=n.noTimeout,vo=!0,So=null,ko=null,wo=n.setCurrentUpdatePriority,xo=n.getCurrentUpdatePriority,zo=n.resolveUpdatePriority;n.resolveEventType,n.resolveEventTimeStamp;var Co=n.shouldAttemptEagerTransition,Eo=n.detachDeletedInstance;n.requestPostPaintCallback;var Po=n.maySuspendCommit,_o=null,Ro=null,To=null,No=null,Lo=null,Uo=null,Do=null,Io=n.appendChild,Fo=n.appendChildToContainer,Mo=n.commitTextUpdate,Wo=null,Ho=n.commitUpdate,jo=n.insertBefore,Ao=null,Qo=n.removeChild,Oo=n.removeChildFromContainer,Bo=n.resetTextContent,Vo=null,$o=null,qo=null,Yo=null,Go=n.clearContainer,Jo=null,Ko=null,Xo=null,Zo=null,eu=null,nu=null,tu=null,ru=null,lu=null,au=null,ou=[],uu=[],iu=-1,su={};Object.freeze(su);var cu=Math.clz32?Math.clz32:function(e){return 0==(e>>>=0)?32:31-(fu(e)/du|0)|0},fu=Math.log,du=Math.LN2,pu=128,mu=4194304,hu=Ta.unstable_scheduleCallback,gu=Ta.unstable_cancelCallback,yu=Ta.unstable_shouldYield,bu=Ta.unstable_requestPaint,vu=Ta.unstable_now,Su=Ta.unstable_ImmediatePriority,ku=Ta.unstable_UserBlockingPriority,wu=Ta.unstable_NormalPriority,xu=Ta.unstable_IdlePriority,zu=Ta.log,Cu=Ta.unstable_setDisableYieldValue,Eu=null,Pu=null,_u="undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__,Ru="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},Tu=new WeakMap,Nu=[],Lu=0,Uu=null,Du=0,Iu=[],Fu=0,Mu=null,Wu=1,Hu="",ju=b(null),Au=b(null),Qu=b(null),Ou=b(null),Bu=!1,Vu=null,$u=0,qu=[],Yu=0,Gu=0,Ju=Ta.unstable_now,Ku=-0,Xu=-1.1,Zu=-0,ei=!1,ni=!1,ti=null,ri=null,li=!1,ai=!1,oi=!1,ui=!1,ii=0,si={},ci=null,fi=0,di=0,pi=null,mi=0,hi=1,gi=2,yi=3,bi=!1,vi=!1,Si=null,ki=!1,wi=Object.prototype.hasOwnProperty,xi={recordUnsafeLifecycleWarnings:function(){},flushPendingUnsafeLifecycleWarnings:function(){},recordLegacyContextWarning:function(){},flushLegacyContextWarning:function(){},discardPendingWarnings:function(){}},zi=[],Ci=[],Ei=[],Pi=[],_i=[],Ri=[],Ti=new Set;xi.recordUnsafeLifecycleWarnings=function(e,n){Ti.has(e.type)||("function"==typeof n.componentWillMount&&!0!==n.componentWillMount.__suppressDeprecationWarning&&zi.push(e),8&e.mode&&"function"==typeof n.UNSAFE_componentWillMount&&Ci.push(e),"function"==typeof n.componentWillReceiveProps&&!0!==n.componentWillReceiveProps.__suppressDeprecationWarning&&Ei.push(e),8&e.mode&&"function"==typeof n.UNSAFE_componentWillReceiveProps&&Pi.push(e),"function"==typeof n.componentWillUpdate&&!0!==n.componentWillUpdate.__suppressDeprecationWarning&&_i.push(e),8&e.mode&&"function"==typeof n.UNSAFE_componentWillUpdate&&Ri.push(e))},xi.flushPendingUnsafeLifecycleWarnings=function(){var e=new Set;0.");var o="";null!=t&&e!==t&&(r=null,"number"==typeof t.tag?r=c(t):"string"==typeof t.name&&(r=t.name),r&&(o=" It was passed a child from "+r+".")),y(n,(function(){console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',a,o)}))}}};var cs,fs=We(!0),ds=We(!1),ps=b(null),ms=b(0),hs=b(null),gs=null,ys=1,bs=2,vs=b(0),Ss=0,ks=1,ws=2,xs=4,zs=8,Cs=new Set,Es=new Set,Ps=new Set,_s=new Set,Rs=0,Ts=null,Ns=null,Ls=null,Us=!1,Ds=!1,Is=!1,Fs=0,Ms=0,Ws=null,Hs=0,js=25,As=null,Qs=null,Os=-1,Bs=!1,Vs=function(){return{lastEffect:null,events:null,stores:null,memoCache:null}},$s={readContext:sr,use:cn,useCallback:Ke,useContext:Ke,useEffect:Ke,useImperativeHandle:Ke,useLayoutEffect:Ke,useInsertionEffect:Ke,useMemo:Ke,useReducer:Ke,useRef:Ke,useState:Ke,useDebugValue:Ke,useDeferredValue:Ke,useTransition:Ke,useSyncExternalStore:Ke,useId:Ke};$s.useCacheRefresh=Ke,$s.useMemoCache=Ke,$s.useHostTransitionStatus=Ke,$s.useFormState=Ke,$s.useActionState=Ke,$s.useOptimistic=Ke;var qs=null,Ys=null,Gs=null,Js=null,Ks=null,Xs=null,Zs=null;(qs={readContext:function(e){return sr(e)},use:cn,useCallback:function(e,n){return As="useCallback",qe(),Ge(n),Kn(e,n)},useContext:function(e){return As="useContext",qe(),sr(e)},useEffect:function(e,n){return As="useEffect",qe(),Ge(n),$n(e,n)},useImperativeHandle:function(e,n,t){return As="useImperativeHandle",qe(),Ge(t),Gn(e,n,t)},useInsertionEffect:function(e,n){As="useInsertionEffect",qe(),Ge(n),Bn(4,ws,e,n)},useLayoutEffect:function(e,n){return As="useLayoutEffect",qe(),Ge(n),qn(e,n)},useMemo:function(e,n){As="useMemo",qe(),Ge(n);var t=Ja.H;Ja.H=Ks;try{return Zn(e,n)}finally{Ja.H=t}},useReducer:function(e,n,t){As="useReducer",qe();var r=Ja.H;Ja.H=Ks;try{return pn(e,n,t)}finally{Ja.H=r}},useRef:function(e){return As="useRef",qe(),On(e)},useState:function(e){As="useState",qe();var n=Ja.H;Ja.H=Ks;try{return Cn(e)}finally{Ja.H=n}},useDebugValue:function(){As="useDebugValue",qe()},useDeferredValue:function(e,n){return As="useDeferredValue",qe(),nt(e,n)},useTransition:function(){return As="useTransition",qe(),ut()},useSyncExternalStore:function(e,n,t){return As="useSyncExternalStore",qe(),yn(e,n,t)},useId:function(){return As="useId",qe(),ft()},useCacheRefresh:function(){return As="useCacheRefresh",qe(),dt()}}).useMemoCache=fn,qs.useHostTransitionStatus=ct,qs.useFormState=function(e,n){return As="useFormState",qe(),Je(),Mn(e,n)},qs.useActionState=function(e,n){return As="useActionState",qe(),Mn(e,n)},qs.useOptimistic=function(e){return As="useOptimistic",qe(),En(e)},(Ys={readContext:function(e){return sr(e)},use:cn,useCallback:function(e,n){return As="useCallback",Ye(),Kn(e,n)},useContext:function(e){return As="useContext",Ye(),sr(e)},useEffect:function(e,n){return As="useEffect",Ye(),$n(e,n)},useImperativeHandle:function(e,n,t){return As="useImperativeHandle",Ye(),Gn(e,n,t)},useInsertionEffect:function(e,n){As="useInsertionEffect",Ye(),Bn(4,ws,e,n)},useLayoutEffect:function(e,n){return As="useLayoutEffect",Ye(),qn(e,n)},useMemo:function(e,n){As="useMemo",Ye();var t=Ja.H;Ja.H=Ks;try{return Zn(e,n)}finally{Ja.H=t}},useReducer:function(e,n,t){As="useReducer",Ye();var r=Ja.H;Ja.H=Ks;try{return pn(e,n,t)}finally{Ja.H=r}},useRef:function(e){return As="useRef",Ye(),On(e)},useState:function(e){As="useState",Ye();var n=Ja.H;Ja.H=Ks;try{return Cn(e)}finally{Ja.H=n}},useDebugValue:function(){As="useDebugValue",Ye()},useDeferredValue:function(e,n){return As="useDeferredValue",Ye(),nt(e,n)},useTransition:function(){return As="useTransition",Ye(),ut()},useSyncExternalStore:function(e,n,t){return As="useSyncExternalStore",Ye(),yn(e,n,t)},useId:function(){return As="useId",Ye(),ft()},useCacheRefresh:function(){return As="useCacheRefresh",Ye(),dt()}}).useMemoCache=fn,Ys.useHostTransitionStatus=ct,Ys.useFormState=function(e,n){return As="useFormState",Ye(),Je(),Mn(e,n)},Ys.useActionState=function(e,n){return As="useActionState",Ye(),Mn(e,n)},Ys.useOptimistic=function(e){return As="useOptimistic",Ye(),En(e)},(Gs={readContext:function(e){return sr(e)},use:cn,useCallback:function(e,n){return As="useCallback",Ye(),Xn(e,n)},useContext:function(e){return As="useContext",Ye(),sr(e)},useEffect:function(e,n){As="useEffect",Ye(),Vn(2048,zs,e,n)},useImperativeHandle:function(e,n,t){return As="useImperativeHandle",Ye(),Jn(e,n,t)},useInsertionEffect:function(e,n){return As="useInsertionEffect",Ye(),Vn(4,ws,e,n)},useLayoutEffect:function(e,n){return As="useLayoutEffect",Ye(),Vn(4,xs,e,n)},useMemo:function(e,n){As="useMemo",Ye();var t=Ja.H;Ja.H=Xs;try{return et(e,n)}finally{Ja.H=t}},useReducer:function(e,n,t){As="useReducer",Ye();var r=Ja.H;Ja.H=Xs;try{return mn(e)}finally{Ja.H=r}},useRef:function(){return As="useRef",Ye(),un().memoizedState},useState:function(){As="useState",Ye();var e=Ja.H;Ja.H=Xs;try{return mn(dn)}finally{Ja.H=e}},useDebugValue:function(){As="useDebugValue",Ye()},useDeferredValue:function(e,n){return As="useDeferredValue",Ye(),tt(e,n)},useTransition:function(){return As="useTransition",Ye(),it()},useSyncExternalStore:function(e,n,t){return As="useSyncExternalStore",Ye(),bn(e,n,t)},useId:function(){return As="useId",Ye(),un().memoizedState},useCacheRefresh:function(){return As="useCacheRefresh",Ye(),un().memoizedState}}).useMemoCache=fn,Gs.useHostTransitionStatus=ct,Gs.useFormState=function(e){return As="useFormState",Ye(),Je(),Wn(e)},Gs.useActionState=function(e){return As="useActionState",Ye(),Wn(e)},Gs.useOptimistic=function(e,n){return As="useOptimistic",Ye(),Pn(e,n)},(Js={readContext:function(e){return sr(e)},use:cn,useCallback:function(e,n){return As="useCallback",Ye(),Xn(e,n)},useContext:function(e){return As="useContext",Ye(),sr(e)},useEffect:function(e,n){As="useEffect",Ye(),Vn(2048,zs,e,n)},useImperativeHandle:function(e,n,t){return As="useImperativeHandle",Ye(),Jn(e,n,t)},useInsertionEffect:function(e,n){return As="useInsertionEffect",Ye(),Vn(4,ws,e,n)},useLayoutEffect:function(e,n){return As="useLayoutEffect",Ye(),Vn(4,xs,e,n)},useMemo:function(e,n){As="useMemo",Ye();var t=Ja.H;Ja.H=Zs;try{return et(e,n)}finally{Ja.H=t}},useReducer:function(e,n,t){As="useReducer",Ye();var r=Ja.H;Ja.H=Zs;try{return gn(e)}finally{Ja.H=r}},useRef:function(){return As="useRef",Ye(),un().memoizedState},useState:function(){As="useState",Ye();var e=Ja.H;Ja.H=Zs;try{return gn(dn)}finally{Ja.H=e}},useDebugValue:function(){As="useDebugValue",Ye()},useDeferredValue:function(e,n){return As="useDeferredValue",Ye(),rt(e,n)},useTransition:function(){return As="useTransition",Ye(),st()},useSyncExternalStore:function(e,n,t){return As="useSyncExternalStore",Ye(),bn(e,n,t)},useId:function(){return As="useId",Ye(),un().memoizedState},useCacheRefresh:function(){return As="useCacheRefresh",Ye(),un().memoizedState}}).useMemoCache=fn,Js.useHostTransitionStatus=ct,Js.useFormState=function(e){return As="useFormState",Ye(),Je(),An(e)},Js.useActionState=function(e){return As="useActionState",Ye(),An(e)},Js.useOptimistic=function(e,n){return As="useOptimistic",Ye(),Rn(e,n)},(Ks={readContext:function(e){return l(),sr(e)},use:function(e){return r(),cn(e)},useCallback:function(e,n){return As="useCallback",r(),qe(),Kn(e,n)},useContext:function(e){return As="useContext",r(),qe(),sr(e)},useEffect:function(e,n){return As="useEffect",r(),qe(),$n(e,n)},useImperativeHandle:function(e,n,t){return As="useImperativeHandle",r(),qe(),Gn(e,n,t)},useInsertionEffect:function(e,n){As="useInsertionEffect",r(),qe(),Bn(4,ws,e,n)},useLayoutEffect:function(e,n){return As="useLayoutEffect",r(),qe(),qn(e,n)},useMemo:function(e,n){As="useMemo",r(),qe();var t=Ja.H;Ja.H=Ks;try{return Zn(e,n)}finally{Ja.H=t}},useReducer:function(e,n,t){As="useReducer",r(),qe();var l=Ja.H;Ja.H=Ks;try{return pn(e,n,t)}finally{Ja.H=l}},useRef:function(e){return As="useRef",r(),qe(),On(e)},useState:function(e){As="useState",r(),qe();var n=Ja.H;Ja.H=Ks;try{return Cn(e)}finally{Ja.H=n}},useDebugValue:function(){As="useDebugValue",r(),qe()},useDeferredValue:function(e,n){return As="useDeferredValue",r(),qe(),nt(e,n)},useTransition:function(){return As="useTransition",r(),qe(),ut()},useSyncExternalStore:function(e,n,t){return As="useSyncExternalStore",r(),qe(),yn(e,n,t)},useId:function(){return As="useId",r(),qe(),ft()},useCacheRefresh:function(){return As="useCacheRefresh",qe(),dt()},useMemoCache:function(e){return r(),fn(e)}}).useHostTransitionStatus=ct,Ks.useFormState=function(e,n){return As="useFormState",r(),qe(),Mn(e,n)},Ks.useActionState=function(e,n){return As="useActionState",r(),qe(),Mn(e,n)},Ks.useOptimistic=function(e){return As="useOptimistic",r(),qe(),En(e)},(Xs={readContext:function(e){return l(),sr(e)},use:function(e){return r(),cn(e)},useCallback:function(e,n){return As="useCallback",r(),Ye(),Xn(e,n)},useContext:function(e){return As="useContext",r(),Ye(),sr(e)},useEffect:function(e,n){As="useEffect",r(),Ye(),Vn(2048,zs,e,n)},useImperativeHandle:function(e,n,t){return As="useImperativeHandle",r(),Ye(),Jn(e,n,t)},useInsertionEffect:function(e,n){return As="useInsertionEffect",r(),Ye(),Vn(4,ws,e,n)},useLayoutEffect:function(e,n){return As="useLayoutEffect",r(),Ye(),Vn(4,xs,e,n)},useMemo:function(e,n){As="useMemo",r(),Ye();var t=Ja.H;Ja.H=Xs;try{return et(e,n)}finally{Ja.H=t}},useReducer:function(e,n,t){As="useReducer",r(),Ye();var l=Ja.H;Ja.H=Xs;try{return mn(e)}finally{Ja.H=l}},useRef:function(){return As="useRef",r(),Ye(),un().memoizedState},useState:function(){As="useState",r(),Ye();var e=Ja.H;Ja.H=Xs;try{return mn(dn)}finally{Ja.H=e}},useDebugValue:function(){As="useDebugValue",r(),Ye()},useDeferredValue:function(e,n){return As="useDeferredValue",r(),Ye(),tt(e,n)},useTransition:function(){return As="useTransition",r(),Ye(),it()},useSyncExternalStore:function(e,n,t){return As="useSyncExternalStore",r(),Ye(),bn(e,n,t)},useId:function(){return As="useId",r(),Ye(),un().memoizedState},useCacheRefresh:function(){return As="useCacheRefresh",Ye(),un().memoizedState},useMemoCache:function(e){return r(),fn(e)}}).useHostTransitionStatus=ct,Xs.useFormState=function(e){return As="useFormState",r(),Ye(),Wn(e)},Xs.useActionState=function(e){return As="useActionState",r(),Ye(),Wn(e)},Xs.useOptimistic=function(e,n){return As="useOptimistic",r(),Ye(),Pn(e,n)},(Zs={readContext:function(e){return l(),sr(e)},use:function(e){return r(),cn(e)},useCallback:function(e,n){return As="useCallback",r(),Ye(),Xn(e,n)},useContext:function(e){return As="useContext",r(),Ye(),sr(e)},useEffect:function(e,n){As="useEffect",r(),Ye(),Vn(2048,zs,e,n)},useImperativeHandle:function(e,n,t){return As="useImperativeHandle",r(),Ye(),Jn(e,n,t)},useInsertionEffect:function(e,n){return As="useInsertionEffect",r(),Ye(),Vn(4,ws,e,n)},useLayoutEffect:function(e,n){return As="useLayoutEffect",r(),Ye(),Vn(4,xs,e,n)},useMemo:function(e,n){As="useMemo",r(),Ye();var t=Ja.H;Ja.H=Xs;try{return et(e,n)}finally{Ja.H=t}},useReducer:function(e,n,t){As="useReducer",r(),Ye();var l=Ja.H;Ja.H=Xs;try{return gn(e)}finally{Ja.H=l}},useRef:function(){return As="useRef",r(),Ye(),un().memoizedState},useState:function(){As="useState",r(),Ye();var e=Ja.H;Ja.H=Xs;try{return gn(dn)}finally{Ja.H=e}},useDebugValue:function(){As="useDebugValue",r(),Ye()},useDeferredValue:function(e,n){return As="useDeferredValue",r(),Ye(),rt(e,n)},useTransition:function(){return As="useTransition",r(),Ye(),st()},useSyncExternalStore:function(e,n,t){return As="useSyncExternalStore",r(),Ye(),bn(e,n,t)},useId:function(){return As="useId",r(),Ye(),un().memoizedState},useCacheRefresh:function(){return As="useCacheRefresh",Ye(),un().memoizedState},useMemoCache:function(e){return r(),fn(e)}}).useHostTransitionStatus=ct,Zs.useFormState=function(e){return As="useFormState",r(),Ye(),An(e)},Zs.useActionState=function(e){return As="useActionState",r(),Ye(),An(e)},Zs.useOptimistic=function(e,n){return As="useOptimistic",r(),Ye(),Rn(e,n)};var ec={},nc=new Set,tc=new Set,rc=new Set,lc=new Set,ac=new Set,oc=new Set,uc=new Set,ic=new Set,sc=new Set,cc=new Set;Object.freeze(ec);var fc={isMounted:function(e){var n=to;if(null!==n&&ro&&1===n.tag){var t=n.stateNode;t._warnedAboutRefsInRender||console.error("%s is accessing isMounted inside its render() function. render() should be a pure function of props and state. It should never access something that requires stale data from the previous render, such as refs. Move this logic to componentDidMount and componentDidUpdate instead.",c(n)||"A component"),t._warnedAboutRefsInRender=!0}return!!(e=e._reactInternals)&&function(e){var n=e,t=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do{0!=(4098&(n=e).flags)&&(t=n.return),e=n.return}while(e)}return 3===n.tag?t:null}(e)===e},enqueueSetState:function(e,n,t){var r=xl(e=e._reactInternals),l=ge(r);l.payload=n,null!=t&&(kt(t),l.callback=t),null!==(n=ye(e,l,r))&&(Cl(n,e,r),be(n,e,r))},enqueueReplaceState:function(e,n,t){var r=xl(e=e._reactInternals),l=ge(r);l.tag=hi,l.payload=n,null!=t&&(kt(t),l.callback=t),null!==(n=ye(e,l,r))&&(Cl(n,e,r),be(n,e,r))},enqueueForceUpdate:function(e,n){var t=xl(e=e._reactInternals),r=ge(t);r.tag=gi,null!=n&&(kt(n),r.callback=n),null!==(n=ye(e,r,t))&&(Cl(n,e,t),be(n,e,t))}};"function"==typeof reportError&&reportError;var dc=Error("This is not a real error. It's an implementation detail of React's selective hydration feature. If this leaks into userspace, it's a bug in React. Please file an issue."),pc=!1,mc={},hc={},gc={},yc={},bc=!1,vc={},Sc={},kc={dehydrated:null,treeContext:null,retryLane:0},wc=!1,xc=b(null),zc=b(null),Cc={},Ec=null,Pc=null,_c=null,Rc=!1,Tc="undefined"!=typeof AbortController?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(n,t){e.push(t)}};this.abort=function(){n.aborted=!0,e.forEach((function(e){return e()}))}},Nc=Ta.unstable_scheduleCallback,Lc=Ta.unstable_NormalPriority,Uc={$$typeof:ja,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0,_currentRenderer:null,_currentRenderer2:null},Dc=Ja.S;Ja.S=function(e,n){"object"==typeof n&&null!==n&&"function"==typeof n.then&&function(e,n){if(null===ci){var t=ci=[];fi=0,di=de(),pi={status:"pending",value:void 0,then:function(e){t.push(e)}}}fi++,n.then(pe,pe)}(0,n),null!==Dc&&Dc(e,n)};var Ic=b(null),Fc=null;Fc=new Set;var Mc=!1,Wc=!1,Hc=!1,jc="function"==typeof WeakSet?WeakSet:Set,Ac=null,Qc=null,Oc=null,Bc=!1,Vc=null,$c=!1,qc=null,Yc=8192,Gc={getCacheForType:function(e){var n=sr(Uc),t=n.data.get(e);return void 0===t&&(t=e(),n.data.set(e,t)),t},getOwner:function(){return to}};if("function"==typeof Symbol&&Symbol.for){var Jc=Symbol.for;Jc("selector.component"),Jc("selector.has_pseudo_class"),Jc("selector.role"),Jc("selector.test_id"),Jc("selector.text")}var Kc="function"==typeof WeakMap?WeakMap:Map,Xc=0,Zc=2,ef=4,nf=0,tf=1,rf=2,lf=3,af=4,of=5,uf=6,sf=Xc,cf=null,ff=null,df=0,pf=0,mf=1,hf=2,gf=3,yf=4,bf=5,vf=6,Sf=7,kf=8,wf=pf,xf=null,zf=!1,Cf=!1,Ef=0,Pf=nf,_f=0,Rf=0,Tf=0,Nf=0,Lf=0,Uf=null,Df=null,If=!1,Ff=0,Mf=300,Wf=1/0,Hf=500,jf=null,Af=null,Qf=!1,Of=null,Bf=0,Vf=0,$f=null,qf=50,Yf=0,Gf=null,Jf=!1,Kf=!1,Xf=50,Zf=0,ed=null,nd=!1,td=0,rd=1,ld=2,ad=null,od=!1,ud=new Set,id=!1;try{var sd=Object.preventExtensions({});new Map([[sd,null]]),new Set([sd])}catch(e){id=!0}var cd=!1;return _a.createContainer=function(e,n,r,l,a,o,u,i,s,c){return function(e,n,r,l,a,o,u,i,s,c,f,d){return e=new va(e,n,r,u,i,s,c,null),n=1,!0===o&&(n|=24),_u&&(n|=2),o=t(3,null,null,n),e.current=o,o.stateNode=e,pr(n=dr()),e.pooledCache=n,pr(n),o.memoizedState={element:l,isDehydrated:r,cache:n},me(o),e}(e,n,!1,null,0,l,o,u,i,s)},_a.flushSyncWork=function(){return(sf&(Zc|ef))!==Xc||(ae(0),!1)},_a.updateContainer=function(e,n,t,r){var l=n.current,a=xl(l);return Sa(l,a,e,n,t,r),a},_a.updateContainerSync=function(e,n,t,r){return 0===n.tag&&Jl(),Sa(n.current,2,e,n,t,r),2},_a},n.exports.default=n.exports,Object.defineProperty(n.exports,"__esModule",{value:!0}))),c.exports;var n}();var f,d=t(a.exports),p={exports:{}},m={};var h,g={}; +/** + * @license React + * react-reconciler-constants.development.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */"production"===process.env.NODE_ENV?p.exports=(f||(f=1,m.ConcurrentRoot=1,m.ContinuousEventPriority=8,m.DefaultEventPriority=32,m.DiscreteEventPriority=2,m.IdleEventPriority=268435456,m.LegacyRoot=0,m.NoEventPriority=0),m):p.exports=(h||(h=1,"production"!==process.env.NODE_ENV&&(g.ConcurrentRoot=1,g.ContinuousEventPriority=8,g.DefaultEventPriority=32,g.DiscreteEventPriority=2,g.IdleEventPriority=268435456,g.LegacyRoot=0,g.NoEventPriority=0)),g);var y=p.exports;const b=(e,n)=>{const t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;for(let r=0;r{const c=d({appendChild:e,appendChildToContainer:n,appendInitialChild:e,createInstance:l,createTextInstance:a,insertBefore:o,commitUpdate:(e,n,t,l)=>{b(t,l)||r(e,null,n,t,l)},commitTextUpdate:t,removeChild:u,removeChildFromContainer:i,resetAfterCommit:s,noTimeout:-1,shouldSetTextContent:()=>!1,finalizeInitialChildren:()=>!1,getPublicInstance:e=>e,getRootHostContext:()=>v,getChildHostContext:()=>v,prepareForCommit(){},clearContainer(){},resetTextContent(){},getCurrentUpdatePriority:()=>y.DefaultEventPriority,maySuspendCommit:()=>!1,requestPostPaintCallback:()=>{},resolveUpdatePriority:()=>y.DefaultEventPriority,setCurrentUpdatePriority:()=>{},shouldAttemptEagerTransition:()=>!1,detachDeletedInstance:()=>{}});return{createContainer:e=>c.createContainer(e,y.ConcurrentRoot,null,!1,null,"",S,S,S,null),updateContainer:(e,n,t,r)=>{c.updateContainerSync(e,n,t,r),c.flushSyncWork()}}};export{k as default}; diff --git a/node_modules/@react-pdf/reconciler/lib/reconciler-33.js b/node_modules/@react-pdf/reconciler/lib/reconciler-33.js new file mode 100644 index 0000000000000000000000000000000000000000..9d5d350d658410cf7c3c907de782d4107f9716c4 --- /dev/null +++ b/node_modules/@react-pdf/reconciler/lib/reconciler-33.js @@ -0,0 +1,19 @@ +import e from"react";import*as n from"scheduler";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(e){if(e.__esModule)return e;var n=e.default;if("function"==typeof n){var t=function e(){return this instanceof e?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}var l,a={exports:{}},o={exports:{}},u=r(n);var i,s,c={exports:{}}; +/** + * @license React + * react-reconciler.development.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */"production"===process.env.NODE_ENV?a.exports=(l||(l=1,(s=o).exports=function(n){function t(e,n,t,r){return new tl(e,n,t,r)}function r(e){var n="https://react.dev/errors/"+e;if(1Ma||(e.current=Oa[Ma],Oa[Ma]=null,Ma--)}function s(e,n){Ma++,Oa[Ma]=e.current,e.current=n}function c(e){var n=42&e;if(0!==n)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function d(e,n,t){var r=e.pendingLanes;if(0===r)return 0;var l=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var u=134217727&r;return 0!==u?0!=(r=u&~a)?l=c(r):0!=(o&=u)?l=c(o):t||0!=(t=u&~e)&&(l=c(t)):0!=(u=r&~a)?l=c(u):0!==o?l=c(o):t||0!=(t=r&~e)&&(l=c(t)),0===l?0:0!==n&&n!==l&&0==(n&a)&&((a=l&-l)>=(t=n&-n)||32===a&&0!=(4194048&t))?n:l}function f(e,n){return 0==(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)}function p(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;default:return-1}}function m(){var e=Ya;return 0==(62914560&(Ya<<=1))&&(Ya=4194304),e}function h(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function g(e,n){e.pendingLanes|=n,268435456!==n&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function y(e,n,t){e.pendingLanes|=n,e.suspendedLanes&=~n;var r=31-Qa(n);e.entangledLanes|=n,e.entanglements[r]=1073741824|e.entanglements[r]|261930&t}function b(e,n){var t=e.entangledLanes|=n;for(e=e.entanglements;t;){var r=31-Qa(t),l=1<)":-1--l||i[r]!==s[l]){var c="\n"+i[r].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}}while(1<=r&&0<=l);break}}}finally{fo=!1,Error.prepareStackTrace=t}return(t=e?e.displayName||e.name:"")?w(t):""}function x(e,n){switch(e.tag){case 26:case 27:case 5:return w(e.type);case 16:return w("Lazy");case 13:return e.child!==n&&null!==n?w("Suspense Fallback"):w("Suspense");case 19:return w("SuspenseList");case 0:case 15:return z(e.type,!1);case 11:return z(e.type.render,!1);case 1:return z(e.type,!0);case 31:return w("Activity");default:return""}}function E(e){try{var n="",t=null;do{n+=x(e,t),t=e,e=e.return}while(e);return n}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}function C(e,n){if("object"==typeof e&&null!==e){var t=po.get(e);return void 0!==t?t:(n={value:e,source:n,stack:E(n)},po.set(e,n),n)}return{value:e,source:n,stack:E(n)}}function P(e){for(;e===go;)go=mo[--ho],mo[ho]=null,mo[--ho],mo[ho]=null;for(;e===vo;)vo=yo[--bo],yo[bo]=null,yo[--bo],yo[bo]=null,yo[--bo],yo[bo]=null}function _(e,n){s(wo,n),s(ko,e),s(So,null),e=Fl(n),i(So),s(So,e)}function T(){i(So),i(ko),i(wo)}function R(e){null!==e.memoizedState&&s(zo,e);var n=So.current,t=jl(n,e.type);n!==t&&(s(ko,e),s(So,t))}function N(e){ko.current===e&&(i(So),i(ko)),zo.current===e&&(i(zo),ca._currentValue2=sa)}function L(){var e=Eo;return null!==e&&(null===li?li=e:li.push.apply(li,e),Eo=null),e}function U(e,n,t){s(Co,n._currentValue2),n._currentValue2=t}function D(e){var n=Co.current;e._currentValue2=n,i(Co)}function I(e,n,t){for(;null!==e;){var r=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,null!==r&&(r.childLanes|=n)):null!==r&&(r.childLanes&n)!==n&&(r.childLanes|=n),e===t)break;e=e.return}}function F(e,n,t,l){var a=e.child;for(null!==a&&(a.return=e);null!==a;){var o=a.dependencies;if(null!==o){var u=a.child;o=o.firstContext;e:for(;null!==o;){var i=o;o=a;for(var s=0;sf?(p=d,d=null):p=d.sibling;var y=h(t,d,l[f],u);if(null===y){null===d&&(d=p);break}e&&d&&null===y.alternate&&n(t,d),r=i(y,r,f),null===c?s=y:c.sibling=y,c=y,d=p}if(f===l.length)return a(t,d),s;if(null===d){for(;fp?(y=f,f=null):y=f.sibling;var v=h(t,f,b.value,s);if(null===v){null===f&&(f=y);break}e&&f&&null===v.alternate&&n(t,f),l=i(v,l,p),null===d?c=v:d.sibling=v,d=v,f=y}if(b.done)return a(t,f),c;if(null===f){for(;!b.done;p++,b=u.next())null!==(b=m(t,b.value,s))&&(l=i(b,l,p),null===d?c=b:d.sibling=b,d=b);return c}for(f=o(f);!b.done;p++,b=u.next())null!==(b=g(f,t,p,b.value,s))&&(e&&null!==b.alternate&&f.delete(null===b.key?p:b.key),l=i(b,l,p),null===d?c=b:d.sibling=b,d=b);return e&&f.forEach((function(e){return n(t,e)})),c}(t,c,d=p.call(d),f)}if("function"==typeof d.then)return y(t,c,se(d),f);if(d.$$typeof===zl)return y(t,c,M(t,d),f);de(t,d)}return"string"==typeof d&&""!==d||"number"==typeof d||"bigint"==typeof d?(d=""+d,null!==c&&6===c.tag?(a(t,c.sibling),(f=u(c,d)).return=t,t=f):(a(t,c),(f=il(d,t.mode,f)).return=t,t=f),s(t)):a(t,c)}return function(e,n,r,l){try{Ko=0;var a=y(e,n,r,l);return Jo=null,a}catch(n){if(n===$o||n===qo)throw n;var o=t(29,n,null,e.mode);return o.lanes=l,o.return=e,o}}}function pe(){for(var e=nu,n=tu=nu=0;na?a:8);var o,u,i,s=Dl.T,c={};Dl.T=c,qn(e,!1,n,t);try{var d=l(),f=Dl.S;null!==f&&f(c,d),null!==d&&"object"==typeof d&&"function"==typeof d.then?Vn(e,n,(o=r,u=[],i={status:"pending",value:null,reason:null,then:function(e){u.push(e)}},d.then((function(){i.status="fulfilled",i.value=o;for(var e=0;eii&&(n.flags|=128,a=!0,Dt(l,!1),n.lanes=4194304)}else{if(!a)if(null!==(e=je(o))){if(n.flags|=128,a=!0,e=e.updateQueue,n.updateQueue=e,Ut(n,e),Dt(l,!0),null===l.tail&&"hidden"===l.tailMode&&!o.alternate)return It(n),null}else 2*Za()-l.renderingStartTime>ii&&536870912!==t&&(n.flags|=128,a=!0,Dt(l,!1),n.lanes=4194304);l.isBackwards?(o.sibling=n.child,n.child=o):(null!==(e=l.last)?e.sibling=o:n.child=o,l.last=o)}return null!==l.tail?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=Za(),e.sibling=null,t=su.current,s(su,a?1&t|2:1&t),e):(It(n),null);case 22:case 23:return Fe(n),Ne(),l=null!==n.memoizedState,null!==e?null!==e.memoizedState!==l&&(n.flags|=8192):l&&(n.flags|=8192),l?0!=(536870912&t)&&0==(128&n.flags)&&(It(n),6&n.subtreeFlags&&(n.flags|=8192)):It(n),null!==(t=n.updateQueue)&&Ut(n,t.retryQueue),t=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(t=e.memoizedState.cachePool.pool),l=null,null!==n.memoizedState&&null!==n.memoizedState.cachePool&&(l=n.memoizedState.cachePool.pool),l!==t&&(n.flags|=2048),null!==e&&i(Bo),null;case 24:return t=null,null!==e&&(t=e.memoizedState.cache),n.memoizedState.cache!==t&&(n.flags|=2048),D(Lo),It(n),null;case 25:case 30:return null}throw Error(r(156,n.tag))}function jt(e,n){switch(P(n),n.tag){case 1:return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 3:return D(Lo),T(),0!=(65536&(e=n.flags))&&0==(128&e)?(n.flags=-65537&e|128,n):null;case 26:case 27:case 5:return N(n),null;case 31:if(null!==n.memoizedState&&(Fe(n),null===n.alternate))throw Error(r(340));return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 13:if(Fe(n),null!==(e=n.memoizedState)&&null!==e.dehydrated&&null===n.alternate)throw Error(r(340));return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 19:return i(su),null;case 4:return T(),null;case 10:return D(n.type),null;case 22:case 23:return Fe(n),Ne(),null!==e&&i(Bo),65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 24:return D(Lo),null;default:return null}}function At(e,n){switch(P(n),n.tag){case 3:D(Lo),T();break;case 26:case 27:case 5:N(n);break;case 4:T();break;case 31:null!==n.memoizedState&&Fe(n);break;case 13:Fe(n);break;case 19:i(su);break;case 10:D(n.type);break;case 22:case 23:Fe(n),Ne(),null!==e&&i(Bo);break;case 24:D(Lo)}}function Ht(e,n){try{var t=n.updateQueue,r=null!==t?t.lastEffect:null;if(null!==r){var l=r.next;t=l;do{if((t.tag&e)===e){r=void 0;var a=t.create,o=t.inst;r=a(),o.destroy=r}t=t.next}while(t!==l)}}catch(e){Jr(n,n.return,e)}}function Ot(e,n,t){try{var r=n.updateQueue,l=null!==r?r.lastEffect:null;if(null!==l){var a=l.next;r=a;do{if((r.tag&e)===e){var o=r.inst,u=o.destroy;if(void 0!==u){o.destroy=void 0,l=n;var i=t,s=u;try{s()}catch(e){Jr(l,i,e)}}}r=r.next}while(r!==a)}}catch(e){Jr(n,n.return,e)}}function Mt(e){var n=e.updateQueue;if(null!==n){var t=e.stateNode;try{_e(n,t)}catch(n){Jr(e,e.return,n)}}}function Wt(e,n,t){t.props=et(e.type,e.memoizedProps),t.state=e.memoizedState;try{t.componentWillUnmount()}catch(t){Jr(e,n,t)}}function Qt(e,n){try{var t=e.ref;if(null!==t){switch(e.tag){case 26:case 27:case 5:var r=Il(e.stateNode);break;default:r=e.stateNode}"function"==typeof t?e.refCleanup=t(r):t.current=r}}catch(t){Jr(e,n,t)}}function Bt(e,n){var t=e.ref,r=e.refCleanup;if(null!==t)if("function"==typeof r)try{r()}catch(t){Jr(e,n,t)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof t)try{t(null)}catch(t){Jr(e,n,t)}else t.current=null}function $t(e){var n=e.type,t=e.memoizedProps,r=e.stateNode;try{ha(r,n,t,e)}catch(n){Jr(e,e.return,n)}}function Vt(e){return 5===e.tag||3===e.tag||4===e.tag}function qt(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||Vt(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function Yt(e,n,t){var r=e.tag;if(5===r||6===r)e=e.stateNode,n?ba(t,e,n):pa(t,e);else if(4!==r&&null!==(e=e.child))for(Yt(e,n,t),e=e.sibling;null!==e;)Yt(e,n,t),e=e.sibling}function Gt(e,n,t){var r=e.tag;if(5===r||6===r)e=e.stateNode,n?ya(t,e,n):fa(t,e);else if(4!==r&&null!==(e=e.child))for(Gt(e,n,t),e=e.sibling;null!==e;)Gt(e,n,t),e=e.sibling}function Jt(e,n,t){var r=t.flags;switch(t.tag){case 0:case 11:case 15:ar(e,t),4&r&&Ht(5,t);break;case 1:if(ar(e,t),4&r)if(e=t.stateNode,null===n)try{e.componentDidMount()}catch(e){Jr(t,t.return,e)}else{var l=et(t.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(l,n,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Jr(t,t.return,e)}}64&r&&Mt(t),512&r&&Qt(t,t.return);break;case 3:if(ar(e,t),64&r&&null!==(r=t.updateQueue)){if(e=null,null!==t.child)switch(t.child.tag){case 27:case 5:e=Il(t.child.stateNode);break;case 1:e=t.child.stateNode}try{_e(r,e)}catch(e){Jr(t,t.return,e)}}break;case 27:case 26:case 5:if(ar(e,t),null===n)if(4&r)$t(t);else if(64&r){e=t.type,n=t.memoizedProps,l=t.stateNode;try{Na(l,e,n,t)}catch(e){Jr(t,t.return,e)}}512&r&&Qt(t,t.return);break;case 12:case 31:default:ar(e,t);break;case 13:ar(e,t),64&r&&null!==(r=t.memoizedState)&&null!==(r=r.dehydrated)&&(t=el.bind(null,t),Ra(r,t));break;case 22:if(!(r=null!==t.memoizedState||Tu)){n=null!==n&&null!==n.memoizedState||Ru,l=Tu;var a=Ru;Tu=r,(Ru=n)&&!a?ur(e,t,0!=(8772&t.subtreeFlags)):ar(e,t),Tu=l,Ru=a}case 30:}}function Kt(e){var n=e.alternate;null!==n&&(e.alternate=null,Kt(n)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&null!==(n=e.stateNode)&&na(n),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Xt(e,n,t){for(t=t.child;null!==t;)Zt(e,n,t),t=t.sibling}function Zt(e,n,t){switch(t.tag){case 26:case 27:var r,l;case 5:Ru||Bt(t,n);case 6:if(r=Du,l=Iu,Du=null,Xt(e,n,t),Iu=l,null!==(Du=r))if(Iu)try{Sa(Du,t.stateNode)}catch(e){Jr(t,n,e)}else try{va(Du,t.stateNode)}catch(e){Jr(t,n,e)}break;case 18:null!==Du&&(Iu?Ua(Du,t.stateNode):La(Du,t.stateNode));break;case 4:r=Du,l=Iu,Du=t.stateNode.containerInfo,Iu=!0,Xt(e,n,t),Du=r,Iu=l;break;case 0:case 11:case 14:case 15:Ot(2,t,n),Ru||Ot(4,t,n),Xt(e,n,t);break;case 1:Ru||(Bt(t,n),"function"==typeof(r=t.stateNode).componentWillUnmount&&Wt(t,n,r)),Xt(e,n,t);break;case 21:Xt(e,n,t);break;case 22:Ru=(r=Ru)||null!==t.memoizedState,Xt(e,n,t),Ru=r;break;default:Xt(e,n,t)}}function er(e,n){var t=function(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return null===n&&(n=e.stateNode=new Lu),n;case 22:return null===(n=(e=e.stateNode)._retryCache)&&(n=e._retryCache=new Lu),n;default:throw Error(r(435,e.tag))}}(e);n.forEach((function(n){if(!t.has(n)){t.add(n);var r=nl.bind(null,e,n);n.then(r,r)}}))}function nr(e,n){var t=n.deletions;if(null!==t)for(var l=0;lt?32:t;t=Dl.T;var a=Xl();try{Kl(l),Dl.T=null,l=gi,gi=null;var o=fi,u=mi;if(di=0,pi=fi=null,mi=0,0!=(6&Mu))throw Error(r(331));var i=Mu;return Mu|=4,br(o.current),dr(o,o.current,u,l),Mu=i,q(0),oo&&oo.onPostCommitFiberRoot,!0}finally{Kl(a),Dl.T=t,Vr(e,n)}}function Gr(e,n,t){n=C(t,n),null!==(e=we(e,n=rt(e.stateNode,n,2),2))&&(g(e,2),V(e))}function Jr(e,n,t){if(3===e.tag)Gr(e,e,t);else for(;null!==n;){if(3===n.tag){Gr(n,e,t);break}if(1===n.tag){var r=n.stateNode;if("function"==typeof n.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===ci||!ci.has(r))){e=C(t,e),null!==(r=we(n,t=lt(2),2))&&(at(t,r,n,e),g(r,2),V(r));break}}n=n.return}}function Kr(e,n,t){var r=e.pingCache;if(null===r){r=e.pingCache=new Ou;var l=new Set;r.set(n,l)}else void 0===(l=r.get(n))&&(l=new Set,r.set(n,l));l.has(t)||(Gu=!0,l.add(t),e=Xr.bind(null,e,n,t),n.then(e,e))}function Xr(e,n,t){var r=e.pingCache;null!==r&&r.delete(n),e.pingedLanes|=e.suspendedLanes&t,e.warmLanes&=~t,Wu===e&&(Bu&t)===t&&(4===Ku||3===Ku&&(62914560&Bu)===Bu&&300>Za()-oi?0==(2&Mu)&&Tr(e,0):ei|=t,ti===Bu&&(ti=0)),V(e)}function Zr(e,n){0===n&&(n=m()),null!==(e=ge(e,n))&&(g(e,n),V(e))}function el(e){var n=e.memoizedState,t=0;null!==n&&(t=n.retryLane),Zr(e,t)}function nl(e,n){var t=0;switch(e.tag){case 31:case 13:var l=e.stateNode,a=e.memoizedState;null!==a&&(t=a.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(r(314))}null!==l&&l.delete(n),Zr(e,t)}function tl(e,n,t,r){this.tag=e,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function rl(e){return!(!(e=e.prototype)||!e.isReactComponent)}function ll(e,n){var r=e.alternate;return null===r?((r=t(e.tag,n,e.key,e.mode)).elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=65011712&e.flags,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function al(e,n){e.flags&=65011714;var t=e.alternate;return null===t?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=t.childLanes,e.lanes=t.lanes,e.child=t.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=t.memoizedProps,e.memoizedState=t.memoizedState,e.updateQueue=t.updateQueue,e.type=t.type,n=t.dependencies,e.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function ol(e,n,l,a,o,u){var i=0;if(a=e,"function"==typeof e)rl(e)&&(i=1);else if("string"==typeof e)i=5;else e:switch(e){case Tl:return(e=t(31,l,n,o)).elementType=Tl,e.lanes=u,e;case vl:return ul(l.children,o,u,n);case Sl:i=8,o|=24;break;case kl:return(e=t(12,l,n,2|o)).elementType=kl,e.lanes=u,e;case El:return(e=t(13,l,n,o)).elementType=El,e.lanes=u,e;case Cl:return(e=t(19,l,n,o)).elementType=Cl,e.lanes=u,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case zl:i=10;break e;case wl:i=9;break e;case xl:i=11;break e;case Pl:i=14;break e;case _l:i=16,a=null;break e}i=29,l=Error(r(130,null===e?"null":typeof e,"")),a=null}return(n=t(i,l,n,o)).elementType=e,n.type=a,n.lanes=u,n}function ul(e,n,r,l){return(e=t(7,e,l,n)).lanes=r,e}function il(e,n,r){return(e=t(6,e,null,n)).lanes=r,e}function sl(e,n,r){return(n=t(4,null!==e.children?e.children:[],e.key,n)).lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function cl(e,n,t,r,l,a,o,u,i){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=ql,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=h(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=h(0),this.hiddenUpdates=h(null),this.identifierPrefix=r,this.onUncaughtError=l,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=i,this.incompleteTransitions=new Map}function dl(e,n,t,r,l,a){l=function(e){return e?e=Wa:Wa}(l),null===r.context?r.context=l:r.pendingContext=l,(r=ke(n)).payload={element:t},null!==(a=void 0===a?null:a)&&(r.callback=a),null!==(t=we(e,r,n))&&(zr(t,0,n),ze(t,e,n))}var fl={},pl=e,ml=u,hl=Object.assign,gl=Symbol.for("react.element"),yl=Symbol.for("react.transitional.element"),bl=Symbol.for("react.portal"),vl=Symbol.for("react.fragment"),Sl=Symbol.for("react.strict_mode"),kl=Symbol.for("react.profiler"),wl=Symbol.for("react.consumer"),zl=Symbol.for("react.context"),xl=Symbol.for("react.forward_ref"),El=Symbol.for("react.suspense"),Cl=Symbol.for("react.suspense_list"),Pl=Symbol.for("react.memo"),_l=Symbol.for("react.lazy"),Tl=Symbol.for("react.activity"),Rl=Symbol.for("react.memo_cache_sentinel"),Nl=Symbol.iterator,Ll=Symbol.for("react.client.reference"),Ul=Array.isArray,Dl=pl.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Il=n.getPublicInstance,Fl=n.getRootHostContext,jl=n.getChildHostContext,Al=n.prepareForCommit,Hl=n.resetAfterCommit,Ol=n.createInstance,Ml=n.appendInitialChild,Wl=n.finalizeInitialChildren,Ql=n.shouldSetTextContent,Bl=n.createTextInstance,$l=null,Vl=null,ql=n.noTimeout,Yl=!0,Gl=null,Jl=null,Kl=n.setCurrentUpdatePriority,Xl=n.getCurrentUpdatePriority,Zl=n.resolveUpdatePriority;n.trackSchedulerEvent,n.resolveEventType,n.resolveEventTimeStamp;var ea=n.shouldAttemptEagerTransition,na=n.detachDeletedInstance;n.requestPostPaintCallback;var ta=n.maySuspendCommit,ra=null,la=null,aa=null,oa=null,ua=null,ia=null,sa=null,ca=null,da=null,fa=n.appendChild,pa=n.appendChildToContainer,ma=n.commitTextUpdate,ha=null,ga=n.commitUpdate,ya=n.insertBefore,ba=null,va=n.removeChild,Sa=n.removeChildFromContainer,ka=n.resetTextContent,wa=null,za=null,xa=null,Ea=null,Ca=n.clearContainer,Pa=null,_a=null,Ta=null,Ra=null,Na=null,La=null,Ua=null,Da=null,Ia=null,Fa=null,ja=null,Aa=null,Ha=null,Oa=[],Ma=-1,Wa={},Qa=Math.clz32?Math.clz32:function(e){return 0==(e>>>=0)?32:31-(Ba(e)/$a|0)|0},Ba=Math.log,$a=Math.LN2,Va=256,qa=262144,Ya=4194304,Ga=ml.unstable_scheduleCallback,Ja=ml.unstable_cancelCallback,Ka=ml.unstable_shouldYield,Xa=ml.unstable_requestPaint,Za=ml.unstable_now,eo=ml.unstable_ImmediatePriority,no=ml.unstable_UserBlockingPriority,to=ml.unstable_NormalPriority,ro=ml.unstable_IdlePriority,lo=ml.log,ao=ml.unstable_setDisableYieldValue,oo=null,uo="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n};"function"==typeof reportError&&reportError;var io,so,co=Object.prototype.hasOwnProperty,fo=!1,po=new WeakMap,mo=[],ho=0,go=null,yo=[],bo=0,vo=null,So=o(null),ko=o(null),wo=o(null),zo=o(null),xo=!1,Eo=null;Error(r(519));var Co=o(null),Po=null,_o=null,To="undefined"!=typeof AbortController?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(n,t){e.push(t)}};this.abort=function(){n.aborted=!0,e.forEach((function(e){return e()}))}},Ro=ml.unstable_scheduleCallback,No=ml.unstable_NormalPriority,Lo={$$typeof:zl,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},Uo=null,Do=null,Io=!1,Fo=!1,jo=!1,Ao=0,Ho=null,Oo=0,Mo=0,Wo=null,Qo=Dl.S;Dl.S=function(e,n){ui=Za(),"object"==typeof n&&null!==n&&"function"==typeof n.then&&function(e,n){if(null===Ho){var t=Ho=[];Oo=0,Mo=X(),Wo={status:"pending",value:void 0,then:function(e){t.push(e)}}}Oo++,n.then(Z,Z)}(0,n),null!==Qo&&Qo(e,n)};var Bo=o(null),$o=Error(r(460)),Vo=Error(r(474)),qo=Error(r(542)),Yo={then:function(){}},Go=null,Jo=null,Ko=0,Xo=fe(!0),Zo=fe(!1),eu=[],nu=0,tu=0,ru=!1,lu=!1,au=o(null),ou=o(0),uu=o(null),iu=null,su=o(0),cu=0,du=null,fu=null,pu=null,mu=!1,hu=!1,gu=!1,yu=0,bu=0,vu=null,Su=0,ku={readContext:O,use:Je,useCallback:Ae,useContext:Ae,useEffect:Ae,useImperativeHandle:Ae,useLayoutEffect:Ae,useInsertionEffect:Ae,useMemo:Ae,useReducer:Ae,useRef:Ae,useState:Ae,useDebugValue:Ae,useDeferredValue:Ae,useTransition:Ae,useSyncExternalStore:Ae,useId:Ae,useHostTransitionStatus:Ae,useFormState:Ae,useActionState:Ae,useOptimistic:Ae,useMemoCache:Ae,useCacheRefresh:Ae};ku.useEffectEvent=Ae;var wu={readContext:O,use:Je,useCallback:function(e,n){return qe().memoizedState=[e,void 0===n?null:n],e},useContext:O,useEffect:Pn,useImperativeHandle:function(e,n,t){t=null!=t?t.concat([e]):null,En(4194308,4,Ln.bind(null,n,e),t)},useLayoutEffect:function(e,n){return En(4194308,4,e,n)},useInsertionEffect:function(e,n){En(4,2,e,n)},useMemo:function(e,n){var t=qe();n=void 0===n?null:n;var r=e();if(gu){k(!0);try{e()}finally{k(!1)}}return t.memoizedState=[r,n],r},useReducer:function(e,n,t){var r=qe();if(void 0!==t){var l=t(n);if(gu){k(!0);try{t(n)}finally{k(!1)}}}else l=n;return r.memoizedState=r.baseState=l,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:l},r.queue=e,e=e.dispatch=Bn.bind(null,du,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},qe().memoizedState=e},useState:function(e){var n=(e=sn(e)).queue,t=$n.bind(null,du,n);return n.dispatch=t,[e.memoizedState,t]},useDebugValue:Dn,useDeferredValue:function(e,n){return jn(qe(),e,n)},useTransition:function(){var e=sn(!1);return e=Hn.bind(null,du,e.queue,!0,!1),qe().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,t){var l=du,a=qe();if(t=n(),null===Wu)throw Error(r(349));0!=(127&Bu)||rn(l,n,t),a.memoizedState=t;var o={value:t,getSnapshot:n};return a.queue=o,Pn(an.bind(null,l,o,e),[e]),l.flags|=2048,zn(9,{destroy:void 0},ln.bind(null,l,o,t,n),null),t},useId:function(){var e=qe(),n=Wu.identifierPrefix;return n="_"+n+"r_"+(Su++).toString(32)+"_",e.memoizedState=n},useHostTransitionStatus:On,useFormState:bn,useActionState:bn,useOptimistic:function(e){var n=qe();n.memoizedState=n.baseState=e;var t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=t,n=qn.bind(null,du,!0,t),t.dispatch=n,[e,n]},useMemoCache:Ke,useCacheRefresh:function(){return qe().memoizedState=Qn.bind(null,du)},useEffectEvent:function(e){var n=qe(),t={impl:e};return n.memoizedState=t,function(){if(0!=(2&Mu))throw Error(r(440));return t.impl.apply(void 0,arguments)}}},zu={readContext:O,use:Je,useCallback:In,useContext:O,useEffect:_n,useImperativeHandle:Un,useInsertionEffect:Rn,useLayoutEffect:Nn,useMemo:Fn,useReducer:Ze,useRef:xn,useState:function(){return Ze(Xe)},useDebugValue:Dn,useDeferredValue:function(e,n){return An(Ye(),fu.memoizedState,e,n)},useTransition:function(){var e=Ze(Xe)[0],n=Ye().memoizedState;return["boolean"==typeof e?e:Ge(e),n]},useSyncExternalStore:tn,useId:Mn,useHostTransitionStatus:On,useFormState:vn,useActionState:vn,useOptimistic:function(e,n){return cn(Ye(),0,e,n)},useMemoCache:Ke,useCacheRefresh:Wn};zu.useEffectEvent=Tn;var xu={readContext:O,use:Je,useCallback:In,useContext:O,useEffect:_n,useImperativeHandle:Un,useInsertionEffect:Rn,useLayoutEffect:Nn,useMemo:Fn,useReducer:nn,useRef:xn,useState:function(){return nn(Xe)},useDebugValue:Dn,useDeferredValue:function(e,n){var t=Ye();return null===fu?jn(t,e,n):An(t,fu.memoizedState,e,n)},useTransition:function(){var e=nn(Xe)[0],n=Ye().memoizedState;return["boolean"==typeof e?e:Ge(e),n]},useSyncExternalStore:tn,useId:Mn,useHostTransitionStatus:On,useFormState:wn,useActionState:wn,useOptimistic:function(e,n){var t=Ye();return null!==fu?cn(t,0,e,n):(t.baseState=e,[e,t.queue.dispatch])},useMemoCache:Ke,useCacheRefresh:Wn};xu.useEffectEvent=Tn;var Eu={enqueueSetState:function(e,n,t){e=e._reactInternals;var r=kr(),l=ke(r);l.payload=n,null!=t&&(l.callback=t),null!==(n=we(e,l,r))&&(zr(n,0,r),ze(n,e,r))},enqueueReplaceState:function(e,n,t){e=e._reactInternals;var r=kr(),l=ke(r);l.tag=1,l.payload=n,null!=t&&(l.callback=t),null!==(n=we(e,l,r))&&(zr(n,0,r),ze(n,e,r))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var t=kr(),r=ke(t);r.tag=2,null!=n&&(r.callback=n),null!==(n=we(e,r,t))&&(zr(n,0,t),ze(n,e,t))}},Cu=Error(r(461)),Pu=!1,_u={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},Tu=!1,Ru=!1,Nu=!1,Lu="function"==typeof WeakSet?WeakSet:Set,Uu=null,Du=null,Iu=!1,Fu=null,ju=8192,Au={getCacheForType:function(e){var n=O(Lo),t=n.data.get(e);return void 0===t&&(t=e(),n.data.set(e,t)),t},cacheSignal:function(){return O(Lo).controller.signal}};if("function"==typeof Symbol&&Symbol.for){var Hu=Symbol.for;Hu("selector.component"),Hu("selector.has_pseudo_class"),Hu("selector.role"),Hu("selector.test_id"),Hu("selector.text")}var Ou="function"==typeof WeakMap?WeakMap:Map,Mu=0,Wu=null,Qu=null,Bu=0,$u=0,Vu=null,qu=!1,Yu=!1,Gu=!1,Ju=0,Ku=0,Xu=0,Zu=0,ei=0,ni=0,ti=0,ri=null,li=null,ai=!1,oi=0,ui=0,ii=1/0,si=null,ci=null,di=0,fi=null,pi=null,mi=0,hi=0,gi=null,yi=null,bi=0,vi=null;return fl.createContainer=function(e,n,r,l,a,o,u,i,s,c){return function(e,n,r,l,a,o,u,i,s,c,d,f){return e=new cl(e,n,r,u,s,c,d,f,null),n=1,!0===o&&(n|=24),o=t(3,null,null,n),e.current=o,o.stateNode=e,(n=Q()).refCount++,e.pooledCache=n,n.refCount++,o.memoizedState={element:l,isDehydrated:r,cache:n},ve(o),e}(e,n,!1,null,0,l,o,0,u,i,s,c)},fl.flushSyncWork=function(){return 0!=(6&Mu)||(q(0),!1)},fl.updateContainer=function(e,n,t,r){var l=n.current,a=kr();return dl(l,a,e,n,t,r),a},fl.updateContainerSync=function(e,n,t,r){return dl(n.current,2,e,n,t,r),2},fl},s.exports.default=s.exports,Object.defineProperty(s.exports,"__esModule",{value:!0})),o.exports):a.exports=function(){return i||(i=1,n=c,"production"!==process.env.NODE_ENV&&(n.exports=function(n){function t(e,n,t,r){return new eo(e,n,t,r)}function r(){console.error("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://react.dev/link/rules-of-hooks")}function l(){console.error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().")}function a(){}function o(e){var n=[];return e.forEach((function(e){n.push(e)})),n.sort().join(", ")}function i(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=No&&e[No]||e["@@iterator"])?e:null}function s(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===Lo?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case vo:return"Fragment";case ko:return"Profiler";case So:return"StrictMode";case Eo:return"Suspense";case Co:return"SuspenseList";case To:return"Activity"}if("object"==typeof e)switch("number"==typeof e.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case bo:return"Portal";case zo:return e.displayName||"Context";case wo:return(e._context.displayName||"Context")+".Consumer";case xo:var n=e.render;return(e=e.displayName)||(e=""!==(e=n.displayName||n.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case Po:return null!==(n=e.displayName||null)?n:s(e.type)||"Memo";case _o:n=e._payload,e=e._init;try{return s(e(n))}catch(e){}}return null}function c(e){var n=e.type;switch(e.tag){case 31:return"Activity";case 24:return"Cache";case 9:return(n._context.displayName||"Context")+".Consumer";case 10:return n.displayName||"Context";case 18:return"DehydratedFragment";case 11:return e=(e=n.render).displayName||e.name||"",n.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 26:case 27:case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return s(n);case 8:return n===So?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 14:case 15:if("function"==typeof n)return n.displayName||n.name||null;if("string"==typeof n)return n;break;case 29:if(null!=(n=e._debugInfo))for(var t=n.length-1;0<=t;t--)if("string"==typeof n[t].name)return n[t].name;if(null!==e.return)return c(e.return)}return null}function d(e){return{current:e}}function f(e,n){0>Vu?console.error("Unexpected pop."):(n!==$u[Vu]&&console.error("Unexpected Fiber popped."),e.current=Bu[Vu],Bu[Vu]=null,$u[Vu]=null,Vu--)}function p(e,n,t){Vu++,Bu[Vu]=e.current,$u[Vu]=t,e.current=n}function m(e){var n=42&e;if(0!==n)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return console.error("Should have found matching lanes. This is a bug in React."),e}}function h(e,n,t){var r=e.pendingLanes;if(0===r)return 0;var l=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var u=134217727&r;return 0!==u?0!=(r=u&~a)?l=m(r):0!=(o&=u)?l=m(o):t||0!=(t=u&~e)&&(l=m(t)):0!=(u=r&~a)?l=m(u):0!==o?l=m(o):t||0!=(t=r&~e)&&(l=m(t)),0===l?0:0!==n&&n!==l&&0==(n&a)&&((a=l&-l)>=(t=n&-n)||32===a&&0!=(4194048&t))?n:l}function g(e,n){return 0==(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)}function y(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return console.error("Should have found matching lanes. This is a bug in React."),-1}}function b(){var e=Zu;return 0==(62914560&(Zu<<=1))&&(Zu=4194304),e}function v(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function S(e,n){e.pendingLanes|=n,268435456!==n&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function k(e,n,t){e.pendingLanes|=n,e.suspendedLanes&=~n;var r=31-Yu(n);e.entangledLanes|=n,e.entanglements[r]=1073741824|e.entanglements[r]|261930&t}function w(e,n){var t=e.entangledLanes|=n;for(e=e.entanglements;t;){var r=31-Yu(t),l=1<";break}if(3>r||1===i&&"children"===u[0]&&null==o){n="<"+a+" … />";break}for(var c in t.push([l+"  ".repeat(r)+e,"<"+a]),null!==o&&T("key",o,t,r+1,l),e=!1,n)"children"===c?null!=n.children&&(!Uo(n.children)||0…":"/>"])}if("Array"===(a=(a=Object.prototype.toString.call(n)).slice(8,a.length-1))){if(c=function(e){for(var n=0,t=0;ta)return void((t=t[a])[1]="Promise<"+(t[1]||"Object")+">")}else if("rejected"===n.status&&(a=t.length,T(e,n.reason,t,r,l),t.length>a))return void((t=t[a])[1]="Rejected Promise<"+t[1]+">");return void t.push(["  ".repeat(r)+e,"Promise"])}return"Object"===a&&(c=Object.getPrototypeOf(n))&&"function"==typeof c.constructor&&(a=c.constructor.name),t.push([l+"  ".repeat(r)+e,"Object"===a?3>r?"":"…":a]),void(3>r&&_(n,t,r+1,l));case"function":n=""===n.name?"() => {}":n.name+"() {}";break;case"string":n="This object has been omitted by React in the console log to avoid sending too much data from the server. Try logging smaller or more specific objects."===n?"…":JSON.stringify(n);break;case"undefined":n="undefined";break;case"boolean":n=n?"true":"false";break;default:n=String(n)}t.push([l+"  ".repeat(r)+e,n])}function R(e,n,t,r){var l=!0;for(o in e)o in n||(t.push(["– "+"  ".repeat(r)+o,"…"]),l=!1);for(var a in n)if(a in e){var o=e[a],u=n[a];if(o!==u){if(0===r&&"children"===a)l="  ".repeat(r)+a,t.push(["– "+l,"…"],["+ "+l,"…"]);else{if(!(3<=r))if("object"==typeof o&&"object"==typeof u&&null!==o&&null!==u&&o.$$typeof===u.$$typeof)if(u.$$typeof===yo){if(o.type===u.type&&o.key===u.key){o=s(u.type)||"…",l="  ".repeat(r)+a,o="<"+o+" … />",t.push(["– "+l,o],["+ "+l,o]),l=!1;continue}}else{var i=Object.prototype.toString.call(o),c=Object.prototype.toString.call(u);if(i===c&&("[object Object]"===c||"[object Array]"===c)){i=["  "+"  ".repeat(r)+a,"[object Array]"===c?"Array":""],t.push(i),c=t.length,R(o,u,t,r+1)?c===t.length&&(i[1]="Referentially unequal but deeply equal objects. Consider memoization."):l=!1;continue}}else if("function"==typeof o&&"function"==typeof u&&o.name===u.name&&o.length===u.length&&(i=Function.prototype.toString.call(o))===(c=Function.prototype.toString.call(u))){o=""===u.name?"() => {}":u.name+"() {}",t.push(["  "+"  ".repeat(r)+a,o+" Referentially unequal function closure. Consider memoization."]);continue}T(a,o,t,r,"– "),T(a,u,t,r,"+ ")}l=!1}}else t.push(["+ "+"  ".repeat(r)+a,"…"]),l=!1;return l}function N(e){Pi=63&e?"Blocking":64&e?"Gesture":4194176&e?"Transition":62914560&e?"Suspense":2080374784&e?"Idle":"Other"}function L(e,n,t,r){Ci&&(Ri.start=n,Ri.end=t,Ti.color="warning",Ti.tooltipText=r,Ti.properties=null,(e=e._debugTask)?e.run(performance.measure.bind(performance,r,Ri)):performance.measure(r,Ri))}function U(e,n,t){L(e,n,t,"Reconnect")}function D(e,n,t,r,l){var a=c(e);if(null!==a&&Ci){var o=e.alternate,u=e.actualDuration;if(null===o||o.child!==e.child)for(var i=e.child;null!==i;i=i.sibling)u-=i.actualDuration;r=.5>u?r?"tertiary-light":"primary-light":10>u?r?"tertiary":"primary":100>u?r?"tertiary-dark":"primary-dark":"error";var s=e.memoizedProps;u=e._debugTask,null!==s&&null!==o&&o.memoizedProps!==s?(i=[Ni],s=R(o.memoizedProps,s,i,0),1r?"secondary-light":100>r?"secondary":500>r?"secondary-dark":"error",(e=e._debugTask)?e.run(console.timeStamp.bind(console,a,n,t,"Components ⚛",void 0,l)):console.timeStamp(a,n,t,"Components ⚛",void 0,l))}function j(e,n,t,r){!Ci||n<=e||(t=(738197653&t)===t?"tertiary-dark":"primary-dark",r?r.run(console.timeStamp.bind(console,"Prewarm",e,n,Pi,"Scheduler ⚛",t)):console.timeStamp("Prewarm",e,n,Pi,"Scheduler ⚛",t))}function A(e,n,t,r){!Ci||n<=e||(t=(738197653&t)===t?"tertiary-dark":"primary-dark",r?r.run(console.timeStamp.bind(console,"Suspended",e,n,Pi,"Scheduler ⚛",t)):console.timeStamp("Suspended",e,n,Pi,"Scheduler ⚛",t))}function H(e,n,t,r){!Ci||n<=e||(r?r.run(console.timeStamp.bind(console,"Errored",e,n,Pi,"Scheduler ⚛","error")):console.timeStamp("Errored",e,n,Pi,"Scheduler ⚛","error"))}function O(e,n,t,r,l){if(Ci&&!(n<=e)){for(var a=[],o=0;o)":-1--o||s[a]!==c[o]){var d="\n"+s[a].replace(" at new "," at ");return e.displayName&&d.includes("")&&(d=d.replace("",e.displayName)),"function"==typeof e&&ji.set(e,d),d}}while(1<=a&&0<=o);break}}}finally{Fi=!1,Do.H=t,function(){if(0==--Ui){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:ho({},e,{value:bi}),info:ho({},e,{value:vi}),warn:ho({},e,{value:Si}),error:ho({},e,{value:ki}),group:ho({},e,{value:wi}),groupCollapsed:ho({},e,{value:zi}),groupEnd:ho({},e,{value:xi})})}0>Ui&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=r}return s=(s=e?e.displayName||e.name:"")?Q(s):"","function"==typeof e&&ji.set(e,s),s}function $(e,n){switch(e.tag){case 26:case 27:case 5:return Q(e.type);case 16:return Q("Lazy");case 13:return e.child!==n&&null!==n?Q("Suspense Fallback"):Q("Suspense");case 19:return Q("SuspenseList");case 0:case 15:return B(e.type,!1);case 11:return B(e.type.render,!1);case 1:return B(e.type,!0);case 31:return Q("Activity");default:return""}}function V(e){try{var n="",t=null;do{n+=$(e,t);var r=e._debugInfo;if(r)for(var l=r.length-1;0<=l;l--){var a=r[l];if("string"==typeof a.name){var o=n;e:{var u=a.name,i=a.env,s=a.debugLocation;if(null!=s){var c=W(s),d=c.lastIndexOf("\n"),f=-1===d?c:c.slice(d+1);if(-1!==f.indexOf(u)){var p="\n"+f;break e}}p=Q(u+(i?" ["+i+"]":""))}n=o+p}}t=e,e=e.return}while(e);return n}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}function q(e){return(e=e?e.displayName||e.name:"")?Q(e):""}function Y(e,n){if("object"==typeof e&&null!==e){var t=Ai.get(e);return void 0!==t?t:(n={value:e,source:n,stack:V(n)},Ai.set(e,n),n)}return{value:e,source:n,stack:V(n)}}function G(e){for(;e===Mi;)Mi=Hi[--Oi],Hi[Oi]=null,Wi=Hi[--Oi],Hi[Oi]=null;for(;e===$i;)$i=Qi[--Bi],Qi[Bi]=null,qi=Qi[--Bi],Qi[Bi]=null,Vi=Qi[--Bi],Qi[Bi]=null}function J(){console.error("Expected to be hydrating. This is a bug in React. Please file an issue.")}function K(e){return null===e&&console.error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."),e}function X(e,n){p(Ji,n,e),p(Gi,e,e),p(Yi,null,e),n=Fo(n),f(Yi,e),p(Yi,n,e)}function Z(e){f(Yi,e),f(Gi,e),f(Ji,e)}function ee(){return K(Yi.current)}function ne(e){null!==e.memoizedState&&p(Ki,e,e);var n=K(Yi.current),t=jo(n,e.type);n!==t&&(p(Gi,e,e),p(Yi,t,e))}function te(e){Gi.current===e&&(f(Yi,e),f(Gi,e)),Ki.current===e&&(f(Ki,e),mu._currentValue2=pu)}function re(){if(null===Xi)return"";var e=Xi;try{var n="";switch(6===e.tag&&(e=e.return),e.tag){case 26:case 27:case 5:n+=Q(e.type);break;case 13:n+=Q("Suspense");break;case 19:n+=Q("SuspenseList");break;case 31:n+=Q("Activity");break;case 30:case 0:case 15:case 1:e._debugOwner||""!==n||(n+=q(e.type));break;case 11:e._debugOwner||""!==n||(n+=q(e.type.render))}for(;e;)if("number"==typeof e.tag){var t=e;e=t._debugOwner;var r=t._debugStack;if(e&&r){var l=W(r);""!==l&&(n+="\n"+l)}}else{if(null==e.debugStack)break;var a=e.debugStack;(e=e.owner)&&a&&(n+="\n"+W(a))}var o=n}catch(e){o="\nError generating stack: "+e.message+"\n"+e.stack}return o}function le(e,n,t,r,l,a,o){var u=Xi;ae(e);try{return null!==e&&e._debugTask?e._debugTask.run(n.bind(null,t,r,l,a,o)):n(t,r,l,a,o)}finally{ae(u)}throw Error("runWithFiberInDEV should never be called in production. This is a bug in React.")}function ae(e){Do.getCurrentStack=null===e?null:re,Zi=!1,Xi=e}function oe(){var e=ns;return null!==e&&(null===Ep?Ep=e:Ep.push.apply(Ep,e),ns=null),e}function ue(){us=os=null,is=!1}function ie(e,n,t){p(rs,n._currentValue2,e),n._currentValue2=t,p(ls,n._currentRenderer2,e),void 0!==n._currentRenderer2&&null!==n._currentRenderer2&&n._currentRenderer2!==as&&console.error("Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."),n._currentRenderer2=as}function se(e,n){var t=rs.current;e._currentValue2=t,t=ls.current,f(ls,n),e._currentRenderer2=t,f(rs,n)}function ce(e,n,t){for(;null!==e;){var r=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,null!==r&&(r.childLanes|=n)):null!==r&&(r.childLanes&n)!==n&&(r.childLanes|=n),e===t)break;e=e.return}e!==t&&console.error("Expected to find the propagation root when scheduling context work. This error is likely caused by a bug in React. Please file an issue.")}function de(e,n,t,r){var l=e.child;for(null!==l&&(l.return=e);null!==l;){var a=l.dependencies;if(null!==a){var o=l.child;a=a.firstContext;e:for(;null!==a;){var u=a;a=l;for(var i=0;ie.refCount&&console.warn("A cache instance was released after it was already freed. This likely indicates a bug in React."),0===e.refCount&&cs(ds,(function(){e.controller.abort()}))}function ke(e,n,t){0!=(127&e)?0>Ps&&(Ps=ps(),_s=ms(n),Rs=n,null!=t&&(Ns=c(t)),(Xf&(Qf|Bf))!==Wf&&(Es=!0,Ts=1),e=tu(),n=nu(),e!==Ds||n!==Us?Ds=-1.1:null!==n&&(Ts=1),Ls=e,Us=n):0!=(4194048&e)&&0>As&&(As=ps(),Os=ms(n),Ms=n,null!=t&&(Ws=c(t)),0>js)&&(e=tu(),n=nu(),e===$s&&n===Bs||($s=-1.1),Qs=e,Bs=n)}function we(){var e=Ss;return Ss=0,e}function ze(e){var n=Ss;return Ss=e,n}function xe(e){var n=Ss;return Ss+=e,n}function Ee(){zs=ws=-1.1}function Ce(){var e=ws;return ws=-1.1,e}function Pe(e){0<=e&&(ws=e)}function _e(){var e=ks;return ks=-0,e}function Te(e){0<=e&&(ks=e)}function Re(){var e=xs;return xs=null,e}function Ne(){var e=Es;return Es=!1,e}function Le(e){vs=ps(),0>e.actualStartTime&&(e.actualStartTime=vs)}function Ue(e){if(0<=vs){var n=ps()-vs;e.actualDuration+=n,e.selfBaseDuration=n,vs=-1}}function De(e){if(0<=vs){var n=ps()-vs;e.actualDuration+=n,vs=-1}}function Ie(){if(0<=vs){var e=ps(),n=e-vs;vs=-1,Ss+=n,ks+=n,zs=e}}function Fe(e){null===xs&&(xs=[]),xs.push(e),null===bs&&(bs=[]),bs.push(e)}function je(){vs=ps(),0>ws&&(ws=vs)}function Ae(e){for(var n=e.child;n;)e.actualDuration+=n.actualDuration,n=n.sibling}function He(){}function Oe(e){e!==Zs&&null===e.next&&(null===Zs?Xs=Zs=e:Zs=Zs.next=e),tc=!0,null!==Do.actQueue?nc||(nc=!0,Ye()):ec||(ec=!0,Ye())}function Me(e,n){if(!rc&&tc){rc=!0;do{for(var t=!1,r=Xs;null!==r;){if(0!==e){var l=r.pendingLanes;if(0===l)var a=0;else{var o=r.suspendedLanes,u=r.pingedLanes;a=(1<<31-Yu(42|e)+1)-1,a=201326741&(a&=l&~(o&~u))?201326741&a|1:a?2|a:0}0!==a&&(t=!0,Ve(r,a))}else a=np,0==(3&(a=h(r,r===Zf?a:0,null!==r.cancelPendingCommit||r.timeoutHandle!==qo)))||g(r,a)||(t=!0,Ve(r,a));r=r.next}}while(t);rc=!1}}function We(){eu(),Qe()}function Qe(){tc=nc=ec=!1;var e=0;0!==lc&&ru()&&(e=lc);for(var n=li(),t=null,r=Xs;null!==r;){var l=r.next,a=Be(r,n);0===a?(r.next=null,null===t?Xs=l:t.next=l,null===l&&(Zs=t)):(t=r,(0!==e||0!=(3&a))&&(tc=!0)),r=l}$p!==Hp&&$p!==Bp||Me(e),0!==lc&&(lc=0)}function Be(e,n){for(var t=e.suspendedLanes,r=e.pingedLanes,l=e.expirationTimes,a=-62914561&e.pendingLanes;0 from render. Or maybe you meant to call this function rather than return it.\n root.render(%s)",n,n,n):console.error("Functions are not valid as a React child. This may happen if you return %s instead of <%s /> from render. Or maybe you meant to call this function rather than return it.\n <%s>{%s}",n,n,t,n,t))}function hn(e,n){var t=un();null!==t?t.run(mn.bind(null,e,n)):mn(e,n)}function gn(e,n){var t=c(e)||"Component";Zc[t]||(Zc[t]=!0,n=String(n),3===e.tag?console.error("Symbols are not valid as a React child.\n root.render(%s)",n):console.error("Symbols are not valid as a React child.\n <%s>%s",t,n,t))}function yn(e,n){var t=un();null!==t?t.run(gn.bind(null,e,n)):gn(e,n)}function bn(e){function n(n,t){if(e){var r=n.deletions;null===r?(n.deletions=[t],n.flags|=16):r.push(t)}}function r(t,r){if(!e)return null;for(;null!==r;)n(t,r),r=r.sibling;return null}function l(e){for(var n=new Map;null!==e;)null!==e.key?n.set(e.key,e):n.set(e.index,e),e=e.sibling;return n}function o(e,n){return(e=to(e,n)).index=0,e.sibling=null,e}function u(n,t,r){return n.index=r,e?null!==(r=n.alternate)?(r=r.index)p?(b=f,f=null):b=f.sibling;var v=h(t,f,o[p],i);if(null===v){null===f&&(f=b);break}s=y(t,v,o[p],s),e&&f&&null===v.alternate&&n(t,f),a=u(v,a,p),null===d?c=v:d.sibling=v,d=v,f=b}if(p===o.length)return r(t,f),c;if(null===f){for(;pf?(p=d,d=null):p=d.sibling;var S=h(t,d,v.value,i);if(null===S){null===d&&(d=p);break}b=y(t,S,v.value,b),e&&d&&null===S.alternate&&n(t,d),a=u(S,a,f),null===c?s=S:c.sibling=S,c=S,d=p}if(v.done)return r(t,d),s;if(null===d){for(;!v.done;f++,v=o.next())null!==(d=m(t,v.value,i))&&(b=y(t,d,v.value,b),a=u(d,a,f),null===c?s=d:c.sibling=d,c=d);return s}for(d=l(d);!v.done;f++,v=o.next())null!==(p=g(d,t,f,v.value,i))&&(b=y(t,p,v.value,b),e&&null!==p.alternate&&d.delete(null===p.key?f:p.key),a=u(p,a,f),null===c?s=p:c.sibling=p,c=p);return e&&d.forEach((function(e){return n(t,e)})),s}(t,a,v,d),Gc=f,t}if("function"==typeof c.then)return f=on(c._debugInfo),t=b(t,a,cn(c),d),Gc=f,t;if(c.$$typeof===zo)return b(t,a,ge(t,c),d);pn(t,c)}return"string"==typeof c&&""!==c||"number"==typeof c||"bigint"==typeof c?(f=""+c,null!==a&&6===a.tag?(r(t,a.sibling),(d=o(a,f)).return=t,t=d):(r(t,a),(d=uo(f,t.mode,d)).return=t,d._debugOwner=t,d._debugTask=t._debugTask,d._debugInfo=Gc,t=d),s(t)):("function"==typeof c&&hn(t,c),"symbol"==typeof c&&yn(t,c),r(t,a))}return function(e,n,r,l){var a=Gc;Gc=null;try{Yc=0;var o=b(e,n,r,l);return qc=null,o}catch(n){if(n===Mc||n===Qc)throw n;var u=t(29,n,null,e.mode);u.lanes=l,u.return=e;var i=u._debugInfo=Gc;if(u._debugOwner=e._debugOwner,u._debugTask=e._debugTask,null!=i)for(var s=i.length-1;0<=s;s--)if("string"==typeof i[s].stack){u._debugOwner=i[s],u._debugTask=i[s].debugTask;break}return u}finally{Gc=a}}}function vn(e,n){var t=Uo(e);return e=!t&&"function"==typeof i(e),!t&&!e||(t=t?"array":"iterable",console.error("A nested %s was passed to row #%s in . Wrap it in an additional SuspenseList to configure its revealOrder: ... {%s} ... ",t,n,t),!1)}function Sn(){for(var e=od,n=ud=od=0;ntm)throw im=rm=0,sm=lm=null,Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");im>um&&(im=0,sm=null,console.error("Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.")),null===e.alternate&&0!=(4098&e.flags)&&Xa(e);for(var n=e,t=n.return;null!==t;)null===n.alternate&&0!=(4098&n.flags)&&Xa(e),t=(n=t).return;return 3===n.tag?n.stateNode:null}function Cn(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Pn(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function _n(e){return{lane:e,tag:id,payload:null,callback:null,next:null}}function Tn(e,n,t){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,md===r&&!pd){var l=c(e);console.error("An update (setState, replaceState, or forceUpdate) was scheduled from inside an update function. Update functions should be pure, with zero side-effects. Consider using componentDidUpdate or a callback.\n\nPlease update the following component: %s",l),pd=!0}return(Xf&Qf)!==Wf?(null===(l=r.pending)?n.next=n:(n.next=l.next,l.next=n),r.pending=n,n=En(e),xn(e,null,t),n):(kn(e,r,n,t),En(e))}function Rn(e,n,t){if(null!==(n=n.updateQueue)&&(n=n.shared,0!=(4194048&t))){var r=n.lanes;t|=r&=e.pendingLanes,n.lanes=t,w(e,t)}}function Nn(e,n){var t=e.updateQueue,r=e.alternate;if(null!==r&&t===(r=r.updateQueue)){var l=null,a=null;if(null!==(t=t.firstBaseUpdate)){do{var o={lane:t.lane,tag:t.tag,payload:t.payload,callback:null,next:null};null===a?l=a=o:a=a.next=o,t=t.next}while(null!==t);null===a?l=a=n:a=a.next=n}else l=a=n;return t={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},void(e.updateQueue=t)}null===(e=t.lastBaseUpdate)?t.firstBaseUpdate=n:e.next=n,t.lastBaseUpdate=n}function Ln(){if(hd&&null!==sc)throw sc}function Un(e,n,t,r){hd=!1;var l=e.updateQueue;fd=!1,md=l.shared;var a=l.firstBaseUpdate,o=l.lastBaseUpdate,u=l.shared.pending;if(null!==u){l.shared.pending=null;var i=u,s=i.next;i.next=null,null===o?a=s:o.next=s,o=i;var c=e.alternate;null!==c&&(u=(c=c.updateQueue).lastBaseUpdate)!==o&&(null===u?c.firstBaseUpdate=s:u.next=s,c.lastBaseUpdate=i)}if(null!==a){var d=l.baseState;for(o=0,c=s=i=null,u=a;;){var f=-536870913&u.lane,p=f!==u.lane;if(p?(np&f)===f:(r&f)===f){0!==f&&f===ic&&(hd=!0),null!==c&&(c=c.next={lane:0,tag:u.tag,payload:u.payload,callback:null,next:null});e:{f=e;var m=u,h=n,g=t;switch(m.tag){case sd:if("function"==typeof(m=m.payload)){is=!0;var y=m.call(g,d,h);if(8&f.mode){P(!0);try{m.call(g,d,h)}finally{P(!1)}}is=!1,d=y;break e}d=m;break e;case dd:f.flags=-65537&f.flags|128;case id:if("function"==typeof(y=m.payload)){if(is=!0,m=y.call(g,d,h),8&f.mode){P(!0);try{y.call(g,d,h)}finally{P(!1)}}is=!1}else m=y;if(null==m)break e;d=ho({},d,m);break e;case cd:fd=!0}}null!==(f=u.callback)&&(e.flags|=64,p&&(e.flags|=8192),null===(p=l.callbacks)?l.callbacks=[f]:p.push(f))}else p={lane:f,tag:u.tag,payload:u.payload,callback:u.callback,next:null},null===c?(s=c=p,i=d):c=c.next=p,o|=f;if(null===(u=u.next)){if(null===(u=l.shared.pending))break;u=(p=u).next,p.next=null,l.lastBaseUpdate=p,l.shared.pending=null}}null===c&&(i=d),l.baseState=i,l.firstBaseUpdate=s,l.lastBaseUpdate=c,null===a&&(l.shared.lanes=0),vp|=o,e.lanes=o,e.memoizedState=d}md=null}function Dn(e,n){if("function"!=typeof e)throw Error("Invalid argument passed as callback. Expected a function. Instead received: "+e);e.call(n)}function In(e,n){var t=e.shared.hiddenCallbacks;if(null!==t)for(e.shared.hiddenCallbacks=null,e=0;el.length;)l+=" ";t+=l+=a+"\n"}console.error("React has detected a change in the order of Hooks called by %s. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://react.dev/link/rules-of-hooks\n\n Previous render Next render\n ------------------------------------------------------\n%s ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",n,t)}}}function Yn(e){null==e||Uo(e)||console.error("%s received a final argument that is not an array (instead, received `%s`). When specified, the final argument must be an array.",Bd,typeof e)}function Gn(){var e=c(Ud);Nd.has(e)||(Nd.add(e),console.error("ReactDOM.useFormState has been renamed to React.useActionState. Please update %s to use React.useActionState.",e))}function Jn(){throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.")}function Kn(e,n){if(qd)return!1;if(null===n)return console.error("%s received a final argument during this render, but not during the previous render. Even though the final argument is optional, its type cannot change between renders.",Bd),!1;e.length!==n.length&&console.error("The final argument passed to %s changed size between renders. The order and size of this array must remain constant.\n\nPrevious: %s\nIncoming: %s",Bd,"["+n.join(", ")+"]","["+e.join(", ")+"]");for(var t=0;t"))),n.memoizedState=null,n.updateQueue=null,n.lanes=0,Do.H=null!==e&&null!==e.memoizedState?Kd:null!==$d?Jd:Gd,Ad=a=(8&n.mode)!==ts;var o=xc(t,r,l);if(Ad=!1,jd&&(o=et(n,t,r,l)),a){P(!0);try{o=et(n,t,r,l)}finally{P(!1)}}return Zn(e,n),o}function Zn(e,n){n._debugHookTypes=$d,null===n.dependencies?null!==Md&&(n.dependencies={lanes:0,firstContext:null,_debugThenableState:Md}):n.dependencies._debugThenableState=Md,Do.H=Yd;var t=null!==Dd&&null!==Dd.next;if(Ld=0,$d=Bd=Id=Dd=Ud=null,Vd=-1,null!==e&&(65011712&e.flags)!=(65011712&n.flags)&&console.error("Internal React error: Expected static flag was missing. Please notify the React team."),Fd=!1,Od=0,Md=null,t)throw Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");null===e||gf||null!==(e=e.dependencies)&&pe(e)&&(gf=!0),Vc?(Vc=!1,e=!0):e=!1,e&&(n=c(n)||"Unknown",Td.has(n)||Rd.has(n)||(Td.add(n),console.error("`use` was called from inside a try/catch block. This is not allowed and can lead to unexpected behavior. To handle errors triggered by `use`, wrap your component in a error boundary.")))}function et(e,n,t,r){Ud=e;var l=0;do{if(jd&&(Md=null),Od=0,jd=!1,l>=Qd)throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");if(l+=1,qd=!1,Id=Dd=null,null!=e.updateQueue){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,null!=a.memoCache&&(a.memoCache.index=0)}Vd=-1,Do.H=Xd,a=xc(n,t,r)}while(jd);return a}function nt(){var e=Do.H,n=e.useState()[0];return n="function"==typeof n.then?ut(n):n,e=e.useState()[0],(null!==Dd?Dd.memoizedState:null)!==e&&(Ud.flags|=1024),n}function tt(){var e=0!==Hd;return Hd=0,e}function rt(e,n,t){n.updateQueue=e.updateQueue,n.flags=(16&n.mode)!==ts?-402655237&n.flags:-2053&n.flags,e.lanes&=~t}function lt(e){if(Fd){for(e=e.memoizedState;null!==e;){var n=e.queue;null!==n&&(n.pending=null),e=e.next}Fd=!1}Ld=0,$d=Id=Dd=Ud=null,Vd=-1,Bd=null,jd=!1,Od=Hd=0,Md=null}function at(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Id?Ud.memoizedState=Id=e:Id=Id.next=e,Id}function ot(){if(null===Dd){var e=Ud.alternate;e=null!==e?e.memoizedState:null}else e=Dd.next;var n=null===Id?Ud.memoizedState:Id.next;if(null!==n)Id=n,Dd=e;else{if(null===e){if(null===Ud.alternate)throw Error("Update hook called on initial render. This is likely a bug in React. Please file an issue.");throw Error("Rendered more hooks than during the previous render.")}e={memoizedState:(Dd=e).memoizedState,baseState:Dd.baseState,baseQueue:Dd.baseQueue,queue:Dd.queue,next:null},null===Id?Ud.memoizedState=Id=e:Id=Id.next=e}return Id}function ut(e){var n=Od;return Od+=1,null===Md&&(Md={didWarnAboutUncachedPromise:!1,thenables:[]}),e=tn(Md,e,n),n=Ud,null===(null===Id?n.memoizedState:Id.next)&&(n=n.alternate,Do.H=null!==n&&null!==n.memoizedState?Kd:Gd),e}function it(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return ut(e);if(e.$$typeof===zo)return he(e)}throw Error("An unsupported type was passed to use(): "+String(e))}function st(e){var n=null,t=Ud.updateQueue;if(null!==t&&(n=t.memoCache),null==n){var r=Ud.alternate;null!==r&&null!==(r=r.updateQueue)&&null!=(r=r.memoCache)&&(n={data:r.data.map((function(e){return e.slice()})),index:0})}if(null==n&&(n={data:[],index:0}),null===t&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Ud.updateQueue=t),t.memoCache=n,void 0===(t=n.data[n.index])||qd)for(t=n.data[n.index]=Array(e),r=0;ra?a:8);var o,u,i,s=Do.T,c={};c._updatedFibers=new Set,Do.T=c,br(e,!1,n,t);try{var d=l(),f=Do.S;null!==f&&f(c,d),null!==d&&"object"==typeof d&&"function"==typeof d.then?(Do.asyncTransitions++,d.then(or,or),yr(e,n,(o=r,u=[],i={status:"pending",value:null,reason:null,then:function(e){u.push(e)}},d.then((function(){i.status="fulfilled",i.value=o;for(var e=0;e doesn\'t accept a hidden prop. Use mode="hidden" instead.\n- \n+ ',!0===t?"hidden":!1===t?"hidden={false}":"hidden={...}",t?'mode="hidden"':'mode="visible"'),(n=Jr({mode:n.mode,children:n.children},e.mode)).ref=e.ref,e.child=n,n.return=e,n}function Or(e,n,t){return nd(n,e.child,null,t),(e=Hr(n,n.pendingProps)).flags|=2,Bn(n),n.memoizedState=null,e}function Mr(e,n){var t=n.ref;if(null===t)null!==e&&null!==e.ref&&(n.flags|=4194816);else{if("function"!=typeof t&&"object"!=typeof t)throw Error("Expected ref to be a function, an object returned by React.createRef(), or undefined/null.");null!==e&&e.ref===t||(n.flags|=4194816)}}function Wr(e,n,t,r,l){if(t.prototype&&"function"==typeof t.prototype.render){var a=s(t)||"Unknown";yf[a]||(console.error("The <%s /> component appears to have a render method, but doesn't extend React.Component. This is likely to cause errors. Change %s to extend React.Component instead.",a,a),yf[a]=!0)}return 8&n.mode&&fc.recordLegacyContextWarning(n,null),null===e&&($r(n,n.type),t.contextTypes&&(a=s(t)||"Unknown",vf[a]||(vf[a]=!0,console.error("%s uses the legacy contextTypes API which was removed in React 19. Use React.createContext() with React.useContext() instead. (https://react.dev/link/legacy-context)",a)))),me(n),t=Xn(e,n,t,r,void 0,l),r=tt(),null===e||gf?(n.flags|=1,Lr(e,n,t,l),n.child):(rt(e,n,l),nl(e,n,l))}function Qr(e,n,t,r,l,a){return me(n),Vd=-1,qd=null!==e&&e.type!==n.type,n.updateQueue=null,t=et(n,r,t,l),Zn(e,n),r=tt(),null===e||gf?(n.flags|=1,Lr(e,n,t,a),n.child):(rt(e,n,a),nl(e,n,a))}function Br(e,n,t,r,l){var a,o,u;if(me(n),null===n.stateNode){if(o=qu,a=t.contextType,"contextType"in t&&null!==a&&(void 0===a||a.$$typeof!==zo)&&!ff.has(t)&&(ff.add(t),u=void 0===a?" However, it is set to undefined. This can be caused by a typo or by mixing up named and default imports. This can also happen due to a circular dependency, so try moving the createContext() call to a separate file.":"object"!=typeof a?" However, it is set to a "+typeof a+".":a.$$typeof===wo?" Did you accidentally pass the Context.Consumer instead?":" However, it is set to an object with keys {"+Object.keys(a).join(", ")+"}.",console.error("%s defines an invalid contextType. contextType should point to the Context object returned by React.createContext().%s",s(t)||"Component",u)),"object"==typeof a&&null!==a&&(o=he(a)),a=new t(r,o),8&n.mode){P(!0);try{a=new t(r,o)}finally{P(!1)}}if(o=n.memoizedState=null!==a.state&&void 0!==a.state?a.state:null,a.updater=mf,n.stateNode=a,a._reactInternals=n,a._reactInternalInstance=tf,"function"==typeof t.getDerivedStateFromProps&&null===o&&(o=s(t)||"Component",lf.has(o)||(lf.add(o),console.error("`%s` uses `getDerivedStateFromProps` but its initial state is %s. This is not recommended. Instead, define the initial state by assigning an object to `this.state` in the constructor of `%s`. This ensures that `getDerivedStateFromProps` arguments have a consistent shape.",o,null===a.state?"null":"undefined",o))),"function"==typeof t.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate){var i=u=o=null;if("function"==typeof a.componentWillMount&&!0!==a.componentWillMount.__suppressDeprecationWarning?o="componentWillMount":"function"==typeof a.UNSAFE_componentWillMount&&(o="UNSAFE_componentWillMount"),"function"==typeof a.componentWillReceiveProps&&!0!==a.componentWillReceiveProps.__suppressDeprecationWarning?u="componentWillReceiveProps":"function"==typeof a.UNSAFE_componentWillReceiveProps&&(u="UNSAFE_componentWillReceiveProps"),"function"==typeof a.componentWillUpdate&&!0!==a.componentWillUpdate.__suppressDeprecationWarning?i="componentWillUpdate":"function"==typeof a.UNSAFE_componentWillUpdate&&(i="UNSAFE_componentWillUpdate"),null!==o||null!==u||null!==i){a=s(t)||"Component";var d="function"==typeof t.getDerivedStateFromProps?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";of.has(a)||(of.add(a),console.error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://react.dev/link/unsafe-component-lifecycles",a,d,null!==o?"\n "+o:"",null!==u?"\n "+u:"",null!==i?"\n "+i:""))}}a=n.stateNode,o=s(t)||"Component",a.render||(t.prototype&&"function"==typeof t.prototype.render?console.error("No `render` method found on the %s instance: did you accidentally return an object from the constructor?",o):console.error("No `render` method found on the %s instance: you may have forgotten to define `render`.",o)),!a.getInitialState||a.getInitialState.isReactClassApproved||a.state||console.error("getInitialState was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Did you mean to define a state property instead?",o),a.getDefaultProps&&!a.getDefaultProps.isReactClassApproved&&console.error("getDefaultProps was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Use a static property to define defaultProps instead.",o),a.contextType&&console.error("contextType was defined as an instance property on %s. Use a static property to define contextType instead.",o),t.childContextTypes&&!df.has(t)&&(df.add(t),console.error("%s uses the legacy childContextTypes API which was removed in React 19. Use React.createContext() instead. (https://react.dev/link/legacy-context)",o)),t.contextTypes&&!cf.has(t)&&(cf.add(t),console.error("%s uses the legacy contextTypes API which was removed in React 19. Use React.createContext() with static contextType instead. (https://react.dev/link/legacy-context)",o)),"function"==typeof a.componentShouldUpdate&&console.error("%s has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.",o),t.prototype&&t.prototype.isPureReactComponent&&void 0!==a.shouldComponentUpdate&&console.error("%s has a method called shouldComponentUpdate(). shouldComponentUpdate should not be used when extending React.PureComponent. Please extend React.Component if shouldComponentUpdate is used.",s(t)||"A pure component"),"function"==typeof a.componentDidUnmount&&console.error("%s has a method called componentDidUnmount(). But there is no such lifecycle method. Did you mean componentWillUnmount()?",o),"function"==typeof a.componentDidReceiveProps&&console.error("%s has a method called componentDidReceiveProps(). But there is no such lifecycle method. If you meant to update the state in response to changing props, use componentWillReceiveProps(). If you meant to fetch data or run side-effects or mutations after React has updated the UI, use componentDidUpdate().",o),"function"==typeof a.componentWillRecieveProps&&console.error("%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?",o),"function"==typeof a.UNSAFE_componentWillRecieveProps&&console.error("%s has a method called UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?",o),u=a.props!==r,void 0!==a.props&&u&&console.error("When calling super() in `%s`, make sure to pass up the same props that your component's constructor was passed.",o),a.defaultProps&&console.error("Setting defaultProps as an instance property on %s is not supported and will be ignored. Instead, define defaultProps as a static property on %s.",o,o),"function"!=typeof a.getSnapshotBeforeUpdate||"function"==typeof a.componentDidUpdate||af.has(t)||(af.add(t),console.error("%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). This component defines getSnapshotBeforeUpdate() only.",s(t))),"function"==typeof a.getDerivedStateFromProps&&console.error("%s: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.",o),"function"==typeof a.getDerivedStateFromError&&console.error("%s: getDerivedStateFromError() is defined as an instance method and will be ignored. Instead, declare it as a static method.",o),"function"==typeof t.getSnapshotBeforeUpdate&&console.error("%s: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.",o),(u=a.state)&&("object"!=typeof u||Uo(u))&&console.error("%s.state: must be set to an object or null",o),"function"==typeof a.getChildContext&&"object"!=typeof t.childContextTypes&&console.error("%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().",o),(a=n.stateNode).props=r,a.state=n.memoizedState,a.refs={},Cn(n),o=t.contextType,a.context="object"==typeof o&&null!==o?he(o):qu,a.state===r&&(o=s(t)||"Component",uf.has(o)||(uf.add(o),console.error("%s: It is not recommended to assign props directly to state because updates to props won't be reflected in state. In most cases, it is better to use props directly.",o))),8&n.mode&&fc.recordLegacyContextWarning(n,a),fc.recordUnsafeLifecycleWarnings(n,a),a.state=n.memoizedState,"function"==typeof(o=t.getDerivedStateFromProps)&&(zr(n,t,o,r),a.state=n.memoizedState),"function"==typeof t.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(o=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),o!==a.state&&(console.error("%s.componentWillMount(): Assigning directly to this.state is deprecated (except inside a component's constructor). Use setState instead.",c(n)||"Component"),mf.enqueueReplaceState(a,a.state,null)),Un(n,r,a,l),Ln(),a.state=n.memoizedState),"function"==typeof a.componentDidMount&&(n.flags|=4194308),(16&n.mode)!==ts&&(n.flags|=134217728),a=!0}else if(null===e){a=n.stateNode;var f=n.memoizedProps;u=Cr(t,f),a.props=u;var p=a.context;i=t.contextType,o=qu,"object"==typeof i&&null!==i&&(o=he(i)),i="function"==typeof(d=t.getDerivedStateFromProps)||"function"==typeof a.getSnapshotBeforeUpdate,f=n.pendingProps!==f,i||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(f||p!==o)&&Er(n,a,r,o),fd=!1;var m=n.memoizedState;a.state=m,Un(n,r,a,l),Ln(),p=n.memoizedState,f||m!==p||fd?("function"==typeof d&&(zr(n,t,d,r),p=n.memoizedState),(u=fd||xr(n,t,u,r,m,p,o))?(i||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||("function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"==typeof a.componentDidMount&&(n.flags|=4194308),(16&n.mode)!==ts&&(n.flags|=134217728)):("function"==typeof a.componentDidMount&&(n.flags|=4194308),(16&n.mode)!==ts&&(n.flags|=134217728),n.memoizedProps=r,n.memoizedState=p),a.props=r,a.state=p,a.context=o,a=u):("function"==typeof a.componentDidMount&&(n.flags|=4194308),(16&n.mode)!==ts&&(n.flags|=134217728),a=!1)}else{a=n.stateNode,Pn(e,n),i=Cr(t,o=n.memoizedProps),a.props=i,d=n.pendingProps,m=a.context,p=t.contextType,u=qu,"object"==typeof p&&null!==p&&(u=he(p)),(p="function"==typeof(f=t.getDerivedStateFromProps)||"function"==typeof a.getSnapshotBeforeUpdate)||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(o!==d||m!==u)&&Er(n,a,r,u),fd=!1,m=n.memoizedState,a.state=m,Un(n,r,a,l),Ln();var h=n.memoizedState;o!==d||m!==h||fd||null!==e&&null!==e.dependencies&&pe(e.dependencies)?("function"==typeof f&&(zr(n,t,f,r),h=n.memoizedState),(i=fd||xr(n,t,i,r,m,h,u)||null!==e&&null!==e.dependencies&&pe(e.dependencies))?(p||"function"!=typeof a.UNSAFE_componentWillUpdate&&"function"!=typeof a.componentWillUpdate||("function"==typeof a.componentWillUpdate&&a.componentWillUpdate(r,h,u),"function"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,h,u)),"function"==typeof a.componentDidUpdate&&(n.flags|=4),"function"==typeof a.getSnapshotBeforeUpdate&&(n.flags|=1024)):("function"!=typeof a.componentDidUpdate||o===e.memoizedProps&&m===e.memoizedState||(n.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&m===e.memoizedState||(n.flags|=1024),n.memoizedProps=r,n.memoizedState=h),a.props=r,a.state=h,a.context=u,a=i):("function"!=typeof a.componentDidUpdate||o===e.memoizedProps&&m===e.memoizedState||(n.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&m===e.memoizedState||(n.flags|=1024),a=!1)}if(u=a,Mr(e,n),o=0!=(128&n.flags),u||o){if(u=n.stateNode,ae(n),o&&"function"!=typeof t.getDerivedStateFromError)t=null,vs=-1;else if(t=Cc(u),8&n.mode){P(!0);try{Cc(u)}finally{P(!1)}}n.flags|=1,null!==e&&o?(n.child=nd(n,e.child,null,l),n.child=nd(n,null,t,l)):Lr(e,n,t,l),n.memoizedState=u.state,e=n.child}else e=nl(e,n,l);return l=n.stateNode,a&&l.props!==r&&(kf||console.error("It looks like %s is reassigning its own `this.props` while rendering. This is not supported and can lead to confusing bugs.",c(n)||"a component"),kf=!0),e}function $r(e,n){n&&n.childContextTypes&&console.error("childContextTypes cannot be defined on a function component.\n %s.childContextTypes = ...",n.displayName||n.name||"Component"),"function"==typeof n.getDerivedStateFromProps&&(e=s(n)||"Unknown",Sf[e]||(console.error("%s: Function components do not support getDerivedStateFromProps.",e),Sf[e]=!0)),"object"==typeof n.contextType&&null!==n.contextType&&(n=s(n)||"Unknown",bf[n]||(console.error("%s: Function components do not support contextType.",n),bf[n]=!0))}function Vr(e){return{baseLanes:e,cachePool:Ze()}}function qr(e,n,t){return e=null!==e?e.childLanes&~t:0,n&&(e|=wp),e}function Yr(e,n,t){var r,l=n.pendingProps,a=!1,o=0!=(128&n.flags);if((r=o)||(r=(null===e||null!==e.memoizedState)&&0!=(wd.current&kd)),r&&(a=!0,n.flags&=-129),r=0!=(32&n.flags),n.flags&=-33,null===e){var u=l.children;return l=l.fallback,a?(Qn(n),u=Jr({mode:"hidden",children:u},a=n.mode),l=oo(l,a,t,null),u.return=n,l.return=n,u.sibling=l,n.child=u,(l=n.child).memoizedState=Vr(t),l.childLanes=qr(e,r,t),n.memoizedState=xf,jr(null,l)):(On(n),Gr(n,u))}var i,s=e.memoizedState;if(null!==s&&null!==(u=s.dehydrated)){if(o)256&n.flags?(On(n),n.flags&=-257,n=Kr(e,n,t)):null!==n.memoizedState?(Qn(n),n.child=e.child,n.flags|=128,n=null):(Qn(n),u=l.fallback,a=n.mode,l=Jr({mode:"visible",children:l.children},a),(u=oo(u,a,t,null)).flags|=2,l.return=n,u.return=n,l.sibling=u,n.child=l,nd(n,e.child,null,t),(l=n.child).memoizedState=Vr(t),l.childLanes=qr(e,r,t),n.memoizedState=xf,n=jr(null,l));else if(On(n),0!=(536870912&t)&&xa(n),Lu(u))r=(a=Uu(u)).digest,u=a.message,l=a.stack,a=a.componentStack,(u=u?Error(u):Error("The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.")).stack=l||"",u.digest=r,l={value:u,source:null,stack:r=void 0===a?null:a},"string"==typeof r&&Ai.set(u,l),i=l,null===ns?ns=[i]:ns.push(i),n=Kr(e,n,t);else if(gf||fe(e,n,t,!1),r=0!=(t&e.childLanes),gf||r){if(null!==(r=Zf)&&0!==(l=z(r,t))&&l!==s.retryLane)throw s.retryLane=l,zn(e,l),pa(r,e,l),hf;Nu(u)||Ea(),n=Kr(e,n,t)}else Nu(u)?(n.flags|=192,n.child=e.child,n=null):(e=s.treeContext,(n=Gr(n,l.children)).flags|=4096);return n}return a?(Qn(n),u=l.fallback,a=n.mode,o=(s=e.child).sibling,(l=to(s,{mode:"hidden",children:l.children})).subtreeFlags=65011712&s.subtreeFlags,null!==o?u=to(o,u):(u=oo(u,a,t,null)).flags|=2,u.return=n,l.return=n,l.sibling=u,n.child=l,jr(null,l),l=n.child,null===(u=e.child.memoizedState)?u=Vr(t):(null!==(a=u.cachePool)?(s=fs._currentValue2,a=a.parent!==s?{parent:s,pool:s}:a):a=Ze(),u={baseLanes:u.baseLanes|t,cachePool:a}),l.memoizedState=u,l.childLanes=qr(e,r,t),n.memoizedState=xf,jr(e.child,l)):(null!==s&&(62914560&t)===t&&0!=(t&e.lanes)&&xa(n),On(n),e=(t=e.child).sibling,(t=to(t,{mode:"visible",children:l.children})).return=n,t.sibling=null,null!==e&&(null===(r=n.deletions)?(n.deletions=[e],n.flags|=16):r.push(e)),n.child=t,n.memoizedState=null,t)}function Gr(e,n){return(n=Jr({mode:"visible",children:n},e.mode)).return=e,e.child=n}function Jr(e,n){return(e=t(22,e,null,n)).lanes=0,e}function Kr(e,n,t){return nd(n,e.child,null,t),(e=Gr(n,n.pendingProps.children)).flags|=2,n.memoizedState=null,e}function Xr(e,n,t){e.lanes|=n;var r=e.alternate;null!==r&&(r.lanes|=n),ce(e.return,n,t)}function Zr(e,n,t,r,l,a){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:r,tail:t,tailMode:l,treeForkCount:a}:(o.isBackwards=n,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=t,o.tailMode=l,o.treeForkCount=a)}function el(e,n,t){var r=n.pendingProps,l=r.revealOrder,a=r.tail,o=r.children,u=wd.current;if((r=0!=(u&kd))?(u=u&Sd|kd,n.flags|=128):u&=Sd,p(wd,u,n),u=null==l?"null":l,"forwards"!==l&&"unstable_legacy-backwards"!==l&&"together"!==l&&"independent"!==l&&!wf[u])if(wf[u]=!0,null==l)console.error('The default for the prop is changing. To be future compatible you must explictly specify either "independent" (the current default), "together", "forwards" or "legacy_unstable-backwards".');else if("backwards"===l)console.error('The rendering order of is changing. To be future compatible you must specify revealOrder="legacy_unstable-backwards" instead.');else if("string"==typeof l)switch(l.toLowerCase()){case"together":case"forwards":case"backwards":case"independent":console.error('"%s" is not a valid value for revealOrder on . Use lowercase "%s" instead.',l,l.toLowerCase());break;case"forward":case"backward":console.error('"%s" is not a valid value for revealOrder on . React uses the -s suffix in the spelling. Use "%ss" instead.',l,l.toLowerCase());break;default:console.error('"%s" is not a supported revealOrder on . Did you mean "independent", "together", "forwards" or "backwards"?',l)}else console.error('%s is not a supported value for revealOrder on . Did you mean "independent", "together", "forwards" or "backwards"?',l);zf[u=null==a?"null":a]||(null==a?"forwards"!==l&&"backwards"!==l&&"unstable_legacy-backwards"!==l||(zf[u]=!0,console.error('The default for the prop is changing. To be future compatible you must explictly specify either "visible" (the current default), "collapsed" or "hidden".')):"visible"!==a&&"collapsed"!==a&&"hidden"!==a?(zf[u]=!0,console.error('"%s" is not a supported value for tail on . Did you mean "visible", "collapsed" or "hidden"?',a)):"forwards"!==l&&"backwards"!==l&&"unstable_legacy-backwards"!==l&&(zf[u]=!0,console.error(' is only valid if revealOrder is "forwards" or "backwards". Did you mean to specify revealOrder="forwards"?',a)));e:if(("forwards"===l||"backwards"===l||"unstable_legacy-backwards"===l)&&null!=o&&!1!==o)if(Uo(o)){for(u=0;u. This is not useful since it needs multiple rows. Did you mean to pass multiple children or an array?',l);if(Lr(e,n,o,t),o=0,!r&&null!==e&&0!=(128&e.flags))e:for(e=n.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Xr(e,t,n);else if(19===e.tag)Xr(e,t,n);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;null===e.sibling;){if(null===e.return||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(l){case"forwards":for(t=n.child,l=null;null!==t;)null!==(e=t.alternate)&&null===$n(e)&&(l=t),t=t.sibling;null===(t=l)?(l=n.child,n.child=null):(l=t.sibling,t.sibling=null),Zr(n,!1,l,t,a,o);break;case"backwards":case"unstable_legacy-backwards":for(t=null,l=n.child,n.child=null;null!==l;){if(null!==(e=l.alternate)&&null===$n(e)){n.child=l;break}e=l.sibling,l.sibling=t,t=l,l=e}Zr(n,!0,t,null,a,o);break;case"together":Zr(n,!1,null,null,void 0,o);break;default:n.memoizedState=null}return n.child}function nl(e,n,t){if(null!==e&&(n.dependencies=e.dependencies),vs=-1,vp|=n.lanes,0==(t&n.childLanes)){if(null===e)return null;if(fe(e,n,t,!1),0==(t&n.childLanes))return null}if(null!==e&&n.child!==e.child)throw Error("Resuming work not yet implemented.");if(null!==n.child){for(t=to(e=n.child,e.pendingProps),n.child=t,t.return=n;null!==e.sibling;)e=e.sibling,(t=t.sibling=to(e,e.pendingProps)).return=n;t.sibling=null}return n.child}function tl(e,n){return 0!=(e.lanes&n)||!(null===(e=e.dependencies)||!pe(e))}function rl(e,n,t){if(n._debugNeedsRemount&&null!==e){(t=lo(n.type,n.key,n.pendingProps,n._debugOwner||null,n.mode,n.lanes))._debugStack=n._debugStack,t._debugTask=n._debugTask;var r=n.return;if(null===r)throw Error("Cannot swap the root fiber.");if(e.alternate=null,n.alternate=null,t.index=n.index,t.sibling=n.sibling,t.return=n.return,t.ref=n.ref,t._debugInfo=n._debugInfo,n===r.child)r.child=t;else{var l=r.child;if(null===l)throw Error("Expected parent to have a child.");for(;l.sibling!==n;)if(null===(l=l.sibling))throw Error("Expected to find the previous sibling.");l.sibling=t}return null===(n=r.deletions)?(r.deletions=[e],r.flags|=16):n.push(e),t.flags|=2,t}if(null!==e)if(e.memoizedProps!==n.pendingProps||n.type!==e.type)gf=!0;else{if(!tl(e,t)&&0==(128&n.flags))return gf=!1,function(e,n,t){switch(n.tag){case 3:X(n,n.stateNode.containerInfo),ie(n,fs,e.memoizedState.cache);break;case 27:case 5:ne(n);break;case 4:X(n,n.stateNode.containerInfo);break;case 10:ie(n,n.type,n.memoizedProps.value);break;case 12:0!=(t&n.childLanes)&&(n.flags|=4),n.flags|=2048;var r=n.stateNode;r.effectDuration=-0,r.passiveEffectDuration=-0;break;case 31:if(null!==n.memoizedState)return n.flags|=128,Mn(n),null;break;case 13:if(null!==(r=n.memoizedState))return null!==r.dehydrated?(On(n),n.flags|=128,null):0!=(t&n.child.childLanes)?Yr(e,n,t):(On(n),null!==(e=nl(e,n,t))?e.sibling:null);On(n);break;case 19:var l=0!=(128&e.flags);if((r=0!=(t&n.childLanes))||(fe(e,n,t,!1),r=0!=(t&n.childLanes)),l){if(r)return el(e,n,t);n.flags|=128}if(null!==(l=n.memoizedState)&&(l.rendering=null,l.tail=null,l.lastEffect=null),p(wd,wd.current,n),r)break;return null;case 22:return n.lanes=0,Fr(e,n,t,n.pendingProps);case 24:ie(n,fs,e.memoizedState.cache)}return nl(e,n,t)}(e,n,t);gf=0!=(131072&e.flags)}else gf=!1,(r=es)&&(J(),r=0!=(1048576&n.flags)),r&&(r=n.index,J(),function(e,n,t){J(),Qi[Bi++]=Vi,Qi[Bi++]=qi,Qi[Bi++]=$i,$i=e;var r=Vi;e=qi;var l=32-Yu(r)-1;r&=~(1<>=o,l-=o,Vi=1<<32-Yu(n)+l|t<`. Did you misspell it or forget to pass it?")),ie(n,r,a),Lr(e,n,l.children,t),n.child;case 9:return l=n.type._context,"function"!=typeof(r=n.pendingProps.children)&&console.error("A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it."),me(n),l=he(l),r=xc(r,l,void 0),n.flags|=1,Lr(e,n,r,t),n.child;case 14:return Dr(e,n,n.type,n.pendingProps,t);case 15:return Ir(e,n,n.type,n.pendingProps,t);case 19:return el(e,n,t);case 31:return function(e,n,t){var r=n.pendingProps,l=0!=(128&n.flags);if(n.flags&=-129,null===e)return Hr(n,r);var a=e.memoizedState;if(null!==a){var o=a.dehydrated;if(Mn(n),l)if(256&n.flags)n.flags&=-257,n=Or(e,n,t);else{if(null===n.memoizedState)throw Error("Client rendering an Activity suspended it again. This is a bug in React.");n.child=e.child,n.flags|=128,n=null}else if(0!=(536870912&t)&&xa(n),gf||fe(e,n,t,!1),l=0!=(t&e.childLanes),gf||l){if(null!==(r=Zf)&&0!==(o=z(r,t))&&o!==a.retryLane)throw a.retryLane=o,zn(e,o),pa(r,e,o),hf;Ea(),n=Or(e,n,t)}else e=a.treeContext,(n=Hr(n,r)).flags|=4096;return n}return a=e.child,r={mode:r.mode,children:r.children},0!=(536870912&t)&&0!=(t&e.lanes)&&xa(n),(e=to(a,r)).ref=n.ref,n.child=e,e.return=n,e}(e,n,t);case 22:return Fr(e,n,t,n.pendingProps);case 24:return me(n),r=he(fs),null===e?(null===(l=Ke())&&(l=Zf,a=be(),l.pooledCache=a,ve(a),null!==a&&(l.pooledCacheLanes|=t),l=a),n.memoizedState={parent:r,cache:l},Cn(n),ie(n,fs,l)):(0!=(e.lanes&t)&&(Pn(e,n),Un(n,null,null,t),Ln()),l=e.memoizedState,a=n.memoizedState,l.parent!==r?(l={parent:r,cache:r},n.memoizedState=l,0===n.lanes&&(n.memoizedState=n.updateQueue.baseState=l),ie(n,fs,r)):(r=a.cache,ie(n,fs,r),r!==l.cache&&de(n,[fs],t,!0))),Lr(e,n,n.pendingProps.children,t),n.child;case 29:throw n.pendingProps}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function ll(e){e.flags|=4}function al(e,n,t,r,l){if((32&e.mode)!==ts&&(null===t?au(n,r):ou(n,t,r))){if(e.flags|=16777216,(335544128&l)===l||uu(n,r))if(iu(e.stateNode,n,r))e.flags|=8192;else{if(null!==(a=bd.current)&&((4194048&np)===np?null!==vd:(62914560&np)!==np&&0==(536870912&np)||a!==vd))throw $c=Bc,Wc;e.flags|=8192}}else e.flags&=-16777217;var a}function ol(e,n){null!==n&&(e.flags|=4),16384&e.flags&&(n=22!==e.tag?b():536870912,e.lanes|=n,zp|=n)}function ul(e,n){switch(e.tailMode){case"hidden":n=e.tail;for(var t=null;null!==n;)null!==n.alternate&&(t=n),n=n.sibling;null===t?e.tail=null:t.sibling=null;break;case"collapsed":t=e.tail;for(var r=null;null!==t;)null!==t.alternate&&(r=t),t=t.sibling;null===r?n||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function il(e){var n=null!==e.alternate&&e.alternate.child===e.child,t=0,r=0;if(n)if((2&e.mode)!==ts){for(var l=e.selfBaseDuration,a=e.child;null!==a;)t|=a.lanes|a.childLanes,r|=65011712&a.subtreeFlags,r|=65011712&a.flags,l+=a.treeBaseDuration,a=a.sibling;e.treeBaseDuration=l}else for(l=e.child;null!==l;)t|=l.lanes|l.childLanes,r|=65011712&l.subtreeFlags,r|=65011712&l.flags,l.return=e,l=l.sibling;else if((2&e.mode)!==ts){l=e.actualDuration,a=e.selfBaseDuration;for(var o=e.child;null!==o;)t|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,l+=o.actualDuration,a+=o.treeBaseDuration,o=o.sibling;e.actualDuration=l,e.treeBaseDuration=a}else for(l=e.child;null!==l;)t|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=t,n}function sl(e,n,t){var r=n.pendingProps;switch(G(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return il(n),null;case 3:return t=n.stateNode,r=null,null!==e&&(r=e.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),se(fs,n),Z(n),t.pendingContext&&(t.context=t.pendingContext,t.pendingContext=null),null!==e&&null!==e.child||null===e||e.memoizedState.isDehydrated&&0==(256&n.flags)||(n.flags|=1024,oe()),il(n),null;case 26:var l,a;case 27:case 5:if(te(n),l=n.type,null!==e&&null!=n.stateNode)!function(e,n,t,r){e.memoizedProps!==r&&ll(n)}(e,n,0,r);else{if(!r){if(null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");return il(n),null}a=ee();var o=K(Ji.current);(function(e,n,t,r){for(t=n.child;null!==t;){if(5===t.tag||6===t.tag)Mo(e,t.stateNode);else if(4!==t.tag&&!Qu&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===n)break;for(;null===t.sibling;){if(null===t.return||t.return===n)return;t=t.return}t.sibling.return=t.return,t=t.sibling}})(o=Oo(l,r,o,a,n),n,!1),n.stateNode=o,Wo(o,l,r,a)&&ll(n)}return il(n),al(n,n.type,null===e?null:e.memoizedProps,n.pendingProps,t),null;case 6:if(e&&null!=n.stateNode)(t=e.memoizedProps)!==r&&ll(n);else{if("string"!=typeof r&&null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");e=K(Ji.current),t=ee(),n.stateNode=Bo(r,e,t,n)}return il(n),null;case 31:if(t=n.memoizedState,null===e||null!==e.memoizedState){if(r=!1,null!==t){if(null===e){if(!r)throw Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");throw Error("Expected prepareToHydrateHostActivityInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.")}0==(128&n.flags)&&(t=n.memoizedState=null),n.flags|=4,il(n),(2&n.mode)!==ts&&null!==t&&null!==(e=n.child)&&(n.treeBaseDuration-=e.treeBaseDuration),e=!1}else t=oe(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=t),e=!0;if(!e)return 256&n.flags?(Bn(n),n):(Bn(n),null);if(0!=(128&n.flags))throw Error("Client rendering an Activity suspended it again. This is a bug in React.")}return il(n),null;case 13:if(r=n.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(a=!1,null!==(l=r)&&null!==l.dehydrated){if(null===e){if(!a)throw Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");throw Error("Expected prepareToHydrateHostSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.")}0==(128&n.flags)&&(l=n.memoizedState=null),n.flags|=4,il(n),(2&n.mode)!==ts&&null!==l&&null!==(l=n.child)&&(n.treeBaseDuration-=l.treeBaseDuration),l=!1}else l=oe(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=l),l=!0;if(!l)return 256&n.flags?(Bn(n),n):(Bn(n),null)}return Bn(n),0!=(128&n.flags)?(n.lanes=t,(2&n.mode)!==ts&&Ae(n),n):(t=null!==r,e=null!==e&&null!==e.memoizedState,t&&(l=null,null!==(r=n.child).alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(l=r.alternate.memoizedState.cachePool.pool),a=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(a=r.memoizedState.cachePool.pool),a!==l&&(r.flags|=2048)),t!==e&&t&&(n.child.flags|=8192),ol(n,n.updateQueue),il(n),(2&n.mode)!==ts&&t&&null!==(e=n.child)&&(n.treeBaseDuration-=e.treeBaseDuration),null);case 4:return Z(n),null===e&&Jo(n.stateNode.containerInfo),il(n),null;case 10:return se(n.type,n),il(n),null;case 19:if(f(wd,n),null===(r=n.memoizedState))return il(n),null;if(l=0!=(128&n.flags),null===(a=r.rendering))if(l)ul(r,!1);else{if(bp!==$f||null!==e&&0!=(128&e.flags))for(e=n.child;null!==e;){if(null!==(a=$n(e))){for(n.flags|=128,ul(r,!1),e=a.updateQueue,n.updateQueue=e,ol(n,e),n.subtreeFlags=0,e=t,t=n.child;null!==t;)ro(t,e),t=t.sibling;return p(wd,wd.current&Sd|kd,n),n.child}e=e.sibling}null!==r.tail&&li()>Rp&&(n.flags|=128,l=!0,ul(r,!1),n.lanes=4194304)}else{if(!l)if(null!==(e=$n(a))){if(n.flags|=128,l=!0,e=e.updateQueue,n.updateQueue=e,ol(n,e),ul(r,!0),null===r.tail&&"hidden"===r.tailMode&&!a.alternate)return il(n),null}else 2*li()-r.renderingStartTime>Rp&&536870912!==t&&(n.flags|=128,l=!0,ul(r,!1),n.lanes=4194304);r.isBackwards?(a.sibling=n.child,n.child=a):(null!==(e=r.last)?e.sibling=a:n.child=a,r.last=a)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=li(),e.sibling=null,t=wd.current,p(wd,t=l?t&Sd|kd:t&Sd,n),e):(il(n),null);case 22:case 23:return Bn(n),Hn(n),r=null!==n.memoizedState,null!==e?null!==e.memoizedState!==r&&(n.flags|=8192):r&&(n.flags|=8192),r?0!=(536870912&t)&&0==(128&n.flags)&&(il(n),6&n.subtreeFlags&&(n.flags|=8192)):il(n),null!==(t=n.updateQueue)&&ol(n,t.retryQueue),t=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(t=e.memoizedState.cachePool.pool),r=null,null!==n.memoizedState&&null!==n.memoizedState.cachePool&&(r=n.memoizedState.cachePool.pool),r!==t&&(n.flags|=2048),null!==e&&f(dc,n),null;case 24:return t=null,null!==e&&(t=e.memoizedState.cache),n.memoizedState.cache!==t&&(n.flags|=2048),se(fs,n),il(n),null;case 25:case 30:return null}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function cl(e,n){switch(G(n),n.tag){case 1:return 65536&(e=n.flags)?(n.flags=-65537&e|128,(2&n.mode)!==ts&&Ae(n),n):null;case 3:return se(fs,n),Z(n),0!=(65536&(e=n.flags))&&0==(128&e)?(n.flags=-65537&e|128,n):null;case 26:case 27:case 5:return te(n),null;case 31:if(null!==n.memoizedState&&(Bn(n),null===n.alternate))throw Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");return 65536&(e=n.flags)?(n.flags=-65537&e|128,(2&n.mode)!==ts&&Ae(n),n):null;case 13:if(Bn(n),null!==(e=n.memoizedState)&&null!==e.dehydrated&&null===n.alternate)throw Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");return 65536&(e=n.flags)?(n.flags=-65537&e|128,(2&n.mode)!==ts&&Ae(n),n):null;case 19:return f(wd,n),null;case 4:return Z(n),null;case 10:return se(n.type,n),null;case 22:case 23:return Bn(n),Hn(n),null!==e&&f(dc,n),65536&(e=n.flags)?(n.flags=-65537&e|128,(2&n.mode)!==ts&&Ae(n),n):null;case 24:return se(fs,n),null;default:return null}}function dl(e,n){switch(G(n),n.tag){case 3:se(fs,n),Z(n);break;case 26:case 27:case 5:te(n);break;case 4:Z(n);break;case 31:null!==n.memoizedState&&Bn(n);break;case 13:Bn(n);break;case 19:f(wd,n);break;case 10:se(n.type,n);break;case 22:case 23:Bn(n),Hn(n),null!==e&&f(dc,n);break;case 24:se(fs,n)}}function fl(e){return(2&e.mode)!==ts}function pl(e,n){fl(e)?(je(),hl(n,e),Ie()):hl(n,e)}function ml(e,n,t){fl(e)?(je(),gl(t,e,n),Ie()):gl(t,e,n)}function hl(e,n){try{var t=n.updateQueue,r=null!==t?t.lastEffect:null;if(null!==r){var l=r.next;t=l;do{var a;(t.tag&e)===e&&(r=void 0,(e&Ed)!==zd&&(cm=!0),r=le(n,Fc,t),(e&Ed)!==zd&&(cm=!1),void 0!==r&&"function"!=typeof r)&&le(n,(function(e,n){console.error("%s must not return anything besides a function, which is used for clean-up.%s",e,n)}),a=0!=(t.tag&Cd)?"useLayoutEffect":0!=(t.tag&Ed)?"useInsertionEffect":"useEffect",null===r?" You returned null. If your effect does not require clean up, return undefined (or nothing).":"function"==typeof r.then?"\n\nIt looks like you wrote "+a+"(async () => ...) or returned a Promise. Instead, write the async function inside your effect and call it immediately:\n\n"+a+"(() => {\n async function fetchData() {\n // You can await here\n const response = await MyAPI.getData(someId);\n // ...\n }\n fetchData();\n}, [someId]); // Or [] if effect doesn't need props or state\n\nLearn more about data fetching with Hooks: https://react.dev/link/hooks-data-fetching":" You returned: "+r),t=t.next}while(t!==l)}}catch(e){Qa(n,n.return,e)}}function gl(e,n,t){try{var r=n.updateQueue,l=null!==r?r.lastEffect:null;if(null!==l){var a=l.next;r=a;do{if((r.tag&e)===e){var o=r.inst,u=o.destroy;void 0!==u&&(o.destroy=void 0,(e&Ed)!==zd&&(cm=!0),le(l=n,Ac,l,t,u),(e&Ed)!==zd&&(cm=!1))}r=r.next}while(r!==a)}}catch(e){Qa(n,n.return,e)}}function yl(e,n){fl(e)?(je(),hl(n,e),Ie()):hl(n,e)}function bl(e,n,t){fl(e)?(je(),gl(t,e,n),Ie()):gl(t,e,n)}function vl(e){var n=e.updateQueue;if(null!==n){var t=e.stateNode;e.type.defaultProps||"ref"in e.memoizedProps||kf||(t.props!==e.memoizedProps&&console.error("Expected %s props to match memoized props before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.",c(e)||"instance"),t.state!==e.memoizedState&&console.error("Expected %s state to match memoized state before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.",c(e)||"instance"));try{le(e,Fn,n,t)}catch(n){Qa(e,e.return,n)}}}function Sl(e,n,t){return e.getSnapshotBeforeUpdate(n,t)}function kl(e,n){var t=n.memoizedProps,r=n.memoizedState;n=e.stateNode,e.type.defaultProps||"ref"in e.memoizedProps||kf||(n.props!==e.memoizedProps&&console.error("Expected %s props to match memoized props before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.",c(e)||"instance"),n.state!==e.memoizedState&&console.error("Expected %s state to match memoized state before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.",c(e)||"instance"));try{var l=Cr(e.type,t),a=le(e,Sl,n,l,r);t=Cf,void 0!==a||t.has(e.type)||(t.add(e.type),le(e,(function(){console.error("%s.getSnapshotBeforeUpdate(): A snapshot value (or null) must be returned. You have returned undefined.",c(e))}))),n.__reactInternalSnapshotBeforeUpdate=a}catch(n){Qa(e,e.return,n)}}function wl(e,n,t){t.props=Cr(e.type,e.memoizedProps),t.state=e.memoizedState,fl(e)?(je(),le(e,Dc,e,n,t),Ie()):le(e,Dc,e,n,t)}function zl(e){var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var t=Io(e.stateNode);break;default:t=e.stateNode}if("function"==typeof n)if(fl(e))try{je(),e.refCleanup=n(t)}finally{Ie()}else e.refCleanup=n(t);else"string"==typeof n?console.error("String refs are no longer supported."):n.hasOwnProperty("current")||console.error("Unexpected ref object provided for %s. Use either a ref-setter function or React.createRef().",c(e)),n.current=t}}function xl(e,n){try{le(e,zl,e)}catch(t){Qa(e,n,t)}}function El(e,n){var t=e.ref,r=e.refCleanup;if(null!==t)if("function"==typeof r)try{if(fl(e))try{je(),le(e,r)}finally{Ie()}else le(e,r)}catch(t){Qa(e,n,t)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof t)try{if(fl(e))try{je(),le(e,t,null)}finally{Ie()}else le(e,t,null)}catch(t){Qa(e,n,t)}else t.current=null}function Cl(e,n,t,r){var l=e.memoizedProps,a=l.id,o=l.onCommit;l=l.onRender,n=null===n?"mount":"update",Js&&(n="nested-update"),"function"==typeof l&&l(a,n,e.actualDuration,e.treeBaseDuration,e.actualStartTime,t),"function"==typeof o&&o(a,n,r,t)}function Pl(e,n,t,r){var l=e.memoizedProps;e=l.id,l=l.onPostCommit,n=null===n?"mount":"update",Js&&(n="nested-update"),"function"==typeof l&&l(e,n,r,t)}function _l(e){var n=e.type,t=e.memoizedProps,r=e.stateNode;try{le(e,vu,r,n,t,e)}catch(n){Qa(e,e.return,n)}}function Tl(e){return 5===e.tag||3===e.tag||4===e.tag}function Rl(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||Tl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function Nl(e,n,t){var r=e.tag;if(5===r||6===r)e=e.stateNode,n?wu(t,e,n):yu(t,e);else if(4!==r&&null!==(e=e.child))for(Nl(e,n,t),e=e.sibling;null!==e;)Nl(e,n,t),e=e.sibling}function Ll(e,n,t){var r=e.tag;if(5===r||6===r)e=e.stateNode,n?ku(t,e,n):gu(t,e);else if(4!==r&&null!==(e=e.child))for(Ll(e,n,t),e=e.sibling;null!==e;)Ll(e,n,t),e=e.sibling}function Ul(e){for(var n,t=e.return;null!==t;){if(Tl(t)){n=t;break}t=t.return}if(null==n)throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");switch(n.tag){case 27:case 5:t=n.stateNode,32&n.flags&&(Eu(t),n.flags&=-33),Ll(e,n=Rl(e),t);break;case 3:case 4:n=n.stateNode.containerInfo,Nl(e,t=Rl(e),n);break;default:throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.")}}function Dl(e,n){return 31===n.tag?(n=n.memoizedState,null!==e.memoizedState&&null===n):13===n.tag?(e=e.memoizedState,n=n.memoizedState,null!==e&&null!==e.dehydrated&&(null===n||null===n.dehydrated)):3===n.tag&&e.memoizedState.isDehydrated&&0==(256&n.flags)}function Il(e,n,t){var r=Ce(),l=_e(),a=Re(),o=Ne(),u=t.flags;switch(t.tag){case 0:case 11:case 15:Bl(e,t),4&u&&pl(t,Cd|xd);break;case 1:if(Bl(e,t),4&u)if(e=t.stateNode,null===n)t.type.defaultProps||"ref"in t.memoizedProps||kf||(e.props!==t.memoizedProps&&console.error("Expected %s props to match memoized props before componentDidMount. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.",c(t)||"instance"),e.state!==t.memoizedState&&console.error("Expected %s state to match memoized state before componentDidMount. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.",c(t)||"instance")),fl(t)?(je(),le(t,_c,t,e),Ie()):le(t,_c,t,e);else{var i=Cr(t.type,n.memoizedProps);n=n.memoizedState,t.type.defaultProps||"ref"in t.memoizedProps||kf||(e.props!==t.memoizedProps&&console.error("Expected %s props to match memoized props before componentDidUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.",c(t)||"instance"),e.state!==t.memoizedState&&console.error("Expected %s state to match memoized state before componentDidUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.",c(t)||"instance")),fl(t)?(je(),le(t,Rc,t,e,i,n,e.__reactInternalSnapshotBeforeUpdate),Ie()):le(t,Rc,t,e,i,n,e.__reactInternalSnapshotBeforeUpdate)}64&u&&vl(t),512&u&&xl(t,t.return);break;case 3:if(n=we(),Bl(e,t),64&u&&null!==(u=t.updateQueue)){if(i=null,null!==t.child)switch(t.child.tag){case 27:case 5:i=Io(t.child.stateNode);break;case 1:i=t.child.stateNode}try{le(t,Fn,u,i)}catch(e){Qa(t,t.return,e)}}e.effectDuration+=ze(n);break;case 27:case 26:case 5:if(Bl(e,t),null===n)if(4&u)_l(t);else if(64&u){e=t.type,n=t.memoizedProps,i=t.stateNode;try{le(t,Iu,i,e,n,t)}catch(e){Qa(t,t.return,e)}}512&u&&xl(t,t.return);break;case 12:if(4&u){u=we(),Bl(e,t),(e=t.stateNode).effectDuration+=xe(u);try{le(t,Cl,t,n,gs,e.effectDuration)}catch(e){Qa(t,t.return,e)}}else Bl(e,t);break;case 31:default:Bl(e,t);break;case 13:Bl(e,t),64&u&&null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)&&(u=qa.bind(null,t),Du(e,u));break;case 22:if(!(u=null!==t.memoizedState||Pf)){n=null!==n&&null!==n.memoizedState||_f,i=Pf;var s=_f;Pf=u,(_f=n)&&!s?(Yl(e,t,0!=(8772&t.subtreeFlags)),(2&t.mode)!==ts&&0<=ws&&0<=zs&&.05 {\n /* fire events that update state */\n});\n/* assert on the output */\n\nThis ensures that you're testing the behavior the user would see in the browser. Learn more at https://react.dev/link/wrap-tests-with-act",c(e))}))}(n),e===Zf&&((Xf&Qf)===Wf&&(Sp|=t),bp===Gf&&ya(e,np,wp,!1)),Oe(e)}function ma(e,n,t){if((Xf&(Qf|Bf))!==Wf)throw Error("Should not already be working.");if(0!==np&&null!==ep){var r=ep,l=li();switch(Ys){case ap:case lp:var a=Gs;Ci&&((r=r._debugTask)?r.run(console.timeStamp.bind(console,"Suspended",a,l,"Components ⚛",void 0,"primary-light")):console.timeStamp("Suspended",a,l,"Components ⚛",void 0,"primary-light"));break;case dp:a=Gs,Ci&&((r=r._debugTask)?r.run(console.timeStamp.bind(console,"Action",a,l,"Components ⚛",void 0,"primary-light")):console.timeStamp("Action",a,l,"Components ⚛",void 0,"primary-light"));break;default:Ci&&(3>(r=l-Gs)||console.timeStamp("Blocked",Gs,l,"Components ⚛",void 0,5>r?"primary-light":10>r?"primary":100>r?"primary-dark":"error"))}}a=(t=!t&&0==(127&n)&&0==(n&e.expiredLanes)||g(e,n))?function(e,n){var t=Xf;Xf|=Qf;var r=wa(),l=za();if(Zf!==e||np!==n){if(fi){var a=e.memoizedUpdaters;0l&&(t=l):t=l,0t&&(u=t):u=t,null!==i&&t>u){var f=s?"secondary-light":"warning";r?r.run(console.timeStamp.bind(console,s?"Consecutive":"Event: "+i,u,t,Pi,"Scheduler ⚛",f)):console.timeStamp(s?"Consecutive":"Event: "+i,u,t,Pi,"Scheduler ⚛",f)}l>t&&(u=c?"error":(738197653&n)===n?"tertiary-light":"primary-light",c=d?"Promise Resolved":c?"Cascading Update":5a&&(t=a):t=a,0t&&(l=t):l=t,0l&&(d=l):d=l,l>d&&null!==u&&(f=i?"secondary-light":"warning",r?r.run(console.timeStamp.bind(console,i?"Consecutive":"Event: "+u,d,l,Pi,"Scheduler ⚛",f)):console.timeStamp(i?"Consecutive":"Event: "+u,d,l,Pi,"Scheduler ⚛",f)),t>l&&(r?r.run(console.timeStamp.bind(console,"Action",l,t,Pi,"Scheduler ⚛","primary-dark")):console.timeStamp("Action",l,t,Pi,"Scheduler ⚛","primary-dark")),a>t&&(l=s?"Promise Resolved":5t?32:t;t=Do.T;var l=Xo();try{Ko(r),Do.T=null;var a=Kp;Kp=null,r=Vp;var o,u=Yp;if($p=Hp,qp=Vp=null,Yp=0,(Xf&(Qf|Bf))!==Wf)throw Error("Cannot flush passive effects while already rendering.");if(N(u),am=!0,om=!1,bs=null,o=li(),em===Ap){var i=ys,s=o;!Ci||s<=i||(qs?qs.run(console.timeStamp.bind(console,"Animating",i,s,Pi,"Scheduler ⚛","secondary-dark")):console.timeStamp("Animating",i,s,Pi,"Scheduler ⚛","secondary-dark"))}else{i=ys,s=o;var c=em===jp;!Ci||s<=i||(Up?Up.run(console.timeStamp.bind(console,c?"Waiting for Paint":"Waiting",i,s,Pi,"Scheduler ⚛","secondary-light")):console.timeStamp(c?"Waiting for Paint":"Waiting",i,s,Pi,"Scheduler ⚛","secondary-light"))}i=Xf,Xf|=Bf;var d=r.current;Ee(),oa(d);var f=r.current;d=Jp,Ee(),Xl(r,f,u,a,d),Ka(r),Xf=i;var p=li();f=o,d=Up,null!==bs?O(f,p,bs,!0,d):!Ci||p<=f||(d?d.run(console.timeStamp.bind(console,"Remaining Effects",f,p,Pi,"Scheduler ⚛","secondary-dark")):console.timeStamp("Remaining Effects",f,p,Pi,"Scheduler ⚛","secondary-dark")),va(u,p),Me(0),om?r===sm?im++:(im=0,sm=r):im=0,om=am=!1,di&&di.onPostCommitFiberRoot;var m=r.current.stateNode;return m.effectDuration=0,m.passiveEffectDuration=0,!0}finally{Ko(l),Do.T=t,Ha(e,n)}}function Wa(e,n,t){Fe(n=Y(t,n)),null!==(e=Tn(e,n=Tr(e.stateNode,n,2),2))&&(S(e,2),Oe(e))}function Qa(e,n,t){if(cm=!1,3===e.tag)Wa(e,e,t);else{for(;null!==n;){if(3===n.tag)return void Wa(n,e,t);if(1===n.tag){var r=n.stateNode;if("function"==typeof n.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===Dp||!Dp.has(r)))return Fe(e=Y(t,e)),void(null!==(r=Tn(n,t=Rr(2),2))&&(Nr(t,r,n,e),S(r,2),Oe(r)))}n=n.return}console.error("Internal React error: Attempted to capture a commit phase error inside a detached tree. This indicates a bug in React. Potential causes include deleting the same fiber more than once, committing an already-finished tree, or an inconsistent return pointer.\n\nError message:\n\n%s",t)}}function Ba(e,n,t){var r=e.pingCache;if(null===r){r=e.pingCache=new Mf;var l=new Set;r.set(n,l)}else void 0===(l=r.get(n))&&(l=new Set,r.set(n,l));l.has(t)||(gp=!0,l.add(t),r=$a.bind(null,e,n,t),fi&&Za(e,t),n.then(r,r))}function $a(e,n,t){var r=e.pingCache;null!==r&&r.delete(n),e.pingedLanes|=e.suspendedLanes&t,e.warmLanes&=~t,0!=(127&t)?0>Ps&&(Cs=Ps=ps(),_s=ms("Promise Resolved"),Ts=2):0!=(4194048&t)&&0>As&&(Fs=As=ps(),Os=ms("Promise Resolved"),Hs=2),ca()&&null===Do.actQueue&&console.error("A suspended resource finished loading inside a test, but the event was not wrapped in act(...).\n\nWhen testing, code that resolves suspended data should be wrapped into act(...):\n\nact(() => {\n /* finish loading suspended data */\n});\n/* assert on the output */\n\nThis ensures that you're testing the behavior the user would see in the browser. Learn more at https://react.dev/link/wrap-tests-with-act"),Zf===e&&(np&t)===t&&(bp===Gf||bp===Yf&&(62914560&np)===np&&li()-Pp",i=" Did you accidentally export a JSX literal instead of a component?"):r=typeof e,(u=l?"number"==typeof l.tag?c(l):"string"==typeof l.name?l.name:null:null)&&(i+="\n\nCheck the render method of `"+u+"`."),u=29,r=Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: "+r+"."+i),i=null}return(n=t(u,r,n,a)).elementType=e,n.type=i,n.lanes=o,n._debugOwner=l,n}function ao(e,n,t){return(n=lo(e.type,e.key,e.props,e._owner,n,t))._debugOwner=e._owner,n._debugStack=e._debugStack,n._debugTask=e._debugTask,n}function oo(e,n,r,l){return(e=t(7,e,l,n)).lanes=r,e}function uo(e,n,r){return(e=t(6,e,null,n)).lanes=r,e}function io(e,n,r){return(n=t(4,null!==e.children?e.children:[],e.key,n)).lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function so(e,n,t,r,l,a,o,u,i){for(this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=qo,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=v(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=v(0),this.hiddenUpdates=v(null),this.identifierPrefix=r,this.onUncaughtError=l,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=i,this.incompleteTransitions=new Map,this.passiveEffectDuration=this.effectDuration=-0,this.memoizedUpdaters=new Set,e=this.pendingUpdatersLaneMap=[],n=0;31>n;n++)e.push(new Set);this._debugRootType=t?"hydrateRoot()":"createRoot()"}function co(e,n,t,r,l,a){l=function(e){return e?e=qu:qu}(l),null===r.context?r.context=l:r.pendingContext=l,Zi&&null!==Xi&&!gm&&(gm=!0,console.error("Render methods should be a pure function of props and state; triggering nested component updates from render is not allowed. If necessary, trigger nested updates in componentDidUpdate.\n\nCheck the render method of %s.",c(Xi)||"Unknown")),(r=_n(n)).payload={element:t},null!==(a=void 0===a?null:a)&&("function"!=typeof a&&console.error("Expected the last optional `callback` argument to be a function. Instead received: %s.",a),r.callback=a),null!==(t=Tn(e,r,n))&&(ke(n,"root.render()",null),pa(t,e,n),Rn(t,e,n))}var fo={},po=e,mo=u,ho=Object.assign,go=Symbol.for("react.element"),yo=Symbol.for("react.transitional.element"),bo=Symbol.for("react.portal"),vo=Symbol.for("react.fragment"),So=Symbol.for("react.strict_mode"),ko=Symbol.for("react.profiler"),wo=Symbol.for("react.consumer"),zo=Symbol.for("react.context"),xo=Symbol.for("react.forward_ref"),Eo=Symbol.for("react.suspense"),Co=Symbol.for("react.suspense_list"),Po=Symbol.for("react.memo"),_o=Symbol.for("react.lazy"),To=Symbol.for("react.activity"),Ro=Symbol.for("react.memo_cache_sentinel"),No=Symbol.iterator,Lo=Symbol.for("react.client.reference"),Uo=Array.isArray,Do=po.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Io=n.getPublicInstance,Fo=n.getRootHostContext,jo=n.getChildHostContext,Ao=n.prepareForCommit,Ho=n.resetAfterCommit,Oo=n.createInstance,Mo=n.appendInitialChild,Wo=n.finalizeInitialChildren,Qo=n.shouldSetTextContent,Bo=n.createTextInstance,$o=null,Vo=null,qo=n.noTimeout,Yo=!0,Go=null,Jo=null,Ko=n.setCurrentUpdatePriority,Xo=n.getCurrentUpdatePriority,Zo=n.resolveUpdatePriority,eu=n.trackSchedulerEvent,nu=n.resolveEventType,tu=n.resolveEventTimeStamp,ru=n.shouldAttemptEagerTransition,lu=n.detachDeletedInstance;n.requestPostPaintCallback;var au=n.maySuspendCommit,ou=null,uu=null,iu=null,su=null,cu=null,du=null,fu=null,pu=null,mu=null,hu=null,gu=n.appendChild,yu=n.appendChildToContainer,bu=n.commitTextUpdate,vu=null,Su=n.commitUpdate,ku=n.insertBefore,wu=null,zu=n.removeChild,xu=n.removeChildFromContainer,Eu=n.resetTextContent,Cu=null,Pu=null,_u=null,Tu=null,Ru=n.clearContainer,Nu=null,Lu=null,Uu=null,Du=null,Iu=null,Fu=null,ju=null,Au=null,Hu=null,Ou=null,Mu=null,Wu=null,Qu=null,Bu=[],$u=[],Vu=-1,qu={};Object.freeze(qu);var Yu=Math.clz32?Math.clz32:function(e){return 0==(e>>>=0)?32:31-(Gu(e)/Ju|0)|0},Gu=Math.log,Ju=Math.LN2,Ku=256,Xu=262144,Zu=4194304,ei=mo.unstable_scheduleCallback,ni=mo.unstable_cancelCallback,ti=mo.unstable_shouldYield,ri=mo.unstable_requestPaint,li=mo.unstable_now,ai=mo.unstable_ImmediatePriority,oi=mo.unstable_UserBlockingPriority,ui=mo.unstable_NormalPriority,ii=mo.unstable_IdlePriority,si=mo.log,ci=mo.unstable_setDisableYieldValue,di=null,fi="undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__,pi=0;if("object"==typeof performance&&"function"==typeof performance.now)var mi=performance,hi=function(){return mi.now()};else{var gi=Date;hi=function(){return gi.now()}}var yi="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n};"function"==typeof reportError&&reportError;var bi,vi,Si,ki,wi,zi,xi,Ei=Object.prototype.hasOwnProperty,Ci="undefined"!=typeof console&&"function"==typeof console.timeStamp&&"undefined"!=typeof performance&&"function"==typeof performance.measure,Pi="Blocking",_i=!1,Ti={color:"primary",properties:null,tooltipText:"",track:"Components ⚛"},Ri={start:-0,end:-0,detail:{devtools:Ti}},Ni=["Changed Props",""],Li=["Changed Props","This component received deeply equal props. It might benefit from useMemo or the React Compiler in its owner."],Ui=0;M.__reactDisabledLog=!0;var Di,Ii,Fi=!1,ji=new("function"==typeof WeakMap?WeakMap:Map),Ai=new WeakMap,Hi=[],Oi=0,Mi=null,Wi=0,Qi=[],Bi=0,$i=null,Vi=1,qi="",Yi=d(null),Gi=d(null),Ji=d(null),Ki=d(null),Xi=null,Zi=!1,es=!1,ns=null,ts=0,rs=d(null),ls=d(null),as={},os=null,us=null,is=!1,ss="undefined"!=typeof AbortController?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(n,t){e.push(t)}};this.abort=function(){n.aborted=!0,e.forEach((function(e){return e()}))}},cs=mo.unstable_scheduleCallback,ds=mo.unstable_NormalPriority,fs={$$typeof:zo,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0,_currentRenderer:null,_currentRenderer2:null},ps=mo.unstable_now,ms=console.createTask?console.createTask:function(){return null},hs=-0,gs=-0,ys=-0,bs=null,vs=-1.1,Ss=-0,ks=-0,ws=-1.1,zs=-1.1,xs=null,Es=!1,Cs=-0,Ps=-1.1,_s=null,Ts=0,Rs=null,Ns=null,Ls=-1.1,Us=null,Ds=-1.1,Is=-1.1,Fs=-0,js=-1.1,As=-1.1,Hs=0,Os=null,Ms=null,Ws=null,Qs=-1.1,Bs=null,$s=-1.1,Vs=-1.1,qs=null,Ys=0,Gs=-1.1,Js=!1,Ks=!1,Xs=null,Zs=null,ec=!1,nc=!1,tc=!1,rc=!1,lc=0,ac={},oc=null,uc=0,ic=0,sc=null,cc=Do.S;Do.S=function(e,n){if(_p=li(),"object"==typeof n&&null!==n&&"function"==typeof n.then){if(0>js&&0>As){js=ps();var t=tu(),r=nu();t===$s&&r===Bs||($s=-1.1),Qs=t,Bs=r}!function(e,n){if(null===oc){var t=oc=[];uc=0,ic=Ge(),sc={status:"pending",value:void 0,then:function(e){t.push(e)}}}uc++,n.then(Je,Je)}(0,n)}null!==cc&&cc(e,n)};var dc=d(null),fc={recordUnsafeLifecycleWarnings:function(){},flushPendingUnsafeLifecycleWarnings:function(){},recordLegacyContextWarning:function(){},flushLegacyContextWarning:function(){},discardPendingWarnings:function(){}},pc=[],mc=[],hc=[],gc=[],yc=[],bc=[],vc=new Set;fc.recordUnsafeLifecycleWarnings=function(e,n){vc.has(e.type)||("function"==typeof n.componentWillMount&&!0!==n.componentWillMount.__suppressDeprecationWarning&&pc.push(e),8&e.mode&&"function"==typeof n.UNSAFE_componentWillMount&&mc.push(e),"function"==typeof n.componentWillReceiveProps&&!0!==n.componentWillReceiveProps.__suppressDeprecationWarning&&hc.push(e),8&e.mode&&"function"==typeof n.UNSAFE_componentWillReceiveProps&&gc.push(e),"function"==typeof n.componentWillUpdate&&!0!==n.componentWillUpdate.__suppressDeprecationWarning&&yc.push(e),8&e.mode&&"function"==typeof n.UNSAFE_componentWillUpdate&&bc.push(e))},fc.flushPendingUnsafeLifecycleWarnings=function(){var e=new Set;0.");var o="";null!=t&&e!==t&&(r=null,"number"==typeof t.tag?r=c(t):"string"==typeof t.name&&(r=t.name),r&&(o=" It was passed a child from "+r+".")),le(n,(function(){console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',a,o)}))}}};var ed,nd=bn(!0),td=bn(!1),rd=1,ld=2,ad=[],od=0,ud=0,id=0,sd=1,cd=2,dd=3,fd=!1,pd=!1,md=null,hd=!1,gd=d(null),yd=d(0),bd=d(null),vd=null,Sd=1,kd=2,wd=d(0),zd=0,xd=1,Ed=2,Cd=4,Pd=8,_d=new Set,Td=new Set,Rd=new Set,Nd=new Set,Ld=0,Ud=null,Dd=null,Id=null,Fd=!1,jd=!1,Ad=!1,Hd=0,Od=0,Md=null,Wd=0,Qd=25,Bd=null,$d=null,Vd=-1,qd=!1,Yd={readContext:he,use:it,useCallback:Jn,useContext:Jn,useEffect:Jn,useImperativeHandle:Jn,useLayoutEffect:Jn,useInsertionEffect:Jn,useMemo:Jn,useReducer:Jn,useRef:Jn,useState:Jn,useDebugValue:Jn,useDeferredValue:Jn,useTransition:Jn,useSyncExternalStore:Jn,useId:Jn,useHostTransitionStatus:Jn,useFormState:Jn,useActionState:Jn,useOptimistic:Jn,useMemoCache:Jn,useCacheRefresh:Jn};Yd.useEffectEvent=Jn;var Gd=null,Jd=null,Kd=null,Xd=null,Zd=null,ef=null,nf=null;Gd={readContext:function(e){return he(e)},use:it,useCallback:function(e,n){return Bd="useCallback",Vn(),Yn(n),Kt(e,n)},useContext:function(e){return Bd="useContext",Vn(),he(e)},useEffect:function(e,n){return Bd="useEffect",Vn(),Yn(n),Bt(e,n)},useImperativeHandle:function(e,n,t){return Bd="useImperativeHandle",Vn(),Yn(t),Gt(e,n,t)},useInsertionEffect:function(e,n){Bd="useInsertionEffect",Vn(),Yn(n),Wt(4,Ed,e,n)},useLayoutEffect:function(e,n){return Bd="useLayoutEffect",Vn(),Yn(n),qt(e,n)},useMemo:function(e,n){Bd="useMemo",Vn(),Yn(n);var t=Do.H;Do.H=Zd;try{return Zt(e,n)}finally{Do.H=t}},useReducer:function(e,n,t){Bd="useReducer",Vn();var r=Do.H;Do.H=Zd;try{return dt(e,n,t)}finally{Do.H=r}},useRef:function(e){return Bd="useRef",Vn(),Mt(e)},useState:function(e){Bd="useState",Vn();var n=Do.H;Do.H=Zd;try{return zt(e)}finally{Do.H=n}},useDebugValue:function(){Bd="useDebugValue",Vn()},useDeferredValue:function(e,n){return Bd="useDeferredValue",Vn(),nr(e,n)},useTransition:function(){return Bd="useTransition",Vn(),ir()},useSyncExternalStore:function(e,n,t){return Bd="useSyncExternalStore",Vn(),ht(e,n,t)},useId:function(){return Bd="useId",Vn(),fr()},useFormState:function(e,n){return Bd="useFormState",Vn(),Gn(),It(e,n)},useActionState:function(e,n){return Bd="useActionState",Vn(),It(e,n)},useOptimistic:function(e){return Bd="useOptimistic",Vn(),xt(e)},useHostTransitionStatus:dr,useMemoCache:st,useCacheRefresh:function(){return Bd="useCacheRefresh",Vn(),pr()},useEffectEvent:function(e){return Bd="useEffectEvent",Vn(),$t(e)}},Jd={readContext:function(e){return he(e)},use:it,useCallback:function(e,n){return Bd="useCallback",qn(),Kt(e,n)},useContext:function(e){return Bd="useContext",qn(),he(e)},useEffect:function(e,n){return Bd="useEffect",qn(),Bt(e,n)},useImperativeHandle:function(e,n,t){return Bd="useImperativeHandle",qn(),Gt(e,n,t)},useInsertionEffect:function(e,n){Bd="useInsertionEffect",qn(),Wt(4,Ed,e,n)},useLayoutEffect:function(e,n){return Bd="useLayoutEffect",qn(),qt(e,n)},useMemo:function(e,n){Bd="useMemo",qn();var t=Do.H;Do.H=Zd;try{return Zt(e,n)}finally{Do.H=t}},useReducer:function(e,n,t){Bd="useReducer",qn();var r=Do.H;Do.H=Zd;try{return dt(e,n,t)}finally{Do.H=r}},useRef:function(e){return Bd="useRef",qn(),Mt(e)},useState:function(e){Bd="useState",qn();var n=Do.H;Do.H=Zd;try{return zt(e)}finally{Do.H=n}},useDebugValue:function(){Bd="useDebugValue",qn()},useDeferredValue:function(e,n){return Bd="useDeferredValue",qn(),nr(e,n)},useTransition:function(){return Bd="useTransition",qn(),ir()},useSyncExternalStore:function(e,n,t){return Bd="useSyncExternalStore",qn(),ht(e,n,t)},useId:function(){return Bd="useId",qn(),fr()},useActionState:function(e,n){return Bd="useActionState",qn(),It(e,n)},useFormState:function(e,n){return Bd="useFormState",qn(),Gn(),It(e,n)},useOptimistic:function(e){return Bd="useOptimistic",qn(),xt(e)},useHostTransitionStatus:dr,useMemoCache:st,useCacheRefresh:function(){return Bd="useCacheRefresh",qn(),pr()},useEffectEvent:function(e){return Bd="useEffectEvent",qn(),$t(e)}},Kd={readContext:function(e){return he(e)},use:it,useCallback:function(e,n){return Bd="useCallback",qn(),Xt(e,n)},useContext:function(e){return Bd="useContext",qn(),he(e)},useEffect:function(e,n){Bd="useEffect",qn(),Qt(2048,Pd,e,n)},useImperativeHandle:function(e,n,t){return Bd="useImperativeHandle",qn(),Jt(e,n,t)},useInsertionEffect:function(e,n){return Bd="useInsertionEffect",qn(),Qt(4,Ed,e,n)},useLayoutEffect:function(e,n){return Bd="useLayoutEffect",qn(),Qt(4,Cd,e,n)},useMemo:function(e,n){Bd="useMemo",qn();var t=Do.H;Do.H=ef;try{return er(e,n)}finally{Do.H=t}},useReducer:function(e,n,t){Bd="useReducer",qn();var r=Do.H;Do.H=ef;try{return ft(e)}finally{Do.H=r}},useRef:function(){return Bd="useRef",qn(),ot().memoizedState},useState:function(){Bd="useState",qn();var e=Do.H;Do.H=ef;try{return ft(ct)}finally{Do.H=e}},useDebugValue:function(){Bd="useDebugValue",qn()},useDeferredValue:function(e,n){return Bd="useDeferredValue",qn(),tr(e,n)},useTransition:function(){return Bd="useTransition",qn(),sr()},useSyncExternalStore:function(e,n,t){return Bd="useSyncExternalStore",qn(),gt(e,n,t)},useId:function(){return Bd="useId",qn(),ot().memoizedState},useFormState:function(e){return Bd="useFormState",qn(),Gn(),Ft(e)},useActionState:function(e){return Bd="useActionState",qn(),Ft(e)},useOptimistic:function(e,n){return Bd="useOptimistic",qn(),Et(e,n)},useHostTransitionStatus:dr,useMemoCache:st,useCacheRefresh:function(){return Bd="useCacheRefresh",qn(),ot().memoizedState},useEffectEvent:function(e){return Bd="useEffectEvent",qn(),Vt(e)}},Xd={readContext:function(e){return he(e)},use:it,useCallback:function(e,n){return Bd="useCallback",qn(),Xt(e,n)},useContext:function(e){return Bd="useContext",qn(),he(e)},useEffect:function(e,n){Bd="useEffect",qn(),Qt(2048,Pd,e,n)},useImperativeHandle:function(e,n,t){return Bd="useImperativeHandle",qn(),Jt(e,n,t)},useInsertionEffect:function(e,n){return Bd="useInsertionEffect",qn(),Qt(4,Ed,e,n)},useLayoutEffect:function(e,n){return Bd="useLayoutEffect",qn(),Qt(4,Cd,e,n)},useMemo:function(e,n){Bd="useMemo",qn();var t=Do.H;Do.H=nf;try{return er(e,n)}finally{Do.H=t}},useReducer:function(e,n,t){Bd="useReducer",qn();var r=Do.H;Do.H=nf;try{return mt(e)}finally{Do.H=r}},useRef:function(){return Bd="useRef",qn(),ot().memoizedState},useState:function(){Bd="useState",qn();var e=Do.H;Do.H=nf;try{return mt(ct)}finally{Do.H=e}},useDebugValue:function(){Bd="useDebugValue",qn()},useDeferredValue:function(e,n){return Bd="useDeferredValue",qn(),rr(e,n)},useTransition:function(){return Bd="useTransition",qn(),cr()},useSyncExternalStore:function(e,n,t){return Bd="useSyncExternalStore",qn(),gt(e,n,t)},useId:function(){return Bd="useId",qn(),ot().memoizedState},useFormState:function(e){return Bd="useFormState",qn(),Gn(),Ht(e)},useActionState:function(e){return Bd="useActionState",qn(),Ht(e)},useOptimistic:function(e,n){return Bd="useOptimistic",qn(),Pt(e,n)},useHostTransitionStatus:dr,useMemoCache:st,useCacheRefresh:function(){return Bd="useCacheRefresh",qn(),ot().memoizedState},useEffectEvent:function(e){return Bd="useEffectEvent",qn(),Vt(e)}},Zd={readContext:function(e){return l(),he(e)},use:function(e){return r(),it(e)},useCallback:function(e,n){return Bd="useCallback",r(),Vn(),Kt(e,n)},useContext:function(e){return Bd="useContext",r(),Vn(),he(e)},useEffect:function(e,n){return Bd="useEffect",r(),Vn(),Bt(e,n)},useImperativeHandle:function(e,n,t){return Bd="useImperativeHandle",r(),Vn(),Gt(e,n,t)},useInsertionEffect:function(e,n){Bd="useInsertionEffect",r(),Vn(),Wt(4,Ed,e,n)},useLayoutEffect:function(e,n){return Bd="useLayoutEffect",r(),Vn(),qt(e,n)},useMemo:function(e,n){Bd="useMemo",r(),Vn();var t=Do.H;Do.H=Zd;try{return Zt(e,n)}finally{Do.H=t}},useReducer:function(e,n,t){Bd="useReducer",r(),Vn();var l=Do.H;Do.H=Zd;try{return dt(e,n,t)}finally{Do.H=l}},useRef:function(e){return Bd="useRef",r(),Vn(),Mt(e)},useState:function(e){Bd="useState",r(),Vn();var n=Do.H;Do.H=Zd;try{return zt(e)}finally{Do.H=n}},useDebugValue:function(){Bd="useDebugValue",r(),Vn()},useDeferredValue:function(e,n){return Bd="useDeferredValue",r(),Vn(),nr(e,n)},useTransition:function(){return Bd="useTransition",r(),Vn(),ir()},useSyncExternalStore:function(e,n,t){return Bd="useSyncExternalStore",r(),Vn(),ht(e,n,t)},useId:function(){return Bd="useId",r(),Vn(),fr()},useFormState:function(e,n){return Bd="useFormState",r(),Vn(),It(e,n)},useActionState:function(e,n){return Bd="useActionState",r(),Vn(),It(e,n)},useOptimistic:function(e){return Bd="useOptimistic",r(),Vn(),xt(e)},useMemoCache:function(e){return r(),st(e)},useHostTransitionStatus:dr,useCacheRefresh:function(){return Bd="useCacheRefresh",Vn(),pr()},useEffectEvent:function(e){return Bd="useEffectEvent",r(),Vn(),$t(e)}},ef={readContext:function(e){return l(),he(e)},use:function(e){return r(),it(e)},useCallback:function(e,n){return Bd="useCallback",r(),qn(),Xt(e,n)},useContext:function(e){return Bd="useContext",r(),qn(),he(e)},useEffect:function(e,n){Bd="useEffect",r(),qn(),Qt(2048,Pd,e,n)},useImperativeHandle:function(e,n,t){return Bd="useImperativeHandle",r(),qn(),Jt(e,n,t)},useInsertionEffect:function(e,n){return Bd="useInsertionEffect",r(),qn(),Qt(4,Ed,e,n)},useLayoutEffect:function(e,n){return Bd="useLayoutEffect",r(),qn(),Qt(4,Cd,e,n)},useMemo:function(e,n){Bd="useMemo",r(),qn();var t=Do.H;Do.H=ef;try{return er(e,n)}finally{Do.H=t}},useReducer:function(e,n,t){Bd="useReducer",r(),qn();var l=Do.H;Do.H=ef;try{return ft(e)}finally{Do.H=l}},useRef:function(){return Bd="useRef",r(),qn(),ot().memoizedState},useState:function(){Bd="useState",r(),qn();var e=Do.H;Do.H=ef;try{return ft(ct)}finally{Do.H=e}},useDebugValue:function(){Bd="useDebugValue",r(),qn()},useDeferredValue:function(e,n){return Bd="useDeferredValue",r(),qn(),tr(e,n)},useTransition:function(){return Bd="useTransition",r(),qn(),sr()},useSyncExternalStore:function(e,n,t){return Bd="useSyncExternalStore",r(),qn(),gt(e,n,t)},useId:function(){return Bd="useId",r(),qn(),ot().memoizedState},useFormState:function(e){return Bd="useFormState",r(),qn(),Ft(e)},useActionState:function(e){return Bd="useActionState",r(),qn(),Ft(e)},useOptimistic:function(e,n){return Bd="useOptimistic",r(),qn(),Et(e,n)},useMemoCache:function(e){return r(),st(e)},useHostTransitionStatus:dr,useCacheRefresh:function(){return Bd="useCacheRefresh",qn(),ot().memoizedState},useEffectEvent:function(e){return Bd="useEffectEvent",r(),qn(),Vt(e)}},nf={readContext:function(e){return l(),he(e)},use:function(e){return r(),it(e)},useCallback:function(e,n){return Bd="useCallback",r(),qn(),Xt(e,n)},useContext:function(e){return Bd="useContext",r(),qn(),he(e)},useEffect:function(e,n){Bd="useEffect",r(),qn(),Qt(2048,Pd,e,n)},useImperativeHandle:function(e,n,t){return Bd="useImperativeHandle",r(),qn(),Jt(e,n,t)},useInsertionEffect:function(e,n){return Bd="useInsertionEffect",r(),qn(),Qt(4,Ed,e,n)},useLayoutEffect:function(e,n){return Bd="useLayoutEffect",r(),qn(),Qt(4,Cd,e,n)},useMemo:function(e,n){Bd="useMemo",r(),qn();var t=Do.H;Do.H=ef;try{return er(e,n)}finally{Do.H=t}},useReducer:function(e,n,t){Bd="useReducer",r(),qn();var l=Do.H;Do.H=ef;try{return mt(e)}finally{Do.H=l}},useRef:function(){return Bd="useRef",r(),qn(),ot().memoizedState},useState:function(){Bd="useState",r(),qn();var e=Do.H;Do.H=ef;try{return mt(ct)}finally{Do.H=e}},useDebugValue:function(){Bd="useDebugValue",r(),qn()},useDeferredValue:function(e,n){return Bd="useDeferredValue",r(),qn(),rr(e,n)},useTransition:function(){return Bd="useTransition",r(),qn(),cr()},useSyncExternalStore:function(e,n,t){return Bd="useSyncExternalStore",r(),qn(),gt(e,n,t)},useId:function(){return Bd="useId",r(),qn(),ot().memoizedState},useFormState:function(e){return Bd="useFormState",r(),qn(),Ht(e)},useActionState:function(e){return Bd="useActionState",r(),qn(),Ht(e)},useOptimistic:function(e,n){return Bd="useOptimistic",r(),qn(),Pt(e,n)},useMemoCache:function(e){return r(),st(e)},useHostTransitionStatus:dr,useCacheRefresh:function(){return Bd="useCacheRefresh",qn(),ot().memoizedState},useEffectEvent:function(e){return Bd="useEffectEvent",r(),qn(),Vt(e)}};var tf={},rf=new Set,lf=new Set,af=new Set,of=new Set,uf=new Set,sf=new Set,cf=new Set,df=new Set,ff=new Set,pf=new Set;Object.freeze(tf);var mf={enqueueSetState:function(e,n,t){var r=da(e=e._reactInternals),l=_n(r);l.payload=n,null!=t&&(wr(t),l.callback=t),null!==(n=Tn(e,l,r))&&(ke(r,"this.setState()",e),pa(n,e,r),Rn(n,e,r))},enqueueReplaceState:function(e,n,t){var r=da(e=e._reactInternals),l=_n(r);l.tag=sd,l.payload=n,null!=t&&(wr(t),l.callback=t),null!==(n=Tn(e,l,r))&&(ke(r,"this.replaceState()",e),pa(n,e,r),Rn(n,e,r))},enqueueForceUpdate:function(e,n){var t=da(e=e._reactInternals),r=_n(t);r.tag=cd,null!=n&&(wr(n),r.callback=n),null!==(n=Tn(e,r,t))&&(ke(t,"this.forceUpdate()",e),pa(n,e,t),Rn(n,e,t))}},hf=Error("This is not a real error. It's an implementation detail of React's selective hydration feature. If this leaks into userspace, it's a bug in React. Please file an issue."),gf=!1,yf={},bf={},vf={},Sf={},kf=!1,wf={},zf={},xf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},Ef=!1,Cf=null;Cf=new Set;var Pf=!1,_f=!1,Tf=!1,Rf="function"==typeof WeakSet?WeakSet:Set,Nf=null,Lf=null,Uf=null,Df=null,If=!1,Ff=null,jf=!1,Af=8192,Hf={getCacheForType:function(e){var n=he(fs),t=n.data.get(e);return void 0===t&&(t=e(),n.data.set(e,t)),t},cacheSignal:function(){return he(fs).controller.signal},getOwner:function(){return Xi}};if("function"==typeof Symbol&&Symbol.for){var Of=Symbol.for;Of("selector.component"),Of("selector.has_pseudo_class"),Of("selector.role"),Of("selector.test_id"),Of("selector.text")}var Mf="function"==typeof WeakMap?WeakMap:Map,Wf=0,Qf=2,Bf=4,$f=0,Vf=1,qf=2,Yf=3,Gf=4,Jf=6,Kf=5,Xf=Wf,Zf=null,ep=null,np=0,tp=0,rp=1,lp=2,ap=3,op=4,up=5,ip=6,sp=7,cp=8,dp=9,fp=tp,pp=null,mp=!1,hp=!1,gp=!1,yp=0,bp=$f,vp=0,Sp=0,kp=0,wp=0,zp=0,xp=null,Ep=null,Cp=!1,Pp=0,_p=0,Tp=300,Rp=1/0,Np=500,Lp=null,Up=null,Dp=null,Ip=0,Fp=1,jp=2,Ap=3,Hp=0,Op=1,Mp=2,Wp=3,Qp=4,Bp=5,$p=0,Vp=null,qp=null,Yp=0,Gp=0,Jp=-0,Kp=null,Xp=null,Zp=null,em=Ip,nm=null,tm=50,rm=0,lm=null,am=!1,om=!1,um=50,im=0,sm=null,cm=!1,dm=null,fm=!1,pm=new Set,mm=!1;try{var hm=Object.preventExtensions({});new Map([[hm,null]]),new Set([hm])}catch(e){mm=!0}var gm=!1;return fo.createContainer=function(e,n,r,l,a,o,u,i,s,c){return function(e,n,r,l,a,o,u,i,s,c,d,f){return e=new so(e,n,r,u,s,c,d,f,null),n=1,!0===o&&(n|=24),o=t(3,null,null,2|n),e.current=o,o.stateNode=e,ve(n=be()),e.pooledCache=n,ve(n),o.memoizedState={element:l,isDehydrated:r,cache:n},Cn(o),e}(e,n,!1,null,0,l,o,0,u,i,s,c)},fo.flushSyncWork=function(){return(Xf&(Qf|Bf))!==Wf||(Me(0),!1)},fo.updateContainer=function(e,n,t,r){var l=n.current,a=da(l);return co(l,a,e,n,t,r),a},fo.updateContainerSync=function(e,n,t,r){return co(n.current,2,e,n,t,r),2},fo},n.exports.default=n.exports,Object.defineProperty(n.exports,"__esModule",{value:!0}))),c.exports;var n}();var d,f=t(a.exports),p={exports:{}},m={};var h,g={}; +/** + * @license React + * react-reconciler-constants.development.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */"production"===process.env.NODE_ENV?p.exports=(d||(d=1,m.ConcurrentRoot=1,m.ContinuousEventPriority=8,m.DefaultEventPriority=32,m.DiscreteEventPriority=2,m.IdleEventPriority=268435456,m.LegacyRoot=0,m.NoEventPriority=0),m):p.exports=(h||(h=1,"production"!==process.env.NODE_ENV&&(g.ConcurrentRoot=1,g.ContinuousEventPriority=8,g.DefaultEventPriority=32,g.DiscreteEventPriority=2,g.IdleEventPriority=268435456,g.LegacyRoot=0,g.NoEventPriority=0)),g);var y=p.exports;const b=(e,n)=>{const t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;for(let r=0;r{const c=f({appendChild:e,appendChildToContainer:n,appendInitialChild:e,createInstance:l,createTextInstance:a,insertBefore:o,commitUpdate:(e,n,t,l)=>{b(t,l)||r(e,null,n,t,l)},commitTextUpdate:t,removeChild:u,removeChildFromContainer:i,resetAfterCommit:s,noTimeout:-1,shouldSetTextContent:()=>!1,finalizeInitialChildren:()=>!1,getPublicInstance:e=>e,getRootHostContext:()=>v,getChildHostContext:()=>v,prepareForCommit(){},clearContainer(){},resetTextContent(){},getCurrentUpdatePriority:()=>y.DefaultEventPriority,maySuspendCommit:()=>!1,requestPostPaintCallback:()=>{},resolveUpdatePriority:()=>y.DefaultEventPriority,setCurrentUpdatePriority:()=>{},shouldAttemptEagerTransition:()=>!1,detachDeletedInstance:()=>{},resolveEventTimeStamp:()=>{},resolveEventType:()=>{},trackSchedulerEvent:()=>{}});return{createContainer:e=>c.createContainer(e,y.ConcurrentRoot,null,!1,null,"",S,S,S,(()=>{}),null),updateContainer:(e,n,t,r)=>{c.updateContainerSync(e,n,t,r),c.flushSyncWork()}}};export{k as default}; diff --git a/node_modules/@react-pdf/reconciler/package.json b/node_modules/@react-pdf/reconciler/package.json new file mode 100644 index 0000000000000000000000000000000000000000..cf34112d328ba770cd686f2d477607cfdc629b23 --- /dev/null +++ b/node_modules/@react-pdf/reconciler/package.json @@ -0,0 +1,40 @@ +{ + "name": "@react-pdf/reconciler", + "version": "2.0.0", + "license": "MIT", + "description": "Define uninitialized elements", + "author": "Diego Muracciole ", + "homepage": "https://github.com/diegomura/react-pdf#readme", + "type": "module", + "main": "./lib/index.js", + "types": "./lib/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/diegomura/react-pdf.git", + "directory": "packages/reconciler" + }, + "scripts": { + "build": "rimraf ./lib && rollup -c", + "watch": "rimraf ./lib && rollup -c -w", + "size": "size-limit", + "lint": "eslint src", + "test": "vitest" + }, + "files": [ + "lib" + ], + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "dependencies": { + "object-assign": "^4.1.1", + "scheduler": "0.25.0-rc-603e6108-20241029" + }, + "devDependencies": { + "ast-types": "^0.14.2", + "react-reconciler-23": "npm:react-reconciler@0.23.0", + "react-reconciler-31": "npm:react-reconciler@0.31.0-rc-603e6108-20241029", + "react-reconciler-33": "npm:react-reconciler@0.33.0", + "recast": "^0.23.9" + } +} diff --git a/node_modules/@react-pdf/render/README.md b/node_modules/@react-pdf/render/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a9a17322da2909b8c9fc5a8e668ce6879b81e11b --- /dev/null +++ b/node_modules/@react-pdf/render/README.md @@ -0,0 +1,145 @@ +

+ +

+ +# @react-pdf/render + +> React-pdf render engine + +## How to install + +```sh +yarn add @react-pdf/render +``` + +## How it works + +```js +import render from '@react-pdf/render'; +import primitives from '@react-pdf/primitives'; + +const view = { + type: primitives.View, + style: { + backgroundColor: 'red', + borderTopLeftRadius: 5, + borderTopRightRadius: 10, + borderBottomLeftRadius: 0, + borderBottomRightRadius: 15, + borderTopColor: 'yellow', + borderLeftColor: 'green', + borderBottomColor: 'black', + borderRightColor: 'purple', + }, + box: { + left: 20, + top: 20, + width: 100, + height: 80, + borderTopWidth: 3, + borderLeftWidth: 2, + borderBottomWidth: 1, + borderRightWidth: 4, + }, +}; + +const doc = { + type: primitives.Document, + children: [ + { + type: primitives.Page, + box: { width: 400, height: 600 }, + children: [view], + }, + ], +}; + +// Provide your own context +const ctx = createContext(); + +render.default(ctx, doc); +``` + +This library exports a `render` function that takes two arguments: + +- _ctx_: This is the target context where the document is going to be rendered. React-pdf currently uses a [pdfkit](https://github.com/react-pdf/pdfkit) document as context, but it can target any other type of structure as long as it signature matches pdfkit API. In the future this will enable rendering documents into muliple formats in addition to PDF. +- _node_: Document root node. A node is a nested structure that defines a single element in a document. They are defined by it's `type` and arguments. + +## Node structure + +A node represents a single element inside a document. It's mainly defined by it's `type` (mandatory) field in addition to other values to define where that element is positioned inside the document (`box`), how it looks (`style`), how it should behave (`params`) and what sub-nodes it contains (`children`). + +The root node must always be of type `DOCUMENT`, containing as many `PAGE` nodes as desired inside it's children field. + +Bare in mind this package does not handle any type of node positioning, inheritance, style transformations or any other layout related logic. It's role is limited to render exactly the node it get's into the provided context. Take this into account when definig styles as `paddingTop`, `paddingLeft` and so on instead of the shortcut `padding`. For layout or styles transformation this project provides separate packages. + +### node.type + +Mandatory field specifiying the type of the particular node. The full list of types can be found and imported from `@react-pdf/primitives` + +### node.box + +Defines bounding box where a particular node is located inside a document + +- left +- top +- width +- height +- paddingTop +- paddingLeft +- paddingBottom +- paddingRight +- marginTop +- marginLeft +- marginBottom +- marginRight +- borderTopWidth +- borderLeftWidth +- borderBottomWidth +- borderRightWidth + +### node.style + +Defines how the node looks like. There are some types of nodes that expect special style values, but generally all support: + +- color +- opacity +- overflow +- backgroundColor +- borderTopLeftRadius +- borderTopRightRadius +- borderBottomLeftRadius +- borderBottomRightRadius +- borderTopColor +- borderLeftColor +- borderBottomColor +- borderRightColor +- _others..._ + +### node.props + +Specific node params needed to render correctly ot behave like certain way. Specially needed for SVG nodes + +## PDF example + +```js +import fs from 'fs'; +import render from '@react-pdf/render'; +import pdfkit from '@react-pdf/pdfkit'; + +const PDFDocument = pdfkit.default; + +const ctx = new PDFDocument({ autoFirstPage: false }); + +const doc = {}; // See above + +render.default(ctx, doc); + +const stream = fs.createWriteStream('./test.pdf'); + +ctx.pipe(stream); +``` + +## License + +MIT © [Diego Muracciole](http://github.com/diegomura) diff --git a/node_modules/@react-pdf/render/lib/index.d.ts b/node_modules/@react-pdf/render/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f71641d149b047568dcced2f58a00060aa6d4f4d --- /dev/null +++ b/node_modules/@react-pdf/render/lib/index.d.ts @@ -0,0 +1,23 @@ +/// +import { SafeDocumentNode } from '@react-pdf/layout'; +import { Font } from '@react-pdf/textkit'; +import PDFKitDocument from 'pdfkit'; + +type PDFFontSource = string | Buffer | Uint8Array | ArrayBuffer | Font; +type Context = typeof PDFKitDocument & { + _root: any; + _font: any; + _imageRegistry: any; + _acroform: any; + _fontSize: number; + openImage: any; + addNamedDestination: any; + addPage(options?: any): Context; + translate(x: number, y: number, options: any): Context; + font(src: PDFFontSource, size?: number): Context; + font(src: PDFFontSource, family: string, size?: number): Context; +}; + +declare const render: (ctx: Context, doc: SafeDocumentNode) => Context; + +export { render as default }; diff --git a/node_modules/@react-pdf/render/lib/index.js b/node_modules/@react-pdf/render/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..028cf374f1a58c341eaee8ade5e5e2143254a723 --- /dev/null +++ b/node_modules/@react-pdf/render/lib/index.js @@ -0,0 +1,2508 @@ +import * as P from '@react-pdf/primitives'; +import { isNil, matchPercent } from '@react-pdf/fns'; +import absPath from 'abs-svg-path'; +import parsePath from 'parse-svg-path'; +import normalizePath from 'normalize-svg-path'; +import colorString from 'color-string'; + +const renderPath = (ctx, node) => { + const d = node.props?.d; + if (d) + ctx.path(node.props.d); +}; + +const KAPPA$3 = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0); +const renderRect = (ctx, node) => { + const x = node.props?.x || 0; + const y = node.props?.y || 0; + const rx = node.props?.rx || 0; + const ry = node.props?.ry || 0; + const width = node.props?.width || 0; + const height = node.props?.height || 0; + if (!width || !height) + return; + if (rx && ry) { + const krx = rx * KAPPA$3; + const kry = ry * KAPPA$3; + ctx.moveTo(x + rx, y); + ctx.lineTo(x - rx + width, y); + ctx.bezierCurveTo(x - rx + width + krx, y, x + width, y + ry - kry, x + width, y + ry); + ctx.lineTo(x + width, y + height - ry); + ctx.bezierCurveTo(x + width, y + height - ry + kry, x - rx + width + krx, y + height, x - rx + width, y + height); + ctx.lineTo(x + rx, y + height); + ctx.bezierCurveTo(x + rx - krx, y + height, x, y + height - ry + kry, x, y + height - ry); + ctx.lineTo(x, y + ry); + ctx.bezierCurveTo(x, y + ry - kry, x + rx - krx, y, x + rx, y); + } + else { + ctx.moveTo(x, y); + ctx.lineTo(x + width, y); + ctx.lineTo(x + width, y + height); + ctx.lineTo(x, y + height); + } + ctx.closePath(); +}; + +const renderLine$1 = (ctx, node) => { + const { x1, x2, y1, y2 } = node.props || {}; + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); +}; + +const renderGroup = () => { + // noop +}; + +const KAPPA$2 = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0); +const drawEllipse = (ctx, rx, ry, cx = 0, cy = 0) => { + const x = cx - rx; + const y = cy - ry; + const ox = rx * KAPPA$2; + const oy = ry * KAPPA$2; + const xe = x + rx * 2; + const ye = y + ry * 2; + const xm = x + rx; + const ym = y + ry; + ctx.moveTo(x, ym); + ctx.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y); + ctx.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym); + ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye); + ctx.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym); + ctx.closePath(); +}; +const renderEllipse = (ctx, node) => { + const { cx, cy, rx, ry } = node.props || {}; + drawEllipse(ctx, rx, ry, cx, cy); +}; + +const renderCircle = (ctx, node) => { + const cx = node.props?.cx; + const cy = node.props?.cy; + const r = node.props?.r; + drawEllipse(ctx, r, r, cx, cy); +}; + +const encodeGlyphs = (font, glyphs) => { + // Embedded font path (has font subset) + if (font.subset) { + const res = []; + for (let i = 0; i < glyphs.length; i++) { + const glyph = glyphs[i]; + const gid = font.subset.includeGlyph(glyph.id); + res.push(`0000${gid.toString(16)}`.slice(-4)); + if (font.widths[gid] == null) { + font.widths[gid] = glyph.advanceWidth * font.scale; + } + if (font.unicode[gid] == null) { + font.unicode[gid] = glyph.codePoints; + } + } + return res; + } + // Standard font path + const res = []; + for (const glyph of glyphs) { + res.push(`00${glyph.id.toString(16)}`.slice(-2)); + } + return res; +}; + +/* eslint-disable no-return-assign */ +const number = (n) => { + if (n > -1e21 && n < 1e21) { + return Math.round(n * 1e6) / 1e6; + } + throw new Error(`unsupported number: ${n}`); +}; +const _renderGlyphs = (ctx, encoded, positions, x, y) => { + const commands = []; + const scale = ctx._fontSize / 1000; + let i; + let last = 0; + let hadOffset = false; + ctx.save(); + // flip coordinate system + ctx.transform(1, 0, 0, -1, 0, ctx.page.height); + y = ctx.page.height - y; + // add current font to page if necessary + if (ctx.page.fonts[ctx._font.id] == null) { + ctx.page.fonts[ctx._font.id] = ctx._font.ref(); + } + // begin the text object + ctx.addContent('BT'); + // text position + ctx.addContent(`1 0 0 1 ${number(x)} ${number(y)} Tm`); + // font and font size + ctx.addContent(`/${ctx._font.id} ${number(ctx._fontSize)} Tf`); + // Adds a segment of text to the TJ command buffer + const addSegment = (cur) => { + if (last < cur) { + const hex = encoded.slice(last, cur).join(''); + const advance = positions[cur - 1].xAdvance - positions[cur - 1].advanceWidth; + commands.push(`<${hex}> ${number(-advance)}`); + } + return (last = cur); + }; + // Flushes the current TJ commands to the output stream + const flush = (s) => { + addSegment(s); + if (commands.length > 0) { + ctx.addContent(`[${commands.join(' ')}] TJ`); + return (commands.length = 0); + } + }; + for (i = 0; i < positions.length; i += 1) { + // If we have an x or y offset, we have to break out of the current TJ command + // so we can move the text position. + const pos = positions[i]; + if (pos.xOffset || pos.yOffset) { + // Flush the current buffer + flush(i); + // Move the text position and flush just the current character + ctx.addContent(`1 0 0 1 ${number(x + pos.xOffset * scale)} ${number(y + pos.yOffset * scale)} Tm`); + flush(i + 1); + hadOffset = true; + } + else { + // If the last character had an offset, reset the text position + if (hadOffset) { + ctx.addContent(`1 0 0 1 ${number(x)} ${number(y)} Tm`); + hadOffset = false; + } + // Group segments that don't have any advance adjustments + if (pos.xAdvance - pos.advanceWidth !== 0) { + addSegment(i + 1); + } + } + x += pos.xAdvance * scale; + } + // Flush any remaining commands + flush(i); + // end the text object + ctx.addContent('ET'); + // restore flipped coordinate system + return ctx.restore(); +}; +const renderGlyphs = (ctx, glyphs, positions, x, y) => { + const scale = 1000 / ctx._fontSize; + const unitsPerEm = ctx._font.font.unitsPerEm || 1000; + const advanceWidthScale = 1000 / unitsPerEm; + // Glyph encoding and positioning + const encodedGlyphs = encodeGlyphs(ctx._font, glyphs); + const encodedPositions = positions.map((pos, i) => ({ + xAdvance: pos.xAdvance * scale, + yAdvance: pos.yAdvance * scale, + xOffset: pos.xOffset, + yOffset: pos.yOffset, + advanceWidth: glyphs[i].advanceWidth * advanceWidthScale, + })); + return _renderGlyphs(ctx, encodedGlyphs, encodedPositions, x, y); +}; + +const renderRun$1 = (ctx, run) => { + if (!run.glyphs) + return; + if (!run.positions) + return; + const runAdvanceWidth = run.xAdvance; + const font = run.attributes.font?.[0]; + const { fontSize, color, opacity } = run.attributes; + if (color) + ctx.fillColor(color); + ctx.fillOpacity(opacity); + if (font) { + ctx.font(font.type === 'STANDARD' ? font.fullName : font, fontSize); + } + try { + renderGlyphs(ctx, run.glyphs, run.positions, 0, 0); + } + catch (error) { + console.log(error); + } + ctx.translate(runAdvanceWidth, 0); +}; +const renderSpan = (ctx, line, textAnchor, dominantBaseline) => { + ctx.save(); + const x = line.box?.x || 0; + const y = line.box?.y || 0; + const font = line.runs[0]?.attributes.font?.[0]; + const scale = line.runs[0]?.attributes?.scale || 1; + const width = line.xAdvance; + if (!font) + return; + const ascent = font.ascent * scale; + const xHeight = font.xHeight * scale; + const descent = font.descent * scale; + const capHeight = font.capHeight * scale; + let xTranslate = x; + let yTranslate = y; + switch (textAnchor) { + case 'middle': + xTranslate = x - width / 2; + break; + case 'end': + xTranslate = x - width; + break; + default: + xTranslate = x; + break; + } + switch (dominantBaseline) { + case 'middle': + case 'central': + yTranslate = y + capHeight / 2; + break; + case 'hanging': + yTranslate = y + capHeight; + break; + case 'mathematical': + yTranslate = y + xHeight; + break; + case 'text-after-edge': + yTranslate = y + descent; + break; + case 'text-before-edge': + yTranslate = y + ascent; + break; + default: + yTranslate = y; + break; + } + ctx.translate(xTranslate, yTranslate); + line.runs.forEach((run) => renderRun$1(ctx, run)); + ctx.restore(); +}; +const renderSvgText = (ctx, node) => { + const children = node.children; + children.forEach((span) => renderSpan(ctx, span.lines[0], span.props.textAnchor, span.props.dominantBaseline)); +}; + +const pairs = (values) => { + const result = []; + for (let i = 0; i < values.length; i += 2) { + result.push([values[i], values[i + 1]]); + } + return result; +}; +/** + * Parse svg-like points into number arrays + * + * @param points string ex. "20,30 50,60" + * @returns points array ex. [[20, 30], [50, 60]] + */ +const parsePoints = (points) => { + let values = (points || '') + .trim() + .replace(/,/g, ' ') + .replace(/(\d)-(\d)/g, '$1 -$2') + .split(/\s+/); + if (values.length % 2 !== 0) { + values = values.slice(0, -1); + } + const mappedValues = values.map(parseFloat); + return pairs(mappedValues); +}; + +const drawPolyline = (ctx, points) => { + if (points.length > 0) { + ctx.moveTo(points[0][0], points[0][1]); + points.slice(1).forEach((p) => ctx.lineTo(p[0], p[1])); + } +}; +const renderPolyline = (ctx, node) => { + const points = parsePoints(node.props.points || ''); + drawPolyline(ctx, points); +}; + +const renderPolygon = (ctx, node) => { + const points = parsePoints(node.props.points || ''); + drawPolyline(ctx, points); + ctx.closePath(); +}; + +const renderImage$1 = (ctx, node) => { + if (!node.box) + return; + if (!node.image?.data) + return; + const { x = 0, y = 0 } = node.props; + const { width, height, opacity } = node.style; + const paddingTop = node.box.paddingLeft || 0; + const paddingLeft = node.box.paddingLeft || 0; + if (width === 0 || height === 0) { + console.warn(`Image with src '${node.props.href}' skipped due to invalid dimensions`); + return; + } + if (typeof width === 'string' || typeof height === 'string') { + console.warn(`Image with src '${node.props.href}' skipped due to percentage width or height`); + return; + } + ctx.save(); + ctx + .fillOpacity(opacity || 1) + .image(node.image.data, x + paddingLeft, y + paddingTop, { + width, + height, + }); + ctx.restore(); +}; + +// This constant is used to approximate a symmetrical arc using a cubic +// Bezier curve. +const KAPPA$1 = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0); +const clipNode = (ctx, node) => { + if (!node.box) + return; + if (!node.style) + return; + const { top, left, width, height } = node.box; + const { borderTopLeftRadius = 0, borderTopRightRadius = 0, borderBottomRightRadius = 0, borderBottomLeftRadius = 0, } = node.style; + // Border top + // @ts-expect-error this is always a number due to resolve border radius step + const rtr = Math.min(borderTopRightRadius, 0.5 * width, 0.5 * height); + const ctr = rtr * (1.0 - KAPPA$1); + ctx.moveTo(left + rtr, top); + ctx.lineTo(left + width - rtr, top); + ctx.bezierCurveTo(left + width - ctr, top, left + width, top + ctr, left + width, top + rtr); + // Border right + // @ts-expect-error this is always a number due to resolve border radius step + const rbr = Math.min(borderBottomRightRadius, 0.5 * width, 0.5 * height); + const cbr = rbr * (1.0 - KAPPA$1); + ctx.lineTo(left + width, top + height - rbr); + ctx.bezierCurveTo(left + width, top + height - cbr, left + width - cbr, top + height, left + width - rbr, top + height); + // Border bottom + // @ts-expect-error this is always a number due to resolve border radius step + const rbl = Math.min(borderBottomLeftRadius, 0.5 * width, 0.5 * height); + const cbl = rbl * (1.0 - KAPPA$1); + ctx.lineTo(left + rbl, top + height); + ctx.bezierCurveTo(left + cbl, top + height, left, top + height - cbl, left, top + height - rbl); + // Border left + // @ts-expect-error this is always a number due to resolve border radius step + const rtl = Math.min(borderTopLeftRadius, 0.5 * width, 0.5 * height); + const ctl = rtl * (1.0 - KAPPA$1); + ctx.lineTo(left, top + rtl); + ctx.bezierCurveTo(left, top + ctl, left + ctl, top, left + rtl, top); + ctx.closePath(); + ctx.clip(); +}; + +const applySingleTransformation = (ctx, transform, origin) => { + const { operation, value } = transform; + switch (operation) { + case 'scale': { + const [scaleX, scaleY] = value; + ctx.scale(scaleX, scaleY, { origin }); + break; + } + case 'rotate': { + const [angle, cx, cy] = value; + ctx.translate(cx, cy); + ctx.rotate(angle, { origin }); + ctx.translate(-cx, -cy); + break; + } + case 'translate': { + const [x, y = 0] = value; + ctx.translate(x, y, { origin }); + break; + } + case 'skew': { + const [xAngle = 0, yAngle = 0] = value; + const radx = (xAngle * Math.PI) / 180; + const rady = (yAngle * Math.PI) / 180; + const tanx = Math.tan(radx); + const tany = Math.tan(rady); + let x = 0; + let y = 0; + if (origin != null) { + [x, y] = Array.from(origin); + const x1 = x + tanx * y; + const y1 = y + tany * x; + x -= x1; + y -= y1; + } + ctx.transform(1, tany, tanx, 1, x, y); + break; + } + case 'matrix': { + ctx.transform(...value); + break; + } + default: { + console.error(`Transform operation: '${operation}' doesn't supported`); + } + } +}; +const applyTransformations = (ctx, node) => { + if (!node.origin) + return; + const { props, style } = node; + const origin = [node.origin.left, node.origin.top]; + const propsTransform = 'transform' in props ? props.transform : undefined; + const operations = style?.transform || propsTransform || []; + operations.forEach((operation) => { + applySingleTransformation(ctx, operation, origin); + }); +}; + +// From https://github.com/dy/svg-path-bounds/blob/master/index.js +const getPathBoundingBox = (node) => { + const path = normalizePath(absPath(parsePath(node.props?.d || ''))); + if (!path.length) + return [0, 0, 0, 0]; + const bounds = [Infinity, Infinity, -Infinity, -Infinity]; + for (let i = 0, l = path.length; i < l; i += 1) { + const points = path[i].slice(1); + for (let j = 0; j < points.length; j += 2) { + if (points[j + 0] < bounds[0]) + bounds[0] = points[j + 0]; + if (points[j + 1] < bounds[1]) + bounds[1] = points[j + 1]; + if (points[j + 0] > bounds[2]) + bounds[2] = points[j + 0]; + if (points[j + 1] > bounds[3]) + bounds[3] = points[j + 1]; + } + } + return bounds; +}; +const getCircleBoundingBox = (node) => { + const r = node.props?.r || 0; + const cx = node.props?.cx || 0; + const cy = node.props?.cy || 0; + return [cx - r, cy - r, cx + r, cy + r]; +}; +const getEllipseBoundingBox = (node) => { + const cx = node.props?.cx || 0; + const cy = node.props?.cy || 0; + const rx = node.props?.rx || 0; + const ry = node.props?.ry || 0; + return [cx - rx, cy - ry, cx + rx, cy + ry]; +}; +const getLineBoundingBox = (node) => { + const x1 = node.props?.x1 || 0; + const y1 = node.props?.y1 || 0; + const x2 = node.props?.x2 || 0; + const y2 = node.props?.y2 || 0; + return [ + Math.min(x1, x2), + Math.min(y1, y2), + Math.max(x1, x2), + Math.max(y1, y2), + ]; +}; +const getRectBoundingBox = (node) => { + const x = node.props?.x || 0; + const y = node.props?.y || 0; + const width = node.props?.width || 0; + const height = node.props?.height || 0; + return [x, y, x + width, y + height]; +}; +const max = (values) => Math.max(-Infinity, ...values); +const min = (values) => Math.min(Infinity, ...values); +const getPolylineBoundingBox = (node) => { + const points = parsePoints(node.props?.points); + const xValues = points.map((p) => p[0]); + const yValues = points.map((p) => p[1]); + return [min(xValues), min(yValues), max(xValues), max(yValues)]; +}; +const boundingBoxFns = { + [P.Rect]: getRectBoundingBox, + [P.Line]: getLineBoundingBox, + [P.Path]: getPathBoundingBox, + [P.Circle]: getCircleBoundingBox, + [P.Ellipse]: getEllipseBoundingBox, + [P.Polygon]: getPolylineBoundingBox, + [P.Polyline]: getPolylineBoundingBox, +}; +const getBoundingBox = (node) => { + const boundingBoxFn = boundingBoxFns[node.type]; + return boundingBoxFn ? boundingBoxFn(node) : [0, 0, 0, 0]; +}; + +const angleBetween = (x1, y1, x2, y2) => { + return Math.atan2(y2 - y1, x2 - x1); +}; +const bisectAngle = (inAngle, outAngle) => { + // Average of incoming and outgoing angles + let diff = outAngle - inAngle; + // Normalize to [-PI, PI] + while (diff > Math.PI) + diff -= 2 * Math.PI; + while (diff < -Math.PI) + diff += 2 * Math.PI; + return inAngle + diff / 2; +}; +const getLineMarkerPoints = (node) => { + const x1 = node.props?.x1 || 0; + const y1 = node.props?.y1 || 0; + const x2 = node.props?.x2 || 0; + const y2 = node.props?.y2 || 0; + const angle = angleBetween(x1, y1, x2, y2); + return { + start: { x: x1, y: y1, angle }, + end: { x: x2, y: y2, angle }, + }; +}; +const getPointListMarkerPoints = (points, closed) => { + if (points.length === 0) + return {}; + if (points.length === 1) + return { start: { x: points[0][0], y: points[0][1], angle: 0 } }; + const n = points.length; + const result = {}; + // Start point + const startOutAngle = angleBetween(points[0][0], points[0][1], points[1][0], points[1][1]); + if (closed) { + const startInAngle = angleBetween(points[n - 1][0], points[n - 1][1], points[0][0], points[0][1]); + result.start = { + x: points[0][0], + y: points[0][1], + angle: bisectAngle(startInAngle, startOutAngle), + }; + } + else { + result.start = { x: points[0][0], y: points[0][1], angle: startOutAngle }; + } + // Mid points + if (n > 2) { + result.mid = []; + for (let i = 1; i < n - 1; i++) { + const inAngle = angleBetween(points[i - 1][0], points[i - 1][1], points[i][0], points[i][1]); + const outAngle = angleBetween(points[i][0], points[i][1], points[i + 1][0], points[i + 1][1]); + result.mid.push({ + x: points[i][0], + y: points[i][1], + angle: bisectAngle(inAngle, outAngle), + }); + } + } + // End point + const endInAngle = angleBetween(points[n - 2][0], points[n - 2][1], points[n - 1][0], points[n - 1][1]); + if (closed) { + const endOutAngle = angleBetween(points[n - 1][0], points[n - 1][1], points[0][0], points[0][1]); + result.end = { + x: points[n - 1][0], + y: points[n - 1][1], + angle: bisectAngle(endInAngle, endOutAngle), + }; + } + else { + result.end = { + x: points[n - 1][0], + y: points[n - 1][1], + angle: endInAngle, + }; + } + return result; +}; +const getPolylineMarkerPoints = (node) => { + const points = parsePoints(node.props?.points); + return getPointListMarkerPoints(points, false); +}; +const getPolygonMarkerPoints = (node) => { + const points = parsePoints(node.props?.points); + return getPointListMarkerPoints(points, true); +}; +const getPathMarkerPoints = (node) => { + const d = node.props?.d; + if (!d) + return {}; + const path = normalizePath(absPath(parsePath(d))); + if (!path.length) + return {}; + // Extract vertices and tangent info from normalized path (M and C commands) + const vertices = []; + let cx = 0; + let cy = 0; + for (let i = 0; i < path.length; i++) { + const cmd = path[i]; + if (cmd[0] === 'M') { + cx = cmd[1]; + cy = cmd[2]; + vertices.push({ x: cx, y: cy }); + } + else if (cmd[0] === 'C') { + const cp1x = cmd[1]; + const cp1y = cmd[2]; + const cp2x = cmd[3]; + const cp2y = cmd[4]; + const ex = cmd[5]; + const ey = cmd[6]; + // Outgoing tangent at previous vertex + const prev = vertices[vertices.length - 1]; + if (prev) { + // Direction from current point to first control point + const dx = cp1x - cx; + const dy = cp1y - cy; + // If control point coincides with current point, use endpoint + if (Math.abs(dx) > 1e-6 || Math.abs(dy) > 1e-6) { + prev.outAngle = Math.atan2(dy, dx); + } + else { + prev.outAngle = Math.atan2(ey - cy, ex - cx); + } + } + // Incoming tangent at endpoint + const dx2 = ex - cp2x; + const dy2 = ey - cp2y; + let inAngle; + if (Math.abs(dx2) > 1e-6 || Math.abs(dy2) > 1e-6) { + inAngle = Math.atan2(dy2, dx2); + } + else { + inAngle = Math.atan2(ey - cy, ex - cx); + } + vertices.push({ x: ex, y: ey, inAngle }); + cx = ex; + cy = ey; + } + } + if (vertices.length === 0) + return {}; + if (vertices.length === 1) { + return { start: { x: vertices[0].x, y: vertices[0].y, angle: 0 } }; + } + const n = vertices.length; + const result = {}; + // Start point: use outgoing angle + const startAngle = vertices[0].outAngle ?? 0; + result.start = { x: vertices[0].x, y: vertices[0].y, angle: startAngle }; + // Mid points + if (n > 2) { + result.mid = []; + for (let i = 1; i < n - 1; i++) { + const v = vertices[i]; + const inA = v.inAngle ?? 0; + const outA = v.outAngle ?? inA; + result.mid.push({ + x: v.x, + y: v.y, + angle: bisectAngle(inA, outA), + }); + } + } + // End point: use incoming angle + const endAngle = vertices[n - 1].inAngle ?? 0; + result.end = { x: vertices[n - 1].x, y: vertices[n - 1].y, angle: endAngle }; + return result; +}; +const markerPointFns = { + [P.Line]: getLineMarkerPoints, + [P.Polyline]: getPolylineMarkerPoints, + [P.Polygon]: getPolygonMarkerPoints, + [P.Path]: getPathMarkerPoints, +}; +const getMarkerPoints = (node) => { + const fn = markerPointFns[node.type]; + return fn ? fn(node) : null; +}; + +const RAD_TO_DEG = 180 / Math.PI; +const DEFAULT_MARKER_WIDTH = 3; +const DEFAULT_MARKER_HEIGHT = 3; +const drawMarkerChildren = (ctx, node, drawNode) => { + const children = node.children || []; + children.forEach((child) => { + ctx.save(); + drawNode(ctx, child); + drawMarkerChildren(ctx, child, drawNode); + ctx.restore(); + }); +}; +const renderMarkerInstance = (ctx, marker, point, strokeWidth, isStart, drawNode) => { + const props = marker.props || {}; + const markerWidth = props.markerWidth ?? DEFAULT_MARKER_WIDTH; + const markerHeight = props.markerHeight ?? DEFAULT_MARKER_HEIGHT; + const refX = props.refX ?? 0; + const refY = props.refY ?? 0; + const orient = props.orient ?? 0; + const markerUnits = props.markerUnits ?? 'strokeWidth'; + const viewBox = props.viewBox; + ctx.save(); + // 1. Translate to vertex position + ctx.translate(point.x, point.y); + // 2. Rotate based on orient (ctx.rotate expects degrees) + if (orient === 'auto') { + ctx.rotate(point.angle * RAD_TO_DEG); + } + else if (orient === 'auto-start-reverse') { + const angle = isStart ? point.angle + Math.PI : point.angle; + ctx.rotate(angle * RAD_TO_DEG); + } + else { + const angle = typeof orient === 'number' ? orient : 0; + ctx.rotate(angle); + } + // 3. Scale for markerUnits + if (markerUnits === 'strokeWidth') { + ctx.scale(strokeWidth, strokeWidth); + } + // 4. Apply viewBox mapping and refX/refY offset + if (viewBox) { + const scaleX = markerWidth / viewBox.maxX; + const scaleY = markerHeight / viewBox.maxY; + ctx.scale(scaleX, scaleY); + ctx.translate(-viewBox.minX - refX, -viewBox.minY - refY); + } + else { + ctx.translate(-refX, -refY); + } + // 5. Render marker children + drawMarkerChildren(ctx, marker, drawNode); + ctx.restore(); +}; +const hasMarkers = (node) => { + if (!node.props) + return false; + return (('markerStart' in node.props && !!node.props.markerStart) || + ('markerMid' in node.props && !!node.props.markerMid) || + ('markerEnd' in node.props && !!node.props.markerEnd)); +}; +const MARKER_TYPES = new Set([P.Line, P.Polyline, P.Polygon, P.Path]); +const renderMarkers = (ctx, node, drawNode) => { + if (!hasMarkers(node)) + return; + if (!MARKER_TYPES.has(node.type)) + return; + const points = getMarkerPoints(node); + if (!points) + return; + const strokeWidth = ('strokeWidth' in (node.props || {}) && node.props.strokeWidth) || + 1; + const props = node.props || {}; + if ('markerStart' in props && props.markerStart && points.start) { + renderMarkerInstance(ctx, props.markerStart, points.start, strokeWidth, true, drawNode); + } + if ('markerMid' in props && props.markerMid && points.mid) { + const marker = props.markerMid; + points.mid.forEach((point) => { + renderMarkerInstance(ctx, marker, point, strokeWidth, false, drawNode); + }); + } + if ('markerEnd' in props && props.markerEnd && points.end) { + renderMarkerInstance(ctx, props.markerEnd, points.end, strokeWidth, false, drawNode); + } +}; + +const setStrokeWidth = (ctx, node) => { + if (!node.props) + return; + if (!('strokeWidth' in node.props)) + return; + const lineWidth = node.props.strokeWidth; + if (lineWidth) + ctx.lineWidth(lineWidth); +}; +const setStrokeColor = (ctx, node) => { + if (!node.props) + return; + if (!('stroke' in node.props)) + return; + const strokeColor = node.props.stroke; + if (strokeColor) + ctx.strokeColor(strokeColor); +}; +const setOpacity = (ctx, node) => { + if (!node.props) + return; + if (!('opacity' in node.props)) + return; + const opacity = node.props.opacity; + if (!isNil(opacity)) + ctx.opacity(opacity); +}; +const setFillOpacity = (ctx, node) => { + if (!node.props) + return; + if (!('fillOpacity' in node.props)) + return; + const fillOpacity = node.props.fillOpacity || null; + if (!isNil(fillOpacity)) + ctx.fillOpacity(fillOpacity); +}; +const setStrokeOpacity = (ctx, node) => { + if (!node.props) + return; + if (!('strokeOpacity' in node.props)) + return; + const strokeOpacity = node.props?.strokeOpacity; + if (!isNil(strokeOpacity)) + ctx.strokeOpacity(strokeOpacity); +}; +const setLineJoin = (ctx, node) => { + if (!node.props) + return; + if (!('strokeLinejoin' in node.props)) + return; + const lineJoin = node.props.strokeLinejoin; + if (lineJoin) + ctx.lineJoin(lineJoin); +}; +const setLineCap = (ctx, node) => { + if (!node.props) + return; + if (!('strokeLinecap' in node.props)) + return; + const lineCap = node.props?.strokeLinecap; + if (lineCap) + ctx.lineCap(lineCap); +}; +const setLineDash = (ctx, node) => { + if (!node.props) + return; + if (!('strokeDasharray' in node.props)) + return; + const value = node.props?.strokeDasharray || null; + // @ts-expect-error check this works as expected + if (value) + ctx.dash(value.split(/[\s,]+/).map(Number)); +}; +const hasLinearGradientFill = (node) => { + if (!node.props) + return false; + if (!('fill' in node.props)) + return false; + if (typeof node.props.fill === 'string') + return false; + return node.props.fill?.type === P.LinearGradient; +}; +const hasRadialGradientFill = (node) => { + if (!node.props) + return false; + if (!('fill' in node.props)) + return false; + if (typeof node.props.fill === 'string') + return false; + return node.props.fill?.type === P.RadialGradient; +}; +function multiplyMatrices(m1, m2) { + const a = m1[0] * m2[0] + m1[2] * m2[1]; + const b = m1[1] * m2[0] + m1[3] * m2[1]; + const c = m1[0] * m2[2] + m1[2] * m2[3]; + const d = m1[1] * m2[2] + m1[3] * m2[3]; + const e = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]; + const f = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]; + return [a, b, c, d, e, f]; +} +const transformGradient = (grad, transforms, bbox, units) => { + const matrices = transforms.map((transform) => { + switch (transform.operation) { + case 'scale': { + const value = transform.value; + return [value[0], 0, 0, value[1], 0, 0]; + } + case 'translate': { + const value = transform.value; + let x = value[0] || 0; + let y = value[1] || 0; + if (units === 'objectBoundingBox') { + x = (bbox[2] - bbox[0]) * x; + y = (bbox[3] - bbox[1]) * y; + } + return [1, 0, 0, 1, x, y]; + } + case 'rotate': { + const value = transform.value; + const cos = Math.cos(value[0]); + const sin = Math.sin(value[0]); + const cx = value[1] || 0; + const cy = value[2] || 0; + return [ + cos, + sin, + -sin, + cos, + cx * (1 - cos) + cy * sin, + cy * (1 - cos) - cx * sin, + ]; + } + case 'skew': { + const value = transform.value; + return [1, Math.tan(value[0]), Math.tan(value[1]), 1, 0, 0]; + } + case 'matrix': { + const value = transform.value; + let x = value[4] || 0; + let y = value[5] || 0; + if (units === 'objectBoundingBox') { + x = (bbox[2] - bbox[0]) * x; + y = (bbox[3] - bbox[1]) * y; + } + return [value[0], value[1], value[2], value[3], x, y]; + } + default: + return [1, 0, 0, 1, 0, 0]; + } + }); + const matrix = matrices.reduce(multiplyMatrices, [1, 0, 0, 1, 0, 0]); + grad.setTransform(...matrix); +}; +// Math simplified from https://github.com/devongovett/svgkit/blob/master/src/elements/SVGGradient.js#L104 +const setLinearGradientFill = (ctx, node) => { + if (!node.props) + return; + if (!('fill' in node.props)) + return; + const bbox = getBoundingBox(node); + const gradient = node.props?.fill; + if (!gradient) + return; + const units = gradient.props.gradientUnits || 'objectBoundingBox'; + const transforms = gradient.props.gradientTransform || []; + let x1 = gradient.props.x1 || 0; + let y1 = gradient.props.y1 || 0; + let x2 = gradient.props.x2 || 1; + let y2 = gradient.props.y2 || 0; + if (units === 'objectBoundingBox') { + const m0 = bbox[2] - bbox[0]; + const m3 = bbox[3] - bbox[1]; + const m4 = bbox[0]; + const m5 = bbox[1]; + x1 = m0 * x1 + m4; + y1 = m3 * y1 + m5; + x2 = m0 * x2 + m4; + y2 = m3 * y2 + m5; + } + const grad = ctx.linearGradient(x1, y1, x2, y2); + transformGradient(grad, transforms, bbox, units); + gradient.children?.forEach((stop) => { + grad.stop(stop.props.offset, stop.props.stopColor, stop.props.stopOpacity); + }); + ctx.fill(grad); +}; +// Math simplified from https://github.com/devongovett/svgkit/blob/master/src/elements/SVGGradient.js#L155 +const setRadialGradientFill = (ctx, node) => { + if (!node.props) + return; + if (!('fill' in node.props)) + return; + const bbox = getBoundingBox(node); + const gradient = node.props?.fill; + if (!gradient) + return; + const units = gradient.props.gradientUnits || 'objectBoundingBox'; + const transforms = gradient.props.gradientTransform || []; + let r = gradient.props.r || 0.5; + let cx = gradient.props.cx || 0.5; + let cy = gradient.props.cy || 0.5; + let fx = gradient.props.fx || cx; + let fy = gradient.props.fy || cy; + if (units === 'objectBoundingBox') { + const m0 = bbox[2] - bbox[0]; + const m3 = bbox[3] - bbox[1]; + const m4 = bbox[0]; + const m5 = bbox[1]; + r = r * m0; + cx = m0 * cx + m4; + cy = m3 * cy + m5; + fx = m0 * fx + m4; + fy = m3 * fy + m5; + } + const grad = ctx.radialGradient(cx, cy, 0, fx, fy, r); + transformGradient(grad, transforms, bbox, units); + gradient.children?.forEach((stop) => { + grad.stop(stop.props.offset, stop.props.stopColor, stop.props.stopOpacity); + }); + ctx.fill(grad); +}; +const setFillColor = (ctx, node) => { + if (!node.props) + return; + if (!('fill' in node.props)) + return; + const fillColor = node.props?.fill; + if (fillColor) + ctx.fillColor(fillColor); +}; +const setFill = (ctx, node) => { + if (hasLinearGradientFill(node)) + return setLinearGradientFill(ctx, node); + if (hasRadialGradientFill(node)) + return setRadialGradientFill(ctx, node); + return setFillColor(ctx, node); +}; +const draw = (ctx, node) => { + const props = node.props || {}; + if ('fill' in props && 'stroke' in props && props.fill && props.stroke) { + ctx.fillAndStroke(props.fillRule); + } + else if ('fill' in props && props.fill) { + ctx.fill(props.fillRule); + } + else if ('stroke' in props && props.stroke) { + ctx.stroke(); + } + else { + ctx.save(); + ctx.opacity(0); + ctx.fill(null); + ctx.restore(); + } +}; +const noop = () => { }; +const renderFns$1 = { + [P.Tspan]: noop, + [P.TextInstance]: noop, + [P.Path]: renderPath, + [P.Rect]: renderRect, + [P.Line]: renderLine$1, + [P.G]: renderGroup, + [P.Text]: renderSvgText, + [P.Circle]: renderCircle, + [P.Image]: renderImage$1, + [P.Ellipse]: renderEllipse, + [P.Polygon]: renderPolygon, + [P.Polyline]: renderPolyline, +}; +const renderNode$1 = (ctx, node) => { + const renderFn = renderFns$1[node.type]; + if (renderFn) { + renderFn(ctx, node); + } + else { + console.warn(`SVG node of type ${node.type} is not currently supported`); + } +}; +const drawNode = (ctx, node) => { + setLineCap(ctx, node); + setLineDash(ctx, node); + setLineJoin(ctx, node); + setStrokeWidth(ctx, node); + setStrokeColor(ctx, node); + setFill(ctx, node); + setStrokeOpacity(ctx, node); + setFillOpacity(ctx, node); + setOpacity(ctx, node); + applyTransformations(ctx, node); + renderNode$1(ctx, node); + draw(ctx, node); +}; +const clipPath = (ctx, node) => { + if (!node.props) + return; + if (!('clipPath' in node.props)) + return; + const value = node.props.clipPath; + if (value) { + const children = value.children || []; + children.forEach((child) => renderNode$1(ctx, child)); + ctx.clip(); + } +}; +const drawChildren = (ctx, node) => { + const children = node.children || []; + children.forEach((child) => { + ctx.save(); + clipPath(ctx, child); + drawNode(ctx, child); + renderMarkers(ctx, child, drawNode); + drawChildren(ctx, child); + ctx.restore(); + }); +}; +const resolveAspectRatio = (ctx, node) => { + if (!node.box) + return; + const { width, height } = node.box; + const { viewBox, preserveAspectRatio } = node.props; + const { meetOrSlice = 'meet', align = 'xMidYMid' } = preserveAspectRatio || {}; + if (viewBox == null || width == null || height == null) + return; + const x = viewBox?.minX || 0; + const y = viewBox?.minY || 0; + const logicalWidth = viewBox?.maxX || width; + const logicalHeight = viewBox?.maxY || height; + const logicalRatio = logicalWidth / logicalHeight; + const physicalRatio = width / height; + const scaleX = width / logicalWidth; + const scaleY = height / logicalHeight; + if (align === 'none') { + ctx.scale(scaleX, scaleY); + ctx.translate(-x, -y); + return; + } + if ((logicalRatio < physicalRatio && meetOrSlice === 'meet') || + (logicalRatio >= physicalRatio && meetOrSlice === 'slice')) { + ctx.scale(scaleY, scaleY); + switch (align) { + case 'xMinYMin': + case 'xMinYMid': + case 'xMinYMax': + ctx.translate(-x, -y); + break; + case 'xMidYMin': + case 'xMidYMid': + case 'xMidYMax': + ctx.translate(-x - (logicalWidth - (width * logicalHeight) / height) / 2, -y); + break; + default: + ctx.translate(-x - (logicalWidth - (width * logicalHeight) / height), -y); + } + } + else { + ctx.scale(scaleX, scaleX); + switch (align) { + case 'xMinYMin': + case 'xMidYMin': + case 'xMaxYMin': + ctx.translate(-x, -y); + break; + case 'xMinYMid': + case 'xMidYMid': + case 'xMaxYMid': + ctx.translate(-x, -y - (logicalHeight - (height * logicalWidth) / width) / 2); + break; + default: + ctx.translate(-x, -y - (logicalHeight - (height * logicalWidth) / width)); + } + } +}; +const moveToOrigin = (ctx, node) => { + if (!node.box) + return; + const { top, left } = node.box; + const paddingLeft = node.box.paddingLeft || 0; + const paddingTop = node.box.paddingTop || 0; + ctx.translate(left + paddingLeft, top + paddingTop); +}; +const renderSvg = (ctx, node) => { + ctx.save(); + clipNode(ctx, node); + moveToOrigin(ctx, node); + resolveAspectRatio(ctx, node); + drawChildren(ctx, node); + ctx.restore(); +}; + +const black = { value: '#000', opacity: 1 }; +const hslToRgb = (h, s, l) => { + const sNorm = s / 100; + const lNorm = l / 100; + const c = (1 - Math.abs(2 * lNorm - 1)) * sNorm; + const x = c * (1 - Math.abs(((h / 60) % 2) - 1)); + const m = lNorm - c / 2; + let r, g, b; + if (h < 60) + [r, g, b] = [c, x, 0]; + else if (h < 120) + [r, g, b] = [x, c, 0]; + else if (h < 180) + [r, g, b] = [0, c, x]; + else if (h < 240) + [r, g, b] = [0, x, c]; + else if (h < 300) + [r, g, b] = [x, 0, c]; + else + [r, g, b] = [c, 0, x]; + return [ + Math.round((r + m) * 255), + Math.round((g + m) * 255), + Math.round((b + m) * 255), + ]; +}; +const hwbToRgb = (h, w, bl) => { + const wNorm = w / 100; + const blNorm = bl / 100; + if (wNorm + blNorm >= 1) { + const gray = Math.round((wNorm / (wNorm + blNorm)) * 255); + return [gray, gray, gray]; + } + const [r, g, b] = hslToRgb(h, 100, 50); + return [ + Math.round((r / 255) * (1 - wNorm - blNorm) * 255 + wNorm * 255), + Math.round((g / 255) * (1 - wNorm - blNorm) * 255 + wNorm * 255), + Math.round((b / 255) * (1 - wNorm - blNorm) * 255 + wNorm * 255), + ]; +}; +// TODO: parse to number[] in layout to avoid this step +const parseColor = (hex) => { + if (!hex) + return black; + const parsed = colorString.get(hex); + if (!parsed) + return black; + let r, g, b; + if (parsed.model === 'hsl') { + [r, g, b] = hslToRgb(parsed.value[0], parsed.value[1], parsed.value[2]); + } + else if (parsed.model === 'hwb') { + [r, g, b] = hwbToRgb(parsed.value[0], parsed.value[1], parsed.value[2]); + } + else { + [r, g, b] = parsed.value; + } + const value = colorString.to.hex(r, g, b); + const opacity = parsed.value[3]; + if (!value) + return black; + return { value, opacity }; +}; + +const DEST_REGEXP = /^#.+/; +const isSrcId$1 = (src) => src.match(DEST_REGEXP); +const renderAttachment = (ctx, attachment) => { + const { xOffset = 0, yOffset = 0, width, height, image } = attachment; + ctx.translate(-width + xOffset, -height + yOffset); + ctx.image(image, 0, 0, { + fit: [width, height], + align: 'center', + valign: 'bottom', + }); +}; +const renderAttachments = (ctx, run, glyphs) => { + if (!glyphs) + return; + if (!run.positions) + return; + const font = run.attributes.font?.[0]; + if (!font) + return; + ctx.save(); + const space = font.glyphForCodePoint(0x20); + const objectReplacement = font.glyphForCodePoint(0xfffc); + let attachmentAdvance = 0; + for (let i = 0; i < glyphs.length; i += 1) { + const position = run.positions[i]; + const glyph = glyphs[i]; + attachmentAdvance += position.xAdvance || 0; + if (glyph.id === objectReplacement.id && run.attributes.attachment) { + ctx.translate(attachmentAdvance, position.yOffset || 0); + renderAttachment(ctx, run.attributes.attachment); + glyphs[i] = space; + attachmentAdvance = 0; + } + } + ctx.restore(); +}; +const renderRun = (ctx, run) => { + if (!run.glyphs) + return; + if (!run.positions) + return; + const font = run.attributes.font?.[0]; + if (!font) + return; + const { fontSize, link } = run.attributes; + const color = parseColor(run.attributes.color); + const opacity = isNil(run.attributes.opacity) + ? color.opacity + : run.attributes.opacity; + const { height = 0, descent = 0, xAdvance = 0 } = run; + ctx.fillColor(color.value); + ctx.fillOpacity(opacity); + if (link) { + if (isSrcId$1(link)) { + ctx.goTo(0, -height - descent, xAdvance, height, link.slice(1)); + } + else { + ctx.link(0, -height - descent, xAdvance, height, link); + } + } + // Copy glyphs to avoid mutating the original array + const glyphs = [...run.glyphs]; + renderAttachments(ctx, run, glyphs); + ctx.font(font.type === 'STANDARD' ? font.fullName : font, fontSize); + try { + renderGlyphs(ctx, glyphs, run.positions, 0, 0); + } + catch (error) { + console.log(error); + } + ctx.translate(xAdvance, 0); +}; +const renderBackground$1 = (ctx, rect, backgroundColor) => { + const color = parseColor(backgroundColor); + ctx.save(); + ctx.fillOpacity(color.opacity); + ctx.rect(rect.x, rect.y, rect.width, rect.height); + ctx.fill(color.value); + ctx.restore(); +}; +const renderDecorationLine = (ctx, decorationLine) => { + const color = parseColor(decorationLine.color); + const opacity = isNil(decorationLine.opacity) + ? color.opacity + : decorationLine.opacity; + ctx.save(); + ctx.lineWidth(decorationLine.rect.height); + ctx.strokeOpacity(opacity); + if (/dashed/.test(decorationLine.style)) { + ctx.dash(3 * decorationLine.rect.height, {}); + } + else if (/dotted/.test(decorationLine.style)) { + ctx.dash(decorationLine.rect.height, {}); + } + if (/wavy/.test(decorationLine.style)) { + const dist = Math.max(2, decorationLine.rect.height); + let step = 1.1 * dist; + const stepCount = Math.floor(decorationLine.rect.width / (2 * step)); + // Adjust step to fill entire width + const remainingWidth = decorationLine.rect.width - stepCount * 2 * step; + const adjustment = remainingWidth / stepCount / 2; + step += adjustment; + const cp1y = decorationLine.rect.y + dist; + const cp2y = decorationLine.rect.y - dist; + let { x } = decorationLine.rect; + ctx.moveTo(decorationLine.rect.x, decorationLine.rect.y); + for (let i = 0; i < stepCount; i += 1) { + ctx.bezierCurveTo(x + step, cp1y, x + step, cp2y, x + 2 * step, decorationLine.rect.y); + x += 2 * step; + } + } + else { + ctx.moveTo(decorationLine.rect.x, decorationLine.rect.y); + ctx.lineTo(decorationLine.rect.x + decorationLine.rect.width, decorationLine.rect.y); + if (/double/.test(decorationLine.style)) { + ctx.moveTo(decorationLine.rect.x, decorationLine.rect.y + decorationLine.rect.height * 2); + ctx.lineTo(decorationLine.rect.x + decorationLine.rect.width, decorationLine.rect.y + decorationLine.rect.height * 2); + } + } + ctx.stroke(color.value); + ctx.restore(); +}; +const renderLine = (ctx, line) => { + if (!line.box) + return; + const lineAscent = line.ascent || 0; + ctx.save(); + ctx.translate(line.box.x, line.box.y + lineAscent); + for (let i = 0; i < line.runs.length; i += 1) { + const run = line.runs[i]; + const isLastRun = i === line.runs.length - 1; + if (run.attributes.backgroundColor) { + const xAdvance = run.xAdvance ?? 0; + const overflowRight = isLastRun ? line.overflowRight ?? 0 : 0; + const backgroundRect = { + x: 0, + y: -lineAscent, + height: line.box.height, + width: xAdvance - overflowRight, + }; + renderBackground$1(ctx, backgroundRect, run.attributes.backgroundColor); + } + renderRun(ctx, run); + } + ctx.restore(); + ctx.save(); + ctx.translate(line.box.x, line.box.y); + if (line.decorationLines) { + for (let i = 0; i < line.decorationLines.length; i += 1) { + const decorationLine = line.decorationLines[i]; + renderDecorationLine(ctx, decorationLine); + } + } + ctx.restore(); +}; +const renderBlock = (ctx, block) => { + block.forEach((line) => { + renderLine(ctx, line); + }); +}; +const renderText = (ctx, node) => { + if (!node.box) + return; + if (!node.lines) + return; + const { top, left } = node.box; + const blocks = [node.lines]; + const paddingTop = node.box?.paddingTop || 0; + const paddingLeft = node.box?.paddingLeft || 0; + const initialY = node.lines[0] ? node.lines[0].box.y : 0; + const offsetX = node.alignOffset || 0; + ctx.save(); + ctx.translate(left + paddingLeft - offsetX, top + paddingTop - initialY); + blocks.forEach((block) => { + renderBlock(ctx, block); + }); + ctx.restore(); +}; + +const renderPage = (ctx, node) => { + if (!node.box) + return; + const { width, height } = node.box; + const dpi = node.props?.dpi || 72; + const userUnit = dpi / 72; + ctx.addPage({ size: [width, height], margin: 0, userUnit }); +}; + +const renderNote = (ctx, node) => { + if (!node.box) + return; + const { top, left } = node.box; + const value = node?.children?.[0].value || ''; + const color = node.style?.backgroundColor; + ctx.note(left, top, 0, 0, value, { color }); +}; + +const isNumeric = (n) => { + return !Number.isNaN(parseFloat(n)) && Number.isFinite(n); +}; +const applyContainObjectFit = (cw, ch, iw, ih, px, py) => { + const cr = cw / ch; + const ir = iw / ih; + const pxp = matchPercent(px ?? null); + const pyp = matchPercent(py ?? null); + const pxv = pxp ? pxp.percent : 0.5; + const pyv = pyp ? pyp.percent : 0.5; + if (cr > ir) { + const height = ch; + const width = height * ir; + const yOffset = isNumeric(py) ? py : 0; + const xOffset = isNumeric(px) ? px : (cw - width) * pxv; + return { width, height, xOffset, yOffset }; + } + const width = cw; + const height = width / ir; + const xOffset = isNumeric(px) ? px : 0; + const yOffset = isNumeric(py) ? py : (ch - height) * pyv; + return { width, height, yOffset, xOffset }; +}; +const applyNoneObjectFit = (cw, ch, iw, ih, px, py) => { + const width = iw; + const height = ih; + const pxp = matchPercent(px ?? null); + const pyp = matchPercent(py ?? null); + const pxv = pxp ? pxp.percent : 0.5; + const pyv = pyp ? pyp.percent : 0.5; + const xOffset = isNumeric(px) ? px : (cw - width) * pxv; + const yOffset = isNumeric(py) ? py : (ch - height) * pyv; + return { width, height, xOffset, yOffset }; +}; +const applyCoverObjectFit = (cw, ch, iw, ih, px, py) => { + const ir = iw / ih; + const cr = cw / ch; + const pxp = matchPercent(px ?? null); + const pyp = matchPercent(py ?? null); + const pxv = pxp ? pxp.percent : 0.5; + const pyv = pyp ? pyp.percent : 0.5; + if (cr > ir) { + const width = cw; + const height = width / ir; + const xOffset = isNumeric(px) ? px : 0; + const yOffset = isNumeric(py) ? py : (ch - height) * pyv; + return { width, height, yOffset, xOffset }; + } + const height = ch; + const width = height * ir; + const xOffset = isNumeric(px) ? px : (cw - width) * pxv; + const yOffset = isNumeric(py) ? py : 0; + return { width, height, xOffset, yOffset }; +}; +const applyScaleDownObjectFit = (cw, ch, iw, ih, px, py) => { + const containDimension = applyContainObjectFit(cw, ch, iw, ih, px, py); + const noneDimension = applyNoneObjectFit(cw, ch, iw, ih, px, py); + return containDimension.width < noneDimension.width + ? containDimension + : noneDimension; +}; +const applyFillObjectFit = (cw, ch, px, py) => { + return { + width: cw, + height: ch, + xOffset: matchPercent(px ?? null) ? 0 : px || 0, + yOffset: matchPercent(py ?? null) ? 0 : py || 0, + }; +}; +const resolveObjectFit = (type = 'fill', cw, ch, iw, ih, px, py) => { + switch (type) { + case 'contain': + return applyContainObjectFit(cw, ch, iw, ih, px, py); + case 'cover': + return applyCoverObjectFit(cw, ch, iw, ih, px, py); + case 'none': + return applyNoneObjectFit(cw, ch, iw, ih, px, py); + case 'scale-down': + return applyScaleDownObjectFit(cw, ch, iw, ih, px, py); + default: + return applyFillObjectFit(cw, ch, px, py); + } +}; + +const drawImage = (ctx, options) => { + const { x, y, width: containerWidth, height: containerHeight, image, opacity, objectFit, objectPositionX, objectPositionY, imageCache = new Map(), } = options; + const { width, height, xOffset, yOffset } = resolveObjectFit(objectFit, containerWidth, containerHeight, image.width, image.height, objectPositionX, objectPositionY); + if (!image.data) + return; + if (width === 0 || height === 0) + return; + const cacheKey = image.key; + let embeddedImage = imageCache.get(cacheKey); + if (!embeddedImage) { + const src = image.data; + embeddedImage = + (typeof src === 'string' && ctx._imageRegistry[src]) || + ctx.openImage(src); + if (!embeddedImage.obj) { + embeddedImage.embed(ctx); + } + } + if (cacheKey) + imageCache.set(cacheKey, embeddedImage); + const imageOpacity = isNil(opacity) ? 1 : opacity; + ctx + .fillOpacity(imageOpacity) + .image(embeddedImage, x + xOffset, y + yOffset, { width, height }); +}; + +const renderImage = (ctx, node, options) => { + if (!node.box) + return; + if (!node.image) + return; + const { left, top } = node.box; + const paddingTop = node.box.paddingTop || 0; + const paddingRight = node.box.paddingRight || 0; + const paddingBottom = node.box.paddingBottom || 0; + const paddingLeft = node.box.paddingLeft || 0; + ctx.save(); + clipNode(ctx, node); + drawImage(ctx, { + x: left + paddingLeft, + y: top + paddingTop, + width: node.box.width - paddingLeft - paddingRight, + height: node.box.height - paddingTop - paddingBottom, + image: node.image, + opacity: node.style?.opacity, + objectFit: node.style?.objectFit, + objectPositionX: node.style?.objectPositionX, + objectPositionY: node.style?.objectPositionY, + imageCache: options.imageCache, + }); + ctx.restore(); +}; + +const renderImageBackground = (ctx, node, options) => { + if (!node.box) + return; + if (!node.image) + return; + const { left, top } = node.box; + const paddingTop = node.box.paddingTop || 0; + const paddingRight = node.box.paddingRight || 0; + const paddingBottom = node.box.paddingBottom || 0; + const paddingLeft = node.box.paddingLeft || 0; + ctx.save(); + clipNode(ctx, node); + drawImage(ctx, { + x: left + paddingLeft, + y: top + paddingTop, + width: node.box.width - paddingLeft - paddingRight, + height: node.box.height - paddingTop - paddingBottom, + image: node.image, + opacity: node.style?.opacity, + objectFit: node.style?.objectFit, + objectPositionX: node.style?.objectPositionX, + objectPositionY: node.style?.objectPositionY, + imageCache: options.imageCache, + }); + ctx.restore(); +}; + +const ZERO = { top: 0, bottom: 0, left: 0, right: 0 }; +const resolveHitSlop = (hitSlop) => { + if (!hitSlop) + return ZERO; + if (typeof hitSlop === 'number') { + return { top: hitSlop, bottom: hitSlop, left: hitSlop, right: hitSlop }; + } + return { + top: hitSlop.top ?? 0, + bottom: hitSlop.bottom ?? 0, + left: hitSlop.left ?? 0, + right: hitSlop.right ?? 0, + }; +}; + +const CONTENT_COLOR = '#a1c6e7'; +const PADDING_COLOR = '#c4deb9'; +const MARGIN_COLOR = '#f8cca1'; +const HITSLOP_COLOR = '#d8b4fe'; +// TODO: Draw debug boxes using clipping to enhance quality +const debugContent = (ctx, node) => { + if (!node.box) + return; + const { left, top, width, height, paddingLeft = 0, paddingTop = 0, paddingRight = 0, paddingBottom = 0, borderLeftWidth = 0, borderTopWidth = 0, borderRightWidth = 0, borderBottomWidth = 0, } = node.box; + ctx + .fillColor(CONTENT_COLOR) + .opacity(0.5) + .rect(left + paddingLeft + borderLeftWidth, top + paddingTop + borderTopWidth, width - paddingLeft - paddingRight - borderRightWidth - borderLeftWidth, height - paddingTop - paddingBottom - borderTopWidth - borderBottomWidth) + .fill(); +}; +const debugPadding = (ctx, node) => { + if (!node.box) + return; + const { left, top, width, height, paddingLeft = 0, paddingTop = 0, paddingRight = 0, paddingBottom = 0, borderLeftWidth = 0, borderTopWidth = 0, borderRightWidth = 0, borderBottomWidth = 0, } = node.box; + ctx.fillColor(PADDING_COLOR).opacity(0.5); + // Padding top + ctx + .rect(left + paddingLeft + borderLeftWidth, top + borderTopWidth, width - paddingRight - paddingLeft - borderLeftWidth - borderRightWidth, paddingTop) + .fill(); + // Padding left + ctx + .rect(left + borderLeftWidth, top + borderTopWidth, paddingLeft, height - borderTopWidth - borderBottomWidth) + .fill(); + // Padding right + ctx + .rect(left + width - paddingRight - borderRightWidth, top + borderTopWidth, paddingRight, height - borderTopWidth - borderBottomWidth) + .fill(); + // Padding bottom + ctx + .rect(left + paddingLeft + borderLeftWidth, top + height - paddingBottom - borderBottomWidth, width - paddingRight - paddingLeft - borderLeftWidth - borderRightWidth, paddingBottom) + .fill(); +}; +const debugMargin = (ctx, node) => { + if (!node.box) + return; + const { left, top, width, height } = node.box; + const { marginLeft = 0, marginTop = 0, marginRight = 0, marginBottom = 0, } = node.box; + ctx.fillColor(MARGIN_COLOR).opacity(0.5); + // Margin top + ctx.rect(left, top - marginTop, width, marginTop).fill(); + // Margin left + ctx + .rect(left - marginLeft, top - marginTop, marginLeft, height + marginTop + marginBottom) + .fill(); + // Margin right + ctx + .rect(left + width, top - marginTop, marginRight, height + marginTop + marginBottom) + .fill(); + // Margin bottom + ctx.rect(left, top + height, width, marginBottom).fill(); +}; +const debugText = (ctx, node) => { + if (!node.box) + return; + const { left, top, width, height } = node.box; + const { marginLeft = 0, marginTop = 0, marginRight = 0, marginBottom = 0, } = node.box; + const roundedWidth = Math.round(width + marginLeft + marginRight); + const roundedHeight = Math.round(height + marginTop + marginBottom); + ctx + .fontSize(6) + .opacity(1) + .fillColor('black') + .text(`${roundedWidth} x ${roundedHeight}`, left - marginLeft, Math.max(top - marginTop - 4, 1), { width: Infinity }); +}; +const debugOrigin = (ctx, node) => { + if (node.origin) { + ctx + .circle(node.origin.left, node.origin.top, 3) + .fill('red') + .circle(node.origin.left, node.origin.top, 5) + .stroke('red'); + } +}; +const debugHitSlop = (ctx, node) => { + if (!node.box || !node.props) + return; + if (!('hitSlop' in node.props)) + return; + const slop = resolveHitSlop(node.props.hitSlop); + if (!slop.top && !slop.bottom && !slop.left && !slop.right) + return; + const { left, top, width, height } = node.box; + ctx.fillColor(HITSLOP_COLOR).opacity(0.35); + // Top + if (slop.top) { + ctx + .rect(left - slop.left, top - slop.top, width + slop.left + slop.right, slop.top) + .fill(); + } + // Bottom + if (slop.bottom) { + ctx + .rect(left - slop.left, top + height, width + slop.left + slop.right, slop.bottom) + .fill(); + } + // Left + if (slop.left) { + ctx.rect(left - slop.left, top, slop.left, height).fill(); + } + // Right + if (slop.right) { + ctx.rect(left + width, top, slop.right, height).fill(); + } +}; +const renderDebug = (ctx, node) => { + if (!node.props) + return; + if (!('debug' in node.props) || !node.props.debug) + return; + ctx.save(); + debugContent(ctx, node); + debugPadding(ctx, node); + debugMargin(ctx, node); + debugHitSlop(ctx, node); + debugText(ctx, node); + debugOrigin(ctx, node); + ctx.restore(); +}; + +const availableMethods = [ + 'dash', + 'clip', + 'save', + 'path', + 'fill', + 'font', + 'text', + 'rect', + 'scale', + 'moveTo', + 'lineTo', + 'stroke', + 'rotate', + 'circle', + 'lineCap', + 'opacity', + 'ellipse', + 'polygon', + 'restore', + 'lineJoin', + 'fontSize', + 'fillColor', + 'lineWidth', + 'translate', + 'miterLimit', + 'strokeColor', + 'fillOpacity', + 'roundedRect', + 'fillAndStroke', + 'strokeOpacity', + 'bezierCurveTo', + 'quadraticCurveTo', + 'linearGradient', + 'radialGradient', +]; +const painter = (ctx) => { + const p = availableMethods.reduce((acc, prop) => ({ + ...acc, + [prop]: (...args) => { + // @ts-expect-error ctx[prop] is a function + ctx[prop](...args); + return p; + }, + }), {}); + return p; +}; +const renderCanvas = (ctx, node) => { + if (!node.box) + return; + const { top, left, width, height } = node.box; + const paddingTop = node.box.paddingTop || 0; + const paddingLeft = node.box.paddingLeft || 0; + const paddingRight = node.box.paddingRight || 0; + const paddingBottom = node.box.paddingBottom || 0; + const availableWidth = width - paddingLeft - paddingRight; + const availableHeight = height - paddingTop - paddingBottom; + if (!availableWidth || !availableHeight) { + console.warn('Canvas element has null width or height. Please provide valid values via the `style` prop in order to correctly render it.'); + } + ctx.save().translate(left + paddingLeft, top + paddingTop); + if (node.props.paint) { + node.props.paint(painter(ctx), availableWidth, availableHeight); + } + ctx.restore(); +}; + +// Ref: https://www.w3.org/TR/css-backgrounds-3/#borders +// This constant is used to approximate a symmetrical arc using a cubic Bezier curve. +const KAPPA = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0); +const clipBorderTop = (ctx, layout, style, rtr, rtl) => { + const { top, left, width, height } = layout; + const { borderTopWidth, borderRightWidth, borderLeftWidth } = style; + // Clip outer top border edge + ctx.moveTo(left + rtl, top); + ctx.lineTo(left + width - rtr, top); + // Ellipse coefficients outer top right cap + const c0 = rtr * (1.0 - KAPPA); + // Clip outer top right cap + ctx.bezierCurveTo(left + width - c0, top, left + width, top + c0, left + width, top + rtr); + // Move down in case the margin exceedes the radius + const topRightYCoord = top + Math.max(borderTopWidth, rtr); + ctx.lineTo(left + width, topRightYCoord); + // Clip inner top right cap + ctx.lineTo(left + width - borderRightWidth, topRightYCoord); + // Ellipse coefficients inner top right cap + const innerTopRightRadiusX = Math.max(rtr - borderRightWidth, 0); + const innerTopRightRadiusY = Math.max(rtr - borderTopWidth, 0); + const c1 = innerTopRightRadiusX * (1.0 - KAPPA); + const c2 = innerTopRightRadiusY * (1.0 - KAPPA); + // Clip inner top right cap + ctx.bezierCurveTo(left + width - borderRightWidth, top + borderTopWidth + c2, left + width - borderRightWidth - c1, top + borderTopWidth, left + width - borderRightWidth - innerTopRightRadiusX, top + borderTopWidth); + // Clip inner top border edge + ctx.lineTo(left + Math.max(rtl, borderLeftWidth), top + borderTopWidth); + // Ellipse coefficients inner top left cap + const innerTopLeftRadiusX = Math.max(rtl - borderLeftWidth, 0); + const innerTopLeftRadiusY = Math.max(rtl - borderTopWidth, 0); + const c3 = innerTopLeftRadiusX * (1.0 - KAPPA); + const c4 = innerTopLeftRadiusY * (1.0 - KAPPA); + const topLeftYCoord = top + Math.max(borderTopWidth, rtl); + // Clip inner top left cap + ctx.bezierCurveTo(left + borderLeftWidth + c3, top + borderTopWidth, left + borderLeftWidth, top + borderTopWidth + c4, left + borderLeftWidth, topLeftYCoord); + ctx.lineTo(left, topLeftYCoord); + // Move down in case the margin exceedes the radius + ctx.lineTo(left, top + rtl); + // Ellipse coefficients outer top left cap + const c5 = rtl * (1.0 - KAPPA); + // Clip outer top left cap + ctx.bezierCurveTo(left, top + c5, left + c5, top, left + rtl, top); + ctx.closePath(); + ctx.clip(); + // Clip border top cap joins + if (borderRightWidth) { + const trSlope = -borderTopWidth / borderRightWidth; + ctx.moveTo(left + width / 2, trSlope * (-width / 2) + top); + ctx.lineTo(left + width, top); + ctx.lineTo(left, top); + ctx.lineTo(left, top + height); + ctx.closePath(); + ctx.clip(); + } + if (borderLeftWidth) { + const trSlope = -borderTopWidth / borderLeftWidth; + ctx.moveTo(left + width / 2, trSlope * (-width / 2) + top); + ctx.lineTo(left, top); + ctx.lineTo(left + width, top); + ctx.lineTo(left + width, top + height); + ctx.closePath(); + ctx.clip(); + } +}; +const fillBorderTop = (ctx, layout, style, rtr, rtl) => { + const { top, left, width } = layout; + const { borderTopColor, borderTopWidth, borderTopStyle, borderRightWidth, borderLeftWidth, } = style; + const c0 = rtl * (1.0 - KAPPA); + const c1 = rtr * (1.0 - KAPPA); + ctx.moveTo(left, top + Math.max(rtl, borderTopWidth)); + ctx.bezierCurveTo(left, top + c0, left + c0, top, left + rtl, top); + ctx.lineTo(left + width - rtr, top); + ctx.bezierCurveTo(left + width - c1, top, left + width, top + c1, left + width, top + rtr); + ctx.strokeColor(borderTopColor); + ctx.lineWidth(Math.max(borderRightWidth, borderTopWidth, borderLeftWidth) * 2); + if (borderTopStyle === 'dashed') { + ctx.dash(borderTopWidth * 2, { space: borderTopWidth * 1.2 }); + } + else if (borderTopStyle === 'dotted') { + ctx.dash(borderTopWidth, { space: borderTopWidth * 1.2 }); + } + ctx.stroke(); + ctx.undash(); +}; +const clipBorderRight = (ctx, layout, style, rtr, rbr) => { + const { top, left, width, height } = layout; + const { borderTopWidth, borderRightWidth, borderBottomWidth } = style; + // Clip outer right border edge + ctx.moveTo(left + width, top + rtr); + ctx.lineTo(left + width, top + height - rbr); + // Ellipse coefficients outer bottom right cap + const c0 = rbr * (1.0 - KAPPA); + // Clip outer top right cap + ctx.bezierCurveTo(left + width, top + height - c0, left + width - c0, top + height, left + width - rbr, top + height); + // Move left in case the margin exceedes the radius + const topBottomXCoord = left + width - Math.max(borderRightWidth, rbr); + ctx.lineTo(topBottomXCoord, top + height); + // Clip inner bottom right cap + ctx.lineTo(topBottomXCoord, top + height - borderBottomWidth); + // Ellipse coefficients inner bottom right cap + const innerBottomRightRadiusX = Math.max(rbr - borderRightWidth, 0); + const innerBottomRightRadiusY = Math.max(rbr - borderBottomWidth, 0); + const c1 = innerBottomRightRadiusX * (1.0 - KAPPA); + const c2 = innerBottomRightRadiusY * (1.0 - KAPPA); + // Clip inner top right cap + ctx.bezierCurveTo(left + width - borderRightWidth - c1, top + height - borderBottomWidth, left + width - borderRightWidth, top + height - borderBottomWidth - c2, left + width - borderRightWidth, top + height - Math.max(rbr, borderBottomWidth)); + // Clip inner right border edge + ctx.lineTo(left + width - borderRightWidth, top + Math.max(rtr, borderTopWidth)); + // Ellipse coefficients inner top right cap + const innerTopRightRadiusX = Math.max(rtr - borderRightWidth, 0); + const innerTopRightRadiusY = Math.max(rtr - borderTopWidth, 0); + const c3 = innerTopRightRadiusX * (1.0 - KAPPA); + const c4 = innerTopRightRadiusY * (1.0 - KAPPA); + const topRightXCoord = left + width - Math.max(rtr, borderRightWidth); + // Clip inner top left cap + ctx.bezierCurveTo(left + width - borderRightWidth, top + borderTopWidth + c4, left + width - borderRightWidth - c3, top + borderTopWidth, topRightXCoord, top + borderTopWidth); + ctx.lineTo(topRightXCoord, top); + // Move right in case the margin exceedes the radius + ctx.lineTo(left + width - rtr, top); + // Ellipse coefficients outer top right cap + const c5 = rtr * (1.0 - KAPPA); + // Clip outer top right cap + ctx.bezierCurveTo(left + width - c5, top, left + width, top + c5, left + width, top + rtr); + ctx.closePath(); + ctx.clip(); + // Clip border right cap joins + if (borderTopWidth) { + const trSlope = -borderTopWidth / borderRightWidth; + ctx.moveTo(left + width / 2, trSlope * (-width / 2) + top); + ctx.lineTo(left + width, top); + ctx.lineTo(left + width, top + height); + ctx.lineTo(left, top + height); + ctx.closePath(); + ctx.clip(); + } + if (borderBottomWidth) { + const brSlope = borderBottomWidth / borderRightWidth; + ctx.moveTo(left + width / 2, brSlope * (-width / 2) + top + height); + ctx.lineTo(left + width, top + height); + ctx.lineTo(left + width, top); + ctx.lineTo(left, top); + ctx.closePath(); + ctx.clip(); + } +}; +const fillBorderRight = (ctx, layout, style, rtr, rbr) => { + const { top, left, width, height } = layout; + const { borderRightColor, borderRightStyle, borderRightWidth, borderTopWidth, borderBottomWidth, } = style; + const c0 = rbr * (1.0 - KAPPA); + const c1 = rtr * (1.0 - KAPPA); + ctx.moveTo(left + width - rtr, top); + ctx.bezierCurveTo(left + width - c1, top, left + width, top + c1, left + width, top + rtr); + ctx.lineTo(left + width, top + height - rbr); + ctx.bezierCurveTo(left + width, top + height - c0, left + width - c0, top + height, left + width - rbr, top + height); + ctx.strokeColor(borderRightColor); + ctx.lineWidth(Math.max(borderRightWidth, borderTopWidth, borderBottomWidth) * 2); + if (borderRightStyle === 'dashed') { + ctx.dash(borderRightWidth * 2, { space: borderRightWidth * 1.2 }); + } + else if (borderRightStyle === 'dotted') { + ctx.dash(borderRightWidth, { space: borderRightWidth * 1.2 }); + } + ctx.stroke(); + ctx.undash(); +}; +const clipBorderBottom = (ctx, layout, style, rbl, rbr) => { + const { top, left, width, height } = layout; + const { borderBottomWidth, borderRightWidth, borderLeftWidth } = style; + // Clip outer top border edge + ctx.moveTo(left + width - rbr, top + height); + ctx.lineTo(left + rbl, top + height); + // Ellipse coefficients outer top right cap + const c0 = rbl * (1.0 - KAPPA); + // Clip outer top right cap + ctx.bezierCurveTo(left + c0, top + height, left, top + height - c0, left, top + height - rbl); + // Move up in case the margin exceedes the radius + const bottomLeftYCoord = top + height - Math.max(borderBottomWidth, rbl); + ctx.lineTo(left, bottomLeftYCoord); + // Clip inner bottom left cap + ctx.lineTo(left + borderLeftWidth, bottomLeftYCoord); + // Ellipse coefficients inner top right cap + const innerBottomLeftRadiusX = Math.max(rbl - borderLeftWidth, 0); + const innerBottomLeftRadiusY = Math.max(rbl - borderBottomWidth, 0); + const c1 = innerBottomLeftRadiusX * (1.0 - KAPPA); + const c2 = innerBottomLeftRadiusY * (1.0 - KAPPA); + // Clip inner bottom left cap + ctx.bezierCurveTo(left + borderLeftWidth, top + height - borderBottomWidth - c2, left + borderLeftWidth + c1, top + height - borderBottomWidth, left + borderLeftWidth + innerBottomLeftRadiusX, top + height - borderBottomWidth); + // Clip inner bottom border edge + ctx.lineTo(left + width - Math.max(rbr, borderRightWidth), top + height - borderBottomWidth); + // Ellipse coefficients inner top left cap + const innerBottomRightRadiusX = Math.max(rbr - borderRightWidth, 0); + const innerBottomRightRadiusY = Math.max(rbr - borderBottomWidth, 0); + const c3 = innerBottomRightRadiusX * (1.0 - KAPPA); + const c4 = innerBottomRightRadiusY * (1.0 - KAPPA); + const bottomRightYCoord = top + height - Math.max(borderBottomWidth, rbr); + // Clip inner top left cap + ctx.bezierCurveTo(left + width - borderRightWidth - c3, top + height - borderBottomWidth, left + width - borderRightWidth, top + height - borderBottomWidth - c4, left + width - borderRightWidth, bottomRightYCoord); + ctx.lineTo(left + width, bottomRightYCoord); + // Move down in case the margin exceedes the radius + ctx.lineTo(left + width, top + height - rbr); + // Ellipse coefficients outer top left cap + const c5 = rbr * (1.0 - KAPPA); + // Clip outer top left cap + ctx.bezierCurveTo(left + width, top + height - c5, left + width - c5, top + height, left + width - rbr, top + height); + ctx.closePath(); + ctx.clip(); + // Clip border bottom cap joins + if (borderRightWidth) { + const brSlope = borderBottomWidth / borderRightWidth; + ctx.moveTo(left + width / 2, brSlope * (-width / 2) + top + height); + ctx.lineTo(left + width, top + height); + ctx.lineTo(left, top + height); + ctx.lineTo(left, top); + ctx.closePath(); + ctx.clip(); + } + if (borderLeftWidth) { + const trSlope = -borderBottomWidth / borderLeftWidth; + ctx.moveTo(left + width / 2, trSlope * (width / 2) + top + height); + ctx.lineTo(left, top + height); + ctx.lineTo(left + width, top + height); + ctx.lineTo(left + width, top); + ctx.closePath(); + ctx.clip(); + } +}; +const fillBorderBottom = (ctx, layout, style, rbl, rbr) => { + const { top, left, width, height } = layout; + const { borderBottomColor, borderBottomStyle, borderBottomWidth, borderRightWidth, borderLeftWidth, } = style; + const c0 = rbl * (1.0 - KAPPA); + const c1 = rbr * (1.0 - KAPPA); + ctx.moveTo(left + width, top + height - rbr); + ctx.bezierCurveTo(left + width, top + height - c1, left + width - c1, top + height, left + width - rbr, top + height); + ctx.lineTo(left + rbl, top + height); + ctx.bezierCurveTo(left + c0, top + height, left, top + height - c0, left, top + height - rbl); + ctx.strokeColor(borderBottomColor); + ctx.lineWidth(Math.max(borderBottomWidth, borderRightWidth, borderLeftWidth) * 2); + if (borderBottomStyle === 'dashed') { + ctx.dash(borderBottomWidth * 2, { space: borderBottomWidth * 1.2 }); + } + else if (borderBottomStyle === 'dotted') { + ctx.dash(borderBottomWidth, { space: borderBottomWidth * 1.2 }); + } + ctx.stroke(); + ctx.undash(); +}; +const clipBorderLeft = (ctx, layout, style, rbl, rtl) => { + const { top, left, width, height } = layout; + const { borderTopWidth, borderLeftWidth, borderBottomWidth } = style; + // Clip outer left border edge + ctx.moveTo(left, top + height - rbl); + ctx.lineTo(left, top + rtl); + // Ellipse coefficients outer top left cap + const c0 = rtl * (1.0 - KAPPA); + // Clip outer top left cap + ctx.bezierCurveTo(left, top + c0, left + c0, top, left + rtl, top); + // Move right in case the margin exceedes the radius + const topLeftCoordX = left + Math.max(borderLeftWidth, rtl); + ctx.lineTo(topLeftCoordX, top); + // Clip inner top left cap + ctx.lineTo(topLeftCoordX, top + borderTopWidth); + // Ellipse coefficients inner top left cap + const innerTopLeftRadiusX = Math.max(rtl - borderLeftWidth, 0); + const innerTopLeftRadiusY = Math.max(rtl - borderTopWidth, 0); + const c1 = innerTopLeftRadiusX * (1.0 - KAPPA); + const c2 = innerTopLeftRadiusY * (1.0 - KAPPA); + // Clip inner top right cap + ctx.bezierCurveTo(left + borderLeftWidth + c1, top + borderTopWidth, left + borderLeftWidth, top + borderTopWidth + c2, left + borderLeftWidth, top + Math.max(rtl, borderTopWidth)); + // Clip inner left border edge + ctx.lineTo(left + borderLeftWidth, top + height - Math.max(rbl, borderBottomWidth)); + // Ellipse coefficients inner bottom left cap + const innerBottomLeftRadiusX = Math.max(rbl - borderLeftWidth, 0); + const innerBottomLeftRadiusY = Math.max(rbl - borderBottomWidth, 0); + const c3 = innerBottomLeftRadiusX * (1.0 - KAPPA); + const c4 = innerBottomLeftRadiusY * (1.0 - KAPPA); + const bottomLeftXCoord = left + Math.max(rbl, borderLeftWidth); + // Clip inner top left cap + ctx.bezierCurveTo(left + borderLeftWidth, top + height - borderBottomWidth - c4, left + borderLeftWidth + c3, top + height - borderBottomWidth, bottomLeftXCoord, top + height - borderBottomWidth); + ctx.lineTo(bottomLeftXCoord, top + height); + // Move left in case the margin exceedes the radius + ctx.lineTo(left + rbl, top + height); + // Ellipse coefficients outer top right cap + const c5 = rbl * (1.0 - KAPPA); + // Clip outer top right cap + ctx.bezierCurveTo(left + c5, top + height, left, top + height - c5, left, top + height - rbl); + ctx.closePath(); + ctx.clip(); + // Clip border right cap joins + if (borderBottomWidth) { + const trSlope = -borderBottomWidth / borderLeftWidth; + ctx.moveTo(left + width / 2, trSlope * (width / 2) + top + height); + ctx.lineTo(left, top + height); + ctx.lineTo(left, top); + ctx.lineTo(left + width, top); + ctx.closePath(); + ctx.clip(); + } + if (borderTopWidth) { + const trSlope = -borderTopWidth / borderLeftWidth; + ctx.moveTo(left + width / 2, trSlope * (-width / 2) + top); + ctx.lineTo(left, top); + ctx.lineTo(left, top + height); + ctx.lineTo(left + width, top + height); + ctx.closePath(); + ctx.clip(); + } +}; +const fillBorderLeft = (ctx, layout, style, rbl, rtl) => { + const { top, left, height } = layout; + const { borderLeftColor, borderLeftStyle, borderLeftWidth, borderTopWidth, borderBottomWidth, } = style; + const c0 = rbl * (1.0 - KAPPA); + const c1 = rtl * (1.0 - KAPPA); + ctx.moveTo(left + rbl, top + height); + ctx.bezierCurveTo(left + c0, top + height, left, top + height - c0, left, top + height - rbl); + ctx.lineTo(left, top + rtl); + ctx.bezierCurveTo(left, top + c1, left + c1, top, left + rtl, top); + ctx.strokeColor(borderLeftColor); + ctx.lineWidth(Math.max(borderLeftWidth, borderTopWidth, borderBottomWidth) * 2); + if (borderLeftStyle === 'dashed') { + ctx.dash(borderLeftWidth * 2, { space: borderLeftWidth * 1.2 }); + } + else if (borderLeftStyle === 'dotted') { + ctx.dash(borderLeftWidth, { space: borderLeftWidth * 1.2 }); + } + ctx.stroke(); + ctx.undash(); +}; +const shouldRenderBorders = (node) => node.box && + (node.box.borderTopWidth || + node.box.borderRightWidth || + node.box.borderBottomWidth || + node.box.borderLeftWidth); +const renderBorders = (ctx, node) => { + if (!node.box) + return; + if (!shouldRenderBorders(node)) + return; + const { width, height, borderTopWidth = 0, borderLeftWidth = 0, borderRightWidth = 0, borderBottomWidth = 0, } = node.box; + const { opacity = 1, borderTopColor = 'black', borderTopStyle = 'solid', borderLeftColor = 'black', borderLeftStyle = 'solid', borderRightColor = 'black', borderRightStyle = 'solid', borderBottomColor = 'black', borderBottomStyle = 'solid', } = node.style; + // @ts-expect-error this is always a number due to resolve border radius step + const borderTopLeftRadius = node.style.borderTopLeftRadius || 0; + // @ts-expect-error this is always a number due to resolve border radius step + const borderTopRightRadius = node.style.borderTopRightRadius || 0; + // @ts-expect-error this is always a number due to resolve border radius step + const borderBottomLeftRadius = node.style.borderBottomLeftRadius || 0; + // @ts-expect-error this is always a number due to resolve border radius step + const borderBottomRightRadius = node.style.borderBottomRightRadius || 0; + const style = { + borderTopColor, + borderTopWidth, + borderTopStyle, + borderLeftColor, + borderLeftWidth, + borderLeftStyle, + borderRightColor, + borderRightWidth, + borderRightStyle, + borderBottomColor, + borderBottomWidth, + borderBottomStyle}; + const rtr = Math.min(borderTopRightRadius, 0.5 * width, 0.5 * height); + const rtl = Math.min(borderTopLeftRadius, 0.5 * width, 0.5 * height); + const rbr = Math.min(borderBottomRightRadius, 0.5 * width, 0.5 * height); + const rbl = Math.min(borderBottomLeftRadius, 0.5 * width, 0.5 * height); + ctx.save(); + ctx.strokeOpacity(opacity); + if (borderTopWidth) { + ctx.save(); + clipBorderTop(ctx, node.box, style, rtr, rtl); + fillBorderTop(ctx, node.box, style, rtr, rtl); + ctx.restore(); + } + if (borderRightWidth) { + ctx.save(); + clipBorderRight(ctx, node.box, style, rtr, rbr); + fillBorderRight(ctx, node.box, style, rtr, rbr); + ctx.restore(); + } + if (borderBottomWidth) { + ctx.save(); + clipBorderBottom(ctx, node.box, style, rbl, rbr); + fillBorderBottom(ctx, node.box, style, rbl, rbr); + ctx.restore(); + } + if (borderLeftWidth) { + ctx.save(); + clipBorderLeft(ctx, node.box, style, rbl, rtl); + fillBorderLeft(ctx, node.box, style, rbl, rtl); + ctx.restore(); + } + ctx.restore(); +}; + +const drawBackground = (ctx, node) => { + if (!node.box) + return; + const { top, left, width, height } = node.box; + const color = parseColor(node.style.backgroundColor); + const nodeOpacity = isNil(node.style?.opacity) ? 1 : node.style.opacity; + const opacity = Math.min(color.opacity, nodeOpacity); + ctx + .fillOpacity(opacity) + .fillColor(color.value) + .rect(left, top, width, height) + .fill(); +}; +const renderBackground = (ctx, node) => { + const hasBackground = !!node.box && !!node.style?.backgroundColor; + if (hasBackground) { + ctx.save(); + clipNode(ctx, node); + drawBackground(ctx, node); + ctx.restore(); + } +}; + +const isString = (value) => typeof value === 'string'; +const isSrcId = (value) => /^#.+/.test(value); +const renderLink = (ctx, node, src) => { + if (!src || !node.box) + return; + const isId = isSrcId(src); + const method = isId ? 'goTo' : 'link'; + const value = isId ? src.slice(1) : src; + const { top, left, width, height } = node.box; + const props = node.props || {}; + const slop = resolveHitSlop('hitSlop' in props ? props.hitSlop : undefined); + ctx[method](left - slop.left, top - slop.top, width + slop.left + slop.right, height + slop.top + slop.bottom, value); +}; +const setLink = (ctx, node) => { + const props = node.props || {}; + if ('src' in props && isString(props.src)) + return renderLink(ctx, node, props.src); + if ('href' in props && isString(props.href)) + return renderLink(ctx, node, props.href); +}; + +const setDestination = (ctx, node) => { + if (!node.box) + return; + if (!node.props) + return; + if ('id' in node.props) { + ctx.addNamedDestination(node.props.id, 'XYZ', null, node.box.top, null); + } +}; + +const clean = (options) => { + const opt = { ...options }; + // We need to ensure the elements are no present if not true + Object.entries(opt).forEach((pair) => { + if (!pair[1]) { + delete opt[pair[0]]; + } + }); + return opt; +}; +const parseCommonFormOptions = (node) => { + // Common Options + return { + required: node.props?.required || false, + noExport: node.props?.noExport || false, + readOnly: node.props?.readOnly || false, + value: node.props?.value || undefined, + defaultValue: node.props?.defaultValue || undefined, + }; +}; +const parseTextInputOptions = (node, fieldSet) => { + return clean({ + ...parseCommonFormOptions(node), + parent: fieldSet || undefined, + align: node.props?.align || 'left', + multiline: node.props?.multiline || undefined, + password: node.props?.password || false, + noSpell: node.props?.noSpell || false, + format: node.props?.format || undefined, + fontSize: node.props?.fontSize || undefined, + MaxLen: node.props?.maxLength || undefined, + }); +}; +const parseSelectAndListFieldOptions = (node) => { + return clean({ + ...parseCommonFormOptions(node), + sort: node.props?.sort || false, + edit: node.props?.edit || false, + multiSelect: node.props?.multiSelect || false, + noSpell: node.props?.noSpell || false, + select: node.props?.select || [''], + }); +}; +const getAppearance = (ctx, codepoint, width, height) => { + const appearance = ctx.ref({ + Type: 'XObject', + Subtype: 'Form', + BBox: [0, 0, width, height], + Resources: { + ProcSet: ['PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'], + Font: { + ZaDi: ctx._acroform.fonts.ZaDi, + }, + }, + }); + appearance.initDeflate(); + appearance.write(`/Tx BMC\nq\n/ZaDi ${height * 0.8} Tf\nBT\n${width * 0.45} ${height / 4} Td (${codepoint}) Tj\nET\nQ\nEMC`); + appearance.end(null); + return appearance; +}; +const parseCheckboxOptions = (ctx, node, fieldSet) => { + const { width, height } = node.box || {}; + const onOption = node.props?.onState || 'Yes'; + const offOption = node.props?.offState || 'Off'; + const xMark = node.props?.xMark || false; + if (!Object.prototype.hasOwnProperty.call(ctx._acroform.fonts, 'ZaDi')) { + const ref = ctx.ref({ + Type: 'Font', + Subtype: 'Type1', + BaseFont: 'ZapfDingbats', + }); + ctx._acroform.fonts.ZaDi = ref; + ref.end(null); + } + const normalAppearance = { + [onOption]: getAppearance(ctx, xMark ? '8' : '4', width, height), + [offOption]: getAppearance(ctx, xMark ? ' ' : '8', width, height), + }; + return clean({ + ...parseCommonFormOptions(node), + backgroundColor: node.props?.backgroundColor || undefined, + borderColor: node.props?.borderColor || undefined, + parent: fieldSet || undefined, + value: `/${node.props?.checked === true ? onOption : offOption}`, + defaultValue: `/${node.props?.checked === true ? onOption : offOption}`, + AS: node.props?.checked === true ? onOption : offOption, + AP: { N: normalAppearance, D: normalAppearance }, + }); +}; + +const renderTextInput = (ctx, node, options) => { + if (!node.box) + return; + const { top, left, width, height } = node.box; + // Element's name + const name = node.props?.name || ''; + const fieldSetOptions = options.fieldSets?.at(0); + if (!ctx._root.data.AcroForm) { + ctx.initForm(); + } + ctx.formText(name, left, top, width, height, parseTextInputOptions(node, fieldSetOptions)); +}; + +const renderSelect = (ctx, node) => { + if (!node.box) + return; + const { top, left, width, height } = node.box; + // Element's name + const name = node.props?.name || ''; + if (!ctx._root.data.AcroForm) { + ctx.initForm(); + } + ctx.formCombo(name, left, top, width, height, parseSelectAndListFieldOptions(node)); +}; + +const renderFieldSet = (ctx, node, options) => { + const name = node.props?.name || ''; + if (!ctx._root.data.AcroForm) { + ctx.initForm(); + } + const formField = ctx.formField(name); + const option = options; + if (!option.fieldSets) { + option.fieldSets = [formField]; + } + else { + option.fieldSets.push(formField); + } +}; +const cleanUpFieldSet = (_ctx, _node, options) => { + options.fieldSets.pop(); +}; + +const renderList = (ctx, node) => { + if (!node.box) + return; + const { top, left, width, height } = node.box || {}; + // Element's name + const name = ('name' in node.props ? node.props.name || '' : ''); + if (!ctx._root.data.AcroForm) { + ctx.initForm(); + } + ctx.formList(name, left, top, width, height, parseSelectAndListFieldOptions(node)); +}; + +const renderCheckbox = (ctx, node, options) => { + if (!node.box) + return; + const { top, left, width, height } = node.box; + // Element's name + const name = node.props?.name || ''; + const fieldSetOptions = options.fieldSets?.at(0); + if (!ctx._root.data.AcroForm) { + ctx.initForm(); + } + ctx.formCheckbox(name, left, top, width, height, parseCheckboxOptions(ctx, node, fieldSetOptions)); +}; + +const isRecursiveNode = (node) => node.type !== P.Text && node.type !== P.Svg; +const renderChildren = (ctx, node, options) => { + ctx.save(); + if (node.box) { + ctx.translate(node.box.left, node.box.top); + } + const children = node.children || []; + const renderChild = (child) => renderNode(ctx, child, options); + children.forEach(renderChild); + ctx.restore(); +}; +const renderFns = { + [P.Text]: renderText, + [P.Note]: renderNote, + [P.Image]: renderImage, + [P.ImageBackground]: renderImageBackground, + [P.FieldSet]: renderFieldSet, + [P.TextInput]: renderTextInput, + [P.Select]: renderSelect, + [P.Checkbox]: renderCheckbox, + [P.List]: renderList, + [P.Canvas]: renderCanvas, + [P.Svg]: renderSvg, + [P.Link]: setLink, +}; +const cleanUpFns = { + [P.FieldSet]: cleanUpFieldSet, +}; +const renderNode = (ctx, node, options) => { + const overflowHidden = node.style?.overflow === 'hidden'; + const shouldRenderChildren = isRecursiveNode(node); + if (node.type === P.Page) + renderPage(ctx, node); + ctx.save(); + if (overflowHidden) + clipNode(ctx, node); + applyTransformations(ctx, node); + renderBackground(ctx, node); + renderBorders(ctx, node); + const renderFn = renderFns[node.type]; + if (renderFn) + renderFn(ctx, node, options); + if (shouldRenderChildren) + renderChildren(ctx, node, options); + const cleanUpFn = cleanUpFns[node.type]; + if (cleanUpFn) + cleanUpFn(ctx, node, options); + setDestination(ctx, node); + renderDebug(ctx, node); + ctx.restore(); +}; + +const addNodeBookmark = (ctx, node, pageNumber, registry) => { + if (!node.box) + return; + if (!node.props) + return; + if ('bookmark' in node.props && node.props.bookmark) { + const bookmark = node.props.bookmark; + const { title, parent, expanded, zoom, fit } = bookmark; + const outline = registry[parent] || ctx.outline; + const top = bookmark.top || node.box.top; + const left = bookmark.left || node.box.left; + const instance = outline.addItem(title, { + pageNumber, + expanded, + top, + left, + zoom, + fit, + }); + registry[bookmark.ref] = instance; + } + if (!node.children) + return; + node.children.forEach((child) => addNodeBookmark(ctx, child, pageNumber, registry)); +}; +const addBookmarks = (ctx, root) => { + const registry = {}; + const pages = root.children || []; + pages.forEach((page, i) => { + addNodeBookmark(ctx, page, i, registry); + }); +}; + +const render = (ctx, doc) => { + const pages = doc.children || []; + const options = { imageCache: new Map(), fieldSets: [] }; + pages.forEach((page) => renderNode(ctx, page, options)); + addBookmarks(ctx, doc); + ctx.end(); + return ctx; +}; + +export { render as default }; diff --git a/node_modules/@react-pdf/render/package.json b/node_modules/@react-pdf/render/package.json new file mode 100644 index 0000000000000000000000000000000000000000..361342b83ed5c399c791fe8eaed4a4caae83902d --- /dev/null +++ b/node_modules/@react-pdf/render/package.json @@ -0,0 +1,41 @@ +{ + "name": "@react-pdf/render", + "version": "4.5.1", + "license": "MIT", + "description": "A render engine for Node and the browser", + "author": "Diego Muracciole ", + "homepage": "https://github.com/diegomura/react-pdf#readme", + "type": "module", + "main": "./lib/index.js", + "repository": { + "type": "git", + "url": "https://github.com/diegomura/react-pdf.git", + "directory": "packages/render" + }, + "scripts": { + "test": "vitest", + "build": "rimraf ./lib && rollup -c", + "watch": "rimraf ./lib && rollup -c -w", + "typecheck": "tsc --noEmit" + }, + "dependencies": { + "@babel/runtime": "^7.20.13", + "@react-pdf/fns": "3.1.3", + "@react-pdf/primitives": "^4.3.0", + "@react-pdf/textkit": "^6.3.0", + "@react-pdf/types": "^2.11.1", + "abs-svg-path": "^0.1.1", + "color-string": "^2.1.4", + "normalize-svg-path": "^1.1.0", + "parse-svg-path": "^0.1.2", + "svg-arc-to-cubic-bezier": "^3.2.0" + }, + "devDependencies": { + "@react-pdf/layout": "^4.6.1", + "@types/abs-svg-path": "^0.1.3", + "@types/pdfkit": "^0.13.9" + }, + "files": [ + "lib" + ] +} diff --git a/node_modules/@react-pdf/renderer/README.md b/node_modules/@react-pdf/renderer/README.md new file mode 100644 index 0000000000000000000000000000000000000000..136b178a343a2fe8892cda5c20b7c4d9a38374b6 --- /dev/null +++ b/node_modules/@react-pdf/renderer/README.md @@ -0,0 +1,112 @@ +

+ +

React renderer for creating PDF files on the browser and server

+

+ + + + + + + + + + + + + + + +

+

+ +## How to install + +```sh +yarn add @react-pdf/renderer +``` + +## How it works + +```jsx +import React from 'react'; +import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer'; + +// Create styles +const styles = StyleSheet.create({ + page: { + flexDirection: 'row', + backgroundColor: '#E4E4E4', + }, + section: { + margin: 10, + padding: 10, + flexGrow: 1, + }, +}); + +// Create Document Component +const MyDocument = () => ( + + + + Section #1 + + + Section #2 + + + +); +``` + +### `Web.` Render in DOM + +```jsx +import React from 'react'; +import ReactDOM from 'react-dom'; +import { PDFViewer } from '@react-pdf/renderer'; + +const App = () => ( + + + +); + +ReactDOM.render(, document.getElementById('root')); +``` + +### `Node.` Save in a file + +```jsx +import React from 'react'; +import ReactPDF from '@react-pdf/renderer'; + +ReactPDF.render(, `${__dirname}/example.pdf`); +``` + +## Contributors + +This project exists thanks to all the people who contribute. Looking to contribute? Please check our [[contribute]](https://github.com/diegomura/react-pdf/blob/master/.github/CONTRIBUTING.md) document for more details about how to setup a development environment and submitting code. + + + +## Sponsors + +Thank you to all our sponsors! [[Become a sponsors](https://opencollective.com/react-pdf#sponsors)] + + + +## Backers + +Thank you to all our backers! [[Become a backer](https://opencollective.com/react-pdf#backer)] + + + +## License + +MIT © [Diego Muracciole](http://github.com/diegomura) + +--- + +[![](https://img.shields.io/npm/dt/@react-pdf/renderer.svg?style=flat)](https://www.npmjs.com/package/@react-pdf/renderer) diff --git a/node_modules/@react-pdf/renderer/index.d.ts b/node_modules/@react-pdf/renderer/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1aa2dc8042e236867156186033b1931bf366c2d2 --- /dev/null +++ b/node_modules/@react-pdf/renderer/index.d.ts @@ -0,0 +1,793 @@ +/* eslint-disable max-classes-per-file */ + +import * as React from 'react'; +import { + Style, + PageSize, + FontStore, + PDFVersion, + Orientation, + SourceObject, + SrcSet, + Sizes, + HyphenationCallback, + SVGPresentationAttributes, + Bookmark, + PageLayout, + PageMode, + HitSlop, +} from '@react-pdf/types'; + +declare class ReactPDF { + static default: typeof ReactPDF; +} + +export = ReactPDF; + +declare namespace ReactPDF { + interface Styles { + [key: string]: Style; + } + interface OnRenderProps { + blob?: Blob; + } + + interface Permissions { + printing?: 'lowResolution' | 'highResolution'; + modifying?: boolean; + copying?: boolean; + annotating?: boolean; + fillingForms?: boolean; + contentAccessibility?: boolean; + documentAssembly?: boolean; + } + + interface DocumentProps { + style?: Style | Style[]; + title?: string; + author?: string; + subject?: string; + creator?: string; + keywords?: string; + producer?: string; + language?: string; + creationDate?: Date; + modificationDate?: Date; + pdfVersion?: PDFVersion; + pageMode?: PageMode; + pageLayout?: PageLayout; + ownerPassword?: string; + userPassword?: string; + permissions?: Permissions; + onRender?: (props: OnRenderProps) => any; + } + + /** + * This component represent the PDF document itself. It must be the root + * of your tree element structure, and under no circumstances should it be + * used as children of another react-pdf component. In addition, it should + * only have childs of type . + */ + export class Document extends React.Component< + React.PropsWithChildren + > {} + + interface NodeProps { + id?: string; + style?: Style | Style[]; + /** + * Render component in all wrapped pages. + * @see https://react-pdf.org/advanced#fixed-components + */ + fixed?: boolean; + /** + * Force the wrapping algorithm to start a new page when rendering the + * element. + * @see https://react-pdf.org/advanced#page-breaks + */ + break?: boolean; + /** + * Hint that no page wrapping should occur between all sibling elements following the element within n points + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + minPresenceAhead?: number; + } + + interface PageProps extends NodeProps { + /** + * Enable page wrapping for this page. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + size?: PageSize; + orientation?: Orientation; + dpi?: number; + bookmark?: Bookmark; + } + + /** + * Represents single page inside the PDF document, or a subset of them if + * using the wrapping feature. A can contain as many pages as + * you want, but ensure not rendering a page inside any component besides + * Document. + */ + export class Page extends React.Component< + React.PropsWithChildren + > {} + + interface ViewProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + subPageNumber: number; + }) => React.ReactNode; + } + + /** + * The most fundamental component for building a UI and is designed to be + * nested inside other views and can have 0 to many children. + */ + export class View extends React.Component< + React.PropsWithChildren + > {} + + interface BaseImageProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * Works like the HTML img sizes attribute. + * @example 300 + * @example "300" + */ + sizes?: Sizes; + } + + interface ImageWithSrcProp extends BaseImageProps { + src: SourceObject; + } + + interface ImageWithSourceProp extends BaseImageProps { + source: SourceObject; + } + + type ImageProps = ImageWithSrcProp | ImageWithSourceProp; + + /** + * A React component for displaying network or local (Node only) JPG or + * PNG images, as well as base64 encoded image strings. + */ + export class Image extends React.Component {} + + interface BaseImageBackgroundProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * @example 300 + */ + sizes?: Sizes; + /** + * Style applied to the background image. + */ + imageStyle?: Style; + } + + interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps { + src: SourceObject; + } + + interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps { + source: SourceObject; + } + + type ImageBackgroundProps = + | ImageBackgroundWithSrcProp + | ImageBackgroundWithSourceProp; + + /** + * A React component for displaying an image behind child content. + * Compatible with React Native's ImageBackground component. + * @see https://reactnative.dev/docs/imagebackground + */ + export class ImageBackground extends React.Component< + React.PropsWithChildren + > {} + + interface TextProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + totalPages: number; + subPageNumber: number; + subPageTotalPages: number; + }) => React.ReactNode; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + /** + * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + orphans?: number; + /** + * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container.. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + widows?: number; + } + + interface SVGTextProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x: string | number; + y: string | number; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + } + + /** + * A React component for displaying text. Text supports nesting of other + * Text or Link components to create inline styling. + */ + export class Text extends React.Component< + React.PropsWithChildren | SVGTextProps + > {} + + interface LinkProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + href?: string; + src?: string; + /** + * Extends the clickable area of the link beyond its visible bounds. + * Accepts a number (applied to all sides) or an object with top, bottom, left, right. + * @see https://reactnative.dev/docs/view#hitslop + */ + hitSlop?: HitSlop; + } + + /** + * A React component for displaying a hyperlink. Link’s can be nested + * inside a Text component, or being inside any other valid primitive. + */ + export class Link extends React.Component< + React.PropsWithChildren + > {} + + interface FormCommonProps extends NodeProps { + name?: string; + required?: boolean; + noExport?: boolean; + readOnly?: boolean; + value?: number | string; + defaultValue?: number | string; + } + + interface FieldSetProps extends NodeProps { + name: string; + } + + export class FieldSet extends React.Component< + React.PropsWithChildren + > {} + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputFormatting { + type: + | 'date' + | 'time' + | 'percent' + | 'number' + | 'zip' + | 'zipPlus4' + | 'phone' + | 'ssn'; + param?: string; + nDec?: number; + sepComma?: boolean; + negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed'; + currency?: string; + currencyPrepend?: boolean; + } + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputProps extends FormCommonProps { + align?: 'left' | 'center' | 'right'; + multiline?: boolean; + /** + * The text will be masked (e.g. with asterisks). + */ + password?: boolean; + /** + * If set, text entered in the field is not spell-checked + */ + noSpell?: boolean; + format?: TextInputFormatting; + /** + * Sets the fontSize (default or 0 means auto sizing) + */ + fontSize?: number; + /** + * Sets the maximum length (characters) of the text in the field + */ + maxLength?: number; + } + + export class TextInput extends React.Component {} + + interface CheckboxProps extends FormCommonProps { + backgroundColor?: string; + borderColor?: string; + checked?: boolean; + onState?: string; + offState?: string; + xMark?: boolean; + } + + export class Checkbox extends React.Component {} + + interface SelectAndListPropsBase extends FormCommonProps { + sort?: boolean; + edit?: boolean; + multiSelect?: boolean; + noSpell?: boolean; + select?: string[]; + } + + type SelectAndListPropsWithEdit = SelectAndListPropsBase & { + edit: true | false; + noSpell: boolean; + }; + + type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & { + edit: boolean; + noSpell: true | false; + }; + + type SelectAndListProps = + | SelectAndListPropsWithEdit + | SelectAndListPropsWithNoSpell; + + export class Select extends React.Component {} + + export class List extends React.Component {} + + interface NoteProps extends NodeProps { + children: string; + } + + export class Note extends React.Component {} + + interface CanvasProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + paint: ( + painter: any, + availableWidth: number, + availableHeight: number, + ) => null; + } + + export class Canvas extends React.Component {} + + interface SVGProps extends NodeProps, SVGPresentationAttributes { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + width?: string | number; + height?: string | number; + viewBox?: string; + preserveAspectRatio?: string; + } + + /** + * The element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents. + */ + export class Svg extends React.Component> {} + + interface LineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x1: string | number; + x2: string | number; + y1: string | number; + y2: string | number; + } + + /** + * The element is used to create a line. + */ + export class Line extends React.Component< + React.PropsWithChildren + > {} + + interface PolylineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create any shape that consists of only straight lines (that is connected at several points). + */ + export class Polyline extends React.Component< + React.PropsWithChildren + > {} + + interface PolygonProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create a graphic that contains at least three sides. + * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up). + */ + export class Polygon extends React.Component< + React.PropsWithChildren + > {} + + interface PathProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + d: string; + } + + /** + * The element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more. + */ + export class Path extends React.Component< + React.PropsWithChildren + > {} + + interface RectProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x?: string | number; + y?: string | number; + width: string | number; + height: string | number; + rx?: string | number; + ry?: string | number; + } + + /** + * The element is used to create a rectangle and variations of a rectangle shape. + */ + export class Rect extends React.Component< + React.PropsWithChildren + > {} + + interface CircleProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + r: string | number; + } + + /** + * The element is used to create a circle. + */ + export class Circle extends React.Component< + React.PropsWithChildren + > {} + + interface EllipseProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + rx: string | number; + ry: string | number; + } + + /** + * The element is used to create an ellipse. + * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius. + */ + export class Ellipse extends React.Component< + React.PropsWithChildren + > {} + + interface TspanProps extends SVGPresentationAttributes { + x?: string | number; + y?: string | number; + } + + /** + * The element defines a subtext within a element or another element. + * It allows for adjustment of the style and/or position of that subtext as needed. + */ + export class Tspan extends React.Component< + React.PropsWithChildren + > {} + + interface GProps extends SVGPresentationAttributes { + style?: Style; + } + + /** + * The SVG element is a container used to group other SVG elements. + * Transformations applied to the element are performed on its child elements, and its attributes are inherited by its children. + */ + export class G extends React.Component> {} + + interface StopProps { + offset: string | number; + stopColor: string; + stopOpacity?: string | number; + } + + /** + * The SVG element defines a color and its position to use on a gradient. This element is always a child of a or element + */ + export class Stop extends React.Component< + React.PropsWithChildren + > {} + + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface DefsProps {} + + /** + * The element is used to store graphical objects that will be used at a later time. Objects created inside a element are not rendered directly. To display them you have to reference them + */ + export class Defs extends React.Component< + React.PropsWithChildren + > {} + + interface ClipPathProps { + id?: string; + } + + /** + * The SVG element defines a clipping path, to be used by the clipPath property. + * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn. + */ + export class ClipPath extends React.Component< + React.PropsWithChildren + > {} + + interface MarkerProps { + id: string; + viewBox?: string; + refX?: string | number; + refY?: string | number; + markerWidth?: string | number; + markerHeight?: string | number; + orient?: 'auto' | 'auto-start-reverse' | number; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; + } + + /** + * The SVG element defines a graphic used for drawing arrows or polymarkers on a given , , , or element. + * Markers can be attached to shapes using the markerStart, markerMid, and markerEnd properties. + */ + export class Marker extends React.Component< + React.PropsWithChildren + > {} + + interface LinearGradientProps { + id: string; + x1?: string | number; + x2?: string | number; + y1?: string | number; + y2?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define linear gradients that can be applied to fill or stroke of graphical elements. + */ + export class LinearGradient extends React.Component< + React.PropsWithChildren + > {} + + interface RadialGradientProps { + id: string; + cx?: string | number; + cy?: string | number; + r?: string | number; + fx?: string | number; + fy?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define radial gradients that can be applied to fill or stroke of graphical elements. + */ + export class RadialGradient extends React.Component< + React.PropsWithChildren + > {} + + interface BlobProviderParams { + blob: Blob | null; + url: string | null; + loading: boolean; + error: Error | null; + } + interface BlobProviderProps { + document: React.ReactElement; + children: (params: BlobProviderParams) => React.ReactNode; + } + + /** + * Easy and declarative way of getting document's blob data without + * showing it on screen. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class BlobProvider extends React.Component {} + + interface PDFViewerProps { + width?: number | string; + height?: number | string; + style?: Style | Style[]; + className?: string; + children?: React.ReactElement; + innerRef?: React.Ref; + showToolbar?: boolean; + } + + /** + * Iframe PDF viewer for client-side generated documents. + * @platform web + */ + export class PDFViewer extends React.Component {} + + interface PDFDownloadLinkProps + extends Omit< + React.AnchorHTMLAttributes, + 'href' | 'children' + > { + /** PDF filename. Alias for anchor tag `download` attribute. */ + fileName?: string; + document: React.ReactElement; + children?: React.ReactNode | React.FC; + onClick?: React.AnchorHTMLAttributes['onClick'] & + (( + event: React.MouseEvent, + instance: UsePDFInstance, + ) => void); + ref?: React.Ref | undefined; + } + + /** + * Anchor tag to enable generate and download PDF documents on the fly. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class PDFDownloadLink extends React.Component {} + + interface UsePDFInstance { + loading: boolean; + blob: Blob | null; + url: string | null; + error: string | null; + } + + /** + * React hook for creating and updating a PDF document instance + * @platform web + */ + export function usePDF(options?: { + document?: React.ReactElement; + }): [ + UsePDFInstance, + (newDocument: React.ReactElement) => void, + ]; + + export const Font: FontStore; + + export const StyleSheet: { + create: (styles: T) => T; + }; + + export const version: any; + + export const PDFRenderer: any; + + export const pdf: (initialValue?: React.ReactElement) => { + container: any; + isDirty: () => boolean; + toString: () => string; + toBlob: () => Promise; + toBuffer: () => Promise; + on: (event: 'change', callback: () => void) => void; + updateContainer: ( + document: React.ReactElement, + callback?: () => void, + ) => void; + removeListener: (event: 'change', callback: () => void) => void; + }; + + export const renderToStream: ( + document: React.ReactElement, + ) => Promise; + + /** + * @deprecated use the `renderToBuffer` method + */ + export const renderToString: ( + document: React.ReactElement, + ) => Promise; + + export const renderToFile: ( + document: React.ReactElement, + filePath: string, + callback?: (output: NodeJS.ReadableStream, _filePath: string) => any, + ) => Promise; + + const render: typeof renderToFile; + + /** + * Render document into a nodejs buffer + * @platform node + */ + export const renderToBuffer: ( + document: React.ReactElement, + ) => Promise; +} diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.browser.d.cts b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..1aa2dc8042e236867156186033b1931bf366c2d2 --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.d.cts @@ -0,0 +1,793 @@ +/* eslint-disable max-classes-per-file */ + +import * as React from 'react'; +import { + Style, + PageSize, + FontStore, + PDFVersion, + Orientation, + SourceObject, + SrcSet, + Sizes, + HyphenationCallback, + SVGPresentationAttributes, + Bookmark, + PageLayout, + PageMode, + HitSlop, +} from '@react-pdf/types'; + +declare class ReactPDF { + static default: typeof ReactPDF; +} + +export = ReactPDF; + +declare namespace ReactPDF { + interface Styles { + [key: string]: Style; + } + interface OnRenderProps { + blob?: Blob; + } + + interface Permissions { + printing?: 'lowResolution' | 'highResolution'; + modifying?: boolean; + copying?: boolean; + annotating?: boolean; + fillingForms?: boolean; + contentAccessibility?: boolean; + documentAssembly?: boolean; + } + + interface DocumentProps { + style?: Style | Style[]; + title?: string; + author?: string; + subject?: string; + creator?: string; + keywords?: string; + producer?: string; + language?: string; + creationDate?: Date; + modificationDate?: Date; + pdfVersion?: PDFVersion; + pageMode?: PageMode; + pageLayout?: PageLayout; + ownerPassword?: string; + userPassword?: string; + permissions?: Permissions; + onRender?: (props: OnRenderProps) => any; + } + + /** + * This component represent the PDF document itself. It must be the root + * of your tree element structure, and under no circumstances should it be + * used as children of another react-pdf component. In addition, it should + * only have childs of type . + */ + export class Document extends React.Component< + React.PropsWithChildren + > {} + + interface NodeProps { + id?: string; + style?: Style | Style[]; + /** + * Render component in all wrapped pages. + * @see https://react-pdf.org/advanced#fixed-components + */ + fixed?: boolean; + /** + * Force the wrapping algorithm to start a new page when rendering the + * element. + * @see https://react-pdf.org/advanced#page-breaks + */ + break?: boolean; + /** + * Hint that no page wrapping should occur between all sibling elements following the element within n points + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + minPresenceAhead?: number; + } + + interface PageProps extends NodeProps { + /** + * Enable page wrapping for this page. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + size?: PageSize; + orientation?: Orientation; + dpi?: number; + bookmark?: Bookmark; + } + + /** + * Represents single page inside the PDF document, or a subset of them if + * using the wrapping feature. A can contain as many pages as + * you want, but ensure not rendering a page inside any component besides + * Document. + */ + export class Page extends React.Component< + React.PropsWithChildren + > {} + + interface ViewProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + subPageNumber: number; + }) => React.ReactNode; + } + + /** + * The most fundamental component for building a UI and is designed to be + * nested inside other views and can have 0 to many children. + */ + export class View extends React.Component< + React.PropsWithChildren + > {} + + interface BaseImageProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * Works like the HTML img sizes attribute. + * @example 300 + * @example "300" + */ + sizes?: Sizes; + } + + interface ImageWithSrcProp extends BaseImageProps { + src: SourceObject; + } + + interface ImageWithSourceProp extends BaseImageProps { + source: SourceObject; + } + + type ImageProps = ImageWithSrcProp | ImageWithSourceProp; + + /** + * A React component for displaying network or local (Node only) JPG or + * PNG images, as well as base64 encoded image strings. + */ + export class Image extends React.Component {} + + interface BaseImageBackgroundProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * @example 300 + */ + sizes?: Sizes; + /** + * Style applied to the background image. + */ + imageStyle?: Style; + } + + interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps { + src: SourceObject; + } + + interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps { + source: SourceObject; + } + + type ImageBackgroundProps = + | ImageBackgroundWithSrcProp + | ImageBackgroundWithSourceProp; + + /** + * A React component for displaying an image behind child content. + * Compatible with React Native's ImageBackground component. + * @see https://reactnative.dev/docs/imagebackground + */ + export class ImageBackground extends React.Component< + React.PropsWithChildren + > {} + + interface TextProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + totalPages: number; + subPageNumber: number; + subPageTotalPages: number; + }) => React.ReactNode; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + /** + * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + orphans?: number; + /** + * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container.. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + widows?: number; + } + + interface SVGTextProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x: string | number; + y: string | number; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + } + + /** + * A React component for displaying text. Text supports nesting of other + * Text or Link components to create inline styling. + */ + export class Text extends React.Component< + React.PropsWithChildren | SVGTextProps + > {} + + interface LinkProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + href?: string; + src?: string; + /** + * Extends the clickable area of the link beyond its visible bounds. + * Accepts a number (applied to all sides) or an object with top, bottom, left, right. + * @see https://reactnative.dev/docs/view#hitslop + */ + hitSlop?: HitSlop; + } + + /** + * A React component for displaying a hyperlink. Link’s can be nested + * inside a Text component, or being inside any other valid primitive. + */ + export class Link extends React.Component< + React.PropsWithChildren + > {} + + interface FormCommonProps extends NodeProps { + name?: string; + required?: boolean; + noExport?: boolean; + readOnly?: boolean; + value?: number | string; + defaultValue?: number | string; + } + + interface FieldSetProps extends NodeProps { + name: string; + } + + export class FieldSet extends React.Component< + React.PropsWithChildren + > {} + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputFormatting { + type: + | 'date' + | 'time' + | 'percent' + | 'number' + | 'zip' + | 'zipPlus4' + | 'phone' + | 'ssn'; + param?: string; + nDec?: number; + sepComma?: boolean; + negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed'; + currency?: string; + currencyPrepend?: boolean; + } + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputProps extends FormCommonProps { + align?: 'left' | 'center' | 'right'; + multiline?: boolean; + /** + * The text will be masked (e.g. with asterisks). + */ + password?: boolean; + /** + * If set, text entered in the field is not spell-checked + */ + noSpell?: boolean; + format?: TextInputFormatting; + /** + * Sets the fontSize (default or 0 means auto sizing) + */ + fontSize?: number; + /** + * Sets the maximum length (characters) of the text in the field + */ + maxLength?: number; + } + + export class TextInput extends React.Component {} + + interface CheckboxProps extends FormCommonProps { + backgroundColor?: string; + borderColor?: string; + checked?: boolean; + onState?: string; + offState?: string; + xMark?: boolean; + } + + export class Checkbox extends React.Component {} + + interface SelectAndListPropsBase extends FormCommonProps { + sort?: boolean; + edit?: boolean; + multiSelect?: boolean; + noSpell?: boolean; + select?: string[]; + } + + type SelectAndListPropsWithEdit = SelectAndListPropsBase & { + edit: true | false; + noSpell: boolean; + }; + + type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & { + edit: boolean; + noSpell: true | false; + }; + + type SelectAndListProps = + | SelectAndListPropsWithEdit + | SelectAndListPropsWithNoSpell; + + export class Select extends React.Component {} + + export class List extends React.Component {} + + interface NoteProps extends NodeProps { + children: string; + } + + export class Note extends React.Component {} + + interface CanvasProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + paint: ( + painter: any, + availableWidth: number, + availableHeight: number, + ) => null; + } + + export class Canvas extends React.Component {} + + interface SVGProps extends NodeProps, SVGPresentationAttributes { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + width?: string | number; + height?: string | number; + viewBox?: string; + preserveAspectRatio?: string; + } + + /** + * The element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents. + */ + export class Svg extends React.Component> {} + + interface LineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x1: string | number; + x2: string | number; + y1: string | number; + y2: string | number; + } + + /** + * The element is used to create a line. + */ + export class Line extends React.Component< + React.PropsWithChildren + > {} + + interface PolylineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create any shape that consists of only straight lines (that is connected at several points). + */ + export class Polyline extends React.Component< + React.PropsWithChildren + > {} + + interface PolygonProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create a graphic that contains at least three sides. + * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up). + */ + export class Polygon extends React.Component< + React.PropsWithChildren + > {} + + interface PathProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + d: string; + } + + /** + * The element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more. + */ + export class Path extends React.Component< + React.PropsWithChildren + > {} + + interface RectProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x?: string | number; + y?: string | number; + width: string | number; + height: string | number; + rx?: string | number; + ry?: string | number; + } + + /** + * The element is used to create a rectangle and variations of a rectangle shape. + */ + export class Rect extends React.Component< + React.PropsWithChildren + > {} + + interface CircleProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + r: string | number; + } + + /** + * The element is used to create a circle. + */ + export class Circle extends React.Component< + React.PropsWithChildren + > {} + + interface EllipseProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + rx: string | number; + ry: string | number; + } + + /** + * The element is used to create an ellipse. + * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius. + */ + export class Ellipse extends React.Component< + React.PropsWithChildren + > {} + + interface TspanProps extends SVGPresentationAttributes { + x?: string | number; + y?: string | number; + } + + /** + * The element defines a subtext within a element or another element. + * It allows for adjustment of the style and/or position of that subtext as needed. + */ + export class Tspan extends React.Component< + React.PropsWithChildren + > {} + + interface GProps extends SVGPresentationAttributes { + style?: Style; + } + + /** + * The SVG element is a container used to group other SVG elements. + * Transformations applied to the element are performed on its child elements, and its attributes are inherited by its children. + */ + export class G extends React.Component> {} + + interface StopProps { + offset: string | number; + stopColor: string; + stopOpacity?: string | number; + } + + /** + * The SVG element defines a color and its position to use on a gradient. This element is always a child of a or element + */ + export class Stop extends React.Component< + React.PropsWithChildren + > {} + + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface DefsProps {} + + /** + * The element is used to store graphical objects that will be used at a later time. Objects created inside a element are not rendered directly. To display them you have to reference them + */ + export class Defs extends React.Component< + React.PropsWithChildren + > {} + + interface ClipPathProps { + id?: string; + } + + /** + * The SVG element defines a clipping path, to be used by the clipPath property. + * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn. + */ + export class ClipPath extends React.Component< + React.PropsWithChildren + > {} + + interface MarkerProps { + id: string; + viewBox?: string; + refX?: string | number; + refY?: string | number; + markerWidth?: string | number; + markerHeight?: string | number; + orient?: 'auto' | 'auto-start-reverse' | number; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; + } + + /** + * The SVG element defines a graphic used for drawing arrows or polymarkers on a given , , , or element. + * Markers can be attached to shapes using the markerStart, markerMid, and markerEnd properties. + */ + export class Marker extends React.Component< + React.PropsWithChildren + > {} + + interface LinearGradientProps { + id: string; + x1?: string | number; + x2?: string | number; + y1?: string | number; + y2?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define linear gradients that can be applied to fill or stroke of graphical elements. + */ + export class LinearGradient extends React.Component< + React.PropsWithChildren + > {} + + interface RadialGradientProps { + id: string; + cx?: string | number; + cy?: string | number; + r?: string | number; + fx?: string | number; + fy?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define radial gradients that can be applied to fill or stroke of graphical elements. + */ + export class RadialGradient extends React.Component< + React.PropsWithChildren + > {} + + interface BlobProviderParams { + blob: Blob | null; + url: string | null; + loading: boolean; + error: Error | null; + } + interface BlobProviderProps { + document: React.ReactElement; + children: (params: BlobProviderParams) => React.ReactNode; + } + + /** + * Easy and declarative way of getting document's blob data without + * showing it on screen. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class BlobProvider extends React.Component {} + + interface PDFViewerProps { + width?: number | string; + height?: number | string; + style?: Style | Style[]; + className?: string; + children?: React.ReactElement; + innerRef?: React.Ref; + showToolbar?: boolean; + } + + /** + * Iframe PDF viewer for client-side generated documents. + * @platform web + */ + export class PDFViewer extends React.Component {} + + interface PDFDownloadLinkProps + extends Omit< + React.AnchorHTMLAttributes, + 'href' | 'children' + > { + /** PDF filename. Alias for anchor tag `download` attribute. */ + fileName?: string; + document: React.ReactElement; + children?: React.ReactNode | React.FC; + onClick?: React.AnchorHTMLAttributes['onClick'] & + (( + event: React.MouseEvent, + instance: UsePDFInstance, + ) => void); + ref?: React.Ref | undefined; + } + + /** + * Anchor tag to enable generate and download PDF documents on the fly. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class PDFDownloadLink extends React.Component {} + + interface UsePDFInstance { + loading: boolean; + blob: Blob | null; + url: string | null; + error: string | null; + } + + /** + * React hook for creating and updating a PDF document instance + * @platform web + */ + export function usePDF(options?: { + document?: React.ReactElement; + }): [ + UsePDFInstance, + (newDocument: React.ReactElement) => void, + ]; + + export const Font: FontStore; + + export const StyleSheet: { + create: (styles: T) => T; + }; + + export const version: any; + + export const PDFRenderer: any; + + export const pdf: (initialValue?: React.ReactElement) => { + container: any; + isDirty: () => boolean; + toString: () => string; + toBlob: () => Promise; + toBuffer: () => Promise; + on: (event: 'change', callback: () => void) => void; + updateContainer: ( + document: React.ReactElement, + callback?: () => void, + ) => void; + removeListener: (event: 'change', callback: () => void) => void; + }; + + export const renderToStream: ( + document: React.ReactElement, + ) => Promise; + + /** + * @deprecated use the `renderToBuffer` method + */ + export const renderToString: ( + document: React.ReactElement, + ) => Promise; + + export const renderToFile: ( + document: React.ReactElement, + filePath: string, + callback?: (output: NodeJS.ReadableStream, _filePath: string) => any, + ) => Promise; + + const render: typeof renderToFile; + + /** + * Render document into a nodejs buffer + * @platform node + */ + export const renderToBuffer: ( + document: React.ReactElement, + ) => Promise; +} diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.browser.d.ts b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1aa2dc8042e236867156186033b1931bf366c2d2 --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.d.ts @@ -0,0 +1,793 @@ +/* eslint-disable max-classes-per-file */ + +import * as React from 'react'; +import { + Style, + PageSize, + FontStore, + PDFVersion, + Orientation, + SourceObject, + SrcSet, + Sizes, + HyphenationCallback, + SVGPresentationAttributes, + Bookmark, + PageLayout, + PageMode, + HitSlop, +} from '@react-pdf/types'; + +declare class ReactPDF { + static default: typeof ReactPDF; +} + +export = ReactPDF; + +declare namespace ReactPDF { + interface Styles { + [key: string]: Style; + } + interface OnRenderProps { + blob?: Blob; + } + + interface Permissions { + printing?: 'lowResolution' | 'highResolution'; + modifying?: boolean; + copying?: boolean; + annotating?: boolean; + fillingForms?: boolean; + contentAccessibility?: boolean; + documentAssembly?: boolean; + } + + interface DocumentProps { + style?: Style | Style[]; + title?: string; + author?: string; + subject?: string; + creator?: string; + keywords?: string; + producer?: string; + language?: string; + creationDate?: Date; + modificationDate?: Date; + pdfVersion?: PDFVersion; + pageMode?: PageMode; + pageLayout?: PageLayout; + ownerPassword?: string; + userPassword?: string; + permissions?: Permissions; + onRender?: (props: OnRenderProps) => any; + } + + /** + * This component represent the PDF document itself. It must be the root + * of your tree element structure, and under no circumstances should it be + * used as children of another react-pdf component. In addition, it should + * only have childs of type . + */ + export class Document extends React.Component< + React.PropsWithChildren + > {} + + interface NodeProps { + id?: string; + style?: Style | Style[]; + /** + * Render component in all wrapped pages. + * @see https://react-pdf.org/advanced#fixed-components + */ + fixed?: boolean; + /** + * Force the wrapping algorithm to start a new page when rendering the + * element. + * @see https://react-pdf.org/advanced#page-breaks + */ + break?: boolean; + /** + * Hint that no page wrapping should occur between all sibling elements following the element within n points + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + minPresenceAhead?: number; + } + + interface PageProps extends NodeProps { + /** + * Enable page wrapping for this page. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + size?: PageSize; + orientation?: Orientation; + dpi?: number; + bookmark?: Bookmark; + } + + /** + * Represents single page inside the PDF document, or a subset of them if + * using the wrapping feature. A can contain as many pages as + * you want, but ensure not rendering a page inside any component besides + * Document. + */ + export class Page extends React.Component< + React.PropsWithChildren + > {} + + interface ViewProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + subPageNumber: number; + }) => React.ReactNode; + } + + /** + * The most fundamental component for building a UI and is designed to be + * nested inside other views and can have 0 to many children. + */ + export class View extends React.Component< + React.PropsWithChildren + > {} + + interface BaseImageProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * Works like the HTML img sizes attribute. + * @example 300 + * @example "300" + */ + sizes?: Sizes; + } + + interface ImageWithSrcProp extends BaseImageProps { + src: SourceObject; + } + + interface ImageWithSourceProp extends BaseImageProps { + source: SourceObject; + } + + type ImageProps = ImageWithSrcProp | ImageWithSourceProp; + + /** + * A React component for displaying network or local (Node only) JPG or + * PNG images, as well as base64 encoded image strings. + */ + export class Image extends React.Component {} + + interface BaseImageBackgroundProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * @example 300 + */ + sizes?: Sizes; + /** + * Style applied to the background image. + */ + imageStyle?: Style; + } + + interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps { + src: SourceObject; + } + + interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps { + source: SourceObject; + } + + type ImageBackgroundProps = + | ImageBackgroundWithSrcProp + | ImageBackgroundWithSourceProp; + + /** + * A React component for displaying an image behind child content. + * Compatible with React Native's ImageBackground component. + * @see https://reactnative.dev/docs/imagebackground + */ + export class ImageBackground extends React.Component< + React.PropsWithChildren + > {} + + interface TextProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + totalPages: number; + subPageNumber: number; + subPageTotalPages: number; + }) => React.ReactNode; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + /** + * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + orphans?: number; + /** + * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container.. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + widows?: number; + } + + interface SVGTextProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x: string | number; + y: string | number; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + } + + /** + * A React component for displaying text. Text supports nesting of other + * Text or Link components to create inline styling. + */ + export class Text extends React.Component< + React.PropsWithChildren | SVGTextProps + > {} + + interface LinkProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + href?: string; + src?: string; + /** + * Extends the clickable area of the link beyond its visible bounds. + * Accepts a number (applied to all sides) or an object with top, bottom, left, right. + * @see https://reactnative.dev/docs/view#hitslop + */ + hitSlop?: HitSlop; + } + + /** + * A React component for displaying a hyperlink. Link’s can be nested + * inside a Text component, or being inside any other valid primitive. + */ + export class Link extends React.Component< + React.PropsWithChildren + > {} + + interface FormCommonProps extends NodeProps { + name?: string; + required?: boolean; + noExport?: boolean; + readOnly?: boolean; + value?: number | string; + defaultValue?: number | string; + } + + interface FieldSetProps extends NodeProps { + name: string; + } + + export class FieldSet extends React.Component< + React.PropsWithChildren + > {} + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputFormatting { + type: + | 'date' + | 'time' + | 'percent' + | 'number' + | 'zip' + | 'zipPlus4' + | 'phone' + | 'ssn'; + param?: string; + nDec?: number; + sepComma?: boolean; + negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed'; + currency?: string; + currencyPrepend?: boolean; + } + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputProps extends FormCommonProps { + align?: 'left' | 'center' | 'right'; + multiline?: boolean; + /** + * The text will be masked (e.g. with asterisks). + */ + password?: boolean; + /** + * If set, text entered in the field is not spell-checked + */ + noSpell?: boolean; + format?: TextInputFormatting; + /** + * Sets the fontSize (default or 0 means auto sizing) + */ + fontSize?: number; + /** + * Sets the maximum length (characters) of the text in the field + */ + maxLength?: number; + } + + export class TextInput extends React.Component {} + + interface CheckboxProps extends FormCommonProps { + backgroundColor?: string; + borderColor?: string; + checked?: boolean; + onState?: string; + offState?: string; + xMark?: boolean; + } + + export class Checkbox extends React.Component {} + + interface SelectAndListPropsBase extends FormCommonProps { + sort?: boolean; + edit?: boolean; + multiSelect?: boolean; + noSpell?: boolean; + select?: string[]; + } + + type SelectAndListPropsWithEdit = SelectAndListPropsBase & { + edit: true | false; + noSpell: boolean; + }; + + type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & { + edit: boolean; + noSpell: true | false; + }; + + type SelectAndListProps = + | SelectAndListPropsWithEdit + | SelectAndListPropsWithNoSpell; + + export class Select extends React.Component {} + + export class List extends React.Component {} + + interface NoteProps extends NodeProps { + children: string; + } + + export class Note extends React.Component {} + + interface CanvasProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + paint: ( + painter: any, + availableWidth: number, + availableHeight: number, + ) => null; + } + + export class Canvas extends React.Component {} + + interface SVGProps extends NodeProps, SVGPresentationAttributes { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + width?: string | number; + height?: string | number; + viewBox?: string; + preserveAspectRatio?: string; + } + + /** + * The element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents. + */ + export class Svg extends React.Component> {} + + interface LineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x1: string | number; + x2: string | number; + y1: string | number; + y2: string | number; + } + + /** + * The element is used to create a line. + */ + export class Line extends React.Component< + React.PropsWithChildren + > {} + + interface PolylineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create any shape that consists of only straight lines (that is connected at several points). + */ + export class Polyline extends React.Component< + React.PropsWithChildren + > {} + + interface PolygonProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create a graphic that contains at least three sides. + * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up). + */ + export class Polygon extends React.Component< + React.PropsWithChildren + > {} + + interface PathProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + d: string; + } + + /** + * The element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more. + */ + export class Path extends React.Component< + React.PropsWithChildren + > {} + + interface RectProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x?: string | number; + y?: string | number; + width: string | number; + height: string | number; + rx?: string | number; + ry?: string | number; + } + + /** + * The element is used to create a rectangle and variations of a rectangle shape. + */ + export class Rect extends React.Component< + React.PropsWithChildren + > {} + + interface CircleProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + r: string | number; + } + + /** + * The element is used to create a circle. + */ + export class Circle extends React.Component< + React.PropsWithChildren + > {} + + interface EllipseProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + rx: string | number; + ry: string | number; + } + + /** + * The element is used to create an ellipse. + * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius. + */ + export class Ellipse extends React.Component< + React.PropsWithChildren + > {} + + interface TspanProps extends SVGPresentationAttributes { + x?: string | number; + y?: string | number; + } + + /** + * The element defines a subtext within a element or another element. + * It allows for adjustment of the style and/or position of that subtext as needed. + */ + export class Tspan extends React.Component< + React.PropsWithChildren + > {} + + interface GProps extends SVGPresentationAttributes { + style?: Style; + } + + /** + * The SVG element is a container used to group other SVG elements. + * Transformations applied to the element are performed on its child elements, and its attributes are inherited by its children. + */ + export class G extends React.Component> {} + + interface StopProps { + offset: string | number; + stopColor: string; + stopOpacity?: string | number; + } + + /** + * The SVG element defines a color and its position to use on a gradient. This element is always a child of a or element + */ + export class Stop extends React.Component< + React.PropsWithChildren + > {} + + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface DefsProps {} + + /** + * The element is used to store graphical objects that will be used at a later time. Objects created inside a element are not rendered directly. To display them you have to reference them + */ + export class Defs extends React.Component< + React.PropsWithChildren + > {} + + interface ClipPathProps { + id?: string; + } + + /** + * The SVG element defines a clipping path, to be used by the clipPath property. + * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn. + */ + export class ClipPath extends React.Component< + React.PropsWithChildren + > {} + + interface MarkerProps { + id: string; + viewBox?: string; + refX?: string | number; + refY?: string | number; + markerWidth?: string | number; + markerHeight?: string | number; + orient?: 'auto' | 'auto-start-reverse' | number; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; + } + + /** + * The SVG element defines a graphic used for drawing arrows or polymarkers on a given , , , or element. + * Markers can be attached to shapes using the markerStart, markerMid, and markerEnd properties. + */ + export class Marker extends React.Component< + React.PropsWithChildren + > {} + + interface LinearGradientProps { + id: string; + x1?: string | number; + x2?: string | number; + y1?: string | number; + y2?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define linear gradients that can be applied to fill or stroke of graphical elements. + */ + export class LinearGradient extends React.Component< + React.PropsWithChildren + > {} + + interface RadialGradientProps { + id: string; + cx?: string | number; + cy?: string | number; + r?: string | number; + fx?: string | number; + fy?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define radial gradients that can be applied to fill or stroke of graphical elements. + */ + export class RadialGradient extends React.Component< + React.PropsWithChildren + > {} + + interface BlobProviderParams { + blob: Blob | null; + url: string | null; + loading: boolean; + error: Error | null; + } + interface BlobProviderProps { + document: React.ReactElement; + children: (params: BlobProviderParams) => React.ReactNode; + } + + /** + * Easy and declarative way of getting document's blob data without + * showing it on screen. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class BlobProvider extends React.Component {} + + interface PDFViewerProps { + width?: number | string; + height?: number | string; + style?: Style | Style[]; + className?: string; + children?: React.ReactElement; + innerRef?: React.Ref; + showToolbar?: boolean; + } + + /** + * Iframe PDF viewer for client-side generated documents. + * @platform web + */ + export class PDFViewer extends React.Component {} + + interface PDFDownloadLinkProps + extends Omit< + React.AnchorHTMLAttributes, + 'href' | 'children' + > { + /** PDF filename. Alias for anchor tag `download` attribute. */ + fileName?: string; + document: React.ReactElement; + children?: React.ReactNode | React.FC; + onClick?: React.AnchorHTMLAttributes['onClick'] & + (( + event: React.MouseEvent, + instance: UsePDFInstance, + ) => void); + ref?: React.Ref | undefined; + } + + /** + * Anchor tag to enable generate and download PDF documents on the fly. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class PDFDownloadLink extends React.Component {} + + interface UsePDFInstance { + loading: boolean; + blob: Blob | null; + url: string | null; + error: string | null; + } + + /** + * React hook for creating and updating a PDF document instance + * @platform web + */ + export function usePDF(options?: { + document?: React.ReactElement; + }): [ + UsePDFInstance, + (newDocument: React.ReactElement) => void, + ]; + + export const Font: FontStore; + + export const StyleSheet: { + create: (styles: T) => T; + }; + + export const version: any; + + export const PDFRenderer: any; + + export const pdf: (initialValue?: React.ReactElement) => { + container: any; + isDirty: () => boolean; + toString: () => string; + toBlob: () => Promise; + toBuffer: () => Promise; + on: (event: 'change', callback: () => void) => void; + updateContainer: ( + document: React.ReactElement, + callback?: () => void, + ) => void; + removeListener: (event: 'change', callback: () => void) => void; + }; + + export const renderToStream: ( + document: React.ReactElement, + ) => Promise; + + /** + * @deprecated use the `renderToBuffer` method + */ + export const renderToString: ( + document: React.ReactElement, + ) => Promise; + + export const renderToFile: ( + document: React.ReactElement, + filePath: string, + callback?: (output: NodeJS.ReadableStream, _filePath: string) => any, + ) => Promise; + + const render: typeof renderToFile; + + /** + * Render document into a nodejs buffer + * @platform node + */ + export const renderToBuffer: ( + document: React.ReactElement, + ) => Promise; +} diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.browser.js b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.js new file mode 100644 index 0000000000000000000000000000000000000000..31c0edf9b3ed142f6b11b877e36562ab99f1da9a --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.js @@ -0,0 +1,473 @@ +import * as primitives from '@react-pdf/primitives'; +export * from '@react-pdf/primitives'; +import queue from 'queue'; +import { useRef, useState, useEffect, useCallback, forwardRef } from 'react'; +import FontStore from '@react-pdf/font'; +import renderPDF from '@react-pdf/render'; +import PDFDocument from '@react-pdf/pdfkit'; +import layoutDocument from '@react-pdf/layout'; +import { upperFirst } from '@react-pdf/fns'; +import Reconciler from '@react-pdf/reconciler'; +import { jsx } from 'react/jsx-runtime'; + +const omitNils = object => Object.fromEntries(Object.entries(object).filter(_ref => { + let [, value] = _ref; + return value !== undefined; +})); + +const createInstance = (type, _ref) => { + let { + style, + children, + ...props + } = _ref; + return { + type, + box: {}, + style: style || {}, + props: props || {}, + children: [] + }; +}; +const createTextInstance = text => ({ + type: 'TEXT_INSTANCE', + value: text +}); +const appendChild = (parent, child) => { + const isParentText = parent.type === 'TEXT' || parent.type === 'LINK' || parent.type === 'TSPAN' || parent.type === 'NOTE'; + const isChildTextInstance = child.type === 'TEXT_INSTANCE'; + const isOrphanTextInstance = isChildTextInstance && !isParentText; + + // Ignore orphan text instances. + // Caused by cases such as <>{name && {name}} + if (isOrphanTextInstance) { + console.warn(`Invalid '${child.value}' string child outside component`); + return; + } + parent.children.push(child); +}; +const appendChildToContainer = (parentInstance, child) => { + if (parentInstance.type === 'ROOT') { + parentInstance.document = child; + } else { + appendChild(parentInstance, child); + } +}; +const insertBefore = (parentInstance, child, beforeChild) => { + var _parentInstance$child; + const index = (_parentInstance$child = parentInstance.children) === null || _parentInstance$child === void 0 ? void 0 : _parentInstance$child.indexOf(beforeChild); + if (index === undefined) return; + if (index !== -1 && child) parentInstance.children.splice(index, 0, child); +}; +const removeChild = (parentInstance, child) => { + var _parentInstance$child2; + const index = (_parentInstance$child2 = parentInstance.children) === null || _parentInstance$child2 === void 0 ? void 0 : _parentInstance$child2.indexOf(child); + if (index === undefined) return; + if (index !== -1) parentInstance.children.splice(index, 1); +}; +const removeChildFromContainer = (parentInstance, child) => { + var _parentInstance$child3; + const index = (_parentInstance$child3 = parentInstance.children) === null || _parentInstance$child3 === void 0 ? void 0 : _parentInstance$child3.indexOf(child); + if (index === undefined) return; + if (index !== -1) parentInstance.children.splice(index, 1); +}; +const commitTextUpdate = (textInstance, oldText, newText) => { + textInstance.value = newText; +}; +const commitUpdate = (instance, updatePayload, type, oldProps, newProps) => { + const { + style, + ...props + } = newProps; + instance.props = props; + instance.style = style; +}; +const createRenderer = _ref2 => { + let { + onChange = () => {} + } = _ref2; + return Reconciler({ + appendChild, + appendChildToContainer, + commitTextUpdate, + commitUpdate, + createInstance, + createTextInstance, + insertBefore, + removeChild, + removeChildFromContainer, + resetAfterCommit: onChange + }); +}; + +var version$1 = "4.5.1"; +var packageJson = { + version: version$1}; + +const { + version +} = packageJson; +const fontStore = new FontStore(); + +// We must keep a single renderer instance, otherwise React will complain +let renderer; + +// The pdf instance acts as an event emitter for DOM usage. +// We only want to trigger an update when PDF content changes +const events = {}; +const pdf = initialValue => { + const onChange = () => { + var _events$change; + const listeners = ((_events$change = events.change) === null || _events$change === void 0 ? void 0 : _events$change.slice()) || []; + for (let i = 0; i < listeners.length; i += 1) listeners[i](); + }; + const container = { + type: 'ROOT', + document: null + }; + renderer = renderer || createRenderer({ + onChange + }); + const mountNode = renderer.createContainer(container); + const updateContainer = (doc, callback) => { + renderer.updateContainer(doc, mountNode, null, callback); + }; + if (initialValue) updateContainer(initialValue); + const render = async function (compress) { + if (compress === void 0) { + compress = true; + } + const props = container.document.props || {}; + const { + pdfVersion, + language, + pageLayout, + pageMode, + title, + author, + subject, + keywords, + creator = 'react-pdf', + producer = 'react-pdf', + creationDate = new Date(), + modificationDate, + ownerPassword, + userPassword, + permissions + } = props; + const ctx = new PDFDocument({ + compress, + pdfVersion, + lang: language, + displayTitle: true, + autoFirstPage: false, + ownerPassword, + userPassword, + permissions, + pageLayout, + info: omitNils({ + Title: title, + Author: author, + Subject: subject, + Keywords: keywords, + Creator: creator, + Producer: producer, + CreationDate: creationDate, + ModificationDate: modificationDate + }) + }); + if (pageMode) { + ctx._root.data.PageMode = upperFirst(pageMode); + } + const layout = await layoutDocument(container.document, fontStore); + const fileStream = renderPDF(ctx, layout); + return { + layout, + fileStream + }; + }; + const callOnRender = function (params) { + if (params === void 0) { + params = {}; + } + if (container.document.props.onRender) { + container.document.props.onRender(params); + } + }; + const toBlob = async () => { + const chunks = []; + const { + layout: _INTERNAL__LAYOUT__DATA_, + fileStream: instance + } = await render(); + return new Promise((resolve, reject) => { + instance.on('data', chunk => { + chunks.push(chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk)); + }); + instance.on('end', () => { + try { + const blob = new Blob(chunks, { + type: 'application/pdf' + }); + callOnRender({ + blob, + _INTERNAL__LAYOUT__DATA_ + }); + resolve(blob); + } catch (error) { + reject(error); + } + }); + }); + }; + + // TODO: rename this method to `toStream` in next major release, because it return stream not a buffer + const toBuffer = async () => { + const { + layout: _INTERNAL__LAYOUT__DATA_, + fileStream + } = await render(); + callOnRender({ + _INTERNAL__LAYOUT__DATA_ + }); + return fileStream; + }; + + /* + * TODO: remove this method in next major release. it is buggy + * see + * - https://github.com/diegomura/react-pdf/issues/2112 + * - https://github.com/diegomura/react-pdf/issues/2095 + */ + const toString = async () => { + if (process.env.NODE_ENV === 'development') { + console.warn('`toString` is deprecated and will be removed in next major release'); + } + let result = ''; + const { + fileStream: instance + } = await render(false); // For some reason, when rendering to string if compress=true the document is blank + + return new Promise((resolve, reject) => { + try { + instance.on('data', buffer => { + result += buffer; + }); + instance.on('end', () => { + callOnRender(); + resolve(result); + }); + } catch (error) { + reject(error); + } + }); + }; + const on = (event, listener) => { + if (!events[event]) events[event] = []; + events[event].push(listener); + }; + const removeListener = (event, listener) => { + if (!events[event]) return; + const idx = events[event].indexOf(listener); + if (idx > -1) events[event].splice(idx, 1); + }; + return { + on, + container, + toBlob, + toBuffer, + toString, + removeListener, + updateContainer + }; +}; +const Font = fontStore; +const StyleSheet = { + create: s => s +}; + +/** + * PDF hook + * + * @param {Object} [options] hook options + * @returns {[Object, Function]} pdf state and update function + */ +const usePDF = function (_temp) { + let { + document + } = _temp === void 0 ? {} : _temp; + const pdfInstance = useRef(null); + const [state, setState] = useState({ + url: null, + blob: null, + error: null, + loading: !!document + }); + + // Setup rendering queue + useEffect(() => { + const renderQueue = queue({ + autostart: true, + concurrency: 1 + }); + const queueDocumentRender = () => { + setState(prev => ({ + ...prev, + loading: true + })); + renderQueue.splice(0, renderQueue.length, () => state.error ? Promise.resolve() : pdfInstance.current.toBlob()); + }; + const onRenderFailed = error => { + console.error(error); + setState(prev => ({ + ...prev, + loading: false, + error + })); + }; + const onRenderSuccessful = blob => { + setState({ + blob, + error: null, + loading: false, + url: URL.createObjectURL(blob) + }); + }; + pdfInstance.current = pdf(); + pdfInstance.current.on('change', queueDocumentRender); + if (document) { + pdfInstance.current.updateContainer(document); + } + renderQueue.on('error', onRenderFailed); + renderQueue.on('success', onRenderSuccessful); + return () => { + renderQueue.end(); + pdfInstance.current.removeListener('change', queueDocumentRender); + }; + }, []); + + // Revoke old unused url instances + useEffect(() => { + return () => { + if (state.url) { + URL.revokeObjectURL(state.url); + } + }; + }, [state.url]); + const update = useCallback(newDoc => { + pdfInstance.current.updateContainer(newDoc); + }, []); + return [state, update]; +}; + +const PDFViewer = _ref => { + let { + title, + style, + className, + children, + innerRef, + showToolbar = true, + ...props + } = _ref; + const [instance, updateInstance] = usePDF(); + useEffect(() => updateInstance(children), [children]); + const src = instance.url ? `${instance.url}#toolbar=${showToolbar ? 1 : 0}` : null; + return /*#__PURE__*/jsx("iframe", { + src: src, + title: title, + ref: innerRef, + style: style, + className: className, + ...props + }); +}; + +const BlobProvider = _ref => { + let { + document: doc, + children + } = _ref; + const [instance, updateInstance] = usePDF(); + useEffect(() => updateInstance(doc), [doc]); + if (!doc) { + console.warn('You should pass a valid document to BlobProvider'); + return null; + } + return children(instance); +}; + +const PDFDownloadLinkBase = (_ref, ref) => { + let { + fileName = 'document.pdf', + document: doc, + children, + onClick, + href, + ...rest + } = _ref; + const [instance, updateInstance] = usePDF(); + useEffect(() => updateInstance(doc), [doc]); + if (!doc) { + console.warn('You should pass a valid document to PDFDownloadLink'); + return null; + } + const handleDownloadIE = () => { + if (instance && window.navigator.msSaveBlob) { + // IE + window.navigator.msSaveBlob(instance.blob, fileName); + } + }; + const handleClick = event => { + handleDownloadIE(); + if (typeof onClick === 'function') onClick(event, instance); + }; + return /*#__PURE__*/jsx("a", { + href: instance.url, + download: fileName, + onClick: handleClick, + ref: ref, + ...rest, + children: typeof children === 'function' ? children(instance) : children + }); +}; +const PDFDownloadLink = /*#__PURE__*/forwardRef(PDFDownloadLinkBase); + +const throwEnvironmentError = name => { + throw new Error(`${name} is a Node specific API. You're either using this method in a browser, or your bundler is not loading react-pdf from the appropriate web build.`); +}; +const renderToStream = () => { + throwEnvironmentError('renderToStream'); +}; +const renderToBuffer = () => { + throwEnvironmentError('renderToBuffer'); +}; +const renderToString = () => { + throwEnvironmentError('renderToString'); +}; +const renderToFile = () => { + throwEnvironmentError('renderToFile'); +}; +const render = () => { + throwEnvironmentError('render'); +}; + +// TODO: remove this default export in next major release because it breaks tree-shacking +var index = { + pdf, + usePDF, + Font, + version, + StyleSheet, + PDFViewer, + BlobProvider, + PDFDownloadLink, + renderToStream, + renderToString, + renderToFile, + render, + ...primitives +}; + +export { BlobProvider, Font, PDFDownloadLink, PDFViewer, StyleSheet, createRenderer, index as default, pdf, render, renderToBuffer, renderToFile, renderToStream, renderToString, usePDF, version }; +//# sourceMappingURL=react-pdf.browser.js.map diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.browser.js.map b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d2d63fd955f22a68cd4b78355539a258f6acca5f --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"react-pdf.browser.js","sources":["../src/utils.js","../src/renderer.js","../src/index.js","../src/dom/usePDF.js","../src/dom/PDFViewer.js","../src/dom/BlobProvider.js","../src/dom/PDFDownloadLink.js","../src/dom/index.js"],"sourcesContent":["export const omitNils = (object) =>\n Object.fromEntries(\n Object.entries(object).filter(([, value]) => value !== undefined),\n );\n","import Reconciler from '@react-pdf/reconciler';\n\nconst createInstance = (type, { style, children, ...props }) => ({\n type,\n box: {},\n style: style || {},\n props: props || {},\n children: [],\n});\n\nconst createTextInstance = (text) => ({ type: 'TEXT_INSTANCE', value: text });\n\nconst appendChild = (parent, child) => {\n const isParentText =\n parent.type === 'TEXT' ||\n parent.type === 'LINK' ||\n parent.type === 'TSPAN' ||\n parent.type === 'NOTE';\n\n const isChildTextInstance = child.type === 'TEXT_INSTANCE';\n const isOrphanTextInstance = isChildTextInstance && !isParentText;\n\n // Ignore orphan text instances.\n // Caused by cases such as <>{name && {name}}\n if (isOrphanTextInstance) {\n console.warn(\n `Invalid '${child.value}' string child outside component`,\n );\n return;\n }\n\n parent.children.push(child);\n};\n\nconst appendChildToContainer = (parentInstance, child) => {\n if (parentInstance.type === 'ROOT') {\n parentInstance.document = child;\n } else {\n appendChild(parentInstance, child);\n }\n};\n\nconst insertBefore = (parentInstance, child, beforeChild) => {\n const index = parentInstance.children?.indexOf(beforeChild);\n\n if (index === undefined) return;\n\n if (index !== -1 && child) parentInstance.children.splice(index, 0, child);\n};\n\nconst removeChild = (parentInstance, child) => {\n const index = parentInstance.children?.indexOf(child);\n\n if (index === undefined) return;\n\n if (index !== -1) parentInstance.children.splice(index, 1);\n};\n\nconst removeChildFromContainer = (parentInstance, child) => {\n const index = parentInstance.children?.indexOf(child);\n\n if (index === undefined) return;\n\n if (index !== -1) parentInstance.children.splice(index, 1);\n};\n\nconst commitTextUpdate = (textInstance, oldText, newText) => {\n textInstance.value = newText;\n};\n\nconst commitUpdate = (instance, updatePayload, type, oldProps, newProps) => {\n const { style, ...props } = newProps;\n instance.props = props;\n instance.style = style;\n};\n\nconst createRenderer = ({ onChange = () => {} }) =>\n Reconciler({\n appendChild,\n appendChildToContainer,\n commitTextUpdate,\n commitUpdate,\n createInstance,\n createTextInstance,\n insertBefore,\n removeChild,\n removeChildFromContainer,\n resetAfterCommit: onChange,\n });\n\nexport default createRenderer;\n","import FontStore from '@react-pdf/font';\nimport renderPDF from '@react-pdf/render';\nimport PDFDocument from '@react-pdf/pdfkit';\nimport layoutDocument from '@react-pdf/layout';\nimport { upperFirst } from '@react-pdf/fns';\n\nimport { omitNils } from './utils';\nimport createRenderer from './renderer';\nimport packageJson from '../package.json';\n\nconst { version } = packageJson;\n\nconst fontStore = new FontStore();\n\n// We must keep a single renderer instance, otherwise React will complain\nlet renderer;\n\n// The pdf instance acts as an event emitter for DOM usage.\n// We only want to trigger an update when PDF content changes\nconst events = {};\n\nconst pdf = (initialValue) => {\n const onChange = () => {\n const listeners = events.change?.slice() || [];\n for (let i = 0; i < listeners.length; i += 1) listeners[i]();\n };\n\n const container = { type: 'ROOT', document: null };\n renderer = renderer || createRenderer({ onChange });\n const mountNode = renderer.createContainer(container);\n\n const updateContainer = (doc, callback) => {\n renderer.updateContainer(doc, mountNode, null, callback);\n };\n\n if (initialValue) updateContainer(initialValue);\n\n const render = async (compress = true) => {\n const props = container.document.props || {};\n const {\n pdfVersion,\n language,\n pageLayout,\n pageMode,\n title,\n author,\n subject,\n keywords,\n creator = 'react-pdf',\n producer = 'react-pdf',\n creationDate = new Date(),\n modificationDate,\n ownerPassword,\n userPassword,\n permissions,\n } = props;\n\n const ctx = new PDFDocument({\n compress,\n pdfVersion,\n lang: language,\n displayTitle: true,\n autoFirstPage: false,\n ownerPassword,\n userPassword,\n permissions,\n pageLayout,\n info: omitNils({\n Title: title,\n Author: author,\n Subject: subject,\n Keywords: keywords,\n Creator: creator,\n Producer: producer,\n CreationDate: creationDate,\n ModificationDate: modificationDate,\n }),\n });\n\n if (pageMode) {\n ctx._root.data.PageMode = upperFirst(pageMode);\n }\n\n const layout = await layoutDocument(container.document, fontStore);\n const fileStream = renderPDF(ctx, layout);\n return { layout, fileStream };\n };\n\n const callOnRender = (params = {}) => {\n if (container.document.props.onRender) {\n container.document.props.onRender(params);\n }\n };\n\n const toBlob = async () => {\n const chunks = [];\n const { layout: _INTERNAL__LAYOUT__DATA_, fileStream: instance } =\n await render();\n\n return new Promise((resolve, reject) => {\n instance.on('data', (chunk) => {\n chunks.push(\n chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk),\n );\n });\n\n instance.on('end', () => {\n try {\n const blob = new Blob(chunks, { type: 'application/pdf' });\n callOnRender({ blob, _INTERNAL__LAYOUT__DATA_ });\n resolve(blob);\n } catch (error) {\n reject(error);\n }\n });\n });\n };\n\n // TODO: rename this method to `toStream` in next major release, because it return stream not a buffer\n const toBuffer = async () => {\n const { layout: _INTERNAL__LAYOUT__DATA_, fileStream } = await render();\n callOnRender({ _INTERNAL__LAYOUT__DATA_ });\n\n return fileStream;\n };\n\n /*\n * TODO: remove this method in next major release. it is buggy\n * see\n * - https://github.com/diegomura/react-pdf/issues/2112\n * - https://github.com/diegomura/react-pdf/issues/2095\n */\n const toString = async () => {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '`toString` is deprecated and will be removed in next major release',\n );\n }\n\n let result = '';\n const { fileStream: instance } = await render(false); // For some reason, when rendering to string if compress=true the document is blank\n\n return new Promise((resolve, reject) => {\n try {\n instance.on('data', (buffer) => {\n result += buffer;\n });\n\n instance.on('end', () => {\n callOnRender();\n resolve(result);\n });\n } catch (error) {\n reject(error);\n }\n });\n };\n\n const on = (event, listener) => {\n if (!events[event]) events[event] = [];\n events[event].push(listener);\n };\n\n const removeListener = (event, listener) => {\n if (!events[event]) return;\n const idx = events[event].indexOf(listener);\n if (idx > -1) events[event].splice(idx, 1);\n };\n\n return {\n on,\n container,\n toBlob,\n toBuffer,\n toString,\n removeListener,\n updateContainer,\n };\n};\n\nconst Font = fontStore;\n\nconst StyleSheet = {\n create: (s) => s,\n};\n\nexport { version, Font, StyleSheet, pdf, createRenderer };\n","import queue from 'queue';\nimport { useState, useRef, useEffect, useCallback } from 'react';\n\nimport { pdf } from '../index';\n\n/**\n * PDF hook\n *\n * @param {Object} [options] hook options\n * @returns {[Object, Function]} pdf state and update function\n */\nexport const usePDF = ({ document } = {}) => {\n const pdfInstance = useRef(null);\n\n const [state, setState] = useState({\n url: null,\n blob: null,\n error: null,\n loading: !!document,\n });\n\n // Setup rendering queue\n useEffect(() => {\n const renderQueue = queue({ autostart: true, concurrency: 1 });\n\n const queueDocumentRender = () => {\n setState((prev) => ({ ...prev, loading: true }));\n\n renderQueue.splice(0, renderQueue.length, () =>\n state.error ? Promise.resolve() : pdfInstance.current.toBlob(),\n );\n };\n\n const onRenderFailed = (error) => {\n console.error(error);\n setState((prev) => ({ ...prev, loading: false, error }));\n };\n\n const onRenderSuccessful = (blob) => {\n setState({\n blob,\n error: null,\n loading: false,\n url: URL.createObjectURL(blob),\n });\n };\n\n pdfInstance.current = pdf();\n pdfInstance.current.on('change', queueDocumentRender);\n if (document) {\n pdfInstance.current.updateContainer(document);\n }\n\n renderQueue.on('error', onRenderFailed);\n renderQueue.on('success', onRenderSuccessful);\n\n return () => {\n renderQueue.end();\n pdfInstance.current.removeListener('change', queueDocumentRender);\n };\n }, []);\n\n // Revoke old unused url instances\n useEffect(() => {\n return () => {\n if (state.url) {\n URL.revokeObjectURL(state.url);\n }\n };\n }, [state.url]);\n\n const update = useCallback((newDoc) => {\n pdfInstance.current.updateContainer(newDoc);\n }, []);\n\n return [state, update];\n};\n\nexport default usePDF;\n","import { useEffect } from 'react';\n\nimport usePDF from './usePDF';\n\nexport const PDFViewer = ({\n title,\n style,\n className,\n children,\n innerRef,\n showToolbar = true,\n ...props\n}) => {\n const [instance, updateInstance] = usePDF();\n\n useEffect(() => updateInstance(children), [children]);\n\n const src = instance.url\n ? `${instance.url}#toolbar=${showToolbar ? 1 : 0}`\n : null;\n\n return (\n \n );\n};\n\nexport default PDFViewer;\n","import { useEffect } from 'react';\n\nimport usePDF from './usePDF';\n\nexport const BlobProvider = ({ document: doc, children }) => {\n const [instance, updateInstance] = usePDF();\n\n useEffect(() => updateInstance(doc), [doc]);\n\n if (!doc) {\n console.warn('You should pass a valid document to BlobProvider');\n return null;\n }\n\n return children(instance);\n};\n\nexport default BlobProvider;\n","import { forwardRef, useEffect } from 'react';\n\nimport usePDF from './usePDF';\n\nconst PDFDownloadLinkBase = (\n {\n fileName = 'document.pdf',\n document: doc,\n children,\n onClick,\n href,\n ...rest\n },\n ref,\n) => {\n const [instance, updateInstance] = usePDF();\n\n useEffect(() => updateInstance(doc), [doc]);\n\n if (!doc) {\n console.warn('You should pass a valid document to PDFDownloadLink');\n return null;\n }\n\n const handleDownloadIE = () => {\n if (instance && window.navigator.msSaveBlob) {\n // IE\n window.navigator.msSaveBlob(instance.blob, fileName);\n }\n };\n\n const handleClick = (event) => {\n handleDownloadIE();\n if (typeof onClick === 'function') onClick(event, instance);\n };\n\n return (\n \n {typeof children === 'function' ? children(instance) : children}\n \n );\n};\n\nexport const PDFDownloadLink = forwardRef(PDFDownloadLinkBase);\n\nexport default PDFDownloadLink;\n","import * as primitives from '@react-pdf/primitives';\n\nimport usePDF from './usePDF';\nimport PDFViewer from './PDFViewer';\nimport BlobProvider from './BlobProvider';\nimport PDFDownloadLink from './PDFDownloadLink';\nimport { pdf, version, Font, StyleSheet } from '../index';\n\nconst throwEnvironmentError = (name) => {\n throw new Error(\n `${name} is a Node specific API. You're either using this method in a browser, or your bundler is not loading react-pdf from the appropriate web build.`,\n );\n};\n\nexport const renderToStream = () => {\n throwEnvironmentError('renderToStream');\n};\n\nexport const renderToBuffer = () => {\n throwEnvironmentError('renderToBuffer');\n};\n\nexport const renderToString = () => {\n throwEnvironmentError('renderToString');\n};\n\nexport const renderToFile = () => {\n throwEnvironmentError('renderToFile');\n};\n\nexport const render = () => {\n throwEnvironmentError('render');\n};\n\nexport * from '../index';\n\nexport * from './usePDF';\n\nexport * from './PDFViewer';\n\nexport * from './BlobProvider';\n\nexport * from './PDFDownloadLink';\n\nexport * from '@react-pdf/primitives';\n\n// TODO: remove this default export in next major release because it breaks tree-shacking\nexport default {\n pdf,\n usePDF,\n Font,\n version,\n StyleSheet,\n PDFViewer,\n BlobProvider,\n PDFDownloadLink,\n renderToStream,\n renderToString,\n renderToFile,\n render,\n ...primitives,\n};\n"],"names":["omitNils","object","Object","fromEntries","entries","filter","_ref","value","undefined","createInstance","type","style","children","props","box","createTextInstance","text","appendChild","parent","child","isParentText","isChildTextInstance","isOrphanTextInstance","console","warn","push","appendChildToContainer","parentInstance","document","insertBefore","beforeChild","_parentInstance$child","index","indexOf","splice","removeChild","_parentInstance$child2","removeChildFromContainer","_parentInstance$child3","commitTextUpdate","textInstance","oldText","newText","commitUpdate","instance","updatePayload","oldProps","newProps","createRenderer","_ref2","onChange","Reconciler","resetAfterCommit","version","packageJson","fontStore","FontStore","renderer","events","pdf","initialValue","_events$change","listeners","change","slice","i","length","container","mountNode","createContainer","updateContainer","doc","callback","render","compress","pdfVersion","language","pageLayout","pageMode","title","author","subject","keywords","creator","producer","creationDate","Date","modificationDate","ownerPassword","userPassword","permissions","ctx","PDFDocument","lang","displayTitle","autoFirstPage","info","Title","Author","Subject","Keywords","Creator","Producer","CreationDate","ModificationDate","_root","data","PageMode","upperFirst","layout","layoutDocument","fileStream","renderPDF","callOnRender","params","onRender","toBlob","chunks","_INTERNAL__LAYOUT__DATA_","Promise","resolve","reject","on","chunk","Uint8Array","blob","Blob","error","toBuffer","toString","process","env","NODE_ENV","result","buffer","event","listener","removeListener","idx","Font","StyleSheet","create","s","usePDF","_temp","pdfInstance","useRef","state","setState","useState","url","loading","useEffect","renderQueue","queue","autostart","concurrency","queueDocumentRender","prev","current","onRenderFailed","onRenderSuccessful","URL","createObjectURL","end","revokeObjectURL","update","useCallback","newDoc","PDFViewer","className","innerRef","showToolbar","updateInstance","src","_jsx","ref","BlobProvider","PDFDownloadLinkBase","fileName","onClick","href","rest","handleDownloadIE","window","navigator","msSaveBlob","handleClick","download","PDFDownloadLink","forwardRef","throwEnvironmentError","name","Error","renderToStream","renderToBuffer","renderToString","renderToFile","primitives"],"mappings":";;;;;;;;;;;;AAAO,MAAMA,QAAQ,GAAIC,MAAM,IAC7BC,MAAM,CAACC,WAAW,CAChBD,MAAM,CAACE,OAAO,CAACH,MAAM,CAAC,CAACI,MAAM,CAACC,IAAA,IAAA;AAAA,EAAA,IAAC,GAAGC,KAAK,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,KAAKC,SAAS;AAAA,CAAA,CAClE,CAAC;;ACDH,MAAMC,cAAc,GAAGA,CAACC,IAAI,EAAAJ,IAAA,KAAA;EAAA,IAAE;IAAEK,KAAK;IAAEC,QAAQ;IAAE,GAAGC;AAAM,GAAC,GAAAP,IAAA;EAAA,OAAM;IAC/DI,IAAI;IACJI,GAAG,EAAE,EAAE;AACPH,IAAAA,KAAK,EAAEA,KAAK,IAAI,EAAE;AAClBE,IAAAA,KAAK,EAAEA,KAAK,IAAI,EAAE;AAClBD,IAAAA,QAAQ,EAAE;GACX;AAAA,CAAC;AAEF,MAAMG,kBAAkB,GAAIC,IAAI,KAAM;AAAEN,EAAAA,IAAI,EAAE,eAAe;AAAEH,EAAAA,KAAK,EAAES;AAAK,CAAC,CAAC;AAE7E,MAAMC,WAAW,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EACrC,MAAMC,YAAY,GAChBF,MAAM,CAACR,IAAI,KAAK,MAAM,IACtBQ,MAAM,CAACR,IAAI,KAAK,MAAM,IACtBQ,MAAM,CAACR,IAAI,KAAK,OAAO,IACvBQ,MAAM,CAACR,IAAI,KAAK,MAAM;AAExB,EAAA,MAAMW,mBAAmB,GAAGF,KAAK,CAACT,IAAI,KAAK,eAAe;AAC1D,EAAA,MAAMY,oBAAoB,GAAGD,mBAAmB,IAAI,CAACD,YAAY;;AAEjE;AACA;AACA,EAAA,IAAIE,oBAAoB,EAAE;IACxBC,OAAO,CAACC,IAAI,CACT,CAAA,SAAA,EAAWL,KAAK,CAACZ,KAAM,yCAC1B,CAAC;AACD,IAAA;AACF;AAEAW,EAAAA,MAAM,CAACN,QAAQ,CAACa,IAAI,CAACN,KAAK,CAAC;AAC7B,CAAC;AAED,MAAMO,sBAAsB,GAAGA,CAACC,cAAc,EAAER,KAAK,KAAK;AACxD,EAAA,IAAIQ,cAAc,CAACjB,IAAI,KAAK,MAAM,EAAE;IAClCiB,cAAc,CAACC,QAAQ,GAAGT,KAAK;AACjC,GAAC,MAAM;AACLF,IAAAA,WAAW,CAACU,cAAc,EAAER,KAAK,CAAC;AACpC;AACF,CAAC;AAED,MAAMU,YAAY,GAAGA,CAACF,cAAc,EAAER,KAAK,EAAEW,WAAW,KAAK;AAAA,EAAA,IAAAC,qBAAA;AAC3D,EAAA,MAAMC,KAAK,GAAA,CAAAD,qBAAA,GAAGJ,cAAc,CAACf,QAAQ,MAAAmB,IAAAA,IAAAA,qBAAA,uBAAvBA,qBAAA,CAAyBE,OAAO,CAACH,WAAW,CAAC;EAE3D,IAAIE,KAAK,KAAKxB,SAAS,EAAE;AAEzB,EAAA,IAAIwB,KAAK,KAAK,EAAE,IAAIb,KAAK,EAAEQ,cAAc,CAACf,QAAQ,CAACsB,MAAM,CAACF,KAAK,EAAE,CAAC,EAAEb,KAAK,CAAC;AAC5E,CAAC;AAED,MAAMgB,WAAW,GAAGA,CAACR,cAAc,EAAER,KAAK,KAAK;AAAA,EAAA,IAAAiB,sBAAA;AAC7C,EAAA,MAAMJ,KAAK,GAAA,CAAAI,sBAAA,GAAGT,cAAc,CAACf,QAAQ,MAAAwB,IAAAA,IAAAA,sBAAA,uBAAvBA,sBAAA,CAAyBH,OAAO,CAACd,KAAK,CAAC;EAErD,IAAIa,KAAK,KAAKxB,SAAS,EAAE;AAEzB,EAAA,IAAIwB,KAAK,KAAK,EAAE,EAAEL,cAAc,CAACf,QAAQ,CAACsB,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,MAAMK,wBAAwB,GAAGA,CAACV,cAAc,EAAER,KAAK,KAAK;AAAA,EAAA,IAAAmB,sBAAA;AAC1D,EAAA,MAAMN,KAAK,GAAA,CAAAM,sBAAA,GAAGX,cAAc,CAACf,QAAQ,MAAA0B,IAAAA,IAAAA,sBAAA,uBAAvBA,sBAAA,CAAyBL,OAAO,CAACd,KAAK,CAAC;EAErD,IAAIa,KAAK,KAAKxB,SAAS,EAAE;AAEzB,EAAA,IAAIwB,KAAK,KAAK,EAAE,EAAEL,cAAc,CAACf,QAAQ,CAACsB,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,MAAMO,gBAAgB,GAAGA,CAACC,YAAY,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAC3DF,YAAY,CAACjC,KAAK,GAAGmC,OAAO;AAC9B,CAAC;AAED,MAAMC,YAAY,GAAGA,CAACC,QAAQ,EAAEC,aAAa,EAAEnC,IAAI,EAAEoC,QAAQ,EAAEC,QAAQ,KAAK;EAC1E,MAAM;IAAEpC,KAAK;IAAE,GAAGE;AAAM,GAAC,GAAGkC,QAAQ;EACpCH,QAAQ,CAAC/B,KAAK,GAAGA,KAAK;EACtB+B,QAAQ,CAACjC,KAAK,GAAGA,KAAK;AACxB,CAAC;AAEKqC,MAAAA,cAAc,GAAGC,KAAA,IAAA;EAAA,IAAC;IAAEC,QAAQ,GAAGA,MAAM;AAAG,GAAC,GAAAD,KAAA;AAAA,EAAA,OAC7CE,UAAU,CAAC;IACTlC,WAAW;IACXS,sBAAsB;IACtBa,gBAAgB;IAChBI,YAAY;IACZlC,cAAc;IACdM,kBAAkB;IAClBc,YAAY;IACZM,WAAW;IACXE,wBAAwB;AACxBe,IAAAA,gBAAgB,EAAEF;AACpB,GAAC,CAAC;AAAA;;;;;;AC9EE,MAAA;AAAEG,EAAAA;AAAQ,CAAC,GAAGC;AAEpB,MAAMC,SAAS,GAAG,IAAIC,SAAS,EAAE;;AAEjC;AACA,IAAIC,QAAQ;;AAEZ;AACA;AACA,MAAMC,MAAM,GAAG,EAAE;AAEXC,MAAAA,GAAG,GAAIC,YAAY,IAAK;EAC5B,MAAMV,QAAQ,GAAGA,MAAM;AAAA,IAAA,IAAAW,cAAA;AACrB,IAAA,MAAMC,SAAS,GAAG,CAAA,CAAAD,cAAA,GAAAH,MAAM,CAACK,MAAM,MAAAF,IAAAA,IAAAA,cAAA,uBAAbA,cAAA,CAAeG,KAAK,EAAE,KAAI,EAAE;IAC9C,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,SAAS,CAACI,MAAM,EAAED,CAAC,IAAI,CAAC,EAAEH,SAAS,CAACG,CAAC,CAAC,EAAE;GAC7D;AAED,EAAA,MAAME,SAAS,GAAG;AAAEzD,IAAAA,IAAI,EAAE,MAAM;AAAEkB,IAAAA,QAAQ,EAAE;GAAM;AAClD6B,EAAAA,QAAQ,GAAGA,QAAQ,IAAIT,cAAc,CAAC;AAAEE,IAAAA;AAAS,GAAC,CAAC;AACnD,EAAA,MAAMkB,SAAS,GAAGX,QAAQ,CAACY,eAAe,CAACF,SAAS,CAAC;AAErD,EAAA,MAAMG,eAAe,GAAGA,CAACC,GAAG,EAAEC,QAAQ,KAAK;IACzCf,QAAQ,CAACa,eAAe,CAACC,GAAG,EAAEH,SAAS,EAAE,IAAI,EAAEI,QAAQ,CAAC;GACzD;AAED,EAAA,IAAIZ,YAAY,EAAEU,eAAe,CAACV,YAAY,CAAC;AAE/C,EAAA,MAAMa,MAAM,GAAG,gBAAOC,QAAQ,EAAY;AAAA,IAAA,IAApBA,QAAQ,KAAA,MAAA,EAAA;AAARA,MAAAA,QAAQ,GAAG,IAAI;AAAA;IACnC,MAAM7D,KAAK,GAAGsD,SAAS,CAACvC,QAAQ,CAACf,KAAK,IAAI,EAAE;IAC5C,MAAM;MACJ8D,UAAU;MACVC,QAAQ;MACRC,UAAU;MACVC,QAAQ;MACRC,KAAK;MACLC,MAAM;MACNC,OAAO;MACPC,QAAQ;AACRC,MAAAA,OAAO,GAAG,WAAW;AACrBC,MAAAA,QAAQ,GAAG,WAAW;AACtBC,MAAAA,YAAY,GAAG,IAAIC,IAAI,EAAE;MACzBC,gBAAgB;MAChBC,aAAa;MACbC,YAAY;AACZC,MAAAA;AACF,KAAC,GAAG7E,KAAK;AAET,IAAA,MAAM8E,GAAG,GAAG,IAAIC,WAAW,CAAC;MAC1BlB,QAAQ;MACRC,UAAU;AACVkB,MAAAA,IAAI,EAAEjB,QAAQ;AACdkB,MAAAA,YAAY,EAAE,IAAI;AAClBC,MAAAA,aAAa,EAAE,KAAK;MACpBP,aAAa;MACbC,YAAY;MACZC,WAAW;MACXb,UAAU;MACVmB,IAAI,EAAEhG,QAAQ,CAAC;AACbiG,QAAAA,KAAK,EAAElB,KAAK;AACZmB,QAAAA,MAAM,EAAElB,MAAM;AACdmB,QAAAA,OAAO,EAAElB,OAAO;AAChBmB,QAAAA,QAAQ,EAAElB,QAAQ;AAClBmB,QAAAA,OAAO,EAAElB,OAAO;AAChBmB,QAAAA,QAAQ,EAAElB,QAAQ;AAClBmB,QAAAA,YAAY,EAAElB,YAAY;AAC1BmB,QAAAA,gBAAgB,EAAEjB;OACnB;AACH,KAAC,CAAC;AAEF,IAAA,IAAIT,QAAQ,EAAE;MACZa,GAAG,CAACc,KAAK,CAACC,IAAI,CAACC,QAAQ,GAAGC,UAAU,CAAC9B,QAAQ,CAAC;AAChD;IAEA,MAAM+B,MAAM,GAAG,MAAMC,cAAc,CAAC3C,SAAS,CAACvC,QAAQ,EAAE2B,SAAS,CAAC;AAClE,IAAA,MAAMwD,UAAU,GAAGC,SAAS,CAACrB,GAAG,EAAEkB,MAAM,CAAC;IACzC,OAAO;MAAEA,MAAM;AAAEE,MAAAA;KAAY;GAC9B;AAED,EAAA,MAAME,YAAY,GAAG,UAACC,MAAM,EAAU;AAAA,IAAA,IAAhBA,MAAM,KAAA,MAAA,EAAA;MAANA,MAAM,GAAG,EAAE;AAAA;AAC/B,IAAA,IAAI/C,SAAS,CAACvC,QAAQ,CAACf,KAAK,CAACsG,QAAQ,EAAE;MACrChD,SAAS,CAACvC,QAAQ,CAACf,KAAK,CAACsG,QAAQ,CAACD,MAAM,CAAC;AAC3C;GACD;AAED,EAAA,MAAME,MAAM,GAAG,YAAY;IACzB,MAAMC,MAAM,GAAG,EAAE;IACjB,MAAM;AAAER,MAAAA,MAAM,EAAES,wBAAwB;AAAEP,MAAAA,UAAU,EAAEnE;AAAS,KAAC,GAC9D,MAAM6B,MAAM,EAAE;AAEhB,IAAA,OAAO,IAAI8C,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;AACtC7E,MAAAA,QAAQ,CAAC8E,EAAE,CAAC,MAAM,EAAGC,KAAK,IAAK;AAC7BN,QAAAA,MAAM,CAAC5F,IAAI,CACTkG,KAAK,YAAYC,UAAU,GAAGD,KAAK,GAAG,IAAIC,UAAU,CAACD,KAAK,CAC5D,CAAC;AACH,OAAC,CAAC;AAEF/E,MAAAA,QAAQ,CAAC8E,EAAE,CAAC,KAAK,EAAE,MAAM;QACvB,IAAI;AACF,UAAA,MAAMG,IAAI,GAAG,IAAIC,IAAI,CAACT,MAAM,EAAE;AAAE3G,YAAAA,IAAI,EAAE;AAAkB,WAAC,CAAC;AAC1DuG,UAAAA,YAAY,CAAC;YAAEY,IAAI;AAAEP,YAAAA;AAAyB,WAAC,CAAC;UAChDE,OAAO,CAACK,IAAI,CAAC;SACd,CAAC,OAAOE,KAAK,EAAE;UACdN,MAAM,CAACM,KAAK,CAAC;AACf;AACF,OAAC,CAAC;AACJ,KAAC,CAAC;GACH;;AAED;AACA,EAAA,MAAMC,QAAQ,GAAG,YAAY;IAC3B,MAAM;AAAEnB,MAAAA,MAAM,EAAES,wBAAwB;AAAEP,MAAAA;AAAW,KAAC,GAAG,MAAMtC,MAAM,EAAE;AACvEwC,IAAAA,YAAY,CAAC;AAAEK,MAAAA;AAAyB,KAAC,CAAC;AAE1C,IAAA,OAAOP,UAAU;GAClB;;AAED;AACF;AACA;AACA;AACA;AACA;AACE,EAAA,MAAMkB,QAAQ,GAAG,YAAY;AAC3B,IAAA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1C7G,MAAAA,OAAO,CAACC,IAAI,CACV,oEACF,CAAC;AACH;IAEA,IAAI6G,MAAM,GAAG,EAAE;IACf,MAAM;AAAEtB,MAAAA,UAAU,EAAEnE;AAAS,KAAC,GAAG,MAAM6B,MAAM,CAAC,KAAK,CAAC,CAAC;;AAErD,IAAA,OAAO,IAAI8C,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,IAAI;AACF7E,QAAAA,QAAQ,CAAC8E,EAAE,CAAC,MAAM,EAAGY,MAAM,IAAK;AAC9BD,UAAAA,MAAM,IAAIC,MAAM;AAClB,SAAC,CAAC;AAEF1F,QAAAA,QAAQ,CAAC8E,EAAE,CAAC,KAAK,EAAE,MAAM;AACvBT,UAAAA,YAAY,EAAE;UACdO,OAAO,CAACa,MAAM,CAAC;AACjB,SAAC,CAAC;OACH,CAAC,OAAON,KAAK,EAAE;QACdN,MAAM,CAACM,KAAK,CAAC;AACf;AACF,KAAC,CAAC;GACH;AAED,EAAA,MAAML,EAAE,GAAGA,CAACa,KAAK,EAAEC,QAAQ,KAAK;IAC9B,IAAI,CAAC9E,MAAM,CAAC6E,KAAK,CAAC,EAAE7E,MAAM,CAAC6E,KAAK,CAAC,GAAG,EAAE;AACtC7E,IAAAA,MAAM,CAAC6E,KAAK,CAAC,CAAC9G,IAAI,CAAC+G,QAAQ,CAAC;GAC7B;AAED,EAAA,MAAMC,cAAc,GAAGA,CAACF,KAAK,EAAEC,QAAQ,KAAK;AAC1C,IAAA,IAAI,CAAC9E,MAAM,CAAC6E,KAAK,CAAC,EAAE;IACpB,MAAMG,GAAG,GAAGhF,MAAM,CAAC6E,KAAK,CAAC,CAACtG,OAAO,CAACuG,QAAQ,CAAC;AAC3C,IAAA,IAAIE,GAAG,GAAG,EAAE,EAAEhF,MAAM,CAAC6E,KAAK,CAAC,CAACrG,MAAM,CAACwG,GAAG,EAAE,CAAC,CAAC;GAC3C;EAED,OAAO;IACLhB,EAAE;IACFvD,SAAS;IACTiD,MAAM;IACNY,QAAQ;IACRC,QAAQ;IACRQ,cAAc;AACdnE,IAAAA;GACD;AACH;AAEMqE,MAAAA,IAAI,GAAGpF;AAEb,MAAMqF,UAAU,GAAG;EACjBC,MAAM,EAAGC,CAAC,IAAKA;AACjB;;ACnLA;AACA;AACA;AACA;AACA;AACA;MACaC,MAAM,GAAG,UAAAC,KAAA,EAAuB;EAAA,IAAtB;AAAEpH,IAAAA;AAAS,GAAC,GAAAoH,KAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,KAAA;AACtC,EAAA,MAAMC,WAAW,GAAGC,MAAM,CAAC,IAAI,CAAC;AAEhC,EAAA,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAC;AACjCC,IAAAA,GAAG,EAAE,IAAI;AACTzB,IAAAA,IAAI,EAAE,IAAI;AACVE,IAAAA,KAAK,EAAE,IAAI;IACXwB,OAAO,EAAE,CAAC,CAAC3H;AACb,GAAC,CAAC;;AAEF;AACA4H,EAAAA,SAAS,CAAC,MAAM;IACd,MAAMC,WAAW,GAAGC,KAAK,CAAC;AAAEC,MAAAA,SAAS,EAAE,IAAI;AAAEC,MAAAA,WAAW,EAAE;AAAE,KAAC,CAAC;IAE9D,MAAMC,mBAAmB,GAAGA,MAAM;MAChCT,QAAQ,CAAEU,IAAI,KAAM;AAAE,QAAA,GAAGA,IAAI;AAAEP,QAAAA,OAAO,EAAE;AAAK,OAAC,CAAC,CAAC;MAEhDE,WAAW,CAACvH,MAAM,CAAC,CAAC,EAAEuH,WAAW,CAACvF,MAAM,EAAE,MACxCiF,KAAK,CAACpB,KAAK,GAAGR,OAAO,CAACC,OAAO,EAAE,GAAGyB,WAAW,CAACc,OAAO,CAAC3C,MAAM,EAC9D,CAAC;KACF;IAED,MAAM4C,cAAc,GAAIjC,KAAK,IAAK;AAChCxG,MAAAA,OAAO,CAACwG,KAAK,CAACA,KAAK,CAAC;MACpBqB,QAAQ,CAAEU,IAAI,KAAM;AAAE,QAAA,GAAGA,IAAI;AAAEP,QAAAA,OAAO,EAAE,KAAK;AAAExB,QAAAA;AAAM,OAAC,CAAC,CAAC;KACzD;IAED,MAAMkC,kBAAkB,GAAIpC,IAAI,IAAK;AACnCuB,MAAAA,QAAQ,CAAC;QACPvB,IAAI;AACJE,QAAAA,KAAK,EAAE,IAAI;AACXwB,QAAAA,OAAO,EAAE,KAAK;AACdD,QAAAA,GAAG,EAAEY,GAAG,CAACC,eAAe,CAACtC,IAAI;AAC/B,OAAC,CAAC;KACH;AAEDoB,IAAAA,WAAW,CAACc,OAAO,GAAGpG,GAAG,EAAE;IAC3BsF,WAAW,CAACc,OAAO,CAACrC,EAAE,CAAC,QAAQ,EAAEmC,mBAAmB,CAAC;AACrD,IAAA,IAAIjI,QAAQ,EAAE;AACZqH,MAAAA,WAAW,CAACc,OAAO,CAACzF,eAAe,CAAC1C,QAAQ,CAAC;AAC/C;AAEA6H,IAAAA,WAAW,CAAC/B,EAAE,CAAC,OAAO,EAAEsC,cAAc,CAAC;AACvCP,IAAAA,WAAW,CAAC/B,EAAE,CAAC,SAAS,EAAEuC,kBAAkB,CAAC;AAE7C,IAAA,OAAO,MAAM;MACXR,WAAW,CAACW,GAAG,EAAE;MACjBnB,WAAW,CAACc,OAAO,CAACtB,cAAc,CAAC,QAAQ,EAAEoB,mBAAmB,CAAC;KAClE;GACF,EAAE,EAAE,CAAC;;AAEN;AACAL,EAAAA,SAAS,CAAC,MAAM;AACd,IAAA,OAAO,MAAM;MACX,IAAIL,KAAK,CAACG,GAAG,EAAE;AACbY,QAAAA,GAAG,CAACG,eAAe,CAAClB,KAAK,CAACG,GAAG,CAAC;AAChC;KACD;AACH,GAAC,EAAE,CAACH,KAAK,CAACG,GAAG,CAAC,CAAC;AAEf,EAAA,MAAMgB,MAAM,GAAGC,WAAW,CAAEC,MAAM,IAAK;AACrCvB,IAAAA,WAAW,CAACc,OAAO,CAACzF,eAAe,CAACkG,MAAM,CAAC;GAC5C,EAAE,EAAE,CAAC;AAEN,EAAA,OAAO,CAACrB,KAAK,EAAEmB,MAAM,CAAC;AACxB;;ACxEaG,MAAAA,SAAS,GAAGnK,IAAA,IAQnB;EAAA,IARoB;IACxByE,KAAK;IACLpE,KAAK;IACL+J,SAAS;IACT9J,QAAQ;IACR+J,QAAQ;AACRC,IAAAA,WAAW,GAAG,IAAI;IAClB,GAAG/J;AACL,GAAC,GAAAP,IAAA;EACC,MAAM,CAACsC,QAAQ,EAAEiI,cAAc,CAAC,GAAG9B,MAAM,EAAE;EAE3CS,SAAS,CAAC,MAAMqB,cAAc,CAACjK,QAAQ,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;AAErD,EAAA,MAAMkK,GAAG,GAAGlI,QAAQ,CAAC0G,GAAG,GACnB,GAAE1G,QAAQ,CAAC0G,GAAI,CAAA,SAAA,EAAWsB,WAAW,GAAG,CAAC,GAAG,CAAE,CAAA,CAAC,GAChD,IAAI;AAER,EAAA,oBACEG,GAAA,CAAA,QAAA,EAAA;AACED,IAAAA,GAAG,EAAEA,GAAI;AACT/F,IAAAA,KAAK,EAAEA,KAAM;AACbiG,IAAAA,GAAG,EAAEL,QAAS;AACdhK,IAAAA,KAAK,EAAEA,KAAM;AACb+J,IAAAA,SAAS,EAAEA,SAAU;IAAA,GACjB7J;AAAK,GACV,CAAC;AAEN;;AC3BaoK,MAAAA,YAAY,GAAG3K,IAAA,IAAiC;EAAA,IAAhC;AAAEsB,IAAAA,QAAQ,EAAE2C,GAAG;AAAE3D,IAAAA;AAAS,GAAC,GAAAN,IAAA;EACtD,MAAM,CAACsC,QAAQ,EAAEiI,cAAc,CAAC,GAAG9B,MAAM,EAAE;EAE3CS,SAAS,CAAC,MAAMqB,cAAc,CAACtG,GAAG,CAAC,EAAE,CAACA,GAAG,CAAC,CAAC;EAE3C,IAAI,CAACA,GAAG,EAAE;AACRhD,IAAAA,OAAO,CAACC,IAAI,CAAC,kDAAkD,CAAC;AAChE,IAAA,OAAO,IAAI;AACb;EAEA,OAAOZ,QAAQ,CAACgC,QAAQ,CAAC;AAC3B;;ACXA,MAAMsI,mBAAmB,GAAGA,CAAA5K,IAAA,EAS1B0K,GAAG,KACA;EAAA,IATH;AACEG,IAAAA,QAAQ,GAAG,cAAc;AACzBvJ,IAAAA,QAAQ,EAAE2C,GAAG;IACb3D,QAAQ;IACRwK,OAAO;IACPC,IAAI;IACJ,GAAGC;AACL,GAAC,GAAAhL,IAAA;EAGD,MAAM,CAACsC,QAAQ,EAAEiI,cAAc,CAAC,GAAG9B,MAAM,EAAE;EAE3CS,SAAS,CAAC,MAAMqB,cAAc,CAACtG,GAAG,CAAC,EAAE,CAACA,GAAG,CAAC,CAAC;EAE3C,IAAI,CAACA,GAAG,EAAE;AACRhD,IAAAA,OAAO,CAACC,IAAI,CAAC,qDAAqD,CAAC;AACnE,IAAA,OAAO,IAAI;AACb;EAEA,MAAM+J,gBAAgB,GAAGA,MAAM;AAC7B,IAAA,IAAI3I,QAAQ,IAAI4I,MAAM,CAACC,SAAS,CAACC,UAAU,EAAE;AAC3C;MACAF,MAAM,CAACC,SAAS,CAACC,UAAU,CAAC9I,QAAQ,CAACiF,IAAI,EAAEsD,QAAQ,CAAC;AACtD;GACD;EAED,MAAMQ,WAAW,GAAIpD,KAAK,IAAK;AAC7BgD,IAAAA,gBAAgB,EAAE;IAClB,IAAI,OAAOH,OAAO,KAAK,UAAU,EAAEA,OAAO,CAAC7C,KAAK,EAAE3F,QAAQ,CAAC;GAC5D;AAED,EAAA,oBACEmI,GAAA,CAAA,GAAA,EAAA;IACEM,IAAI,EAAEzI,QAAQ,CAAC0G,GAAI;AACnBsC,IAAAA,QAAQ,EAAET,QAAS;AACnBC,IAAAA,OAAO,EAAEO,WAAY;AACrBX,IAAAA,GAAG,EAAEA,GAAI;AAAA,IAAA,GACLM,IAAI;IAAA1K,QAAA,EAEP,OAAOA,QAAQ,KAAK,UAAU,GAAGA,QAAQ,CAACgC,QAAQ,CAAC,GAAGhC;AAAQ,GAC9D,CAAC;AAER,CAAC;MAEYiL,eAAe,gBAAGC,UAAU,CAACZ,mBAAmB;;ACzC7D,MAAMa,qBAAqB,GAAIC,IAAI,IAAK;AACtC,EAAA,MAAM,IAAIC,KAAK,CACZ,CAAED,EAAAA,IAAK,iJACV,CAAC;AACH,CAAC;AAEYE,MAAAA,cAAc,GAAGA,MAAM;EAClCH,qBAAqB,CAAC,gBAAgB,CAAC;AACzC;AAEaI,MAAAA,cAAc,GAAGA,MAAM;EAClCJ,qBAAqB,CAAC,gBAAgB,CAAC;AACzC;AAEaK,MAAAA,cAAc,GAAGA,MAAM;EAClCL,qBAAqB,CAAC,gBAAgB,CAAC;AACzC;AAEaM,MAAAA,YAAY,GAAGA,MAAM;EAChCN,qBAAqB,CAAC,cAAc,CAAC;AACvC;AAEatH,MAAAA,MAAM,GAAGA,MAAM;EAC1BsH,qBAAqB,CAAC,QAAQ,CAAC;AACjC;;AAcA;AACA,YAAe;EACbpI,GAAG;EACHoF,MAAM;EACNJ,IAAI;EACJtF,OAAO;EACPuF,UAAU;EACV6B,SAAS;EACTQ,YAAY;EACZY,eAAe;EACfK,cAAc;EACdE,cAAc;EACdC,YAAY;EACZ5H,MAAM;EACN,GAAG6H;AACL,CAAC;;;;"} \ No newline at end of file diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.d.cts b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..1aa2dc8042e236867156186033b1931bf366c2d2 --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.d.cts @@ -0,0 +1,793 @@ +/* eslint-disable max-classes-per-file */ + +import * as React from 'react'; +import { + Style, + PageSize, + FontStore, + PDFVersion, + Orientation, + SourceObject, + SrcSet, + Sizes, + HyphenationCallback, + SVGPresentationAttributes, + Bookmark, + PageLayout, + PageMode, + HitSlop, +} from '@react-pdf/types'; + +declare class ReactPDF { + static default: typeof ReactPDF; +} + +export = ReactPDF; + +declare namespace ReactPDF { + interface Styles { + [key: string]: Style; + } + interface OnRenderProps { + blob?: Blob; + } + + interface Permissions { + printing?: 'lowResolution' | 'highResolution'; + modifying?: boolean; + copying?: boolean; + annotating?: boolean; + fillingForms?: boolean; + contentAccessibility?: boolean; + documentAssembly?: boolean; + } + + interface DocumentProps { + style?: Style | Style[]; + title?: string; + author?: string; + subject?: string; + creator?: string; + keywords?: string; + producer?: string; + language?: string; + creationDate?: Date; + modificationDate?: Date; + pdfVersion?: PDFVersion; + pageMode?: PageMode; + pageLayout?: PageLayout; + ownerPassword?: string; + userPassword?: string; + permissions?: Permissions; + onRender?: (props: OnRenderProps) => any; + } + + /** + * This component represent the PDF document itself. It must be the root + * of your tree element structure, and under no circumstances should it be + * used as children of another react-pdf component. In addition, it should + * only have childs of type . + */ + export class Document extends React.Component< + React.PropsWithChildren + > {} + + interface NodeProps { + id?: string; + style?: Style | Style[]; + /** + * Render component in all wrapped pages. + * @see https://react-pdf.org/advanced#fixed-components + */ + fixed?: boolean; + /** + * Force the wrapping algorithm to start a new page when rendering the + * element. + * @see https://react-pdf.org/advanced#page-breaks + */ + break?: boolean; + /** + * Hint that no page wrapping should occur between all sibling elements following the element within n points + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + minPresenceAhead?: number; + } + + interface PageProps extends NodeProps { + /** + * Enable page wrapping for this page. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + size?: PageSize; + orientation?: Orientation; + dpi?: number; + bookmark?: Bookmark; + } + + /** + * Represents single page inside the PDF document, or a subset of them if + * using the wrapping feature. A can contain as many pages as + * you want, but ensure not rendering a page inside any component besides + * Document. + */ + export class Page extends React.Component< + React.PropsWithChildren + > {} + + interface ViewProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + subPageNumber: number; + }) => React.ReactNode; + } + + /** + * The most fundamental component for building a UI and is designed to be + * nested inside other views and can have 0 to many children. + */ + export class View extends React.Component< + React.PropsWithChildren + > {} + + interface BaseImageProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * Works like the HTML img sizes attribute. + * @example 300 + * @example "300" + */ + sizes?: Sizes; + } + + interface ImageWithSrcProp extends BaseImageProps { + src: SourceObject; + } + + interface ImageWithSourceProp extends BaseImageProps { + source: SourceObject; + } + + type ImageProps = ImageWithSrcProp | ImageWithSourceProp; + + /** + * A React component for displaying network or local (Node only) JPG or + * PNG images, as well as base64 encoded image strings. + */ + export class Image extends React.Component {} + + interface BaseImageBackgroundProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * @example 300 + */ + sizes?: Sizes; + /** + * Style applied to the background image. + */ + imageStyle?: Style; + } + + interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps { + src: SourceObject; + } + + interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps { + source: SourceObject; + } + + type ImageBackgroundProps = + | ImageBackgroundWithSrcProp + | ImageBackgroundWithSourceProp; + + /** + * A React component for displaying an image behind child content. + * Compatible with React Native's ImageBackground component. + * @see https://reactnative.dev/docs/imagebackground + */ + export class ImageBackground extends React.Component< + React.PropsWithChildren + > {} + + interface TextProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + totalPages: number; + subPageNumber: number; + subPageTotalPages: number; + }) => React.ReactNode; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + /** + * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + orphans?: number; + /** + * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container.. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + widows?: number; + } + + interface SVGTextProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x: string | number; + y: string | number; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + } + + /** + * A React component for displaying text. Text supports nesting of other + * Text or Link components to create inline styling. + */ + export class Text extends React.Component< + React.PropsWithChildren | SVGTextProps + > {} + + interface LinkProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + href?: string; + src?: string; + /** + * Extends the clickable area of the link beyond its visible bounds. + * Accepts a number (applied to all sides) or an object with top, bottom, left, right. + * @see https://reactnative.dev/docs/view#hitslop + */ + hitSlop?: HitSlop; + } + + /** + * A React component for displaying a hyperlink. Link’s can be nested + * inside a Text component, or being inside any other valid primitive. + */ + export class Link extends React.Component< + React.PropsWithChildren + > {} + + interface FormCommonProps extends NodeProps { + name?: string; + required?: boolean; + noExport?: boolean; + readOnly?: boolean; + value?: number | string; + defaultValue?: number | string; + } + + interface FieldSetProps extends NodeProps { + name: string; + } + + export class FieldSet extends React.Component< + React.PropsWithChildren + > {} + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputFormatting { + type: + | 'date' + | 'time' + | 'percent' + | 'number' + | 'zip' + | 'zipPlus4' + | 'phone' + | 'ssn'; + param?: string; + nDec?: number; + sepComma?: boolean; + negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed'; + currency?: string; + currencyPrepend?: boolean; + } + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputProps extends FormCommonProps { + align?: 'left' | 'center' | 'right'; + multiline?: boolean; + /** + * The text will be masked (e.g. with asterisks). + */ + password?: boolean; + /** + * If set, text entered in the field is not spell-checked + */ + noSpell?: boolean; + format?: TextInputFormatting; + /** + * Sets the fontSize (default or 0 means auto sizing) + */ + fontSize?: number; + /** + * Sets the maximum length (characters) of the text in the field + */ + maxLength?: number; + } + + export class TextInput extends React.Component {} + + interface CheckboxProps extends FormCommonProps { + backgroundColor?: string; + borderColor?: string; + checked?: boolean; + onState?: string; + offState?: string; + xMark?: boolean; + } + + export class Checkbox extends React.Component {} + + interface SelectAndListPropsBase extends FormCommonProps { + sort?: boolean; + edit?: boolean; + multiSelect?: boolean; + noSpell?: boolean; + select?: string[]; + } + + type SelectAndListPropsWithEdit = SelectAndListPropsBase & { + edit: true | false; + noSpell: boolean; + }; + + type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & { + edit: boolean; + noSpell: true | false; + }; + + type SelectAndListProps = + | SelectAndListPropsWithEdit + | SelectAndListPropsWithNoSpell; + + export class Select extends React.Component {} + + export class List extends React.Component {} + + interface NoteProps extends NodeProps { + children: string; + } + + export class Note extends React.Component {} + + interface CanvasProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + paint: ( + painter: any, + availableWidth: number, + availableHeight: number, + ) => null; + } + + export class Canvas extends React.Component {} + + interface SVGProps extends NodeProps, SVGPresentationAttributes { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + width?: string | number; + height?: string | number; + viewBox?: string; + preserveAspectRatio?: string; + } + + /** + * The element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents. + */ + export class Svg extends React.Component> {} + + interface LineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x1: string | number; + x2: string | number; + y1: string | number; + y2: string | number; + } + + /** + * The element is used to create a line. + */ + export class Line extends React.Component< + React.PropsWithChildren + > {} + + interface PolylineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create any shape that consists of only straight lines (that is connected at several points). + */ + export class Polyline extends React.Component< + React.PropsWithChildren + > {} + + interface PolygonProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create a graphic that contains at least three sides. + * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up). + */ + export class Polygon extends React.Component< + React.PropsWithChildren + > {} + + interface PathProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + d: string; + } + + /** + * The element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more. + */ + export class Path extends React.Component< + React.PropsWithChildren + > {} + + interface RectProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x?: string | number; + y?: string | number; + width: string | number; + height: string | number; + rx?: string | number; + ry?: string | number; + } + + /** + * The element is used to create a rectangle and variations of a rectangle shape. + */ + export class Rect extends React.Component< + React.PropsWithChildren + > {} + + interface CircleProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + r: string | number; + } + + /** + * The element is used to create a circle. + */ + export class Circle extends React.Component< + React.PropsWithChildren + > {} + + interface EllipseProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + rx: string | number; + ry: string | number; + } + + /** + * The element is used to create an ellipse. + * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius. + */ + export class Ellipse extends React.Component< + React.PropsWithChildren + > {} + + interface TspanProps extends SVGPresentationAttributes { + x?: string | number; + y?: string | number; + } + + /** + * The element defines a subtext within a element or another element. + * It allows for adjustment of the style and/or position of that subtext as needed. + */ + export class Tspan extends React.Component< + React.PropsWithChildren + > {} + + interface GProps extends SVGPresentationAttributes { + style?: Style; + } + + /** + * The SVG element is a container used to group other SVG elements. + * Transformations applied to the element are performed on its child elements, and its attributes are inherited by its children. + */ + export class G extends React.Component> {} + + interface StopProps { + offset: string | number; + stopColor: string; + stopOpacity?: string | number; + } + + /** + * The SVG element defines a color and its position to use on a gradient. This element is always a child of a or element + */ + export class Stop extends React.Component< + React.PropsWithChildren + > {} + + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface DefsProps {} + + /** + * The element is used to store graphical objects that will be used at a later time. Objects created inside a element are not rendered directly. To display them you have to reference them + */ + export class Defs extends React.Component< + React.PropsWithChildren + > {} + + interface ClipPathProps { + id?: string; + } + + /** + * The SVG element defines a clipping path, to be used by the clipPath property. + * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn. + */ + export class ClipPath extends React.Component< + React.PropsWithChildren + > {} + + interface MarkerProps { + id: string; + viewBox?: string; + refX?: string | number; + refY?: string | number; + markerWidth?: string | number; + markerHeight?: string | number; + orient?: 'auto' | 'auto-start-reverse' | number; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; + } + + /** + * The SVG element defines a graphic used for drawing arrows or polymarkers on a given , , , or element. + * Markers can be attached to shapes using the markerStart, markerMid, and markerEnd properties. + */ + export class Marker extends React.Component< + React.PropsWithChildren + > {} + + interface LinearGradientProps { + id: string; + x1?: string | number; + x2?: string | number; + y1?: string | number; + y2?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define linear gradients that can be applied to fill or stroke of graphical elements. + */ + export class LinearGradient extends React.Component< + React.PropsWithChildren + > {} + + interface RadialGradientProps { + id: string; + cx?: string | number; + cy?: string | number; + r?: string | number; + fx?: string | number; + fy?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define radial gradients that can be applied to fill or stroke of graphical elements. + */ + export class RadialGradient extends React.Component< + React.PropsWithChildren + > {} + + interface BlobProviderParams { + blob: Blob | null; + url: string | null; + loading: boolean; + error: Error | null; + } + interface BlobProviderProps { + document: React.ReactElement; + children: (params: BlobProviderParams) => React.ReactNode; + } + + /** + * Easy and declarative way of getting document's blob data without + * showing it on screen. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class BlobProvider extends React.Component {} + + interface PDFViewerProps { + width?: number | string; + height?: number | string; + style?: Style | Style[]; + className?: string; + children?: React.ReactElement; + innerRef?: React.Ref; + showToolbar?: boolean; + } + + /** + * Iframe PDF viewer for client-side generated documents. + * @platform web + */ + export class PDFViewer extends React.Component {} + + interface PDFDownloadLinkProps + extends Omit< + React.AnchorHTMLAttributes, + 'href' | 'children' + > { + /** PDF filename. Alias for anchor tag `download` attribute. */ + fileName?: string; + document: React.ReactElement; + children?: React.ReactNode | React.FC; + onClick?: React.AnchorHTMLAttributes['onClick'] & + (( + event: React.MouseEvent, + instance: UsePDFInstance, + ) => void); + ref?: React.Ref | undefined; + } + + /** + * Anchor tag to enable generate and download PDF documents on the fly. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class PDFDownloadLink extends React.Component {} + + interface UsePDFInstance { + loading: boolean; + blob: Blob | null; + url: string | null; + error: string | null; + } + + /** + * React hook for creating and updating a PDF document instance + * @platform web + */ + export function usePDF(options?: { + document?: React.ReactElement; + }): [ + UsePDFInstance, + (newDocument: React.ReactElement) => void, + ]; + + export const Font: FontStore; + + export const StyleSheet: { + create: (styles: T) => T; + }; + + export const version: any; + + export const PDFRenderer: any; + + export const pdf: (initialValue?: React.ReactElement) => { + container: any; + isDirty: () => boolean; + toString: () => string; + toBlob: () => Promise; + toBuffer: () => Promise; + on: (event: 'change', callback: () => void) => void; + updateContainer: ( + document: React.ReactElement, + callback?: () => void, + ) => void; + removeListener: (event: 'change', callback: () => void) => void; + }; + + export const renderToStream: ( + document: React.ReactElement, + ) => Promise; + + /** + * @deprecated use the `renderToBuffer` method + */ + export const renderToString: ( + document: React.ReactElement, + ) => Promise; + + export const renderToFile: ( + document: React.ReactElement, + filePath: string, + callback?: (output: NodeJS.ReadableStream, _filePath: string) => any, + ) => Promise; + + const render: typeof renderToFile; + + /** + * Render document into a nodejs buffer + * @platform node + */ + export const renderToBuffer: ( + document: React.ReactElement, + ) => Promise; +} diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.d.ts b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1aa2dc8042e236867156186033b1931bf366c2d2 --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.d.ts @@ -0,0 +1,793 @@ +/* eslint-disable max-classes-per-file */ + +import * as React from 'react'; +import { + Style, + PageSize, + FontStore, + PDFVersion, + Orientation, + SourceObject, + SrcSet, + Sizes, + HyphenationCallback, + SVGPresentationAttributes, + Bookmark, + PageLayout, + PageMode, + HitSlop, +} from '@react-pdf/types'; + +declare class ReactPDF { + static default: typeof ReactPDF; +} + +export = ReactPDF; + +declare namespace ReactPDF { + interface Styles { + [key: string]: Style; + } + interface OnRenderProps { + blob?: Blob; + } + + interface Permissions { + printing?: 'lowResolution' | 'highResolution'; + modifying?: boolean; + copying?: boolean; + annotating?: boolean; + fillingForms?: boolean; + contentAccessibility?: boolean; + documentAssembly?: boolean; + } + + interface DocumentProps { + style?: Style | Style[]; + title?: string; + author?: string; + subject?: string; + creator?: string; + keywords?: string; + producer?: string; + language?: string; + creationDate?: Date; + modificationDate?: Date; + pdfVersion?: PDFVersion; + pageMode?: PageMode; + pageLayout?: PageLayout; + ownerPassword?: string; + userPassword?: string; + permissions?: Permissions; + onRender?: (props: OnRenderProps) => any; + } + + /** + * This component represent the PDF document itself. It must be the root + * of your tree element structure, and under no circumstances should it be + * used as children of another react-pdf component. In addition, it should + * only have childs of type . + */ + export class Document extends React.Component< + React.PropsWithChildren + > {} + + interface NodeProps { + id?: string; + style?: Style | Style[]; + /** + * Render component in all wrapped pages. + * @see https://react-pdf.org/advanced#fixed-components + */ + fixed?: boolean; + /** + * Force the wrapping algorithm to start a new page when rendering the + * element. + * @see https://react-pdf.org/advanced#page-breaks + */ + break?: boolean; + /** + * Hint that no page wrapping should occur between all sibling elements following the element within n points + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + minPresenceAhead?: number; + } + + interface PageProps extends NodeProps { + /** + * Enable page wrapping for this page. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + size?: PageSize; + orientation?: Orientation; + dpi?: number; + bookmark?: Bookmark; + } + + /** + * Represents single page inside the PDF document, or a subset of them if + * using the wrapping feature. A can contain as many pages as + * you want, but ensure not rendering a page inside any component besides + * Document. + */ + export class Page extends React.Component< + React.PropsWithChildren + > {} + + interface ViewProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + subPageNumber: number; + }) => React.ReactNode; + } + + /** + * The most fundamental component for building a UI and is designed to be + * nested inside other views and can have 0 to many children. + */ + export class View extends React.Component< + React.PropsWithChildren + > {} + + interface BaseImageProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * Works like the HTML img sizes attribute. + * @example 300 + * @example "300" + */ + sizes?: Sizes; + } + + interface ImageWithSrcProp extends BaseImageProps { + src: SourceObject; + } + + interface ImageWithSourceProp extends BaseImageProps { + source: SourceObject; + } + + type ImageProps = ImageWithSrcProp | ImageWithSourceProp; + + /** + * A React component for displaying network or local (Node only) JPG or + * PNG images, as well as base64 encoded image strings. + */ + export class Image extends React.Component {} + + interface BaseImageBackgroundProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * @example 300 + */ + sizes?: Sizes; + /** + * Style applied to the background image. + */ + imageStyle?: Style; + } + + interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps { + src: SourceObject; + } + + interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps { + source: SourceObject; + } + + type ImageBackgroundProps = + | ImageBackgroundWithSrcProp + | ImageBackgroundWithSourceProp; + + /** + * A React component for displaying an image behind child content. + * Compatible with React Native's ImageBackground component. + * @see https://reactnative.dev/docs/imagebackground + */ + export class ImageBackground extends React.Component< + React.PropsWithChildren + > {} + + interface TextProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + totalPages: number; + subPageNumber: number; + subPageTotalPages: number; + }) => React.ReactNode; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + /** + * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + orphans?: number; + /** + * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container.. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + widows?: number; + } + + interface SVGTextProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x: string | number; + y: string | number; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + } + + /** + * A React component for displaying text. Text supports nesting of other + * Text or Link components to create inline styling. + */ + export class Text extends React.Component< + React.PropsWithChildren | SVGTextProps + > {} + + interface LinkProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + href?: string; + src?: string; + /** + * Extends the clickable area of the link beyond its visible bounds. + * Accepts a number (applied to all sides) or an object with top, bottom, left, right. + * @see https://reactnative.dev/docs/view#hitslop + */ + hitSlop?: HitSlop; + } + + /** + * A React component for displaying a hyperlink. Link’s can be nested + * inside a Text component, or being inside any other valid primitive. + */ + export class Link extends React.Component< + React.PropsWithChildren + > {} + + interface FormCommonProps extends NodeProps { + name?: string; + required?: boolean; + noExport?: boolean; + readOnly?: boolean; + value?: number | string; + defaultValue?: number | string; + } + + interface FieldSetProps extends NodeProps { + name: string; + } + + export class FieldSet extends React.Component< + React.PropsWithChildren + > {} + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputFormatting { + type: + | 'date' + | 'time' + | 'percent' + | 'number' + | 'zip' + | 'zipPlus4' + | 'phone' + | 'ssn'; + param?: string; + nDec?: number; + sepComma?: boolean; + negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed'; + currency?: string; + currencyPrepend?: boolean; + } + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputProps extends FormCommonProps { + align?: 'left' | 'center' | 'right'; + multiline?: boolean; + /** + * The text will be masked (e.g. with asterisks). + */ + password?: boolean; + /** + * If set, text entered in the field is not spell-checked + */ + noSpell?: boolean; + format?: TextInputFormatting; + /** + * Sets the fontSize (default or 0 means auto sizing) + */ + fontSize?: number; + /** + * Sets the maximum length (characters) of the text in the field + */ + maxLength?: number; + } + + export class TextInput extends React.Component {} + + interface CheckboxProps extends FormCommonProps { + backgroundColor?: string; + borderColor?: string; + checked?: boolean; + onState?: string; + offState?: string; + xMark?: boolean; + } + + export class Checkbox extends React.Component {} + + interface SelectAndListPropsBase extends FormCommonProps { + sort?: boolean; + edit?: boolean; + multiSelect?: boolean; + noSpell?: boolean; + select?: string[]; + } + + type SelectAndListPropsWithEdit = SelectAndListPropsBase & { + edit: true | false; + noSpell: boolean; + }; + + type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & { + edit: boolean; + noSpell: true | false; + }; + + type SelectAndListProps = + | SelectAndListPropsWithEdit + | SelectAndListPropsWithNoSpell; + + export class Select extends React.Component {} + + export class List extends React.Component {} + + interface NoteProps extends NodeProps { + children: string; + } + + export class Note extends React.Component {} + + interface CanvasProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + paint: ( + painter: any, + availableWidth: number, + availableHeight: number, + ) => null; + } + + export class Canvas extends React.Component {} + + interface SVGProps extends NodeProps, SVGPresentationAttributes { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + width?: string | number; + height?: string | number; + viewBox?: string; + preserveAspectRatio?: string; + } + + /** + * The element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents. + */ + export class Svg extends React.Component> {} + + interface LineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x1: string | number; + x2: string | number; + y1: string | number; + y2: string | number; + } + + /** + * The element is used to create a line. + */ + export class Line extends React.Component< + React.PropsWithChildren + > {} + + interface PolylineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create any shape that consists of only straight lines (that is connected at several points). + */ + export class Polyline extends React.Component< + React.PropsWithChildren + > {} + + interface PolygonProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create a graphic that contains at least three sides. + * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up). + */ + export class Polygon extends React.Component< + React.PropsWithChildren + > {} + + interface PathProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + d: string; + } + + /** + * The element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more. + */ + export class Path extends React.Component< + React.PropsWithChildren + > {} + + interface RectProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x?: string | number; + y?: string | number; + width: string | number; + height: string | number; + rx?: string | number; + ry?: string | number; + } + + /** + * The element is used to create a rectangle and variations of a rectangle shape. + */ + export class Rect extends React.Component< + React.PropsWithChildren + > {} + + interface CircleProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + r: string | number; + } + + /** + * The element is used to create a circle. + */ + export class Circle extends React.Component< + React.PropsWithChildren + > {} + + interface EllipseProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + rx: string | number; + ry: string | number; + } + + /** + * The element is used to create an ellipse. + * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius. + */ + export class Ellipse extends React.Component< + React.PropsWithChildren + > {} + + interface TspanProps extends SVGPresentationAttributes { + x?: string | number; + y?: string | number; + } + + /** + * The element defines a subtext within a element or another element. + * It allows for adjustment of the style and/or position of that subtext as needed. + */ + export class Tspan extends React.Component< + React.PropsWithChildren + > {} + + interface GProps extends SVGPresentationAttributes { + style?: Style; + } + + /** + * The SVG element is a container used to group other SVG elements. + * Transformations applied to the element are performed on its child elements, and its attributes are inherited by its children. + */ + export class G extends React.Component> {} + + interface StopProps { + offset: string | number; + stopColor: string; + stopOpacity?: string | number; + } + + /** + * The SVG element defines a color and its position to use on a gradient. This element is always a child of a or element + */ + export class Stop extends React.Component< + React.PropsWithChildren + > {} + + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface DefsProps {} + + /** + * The element is used to store graphical objects that will be used at a later time. Objects created inside a element are not rendered directly. To display them you have to reference them + */ + export class Defs extends React.Component< + React.PropsWithChildren + > {} + + interface ClipPathProps { + id?: string; + } + + /** + * The SVG element defines a clipping path, to be used by the clipPath property. + * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn. + */ + export class ClipPath extends React.Component< + React.PropsWithChildren + > {} + + interface MarkerProps { + id: string; + viewBox?: string; + refX?: string | number; + refY?: string | number; + markerWidth?: string | number; + markerHeight?: string | number; + orient?: 'auto' | 'auto-start-reverse' | number; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; + } + + /** + * The SVG element defines a graphic used for drawing arrows or polymarkers on a given , , , or element. + * Markers can be attached to shapes using the markerStart, markerMid, and markerEnd properties. + */ + export class Marker extends React.Component< + React.PropsWithChildren + > {} + + interface LinearGradientProps { + id: string; + x1?: string | number; + x2?: string | number; + y1?: string | number; + y2?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define linear gradients that can be applied to fill or stroke of graphical elements. + */ + export class LinearGradient extends React.Component< + React.PropsWithChildren + > {} + + interface RadialGradientProps { + id: string; + cx?: string | number; + cy?: string | number; + r?: string | number; + fx?: string | number; + fy?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define radial gradients that can be applied to fill or stroke of graphical elements. + */ + export class RadialGradient extends React.Component< + React.PropsWithChildren + > {} + + interface BlobProviderParams { + blob: Blob | null; + url: string | null; + loading: boolean; + error: Error | null; + } + interface BlobProviderProps { + document: React.ReactElement; + children: (params: BlobProviderParams) => React.ReactNode; + } + + /** + * Easy and declarative way of getting document's blob data without + * showing it on screen. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class BlobProvider extends React.Component {} + + interface PDFViewerProps { + width?: number | string; + height?: number | string; + style?: Style | Style[]; + className?: string; + children?: React.ReactElement; + innerRef?: React.Ref; + showToolbar?: boolean; + } + + /** + * Iframe PDF viewer for client-side generated documents. + * @platform web + */ + export class PDFViewer extends React.Component {} + + interface PDFDownloadLinkProps + extends Omit< + React.AnchorHTMLAttributes, + 'href' | 'children' + > { + /** PDF filename. Alias for anchor tag `download` attribute. */ + fileName?: string; + document: React.ReactElement; + children?: React.ReactNode | React.FC; + onClick?: React.AnchorHTMLAttributes['onClick'] & + (( + event: React.MouseEvent, + instance: UsePDFInstance, + ) => void); + ref?: React.Ref | undefined; + } + + /** + * Anchor tag to enable generate and download PDF documents on the fly. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class PDFDownloadLink extends React.Component {} + + interface UsePDFInstance { + loading: boolean; + blob: Blob | null; + url: string | null; + error: string | null; + } + + /** + * React hook for creating and updating a PDF document instance + * @platform web + */ + export function usePDF(options?: { + document?: React.ReactElement; + }): [ + UsePDFInstance, + (newDocument: React.ReactElement) => void, + ]; + + export const Font: FontStore; + + export const StyleSheet: { + create: (styles: T) => T; + }; + + export const version: any; + + export const PDFRenderer: any; + + export const pdf: (initialValue?: React.ReactElement) => { + container: any; + isDirty: () => boolean; + toString: () => string; + toBlob: () => Promise; + toBuffer: () => Promise; + on: (event: 'change', callback: () => void) => void; + updateContainer: ( + document: React.ReactElement, + callback?: () => void, + ) => void; + removeListener: (event: 'change', callback: () => void) => void; + }; + + export const renderToStream: ( + document: React.ReactElement, + ) => Promise; + + /** + * @deprecated use the `renderToBuffer` method + */ + export const renderToString: ( + document: React.ReactElement, + ) => Promise; + + export const renderToFile: ( + document: React.ReactElement, + filePath: string, + callback?: (output: NodeJS.ReadableStream, _filePath: string) => any, + ) => Promise; + + const render: typeof renderToFile; + + /** + * Render document into a nodejs buffer + * @platform node + */ + export const renderToBuffer: ( + document: React.ReactElement, + ) => Promise; +} diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.js b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.js new file mode 100644 index 0000000000000000000000000000000000000000..769a5c3c91f50424e5b1c390bcb3672c12c4535f --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.js @@ -0,0 +1 @@ +import*as e from"@react-pdf/primitives";export*from"@react-pdf/primitives";import r from"queue";import{useRef as o,useState as t,useEffect as n,useCallback as i,forwardRef as a}from"react";import l from"@react-pdf/font";import c from"@react-pdf/render";import d from"@react-pdf/pdfkit";import s from"@react-pdf/layout";import{upperFirst as u}from"@react-pdf/fns";import p from"@react-pdf/reconciler";import{jsx as m}from"react/jsx-runtime";const f=(e,r)=>{let{style:o,children:t,...n}=r;return{type:e,box:{},style:o||{},props:n||{},children:[]}},v=e=>({type:"TEXT_INSTANCE",value:e}),h=(e,r)=>{const o="TEXT"===e.type||"LINK"===e.type||"TSPAN"===e.type||"NOTE"===e.type;"TEXT_INSTANCE"!==r.type||o?e.children.push(r):console.warn(`Invalid '${r.value}' string child outside component`)},y=(e,r)=>{"ROOT"===e.type?e.document=r:h(e,r)},w=(e,r,o)=>{var t;const n=null===(t=e.children)||void 0===t?void 0:t.indexOf(o);void 0!==n&&-1!==n&&r&&e.children.splice(n,0,r)},T=(e,r)=>{var o;const t=null===(o=e.children)||void 0===o?void 0:o.indexOf(r);void 0!==t&&-1!==t&&e.children.splice(t,1)},b=(e,r)=>{var o;const t=null===(o=e.children)||void 0===o?void 0:o.indexOf(r);void 0!==t&&-1!==t&&e.children.splice(t,1)},g=(e,r,o)=>{e.value=o},C=(e,r,o,t,n)=>{const{style:i,...a}=n;e.props=a,e.style=i},P=e=>{let{onChange:r=(()=>{})}=e;return p({appendChild:h,appendChildToContainer:y,commitTextUpdate:g,commitUpdate:C,createInstance:f,createTextInstance:v,insertBefore:w,removeChild:T,removeChildFromContainer:b,resetAfterCommit:r})};var S={version:"4.5.1"};const{version:N}=S,A=new l;let O;const _={},L=e=>{const r={type:"ROOT",document:null};O=O||P({onChange:()=>{var e;const r=(null===(e=_.change)||void 0===e?void 0:e.slice())||[];for(let e=0;e{O.updateContainer(e,o,null,r)};e&&t(e);const n=async function(e){void 0===e&&(e=!0);const o=r.document.props||{},{pdfVersion:t,language:n,pageLayout:i,pageMode:a,title:l,author:p,subject:m,keywords:f,creator:v="react-pdf",producer:h="react-pdf",creationDate:y=new Date,modificationDate:w,ownerPassword:T,userPassword:b,permissions:g}=o,C=new d({compress:e,pdfVersion:t,lang:n,displayTitle:!0,autoFirstPage:!1,ownerPassword:T,userPassword:b,permissions:g,pageLayout:i,info:(P={Title:l,Author:p,Subject:m,Keywords:f,Creator:v,Producer:h,CreationDate:y,ModificationDate:w},Object.fromEntries(Object.entries(P).filter((e=>{let[,r]=e;return void 0!==r}))))});var P;a&&(C._root.data.PageMode=u(a));const S=await s(r.document,A);return{layout:S,fileStream:c(C,S)}},i=function(e){void 0===e&&(e={}),r.document.props.onRender&&r.document.props.onRender(e)};return{on:(e,r)=>{_[e]||(_[e]=[]),_[e].push(r)},container:r,toBlob:async()=>{const e=[],{layout:r,fileStream:o}=await n();return new Promise(((t,n)=>{o.on("data",(r=>{e.push(r instanceof Uint8Array?r:new Uint8Array(r))})),o.on("end",(()=>{try{const o=new Blob(e,{type:"application/pdf"});i({blob:o,_INTERNAL__LAYOUT__DATA_:r}),t(o)}catch(e){n(e)}}))}))},toBuffer:async()=>{const{layout:e,fileStream:r}=await n();return i({_INTERNAL__LAYOUT__DATA_:e}),r},toString:async()=>{"development"===process.env.NODE_ENV&&console.warn("`toString` is deprecated and will be removed in next major release");let e="";const{fileStream:r}=await n(!1);return new Promise(((o,t)=>{try{r.on("data",(r=>{e+=r})),r.on("end",(()=>{i(),o(e)}))}catch(e){t(e)}}))},removeListener:(e,r)=>{if(!_[e])return;const o=_[e].indexOf(r);o>-1&&_[e].splice(o,1)},updateContainer:t}},D=A,x={create:e=>e},E=function(e){let{document:a}=void 0===e?{}:e;const l=o(null),[c,d]=t({url:null,blob:null,error:null,loading:!!a});n((()=>{const e=r({autostart:!0,concurrency:1}),o=()=>{d((e=>({...e,loading:!0}))),e.splice(0,e.length,(()=>c.error?Promise.resolve():l.current.toBlob()))};return l.current=L(),l.current.on("change",o),a&&l.current.updateContainer(a),e.on("error",(e=>{console.error(e),d((r=>({...r,loading:!1,error:e})))})),e.on("success",(e=>{d({blob:e,error:null,loading:!1,url:URL.createObjectURL(e)})})),()=>{e.end(),l.current.removeListener("change",o)}}),[]),n((()=>()=>{c.url&&URL.revokeObjectURL(c.url)}),[c.url]);const s=i((e=>{l.current.updateContainer(e)}),[]);return[c,s]},R=e=>{let{title:r,style:o,className:t,children:i,innerRef:a,showToolbar:l=!0,...c}=e;const[d,s]=E();n((()=>s(i)),[i]);const u=d.url?`${d.url}#toolbar=${l?1:0}`:null;return m("iframe",{src:u,title:r,ref:a,style:o,className:t,...c})},B=e=>{let{document:r,children:o}=e;const[t,i]=E();return n((()=>i(r)),[r]),r?o(t):(console.warn("You should pass a valid document to BlobProvider"),null)},U=a(((e,r)=>{let{fileName:o="document.pdf",document:t,children:i,onClick:a,href:l,...c}=e;const[d,s]=E();if(n((()=>s(t)),[t]),!t)return console.warn("You should pass a valid document to PDFDownloadLink"),null;return m("a",{href:d.url,download:o,onClick:e=>{d&&window.navigator.msSaveBlob&&window.navigator.msSaveBlob(d.blob,o),"function"==typeof a&&a(e,d)},ref:r,...c,children:"function"==typeof i?i(d):i})})),F=e=>{throw new Error(`${e} is a Node specific API. You're either using this method in a browser, or your bundler is not loading react-pdf from the appropriate web build.`)},I=()=>{F("renderToStream")},j=()=>{F("renderToBuffer")},k=()=>{F("renderToString")},Y=()=>{F("renderToFile")},V=()=>{F("render")};var $={pdf:L,usePDF:E,Font:D,version:N,StyleSheet:x,PDFViewer:R,BlobProvider:B,PDFDownloadLink:U,renderToStream:I,renderToString:k,renderToFile:Y,render:V,...e};export{B as BlobProvider,D as Font,U as PDFDownloadLink,R as PDFViewer,x as StyleSheet,P as createRenderer,$ as default,L as pdf,V as render,j as renderToBuffer,Y as renderToFile,I as renderToStream,k as renderToString,E as usePDF,N as version}; diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.d.cts b/node_modules/@react-pdf/renderer/lib/react-pdf.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..1aa2dc8042e236867156186033b1931bf366c2d2 --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.d.cts @@ -0,0 +1,793 @@ +/* eslint-disable max-classes-per-file */ + +import * as React from 'react'; +import { + Style, + PageSize, + FontStore, + PDFVersion, + Orientation, + SourceObject, + SrcSet, + Sizes, + HyphenationCallback, + SVGPresentationAttributes, + Bookmark, + PageLayout, + PageMode, + HitSlop, +} from '@react-pdf/types'; + +declare class ReactPDF { + static default: typeof ReactPDF; +} + +export = ReactPDF; + +declare namespace ReactPDF { + interface Styles { + [key: string]: Style; + } + interface OnRenderProps { + blob?: Blob; + } + + interface Permissions { + printing?: 'lowResolution' | 'highResolution'; + modifying?: boolean; + copying?: boolean; + annotating?: boolean; + fillingForms?: boolean; + contentAccessibility?: boolean; + documentAssembly?: boolean; + } + + interface DocumentProps { + style?: Style | Style[]; + title?: string; + author?: string; + subject?: string; + creator?: string; + keywords?: string; + producer?: string; + language?: string; + creationDate?: Date; + modificationDate?: Date; + pdfVersion?: PDFVersion; + pageMode?: PageMode; + pageLayout?: PageLayout; + ownerPassword?: string; + userPassword?: string; + permissions?: Permissions; + onRender?: (props: OnRenderProps) => any; + } + + /** + * This component represent the PDF document itself. It must be the root + * of your tree element structure, and under no circumstances should it be + * used as children of another react-pdf component. In addition, it should + * only have childs of type . + */ + export class Document extends React.Component< + React.PropsWithChildren + > {} + + interface NodeProps { + id?: string; + style?: Style | Style[]; + /** + * Render component in all wrapped pages. + * @see https://react-pdf.org/advanced#fixed-components + */ + fixed?: boolean; + /** + * Force the wrapping algorithm to start a new page when rendering the + * element. + * @see https://react-pdf.org/advanced#page-breaks + */ + break?: boolean; + /** + * Hint that no page wrapping should occur between all sibling elements following the element within n points + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + minPresenceAhead?: number; + } + + interface PageProps extends NodeProps { + /** + * Enable page wrapping for this page. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + size?: PageSize; + orientation?: Orientation; + dpi?: number; + bookmark?: Bookmark; + } + + /** + * Represents single page inside the PDF document, or a subset of them if + * using the wrapping feature. A can contain as many pages as + * you want, but ensure not rendering a page inside any component besides + * Document. + */ + export class Page extends React.Component< + React.PropsWithChildren + > {} + + interface ViewProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + subPageNumber: number; + }) => React.ReactNode; + } + + /** + * The most fundamental component for building a UI and is designed to be + * nested inside other views and can have 0 to many children. + */ + export class View extends React.Component< + React.PropsWithChildren + > {} + + interface BaseImageProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * Works like the HTML img sizes attribute. + * @example 300 + * @example "300" + */ + sizes?: Sizes; + } + + interface ImageWithSrcProp extends BaseImageProps { + src: SourceObject; + } + + interface ImageWithSourceProp extends BaseImageProps { + source: SourceObject; + } + + type ImageProps = ImageWithSrcProp | ImageWithSourceProp; + + /** + * A React component for displaying network or local (Node only) JPG or + * PNG images, as well as base64 encoded image strings. + */ + export class Image extends React.Component {} + + interface BaseImageBackgroundProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * @example 300 + */ + sizes?: Sizes; + /** + * Style applied to the background image. + */ + imageStyle?: Style; + } + + interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps { + src: SourceObject; + } + + interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps { + source: SourceObject; + } + + type ImageBackgroundProps = + | ImageBackgroundWithSrcProp + | ImageBackgroundWithSourceProp; + + /** + * A React component for displaying an image behind child content. + * Compatible with React Native's ImageBackground component. + * @see https://reactnative.dev/docs/imagebackground + */ + export class ImageBackground extends React.Component< + React.PropsWithChildren + > {} + + interface TextProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + totalPages: number; + subPageNumber: number; + subPageTotalPages: number; + }) => React.ReactNode; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + /** + * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + orphans?: number; + /** + * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container.. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + widows?: number; + } + + interface SVGTextProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x: string | number; + y: string | number; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + } + + /** + * A React component for displaying text. Text supports nesting of other + * Text or Link components to create inline styling. + */ + export class Text extends React.Component< + React.PropsWithChildren | SVGTextProps + > {} + + interface LinkProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + href?: string; + src?: string; + /** + * Extends the clickable area of the link beyond its visible bounds. + * Accepts a number (applied to all sides) or an object with top, bottom, left, right. + * @see https://reactnative.dev/docs/view#hitslop + */ + hitSlop?: HitSlop; + } + + /** + * A React component for displaying a hyperlink. Link’s can be nested + * inside a Text component, or being inside any other valid primitive. + */ + export class Link extends React.Component< + React.PropsWithChildren + > {} + + interface FormCommonProps extends NodeProps { + name?: string; + required?: boolean; + noExport?: boolean; + readOnly?: boolean; + value?: number | string; + defaultValue?: number | string; + } + + interface FieldSetProps extends NodeProps { + name: string; + } + + export class FieldSet extends React.Component< + React.PropsWithChildren + > {} + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputFormatting { + type: + | 'date' + | 'time' + | 'percent' + | 'number' + | 'zip' + | 'zipPlus4' + | 'phone' + | 'ssn'; + param?: string; + nDec?: number; + sepComma?: boolean; + negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed'; + currency?: string; + currencyPrepend?: boolean; + } + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputProps extends FormCommonProps { + align?: 'left' | 'center' | 'right'; + multiline?: boolean; + /** + * The text will be masked (e.g. with asterisks). + */ + password?: boolean; + /** + * If set, text entered in the field is not spell-checked + */ + noSpell?: boolean; + format?: TextInputFormatting; + /** + * Sets the fontSize (default or 0 means auto sizing) + */ + fontSize?: number; + /** + * Sets the maximum length (characters) of the text in the field + */ + maxLength?: number; + } + + export class TextInput extends React.Component {} + + interface CheckboxProps extends FormCommonProps { + backgroundColor?: string; + borderColor?: string; + checked?: boolean; + onState?: string; + offState?: string; + xMark?: boolean; + } + + export class Checkbox extends React.Component {} + + interface SelectAndListPropsBase extends FormCommonProps { + sort?: boolean; + edit?: boolean; + multiSelect?: boolean; + noSpell?: boolean; + select?: string[]; + } + + type SelectAndListPropsWithEdit = SelectAndListPropsBase & { + edit: true | false; + noSpell: boolean; + }; + + type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & { + edit: boolean; + noSpell: true | false; + }; + + type SelectAndListProps = + | SelectAndListPropsWithEdit + | SelectAndListPropsWithNoSpell; + + export class Select extends React.Component {} + + export class List extends React.Component {} + + interface NoteProps extends NodeProps { + children: string; + } + + export class Note extends React.Component {} + + interface CanvasProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + paint: ( + painter: any, + availableWidth: number, + availableHeight: number, + ) => null; + } + + export class Canvas extends React.Component {} + + interface SVGProps extends NodeProps, SVGPresentationAttributes { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + width?: string | number; + height?: string | number; + viewBox?: string; + preserveAspectRatio?: string; + } + + /** + * The element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents. + */ + export class Svg extends React.Component> {} + + interface LineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x1: string | number; + x2: string | number; + y1: string | number; + y2: string | number; + } + + /** + * The element is used to create a line. + */ + export class Line extends React.Component< + React.PropsWithChildren + > {} + + interface PolylineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create any shape that consists of only straight lines (that is connected at several points). + */ + export class Polyline extends React.Component< + React.PropsWithChildren + > {} + + interface PolygonProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create a graphic that contains at least three sides. + * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up). + */ + export class Polygon extends React.Component< + React.PropsWithChildren + > {} + + interface PathProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + d: string; + } + + /** + * The element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more. + */ + export class Path extends React.Component< + React.PropsWithChildren + > {} + + interface RectProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x?: string | number; + y?: string | number; + width: string | number; + height: string | number; + rx?: string | number; + ry?: string | number; + } + + /** + * The element is used to create a rectangle and variations of a rectangle shape. + */ + export class Rect extends React.Component< + React.PropsWithChildren + > {} + + interface CircleProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + r: string | number; + } + + /** + * The element is used to create a circle. + */ + export class Circle extends React.Component< + React.PropsWithChildren + > {} + + interface EllipseProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + rx: string | number; + ry: string | number; + } + + /** + * The element is used to create an ellipse. + * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius. + */ + export class Ellipse extends React.Component< + React.PropsWithChildren + > {} + + interface TspanProps extends SVGPresentationAttributes { + x?: string | number; + y?: string | number; + } + + /** + * The element defines a subtext within a element or another element. + * It allows for adjustment of the style and/or position of that subtext as needed. + */ + export class Tspan extends React.Component< + React.PropsWithChildren + > {} + + interface GProps extends SVGPresentationAttributes { + style?: Style; + } + + /** + * The SVG element is a container used to group other SVG elements. + * Transformations applied to the element are performed on its child elements, and its attributes are inherited by its children. + */ + export class G extends React.Component> {} + + interface StopProps { + offset: string | number; + stopColor: string; + stopOpacity?: string | number; + } + + /** + * The SVG element defines a color and its position to use on a gradient. This element is always a child of a or element + */ + export class Stop extends React.Component< + React.PropsWithChildren + > {} + + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface DefsProps {} + + /** + * The element is used to store graphical objects that will be used at a later time. Objects created inside a element are not rendered directly. To display them you have to reference them + */ + export class Defs extends React.Component< + React.PropsWithChildren + > {} + + interface ClipPathProps { + id?: string; + } + + /** + * The SVG element defines a clipping path, to be used by the clipPath property. + * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn. + */ + export class ClipPath extends React.Component< + React.PropsWithChildren + > {} + + interface MarkerProps { + id: string; + viewBox?: string; + refX?: string | number; + refY?: string | number; + markerWidth?: string | number; + markerHeight?: string | number; + orient?: 'auto' | 'auto-start-reverse' | number; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; + } + + /** + * The SVG element defines a graphic used for drawing arrows or polymarkers on a given , , , or element. + * Markers can be attached to shapes using the markerStart, markerMid, and markerEnd properties. + */ + export class Marker extends React.Component< + React.PropsWithChildren + > {} + + interface LinearGradientProps { + id: string; + x1?: string | number; + x2?: string | number; + y1?: string | number; + y2?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define linear gradients that can be applied to fill or stroke of graphical elements. + */ + export class LinearGradient extends React.Component< + React.PropsWithChildren + > {} + + interface RadialGradientProps { + id: string; + cx?: string | number; + cy?: string | number; + r?: string | number; + fx?: string | number; + fy?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define radial gradients that can be applied to fill or stroke of graphical elements. + */ + export class RadialGradient extends React.Component< + React.PropsWithChildren + > {} + + interface BlobProviderParams { + blob: Blob | null; + url: string | null; + loading: boolean; + error: Error | null; + } + interface BlobProviderProps { + document: React.ReactElement; + children: (params: BlobProviderParams) => React.ReactNode; + } + + /** + * Easy and declarative way of getting document's blob data without + * showing it on screen. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class BlobProvider extends React.Component {} + + interface PDFViewerProps { + width?: number | string; + height?: number | string; + style?: Style | Style[]; + className?: string; + children?: React.ReactElement; + innerRef?: React.Ref; + showToolbar?: boolean; + } + + /** + * Iframe PDF viewer for client-side generated documents. + * @platform web + */ + export class PDFViewer extends React.Component {} + + interface PDFDownloadLinkProps + extends Omit< + React.AnchorHTMLAttributes, + 'href' | 'children' + > { + /** PDF filename. Alias for anchor tag `download` attribute. */ + fileName?: string; + document: React.ReactElement; + children?: React.ReactNode | React.FC; + onClick?: React.AnchorHTMLAttributes['onClick'] & + (( + event: React.MouseEvent, + instance: UsePDFInstance, + ) => void); + ref?: React.Ref | undefined; + } + + /** + * Anchor tag to enable generate and download PDF documents on the fly. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class PDFDownloadLink extends React.Component {} + + interface UsePDFInstance { + loading: boolean; + blob: Blob | null; + url: string | null; + error: string | null; + } + + /** + * React hook for creating and updating a PDF document instance + * @platform web + */ + export function usePDF(options?: { + document?: React.ReactElement; + }): [ + UsePDFInstance, + (newDocument: React.ReactElement) => void, + ]; + + export const Font: FontStore; + + export const StyleSheet: { + create: (styles: T) => T; + }; + + export const version: any; + + export const PDFRenderer: any; + + export const pdf: (initialValue?: React.ReactElement) => { + container: any; + isDirty: () => boolean; + toString: () => string; + toBlob: () => Promise; + toBuffer: () => Promise; + on: (event: 'change', callback: () => void) => void; + updateContainer: ( + document: React.ReactElement, + callback?: () => void, + ) => void; + removeListener: (event: 'change', callback: () => void) => void; + }; + + export const renderToStream: ( + document: React.ReactElement, + ) => Promise; + + /** + * @deprecated use the `renderToBuffer` method + */ + export const renderToString: ( + document: React.ReactElement, + ) => Promise; + + export const renderToFile: ( + document: React.ReactElement, + filePath: string, + callback?: (output: NodeJS.ReadableStream, _filePath: string) => any, + ) => Promise; + + const render: typeof renderToFile; + + /** + * Render document into a nodejs buffer + * @platform node + */ + export const renderToBuffer: ( + document: React.ReactElement, + ) => Promise; +} diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.d.ts b/node_modules/@react-pdf/renderer/lib/react-pdf.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1aa2dc8042e236867156186033b1931bf366c2d2 --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.d.ts @@ -0,0 +1,793 @@ +/* eslint-disable max-classes-per-file */ + +import * as React from 'react'; +import { + Style, + PageSize, + FontStore, + PDFVersion, + Orientation, + SourceObject, + SrcSet, + Sizes, + HyphenationCallback, + SVGPresentationAttributes, + Bookmark, + PageLayout, + PageMode, + HitSlop, +} from '@react-pdf/types'; + +declare class ReactPDF { + static default: typeof ReactPDF; +} + +export = ReactPDF; + +declare namespace ReactPDF { + interface Styles { + [key: string]: Style; + } + interface OnRenderProps { + blob?: Blob; + } + + interface Permissions { + printing?: 'lowResolution' | 'highResolution'; + modifying?: boolean; + copying?: boolean; + annotating?: boolean; + fillingForms?: boolean; + contentAccessibility?: boolean; + documentAssembly?: boolean; + } + + interface DocumentProps { + style?: Style | Style[]; + title?: string; + author?: string; + subject?: string; + creator?: string; + keywords?: string; + producer?: string; + language?: string; + creationDate?: Date; + modificationDate?: Date; + pdfVersion?: PDFVersion; + pageMode?: PageMode; + pageLayout?: PageLayout; + ownerPassword?: string; + userPassword?: string; + permissions?: Permissions; + onRender?: (props: OnRenderProps) => any; + } + + /** + * This component represent the PDF document itself. It must be the root + * of your tree element structure, and under no circumstances should it be + * used as children of another react-pdf component. In addition, it should + * only have childs of type . + */ + export class Document extends React.Component< + React.PropsWithChildren + > {} + + interface NodeProps { + id?: string; + style?: Style | Style[]; + /** + * Render component in all wrapped pages. + * @see https://react-pdf.org/advanced#fixed-components + */ + fixed?: boolean; + /** + * Force the wrapping algorithm to start a new page when rendering the + * element. + * @see https://react-pdf.org/advanced#page-breaks + */ + break?: boolean; + /** + * Hint that no page wrapping should occur between all sibling elements following the element within n points + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + minPresenceAhead?: number; + } + + interface PageProps extends NodeProps { + /** + * Enable page wrapping for this page. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + size?: PageSize; + orientation?: Orientation; + dpi?: number; + bookmark?: Bookmark; + } + + /** + * Represents single page inside the PDF document, or a subset of them if + * using the wrapping feature. A can contain as many pages as + * you want, but ensure not rendering a page inside any component besides + * Document. + */ + export class Page extends React.Component< + React.PropsWithChildren + > {} + + interface ViewProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + subPageNumber: number; + }) => React.ReactNode; + } + + /** + * The most fundamental component for building a UI and is designed to be + * nested inside other views and can have 0 to many children. + */ + export class View extends React.Component< + React.PropsWithChildren + > {} + + interface BaseImageProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * Works like the HTML img sizes attribute. + * @example 300 + * @example "300" + */ + sizes?: Sizes; + } + + interface ImageWithSrcProp extends BaseImageProps { + src: SourceObject; + } + + interface ImageWithSourceProp extends BaseImageProps { + source: SourceObject; + } + + type ImageProps = ImageWithSrcProp | ImageWithSourceProp; + + /** + * A React component for displaying network or local (Node only) JPG or + * PNG images, as well as base64 encoded image strings. + */ + export class Image extends React.Component {} + + interface BaseImageBackgroundProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * @example 300 + */ + sizes?: Sizes; + /** + * Style applied to the background image. + */ + imageStyle?: Style; + } + + interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps { + src: SourceObject; + } + + interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps { + source: SourceObject; + } + + type ImageBackgroundProps = + | ImageBackgroundWithSrcProp + | ImageBackgroundWithSourceProp; + + /** + * A React component for displaying an image behind child content. + * Compatible with React Native's ImageBackground component. + * @see https://reactnative.dev/docs/imagebackground + */ + export class ImageBackground extends React.Component< + React.PropsWithChildren + > {} + + interface TextProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + totalPages: number; + subPageNumber: number; + subPageTotalPages: number; + }) => React.ReactNode; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + /** + * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + orphans?: number; + /** + * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container.. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + widows?: number; + } + + interface SVGTextProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x: string | number; + y: string | number; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + } + + /** + * A React component for displaying text. Text supports nesting of other + * Text or Link components to create inline styling. + */ + export class Text extends React.Component< + React.PropsWithChildren | SVGTextProps + > {} + + interface LinkProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + href?: string; + src?: string; + /** + * Extends the clickable area of the link beyond its visible bounds. + * Accepts a number (applied to all sides) or an object with top, bottom, left, right. + * @see https://reactnative.dev/docs/view#hitslop + */ + hitSlop?: HitSlop; + } + + /** + * A React component for displaying a hyperlink. Link’s can be nested + * inside a Text component, or being inside any other valid primitive. + */ + export class Link extends React.Component< + React.PropsWithChildren + > {} + + interface FormCommonProps extends NodeProps { + name?: string; + required?: boolean; + noExport?: boolean; + readOnly?: boolean; + value?: number | string; + defaultValue?: number | string; + } + + interface FieldSetProps extends NodeProps { + name: string; + } + + export class FieldSet extends React.Component< + React.PropsWithChildren + > {} + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputFormatting { + type: + | 'date' + | 'time' + | 'percent' + | 'number' + | 'zip' + | 'zipPlus4' + | 'phone' + | 'ssn'; + param?: string; + nDec?: number; + sepComma?: boolean; + negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed'; + currency?: string; + currencyPrepend?: boolean; + } + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputProps extends FormCommonProps { + align?: 'left' | 'center' | 'right'; + multiline?: boolean; + /** + * The text will be masked (e.g. with asterisks). + */ + password?: boolean; + /** + * If set, text entered in the field is not spell-checked + */ + noSpell?: boolean; + format?: TextInputFormatting; + /** + * Sets the fontSize (default or 0 means auto sizing) + */ + fontSize?: number; + /** + * Sets the maximum length (characters) of the text in the field + */ + maxLength?: number; + } + + export class TextInput extends React.Component {} + + interface CheckboxProps extends FormCommonProps { + backgroundColor?: string; + borderColor?: string; + checked?: boolean; + onState?: string; + offState?: string; + xMark?: boolean; + } + + export class Checkbox extends React.Component {} + + interface SelectAndListPropsBase extends FormCommonProps { + sort?: boolean; + edit?: boolean; + multiSelect?: boolean; + noSpell?: boolean; + select?: string[]; + } + + type SelectAndListPropsWithEdit = SelectAndListPropsBase & { + edit: true | false; + noSpell: boolean; + }; + + type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & { + edit: boolean; + noSpell: true | false; + }; + + type SelectAndListProps = + | SelectAndListPropsWithEdit + | SelectAndListPropsWithNoSpell; + + export class Select extends React.Component {} + + export class List extends React.Component {} + + interface NoteProps extends NodeProps { + children: string; + } + + export class Note extends React.Component {} + + interface CanvasProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + paint: ( + painter: any, + availableWidth: number, + availableHeight: number, + ) => null; + } + + export class Canvas extends React.Component {} + + interface SVGProps extends NodeProps, SVGPresentationAttributes { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + width?: string | number; + height?: string | number; + viewBox?: string; + preserveAspectRatio?: string; + } + + /** + * The element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents. + */ + export class Svg extends React.Component> {} + + interface LineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x1: string | number; + x2: string | number; + y1: string | number; + y2: string | number; + } + + /** + * The element is used to create a line. + */ + export class Line extends React.Component< + React.PropsWithChildren + > {} + + interface PolylineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create any shape that consists of only straight lines (that is connected at several points). + */ + export class Polyline extends React.Component< + React.PropsWithChildren + > {} + + interface PolygonProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create a graphic that contains at least three sides. + * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up). + */ + export class Polygon extends React.Component< + React.PropsWithChildren + > {} + + interface PathProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + d: string; + } + + /** + * The element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more. + */ + export class Path extends React.Component< + React.PropsWithChildren + > {} + + interface RectProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x?: string | number; + y?: string | number; + width: string | number; + height: string | number; + rx?: string | number; + ry?: string | number; + } + + /** + * The element is used to create a rectangle and variations of a rectangle shape. + */ + export class Rect extends React.Component< + React.PropsWithChildren + > {} + + interface CircleProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + r: string | number; + } + + /** + * The element is used to create a circle. + */ + export class Circle extends React.Component< + React.PropsWithChildren + > {} + + interface EllipseProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + rx: string | number; + ry: string | number; + } + + /** + * The element is used to create an ellipse. + * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius. + */ + export class Ellipse extends React.Component< + React.PropsWithChildren + > {} + + interface TspanProps extends SVGPresentationAttributes { + x?: string | number; + y?: string | number; + } + + /** + * The element defines a subtext within a element or another element. + * It allows for adjustment of the style and/or position of that subtext as needed. + */ + export class Tspan extends React.Component< + React.PropsWithChildren + > {} + + interface GProps extends SVGPresentationAttributes { + style?: Style; + } + + /** + * The SVG element is a container used to group other SVG elements. + * Transformations applied to the element are performed on its child elements, and its attributes are inherited by its children. + */ + export class G extends React.Component> {} + + interface StopProps { + offset: string | number; + stopColor: string; + stopOpacity?: string | number; + } + + /** + * The SVG element defines a color and its position to use on a gradient. This element is always a child of a or element + */ + export class Stop extends React.Component< + React.PropsWithChildren + > {} + + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface DefsProps {} + + /** + * The element is used to store graphical objects that will be used at a later time. Objects created inside a element are not rendered directly. To display them you have to reference them + */ + export class Defs extends React.Component< + React.PropsWithChildren + > {} + + interface ClipPathProps { + id?: string; + } + + /** + * The SVG element defines a clipping path, to be used by the clipPath property. + * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn. + */ + export class ClipPath extends React.Component< + React.PropsWithChildren + > {} + + interface MarkerProps { + id: string; + viewBox?: string; + refX?: string | number; + refY?: string | number; + markerWidth?: string | number; + markerHeight?: string | number; + orient?: 'auto' | 'auto-start-reverse' | number; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; + } + + /** + * The SVG element defines a graphic used for drawing arrows or polymarkers on a given , , , or element. + * Markers can be attached to shapes using the markerStart, markerMid, and markerEnd properties. + */ + export class Marker extends React.Component< + React.PropsWithChildren + > {} + + interface LinearGradientProps { + id: string; + x1?: string | number; + x2?: string | number; + y1?: string | number; + y2?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define linear gradients that can be applied to fill or stroke of graphical elements. + */ + export class LinearGradient extends React.Component< + React.PropsWithChildren + > {} + + interface RadialGradientProps { + id: string; + cx?: string | number; + cy?: string | number; + r?: string | number; + fx?: string | number; + fy?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define radial gradients that can be applied to fill or stroke of graphical elements. + */ + export class RadialGradient extends React.Component< + React.PropsWithChildren + > {} + + interface BlobProviderParams { + blob: Blob | null; + url: string | null; + loading: boolean; + error: Error | null; + } + interface BlobProviderProps { + document: React.ReactElement; + children: (params: BlobProviderParams) => React.ReactNode; + } + + /** + * Easy and declarative way of getting document's blob data without + * showing it on screen. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class BlobProvider extends React.Component {} + + interface PDFViewerProps { + width?: number | string; + height?: number | string; + style?: Style | Style[]; + className?: string; + children?: React.ReactElement; + innerRef?: React.Ref; + showToolbar?: boolean; + } + + /** + * Iframe PDF viewer for client-side generated documents. + * @platform web + */ + export class PDFViewer extends React.Component {} + + interface PDFDownloadLinkProps + extends Omit< + React.AnchorHTMLAttributes, + 'href' | 'children' + > { + /** PDF filename. Alias for anchor tag `download` attribute. */ + fileName?: string; + document: React.ReactElement; + children?: React.ReactNode | React.FC; + onClick?: React.AnchorHTMLAttributes['onClick'] & + (( + event: React.MouseEvent, + instance: UsePDFInstance, + ) => void); + ref?: React.Ref | undefined; + } + + /** + * Anchor tag to enable generate and download PDF documents on the fly. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class PDFDownloadLink extends React.Component {} + + interface UsePDFInstance { + loading: boolean; + blob: Blob | null; + url: string | null; + error: string | null; + } + + /** + * React hook for creating and updating a PDF document instance + * @platform web + */ + export function usePDF(options?: { + document?: React.ReactElement; + }): [ + UsePDFInstance, + (newDocument: React.ReactElement) => void, + ]; + + export const Font: FontStore; + + export const StyleSheet: { + create: (styles: T) => T; + }; + + export const version: any; + + export const PDFRenderer: any; + + export const pdf: (initialValue?: React.ReactElement) => { + container: any; + isDirty: () => boolean; + toString: () => string; + toBlob: () => Promise; + toBuffer: () => Promise; + on: (event: 'change', callback: () => void) => void; + updateContainer: ( + document: React.ReactElement, + callback?: () => void, + ) => void; + removeListener: (event: 'change', callback: () => void) => void; + }; + + export const renderToStream: ( + document: React.ReactElement, + ) => Promise; + + /** + * @deprecated use the `renderToBuffer` method + */ + export const renderToString: ( + document: React.ReactElement, + ) => Promise; + + export const renderToFile: ( + document: React.ReactElement, + filePath: string, + callback?: (output: NodeJS.ReadableStream, _filePath: string) => any, + ) => Promise; + + const render: typeof renderToFile; + + /** + * Render document into a nodejs buffer + * @platform node + */ + export const renderToBuffer: ( + document: React.ReactElement, + ) => Promise; +} diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.js b/node_modules/@react-pdf/renderer/lib/react-pdf.js new file mode 100644 index 0000000000000000000000000000000000000000..fa6f82d1ca8036dbef5bf88e8baae992f7f2840a --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.js @@ -0,0 +1,368 @@ +import * as primitives from '@react-pdf/primitives'; +export * from '@react-pdf/primitives'; +import fs from 'fs'; +import { Buffer } from 'buffer'; +import FontStore from '@react-pdf/font'; +import renderPDF from '@react-pdf/render'; +import PDFDocument from '@react-pdf/pdfkit'; +import layoutDocument from '@react-pdf/layout'; +import { upperFirst } from '@react-pdf/fns'; +import Reconciler from '@react-pdf/reconciler'; + +const omitNils = object => Object.fromEntries(Object.entries(object).filter(_ref => { + let [, value] = _ref; + return value !== undefined; +})); + +const createInstance = (type, _ref) => { + let { + style, + children, + ...props + } = _ref; + return { + type, + box: {}, + style: style || {}, + props: props || {}, + children: [] + }; +}; +const createTextInstance = text => ({ + type: 'TEXT_INSTANCE', + value: text +}); +const appendChild = (parent, child) => { + const isParentText = parent.type === 'TEXT' || parent.type === 'LINK' || parent.type === 'TSPAN' || parent.type === 'NOTE'; + const isChildTextInstance = child.type === 'TEXT_INSTANCE'; + const isOrphanTextInstance = isChildTextInstance && !isParentText; + + // Ignore orphan text instances. + // Caused by cases such as <>{name && {name}} + if (isOrphanTextInstance) { + console.warn(`Invalid '${child.value}' string child outside component`); + return; + } + parent.children.push(child); +}; +const appendChildToContainer = (parentInstance, child) => { + if (parentInstance.type === 'ROOT') { + parentInstance.document = child; + } else { + appendChild(parentInstance, child); + } +}; +const insertBefore = (parentInstance, child, beforeChild) => { + var _parentInstance$child; + const index = (_parentInstance$child = parentInstance.children) === null || _parentInstance$child === void 0 ? void 0 : _parentInstance$child.indexOf(beforeChild); + if (index === undefined) return; + if (index !== -1 && child) parentInstance.children.splice(index, 0, child); +}; +const removeChild = (parentInstance, child) => { + var _parentInstance$child2; + const index = (_parentInstance$child2 = parentInstance.children) === null || _parentInstance$child2 === void 0 ? void 0 : _parentInstance$child2.indexOf(child); + if (index === undefined) return; + if (index !== -1) parentInstance.children.splice(index, 1); +}; +const removeChildFromContainer = (parentInstance, child) => { + var _parentInstance$child3; + const index = (_parentInstance$child3 = parentInstance.children) === null || _parentInstance$child3 === void 0 ? void 0 : _parentInstance$child3.indexOf(child); + if (index === undefined) return; + if (index !== -1) parentInstance.children.splice(index, 1); +}; +const commitTextUpdate = (textInstance, oldText, newText) => { + textInstance.value = newText; +}; +const commitUpdate = (instance, updatePayload, type, oldProps, newProps) => { + const { + style, + ...props + } = newProps; + instance.props = props; + instance.style = style; +}; +const createRenderer = _ref2 => { + let { + onChange = () => {} + } = _ref2; + return Reconciler({ + appendChild, + appendChildToContainer, + commitTextUpdate, + commitUpdate, + createInstance, + createTextInstance, + insertBefore, + removeChild, + removeChildFromContainer, + resetAfterCommit: onChange + }); +}; + +var version$1 = "4.5.1"; +var packageJson = { + version: version$1}; + +const { + version +} = packageJson; +const fontStore = new FontStore(); + +// We must keep a single renderer instance, otherwise React will complain +let renderer; + +// The pdf instance acts as an event emitter for DOM usage. +// We only want to trigger an update when PDF content changes +const events = {}; +const pdf = initialValue => { + const onChange = () => { + var _events$change; + const listeners = ((_events$change = events.change) === null || _events$change === void 0 ? void 0 : _events$change.slice()) || []; + for (let i = 0; i < listeners.length; i += 1) listeners[i](); + }; + const container = { + type: 'ROOT', + document: null + }; + renderer = renderer || createRenderer({ + onChange + }); + const mountNode = renderer.createContainer(container); + const updateContainer = (doc, callback) => { + renderer.updateContainer(doc, mountNode, null, callback); + }; + if (initialValue) updateContainer(initialValue); + const render = async function (compress) { + if (compress === void 0) { + compress = true; + } + const props = container.document.props || {}; + const { + pdfVersion, + language, + pageLayout, + pageMode, + title, + author, + subject, + keywords, + creator = 'react-pdf', + producer = 'react-pdf', + creationDate = new Date(), + modificationDate, + ownerPassword, + userPassword, + permissions + } = props; + const ctx = new PDFDocument({ + compress, + pdfVersion, + lang: language, + displayTitle: true, + autoFirstPage: false, + ownerPassword, + userPassword, + permissions, + pageLayout, + info: omitNils({ + Title: title, + Author: author, + Subject: subject, + Keywords: keywords, + Creator: creator, + Producer: producer, + CreationDate: creationDate, + ModificationDate: modificationDate + }) + }); + if (pageMode) { + ctx._root.data.PageMode = upperFirst(pageMode); + } + const layout = await layoutDocument(container.document, fontStore); + const fileStream = renderPDF(ctx, layout); + return { + layout, + fileStream + }; + }; + const callOnRender = function (params) { + if (params === void 0) { + params = {}; + } + if (container.document.props.onRender) { + container.document.props.onRender(params); + } + }; + const toBlob = async () => { + const chunks = []; + const { + layout: _INTERNAL__LAYOUT__DATA_, + fileStream: instance + } = await render(); + return new Promise((resolve, reject) => { + instance.on('data', chunk => { + chunks.push(chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk)); + }); + instance.on('end', () => { + try { + const blob = new Blob(chunks, { + type: 'application/pdf' + }); + callOnRender({ + blob, + _INTERNAL__LAYOUT__DATA_ + }); + resolve(blob); + } catch (error) { + reject(error); + } + }); + }); + }; + + // TODO: rename this method to `toStream` in next major release, because it return stream not a buffer + const toBuffer = async () => { + const { + layout: _INTERNAL__LAYOUT__DATA_, + fileStream + } = await render(); + callOnRender({ + _INTERNAL__LAYOUT__DATA_ + }); + return fileStream; + }; + + /* + * TODO: remove this method in next major release. it is buggy + * see + * - https://github.com/diegomura/react-pdf/issues/2112 + * - https://github.com/diegomura/react-pdf/issues/2095 + */ + const toString = async () => { + if (process.env.NODE_ENV === 'development') { + console.warn('`toString` is deprecated and will be removed in next major release'); + } + let result = ''; + const { + fileStream: instance + } = await render(false); // For some reason, when rendering to string if compress=true the document is blank + + return new Promise((resolve, reject) => { + try { + instance.on('data', buffer => { + result += buffer; + }); + instance.on('end', () => { + callOnRender(); + resolve(result); + }); + } catch (error) { + reject(error); + } + }); + }; + const on = (event, listener) => { + if (!events[event]) events[event] = []; + events[event].push(listener); + }; + const removeListener = (event, listener) => { + if (!events[event]) return; + const idx = events[event].indexOf(listener); + if (idx > -1) events[event].splice(idx, 1); + }; + return { + on, + container, + toBlob, + toBuffer, + toString, + removeListener, + updateContainer + }; +}; +const Font = fontStore; +const StyleSheet = { + create: s => s +}; + +/** + * @param {React.ReactElement} element + * @returns {Promise} + */ +const renderToStream = async element => { + const instance = pdf(element); + const stream = await instance.toBuffer(); + return stream; +}; + +/** + * @param {React.ReactElement} element + * @param {string} filePath + * @param {Function} [callback] + */ +const renderToFile = async (element, filePath, callback) => { + const output = await renderToStream(element); + const stream = fs.createWriteStream(filePath); + output.pipe(stream); + return new Promise((resolve, reject) => { + stream.on('finish', () => { + if (callback) callback(output, filePath); + resolve(output); + }); + stream.on('error', reject); + }); +}; + +/** + * @param {React.ReactElement} element + * @returns {Promise} + */ +const renderToBuffer = element => renderToStream(element).then(stream => new Promise((resolve, reject) => { + const chunks = []; + stream.on('data', chunk => chunks.push(chunk)); + stream.on('end', () => resolve(Buffer.concat(chunks))); + stream.on('error', error => reject(error)); +})); +const renderToString = element => { + if (process.env.NODE_ENV === 'development') { + console.warn('`renderToString` is deprecated and will be removed in next major release, use `renderToBuffer` instead'); + } + return renderToBuffer(element).then(buffer => buffer.toString()); +}; + +const throwEnvironmentError = name => { + throw new Error(`${name} is a web specific API. You're either using this component on Node, or your bundler is not loading react-pdf from the appropriate web build.`); +}; +const usePDF = () => { + throwEnvironmentError('usePDF'); +}; +const PDFViewer = () => { + throwEnvironmentError('PDFViewer'); +}; +const PDFDownloadLink = () => { + throwEnvironmentError('PDFDownloadLink'); +}; +const BlobProvider = () => { + throwEnvironmentError('BlobProvider'); +}; +const render = renderToFile; + +// TODO: remove this default export in next major release because it breaks tree-shacking +var index = { + pdf, + Font, + version, + StyleSheet, + usePDF, + PDFViewer, + BlobProvider, + PDFDownloadLink, + renderToStream, + renderToString, + renderToFile, + render, + ...primitives +}; + +export { BlobProvider, Font, PDFDownloadLink, PDFViewer, StyleSheet, createRenderer, index as default, pdf, render, renderToBuffer, renderToFile, renderToStream, renderToString, usePDF, version }; +//# sourceMappingURL=react-pdf.js.map diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.js.map b/node_modules/@react-pdf/renderer/lib/react-pdf.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6b3b599a947561b3a72072a52ab16f6adb3e077c --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.js.map @@ -0,0 +1 @@ +{"version":3,"file":"react-pdf.js","sources":["../src/utils.js","../src/renderer.js","../src/index.js","../src/node/renderTo.js","../src/node/index.js"],"sourcesContent":["export const omitNils = (object) =>\n Object.fromEntries(\n Object.entries(object).filter(([, value]) => value !== undefined),\n );\n","import Reconciler from '@react-pdf/reconciler';\n\nconst createInstance = (type, { style, children, ...props }) => ({\n type,\n box: {},\n style: style || {},\n props: props || {},\n children: [],\n});\n\nconst createTextInstance = (text) => ({ type: 'TEXT_INSTANCE', value: text });\n\nconst appendChild = (parent, child) => {\n const isParentText =\n parent.type === 'TEXT' ||\n parent.type === 'LINK' ||\n parent.type === 'TSPAN' ||\n parent.type === 'NOTE';\n\n const isChildTextInstance = child.type === 'TEXT_INSTANCE';\n const isOrphanTextInstance = isChildTextInstance && !isParentText;\n\n // Ignore orphan text instances.\n // Caused by cases such as <>{name && {name}}\n if (isOrphanTextInstance) {\n console.warn(\n `Invalid '${child.value}' string child outside component`,\n );\n return;\n }\n\n parent.children.push(child);\n};\n\nconst appendChildToContainer = (parentInstance, child) => {\n if (parentInstance.type === 'ROOT') {\n parentInstance.document = child;\n } else {\n appendChild(parentInstance, child);\n }\n};\n\nconst insertBefore = (parentInstance, child, beforeChild) => {\n const index = parentInstance.children?.indexOf(beforeChild);\n\n if (index === undefined) return;\n\n if (index !== -1 && child) parentInstance.children.splice(index, 0, child);\n};\n\nconst removeChild = (parentInstance, child) => {\n const index = parentInstance.children?.indexOf(child);\n\n if (index === undefined) return;\n\n if (index !== -1) parentInstance.children.splice(index, 1);\n};\n\nconst removeChildFromContainer = (parentInstance, child) => {\n const index = parentInstance.children?.indexOf(child);\n\n if (index === undefined) return;\n\n if (index !== -1) parentInstance.children.splice(index, 1);\n};\n\nconst commitTextUpdate = (textInstance, oldText, newText) => {\n textInstance.value = newText;\n};\n\nconst commitUpdate = (instance, updatePayload, type, oldProps, newProps) => {\n const { style, ...props } = newProps;\n instance.props = props;\n instance.style = style;\n};\n\nconst createRenderer = ({ onChange = () => {} }) =>\n Reconciler({\n appendChild,\n appendChildToContainer,\n commitTextUpdate,\n commitUpdate,\n createInstance,\n createTextInstance,\n insertBefore,\n removeChild,\n removeChildFromContainer,\n resetAfterCommit: onChange,\n });\n\nexport default createRenderer;\n","import FontStore from '@react-pdf/font';\nimport renderPDF from '@react-pdf/render';\nimport PDFDocument from '@react-pdf/pdfkit';\nimport layoutDocument from '@react-pdf/layout';\nimport { upperFirst } from '@react-pdf/fns';\n\nimport { omitNils } from './utils';\nimport createRenderer from './renderer';\nimport packageJson from '../package.json';\n\nconst { version } = packageJson;\n\nconst fontStore = new FontStore();\n\n// We must keep a single renderer instance, otherwise React will complain\nlet renderer;\n\n// The pdf instance acts as an event emitter for DOM usage.\n// We only want to trigger an update when PDF content changes\nconst events = {};\n\nconst pdf = (initialValue) => {\n const onChange = () => {\n const listeners = events.change?.slice() || [];\n for (let i = 0; i < listeners.length; i += 1) listeners[i]();\n };\n\n const container = { type: 'ROOT', document: null };\n renderer = renderer || createRenderer({ onChange });\n const mountNode = renderer.createContainer(container);\n\n const updateContainer = (doc, callback) => {\n renderer.updateContainer(doc, mountNode, null, callback);\n };\n\n if (initialValue) updateContainer(initialValue);\n\n const render = async (compress = true) => {\n const props = container.document.props || {};\n const {\n pdfVersion,\n language,\n pageLayout,\n pageMode,\n title,\n author,\n subject,\n keywords,\n creator = 'react-pdf',\n producer = 'react-pdf',\n creationDate = new Date(),\n modificationDate,\n ownerPassword,\n userPassword,\n permissions,\n } = props;\n\n const ctx = new PDFDocument({\n compress,\n pdfVersion,\n lang: language,\n displayTitle: true,\n autoFirstPage: false,\n ownerPassword,\n userPassword,\n permissions,\n pageLayout,\n info: omitNils({\n Title: title,\n Author: author,\n Subject: subject,\n Keywords: keywords,\n Creator: creator,\n Producer: producer,\n CreationDate: creationDate,\n ModificationDate: modificationDate,\n }),\n });\n\n if (pageMode) {\n ctx._root.data.PageMode = upperFirst(pageMode);\n }\n\n const layout = await layoutDocument(container.document, fontStore);\n const fileStream = renderPDF(ctx, layout);\n return { layout, fileStream };\n };\n\n const callOnRender = (params = {}) => {\n if (container.document.props.onRender) {\n container.document.props.onRender(params);\n }\n };\n\n const toBlob = async () => {\n const chunks = [];\n const { layout: _INTERNAL__LAYOUT__DATA_, fileStream: instance } =\n await render();\n\n return new Promise((resolve, reject) => {\n instance.on('data', (chunk) => {\n chunks.push(\n chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk),\n );\n });\n\n instance.on('end', () => {\n try {\n const blob = new Blob(chunks, { type: 'application/pdf' });\n callOnRender({ blob, _INTERNAL__LAYOUT__DATA_ });\n resolve(blob);\n } catch (error) {\n reject(error);\n }\n });\n });\n };\n\n // TODO: rename this method to `toStream` in next major release, because it return stream not a buffer\n const toBuffer = async () => {\n const { layout: _INTERNAL__LAYOUT__DATA_, fileStream } = await render();\n callOnRender({ _INTERNAL__LAYOUT__DATA_ });\n\n return fileStream;\n };\n\n /*\n * TODO: remove this method in next major release. it is buggy\n * see\n * - https://github.com/diegomura/react-pdf/issues/2112\n * - https://github.com/diegomura/react-pdf/issues/2095\n */\n const toString = async () => {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '`toString` is deprecated and will be removed in next major release',\n );\n }\n\n let result = '';\n const { fileStream: instance } = await render(false); // For some reason, when rendering to string if compress=true the document is blank\n\n return new Promise((resolve, reject) => {\n try {\n instance.on('data', (buffer) => {\n result += buffer;\n });\n\n instance.on('end', () => {\n callOnRender();\n resolve(result);\n });\n } catch (error) {\n reject(error);\n }\n });\n };\n\n const on = (event, listener) => {\n if (!events[event]) events[event] = [];\n events[event].push(listener);\n };\n\n const removeListener = (event, listener) => {\n if (!events[event]) return;\n const idx = events[event].indexOf(listener);\n if (idx > -1) events[event].splice(idx, 1);\n };\n\n return {\n on,\n container,\n toBlob,\n toBuffer,\n toString,\n removeListener,\n updateContainer,\n };\n};\n\nconst Font = fontStore;\n\nconst StyleSheet = {\n create: (s) => s,\n};\n\nexport { version, Font, StyleSheet, pdf, createRenderer };\n","import fs from 'fs';\nimport { Buffer } from 'buffer';\n\nimport { pdf } from '../index';\n\n/**\n * @param {React.ReactElement} element\n * @returns {Promise}\n */\nexport const renderToStream = async (element) => {\n const instance = pdf(element);\n const stream = await instance.toBuffer();\n return stream;\n};\n\n/**\n * @param {React.ReactElement} element\n * @param {string} filePath\n * @param {Function} [callback]\n */\nexport const renderToFile = async (element, filePath, callback) => {\n const output = await renderToStream(element);\n const stream = fs.createWriteStream(filePath);\n\n output.pipe(stream);\n\n return new Promise((resolve, reject) => {\n stream.on('finish', () => {\n if (callback) callback(output, filePath);\n resolve(output);\n });\n stream.on('error', reject);\n });\n};\n\n/**\n * @param {React.ReactElement} element\n * @returns {Promise}\n */\nexport const renderToBuffer = (element) =>\n renderToStream(element).then(\n (stream) =>\n new Promise((resolve, reject) => {\n const chunks = [];\n stream.on('data', (chunk) => chunks.push(chunk));\n stream.on('end', () => resolve(Buffer.concat(chunks)));\n stream.on('error', (error) => reject(error));\n }),\n );\n\nexport const renderToString = (element) => {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '`renderToString` is deprecated and will be removed in next major release, use `renderToBuffer` instead',\n );\n }\n\n return renderToBuffer(element).then((buffer) => buffer.toString());\n};\n","import * as primitives from '@react-pdf/primitives';\n\nimport { renderToFile, renderToStream, renderToString } from './renderTo';\nimport { pdf, version, Font, StyleSheet } from '../index';\n\nconst throwEnvironmentError = (name) => {\n throw new Error(\n `${name} is a web specific API. You're either using this component on Node, or your bundler is not loading react-pdf from the appropriate web build.`,\n );\n};\n\nexport const usePDF = () => {\n throwEnvironmentError('usePDF');\n};\n\nexport const PDFViewer = () => {\n throwEnvironmentError('PDFViewer');\n};\n\nexport const PDFDownloadLink = () => {\n throwEnvironmentError('PDFDownloadLink');\n};\n\nexport const BlobProvider = () => {\n throwEnvironmentError('BlobProvider');\n};\n\nexport const render = renderToFile;\n\nexport * from '../index';\n\nexport * from './renderTo';\n\nexport * from '@react-pdf/primitives';\n\n// TODO: remove this default export in next major release because it breaks tree-shacking\nexport default {\n pdf,\n Font,\n version,\n StyleSheet,\n usePDF,\n PDFViewer,\n BlobProvider,\n PDFDownloadLink,\n renderToStream,\n renderToString,\n renderToFile,\n render,\n ...primitives,\n};\n"],"names":["omitNils","object","Object","fromEntries","entries","filter","_ref","value","undefined","createInstance","type","style","children","props","box","createTextInstance","text","appendChild","parent","child","isParentText","isChildTextInstance","isOrphanTextInstance","console","warn","push","appendChildToContainer","parentInstance","document","insertBefore","beforeChild","_parentInstance$child","index","indexOf","splice","removeChild","_parentInstance$child2","removeChildFromContainer","_parentInstance$child3","commitTextUpdate","textInstance","oldText","newText","commitUpdate","instance","updatePayload","oldProps","newProps","createRenderer","_ref2","onChange","Reconciler","resetAfterCommit","version","packageJson","fontStore","FontStore","renderer","events","pdf","initialValue","_events$change","listeners","change","slice","i","length","container","mountNode","createContainer","updateContainer","doc","callback","render","compress","pdfVersion","language","pageLayout","pageMode","title","author","subject","keywords","creator","producer","creationDate","Date","modificationDate","ownerPassword","userPassword","permissions","ctx","PDFDocument","lang","displayTitle","autoFirstPage","info","Title","Author","Subject","Keywords","Creator","Producer","CreationDate","ModificationDate","_root","data","PageMode","upperFirst","layout","layoutDocument","fileStream","renderPDF","callOnRender","params","onRender","toBlob","chunks","_INTERNAL__LAYOUT__DATA_","Promise","resolve","reject","on","chunk","Uint8Array","blob","Blob","error","toBuffer","toString","process","env","NODE_ENV","result","buffer","event","listener","removeListener","idx","Font","StyleSheet","create","s","renderToStream","element","stream","renderToFile","filePath","output","fs","createWriteStream","pipe","renderToBuffer","then","Buffer","concat","renderToString","throwEnvironmentError","name","Error","usePDF","PDFViewer","PDFDownloadLink","BlobProvider","primitives"],"mappings":";;;;;;;;;;;AAAO,MAAMA,QAAQ,GAAIC,MAAM,IAC7BC,MAAM,CAACC,WAAW,CAChBD,MAAM,CAACE,OAAO,CAACH,MAAM,CAAC,CAACI,MAAM,CAACC,IAAA,IAAA;AAAA,EAAA,IAAC,GAAGC,KAAK,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,KAAKC,SAAS;AAAA,CAAA,CAClE,CAAC;;ACDH,MAAMC,cAAc,GAAGA,CAACC,IAAI,EAAAJ,IAAA,KAAA;EAAA,IAAE;IAAEK,KAAK;IAAEC,QAAQ;IAAE,GAAGC;AAAM,GAAC,GAAAP,IAAA;EAAA,OAAM;IAC/DI,IAAI;IACJI,GAAG,EAAE,EAAE;AACPH,IAAAA,KAAK,EAAEA,KAAK,IAAI,EAAE;AAClBE,IAAAA,KAAK,EAAEA,KAAK,IAAI,EAAE;AAClBD,IAAAA,QAAQ,EAAE;GACX;AAAA,CAAC;AAEF,MAAMG,kBAAkB,GAAIC,IAAI,KAAM;AAAEN,EAAAA,IAAI,EAAE,eAAe;AAAEH,EAAAA,KAAK,EAAES;AAAK,CAAC,CAAC;AAE7E,MAAMC,WAAW,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EACrC,MAAMC,YAAY,GAChBF,MAAM,CAACR,IAAI,KAAK,MAAM,IACtBQ,MAAM,CAACR,IAAI,KAAK,MAAM,IACtBQ,MAAM,CAACR,IAAI,KAAK,OAAO,IACvBQ,MAAM,CAACR,IAAI,KAAK,MAAM;AAExB,EAAA,MAAMW,mBAAmB,GAAGF,KAAK,CAACT,IAAI,KAAK,eAAe;AAC1D,EAAA,MAAMY,oBAAoB,GAAGD,mBAAmB,IAAI,CAACD,YAAY;;AAEjE;AACA;AACA,EAAA,IAAIE,oBAAoB,EAAE;IACxBC,OAAO,CAACC,IAAI,CACT,CAAA,SAAA,EAAWL,KAAK,CAACZ,KAAM,yCAC1B,CAAC;AACD,IAAA;AACF;AAEAW,EAAAA,MAAM,CAACN,QAAQ,CAACa,IAAI,CAACN,KAAK,CAAC;AAC7B,CAAC;AAED,MAAMO,sBAAsB,GAAGA,CAACC,cAAc,EAAER,KAAK,KAAK;AACxD,EAAA,IAAIQ,cAAc,CAACjB,IAAI,KAAK,MAAM,EAAE;IAClCiB,cAAc,CAACC,QAAQ,GAAGT,KAAK;AACjC,GAAC,MAAM;AACLF,IAAAA,WAAW,CAACU,cAAc,EAAER,KAAK,CAAC;AACpC;AACF,CAAC;AAED,MAAMU,YAAY,GAAGA,CAACF,cAAc,EAAER,KAAK,EAAEW,WAAW,KAAK;AAAA,EAAA,IAAAC,qBAAA;AAC3D,EAAA,MAAMC,KAAK,GAAA,CAAAD,qBAAA,GAAGJ,cAAc,CAACf,QAAQ,MAAAmB,IAAAA,IAAAA,qBAAA,uBAAvBA,qBAAA,CAAyBE,OAAO,CAACH,WAAW,CAAC;EAE3D,IAAIE,KAAK,KAAKxB,SAAS,EAAE;AAEzB,EAAA,IAAIwB,KAAK,KAAK,EAAE,IAAIb,KAAK,EAAEQ,cAAc,CAACf,QAAQ,CAACsB,MAAM,CAACF,KAAK,EAAE,CAAC,EAAEb,KAAK,CAAC;AAC5E,CAAC;AAED,MAAMgB,WAAW,GAAGA,CAACR,cAAc,EAAER,KAAK,KAAK;AAAA,EAAA,IAAAiB,sBAAA;AAC7C,EAAA,MAAMJ,KAAK,GAAA,CAAAI,sBAAA,GAAGT,cAAc,CAACf,QAAQ,MAAAwB,IAAAA,IAAAA,sBAAA,uBAAvBA,sBAAA,CAAyBH,OAAO,CAACd,KAAK,CAAC;EAErD,IAAIa,KAAK,KAAKxB,SAAS,EAAE;AAEzB,EAAA,IAAIwB,KAAK,KAAK,EAAE,EAAEL,cAAc,CAACf,QAAQ,CAACsB,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,MAAMK,wBAAwB,GAAGA,CAACV,cAAc,EAAER,KAAK,KAAK;AAAA,EAAA,IAAAmB,sBAAA;AAC1D,EAAA,MAAMN,KAAK,GAAA,CAAAM,sBAAA,GAAGX,cAAc,CAACf,QAAQ,MAAA0B,IAAAA,IAAAA,sBAAA,uBAAvBA,sBAAA,CAAyBL,OAAO,CAACd,KAAK,CAAC;EAErD,IAAIa,KAAK,KAAKxB,SAAS,EAAE;AAEzB,EAAA,IAAIwB,KAAK,KAAK,EAAE,EAAEL,cAAc,CAACf,QAAQ,CAACsB,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,MAAMO,gBAAgB,GAAGA,CAACC,YAAY,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAC3DF,YAAY,CAACjC,KAAK,GAAGmC,OAAO;AAC9B,CAAC;AAED,MAAMC,YAAY,GAAGA,CAACC,QAAQ,EAAEC,aAAa,EAAEnC,IAAI,EAAEoC,QAAQ,EAAEC,QAAQ,KAAK;EAC1E,MAAM;IAAEpC,KAAK;IAAE,GAAGE;AAAM,GAAC,GAAGkC,QAAQ;EACpCH,QAAQ,CAAC/B,KAAK,GAAGA,KAAK;EACtB+B,QAAQ,CAACjC,KAAK,GAAGA,KAAK;AACxB,CAAC;AAEKqC,MAAAA,cAAc,GAAGC,KAAA,IAAA;EAAA,IAAC;IAAEC,QAAQ,GAAGA,MAAM;AAAG,GAAC,GAAAD,KAAA;AAAA,EAAA,OAC7CE,UAAU,CAAC;IACTlC,WAAW;IACXS,sBAAsB;IACtBa,gBAAgB;IAChBI,YAAY;IACZlC,cAAc;IACdM,kBAAkB;IAClBc,YAAY;IACZM,WAAW;IACXE,wBAAwB;AACxBe,IAAAA,gBAAgB,EAAEF;AACpB,GAAC,CAAC;AAAA;;;;;;AC9EE,MAAA;AAAEG,EAAAA;AAAQ,CAAC,GAAGC;AAEpB,MAAMC,SAAS,GAAG,IAAIC,SAAS,EAAE;;AAEjC;AACA,IAAIC,QAAQ;;AAEZ;AACA;AACA,MAAMC,MAAM,GAAG,EAAE;AAEXC,MAAAA,GAAG,GAAIC,YAAY,IAAK;EAC5B,MAAMV,QAAQ,GAAGA,MAAM;AAAA,IAAA,IAAAW,cAAA;AACrB,IAAA,MAAMC,SAAS,GAAG,CAAA,CAAAD,cAAA,GAAAH,MAAM,CAACK,MAAM,MAAAF,IAAAA,IAAAA,cAAA,uBAAbA,cAAA,CAAeG,KAAK,EAAE,KAAI,EAAE;IAC9C,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,SAAS,CAACI,MAAM,EAAED,CAAC,IAAI,CAAC,EAAEH,SAAS,CAACG,CAAC,CAAC,EAAE;GAC7D;AAED,EAAA,MAAME,SAAS,GAAG;AAAEzD,IAAAA,IAAI,EAAE,MAAM;AAAEkB,IAAAA,QAAQ,EAAE;GAAM;AAClD6B,EAAAA,QAAQ,GAAGA,QAAQ,IAAIT,cAAc,CAAC;AAAEE,IAAAA;AAAS,GAAC,CAAC;AACnD,EAAA,MAAMkB,SAAS,GAAGX,QAAQ,CAACY,eAAe,CAACF,SAAS,CAAC;AAErD,EAAA,MAAMG,eAAe,GAAGA,CAACC,GAAG,EAAEC,QAAQ,KAAK;IACzCf,QAAQ,CAACa,eAAe,CAACC,GAAG,EAAEH,SAAS,EAAE,IAAI,EAAEI,QAAQ,CAAC;GACzD;AAED,EAAA,IAAIZ,YAAY,EAAEU,eAAe,CAACV,YAAY,CAAC;AAE/C,EAAA,MAAMa,MAAM,GAAG,gBAAOC,QAAQ,EAAY;AAAA,IAAA,IAApBA,QAAQ,KAAA,MAAA,EAAA;AAARA,MAAAA,QAAQ,GAAG,IAAI;AAAA;IACnC,MAAM7D,KAAK,GAAGsD,SAAS,CAACvC,QAAQ,CAACf,KAAK,IAAI,EAAE;IAC5C,MAAM;MACJ8D,UAAU;MACVC,QAAQ;MACRC,UAAU;MACVC,QAAQ;MACRC,KAAK;MACLC,MAAM;MACNC,OAAO;MACPC,QAAQ;AACRC,MAAAA,OAAO,GAAG,WAAW;AACrBC,MAAAA,QAAQ,GAAG,WAAW;AACtBC,MAAAA,YAAY,GAAG,IAAIC,IAAI,EAAE;MACzBC,gBAAgB;MAChBC,aAAa;MACbC,YAAY;AACZC,MAAAA;AACF,KAAC,GAAG7E,KAAK;AAET,IAAA,MAAM8E,GAAG,GAAG,IAAIC,WAAW,CAAC;MAC1BlB,QAAQ;MACRC,UAAU;AACVkB,MAAAA,IAAI,EAAEjB,QAAQ;AACdkB,MAAAA,YAAY,EAAE,IAAI;AAClBC,MAAAA,aAAa,EAAE,KAAK;MACpBP,aAAa;MACbC,YAAY;MACZC,WAAW;MACXb,UAAU;MACVmB,IAAI,EAAEhG,QAAQ,CAAC;AACbiG,QAAAA,KAAK,EAAElB,KAAK;AACZmB,QAAAA,MAAM,EAAElB,MAAM;AACdmB,QAAAA,OAAO,EAAElB,OAAO;AAChBmB,QAAAA,QAAQ,EAAElB,QAAQ;AAClBmB,QAAAA,OAAO,EAAElB,OAAO;AAChBmB,QAAAA,QAAQ,EAAElB,QAAQ;AAClBmB,QAAAA,YAAY,EAAElB,YAAY;AAC1BmB,QAAAA,gBAAgB,EAAEjB;OACnB;AACH,KAAC,CAAC;AAEF,IAAA,IAAIT,QAAQ,EAAE;MACZa,GAAG,CAACc,KAAK,CAACC,IAAI,CAACC,QAAQ,GAAGC,UAAU,CAAC9B,QAAQ,CAAC;AAChD;IAEA,MAAM+B,MAAM,GAAG,MAAMC,cAAc,CAAC3C,SAAS,CAACvC,QAAQ,EAAE2B,SAAS,CAAC;AAClE,IAAA,MAAMwD,UAAU,GAAGC,SAAS,CAACrB,GAAG,EAAEkB,MAAM,CAAC;IACzC,OAAO;MAAEA,MAAM;AAAEE,MAAAA;KAAY;GAC9B;AAED,EAAA,MAAME,YAAY,GAAG,UAACC,MAAM,EAAU;AAAA,IAAA,IAAhBA,MAAM,KAAA,MAAA,EAAA;MAANA,MAAM,GAAG,EAAE;AAAA;AAC/B,IAAA,IAAI/C,SAAS,CAACvC,QAAQ,CAACf,KAAK,CAACsG,QAAQ,EAAE;MACrChD,SAAS,CAACvC,QAAQ,CAACf,KAAK,CAACsG,QAAQ,CAACD,MAAM,CAAC;AAC3C;GACD;AAED,EAAA,MAAME,MAAM,GAAG,YAAY;IACzB,MAAMC,MAAM,GAAG,EAAE;IACjB,MAAM;AAAER,MAAAA,MAAM,EAAES,wBAAwB;AAAEP,MAAAA,UAAU,EAAEnE;AAAS,KAAC,GAC9D,MAAM6B,MAAM,EAAE;AAEhB,IAAA,OAAO,IAAI8C,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;AACtC7E,MAAAA,QAAQ,CAAC8E,EAAE,CAAC,MAAM,EAAGC,KAAK,IAAK;AAC7BN,QAAAA,MAAM,CAAC5F,IAAI,CACTkG,KAAK,YAAYC,UAAU,GAAGD,KAAK,GAAG,IAAIC,UAAU,CAACD,KAAK,CAC5D,CAAC;AACH,OAAC,CAAC;AAEF/E,MAAAA,QAAQ,CAAC8E,EAAE,CAAC,KAAK,EAAE,MAAM;QACvB,IAAI;AACF,UAAA,MAAMG,IAAI,GAAG,IAAIC,IAAI,CAACT,MAAM,EAAE;AAAE3G,YAAAA,IAAI,EAAE;AAAkB,WAAC,CAAC;AAC1DuG,UAAAA,YAAY,CAAC;YAAEY,IAAI;AAAEP,YAAAA;AAAyB,WAAC,CAAC;UAChDE,OAAO,CAACK,IAAI,CAAC;SACd,CAAC,OAAOE,KAAK,EAAE;UACdN,MAAM,CAACM,KAAK,CAAC;AACf;AACF,OAAC,CAAC;AACJ,KAAC,CAAC;GACH;;AAED;AACA,EAAA,MAAMC,QAAQ,GAAG,YAAY;IAC3B,MAAM;AAAEnB,MAAAA,MAAM,EAAES,wBAAwB;AAAEP,MAAAA;AAAW,KAAC,GAAG,MAAMtC,MAAM,EAAE;AACvEwC,IAAAA,YAAY,CAAC;AAAEK,MAAAA;AAAyB,KAAC,CAAC;AAE1C,IAAA,OAAOP,UAAU;GAClB;;AAED;AACF;AACA;AACA;AACA;AACA;AACE,EAAA,MAAMkB,QAAQ,GAAG,YAAY;AAC3B,IAAA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1C7G,MAAAA,OAAO,CAACC,IAAI,CACV,oEACF,CAAC;AACH;IAEA,IAAI6G,MAAM,GAAG,EAAE;IACf,MAAM;AAAEtB,MAAAA,UAAU,EAAEnE;AAAS,KAAC,GAAG,MAAM6B,MAAM,CAAC,KAAK,CAAC,CAAC;;AAErD,IAAA,OAAO,IAAI8C,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,IAAI;AACF7E,QAAAA,QAAQ,CAAC8E,EAAE,CAAC,MAAM,EAAGY,MAAM,IAAK;AAC9BD,UAAAA,MAAM,IAAIC,MAAM;AAClB,SAAC,CAAC;AAEF1F,QAAAA,QAAQ,CAAC8E,EAAE,CAAC,KAAK,EAAE,MAAM;AACvBT,UAAAA,YAAY,EAAE;UACdO,OAAO,CAACa,MAAM,CAAC;AACjB,SAAC,CAAC;OACH,CAAC,OAAON,KAAK,EAAE;QACdN,MAAM,CAACM,KAAK,CAAC;AACf;AACF,KAAC,CAAC;GACH;AAED,EAAA,MAAML,EAAE,GAAGA,CAACa,KAAK,EAAEC,QAAQ,KAAK;IAC9B,IAAI,CAAC9E,MAAM,CAAC6E,KAAK,CAAC,EAAE7E,MAAM,CAAC6E,KAAK,CAAC,GAAG,EAAE;AACtC7E,IAAAA,MAAM,CAAC6E,KAAK,CAAC,CAAC9G,IAAI,CAAC+G,QAAQ,CAAC;GAC7B;AAED,EAAA,MAAMC,cAAc,GAAGA,CAACF,KAAK,EAAEC,QAAQ,KAAK;AAC1C,IAAA,IAAI,CAAC9E,MAAM,CAAC6E,KAAK,CAAC,EAAE;IACpB,MAAMG,GAAG,GAAGhF,MAAM,CAAC6E,KAAK,CAAC,CAACtG,OAAO,CAACuG,QAAQ,CAAC;AAC3C,IAAA,IAAIE,GAAG,GAAG,EAAE,EAAEhF,MAAM,CAAC6E,KAAK,CAAC,CAACrG,MAAM,CAACwG,GAAG,EAAE,CAAC,CAAC;GAC3C;EAED,OAAO;IACLhB,EAAE;IACFvD,SAAS;IACTiD,MAAM;IACNY,QAAQ;IACRC,QAAQ;IACRQ,cAAc;AACdnE,IAAAA;GACD;AACH;AAEMqE,MAAAA,IAAI,GAAGpF;AAEb,MAAMqF,UAAU,GAAG;EACjBC,MAAM,EAAGC,CAAC,IAAKA;AACjB;;ACnLA;AACA;AACA;AACA;AACaC,MAAAA,cAAc,GAAG,MAAOC,OAAO,IAAK;AAC/C,EAAA,MAAMpG,QAAQ,GAAGe,GAAG,CAACqF,OAAO,CAAC;AAC7B,EAAA,MAAMC,MAAM,GAAG,MAAMrG,QAAQ,CAACoF,QAAQ,EAAE;AACxC,EAAA,OAAOiB,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,GAAG,OAAOF,OAAO,EAAEG,QAAQ,EAAE3E,QAAQ,KAAK;AACjE,EAAA,MAAM4E,MAAM,GAAG,MAAML,cAAc,CAACC,OAAO,CAAC;AAC5C,EAAA,MAAMC,MAAM,GAAGI,EAAE,CAACC,iBAAiB,CAACH,QAAQ,CAAC;AAE7CC,EAAAA,MAAM,CAACG,IAAI,CAACN,MAAM,CAAC;AAEnB,EAAA,OAAO,IAAI1B,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;AACtCwB,IAAAA,MAAM,CAACvB,EAAE,CAAC,QAAQ,EAAE,MAAM;AACxB,MAAA,IAAIlD,QAAQ,EAAEA,QAAQ,CAAC4E,MAAM,EAAED,QAAQ,CAAC;MACxC3B,OAAO,CAAC4B,MAAM,CAAC;AACjB,KAAC,CAAC;AACFH,IAAAA,MAAM,CAACvB,EAAE,CAAC,OAAO,EAAED,MAAM,CAAC;AAC5B,GAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACO,MAAM+B,cAAc,GAAIR,OAAO,IACpCD,cAAc,CAACC,OAAO,CAAC,CAACS,IAAI,CACzBR,MAAM,IACL,IAAI1B,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;EAC/B,MAAMJ,MAAM,GAAG,EAAE;AACjB4B,EAAAA,MAAM,CAACvB,EAAE,CAAC,MAAM,EAAGC,KAAK,IAAKN,MAAM,CAAC5F,IAAI,CAACkG,KAAK,CAAC,CAAC;AAChDsB,EAAAA,MAAM,CAACvB,EAAE,CAAC,KAAK,EAAE,MAAMF,OAAO,CAACkC,MAAM,CAACC,MAAM,CAACtC,MAAM,CAAC,CAAC,CAAC;EACtD4B,MAAM,CAACvB,EAAE,CAAC,OAAO,EAAGK,KAAK,IAAKN,MAAM,CAACM,KAAK,CAAC,CAAC;AAC9C,CAAC,CACL;AAEW6B,MAAAA,cAAc,GAAIZ,OAAO,IAAK;AACzC,EAAA,IAAId,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1C7G,IAAAA,OAAO,CAACC,IAAI,CACV,wGACF,CAAC;AACH;AAEA,EAAA,OAAOgI,cAAc,CAACR,OAAO,CAAC,CAACS,IAAI,CAAEnB,MAAM,IAAKA,MAAM,CAACL,QAAQ,EAAE,CAAC;AACpE;;ACrDA,MAAM4B,qBAAqB,GAAIC,IAAI,IAAK;AACtC,EAAA,MAAM,IAAIC,KAAK,CACZ,CAAED,EAAAA,IAAK,8IACV,CAAC;AACH,CAAC;AAEYE,MAAAA,MAAM,GAAGA,MAAM;EAC1BH,qBAAqB,CAAC,QAAQ,CAAC;AACjC;AAEaI,MAAAA,SAAS,GAAGA,MAAM;EAC7BJ,qBAAqB,CAAC,WAAW,CAAC;AACpC;AAEaK,MAAAA,eAAe,GAAGA,MAAM;EACnCL,qBAAqB,CAAC,iBAAiB,CAAC;AAC1C;AAEaM,MAAAA,YAAY,GAAGA,MAAM;EAChCN,qBAAqB,CAAC,cAAc,CAAC;AACvC;AAEO,MAAMpF,MAAM,GAAGyE;;AAQtB;AACA,YAAe;EACbvF,GAAG;EACHgF,IAAI;EACJtF,OAAO;EACPuF,UAAU;EACVoB,MAAM;EACNC,SAAS;EACTE,YAAY;EACZD,eAAe;EACfnB,cAAc;EACda,cAAc;EACdV,YAAY;EACZzE,MAAM;EACN,GAAG2F;AACL,CAAC;;;;"} \ No newline at end of file diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.min.d.cts b/node_modules/@react-pdf/renderer/lib/react-pdf.min.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..1aa2dc8042e236867156186033b1931bf366c2d2 --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.min.d.cts @@ -0,0 +1,793 @@ +/* eslint-disable max-classes-per-file */ + +import * as React from 'react'; +import { + Style, + PageSize, + FontStore, + PDFVersion, + Orientation, + SourceObject, + SrcSet, + Sizes, + HyphenationCallback, + SVGPresentationAttributes, + Bookmark, + PageLayout, + PageMode, + HitSlop, +} from '@react-pdf/types'; + +declare class ReactPDF { + static default: typeof ReactPDF; +} + +export = ReactPDF; + +declare namespace ReactPDF { + interface Styles { + [key: string]: Style; + } + interface OnRenderProps { + blob?: Blob; + } + + interface Permissions { + printing?: 'lowResolution' | 'highResolution'; + modifying?: boolean; + copying?: boolean; + annotating?: boolean; + fillingForms?: boolean; + contentAccessibility?: boolean; + documentAssembly?: boolean; + } + + interface DocumentProps { + style?: Style | Style[]; + title?: string; + author?: string; + subject?: string; + creator?: string; + keywords?: string; + producer?: string; + language?: string; + creationDate?: Date; + modificationDate?: Date; + pdfVersion?: PDFVersion; + pageMode?: PageMode; + pageLayout?: PageLayout; + ownerPassword?: string; + userPassword?: string; + permissions?: Permissions; + onRender?: (props: OnRenderProps) => any; + } + + /** + * This component represent the PDF document itself. It must be the root + * of your tree element structure, and under no circumstances should it be + * used as children of another react-pdf component. In addition, it should + * only have childs of type . + */ + export class Document extends React.Component< + React.PropsWithChildren + > {} + + interface NodeProps { + id?: string; + style?: Style | Style[]; + /** + * Render component in all wrapped pages. + * @see https://react-pdf.org/advanced#fixed-components + */ + fixed?: boolean; + /** + * Force the wrapping algorithm to start a new page when rendering the + * element. + * @see https://react-pdf.org/advanced#page-breaks + */ + break?: boolean; + /** + * Hint that no page wrapping should occur between all sibling elements following the element within n points + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + minPresenceAhead?: number; + } + + interface PageProps extends NodeProps { + /** + * Enable page wrapping for this page. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + size?: PageSize; + orientation?: Orientation; + dpi?: number; + bookmark?: Bookmark; + } + + /** + * Represents single page inside the PDF document, or a subset of them if + * using the wrapping feature. A can contain as many pages as + * you want, but ensure not rendering a page inside any component besides + * Document. + */ + export class Page extends React.Component< + React.PropsWithChildren + > {} + + interface ViewProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + subPageNumber: number; + }) => React.ReactNode; + } + + /** + * The most fundamental component for building a UI and is designed to be + * nested inside other views and can have 0 to many children. + */ + export class View extends React.Component< + React.PropsWithChildren + > {} + + interface BaseImageProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * Works like the HTML img sizes attribute. + * @example 300 + * @example "300" + */ + sizes?: Sizes; + } + + interface ImageWithSrcProp extends BaseImageProps { + src: SourceObject; + } + + interface ImageWithSourceProp extends BaseImageProps { + source: SourceObject; + } + + type ImageProps = ImageWithSrcProp | ImageWithSourceProp; + + /** + * A React component for displaying network or local (Node only) JPG or + * PNG images, as well as base64 encoded image strings. + */ + export class Image extends React.Component {} + + interface BaseImageBackgroundProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * @example 300 + */ + sizes?: Sizes; + /** + * Style applied to the background image. + */ + imageStyle?: Style; + } + + interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps { + src: SourceObject; + } + + interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps { + source: SourceObject; + } + + type ImageBackgroundProps = + | ImageBackgroundWithSrcProp + | ImageBackgroundWithSourceProp; + + /** + * A React component for displaying an image behind child content. + * Compatible with React Native's ImageBackground component. + * @see https://reactnative.dev/docs/imagebackground + */ + export class ImageBackground extends React.Component< + React.PropsWithChildren + > {} + + interface TextProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + totalPages: number; + subPageNumber: number; + subPageTotalPages: number; + }) => React.ReactNode; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + /** + * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + orphans?: number; + /** + * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container.. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + widows?: number; + } + + interface SVGTextProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x: string | number; + y: string | number; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + } + + /** + * A React component for displaying text. Text supports nesting of other + * Text or Link components to create inline styling. + */ + export class Text extends React.Component< + React.PropsWithChildren | SVGTextProps + > {} + + interface LinkProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + href?: string; + src?: string; + /** + * Extends the clickable area of the link beyond its visible bounds. + * Accepts a number (applied to all sides) or an object with top, bottom, left, right. + * @see https://reactnative.dev/docs/view#hitslop + */ + hitSlop?: HitSlop; + } + + /** + * A React component for displaying a hyperlink. Link’s can be nested + * inside a Text component, or being inside any other valid primitive. + */ + export class Link extends React.Component< + React.PropsWithChildren + > {} + + interface FormCommonProps extends NodeProps { + name?: string; + required?: boolean; + noExport?: boolean; + readOnly?: boolean; + value?: number | string; + defaultValue?: number | string; + } + + interface FieldSetProps extends NodeProps { + name: string; + } + + export class FieldSet extends React.Component< + React.PropsWithChildren + > {} + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputFormatting { + type: + | 'date' + | 'time' + | 'percent' + | 'number' + | 'zip' + | 'zipPlus4' + | 'phone' + | 'ssn'; + param?: string; + nDec?: number; + sepComma?: boolean; + negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed'; + currency?: string; + currencyPrepend?: boolean; + } + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputProps extends FormCommonProps { + align?: 'left' | 'center' | 'right'; + multiline?: boolean; + /** + * The text will be masked (e.g. with asterisks). + */ + password?: boolean; + /** + * If set, text entered in the field is not spell-checked + */ + noSpell?: boolean; + format?: TextInputFormatting; + /** + * Sets the fontSize (default or 0 means auto sizing) + */ + fontSize?: number; + /** + * Sets the maximum length (characters) of the text in the field + */ + maxLength?: number; + } + + export class TextInput extends React.Component {} + + interface CheckboxProps extends FormCommonProps { + backgroundColor?: string; + borderColor?: string; + checked?: boolean; + onState?: string; + offState?: string; + xMark?: boolean; + } + + export class Checkbox extends React.Component {} + + interface SelectAndListPropsBase extends FormCommonProps { + sort?: boolean; + edit?: boolean; + multiSelect?: boolean; + noSpell?: boolean; + select?: string[]; + } + + type SelectAndListPropsWithEdit = SelectAndListPropsBase & { + edit: true | false; + noSpell: boolean; + }; + + type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & { + edit: boolean; + noSpell: true | false; + }; + + type SelectAndListProps = + | SelectAndListPropsWithEdit + | SelectAndListPropsWithNoSpell; + + export class Select extends React.Component {} + + export class List extends React.Component {} + + interface NoteProps extends NodeProps { + children: string; + } + + export class Note extends React.Component {} + + interface CanvasProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + paint: ( + painter: any, + availableWidth: number, + availableHeight: number, + ) => null; + } + + export class Canvas extends React.Component {} + + interface SVGProps extends NodeProps, SVGPresentationAttributes { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + width?: string | number; + height?: string | number; + viewBox?: string; + preserveAspectRatio?: string; + } + + /** + * The element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents. + */ + export class Svg extends React.Component> {} + + interface LineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x1: string | number; + x2: string | number; + y1: string | number; + y2: string | number; + } + + /** + * The element is used to create a line. + */ + export class Line extends React.Component< + React.PropsWithChildren + > {} + + interface PolylineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create any shape that consists of only straight lines (that is connected at several points). + */ + export class Polyline extends React.Component< + React.PropsWithChildren + > {} + + interface PolygonProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create a graphic that contains at least three sides. + * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up). + */ + export class Polygon extends React.Component< + React.PropsWithChildren + > {} + + interface PathProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + d: string; + } + + /** + * The element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more. + */ + export class Path extends React.Component< + React.PropsWithChildren + > {} + + interface RectProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x?: string | number; + y?: string | number; + width: string | number; + height: string | number; + rx?: string | number; + ry?: string | number; + } + + /** + * The element is used to create a rectangle and variations of a rectangle shape. + */ + export class Rect extends React.Component< + React.PropsWithChildren + > {} + + interface CircleProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + r: string | number; + } + + /** + * The element is used to create a circle. + */ + export class Circle extends React.Component< + React.PropsWithChildren + > {} + + interface EllipseProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + rx: string | number; + ry: string | number; + } + + /** + * The element is used to create an ellipse. + * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius. + */ + export class Ellipse extends React.Component< + React.PropsWithChildren + > {} + + interface TspanProps extends SVGPresentationAttributes { + x?: string | number; + y?: string | number; + } + + /** + * The element defines a subtext within a element or another element. + * It allows for adjustment of the style and/or position of that subtext as needed. + */ + export class Tspan extends React.Component< + React.PropsWithChildren + > {} + + interface GProps extends SVGPresentationAttributes { + style?: Style; + } + + /** + * The SVG element is a container used to group other SVG elements. + * Transformations applied to the element are performed on its child elements, and its attributes are inherited by its children. + */ + export class G extends React.Component> {} + + interface StopProps { + offset: string | number; + stopColor: string; + stopOpacity?: string | number; + } + + /** + * The SVG element defines a color and its position to use on a gradient. This element is always a child of a or element + */ + export class Stop extends React.Component< + React.PropsWithChildren + > {} + + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface DefsProps {} + + /** + * The element is used to store graphical objects that will be used at a later time. Objects created inside a element are not rendered directly. To display them you have to reference them + */ + export class Defs extends React.Component< + React.PropsWithChildren + > {} + + interface ClipPathProps { + id?: string; + } + + /** + * The SVG element defines a clipping path, to be used by the clipPath property. + * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn. + */ + export class ClipPath extends React.Component< + React.PropsWithChildren + > {} + + interface MarkerProps { + id: string; + viewBox?: string; + refX?: string | number; + refY?: string | number; + markerWidth?: string | number; + markerHeight?: string | number; + orient?: 'auto' | 'auto-start-reverse' | number; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; + } + + /** + * The SVG element defines a graphic used for drawing arrows or polymarkers on a given , , , or element. + * Markers can be attached to shapes using the markerStart, markerMid, and markerEnd properties. + */ + export class Marker extends React.Component< + React.PropsWithChildren + > {} + + interface LinearGradientProps { + id: string; + x1?: string | number; + x2?: string | number; + y1?: string | number; + y2?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define linear gradients that can be applied to fill or stroke of graphical elements. + */ + export class LinearGradient extends React.Component< + React.PropsWithChildren + > {} + + interface RadialGradientProps { + id: string; + cx?: string | number; + cy?: string | number; + r?: string | number; + fx?: string | number; + fy?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define radial gradients that can be applied to fill or stroke of graphical elements. + */ + export class RadialGradient extends React.Component< + React.PropsWithChildren + > {} + + interface BlobProviderParams { + blob: Blob | null; + url: string | null; + loading: boolean; + error: Error | null; + } + interface BlobProviderProps { + document: React.ReactElement; + children: (params: BlobProviderParams) => React.ReactNode; + } + + /** + * Easy and declarative way of getting document's blob data without + * showing it on screen. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class BlobProvider extends React.Component {} + + interface PDFViewerProps { + width?: number | string; + height?: number | string; + style?: Style | Style[]; + className?: string; + children?: React.ReactElement; + innerRef?: React.Ref; + showToolbar?: boolean; + } + + /** + * Iframe PDF viewer for client-side generated documents. + * @platform web + */ + export class PDFViewer extends React.Component {} + + interface PDFDownloadLinkProps + extends Omit< + React.AnchorHTMLAttributes, + 'href' | 'children' + > { + /** PDF filename. Alias for anchor tag `download` attribute. */ + fileName?: string; + document: React.ReactElement; + children?: React.ReactNode | React.FC; + onClick?: React.AnchorHTMLAttributes['onClick'] & + (( + event: React.MouseEvent, + instance: UsePDFInstance, + ) => void); + ref?: React.Ref | undefined; + } + + /** + * Anchor tag to enable generate and download PDF documents on the fly. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class PDFDownloadLink extends React.Component {} + + interface UsePDFInstance { + loading: boolean; + blob: Blob | null; + url: string | null; + error: string | null; + } + + /** + * React hook for creating and updating a PDF document instance + * @platform web + */ + export function usePDF(options?: { + document?: React.ReactElement; + }): [ + UsePDFInstance, + (newDocument: React.ReactElement) => void, + ]; + + export const Font: FontStore; + + export const StyleSheet: { + create: (styles: T) => T; + }; + + export const version: any; + + export const PDFRenderer: any; + + export const pdf: (initialValue?: React.ReactElement) => { + container: any; + isDirty: () => boolean; + toString: () => string; + toBlob: () => Promise; + toBuffer: () => Promise; + on: (event: 'change', callback: () => void) => void; + updateContainer: ( + document: React.ReactElement, + callback?: () => void, + ) => void; + removeListener: (event: 'change', callback: () => void) => void; + }; + + export const renderToStream: ( + document: React.ReactElement, + ) => Promise; + + /** + * @deprecated use the `renderToBuffer` method + */ + export const renderToString: ( + document: React.ReactElement, + ) => Promise; + + export const renderToFile: ( + document: React.ReactElement, + filePath: string, + callback?: (output: NodeJS.ReadableStream, _filePath: string) => any, + ) => Promise; + + const render: typeof renderToFile; + + /** + * Render document into a nodejs buffer + * @platform node + */ + export const renderToBuffer: ( + document: React.ReactElement, + ) => Promise; +} diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.min.d.ts b/node_modules/@react-pdf/renderer/lib/react-pdf.min.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1aa2dc8042e236867156186033b1931bf366c2d2 --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.min.d.ts @@ -0,0 +1,793 @@ +/* eslint-disable max-classes-per-file */ + +import * as React from 'react'; +import { + Style, + PageSize, + FontStore, + PDFVersion, + Orientation, + SourceObject, + SrcSet, + Sizes, + HyphenationCallback, + SVGPresentationAttributes, + Bookmark, + PageLayout, + PageMode, + HitSlop, +} from '@react-pdf/types'; + +declare class ReactPDF { + static default: typeof ReactPDF; +} + +export = ReactPDF; + +declare namespace ReactPDF { + interface Styles { + [key: string]: Style; + } + interface OnRenderProps { + blob?: Blob; + } + + interface Permissions { + printing?: 'lowResolution' | 'highResolution'; + modifying?: boolean; + copying?: boolean; + annotating?: boolean; + fillingForms?: boolean; + contentAccessibility?: boolean; + documentAssembly?: boolean; + } + + interface DocumentProps { + style?: Style | Style[]; + title?: string; + author?: string; + subject?: string; + creator?: string; + keywords?: string; + producer?: string; + language?: string; + creationDate?: Date; + modificationDate?: Date; + pdfVersion?: PDFVersion; + pageMode?: PageMode; + pageLayout?: PageLayout; + ownerPassword?: string; + userPassword?: string; + permissions?: Permissions; + onRender?: (props: OnRenderProps) => any; + } + + /** + * This component represent the PDF document itself. It must be the root + * of your tree element structure, and under no circumstances should it be + * used as children of another react-pdf component. In addition, it should + * only have childs of type . + */ + export class Document extends React.Component< + React.PropsWithChildren + > {} + + interface NodeProps { + id?: string; + style?: Style | Style[]; + /** + * Render component in all wrapped pages. + * @see https://react-pdf.org/advanced#fixed-components + */ + fixed?: boolean; + /** + * Force the wrapping algorithm to start a new page when rendering the + * element. + * @see https://react-pdf.org/advanced#page-breaks + */ + break?: boolean; + /** + * Hint that no page wrapping should occur between all sibling elements following the element within n points + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + minPresenceAhead?: number; + } + + interface PageProps extends NodeProps { + /** + * Enable page wrapping for this page. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + size?: PageSize; + orientation?: Orientation; + dpi?: number; + bookmark?: Bookmark; + } + + /** + * Represents single page inside the PDF document, or a subset of them if + * using the wrapping feature. A can contain as many pages as + * you want, but ensure not rendering a page inside any component besides + * Document. + */ + export class Page extends React.Component< + React.PropsWithChildren + > {} + + interface ViewProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + subPageNumber: number; + }) => React.ReactNode; + } + + /** + * The most fundamental component for building a UI and is designed to be + * nested inside other views and can have 0 to many children. + */ + export class View extends React.Component< + React.PropsWithChildren + > {} + + interface BaseImageProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * Works like the HTML img sizes attribute. + * @example 300 + * @example "300" + */ + sizes?: Sizes; + } + + interface ImageWithSrcProp extends BaseImageProps { + src: SourceObject; + } + + interface ImageWithSourceProp extends BaseImageProps { + source: SourceObject; + } + + type ImageProps = ImageWithSrcProp | ImageWithSourceProp; + + /** + * A React component for displaying network or local (Node only) JPG or + * PNG images, as well as base64 encoded image strings. + */ + export class Image extends React.Component {} + + interface BaseImageBackgroundProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + cache?: boolean; + /** + * A comma-separated list of image sources with width descriptors. + * Works like the HTML img srcSet attribute. + * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w" + */ + srcSet?: SrcSet; + /** + * The intended display width of the image, used to select the best source + * from srcSet. Accepts a number (in points) or a string. + * @example 300 + */ + sizes?: Sizes; + /** + * Style applied to the background image. + */ + imageStyle?: Style; + } + + interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps { + src: SourceObject; + } + + interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps { + source: SourceObject; + } + + type ImageBackgroundProps = + | ImageBackgroundWithSrcProp + | ImageBackgroundWithSourceProp; + + /** + * A React component for displaying an image behind child content. + * Compatible with React Native's ImageBackground component. + * @see https://reactnative.dev/docs/imagebackground + */ + export class ImageBackground extends React.Component< + React.PropsWithChildren + > {} + + interface TextProps extends NodeProps { + id?: string; + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + render?: (props: { + pageNumber: number; + totalPages: number; + subPageNumber: number; + subPageTotalPages: number; + }) => React.ReactNode; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + /** + * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + orphans?: number; + /** + * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container.. + * @see https://react-pdf.org/advanced#orphan-&-widow-protection + */ + widows?: number; + } + + interface SVGTextProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x: string | number; + y: string | number; + /** + * Override the default hyphenation-callback + * @see https://react-pdf.org/fonts#registerhyphenationcallback + */ + hyphenationCallback?: HyphenationCallback; + } + + /** + * A React component for displaying text. Text supports nesting of other + * Text or Link components to create inline styling. + */ + export class Text extends React.Component< + React.PropsWithChildren | SVGTextProps + > {} + + interface LinkProps extends NodeProps { + /** + * Enable/disable page wrapping for element. + * @see https://react-pdf.org/components#page-wrapping + */ + wrap?: boolean; + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + href?: string; + src?: string; + /** + * Extends the clickable area of the link beyond its visible bounds. + * Accepts a number (applied to all sides) or an object with top, bottom, left, right. + * @see https://reactnative.dev/docs/view#hitslop + */ + hitSlop?: HitSlop; + } + + /** + * A React component for displaying a hyperlink. Link’s can be nested + * inside a Text component, or being inside any other valid primitive. + */ + export class Link extends React.Component< + React.PropsWithChildren + > {} + + interface FormCommonProps extends NodeProps { + name?: string; + required?: boolean; + noExport?: boolean; + readOnly?: boolean; + value?: number | string; + defaultValue?: number | string; + } + + interface FieldSetProps extends NodeProps { + name: string; + } + + export class FieldSet extends React.Component< + React.PropsWithChildren + > {} + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputFormatting { + type: + | 'date' + | 'time' + | 'percent' + | 'number' + | 'zip' + | 'zipPlus4' + | 'phone' + | 'ssn'; + param?: string; + nDec?: number; + sepComma?: boolean; + negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed'; + currency?: string; + currencyPrepend?: boolean; + } + + // see http://pdfkit.org/docs/forms.html#text_field_formatting + interface TextInputProps extends FormCommonProps { + align?: 'left' | 'center' | 'right'; + multiline?: boolean; + /** + * The text will be masked (e.g. with asterisks). + */ + password?: boolean; + /** + * If set, text entered in the field is not spell-checked + */ + noSpell?: boolean; + format?: TextInputFormatting; + /** + * Sets the fontSize (default or 0 means auto sizing) + */ + fontSize?: number; + /** + * Sets the maximum length (characters) of the text in the field + */ + maxLength?: number; + } + + export class TextInput extends React.Component {} + + interface CheckboxProps extends FormCommonProps { + backgroundColor?: string; + borderColor?: string; + checked?: boolean; + onState?: string; + offState?: string; + xMark?: boolean; + } + + export class Checkbox extends React.Component {} + + interface SelectAndListPropsBase extends FormCommonProps { + sort?: boolean; + edit?: boolean; + multiSelect?: boolean; + noSpell?: boolean; + select?: string[]; + } + + type SelectAndListPropsWithEdit = SelectAndListPropsBase & { + edit: true | false; + noSpell: boolean; + }; + + type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & { + edit: boolean; + noSpell: true | false; + }; + + type SelectAndListProps = + | SelectAndListPropsWithEdit + | SelectAndListPropsWithNoSpell; + + export class Select extends React.Component {} + + export class List extends React.Component {} + + interface NoteProps extends NodeProps { + children: string; + } + + export class Note extends React.Component {} + + interface CanvasProps extends NodeProps { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + paint: ( + painter: any, + availableWidth: number, + availableHeight: number, + ) => null; + } + + export class Canvas extends React.Component {} + + interface SVGProps extends NodeProps, SVGPresentationAttributes { + /** + * Enables debug mode on page bounding box. + * @see https://react-pdf.org/advanced#debugging + */ + debug?: boolean; + width?: string | number; + height?: string | number; + viewBox?: string; + preserveAspectRatio?: string; + } + + /** + * The element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents. + */ + export class Svg extends React.Component> {} + + interface LineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x1: string | number; + x2: string | number; + y1: string | number; + y2: string | number; + } + + /** + * The element is used to create a line. + */ + export class Line extends React.Component< + React.PropsWithChildren + > {} + + interface PolylineProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create any shape that consists of only straight lines (that is connected at several points). + */ + export class Polyline extends React.Component< + React.PropsWithChildren + > {} + + interface PolygonProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + points: string; + } + + /** + * The element is used to create a graphic that contains at least three sides. + * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up). + */ + export class Polygon extends React.Component< + React.PropsWithChildren + > {} + + interface PathProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + d: string; + } + + /** + * The element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more. + */ + export class Path extends React.Component< + React.PropsWithChildren + > {} + + interface RectProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + x?: string | number; + y?: string | number; + width: string | number; + height: string | number; + rx?: string | number; + ry?: string | number; + } + + /** + * The element is used to create a rectangle and variations of a rectangle shape. + */ + export class Rect extends React.Component< + React.PropsWithChildren + > {} + + interface CircleProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + r: string | number; + } + + /** + * The element is used to create a circle. + */ + export class Circle extends React.Component< + React.PropsWithChildren + > {} + + interface EllipseProps extends SVGPresentationAttributes { + style?: SVGPresentationAttributes; + cx?: string | number; + cy?: string | number; + rx: string | number; + ry: string | number; + } + + /** + * The element is used to create an ellipse. + * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius. + */ + export class Ellipse extends React.Component< + React.PropsWithChildren + > {} + + interface TspanProps extends SVGPresentationAttributes { + x?: string | number; + y?: string | number; + } + + /** + * The element defines a subtext within a element or another element. + * It allows for adjustment of the style and/or position of that subtext as needed. + */ + export class Tspan extends React.Component< + React.PropsWithChildren + > {} + + interface GProps extends SVGPresentationAttributes { + style?: Style; + } + + /** + * The SVG element is a container used to group other SVG elements. + * Transformations applied to the element are performed on its child elements, and its attributes are inherited by its children. + */ + export class G extends React.Component> {} + + interface StopProps { + offset: string | number; + stopColor: string; + stopOpacity?: string | number; + } + + /** + * The SVG element defines a color and its position to use on a gradient. This element is always a child of a or element + */ + export class Stop extends React.Component< + React.PropsWithChildren + > {} + + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface DefsProps {} + + /** + * The element is used to store graphical objects that will be used at a later time. Objects created inside a element are not rendered directly. To display them you have to reference them + */ + export class Defs extends React.Component< + React.PropsWithChildren + > {} + + interface ClipPathProps { + id?: string; + } + + /** + * The SVG element defines a clipping path, to be used by the clipPath property. + * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn. + */ + export class ClipPath extends React.Component< + React.PropsWithChildren + > {} + + interface MarkerProps { + id: string; + viewBox?: string; + refX?: string | number; + refY?: string | number; + markerWidth?: string | number; + markerHeight?: string | number; + orient?: 'auto' | 'auto-start-reverse' | number; + markerUnits?: 'strokeWidth' | 'userSpaceOnUse'; + } + + /** + * The SVG element defines a graphic used for drawing arrows or polymarkers on a given , , , or element. + * Markers can be attached to shapes using the markerStart, markerMid, and markerEnd properties. + */ + export class Marker extends React.Component< + React.PropsWithChildren + > {} + + interface LinearGradientProps { + id: string; + x1?: string | number; + x2?: string | number; + y1?: string | number; + y2?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define linear gradients that can be applied to fill or stroke of graphical elements. + */ + export class LinearGradient extends React.Component< + React.PropsWithChildren + > {} + + interface RadialGradientProps { + id: string; + cx?: string | number; + cy?: string | number; + r?: string | number; + fx?: string | number; + fy?: string | number; + xlinkHref?: string; + gradientTransform?: string; + gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'; + } + + /** + * The element lets authors define radial gradients that can be applied to fill or stroke of graphical elements. + */ + export class RadialGradient extends React.Component< + React.PropsWithChildren + > {} + + interface BlobProviderParams { + blob: Blob | null; + url: string | null; + loading: boolean; + error: Error | null; + } + interface BlobProviderProps { + document: React.ReactElement; + children: (params: BlobProviderParams) => React.ReactNode; + } + + /** + * Easy and declarative way of getting document's blob data without + * showing it on screen. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class BlobProvider extends React.Component {} + + interface PDFViewerProps { + width?: number | string; + height?: number | string; + style?: Style | Style[]; + className?: string; + children?: React.ReactElement; + innerRef?: React.Ref; + showToolbar?: boolean; + } + + /** + * Iframe PDF viewer for client-side generated documents. + * @platform web + */ + export class PDFViewer extends React.Component {} + + interface PDFDownloadLinkProps + extends Omit< + React.AnchorHTMLAttributes, + 'href' | 'children' + > { + /** PDF filename. Alias for anchor tag `download` attribute. */ + fileName?: string; + document: React.ReactElement; + children?: React.ReactNode | React.FC; + onClick?: React.AnchorHTMLAttributes['onClick'] & + (( + event: React.MouseEvent, + instance: UsePDFInstance, + ) => void); + ref?: React.Ref | undefined; + } + + /** + * Anchor tag to enable generate and download PDF documents on the fly. + * @see https://react-pdf.org/advanced#on-the-fly-rendering + * @platform web + */ + export class PDFDownloadLink extends React.Component {} + + interface UsePDFInstance { + loading: boolean; + blob: Blob | null; + url: string | null; + error: string | null; + } + + /** + * React hook for creating and updating a PDF document instance + * @platform web + */ + export function usePDF(options?: { + document?: React.ReactElement; + }): [ + UsePDFInstance, + (newDocument: React.ReactElement) => void, + ]; + + export const Font: FontStore; + + export const StyleSheet: { + create: (styles: T) => T; + }; + + export const version: any; + + export const PDFRenderer: any; + + export const pdf: (initialValue?: React.ReactElement) => { + container: any; + isDirty: () => boolean; + toString: () => string; + toBlob: () => Promise; + toBuffer: () => Promise; + on: (event: 'change', callback: () => void) => void; + updateContainer: ( + document: React.ReactElement, + callback?: () => void, + ) => void; + removeListener: (event: 'change', callback: () => void) => void; + }; + + export const renderToStream: ( + document: React.ReactElement, + ) => Promise; + + /** + * @deprecated use the `renderToBuffer` method + */ + export const renderToString: ( + document: React.ReactElement, + ) => Promise; + + export const renderToFile: ( + document: React.ReactElement, + filePath: string, + callback?: (output: NodeJS.ReadableStream, _filePath: string) => any, + ) => Promise; + + const render: typeof renderToFile; + + /** + * Render document into a nodejs buffer + * @platform node + */ + export const renderToBuffer: ( + document: React.ReactElement, + ) => Promise; +} diff --git a/node_modules/@react-pdf/renderer/lib/react-pdf.min.js b/node_modules/@react-pdf/renderer/lib/react-pdf.min.js new file mode 100644 index 0000000000000000000000000000000000000000..38104fa7c1963e1819ee3e4123d8fa91e35c75b3 --- /dev/null +++ b/node_modules/@react-pdf/renderer/lib/react-pdf.min.js @@ -0,0 +1 @@ +import*as e from"@react-pdf/primitives";export*from"@react-pdf/primitives";import r from"fs";import{Buffer as t}from"buffer";import o from"@react-pdf/font";import n from"@react-pdf/render";import i from"@react-pdf/pdfkit";import a from"@react-pdf/layout";import{upperFirst as s}from"@react-pdf/fns";import d from"@react-pdf/reconciler";const c=(e,r)=>{let{style:t,children:o,...n}=r;return{type:e,box:{},style:t||{},props:n||{},children:[]}},p=e=>({type:"TEXT_INSTANCE",value:e}),l=(e,r)=>{const t="TEXT"===e.type||"LINK"===e.type||"TSPAN"===e.type||"NOTE"===e.type;"TEXT_INSTANCE"!==r.type||t?e.children.push(r):console.warn(`Invalid '${r.value}' string child outside component`)},u=(e,r)=>{"ROOT"===e.type?e.document=r:l(e,r)},f=(e,r,t)=>{var o;const n=null===(o=e.children)||void 0===o?void 0:o.indexOf(t);void 0!==n&&-1!==n&&r&&e.children.splice(n,0,r)},m=(e,r)=>{var t;const o=null===(t=e.children)||void 0===t?void 0:t.indexOf(r);void 0!==o&&-1!==o&&e.children.splice(o,1)},v=(e,r)=>{var t;const o=null===(t=e.children)||void 0===t?void 0:t.indexOf(r);void 0!==o&&-1!==o&&e.children.splice(o,1)},w=(e,r,t)=>{e.value=t},y=(e,r,t,o,n)=>{const{style:i,...a}=n;e.props=a,e.style=i},h=e=>{let{onChange:r=(()=>{})}=e;return d({appendChild:l,appendChildToContainer:u,commitTextUpdate:w,commitUpdate:y,createInstance:c,createTextInstance:p,insertBefore:f,removeChild:m,removeChildFromContainer:v,resetAfterCommit:r})};var T={version:"4.5.1"};const{version:P}=T,g=new o;let b;const D={},S=e=>{const r={type:"ROOT",document:null};b=b||h({onChange:()=>{var e;const r=(null===(e=D.change)||void 0===e?void 0:e.slice())||[];for(let e=0;e{b.updateContainer(e,t,null,r)};e&&o(e);const d=async function(e){void 0===e&&(e=!0);const t=r.document.props||{},{pdfVersion:o,language:d,pageLayout:c,pageMode:p,title:l,author:u,subject:f,keywords:m,creator:v="react-pdf",producer:w="react-pdf",creationDate:y=new Date,modificationDate:h,ownerPassword:T,userPassword:P,permissions:b}=t,D=new i({compress:e,pdfVersion:o,lang:d,displayTitle:!0,autoFirstPage:!1,ownerPassword:T,userPassword:P,permissions:b,pageLayout:c,info:(S={Title:l,Author:u,Subject:f,Keywords:m,Creator:v,Producer:w,CreationDate:y,ModificationDate:h},Object.fromEntries(Object.entries(S).filter((e=>{let[,r]=e;return void 0!==r}))))});var S;p&&(D._root.data.PageMode=s(p));const _=await a(r.document,g);return{layout:_,fileStream:n(D,_)}},c=function(e){void 0===e&&(e={}),r.document.props.onRender&&r.document.props.onRender(e)};return{on:(e,r)=>{D[e]||(D[e]=[]),D[e].push(r)},container:r,toBlob:async()=>{const e=[],{layout:r,fileStream:t}=await d();return new Promise(((o,n)=>{t.on("data",(r=>{e.push(r instanceof Uint8Array?r:new Uint8Array(r))})),t.on("end",(()=>{try{const t=new Blob(e,{type:"application/pdf"});c({blob:t,_INTERNAL__LAYOUT__DATA_:r}),o(t)}catch(e){n(e)}}))}))},toBuffer:async()=>{const{layout:e,fileStream:r}=await d();return c({_INTERNAL__LAYOUT__DATA_:e}),r},toString:async()=>{"development"===process.env.NODE_ENV&&console.warn("`toString` is deprecated and will be removed in next major release");let e="";const{fileStream:r}=await d(!1);return new Promise(((t,o)=>{try{r.on("data",(r=>{e+=r})),r.on("end",(()=>{c(),t(e)}))}catch(e){o(e)}}))},removeListener:(e,r)=>{if(!D[e])return;const t=D[e].indexOf(r);t>-1&&D[e].splice(t,1)},updateContainer:o}},_=g,A={create:e=>e},C=async e=>{const r=S(e);return await r.toBuffer()},N=async(e,t,o)=>{const n=await C(e),i=r.createWriteStream(t);return n.pipe(i),new Promise(((e,r)=>{i.on("finish",(()=>{o&&o(n,t),e(n)})),i.on("error",r)}))},O=e=>C(e).then((e=>new Promise(((r,o)=>{const n=[];e.on("data",(e=>n.push(e))),e.on("end",(()=>r(t.concat(n)))),e.on("error",(e=>o(e)))})))),E=e=>("development"===process.env.NODE_ENV&&console.warn("`renderToString` is deprecated and will be removed in next major release, use `renderToBuffer` instead"),O(e).then((e=>e.toString()))),x=e=>{throw new Error(`${e} is a web specific API. You're either using this component on Node, or your bundler is not loading react-pdf from the appropriate web build.`)},F=()=>{x("usePDF")},L=()=>{x("PDFViewer")},I=()=>{x("PDFDownloadLink")},B=()=>{x("BlobProvider")},j=N;var R={pdf:S,Font:_,version:P,StyleSheet:A,usePDF:F,PDFViewer:L,BlobProvider:B,PDFDownloadLink:I,renderToStream:C,renderToString:E,renderToFile:N,render:j,...e};export{B as BlobProvider,_ as Font,I as PDFDownloadLink,L as PDFViewer,A as StyleSheet,h as createRenderer,R as default,S as pdf,j as render,O as renderToBuffer,N as renderToFile,C as renderToStream,E as renderToString,F as usePDF,P as version}; diff --git a/node_modules/@react-pdf/renderer/package.json b/node_modules/@react-pdf/renderer/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3c663f16f18877a49d12cc6daa0820c6e6f3136a --- /dev/null +++ b/node_modules/@react-pdf/renderer/package.json @@ -0,0 +1,67 @@ +{ + "name": "@react-pdf/renderer", + "version": "4.5.1", + "license": "MIT", + "description": "Create PDF files on the browser and server", + "author": "Diego Muracciole ", + "homepage": "https://github.com/diegomura/react-pdf#readme", + "type": "module", + "main": "./lib/react-pdf.js", + "browser": { + "./lib/react-pdf.js": "./lib/react-pdf.browser.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/diegomura/react-pdf.git", + "directory": "packages/renderer" + }, + "scripts": { + "build": "rimraf ./lib && rollup -c", + "watch": "rimraf ./lib && rollup -c -w", + "size": "size-limit", + "lint": "eslint src", + "test": "vitest && vitest --config vitest.browser.config.js" + }, + "dependencies": { + "@babel/runtime": "^7.20.13", + "@react-pdf/fns": "3.1.3", + "@react-pdf/font": "^4.0.8", + "@react-pdf/layout": "^4.6.1", + "@react-pdf/pdfkit": "^5.1.1", + "@react-pdf/primitives": "^4.3.0", + "@react-pdf/reconciler": "^2.0.0", + "@react-pdf/render": "^4.5.1", + "@react-pdf/types": "^2.11.1", + "events": "^3.3.0", + "object-assign": "^4.1.1", + "prop-types": "^15.6.2", + "queue": "^6.0.1" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "lint-staged": { + "*.js": [ + "yarn lint", + "prettier --write" + ] + }, + "files": [ + "lib", + "index.d.ts" + ], + "collective": { + "type": "opencollective", + "url": "https://opencollective.com/react-pdf", + "logo": "https://opencollective.com/opencollective/logo.txt" + }, + "devDependencies": { + "@size-limit/preset-big-lib": "^11.0.1", + "assert": "^2.0.0", + "browserify-zlib": "^0.2.0", + "buffer": "^6.0.3", + "process": "^0.11.10", + "size-limit": "^11.0.1", + "util": "^0.12.4" + } +} diff --git a/node_modules/@react-pdf/stylesheet/README.md b/node_modules/@react-pdf/stylesheet/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6f817a5a70a0458be37ae2bb62dcb21bb9efc29a --- /dev/null +++ b/node_modules/@react-pdf/stylesheet/README.md @@ -0,0 +1,569 @@ +

+ +

+ +# @react-pdf/stylesheet + +Styles resolution engine for react-pdf. Transforms CSS-like style objects into normalized, resolved values ready for layout and rendering. Handles unit conversions, color parsing, shorthand expansion, media queries, and style flattening. + +## Installation + +```bash +yarn add @react-pdf/stylesheet +``` + +## Usage + +```js +import stylesheet from '@react-pdf/stylesheet'; + +const container = { + width: 400, + height: 600, + orientation: 'portrait', +}; + +const style = { + margin: 20, + width: '50vw', + height: '20vh', + borderRadius: 5, + fontWeight: 'semibold', + borderBottom: '2 solid yellow', + '@media max-width: 500': { + backgroundColor: 'rgb(255, 0, 0)', + }, +}; + +const computed = stylesheet(container, style); + +// Result: +// { +// width: 200, +// height: 120, +// marginTop: 20, +// marginLeft: 20, +// marginRight: 20, +// marginBottom: 20, +// borderTopLeftRadius: 5, +// borderTopRightRadius: 5, +// borderBottomLeftRadius: 5, +// borderBottomRightRadius: 5, +// fontWeight: 600, +// borderBottomWidth: 2, +// borderBottomStyle: 'solid', +// borderBottomColor: 'yellow', +// backgroundColor: '#FF0000' +// } +``` + +## Features + +### Style Flattening + +Merges arrays of style objects into a single object. Supports nested arrays and filters out null/undefined values. + +```js +import stylesheet, { flatten } from '@react-pdf/stylesheet'; + +const baseStyle = { margin: 10, padding: 5 }; +const activeStyle = { backgroundColor: 'blue' }; + +// Pass an array of styles +const computed = stylesheet(container, [baseStyle, activeStyle]); + +// Or use flatten directly +const merged = flatten([baseStyle, null, activeStyle, undefined]); +// => { margin: 10, padding: 5, backgroundColor: 'blue' } +``` + +### Media Queries + +Apply styles conditionally based on container dimensions and orientation. + +```js +const style = { + fontSize: 12, + '@media max-width: 500': { + fontSize: 10, + }, + '@media orientation: landscape': { + flexDirection: 'row', + }, + '@media min-width: 400 and max-width: 800': { + padding: 20, + }, +}; +``` + +Supported media features: + +- `min-width` / `max-width` +- `min-height` / `max-height` +- `orientation` (`portrait` | `landscape`) + +### Unit Conversion + +Converts various CSS units to points (the PDF standard unit). + +```js +const style = { + width: '2in', // 144pt (72pt per inch) + height: '50mm', // ~141.73pt + padding: '1cm', // ~28.35pt + margin: '10vh', // 10% of container height + fontSize: '5vw', // 5% of container width + gap: '2rem', // 36pt (default rem base: 18pt) + left: '100px', // ~100pt at 72dpi +}; +``` + +| Unit | Description | +| ----- | ------------------------------------ | +| `pt` | Points (default, 1pt = 1/72 inch) | +| `in` | Inches (1in = 72pt) | +| `mm` | Millimeters | +| `cm` | Centimeters | +| `vh` | Percentage of container height | +| `vw` | Percentage of container width | +| `rem` | Relative to rem base (default 18pt) | +| `px` | Pixels (converted using DPI setting) | + +### Color Transformation + +Normalizes color values to hexadecimal format. + +```js +import { transformColor } from '@react-pdf/stylesheet'; + +transformColor('rgb(255, 0, 0)'); // => '#FF0000' +transformColor('rgba(0, 0, 255, 0.5)'); // => '#0000FF80' +transformColor('hsl(120, 100%, 50%)'); // => '#00FF00' +transformColor('hsla(0, 100%, 50%, 0.8)'); // => '#FF0000CC' +transformColor('red'); // => 'red' (passed through) +``` + +### Shorthand Expansion + +Expands CSS shorthand properties into their individual components. + +#### Margin & Padding + +```js +// Input +{ margin: '10 20 30 40' } +// Output +{ + marginTop: 10, + marginRight: 20, + marginBottom: 30, + marginLeft: 40 +} + +// Also supports marginHorizontal/marginVertical +{ marginHorizontal: 20, marginVertical: 10 } +// Output +{ + marginTop: 10, + marginRight: 20, + marginBottom: 10, + marginLeft: 20 +} +``` + +#### Border + +```js +// Input +{ border: '2 solid red' } +// Output +{ + borderTopWidth: 2, + borderTopStyle: 'solid', + borderTopColor: 'red', + borderRightWidth: 2, + borderRightStyle: 'solid', + borderRightColor: 'red', + borderBottomWidth: 2, + borderBottomStyle: 'solid', + borderBottomColor: 'red', + borderLeftWidth: 2, + borderLeftStyle: 'solid', + borderLeftColor: 'red', +} + +// Border radius expansion +{ borderRadius: 5 } +// Output +{ + borderTopLeftRadius: 5, + borderTopRightRadius: 5, + borderBottomRightRadius: 5, + borderBottomLeftRadius: 5, +} +``` + +#### Flex + +```js +// Input +{ flex: '1 0 auto' } +// Output +{ + flexGrow: 1, + flexShrink: 0, + flexBasis: 'auto' +} + +// Single value +{ flex: 1 } +// Output +{ flexGrow: 1 } +``` + +#### Gap + +```js +// Input +{ gap: '10 20' } +// Output +{ + rowGap: 10, + columnGap: 20 +} +``` + +#### Object Position + +```js +// Input +{ objectPosition: '50% 25%' } +// Output +{ + objectPositionX: 0.5, + objectPositionY: 0.25 +} +``` + +#### Transform Origin + +```js +// Input +{ transformOrigin: 'center top' } +// Output +{ + transformOriginX: '50%', + transformOriginY: '0%' +} +``` + +### Transform Parsing + +Parses CSS transform strings into structured transform arrays. + +```js +// Input +{ + transform: 'translate(10, 20) rotate(45) scale(2)'; +} +// Output +{ + transform: [ + { operation: 'translate', value: [10, 20] }, + { operation: 'rotate', value: [45] }, + { operation: 'scale', value: [2, 2] }, + ]; +} +``` + +Supported transform functions: + +- `translate(x, y)` - Translation +- `translateX(x)` / `translateY(y)` - Single-axis translation +- `rotate(angle)` - Rotation in degrees +- `scale(x, y)` - Scaling (y defaults to x if omitted) +- `scaleX(x)` / `scaleY(y)` - Single-axis scaling +- `skew(x, y)` - Skewing in degrees +- `skewX(x)` / `skewY(y)` - Single-axis skewing +- `matrix(a, b, c, d, e, f)` - Full transformation matrix + +### Font Weight Resolution + +Converts font weight keywords to numeric values. + +| Keyword | Numeric Value | +| -------------------------- | ------------- | +| `thin`, `hairline` | 100 | +| `ultralight`, `extralight` | 200 | +| `light` | 300 | +| `normal` | 400 | +| `medium` | 500 | +| `semibold`, `demibold` | 600 | +| `bold` | 700 | +| `ultrabold`, `extrabold` | 800 | +| `heavy`, `black` | 900 | + +## API Reference + +### Default Export + +#### `stylesheet(container, style)` + +Resolves styles for a given container. + +**Parameters:** + +- `container` - Container dimensions and settings +- `style` - Style object or array of style objects + +**Returns:** Resolved style object with expanded shorthands and converted units + +### Named Exports + +#### `flatten(styles)` + +Flattens an array of style objects into a single merged object. + +```js +import { flatten } from '@react-pdf/stylesheet'; + +flatten([{ margin: 10 }, null, { padding: 5 }]); +// => { margin: 10, padding: 5 } +``` + +#### `transformColor(value)` + +Transforms RGB/HSL color strings to hexadecimal format. + +```js +import { transformColor } from '@react-pdf/stylesheet'; + +transformColor('rgb(255, 128, 0)'); // => '#FF8000' +``` + +## Types + +### Container + +```ts +type Container = { + width: number; // Container width in points + height: number; // Container height in points + dpi?: number; // DPI for px unit conversion (default: 72) + remBase?: number; // Base size for rem units (default: 18) + orientation?: 'landscape' | 'portrait'; +}; +``` + +### Style + +The input style object supporting all CSS-like properties: + +```ts +type Style = { + // Dimensions + width?: number | string; + height?: number | string; + minWidth?: number | string; + maxWidth?: number | string; + minHeight?: number | string; + maxHeight?: number | string; + + // Flexbox + flex?: number | string; + flexDirection?: 'row' | 'row-reverse' | 'column' | 'column-reverse'; + flexWrap?: 'nowrap' | 'wrap' | 'wrap-reverse'; + flexGrow?: number | string; + flexShrink?: number | string; + flexBasis?: number | string; + alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline'; + alignSelf?: + | 'auto' + | 'flex-start' + | 'flex-end' + | 'center' + | 'baseline' + | 'stretch'; + alignContent?: + | 'flex-start' + | 'flex-end' + | 'center' + | 'stretch' + | 'space-between' + | 'space-around' + | 'space-evenly'; + justifyContent?: + | 'flex-start' + | 'flex-end' + | 'center' + | 'space-around' + | 'space-between' + | 'space-evenly'; + + // Gap + gap?: number | string; + rowGap?: number | string; + columnGap?: number | string; + + // Spacing + margin?: number | string; + marginTop?: number | string; + marginRight?: number | string; + marginBottom?: number | string; + marginLeft?: number | string; + marginHorizontal?: number | string; + marginVertical?: number | string; + padding?: number | string; + paddingTop?: number | string; + paddingRight?: number | string; + paddingBottom?: number | string; + paddingLeft?: number | string; + paddingHorizontal?: number | string; + paddingVertical?: number | string; + + // Borders + border?: number | string; + borderTop?: number | string; + borderRight?: number | string; + borderBottom?: number | string; + borderLeft?: number | string; + borderWidth?: number | string; + borderStyle?: 'solid' | 'dashed' | 'dotted'; + borderColor?: string; + borderRadius?: number | string; + borderTopLeftRadius?: number | string; + borderTopRightRadius?: number | string; + borderBottomRightRadius?: number | string; + borderBottomLeftRadius?: number | string; + // ... and per-side border properties + + // Layout + display?: 'flex' | 'none'; + position?: 'absolute' | 'relative' | 'static'; + top?: number | string; + right?: number | string; + bottom?: number | string; + left?: number | string; + zIndex?: number | string; + overflow?: 'hidden'; + aspectRatio?: number | string; + + // Colors + backgroundColor?: string; + color?: string; + opacity?: number | string; + + // Text + fontFamily?: string | string[]; + fontSize?: number | string; + fontStyle?: 'normal' | 'italic' | 'oblique'; + fontWeight?: FontWeight; + letterSpacing?: number | string; + lineHeight?: number | string; + textAlign?: 'left' | 'right' | 'center' | 'justify'; + textDecoration?: + | 'none' + | 'underline' + | 'line-through' + | 'underline line-through'; + textDecorationColor?: string; + textDecorationStyle?: 'solid' | 'dashed' | 'dotted'; + textTransform?: + | 'none' + | 'capitalize' + | 'lowercase' + | 'uppercase' + | 'upperfirst'; + textOverflow?: 'ellipsis'; + maxLines?: number | string; + + // Transform + transform?: string | Transform[]; + transformOrigin?: number | string; + transformOriginX?: number | string; + transformOriginY?: number | string; + + // Object positioning (for images) + objectFit?: string; + objectPosition?: number | string; + objectPositionX?: number | string; + objectPositionY?: number | string; + + // SVG + fill?: string; + stroke?: string; + strokeWidth?: string | number; + strokeDasharray?: string; + fillOpacity?: string | number; + strokeOpacity?: string | number; + fillRule?: 'nonzero' | 'evenodd'; + textAnchor?: 'start' | 'middle' | 'end'; + strokeLinecap?: 'butt' | 'round' | 'square'; + strokeLinejoin?: 'miter' | 'round' | 'bevel'; + visibility?: 'visible' | 'hidden' | 'collapse'; + clipPath?: string; + dominantBaseline?: + | 'auto' + | 'middle' + | 'central' + | 'hanging' + | 'mathematical' + | 'text-after-edge' + | 'text-before-edge'; + + // Media queries + [key: `@media${string}`]: Style; +}; +``` + +### SafeStyle + +The resolved output style with normalized values: + +```ts +type SafeStyle = { + // All shorthand properties expanded + // All units converted to points (numbers) + // All colors normalized + // Transforms parsed into structured arrays +}; +``` + +### Transform + +```ts +type Transform = + | { operation: 'translate'; value: [number, number] } + | { operation: 'rotate'; value: [number] } + | { operation: 'scale'; value: [number, number] } + | { operation: 'skew'; value: [number, number] } + | { + operation: 'matrix'; + value: [number, number, number, number, number, number]; + }; +``` + +### FontWeight + +```ts +type FontWeight = + | number + | 'thin' + | 'hairline' + | 'ultralight' + | 'extralight' + | 'light' + | 'normal' + | 'medium' + | 'semibold' + | 'demibold' + | 'bold' + | 'ultrabold' + | 'extrabold' + | 'heavy' + | 'black'; +``` + +## License + +MIT diff --git a/node_modules/@react-pdf/stylesheet/lib/index.d.ts b/node_modules/@react-pdf/stylesheet/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd7accf6acc32282df7e6bd3dc3ebb314657ae89 --- /dev/null +++ b/node_modules/@react-pdf/stylesheet/lib/index.d.ts @@ -0,0 +1,316 @@ +type Container = { + width: number; + height: number; + dpi?: number; + remBase?: number; + orientation?: 'landscape' | 'portrait'; +}; +type Percentage = `${string}%`; +type BorderStyleValue = 'dashed' | 'dotted' | 'solid'; +type BorderShorthandStyle = { + border?: number | string; + borderTop?: number | string; + borderRight?: number | string; + borderBottom?: number | string; + borderLeft?: number | string; + borderColor?: string; + borderRadius?: number | string; + borderStyle?: BorderStyleValue; + borderWidth?: number | string; +}; +type BorderExpandedStyle = { + borderTopColor?: string; + borderTopStyle?: BorderStyleValue; + borderTopWidth?: number | string; + borderRightColor?: string; + borderRightStyle?: BorderStyleValue; + borderRightWidth?: number | string; + borderBottomColor?: string; + borderBottomStyle?: BorderStyleValue; + borderBottomWidth?: number | string; + borderLeftColor?: string; + borderLeftStyle?: BorderStyleValue; + borderLeftWidth?: number | string; + borderTopLeftRadius?: number | string; + borderTopRightRadius?: number | string; + borderBottomRightRadius?: number | string; + borderBottomLeftRadius?: number | string; +}; +type BorderSafeStyle = BorderExpandedStyle & { + borderTopWidth?: number; + borderRightWidth?: number; + borderBottomWidth?: number; + borderLeftWidth?: number; + borderTopLeftRadius?: number | Percentage; + borderTopRightRadius?: number | Percentage; + borderBottomRightRadius?: number | Percentage; + borderBottomLeftRadius?: number | Percentage; +}; +type BorderStyle = BorderShorthandStyle & BorderExpandedStyle; +type FlexboxShorthandStyle = { + flex?: number | string; +}; +type AlignContent = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'space-between' | 'space-around' | 'space-evenly'; +type AlignItems = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline'; +type AlignSelf = 'auto' | 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch'; +type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse'; +type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse'; +type JustifyContent = 'flex-start' | 'flex-end' | 'center' | 'space-around' | 'space-between' | 'space-evenly'; +type JustifySelf = string; +type FlexboxExpandedStyle = { + alignContent?: AlignContent; + alignItems?: AlignItems; + alignSelf?: AlignSelf; + flexDirection?: FlexDirection; + flexWrap?: FlexWrap; + flexFlow?: number | string; + flexGrow?: number | string; + flexShrink?: number | string; + flexBasis?: number | string; + justifySelf?: JustifySelf; + justifyContent?: JustifyContent; +}; +type FlexboxSafeStyle = FlexboxExpandedStyle & { + flexGrow?: number; + flexShrink?: number; +}; +type FlexboxStyle = FlexboxShorthandStyle & FlexboxExpandedStyle; +type GapShorthandStyle = { + gap?: number | string; +}; +type GapExpandedStyle = { + rowGap?: number | string; + columnGap?: number | string; +}; +type GapSafeStyle = { + rowGap?: number | string; + columnGap?: number | string; +}; +type GapStyle = GapShorthandStyle & GapExpandedStyle; +type PositionShorthandStyle = { + objectPosition?: number | string; +}; +type PositionExpandedStyle = { + objectPositionX?: number | string; + objectPositionY?: number | string; + objectFit?: string; +}; +type PositionSafeStyle = PositionExpandedStyle & { + objectPositionX?: number; + objectPositionY?: number; +}; +type PositioningStyle = PositionShorthandStyle & PositionExpandedStyle; +type ScaleTransform = { + operation: 'scale'; + value: [number, number]; +}; +type TranslateTransform = { + operation: 'translate'; + value: [number, number]; +}; +type RotateTransform = { + operation: 'rotate'; + value: [number, number, number]; +}; +type SkewTransform = { + operation: 'skew'; + value: [number, number]; +}; +type MatrixTransform = { + operation: 'matrix'; + value: [number, number, number, number, number, number]; +}; +type Transform = ScaleTransform | TranslateTransform | RotateTransform | SkewTransform | MatrixTransform; +type TransformShorthandStyle = { + transformOrigin?: number | string; +}; +type TransformExpandedStyle = { + transformOriginX?: number | string; + transformOriginY?: number | string; + transform?: string | Transform[]; + gradientTransform?: string | Transform[]; +}; +type TransformSafeStyle = Omit & { + transformOriginX?: number | Percentage; + transformOriginY?: number | Percentage; + transform?: Transform[]; + gradientTransform?: Transform[]; +}; +type TransformStyle = TransformShorthandStyle & TransformExpandedStyle; +type Display = 'flex' | 'none'; +type Position = 'absolute' | 'relative' | 'static'; +type LayoutStyle = { + aspectRatio?: number | string; + bottom?: number | string; + display?: Display; + left?: number | string; + position?: Position; + right?: number | string; + top?: number | string; + overflow?: 'hidden'; + zIndex?: number | string; +}; +type LayoutExpandedStyle = LayoutStyle; +type LayoutSafeStyle = LayoutExpandedStyle & { + aspectRatio?: number; + bottom?: number; + left?: number; + right?: number; + top?: number; + zIndex?: number; +}; +type DimensionStyle = { + height?: number | string; + maxHeight?: number | string; + maxWidth?: number | string; + minHeight?: number | string; + minWidth?: number | string; + width?: number | string; +}; +type DimensionExpandedStyle = DimensionStyle; +type DimensionSafeStyle = DimensionExpandedStyle & { + height?: number | Percentage; + maxHeight?: number | Percentage; + maxWidth?: number | Percentage; + minHeight?: number | Percentage; + minWidth?: number | Percentage; + width?: number | Percentage; +}; +type ColorStyle = { + backgroundColor?: string; + color?: string; + opacity?: number | string; +}; +type ColorExpandedStyle = ColorStyle; +type ColorSafeStyle = { + backgroundColor?: string; + color?: string; + opacity?: number; +}; +type FontStyle = 'normal' | 'italic' | 'oblique'; +type FontWeight = string | number | 'thin' | 'hairline' | 'ultralight' | 'extralight' | 'light' | 'normal' | 'medium' | 'semibold' | 'demibold' | 'bold' | 'ultrabold' | 'extrabold' | 'heavy' | 'black'; +type TextAlign = 'left' | 'right' | 'center' | 'justify'; +type TextDecoration = 'line-through' | 'underline' | 'none' | 'line-through underline' | 'underline line-through'; +type TextDecorationStyle = 'dashed' | 'dotted' | 'solid' | string; +type TextTransform = 'capitalize' | 'lowercase' | 'uppercase' | 'upperfirst' | 'none'; +type VerticalAlign = 'sub' | 'super'; +type TextStyle = { + direction?: 'ltr' | 'rtl'; + fontSize?: number | string; + fontFamily?: string | string[]; + fontStyle?: FontStyle; + fontWeight?: FontWeight; + letterSpacing?: number | string; + lineHeight?: number | string; + maxLines?: number | string; + textAlign?: TextAlign; + textDecoration?: TextDecoration; + textDecorationColor?: string; + textDecorationStyle?: TextDecorationStyle; + textIndent?: any; + textOverflow?: 'ellipsis'; + textTransform?: TextTransform; + verticalAlign?: VerticalAlign; +}; +type TextExpandedStyle = TextStyle; +type TextSafeStyle = TextExpandedStyle & { + fontSize?: number; + fontWeight?: number; + letterSpacing?: number; + lineHeight?: number; +}; +type MarginShorthandStyle = { + margin?: number | string; + marginHorizontal?: number | string; + marginVertical?: number | string; +}; +type MarginExpandedStyle = { + marginTop?: number | string; + marginRight?: number | string; + marginBottom?: number | string; + marginLeft?: number | string; +}; +type MarginSafeStyle = MarginExpandedStyle & { + marginTop?: number | Percentage; + marginRight?: number | Percentage; + marginBottom?: number | Percentage; + marginLeft?: number | Percentage; +}; +type MarginStyle = MarginShorthandStyle & MarginExpandedStyle; +type PaddingShorthandStyle = { + padding?: number | string; + paddingHorizontal?: number | string; + paddingVertical?: number | string; +}; +type PaddingExpandedStyle = { + paddingTop?: number | string; + paddingRight?: number | string; + paddingBottom?: number | string; + paddingLeft?: number | string; +}; +type PaddingSafeStyle = PaddingExpandedStyle & { + paddingTop?: number | Percentage; + paddingRight?: number | Percentage; + paddingBottom?: number | Percentage; + paddingLeft?: number | Percentage; +}; +type PaddingStyle = PaddingShorthandStyle & PaddingExpandedStyle; +interface SvgStyle { + fill?: string; + stroke?: string; + strokeDasharray?: string; + strokeWidth?: string | number; + fillOpacity?: string | number; + fillRule?: 'nonzero' | 'evenodd'; + strokeOpacity?: string | number; + textAnchor?: 'start' | 'middle' | 'end'; + strokeLinecap?: 'butt' | 'round' | 'square'; + strokeLinejoin?: 'butt' | 'round' | 'square' | 'miter' | 'bevel'; + visibility?: 'visible' | 'hidden' | 'collapse'; + clipPath?: string; + dominantBaseline?: 'auto' | 'middle' | 'central' | 'hanging' | 'mathematical' | 'text-after-edge' | 'text-before-edge'; +} +type SvgExpandedStyle = SvgStyle; +type SvgSafeStyle = SvgStyle & { + strokeWidth?: number; + fillOpacity?: number; + strokeOpacity?: number; +}; +type BaseStyle = BorderStyle & ColorStyle & DimensionStyle & FlexboxStyle & GapStyle & LayoutStyle & MarginStyle & PaddingStyle & PositioningStyle & TextStyle & TransformStyle & SvgStyle; +type MediaQueryStyle = { + [key in `@media${string}`]: BaseStyle; +}; +type Style = BaseStyle & MediaQueryStyle; +type StyleKey = keyof BaseStyle; +type ExpandedStyle = BorderExpandedStyle & ColorExpandedStyle & DimensionExpandedStyle & FlexboxExpandedStyle & GapExpandedStyle & LayoutExpandedStyle & MarginExpandedStyle & PaddingExpandedStyle & PositionExpandedStyle & TextExpandedStyle & TransformExpandedStyle & SvgExpandedStyle; +type SafeStyle = BorderSafeStyle & ColorSafeStyle & DimensionSafeStyle & FlexboxSafeStyle & GapSafeStyle & LayoutSafeStyle & MarginSafeStyle & PaddingSafeStyle & PositionSafeStyle & TextSafeStyle & TransformSafeStyle & SvgSafeStyle; + +/** + * Transform given color to hexa + * + * @param value - Styles value + * @returns Transformed value + */ +declare const transformColor: (value: string) => string; + +type StyleInput = Style | StyleInput[] | null | undefined; +/** + * Flattens an array of style objects, into one aggregated style object. + * Supports nested arrays of styles. + * + * @param styles - Style or style array (can be nested) + * @returns Flattened style object + */ +declare const flatten: (value: StyleInput | StyleInput[], ...args: any[]) => Style; + +type StyleParam = Style | null | undefined; +/** + * Resolves styles + * + * @param container + * @param style - Style + * @returns Resolved style + */ +declare const resolveStyles: (container: Container, style: StyleParam | StyleParam[]) => SafeStyle; + +export { type AlignContent, type AlignItems, type AlignSelf, type BorderExpandedStyle, type BorderSafeStyle, type BorderShorthandStyle, type BorderStyle, type BorderStyleValue, type ColorExpandedStyle, type ColorSafeStyle, type ColorStyle, type Container, type DimensionExpandedStyle, type DimensionSafeStyle, type DimensionStyle, type Display, type ExpandedStyle, type FlexDirection, type FlexWrap, type FlexboxExpandedStyle, type FlexboxSafeStyle, type FlexboxShorthandStyle, type FlexboxStyle, type FontStyle, type FontWeight, type GapExpandedStyle, type GapSafeStyle, type GapShorthandStyle, type GapStyle, type JustifyContent, type JustifySelf, type LayoutExpandedStyle, type LayoutSafeStyle, type LayoutStyle, type MarginExpandedStyle, type MarginSafeStyle, type MarginShorthandStyle, type MarginStyle, type MatrixTransform, type PaddingExpandedStyle, type PaddingSafeStyle, type PaddingShorthandStyle, type PaddingStyle, type Percentage, type Position, type PositionExpandedStyle, type PositionSafeStyle, type PositionShorthandStyle, type PositioningStyle, type RotateTransform, type SafeStyle, type ScaleTransform, type SkewTransform, type Style, type StyleKey, type SvgExpandedStyle, type SvgSafeStyle, type SvgStyle, type TextAlign, type TextDecoration, type TextDecorationStyle, type TextExpandedStyle, type TextSafeStyle, type TextStyle, type TextTransform, type Transform, type TransformExpandedStyle, type TransformSafeStyle, type TransformShorthandStyle, type TransformStyle, type TranslateTransform, type VerticalAlign, resolveStyles as default, flatten, transformColor }; diff --git a/node_modules/@react-pdf/stylesheet/lib/index.js b/node_modules/@react-pdf/stylesheet/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..5a18b411c09c168fb61a5fb5cc16dff977622343 --- /dev/null +++ b/node_modules/@react-pdf/stylesheet/lib/index.js @@ -0,0 +1,833 @@ +import { compose, castArray, parseFloat as parseFloat$1, matchPercent } from '@react-pdf/fns'; +import matchMedia from 'media-engine'; +import hlsToHex from 'hsl-to-hex'; +import colorString from 'color-string'; +import parse$1 from 'postcss-value-parser/lib/parse.js'; +import parseUnit from 'postcss-value-parser/lib/unit.js'; + +/** + * Remove nil values from array + * + * @param array - Style array + * @returns Style array without nils + */ +const compact = (array) => array.filter((item) => item != null); +/** + * Merges style objects array + * + * @param styles - Style array + * @returns Merged style object + */ +const mergeStyles = (styles) => styles.reduce((acc, style) => { + const s = Array.isArray(style) ? flatten(style) : style; + if (!s) + return acc; + for (const key of Object.keys(s)) { + if (s[key] != null) { + acc[key] = s[key]; + } + } + return acc; +}, {}); +/** + * Flattens an array of style objects, into one aggregated style object. + * Supports nested arrays of styles. + * + * @param styles - Style or style array (can be nested) + * @returns Flattened style object + */ +const flatten = compose(mergeStyles, compact, (castArray)); + +/** + * Resolves media queries in styles object + * + * @param container - Container for which styles are resolved + * @param style - Style description + * @returns Resolved style object + */ +const resolveMediaQueries = (container, style) => { + return Object.entries(style).reduce((acc, [key, value]) => { + if (key.startsWith('@media')) { + return { ...acc, ...matchMedia({ [key]: value }, container) }; + } + return { ...acc, [key]: value }; + }, {}); +}; + +const isRgb = (value) => /^rgba?\(/i.test(value); +const isHsl = (value) => /^hsla?\(/i.test(value); +/** + * Transform rgb color to hexa + * + * @param value - Styles value + * @returns Transformed value + */ +const parseRgb = (value) => { + const rgb = colorString.get.rgb(value); + if (!rgb) + return value; + return colorString.to.hex(rgb[0], rgb[1], rgb[2], rgb[3]); +}; +/** + * Transform Hsl color to hexa + * + * @param value - Styles value + * @returns Transformed value + */ +const parseHsl = (value) => { + const hsl = colorString.get.hsl(value); + if (!hsl) + return value; + const [h, s, l, a] = hsl; + const hex = hlsToHex(Math.round(h), Math.round(s), Math.round(l)); + // Append alpha channel if not fully opaque + if (a !== undefined && a < 1) { + const alphaHex = Math.round(a * 255) + .toString(16) + .toUpperCase() + .padStart(2, '0'); + return hex.toUpperCase() + alphaHex; + } + return hex.toUpperCase(); +}; +/** + * Transform given color to hexa + * + * @param value - Styles value + * @returns Transformed value + */ +const transformColor = (value) => { + const trimmed = value?.trim(); + if (isRgb(trimmed)) + return parseRgb(trimmed); + if (isHsl(trimmed)) + return parseHsl(trimmed); + return trimmed; +}; + +const VALUE_REGEX = /^(-?\d*\.?\d+)(in|mm|cm|pt|vh|vw|px|rem)?$/; +const DEFAULT_DPI = 72; +const DEFAULT_REM_BASE = 18; +const MM_PER_INCH = 25.4; +const CM_PER_INCH = 2.54; +/** + * Parses scalar value in value and unit pairs + * + * @param value - Scalar value + * @returns Parsed value + */ +const parseValue = (value) => { + if (typeof value === 'number') + return { value, unit: undefined }; + const match = VALUE_REGEX.exec(value); + return match + ? { value: parseFloat(match[1]), unit: (match[2] || 'pt') } + : { value, unit: undefined }; +}; +/** + * Transform given scalar value to points + * + * @param container - Container with dimensions and settings + * @param value - Styles value + * @returns Transformed value in points + */ +const transformUnit = (container, value) => { + const scalar = parseValue(value); + if (typeof scalar.value !== 'number') + return scalar.value; + const inputDpi = container.dpi || DEFAULT_DPI; + switch (scalar.unit) { + case 'rem': + return scalar.value * (container.remBase || DEFAULT_REM_BASE); + case 'in': + return scalar.value * DEFAULT_DPI; + case 'mm': + return scalar.value * (DEFAULT_DPI / MM_PER_INCH); + case 'cm': + return scalar.value * (DEFAULT_DPI / CM_PER_INCH); + case 'vh': + return scalar.value * (container.height / 100); + case 'vw': + return scalar.value * (container.width / 100); + case 'px': + return Math.round(scalar.value * (DEFAULT_DPI / inputDpi)); + default: + return scalar.value; + } +}; + +const processNumberValue = (key, value) => ({ + [key]: parseFloat$1(value), +}); +const processUnitValue = (key, value, container) => ({ + [key]: transformUnit(container, value), +}); +const processColorValue = (key, value) => { + const result = { [key]: transformColor(value) }; + return result; +}; +const processNoopValue = (key, value) => ({ + [key]: value, +}); + +// Matches border shorthand: "width style color" (e.g., "1px solid red") +const BORDER_SHORTHAND_REGEX = /^(?-?\d+(?:\.\d+)?(?:in|mm|cm|pt|vw|vh|px|rem)?)\s+(?