fas-js 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -674
- package/README.md +177 -164
- package/lib/.gitkeep +0 -0
- package/lib/bundle.js +12 -1
- package/lib/bundle.js.map +1 -0
- package/lib/index.cjs +644 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +39 -0
- package/lib/index.d.ts +39 -0
- package/lib/index.js +616 -0
- package/lib/index.js.map +1 -0
- package/package.json +74 -80
package/README.md
CHANGED
|
@@ -1,164 +1,177 @@
|
|
|
1
|
-
# Finite Automaton Simulator
|
|
2
|
-
|
|
3
|
-
[](https://snyk.io/test/github/jml6m/fas-js)
|
|
6
|
-
[](https://codecov.io/gh/jml6m/fas-js)
|
|
7
|
-
[](https://npmjs.org/package/fas-js)
|
|
8
|
-
[](https://www.jsdelivr.com/package/npm/fas-js)
|
|
9
|
-
|
|
10
|
-
Easily create and simulate state machines using this JS library. Import into your own server side or browser based JS application.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
{ from: "q1", to: "
|
|
79
|
-
{ from: "
|
|
80
|
-
{ from: "q2", to: "
|
|
81
|
-
{ from: "
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<span style="font-size:18px"><
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
//
|
|
136
|
-
simulateFSA("
|
|
137
|
-
simulateFSA("
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
1
|
+
# Finite Automaton Simulator
|
|
2
|
+
|
|
3
|
+
[](https://github.com/jml6m/fas-js/actions/workflows/ci.yml)
|
|
4
|
+
[](https://badge.fury.io/js/fas-js)
|
|
5
|
+
[](https://snyk.io/test/github/jml6m/fas-js)
|
|
6
|
+
[](https://codecov.io/gh/jml6m/fas-js)
|
|
7
|
+
[](https://npmjs.org/package/fas-js)
|
|
8
|
+
[](https://www.jsdelivr.com/package/npm/fas-js)
|
|
9
|
+
|
|
10
|
+
Easily create and simulate state machines using this JS library. Import into your own server side or browser based JS application.
|
|
11
|
+
|
|
12
|
+
> **Contributing:** See [CONTRIBUTING.md](CONTRIBUTING.md). v1.4 modernized the toolchain (TypeScript, tsup, demo, tests) without API changes — see [docs/v1.1-prep/](docs/v1.1-prep/) for the prep history.
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
###### Visualization of an FSA
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
Add the latest version of `fas-js` to your package.json:
|
|
19
|
+
```
|
|
20
|
+
npm install fas-js --save-dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
ESM import:
|
|
24
|
+
```javascript
|
|
25
|
+
import { createFSA, simulateFSA, stepOnceFSA } from "fas-js";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
CommonJS:
|
|
29
|
+
```javascript
|
|
30
|
+
const { createFSA, simulateFSA, stepOnceFSA } = require("fas-js");
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Import into HTML file
|
|
34
|
+
```
|
|
35
|
+
<script src="https://cdn.jsdelivr.net/npm/fas-js/lib/bundle.js"></script>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Background
|
|
39
|
+
A finite automaton is a formally defined state machine, a concept that can then be expanded on to build more complex and powerful computational machines. I highly recommend the book "Introduction to the Theory of Computation" by Michael Sipser if you want to learn more about FSAs and related concepts.
|
|
40
|
+
|
|
41
|
+
A **Finite State Automaton (FSA)** is defined as a 5-tuple (Q, Σ, δ, q0, F) where:
|
|
42
|
+
|
|
43
|
+
1. Q is a finite set called **states**
|
|
44
|
+
2. Σ is a finite set called **alphabet**
|
|
45
|
+
3. δ: Q x Σ → Q is the **transition function**
|
|
46
|
+
4. q0 ∈ Q is the **start state**
|
|
47
|
+
5. F ⊆ Q is the set of **accept states**
|
|
48
|
+
|
|
49
|
+
An FSA can be conceptualized as a [Directed Graph](https://en.wikipedia.org/wiki/Directed_graph), or more specifically, an [Oriented Graph](https://en.wikipedia.org/wiki/Orientation_(graph_theory)). It's often visualized in this way for teaching and demonstration purposes. It is also important to understand [Sets](https://en.wikipedia.org/wiki/Set_(mathematics)) and their logical operators when working with FSAs.
|
|
50
|
+
|
|
51
|
+
A **Deterministic Finite Automaton (DFA)** has exactly one transition for each symbol on every state. A **Nondeterministic Finite Automaton (NFA)** may have any number of transitions (including no transition) for an input symbol on any given state. NFAs may also include an ε-transition, a transition that occurs without consuming an input symbol. By definition, all DFAs are also NFAs. It also follows that all NFAs can be represented as a DFA.
|
|
52
|
+
|
|
53
|
+
## Creation
|
|
54
|
+
This library offers one method for creating an FSA. The parameters correspond to the definition above:
|
|
55
|
+
|
|
56
|
+
<span style="font-size:20px"><a name="createFSA" href="#createFSA">#</a> <b>createFSA</b>(<i>Q</i>: string[], <i>Σ</i>: string | string[], <i>δ</i>: Object[], <i>q0</i>: string, <i>F</i>: string[]): FSA [<>](https://github.com/jml6m/fas-js/blob/master/src/utils/FSAUtils.js#L125 "Source")</span>
|
|
57
|
+
|
|
58
|
+
### Inputs
|
|
59
|
+
<b>Q</b> cannot be empty, and each state name must be unique
|
|
60
|
+
```javascript
|
|
61
|
+
const states = ["q1", "q2"];
|
|
62
|
+
const states2 = ["q1", "q2", "q3", "q4"];
|
|
63
|
+
```
|
|
64
|
+
<b>Σ</b> cannot be empty, and can be passed in as one string (each character will be interpreted as a separate symbol) or a string array. Cannot contain duplicate symbols. For NFAs, you do not need to specify the empty string, it is implicitly added.
|
|
65
|
+
```javascript
|
|
66
|
+
const alphabet = "01"; // ["0", "1"]
|
|
67
|
+
const alph_array = ["0", "1", "up", "down", "*"];
|
|
68
|
+
```
|
|
69
|
+
<b>δ</b> is an array of objects that define the transitions between states. This object differs for DFAs and NFAs, and createFSA() will determine which to create based on the structure of this input.
|
|
70
|
+
* For DFA: `{from: "origin_state", to: "dest_state", input: "symbol"}`
|
|
71
|
+
* For NFA: `{from: "origin_state", to: "dest_state1,dest_state2,...", input: "symbol"}`
|
|
72
|
+
|
|
73
|
+
Input array for DFAs must contain a transition for each alphabet symbol on each origin state. Thus, the size of δ = size of Σ x size of Q. Σ cannot contain an empty string as a symbol for DFAs.
|
|
74
|
+
|
|
75
|
+
For NFAs, the `to` field can contain one or more destination states, comma separated, no spaces between state names. The `input` field can be `""`, indicating an ε (empty) transition.
|
|
76
|
+
```javascript
|
|
77
|
+
const dfa_tfunc = [
|
|
78
|
+
{ from: "q1", to: "q2", input: "1" },
|
|
79
|
+
{ from: "q2", to: "q1", input: "0" },
|
|
80
|
+
{ from: "q2", to: "q2", input: "1" },
|
|
81
|
+
{ from: "q1", to: "q1", input: "0" }
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
const nfa_tfunc = [
|
|
85
|
+
{ from: "q1", to: "q1", input: "0" },
|
|
86
|
+
{ from: "q1", to: "q1,q2", input: "1" },
|
|
87
|
+
{ from: "q2", to: "q3", input: "0" },
|
|
88
|
+
{ from: "q2", to: "q3", input: "" },
|
|
89
|
+
{ from: "q3", to: "q4", input: "1" },
|
|
90
|
+
{ from: "q4", to: "q4", input: "0" },
|
|
91
|
+
{ from: "q4", to: "q4", input: "1" }
|
|
92
|
+
];
|
|
93
|
+
```
|
|
94
|
+
<b>q0</b> is the start state of the FSA. The first symbol of the input string is processed on this state. It must be a member of Q.
|
|
95
|
+
```javascript
|
|
96
|
+
const start = "q1";
|
|
97
|
+
```
|
|
98
|
+
<b>F</b> is the set of accept states, which determine whether a given input string is "accepted" by the FSA or "rejected". This determination is made after the last symbol of the input has been read. If any of the final states are in the accepting set, that string is accepted.
|
|
99
|
+
|
|
100
|
+
The set of accept states must be a subset of Q - it can also be an empty set (an FSA that always rejects). For simulation purposes, F is passed in as a string array that cannot contain duplicate states
|
|
101
|
+
```javascript
|
|
102
|
+
const accepts = ["q1"]; // Start state can also be an accept state
|
|
103
|
+
const accepts2 = ["q3", "q4"];
|
|
104
|
+
```
|
|
105
|
+
### Examples
|
|
106
|
+
```javascript
|
|
107
|
+
const dfa = createFSA(states, alphabet, dfa_tfunc, start, accepts);
|
|
108
|
+
const nfa = createFSA(states2, alphabet, nfa_tfunc, start, accepts2);
|
|
109
|
+
```
|
|
110
|
+
<span style="font-size:24px"><a name="FSA" href="#FSA">#</a> <b>FSA</b></span><br />
|
|
111
|
+
`createFSA()` returns an object with custom type. This object has no public properties, but does include helper methods available to the user.
|
|
112
|
+
|
|
113
|
+
<span style="font-size:18px"><b>getType</b>(): string</span> - returns either `"DFA"` or `"NFA"`
|
|
114
|
+
|
|
115
|
+
<span style="font-size:18px"><b>generateDigraph</b>(): string</span> - returns digraph according to [DOT](https://www.graphviz.org/doc/info/lang.html) language to be used for visualization.
|
|
116
|
+
|
|
117
|
+
## Simulation
|
|
118
|
+
There are two simulation options available:<br />
|
|
119
|
+
|
|
120
|
+
<span style="font-size:18px"><a name="simulateFSA" href="#simulateFSA">#</a> <b>simulateFSA</b>(<i>w</i>: string | string[], <i>fsa</i>: FSA, <i>logging</i>: boolean = false, <i>returnEndState</i>: boolean = false) [<>](https://github.com/jml6m/fas-js/blob/master/src/engine/Simulators.js#L10 "Source")</span>
|
|
121
|
+
|
|
122
|
+
Runs the entire input `w` through the `fsa`. `w` must only contain symbols from the alphabet defined in `fsa`. By default, the function returns a boolean signifying whether `w` was accepted by the `fsa`. If `returnEndState` is set to true, the function will instead return the final state (string) or the final array of states (string[]), depending on whether `fsa` is a DFA or NFA.
|
|
123
|
+
|
|
124
|
+
<span style="font-size:18px"><a name="stepOnceFSA" href="#stepOnceFSA">#</a> <b>stepOnceFSA</b>(w: string, qin: string | string[], fsa: FSA, logging: boolean = false) [<>](https://github.com/jml6m/fas-js/blob/master/src/engine/Simulators.js#L23 "Source")</span>
|
|
125
|
+
|
|
126
|
+
Returns the destination state(s), based on input symbol `w` and input state `qin`, as defined by δ of `fsa`. `w` must match a symbol from the alphabet defined in `fsa` (can also be the empty string). `qin` must be a state in Q. Use this function if you'd like to iterate through an input string step-by-step.
|
|
127
|
+
|
|
128
|
+
<sub>Note: In both functions above, a third `logging` parameter is available (defaults to false) which will print useful messages to the console as the simulator processes the input string. This can be used for debugging purposes or server-side logs. It is recommended to leave it defaulted to false for browser applications.
|
|
129
|
+
|
|
130
|
+
### Examples
|
|
131
|
+
Both simulators require an FSA object created with createFSA(). Here we will use the FSAs created in the [Examples](#Examples) above.
|
|
132
|
+
```javascript
|
|
133
|
+
// DFA Simulations
|
|
134
|
+
simulateFSA("0", dfa); // returns true
|
|
135
|
+
simulateFSA("01", dfa); // returns false
|
|
136
|
+
simulateFSA("", dfa); // returns true
|
|
137
|
+
simulateFSA("011", dfa, false, true); // returnEndState enabled, returns "q2"
|
|
138
|
+
|
|
139
|
+
stepOnceFSA("0", "q1", dfa); // returns "q1"
|
|
140
|
+
stepOnceFSA("1", "q1", dfa); // returns "q2"
|
|
141
|
+
|
|
142
|
+
// NFA Simulations
|
|
143
|
+
simulateFSA("0", nfa); // returns false
|
|
144
|
+
simulateFSA("01", nfa); // returns true
|
|
145
|
+
simulateFSA("0100", nfa); // returns false
|
|
146
|
+
simulateFSA("011", nfa, false, true); // returnEndState enabled, returns ["q1", "q2", "q3", "q4"]
|
|
147
|
+
|
|
148
|
+
stepOnceFSA("1", "q1", nfa); // returns ["q1", "q2", "q3"]
|
|
149
|
+
stepOnceFSA("0", ["q1","q2","q3"], nfa); // returns ["q1", "q3"]
|
|
150
|
+
|
|
151
|
+
// Step through an input string w on DFA
|
|
152
|
+
const w = "01101";
|
|
153
|
+
let inputState = start;
|
|
154
|
+
for (const symbol of w) {
|
|
155
|
+
inputState = stepOnceFSA(symbol, inputState, dfa);
|
|
156
|
+
}
|
|
157
|
+
// Now, check for acceptance
|
|
158
|
+
if(accepts.indexOf(inputState) !== -1)
|
|
159
|
+
console.log("Accepted!");
|
|
160
|
+
else
|
|
161
|
+
console.log("Rejected!");
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Demo
|
|
166
|
+
|
|
167
|
+
Interactive demos visualize FSAs as you simulate input strings.
|
|
168
|
+
|
|
169
|
+
| Version | URL | Notes |
|
|
170
|
+
|---------|-----|-------|
|
|
171
|
+
| **v1.1** (prep) | [GitHub Pages demo](https://jml6m.github.io/fas-js/v1.1/) | Self-hosted in this repo (`demo/v1.1/`); uses current `fasJs` bundle |
|
|
172
|
+
| **v1** (legacy) | [ObservableHQ](https://observablehq.com/@jml6m/state-machine-simulator) | Original demo; kept for legacy reference |
|
|
173
|
+
|
|
174
|
+
See [demo/README.md](demo/README.md) for local development and deployment details.
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
This library is distributed under the GPL 3.0 license found in the [LICENSE](https://github.com/jml6m/fas-js/blob/master/LICENSE) file.
|
package/lib/.gitkeep
ADDED
|
File without changes
|
package/lib/bundle.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).fasJs=e()}}(function(){var e=function(e){var t;return function(r){return t||e(t={exports:{},parent:r},t.exports),t.exports}},t=e(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n({});Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var i=r({});Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})})}),r=e(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NFA=void 0;var r,o=(r=mn)&&r.__esModule?r:{default:r},i=n({});function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var f=function(e,t,r,n,f){var h=function(e){function t(e,r,n,i,u){var s;!function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),r.sigma.includes("")||r.sigma.push("");var f,h=new o.default,m=!0,S=!1,O=void 0;try{for(var A,_=function(){var e=A.value;e.dest.forEach(function(t){h.add(new ce.Transition(e.origin,t,e.input))})},E=n[Symbol.iterator]();!(m=(A=E.next()).done);m=!0)_()}catch(T){S=!0,O=T}finally{try{m||null==E.return||E.return()}finally{if(S)throw O}}return this,s=!(f=l(t).call(this,e,r,h,i,u))||"object"!==a(f)&&"function"!=typeof f?c(this):f,d.set(c(s),{writable:!0,value:void 0}),p.set(c(s),{writable:!0,value:void 0}),y.set(c(s),{writable:!0,value:void 0}),v.set(c(s),{writable:!0,value:void 0}),g.set(c(s),{writable:!0,value:void 0}),b.set(c(s),{writable:!0,value:void 0}),w.set(c(s),{writable:!0,value:void 0}),s}var r,n;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,i.DFA),r=t,(n=[{key:"getType",value:function(){return"NFA"}}])&&u(r.prototype,n),t}(),d=new WeakMap,p=new WeakMap,y=new WeakMap,v=new WeakMap,g=new WeakMap,b=new WeakMap,w=new WeakMap;return h}();t.NFA=f}),n=e(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DFA=void 0;var r,n=(r=mn)&&r.__esModule?r:{default:r},i=ee,a=o({});function u(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,t){var r=t.get(e);if(!r)throw new TypeError("attempted to get private field on non-instance");return r.get?r.get.call(e):r.value}function s(e,t,r){var n=t.get(e);if(!n)throw new TypeError("attempted to set private field on non-instance");if(n.set)n.set.call(e,r);else{if(!n.writable)throw new TypeError("attempted to set read only private field");n.value=r}return r}var f=function(e,t,r,o,f){var h=function(){function e(t,r,o,u,l){if(function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),d.set(this,{writable:!0,value:void 0}),p.set(this,{writable:!0,value:void 0}),y.set(this,{writable:!0,value:void 0}),v.set(this,{writable:!0,value:void 0}),g.set(this,{writable:!0,value:void 0}),b.set(this,{writable:!0,value:void 0}),w.set(this,{writable:!0,value:void 0}),m.set(this,{writable:!0,value:void 0}),s(this,m,new a.FSAUtils(this.constructor)),(0,ne.checkStateDuplicates)(t))throw new Error(i.ErrorCode.DUPLICATE_STATE_NAMES);if(s(this,d,t),s(this,p,r),s(this,b,c(this,m).createPaths(c(this,d),c(this,p))),!t.has(u))throw new Error(i.ErrorCode.START_STATE_NOT_FOUND);if(s(this,v,u),0===Object.keys(l).length&&l.constructor===Object&&(l=new n.default([])),!l.isSubsetOf(t))throw new Error(i.ErrorCode.ACCEPTS_NOT_SUBSET);s(this,g,l),s(this,y,c(this,m).validateTFunc(c(this,d),c(this,b),o,c(this,p)))}var t,r;return t=e,(r=[{key:"getStates",value:function(){return c(this,d)}},{key:"getAlphabet",value:function(){return c(this,p)}},{key:"getTFunc",value:function(){return c(this,y)}},{key:"getStartState",value:function(){return c(this,v)}},{key:"getAcceptStates",value:function(){return c(this,g)}},{key:"getType",value:function(){return"DFA"}},{key:"generateDigraph",value:function(){var e=[],t=!0,r=!1,n=void 0;try{for(var o,i=c(this,g)[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var a=o.value;e.push(a.name)}}catch(s){r=!0,n=s}finally{try{t||null==i.return||i.return()}finally{if(r)throw n}}var l=new Map;return Object.values(u(c(this,y))).map(function(e){var t=e.origin.name+e.dest.name,r=e.input;if(""===r&&(r="\u03b5"),l.has(t)){var n=(0,ne.getOrDefault)(l,t,null),o=n.split('"')[1],i=o.split(",");i.push(r),i.sort(),n=n.replace('"'+o+'"','"'+i.toString()+'"'),l.set(t,n)}else l.set(t,e.origin.name+" -> "+e.dest.name+' [ label = "'+r+'" ];')}),"digraph fsa {\n ".concat(Object.values(c(this,m).determineStateOrder(c(this,w),c(this,y),c(this,d),c(this,v),c(this,g))).map(function(t){return-1!==e.indexOf(t)?t+" [shape = doublecircle];":t}).join("\n\t"),"\n rankdir=LR;\n node [shape = point ]; qi;\n node [shape = circle];\n qi -> ").concat(c(this,v).name,";\n ").concat(Object.values(u(l)).map(function(e){var t,r,n=(r=2,function(e){if(Array.isArray(e))return e}(t=e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(s){o=!0,i=s}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}());return n[0],n[1]}).join("\n\t"),"\n }\n ")}}])&&l(t.prototype,r),e}(),d=new WeakMap,p=new WeakMap,y=new WeakMap,v=new WeakMap,g=new WeakMap,b=new WeakMap,w=new WeakMap,m=new WeakMap;return h}();t.DFA=f}),o=e(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=u({});Object.keys(r).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var n=a({});Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=i({});Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})}),i=e(function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createFSA=r.FSAUtils=void 0;var n,i=(n=Z)&&n.__esModule?n:{default:n},a=ce,u=t({}),l=o({});function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var f=function(e){function t(e,t,n){var o=[];if(-1===e.getAlphabet().sigma.indexOf(t))throw new Error(ee.ErrorCode.INVALID_INPUT_CHAR);if(n=r(e.getTFunc(),n),""===t)return new Set(n);var i=!0,a=!1,u=void 0;try{for(var l,c=function(){var r=l.value,n=Array.from(e.getTFunc()).filter(function(e){return e.origin===r&&e.input===t});o=o.concat(n)},s=n[Symbol.iterator]();!(i=(l=s.next()).done);i=!0)c()}catch(b){a=!0,u=b}finally{try{i||null==s.return||s.return()}finally{if(a)throw u}}var f=[];if(o.length>1){var h=!0,d=!1,p=void 0;try{for(var y,v=o[Symbol.iterator]();!(h=(y=v.next()).done);h=!0){var g=y.value;f.push(g.dest)}}catch(b){d=!0,p=b}finally{try{h||null==v.return||v.return()}finally{if(d)throw p}}}else{if(1!==o.length)return new Set;f.push(o[0].dest)}return new Set(r(e.getTFunc(),f))}function r(e,t){return l.NFAUtils.populateEpsilons(e,t)}return function(){function e(t){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),"_type"in this?Object.defineProperty(this,"_type",{value:void 0,enumerable:!0,configurable:!0,writable:!0}):this._type=void 0,this._type=t}var r,n;return r=e,(n=[{key:"receiveInput",value:function(e,r,n){if((0,ne.instanceOf)(u.NFA,e))return n instanceof a.State?t(e,r,[n]):t(e,r,n);if(n instanceof Array){if(n.length>1)throw console.error(i.default.redBright("State array can only contain one state for DFAs")),new Error(ee.ErrorCode.INVALID_STATE_ARRAY);n=n[0]}return function(e,t,r){if(-1===e.getAlphabet().sigma.indexOf(t))throw new Error(ee.ErrorCode.INVALID_INPUT_CHAR);if(!e.getStates().has(r))throw new Error(ee.ErrorCode.INPUT_STATE_NOT_FOUND);var n=Array.from(e.getTFunc()).find(function(e){return e.origin===r&&e.input===t});if(n)return n.dest;throw new Error(ee.ErrorCode.INVALID_TRANSITION_OBJECT)}(e,r,n)}},{key:"validateTFunc",value:function(e,t,r,n){return this._type===u.NFA?l.NFAUtils.validateTFunc(e,t,r,n):l.DFAUtils.validateTFunc(e,t,r,n)}},{key:"createPaths",value:function(e,t){return l.DFAUtils.createPaths(e,t)}},{key:"determineStateOrder",value:function(e,t,r,n,o){return l.DFAUtils.determineStateOrder(e,t,r,n,o)}}])&&s(r.prototype,n),e}()}();r.FSAUtils=f,r.createFSA=function(e,t,r,n,o){var i=new Map;if("string"==typeof e)i.set(e,new a.State(e));else{if(!Array.isArray(e))throw new TypeError(e);var u=!0,s=!1,f=void 0;try{for(var h,d=e[Symbol.iterator]();!(u=(h=d.next()).done);u=!0){var p=h.value;i.has(p)||i.set(p,new a.State(p))}}catch(I){s=!0,f=I}finally{try{u||null==d.return||d.return()}finally{if(s)throw f}}}var y=new a.Alphabet(t);if("string"!=typeof n)throw new TypeError(n);var v=(0,ne.getOrDefault)(i,n,null),g=new Set;if("string"==typeof o)i.has(o)&&g.add((0,ne.getOrDefault)(i,o,null));else{if(!Array.isArray(o))throw new TypeError(o);var b=!0,w=!1,m=void 0;try{for(var S,O=o[Symbol.iterator]();!(b=(S=O.next()).done);b=!0){var A=S.value;g.add((0,ne.getOrDefault)(i,A,null))}}catch(I){w=!0,m=I}finally{try{b||null==O.return||O.return()}finally{if(w)throw m}}}if(Array.isArray(r)||"object"!==c(r)||(r=[r]),Array.isArray(r)){var _=!0,E=!1,T=void 0;try{for(var j,k=r[Symbol.iterator]();!(_=(j=k.next()).done);_=!0){var M=j.value;if(-1!=M.to.indexOf(",")||""===M.input)return(0,l.createNFA)(i,y,r,v,g)}}catch(I){E=!0,T=I}finally{try{_||null==k.return||k.return()}finally{if(E)throw T}}return(0,l.createDFA)(i,y,r,v,g)}throw new TypeError(r)}}),a=e(function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createNFA=r.NFAUtils=void 0;var n,o=(n=Z)&&n.__esModule?n:{default:n},i=u({}),a=t({});function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var h=function(e){function t(){return function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),e=this,!(r=s(t).apply(this,arguments))||"object"!==l(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):r;var e,r}var r,n;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)}(t,i.DFAUtils),r=t,n=[{key:"isValidInputChar",value:function(e,t){return-1!==t.sigma.indexOf(e)||""===e}},{key:"populateEpsilons",value:function(e,t){for(var r=!0;r;){r=!1;var n=Array.from(e).filter(function(e){return t.includes(e.origin)&&""===e.input}),o=!0,i=!1,a=void 0;try{for(var u,l=n[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c=u.value;t.includes(c.dest)||(t.push(c.dest),r=!0)}}catch(s){i=!0,a=s}finally{try{o||null==l.return||l.return()}finally{if(i)throw a}}}return t}},{key:"validateTFunc",value:function(e,t,r,n){var i=new Set,a=!0,u=!1,l=void 0;try{for(var c,s=r[Symbol.iterator]();!(a=(c=s.next()).done);a=!0){var f=c.value,h=!1;if(!e.has(f.origin))throw console.error(o.default.redBright("Origin state was invalid: %o"),JSON.stringify(f.origin)),new Error(ee.ErrorCode.ORIGIN_STATE_NOT_FOUND);if(!e.has(f.dest))throw console.error(o.default.redBright("Dest state was invalid: %o"),JSON.stringify(f.dest)),new Error(ee.ErrorCode.DEST_STATE_NOT_FOUND);(0,ne.getOrDefault)(t,f.origin,new Set);var d=!0,p=!1,y=void 0;try{for(var v,g=i[Symbol.iterator]();!(d=(v=g.next()).done);d=!0){var b=v.value;b.origin===f.origin&&b.dest===f.dest&&b.input===f.input&&(h=!0)}}catch(w){p=!0,y=w}finally{try{d||null==g.return||g.return()}finally{if(p)throw y}}if(!h&&t.has(f.origin)){if(!this.isValidInputChar(f.input,n))throw new Error(ee.ErrorCode.INVALID_INPUT_CHAR);i.add(f)}}}catch(w){u=!0,l=w}finally{try{a||null==s.return||s.return()}finally{if(u)throw l}}return i}}],null&&c(r.prototype,null),n&&c(r,n),t}();r.NFAUtils=h,r.createNFA=function(e,t,r,n,o){var i=new Set,u=!0,l=!1,c=void 0;try{for(var s,f=function(){var t=s.value;if(!t.from||!t.to||!t.input&&""!==t.input)throw new Error(ee.ErrorCode.INVALID_TRANSITION_OBJECT);var r=(0,ne.getOrDefault)(e,t.from,null),n=t.to.split(","),o=[];n.forEach(function(t){o.push((0,ne.getOrDefault)(e,t,null))}),i.add(new ce.NFATransition(r,o,t.input))},h=r[Symbol.iterator]();!(u=(s=h.next()).done);u=!0)f()}catch(d){l=!0,c=d}finally{try{u||null==h.return||h.return()}finally{if(l)throw c}}return new a.NFA(new Set(e.values()),t,i,n,o)}}),u=e(function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createDFA=r.DFAUtils=void 0;var n,o=(n=Z)&&n.__esModule?n:{default:n},i=t({});function a(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var l=function(){function e(){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this)}var t,r;return t=e,r=[{key:"validateTFunc",value:function(e,t,r,n){var i,u,l=new Set,c=!0,s=!1,f=void 0;try{for(var h,d=r[Symbol.iterator]();!(c=(h=d.next()).done);c=!0){var p=h.value;if(!e.has(p.origin))throw console.error(o.default.redBright("Origin state was invalid: %o"),JSON.stringify(p.origin)),new Error(ee.ErrorCode.ORIGIN_STATE_NOT_FOUND);if(!e.has(p.dest))throw console.error(o.default.redBright("Dest state was invalid: %o"),JSON.stringify(p.dest)),new Error(ee.ErrorCode.DEST_STATE_NOT_FOUND);var y=(0,ne.getOrDefault)(t,p.origin,new Set);if(!this.isValidInputChar(p.input,n))throw new Error(ee.ErrorCode.INVALID_INPUT_CHAR);if(!t.has(p.origin)||!y.has(p.input))throw new Error(ee.ErrorCode.DUPLICATE_TRANSITION_OBJECT);l.add(p),y.delete(p.input),0===y.size&&t.delete(p.origin)}}catch(_){s=!0,f=_}finally{try{c||null==d.return||d.return()}finally{if(s)throw f}}if(t.size>0){console.error(o.default.redBright("Not all FSA paths have a transition specified:"));var v=!0,g=!1,b=void 0;try{for(var w,m=t[Symbol.iterator]();!(v=(w=m.next()).done);v=!0){var S=(i=w.value,u=2,function(e){if(Array.isArray(e))return e}(i)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(_){o=!0,i=_}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}}(i,u)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()),O=S[0],A=S[1];console.error(o.default.redBright("State %s on input(s): %s"),O.name,a(A).join(" "))}}catch(_){g=!0,b=_}finally{try{v||null==m.return||m.return()}finally{if(g)throw b}}throw new Error(ee.ErrorCode.MISSING_REQUIRED_TRANSITION)}return l}},{key:"createPaths",value:function(e,t){var r=new Map,n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var l=a.value,c=!0,s=!1,f=void 0;try{for(var h,d=t.sigma[Symbol.iterator]();!(c=(h=d.next()).done);c=!0){var p=h.value,y=(0,ne.getOrDefault)(r,l,new Set);r.has(l)?y.add(p):r.set(l,new Set([p]))}}catch(v){s=!0,f=v}finally{try{c||null==d.return||d.return()}finally{if(s)throw f}}}}catch(v){o=!0,i=v}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}},{key:"determineStateOrder",value:function(e,t,r,n,i){var u=[];e=new Map;var l=!0,c=!1,s=void 0;try{for(var f,h=t[Symbol.iterator]();!(l=(f=h.next()).done);l=!0){var d=f.value,p=(0,ne.getOrDefault)(e,d.origin.name,new Set);e.has(d.origin.name)?p.add(d.dest.name):e.set(d.origin.name,new Set([d.dest.name]))}}catch(g){c=!0,s=g}finally{try{l||null==h.return||h.return()}finally{if(c)throw s}}this.parseLinks(u,n.name,e);var y=[];Object.values(a(r)).map(function(e){return y.push(e.name)});var v=y.filter(function(e){return!u.includes(e)});return v.length>0&&(console.warn(o.default.yellowBright("Dead states detected, removing them and associated transitions: %O"),v),this.removeDeadStates(v,r,i,t)),u}},{key:"removeDeadStates",value:function(e,t,r,n){var o=!0,i=!1,a=void 0;try{for(var u,l=t[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c=u.value;-1!==e.indexOf(c.name)&&t.delete(c)}}catch(O){i=!0,a=O}finally{try{o||null==l.return||l.return()}finally{if(i)throw a}}var s=!0,f=!1,h=void 0;try{for(var d,p=r[Symbol.iterator]();!(s=(d=p.next()).done);s=!0){var y=d.value;-1!==e.indexOf(y.name)&&r.delete(y)}}catch(O){f=!0,h=O}finally{try{s||null==p.return||p.return()}finally{if(f)throw h}}var v=!0,g=!1,b=void 0;try{for(var w,m=n[Symbol.iterator]();!(v=(w=m.next()).done);v=!0){var S=w.value;-1===e.indexOf(S.origin.name)&&-1===e.indexOf(S.dest.name)||n.delete(S)}}catch(O){g=!0,b=O}finally{try{v||null==m.return||m.return()}finally{if(g)throw b}}}},{key:"parseLinks",value:function(e,t,r){e.push(t);var n=(0,ne.getOrDefault)(r,t,""),o=!0,i=!1,a=void 0;try{for(var u,l=n[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c=u.value;-1===e.indexOf(c)&&this.parseLinks(e,c,r)}}catch(s){i=!0,a=s}finally{try{o||null==l.return||l.return()}finally{if(i)throw a}}}},{key:"isValidInputChar",value:function(e,t){return""!==e&&-1!==t.sigma.indexOf(e)}}],null&&u(t.prototype,null),r&&u(t,r),e}();r.DFAUtils=l,r.createDFA=function(e,t,r,n,o){var a=new Set,u=!0,l=!1,c=void 0;try{for(var s,f=r[Symbol.iterator]();!(u=(s=f.next()).done);u=!0){var h=s.value;if(!h.from||!h.to||!h.input)throw new Error(ee.ErrorCode.INVALID_TRANSITION_OBJECT);var d=(0,ne.getOrDefault)(e,h.from,null),p=(0,ne.getOrDefault)(e,h.to,null);a.add(new ce.Transition(d,p,h.input))}}catch(y){l=!0,c=y}finally{try{u||null==f.return||f.return()}finally{if(l)throw c}}return new i.DFA(new Set(e.values()),t,a,n,o)}}),l=/[|\\{}()[\]^$+*?.]/g,c=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(l,"\\$&")},s={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},f={},h={};for(var d in s)s.hasOwnProperty(d)&&(h[s[d]]=d);var p=f={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var y in p)if(p.hasOwnProperty(y)){if(!("channels"in p[y]))throw new Error("missing channels property: "+y);if(!("labels"in p[y]))throw new Error("missing channel labels property: "+y);if(p[y].labels.length!==p[y].channels)throw new Error("channel and label counts mismatch: "+y);var v=p[y].channels,g=p[y].labels;delete p[y].channels,delete p[y].labels,Object.defineProperty(p[y],"channels",{value:v}),Object.defineProperty(p[y],"labels",{value:g})}function b(e,t){return function(r){return t(e(r))}}function w(e,t){for(var r=[t[e].parent,e],n=f[t[e].parent][e],o=t[e].parent;t[o].parent;)r.unshift(t[o].parent),n=b(f[t[o].parent][o],n),o=t[o].parent;return n.conversion=r,n}p.rgb.hsl=function(e){var t,r,n=e[0]/255,o=e[1]/255,i=e[2]/255,a=Math.min(n,o,i),u=Math.max(n,o,i),l=u-a;return u===a?t=0:n===u?t=(o-i)/l:o===u?t=2+(i-n)/l:i===u&&(t=4+(n-o)/l),(t=Math.min(60*t,360))<0&&(t+=360),r=(a+u)/2,[t,100*(u===a?0:r<=.5?l/(u+a):l/(2-u-a)),100*r]},p.rgb.hsv=function(e){var t,r,n,o,i,a=e[0]/255,u=e[1]/255,l=e[2]/255,c=Math.max(a,u,l),s=c-Math.min(a,u,l),f=function(e){return(c-e)/6/s+.5};return 0===s?o=i=0:(i=s/c,t=f(a),r=f(u),n=f(l),a===c?o=n-r:u===c?o=1/3+t-n:l===c&&(o=2/3+r-t),o<0?o+=1:o>1&&(o-=1)),[360*o,100*i,100*c]},p.rgb.hwb=function(e){var t=e[0],r=e[1],n=e[2];return[p.rgb.hsl(e)[0],1/255*Math.min(t,Math.min(r,n))*100,100*(n=1-1/255*Math.max(t,Math.max(r,n)))]},p.rgb.cmyk=function(e){var t,r=e[0]/255,n=e[1]/255,o=e[2]/255;return[100*((1-r-(t=Math.min(1-r,1-n,1-o)))/(1-t)||0),100*((1-n-t)/(1-t)||0),100*((1-o-t)/(1-t)||0),100*t]},p.rgb.keyword=function(e){var t=h[e];if(t)return t;var r,n,o,i=1/0;for(var a in s)if(s.hasOwnProperty(a)){var u=(n=e,o=s[a],Math.pow(n[0]-o[0],2)+Math.pow(n[1]-o[1],2)+Math.pow(n[2]-o[2],2));u<i&&(i=u,r=a)}return r},p.keyword.rgb=function(e){return s[e]},p.rgb.xyz=function(e){var t=e[0]/255,r=e[1]/255,n=e[2]/255;return[100*(.4124*(t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92)+.3576*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)+.1805*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)),100*(.2126*t+.7152*r+.0722*n),100*(.0193*t+.1192*r+.9505*n)]},p.rgb.lab=function(e){var t=p.rgb.xyz(e),r=t[0],n=t[1],o=t[2];return n/=100,o/=108.883,r=(r/=95.047)>.008856?Math.pow(r,1/3):7.787*r+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(r-n),200*(n-(o=o>.008856?Math.pow(o,1/3):7.787*o+16/116))]},p.hsl.rgb=function(e){var t,r,n,o,i,a=e[0]/360,u=e[1]/100,l=e[2]/100;if(0===u)return[i=255*l,i,i];t=2*l-(r=l<.5?l*(1+u):l+u-l*u),o=[0,0,0];for(var c=0;c<3;c++)(n=a+1/3*-(c-1))<0&&n++,n>1&&n--,i=6*n<1?t+6*(r-t)*n:2*n<1?r:3*n<2?t+(r-t)*(2/3-n)*6:t,o[c]=255*i;return o},p.hsl.hsv=function(e){var t=e[0],r=e[1]/100,n=e[2]/100,o=r,i=Math.max(n,.01);return r*=(n*=2)<=1?n:2-n,o*=i<=1?i:2-i,[t,100*(0===n?2*o/(i+o):2*r/(n+r)),(n+r)/2*100]},p.hsv.rgb=function(e){var t=e[0]/60,r=e[1]/100,n=e[2]/100,o=Math.floor(t)%6,i=t-Math.floor(t),a=255*n*(1-r),u=255*n*(1-r*i),l=255*n*(1-r*(1-i));switch(n*=255,o){case 0:return[n,l,a];case 1:return[u,n,a];case 2:return[a,n,l];case 3:return[a,u,n];case 4:return[l,a,n];case 5:return[n,a,u]}},p.hsv.hsl=function(e){var t,r,n,o=e[0],i=e[1]/100,a=e[2]/100,u=Math.max(a,.01);return n=(2-i)*a,r=i*u,[o,100*(r=(r/=(t=(2-i)*u)<=1?t:2-t)||0),100*(n/=2)]},p.hwb.rgb=function(e){var t,r,n,o,i,a,u,l=e[0]/360,c=e[1]/100,s=e[2]/100,f=c+s;switch(f>1&&(c/=f,s/=f),n=6*l-(t=Math.floor(6*l)),0!=(1&t)&&(n=1-n),o=c+n*((r=1-s)-c),t){default:case 6:case 0:i=r,a=o,u=c;break;case 1:i=o,a=r,u=c;break;case 2:i=c,a=r,u=o;break;case 3:i=c,a=o,u=r;break;case 4:i=o,a=c,u=r;break;case 5:i=r,a=c,u=o}return[255*i,255*a,255*u]},p.cmyk.rgb=function(e){var t=e[0]/100,r=e[1]/100,n=e[2]/100,o=e[3]/100;return[255*(1-Math.min(1,t*(1-o)+o)),255*(1-Math.min(1,r*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o))]},p.xyz.rgb=function(e){var t,r,n,o=e[0]/100,i=e[1]/100,a=e[2]/100;return r=-.9689*o+1.8758*i+.0415*a,n=.0557*o+-.204*i+1.057*a,t=(t=3.2406*o+-1.5372*i+-.4986*a)>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,[255*(t=Math.min(Math.max(0,t),1)),255*(r=Math.min(Math.max(0,r),1)),255*(n=Math.min(Math.max(0,n),1))]},p.xyz.lab=function(e){var t=e[0],r=e[1],n=e[2];return r/=100,n/=108.883,t=(t/=95.047)>.008856?Math.pow(t,1/3):7.787*t+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(t-r),200*(r-(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116))]},p.lab.xyz=function(e){var t,r,n,o=e[0];t=e[1]/500+(r=(o+16)/116),n=r-e[2]/200;var i=Math.pow(r,3),a=Math.pow(t,3),u=Math.pow(n,3);return r=i>.008856?i:(r-16/116)/7.787,t=a>.008856?a:(t-16/116)/7.787,n=u>.008856?u:(n-16/116)/7.787,[t*=95.047,r*=100,n*=108.883]},p.lab.lch=function(e){var t,r=e[0],n=e[1],o=e[2];return(t=360*Math.atan2(o,n)/2/Math.PI)<0&&(t+=360),[r,Math.sqrt(n*n+o*o),t]},p.lch.lab=function(e){var t,r=e[0],n=e[1];return t=e[2]/360*2*Math.PI,[r,n*Math.cos(t),n*Math.sin(t)]},p.rgb.ansi16=function(e){var t=e[0],r=e[1],n=e[2],o=1 in arguments?arguments[1]:p.rgb.hsv(e)[2];if(0===(o=Math.round(o/50)))return 30;var i=30+(Math.round(n/255)<<2|Math.round(r/255)<<1|Math.round(t/255));return 2===o&&(i+=60),i},p.hsv.ansi16=function(e){return p.rgb.ansi16(p.hsv.rgb(e),e[2])},p.rgb.ansi256=function(e){var t=e[0],r=e[1],n=e[2];return t===r&&r===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},p.ansi16.rgb=function(e){var t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),[t=t/10.5*255,t,t];var r=.5*(1+~~(e>50));return[(1&t)*r*255,(t>>1&1)*r*255,(t>>2&1)*r*255]},p.ansi256.rgb=function(e){if(e>=232){var t=10*(e-232)+8;return[t,t,t]}var r;return e-=16,[Math.floor(e/36)/5*255,Math.floor((r=e%36)/6)/5*255,r%6/5*255]},p.rgb.hex=function(e){var t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},p.hex.rgb=function(e){var t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];var r=t[0];3===t[0].length&&(r=r.split("").map(function(e){return e+e}).join(""));var n=parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},p.rgb.hcg=function(e){var t,r=e[0]/255,n=e[1]/255,o=e[2]/255,i=Math.max(Math.max(r,n),o),a=Math.min(Math.min(r,n),o),u=i-a;return t=u<=0?0:i===r?(n-o)/u%6:i===n?2+(o-r)/u:4+(r-n)/u+4,t/=6,[360*(t%=1),100*u,100*(u<1?a/(1-u):0)]},p.hsl.hcg=function(e){var t,r=e[1]/100,n=e[2]/100,o=0;return(t=n<.5?2*r*n:2*r*(1-n))<1&&(o=(n-.5*t)/(1-t)),[e[0],100*t,100*o]},p.hsv.hcg=function(e){var t=e[1]/100,r=e[2]/100,n=t*r,o=0;return n<1&&(o=(r-n)/(1-n)),[e[0],100*n,100*o]},p.hcg.rgb=function(e){var t=e[0]/360,r=e[1]/100,n=e[2]/100;if(0===r)return[255*n,255*n,255*n];var o,i=[0,0,0],a=t%1*6,u=a%1,l=1-u;switch(Math.floor(a)){case 0:i[0]=1,i[1]=u,i[2]=0;break;case 1:i[0]=l,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=u;break;case 3:i[0]=0,i[1]=l,i[2]=1;break;case 4:i[0]=u,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=l}return o=(1-r)*n,[255*(r*i[0]+o),255*(r*i[1]+o),255*(r*i[2]+o)]},p.hcg.hsv=function(e){var t=e[1]/100,r=t+e[2]/100*(1-t),n=0;return r>0&&(n=t/r),[e[0],100*n,100*r]},p.hcg.hsl=function(e){var t=e[1]/100,r=e[2]/100*(1-t)+.5*t,n=0;return r>0&&r<.5?n=t/(2*r):r>=.5&&r<1&&(n=t/(2*(1-r))),[e[0],100*n,100*r]},p.hcg.hwb=function(e){var t=e[1]/100,r=t+e[2]/100*(1-t);return[e[0],100*(r-t),100*(1-r)]},p.hwb.hcg=function(e){var t=e[1]/100,r=1-e[2]/100,n=r-t,o=0;return n<1&&(o=(r-n)/(1-n)),[e[0],100*n,100*o]},p.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},p.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},p.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},p.gray.hsl=p.gray.hsv=function(e){return[0,0,e[0]]},p.gray.hwb=function(e){return[0,100,e[0]]},p.gray.cmyk=function(e){return[0,0,0,e[0]]},p.gray.lab=function(e){return[e[0],0,0]},p.gray.hex=function(e){var t=255&Math.round(e[0]/100*255),r=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(r.length)+r},p.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};var m,S=function(e){for(var t=function(e){var t=function(){for(var e={},t=Object.keys(f),r=t.length,n=0;n<r;n++)e[t[n]]={distance:-1,parent:null};return e}(),r=[e];for(t[e].distance=0;r.length;)for(var n=r.pop(),o=Object.keys(f[n]),i=o.length,a=0;a<i;a++){var u=o[a],l=t[u];-1===l.distance&&(l.distance=t[n].distance+1,l.parent=n,r.unshift(u))}return t}(e),r={},n=Object.keys(t),o=n.length,i=0;i<o;i++){var a=n[i];null!==t[a].parent&&(r[a]=w(a,t))}return r},O={};Object.keys(f).forEach(function(e){O[e]={},Object.defineProperty(O[e],"channels",{value:f[e].channels}),Object.defineProperty(O[e],"labels",{value:f[e].labels});var t=S(e);Object.keys(t).forEach(function(r){var n=t[r];O[e][r]=function(e){var t=function(t){if(null==t)return t;arguments.length>1&&(t=Array.prototype.slice.call(arguments));var r=e(t);if("object"==typeof r)for(var n=r.length,o=0;o<n;o++)r[o]=Math.round(r[o]);return r};return"conversion"in e&&(t.conversion=e.conversion),t}(n),O[e][r].raw=function(e){var t=function(t){return null==t?t:(arguments.length>1&&(t=Array.prototype.slice.call(arguments)),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(n)})}),m=O;var A={exports:{}};const _=(e,t)=>(function(){return`\x1b[${e.apply(m,arguments)+t}m`}),E=(e,t)=>(function(){const r=e.apply(m,arguments);return`\x1b[${38+t};5;${r}m`}),T=(e,t)=>(function(){const r=e.apply(m,arguments);return`\x1b[${38+t};2;${r[0]};${r[1]};${r[2]}m`});Object.defineProperty(A,"exports",{enumerable:!0,get:function(){const e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.grey=t.color.gray;for(const o of Object.keys(t)){const r=t[o];for(const n of Object.keys(r)){const o=r[n];t[n]={open:`\x1b[${o[0]}m`,close:`\x1b[${o[1]}m`},r[n]=t[n],e.set(o[0],o[1])}Object.defineProperty(t,o,{value:r,enumerable:!1}),Object.defineProperty(t,"codes",{value:e,enumerable:!1})}const r=e=>e,n=(e,t,r)=>[e,t,r];t.color.close="\x1b[39m",t.bgColor.close="\x1b[49m",t.color.ansi={ansi:_(r,0)},t.color.ansi256={ansi256:E(r,0)},t.color.ansi16m={rgb:T(n,0)},t.bgColor.ansi={ansi:_(r,10)},t.bgColor.ansi256={ansi256:E(r,10)},t.bgColor.ansi16m={rgb:T(n,10)};for(let o of Object.keys(m)){if("object"!=typeof m[o])continue;const e=m[o];"ansi16"===o&&(o="ansi"),"ansi16"in e&&(t.color.ansi[o]=_(e.ansi16,0),t.bgColor.ansi[o]=_(e.ansi16,10)),"ansi256"in e&&(t.color.ansi256[o]=E(e.ansi256,0),t.bgColor.ansi256[o]=E(e.ansi256,10)),"rgb"in e&&(t.color.ansi16m[o]=T(e.rgb,0),t.bgColor.ansi16m[o]=T(e.rgb,10))}return t}}),A=A.exports;var j=!1;const k=/(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,M=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,I=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,x=/\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi,P=new Map([["n","\n"],["r","\r"],["t","\t"],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e","\x1b"],["a","\x07"]]);function N(e){return"u"===e[0]&&5===e.length||"x"===e[0]&&3===e.length?String.fromCharCode(parseInt(e.slice(1),16)):P.get(e)||e}function C(e,t){const r=[],n=t.trim().split(/\s*,\s*/g);let o;for(const i of n)if(isNaN(i)){if(!(o=i.match(I)))throw new Error(`Invalid Chalk template style argument: ${i} (in style '${e}')`);r.push(o[2].replace(x,(e,t,r)=>t?N(t):r))}else r.push(Number(i));return r}function F(e){M.lastIndex=0;const t=[];let r;for(;null!==(r=M.exec(e));){const e=r[1];if(r[2]){const n=C(e,r[2]);t.push([e].concat(n))}else t.push([e])}return t}function D(e,t){const r={};for(const o of t)for(const e of o.styles)r[e[0]]=o.inverse?null:e.slice(1);let n=e;for(const o of Object.keys(r))if(Array.isArray(r[o])){if(!(o in n))throw new Error(`Unknown Chalk style: ${o}`);n=r[o].length>0?n[o].apply(n,r[o]):n[o]}return n}var L,R,U,B=(e,t)=>{const r=[],n=[];let o=[];if(t.replace(k,(t,i,a,u,l,c)=>{if(i)o.push(N(i));else if(u){const t=o.join("");o=[],n.push(0===r.length?t:D(e,r)(t)),r.push({inverse:a,styles:F(u)})}else if(l){if(0===r.length)throw new Error("Found extraneous } in Chalk template literal");n.push(D(e,r)(o.join(""))),o=[],r.pop()}else o.push(c)}),n.push(o.join("")),r.length>0){const e=`Chalk template literal is missing ${r.length} closing bracket${1===r.length?"":"s"} (\`}\`)`;throw new Error(e)}return n.join("")},V=L={};function z(){throw new Error("setTimeout has not been defined")}function G(){throw new Error("clearTimeout has not been defined")}function W(e){if(R===setTimeout)return setTimeout(e,0);if((R===z||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}!function(){try{R="function"==typeof setTimeout?setTimeout:z}catch(e){R=z}try{U="function"==typeof clearTimeout?clearTimeout:G}catch(e){U=G}}();var $,J=[],q=!1,H=-1;function Y(){q&&$&&(q=!1,$.length?J=$.concat(J):H=-1,J.length&&Q())}function Q(){if(!q){var e=W(Y);q=!0;for(var t=J.length;t;){for($=J,J=[];++H<t;)$&&$[H].run();H=-1,t=J.length}$=null,q=!1,function(e){if(U===clearTimeout)return clearTimeout(e);if((U===G||!U)&&clearTimeout)return U=clearTimeout,clearTimeout(e);try{U(e)}catch(t){try{return U.call(null,e)}catch(t){return U.call(this,e)}}}(e)}}function K(e,t){this.fun=e,this.array=t}function X(){}V.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];J.push(new K(e,t)),1!==J.length||q||W(Q)},K.prototype.run=function(){this.fun.apply(null,this.array)},V.title="browser",V.browser=!0,V.env={},V.argv=[],V.version="",V.versions={},V.on=X,V.addListener=X,V.once=X,V.off=X,V.removeListener=X,V.removeAllListeners=X,V.emit=X,V.prependListener=X,V.prependOnceListener=X,V.listeners=function(e){return[]},V.binding=function(e){throw new Error("process.binding is not supported")},V.cwd=function(){return"/"},V.chdir=function(e){throw new Error("process.chdir is not supported")},V.umask=function(){return 0};var Z={};(function(e){"use strict";const t=j,r="win32"===e.platform&&!"xterm".toLowerCase().startsWith("xterm"),n=["ansi","ansi","ansi256","ansi16m"],o=new Set(["gray"]),i=Object.create(null);function a(e,r){r=r||{};const n=t?t.level:0;e.level=void 0===r.level?n:r.level,e.enabled="enabled"in r?r.enabled:e.level>0}function u(e){if(!this||!(this instanceof u)||this.template){const t={};return a(t,e),t.template=function(){const e=[].slice.call(arguments);return function(e,t){if(!Array.isArray(t))return[].slice.call(arguments,1).join(" ");const r=[].slice.call(arguments,2),n=[t.raw[0]];for(let o=1;o<t.length;o++)n.push(String(r[o-1]).replace(/[{}\\]/g,"\\$&")),n.push(String(t.raw[o]));return B(e,n.join(""))}.apply(null,[t.template].concat(e))},Object.setPrototypeOf(t,u.prototype),Object.setPrototypeOf(t.template,t),t.template.constructor=u,t.template}a(this,e)}r&&(A.blue.open="\x1b[94m");for(const f of Object.keys(A))A[f].closeRe=new RegExp(c(A[f].close),"g"),i[f]={get(){const e=A[f];return s.call(this,this._styles?this._styles.concat(e):[e],this._empty,f)}};i.visible={get(){return s.call(this,this._styles||[],!0,"visible")}},A.color.closeRe=new RegExp(c(A.color.close),"g");for(const c of Object.keys(A.color.ansi))o.has(c)||(i[c]={get(){const e=this.level;return function(){const t={open:A.color[n[e]][c].apply(null,arguments),close:A.color.close,closeRe:A.color.closeRe};return s.call(this,this._styles?this._styles.concat(t):[t],this._empty,c)}}});A.bgColor.closeRe=new RegExp(c(A.bgColor.close),"g");for(const c of Object.keys(A.bgColor.ansi))o.has(c)||(i["bg"+c[0].toUpperCase()+c.slice(1)]={get(){const e=this.level;return function(){const t={open:A.bgColor[n[e]][c].apply(null,arguments),close:A.bgColor.close,closeRe:A.bgColor.closeRe};return s.call(this,this._styles?this._styles.concat(t):[t],this._empty,c)}}});const l=Object.defineProperties(()=>{},i);function s(e,t,n){const o=function(){return function(){const e=arguments,t=e.length;let n=String(arguments[0]);if(0===t)return"";if(t>1)for(let r=1;r<t;r++)n+=" "+e[r];if(!this.enabled||this.level<=0||!n)return this._empty?"":n;const o=A.dim.open;r&&this.hasGrey&&(A.dim.open="");for(const r of this._styles.slice().reverse())n=(n=r.open+n.replace(r.closeRe,r.open)+r.close).replace(/\r?\n/g,`${r.close}$&${r.open}`);return A.dim.open=o,n}.apply(o,arguments)};o._styles=e,o._empty=t;const i=this;return Object.defineProperty(o,"level",{enumerable:!0,get:()=>i.level,set(e){i.level=e}}),Object.defineProperty(o,"enabled",{enumerable:!0,get:()=>i.enabled,set(e){i.enabled=e}}),o.hasGrey=this.hasGrey||"gray"===n||"grey"===n,o.__proto__=l,o}Object.defineProperties(u.prototype,i),(Z=u()).supportsColor=t,Z.default=Z}).call(this,L);var ee={};Object.defineProperty(ee,"__esModule",{value:!0}),ee.ErrorCode=void 0;var te=Object.freeze({DUPLICATE_ALPHABET_VALS:"E-001",DUPLICATE_STATE_NAMES:"E-002",INVALID_STATE_NAME:"E-003",START_STATE_NOT_FOUND:"E-004",ACCEPTS_NOT_SUBSET:"E-005",ORIGIN_STATE_NOT_FOUND:"E-006",DEST_STATE_NOT_FOUND:"E-007",MISSING_REQUIRED_TRANSITION:"E-008",INVALID_INPUT_CHAR:"E-009",INPUT_STATE_NOT_FOUND:"E-010",INVALID_TRANSITION_OBJECT:"E-011",DUPLICATE_TRANSITION_OBJECT:"E-012",INVALID_STATE_ARRAY:"E-013"});ee.ErrorCode=te;var re={};Object.defineProperty(re,"__esModule",{value:!0}),re.State=void 0,re.State=function e(t){if(function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),void 0,"name"in this?Object.defineProperty(this,"name",{value:void 0,enumerable:!0,configurable:!0,writable:!0}):this.name=void 0,this.name=t,!this.name)throw new Error(ee.ErrorCode.INVALID_STATE_NAME)};var ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.instanceOf=ne.getOrDefault=ne.checkStateDuplicates=ne.duplicates=ne.count=void 0,ne.count=function(e){return e.reduce(function(e,t){return Object.assign(e,(r={},n=t,o=(e[t]||0)+1,n in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,r));var r,n,o},{})},ne.duplicates=function(e){return Object.keys(e).filter(function(t){return e[t]>1})},ne.checkStateDuplicates=function(e){var t=new Set,r=!0,n=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(r=(i=a.next()).done);r=!0){var u=i.value;if(t.has(u.name))return!0;t.add(u.name)}}catch(l){n=!0,o=l}finally{try{r||null==a.return||a.return()}finally{if(n)throw o}}return!1},ne.getOrDefault=function(e,t,r){var n=e.get(t);return null==n?r:n},ne.instanceOf=function(e,t){return t instanceof e||e.name&&e.name===t.constructor.name};var oe={};Object.defineProperty(oe,"__esModule",{value:!0}),oe.Alphabet=void 0,oe.Alphabet=function e(t){var r;if(function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),void 0,"sigma"in this?Object.defineProperty(this,"sigma",{value:void 0,enumerable:!0,configurable:!0,writable:!0}):this.sigma=void 0,!Array.isArray(t)){if("string"!=typeof t)throw new TypeError;t=function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(r=t)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}if(this.sigma=t,(0,ne.duplicates)((0,ne.count)(this.sigma)).length>0)throw new Error(ee.ErrorCode.DUPLICATE_ALPHABET_VALS)};var ie={};function ae(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(ie,"__esModule",{value:!0}),ie.NFATransition=void 0,ie.NFATransition=function e(t,r,n){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),ae(this,"origin",void 0),ae(this,"dest",void 0),ae(this,"input",void 0),this.origin=t,this.dest=r,this.input=n};var ue={};function le(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(ue,"__esModule",{value:!0}),ue.Transition=void 0,ue.Transition=function e(t,r,n){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),le(this,"origin",void 0),le(this,"dest",void 0),le(this,"input",void 0),this.origin=t,this.dest=r,this.input=n};var ce={};Object.defineProperty(ce,"__esModule",{value:!0}),Object.keys(oe).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(ce,e,{enumerable:!0,get:function(){return oe[e]}})}),Object.keys(ie).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(ce,e,{enumerable:!0,get:function(){return ie[e]}})}),Object.keys(re).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(ce,e,{enumerable:!0,get:function(){return re[e]}})}),Object.keys(ue).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(ce,e,{enumerable:!0,get:function(){return ue[e]}})});var se={};(function(e){var t="object",r=function(e){return e&&e.Math==Math&&e};se=r(typeof globalThis==t&&globalThis)||r(typeof window==t&&window)||r(typeof self==t&&self)||r(typeof e==t&&e)||Function("return this")()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var fe=function(e){try{return!!e()}catch(t){return!0}},he=!fe(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),de={},pe={}.propertyIsEnumerable,ye=Object.getOwnPropertyDescriptor,ve=(ye&&pe.call({1:2},1),function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}),ge={}.toString,be=function(e){return ge.call(e).slice(8,-1)},we="".split,me=fe(function(){return!Object("z").propertyIsEnumerable(0)})?function(e){return"String"==be(e)?we.call(e,""):Object(e)}:Object,Se=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},Oe=function(e){return me(Se(e))},Ae=function(e){return"object"==typeof e?null!==e:"function"==typeof e},_e=function(e,t){if(!Ae(e))return e;var r,n;if(t&&"function"==typeof(r=e.toString)&&!Ae(n=r.call(e)))return n;if("function"==typeof(r=e.valueOf)&&!Ae(n=r.call(e)))return n;if(!t&&"function"==typeof(r=e.toString)&&!Ae(n=r.call(e)))return n;throw TypeError("Can't convert object to primitive value")},Ee={}.hasOwnProperty,Te=function(e,t){return Ee.call(e,t)},je=se.document,ke=Ae(je)&&Ae(je.createElement),Me=function(e){return ke?je.createElement(e):{}},Ie=!he&&!fe(function(){return 7!=Object.defineProperty(Me("div"),"a",{get:function(){return 7}}).a}),xe={},Pe=Object.getOwnPropertyDescriptor;xe.f=he?Pe:function(e,t){if(e=Oe(e),t=_e(t,!0),Ie)try{return Pe(e,t)}catch(r){}if(Te(e,t))return ve(!de.f.call(e,t),e[t])};var Ne=function(e){if(!Ae(e))throw TypeError(String(e)+" is not an object");return e},Ce={},Fe=Object.defineProperty;Ce.f=he?Fe:function(e,t,r){if(Ne(e),t=_e(t,!0),Ne(r),Ie)try{return Fe(e,t,r)}catch(n){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var De,Le=he?function(e,t,r){return Ce.f(e,t,ve(1,r))}:function(e,t,r){return e[t]=r,e},Re=function(e,t){try{Le(se,e,t)}catch(r){se[e]=t}return t},Ue=se["__core-js_shared__"]||Re("__core-js_shared__",{});(De=function(e,t){return Ue[e]||(Ue[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.2.1",mode:"global",copyright:"\xa9 2019 Denis Pushkarev (zloirock.ru)"});var Be,Ve,ze,Ge=De("native-function-to-string",Function.toString),We=se.WeakMap,$e="function"==typeof We&&/native code/.test(Ge.call(We)),Je=0,qe=Math.random(),He=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++Je+qe).toString(36)},Ye=De("keys"),Qe=function(e){return Ye[e]||(Ye[e]=He(e))},Ke={},Xe=se.WeakMap;if($e){var Ze=new Xe,et=Ze.get,tt=Ze.has,rt=Ze.set;Be=function(e,t){return rt.call(Ze,e,t),t},Ve=function(e){return et.call(Ze,e)||{}},ze=function(e){return tt.call(Ze,e)}}else{var nt=Qe("state");Ke[nt]=!0,Be=function(e,t){return Le(e,nt,t),t},Ve=function(e){return Te(e,nt)?e[nt]:{}},ze=function(e){return Te(e,nt)}}var ot,it={set:Be,get:Ve,enforce:function(e){return ze(e)?Ve(e):Be(e,{})},getterFor:function(e){return function(t){var r;if(!Ae(t)||(r=Ve(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return r}}},at=it.get,ut=it.enforce,lt=String(Ge).split("toString");De("inspectSource",function(e){return Ge.call(e)}),(ot=function(e,t,r,n){var o=!!n&&!!n.unsafe,i=!!n&&!!n.enumerable,a=!!n&&!!n.noTargetGet;"function"==typeof r&&("string"!=typeof t||Te(r,"name")||Le(r,"name",t),ut(r).source=lt.join("string"==typeof t?t:"")),e!==se?(o?!a&&e[t]&&(i=!0):delete e[t],i?e[t]=r:Le(e,t,r)):i?e[t]=r:Re(t,r)})(Function.prototype,"toString",function(){return"function"==typeof this&&at(this).source||Ge.call(this)});var ct,st=se,ft=function(e){return"function"==typeof e?e:void 0},ht=function(e,t){return arguments.length<2?ft(st[e])||ft(se[e]):st[e]&&st[e][t]||se[e]&&se[e][t]},dt=Math.ceil,pt=Math.floor,yt=function(e){return isNaN(e=+e)?0:(e>0?pt:dt)(e)},vt=Math.min,gt=function(e){return e>0?vt(yt(e),9007199254740991):0},bt=Math.max,wt=Math.min,mt={indexOf:(ct=!1,function(e,t,r){var n,o=Oe(e),i=gt(o.length),a=function(e,t){var r=yt(e);return r<0?bt(r+t,0):wt(r,t)}(r,i);if(ct&&t!=t){for(;i>a;)if((n=o[a++])!=n)return!0}else for(;i>a;a++)if((ct||a in o)&&o[a]===t)return ct||a||0;return!ct&&-1})}.indexOf,St=function(e,t){var r,n=Oe(e),o=0,i=[];for(r in n)!Te(Ke,r)&&Te(n,r)&&i.push(r);for(;t.length>o;)Te(n,r=t[o++])&&(~mt(i,r)||i.push(r));return i},Ot=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],At={},_t=Ot.concat("length","prototype");At.f=Object.getOwnPropertyNames||function(e){return St(e,_t)};var Et={};Et.f=Object.getOwnPropertySymbols;var Tt=ht("Reflect","ownKeys")||function(e){var t=At.f(Ne(e)),r=Et.f;return r?t.concat(r(e)):t},jt=function(e,t){for(var r=Tt(t),n=Ce.f,o=xe.f,i=0;i<r.length;i++){var a=r[i];Te(e,a)||n(e,a,o(t,a))}},kt=/#|\.prototype\./,Mt=function(e,t){var r=xt[It(e)];return r==Nt||r!=Pt&&("function"==typeof t?fe(t):!!t)},It=Mt.normalize=function(e){return String(e).replace(kt,".").toLowerCase()},xt=Mt.data={},Pt=Mt.NATIVE="N",Nt=Mt.POLYFILL="P",Ct=Mt,Ft=xe.f,Dt=function(e,t){var r,n,o,i,a,u=e.target,l=e.global,c=e.stat;if(r=l?se:c?se[u]||Re(u,{}):(se[u]||{}).prototype)for(n in t){if(i=t[n],o=e.noTargetGet?(a=Ft(r,n))&&a.value:r[n],!Ct(l?n:u+(c?".":"#")+n,e.forced)&&void 0!==o){if(typeof i==typeof o)continue;jt(i,o)}(e.sham||o&&o.sham)&&Le(i,"sham",!0),ot(r,n,i,e)}},Lt=!fe(function(){return Object.isExtensible(Object.preventExtensions({}))}),Rt={},Ut=Ce.f,Bt=He("meta"),Vt=0,zt=Object.isExtensible||function(){return!0},Gt=function(e){Ut(e,Bt,{value:{objectID:"O"+ ++Vt,weakData:{}}})},Wt=Rt={REQUIRED:!1,fastKey:function(e,t){if(!Ae(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!Te(e,Bt)){if(!zt(e))return"F";if(!t)return"E";Gt(e)}return e[Bt].objectID},getWeakData:function(e,t){if(!Te(e,Bt)){if(!zt(e))return!0;if(!t)return!1;Gt(e)}return e[Bt].weakData},onFreeze:function(e){return Lt&&Wt.REQUIRED&&zt(e)&&!Te(e,Bt)&&Gt(e),e}};Ke[Bt]=!0;var $t=!!Object.getOwnPropertySymbols&&!fe(function(){return!String(Symbol())}),Jt=se.Symbol,qt=De("wks"),Ht=function(e){return qt[e]||(qt[e]=$t&&Jt[e]||($t?Jt:He)("Symbol."+e))},Yt={},Qt=Ht("iterator"),Kt=Array.prototype,Xt=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},Zt=function(e,t,r){if(Xt(e),void 0===t)return e;switch(r){case 0:return function(){return e.call(t)};case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,o){return e.call(t,r,n,o)}}return function(){return e.apply(t,arguments)}},er=Ht("toStringTag"),tr="Arguments"==be(function(){return arguments}()),rr=function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=Object(e),er))?r:tr?be(t):"Object"==(n=be(t))&&"function"==typeof t.callee?"Arguments":n},nr=Ht("iterator"),or=function(e){if(null!=e)return e[nr]||e["@@iterator"]||Yt[rr(e)]},ir=function(e,t,r,n){try{return n?t(Ne(r)[0],r[1]):t(r)}catch(i){var o=e.return;throw void 0!==o&&Ne(o.call(e)),i}},ar={},ur=function(e,t){this.stopped=e,this.result=t};(ar=function(e,t,r,n,o){var i,a,u,l,c,s,f,h=Zt(t,r,n?2:1);if(o)i=e;else{if("function"!=typeof(a=or(e)))throw TypeError("Target is not iterable");if(void 0!==(f=a)&&(Yt.Array===f||Kt[Qt]===f)){for(u=0,l=gt(e.length);l>u;u++)if((c=n?h(Ne(s=e[u])[0],s[1]):h(e[u]))&&c instanceof ur)return c;return new ur(!1)}i=a.call(e)}for(;!(s=i.next()).done;)if((c=ir(i,h,s.value,n))&&c instanceof ur)return c;return new ur(!1)}).stop=function(e){return new ur(!0,e)};var lr=function(e,t,r){if(!(e instanceof t))throw TypeError("Incorrect "+(r?r+" ":"")+"invocation");return e},cr=Ht("iterator"),sr=!1;try{var fr=0,hr={next:function(){return{done:!!fr++}},return:function(){sr=!0}};hr[cr]=function(){return this},Array.from(hr,function(){throw 2})}catch(In){}var dr=Ce.f,pr=Ht("toStringTag"),yr=function(e,t,r){e&&!Te(e=r?e:e.prototype,pr)&&dr(e,pr,{configurable:!0,value:t})},vr=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(r,[]),t=r instanceof Array}catch(In){}return function(r,n){return Ne(r),function(e){if(!Ae(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype")}(n),t?e.call(r,n):r.__proto__=n,r}}():void 0),gr=Object.keys||function(e){return St(e,Ot)},br=he?Object.defineProperties:function(e,t){Ne(e);for(var r,n=gr(t),o=n.length,i=0;o>i;)Ce.f(e,r=n[i++],t[r]);return e},wr=ht("document","documentElement"),mr={},Sr=Qe("IE_PROTO"),Or=function(){},Ar=function(){var e,t=Me("iframe"),r=Ot.length;for(t.style.display="none",wr.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write("<script>document.F=Object<\/script>"),e.close(),Ar=e.F;r--;)delete Ar.prototype[Ot[r]];return Ar()};mr=Object.create||function(e,t){var r;return null!==e?(Or.prototype=Ne(e),r=new Or,Or.prototype=null,r[Sr]=e):r=Ar(),void 0===t?r:br(r,t)},Ke[Sr]=!0;var _r,Er,Tr,jr,kr=function(e,t,r){for(var n in t)ot(e,n,t[n],r);return e},Mr=!fe(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),Ir=Qe("IE_PROTO"),xr=Object.prototype,Pr=Mr?Object.getPrototypeOf:function(e){return e=Object(Se(e)),Te(e,Ir)?e[Ir]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?xr:null},Nr=Ht("iterator"),Cr=!1;[].keys&&("next"in(jr=[].keys())?(Tr=Pr(Pr(jr)))!==Object.prototype&&(Er=Tr):Cr=!0),null==Er&&(Er={}),Te(Er,Nr)||Le(Er,Nr,function(){return this});var Fr,Dr=(_r={IteratorPrototype:Er,BUGGY_SAFARI_ITERATORS:Cr}).IteratorPrototype,Lr=function(){return this},Rr=_r.IteratorPrototype,Ur=_r.BUGGY_SAFARI_ITERATORS,Br=Ht("iterator"),Vr=function(){return this},zr=function(e,t,r,n,o,i,a){!function(e,t,r){var n=t+" Iterator";e.prototype=mr(Dr,{next:ve(1,r)}),yr(e,n,!1),Yt[n]=Lr}(r,t,n);var u,l,c,s=function(e){if(e===o&&y)return y;if(!Ur&&e in d)return d[e];switch(e){case"keys":case"values":case"entries":return function(){return new r(this,e)}}return function(){return new r(this)}},f=t+" Iterator",h=!1,d=e.prototype,p=d[Br]||d["@@iterator"]||o&&d[o],y=!Ur&&p||s(o),v="Array"==t&&d.entries||p;if(v&&(u=Pr(v.call(new e)),Rr!==Object.prototype&&u.next&&(Pr(u)===Rr||(vr?vr(u,Rr):"function"!=typeof u[Br]&&Le(u,Br,Vr)),yr(u,f,!0))),"values"==o&&p&&"values"!==p.name&&(h=!0,y=function(){return p.call(this)}),d[Br]===y||Le(d,Br,y),Yt[t]=y,o)if(l={values:s("values"),keys:i?y:s("keys"),entries:s("entries")},a)for(c in l)!Ur&&!h&&c in d||ot(d,c,l[c]);else Dt({target:t,proto:!0,forced:Ur||h},l);return l},Gr=Ht("species"),Wr=Ce.f,$r=Rt.fastKey,Jr=it.set,qr=it.getterFor,Hr=(function(e,t,r,n,o){var i=se[e],a=i&&i.prototype,u=i,l=n?"set":"add",c={},s=function(e){var t=a[e];ot(a,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(o&&!Ae(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return o&&!Ae(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(o&&!Ae(e))&&t.call(this,0===e?0:e)}:function(e,r){return t.call(this,0===e?0:e,r),this})};if(Ct(e,"function"!=typeof i||!(o||a.forEach&&!fe(function(){(new i).entries().next()}))))u=r.getConstructor(t,e,n,l),Rt.REQUIRED=!0;else if(Ct(e,!0)){var f=new u,h=f[l](o?{}:-0,1)!=f,d=fe(function(){f.has(1)}),p=function(e,t){if(!t&&!sr)return!1;var r=!1;try{var n={};n[cr]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(In){}return r}(function(e){new i(e)}),y=!o&&fe(function(){for(var e=new i,t=5;t--;)e[l](t,t);return!e.has(-0)});p||((u=t(function(t,r){lr(t,u,e);var o=function(e,t,r){var n,o;return vr&&"function"==typeof(n=t.constructor)&&n!==r&&Ae(o=n.prototype)&&o!==r.prototype&&vr(e,o),e}(new i,t,u);return null!=r&&ar(r,o[l],o,n),o})).prototype=a,a.constructor=u),(d||y)&&(s("delete"),s("has"),n&&s("get")),(y||h)&&s(l),o&&a.clear&&delete a.clear}c[e]=u,Dt({global:!0,forced:u!=i},c),yr(u,e),o||r.setStrong(u,e,n)}("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},{getConstructor:function(e,t,r,n){var o=e(function(e,i){lr(e,o,t),Jr(e,{type:t,index:mr(null),first:void 0,last:void 0,size:0}),he||(e.size=0),null!=i&&ar(i,e[n],e,r)}),i=qr(t),a=function(e,t,r){var n,o,a=i(e),l=u(e,t);return l?l.value=r:(a.last=l={index:o=$r(t,!0),key:t,value:r,previous:n=a.last,next:void 0,removed:!1},a.first||(a.first=l),n&&(n.next=l),he?a.size++:e.size++,"F"!==o&&(a.index[o]=l)),e},u=function(e,t){var r,n=i(e),o=$r(t);if("F"!==o)return n.index[o];for(r=n.first;r;r=r.next)if(r.key==t)return r};return kr(o.prototype,{clear:function(){for(var e=i(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,he?e.size=0:this.size=0},delete:function(e){var t=i(this),r=u(this,e);if(r){var n=r.next,o=r.previous;delete t.index[r.index],r.removed=!0,o&&(o.next=n),n&&(n.previous=o),t.first==r&&(t.first=n),t.last==r&&(t.last=o),he?t.size--:this.size--}return!!r},forEach:function(e){for(var t,r=i(this),n=Zt(e,arguments.length>1?arguments[1]:void 0,3);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!u(this,e)}}),kr(o.prototype,r?{get:function(e){var t=u(this,e);return t&&t.value},set:function(e,t){return a(this,0===e?0:e,t)}}:{add:function(e){return a(this,e=0===e?0:e,e)}}),he&&Wr(o.prototype,"size",{get:function(){return i(this).size}}),o},setStrong:function(e,t,r){var n=t+" Iterator",o=qr(t),i=qr(n);zr(e,t,function(e,t){Jr(this,{type:n,target:e,state:o(e),kind:t,last:void 0})},function(){for(var e=i(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?"keys"==t?{value:r.key,done:!1}:"values"==t?{value:r.value,done:!1}:{value:[r.key,r.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})},r?"entries":"values",!r,!0),function(e){var t=ht(e),r=Ce.f;he&&t&&!t[Gr]&&r(t,Gr,{configurable:!0,get:function(){return this}})}(t)}}),{});Hr[Ht("toStringTag")]="z",Fr="[object z]"!==String(Hr)?function(){return"[object "+rr(this)+"]"}:Hr.toString;var Yr=Object.prototype;Fr!==Yr.toString&&ot(Yr,"toString",Fr,{unsafe:!0});var Qr,Kr={charAt:(Qr=!0,function(e,t){var r,n,o=String(Se(e)),i=yt(t),a=o.length;return i<0||i>=a?Qr?"":void 0:(r=o.charCodeAt(i))<55296||r>56319||i+1===a||(n=o.charCodeAt(i+1))<56320||n>57343?Qr?o.charAt(i):r:Qr?o.slice(i,i+2):n-56320+(r-55296<<10)+65536})}.charAt,Xr=it.set,Zr=it.getterFor("String Iterator");zr(String,"String",function(e){Xr(this,{type:"String Iterator",string:String(e),index:0})},function(){var e,t=Zr(this),r=t.string,n=t.index;return n>=r.length?{value:void 0,done:!0}:(e=Kr(r,n),t.index+=e.length,{value:e,done:!1})});var en,tn={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},rn=Ht("unscopables"),nn=Array.prototype;null==nn[rn]&&Le(nn,rn,mr(null)),en=function(e){nn[rn][e]=!0};var on,an=it.set,un=it.getterFor("Array Iterator");on=zr(Array,"Array",function(e,t){an(this,{type:"Array Iterator",target:Oe(e),index:0,kind:t})},function(){var e=un(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==r?{value:n,done:!1}:"values"==r?{value:t[n],done:!1}:{value:[n,t[n]],done:!1}},"values"),Yt.Arguments=Yt.Array,en("keys"),en("values"),en("entries");var ln=Ht("iterator"),cn=Ht("toStringTag"),sn=on.values;for(var fn in tn){var hn=se[fn],dn=hn&&hn.prototype;if(dn){if(dn[ln]!==sn)try{Le(dn,ln,sn)}catch(In){dn[ln]=sn}if(dn[cn]||Le(dn,cn,fn),tn[fn])for(var pn in on)if(dn[pn]!==on[pn])try{Le(dn,pn,on[pn])}catch(In){dn[pn]=on[pn]}}}var yn=st.Set;Dt({target:"Set",stat:!0},{from:function(e){var t,r,n,o,i=arguments.length,a=i>1?arguments[1]:void 0;return Xt(this),(t=void 0!==a)&&Xt(a),null==e?new this:(r=[],t?(n=0,o=Zt(a,i>2?arguments[2]:void 0,2),ar(e,function(e){r.push(o(e,n++))})):ar(e,r.push,r),new this(r))}});Dt({target:"Set",stat:!0},{of:function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];return new this(t)}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{addAll:function(){return function(){for(var e=Ne(this),t=Xt(e.add),r=0,n=arguments.length;r<n;r++)t.call(e,arguments[r]);return e}.apply(this,arguments)}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{deleteAll:function(){return function(){for(var e,t=Ne(this),r=Xt(t.delete),n=!0,o=0,i=arguments.length;o<i;o++)e=r.call(t,arguments[o]),n=n&&e;return!!n}.apply(this,arguments)}});var vn=function(e){var t=or(e);if("function"!=typeof t)throw TypeError(String(e)+" is not iterable");return Ne(t.call(e))},gn=function(e){return Set.prototype.values.call(e)};Dt({target:"Set",proto:!0,real:!0,forced:!1},{every:function(e){var t=Ne(this),r=gn(t),n=Zt(e,arguments.length>1?arguments[1]:void 0,3);return!ar(r,function(e){if(!n(e,e,t))return ar.stop()},void 0,!1,!0).stopped}});var bn=Ht("species"),wn=function(e,t){var r,n=Ne(e).constructor;return void 0===n||null==(r=Ne(n)[bn])?t:Xt(r)};Dt({target:"Set",proto:!0,real:!0,forced:!1},{difference:function(e){var t=Ne(this),r=new(wn(t,ht("Set")))(t),n=Xt(r.delete);return ar(e,function(e){n.call(r,e)}),r}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{filter:function(e){var t=Ne(this),r=gn(t),n=Zt(e,arguments.length>1?arguments[1]:void 0,3),o=new(wn(t,ht("Set"))),i=Xt(o.add);return ar(r,function(e){n(e,e,t)&&i.call(o,e)},void 0,!1,!0),o}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{find:function(e){var t=Ne(this),r=gn(t),n=Zt(e,arguments.length>1?arguments[1]:void 0,3);return ar(r,function(e){if(n(e,e,t))return ar.stop(e)},void 0,!1,!0).result}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{intersection:function(e){var t=Ne(this),r=new(wn(t,ht("Set"))),n=Xt(t.has),o=Xt(r.add);return ar(e,function(e){n.call(t,e)&&o.call(r,e)}),r}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{isDisjointFrom:function(e){var t=Ne(this),r=Xt(t.has);return!ar(e,function(e){if(!0===r.call(t,e))return ar.stop()}).stopped}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{isSubsetOf:function(e){var t=vn(this),r=Ne(e),n=r.has;return"function"!=typeof n&&(r=new(ht("Set"))(e),n=Xt(r.has)),!ar(t,function(e){if(!1===n.call(r,e))return ar.stop()},void 0,!1,!0).stopped}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{isSupersetOf:function(e){var t=Ne(this),r=Xt(t.has);return!ar(e,function(e){if(!1===r.call(t,e))return ar.stop()}).stopped}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{join:function(e){var t=Ne(this),r=gn(t),n=void 0===e?",":String(e),o=[];return ar(r,o.push,o,!1,!0),o.join(n)}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{map:function(e){var t=Ne(this),r=gn(t),n=Zt(e,arguments.length>1?arguments[1]:void 0,3),o=new(wn(t,ht("Set"))),i=Xt(o.add);return ar(r,function(e){i.call(o,n(e,e,t))},void 0,!1,!0),o}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{reduce:function(e){var t,r,n=Ne(this),o=gn(n);if(Xt(e),arguments.length>1)t=arguments[1];else{if((r=o.next()).done)throw TypeError("Reduce of empty set with no initial value");t=r.value}return ar(o,function(r){t=e(t,r,r,n)},void 0,!1,!0),t}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{some:function(e){var t=Ne(this),r=gn(t),n=Zt(e,arguments.length>1?arguments[1]:void 0,3);return ar(r,function(e){if(n(e,e,t))return ar.stop()},void 0,!1,!0).stopped}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{symmetricDifference:function(e){var t=Ne(this),r=new(wn(t,ht("Set")))(t),n=Xt(r.delete),o=Xt(r.add);return ar(e,function(e){n.call(r,e)||o.call(r,e)}),r}});Dt({target:"Set",proto:!0,real:!0,forced:!1},{union:function(e){var t=Ne(this),r=new(wn(t,ht("Set")))(t);return ar(e,Xt(r.add),r),r}});var mn={};mn=yn;var Sn={};Object.defineProperty(Sn,"__esModule",{value:!0}),Sn.stepOnceFSA=Sn.simulateFSA=void 0;var On,An=(On=Z)&&On.__esModule?On:{default:On},_n=re,En=t({}),Tn=o({});function jn(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}Sn.simulateFSA=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return(0,ne.instanceOf)(En.NFA,t)?function(e,t,r,n,o){if(n&&console.log(An.default.cyan("Beginning NFA Simulation")),!(e instanceof Array)){if("string"!=typeof e)throw n&&console.error(An.default.redBright("Input w was invalid type: %O"),e),new TypeError;e=""===e?[""]:jn(e)}n&&console.log(An.default.inverse("Input Processing Started"));var i=[t.getStartState()],a=!0,u=!1,l=void 0;try{for(var c,s=e[Symbol.iterator]();!(a=(c=s.next()).done);a=!0){var f=c.value,h=i;i=jn(r.receiveInput(t,f,i)),n&&console.log("%o x '%s' -> %o",JSON.stringify(h),f,JSON.stringify(i))}}catch(T){u=!0,l=T}finally{try{a||null==s.return||s.return()}finally{if(u)throw l}}n&&console.log(An.default.inverse("Input Processing Ended"));var d=[],p=!0,y=!1,v=void 0;try{for(var g,b=t.getAcceptStates()[Symbol.iterator]();!(p=(g=b.next()).done);p=!0){var w=g.value;if(i.includes(w)){if(!o)return n&&console.log(An.default.green("Input Accepted!")),!0;d.push(w.name)}}}catch(T){y=!0,v=T}finally{try{p||null==b.return||b.return()}finally{if(y)throw v}}if(d.length>0)return n&&console.log(An.default.green("Input Accepted!")),d;if(n&&console.log(An.default.red("Input Rejected!")),o){if(i.length>0){var m=!0,S=!1,O=void 0;try{for(var A,_=i[Symbol.iterator]();!(m=(A=_.next()).done);m=!0){var E=A.value;d.push(E.name)}}catch(T){S=!0,O=T}finally{try{m||null==_.return||_.return()}finally{if(S)throw O}}}return d}return!1}(e,t,new Tn.FSAUtils(En.NFA),r,n):function(e,t,r,n,o){if(n&&console.log(An.default.cyan("Beginning DFA Simulation")),!Array.isArray(e)){if("string"!=typeof e)throw n&&console.error(An.default.redBright("Input w was invalid type: %O"),e),new TypeError;e=jn(e)}n&&console.log(An.default.inverse("Input Processing Started"));var i=t.getStartState(),a=!0,u=!1,l=void 0;try{for(var c,s=e[Symbol.iterator]();!(a=(c=s.next()).done);a=!0){var f=c.value,h=i;i=r.receiveInput(t,f,h),n&&console.log("%o x '%s' -> %o",JSON.stringify(h),f,JSON.stringify(i))}}catch(d){u=!0,l=d}finally{try{a||null==s.return||s.return()}finally{if(u)throw l}}return n&&console.log(An.default.inverse("Input Processing Ended")),t.getAcceptStates().has(i)?(n&&console.log(An.default.green("Input Accepted!")),!o||i.name):(n&&console.log(An.default.red("Input Rejected!")),!!o&&i.name)}(e,t,new Tn.FSAUtils(En.DFA),r,n)},Sn.stepOnceFSA=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"!=typeof e)throw n&&console.error(An.default.redBright("Input w was invalid type: %O"),e),new TypeError;if("string"!=typeof t&&!Array.isArray(t))throw n&&console.error(An.default.redBright("Input state was invalid type: %O"),t),new TypeError;n&&console.log(An.default.inverse("Input Processing Started"));var o,i=[];if("string"==typeof t){var a=!0,u=!1,l=void 0;try{for(var c,s=r.getStates().values()[Symbol.iterator]();!(a=(c=s.next()).done);a=!0){var f=c.value;t===f.name&&(i=f)}}catch(E){u=!0,l=E}finally{try{a||null==s.return||s.return()}finally{if(u)throw l}}if(!i||Array.isArray(i)&&0===i.length)throw new Error(ee.ErrorCode.INVALID_STATE_NAME)}else{i=[];var h=!0,d=!1,p=void 0;try{for(var y,v=r.getStates().values()[Symbol.iterator]();!(h=(y=v.next()).done);h=!0){var g=y.value;t.includes(g.name)&&i.push(g)}}catch(E){d=!0,p=E}finally{try{h||null==v.return||v.return()}finally{if(d)throw p}}if(i.length!==t.length)throw new Error(ee.ErrorCode.INVALID_STATE_NAME)}if(o=(0,ne.instanceOf)(En.NFA,r)?jn(new Tn.FSAUtils(En.NFA).receiveInput(r,e,i)):new Tn.FSAUtils(En.DFA).receiveInput(r,e,i),n&&console.log("%o x '%s' -> %o",JSON.stringify(i),e,JSON.stringify(o)),n&&console.log(An.default.inverse("Input Processing Ended")),o instanceof _n.State)return o.name;var b=[],w=!0,m=!1,S=void 0;try{for(var O,A=o[Symbol.iterator]();!(w=(O=A.next()).done);w=!0){var _=O.value;b.push(_.name)}}catch(E){m=!0,S=E}finally{try{w||null==A.return||A.return()}finally{if(m)throw S}}return b};var kn={};Object.defineProperty(kn,"__esModule",{value:!0}),Object.defineProperty(kn,"simulateFSA",{enumerable:!0,get:function(){return Sn.simulateFSA}}),Object.defineProperty(kn,"stepOnceFSA",{enumerable:!0,get:function(){return Sn.stepOnceFSA}}),Object.defineProperty(kn,"createFSA",{enumerable:!0,get:function(){return Mn.createFSA}});var Mn=i({});return kn});
|
|
1
|
+
"use strict";var fasJs=(()=>{var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var V=o=>{throw TypeError(o)};var Q=(o,t)=>{for(var r in t)U(o,r,{get:t[r],enumerable:!0})},Y=(o,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of K(t))!$.call(o,s)&&s!==r&&U(o,s,{get:()=>t[s],enumerable:!(i=G(t,s))||i.enumerable});return o};var W=o=>Y(U({},"__esModule",{value:!0}),o);var C=(o,t,r)=>t.has(o)||V("Cannot "+r);var l=(o,t,r)=>(C(o,t,"read from private field"),r?r.call(o):t.get(o)),m=(o,t,r)=>t.has(o)?V("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,r),d=(o,t,r,i)=>(C(o,t,"write to private field"),i?i.call(o,r):t.set(o,r),r);var q={};Q(q,{createFSA:()=>B,simulateFSA:()=>H,stepOnceFSA:()=>z});var f=Object.freeze({DUPLICATE_ALPHABET_VALS:"E-001",DUPLICATE_STATE_NAMES:"E-002",INVALID_STATE_NAME:"E-003",START_STATE_NOT_FOUND:"E-004",ACCEPTS_NOT_SUBSET:"E-005",ORIGIN_STATE_NOT_FOUND:"E-006",DEST_STATE_NOT_FOUND:"E-007",MISSING_REQUIRED_TRANSITION:"E-008",INVALID_INPUT_CHAR:"E-009",INPUT_STATE_NOT_FOUND:"E-010",INVALID_TRANSITION_OBJECT:"E-011",DUPLICATE_TRANSITION_OBJECT:"E-012",INVALID_STATE_ARRAY:"E-013"});var I=class{constructor(t){if(this.name=t,!this.name)throw new Error(f.INVALID_STATE_NAME)}};var L=o=>o.reduce((t,r)=>Object.assign(t,{[r]:(t[r]||0)+1}),{}),M=o=>Object.keys(o).filter(t=>o[t]>1);var P=o=>{let t=new Set;for(let r of o){if(t.has(r.name))return!0;t.add(r.name)}return!1},A=(o,t,r)=>{let i=o.get(t);return i??r},F=(o,t)=>t instanceof o||!!o.name&&o.name===t.constructor.name,k=(o,t)=>{for(let r of o)if(!t.has(r))return!1;return!0};var b=class{constructor(t){if(!Array.isArray(t))if(typeof t=="string")t=[...t];else throw new TypeError;if(this.sigma=t,M(L(this.sigma)).length>0)throw new Error(f.DUPLICATE_ALPHABET_VALS)}};var x=class{constructor(t,r,i){this.origin=t,this.dest=r,this.input=i}};var O=class{constructor(t,r,i){this.origin=t,this.dest=r,this.input=i}};var w=class{static validateTFunc(t,r,i,s){let e=new Set;for(let n of i){if(!t.has(n.origin))throw console.error("Origin state was invalid: %o",JSON.stringify(n.origin)),new Error(f.ORIGIN_STATE_NOT_FOUND);if(!t.has(n.dest))throw console.error("Dest state was invalid: %o",JSON.stringify(n.dest)),new Error(f.DEST_STATE_NOT_FOUND);let a=A(r,n.origin,new Set);if(this.isValidInputChar(n.input,s))if(r.has(n.origin)&&a.has(n.input))e.add(n),a.delete(n.input),a.size===0&&r.delete(n.origin);else throw new Error(f.DUPLICATE_TRANSITION_OBJECT);else throw new Error(f.INVALID_INPUT_CHAR)}if(r.size>0){console.error("Not all FSA paths have a transition specified:");for(let[n,a]of r)console.error("State %s on input(s): %s",n.name,[...a].join(" "));throw new Error(f.MISSING_REQUIRED_TRANSITION)}return e}static createPaths(t,r){let i=new Map;for(let s of t)for(let e of r.sigma){let n=A(i,s,new Set);i.has(s)?n.add(e):i.set(s,new Set([e]))}return i}static determineStateOrder(t,r,i,s,e){let n=[];t=new Map;for(let p of r){let c=A(t,p.origin.name,new Set);t.has(p.origin.name)?c.add(p.dest.name):t.set(p.origin.name,new Set([p.dest.name]))}this.parseLinks(n,s.name,t);let a=[];Object.values([...i]).map(p=>a.push(p.name));let S=a.filter(p=>!n.includes(p));return S.length>0&&(console.warn("Dead states detected, removing them and associated transitions: %O",S),this.removeDeadStates(S,i,e,r)),n}static removeDeadStates(t,r,i,s){for(let e of r)t.indexOf(e.name)!==-1&&r.delete(e);for(let e of i)t.indexOf(e.name)!==-1&&i.delete(e);for(let e of s)(t.indexOf(e.origin.name)!==-1||t.indexOf(e.dest.name)!==-1)&&s.delete(e)}static parseLinks(t,r,i){t.push(r);let s=A(i,r,new Set);for(let e of s)t.indexOf(e)===-1&&this.parseLinks(t,e,i)}static isValidInputChar(t,r){return t===""?!1:r.sigma.indexOf(t)!==-1}},J=(o,t,r,i,s)=>{let e=new Set;for(let n of r){if(!n.from||!n.to||!n.input)throw new Error(f.INVALID_TRANSITION_OBJECT);let a=A(o,n.from,null),S=A(o,n.to,null);e.add(new O(a,S,n.input))}return new E(new Set(o.values()),t,e,i,s)};var _=class extends w{static isValidInputChar(t,r){return r.sigma.indexOf(t)!==-1||t===""}static populateEpsilons(t,r){let i=!0;for(;i;){i=!1;let s=Array.from(t).filter(e=>r.includes(e.origin)&&e.input==="");for(let e of s)r.includes(e.dest)||(r.push(e.dest),i=!0)}return r}static validateTFunc(t,r,i,s){let e=new Set;for(let n of i){let a=!1;if(!t.has(n.origin))throw console.error("Origin state was invalid: %o",JSON.stringify(n.origin)),new Error(f.ORIGIN_STATE_NOT_FOUND);if(!t.has(n.dest))throw console.error("Dest state was invalid: %o",JSON.stringify(n.dest)),new Error(f.DEST_STATE_NOT_FOUND);let S=A(r,n.origin,new Set);for(let p of e)p.origin===n.origin&&p.dest===n.dest&&p.input===n.input&&(a=!0);if(!a&&r.has(n.origin))if(this.isValidInputChar(n.input,s))e.add(n);else throw new Error(f.INVALID_INPUT_CHAR)}return e}},j=(o,t,r,i,s)=>{let e=new Set;for(let n of r){if(!n.from||!n.to||!n.input&&n.input!=="")throw new Error(f.INVALID_TRANSITION_OBJECT);let a=A(o,n.from,null),S=n.to.split(","),p=[];S.forEach(c=>{p.push(A(o,c,null))}),e.add(new x(a,p,n.input))}return new g(new Set(o.values()),t,e,i,s)};var N=(()=>{function o(s,e,n){if(s.getAlphabet().sigma.indexOf(e)===-1)throw new Error(f.INVALID_INPUT_CHAR);if(!s.getStates().has(n))throw new Error(f.INPUT_STATE_NOT_FOUND);let a=Array.from(s.getTFunc()).find(S=>S.origin===n&&S.input===e);if(a)return a.dest;throw new Error(f.INVALID_TRANSITION_OBJECT)}function t(s,e,n){let a=[];if(s.getAlphabet().sigma.indexOf(e)===-1)throw new Error(f.INVALID_INPUT_CHAR);if(n=r(s.getTFunc(),n),e==="")return new Set(n);for(let c of n){let h=Array.from(s.getTFunc()).filter(u=>u.origin===c&&u.input===e);a=a.concat(h)}let S=[];if(a.length>1)for(let c of a)S.push(c.dest);else if(a.length===1)S.push(a[0].dest);else return new Set;return new Set(r(s.getTFunc(),S))}function r(s,e){return _.populateEpsilons(s,e)}class i{constructor(e){this._type=e}receiveInput(e,n,a){if(F(g,e))return a instanceof I?t(e,n,[a]):t(e,n,a);if(Array.isArray(a)){if(a.length>1)throw console.error("State array can only contain one state for DFAs"),new Error(f.INVALID_STATE_ARRAY);a=a[0]}return o(e,n,a)}validateTFunc(e,n,a,S){return this._type===g?_.validateTFunc(e,n,a,S):w.validateTFunc(e,n,a,S)}createPaths(e,n){return w.createPaths(e,n)}determineStateOrder(e,n,a,S,p){return w.determineStateOrder(e,n,a,S,p)}}return i})(),B=(o,t,r,i,s)=>{let e=new Map;if(typeof o=="string")e.set(o,new I(o));else if(Array.isArray(o))for(let c of o)e.has(c)||e.set(c,new I(c));else throw new TypeError(String(o));let n=new b(t);if(typeof i!="string")throw new TypeError(String(i));let a=A(e,i,null),S=new Set;if(typeof s=="string")e.has(s)&&S.add(A(e,s,null));else if(Array.isArray(s))for(let c of s)S.add(A(e,c,null));else throw new TypeError(String(s));let p;if(!Array.isArray(r)&&typeof r=="object")p=[r];else if(Array.isArray(r))p=r;else throw new TypeError(String(r));for(let c of p)if(c.to.indexOf(",")!=-1||c.input==="")return j(e,n,p,a,S);return J(e,n,p,a,S)};var E=(()=>{var t,r,i,s,e,n,a,S;class o{constructor(c,h,u,y,T){m(this,t);m(this,r);m(this,i);m(this,s);m(this,e);m(this,n);m(this,a,new Map);m(this,S);if(d(this,S,new N(this.constructor)),P(c))throw new Error(f.DUPLICATE_STATE_NAMES);if(d(this,t,c),d(this,r,h),d(this,n,l(this,S).createPaths(l(this,t),l(this,r))),!c.has(y))throw new Error(f.START_STATE_NOT_FOUND);if(d(this,s,y),Object.keys(T).length===0&&T.constructor===Object&&(T=new Set([])),!k(T,c))throw new Error(f.ACCEPTS_NOT_SUBSET);d(this,e,T),d(this,i,l(this,S).validateTFunc(l(this,t),l(this,n),u,l(this,r)))}getStates(){return l(this,t)}getAlphabet(){return l(this,r)}getTFunc(){return l(this,i)}getStartState(){return l(this,s)}getAcceptStates(){return l(this,e)}getType(){return"DFA"}generateDigraph(){let c=[];for(let u of l(this,e))c.push(u.name);let h=new Map;return Object.values([...l(this,i)]).map(function(u){let y=u.origin.name+u.dest.name,T=u.input;if(T===""&&(T="\u03B5"),!h.has(y))h.set(y,u.origin.name+" -> "+u.dest.name+' [ label = "'+T+'" ];');else{let D=A(h,y,""),R=D.split('"')[1],v=R.split(",");v.push(T),v.sort(),D=D.replace('"'+R+'"','"'+v.toString()+'"'),h.set(y,D)}}),`digraph fsa {
|
|
2
|
+
${Object.values(l(this,S).determineStateOrder(l(this,a),l(this,i),l(this,t),l(this,s),l(this,e))).map(function(u){return c.indexOf(u)!==-1?u+" [shape = doublecircle];":u}).join(`
|
|
3
|
+
`)}
|
|
4
|
+
rankdir=LR;
|
|
5
|
+
node [shape = point ]; qi;
|
|
6
|
+
node [shape = circle];
|
|
7
|
+
qi -> ${l(this,s).name};
|
|
8
|
+
${Object.values([...h]).map(function([,u]){return u}).join(`
|
|
9
|
+
`)}
|
|
10
|
+
}
|
|
11
|
+
`}}return t=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,e=new WeakMap,n=new WeakMap,a=new WeakMap,S=new WeakMap,o})();var g=(()=>{class o extends E{constructor(r,i,s,e,n){i.sigma.includes("")||i.sigma.push("");let a=new Set;for(let S of s)S.dest.forEach(p=>{a.add(new O(S.origin,p,S.input))});super(r,i,a,e,n)}getType(){return"NFA"}}return o})();var H=(o,t,r=!1,i=!1)=>F(g,t)?Z(o,t,new N(g),r,i):X(o,t,new N(E),r,i),z=(o,t,r,i=!1)=>{if(typeof o!="string")throw i&&console.error("Input w was invalid type: %O",o),new TypeError;if(typeof t!="string"&&!Array.isArray(t))throw i&&console.error("Input state was invalid type: %O",t),new TypeError;i&&console.log("Input Processing Started");let s=[];if(typeof t=="string"){for(let n of r.getStates().values())t===n.name&&(s=n);if(!s||Array.isArray(s)&&s.length===0)throw new Error(f.INVALID_STATE_NAME)}else{s=[];for(let n of r.getStates().values())t.includes(n.name)&&s.push(n);if(s.length!==t.length)throw new Error(f.INVALID_STATE_NAME)}let e;if(F(g,r)?e=[...new N(g).receiveInput(r,o,s)]:e=new N(E).receiveInput(r,o,s),i&&console.log("%o x '%s' -> %o",JSON.stringify(s),o,JSON.stringify(e)),i&&console.log("Input Processing Ended"),e instanceof I)return e.name;{let n=[];for(let a of e)n.push(a.name);return n}};function X(o,t,r,i,s){if(i&&console.log("Beginning DFA Simulation"),!Array.isArray(o))if(typeof o=="string")o=[...o];else throw i&&console.error("Input w was invalid type: %O",o),new TypeError;i&&console.log("Input Processing Started");let e=t.getStartState();for(let n of o){let a=e;e=r.receiveInput(t,n,a),i&&console.log("%o x '%s' -> %o",JSON.stringify(a),n,JSON.stringify(e))}return i&&console.log("Input Processing Ended"),t.getAcceptStates().has(e)?(i&&console.log("Input Accepted!"),s?e.name:!0):(i&&console.log("Input Rejected!"),s?e.name:!1)}function Z(o,t,r,i,s){if(i&&console.log("Beginning NFA Simulation"),!(o instanceof Array))if(typeof o=="string")o===""?o=[""]:o=[...o];else throw i&&console.error("Input w was invalid type: %O",o),new TypeError;i&&console.log("Input Processing Started");let e=[t.getStartState()];for(let a of o){let S=e;e=[...r.receiveInput(t,a,e)],i&&console.log("%o x '%s' -> %o",JSON.stringify(S),a,JSON.stringify(e))}i&&console.log("Input Processing Ended");let n=[];for(let a of t.getAcceptStates())if(e.includes(a)){if(!s)return i&&console.log("Input Accepted!"),!0;n.push(a.name)}if(n.length>0)return i&&console.log("Input Accepted!"),n;if(i&&console.log("Input Rejected!"),s){if(e.length>0)for(let a of e)n.push(a.name);return n}else return!1}return W(q);})();
|
|
12
|
+
//# sourceMappingURL=bundle.global.js.map
|