Scan report
devcode-it / openstamanager
Could an attacker exploit mistakes in this code?
Serious issues. Review the high-severity findings before using it.
- High
- 7
- Medium
- 50
- Low
- 33
Sources: Bandit, Semgrep, pip-audit
Does this code look like it is trying to cause harm?
Real issues worth reviewing before you rely on this code.
- High
- 19
- Medium
- 2
- Low
- 78
Sources: YARA, ClamAV, GuardDog, dependency checker
- Likely real
- 42
- Uncertain
- 44
- Likely noise
- 103
The risk classifier rates every finding for how likely it is to be a real issue. Likely noise still counts, just much less.
What we found, in plain English
This repository shows high-risk issues that could allow attackers to run code, delete files, or steal data if they are not careful. The most serious problems involve dangerous operations like base64 decoding followed by execution and downloading remote files that are then run. These findings suggest the code may be intentionally malicious rather than just having poor security habits. While some issues appear to be ordinary insecure coding patterns, others indicate a deliberate attempt to bypass security checks or execute harmful payloads. The developer should treat this code as unsafe until it is thoroughly reviewed and fixed by a qualified security expert before any production use.
Written by a local language model from the findings below. The risk scores come from the classifier, not from this summary.
Detections by engine
Score over time
Overall score each time this repository was scanned.
Findings
Highest severity first. Select a finding to see the code and what it means.
-
- Engine
- GuardDog · Supply-chain attack heuristics
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/common/libs/signature_sdk.js line 1
- Likely real
- Yes, 99% confidence
Detects destructive operations (recursive deletion, wiping) [threat-filesystem-destruction]
...Error(54)}var errCode=FS.nodePermissions(lookup.node,"x");if(errCode){throw new FS.ErrnoError(errCode)}FS.currentPath=lookup.path},createDefaultDirectories:function(){FS.mkdir("/tmp");FS.mkdir("/home");FS.mkdir("/home/web_user")},createDefaultDevice... -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /gulpfile.js line 676
- Likely real
- Yes, 97% confidence
If unverified user data can reach the `exec` method it can result in Remote Code Execution
const dumpAll = shell.exec(dumpAllCommand, { silent: true }).stdout; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /gulpfile.js line 680
- Likely real
- Yes, 97% confidence
If unverified user data can reach the `exec` method it can result in Remote Code Execution
const dumpUsersStructure = shell.exec(dumpUsersStructureCommand, { silent: true }).stdout; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /gulpfile.js line 684
- Likely real
- Yes, 97% confidence
If unverified user data can reach the `exec` method it can result in Remote Code Execution
const dumpAnagraficheStructure = shell.exec(dumpAnagraficheStructureCommand, { silent: true }).stdout; -
- Engine
- GuardDog · Supply-chain attack heuristics
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/digital-ink/workers/InkPathProvider.js line 1
- Likely real
- Yes, 91% confidence
Detects base64 decoding followed by code execution [threat-runtime-obfuscation-base64exec]
...e<OUTPUT_TYPES.length;++e){var r=OUTPUT_TYPES[e];t[r]=createOutputMethod(r)}return t},nodeWrap=function(method){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),nodeMethod=function(t){if("string"==typeof t)return crypto.cr... -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /update/2_4_48.sql line 41
- Likely real
- Uncertain, 50% confidence
JWT token detected
(NULL, 'Licenza Wacom SDK', 'eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiMzNhYWUyODA0NmM0MmE5OTgyY2E1NTdkZjhmY2YxOCIsImV4cCI6MTcwODE3ODg3NCwiaWF0IjoxNjgxNzI2MjY3LCJzZWF0cyI6MCwicmlnaHRzIjpbIkpTX0NPUkUiLCJTSUdfU0RLX0NPUkUiLCJTSUdfU0RLX0lTTyIsIlNJR19TREtfRU5DUllQVElPTiJdLCJkZXZpY2VzIjpbIldBQ09NX0FOWSJdLCJ0eXBlIjoiZXZhbCIsImxpY19uYW1lIjoiTGljZW5zZSBmb3IgSmF2YXNjcmlwdCBEZW1vIiwid2Fjb21faWQiOiJiMzNhYWUyODA0NmM0MmE5OTgyY2E1NTdkZjhmY2YxOCIsImxpY191aWQiOiI1MDU3Mzk4My05MDgzLTRjZjUtOGM5Yy0yNTMwNjc0ZWFmMmIiLCJhcHBzX3dpbmRvd3MiOltdLCJhcHBzX2lvcyI6W10sImFwcHNfYW5kcm9pZCI6W10sIm1hY2hpbmVfaWRzIjpbXX0.inGHe6CM3FexchESeu5mlPccOzrbTeZ_goMxRPppmHEqMcKz8DplC0IHOhjPvfV5c1giHsj_OctuomKWAsqt_lqo9ml4QAmnRiBYhE_itq1UdemIYusaHxapU3CL1Nr3ed9g-2Wq9Dducl-d7jCMNVnvmYM7fexIQAEV6soXBnJbdY4YXCznFftcA2jj2YI6Nz6f9ya-C9R1skQ0xuCEkkESWZ9NC_CSbu4I9h_Uv_X-0voY89H046F7wM1t61JGYMfIYwaDcJGazgD8_71OsRfOf5cUKDYsE0c-gH8vUUbbIMRO6i6zICwgEj2FAki9Rf23blPmvk8ijhBU0ZE_Hg', 'string', '1', 'Tavoletta Wacom', '1', NULL), -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /src/Util/XML.php line 107
- Likely real
- Uncertain, 43% confidence
Executing non-constant commands. This can lead to command injection.
exec('openssl smime -verify -noverify -in '.$escaped_file.' -inform DER -out '.$escaped_output, $output, $cmd); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /modules/aggiornamenti/actions.php line 151
- Likely real
- Uncertain, 43% confidence
Executing non-constant commands. This can lead to command injection.
$execution_result = executeQueries($safe_queries, $dbo); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /include/init/configuration.php line 189
- Likely real
- Uncertain, 43% confidence
Executing non-constant commands. This can lead to command injection.
shell_exec($artisan_path.' '.$artisan_cmd.' '.$key_generate_cmd); -
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.js
- Likely real
- Probably noise, 3% confidence
YARA rule matched: detect_base64_exec — Encoded payload decoded and then executed
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs
- Likely real
- Probably noise, 3% confidence
YARA rule matched: detect_base64_exec — Encoded payload decoded and then executed
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs
- Likely real
- Probably noise, 3% confidence
YARA rule matched: detect_base64_exec — Encoded payload decoded and then executed
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js
- Likely real
- Probably noise, 3% confidence
YARA rule matched: detect_base64_exec — Encoded payload decoded and then executed
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.cjs.mjs
- Likely real
- Probably noise, 3% confidence
YARA rule matched: detect_base64_exec — Encoded payload decoded and then executed
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/digital-ink/workers/SplitPointsProvider.js
- Likely real
- Probably noise, 3% confidence
YARA rule matched: detect_base64_exec — Encoded payload decoded and then executed
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.mjs
- Likely real
- Probably noise, 3% confidence
YARA rule matched: detect_base64_exec — Encoded payload decoded and then executed
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/digital-ink/workers/InkPathProvider.js
- Likely real
- Probably noise, 3% confidence
YARA rule matched: detect_base64_exec — Encoded payload decoded and then executed
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.cjs
- Likely real
- Probably noise, 3% confidence
YARA rule matched: detect_base64_exec — Encoded payload decoded and then executed
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /docker/Dockerfile.dev
- Likely real
- Probably noise, 1% confidence
YARA rule matched: detect_download_and_execute — Downloads a remote resource AND executes it - the actually dangerous combination, not just downloading alone
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs
- Likely real
- Probably noise, 1% confidence
YARA rule matched: detect_obfuscated_string_execution — Reconstructs a string character-by-character or from hex escapes, then immediately executes it - fromCharCode/chr() alone are common in ordinary text-processing code, so this requires both the reconstruction and an execution call together
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs
- Likely real
- Probably noise, 1% confidence
YARA rule matched: detect_obfuscated_string_execution — Reconstructs a string character-by-character or from hex escapes, then immediately executes it - fromCharCode/chr() alone are common in ordinary text-processing code, so this requires both the reconstruction and an execution call together
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/sigCaptDialog/stuCaptDialog.js
- Likely real
- Probably noise, 1% confidence
YARA rule matched: detect_obfuscated_string_execution — Reconstructs a string character-by-character or from hex escapes, then immediately executes it - fromCharCode/chr() alone are common in ordinary text-processing code, so this requires both the reconstruction and an execution call together
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js
- Likely real
- Probably noise, 1% confidence
YARA rule matched: detect_obfuscated_string_execution — Reconstructs a string character-by-character or from hex escapes, then immediately executes it - fromCharCode/chr() alone are common in ordinary text-processing code, so this requires both the reconstruction and an execution call together
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/common/libs/signature_sdk.js
- Likely real
- Probably noise, 1% confidence
YARA rule matched: detect_obfuscated_string_execution — Reconstructs a string character-by-character or from hex escapes, then immediately executes it - fromCharCode/chr() alone are common in ordinary text-processing code, so this requires both the reconstruction and an execution call together
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/digital-ink/workers/SplitPointsProvider.js
- Likely real
- Probably noise, 1% confidence
YARA rule matched: detect_obfuscated_string_execution — Reconstructs a string character-by-character or from hex escapes, then immediately executes it - fromCharCode/chr() alone are common in ordinary text-processing code, so this requires both the reconstruction and an execution call together
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /assets/src/js/wacom/modules/digital-ink/workers/InkPathProvider.js
- Likely real
- Probably noise, 1% confidence
YARA rule matched: detect_obfuscated_string_execution — Reconstructs a string character-by-character or from hex escapes, then immediately executes it - fromCharCode/chr() alone are common in ordinary text-processing code, so this requires both the reconstruction and an execution call together
-
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/base/supersearch.js line 82
- Likely real
- Yes, 100% confidence
RegExp() called with a `searchTerm` function argument, this might allow an attacker to cause a Regular Expression Denial-of-Service (ReDoS) within your application as RegExP blocks the main thread. For this reason, it is recommended to use hardcoded regexes instead. If your regex is run on user-controlled input, consider performing input validation or use a regex checking/sanitization library such as https://www.npmjs.com/package/recheck to verify that the regex does not appear vulnerable to ReDoS.
const regex = new RegExp(`(${searchTerm})`, 'gi'); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/functions/functions.js line 436
- Likely real
- Yes, 100% confidence
RegExp() called with a `find` function argument, this might allow an attacker to cause a Regular Expression Denial-of-Service (ReDoS) within your application as RegExP blocks the main thread. For this reason, it is recommended to use hardcoded regexes instead. If your regex is run on user-controlled input, consider performing input validation or use a regex checking/sanitization library such as https://www.npmjs.com/package/recheck to verify that the regex does not appear vulnerable to ReDoS.
return str.replace(new RegExp(find, "g"), replace); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/functions/functions.js line 336
- Likely real
- Yes, 99% confidence
User controlled data in a HTML string may result in XSS
var text = '<form action="' + href + window.location.hash + '" method="post"' + (blank ? ' target="_blank"' : '') + '>'; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/functions/functions.js line 340
- Likely real
- Yes, 99% confidence
User controlled data in a HTML string may result in XSS
text += '<input type="hidden" name="' + name + '" value="' + data[name] + '"/>'; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/functions/functions.js line 344
- Likely real
- Yes, 99% confidence
User controlled data in a HTML string may result in XSS
text += '</form>'; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.cjs line 1
- Likely real
- Yes, 99% confidence
`t.replace` method will only replace the first occurrence when used with a string argument ("["). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("js-ext");var e=require("js-md5"),t=require("long"),r=require("gl-matrix"),i=require("poly2tri"),s=require("clipper-lib"),n=require("rbush"),o=require("jszip"),a=require("protobufjs");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=h(e),c=l(t),p=h(i),u=h(s),f=l(n),m=h(o),g=h(a);class y{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let b=d?d.default||globalThis.md5:{},E={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(b.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),r=this.toBytes(e);return t[0]=c.default.fromBytes(r.slice(0,8)),t[1]=c.default.fromBytes(r.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class P{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=P.Algorithm.MD5;else if("function"==typeof this.buildURI)t=P.Algorithm.URI;else if(t=P.Algorithm.GUID,e&&!E.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=P.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==P.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return b(e)}return this.algorithm==P.Algorithm.URI?this.buildURI():E.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(P,"Algorithm",["GUID","MD5","URI"]);class I extends P{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,P.buildMD5Tokens(this.props)]}}Object.defineEnum(I,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class S{constructor(){this.phase=S.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=S.Phase.END||e==S.Phase.BEGIN)&&((this.phase!=S.Phase.BEGIN||e==S.Phase.UPDATE||e==S.Phase.END)&&((this.phase!=S.Phase.UPDATE||e==S.Phase.UPDATE||e==S.Phase.END)&&(e==S.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=S.Phase.END}}Object.defineEnum(S,"Phase",["BEGIN","UPDATE","END"]);class w{constructor(e,t,i,s){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let n=[e,t];isFinite(i)&&(n.push(i),isFinite(s)&&n.push(s)),this.value=n.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==n.length?this.vec=r.vec2:3==n.length?(this.vec=r.vec3,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=r.vec4,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),w.fromPoint(t)}addSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),w.fromPoint(t)}subtractSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),w.fromPoint(t)}multiplySelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),w.fromPoint(t)}divideSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),w.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new w(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),w.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return w.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new w(e[0],e[1],e[2],e[3]):new w(e.x,e.y,e.z,e.w)}}class x{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof x))throw new TypeError("rect must be instance of RectGL");return e?x.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof x))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=x.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return x.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return x.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=w.fromPoint({x:this.left,y:this.bottom}).transform(e),r=w.fromPoint({x:this.right,y:this.bottom}).transform(e),i=w.fromPoint({x:this.left,y:this.top}).transform(e),s=w.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return x.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let i=w.fromPoint({x:this.left,y:this.bottom}).transform(e),s=w.fromPoint({x:this.right,y:this.bottom}).transform(e),n=w.fromPoint({x:this.left,y:this.top}).transform(e),o=w.fromPoint({x:this.right,y:this.top}).transform(e);t=r.quat2.fromValues(i.x,i.y,s.x,s.y,n.x,n.y,o.x,o.y)}else t=r.quat2.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new x(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new w(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of x.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return x.ofEdges(f,g,m,y)}}Object.defineProperty(x,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class v{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?v.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=v.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return v.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return v.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=w.fromPoint({x:this.left,y:this.top}).transform(e),r=w.fromPoint({x:this.right,y:this.top}).transform(e),i=w.fromPoint({x:this.left,y:this.bottom}).transform(e),s=w.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return v.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new x(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof x))throw new TypeError("rect must be instance of RectGL");return new v(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new v(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?v.fromString(e):new v(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return v.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=x.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return v.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new v(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const R={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},T=R.m11,A=R.m12,C=R.m21,O=R.m22,D=R.m41,k=R.m42;class N{constructor(e=r.mat4.create(),t=N.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let i=function(e,t){let r=R[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[T],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[A],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[C],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[O],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[D],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[k],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[D],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[k],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:i.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:i.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:i.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:i.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:i.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:i.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:i.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:i.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:i.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:i.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new N(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(N.fromTranslate(e))}translateSelf(e){this.multiplySelf(N.fromTranslate(e))}rotate(e,t){return this.multiply(N.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(N.fromRotate(e,t))}scale(e,t){return this.multiply(N.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(N.fromScale(e,t))}multiply(e){return this.multiplicationType==N.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=r.mat4.create();return r.mat4.multiply(t,e.toFloat32Array(),this.value),new N(t,this.multiplicationType)}postMultiply(e){let t=r.mat4.create();return r.mat4.multiply(t,this.value,e.toFloat32Array()),new N(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==N.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){r.mat4.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){r.mat4.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=r.mat4.create();return r.mat4.invert(e,this.value),new N(e,this.multiplicationType)}invertSelf(){r.mat4.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return w.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let i=r.mat4.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(i[0]=parseFloat(e[0]),i[1]=parseFloat(e[1]),i[2]=parseFloat(e[2]),i[3]=parseFloat(e[3]),i[4]=parseFloat(e[4]),i[5]=parseFloat(e[5]),i[6]=parseFloat(e[6]),i[7]=parseFloat(e[7]),i[8]=parseFloat(e[8]),i[9]=parseFloat(e[9]),i[10]=parseFloat(e[10]),i[11]=parseFloat(e[11]),i[12]=parseFloat(e[12]),i[13]=parseFloat(e[13]),i[14]=parseFloat(e[14]),i[15]=parseFloat(e[15])):(i[T]=parseFloat(e[0]),i[A]=parseFloat(e[1]),i[C]=parseFloat(e[2]),i[O]=parseFloat(e[3]),i[D]=parseFloat(e[4]),i[k]=parseFloat(e[5]))}return new N(i,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof N)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new N(e,t);if("string"==typeof e)return N.fromString(e,t);let i=r.mat4.create(),s=Object.assign({},e);return isFinite(e.a)&&(s.m11=e.a),isFinite(e.b)&&(s.m12=e.b),isFinite(e.c)&&(s.m21=e.c),isFinite(e.d)&&(s.m22=e.d),isFinite(e.tx)?s.m41=e.tx:isFinite(e.e)?s.m41=e.e:isFinite(e.dx)&&(s.m41=e.dx),isFinite(e.ty)?s.m42=e.ty:isFinite(e.f)?s.m42=e.f:isFinite(e.dy)&&(s.m42=e.dy),isFinite(s.m11)&&(i[0]=s.m11),isFinite(s.m12)&&(i[1]=s.m12),isFinite(s.m13)&&(i[2]=s.m13),isFinite(s.m14)&&(i[3]=s.m14),isFinite(s.m21)&&(i[4]=s.m21),isFinite(s.m22)&&(i[5]=s.m22),isFinite(s.m23)&&(i[6]=s.m23),isFinite(s.m24)&&(i[7]=s.m24),isFinite(s.m31)&&(i[8]=s.m31),isFinite(s.m32)&&(i[9]=s.m32),isFinite(s.m33)&&(i[10]=s.m33),isFinite(s.m34)&&(i[11]=s.m34),isFinite(s.m41)&&(i[12]=s.m41),isFinite(s.m42)&&(i[13]=s.m42),isFinite(s.m43)&&(i[14]=s.m43),isFinite(s.m44)&&(i[15]=s.m44),new N(i,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return N.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),N.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),N.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=N.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=N.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return N.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let i=r.mat4.create();return r.mat4.multiply(i,e.value,t.value),new N(i)}}N.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let M={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(M.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class L{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let _={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof y))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==_.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==_.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=_.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==_.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=S.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:S.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return I.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=_.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=_.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:N.fromMatrix(i);let s=w.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=v.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=w.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(_.PointerType.MOUSE)||(this.stop(_.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(_.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new L(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},F={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof y))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==y.prototype.resize)return;let e=F.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=F.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?F.ResizeReason.ZOOM_IN:F.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=M.debounce((()=>{e==F.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?F.ResizeReason.SCREEN_SIZE_INCREASED:F.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=F.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=y.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==F.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==F.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=S.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:S.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return I.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:N.fromMatrix(i);let s=w.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=v.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=w.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==F.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?F.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new L(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(F,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(_.suppressKeys=F.suppressKeys,_.ResizeReason=F.ResizeReason,_.attachResize=F.attachResize,_.dettachResize=F.dettachResize,F=_);var B=F;class U extends w{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||U.defaults.size,this.rotation=i.rotation||U.defaults.rotation,this.scaleX=i.scaleX||U.defaults.scaleX,this.scaleY=i.scaleY||U.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||U.defaults.scaleZ:void 0,this.offsetX=i.offsetX||U.defaults.offsetX,this.offsetY=i.offsetY||U.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||U.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new U(0,0,e.includes(U.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>U.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||U.defaults.size,this.rotation=s.rotation||i.rotation||U.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||U.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||U.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||U.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||U.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||U.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||U.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case U.Property.X:return this.x;case U.Property.Y:return this.y;case U.Property.Z:return this.z;case U.Property.RED:return this.red;case U.Property.GREEN:return this.green;case U.Property.BLUE:return this.blue;case U.Property.ALPHA:return this.alpha;case U.Property.SIZE:return this.size;case U.Property.ROTATION:return this.rotation;case U.Property.SCALE_X:return this.scaleX;case U.Property.SCALE_Y:return this.scaleY;case U.Property.SCALE_Z:return this.scaleZ;case U.Property.OFFSET_X:return this.offsetX;case U.Property.OFFSET_Y:return this.offsetY;case U.Property.OFFSET_Z:return this.offsetZ;case U.Property.D_X:return this.dX;case U.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){U.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case U.Property.X:e.x=r;break;case U.Property.Y:e.y=r;break;case U.Property.Z:e.z=r;break;case U.Property.RED:e.red=r;break;case U.Property.GREEN:e.green=r;break;case U.Property.BLUE:e.blue=r;break;case U.Property.ALPHA:e.alpha=r;break;case U.Property.SIZE:e.size=r;break;case U.Property.ROTATION:e.rotation=r;break;case U.Property.SCALE_X:e.scaleX=r;break;case U.Property.SCALE_Y:e.scaleY=r;break;case U.Property.SCALE_Z:e.scaleZ=r;break;case U.Property.OFFSET_X:e.offsetX=r;break;case U.Property.OFFSET_Y:e.offsetY=r;break;case U.Property.OFFSET_Z:e.offsetZ=r;break;case U.Property.D_X:e.dX=r;break;case U.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof N))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return U.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(U,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let j,G={version:"1.5.0"};Object.defineEnum(G,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(G,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(G,"TypeGL",["WEB","STACK"]),function(e){let t,r="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof require;t="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":r?"NODE":"SHELL";let i="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",s="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(G,"commonJS",{value:r,enumerable:!0}),Object.defineProperty(G,"type",{value:G.Type[t],enumerable:!0}),Object.defineProperty(G,"type2D",{value:G.Type2D[i],enumerable:!0}),Object.defineProperty(G,"typeGL",{value:G.TypeGL[s],enumerable:!0})}(),G.commonJS&&(j=require("systeminformation"));var $=j;class Y extends P{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",P.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new Y;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=G.version,t.props["runtime.type"]=G.type.name,void 0===$)t.props["user.agent"]=navigator.userAgent;else{let e=await $.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const X={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class z{static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=z.getUnitMetric(e);return i!=z.Metric.NORMALIZED&&i!=z.Metric.LOGICAL&&(r=z[V[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*z[V[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*z[t.name][r.name]/i}static getUnitMetric(e){switch(e){case z.Unit.METER:case z.Unit.CENTIMETER:case z.Unit.MILLIMETER:case z.Unit.MICROMETER:case z.Unit.INCH:case z.Unit.DP:case z.Unit.PICA:case z.Unit.POINT:case z.Unit.DIP:case z.Unit.DPI:return z.Metric.LENGTH;case z.Unit.SECOND:case z.Unit.MILLISECOND:case z.Unit.MICROSECOND:case z.Unit.NANOSECOND:return z.Metric.TIME;case z.Unit.RADIAN:case z.Unit.DEGREE:return z.Metric.ANGLE;case z.Unit.NEWTON:return z.Metric.FORCE;case z.Unit.NORMALIZED:return z.Metric.NORMALIZED;case z.Unit.LOGICAL:return z.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case z.Metric.LENGTH:return[z.Unit.METER,z.Unit.CENTIMETER,z.Unit.MILLIMETER,z.Unit.MICROMETER,z.Unit.INCH,z.Unit.DP,z.Unit.PICA,z.Unit.POINT,z.Unit.DIP,z.Unit.DPI];case z.Metric.TIME:return[z.Unit.SECOND,z.Unit.MILLISECOND,z.Unit.MICROSECOND,z.Unit.NANOSECOND];case z.Metric.ANGLE:return[z.Unit.RADIAN,z.Unit.DEGREE];case z.Metric.FORCE:return[z.Unit.NEWTON];case z.Metric.NORMALIZED:return[z.Unit.NORMALIZED];case z.Metric.LOGICAL:return[z.Unit.LOGICAL];case z.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return V[e.name]}static convertValue(e,t,r){return e*z[t.name][r.name]}}Object.defineEnum(z,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum(z,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const V=Object.freeze({LENGTH:z.Unit.METER,TIME:z.Unit.SECOND,FORCE:z.Unit.NEWTON,ANGLE:z.Unit.RADIAN,NORMALIZED:z.Unit.NORMALIZED,LOGICAL:z.Unit.LOGICAL});!function(){let e=z.getMetricUnits(z.Metric.LENGTH).filter((e=>!(e.name in X)));for(let t of e){let e=z.Units[t.name];for(let t in X)e[t]=e.INCH*X[t]}for(let t in X){let r={};for(let i of e)r[i.name]=z.Units.INCH[i.name]/X[t];for(let e in X)r[e]=X[e]/X[t];z.Units[t]=r}for(let e in z.Units)z[e]=z.Units[e]}(),Object.freeze(z);class H extends P{constructor(e,t,r,i,s){if(super(),t==H.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=H.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=z.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==H.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return M.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(H.Type).find((t=>H.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case H.Type.X:case H.Type.Y:case H.Type.Z:case H.Type.RADIUS_X:case H.Type.RADIUS_Y:t.unit=z.Unit.DIP;break;case H.Type.TIMESTAMP:t.unit=z.Unit.MILLISECOND;break;case H.Type.PRESSURE:t.unit=z.Unit.NORMALIZED,t.min=0,t.max=1;break;case H.Type.ALTITUDE:t.unit=z.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case H.Type.AZIMUTH:t.unit=z.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case H.Type.ROTATION:t.unit=z.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=z.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new H(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=H.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=z.getChannelResolution(r.unit),s=new H(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=H.Type.X&&e!=H.Type.Y||t.type!=I.Type.MOUSE||(s.precision=0),s}}H.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),H.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},H.Metric=z.Metric;class Z extends P{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==H.Type.X||e.type==H.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new Z(e,t);return r.channels=H.defaults[t.type.name].map((e=>H.createDefaultInstance(H.Type[e],t))),r}}class q extends P{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new q;return r.addContext(Z.createDefaultInstance(e,t)),r}}class W extends P{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=q.createDefaultInstance(t,r);return new W(e,i)}}class K{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${K.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class J extends P{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=K.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=J.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(J,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class Q{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=M.getPropName(t.name),i=e[r];if(t.type==H.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==H.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=M.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==H.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class ee extends P{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",P.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof ee))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new I(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return q.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=I.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new W(this.environment,r);r.inkChannelsContext.layout=ee.getLayout(e),this.sensorData=new J(i),this.sensorData.add(new Q(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(H.Type).forEach((r=>{let i,s=H.Type[r];i=s==H.Type.ALTITUDE?"tiltX":s==H.Type.AZIMUTH?"tiltY":M.getPropName(r),ee.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===$)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await $.system(),r=await $.cpu(),i=await $.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await Y.createInstance(e),t}}let te={};if(G.type==G.Type.WEB)te.Image=globalThis.Image,te.ImageData=globalThis.ImageData,te.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(te.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},te.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(te.OffscreenCanvas=globalThis.OffscreenCanvas,te.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)te.Image=globalThis.Image,te.ImageData=globalThis.ImageData,te.OffscreenCanvas=globalThis.OffscreenCanvas,te.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(G.commonJS){const{Canvas:e,CanvasRenderingContext2D:t,Image:r,ImageData:i}=require("canvas");te.Image=r,te.ImageData=i,te.OffscreenCanvas=e,te.OffscreenCanvasRenderingContext2D=t}else console.warn(`Current env - ${G.type.name}, do not provides OffscreenCanvas support`);function re(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}te.CanvasRenderingContext2D&&(te.CanvasRenderingContext2D.prototype.clearCanvas=re),te.OffscreenCanvasRenderingContext2D&&(te.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=re);const{Image:ie,ImageData:se,OffscreenCanvas:ne,CanvasRenderingContext2D:oe,OffscreenCanvasRenderingContext2D:ae}=te;let le;class he{#r={};constructor(...e){if(le)throw new Error("URIResolver instance already available");le=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(he,"instance",{get:()=>le});class de{static encode(e,t=de.Encoding.AUTO){let r;if(t==de.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?de.Encoding.NONE:de.Encoding.ARRAY:de.Encoding.BUFFER:t==de.Encoding.ARRAY&&e instanceof Array&&(t=de.Encoding.NONE),t==de.Encoding.NONE)r=e;else if(t==de.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case de.Encoding.BUFFER:r=i.toJSON();break;case de.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=de.Encoding[e.encoding];if(r==de.Encoding.NONE)t=e.content;else if(r==de.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case de.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case de.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(de,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class ce{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||M.isValidURL(e)||ce.repetitionsCache.has(e)||(ce.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!he.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=he.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=de.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return de.isTypedArrayData(t)&&(t=de.decode(t)),new ce(e.name,t)}static getInstance(e,t){return new ce(t,e)}}class pe{constructor(e){M.isValidURL(e)||(ce.repetitionsCache.has(e)||(ce.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class ue{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=ue.defaults.CIRCLE_PRECISION,t=ue.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return ue.createEllipse(e,t,t,r)}static createEllipse(e=ue.defaults.ELLIPSE_PRECISION,t=ue.defaults.ELLIPSE_RADIUS_X,r=ue.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=ue.defaults.STAR_POINTS,t=ue.defaults.STAR_INTERNAL_RADIUS,r=ue.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let fe=p?p...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.cjs line 1
- Likely real
- Yes, 99% confidence
`t.replace("[",".").replace` method will only replace the first occurrence when used with a string argument ("]"). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("js-ext");var e=require("js-md5"),t=require("long"),r=require("gl-matrix"),i=require("poly2tri"),s=require("clipper-lib"),n=require("rbush"),o=require("jszip"),a=require("protobufjs");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=h(e),c=l(t),p=h(i),u=h(s),f=l(n),m=h(o),g=h(a);class y{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let b=d?d.default||globalThis.md5:{},E={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(b.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),r=this.toBytes(e);return t[0]=c.default.fromBytes(r.slice(0,8)),t[1]=c.default.fromBytes(r.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class P{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=P.Algorithm.MD5;else if("function"==typeof this.buildURI)t=P.Algorithm.URI;else if(t=P.Algorithm.GUID,e&&!E.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=P.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==P.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return b(e)}return this.algorithm==P.Algorithm.URI?this.buildURI():E.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(P,"Algorithm",["GUID","MD5","URI"]);class I extends P{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,P.buildMD5Tokens(this.props)]}}Object.defineEnum(I,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class S{constructor(){this.phase=S.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=S.Phase.END||e==S.Phase.BEGIN)&&((this.phase!=S.Phase.BEGIN||e==S.Phase.UPDATE||e==S.Phase.END)&&((this.phase!=S.Phase.UPDATE||e==S.Phase.UPDATE||e==S.Phase.END)&&(e==S.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=S.Phase.END}}Object.defineEnum(S,"Phase",["BEGIN","UPDATE","END"]);class w{constructor(e,t,i,s){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let n=[e,t];isFinite(i)&&(n.push(i),isFinite(s)&&n.push(s)),this.value=n.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==n.length?this.vec=r.vec2:3==n.length?(this.vec=r.vec3,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=r.vec4,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),w.fromPoint(t)}addSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),w.fromPoint(t)}subtractSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),w.fromPoint(t)}multiplySelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),w.fromPoint(t)}divideSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),w.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new w(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),w.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return w.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new w(e[0],e[1],e[2],e[3]):new w(e.x,e.y,e.z,e.w)}}class x{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof x))throw new TypeError("rect must be instance of RectGL");return e?x.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof x))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=x.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return x.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return x.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=w.fromPoint({x:this.left,y:this.bottom}).transform(e),r=w.fromPoint({x:this.right,y:this.bottom}).transform(e),i=w.fromPoint({x:this.left,y:this.top}).transform(e),s=w.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return x.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let i=w.fromPoint({x:this.left,y:this.bottom}).transform(e),s=w.fromPoint({x:this.right,y:this.bottom}).transform(e),n=w.fromPoint({x:this.left,y:this.top}).transform(e),o=w.fromPoint({x:this.right,y:this.top}).transform(e);t=r.quat2.fromValues(i.x,i.y,s.x,s.y,n.x,n.y,o.x,o.y)}else t=r.quat2.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new x(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new w(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of x.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return x.ofEdges(f,g,m,y)}}Object.defineProperty(x,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class v{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?v.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=v.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return v.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return v.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=w.fromPoint({x:this.left,y:this.top}).transform(e),r=w.fromPoint({x:this.right,y:this.top}).transform(e),i=w.fromPoint({x:this.left,y:this.bottom}).transform(e),s=w.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return v.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new x(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof x))throw new TypeError("rect must be instance of RectGL");return new v(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new v(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?v.fromString(e):new v(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return v.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=x.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return v.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new v(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const R={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},T=R.m11,A=R.m12,C=R.m21,O=R.m22,D=R.m41,k=R.m42;class N{constructor(e=r.mat4.create(),t=N.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let i=function(e,t){let r=R[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[T],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[A],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[C],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[O],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[D],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[k],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[D],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[k],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:i.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:i.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:i.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:i.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:i.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:i.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:i.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:i.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:i.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:i.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new N(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(N.fromTranslate(e))}translateSelf(e){this.multiplySelf(N.fromTranslate(e))}rotate(e,t){return this.multiply(N.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(N.fromRotate(e,t))}scale(e,t){return this.multiply(N.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(N.fromScale(e,t))}multiply(e){return this.multiplicationType==N.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=r.mat4.create();return r.mat4.multiply(t,e.toFloat32Array(),this.value),new N(t,this.multiplicationType)}postMultiply(e){let t=r.mat4.create();return r.mat4.multiply(t,this.value,e.toFloat32Array()),new N(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==N.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){r.mat4.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){r.mat4.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=r.mat4.create();return r.mat4.invert(e,this.value),new N(e,this.multiplicationType)}invertSelf(){r.mat4.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return w.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let i=r.mat4.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(i[0]=parseFloat(e[0]),i[1]=parseFloat(e[1]),i[2]=parseFloat(e[2]),i[3]=parseFloat(e[3]),i[4]=parseFloat(e[4]),i[5]=parseFloat(e[5]),i[6]=parseFloat(e[6]),i[7]=parseFloat(e[7]),i[8]=parseFloat(e[8]),i[9]=parseFloat(e[9]),i[10]=parseFloat(e[10]),i[11]=parseFloat(e[11]),i[12]=parseFloat(e[12]),i[13]=parseFloat(e[13]),i[14]=parseFloat(e[14]),i[15]=parseFloat(e[15])):(i[T]=parseFloat(e[0]),i[A]=parseFloat(e[1]),i[C]=parseFloat(e[2]),i[O]=parseFloat(e[3]),i[D]=parseFloat(e[4]),i[k]=parseFloat(e[5]))}return new N(i,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof N)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new N(e,t);if("string"==typeof e)return N.fromString(e,t);let i=r.mat4.create(),s=Object.assign({},e);return isFinite(e.a)&&(s.m11=e.a),isFinite(e.b)&&(s.m12=e.b),isFinite(e.c)&&(s.m21=e.c),isFinite(e.d)&&(s.m22=e.d),isFinite(e.tx)?s.m41=e.tx:isFinite(e.e)?s.m41=e.e:isFinite(e.dx)&&(s.m41=e.dx),isFinite(e.ty)?s.m42=e.ty:isFinite(e.f)?s.m42=e.f:isFinite(e.dy)&&(s.m42=e.dy),isFinite(s.m11)&&(i[0]=s.m11),isFinite(s.m12)&&(i[1]=s.m12),isFinite(s.m13)&&(i[2]=s.m13),isFinite(s.m14)&&(i[3]=s.m14),isFinite(s.m21)&&(i[4]=s.m21),isFinite(s.m22)&&(i[5]=s.m22),isFinite(s.m23)&&(i[6]=s.m23),isFinite(s.m24)&&(i[7]=s.m24),isFinite(s.m31)&&(i[8]=s.m31),isFinite(s.m32)&&(i[9]=s.m32),isFinite(s.m33)&&(i[10]=s.m33),isFinite(s.m34)&&(i[11]=s.m34),isFinite(s.m41)&&(i[12]=s.m41),isFinite(s.m42)&&(i[13]=s.m42),isFinite(s.m43)&&(i[14]=s.m43),isFinite(s.m44)&&(i[15]=s.m44),new N(i,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return N.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),N.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),N.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=N.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=N.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return N.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let i=r.mat4.create();return r.mat4.multiply(i,e.value,t.value),new N(i)}}N.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let M={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(M.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class L{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let _={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof y))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==_.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==_.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=_.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==_.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=S.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:S.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return I.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=_.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=_.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:N.fromMatrix(i);let s=w.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=v.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=w.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(_.PointerType.MOUSE)||(this.stop(_.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(_.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new L(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},F={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof y))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==y.prototype.resize)return;let e=F.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=F.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?F.ResizeReason.ZOOM_IN:F.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=M.debounce((()=>{e==F.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?F.ResizeReason.SCREEN_SIZE_INCREASED:F.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=F.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=y.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==F.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==F.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=S.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:S.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return I.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:N.fromMatrix(i);let s=w.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=v.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=w.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==F.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?F.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new L(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(F,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(_.suppressKeys=F.suppressKeys,_.ResizeReason=F.ResizeReason,_.attachResize=F.attachResize,_.dettachResize=F.dettachResize,F=_);var B=F;class U extends w{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||U.defaults.size,this.rotation=i.rotation||U.defaults.rotation,this.scaleX=i.scaleX||U.defaults.scaleX,this.scaleY=i.scaleY||U.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||U.defaults.scaleZ:void 0,this.offsetX=i.offsetX||U.defaults.offsetX,this.offsetY=i.offsetY||U.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||U.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new U(0,0,e.includes(U.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>U.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||U.defaults.size,this.rotation=s.rotation||i.rotation||U.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||U.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||U.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||U.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||U.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||U.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||U.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case U.Property.X:return this.x;case U.Property.Y:return this.y;case U.Property.Z:return this.z;case U.Property.RED:return this.red;case U.Property.GREEN:return this.green;case U.Property.BLUE:return this.blue;case U.Property.ALPHA:return this.alpha;case U.Property.SIZE:return this.size;case U.Property.ROTATION:return this.rotation;case U.Property.SCALE_X:return this.scaleX;case U.Property.SCALE_Y:return this.scaleY;case U.Property.SCALE_Z:return this.scaleZ;case U.Property.OFFSET_X:return this.offsetX;case U.Property.OFFSET_Y:return this.offsetY;case U.Property.OFFSET_Z:return this.offsetZ;case U.Property.D_X:return this.dX;case U.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){U.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case U.Property.X:e.x=r;break;case U.Property.Y:e.y=r;break;case U.Property.Z:e.z=r;break;case U.Property.RED:e.red=r;break;case U.Property.GREEN:e.green=r;break;case U.Property.BLUE:e.blue=r;break;case U.Property.ALPHA:e.alpha=r;break;case U.Property.SIZE:e.size=r;break;case U.Property.ROTATION:e.rotation=r;break;case U.Property.SCALE_X:e.scaleX=r;break;case U.Property.SCALE_Y:e.scaleY=r;break;case U.Property.SCALE_Z:e.scaleZ=r;break;case U.Property.OFFSET_X:e.offsetX=r;break;case U.Property.OFFSET_Y:e.offsetY=r;break;case U.Property.OFFSET_Z:e.offsetZ=r;break;case U.Property.D_X:e.dX=r;break;case U.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof N))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return U.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(U,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let j,G={version:"1.5.0"};Object.defineEnum(G,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(G,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(G,"TypeGL",["WEB","STACK"]),function(e){let t,r="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof require;t="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":r?"NODE":"SHELL";let i="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",s="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(G,"commonJS",{value:r,enumerable:!0}),Object.defineProperty(G,"type",{value:G.Type[t],enumerable:!0}),Object.defineProperty(G,"type2D",{value:G.Type2D[i],enumerable:!0}),Object.defineProperty(G,"typeGL",{value:G.TypeGL[s],enumerable:!0})}(),G.commonJS&&(j=require("systeminformation"));var $=j;class Y extends P{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",P.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new Y;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=G.version,t.props["runtime.type"]=G.type.name,void 0===$)t.props["user.agent"]=navigator.userAgent;else{let e=await $.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const X={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class z{static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=z.getUnitMetric(e);return i!=z.Metric.NORMALIZED&&i!=z.Metric.LOGICAL&&(r=z[V[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*z[V[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*z[t.name][r.name]/i}static getUnitMetric(e){switch(e){case z.Unit.METER:case z.Unit.CENTIMETER:case z.Unit.MILLIMETER:case z.Unit.MICROMETER:case z.Unit.INCH:case z.Unit.DP:case z.Unit.PICA:case z.Unit.POINT:case z.Unit.DIP:case z.Unit.DPI:return z.Metric.LENGTH;case z.Unit.SECOND:case z.Unit.MILLISECOND:case z.Unit.MICROSECOND:case z.Unit.NANOSECOND:return z.Metric.TIME;case z.Unit.RADIAN:case z.Unit.DEGREE:return z.Metric.ANGLE;case z.Unit.NEWTON:return z.Metric.FORCE;case z.Unit.NORMALIZED:return z.Metric.NORMALIZED;case z.Unit.LOGICAL:return z.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case z.Metric.LENGTH:return[z.Unit.METER,z.Unit.CENTIMETER,z.Unit.MILLIMETER,z.Unit.MICROMETER,z.Unit.INCH,z.Unit.DP,z.Unit.PICA,z.Unit.POINT,z.Unit.DIP,z.Unit.DPI];case z.Metric.TIME:return[z.Unit.SECOND,z.Unit.MILLISECOND,z.Unit.MICROSECOND,z.Unit.NANOSECOND];case z.Metric.ANGLE:return[z.Unit.RADIAN,z.Unit.DEGREE];case z.Metric.FORCE:return[z.Unit.NEWTON];case z.Metric.NORMALIZED:return[z.Unit.NORMALIZED];case z.Metric.LOGICAL:return[z.Unit.LOGICAL];case z.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return V[e.name]}static convertValue(e,t,r){return e*z[t.name][r.name]}}Object.defineEnum(z,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum(z,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const V=Object.freeze({LENGTH:z.Unit.METER,TIME:z.Unit.SECOND,FORCE:z.Unit.NEWTON,ANGLE:z.Unit.RADIAN,NORMALIZED:z.Unit.NORMALIZED,LOGICAL:z.Unit.LOGICAL});!function(){let e=z.getMetricUnits(z.Metric.LENGTH).filter((e=>!(e.name in X)));for(let t of e){let e=z.Units[t.name];for(let t in X)e[t]=e.INCH*X[t]}for(let t in X){let r={};for(let i of e)r[i.name]=z.Units.INCH[i.name]/X[t];for(let e in X)r[e]=X[e]/X[t];z.Units[t]=r}for(let e in z.Units)z[e]=z.Units[e]}(),Object.freeze(z);class H extends P{constructor(e,t,r,i,s){if(super(),t==H.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=H.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=z.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==H.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return M.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(H.Type).find((t=>H.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case H.Type.X:case H.Type.Y:case H.Type.Z:case H.Type.RADIUS_X:case H.Type.RADIUS_Y:t.unit=z.Unit.DIP;break;case H.Type.TIMESTAMP:t.unit=z.Unit.MILLISECOND;break;case H.Type.PRESSURE:t.unit=z.Unit.NORMALIZED,t.min=0,t.max=1;break;case H.Type.ALTITUDE:t.unit=z.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case H.Type.AZIMUTH:t.unit=z.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case H.Type.ROTATION:t.unit=z.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=z.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new H(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=H.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=z.getChannelResolution(r.unit),s=new H(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=H.Type.X&&e!=H.Type.Y||t.type!=I.Type.MOUSE||(s.precision=0),s}}H.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),H.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},H.Metric=z.Metric;class Z extends P{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==H.Type.X||e.type==H.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new Z(e,t);return r.channels=H.defaults[t.type.name].map((e=>H.createDefaultInstance(H.Type[e],t))),r}}class q extends P{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new q;return r.addContext(Z.createDefaultInstance(e,t)),r}}class W extends P{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=q.createDefaultInstance(t,r);return new W(e,i)}}class K{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${K.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class J extends P{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=K.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=J.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(J,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class Q{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=M.getPropName(t.name),i=e[r];if(t.type==H.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==H.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=M.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==H.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class ee extends P{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",P.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof ee))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new I(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return q.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=I.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new W(this.environment,r);r.inkChannelsContext.layout=ee.getLayout(e),this.sensorData=new J(i),this.sensorData.add(new Q(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(H.Type).forEach((r=>{let i,s=H.Type[r];i=s==H.Type.ALTITUDE?"tiltX":s==H.Type.AZIMUTH?"tiltY":M.getPropName(r),ee.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===$)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await $.system(),r=await $.cpu(),i=await $.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await Y.createInstance(e),t}}let te={};if(G.type==G.Type.WEB)te.Image=globalThis.Image,te.ImageData=globalThis.ImageData,te.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(te.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},te.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(te.OffscreenCanvas=globalThis.OffscreenCanvas,te.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)te.Image=globalThis.Image,te.ImageData=globalThis.ImageData,te.OffscreenCanvas=globalThis.OffscreenCanvas,te.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(G.commonJS){const{Canvas:e,CanvasRenderingContext2D:t,Image:r,ImageData:i}=require("canvas");te.Image=r,te.ImageData=i,te.OffscreenCanvas=e,te.OffscreenCanvasRenderingContext2D=t}else console.warn(`Current env - ${G.type.name}, do not provides OffscreenCanvas support`);function re(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}te.CanvasRenderingContext2D&&(te.CanvasRenderingContext2D.prototype.clearCanvas=re),te.OffscreenCanvasRenderingContext2D&&(te.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=re);const{Image:ie,ImageData:se,OffscreenCanvas:ne,CanvasRenderingContext2D:oe,OffscreenCanvasRenderingContext2D:ae}=te;let le;class he{#r={};constructor(...e){if(le)throw new Error("URIResolver instance already available");le=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(he,"instance",{get:()=>le});class de{static encode(e,t=de.Encoding.AUTO){let r;if(t==de.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?de.Encoding.NONE:de.Encoding.ARRAY:de.Encoding.BUFFER:t==de.Encoding.ARRAY&&e instanceof Array&&(t=de.Encoding.NONE),t==de.Encoding.NONE)r=e;else if(t==de.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case de.Encoding.BUFFER:r=i.toJSON();break;case de.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=de.Encoding[e.encoding];if(r==de.Encoding.NONE)t=e.content;else if(r==de.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case de.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case de.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(de,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class ce{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||M.isValidURL(e)||ce.repetitionsCache.has(e)||(ce.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!he.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=he.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=de.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return de.isTypedArrayData(t)&&(t=de.decode(t)),new ce(e.name,t)}static getInstance(e,t){return new ce(t,e)}}class pe{constructor(e){M.isValidURL(e)||(ce.repetitionsCache.has(e)||(ce.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class ue{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=ue.defaults.CIRCLE_PRECISION,t=ue.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return ue.createEllipse(e,t,t,r)}static createEllipse(e=ue.defaults.ELLIPSE_PRECISION,t=ue.defaults.ELLIPSE_RADIUS_X,r=ue.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=ue.defaults.STAR_POINTS,t=ue.defaults.STAR_INTERNAL_RADIUS,r=ue.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let fe=p?p...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.cjs.mjs line 1
- Likely real
- Yes, 99% confidence
`t.replace` method will only replace the first occurrence when used with a string argument ("["). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
import{createRequire as e}from"module";const t=e(import.meta.url);t.resolve.paths(".")[0];import"js-ext";import*as r from"js-md5";import i from"long";import{vec2 as s,vec3 as n,vec4 as o,quat2 as a,mat4 as l,mat2d as h}from"gl-matrix";import*as d from"poly2tri";import*as c from"clipper-lib";import p from"rbush";import*as u from"jszip";import*as f from"protobufjs";var m="1.5.0";class g{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let y=r?r.default||globalThis.md5:{},b={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(y.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),r=this.toBytes(e);return t[0]=i.fromBytes(r.slice(0,8)),t[1]=i.fromBytes(r.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class E{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=E.Algorithm.MD5;else if("function"==typeof this.buildURI)t=E.Algorithm.URI;else if(t=E.Algorithm.GUID,e&&!b.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=E.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==E.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return y(e)}return this.algorithm==E.Algorithm.URI?this.buildURI():b.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(E,"Algorithm",["GUID","MD5","URI"]);class P extends E{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,E.buildMD5Tokens(this.props)]}}Object.defineEnum(P,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class I{constructor(){this.phase=I.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=I.Phase.END||e==I.Phase.BEGIN)&&((this.phase!=I.Phase.BEGIN||e==I.Phase.UPDATE||e==I.Phase.END)&&((this.phase!=I.Phase.UPDATE||e==I.Phase.UPDATE||e==I.Phase.END)&&(e==I.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=I.Phase.END}}Object.defineEnum(I,"Phase",["BEGIN","UPDATE","END"]);class S{constructor(e,t,r,i){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let a=[e,t];isFinite(r)&&(a.push(r),isFinite(i)&&a.push(i)),this.value=a.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==a.length?this.vec=s:3==a.length?(this.vec=n,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=o,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),S.fromPoint(t)}addSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),S.fromPoint(t)}subtractSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),S.fromPoint(t)}multiplySelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),S.fromPoint(t)}divideSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),S.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new S(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),S.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return S.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new S(e[0],e[1],e[2],e[3]):new S(e.x,e.y,e.z,e.w)}}class w{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof w))throw new TypeError("rect must be instance of RectGL");return e?w.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof w))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=w.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return w.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return w.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=S.fromPoint({x:this.left,y:this.bottom}).transform(e),r=S.fromPoint({x:this.right,y:this.bottom}).transform(e),i=S.fromPoint({x:this.left,y:this.top}).transform(e),s=S.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return w.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let r=S.fromPoint({x:this.left,y:this.bottom}).transform(e),i=S.fromPoint({x:this.right,y:this.bottom}).transform(e),s=S.fromPoint({x:this.left,y:this.top}).transform(e),n=S.fromPoint({x:this.right,y:this.top}).transform(e);t=a.fromValues(r.x,r.y,i.x,i.y,s.x,s.y,n.x,n.y)}else t=a.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new w(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new S(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of w.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return w.ofEdges(f,g,m,y)}}Object.defineProperty(w,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class x{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?x.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=x.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return x.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return x.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=S.fromPoint({x:this.left,y:this.top}).transform(e),r=S.fromPoint({x:this.right,y:this.top}).transform(e),i=S.fromPoint({x:this.left,y:this.bottom}).transform(e),s=S.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return x.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new w(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof w))throw new TypeError("rect must be instance of RectGL");return new x(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new x(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?x.fromString(e):new x(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return x.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=w.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return x.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new x(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const v={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},R=v.m11,T=v.m12,A=v.m21,C=v.m22,O=v.m41,D=v.m42;class k{constructor(e=l.create(),t=k.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let r=function(e,t){let r=v[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[R],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[T],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[A],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[C],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[O],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[D],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[O],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[D],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:r.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:r.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:r.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:r.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:r.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:r.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:r.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:r.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:r.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:r.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new k(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(k.fromTranslate(e))}translateSelf(e){this.multiplySelf(k.fromTranslate(e))}rotate(e,t){return this.multiply(k.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(k.fromRotate(e,t))}scale(e,t){return this.multiply(k.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(k.fromScale(e,t))}multiply(e){return this.multiplicationType==k.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=l.create();return l.multiply(t,e.toFloat32Array(),this.value),new k(t,this.multiplicationType)}postMultiply(e){let t=l.create();return l.multiply(t,this.value,e.toFloat32Array()),new k(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==k.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){l.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){l.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=l.create();return l.invert(e,this.value),new k(e,this.multiplicationType)}invertSelf(){l.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return S.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let r=l.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(r[0]=parseFloat(e[0]),r[1]=parseFloat(e[1]),r[2]=parseFloat(e[2]),r[3]=parseFloat(e[3]),r[4]=parseFloat(e[4]),r[5]=parseFloat(e[5]),r[6]=parseFloat(e[6]),r[7]=parseFloat(e[7]),r[8]=parseFloat(e[8]),r[9]=parseFloat(e[9]),r[10]=parseFloat(e[10]),r[11]=parseFloat(e[11]),r[12]=parseFloat(e[12]),r[13]=parseFloat(e[13]),r[14]=parseFloat(e[14]),r[15]=parseFloat(e[15])):(r[R]=parseFloat(e[0]),r[T]=parseFloat(e[1]),r[A]=parseFloat(e[2]),r[C]=parseFloat(e[3]),r[O]=parseFloat(e[4]),r[D]=parseFloat(e[5]))}return new k(r,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof k)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new k(e,t);if("string"==typeof e)return k.fromString(e,t);let r=l.create(),i=Object.assign({},e);return isFinite(e.a)&&(i.m11=e.a),isFinite(e.b)&&(i.m12=e.b),isFinite(e.c)&&(i.m21=e.c),isFinite(e.d)&&(i.m22=e.d),isFinite(e.tx)?i.m41=e.tx:isFinite(e.e)?i.m41=e.e:isFinite(e.dx)&&(i.m41=e.dx),isFinite(e.ty)?i.m42=e.ty:isFinite(e.f)?i.m42=e.f:isFinite(e.dy)&&(i.m42=e.dy),isFinite(i.m11)&&(r[0]=i.m11),isFinite(i.m12)&&(r[1]=i.m12),isFinite(i.m13)&&(r[2]=i.m13),isFinite(i.m14)&&(r[3]=i.m14),isFinite(i.m21)&&(r[4]=i.m21),isFinite(i.m22)&&(r[5]=i.m22),isFinite(i.m23)&&(r[6]=i.m23),isFinite(i.m24)&&(r[7]=i.m24),isFinite(i.m31)&&(r[8]=i.m31),isFinite(i.m32)&&(r[9]=i.m32),isFinite(i.m33)&&(r[10]=i.m33),isFinite(i.m34)&&(r[11]=i.m34),isFinite(i.m41)&&(r[12]=i.m41),isFinite(i.m42)&&(r[13]=i.m42),isFinite(i.m43)&&(r[14]=i.m43),isFinite(i.m44)&&(r[15]=i.m44),new k(r,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return k.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),k.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),k.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=k.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=k.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return k.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let r=l.create();return l.multiply(r,e.value,t.value),new k(r)}}k.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let N={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(N.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class M{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let L={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof g))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==L.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==L.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=L.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==L.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=I.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:I.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return P.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=L.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=L.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:k.fromMatrix(i);let s=S.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=x.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=S.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(L.PointerType.MOUSE)||(this.stop(L.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(L.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new M(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},_={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof g))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==g.prototype.resize)return;let e=_.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=_.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?_.ResizeReason.ZOOM_IN:_.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=N.debounce((()=>{e==_.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?_.ResizeReason.SCREEN_SIZE_INCREASED:_.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=_.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=g.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==_.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==_.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=I.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:I.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return P.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:k.fromMatrix(i);let s=S.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=x.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=S.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==_.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?_.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new M(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(_,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(L.suppressKeys=_.suppressKeys,L.ResizeReason=_.ResizeReason,L.attachResize=_.attachResize,L.dettachResize=_.dettachResize,_=L);var F=_;class B extends S{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||B.defaults.size,this.rotation=i.rotation||B.defaults.rotation,this.scaleX=i.scaleX||B.defaults.scaleX,this.scaleY=i.scaleY||B.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||B.defaults.scaleZ:void 0,this.offsetX=i.offsetX||B.defaults.offsetX,this.offsetY=i.offsetY||B.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||B.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new B(0,0,e.includes(B.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>B.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||B.defaults.size,this.rotation=s.rotation||i.rotation||B.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||B.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||B.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||B.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||B.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||B.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||B.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case B.Property.X:return this.x;case B.Property.Y:return this.y;case B.Property.Z:return this.z;case B.Property.RED:return this.red;case B.Property.GREEN:return this.green;case B.Property.BLUE:return this.blue;case B.Property.ALPHA:return this.alpha;case B.Property.SIZE:return this.size;case B.Property.ROTATION:return this.rotation;case B.Property.SCALE_X:return this.scaleX;case B.Property.SCALE_Y:return this.scaleY;case B.Property.SCALE_Z:return this.scaleZ;case B.Property.OFFSET_X:return this.offsetX;case B.Property.OFFSET_Y:return this.offsetY;case B.Property.OFFSET_Z:return this.offsetZ;case B.Property.D_X:return this.dX;case B.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){B.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case B.Property.X:e.x=r;break;case B.Property.Y:e.y=r;break;case B.Property.Z:e.z=r;break;case B.Property.RED:e.red=r;break;case B.Property.GREEN:e.green=r;break;case B.Property.BLUE:e.blue=r;break;case B.Property.ALPHA:e.alpha=r;break;case B.Property.SIZE:e.size=r;break;case B.Property.ROTATION:e.rotation=r;break;case B.Property.SCALE_X:e.scaleX=r;break;case B.Property.SCALE_Y:e.scaleY=r;break;case B.Property.SCALE_Z:e.scaleZ=r;break;case B.Property.OFFSET_X:e.offsetX=r;break;case B.Property.OFFSET_Y:e.offsetY=r;break;case B.Property.OFFSET_Z:e.offsetZ=r;break;case B.Property.D_X:e.dX=r;break;case B.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof k))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return B.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(B,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let U,j={version:"1.5.0"};Object.defineEnum(j,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(j,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(j,"TypeGL",["WEB","STACK"]),function(e){let r,i="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof t;r="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":i?"NODE":"SHELL";let s="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",n="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(j,"commonJS",{value:i,enumerable:!0}),Object.defineProperty(j,"type",{value:j.Type[r],enumerable:!0}),Object.defineProperty(j,"type2D",{value:j.Type2D[s],enumerable:!0}),Object.defineProperty(j,"typeGL",{value:j.TypeGL[n],enumerable:!0})}(),j.commonJS&&(U=t("systeminformation"));var G=U;class $ extends E{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",E.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new $;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=j.version,t.props["runtime.type"]=j.type.name,void 0===G)t.props["user.agent"]=navigator.userAgent;else{let e=await G.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const Y={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class X{static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=X.getUnitMetric(e);return i!=X.Metric.NORMALIZED&&i!=X.Metric.LOGICAL&&(r=X[z[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*X[z[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*X[t.name][r.name]/i}static getUnitMetric(e){switch(e){case X.Unit.METER:case X.Unit.CENTIMETER:case X.Unit.MILLIMETER:case X.Unit.MICROMETER:case X.Unit.INCH:case X.Unit.DP:case X.Unit.PICA:case X.Unit.POINT:case X.Unit.DIP:case X.Unit.DPI:return X.Metric.LENGTH;case X.Unit.SECOND:case X.Unit.MILLISECOND:case X.Unit.MICROSECOND:case X.Unit.NANOSECOND:return X.Metric.TIME;case X.Unit.RADIAN:case X.Unit.DEGREE:return X.Metric.ANGLE;case X.Unit.NEWTON:return X.Metric.FORCE;case X.Unit.NORMALIZED:return X.Metric.NORMALIZED;case X.Unit.LOGICAL:return X.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case X.Metric.LENGTH:return[X.Unit.METER,X.Unit.CENTIMETER,X.Unit.MILLIMETER,X.Unit.MICROMETER,X.Unit.INCH,X.Unit.DP,X.Unit.PICA,X.Unit.POINT,X.Unit.DIP,X.Unit.DPI];case X.Metric.TIME:return[X.Unit.SECOND,X.Unit.MILLISECOND,X.Unit.MICROSECOND,X.Unit.NANOSECOND];case X.Metric.ANGLE:return[X.Unit.RADIAN,X.Unit.DEGREE];case X.Metric.FORCE:return[X.Unit.NEWTON];case X.Metric.NORMALIZED:return[X.Unit.NORMALIZED];case X.Metric.LOGICAL:return[X.Unit.LOGICAL];case X.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return z[e.name]}static convertValue(e,t,r){return e*X[t.name][r.name]}}Object.defineEnum(X,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum(X,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const z=Object.freeze({LENGTH:X.Unit.METER,TIME:X.Unit.SECOND,FORCE:X.Unit.NEWTON,ANGLE:X.Unit.RADIAN,NORMALIZED:X.Unit.NORMALIZED,LOGICAL:X.Unit.LOGICAL});!function(){let e=X.getMetricUnits(X.Metric.LENGTH).filter((e=>!(e.name in Y)));for(let t of e){let e=X.Units[t.name];for(let t in Y)e[t]=e.INCH*Y[t]}for(let t in Y){let r={};for(let i of e)r[i.name]=X.Units.INCH[i.name]/Y[t];for(let e in Y)r[e]=Y[e]/Y[t];X.Units[t]=r}for(let e in X.Units)X[e]=X.Units[e]}(),Object.freeze(X);class V extends E{constructor(e,t,r,i,s){if(super(),t==V.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=V.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=X.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==V.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return N.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(V.Type).find((t=>V.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case V.Type.X:case V.Type.Y:case V.Type.Z:case V.Type.RADIUS_X:case V.Type.RADIUS_Y:t.unit=X.Unit.DIP;break;case V.Type.TIMESTAMP:t.unit=X.Unit.MILLISECOND;break;case V.Type.PRESSURE:t.unit=X.Unit.NORMALIZED,t.min=0,t.max=1;break;case V.Type.ALTITUDE:t.unit=X.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case V.Type.AZIMUTH:t.unit=X.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case V.Type.ROTATION:t.unit=X.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=X.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new V(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=V.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=X.getChannelResolution(r.unit),s=new V(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=V.Type.X&&e!=V.Type.Y||t.type!=P.Type.MOUSE||(s.precision=0),s}}V.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),V.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},V.Metric=X.Metric;class H extends E{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==V.Type.X||e.type==V.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new H(e,t);return r.channels=V.defaults[t.type.name].map((e=>V.createDefaultInstance(V.Type[e],t))),r}}class Z extends E{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new Z;return r.addContext(H.createDefaultInstance(e,t)),r}}class W extends E{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=Z.createDefaultInstance(t,r);return new W(e,i)}}class q{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${q.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class K extends E{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=q.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=K.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(K,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class J{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=N.getPropName(t.name),i=e[r];if(t.type==V.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==V.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=N.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==V.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class Q extends E{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",E.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof Q))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new P(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return Z.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=P.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new W(this.environment,r);r.inkChannelsContext.layout=Q.getLayout(e),this.sensorData=new K(i),this.sensorData.add(new J(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(V.Type).forEach((r=>{let i,s=V.Type[r];i=s==V.Type.ALTITUDE?"tiltX":s==V.Type.AZIMUTH?"tiltY":N.getPropName(r),Q.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===G)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await G.system(),r=await G.cpu(),i=await G.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await $.createInstance(e),t}}let ee={};if(j.type==j.Type.WEB)ee.Image=globalThis.Image,ee.ImageData=globalThis.ImageData,ee.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(ee.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},ee.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(ee.OffscreenCanvas=globalThis.OffscreenCanvas,ee.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)ee.Image=globalThis.Image,ee.ImageData=globalThis.ImageData,ee.OffscreenCanvas=globalThis.OffscreenCanvas,ee.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(j.commonJS){const{Canvas:e,CanvasRenderingContext2D:r,Image:i,ImageData:s}=t("canvas");ee.Image=i,ee.ImageData=s,ee.OffscreenCanvas=e,ee.OffscreenCanvasRenderingContext2D=r}else console.warn(`Current env - ${j.type.name}, do not provides OffscreenCanvas support`);function te(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}ee.CanvasRenderingContext2D&&(ee.CanvasRenderingContext2D.prototype.clearCanvas=te),ee.OffscreenCanvasRenderingContext2D&&(ee.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=te);const{Image:re,ImageData:ie,OffscreenCanvas:se,CanvasRenderingContext2D:ne,OffscreenCanvasRenderingContext2D:oe}=ee;let ae;class le{#r={};constructor(...e){if(ae)throw new Error("URIResolver instance already available");ae=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(le,"instance",{get:()=>ae});class he{static encode(e,t=he.Encoding.AUTO){let r;if(t==he.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?he.Encoding.NONE:he.Encoding.ARRAY:he.Encoding.BUFFER:t==he.Encoding.ARRAY&&e instanceof Array&&(t=he.Encoding.NONE),t==he.Encoding.NONE)r=e;else if(t==he.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case he.Encoding.BUFFER:r=i.toJSON();break;case he.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=he.Encoding[e.encoding];if(r==he.Encoding.NONE)t=e.content;else if(r==he.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case he.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case he.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(he,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class de{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||N.isValidURL(e)||de.repetitionsCache.has(e)||(de.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!le.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=le.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=he.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return he.isTypedArrayData(t)&&(t=he.decode(t)),new de(e.name,t)}static getInstance(e,t){return new de(t,e)}}class ce{constructor(e){N.isValidURL(e)||(de.repetitionsCache.has(e)||(de.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class pe{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=pe.defaults.CIRCLE_PRECISION,t=pe.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return pe.createEllipse(e,t,t,r)}static createEllipse(e=pe.defaults.ELLIPSE_PRECISION,t=pe.defaults.ELLIPSE_RADIUS_X,r=pe.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=pe.defaults.STAR_POINTS,t=pe.defaults.STAR_INTERNAL_RADIUS,r=pe.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let ue=d?d.default||globalThis.poly2tri:{};const{SweepContext:fe,Point:me}=ue;let ge=c?c.default||globalThis.ClipperLib:{};const{Clipper:ye,Paths:be,Path:Ee,ClipType:Pe,PolyType:Ie,PolyFillType:Se}=ge;class we{constructor(e,t,r){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:r,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.cjs.mjs line 1
- Likely real
- Yes, 99% confidence
`t.replace("[",".").replace` method will only replace the first occurrence when used with a string argument ("]"). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
import{createRequire as e}from"module";const t=e(import.meta.url);t.resolve.paths(".")[0];import"js-ext";import*as r from"js-md5";import i from"long";import{vec2 as s,vec3 as n,vec4 as o,quat2 as a,mat4 as l,mat2d as h}from"gl-matrix";import*as d from"poly2tri";import*as c from"clipper-lib";import p from"rbush";import*as u from"jszip";import*as f from"protobufjs";var m="1.5.0";class g{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let y=r?r.default||globalThis.md5:{},b={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(y.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),r=this.toBytes(e);return t[0]=i.fromBytes(r.slice(0,8)),t[1]=i.fromBytes(r.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class E{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=E.Algorithm.MD5;else if("function"==typeof this.buildURI)t=E.Algorithm.URI;else if(t=E.Algorithm.GUID,e&&!b.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=E.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==E.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return y(e)}return this.algorithm==E.Algorithm.URI?this.buildURI():b.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(E,"Algorithm",["GUID","MD5","URI"]);class P extends E{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,E.buildMD5Tokens(this.props)]}}Object.defineEnum(P,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class I{constructor(){this.phase=I.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=I.Phase.END||e==I.Phase.BEGIN)&&((this.phase!=I.Phase.BEGIN||e==I.Phase.UPDATE||e==I.Phase.END)&&((this.phase!=I.Phase.UPDATE||e==I.Phase.UPDATE||e==I.Phase.END)&&(e==I.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=I.Phase.END}}Object.defineEnum(I,"Phase",["BEGIN","UPDATE","END"]);class S{constructor(e,t,r,i){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let a=[e,t];isFinite(r)&&(a.push(r),isFinite(i)&&a.push(i)),this.value=a.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==a.length?this.vec=s:3==a.length?(this.vec=n,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=o,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),S.fromPoint(t)}addSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),S.fromPoint(t)}subtractSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),S.fromPoint(t)}multiplySelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),S.fromPoint(t)}divideSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),S.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new S(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),S.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return S.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new S(e[0],e[1],e[2],e[3]):new S(e.x,e.y,e.z,e.w)}}class w{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof w))throw new TypeError("rect must be instance of RectGL");return e?w.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof w))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=w.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return w.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return w.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=S.fromPoint({x:this.left,y:this.bottom}).transform(e),r=S.fromPoint({x:this.right,y:this.bottom}).transform(e),i=S.fromPoint({x:this.left,y:this.top}).transform(e),s=S.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return w.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let r=S.fromPoint({x:this.left,y:this.bottom}).transform(e),i=S.fromPoint({x:this.right,y:this.bottom}).transform(e),s=S.fromPoint({x:this.left,y:this.top}).transform(e),n=S.fromPoint({x:this.right,y:this.top}).transform(e);t=a.fromValues(r.x,r.y,i.x,i.y,s.x,s.y,n.x,n.y)}else t=a.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new w(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new S(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of w.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return w.ofEdges(f,g,m,y)}}Object.defineProperty(w,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class x{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?x.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=x.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return x.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return x.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=S.fromPoint({x:this.left,y:this.top}).transform(e),r=S.fromPoint({x:this.right,y:this.top}).transform(e),i=S.fromPoint({x:this.left,y:this.bottom}).transform(e),s=S.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return x.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new w(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof w))throw new TypeError("rect must be instance of RectGL");return new x(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new x(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?x.fromString(e):new x(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return x.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=w.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return x.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new x(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const v={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},R=v.m11,T=v.m12,A=v.m21,C=v.m22,O=v.m41,D=v.m42;class k{constructor(e=l.create(),t=k.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let r=function(e,t){let r=v[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[R],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[T],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[A],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[C],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[O],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[D],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[O],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[D],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:r.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:r.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:r.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:r.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:r.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:r.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:r.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:r.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:r.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:r.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new k(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(k.fromTranslate(e))}translateSelf(e){this.multiplySelf(k.fromTranslate(e))}rotate(e,t){return this.multiply(k.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(k.fromRotate(e,t))}scale(e,t){return this.multiply(k.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(k.fromScale(e,t))}multiply(e){return this.multiplicationType==k.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=l.create();return l.multiply(t,e.toFloat32Array(),this.value),new k(t,this.multiplicationType)}postMultiply(e){let t=l.create();return l.multiply(t,this.value,e.toFloat32Array()),new k(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==k.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){l.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){l.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=l.create();return l.invert(e,this.value),new k(e,this.multiplicationType)}invertSelf(){l.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return S.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let r=l.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(r[0]=parseFloat(e[0]),r[1]=parseFloat(e[1]),r[2]=parseFloat(e[2]),r[3]=parseFloat(e[3]),r[4]=parseFloat(e[4]),r[5]=parseFloat(e[5]),r[6]=parseFloat(e[6]),r[7]=parseFloat(e[7]),r[8]=parseFloat(e[8]),r[9]=parseFloat(e[9]),r[10]=parseFloat(e[10]),r[11]=parseFloat(e[11]),r[12]=parseFloat(e[12]),r[13]=parseFloat(e[13]),r[14]=parseFloat(e[14]),r[15]=parseFloat(e[15])):(r[R]=parseFloat(e[0]),r[T]=parseFloat(e[1]),r[A]=parseFloat(e[2]),r[C]=parseFloat(e[3]),r[O]=parseFloat(e[4]),r[D]=parseFloat(e[5]))}return new k(r,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof k)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new k(e,t);if("string"==typeof e)return k.fromString(e,t);let r=l.create(),i=Object.assign({},e);return isFinite(e.a)&&(i.m11=e.a),isFinite(e.b)&&(i.m12=e.b),isFinite(e.c)&&(i.m21=e.c),isFinite(e.d)&&(i.m22=e.d),isFinite(e.tx)?i.m41=e.tx:isFinite(e.e)?i.m41=e.e:isFinite(e.dx)&&(i.m41=e.dx),isFinite(e.ty)?i.m42=e.ty:isFinite(e.f)?i.m42=e.f:isFinite(e.dy)&&(i.m42=e.dy),isFinite(i.m11)&&(r[0]=i.m11),isFinite(i.m12)&&(r[1]=i.m12),isFinite(i.m13)&&(r[2]=i.m13),isFinite(i.m14)&&(r[3]=i.m14),isFinite(i.m21)&&(r[4]=i.m21),isFinite(i.m22)&&(r[5]=i.m22),isFinite(i.m23)&&(r[6]=i.m23),isFinite(i.m24)&&(r[7]=i.m24),isFinite(i.m31)&&(r[8]=i.m31),isFinite(i.m32)&&(r[9]=i.m32),isFinite(i.m33)&&(r[10]=i.m33),isFinite(i.m34)&&(r[11]=i.m34),isFinite(i.m41)&&(r[12]=i.m41),isFinite(i.m42)&&(r[13]=i.m42),isFinite(i.m43)&&(r[14]=i.m43),isFinite(i.m44)&&(r[15]=i.m44),new k(r,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return k.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),k.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),k.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=k.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=k.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return k.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let r=l.create();return l.multiply(r,e.value,t.value),new k(r)}}k.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let N={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(N.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class M{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let L={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof g))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==L.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==L.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=L.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==L.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=I.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:I.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return P.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=L.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=L.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:k.fromMatrix(i);let s=S.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=x.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=S.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(L.PointerType.MOUSE)||(this.stop(L.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(L.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new M(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},_={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof g))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==g.prototype.resize)return;let e=_.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=_.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?_.ResizeReason.ZOOM_IN:_.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=N.debounce((()=>{e==_.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?_.ResizeReason.SCREEN_SIZE_INCREASED:_.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=_.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=g.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==_.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==_.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=I.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:I.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return P.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:k.fromMatrix(i);let s=S.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=x.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=S.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==_.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?_.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new M(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(_,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(L.suppressKeys=_.suppressKeys,L.ResizeReason=_.ResizeReason,L.attachResize=_.attachResize,L.dettachResize=_.dettachResize,_=L);var F=_;class B extends S{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||B.defaults.size,this.rotation=i.rotation||B.defaults.rotation,this.scaleX=i.scaleX||B.defaults.scaleX,this.scaleY=i.scaleY||B.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||B.defaults.scaleZ:void 0,this.offsetX=i.offsetX||B.defaults.offsetX,this.offsetY=i.offsetY||B.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||B.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new B(0,0,e.includes(B.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>B.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||B.defaults.size,this.rotation=s.rotation||i.rotation||B.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||B.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||B.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||B.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||B.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||B.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||B.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case B.Property.X:return this.x;case B.Property.Y:return this.y;case B.Property.Z:return this.z;case B.Property.RED:return this.red;case B.Property.GREEN:return this.green;case B.Property.BLUE:return this.blue;case B.Property.ALPHA:return this.alpha;case B.Property.SIZE:return this.size;case B.Property.ROTATION:return this.rotation;case B.Property.SCALE_X:return this.scaleX;case B.Property.SCALE_Y:return this.scaleY;case B.Property.SCALE_Z:return this.scaleZ;case B.Property.OFFSET_X:return this.offsetX;case B.Property.OFFSET_Y:return this.offsetY;case B.Property.OFFSET_Z:return this.offsetZ;case B.Property.D_X:return this.dX;case B.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){B.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case B.Property.X:e.x=r;break;case B.Property.Y:e.y=r;break;case B.Property.Z:e.z=r;break;case B.Property.RED:e.red=r;break;case B.Property.GREEN:e.green=r;break;case B.Property.BLUE:e.blue=r;break;case B.Property.ALPHA:e.alpha=r;break;case B.Property.SIZE:e.size=r;break;case B.Property.ROTATION:e.rotation=r;break;case B.Property.SCALE_X:e.scaleX=r;break;case B.Property.SCALE_Y:e.scaleY=r;break;case B.Property.SCALE_Z:e.scaleZ=r;break;case B.Property.OFFSET_X:e.offsetX=r;break;case B.Property.OFFSET_Y:e.offsetY=r;break;case B.Property.OFFSET_Z:e.offsetZ=r;break;case B.Property.D_X:e.dX=r;break;case B.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof k))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return B.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(B,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let U,j={version:"1.5.0"};Object.defineEnum(j,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(j,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(j,"TypeGL",["WEB","STACK"]),function(e){let r,i="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof t;r="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":i?"NODE":"SHELL";let s="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",n="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(j,"commonJS",{value:i,enumerable:!0}),Object.defineProperty(j,"type",{value:j.Type[r],enumerable:!0}),Object.defineProperty(j,"type2D",{value:j.Type2D[s],enumerable:!0}),Object.defineProperty(j,"typeGL",{value:j.TypeGL[n],enumerable:!0})}(),j.commonJS&&(U=t("systeminformation"));var G=U;class $ extends E{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",E.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new $;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=j.version,t.props["runtime.type"]=j.type.name,void 0===G)t.props["user.agent"]=navigator.userAgent;else{let e=await G.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const Y={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class X{static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=X.getUnitMetric(e);return i!=X.Metric.NORMALIZED&&i!=X.Metric.LOGICAL&&(r=X[z[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*X[z[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*X[t.name][r.name]/i}static getUnitMetric(e){switch(e){case X.Unit.METER:case X.Unit.CENTIMETER:case X.Unit.MILLIMETER:case X.Unit.MICROMETER:case X.Unit.INCH:case X.Unit.DP:case X.Unit.PICA:case X.Unit.POINT:case X.Unit.DIP:case X.Unit.DPI:return X.Metric.LENGTH;case X.Unit.SECOND:case X.Unit.MILLISECOND:case X.Unit.MICROSECOND:case X.Unit.NANOSECOND:return X.Metric.TIME;case X.Unit.RADIAN:case X.Unit.DEGREE:return X.Metric.ANGLE;case X.Unit.NEWTON:return X.Metric.FORCE;case X.Unit.NORMALIZED:return X.Metric.NORMALIZED;case X.Unit.LOGICAL:return X.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case X.Metric.LENGTH:return[X.Unit.METER,X.Unit.CENTIMETER,X.Unit.MILLIMETER,X.Unit.MICROMETER,X.Unit.INCH,X.Unit.DP,X.Unit.PICA,X.Unit.POINT,X.Unit.DIP,X.Unit.DPI];case X.Metric.TIME:return[X.Unit.SECOND,X.Unit.MILLISECOND,X.Unit.MICROSECOND,X.Unit.NANOSECOND];case X.Metric.ANGLE:return[X.Unit.RADIAN,X.Unit.DEGREE];case X.Metric.FORCE:return[X.Unit.NEWTON];case X.Metric.NORMALIZED:return[X.Unit.NORMALIZED];case X.Metric.LOGICAL:return[X.Unit.LOGICAL];case X.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return z[e.name]}static convertValue(e,t,r){return e*X[t.name][r.name]}}Object.defineEnum(X,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum(X,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const z=Object.freeze({LENGTH:X.Unit.METER,TIME:X.Unit.SECOND,FORCE:X.Unit.NEWTON,ANGLE:X.Unit.RADIAN,NORMALIZED:X.Unit.NORMALIZED,LOGICAL:X.Unit.LOGICAL});!function(){let e=X.getMetricUnits(X.Metric.LENGTH).filter((e=>!(e.name in Y)));for(let t of e){let e=X.Units[t.name];for(let t in Y)e[t]=e.INCH*Y[t]}for(let t in Y){let r={};for(let i of e)r[i.name]=X.Units.INCH[i.name]/Y[t];for(let e in Y)r[e]=Y[e]/Y[t];X.Units[t]=r}for(let e in X.Units)X[e]=X.Units[e]}(),Object.freeze(X);class V extends E{constructor(e,t,r,i,s){if(super(),t==V.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=V.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=X.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==V.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return N.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(V.Type).find((t=>V.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case V.Type.X:case V.Type.Y:case V.Type.Z:case V.Type.RADIUS_X:case V.Type.RADIUS_Y:t.unit=X.Unit.DIP;break;case V.Type.TIMESTAMP:t.unit=X.Unit.MILLISECOND;break;case V.Type.PRESSURE:t.unit=X.Unit.NORMALIZED,t.min=0,t.max=1;break;case V.Type.ALTITUDE:t.unit=X.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case V.Type.AZIMUTH:t.unit=X.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case V.Type.ROTATION:t.unit=X.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=X.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new V(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=V.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=X.getChannelResolution(r.unit),s=new V(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=V.Type.X&&e!=V.Type.Y||t.type!=P.Type.MOUSE||(s.precision=0),s}}V.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),V.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},V.Metric=X.Metric;class H extends E{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==V.Type.X||e.type==V.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new H(e,t);return r.channels=V.defaults[t.type.name].map((e=>V.createDefaultInstance(V.Type[e],t))),r}}class Z extends E{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new Z;return r.addContext(H.createDefaultInstance(e,t)),r}}class W extends E{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=Z.createDefaultInstance(t,r);return new W(e,i)}}class q{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${q.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class K extends E{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=q.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=K.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(K,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class J{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=N.getPropName(t.name),i=e[r];if(t.type==V.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==V.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=N.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==V.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class Q extends E{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",E.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof Q))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new P(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return Z.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=P.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new W(this.environment,r);r.inkChannelsContext.layout=Q.getLayout(e),this.sensorData=new K(i),this.sensorData.add(new J(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(V.Type).forEach((r=>{let i,s=V.Type[r];i=s==V.Type.ALTITUDE?"tiltX":s==V.Type.AZIMUTH?"tiltY":N.getPropName(r),Q.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===G)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await G.system(),r=await G.cpu(),i=await G.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await $.createInstance(e),t}}let ee={};if(j.type==j.Type.WEB)ee.Image=globalThis.Image,ee.ImageData=globalThis.ImageData,ee.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(ee.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},ee.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(ee.OffscreenCanvas=globalThis.OffscreenCanvas,ee.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)ee.Image=globalThis.Image,ee.ImageData=globalThis.ImageData,ee.OffscreenCanvas=globalThis.OffscreenCanvas,ee.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(j.commonJS){const{Canvas:e,CanvasRenderingContext2D:r,Image:i,ImageData:s}=t("canvas");ee.Image=i,ee.ImageData=s,ee.OffscreenCanvas=e,ee.OffscreenCanvasRenderingContext2D=r}else console.warn(`Current env - ${j.type.name}, do not provides OffscreenCanvas support`);function te(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}ee.CanvasRenderingContext2D&&(ee.CanvasRenderingContext2D.prototype.clearCanvas=te),ee.OffscreenCanvasRenderingContext2D&&(ee.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=te);const{Image:re,ImageData:ie,OffscreenCanvas:se,CanvasRenderingContext2D:ne,OffscreenCanvasRenderingContext2D:oe}=ee;let ae;class le{#r={};constructor(...e){if(ae)throw new Error("URIResolver instance already available");ae=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(le,"instance",{get:()=>ae});class he{static encode(e,t=he.Encoding.AUTO){let r;if(t==he.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?he.Encoding.NONE:he.Encoding.ARRAY:he.Encoding.BUFFER:t==he.Encoding.ARRAY&&e instanceof Array&&(t=he.Encoding.NONE),t==he.Encoding.NONE)r=e;else if(t==he.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case he.Encoding.BUFFER:r=i.toJSON();break;case he.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=he.Encoding[e.encoding];if(r==he.Encoding.NONE)t=e.content;else if(r==he.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case he.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case he.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(he,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class de{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||N.isValidURL(e)||de.repetitionsCache.has(e)||(de.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!le.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=le.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=he.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return he.isTypedArrayData(t)&&(t=he.decode(t)),new de(e.name,t)}static getInstance(e,t){return new de(t,e)}}class ce{constructor(e){N.isValidURL(e)||(de.repetitionsCache.has(e)||(de.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class pe{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=pe.defaults.CIRCLE_PRECISION,t=pe.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return pe.createEllipse(e,t,t,r)}static createEllipse(e=pe.defaults.ELLIPSE_PRECISION,t=pe.defaults.ELLIPSE_RADIUS_X,r=pe.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=pe.defaults.STAR_POINTS,t=pe.defaults.STAR_INTERNAL_RADIUS,r=pe.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let ue=d?d.default||globalThis.poly2tri:{};const{SweepContext:fe,Point:me}=ue;let ge=c?c.default||globalThis.ClipperLib:{};const{Clipper:ye,Paths:be,Path:Ee,ClipType:Pe,PolyType:Ie,PolyFillType:Se}=ge;class we{constructor(e,t,r){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:r,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.mjs line 1
- Likely real
- Yes, 99% confidence
`t.replace` method will only replace the first occurrence when used with a string argument ("["). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
import"js-ext";import*as e from"js-md5";import t from"long";import{vec2 as r,vec3 as i,vec4 as s,quat2 as n,mat4 as o,mat2d as a}from"gl-matrix";import*as l from"poly2tri";import*as h from"clipper-lib";import d from"rbush";import*as c from"jszip";import*as p from"protobufjs";var u="1.5.0";class f{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let m=e?e.default||globalThis.md5:{},g={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(m.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let r=new Array(2),i=this.toBytes(e);return r[0]=t.fromBytes(i.slice(0,8)),r[1]=t.fromBytes(i.slice(8)),r},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class y{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=y.Algorithm.MD5;else if("function"==typeof this.buildURI)t=y.Algorithm.URI;else if(t=y.Algorithm.GUID,e&&!g.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=y.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==y.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return m(e)}return this.algorithm==y.Algorithm.URI?this.buildURI():g.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(y,"Algorithm",["GUID","MD5","URI"]);class b extends y{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,y.buildMD5Tokens(this.props)]}}Object.defineEnum(b,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class E{constructor(){this.phase=E.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=E.Phase.END||e==E.Phase.BEGIN)&&((this.phase!=E.Phase.BEGIN||e==E.Phase.UPDATE||e==E.Phase.END)&&((this.phase!=E.Phase.UPDATE||e==E.Phase.UPDATE||e==E.Phase.END)&&(e==E.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=E.Phase.END}}Object.defineEnum(E,"Phase",["BEGIN","UPDATE","END"]);class P{constructor(e,t,n,o){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let a=[e,t];isFinite(n)&&(a.push(n),isFinite(o)&&a.push(o)),this.value=a.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==a.length?this.vec=r:3==a.length?(this.vec=i,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=s,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),P.fromPoint(t)}addSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),P.fromPoint(t)}subtractSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),P.fromPoint(t)}multiplySelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),P.fromPoint(t)}divideSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),P.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new P(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),P.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return P.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new P(e[0],e[1],e[2],e[3]):new P(e.x,e.y,e.z,e.w)}}class I{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof I))throw new TypeError("rect must be instance of RectGL");return e?I.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof I))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=I.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return I.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return I.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=P.fromPoint({x:this.left,y:this.bottom}).transform(e),r=P.fromPoint({x:this.right,y:this.bottom}).transform(e),i=P.fromPoint({x:this.left,y:this.top}).transform(e),s=P.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return I.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let r=P.fromPoint({x:this.left,y:this.bottom}).transform(e),i=P.fromPoint({x:this.right,y:this.bottom}).transform(e),s=P.fromPoint({x:this.left,y:this.top}).transform(e),o=P.fromPoint({x:this.right,y:this.top}).transform(e);t=n.fromValues(r.x,r.y,i.x,i.y,s.x,s.y,o.x,o.y)}else t=n.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new I(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new P(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of I.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return I.ofEdges(f,g,m,y)}}Object.defineProperty(I,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class S{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?S.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=S.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return S.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return S.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=P.fromPoint({x:this.left,y:this.top}).transform(e),r=P.fromPoint({x:this.right,y:this.top}).transform(e),i=P.fromPoint({x:this.left,y:this.bottom}).transform(e),s=P.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return S.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new I(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof I))throw new TypeError("rect must be instance of RectGL");return new S(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new S(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?S.fromString(e):new S(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return S.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=I.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return S.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new S(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const w={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},x=w.m11,v=w.m12,R=w.m21,T=w.m22,A=w.m41,C=w.m42;class O{constructor(e=o.create(),t=O.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let r=function(e,t){let r=w[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[x],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[v],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[R],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[T],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[A],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[C],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[A],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[C],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:r.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:r.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:r.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:r.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:r.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:r.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:r.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:r.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:r.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:r.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new O(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(O.fromTranslate(e))}translateSelf(e){this.multiplySelf(O.fromTranslate(e))}rotate(e,t){return this.multiply(O.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(O.fromRotate(e,t))}scale(e,t){return this.multiply(O.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(O.fromScale(e,t))}multiply(e){return this.multiplicationType==O.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=o.create();return o.multiply(t,e.toFloat32Array(),this.value),new O(t,this.multiplicationType)}postMultiply(e){let t=o.create();return o.multiply(t,this.value,e.toFloat32Array()),new O(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==O.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){o.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){o.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=o.create();return o.invert(e,this.value),new O(e,this.multiplicationType)}invertSelf(){o.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return P.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let r=o.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(r[0]=parseFloat(e[0]),r[1]=parseFloat(e[1]),r[2]=parseFloat(e[2]),r[3]=parseFloat(e[3]),r[4]=parseFloat(e[4]),r[5]=parseFloat(e[5]),r[6]=parseFloat(e[6]),r[7]=parseFloat(e[7]),r[8]=parseFloat(e[8]),r[9]=parseFloat(e[9]),r[10]=parseFloat(e[10]),r[11]=parseFloat(e[11]),r[12]=parseFloat(e[12]),r[13]=parseFloat(e[13]),r[14]=parseFloat(e[14]),r[15]=parseFloat(e[15])):(r[x]=parseFloat(e[0]),r[v]=parseFloat(e[1]),r[R]=parseFloat(e[2]),r[T]=parseFloat(e[3]),r[A]=parseFloat(e[4]),r[C]=parseFloat(e[5]))}return new O(r,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof O)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new O(e,t);if("string"==typeof e)return O.fromString(e,t);let r=o.create(),i=Object.assign({},e);return isFinite(e.a)&&(i.m11=e.a),isFinite(e.b)&&(i.m12=e.b),isFinite(e.c)&&(i.m21=e.c),isFinite(e.d)&&(i.m22=e.d),isFinite(e.tx)?i.m41=e.tx:isFinite(e.e)?i.m41=e.e:isFinite(e.dx)&&(i.m41=e.dx),isFinite(e.ty)?i.m42=e.ty:isFinite(e.f)?i.m42=e.f:isFinite(e.dy)&&(i.m42=e.dy),isFinite(i.m11)&&(r[0]=i.m11),isFinite(i.m12)&&(r[1]=i.m12),isFinite(i.m13)&&(r[2]=i.m13),isFinite(i.m14)&&(r[3]=i.m14),isFinite(i.m21)&&(r[4]=i.m21),isFinite(i.m22)&&(r[5]=i.m22),isFinite(i.m23)&&(r[6]=i.m23),isFinite(i.m24)&&(r[7]=i.m24),isFinite(i.m31)&&(r[8]=i.m31),isFinite(i.m32)&&(r[9]=i.m32),isFinite(i.m33)&&(r[10]=i.m33),isFinite(i.m34)&&(r[11]=i.m34),isFinite(i.m41)&&(r[12]=i.m41),isFinite(i.m42)&&(r[13]=i.m42),isFinite(i.m43)&&(r[14]=i.m43),isFinite(i.m44)&&(r[15]=i.m44),new O(r,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return O.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),O.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),O.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=O.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=O.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return O.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let r=o.create();return o.multiply(r,e.value,t.value),new O(r)}}O.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let D={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(D.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class k{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let N={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof f))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==N.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==N.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=N.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==N.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=E.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:E.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return b.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=N.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=N.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:O.fromMatrix(i);let s=P.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=S.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=P.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(N.PointerType.MOUSE)||(this.stop(N.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(N.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new k(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},M={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof f))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==f.prototype.resize)return;let e=M.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=M.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?M.ResizeReason.ZOOM_IN:M.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=D.debounce((()=>{e==M.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?M.ResizeReason.SCREEN_SIZE_INCREASED:M.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=M.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=f.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==M.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==M.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=E.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:E.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return b.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:O.fromMatrix(i);let s=P.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=S.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=P.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==M.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?M.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new k(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(M,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(N.suppressKeys=M.suppressKeys,N.ResizeReason=M.ResizeReason,N.attachResize=M.attachResize,N.dettachResize=M.dettachResize,M=N);var L=M;class _ extends P{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||_.defaults.size,this.rotation=i.rotation||_.defaults.rotation,this.scaleX=i.scaleX||_.defaults.scaleX,this.scaleY=i.scaleY||_.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||_.defaults.scaleZ:void 0,this.offsetX=i.offsetX||_.defaults.offsetX,this.offsetY=i.offsetY||_.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||_.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new _(0,0,e.includes(_.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>_.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||_.defaults.size,this.rotation=s.rotation||i.rotation||_.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||_.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||_.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||_.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||_.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||_.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||_.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case _.Property.X:return this.x;case _.Property.Y:return this.y;case _.Property.Z:return this.z;case _.Property.RED:return this.red;case _.Property.GREEN:return this.green;case _.Property.BLUE:return this.blue;case _.Property.ALPHA:return this.alpha;case _.Property.SIZE:return this.size;case _.Property.ROTATION:return this.rotation;case _.Property.SCALE_X:return this.scaleX;case _.Property.SCALE_Y:return this.scaleY;case _.Property.SCALE_Z:return this.scaleZ;case _.Property.OFFSET_X:return this.offsetX;case _.Property.OFFSET_Y:return this.offsetY;case _.Property.OFFSET_Z:return this.offsetZ;case _.Property.D_X:return this.dX;case _.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){_.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case _.Property.X:e.x=r;break;case _.Property.Y:e.y=r;break;case _.Property.Z:e.z=r;break;case _.Property.RED:e.red=r;break;case _.Property.GREEN:e.green=r;break;case _.Property.BLUE:e.blue=r;break;case _.Property.ALPHA:e.alpha=r;break;case _.Property.SIZE:e.size=r;break;case _.Property.ROTATION:e.rotation=r;break;case _.Property.SCALE_X:e.scaleX=r;break;case _.Property.SCALE_Y:e.scaleY=r;break;case _.Property.SCALE_Z:e.scaleZ=r;break;case _.Property.OFFSET_X:e.offsetX=r;break;case _.Property.OFFSET_Y:e.offsetY=r;break;case _.Property.OFFSET_Z:e.offsetZ=r;break;case _.Property.D_X:e.dX=r;break;case _.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof O))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return _.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(_,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let F,B={version:"1.5.0"};Object.defineEnum(B,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(B,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(B,"TypeGL",["WEB","STACK"]),function(e){let t,r="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof require;t="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":r?"NODE":"SHELL";let i="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",s="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(B,"commonJS",{value:r,enumerable:!0}),Object.defineProperty(B,"type",{value:B.Type[t],enumerable:!0}),Object.defineProperty(B,"type2D",{value:B.Type2D[i],enumerable:!0}),Object.defineProperty(B,"typeGL",{value:B.TypeGL[s],enumerable:!0})}(),B.commonJS&&(F=require("systeminformation"));var U=F;class j extends y{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",y.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new j;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=B.version,t.props["runtime.type"]=B.type.name,void 0===U)t.props["user.agent"]=navigator.userAgent;else{let e=await U.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const G={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class ${static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=$.getUnitMetric(e);return i!=$.Metric.NORMALIZED&&i!=$.Metric.LOGICAL&&(r=$[Y[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*$[Y[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*$[t.name][r.name]/i}static getUnitMetric(e){switch(e){case $.Unit.METER:case $.Unit.CENTIMETER:case $.Unit.MILLIMETER:case $.Unit.MICROMETER:case $.Unit.INCH:case $.Unit.DP:case $.Unit.PICA:case $.Unit.POINT:case $.Unit.DIP:case $.Unit.DPI:return $.Metric.LENGTH;case $.Unit.SECOND:case $.Unit.MILLISECOND:case $.Unit.MICROSECOND:case $.Unit.NANOSECOND:return $.Metric.TIME;case $.Unit.RADIAN:case $.Unit.DEGREE:return $.Metric.ANGLE;case $.Unit.NEWTON:return $.Metric.FORCE;case $.Unit.NORMALIZED:return $.Metric.NORMALIZED;case $.Unit.LOGICAL:return $.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case $.Metric.LENGTH:return[$.Unit.METER,$.Unit.CENTIMETER,$.Unit.MILLIMETER,$.Unit.MICROMETER,$.Unit.INCH,$.Unit.DP,$.Unit.PICA,$.Unit.POINT,$.Unit.DIP,$.Unit.DPI];case $.Metric.TIME:return[$.Unit.SECOND,$.Unit.MILLISECOND,$.Unit.MICROSECOND,$.Unit.NANOSECOND];case $.Metric.ANGLE:return[$.Unit.RADIAN,$.Unit.DEGREE];case $.Metric.FORCE:return[$.Unit.NEWTON];case $.Metric.NORMALIZED:return[$.Unit.NORMALIZED];case $.Metric.LOGICAL:return[$.Unit.LOGICAL];case $.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return Y[e.name]}static convertValue(e,t,r){return e*$[t.name][r.name]}}Object.defineEnum($,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum($,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const Y=Object.freeze({LENGTH:$.Unit.METER,TIME:$.Unit.SECOND,FORCE:$.Unit.NEWTON,ANGLE:$.Unit.RADIAN,NORMALIZED:$.Unit.NORMALIZED,LOGICAL:$.Unit.LOGICAL});!function(){let e=$.getMetricUnits($.Metric.LENGTH).filter((e=>!(e.name in G)));for(let t of e){let e=$.Units[t.name];for(let t in G)e[t]=e.INCH*G[t]}for(let t in G){let r={};for(let i of e)r[i.name]=$.Units.INCH[i.name]/G[t];for(let e in G)r[e]=G[e]/G[t];$.Units[t]=r}for(let e in $.Units)$[e]=$.Units[e]}(),Object.freeze($);class X extends y{constructor(e,t,r,i,s){if(super(),t==X.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=X.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=$.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==X.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return D.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(X.Type).find((t=>X.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case X.Type.X:case X.Type.Y:case X.Type.Z:case X.Type.RADIUS_X:case X.Type.RADIUS_Y:t.unit=$.Unit.DIP;break;case X.Type.TIMESTAMP:t.unit=$.Unit.MILLISECOND;break;case X.Type.PRESSURE:t.unit=$.Unit.NORMALIZED,t.min=0,t.max=1;break;case X.Type.ALTITUDE:t.unit=$.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case X.Type.AZIMUTH:t.unit=$.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case X.Type.ROTATION:t.unit=$.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=$.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new X(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=X.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=$.getChannelResolution(r.unit),s=new X(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=X.Type.X&&e!=X.Type.Y||t.type!=b.Type.MOUSE||(s.precision=0),s}}X.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),X.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},X.Metric=$.Metric;class z extends y{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==X.Type.X||e.type==X.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new z(e,t);return r.channels=X.defaults[t.type.name].map((e=>X.createDefaultInstance(X.Type[e],t))),r}}class V extends y{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new V;return r.addContext(z.createDefaultInstance(e,t)),r}}class H extends y{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=V.createDefaultInstance(t,r);return new H(e,i)}}class Z{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${Z.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class W extends y{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=Z.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=W.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(W,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class q{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=D.getPropName(t.name),i=e[r];if(t.type==X.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==X.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=D.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==X.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class K extends y{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",y.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof K))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new b(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return V.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=b.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new H(this.environment,r);r.inkChannelsContext.layout=K.getLayout(e),this.sensorData=new W(i),this.sensorData.add(new q(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(X.Type).forEach((r=>{let i,s=X.Type[r];i=s==X.Type.ALTITUDE?"tiltX":s==X.Type.AZIMUTH?"tiltY":D.getPropName(r),K.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===U)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await U.system(),r=await U.cpu(),i=await U.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await j.createInstance(e),t}}let J={};if(B.type==B.Type.WEB)J.Image=globalThis.Image,J.ImageData=globalThis.ImageData,J.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(J.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},J.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(J.OffscreenCanvas=globalThis.OffscreenCanvas,J.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)J.Image=globalThis.Image,J.ImageData=globalThis.ImageData,J.OffscreenCanvas=globalThis.OffscreenCanvas,J.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(B.commonJS){const{Canvas:e,CanvasRenderingContext2D:t,Image:r,ImageData:i}=require("canvas");J.Image=r,J.ImageData=i,J.OffscreenCanvas=e,J.OffscreenCanvasRenderingContext2D=t}else console.warn(`Current env - ${B.type.name}, do not provides OffscreenCanvas support`);function Q(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}J.CanvasRenderingContext2D&&(J.CanvasRenderingContext2D.prototype.clearCanvas=Q),J.OffscreenCanvasRenderingContext2D&&(J.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=Q);const{Image:ee,ImageData:te,OffscreenCanvas:re,CanvasRenderingContext2D:ie,OffscreenCanvasRenderingContext2D:se}=J;let ne;class oe{#r={};constructor(...e){if(ne)throw new Error("URIResolver instance already available");ne=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(oe,"instance",{get:()=>ne});class ae{static encode(e,t=ae.Encoding.AUTO){let r;if(t==ae.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?ae.Encoding.NONE:ae.Encoding.ARRAY:ae.Encoding.BUFFER:t==ae.Encoding.ARRAY&&e instanceof Array&&(t=ae.Encoding.NONE),t==ae.Encoding.NONE)r=e;else if(t==ae.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case ae.Encoding.BUFFER:r=i.toJSON();break;case ae.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=ae.Encoding[e.encoding];if(r==ae.Encoding.NONE)t=e.content;else if(r==ae.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case ae.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case ae.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(ae,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class le{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||D.isValidURL(e)||le.repetitionsCache.has(e)||(le.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!oe.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=oe.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=ae.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return ae.isTypedArrayData(t)&&(t=ae.decode(t)),new le(e.name,t)}static getInstance(e,t){return new le(t,e)}}class he{constructor(e){D.isValidURL(e)||(le.repetitionsCache.has(e)||(le.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class de{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=de.defaults.CIRCLE_PRECISION,t=de.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return de.createEllipse(e,t,t,r)}static createEllipse(e=de.defaults.ELLIPSE_PRECISION,t=de.defaults.ELLIPSE_RADIUS_X,r=de.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=de.defaults.STAR_POINTS,t=de.defaults.STAR_INTERNAL_RADIUS,r=de.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let ce=l?l.default||globalThis.poly2tri:{};const{SweepContext:pe,Point:ue}=ce;let fe=h?h.default||globalThis.ClipperLib:{};const{Clipper:me,Paths:ge,Path:ye,ClipType:be,PolyType:Ee,PolyFillType:Pe}=fe;class Ie{constructor(e,t,r){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:r,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative....[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/workers/SplitPointsProvider.mjs line 1
- Likely real
- Yes, 99% confidence
`t.replace("[",".").replace` method will only replace the first occurrence when used with a string argument ("]"). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
import"js-ext";import{vec2 as e,vec3 as t,vec4 as i,mat4 as s,quat2 as r,mat2d as n}from"gl-matrix";import*as a from"poly2tri";import*as o from"clipper-lib";import l from"long";import*as h from"js-md5";import u from"rbush";"function"==typeof Worker&&(Worker.prototype.on=function(e,t){this[`on${e}`]=i=>{let s="message"==e?i.data:i;t(s)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(e,t){this[`on${e}`]=i=>{let s="message"==e?i.data:i;t(s)}});class p{constructor(e,t){e>0&&0==t?(this.segmentIndex=e-1,this.t=1):(this.segmentIndex=e,this.t=t),Object.defineProperty(this,"index",{get:()=>(console.warn("SplineParameter index => segmentIndex"),this.segmentIndex)})}equals(e){return this.segmentIndex==e.segmentIndex&&this.t==e.t}toString(){return`spline-parameter(${this.segmentIndex}, ${this.t})`}toJSON(){return{segmentIndex:this.segmentIndex,t:this.t}}static fromJSON(e){return new p(e.segmentIndex,e.t)}static calcMiddleOfSegment(e,t){let i=.5*(e.t+t.t+(t.segmentIndex-e.segmentIndex)),s=Math.trunc(i),r=i-s;return new p(e.segmentIndex+s,r)}static areDistantEnough(e,t,i=.01){return t.t+(t.segmentIndex-e.segmentIndex)-e.t>i}}class c{constructor(e,t,i){this.splineParameter=e,this.segmentIndex=t,this.on=i}toString(){return`SplineSplitPoint: ${this.splineParameter.segmentIndex} T:${this.splineParameter.t} -> ${this.on?"ON":"OFF"}, split by ${this.segmentIndex}`}toJSON(){return{splineParameter:this.splineParameter.toJSON(),segmentIndex:this.segmentIndex,on:this.on}}static fromJSON(e){return new c(p.fromJSON(e.splineParameter),e.segmentIndex,e.on)}static compare(e,t){return e.splineParameter.segmentIndex<t.splineParameter.segmentIndex?-1:e.splineParameter.segmentIndex>t.splineParameter.segmentIndex?1:e.splineParameter.t<t.splineParameter.t?-1:e.splineParameter.t>t.splineParameter.t?1:0}}class d{constructor(s,r,n,a){if(isNaN(s))throw new Error(`Invalid x found: ${s}`);if(isNaN(r))throw new Error(`Invalid y found: ${r}`);let o=[s,r];isFinite(n)&&(o.push(n),isFinite(a)&&o.push(a)),this.value=o.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==o.length?this.vec=e:3==o.length?(this.vec=t,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=i,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),d.fromPoint(t)}addSelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),d.fromPoint(t)}subtractSelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),d.fromPoint(t)}multiplySelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),d.fromPoint(t)}divideSelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),d.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new d(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),d.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return d.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new d(e[0],e[1],e[2],e[3]):new d(e.x,e.y,e.z,e.w)}}const f={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},m=f.m11,g=f.m12,y=f.m21,P=f.m22,b=f.m41,E=f.m42;class S{constructor(e=s.create(),t=S.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let i=function(e,t){let i=f[e];this.value[i]=t};Object.defineProperty(this,"a",{get:()=>this.value[m],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[g],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[y],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[P],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[b],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[E],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[b],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[E],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:i.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:i.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:i.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:i.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:i.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:i.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:i.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:i.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:i.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:i.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new S(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(S.fromTranslate(e))}translateSelf(e){this.multiplySelf(S.fromTranslate(e))}rotate(e,t){return this.multiply(S.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(S.fromRotate(e,t))}scale(e,t){return this.multiply(S.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(S.fromScale(e,t))}multiply(e){return this.multiplicationType==S.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=s.create();return s.multiply(t,e.toFloat32Array(),this.value),new S(t,this.multiplicationType)}postMultiply(e){let t=s.create();return s.multiply(t,this.value,e.toFloat32Array()),new S(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==S.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){s.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){s.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=s.create();return s.invert(e,this.value),new S(e,this.multiplicationType)}invertSelf(){s.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return d.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let i=s.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(i[0]=parseFloat(e[0]),i[1]=parseFloat(e[1]),i[2]=parseFloat(e[2]),i[3]=parseFloat(e[3]),i[4]=parseFloat(e[4]),i[5]=parseFloat(e[5]),i[6]=parseFloat(e[6]),i[7]=parseFloat(e[7]),i[8]=parseFloat(e[8]),i[9]=parseFloat(e[9]),i[10]=parseFloat(e[10]),i[11]=parseFloat(e[11]),i[12]=parseFloat(e[12]),i[13]=parseFloat(e[13]),i[14]=parseFloat(e[14]),i[15]=parseFloat(e[15])):(i[m]=parseFloat(e[0]),i[g]=parseFloat(e[1]),i[y]=parseFloat(e[2]),i[P]=parseFloat(e[3]),i[b]=parseFloat(e[4]),i[E]=parseFloat(e[5]))}return new S(i,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof S)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new S(e,t);if("string"==typeof e)return S.fromString(e,t);let i=s.create(),r=Object.assign({},e);return isFinite(e.a)&&(r.m11=e.a),isFinite(e.b)&&(r.m12=e.b),isFinite(e.c)&&(r.m21=e.c),isFinite(e.d)&&(r.m22=e.d),isFinite(e.tx)?r.m41=e.tx:isFinite(e.e)?r.m41=e.e:isFinite(e.dx)&&(r.m41=e.dx),isFinite(e.ty)?r.m42=e.ty:isFinite(e.f)?r.m42=e.f:isFinite(e.dy)&&(r.m42=e.dy),isFinite(r.m11)&&(i[0]=r.m11),isFinite(r.m12)&&(i[1]=r.m12),isFinite(r.m13)&&(i[2]=r.m13),isFinite(r.m14)&&(i[3]=r.m14),isFinite(r.m21)&&(i[4]=r.m21),isFinite(r.m22)&&(i[5]=r.m22),isFinite(r.m23)&&(i[6]=r.m23),isFinite(r.m24)&&(i[7]=r.m24),isFinite(r.m31)&&(i[8]=r.m31),isFinite(r.m32)&&(i[9]=r.m32),isFinite(r.m33)&&(i[10]=r.m33),isFinite(r.m34)&&(i[11]=r.m34),isFinite(r.m41)&&(i[12]=r.m41),isFinite(r.m42)&&(i[13]=r.m42),isFinite(r.m43)&&(i[14]=r.m43),isFinite(r.m44)&&(i[15]=r.m44),new S(i,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return S.fromMatrix(t)}static fromRotate(e,t){let i=Math.sin(e),s=Math.cos(e),r={a:s,b:i,c:-i,d:s};return t&&(r.tx=t.x-t.x*s+t.y*i,r.ty=t.y-t.x*i-t.y*s),S.fromMatrix(r)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let i={a:e.x,d:e.y};return t&&(i.tx=t.x-t.x*e.x,i.ty=t.y-t.y*e.y),S.fromMatrix(i)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let i=S.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),s=S.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=i.invert().preMultiply(s);return S.fromMatrix({a:r.m11,b:r.m12,c:r.m21,d:r.m22,tx:r.m31,ty:r.m32})}static multiply(e,t){let i=s.create();return s.multiply(i,e.value,t.value),new S(i)}}S.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});class w extends d{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,i,s={}){super(e,t,i),this.red=s.red,this.green=s.green,this.blue=s.blue,this.alpha=s.alpha,this.size=s.size||w.defaults.size,this.rotation=s.rotation||w.defaults.rotation,this.scaleX=s.scaleX||w.defaults.scaleX,this.scaleY=s.scaleY||w.defaults.scaleY,this.scaleZ=isFinite(i)?s.scaleZ||w.defaults.scaleZ:void 0,this.offsetX=s.offsetX||w.defaults.offsetX,this.offsetY=s.offsetY||w.defaults.offsetY,this.offsetZ=isFinite(i)?s.offsetZ||w.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,i,s=0){let r=new w(0,0,e.includes(w.Property.Z)?0:void 0);return i&&r.fill(s,i,e,t),r}fill(e,t,i,s={}){let r={},n=e*i.length;i.forEach(((e,i)=>w.setProperty(r,e,t[n+i]))),this.x=r.x,this.y=r.y,this.z=r.z,this.red=isFinite(r.red)?r.red:s.red,this.green=isFinite(r.green)?r.green:s.green,this.blue=isFinite(r.blue)?r.blue:s.blue,this.alpha=isFinite(r.alpha)?r.alpha:s.alpha,this.size=r.size||s.size||w.defaults.size,this.rotation=r.rotation||s.rotation||w.defaults.rotation,this.scaleX=r.scaleX||s.scaleX||w.defaults.scaleX,this.scaleY=r.scaleY||s.scaleY||w.defaults.scaleY,this.scaleZ=isFinite(r.z)?r.scaleZ||s.scaleZ||w.defaults.scaleZ:void 0,this.offsetX=r.offsetX||s.offsetX||w.defaults.offsetX,this.offsetY=r.offsetY||s.offsetY||w.defaults.offsetY,this.offsetZ=isFinite(r.z)?r.offsetZ||s.offsetZ||w.defaults.offsetZ:void 0,this.dX=r.dX,this.dY=r.dY}getProperty(e){switch(e){case w.Property.X:return this.x;case w.Property.Y:return this.y;case w.Property.Z:return this.z;case w.Property.RED:return this.red;case w.Property.GREEN:return this.green;case w.Property.BLUE:return this.blue;case w.Property.ALPHA:return this.alpha;case w.Property.SIZE:return this.size;case w.Property.ROTATION:return this.rotation;case w.Property.SCALE_X:return this.scaleX;case w.Property.SCALE_Y:return this.scaleY;case w.Property.SCALE_Z:return this.scaleZ;case w.Property.OFFSET_X:return this.offsetX;case w.Property.OFFSET_Y:return this.offsetY;case w.Property.OFFSET_Z:return this.offsetZ;case w.Property.D_X:return this.dX;case w.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){w.setProperty(this,e,t)}static setProperty(e,t,i){switch(t){case w.Property.X:e.x=i;break;case w.Property.Y:e.y=i;break;case w.Property.Z:e.z=i;break;case w.Property.RED:e.red=i;break;case w.Property.GREEN:e.green=i;break;case w.Property.BLUE:e.blue=i;break;case w.Property.ALPHA:e.alpha=i;break;case w.Property.SIZE:e.size=i;break;case w.Property.ROTATION:e.rotation=i;break;case w.Property.SCALE_X:e.scaleX=i;break;case w.Property.SCALE_Y:e.scaleY=i;break;case w.Property.SCALE_Z:e.scaleZ=i;break;case w.Property.OFFSET_X:e.offsetX=i;break;case w.Property.OFFSET_Y:e.offsetY=i;break;case w.Property.OFFSET_Z:e.offsetZ=i;break;case w.Property.D_X:e.dX=i;break;case w.Property.D_Y:e.dY=i;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof S))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,i=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=i}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return w.Property.values.forEach((t=>{let i=this.getProperty(t);null!=i&&isFinite(i)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(w,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]);class I{constructor(e){this.key=e,this.height=1}leftRotate(){let e=this.right,t=e.left;return e.left=this,this.right=t,this.height=Math.max(I.height(this.left),I.height(this.right))+1,e.height=Math.max(I.height(e.left),I.height(e.right))+1,e}rightRotate(){let e=this.left,t=e.right;return e.right=this,this.left=t,this.height=Math.max(I.height(this.left),I.height(this.right))+1,e.height=Math.max(I.height(e.left),I.height(e.right))+1,e}getBalanceFactor(){return I.height(this.left)-I.height(this.right)}static height(e){return e?e.height:0}static minValue(e){if(!e)return;let t=e;for(;t.left;)t=t.left;return t.key}static maxValue(e){if(!e)return;let t=e;for(;t.right;)t=t.right;return t.key}}class O{constructor(){this.count=0,this.hasKey=!1,this.root}min(){return I.minValue(this.root)}max(){return I.maxValue(this.root)}add(e){return this.hasKey=!1,this.root=this.insertNode(this.root,e),this.hasKey||this.count++,!this.hasKey}insertNode(e,t){if(!e)return new I(t);if(t<e.key)e.left=this.insertNode(e.left,t);else{if(!(t>e.key))return this.hasKey=!0,e;e.right=this.insertNode(e.right,t)}if(!this.hasKey){e.height=1+Math.max(I.height(e.left),I.height(e.right));let i=e.getBalanceFactor();if(i>1){if(t<e.left.key)return e.rightRotate();if(t>e.left.key)return e.left=e.left.leftRotate(),e.rightRotate()}else if(i<-1){if(t>e.right.key)return e.leftRotate();if(t<e.right.key)return e.right=e.right.rightRotate(),e.leftRotate()}}return e}contains(e){return this.containsNode(this.root,e)}containsNode(e,t){return!!e&&(t<e.key?this.containsNode(e.left,t):!(t>e.key)||this.containsNode(e.right,t))}printTree(){if(!this.root)return;let e=[this.root],t=this.root.height;for(;e.length>0;){let i=e.shift();t!=i.height&&console.log("-"),console.log(`${i.key} with height: ${i.height}, balance: ${i.getBalanceFactor()}`),t=i.height;let s=i.left,r=i.right;s&&e.push(s),r&&e.push(r)}}toArray(){let e=[];return O.fillArray(e,this.root),e}static fillArray(e,t){t&&(this.fillArray(e,t.left),e.push(t.key),this.fillArray(e,t.right))}}class v{constructor(){this.tree=new O,Object.defineProperty(this,"length",{get:()=>this.tree.count,enumerable:!0})}clear(){this.tree=new O}add(e){return this.tree.add(e)}includes(e){return this.tree.contains(e)}min(){return this.tree.min()}max(){return this.tree.max()}toArray(){return this.tree.toArray()}}let x=a?a.default||globalThis.poly2tri:{};const{SweepContext:A,Point:R}=x;let T=o?o.default||globalThis.ClipperLib:{};const{Clipper:D,Paths:N,Path:F,ClipType:C,PolyType:M,PolyFillType:k}=T;class L{constructor(e,t,i){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:i,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.path.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in path index is ${this.path.length-1}.`)}toPath(){return this.path.slice(this)}toString(){return`fragment(${this.pointIndexStart} - ${this.pointIndexEnd})`}}class B{constructor(e,t,i,s=1){if(this.red=e,this.green=t,this.blue=i,this.alpha=s,s<0||s>1)throw new Error(`Invalid alpha ${s} found. The value must be in the interval [0, 1].`);Object.defineProperty(this,"hex",{get:()=>`#${this.red.toString(16).pad(2,"0")}${this.green.toString(16).pad(2,"0")}${this.blue.toString(16).pad(2,"0")}${Math.round(255*this.alpha).toString(16).pad(2,"0")}`,enumerable:!0})}premultiply(){return{red:this.red/255*this.alpha,green:this.green/255*this.alpha,blue:this.blue/255*this.alpha,alpha:this.alpha}}static postdivide(e,t,i,s){let r=parseInt(255*e/s),n=parseInt(255*t/s),a=parseInt(255*i/s);return new B(r,n,a,s)}equals(e){return e&&this.red==e.red&&this.green==e.green&&this.blue==e.blue&&this.alpha==e.alpha}toRGB(){return 1==this.alpha?this:new B(this.red,this.green,this.blue)}toRGBA(e){return new B(this.red,this.green,this.blue,e)}toHSLA(){let e=this.red/255,t=this.green/255,i=this.blue/255,s=Math.min(e,t,i),r=Math.max(e,t,i),n=0,a=0,o=(r+s)/2;if(r!=s){let l=r-s;switch(a=l/(1-Math.abs(2*o-1)),r){case e:n=(t-i)/l%6;break;case t:n=(i-e)/l+2;break;case i:n=(e-t)/l+4}}return n*=60,n<0&&(n+=360),{hue:parseFloat(n.toFixed(0)),saturation:parseFloat((100*a).toFixed(2)),lightness:parseFloat((100*o).toFixed(2)),alpha:this.alpha}}toArray(){return[this.red,this.green,this.blue,this.alpha]}toJSON(){return{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}}toString(){return 1==this.alpha?`rgb(${this.red}, ${this.green}, ${this.blue})`:`rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`}static isColor(e){return e&&isFinite(e.red)&&isFinite(e.green)&&isFinite(e.blue)}static fromColor(e){let t,i,s,r;if("string"==typeof e)if(e.startsWith("rgb"))e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),t=parseInt(e[0]),i=parseInt(e[1]),s=parseInt(e[2]),r=e[3]?parseInt(e[3]):1;else{if(!e.startsWith("#"))throw new Error(`Unknown input found: ${e}. Expected data starts with rgba, rgb or #.`);e=e.substring(1),t=parseInt(e.substring(0,2),16),i=parseInt(e.substring(2,4),16),s=parseInt(e.substring(4,6),16),r=8==e.length?parseInt(e.substring(6,8),16)/255:1}else Array.isArray(e)?(t=e[0],i=e[1],s=e[2],r=e[3]):(t=e.red,i=e.green,s=e.blue,r=e.alpha);return new B(t,i,s,r)}static fromHSLA(e=0,t=0,i=0,s){e/=60,t/=100,i/=100;let r=(1-Math.abs(2*i-1))*t,n=r*(1-Math.abs(e%2-1)),a=0,o=0,l=0;e>=0&&e<1?(a=r,o=n):e>=1&&e<2?(a=n,o=r):e>=2&&e<3?(o=r,l=n):e>=3&&e<4?(o=n,l=r):e>=4&&e<5?(a=n,l=r):(a=r,l=n);let h=i-r/2;return a+=h,o+=h,l+=h,new B(Math.round(255*a),Math.round(255*o),Math.round(255*l),s)}static random(e=!1){return new B(Math.randomInt(0,255),Math.randomInt(0,255),Math.randomInt(0,255),e?Math.random():1)}}B.TRANSPERENT=new B(0,0,0,0),B.BLACK=new B(0,0,0,1),B.WHITE=new B(255,255,255,1),B.RED=new B(255,0,0,1),B.GREEN=new B(0,255,0,1),B.BLUE=new B(0,0,255,1);let _={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let i=0;i<t.length;i++){let s=255&e;t[i]=s,e=(e-s)/256}return t},byteArrayToLong(e){let t=0;for(let i=e.length-1;i>=0;i--)t=256*t+e[i];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let i=t;for(let e=8;e--;)i=1&i?3988292384^i>>>1:i>>>1;e[t]=i}return function(t){let i=-1;for(let s=0,r=t.length;s<r;s++)i=i>>>8^e[255&i^t[s]];return(-1^i)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",i=Math.max(...e);for(let s=1;s<=i;s++)t+=e.includes(s)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],i=e.toString(2).split("").reverse();for(let e=0;e<i.length;e++)1==i[e]&&t.push(e+1);return t},mapTo:(e,t,i)=>i.min+(_.clamp(e,t)-t.min)/(t.max-t.min)*(i.max-i.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let i=null;return function(){let s=this,r=arguments;clearTimeout(i),i=setTimeout((function(){e.apply(s,r)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,i){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),i?e.toLowerCase():e};return function(i,s){return e.map((e=>function(e,t,i){let s="asc"===i?1:-1;return e>t?1*s:e<t?-1*s:0}(t(i,e.sortBy,e.ignoreCase),t(s,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let i=e.split("_"),s=i.first.toLowerCase();t&&(s=s.substring(0,1).toUpperCase()+s.substring(1));for(let e=1;e<i.length;e++)s+=i[e].substring(0,1),s+=i[e].substring(1).toLowerCase();return s},getEnumValueName(e){let t="";for(let i=0;i<e.length;i++)i>0&&e[i]!=e[i].toLowerCase()&&(t+="_"),t+=e[i];return t.toUpperCase()}};class j{constructor(e,t,i={}){this.layout=e,this.pointProps=t,this.sheet={};let s={};Object.defineProperties(s,{size:{get:this.getComputed.bind(this,"size"),set:this.setStyle.bind(this,"size"),enumerable:!0},red:{get:this.getComputed.bind(this,"red"),set:this.setStyle.bind(this,"red"),enumerable:!0},green:{get:this.getComputed.bind(this,"green"),set:this.setStyle.bind(this,"green"),enumerable:!0},blue:{get:this.getComputed.bind(this,"blue"),set:this.setStyle.bind(this,"blue"),enumerable:!0},alpha:{get:this.getComputed.bind(this,"alpha"),set:this.setStyle.bind(this,"alpha"),enumerable:!0},rotation:{get:this.getComputed.bind(this,"rotation"),set:this.setStyle.bind(this,"rotation"),enumerable:!0},scaleX:{get:this.getComputed.bind(this,"scaleX"),set:this.setStyle.bind(this,"scaleX"),enumerable:!0},scaleY:{get:this.getComputed.bind(this,"scaleY"),set:this.setStyle.bind(this,"scaleY"),enumerable:!0},scaleZ:{get:this.getComputed.bind(this,"scaleZ"),set:this.setStyle.bind(this,"scaleZ"),enumerable:!0},offsetX:{get:this.getComputed.bind(this,"offsetX"),set:this.setStyle.bind(this,"offsetX"),enumerable:!0},offsetY:{get:this.getComputed.bind(this,"offsetY"),set:this.setStyle.bind(this,"offsetY"),enumerable:!0},offsetZ:{get:this.getComputed.bind(this,"offsetZ"),set:this.setStyle.bind(this,"offsetZ"),enumerable:!0},color:{get:this.getComputed.bind(this,"color"),set:this.setStyle.bind(this,"color"),enumerable:!0},blendMode:{get:this.getComputed.bind(this,"blendMode"),set:this.setStyle.bind(this,"blendMode"),enumerable:!0},visibility:{get:this.getComputed.bind(this,"visibility"),set:this.setStyle.bind(this,"visibility"),enumerable:!0},reset:{value:e=>{e&&(i=e),this.clear(),Object.keys(i).forEach((e=>this.setStyle(e,i[e])))}},clear:{value:this.clear.bind(this)}}),this.style=Object.freeze(s),this.style.reset(i)}setStyle(e,t){if(null==t&&(t=void 0),j.validate(this.layout,e,t),"color"==e&&t)return this.sheet.red=t.red,this.sheet.green=t.green,this.sheet.blue=t.blue,void(this.sheet.alpha=t.alpha);null==t?delete this.sheet[e]:this.sheet[e]=t}getStyle(e){let t=this.sheet[e];return"visibility"==e?"boolean"!=typeof t&&(t=!0):"color"==e&&B.isColor(this.sheet)&&(t=B.fromColor(this.sheet)),t}getComputed(e){let t=this.getStyle(e);if(null==t)if("color"==e){let e={red:isFinite(this.sheet.red)?this.sheet.red:this.pointProps.red,green:isFinite(this.sheet.green)?this.sheet.green:this.pointProps.green,blue:isFinite(this.sheet.blue)?this.sheet.blue:this.pointProps.blue,alpha:isFinite(this.sheet.alpha)?this.sheet.alpha:this.pointProps.alpha};B.isColor(e)&&(t=B.fromColor(e))}else t=this.pointProps[e];return t}clear(){this.sheet={}}static validate(e,t,i,s){let r;if(i&&e.includes(w.Property[_.getEnumValueName(t)])){if(!s)throw new Error(`Property ${t} value ${i} is not applicable. This is a dynamic property and is part of the layout.`);console.warn(`Property ${t} value ${i} is not applicable. This is a dynamic property and is part of the layout.`),i=void 0}if("color"==t)!i||i instanceof B||(r=`Property ${t} is not an instance of Color`);else if("blendMode"==t)""==i&&(i=void 0);else if("number"==typeof i)if("size"==t)i<0?r=`Property ${t} with value ${i} is not allowed. Value should be a positive number.`:0==i&&(i=void 0);else if("red"==t||"green"==t||"blue"==t||"alpha"==t){let e="alpha"==t?{min:0,max:1}:{min:0,max:255};i>=e.min&&i<=e.max||(r=`Property ${t} with value ${i} is out of range. Allowd range: [${e.min}, ${e.max}].`)}else"rotation"==t?0==i&&(i=void 0):"scattering"==t&&i<0&&(i=void 0);if(r)throw new Error(r);return i}}class ${static encode(e,t=$.Encoding.AUTO){let i;if(t==$.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?$.Encoding.NONE:$.Encoding.ARRAY:$.Encoding.BUFFER:t==$.Encoding.ARRAY&&e instanceof Array&&(t=$.Encoding.NONE),t==$.Encoding.NONE)i=e;else if(t==$.Encoding.ARRAY)i=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let s=Buffer.from(e.buffer);switch(t){case $.Encoding.BUFFER:i=s.toJSON();break;case $.Encoding.BASE64:i=s.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:i}}static decode(e){let t,i=$.Encoding[e.encoding];if(i==$.Encoding.NONE)t=e.content;else if(i==$.Encoding.ARRAY)t=e.content.toFloat32Array();else{let s;switch(i){case $.Encoding.BUFFER:s="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case $.Encoding.BASE64:s="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${i.name}`)}let r=new Uint8Array(s);t=new globalThis[e.type](r.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum($,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);const U=[w.Property.X,w.Property.Y];class Y{#e;#t;constructor(e,t={},i=U){if(this.#e=e,Object.defineProperty(this,"points",{get:()=>this.#e,set:e=>{if(this.#e instanceof Float32Array)throw new Error("Points setter is not accessible wehn points type is Float32Array.");this.#e=e,this.validate()},enumerable:!0}),Object.defineProperty(this,"buffer",{get:()=>this.#e.buffer,set:e=>{if(Array.isArray(this.#e))throw new Error("Underlying points buffer is Array. This property is applicable for TypedArray only.");if("undefined"!=typeof SharedArrayBuffer&&this.#e.buffer instanceof SharedArrayBuffer)throw new Error("Underlying buffer is SharedArrayBuffer and cannot be restored");if(this.#e.buffer.byteLength>0)throw new Error("Cannot restore buffer when underlying buffer is not empty");if(e.byteLength/Float32Array.BYTES_PER_ELEMENT/this.stride!=this.length)throw new Error("Value exceeds expected memory length");this.#e=new Float32Array(e)}}),!Object.isSealed(t))for(let e in t)void 0!==t[e]&&(t[e]=j.validate(i,e,t[e],!0));i.includes(w.Property.ROTATION)||"rotation"in t||(t.rotation=void 0),i.includes(w.Property.SIZE)||t.size||(t.size=1),Object.defineProperties(this,{stride:{value:i.length,enumerable:!0},layout:{value:Object.freeze(i),enumerable:!0},pointProps:{value:Object.seal(t),enumerable:!0}}),e instanceof Float32Array?Object.defineProperty(this,"length",{value:this.#e.length/this.stride,enumerable:!0}):Object.defineProperty(this,"length",{get:()=>this.#e.length/this.stride,enumerable:!0}),i.forEach(((e,t)=>{let i=_.getPropName(e.name,!0);Object.defineProperty(this,`setPoint${i}`,{value:this.setPointPropertyValue.bind(this,t)}),Object.defineProperty(this,`getPoint${i}`,{value:this.getPointPropertyValue.bind(this,t)})}))}validate(){if(this.points.length%this.stride!=0)throw new Error("Path length doesn't match the stride provided via the layout")}setPointPropertyValue(e,t,i){if(isNaN(t))throw new Error("Point index is required");if(t>=this.length||t<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);if(isNaN(i))throw new Error("value is required");this.points[t*this.layout.length+e]=i}getPointPropertyValue(e,t){if(isNaN(t))throw new Error("Point index is required");if(t>=this.length||t<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);return this.points[t*this.layout.length+e]}setPoint(e,t){let i=e*this.stride;this.layout.forEach(((e,s)=>this.points[i+s]=t.getProperty(e)))}getPoint(e,t=this.pointProps){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);return w.createInstance(this.layout,t,this.points,e)}getPointRef(e,t=this.pointProps){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);return this.#t||(this.#t=w.createInstance(this.layout)),this.#t.fill(e,this.points,this.layout,this.pointProps),this.#t}getChannelData(e){let t=new([w.Property.RED,w.Property.GREEN,w.Property.BLUE].includes(e)?Uint8Array:Float32Array)(this.length),i=this.layout.indexOf(e);if(-1==i)throw new Error(`Property ${e.name} is not part from the spline layout ${this.layout.map((e=>e.name)).join(", ")}`);for(let e=0;e<this.length;e++)t[e]=this.points[e*this.stride+i];return t}transform(e){let t=e.scaleX,s=e.rotation;for(let r=0;r<this.length;r++){let n=r*this.stride,a=i.fromValues(this.getPointX(r),this.getPointY(r),0,1);i.transformMat4(a,a,e.value);for(let e=0;e<this.stride;e++){let i=n+e;switch(this.layout[e]){case w.Property.X:this.points[i]=a[0]/a[3];break;case w.Property.Y:this.points[i]=a[1]/a[3];break;case w.Property.Z:this.points[i]=a[2]/a[3];break;case w.Property.ROTATION:this.points[i]+=s;break;case w.Property.SIZE:this.points[i]*=t}}}this.layout.includes(w.Property.ROTATION)||(this.pointProps.rotation=0==s?void 0:s)}clone(){return new Y(this.#e.clone(),Object.clone(this.pointProps),this.layout.slice())}getFragment(e=0,t=this.length-1){return new L(this,e,t)}slice(e){let t=this.slicePoints(e.pointIndexStart,e.pointIndexEnd);return new Y(t,Object.clone(this.pointProps),this.layout.slice())}validateFragment(e,t){if(e<0)throw new Error(`Invalid fragment pointIndexStart ${e} found. The value must be non-negative.`);if(t>this.length-1)throw new Error(`Invalid fragment pointIndexEnd ${t} found. Last point in path index is ${this.length-1}.`)}slicePoints(e,t){let i;if(this.validateFragment(e,t),"undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let s=this.points.subarray(e*this.stride,(t+1)*this.stride),r=new SharedArrayBuffer(s.length*Float32Array.BYTES_PER_ELEMENT);i=new Float32Array(r),i.set(s)}else i=this.points.slice(e*this.stride,(t+1)*this.stride);return i}toSVGPath(){let e=[];for(let t=0;t<this.length;t++)e.push(`${this.getPointX(t)},${this.getPointY(t)}`);return`M ${e.join(" L ")} Z`}toJSON(){return{type:"Path",points:$.encode(this.#e,this.encoding),pointProps:this.pointProps,layout:this.layout.map((e=>e.name))}}static fromJSON(e){if("Path"!=e.type)throw new Error(`Path deserialization failed. JSON type is ${e.type}, expected Path.`);return new Y($.decode(e.points),e.pointProps,e.layout.map((e=>w.Property[e])))}static fromRect(e,t){let i=[e.left,e.top,e.right,e.top,e.right,e.bottom,e.left,e.bottom,e.left,e.top];return new Y(i,t)}static createInstance(e,t,i){return new Y(e,t,i)}static createSharedInstance(e,t,i){return new Y(Float32Array.createSharedInstance(e),t,i)}}class G{constructor(e,t){if(!Array.isArray(e))throw new Error("Unexpected polygons type found");let i=65534/(t.width+1e-16),s=65534/(t.height+1e-16),r=Math.floor(Math.min(i,s));if(0==r)throw new Error(`Insufficent clipper range - (-32767 - 32767), scale failed - scaleX: ${i}, scaleY: ${s}`);let n=t.left+32767/r,a=t.top+32767/r;this.solution=new N,this.bounds=t,this.transform={scale:r,offsetX:n,offsetY:a},this.subject=this.apply(e)}convertPoint(e){let t=(e.x-this.transform.offsetX)*this.transform.scale,i=(e.y-this.transform.offsetY)*this.transform.scale;return{X:t<0?Math.ceil(t):Math.floor(t),Y:i<0?Math.ceil(i):Math.floor(i)}}containsPoint(e){return D.PointInPolygon(this.convertPoint(e),this.solution)}apply(e){let t=new N;for(let i of e){let e=new F,s=i.shape;for(let t=0;t<s.length;t++)e.push(this.convertPoint({x:s.getPointX(t),y:s.getPointY(t)}));t.push(e)}return t}toPaths(){let e=[];this.lastPoint={};for(let t of this.solution){if(0==t.length)continue;let i=this.flatPath(t);i.length>0&&e.push(i)}return e}flatPath(e){let t=[];for(let i of e)this.lastPoint.X==i.X&&this.lastPoint.Y==i.Y||(t.push(i.X/this.transform.scale+this.transform.offsetX,i.Y/this.transform.scale+this.transform.offsetY),this.lastPoint=i);return t.length<6&&(console.warn(`Invalid contour found: [${t.join(", ")}]`),t.clear()),t}}class X{constructor(e=2){this.stride=e}sort(e,t){return this.sortArrayPart(e,0,e.length-this.stride,t),e}partition(e,t,i,s){let r=e[i],n=e[i+1],a=t-this.stride;for(let o=t;o<i;o+=2)s?s(r,n,e[o],e[o+1])&&(a+=this.stride,this.swap(e,a,o)):(r>e[o]||r==e[o]&&n>e[o+1])&&(a+=this.stride,this.swap(e,a,o));return this.swap(e,a+this.stride,i),a+this.stride}swap(e,t,i){let s=e[t],r=e[t+1];return e[t]=e[i],e[t+1]=e[i+1],e[i]=s,e[i+1]=r,e}sortArrayPart(e,t,i,s){if(t<i){let r=this.partition(e,t,i,s);this.sortArrayPart(e,t,r-this.stride,s),this.sortArrayPart(e,r+this.stride,i,s)}}}function z(e,t,i,s,r,n){return(i-e)*(n-t)-(s-t)*(r-e)}function H(e,t,i,s,r,n){let a=e-i,o=r-i,l=a*(n-s)-o*(t-s);l*=l,a=r-i,o=n-s;let h=a*a+o*o;return h>0?Math.sqrt(l/h):Math.sqrt((i-e)*(i-e)+(s-t)*(s-t))}class q{constructor(e=Float32Array){this.ArrayType=e,this.quickSort=new X}monotoneChain(e){if(e.length<=0)return new this.ArrayType;this.quickSort.sort(e);let t=new this.ArrayType(e.length),i=0;for(let s=0;s<e.length;s+=2){for(;i>=4&&z(t[i-4],t[i-3],t[i-2],t[i-1],e[s],e[s+1])<=0;)i-=2;t[i]=e[s],t[i+1]=e[s+1],i+=2}t=t.slice(0,i);let s,r=new this.ArrayType(e.length);i=0;for(let t=e.length-2;t>=0;t-=2){for(;i>=4&&z(r[i-4],r[i-3],r[i-2],r[i-1],e[t],e[t+1])<=0;)i-=2;r[i]=e[t],r[i+1]=e[t+1],i+=2}if(r=r.slice(0,i-2),this.ArrayType==Float32Array){let e=r.length+t.length;s=Float32Array.createSharedInstance(e),s.set(r),s.set(t,r.length)}else s=r.concat(t);return s}}class J{constructor(e,t,i,s){let r=e,n=t,a=e+i,o=t+s;Object.defineProperties(this,{left:{value:r,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:a,enumerable:!0},top:{value:o,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0}})}union(e){if(e&&!(e instanceof J))throw new TypeError("rect must be instance of RectGL");return e?J.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof J))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=J.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return J.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return J.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=d.fromPoint({x:this.left,y:this.bottom}).transform(e),i=d.fromPoint({x:this.right,y:this.bottom}).transform(e),s=d.fromPoint({x:this.left,y:this.top}).transform(e),r=d.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(s.x,r.x,t.x,i.x),a=Math.min(s.y,r.y,t.y,i.y),o=Math.max(s.x,r.x,t.x,i.x),l=Math.max(s.y,r.y,t.y,i.y);return J.ofEdges(n,a,o,l)}toQuad(e){let t;if(e){let i=d.fromPoint({x:this.left,y:this.bottom}).transform(e),s=d.fromPoint({x:this.right,y:this.bottom}).transform(e),n=d.fromPoint({x:this.left,y:this.top}).transform(e),a=d.fromPoint({x:this.right,y:this.top}).transform(e);t=r.fromValues(i.x,i.y,s.x,s.y,n.x,n.y,a.x,a.y)}else t=r.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,i,s){return new J(e,t,i-e,s-t)}static calculateBrushGLSegmentBounds(e,t=0,i){let s,r=.5*e.size,n=Math.abs(t*r);if(i){s=new d(e.x,e.y,e.x,e.z).transform(i)}else s=e;let a=s.x,o=s.y,l=e.scaleX*r,h=e.scaleY*r,u=e.offsetX,p=-e.offsetY,c=Math.cos(e.rotation),f=Math.sin(e.rotation),m=Number.MAX_SAFE_INTEGER,g=Number.MIN_SAFE_INTEGER,y=Number.MAX_SAFE_INTEGER,P=Number.MIN_SAFE_INTEGER;for(let e of J.SQURE){let t=e.x*l+u,i=e.y*h+p,s=c*t+f*i+a,r=-f*t+c*i+o,d=s-n;m=Math.min(m,d),g=Math.max(g,d),d=s+n,m=Math.min(m,d),g=Math.max(g,d);let b=r-n;y=Math.min(y,b),P=Math.max(P,b),b=r+n,y=Math.min(y,b),P=Math.max(P,b)}return J.ofEdges(m,y,g,P)}}Object.defineProperty(J,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class V{constructor(e,t,i,s){let r,n,a,o=e,l=t,h=e+i,u=t+s;Object.defineProperties(this,{left:{value:o,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:u,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0},size:{get:()=>(r||(r={width:i,height:s}),r),enumerable:!0},area:{get:()=>(n||(n=i*s),n),enumerable:!0},center:{get:()=>(a||(a={x:(o+h)/2,y:(l+u)/2}),a),enumerable:!0}})}union(e){return e?V.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=V.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),i=Math.floor(this.top),s=Math.ceil(this.right),r=Math.ceil(this.bottom);if(e){let e=s-t,n=r-i;e+=e%2,n+=n%2,s=t+e,r=i+n}return V.ofEdges(t,i,s,r)}floor(e){let t=Math.ceil(this.left),i=Math.ceil(this.top),s=Math.floor(this.right),r=Math.floor(this.bottom);if(e){let e=s-t,n=r-i;e-=e%2,n-=n%2,s=t+e,r=i+n}return V.ofEdges(t,i,s,r)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=d.fromPoint({x:this.left,y:this.top}).transform(e),i=d.fromPoint({x:this.right,y:this.top}).transform(e),s=d.fromPoint({x:this.left,y:this.bottom}).transform(e),r=d.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,i.x,s.x,r.x),a=Math.min(t.y,i.y,s.y,r.y),o=Math.max(t.x,i.x,s.x,r.x),l=Math.max(t.y,i.y,s.y,r.y);return V.ofEdges(n,a,o,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new J(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof J))throw new TypeError("rect must be instance of RectGL");return new V(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new V(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?V.fromString(e):new V(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let a=e.getPointX(n),o=e.getPointY(n);t=Math.min(t,a),i=Math.min(i,o),s=Math.max(s,a),r=Math.max(r,o)}return V.ofEdges(t,i,s,r)}static ofSpline(e,t=0){let i;for(let s=0;s<e.length;s++)i=J.calculateBrushGLSegmentBounds(e.getPointRef(s),t).union(i);return V.fromGLRect(i)}static ofEdges(e,t,i,s){let r=Math.min(e,i),n=Math.min(t,s),a=Math.max(e,i),o=Math.max(t,s);return new V(r,n,a-r,o-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}class W{constructor(e,t=[]){if(!(e instanceof Y))throw new Error("Expected shape type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");if(t.some((e=>!(e instanceof Y))))throw new Error("Expected hole type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");let i;this.holesDirection=W.PointsDirection.CLOCKWISE,Object.defineProperty(this,"shape",{value:e,enumerable:!0}),Object.defineProperty(this,"holes",{value:t,enumerable:!0}),Object.defineProperty(this,"contours",{value:[e,...t],enumerable:!0}),Object.defineProperty(this,"ArrayType",{value:e.points instanceof Float32Array?Float32Array:Array}),Object.defineProperty(this,"bounds",{get:()=>V.ofPolygon(this),enumerable:!0}),Object.defineProperty(this,"vertices",{get:()=>(i||(i=this.triangulate()),i),set:e=>i=e,enumerable:!0}),Object.defineProperty(this,"verticesValue",{get:()=>i})}clone(e=!1){let t=this.shape.clone(e),i=this.holes.map((t=>t.clone(e))),s=new W(t,i);return this.verticesValue&&(s.vertices=this.vertices.slice()),s}fit(e){let t=this.bounds,i=e.width/t.width,s=e.height/t.height,r=i>0&&s>0?Math.min(i,s):Math.max(i,s);for(let e of this.contours)for(let t=0;t<e.length;t++)e.setPointX(t,e.getPointX(t)*r),e.setPointY(t,e.getPointY(t)*r)}center(){let e=this.bounds;for(let t of this.contours)for(let i=0;i<t.length;i++)t.setPointX(i,t.getPointX(i)-e.center.x),t.setPointY(i,t.getPointY(i)-e.center.y)}transform(e){this.contours.forEach((t=>t.transform(e)))}intersects(e){if(!(e instanceof W))throw new Error("Expected 'poly' type is Polygon");(this.holes.length>0||e.holes.length)&&console.warn("Polygon intersection is for contours only. Holes are ignored.");let t=this.shape,i=e.shape;for(let e=0;e<2;e++){let s=0==e?t:i;for(let e=0;e<s.length;e++){let r=e+1==s.length?0:e+1,n=s.getPointX(e),a=s.getPointY(e),o=s.getPointX(r),l=s.getPointY(r)-a,h=n-o,u=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY;for(let e=0;e<t.length;e++){let i=l*t.getPointX(e)+h*t.getPointY(e);i<u&&(u=i),i>p&&(p=i)}let c=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY;for(let e=0;e<i.length;e++){let t=l*i.getPointX(e)+h*i.getPointY(e);t<c&&(c=t),t>d&&(d=t)}if(p<c||d<u)return!1}}return!0}containsPoint(e){let t=!1,i=this.shape;this.holes.length>0&&console.warn("Polygon intersection is for contours only. Holes are ignored.");for(let s=0,r=i.length-1;s<i.length;r=s++)i.getPointY(s)>e.y!=i.getPointY(r)>e.y&&e.x<(i.getPointX(r)-i.getPointX(s))*(e.y-i.getPointY(s))/(i.getPointY(r)-i.getPointY(s))+i.getPointX(s)&&(t=!t);return t}triangulate(){let e,t=[];for(let e of this.contours){let i=[];for(let t=0;t<e.length;t++){let s=new R(e.getPointX(t),e.getPointY(t));if(t>0){if(i.last.x==s.x&&i.last.y==s.y)continue;if(t==e.length-1&&i.first.x==s.x&&i.first.y==s.y)continue}i.push(s)}t.push(i)}try{e=new A(t.shift())}catch(e){return console.error(e),new Float32Array}for(let i of t)try{e.addHole(i)}catch(e){return console.error(e),new Float32Array}try{e.triangulate()}catch(e){return console.warn(e),new Float32Array}let i=e.getTriangles(),s=Float32Array.createSharedInstance(6*i.length),r=0;for(let e of i){let t=e.getPoints();for(let e of t)s[r++]=e.x,s[r++]=e.y}return s}convex(){return this.buildConvex(this.shape.points)}union(e){let t=Array.of(...this.shape.points,...e.shape.points);return this.buildConvex(t)}buildConvex(e){this.convexHullProducer||(this.convexHullProducer=new q(this.ArrayType));let t=this.convexHullProducer.monotoneChain(e);return this.ArrayType==Float32Array?W.createSharedInstance(t):W.createInstance(t)}simplify(e=.1){let t=new G([this],this.bounds);return t.subject=D.SimplifyPolygons(t.subject,k.pftNonZero),t.solution=D.CleanPolygons(t.subject,e*t.transform.scale),1==t.subject.length&&0==t.solution.first.length&&(t.solution=t.subject),W.toPolygonArray(t.toPaths())}simplifyRamerDouglasPeucker(e=.1){if(e<=0)throw new Error("epsilon expected value > 0");this.epsilon=e;let t=this.simplifyPath(this.shape),i=[];for(let e of this.holes){let t=this.simplifyPath(e);t.length>0&&i.push(t)}return this.ArrayType==Float32Array?W.createSharedInstance(t,i):W.createInstance(t,i)}simplifyPath(e){if(e.length<3)return e.points;let t=Array.of(...e.points,e.getPointX(0),e.getPointY(0)),i=this.simplifyPolyline(t);return i.length<8?t.slice(0,t.length-2):i.slice(0,i.length-2)}simplifyPolyline(e){if(e.length<4)return e;let t=0,i=0;for(let s=2;s<e.length-2;s+=2){let r=H(e[s],e[s+1],e[0],e[1],e[e.length-2],e[e.length-1]);r>t&&(i=s,t=r)}if(t>this.epsilon){let t=this.simplifyPolyline(e.slice(0,i+2)),s=this.simplifyPolyline(e.slice(i,e.length));return t.concat(s.slice(2,s.length))}return[e[0],e[1],e[e.length-2],e[e.length-1]]}toSVGPath(){return this.contours.map((e=>e.toSVGPath())).join(" ")}toJSON(){return{type:"Polygon",shape:this.shape.toJSON(),holes:this.holes.map((e=>e.toJSON())),holesDirection:this.holesDirection.name,vertices:this.verticesValue}}static fromJSON(e){if("Polygon"!=e.type)throw new Error(`Polygon deserialization failed. JSON type is ${e.type}, expected Polygon.`);let t=Y.fromJSON(e.shape),i=e.holes.map((e=>Y.fromJSON(e))),s=new W(t,i);return s.holesDirection=W.PointsDirection[e.holesDirection],s.vertices=e.vertices,s}static fromRect(e){return W.createInstance([e.left,e.top,e.right,e.top,e.right,e.bottom,e.left,e.bottom,e.left,e.top])}static createInstance(e,t=[]){return new W(Y.createInstance(e),t.map((e=>Y.createInstance(e))))}static createSharedInstance(e,t=[]){let i=new W(Y.createSharedInstance(e),t.map((e=>Y.createSharedInstance(e))));return Object.defineProperty(i,"encoding",{get:()=>i.shape.encoding,set:e=>{i.contours.forEach((t=>t.encoding=e))},enumerable:!0}),i}}Object.defineEnum(W,"PointsDirection",["CLOCKWISE","COUNTERCLOCKWISE"]);class Z{static ARRAY_TYPE=Array;#i;constructor(){this.keepAllData=!1,Object.defineProperty(this,"allData",{get:()=>{if(!this.keepAllData)throw new Error("All data is not accumulated. By default keepAllData property is false.");return this.#i||(this.#i=new this.constructor.ARRAY_TYPE),this.getOutput(this.#i,Z.OutputType.ALL_DATA)},enumerable:!0})}build(e,t=Z.OutputType.PROCESSOR,i=!0){return console.warn("use process instead"),this.process(e,t,i)}process(e,t=Z.OutputType.PROCESSOR,i=!0){let s;switch(t){case Z.OutputType.ADDITION:s=this.add(e,i);break;case Z.OutputType.PREDICTION:s=this.predict(e);break;case Z.OutputType.PROCESSOR:this.reset(),s=this.processImpl(e,t);break;default:throw new Error("Unexpected OutputType found. Allowed type is oneof(ADDITION, PREDICTION, PROCESSOR)")}return t!=Z.OutputType.PREDICTION&&this.keepAllData&&(this.#i||(this.#i=new this.constructor.ARRAY_TYPE),s instanceof W?this.#i.push(s):t==Z.OutputType.PROCESSOR?this.#i=s:this.#i.push(...s)),this.debug&&console.log(this.constructor.name,t.name,i,s),this.getOutput(s,t)}add(e,t=!1){return this.processImpl(e,Z.OutputType.ADDITION)}predict(e){return this.processImpl(e,Z.OutputType.PREDICTION)}processImpl(e,t){throw new Error("Abstract method processImpl(input, type) of DataSequenceProcessor should be implemented")}getOutput(e,t){return e}reset(){this.#i&&(this.#i=new this.constructor.ARRAY_TYPE)}}Object.defineEnum(Z,"OutputType",["ADDITION","PREDICTION","ALL_DATA","PROCESSOR"]);let K=h?h.default||globalThis.md5:{},Q={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],i=0;return this.mask.split("-").forEach((s=>{t.push(e.substring(i,i+s.length)),i+=s.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(K.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,i)=>{(i<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),i=this.toBytes(e);return t[0]=new Uint32Array(i.slice(0,4).buffer)[0],t[1]=new Uint32Array(i.slice(4,8).buffer)[0],t[2]=new Uint32Array(i.slice(8,12).buffer)[0],t[3]=new Uint32Array(i.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),i=this.toBytes(e);return t[0]=new BigUint64Array(i.slice(0,8).buffer)[0],t[1]=new BigUint64Array(i.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),i=this.toBytes(e);return t[0]=l.fromBytes(i.slice(0,8)),t[1]=l.fromBytes(i.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class ee{#s;constructor(e,t,i,s,r){1==i&&(t++,i=0),0==r&&(s--,r=1),Object.defineProperties(this,{spline:{value:e,enumerable:!0},segmentIndexStart:{value:t,enumerable:!0},segmentIndexEnd:{value:s,enumerable:!0},ts:{value:i,enumerable:!0},tf:{value:r,enumerable:!0}}),Object.defineProperty(this,"pointIndexStart",{value:t,enumerable:!0}),Object.defineProperty(this,"pointIndexEnd",{value:s+3,enumerable:!0}),Object.defineProperty(this,"length",{value:this.pointIndexEnd-this.pointIndexStart+1,enumerable:!0}),Object.defineProperty(this,"id",{get:()=>(this.#s||(this.#s=Q.generate()),this.#s),set:e=>{if(this.#s)throw new Error("id is immutable");this.#s=e}}),this.validate()}validate(){let e=this.length-3;if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.spline.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in spline index is ${this.spline.length-1}.`);if(this.ts<0||this.ts>=1)throw new Error(`Invalid fragment ts ${this.ts} found. The value must be in the interval [0, 1).`);if(this.tf<=0||this.tf>1)throw new Error(`Invalid fragment tf ${this.tf} found. The value must be in the interval (0, 1].`);if(e<1)throw new Error(`Invalid fragment points range {${this.pointIndexStart}, ${this.pointIndexEnd}} found. At least 4 points are needed to define spline.`);if(1==e&&this.ts>this.tf)throw new Error(`Invalid fragment T range ${this.ts} - ${this.tf} found. Spline has only one segment and ts <= tf.`)}union(e){let t=[this,e];t.sort(ee.compare);let i=t.first,s=t.last,r=i.segmentIndexEnd,n=i.tf;if(1==n&&(r++,n=0),r!=s.segmentIndexStart||n!=s.ts)throw new Error(`Fragments ${i} and ${s} are not adjacent.`);let a=new ee(this.spline,i.segmentIndexStart,i.ts,s.segmentIndexEnd,s.tf);return a.#s=this.#s,this.inside&&(a.inside=this.inside),a}overlaps(e){if(e.spline!=this.spline)return!1;let t=e.segmentIndexStart<this.segmentIndexEnd||e.segmentIndexStart==this.segmentIndexEnd&&e.ts<=this.tf,i=e.segmentIndexEnd>this.segmentIndexStart||e.segmentIndexEnd==this.segmentIndexStart&&e.tf>=this.ts;return t&&i}toString(){return`fragment(${this.segmentIndexStart}, ${this.ts} - ${this.segmentIndexEnd}, ${this.tf})`}static compare(e,t){return e.segmentIndexStart<t.segmentIndexStart?-1:e.segmentIndexStart>t.segmentIndexStart?1:e.ts<t.ts?-1:e.ts>t.ts?1:0}static getInstance(e,t,i){return new ee(e,t.segmentIndex,t.t,i.segmentIndex,i.t)}}class te extends Y{constructor(e,t,i,s=[]){super(t,i,e),s.length>0&&!Object.isFrozen(s.first)&&s.forEach((e=>Object.freeze(e))),Object.defineProperty(this,"splineParameters",{value:Object.freeze(s),enumerable:!0});let r=new j(e,i);Object.defineProperty(this,"style",{get:()=>r.style,set:e=>r.style.reset(e),enumerable:!0}),Object.defineProperty(this,"color",{get:()=>this.style.color,set:e=>{if(!e)throw new Error("Spline color cannot be removed");if(!(e instanceof B))throw new Error("Expected value should be Color instance");"red"in this.pointProps&&(this.pointProps.red=e.red),"green"in this.pointProps&&(this.pointProps.green=e.green),"blue"in this.pointProps&&(this.pointProps.blue=e.blue),"alpha"in this.pointProps&&(this.pointProps.alpha=e.alpha)},enumerable:!0}),Object.defineProperty(this,"bounds",{get:()=>V.ofSpline(this,this.pointProps.scattering).ceil(),enumerable:!0}),this.validate()}validate(){let e=this.points instanceof Float32Array;if(super.validate(),!this.layout.includes(w.Property.X))throw new Error("Layout doesn't contains required properties X");if(!this.layout.includes(w.Property.Y))throw new Error("Layout doesn't contains required properties Y");if(e&&0==this.points.length)throw new Error("Empty spline is not allowed")}clone(){return new te(this.layout.slice(),this.points.clone(),Object.clone(this.pointProps),this.splineParameters.slice())}slice(e){let t=this.slicePoints(e.pointIndexStart,e.pointIndexEnd);return new te(this.layout.slice(),t,Object.clone(this.pointProps),this.splineParameters.slice())}getPoint(e){return super.getPoint(e,this.style)}getPointRef(e){return super.getPointRef(e,this.style)}getPointSegmentIndex(e){return this.splineParameters[e]?this.splineParameters[e].index:void 0}getPointT(e){return this.splineParameters[e]?this.splineParameters[e].t:void 0}getPointParameter(e){return this.splineParameters[e]}toJSON(){return{type:"InterpolatedSpline",layout:this.layout.map((e=>e.name)),points:$.encode(this.points,this.encoding),pointProps:this.pointProps,splineParameters:this.splineParameters}}static fromJSON(e){let t=$.decode(e.points);return new te(e.layout.map((e=>w.Property[e])),t,e.pointProps,e.splineParameters.map(p.fromJSON))}static fromRect(e,t){throw new Error("InterpolatedSpline.fromRect is not supported. Try Spline.fromRect and interpolate with particular Spline interpolator.")}static createInstance(e,t,i=[]){return new te(e,i,t)}static createSharedInstance(e,t,i,s){return new te(e,Float32Array.createSharedInstance(t),i,s)}}const ie=s.fromValues(0,-.5,1,-.5,1,0,-2.5,1.5,0,.5,2,-1.5,0,0,-.5,.5);class se extends Z{#r;#n;#a;constructor(e=!1,t=!1){super(),this.calculateDerivates=e,this.keepSplineParameters=t,this.state={segmentIndex:-1,lastPointPosition:void 0,lastPointSize:0}}initState(e){this.state.layout={},e.layout.forEach(((e,t)=>{this.state.layout[e.name]={index:t,polynomials:i.create()}})),this.keepSplineParameters?this.state.splineParameters?this.state.splineParameters.clear():this.state.splineParameters=[]:delete this.state.splineParameters,this.splineLayout=e.layout,this.pathPointProps=Object.clone(e.pointProps),this.scattering&&(this.pathPointProps.scattering=this.scattering),this.layout=this.calculateDerivates?e.layout.concat([w.Property.D_X,w.Property.D_Y]):e.layout,this.state.ready=!0}predict(e){if(!e)return[];this.state.ready||this.initState(e),this.#n?this.#n.points.clear():this.#n=te.createInstance(this.layout,this.pathPointProps),this.path=this.#n;let t=Object.clone(this.state);return delete this.state.splineParameters,this.resetState(),this.discretize(e),this.state=t,this.path.points}processImpl(e,t){if(!e)return[];let i;return e instanceof ee&&(i=e,e=i.spline),this.state.ready||this.initState(e),t==se.OutputType.ADDITION?(this.#r?this.#r.points.clear():this.#r=te.createInstance(this.layout,this.pathPointProps),this.path=this.#r):(this.#a=te.createInstance(this.layout,this.pathPointProps),this.path=this.#a),this.discretize(e,i),this.path.points}getOutput(e,t){if(0!=e.length){if(t==se.OutputType.PROCESSOR||t==se.OutputType.ALL_DATA){let t=this.state.splineParameters;return t&&(t=t.slice()),te.createSharedInstance(this.layout,e,this.pathPointProps,t)}return this.path}}calculateInterpolatedPoint(e,t,s){this.initState(e);let r=new w(0,0,this.splineLayout.includes(w.Property.Z)?0:void 0),n=i.fromValues(1,s,s*s,s*s*s);return this.calculatePolynomials(e,t),this.splineLayout.forEach((e=>{let t=i.dot(this.state.layout[e.name].polynomials,n);r[_.getPropName(e.name)]=t})),r}discretize(e,t){throw new Error("This method is abstract and should be implemented")}storeLastPoint(e,t=0){this.state.lastPointPosition=new d(this.getPropValue(w.Property.X,e,t),this.getPropValue(w.Property.Y,e,t),this.getPropValue(w.Property.Z,e,t)),this.state.lastPointSize=this.getPropValue(w.Property.SIZE,e,t)}getPropValue(e,t,i=0){return this.state.layout[e.name]?t[i+this.state.layout[e.name].index]:void 0}calculatePolynomials(e,t){let s=e.points,r=this.splineLayout.length*(t+0),n=this.splineLayout.length*(t+1),a=this.splineLayout.length*(t+2),o=this.splineLayout.length*(t+3);this.splineLayout.forEach(((e,t)=>{let l=i.fromValues(s[r+t],s[n+t],s[a+t],s[o+t]);i.transformMat4(this.state.layout[e.name].polynomials,l,ie)}))}samplePoint(e){let t=[],s=i.fromValues(1,e,e*e,e*e*e);return this.splineLayout.forEach((e=>{let r=i.dot(this.state.layout[e.name].polynomials,s);t.push(r)})),this.calculateDerivates&&(t.push(this.getDerivativeOf(this.state.layout.X.polynomials,s)),t.push(this.getDerivativeOf(this.state.layout.Y.polynomials,s))),t}getDerivativeOf(e,t){let s=i.fromValues(e[1],2*e[2],3*e[3],0);return i.dot(s,t)}keepSegmentT(e){this.state.splineParameters&&this.state.splineParameters.push(new p(this.state.segmentIndex,e))}resetState(){this.state.segmentIndex=-1}reset(){super.reset(),this.state.ready=!1,this.state.lastPointPosition=void 0,this.state.lastPointSize=0,this.resetState(),this.#r=null,this.#n=null,this.#a=null}}class re extends se{constructor(e,t){super(e,t),this.state.lastSegmentIndex=-1,this.state.lastPointRotation=0,this.state.lastPointT=0,this.state.absAccumulatedErrorPos=0,this.state.absAccumulatedErrorS=0,this.setT=new v,this.samples=[],Object.defineProperty(this,"errorThreshold",{get:()=>this.error,set:e=>{this.error=e,this.errorDistSq=this.error*this.error,this.error10=10*this.error},enumerable:!0}),this.errorThreshold=.15}discretize(e,t){let i=this.path.points,s=0,r=e.segmentsCount-1,n=e.ts,a=e.tf;t&&(s=t.segmentIndexStart,r=t.segmentIndexEnd,n=t.ts,a=t.tf,this.state.segmentIndex=s-1);for(let t=s;t<r+1;t++){this.state.segmentIndex++,this.calculatePolynomials(e,t);let s=this.calculateTValues(t==r,n,a);i.push(...this.samplePoints(s)),s.length>0&&(this.resetAccumulatedErrors(),this.storeLastPoint(i))}}samplePoints(e){return this.samples.clear(),e.toArray().forEach((e=>{this.keepSegmentT(e),this.samples.push(...this.samplePoint(e))})),this.samples}storeLastPoint(e){let t=e.length-this.layout.length;super.storeLastPoint(e,t),this.state.lastPointRotation=this.getPropValue(w.Property.ROTATION,e,t),this.state.lastPointT=this.setT.max(),this.state.lastSegmentIndex=this.state.segmentIndex}calculateTValues(e,t,i){let s=0==this.state.segmentIndex?t:0,r=e?i:1;return this.setT.clear(),this.getTForPos(s,r),this.state.layout.SIZE&&this.getTForCubic(s,r,this.state.layout.SIZE.polynomials,this.error),this.mustAddStartT()&&this.setT.add(s),e&&this.setT.add(r),this.state.layout.ROTATION&&this.getTForRotation(s,r),this.setT}mustAddStartT(){if(this.state.lastSegmentIndex<0)return!0;let e=this.state.lastPointT-(this.state.segmentIndex-this.state.lastSegmentIndex),t=this.setT.length>0?this.setT.min():1,i=this.getPosErrorAtT0(t,this.state.lastPointPosition);if(this.state.absAccumulatedErrorPos+=Math.abs(i),this.state.layout.SIZE){let i=this.getErrorAtT0(this.state.layout.SIZE.polynomials,t,e,this.state.lastPointSize);this.state.absAccumulatedErrorS+=Math.abs(i)}return this.state.absAccumulatedErrorPos>this.errorDistSq||this.state.absAccumulatedErrorS>this.error}getPosErrorAtT0(e,t){let i=this.getTPoint(e),s=this.getTPoint(0);return this.minDistanceSq(t,i,s)}getErrorAtT0(e,t,i,s){let r=i,n=s,a=t,o=this.cubicCalc(e,a),l=this.cubicCalc(e,0),h=n+(0-r)*(o-n)/(a-r);return Math.abs(l-h)}getTForPos(e,t){let i=this.getTPoint(e),s=this.getTPoint(t),r=this.subdividePos(i,s);if(r.split)this.subdivideRecursivePos(i,r),this.setT.add(r.t),this.subdivideRecursivePos(r,s);else{let e=this.subdividePos(i,r),t=this.subdividePos(r,s);e.split&&(this.subdivideRecursivePos(i,e),this.setT.add(e.t),this.subdivideRecursivePos(e,r)),(e.split||t.split)&&this.setT.add(r.t),t.split&&(this.subdivideRecursivePos(r,t),this.setT.add(t.t),this.subdivideRecursivePos(t,s))}}subdivideRecursivePos(e,t){let i=this.subdividePos(e,t);i.split&&(this.subdivideRecursivePos(e,i),this.setT.add(i.t),this.subdivideRecursivePos(i,t))}subdividePos(e,t){let i=.5*(e.t+t.t),s=this.getTPoint(i),r=this.minDistanceSq(e,t,s),n=e.add(t).scaleSelf(.5),a=s.subtract(n).absSelf();return s.split=r>this.errorDistSq||a.x>this.error10||a.y>this.error10,this.state.layout.Z&&(s.split=s.split||a.z>this.error10),s}getTForCubic(e,t,i,s){let r={v:this.cubicCalc(i,e),t:e},n={v:this.cubicCalc(i,t),t:t},a=this.subdivide(r,n,i);if(a.diff>s)this.subdivideRecursive(r,a,i,s),this.setT.add(a.t),this.subdivideRecursive(a,n,i,s);else{let e=this.subdivide(r,a,i),t=this.subdivide(a,n,i);e.diff>s&&(this.subdivideRecursive(r,e,i,s),this.setT.add(e.t),this.subdivideRecursive(e,a,i,s)),(e.diff>s||t.diff>s)&&this.setT.add(a.t),t.diff>s&&(this.subdivideRecursive(a,t,i,s),this.setT.add(t.t),this.subdivideRecursive(t,n,i,s))}}subdivideRecursive(e,t,i,s){let r=this.subdivide(e,t,i);r.diff>s&&(this.subdivideRecursive(e,r,i,s),this.setT.add(r.t),this.subdivideRecursive(r,t,i,s))}subdivide(e,t,i){let s=.5*(e.t+t.t),r=this.cubicCalc(i,s),n=.5*(e.v+t.v);return{v:r,t:s,diff:Math.abs(r-n)}}getTForRotation(e,t){let i=this.state.layout.ROTATION.polynomials,s=this.state.lastPointRotation;this.state.lastSegmentIndex<0&&(s=this.cubicCalc(i,e));let r=.25*(t-e);for(let t=0;t<4;t++){let n=e+t*r,a=this.cubicCalc(i,n);Math.abs(a-s)>.06&&(this.setT.add(n),s=a)}}minDistanceSq(e,t,i){let s=i.vec,r=s.squaredDistance(e.value,t.value);if(0==r)retu...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/workers/SplitPointsProvider.mjs line 1
- Likely real
- Yes, 99% confidence
`t.replace` method will only replace the first occurrence when used with a string argument ("["). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
import"js-ext";import{vec2 as e,vec3 as t,vec4 as i,mat4 as s,quat2 as r,mat2d as n}from"gl-matrix";import*as a from"poly2tri";import*as o from"clipper-lib";import l from"long";import*as h from"js-md5";import u from"rbush";"function"==typeof Worker&&(Worker.prototype.on=function(e,t){this[`on${e}`]=i=>{let s="message"==e?i.data:i;t(s)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(e,t){this[`on${e}`]=i=>{let s="message"==e?i.data:i;t(s)}});class p{constructor(e,t){e>0&&0==t?(this.segmentIndex=e-1,this.t=1):(this.segmentIndex=e,this.t=t),Object.defineProperty(this,"index",{get:()=>(console.warn("SplineParameter index => segmentIndex"),this.segmentIndex)})}equals(e){return this.segmentIndex==e.segmentIndex&&this.t==e.t}toString(){return`spline-parameter(${this.segmentIndex}, ${this.t})`}toJSON(){return{segmentIndex:this.segmentIndex,t:this.t}}static fromJSON(e){return new p(e.segmentIndex,e.t)}static calcMiddleOfSegment(e,t){let i=.5*(e.t+t.t+(t.segmentIndex-e.segmentIndex)),s=Math.trunc(i),r=i-s;return new p(e.segmentIndex+s,r)}static areDistantEnough(e,t,i=.01){return t.t+(t.segmentIndex-e.segmentIndex)-e.t>i}}class c{constructor(e,t,i){this.splineParameter=e,this.segmentIndex=t,this.on=i}toString(){return`SplineSplitPoint: ${this.splineParameter.segmentIndex} T:${this.splineParameter.t} -> ${this.on?"ON":"OFF"}, split by ${this.segmentIndex}`}toJSON(){return{splineParameter:this.splineParameter.toJSON(),segmentIndex:this.segmentIndex,on:this.on}}static fromJSON(e){return new c(p.fromJSON(e.splineParameter),e.segmentIndex,e.on)}static compare(e,t){return e.splineParameter.segmentIndex<t.splineParameter.segmentIndex?-1:e.splineParameter.segmentIndex>t.splineParameter.segmentIndex?1:e.splineParameter.t<t.splineParameter.t?-1:e.splineParameter.t>t.splineParameter.t?1:0}}class d{constructor(s,r,n,a){if(isNaN(s))throw new Error(`Invalid x found: ${s}`);if(isNaN(r))throw new Error(`Invalid y found: ${r}`);let o=[s,r];isFinite(n)&&(o.push(n),isFinite(a)&&o.push(a)),this.value=o.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==o.length?this.vec=e:3==o.length?(this.vec=t,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=i,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),d.fromPoint(t)}addSelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),d.fromPoint(t)}subtractSelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),d.fromPoint(t)}multiplySelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),d.fromPoint(t)}divideSelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),d.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new d(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),d.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return d.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new d(e[0],e[1],e[2],e[3]):new d(e.x,e.y,e.z,e.w)}}const f={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},m=f.m11,g=f.m12,y=f.m21,P=f.m22,b=f.m41,E=f.m42;class S{constructor(e=s.create(),t=S.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let i=function(e,t){let i=f[e];this.value[i]=t};Object.defineProperty(this,"a",{get:()=>this.value[m],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[g],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[y],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[P],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[b],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[E],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[b],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[E],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:i.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:i.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:i.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:i.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:i.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:i.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:i.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:i.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:i.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:i.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new S(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(S.fromTranslate(e))}translateSelf(e){this.multiplySelf(S.fromTranslate(e))}rotate(e,t){return this.multiply(S.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(S.fromRotate(e,t))}scale(e,t){return this.multiply(S.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(S.fromScale(e,t))}multiply(e){return this.multiplicationType==S.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=s.create();return s.multiply(t,e.toFloat32Array(),this.value),new S(t,this.multiplicationType)}postMultiply(e){let t=s.create();return s.multiply(t,this.value,e.toFloat32Array()),new S(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==S.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){s.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){s.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=s.create();return s.invert(e,this.value),new S(e,this.multiplicationType)}invertSelf(){s.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return d.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let i=s.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(i[0]=parseFloat(e[0]),i[1]=parseFloat(e[1]),i[2]=parseFloat(e[2]),i[3]=parseFloat(e[3]),i[4]=parseFloat(e[4]),i[5]=parseFloat(e[5]),i[6]=parseFloat(e[6]),i[7]=parseFloat(e[7]),i[8]=parseFloat(e[8]),i[9]=parseFloat(e[9]),i[10]=parseFloat(e[10]),i[11]=parseFloat(e[11]),i[12]=parseFloat(e[12]),i[13]=parseFloat(e[13]),i[14]=parseFloat(e[14]),i[15]=parseFloat(e[15])):(i[m]=parseFloat(e[0]),i[g]=parseFloat(e[1]),i[y]=parseFloat(e[2]),i[P]=parseFloat(e[3]),i[b]=parseFloat(e[4]),i[E]=parseFloat(e[5]))}return new S(i,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof S)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new S(e,t);if("string"==typeof e)return S.fromString(e,t);let i=s.create(),r=Object.assign({},e);return isFinite(e.a)&&(r.m11=e.a),isFinite(e.b)&&(r.m12=e.b),isFinite(e.c)&&(r.m21=e.c),isFinite(e.d)&&(r.m22=e.d),isFinite(e.tx)?r.m41=e.tx:isFinite(e.e)?r.m41=e.e:isFinite(e.dx)&&(r.m41=e.dx),isFinite(e.ty)?r.m42=e.ty:isFinite(e.f)?r.m42=e.f:isFinite(e.dy)&&(r.m42=e.dy),isFinite(r.m11)&&(i[0]=r.m11),isFinite(r.m12)&&(i[1]=r.m12),isFinite(r.m13)&&(i[2]=r.m13),isFinite(r.m14)&&(i[3]=r.m14),isFinite(r.m21)&&(i[4]=r.m21),isFinite(r.m22)&&(i[5]=r.m22),isFinite(r.m23)&&(i[6]=r.m23),isFinite(r.m24)&&(i[7]=r.m24),isFinite(r.m31)&&(i[8]=r.m31),isFinite(r.m32)&&(i[9]=r.m32),isFinite(r.m33)&&(i[10]=r.m33),isFinite(r.m34)&&(i[11]=r.m34),isFinite(r.m41)&&(i[12]=r.m41),isFinite(r.m42)&&(i[13]=r.m42),isFinite(r.m43)&&(i[14]=r.m43),isFinite(r.m44)&&(i[15]=r.m44),new S(i,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return S.fromMatrix(t)}static fromRotate(e,t){let i=Math.sin(e),s=Math.cos(e),r={a:s,b:i,c:-i,d:s};return t&&(r.tx=t.x-t.x*s+t.y*i,r.ty=t.y-t.x*i-t.y*s),S.fromMatrix(r)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let i={a:e.x,d:e.y};return t&&(i.tx=t.x-t.x*e.x,i.ty=t.y-t.y*e.y),S.fromMatrix(i)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let i=S.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),s=S.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=i.invert().preMultiply(s);return S.fromMatrix({a:r.m11,b:r.m12,c:r.m21,d:r.m22,tx:r.m31,ty:r.m32})}static multiply(e,t){let i=s.create();return s.multiply(i,e.value,t.value),new S(i)}}S.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});class w extends d{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,i,s={}){super(e,t,i),this.red=s.red,this.green=s.green,this.blue=s.blue,this.alpha=s.alpha,this.size=s.size||w.defaults.size,this.rotation=s.rotation||w.defaults.rotation,this.scaleX=s.scaleX||w.defaults.scaleX,this.scaleY=s.scaleY||w.defaults.scaleY,this.scaleZ=isFinite(i)?s.scaleZ||w.defaults.scaleZ:void 0,this.offsetX=s.offsetX||w.defaults.offsetX,this.offsetY=s.offsetY||w.defaults.offsetY,this.offsetZ=isFinite(i)?s.offsetZ||w.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,i,s=0){let r=new w(0,0,e.includes(w.Property.Z)?0:void 0);return i&&r.fill(s,i,e,t),r}fill(e,t,i,s={}){let r={},n=e*i.length;i.forEach(((e,i)=>w.setProperty(r,e,t[n+i]))),this.x=r.x,this.y=r.y,this.z=r.z,this.red=isFinite(r.red)?r.red:s.red,this.green=isFinite(r.green)?r.green:s.green,this.blue=isFinite(r.blue)?r.blue:s.blue,this.alpha=isFinite(r.alpha)?r.alpha:s.alpha,this.size=r.size||s.size||w.defaults.size,this.rotation=r.rotation||s.rotation||w.defaults.rotation,this.scaleX=r.scaleX||s.scaleX||w.defaults.scaleX,this.scaleY=r.scaleY||s.scaleY||w.defaults.scaleY,this.scaleZ=isFinite(r.z)?r.scaleZ||s.scaleZ||w.defaults.scaleZ:void 0,this.offsetX=r.offsetX||s.offsetX||w.defaults.offsetX,this.offsetY=r.offsetY||s.offsetY||w.defaults.offsetY,this.offsetZ=isFinite(r.z)?r.offsetZ||s.offsetZ||w.defaults.offsetZ:void 0,this.dX=r.dX,this.dY=r.dY}getProperty(e){switch(e){case w.Property.X:return this.x;case w.Property.Y:return this.y;case w.Property.Z:return this.z;case w.Property.RED:return this.red;case w.Property.GREEN:return this.green;case w.Property.BLUE:return this.blue;case w.Property.ALPHA:return this.alpha;case w.Property.SIZE:return this.size;case w.Property.ROTATION:return this.rotation;case w.Property.SCALE_X:return this.scaleX;case w.Property.SCALE_Y:return this.scaleY;case w.Property.SCALE_Z:return this.scaleZ;case w.Property.OFFSET_X:return this.offsetX;case w.Property.OFFSET_Y:return this.offsetY;case w.Property.OFFSET_Z:return this.offsetZ;case w.Property.D_X:return this.dX;case w.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){w.setProperty(this,e,t)}static setProperty(e,t,i){switch(t){case w.Property.X:e.x=i;break;case w.Property.Y:e.y=i;break;case w.Property.Z:e.z=i;break;case w.Property.RED:e.red=i;break;case w.Property.GREEN:e.green=i;break;case w.Property.BLUE:e.blue=i;break;case w.Property.ALPHA:e.alpha=i;break;case w.Property.SIZE:e.size=i;break;case w.Property.ROTATION:e.rotation=i;break;case w.Property.SCALE_X:e.scaleX=i;break;case w.Property.SCALE_Y:e.scaleY=i;break;case w.Property.SCALE_Z:e.scaleZ=i;break;case w.Property.OFFSET_X:e.offsetX=i;break;case w.Property.OFFSET_Y:e.offsetY=i;break;case w.Property.OFFSET_Z:e.offsetZ=i;break;case w.Property.D_X:e.dX=i;break;case w.Property.D_Y:e.dY=i;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof S))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,i=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=i}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return w.Property.values.forEach((t=>{let i=this.getProperty(t);null!=i&&isFinite(i)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(w,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]);class I{constructor(e){this.key=e,this.height=1}leftRotate(){let e=this.right,t=e.left;return e.left=this,this.right=t,this.height=Math.max(I.height(this.left),I.height(this.right))+1,e.height=Math.max(I.height(e.left),I.height(e.right))+1,e}rightRotate(){let e=this.left,t=e.right;return e.right=this,this.left=t,this.height=Math.max(I.height(this.left),I.height(this.right))+1,e.height=Math.max(I.height(e.left),I.height(e.right))+1,e}getBalanceFactor(){return I.height(this.left)-I.height(this.right)}static height(e){return e?e.height:0}static minValue(e){if(!e)return;let t=e;for(;t.left;)t=t.left;return t.key}static maxValue(e){if(!e)return;let t=e;for(;t.right;)t=t.right;return t.key}}class O{constructor(){this.count=0,this.hasKey=!1,this.root}min(){return I.minValue(this.root)}max(){return I.maxValue(this.root)}add(e){return this.hasKey=!1,this.root=this.insertNode(this.root,e),this.hasKey||this.count++,!this.hasKey}insertNode(e,t){if(!e)return new I(t);if(t<e.key)e.left=this.insertNode(e.left,t);else{if(!(t>e.key))return this.hasKey=!0,e;e.right=this.insertNode(e.right,t)}if(!this.hasKey){e.height=1+Math.max(I.height(e.left),I.height(e.right));let i=e.getBalanceFactor();if(i>1){if(t<e.left.key)return e.rightRotate();if(t>e.left.key)return e.left=e.left.leftRotate(),e.rightRotate()}else if(i<-1){if(t>e.right.key)return e.leftRotate();if(t<e.right.key)return e.right=e.right.rightRotate(),e.leftRotate()}}return e}contains(e){return this.containsNode(this.root,e)}containsNode(e,t){return!!e&&(t<e.key?this.containsNode(e.left,t):!(t>e.key)||this.containsNode(e.right,t))}printTree(){if(!this.root)return;let e=[this.root],t=this.root.height;for(;e.length>0;){let i=e.shift();t!=i.height&&console.log("-"),console.log(`${i.key} with height: ${i.height}, balance: ${i.getBalanceFactor()}`),t=i.height;let s=i.left,r=i.right;s&&e.push(s),r&&e.push(r)}}toArray(){let e=[];return O.fillArray(e,this.root),e}static fillArray(e,t){t&&(this.fillArray(e,t.left),e.push(t.key),this.fillArray(e,t.right))}}class v{constructor(){this.tree=new O,Object.defineProperty(this,"length",{get:()=>this.tree.count,enumerable:!0})}clear(){this.tree=new O}add(e){return this.tree.add(e)}includes(e){return this.tree.contains(e)}min(){return this.tree.min()}max(){return this.tree.max()}toArray(){return this.tree.toArray()}}let x=a?a.default||globalThis.poly2tri:{};const{SweepContext:A,Point:R}=x;let T=o?o.default||globalThis.ClipperLib:{};const{Clipper:D,Paths:N,Path:F,ClipType:C,PolyType:M,PolyFillType:k}=T;class L{constructor(e,t,i){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:i,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.path.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in path index is ${this.path.length-1}.`)}toPath(){return this.path.slice(this)}toString(){return`fragment(${this.pointIndexStart} - ${this.pointIndexEnd})`}}class B{constructor(e,t,i,s=1){if(this.red=e,this.green=t,this.blue=i,this.alpha=s,s<0||s>1)throw new Error(`Invalid alpha ${s} found. The value must be in the interval [0, 1].`);Object.defineProperty(this,"hex",{get:()=>`#${this.red.toString(16).pad(2,"0")}${this.green.toString(16).pad(2,"0")}${this.blue.toString(16).pad(2,"0")}${Math.round(255*this.alpha).toString(16).pad(2,"0")}`,enumerable:!0})}premultiply(){return{red:this.red/255*this.alpha,green:this.green/255*this.alpha,blue:this.blue/255*this.alpha,alpha:this.alpha}}static postdivide(e,t,i,s){let r=parseInt(255*e/s),n=parseInt(255*t/s),a=parseInt(255*i/s);return new B(r,n,a,s)}equals(e){return e&&this.red==e.red&&this.green==e.green&&this.blue==e.blue&&this.alpha==e.alpha}toRGB(){return 1==this.alpha?this:new B(this.red,this.green,this.blue)}toRGBA(e){return new B(this.red,this.green,this.blue,e)}toHSLA(){let e=this.red/255,t=this.green/255,i=this.blue/255,s=Math.min(e,t,i),r=Math.max(e,t,i),n=0,a=0,o=(r+s)/2;if(r!=s){let l=r-s;switch(a=l/(1-Math.abs(2*o-1)),r){case e:n=(t-i)/l%6;break;case t:n=(i-e)/l+2;break;case i:n=(e-t)/l+4}}return n*=60,n<0&&(n+=360),{hue:parseFloat(n.toFixed(0)),saturation:parseFloat((100*a).toFixed(2)),lightness:parseFloat((100*o).toFixed(2)),alpha:this.alpha}}toArray(){return[this.red,this.green,this.blue,this.alpha]}toJSON(){return{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}}toString(){return 1==this.alpha?`rgb(${this.red}, ${this.green}, ${this.blue})`:`rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`}static isColor(e){return e&&isFinite(e.red)&&isFinite(e.green)&&isFinite(e.blue)}static fromColor(e){let t,i,s,r;if("string"==typeof e)if(e.startsWith("rgb"))e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),t=parseInt(e[0]),i=parseInt(e[1]),s=parseInt(e[2]),r=e[3]?parseInt(e[3]):1;else{if(!e.startsWith("#"))throw new Error(`Unknown input found: ${e}. Expected data starts with rgba, rgb or #.`);e=e.substring(1),t=parseInt(e.substring(0,2),16),i=parseInt(e.substring(2,4),16),s=parseInt(e.substring(4,6),16),r=8==e.length?parseInt(e.substring(6,8),16)/255:1}else Array.isArray(e)?(t=e[0],i=e[1],s=e[2],r=e[3]):(t=e.red,i=e.green,s=e.blue,r=e.alpha);return new B(t,i,s,r)}static fromHSLA(e=0,t=0,i=0,s){e/=60,t/=100,i/=100;let r=(1-Math.abs(2*i-1))*t,n=r*(1-Math.abs(e%2-1)),a=0,o=0,l=0;e>=0&&e<1?(a=r,o=n):e>=1&&e<2?(a=n,o=r):e>=2&&e<3?(o=r,l=n):e>=3&&e<4?(o=n,l=r):e>=4&&e<5?(a=n,l=r):(a=r,l=n);let h=i-r/2;return a+=h,o+=h,l+=h,new B(Math.round(255*a),Math.round(255*o),Math.round(255*l),s)}static random(e=!1){return new B(Math.randomInt(0,255),Math.randomInt(0,255),Math.randomInt(0,255),e?Math.random():1)}}B.TRANSPERENT=new B(0,0,0,0),B.BLACK=new B(0,0,0,1),B.WHITE=new B(255,255,255,1),B.RED=new B(255,0,0,1),B.GREEN=new B(0,255,0,1),B.BLUE=new B(0,0,255,1);let _={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let i=0;i<t.length;i++){let s=255&e;t[i]=s,e=(e-s)/256}return t},byteArrayToLong(e){let t=0;for(let i=e.length-1;i>=0;i--)t=256*t+e[i];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let i=t;for(let e=8;e--;)i=1&i?3988292384^i>>>1:i>>>1;e[t]=i}return function(t){let i=-1;for(let s=0,r=t.length;s<r;s++)i=i>>>8^e[255&i^t[s]];return(-1^i)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",i=Math.max(...e);for(let s=1;s<=i;s++)t+=e.includes(s)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],i=e.toString(2).split("").reverse();for(let e=0;e<i.length;e++)1==i[e]&&t.push(e+1);return t},mapTo:(e,t,i)=>i.min+(_.clamp(e,t)-t.min)/(t.max-t.min)*(i.max-i.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let i=null;return function(){let s=this,r=arguments;clearTimeout(i),i=setTimeout((function(){e.apply(s,r)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,i){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),i?e.toLowerCase():e};return function(i,s){return e.map((e=>function(e,t,i){let s="asc"===i?1:-1;return e>t?1*s:e<t?-1*s:0}(t(i,e.sortBy,e.ignoreCase),t(s,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let i=e.split("_"),s=i.first.toLowerCase();t&&(s=s.substring(0,1).toUpperCase()+s.substring(1));for(let e=1;e<i.length;e++)s+=i[e].substring(0,1),s+=i[e].substring(1).toLowerCase();return s},getEnumValueName(e){let t="";for(let i=0;i<e.length;i++)i>0&&e[i]!=e[i].toLowerCase()&&(t+="_"),t+=e[i];return t.toUpperCase()}};class j{constructor(e,t,i={}){this.layout=e,this.pointProps=t,this.sheet={};let s={};Object.defineProperties(s,{size:{get:this.getComputed.bind(this,"size"),set:this.setStyle.bind(this,"size"),enumerable:!0},red:{get:this.getComputed.bind(this,"red"),set:this.setStyle.bind(this,"red"),enumerable:!0},green:{get:this.getComputed.bind(this,"green"),set:this.setStyle.bind(this,"green"),enumerable:!0},blue:{get:this.getComputed.bind(this,"blue"),set:this.setStyle.bind(this,"blue"),enumerable:!0},alpha:{get:this.getComputed.bind(this,"alpha"),set:this.setStyle.bind(this,"alpha"),enumerable:!0},rotation:{get:this.getComputed.bind(this,"rotation"),set:this.setStyle.bind(this,"rotation"),enumerable:!0},scaleX:{get:this.getComputed.bind(this,"scaleX"),set:this.setStyle.bind(this,"scaleX"),enumerable:!0},scaleY:{get:this.getComputed.bind(this,"scaleY"),set:this.setStyle.bind(this,"scaleY"),enumerable:!0},scaleZ:{get:this.getComputed.bind(this,"scaleZ"),set:this.setStyle.bind(this,"scaleZ"),enumerable:!0},offsetX:{get:this.getComputed.bind(this,"offsetX"),set:this.setStyle.bind(this,"offsetX"),enumerable:!0},offsetY:{get:this.getComputed.bind(this,"offsetY"),set:this.setStyle.bind(this,"offsetY"),enumerable:!0},offsetZ:{get:this.getComputed.bind(this,"offsetZ"),set:this.setStyle.bind(this,"offsetZ"),enumerable:!0},color:{get:this.getComputed.bind(this,"color"),set:this.setStyle.bind(this,"color"),enumerable:!0},blendMode:{get:this.getComputed.bind(this,"blendMode"),set:this.setStyle.bind(this,"blendMode"),enumerable:!0},visibility:{get:this.getComputed.bind(this,"visibility"),set:this.setStyle.bind(this,"visibility"),enumerable:!0},reset:{value:e=>{e&&(i=e),this.clear(),Object.keys(i).forEach((e=>this.setStyle(e,i[e])))}},clear:{value:this.clear.bind(this)}}),this.style=Object.freeze(s),this.style.reset(i)}setStyle(e,t){if(null==t&&(t=void 0),j.validate(this.layout,e,t),"color"==e&&t)return this.sheet.red=t.red,this.sheet.green=t.green,this.sheet.blue=t.blue,void(this.sheet.alpha=t.alpha);null==t?delete this.sheet[e]:this.sheet[e]=t}getStyle(e){let t=this.sheet[e];return"visibility"==e?"boolean"!=typeof t&&(t=!0):"color"==e&&B.isColor(this.sheet)&&(t=B.fromColor(this.sheet)),t}getComputed(e){let t=this.getStyle(e);if(null==t)if("color"==e){let e={red:isFinite(this.sheet.red)?this.sheet.red:this.pointProps.red,green:isFinite(this.sheet.green)?this.sheet.green:this.pointProps.green,blue:isFinite(this.sheet.blue)?this.sheet.blue:this.pointProps.blue,alpha:isFinite(this.sheet.alpha)?this.sheet.alpha:this.pointProps.alpha};B.isColor(e)&&(t=B.fromColor(e))}else t=this.pointProps[e];return t}clear(){this.sheet={}}static validate(e,t,i,s){let r;if(i&&e.includes(w.Property[_.getEnumValueName(t)])){if(!s)throw new Error(`Property ${t} value ${i} is not applicable. This is a dynamic property and is part of the layout.`);console.warn(`Property ${t} value ${i} is not applicable. This is a dynamic property and is part of the layout.`),i=void 0}if("color"==t)!i||i instanceof B||(r=`Property ${t} is not an instance of Color`);else if("blendMode"==t)""==i&&(i=void 0);else if("number"==typeof i)if("size"==t)i<0?r=`Property ${t} with value ${i} is not allowed. Value should be a positive number.`:0==i&&(i=void 0);else if("red"==t||"green"==t||"blue"==t||"alpha"==t){let e="alpha"==t?{min:0,max:1}:{min:0,max:255};i>=e.min&&i<=e.max||(r=`Property ${t} with value ${i} is out of range. Allowd range: [${e.min}, ${e.max}].`)}else"rotation"==t?0==i&&(i=void 0):"scattering"==t&&i<0&&(i=void 0);if(r)throw new Error(r);return i}}class ${static encode(e,t=$.Encoding.AUTO){let i;if(t==$.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?$.Encoding.NONE:$.Encoding.ARRAY:$.Encoding.BUFFER:t==$.Encoding.ARRAY&&e instanceof Array&&(t=$.Encoding.NONE),t==$.Encoding.NONE)i=e;else if(t==$.Encoding.ARRAY)i=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let s=Buffer.from(e.buffer);switch(t){case $.Encoding.BUFFER:i=s.toJSON();break;case $.Encoding.BASE64:i=s.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:i}}static decode(e){let t,i=$.Encoding[e.encoding];if(i==$.Encoding.NONE)t=e.content;else if(i==$.Encoding.ARRAY)t=e.content.toFloat32Array();else{let s;switch(i){case $.Encoding.BUFFER:s="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case $.Encoding.BASE64:s="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${i.name}`)}let r=new Uint8Array(s);t=new globalThis[e.type](r.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum($,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);const U=[w.Property.X,w.Property.Y];class Y{#e;#t;constructor(e,t={},i=U){if(this.#e=e,Object.defineProperty(this,"points",{get:()=>this.#e,set:e=>{if(this.#e instanceof Float32Array)throw new Error("Points setter is not accessible wehn points type is Float32Array.");this.#e=e,this.validate()},enumerable:!0}),Object.defineProperty(this,"buffer",{get:()=>this.#e.buffer,set:e=>{if(Array.isArray(this.#e))throw new Error("Underlying points buffer is Array. This property is applicable for TypedArray only.");if("undefined"!=typeof SharedArrayBuffer&&this.#e.buffer instanceof SharedArrayBuffer)throw new Error("Underlying buffer is SharedArrayBuffer and cannot be restored");if(this.#e.buffer.byteLength>0)throw new Error("Cannot restore buffer when underlying buffer is not empty");if(e.byteLength/Float32Array.BYTES_PER_ELEMENT/this.stride!=this.length)throw new Error("Value exceeds expected memory length");this.#e=new Float32Array(e)}}),!Object.isSealed(t))for(let e in t)void 0!==t[e]&&(t[e]=j.validate(i,e,t[e],!0));i.includes(w.Property.ROTATION)||"rotation"in t||(t.rotation=void 0),i.includes(w.Property.SIZE)||t.size||(t.size=1),Object.defineProperties(this,{stride:{value:i.length,enumerable:!0},layout:{value:Object.freeze(i),enumerable:!0},pointProps:{value:Object.seal(t),enumerable:!0}}),e instanceof Float32Array?Object.defineProperty(this,"length",{value:this.#e.length/this.stride,enumerable:!0}):Object.defineProperty(this,"length",{get:()=>this.#e.length/this.stride,enumerable:!0}),i.forEach(((e,t)=>{let i=_.getPropName(e.name,!0);Object.defineProperty(this,`setPoint${i}`,{value:this.setPointPropertyValue.bind(this,t)}),Object.defineProperty(this,`getPoint${i}`,{value:this.getPointPropertyValue.bind(this,t)})}))}validate(){if(this.points.length%this.stride!=0)throw new Error("Path length doesn't match the stride provided via the layout")}setPointPropertyValue(e,t,i){if(isNaN(t))throw new Error("Point index is required");if(t>=this.length||t<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);if(isNaN(i))throw new Error("value is required");this.points[t*this.layout.length+e]=i}getPointPropertyValue(e,t){if(isNaN(t))throw new Error("Point index is required");if(t>=this.length||t<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);return this.points[t*this.layout.length+e]}setPoint(e,t){let i=e*this.stride;this.layout.forEach(((e,s)=>this.points[i+s]=t.getProperty(e)))}getPoint(e,t=this.pointProps){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);return w.createInstance(this.layout,t,this.points,e)}getPointRef(e,t=this.pointProps){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);return this.#t||(this.#t=w.createInstance(this.layout)),this.#t.fill(e,this.points,this.layout,this.pointProps),this.#t}getChannelData(e){let t=new([w.Property.RED,w.Property.GREEN,w.Property.BLUE].includes(e)?Uint8Array:Float32Array)(this.length),i=this.layout.indexOf(e);if(-1==i)throw new Error(`Property ${e.name} is not part from the spline layout ${this.layout.map((e=>e.name)).join(", ")}`);for(let e=0;e<this.length;e++)t[e]=this.points[e*this.stride+i];return t}transform(e){let t=e.scaleX,s=e.rotation;for(let r=0;r<this.length;r++){let n=r*this.stride,a=i.fromValues(this.getPointX(r),this.getPointY(r),0,1);i.transformMat4(a,a,e.value);for(let e=0;e<this.stride;e++){let i=n+e;switch(this.layout[e]){case w.Property.X:this.points[i]=a[0]/a[3];break;case w.Property.Y:this.points[i]=a[1]/a[3];break;case w.Property.Z:this.points[i]=a[2]/a[3];break;case w.Property.ROTATION:this.points[i]+=s;break;case w.Property.SIZE:this.points[i]*=t}}}this.layout.includes(w.Property.ROTATION)||(this.pointProps.rotation=0==s?void 0:s)}clone(){return new Y(this.#e.clone(),Object.clone(this.pointProps),this.layout.slice())}getFragment(e=0,t=this.length-1){return new L(this,e,t)}slice(e){let t=this.slicePoints(e.pointIndexStart,e.pointIndexEnd);return new Y(t,Object.clone(this.pointProps),this.layout.slice())}validateFragment(e,t){if(e<0)throw new Error(`Invalid fragment pointIndexStart ${e} found. The value must be non-negative.`);if(t>this.length-1)throw new Error(`Invalid fragment pointIndexEnd ${t} found. Last point in path index is ${this.length-1}.`)}slicePoints(e,t){let i;if(this.validateFragment(e,t),"undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let s=this.points.subarray(e*this.stride,(t+1)*this.stride),r=new SharedArrayBuffer(s.length*Float32Array.BYTES_PER_ELEMENT);i=new Float32Array(r),i.set(s)}else i=this.points.slice(e*this.stride,(t+1)*this.stride);return i}toSVGPath(){let e=[];for(let t=0;t<this.length;t++)e.push(`${this.getPointX(t)},${this.getPointY(t)}`);return`M ${e.join(" L ")} Z`}toJSON(){return{type:"Path",points:$.encode(this.#e,this.encoding),pointProps:this.pointProps,layout:this.layout.map((e=>e.name))}}static fromJSON(e){if("Path"!=e.type)throw new Error(`Path deserialization failed. JSON type is ${e.type}, expected Path.`);return new Y($.decode(e.points),e.pointProps,e.layout.map((e=>w.Property[e])))}static fromRect(e,t){let i=[e.left,e.top,e.right,e.top,e.right,e.bottom,e.left,e.bottom,e.left,e.top];return new Y(i,t)}static createInstance(e,t,i){return new Y(e,t,i)}static createSharedInstance(e,t,i){return new Y(Float32Array.createSharedInstance(e),t,i)}}class G{constructor(e,t){if(!Array.isArray(e))throw new Error("Unexpected polygons type found");let i=65534/(t.width+1e-16),s=65534/(t.height+1e-16),r=Math.floor(Math.min(i,s));if(0==r)throw new Error(`Insufficent clipper range - (-32767 - 32767), scale failed - scaleX: ${i}, scaleY: ${s}`);let n=t.left+32767/r,a=t.top+32767/r;this.solution=new N,this.bounds=t,this.transform={scale:r,offsetX:n,offsetY:a},this.subject=this.apply(e)}convertPoint(e){let t=(e.x-this.transform.offsetX)*this.transform.scale,i=(e.y-this.transform.offsetY)*this.transform.scale;return{X:t<0?Math.ceil(t):Math.floor(t),Y:i<0?Math.ceil(i):Math.floor(i)}}containsPoint(e){return D.PointInPolygon(this.convertPoint(e),this.solution)}apply(e){let t=new N;for(let i of e){let e=new F,s=i.shape;for(let t=0;t<s.length;t++)e.push(this.convertPoint({x:s.getPointX(t),y:s.getPointY(t)}));t.push(e)}return t}toPaths(){let e=[];this.lastPoint={};for(let t of this.solution){if(0==t.length)continue;let i=this.flatPath(t);i.length>0&&e.push(i)}return e}flatPath(e){let t=[];for(let i of e)this.lastPoint.X==i.X&&this.lastPoint.Y==i.Y||(t.push(i.X/this.transform.scale+this.transform.offsetX,i.Y/this.transform.scale+this.transform.offsetY),this.lastPoint=i);return t.length<6&&(console.warn(`Invalid contour found: [${t.join(", ")}]`),t.clear()),t}}class X{constructor(e=2){this.stride=e}sort(e,t){return this.sortArrayPart(e,0,e.length-this.stride,t),e}partition(e,t,i,s){let r=e[i],n=e[i+1],a=t-this.stride;for(let o=t;o<i;o+=2)s?s(r,n,e[o],e[o+1])&&(a+=this.stride,this.swap(e,a,o)):(r>e[o]||r==e[o]&&n>e[o+1])&&(a+=this.stride,this.swap(e,a,o));return this.swap(e,a+this.stride,i),a+this.stride}swap(e,t,i){let s=e[t],r=e[t+1];return e[t]=e[i],e[t+1]=e[i+1],e[i]=s,e[i+1]=r,e}sortArrayPart(e,t,i,s){if(t<i){let r=this.partition(e,t,i,s);this.sortArrayPart(e,t,r-this.stride,s),this.sortArrayPart(e,r+this.stride,i,s)}}}function z(e,t,i,s,r,n){return(i-e)*(n-t)-(s-t)*(r-e)}function H(e,t,i,s,r,n){let a=e-i,o=r-i,l=a*(n-s)-o*(t-s);l*=l,a=r-i,o=n-s;let h=a*a+o*o;return h>0?Math.sqrt(l/h):Math.sqrt((i-e)*(i-e)+(s-t)*(s-t))}class q{constructor(e=Float32Array){this.ArrayType=e,this.quickSort=new X}monotoneChain(e){if(e.length<=0)return new this.ArrayType;this.quickSort.sort(e);let t=new this.ArrayType(e.length),i=0;for(let s=0;s<e.length;s+=2){for(;i>=4&&z(t[i-4],t[i-3],t[i-2],t[i-1],e[s],e[s+1])<=0;)i-=2;t[i]=e[s],t[i+1]=e[s+1],i+=2}t=t.slice(0,i);let s,r=new this.ArrayType(e.length);i=0;for(let t=e.length-2;t>=0;t-=2){for(;i>=4&&z(r[i-4],r[i-3],r[i-2],r[i-1],e[t],e[t+1])<=0;)i-=2;r[i]=e[t],r[i+1]=e[t+1],i+=2}if(r=r.slice(0,i-2),this.ArrayType==Float32Array){let e=r.length+t.length;s=Float32Array.createSharedInstance(e),s.set(r),s.set(t,r.length)}else s=r.concat(t);return s}}class J{constructor(e,t,i,s){let r=e,n=t,a=e+i,o=t+s;Object.defineProperties(this,{left:{value:r,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:a,enumerable:!0},top:{value:o,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0}})}union(e){if(e&&!(e instanceof J))throw new TypeError("rect must be instance of RectGL");return e?J.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof J))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=J.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return J.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return J.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=d.fromPoint({x:this.left,y:this.bottom}).transform(e),i=d.fromPoint({x:this.right,y:this.bottom}).transform(e),s=d.fromPoint({x:this.left,y:this.top}).transform(e),r=d.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(s.x,r.x,t.x,i.x),a=Math.min(s.y,r.y,t.y,i.y),o=Math.max(s.x,r.x,t.x,i.x),l=Math.max(s.y,r.y,t.y,i.y);return J.ofEdges(n,a,o,l)}toQuad(e){let t;if(e){let i=d.fromPoint({x:this.left,y:this.bottom}).transform(e),s=d.fromPoint({x:this.right,y:this.bottom}).transform(e),n=d.fromPoint({x:this.left,y:this.top}).transform(e),a=d.fromPoint({x:this.right,y:this.top}).transform(e);t=r.fromValues(i.x,i.y,s.x,s.y,n.x,n.y,a.x,a.y)}else t=r.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,i,s){return new J(e,t,i-e,s-t)}static calculateBrushGLSegmentBounds(e,t=0,i){let s,r=.5*e.size,n=Math.abs(t*r);if(i){s=new d(e.x,e.y,e.x,e.z).transform(i)}else s=e;let a=s.x,o=s.y,l=e.scaleX*r,h=e.scaleY*r,u=e.offsetX,p=-e.offsetY,c=Math.cos(e.rotation),f=Math.sin(e.rotation),m=Number.MAX_SAFE_INTEGER,g=Number.MIN_SAFE_INTEGER,y=Number.MAX_SAFE_INTEGER,P=Number.MIN_SAFE_INTEGER;for(let e of J.SQURE){let t=e.x*l+u,i=e.y*h+p,s=c*t+f*i+a,r=-f*t+c*i+o,d=s-n;m=Math.min(m,d),g=Math.max(g,d),d=s+n,m=Math.min(m,d),g=Math.max(g,d);let b=r-n;y=Math.min(y,b),P=Math.max(P,b),b=r+n,y=Math.min(y,b),P=Math.max(P,b)}return J.ofEdges(m,y,g,P)}}Object.defineProperty(J,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class V{constructor(e,t,i,s){let r,n,a,o=e,l=t,h=e+i,u=t+s;Object.defineProperties(this,{left:{value:o,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:u,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0},size:{get:()=>(r||(r={width:i,height:s}),r),enumerable:!0},area:{get:()=>(n||(n=i*s),n),enumerable:!0},center:{get:()=>(a||(a={x:(o+h)/2,y:(l+u)/2}),a),enumerable:!0}})}union(e){return e?V.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=V.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),i=Math.floor(this.top),s=Math.ceil(this.right),r=Math.ceil(this.bottom);if(e){let e=s-t,n=r-i;e+=e%2,n+=n%2,s=t+e,r=i+n}return V.ofEdges(t,i,s,r)}floor(e){let t=Math.ceil(this.left),i=Math.ceil(this.top),s=Math.floor(this.right),r=Math.floor(this.bottom);if(e){let e=s-t,n=r-i;e-=e%2,n-=n%2,s=t+e,r=i+n}return V.ofEdges(t,i,s,r)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=d.fromPoint({x:this.left,y:this.top}).transform(e),i=d.fromPoint({x:this.right,y:this.top}).transform(e),s=d.fromPoint({x:this.left,y:this.bottom}).transform(e),r=d.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,i.x,s.x,r.x),a=Math.min(t.y,i.y,s.y,r.y),o=Math.max(t.x,i.x,s.x,r.x),l=Math.max(t.y,i.y,s.y,r.y);return V.ofEdges(n,a,o,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new J(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof J))throw new TypeError("rect must be instance of RectGL");return new V(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new V(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?V.fromString(e):new V(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let a=e.getPointX(n),o=e.getPointY(n);t=Math.min(t,a),i=Math.min(i,o),s=Math.max(s,a),r=Math.max(r,o)}return V.ofEdges(t,i,s,r)}static ofSpline(e,t=0){let i;for(let s=0;s<e.length;s++)i=J.calculateBrushGLSegmentBounds(e.getPointRef(s),t).union(i);return V.fromGLRect(i)}static ofEdges(e,t,i,s){let r=Math.min(e,i),n=Math.min(t,s),a=Math.max(e,i),o=Math.max(t,s);return new V(r,n,a-r,o-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}class W{constructor(e,t=[]){if(!(e instanceof Y))throw new Error("Expected shape type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");if(t.some((e=>!(e instanceof Y))))throw new Error("Expected hole type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");let i;this.holesDirection=W.PointsDirection.CLOCKWISE,Object.defineProperty(this,"shape",{value:e,enumerable:!0}),Object.defineProperty(this,"holes",{value:t,enumerable:!0}),Object.defineProperty(this,"contours",{value:[e,...t],enumerable:!0}),Object.defineProperty(this,"ArrayType",{value:e.points instanceof Float32Array?Float32Array:Array}),Object.defineProperty(this,"bounds",{get:()=>V.ofPolygon(this),enumerable:!0}),Object.defineProperty(this,"vertices",{get:()=>(i||(i=this.triangulate()),i),set:e=>i=e,enumerable:!0}),Object.defineProperty(this,"verticesValue",{get:()=>i})}clone(e=!1){let t=this.shape.clone(e),i=this.holes.map((t=>t.clone(e))),s=new W(t,i);return this.verticesValue&&(s.vertices=this.vertices.slice()),s}fit(e){let t=this.bounds,i=e.width/t.width,s=e.height/t.height,r=i>0&&s>0?Math.min(i,s):Math.max(i,s);for(let e of this.contours)for(let t=0;t<e.length;t++)e.setPointX(t,e.getPointX(t)*r),e.setPointY(t,e.getPointY(t)*r)}center(){let e=this.bounds;for(let t of this.contours)for(let i=0;i<t.length;i++)t.setPointX(i,t.getPointX(i)-e.center.x),t.setPointY(i,t.getPointY(i)-e.center.y)}transform(e){this.contours.forEach((t=>t.transform(e)))}intersects(e){if(!(e instanceof W))throw new Error("Expected 'poly' type is Polygon");(this.holes.length>0||e.holes.length)&&console.warn("Polygon intersection is for contours only. Holes are ignored.");let t=this.shape,i=e.shape;for(let e=0;e<2;e++){let s=0==e?t:i;for(let e=0;e<s.length;e++){let r=e+1==s.length?0:e+1,n=s.getPointX(e),a=s.getPointY(e),o=s.getPointX(r),l=s.getPointY(r)-a,h=n-o,u=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY;for(let e=0;e<t.length;e++){let i=l*t.getPointX(e)+h*t.getPointY(e);i<u&&(u=i),i>p&&(p=i)}let c=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY;for(let e=0;e<i.length;e++){let t=l*i.getPointX(e)+h*i.getPointY(e);t<c&&(c=t),t>d&&(d=t)}if(p<c||d<u)return!1}}return!0}containsPoint(e){let t=!1,i=this.shape;this.holes.length>0&&console.warn("Polygon intersection is for contours only. Holes are ignored.");for(let s=0,r=i.length-1;s<i.length;r=s++)i.getPointY(s)>e.y!=i.getPointY(r)>e.y&&e.x<(i.getPointX(r)-i.getPointX(s))*(e.y-i.getPointY(s))/(i.getPointY(r)-i.getPointY(s))+i.getPointX(s)&&(t=!t);return t}triangulate(){let e,t=[];for(let e of this.contours){let i=[];for(let t=0;t<e.length;t++){let s=new R(e.getPointX(t),e.getPointY(t));if(t>0){if(i.last.x==s.x&&i.last.y==s.y)continue;if(t==e.length-1&&i.first.x==s.x&&i.first.y==s.y)continue}i.push(s)}t.push(i)}try{e=new A(t.shift())}catch(e){return console.error(e),new Float32Array}for(let i of t)try{e.addHole(i)}catch(e){return console.error(e),new Float32Array}try{e.triangulate()}catch(e){return console.warn(e),new Float32Array}let i=e.getTriangles(),s=Float32Array.createSharedInstance(6*i.length),r=0;for(let e of i){let t=e.getPoints();for(let e of t)s[r++]=e.x,s[r++]=e.y}return s}convex(){return this.buildConvex(this.shape.points)}union(e){let t=Array.of(...this.shape.points,...e.shape.points);return this.buildConvex(t)}buildConvex(e){this.convexHullProducer||(this.convexHullProducer=new q(this.ArrayType));let t=this.convexHullProducer.monotoneChain(e);return this.ArrayType==Float32Array?W.createSharedInstance(t):W.createInstance(t)}simplify(e=.1){let t=new G([this],this.bounds);return t.subject=D.SimplifyPolygons(t.subject,k.pftNonZero),t.solution=D.CleanPolygons(t.subject,e*t.transform.scale),1==t.subject.length&&0==t.solution.first.length&&(t.solution=t.subject),W.toPolygonArray(t.toPaths())}simplifyRamerDouglasPeucker(e=.1){if(e<=0)throw new Error("epsilon expected value > 0");this.epsilon=e;let t=this.simplifyPath(this.shape),i=[];for(let e of this.holes){let t=this.simplifyPath(e);t.length>0&&i.push(t)}return this.ArrayType==Float32Array?W.createSharedInstance(t,i):W.createInstance(t,i)}simplifyPath(e){if(e.length<3)return e.points;let t=Array.of(...e.points,e.getPointX(0),e.getPointY(0)),i=this.simplifyPolyline(t);return i.length<8?t.slice(0,t.length-2):i.slice(0,i.length-2)}simplifyPolyline(e){if(e.length<4)return e;let t=0,i=0;for(let s=2;s<e.length-2;s+=2){let r=H(e[s],e[s+1],e[0],e[1],e[e.length-2],e[e.length-1]);r>t&&(i=s,t=r)}if(t>this.epsilon){let t=this.simplifyPolyline(e.slice(0,i+2)),s=this.simplifyPolyline(e.slice(i,e.length));return t.concat(s.slice(2,s.length))}return[e[0],e[1],e[e.length-2],e[e.length-1]]}toSVGPath(){return this.contours.map((e=>e.toSVGPath())).join(" ")}toJSON(){return{type:"Polygon",shape:this.shape.toJSON(),holes:this.holes.map((e=>e.toJSON())),holesDirection:this.holesDirection.name,vertices:this.verticesValue}}static fromJSON(e){if("Polygon"!=e.type)throw new Error(`Polygon deserialization failed. JSON type is ${e.type}, expected Polygon.`);let t=Y.fromJSON(e.shape),i=e.holes.map((e=>Y.fromJSON(e))),s=new W(t,i);return s.holesDirection=W.PointsDirection[e.holesDirection],s.vertices=e.vertices,s}static fromRect(e){return W.createInstance([e.left,e.top,e.right,e.top,e.right,e.bottom,e.left,e.bottom,e.left,e.top])}static createInstance(e,t=[]){return new W(Y.createInstance(e),t.map((e=>Y.createInstance(e))))}static createSharedInstance(e,t=[]){let i=new W(Y.createSharedInstance(e),t.map((e=>Y.createSharedInstance(e))));return Object.defineProperty(i,"encoding",{get:()=>i.shape.encoding,set:e=>{i.contours.forEach((t=>t.encoding=e))},enumerable:!0}),i}}Object.defineEnum(W,"PointsDirection",["CLOCKWISE","COUNTERCLOCKWISE"]);class Z{static ARRAY_TYPE=Array;#i;constructor(){this.keepAllData=!1,Object.defineProperty(this,"allData",{get:()=>{if(!this.keepAllData)throw new Error("All data is not accumulated. By default keepAllData property is false.");return this.#i||(this.#i=new this.constructor.ARRAY_TYPE),this.getOutput(this.#i,Z.OutputType.ALL_DATA)},enumerable:!0})}build(e,t=Z.OutputType.PROCESSOR,i=!0){return console.warn("use process instead"),this.process(e,t,i)}process(e,t=Z.OutputType.PROCESSOR,i=!0){let s;switch(t){case Z.OutputType.ADDITION:s=this.add(e,i);break;case Z.OutputType.PREDICTION:s=this.predict(e);break;case Z.OutputType.PROCESSOR:this.reset(),s=this.processImpl(e,t);break;default:throw new Error("Unexpected OutputType found. Allowed type is oneof(ADDITION, PREDICTION, PROCESSOR)")}return t!=Z.OutputType.PREDICTION&&this.keepAllData&&(this.#i||(this.#i=new this.constructor.ARRAY_TYPE),s instanceof W?this.#i.push(s):t==Z.OutputType.PROCESSOR?this.#i=s:this.#i.push(...s)),this.debug&&console.log(this.constructor.name,t.name,i,s),this.getOutput(s,t)}add(e,t=!1){return this.processImpl(e,Z.OutputType.ADDITION)}predict(e){return this.processImpl(e,Z.OutputType.PREDICTION)}processImpl(e,t){throw new Error("Abstract method processImpl(input, type) of DataSequenceProcessor should be implemented")}getOutput(e,t){return e}reset(){this.#i&&(this.#i=new this.constructor.ARRAY_TYPE)}}Object.defineEnum(Z,"OutputType",["ADDITION","PREDICTION","ALL_DATA","PROCESSOR"]);let K=h?h.default||globalThis.md5:{},Q={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],i=0;return this.mask.split("-").forEach((s=>{t.push(e.substring(i,i+s.length)),i+=s.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(K.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,i)=>{(i<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),i=this.toBytes(e);return t[0]=new Uint32Array(i.slice(0,4).buffer)[0],t[1]=new Uint32Array(i.slice(4,8).buffer)[0],t[2]=new Uint32Array(i.slice(8,12).buffer)[0],t[3]=new Uint32Array(i.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),i=this.toBytes(e);return t[0]=new BigUint64Array(i.slice(0,8).buffer)[0],t[1]=new BigUint64Array(i.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),i=this.toBytes(e);return t[0]=l.fromBytes(i.slice(0,8)),t[1]=l.fromBytes(i.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class ee{#s;constructor(e,t,i,s,r){1==i&&(t++,i=0),0==r&&(s--,r=1),Object.defineProperties(this,{spline:{value:e,enumerable:!0},segmentIndexStart:{value:t,enumerable:!0},segmentIndexEnd:{value:s,enumerable:!0},ts:{value:i,enumerable:!0},tf:{value:r,enumerable:!0}}),Object.defineProperty(this,"pointIndexStart",{value:t,enumerable:!0}),Object.defineProperty(this,"pointIndexEnd",{value:s+3,enumerable:!0}),Object.defineProperty(this,"length",{value:this.pointIndexEnd-this.pointIndexStart+1,enumerable:!0}),Object.defineProperty(this,"id",{get:()=>(this.#s||(this.#s=Q.generate()),this.#s),set:e=>{if(this.#s)throw new Error("id is immutable");this.#s=e}}),this.validate()}validate(){let e=this.length-3;if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.spline.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in spline index is ${this.spline.length-1}.`);if(this.ts<0||this.ts>=1)throw new Error(`Invalid fragment ts ${this.ts} found. The value must be in the interval [0, 1).`);if(this.tf<=0||this.tf>1)throw new Error(`Invalid fragment tf ${this.tf} found. The value must be in the interval (0, 1].`);if(e<1)throw new Error(`Invalid fragment points range {${this.pointIndexStart}, ${this.pointIndexEnd}} found. At least 4 points are needed to define spline.`);if(1==e&&this.ts>this.tf)throw new Error(`Invalid fragment T range ${this.ts} - ${this.tf} found. Spline has only one segment and ts <= tf.`)}union(e){let t=[this,e];t.sort(ee.compare);let i=t.first,s=t.last,r=i.segmentIndexEnd,n=i.tf;if(1==n&&(r++,n=0),r!=s.segmentIndexStart||n!=s.ts)throw new Error(`Fragments ${i} and ${s} are not adjacent.`);let a=new ee(this.spline,i.segmentIndexStart,i.ts,s.segmentIndexEnd,s.tf);return a.#s=this.#s,this.inside&&(a.inside=this.inside),a}overlaps(e){if(e.spline!=this.spline)return!1;let t=e.segmentIndexStart<this.segmentIndexEnd||e.segmentIndexStart==this.segmentIndexEnd&&e.ts<=this.tf,i=e.segmentIndexEnd>this.segmentIndexStart||e.segmentIndexEnd==this.segmentIndexStart&&e.tf>=this.ts;return t&&i}toString(){return`fragment(${this.segmentIndexStart}, ${this.ts} - ${this.segmentIndexEnd}, ${this.tf})`}static compare(e,t){return e.segmentIndexStart<t.segmentIndexStart?-1:e.segmentIndexStart>t.segmentIndexStart?1:e.ts<t.ts?-1:e.ts>t.ts?1:0}static getInstance(e,t,i){return new ee(e,t.segmentIndex,t.t,i.segmentIndex,i.t)}}class te extends Y{constructor(e,t,i,s=[]){super(t,i,e),s.length>0&&!Object.isFrozen(s.first)&&s.forEach((e=>Object.freeze(e))),Object.defineProperty(this,"splineParameters",{value:Object.freeze(s),enumerable:!0});let r=new j(e,i);Object.defineProperty(this,"style",{get:()=>r.style,set:e=>r.style.reset(e),enumerable:!0}),Object.defineProperty(this,"color",{get:()=>this.style.color,set:e=>{if(!e)throw new Error("Spline color cannot be removed");if(!(e instanceof B))throw new Error("Expected value should be Color instance");"red"in this.pointProps&&(this.pointProps.red=e.red),"green"in this.pointProps&&(this.pointProps.green=e.green),"blue"in this.pointProps&&(this.pointProps.blue=e.blue),"alpha"in this.pointProps&&(this.pointProps.alpha=e.alpha)},enumerable:!0}),Object.defineProperty(this,"bounds",{get:()=>V.ofSpline(this,this.pointProps.scattering).ceil(),enumerable:!0}),this.validate()}validate(){let e=this.points instanceof Float32Array;if(super.validate(),!this.layout.includes(w.Property.X))throw new Error("Layout doesn't contains required properties X");if(!this.layout.includes(w.Property.Y))throw new Error("Layout doesn't contains required properties Y");if(e&&0==this.points.length)throw new Error("Empty spline is not allowed")}clone(){return new te(this.layout.slice(),this.points.clone(),Object.clone(this.pointProps),this.splineParameters.slice())}slice(e){let t=this.slicePoints(e.pointIndexStart,e.pointIndexEnd);return new te(this.layout.slice(),t,Object.clone(this.pointProps),this.splineParameters.slice())}getPoint(e){return super.getPoint(e,this.style)}getPointRef(e){return super.getPointRef(e,this.style)}getPointSegmentIndex(e){return this.splineParameters[e]?this.splineParameters[e].index:void 0}getPointT(e){return this.splineParameters[e]?this.splineParameters[e].t:void 0}getPointParameter(e){return this.splineParameters[e]}toJSON(){return{type:"InterpolatedSpline",layout:this.layout.map((e=>e.name)),points:$.encode(this.points,this.encoding),pointProps:this.pointProps,splineParameters:this.splineParameters}}static fromJSON(e){let t=$.decode(e.points);return new te(e.layout.map((e=>w.Property[e])),t,e.pointProps,e.splineParameters.map(p.fromJSON))}static fromRect(e,t){throw new Error("InterpolatedSpline.fromRect is not supported. Try Spline.fromRect and interpolate with particular Spline interpolator.")}static createInstance(e,t,i=[]){return new te(e,i,t)}static createSharedInstance(e,t,i,s){return new te(e,Float32Array.createSharedInstance(t),i,s)}}const ie=s.fromValues(0,-.5,1,-.5,1,0,-2.5,1.5,0,.5,2,-1.5,0,0,-.5,.5);class se extends Z{#r;#n;#a;constructor(e=!1,t=!1){super(),this.calculateDerivates=e,this.keepSplineParameters=t,this.state={segmentIndex:-1,lastPointPosition:void 0,lastPointSize:0}}initState(e){this.state.layout={},e.layout.forEach(((e,t)=>{this.state.layout[e.name]={index:t,polynomials:i.create()}})),this.keepSplineParameters?this.state.splineParameters?this.state.splineParameters.clear():this.state.splineParameters=[]:delete this.state.splineParameters,this.splineLayout=e.layout,this.pathPointProps=Object.clone(e.pointProps),this.scattering&&(this.pathPointProps.scattering=this.scattering),this.layout=this.calculateDerivates?e.layout.concat([w.Property.D_X,w.Property.D_Y]):e.layout,this.state.ready=!0}predict(e){if(!e)return[];this.state.ready||this.initState(e),this.#n?this.#n.points.clear():this.#n=te.createInstance(this.layout,this.pathPointProps),this.path=this.#n;let t=Object.clone(this.state);return delete this.state.splineParameters,this.resetState(),this.discretize(e),this.state=t,this.path.points}processImpl(e,t){if(!e)return[];let i;return e instanceof ee&&(i=e,e=i.spline),this.state.ready||this.initState(e),t==se.OutputType.ADDITION?(this.#r?this.#r.points.clear():this.#r=te.createInstance(this.layout,this.pathPointProps),this.path=this.#r):(this.#a=te.createInstance(this.layout,this.pathPointProps),this.path=this.#a),this.discretize(e,i),this.path.points}getOutput(e,t){if(0!=e.length){if(t==se.OutputType.PROCESSOR||t==se.OutputType.ALL_DATA){let t=this.state.splineParameters;return t&&(t=t.slice()),te.createSharedInstance(this.layout,e,this.pathPointProps,t)}return this.path}}calculateInterpolatedPoint(e,t,s){this.initState(e);let r=new w(0,0,this.splineLayout.includes(w.Property.Z)?0:void 0),n=i.fromValues(1,s,s*s,s*s*s);return this.calculatePolynomials(e,t),this.splineLayout.forEach((e=>{let t=i.dot(this.state.layout[e.name].polynomials,n);r[_.getPropName(e.name)]=t})),r}discretize(e,t){throw new Error("This method is abstract and should be implemented")}storeLastPoint(e,t=0){this.state.lastPointPosition=new d(this.getPropValue(w.Property.X,e,t),this.getPropValue(w.Property.Y,e,t),this.getPropValue(w.Property.Z,e,t)),this.state.lastPointSize=this.getPropValue(w.Property.SIZE,e,t)}getPropValue(e,t,i=0){return this.state.layout[e.name]?t[i+this.state.layout[e.name].index]:void 0}calculatePolynomials(e,t){let s=e.points,r=this.splineLayout.length*(t+0),n=this.splineLayout.length*(t+1),a=this.splineLayout.length*(t+2),o=this.splineLayout.length*(t+3);this.splineLayout.forEach(((e,t)=>{let l=i.fromValues(s[r+t],s[n+t],s[a+t],s[o+t]);i.transformMat4(this.state.layout[e.name].polynomials,l,ie)}))}samplePoint(e){let t=[],s=i.fromValues(1,e,e*e,e*e*e);return this.splineLayout.forEach((e=>{let r=i.dot(this.state.layout[e.name].polynomials,s);t.push(r)})),this.calculateDerivates&&(t.push(this.getDerivativeOf(this.state.layout.X.polynomials,s)),t.push(this.getDerivativeOf(this.state.layout.Y.polynomials,s))),t}getDerivativeOf(e,t){let s=i.fromValues(e[1],2*e[2],3*e[3],0);return i.dot(s,t)}keepSegmentT(e){this.state.splineParameters&&this.state.splineParameters.push(new p(this.state.segmentIndex,e))}resetState(){this.state.segmentIndex=-1}reset(){super.reset(),this.state.ready=!1,this.state.lastPointPosition=void 0,this.state.lastPointSize=0,this.resetState(),this.#r=null,this.#n=null,this.#a=null}}class re extends se{constructor(e,t){super(e,t),this.state.lastSegmentIndex=-1,this.state.lastPointRotation=0,this.state.lastPointT=0,this.state.absAccumulatedErrorPos=0,this.state.absAccumulatedErrorS=0,this.setT=new v,this.samples=[],Object.defineProperty(this,"errorThreshold",{get:()=>this.error,set:e=>{this.error=e,this.errorDistSq=this.error*this.error,this.error10=10*this.error},enumerable:!0}),this.errorThreshold=.15}discretize(e,t){let i=this.path.points,s=0,r=e.segmentsCount-1,n=e.ts,a=e.tf;t&&(s=t.segmentIndexStart,r=t.segmentIndexEnd,n=t.ts,a=t.tf,this.state.segmentIndex=s-1);for(let t=s;t<r+1;t++){this.state.segmentIndex++,this.calculatePolynomials(e,t);let s=this.calculateTValues(t==r,n,a);i.push(...this.samplePoints(s)),s.length>0&&(this.resetAccumulatedErrors(),this.storeLastPoint(i))}}samplePoints(e){return this.samples.clear(),e.toArray().forEach((e=>{this.keepSegmentT(e),this.samples.push(...this.samplePoint(e))})),this.samples}storeLastPoint(e){let t=e.length-this.layout.length;super.storeLastPoint(e,t),this.state.lastPointRotation=this.getPropValue(w.Property.ROTATION,e,t),this.state.lastPointT=this.setT.max(),this.state.lastSegmentIndex=this.state.segmentIndex}calculateTValues(e,t,i){let s=0==this.state.segmentIndex?t:0,r=e?i:1;return this.setT.clear(),this.getTForPos(s,r),this.state.layout.SIZE&&this.getTForCubic(s,r,this.state.layout.SIZE.polynomials,this.error),this.mustAddStartT()&&this.setT.add(s),e&&this.setT.add(r),this.state.layout.ROTATION&&this.getTForRotation(s,r),this.setT}mustAddStartT(){if(this.state.lastSegmentIndex<0)return!0;let e=this.state.lastPointT-(this.state.segmentIndex-this.state.lastSegmentIndex),t=this.setT.length>0?this.setT.min():1,i=this.getPosErrorAtT0(t,this.state.lastPointPosition);if(this.state.absAccumulatedErrorPos+=Math.abs(i),this.state.layout.SIZE){let i=this.getErrorAtT0(this.state.layout.SIZE.polynomials,t,e,this.state.lastPointSize);this.state.absAccumulatedErrorS+=Math.abs(i)}return this.state.absAccumulatedErrorPos>this.errorDistSq||this.state.absAccumulatedErrorS>this.error}getPosErrorAtT0(e,t){let i=this.getTPoint(e),s=this.getTPoint(0);return this.minDistanceSq(t,i,s)}getErrorAtT0(e,t,i,s){let r=i,n=s,a=t,o=this.cubicCalc(e,a),l=this.cubicCalc(e,0),h=n+(0-r)*(o-n)/(a-r);return Math.abs(l-h)}getTForPos(e,t){let i=this.getTPoint(e),s=this.getTPoint(t),r=this.subdividePos(i,s);if(r.split)this.subdivideRecursivePos(i,r),this.setT.add(r.t),this.subdivideRecursivePos(r,s);else{let e=this.subdividePos(i,r),t=this.subdividePos(r,s);e.split&&(this.subdivideRecursivePos(i,e),this.setT.add(e.t),this.subdivideRecursivePos(e,r)),(e.split||t.split)&&this.setT.add(r.t),t.split&&(this.subdivideRecursivePos(r,t),this.setT.add(t.t),this.subdivideRecursivePos(t,s))}}subdivideRecursivePos(e,t){let i=this.subdividePos(e,t);i.split&&(this.subdivideRecursivePos(e,i),this.setT.add(i.t),this.subdivideRecursivePos(i,t))}subdividePos(e,t){let i=.5*(e.t+t.t),s=this.getTPoint(i),r=this.minDistanceSq(e,t,s),n=e.add(t).scaleSelf(.5),a=s.subtract(n).absSelf();return s.split=r>this.errorDistSq||a.x>this.error10||a.y>this.error10,this.state.layout.Z&&(s.split=s.split||a.z>this.error10),s}getTForCubic(e,t,i,s){let r={v:this.cubicCalc(i,e),t:e},n={v:this.cubicCalc(i,t),t:t},a=this.subdivide(r,n,i);if(a.diff>s)this.subdivideRecursive(r,a,i,s),this.setT.add(a.t),this.subdivideRecursive(a,n,i,s);else{let e=this.subdivide(r,a,i),t=this.subdivide(a,n,i);e.diff>s&&(this.subdivideRecursive(r,e,i,s),this.setT.add(e.t),this.subdivideRecursive(e,a,i,s)),(e.diff>s||t.diff>s)&&this.setT.add(a.t),t.diff>s&&(this.subdivideRecursive(a,t,i,s),this.setT.add(t.t),this.subdivideRecursive(t,n,i,s))}}subdivideRecursive(e,t,i,s){let r=this.subdivide(e,t,i);r.diff>s&&(this.subdivideRecursive(e,r,i,s),this.setT.add(r.t),this.subdivideRecursive(r,t,i,s))}subdivide(e,t,i){let s=.5*(e.t+t.t),r=this.cubicCalc(i,s),n=.5*(e.v+t.v);return{v:r,t:s,diff:Math.abs(r-n)}}getTForRotation(e,t){let i=this.state.layout.ROTATION.polynomials,s=this.state.lastPointRotation;this.state.lastSegmentIndex<0&&(s=this.cubicCalc(i,e));let r=.25*(t-e);for(let t=0;t<4;t++){let n=e+t*r,a=this.cubicCalc(i,n);Math.abs(a-s)>.06&&(this.setT.add(n),s=a)}}minDistanceSq(e,t,i){let s=i.vec,r=s.squaredDistance(e.value,t.value);if(0==r)retu...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.mjs line 1
- Likely real
- Yes, 99% confidence
`t.replace("[",".").replace` method will only replace the first occurrence when used with a string argument ("]"). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
import"js-ext";import*as e from"js-md5";import t from"long";import{vec2 as r,vec3 as i,vec4 as s,quat2 as n,mat4 as o,mat2d as a}from"gl-matrix";import*as l from"poly2tri";import*as h from"clipper-lib";import d from"rbush";import*as c from"jszip";import*as p from"protobufjs";var u="1.5.0";class f{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let m=e?e.default||globalThis.md5:{},g={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(m.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let r=new Array(2),i=this.toBytes(e);return r[0]=t.fromBytes(i.slice(0,8)),r[1]=t.fromBytes(i.slice(8)),r},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class y{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=y.Algorithm.MD5;else if("function"==typeof this.buildURI)t=y.Algorithm.URI;else if(t=y.Algorithm.GUID,e&&!g.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=y.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==y.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return m(e)}return this.algorithm==y.Algorithm.URI?this.buildURI():g.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(y,"Algorithm",["GUID","MD5","URI"]);class b extends y{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,y.buildMD5Tokens(this.props)]}}Object.defineEnum(b,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class E{constructor(){this.phase=E.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=E.Phase.END||e==E.Phase.BEGIN)&&((this.phase!=E.Phase.BEGIN||e==E.Phase.UPDATE||e==E.Phase.END)&&((this.phase!=E.Phase.UPDATE||e==E.Phase.UPDATE||e==E.Phase.END)&&(e==E.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=E.Phase.END}}Object.defineEnum(E,"Phase",["BEGIN","UPDATE","END"]);class P{constructor(e,t,n,o){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let a=[e,t];isFinite(n)&&(a.push(n),isFinite(o)&&a.push(o)),this.value=a.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==a.length?this.vec=r:3==a.length?(this.vec=i,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=s,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),P.fromPoint(t)}addSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),P.fromPoint(t)}subtractSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),P.fromPoint(t)}multiplySelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),P.fromPoint(t)}divideSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),P.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new P(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),P.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return P.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new P(e[0],e[1],e[2],e[3]):new P(e.x,e.y,e.z,e.w)}}class I{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof I))throw new TypeError("rect must be instance of RectGL");return e?I.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof I))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=I.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return I.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return I.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=P.fromPoint({x:this.left,y:this.bottom}).transform(e),r=P.fromPoint({x:this.right,y:this.bottom}).transform(e),i=P.fromPoint({x:this.left,y:this.top}).transform(e),s=P.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return I.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let r=P.fromPoint({x:this.left,y:this.bottom}).transform(e),i=P.fromPoint({x:this.right,y:this.bottom}).transform(e),s=P.fromPoint({x:this.left,y:this.top}).transform(e),o=P.fromPoint({x:this.right,y:this.top}).transform(e);t=n.fromValues(r.x,r.y,i.x,i.y,s.x,s.y,o.x,o.y)}else t=n.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new I(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new P(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of I.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return I.ofEdges(f,g,m,y)}}Object.defineProperty(I,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class S{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?S.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=S.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return S.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return S.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=P.fromPoint({x:this.left,y:this.top}).transform(e),r=P.fromPoint({x:this.right,y:this.top}).transform(e),i=P.fromPoint({x:this.left,y:this.bottom}).transform(e),s=P.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return S.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new I(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof I))throw new TypeError("rect must be instance of RectGL");return new S(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new S(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?S.fromString(e):new S(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return S.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=I.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return S.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new S(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const w={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},x=w.m11,v=w.m12,R=w.m21,T=w.m22,A=w.m41,C=w.m42;class O{constructor(e=o.create(),t=O.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let r=function(e,t){let r=w[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[x],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[v],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[R],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[T],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[A],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[C],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[A],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[C],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:r.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:r.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:r.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:r.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:r.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:r.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:r.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:r.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:r.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:r.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new O(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(O.fromTranslate(e))}translateSelf(e){this.multiplySelf(O.fromTranslate(e))}rotate(e,t){return this.multiply(O.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(O.fromRotate(e,t))}scale(e,t){return this.multiply(O.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(O.fromScale(e,t))}multiply(e){return this.multiplicationType==O.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=o.create();return o.multiply(t,e.toFloat32Array(),this.value),new O(t,this.multiplicationType)}postMultiply(e){let t=o.create();return o.multiply(t,this.value,e.toFloat32Array()),new O(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==O.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){o.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){o.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=o.create();return o.invert(e,this.value),new O(e,this.multiplicationType)}invertSelf(){o.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return P.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let r=o.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(r[0]=parseFloat(e[0]),r[1]=parseFloat(e[1]),r[2]=parseFloat(e[2]),r[3]=parseFloat(e[3]),r[4]=parseFloat(e[4]),r[5]=parseFloat(e[5]),r[6]=parseFloat(e[6]),r[7]=parseFloat(e[7]),r[8]=parseFloat(e[8]),r[9]=parseFloat(e[9]),r[10]=parseFloat(e[10]),r[11]=parseFloat(e[11]),r[12]=parseFloat(e[12]),r[13]=parseFloat(e[13]),r[14]=parseFloat(e[14]),r[15]=parseFloat(e[15])):(r[x]=parseFloat(e[0]),r[v]=parseFloat(e[1]),r[R]=parseFloat(e[2]),r[T]=parseFloat(e[3]),r[A]=parseFloat(e[4]),r[C]=parseFloat(e[5]))}return new O(r,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof O)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new O(e,t);if("string"==typeof e)return O.fromString(e,t);let r=o.create(),i=Object.assign({},e);return isFinite(e.a)&&(i.m11=e.a),isFinite(e.b)&&(i.m12=e.b),isFinite(e.c)&&(i.m21=e.c),isFinite(e.d)&&(i.m22=e.d),isFinite(e.tx)?i.m41=e.tx:isFinite(e.e)?i.m41=e.e:isFinite(e.dx)&&(i.m41=e.dx),isFinite(e.ty)?i.m42=e.ty:isFinite(e.f)?i.m42=e.f:isFinite(e.dy)&&(i.m42=e.dy),isFinite(i.m11)&&(r[0]=i.m11),isFinite(i.m12)&&(r[1]=i.m12),isFinite(i.m13)&&(r[2]=i.m13),isFinite(i.m14)&&(r[3]=i.m14),isFinite(i.m21)&&(r[4]=i.m21),isFinite(i.m22)&&(r[5]=i.m22),isFinite(i.m23)&&(r[6]=i.m23),isFinite(i.m24)&&(r[7]=i.m24),isFinite(i.m31)&&(r[8]=i.m31),isFinite(i.m32)&&(r[9]=i.m32),isFinite(i.m33)&&(r[10]=i.m33),isFinite(i.m34)&&(r[11]=i.m34),isFinite(i.m41)&&(r[12]=i.m41),isFinite(i.m42)&&(r[13]=i.m42),isFinite(i.m43)&&(r[14]=i.m43),isFinite(i.m44)&&(r[15]=i.m44),new O(r,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return O.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),O.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),O.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=O.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=O.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return O.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let r=o.create();return o.multiply(r,e.value,t.value),new O(r)}}O.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let D={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(D.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class k{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let N={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof f))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==N.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==N.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=N.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==N.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=E.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:E.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return b.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=N.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=N.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:O.fromMatrix(i);let s=P.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=S.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=P.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(N.PointerType.MOUSE)||(this.stop(N.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(N.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new k(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},M={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof f))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==f.prototype.resize)return;let e=M.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=M.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?M.ResizeReason.ZOOM_IN:M.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=D.debounce((()=>{e==M.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?M.ResizeReason.SCREEN_SIZE_INCREASED:M.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=M.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=f.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==M.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==M.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=E.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:E.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return b.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:O.fromMatrix(i);let s=P.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=S.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=P.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==M.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?M.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new k(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(M,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(N.suppressKeys=M.suppressKeys,N.ResizeReason=M.ResizeReason,N.attachResize=M.attachResize,N.dettachResize=M.dettachResize,M=N);var L=M;class _ extends P{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||_.defaults.size,this.rotation=i.rotation||_.defaults.rotation,this.scaleX=i.scaleX||_.defaults.scaleX,this.scaleY=i.scaleY||_.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||_.defaults.scaleZ:void 0,this.offsetX=i.offsetX||_.defaults.offsetX,this.offsetY=i.offsetY||_.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||_.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new _(0,0,e.includes(_.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>_.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||_.defaults.size,this.rotation=s.rotation||i.rotation||_.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||_.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||_.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||_.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||_.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||_.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||_.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case _.Property.X:return this.x;case _.Property.Y:return this.y;case _.Property.Z:return this.z;case _.Property.RED:return this.red;case _.Property.GREEN:return this.green;case _.Property.BLUE:return this.blue;case _.Property.ALPHA:return this.alpha;case _.Property.SIZE:return this.size;case _.Property.ROTATION:return this.rotation;case _.Property.SCALE_X:return this.scaleX;case _.Property.SCALE_Y:return this.scaleY;case _.Property.SCALE_Z:return this.scaleZ;case _.Property.OFFSET_X:return this.offsetX;case _.Property.OFFSET_Y:return this.offsetY;case _.Property.OFFSET_Z:return this.offsetZ;case _.Property.D_X:return this.dX;case _.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){_.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case _.Property.X:e.x=r;break;case _.Property.Y:e.y=r;break;case _.Property.Z:e.z=r;break;case _.Property.RED:e.red=r;break;case _.Property.GREEN:e.green=r;break;case _.Property.BLUE:e.blue=r;break;case _.Property.ALPHA:e.alpha=r;break;case _.Property.SIZE:e.size=r;break;case _.Property.ROTATION:e.rotation=r;break;case _.Property.SCALE_X:e.scaleX=r;break;case _.Property.SCALE_Y:e.scaleY=r;break;case _.Property.SCALE_Z:e.scaleZ=r;break;case _.Property.OFFSET_X:e.offsetX=r;break;case _.Property.OFFSET_Y:e.offsetY=r;break;case _.Property.OFFSET_Z:e.offsetZ=r;break;case _.Property.D_X:e.dX=r;break;case _.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof O))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return _.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(_,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let F,B={version:"1.5.0"};Object.defineEnum(B,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(B,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(B,"TypeGL",["WEB","STACK"]),function(e){let t,r="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof require;t="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":r?"NODE":"SHELL";let i="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",s="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(B,"commonJS",{value:r,enumerable:!0}),Object.defineProperty(B,"type",{value:B.Type[t],enumerable:!0}),Object.defineProperty(B,"type2D",{value:B.Type2D[i],enumerable:!0}),Object.defineProperty(B,"typeGL",{value:B.TypeGL[s],enumerable:!0})}(),B.commonJS&&(F=require("systeminformation"));var U=F;class j extends y{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",y.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new j;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=B.version,t.props["runtime.type"]=B.type.name,void 0===U)t.props["user.agent"]=navigator.userAgent;else{let e=await U.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const G={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class ${static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=$.getUnitMetric(e);return i!=$.Metric.NORMALIZED&&i!=$.Metric.LOGICAL&&(r=$[Y[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*$[Y[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*$[t.name][r.name]/i}static getUnitMetric(e){switch(e){case $.Unit.METER:case $.Unit.CENTIMETER:case $.Unit.MILLIMETER:case $.Unit.MICROMETER:case $.Unit.INCH:case $.Unit.DP:case $.Unit.PICA:case $.Unit.POINT:case $.Unit.DIP:case $.Unit.DPI:return $.Metric.LENGTH;case $.Unit.SECOND:case $.Unit.MILLISECOND:case $.Unit.MICROSECOND:case $.Unit.NANOSECOND:return $.Metric.TIME;case $.Unit.RADIAN:case $.Unit.DEGREE:return $.Metric.ANGLE;case $.Unit.NEWTON:return $.Metric.FORCE;case $.Unit.NORMALIZED:return $.Metric.NORMALIZED;case $.Unit.LOGICAL:return $.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case $.Metric.LENGTH:return[$.Unit.METER,$.Unit.CENTIMETER,$.Unit.MILLIMETER,$.Unit.MICROMETER,$.Unit.INCH,$.Unit.DP,$.Unit.PICA,$.Unit.POINT,$.Unit.DIP,$.Unit.DPI];case $.Metric.TIME:return[$.Unit.SECOND,$.Unit.MILLISECOND,$.Unit.MICROSECOND,$.Unit.NANOSECOND];case $.Metric.ANGLE:return[$.Unit.RADIAN,$.Unit.DEGREE];case $.Metric.FORCE:return[$.Unit.NEWTON];case $.Metric.NORMALIZED:return[$.Unit.NORMALIZED];case $.Metric.LOGICAL:return[$.Unit.LOGICAL];case $.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return Y[e.name]}static convertValue(e,t,r){return e*$[t.name][r.name]}}Object.defineEnum($,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum($,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const Y=Object.freeze({LENGTH:$.Unit.METER,TIME:$.Unit.SECOND,FORCE:$.Unit.NEWTON,ANGLE:$.Unit.RADIAN,NORMALIZED:$.Unit.NORMALIZED,LOGICAL:$.Unit.LOGICAL});!function(){let e=$.getMetricUnits($.Metric.LENGTH).filter((e=>!(e.name in G)));for(let t of e){let e=$.Units[t.name];for(let t in G)e[t]=e.INCH*G[t]}for(let t in G){let r={};for(let i of e)r[i.name]=$.Units.INCH[i.name]/G[t];for(let e in G)r[e]=G[e]/G[t];$.Units[t]=r}for(let e in $.Units)$[e]=$.Units[e]}(),Object.freeze($);class X extends y{constructor(e,t,r,i,s){if(super(),t==X.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=X.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=$.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==X.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return D.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(X.Type).find((t=>X.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case X.Type.X:case X.Type.Y:case X.Type.Z:case X.Type.RADIUS_X:case X.Type.RADIUS_Y:t.unit=$.Unit.DIP;break;case X.Type.TIMESTAMP:t.unit=$.Unit.MILLISECOND;break;case X.Type.PRESSURE:t.unit=$.Unit.NORMALIZED,t.min=0,t.max=1;break;case X.Type.ALTITUDE:t.unit=$.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case X.Type.AZIMUTH:t.unit=$.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case X.Type.ROTATION:t.unit=$.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=$.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new X(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=X.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=$.getChannelResolution(r.unit),s=new X(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=X.Type.X&&e!=X.Type.Y||t.type!=b.Type.MOUSE||(s.precision=0),s}}X.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),X.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},X.Metric=$.Metric;class z extends y{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==X.Type.X||e.type==X.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new z(e,t);return r.channels=X.defaults[t.type.name].map((e=>X.createDefaultInstance(X.Type[e],t))),r}}class V extends y{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new V;return r.addContext(z.createDefaultInstance(e,t)),r}}class H extends y{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=V.createDefaultInstance(t,r);return new H(e,i)}}class Z{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${Z.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class W extends y{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=Z.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=W.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(W,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class q{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=D.getPropName(t.name),i=e[r];if(t.type==X.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==X.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=D.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==X.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class K extends y{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",y.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof K))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new b(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return V.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=b.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new H(this.environment,r);r.inkChannelsContext.layout=K.getLayout(e),this.sensorData=new W(i),this.sensorData.add(new q(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(X.Type).forEach((r=>{let i,s=X.Type[r];i=s==X.Type.ALTITUDE?"tiltX":s==X.Type.AZIMUTH?"tiltY":D.getPropName(r),K.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===U)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await U.system(),r=await U.cpu(),i=await U.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await j.createInstance(e),t}}let J={};if(B.type==B.Type.WEB)J.Image=globalThis.Image,J.ImageData=globalThis.ImageData,J.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(J.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},J.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(J.OffscreenCanvas=globalThis.OffscreenCanvas,J.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)J.Image=globalThis.Image,J.ImageData=globalThis.ImageData,J.OffscreenCanvas=globalThis.OffscreenCanvas,J.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(B.commonJS){const{Canvas:e,CanvasRenderingContext2D:t,Image:r,ImageData:i}=require("canvas");J.Image=r,J.ImageData=i,J.OffscreenCanvas=e,J.OffscreenCanvasRenderingContext2D=t}else console.warn(`Current env - ${B.type.name}, do not provides OffscreenCanvas support`);function Q(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}J.CanvasRenderingContext2D&&(J.CanvasRenderingContext2D.prototype.clearCanvas=Q),J.OffscreenCanvasRenderingContext2D&&(J.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=Q);const{Image:ee,ImageData:te,OffscreenCanvas:re,CanvasRenderingContext2D:ie,OffscreenCanvasRenderingContext2D:se}=J;let ne;class oe{#r={};constructor(...e){if(ne)throw new Error("URIResolver instance already available");ne=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(oe,"instance",{get:()=>ne});class ae{static encode(e,t=ae.Encoding.AUTO){let r;if(t==ae.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?ae.Encoding.NONE:ae.Encoding.ARRAY:ae.Encoding.BUFFER:t==ae.Encoding.ARRAY&&e instanceof Array&&(t=ae.Encoding.NONE),t==ae.Encoding.NONE)r=e;else if(t==ae.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case ae.Encoding.BUFFER:r=i.toJSON();break;case ae.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=ae.Encoding[e.encoding];if(r==ae.Encoding.NONE)t=e.content;else if(r==ae.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case ae.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case ae.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(ae,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class le{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||D.isValidURL(e)||le.repetitionsCache.has(e)||(le.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!oe.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=oe.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=ae.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return ae.isTypedArrayData(t)&&(t=ae.decode(t)),new le(e.name,t)}static getInstance(e,t){return new le(t,e)}}class he{constructor(e){D.isValidURL(e)||(le.repetitionsCache.has(e)||(le.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class de{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=de.defaults.CIRCLE_PRECISION,t=de.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return de.createEllipse(e,t,t,r)}static createEllipse(e=de.defaults.ELLIPSE_PRECISION,t=de.defaults.ELLIPSE_RADIUS_X,r=de.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=de.defaults.STAR_POINTS,t=de.defaults.STAR_INTERNAL_RADIUS,r=de.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let ce=l?l.default||globalThis.poly2tri:{};const{SweepContext:pe,Point:ue}=ce;let fe=h?h.default||globalThis.ClipperLib:{};const{Clipper:me,Paths:ge,Path:ye,ClipType:be,PolyType:Ee,PolyFillType:Pe}=fe;class Ie{constructor(e,t,r){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:r,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative....[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/workers/InkPathProvider.mjs line 1
- Likely real
- Yes, 99% confidence
`e.replace` method will only replace the first occurrence when used with a string argument ("["). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
import"js-ext";import{vec2 as t,vec3 as e,vec4 as i,mat4 as s,quat2 as r,mat2d as n}from"gl-matrix";import a from"long";import*as o from"js-md5";import*as h from"poly2tri";import*as l from"clipper-lib";"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=i=>{let s="message"==t?i.data:i;e(s)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=i=>{let s="message"==t?i.data:i;e(s)}});class u{constructor(s,r,n,a){if(isNaN(s))throw new Error(`Invalid x found: ${s}`);if(isNaN(r))throw new Error(`Invalid y found: ${r}`);let o=[s,r];isFinite(n)&&(o.push(n),isFinite(a)&&o.push(a)),this.value=o.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:t=>{this.value[0]=t},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:t=>{this.value[1]=t},enumerable:!0}),2==o.length?this.vec=t:3==o.length?(this.vec=e,Object.defineProperty(this,"z",{get:()=>this.value[2],set:t=>{this.value[2]=t},enumerable:!0})):(this.vec=i,Object.defineProperty(this,"w",{get:()=>this.value[3],set:t=>{this.value[3]=t},enumerable:!0}))}add(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.add(e,this.value,t.value),u.fromPoint(e)}addSelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.add(this.value,this.value,t.value),this}subtract(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.subtract(e,this.value,t.value),u.fromPoint(e)}subtractSelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.subtract(this.value,this.value,t.value),this}multiply(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.multiply(e,this.value,t.value),u.fromPoint(e)}multiplySelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.multiply(this.value,this.value,t.value),this}divide(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.divide(e,this.value,t.value),u.fromPoint(e)}divideSelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.divide(this.value,this.value,t.value),this}scale(t){let e=this.vec.create();return this.vec.scale(e,this.value,t),u.fromPoint(e)}scaleSelf(t){return this.vec.scale(this.value,this.value,t),this}abs(){return new u(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(t){if(!t)return this;let e=this.vec.create();return this.vec.transformMat4(e,this.value,t.toFloat32Array()),u.fromPoint(e)}transformSelf(t){return this.vec.transformMat4(this.value,this.value,t.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let t={x:this.x,y:this.y};return isFinite(this.z)&&(t.z=this.z,isFinite(this.w)&&(t.w=this.w)),t}toString(){return`point(${this.value.join(", ")})`}clone(){return u.fromPoint(this)}static fromPoint(t){return Array.isArray(t)||ArrayBuffer.isTypedArray(t)?new u(t[0],t[1],t[2],t[3]):new u(t.x,t.y,t.z,t.w)}}const c={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},p=c.m11,d=c.m12,f=c.m21,m=c.m22,g=c.m41,y=c.m42;class P{constructor(t=s.create(),e=P.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:t,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:e,enumerable:!0});let i=function(t,e){let i=c[t];this.value[i]=e};Object.defineProperty(this,"a",{get:()=>this.value[p],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[d],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[f],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[m],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[g],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[y],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[g],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[y],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:i.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:i.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:i.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:i.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:i.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:i.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:i.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:i.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:i.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:i.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new P(this.value.clone(),this.multiplicationType)}translate(t){return this.multiply(P.fromTranslate(t))}translateSelf(t){this.multiplySelf(P.fromTranslate(t))}rotate(t,e){return this.multiply(P.fromRotate(t,e))}rotateSelf(t,e){this.multiplySelf(P.fromRotate(t,e))}scale(t,e){return this.multiply(P.fromScale(t,e))}scaleSelf(t,e){this.multiplySelf(P.fromScale(t,e))}multiply(t){return this.multiplicationType==P.MultiplicationType.PRE?this.preMultiply(t):this.postMultiply(t)}preMultiply(t){let e=s.create();return s.multiply(e,t.toFloat32Array(),this.value),new P(e,this.multiplicationType)}postMultiply(t){let e=s.create();return s.multiply(e,this.value,t.toFloat32Array()),new P(e,this.multiplicationType)}multiplySelf(t){this.multiplicationType==P.MultiplicationType.PRE?this.preMultiplySelf(t):this.postMultiplySelf(t)}preMultiplySelf(t){s.multiply(this.value,t.toFloat32Array(),this.value)}postMultiplySelf(t){s.multiply(this.value,this.value,t.toFloat32Array())}invert(){let t=s.create();return s.invert(t,this.value),new P(t,this.multiplicationType)}invertSelf(){s.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(t){return u.fromPoint(t).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(t){if(t){let t=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${t(this.m11)}, ${t(this.m21)}, ${t(this.m31)}, ${t(this.m41)}`+`\n${t(this.m12)}, ${t(this.m22)}, ${t(this.m32)}, ${t(this.m42)}`+`\n${t(this.m13)}, ${t(this.m23)}, ${t(this.m33)}, ${t(this.m43)}`+`\n${t(this.m14)}, ${t(this.m24)}, ${t(this.m34)}, ${t(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(t,e){let i=s.create();if("none"!=t){let e=t.substring(0,t.indexOf("("));t=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g),"matrix3d"==e?(i[0]=parseFloat(t[0]),i[1]=parseFloat(t[1]),i[2]=parseFloat(t[2]),i[3]=parseFloat(t[3]),i[4]=parseFloat(t[4]),i[5]=parseFloat(t[5]),i[6]=parseFloat(t[6]),i[7]=parseFloat(t[7]),i[8]=parseFloat(t[8]),i[9]=parseFloat(t[9]),i[10]=parseFloat(t[10]),i[11]=parseFloat(t[11]),i[12]=parseFloat(t[12]),i[13]=parseFloat(t[13]),i[14]=parseFloat(t[14]),i[15]=parseFloat(t[15])):(i[p]=parseFloat(t[0]),i[d]=parseFloat(t[1]),i[f]=parseFloat(t[2]),i[m]=parseFloat(t[3]),i[g]=parseFloat(t[4]),i[y]=parseFloat(t[5]))}return new P(i,e)}static fromMatrix(t,e){if(!t)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof t)throw new Error("data type function is not allowed");if(t instanceof P)return t;if(Array.isArray(t)&&(t=new Float32Array(t)),t instanceof Float32Array)return new P(t,e);if("string"==typeof t)return P.fromString(t,e);let i=s.create(),r=Object.assign({},t);return isFinite(t.a)&&(r.m11=t.a),isFinite(t.b)&&(r.m12=t.b),isFinite(t.c)&&(r.m21=t.c),isFinite(t.d)&&(r.m22=t.d),isFinite(t.tx)?r.m41=t.tx:isFinite(t.e)?r.m41=t.e:isFinite(t.dx)&&(r.m41=t.dx),isFinite(t.ty)?r.m42=t.ty:isFinite(t.f)?r.m42=t.f:isFinite(t.dy)&&(r.m42=t.dy),isFinite(r.m11)&&(i[0]=r.m11),isFinite(r.m12)&&(i[1]=r.m12),isFinite(r.m13)&&(i[2]=r.m13),isFinite(r.m14)&&(i[3]=r.m14),isFinite(r.m21)&&(i[4]=r.m21),isFinite(r.m22)&&(i[5]=r.m22),isFinite(r.m23)&&(i[6]=r.m23),isFinite(r.m24)&&(i[7]=r.m24),isFinite(r.m31)&&(i[8]=r.m31),isFinite(r.m32)&&(i[9]=r.m32),isFinite(r.m33)&&(i[10]=r.m33),isFinite(r.m34)&&(i[11]=r.m34),isFinite(r.m41)&&(i[12]=r.m41),isFinite(r.m42)&&(i[13]=r.m42),isFinite(r.m43)&&(i[14]=r.m43),isFinite(r.m44)&&(i[15]=r.m44),new P(i,e||t.multiplicationType)}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return P.fromMatrix(e)}static fromRotate(t,e){let i=Math.sin(t),s=Math.cos(t),r={a:s,b:i,c:-i,d:s};return e&&(r.tx=e.x-e.x*s+e.y*i,r.ty=e.y-e.x*i-e.y*s),P.fromMatrix(r)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let i={a:t.x,d:t.y};return e&&(i.tx=e.x-e.x*t.x,i.ty=e.y-e.y*t.y),P.fromMatrix(i)}static fromPoints(t,e){if(!Array.isArray(t)||!Array.isArray(e))throw new Error("Expected input type Array requirement not satisfied");if(3!=t.length||3!=e.length)throw new Error("Expected input size 3 requirement not satisfied");let i=P.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=P.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),r=i.invert().preMultiply(s);return P.fromMatrix({a:r.m11,b:r.m12,c:r.m21,d:r.m22,tx:r.m31,ty:r.m32})}static multiply(t,e){let i=s.create();return s.multiply(i,t.value,e.value),new P(i)}}P.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});class b extends u{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(t,e,i,s={}){super(t,e,i),this.red=s.red,this.green=s.green,this.blue=s.blue,this.alpha=s.alpha,this.size=s.size||b.defaults.size,this.rotation=s.rotation||b.defaults.rotation,this.scaleX=s.scaleX||b.defaults.scaleX,this.scaleY=s.scaleY||b.defaults.scaleY,this.scaleZ=isFinite(i)?s.scaleZ||b.defaults.scaleZ:void 0,this.offsetX=s.offsetX||b.defaults.offsetX,this.offsetY=s.offsetY||b.defaults.offsetY,this.offsetZ=isFinite(i)?s.offsetZ||b.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(t,e,i,s=0){let r=new b(0,0,t.includes(b.Property.Z)?0:void 0);return i&&r.fill(s,i,t,e),r}fill(t,e,i,s={}){let r={},n=t*i.length;i.forEach(((t,i)=>b.setProperty(r,t,e[n+i]))),this.x=r.x,this.y=r.y,this.z=r.z,this.red=isFinite(r.red)?r.red:s.red,this.green=isFinite(r.green)?r.green:s.green,this.blue=isFinite(r.blue)?r.blue:s.blue,this.alpha=isFinite(r.alpha)?r.alpha:s.alpha,this.size=r.size||s.size||b.defaults.size,this.rotation=r.rotation||s.rotation||b.defaults.rotation,this.scaleX=r.scaleX||s.scaleX||b.defaults.scaleX,this.scaleY=r.scaleY||s.scaleY||b.defaults.scaleY,this.scaleZ=isFinite(r.z)?r.scaleZ||s.scaleZ||b.defaults.scaleZ:void 0,this.offsetX=r.offsetX||s.offsetX||b.defaults.offsetX,this.offsetY=r.offsetY||s.offsetY||b.defaults.offsetY,this.offsetZ=isFinite(r.z)?r.offsetZ||s.offsetZ||b.defaults.offsetZ:void 0,this.dX=r.dX,this.dY=r.dY}getProperty(t){switch(t){case b.Property.X:return this.x;case b.Property.Y:return this.y;case b.Property.Z:return this.z;case b.Property.RED:return this.red;case b.Property.GREEN:return this.green;case b.Property.BLUE:return this.blue;case b.Property.ALPHA:return this.alpha;case b.Property.SIZE:return this.size;case b.Property.ROTATION:return this.rotation;case b.Property.SCALE_X:return this.scaleX;case b.Property.SCALE_Y:return this.scaleY;case b.Property.SCALE_Z:return this.scaleZ;case b.Property.OFFSET_X:return this.offsetX;case b.Property.OFFSET_Y:return this.offsetY;case b.Property.OFFSET_Z:return this.offsetZ;case b.Property.D_X:return this.dX;case b.Property.D_Y:return this.dY;default:throw console.warn(t),new Error("Invalid property found")}}setProperty(t,e){b.setProperty(this,t,e)}static setProperty(t,e,i){switch(e){case b.Property.X:t.x=i;break;case b.Property.Y:t.y=i;break;case b.Property.Z:t.z=i;break;case b.Property.RED:t.red=i;break;case b.Property.GREEN:t.green=i;break;case b.Property.BLUE:t.blue=i;break;case b.Property.ALPHA:t.alpha=i;break;case b.Property.SIZE:t.size=i;break;case b.Property.ROTATION:t.rotation=i;break;case b.Property.SCALE_X:t.scaleX=i;break;case b.Property.SCALE_Y:t.scaleY=i;break;case b.Property.SCALE_Z:t.scaleZ=i;break;case b.Property.OFFSET_X:t.offsetX=i;break;case b.Property.OFFSET_Y:t.offsetY=i;break;case b.Property.OFFSET_Z:t.offsetZ=i;break;case b.Property.D_X:t.dX=i;break;case b.Property.D_Y:t.dY=i;break;default:throw console.warn(e),new Error("Invalid property found")}}transform(t){if(!(t instanceof P))throw new Error(`matrix is instance of ${t.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let e=t.scaleX,i=t.rotation;this.transformSelf(t),this.size*=e,this.rotation+=i}toArray(t){return t.map((t=>{let e=this.getProperty(t);if(null==e||isNaN(e))throw new Error(`Property ${t.name} has invalid value ${e}`);return e}))}toJSON(){let t={};return b.Property.values.forEach((e=>{let i=this.getProperty(e);null!=i&&isFinite(i)&&(t[e.name]=this.getProperty(e))})),t}}Object.defineEnum(b,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]);class E{constructor(t,e,i){Object.defineProperties(this,{path:{value:t,enumerable:!0},pointIndexStart:{value:e,enumerable:!0},pointIndexEnd:{value:i,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.path.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in path index is ${this.path.length-1}.`)}toPath(){return this.path.slice(this)}toString(){return`fragment(${this.pointIndexStart} - ${this.pointIndexEnd})`}}class S{constructor(t,e,i,s=1){if(this.red=t,this.green=e,this.blue=i,this.alpha=s,s<0||s>1)throw new Error(`Invalid alpha ${s} found. The value must be in the interval [0, 1].`);Object.defineProperty(this,"hex",{get:()=>`#${this.red.toString(16).pad(2,"0")}${this.green.toString(16).pad(2,"0")}${this.blue.toString(16).pad(2,"0")}${Math.round(255*this.alpha).toString(16).pad(2,"0")}`,enumerable:!0})}premultiply(){return{red:this.red/255*this.alpha,green:this.green/255*this.alpha,blue:this.blue/255*this.alpha,alpha:this.alpha}}static postdivide(t,e,i,s){let r=parseInt(255*t/s),n=parseInt(255*e/s),a=parseInt(255*i/s);return new S(r,n,a,s)}equals(t){return t&&this.red==t.red&&this.green==t.green&&this.blue==t.blue&&this.alpha==t.alpha}toRGB(){return 1==this.alpha?this:new S(this.red,this.green,this.blue)}toRGBA(t){return new S(this.red,this.green,this.blue,t)}toHSLA(){let t=this.red/255,e=this.green/255,i=this.blue/255,s=Math.min(t,e,i),r=Math.max(t,e,i),n=0,a=0,o=(r+s)/2;if(r!=s){let h=r-s;switch(a=h/(1-Math.abs(2*o-1)),r){case t:n=(e-i)/h%6;break;case e:n=(i-t)/h+2;break;case i:n=(t-e)/h+4}}return n*=60,n<0&&(n+=360),{hue:parseFloat(n.toFixed(0)),saturation:parseFloat((100*a).toFixed(2)),lightness:parseFloat((100*o).toFixed(2)),alpha:this.alpha}}toArray(){return[this.red,this.green,this.blue,this.alpha]}toJSON(){return{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}}toString(){return 1==this.alpha?`rgb(${this.red}, ${this.green}, ${this.blue})`:`rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`}static isColor(t){return t&&isFinite(t.red)&&isFinite(t.green)&&isFinite(t.blue)}static fromColor(t){let e,i,s,r;if("string"==typeof t)if(t.startsWith("rgb"))t=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g),e=parseInt(t[0]),i=parseInt(t[1]),s=parseInt(t[2]),r=t[3]?parseInt(t[3]):1;else{if(!t.startsWith("#"))throw new Error(`Unknown input found: ${t}. Expected data starts with rgba, rgb or #.`);t=t.substring(1),e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16),r=8==t.length?parseInt(t.substring(6,8),16)/255:1}else Array.isArray(t)?(e=t[0],i=t[1],s=t[2],r=t[3]):(e=t.red,i=t.green,s=t.blue,r=t.alpha);return new S(e,i,s,r)}static fromHSLA(t=0,e=0,i=0,s){t/=60,e/=100,i/=100;let r=(1-Math.abs(2*i-1))*e,n=r*(1-Math.abs(t%2-1)),a=0,o=0,h=0;t>=0&&t<1?(a=r,o=n):t>=1&&t<2?(a=n,o=r):t>=2&&t<3?(o=r,h=n):t>=3&&t<4?(o=n,h=r):t>=4&&t<5?(a=n,h=r):(a=r,h=n);let l=i-r/2;return a+=l,o+=l,h+=l,new S(Math.round(255*a),Math.round(255*o),Math.round(255*h),s)}static random(t=!1){return new S(Math.randomInt(0,255),Math.randomInt(0,255),Math.randomInt(0,255),t?Math.random():1)}}S.TRANSPERENT=new S(0,0,0,0),S.BLACK=new S(0,0,0,1),S.WHITE=new S(255,255,255,1),S.RED=new S(255,0,0,1),S.GREEN=new S(0,255,0,1),S.BLUE=new S(0,0,255,1);let w={longToByteArray(t){let e=[0,0,0,0,0,0,0,0];for(let i=0;i<e.length;i++){let s=255&t;e[i]=s,t=(t-s)/256}return e},byteArrayToLong(t){let e=0;for(let i=t.length-1;i>=0;i--)e=256*e+t[i];return e},crc32:function(){let t=new Uint32Array(256);for(let e=256;e--;){let i=e;for(let t=8;t--;)i=1&i?3988292384^i>>>1:i>>>1;t[e]=i}return function(e){let i=-1;for(let s=0,r=e.length;s<r;s++)i=i>>>8^t[255&i^e[s]];return(-1^i)>>>0}}(),encodeBitMask(t=[]){if(0==t.length)return 0;let e="",i=Math.max(...t);for(let s=1;s<=i;s++)e+=t.includes(s)?"1":"0";return parseInt(e.split("").reverse().join(""),2)},decodeBitMask(t){let e=[],i=t.toString(2).split("").reverse();for(let t=0;t<i.length;t++)1==i[t]&&e.push(t+1);return e},mapTo:(t,e,i)=>i.min+(w.clamp(t,e)-e.min)/(e.max-e.min)*(i.max-i.min),clamp:(t,e)=>Math.min(Math.max(t,e.min),e.max),debounce(t,e){let i=null;return function(){let s=this,r=arguments;clearTimeout(i),i=setTimeout((function(){t.apply(s,r)}),e)}},comparator(){let t=Array.prototype.slice.call(arguments),e=function(t,e,i){return e.replace("[",".").replace("]","").split(".").forEach((e=>t=t[e])),i?t.toLowerCase():t};return function(i,s){return t.map((t=>function(t,e,i){let s="asc"===i?1:-1;return t>e?1*s:t<e?-1*s:0}(e(i,t.sortBy,t.ignoreCase),e(s,t.sortBy,t.ignoreCase),t.sortOrder))).reduceRight((function(t,e){return e||t}))}},isValidURL(t){if("string"!=typeof t)return!1;try{return new URL(t),!0}catch(t){return!1}},getPropName(t,e){let i=t.split("_"),s=i.first.toLowerCase();e&&(s=s.substring(0,1).toUpperCase()+s.substring(1));for(let t=1;t<i.length;t++)s+=i[t].substring(0,1),s+=i[t].substring(1).toLowerCase();return s},getEnumValueName(t){let e="";for(let i=0;i<t.length;i++)i>0&&t[i]!=t[i].toLowerCase()&&(e+="_"),e+=t[i];return e.toUpperCase()}};class I{constructor(t,e,i={}){this.layout=t,this.pointProps=e,this.sheet={};let s={};Object.defineProperties(s,{size:{get:this.getComputed.bind(this,"size"),set:this.setStyle.bind(this,"size"),enumerable:!0},red:{get:this.getComputed.bind(this,"red"),set:this.setStyle.bind(this,"red"),enumerable:!0},green:{get:this.getComputed.bind(this,"green"),set:this.setStyle.bind(this,"green"),enumerable:!0},blue:{get:this.getComputed.bind(this,"blue"),set:this.setStyle.bind(this,"blue"),enumerable:!0},alpha:{get:this.getComputed.bind(this,"alpha"),set:this.setStyle.bind(this,"alpha"),enumerable:!0},rotation:{get:this.getComputed.bind(this,"rotation"),set:this.setStyle.bind(this,"rotation"),enumerable:!0},scaleX:{get:this.getComputed.bind(this,"scaleX"),set:this.setStyle.bind(this,"scaleX"),enumerable:!0},scaleY:{get:this.getComputed.bind(this,"scaleY"),set:this.setStyle.bind(this,"scaleY"),enumerable:!0},scaleZ:{get:this.getComputed.bind(this,"scaleZ"),set:this.setStyle.bind(this,"scaleZ"),enumerable:!0},offsetX:{get:this.getComputed.bind(this,"offsetX"),set:this.setStyle.bind(this,"offsetX"),enumerable:!0},offsetY:{get:this.getComputed.bind(this,"offsetY"),set:this.setStyle.bind(this,"offsetY"),enumerable:!0},offsetZ:{get:this.getComputed.bind(this,"offsetZ"),set:this.setStyle.bind(this,"offsetZ"),enumerable:!0},color:{get:this.getComputed.bind(this,"color"),set:this.setStyle.bind(this,"color"),enumerable:!0},blendMode:{get:this.getComputed.bind(this,"blendMode"),set:this.setStyle.bind(this,"blendMode"),enumerable:!0},visibility:{get:this.getComputed.bind(this,"visibility"),set:this.setStyle.bind(this,"visibility"),enumerable:!0},reset:{value:t=>{t&&(i=t),this.clear(),Object.keys(i).forEach((t=>this.setStyle(t,i[t])))}},clear:{value:this.clear.bind(this)}}),this.style=Object.freeze(s),this.style.reset(i)}setStyle(t,e){if(null==e&&(e=void 0),I.validate(this.layout,t,e),"color"==t&&e)return this.sheet.red=e.red,this.sheet.green=e.green,this.sheet.blue=e.blue,void(this.sheet.alpha=e.alpha);null==e?delete this.sheet[t]:this.sheet[t]=e}getStyle(t){let e=this.sheet[t];return"visibility"==t?"boolean"!=typeof e&&(e=!0):"color"==t&&S.isColor(this.sheet)&&(e=S.fromColor(this.sheet)),e}getComputed(t){let e=this.getStyle(t);if(null==e)if("color"==t){let t={red:isFinite(this.sheet.red)?this.sheet.red:this.pointProps.red,green:isFinite(this.sheet.green)?this.sheet.green:this.pointProps.green,blue:isFinite(this.sheet.blue)?this.sheet.blue:this.pointProps.blue,alpha:isFinite(this.sheet.alpha)?this.sheet.alpha:this.pointProps.alpha};S.isColor(t)&&(e=S.fromColor(t))}else e=this.pointProps[t];return e}clear(){this.sheet={}}static validate(t,e,i,s){let r;if(i&&t.includes(b.Property[w.getEnumValueName(e)])){if(!s)throw new Error(`Property ${e} value ${i} is not applicable. This is a dynamic property and is part of the layout.`);console.warn(`Property ${e} value ${i} is not applicable. This is a dynamic property and is part of the layout.`),i=void 0}if("color"==e)!i||i instanceof S||(r=`Property ${e} is not an instance of Color`);else if("blendMode"==e)""==i&&(i=void 0);else if("number"==typeof i)if("size"==e)i<0?r=`Property ${e} with value ${i} is not allowed. Value should be a positive number.`:0==i&&(i=void 0);else if("red"==e||"green"==e||"blue"==e||"alpha"==e){let t="alpha"==e?{min:0,max:1}:{min:0,max:255};i>=t.min&&i<=t.max||(r=`Property ${e} with value ${i} is out of range. Allowd range: [${t.min}, ${t.max}].`)}else"rotation"==e?0==i&&(i=void 0):"scattering"==e&&i<0&&(i=void 0);if(r)throw new Error(r);return i}}class v{static encode(t,e=v.Encoding.AUTO){let i;if(e==v.Encoding.AUTO?e="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer?v.Encoding.NONE:v.Encoding.ARRAY:v.Encoding.BUFFER:e==v.Encoding.ARRAY&&t instanceof Array&&(e=v.Encoding.NONE),e==v.Encoding.NONE)i=t;else if(e==v.Encoding.ARRAY)i=t.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let s=Buffer.from(t.buffer);switch(e){case v.Encoding.BUFFER:i=s.toJSON();break;case v.Encoding.BASE64:i=s.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${e.name}`)}}return{encoding:e.name,type:t.constructor.name,content:i}}static decode(t){let e,i=v.Encoding[t.encoding];if(i==v.Encoding.NONE)e=t.content;else if(i==v.Encoding.ARRAY)e=t.content.toFloat32Array();else{let s;switch(i){case v.Encoding.BUFFER:s="undefined"==typeof Buffer?t.content.data:Buffer.from(t.content);break;case v.Encoding.BASE64:s="undefined"==typeof Buffer?atob(t.content).toCharArray():Buffer.from(t.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${i.name}`)}let r=new Uint8Array(s);e=new globalThis[t.type](r.buffer)}return e}static isTypedArrayData(t){return t&&t.encoding&&t.type&&t.type.endsWith("Array")}}Object.defineEnum(v,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);const O=[b.Property.X,b.Property.Y];class x{#t;#e;constructor(t,e={},i=O){if(this.#t=t,Object.defineProperty(this,"points",{get:()=>this.#t,set:t=>{if(this.#t instanceof Float32Array)throw new Error("Points setter is not accessible wehn points type is Float32Array.");this.#t=t,this.validate()},enumerable:!0}),Object.defineProperty(this,"buffer",{get:()=>this.#t.buffer,set:t=>{if(Array.isArray(this.#t))throw new Error("Underlying points buffer is Array. This property is applicable for TypedArray only.");if("undefined"!=typeof SharedArrayBuffer&&this.#t.buffer instanceof SharedArrayBuffer)throw new Error("Underlying buffer is SharedArrayBuffer and cannot be restored");if(this.#t.buffer.byteLength>0)throw new Error("Cannot restore buffer when underlying buffer is not empty");if(t.byteLength/Float32Array.BYTES_PER_ELEMENT/this.stride!=this.length)throw new Error("Value exceeds expected memory length");this.#t=new Float32Array(t)}}),!Object.isSealed(e))for(let t in e)void 0!==e[t]&&(e[t]=I.validate(i,t,e[t],!0));i.includes(b.Property.ROTATION)||"rotation"in e||(e.rotation=void 0),i.includes(b.Property.SIZE)||e.size||(e.size=1),Object.defineProperties(this,{stride:{value:i.length,enumerable:!0},layout:{value:Object.freeze(i),enumerable:!0},pointProps:{value:Object.seal(e),enumerable:!0}}),t instanceof Float32Array?Object.defineProperty(this,"length",{value:this.#t.length/this.stride,enumerable:!0}):Object.defineProperty(this,"length",{get:()=>this.#t.length/this.stride,enumerable:!0}),i.forEach(((t,e)=>{let i=w.getPropName(t.name,!0);Object.defineProperty(this,`setPoint${i}`,{value:this.setPointPropertyValue.bind(this,e)}),Object.defineProperty(this,`getPoint${i}`,{value:this.getPointPropertyValue.bind(this,e)})}))}validate(){if(this.points.length%this.stride!=0)throw new Error("Path length doesn't match the stride provided via the layout")}setPointPropertyValue(t,e,i){if(isNaN(e))throw new Error("Point index is required");if(e>=this.length||e<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);if(isNaN(i))throw new Error("value is required");this.points[e*this.layout.length+t]=i}getPointPropertyValue(t,e){if(isNaN(e))throw new Error("Point index is required");if(e>=this.length||e<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);return this.points[e*this.layout.length+t]}setPoint(t,e){let i=t*this.stride;this.layout.forEach(((t,s)=>this.points[i+s]=e.getProperty(t)))}getPoint(t,e=this.pointProps){if(t>=this.length||t<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);return b.createInstance(this.layout,e,this.points,t)}getPointRef(t,e=this.pointProps){if(t>=this.length||t<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);return this.#e||(this.#e=b.createInstance(this.layout)),this.#e.fill(t,this.points,this.layout,this.pointProps),this.#e}getChannelData(t){let e=new([b.Property.RED,b.Property.GREEN,b.Property.BLUE].includes(t)?Uint8Array:Float32Array)(this.length),i=this.layout.indexOf(t);if(-1==i)throw new Error(`Property ${t.name} is not part from the spline layout ${this.layout.map((t=>t.name)).join(", ")}`);for(let t=0;t<this.length;t++)e[t]=this.points[t*this.stride+i];return e}transform(t){let e=t.scaleX,s=t.rotation;for(let r=0;r<this.length;r++){let n=r*this.stride,a=i.fromValues(this.getPointX(r),this.getPointY(r),0,1);i.transformMat4(a,a,t.value);for(let t=0;t<this.stride;t++){let i=n+t;switch(this.layout[t]){case b.Property.X:this.points[i]=a[0]/a[3];break;case b.Property.Y:this.points[i]=a[1]/a[3];break;case b.Property.Z:this.points[i]=a[2]/a[3];break;case b.Property.ROTATION:this.points[i]+=s;break;case b.Property.SIZE:this.points[i]*=e}}}this.layout.includes(b.Property.ROTATION)||(this.pointProps.rotation=0==s?void 0:s)}clone(){return new x(this.#t.clone(),Object.clone(this.pointProps),this.layout.slice())}getFragment(t=0,e=this.length-1){return new E(this,t,e)}slice(t){let e=this.slicePoints(t.pointIndexStart,t.pointIndexEnd);return new x(e,Object.clone(this.pointProps),this.layout.slice())}validateFragment(t,e){if(t<0)throw new Error(`Invalid fragment pointIndexStart ${t} found. The value must be non-negative.`);if(e>this.length-1)throw new Error(`Invalid fragment pointIndexEnd ${e} found. Last point in path index is ${this.length-1}.`)}slicePoints(t,e){let i;if(this.validateFragment(t,e),"undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let s=this.points.subarray(t*this.stride,(e+1)*this.stride),r=new SharedArrayBuffer(s.length*Float32Array.BYTES_PER_ELEMENT);i=new Float32Array(r),i.set(s)}else i=this.points.slice(t*this.stride,(e+1)*this.stride);return i}toSVGPath(){let t=[];for(let e=0;e<this.length;e++)t.push(`${this.getPointX(e)},${this.getPointY(e)}`);return`M ${t.join(" L ")} Z`}toJSON(){return{type:"Path",points:v.encode(this.#t,this.encoding),pointProps:this.pointProps,layout:this.layout.map((t=>t.name))}}static fromJSON(t){if("Path"!=t.type)throw new Error(`Path deserialization failed. JSON type is ${t.type}, expected Path.`);return new x(v.decode(t.points),t.pointProps,t.layout.map((t=>b.Property[t])))}static fromRect(t,e){let i=[t.left,t.top,t.right,t.top,t.right,t.bottom,t.left,t.bottom,t.left,t.top];return new x(i,e)}static createInstance(t,e,i){return new x(t,e,i)}static createSharedInstance(t,e,i){return new x(Float32Array.createSharedInstance(t),e,i)}}class A{constructor(t,e){t>0&&0==e?(this.segmentIndex=t-1,this.t=1):(this.segmentIndex=t,this.t=e),Object.defineProperty(this,"index",{get:()=>(console.warn("SplineParameter index => segmentIndex"),this.segmentIndex)})}equals(t){return this.segmentIndex==t.segmentIndex&&this.t==t.t}toString(){return`spline-parameter(${this.segmentIndex}, ${this.t})`}toJSON(){return{segmentIndex:this.segmentIndex,t:this.t}}static fromJSON(t){return new A(t.segmentIndex,t.t)}static calcMiddleOfSegment(t,e){let i=.5*(t.t+e.t+(e.segmentIndex-t.segmentIndex)),s=Math.trunc(i),r=i-s;return new A(t.segmentIndex+s,r)}static areDistantEnough(t,e,i=.01){return e.t+(e.segmentIndex-t.segmentIndex)-t.t>i}}let R=o?o.default||globalThis.md5:{},T={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let t=Date.now();return this.mask.replace(/[xy]/g,(function(e){let i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:3&i|8).toString(16)}))},validate:t=>"string"==typeof t&&!!t.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(t){let e=[],i=0;return this.mask.split("-").forEach((s=>{e.push(t.substring(i,i+s.length)),i+=s.length})),e.join("-")},fromString(t){return this.fromBytes(new Uint8Array(R.arrayBuffer(t)))},toBytes(t){let e=[];return t.split("-").map(((t,i)=>{(i<3?t.match(/.{1,2}/g).reverse():t.match(/.{1,2}/g)).map((t=>e.push(parseInt(t,16))))})),new Uint8Array(e)},fromBytes(t){let e=Array.from(t).map((t=>t.toString(16))).map((t=>(1==t.length?"0":"")+t));return e.slice(0,4).reverse().join("")+"-"+e.slice(4,6).reverse().join("")+"-"+e.slice(6,8).reverse().join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10).join("")},toUint32Array(t){let e=new Uint32Array(4),i=this.toBytes(t);return e[0]=new Uint32Array(i.slice(0,4).buffer)[0],e[1]=new Uint32Array(i.slice(4,8).buffer)[0],e[2]=new Uint32Array(i.slice(8,12).buffer)[0],e[3]=new Uint32Array(i.slice(12).buffer)[0],e},fromUint32Array(t){return this.fromBytes(new Uint8Array(t.buffer))},toUint64Array(t){let e=new BigUint64Array(2),i=this.toBytes(t);return e[0]=new BigUint64Array(i.slice(0,8).buffer)[0],e[1]=new BigUint64Array(i.slice(8).buffer)[0],e},fromUint64Array(t){return this.fromBytes(new Uint8Array(t.buffer))},toLongArray(t){let e=new Array(2),i=this.toBytes(t);return e[0]=a.fromBytes(i.slice(0,8)),e[1]=a.fromBytes(i.slice(8)),e},fromLongArray(t){let e=t[0].toBytes().concat(t[1].toBytes());return this.fromBytes(e)}};class N{#i;constructor(t,e,i,s,r){1==i&&(e++,i=0),0==r&&(s--,r=1),Object.defineProperties(this,{spline:{value:t,enumerable:!0},segmentIndexStart:{value:e,enumerable:!0},segmentIndexEnd:{value:s,enumerable:!0},ts:{value:i,enumerable:!0},tf:{value:r,enumerable:!0}}),Object.defineProperty(this,"pointIndexStart",{value:e,enumerable:!0}),Object.defineProperty(this,"pointIndexEnd",{value:s+3,enumerable:!0}),Object.defineProperty(this,"length",{value:this.pointIndexEnd-this.pointIndexStart+1,enumerable:!0}),Object.defineProperty(this,"id",{get:()=>(this.#i||(this.#i=T.generate()),this.#i),set:t=>{if(this.#i)throw new Error("id is immutable");this.#i=t}}),this.validate()}validate(){let t=this.length-3;if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.spline.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in spline index is ${this.spline.length-1}.`);if(this.ts<0||this.ts>=1)throw new Error(`Invalid fragment ts ${this.ts} found. The value must be in the interval [0, 1).`);if(this.tf<=0||this.tf>1)throw new Error(`Invalid fragment tf ${this.tf} found. The value must be in the interval (0, 1].`);if(t<1)throw new Error(`Invalid fragment points range {${this.pointIndexStart}, ${this.pointIndexEnd}} found. At least 4 points are needed to define spline.`);if(1==t&&this.ts>this.tf)throw new Error(`Invalid fragment T range ${this.ts} - ${this.tf} found. Spline has only one segment and ts <= tf.`)}union(t){let e=[this,t];e.sort(N.compare);let i=e.first,s=e.last,r=i.segmentIndexEnd,n=i.tf;if(1==n&&(r++,n=0),r!=s.segmentIndexStart||n!=s.ts)throw new Error(`Fragments ${i} and ${s} are not adjacent.`);let a=new N(this.spline,i.segmentIndexStart,i.ts,s.segmentIndexEnd,s.tf);return a.#i=this.#i,this.inside&&(a.inside=this.inside),a}overlaps(t){if(t.spline!=this.spline)return!1;let e=t.segmentIndexStart<this.segmentIndexEnd||t.segmentIndexStart==this.segmentIndexEnd&&t.ts<=this.tf,i=t.segmentIndexEnd>this.segmentIndexStart||t.segmentIndexEnd==this.segmentIndexStart&&t.tf>=this.ts;return e&&i}toString(){return`fragment(${this.segmentIndexStart}, ${this.ts} - ${this.segmentIndexEnd}, ${this.tf})`}static compare(t,e){return t.segmentIndexStart<e.segmentIndexStart?-1:t.segmentIndexStart>e.segmentIndexStart?1:t.ts<e.ts?-1:t.ts>e.ts?1:0}static getInstance(t,e,i){return new N(t,e.segmentIndex,e.t,i.segmentIndex,i.t)}}class C{constructor(t,e,i,s){let r=t,n=e,a=t+i,o=e+s;Object.defineProperties(this,{left:{value:r,enumerable:!0},x:{value:t,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:e,enumerable:!0},right:{value:a,enumerable:!0},top:{value:o,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0}})}union(t){if(t&&!(t instanceof C))throw new TypeError("rect must be instance of RectGL");return t?C.ofEdges(Math.min(this.left,t.left),Math.min(this.bottom,t.bottom),Math.max(this.right,t.right),Math.max(this.top,t.top)):this}intersect(t){if(t&&!(t instanceof C))throw new TypeError("rect must be instance of RectGL");if(!t)return null;let e=C.ofEdges(Math.max(this.left,t.left),Math.max(this.bottom,t.bottom),Math.min(this.right,t.right),Math.min(this.top,t.top));return e.width>0&&e.height>0?e:null}ceil(){return C.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return C.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(t){if(!t)return this;let e=u.fromPoint({x:this.left,y:this.bottom}).transform(t),i=u.fromPoint({x:this.right,y:this.bottom}).transform(t),s=u.fromPoint({x:this.left,y:this.top}).transform(t),r=u.fromPoint({x:this.right,y:this.top}).transform(t),n=Math.min(s.x,r.x,e.x,i.x),a=Math.min(s.y,r.y,e.y,i.y),o=Math.max(s.x,r.x,e.x,i.x),h=Math.max(s.y,r.y,e.y,i.y);return C.ofEdges(n,a,o,h)}toQuad(t){let e;if(t){let i=u.fromPoint({x:this.left,y:this.bottom}).transform(t),s=u.fromPoint({x:this.right,y:this.bottom}).transform(t),n=u.fromPoint({x:this.left,y:this.top}).transform(t),a=u.fromPoint({x:this.right,y:this.top}).transform(t);e=r.fromValues(i.x,i.y,s.x,s.y,n.x,n.y,a.x,a.y)}else e=r.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return e}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,i,s){return new C(t,e,i-t,s-e)}static calculateBrushGLSegmentBounds(t,e=0,i){let s,r=.5*t.size,n=Math.abs(e*r);if(i){s=new u(t.x,t.y,t.x,t.z).transform(i)}else s=t;let a=s.x,o=s.y,h=t.scaleX*r,l=t.scaleY*r,c=t.offsetX,p=-t.offsetY,d=Math.cos(t.rotation),f=Math.sin(t.rotation),m=Number.MAX_SAFE_INTEGER,g=Number.MIN_SAFE_INTEGER,y=Number.MAX_SAFE_INTEGER,P=Number.MIN_SAFE_INTEGER;for(let t of C.SQURE){let e=t.x*h+c,i=t.y*l+p,s=d*e+f*i+a,r=-f*e+d*i+o,u=s-n;m=Math.min(m,u),g=Math.max(g,u),u=s+n,m=Math.min(m,u),g=Math.max(g,u);let b=r-n;y=Math.min(y,b),P=Math.max(P,b),b=r+n,y=Math.min(y,b),P=Math.max(P,b)}return C.ofEdges(m,y,g,P)}}Object.defineProperty(C,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class D{constructor(t,e,i,s){let r,n,a,o=t,h=e,l=t+i,u=e+s;Object.defineProperties(this,{left:{value:o,enumerable:!0},top:{value:h,enumerable:!0},right:{value:l,enumerable:!0},bottom:{value:u,enumerable:!0},x:{value:t,enumerable:!0},y:{value:e,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0},size:{get:()=>(r||(r={width:i,height:s}),r),enumerable:!0},area:{get:()=>(n||(n=i*s),n),enumerable:!0},center:{get:()=>(a||(a={x:(o+l)/2,y:(h+u)/2}),a),enumerable:!0}})}union(t){return t?D.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return null;let e=D.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:null}intersects(t){return this.left<=t.right&&this.right>=t.left&&this.top<=t.bottom&&this.bottom>=t.top}ceil(t){let e=Math.floor(this.left),i=Math.floor(this.top),s=Math.ceil(this.right),r=Math.ceil(this.bottom);if(t){let t=s-e,n=r-i;t+=t%2,n+=n%2,s=e+t,r=i+n}return D.ofEdges(e,i,s,r)}floor(t){let e=Math.ceil(this.left),i=Math.ceil(this.top),s=Math.floor(this.right),r=Math.floor(this.bottom);if(t){let t=s-e,n=r-i;t-=t%2,n-=n%2,s=e+t,r=i+n}return D.ofEdges(e,i,s,r)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}includes(t){return this.left<=t.left&&this.right>=t.right&&this.top<=t.top&&this.bottom>=t.bottom}transform(t){if(!t)return this;let e=u.fromPoint({x:this.left,y:this.top}).transform(t),i=u.fromPoint({x:this.right,y:this.top}).transform(t),s=u.fromPoint({x:this.left,y:this.bottom}).transform(t),r=u.fromPoint({x:this.right,y:this.bottom}).transform(t),n=Math.min(e.x,i.x,s.x,r.x),a=Math.min(e.y,i.y,s.y,r.y),o=Math.max(e.x,i.x,s.x,r.x),h=Math.max(e.y,i.y,s.y,r.y);return D.ofEdges(n,a,o,h)}toPath(t,e=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new C(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(t){if(!t)return null;if(!(t instanceof C))throw new TypeError("rect must be instance of RectGL");return new D(t.left,t.bottom,t.width,t.height)}static isRect(t){return t&&isFinite(t.left)&&isFinite(t.top)&&isFinite(t.width)&&isFinite(t.height)}static fromString(t){return t=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g),new D(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]))}static fromRect(t){return"string"==typeof t?D.fromString(t):new D(t.x,t.y,t.width,t.height)}static ofPolygon(t){if(t.shape&&(t=t.shape),0==t.length)return null;let e=Number.MAX_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let n=0;n<t.length;n++){let a=t.getPointX(n),o=t.getPointY(n);e=Math.min(e,a),i=Math.min(i,o),s=Math.max(s,a),r=Math.max(r,o)}return D.ofEdges(e,i,s,r)}static ofSpline(t,e=0){let i;for(let s=0;s<t.length;s++)i=C.calculateBrushGLSegmentBounds(t.getPointRef(s),e).union(i);return D.fromGLRect(i)}static ofEdges(t,e,i,s){let r=Math.min(t,i),n=Math.min(e,s),a=Math.max(t,i),o=Math.max(e,s);return new D(r,n,a-r,o-n)}static union(t,e){return t?e?t.union(e):t:e}static intersect(t,e){return t&&e?t.intersect(e):null}}class M extends x{constructor(t,e,i,s=0,r=1){super(e,i,t),this.points instanceof Float32Array?Object.defineProperty(this,"segmentsCount",{value:this.length-3,configurable:!0}):Object.defineProperty(this,"segmentsCount",{get:()=>this.length-3,configurable:!0}),this.ts=s,this.tf=r,Object.defineProperty(this,"bounds",{get:()=>D.ofSpline(this,this.pointProps.scattering).ceil(),enumerable:!0}),Object.defineProperty(this,"color",{get:()=>S.isColor(this.pointProps)?S.fromColor(this.pointProps):void 0,set:t=>{if(!t)throw new Error("Spline color cannot be removed");if(!(t instanceof S))throw new Error("Expected value should be Color instance");"red"in this.pointProps&&(this.pointProps.red=t.red),"green"in this.pointProps&&(this.pointProps.green=t.green),"blue"in this.pointProps&&(this.pointProps.blue=t.blue),"alpha"in this.pointProps&&(this.pointProps.alpha=t.alpha)},enumerable:!0}),this.validate()}validate(){let t=this.points instanceof Float32Array;if(super.validate(),!this.layout.includes(b.Property.X))throw new Error("Layout doesn't contains required properties X");if(!this.layout.includes(b.Property.Y))throw new Error("Layout doesn't contains required properties Y");if(t&&0==this.points.length)throw new Error("Empty spline is not allowed");if(this.ts<0||this.ts>=1)throw new Error(`Invalid spline ts ${this.ts} found. The value must be in the interval [0, 1).`);if(this.tf<=0||this.tf>1)throw new Error(`Invalid spline tf ${this.tf} found. The value must be in the interval (0, 1].`);if(1==this.segmentsCount&&this.ts>this.tf)throw new Error(`Invalid spline t range ${this.ts} - ${this.tf} found. Spline has only one segment and ts <= tf.`);if(t&&this.segmentsCount<1)throw new Error("Incompleted spline found. Spline is defined with at least 4 control points.")}clone(){return new M(this.layout.slice(),this.points.clone(),Object.clone(this.pointProps),this.ts,this.tf)}slice(t){let e=this.slicePoints(t.pointIndexStart,t.pointIndexEnd),i=new M(this.layout.slice(),e,Object.clone(this.pointProps),t.ts,t.tf);return i.id=t.id,i}getSegment(t){let e=t,i=t+3,s=0==e?this.ts:0,r=i+1==this.length?this.tf:1;return this.slice({pointIndexStart:e,pointIndexEnd:i,ts:s,tf:r})}getFragment(t=0,e=this.ts,i=this.segmentsCount-1,s=this.tf,r=!1){return new N(this,t,e,r?i-3:i,s)}toPlainPath(){let t=new x([]);for(let e=0;e<this.length;e++)t.points.push(this.getPointX(),this.getPointY());return t}toJSON(){return{type:"Spline",id:this.id,layout:this.layout.map((t=>t.name)),points:v.encode(this.points,this.encoding),pointProps:this.pointProps,ts:this.ts,tf:this.tf}}static fromJSON(t){let e=v.decode(t.points),i=new M(t.layout.map((t=>b.Property[t])),e,t.pointProps,t.ts,t.tf);return i.id=t.id,i}static fromRect(t,e){let i=[t.left,t.top,t.left,t.top,t.right,t.top,t.right,t.bottom,t.left,t.bottom,t.left,t.top,t.left,t.top];return new M(void 0,i,e)}static createInstance(t,e,i=[],s,r){return new M(t,i,e,s,r)}static createSharedInstance(t,e,i,s,r){return new M(t,Float32Array.createSharedInstance(e),i,s,r)}}class L extends x{constructor(t,e,i,s=[]){super(e,i,t),s.length>0&&!Object.isFrozen(s.first)&&s.forEach((t=>Object.freeze(t))),Object.defineProperty(this,"splineParameters",{value:Object.freeze(s),enumerable:!0});let r=new I(t,i);Object.defineProperty(this,"style",{get:()=>r.style,set:t=>r.style.reset(t),enumerable:!0}),Object.defineProperty(this,"color",{get:()=>this.style.color,set:t=>{if(!t)throw new Error("Spline color cannot be removed");if(!(t instanceof S))throw new Error("Expected value should be Color instance");"red"in this.pointProps&&(this.pointProps.red=t.red),"green"in this.pointProps&&(this.pointProps.green=t.green),"blue"in this.pointProps&&(this.pointProps.blue=t.blue),"alpha"in this.pointProps&&(this.pointProps.alpha=t.alpha)},enumerable:!0}),Object.defineProperty(this,"bounds",{get:()=>D.ofSpline(this,this.pointProps.scattering).ceil(),enumerable:!0}),this.validate()}validate(){let t=this.points instanceof Float32Array;if(super.validate(),!this.layout.includes(b.Property.X))throw new Error("Layout doesn't contains required properties X");if(!this.layout.includes(b.Property.Y))throw new Error("Layout doesn't contains required properties Y");if(t&&0==this.points.length)throw new Error("Empty spline is not allowed")}clone(){return new L(this.layout.slice(),this.points.clone(),Object.clone(this.pointProps),this.splineParameters.slice())}slice(t){let e=this.slicePoints(t.pointIndexStart,t.pointIndexEnd);return new L(this.layout.slice(),e,Object.clone(this.pointProps),this.splineParameters.slice())}getPoint(t){return super.getPoint(t,this.style)}getPointRef(t){return super.getPointRef(t,this.style)}getPointSegmentIndex(t){return this.splineParameters[t]?this.splineParameters[t].index:void 0}getPointT(t){return this.splineParameters[t]?this.splineParameters[t].t:void 0}getPointParameter(t){return this.splineParameters[t]}toJSON(){return{type:"InterpolatedSpline",layout:this.layout.map((t=>t.name)),points:v.encode(this.points,this.encoding),pointProps:this.pointProps,splineParameters:this.splineParameters}}static fromJSON(t){let e=v.decode(t.points);return new L(t.layout.map((t=>b.Property[t])),e,t.pointProps,t.splineParameters.map(A.fromJSON))}static fromRect(t,e){throw new Error("InterpolatedSpline.fromRect is not supported. Try Spline.fromRect and interpolate with particular Spline interpolator.")}static createInstance(t,e,i=[]){return new L(t,i,e)}static createSharedInstance(t,e,i,s){return new L(t,Float32Array.createSharedInstance(e),i,s)}}class _{constructor(){this.phase=_.Phase.END}add(t,e,i){if(!this.move(t))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${t.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,t.name)),this.addImpl(e,i)}addImpl(t,e){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(t){return(this.phase!=_.Phase.END||t==_.Phase.BEGIN)&&((this.phase!=_.Phase.BEGIN||t==_.Phase.UPDATE||t==_.Phase.END)&&((this.phase!=_.Phase.UPDATE||t==_.Phase.UPDATE||t==_.Phase.END)&&(t==_.Phase.BEGIN&&this.reset(),this.phase=t,!0)))}reset(){this.phase=_.Phase.END}}Object.defineEnum(_,"Phase",["BEGIN","UPDATE","END"]);let F=h?h.default||globalThis.poly2tri:{};const{SweepContext:k,Point:j}=F;let $=l?l.default||globalThis.ClipperLib:{};const{Clipper:U,Paths:B,Path:Y,ClipType:X,PolyType:z,PolyFillType:G}=$;class H{constructor(t,e){if(!Array.isArray(t))throw new Error("Unexpected polygons type found");let i=65534/(e.width+1e-16),s=65534/(e.height+1e-16),r=Math.floor(Math.min(i,s));if(0==r)throw new Error(`Insufficent clipper range - (-32767 - 32767), scale failed - scaleX: ${i}, scaleY: ${s}`);let n=e.left+32767/r,a=e.top+32767/r;this.solution=new B,this.bounds=e,this.transform={scale:r,offsetX:n,offsetY:a},this.subject=this.apply(t)}convertPoint(t){let e=(t.x-this.transform.offsetX)*this.transform.scale,i=(t.y-this.transform.offsetY)*this.transform.scale;return{X:e<0?Math.ceil(e):Math.floor(e),Y:i<0?Math.ceil(i):Math.floor(i)}}containsPoint(t){return U.PointInPolygon(this.convertPoint(t),this.solution)}apply(t){let e=new B;for(let i of t){let t=new Y,s=i.shape;for(let e=0;e<s.length;e++)t.push(this.convertPoint({x:s.getPointX(e),y:s.getPointY(e)}));e.push(t)}return e}toPaths(){let t=[];this.lastPoint={};for(let e of this.solution){if(0==e.length)continue;let i=this.flatPath(e);i.length>0&&t.push(i)}return t}flatPath(t){let e=[];for(let i of t)this.lastPoint.X==i.X&&this.lastPoint.Y==i.Y||(e.push(i.X/this.transform.scale+this.transform.offsetX,i.Y/this.transform.scale+this.transform.offsetY),this.lastPoint=i);return e.length<6&&(console.warn(`Invalid contour found: [${e.join(", ")}]`),e.clear()),e}}class J{constructor(t=2){this.stride=t}sort(t,e){return this.sortArrayPart(t,0,t.length-this.stride,e),t}partition(t,e,i,s){let r=t[i],n=t[i+1],a=e-this.stride;for(let o=e;o<i;o+=2)s?s(r,n,t[o],t[o+1])&&(a+=this.stride,this.swap(t,a,o)):(r>t[o]||r==t[o]&&n>t[o+1])&&(a+=this.stride,this.swap(t,a,o));return this.swap(t,a+this.stride,i),a+this.stride}swap(t,e,i){let s=t[e],r=t[e+1];return t[e]=t[i],t[e+1]=t[i+1],t[i]=s,t[i+1]=r,t}sortArrayPart(t,e,i,s){if(e<i){let r=this.partition(t,e,i,s);this.sortArrayPart(t,e,r-this.stride,s),this.sortArrayPart(t,r+this.stride,i,s)}}}function V(t,e,i,s,r,n){return(i-t)*(n-e)-(s-e)*(r-t)}function Z(t,e,i,s,r,n){let a=t-i,o=r-i,h=a*(n-s)-o*(e-s);h*=h,a=r-i,o=n-s;let l=a*a+o*o;return l>0?Math.sqrt(h/l):Math.sqrt((i-t)*(i-t)+(s-e)*(s-e))}class q{constructor(t=Float32Array){this.ArrayType=t,this.quickSort=new J}monotoneChain(t){if(t.length<=0)return new this.ArrayType;this.quickSort.sort(t);let e=new this.ArrayType(t.length),i=0;for(let s=0;s<t.length;s+=2){for(;i>=4&&V(e[i-4],e[i-3],e[i-2],e[i-1],t[s],t[s+1])<=0;)i-=2;e[i]=t[s],e[i+1]=t[s+1],i+=2}e=e.slice(0,i);let s,r=new this.ArrayType(t.length);i=0;for(let e=t.length-2;e>=0;e-=2){for(;i>=4&&V(r[i-4],r[i-3],r[i-2],r[i-1],t[e],t[e+1])<=0;)i-=2;r[i]=t[e],r[i+1]=t[e+1],i+=2}if(r=r.slice(0,i-2),this.ArrayType==Float32Array){let t=r.length+e.length;s=Float32Array.createSharedInstance(t),s.set(r),s.set(e,r.length)}else s=r.concat(e);return s}}class W{constructor(t,e=[]){if(!(t instanceof x))throw new Error("Expected shape type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");if(e.some((t=>!(t instanceof x))))throw new Error("Expected hole type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");let i;this.holesDirection=W.PointsDirection.CLOCKWISE,Object.defineProperty(this,"shape",{value:t,enumerable:!0}),Object.defineProperty(this,"holes",{value:e,enumerable:!0}),Object.defineProperty(this,"contours",{value:[t,...e],enumerable:!0}),Object.defineProperty(this,"ArrayType",{value:t.points instanceof Float32Array?Float32Array:Array}),Object.defineProperty(this,"bounds",{get:()=>D.ofPolygon(this),enumerable:!0}),Object.defineProperty(this,"vertices",{get:()=>(i||(i=this.triangulate()),i),set:t=>i=t,enumerable:!0}),Object.defineProperty(this,"verticesValue",{get:()=>i})}clone(t=!1){let e=this.shape.clone(t),i=this.holes.map((e=>e.clone(t))),s=new W(e,i);return this.verticesValue&&(s.vertices=this.vertices.slice()),s}fit(t){let e=this.bounds,i=t.width/e.width,s=t.height/e.height,r=i>0&&s>0?Math.min(i,s):Math.max(i,s);for(let t of this.contours)for(let e=0;e<t.length;e++)t.setPointX(e,t.getPointX(e)*r),t.setPointY(e,t.getPointY(e)*r)}center(){let t=this.bounds;for(let e of this.contours)for(let i=0;i<e.length;i++)e.setPointX(i,e.getPointX(i)-t.center.x),e.setPointY(i,e.getPointY(i)-t.center.y)}transform(t){this.contours.forEach((e=>e.transform(t)))}intersects(t){if(!(t instanceof W))throw new Error("Expected 'poly' type is Polygon");(this.holes.length>0||t.holes.length)&&console.warn("Polygon intersection is for contours only. Holes are ignored.");let e=this.shape,i=t.shape;for(let t=0;t<2;t++){let s=0==t?e:i;for(let t=0;t<s.length;t++){let r=t+1==s.length?0:t+1,n=s.getPointX(t),a=s.getPointY(t),o=s.getPointX(r),h=s.getPointY(r)-a,l=n-o,u=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(let t=0;t<e.length;t++){let i=h*e.getPointX(t)+l*e.getPointY(t);i<u&&(u=i),i>c&&(c=i)}let p=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY;for(let t=0;t<i.length;t++){let e=h*i.getPointX(t)+l*i.getPointY(t);e<p&&(p=e),e>d&&(d=e)}if(c<p||d<u)return!1}}return!0}containsPoint(t){let e=!1,i=this.shape;this.holes.length>0&&console.warn("Polygon intersection is for contours only. Holes are ignored.");for(let s=0,r=i.length-1;s<i.length;r=s++)i.getPointY(s)>t.y!=i.getPointY(r)>t.y&&t.x<(i.getPointX(r)-i.getPointX(s))*(t.y-i.getPointY(s))/(i.getPointY(r)-i.getPointY(s))+i.getPointX(s)&&(e=!e);return e}triangulate(){let t,e=[];for(let t of this.contours){let i=[];for(let e=0;e<t.length;e++){let s=new j(t.getPointX(e),t.getPointY(e));if(e>0){if(i.last.x==s.x&&i.last.y==s.y)continue;if(e==t.length-1&&i.first.x==s.x&&i.first.y==s.y)continue}i.push(s)}e.push(i)}try{t=new k(e.shift())}catch(t){return console.error(t),new Float32Array}for(let i of e)try{t.addHole(i)}catch(t){return console.error(t),new Float32Array}try{t.triangulate()}catch(t){return console.warn(t),new Float32Array}let i=t.getTriangles(),s=Float32Array.createSharedInstance(6*i.length),r=0;for(let t of i){let e=t.getPoints();for(let t of e)s[r++]=t.x,s[r++]=t.y}return s}convex(){return this.buildConvex(this.shape.points)}union(t){let e=Array.of(...this.shape.points,...t.shape.points);return this.buildConvex(e)}buildConvex(t){this.convexHullProducer||(this.convexHullProducer=new q(this.ArrayType));let e=this.convexHullProducer.monotoneChain(t);return this.ArrayType==Float32Array?W.createSharedInstance(e):W.createInstance(e)}simplify(t=.1){let e=new H([this],this.bounds);return e.subject=U.SimplifyPolygons(e.subject,G.pftNonZero),e.solution=U.CleanPolygons(e.subject,t*e.transform.scale),1==e.subject.length&&0==e.solution.first.length&&(e.solution=e.subject),W.toPolygonArray(e.toPaths())}simplifyRamerDouglasPeucker(t=.1){if(t<=0)throw new Error("epsilon expected value > 0");this.epsilon=t;let e=this.simplifyPath(this.shape),i=[];for(let t of this.holes){let e=this.simplifyPath(t);e.length>0&&i.push(e)}return this.ArrayType==Float32Array?W.createSharedInstance(e,i):W.createInstance(e,i)}simplifyPath(t){if(t.length<3)return t.points;let e=Array.of(...t.points,t.getPointX(0),t.getPointY(0)),i=this.simplifyPolyline(e);return i.length<8?e.slice(0,e.length-2):i.slice(0,i.length-2)}simplifyPolyline(t){if(t.length<4)return t;let e=0,i=0;for(let s=2;s<t.length-2;s+=2){let r=Z(t[s],t[s+1],t[0],t[1],t[t.length-2],t[t.length-1]);r>e&&(i=s,e=r)}if(e>this.epsilon){let e=this.simplifyPolyline(t.slice(0,i+2)),s=this.simplifyPolyline(t.slice(i,t.length));return e.concat(s.slice(2,s.length))}return[t[0],t[1],t[t.length-2],t[t.length-1]]}toSVGPath(){return this.contours.map((t=>t.toSVGPath())).join(" ")}toJSON(){return{type:"Polygon",shape:this.shape.toJSON(),holes:this.holes.map((t=>t.toJSON())),holesDirection:this.holesDirection.name,vertices:this.verticesValue}}static fromJSON(t){if("Polygon"!=t.type)throw new Error(`Polygon deserialization failed. JSON type is ${t.type}, expected Polygon.`);let e=x.fromJSON(t.shape),i=t.holes.map((t=>x.fromJSON(t))),s=new W(e,i);return s.holesDirection=W.PointsDirection[t.holesDirection],s.vertices=t.vertices,s}static fromRect(t){return W.createInstance([t.left,t.top,t.right,t.top,t.right,t.bottom,t.left,t.bottom,t.left,t.top])}static createInstance(t,e=[]){return new W(x.createInstance(t),e.map((t=>x.createInstance(t))))}static createSharedInstance(t,e=[]){let i=new W(x.createSharedInstance(t),e.map((t=>x.createSharedInstance(t))));return Object.defineProperty(i,"encoding",{get:()=>i.shape.encoding,set:t=>{i.contours.forEach((e=>e.encoding=t))},enumerable:!0}),i}}Object.defineEnum(W,"PointsDirection",["CLOCKWISE","COUNTERCLOCKWISE"]);class K{static ARRAY_TYPE=Array;#s;constructor(){this.keepAllData=!1,Object.defineProperty(this,"allData",{get:()=>{if(!this.keepAllData)throw new Error("All data is not accumulated. By default keepAllData property is false.");return this.#s||(this.#s=new this.constructor.ARRAY_TYPE),this.getOutput(this.#s,K.OutputType.ALL_DATA)},enumerable:!0})}build(t,e=K.OutputType.PROCESSOR,i=!0){return console.warn("use process instead"),this.process(t,e,i)}process(t,e=K.OutputType.PROCESSOR,i=!0){let s;switch(e){case K.OutputType.ADDITION:s=this.add(t,i);break;case K.OutputType.PREDICTION:s=this.predict(t);break;case K.OutputType.PROCESSOR:this.reset(),s=this.processImpl(t,e);break;default:throw new Error("Unexpected OutputType found. Allowed type is oneof(ADDITION, PREDICTION, PROCESSOR)")}return e!=K.OutputType.PREDICTION&&this.keepAllData&&(this.#s||(this.#s=new this.constructor.ARRAY_TYPE),s instanceof W?this.#s.push(s):e==K.OutputType.PROCESSOR?this.#s=s:this.#s.push(...s)),this.debug&&console.log(this.constructor.name,e.name,i,s),this.getOutput(s,e)}add(t,e=!1){return this.processImpl(t,K.OutputType.ADDITION)}predict(t){return this.processImpl(t,K.OutputType.PREDICTION)}processImpl(t,e){throw new Error("Abstract method processImpl(input, type) of DataSequenceProcessor should be implemented")}getOutput(t,e){return t}reset(){this.#s&&(this.#s=new this.constructor.ARRAY_TYPE)}}Object.defineEnum(K,"OutputType",["ADDITION","PREDICTION","ALL_DATA","PROCESSOR"]);class Q extends _{constructor(t,e){super(),this.layout=t,this.pathPointCalculator=e,this.inputBuffer=[],this.prediction=!0}togglePrediction(t){console.warn("PathProducer togglePrediction method is deprecated. Use InkBuilder instance prediction property to configure prediction behaviour."),this.prediction=t}addImpl(t,e){if(t.phase!=this.phase)throw new Error(`The phase of the addition (${t.phase.name}) doesn't match the phase of the PathProducer (${this.phase.name})`);let i=[],s=[];t&&this.inputBuffer.push(t);let r=this.inputBuffer.length>=3?this.inputBuffer[this.inputBuffer.length-3]:null,n=this.inputBuffer.length>=2?this.inputBuffer[this.inputBuffer.length-2]:null,a=this.inputBuffer.length>=1?this.inputBuffer[this.inputBuffer.length-1]:null,o=this.calculate(r,n,a);return t&&o&&i.push(...o.toArray(this.layout)),this.phase==_.Phase.END?(o=this.calculate(n,a,null),o&&i.push(...o.toArray(this.layout))):this.prediction&&(this.phase==_.Phase.UPDATE||e)&&(o=this.calculate(n,a,e),o&&(s.push(...o.toArray(this.layout)),o=this.calculate(a,e,null),o&&s.push(...o.toArray(this.layout)))),{added:i,predicted:s}}calculate(t,e,i){return e?this.pathPointCalculator(t,e,i):null}reset(){super.reset(),this.inputBuffer.clear()}}const tt=[-6e-6,-139e-6,-185e-6,414e-6,.002357,.003357,-.003135,-.023928,-.042909,-.017858,.096525,.254692,.347072,.26881,.114933];class et extends K{#r=[];#n=0;constructor(t,e=15){super(),this.filter=tt.slice(),Object.defineProperty(this,"movingAverageWindowSize",{get:function(){return e},set:function(t){e=t,this.filter.length!=t&&(this.filter=et.resample(tt,t)),this.predictionPointsCount=4*t/15,this.windowSize=this.filter.length},enumerable:!0}),this.dimsCount=t,this.movingAverageWindowSize=e}add(t,e){return e?this.project(t):this.addSequence(t)}processImpl(t){return this.project(t)}project(t){if(t.length%this.dimsCount!=0)throw new Error(`Points size ('${t.length}') must be multiple of the dimensions count ('${this.dimsCount}').`);if(0==t.length)return[];let e=[],i=this.#r.slice(),s=t.slice(0,t.length-this.dimsCount),r=this.addSequence(s);e.push(...r);let n=t.slice(t.length-this.dimsCount,t.length),a=this.predictionPointsCount;for(let t=0;t<a;t++){let i=this.addPoint(n);a-t<=this.#n&&e.push(...i)}return this.#r=i,e}addSequence(t){if(t.length%this.dimsCount!=0)throw new Error(`Points size ('${t.length}') must be multiple of the dimensions count ('${this.dimsCount}').`);let e=[],i=t.length/this.dimsCount;for(let s=0;s<i;s++){let i=this.addPoint(t.slice(s*this.dimsCount,(s+1)*this.dimsCount));e.push(...i)}return this.#n+=i,e}addPoint(t){for(this.#r.push(...t);this.#r.length<this.windowSize*this.dimsCount;)this.#r.unshift(...this.#r.slice(0,this.dimsCount));for(;this.#r.length>this.windowSize*this.dimsCount;)this.#r=this.#r.slice(this.dimsCount);return this.filterBuffer()}filterBuffer(){let t=[];for(let e=0;e<this.windowSize;e++)for(let i=0;i<this.dimsCount;i++)isNaN(t[i])&&(t[i]=0),t[i]+=this.#r[e*this.dimsCount+i]*this.filter[e];return t}reset(){super.reset(),this.#n=0,this.#r.clear()}static resample(t,e){let i=new Float32Array(e),s=t.length/e,r=0;for(let n=0;n<e;n++){let a=(t.length-1)*n/(e-1),o=Math.floor(a),h=Math.ceil(a),l=a-o,u=s*(t[o]*(1-l)+t[h]*l);r+=u,i[n]=u}let n=1/r;for(let t=0;t<e;t++)i[t]*=n;return i}}class it extends K{#a;#o;constructor(t){super(),this.layout=t,this.pathPointProps={}}add(t,e){this.#a||(this.#a=M.createInstance(this.layout,this.pathPointProps)),0==this.#a.points.length&&t.length>0&&t.unshift(...t.slice(0,this.layout.length)),e&&(t.length>=this.layout.length?t.push(...t.slice(t.length-this.layout.length,t.length)):t.push(...this.getLastPart()));let i=this.getFirstPart();return this.#a.points=i.concat(t),t}predict(t=[]){if(0==t.length)return t;this.#o?this.#o.points.clear():this.#o=M.createInstance(this.layout,this.pathPointProps);let e=this.#o.points,i=this.getFirstPart();for(e.push(...i),e.push(...t),e.push(...e.slice(e.length-this.layout.length,e.length));e.length<4*this.layout.length;)e.unshift(e.slice(0,this.layout.length));return e}processImpl(t){let e=[];return t.length>0&&(e.push(...t.slice(0,this.layout.length)),e.push(...t),t.length>=this.layout.length&&e.push(...t.slice(t.length-this.layout.length,t.length))),t}getOutput(t,e){if(e==it.OutputType.ADDITION){if(this.#a.points.length>=4*this.layout.length)return this.#a}else if(e==it.OutputType.PREDICTION){if(this.#o.points.length>0)return this.#o}else if(t.length>0)return M.createSharedInstance(this.layout,t,this.pathPointProps)}getFirstPart(){return this.#a.points.slice(Math.max(0,this.#a.points.length-3*this.layout.length),this.#a.points.length)}getLastPart(){return this.#a.points.slice(this.#a.points.length-this.layout.length,this.#a.points.length)}reset(){super.reset(),this.#a=null,this.#o=null}}const st=s.fromValues(0,-.5,1,-.5,1,0,-2.5,1.5,0,.5,2,-1.5,0,0,-.5,.5);class rt extends K{#a;#o;#h;constructor(t=!1,e=!1){super(),this.calculateDerivates=t,this.keepSplineParameters=e,this.state={segmentIndex:-1,lastPointPosition:void 0,lastPointSize:0}}initState(t){this.state.layout={},t.layout.forEach(((t,e)=>{this.state.layout[t.name]={index:e,polynomials:i.create()}})),this.keepSplineParameters?this.state.splineParameters?this.state.splineParameters.clear():this.state.splineParameters=[]:delete this.state.splineParameters,this.splineLayout=t.layout,this.pathPointProps=Object.clone(t.pointProps),this.scattering&&(this.pathPointProps.scattering=this.scattering),this.layout=this.calculateDerivates?t.layout.concat([b.Property.D_X,b.Property.D_Y]):t.layout,this.state.ready=!0}predict(t){if(!t)return[];this.state.ready||this.initState(t),this.#o?this.#o.points.clear():this.#o=L.createInstance(this.layout,this.pathPointProps),this.path=this.#o;let e=Object.clone(this.state);return delete this.state.splineParameters,this.resetState(),this.discretize(t),this.state=e,this.path.points}processImpl(t,e){if(!t)return[];let i;return t instanceof N&&(i=t,t=i.spline),this.state.ready||this.initState(t),e==rt.OutputType.ADDITION?(this.#a?this.#a.points.clear():this.#a=L.createInstance(this.layout,this.pathPointProps),this.path=this.#a):(this.#h=L.createInstance(this.layout,this.pathPointProps),this.path=this.#h),this.discretize(t,i),this.path.points}getOutput(t,e){if(0!=t.length){if(e==rt.OutputType.PROCESSOR||e==rt.OutputType.ALL_DATA){let e=this.state.splineParameters;return e&&(e=e.slice()),L.createSharedInstance(this.layout,t,this.pathPointProps,e)}return this.path}}calculateInterpolatedPoint(t,e,s){this.initState(t);let r=new b(0,0,this.splineLayout.includes(b.Property.Z)?0:void 0),n=i.fromValues(1,s,s*s,s*s*s);return this.calculatePolynomials(t,e),this.splineLayout.forEach((t=>{let e=i.dot(this.state.layout[t.name].polynomials,n);r[w.getPropName(t.name)]=e})),r}discretize(t,e){throw new Error("This method is abstract and should be implemented")}storeLastPoint(t,e=0){this.state.lastPointPosition=new u(this.getPropValue(b.Property.X,t,e),this.getPropValue(b.Property.Y,t,e),this.getPropValue(b.Property.Z,t,e)),this.state.lastP...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/workers/InkPathProvider.mjs line 1
- Likely real
- Yes, 99% confidence
`e.replace("[",".").replace` method will only replace the first occurrence when used with a string argument ("]"). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
import"js-ext";import{vec2 as t,vec3 as e,vec4 as i,mat4 as s,quat2 as r,mat2d as n}from"gl-matrix";import a from"long";import*as o from"js-md5";import*as h from"poly2tri";import*as l from"clipper-lib";"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=i=>{let s="message"==t?i.data:i;e(s)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=i=>{let s="message"==t?i.data:i;e(s)}});class u{constructor(s,r,n,a){if(isNaN(s))throw new Error(`Invalid x found: ${s}`);if(isNaN(r))throw new Error(`Invalid y found: ${r}`);let o=[s,r];isFinite(n)&&(o.push(n),isFinite(a)&&o.push(a)),this.value=o.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:t=>{this.value[0]=t},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:t=>{this.value[1]=t},enumerable:!0}),2==o.length?this.vec=t:3==o.length?(this.vec=e,Object.defineProperty(this,"z",{get:()=>this.value[2],set:t=>{this.value[2]=t},enumerable:!0})):(this.vec=i,Object.defineProperty(this,"w",{get:()=>this.value[3],set:t=>{this.value[3]=t},enumerable:!0}))}add(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.add(e,this.value,t.value),u.fromPoint(e)}addSelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.add(this.value,this.value,t.value),this}subtract(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.subtract(e,this.value,t.value),u.fromPoint(e)}subtractSelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.subtract(this.value,this.value,t.value),this}multiply(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.multiply(e,this.value,t.value),u.fromPoint(e)}multiplySelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.multiply(this.value,this.value,t.value),this}divide(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.divide(e,this.value,t.value),u.fromPoint(e)}divideSelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.divide(this.value,this.value,t.value),this}scale(t){let e=this.vec.create();return this.vec.scale(e,this.value,t),u.fromPoint(e)}scaleSelf(t){return this.vec.scale(this.value,this.value,t),this}abs(){return new u(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(t){if(!t)return this;let e=this.vec.create();return this.vec.transformMat4(e,this.value,t.toFloat32Array()),u.fromPoint(e)}transformSelf(t){return this.vec.transformMat4(this.value,this.value,t.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let t={x:this.x,y:this.y};return isFinite(this.z)&&(t.z=this.z,isFinite(this.w)&&(t.w=this.w)),t}toString(){return`point(${this.value.join(", ")})`}clone(){return u.fromPoint(this)}static fromPoint(t){return Array.isArray(t)||ArrayBuffer.isTypedArray(t)?new u(t[0],t[1],t[2],t[3]):new u(t.x,t.y,t.z,t.w)}}const c={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},p=c.m11,d=c.m12,f=c.m21,m=c.m22,g=c.m41,y=c.m42;class P{constructor(t=s.create(),e=P.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:t,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:e,enumerable:!0});let i=function(t,e){let i=c[t];this.value[i]=e};Object.defineProperty(this,"a",{get:()=>this.value[p],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[d],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[f],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[m],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[g],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[y],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[g],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[y],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:i.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:i.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:i.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:i.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:i.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:i.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:i.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:i.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:i.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:i.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new P(this.value.clone(),this.multiplicationType)}translate(t){return this.multiply(P.fromTranslate(t))}translateSelf(t){this.multiplySelf(P.fromTranslate(t))}rotate(t,e){return this.multiply(P.fromRotate(t,e))}rotateSelf(t,e){this.multiplySelf(P.fromRotate(t,e))}scale(t,e){return this.multiply(P.fromScale(t,e))}scaleSelf(t,e){this.multiplySelf(P.fromScale(t,e))}multiply(t){return this.multiplicationType==P.MultiplicationType.PRE?this.preMultiply(t):this.postMultiply(t)}preMultiply(t){let e=s.create();return s.multiply(e,t.toFloat32Array(),this.value),new P(e,this.multiplicationType)}postMultiply(t){let e=s.create();return s.multiply(e,this.value,t.toFloat32Array()),new P(e,this.multiplicationType)}multiplySelf(t){this.multiplicationType==P.MultiplicationType.PRE?this.preMultiplySelf(t):this.postMultiplySelf(t)}preMultiplySelf(t){s.multiply(this.value,t.toFloat32Array(),this.value)}postMultiplySelf(t){s.multiply(this.value,this.value,t.toFloat32Array())}invert(){let t=s.create();return s.invert(t,this.value),new P(t,this.multiplicationType)}invertSelf(){s.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(t){return u.fromPoint(t).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(t){if(t){let t=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${t(this.m11)}, ${t(this.m21)}, ${t(this.m31)}, ${t(this.m41)}`+`\n${t(this.m12)}, ${t(this.m22)}, ${t(this.m32)}, ${t(this.m42)}`+`\n${t(this.m13)}, ${t(this.m23)}, ${t(this.m33)}, ${t(this.m43)}`+`\n${t(this.m14)}, ${t(this.m24)}, ${t(this.m34)}, ${t(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(t,e){let i=s.create();if("none"!=t){let e=t.substring(0,t.indexOf("("));t=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g),"matrix3d"==e?(i[0]=parseFloat(t[0]),i[1]=parseFloat(t[1]),i[2]=parseFloat(t[2]),i[3]=parseFloat(t[3]),i[4]=parseFloat(t[4]),i[5]=parseFloat(t[5]),i[6]=parseFloat(t[6]),i[7]=parseFloat(t[7]),i[8]=parseFloat(t[8]),i[9]=parseFloat(t[9]),i[10]=parseFloat(t[10]),i[11]=parseFloat(t[11]),i[12]=parseFloat(t[12]),i[13]=parseFloat(t[13]),i[14]=parseFloat(t[14]),i[15]=parseFloat(t[15])):(i[p]=parseFloat(t[0]),i[d]=parseFloat(t[1]),i[f]=parseFloat(t[2]),i[m]=parseFloat(t[3]),i[g]=parseFloat(t[4]),i[y]=parseFloat(t[5]))}return new P(i,e)}static fromMatrix(t,e){if(!t)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof t)throw new Error("data type function is not allowed");if(t instanceof P)return t;if(Array.isArray(t)&&(t=new Float32Array(t)),t instanceof Float32Array)return new P(t,e);if("string"==typeof t)return P.fromString(t,e);let i=s.create(),r=Object.assign({},t);return isFinite(t.a)&&(r.m11=t.a),isFinite(t.b)&&(r.m12=t.b),isFinite(t.c)&&(r.m21=t.c),isFinite(t.d)&&(r.m22=t.d),isFinite(t.tx)?r.m41=t.tx:isFinite(t.e)?r.m41=t.e:isFinite(t.dx)&&(r.m41=t.dx),isFinite(t.ty)?r.m42=t.ty:isFinite(t.f)?r.m42=t.f:isFinite(t.dy)&&(r.m42=t.dy),isFinite(r.m11)&&(i[0]=r.m11),isFinite(r.m12)&&(i[1]=r.m12),isFinite(r.m13)&&(i[2]=r.m13),isFinite(r.m14)&&(i[3]=r.m14),isFinite(r.m21)&&(i[4]=r.m21),isFinite(r.m22)&&(i[5]=r.m22),isFinite(r.m23)&&(i[6]=r.m23),isFinite(r.m24)&&(i[7]=r.m24),isFinite(r.m31)&&(i[8]=r.m31),isFinite(r.m32)&&(i[9]=r.m32),isFinite(r.m33)&&(i[10]=r.m33),isFinite(r.m34)&&(i[11]=r.m34),isFinite(r.m41)&&(i[12]=r.m41),isFinite(r.m42)&&(i[13]=r.m42),isFinite(r.m43)&&(i[14]=r.m43),isFinite(r.m44)&&(i[15]=r.m44),new P(i,e||t.multiplicationType)}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return P.fromMatrix(e)}static fromRotate(t,e){let i=Math.sin(t),s=Math.cos(t),r={a:s,b:i,c:-i,d:s};return e&&(r.tx=e.x-e.x*s+e.y*i,r.ty=e.y-e.x*i-e.y*s),P.fromMatrix(r)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let i={a:t.x,d:t.y};return e&&(i.tx=e.x-e.x*t.x,i.ty=e.y-e.y*t.y),P.fromMatrix(i)}static fromPoints(t,e){if(!Array.isArray(t)||!Array.isArray(e))throw new Error("Expected input type Array requirement not satisfied");if(3!=t.length||3!=e.length)throw new Error("Expected input size 3 requirement not satisfied");let i=P.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=P.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),r=i.invert().preMultiply(s);return P.fromMatrix({a:r.m11,b:r.m12,c:r.m21,d:r.m22,tx:r.m31,ty:r.m32})}static multiply(t,e){let i=s.create();return s.multiply(i,t.value,e.value),new P(i)}}P.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});class b extends u{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(t,e,i,s={}){super(t,e,i),this.red=s.red,this.green=s.green,this.blue=s.blue,this.alpha=s.alpha,this.size=s.size||b.defaults.size,this.rotation=s.rotation||b.defaults.rotation,this.scaleX=s.scaleX||b.defaults.scaleX,this.scaleY=s.scaleY||b.defaults.scaleY,this.scaleZ=isFinite(i)?s.scaleZ||b.defaults.scaleZ:void 0,this.offsetX=s.offsetX||b.defaults.offsetX,this.offsetY=s.offsetY||b.defaults.offsetY,this.offsetZ=isFinite(i)?s.offsetZ||b.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(t,e,i,s=0){let r=new b(0,0,t.includes(b.Property.Z)?0:void 0);return i&&r.fill(s,i,t,e),r}fill(t,e,i,s={}){let r={},n=t*i.length;i.forEach(((t,i)=>b.setProperty(r,t,e[n+i]))),this.x=r.x,this.y=r.y,this.z=r.z,this.red=isFinite(r.red)?r.red:s.red,this.green=isFinite(r.green)?r.green:s.green,this.blue=isFinite(r.blue)?r.blue:s.blue,this.alpha=isFinite(r.alpha)?r.alpha:s.alpha,this.size=r.size||s.size||b.defaults.size,this.rotation=r.rotation||s.rotation||b.defaults.rotation,this.scaleX=r.scaleX||s.scaleX||b.defaults.scaleX,this.scaleY=r.scaleY||s.scaleY||b.defaults.scaleY,this.scaleZ=isFinite(r.z)?r.scaleZ||s.scaleZ||b.defaults.scaleZ:void 0,this.offsetX=r.offsetX||s.offsetX||b.defaults.offsetX,this.offsetY=r.offsetY||s.offsetY||b.defaults.offsetY,this.offsetZ=isFinite(r.z)?r.offsetZ||s.offsetZ||b.defaults.offsetZ:void 0,this.dX=r.dX,this.dY=r.dY}getProperty(t){switch(t){case b.Property.X:return this.x;case b.Property.Y:return this.y;case b.Property.Z:return this.z;case b.Property.RED:return this.red;case b.Property.GREEN:return this.green;case b.Property.BLUE:return this.blue;case b.Property.ALPHA:return this.alpha;case b.Property.SIZE:return this.size;case b.Property.ROTATION:return this.rotation;case b.Property.SCALE_X:return this.scaleX;case b.Property.SCALE_Y:return this.scaleY;case b.Property.SCALE_Z:return this.scaleZ;case b.Property.OFFSET_X:return this.offsetX;case b.Property.OFFSET_Y:return this.offsetY;case b.Property.OFFSET_Z:return this.offsetZ;case b.Property.D_X:return this.dX;case b.Property.D_Y:return this.dY;default:throw console.warn(t),new Error("Invalid property found")}}setProperty(t,e){b.setProperty(this,t,e)}static setProperty(t,e,i){switch(e){case b.Property.X:t.x=i;break;case b.Property.Y:t.y=i;break;case b.Property.Z:t.z=i;break;case b.Property.RED:t.red=i;break;case b.Property.GREEN:t.green=i;break;case b.Property.BLUE:t.blue=i;break;case b.Property.ALPHA:t.alpha=i;break;case b.Property.SIZE:t.size=i;break;case b.Property.ROTATION:t.rotation=i;break;case b.Property.SCALE_X:t.scaleX=i;break;case b.Property.SCALE_Y:t.scaleY=i;break;case b.Property.SCALE_Z:t.scaleZ=i;break;case b.Property.OFFSET_X:t.offsetX=i;break;case b.Property.OFFSET_Y:t.offsetY=i;break;case b.Property.OFFSET_Z:t.offsetZ=i;break;case b.Property.D_X:t.dX=i;break;case b.Property.D_Y:t.dY=i;break;default:throw console.warn(e),new Error("Invalid property found")}}transform(t){if(!(t instanceof P))throw new Error(`matrix is instance of ${t.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let e=t.scaleX,i=t.rotation;this.transformSelf(t),this.size*=e,this.rotation+=i}toArray(t){return t.map((t=>{let e=this.getProperty(t);if(null==e||isNaN(e))throw new Error(`Property ${t.name} has invalid value ${e}`);return e}))}toJSON(){let t={};return b.Property.values.forEach((e=>{let i=this.getProperty(e);null!=i&&isFinite(i)&&(t[e.name]=this.getProperty(e))})),t}}Object.defineEnum(b,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]);class E{constructor(t,e,i){Object.defineProperties(this,{path:{value:t,enumerable:!0},pointIndexStart:{value:e,enumerable:!0},pointIndexEnd:{value:i,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.path.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in path index is ${this.path.length-1}.`)}toPath(){return this.path.slice(this)}toString(){return`fragment(${this.pointIndexStart} - ${this.pointIndexEnd})`}}class S{constructor(t,e,i,s=1){if(this.red=t,this.green=e,this.blue=i,this.alpha=s,s<0||s>1)throw new Error(`Invalid alpha ${s} found. The value must be in the interval [0, 1].`);Object.defineProperty(this,"hex",{get:()=>`#${this.red.toString(16).pad(2,"0")}${this.green.toString(16).pad(2,"0")}${this.blue.toString(16).pad(2,"0")}${Math.round(255*this.alpha).toString(16).pad(2,"0")}`,enumerable:!0})}premultiply(){return{red:this.red/255*this.alpha,green:this.green/255*this.alpha,blue:this.blue/255*this.alpha,alpha:this.alpha}}static postdivide(t,e,i,s){let r=parseInt(255*t/s),n=parseInt(255*e/s),a=parseInt(255*i/s);return new S(r,n,a,s)}equals(t){return t&&this.red==t.red&&this.green==t.green&&this.blue==t.blue&&this.alpha==t.alpha}toRGB(){return 1==this.alpha?this:new S(this.red,this.green,this.blue)}toRGBA(t){return new S(this.red,this.green,this.blue,t)}toHSLA(){let t=this.red/255,e=this.green/255,i=this.blue/255,s=Math.min(t,e,i),r=Math.max(t,e,i),n=0,a=0,o=(r+s)/2;if(r!=s){let h=r-s;switch(a=h/(1-Math.abs(2*o-1)),r){case t:n=(e-i)/h%6;break;case e:n=(i-t)/h+2;break;case i:n=(t-e)/h+4}}return n*=60,n<0&&(n+=360),{hue:parseFloat(n.toFixed(0)),saturation:parseFloat((100*a).toFixed(2)),lightness:parseFloat((100*o).toFixed(2)),alpha:this.alpha}}toArray(){return[this.red,this.green,this.blue,this.alpha]}toJSON(){return{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}}toString(){return 1==this.alpha?`rgb(${this.red}, ${this.green}, ${this.blue})`:`rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`}static isColor(t){return t&&isFinite(t.red)&&isFinite(t.green)&&isFinite(t.blue)}static fromColor(t){let e,i,s,r;if("string"==typeof t)if(t.startsWith("rgb"))t=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g),e=parseInt(t[0]),i=parseInt(t[1]),s=parseInt(t[2]),r=t[3]?parseInt(t[3]):1;else{if(!t.startsWith("#"))throw new Error(`Unknown input found: ${t}. Expected data starts with rgba, rgb or #.`);t=t.substring(1),e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16),r=8==t.length?parseInt(t.substring(6,8),16)/255:1}else Array.isArray(t)?(e=t[0],i=t[1],s=t[2],r=t[3]):(e=t.red,i=t.green,s=t.blue,r=t.alpha);return new S(e,i,s,r)}static fromHSLA(t=0,e=0,i=0,s){t/=60,e/=100,i/=100;let r=(1-Math.abs(2*i-1))*e,n=r*(1-Math.abs(t%2-1)),a=0,o=0,h=0;t>=0&&t<1?(a=r,o=n):t>=1&&t<2?(a=n,o=r):t>=2&&t<3?(o=r,h=n):t>=3&&t<4?(o=n,h=r):t>=4&&t<5?(a=n,h=r):(a=r,h=n);let l=i-r/2;return a+=l,o+=l,h+=l,new S(Math.round(255*a),Math.round(255*o),Math.round(255*h),s)}static random(t=!1){return new S(Math.randomInt(0,255),Math.randomInt(0,255),Math.randomInt(0,255),t?Math.random():1)}}S.TRANSPERENT=new S(0,0,0,0),S.BLACK=new S(0,0,0,1),S.WHITE=new S(255,255,255,1),S.RED=new S(255,0,0,1),S.GREEN=new S(0,255,0,1),S.BLUE=new S(0,0,255,1);let w={longToByteArray(t){let e=[0,0,0,0,0,0,0,0];for(let i=0;i<e.length;i++){let s=255&t;e[i]=s,t=(t-s)/256}return e},byteArrayToLong(t){let e=0;for(let i=t.length-1;i>=0;i--)e=256*e+t[i];return e},crc32:function(){let t=new Uint32Array(256);for(let e=256;e--;){let i=e;for(let t=8;t--;)i=1&i?3988292384^i>>>1:i>>>1;t[e]=i}return function(e){let i=-1;for(let s=0,r=e.length;s<r;s++)i=i>>>8^t[255&i^e[s]];return(-1^i)>>>0}}(),encodeBitMask(t=[]){if(0==t.length)return 0;let e="",i=Math.max(...t);for(let s=1;s<=i;s++)e+=t.includes(s)?"1":"0";return parseInt(e.split("").reverse().join(""),2)},decodeBitMask(t){let e=[],i=t.toString(2).split("").reverse();for(let t=0;t<i.length;t++)1==i[t]&&e.push(t+1);return e},mapTo:(t,e,i)=>i.min+(w.clamp(t,e)-e.min)/(e.max-e.min)*(i.max-i.min),clamp:(t,e)=>Math.min(Math.max(t,e.min),e.max),debounce(t,e){let i=null;return function(){let s=this,r=arguments;clearTimeout(i),i=setTimeout((function(){t.apply(s,r)}),e)}},comparator(){let t=Array.prototype.slice.call(arguments),e=function(t,e,i){return e.replace("[",".").replace("]","").split(".").forEach((e=>t=t[e])),i?t.toLowerCase():t};return function(i,s){return t.map((t=>function(t,e,i){let s="asc"===i?1:-1;return t>e?1*s:t<e?-1*s:0}(e(i,t.sortBy,t.ignoreCase),e(s,t.sortBy,t.ignoreCase),t.sortOrder))).reduceRight((function(t,e){return e||t}))}},isValidURL(t){if("string"!=typeof t)return!1;try{return new URL(t),!0}catch(t){return!1}},getPropName(t,e){let i=t.split("_"),s=i.first.toLowerCase();e&&(s=s.substring(0,1).toUpperCase()+s.substring(1));for(let t=1;t<i.length;t++)s+=i[t].substring(0,1),s+=i[t].substring(1).toLowerCase();return s},getEnumValueName(t){let e="";for(let i=0;i<t.length;i++)i>0&&t[i]!=t[i].toLowerCase()&&(e+="_"),e+=t[i];return e.toUpperCase()}};class I{constructor(t,e,i={}){this.layout=t,this.pointProps=e,this.sheet={};let s={};Object.defineProperties(s,{size:{get:this.getComputed.bind(this,"size"),set:this.setStyle.bind(this,"size"),enumerable:!0},red:{get:this.getComputed.bind(this,"red"),set:this.setStyle.bind(this,"red"),enumerable:!0},green:{get:this.getComputed.bind(this,"green"),set:this.setStyle.bind(this,"green"),enumerable:!0},blue:{get:this.getComputed.bind(this,"blue"),set:this.setStyle.bind(this,"blue"),enumerable:!0},alpha:{get:this.getComputed.bind(this,"alpha"),set:this.setStyle.bind(this,"alpha"),enumerable:!0},rotation:{get:this.getComputed.bind(this,"rotation"),set:this.setStyle.bind(this,"rotation"),enumerable:!0},scaleX:{get:this.getComputed.bind(this,"scaleX"),set:this.setStyle.bind(this,"scaleX"),enumerable:!0},scaleY:{get:this.getComputed.bind(this,"scaleY"),set:this.setStyle.bind(this,"scaleY"),enumerable:!0},scaleZ:{get:this.getComputed.bind(this,"scaleZ"),set:this.setStyle.bind(this,"scaleZ"),enumerable:!0},offsetX:{get:this.getComputed.bind(this,"offsetX"),set:this.setStyle.bind(this,"offsetX"),enumerable:!0},offsetY:{get:this.getComputed.bind(this,"offsetY"),set:this.setStyle.bind(this,"offsetY"),enumerable:!0},offsetZ:{get:this.getComputed.bind(this,"offsetZ"),set:this.setStyle.bind(this,"offsetZ"),enumerable:!0},color:{get:this.getComputed.bind(this,"color"),set:this.setStyle.bind(this,"color"),enumerable:!0},blendMode:{get:this.getComputed.bind(this,"blendMode"),set:this.setStyle.bind(this,"blendMode"),enumerable:!0},visibility:{get:this.getComputed.bind(this,"visibility"),set:this.setStyle.bind(this,"visibility"),enumerable:!0},reset:{value:t=>{t&&(i=t),this.clear(),Object.keys(i).forEach((t=>this.setStyle(t,i[t])))}},clear:{value:this.clear.bind(this)}}),this.style=Object.freeze(s),this.style.reset(i)}setStyle(t,e){if(null==e&&(e=void 0),I.validate(this.layout,t,e),"color"==t&&e)return this.sheet.red=e.red,this.sheet.green=e.green,this.sheet.blue=e.blue,void(this.sheet.alpha=e.alpha);null==e?delete this.sheet[t]:this.sheet[t]=e}getStyle(t){let e=this.sheet[t];return"visibility"==t?"boolean"!=typeof e&&(e=!0):"color"==t&&S.isColor(this.sheet)&&(e=S.fromColor(this.sheet)),e}getComputed(t){let e=this.getStyle(t);if(null==e)if("color"==t){let t={red:isFinite(this.sheet.red)?this.sheet.red:this.pointProps.red,green:isFinite(this.sheet.green)?this.sheet.green:this.pointProps.green,blue:isFinite(this.sheet.blue)?this.sheet.blue:this.pointProps.blue,alpha:isFinite(this.sheet.alpha)?this.sheet.alpha:this.pointProps.alpha};S.isColor(t)&&(e=S.fromColor(t))}else e=this.pointProps[t];return e}clear(){this.sheet={}}static validate(t,e,i,s){let r;if(i&&t.includes(b.Property[w.getEnumValueName(e)])){if(!s)throw new Error(`Property ${e} value ${i} is not applicable. This is a dynamic property and is part of the layout.`);console.warn(`Property ${e} value ${i} is not applicable. This is a dynamic property and is part of the layout.`),i=void 0}if("color"==e)!i||i instanceof S||(r=`Property ${e} is not an instance of Color`);else if("blendMode"==e)""==i&&(i=void 0);else if("number"==typeof i)if("size"==e)i<0?r=`Property ${e} with value ${i} is not allowed. Value should be a positive number.`:0==i&&(i=void 0);else if("red"==e||"green"==e||"blue"==e||"alpha"==e){let t="alpha"==e?{min:0,max:1}:{min:0,max:255};i>=t.min&&i<=t.max||(r=`Property ${e} with value ${i} is out of range. Allowd range: [${t.min}, ${t.max}].`)}else"rotation"==e?0==i&&(i=void 0):"scattering"==e&&i<0&&(i=void 0);if(r)throw new Error(r);return i}}class v{static encode(t,e=v.Encoding.AUTO){let i;if(e==v.Encoding.AUTO?e="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer?v.Encoding.NONE:v.Encoding.ARRAY:v.Encoding.BUFFER:e==v.Encoding.ARRAY&&t instanceof Array&&(e=v.Encoding.NONE),e==v.Encoding.NONE)i=t;else if(e==v.Encoding.ARRAY)i=t.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let s=Buffer.from(t.buffer);switch(e){case v.Encoding.BUFFER:i=s.toJSON();break;case v.Encoding.BASE64:i=s.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${e.name}`)}}return{encoding:e.name,type:t.constructor.name,content:i}}static decode(t){let e,i=v.Encoding[t.encoding];if(i==v.Encoding.NONE)e=t.content;else if(i==v.Encoding.ARRAY)e=t.content.toFloat32Array();else{let s;switch(i){case v.Encoding.BUFFER:s="undefined"==typeof Buffer?t.content.data:Buffer.from(t.content);break;case v.Encoding.BASE64:s="undefined"==typeof Buffer?atob(t.content).toCharArray():Buffer.from(t.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${i.name}`)}let r=new Uint8Array(s);e=new globalThis[t.type](r.buffer)}return e}static isTypedArrayData(t){return t&&t.encoding&&t.type&&t.type.endsWith("Array")}}Object.defineEnum(v,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);const O=[b.Property.X,b.Property.Y];class x{#t;#e;constructor(t,e={},i=O){if(this.#t=t,Object.defineProperty(this,"points",{get:()=>this.#t,set:t=>{if(this.#t instanceof Float32Array)throw new Error("Points setter is not accessible wehn points type is Float32Array.");this.#t=t,this.validate()},enumerable:!0}),Object.defineProperty(this,"buffer",{get:()=>this.#t.buffer,set:t=>{if(Array.isArray(this.#t))throw new Error("Underlying points buffer is Array. This property is applicable for TypedArray only.");if("undefined"!=typeof SharedArrayBuffer&&this.#t.buffer instanceof SharedArrayBuffer)throw new Error("Underlying buffer is SharedArrayBuffer and cannot be restored");if(this.#t.buffer.byteLength>0)throw new Error("Cannot restore buffer when underlying buffer is not empty");if(t.byteLength/Float32Array.BYTES_PER_ELEMENT/this.stride!=this.length)throw new Error("Value exceeds expected memory length");this.#t=new Float32Array(t)}}),!Object.isSealed(e))for(let t in e)void 0!==e[t]&&(e[t]=I.validate(i,t,e[t],!0));i.includes(b.Property.ROTATION)||"rotation"in e||(e.rotation=void 0),i.includes(b.Property.SIZE)||e.size||(e.size=1),Object.defineProperties(this,{stride:{value:i.length,enumerable:!0},layout:{value:Object.freeze(i),enumerable:!0},pointProps:{value:Object.seal(e),enumerable:!0}}),t instanceof Float32Array?Object.defineProperty(this,"length",{value:this.#t.length/this.stride,enumerable:!0}):Object.defineProperty(this,"length",{get:()=>this.#t.length/this.stride,enumerable:!0}),i.forEach(((t,e)=>{let i=w.getPropName(t.name,!0);Object.defineProperty(this,`setPoint${i}`,{value:this.setPointPropertyValue.bind(this,e)}),Object.defineProperty(this,`getPoint${i}`,{value:this.getPointPropertyValue.bind(this,e)})}))}validate(){if(this.points.length%this.stride!=0)throw new Error("Path length doesn't match the stride provided via the layout")}setPointPropertyValue(t,e,i){if(isNaN(e))throw new Error("Point index is required");if(e>=this.length||e<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);if(isNaN(i))throw new Error("value is required");this.points[e*this.layout.length+t]=i}getPointPropertyValue(t,e){if(isNaN(e))throw new Error("Point index is required");if(e>=this.length||e<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);return this.points[e*this.layout.length+t]}setPoint(t,e){let i=t*this.stride;this.layout.forEach(((t,s)=>this.points[i+s]=e.getProperty(t)))}getPoint(t,e=this.pointProps){if(t>=this.length||t<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);return b.createInstance(this.layout,e,this.points,t)}getPointRef(t,e=this.pointProps){if(t>=this.length||t<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);return this.#e||(this.#e=b.createInstance(this.layout)),this.#e.fill(t,this.points,this.layout,this.pointProps),this.#e}getChannelData(t){let e=new([b.Property.RED,b.Property.GREEN,b.Property.BLUE].includes(t)?Uint8Array:Float32Array)(this.length),i=this.layout.indexOf(t);if(-1==i)throw new Error(`Property ${t.name} is not part from the spline layout ${this.layout.map((t=>t.name)).join(", ")}`);for(let t=0;t<this.length;t++)e[t]=this.points[t*this.stride+i];return e}transform(t){let e=t.scaleX,s=t.rotation;for(let r=0;r<this.length;r++){let n=r*this.stride,a=i.fromValues(this.getPointX(r),this.getPointY(r),0,1);i.transformMat4(a,a,t.value);for(let t=0;t<this.stride;t++){let i=n+t;switch(this.layout[t]){case b.Property.X:this.points[i]=a[0]/a[3];break;case b.Property.Y:this.points[i]=a[1]/a[3];break;case b.Property.Z:this.points[i]=a[2]/a[3];break;case b.Property.ROTATION:this.points[i]+=s;break;case b.Property.SIZE:this.points[i]*=e}}}this.layout.includes(b.Property.ROTATION)||(this.pointProps.rotation=0==s?void 0:s)}clone(){return new x(this.#t.clone(),Object.clone(this.pointProps),this.layout.slice())}getFragment(t=0,e=this.length-1){return new E(this,t,e)}slice(t){let e=this.slicePoints(t.pointIndexStart,t.pointIndexEnd);return new x(e,Object.clone(this.pointProps),this.layout.slice())}validateFragment(t,e){if(t<0)throw new Error(`Invalid fragment pointIndexStart ${t} found. The value must be non-negative.`);if(e>this.length-1)throw new Error(`Invalid fragment pointIndexEnd ${e} found. Last point in path index is ${this.length-1}.`)}slicePoints(t,e){let i;if(this.validateFragment(t,e),"undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let s=this.points.subarray(t*this.stride,(e+1)*this.stride),r=new SharedArrayBuffer(s.length*Float32Array.BYTES_PER_ELEMENT);i=new Float32Array(r),i.set(s)}else i=this.points.slice(t*this.stride,(e+1)*this.stride);return i}toSVGPath(){let t=[];for(let e=0;e<this.length;e++)t.push(`${this.getPointX(e)},${this.getPointY(e)}`);return`M ${t.join(" L ")} Z`}toJSON(){return{type:"Path",points:v.encode(this.#t,this.encoding),pointProps:this.pointProps,layout:this.layout.map((t=>t.name))}}static fromJSON(t){if("Path"!=t.type)throw new Error(`Path deserialization failed. JSON type is ${t.type}, expected Path.`);return new x(v.decode(t.points),t.pointProps,t.layout.map((t=>b.Property[t])))}static fromRect(t,e){let i=[t.left,t.top,t.right,t.top,t.right,t.bottom,t.left,t.bottom,t.left,t.top];return new x(i,e)}static createInstance(t,e,i){return new x(t,e,i)}static createSharedInstance(t,e,i){return new x(Float32Array.createSharedInstance(t),e,i)}}class A{constructor(t,e){t>0&&0==e?(this.segmentIndex=t-1,this.t=1):(this.segmentIndex=t,this.t=e),Object.defineProperty(this,"index",{get:()=>(console.warn("SplineParameter index => segmentIndex"),this.segmentIndex)})}equals(t){return this.segmentIndex==t.segmentIndex&&this.t==t.t}toString(){return`spline-parameter(${this.segmentIndex}, ${this.t})`}toJSON(){return{segmentIndex:this.segmentIndex,t:this.t}}static fromJSON(t){return new A(t.segmentIndex,t.t)}static calcMiddleOfSegment(t,e){let i=.5*(t.t+e.t+(e.segmentIndex-t.segmentIndex)),s=Math.trunc(i),r=i-s;return new A(t.segmentIndex+s,r)}static areDistantEnough(t,e,i=.01){return e.t+(e.segmentIndex-t.segmentIndex)-t.t>i}}let R=o?o.default||globalThis.md5:{},T={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let t=Date.now();return this.mask.replace(/[xy]/g,(function(e){let i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:3&i|8).toString(16)}))},validate:t=>"string"==typeof t&&!!t.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(t){let e=[],i=0;return this.mask.split("-").forEach((s=>{e.push(t.substring(i,i+s.length)),i+=s.length})),e.join("-")},fromString(t){return this.fromBytes(new Uint8Array(R.arrayBuffer(t)))},toBytes(t){let e=[];return t.split("-").map(((t,i)=>{(i<3?t.match(/.{1,2}/g).reverse():t.match(/.{1,2}/g)).map((t=>e.push(parseInt(t,16))))})),new Uint8Array(e)},fromBytes(t){let e=Array.from(t).map((t=>t.toString(16))).map((t=>(1==t.length?"0":"")+t));return e.slice(0,4).reverse().join("")+"-"+e.slice(4,6).reverse().join("")+"-"+e.slice(6,8).reverse().join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10).join("")},toUint32Array(t){let e=new Uint32Array(4),i=this.toBytes(t);return e[0]=new Uint32Array(i.slice(0,4).buffer)[0],e[1]=new Uint32Array(i.slice(4,8).buffer)[0],e[2]=new Uint32Array(i.slice(8,12).buffer)[0],e[3]=new Uint32Array(i.slice(12).buffer)[0],e},fromUint32Array(t){return this.fromBytes(new Uint8Array(t.buffer))},toUint64Array(t){let e=new BigUint64Array(2),i=this.toBytes(t);return e[0]=new BigUint64Array(i.slice(0,8).buffer)[0],e[1]=new BigUint64Array(i.slice(8).buffer)[0],e},fromUint64Array(t){return this.fromBytes(new Uint8Array(t.buffer))},toLongArray(t){let e=new Array(2),i=this.toBytes(t);return e[0]=a.fromBytes(i.slice(0,8)),e[1]=a.fromBytes(i.slice(8)),e},fromLongArray(t){let e=t[0].toBytes().concat(t[1].toBytes());return this.fromBytes(e)}};class N{#i;constructor(t,e,i,s,r){1==i&&(e++,i=0),0==r&&(s--,r=1),Object.defineProperties(this,{spline:{value:t,enumerable:!0},segmentIndexStart:{value:e,enumerable:!0},segmentIndexEnd:{value:s,enumerable:!0},ts:{value:i,enumerable:!0},tf:{value:r,enumerable:!0}}),Object.defineProperty(this,"pointIndexStart",{value:e,enumerable:!0}),Object.defineProperty(this,"pointIndexEnd",{value:s+3,enumerable:!0}),Object.defineProperty(this,"length",{value:this.pointIndexEnd-this.pointIndexStart+1,enumerable:!0}),Object.defineProperty(this,"id",{get:()=>(this.#i||(this.#i=T.generate()),this.#i),set:t=>{if(this.#i)throw new Error("id is immutable");this.#i=t}}),this.validate()}validate(){let t=this.length-3;if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.spline.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in spline index is ${this.spline.length-1}.`);if(this.ts<0||this.ts>=1)throw new Error(`Invalid fragment ts ${this.ts} found. The value must be in the interval [0, 1).`);if(this.tf<=0||this.tf>1)throw new Error(`Invalid fragment tf ${this.tf} found. The value must be in the interval (0, 1].`);if(t<1)throw new Error(`Invalid fragment points range {${this.pointIndexStart}, ${this.pointIndexEnd}} found. At least 4 points are needed to define spline.`);if(1==t&&this.ts>this.tf)throw new Error(`Invalid fragment T range ${this.ts} - ${this.tf} found. Spline has only one segment and ts <= tf.`)}union(t){let e=[this,t];e.sort(N.compare);let i=e.first,s=e.last,r=i.segmentIndexEnd,n=i.tf;if(1==n&&(r++,n=0),r!=s.segmentIndexStart||n!=s.ts)throw new Error(`Fragments ${i} and ${s} are not adjacent.`);let a=new N(this.spline,i.segmentIndexStart,i.ts,s.segmentIndexEnd,s.tf);return a.#i=this.#i,this.inside&&(a.inside=this.inside),a}overlaps(t){if(t.spline!=this.spline)return!1;let e=t.segmentIndexStart<this.segmentIndexEnd||t.segmentIndexStart==this.segmentIndexEnd&&t.ts<=this.tf,i=t.segmentIndexEnd>this.segmentIndexStart||t.segmentIndexEnd==this.segmentIndexStart&&t.tf>=this.ts;return e&&i}toString(){return`fragment(${this.segmentIndexStart}, ${this.ts} - ${this.segmentIndexEnd}, ${this.tf})`}static compare(t,e){return t.segmentIndexStart<e.segmentIndexStart?-1:t.segmentIndexStart>e.segmentIndexStart?1:t.ts<e.ts?-1:t.ts>e.ts?1:0}static getInstance(t,e,i){return new N(t,e.segmentIndex,e.t,i.segmentIndex,i.t)}}class C{constructor(t,e,i,s){let r=t,n=e,a=t+i,o=e+s;Object.defineProperties(this,{left:{value:r,enumerable:!0},x:{value:t,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:e,enumerable:!0},right:{value:a,enumerable:!0},top:{value:o,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0}})}union(t){if(t&&!(t instanceof C))throw new TypeError("rect must be instance of RectGL");return t?C.ofEdges(Math.min(this.left,t.left),Math.min(this.bottom,t.bottom),Math.max(this.right,t.right),Math.max(this.top,t.top)):this}intersect(t){if(t&&!(t instanceof C))throw new TypeError("rect must be instance of RectGL");if(!t)return null;let e=C.ofEdges(Math.max(this.left,t.left),Math.max(this.bottom,t.bottom),Math.min(this.right,t.right),Math.min(this.top,t.top));return e.width>0&&e.height>0?e:null}ceil(){return C.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return C.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(t){if(!t)return this;let e=u.fromPoint({x:this.left,y:this.bottom}).transform(t),i=u.fromPoint({x:this.right,y:this.bottom}).transform(t),s=u.fromPoint({x:this.left,y:this.top}).transform(t),r=u.fromPoint({x:this.right,y:this.top}).transform(t),n=Math.min(s.x,r.x,e.x,i.x),a=Math.min(s.y,r.y,e.y,i.y),o=Math.max(s.x,r.x,e.x,i.x),h=Math.max(s.y,r.y,e.y,i.y);return C.ofEdges(n,a,o,h)}toQuad(t){let e;if(t){let i=u.fromPoint({x:this.left,y:this.bottom}).transform(t),s=u.fromPoint({x:this.right,y:this.bottom}).transform(t),n=u.fromPoint({x:this.left,y:this.top}).transform(t),a=u.fromPoint({x:this.right,y:this.top}).transform(t);e=r.fromValues(i.x,i.y,s.x,s.y,n.x,n.y,a.x,a.y)}else e=r.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return e}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,i,s){return new C(t,e,i-t,s-e)}static calculateBrushGLSegmentBounds(t,e=0,i){let s,r=.5*t.size,n=Math.abs(e*r);if(i){s=new u(t.x,t.y,t.x,t.z).transform(i)}else s=t;let a=s.x,o=s.y,h=t.scaleX*r,l=t.scaleY*r,c=t.offsetX,p=-t.offsetY,d=Math.cos(t.rotation),f=Math.sin(t.rotation),m=Number.MAX_SAFE_INTEGER,g=Number.MIN_SAFE_INTEGER,y=Number.MAX_SAFE_INTEGER,P=Number.MIN_SAFE_INTEGER;for(let t of C.SQURE){let e=t.x*h+c,i=t.y*l+p,s=d*e+f*i+a,r=-f*e+d*i+o,u=s-n;m=Math.min(m,u),g=Math.max(g,u),u=s+n,m=Math.min(m,u),g=Math.max(g,u);let b=r-n;y=Math.min(y,b),P=Math.max(P,b),b=r+n,y=Math.min(y,b),P=Math.max(P,b)}return C.ofEdges(m,y,g,P)}}Object.defineProperty(C,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class D{constructor(t,e,i,s){let r,n,a,o=t,h=e,l=t+i,u=e+s;Object.defineProperties(this,{left:{value:o,enumerable:!0},top:{value:h,enumerable:!0},right:{value:l,enumerable:!0},bottom:{value:u,enumerable:!0},x:{value:t,enumerable:!0},y:{value:e,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0},size:{get:()=>(r||(r={width:i,height:s}),r),enumerable:!0},area:{get:()=>(n||(n=i*s),n),enumerable:!0},center:{get:()=>(a||(a={x:(o+l)/2,y:(h+u)/2}),a),enumerable:!0}})}union(t){return t?D.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return null;let e=D.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:null}intersects(t){return this.left<=t.right&&this.right>=t.left&&this.top<=t.bottom&&this.bottom>=t.top}ceil(t){let e=Math.floor(this.left),i=Math.floor(this.top),s=Math.ceil(this.right),r=Math.ceil(this.bottom);if(t){let t=s-e,n=r-i;t+=t%2,n+=n%2,s=e+t,r=i+n}return D.ofEdges(e,i,s,r)}floor(t){let e=Math.ceil(this.left),i=Math.ceil(this.top),s=Math.floor(this.right),r=Math.floor(this.bottom);if(t){let t=s-e,n=r-i;t-=t%2,n-=n%2,s=e+t,r=i+n}return D.ofEdges(e,i,s,r)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}includes(t){return this.left<=t.left&&this.right>=t.right&&this.top<=t.top&&this.bottom>=t.bottom}transform(t){if(!t)return this;let e=u.fromPoint({x:this.left,y:this.top}).transform(t),i=u.fromPoint({x:this.right,y:this.top}).transform(t),s=u.fromPoint({x:this.left,y:this.bottom}).transform(t),r=u.fromPoint({x:this.right,y:this.bottom}).transform(t),n=Math.min(e.x,i.x,s.x,r.x),a=Math.min(e.y,i.y,s.y,r.y),o=Math.max(e.x,i.x,s.x,r.x),h=Math.max(e.y,i.y,s.y,r.y);return D.ofEdges(n,a,o,h)}toPath(t,e=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new C(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(t){if(!t)return null;if(!(t instanceof C))throw new TypeError("rect must be instance of RectGL");return new D(t.left,t.bottom,t.width,t.height)}static isRect(t){return t&&isFinite(t.left)&&isFinite(t.top)&&isFinite(t.width)&&isFinite(t.height)}static fromString(t){return t=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g),new D(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]))}static fromRect(t){return"string"==typeof t?D.fromString(t):new D(t.x,t.y,t.width,t.height)}static ofPolygon(t){if(t.shape&&(t=t.shape),0==t.length)return null;let e=Number.MAX_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let n=0;n<t.length;n++){let a=t.getPointX(n),o=t.getPointY(n);e=Math.min(e,a),i=Math.min(i,o),s=Math.max(s,a),r=Math.max(r,o)}return D.ofEdges(e,i,s,r)}static ofSpline(t,e=0){let i;for(let s=0;s<t.length;s++)i=C.calculateBrushGLSegmentBounds(t.getPointRef(s),e).union(i);return D.fromGLRect(i)}static ofEdges(t,e,i,s){let r=Math.min(t,i),n=Math.min(e,s),a=Math.max(t,i),o=Math.max(e,s);return new D(r,n,a-r,o-n)}static union(t,e){return t?e?t.union(e):t:e}static intersect(t,e){return t&&e?t.intersect(e):null}}class M extends x{constructor(t,e,i,s=0,r=1){super(e,i,t),this.points instanceof Float32Array?Object.defineProperty(this,"segmentsCount",{value:this.length-3,configurable:!0}):Object.defineProperty(this,"segmentsCount",{get:()=>this.length-3,configurable:!0}),this.ts=s,this.tf=r,Object.defineProperty(this,"bounds",{get:()=>D.ofSpline(this,this.pointProps.scattering).ceil(),enumerable:!0}),Object.defineProperty(this,"color",{get:()=>S.isColor(this.pointProps)?S.fromColor(this.pointProps):void 0,set:t=>{if(!t)throw new Error("Spline color cannot be removed");if(!(t instanceof S))throw new Error("Expected value should be Color instance");"red"in this.pointProps&&(this.pointProps.red=t.red),"green"in this.pointProps&&(this.pointProps.green=t.green),"blue"in this.pointProps&&(this.pointProps.blue=t.blue),"alpha"in this.pointProps&&(this.pointProps.alpha=t.alpha)},enumerable:!0}),this.validate()}validate(){let t=this.points instanceof Float32Array;if(super.validate(),!this.layout.includes(b.Property.X))throw new Error("Layout doesn't contains required properties X");if(!this.layout.includes(b.Property.Y))throw new Error("Layout doesn't contains required properties Y");if(t&&0==this.points.length)throw new Error("Empty spline is not allowed");if(this.ts<0||this.ts>=1)throw new Error(`Invalid spline ts ${this.ts} found. The value must be in the interval [0, 1).`);if(this.tf<=0||this.tf>1)throw new Error(`Invalid spline tf ${this.tf} found. The value must be in the interval (0, 1].`);if(1==this.segmentsCount&&this.ts>this.tf)throw new Error(`Invalid spline t range ${this.ts} - ${this.tf} found. Spline has only one segment and ts <= tf.`);if(t&&this.segmentsCount<1)throw new Error("Incompleted spline found. Spline is defined with at least 4 control points.")}clone(){return new M(this.layout.slice(),this.points.clone(),Object.clone(this.pointProps),this.ts,this.tf)}slice(t){let e=this.slicePoints(t.pointIndexStart,t.pointIndexEnd),i=new M(this.layout.slice(),e,Object.clone(this.pointProps),t.ts,t.tf);return i.id=t.id,i}getSegment(t){let e=t,i=t+3,s=0==e?this.ts:0,r=i+1==this.length?this.tf:1;return this.slice({pointIndexStart:e,pointIndexEnd:i,ts:s,tf:r})}getFragment(t=0,e=this.ts,i=this.segmentsCount-1,s=this.tf,r=!1){return new N(this,t,e,r?i-3:i,s)}toPlainPath(){let t=new x([]);for(let e=0;e<this.length;e++)t.points.push(this.getPointX(),this.getPointY());return t}toJSON(){return{type:"Spline",id:this.id,layout:this.layout.map((t=>t.name)),points:v.encode(this.points,this.encoding),pointProps:this.pointProps,ts:this.ts,tf:this.tf}}static fromJSON(t){let e=v.decode(t.points),i=new M(t.layout.map((t=>b.Property[t])),e,t.pointProps,t.ts,t.tf);return i.id=t.id,i}static fromRect(t,e){let i=[t.left,t.top,t.left,t.top,t.right,t.top,t.right,t.bottom,t.left,t.bottom,t.left,t.top,t.left,t.top];return new M(void 0,i,e)}static createInstance(t,e,i=[],s,r){return new M(t,i,e,s,r)}static createSharedInstance(t,e,i,s,r){return new M(t,Float32Array.createSharedInstance(e),i,s,r)}}class L extends x{constructor(t,e,i,s=[]){super(e,i,t),s.length>0&&!Object.isFrozen(s.first)&&s.forEach((t=>Object.freeze(t))),Object.defineProperty(this,"splineParameters",{value:Object.freeze(s),enumerable:!0});let r=new I(t,i);Object.defineProperty(this,"style",{get:()=>r.style,set:t=>r.style.reset(t),enumerable:!0}),Object.defineProperty(this,"color",{get:()=>this.style.color,set:t=>{if(!t)throw new Error("Spline color cannot be removed");if(!(t instanceof S))throw new Error("Expected value should be Color instance");"red"in this.pointProps&&(this.pointProps.red=t.red),"green"in this.pointProps&&(this.pointProps.green=t.green),"blue"in this.pointProps&&(this.pointProps.blue=t.blue),"alpha"in this.pointProps&&(this.pointProps.alpha=t.alpha)},enumerable:!0}),Object.defineProperty(this,"bounds",{get:()=>D.ofSpline(this,this.pointProps.scattering).ceil(),enumerable:!0}),this.validate()}validate(){let t=this.points instanceof Float32Array;if(super.validate(),!this.layout.includes(b.Property.X))throw new Error("Layout doesn't contains required properties X");if(!this.layout.includes(b.Property.Y))throw new Error("Layout doesn't contains required properties Y");if(t&&0==this.points.length)throw new Error("Empty spline is not allowed")}clone(){return new L(this.layout.slice(),this.points.clone(),Object.clone(this.pointProps),this.splineParameters.slice())}slice(t){let e=this.slicePoints(t.pointIndexStart,t.pointIndexEnd);return new L(this.layout.slice(),e,Object.clone(this.pointProps),this.splineParameters.slice())}getPoint(t){return super.getPoint(t,this.style)}getPointRef(t){return super.getPointRef(t,this.style)}getPointSegmentIndex(t){return this.splineParameters[t]?this.splineParameters[t].index:void 0}getPointT(t){return this.splineParameters[t]?this.splineParameters[t].t:void 0}getPointParameter(t){return this.splineParameters[t]}toJSON(){return{type:"InterpolatedSpline",layout:this.layout.map((t=>t.name)),points:v.encode(this.points,this.encoding),pointProps:this.pointProps,splineParameters:this.splineParameters}}static fromJSON(t){let e=v.decode(t.points);return new L(t.layout.map((t=>b.Property[t])),e,t.pointProps,t.splineParameters.map(A.fromJSON))}static fromRect(t,e){throw new Error("InterpolatedSpline.fromRect is not supported. Try Spline.fromRect and interpolate with particular Spline interpolator.")}static createInstance(t,e,i=[]){return new L(t,i,e)}static createSharedInstance(t,e,i,s){return new L(t,Float32Array.createSharedInstance(e),i,s)}}class _{constructor(){this.phase=_.Phase.END}add(t,e,i){if(!this.move(t))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${t.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,t.name)),this.addImpl(e,i)}addImpl(t,e){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(t){return(this.phase!=_.Phase.END||t==_.Phase.BEGIN)&&((this.phase!=_.Phase.BEGIN||t==_.Phase.UPDATE||t==_.Phase.END)&&((this.phase!=_.Phase.UPDATE||t==_.Phase.UPDATE||t==_.Phase.END)&&(t==_.Phase.BEGIN&&this.reset(),this.phase=t,!0)))}reset(){this.phase=_.Phase.END}}Object.defineEnum(_,"Phase",["BEGIN","UPDATE","END"]);let F=h?h.default||globalThis.poly2tri:{};const{SweepContext:k,Point:j}=F;let $=l?l.default||globalThis.ClipperLib:{};const{Clipper:U,Paths:B,Path:Y,ClipType:X,PolyType:z,PolyFillType:G}=$;class H{constructor(t,e){if(!Array.isArray(t))throw new Error("Unexpected polygons type found");let i=65534/(e.width+1e-16),s=65534/(e.height+1e-16),r=Math.floor(Math.min(i,s));if(0==r)throw new Error(`Insufficent clipper range - (-32767 - 32767), scale failed - scaleX: ${i}, scaleY: ${s}`);let n=e.left+32767/r,a=e.top+32767/r;this.solution=new B,this.bounds=e,this.transform={scale:r,offsetX:n,offsetY:a},this.subject=this.apply(t)}convertPoint(t){let e=(t.x-this.transform.offsetX)*this.transform.scale,i=(t.y-this.transform.offsetY)*this.transform.scale;return{X:e<0?Math.ceil(e):Math.floor(e),Y:i<0?Math.ceil(i):Math.floor(i)}}containsPoint(t){return U.PointInPolygon(this.convertPoint(t),this.solution)}apply(t){let e=new B;for(let i of t){let t=new Y,s=i.shape;for(let e=0;e<s.length;e++)t.push(this.convertPoint({x:s.getPointX(e),y:s.getPointY(e)}));e.push(t)}return e}toPaths(){let t=[];this.lastPoint={};for(let e of this.solution){if(0==e.length)continue;let i=this.flatPath(e);i.length>0&&t.push(i)}return t}flatPath(t){let e=[];for(let i of t)this.lastPoint.X==i.X&&this.lastPoint.Y==i.Y||(e.push(i.X/this.transform.scale+this.transform.offsetX,i.Y/this.transform.scale+this.transform.offsetY),this.lastPoint=i);return e.length<6&&(console.warn(`Invalid contour found: [${e.join(", ")}]`),e.clear()),e}}class J{constructor(t=2){this.stride=t}sort(t,e){return this.sortArrayPart(t,0,t.length-this.stride,e),t}partition(t,e,i,s){let r=t[i],n=t[i+1],a=e-this.stride;for(let o=e;o<i;o+=2)s?s(r,n,t[o],t[o+1])&&(a+=this.stride,this.swap(t,a,o)):(r>t[o]||r==t[o]&&n>t[o+1])&&(a+=this.stride,this.swap(t,a,o));return this.swap(t,a+this.stride,i),a+this.stride}swap(t,e,i){let s=t[e],r=t[e+1];return t[e]=t[i],t[e+1]=t[i+1],t[i]=s,t[i+1]=r,t}sortArrayPart(t,e,i,s){if(e<i){let r=this.partition(t,e,i,s);this.sortArrayPart(t,e,r-this.stride,s),this.sortArrayPart(t,r+this.stride,i,s)}}}function V(t,e,i,s,r,n){return(i-t)*(n-e)-(s-e)*(r-t)}function Z(t,e,i,s,r,n){let a=t-i,o=r-i,h=a*(n-s)-o*(e-s);h*=h,a=r-i,o=n-s;let l=a*a+o*o;return l>0?Math.sqrt(h/l):Math.sqrt((i-t)*(i-t)+(s-e)*(s-e))}class q{constructor(t=Float32Array){this.ArrayType=t,this.quickSort=new J}monotoneChain(t){if(t.length<=0)return new this.ArrayType;this.quickSort.sort(t);let e=new this.ArrayType(t.length),i=0;for(let s=0;s<t.length;s+=2){for(;i>=4&&V(e[i-4],e[i-3],e[i-2],e[i-1],t[s],t[s+1])<=0;)i-=2;e[i]=t[s],e[i+1]=t[s+1],i+=2}e=e.slice(0,i);let s,r=new this.ArrayType(t.length);i=0;for(let e=t.length-2;e>=0;e-=2){for(;i>=4&&V(r[i-4],r[i-3],r[i-2],r[i-1],t[e],t[e+1])<=0;)i-=2;r[i]=t[e],r[i+1]=t[e+1],i+=2}if(r=r.slice(0,i-2),this.ArrayType==Float32Array){let t=r.length+e.length;s=Float32Array.createSharedInstance(t),s.set(r),s.set(e,r.length)}else s=r.concat(e);return s}}class W{constructor(t,e=[]){if(!(t instanceof x))throw new Error("Expected shape type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");if(e.some((t=>!(t instanceof x))))throw new Error("Expected hole type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");let i;this.holesDirection=W.PointsDirection.CLOCKWISE,Object.defineProperty(this,"shape",{value:t,enumerable:!0}),Object.defineProperty(this,"holes",{value:e,enumerable:!0}),Object.defineProperty(this,"contours",{value:[t,...e],enumerable:!0}),Object.defineProperty(this,"ArrayType",{value:t.points instanceof Float32Array?Float32Array:Array}),Object.defineProperty(this,"bounds",{get:()=>D.ofPolygon(this),enumerable:!0}),Object.defineProperty(this,"vertices",{get:()=>(i||(i=this.triangulate()),i),set:t=>i=t,enumerable:!0}),Object.defineProperty(this,"verticesValue",{get:()=>i})}clone(t=!1){let e=this.shape.clone(t),i=this.holes.map((e=>e.clone(t))),s=new W(e,i);return this.verticesValue&&(s.vertices=this.vertices.slice()),s}fit(t){let e=this.bounds,i=t.width/e.width,s=t.height/e.height,r=i>0&&s>0?Math.min(i,s):Math.max(i,s);for(let t of this.contours)for(let e=0;e<t.length;e++)t.setPointX(e,t.getPointX(e)*r),t.setPointY(e,t.getPointY(e)*r)}center(){let t=this.bounds;for(let e of this.contours)for(let i=0;i<e.length;i++)e.setPointX(i,e.getPointX(i)-t.center.x),e.setPointY(i,e.getPointY(i)-t.center.y)}transform(t){this.contours.forEach((e=>e.transform(t)))}intersects(t){if(!(t instanceof W))throw new Error("Expected 'poly' type is Polygon");(this.holes.length>0||t.holes.length)&&console.warn("Polygon intersection is for contours only. Holes are ignored.");let e=this.shape,i=t.shape;for(let t=0;t<2;t++){let s=0==t?e:i;for(let t=0;t<s.length;t++){let r=t+1==s.length?0:t+1,n=s.getPointX(t),a=s.getPointY(t),o=s.getPointX(r),h=s.getPointY(r)-a,l=n-o,u=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(let t=0;t<e.length;t++){let i=h*e.getPointX(t)+l*e.getPointY(t);i<u&&(u=i),i>c&&(c=i)}let p=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY;for(let t=0;t<i.length;t++){let e=h*i.getPointX(t)+l*i.getPointY(t);e<p&&(p=e),e>d&&(d=e)}if(c<p||d<u)return!1}}return!0}containsPoint(t){let e=!1,i=this.shape;this.holes.length>0&&console.warn("Polygon intersection is for contours only. Holes are ignored.");for(let s=0,r=i.length-1;s<i.length;r=s++)i.getPointY(s)>t.y!=i.getPointY(r)>t.y&&t.x<(i.getPointX(r)-i.getPointX(s))*(t.y-i.getPointY(s))/(i.getPointY(r)-i.getPointY(s))+i.getPointX(s)&&(e=!e);return e}triangulate(){let t,e=[];for(let t of this.contours){let i=[];for(let e=0;e<t.length;e++){let s=new j(t.getPointX(e),t.getPointY(e));if(e>0){if(i.last.x==s.x&&i.last.y==s.y)continue;if(e==t.length-1&&i.first.x==s.x&&i.first.y==s.y)continue}i.push(s)}e.push(i)}try{t=new k(e.shift())}catch(t){return console.error(t),new Float32Array}for(let i of e)try{t.addHole(i)}catch(t){return console.error(t),new Float32Array}try{t.triangulate()}catch(t){return console.warn(t),new Float32Array}let i=t.getTriangles(),s=Float32Array.createSharedInstance(6*i.length),r=0;for(let t of i){let e=t.getPoints();for(let t of e)s[r++]=t.x,s[r++]=t.y}return s}convex(){return this.buildConvex(this.shape.points)}union(t){let e=Array.of(...this.shape.points,...t.shape.points);return this.buildConvex(e)}buildConvex(t){this.convexHullProducer||(this.convexHullProducer=new q(this.ArrayType));let e=this.convexHullProducer.monotoneChain(t);return this.ArrayType==Float32Array?W.createSharedInstance(e):W.createInstance(e)}simplify(t=.1){let e=new H([this],this.bounds);return e.subject=U.SimplifyPolygons(e.subject,G.pftNonZero),e.solution=U.CleanPolygons(e.subject,t*e.transform.scale),1==e.subject.length&&0==e.solution.first.length&&(e.solution=e.subject),W.toPolygonArray(e.toPaths())}simplifyRamerDouglasPeucker(t=.1){if(t<=0)throw new Error("epsilon expected value > 0");this.epsilon=t;let e=this.simplifyPath(this.shape),i=[];for(let t of this.holes){let e=this.simplifyPath(t);e.length>0&&i.push(e)}return this.ArrayType==Float32Array?W.createSharedInstance(e,i):W.createInstance(e,i)}simplifyPath(t){if(t.length<3)return t.points;let e=Array.of(...t.points,t.getPointX(0),t.getPointY(0)),i=this.simplifyPolyline(e);return i.length<8?e.slice(0,e.length-2):i.slice(0,i.length-2)}simplifyPolyline(t){if(t.length<4)return t;let e=0,i=0;for(let s=2;s<t.length-2;s+=2){let r=Z(t[s],t[s+1],t[0],t[1],t[t.length-2],t[t.length-1]);r>e&&(i=s,e=r)}if(e>this.epsilon){let e=this.simplifyPolyline(t.slice(0,i+2)),s=this.simplifyPolyline(t.slice(i,t.length));return e.concat(s.slice(2,s.length))}return[t[0],t[1],t[t.length-2],t[t.length-1]]}toSVGPath(){return this.contours.map((t=>t.toSVGPath())).join(" ")}toJSON(){return{type:"Polygon",shape:this.shape.toJSON(),holes:this.holes.map((t=>t.toJSON())),holesDirection:this.holesDirection.name,vertices:this.verticesValue}}static fromJSON(t){if("Polygon"!=t.type)throw new Error(`Polygon deserialization failed. JSON type is ${t.type}, expected Polygon.`);let e=x.fromJSON(t.shape),i=t.holes.map((t=>x.fromJSON(t))),s=new W(e,i);return s.holesDirection=W.PointsDirection[t.holesDirection],s.vertices=t.vertices,s}static fromRect(t){return W.createInstance([t.left,t.top,t.right,t.top,t.right,t.bottom,t.left,t.bottom,t.left,t.top])}static createInstance(t,e=[]){return new W(x.createInstance(t),e.map((t=>x.createInstance(t))))}static createSharedInstance(t,e=[]){let i=new W(x.createSharedInstance(t),e.map((t=>x.createSharedInstance(t))));return Object.defineProperty(i,"encoding",{get:()=>i.shape.encoding,set:t=>{i.contours.forEach((e=>e.encoding=t))},enumerable:!0}),i}}Object.defineEnum(W,"PointsDirection",["CLOCKWISE","COUNTERCLOCKWISE"]);class K{static ARRAY_TYPE=Array;#s;constructor(){this.keepAllData=!1,Object.defineProperty(this,"allData",{get:()=>{if(!this.keepAllData)throw new Error("All data is not accumulated. By default keepAllData property is false.");return this.#s||(this.#s=new this.constructor.ARRAY_TYPE),this.getOutput(this.#s,K.OutputType.ALL_DATA)},enumerable:!0})}build(t,e=K.OutputType.PROCESSOR,i=!0){return console.warn("use process instead"),this.process(t,e,i)}process(t,e=K.OutputType.PROCESSOR,i=!0){let s;switch(e){case K.OutputType.ADDITION:s=this.add(t,i);break;case K.OutputType.PREDICTION:s=this.predict(t);break;case K.OutputType.PROCESSOR:this.reset(),s=this.processImpl(t,e);break;default:throw new Error("Unexpected OutputType found. Allowed type is oneof(ADDITION, PREDICTION, PROCESSOR)")}return e!=K.OutputType.PREDICTION&&this.keepAllData&&(this.#s||(this.#s=new this.constructor.ARRAY_TYPE),s instanceof W?this.#s.push(s):e==K.OutputType.PROCESSOR?this.#s=s:this.#s.push(...s)),this.debug&&console.log(this.constructor.name,e.name,i,s),this.getOutput(s,e)}add(t,e=!1){return this.processImpl(t,K.OutputType.ADDITION)}predict(t){return this.processImpl(t,K.OutputType.PREDICTION)}processImpl(t,e){throw new Error("Abstract method processImpl(input, type) of DataSequenceProcessor should be implemented")}getOutput(t,e){return t}reset(){this.#s&&(this.#s=new this.constructor.ARRAY_TYPE)}}Object.defineEnum(K,"OutputType",["ADDITION","PREDICTION","ALL_DATA","PROCESSOR"]);class Q extends _{constructor(t,e){super(),this.layout=t,this.pathPointCalculator=e,this.inputBuffer=[],this.prediction=!0}togglePrediction(t){console.warn("PathProducer togglePrediction method is deprecated. Use InkBuilder instance prediction property to configure prediction behaviour."),this.prediction=t}addImpl(t,e){if(t.phase!=this.phase)throw new Error(`The phase of the addition (${t.phase.name}) doesn't match the phase of the PathProducer (${this.phase.name})`);let i=[],s=[];t&&this.inputBuffer.push(t);let r=this.inputBuffer.length>=3?this.inputBuffer[this.inputBuffer.length-3]:null,n=this.inputBuffer.length>=2?this.inputBuffer[this.inputBuffer.length-2]:null,a=this.inputBuffer.length>=1?this.inputBuffer[this.inputBuffer.length-1]:null,o=this.calculate(r,n,a);return t&&o&&i.push(...o.toArray(this.layout)),this.phase==_.Phase.END?(o=this.calculate(n,a,null),o&&i.push(...o.toArray(this.layout))):this.prediction&&(this.phase==_.Phase.UPDATE||e)&&(o=this.calculate(n,a,e),o&&(s.push(...o.toArray(this.layout)),o=this.calculate(a,e,null),o&&s.push(...o.toArray(this.layout)))),{added:i,predicted:s}}calculate(t,e,i){return e?this.pathPointCalculator(t,e,i):null}reset(){super.reset(),this.inputBuffer.clear()}}const tt=[-6e-6,-139e-6,-185e-6,414e-6,.002357,.003357,-.003135,-.023928,-.042909,-.017858,.096525,.254692,.347072,.26881,.114933];class et extends K{#r=[];#n=0;constructor(t,e=15){super(),this.filter=tt.slice(),Object.defineProperty(this,"movingAverageWindowSize",{get:function(){return e},set:function(t){e=t,this.filter.length!=t&&(this.filter=et.resample(tt,t)),this.predictionPointsCount=4*t/15,this.windowSize=this.filter.length},enumerable:!0}),this.dimsCount=t,this.movingAverageWindowSize=e}add(t,e){return e?this.project(t):this.addSequence(t)}processImpl(t){return this.project(t)}project(t){if(t.length%this.dimsCount!=0)throw new Error(`Points size ('${t.length}') must be multiple of the dimensions count ('${this.dimsCount}').`);if(0==t.length)return[];let e=[],i=this.#r.slice(),s=t.slice(0,t.length-this.dimsCount),r=this.addSequence(s);e.push(...r);let n=t.slice(t.length-this.dimsCount,t.length),a=this.predictionPointsCount;for(let t=0;t<a;t++){let i=this.addPoint(n);a-t<=this.#n&&e.push(...i)}return this.#r=i,e}addSequence(t){if(t.length%this.dimsCount!=0)throw new Error(`Points size ('${t.length}') must be multiple of the dimensions count ('${this.dimsCount}').`);let e=[],i=t.length/this.dimsCount;for(let s=0;s<i;s++){let i=this.addPoint(t.slice(s*this.dimsCount,(s+1)*this.dimsCount));e.push(...i)}return this.#n+=i,e}addPoint(t){for(this.#r.push(...t);this.#r.length<this.windowSize*this.dimsCount;)this.#r.unshift(...this.#r.slice(0,this.dimsCount));for(;this.#r.length>this.windowSize*this.dimsCount;)this.#r=this.#r.slice(this.dimsCount);return this.filterBuffer()}filterBuffer(){let t=[];for(let e=0;e<this.windowSize;e++)for(let i=0;i<this.dimsCount;i++)isNaN(t[i])&&(t[i]=0),t[i]+=this.#r[e*this.dimsCount+i]*this.filter[e];return t}reset(){super.reset(),this.#n=0,this.#r.clear()}static resample(t,e){let i=new Float32Array(e),s=t.length/e,r=0;for(let n=0;n<e;n++){let a=(t.length-1)*n/(e-1),o=Math.floor(a),h=Math.ceil(a),l=a-o,u=s*(t[o]*(1-l)+t[h]*l);r+=u,i[n]=u}let n=1/r;for(let t=0;t<e;t++)i[t]*=n;return i}}class it extends K{#a;#o;constructor(t){super(),this.layout=t,this.pathPointProps={}}add(t,e){this.#a||(this.#a=M.createInstance(this.layout,this.pathPointProps)),0==this.#a.points.length&&t.length>0&&t.unshift(...t.slice(0,this.layout.length)),e&&(t.length>=this.layout.length?t.push(...t.slice(t.length-this.layout.length,t.length)):t.push(...this.getLastPart()));let i=this.getFirstPart();return this.#a.points=i.concat(t),t}predict(t=[]){if(0==t.length)return t;this.#o?this.#o.points.clear():this.#o=M.createInstance(this.layout,this.pathPointProps);let e=this.#o.points,i=this.getFirstPart();for(e.push(...i),e.push(...t),e.push(...e.slice(e.length-this.layout.length,e.length));e.length<4*this.layout.length;)e.unshift(e.slice(0,this.layout.length));return e}processImpl(t){let e=[];return t.length>0&&(e.push(...t.slice(0,this.layout.length)),e.push(...t),t.length>=this.layout.length&&e.push(...t.slice(t.length-this.layout.length,t.length))),t}getOutput(t,e){if(e==it.OutputType.ADDITION){if(this.#a.points.length>=4*this.layout.length)return this.#a}else if(e==it.OutputType.PREDICTION){if(this.#o.points.length>0)return this.#o}else if(t.length>0)return M.createSharedInstance(this.layout,t,this.pathPointProps)}getFirstPart(){return this.#a.points.slice(Math.max(0,this.#a.points.length-3*this.layout.length),this.#a.points.length)}getLastPart(){return this.#a.points.slice(this.#a.points.length-this.layout.length,this.#a.points.length)}reset(){super.reset(),this.#a=null,this.#o=null}}const st=s.fromValues(0,-.5,1,-.5,1,0,-2.5,1.5,0,.5,2,-1.5,0,0,-.5,.5);class rt extends K{#a;#o;#h;constructor(t=!1,e=!1){super(),this.calculateDerivates=t,this.keepSplineParameters=e,this.state={segmentIndex:-1,lastPointPosition:void 0,lastPointSize:0}}initState(t){this.state.layout={},t.layout.forEach(((t,e)=>{this.state.layout[t.name]={index:e,polynomials:i.create()}})),this.keepSplineParameters?this.state.splineParameters?this.state.splineParameters.clear():this.state.splineParameters=[]:delete this.state.splineParameters,this.splineLayout=t.layout,this.pathPointProps=Object.clone(t.pointProps),this.scattering&&(this.pathPointProps.scattering=this.scattering),this.layout=this.calculateDerivates?t.layout.concat([b.Property.D_X,b.Property.D_Y]):t.layout,this.state.ready=!0}predict(t){if(!t)return[];this.state.ready||this.initState(t),this.#o?this.#o.points.clear():this.#o=L.createInstance(this.layout,this.pathPointProps),this.path=this.#o;let e=Object.clone(this.state);return delete this.state.splineParameters,this.resetState(),this.discretize(t),this.state=e,this.path.points}processImpl(t,e){if(!t)return[];let i;return t instanceof N&&(i=t,t=i.spline),this.state.ready||this.initState(t),e==rt.OutputType.ADDITION?(this.#a?this.#a.points.clear():this.#a=L.createInstance(this.layout,this.pathPointProps),this.path=this.#a):(this.#h=L.createInstance(this.layout,this.pathPointProps),this.path=this.#h),this.discretize(t,i),this.path.points}getOutput(t,e){if(0!=t.length){if(e==rt.OutputType.PROCESSOR||e==rt.OutputType.ALL_DATA){let e=this.state.splineParameters;return e&&(e=e.slice()),L.createSharedInstance(this.layout,t,this.pathPointProps,e)}return this.path}}calculateInterpolatedPoint(t,e,s){this.initState(t);let r=new b(0,0,this.splineLayout.includes(b.Property.Z)?0:void 0),n=i.fromValues(1,s,s*s,s*s*s);return this.calculatePolynomials(t,e),this.splineLayout.forEach((t=>{let e=i.dot(this.state.layout[t.name].polynomials,n);r[w.getPropName(t.name)]=e})),r}discretize(t,e){throw new Error("This method is abstract and should be implemented")}storeLastPoint(t,e=0){this.state.lastPointPosition=new u(this.getPropValue(b.Property.X,t,e),this.getPropValue(b.Property.Y,t,e),this.getPropValue(b.Property.Z,t,e)),this.state.lastP...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/dependabot.yml line 8
- Likely real
- Yes, 99% confidence
This Dependabot configuration does not set a cooldown period. Newly published packages can be malicious or unstable. Add a `cooldown` block with `default-days: 7` to each `package-ecosystem` entry under `updates` to wait 7 days before proposing updates to newly published package versions. Reference: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#cooldown
- package-ecosystem: "npm" directory: "/" schedule: interval: "weekly" -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/dependabot.yml line 12
- Likely real
- Yes, 99% confidence
This Dependabot configuration does not set a cooldown period. Newly published packages can be malicious or unstable. Add a `cooldown` block with `default-days: 7` to each `package-ecosystem` entry under `updates` to wait 7 days before proposing updates to newly published package versions. Reference: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#cooldown
- package-ecosystem: "composer" directory: "/" schedule: interval: "weekly" -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/dependabot.yml line 16
- Likely real
- Yes, 99% confidence
This Dependabot configuration does not set a cooldown period. Newly published packages can be malicious or unstable. Add a `cooldown` block with `default-days: 7` to each `package-ecosystem` entry under `updates` to wait 7 days before proposing updates to newly published package versions. Reference: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#cooldown
- package-ecosystem: "docker" directory: "/docker" schedule: interval: "weekly" -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /include/init/configuration.php line 125
- Likely real
- Yes, 98% confidence
Found direct access to a PHP variable wihout HTML escaping inside an inline PHP statement setting data from `$_REQUEST[...]`. When untrusted input can be used to tamper with a web page rendering, it can lead to a Cross-site scripting (XSS) vulnerability. XSS vulnerabilities occur when untrusted input executes malicious JavaScript code, leading to issues such as account compromise and sensitive information leakage. To prevent this vulnerability, validate the user input, perform contextual output encoding or sanitize the input. In PHP you can encode or sanitize user input with `htmlspecialchars` or use automatic context-aware escaping with a template engine such as Latte.
echo json_encode([ 'connected' => true, 'ok' => !$has_only_full_group_by, 'sql_mode' => $sql_mode, ]); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /include/init/configuration.php line 734
- Likely real
- Yes, 98% confidence
Found direct access to a PHP variable wihout HTML escaping inside an inline PHP statement setting data from `$_REQUEST[...]`. When untrusted input can be used to tamper with a web page rendering, it can lead to a Cross-site scripting (XSS) vulnerability. XSS vulnerabilities occur when untrusted input executes malicious JavaScript code, leading to issues such as account compromise and sensitive information leakage. To prevent this vulnerability, validate the user input, perform contextual output encoding or sanitize the input. In PHP you can encode or sanitize user input with `htmlspecialchars` or use automatic context-aware escaping with a template engine such as Latte.
echo ' <div class="col-md-12"> {[ "type": "text", "label": "'.tr('Host del database').'", "name": "db_host", "placeholder": "'.tr('Host').'", "value": "'.$host.'", "help": "'.tr('Esempio').': localhost", "show-help": 0, "required": 1 ]} </div> </div> <div class="row">'; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.yarnrc.yml line 8
- Likely real
- Yes, 96% confidence
This .yarnrc.yml does not set a minimal age gate or sets it too low. Newly published packages can be malicious or unstable. Add `npmMinimalAgeGate: "7d"` to wait 7 days before resolving newly published package versions. Added in: 4.10 Reference: https://yarnpkg.com/configuration/yarnrc#npmMinimalAgeGate
npmMinimalAgeGate: 0 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /src/Security/LaravelRateLimiter.php line 55
- Likely real
- Yes, 55% confidence
File name based on user input risks server-side request forgery.
if (!is_dir($storePath)) { -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /src/AuthOSM.php line 1082
- Likely real
- Yes, 54% confidence
Make sure comparisons involving md5 values are strict (use `===` not `==`) to avoid type juggling issues
if ((empty($_SESSION['last_active']) || time() < $_SESSION['last_active'] + (60 * 60)) && (empty($_SESSION['identifier']) || $_SESSION['identifier'] == $identifier)) { -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /src/AuthOSM.php line 1042
- Likely real
- Yes, 54% confidence
Make sure comparisons involving md5 values are strict (use `===` not `==`) to avoid type juggling issues
if ($hash == md5($password)) { -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /modules/aggiornamenti/edit.php line 244
- Likely real
- Yes, 54% confidence
Make sure comparisons involving md5 values are strict (use `===` not `==`) to avoid type juggling issues
if ($verifica != $md5) { -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /modules/aggiornamenti/checksum.php line 63
- Likely real
- Yes, 54% confidence
Make sure comparisons involving md5 values are strict (use `===` not `==`) to avoid type juggling issues
if ($verifica != $md5) { -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /api/index.php line 51
- Likely real
- Yes, 53% confidence
Access-Control-Allow-Origin response header is set to "*". This will disable CORS Same Origin Policy restrictions.
header('Access-Control-Allow-Origin: *'); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/workflows/codeql.yml line 58
- Likely real
- Yes, 52% confidence
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. `uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608`.
uses: actions/checkout@v4 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/workflows/codeql.yml line 62
- Likely real
- Yes, 52% confidence
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. `uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608`.
uses: github/codeql-action/init@v3 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/workflows/codeql.yml line 90
- Likely real
- Yes, 52% confidence
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. `uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608`.
uses: github/codeql-action/analyze@v3 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/workflows/main.yml line 16
- Likely real
- Yes, 52% confidence
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. `uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608`.
- uses: actions/checkout@v4 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/workflows/main.yml line 19
- Likely real
- Yes, 52% confidence
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. `uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608`.
uses: shivammathur/setup-php@v2 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/workflows/main.yml line 31
- Likely real
- Yes, 52% confidence
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. `uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608`.
uses: actions/setup-python@v5 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/workflows/main.yml line 36
- Likely real
- Yes, 52% confidence
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. `uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608`.
uses: actions/checkout@v2 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/workflows/main.yml line 73
- Likely real
- Yes, 52% confidence
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. `uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608`.
uses: actions/cache@v4 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/workflows/main.yml line 84
- Likely real
- Yes, 52% confidence
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. `uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608`.
uses: actions/setup-node@v4 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /.github/workflows/main.yml line 100
- Likely real
- Yes, 52% confidence
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. `uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608`.
uses: actions/checkout@v4 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.cjs line 1
- Likely real
- Uncertain, 45% confidence
Possibility of prototype polluting function detected. By adding or modifying attributes of an object prototype, it is possible to create attributes that exist on every object, or replace critical attributes with malicious ones. This can be problematic if the software depends on existence or non-existence of certain attributes, or uses pre-defined attributes of object prototype (such as hasOwnProperty, toString or valueOf). Possible mitigations might be: freezing the object prototype, using an object without prototypes (via Object.create(null) ), blocking modifications of attributes that resolve to object prototype, using Map instead of object.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("js-ext");var e=require("js-md5"),t=require("long"),r=require("gl-matrix"),i=require("poly2tri"),s=require("clipper-lib"),n=require("rbush"),o=require("jszip"),a=require("protobufjs");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=h(e),c=l(t),p=h(i),u=h(s),f=l(n),m=h(o),g=h(a);class y{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let b=d?d.default||globalThis.md5:{},E={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(b.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),r=this.toBytes(e);return t[0]=c.default.fromBytes(r.slice(0,8)),t[1]=c.default.fromBytes(r.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class P{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=P.Algorithm.MD5;else if("function"==typeof this.buildURI)t=P.Algorithm.URI;else if(t=P.Algorithm.GUID,e&&!E.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=P.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==P.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return b(e)}return this.algorithm==P.Algorithm.URI?this.buildURI():E.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(P,"Algorithm",["GUID","MD5","URI"]);class I extends P{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,P.buildMD5Tokens(this.props)]}}Object.defineEnum(I,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class S{constructor(){this.phase=S.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=S.Phase.END||e==S.Phase.BEGIN)&&((this.phase!=S.Phase.BEGIN||e==S.Phase.UPDATE||e==S.Phase.END)&&((this.phase!=S.Phase.UPDATE||e==S.Phase.UPDATE||e==S.Phase.END)&&(e==S.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=S.Phase.END}}Object.defineEnum(S,"Phase",["BEGIN","UPDATE","END"]);class w{constructor(e,t,i,s){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let n=[e,t];isFinite(i)&&(n.push(i),isFinite(s)&&n.push(s)),this.value=n.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==n.length?this.vec=r.vec2:3==n.length?(this.vec=r.vec3,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=r.vec4,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),w.fromPoint(t)}addSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),w.fromPoint(t)}subtractSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),w.fromPoint(t)}multiplySelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),w.fromPoint(t)}divideSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),w.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new w(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),w.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return w.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new w(e[0],e[1],e[2],e[3]):new w(e.x,e.y,e.z,e.w)}}class x{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof x))throw new TypeError("rect must be instance of RectGL");return e?x.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof x))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=x.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return x.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return x.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=w.fromPoint({x:this.left,y:this.bottom}).transform(e),r=w.fromPoint({x:this.right,y:this.bottom}).transform(e),i=w.fromPoint({x:this.left,y:this.top}).transform(e),s=w.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return x.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let i=w.fromPoint({x:this.left,y:this.bottom}).transform(e),s=w.fromPoint({x:this.right,y:this.bottom}).transform(e),n=w.fromPoint({x:this.left,y:this.top}).transform(e),o=w.fromPoint({x:this.right,y:this.top}).transform(e);t=r.quat2.fromValues(i.x,i.y,s.x,s.y,n.x,n.y,o.x,o.y)}else t=r.quat2.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new x(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new w(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of x.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return x.ofEdges(f,g,m,y)}}Object.defineProperty(x,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class v{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?v.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=v.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return v.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return v.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=w.fromPoint({x:this.left,y:this.top}).transform(e),r=w.fromPoint({x:this.right,y:this.top}).transform(e),i=w.fromPoint({x:this.left,y:this.bottom}).transform(e),s=w.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return v.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new x(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof x))throw new TypeError("rect must be instance of RectGL");return new v(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new v(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?v.fromString(e):new v(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return v.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=x.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return v.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new v(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const R={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},T=R.m11,A=R.m12,C=R.m21,O=R.m22,D=R.m41,k=R.m42;class N{constructor(e=r.mat4.create(),t=N.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let i=function(e,t){let r=R[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[T],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[A],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[C],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[O],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[D],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[k],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[D],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[k],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:i.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:i.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:i.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:i.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:i.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:i.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:i.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:i.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:i.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:i.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new N(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(N.fromTranslate(e))}translateSelf(e){this.multiplySelf(N.fromTranslate(e))}rotate(e,t){return this.multiply(N.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(N.fromRotate(e,t))}scale(e,t){return this.multiply(N.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(N.fromScale(e,t))}multiply(e){return this.multiplicationType==N.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=r.mat4.create();return r.mat4.multiply(t,e.toFloat32Array(),this.value),new N(t,this.multiplicationType)}postMultiply(e){let t=r.mat4.create();return r.mat4.multiply(t,this.value,e.toFloat32Array()),new N(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==N.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){r.mat4.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){r.mat4.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=r.mat4.create();return r.mat4.invert(e,this.value),new N(e,this.multiplicationType)}invertSelf(){r.mat4.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return w.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let i=r.mat4.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(i[0]=parseFloat(e[0]),i[1]=parseFloat(e[1]),i[2]=parseFloat(e[2]),i[3]=parseFloat(e[3]),i[4]=parseFloat(e[4]),i[5]=parseFloat(e[5]),i[6]=parseFloat(e[6]),i[7]=parseFloat(e[7]),i[8]=parseFloat(e[8]),i[9]=parseFloat(e[9]),i[10]=parseFloat(e[10]),i[11]=parseFloat(e[11]),i[12]=parseFloat(e[12]),i[13]=parseFloat(e[13]),i[14]=parseFloat(e[14]),i[15]=parseFloat(e[15])):(i[T]=parseFloat(e[0]),i[A]=parseFloat(e[1]),i[C]=parseFloat(e[2]),i[O]=parseFloat(e[3]),i[D]=parseFloat(e[4]),i[k]=parseFloat(e[5]))}return new N(i,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof N)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new N(e,t);if("string"==typeof e)return N.fromString(e,t);let i=r.mat4.create(),s=Object.assign({},e);return isFinite(e.a)&&(s.m11=e.a),isFinite(e.b)&&(s.m12=e.b),isFinite(e.c)&&(s.m21=e.c),isFinite(e.d)&&(s.m22=e.d),isFinite(e.tx)?s.m41=e.tx:isFinite(e.e)?s.m41=e.e:isFinite(e.dx)&&(s.m41=e.dx),isFinite(e.ty)?s.m42=e.ty:isFinite(e.f)?s.m42=e.f:isFinite(e.dy)&&(s.m42=e.dy),isFinite(s.m11)&&(i[0]=s.m11),isFinite(s.m12)&&(i[1]=s.m12),isFinite(s.m13)&&(i[2]=s.m13),isFinite(s.m14)&&(i[3]=s.m14),isFinite(s.m21)&&(i[4]=s.m21),isFinite(s.m22)&&(i[5]=s.m22),isFinite(s.m23)&&(i[6]=s.m23),isFinite(s.m24)&&(i[7]=s.m24),isFinite(s.m31)&&(i[8]=s.m31),isFinite(s.m32)&&(i[9]=s.m32),isFinite(s.m33)&&(i[10]=s.m33),isFinite(s.m34)&&(i[11]=s.m34),isFinite(s.m41)&&(i[12]=s.m41),isFinite(s.m42)&&(i[13]=s.m42),isFinite(s.m43)&&(i[14]=s.m43),isFinite(s.m44)&&(i[15]=s.m44),new N(i,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return N.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),N.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),N.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=N.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=N.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return N.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let i=r.mat4.create();return r.mat4.multiply(i,e.value,t.value),new N(i)}}N.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let M={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(M.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class L{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let _={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof y))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==_.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==_.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=_.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==_.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=S.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:S.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return I.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=_.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=_.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:N.fromMatrix(i);let s=w.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=v.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=w.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(_.PointerType.MOUSE)||(this.stop(_.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(_.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new L(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},F={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof y))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==y.prototype.resize)return;let e=F.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=F.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?F.ResizeReason.ZOOM_IN:F.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=M.debounce((()=>{e==F.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?F.ResizeReason.SCREEN_SIZE_INCREASED:F.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=F.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=y.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==F.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==F.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=S.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:S.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return I.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:N.fromMatrix(i);let s=w.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=v.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=w.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==F.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?F.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new L(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(F,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(_.suppressKeys=F.suppressKeys,_.ResizeReason=F.ResizeReason,_.attachResize=F.attachResize,_.dettachResize=F.dettachResize,F=_);var B=F;class U extends w{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||U.defaults.size,this.rotation=i.rotation||U.defaults.rotation,this.scaleX=i.scaleX||U.defaults.scaleX,this.scaleY=i.scaleY||U.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||U.defaults.scaleZ:void 0,this.offsetX=i.offsetX||U.defaults.offsetX,this.offsetY=i.offsetY||U.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||U.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new U(0,0,e.includes(U.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>U.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||U.defaults.size,this.rotation=s.rotation||i.rotation||U.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||U.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||U.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||U.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||U.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||U.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||U.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case U.Property.X:return this.x;case U.Property.Y:return this.y;case U.Property.Z:return this.z;case U.Property.RED:return this.red;case U.Property.GREEN:return this.green;case U.Property.BLUE:return this.blue;case U.Property.ALPHA:return this.alpha;case U.Property.SIZE:return this.size;case U.Property.ROTATION:return this.rotation;case U.Property.SCALE_X:return this.scaleX;case U.Property.SCALE_Y:return this.scaleY;case U.Property.SCALE_Z:return this.scaleZ;case U.Property.OFFSET_X:return this.offsetX;case U.Property.OFFSET_Y:return this.offsetY;case U.Property.OFFSET_Z:return this.offsetZ;case U.Property.D_X:return this.dX;case U.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){U.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case U.Property.X:e.x=r;break;case U.Property.Y:e.y=r;break;case U.Property.Z:e.z=r;break;case U.Property.RED:e.red=r;break;case U.Property.GREEN:e.green=r;break;case U.Property.BLUE:e.blue=r;break;case U.Property.ALPHA:e.alpha=r;break;case U.Property.SIZE:e.size=r;break;case U.Property.ROTATION:e.rotation=r;break;case U.Property.SCALE_X:e.scaleX=r;break;case U.Property.SCALE_Y:e.scaleY=r;break;case U.Property.SCALE_Z:e.scaleZ=r;break;case U.Property.OFFSET_X:e.offsetX=r;break;case U.Property.OFFSET_Y:e.offsetY=r;break;case U.Property.OFFSET_Z:e.offsetZ=r;break;case U.Property.D_X:e.dX=r;break;case U.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof N))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return U.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(U,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let j,G={version:"1.5.0"};Object.defineEnum(G,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(G,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(G,"TypeGL",["WEB","STACK"]),function(e){let t,r="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof require;t="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":r?"NODE":"SHELL";let i="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",s="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(G,"commonJS",{value:r,enumerable:!0}),Object.defineProperty(G,"type",{value:G.Type[t],enumerable:!0}),Object.defineProperty(G,"type2D",{value:G.Type2D[i],enumerable:!0}),Object.defineProperty(G,"typeGL",{value:G.TypeGL[s],enumerable:!0})}(),G.commonJS&&(j=require("systeminformation"));var $=j;class Y extends P{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",P.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new Y;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=G.version,t.props["runtime.type"]=G.type.name,void 0===$)t.props["user.agent"]=navigator.userAgent;else{let e=await $.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const X={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class z{static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=z.getUnitMetric(e);return i!=z.Metric.NORMALIZED&&i!=z.Metric.LOGICAL&&(r=z[V[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*z[V[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*z[t.name][r.name]/i}static getUnitMetric(e){switch(e){case z.Unit.METER:case z.Unit.CENTIMETER:case z.Unit.MILLIMETER:case z.Unit.MICROMETER:case z.Unit.INCH:case z.Unit.DP:case z.Unit.PICA:case z.Unit.POINT:case z.Unit.DIP:case z.Unit.DPI:return z.Metric.LENGTH;case z.Unit.SECOND:case z.Unit.MILLISECOND:case z.Unit.MICROSECOND:case z.Unit.NANOSECOND:return z.Metric.TIME;case z.Unit.RADIAN:case z.Unit.DEGREE:return z.Metric.ANGLE;case z.Unit.NEWTON:return z.Metric.FORCE;case z.Unit.NORMALIZED:return z.Metric.NORMALIZED;case z.Unit.LOGICAL:return z.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case z.Metric.LENGTH:return[z.Unit.METER,z.Unit.CENTIMETER,z.Unit.MILLIMETER,z.Unit.MICROMETER,z.Unit.INCH,z.Unit.DP,z.Unit.PICA,z.Unit.POINT,z.Unit.DIP,z.Unit.DPI];case z.Metric.TIME:return[z.Unit.SECOND,z.Unit.MILLISECOND,z.Unit.MICROSECOND,z.Unit.NANOSECOND];case z.Metric.ANGLE:return[z.Unit.RADIAN,z.Unit.DEGREE];case z.Metric.FORCE:return[z.Unit.NEWTON];case z.Metric.NORMALIZED:return[z.Unit.NORMALIZED];case z.Metric.LOGICAL:return[z.Unit.LOGICAL];case z.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return V[e.name]}static convertValue(e,t,r){return e*z[t.name][r.name]}}Object.defineEnum(z,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum(z,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const V=Object.freeze({LENGTH:z.Unit.METER,TIME:z.Unit.SECOND,FORCE:z.Unit.NEWTON,ANGLE:z.Unit.RADIAN,NORMALIZED:z.Unit.NORMALIZED,LOGICAL:z.Unit.LOGICAL});!function(){let e=z.getMetricUnits(z.Metric.LENGTH).filter((e=>!(e.name in X)));for(let t of e){let e=z.Units[t.name];for(let t in X)e[t]=e.INCH*X[t]}for(let t in X){let r={};for(let i of e)r[i.name]=z.Units.INCH[i.name]/X[t];for(let e in X)r[e]=X[e]/X[t];z.Units[t]=r}for(let e in z.Units)z[e]=z.Units[e]}(),Object.freeze(z);class H extends P{constructor(e,t,r,i,s){if(super(),t==H.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=H.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=z.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==H.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return M.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(H.Type).find((t=>H.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case H.Type.X:case H.Type.Y:case H.Type.Z:case H.Type.RADIUS_X:case H.Type.RADIUS_Y:t.unit=z.Unit.DIP;break;case H.Type.TIMESTAMP:t.unit=z.Unit.MILLISECOND;break;case H.Type.PRESSURE:t.unit=z.Unit.NORMALIZED,t.min=0,t.max=1;break;case H.Type.ALTITUDE:t.unit=z.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case H.Type.AZIMUTH:t.unit=z.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case H.Type.ROTATION:t.unit=z.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=z.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new H(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=H.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=z.getChannelResolution(r.unit),s=new H(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=H.Type.X&&e!=H.Type.Y||t.type!=I.Type.MOUSE||(s.precision=0),s}}H.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),H.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},H.Metric=z.Metric;class Z extends P{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==H.Type.X||e.type==H.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new Z(e,t);return r.channels=H.defaults[t.type.name].map((e=>H.createDefaultInstance(H.Type[e],t))),r}}class q extends P{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new q;return r.addContext(Z.createDefaultInstance(e,t)),r}}class W extends P{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=q.createDefaultInstance(t,r);return new W(e,i)}}class K{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${K.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class J extends P{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=K.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=J.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(J,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class Q{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=M.getPropName(t.name),i=e[r];if(t.type==H.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==H.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=M.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==H.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class ee extends P{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",P.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof ee))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new I(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return q.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=I.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new W(this.environment,r);r.inkChannelsContext.layout=ee.getLayout(e),this.sensorData=new J(i),this.sensorData.add(new Q(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(H.Type).forEach((r=>{let i,s=H.Type[r];i=s==H.Type.ALTITUDE?"tiltX":s==H.Type.AZIMUTH?"tiltY":M.getPropName(r),ee.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===$)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await $.system(),r=await $.cpu(),i=await $.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await Y.createInstance(e),t}}let te={};if(G.type==G.Type.WEB)te.Image=globalThis.Image,te.ImageData=globalThis.ImageData,te.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(te.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},te.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(te.OffscreenCanvas=globalThis.OffscreenCanvas,te.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)te.Image=globalThis.Image,te.ImageData=globalThis.ImageData,te.OffscreenCanvas=globalThis.OffscreenCanvas,te.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(G.commonJS){const{Canvas:e,CanvasRenderingContext2D:t,Image:r,ImageData:i}=require("canvas");te.Image=r,te.ImageData=i,te.OffscreenCanvas=e,te.OffscreenCanvasRenderingContext2D=t}else console.warn(`Current env - ${G.type.name}, do not provides OffscreenCanvas support`);function re(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}te.CanvasRenderingContext2D&&(te.CanvasRenderingContext2D.prototype.clearCanvas=re),te.OffscreenCanvasRenderingContext2D&&(te.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=re);const{Image:ie,ImageData:se,OffscreenCanvas:ne,CanvasRenderingContext2D:oe,OffscreenCanvasRenderingContext2D:ae}=te;let le;class he{#r={};constructor(...e){if(le)throw new Error("URIResolver instance already available");le=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(he,"instance",{get:()=>le});class de{static encode(e,t=de.Encoding.AUTO){let r;if(t==de.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?de.Encoding.NONE:de.Encoding.ARRAY:de.Encoding.BUFFER:t==de.Encoding.ARRAY&&e instanceof Array&&(t=de.Encoding.NONE),t==de.Encoding.NONE)r=e;else if(t==de.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case de.Encoding.BUFFER:r=i.toJSON();break;case de.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=de.Encoding[e.encoding];if(r==de.Encoding.NONE)t=e.content;else if(r==de.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case de.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case de.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(de,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class ce{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||M.isValidURL(e)||ce.repetitionsCache.has(e)||(ce.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!he.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=he.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=de.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return de.isTypedArrayData(t)&&(t=de.decode(t)),new ce(e.name,t)}static getInstance(e,t){return new ce(t,e)}}class pe{constructor(e){M.isValidURL(e)||(ce.repetitionsCache.has(e)||(ce.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class ue{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=ue.defaults.CIRCLE_PRECISION,t=ue.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return ue.createEllipse(e,t,t,r)}static createEllipse(e=ue.defaults.ELLIPSE_PRECISION,t=ue.defaults.ELLIPSE_RADIUS_X,r=ue.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=ue.defaults.STAR_POINTS,t=ue.defaults.STAR_INTERNAL_RADIUS,r=ue.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let fe=p?p...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.cjs.mjs line 1
- Likely real
- Uncertain, 45% confidence
Possibility of prototype polluting function detected. By adding or modifying attributes of an object prototype, it is possible to create attributes that exist on every object, or replace critical attributes with malicious ones. This can be problematic if the software depends on existence or non-existence of certain attributes, or uses pre-defined attributes of object prototype (such as hasOwnProperty, toString or valueOf). Possible mitigations might be: freezing the object prototype, using an object without prototypes (via Object.create(null) ), blocking modifications of attributes that resolve to object prototype, using Map instead of object.
import{createRequire as e}from"module";const t=e(import.meta.url);t.resolve.paths(".")[0];import"js-ext";import*as r from"js-md5";import i from"long";import{vec2 as s,vec3 as n,vec4 as o,quat2 as a,mat4 as l,mat2d as h}from"gl-matrix";import*as d from"poly2tri";import*as c from"clipper-lib";import p from"rbush";import*as u from"jszip";import*as f from"protobufjs";var m="1.5.0";class g{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let y=r?r.default||globalThis.md5:{},b={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(y.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),r=this.toBytes(e);return t[0]=i.fromBytes(r.slice(0,8)),t[1]=i.fromBytes(r.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class E{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=E.Algorithm.MD5;else if("function"==typeof this.buildURI)t=E.Algorithm.URI;else if(t=E.Algorithm.GUID,e&&!b.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=E.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==E.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return y(e)}return this.algorithm==E.Algorithm.URI?this.buildURI():b.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(E,"Algorithm",["GUID","MD5","URI"]);class P extends E{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,E.buildMD5Tokens(this.props)]}}Object.defineEnum(P,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class I{constructor(){this.phase=I.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=I.Phase.END||e==I.Phase.BEGIN)&&((this.phase!=I.Phase.BEGIN||e==I.Phase.UPDATE||e==I.Phase.END)&&((this.phase!=I.Phase.UPDATE||e==I.Phase.UPDATE||e==I.Phase.END)&&(e==I.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=I.Phase.END}}Object.defineEnum(I,"Phase",["BEGIN","UPDATE","END"]);class S{constructor(e,t,r,i){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let a=[e,t];isFinite(r)&&(a.push(r),isFinite(i)&&a.push(i)),this.value=a.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==a.length?this.vec=s:3==a.length?(this.vec=n,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=o,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),S.fromPoint(t)}addSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),S.fromPoint(t)}subtractSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),S.fromPoint(t)}multiplySelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),S.fromPoint(t)}divideSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),S.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new S(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),S.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return S.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new S(e[0],e[1],e[2],e[3]):new S(e.x,e.y,e.z,e.w)}}class w{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof w))throw new TypeError("rect must be instance of RectGL");return e?w.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof w))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=w.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return w.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return w.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=S.fromPoint({x:this.left,y:this.bottom}).transform(e),r=S.fromPoint({x:this.right,y:this.bottom}).transform(e),i=S.fromPoint({x:this.left,y:this.top}).transform(e),s=S.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return w.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let r=S.fromPoint({x:this.left,y:this.bottom}).transform(e),i=S.fromPoint({x:this.right,y:this.bottom}).transform(e),s=S.fromPoint({x:this.left,y:this.top}).transform(e),n=S.fromPoint({x:this.right,y:this.top}).transform(e);t=a.fromValues(r.x,r.y,i.x,i.y,s.x,s.y,n.x,n.y)}else t=a.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new w(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new S(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of w.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return w.ofEdges(f,g,m,y)}}Object.defineProperty(w,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class x{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?x.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=x.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return x.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return x.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=S.fromPoint({x:this.left,y:this.top}).transform(e),r=S.fromPoint({x:this.right,y:this.top}).transform(e),i=S.fromPoint({x:this.left,y:this.bottom}).transform(e),s=S.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return x.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new w(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof w))throw new TypeError("rect must be instance of RectGL");return new x(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new x(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?x.fromString(e):new x(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return x.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=w.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return x.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new x(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const v={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},R=v.m11,T=v.m12,A=v.m21,C=v.m22,O=v.m41,D=v.m42;class k{constructor(e=l.create(),t=k.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let r=function(e,t){let r=v[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[R],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[T],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[A],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[C],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[O],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[D],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[O],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[D],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:r.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:r.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:r.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:r.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:r.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:r.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:r.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:r.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:r.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:r.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new k(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(k.fromTranslate(e))}translateSelf(e){this.multiplySelf(k.fromTranslate(e))}rotate(e,t){return this.multiply(k.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(k.fromRotate(e,t))}scale(e,t){return this.multiply(k.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(k.fromScale(e,t))}multiply(e){return this.multiplicationType==k.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=l.create();return l.multiply(t,e.toFloat32Array(),this.value),new k(t,this.multiplicationType)}postMultiply(e){let t=l.create();return l.multiply(t,this.value,e.toFloat32Array()),new k(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==k.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){l.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){l.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=l.create();return l.invert(e,this.value),new k(e,this.multiplicationType)}invertSelf(){l.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return S.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let r=l.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(r[0]=parseFloat(e[0]),r[1]=parseFloat(e[1]),r[2]=parseFloat(e[2]),r[3]=parseFloat(e[3]),r[4]=parseFloat(e[4]),r[5]=parseFloat(e[5]),r[6]=parseFloat(e[6]),r[7]=parseFloat(e[7]),r[8]=parseFloat(e[8]),r[9]=parseFloat(e[9]),r[10]=parseFloat(e[10]),r[11]=parseFloat(e[11]),r[12]=parseFloat(e[12]),r[13]=parseFloat(e[13]),r[14]=parseFloat(e[14]),r[15]=parseFloat(e[15])):(r[R]=parseFloat(e[0]),r[T]=parseFloat(e[1]),r[A]=parseFloat(e[2]),r[C]=parseFloat(e[3]),r[O]=parseFloat(e[4]),r[D]=parseFloat(e[5]))}return new k(r,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof k)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new k(e,t);if("string"==typeof e)return k.fromString(e,t);let r=l.create(),i=Object.assign({},e);return isFinite(e.a)&&(i.m11=e.a),isFinite(e.b)&&(i.m12=e.b),isFinite(e.c)&&(i.m21=e.c),isFinite(e.d)&&(i.m22=e.d),isFinite(e.tx)?i.m41=e.tx:isFinite(e.e)?i.m41=e.e:isFinite(e.dx)&&(i.m41=e.dx),isFinite(e.ty)?i.m42=e.ty:isFinite(e.f)?i.m42=e.f:isFinite(e.dy)&&(i.m42=e.dy),isFinite(i.m11)&&(r[0]=i.m11),isFinite(i.m12)&&(r[1]=i.m12),isFinite(i.m13)&&(r[2]=i.m13),isFinite(i.m14)&&(r[3]=i.m14),isFinite(i.m21)&&(r[4]=i.m21),isFinite(i.m22)&&(r[5]=i.m22),isFinite(i.m23)&&(r[6]=i.m23),isFinite(i.m24)&&(r[7]=i.m24),isFinite(i.m31)&&(r[8]=i.m31),isFinite(i.m32)&&(r[9]=i.m32),isFinite(i.m33)&&(r[10]=i.m33),isFinite(i.m34)&&(r[11]=i.m34),isFinite(i.m41)&&(r[12]=i.m41),isFinite(i.m42)&&(r[13]=i.m42),isFinite(i.m43)&&(r[14]=i.m43),isFinite(i.m44)&&(r[15]=i.m44),new k(r,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return k.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),k.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),k.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=k.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=k.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return k.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let r=l.create();return l.multiply(r,e.value,t.value),new k(r)}}k.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let N={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(N.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class M{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let L={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof g))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==L.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==L.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=L.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==L.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=I.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:I.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return P.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=L.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=L.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:k.fromMatrix(i);let s=S.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=x.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=S.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(L.PointerType.MOUSE)||(this.stop(L.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(L.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new M(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},_={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof g))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==g.prototype.resize)return;let e=_.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=_.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?_.ResizeReason.ZOOM_IN:_.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=N.debounce((()=>{e==_.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?_.ResizeReason.SCREEN_SIZE_INCREASED:_.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=_.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=g.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==_.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==_.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=I.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:I.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return P.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:k.fromMatrix(i);let s=S.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=x.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=S.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==_.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?_.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new M(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(_,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(L.suppressKeys=_.suppressKeys,L.ResizeReason=_.ResizeReason,L.attachResize=_.attachResize,L.dettachResize=_.dettachResize,_=L);var F=_;class B extends S{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||B.defaults.size,this.rotation=i.rotation||B.defaults.rotation,this.scaleX=i.scaleX||B.defaults.scaleX,this.scaleY=i.scaleY||B.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||B.defaults.scaleZ:void 0,this.offsetX=i.offsetX||B.defaults.offsetX,this.offsetY=i.offsetY||B.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||B.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new B(0,0,e.includes(B.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>B.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||B.defaults.size,this.rotation=s.rotation||i.rotation||B.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||B.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||B.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||B.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||B.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||B.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||B.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case B.Property.X:return this.x;case B.Property.Y:return this.y;case B.Property.Z:return this.z;case B.Property.RED:return this.red;case B.Property.GREEN:return this.green;case B.Property.BLUE:return this.blue;case B.Property.ALPHA:return this.alpha;case B.Property.SIZE:return this.size;case B.Property.ROTATION:return this.rotation;case B.Property.SCALE_X:return this.scaleX;case B.Property.SCALE_Y:return this.scaleY;case B.Property.SCALE_Z:return this.scaleZ;case B.Property.OFFSET_X:return this.offsetX;case B.Property.OFFSET_Y:return this.offsetY;case B.Property.OFFSET_Z:return this.offsetZ;case B.Property.D_X:return this.dX;case B.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){B.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case B.Property.X:e.x=r;break;case B.Property.Y:e.y=r;break;case B.Property.Z:e.z=r;break;case B.Property.RED:e.red=r;break;case B.Property.GREEN:e.green=r;break;case B.Property.BLUE:e.blue=r;break;case B.Property.ALPHA:e.alpha=r;break;case B.Property.SIZE:e.size=r;break;case B.Property.ROTATION:e.rotation=r;break;case B.Property.SCALE_X:e.scaleX=r;break;case B.Property.SCALE_Y:e.scaleY=r;break;case B.Property.SCALE_Z:e.scaleZ=r;break;case B.Property.OFFSET_X:e.offsetX=r;break;case B.Property.OFFSET_Y:e.offsetY=r;break;case B.Property.OFFSET_Z:e.offsetZ=r;break;case B.Property.D_X:e.dX=r;break;case B.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof k))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return B.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(B,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let U,j={version:"1.5.0"};Object.defineEnum(j,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(j,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(j,"TypeGL",["WEB","STACK"]),function(e){let r,i="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof t;r="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":i?"NODE":"SHELL";let s="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",n="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(j,"commonJS",{value:i,enumerable:!0}),Object.defineProperty(j,"type",{value:j.Type[r],enumerable:!0}),Object.defineProperty(j,"type2D",{value:j.Type2D[s],enumerable:!0}),Object.defineProperty(j,"typeGL",{value:j.TypeGL[n],enumerable:!0})}(),j.commonJS&&(U=t("systeminformation"));var G=U;class $ extends E{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",E.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new $;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=j.version,t.props["runtime.type"]=j.type.name,void 0===G)t.props["user.agent"]=navigator.userAgent;else{let e=await G.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const Y={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class X{static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=X.getUnitMetric(e);return i!=X.Metric.NORMALIZED&&i!=X.Metric.LOGICAL&&(r=X[z[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*X[z[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*X[t.name][r.name]/i}static getUnitMetric(e){switch(e){case X.Unit.METER:case X.Unit.CENTIMETER:case X.Unit.MILLIMETER:case X.Unit.MICROMETER:case X.Unit.INCH:case X.Unit.DP:case X.Unit.PICA:case X.Unit.POINT:case X.Unit.DIP:case X.Unit.DPI:return X.Metric.LENGTH;case X.Unit.SECOND:case X.Unit.MILLISECOND:case X.Unit.MICROSECOND:case X.Unit.NANOSECOND:return X.Metric.TIME;case X.Unit.RADIAN:case X.Unit.DEGREE:return X.Metric.ANGLE;case X.Unit.NEWTON:return X.Metric.FORCE;case X.Unit.NORMALIZED:return X.Metric.NORMALIZED;case X.Unit.LOGICAL:return X.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case X.Metric.LENGTH:return[X.Unit.METER,X.Unit.CENTIMETER,X.Unit.MILLIMETER,X.Unit.MICROMETER,X.Unit.INCH,X.Unit.DP,X.Unit.PICA,X.Unit.POINT,X.Unit.DIP,X.Unit.DPI];case X.Metric.TIME:return[X.Unit.SECOND,X.Unit.MILLISECOND,X.Unit.MICROSECOND,X.Unit.NANOSECOND];case X.Metric.ANGLE:return[X.Unit.RADIAN,X.Unit.DEGREE];case X.Metric.FORCE:return[X.Unit.NEWTON];case X.Metric.NORMALIZED:return[X.Unit.NORMALIZED];case X.Metric.LOGICAL:return[X.Unit.LOGICAL];case X.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return z[e.name]}static convertValue(e,t,r){return e*X[t.name][r.name]}}Object.defineEnum(X,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum(X,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const z=Object.freeze({LENGTH:X.Unit.METER,TIME:X.Unit.SECOND,FORCE:X.Unit.NEWTON,ANGLE:X.Unit.RADIAN,NORMALIZED:X.Unit.NORMALIZED,LOGICAL:X.Unit.LOGICAL});!function(){let e=X.getMetricUnits(X.Metric.LENGTH).filter((e=>!(e.name in Y)));for(let t of e){let e=X.Units[t.name];for(let t in Y)e[t]=e.INCH*Y[t]}for(let t in Y){let r={};for(let i of e)r[i.name]=X.Units.INCH[i.name]/Y[t];for(let e in Y)r[e]=Y[e]/Y[t];X.Units[t]=r}for(let e in X.Units)X[e]=X.Units[e]}(),Object.freeze(X);class V extends E{constructor(e,t,r,i,s){if(super(),t==V.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=V.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=X.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==V.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return N.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(V.Type).find((t=>V.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case V.Type.X:case V.Type.Y:case V.Type.Z:case V.Type.RADIUS_X:case V.Type.RADIUS_Y:t.unit=X.Unit.DIP;break;case V.Type.TIMESTAMP:t.unit=X.Unit.MILLISECOND;break;case V.Type.PRESSURE:t.unit=X.Unit.NORMALIZED,t.min=0,t.max=1;break;case V.Type.ALTITUDE:t.unit=X.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case V.Type.AZIMUTH:t.unit=X.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case V.Type.ROTATION:t.unit=X.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=X.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new V(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=V.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=X.getChannelResolution(r.unit),s=new V(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=V.Type.X&&e!=V.Type.Y||t.type!=P.Type.MOUSE||(s.precision=0),s}}V.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),V.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},V.Metric=X.Metric;class H extends E{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==V.Type.X||e.type==V.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new H(e,t);return r.channels=V.defaults[t.type.name].map((e=>V.createDefaultInstance(V.Type[e],t))),r}}class Z extends E{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new Z;return r.addContext(H.createDefaultInstance(e,t)),r}}class W extends E{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=Z.createDefaultInstance(t,r);return new W(e,i)}}class q{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${q.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class K extends E{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=q.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=K.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(K,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class J{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=N.getPropName(t.name),i=e[r];if(t.type==V.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==V.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=N.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==V.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class Q extends E{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",E.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof Q))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new P(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return Z.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=P.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new W(this.environment,r);r.inkChannelsContext.layout=Q.getLayout(e),this.sensorData=new K(i),this.sensorData.add(new J(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(V.Type).forEach((r=>{let i,s=V.Type[r];i=s==V.Type.ALTITUDE?"tiltX":s==V.Type.AZIMUTH?"tiltY":N.getPropName(r),Q.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===G)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await G.system(),r=await G.cpu(),i=await G.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await $.createInstance(e),t}}let ee={};if(j.type==j.Type.WEB)ee.Image=globalThis.Image,ee.ImageData=globalThis.ImageData,ee.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(ee.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},ee.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(ee.OffscreenCanvas=globalThis.OffscreenCanvas,ee.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)ee.Image=globalThis.Image,ee.ImageData=globalThis.ImageData,ee.OffscreenCanvas=globalThis.OffscreenCanvas,ee.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(j.commonJS){const{Canvas:e,CanvasRenderingContext2D:r,Image:i,ImageData:s}=t("canvas");ee.Image=i,ee.ImageData=s,ee.OffscreenCanvas=e,ee.OffscreenCanvasRenderingContext2D=r}else console.warn(`Current env - ${j.type.name}, do not provides OffscreenCanvas support`);function te(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}ee.CanvasRenderingContext2D&&(ee.CanvasRenderingContext2D.prototype.clearCanvas=te),ee.OffscreenCanvasRenderingContext2D&&(ee.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=te);const{Image:re,ImageData:ie,OffscreenCanvas:se,CanvasRenderingContext2D:ne,OffscreenCanvasRenderingContext2D:oe}=ee;let ae;class le{#r={};constructor(...e){if(ae)throw new Error("URIResolver instance already available");ae=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(le,"instance",{get:()=>ae});class he{static encode(e,t=he.Encoding.AUTO){let r;if(t==he.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?he.Encoding.NONE:he.Encoding.ARRAY:he.Encoding.BUFFER:t==he.Encoding.ARRAY&&e instanceof Array&&(t=he.Encoding.NONE),t==he.Encoding.NONE)r=e;else if(t==he.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case he.Encoding.BUFFER:r=i.toJSON();break;case he.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=he.Encoding[e.encoding];if(r==he.Encoding.NONE)t=e.content;else if(r==he.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case he.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case he.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(he,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class de{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||N.isValidURL(e)||de.repetitionsCache.has(e)||(de.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!le.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=le.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=he.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return he.isTypedArrayData(t)&&(t=he.decode(t)),new de(e.name,t)}static getInstance(e,t){return new de(t,e)}}class ce{constructor(e){N.isValidURL(e)||(de.repetitionsCache.has(e)||(de.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class pe{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=pe.defaults.CIRCLE_PRECISION,t=pe.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return pe.createEllipse(e,t,t,r)}static createEllipse(e=pe.defaults.ELLIPSE_PRECISION,t=pe.defaults.ELLIPSE_RADIUS_X,r=pe.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=pe.defaults.STAR_POINTS,t=pe.defaults.STAR_INTERNAL_RADIUS,r=pe.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let ue=d?d.default||globalThis.poly2tri:{};const{SweepContext:fe,Point:me}=ue;let ge=c?c.default||globalThis.ClipperLib:{};const{Clipper:ye,Paths:be,Path:Ee,ClipType:Pe,PolyType:Ie,PolyFillType:Se}=ge;class we{constructor(e,t,r){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:r,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.mjs line 1
- Likely real
- Uncertain, 45% confidence
Possibility of prototype polluting function detected. By adding or modifying attributes of an object prototype, it is possible to create attributes that exist on every object, or replace critical attributes with malicious ones. This can be problematic if the software depends on existence or non-existence of certain attributes, or uses pre-defined attributes of object prototype (such as hasOwnProperty, toString or valueOf). Possible mitigations might be: freezing the object prototype, using an object without prototypes (via Object.create(null) ), blocking modifications of attributes that resolve to object prototype, using Map instead of object.
import"js-ext";import*as e from"js-md5";import t from"long";import{vec2 as r,vec3 as i,vec4 as s,quat2 as n,mat4 as o,mat2d as a}from"gl-matrix";import*as l from"poly2tri";import*as h from"clipper-lib";import d from"rbush";import*as c from"jszip";import*as p from"protobufjs";var u="1.5.0";class f{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let m=e?e.default||globalThis.md5:{},g={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(m.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let r=new Array(2),i=this.toBytes(e);return r[0]=t.fromBytes(i.slice(0,8)),r[1]=t.fromBytes(i.slice(8)),r},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class y{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=y.Algorithm.MD5;else if("function"==typeof this.buildURI)t=y.Algorithm.URI;else if(t=y.Algorithm.GUID,e&&!g.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=y.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==y.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return m(e)}return this.algorithm==y.Algorithm.URI?this.buildURI():g.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(y,"Algorithm",["GUID","MD5","URI"]);class b extends y{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,y.buildMD5Tokens(this.props)]}}Object.defineEnum(b,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class E{constructor(){this.phase=E.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=E.Phase.END||e==E.Phase.BEGIN)&&((this.phase!=E.Phase.BEGIN||e==E.Phase.UPDATE||e==E.Phase.END)&&((this.phase!=E.Phase.UPDATE||e==E.Phase.UPDATE||e==E.Phase.END)&&(e==E.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=E.Phase.END}}Object.defineEnum(E,"Phase",["BEGIN","UPDATE","END"]);class P{constructor(e,t,n,o){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let a=[e,t];isFinite(n)&&(a.push(n),isFinite(o)&&a.push(o)),this.value=a.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==a.length?this.vec=r:3==a.length?(this.vec=i,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=s,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),P.fromPoint(t)}addSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),P.fromPoint(t)}subtractSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),P.fromPoint(t)}multiplySelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),P.fromPoint(t)}divideSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),P.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new P(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),P.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return P.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new P(e[0],e[1],e[2],e[3]):new P(e.x,e.y,e.z,e.w)}}class I{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof I))throw new TypeError("rect must be instance of RectGL");return e?I.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof I))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=I.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return I.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return I.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=P.fromPoint({x:this.left,y:this.bottom}).transform(e),r=P.fromPoint({x:this.right,y:this.bottom}).transform(e),i=P.fromPoint({x:this.left,y:this.top}).transform(e),s=P.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return I.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let r=P.fromPoint({x:this.left,y:this.bottom}).transform(e),i=P.fromPoint({x:this.right,y:this.bottom}).transform(e),s=P.fromPoint({x:this.left,y:this.top}).transform(e),o=P.fromPoint({x:this.right,y:this.top}).transform(e);t=n.fromValues(r.x,r.y,i.x,i.y,s.x,s.y,o.x,o.y)}else t=n.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new I(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new P(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of I.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return I.ofEdges(f,g,m,y)}}Object.defineProperty(I,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class S{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?S.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=S.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return S.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return S.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=P.fromPoint({x:this.left,y:this.top}).transform(e),r=P.fromPoint({x:this.right,y:this.top}).transform(e),i=P.fromPoint({x:this.left,y:this.bottom}).transform(e),s=P.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return S.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new I(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof I))throw new TypeError("rect must be instance of RectGL");return new S(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new S(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?S.fromString(e):new S(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return S.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=I.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return S.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new S(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const w={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},x=w.m11,v=w.m12,R=w.m21,T=w.m22,A=w.m41,C=w.m42;class O{constructor(e=o.create(),t=O.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let r=function(e,t){let r=w[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[x],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[v],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[R],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[T],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[A],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[C],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[A],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[C],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:r.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:r.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:r.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:r.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:r.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:r.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:r.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:r.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:r.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:r.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new O(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(O.fromTranslate(e))}translateSelf(e){this.multiplySelf(O.fromTranslate(e))}rotate(e,t){return this.multiply(O.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(O.fromRotate(e,t))}scale(e,t){return this.multiply(O.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(O.fromScale(e,t))}multiply(e){return this.multiplicationType==O.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=o.create();return o.multiply(t,e.toFloat32Array(),this.value),new O(t,this.multiplicationType)}postMultiply(e){let t=o.create();return o.multiply(t,this.value,e.toFloat32Array()),new O(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==O.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){o.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){o.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=o.create();return o.invert(e,this.value),new O(e,this.multiplicationType)}invertSelf(){o.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return P.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let r=o.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(r[0]=parseFloat(e[0]),r[1]=parseFloat(e[1]),r[2]=parseFloat(e[2]),r[3]=parseFloat(e[3]),r[4]=parseFloat(e[4]),r[5]=parseFloat(e[5]),r[6]=parseFloat(e[6]),r[7]=parseFloat(e[7]),r[8]=parseFloat(e[8]),r[9]=parseFloat(e[9]),r[10]=parseFloat(e[10]),r[11]=parseFloat(e[11]),r[12]=parseFloat(e[12]),r[13]=parseFloat(e[13]),r[14]=parseFloat(e[14]),r[15]=parseFloat(e[15])):(r[x]=parseFloat(e[0]),r[v]=parseFloat(e[1]),r[R]=parseFloat(e[2]),r[T]=parseFloat(e[3]),r[A]=parseFloat(e[4]),r[C]=parseFloat(e[5]))}return new O(r,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof O)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new O(e,t);if("string"==typeof e)return O.fromString(e,t);let r=o.create(),i=Object.assign({},e);return isFinite(e.a)&&(i.m11=e.a),isFinite(e.b)&&(i.m12=e.b),isFinite(e.c)&&(i.m21=e.c),isFinite(e.d)&&(i.m22=e.d),isFinite(e.tx)?i.m41=e.tx:isFinite(e.e)?i.m41=e.e:isFinite(e.dx)&&(i.m41=e.dx),isFinite(e.ty)?i.m42=e.ty:isFinite(e.f)?i.m42=e.f:isFinite(e.dy)&&(i.m42=e.dy),isFinite(i.m11)&&(r[0]=i.m11),isFinite(i.m12)&&(r[1]=i.m12),isFinite(i.m13)&&(r[2]=i.m13),isFinite(i.m14)&&(r[3]=i.m14),isFinite(i.m21)&&(r[4]=i.m21),isFinite(i.m22)&&(r[5]=i.m22),isFinite(i.m23)&&(r[6]=i.m23),isFinite(i.m24)&&(r[7]=i.m24),isFinite(i.m31)&&(r[8]=i.m31),isFinite(i.m32)&&(r[9]=i.m32),isFinite(i.m33)&&(r[10]=i.m33),isFinite(i.m34)&&(r[11]=i.m34),isFinite(i.m41)&&(r[12]=i.m41),isFinite(i.m42)&&(r[13]=i.m42),isFinite(i.m43)&&(r[14]=i.m43),isFinite(i.m44)&&(r[15]=i.m44),new O(r,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return O.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),O.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),O.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=O.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=O.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return O.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let r=o.create();return o.multiply(r,e.value,t.value),new O(r)}}O.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let D={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(D.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class k{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let N={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof f))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==N.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==N.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=N.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==N.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=E.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:E.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return b.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=N.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=N.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:O.fromMatrix(i);let s=P.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=S.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=P.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(N.PointerType.MOUSE)||(this.stop(N.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(N.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new k(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},M={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof f))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==f.prototype.resize)return;let e=M.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=M.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?M.ResizeReason.ZOOM_IN:M.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=D.debounce((()=>{e==M.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?M.ResizeReason.SCREEN_SIZE_INCREASED:M.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=M.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=f.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==M.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==M.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=E.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:E.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return b.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:O.fromMatrix(i);let s=P.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=S.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=P.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==M.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?M.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new k(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(M,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(N.suppressKeys=M.suppressKeys,N.ResizeReason=M.ResizeReason,N.attachResize=M.attachResize,N.dettachResize=M.dettachResize,M=N);var L=M;class _ extends P{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||_.defaults.size,this.rotation=i.rotation||_.defaults.rotation,this.scaleX=i.scaleX||_.defaults.scaleX,this.scaleY=i.scaleY||_.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||_.defaults.scaleZ:void 0,this.offsetX=i.offsetX||_.defaults.offsetX,this.offsetY=i.offsetY||_.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||_.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new _(0,0,e.includes(_.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>_.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||_.defaults.size,this.rotation=s.rotation||i.rotation||_.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||_.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||_.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||_.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||_.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||_.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||_.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case _.Property.X:return this.x;case _.Property.Y:return this.y;case _.Property.Z:return this.z;case _.Property.RED:return this.red;case _.Property.GREEN:return this.green;case _.Property.BLUE:return this.blue;case _.Property.ALPHA:return this.alpha;case _.Property.SIZE:return this.size;case _.Property.ROTATION:return this.rotation;case _.Property.SCALE_X:return this.scaleX;case _.Property.SCALE_Y:return this.scaleY;case _.Property.SCALE_Z:return this.scaleZ;case _.Property.OFFSET_X:return this.offsetX;case _.Property.OFFSET_Y:return this.offsetY;case _.Property.OFFSET_Z:return this.offsetZ;case _.Property.D_X:return this.dX;case _.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){_.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case _.Property.X:e.x=r;break;case _.Property.Y:e.y=r;break;case _.Property.Z:e.z=r;break;case _.Property.RED:e.red=r;break;case _.Property.GREEN:e.green=r;break;case _.Property.BLUE:e.blue=r;break;case _.Property.ALPHA:e.alpha=r;break;case _.Property.SIZE:e.size=r;break;case _.Property.ROTATION:e.rotation=r;break;case _.Property.SCALE_X:e.scaleX=r;break;case _.Property.SCALE_Y:e.scaleY=r;break;case _.Property.SCALE_Z:e.scaleZ=r;break;case _.Property.OFFSET_X:e.offsetX=r;break;case _.Property.OFFSET_Y:e.offsetY=r;break;case _.Property.OFFSET_Z:e.offsetZ=r;break;case _.Property.D_X:e.dX=r;break;case _.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof O))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return _.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(_,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let F,B={version:"1.5.0"};Object.defineEnum(B,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(B,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(B,"TypeGL",["WEB","STACK"]),function(e){let t,r="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof require;t="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":r?"NODE":"SHELL";let i="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",s="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(B,"commonJS",{value:r,enumerable:!0}),Object.defineProperty(B,"type",{value:B.Type[t],enumerable:!0}),Object.defineProperty(B,"type2D",{value:B.Type2D[i],enumerable:!0}),Object.defineProperty(B,"typeGL",{value:B.TypeGL[s],enumerable:!0})}(),B.commonJS&&(F=require("systeminformation"));var U=F;class j extends y{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",y.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new j;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=B.version,t.props["runtime.type"]=B.type.name,void 0===U)t.props["user.agent"]=navigator.userAgent;else{let e=await U.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const G={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class ${static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=$.getUnitMetric(e);return i!=$.Metric.NORMALIZED&&i!=$.Metric.LOGICAL&&(r=$[Y[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*$[Y[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*$[t.name][r.name]/i}static getUnitMetric(e){switch(e){case $.Unit.METER:case $.Unit.CENTIMETER:case $.Unit.MILLIMETER:case $.Unit.MICROMETER:case $.Unit.INCH:case $.Unit.DP:case $.Unit.PICA:case $.Unit.POINT:case $.Unit.DIP:case $.Unit.DPI:return $.Metric.LENGTH;case $.Unit.SECOND:case $.Unit.MILLISECOND:case $.Unit.MICROSECOND:case $.Unit.NANOSECOND:return $.Metric.TIME;case $.Unit.RADIAN:case $.Unit.DEGREE:return $.Metric.ANGLE;case $.Unit.NEWTON:return $.Metric.FORCE;case $.Unit.NORMALIZED:return $.Metric.NORMALIZED;case $.Unit.LOGICAL:return $.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case $.Metric.LENGTH:return[$.Unit.METER,$.Unit.CENTIMETER,$.Unit.MILLIMETER,$.Unit.MICROMETER,$.Unit.INCH,$.Unit.DP,$.Unit.PICA,$.Unit.POINT,$.Unit.DIP,$.Unit.DPI];case $.Metric.TIME:return[$.Unit.SECOND,$.Unit.MILLISECOND,$.Unit.MICROSECOND,$.Unit.NANOSECOND];case $.Metric.ANGLE:return[$.Unit.RADIAN,$.Unit.DEGREE];case $.Metric.FORCE:return[$.Unit.NEWTON];case $.Metric.NORMALIZED:return[$.Unit.NORMALIZED];case $.Metric.LOGICAL:return[$.Unit.LOGICAL];case $.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return Y[e.name]}static convertValue(e,t,r){return e*$[t.name][r.name]}}Object.defineEnum($,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum($,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const Y=Object.freeze({LENGTH:$.Unit.METER,TIME:$.Unit.SECOND,FORCE:$.Unit.NEWTON,ANGLE:$.Unit.RADIAN,NORMALIZED:$.Unit.NORMALIZED,LOGICAL:$.Unit.LOGICAL});!function(){let e=$.getMetricUnits($.Metric.LENGTH).filter((e=>!(e.name in G)));for(let t of e){let e=$.Units[t.name];for(let t in G)e[t]=e.INCH*G[t]}for(let t in G){let r={};for(let i of e)r[i.name]=$.Units.INCH[i.name]/G[t];for(let e in G)r[e]=G[e]/G[t];$.Units[t]=r}for(let e in $.Units)$[e]=$.Units[e]}(),Object.freeze($);class X extends y{constructor(e,t,r,i,s){if(super(),t==X.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=X.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=$.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==X.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return D.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(X.Type).find((t=>X.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case X.Type.X:case X.Type.Y:case X.Type.Z:case X.Type.RADIUS_X:case X.Type.RADIUS_Y:t.unit=$.Unit.DIP;break;case X.Type.TIMESTAMP:t.unit=$.Unit.MILLISECOND;break;case X.Type.PRESSURE:t.unit=$.Unit.NORMALIZED,t.min=0,t.max=1;break;case X.Type.ALTITUDE:t.unit=$.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case X.Type.AZIMUTH:t.unit=$.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case X.Type.ROTATION:t.unit=$.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=$.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new X(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=X.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=$.getChannelResolution(r.unit),s=new X(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=X.Type.X&&e!=X.Type.Y||t.type!=b.Type.MOUSE||(s.precision=0),s}}X.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),X.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},X.Metric=$.Metric;class z extends y{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==X.Type.X||e.type==X.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new z(e,t);return r.channels=X.defaults[t.type.name].map((e=>X.createDefaultInstance(X.Type[e],t))),r}}class V extends y{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new V;return r.addContext(z.createDefaultInstance(e,t)),r}}class H extends y{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=V.createDefaultInstance(t,r);return new H(e,i)}}class Z{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${Z.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class W extends y{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=Z.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=W.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(W,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class q{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=D.getPropName(t.name),i=e[r];if(t.type==X.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==X.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=D.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==X.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class K extends y{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",y.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof K))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new b(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return V.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=b.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new H(this.environment,r);r.inkChannelsContext.layout=K.getLayout(e),this.sensorData=new W(i),this.sensorData.add(new q(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(X.Type).forEach((r=>{let i,s=X.Type[r];i=s==X.Type.ALTITUDE?"tiltX":s==X.Type.AZIMUTH?"tiltY":D.getPropName(r),K.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===U)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await U.system(),r=await U.cpu(),i=await U.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await j.createInstance(e),t}}let J={};if(B.type==B.Type.WEB)J.Image=globalThis.Image,J.ImageData=globalThis.ImageData,J.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(J.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},J.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(J.OffscreenCanvas=globalThis.OffscreenCanvas,J.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)J.Image=globalThis.Image,J.ImageData=globalThis.ImageData,J.OffscreenCanvas=globalThis.OffscreenCanvas,J.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(B.commonJS){const{Canvas:e,CanvasRenderingContext2D:t,Image:r,ImageData:i}=require("canvas");J.Image=r,J.ImageData=i,J.OffscreenCanvas=e,J.OffscreenCanvasRenderingContext2D=t}else console.warn(`Current env - ${B.type.name}, do not provides OffscreenCanvas support`);function Q(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}J.CanvasRenderingContext2D&&(J.CanvasRenderingContext2D.prototype.clearCanvas=Q),J.OffscreenCanvasRenderingContext2D&&(J.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=Q);const{Image:ee,ImageData:te,OffscreenCanvas:re,CanvasRenderingContext2D:ie,OffscreenCanvasRenderingContext2D:se}=J;let ne;class oe{#r={};constructor(...e){if(ne)throw new Error("URIResolver instance already available");ne=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(oe,"instance",{get:()=>ne});class ae{static encode(e,t=ae.Encoding.AUTO){let r;if(t==ae.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?ae.Encoding.NONE:ae.Encoding.ARRAY:ae.Encoding.BUFFER:t==ae.Encoding.ARRAY&&e instanceof Array&&(t=ae.Encoding.NONE),t==ae.Encoding.NONE)r=e;else if(t==ae.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case ae.Encoding.BUFFER:r=i.toJSON();break;case ae.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=ae.Encoding[e.encoding];if(r==ae.Encoding.NONE)t=e.content;else if(r==ae.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case ae.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case ae.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(ae,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class le{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||D.isValidURL(e)||le.repetitionsCache.has(e)||(le.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!oe.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=oe.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=ae.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return ae.isTypedArrayData(t)&&(t=ae.decode(t)),new le(e.name,t)}static getInstance(e,t){return new le(t,e)}}class he{constructor(e){D.isValidURL(e)||(le.repetitionsCache.has(e)||(le.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class de{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=de.defaults.CIRCLE_PRECISION,t=de.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return de.createEllipse(e,t,t,r)}static createEllipse(e=de.defaults.ELLIPSE_PRECISION,t=de.defaults.ELLIPSE_RADIUS_X,r=de.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=de.defaults.STAR_POINTS,t=de.defaults.STAR_INTERNAL_RADIUS,r=de.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let ce=l?l.default||globalThis.poly2tri:{};const{SweepContext:pe,Point:ue}=ce;let fe=h?h.default||globalThis.ClipperLib:{};const{Clipper:me,Paths:ge,Path:ye,ClipType:be,PolyType:Ee,PolyFillType:Pe}=fe;class Ie{constructor(e,t,r){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:r,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative....[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/workers/InkPathProvider.mjs line 1
- Likely real
- Uncertain, 45% confidence
Possibility of prototype polluting function detected. By adding or modifying attributes of an object prototype, it is possible to create attributes that exist on every object, or replace critical attributes with malicious ones. This can be problematic if the software depends on existence or non-existence of certain attributes, or uses pre-defined attributes of object prototype (such as hasOwnProperty, toString or valueOf). Possible mitigations might be: freezing the object prototype, using an object without prototypes (via Object.create(null) ), blocking modifications of attributes that resolve to object prototype, using Map instead of object.
import"js-ext";import{vec2 as t,vec3 as e,vec4 as i,mat4 as s,quat2 as r,mat2d as n}from"gl-matrix";import a from"long";import*as o from"js-md5";import*as h from"poly2tri";import*as l from"clipper-lib";"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=i=>{let s="message"==t?i.data:i;e(s)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=i=>{let s="message"==t?i.data:i;e(s)}});class u{constructor(s,r,n,a){if(isNaN(s))throw new Error(`Invalid x found: ${s}`);if(isNaN(r))throw new Error(`Invalid y found: ${r}`);let o=[s,r];isFinite(n)&&(o.push(n),isFinite(a)&&o.push(a)),this.value=o.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:t=>{this.value[0]=t},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:t=>{this.value[1]=t},enumerable:!0}),2==o.length?this.vec=t:3==o.length?(this.vec=e,Object.defineProperty(this,"z",{get:()=>this.value[2],set:t=>{this.value[2]=t},enumerable:!0})):(this.vec=i,Object.defineProperty(this,"w",{get:()=>this.value[3],set:t=>{this.value[3]=t},enumerable:!0}))}add(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.add(e,this.value,t.value),u.fromPoint(e)}addSelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.add(this.value,this.value,t.value),this}subtract(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.subtract(e,this.value,t.value),u.fromPoint(e)}subtractSelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.subtract(this.value,this.value,t.value),this}multiply(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.multiply(e,this.value,t.value),u.fromPoint(e)}multiplySelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.multiply(this.value,this.value,t.value),this}divide(t){t instanceof u||(t=u.fromPoint(t));let e=this.vec.create();return this.vec.divide(e,this.value,t.value),u.fromPoint(e)}divideSelf(t){return t instanceof u||(t=u.fromPoint(t)),this.vec.divide(this.value,this.value,t.value),this}scale(t){let e=this.vec.create();return this.vec.scale(e,this.value,t),u.fromPoint(e)}scaleSelf(t){return this.vec.scale(this.value,this.value,t),this}abs(){return new u(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(t){if(!t)return this;let e=this.vec.create();return this.vec.transformMat4(e,this.value,t.toFloat32Array()),u.fromPoint(e)}transformSelf(t){return this.vec.transformMat4(this.value,this.value,t.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let t={x:this.x,y:this.y};return isFinite(this.z)&&(t.z=this.z,isFinite(this.w)&&(t.w=this.w)),t}toString(){return`point(${this.value.join(", ")})`}clone(){return u.fromPoint(this)}static fromPoint(t){return Array.isArray(t)||ArrayBuffer.isTypedArray(t)?new u(t[0],t[1],t[2],t[3]):new u(t.x,t.y,t.z,t.w)}}const c={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},p=c.m11,d=c.m12,f=c.m21,m=c.m22,g=c.m41,y=c.m42;class P{constructor(t=s.create(),e=P.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:t,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:e,enumerable:!0});let i=function(t,e){let i=c[t];this.value[i]=e};Object.defineProperty(this,"a",{get:()=>this.value[p],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[d],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[f],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[m],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[g],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[y],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[g],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[y],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:i.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:i.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:i.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:i.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:i.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:i.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:i.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:i.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:i.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:i.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new P(this.value.clone(),this.multiplicationType)}translate(t){return this.multiply(P.fromTranslate(t))}translateSelf(t){this.multiplySelf(P.fromTranslate(t))}rotate(t,e){return this.multiply(P.fromRotate(t,e))}rotateSelf(t,e){this.multiplySelf(P.fromRotate(t,e))}scale(t,e){return this.multiply(P.fromScale(t,e))}scaleSelf(t,e){this.multiplySelf(P.fromScale(t,e))}multiply(t){return this.multiplicationType==P.MultiplicationType.PRE?this.preMultiply(t):this.postMultiply(t)}preMultiply(t){let e=s.create();return s.multiply(e,t.toFloat32Array(),this.value),new P(e,this.multiplicationType)}postMultiply(t){let e=s.create();return s.multiply(e,this.value,t.toFloat32Array()),new P(e,this.multiplicationType)}multiplySelf(t){this.multiplicationType==P.MultiplicationType.PRE?this.preMultiplySelf(t):this.postMultiplySelf(t)}preMultiplySelf(t){s.multiply(this.value,t.toFloat32Array(),this.value)}postMultiplySelf(t){s.multiply(this.value,this.value,t.toFloat32Array())}invert(){let t=s.create();return s.invert(t,this.value),new P(t,this.multiplicationType)}invertSelf(){s.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(t){return u.fromPoint(t).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(t){if(t){let t=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${t(this.m11)}, ${t(this.m21)}, ${t(this.m31)}, ${t(this.m41)}`+`\n${t(this.m12)}, ${t(this.m22)}, ${t(this.m32)}, ${t(this.m42)}`+`\n${t(this.m13)}, ${t(this.m23)}, ${t(this.m33)}, ${t(this.m43)}`+`\n${t(this.m14)}, ${t(this.m24)}, ${t(this.m34)}, ${t(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(t,e){let i=s.create();if("none"!=t){let e=t.substring(0,t.indexOf("("));t=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g),"matrix3d"==e?(i[0]=parseFloat(t[0]),i[1]=parseFloat(t[1]),i[2]=parseFloat(t[2]),i[3]=parseFloat(t[3]),i[4]=parseFloat(t[4]),i[5]=parseFloat(t[5]),i[6]=parseFloat(t[6]),i[7]=parseFloat(t[7]),i[8]=parseFloat(t[8]),i[9]=parseFloat(t[9]),i[10]=parseFloat(t[10]),i[11]=parseFloat(t[11]),i[12]=parseFloat(t[12]),i[13]=parseFloat(t[13]),i[14]=parseFloat(t[14]),i[15]=parseFloat(t[15])):(i[p]=parseFloat(t[0]),i[d]=parseFloat(t[1]),i[f]=parseFloat(t[2]),i[m]=parseFloat(t[3]),i[g]=parseFloat(t[4]),i[y]=parseFloat(t[5]))}return new P(i,e)}static fromMatrix(t,e){if(!t)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof t)throw new Error("data type function is not allowed");if(t instanceof P)return t;if(Array.isArray(t)&&(t=new Float32Array(t)),t instanceof Float32Array)return new P(t,e);if("string"==typeof t)return P.fromString(t,e);let i=s.create(),r=Object.assign({},t);return isFinite(t.a)&&(r.m11=t.a),isFinite(t.b)&&(r.m12=t.b),isFinite(t.c)&&(r.m21=t.c),isFinite(t.d)&&(r.m22=t.d),isFinite(t.tx)?r.m41=t.tx:isFinite(t.e)?r.m41=t.e:isFinite(t.dx)&&(r.m41=t.dx),isFinite(t.ty)?r.m42=t.ty:isFinite(t.f)?r.m42=t.f:isFinite(t.dy)&&(r.m42=t.dy),isFinite(r.m11)&&(i[0]=r.m11),isFinite(r.m12)&&(i[1]=r.m12),isFinite(r.m13)&&(i[2]=r.m13),isFinite(r.m14)&&(i[3]=r.m14),isFinite(r.m21)&&(i[4]=r.m21),isFinite(r.m22)&&(i[5]=r.m22),isFinite(r.m23)&&(i[6]=r.m23),isFinite(r.m24)&&(i[7]=r.m24),isFinite(r.m31)&&(i[8]=r.m31),isFinite(r.m32)&&(i[9]=r.m32),isFinite(r.m33)&&(i[10]=r.m33),isFinite(r.m34)&&(i[11]=r.m34),isFinite(r.m41)&&(i[12]=r.m41),isFinite(r.m42)&&(i[13]=r.m42),isFinite(r.m43)&&(i[14]=r.m43),isFinite(r.m44)&&(i[15]=r.m44),new P(i,e||t.multiplicationType)}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return P.fromMatrix(e)}static fromRotate(t,e){let i=Math.sin(t),s=Math.cos(t),r={a:s,b:i,c:-i,d:s};return e&&(r.tx=e.x-e.x*s+e.y*i,r.ty=e.y-e.x*i-e.y*s),P.fromMatrix(r)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let i={a:t.x,d:t.y};return e&&(i.tx=e.x-e.x*t.x,i.ty=e.y-e.y*t.y),P.fromMatrix(i)}static fromPoints(t,e){if(!Array.isArray(t)||!Array.isArray(e))throw new Error("Expected input type Array requirement not satisfied");if(3!=t.length||3!=e.length)throw new Error("Expected input size 3 requirement not satisfied");let i=P.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=P.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),r=i.invert().preMultiply(s);return P.fromMatrix({a:r.m11,b:r.m12,c:r.m21,d:r.m22,tx:r.m31,ty:r.m32})}static multiply(t,e){let i=s.create();return s.multiply(i,t.value,e.value),new P(i)}}P.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});class b extends u{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(t,e,i,s={}){super(t,e,i),this.red=s.red,this.green=s.green,this.blue=s.blue,this.alpha=s.alpha,this.size=s.size||b.defaults.size,this.rotation=s.rotation||b.defaults.rotation,this.scaleX=s.scaleX||b.defaults.scaleX,this.scaleY=s.scaleY||b.defaults.scaleY,this.scaleZ=isFinite(i)?s.scaleZ||b.defaults.scaleZ:void 0,this.offsetX=s.offsetX||b.defaults.offsetX,this.offsetY=s.offsetY||b.defaults.offsetY,this.offsetZ=isFinite(i)?s.offsetZ||b.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(t,e,i,s=0){let r=new b(0,0,t.includes(b.Property.Z)?0:void 0);return i&&r.fill(s,i,t,e),r}fill(t,e,i,s={}){let r={},n=t*i.length;i.forEach(((t,i)=>b.setProperty(r,t,e[n+i]))),this.x=r.x,this.y=r.y,this.z=r.z,this.red=isFinite(r.red)?r.red:s.red,this.green=isFinite(r.green)?r.green:s.green,this.blue=isFinite(r.blue)?r.blue:s.blue,this.alpha=isFinite(r.alpha)?r.alpha:s.alpha,this.size=r.size||s.size||b.defaults.size,this.rotation=r.rotation||s.rotation||b.defaults.rotation,this.scaleX=r.scaleX||s.scaleX||b.defaults.scaleX,this.scaleY=r.scaleY||s.scaleY||b.defaults.scaleY,this.scaleZ=isFinite(r.z)?r.scaleZ||s.scaleZ||b.defaults.scaleZ:void 0,this.offsetX=r.offsetX||s.offsetX||b.defaults.offsetX,this.offsetY=r.offsetY||s.offsetY||b.defaults.offsetY,this.offsetZ=isFinite(r.z)?r.offsetZ||s.offsetZ||b.defaults.offsetZ:void 0,this.dX=r.dX,this.dY=r.dY}getProperty(t){switch(t){case b.Property.X:return this.x;case b.Property.Y:return this.y;case b.Property.Z:return this.z;case b.Property.RED:return this.red;case b.Property.GREEN:return this.green;case b.Property.BLUE:return this.blue;case b.Property.ALPHA:return this.alpha;case b.Property.SIZE:return this.size;case b.Property.ROTATION:return this.rotation;case b.Property.SCALE_X:return this.scaleX;case b.Property.SCALE_Y:return this.scaleY;case b.Property.SCALE_Z:return this.scaleZ;case b.Property.OFFSET_X:return this.offsetX;case b.Property.OFFSET_Y:return this.offsetY;case b.Property.OFFSET_Z:return this.offsetZ;case b.Property.D_X:return this.dX;case b.Property.D_Y:return this.dY;default:throw console.warn(t),new Error("Invalid property found")}}setProperty(t,e){b.setProperty(this,t,e)}static setProperty(t,e,i){switch(e){case b.Property.X:t.x=i;break;case b.Property.Y:t.y=i;break;case b.Property.Z:t.z=i;break;case b.Property.RED:t.red=i;break;case b.Property.GREEN:t.green=i;break;case b.Property.BLUE:t.blue=i;break;case b.Property.ALPHA:t.alpha=i;break;case b.Property.SIZE:t.size=i;break;case b.Property.ROTATION:t.rotation=i;break;case b.Property.SCALE_X:t.scaleX=i;break;case b.Property.SCALE_Y:t.scaleY=i;break;case b.Property.SCALE_Z:t.scaleZ=i;break;case b.Property.OFFSET_X:t.offsetX=i;break;case b.Property.OFFSET_Y:t.offsetY=i;break;case b.Property.OFFSET_Z:t.offsetZ=i;break;case b.Property.D_X:t.dX=i;break;case b.Property.D_Y:t.dY=i;break;default:throw console.warn(e),new Error("Invalid property found")}}transform(t){if(!(t instanceof P))throw new Error(`matrix is instance of ${t.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let e=t.scaleX,i=t.rotation;this.transformSelf(t),this.size*=e,this.rotation+=i}toArray(t){return t.map((t=>{let e=this.getProperty(t);if(null==e||isNaN(e))throw new Error(`Property ${t.name} has invalid value ${e}`);return e}))}toJSON(){let t={};return b.Property.values.forEach((e=>{let i=this.getProperty(e);null!=i&&isFinite(i)&&(t[e.name]=this.getProperty(e))})),t}}Object.defineEnum(b,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]);class E{constructor(t,e,i){Object.defineProperties(this,{path:{value:t,enumerable:!0},pointIndexStart:{value:e,enumerable:!0},pointIndexEnd:{value:i,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.path.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in path index is ${this.path.length-1}.`)}toPath(){return this.path.slice(this)}toString(){return`fragment(${this.pointIndexStart} - ${this.pointIndexEnd})`}}class S{constructor(t,e,i,s=1){if(this.red=t,this.green=e,this.blue=i,this.alpha=s,s<0||s>1)throw new Error(`Invalid alpha ${s} found. The value must be in the interval [0, 1].`);Object.defineProperty(this,"hex",{get:()=>`#${this.red.toString(16).pad(2,"0")}${this.green.toString(16).pad(2,"0")}${this.blue.toString(16).pad(2,"0")}${Math.round(255*this.alpha).toString(16).pad(2,"0")}`,enumerable:!0})}premultiply(){return{red:this.red/255*this.alpha,green:this.green/255*this.alpha,blue:this.blue/255*this.alpha,alpha:this.alpha}}static postdivide(t,e,i,s){let r=parseInt(255*t/s),n=parseInt(255*e/s),a=parseInt(255*i/s);return new S(r,n,a,s)}equals(t){return t&&this.red==t.red&&this.green==t.green&&this.blue==t.blue&&this.alpha==t.alpha}toRGB(){return 1==this.alpha?this:new S(this.red,this.green,this.blue)}toRGBA(t){return new S(this.red,this.green,this.blue,t)}toHSLA(){let t=this.red/255,e=this.green/255,i=this.blue/255,s=Math.min(t,e,i),r=Math.max(t,e,i),n=0,a=0,o=(r+s)/2;if(r!=s){let h=r-s;switch(a=h/(1-Math.abs(2*o-1)),r){case t:n=(e-i)/h%6;break;case e:n=(i-t)/h+2;break;case i:n=(t-e)/h+4}}return n*=60,n<0&&(n+=360),{hue:parseFloat(n.toFixed(0)),saturation:parseFloat((100*a).toFixed(2)),lightness:parseFloat((100*o).toFixed(2)),alpha:this.alpha}}toArray(){return[this.red,this.green,this.blue,this.alpha]}toJSON(){return{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}}toString(){return 1==this.alpha?`rgb(${this.red}, ${this.green}, ${this.blue})`:`rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`}static isColor(t){return t&&isFinite(t.red)&&isFinite(t.green)&&isFinite(t.blue)}static fromColor(t){let e,i,s,r;if("string"==typeof t)if(t.startsWith("rgb"))t=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g),e=parseInt(t[0]),i=parseInt(t[1]),s=parseInt(t[2]),r=t[3]?parseInt(t[3]):1;else{if(!t.startsWith("#"))throw new Error(`Unknown input found: ${t}. Expected data starts with rgba, rgb or #.`);t=t.substring(1),e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16),r=8==t.length?parseInt(t.substring(6,8),16)/255:1}else Array.isArray(t)?(e=t[0],i=t[1],s=t[2],r=t[3]):(e=t.red,i=t.green,s=t.blue,r=t.alpha);return new S(e,i,s,r)}static fromHSLA(t=0,e=0,i=0,s){t/=60,e/=100,i/=100;let r=(1-Math.abs(2*i-1))*e,n=r*(1-Math.abs(t%2-1)),a=0,o=0,h=0;t>=0&&t<1?(a=r,o=n):t>=1&&t<2?(a=n,o=r):t>=2&&t<3?(o=r,h=n):t>=3&&t<4?(o=n,h=r):t>=4&&t<5?(a=n,h=r):(a=r,h=n);let l=i-r/2;return a+=l,o+=l,h+=l,new S(Math.round(255*a),Math.round(255*o),Math.round(255*h),s)}static random(t=!1){return new S(Math.randomInt(0,255),Math.randomInt(0,255),Math.randomInt(0,255),t?Math.random():1)}}S.TRANSPERENT=new S(0,0,0,0),S.BLACK=new S(0,0,0,1),S.WHITE=new S(255,255,255,1),S.RED=new S(255,0,0,1),S.GREEN=new S(0,255,0,1),S.BLUE=new S(0,0,255,1);let w={longToByteArray(t){let e=[0,0,0,0,0,0,0,0];for(let i=0;i<e.length;i++){let s=255&t;e[i]=s,t=(t-s)/256}return e},byteArrayToLong(t){let e=0;for(let i=t.length-1;i>=0;i--)e=256*e+t[i];return e},crc32:function(){let t=new Uint32Array(256);for(let e=256;e--;){let i=e;for(let t=8;t--;)i=1&i?3988292384^i>>>1:i>>>1;t[e]=i}return function(e){let i=-1;for(let s=0,r=e.length;s<r;s++)i=i>>>8^t[255&i^e[s]];return(-1^i)>>>0}}(),encodeBitMask(t=[]){if(0==t.length)return 0;let e="",i=Math.max(...t);for(let s=1;s<=i;s++)e+=t.includes(s)?"1":"0";return parseInt(e.split("").reverse().join(""),2)},decodeBitMask(t){let e=[],i=t.toString(2).split("").reverse();for(let t=0;t<i.length;t++)1==i[t]&&e.push(t+1);return e},mapTo:(t,e,i)=>i.min+(w.clamp(t,e)-e.min)/(e.max-e.min)*(i.max-i.min),clamp:(t,e)=>Math.min(Math.max(t,e.min),e.max),debounce(t,e){let i=null;return function(){let s=this,r=arguments;clearTimeout(i),i=setTimeout((function(){t.apply(s,r)}),e)}},comparator(){let t=Array.prototype.slice.call(arguments),e=function(t,e,i){return e.replace("[",".").replace("]","").split(".").forEach((e=>t=t[e])),i?t.toLowerCase():t};return function(i,s){return t.map((t=>function(t,e,i){let s="asc"===i?1:-1;return t>e?1*s:t<e?-1*s:0}(e(i,t.sortBy,t.ignoreCase),e(s,t.sortBy,t.ignoreCase),t.sortOrder))).reduceRight((function(t,e){return e||t}))}},isValidURL(t){if("string"!=typeof t)return!1;try{return new URL(t),!0}catch(t){return!1}},getPropName(t,e){let i=t.split("_"),s=i.first.toLowerCase();e&&(s=s.substring(0,1).toUpperCase()+s.substring(1));for(let t=1;t<i.length;t++)s+=i[t].substring(0,1),s+=i[t].substring(1).toLowerCase();return s},getEnumValueName(t){let e="";for(let i=0;i<t.length;i++)i>0&&t[i]!=t[i].toLowerCase()&&(e+="_"),e+=t[i];return e.toUpperCase()}};class I{constructor(t,e,i={}){this.layout=t,this.pointProps=e,this.sheet={};let s={};Object.defineProperties(s,{size:{get:this.getComputed.bind(this,"size"),set:this.setStyle.bind(this,"size"),enumerable:!0},red:{get:this.getComputed.bind(this,"red"),set:this.setStyle.bind(this,"red"),enumerable:!0},green:{get:this.getComputed.bind(this,"green"),set:this.setStyle.bind(this,"green"),enumerable:!0},blue:{get:this.getComputed.bind(this,"blue"),set:this.setStyle.bind(this,"blue"),enumerable:!0},alpha:{get:this.getComputed.bind(this,"alpha"),set:this.setStyle.bind(this,"alpha"),enumerable:!0},rotation:{get:this.getComputed.bind(this,"rotation"),set:this.setStyle.bind(this,"rotation"),enumerable:!0},scaleX:{get:this.getComputed.bind(this,"scaleX"),set:this.setStyle.bind(this,"scaleX"),enumerable:!0},scaleY:{get:this.getComputed.bind(this,"scaleY"),set:this.setStyle.bind(this,"scaleY"),enumerable:!0},scaleZ:{get:this.getComputed.bind(this,"scaleZ"),set:this.setStyle.bind(this,"scaleZ"),enumerable:!0},offsetX:{get:this.getComputed.bind(this,"offsetX"),set:this.setStyle.bind(this,"offsetX"),enumerable:!0},offsetY:{get:this.getComputed.bind(this,"offsetY"),set:this.setStyle.bind(this,"offsetY"),enumerable:!0},offsetZ:{get:this.getComputed.bind(this,"offsetZ"),set:this.setStyle.bind(this,"offsetZ"),enumerable:!0},color:{get:this.getComputed.bind(this,"color"),set:this.setStyle.bind(this,"color"),enumerable:!0},blendMode:{get:this.getComputed.bind(this,"blendMode"),set:this.setStyle.bind(this,"blendMode"),enumerable:!0},visibility:{get:this.getComputed.bind(this,"visibility"),set:this.setStyle.bind(this,"visibility"),enumerable:!0},reset:{value:t=>{t&&(i=t),this.clear(),Object.keys(i).forEach((t=>this.setStyle(t,i[t])))}},clear:{value:this.clear.bind(this)}}),this.style=Object.freeze(s),this.style.reset(i)}setStyle(t,e){if(null==e&&(e=void 0),I.validate(this.layout,t,e),"color"==t&&e)return this.sheet.red=e.red,this.sheet.green=e.green,this.sheet.blue=e.blue,void(this.sheet.alpha=e.alpha);null==e?delete this.sheet[t]:this.sheet[t]=e}getStyle(t){let e=this.sheet[t];return"visibility"==t?"boolean"!=typeof e&&(e=!0):"color"==t&&S.isColor(this.sheet)&&(e=S.fromColor(this.sheet)),e}getComputed(t){let e=this.getStyle(t);if(null==e)if("color"==t){let t={red:isFinite(this.sheet.red)?this.sheet.red:this.pointProps.red,green:isFinite(this.sheet.green)?this.sheet.green:this.pointProps.green,blue:isFinite(this.sheet.blue)?this.sheet.blue:this.pointProps.blue,alpha:isFinite(this.sheet.alpha)?this.sheet.alpha:this.pointProps.alpha};S.isColor(t)&&(e=S.fromColor(t))}else e=this.pointProps[t];return e}clear(){this.sheet={}}static validate(t,e,i,s){let r;if(i&&t.includes(b.Property[w.getEnumValueName(e)])){if(!s)throw new Error(`Property ${e} value ${i} is not applicable. This is a dynamic property and is part of the layout.`);console.warn(`Property ${e} value ${i} is not applicable. This is a dynamic property and is part of the layout.`),i=void 0}if("color"==e)!i||i instanceof S||(r=`Property ${e} is not an instance of Color`);else if("blendMode"==e)""==i&&(i=void 0);else if("number"==typeof i)if("size"==e)i<0?r=`Property ${e} with value ${i} is not allowed. Value should be a positive number.`:0==i&&(i=void 0);else if("red"==e||"green"==e||"blue"==e||"alpha"==e){let t="alpha"==e?{min:0,max:1}:{min:0,max:255};i>=t.min&&i<=t.max||(r=`Property ${e} with value ${i} is out of range. Allowd range: [${t.min}, ${t.max}].`)}else"rotation"==e?0==i&&(i=void 0):"scattering"==e&&i<0&&(i=void 0);if(r)throw new Error(r);return i}}class v{static encode(t,e=v.Encoding.AUTO){let i;if(e==v.Encoding.AUTO?e="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer?v.Encoding.NONE:v.Encoding.ARRAY:v.Encoding.BUFFER:e==v.Encoding.ARRAY&&t instanceof Array&&(e=v.Encoding.NONE),e==v.Encoding.NONE)i=t;else if(e==v.Encoding.ARRAY)i=t.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let s=Buffer.from(t.buffer);switch(e){case v.Encoding.BUFFER:i=s.toJSON();break;case v.Encoding.BASE64:i=s.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${e.name}`)}}return{encoding:e.name,type:t.constructor.name,content:i}}static decode(t){let e,i=v.Encoding[t.encoding];if(i==v.Encoding.NONE)e=t.content;else if(i==v.Encoding.ARRAY)e=t.content.toFloat32Array();else{let s;switch(i){case v.Encoding.BUFFER:s="undefined"==typeof Buffer?t.content.data:Buffer.from(t.content);break;case v.Encoding.BASE64:s="undefined"==typeof Buffer?atob(t.content).toCharArray():Buffer.from(t.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${i.name}`)}let r=new Uint8Array(s);e=new globalThis[t.type](r.buffer)}return e}static isTypedArrayData(t){return t&&t.encoding&&t.type&&t.type.endsWith("Array")}}Object.defineEnum(v,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);const O=[b.Property.X,b.Property.Y];class x{#t;#e;constructor(t,e={},i=O){if(this.#t=t,Object.defineProperty(this,"points",{get:()=>this.#t,set:t=>{if(this.#t instanceof Float32Array)throw new Error("Points setter is not accessible wehn points type is Float32Array.");this.#t=t,this.validate()},enumerable:!0}),Object.defineProperty(this,"buffer",{get:()=>this.#t.buffer,set:t=>{if(Array.isArray(this.#t))throw new Error("Underlying points buffer is Array. This property is applicable for TypedArray only.");if("undefined"!=typeof SharedArrayBuffer&&this.#t.buffer instanceof SharedArrayBuffer)throw new Error("Underlying buffer is SharedArrayBuffer and cannot be restored");if(this.#t.buffer.byteLength>0)throw new Error("Cannot restore buffer when underlying buffer is not empty");if(t.byteLength/Float32Array.BYTES_PER_ELEMENT/this.stride!=this.length)throw new Error("Value exceeds expected memory length");this.#t=new Float32Array(t)}}),!Object.isSealed(e))for(let t in e)void 0!==e[t]&&(e[t]=I.validate(i,t,e[t],!0));i.includes(b.Property.ROTATION)||"rotation"in e||(e.rotation=void 0),i.includes(b.Property.SIZE)||e.size||(e.size=1),Object.defineProperties(this,{stride:{value:i.length,enumerable:!0},layout:{value:Object.freeze(i),enumerable:!0},pointProps:{value:Object.seal(e),enumerable:!0}}),t instanceof Float32Array?Object.defineProperty(this,"length",{value:this.#t.length/this.stride,enumerable:!0}):Object.defineProperty(this,"length",{get:()=>this.#t.length/this.stride,enumerable:!0}),i.forEach(((t,e)=>{let i=w.getPropName(t.name,!0);Object.defineProperty(this,`setPoint${i}`,{value:this.setPointPropertyValue.bind(this,e)}),Object.defineProperty(this,`getPoint${i}`,{value:this.getPointPropertyValue.bind(this,e)})}))}validate(){if(this.points.length%this.stride!=0)throw new Error("Path length doesn't match the stride provided via the layout")}setPointPropertyValue(t,e,i){if(isNaN(e))throw new Error("Point index is required");if(e>=this.length||e<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);if(isNaN(i))throw new Error("value is required");this.points[e*this.layout.length+t]=i}getPointPropertyValue(t,e){if(isNaN(e))throw new Error("Point index is required");if(e>=this.length||e<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);return this.points[e*this.layout.length+t]}setPoint(t,e){let i=t*this.stride;this.layout.forEach(((t,s)=>this.points[i+s]=e.getProperty(t)))}getPoint(t,e=this.pointProps){if(t>=this.length||t<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);return b.createInstance(this.layout,e,this.points,t)}getPointRef(t,e=this.pointProps){if(t>=this.length||t<0)throw new Error(`Index ${t} out of range - (0, ${this.length-1})`);return this.#e||(this.#e=b.createInstance(this.layout)),this.#e.fill(t,this.points,this.layout,this.pointProps),this.#e}getChannelData(t){let e=new([b.Property.RED,b.Property.GREEN,b.Property.BLUE].includes(t)?Uint8Array:Float32Array)(this.length),i=this.layout.indexOf(t);if(-1==i)throw new Error(`Property ${t.name} is not part from the spline layout ${this.layout.map((t=>t.name)).join(", ")}`);for(let t=0;t<this.length;t++)e[t]=this.points[t*this.stride+i];return e}transform(t){let e=t.scaleX,s=t.rotation;for(let r=0;r<this.length;r++){let n=r*this.stride,a=i.fromValues(this.getPointX(r),this.getPointY(r),0,1);i.transformMat4(a,a,t.value);for(let t=0;t<this.stride;t++){let i=n+t;switch(this.layout[t]){case b.Property.X:this.points[i]=a[0]/a[3];break;case b.Property.Y:this.points[i]=a[1]/a[3];break;case b.Property.Z:this.points[i]=a[2]/a[3];break;case b.Property.ROTATION:this.points[i]+=s;break;case b.Property.SIZE:this.points[i]*=e}}}this.layout.includes(b.Property.ROTATION)||(this.pointProps.rotation=0==s?void 0:s)}clone(){return new x(this.#t.clone(),Object.clone(this.pointProps),this.layout.slice())}getFragment(t=0,e=this.length-1){return new E(this,t,e)}slice(t){let e=this.slicePoints(t.pointIndexStart,t.pointIndexEnd);return new x(e,Object.clone(this.pointProps),this.layout.slice())}validateFragment(t,e){if(t<0)throw new Error(`Invalid fragment pointIndexStart ${t} found. The value must be non-negative.`);if(e>this.length-1)throw new Error(`Invalid fragment pointIndexEnd ${e} found. Last point in path index is ${this.length-1}.`)}slicePoints(t,e){let i;if(this.validateFragment(t,e),"undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let s=this.points.subarray(t*this.stride,(e+1)*this.stride),r=new SharedArrayBuffer(s.length*Float32Array.BYTES_PER_ELEMENT);i=new Float32Array(r),i.set(s)}else i=this.points.slice(t*this.stride,(e+1)*this.stride);return i}toSVGPath(){let t=[];for(let e=0;e<this.length;e++)t.push(`${this.getPointX(e)},${this.getPointY(e)}`);return`M ${t.join(" L ")} Z`}toJSON(){return{type:"Path",points:v.encode(this.#t,this.encoding),pointProps:this.pointProps,layout:this.layout.map((t=>t.name))}}static fromJSON(t){if("Path"!=t.type)throw new Error(`Path deserialization failed. JSON type is ${t.type}, expected Path.`);return new x(v.decode(t.points),t.pointProps,t.layout.map((t=>b.Property[t])))}static fromRect(t,e){let i=[t.left,t.top,t.right,t.top,t.right,t.bottom,t.left,t.bottom,t.left,t.top];return new x(i,e)}static createInstance(t,e,i){return new x(t,e,i)}static createSharedInstance(t,e,i){return new x(Float32Array.createSharedInstance(t),e,i)}}class A{constructor(t,e){t>0&&0==e?(this.segmentIndex=t-1,this.t=1):(this.segmentIndex=t,this.t=e),Object.defineProperty(this,"index",{get:()=>(console.warn("SplineParameter index => segmentIndex"),this.segmentIndex)})}equals(t){return this.segmentIndex==t.segmentIndex&&this.t==t.t}toString(){return`spline-parameter(${this.segmentIndex}, ${this.t})`}toJSON(){return{segmentIndex:this.segmentIndex,t:this.t}}static fromJSON(t){return new A(t.segmentIndex,t.t)}static calcMiddleOfSegment(t,e){let i=.5*(t.t+e.t+(e.segmentIndex-t.segmentIndex)),s=Math.trunc(i),r=i-s;return new A(t.segmentIndex+s,r)}static areDistantEnough(t,e,i=.01){return e.t+(e.segmentIndex-t.segmentIndex)-t.t>i}}let R=o?o.default||globalThis.md5:{},T={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let t=Date.now();return this.mask.replace(/[xy]/g,(function(e){let i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:3&i|8).toString(16)}))},validate:t=>"string"==typeof t&&!!t.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(t){let e=[],i=0;return this.mask.split("-").forEach((s=>{e.push(t.substring(i,i+s.length)),i+=s.length})),e.join("-")},fromString(t){return this.fromBytes(new Uint8Array(R.arrayBuffer(t)))},toBytes(t){let e=[];return t.split("-").map(((t,i)=>{(i<3?t.match(/.{1,2}/g).reverse():t.match(/.{1,2}/g)).map((t=>e.push(parseInt(t,16))))})),new Uint8Array(e)},fromBytes(t){let e=Array.from(t).map((t=>t.toString(16))).map((t=>(1==t.length?"0":"")+t));return e.slice(0,4).reverse().join("")+"-"+e.slice(4,6).reverse().join("")+"-"+e.slice(6,8).reverse().join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10).join("")},toUint32Array(t){let e=new Uint32Array(4),i=this.toBytes(t);return e[0]=new Uint32Array(i.slice(0,4).buffer)[0],e[1]=new Uint32Array(i.slice(4,8).buffer)[0],e[2]=new Uint32Array(i.slice(8,12).buffer)[0],e[3]=new Uint32Array(i.slice(12).buffer)[0],e},fromUint32Array(t){return this.fromBytes(new Uint8Array(t.buffer))},toUint64Array(t){let e=new BigUint64Array(2),i=this.toBytes(t);return e[0]=new BigUint64Array(i.slice(0,8).buffer)[0],e[1]=new BigUint64Array(i.slice(8).buffer)[0],e},fromUint64Array(t){return this.fromBytes(new Uint8Array(t.buffer))},toLongArray(t){let e=new Array(2),i=this.toBytes(t);return e[0]=a.fromBytes(i.slice(0,8)),e[1]=a.fromBytes(i.slice(8)),e},fromLongArray(t){let e=t[0].toBytes().concat(t[1].toBytes());return this.fromBytes(e)}};class N{#i;constructor(t,e,i,s,r){1==i&&(e++,i=0),0==r&&(s--,r=1),Object.defineProperties(this,{spline:{value:t,enumerable:!0},segmentIndexStart:{value:e,enumerable:!0},segmentIndexEnd:{value:s,enumerable:!0},ts:{value:i,enumerable:!0},tf:{value:r,enumerable:!0}}),Object.defineProperty(this,"pointIndexStart",{value:e,enumerable:!0}),Object.defineProperty(this,"pointIndexEnd",{value:s+3,enumerable:!0}),Object.defineProperty(this,"length",{value:this.pointIndexEnd-this.pointIndexStart+1,enumerable:!0}),Object.defineProperty(this,"id",{get:()=>(this.#i||(this.#i=T.generate()),this.#i),set:t=>{if(this.#i)throw new Error("id is immutable");this.#i=t}}),this.validate()}validate(){let t=this.length-3;if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.spline.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in spline index is ${this.spline.length-1}.`);if(this.ts<0||this.ts>=1)throw new Error(`Invalid fragment ts ${this.ts} found. The value must be in the interval [0, 1).`);if(this.tf<=0||this.tf>1)throw new Error(`Invalid fragment tf ${this.tf} found. The value must be in the interval (0, 1].`);if(t<1)throw new Error(`Invalid fragment points range {${this.pointIndexStart}, ${this.pointIndexEnd}} found. At least 4 points are needed to define spline.`);if(1==t&&this.ts>this.tf)throw new Error(`Invalid fragment T range ${this.ts} - ${this.tf} found. Spline has only one segment and ts <= tf.`)}union(t){let e=[this,t];e.sort(N.compare);let i=e.first,s=e.last,r=i.segmentIndexEnd,n=i.tf;if(1==n&&(r++,n=0),r!=s.segmentIndexStart||n!=s.ts)throw new Error(`Fragments ${i} and ${s} are not adjacent.`);let a=new N(this.spline,i.segmentIndexStart,i.ts,s.segmentIndexEnd,s.tf);return a.#i=this.#i,this.inside&&(a.inside=this.inside),a}overlaps(t){if(t.spline!=this.spline)return!1;let e=t.segmentIndexStart<this.segmentIndexEnd||t.segmentIndexStart==this.segmentIndexEnd&&t.ts<=this.tf,i=t.segmentIndexEnd>this.segmentIndexStart||t.segmentIndexEnd==this.segmentIndexStart&&t.tf>=this.ts;return e&&i}toString(){return`fragment(${this.segmentIndexStart}, ${this.ts} - ${this.segmentIndexEnd}, ${this.tf})`}static compare(t,e){return t.segmentIndexStart<e.segmentIndexStart?-1:t.segmentIndexStart>e.segmentIndexStart?1:t.ts<e.ts?-1:t.ts>e.ts?1:0}static getInstance(t,e,i){return new N(t,e.segmentIndex,e.t,i.segmentIndex,i.t)}}class C{constructor(t,e,i,s){let r=t,n=e,a=t+i,o=e+s;Object.defineProperties(this,{left:{value:r,enumerable:!0},x:{value:t,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:e,enumerable:!0},right:{value:a,enumerable:!0},top:{value:o,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0}})}union(t){if(t&&!(t instanceof C))throw new TypeError("rect must be instance of RectGL");return t?C.ofEdges(Math.min(this.left,t.left),Math.min(this.bottom,t.bottom),Math.max(this.right,t.right),Math.max(this.top,t.top)):this}intersect(t){if(t&&!(t instanceof C))throw new TypeError("rect must be instance of RectGL");if(!t)return null;let e=C.ofEdges(Math.max(this.left,t.left),Math.max(this.bottom,t.bottom),Math.min(this.right,t.right),Math.min(this.top,t.top));return e.width>0&&e.height>0?e:null}ceil(){return C.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return C.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(t){if(!t)return this;let e=u.fromPoint({x:this.left,y:this.bottom}).transform(t),i=u.fromPoint({x:this.right,y:this.bottom}).transform(t),s=u.fromPoint({x:this.left,y:this.top}).transform(t),r=u.fromPoint({x:this.right,y:this.top}).transform(t),n=Math.min(s.x,r.x,e.x,i.x),a=Math.min(s.y,r.y,e.y,i.y),o=Math.max(s.x,r.x,e.x,i.x),h=Math.max(s.y,r.y,e.y,i.y);return C.ofEdges(n,a,o,h)}toQuad(t){let e;if(t){let i=u.fromPoint({x:this.left,y:this.bottom}).transform(t),s=u.fromPoint({x:this.right,y:this.bottom}).transform(t),n=u.fromPoint({x:this.left,y:this.top}).transform(t),a=u.fromPoint({x:this.right,y:this.top}).transform(t);e=r.fromValues(i.x,i.y,s.x,s.y,n.x,n.y,a.x,a.y)}else e=r.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return e}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,i,s){return new C(t,e,i-t,s-e)}static calculateBrushGLSegmentBounds(t,e=0,i){let s,r=.5*t.size,n=Math.abs(e*r);if(i){s=new u(t.x,t.y,t.x,t.z).transform(i)}else s=t;let a=s.x,o=s.y,h=t.scaleX*r,l=t.scaleY*r,c=t.offsetX,p=-t.offsetY,d=Math.cos(t.rotation),f=Math.sin(t.rotation),m=Number.MAX_SAFE_INTEGER,g=Number.MIN_SAFE_INTEGER,y=Number.MAX_SAFE_INTEGER,P=Number.MIN_SAFE_INTEGER;for(let t of C.SQURE){let e=t.x*h+c,i=t.y*l+p,s=d*e+f*i+a,r=-f*e+d*i+o,u=s-n;m=Math.min(m,u),g=Math.max(g,u),u=s+n,m=Math.min(m,u),g=Math.max(g,u);let b=r-n;y=Math.min(y,b),P=Math.max(P,b),b=r+n,y=Math.min(y,b),P=Math.max(P,b)}return C.ofEdges(m,y,g,P)}}Object.defineProperty(C,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class D{constructor(t,e,i,s){let r,n,a,o=t,h=e,l=t+i,u=e+s;Object.defineProperties(this,{left:{value:o,enumerable:!0},top:{value:h,enumerable:!0},right:{value:l,enumerable:!0},bottom:{value:u,enumerable:!0},x:{value:t,enumerable:!0},y:{value:e,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0},size:{get:()=>(r||(r={width:i,height:s}),r),enumerable:!0},area:{get:()=>(n||(n=i*s),n),enumerable:!0},center:{get:()=>(a||(a={x:(o+l)/2,y:(h+u)/2}),a),enumerable:!0}})}union(t){return t?D.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return null;let e=D.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:null}intersects(t){return this.left<=t.right&&this.right>=t.left&&this.top<=t.bottom&&this.bottom>=t.top}ceil(t){let e=Math.floor(this.left),i=Math.floor(this.top),s=Math.ceil(this.right),r=Math.ceil(this.bottom);if(t){let t=s-e,n=r-i;t+=t%2,n+=n%2,s=e+t,r=i+n}return D.ofEdges(e,i,s,r)}floor(t){let e=Math.ceil(this.left),i=Math.ceil(this.top),s=Math.floor(this.right),r=Math.floor(this.bottom);if(t){let t=s-e,n=r-i;t-=t%2,n-=n%2,s=e+t,r=i+n}return D.ofEdges(e,i,s,r)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}includes(t){return this.left<=t.left&&this.right>=t.right&&this.top<=t.top&&this.bottom>=t.bottom}transform(t){if(!t)return this;let e=u.fromPoint({x:this.left,y:this.top}).transform(t),i=u.fromPoint({x:this.right,y:this.top}).transform(t),s=u.fromPoint({x:this.left,y:this.bottom}).transform(t),r=u.fromPoint({x:this.right,y:this.bottom}).transform(t),n=Math.min(e.x,i.x,s.x,r.x),a=Math.min(e.y,i.y,s.y,r.y),o=Math.max(e.x,i.x,s.x,r.x),h=Math.max(e.y,i.y,s.y,r.y);return D.ofEdges(n,a,o,h)}toPath(t,e=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new C(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(t){if(!t)return null;if(!(t instanceof C))throw new TypeError("rect must be instance of RectGL");return new D(t.left,t.bottom,t.width,t.height)}static isRect(t){return t&&isFinite(t.left)&&isFinite(t.top)&&isFinite(t.width)&&isFinite(t.height)}static fromString(t){return t=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g),new D(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]))}static fromRect(t){return"string"==typeof t?D.fromString(t):new D(t.x,t.y,t.width,t.height)}static ofPolygon(t){if(t.shape&&(t=t.shape),0==t.length)return null;let e=Number.MAX_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let n=0;n<t.length;n++){let a=t.getPointX(n),o=t.getPointY(n);e=Math.min(e,a),i=Math.min(i,o),s=Math.max(s,a),r=Math.max(r,o)}return D.ofEdges(e,i,s,r)}static ofSpline(t,e=0){let i;for(let s=0;s<t.length;s++)i=C.calculateBrushGLSegmentBounds(t.getPointRef(s),e).union(i);return D.fromGLRect(i)}static ofEdges(t,e,i,s){let r=Math.min(t,i),n=Math.min(e,s),a=Math.max(t,i),o=Math.max(e,s);return new D(r,n,a-r,o-n)}static union(t,e){return t?e?t.union(e):t:e}static intersect(t,e){return t&&e?t.intersect(e):null}}class M extends x{constructor(t,e,i,s=0,r=1){super(e,i,t),this.points instanceof Float32Array?Object.defineProperty(this,"segmentsCount",{value:this.length-3,configurable:!0}):Object.defineProperty(this,"segmentsCount",{get:()=>this.length-3,configurable:!0}),this.ts=s,this.tf=r,Object.defineProperty(this,"bounds",{get:()=>D.ofSpline(this,this.pointProps.scattering).ceil(),enumerable:!0}),Object.defineProperty(this,"color",{get:()=>S.isColor(this.pointProps)?S.fromColor(this.pointProps):void 0,set:t=>{if(!t)throw new Error("Spline color cannot be removed");if(!(t instanceof S))throw new Error("Expected value should be Color instance");"red"in this.pointProps&&(this.pointProps.red=t.red),"green"in this.pointProps&&(this.pointProps.green=t.green),"blue"in this.pointProps&&(this.pointProps.blue=t.blue),"alpha"in this.pointProps&&(this.pointProps.alpha=t.alpha)},enumerable:!0}),this.validate()}validate(){let t=this.points instanceof Float32Array;if(super.validate(),!this.layout.includes(b.Property.X))throw new Error("Layout doesn't contains required properties X");if(!this.layout.includes(b.Property.Y))throw new Error("Layout doesn't contains required properties Y");if(t&&0==this.points.length)throw new Error("Empty spline is not allowed");if(this.ts<0||this.ts>=1)throw new Error(`Invalid spline ts ${this.ts} found. The value must be in the interval [0, 1).`);if(this.tf<=0||this.tf>1)throw new Error(`Invalid spline tf ${this.tf} found. The value must be in the interval (0, 1].`);if(1==this.segmentsCount&&this.ts>this.tf)throw new Error(`Invalid spline t range ${this.ts} - ${this.tf} found. Spline has only one segment and ts <= tf.`);if(t&&this.segmentsCount<1)throw new Error("Incompleted spline found. Spline is defined with at least 4 control points.")}clone(){return new M(this.layout.slice(),this.points.clone(),Object.clone(this.pointProps),this.ts,this.tf)}slice(t){let e=this.slicePoints(t.pointIndexStart,t.pointIndexEnd),i=new M(this.layout.slice(),e,Object.clone(this.pointProps),t.ts,t.tf);return i.id=t.id,i}getSegment(t){let e=t,i=t+3,s=0==e?this.ts:0,r=i+1==this.length?this.tf:1;return this.slice({pointIndexStart:e,pointIndexEnd:i,ts:s,tf:r})}getFragment(t=0,e=this.ts,i=this.segmentsCount-1,s=this.tf,r=!1){return new N(this,t,e,r?i-3:i,s)}toPlainPath(){let t=new x([]);for(let e=0;e<this.length;e++)t.points.push(this.getPointX(),this.getPointY());return t}toJSON(){return{type:"Spline",id:this.id,layout:this.layout.map((t=>t.name)),points:v.encode(this.points,this.encoding),pointProps:this.pointProps,ts:this.ts,tf:this.tf}}static fromJSON(t){let e=v.decode(t.points),i=new M(t.layout.map((t=>b.Property[t])),e,t.pointProps,t.ts,t.tf);return i.id=t.id,i}static fromRect(t,e){let i=[t.left,t.top,t.left,t.top,t.right,t.top,t.right,t.bottom,t.left,t.bottom,t.left,t.top,t.left,t.top];return new M(void 0,i,e)}static createInstance(t,e,i=[],s,r){return new M(t,i,e,s,r)}static createSharedInstance(t,e,i,s,r){return new M(t,Float32Array.createSharedInstance(e),i,s,r)}}class L extends x{constructor(t,e,i,s=[]){super(e,i,t),s.length>0&&!Object.isFrozen(s.first)&&s.forEach((t=>Object.freeze(t))),Object.defineProperty(this,"splineParameters",{value:Object.freeze(s),enumerable:!0});let r=new I(t,i);Object.defineProperty(this,"style",{get:()=>r.style,set:t=>r.style.reset(t),enumerable:!0}),Object.defineProperty(this,"color",{get:()=>this.style.color,set:t=>{if(!t)throw new Error("Spline color cannot be removed");if(!(t instanceof S))throw new Error("Expected value should be Color instance");"red"in this.pointProps&&(this.pointProps.red=t.red),"green"in this.pointProps&&(this.pointProps.green=t.green),"blue"in this.pointProps&&(this.pointProps.blue=t.blue),"alpha"in this.pointProps&&(this.pointProps.alpha=t.alpha)},enumerable:!0}),Object.defineProperty(this,"bounds",{get:()=>D.ofSpline(this,this.pointProps.scattering).ceil(),enumerable:!0}),this.validate()}validate(){let t=this.points instanceof Float32Array;if(super.validate(),!this.layout.includes(b.Property.X))throw new Error("Layout doesn't contains required properties X");if(!this.layout.includes(b.Property.Y))throw new Error("Layout doesn't contains required properties Y");if(t&&0==this.points.length)throw new Error("Empty spline is not allowed")}clone(){return new L(this.layout.slice(),this.points.clone(),Object.clone(this.pointProps),this.splineParameters.slice())}slice(t){let e=this.slicePoints(t.pointIndexStart,t.pointIndexEnd);return new L(this.layout.slice(),e,Object.clone(this.pointProps),this.splineParameters.slice())}getPoint(t){return super.getPoint(t,this.style)}getPointRef(t){return super.getPointRef(t,this.style)}getPointSegmentIndex(t){return this.splineParameters[t]?this.splineParameters[t].index:void 0}getPointT(t){return this.splineParameters[t]?this.splineParameters[t].t:void 0}getPointParameter(t){return this.splineParameters[t]}toJSON(){return{type:"InterpolatedSpline",layout:this.layout.map((t=>t.name)),points:v.encode(this.points,this.encoding),pointProps:this.pointProps,splineParameters:this.splineParameters}}static fromJSON(t){let e=v.decode(t.points);return new L(t.layout.map((t=>b.Property[t])),e,t.pointProps,t.splineParameters.map(A.fromJSON))}static fromRect(t,e){throw new Error("InterpolatedSpline.fromRect is not supported. Try Spline.fromRect and interpolate with particular Spline interpolator.")}static createInstance(t,e,i=[]){return new L(t,i,e)}static createSharedInstance(t,e,i,s){return new L(t,Float32Array.createSharedInstance(e),i,s)}}class _{constructor(){this.phase=_.Phase.END}add(t,e,i){if(!this.move(t))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${t.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,t.name)),this.addImpl(e,i)}addImpl(t,e){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(t){return(this.phase!=_.Phase.END||t==_.Phase.BEGIN)&&((this.phase!=_.Phase.BEGIN||t==_.Phase.UPDATE||t==_.Phase.END)&&((this.phase!=_.Phase.UPDATE||t==_.Phase.UPDATE||t==_.Phase.END)&&(t==_.Phase.BEGIN&&this.reset(),this.phase=t,!0)))}reset(){this.phase=_.Phase.END}}Object.defineEnum(_,"Phase",["BEGIN","UPDATE","END"]);let F=h?h.default||globalThis.poly2tri:{};const{SweepContext:k,Point:j}=F;let $=l?l.default||globalThis.ClipperLib:{};const{Clipper:U,Paths:B,Path:Y,ClipType:X,PolyType:z,PolyFillType:G}=$;class H{constructor(t,e){if(!Array.isArray(t))throw new Error("Unexpected polygons type found");let i=65534/(e.width+1e-16),s=65534/(e.height+1e-16),r=Math.floor(Math.min(i,s));if(0==r)throw new Error(`Insufficent clipper range - (-32767 - 32767), scale failed - scaleX: ${i}, scaleY: ${s}`);let n=e.left+32767/r,a=e.top+32767/r;this.solution=new B,this.bounds=e,this.transform={scale:r,offsetX:n,offsetY:a},this.subject=this.apply(t)}convertPoint(t){let e=(t.x-this.transform.offsetX)*this.transform.scale,i=(t.y-this.transform.offsetY)*this.transform.scale;return{X:e<0?Math.ceil(e):Math.floor(e),Y:i<0?Math.ceil(i):Math.floor(i)}}containsPoint(t){return U.PointInPolygon(this.convertPoint(t),this.solution)}apply(t){let e=new B;for(let i of t){let t=new Y,s=i.shape;for(let e=0;e<s.length;e++)t.push(this.convertPoint({x:s.getPointX(e),y:s.getPointY(e)}));e.push(t)}return e}toPaths(){let t=[];this.lastPoint={};for(let e of this.solution){if(0==e.length)continue;let i=this.flatPath(e);i.length>0&&t.push(i)}return t}flatPath(t){let e=[];for(let i of t)this.lastPoint.X==i.X&&this.lastPoint.Y==i.Y||(e.push(i.X/this.transform.scale+this.transform.offsetX,i.Y/this.transform.scale+this.transform.offsetY),this.lastPoint=i);return e.length<6&&(console.warn(`Invalid contour found: [${e.join(", ")}]`),e.clear()),e}}class J{constructor(t=2){this.stride=t}sort(t,e){return this.sortArrayPart(t,0,t.length-this.stride,e),t}partition(t,e,i,s){let r=t[i],n=t[i+1],a=e-this.stride;for(let o=e;o<i;o+=2)s?s(r,n,t[o],t[o+1])&&(a+=this.stride,this.swap(t,a,o)):(r>t[o]||r==t[o]&&n>t[o+1])&&(a+=this.stride,this.swap(t,a,o));return this.swap(t,a+this.stride,i),a+this.stride}swap(t,e,i){let s=t[e],r=t[e+1];return t[e]=t[i],t[e+1]=t[i+1],t[i]=s,t[i+1]=r,t}sortArrayPart(t,e,i,s){if(e<i){let r=this.partition(t,e,i,s);this.sortArrayPart(t,e,r-this.stride,s),this.sortArrayPart(t,r+this.stride,i,s)}}}function V(t,e,i,s,r,n){return(i-t)*(n-e)-(s-e)*(r-t)}function Z(t,e,i,s,r,n){let a=t-i,o=r-i,h=a*(n-s)-o*(e-s);h*=h,a=r-i,o=n-s;let l=a*a+o*o;return l>0?Math.sqrt(h/l):Math.sqrt((i-t)*(i-t)+(s-e)*(s-e))}class q{constructor(t=Float32Array){this.ArrayType=t,this.quickSort=new J}monotoneChain(t){if(t.length<=0)return new this.ArrayType;this.quickSort.sort(t);let e=new this.ArrayType(t.length),i=0;for(let s=0;s<t.length;s+=2){for(;i>=4&&V(e[i-4],e[i-3],e[i-2],e[i-1],t[s],t[s+1])<=0;)i-=2;e[i]=t[s],e[i+1]=t[s+1],i+=2}e=e.slice(0,i);let s,r=new this.ArrayType(t.length);i=0;for(let e=t.length-2;e>=0;e-=2){for(;i>=4&&V(r[i-4],r[i-3],r[i-2],r[i-1],t[e],t[e+1])<=0;)i-=2;r[i]=t[e],r[i+1]=t[e+1],i+=2}if(r=r.slice(0,i-2),this.ArrayType==Float32Array){let t=r.length+e.length;s=Float32Array.createSharedInstance(t),s.set(r),s.set(e,r.length)}else s=r.concat(e);return s}}class W{constructor(t,e=[]){if(!(t instanceof x))throw new Error("Expected shape type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");if(e.some((t=>!(t instanceof x))))throw new Error("Expected hole type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");let i;this.holesDirection=W.PointsDirection.CLOCKWISE,Object.defineProperty(this,"shape",{value:t,enumerable:!0}),Object.defineProperty(this,"holes",{value:e,enumerable:!0}),Object.defineProperty(this,"contours",{value:[t,...e],enumerable:!0}),Object.defineProperty(this,"ArrayType",{value:t.points instanceof Float32Array?Float32Array:Array}),Object.defineProperty(this,"bounds",{get:()=>D.ofPolygon(this),enumerable:!0}),Object.defineProperty(this,"vertices",{get:()=>(i||(i=this.triangulate()),i),set:t=>i=t,enumerable:!0}),Object.defineProperty(this,"verticesValue",{get:()=>i})}clone(t=!1){let e=this.shape.clone(t),i=this.holes.map((e=>e.clone(t))),s=new W(e,i);return this.verticesValue&&(s.vertices=this.vertices.slice()),s}fit(t){let e=this.bounds,i=t.width/e.width,s=t.height/e.height,r=i>0&&s>0?Math.min(i,s):Math.max(i,s);for(let t of this.contours)for(let e=0;e<t.length;e++)t.setPointX(e,t.getPointX(e)*r),t.setPointY(e,t.getPointY(e)*r)}center(){let t=this.bounds;for(let e of this.contours)for(let i=0;i<e.length;i++)e.setPointX(i,e.getPointX(i)-t.center.x),e.setPointY(i,e.getPointY(i)-t.center.y)}transform(t){this.contours.forEach((e=>e.transform(t)))}intersects(t){if(!(t instanceof W))throw new Error("Expected 'poly' type is Polygon");(this.holes.length>0||t.holes.length)&&console.warn("Polygon intersection is for contours only. Holes are ignored.");let e=this.shape,i=t.shape;for(let t=0;t<2;t++){let s=0==t?e:i;for(let t=0;t<s.length;t++){let r=t+1==s.length?0:t+1,n=s.getPointX(t),a=s.getPointY(t),o=s.getPointX(r),h=s.getPointY(r)-a,l=n-o,u=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(let t=0;t<e.length;t++){let i=h*e.getPointX(t)+l*e.getPointY(t);i<u&&(u=i),i>c&&(c=i)}let p=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY;for(let t=0;t<i.length;t++){let e=h*i.getPointX(t)+l*i.getPointY(t);e<p&&(p=e),e>d&&(d=e)}if(c<p||d<u)return!1}}return!0}containsPoint(t){let e=!1,i=this.shape;this.holes.length>0&&console.warn("Polygon intersection is for contours only. Holes are ignored.");for(let s=0,r=i.length-1;s<i.length;r=s++)i.getPointY(s)>t.y!=i.getPointY(r)>t.y&&t.x<(i.getPointX(r)-i.getPointX(s))*(t.y-i.getPointY(s))/(i.getPointY(r)-i.getPointY(s))+i.getPointX(s)&&(e=!e);return e}triangulate(){let t,e=[];for(let t of this.contours){let i=[];for(let e=0;e<t.length;e++){let s=new j(t.getPointX(e),t.getPointY(e));if(e>0){if(i.last.x==s.x&&i.last.y==s.y)continue;if(e==t.length-1&&i.first.x==s.x&&i.first.y==s.y)continue}i.push(s)}e.push(i)}try{t=new k(e.shift())}catch(t){return console.error(t),new Float32Array}for(let i of e)try{t.addHole(i)}catch(t){return console.error(t),new Float32Array}try{t.triangulate()}catch(t){return console.warn(t),new Float32Array}let i=t.getTriangles(),s=Float32Array.createSharedInstance(6*i.length),r=0;for(let t of i){let e=t.getPoints();for(let t of e)s[r++]=t.x,s[r++]=t.y}return s}convex(){return this.buildConvex(this.shape.points)}union(t){let e=Array.of(...this.shape.points,...t.shape.points);return this.buildConvex(e)}buildConvex(t){this.convexHullProducer||(this.convexHullProducer=new q(this.ArrayType));let e=this.convexHullProducer.monotoneChain(t);return this.ArrayType==Float32Array?W.createSharedInstance(e):W.createInstance(e)}simplify(t=.1){let e=new H([this],this.bounds);return e.subject=U.SimplifyPolygons(e.subject,G.pftNonZero),e.solution=U.CleanPolygons(e.subject,t*e.transform.scale),1==e.subject.length&&0==e.solution.first.length&&(e.solution=e.subject),W.toPolygonArray(e.toPaths())}simplifyRamerDouglasPeucker(t=.1){if(t<=0)throw new Error("epsilon expected value > 0");this.epsilon=t;let e=this.simplifyPath(this.shape),i=[];for(let t of this.holes){let e=this.simplifyPath(t);e.length>0&&i.push(e)}return this.ArrayType==Float32Array?W.createSharedInstance(e,i):W.createInstance(e,i)}simplifyPath(t){if(t.length<3)return t.points;let e=Array.of(...t.points,t.getPointX(0),t.getPointY(0)),i=this.simplifyPolyline(e);return i.length<8?e.slice(0,e.length-2):i.slice(0,i.length-2)}simplifyPolyline(t){if(t.length<4)return t;let e=0,i=0;for(let s=2;s<t.length-2;s+=2){let r=Z(t[s],t[s+1],t[0],t[1],t[t.length-2],t[t.length-1]);r>e&&(i=s,e=r)}if(e>this.epsilon){let e=this.simplifyPolyline(t.slice(0,i+2)),s=this.simplifyPolyline(t.slice(i,t.length));return e.concat(s.slice(2,s.length))}return[t[0],t[1],t[t.length-2],t[t.length-1]]}toSVGPath(){return this.contours.map((t=>t.toSVGPath())).join(" ")}toJSON(){return{type:"Polygon",shape:this.shape.toJSON(),holes:this.holes.map((t=>t.toJSON())),holesDirection:this.holesDirection.name,vertices:this.verticesValue}}static fromJSON(t){if("Polygon"!=t.type)throw new Error(`Polygon deserialization failed. JSON type is ${t.type}, expected Polygon.`);let e=x.fromJSON(t.shape),i=t.holes.map((t=>x.fromJSON(t))),s=new W(e,i);return s.holesDirection=W.PointsDirection[t.holesDirection],s.vertices=t.vertices,s}static fromRect(t){return W.createInstance([t.left,t.top,t.right,t.top,t.right,t.bottom,t.left,t.bottom,t.left,t.top])}static createInstance(t,e=[]){return new W(x.createInstance(t),e.map((t=>x.createInstance(t))))}static createSharedInstance(t,e=[]){let i=new W(x.createSharedInstance(t),e.map((t=>x.createSharedInstance(t))));return Object.defineProperty(i,"encoding",{get:()=>i.shape.encoding,set:t=>{i.contours.forEach((e=>e.encoding=t))},enumerable:!0}),i}}Object.defineEnum(W,"PointsDirection",["CLOCKWISE","COUNTERCLOCKWISE"]);class K{static ARRAY_TYPE=Array;#s;constructor(){this.keepAllData=!1,Object.defineProperty(this,"allData",{get:()=>{if(!this.keepAllData)throw new Error("All data is not accumulated. By default keepAllData property is false.");return this.#s||(this.#s=new this.constructor.ARRAY_TYPE),this.getOutput(this.#s,K.OutputType.ALL_DATA)},enumerable:!0})}build(t,e=K.OutputType.PROCESSOR,i=!0){return console.warn("use process instead"),this.process(t,e,i)}process(t,e=K.OutputType.PROCESSOR,i=!0){let s;switch(e){case K.OutputType.ADDITION:s=this.add(t,i);break;case K.OutputType.PREDICTION:s=this.predict(t);break;case K.OutputType.PROCESSOR:this.reset(),s=this.processImpl(t,e);break;default:throw new Error("Unexpected OutputType found. Allowed type is oneof(ADDITION, PREDICTION, PROCESSOR)")}return e!=K.OutputType.PREDICTION&&this.keepAllData&&(this.#s||(this.#s=new this.constructor.ARRAY_TYPE),s instanceof W?this.#s.push(s):e==K.OutputType.PROCESSOR?this.#s=s:this.#s.push(...s)),this.debug&&console.log(this.constructor.name,e.name,i,s),this.getOutput(s,e)}add(t,e=!1){return this.processImpl(t,K.OutputType.ADDITION)}predict(t){return this.processImpl(t,K.OutputType.PREDICTION)}processImpl(t,e){throw new Error("Abstract method processImpl(input, type) of DataSequenceProcessor should be implemented")}getOutput(t,e){return t}reset(){this.#s&&(this.#s=new this.constructor.ARRAY_TYPE)}}Object.defineEnum(K,"OutputType",["ADDITION","PREDICTION","ALL_DATA","PROCESSOR"]);class Q extends _{constructor(t,e){super(),this.layout=t,this.pathPointCalculator=e,this.inputBuffer=[],this.prediction=!0}togglePrediction(t){console.warn("PathProducer togglePrediction method is deprecated. Use InkBuilder instance prediction property to configure prediction behaviour."),this.prediction=t}addImpl(t,e){if(t.phase!=this.phase)throw new Error(`The phase of the addition (${t.phase.name}) doesn't match the phase of the PathProducer (${this.phase.name})`);let i=[],s=[];t&&this.inputBuffer.push(t);let r=this.inputBuffer.length>=3?this.inputBuffer[this.inputBuffer.length-3]:null,n=this.inputBuffer.length>=2?this.inputBuffer[this.inputBuffer.length-2]:null,a=this.inputBuffer.length>=1?this.inputBuffer[this.inputBuffer.length-1]:null,o=this.calculate(r,n,a);return t&&o&&i.push(...o.toArray(this.layout)),this.phase==_.Phase.END?(o=this.calculate(n,a,null),o&&i.push(...o.toArray(this.layout))):this.prediction&&(this.phase==_.Phase.UPDATE||e)&&(o=this.calculate(n,a,e),o&&(s.push(...o.toArray(this.layout)),o=this.calculate(a,e,null),o&&s.push(...o.toArray(this.layout)))),{added:i,predicted:s}}calculate(t,e,i){return e?this.pathPointCalculator(t,e,i):null}reset(){super.reset(),this.inputBuffer.clear()}}const tt=[-6e-6,-139e-6,-185e-6,414e-6,.002357,.003357,-.003135,-.023928,-.042909,-.017858,.096525,.254692,.347072,.26881,.114933];class et extends K{#r=[];#n=0;constructor(t,e=15){super(),this.filter=tt.slice(),Object.defineProperty(this,"movingAverageWindowSize",{get:function(){return e},set:function(t){e=t,this.filter.length!=t&&(this.filter=et.resample(tt,t)),this.predictionPointsCount=4*t/15,this.windowSize=this.filter.length},enumerable:!0}),this.dimsCount=t,this.movingAverageWindowSize=e}add(t,e){return e?this.project(t):this.addSequence(t)}processImpl(t){return this.project(t)}project(t){if(t.length%this.dimsCount!=0)throw new Error(`Points size ('${t.length}') must be multiple of the dimensions count ('${this.dimsCount}').`);if(0==t.length)return[];let e=[],i=this.#r.slice(),s=t.slice(0,t.length-this.dimsCount),r=this.addSequence(s);e.push(...r);let n=t.slice(t.length-this.dimsCount,t.length),a=this.predictionPointsCount;for(let t=0;t<a;t++){let i=this.addPoint(n);a-t<=this.#n&&e.push(...i)}return this.#r=i,e}addSequence(t){if(t.length%this.dimsCount!=0)throw new Error(`Points size ('${t.length}') must be multiple of the dimensions count ('${this.dimsCount}').`);let e=[],i=t.length/this.dimsCount;for(let s=0;s<i;s++){let i=this.addPoint(t.slice(s*this.dimsCount,(s+1)*this.dimsCount));e.push(...i)}return this.#n+=i,e}addPoint(t){for(this.#r.push(...t);this.#r.length<this.windowSize*this.dimsCount;)this.#r.unshift(...this.#r.slice(0,this.dimsCount));for(;this.#r.length>this.windowSize*this.dimsCount;)this.#r=this.#r.slice(this.dimsCount);return this.filterBuffer()}filterBuffer(){let t=[];for(let e=0;e<this.windowSize;e++)for(let i=0;i<this.dimsCount;i++)isNaN(t[i])&&(t[i]=0),t[i]+=this.#r[e*this.dimsCount+i]*this.filter[e];return t}reset(){super.reset(),this.#n=0,this.#r.clear()}static resample(t,e){let i=new Float32Array(e),s=t.length/e,r=0;for(let n=0;n<e;n++){let a=(t.length-1)*n/(e-1),o=Math.floor(a),h=Math.ceil(a),l=a-o,u=s*(t[o]*(1-l)+t[h]*l);r+=u,i[n]=u}let n=1/r;for(let t=0;t<e;t++)i[t]*=n;return i}}class it extends K{#a;#o;constructor(t){super(),this.layout=t,this.pathPointProps={}}add(t,e){this.#a||(this.#a=M.createInstance(this.layout,this.pathPointProps)),0==this.#a.points.length&&t.length>0&&t.unshift(...t.slice(0,this.layout.length)),e&&(t.length>=this.layout.length?t.push(...t.slice(t.length-this.layout.length,t.length)):t.push(...this.getLastPart()));let i=this.getFirstPart();return this.#a.points=i.concat(t),t}predict(t=[]){if(0==t.length)return t;this.#o?this.#o.points.clear():this.#o=M.createInstance(this.layout,this.pathPointProps);let e=this.#o.points,i=this.getFirstPart();for(e.push(...i),e.push(...t),e.push(...e.slice(e.length-this.layout.length,e.length));e.length<4*this.layout.length;)e.unshift(e.slice(0,this.layout.length));return e}processImpl(t){let e=[];return t.length>0&&(e.push(...t.slice(0,this.layout.length)),e.push(...t),t.length>=this.layout.length&&e.push(...t.slice(t.length-this.layout.length,t.length))),t}getOutput(t,e){if(e==it.OutputType.ADDITION){if(this.#a.points.length>=4*this.layout.length)return this.#a}else if(e==it.OutputType.PREDICTION){if(this.#o.points.length>0)return this.#o}else if(t.length>0)return M.createSharedInstance(this.layout,t,this.pathPointProps)}getFirstPart(){return this.#a.points.slice(Math.max(0,this.#a.points.length-3*this.layout.length),this.#a.points.length)}getLastPart(){return this.#a.points.slice(this.#a.points.length-this.layout.length,this.#a.points.length)}reset(){super.reset(),this.#a=null,this.#o=null}}const st=s.fromValues(0,-.5,1,-.5,1,0,-2.5,1.5,0,.5,2,-1.5,0,0,-.5,.5);class rt extends K{#a;#o;#h;constructor(t=!1,e=!1){super(),this.calculateDerivates=t,this.keepSplineParameters=e,this.state={segmentIndex:-1,lastPointPosition:void 0,lastPointSize:0}}initState(t){this.state.layout={},t.layout.forEach(((t,e)=>{this.state.layout[t.name]={index:e,polynomials:i.create()}})),this.keepSplineParameters?this.state.splineParameters?this.state.splineParameters.clear():this.state.splineParameters=[]:delete this.state.splineParameters,this.splineLayout=t.layout,this.pathPointProps=Object.clone(t.pointProps),this.scattering&&(this.pathPointProps.scattering=this.scattering),this.layout=this.calculateDerivates?t.layout.concat([b.Property.D_X,b.Property.D_Y]):t.layout,this.state.ready=!0}predict(t){if(!t)return[];this.state.ready||this.initState(t),this.#o?this.#o.points.clear():this.#o=L.createInstance(this.layout,this.pathPointProps),this.path=this.#o;let e=Object.clone(this.state);return delete this.state.splineParameters,this.resetState(),this.discretize(t),this.state=e,this.path.points}processImpl(t,e){if(!t)return[];let i;return t instanceof N&&(i=t,t=i.spline),this.state.ready||this.initState(t),e==rt.OutputType.ADDITION?(this.#a?this.#a.points.clear():this.#a=L.createInstance(this.layout,this.pathPointProps),this.path=this.#a):(this.#h=L.createInstance(this.layout,this.pathPointProps),this.path=this.#h),this.discretize(t,i),this.path.points}getOutput(t,e){if(0!=t.length){if(e==rt.OutputType.PROCESSOR||e==rt.OutputType.ALL_DATA){let e=this.state.splineParameters;return e&&(e=e.slice()),L.createSharedInstance(this.layout,t,this.pathPointProps,e)}return this.path}}calculateInterpolatedPoint(t,e,s){this.initState(t);let r=new b(0,0,this.splineLayout.includes(b.Property.Z)?0:void 0),n=i.fromValues(1,s,s*s,s*s*s);return this.calculatePolynomials(t,e),this.splineLayout.forEach((t=>{let e=i.dot(this.state.layout[t.name].polynomials,n);r[w.getPropName(t.name)]=e})),r}discretize(t,e){throw new Error("This method is abstract and should be implemented")}storeLastPoint(t,e=0){this.state.lastPointPosition=new u(this.getPropValue(b.Property.X,t,e),this.getPropValue(b.Property.Y,t,e),this.getPropValue(b.Property.Z,t,e)),this.state.lastP...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/workers/SplitPointsProvider.mjs line 1
- Likely real
- Uncertain, 45% confidence
Possibility of prototype polluting function detected. By adding or modifying attributes of an object prototype, it is possible to create attributes that exist on every object, or replace critical attributes with malicious ones. This can be problematic if the software depends on existence or non-existence of certain attributes, or uses pre-defined attributes of object prototype (such as hasOwnProperty, toString or valueOf). Possible mitigations might be: freezing the object prototype, using an object without prototypes (via Object.create(null) ), blocking modifications of attributes that resolve to object prototype, using Map instead of object.
import"js-ext";import{vec2 as e,vec3 as t,vec4 as i,mat4 as s,quat2 as r,mat2d as n}from"gl-matrix";import*as a from"poly2tri";import*as o from"clipper-lib";import l from"long";import*as h from"js-md5";import u from"rbush";"function"==typeof Worker&&(Worker.prototype.on=function(e,t){this[`on${e}`]=i=>{let s="message"==e?i.data:i;t(s)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(e,t){this[`on${e}`]=i=>{let s="message"==e?i.data:i;t(s)}});class p{constructor(e,t){e>0&&0==t?(this.segmentIndex=e-1,this.t=1):(this.segmentIndex=e,this.t=t),Object.defineProperty(this,"index",{get:()=>(console.warn("SplineParameter index => segmentIndex"),this.segmentIndex)})}equals(e){return this.segmentIndex==e.segmentIndex&&this.t==e.t}toString(){return`spline-parameter(${this.segmentIndex}, ${this.t})`}toJSON(){return{segmentIndex:this.segmentIndex,t:this.t}}static fromJSON(e){return new p(e.segmentIndex,e.t)}static calcMiddleOfSegment(e,t){let i=.5*(e.t+t.t+(t.segmentIndex-e.segmentIndex)),s=Math.trunc(i),r=i-s;return new p(e.segmentIndex+s,r)}static areDistantEnough(e,t,i=.01){return t.t+(t.segmentIndex-e.segmentIndex)-e.t>i}}class c{constructor(e,t,i){this.splineParameter=e,this.segmentIndex=t,this.on=i}toString(){return`SplineSplitPoint: ${this.splineParameter.segmentIndex} T:${this.splineParameter.t} -> ${this.on?"ON":"OFF"}, split by ${this.segmentIndex}`}toJSON(){return{splineParameter:this.splineParameter.toJSON(),segmentIndex:this.segmentIndex,on:this.on}}static fromJSON(e){return new c(p.fromJSON(e.splineParameter),e.segmentIndex,e.on)}static compare(e,t){return e.splineParameter.segmentIndex<t.splineParameter.segmentIndex?-1:e.splineParameter.segmentIndex>t.splineParameter.segmentIndex?1:e.splineParameter.t<t.splineParameter.t?-1:e.splineParameter.t>t.splineParameter.t?1:0}}class d{constructor(s,r,n,a){if(isNaN(s))throw new Error(`Invalid x found: ${s}`);if(isNaN(r))throw new Error(`Invalid y found: ${r}`);let o=[s,r];isFinite(n)&&(o.push(n),isFinite(a)&&o.push(a)),this.value=o.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==o.length?this.vec=e:3==o.length?(this.vec=t,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=i,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),d.fromPoint(t)}addSelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),d.fromPoint(t)}subtractSelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),d.fromPoint(t)}multiplySelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof d||(e=d.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),d.fromPoint(t)}divideSelf(e){return e instanceof d||(e=d.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),d.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new d(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),d.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return d.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new d(e[0],e[1],e[2],e[3]):new d(e.x,e.y,e.z,e.w)}}const f={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},m=f.m11,g=f.m12,y=f.m21,P=f.m22,b=f.m41,E=f.m42;class S{constructor(e=s.create(),t=S.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let i=function(e,t){let i=f[e];this.value[i]=t};Object.defineProperty(this,"a",{get:()=>this.value[m],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[g],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[y],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[P],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[b],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[E],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[b],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[E],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:i.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:i.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:i.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:i.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:i.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:i.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:i.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:i.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:i.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:i.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new S(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(S.fromTranslate(e))}translateSelf(e){this.multiplySelf(S.fromTranslate(e))}rotate(e,t){return this.multiply(S.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(S.fromRotate(e,t))}scale(e,t){return this.multiply(S.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(S.fromScale(e,t))}multiply(e){return this.multiplicationType==S.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=s.create();return s.multiply(t,e.toFloat32Array(),this.value),new S(t,this.multiplicationType)}postMultiply(e){let t=s.create();return s.multiply(t,this.value,e.toFloat32Array()),new S(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==S.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){s.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){s.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=s.create();return s.invert(e,this.value),new S(e,this.multiplicationType)}invertSelf(){s.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return d.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let i=s.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(i[0]=parseFloat(e[0]),i[1]=parseFloat(e[1]),i[2]=parseFloat(e[2]),i[3]=parseFloat(e[3]),i[4]=parseFloat(e[4]),i[5]=parseFloat(e[5]),i[6]=parseFloat(e[6]),i[7]=parseFloat(e[7]),i[8]=parseFloat(e[8]),i[9]=parseFloat(e[9]),i[10]=parseFloat(e[10]),i[11]=parseFloat(e[11]),i[12]=parseFloat(e[12]),i[13]=parseFloat(e[13]),i[14]=parseFloat(e[14]),i[15]=parseFloat(e[15])):(i[m]=parseFloat(e[0]),i[g]=parseFloat(e[1]),i[y]=parseFloat(e[2]),i[P]=parseFloat(e[3]),i[b]=parseFloat(e[4]),i[E]=parseFloat(e[5]))}return new S(i,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof S)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new S(e,t);if("string"==typeof e)return S.fromString(e,t);let i=s.create(),r=Object.assign({},e);return isFinite(e.a)&&(r.m11=e.a),isFinite(e.b)&&(r.m12=e.b),isFinite(e.c)&&(r.m21=e.c),isFinite(e.d)&&(r.m22=e.d),isFinite(e.tx)?r.m41=e.tx:isFinite(e.e)?r.m41=e.e:isFinite(e.dx)&&(r.m41=e.dx),isFinite(e.ty)?r.m42=e.ty:isFinite(e.f)?r.m42=e.f:isFinite(e.dy)&&(r.m42=e.dy),isFinite(r.m11)&&(i[0]=r.m11),isFinite(r.m12)&&(i[1]=r.m12),isFinite(r.m13)&&(i[2]=r.m13),isFinite(r.m14)&&(i[3]=r.m14),isFinite(r.m21)&&(i[4]=r.m21),isFinite(r.m22)&&(i[5]=r.m22),isFinite(r.m23)&&(i[6]=r.m23),isFinite(r.m24)&&(i[7]=r.m24),isFinite(r.m31)&&(i[8]=r.m31),isFinite(r.m32)&&(i[9]=r.m32),isFinite(r.m33)&&(i[10]=r.m33),isFinite(r.m34)&&(i[11]=r.m34),isFinite(r.m41)&&(i[12]=r.m41),isFinite(r.m42)&&(i[13]=r.m42),isFinite(r.m43)&&(i[14]=r.m43),isFinite(r.m44)&&(i[15]=r.m44),new S(i,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return S.fromMatrix(t)}static fromRotate(e,t){let i=Math.sin(e),s=Math.cos(e),r={a:s,b:i,c:-i,d:s};return t&&(r.tx=t.x-t.x*s+t.y*i,r.ty=t.y-t.x*i-t.y*s),S.fromMatrix(r)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let i={a:e.x,d:e.y};return t&&(i.tx=t.x-t.x*e.x,i.ty=t.y-t.y*e.y),S.fromMatrix(i)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let i=S.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),s=S.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=i.invert().preMultiply(s);return S.fromMatrix({a:r.m11,b:r.m12,c:r.m21,d:r.m22,tx:r.m31,ty:r.m32})}static multiply(e,t){let i=s.create();return s.multiply(i,e.value,t.value),new S(i)}}S.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});class w extends d{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,i,s={}){super(e,t,i),this.red=s.red,this.green=s.green,this.blue=s.blue,this.alpha=s.alpha,this.size=s.size||w.defaults.size,this.rotation=s.rotation||w.defaults.rotation,this.scaleX=s.scaleX||w.defaults.scaleX,this.scaleY=s.scaleY||w.defaults.scaleY,this.scaleZ=isFinite(i)?s.scaleZ||w.defaults.scaleZ:void 0,this.offsetX=s.offsetX||w.defaults.offsetX,this.offsetY=s.offsetY||w.defaults.offsetY,this.offsetZ=isFinite(i)?s.offsetZ||w.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,i,s=0){let r=new w(0,0,e.includes(w.Property.Z)?0:void 0);return i&&r.fill(s,i,e,t),r}fill(e,t,i,s={}){let r={},n=e*i.length;i.forEach(((e,i)=>w.setProperty(r,e,t[n+i]))),this.x=r.x,this.y=r.y,this.z=r.z,this.red=isFinite(r.red)?r.red:s.red,this.green=isFinite(r.green)?r.green:s.green,this.blue=isFinite(r.blue)?r.blue:s.blue,this.alpha=isFinite(r.alpha)?r.alpha:s.alpha,this.size=r.size||s.size||w.defaults.size,this.rotation=r.rotation||s.rotation||w.defaults.rotation,this.scaleX=r.scaleX||s.scaleX||w.defaults.scaleX,this.scaleY=r.scaleY||s.scaleY||w.defaults.scaleY,this.scaleZ=isFinite(r.z)?r.scaleZ||s.scaleZ||w.defaults.scaleZ:void 0,this.offsetX=r.offsetX||s.offsetX||w.defaults.offsetX,this.offsetY=r.offsetY||s.offsetY||w.defaults.offsetY,this.offsetZ=isFinite(r.z)?r.offsetZ||s.offsetZ||w.defaults.offsetZ:void 0,this.dX=r.dX,this.dY=r.dY}getProperty(e){switch(e){case w.Property.X:return this.x;case w.Property.Y:return this.y;case w.Property.Z:return this.z;case w.Property.RED:return this.red;case w.Property.GREEN:return this.green;case w.Property.BLUE:return this.blue;case w.Property.ALPHA:return this.alpha;case w.Property.SIZE:return this.size;case w.Property.ROTATION:return this.rotation;case w.Property.SCALE_X:return this.scaleX;case w.Property.SCALE_Y:return this.scaleY;case w.Property.SCALE_Z:return this.scaleZ;case w.Property.OFFSET_X:return this.offsetX;case w.Property.OFFSET_Y:return this.offsetY;case w.Property.OFFSET_Z:return this.offsetZ;case w.Property.D_X:return this.dX;case w.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){w.setProperty(this,e,t)}static setProperty(e,t,i){switch(t){case w.Property.X:e.x=i;break;case w.Property.Y:e.y=i;break;case w.Property.Z:e.z=i;break;case w.Property.RED:e.red=i;break;case w.Property.GREEN:e.green=i;break;case w.Property.BLUE:e.blue=i;break;case w.Property.ALPHA:e.alpha=i;break;case w.Property.SIZE:e.size=i;break;case w.Property.ROTATION:e.rotation=i;break;case w.Property.SCALE_X:e.scaleX=i;break;case w.Property.SCALE_Y:e.scaleY=i;break;case w.Property.SCALE_Z:e.scaleZ=i;break;case w.Property.OFFSET_X:e.offsetX=i;break;case w.Property.OFFSET_Y:e.offsetY=i;break;case w.Property.OFFSET_Z:e.offsetZ=i;break;case w.Property.D_X:e.dX=i;break;case w.Property.D_Y:e.dY=i;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof S))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,i=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=i}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return w.Property.values.forEach((t=>{let i=this.getProperty(t);null!=i&&isFinite(i)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(w,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]);class I{constructor(e){this.key=e,this.height=1}leftRotate(){let e=this.right,t=e.left;return e.left=this,this.right=t,this.height=Math.max(I.height(this.left),I.height(this.right))+1,e.height=Math.max(I.height(e.left),I.height(e.right))+1,e}rightRotate(){let e=this.left,t=e.right;return e.right=this,this.left=t,this.height=Math.max(I.height(this.left),I.height(this.right))+1,e.height=Math.max(I.height(e.left),I.height(e.right))+1,e}getBalanceFactor(){return I.height(this.left)-I.height(this.right)}static height(e){return e?e.height:0}static minValue(e){if(!e)return;let t=e;for(;t.left;)t=t.left;return t.key}static maxValue(e){if(!e)return;let t=e;for(;t.right;)t=t.right;return t.key}}class O{constructor(){this.count=0,this.hasKey=!1,this.root}min(){return I.minValue(this.root)}max(){return I.maxValue(this.root)}add(e){return this.hasKey=!1,this.root=this.insertNode(this.root,e),this.hasKey||this.count++,!this.hasKey}insertNode(e,t){if(!e)return new I(t);if(t<e.key)e.left=this.insertNode(e.left,t);else{if(!(t>e.key))return this.hasKey=!0,e;e.right=this.insertNode(e.right,t)}if(!this.hasKey){e.height=1+Math.max(I.height(e.left),I.height(e.right));let i=e.getBalanceFactor();if(i>1){if(t<e.left.key)return e.rightRotate();if(t>e.left.key)return e.left=e.left.leftRotate(),e.rightRotate()}else if(i<-1){if(t>e.right.key)return e.leftRotate();if(t<e.right.key)return e.right=e.right.rightRotate(),e.leftRotate()}}return e}contains(e){return this.containsNode(this.root,e)}containsNode(e,t){return!!e&&(t<e.key?this.containsNode(e.left,t):!(t>e.key)||this.containsNode(e.right,t))}printTree(){if(!this.root)return;let e=[this.root],t=this.root.height;for(;e.length>0;){let i=e.shift();t!=i.height&&console.log("-"),console.log(`${i.key} with height: ${i.height}, balance: ${i.getBalanceFactor()}`),t=i.height;let s=i.left,r=i.right;s&&e.push(s),r&&e.push(r)}}toArray(){let e=[];return O.fillArray(e,this.root),e}static fillArray(e,t){t&&(this.fillArray(e,t.left),e.push(t.key),this.fillArray(e,t.right))}}class v{constructor(){this.tree=new O,Object.defineProperty(this,"length",{get:()=>this.tree.count,enumerable:!0})}clear(){this.tree=new O}add(e){return this.tree.add(e)}includes(e){return this.tree.contains(e)}min(){return this.tree.min()}max(){return this.tree.max()}toArray(){return this.tree.toArray()}}let x=a?a.default||globalThis.poly2tri:{};const{SweepContext:A,Point:R}=x;let T=o?o.default||globalThis.ClipperLib:{};const{Clipper:D,Paths:N,Path:F,ClipType:C,PolyType:M,PolyFillType:k}=T;class L{constructor(e,t,i){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:i,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.path.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in path index is ${this.path.length-1}.`)}toPath(){return this.path.slice(this)}toString(){return`fragment(${this.pointIndexStart} - ${this.pointIndexEnd})`}}class B{constructor(e,t,i,s=1){if(this.red=e,this.green=t,this.blue=i,this.alpha=s,s<0||s>1)throw new Error(`Invalid alpha ${s} found. The value must be in the interval [0, 1].`);Object.defineProperty(this,"hex",{get:()=>`#${this.red.toString(16).pad(2,"0")}${this.green.toString(16).pad(2,"0")}${this.blue.toString(16).pad(2,"0")}${Math.round(255*this.alpha).toString(16).pad(2,"0")}`,enumerable:!0})}premultiply(){return{red:this.red/255*this.alpha,green:this.green/255*this.alpha,blue:this.blue/255*this.alpha,alpha:this.alpha}}static postdivide(e,t,i,s){let r=parseInt(255*e/s),n=parseInt(255*t/s),a=parseInt(255*i/s);return new B(r,n,a,s)}equals(e){return e&&this.red==e.red&&this.green==e.green&&this.blue==e.blue&&this.alpha==e.alpha}toRGB(){return 1==this.alpha?this:new B(this.red,this.green,this.blue)}toRGBA(e){return new B(this.red,this.green,this.blue,e)}toHSLA(){let e=this.red/255,t=this.green/255,i=this.blue/255,s=Math.min(e,t,i),r=Math.max(e,t,i),n=0,a=0,o=(r+s)/2;if(r!=s){let l=r-s;switch(a=l/(1-Math.abs(2*o-1)),r){case e:n=(t-i)/l%6;break;case t:n=(i-e)/l+2;break;case i:n=(e-t)/l+4}}return n*=60,n<0&&(n+=360),{hue:parseFloat(n.toFixed(0)),saturation:parseFloat((100*a).toFixed(2)),lightness:parseFloat((100*o).toFixed(2)),alpha:this.alpha}}toArray(){return[this.red,this.green,this.blue,this.alpha]}toJSON(){return{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}}toString(){return 1==this.alpha?`rgb(${this.red}, ${this.green}, ${this.blue})`:`rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`}static isColor(e){return e&&isFinite(e.red)&&isFinite(e.green)&&isFinite(e.blue)}static fromColor(e){let t,i,s,r;if("string"==typeof e)if(e.startsWith("rgb"))e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),t=parseInt(e[0]),i=parseInt(e[1]),s=parseInt(e[2]),r=e[3]?parseInt(e[3]):1;else{if(!e.startsWith("#"))throw new Error(`Unknown input found: ${e}. Expected data starts with rgba, rgb or #.`);e=e.substring(1),t=parseInt(e.substring(0,2),16),i=parseInt(e.substring(2,4),16),s=parseInt(e.substring(4,6),16),r=8==e.length?parseInt(e.substring(6,8),16)/255:1}else Array.isArray(e)?(t=e[0],i=e[1],s=e[2],r=e[3]):(t=e.red,i=e.green,s=e.blue,r=e.alpha);return new B(t,i,s,r)}static fromHSLA(e=0,t=0,i=0,s){e/=60,t/=100,i/=100;let r=(1-Math.abs(2*i-1))*t,n=r*(1-Math.abs(e%2-1)),a=0,o=0,l=0;e>=0&&e<1?(a=r,o=n):e>=1&&e<2?(a=n,o=r):e>=2&&e<3?(o=r,l=n):e>=3&&e<4?(o=n,l=r):e>=4&&e<5?(a=n,l=r):(a=r,l=n);let h=i-r/2;return a+=h,o+=h,l+=h,new B(Math.round(255*a),Math.round(255*o),Math.round(255*l),s)}static random(e=!1){return new B(Math.randomInt(0,255),Math.randomInt(0,255),Math.randomInt(0,255),e?Math.random():1)}}B.TRANSPERENT=new B(0,0,0,0),B.BLACK=new B(0,0,0,1),B.WHITE=new B(255,255,255,1),B.RED=new B(255,0,0,1),B.GREEN=new B(0,255,0,1),B.BLUE=new B(0,0,255,1);let _={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let i=0;i<t.length;i++){let s=255&e;t[i]=s,e=(e-s)/256}return t},byteArrayToLong(e){let t=0;for(let i=e.length-1;i>=0;i--)t=256*t+e[i];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let i=t;for(let e=8;e--;)i=1&i?3988292384^i>>>1:i>>>1;e[t]=i}return function(t){let i=-1;for(let s=0,r=t.length;s<r;s++)i=i>>>8^e[255&i^t[s]];return(-1^i)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",i=Math.max(...e);for(let s=1;s<=i;s++)t+=e.includes(s)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],i=e.toString(2).split("").reverse();for(let e=0;e<i.length;e++)1==i[e]&&t.push(e+1);return t},mapTo:(e,t,i)=>i.min+(_.clamp(e,t)-t.min)/(t.max-t.min)*(i.max-i.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let i=null;return function(){let s=this,r=arguments;clearTimeout(i),i=setTimeout((function(){e.apply(s,r)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,i){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),i?e.toLowerCase():e};return function(i,s){return e.map((e=>function(e,t,i){let s="asc"===i?1:-1;return e>t?1*s:e<t?-1*s:0}(t(i,e.sortBy,e.ignoreCase),t(s,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let i=e.split("_"),s=i.first.toLowerCase();t&&(s=s.substring(0,1).toUpperCase()+s.substring(1));for(let e=1;e<i.length;e++)s+=i[e].substring(0,1),s+=i[e].substring(1).toLowerCase();return s},getEnumValueName(e){let t="";for(let i=0;i<e.length;i++)i>0&&e[i]!=e[i].toLowerCase()&&(t+="_"),t+=e[i];return t.toUpperCase()}};class j{constructor(e,t,i={}){this.layout=e,this.pointProps=t,this.sheet={};let s={};Object.defineProperties(s,{size:{get:this.getComputed.bind(this,"size"),set:this.setStyle.bind(this,"size"),enumerable:!0},red:{get:this.getComputed.bind(this,"red"),set:this.setStyle.bind(this,"red"),enumerable:!0},green:{get:this.getComputed.bind(this,"green"),set:this.setStyle.bind(this,"green"),enumerable:!0},blue:{get:this.getComputed.bind(this,"blue"),set:this.setStyle.bind(this,"blue"),enumerable:!0},alpha:{get:this.getComputed.bind(this,"alpha"),set:this.setStyle.bind(this,"alpha"),enumerable:!0},rotation:{get:this.getComputed.bind(this,"rotation"),set:this.setStyle.bind(this,"rotation"),enumerable:!0},scaleX:{get:this.getComputed.bind(this,"scaleX"),set:this.setStyle.bind(this,"scaleX"),enumerable:!0},scaleY:{get:this.getComputed.bind(this,"scaleY"),set:this.setStyle.bind(this,"scaleY"),enumerable:!0},scaleZ:{get:this.getComputed.bind(this,"scaleZ"),set:this.setStyle.bind(this,"scaleZ"),enumerable:!0},offsetX:{get:this.getComputed.bind(this,"offsetX"),set:this.setStyle.bind(this,"offsetX"),enumerable:!0},offsetY:{get:this.getComputed.bind(this,"offsetY"),set:this.setStyle.bind(this,"offsetY"),enumerable:!0},offsetZ:{get:this.getComputed.bind(this,"offsetZ"),set:this.setStyle.bind(this,"offsetZ"),enumerable:!0},color:{get:this.getComputed.bind(this,"color"),set:this.setStyle.bind(this,"color"),enumerable:!0},blendMode:{get:this.getComputed.bind(this,"blendMode"),set:this.setStyle.bind(this,"blendMode"),enumerable:!0},visibility:{get:this.getComputed.bind(this,"visibility"),set:this.setStyle.bind(this,"visibility"),enumerable:!0},reset:{value:e=>{e&&(i=e),this.clear(),Object.keys(i).forEach((e=>this.setStyle(e,i[e])))}},clear:{value:this.clear.bind(this)}}),this.style=Object.freeze(s),this.style.reset(i)}setStyle(e,t){if(null==t&&(t=void 0),j.validate(this.layout,e,t),"color"==e&&t)return this.sheet.red=t.red,this.sheet.green=t.green,this.sheet.blue=t.blue,void(this.sheet.alpha=t.alpha);null==t?delete this.sheet[e]:this.sheet[e]=t}getStyle(e){let t=this.sheet[e];return"visibility"==e?"boolean"!=typeof t&&(t=!0):"color"==e&&B.isColor(this.sheet)&&(t=B.fromColor(this.sheet)),t}getComputed(e){let t=this.getStyle(e);if(null==t)if("color"==e){let e={red:isFinite(this.sheet.red)?this.sheet.red:this.pointProps.red,green:isFinite(this.sheet.green)?this.sheet.green:this.pointProps.green,blue:isFinite(this.sheet.blue)?this.sheet.blue:this.pointProps.blue,alpha:isFinite(this.sheet.alpha)?this.sheet.alpha:this.pointProps.alpha};B.isColor(e)&&(t=B.fromColor(e))}else t=this.pointProps[e];return t}clear(){this.sheet={}}static validate(e,t,i,s){let r;if(i&&e.includes(w.Property[_.getEnumValueName(t)])){if(!s)throw new Error(`Property ${t} value ${i} is not applicable. This is a dynamic property and is part of the layout.`);console.warn(`Property ${t} value ${i} is not applicable. This is a dynamic property and is part of the layout.`),i=void 0}if("color"==t)!i||i instanceof B||(r=`Property ${t} is not an instance of Color`);else if("blendMode"==t)""==i&&(i=void 0);else if("number"==typeof i)if("size"==t)i<0?r=`Property ${t} with value ${i} is not allowed. Value should be a positive number.`:0==i&&(i=void 0);else if("red"==t||"green"==t||"blue"==t||"alpha"==t){let e="alpha"==t?{min:0,max:1}:{min:0,max:255};i>=e.min&&i<=e.max||(r=`Property ${t} with value ${i} is out of range. Allowd range: [${e.min}, ${e.max}].`)}else"rotation"==t?0==i&&(i=void 0):"scattering"==t&&i<0&&(i=void 0);if(r)throw new Error(r);return i}}class ${static encode(e,t=$.Encoding.AUTO){let i;if(t==$.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?$.Encoding.NONE:$.Encoding.ARRAY:$.Encoding.BUFFER:t==$.Encoding.ARRAY&&e instanceof Array&&(t=$.Encoding.NONE),t==$.Encoding.NONE)i=e;else if(t==$.Encoding.ARRAY)i=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let s=Buffer.from(e.buffer);switch(t){case $.Encoding.BUFFER:i=s.toJSON();break;case $.Encoding.BASE64:i=s.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:i}}static decode(e){let t,i=$.Encoding[e.encoding];if(i==$.Encoding.NONE)t=e.content;else if(i==$.Encoding.ARRAY)t=e.content.toFloat32Array();else{let s;switch(i){case $.Encoding.BUFFER:s="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case $.Encoding.BASE64:s="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${i.name}`)}let r=new Uint8Array(s);t=new globalThis[e.type](r.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum($,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);const U=[w.Property.X,w.Property.Y];class Y{#e;#t;constructor(e,t={},i=U){if(this.#e=e,Object.defineProperty(this,"points",{get:()=>this.#e,set:e=>{if(this.#e instanceof Float32Array)throw new Error("Points setter is not accessible wehn points type is Float32Array.");this.#e=e,this.validate()},enumerable:!0}),Object.defineProperty(this,"buffer",{get:()=>this.#e.buffer,set:e=>{if(Array.isArray(this.#e))throw new Error("Underlying points buffer is Array. This property is applicable for TypedArray only.");if("undefined"!=typeof SharedArrayBuffer&&this.#e.buffer instanceof SharedArrayBuffer)throw new Error("Underlying buffer is SharedArrayBuffer and cannot be restored");if(this.#e.buffer.byteLength>0)throw new Error("Cannot restore buffer when underlying buffer is not empty");if(e.byteLength/Float32Array.BYTES_PER_ELEMENT/this.stride!=this.length)throw new Error("Value exceeds expected memory length");this.#e=new Float32Array(e)}}),!Object.isSealed(t))for(let e in t)void 0!==t[e]&&(t[e]=j.validate(i,e,t[e],!0));i.includes(w.Property.ROTATION)||"rotation"in t||(t.rotation=void 0),i.includes(w.Property.SIZE)||t.size||(t.size=1),Object.defineProperties(this,{stride:{value:i.length,enumerable:!0},layout:{value:Object.freeze(i),enumerable:!0},pointProps:{value:Object.seal(t),enumerable:!0}}),e instanceof Float32Array?Object.defineProperty(this,"length",{value:this.#e.length/this.stride,enumerable:!0}):Object.defineProperty(this,"length",{get:()=>this.#e.length/this.stride,enumerable:!0}),i.forEach(((e,t)=>{let i=_.getPropName(e.name,!0);Object.defineProperty(this,`setPoint${i}`,{value:this.setPointPropertyValue.bind(this,t)}),Object.defineProperty(this,`getPoint${i}`,{value:this.getPointPropertyValue.bind(this,t)})}))}validate(){if(this.points.length%this.stride!=0)throw new Error("Path length doesn't match the stride provided via the layout")}setPointPropertyValue(e,t,i){if(isNaN(t))throw new Error("Point index is required");if(t>=this.length||t<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);if(isNaN(i))throw new Error("value is required");this.points[t*this.layout.length+e]=i}getPointPropertyValue(e,t){if(isNaN(t))throw new Error("Point index is required");if(t>=this.length||t<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);return this.points[t*this.layout.length+e]}setPoint(e,t){let i=e*this.stride;this.layout.forEach(((e,s)=>this.points[i+s]=t.getProperty(e)))}getPoint(e,t=this.pointProps){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);return w.createInstance(this.layout,t,this.points,e)}getPointRef(e,t=this.pointProps){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);return this.#t||(this.#t=w.createInstance(this.layout)),this.#t.fill(e,this.points,this.layout,this.pointProps),this.#t}getChannelData(e){let t=new([w.Property.RED,w.Property.GREEN,w.Property.BLUE].includes(e)?Uint8Array:Float32Array)(this.length),i=this.layout.indexOf(e);if(-1==i)throw new Error(`Property ${e.name} is not part from the spline layout ${this.layout.map((e=>e.name)).join(", ")}`);for(let e=0;e<this.length;e++)t[e]=this.points[e*this.stride+i];return t}transform(e){let t=e.scaleX,s=e.rotation;for(let r=0;r<this.length;r++){let n=r*this.stride,a=i.fromValues(this.getPointX(r),this.getPointY(r),0,1);i.transformMat4(a,a,e.value);for(let e=0;e<this.stride;e++){let i=n+e;switch(this.layout[e]){case w.Property.X:this.points[i]=a[0]/a[3];break;case w.Property.Y:this.points[i]=a[1]/a[3];break;case w.Property.Z:this.points[i]=a[2]/a[3];break;case w.Property.ROTATION:this.points[i]+=s;break;case w.Property.SIZE:this.points[i]*=t}}}this.layout.includes(w.Property.ROTATION)||(this.pointProps.rotation=0==s?void 0:s)}clone(){return new Y(this.#e.clone(),Object.clone(this.pointProps),this.layout.slice())}getFragment(e=0,t=this.length-1){return new L(this,e,t)}slice(e){let t=this.slicePoints(e.pointIndexStart,e.pointIndexEnd);return new Y(t,Object.clone(this.pointProps),this.layout.slice())}validateFragment(e,t){if(e<0)throw new Error(`Invalid fragment pointIndexStart ${e} found. The value must be non-negative.`);if(t>this.length-1)throw new Error(`Invalid fragment pointIndexEnd ${t} found. Last point in path index is ${this.length-1}.`)}slicePoints(e,t){let i;if(this.validateFragment(e,t),"undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let s=this.points.subarray(e*this.stride,(t+1)*this.stride),r=new SharedArrayBuffer(s.length*Float32Array.BYTES_PER_ELEMENT);i=new Float32Array(r),i.set(s)}else i=this.points.slice(e*this.stride,(t+1)*this.stride);return i}toSVGPath(){let e=[];for(let t=0;t<this.length;t++)e.push(`${this.getPointX(t)},${this.getPointY(t)}`);return`M ${e.join(" L ")} Z`}toJSON(){return{type:"Path",points:$.encode(this.#e,this.encoding),pointProps:this.pointProps,layout:this.layout.map((e=>e.name))}}static fromJSON(e){if("Path"!=e.type)throw new Error(`Path deserialization failed. JSON type is ${e.type}, expected Path.`);return new Y($.decode(e.points),e.pointProps,e.layout.map((e=>w.Property[e])))}static fromRect(e,t){let i=[e.left,e.top,e.right,e.top,e.right,e.bottom,e.left,e.bottom,e.left,e.top];return new Y(i,t)}static createInstance(e,t,i){return new Y(e,t,i)}static createSharedInstance(e,t,i){return new Y(Float32Array.createSharedInstance(e),t,i)}}class G{constructor(e,t){if(!Array.isArray(e))throw new Error("Unexpected polygons type found");let i=65534/(t.width+1e-16),s=65534/(t.height+1e-16),r=Math.floor(Math.min(i,s));if(0==r)throw new Error(`Insufficent clipper range - (-32767 - 32767), scale failed - scaleX: ${i}, scaleY: ${s}`);let n=t.left+32767/r,a=t.top+32767/r;this.solution=new N,this.bounds=t,this.transform={scale:r,offsetX:n,offsetY:a},this.subject=this.apply(e)}convertPoint(e){let t=(e.x-this.transform.offsetX)*this.transform.scale,i=(e.y-this.transform.offsetY)*this.transform.scale;return{X:t<0?Math.ceil(t):Math.floor(t),Y:i<0?Math.ceil(i):Math.floor(i)}}containsPoint(e){return D.PointInPolygon(this.convertPoint(e),this.solution)}apply(e){let t=new N;for(let i of e){let e=new F,s=i.shape;for(let t=0;t<s.length;t++)e.push(this.convertPoint({x:s.getPointX(t),y:s.getPointY(t)}));t.push(e)}return t}toPaths(){let e=[];this.lastPoint={};for(let t of this.solution){if(0==t.length)continue;let i=this.flatPath(t);i.length>0&&e.push(i)}return e}flatPath(e){let t=[];for(let i of e)this.lastPoint.X==i.X&&this.lastPoint.Y==i.Y||(t.push(i.X/this.transform.scale+this.transform.offsetX,i.Y/this.transform.scale+this.transform.offsetY),this.lastPoint=i);return t.length<6&&(console.warn(`Invalid contour found: [${t.join(", ")}]`),t.clear()),t}}class X{constructor(e=2){this.stride=e}sort(e,t){return this.sortArrayPart(e,0,e.length-this.stride,t),e}partition(e,t,i,s){let r=e[i],n=e[i+1],a=t-this.stride;for(let o=t;o<i;o+=2)s?s(r,n,e[o],e[o+1])&&(a+=this.stride,this.swap(e,a,o)):(r>e[o]||r==e[o]&&n>e[o+1])&&(a+=this.stride,this.swap(e,a,o));return this.swap(e,a+this.stride,i),a+this.stride}swap(e,t,i){let s=e[t],r=e[t+1];return e[t]=e[i],e[t+1]=e[i+1],e[i]=s,e[i+1]=r,e}sortArrayPart(e,t,i,s){if(t<i){let r=this.partition(e,t,i,s);this.sortArrayPart(e,t,r-this.stride,s),this.sortArrayPart(e,r+this.stride,i,s)}}}function z(e,t,i,s,r,n){return(i-e)*(n-t)-(s-t)*(r-e)}function H(e,t,i,s,r,n){let a=e-i,o=r-i,l=a*(n-s)-o*(t-s);l*=l,a=r-i,o=n-s;let h=a*a+o*o;return h>0?Math.sqrt(l/h):Math.sqrt((i-e)*(i-e)+(s-t)*(s-t))}class q{constructor(e=Float32Array){this.ArrayType=e,this.quickSort=new X}monotoneChain(e){if(e.length<=0)return new this.ArrayType;this.quickSort.sort(e);let t=new this.ArrayType(e.length),i=0;for(let s=0;s<e.length;s+=2){for(;i>=4&&z(t[i-4],t[i-3],t[i-2],t[i-1],e[s],e[s+1])<=0;)i-=2;t[i]=e[s],t[i+1]=e[s+1],i+=2}t=t.slice(0,i);let s,r=new this.ArrayType(e.length);i=0;for(let t=e.length-2;t>=0;t-=2){for(;i>=4&&z(r[i-4],r[i-3],r[i-2],r[i-1],e[t],e[t+1])<=0;)i-=2;r[i]=e[t],r[i+1]=e[t+1],i+=2}if(r=r.slice(0,i-2),this.ArrayType==Float32Array){let e=r.length+t.length;s=Float32Array.createSharedInstance(e),s.set(r),s.set(t,r.length)}else s=r.concat(t);return s}}class J{constructor(e,t,i,s){let r=e,n=t,a=e+i,o=t+s;Object.defineProperties(this,{left:{value:r,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:a,enumerable:!0},top:{value:o,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0}})}union(e){if(e&&!(e instanceof J))throw new TypeError("rect must be instance of RectGL");return e?J.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof J))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=J.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return J.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return J.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=d.fromPoint({x:this.left,y:this.bottom}).transform(e),i=d.fromPoint({x:this.right,y:this.bottom}).transform(e),s=d.fromPoint({x:this.left,y:this.top}).transform(e),r=d.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(s.x,r.x,t.x,i.x),a=Math.min(s.y,r.y,t.y,i.y),o=Math.max(s.x,r.x,t.x,i.x),l=Math.max(s.y,r.y,t.y,i.y);return J.ofEdges(n,a,o,l)}toQuad(e){let t;if(e){let i=d.fromPoint({x:this.left,y:this.bottom}).transform(e),s=d.fromPoint({x:this.right,y:this.bottom}).transform(e),n=d.fromPoint({x:this.left,y:this.top}).transform(e),a=d.fromPoint({x:this.right,y:this.top}).transform(e);t=r.fromValues(i.x,i.y,s.x,s.y,n.x,n.y,a.x,a.y)}else t=r.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,i,s){return new J(e,t,i-e,s-t)}static calculateBrushGLSegmentBounds(e,t=0,i){let s,r=.5*e.size,n=Math.abs(t*r);if(i){s=new d(e.x,e.y,e.x,e.z).transform(i)}else s=e;let a=s.x,o=s.y,l=e.scaleX*r,h=e.scaleY*r,u=e.offsetX,p=-e.offsetY,c=Math.cos(e.rotation),f=Math.sin(e.rotation),m=Number.MAX_SAFE_INTEGER,g=Number.MIN_SAFE_INTEGER,y=Number.MAX_SAFE_INTEGER,P=Number.MIN_SAFE_INTEGER;for(let e of J.SQURE){let t=e.x*l+u,i=e.y*h+p,s=c*t+f*i+a,r=-f*t+c*i+o,d=s-n;m=Math.min(m,d),g=Math.max(g,d),d=s+n,m=Math.min(m,d),g=Math.max(g,d);let b=r-n;y=Math.min(y,b),P=Math.max(P,b),b=r+n,y=Math.min(y,b),P=Math.max(P,b)}return J.ofEdges(m,y,g,P)}}Object.defineProperty(J,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class V{constructor(e,t,i,s){let r,n,a,o=e,l=t,h=e+i,u=t+s;Object.defineProperties(this,{left:{value:o,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:u,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:i,enumerable:!0},height:{value:s,enumerable:!0},size:{get:()=>(r||(r={width:i,height:s}),r),enumerable:!0},area:{get:()=>(n||(n=i*s),n),enumerable:!0},center:{get:()=>(a||(a={x:(o+h)/2,y:(l+u)/2}),a),enumerable:!0}})}union(e){return e?V.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=V.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),i=Math.floor(this.top),s=Math.ceil(this.right),r=Math.ceil(this.bottom);if(e){let e=s-t,n=r-i;e+=e%2,n+=n%2,s=t+e,r=i+n}return V.ofEdges(t,i,s,r)}floor(e){let t=Math.ceil(this.left),i=Math.ceil(this.top),s=Math.floor(this.right),r=Math.floor(this.bottom);if(e){let e=s-t,n=r-i;e-=e%2,n-=n%2,s=t+e,r=i+n}return V.ofEdges(t,i,s,r)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=d.fromPoint({x:this.left,y:this.top}).transform(e),i=d.fromPoint({x:this.right,y:this.top}).transform(e),s=d.fromPoint({x:this.left,y:this.bottom}).transform(e),r=d.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,i.x,s.x,r.x),a=Math.min(t.y,i.y,s.y,r.y),o=Math.max(t.x,i.x,s.x,r.x),l=Math.max(t.y,i.y,s.y,r.y);return V.ofEdges(n,a,o,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new J(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof J))throw new TypeError("rect must be instance of RectGL");return new V(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new V(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?V.fromString(e):new V(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let a=e.getPointX(n),o=e.getPointY(n);t=Math.min(t,a),i=Math.min(i,o),s=Math.max(s,a),r=Math.max(r,o)}return V.ofEdges(t,i,s,r)}static ofSpline(e,t=0){let i;for(let s=0;s<e.length;s++)i=J.calculateBrushGLSegmentBounds(e.getPointRef(s),t).union(i);return V.fromGLRect(i)}static ofEdges(e,t,i,s){let r=Math.min(e,i),n=Math.min(t,s),a=Math.max(e,i),o=Math.max(t,s);return new V(r,n,a-r,o-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}class W{constructor(e,t=[]){if(!(e instanceof Y))throw new Error("Expected shape type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");if(t.some((e=>!(e instanceof Y))))throw new Error("Expected hole type is Path. Use createInstance or createSharedInstance Polygon methods to allocate instance.");let i;this.holesDirection=W.PointsDirection.CLOCKWISE,Object.defineProperty(this,"shape",{value:e,enumerable:!0}),Object.defineProperty(this,"holes",{value:t,enumerable:!0}),Object.defineProperty(this,"contours",{value:[e,...t],enumerable:!0}),Object.defineProperty(this,"ArrayType",{value:e.points instanceof Float32Array?Float32Array:Array}),Object.defineProperty(this,"bounds",{get:()=>V.ofPolygon(this),enumerable:!0}),Object.defineProperty(this,"vertices",{get:()=>(i||(i=this.triangulate()),i),set:e=>i=e,enumerable:!0}),Object.defineProperty(this,"verticesValue",{get:()=>i})}clone(e=!1){let t=this.shape.clone(e),i=this.holes.map((t=>t.clone(e))),s=new W(t,i);return this.verticesValue&&(s.vertices=this.vertices.slice()),s}fit(e){let t=this.bounds,i=e.width/t.width,s=e.height/t.height,r=i>0&&s>0?Math.min(i,s):Math.max(i,s);for(let e of this.contours)for(let t=0;t<e.length;t++)e.setPointX(t,e.getPointX(t)*r),e.setPointY(t,e.getPointY(t)*r)}center(){let e=this.bounds;for(let t of this.contours)for(let i=0;i<t.length;i++)t.setPointX(i,t.getPointX(i)-e.center.x),t.setPointY(i,t.getPointY(i)-e.center.y)}transform(e){this.contours.forEach((t=>t.transform(e)))}intersects(e){if(!(e instanceof W))throw new Error("Expected 'poly' type is Polygon");(this.holes.length>0||e.holes.length)&&console.warn("Polygon intersection is for contours only. Holes are ignored.");let t=this.shape,i=e.shape;for(let e=0;e<2;e++){let s=0==e?t:i;for(let e=0;e<s.length;e++){let r=e+1==s.length?0:e+1,n=s.getPointX(e),a=s.getPointY(e),o=s.getPointX(r),l=s.getPointY(r)-a,h=n-o,u=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY;for(let e=0;e<t.length;e++){let i=l*t.getPointX(e)+h*t.getPointY(e);i<u&&(u=i),i>p&&(p=i)}let c=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY;for(let e=0;e<i.length;e++){let t=l*i.getPointX(e)+h*i.getPointY(e);t<c&&(c=t),t>d&&(d=t)}if(p<c||d<u)return!1}}return!0}containsPoint(e){let t=!1,i=this.shape;this.holes.length>0&&console.warn("Polygon intersection is for contours only. Holes are ignored.");for(let s=0,r=i.length-1;s<i.length;r=s++)i.getPointY(s)>e.y!=i.getPointY(r)>e.y&&e.x<(i.getPointX(r)-i.getPointX(s))*(e.y-i.getPointY(s))/(i.getPointY(r)-i.getPointY(s))+i.getPointX(s)&&(t=!t);return t}triangulate(){let e,t=[];for(let e of this.contours){let i=[];for(let t=0;t<e.length;t++){let s=new R(e.getPointX(t),e.getPointY(t));if(t>0){if(i.last.x==s.x&&i.last.y==s.y)continue;if(t==e.length-1&&i.first.x==s.x&&i.first.y==s.y)continue}i.push(s)}t.push(i)}try{e=new A(t.shift())}catch(e){return console.error(e),new Float32Array}for(let i of t)try{e.addHole(i)}catch(e){return console.error(e),new Float32Array}try{e.triangulate()}catch(e){return console.warn(e),new Float32Array}let i=e.getTriangles(),s=Float32Array.createSharedInstance(6*i.length),r=0;for(let e of i){let t=e.getPoints();for(let e of t)s[r++]=e.x,s[r++]=e.y}return s}convex(){return this.buildConvex(this.shape.points)}union(e){let t=Array.of(...this.shape.points,...e.shape.points);return this.buildConvex(t)}buildConvex(e){this.convexHullProducer||(this.convexHullProducer=new q(this.ArrayType));let t=this.convexHullProducer.monotoneChain(e);return this.ArrayType==Float32Array?W.createSharedInstance(t):W.createInstance(t)}simplify(e=.1){let t=new G([this],this.bounds);return t.subject=D.SimplifyPolygons(t.subject,k.pftNonZero),t.solution=D.CleanPolygons(t.subject,e*t.transform.scale),1==t.subject.length&&0==t.solution.first.length&&(t.solution=t.subject),W.toPolygonArray(t.toPaths())}simplifyRamerDouglasPeucker(e=.1){if(e<=0)throw new Error("epsilon expected value > 0");this.epsilon=e;let t=this.simplifyPath(this.shape),i=[];for(let e of this.holes){let t=this.simplifyPath(e);t.length>0&&i.push(t)}return this.ArrayType==Float32Array?W.createSharedInstance(t,i):W.createInstance(t,i)}simplifyPath(e){if(e.length<3)return e.points;let t=Array.of(...e.points,e.getPointX(0),e.getPointY(0)),i=this.simplifyPolyline(t);return i.length<8?t.slice(0,t.length-2):i.slice(0,i.length-2)}simplifyPolyline(e){if(e.length<4)return e;let t=0,i=0;for(let s=2;s<e.length-2;s+=2){let r=H(e[s],e[s+1],e[0],e[1],e[e.length-2],e[e.length-1]);r>t&&(i=s,t=r)}if(t>this.epsilon){let t=this.simplifyPolyline(e.slice(0,i+2)),s=this.simplifyPolyline(e.slice(i,e.length));return t.concat(s.slice(2,s.length))}return[e[0],e[1],e[e.length-2],e[e.length-1]]}toSVGPath(){return this.contours.map((e=>e.toSVGPath())).join(" ")}toJSON(){return{type:"Polygon",shape:this.shape.toJSON(),holes:this.holes.map((e=>e.toJSON())),holesDirection:this.holesDirection.name,vertices:this.verticesValue}}static fromJSON(e){if("Polygon"!=e.type)throw new Error(`Polygon deserialization failed. JSON type is ${e.type}, expected Polygon.`);let t=Y.fromJSON(e.shape),i=e.holes.map((e=>Y.fromJSON(e))),s=new W(t,i);return s.holesDirection=W.PointsDirection[e.holesDirection],s.vertices=e.vertices,s}static fromRect(e){return W.createInstance([e.left,e.top,e.right,e.top,e.right,e.bottom,e.left,e.bottom,e.left,e.top])}static createInstance(e,t=[]){return new W(Y.createInstance(e),t.map((e=>Y.createInstance(e))))}static createSharedInstance(e,t=[]){let i=new W(Y.createSharedInstance(e),t.map((e=>Y.createSharedInstance(e))));return Object.defineProperty(i,"encoding",{get:()=>i.shape.encoding,set:e=>{i.contours.forEach((t=>t.encoding=e))},enumerable:!0}),i}}Object.defineEnum(W,"PointsDirection",["CLOCKWISE","COUNTERCLOCKWISE"]);class Z{static ARRAY_TYPE=Array;#i;constructor(){this.keepAllData=!1,Object.defineProperty(this,"allData",{get:()=>{if(!this.keepAllData)throw new Error("All data is not accumulated. By default keepAllData property is false.");return this.#i||(this.#i=new this.constructor.ARRAY_TYPE),this.getOutput(this.#i,Z.OutputType.ALL_DATA)},enumerable:!0})}build(e,t=Z.OutputType.PROCESSOR,i=!0){return console.warn("use process instead"),this.process(e,t,i)}process(e,t=Z.OutputType.PROCESSOR,i=!0){let s;switch(t){case Z.OutputType.ADDITION:s=this.add(e,i);break;case Z.OutputType.PREDICTION:s=this.predict(e);break;case Z.OutputType.PROCESSOR:this.reset(),s=this.processImpl(e,t);break;default:throw new Error("Unexpected OutputType found. Allowed type is oneof(ADDITION, PREDICTION, PROCESSOR)")}return t!=Z.OutputType.PREDICTION&&this.keepAllData&&(this.#i||(this.#i=new this.constructor.ARRAY_TYPE),s instanceof W?this.#i.push(s):t==Z.OutputType.PROCESSOR?this.#i=s:this.#i.push(...s)),this.debug&&console.log(this.constructor.name,t.name,i,s),this.getOutput(s,t)}add(e,t=!1){return this.processImpl(e,Z.OutputType.ADDITION)}predict(e){return this.processImpl(e,Z.OutputType.PREDICTION)}processImpl(e,t){throw new Error("Abstract method processImpl(input, type) of DataSequenceProcessor should be implemented")}getOutput(e,t){return e}reset(){this.#i&&(this.#i=new this.constructor.ARRAY_TYPE)}}Object.defineEnum(Z,"OutputType",["ADDITION","PREDICTION","ALL_DATA","PROCESSOR"]);let K=h?h.default||globalThis.md5:{},Q={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],i=0;return this.mask.split("-").forEach((s=>{t.push(e.substring(i,i+s.length)),i+=s.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(K.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,i)=>{(i<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),i=this.toBytes(e);return t[0]=new Uint32Array(i.slice(0,4).buffer)[0],t[1]=new Uint32Array(i.slice(4,8).buffer)[0],t[2]=new Uint32Array(i.slice(8,12).buffer)[0],t[3]=new Uint32Array(i.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),i=this.toBytes(e);return t[0]=new BigUint64Array(i.slice(0,8).buffer)[0],t[1]=new BigUint64Array(i.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),i=this.toBytes(e);return t[0]=l.fromBytes(i.slice(0,8)),t[1]=l.fromBytes(i.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class ee{#s;constructor(e,t,i,s,r){1==i&&(t++,i=0),0==r&&(s--,r=1),Object.defineProperties(this,{spline:{value:e,enumerable:!0},segmentIndexStart:{value:t,enumerable:!0},segmentIndexEnd:{value:s,enumerable:!0},ts:{value:i,enumerable:!0},tf:{value:r,enumerable:!0}}),Object.defineProperty(this,"pointIndexStart",{value:t,enumerable:!0}),Object.defineProperty(this,"pointIndexEnd",{value:s+3,enumerable:!0}),Object.defineProperty(this,"length",{value:this.pointIndexEnd-this.pointIndexStart+1,enumerable:!0}),Object.defineProperty(this,"id",{get:()=>(this.#s||(this.#s=Q.generate()),this.#s),set:e=>{if(this.#s)throw new Error("id is immutable");this.#s=e}}),this.validate()}validate(){let e=this.length-3;if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative.`);if(this.pointIndexEnd>this.spline.length-1)throw new Error(`Invalid fragment pointIndexEnd ${this.pointIndexEnd} found. Last point in spline index is ${this.spline.length-1}.`);if(this.ts<0||this.ts>=1)throw new Error(`Invalid fragment ts ${this.ts} found. The value must be in the interval [0, 1).`);if(this.tf<=0||this.tf>1)throw new Error(`Invalid fragment tf ${this.tf} found. The value must be in the interval (0, 1].`);if(e<1)throw new Error(`Invalid fragment points range {${this.pointIndexStart}, ${this.pointIndexEnd}} found. At least 4 points are needed to define spline.`);if(1==e&&this.ts>this.tf)throw new Error(`Invalid fragment T range ${this.ts} - ${this.tf} found. Spline has only one segment and ts <= tf.`)}union(e){let t=[this,e];t.sort(ee.compare);let i=t.first,s=t.last,r=i.segmentIndexEnd,n=i.tf;if(1==n&&(r++,n=0),r!=s.segmentIndexStart||n!=s.ts)throw new Error(`Fragments ${i} and ${s} are not adjacent.`);let a=new ee(this.spline,i.segmentIndexStart,i.ts,s.segmentIndexEnd,s.tf);return a.#s=this.#s,this.inside&&(a.inside=this.inside),a}overlaps(e){if(e.spline!=this.spline)return!1;let t=e.segmentIndexStart<this.segmentIndexEnd||e.segmentIndexStart==this.segmentIndexEnd&&e.ts<=this.tf,i=e.segmentIndexEnd>this.segmentIndexStart||e.segmentIndexEnd==this.segmentIndexStart&&e.tf>=this.ts;return t&&i}toString(){return`fragment(${this.segmentIndexStart}, ${this.ts} - ${this.segmentIndexEnd}, ${this.tf})`}static compare(e,t){return e.segmentIndexStart<t.segmentIndexStart?-1:e.segmentIndexStart>t.segmentIndexStart?1:e.ts<t.ts?-1:e.ts>t.ts?1:0}static getInstance(e,t,i){return new ee(e,t.segmentIndex,t.t,i.segmentIndex,i.t)}}class te extends Y{constructor(e,t,i,s=[]){super(t,i,e),s.length>0&&!Object.isFrozen(s.first)&&s.forEach((e=>Object.freeze(e))),Object.defineProperty(this,"splineParameters",{value:Object.freeze(s),enumerable:!0});let r=new j(e,i);Object.defineProperty(this,"style",{get:()=>r.style,set:e=>r.style.reset(e),enumerable:!0}),Object.defineProperty(this,"color",{get:()=>this.style.color,set:e=>{if(!e)throw new Error("Spline color cannot be removed");if(!(e instanceof B))throw new Error("Expected value should be Color instance");"red"in this.pointProps&&(this.pointProps.red=e.red),"green"in this.pointProps&&(this.pointProps.green=e.green),"blue"in this.pointProps&&(this.pointProps.blue=e.blue),"alpha"in this.pointProps&&(this.pointProps.alpha=e.alpha)},enumerable:!0}),Object.defineProperty(this,"bounds",{get:()=>V.ofSpline(this,this.pointProps.scattering).ceil(),enumerable:!0}),this.validate()}validate(){let e=this.points instanceof Float32Array;if(super.validate(),!this.layout.includes(w.Property.X))throw new Error("Layout doesn't contains required properties X");if(!this.layout.includes(w.Property.Y))throw new Error("Layout doesn't contains required properties Y");if(e&&0==this.points.length)throw new Error("Empty spline is not allowed")}clone(){return new te(this.layout.slice(),this.points.clone(),Object.clone(this.pointProps),this.splineParameters.slice())}slice(e){let t=this.slicePoints(e.pointIndexStart,e.pointIndexEnd);return new te(this.layout.slice(),t,Object.clone(this.pointProps),this.splineParameters.slice())}getPoint(e){return super.getPoint(e,this.style)}getPointRef(e){return super.getPointRef(e,this.style)}getPointSegmentIndex(e){return this.splineParameters[e]?this.splineParameters[e].index:void 0}getPointT(e){return this.splineParameters[e]?this.splineParameters[e].t:void 0}getPointParameter(e){return this.splineParameters[e]}toJSON(){return{type:"InterpolatedSpline",layout:this.layout.map((e=>e.name)),points:$.encode(this.points,this.encoding),pointProps:this.pointProps,splineParameters:this.splineParameters}}static fromJSON(e){let t=$.decode(e.points);return new te(e.layout.map((e=>w.Property[e])),t,e.pointProps,e.splineParameters.map(p.fromJSON))}static fromRect(e,t){throw new Error("InterpolatedSpline.fromRect is not supported. Try Spline.fromRect and interpolate with particular Spline interpolator.")}static createInstance(e,t,i=[]){return new te(e,i,t)}static createSharedInstance(e,t,i,s){return new te(e,Float32Array.createSharedInstance(t),i,s)}}const ie=s.fromValues(0,-.5,1,-.5,1,0,-2.5,1.5,0,.5,2,-1.5,0,0,-.5,.5);class se extends Z{#r;#n;#a;constructor(e=!1,t=!1){super(),this.calculateDerivates=e,this.keepSplineParameters=t,this.state={segmentIndex:-1,lastPointPosition:void 0,lastPointSize:0}}initState(e){this.state.layout={},e.layout.forEach(((e,t)=>{this.state.layout[e.name]={index:t,polynomials:i.create()}})),this.keepSplineParameters?this.state.splineParameters?this.state.splineParameters.clear():this.state.splineParameters=[]:delete this.state.splineParameters,this.splineLayout=e.layout,this.pathPointProps=Object.clone(e.pointProps),this.scattering&&(this.pathPointProps.scattering=this.scattering),this.layout=this.calculateDerivates?e.layout.concat([w.Property.D_X,w.Property.D_Y]):e.layout,this.state.ready=!0}predict(e){if(!e)return[];this.state.ready||this.initState(e),this.#n?this.#n.points.clear():this.#n=te.createInstance(this.layout,this.pathPointProps),this.path=this.#n;let t=Object.clone(this.state);return delete this.state.splineParameters,this.resetState(),this.discretize(e),this.state=t,this.path.points}processImpl(e,t){if(!e)return[];let i;return e instanceof ee&&(i=e,e=i.spline),this.state.ready||this.initState(e),t==se.OutputType.ADDITION?(this.#r?this.#r.points.clear():this.#r=te.createInstance(this.layout,this.pathPointProps),this.path=this.#r):(this.#a=te.createInstance(this.layout,this.pathPointProps),this.path=this.#a),this.discretize(e,i),this.path.points}getOutput(e,t){if(0!=e.length){if(t==se.OutputType.PROCESSOR||t==se.OutputType.ALL_DATA){let t=this.state.splineParameters;return t&&(t=t.slice()),te.createSharedInstance(this.layout,e,this.pathPointProps,t)}return this.path}}calculateInterpolatedPoint(e,t,s){this.initState(e);let r=new w(0,0,this.splineLayout.includes(w.Property.Z)?0:void 0),n=i.fromValues(1,s,s*s,s*s*s);return this.calculatePolynomials(e,t),this.splineLayout.forEach((e=>{let t=i.dot(this.state.layout[e.name].polynomials,n);r[_.getPropName(e.name)]=t})),r}discretize(e,t){throw new Error("This method is abstract and should be implemented")}storeLastPoint(e,t=0){this.state.lastPointPosition=new d(this.getPropValue(w.Property.X,e,t),this.getPropValue(w.Property.Y,e,t),this.getPropValue(w.Property.Z,e,t)),this.state.lastPointSize=this.getPropValue(w.Property.SIZE,e,t)}getPropValue(e,t,i=0){return this.state.layout[e.name]?t[i+this.state.layout[e.name].index]:void 0}calculatePolynomials(e,t){let s=e.points,r=this.splineLayout.length*(t+0),n=this.splineLayout.length*(t+1),a=this.splineLayout.length*(t+2),o=this.splineLayout.length*(t+3);this.splineLayout.forEach(((e,t)=>{let l=i.fromValues(s[r+t],s[n+t],s[a+t],s[o+t]);i.transformMat4(this.state.layout[e.name].polynomials,l,ie)}))}samplePoint(e){let t=[],s=i.fromValues(1,e,e*e,e*e*e);return this.splineLayout.forEach((e=>{let r=i.dot(this.state.layout[e.name].polynomials,s);t.push(r)})),this.calculateDerivates&&(t.push(this.getDerivativeOf(this.state.layout.X.polynomials,s)),t.push(this.getDerivativeOf(this.state.layout.Y.polynomials,s))),t}getDerivativeOf(e,t){let s=i.fromValues(e[1],2*e[2],3*e[3],0);return i.dot(s,t)}keepSegmentT(e){this.state.splineParameters&&this.state.splineParameters.push(new p(this.state.segmentIndex,e))}resetState(){this.state.segmentIndex=-1}reset(){super.reset(),this.state.ready=!1,this.state.lastPointPosition=void 0,this.state.lastPointSize=0,this.resetState(),this.#r=null,this.#n=null,this.#a=null}}class re extends se{constructor(e,t){super(e,t),this.state.lastSegmentIndex=-1,this.state.lastPointRotation=0,this.state.lastPointT=0,this.state.absAccumulatedErrorPos=0,this.state.absAccumulatedErrorS=0,this.setT=new v,this.samples=[],Object.defineProperty(this,"errorThreshold",{get:()=>this.error,set:e=>{this.error=e,this.errorDistSq=this.error*this.error,this.error10=10*this.error},enumerable:!0}),this.errorThreshold=.15}discretize(e,t){let i=this.path.points,s=0,r=e.segmentsCount-1,n=e.ts,a=e.tf;t&&(s=t.segmentIndexStart,r=t.segmentIndexEnd,n=t.ts,a=t.tf,this.state.segmentIndex=s-1);for(let t=s;t<r+1;t++){this.state.segmentIndex++,this.calculatePolynomials(e,t);let s=this.calculateTValues(t==r,n,a);i.push(...this.samplePoints(s)),s.length>0&&(this.resetAccumulatedErrors(),this.storeLastPoint(i))}}samplePoints(e){return this.samples.clear(),e.toArray().forEach((e=>{this.keepSegmentT(e),this.samples.push(...this.samplePoint(e))})),this.samples}storeLastPoint(e){let t=e.length-this.layout.length;super.storeLastPoint(e,t),this.state.lastPointRotation=this.getPropValue(w.Property.ROTATION,e,t),this.state.lastPointT=this.setT.max(),this.state.lastSegmentIndex=this.state.segmentIndex}calculateTValues(e,t,i){let s=0==this.state.segmentIndex?t:0,r=e?i:1;return this.setT.clear(),this.getTForPos(s,r),this.state.layout.SIZE&&this.getTForCubic(s,r,this.state.layout.SIZE.polynomials,this.error),this.mustAddStartT()&&this.setT.add(s),e&&this.setT.add(r),this.state.layout.ROTATION&&this.getTForRotation(s,r),this.setT}mustAddStartT(){if(this.state.lastSegmentIndex<0)return!0;let e=this.state.lastPointT-(this.state.segmentIndex-this.state.lastSegmentIndex),t=this.setT.length>0?this.setT.min():1,i=this.getPosErrorAtT0(t,this.state.lastPointPosition);if(this.state.absAccumulatedErrorPos+=Math.abs(i),this.state.layout.SIZE){let i=this.getErrorAtT0(this.state.layout.SIZE.polynomials,t,e,this.state.lastPointSize);this.state.absAccumulatedErrorS+=Math.abs(i)}return this.state.absAccumulatedErrorPos>this.errorDistSq||this.state.absAccumulatedErrorS>this.error}getPosErrorAtT0(e,t){let i=this.getTPoint(e),s=this.getTPoint(0);return this.minDistanceSq(t,i,s)}getErrorAtT0(e,t,i,s){let r=i,n=s,a=t,o=this.cubicCalc(e,a),l=this.cubicCalc(e,0),h=n+(0-r)*(o-n)/(a-r);return Math.abs(l-h)}getTForPos(e,t){let i=this.getTPoint(e),s=this.getTPoint(t),r=this.subdividePos(i,s);if(r.split)this.subdivideRecursivePos(i,r),this.setT.add(r.t),this.subdivideRecursivePos(r,s);else{let e=this.subdividePos(i,r),t=this.subdividePos(r,s);e.split&&(this.subdivideRecursivePos(i,e),this.setT.add(e.t),this.subdivideRecursivePos(e,r)),(e.split||t.split)&&this.setT.add(r.t),t.split&&(this.subdivideRecursivePos(r,t),this.setT.add(t.t),this.subdivideRecursivePos(t,s))}}subdivideRecursivePos(e,t){let i=this.subdividePos(e,t);i.split&&(this.subdivideRecursivePos(e,i),this.setT.add(i.t),this.subdivideRecursivePos(i,t))}subdividePos(e,t){let i=.5*(e.t+t.t),s=this.getTPoint(i),r=this.minDistanceSq(e,t,s),n=e.add(t).scaleSelf(.5),a=s.subtract(n).absSelf();return s.split=r>this.errorDistSq||a.x>this.error10||a.y>this.error10,this.state.layout.Z&&(s.split=s.split||a.z>this.error10),s}getTForCubic(e,t,i,s){let r={v:this.cubicCalc(i,e),t:e},n={v:this.cubicCalc(i,t),t:t},a=this.subdivide(r,n,i);if(a.diff>s)this.subdivideRecursive(r,a,i,s),this.setT.add(a.t),this.subdivideRecursive(a,n,i,s);else{let e=this.subdivide(r,a,i),t=this.subdivide(a,n,i);e.diff>s&&(this.subdivideRecursive(r,e,i,s),this.setT.add(e.t),this.subdivideRecursive(e,a,i,s)),(e.diff>s||t.diff>s)&&this.setT.add(a.t),t.diff>s&&(this.subdivideRecursive(a,t,i,s),this.setT.add(t.t),this.subdivideRecursive(t,n,i,s))}}subdivideRecursive(e,t,i,s){let r=this.subdivide(e,t,i);r.diff>s&&(this.subdivideRecursive(e,r,i,s),this.setT.add(r.t),this.subdivideRecursive(r,t,i,s))}subdivide(e,t,i){let s=.5*(e.t+t.t),r=this.cubicCalc(i,s),n=.5*(e.v+t.v);return{v:r,t:s,diff:Math.abs(r-n)}}getTForRotation(e,t){let i=this.state.layout.ROTATION.polynomials,s=this.state.lastPointRotation;this.state.lastSegmentIndex<0&&(s=this.cubicCalc(i,e));let r=.25*(t-e);for(let t=0;t<4;t++){let n=e+t*r,a=this.cubicCalc(i,n);Math.abs(a-s)>.06&&(this.setT.add(n),s=a)}}minDistanceSq(e,t,i){let s=i.vec,r=s.squaredDistance(e.value,t.value);if(0==r)retu...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /src/Models/OAuth2.php line 153
- Likely real
- Uncertain, 36% confidence
Calling `unserialize()` with user input in the pattern can lead to arbitrary code execution. Consider using JSON or structured data approaches (e.g. Google Protocol Buffers).
return $this->attributes['access_token'] ? unserialize($this->attributes['access_token'], ['allowed_classes' => [AccessToken::class]]) : null; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /src/Models/OAuth2.php line 195
- Likely real
- Uncertain, 36% confidence
Calling `unserialize()` with user input in the pattern can lead to arbitrary code execution. Consider using JSON or structured data approaches (e.g. Google Protocol Buffers).
$access_token = $this->access_token ? unserialize($this->access_token, ['allowed_classes' => [AccessToken::class]]) : null; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /modules/aggiornamenti/src/Controlli/IntegritaFile.php line 137
- Likely real
- Probably noise, 21% confidence
Using user input when deleting files with `unlink()` is potentially dangerous. A malicious actor could use this to modify or access files they have no right to.
? (unlink($file_path) ? tr('File _FILE_ rimosso con successo', ['_FILE_' => $record['nome_file']]) : tr('Errore nella rimozione del file _FILE_', ['_FILE_' => $record['nome_file']])) -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /modules/aggiornamenti/src/Controlli/IntegritaFile.php line 243
- Likely real
- Probably noise, 20% confidence
Using user input when deleting files with `unlink()` is potentially dangerous. A malicious actor could use this to modify or access files they have no right to.
if (unlink($file_path)) { -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /src/Backup.php line 275
- Likely real
- Probably noise, 20% confidence
Using user input when deleting files with `unlink()` is potentially dangerous. A malicious actor could use this to modify or access files they have no right to.
unlink($temp_path); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /src/Backup.php line 279
- Likely real
- Probably noise, 20% confidence
Using user input when deleting files with `unlink()` is potentially dangerous. A malicious actor could use this to modify or access files they have no right to.
unlink($backup_path); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /lib/util.php line 569
- Likely real
- Probably noise, 20% confidence
Using user input when deleting files with `unlink()` is potentially dangerous. A malicious actor could use this to modify or access files they have no right to.
unlink($file); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /update/v2_4_17/recupero_date_movimenti.php line 63
- Likely real
- Probably noise, 20% confidence
Using user input when deleting files with `unlink()` is potentially dangerous. A malicious actor could use this to modify or access files they have no right to.
unlink($file); -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 14% confidence
Loose version constraint: 'js-md5^0.9.0' — attacker could push malicious update
js-md5:^0.9.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 13% confidence
Loose version constraint: 'md5-file^5.0.0' — attacker could push malicious update
md5-file:^5.0.0 -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("js-ext");var e=require("js-md5"),t=require("long"),r=require("gl-matrix"),i=require("poly2tri"),s=require("clipper-lib"),n=require("rbush"),o=require("jszip"),a=require("protobufjs");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=h(e),c=l(t),p=h(i),u=h(s),f=l(n),m=h(o),g=h(a);class y{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let b=d?d.default||globalThis.md5:{},E={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(b.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),r=this.toBytes(e);return t[0]=c.default.fromBytes(r.slice(0,8)),t[1]=c.default.fromBytes(r.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class P{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=P.Algorithm.MD5;else if("function"==typeof this.buildURI)t=P.Algorithm.URI;else if(t=P.Algorithm.GUID,e&&!E.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=P.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==P.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return b(e)}return this.algorithm==P.Algorithm.URI?this.buildURI():E.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(P,"Algorithm",["GUID","MD5","URI"]);class I extends P{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,P.buildMD5Tokens(this.props)]}}Object.defineEnum(I,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class S{constructor(){this.phase=S.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=S.Phase.END||e==S.Phase.BEGIN)&&((this.phase!=S.Phase.BEGIN||e==S.Phase.UPDATE||e==S.Phase.END)&&((this.phase!=S.Phase.UPDATE||e==S.Phase.UPDATE||e==S.Phase.END)&&(e==S.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=S.Phase.END}}Object.defineEnum(S,"Phase",["BEGIN","UPDATE","END"]);class w{constructor(e,t,i,s){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let n=[e,t];isFinite(i)&&(n.push(i),isFinite(s)&&n.push(s)),this.value=n.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==n.length?this.vec=r.vec2:3==n.length?(this.vec=r.vec3,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=r.vec4,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),w.fromPoint(t)}addSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),w.fromPoint(t)}subtractSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),w.fromPoint(t)}multiplySelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof w||(e=w.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),w.fromPoint(t)}divideSelf(e){return e instanceof w||(e=w.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),w.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new w(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),w.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return w.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new w(e[0],e[1],e[2],e[3]):new w(e.x,e.y,e.z,e.w)}}class x{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof x))throw new TypeError("rect must be instance of RectGL");return e?x.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof x))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=x.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return x.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return x.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=w.fromPoint({x:this.left,y:this.bottom}).transform(e),r=w.fromPoint({x:this.right,y:this.bottom}).transform(e),i=w.fromPoint({x:this.left,y:this.top}).transform(e),s=w.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return x.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let i=w.fromPoint({x:this.left,y:this.bottom}).transform(e),s=w.fromPoint({x:this.right,y:this.bottom}).transform(e),n=w.fromPoint({x:this.left,y:this.top}).transform(e),o=w.fromPoint({x:this.right,y:this.top}).transform(e);t=r.quat2.fromValues(i.x,i.y,s.x,s.y,n.x,n.y,o.x,o.y)}else t=r.quat2.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new x(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new w(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of x.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return x.ofEdges(f,g,m,y)}}Object.defineProperty(x,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class v{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?v.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=v.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return v.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return v.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=w.fromPoint({x:this.left,y:this.top}).transform(e),r=w.fromPoint({x:this.right,y:this.top}).transform(e),i=w.fromPoint({x:this.left,y:this.bottom}).transform(e),s=w.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return v.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new x(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof x))throw new TypeError("rect must be instance of RectGL");return new v(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new v(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?v.fromString(e):new v(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return v.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=x.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return v.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new v(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const R={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},T=R.m11,A=R.m12,C=R.m21,O=R.m22,D=R.m41,k=R.m42;class N{constructor(e=r.mat4.create(),t=N.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let i=function(e,t){let r=R[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[T],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[A],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[C],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[O],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[D],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[k],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[D],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[k],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:i.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:i.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:i.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:i.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:i.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:i.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:i.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:i.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:i.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:i.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:i.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:i.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:i.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:i.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:i.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:i.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new N(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(N.fromTranslate(e))}translateSelf(e){this.multiplySelf(N.fromTranslate(e))}rotate(e,t){return this.multiply(N.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(N.fromRotate(e,t))}scale(e,t){return this.multiply(N.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(N.fromScale(e,t))}multiply(e){return this.multiplicationType==N.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=r.mat4.create();return r.mat4.multiply(t,e.toFloat32Array(),this.value),new N(t,this.multiplicationType)}postMultiply(e){let t=r.mat4.create();return r.mat4.multiply(t,this.value,e.toFloat32Array()),new N(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==N.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){r.mat4.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){r.mat4.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=r.mat4.create();return r.mat4.invert(e,this.value),new N(e,this.multiplicationType)}invertSelf(){r.mat4.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return w.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let i=r.mat4.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(i[0]=parseFloat(e[0]),i[1]=parseFloat(e[1]),i[2]=parseFloat(e[2]),i[3]=parseFloat(e[3]),i[4]=parseFloat(e[4]),i[5]=parseFloat(e[5]),i[6]=parseFloat(e[6]),i[7]=parseFloat(e[7]),i[8]=parseFloat(e[8]),i[9]=parseFloat(e[9]),i[10]=parseFloat(e[10]),i[11]=parseFloat(e[11]),i[12]=parseFloat(e[12]),i[13]=parseFloat(e[13]),i[14]=parseFloat(e[14]),i[15]=parseFloat(e[15])):(i[T]=parseFloat(e[0]),i[A]=parseFloat(e[1]),i[C]=parseFloat(e[2]),i[O]=parseFloat(e[3]),i[D]=parseFloat(e[4]),i[k]=parseFloat(e[5]))}return new N(i,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof N)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new N(e,t);if("string"==typeof e)return N.fromString(e,t);let i=r.mat4.create(),s=Object.assign({},e);return isFinite(e.a)&&(s.m11=e.a),isFinite(e.b)&&(s.m12=e.b),isFinite(e.c)&&(s.m21=e.c),isFinite(e.d)&&(s.m22=e.d),isFinite(e.tx)?s.m41=e.tx:isFinite(e.e)?s.m41=e.e:isFinite(e.dx)&&(s.m41=e.dx),isFinite(e.ty)?s.m42=e.ty:isFinite(e.f)?s.m42=e.f:isFinite(e.dy)&&(s.m42=e.dy),isFinite(s.m11)&&(i[0]=s.m11),isFinite(s.m12)&&(i[1]=s.m12),isFinite(s.m13)&&(i[2]=s.m13),isFinite(s.m14)&&(i[3]=s.m14),isFinite(s.m21)&&(i[4]=s.m21),isFinite(s.m22)&&(i[5]=s.m22),isFinite(s.m23)&&(i[6]=s.m23),isFinite(s.m24)&&(i[7]=s.m24),isFinite(s.m31)&&(i[8]=s.m31),isFinite(s.m32)&&(i[9]=s.m32),isFinite(s.m33)&&(i[10]=s.m33),isFinite(s.m34)&&(i[11]=s.m34),isFinite(s.m41)&&(i[12]=s.m41),isFinite(s.m42)&&(i[13]=s.m42),isFinite(s.m43)&&(i[14]=s.m43),isFinite(s.m44)&&(i[15]=s.m44),new N(i,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return N.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),N.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),N.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=N.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=N.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return N.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let i=r.mat4.create();return r.mat4.multiply(i,e.value,t.value),new N(i)}}N.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let M={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(M.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class L{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let _={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof y))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==_.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==_.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=_.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==_.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=S.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:S.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return I.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=_.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=_.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:N.fromMatrix(i);let s=w.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=v.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=w.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(_.PointerType.MOUSE)||(this.stop(_.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(_.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new L(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},F={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof y))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==y.prototype.resize)return;let e=F.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=F.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?F.ResizeReason.ZOOM_IN:F.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=M.debounce((()=>{e==F.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?F.ResizeReason.SCREEN_SIZE_INCREASED:F.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=F.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=y.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==F.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==F.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=S.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:S.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return I.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:N.fromMatrix(i);let s=w.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=v.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=w.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==F.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?F.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new L(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(F,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(_.suppressKeys=F.suppressKeys,_.ResizeReason=F.ResizeReason,_.attachResize=F.attachResize,_.dettachResize=F.dettachResize,F=_);var B=F;class U extends w{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||U.defaults.size,this.rotation=i.rotation||U.defaults.rotation,this.scaleX=i.scaleX||U.defaults.scaleX,this.scaleY=i.scaleY||U.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||U.defaults.scaleZ:void 0,this.offsetX=i.offsetX||U.defaults.offsetX,this.offsetY=i.offsetY||U.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||U.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new U(0,0,e.includes(U.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>U.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||U.defaults.size,this.rotation=s.rotation||i.rotation||U.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||U.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||U.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||U.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||U.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||U.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||U.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case U.Property.X:return this.x;case U.Property.Y:return this.y;case U.Property.Z:return this.z;case U.Property.RED:return this.red;case U.Property.GREEN:return this.green;case U.Property.BLUE:return this.blue;case U.Property.ALPHA:return this.alpha;case U.Property.SIZE:return this.size;case U.Property.ROTATION:return this.rotation;case U.Property.SCALE_X:return this.scaleX;case U.Property.SCALE_Y:return this.scaleY;case U.Property.SCALE_Z:return this.scaleZ;case U.Property.OFFSET_X:return this.offsetX;case U.Property.OFFSET_Y:return this.offsetY;case U.Property.OFFSET_Z:return this.offsetZ;case U.Property.D_X:return this.dX;case U.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){U.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case U.Property.X:e.x=r;break;case U.Property.Y:e.y=r;break;case U.Property.Z:e.z=r;break;case U.Property.RED:e.red=r;break;case U.Property.GREEN:e.green=r;break;case U.Property.BLUE:e.blue=r;break;case U.Property.ALPHA:e.alpha=r;break;case U.Property.SIZE:e.size=r;break;case U.Property.ROTATION:e.rotation=r;break;case U.Property.SCALE_X:e.scaleX=r;break;case U.Property.SCALE_Y:e.scaleY=r;break;case U.Property.SCALE_Z:e.scaleZ=r;break;case U.Property.OFFSET_X:e.offsetX=r;break;case U.Property.OFFSET_Y:e.offsetY=r;break;case U.Property.OFFSET_Z:e.offsetZ=r;break;case U.Property.D_X:e.dX=r;break;case U.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof N))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return U.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(U,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let j,G={version:"1.5.0"};Object.defineEnum(G,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(G,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(G,"TypeGL",["WEB","STACK"]),function(e){let t,r="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof require;t="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":r?"NODE":"SHELL";let i="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",s="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(G,"commonJS",{value:r,enumerable:!0}),Object.defineProperty(G,"type",{value:G.Type[t],enumerable:!0}),Object.defineProperty(G,"type2D",{value:G.Type2D[i],enumerable:!0}),Object.defineProperty(G,"typeGL",{value:G.TypeGL[s],enumerable:!0})}(),G.commonJS&&(j=require("systeminformation"));var $=j;class Y extends P{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",P.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new Y;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=G.version,t.props["runtime.type"]=G.type.name,void 0===$)t.props["user.agent"]=navigator.userAgent;else{let e=await $.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const X={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class z{static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=z.getUnitMetric(e);return i!=z.Metric.NORMALIZED&&i!=z.Metric.LOGICAL&&(r=z[V[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*z[V[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*z[t.name][r.name]/i}static getUnitMetric(e){switch(e){case z.Unit.METER:case z.Unit.CENTIMETER:case z.Unit.MILLIMETER:case z.Unit.MICROMETER:case z.Unit.INCH:case z.Unit.DP:case z.Unit.PICA:case z.Unit.POINT:case z.Unit.DIP:case z.Unit.DPI:return z.Metric.LENGTH;case z.Unit.SECOND:case z.Unit.MILLISECOND:case z.Unit.MICROSECOND:case z.Unit.NANOSECOND:return z.Metric.TIME;case z.Unit.RADIAN:case z.Unit.DEGREE:return z.Metric.ANGLE;case z.Unit.NEWTON:return z.Metric.FORCE;case z.Unit.NORMALIZED:return z.Metric.NORMALIZED;case z.Unit.LOGICAL:return z.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case z.Metric.LENGTH:return[z.Unit.METER,z.Unit.CENTIMETER,z.Unit.MILLIMETER,z.Unit.MICROMETER,z.Unit.INCH,z.Unit.DP,z.Unit.PICA,z.Unit.POINT,z.Unit.DIP,z.Unit.DPI];case z.Metric.TIME:return[z.Unit.SECOND,z.Unit.MILLISECOND,z.Unit.MICROSECOND,z.Unit.NANOSECOND];case z.Metric.ANGLE:return[z.Unit.RADIAN,z.Unit.DEGREE];case z.Metric.FORCE:return[z.Unit.NEWTON];case z.Metric.NORMALIZED:return[z.Unit.NORMALIZED];case z.Metric.LOGICAL:return[z.Unit.LOGICAL];case z.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return V[e.name]}static convertValue(e,t,r){return e*z[t.name][r.name]}}Object.defineEnum(z,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum(z,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const V=Object.freeze({LENGTH:z.Unit.METER,TIME:z.Unit.SECOND,FORCE:z.Unit.NEWTON,ANGLE:z.Unit.RADIAN,NORMALIZED:z.Unit.NORMALIZED,LOGICAL:z.Unit.LOGICAL});!function(){let e=z.getMetricUnits(z.Metric.LENGTH).filter((e=>!(e.name in X)));for(let t of e){let e=z.Units[t.name];for(let t in X)e[t]=e.INCH*X[t]}for(let t in X){let r={};for(let i of e)r[i.name]=z.Units.INCH[i.name]/X[t];for(let e in X)r[e]=X[e]/X[t];z.Units[t]=r}for(let e in z.Units)z[e]=z.Units[e]}(),Object.freeze(z);class H extends P{constructor(e,t,r,i,s){if(super(),t==H.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=H.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=z.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==H.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return M.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(H.Type).find((t=>H.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case H.Type.X:case H.Type.Y:case H.Type.Z:case H.Type.RADIUS_X:case H.Type.RADIUS_Y:t.unit=z.Unit.DIP;break;case H.Type.TIMESTAMP:t.unit=z.Unit.MILLISECOND;break;case H.Type.PRESSURE:t.unit=z.Unit.NORMALIZED,t.min=0,t.max=1;break;case H.Type.ALTITUDE:t.unit=z.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case H.Type.AZIMUTH:t.unit=z.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case H.Type.ROTATION:t.unit=z.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=z.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new H(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=H.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=z.getChannelResolution(r.unit),s=new H(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=H.Type.X&&e!=H.Type.Y||t.type!=I.Type.MOUSE||(s.precision=0),s}}H.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),H.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},H.Metric=z.Metric;class Z extends P{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==H.Type.X||e.type==H.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new Z(e,t);return r.channels=H.defaults[t.type.name].map((e=>H.createDefaultInstance(H.Type[e],t))),r}}class q extends P{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new q;return r.addContext(Z.createDefaultInstance(e,t)),r}}class W extends P{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=q.createDefaultInstance(t,r);return new W(e,i)}}class K{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${K.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class J extends P{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=K.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=J.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(J,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class Q{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=M.getPropName(t.name),i=e[r];if(t.type==H.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==H.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=M.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==H.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class ee extends P{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",P.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof ee))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new I(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return q.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=I.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new W(this.environment,r);r.inkChannelsContext.layout=ee.getLayout(e),this.sensorData=new J(i),this.sensorData.add(new Q(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(H.Type).forEach((r=>{let i,s=H.Type[r];i=s==H.Type.ALTITUDE?"tiltX":s==H.Type.AZIMUTH?"tiltY":M.getPropName(r),ee.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===$)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await $.system(),r=await $.cpu(),i=await $.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await Y.createInstance(e),t}}let te={};if(G.type==G.Type.WEB)te.Image=globalThis.Image,te.ImageData=globalThis.ImageData,te.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(te.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},te.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(te.OffscreenCanvas=globalThis.OffscreenCanvas,te.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)te.Image=globalThis.Image,te.ImageData=globalThis.ImageData,te.OffscreenCanvas=globalThis.OffscreenCanvas,te.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(G.commonJS){const{Canvas:e,CanvasRenderingContext2D:t,Image:r,ImageData:i}=require("canvas");te.Image=r,te.ImageData=i,te.OffscreenCanvas=e,te.OffscreenCanvasRenderingContext2D=t}else console.warn(`Current env - ${G.type.name}, do not provides OffscreenCanvas support`);function re(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}te.CanvasRenderingContext2D&&(te.CanvasRenderingContext2D.prototype.clearCanvas=re),te.OffscreenCanvasRenderingContext2D&&(te.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=re);const{Image:ie,ImageData:se,OffscreenCanvas:ne,CanvasRenderingContext2D:oe,OffscreenCanvasRenderingContext2D:ae}=te;let le;class he{#r={};constructor(...e){if(le)throw new Error("URIResolver instance already available");le=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(he,"instance",{get:()=>le});class de{static encode(e,t=de.Encoding.AUTO){let r;if(t==de.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?de.Encoding.NONE:de.Encoding.ARRAY:de.Encoding.BUFFER:t==de.Encoding.ARRAY&&e instanceof Array&&(t=de.Encoding.NONE),t==de.Encoding.NONE)r=e;else if(t==de.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case de.Encoding.BUFFER:r=i.toJSON();break;case de.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=de.Encoding[e.encoding];if(r==de.Encoding.NONE)t=e.content;else if(r==de.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case de.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case de.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(de,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class ce{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||M.isValidURL(e)||ce.repetitionsCache.has(e)||(ce.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!he.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=he.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=de.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return de.isTypedArrayData(t)&&(t=de.decode(t)),new ce(e.name,t)}static getInstance(e,t){return new ce(t,e)}}class pe{constructor(e){M.isValidURL(e)||(ce.repetitionsCache.has(e)||(ce.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class ue{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=ue.defaults.CIRCLE_PRECISION,t=ue.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return ue.createEllipse(e,t,t,r)}static createEllipse(e=ue.defaults.ELLIPSE_PRECISION,t=ue.defaults.ELLIPSE_RADIUS_X,r=ue.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=ue.defaults.STAR_POINTS,t=ue.defaults.STAR_INTERNAL_RADIUS,r=ue.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let fe=p?p...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.cjs.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
import{createRequire as e}from"module";const t=e(import.meta.url);t.resolve.paths(".")[0];import"js-ext";import*as r from"js-md5";import i from"long";import{vec2 as s,vec3 as n,vec4 as o,quat2 as a,mat4 as l,mat2d as h}from"gl-matrix";import*as d from"poly2tri";import*as c from"clipper-lib";import p from"rbush";import*as u from"jszip";import*as f from"protobufjs";var m="1.5.0";class g{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let y=r?r.default||globalThis.md5:{},b={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(y.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let t=new Array(2),r=this.toBytes(e);return t[0]=i.fromBytes(r.slice(0,8)),t[1]=i.fromBytes(r.slice(8)),t},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class E{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=E.Algorithm.MD5;else if("function"==typeof this.buildURI)t=E.Algorithm.URI;else if(t=E.Algorithm.GUID,e&&!b.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=E.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==E.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return y(e)}return this.algorithm==E.Algorithm.URI?this.buildURI():b.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(E,"Algorithm",["GUID","MD5","URI"]);class P extends E{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,E.buildMD5Tokens(this.props)]}}Object.defineEnum(P,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class I{constructor(){this.phase=I.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=I.Phase.END||e==I.Phase.BEGIN)&&((this.phase!=I.Phase.BEGIN||e==I.Phase.UPDATE||e==I.Phase.END)&&((this.phase!=I.Phase.UPDATE||e==I.Phase.UPDATE||e==I.Phase.END)&&(e==I.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=I.Phase.END}}Object.defineEnum(I,"Phase",["BEGIN","UPDATE","END"]);class S{constructor(e,t,r,i){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let a=[e,t];isFinite(r)&&(a.push(r),isFinite(i)&&a.push(i)),this.value=a.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==a.length?this.vec=s:3==a.length?(this.vec=n,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=o,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),S.fromPoint(t)}addSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),S.fromPoint(t)}subtractSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),S.fromPoint(t)}multiplySelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof S||(e=S.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),S.fromPoint(t)}divideSelf(e){return e instanceof S||(e=S.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),S.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new S(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),S.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return S.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new S(e[0],e[1],e[2],e[3]):new S(e.x,e.y,e.z,e.w)}}class w{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof w))throw new TypeError("rect must be instance of RectGL");return e?w.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof w))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=w.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return w.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return w.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=S.fromPoint({x:this.left,y:this.bottom}).transform(e),r=S.fromPoint({x:this.right,y:this.bottom}).transform(e),i=S.fromPoint({x:this.left,y:this.top}).transform(e),s=S.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return w.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let r=S.fromPoint({x:this.left,y:this.bottom}).transform(e),i=S.fromPoint({x:this.right,y:this.bottom}).transform(e),s=S.fromPoint({x:this.left,y:this.top}).transform(e),n=S.fromPoint({x:this.right,y:this.top}).transform(e);t=a.fromValues(r.x,r.y,i.x,i.y,s.x,s.y,n.x,n.y)}else t=a.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new w(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new S(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of w.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return w.ofEdges(f,g,m,y)}}Object.defineProperty(w,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class x{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?x.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=x.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return x.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return x.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=S.fromPoint({x:this.left,y:this.top}).transform(e),r=S.fromPoint({x:this.right,y:this.top}).transform(e),i=S.fromPoint({x:this.left,y:this.bottom}).transform(e),s=S.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return x.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new w(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof w))throw new TypeError("rect must be instance of RectGL");return new x(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new x(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?x.fromString(e):new x(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return x.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=w.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return x.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new x(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const v={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},R=v.m11,T=v.m12,A=v.m21,C=v.m22,O=v.m41,D=v.m42;class k{constructor(e=l.create(),t=k.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let r=function(e,t){let r=v[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[R],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[T],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[A],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[C],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[O],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[D],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[O],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[D],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:r.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:r.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:r.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:r.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:r.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:r.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:r.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:r.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:r.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:r.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new k(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(k.fromTranslate(e))}translateSelf(e){this.multiplySelf(k.fromTranslate(e))}rotate(e,t){return this.multiply(k.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(k.fromRotate(e,t))}scale(e,t){return this.multiply(k.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(k.fromScale(e,t))}multiply(e){return this.multiplicationType==k.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=l.create();return l.multiply(t,e.toFloat32Array(),this.value),new k(t,this.multiplicationType)}postMultiply(e){let t=l.create();return l.multiply(t,this.value,e.toFloat32Array()),new k(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==k.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){l.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){l.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=l.create();return l.invert(e,this.value),new k(e,this.multiplicationType)}invertSelf(){l.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return S.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let r=l.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(r[0]=parseFloat(e[0]),r[1]=parseFloat(e[1]),r[2]=parseFloat(e[2]),r[3]=parseFloat(e[3]),r[4]=parseFloat(e[4]),r[5]=parseFloat(e[5]),r[6]=parseFloat(e[6]),r[7]=parseFloat(e[7]),r[8]=parseFloat(e[8]),r[9]=parseFloat(e[9]),r[10]=parseFloat(e[10]),r[11]=parseFloat(e[11]),r[12]=parseFloat(e[12]),r[13]=parseFloat(e[13]),r[14]=parseFloat(e[14]),r[15]=parseFloat(e[15])):(r[R]=parseFloat(e[0]),r[T]=parseFloat(e[1]),r[A]=parseFloat(e[2]),r[C]=parseFloat(e[3]),r[O]=parseFloat(e[4]),r[D]=parseFloat(e[5]))}return new k(r,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof k)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new k(e,t);if("string"==typeof e)return k.fromString(e,t);let r=l.create(),i=Object.assign({},e);return isFinite(e.a)&&(i.m11=e.a),isFinite(e.b)&&(i.m12=e.b),isFinite(e.c)&&(i.m21=e.c),isFinite(e.d)&&(i.m22=e.d),isFinite(e.tx)?i.m41=e.tx:isFinite(e.e)?i.m41=e.e:isFinite(e.dx)&&(i.m41=e.dx),isFinite(e.ty)?i.m42=e.ty:isFinite(e.f)?i.m42=e.f:isFinite(e.dy)&&(i.m42=e.dy),isFinite(i.m11)&&(r[0]=i.m11),isFinite(i.m12)&&(r[1]=i.m12),isFinite(i.m13)&&(r[2]=i.m13),isFinite(i.m14)&&(r[3]=i.m14),isFinite(i.m21)&&(r[4]=i.m21),isFinite(i.m22)&&(r[5]=i.m22),isFinite(i.m23)&&(r[6]=i.m23),isFinite(i.m24)&&(r[7]=i.m24),isFinite(i.m31)&&(r[8]=i.m31),isFinite(i.m32)&&(r[9]=i.m32),isFinite(i.m33)&&(r[10]=i.m33),isFinite(i.m34)&&(r[11]=i.m34),isFinite(i.m41)&&(r[12]=i.m41),isFinite(i.m42)&&(r[13]=i.m42),isFinite(i.m43)&&(r[14]=i.m43),isFinite(i.m44)&&(r[15]=i.m44),new k(r,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return k.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),k.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),k.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=k.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=k.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return k.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let r=l.create();return l.multiply(r,e.value,t.value),new k(r)}}k.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let N={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(N.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class M{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let L={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof g))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==L.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==L.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=L.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==L.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=I.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:I.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return P.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=L.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=L.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:k.fromMatrix(i);let s=S.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=x.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=S.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(L.PointerType.MOUSE)||(this.stop(L.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(L.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new M(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},_={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof g))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==g.prototype.resize)return;let e=_.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=_.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?_.ResizeReason.ZOOM_IN:_.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=N.debounce((()=>{e==_.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?_.ResizeReason.SCREEN_SIZE_INCREASED:_.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=_.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=g.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==_.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==_.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=I.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:I.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return P.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:k.fromMatrix(i);let s=S.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=x.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=S.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==_.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?_.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new M(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(_,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(L.suppressKeys=_.suppressKeys,L.ResizeReason=_.ResizeReason,L.attachResize=_.attachResize,L.dettachResize=_.dettachResize,_=L);var F=_;class B extends S{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||B.defaults.size,this.rotation=i.rotation||B.defaults.rotation,this.scaleX=i.scaleX||B.defaults.scaleX,this.scaleY=i.scaleY||B.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||B.defaults.scaleZ:void 0,this.offsetX=i.offsetX||B.defaults.offsetX,this.offsetY=i.offsetY||B.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||B.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new B(0,0,e.includes(B.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>B.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||B.defaults.size,this.rotation=s.rotation||i.rotation||B.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||B.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||B.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||B.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||B.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||B.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||B.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case B.Property.X:return this.x;case B.Property.Y:return this.y;case B.Property.Z:return this.z;case B.Property.RED:return this.red;case B.Property.GREEN:return this.green;case B.Property.BLUE:return this.blue;case B.Property.ALPHA:return this.alpha;case B.Property.SIZE:return this.size;case B.Property.ROTATION:return this.rotation;case B.Property.SCALE_X:return this.scaleX;case B.Property.SCALE_Y:return this.scaleY;case B.Property.SCALE_Z:return this.scaleZ;case B.Property.OFFSET_X:return this.offsetX;case B.Property.OFFSET_Y:return this.offsetY;case B.Property.OFFSET_Z:return this.offsetZ;case B.Property.D_X:return this.dX;case B.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){B.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case B.Property.X:e.x=r;break;case B.Property.Y:e.y=r;break;case B.Property.Z:e.z=r;break;case B.Property.RED:e.red=r;break;case B.Property.GREEN:e.green=r;break;case B.Property.BLUE:e.blue=r;break;case B.Property.ALPHA:e.alpha=r;break;case B.Property.SIZE:e.size=r;break;case B.Property.ROTATION:e.rotation=r;break;case B.Property.SCALE_X:e.scaleX=r;break;case B.Property.SCALE_Y:e.scaleY=r;break;case B.Property.SCALE_Z:e.scaleZ=r;break;case B.Property.OFFSET_X:e.offsetX=r;break;case B.Property.OFFSET_Y:e.offsetY=r;break;case B.Property.OFFSET_Z:e.offsetZ=r;break;case B.Property.D_X:e.dX=r;break;case B.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof k))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return B.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(B,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let U,j={version:"1.5.0"};Object.defineEnum(j,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(j,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(j,"TypeGL",["WEB","STACK"]),function(e){let r,i="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof t;r="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":i?"NODE":"SHELL";let s="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",n="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(j,"commonJS",{value:i,enumerable:!0}),Object.defineProperty(j,"type",{value:j.Type[r],enumerable:!0}),Object.defineProperty(j,"type2D",{value:j.Type2D[s],enumerable:!0}),Object.defineProperty(j,"typeGL",{value:j.TypeGL[n],enumerable:!0})}(),j.commonJS&&(U=t("systeminformation"));var G=U;class $ extends E{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",E.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new $;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=j.version,t.props["runtime.type"]=j.type.name,void 0===G)t.props["user.agent"]=navigator.userAgent;else{let e=await G.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const Y={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class X{static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=X.getUnitMetric(e);return i!=X.Metric.NORMALIZED&&i!=X.Metric.LOGICAL&&(r=X[z[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*X[z[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*X[t.name][r.name]/i}static getUnitMetric(e){switch(e){case X.Unit.METER:case X.Unit.CENTIMETER:case X.Unit.MILLIMETER:case X.Unit.MICROMETER:case X.Unit.INCH:case X.Unit.DP:case X.Unit.PICA:case X.Unit.POINT:case X.Unit.DIP:case X.Unit.DPI:return X.Metric.LENGTH;case X.Unit.SECOND:case X.Unit.MILLISECOND:case X.Unit.MICROSECOND:case X.Unit.NANOSECOND:return X.Metric.TIME;case X.Unit.RADIAN:case X.Unit.DEGREE:return X.Metric.ANGLE;case X.Unit.NEWTON:return X.Metric.FORCE;case X.Unit.NORMALIZED:return X.Metric.NORMALIZED;case X.Unit.LOGICAL:return X.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case X.Metric.LENGTH:return[X.Unit.METER,X.Unit.CENTIMETER,X.Unit.MILLIMETER,X.Unit.MICROMETER,X.Unit.INCH,X.Unit.DP,X.Unit.PICA,X.Unit.POINT,X.Unit.DIP,X.Unit.DPI];case X.Metric.TIME:return[X.Unit.SECOND,X.Unit.MILLISECOND,X.Unit.MICROSECOND,X.Unit.NANOSECOND];case X.Metric.ANGLE:return[X.Unit.RADIAN,X.Unit.DEGREE];case X.Metric.FORCE:return[X.Unit.NEWTON];case X.Metric.NORMALIZED:return[X.Unit.NORMALIZED];case X.Metric.LOGICAL:return[X.Unit.LOGICAL];case X.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return z[e.name]}static convertValue(e,t,r){return e*X[t.name][r.name]}}Object.defineEnum(X,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum(X,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const z=Object.freeze({LENGTH:X.Unit.METER,TIME:X.Unit.SECOND,FORCE:X.Unit.NEWTON,ANGLE:X.Unit.RADIAN,NORMALIZED:X.Unit.NORMALIZED,LOGICAL:X.Unit.LOGICAL});!function(){let e=X.getMetricUnits(X.Metric.LENGTH).filter((e=>!(e.name in Y)));for(let t of e){let e=X.Units[t.name];for(let t in Y)e[t]=e.INCH*Y[t]}for(let t in Y){let r={};for(let i of e)r[i.name]=X.Units.INCH[i.name]/Y[t];for(let e in Y)r[e]=Y[e]/Y[t];X.Units[t]=r}for(let e in X.Units)X[e]=X.Units[e]}(),Object.freeze(X);class V extends E{constructor(e,t,r,i,s){if(super(),t==V.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=V.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=X.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==V.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return N.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(V.Type).find((t=>V.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case V.Type.X:case V.Type.Y:case V.Type.Z:case V.Type.RADIUS_X:case V.Type.RADIUS_Y:t.unit=X.Unit.DIP;break;case V.Type.TIMESTAMP:t.unit=X.Unit.MILLISECOND;break;case V.Type.PRESSURE:t.unit=X.Unit.NORMALIZED,t.min=0,t.max=1;break;case V.Type.ALTITUDE:t.unit=X.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case V.Type.AZIMUTH:t.unit=X.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case V.Type.ROTATION:t.unit=X.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=X.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new V(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=V.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=X.getChannelResolution(r.unit),s=new V(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=V.Type.X&&e!=V.Type.Y||t.type!=P.Type.MOUSE||(s.precision=0),s}}V.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),V.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},V.Metric=X.Metric;class H extends E{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==V.Type.X||e.type==V.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new H(e,t);return r.channels=V.defaults[t.type.name].map((e=>V.createDefaultInstance(V.Type[e],t))),r}}class Z extends E{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new Z;return r.addContext(H.createDefaultInstance(e,t)),r}}class W extends E{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=Z.createDefaultInstance(t,r);return new W(e,i)}}class q{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${q.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class K extends E{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=q.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=K.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(K,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class J{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=N.getPropName(t.name),i=e[r];if(t.type==V.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==V.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=N.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==V.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class Q extends E{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",E.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof Q))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new P(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return Z.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=P.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new W(this.environment,r);r.inkChannelsContext.layout=Q.getLayout(e),this.sensorData=new K(i),this.sensorData.add(new J(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(V.Type).forEach((r=>{let i,s=V.Type[r];i=s==V.Type.ALTITUDE?"tiltX":s==V.Type.AZIMUTH?"tiltY":N.getPropName(r),Q.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===G)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await G.system(),r=await G.cpu(),i=await G.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await $.createInstance(e),t}}let ee={};if(j.type==j.Type.WEB)ee.Image=globalThis.Image,ee.ImageData=globalThis.ImageData,ee.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(ee.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},ee.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(ee.OffscreenCanvas=globalThis.OffscreenCanvas,ee.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)ee.Image=globalThis.Image,ee.ImageData=globalThis.ImageData,ee.OffscreenCanvas=globalThis.OffscreenCanvas,ee.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(j.commonJS){const{Canvas:e,CanvasRenderingContext2D:r,Image:i,ImageData:s}=t("canvas");ee.Image=i,ee.ImageData=s,ee.OffscreenCanvas=e,ee.OffscreenCanvasRenderingContext2D=r}else console.warn(`Current env - ${j.type.name}, do not provides OffscreenCanvas support`);function te(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}ee.CanvasRenderingContext2D&&(ee.CanvasRenderingContext2D.prototype.clearCanvas=te),ee.OffscreenCanvasRenderingContext2D&&(ee.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=te);const{Image:re,ImageData:ie,OffscreenCanvas:se,CanvasRenderingContext2D:ne,OffscreenCanvasRenderingContext2D:oe}=ee;let ae;class le{#r={};constructor(...e){if(ae)throw new Error("URIResolver instance already available");ae=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(le,"instance",{get:()=>ae});class he{static encode(e,t=he.Encoding.AUTO){let r;if(t==he.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?he.Encoding.NONE:he.Encoding.ARRAY:he.Encoding.BUFFER:t==he.Encoding.ARRAY&&e instanceof Array&&(t=he.Encoding.NONE),t==he.Encoding.NONE)r=e;else if(t==he.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case he.Encoding.BUFFER:r=i.toJSON();break;case he.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=he.Encoding[e.encoding];if(r==he.Encoding.NONE)t=e.content;else if(r==he.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case he.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case he.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(he,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class de{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||N.isValidURL(e)||de.repetitionsCache.has(e)||(de.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!le.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=le.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=he.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return he.isTypedArrayData(t)&&(t=he.decode(t)),new de(e.name,t)}static getInstance(e,t){return new de(t,e)}}class ce{constructor(e){N.isValidURL(e)||(de.repetitionsCache.has(e)||(de.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class pe{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=pe.defaults.CIRCLE_PRECISION,t=pe.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return pe.createEllipse(e,t,t,r)}static createEllipse(e=pe.defaults.ELLIPSE_PRECISION,t=pe.defaults.ELLIPSE_RADIUS_X,r=pe.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=pe.defaults.STAR_POINTS,t=pe.defaults.STAR_INTERNAL_RADIUS,r=pe.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let ue=d?d.default||globalThis.poly2tri:{};const{SweepContext:fe,Point:me}=ue;let ge=c?c.default||globalThis.ClipperLib:{};const{Clipper:ye,Paths:be,Path:Ee,ClipType:Pe,PolyType:Ie,PolyFillType:Se}=ge;class we{constructor(e,t,r){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:r,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(...[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jsExt={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var i=u(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}function l(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var d=function(){function t(){n(this,t)}return i(t,null,[{key:"overrides",get:function(){return["toString"]}},{key:"extend",value:function(t){var e,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;return"string"==typeof t?(e=t,t=globalThis[e]):e=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,r.name),Object.getOwnPropertyNames(r.prototype).filter((function(t){return"constructor"!=t})).forEach((function(e){!(e in t.prototype)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride ".concat(e),"color: chartreuse"):console.log("%cdefine ".concat(e),"color: green")),t.prototype[e]=r.prototype[e]):n.debug&&console.log("%cexclude ".concat(e),"color: red")})),Object.getOwnPropertyNames(r).forEach((function(e){"function"==typeof r[e]&&"extend"!=e&&(!(e in t)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride static ".concat(e),"color: chartreuse"):console.log("%cdefine static ".concat(e),"color: orange")),t[e]=r[e]):n.debug&&console.log("%cexclude static ".concat(e),"color: red"))})),r.properties&&Object.keys(r.properties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t.prototype?n.debug&&console.log("%cexclude prop ".concat(e),"color: red"):r.properties[e]&&(n.debug&&console.log("%cdefine prop ".concat(e),"color: darkseagreen"),Object.defineProperty(t.prototype,e,r.properties[e]))})),r.classProperties&&Object.keys(r.classProperties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t?n.debug&&console.log("%cexclude static prop ".concat(e),"color: red"):r.classProperties[e]&&(n.debug&&console.log("%cdefine static prop ".concat(e),"color: chocolate"),Object.defineProperty(t,e,r.classProperties[e]))})),!0):(this.debug&&console.warn("============================================================ Class ".concat(e," not found")),!1)}}]),t}(),v=function(){function t(e,r,i){n(this,t),Object.defineProperty(this,"type",{value:e,enumerable:!0}),Object.defineProperty(this,"name",{value:r,enumerable:!0}),Object.defineProperty(this,"value",{value:i,enumerable:!0})}return i(t,[{key:"toString",value:function(){return this.name}}]),t}(),m=function(t){a(o,t);var r=f(o);function o(){return n(this,o),r.apply(this,arguments)}return i(o,null,[{key:"equals",value:function(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==n.length&&t.every((function(t,e){return Object.equals(t,n[e])}));for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!==e(t[r]))return!1;if(!Object.equals(t[r],n[r]))return!1}}for(var i in n)if(n.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}},{key:"clone",value:function(t,n){var r=new Array;return function t(i){if(null===i)return null;if("object"!==e(i)||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(var o=0;o<r.length;o++)if(r[o][0]===i)return r[o][1];var a=Object.create(Object.getPrototypeOf(i));for(var u in r.push([i,a]),i)n&&"function"==typeof i[u]||i.hasOwnProperty(u)&&(a[u]=t(i[u]));return a}(t)}},{key:"toSource",value:function(t,n){if("object"==e(t)){var r=[];for(var i in t)t.hasOwnProperty(i)&&r.push("".concat(i,": ").concat(Object.toSource(t[i])));return(n?"".concat(n," = "):"")+"{"+r.join(", ")+"}"}if("function"==typeof t){var o=t.toString();return t.name&&o.startsWith(t.name)&&(o="function "+o),o}return t}},{key:"defineEnum",value:function(t,e,n){if(t[e])throw new Error("Already exist property: ".concat(e));var r={values:n.map((function(t,n){return new v(e,t,n)}))};return r.values.forEach((function(t){Object.defineProperty(r,t.name,{value:t,enumerable:!0}),Object.defineProperty(r,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,e,{value:r,enumerable:!0}),r}}]),o}(d),g=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"startsWith",value:function(t){return this.length>=t.length&&this.substring(0,t.length)==t}},{key:"endsWith",value:function(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}},{key:"includes",value:function(t){return-1!=this.indexOf(t)}},{key:"contains",value:function(t){return this.includes(t)}},{key:"containsIgnoreCase",value:function(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}},{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}},{key:"toCharArray",value:function(t){for(var e=[],n=!0,r=0;r<this.length;r++){var i=this.charCodeAt(r);i>255&&(n=!1),e[r]=i}if(t){if(!n)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}}],[{key:"fromCharArray",value:function(t){var e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n])}return e}}]),r}(d),b=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}},{key:"toFloat32",value:function(){var t=new Float32Array(1);return t[0]=this,t[0]}}]),r}(d);o(b,"classProperties",{MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}}),o(b,"properties",{length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}});var x=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"createClass",value:function(t,e){return new Function(e?e.name:void 0,"return class ".concat(t).concat(e?" extends ".concat(e.name):""," {\n\t\t\tconstructor() {\n\t\t\t\t").concat(e?"super(...arguments);":"","\n\t\t\t}\n\t\t}"))(e)}}]),r}(d);o(x,"properties",{body:{get:function(){var t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},configurable:!0}});var M=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clear",value:function(){this.length=0}},{key:"includes",value:function(t){return this.indexOf(t)>-1}},{key:"clone",value:function(){if(!Object.clone)throw new Error("Object extension is required");return this.map((function(t){return Object.clone(t)}))}},{key:"unique",value:function(){var t=this;return this.filter((function(e,n){return t.indexOf(e)==n}))}},{key:"add",value:function(t){return!this.includes(t)&&(this.push(t),!0)}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.splice(e,0,t)}},{key:"indicesOf",value:function(t){var e=[],n=this.indexOf(t);if(-1!=n){e.push(n);for(var r=this.lastIndexOf(t);r>n;)n=this.indexOf(t,n+1),e.push(n)}return e}},{key:"remove",value:function(){for(var t=this,e=function(t){var e=[],n=-1;return t.forEach((function(t){n-t!=1&&e.push([]),e.last.push(t),n=t})),e},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.map((function(e){return t.indicesOf(e)})).flat().sort((function(t,e){return e-t}));return e(o).forEach((function(e){return t.removeAt(e.last,e.length)})),this}},{key:"removeAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t>-1&&this.splice(t,e),this}},{key:"replace",value:function(t,e,n){var r=this.indexOf(t);return r>-1&&(!n&&e instanceof Array?this.splice.apply(this,[r,1].concat(l(e))):this.splice(r,1,e)),this}}],[{key:"from",value:function(t){return Array.prototype.slice.call(t)}}]),r}(d);o(M,"properties",{first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}});var O=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toBase64",value:function(){if(!String.fromCharArray)throw new Error("String extension is required");var t=new Uint8Array(this);return btoa(String.fromCharArray(t))}}],[{key:"fromBase64",value:function(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}},{key:"isTypedArray",value:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}}]),r}(d),w=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"],k=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clone",value:function(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){var t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}},{key:"concat",value:function(){for(var t,e=this,n=this.length,r=this.length,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach((function(t){if(e.constructor!=t.constructor)throw new Error("Concat array from wrong type detected - expected ".concat(e.constructor.name,", found ").concat(t.constructor.name));n+=t.length})),(t="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(n):new this.constructor(n)).set(this),o.forEach((function(e){t.set(e,r),r+=e.length})),t}},{key:"toArray",value:function(){return Array.from(this)}}],[{key:"createSharedInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");var e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);var n=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(n);var r=new this(n);return r.set(t),r}},{key:"from",value:function(t){return new this(t)}},{key:"extend",value:function(){var t=this;w.forEach((function(e){if(d.extend(e+"Array",t)){var n=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return n.from(this)}}}))}}]),r}(d),S=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"map",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i=t(i))&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"filter",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;t(i)&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}}]),r}(d),E=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(d);o(E,"properties",{size:{get:function(){return{width:Math.floor(screen.width),height:Math.floor(screen.height)}},configurable:!0},resolution:{get:function(){return{width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}},configurable:!0}});var P=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"properties",get:function(){return{query:{get:function(){if(!this._query){var t=Object.assign.apply(Object,[{}].concat(l(this.search.substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=")})).map((function(t){return o({},t[0],decodeURIComponent(t[1]))})))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}}]),r}(d),D=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"getInlineStyle",value:function(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}},{key:"setStyle",value:function(t,e){var n=this;["-webkit","-khtml","-moz","-ms","-o"].forEach((function(r){return n.style[r+"-"+t]=e})),this.style[t]=e}},{key:"getStyle",value:function(t){var e=t,n=t.startsWith("-");n&&(e=t.substring(1));for(var r=e.split("-"),i=r.length-1;i>0;i--)r[i]=r[i].substring(0,1).toUpperCase()+r[i].substring(1);e=r.join("");var o=this.style.display,a=this.style.visibility;"none"==o&&(this.style.visibility="hidden",this.style.display="");var u=window.getComputedStyle(this)[e];if(!n&&void 0===u)for(var s=["-webkit","-khtml","-moz","-ms","-o"],c=0;c<s.length&&"undefined"==(u=this.getStyle(s[c]+"-"+t));c++);return"none"==o&&(this.style.visibility=a,this.style.display="none"),u}},{key:"getMathStyle",value:function(t,e){var n=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==n&&(n=0),parseFloat(n)}},{key:"getTransformStyle",value:function(){var t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),r=parseFloat(n[0]),i=parseFloat(n[1]),o=parseFloat(n[2]),a=parseFloat(n[3]),u=parseFloat(n[4]),s=parseFloat(n[5]);t.scale={x:Math.sqrt(r*r+o*o),y:Math.sqrt(a*a+i*i)},t.skew={angleX:Math.tan(o),angleY:Math.tan(i)},t.rotate={angle:Math.atan2(i,r)},t.translate={x:u,y:s},t.matrix={a:r,b:i,c:o,d:a,tx:u,ty:s}}return t}},{key:"toRect",value:function(){var t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");var n=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),r=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),i=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return i.outerSize=new DOMSize(n,r),"none"==t&&(this.style.visibility=e,this.style.display="none"),i}}]),r}(d),A=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toDataURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png",e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL("image/".concat(t))}},{key:"toBlob",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png";return new Blob([this.toArrayBuffer(t)],{type:"image/".concat(t)})}},{key:"toArrayBuffer",value:function(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");var e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}}]),r}(d),T=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"fromBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"png",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Image;return new Promise((function(r,i){n.onload=function(){URL.revokeObjectURL(n.src),r(n)},n.onerror=i,n.src=URL.createObjectURL(new Blob([t.buffer||t],{type:"image/".concat(e)}))}))}}]),r}(d),j=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"extend",value:function(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}}]),r}(d),F=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"transform",value:function(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}},{key:"toString",value:function(){return"point(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}}]),r}(d),C=function(){function t(e,r){n(this,t),this.width=e,this.height=r}return i(t,[{key:"toJSON",value:function(){return{width:this.width,height:this.height}}},{key:"toString",value:function(){return"size(".concat(this.width,", ").concat(this.height,")")}}],[{key:"fromSize",value:function(e){if(e instanceof t)return e;if("string"==typeof e){if(!e.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g);e={width:parseFloat(n[0]),height:parseFloat(n[1])}}if(isNaN(e.width))throw new Error("Invalid width found, expected number");if(isNaN(e.height))throw new Error("Invalid height found, expected number");return new t(e.width,e.height)}}]),t}(),R=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"union",value:function(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}},{key:"intersect",value:function(t){if(t){var e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}}},{key:"ceil",value:function(t){var e=Math.floor(this.left),n=Math.floor(this.top),r=Math.ceil(this.right),i=Math.ceil(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o+=o%2),i=n+(a+=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"floor",value:function(t){var e=Math.ceil(this.left),n=Math.ceil(this.top),r=Math.floor(this.right),i=Math.floor(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o-=o%2),i=n+(a-=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"contains",value:function(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}},{key:"transform",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));var e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),i=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),o=Math.min(e.x,n.x,r.x,i.x),a=Math.min(e.y,n.y,r.y,i.y),u=Math.max(e.x,n.x,r.x,i.x),s=Math.max(e.y,n.y,r.y,i.y);return DOMRect.ofEdges(o,a,u,s)}},{key:"matrixTransform",value:function(t){return this.transform(t)}},{key:"toPath",value:function(){var t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}},{key:"toString",value:function(){return"rect(".concat(this.x,", ").concat(this.y,", ").concat(this.width,", ").concat(this.height,")")}}],[{key:"ofEdges",value:function(t,e,n,r){return new DOMRect(t,e,n-t,r-e)}},{key:"extend",value:function(){d.extend("DOMRect",this)&&(globalThis.DOMSize=C)}}]),r}(d);o(R,"properties",{size:{get:function(){return new C(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}});var I=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"preMultiply",value:function(t){var e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}},{key:"multiply",value:function(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);var e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}},{key:"multiplySelf",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}},{key:"transformPoint",value:function(t){return DOMPoint.fromPoint(t).matrixTransform(this)}},{key:"invert",value:function(){return this.inverse()}},{key:"decompose",value:function(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}},{key:"disassemble",value:function(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}},{key:"toString",value:function(t){if(!t)return this.nativeToString();var e=function(t){return((t<0?"":" ")+t.toPrecision(6)).substring(0,8)};return" Matrix 4x4\n"+"-".repeat(39)+"\n".concat(e(this.m11),", ").concat(e(this.m21),", ").concat(e(this.m31),", ").concat(e(this.m41))+"\n".concat(e(this.m12),", ").concat(e(this.m22),", ").concat(e(this.m32),", ").concat(e(this.m42))+"\n".concat(e(this.m13),", ").concat(e(this.m23),", ").concat(e(this.m33),", ").concat(e(this.m43))+"\n".concat(e(this.m14),", ").concat(e(this.m24),", ").concat(e(this.m34),", ").concat(e(this.m44))}}],[{key:"fromMatrix",value:function(t,e){var n;return"string"==typeof t?n=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),n=DOMMatrix.nativeFromMatrix(t)),n.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,n}},{key:"fromTranslate",value:function(t){var e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}},{key:"fromRotate",value:function(t,e){var n=Math.sin(t),r=Math.cos(t),i={a:r,b:n,c:-n,d:r};return e&&(i.tx=e.x-e.x*r+e.y*n,i.ty=e.y-e.x*n-e.y*r),DOMMatrix.fromMatrix(i)}},{key:"fromScale",value:function(t,e){isFinite(t)&&(t={x:t,y:t});var n={a:t.x,d:t.y};return e&&(n.tx=e.x-e.x*t.x,n.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(n)}},{key:"fromPoints",value:function(t,e){var n=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=n.invert().preMultiply(r);return DOMMatrix.fromMatrix({a:i.m11,b:i.m12,c:i.m21,d:i.m22,tx:i.m31,ty:i.m32})}},{key:"extend",value:function(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,d.extend("DOMMatrix",this)}}]),r}(d);o(I,"overrides",d.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"])),o(I,"properties",{tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}}),o(I,"classProperties",{MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}});var B=Object.freeze({__proto__:null,ObjectExt:m,StringExt:g,NumberExt:b,FunctionExt:x,ArrayExt:M,ArrayBufferExt:O,TypedArrayExt:k,SetExt:S,ScreenExt:E,LocationExt:P,HTMLElementExt:D,HTMLImageElementExt:A,ImageExt:T,CanvasExt:j,DOMPointExt:F,DOMRectExt:R,DOMMatrixExt:I});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn("createEnum is deprecated, please update ".concat(t," enum with Object.defineEnum(target, name, values)")),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((function(t){var e=B["".concat(t,"Ext")];if(!e)throw new Error("Extension ".concat(t," not found"));e.extend(t)})),t.Extension=d,t.version="1.0.2",Object.defineProperty(t,"__esModule",{value:!0})})); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jsExt={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var i=u(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}function l(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var d=function(){function t(){n(this,t)}return i(t,null,[{key:"overrides",get:function(){return["toString"]}},{key:"extend",value:function(t){var e,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;return"string"==typeof t?(e=t,t=globalThis[e]):e=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,r.name),Object.getOwnPropertyNames(r.prototype).filter((function(t){return"constructor"!=t})).forEach((function(e){!(e in t.prototype)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride ".concat(e),"color: chartreuse"):console.log("%cdefine ".concat(e),"color: green")),t.prototype[e]=r.prototype[e]):n.debug&&console.log("%cexclude ".concat(e),"color: red")})),Object.getOwnPropertyNames(r).forEach((function(e){"function"==typeof r[e]&&"extend"!=e&&(!(e in t)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride static ".concat(e),"color: chartreuse"):console.log("%cdefine static ".concat(e),"color: orange")),t[e]=r[e]):n.debug&&console.log("%cexclude static ".concat(e),"color: red"))})),r.properties&&Object.keys(r.properties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t.prototype?n.debug&&console.log("%cexclude prop ".concat(e),"color: red"):r.properties[e]&&(n.debug&&console.log("%cdefine prop ".concat(e),"color: darkseagreen"),Object.defineProperty(t.prototype,e,r.properties[e]))})),r.classProperties&&Object.keys(r.classProperties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t?n.debug&&console.log("%cexclude static prop ".concat(e),"color: red"):r.classProperties[e]&&(n.debug&&console.log("%cdefine static prop ".concat(e),"color: chocolate"),Object.defineProperty(t,e,r.classProperties[e]))})),!0):(this.debug&&console.warn("============================================================ Class ".concat(e," not found")),!1)}}]),t}(),v=function(){function t(e,r,i){n(this,t),Object.defineProperty(this,"type",{value:e,enumerable:!0}),Object.defineProperty(this,"name",{value:r,enumerable:!0}),Object.defineProperty(this,"value",{value:i,enumerable:!0})}return i(t,[{key:"toString",value:function(){return this.name}}]),t}(),m=function(t){a(o,t);var r=f(o);function o(){return n(this,o),r.apply(this,arguments)}return i(o,null,[{key:"equals",value:function(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==n.length&&t.every((function(t,e){return Object.equals(t,n[e])}));for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!==e(t[r]))return!1;if(!Object.equals(t[r],n[r]))return!1}}for(var i in n)if(n.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}},{key:"clone",value:function(t,n){var r=new Array;return function t(i){if(null===i)return null;if("object"!==e(i)||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(var o=0;o<r.length;o++)if(r[o][0]===i)return r[o][1];var a=Object.create(Object.getPrototypeOf(i));for(var u in r.push([i,a]),i)n&&"function"==typeof i[u]||i.hasOwnProperty(u)&&(a[u]=t(i[u]));return a}(t)}},{key:"toSource",value:function(t,n){if("object"==e(t)){var r=[];for(var i in t)t.hasOwnProperty(i)&&r.push("".concat(i,": ").concat(Object.toSource(t[i])));return(n?"".concat(n," = "):"")+"{"+r.join(", ")+"}"}if("function"==typeof t){var o=t.toString();return t.name&&o.startsWith(t.name)&&(o="function "+o),o}return t}},{key:"defineEnum",value:function(t,e,n){if(t[e])throw new Error("Already exist property: ".concat(e));var r={values:n.map((function(t,n){return new v(e,t,n)}))};return r.values.forEach((function(t){Object.defineProperty(r,t.name,{value:t,enumerable:!0}),Object.defineProperty(r,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,e,{value:r,enumerable:!0}),r}}]),o}(d),g=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"startsWith",value:function(t){return this.length>=t.length&&this.substring(0,t.length)==t}},{key:"endsWith",value:function(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}},{key:"includes",value:function(t){return-1!=this.indexOf(t)}},{key:"contains",value:function(t){return this.includes(t)}},{key:"containsIgnoreCase",value:function(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}},{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}},{key:"toCharArray",value:function(t){for(var e=[],n=!0,r=0;r<this.length;r++){var i=this.charCodeAt(r);i>255&&(n=!1),e[r]=i}if(t){if(!n)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}}],[{key:"fromCharArray",value:function(t){var e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n])}return e}}]),r}(d),b=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}},{key:"toFloat32",value:function(){var t=new Float32Array(1);return t[0]=this,t[0]}}]),r}(d);o(b,"classProperties",{MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}}),o(b,"properties",{length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}});var x=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"createClass",value:function(t,e){return new Function(e?e.name:void 0,"return class ".concat(t).concat(e?" extends ".concat(e.name):""," {\n\t\t\tconstructor() {\n\t\t\t\t").concat(e?"super(...arguments);":"","\n\t\t\t}\n\t\t}"))(e)}}]),r}(d);o(x,"properties",{body:{get:function(){var t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},configurable:!0}});var M=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clear",value:function(){this.length=0}},{key:"includes",value:function(t){return this.indexOf(t)>-1}},{key:"clone",value:function(){if(!Object.clone)throw new Error("Object extension is required");return this.map((function(t){return Object.clone(t)}))}},{key:"unique",value:function(){var t=this;return this.filter((function(e,n){return t.indexOf(e)==n}))}},{key:"add",value:function(t){return!this.includes(t)&&(this.push(t),!0)}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.splice(e,0,t)}},{key:"indicesOf",value:function(t){var e=[],n=this.indexOf(t);if(-1!=n){e.push(n);for(var r=this.lastIndexOf(t);r>n;)n=this.indexOf(t,n+1),e.push(n)}return e}},{key:"remove",value:function(){for(var t=this,e=function(t){var e=[],n=-1;return t.forEach((function(t){n-t!=1&&e.push([]),e.last.push(t),n=t})),e},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.map((function(e){return t.indicesOf(e)})).flat().sort((function(t,e){return e-t}));return e(o).forEach((function(e){return t.removeAt(e.last,e.length)})),this}},{key:"removeAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t>-1&&this.splice(t,e),this}},{key:"replace",value:function(t,e,n){var r=this.indexOf(t);return r>-1&&(!n&&e instanceof Array?this.splice.apply(this,[r,1].concat(l(e))):this.splice(r,1,e)),this}}],[{key:"from",value:function(t){return Array.prototype.slice.call(t)}}]),r}(d);o(M,"properties",{first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}});var O=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toBase64",value:function(){if(!String.fromCharArray)throw new Error("String extension is required");var t=new Uint8Array(this);return btoa(String.fromCharArray(t))}}],[{key:"fromBase64",value:function(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}},{key:"isTypedArray",value:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}}]),r}(d),w=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"],k=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clone",value:function(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){var t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}},{key:"concat",value:function(){for(var t,e=this,n=this.length,r=this.length,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach((function(t){if(e.constructor!=t.constructor)throw new Error("Concat array from wrong type detected - expected ".concat(e.constructor.name,", found ").concat(t.constructor.name));n+=t.length})),(t="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(n):new this.constructor(n)).set(this),o.forEach((function(e){t.set(e,r),r+=e.length})),t}},{key:"toArray",value:function(){return Array.from(this)}}],[{key:"createSharedInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");var e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);var n=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(n);var r=new this(n);return r.set(t),r}},{key:"from",value:function(t){return new this(t)}},{key:"extend",value:function(){var t=this;w.forEach((function(e){if(d.extend(e+"Array",t)){var n=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return n.from(this)}}}))}}]),r}(d),S=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"map",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i=t(i))&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"filter",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;t(i)&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}}]),r}(d),E=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(d);o(E,"properties",{size:{get:function(){return{width:Math.floor(screen.width),height:Math.floor(screen.height)}},configurable:!0},resolution:{get:function(){return{width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}},configurable:!0}});var P=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"properties",get:function(){return{query:{get:function(){if(!this._query){var t=Object.assign.apply(Object,[{}].concat(l(this.search.substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=")})).map((function(t){return o({},t[0],decodeURIComponent(t[1]))})))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}}]),r}(d),D=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"getInlineStyle",value:function(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}},{key:"setStyle",value:function(t,e){var n=this;["-webkit","-khtml","-moz","-ms","-o"].forEach((function(r){return n.style[r+"-"+t]=e})),this.style[t]=e}},{key:"getStyle",value:function(t){var e=t,n=t.startsWith("-");n&&(e=t.substring(1));for(var r=e.split("-"),i=r.length-1;i>0;i--)r[i]=r[i].substring(0,1).toUpperCase()+r[i].substring(1);e=r.join("");var o=this.style.display,a=this.style.visibility;"none"==o&&(this.style.visibility="hidden",this.style.display="");var u=window.getComputedStyle(this)[e];if(!n&&void 0===u)for(var s=["-webkit","-khtml","-moz","-ms","-o"],c=0;c<s.length&&"undefined"==(u=this.getStyle(s[c]+"-"+t));c++);return"none"==o&&(this.style.visibility=a,this.style.display="none"),u}},{key:"getMathStyle",value:function(t,e){var n=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==n&&(n=0),parseFloat(n)}},{key:"getTransformStyle",value:function(){var t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),r=parseFloat(n[0]),i=parseFloat(n[1]),o=parseFloat(n[2]),a=parseFloat(n[3]),u=parseFloat(n[4]),s=parseFloat(n[5]);t.scale={x:Math.sqrt(r*r+o*o),y:Math.sqrt(a*a+i*i)},t.skew={angleX:Math.tan(o),angleY:Math.tan(i)},t.rotate={angle:Math.atan2(i,r)},t.translate={x:u,y:s},t.matrix={a:r,b:i,c:o,d:a,tx:u,ty:s}}return t}},{key:"toRect",value:function(){var t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");var n=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),r=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),i=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return i.outerSize=new DOMSize(n,r),"none"==t&&(this.style.visibility=e,this.style.display="none"),i}}]),r}(d),A=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toDataURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png",e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL("image/".concat(t))}},{key:"toBlob",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png";return new Blob([this.toArrayBuffer(t)],{type:"image/".concat(t)})}},{key:"toArrayBuffer",value:function(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");var e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}}]),r}(d),T=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"fromBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"png",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Image;return new Promise((function(r,i){n.onload=function(){URL.revokeObjectURL(n.src),r(n)},n.onerror=i,n.src=URL.createObjectURL(new Blob([t.buffer||t],{type:"image/".concat(e)}))}))}}]),r}(d),j=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"extend",value:function(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}}]),r}(d),F=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"transform",value:function(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}},{key:"toString",value:function(){return"point(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}}]),r}(d),C=function(){function t(e,r){n(this,t),this.width=e,this.height=r}return i(t,[{key:"toJSON",value:function(){return{width:this.width,height:this.height}}},{key:"toString",value:function(){return"size(".concat(this.width,", ").concat(this.height,")")}}],[{key:"fromSize",value:function(e){if(e instanceof t)return e;if("string"==typeof e){if(!e.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g);e={width:parseFloat(n[0]),height:parseFloat(n[1])}}if(isNaN(e.width))throw new Error("Invalid width found, expected number");if(isNaN(e.height))throw new Error("Invalid height found, expected number");return new t(e.width,e.height)}}]),t}(),R=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"union",value:function(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}},{key:"intersect",value:function(t){if(t){var e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}}},{key:"ceil",value:function(t){var e=Math.floor(this.left),n=Math.floor(this.top),r=Math.ceil(this.right),i=Math.ceil(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o+=o%2),i=n+(a+=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"floor",value:function(t){var e=Math.ceil(this.left),n=Math.ceil(this.top),r=Math.floor(this.right),i=Math.floor(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o-=o%2),i=n+(a-=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"contains",value:function(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}},{key:"transform",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));var e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),i=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),o=Math.min(e.x,n.x,r.x,i.x),a=Math.min(e.y,n.y,r.y,i.y),u=Math.max(e.x,n.x,r.x,i.x),s=Math.max(e.y,n.y,r.y,i.y);return DOMRect.ofEdges(o,a,u,s)}},{key:"matrixTransform",value:function(t){return this.transform(t)}},{key:"toPath",value:function(){var t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}},{key:"toString",value:function(){return"rect(".concat(this.x,", ").concat(this.y,", ").concat(this.width,", ").concat(this.height,")")}}],[{key:"ofEdges",value:function(t,e,n,r){return new DOMRect(t,e,n-t,r-e)}},{key:"extend",value:function(){d.extend("DOMRect",this)&&(globalThis.DOMSize=C)}}]),r}(d);o(R,"properties",{size:{get:function(){return new C(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}});var I=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"preMultiply",value:function(t){var e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}},{key:"multiply",value:function(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);var e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}},{key:"multiplySelf",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}},{key:"transformPoint",value:function(t){return DOMPoint.fromPoint(t).matrixTransform(this)}},{key:"invert",value:function(){return this.inverse()}},{key:"decompose",value:function(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}},{key:"disassemble",value:function(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}},{key:"toString",value:function(t){if(!t)return this.nativeToString();var e=function(t){return((t<0?"":" ")+t.toPrecision(6)).substring(0,8)};return" Matrix 4x4\n"+"-".repeat(39)+"\n".concat(e(this.m11),", ").concat(e(this.m21),", ").concat(e(this.m31),", ").concat(e(this.m41))+"\n".concat(e(this.m12),", ").concat(e(this.m22),", ").concat(e(this.m32),", ").concat(e(this.m42))+"\n".concat(e(this.m13),", ").concat(e(this.m23),", ").concat(e(this.m33),", ").concat(e(this.m43))+"\n".concat(e(this.m14),", ").concat(e(this.m24),", ").concat(e(this.m34),", ").concat(e(this.m44))}}],[{key:"fromMatrix",value:function(t,e){var n;return"string"==typeof t?n=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),n=DOMMatrix.nativeFromMatrix(t)),n.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,n}},{key:"fromTranslate",value:function(t){var e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}},{key:"fromRotate",value:function(t,e){var n=Math.sin(t),r=Math.cos(t),i={a:r,b:n,c:-n,d:r};return e&&(i.tx=e.x-e.x*r+e.y*n,i.ty=e.y-e.x*n-e.y*r),DOMMatrix.fromMatrix(i)}},{key:"fromScale",value:function(t,e){isFinite(t)&&(t={x:t,y:t});var n={a:t.x,d:t.y};return e&&(n.tx=e.x-e.x*t.x,n.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(n)}},{key:"fromPoints",value:function(t,e){var n=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=n.invert().preMultiply(r);return DOMMatrix.fromMatrix({a:i.m11,b:i.m12,c:i.m21,d:i.m22,tx:i.m31,ty:i.m32})}},{key:"extend",value:function(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,d.extend("DOMMatrix",this)}}]),r}(d);o(I,"overrides",d.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"])),o(I,"properties",{tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}}),o(I,"classProperties",{MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}});var B=Object.freeze({__proto__:null,ObjectExt:m,StringExt:g,NumberExt:b,FunctionExt:x,ArrayExt:M,ArrayBufferExt:O,TypedArrayExt:k,SetExt:S,ScreenExt:E,LocationExt:P,HTMLElementExt:D,HTMLImageElementExt:A,ImageExt:T,CanvasExt:j,DOMPointExt:F,DOMRectExt:R,DOMMatrixExt:I});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn("createEnum is deprecated, please update ".concat(t," enum with Object.defineEnum(target, name, values)")),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((function(t){var e=B["".concat(t,"Ext")];if(!e)throw new Error("Extension ".concat(t," not found"));e.extend(t)})),t.Extension=d,t.version="1.0.2",Object.defineProperty(t,"__esModule",{value:!0})})); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jsExt={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var i=u(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}function l(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var d=function(){function t(){n(this,t)}return i(t,null,[{key:"overrides",get:function(){return["toString"]}},{key:"extend",value:function(t){var e,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;return"string"==typeof t?(e=t,t=globalThis[e]):e=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,r.name),Object.getOwnPropertyNames(r.prototype).filter((function(t){return"constructor"!=t})).forEach((function(e){!(e in t.prototype)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride ".concat(e),"color: chartreuse"):console.log("%cdefine ".concat(e),"color: green")),t.prototype[e]=r.prototype[e]):n.debug&&console.log("%cexclude ".concat(e),"color: red")})),Object.getOwnPropertyNames(r).forEach((function(e){"function"==typeof r[e]&&"extend"!=e&&(!(e in t)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride static ".concat(e),"color: chartreuse"):console.log("%cdefine static ".concat(e),"color: orange")),t[e]=r[e]):n.debug&&console.log("%cexclude static ".concat(e),"color: red"))})),r.properties&&Object.keys(r.properties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t.prototype?n.debug&&console.log("%cexclude prop ".concat(e),"color: red"):r.properties[e]&&(n.debug&&console.log("%cdefine prop ".concat(e),"color: darkseagreen"),Object.defineProperty(t.prototype,e,r.properties[e]))})),r.classProperties&&Object.keys(r.classProperties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t?n.debug&&console.log("%cexclude static prop ".concat(e),"color: red"):r.classProperties[e]&&(n.debug&&console.log("%cdefine static prop ".concat(e),"color: chocolate"),Object.defineProperty(t,e,r.classProperties[e]))})),!0):(this.debug&&console.warn("============================================================ Class ".concat(e," not found")),!1)}}]),t}(),v=function(){function t(e,r,i){n(this,t),Object.defineProperty(this,"type",{value:e,enumerable:!0}),Object.defineProperty(this,"name",{value:r,enumerable:!0}),Object.defineProperty(this,"value",{value:i,enumerable:!0})}return i(t,[{key:"toString",value:function(){return this.name}}]),t}(),m=function(t){a(o,t);var r=f(o);function o(){return n(this,o),r.apply(this,arguments)}return i(o,null,[{key:"equals",value:function(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==n.length&&t.every((function(t,e){return Object.equals(t,n[e])}));for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!==e(t[r]))return!1;if(!Object.equals(t[r],n[r]))return!1}}for(var i in n)if(n.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}},{key:"clone",value:function(t,n){var r=new Array;return function t(i){if(null===i)return null;if("object"!==e(i)||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(var o=0;o<r.length;o++)if(r[o][0]===i)return r[o][1];var a=Object.create(Object.getPrototypeOf(i));for(var u in r.push([i,a]),i)n&&"function"==typeof i[u]||i.hasOwnProperty(u)&&(a[u]=t(i[u]));return a}(t)}},{key:"toSource",value:function(t,n){if("object"==e(t)){var r=[];for(var i in t)t.hasOwnProperty(i)&&r.push("".concat(i,": ").concat(Object.toSource(t[i])));return(n?"".concat(n," = "):"")+"{"+r.join(", ")+"}"}if("function"==typeof t){var o=t.toString();return t.name&&o.startsWith(t.name)&&(o="function "+o),o}return t}},{key:"defineEnum",value:function(t,e,n){if(t[e])throw new Error("Already exist property: ".concat(e));var r={values:n.map((function(t,n){return new v(e,t,n)}))};return r.values.forEach((function(t){Object.defineProperty(r,t.name,{value:t,enumerable:!0}),Object.defineProperty(r,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,e,{value:r,enumerable:!0}),r}}]),o}(d),g=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"startsWith",value:function(t){return this.length>=t.length&&this.substring(0,t.length)==t}},{key:"endsWith",value:function(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}},{key:"includes",value:function(t){return-1!=this.indexOf(t)}},{key:"contains",value:function(t){return this.includes(t)}},{key:"containsIgnoreCase",value:function(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}},{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}},{key:"toCharArray",value:function(t){for(var e=[],n=!0,r=0;r<this.length;r++){var i=this.charCodeAt(r);i>255&&(n=!1),e[r]=i}if(t){if(!n)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}}],[{key:"fromCharArray",value:function(t){var e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n])}return e}}]),r}(d),b=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}},{key:"toFloat32",value:function(){var t=new Float32Array(1);return t[0]=this,t[0]}}]),r}(d);o(b,"classProperties",{MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}}),o(b,"properties",{length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}});var x=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"createClass",value:function(t,e){return new Function(e?e.name:void 0,"return class ".concat(t).concat(e?" extends ".concat(e.name):""," {\n\t\t\tconstructor() {\n\t\t\t\t").concat(e?"super(...arguments);":"","\n\t\t\t}\n\t\t}"))(e)}}]),r}(d);o(x,"properties",{body:{get:function(){var t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},configurable:!0}});var M=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clear",value:function(){this.length=0}},{key:"includes",value:function(t){return this.indexOf(t)>-1}},{key:"clone",value:function(){if(!Object.clone)throw new Error("Object extension is required");return this.map((function(t){return Object.clone(t)}))}},{key:"unique",value:function(){var t=this;return this.filter((function(e,n){return t.indexOf(e)==n}))}},{key:"add",value:function(t){return!this.includes(t)&&(this.push(t),!0)}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.splice(e,0,t)}},{key:"indicesOf",value:function(t){var e=[],n=this.indexOf(t);if(-1!=n){e.push(n);for(var r=this.lastIndexOf(t);r>n;)n=this.indexOf(t,n+1),e.push(n)}return e}},{key:"remove",value:function(){for(var t=this,e=function(t){var e=[],n=-1;return t.forEach((function(t){n-t!=1&&e.push([]),e.last.push(t),n=t})),e},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.map((function(e){return t.indicesOf(e)})).flat().sort((function(t,e){return e-t}));return e(o).forEach((function(e){return t.removeAt(e.last,e.length)})),this}},{key:"removeAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t>-1&&this.splice(t,e),this}},{key:"replace",value:function(t,e,n){var r=this.indexOf(t);return r>-1&&(!n&&e instanceof Array?this.splice.apply(this,[r,1].concat(l(e))):this.splice(r,1,e)),this}}],[{key:"from",value:function(t){return Array.prototype.slice.call(t)}}]),r}(d);o(M,"properties",{first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}});var O=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toBase64",value:function(){if(!String.fromCharArray)throw new Error("String extension is required");var t=new Uint8Array(this);return btoa(String.fromCharArray(t))}}],[{key:"fromBase64",value:function(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}},{key:"isTypedArray",value:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}}]),r}(d),w=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"],k=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clone",value:function(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){var t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}},{key:"concat",value:function(){for(var t,e=this,n=this.length,r=this.length,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach((function(t){if(e.constructor!=t.constructor)throw new Error("Concat array from wrong type detected - expected ".concat(e.constructor.name,", found ").concat(t.constructor.name));n+=t.length})),(t="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(n):new this.constructor(n)).set(this),o.forEach((function(e){t.set(e,r),r+=e.length})),t}},{key:"toArray",value:function(){return Array.from(this)}}],[{key:"createSharedInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");var e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);var n=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(n);var r=new this(n);return r.set(t),r}},{key:"from",value:function(t){return new this(t)}},{key:"extend",value:function(){var t=this;w.forEach((function(e){if(d.extend(e+"Array",t)){var n=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return n.from(this)}}}))}}]),r}(d),S=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"map",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i=t(i))&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"filter",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;t(i)&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}}]),r}(d),E=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(d);o(E,"properties",{size:{get:function(){return{width:Math.floor(screen.width),height:Math.floor(screen.height)}},configurable:!0},resolution:{get:function(){return{width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}},configurable:!0}});var P=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"properties",get:function(){return{query:{get:function(){if(!this._query){var t=Object.assign.apply(Object,[{}].concat(l(this.search.substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=")})).map((function(t){return o({},t[0],decodeURIComponent(t[1]))})))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}}]),r}(d),D=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"getInlineStyle",value:function(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}},{key:"setStyle",value:function(t,e){var n=this;["-webkit","-khtml","-moz","-ms","-o"].forEach((function(r){return n.style[r+"-"+t]=e})),this.style[t]=e}},{key:"getStyle",value:function(t){var e=t,n=t.startsWith("-");n&&(e=t.substring(1));for(var r=e.split("-"),i=r.length-1;i>0;i--)r[i]=r[i].substring(0,1).toUpperCase()+r[i].substring(1);e=r.join("");var o=this.style.display,a=this.style.visibility;"none"==o&&(this.style.visibility="hidden",this.style.display="");var u=window.getComputedStyle(this)[e];if(!n&&void 0===u)for(var s=["-webkit","-khtml","-moz","-ms","-o"],c=0;c<s.length&&"undefined"==(u=this.getStyle(s[c]+"-"+t));c++);return"none"==o&&(this.style.visibility=a,this.style.display="none"),u}},{key:"getMathStyle",value:function(t,e){var n=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==n&&(n=0),parseFloat(n)}},{key:"getTransformStyle",value:function(){var t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),r=parseFloat(n[0]),i=parseFloat(n[1]),o=parseFloat(n[2]),a=parseFloat(n[3]),u=parseFloat(n[4]),s=parseFloat(n[5]);t.scale={x:Math.sqrt(r*r+o*o),y:Math.sqrt(a*a+i*i)},t.skew={angleX:Math.tan(o),angleY:Math.tan(i)},t.rotate={angle:Math.atan2(i,r)},t.translate={x:u,y:s},t.matrix={a:r,b:i,c:o,d:a,tx:u,ty:s}}return t}},{key:"toRect",value:function(){var t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");var n=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),r=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),i=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return i.outerSize=new DOMSize(n,r),"none"==t&&(this.style.visibility=e,this.style.display="none"),i}}]),r}(d),A=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toDataURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png",e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL("image/".concat(t))}},{key:"toBlob",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png";return new Blob([this.toArrayBuffer(t)],{type:"image/".concat(t)})}},{key:"toArrayBuffer",value:function(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");var e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}}]),r}(d),T=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"fromBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"png",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Image;return new Promise((function(r,i){n.onload=function(){URL.revokeObjectURL(n.src),r(n)},n.onerror=i,n.src=URL.createObjectURL(new Blob([t.buffer||t],{type:"image/".concat(e)}))}))}}]),r}(d),j=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"extend",value:function(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}}]),r}(d),F=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"transform",value:function(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}},{key:"toString",value:function(){return"point(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}}]),r}(d),C=function(){function t(e,r){n(this,t),this.width=e,this.height=r}return i(t,[{key:"toJSON",value:function(){return{width:this.width,height:this.height}}},{key:"toString",value:function(){return"size(".concat(this.width,", ").concat(this.height,")")}}],[{key:"fromSize",value:function(e){if(e instanceof t)return e;if("string"==typeof e){if(!e.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g);e={width:parseFloat(n[0]),height:parseFloat(n[1])}}if(isNaN(e.width))throw new Error("Invalid width found, expected number");if(isNaN(e.height))throw new Error("Invalid height found, expected number");return new t(e.width,e.height)}}]),t}(),R=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"union",value:function(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}},{key:"intersect",value:function(t){if(t){var e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}}},{key:"ceil",value:function(t){var e=Math.floor(this.left),n=Math.floor(this.top),r=Math.ceil(this.right),i=Math.ceil(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o+=o%2),i=n+(a+=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"floor",value:function(t){var e=Math.ceil(this.left),n=Math.ceil(this.top),r=Math.floor(this.right),i=Math.floor(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o-=o%2),i=n+(a-=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"contains",value:function(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}},{key:"transform",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));var e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),i=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),o=Math.min(e.x,n.x,r.x,i.x),a=Math.min(e.y,n.y,r.y,i.y),u=Math.max(e.x,n.x,r.x,i.x),s=Math.max(e.y,n.y,r.y,i.y);return DOMRect.ofEdges(o,a,u,s)}},{key:"matrixTransform",value:function(t){return this.transform(t)}},{key:"toPath",value:function(){var t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}},{key:"toString",value:function(){return"rect(".concat(this.x,", ").concat(this.y,", ").concat(this.width,", ").concat(this.height,")")}}],[{key:"ofEdges",value:function(t,e,n,r){return new DOMRect(t,e,n-t,r-e)}},{key:"extend",value:function(){d.extend("DOMRect",this)&&(globalThis.DOMSize=C)}}]),r}(d);o(R,"properties",{size:{get:function(){return new C(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}});var I=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"preMultiply",value:function(t){var e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}},{key:"multiply",value:function(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);var e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}},{key:"multiplySelf",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}},{key:"transformPoint",value:function(t){return DOMPoint.fromPoint(t).matrixTransform(this)}},{key:"invert",value:function(){return this.inverse()}},{key:"decompose",value:function(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}},{key:"disassemble",value:function(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}},{key:"toString",value:function(t){if(!t)return this.nativeToString();var e=function(t){return((t<0?"":" ")+t.toPrecision(6)).substring(0,8)};return" Matrix 4x4\n"+"-".repeat(39)+"\n".concat(e(this.m11),", ").concat(e(this.m21),", ").concat(e(this.m31),", ").concat(e(this.m41))+"\n".concat(e(this.m12),", ").concat(e(this.m22),", ").concat(e(this.m32),", ").concat(e(this.m42))+"\n".concat(e(this.m13),", ").concat(e(this.m23),", ").concat(e(this.m33),", ").concat(e(this.m43))+"\n".concat(e(this.m14),", ").concat(e(this.m24),", ").concat(e(this.m34),", ").concat(e(this.m44))}}],[{key:"fromMatrix",value:function(t,e){var n;return"string"==typeof t?n=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),n=DOMMatrix.nativeFromMatrix(t)),n.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,n}},{key:"fromTranslate",value:function(t){var e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}},{key:"fromRotate",value:function(t,e){var n=Math.sin(t),r=Math.cos(t),i={a:r,b:n,c:-n,d:r};return e&&(i.tx=e.x-e.x*r+e.y*n,i.ty=e.y-e.x*n-e.y*r),DOMMatrix.fromMatrix(i)}},{key:"fromScale",value:function(t,e){isFinite(t)&&(t={x:t,y:t});var n={a:t.x,d:t.y};return e&&(n.tx=e.x-e.x*t.x,n.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(n)}},{key:"fromPoints",value:function(t,e){var n=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=n.invert().preMultiply(r);return DOMMatrix.fromMatrix({a:i.m11,b:i.m12,c:i.m21,d:i.m22,tx:i.m31,ty:i.m32})}},{key:"extend",value:function(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,d.extend("DOMMatrix",this)}}]),r}(d);o(I,"overrides",d.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"])),o(I,"properties",{tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}}),o(I,"classProperties",{MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}});var B=Object.freeze({__proto__:null,ObjectExt:m,StringExt:g,NumberExt:b,FunctionExt:x,ArrayExt:M,ArrayBufferExt:O,TypedArrayExt:k,SetExt:S,ScreenExt:E,LocationExt:P,HTMLElementExt:D,HTMLImageElementExt:A,ImageExt:T,CanvasExt:j,DOMPointExt:F,DOMRectExt:R,DOMMatrixExt:I});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn("createEnum is deprecated, please update ".concat(t," enum with Object.defineEnum(target, name, values)")),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((function(t){var e=B["".concat(t,"Ext")];if(!e)throw new Error("Extension ".concat(t," not found"));e.extend(t)})),t.Extension=d,t.version="1.0.2",Object.defineProperty(t,"__esModule",{value:!0})})); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jsExt={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var i=u(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}function l(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var d=function(){function t(){n(this,t)}return i(t,null,[{key:"overrides",get:function(){return["toString"]}},{key:"extend",value:function(t){var e,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;return"string"==typeof t?(e=t,t=globalThis[e]):e=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,r.name),Object.getOwnPropertyNames(r.prototype).filter((function(t){return"constructor"!=t})).forEach((function(e){!(e in t.prototype)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride ".concat(e),"color: chartreuse"):console.log("%cdefine ".concat(e),"color: green")),t.prototype[e]=r.prototype[e]):n.debug&&console.log("%cexclude ".concat(e),"color: red")})),Object.getOwnPropertyNames(r).forEach((function(e){"function"==typeof r[e]&&"extend"!=e&&(!(e in t)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride static ".concat(e),"color: chartreuse"):console.log("%cdefine static ".concat(e),"color: orange")),t[e]=r[e]):n.debug&&console.log("%cexclude static ".concat(e),"color: red"))})),r.properties&&Object.keys(r.properties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t.prototype?n.debug&&console.log("%cexclude prop ".concat(e),"color: red"):r.properties[e]&&(n.debug&&console.log("%cdefine prop ".concat(e),"color: darkseagreen"),Object.defineProperty(t.prototype,e,r.properties[e]))})),r.classProperties&&Object.keys(r.classProperties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t?n.debug&&console.log("%cexclude static prop ".concat(e),"color: red"):r.classProperties[e]&&(n.debug&&console.log("%cdefine static prop ".concat(e),"color: chocolate"),Object.defineProperty(t,e,r.classProperties[e]))})),!0):(this.debug&&console.warn("============================================================ Class ".concat(e," not found")),!1)}}]),t}(),v=function(){function t(e,r,i){n(this,t),Object.defineProperty(this,"type",{value:e,enumerable:!0}),Object.defineProperty(this,"name",{value:r,enumerable:!0}),Object.defineProperty(this,"value",{value:i,enumerable:!0})}return i(t,[{key:"toString",value:function(){return this.name}}]),t}(),m=function(t){a(o,t);var r=f(o);function o(){return n(this,o),r.apply(this,arguments)}return i(o,null,[{key:"equals",value:function(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==n.length&&t.every((function(t,e){return Object.equals(t,n[e])}));for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!==e(t[r]))return!1;if(!Object.equals(t[r],n[r]))return!1}}for(var i in n)if(n.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}},{key:"clone",value:function(t,n){var r=new Array;return function t(i){if(null===i)return null;if("object"!==e(i)||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(var o=0;o<r.length;o++)if(r[o][0]===i)return r[o][1];var a=Object.create(Object.getPrototypeOf(i));for(var u in r.push([i,a]),i)n&&"function"==typeof i[u]||i.hasOwnProperty(u)&&(a[u]=t(i[u]));return a}(t)}},{key:"toSource",value:function(t,n){if("object"==e(t)){var r=[];for(var i in t)t.hasOwnProperty(i)&&r.push("".concat(i,": ").concat(Object.toSource(t[i])));return(n?"".concat(n," = "):"")+"{"+r.join(", ")+"}"}if("function"==typeof t){var o=t.toString();return t.name&&o.startsWith(t.name)&&(o="function "+o),o}return t}},{key:"defineEnum",value:function(t,e,n){if(t[e])throw new Error("Already exist property: ".concat(e));var r={values:n.map((function(t,n){return new v(e,t,n)}))};return r.values.forEach((function(t){Object.defineProperty(r,t.name,{value:t,enumerable:!0}),Object.defineProperty(r,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,e,{value:r,enumerable:!0}),r}}]),o}(d),g=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"startsWith",value:function(t){return this.length>=t.length&&this.substring(0,t.length)==t}},{key:"endsWith",value:function(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}},{key:"includes",value:function(t){return-1!=this.indexOf(t)}},{key:"contains",value:function(t){return this.includes(t)}},{key:"containsIgnoreCase",value:function(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}},{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}},{key:"toCharArray",value:function(t){for(var e=[],n=!0,r=0;r<this.length;r++){var i=this.charCodeAt(r);i>255&&(n=!1),e[r]=i}if(t){if(!n)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}}],[{key:"fromCharArray",value:function(t){var e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n])}return e}}]),r}(d),b=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}},{key:"toFloat32",value:function(){var t=new Float32Array(1);return t[0]=this,t[0]}}]),r}(d);o(b,"classProperties",{MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}}),o(b,"properties",{length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}});var x=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"createClass",value:function(t,e){return new Function(e?e.name:void 0,"return class ".concat(t).concat(e?" extends ".concat(e.name):""," {\n\t\t\tconstructor() {\n\t\t\t\t").concat(e?"super(...arguments);":"","\n\t\t\t}\n\t\t}"))(e)}}]),r}(d);o(x,"properties",{body:{get:function(){var t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},configurable:!0}});var M=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clear",value:function(){this.length=0}},{key:"includes",value:function(t){return this.indexOf(t)>-1}},{key:"clone",value:function(){if(!Object.clone)throw new Error("Object extension is required");return this.map((function(t){return Object.clone(t)}))}},{key:"unique",value:function(){var t=this;return this.filter((function(e,n){return t.indexOf(e)==n}))}},{key:"add",value:function(t){return!this.includes(t)&&(this.push(t),!0)}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.splice(e,0,t)}},{key:"indicesOf",value:function(t){var e=[],n=this.indexOf(t);if(-1!=n){e.push(n);for(var r=this.lastIndexOf(t);r>n;)n=this.indexOf(t,n+1),e.push(n)}return e}},{key:"remove",value:function(){for(var t=this,e=function(t){var e=[],n=-1;return t.forEach((function(t){n-t!=1&&e.push([]),e.last.push(t),n=t})),e},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.map((function(e){return t.indicesOf(e)})).flat().sort((function(t,e){return e-t}));return e(o).forEach((function(e){return t.removeAt(e.last,e.length)})),this}},{key:"removeAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t>-1&&this.splice(t,e),this}},{key:"replace",value:function(t,e,n){var r=this.indexOf(t);return r>-1&&(!n&&e instanceof Array?this.splice.apply(this,[r,1].concat(l(e))):this.splice(r,1,e)),this}}],[{key:"from",value:function(t){return Array.prototype.slice.call(t)}}]),r}(d);o(M,"properties",{first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}});var O=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toBase64",value:function(){if(!String.fromCharArray)throw new Error("String extension is required");var t=new Uint8Array(this);return btoa(String.fromCharArray(t))}}],[{key:"fromBase64",value:function(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}},{key:"isTypedArray",value:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}}]),r}(d),w=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"],k=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clone",value:function(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){var t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}},{key:"concat",value:function(){for(var t,e=this,n=this.length,r=this.length,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach((function(t){if(e.constructor!=t.constructor)throw new Error("Concat array from wrong type detected - expected ".concat(e.constructor.name,", found ").concat(t.constructor.name));n+=t.length})),(t="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(n):new this.constructor(n)).set(this),o.forEach((function(e){t.set(e,r),r+=e.length})),t}},{key:"toArray",value:function(){return Array.from(this)}}],[{key:"createSharedInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");var e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);var n=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(n);var r=new this(n);return r.set(t),r}},{key:"from",value:function(t){return new this(t)}},{key:"extend",value:function(){var t=this;w.forEach((function(e){if(d.extend(e+"Array",t)){var n=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return n.from(this)}}}))}}]),r}(d),S=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"map",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i=t(i))&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"filter",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;t(i)&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}}]),r}(d),E=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(d);o(E,"properties",{size:{get:function(){return{width:Math.floor(screen.width),height:Math.floor(screen.height)}},configurable:!0},resolution:{get:function(){return{width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}},configurable:!0}});var P=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"properties",get:function(){return{query:{get:function(){if(!this._query){var t=Object.assign.apply(Object,[{}].concat(l(this.search.substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=")})).map((function(t){return o({},t[0],decodeURIComponent(t[1]))})))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}}]),r}(d),D=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"getInlineStyle",value:function(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}},{key:"setStyle",value:function(t,e){var n=this;["-webkit","-khtml","-moz","-ms","-o"].forEach((function(r){return n.style[r+"-"+t]=e})),this.style[t]=e}},{key:"getStyle",value:function(t){var e=t,n=t.startsWith("-");n&&(e=t.substring(1));for(var r=e.split("-"),i=r.length-1;i>0;i--)r[i]=r[i].substring(0,1).toUpperCase()+r[i].substring(1);e=r.join("");var o=this.style.display,a=this.style.visibility;"none"==o&&(this.style.visibility="hidden",this.style.display="");var u=window.getComputedStyle(this)[e];if(!n&&void 0===u)for(var s=["-webkit","-khtml","-moz","-ms","-o"],c=0;c<s.length&&"undefined"==(u=this.getStyle(s[c]+"-"+t));c++);return"none"==o&&(this.style.visibility=a,this.style.display="none"),u}},{key:"getMathStyle",value:function(t,e){var n=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==n&&(n=0),parseFloat(n)}},{key:"getTransformStyle",value:function(){var t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),r=parseFloat(n[0]),i=parseFloat(n[1]),o=parseFloat(n[2]),a=parseFloat(n[3]),u=parseFloat(n[4]),s=parseFloat(n[5]);t.scale={x:Math.sqrt(r*r+o*o),y:Math.sqrt(a*a+i*i)},t.skew={angleX:Math.tan(o),angleY:Math.tan(i)},t.rotate={angle:Math.atan2(i,r)},t.translate={x:u,y:s},t.matrix={a:r,b:i,c:o,d:a,tx:u,ty:s}}return t}},{key:"toRect",value:function(){var t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");var n=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),r=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),i=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return i.outerSize=new DOMSize(n,r),"none"==t&&(this.style.visibility=e,this.style.display="none"),i}}]),r}(d),A=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toDataURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png",e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL("image/".concat(t))}},{key:"toBlob",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png";return new Blob([this.toArrayBuffer(t)],{type:"image/".concat(t)})}},{key:"toArrayBuffer",value:function(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");var e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}}]),r}(d),T=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"fromBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"png",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Image;return new Promise((function(r,i){n.onload=function(){URL.revokeObjectURL(n.src),r(n)},n.onerror=i,n.src=URL.createObjectURL(new Blob([t.buffer||t],{type:"image/".concat(e)}))}))}}]),r}(d),j=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"extend",value:function(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}}]),r}(d),F=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"transform",value:function(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}},{key:"toString",value:function(){return"point(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}}]),r}(d),C=function(){function t(e,r){n(this,t),this.width=e,this.height=r}return i(t,[{key:"toJSON",value:function(){return{width:this.width,height:this.height}}},{key:"toString",value:function(){return"size(".concat(this.width,", ").concat(this.height,")")}}],[{key:"fromSize",value:function(e){if(e instanceof t)return e;if("string"==typeof e){if(!e.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g);e={width:parseFloat(n[0]),height:parseFloat(n[1])}}if(isNaN(e.width))throw new Error("Invalid width found, expected number");if(isNaN(e.height))throw new Error("Invalid height found, expected number");return new t(e.width,e.height)}}]),t}(),R=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"union",value:function(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}},{key:"intersect",value:function(t){if(t){var e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}}},{key:"ceil",value:function(t){var e=Math.floor(this.left),n=Math.floor(this.top),r=Math.ceil(this.right),i=Math.ceil(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o+=o%2),i=n+(a+=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"floor",value:function(t){var e=Math.ceil(this.left),n=Math.ceil(this.top),r=Math.floor(this.right),i=Math.floor(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o-=o%2),i=n+(a-=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"contains",value:function(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}},{key:"transform",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));var e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),i=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),o=Math.min(e.x,n.x,r.x,i.x),a=Math.min(e.y,n.y,r.y,i.y),u=Math.max(e.x,n.x,r.x,i.x),s=Math.max(e.y,n.y,r.y,i.y);return DOMRect.ofEdges(o,a,u,s)}},{key:"matrixTransform",value:function(t){return this.transform(t)}},{key:"toPath",value:function(){var t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}},{key:"toString",value:function(){return"rect(".concat(this.x,", ").concat(this.y,", ").concat(this.width,", ").concat(this.height,")")}}],[{key:"ofEdges",value:function(t,e,n,r){return new DOMRect(t,e,n-t,r-e)}},{key:"extend",value:function(){d.extend("DOMRect",this)&&(globalThis.DOMSize=C)}}]),r}(d);o(R,"properties",{size:{get:function(){return new C(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}});var I=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"preMultiply",value:function(t){var e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}},{key:"multiply",value:function(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);var e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}},{key:"multiplySelf",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}},{key:"transformPoint",value:function(t){return DOMPoint.fromPoint(t).matrixTransform(this)}},{key:"invert",value:function(){return this.inverse()}},{key:"decompose",value:function(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}},{key:"disassemble",value:function(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}},{key:"toString",value:function(t){if(!t)return this.nativeToString();var e=function(t){return((t<0?"":" ")+t.toPrecision(6)).substring(0,8)};return" Matrix 4x4\n"+"-".repeat(39)+"\n".concat(e(this.m11),", ").concat(e(this.m21),", ").concat(e(this.m31),", ").concat(e(this.m41))+"\n".concat(e(this.m12),", ").concat(e(this.m22),", ").concat(e(this.m32),", ").concat(e(this.m42))+"\n".concat(e(this.m13),", ").concat(e(this.m23),", ").concat(e(this.m33),", ").concat(e(this.m43))+"\n".concat(e(this.m14),", ").concat(e(this.m24),", ").concat(e(this.m34),", ").concat(e(this.m44))}}],[{key:"fromMatrix",value:function(t,e){var n;return"string"==typeof t?n=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),n=DOMMatrix.nativeFromMatrix(t)),n.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,n}},{key:"fromTranslate",value:function(t){var e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}},{key:"fromRotate",value:function(t,e){var n=Math.sin(t),r=Math.cos(t),i={a:r,b:n,c:-n,d:r};return e&&(i.tx=e.x-e.x*r+e.y*n,i.ty=e.y-e.x*n-e.y*r),DOMMatrix.fromMatrix(i)}},{key:"fromScale",value:function(t,e){isFinite(t)&&(t={x:t,y:t});var n={a:t.x,d:t.y};return e&&(n.tx=e.x-e.x*t.x,n.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(n)}},{key:"fromPoints",value:function(t,e){var n=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=n.invert().preMultiply(r);return DOMMatrix.fromMatrix({a:i.m11,b:i.m12,c:i.m21,d:i.m22,tx:i.m31,ty:i.m32})}},{key:"extend",value:function(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,d.extend("DOMMatrix",this)}}]),r}(d);o(I,"overrides",d.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"])),o(I,"properties",{tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}}),o(I,"classProperties",{MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}});var B=Object.freeze({__proto__:null,ObjectExt:m,StringExt:g,NumberExt:b,FunctionExt:x,ArrayExt:M,ArrayBufferExt:O,TypedArrayExt:k,SetExt:S,ScreenExt:E,LocationExt:P,HTMLElementExt:D,HTMLImageElementExt:A,ImageExt:T,CanvasExt:j,DOMPointExt:F,DOMRectExt:R,DOMMatrixExt:I});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn("createEnum is deprecated, please update ".concat(t," enum with Object.defineEnum(target, name, values)")),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((function(t){var e=B["".concat(t,"Ext")];if(!e)throw new Error("Extension ".concat(t," not found"));e.extend(t)})),t.Extension=d,t.version="1.0.2",Object.defineProperty(t,"__esModule",{value:!0})})); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s}),a="1.0.2";"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)}));export{t as Extension,a as version}; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s}),a="1.0.2";"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)}));export{t as Extension,a as version}; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s}),a="1.0.2";"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)}));export{t as Extension,a as version}; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s}),a="1.0.2";"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)}));export{t as Extension,a as version}; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s}),a="1.0.2";"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)}));export{t as Extension,a as version}; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)})),exports.Extension=t,exports.version="1.0.2"; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)})),exports.Extension=t,exports.version="1.0.2"; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jsExt={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var i=u(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}function l(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var d=function(){function t(){n(this,t)}return i(t,null,[{key:"overrides",get:function(){return["toString"]}},{key:"extend",value:function(t){var e,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;return"string"==typeof t?(e=t,t=globalThis[e]):e=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,r.name),Object.getOwnPropertyNames(r.prototype).filter((function(t){return"constructor"!=t})).forEach((function(e){!(e in t.prototype)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride ".concat(e),"color: chartreuse"):console.log("%cdefine ".concat(e),"color: green")),t.prototype[e]=r.prototype[e]):n.debug&&console.log("%cexclude ".concat(e),"color: red")})),Object.getOwnPropertyNames(r).forEach((function(e){"function"==typeof r[e]&&"extend"!=e&&(!(e in t)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride static ".concat(e),"color: chartreuse"):console.log("%cdefine static ".concat(e),"color: orange")),t[e]=r[e]):n.debug&&console.log("%cexclude static ".concat(e),"color: red"))})),r.properties&&Object.keys(r.properties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t.prototype?n.debug&&console.log("%cexclude prop ".concat(e),"color: red"):r.properties[e]&&(n.debug&&console.log("%cdefine prop ".concat(e),"color: darkseagreen"),Object.defineProperty(t.prototype,e,r.properties[e]))})),r.classProperties&&Object.keys(r.classProperties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t?n.debug&&console.log("%cexclude static prop ".concat(e),"color: red"):r.classProperties[e]&&(n.debug&&console.log("%cdefine static prop ".concat(e),"color: chocolate"),Object.defineProperty(t,e,r.classProperties[e]))})),!0):(this.debug&&console.warn("============================================================ Class ".concat(e," not found")),!1)}}]),t}(),v=function(){function t(e,r,i){n(this,t),Object.defineProperty(this,"type",{value:e,enumerable:!0}),Object.defineProperty(this,"name",{value:r,enumerable:!0}),Object.defineProperty(this,"value",{value:i,enumerable:!0})}return i(t,[{key:"toString",value:function(){return this.name}}]),t}(),m=function(t){a(o,t);var r=f(o);function o(){return n(this,o),r.apply(this,arguments)}return i(o,null,[{key:"equals",value:function(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==n.length&&t.every((function(t,e){return Object.equals(t,n[e])}));for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!==e(t[r]))return!1;if(!Object.equals(t[r],n[r]))return!1}}for(var i in n)if(n.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}},{key:"clone",value:function(t,n){var r=new Array;return function t(i){if(null===i)return null;if("object"!==e(i)||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(var o=0;o<r.length;o++)if(r[o][0]===i)return r[o][1];var a=Object.create(Object.getPrototypeOf(i));for(var u in r.push([i,a]),i)n&&"function"==typeof i[u]||i.hasOwnProperty(u)&&(a[u]=t(i[u]));return a}(t)}},{key:"toSource",value:function(t,n){if("object"==e(t)){var r=[];for(var i in t)t.hasOwnProperty(i)&&r.push("".concat(i,": ").concat(Object.toSource(t[i])));return(n?"".concat(n," = "):"")+"{"+r.join(", ")+"}"}if("function"==typeof t){var o=t.toString();return t.name&&o.startsWith(t.name)&&(o="function "+o),o}return t}},{key:"defineEnum",value:function(t,e,n){if(t[e])throw new Error("Already exist property: ".concat(e));var r={values:n.map((function(t,n){return new v(e,t,n)}))};return r.values.forEach((function(t){Object.defineProperty(r,t.name,{value:t,enumerable:!0}),Object.defineProperty(r,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,e,{value:r,enumerable:!0}),r}}]),o}(d),g=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"startsWith",value:function(t){return this.length>=t.length&&this.substring(0,t.length)==t}},{key:"endsWith",value:function(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}},{key:"includes",value:function(t){return-1!=this.indexOf(t)}},{key:"contains",value:function(t){return this.includes(t)}},{key:"containsIgnoreCase",value:function(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}},{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}},{key:"toCharArray",value:function(t){for(var e=[],n=!0,r=0;r<this.length;r++){var i=this.charCodeAt(r);i>255&&(n=!1),e[r]=i}if(t){if(!n)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}}],[{key:"fromCharArray",value:function(t){var e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n])}return e}}]),r}(d),b=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}},{key:"toFloat32",value:function(){var t=new Float32Array(1);return t[0]=this,t[0]}}]),r}(d);o(b,"classProperties",{MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}}),o(b,"properties",{length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}});var x=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"createClass",value:function(t,e){return new Function(e?e.name:void 0,"return class ".concat(t).concat(e?" extends ".concat(e.name):""," {\n\t\t\tconstructor() {\n\t\t\t\t").concat(e?"super(...arguments);":"","\n\t\t\t}\n\t\t}"))(e)}}]),r}(d);o(x,"properties",{body:{get:function(){var t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},configurable:!0}});var M=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clear",value:function(){this.length=0}},{key:"includes",value:function(t){return this.indexOf(t)>-1}},{key:"clone",value:function(){if(!Object.clone)throw new Error("Object extension is required");return this.map((function(t){return Object.clone(t)}))}},{key:"unique",value:function(){var t=this;return this.filter((function(e,n){return t.indexOf(e)==n}))}},{key:"add",value:function(t){return!this.includes(t)&&(this.push(t),!0)}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.splice(e,0,t)}},{key:"indicesOf",value:function(t){var e=[],n=this.indexOf(t);if(-1!=n){e.push(n);for(var r=this.lastIndexOf(t);r>n;)n=this.indexOf(t,n+1),e.push(n)}return e}},{key:"remove",value:function(){for(var t=this,e=function(t){var e=[],n=-1;return t.forEach((function(t){n-t!=1&&e.push([]),e.last.push(t),n=t})),e},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.map((function(e){return t.indicesOf(e)})).flat().sort((function(t,e){return e-t}));return e(o).forEach((function(e){return t.removeAt(e.last,e.length)})),this}},{key:"removeAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t>-1&&this.splice(t,e),this}},{key:"replace",value:function(t,e,n){var r=this.indexOf(t);return r>-1&&(!n&&e instanceof Array?this.splice.apply(this,[r,1].concat(l(e))):this.splice(r,1,e)),this}}],[{key:"from",value:function(t){return Array.prototype.slice.call(t)}}]),r}(d);o(M,"properties",{first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}});var O=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toBase64",value:function(){if(!String.fromCharArray)throw new Error("String extension is required");var t=new Uint8Array(this);return btoa(String.fromCharArray(t))}}],[{key:"fromBase64",value:function(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}},{key:"isTypedArray",value:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}}]),r}(d),w=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"],k=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clone",value:function(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){var t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}},{key:"concat",value:function(){for(var t,e=this,n=this.length,r=this.length,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach((function(t){if(e.constructor!=t.constructor)throw new Error("Concat array from wrong type detected - expected ".concat(e.constructor.name,", found ").concat(t.constructor.name));n+=t.length})),(t="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(n):new this.constructor(n)).set(this),o.forEach((function(e){t.set(e,r),r+=e.length})),t}},{key:"toArray",value:function(){return Array.from(this)}}],[{key:"createSharedInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");var e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);var n=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(n);var r=new this(n);return r.set(t),r}},{key:"from",value:function(t){return new this(t)}},{key:"extend",value:function(){var t=this;w.forEach((function(e){if(d.extend(e+"Array",t)){var n=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return n.from(this)}}}))}}]),r}(d),S=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"map",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i=t(i))&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"filter",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;t(i)&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}}]),r}(d),E=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(d);o(E,"properties",{size:{get:function(){return{width:Math.floor(screen.width),height:Math.floor(screen.height)}},configurable:!0},resolution:{get:function(){return{width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}},configurable:!0}});var P=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"properties",get:function(){return{query:{get:function(){if(!this._query){var t=Object.assign.apply(Object,[{}].concat(l(this.search.substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=")})).map((function(t){return o({},t[0],decodeURIComponent(t[1]))})))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}}]),r}(d),D=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"getInlineStyle",value:function(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}},{key:"setStyle",value:function(t,e){var n=this;["-webkit","-khtml","-moz","-ms","-o"].forEach((function(r){return n.style[r+"-"+t]=e})),this.style[t]=e}},{key:"getStyle",value:function(t){var e=t,n=t.startsWith("-");n&&(e=t.substring(1));for(var r=e.split("-"),i=r.length-1;i>0;i--)r[i]=r[i].substring(0,1).toUpperCase()+r[i].substring(1);e=r.join("");var o=this.style.display,a=this.style.visibility;"none"==o&&(this.style.visibility="hidden",this.style.display="");var u=window.getComputedStyle(this)[e];if(!n&&void 0===u)for(var s=["-webkit","-khtml","-moz","-ms","-o"],c=0;c<s.length&&"undefined"==(u=this.getStyle(s[c]+"-"+t));c++);return"none"==o&&(this.style.visibility=a,this.style.display="none"),u}},{key:"getMathStyle",value:function(t,e){var n=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==n&&(n=0),parseFloat(n)}},{key:"getTransformStyle",value:function(){var t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),r=parseFloat(n[0]),i=parseFloat(n[1]),o=parseFloat(n[2]),a=parseFloat(n[3]),u=parseFloat(n[4]),s=parseFloat(n[5]);t.scale={x:Math.sqrt(r*r+o*o),y:Math.sqrt(a*a+i*i)},t.skew={angleX:Math.tan(o),angleY:Math.tan(i)},t.rotate={angle:Math.atan2(i,r)},t.translate={x:u,y:s},t.matrix={a:r,b:i,c:o,d:a,tx:u,ty:s}}return t}},{key:"toRect",value:function(){var t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");var n=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),r=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),i=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return i.outerSize=new DOMSize(n,r),"none"==t&&(this.style.visibility=e,this.style.display="none"),i}}]),r}(d),A=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toDataURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png",e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL("image/".concat(t))}},{key:"toBlob",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png";return new Blob([this.toArrayBuffer(t)],{type:"image/".concat(t)})}},{key:"toArrayBuffer",value:function(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");var e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}}]),r}(d),T=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"fromBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"png",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Image;return new Promise((function(r,i){n.onload=function(){URL.revokeObjectURL(n.src),r(n)},n.onerror=i,n.src=URL.createObjectURL(new Blob([t.buffer||t],{type:"image/".concat(e)}))}))}}]),r}(d),j=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"extend",value:function(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}}]),r}(d),F=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"transform",value:function(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}},{key:"toString",value:function(){return"point(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}}]),r}(d),C=function(){function t(e,r){n(this,t),this.width=e,this.height=r}return i(t,[{key:"toJSON",value:function(){return{width:this.width,height:this.height}}},{key:"toString",value:function(){return"size(".concat(this.width,", ").concat(this.height,")")}}],[{key:"fromSize",value:function(e){if(e instanceof t)return e;if("string"==typeof e){if(!e.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g);e={width:parseFloat(n[0]),height:parseFloat(n[1])}}if(isNaN(e.width))throw new Error("Invalid width found, expected number");if(isNaN(e.height))throw new Error("Invalid height found, expected number");return new t(e.width,e.height)}}]),t}(),R=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"union",value:function(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}},{key:"intersect",value:function(t){if(t){var e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}}},{key:"ceil",value:function(t){var e=Math.floor(this.left),n=Math.floor(this.top),r=Math.ceil(this.right),i=Math.ceil(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o+=o%2),i=n+(a+=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"floor",value:function(t){var e=Math.ceil(this.left),n=Math.ceil(this.top),r=Math.floor(this.right),i=Math.floor(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o-=o%2),i=n+(a-=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"contains",value:function(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}},{key:"transform",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));var e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),i=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),o=Math.min(e.x,n.x,r.x,i.x),a=Math.min(e.y,n.y,r.y,i.y),u=Math.max(e.x,n.x,r.x,i.x),s=Math.max(e.y,n.y,r.y,i.y);return DOMRect.ofEdges(o,a,u,s)}},{key:"matrixTransform",value:function(t){return this.transform(t)}},{key:"toPath",value:function(){var t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}},{key:"toString",value:function(){return"rect(".concat(this.x,", ").concat(this.y,", ").concat(this.width,", ").concat(this.height,")")}}],[{key:"ofEdges",value:function(t,e,n,r){return new DOMRect(t,e,n-t,r-e)}},{key:"extend",value:function(){d.extend("DOMRect",this)&&(globalThis.DOMSize=C)}}]),r}(d);o(R,"properties",{size:{get:function(){return new C(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}});var I=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"preMultiply",value:function(t){var e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}},{key:"multiply",value:function(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);var e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}},{key:"multiplySelf",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}},{key:"transformPoint",value:function(t){return DOMPoint.fromPoint(t).matrixTransform(this)}},{key:"invert",value:function(){return this.inverse()}},{key:"decompose",value:function(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}},{key:"disassemble",value:function(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}},{key:"toString",value:function(t){if(!t)return this.nativeToString();var e=function(t){return((t<0?"":" ")+t.toPrecision(6)).substring(0,8)};return" Matrix 4x4\n"+"-".repeat(39)+"\n".concat(e(this.m11),", ").concat(e(this.m21),", ").concat(e(this.m31),", ").concat(e(this.m41))+"\n".concat(e(this.m12),", ").concat(e(this.m22),", ").concat(e(this.m32),", ").concat(e(this.m42))+"\n".concat(e(this.m13),", ").concat(e(this.m23),", ").concat(e(this.m33),", ").concat(e(this.m43))+"\n".concat(e(this.m14),", ").concat(e(this.m24),", ").concat(e(this.m34),", ").concat(e(this.m44))}}],[{key:"fromMatrix",value:function(t,e){var n;return"string"==typeof t?n=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),n=DOMMatrix.nativeFromMatrix(t)),n.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,n}},{key:"fromTranslate",value:function(t){var e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}},{key:"fromRotate",value:function(t,e){var n=Math.sin(t),r=Math.cos(t),i={a:r,b:n,c:-n,d:r};return e&&(i.tx=e.x-e.x*r+e.y*n,i.ty=e.y-e.x*n-e.y*r),DOMMatrix.fromMatrix(i)}},{key:"fromScale",value:function(t,e){isFinite(t)&&(t={x:t,y:t});var n={a:t.x,d:t.y};return e&&(n.tx=e.x-e.x*t.x,n.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(n)}},{key:"fromPoints",value:function(t,e){var n=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=n.invert().preMultiply(r);return DOMMatrix.fromMatrix({a:i.m11,b:i.m12,c:i.m21,d:i.m22,tx:i.m31,ty:i.m32})}},{key:"extend",value:function(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,d.extend("DOMMatrix",this)}}]),r}(d);o(I,"overrides",d.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"])),o(I,"properties",{tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}}),o(I,"classProperties",{MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}});var B=Object.freeze({__proto__:null,ObjectExt:m,StringExt:g,NumberExt:b,FunctionExt:x,ArrayExt:M,ArrayBufferExt:O,TypedArrayExt:k,SetExt:S,ScreenExt:E,LocationExt:P,HTMLElementExt:D,HTMLImageElementExt:A,ImageExt:T,CanvasExt:j,DOMPointExt:F,DOMRectExt:R,DOMMatrixExt:I});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn("createEnum is deprecated, please update ".concat(t," enum with Object.defineEnum(target, name, values)")),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((function(t){var e=B["".concat(t,"Ext")];if(!e)throw new Error("Extension ".concat(t," not found"));e.extend(t)})),t.Extension=d,t.version="1.0.2",Object.defineProperty(t,"__esModule",{value:!0})})); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jsExt={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var i=u(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}function l(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var d=function(){function t(){n(this,t)}return i(t,null,[{key:"overrides",get:function(){return["toString"]}},{key:"extend",value:function(t){var e,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;return"string"==typeof t?(e=t,t=globalThis[e]):e=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,r.name),Object.getOwnPropertyNames(r.prototype).filter((function(t){return"constructor"!=t})).forEach((function(e){!(e in t.prototype)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride ".concat(e),"color: chartreuse"):console.log("%cdefine ".concat(e),"color: green")),t.prototype[e]=r.prototype[e]):n.debug&&console.log("%cexclude ".concat(e),"color: red")})),Object.getOwnPropertyNames(r).forEach((function(e){"function"==typeof r[e]&&"extend"!=e&&(!(e in t)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride static ".concat(e),"color: chartreuse"):console.log("%cdefine static ".concat(e),"color: orange")),t[e]=r[e]):n.debug&&console.log("%cexclude static ".concat(e),"color: red"))})),r.properties&&Object.keys(r.properties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t.prototype?n.debug&&console.log("%cexclude prop ".concat(e),"color: red"):r.properties[e]&&(n.debug&&console.log("%cdefine prop ".concat(e),"color: darkseagreen"),Object.defineProperty(t.prototype,e,r.properties[e]))})),r.classProperties&&Object.keys(r.classProperties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t?n.debug&&console.log("%cexclude static prop ".concat(e),"color: red"):r.classProperties[e]&&(n.debug&&console.log("%cdefine static prop ".concat(e),"color: chocolate"),Object.defineProperty(t,e,r.classProperties[e]))})),!0):(this.debug&&console.warn("============================================================ Class ".concat(e," not found")),!1)}}]),t}(),v=function(){function t(e,r,i){n(this,t),Object.defineProperty(this,"type",{value:e,enumerable:!0}),Object.defineProperty(this,"name",{value:r,enumerable:!0}),Object.defineProperty(this,"value",{value:i,enumerable:!0})}return i(t,[{key:"toString",value:function(){return this.name}}]),t}(),m=function(t){a(o,t);var r=f(o);function o(){return n(this,o),r.apply(this,arguments)}return i(o,null,[{key:"equals",value:function(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==n.length&&t.every((function(t,e){return Object.equals(t,n[e])}));for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!==e(t[r]))return!1;if(!Object.equals(t[r],n[r]))return!1}}for(var i in n)if(n.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}},{key:"clone",value:function(t,n){var r=new Array;return function t(i){if(null===i)return null;if("object"!==e(i)||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(var o=0;o<r.length;o++)if(r[o][0]===i)return r[o][1];var a=Object.create(Object.getPrototypeOf(i));for(var u in r.push([i,a]),i)n&&"function"==typeof i[u]||i.hasOwnProperty(u)&&(a[u]=t(i[u]));return a}(t)}},{key:"toSource",value:function(t,n){if("object"==e(t)){var r=[];for(var i in t)t.hasOwnProperty(i)&&r.push("".concat(i,": ").concat(Object.toSource(t[i])));return(n?"".concat(n," = "):"")+"{"+r.join(", ")+"}"}if("function"==typeof t){var o=t.toString();return t.name&&o.startsWith(t.name)&&(o="function "+o),o}return t}},{key:"defineEnum",value:function(t,e,n){if(t[e])throw new Error("Already exist property: ".concat(e));var r={values:n.map((function(t,n){return new v(e,t,n)}))};return r.values.forEach((function(t){Object.defineProperty(r,t.name,{value:t,enumerable:!0}),Object.defineProperty(r,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,e,{value:r,enumerable:!0}),r}}]),o}(d),g=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"startsWith",value:function(t){return this.length>=t.length&&this.substring(0,t.length)==t}},{key:"endsWith",value:function(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}},{key:"includes",value:function(t){return-1!=this.indexOf(t)}},{key:"contains",value:function(t){return this.includes(t)}},{key:"containsIgnoreCase",value:function(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}},{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}},{key:"toCharArray",value:function(t){for(var e=[],n=!0,r=0;r<this.length;r++){var i=this.charCodeAt(r);i>255&&(n=!1),e[r]=i}if(t){if(!n)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}}],[{key:"fromCharArray",value:function(t){var e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n])}return e}}]),r}(d),b=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}},{key:"toFloat32",value:function(){var t=new Float32Array(1);return t[0]=this,t[0]}}]),r}(d);o(b,"classProperties",{MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}}),o(b,"properties",{length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}});var x=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"createClass",value:function(t,e){return new Function(e?e.name:void 0,"return class ".concat(t).concat(e?" extends ".concat(e.name):""," {\n\t\t\tconstructor() {\n\t\t\t\t").concat(e?"super(...arguments);":"","\n\t\t\t}\n\t\t}"))(e)}}]),r}(d);o(x,"properties",{body:{get:function(){var t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},configurable:!0}});var M=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clear",value:function(){this.length=0}},{key:"includes",value:function(t){return this.indexOf(t)>-1}},{key:"clone",value:function(){if(!Object.clone)throw new Error("Object extension is required");return this.map((function(t){return Object.clone(t)}))}},{key:"unique",value:function(){var t=this;return this.filter((function(e,n){return t.indexOf(e)==n}))}},{key:"add",value:function(t){return!this.includes(t)&&(this.push(t),!0)}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.splice(e,0,t)}},{key:"indicesOf",value:function(t){var e=[],n=this.indexOf(t);if(-1!=n){e.push(n);for(var r=this.lastIndexOf(t);r>n;)n=this.indexOf(t,n+1),e.push(n)}return e}},{key:"remove",value:function(){for(var t=this,e=function(t){var e=[],n=-1;return t.forEach((function(t){n-t!=1&&e.push([]),e.last.push(t),n=t})),e},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.map((function(e){return t.indicesOf(e)})).flat().sort((function(t,e){return e-t}));return e(o).forEach((function(e){return t.removeAt(e.last,e.length)})),this}},{key:"removeAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t>-1&&this.splice(t,e),this}},{key:"replace",value:function(t,e,n){var r=this.indexOf(t);return r>-1&&(!n&&e instanceof Array?this.splice.apply(this,[r,1].concat(l(e))):this.splice(r,1,e)),this}}],[{key:"from",value:function(t){return Array.prototype.slice.call(t)}}]),r}(d);o(M,"properties",{first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}});var O=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toBase64",value:function(){if(!String.fromCharArray)throw new Error("String extension is required");var t=new Uint8Array(this);return btoa(String.fromCharArray(t))}}],[{key:"fromBase64",value:function(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}},{key:"isTypedArray",value:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}}]),r}(d),w=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"],k=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clone",value:function(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){var t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}},{key:"concat",value:function(){for(var t,e=this,n=this.length,r=this.length,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach((function(t){if(e.constructor!=t.constructor)throw new Error("Concat array from wrong type detected - expected ".concat(e.constructor.name,", found ").concat(t.constructor.name));n+=t.length})),(t="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(n):new this.constructor(n)).set(this),o.forEach((function(e){t.set(e,r),r+=e.length})),t}},{key:"toArray",value:function(){return Array.from(this)}}],[{key:"createSharedInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");var e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);var n=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(n);var r=new this(n);return r.set(t),r}},{key:"from",value:function(t){return new this(t)}},{key:"extend",value:function(){var t=this;w.forEach((function(e){if(d.extend(e+"Array",t)){var n=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return n.from(this)}}}))}}]),r}(d),S=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"map",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i=t(i))&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"filter",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;t(i)&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}}]),r}(d),E=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(d);o(E,"properties",{size:{get:function(){return{width:Math.floor(screen.width),height:Math.floor(screen.height)}},configurable:!0},resolution:{get:function(){return{width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}},configurable:!0}});var P=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"properties",get:function(){return{query:{get:function(){if(!this._query){var t=Object.assign.apply(Object,[{}].concat(l(this.search.substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=")})).map((function(t){return o({},t[0],decodeURIComponent(t[1]))})))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}}]),r}(d),D=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"getInlineStyle",value:function(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}},{key:"setStyle",value:function(t,e){var n=this;["-webkit","-khtml","-moz","-ms","-o"].forEach((function(r){return n.style[r+"-"+t]=e})),this.style[t]=e}},{key:"getStyle",value:function(t){var e=t,n=t.startsWith("-");n&&(e=t.substring(1));for(var r=e.split("-"),i=r.length-1;i>0;i--)r[i]=r[i].substring(0,1).toUpperCase()+r[i].substring(1);e=r.join("");var o=this.style.display,a=this.style.visibility;"none"==o&&(this.style.visibility="hidden",this.style.display="");var u=window.getComputedStyle(this)[e];if(!n&&void 0===u)for(var s=["-webkit","-khtml","-moz","-ms","-o"],c=0;c<s.length&&"undefined"==(u=this.getStyle(s[c]+"-"+t));c++);return"none"==o&&(this.style.visibility=a,this.style.display="none"),u}},{key:"getMathStyle",value:function(t,e){var n=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==n&&(n=0),parseFloat(n)}},{key:"getTransformStyle",value:function(){var t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),r=parseFloat(n[0]),i=parseFloat(n[1]),o=parseFloat(n[2]),a=parseFloat(n[3]),u=parseFloat(n[4]),s=parseFloat(n[5]);t.scale={x:Math.sqrt(r*r+o*o),y:Math.sqrt(a*a+i*i)},t.skew={angleX:Math.tan(o),angleY:Math.tan(i)},t.rotate={angle:Math.atan2(i,r)},t.translate={x:u,y:s},t.matrix={a:r,b:i,c:o,d:a,tx:u,ty:s}}return t}},{key:"toRect",value:function(){var t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");var n=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),r=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),i=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return i.outerSize=new DOMSize(n,r),"none"==t&&(this.style.visibility=e,this.style.display="none"),i}}]),r}(d),A=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toDataURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png",e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL("image/".concat(t))}},{key:"toBlob",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png";return new Blob([this.toArrayBuffer(t)],{type:"image/".concat(t)})}},{key:"toArrayBuffer",value:function(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");var e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}}]),r}(d),T=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"fromBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"png",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Image;return new Promise((function(r,i){n.onload=function(){URL.revokeObjectURL(n.src),r(n)},n.onerror=i,n.src=URL.createObjectURL(new Blob([t.buffer||t],{type:"image/".concat(e)}))}))}}]),r}(d),j=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"extend",value:function(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}}]),r}(d),F=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"transform",value:function(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}},{key:"toString",value:function(){return"point(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}}]),r}(d),C=function(){function t(e,r){n(this,t),this.width=e,this.height=r}return i(t,[{key:"toJSON",value:function(){return{width:this.width,height:this.height}}},{key:"toString",value:function(){return"size(".concat(this.width,", ").concat(this.height,")")}}],[{key:"fromSize",value:function(e){if(e instanceof t)return e;if("string"==typeof e){if(!e.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g);e={width:parseFloat(n[0]),height:parseFloat(n[1])}}if(isNaN(e.width))throw new Error("Invalid width found, expected number");if(isNaN(e.height))throw new Error("Invalid height found, expected number");return new t(e.width,e.height)}}]),t}(),R=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"union",value:function(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}},{key:"intersect",value:function(t){if(t){var e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}}},{key:"ceil",value:function(t){var e=Math.floor(this.left),n=Math.floor(this.top),r=Math.ceil(this.right),i=Math.ceil(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o+=o%2),i=n+(a+=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"floor",value:function(t){var e=Math.ceil(this.left),n=Math.ceil(this.top),r=Math.floor(this.right),i=Math.floor(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o-=o%2),i=n+(a-=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"contains",value:function(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}},{key:"transform",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));var e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),i=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),o=Math.min(e.x,n.x,r.x,i.x),a=Math.min(e.y,n.y,r.y,i.y),u=Math.max(e.x,n.x,r.x,i.x),s=Math.max(e.y,n.y,r.y,i.y);return DOMRect.ofEdges(o,a,u,s)}},{key:"matrixTransform",value:function(t){return this.transform(t)}},{key:"toPath",value:function(){var t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}},{key:"toString",value:function(){return"rect(".concat(this.x,", ").concat(this.y,", ").concat(this.width,", ").concat(this.height,")")}}],[{key:"ofEdges",value:function(t,e,n,r){return new DOMRect(t,e,n-t,r-e)}},{key:"extend",value:function(){d.extend("DOMRect",this)&&(globalThis.DOMSize=C)}}]),r}(d);o(R,"properties",{size:{get:function(){return new C(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}});var I=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"preMultiply",value:function(t){var e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}},{key:"multiply",value:function(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);var e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}},{key:"multiplySelf",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}},{key:"transformPoint",value:function(t){return DOMPoint.fromPoint(t).matrixTransform(this)}},{key:"invert",value:function(){return this.inverse()}},{key:"decompose",value:function(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}},{key:"disassemble",value:function(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}},{key:"toString",value:function(t){if(!t)return this.nativeToString();var e=function(t){return((t<0?"":" ")+t.toPrecision(6)).substring(0,8)};return" Matrix 4x4\n"+"-".repeat(39)+"\n".concat(e(this.m11),", ").concat(e(this.m21),", ").concat(e(this.m31),", ").concat(e(this.m41))+"\n".concat(e(this.m12),", ").concat(e(this.m22),", ").concat(e(this.m32),", ").concat(e(this.m42))+"\n".concat(e(this.m13),", ").concat(e(this.m23),", ").concat(e(this.m33),", ").concat(e(this.m43))+"\n".concat(e(this.m14),", ").concat(e(this.m24),", ").concat(e(this.m34),", ").concat(e(this.m44))}}],[{key:"fromMatrix",value:function(t,e){var n;return"string"==typeof t?n=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),n=DOMMatrix.nativeFromMatrix(t)),n.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,n}},{key:"fromTranslate",value:function(t){var e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}},{key:"fromRotate",value:function(t,e){var n=Math.sin(t),r=Math.cos(t),i={a:r,b:n,c:-n,d:r};return e&&(i.tx=e.x-e.x*r+e.y*n,i.ty=e.y-e.x*n-e.y*r),DOMMatrix.fromMatrix(i)}},{key:"fromScale",value:function(t,e){isFinite(t)&&(t={x:t,y:t});var n={a:t.x,d:t.y};return e&&(n.tx=e.x-e.x*t.x,n.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(n)}},{key:"fromPoints",value:function(t,e){var n=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=n.invert().preMultiply(r);return DOMMatrix.fromMatrix({a:i.m11,b:i.m12,c:i.m21,d:i.m22,tx:i.m31,ty:i.m32})}},{key:"extend",value:function(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,d.extend("DOMMatrix",this)}}]),r}(d);o(I,"overrides",d.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"])),o(I,"properties",{tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}}),o(I,"classProperties",{MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}});var B=Object.freeze({__proto__:null,ObjectExt:m,StringExt:g,NumberExt:b,FunctionExt:x,ArrayExt:M,ArrayBufferExt:O,TypedArrayExt:k,SetExt:S,ScreenExt:E,LocationExt:P,HTMLElementExt:D,HTMLImageElementExt:A,ImageExt:T,CanvasExt:j,DOMPointExt:F,DOMRectExt:R,DOMMatrixExt:I});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn("createEnum is deprecated, please update ".concat(t," enum with Object.defineEnum(target, name, values)")),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((function(t){var e=B["".concat(t,"Ext")];if(!e)throw new Error("Extension ".concat(t," not found"));e.extend(t)})),t.Extension=d,t.version="1.0.2",Object.defineProperty(t,"__esModule",{value:!0})})); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jsExt={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var i=u(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}function l(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var d=function(){function t(){n(this,t)}return i(t,null,[{key:"overrides",get:function(){return["toString"]}},{key:"extend",value:function(t){var e,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;return"string"==typeof t?(e=t,t=globalThis[e]):e=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,r.name),Object.getOwnPropertyNames(r.prototype).filter((function(t){return"constructor"!=t})).forEach((function(e){!(e in t.prototype)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride ".concat(e),"color: chartreuse"):console.log("%cdefine ".concat(e),"color: green")),t.prototype[e]=r.prototype[e]):n.debug&&console.log("%cexclude ".concat(e),"color: red")})),Object.getOwnPropertyNames(r).forEach((function(e){"function"==typeof r[e]&&"extend"!=e&&(!(e in t)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride static ".concat(e),"color: chartreuse"):console.log("%cdefine static ".concat(e),"color: orange")),t[e]=r[e]):n.debug&&console.log("%cexclude static ".concat(e),"color: red"))})),r.properties&&Object.keys(r.properties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t.prototype?n.debug&&console.log("%cexclude prop ".concat(e),"color: red"):r.properties[e]&&(n.debug&&console.log("%cdefine prop ".concat(e),"color: darkseagreen"),Object.defineProperty(t.prototype,e,r.properties[e]))})),r.classProperties&&Object.keys(r.classProperties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t?n.debug&&console.log("%cexclude static prop ".concat(e),"color: red"):r.classProperties[e]&&(n.debug&&console.log("%cdefine static prop ".concat(e),"color: chocolate"),Object.defineProperty(t,e,r.classProperties[e]))})),!0):(this.debug&&console.warn("============================================================ Class ".concat(e," not found")),!1)}}]),t}(),v=function(){function t(e,r,i){n(this,t),Object.defineProperty(this,"type",{value:e,enumerable:!0}),Object.defineProperty(this,"name",{value:r,enumerable:!0}),Object.defineProperty(this,"value",{value:i,enumerable:!0})}return i(t,[{key:"toString",value:function(){return this.name}}]),t}(),m=function(t){a(o,t);var r=f(o);function o(){return n(this,o),r.apply(this,arguments)}return i(o,null,[{key:"equals",value:function(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==n.length&&t.every((function(t,e){return Object.equals(t,n[e])}));for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!==e(t[r]))return!1;if(!Object.equals(t[r],n[r]))return!1}}for(var i in n)if(n.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}},{key:"clone",value:function(t,n){var r=new Array;return function t(i){if(null===i)return null;if("object"!==e(i)||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(var o=0;o<r.length;o++)if(r[o][0]===i)return r[o][1];var a=Object.create(Object.getPrototypeOf(i));for(var u in r.push([i,a]),i)n&&"function"==typeof i[u]||i.hasOwnProperty(u)&&(a[u]=t(i[u]));return a}(t)}},{key:"toSource",value:function(t,n){if("object"==e(t)){var r=[];for(var i in t)t.hasOwnProperty(i)&&r.push("".concat(i,": ").concat(Object.toSource(t[i])));return(n?"".concat(n," = "):"")+"{"+r.join(", ")+"}"}if("function"==typeof t){var o=t.toString();return t.name&&o.startsWith(t.name)&&(o="function "+o),o}return t}},{key:"defineEnum",value:function(t,e,n){if(t[e])throw new Error("Already exist property: ".concat(e));var r={values:n.map((function(t,n){return new v(e,t,n)}))};return r.values.forEach((function(t){Object.defineProperty(r,t.name,{value:t,enumerable:!0}),Object.defineProperty(r,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,e,{value:r,enumerable:!0}),r}}]),o}(d),g=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"startsWith",value:function(t){return this.length>=t.length&&this.substring(0,t.length)==t}},{key:"endsWith",value:function(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}},{key:"includes",value:function(t){return-1!=this.indexOf(t)}},{key:"contains",value:function(t){return this.includes(t)}},{key:"containsIgnoreCase",value:function(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}},{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}},{key:"toCharArray",value:function(t){for(var e=[],n=!0,r=0;r<this.length;r++){var i=this.charCodeAt(r);i>255&&(n=!1),e[r]=i}if(t){if(!n)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}}],[{key:"fromCharArray",value:function(t){var e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n])}return e}}]),r}(d),b=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}},{key:"toFloat32",value:function(){var t=new Float32Array(1);return t[0]=this,t[0]}}]),r}(d);o(b,"classProperties",{MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}}),o(b,"properties",{length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}});var x=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"createClass",value:function(t,e){return new Function(e?e.name:void 0,"return class ".concat(t).concat(e?" extends ".concat(e.name):""," {\n\t\t\tconstructor() {\n\t\t\t\t").concat(e?"super(...arguments);":"","\n\t\t\t}\n\t\t}"))(e)}}]),r}(d);o(x,"properties",{body:{get:function(){var t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},configurable:!0}});var M=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clear",value:function(){this.length=0}},{key:"includes",value:function(t){return this.indexOf(t)>-1}},{key:"clone",value:function(){if(!Object.clone)throw new Error("Object extension is required");return this.map((function(t){return Object.clone(t)}))}},{key:"unique",value:function(){var t=this;return this.filter((function(e,n){return t.indexOf(e)==n}))}},{key:"add",value:function(t){return!this.includes(t)&&(this.push(t),!0)}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.splice(e,0,t)}},{key:"indicesOf",value:function(t){var e=[],n=this.indexOf(t);if(-1!=n){e.push(n);for(var r=this.lastIndexOf(t);r>n;)n=this.indexOf(t,n+1),e.push(n)}return e}},{key:"remove",value:function(){for(var t=this,e=function(t){var e=[],n=-1;return t.forEach((function(t){n-t!=1&&e.push([]),e.last.push(t),n=t})),e},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.map((function(e){return t.indicesOf(e)})).flat().sort((function(t,e){return e-t}));return e(o).forEach((function(e){return t.removeAt(e.last,e.length)})),this}},{key:"removeAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t>-1&&this.splice(t,e),this}},{key:"replace",value:function(t,e,n){var r=this.indexOf(t);return r>-1&&(!n&&e instanceof Array?this.splice.apply(this,[r,1].concat(l(e))):this.splice(r,1,e)),this}}],[{key:"from",value:function(t){return Array.prototype.slice.call(t)}}]),r}(d);o(M,"properties",{first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}});var O=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toBase64",value:function(){if(!String.fromCharArray)throw new Error("String extension is required");var t=new Uint8Array(this);return btoa(String.fromCharArray(t))}}],[{key:"fromBase64",value:function(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}},{key:"isTypedArray",value:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}}]),r}(d),w=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"],k=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clone",value:function(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){var t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}},{key:"concat",value:function(){for(var t,e=this,n=this.length,r=this.length,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach((function(t){if(e.constructor!=t.constructor)throw new Error("Concat array from wrong type detected - expected ".concat(e.constructor.name,", found ").concat(t.constructor.name));n+=t.length})),(t="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(n):new this.constructor(n)).set(this),o.forEach((function(e){t.set(e,r),r+=e.length})),t}},{key:"toArray",value:function(){return Array.from(this)}}],[{key:"createSharedInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");var e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);var n=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(n);var r=new this(n);return r.set(t),r}},{key:"from",value:function(t){return new this(t)}},{key:"extend",value:function(){var t=this;w.forEach((function(e){if(d.extend(e+"Array",t)){var n=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return n.from(this)}}}))}}]),r}(d),S=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"map",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i=t(i))&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"filter",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;t(i)&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}}]),r}(d),E=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(d);o(E,"properties",{size:{get:function(){return{width:Math.floor(screen.width),height:Math.floor(screen.height)}},configurable:!0},resolution:{get:function(){return{width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}},configurable:!0}});var P=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"properties",get:function(){return{query:{get:function(){if(!this._query){var t=Object.assign.apply(Object,[{}].concat(l(this.search.substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=")})).map((function(t){return o({},t[0],decodeURIComponent(t[1]))})))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}}]),r}(d),D=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"getInlineStyle",value:function(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}},{key:"setStyle",value:function(t,e){var n=this;["-webkit","-khtml","-moz","-ms","-o"].forEach((function(r){return n.style[r+"-"+t]=e})),this.style[t]=e}},{key:"getStyle",value:function(t){var e=t,n=t.startsWith("-");n&&(e=t.substring(1));for(var r=e.split("-"),i=r.length-1;i>0;i--)r[i]=r[i].substring(0,1).toUpperCase()+r[i].substring(1);e=r.join("");var o=this.style.display,a=this.style.visibility;"none"==o&&(this.style.visibility="hidden",this.style.display="");var u=window.getComputedStyle(this)[e];if(!n&&void 0===u)for(var s=["-webkit","-khtml","-moz","-ms","-o"],c=0;c<s.length&&"undefined"==(u=this.getStyle(s[c]+"-"+t));c++);return"none"==o&&(this.style.visibility=a,this.style.display="none"),u}},{key:"getMathStyle",value:function(t,e){var n=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==n&&(n=0),parseFloat(n)}},{key:"getTransformStyle",value:function(){var t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),r=parseFloat(n[0]),i=parseFloat(n[1]),o=parseFloat(n[2]),a=parseFloat(n[3]),u=parseFloat(n[4]),s=parseFloat(n[5]);t.scale={x:Math.sqrt(r*r+o*o),y:Math.sqrt(a*a+i*i)},t.skew={angleX:Math.tan(o),angleY:Math.tan(i)},t.rotate={angle:Math.atan2(i,r)},t.translate={x:u,y:s},t.matrix={a:r,b:i,c:o,d:a,tx:u,ty:s}}return t}},{key:"toRect",value:function(){var t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");var n=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),r=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),i=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return i.outerSize=new DOMSize(n,r),"none"==t&&(this.style.visibility=e,this.style.display="none"),i}}]),r}(d),A=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toDataURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png",e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL("image/".concat(t))}},{key:"toBlob",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png";return new Blob([this.toArrayBuffer(t)],{type:"image/".concat(t)})}},{key:"toArrayBuffer",value:function(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");var e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}}]),r}(d),T=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"fromBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"png",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Image;return new Promise((function(r,i){n.onload=function(){URL.revokeObjectURL(n.src),r(n)},n.onerror=i,n.src=URL.createObjectURL(new Blob([t.buffer||t],{type:"image/".concat(e)}))}))}}]),r}(d),j=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"extend",value:function(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}}]),r}(d),F=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"transform",value:function(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}},{key:"toString",value:function(){return"point(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}}]),r}(d),C=function(){function t(e,r){n(this,t),this.width=e,this.height=r}return i(t,[{key:"toJSON",value:function(){return{width:this.width,height:this.height}}},{key:"toString",value:function(){return"size(".concat(this.width,", ").concat(this.height,")")}}],[{key:"fromSize",value:function(e){if(e instanceof t)return e;if("string"==typeof e){if(!e.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g);e={width:parseFloat(n[0]),height:parseFloat(n[1])}}if(isNaN(e.width))throw new Error("Invalid width found, expected number");if(isNaN(e.height))throw new Error("Invalid height found, expected number");return new t(e.width,e.height)}}]),t}(),R=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"union",value:function(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}},{key:"intersect",value:function(t){if(t){var e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}}},{key:"ceil",value:function(t){var e=Math.floor(this.left),n=Math.floor(this.top),r=Math.ceil(this.right),i=Math.ceil(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o+=o%2),i=n+(a+=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"floor",value:function(t){var e=Math.ceil(this.left),n=Math.ceil(this.top),r=Math.floor(this.right),i=Math.floor(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o-=o%2),i=n+(a-=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"contains",value:function(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}},{key:"transform",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));var e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),i=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),o=Math.min(e.x,n.x,r.x,i.x),a=Math.min(e.y,n.y,r.y,i.y),u=Math.max(e.x,n.x,r.x,i.x),s=Math.max(e.y,n.y,r.y,i.y);return DOMRect.ofEdges(o,a,u,s)}},{key:"matrixTransform",value:function(t){return this.transform(t)}},{key:"toPath",value:function(){var t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}},{key:"toString",value:function(){return"rect(".concat(this.x,", ").concat(this.y,", ").concat(this.width,", ").concat(this.height,")")}}],[{key:"ofEdges",value:function(t,e,n,r){return new DOMRect(t,e,n-t,r-e)}},{key:"extend",value:function(){d.extend("DOMRect",this)&&(globalThis.DOMSize=C)}}]),r}(d);o(R,"properties",{size:{get:function(){return new C(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}});var I=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"preMultiply",value:function(t){var e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}},{key:"multiply",value:function(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);var e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}},{key:"multiplySelf",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}},{key:"transformPoint",value:function(t){return DOMPoint.fromPoint(t).matrixTransform(this)}},{key:"invert",value:function(){return this.inverse()}},{key:"decompose",value:function(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}},{key:"disassemble",value:function(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}},{key:"toString",value:function(t){if(!t)return this.nativeToString();var e=function(t){return((t<0?"":" ")+t.toPrecision(6)).substring(0,8)};return" Matrix 4x4\n"+"-".repeat(39)+"\n".concat(e(this.m11),", ").concat(e(this.m21),", ").concat(e(this.m31),", ").concat(e(this.m41))+"\n".concat(e(this.m12),", ").concat(e(this.m22),", ").concat(e(this.m32),", ").concat(e(this.m42))+"\n".concat(e(this.m13),", ").concat(e(this.m23),", ").concat(e(this.m33),", ").concat(e(this.m43))+"\n".concat(e(this.m14),", ").concat(e(this.m24),", ").concat(e(this.m34),", ").concat(e(this.m44))}}],[{key:"fromMatrix",value:function(t,e){var n;return"string"==typeof t?n=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),n=DOMMatrix.nativeFromMatrix(t)),n.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,n}},{key:"fromTranslate",value:function(t){var e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}},{key:"fromRotate",value:function(t,e){var n=Math.sin(t),r=Math.cos(t),i={a:r,b:n,c:-n,d:r};return e&&(i.tx=e.x-e.x*r+e.y*n,i.ty=e.y-e.x*n-e.y*r),DOMMatrix.fromMatrix(i)}},{key:"fromScale",value:function(t,e){isFinite(t)&&(t={x:t,y:t});var n={a:t.x,d:t.y};return e&&(n.tx=e.x-e.x*t.x,n.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(n)}},{key:"fromPoints",value:function(t,e){var n=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=n.invert().preMultiply(r);return DOMMatrix.fromMatrix({a:i.m11,b:i.m12,c:i.m21,d:i.m22,tx:i.m31,ty:i.m32})}},{key:"extend",value:function(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,d.extend("DOMMatrix",this)}}]),r}(d);o(I,"overrides",d.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"])),o(I,"properties",{tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}}),o(I,"classProperties",{MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}});var B=Object.freeze({__proto__:null,ObjectExt:m,StringExt:g,NumberExt:b,FunctionExt:x,ArrayExt:M,ArrayBufferExt:O,TypedArrayExt:k,SetExt:S,ScreenExt:E,LocationExt:P,HTMLElementExt:D,HTMLImageElementExt:A,ImageExt:T,CanvasExt:j,DOMPointExt:F,DOMRectExt:R,DOMMatrixExt:I});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn("createEnum is deprecated, please update ".concat(t," enum with Object.defineEnum(target, name, values)")),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((function(t){var e=B["".concat(t,"Ext")];if(!e)throw new Error("Extension ".concat(t," not found"));e.extend(t)})),t.Extension=d,t.version="1.0.2",Object.defineProperty(t,"__esModule",{value:!0})})); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jsExt={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var i=u(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}function l(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var d=function(){function t(){n(this,t)}return i(t,null,[{key:"overrides",get:function(){return["toString"]}},{key:"extend",value:function(t){var e,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;return"string"==typeof t?(e=t,t=globalThis[e]):e=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,r.name),Object.getOwnPropertyNames(r.prototype).filter((function(t){return"constructor"!=t})).forEach((function(e){!(e in t.prototype)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride ".concat(e),"color: chartreuse"):console.log("%cdefine ".concat(e),"color: green")),t.prototype[e]=r.prototype[e]):n.debug&&console.log("%cexclude ".concat(e),"color: red")})),Object.getOwnPropertyNames(r).forEach((function(e){"function"==typeof r[e]&&"extend"!=e&&(!(e in t)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride static ".concat(e),"color: chartreuse"):console.log("%cdefine static ".concat(e),"color: orange")),t[e]=r[e]):n.debug&&console.log("%cexclude static ".concat(e),"color: red"))})),r.properties&&Object.keys(r.properties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t.prototype?n.debug&&console.log("%cexclude prop ".concat(e),"color: red"):r.properties[e]&&(n.debug&&console.log("%cdefine prop ".concat(e),"color: darkseagreen"),Object.defineProperty(t.prototype,e,r.properties[e]))})),r.classProperties&&Object.keys(r.classProperties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t?n.debug&&console.log("%cexclude static prop ".concat(e),"color: red"):r.classProperties[e]&&(n.debug&&console.log("%cdefine static prop ".concat(e),"color: chocolate"),Object.defineProperty(t,e,r.classProperties[e]))})),!0):(this.debug&&console.warn("============================================================ Class ".concat(e," not found")),!1)}}]),t}(),v=function(){function t(e,r,i){n(this,t),Object.defineProperty(this,"type",{value:e,enumerable:!0}),Object.defineProperty(this,"name",{value:r,enumerable:!0}),Object.defineProperty(this,"value",{value:i,enumerable:!0})}return i(t,[{key:"toString",value:function(){return this.name}}]),t}(),m=function(t){a(o,t);var r=f(o);function o(){return n(this,o),r.apply(this,arguments)}return i(o,null,[{key:"equals",value:function(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==n.length&&t.every((function(t,e){return Object.equals(t,n[e])}));for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!==e(t[r]))return!1;if(!Object.equals(t[r],n[r]))return!1}}for(var i in n)if(n.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}},{key:"clone",value:function(t,n){var r=new Array;return function t(i){if(null===i)return null;if("object"!==e(i)||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(var o=0;o<r.length;o++)if(r[o][0]===i)return r[o][1];var a=Object.create(Object.getPrototypeOf(i));for(var u in r.push([i,a]),i)n&&"function"==typeof i[u]||i.hasOwnProperty(u)&&(a[u]=t(i[u]));return a}(t)}},{key:"toSource",value:function(t,n){if("object"==e(t)){var r=[];for(var i in t)t.hasOwnProperty(i)&&r.push("".concat(i,": ").concat(Object.toSource(t[i])));return(n?"".concat(n," = "):"")+"{"+r.join(", ")+"}"}if("function"==typeof t){var o=t.toString();return t.name&&o.startsWith(t.name)&&(o="function "+o),o}return t}},{key:"defineEnum",value:function(t,e,n){if(t[e])throw new Error("Already exist property: ".concat(e));var r={values:n.map((function(t,n){return new v(e,t,n)}))};return r.values.forEach((function(t){Object.defineProperty(r,t.name,{value:t,enumerable:!0}),Object.defineProperty(r,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,e,{value:r,enumerable:!0}),r}}]),o}(d),g=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"startsWith",value:function(t){return this.length>=t.length&&this.substring(0,t.length)==t}},{key:"endsWith",value:function(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}},{key:"includes",value:function(t){return-1!=this.indexOf(t)}},{key:"contains",value:function(t){return this.includes(t)}},{key:"containsIgnoreCase",value:function(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}},{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}},{key:"toCharArray",value:function(t){for(var e=[],n=!0,r=0;r<this.length;r++){var i=this.charCodeAt(r);i>255&&(n=!1),e[r]=i}if(t){if(!n)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}}],[{key:"fromCharArray",value:function(t){var e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n])}return e}}]),r}(d),b=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}},{key:"toFloat32",value:function(){var t=new Float32Array(1);return t[0]=this,t[0]}}]),r}(d);o(b,"classProperties",{MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}}),o(b,"properties",{length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}});var x=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"createClass",value:function(t,e){return new Function(e?e.name:void 0,"return class ".concat(t).concat(e?" extends ".concat(e.name):""," {\n\t\t\tconstructor() {\n\t\t\t\t").concat(e?"super(...arguments);":"","\n\t\t\t}\n\t\t}"))(e)}}]),r}(d);o(x,"properties",{body:{get:function(){var t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},configurable:!0}});var M=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clear",value:function(){this.length=0}},{key:"includes",value:function(t){return this.indexOf(t)>-1}},{key:"clone",value:function(){if(!Object.clone)throw new Error("Object extension is required");return this.map((function(t){return Object.clone(t)}))}},{key:"unique",value:function(){var t=this;return this.filter((function(e,n){return t.indexOf(e)==n}))}},{key:"add",value:function(t){return!this.includes(t)&&(this.push(t),!0)}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.splice(e,0,t)}},{key:"indicesOf",value:function(t){var e=[],n=this.indexOf(t);if(-1!=n){e.push(n);for(var r=this.lastIndexOf(t);r>n;)n=this.indexOf(t,n+1),e.push(n)}return e}},{key:"remove",value:function(){for(var t=this,e=function(t){var e=[],n=-1;return t.forEach((function(t){n-t!=1&&e.push([]),e.last.push(t),n=t})),e},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.map((function(e){return t.indicesOf(e)})).flat().sort((function(t,e){return e-t}));return e(o).forEach((function(e){return t.removeAt(e.last,e.length)})),this}},{key:"removeAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t>-1&&this.splice(t,e),this}},{key:"replace",value:function(t,e,n){var r=this.indexOf(t);return r>-1&&(!n&&e instanceof Array?this.splice.apply(this,[r,1].concat(l(e))):this.splice(r,1,e)),this}}],[{key:"from",value:function(t){return Array.prototype.slice.call(t)}}]),r}(d);o(M,"properties",{first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}});var O=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toBase64",value:function(){if(!String.fromCharArray)throw new Error("String extension is required");var t=new Uint8Array(this);return btoa(String.fromCharArray(t))}}],[{key:"fromBase64",value:function(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}},{key:"isTypedArray",value:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}}]),r}(d),w=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"],k=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clone",value:function(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){var t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}},{key:"concat",value:function(){for(var t,e=this,n=this.length,r=this.length,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach((function(t){if(e.constructor!=t.constructor)throw new Error("Concat array from wrong type detected - expected ".concat(e.constructor.name,", found ").concat(t.constructor.name));n+=t.length})),(t="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(n):new this.constructor(n)).set(this),o.forEach((function(e){t.set(e,r),r+=e.length})),t}},{key:"toArray",value:function(){return Array.from(this)}}],[{key:"createSharedInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");var e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);var n=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(n);var r=new this(n);return r.set(t),r}},{key:"from",value:function(t){return new this(t)}},{key:"extend",value:function(){var t=this;w.forEach((function(e){if(d.extend(e+"Array",t)){var n=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return n.from(this)}}}))}}]),r}(d),S=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"map",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i=t(i))&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"filter",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;t(i)&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}}]),r}(d),E=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(d);o(E,"properties",{size:{get:function(){return{width:Math.floor(screen.width),height:Math.floor(screen.height)}},configurable:!0},resolution:{get:function(){return{width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}},configurable:!0}});var P=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"properties",get:function(){return{query:{get:function(){if(!this._query){var t=Object.assign.apply(Object,[{}].concat(l(this.search.substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=")})).map((function(t){return o({},t[0],decodeURIComponent(t[1]))})))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}}]),r}(d),D=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"getInlineStyle",value:function(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}},{key:"setStyle",value:function(t,e){var n=this;["-webkit","-khtml","-moz","-ms","-o"].forEach((function(r){return n.style[r+"-"+t]=e})),this.style[t]=e}},{key:"getStyle",value:function(t){var e=t,n=t.startsWith("-");n&&(e=t.substring(1));for(var r=e.split("-"),i=r.length-1;i>0;i--)r[i]=r[i].substring(0,1).toUpperCase()+r[i].substring(1);e=r.join("");var o=this.style.display,a=this.style.visibility;"none"==o&&(this.style.visibility="hidden",this.style.display="");var u=window.getComputedStyle(this)[e];if(!n&&void 0===u)for(var s=["-webkit","-khtml","-moz","-ms","-o"],c=0;c<s.length&&"undefined"==(u=this.getStyle(s[c]+"-"+t));c++);return"none"==o&&(this.style.visibility=a,this.style.display="none"),u}},{key:"getMathStyle",value:function(t,e){var n=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==n&&(n=0),parseFloat(n)}},{key:"getTransformStyle",value:function(){var t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),r=parseFloat(n[0]),i=parseFloat(n[1]),o=parseFloat(n[2]),a=parseFloat(n[3]),u=parseFloat(n[4]),s=parseFloat(n[5]);t.scale={x:Math.sqrt(r*r+o*o),y:Math.sqrt(a*a+i*i)},t.skew={angleX:Math.tan(o),angleY:Math.tan(i)},t.rotate={angle:Math.atan2(i,r)},t.translate={x:u,y:s},t.matrix={a:r,b:i,c:o,d:a,tx:u,ty:s}}return t}},{key:"toRect",value:function(){var t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");var n=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),r=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),i=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return i.outerSize=new DOMSize(n,r),"none"==t&&(this.style.visibility=e,this.style.display="none"),i}}]),r}(d),A=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toDataURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png",e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL("image/".concat(t))}},{key:"toBlob",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png";return new Blob([this.toArrayBuffer(t)],{type:"image/".concat(t)})}},{key:"toArrayBuffer",value:function(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");var e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}}]),r}(d),T=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"fromBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"png",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Image;return new Promise((function(r,i){n.onload=function(){URL.revokeObjectURL(n.src),r(n)},n.onerror=i,n.src=URL.createObjectURL(new Blob([t.buffer||t],{type:"image/".concat(e)}))}))}}]),r}(d),j=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"extend",value:function(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}}]),r}(d),F=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"transform",value:function(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}},{key:"toString",value:function(){return"point(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}}]),r}(d),C=function(){function t(e,r){n(this,t),this.width=e,this.height=r}return i(t,[{key:"toJSON",value:function(){return{width:this.width,height:this.height}}},{key:"toString",value:function(){return"size(".concat(this.width,", ").concat(this.height,")")}}],[{key:"fromSize",value:function(e){if(e instanceof t)return e;if("string"==typeof e){if(!e.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g);e={width:parseFloat(n[0]),height:parseFloat(n[1])}}if(isNaN(e.width))throw new Error("Invalid width found, expected number");if(isNaN(e.height))throw new Error("Invalid height found, expected number");return new t(e.width,e.height)}}]),t}(),R=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"union",value:function(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}},{key:"intersect",value:function(t){if(t){var e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}}},{key:"ceil",value:function(t){var e=Math.floor(this.left),n=Math.floor(this.top),r=Math.ceil(this.right),i=Math.ceil(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o+=o%2),i=n+(a+=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"floor",value:function(t){var e=Math.ceil(this.left),n=Math.ceil(this.top),r=Math.floor(this.right),i=Math.floor(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o-=o%2),i=n+(a-=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"contains",value:function(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}},{key:"transform",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));var e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),i=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),o=Math.min(e.x,n.x,r.x,i.x),a=Math.min(e.y,n.y,r.y,i.y),u=Math.max(e.x,n.x,r.x,i.x),s=Math.max(e.y,n.y,r.y,i.y);return DOMRect.ofEdges(o,a,u,s)}},{key:"matrixTransform",value:function(t){return this.transform(t)}},{key:"toPath",value:function(){var t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}},{key:"toString",value:function(){return"rect(".concat(this.x,", ").concat(this.y,", ").concat(this.width,", ").concat(this.height,")")}}],[{key:"ofEdges",value:function(t,e,n,r){return new DOMRect(t,e,n-t,r-e)}},{key:"extend",value:function(){d.extend("DOMRect",this)&&(globalThis.DOMSize=C)}}]),r}(d);o(R,"properties",{size:{get:function(){return new C(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}});var I=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"preMultiply",value:function(t){var e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}},{key:"multiply",value:function(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);var e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}},{key:"multiplySelf",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}},{key:"transformPoint",value:function(t){return DOMPoint.fromPoint(t).matrixTransform(this)}},{key:"invert",value:function(){return this.inverse()}},{key:"decompose",value:function(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}},{key:"disassemble",value:function(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}},{key:"toString",value:function(t){if(!t)return this.nativeToString();var e=function(t){return((t<0?"":" ")+t.toPrecision(6)).substring(0,8)};return" Matrix 4x4\n"+"-".repeat(39)+"\n".concat(e(this.m11),", ").concat(e(this.m21),", ").concat(e(this.m31),", ").concat(e(this.m41))+"\n".concat(e(this.m12),", ").concat(e(this.m22),", ").concat(e(this.m32),", ").concat(e(this.m42))+"\n".concat(e(this.m13),", ").concat(e(this.m23),", ").concat(e(this.m33),", ").concat(e(this.m43))+"\n".concat(e(this.m14),", ").concat(e(this.m24),", ").concat(e(this.m34),", ").concat(e(this.m44))}}],[{key:"fromMatrix",value:function(t,e){var n;return"string"==typeof t?n=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),n=DOMMatrix.nativeFromMatrix(t)),n.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,n}},{key:"fromTranslate",value:function(t){var e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}},{key:"fromRotate",value:function(t,e){var n=Math.sin(t),r=Math.cos(t),i={a:r,b:n,c:-n,d:r};return e&&(i.tx=e.x-e.x*r+e.y*n,i.ty=e.y-e.x*n-e.y*r),DOMMatrix.fromMatrix(i)}},{key:"fromScale",value:function(t,e){isFinite(t)&&(t={x:t,y:t});var n={a:t.x,d:t.y};return e&&(n.tx=e.x-e.x*t.x,n.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(n)}},{key:"fromPoints",value:function(t,e){var n=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=n.invert().preMultiply(r);return DOMMatrix.fromMatrix({a:i.m11,b:i.m12,c:i.m21,d:i.m22,tx:i.m31,ty:i.m32})}},{key:"extend",value:function(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,d.extend("DOMMatrix",this)}}]),r}(d);o(I,"overrides",d.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"])),o(I,"properties",{tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}}),o(I,"classProperties",{MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}});var B=Object.freeze({__proto__:null,ObjectExt:m,StringExt:g,NumberExt:b,FunctionExt:x,ArrayExt:M,ArrayBufferExt:O,TypedArrayExt:k,SetExt:S,ScreenExt:E,LocationExt:P,HTMLElementExt:D,HTMLImageElementExt:A,ImageExt:T,CanvasExt:j,DOMPointExt:F,DOMRectExt:R,DOMMatrixExt:I});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn("createEnum is deprecated, please update ".concat(t," enum with Object.defineEnum(target, name, values)")),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((function(t){var e=B["".concat(t,"Ext")];if(!e)throw new Error("Extension ".concat(t," not found"));e.extend(t)})),t.Extension=d,t.version="1.0.2",Object.defineProperty(t,"__esModule",{value:!0})})); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jsExt={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var i=u(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}function l(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var d=function(){function t(){n(this,t)}return i(t,null,[{key:"overrides",get:function(){return["toString"]}},{key:"extend",value:function(t){var e,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;return"string"==typeof t?(e=t,t=globalThis[e]):e=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,r.name),Object.getOwnPropertyNames(r.prototype).filter((function(t){return"constructor"!=t})).forEach((function(e){!(e in t.prototype)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride ".concat(e),"color: chartreuse"):console.log("%cdefine ".concat(e),"color: green")),t.prototype[e]=r.prototype[e]):n.debug&&console.log("%cexclude ".concat(e),"color: red")})),Object.getOwnPropertyNames(r).forEach((function(e){"function"==typeof r[e]&&"extend"!=e&&(!(e in t)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride static ".concat(e),"color: chartreuse"):console.log("%cdefine static ".concat(e),"color: orange")),t[e]=r[e]):n.debug&&console.log("%cexclude static ".concat(e),"color: red"))})),r.properties&&Object.keys(r.properties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t.prototype?n.debug&&console.log("%cexclude prop ".concat(e),"color: red"):r.properties[e]&&(n.debug&&console.log("%cdefine prop ".concat(e),"color: darkseagreen"),Object.defineProperty(t.prototype,e,r.properties[e]))})),r.classProperties&&Object.keys(r.classProperties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t?n.debug&&console.log("%cexclude static prop ".concat(e),"color: red"):r.classProperties[e]&&(n.debug&&console.log("%cdefine static prop ".concat(e),"color: chocolate"),Object.defineProperty(t,e,r.classProperties[e]))})),!0):(this.debug&&console.warn("============================================================ Class ".concat(e," not found")),!1)}}]),t}(),v=function(){function t(e,r,i){n(this,t),Object.defineProperty(this,"type",{value:e,enumerable:!0}),Object.defineProperty(this,"name",{value:r,enumerable:!0}),Object.defineProperty(this,"value",{value:i,enumerable:!0})}return i(t,[{key:"toString",value:function(){return this.name}}]),t}(),m=function(t){a(o,t);var r=f(o);function o(){return n(this,o),r.apply(this,arguments)}return i(o,null,[{key:"equals",value:function(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==n.length&&t.every((function(t,e){return Object.equals(t,n[e])}));for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!==e(t[r]))return!1;if(!Object.equals(t[r],n[r]))return!1}}for(var i in n)if(n.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}},{key:"clone",value:function(t,n){var r=new Array;return function t(i){if(null===i)return null;if("object"!==e(i)||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(var o=0;o<r.length;o++)if(r[o][0]===i)return r[o][1];var a=Object.create(Object.getPrototypeOf(i));for(var u in r.push([i,a]),i)n&&"function"==typeof i[u]||i.hasOwnProperty(u)&&(a[u]=t(i[u]));return a}(t)}},{key:"toSource",value:function(t,n){if("object"==e(t)){var r=[];for(var i in t)t.hasOwnProperty(i)&&r.push("".concat(i,": ").concat(Object.toSource(t[i])));return(n?"".concat(n," = "):"")+"{"+r.join(", ")+"}"}if("function"==typeof t){var o=t.toString();return t.name&&o.startsWith(t.name)&&(o="function "+o),o}return t}},{key:"defineEnum",value:function(t,e,n){if(t[e])throw new Error("Already exist property: ".concat(e));var r={values:n.map((function(t,n){return new v(e,t,n)}))};return r.values.forEach((function(t){Object.defineProperty(r,t.name,{value:t,enumerable:!0}),Object.defineProperty(r,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,e,{value:r,enumerable:!0}),r}}]),o}(d),g=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"startsWith",value:function(t){return this.length>=t.length&&this.substring(0,t.length)==t}},{key:"endsWith",value:function(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}},{key:"includes",value:function(t){return-1!=this.indexOf(t)}},{key:"contains",value:function(t){return this.includes(t)}},{key:"containsIgnoreCase",value:function(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}},{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}},{key:"toCharArray",value:function(t){for(var e=[],n=!0,r=0;r<this.length;r++){var i=this.charCodeAt(r);i>255&&(n=!1),e[r]=i}if(t){if(!n)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}}],[{key:"fromCharArray",value:function(t){var e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n])}return e}}]),r}(d),b=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}},{key:"toFloat32",value:function(){var t=new Float32Array(1);return t[0]=this,t[0]}}]),r}(d);o(b,"classProperties",{MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}}),o(b,"properties",{length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}});var x=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"createClass",value:function(t,e){return new Function(e?e.name:void 0,"return class ".concat(t).concat(e?" extends ".concat(e.name):""," {\n\t\t\tconstructor() {\n\t\t\t\t").concat(e?"super(...arguments);":"","\n\t\t\t}\n\t\t}"))(e)}}]),r}(d);o(x,"properties",{body:{get:function(){var t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},configurable:!0}});var M=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clear",value:function(){this.length=0}},{key:"includes",value:function(t){return this.indexOf(t)>-1}},{key:"clone",value:function(){if(!Object.clone)throw new Error("Object extension is required");return this.map((function(t){return Object.clone(t)}))}},{key:"unique",value:function(){var t=this;return this.filter((function(e,n){return t.indexOf(e)==n}))}},{key:"add",value:function(t){return!this.includes(t)&&(this.push(t),!0)}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.splice(e,0,t)}},{key:"indicesOf",value:function(t){var e=[],n=this.indexOf(t);if(-1!=n){e.push(n);for(var r=this.lastIndexOf(t);r>n;)n=this.indexOf(t,n+1),e.push(n)}return e}},{key:"remove",value:function(){for(var t=this,e=function(t){var e=[],n=-1;return t.forEach((function(t){n-t!=1&&e.push([]),e.last.push(t),n=t})),e},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.map((function(e){return t.indicesOf(e)})).flat().sort((function(t,e){return e-t}));return e(o).forEach((function(e){return t.removeAt(e.last,e.length)})),this}},{key:"removeAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t>-1&&this.splice(t,e),this}},{key:"replace",value:function(t,e,n){var r=this.indexOf(t);return r>-1&&(!n&&e instanceof Array?this.splice.apply(this,[r,1].concat(l(e))):this.splice(r,1,e)),this}}],[{key:"from",value:function(t){return Array.prototype.slice.call(t)}}]),r}(d);o(M,"properties",{first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}});var O=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toBase64",value:function(){if(!String.fromCharArray)throw new Error("String extension is required");var t=new Uint8Array(this);return btoa(String.fromCharArray(t))}}],[{key:"fromBase64",value:function(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}},{key:"isTypedArray",value:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}}]),r}(d),w=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"],k=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clone",value:function(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){var t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}},{key:"concat",value:function(){for(var t,e=this,n=this.length,r=this.length,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach((function(t){if(e.constructor!=t.constructor)throw new Error("Concat array from wrong type detected - expected ".concat(e.constructor.name,", found ").concat(t.constructor.name));n+=t.length})),(t="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(n):new this.constructor(n)).set(this),o.forEach((function(e){t.set(e,r),r+=e.length})),t}},{key:"toArray",value:function(){return Array.from(this)}}],[{key:"createSharedInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");var e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);var n=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(n);var r=new this(n);return r.set(t),r}},{key:"from",value:function(t){return new this(t)}},{key:"extend",value:function(){var t=this;w.forEach((function(e){if(d.extend(e+"Array",t)){var n=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return n.from(this)}}}))}}]),r}(d),S=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"map",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i=t(i))&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"filter",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;t(i)&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}}]),r}(d),E=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(d);o(E,"properties",{size:{get:function(){return{width:Math.floor(screen.width),height:Math.floor(screen.height)}},configurable:!0},resolution:{get:function(){return{width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}},configurable:!0}});var P=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"properties",get:function(){return{query:{get:function(){if(!this._query){var t=Object.assign.apply(Object,[{}].concat(l(this.search.substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=")})).map((function(t){return o({},t[0],decodeURIComponent(t[1]))})))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}}]),r}(d),D=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"getInlineStyle",value:function(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}},{key:"setStyle",value:function(t,e){var n=this;["-webkit","-khtml","-moz","-ms","-o"].forEach((function(r){return n.style[r+"-"+t]=e})),this.style[t]=e}},{key:"getStyle",value:function(t){var e=t,n=t.startsWith("-");n&&(e=t.substring(1));for(var r=e.split("-"),i=r.length-1;i>0;i--)r[i]=r[i].substring(0,1).toUpperCase()+r[i].substring(1);e=r.join("");var o=this.style.display,a=this.style.visibility;"none"==o&&(this.style.visibility="hidden",this.style.display="");var u=window.getComputedStyle(this)[e];if(!n&&void 0===u)for(var s=["-webkit","-khtml","-moz","-ms","-o"],c=0;c<s.length&&"undefined"==(u=this.getStyle(s[c]+"-"+t));c++);return"none"==o&&(this.style.visibility=a,this.style.display="none"),u}},{key:"getMathStyle",value:function(t,e){var n=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==n&&(n=0),parseFloat(n)}},{key:"getTransformStyle",value:function(){var t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),r=parseFloat(n[0]),i=parseFloat(n[1]),o=parseFloat(n[2]),a=parseFloat(n[3]),u=parseFloat(n[4]),s=parseFloat(n[5]);t.scale={x:Math.sqrt(r*r+o*o),y:Math.sqrt(a*a+i*i)},t.skew={angleX:Math.tan(o),angleY:Math.tan(i)},t.rotate={angle:Math.atan2(i,r)},t.translate={x:u,y:s},t.matrix={a:r,b:i,c:o,d:a,tx:u,ty:s}}return t}},{key:"toRect",value:function(){var t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");var n=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),r=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),i=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return i.outerSize=new DOMSize(n,r),"none"==t&&(this.style.visibility=e,this.style.display="none"),i}}]),r}(d),A=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toDataURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png",e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL("image/".concat(t))}},{key:"toBlob",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png";return new Blob([this.toArrayBuffer(t)],{type:"image/".concat(t)})}},{key:"toArrayBuffer",value:function(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");var e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}}]),r}(d),T=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"fromBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"png",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Image;return new Promise((function(r,i){n.onload=function(){URL.revokeObjectURL(n.src),r(n)},n.onerror=i,n.src=URL.createObjectURL(new Blob([t.buffer||t],{type:"image/".concat(e)}))}))}}]),r}(d),j=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"extend",value:function(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}}]),r}(d),F=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"transform",value:function(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}},{key:"toString",value:function(){return"point(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}}]),r}(d),C=function(){function t(e,r){n(this,t),this.width=e,this.height=r}return i(t,[{key:"toJSON",value:function(){return{width:this.width,height:this.height}}},{key:"toString",value:function(){return"size(".concat(this.width,", ").concat(this.height,")")}}],[{key:"fromSize",value:function(e){if(e instanceof t)return e;if("string"==typeof e){if(!e.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g);e={width:parseFloat(n[0]),height:parseFloat(n[1])}}if(isNaN(e.width))throw new Error("Invalid width found, expected number");if(isNaN(e.height))throw new Error("Invalid height found, expected number");return new t(e.width,e.height)}}]),t}(),R=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"union",value:function(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}},{key:"intersect",value:function(t){if(t){var e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}}},{key:"ceil",value:function(t){var e=Math.floor(this.left),n=Math.floor(this.top),r=Math.ceil(this.right),i=Math.ceil(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o+=o%2),i=n+(a+=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"floor",value:function(t){var e=Math.ceil(this.left),n=Math.ceil(this.top),r=Math.floor(this.right),i=Math.floor(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o-=o%2),i=n+(a-=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"contains",value:function(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}},{key:"transform",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));var e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),i=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),o=Math.min(e.x,n.x,r.x,i.x),a=Math.min(e.y,n.y,r.y,i.y),u=Math.max(e.x,n.x,r.x,i.x),s=Math.max(e.y,n.y,r.y,i.y);return DOMRect.ofEdges(o,a,u,s)}},{key:"matrixTransform",value:function(t){return this.transform(t)}},{key:"toPath",value:function(){var t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}},{key:"toString",value:function(){return"rect(".concat(this.x,", ").concat(this.y,", ").concat(this.width,", ").concat(this.height,")")}}],[{key:"ofEdges",value:function(t,e,n,r){return new DOMRect(t,e,n-t,r-e)}},{key:"extend",value:function(){d.extend("DOMRect",this)&&(globalThis.DOMSize=C)}}]),r}(d);o(R,"properties",{size:{get:function(){return new C(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}});var I=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"preMultiply",value:function(t){var e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}},{key:"multiply",value:function(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);var e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}},{key:"multiplySelf",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}},{key:"transformPoint",value:function(t){return DOMPoint.fromPoint(t).matrixTransform(this)}},{key:"invert",value:function(){return this.inverse()}},{key:"decompose",value:function(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}},{key:"disassemble",value:function(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}},{key:"toString",value:function(t){if(!t)return this.nativeToString();var e=function(t){return((t<0?"":" ")+t.toPrecision(6)).substring(0,8)};return" Matrix 4x4\n"+"-".repeat(39)+"\n".concat(e(this.m11),", ").concat(e(this.m21),", ").concat(e(this.m31),", ").concat(e(this.m41))+"\n".concat(e(this.m12),", ").concat(e(this.m22),", ").concat(e(this.m32),", ").concat(e(this.m42))+"\n".concat(e(this.m13),", ").concat(e(this.m23),", ").concat(e(this.m33),", ").concat(e(this.m43))+"\n".concat(e(this.m14),", ").concat(e(this.m24),", ").concat(e(this.m34),", ").concat(e(this.m44))}}],[{key:"fromMatrix",value:function(t,e){var n;return"string"==typeof t?n=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),n=DOMMatrix.nativeFromMatrix(t)),n.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,n}},{key:"fromTranslate",value:function(t){var e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}},{key:"fromRotate",value:function(t,e){var n=Math.sin(t),r=Math.cos(t),i={a:r,b:n,c:-n,d:r};return e&&(i.tx=e.x-e.x*r+e.y*n,i.ty=e.y-e.x*n-e.y*r),DOMMatrix.fromMatrix(i)}},{key:"fromScale",value:function(t,e){isFinite(t)&&(t={x:t,y:t});var n={a:t.x,d:t.y};return e&&(n.tx=e.x-e.x*t.x,n.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(n)}},{key:"fromPoints",value:function(t,e){var n=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=n.invert().preMultiply(r);return DOMMatrix.fromMatrix({a:i.m11,b:i.m12,c:i.m21,d:i.m22,tx:i.m31,ty:i.m32})}},{key:"extend",value:function(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,d.extend("DOMMatrix",this)}}]),r}(d);o(I,"overrides",d.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"])),o(I,"properties",{tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}}),o(I,"classProperties",{MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}});var B=Object.freeze({__proto__:null,ObjectExt:m,StringExt:g,NumberExt:b,FunctionExt:x,ArrayExt:M,ArrayBufferExt:O,TypedArrayExt:k,SetExt:S,ScreenExt:E,LocationExt:P,HTMLElementExt:D,HTMLImageElementExt:A,ImageExt:T,CanvasExt:j,DOMPointExt:F,DOMRectExt:R,DOMMatrixExt:I});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn("createEnum is deprecated, please update ".concat(t," enum with Object.defineEnum(target, name, values)")),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((function(t){var e=B["".concat(t,"Ext")];if(!e)throw new Error("Extension ".concat(t," not found"));e.extend(t)})),t.Extension=d,t.version="1.0.2",Object.defineProperty(t,"__esModule",{value:!0})})); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.js line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jsExt={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var i=u(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}function l(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var d=function(){function t(){n(this,t)}return i(t,null,[{key:"overrides",get:function(){return["toString"]}},{key:"extend",value:function(t){var e,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;return"string"==typeof t?(e=t,t=globalThis[e]):e=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,r.name),Object.getOwnPropertyNames(r.prototype).filter((function(t){return"constructor"!=t})).forEach((function(e){!(e in t.prototype)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride ".concat(e),"color: chartreuse"):console.log("%cdefine ".concat(e),"color: green")),t.prototype[e]=r.prototype[e]):n.debug&&console.log("%cexclude ".concat(e),"color: red")})),Object.getOwnPropertyNames(r).forEach((function(e){"function"==typeof r[e]&&"extend"!=e&&(!(e in t)||r.overrides.includes(e)?(n.debug&&(r.overrides.includes(e)?console.log("%coverride static ".concat(e),"color: chartreuse"):console.log("%cdefine static ".concat(e),"color: orange")),t[e]=r[e]):n.debug&&console.log("%cexclude static ".concat(e),"color: red"))})),r.properties&&Object.keys(r.properties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t.prototype?n.debug&&console.log("%cexclude prop ".concat(e),"color: red"):r.properties[e]&&(n.debug&&console.log("%cdefine prop ".concat(e),"color: darkseagreen"),Object.defineProperty(t.prototype,e,r.properties[e]))})),r.classProperties&&Object.keys(r.classProperties).filter((function(t){return!["__proto__","prototype","constructor"].includes(t)})).forEach((function(e){e in t?n.debug&&console.log("%cexclude static prop ".concat(e),"color: red"):r.classProperties[e]&&(n.debug&&console.log("%cdefine static prop ".concat(e),"color: chocolate"),Object.defineProperty(t,e,r.classProperties[e]))})),!0):(this.debug&&console.warn("============================================================ Class ".concat(e," not found")),!1)}}]),t}(),v=function(){function t(e,r,i){n(this,t),Object.defineProperty(this,"type",{value:e,enumerable:!0}),Object.defineProperty(this,"name",{value:r,enumerable:!0}),Object.defineProperty(this,"value",{value:i,enumerable:!0})}return i(t,[{key:"toString",value:function(){return this.name}}]),t}(),m=function(t){a(o,t);var r=f(o);function o(){return n(this,o),r.apply(this,arguments)}return i(o,null,[{key:"equals",value:function(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==n.length&&t.every((function(t,e){return Object.equals(t,n[e])}));for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!==e(t[r]))return!1;if(!Object.equals(t[r],n[r]))return!1}}for(var i in n)if(n.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}},{key:"clone",value:function(t,n){var r=new Array;return function t(i){if(null===i)return null;if("object"!==e(i)||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(var o=0;o<r.length;o++)if(r[o][0]===i)return r[o][1];var a=Object.create(Object.getPrototypeOf(i));for(var u in r.push([i,a]),i)n&&"function"==typeof i[u]||i.hasOwnProperty(u)&&(a[u]=t(i[u]));return a}(t)}},{key:"toSource",value:function(t,n){if("object"==e(t)){var r=[];for(var i in t)t.hasOwnProperty(i)&&r.push("".concat(i,": ").concat(Object.toSource(t[i])));return(n?"".concat(n," = "):"")+"{"+r.join(", ")+"}"}if("function"==typeof t){var o=t.toString();return t.name&&o.startsWith(t.name)&&(o="function "+o),o}return t}},{key:"defineEnum",value:function(t,e,n){if(t[e])throw new Error("Already exist property: ".concat(e));var r={values:n.map((function(t,n){return new v(e,t,n)}))};return r.values.forEach((function(t){Object.defineProperty(r,t.name,{value:t,enumerable:!0}),Object.defineProperty(r,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,e,{value:r,enumerable:!0}),r}}]),o}(d),g=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"startsWith",value:function(t){return this.length>=t.length&&this.substring(0,t.length)==t}},{key:"endsWith",value:function(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}},{key:"includes",value:function(t){return-1!=this.indexOf(t)}},{key:"contains",value:function(t){return this.includes(t)}},{key:"containsIgnoreCase",value:function(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}},{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}},{key:"toCharArray",value:function(t){for(var e=[],n=!0,r=0;r<this.length;r++){var i=this.charCodeAt(r);i>255&&(n=!1),e[r]=i}if(t){if(!n)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}}],[{key:"fromCharArray",value:function(t){var e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n])}return e}}]),r}(d),b=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"pad",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}},{key:"toFloat32",value:function(){var t=new Float32Array(1);return t[0]=this,t[0]}}]),r}(d);o(b,"classProperties",{MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}}),o(b,"properties",{length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}});var x=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"createClass",value:function(t,e){return new Function(e?e.name:void 0,"return class ".concat(t).concat(e?" extends ".concat(e.name):""," {\n\t\t\tconstructor() {\n\t\t\t\t").concat(e?"super(...arguments);":"","\n\t\t\t}\n\t\t}"))(e)}}]),r}(d);o(x,"properties",{body:{get:function(){var t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},configurable:!0}});var M=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clear",value:function(){this.length=0}},{key:"includes",value:function(t){return this.indexOf(t)>-1}},{key:"clone",value:function(){if(!Object.clone)throw new Error("Object extension is required");return this.map((function(t){return Object.clone(t)}))}},{key:"unique",value:function(){var t=this;return this.filter((function(e,n){return t.indexOf(e)==n}))}},{key:"add",value:function(t){return!this.includes(t)&&(this.push(t),!0)}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.splice(e,0,t)}},{key:"indicesOf",value:function(t){var e=[],n=this.indexOf(t);if(-1!=n){e.push(n);for(var r=this.lastIndexOf(t);r>n;)n=this.indexOf(t,n+1),e.push(n)}return e}},{key:"remove",value:function(){for(var t=this,e=function(t){var e=[],n=-1;return t.forEach((function(t){n-t!=1&&e.push([]),e.last.push(t),n=t})),e},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.map((function(e){return t.indicesOf(e)})).flat().sort((function(t,e){return e-t}));return e(o).forEach((function(e){return t.removeAt(e.last,e.length)})),this}},{key:"removeAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t>-1&&this.splice(t,e),this}},{key:"replace",value:function(t,e,n){var r=this.indexOf(t);return r>-1&&(!n&&e instanceof Array?this.splice.apply(this,[r,1].concat(l(e))):this.splice(r,1,e)),this}}],[{key:"from",value:function(t){return Array.prototype.slice.call(t)}}]),r}(d);o(M,"properties",{first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}});var O=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toBase64",value:function(){if(!String.fromCharArray)throw new Error("String extension is required");var t=new Uint8Array(this);return btoa(String.fromCharArray(t))}}],[{key:"fromBase64",value:function(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}},{key:"isTypedArray",value:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}}]),r}(d),w=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"],k=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"clone",value:function(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){var t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}},{key:"concat",value:function(){for(var t,e=this,n=this.length,r=this.length,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return o.forEach((function(t){if(e.constructor!=t.constructor)throw new Error("Concat array from wrong type detected - expected ".concat(e.constructor.name,", found ").concat(t.constructor.name));n+=t.length})),(t="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(n):new this.constructor(n)).set(this),o.forEach((function(e){t.set(e,r),r+=e.length})),t}},{key:"toArray",value:function(){return Array.from(this)}}],[{key:"createSharedInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");var e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);var n=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(n);var r=new this(n);return r.set(t),r}},{key:"from",value:function(t){return new this(t)}},{key:"extend",value:function(){var t=this;w.forEach((function(e){if(d.extend(e+"Array",t)){var n=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return n.from(this)}}}))}}]),r}(d),S=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"map",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i=t(i))&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"filter",value:function(t){var e,n=new Set,r=p(this);try{for(r.s();!(e=r.n()).done;){var i=e.value;t(i)&&n.add(i)}}catch(t){r.e(t)}finally{r.f()}return n}}]),r}(d),E=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(d);o(E,"properties",{size:{get:function(){return{width:Math.floor(screen.width),height:Math.floor(screen.height)}},configurable:!0},resolution:{get:function(){return{width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}},configurable:!0}});var P=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"properties",get:function(){return{query:{get:function(){if(!this._query){var t=Object.assign.apply(Object,[{}].concat(l(this.search.substring(1).split("&").filter((function(t){return t})).map((function(t){return t.split("=")})).map((function(t){return o({},t[0],decodeURIComponent(t[1]))})))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}}]),r}(d),D=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"getInlineStyle",value:function(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}},{key:"setStyle",value:function(t,e){var n=this;["-webkit","-khtml","-moz","-ms","-o"].forEach((function(r){return n.style[r+"-"+t]=e})),this.style[t]=e}},{key:"getStyle",value:function(t){var e=t,n=t.startsWith("-");n&&(e=t.substring(1));for(var r=e.split("-"),i=r.length-1;i>0;i--)r[i]=r[i].substring(0,1).toUpperCase()+r[i].substring(1);e=r.join("");var o=this.style.display,a=this.style.visibility;"none"==o&&(this.style.visibility="hidden",this.style.display="");var u=window.getComputedStyle(this)[e];if(!n&&void 0===u)for(var s=["-webkit","-khtml","-moz","-ms","-o"],c=0;c<s.length&&"undefined"==(u=this.getStyle(s[c]+"-"+t));c++);return"none"==o&&(this.style.visibility=a,this.style.display="none"),u}},{key:"getMathStyle",value:function(t,e){var n=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==n&&(n=0),parseFloat(n)}},{key:"getTransformStyle",value:function(){var t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),r=parseFloat(n[0]),i=parseFloat(n[1]),o=parseFloat(n[2]),a=parseFloat(n[3]),u=parseFloat(n[4]),s=parseFloat(n[5]);t.scale={x:Math.sqrt(r*r+o*o),y:Math.sqrt(a*a+i*i)},t.skew={angleX:Math.tan(o),angleY:Math.tan(i)},t.rotate={angle:Math.atan2(i,r)},t.translate={x:u,y:s},t.matrix={a:r,b:i,c:o,d:a,tx:u,ty:s}}return t}},{key:"toRect",value:function(){var t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");var n=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),r=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),i=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return i.outerSize=new DOMSize(n,r),"none"==t&&(this.style.visibility=e,this.style.display="none"),i}}]),r}(d),A=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"toDataURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png",e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL("image/".concat(t))}},{key:"toBlob",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"png";return new Blob([this.toArrayBuffer(t)],{type:"image/".concat(t)})}},{key:"toArrayBuffer",value:function(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");var e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}}]),r}(d),T=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"fromBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"png",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Image;return new Promise((function(r,i){n.onload=function(){URL.revokeObjectURL(n.src),r(n)},n.onerror=i,n.src=URL.createObjectURL(new Blob([t.buffer||t],{type:"image/".concat(e)}))}))}}]),r}(d),j=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,null,[{key:"extend",value:function(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}}]),r}(d),F=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"transform",value:function(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}},{key:"toString",value:function(){return"point(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}}]),r}(d),C=function(){function t(e,r){n(this,t),this.width=e,this.height=r}return i(t,[{key:"toJSON",value:function(){return{width:this.width,height:this.height}}},{key:"toString",value:function(){return"size(".concat(this.width,", ").concat(this.height,")")}}],[{key:"fromSize",value:function(e){if(e instanceof t)return e;if("string"==typeof e){if(!e.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");var n=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g);e={width:parseFloat(n[0]),height:parseFloat(n[1])}}if(isNaN(e.width))throw new Error("Invalid width found, expected number");if(isNaN(e.height))throw new Error("Invalid height found, expected number");return new t(e.width,e.height)}}]),t}(),R=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"union",value:function(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}},{key:"intersect",value:function(t){if(t){var e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}}},{key:"ceil",value:function(t){var e=Math.floor(this.left),n=Math.floor(this.top),r=Math.ceil(this.right),i=Math.ceil(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o+=o%2),i=n+(a+=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"floor",value:function(t){var e=Math.ceil(this.left),n=Math.ceil(this.top),r=Math.floor(this.right),i=Math.floor(this.bottom);if(t){var o=this.width,a=this.height;r=e+(o-=o%2),i=n+(a-=a%2)}return DOMRect.ofEdges(e,n,r,i)}},{key:"contains",value:function(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}},{key:"transform",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));var e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),i=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),o=Math.min(e.x,n.x,r.x,i.x),a=Math.min(e.y,n.y,r.y,i.y),u=Math.max(e.x,n.x,r.x,i.x),s=Math.max(e.y,n.y,r.y,i.y);return DOMRect.ofEdges(o,a,u,s)}},{key:"matrixTransform",value:function(t){return this.transform(t)}},{key:"toPath",value:function(){var t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}},{key:"toString",value:function(){return"rect(".concat(this.x,", ").concat(this.y,", ").concat(this.width,", ").concat(this.height,")")}}],[{key:"ofEdges",value:function(t,e,n,r){return new DOMRect(t,e,n-t,r-e)}},{key:"extend",value:function(){d.extend("DOMRect",this)&&(globalThis.DOMSize=C)}}]),r}(d);o(R,"properties",{size:{get:function(){return new C(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}});var I=function(t){a(r,t);var e=f(r);function r(){return n(this,r),e.apply(this,arguments)}return i(r,[{key:"preMultiply",value:function(t){var e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}},{key:"multiply",value:function(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);var e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}},{key:"multiplySelf",value:function(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}},{key:"transformPoint",value:function(t){return DOMPoint.fromPoint(t).matrixTransform(this)}},{key:"invert",value:function(){return this.inverse()}},{key:"decompose",value:function(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}},{key:"disassemble",value:function(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}},{key:"toString",value:function(t){if(!t)return this.nativeToString();var e=function(t){return((t<0?"":" ")+t.toPrecision(6)).substring(0,8)};return" Matrix 4x4\n"+"-".repeat(39)+"\n".concat(e(this.m11),", ").concat(e(this.m21),", ").concat(e(this.m31),", ").concat(e(this.m41))+"\n".concat(e(this.m12),", ").concat(e(this.m22),", ").concat(e(this.m32),", ").concat(e(this.m42))+"\n".concat(e(this.m13),", ").concat(e(this.m23),", ").concat(e(this.m33),", ").concat(e(this.m43))+"\n".concat(e(this.m14),", ").concat(e(this.m24),", ").concat(e(this.m34),", ").concat(e(this.m44))}}],[{key:"fromMatrix",value:function(t,e){var n;return"string"==typeof t?n=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),n=DOMMatrix.nativeFromMatrix(t)),n.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,n}},{key:"fromTranslate",value:function(t){var e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}},{key:"fromRotate",value:function(t,e){var n=Math.sin(t),r=Math.cos(t),i={a:r,b:n,c:-n,d:r};return e&&(i.tx=e.x-e.x*r+e.y*n,i.ty=e.y-e.x*n-e.y*r),DOMMatrix.fromMatrix(i)}},{key:"fromScale",value:function(t,e){isFinite(t)&&(t={x:t,y:t});var n={a:t.x,d:t.y};return e&&(n.tx=e.x-e.x*t.x,n.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(n)}},{key:"fromPoints",value:function(t,e){var n=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),r=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=n.invert().preMultiply(r);return DOMMatrix.fromMatrix({a:i.m11,b:i.m12,c:i.m21,d:i.m22,tx:i.m31,ty:i.m32})}},{key:"extend",value:function(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,d.extend("DOMMatrix",this)}}]),r}(d);o(I,"overrides",d.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"])),o(I,"properties",{tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}}),o(I,"classProperties",{MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}});var B=Object.freeze({__proto__:null,ObjectExt:m,StringExt:g,NumberExt:b,FunctionExt:x,ArrayExt:M,ArrayBufferExt:O,TypedArrayExt:k,SetExt:S,ScreenExt:E,LocationExt:P,HTMLElementExt:D,HTMLImageElementExt:A,ImageExt:T,CanvasExt:j,DOMPointExt:F,DOMRectExt:R,DOMMatrixExt:I});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn("createEnum is deprecated, please update ".concat(t," enum with Object.defineEnum(target, name, values)")),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this["on".concat(t)]=function(n){var r="message"==t?n.data:n;e(r)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((function(t){var e=B["".concat(t,"Ext")];if(!e)throw new Error("Extension ".concat(t," not found"));e.extend(t)})),t.Extension=d,t.version="1.0.2",Object.defineProperty(t,"__esModule",{value:!0})})); -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s}),a="1.0.2";"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)}));export{t as Extension,a as version}; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s}),a="1.0.2";"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)}));export{t as Extension,a as version}; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s}),a="1.0.2";"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)}));export{t as Extension,a as version}; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s}),a="1.0.2";"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)}));export{t as Extension,a as version}; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s}),a="1.0.2";"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)}));export{t as Extension,a as version}; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/digital-ink/digital-ink-min.mjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
import"js-ext";import*as e from"js-md5";import t from"long";import{vec2 as r,vec3 as i,vec4 as s,quat2 as n,mat4 as o,mat2d as a}from"gl-matrix";import*as l from"poly2tri";import*as h from"clipper-lib";import d from"rbush";import*as c from"jszip";import*as p from"protobufjs";var u="1.5.0";class f{getInkBuilder(e){throw new Error("InkController.getInkBuilder(pointerID) is abstract and should be implemented")}registerInputProvider(e,t){throw new Error("InkController.registerInputProvider(pointerID, isPrimary) is abstract and should be implemented")}reset(e){throw new Error("InkController.reset(sensorPoint) is abstract and should be implemented")}begin(e){throw new Error("InkController.begin(sensorPoint) is abstract and should be implemented")}move(e,t){throw new Error("InkController.move(sensorPoint, [prediction]) is abstract and should be implemented")}end(e){throw new Error("InkController.end(sensorPoint) is abstract and should be implemented")}abort(e){throw new Error("InkController.abort(pointerID) is abstract and should be implemented")}resize(e){throw new Error("InkController.resize() is abstract and should be implemented")}}let m=e?e.default||globalThis.md5:{},g={mask:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",generate(){let e=Date.now();return this.mask.replace(/[xy]/g,(function(t){let r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))},validate:e=>"string"==typeof e&&!!e.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/),format(e){let t=[],r=0;return this.mask.split("-").forEach((i=>{t.push(e.substring(r,r+i.length)),r+=i.length})),t.join("-")},fromString(e){return this.fromBytes(new Uint8Array(m.arrayBuffer(e)))},toBytes(e){let t=[];return e.split("-").map(((e,r)=>{(r<3?e.match(/.{1,2}/g).reverse():e.match(/.{1,2}/g)).map((e=>t.push(parseInt(e,16))))})),new Uint8Array(t)},fromBytes(e){let t=Array.from(e).map((e=>e.toString(16))).map((e=>(1==e.length?"0":"")+e));return t.slice(0,4).reverse().join("")+"-"+t.slice(4,6).reverse().join("")+"-"+t.slice(6,8).reverse().join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")},toUint32Array(e){let t=new Uint32Array(4),r=this.toBytes(e);return t[0]=new Uint32Array(r.slice(0,4).buffer)[0],t[1]=new Uint32Array(r.slice(4,8).buffer)[0],t[2]=new Uint32Array(r.slice(8,12).buffer)[0],t[3]=new Uint32Array(r.slice(12).buffer)[0],t},fromUint32Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toUint64Array(e){let t=new BigUint64Array(2),r=this.toBytes(e);return t[0]=new BigUint64Array(r.slice(0,8).buffer)[0],t[1]=new BigUint64Array(r.slice(8).buffer)[0],t},fromUint64Array(e){return this.fromBytes(new Uint8Array(e.buffer))},toLongArray(e){let r=new Array(2),i=this.toBytes(e);return r[0]=t.fromBytes(i.slice(0,8)),r[1]=t.fromBytes(i.slice(8)),r},fromLongArray(e){let t=e[0].toBytes().concat(e[1].toBytes());return this.fromBytes(t)}};class y{static get SEPARATOR(){return"\n"}#e;constructor(e){let t;if(this.#e=e,"function"==typeof this.getMD5Message)t=y.Algorithm.MD5;else if("function"==typeof this.buildURI)t=y.Algorithm.URI;else if(t=y.Algorithm.GUID,e&&!g.validate(e))throw new Error(`Identifiable ${e} is not a well formed UUID`);Object.defineProperty(this,"algorithm",{value:t}),Object.defineProperty(this,"id",{get:()=>(this.#e||(this.#e=this.resolveID()),this.#e),set:e=>{if(this.#e)throw new Error("id is immutable");this.#e=e},enumerable:!0})}invalidateID(){if(this.algorithm!=y.Algorithm.MD5)throw new Error(`Invalidate id is not applicable for ${this.algorithm} algorithm`);this.#e=void 0}resolveID(){if(this.algorithm==y.Algorithm.MD5){let e="",t=this.getMD5Message();for(let r of t){if(Array.isArray(r))for(let t of r)e+=t,e+="\n";else e+=r;e+="\n"}if(!e)throw new Error("Empty MD5 message container found");return m(e)}return this.algorithm==y.Algorithm.URI?this.buildURI():g.generate()}static buildMD5Tokens(e){let t=[];return Object.keys(e).sort().forEach((r=>t.push(r,e[r]))),t}}Object.defineEnum(y,"Algorithm",["GUID","MD5","URI"]);class b extends y{constructor(e,t={}){super(),this.type=e,this.props=Object.assign({},t)}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. InkInputProvider do not belongs to any SensorChannelsContext yet");return["InkInputProvider",this.type.name,y.buildMD5Tokens(this.props)]}}Object.defineEnum(b,"Type",["PEN","TOUCH","MOUSE","CONTROLLER"]);class E{constructor(){this.phase=E.Phase.END}add(e,t,r){if(!this.move(e))throw new Error(`Cannot move from phase ${this.phase.name} to phase ${e.name}`);return this.debug&&(console.log("-------------------------------------"),console.log(this.constructor.name,e.name)),this.addImpl(t,r)}addImpl(e,t){throw new Error("Abstract method addImpl of DataProcessor should be implemented")}move(e){return(this.phase!=E.Phase.END||e==E.Phase.BEGIN)&&((this.phase!=E.Phase.BEGIN||e==E.Phase.UPDATE||e==E.Phase.END)&&((this.phase!=E.Phase.UPDATE||e==E.Phase.UPDATE||e==E.Phase.END)&&(e==E.Phase.BEGIN&&this.reset(),this.phase=e,!0)))}reset(){this.phase=E.Phase.END}}Object.defineEnum(E,"Phase",["BEGIN","UPDATE","END"]);class P{constructor(e,t,n,o){if(isNaN(e))throw new Error(`Invalid x found: ${e}`);if(isNaN(t))throw new Error(`Invalid y found: ${t}`);let a=[e,t];isFinite(n)&&(a.push(n),isFinite(o)&&a.push(o)),this.value=a.toFloat32Array(),Object.defineProperty(this,"x",{get:()=>this.value[0],set:e=>{this.value[0]=e},enumerable:!0}),Object.defineProperty(this,"y",{get:()=>this.value[1],set:e=>{this.value[1]=e},enumerable:!0}),2==a.length?this.vec=r:3==a.length?(this.vec=i,Object.defineProperty(this,"z",{get:()=>this.value[2],set:e=>{this.value[2]=e},enumerable:!0})):(this.vec=s,Object.defineProperty(this,"w",{get:()=>this.value[3],set:e=>{this.value[3]=e},enumerable:!0}))}add(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.add(t,this.value,e.value),P.fromPoint(t)}addSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.add(this.value,this.value,e.value),this}subtract(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.subtract(t,this.value,e.value),P.fromPoint(t)}subtractSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.subtract(this.value,this.value,e.value),this}multiply(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.multiply(t,this.value,e.value),P.fromPoint(t)}multiplySelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.multiply(this.value,this.value,e.value),this}divide(e){e instanceof P||(e=P.fromPoint(e));let t=this.vec.create();return this.vec.divide(t,this.value,e.value),P.fromPoint(t)}divideSelf(e){return e instanceof P||(e=P.fromPoint(e)),this.vec.divide(this.value,this.value,e.value),this}scale(e){let t=this.vec.create();return this.vec.scale(t,this.value,e),P.fromPoint(t)}scaleSelf(e){return this.vec.scale(this.value,this.value,e),this}abs(){return new P(Math.abs(this.x),Math.abs(this.y),isFinite(this.z)?Math.abs(this.z):void 0,isFinite(this.w)?Math.abs(this.w):void 0)}absSelf(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),isFinite(this.z)&&(this.z=Math.abs(this.z)),isFinite(this.w)&&(this.w=Math.abs(this.w)),this}transform(e){if(!e)return this;let t=this.vec.create();return this.vec.transformMat4(t,this.value,e.toFloat32Array()),P.fromPoint(t)}transformSelf(e){return this.vec.transformMat4(this.value,this.value,e.toFloat32Array()),this}toFloat32Array(){return this.value}toJSON(){let e={x:this.x,y:this.y};return isFinite(this.z)&&(e.z=this.z,isFinite(this.w)&&(e.w=this.w)),e}toString(){return`point(${this.value.join(", ")})`}clone(){return P.fromPoint(this)}static fromPoint(e){return Array.isArray(e)||ArrayBuffer.isTypedArray(e)?new P(e[0],e[1],e[2],e[3]):new P(e.x,e.y,e.z,e.w)}}class I{constructor(e,t,r,i){let s=e,n=t,o=e+r,a=t+i;Object.defineProperties(this,{left:{value:s,enumerable:!0},x:{value:e,enumerable:!0},bottom:{value:n,enumerable:!0},y:{value:t,enumerable:!0},right:{value:o,enumerable:!0},top:{value:a,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0}})}union(e){if(e&&!(e instanceof I))throw new TypeError("rect must be instance of RectGL");return e?I.ofEdges(Math.min(this.left,e.left),Math.min(this.bottom,e.bottom),Math.max(this.right,e.right),Math.max(this.top,e.top)):this}intersect(e){if(e&&!(e instanceof I))throw new TypeError("rect must be instance of RectGL");if(!e)return null;let t=I.ofEdges(Math.max(this.left,e.left),Math.max(this.bottom,e.bottom),Math.min(this.right,e.right),Math.min(this.top,e.top));return t.width>0&&t.height>0?t:null}ceil(){return I.ofEdges(Math.floor(this.left),Math.floor(this.bottom),Math.ceil(this.right),Math.ceil(this.top))}floor(){return I.ofEdges(Math.ceil(this.left),Math.ceil(this.bottom),Math.floor(this.right),Math.floor(this.top))}transform(e){if(!e)return this;let t=P.fromPoint({x:this.left,y:this.bottom}).transform(e),r=P.fromPoint({x:this.right,y:this.bottom}).transform(e),i=P.fromPoint({x:this.left,y:this.top}).transform(e),s=P.fromPoint({x:this.right,y:this.top}).transform(e),n=Math.min(i.x,s.x,t.x,r.x),o=Math.min(i.y,s.y,t.y,r.y),a=Math.max(i.x,s.x,t.x,r.x),l=Math.max(i.y,s.y,t.y,r.y);return I.ofEdges(n,o,a,l)}toQuad(e){let t;if(e){let r=P.fromPoint({x:this.left,y:this.bottom}).transform(e),i=P.fromPoint({x:this.right,y:this.bottom}).transform(e),s=P.fromPoint({x:this.left,y:this.top}).transform(e),o=P.fromPoint({x:this.right,y:this.top}).transform(e);t=n.fromValues(r.x,r.y,i.x,i.y,s.x,s.y,o.x,o.y)}else t=n.fromValues(this.left,this.bottom,this.right,this.bottom,this.left,this.top,this.right,this.top);return t}toString(){return`gl-rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(e,t,r,i){return new I(e,t,r-e,i-t)}static calculateBrushGLSegmentBounds(e,t=0,r){let i,s=.5*e.size,n=Math.abs(t*s);if(r){i=new P(e.x,e.y,e.x,e.z).transform(r)}else i=e;let o=i.x,a=i.y,l=e.scaleX*s,h=e.scaleY*s,d=e.offsetX,c=-e.offsetY,p=Math.cos(e.rotation),u=Math.sin(e.rotation),f=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER,y=Number.MIN_SAFE_INTEGER;for(let e of I.SQURE){let t=e.x*l+d,r=e.y*h+c,i=p*t+u*r+o,s=-u*t+p*r+a,b=i-n;f=Math.min(f,b),m=Math.max(m,b),b=i+n,f=Math.min(f,b),m=Math.max(m,b);let E=s-n;g=Math.min(g,E),y=Math.max(y,E),E=s+n,g=Math.min(g,E),y=Math.max(y,E)}return I.ofEdges(f,g,m,y)}}Object.defineProperty(I,"SQURE",{value:Object.freeze([Object.freeze({x:-1,y:-1}),Object.freeze({x:1,y:-1}),Object.freeze({x:-1,y:1}),Object.freeze({x:1,y:1})]),enumerable:!0});class S{constructor(e,t,r,i){let s,n,o,a=e,l=t,h=e+r,d=t+i;Object.defineProperties(this,{left:{value:a,enumerable:!0},top:{value:l,enumerable:!0},right:{value:h,enumerable:!0},bottom:{value:d,enumerable:!0},x:{value:e,enumerable:!0},y:{value:t,enumerable:!0},width:{value:r,enumerable:!0},height:{value:i,enumerable:!0},size:{get:()=>(s||(s={width:r,height:i}),s),enumerable:!0},area:{get:()=>(n||(n=r*i),n),enumerable:!0},center:{get:()=>(o||(o={x:(a+h)/2,y:(l+d)/2}),o),enumerable:!0}})}union(e){return e?S.ofEdges(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom)):this}intersect(e){if(!e)return null;let t=S.ofEdges(Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom));return t.width>0&&t.height>0?t:null}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top}ceil(e){let t=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),s=Math.ceil(this.bottom);if(e){let e=i-t,n=s-r;e+=e%2,n+=n%2,i=t+e,s=r+n}return S.ofEdges(t,r,i,s)}floor(e){let t=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),s=Math.floor(this.bottom);if(e){let e=i-t,n=s-r;e-=e%2,n-=n%2,i=t+e,s=r+n}return S.ofEdges(t,r,i,s)}contains(e){return this.left<=e.x&&this.right>=e.x&&this.top<=e.y&&this.bottom>=e.y}includes(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom}transform(e){if(!e)return this;let t=P.fromPoint({x:this.left,y:this.top}).transform(e),r=P.fromPoint({x:this.right,y:this.top}).transform(e),i=P.fromPoint({x:this.left,y:this.bottom}).transform(e),s=P.fromPoint({x:this.right,y:this.bottom}).transform(e),n=Math.min(t.x,r.x,i.x,s.x),o=Math.min(t.y,r.y,i.y,s.y),a=Math.max(t.x,r.x,i.x,s.x),l=Math.max(t.y,r.y,i.y,s.y);return S.ofEdges(n,o,a,l)}toPath(e,t=1){throw new Error("Rect.toPath is deprecated. Path.fromRect(rect, [pointProps]) instead")}toGLRect(){return new I(this.x,this.y,this.width,this.height)}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toJSON(){return{x:this.left,y:this.top,width:this.width,height:this.height}}static fromGLRect(e){if(!e)return null;if(!(e instanceof I))throw new TypeError("rect must be instance of RectGL");return new S(e.left,e.bottom,e.width,e.height)}static isRect(e){return e&&isFinite(e.left)&&isFinite(e.top)&&isFinite(e.width)&&isFinite(e.height)}static fromString(e){return e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),new S(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]))}static fromRect(e){return"string"==typeof e?S.fromString(e):new S(e.x,e.y,e.width,e.height)}static ofPolygon(e){if(e.shape&&(e=e.shape),0==e.length)return null;let t=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let n=0;n<e.length;n++){let o=e.getPointX(n),a=e.getPointY(n);t=Math.min(t,o),r=Math.min(r,a),i=Math.max(i,o),s=Math.max(s,a)}return S.ofEdges(t,r,i,s)}static ofSpline(e,t=0){let r;for(let i=0;i<e.length;i++)r=I.calculateBrushGLSegmentBounds(e.getPointRef(i),t).union(r);return S.fromGLRect(r)}static ofEdges(e,t,r,i){let s=Math.min(e,r),n=Math.min(t,i),o=Math.max(e,r),a=Math.max(t,i);return new S(s,n,o-s,a-n)}static union(e,t){return e?t?e.union(t):e:t}static intersect(e,t){return e&&t?e.intersect(t):null}}const w={m11:0,m12:1,m13:2,m14:3,m21:4,m22:5,m23:6,m24:7,m31:8,m32:9,m33:10,m34:11,m41:12,m42:13,m43:14,m44:15},x=w.m11,v=w.m12,R=w.m21,T=w.m22,A=w.m41,C=w.m42;class O{constructor(e=o.create(),t=O.MultiplicationType.PRE){Object.defineProperty(this,"value",{value:e,enumerable:!0}),Object.defineProperty(this,"multiplicationType",{value:t,enumerable:!0});let r=function(e,t){let r=w[e];this.value[r]=t};Object.defineProperty(this,"a",{get:()=>this.value[x],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"b",{get:()=>this.value[v],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"c",{get:()=>this.value[R],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"d",{get:()=>this.value[T],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"e",{get:()=>this.value[A],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"f",{get:()=>this.value[C],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"tx",{get:()=>this.value[A],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"ty",{get:()=>this.value[C],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m11",{get:()=>this.value[0],set:r.bind(this,"m11"),enumerable:!0}),Object.defineProperty(this,"m12",{get:()=>this.value[1],set:r.bind(this,"m12"),enumerable:!0}),Object.defineProperty(this,"m13",{get:()=>this.value[2],set:r.bind(this,"m13"),enumerable:!0}),Object.defineProperty(this,"m14",{get:()=>this.value[3],set:r.bind(this,"m14"),enumerable:!0}),Object.defineProperty(this,"m21",{get:()=>this.value[4],set:r.bind(this,"m21"),enumerable:!0}),Object.defineProperty(this,"m22",{get:()=>this.value[5],set:r.bind(this,"m22"),enumerable:!0}),Object.defineProperty(this,"m23",{get:()=>this.value[6],set:r.bind(this,"m23"),enumerable:!0}),Object.defineProperty(this,"m24",{get:()=>this.value[7],set:r.bind(this,"m24"),enumerable:!0}),Object.defineProperty(this,"m31",{get:()=>this.value[8],set:r.bind(this,"m31"),enumerable:!0}),Object.defineProperty(this,"m32",{get:()=>this.value[9],set:r.bind(this,"m32"),enumerable:!0}),Object.defineProperty(this,"m33",{get:()=>this.value[10],set:r.bind(this,"m33"),enumerable:!0}),Object.defineProperty(this,"m34",{get:()=>this.value[11],set:r.bind(this,"m34"),enumerable:!0}),Object.defineProperty(this,"m41",{get:()=>this.value[12],set:r.bind(this,"m41"),enumerable:!0}),Object.defineProperty(this,"m42",{get:()=>this.value[13],set:r.bind(this,"m42"),enumerable:!0}),Object.defineProperty(this,"m43",{get:()=>this.value[14],set:r.bind(this,"m43"),enumerable:!0}),Object.defineProperty(this,"m44",{get:()=>this.value[15],set:r.bind(this,"m44"),enumerable:!0}),Object.defineProperty(this,"isIdentity",{get:()=>1==this.a&&0==this.b&&0==this.c&&1==this.d&&0==this.tx&&0==this.ty,enumerable:!0}),Object.defineProperty(this,"is2D",{get:()=>!(0!=this.m31||0!=this.m32||0!=this.m13||0!=this.m23||1!=this.m33||0!=this.m43||0!=this.m14||0!=this.m24||0!=this.m34||1!=this.m44),enumerable:!0}),Object.defineProperty(this,"translateX",{get:()=>this.tx}),Object.defineProperty(this,"translateY",{get:()=>this.ty}),Object.defineProperty(this,"skewX",{get:()=>Math.tan(this.c)}),Object.defineProperty(this,"skewY",{get:()=>Math.tan(this.b)}),Object.defineProperty(this,"scaleX",{get:()=>Math.sqrt(this.a*this.a+this.c*this.c)}),Object.defineProperty(this,"scaleY",{get:()=>Math.sqrt(this.d*this.d+this.b*this.b)}),Object.defineProperty(this,"rotation",{get:()=>Math.atan2(this.b,this.a)})}clone(){return new O(this.value.clone(),this.multiplicationType)}translate(e){return this.multiply(O.fromTranslate(e))}translateSelf(e){this.multiplySelf(O.fromTranslate(e))}rotate(e,t){return this.multiply(O.fromRotate(e,t))}rotateSelf(e,t){this.multiplySelf(O.fromRotate(e,t))}scale(e,t){return this.multiply(O.fromScale(e,t))}scaleSelf(e,t){this.multiplySelf(O.fromScale(e,t))}multiply(e){return this.multiplicationType==O.MultiplicationType.PRE?this.preMultiply(e):this.postMultiply(e)}preMultiply(e){let t=o.create();return o.multiply(t,e.toFloat32Array(),this.value),new O(t,this.multiplicationType)}postMultiply(e){let t=o.create();return o.multiply(t,this.value,e.toFloat32Array()),new O(t,this.multiplicationType)}multiplySelf(e){this.multiplicationType==O.MultiplicationType.PRE?this.preMultiplySelf(e):this.postMultiplySelf(e)}preMultiplySelf(e){o.multiply(this.value,e.toFloat32Array(),this.value)}postMultiplySelf(e){o.multiply(this.value,this.value,e.toFloat32Array())}invert(){let e=o.create();return o.invert(e,this.value),new O(e,this.multiplicationType)}invertSelf(){o.invert(this.value,this.value)}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this.toJSON()}}transformPoint(e){return P.fromPoint(e).transform(this)}toFloat32Array(){return this.value}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}toString(e){if(e){let e=e=>((e<0?"":" ")+e.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}static fromString(e,t){let r=o.create();if("none"!=e){let t=e.substring(0,e.indexOf("("));e=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),"matrix3d"==t?(r[0]=parseFloat(e[0]),r[1]=parseFloat(e[1]),r[2]=parseFloat(e[2]),r[3]=parseFloat(e[3]),r[4]=parseFloat(e[4]),r[5]=parseFloat(e[5]),r[6]=parseFloat(e[6]),r[7]=parseFloat(e[7]),r[8]=parseFloat(e[8]),r[9]=parseFloat(e[9]),r[10]=parseFloat(e[10]),r[11]=parseFloat(e[11]),r[12]=parseFloat(e[12]),r[13]=parseFloat(e[13]),r[14]=parseFloat(e[14]),r[15]=parseFloat(e[15])):(r[x]=parseFloat(e[0]),r[v]=parseFloat(e[1]),r[R]=parseFloat(e[2]),r[T]=parseFloat(e[3]),r[A]=parseFloat(e[4]),r[C]=parseFloat(e[5]))}return new O(r,t)}static fromMatrix(e,t){if(!e)throw new Error("data not found, Matrix instance creation failed");if("function"==typeof e)throw new Error("data type function is not allowed");if(e instanceof O)return e;if(Array.isArray(e)&&(e=new Float32Array(e)),e instanceof Float32Array)return new O(e,t);if("string"==typeof e)return O.fromString(e,t);let r=o.create(),i=Object.assign({},e);return isFinite(e.a)&&(i.m11=e.a),isFinite(e.b)&&(i.m12=e.b),isFinite(e.c)&&(i.m21=e.c),isFinite(e.d)&&(i.m22=e.d),isFinite(e.tx)?i.m41=e.tx:isFinite(e.e)?i.m41=e.e:isFinite(e.dx)&&(i.m41=e.dx),isFinite(e.ty)?i.m42=e.ty:isFinite(e.f)?i.m42=e.f:isFinite(e.dy)&&(i.m42=e.dy),isFinite(i.m11)&&(r[0]=i.m11),isFinite(i.m12)&&(r[1]=i.m12),isFinite(i.m13)&&(r[2]=i.m13),isFinite(i.m14)&&(r[3]=i.m14),isFinite(i.m21)&&(r[4]=i.m21),isFinite(i.m22)&&(r[5]=i.m22),isFinite(i.m23)&&(r[6]=i.m23),isFinite(i.m24)&&(r[7]=i.m24),isFinite(i.m31)&&(r[8]=i.m31),isFinite(i.m32)&&(r[9]=i.m32),isFinite(i.m33)&&(r[10]=i.m33),isFinite(i.m34)&&(r[11]=i.m34),isFinite(i.m41)&&(r[12]=i.m41),isFinite(i.m42)&&(r[13]=i.m42),isFinite(i.m43)&&(r[14]=i.m43),isFinite(i.m44)&&(r[15]=i.m44),new O(r,t||e.multiplicationType)}static fromTranslate(e){let t=isFinite(e)?{tx:e,ty:e}:{tx:e.x,ty:e.y};return O.fromMatrix(t)}static fromRotate(e,t){let r=Math.sin(e),i=Math.cos(e),s={a:i,b:r,c:-r,d:i};return t&&(s.tx=t.x-t.x*i+t.y*r,s.ty=t.y-t.x*r-t.y*i),O.fromMatrix(s)}static fromScale(e,t){isFinite(e)&&(e={x:e,y:e});let r={a:e.x,d:e.y};return t&&(r.tx=t.x-t.x*e.x,r.ty=t.y-t.y*e.y),O.fromMatrix(r)}static fromPoints(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("Expected input type Array requirement not satisfied");if(3!=e.length||3!=t.length)throw new Error("Expected input size 3 requirement not satisfied");let r=O.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),i=O.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),s=r.invert().preMultiply(i);return O.fromMatrix({a:s.m11,b:s.m12,c:s.m21,d:s.m22,tx:s.m31,ty:s.m32})}static multiply(e,t){let r=o.create();return o.multiply(r,e.value,t.value),new O(r)}}O.MultiplicationType=Object.freeze({PRE:"PRE",POST:"POST"});let D={longToByteArray(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let i=255&e;t[r]=i,e=(e-i)/256}return t},byteArrayToLong(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t},crc32:function(){let e=new Uint32Array(256);for(let t=256;t--;){let r=t;for(let e=8;e--;)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return function(t){let r=-1;for(let i=0,s=t.length;i<s;i++)r=r>>>8^e[255&r^t[i]];return(-1^r)>>>0}}(),encodeBitMask(e=[]){if(0==e.length)return 0;let t="",r=Math.max(...e);for(let i=1;i<=r;i++)t+=e.includes(i)?"1":"0";return parseInt(t.split("").reverse().join(""),2)},decodeBitMask(e){let t=[],r=e.toString(2).split("").reverse();for(let e=0;e<r.length;e++)1==r[e]&&t.push(e+1);return t},mapTo:(e,t,r)=>r.min+(D.clamp(e,t)-t.min)/(t.max-t.min)*(r.max-r.min),clamp:(e,t)=>Math.min(Math.max(e,t.min),t.max),debounce(e,t){let r=null;return function(){let i=this,s=arguments;clearTimeout(r),r=setTimeout((function(){e.apply(i,s)}),t)}},comparator(){let e=Array.prototype.slice.call(arguments),t=function(e,t,r){return t.replace("[",".").replace("]","").split(".").forEach((t=>e=e[t])),r?e.toLowerCase():e};return function(r,i){return e.map((e=>function(e,t,r){let i="asc"===r?1:-1;return e>t?1*i:e<t?-1*i:0}(t(r,e.sortBy,e.ignoreCase),t(i,e.sortBy,e.ignoreCase),e.sortOrder))).reduceRight((function(e,t){return t||e}))}},isValidURL(e){if("string"!=typeof e)return!1;try{return new URL(e),!0}catch(e){return!1}},getPropName(e,t){let r=e.split("_"),i=r.first.toLowerCase();t&&(i=i.substring(0,1).toUpperCase()+i.substring(1));for(let e=1;e<r.length;e++)i+=r[e].substring(0,1),i+=r[e].substring(1).toLowerCase();return i},getEnumValueName(e){let t="";for(let r=0;r<e.length;r++)r>0&&e[r]!=e[r].toLowerCase()&&(t+="_"),t+=e[r];return t.toUpperCase()}};class k{constructor(e){this.header=[],this.table=[],e.forEach((e=>{"string"==typeof e&&(e={name:e,title:e}),e.size=e.title.length,this.header.push(e)})),Object.defineProperty(this,"length",{get:()=>this.table.length,enumerable:!0})}insert(e){this.table.push(e),this.header.forEach((t=>{let r=e[t.name];null!=r&&(t.size=Math.max(t.size,r.toString().length))}))}build(){let e=[],t=this.header.length+1,r=[];return this.header.forEach((e=>{t+=e.size+2;let i=e.size-e.title.length,s=Math.floor(i/2),n=Math.ceil(i/2);r.push(this.getRepetedValue(s)+e.title+this.getRepetedValue(n))})),this.table.forEach((t=>{let r=[];this.header.forEach((e=>{let i=null==t[e.name]?"":t[e.name],s=e.size-i.toString().length;r.push(i+this.getRepetedValue(s))})),e.push(r)})),{delimiterLength:t,headerRow:r,content:e}}getFormattedRow(e){let t="| ";return e.forEach((e=>{t+=e,t+=" | "})),t.trim()}getRepetedValue(e,t=" "){return new Array(e+1).join(t)}clear(){this.table.clear()}toString(){let e="",{delimiterLength:t,headerRow:r,content:i}=this.build();return e+=this.getRepetedValue(t,"="),e+="\n",e+=this.getFormattedRow(r),e+="\n",e+=this.getRepetedValue(t,"="),e+="\n",i.forEach((t=>{e+=this.getFormattedRow(t),e+="\n"})),e}}if("object"==typeof window&&"undefined"==typeof TouchEvent){class e extends Event{}window.TouchEvent=e}let N={pointers:{mouse:["down","move","up"],touch:["start","move","end"]},inactive:[],open(e){if(!(e instanceof f))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("touchcancel",this.abort,{passive:!0}),this.attachResize(),this.start()},reset(e){for(let t in this.pointers){let r=t==N.PointerType.TOUCH?{passive:!0}:void 0,i=t+this.pointers[t][0];this.canvas.removeEventListener(i,this.begin),e.canvas.surface.addEventListener(i,this.begin,r)}this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("touchcancel",this.abort),delete this.canvas,delete this.inkController},start(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&this.inactive.remove(e),this.inactive.forEach((e=>delete t[e])),t){let r=e==N.PointerType.TOUCH?{passive:!0}:void 0;for(let i=0;i<t[e].length;i++){let s=e+t[e][i];0==i?this.canvas.addEventListener(s,this.begin,r):addEventListener(s,2==i?this.end:this.move,r)}}},stop(e){let t=e?{[e]:this.pointers[e]}:this.pointers;for(e in e&&!this.inactive.includes(e)&&this.inactive.push(e),this.inactive.forEach((e=>delete t[e])),e&&e!=N.PointerType.MOUSE||clearTimeout(this.timeoutID),t)for(let r=0;r<t[e].length;r++){let i=e+t[e][r];0==r?this.canvas.removeEventListener(i,this.begin):removeEventListener(i,2==r?this.end:this.move)}},isInputAllowed(e){let t=this.provider;if(e.type.endsWith("down")||e.type.endsWith("start")){if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==N.PointerType.MOUSE&&0!=e.button)return!1;for(let t in this.suppressKeys)if(e[t])return!1}return t==this.getInputProvider(e)},isInputExpected(e){let t=!1,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=e.type.endsWith("down")||e.type.endsWith("start")?!i.phase:i.phase&&i.phase!=E.Phase.END),t},getSensorPoint(e){let t,r=e.changedTouches?Array.from(e.changedTouches).map((e=>e.identifier)):[],i=this.inkController.getInkBuilder(r);return i&&(t=this.createSensorPoint(e,i.pointerID)),t},createSensorPoint(e,t){let r=this.getOffset(e),i={x:r.x,y:r.y,z:void 0,timestamp:Math.floor(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,rotation:void 0},s={id:void 0,type:void 0,button:void 0,buttons:void 0};if(Object.defineProperty(i,"phase",{value:E.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),Object.defineProperty(i,"pointer",{value:s,enumerable:!0}),Object.defineProperty(i.pointer,"provider",{get:function(){return b.Type[this.type.toUpperCase()]},enumerable:!0}),e instanceof MouseEvent)s.type=N.PointerType.MOUSE,s.button=e.button,s.buttons=e.buttons;else{if(!(e instanceof TouchEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of MouseEvent or TouchEvent.`);if(isNaN(t))throw new Error("pointerID is required for touch event");if(!(e=Array.from(e.changedTouches).filter((e=>e.identifier==t)).first))return null;isNaN(i.x)&&(i.x=e.offsetX||e.clientX),isNaN(i.y)&&(i.y=e.offsetY||e.clientY),s.id=e.identifier,s.type=N.PointerType.TOUCH,i.pressure=e.force,i.radiusX=e.radiusX,i.radiusY=e.radiusY,i.rotation=Math.toRadians(e.rotationAngle)}return i},getOffset(e){if(e.changedTouches){let t=Array.from(e.changedTouches).map((e=>e.identifier)),r=this.inkController.getInkBuilder(t);e=r.pointerID!=e.changedTouches.item(0).identifier?Array.from(e.changedTouches).filter((e=>e.identifier==r.pointerID)).first:e.changedTouches.item(0)}let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:O.fromMatrix(i);let s=P.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=S.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=P.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.type.replace(/down|start|move|up|end/g,""),begin(e){if(this.logSampleInput(e),e instanceof MouseEvent&&0!=e.button)return;if(!this.isInputAllowed(e))return;if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.registerInputProvider(t)}if(!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.move(t,void 0,e)},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&(this.inkController.end(t,e),e instanceof MouseEvent||this.inactive.includes(N.PointerType.MOUSE)||(this.stop(N.PointerType.MOUSE),this.timeoutID=setTimeout((()=>this.start(N.PointerType.MOUSE)),500))),e.touches&&0!=e.touches.length||delete this.provider},abort(e){if(delete this.provider,this.inkController.abort)if(e instanceof TouchEvent){let t=Array.from(e.changedTouches).map((e=>e.identifier));this.inkController.abort(t)}else this.inkController.abort()},logSampleInput(e){if(!this.debug)return;const t=e.type.endsWith("move"),r="mouseup"==e.type||"touchend"==e.type;t&&!this.debug.move||r&&!this.debug.end||(r&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new k(["type","id","pointerType","x","y","pressure","radius","rotation","timestamp"])),this.table.insert({type:e.type,id:e.changedTouches?e.changedTouches[0].identifier:void 0,pointerType:this.getInputProvider(e),x:e.changedTouches?e.changedTouches[0].clientX.toFixed(2):e.clientX,y:e.changedTouches?e.changedTouches[0].clientY.toFixed(2):e.clientY,pressure:e.changedTouches?e.changedTouches[0].force.toFixed(2):void 0,radius:e.changedTouches?e.changedTouches[0].radiusX.toFixed(2)+" / "+e.changedTouches[0].radiusY.toFixed(2):void 0,rotation:e.changedTouches?e.changedTouches[0].rotationAngle:e.twist,timestamp:e.timeStamp.toFixed(8)}),t||(console.log(this.table.toString()),this.table.clear()))},PointerType:{MOUSE:"mouse",TOUCH:"touch"}},M={inactive:[],suppressKeys:{ctrlKey:!0,altKey:!0,shiftKey:!0,metaKey:!0},open(e){if(!(e instanceof f))throw new Error("Argument doesn't implement InkController interface");this.inkController=e,this.canvas=e.canvas.surface,this.mounted||(this.mounted=!0,this.begin=this.begin.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.abort=this.abort.bind(this)),addEventListener("pointercancel",this.abort),this.attachResize(),this.start()},reset(e){this.canvas.removeEventListener("pointerdown",this.begin),e.canvas.surface.addEventListener("pointerdown",this.begin),this.dettachResize(),this.inkController=e,this.canvas=e.canvas.surface,this.attachResize()},close(){this.stop(),this.dettachResize(),removeEventListener("pointercancel",this.abort),delete this.canvas,delete this.inkController},start(e){e?this.inactive.remove(e):(this.canvas.addEventListener("pointerdown",this.begin),addEventListener("pointermove",this.move),addEventListener("pointerup",this.end))},stop(e){e?this.inactive.includes(e)||this.inactive.push(e):(this.canvas.removeEventListener("pointerdown",this.begin),removeEventListener("pointermove",this.move),removeEventListener("pointerup",this.end))},attachResize(){if(this.inkController.resize==f.prototype.resize)return;let e=M.ResizeReason.WINDOW,t=devicePixelRatio,r=screen.width;let i;matchMedia("screen and (orientation: portrait)").addListener((t=>{e=M.ResizeReason.ORIENTATION,r=screen.width})),function r(){i&&(i.removeListener(r),e=t<devicePixelRatio?M.ResizeReason.ZOOM_IN:M.ResizeReason.ZOOM_OUT,t=devicePixelRatio),i=matchMedia(`(resolution: ${devicePixelRatio}dppx)`),i.addListener(r)}(),this.resize=D.debounce((()=>{e==M.ResizeReason.WINDOW&&r!=screen.width&&(e=r<screen.width?M.ResizeReason.SCREEN_SIZE_INCREASED:M.ResizeReason.SCREEN_SIZE_DECREASED,r=screen.width),this.inkController.resize(e),e=M.ResizeReason.WINDOW}),200),addEventListener("resize",this.resize)},dettachResize(){this.inkController.resize!=f.prototype.resize&&removeEventListener("resize",this.resize)},isInputAllowed(e){if("pointerdown"!=e.type)return!0;let t=this.provider;if(t||(t=this.getInputProvider(e)),this.inactive.includes(t))return!1;if(t==M.PointerType.MOUSE){if(0!=e.button)return!1}else if(t==M.PointerType.PEN&&0==e.pressure)return!1;for(let t in this.suppressKeys)if(e[t])return!1;return!0},isInputExpected(e){let t=!1,r=this.inkController.getInkBuilder(e.pointerId);return r&&(t="pointerdown"==e.type?!r.phase:r.phase&&r.phase!=E.Phase.END),t},getSensorPoint(e){let t,r=this.inkController.getInkBuilder(e.pointerId);if(r){if(e.pointerId!=r.pointerID)throw new Error(`Create sensor point failed, expected pointer with id: ${r.pointerID}, found: ${e.pointerId}`);if("pointerdown"==e.type){let t=this.getInputProvider(e);e.pointerType!=t?r.pointerType=t:delete r.pointerType}t=this.createSensorPoint(e,r.pointerType)}return t},createSensorPoint(e,t,r){if(!(e instanceof PointerEvent))throw new Error(`Unexpected event detected: ${e.constructor.name}. Expected event should be instance of PointerEvent.`);let i,s=this.getOffset(e),n={x:s.x,y:s.y,z:void 0,timestamp:Math.round(e.timeStamp),pressure:void 0,radiusX:void 0,radiusY:void 0,tiltX:void 0,tiltY:void 0,rotation:void 0};if(r?(Object.defineProperty(n,"phase",{value:r.phase,enumerable:!0}),i=r.pointer):(Object.defineProperty(n,"phase",{value:E.Phase[e.type.replace(/pointer|mouse|touch/g,"").replace(/down|start/,"BEGIN").replace(/move/,"UPDATE").replace(/up|end/,"END")],enumerable:!0}),i={id:e.pointerId,type:t||e.pointerType,button:void 0,buttons:void 0},Object.defineProperty(i,"provider",{get:function(){return b.Type[this.type.toUpperCase()]},enumerable:!0}),"pen"!=i.type&&"mouse"!=i.type||(i.button=e.button,i.buttons=e.buttons)),Object.defineProperty(n,"pointer",{value:i,enumerable:!0}),"pen"!=i.type&&"touch"!=i.type||(n.pressure=e.pressure,n.rotation=Math.toRadians(e.twist)),"pen"==i.type?(n.tiltX=e.tiltX,n.tiltY=e.tiltY):"touch"==i.type&&(n.radiusX=e.width/2,n.radiusY=e.height/2),!r){if(e.getPredictedEvents){let r=e.getPredictedEvents();if(r.length>0){let e;Object.defineProperty(n,"predicted",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}if("pen"==i.type&&e.getCoalescedEvents){let r=e.getCoalescedEvents();if(r.length>1){let e;Object.defineProperty(n,"coalesced",{get:()=>(e||(e=r.map((e=>this.createSensorPoint(e,t,n)))),e),enumerable:!0})}}}return n},getOffset(e){let t=this.canvas.offsetParent;if(!t)return{x:0,y:0};"flex"==t.getStyle("display")&&(t=this.canvas);let r=this.inkController.transform,i=this.canvas.getStyle("transform");"none"==i?i=t.getStyle("transform"):t=this.canvas,i="none"==i?null:O.fromMatrix(i);let s=P.fromPoint({x:e.clientX,y:e.clientY}),n=t.getBoundingClientRect();if(i){let e=i.invert();s=s.transform(e),n=S.fromRect(n).transform(e)}let o={x:s.x-n.x,y:s.y-n.y};return r&&(o=P.fromPoint(o).transform(r.invert())),o},getInputProvider:e=>e.pointerType==M.PointerType.MOUSE&&e.pressure>0&&.5!==e.pressure?M.PointerType.PEN:e.pointerType,begin(e){if(this.logSampleInput(e),!this.isInputAllowed(e))return;if(this.inkController.registerInputProvider(e.pointerId,e.isPrimary),!this.isInputExpected(e))return;this.provider||(this.provider=this.getInputProvider(e));let t=this.getSensorPoint(e);t&&this.inkController.begin(t,e)},move(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);if(t){let r;if(this.inkController.getInkBuilder(e.pointerId).prediction&&e.getPredictedEvents){let i=e.getPredictedEvents();i.length>0&&(r=this.createSensorPoint(i.last,t.pointer.type,t))}this.inkController.move(t,r,e)}},end(e){if(!this.isInputAllowed(e)||!this.isInputExpected(e))return;this.logSampleInput(e);let t=this.getSensorPoint(e);t&&this.inkController.end(t,e),delete this.provider},abort(e){delete this.provider,this.inkController.abort(e.pointerId)},logSampleInput(e){this.debug&&(this.debug.move||this.debug.end)&&("pointermove"!=e.type||this.debug.move)&&("pointerup"!=e.type||this.debug.end)&&(e.pointerType!=this.getInputProvider(e)&&(e.pen=!0),"pointerup"==e.type&&this.table.length>0&&(console.log(this.table.toString()),this.table.clear()),this.table||(this.table=new k(["type","id","pointerType","x","y","pressure","radius","tilt","rotation","buttons","timestamp"])),this.table.insert({type:e.type,id:e.pointerId,pointerType:e.pen?`${e.pointerType} / pen`:e.pointerType,x:e.clientX.toFixed(2),y:e.clientY.toFixed(2),pressure:e.pressure.toFixed(8),radius:(e.width/2).toFixed(2)+" / "+(e.height/2).toFixed(2),rotation:e.twist,tilt:isFinite(e.tiltX)?e.tiltX+" / "+e.tiltY:"",buttons:e.buttons,timestamp:e.timeStamp.toFixed(8)}),"pointermove"!=e.type&&(console.log(this.table.toString()),this.table.clear()))},PointerType:{PEN:"pen",MOUSE:"mouse",TOUCH:"touch"}};Object.defineEnum(M,"ResizeReason",["WINDOW","ZOOM_IN","ZOOM_OUT","SCREEN_SIZE_INCREASED","SCREEN_SIZE_DECREASED","ORIENTATION"]),"object"==typeof window&&"undefined"==typeof PointerEvent&&(N.suppressKeys=M.suppressKeys,N.ResizeReason=M.ResizeReason,N.attachResize=M.attachResize,N.dettachResize=M.dettachResize,M=N);var L=M;class _ extends P{static defaults={size:1,rotation:0,scaleX:1,scaleY:1,scaleZ:1,offsetX:0,offsetY:0,offsetZ:0};constructor(e,t,r,i={}){super(e,t,r),this.red=i.red,this.green=i.green,this.blue=i.blue,this.alpha=i.alpha,this.size=i.size||_.defaults.size,this.rotation=i.rotation||_.defaults.rotation,this.scaleX=i.scaleX||_.defaults.scaleX,this.scaleY=i.scaleY||_.defaults.scaleY,this.scaleZ=isFinite(r)?i.scaleZ||_.defaults.scaleZ:void 0,this.offsetX=i.offsetX||_.defaults.offsetX,this.offsetY=i.offsetY||_.defaults.offsetY,this.offsetZ=isFinite(r)?i.offsetZ||_.defaults.offsetZ:void 0,this.dX,this.dY}static createInstance(e,t,r,i=0){let s=new _(0,0,e.includes(_.Property.Z)?0:void 0);return r&&s.fill(i,r,e,t),s}fill(e,t,r,i={}){let s={},n=e*r.length;r.forEach(((e,r)=>_.setProperty(s,e,t[n+r]))),this.x=s.x,this.y=s.y,this.z=s.z,this.red=isFinite(s.red)?s.red:i.red,this.green=isFinite(s.green)?s.green:i.green,this.blue=isFinite(s.blue)?s.blue:i.blue,this.alpha=isFinite(s.alpha)?s.alpha:i.alpha,this.size=s.size||i.size||_.defaults.size,this.rotation=s.rotation||i.rotation||_.defaults.rotation,this.scaleX=s.scaleX||i.scaleX||_.defaults.scaleX,this.scaleY=s.scaleY||i.scaleY||_.defaults.scaleY,this.scaleZ=isFinite(s.z)?s.scaleZ||i.scaleZ||_.defaults.scaleZ:void 0,this.offsetX=s.offsetX||i.offsetX||_.defaults.offsetX,this.offsetY=s.offsetY||i.offsetY||_.defaults.offsetY,this.offsetZ=isFinite(s.z)?s.offsetZ||i.offsetZ||_.defaults.offsetZ:void 0,this.dX=s.dX,this.dY=s.dY}getProperty(e){switch(e){case _.Property.X:return this.x;case _.Property.Y:return this.y;case _.Property.Z:return this.z;case _.Property.RED:return this.red;case _.Property.GREEN:return this.green;case _.Property.BLUE:return this.blue;case _.Property.ALPHA:return this.alpha;case _.Property.SIZE:return this.size;case _.Property.ROTATION:return this.rotation;case _.Property.SCALE_X:return this.scaleX;case _.Property.SCALE_Y:return this.scaleY;case _.Property.SCALE_Z:return this.scaleZ;case _.Property.OFFSET_X:return this.offsetX;case _.Property.OFFSET_Y:return this.offsetY;case _.Property.OFFSET_Z:return this.offsetZ;case _.Property.D_X:return this.dX;case _.Property.D_Y:return this.dY;default:throw console.warn(e),new Error("Invalid property found")}}setProperty(e,t){_.setProperty(this,e,t)}static setProperty(e,t,r){switch(t){case _.Property.X:e.x=r;break;case _.Property.Y:e.y=r;break;case _.Property.Z:e.z=r;break;case _.Property.RED:e.red=r;break;case _.Property.GREEN:e.green=r;break;case _.Property.BLUE:e.blue=r;break;case _.Property.ALPHA:e.alpha=r;break;case _.Property.SIZE:e.size=r;break;case _.Property.ROTATION:e.rotation=r;break;case _.Property.SCALE_X:e.scaleX=r;break;case _.Property.SCALE_Y:e.scaleY=r;break;case _.Property.SCALE_Z:e.scaleZ=r;break;case _.Property.OFFSET_X:e.offsetX=r;break;case _.Property.OFFSET_Y:e.offsetY=r;break;case _.Property.OFFSET_Z:e.offsetZ=r;break;case _.Property.D_X:e.dX=r;break;case _.Property.D_Y:e.dY=r;break;default:throw console.warn(t),new Error("Invalid property found")}}transform(e){if(!(e instanceof O))throw new Error(`matrix is instance of ${e.constructor.name} - it should be instance of Matrix. Use Matrix.fromMatrix method to convert.`);let t=e.scaleX,r=e.rotation;this.transformSelf(e),this.size*=t,this.rotation+=r}toArray(e){return e.map((e=>{let t=this.getProperty(e);if(null==t||isNaN(t))throw new Error(`Property ${e.name} has invalid value ${t}`);return t}))}toJSON(){let e={};return _.Property.values.forEach((t=>{let r=this.getProperty(t);null!=r&&isFinite(r)&&(e[t.name]=this.getProperty(t))})),e}}Object.defineEnum(_,"Property",["X","Y","Z","RED","GREEN","BLUE","ALPHA","SIZE","ROTATION","SCALE_X","SCALE_Y","SCALE_Z","OFFSET_X","OFFSET_Y","OFFSET_Z","D_X","D_Y"]),Object.defineProperty(globalThis,"DIGITAL_INK_ENV",{value:"AUTO",enumerable:!0,configurable:!0});let F,B={version:"1.5.0"};Object.defineEnum(B,"Type",["WEB","WORKER","NODE","SHELL"]),Object.defineEnum(B,"Type2D",["SCREEN","OFFSCREEN"]),Object.defineEnum(B,"TypeGL",["WEB","STACK"]),function(e){let t,r="BROWSER"!=DIGITAL_INK_ENV&&"object"==typeof process&&"function"==typeof require;t="object"==typeof window?"WEB":"function"==typeof importScripts?"WORKER":r?"NODE":"SHELL";let i="undefined"==typeof Screen?"OFFSCREEN":"SCREEN",s="undefined"==typeof WebGLRenderingContext?"STACK":"WEB";Object.defineProperty(B,"commonJS",{value:r,enumerable:!0}),Object.defineProperty(B,"type",{value:B.Type[t],enumerable:!0}),Object.defineProperty(B,"type2D",{value:B.Type2D[i],enumerable:!0}),Object.defineProperty(B,"typeGL",{value:B.TypeGL[s],enumerable:!0})}(),B.commonJS&&(F=require("systeminformation"));var U=F;class j extends y{constructor(){super(),this.props={}}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. Environment do not belongs to any InputContext yet");return["Environment",y.buildMD5Tokens(this.props)]}static async createInstance(e={}){let t=new j;if(t.props["wacom.ink.sdk.lang"]="js",t.props["wacom.ink.sdk.version"]=B.version,t.props["runtime.type"]=B.type.name,void 0===U)t.props["user.agent"]=navigator.userAgent;else{let e=await U.osInfo();t.props["os.id"]=e.serial.toLowerCase(),t.props["os.name"]=e.codename,t.props["os.version"]=e.release,t.props["os.build"]=e.build,t.props["os.platform"]=`${e.distro} (${e.platform} ${e.arch})`}return Object.keys(e).forEach((r=>t.props[r]=e[r])),t}}const G={DP:160,PICA:6,POINT:72,DIP:96,DPI:96*("undefined"==typeof window?1:window.devicePixelRatio)};class ${static Units={METER:{METER:1,CENTIMETER:100,MILLIMETER:1e3,MICROMETER:1e6,INCH:39.3700787402},CENTIMETER:{METER:.01,CENTIMETER:1,MILLIMETER:10,MICROMETER:1e4,INCH:.3937007874},MILLIMETER:{METER:.001,CENTIMETER:.1,MILLIMETER:1,MICROMETER:1e3,INCH:.0393700787},MICROMETER:{METER:1e-6,CENTIMETER:1e-4,MILLIMETER:.001,MICROMETER:1,INCH:393701e-10},INCH:{METER:.0254,CENTIMETER:2.54,MILLIMETER:25.4,MICROMETER:25400,INCH:1},SECOND:{SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},MILLISECOND:{SECOND:.001,MILLISECOND:1,MICROSECOND:1e3,NANOSECOND:1e6},MICROSECOND:{SECOND:1e-6,MILLISECOND:.001,MICROSECOND:1,NANOSECOND:1e3},NANOSECOND:{SECOND:1e-9,MILLISECOND:1e-6,MICROSECOND:.001,NANOSECOND:1},RADIAN:{RADIAN:1,DEGREE:57.2957795},DEGREE:{RADIAN:.0174532925,DEGREE:1},NEWTON:{NEWTON:1}};static getChannelResolution(e,t=1){let r=1,i=$.getUnitMetric(e);return i!=$.Metric.NORMALIZED&&i!=$.Metric.LOGICAL&&(r=$[Y[i.name].name][e.name]/t),r}static convert(e,t,r,i){return t?r*$[Y[e.name].name][i.name]/t:r}static convertAny(e,t,r,i){return e*$[t.name][r.name]/i}static getUnitMetric(e){switch(e){case $.Unit.METER:case $.Unit.CENTIMETER:case $.Unit.MILLIMETER:case $.Unit.MICROMETER:case $.Unit.INCH:case $.Unit.DP:case $.Unit.PICA:case $.Unit.POINT:case $.Unit.DIP:case $.Unit.DPI:return $.Metric.LENGTH;case $.Unit.SECOND:case $.Unit.MILLISECOND:case $.Unit.MICROSECOND:case $.Unit.NANOSECOND:return $.Metric.TIME;case $.Unit.RADIAN:case $.Unit.DEGREE:return $.Metric.ANGLE;case $.Unit.NEWTON:return $.Metric.FORCE;case $.Unit.NORMALIZED:return $.Metric.NORMALIZED;case $.Unit.LOGICAL:return $.Metric.LOGICAL;default:throw console.warn(e),new Error("Invalid unit found")}}static getMetricUnits(e){switch(e){case $.Metric.LENGTH:return[$.Unit.METER,$.Unit.CENTIMETER,$.Unit.MILLIMETER,$.Unit.MICROMETER,$.Unit.INCH,$.Unit.DP,$.Unit.PICA,$.Unit.POINT,$.Unit.DIP,$.Unit.DPI];case $.Metric.TIME:return[$.Unit.SECOND,$.Unit.MILLISECOND,$.Unit.MICROSECOND,$.Unit.NANOSECOND];case $.Metric.ANGLE:return[$.Unit.RADIAN,$.Unit.DEGREE];case $.Metric.FORCE:return[$.Unit.NEWTON];case $.Metric.NORMALIZED:return[$.Unit.NORMALIZED];case $.Metric.LOGICAL:return[$.Unit.LOGICAL];case $.Metric.DIMENSIONLESS:return[];default:throw console.warn(e),new Error("Invalid metric found")}}static getUnit(e){return Y[e.name]}static convertValue(e,t,r){return e*$[t.name][r.name]}}Object.defineEnum($,"Unit",["METER","CENTIMETER","MILLIMETER","MICROMETER","INCH","DP","PICA","POINT","DIP","DPI","SECOND","MILLISECOND","MICROSECOND","NANOSECOND","RADIAN","DEGREE","NEWTON","NORMALIZED","LOGICAL"]),Object.defineEnum($,"Metric",["LENGTH","TIME","FORCE","ANGLE","NORMALIZED","LOGICAL","DIMENSIONLESS"]);const Y=Object.freeze({LENGTH:$.Unit.METER,TIME:$.Unit.SECOND,FORCE:$.Unit.NEWTON,ANGLE:$.Unit.RADIAN,NORMALIZED:$.Unit.NORMALIZED,LOGICAL:$.Unit.LOGICAL});!function(){let e=$.getMetricUnits($.Metric.LENGTH).filter((e=>!(e.name in G)));for(let t of e){let e=$.Units[t.name];for(let t in G)e[t]=e.INCH*G[t]}for(let t in G){let r={};for(let i of e)r[i.name]=$.Units.INCH[i.name]/G[t];for(let e in G)r[e]=G[e]/G[t];$.Units[t]=r}for(let e in $.Units)$[e]=$.Units[e]}(),Object.freeze($);class X extends y{constructor(e,t,r,i,s){if(super(),t==X.Metric.DIMENSIONLESS)r=1;else if(isNaN(r)||!t){let n=X.getDefaultUnitDescriptorPerType(e);if(!t){if(!n)throw new Error("metric is required");t=n.metric}if(!r){if(!n)throw new Error("resolution is required");r=$.getChannelResolution(n.unit)}isNaN(i)&&(i=n.min),isNaN(s)&&(s=n.max)}this.type=e,this.metric=t,this.resolution=r,this.min=i,this.max=s,e==X.Type.TIMESTAMP?this.precision=0:this.precision=2,Object.defineProperty(this,"name",{get:function(){return D.getEnumValueName(this.type.substring(this.type.lastIndexOf("/")+1))}})}getMD5Message(){if(!this.context)throw new Error("ID generation failed. This channel do not belongs to SensorChannelsContext yet");if(!Object.isFrozen(this.context)&&!Object.isFrozen(this))throw new Error("ID generation failed. Underlying SensorChannelsContext do not belongs to any SensorContext yet");let e=[];return e.push("SensorChannel"),e.push(this.context.inkProvider?this.context.inkProvider.id:""),e.push(this.context.device.id),e.push(this.type),e.push(this.metric.name),e.push(this.resolution.toFixed(4)),e.push((this.min||0).toFixed(4)),e.push((this.max||0).toFixed(4)),e.push(this.precision.toString()),e}static getTypeName(e){return Object.keys(X.Type).find((t=>X.Type[t]==e))}static getDefaultUnitDescriptorPerType(e){let t={};switch(e){case X.Type.X:case X.Type.Y:case X.Type.Z:case X.Type.RADIUS_X:case X.Type.RADIUS_Y:t.unit=$.Unit.DIP;break;case X.Type.TIMESTAMP:t.unit=$.Unit.MILLISECOND;break;case X.Type.PRESSURE:t.unit=$.Unit.NORMALIZED,t.min=0,t.max=1;break;case X.Type.ALTITUDE:t.unit=$.Unit.RADIAN,t.min=0,t.max=Math.PI/2;break;case X.Type.AZIMUTH:t.unit=$.Unit.RADIAN,t.min=-Math.PI,t.max=Math.PI;break;case X.Type.ROTATION:t.unit=$.Unit.RADIAN,t.min=0,t.max=2*Math.PI;break;default:t=null}return t.metric=$.getUnitMetric(t.unit),t}static createCustomChannel(e,t,r,i,s,n){let o=new X(e,r,i,s,n);return o.precision=t,o}static createDefaultInstance(e,t){let r=X.getDefaultUnitDescriptorPerType(e);r||console.error(`SensorChannel: createDefaultInstance failed with ${e} type`);let i=$.getChannelResolution(r.unit),s=new X(e,r.metric,i,r.min,r.max);return s.unit=r.unit,e!=X.Type.X&&e!=X.Type.Y||t.type!=b.Type.MOUSE||(s.precision=0),s}}X.defaults=Object.freeze({PEN:["X","Y","TIMESTAMP","PRESSURE","ALTITUDE","AZIMUTH","ROTATION"],TOUCH:["X","Y","TIMESTAMP","PRESSURE","RADIUS_X","RADIUS_Y","ROTATION"],MOUSE:["X","Y","TIMESTAMP"]}),X.Type={X:"will://input/3.0/channel/X",Y:"will://input/3.0/channel/Y",Z:"will://input/3.0/channel/Z",TIMESTAMP:"will://input/3.0/channel/Timestamp",PRESSURE:"will://input/3.0/channel/Pressure",RADIUS_X:"will://input/3.0/channel/RadiusX",RADIUS_Y:"will://input/3.0/channel/RadiusY",ALTITUDE:"will://input/3.0/channel/Altitude",AZIMUTH:"will://input/3.0/channel/Azimuth",ROTATION:"will://input/3.0/channel/Rotation"},X.Metric=$.Metric;class z extends y{constructor(e,t){super(),this.device=e.freeze(),this.inkProvider=Object.freeze(t);let r,i,s=[];Object.defineProperty(this,"channels",{get:function(){return s},set:function(e){this.invalidateID(),s=[],e.forEach((e=>this.add(e)))},enumerable:!0}),Object.defineProperty(this,"layout",{get:function(){return s.map((e=>e.name))},set:function(e){this.invalidateID(),s=s.filter((t=>e.includes(t.name)))},enumerable:!0}),Object.defineProperty(this,"samplingRate",{get:function(){return r},set:function(e){this.invalidateID(),r=e},enumerable:!0}),Object.defineProperty(this,"latency",{get:function(){return i},set:function(e){this.invalidateID(),i=e},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorChannelsContext do not belongs to any SensorContext yet");let e=["SensorChannelsContext",...this.channels.map((e=>e.id))];return e.push(this.samplingRate||""),e.push(this.latency||""),e.push(this.inkProvider?this.inkProvider.id:""),e.push(this.device.id),e}add(e){if((e.type==X.Type.X||e.type==X.Type.Y)&&!this.inkProvider)throw new Error("inkProvider is not found. Required for ink group.");e.context=this,Object.freeze(e),this.channels.push(e)}get(e){return this.channels.filter((t=>t.id==e)).first}static createDefaultInstance(e,t){let r=new z(e,t);return r.channels=X.defaults[t.type.name].map((e=>X.createDefaultInstance(X.Type[e],t))),r}}class V extends y{constructor(){super();let e=[];Object.defineProperty(this,"channelsContexts",{get:function(){return e},set:function(t){this.invalidateID(),e=t},enumerable:!0})}getMD5Message(){if(!Object.isFrozen(this))throw new Error("ID generation failed. SensorContext do not belongs to any InputContext yet");return["SensorContext",...this.channelsContexts.map((e=>e.id))]}addContext(e){if(!this.channelsContexts.includes(e)){if(this.channelsContexts.some((t=>t.device==e.device)))throw new Error(`Already exists channelsContext with device ${e.device.id}. Device should be unique in the scope of SensorContext.`);e.inkProvider&&(this.inkChannelsContext=e),Object.freeze(e),this.channelsContexts.push(e)}}getContext(e){return this.channelsContexts.find((t=>t.id==e))}getContextByChannelID(e){return this.channelsContexts.find((t=>t.get(e)))}static createDefaultInstance(e,t){let r=new V;return r.addContext(z.createDefaultInstance(e,t)),r}}class H extends y{constructor(e,t){super(),this.environment=Object.freeze(e),this.sensorContext=Object.freeze(t)}getMD5Message(){return["InputContext",this.environment.id,this.sensorContext.id]}addChannelsContext(e){this.sensorContext.addContext(e)}static createDefaultInstance(e,t,r){let i=V.createDefaultInstance(t,r);return new H(e,i)}}class Z{static createTreeURI(e,t){return`uim:tree/${t?`${t}/`:""}${e}`}static createStrokeURI(e,t){return`uim:stroke/${t?`${t}/`:""}${e}`}static createSensorDataURI(e,t){return`uim:sensor/${t?`${t}/`:""}${e}`}static createNodeURI(e,t,r){if(!e)throw new Error("inkTree is required");let i="";return r&&(i=`#frag=${r.pointIndexStart},${r.pointIndexEnd}`,0==r.ts&&1==r.tf||(i+=`,${r.ts.toFixed(5)},${r.tf.toFixed(5)}`)),`${Z.createNodeURISchema(e)}/${t}${i}`}static createNodeURISchema(e,t=e.name){return`uim:node${e.id?`/${e.id}`:""}/${t}`}static createNamedEntityURI(e,t){return`uim:ne/${t?`${t}/`:""}${e}`}}class W extends y{#t;constructor(e,t){super(t),Object.defineProperty(this,"uri",{get:()=>(this.#t||(this.#t=Z.createSensorDataURI(this.id)),this.#t),enumerable:!0}),this.created=Date.now(),this.inkState=W.InkState.PLANE,this.context=e,this.streams=[]}add(e){if(!this.context.sensorContext.getContextByChannelID(e.channels.first.id))throw new Error("SensorContext do not contains information about SensorChannelsContext corresponding with this stream");e.ink&&(this.inkStream=e),this.streams.push(e)}}Object.defineEnum(W,"InkState",["PLANE","HOVERING","IN_VOLUME","VOLUME_HOVERING"]);class q{constructor(e){this.channels=e,this.data=[],this.ignoredIndex=[],Object.defineProperty(this,"layout",{value:e.map((e=>e.name)),enumerable:!0}),Object.defineProperty(this,"stride",{value:this.layout.length,enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return this.data.length/this.stride},enumerable:!0}),this.ink=this.layout.includes("X")&&this.layout.includes("Y")}add(e,t){t&&this.ignoredIndex.push(this.length),this.channels.forEach((t=>{let r=D.getPropName(t.name),i=e[r];if(t.type==X.Type.ALTITUDE&&!("altitude"in e))throw new Error("SensorStream input data do not provides altitude");if(t.type==X.Type.AZIMUTH&&!("azimuth"in e))throw new Error("SensorStream input data do not provides azimuth");this.data.push(i)}))}get(e){if(e>=this.length||e<0)throw new Error(`Index ${e} out of range - (0, ${this.length-1})`);let t={};for(let r=0;r<this.stride;r++){let i=this.channels[r],s=D.getPropName(i.name),n=e*this.stride;t[s]=this.data[n+r]}return t}getChannelData(e){let t=e==X.Type.TIMESTAMP?new Uint32Array(this.length):new Float32Array(this.length),r=this.channels.findIndex((t=>t.type==e));this.channels[r].name;for(let e=0;e<this.length;e++)t[e]=this.data[e*this.stride+r];return t}getPipelineMapping(){let e=[];if(this.ignoredIndex.length>0)for(let t=0;t<this.length;t++)this.ignoredIndex.includes(t)||e.push(t);return e}}class K extends y{constructor(){super(),this.props={},this.devices=[]}freeze(){return Object.freeze(this.props),this}getMD5Message(){if(!Object.isFrozen(this.props)&&!Object.isFrozen(this))throw new Error("ID generation failed. InputDevice do not belongs to any SensorChannelsContext yet");return["InputDevice",y.buildMD5Tokens(this.props)]}link(e){if(!(e instanceof K))throw new Error("Implementation of InputDevice is required");this.devices.push(e)}getInkInputProvider(e){return new b(e)}getInkSensorContext(e){let t=this.getInkInputProvider(e);return V.createDefaultInstance(this,t)}openStream(e){if(!this.environment)throw new Error("Environment is not configured for current InputDevice instance");let t=b.Type[e.pointer.type.toUpperCase()],r=this.getInkSensorContext(t),i=new H(this.environment,r);r.inkChannelsContext.layout=K.getLayout(e),this.sensorData=new W(i),this.sensorData.add(new q(r.inkChannelsContext.channels)),this.sampleTimestamp=e.timestamp,this.devices.forEach((e=>e.openStream(this.sensorData)))}add(e,t){if(!this.sensorData)throw new Error("Open ink stream not found");e.timestamp-=this.sampleTimestamp,this.sensorData.inkStream.add(e,t)}closeStream(e){let t=this.sensorData;return this.devices.forEach((t=>t.closeStream(e))),this.sensorData=null,this.sampleTimestamp=0,e?null:t}static getLayout(e){let t=[];return Object.keys(X.Type).forEach((r=>{let i,s=X.Type[r];i=s==X.Type.ALTITUDE?"tiltX":s==X.Type.AZIMUTH?"tiltY":D.getPropName(r),K.isValidInput(i,e)&&t.push(r)})),t}static isValidInput(e,t){let r=!1;return isFinite(t[e])&&(r=!0,"pressure"==e?(r=t.pressure>0,r&&t.pointer&&("mouse"==t.pointer.type?r=!1:"touch"==t.pointer.type&&(r=.5!==t.pressure&&1!==t.pressure))):"tiltX"==e||"tiltY"==e?r=0!=t.tiltX||0!=t.tiltY:"radiusX"==e||"radiusY"==e?r=t.radiusX!=t.radiusY||parseInt(t.radiusX)!=t.radiusX:"rotation"==e&&(r=0!=t.rotation)),r}static async createInstance(e){let t=new this(...Array.from(arguments).slice(1));if(void 0===U)t.props["dev.graphics.resolution"]=`${screen.width}x${screen.height}`;else{let e=await U.system(),r=await U.cpu(),i=await U.graphics(),s=i.displays.filter((e=>e.main))[0],n=i.controllers[0];t.props["dev.id"]=e.uuid.toLowerCase(),t.props["dev.manufacturer"]=e.manufacturer,t.props["dev.model"]=e.model,t.props["dev.cpu"]=`${r.manufacturer} ${r.brand} ${r.speed} - ${r.cores} core(s)`,t.props["dev.graphics.display"]=`${s.model} ${s.currentResX}x${s.currentResY} (${s.pixeldepth} bit)`,t.props["dev.graphics.adapter"]=`${n.model} ${n.vram} GB`}return t.environment=await j.createInstance(e),t}}let J={};if(B.type==B.Type.WEB)J.Image=globalThis.Image,J.ImageData=globalThis.ImageData,J.CanvasRenderingContext2D=globalThis.CanvasRenderingContext2D,void 0===globalThis.OffscreenCanvas?(J.OffscreenCanvas=function(e,t){let r=document.createElement("canvas");return r.width=e,r.height=t,r},J.OffscreenCanvasRenderingContext2D=globalThis.CanvasRenderingContext2D):(J.OffscreenCanvas=globalThis.OffscreenCanvas,J.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D);else if(void 0!==globalThis.OffscreenCanvas)J.Image=globalThis.Image,J.ImageData=globalThis.ImageData,J.OffscreenCanvas=globalThis.OffscreenCanvas,J.OffscreenCanvasRenderingContext2D=globalThis.OffscreenCanvasRenderingContext2D;else if(B.commonJS){const{Canvas:e,CanvasRenderingContext2D:t,Image:r,ImageData:i}=require("canvas");J.Image=r,J.ImageData=i,J.OffscreenCanvas=e,J.OffscreenCanvasRenderingContext2D=t}else console.warn(`Current env - ${B.type.name}, do not provides OffscreenCanvas support`);function Q(e){this.clearRect(0,0,this.canvas.width,this.canvas.height),e&&(this.fillStyle=e,this.fillRect(0,0,this.canvas.width,this.canvas.height))}J.CanvasRenderingContext2D&&(J.CanvasRenderingContext2D.prototype.clearCanvas=Q),J.OffscreenCanvasRenderingContext2D&&(J.OffscreenCanvasRenderingContext2D.prototype.clearCanvas=Q);const{Image:ee,ImageData:te,OffscreenCanvas:re,CanvasRenderingContext2D:ie,OffscreenCanvasRenderingContext2D:se}=J;let ne;class oe{#r={};constructor(...e){if(ne)throw new Error("URIResolver instance already available");ne=this,Object.defineProperty(this,"items",{get:()=>Object.values(this.#r),enumerable:!0}),this.init(...e)}init(...e){throw new Error("URIResolver.init(...args) is abstract and should be implemented")}get(e){return this.#r[e]}register(e,t){this.#r[e]=t}resolve(e){let t;if(e.includes("?")){let r=e.split("?")[0],i=this.#r[r];if(i){let r=e.split("?")[1],s=[];r.split("&").forEach((e=>{let t=e.split("=")[1],r=parseFloat(t);isFinite(r)?t=r:"true"==t?t=!0:"false"==t&&(t=!1),s.push(t)})),t=function(){return i(...Array.from(arguments).concat(s))}}}else t=this.#r[e];if(!t)throw new Error(`Failed to resolve ${e}`);return t}}Object.defineProperty(oe,"instance",{get:()=>ne});class ae{static encode(e,t=ae.Encoding.AUTO){let r;if(t==ae.Encoding.AUTO?t="undefined"==typeof Buffer?"undefined"!=typeof SharedArrayBuffer&&e.buffer instanceof SharedArrayBuffer?ae.Encoding.NONE:ae.Encoding.ARRAY:ae.Encoding.BUFFER:t==ae.Encoding.ARRAY&&e instanceof Array&&(t=ae.Encoding.NONE),t==ae.Encoding.NONE)r=e;else if(t==ae.Encoding.ARRAY)r=e.toArray();else{if("undefined"==typeof Buffer)throw new Error("Buffer not found, unable to serialize. Please provide Buffer in global scope.");let i=Buffer.from(e.buffer);switch(t){case ae.Encoding.BUFFER:r=i.toJSON();break;case ae.Encoding.BASE64:r=i.toString("base64");break;default:throw new Error(`Invalid encoding provided: ${t.name}`)}}return{encoding:t.name,type:e.constructor.name,content:r}}static decode(e){let t,r=ae.Encoding[e.encoding];if(r==ae.Encoding.NONE)t=e.content;else if(r==ae.Encoding.ARRAY)t=e.content.toFloat32Array();else{let i;switch(r){case ae.Encoding.BUFFER:i="undefined"==typeof Buffer?e.content.data:Buffer.from(e.content);break;case ae.Encoding.BASE64:i="undefined"==typeof Buffer?atob(e.content).toCharArray():Buffer.from(e.content,"base64");break;default:throw new Error(`Invalid encoding provided: ${r.name}`)}let s=new Uint8Array(i);t=new globalThis[e.type](s.buffer)}return t}static isTypedArrayData(e){return e&&e.encoding&&e.type&&e.type.endsWith("Array")}}Object.defineEnum(ae,"Encoding",["AUTO","NONE","ARRAY","BUFFER","BASE64"]);class le{static repetitionsCache=new Set;constructor(e,t){this.name=e,!e||D.isValidURL(e)||le.repetitionsCache.has(e)||(le.repetitionsCache.add(e),console.warn(`The string ${e} is not a well formed URI`)),Object.defineProperty(this,"value",{get:function(){if(!t){if(!this.name)throw new Error("Resource descriptor identifier not found. Cannot resolve resource content.");if("function"==typeof this.resolve&&(t=this.resolve(this.name)),!t){if(!oe.instance)throw new Error(`Resource URI ${this.name} cannot be resolved. URIResolver not implemented yet. Please implement and instantiate.`);t=oe.instance.resolve(this.name)}if(!t)throw new Error(`Resource URI ${this.name} cannot be resolved. Please provide resource definition in URIResolver init implementation.`)}return t},set:function(e){t=e},enumerable:!0})}toJSON(){let e=this.value;return ArrayBuffer.isTypedArray(e)?e=ae.encode(e,this.encoding):"function"==typeof e&&(e=e()),{name:this.name,value:e}}static fromJSON(e){let t=e.value;return ae.isTypedArrayData(t)&&(t=ae.decode(t)),new le(e.name,t)}static getInstance(e,t){return new le(t,e)}}class he{constructor(e){D.isValidURL(e)||(le.repetitionsCache.has(e)||(le.repetitionsCache.add(e),console.warn(`Brush URI ${e} is not a well formed URI`)),e=this.constructor.onInvalidName(e)),Object.defineProperty(this,"id",{value:e}),Object.defineProperty(this,"uri",{value:e}),Object.defineProperty(this,"name",{value:e,enumerable:!0})}toJSON(){throw new Error("Brush.toJSON() should be implemented")}static fromJSON(e){throw new Error("static Brush.fromJSON() should be implemented")}static onInvalidName(e){return e}}class de{static defaults={CIRCLE_PRECISION:20,CIRCLE_RADIUS:.5,ELLIPSE_PRECISION:20,ELLIPSE_RADIUS_X:.5,ELLIPSE_RADIUS_Y:.25,STAR_POINTS:5,STAR_RADIUS:.5,STAR_INTERNAL_RADIUS:.25};static createCircle(e=de.defaults.CIRCLE_PRECISION,t=de.defaults.CIRCLE_RADIUS,r={x:0,y:0}){return de.createEllipse(e,t,t,r)}static createEllipse(e=de.defaults.ELLIPSE_PRECISION,t=de.defaults.ELLIPSE_RADIUS_X,r=de.defaults.ELLIPSE_RADIUS_Y,i={x:0,y:0}){let s=[],n=2*Math.PI/e;if(t<=0)throw new Error(`Invalid radius x found ${t} > 0`);if(r<=0)throw new Error(`Invalid radius y found ${r} > 0`);for(let o=0;o<e;o++){let e=o*n,a=t*Math.cos(e),l=r*Math.sin(e);s.push(i.x+a,i.y+l)}return Float32Array.createSharedInstance(s)}static createStar(e=de.defaults.STAR_POINTS,t=de.defaults.STAR_INTERNAL_RADIUS,r=de.defaults.STAR_RADIUS){let i=[];if(r<=0)throw new Error(`Invalid radius found ${r} > 0`);if(t<=0)throw new Error(`Invalid internal radius found ${t} > 0`);if(t>r)throw new Error(`Invalid internal radius found 0 < ${t} < ${r}`);let s=2*Math.PI/e;for(let n=0;n<e;n++){let e=n*s,o=r*Math.cos(e),a=r*Math.sin(e),l=t*Math.cos(e+s/2),h=t*Math.sin(e+s/2);i.push(o,a,l,h)}return Float32Array.createSharedInstance(i)}}let ce=l?l.default||globalThis.poly2tri:{};const{SweepContext:pe,Point:ue}=ce;let fe=h?h.default||globalThis.ClipperLib:{};const{Clipper:me,Paths:ge,Path:ye,ClipType:be,PolyType:Ee,PolyFillType:Pe}=fe;class Ie{constructor(e,t,r){Object.defineProperties(this,{path:{value:e,enumerable:!0},pointIndexStart:{value:t,enumerable:!0},pointIndexEnd:{value:r,enumerable:!0}}),this.validate()}validate(){if(this.pointIndexStart<0)throw new Error(`Invalid fragment pointIndexStart ${this.pointIndexStart} found. The value must be non-negative....[truncated] -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)})),exports.Extension=t,exports.version="1.0.2"; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)})),exports.Extension=t,exports.version="1.0.2"; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)})),exports.Extension=t,exports.version="1.0.2"; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)})),exports.Extension=t,exports.version="1.0.2"; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)})),exports.Extension=t,exports.version="1.0.2"; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)})),exports.Extension=t,exports.version="1.0.2"; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)})),exports.Extension=t,exports.version="1.0.2"; -
- Engine
- Semgrep · Pattern-based code analysis
- Counts towards
- Vulnerability
- File
- /assets/src/js/wacom/modules/js-ext/js-ext-min.cjs line 1
- Likely real
- Uncertain, 33% confidence
Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static get overrides(){return["toString"]}static extend(t,e=this){let r;return"string"==typeof t?(r=t,t=globalThis[r]):r=t.name,t?(this.debug&&console.log("============================================================ extend",t.name,e.name),Object.getOwnPropertyNames(e.prototype).filter((t=>"constructor"!=t)).forEach((r=>{!(r in t.prototype)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride ${r}`,"color: chartreuse"):console.log(`%cdefine ${r}`,"color: green")),t.prototype[r]=e.prototype[r]):this.debug&&console.log(`%cexclude ${r}`,"color: red")})),Object.getOwnPropertyNames(e).forEach((r=>{"function"==typeof e[r]&&"extend"!=r&&(!(r in t)||e.overrides.includes(r)?(this.debug&&(e.overrides.includes(r)?console.log(`%coverride static ${r}`,"color: chartreuse"):console.log(`%cdefine static ${r}`,"color: orange")),t[r]=e[r]):this.debug&&console.log(`%cexclude static ${r}`,"color: red"))})),e.properties&&Object.keys(e.properties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t.prototype?this.debug&&console.log(`%cexclude prop ${r}`,"color: red"):e.properties[r]&&(this.debug&&console.log(`%cdefine prop ${r}`,"color: darkseagreen"),Object.defineProperty(t.prototype,r,e.properties[r]))})),e.classProperties&&Object.keys(e.classProperties).filter((t=>!["__proto__","prototype","constructor"].includes(t))).forEach((r=>{r in t?this.debug&&console.log(`%cexclude static prop ${r}`,"color: red"):e.classProperties[r]&&(this.debug&&console.log(`%cdefine static prop ${r}`,"color: chocolate"),Object.defineProperty(t,r,e.classProperties[r]))})),!0):(this.debug&&console.warn(`============================================================ Class ${r} not found`),!1)}}class e{constructor(t,e,r){Object.defineProperty(this,"type",{value:t,enumerable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!0}),Object.defineProperty(this,"value",{value:r,enumerable:!0})}toString(){return this.name}}class r extends t{static classProperties={MAX_INT32:{value:2147483647,enumerable:!0},MAX_UINT32:{value:4294967295,enumerable:!0},MAX_INT64:"undefined"==typeof BigInt?void 0:{value:0x7FFFFFFFFFFFFFFFn,enumerable:!0},MAX_UINT64:"undefined"==typeof BigInt?void 0:{value:0xFFFFFFFFFFFFFFFFn,enumerable:!0}};static properties={length:{get:function(){return 1+(0|Math.log10((this^this>>31)-(this>>31)))},configurable:!0}};pad(t,e="0"){return String(this).length<t?new Array(t-String(this).length+1).join(e)+String(this):this.toString()}toFloat32(){let t=new Float32Array(1);return t[0]=this,t[0]}}const i=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"];class n{constructor(t,e){this.width=t,this.height=e}toJSON(){return{width:this.width,height:this.height}}toString(){return`size(${this.width}, ${this.height})`}static fromSize(t){if(t instanceof n)return t;if("string"==typeof t){if(!t.startsWith("size("))throw new Error("Invalid value found. Expected template - size(width, height).");{let e=t.substring(t.indexOf("(")+1,t.indexOf(")")).split(/,\s*/g);t={width:parseFloat(e[0]),height:parseFloat(e[1])}}}if(isNaN(t.width))throw new Error("Invalid width found, expected number");if(isNaN(t.height))throw new Error("Invalid height found, expected number");return new n(t.width,t.height)}}class s extends t{static overrides=t.overrides.concat(["fromMatrix","multiply","multiplySelf","transformPoint"]);static properties={tx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},ty:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},dx:{get:function(){return this.e},set:function(t){this.e=t},enumerable:!0},dy:{get:function(){return this.f},set:function(t){this.f=t},enumerable:!0},multiplicationType:{value:"POST",enumerable:!0,writable:!0}};static classProperties={MultiplicationType:{value:{PRE:"PRE",POST:"POST"},enumerable:!0}};preMultiply(t){let e=t.postMultiply(this);return e.multiplicationType=this.multiplicationType,e}multiply(t){if(t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST)return this.postMultiply(t);{let e=this.preMultiply(t);return e.multiplicationType=DOMMatrix.MultiplicationType.PRE,e}}multiplySelf(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.multiplicationType==DOMMatrix.MultiplicationType.POST?this.postMultiplySelf(t):this.preMultiplySelf(t)}transformPoint(t){return DOMPoint.fromPoint(t).matrixTransform(this)}invert(){return this.inverse()}decompose(){return{translate:{x:this.tx,y:this.ty},rotate:{angle:Math.atan2(this.b,this.a)},skew:{angleX:Math.tan(this.c),angleY:Math.tan(this.b)},scale:{x:Math.sqrt(this.a*this.a+this.c*this.c),y:Math.sqrt(this.d*this.d+this.b*this.b)},matrix:this}}disassemble(){return console.warn("disassemble is deprecated, use decompose instead"),this.decompose()}toString(t){if(!t)return this.nativeToString();let e=t=>((t<0?"":" ")+t.toPrecision(6)).substring(0,8);return" Matrix 4x4\n"+"-".repeat(39)+`\n${e(this.m11)}, ${e(this.m21)}, ${e(this.m31)}, ${e(this.m41)}`+`\n${e(this.m12)}, ${e(this.m22)}, ${e(this.m32)}, ${e(this.m42)}`+`\n${e(this.m13)}, ${e(this.m23)}, ${e(this.m33)}, ${e(this.m43)}`+`\n${e(this.m14)}, ${e(this.m24)}, ${e(this.m34)}, ${e(this.m44)}`}static fromMatrix(t,e){let r;return"string"==typeof t?r=new DOMMatrix(t):("e"in t||(t.e=t.tx||t.dx),"f"in t||(t.f=t.ty||t.dy),r=DOMMatrix.nativeFromMatrix(t)),r.multiplicationType=e||t.multiplicationType||DOMMatrix.MultiplicationType.POST,r}static fromTranslate(t){let e=isFinite(t)?{tx:t,ty:t}:{tx:t.x,ty:t.y};return DOMMatrix.fromMatrix(e)}static fromRotate(t,e){let r=Math.sin(t),i=Math.cos(t),n={a:i,b:r,c:-r,d:i};return e&&(n.tx=e.x-e.x*i+e.y*r,n.ty=e.y-e.x*r-e.y*i),DOMMatrix.fromMatrix(n)}static fromScale(t,e){isFinite(t)&&(t={x:t,y:t});let r={a:t.x,d:t.y};return e&&(r.tx=e.x-e.x*t.x,r.ty=e.y-e.y*t.y),DOMMatrix.fromMatrix(r)}static fromPoints(t,e){let r=DOMMatrix.fromMatrix({m11:t[0].x,m21:t[1].x,m31:t[2].x,m12:t[0].y,m22:t[1].y,m32:t[2].y,m13:1,m23:1,m33:1}),i=DOMMatrix.fromMatrix({m11:e[0].x,m21:e[1].x,m31:e[2].x,m12:e[0].y,m22:e[1].y,m32:e[2].y,m13:1,m23:1,m33:1}),n=r.invert().preMultiply(i);return DOMMatrix.fromMatrix({a:n.m11,b:n.m12,c:n.m21,d:n.m22,tx:n.m31,ty:n.m32})}static extend(){if("undefined"==typeof DOMMatrix||DOMMatrix.nativeFromMatrix)return!1;DOMMatrix.nativeFromMatrix=DOMMatrix.fromMatrix,DOMMatrix.prototype.nativeToString=DOMMatrix.prototype.toString,DOMMatrix.prototype.postMultiply=DOMMatrix.prototype.multiply,DOMMatrix.prototype.postMultiplySelf=DOMMatrix.prototype.multiplySelf,t.extend("DOMMatrix",this)}}var o=Object.freeze({__proto__:null,ObjectExt:class extends t{static equals(t,e){if(t===e)return!0;if(!(t instanceof Object&&e instanceof Object))return!1;if(t.constructor!==e.constructor)return!1;if(t instanceof Array||ArrayBuffer.isTypedArray(t))return t.length==e.length&&t.every(((t,r)=>Object.equals(t,e[r])));for(let r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r))return!1;if(t[r]!==e[r]){if("object"!=typeof t[r])return!1;if(!Object.equals(t[r],e[r]))return!1}}for(let r in e)if(e.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}static clone(t,e){let r=new Array;return function t(i){if(null===i)return null;if("object"!=typeof i||i.immutable)return i;if("function"==typeof i.clone)return i.clone();for(let t=0;t<r.length;t++)if(r[t][0]===i)return r[t][1];let n=Object.create(Object.getPrototypeOf(i));r.push([i,n]);for(let r in i)e&&"function"==typeof i[r]||i.hasOwnProperty(r)&&(n[r]=t(i[r]));return n}(t)}static toSource(t,e){if("object"==typeof t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(`${e}: ${Object.toSource(t[e])}`);return(e?`${e} = `:"")+"{"+r.join(", ")+"}"}if("function"==typeof t){let e=t.toString();return t.name&&e.startsWith(t.name)&&(e="function "+e),e}return t}static defineEnum(t,r,i){if(t[r])throw new Error(`Already exist property: ${r}`);let n={values:i.map(((t,i)=>new e(r,t,i)))};return n.values.forEach((t=>{Object.defineProperty(n,t.name,{value:t,enumerable:!0}),Object.defineProperty(n,t.value,{value:t,enumerable:!0})})),Object.defineProperty(t,r,{value:n,enumerable:!0}),n}},StringExt:class extends t{startsWith(t){return this.length>=t.length&&this.substring(0,t.length)==t}endsWith(t){return this.length>=t.length&&this.substring(this.length-t.length,this.length)==t}includes(t){return-1!=this.indexOf(t)}contains(t){return this.includes(t)}containsIgnoreCase(t){return-1!=this.toUpperCase().indexOf(t.toUpperCase())}pad(t,e="-"){return this.length<t?new Array(t-this.length+1).join(e)+this:this.toString()}toCharArray(t){let e=[],r=!0;for(let t=0;t<this.length;t++){let i=this.charCodeAt(t);i>255&&(r=!1),e[t]=i}if(t){if(!r)throw new Error("Current value is not byte string");e=new Uint8Array(e)}return e}static fromCharArray(t){let e="";try{e=String.fromCharCode.apply(null,t)}catch(r){for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r])}return e}},NumberExt:r,FunctionExt:class extends t{static properties={body:{get:function(){let t=this.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),t},configurable:!0}};static createClass(t,e){return new Function(e?e.name:void 0,`return class ${t}${e?` extends ${e.name}`:""} {\n\t\t\tconstructor() {\n\t\t\t\t${e?"super(...arguments);":""}\n\t\t\t}\n\t\t}`)(e)}},ArrayExt:class extends t{static properties={first:{get:function(){return this[0]},configurable:!0},last:{get:function(){return this[this.length-1]},configurable:!0}};clear(){this.length=0}includes(t){return this.indexOf(t)>-1}clone(){if(!Object.clone)throw new Error("Object extension is required");return this.map((t=>Object.clone(t)))}unique(){return this.filter(((t,e)=>this.indexOf(t)==e))}add(t){return!this.includes(t)&&(this.push(t),!0)}insert(t,e=0){this.splice(e,0,t)}indicesOf(t){let e=[],r=this.indexOf(t);if(-1!=r){e.push(r);let i=this.lastIndexOf(t);for(;i>r;)r=this.indexOf(t,r+1),e.push(r)}return e}remove(...t){return(t=>{let e=[],r=-1;return t.forEach((t=>{r-t!=1&&e.push([]),e.last.push(t),r=t})),e})(t.map((t=>this.indicesOf(t))).flat().sort(((t,e)=>e-t))).forEach((t=>this.removeAt(t.last,t.length))),this}removeAt(t,e=1){return t>-1&&this.splice(t,e),this}replace(t,e,r){let i=this.indexOf(t);return i>-1&&(!r&&e instanceof Array?this.splice(i,1,...e):this.splice(i,1,e)),this}static from(t){return Array.prototype.slice.call(t)}},ArrayBufferExt:class extends t{toBase64(){if(!String.fromCharArray)throw new Error("String extension is required");let t=new Uint8Array(this);return btoa(String.fromCharArray(t))}static fromBase64(t){if(!String.prototype.toCharArray)throw new Error("String extension is required");return atob(t).toCharArray(!0).buffer}static isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}},TypedArrayExt:class extends t{clone(){if("undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer){let t=new SharedArrayBuffer(this.byteLength),e=new this.constructor(t);return e.set(this,this.byteOffset),e}return new this.constructor(this,this.byteOffset,this.length)}concat(...t){let e,r=this.length,i=this.length;return t.forEach((t=>{if(this.constructor!=t.constructor)throw new Error(`Concat array from wrong type detected - expected ${this.constructor.name}, found ${t.constructor.name}`);r+=t.length})),e="undefined"!=typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer?this.constructor.createSharedInstance(r):new this.constructor(r),e.set(this),t.forEach((t=>{e.set(t,i),i+=t.length})),e}toArray(){return Array.from(this)}static createSharedInstance(t=0){if(t instanceof this)return t;if("number"!=typeof t&&!Array.isArray(t))throw new Error("Expected data type is Array");let e="number"==typeof t?t:t.length;if("undefined"==typeof SharedArrayBuffer)return new this("number"==typeof t?e:t);{let r=new SharedArrayBuffer(e*this.BYTES_PER_ELEMENT);if("number"==typeof t)return new this(r);{let e=new this(r);return e.set(t),e}}}static from(t){return new this(t)}static extend(){i.forEach((e=>{if(t.extend(e+"Array",this)){let t=globalThis[e+"Array"];Array.prototype["to"+e+"Array"]=function(){return t.from(this)}}}))}},SetExt:class extends t{map(t){let e=new Set;for(let r of this)r=t(r),r&&e.add(r);return e}filter(t){let e=new Set;for(let r of this)t(r)&&e.add(r);return e}},ScreenExt:class extends t{static properties={size:{get:()=>({width:Math.floor(screen.width),height:Math.floor(screen.height)}),configurable:!0},resolution:{get:()=>({width:Math.floor(screen.width*devicePixelRatio),height:Math.floor(screen.height*devicePixelRatio)}),configurable:!0}}},LocationExt:class extends t{static get properties(){return{query:{get:function(){if(!this._query){let t=Object.assign({},...this.search.substring(1).split("&").filter((t=>t)).map((t=>t.split("="))).map((t=>({[t[0]]:decodeURIComponent(t[1])}))));Object.defineProperty(this,"_query",{value:t})}return this._query},configurable:!0}}}},HTMLElementExt:class extends t{getInlineStyle(t){return this.style[t]||this.style["-webkit-"+t]||this.style["-khtml-"+t]||this.style["-moz-"+t]||this.style["-ms-"+t]||this.style["-o-"+t]||""}setStyle(t,e){["-webkit","-khtml","-moz","-ms","-o"].forEach((r=>this.style[r+"-"+t]=e)),this.style[t]=e}getStyle(t){let e=t,r=t.startsWith("-");r&&(e=t.substring(1));let i=e.split("-");for(let t=i.length-1;t>0;t--)i[t]=i[t].substring(0,1).toUpperCase()+i[t].substring(1);e=i.join("");let n=this.style.display,s=this.style.visibility;"none"==n&&(this.style.visibility="hidden",this.style.display="");let o=window.getComputedStyle(this)[e];if(!r&&void 0===o){let e=["-webkit","-khtml","-moz","-ms","-o"];for(let r=0;r<e.length&&(o=this.getStyle(e[r]+"-"+t),"undefined"==o);r++);}return"none"==n&&(this.style.visibility=s,this.style.display="none"),o}getMathStyle(t,e){let r=e?this.getInlineStyle(t):this.getStyle(t);return"auto"==r&&(r=0),parseFloat(r)}getTransformStyle(){let t={translate:{x:0,y:0},scale:{x:1,y:1},rotate:{angle:0},skew:{angleX:0,angleY:0},matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0}},e=this.getStyle("transform");if("none"!=e){let r=e.substring(e.indexOf("(")+1,e.indexOf(")")).split(/,\s*/g),i=parseFloat(r[0]),n=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),a=parseFloat(r[4]),h=parseFloat(r[5]);t.scale={x:Math.sqrt(i*i+s*s),y:Math.sqrt(o*o+n*n)},t.skew={angleX:Math.tan(s),angleY:Math.tan(n)},t.rotate={angle:Math.atan2(n,i)},t.translate={x:a,y:h},t.matrix={a:i,b:n,c:s,d:o,tx:a,ty:h}}return t}toRect(){let t=this.style.display,e=this.style.visibility;"none"==t&&(this.style.visibility="hidden",this.style.display="");let r=this.offsetWidth+this.getMathStyle("margin-left")+this.getMathStyle("margin-right"),i=this.offsetHeight+this.getMathStyle("margin-top")+this.getMathStyle("margin-bottom"),n=new DOMRect(this.offsetLeft,this.offsetTop,this.offsetWidth,this.offsetHeight);return n.outerSize=new DOMSize(r,i),"none"==t&&(this.style.visibility=e,this.style.display="none"),n}},HTMLImageElementExt:class extends t{toDataURL(t="png"){let e=document.createElement("canvas");return e.width=this.width,e.height=this.height,e.getContext("2d").drawImage(this,0,0),e.toDataURL(`image/${t}`)}toBlob(t="png"){return new Blob([this.toArrayBuffer(t)],{type:`image/${t}`})}toArrayBuffer(t){if(!ArrayBuffer.fromBase64)throw new Error("ArrayBuffer extension is required");let e=this.toDataURL(t).split(",")[1];return ArrayBuffer.fromBase64(e)}},ImageExt:class extends t{static fromBytes(t,e="png",r=new Image){return new Promise(((i,n)=>{r.onload=()=>{URL.revokeObjectURL(r.src),i(r)},r.onerror=n,r.src=URL.createObjectURL(new Blob([t.buffer||t],{type:`image/${e}`}))}))}},CanvasExt:class extends t{static extend(){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.clearCanvas=function(t){this.clearRect(0,0,this.canvas.width,this.canvas.height),t&&(this.fillStyle=t,this.fillRect(0,0,this.canvas.width,this.canvas.height))},"undefined"==typeof OffscreenCanvas?(globalThis.OffscreenCanvas=function(t,e){let r=document.createElement("canvas");return r.width=t,r.height=e,r},globalThis.OffscreenCanvasRenderingContext2D=CanvasRenderingContext2D):"undefined"!=typeof OffscreenCanvasRenderingContext2D&&(OffscreenCanvasRenderingContext2D.prototype.clearCanvas=CanvasRenderingContext2D.prototype.clearCanvas))}},DOMPointExt:class extends t{transform(t){return t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t)),this.matrixTransform(t)}toString(){return`point(${this.x}, ${this.y}, ${this.z})`}},DOMRectExt:class extends t{static properties={size:{get:function(){return new n(this.width,this.height)},configurable:!0},center:{get:function(){return new DOMPoint((this.left+this.right)/2,(this.top+this.bottom)/2)},configurable:!0}};union(t){return t?DOMRect.ofEdges(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom)):this}intersect(t){if(!t)return;let e=DOMRect.ofEdges(Math.max(this.left,t.left),Math.max(this.top,t.top),Math.min(this.right,t.right),Math.min(this.bottom,t.bottom));return e.width>0&&e.height>0?e:void 0}ceil(t){let e=Math.floor(this.left),r=Math.floor(this.top),i=Math.ceil(this.right),n=Math.ceil(this.bottom);if(t){let t=this.width,s=this.height;t+=t%2,s+=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}floor(t){let e=Math.ceil(this.left),r=Math.ceil(this.top),i=Math.floor(this.right),n=Math.floor(this.bottom);if(t){let t=this.width,s=this.height;t-=t%2,s-=s%2,i=e+t,n=r+s}return DOMRect.ofEdges(e,r,i,n)}contains(t){return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}transform(t){t instanceof DOMMatrix||(t=DOMMatrix.fromMatrix(t));let e=DOMPoint.fromPoint({x:this.left,y:this.top}).transform(t),r=DOMPoint.fromPoint({x:this.right,y:this.top}).transform(t),i=DOMPoint.fromPoint({x:this.left,y:this.bottom}).transform(t),n=DOMPoint.fromPoint({x:this.right,y:this.bottom}).transform(t),s=Math.min(e.x,r.x,i.x,n.x),o=Math.min(e.y,r.y,i.y,n.y),a=Math.max(e.x,r.x,i.x,n.x),h=Math.max(e.y,r.y,i.y,n.y);return DOMRect.ofEdges(s,o,a,h)}matrixTransform(t){return this.transform(t)}toPath(){let t=[];return t.push(this.left,this.top),t.push(this.right,this.top),t.push(this.right,this.bottom),t.push(this.left,this.bottom),t.push(this.left,this.top),t.toFloat32Array()}toString(){return`rect(${this.x}, ${this.y}, ${this.width}, ${this.height})`}static ofEdges(t,e,r,i){return new DOMRect(t,e,r-t,i-e)}static extend(){t.extend("DOMRect",this)&&(globalThis.DOMSize=n)}},DOMMatrixExt:s});"undefined"==typeof globalThis&&("undefined"!=typeof window?window.globalThis=window:"undefined"!=typeof self?self.globalThis=self:"undefined"!=typeof global&&(global.globalThis=global)),Math.toDegrees=function(t){return t*(180/this.PI)},Math.toRadians=function(t){return t*(this.PI/180)},Math.randomInt=function(t,e){return Math.floor(this.random()*(e-t+1))+t},Function.prototype.createEnum=function(t,e){console.warn(`createEnum is deprecated, please update ${t} enum with Object.defineEnum(target, name, values)`),Object.defineEnum(this,t,e)},"function"==typeof Worker&&(Worker.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),"function"==typeof DedicatedWorkerGlobalScope&&(DedicatedWorkerGlobalScope.prototype.on=function(t,e){this[`on${t}`]=r=>{let i="message"==t?r.data:r;e(i)}}),globalThis.JS_EXT_SCOPE||Object.defineProperty(globalThis,"JS_EXT_SCOPE",{value:["Object","String","Number","Function","Array","ArrayBuffer","TypedArray","Set","Screen","Location","HTMLElement","HTMLImageElement","Image","Canvas","DOMPoint","DOMRect","DOMMatrix"],enumerable:!0,configurable:!0}),globalThis.JS_EXT_SCOPE.forEach((t=>{let e=o[`${t}Ext`];if(!e)throw new Error(`Extension ${t} not found`);e.extend(t)})),exports.Extension=t,exports.version="1.0.2"; -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-debug^5.0.0' — attacker could push malicious update
gulp-debug:^5.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'hotkeys-js^4.0.0' — attacker could push malicious update
hotkeys-js:^4.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-uglify^3.0.2' — attacker could push malicious update
gulp-uglify:^3.0.2 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-stylus^3.0.0' — attacker could push malicious update
gulp-stylus:^3.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-sass^6.0.0' — attacker could push malicious update
gulp-sass:^6.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-replace^1.1.4' — attacker could push malicious update
gulp-replace:^1.1.4 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-rename^2.0.0' — attacker could push malicious update
gulp-rename:^2.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-less^5.0.0' — attacker could push malicious update
gulp-less:^5.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-if^3.0.0' — attacker could push malicious update
gulp-if:^3.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-flatten^0.4.0' — attacker could push malicious update
gulp-flatten:^0.4.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'inquirer^13.2.0' — attacker could push malicious update
inquirer:^13.2.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-concat^2.6.0' — attacker could push malicious update
gulp-concat:^2.6.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-clean-css^4.0.0' — attacker could push malicious update
gulp-clean-css:^4.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-babel^8.0.0' — attacker could push malicious update
gulp-babel:^8.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp-autoprefixer^10.0.0' — attacker could push malicious update
gulp-autoprefixer:^10.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gulp^4.0.2' — attacker could push malicious update
gulp:^4.0.2 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'globby^14.0.1' — attacker could push malicious update
globby:^14.0.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'del^6.0.0' — attacker could push malicious update
del:^6.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'archiver^8.0.0' — attacker could push malicious update
archiver:^8.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'bootstrap-daterangepicker^2.1.25' — attacker could push malicious update
bootstrap-daterangepicker:^2.1.25 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: '@fullcalendar/moment^6.1.5' — attacker could push malicious update
@fullcalendar/moment:^6.1.5 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: '@openapitools/openapi-generator-cli^2.25.0' — attacker could push malicious update
@openapitools/openapi-generator-cli:^2.25.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: '@ttskch/select2-bootstrap4-theme^1.5.2' — attacker could push malicious update
@ttskch/select2-bootstrap4-theme:^1.5.2 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'admin-lte^3.2.0' — attacker could push malicious update
admin-lte:^3.2.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'autocompleter^6.1.1' — attacker could push malicious update
autocompleter:^6.1.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'autonumeric^4.6.0' — attacker could push malicious update
autonumeric:^4.6.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'autosize^6.0.1' — attacker could push malicious update
autosize:^6.0.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'bootstrap^4.3.1' — attacker could push malicious update
bootstrap:^4.3.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'bootstrap-colorpicker^3.4.0' — attacker could push malicious update
bootstrap-colorpicker:^3.4.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: '@babel/preset-env^7.11.0' — attacker could push malicious update
@babel/preset-env:^7.11.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'bootstrap-maxlength^2.0.0' — attacker could push malicious update
bootstrap-maxlength:^2.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'chart.js^4.5.1' — attacker could push malicious update
chart.js:^4.5.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'clipper-lib^6.4.2' — attacker could push malicious update
clipper-lib:^6.4.2 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'components-jqueryui^1.12.1' — attacker could push malicious update
components-jqueryui:^1.12.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'datatables.net-bs^1.10.15' — attacker could push malicious update
datatables.net-bs:^1.10.15 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'datatables.net-buttons-bs^1.3.1' — attacker could push malicious update
datatables.net-buttons-bs:^1.3.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'shelljs^0.10.0' — attacker could push malicious update
shelljs:^0.10.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'sass^1.62.1' — attacker could push malicious update
sass:^1.62.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'html5sortable^0.14.0' — attacker could push malicious update
html5sortable:^0.14.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'leaflet.fullscreen^3.0.2' — attacker could push malicious update
leaflet.fullscreen:^3.0.2 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'leaflet-gesture-handling^1.2.2' — attacker could push malicious update
leaflet-gesture-handling:^1.2.2 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'leaflet^1.9.4' — attacker could push malicious update
leaflet:^1.9.4 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'jszip^3.10.1' — attacker could push malicious update
jszip:^3.10.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'jquery-ui-touch-punch^0.2.3' — attacker could push malicious update
jquery-ui-touch-punch:^0.2.3 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'jquery-form^4.3.0' — attacker could push malicious update
jquery-form:^4.3.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'jquery^3.5.1' — attacker could push malicious update
jquery:^3.5.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'ismobilejs^1.1.1' — attacker could push malicious update
ismobilejs:^1.1.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'inputmask^5.0.9' — attacker could push malicious update
inputmask:^5.0.9 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'merge-stream^2.0.0' — attacker could push malicious update
merge-stream:^2.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'gl-matrix^3.4.3' — attacker could push malicious update
gl-matrix:^3.4.3 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'geocomplete^1.7.0' — attacker could push malicious update
geocomplete:^1.7.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'fullcalendar-scheduler^6.1.5' — attacker could push malicious update
fullcalendar-scheduler:^6.1.5 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'font-awesome^4.7.0' — attacker could push malicious update
font-awesome:^4.7.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'eonasdan-bootstrap-datetimepicker^4.17.49' — attacker could push malicious update
eonasdan-bootstrap-datetimepicker:^4.17.49 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'dropzone^5.7.2' — attacker could push malicious update
dropzone:^5.7.2 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'driver.js^1.0.0' — attacker could push malicious update
driver.js:^1.0.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'datatables.net-select-bs^1.2.2' — attacker could push malicious update
datatables.net-select-bs:^1.2.2 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'readmore.js^2.0.4' — attacker could push malicious update
readmore.js:^2.0.4 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: '@babel/core^7.11.1' — attacker could push malicious update
@babel/core:^7.11.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'tooltipster^4.2.5' — attacker could push malicious update
tooltipster:^4.2.5 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'toastr^2.1.4' — attacker could push malicious update
toastr:^2.1.4 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'sweetalert2^11.26.24' — attacker could push malicious update
sweetalert2:^11.26.24 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'smartwizard^6.0.6' — attacker could push malicious update
smartwizard:^6.0.6 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'sjcl^1.0.8' — attacker could push malicious update
sjcl:^1.0.8 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'signature_pad^2.3.0' — attacker could push malicious update
signature_pad:^2.3.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'select2^4.0.3' — attacker could push malicious update
select2:^4.0.3 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'datatables.net-scroller-bs^2.4.3' — attacker could push malicious update
datatables.net-scroller-bs:^2.4.3 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'rbush^3.0.1' — attacker could push malicious update
rbush:^3.0.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'pwstrength-bootstrap^3.0.4' — attacker could push malicious update
pwstrength-bootstrap:^3.0.4 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'protobufjs^8.7.0' — attacker could push malicious update
protobufjs:^8.7.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'popper.js^1.16.1' — attacker could push malicious update
popper.js:^1.16.1 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'poly2tri^1.5.0' — attacker could push malicious update
poly2tri:^1.5.0 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'parsleyjs^2.7.2' — attacker could push malicious update
parsleyjs:^2.7.2 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'numeral^2.0.6' — attacker could push malicious update
numeral:^2.0.6 -
- Engine
- Dependency checker · CVEs, typosquats and risky installs
- Counts towards
- Supply chain
- File
- package.json
- Likely real
- Probably noise, 2% confidence
Loose version constraint: 'moment^2.18.1' — attacker could push malicious update
moment:^2.18.1 -
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /docker/README.md
- Likely real
- Probably noise, 0% confidence
YARA rule matched: detect_downloader — Downloads a remote resource - common and low-signal alone; see detect_download_and_execute for the composite version
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /docker/Dockerfile
- Likely real
- Probably noise, 0% confidence
YARA rule matched: detect_downloader — Downloads a remote resource - common and low-signal alone; see detect_download_and_execute for the composite version
-
- Engine
- YARA · Malware signature rules
- Counts towards
- Malicious pattern
- File
- /docker/Dockerfile.dev
- Likely real
- Probably noise, 0% confidence
YARA rule matched: detect_downloader — Downloads a remote resource - common and low-signal alone; see detect_download_and_execute for the composite version
No findings match these filters.