@vuu-ui/vuu-data-react 0.8.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 +201 -0
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +7 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +7 -0
- package/package.json +29 -0
- package/types/hooks/index.d.ts +6 -0
- package/types/hooks/useDataSource.d.ts +24 -0
- package/types/hooks/useServerConnectionQuality.d.ts +1 -0
- package/types/hooks/useServerConnectionStatus.d.ts +1 -0
- package/types/hooks/useTypeaheadSuggestions.d.ts +4 -0
- package/types/hooks/useVuuMenuActions.d.ts +48 -0
- package/types/hooks/useVuuTables.d.ts +2 -0
- package/types/index.d.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2015 UBS
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var Oe=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Ot=Object.prototype.hasOwnProperty;var Pt=(i,e)=>{for(var t in e)Oe(i,t,{get:e[t],enumerable:!0})},Ct=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of wt(e))!Ot.call(i,r)&&r!==t&&Oe(i,r,{get:()=>e[r],enumerable:!(s=kt(e,r))||s.enumerable});return i};var St=i=>Ct(Oe({},"__esModule",{value:!0}),i);var Xe=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var N=(i,e,t)=>(Xe(i,e,"read from private field"),t?t.call(i):e.get(i)),Ye=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Pe=(i,e,t,s)=>(Xe(i,e,"write to private field"),s?s.call(i,t):e.set(i,t),t);var fs={};Pt(fs,{MovingWindow:()=>de,addRowsFromInstruments:()=>Xt,getTypeaheadParams:()=>Mt,isViewportMenusAction:()=>dt,isVisualLinkCreatedAction:()=>qt,isVisualLinkRemovedAction:()=>Ht,isVisualLinksAction:()=>pt,isVuuFeatureAction:()=>Zt,isVuuFeatureInvocation:()=>Kt,useDataSource:()=>yt,useServerConnectionQuality:()=>Rt,useServerConnectionStatus:()=>vt,useTypeaheadSuggestions:()=>At,useVuuMenuActions:()=>as,useVuuTables:()=>us});module.exports=St(fs);var Q=require("@vuu-ui/vuu-utils"),C=require("react"),{SELECTED:Ce}=Q.metadataKeys;function yt({dataSource:i,renderBufferSize:e=10}){let[,t]=(0,C.useState)(null),s=(0,C.useRef)(!0),r=(0,C.useRef)(!1),o=(0,C.useRef)(null),n=(0,C.useRef)([]),h=(0,C.useRef)({from:0,to:10}),l=(0,C.useMemo)(()=>new de((0,Q.getFullRange)(h.current,e)),[e]),a=(0,C.useCallback)(c=>{for(let p of c)l.add(p);n.current=l.data.slice(),r.current=!0},[l]),f=(0,C.useCallback)(c=>{c.type==="viewport-update"&&(c.size!==void 0&&l.setRowCount(c.size),c.rows?(a(c.rows),t({})):c.size!==void 0&&(n.current=l.data.slice(),r.current=!0))},[l,a]);(0,C.useEffect)(()=>()=>{o.current&&(cancelAnimationFrame(o.current),o.current=null),s.current=!1},[]);let u=(0,C.useCallback)(c=>{h.current=c;let p=(0,Q.getFullRange)(h.current,e);i.range=p,l.setRange(p.from,p.to)},[i,l,e]);return(0,C.useMemo)(()=>{let{from:c,to:p}=h.current,g=(0,Q.getFullRange)({from:c,to:p},e);i.range=g,l.setRange(g.from,g.to)},[i,l,e]),(0,C.useEffect)(()=>{let{from:c,to:p}=(0,Q.getFullRange)(h.current,e);i.subscribe({range:{from:c,to:p}},f)},[i,f,e]),(0,C.useEffect)(()=>()=>{i.unsubscribe()},[i]),[n.current,l.rowCount,(0,Q.getFullRange)(h.current,e),u]}var de=class{constructor({from:e,to:t}){this.rowCount=0;this.setRowCount=e=>{e<this.data.length&&(this.data.length=e),this.rowCount=e};this.range=new Q.WindowRange(e,t),this.data=new Array(t-e)}add(e){let[t]=e;if(this.isWithinRange(t)){let s=t-this.range.from;this.data[s]=e,this.data[s-1]&&this.data[s-1][Ce]===1&&e[Ce]===0&&(e[Ce]=2),t===this.rowCount-1&&(this.data.length=s+1)}}getAtIndex(e){return this.range.isWithin(e)&&this.data[e-this.range.from]!=null?this.data[e-this.range.from]:void 0}isWithinRange(e){return this.range.isWithin(e)}setRange(e,t){if(e!==this.range.from||t!==this.range.to){let[s,r]=this.range.overlap(e,t),o=new Array(t-e);for(let n=s;n<r;n++){let h=this.getAtIndex(n);if(h){let l=n-e;o[l]=h}}this.data=o,this.range.from=e,this.range.to=t}}};var ee=require("react"),Se=require("@vuu-ui/vuu-data"),vt=()=>{let[i,e]=(0,ee.useState)("disconnected"),t=(0,ee.useCallback)(({status:s})=>{e(s)},[]);return(0,ee.useEffect)(()=>(Se.ConnectionManager.on("connection-status",t),()=>{Se.ConnectionManager.removeListener("connection-status",t)}),[t]),i};var te=require("react"),ye=require("@vuu-ui/vuu-data"),Rt=()=>{let[i,e]=(0,te.useState)(0),t=(0,te.useCallback)(({messages:s})=>{e(s.messagesLength)},[]);return(0,te.useEffect)(()=>(ye.ConnectionManager.on("connection-metrics",t),()=>{ye.ConnectionManager.removeListener("connection-metrics",t)}),[t]),i};var He=require("react"),Ze=require("@vuu-ui/vuu-data"),qe={type:"RPC_CALL",service:"TypeAheadRpcHandler"},Mt=(i,e,t="",s=[])=>t!==""&&!s.includes(t.toLowerCase())?[i,e,t]:[i,e],At=()=>(0,He.useCallback)(async e=>{let t=e.length===2?{method:"getUniqueFieldValues",params:e,...qe}:{method:"getUniqueFieldValuesStartingWith",params:e,...qe};return await(0,Ze.makeRpcCall)(t)},[]);var Tt=0,ue=class{constructor(e,t){this.from=e,this.to=t}},k=class{constructor(e={}){this.id=Tt++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=A.match(e)),t=>{let s=e(t);return s===void 0?null:[this,s]}}};k.closedBy=new k({deserialize:i=>i.split(" ")});k.openedBy=new k({deserialize:i=>i.split(" ")});k.group=new k({deserialize:i=>i.split(" ")});k.contextHash=new k({perNode:!0});k.lookAhead=new k({perNode:!0});k.mounted=new k({perNode:!0});var Vt=Object.create(null),A=class{constructor(e,t,s,r=0){this.name=e,this.props=t,this.id=s,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):Vt,s=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new A(e.name||"",t,e.id,s);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(r)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[o[0].id]=o[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(k.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let s in e)for(let r of s.split(" "))t[r]=e[s];return s=>{for(let r=s.prop(k.group),o=-1;o<(r?r.length:0);o++){let n=t[o<0?s.name:r[o]];if(n)return n}}}};A.none=new A("",Object.create(null),0,8);var se=class{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let s of this.types){let r=null;for(let o of e){let n=o(s);n&&(r||(r=Object.assign({},s.props)),r[n[0].id]=n[1])}t.push(r?new A(s.name,r,s.id,s.flags):s)}return new se(t)}},ge=new WeakMap,Ke=new WeakMap,S;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(S||(S={}));var v=class{constructor(e,t,s,r,o){if(this.type=e,this.children=t,this.positions=s,this.length=r,this.props=null,o&&o.length){this.props=Object.create(null);for(let[n,h]of o)this.props[typeof n=="number"?n:n.id]=h}}toString(){let e=this.prop(k.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let s of this.children){let r=s.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new ie(this.topNode,e)}cursorAt(e,t=0,s=0){let r=ge.get(this)||this.topNode,o=new ie(r);return o.moveTo(e,t),ge.set(this,o._tree),o}get topNode(){return new F(this,0,0,null)}resolve(e,t=0){let s=re(ge.get(this)||this.topNode,e,t,!1);return ge.set(this,s),s}resolveInner(e,t=0){let s=re(Ke.get(this)||this.topNode,e,t,!0);return Ke.set(this,s),s}iterate(e){let{enter:t,leave:s,from:r=0,to:o=this.length}=e,n=e.mode||0,h=(n&S.IncludeAnonymous)>0;for(let l=this.cursor(n|S.IncludeAnonymous);;){let a=!1;if(l.from<=o&&l.to>=r&&(!h&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;a=!0}for(;a&&s&&(h||!l.type.isAnonymous)&&s(l),!l.nextSibling();){if(!l.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ae(A.none,this.children,this.positions,0,this.children.length,0,this.length,(t,s,r)=>new v(this.type,t,s,r,this.propValues),e.makeTree||((t,s,r)=>new v(A.none,t,s,r)))}static build(e){return It(e)}};v.empty=new v(A.none,[],[],0);var fe=class{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new fe(this.buffer,this.index)}},B=class{constructor(e,t,s){this.buffer=e,this.length=t,this.set=s}get type(){return A.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],s=this.buffer[e+3],r=this.set.types[t],o=r.name;if(/\W/.test(o)&&!r.isError&&(o=JSON.stringify(o)),e+=4,s==e)return o;let n=[];for(;e<s;)n.push(this.childString(e)),e=this.buffer[e+3];return o+"("+n.join(",")+")"}findChild(e,t,s,r,o){let{buffer:n}=this,h=-1;for(let l=e;l!=t&&!(et(o,r,n[l+1],n[l+2])&&(h=l,s>0));l=n[l+3]);return h}slice(e,t,s){let r=this.buffer,o=new Uint16Array(t-e),n=0;for(let h=e,l=0;h<t;){o[l++]=r[h++],o[l++]=r[h++]-s;let a=o[l++]=r[h++]-s;o[l++]=r[h++]-e,n=Math.max(n,a)}return new B(o,n,this.set)}};function et(i,e,t,s){switch(i){case-2:return t<e;case-1:return s>=e&&t<e;case 0:return t<e&&s>e;case 1:return t<=e&&s>e;case 2:return s>e;case 4:return!0}}function tt(i,e){let t=i.childBefore(e);for(;t;){let s=t.lastChild;if(!s||s.to!=t.to)break;s.type.isError&&s.from==s.to?(i=t,t=s.prevSibling):t=s}return i}function re(i,e,t,s){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to<e);){let n=!s&&i instanceof F&&i.index<0?null:i.parent;if(!n)return i;i=n}let o=s?0:S.IgnoreOverlays;if(s)for(let n=i,h=n.parent;h;n=h,h=n.parent)n instanceof F&&n.index<0&&((r=h.enter(e,t,o))===null||r===void 0?void 0:r.from)!=n.from&&(i=h);for(;;){let n=i.enter(e,t,o);if(!n)return i;i=n}}var F=class{constructor(e,t,s,r){this._tree=e,this.from=t,this.index=s,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,s,r,o=0){for(let n=this;;){for(let{children:h,positions:l}=n._tree,a=t>0?h.length:-1;e!=a;e+=t){let f=h[e],u=l[e]+n.from;if(et(r,s,u,u+f.length)){if(f instanceof B){if(o&S.ExcludeBuffers)continue;let c=f.findChild(0,f.buffer.length,t,s-u,r);if(c>-1)return new _(new ve(n,f,e,u),null,c)}else if(o&S.IncludeAnonymous||!f.type.isAnonymous||Me(f)){let c;if(!(o&S.IgnoreMounts)&&f.props&&(c=f.prop(k.mounted))&&!c.overlay)return new F(c.tree,u,e,n);let p=new F(f,u,e,n);return o&S.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?f.children.length-1:0,t,s,r)}}}if(o&S.IncludeAnonymous||!n.type.isAnonymous||(n.index>=0?e=n.index+t:e=t<0?-1:n._parent._tree.children.length,n=n._parent,!n))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,s=0){let r;if(!(s&S.IgnoreOverlays)&&(r=this._tree.prop(k.mounted))&&r.overlay){let o=e-this.from;for(let{from:n,to:h}of r.overlay)if((t>0?n<=o:n<o)&&(t<0?h>=o:h>o))return new F(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,s)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new ie(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return re(this,e,t,!1)}resolveInner(e,t=0){return re(this,e,t,!0)}enterUnfinishedNodesBefore(e){return tt(this,e)}getChild(e,t=null,s=null){let r=be(this,e,t,s);return r.length?r[0]:null}getChildren(e,t=null,s=null){return be(this,e,t,s)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return xe(this,e)}};function be(i,e,t,s){let r=i.cursor(),o=[];if(!r.firstChild())return o;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return o}for(;;){if(s!=null&&r.type.is(s))return o;if(r.type.is(e)&&o.push(r.node),!r.nextSibling())return s==null?o:[]}}function xe(i,e,t=e.length-1){for(let s=i.parent;t>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(e[t]&&e[t]!=s.name)return!1;t--}}return!0}var ve=class{constructor(e,t,s,r){this.parent=e,this.buffer=t,this.index=s,this.start=r}},_=class{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,s){this.context=e,this._parent=t,this.index=s,this.type=e.buffer.set.types[e.buffer.buffer[s]]}child(e,t,s){let{buffer:r}=this.context,o=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,s);return o<0?null:new _(this.context,this,o)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,s=0){if(s&S.ExcludeBuffers)return null;let{buffer:r}=this.context,o=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new _(this.context,this,o)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new _(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new _(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new ie(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:s}=this.context,r=this.index+4,o=s.buffer[this.index+3];if(o>r){let n=s.buffer[this.index+1];e.push(s.slice(r,o,n)),t.push(0)}return new v(this.type,e,t,this.to-this.from)}resolve(e,t=0){return re(this,e,t,!1)}resolveInner(e,t=0){return re(this,e,t,!0)}enterUnfinishedNodesBefore(e){return tt(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,s=null){let r=be(this,e,t,s);return r.length?r[0]:null}getChildren(e,t=null,s=null){return be(this,e,t,s)}get node(){return this}matchContext(e){return xe(this,e)}},ie=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof F)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let s=e._parent;s;s=s._parent)this.stack.unshift(s.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:s,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=s+r.buffer[e+1],this.to=s+r.buffer[e+2],!0}yield(e){return e?e instanceof F?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,s){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,s,this.mode));let{buffer:r}=this.buffer,o=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,s);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,s=this.mode){return this.buffer?s&S.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,s))}parent(){if(!this.buffer)return this.yieldNode(this.mode&S.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&S.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,s=this.stack.length-1;if(e<0){let r=s<0?0:this.stack[s]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(s<0?t.buffer.length:t.buffer[this.stack[s]+3]))return this.yieldBuf(r)}return s<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,s,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let o=0;o<this.index;o++)if(r.buffer.buffer[o+3]<this.index)return!1;({index:t,parent:s}=r)}else({index:t,_parent:s}=this._tree);for(;s;{index:t,_parent:s}=s)if(t>-1)for(let o=t+e,n=e<0?-1:s._tree.children.length;o!=n;o+=e){let h=s._tree.children[o];if(this.mode&S.IncludeAnonymous||h instanceof B||!h.type.isAnonymous||Me(h))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,s=0;if(e&&e.context==this.buffer)e:for(let r=this.index,o=this.stack.length;o>=0;){for(let n=e;n;n=n._parent)if(n.index==r){if(r==this.index)return n;t=n,s=o+1;break e}r=this.stack[--o]}for(let r=s;r<this.stack.length;r++)t=new _(this.buffer,t,this.stack[r]);return this.bufferNode=new _(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let s=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){s++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!s)return;this.parent(),s--,r=!0}}}matchContext(e){if(!this.buffer)return xe(this.node,e);let{buffer:t}=this.buffer,{types:s}=t.set;for(let r=e.length-1,o=this.stack.length-1;r>=0;o--){if(o<0)return xe(this.node,e,r);let n=s[t.buffer[this.stack[o]]];if(!n.isAnonymous){if(e[r]&&e[r]!=n.name)return!1;r--}}return!0}};function Me(i){return i.children.some(e=>e instanceof B||!e.type.isAnonymous||Me(e))}function It(i){var e;let{buffer:t,nodeSet:s,maxBufferLength:r=1024,reused:o=[],minRepeatType:n=s.types.length}=i,h=Array.isArray(t)?new fe(t,t.length):t,l=s.types,a=0,f=0;function u(w,O,d,b,y){let{id:x,start:m,end:P,size:M}=h,V=f;for(;M<0;)if(h.next(),M==-1){let G=o[x];d.push(G),b.push(m-w);return}else if(M==-3){a=x;return}else if(M==-4){f=x;return}else throw new RangeError(`Unrecognized record size: ${M}`);let K=l[x],j,L,Ge=m-w;if(P-m<=r&&(L=W(h.pos-O,y))){let G=new Uint16Array(L.size-L.skip),I=h.pos-L.size,z=G.length;for(;h.pos>I;)z=H(L.start,G,z);j=new B(G,P-L.start,s),Ge=L.start-w}else{let G=h.pos-M;h.next();let I=[],z=[],Y=x>=n?x:-1,J=0,pe=P;for(;h.pos>G;)Y>=0&&h.id==Y&&h.size>=0?(h.end<=pe-r&&(p(I,z,m,J,h.end,pe,Y,V),J=I.length,pe=h.end),h.next()):u(m,G,I,z,Y);if(Y>=0&&J>0&&J<I.length&&p(I,z,m,J,m,pe,Y,V),I.reverse(),z.reverse(),Y>-1&&J>0){let $e=c(K);j=Ae(K,I,z,0,I.length,0,P-m,$e,$e)}else j=g(K,I,z,P-m,V-P)}d.push(j),b.push(Ge)}function c(w){return(O,d,b)=>{let y=0,x=O.length-1,m,P;if(x>=0&&(m=O[x])instanceof v){if(!x&&m.type==w&&m.length==b)return m;(P=m.prop(k.lookAhead))&&(y=d[x]+m.length+P)}return g(w,O,d,b,y)}}function p(w,O,d,b,y,x,m,P){let M=[],V=[];for(;w.length>b;)M.push(w.pop()),V.push(O.pop()+d-y);w.push(g(s.types[m],M,V,x-y,P-x)),O.push(y-d)}function g(w,O,d,b,y=0,x){if(a){let m=[k.contextHash,a];x=x?[m].concat(x):[m]}if(y>25){let m=[k.lookAhead,y];x=x?[m].concat(x):[m]}return new v(w,O,d,b,x)}function W(w,O){let d=h.fork(),b=0,y=0,x=0,m=d.end-r,P={size:0,start:0,skip:0};e:for(let M=d.pos-w;d.pos>M;){let V=d.size;if(d.id==O&&V>=0){P.size=b,P.start=y,P.skip=x,x+=4,b+=4,d.next();continue}let K=d.pos-V;if(V<0||K<M||d.start<m)break;let j=d.id>=n?4:0,L=d.start;for(d.next();d.pos>K;){if(d.size<0)if(d.size==-3)j+=4;else break e;else d.id>=n&&(j+=4);d.next()}y=L,b+=V,x+=j}return(O<0||b==w)&&(P.size=b,P.start=y,P.skip=x),P.size>4?P:void 0}function H(w,O,d){let{id:b,start:y,end:x,size:m}=h;if(h.next(),m>=0&&b<n){let P=d;if(m>4){let M=h.pos-(m-4);for(;h.pos>M;)d=H(w,O,d)}O[--d]=P,O[--d]=x-w,O[--d]=y-w,O[--d]=b}else m==-3?a=b:m==-4&&(f=b);return d}let X=[],Z=[];for(;h.pos>0;)u(i.start||0,i.bufferStart||0,X,Z,-1);let R=(e=i.length)!==null&&e!==void 0?e:X.length?Z[0]+X[0].length:0;return new v(l[i.topID],X.reverse(),Z.reverse(),R)}var Je=new WeakMap;function me(i,e){if(!i.isAnonymous||e instanceof B||e.type!=i)return 1;let t=Je.get(e);if(t==null){t=1;for(let s of e.children){if(s.type!=i||!(s instanceof v)){t=1;break}t+=me(i,s)}Je.set(e,t)}return t}function Ae(i,e,t,s,r,o,n,h,l){let a=0;for(let g=s;g<r;g++)a+=me(i,e[g]);let f=Math.ceil(a*1.5/8),u=[],c=[];function p(g,W,H,X,Z){for(let R=H;R<X;){let w=R,O=W[R],d=me(i,g[R]);for(R++;R<X;R++){let b=me(i,g[R]);if(d+b>=f)break;d+=b}if(R==w+1){if(d>f){let b=g[w];p(b.children,b.positions,0,b.children.length,W[w]+Z);continue}u.push(g[w])}else{let b=W[R-1]+g[R-1].length-O;u.push(Ae(i,g,W,w,R,O,b,null,l))}c.push(O+Z-o)}}return p(e,t,s,r,0),(h||l)(u,c,n)}var ke=class{startParse(e,t,s){return typeof e=="string"&&(e=new Re(e)),s=s?s.length?s.map(r=>new ue(r.from,r.to)):[new ue(0,0)]:[new ue(0,e.length)],this.createParse(e,t||[],s)}parse(e,t,s){let r=this.startParse(e,t,s);for(;;){let o=r.advance();if(o)return o}}},Re=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var xs=new k({perNode:!0});var oe=class{constructor(e,t,s,r,o,n,h,l,a,f=0,u){this.p=e,this.stack=t,this.state=s,this.reducePos=r,this.pos=o,this.score=n,this.buffer=h,this.bufferBase=l,this.curContext=a,this.lookAhead=f,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,s=0){let r=e.parser.context;return new oe(e,[],t,s,s,0,[],0,r?new we(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let s=e>>19,r=e&65535,{parser:o}=this.p,n=o.dynamicPrecedence(r);if(n&&(this.score+=n),s==0){this.pushState(o.getGoto(this.state,r,!0),this.reducePos),r<o.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,4,!0),this.reduceContext(r,this.reducePos);return}let h=this.stack.length-(s-1)*3-(e&262144?6:0),l=h?this.stack[h-2]:this.p.ranges[0].from,a=this.reducePos-l;a>=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=a):this.p.lastBigReductionSize<a&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=a));let f=h?this.stack[h-1]:0,u=this.bufferBase+this.buffer.length-f;if(r<o.minRepeatTerm||e&131072){let c=o.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,l,c,u+4,!0)}if(e&262144)this.state=this.stack[h];else{let c=this.stack[h-3];this.state=o.getGoto(c,r,!0)}for(;this.stack.length>h;)this.stack.pop();this.reduceContext(r,l)}storeNode(e,t,s,r=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let n=this,h=this.buffer.length;if(h==0&&n.parent&&(h=n.bufferBase-n.parent.bufferBase,n=n.parent),h>0&&n.buffer[h-4]==0&&n.buffer[h-1]>-1){if(t==s)return;if(n.buffer[h-2]>=t){n.buffer[h-2]=s;return}}}if(!o||this.pos==s)this.buffer.push(e,t,s,r);else{let n=this.buffer.length;if(n>0&&this.buffer[n-4]!=0)for(;n>0&&this.buffer[n-2]>s;)this.buffer[n]=this.buffer[n-4],this.buffer[n+1]=this.buffer[n-3],this.buffer[n+2]=this.buffer[n-2],this.buffer[n+3]=this.buffer[n-1],n-=4,r>4&&(r-=4);this.buffer[n]=e,this.buffer[n+1]=t,this.buffer[n+2]=s,this.buffer[n+3]=r}}shift(e,t,s){let r=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=s,this.shiftContext(t,r),t<=this.p.parser.maxNode&&this.buffer.push(t,r,s,4);else{let o=e,{parser:n}=this.p;(s>this.pos||t<=n.maxNode)&&(this.pos=s,n.stateFlag(o,1)||(this.reducePos=s)),this.pushState(o,r),this.shiftContext(t,r),t<=n.maxNode&&this.buffer.push(t,r,s,4)}}apply(e,t,s){e&65536?this.reduce(e):this.shift(e,t,s)}useNode(e,t){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=e)&&(this.p.reused.push(e),s++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(s,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let s=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new oe(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let s=e<=this.p.parser.maxNode;s&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,s?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Ve(this);;){let s=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(s==0)return!1;if(!(s&65536))return!0;t.reduce(s)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>4<<1||this.stack.length>=120){let r=[];for(let o=0,n;o<t.length;o+=2)(n=t[o+1])!=this.state&&this.p.parser.hasAction(n,e)&&r.push(t[o],n);if(this.stack.length<120)for(let o=0;r.length<4<<1&&o<t.length;o+=2){let n=t[o+1];r.some((h,l)=>l&1&&h==n)||r.push(t[o],n)}t=r}let s=[];for(let r=0;r<t.length&&s.length<4;r+=2){let o=t[r+1];if(o==this.state)continue;let n=this.split();n.pushState(o,this.pos),n.storeNode(0,n.pos,n.pos,4,!0),n.shiftContext(t[r],this.pos),n.score-=200,s.push(n)}return s}forceReduce(){let e=this.p.parser.stateSlot(this.state,5);if(!(e&65536))return!1;let{parser:t}=this.p;if(!t.validAction(this.state,e)){let s=e>>19,r=e&65535,o=this.stack.length-s*3;if(o<0||t.getGoto(this.stack[o],r,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.reducePos,this.reducePos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.reducePos,this.reducePos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new we(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},we=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},st;(function(i){i[i.Insert=200]="Insert",i[i.Delete=190]="Delete",i[i.Reduce=100]="Reduce",i[i.MaxNext=4]="MaxNext",i[i.MaxInsertStackDepth=300]="MaxInsertStackDepth",i[i.DampenInsertStackDepth=120]="DampenInsertStackDepth",i[i.MinBigReduction=2e3]="MinBigReduction"})(st||(st={}));var Ve=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,s=e>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},he=class{constructor(e,t,s){this.stack=e,this.pos=t,this.index=s,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new he(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new he(this.stack,this.pos,this.index)}};function ce(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let s=0,r=0;s<i.length;){let o=0;for(;;){let n=i.charCodeAt(s++),h=!1;if(n==126){o=65535;break}n>=92&&n--,n>=34&&n--;let l=n-32;if(l>=46&&(l-=46,h=!0),o+=l,h)break;o*=46}t?t[r++]=o:t=new e(o)}return t}var ne=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},rt=new ne,Ie=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=rt,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let s=this.range,r=this.rangeIndex,o=this.pos+e;for(;o<s.from;){if(!r)return null;let n=this.ranges[--r];o-=s.from-n.to,s=n}for(;t<0?o>s.to:o>=s.to;){if(r==this.ranges.length-1)return null;let n=this.ranges[++r];o+=n.from-s.to,s=n}return o}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,s,r;if(t>=0&&t<this.chunk.length)s=this.pos+e,r=this.chunk.charCodeAt(t);else{let o=this.resolveOffset(e,1);if(o==null)return-1;if(s=o,s>=this.chunk2Pos&&s<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(s-this.chunk2Pos);else{let n=this.rangeIndex,h=this.range;for(;h.to<=s;)h=this.ranges[++n];this.chunk2=this.input.chunk(this.chunk2Pos=s),s+this.chunk2.length>h.to&&(this.chunk2=this.chunk2.slice(0,h.to-s)),r=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),r}acceptToken(e,t=0){let s=t?this.resolveOffset(t,-1):this.pos;if(s==null||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=s}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=rt,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let s="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(s+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return s}},$=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:s}=t.p;ut(this.data,e,t,this.id,s.data,s.tokenPrecTable)}};$.prototype.contextual=$.prototype.fallback=$.prototype.extend=!1;var Fe=class{constructor(e,t,s){this.precTable=t,this.elseToken=s,this.data=typeof e=="string"?ce(e):e}token(e,t){let s=e.pos,r=0;for(;ut(this.data,e,t,0,this.data,this.precTable),!(e.token.value>-1);){if(this.elseToken==null)return;if(e.next<0)break;e.advance(),e.reset(e.pos,e.token),r++}r&&(e.reset(s,e.token),e.acceptToken(this.elseToken,r))}};Fe.prototype.contextual=$.prototype.fallback=$.prototype.extend=!1;function ut(i,e,t,s,r,o){let n=0,h=1<<s,{dialect:l}=t.p.parser;e:for(;h&i[n];){let a=i[n+1];for(let p=n+3;p<a;p+=2)if((i[p+1]&h)>0){let g=i[p];if(l.allows(g)&&(e.token.value==-1||e.token.value==g||Dt(g,e.token.value,r,o))){e.acceptToken(g);break}}let f=e.next,u=0,c=i[n+2];if(e.next<0&&c>u&&i[a+c*3-3]==65535&&i[a+c*3-3]==65535){n=i[a+c*3-1];continue e}for(;u<c;){let p=u+c>>1,g=a+p+(p<<1),W=i[g],H=i[g+1]||65536;if(f<W)c=p;else if(f>=H)u=p+1;else{n=i[g+2],e.advance();continue e}}break}}function it(i,e,t){for(let s=e,r;(r=i[s])!=65535;s++)if(r==t)return s-e;return-1}function Dt(i,e,t,s){let r=it(t,s,e);return r<0||it(t,s,i)<r}var D=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),Te=null,nt;(function(i){i[i.Margin=25]="Margin"})(nt||(nt={}));function ot(i,e,t){let s=i.cursor(S.IncludeAnonymous);for(s.moveTo(e);;)if(!(t<0?s.childBefore(e):s.childAfter(e)))for(;;){if((t<0?s.to<e:s.from>e)&&!s.type.isError)return t<0?Math.max(0,Math.min(s.to-1,e-25)):Math.min(i.length,Math.max(s.from+1,e+25));if(t<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return t<0?0:i.length}}var De=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?ot(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?ot(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let s=this.trees[t],r=this.index[t];if(r==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let o=s.children[r],n=this.start[t]+s.positions[r];if(n>e)return this.nextStart=n,null;if(o instanceof v){if(n==e){if(n<this.safeFrom)return null;let h=n+o.length;if(h<=this.safeTo){let l=o.prop(k.lookAhead);if(!l||h+l<this.fragment.to)return o}}this.index[t]++,n+o.length>=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(n),this.index.push(0))}else this.index[t]++,this.nextStart=n+o.length}}},Ne=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(s=>new ne)}getActions(e){let t=0,s=null,{parser:r}=e.p,{tokenizers:o}=r,n=r.stateSlot(e.state,3),h=e.curContext?e.curContext.hash:0,l=0;for(let a=0;a<o.length;a++){if(!(1<<a&n))continue;let f=o[a],u=this.tokens[a];if(!(s&&!f.fallback)&&((f.contextual||u.start!=e.pos||u.mask!=n||u.context!=h)&&(this.updateCachedToken(u,f,e),u.mask=n,u.context=h),u.lookAhead>u.end+25&&(l=Math.max(u.lookAhead,l)),u.value!=0)){let c=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!f.extend&&(s=u,t>c))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!s&&e.pos==this.stream.end&&(s=new ne,s.value=e.p.parser.eofTerm,s.start=s.end=e.pos,t=this.addActions(e,s.value,s.end,t)),this.mainToken=s,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new ne,{pos:s,p:r}=e;return t.start=s,t.end=Math.min(s+1,r.stream.end),t.value=s==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,s){let r=this.stream.clipPos(s.pos);if(t.token(this.stream.reset(r,e),s),e.value>-1){let{parser:o}=s.p;for(let n=0;n<o.specialized.length;n++)if(o.specialized[n]==e.value){let h=o.specializers[n](this.stream.read(e.start,e.end),s);if(h>=0&&s.p.parser.dialect.allows(h>>1)){h&1?e.extended=h>>1:e.value=h>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,s,r){for(let o=0;o<r;o+=3)if(this.actions[o]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=s,r}addActions(e,t,s,r){let{state:o}=e,{parser:n}=e.p,{data:h}=n;for(let l=0;l<2;l++)for(let a=n.stateSlot(o,l?2:1);;a+=3){if(h[a]==65535)if(h[a+1]==1)a=U(h,a+2);else{r==0&&h[a+1]==2&&(r=this.putAction(U(h,a+2),t,s,r));break}h[a]==t&&(r=this.putAction(U(h,a+1),t,s,r))}return r}},ht;(function(i){i[i.Distance=5]="Distance",i[i.MaxRemainingPerStep=3]="MaxRemainingPerStep",i[i.MinBufferLengthPrune=500]="MinBufferLengthPrune",i[i.ForceReduceLimit=10]="ForceReduceLimit",i[i.CutDepth=15e3]="CutDepth",i[i.CutTo=9e3]="CutTo",i[i.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",i[i.MaxStackCount=12]="MaxStackCount"})(ht||(ht={}));var Qe=class{constructor(e,t,s,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Ie(t,r),this.tokens=new Ne(e,this.stream),this.topTerm=e.top[1];let{from:o}=r[0];this.stacks=[oe.start(this,e.top[0],o)],this.fragments=s.length&&this.stream.end-o>e.bufferLength*4?new De(s,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,s=this.stacks=[],r,o;if(this.bigReductionCount>300&&e.length==1){let[n]=e;for(;n.forceReduce()&&n.stack.length&&n.stack[n.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let n=0;n<e.length;n++){let h=e[n];for(;;){if(this.tokens.mainToken=null,h.pos>t)s.push(h);else{if(this.advanceStack(h,s,e))continue;{r||(r=[],o=[]),r.push(h);let l=this.tokens.getMainToken(h);o.push(l.value,l.end)}}break}}if(!s.length){let n=r&&Nt(r);if(n)return this.stackToTree(n);if(this.parser.strict)throw D&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let n=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,o,s);if(n)return this.stackToTree(n.forceAll())}if(this.recovering){let n=this.recovering==1?1:this.recovering*3;if(s.length>n)for(s.sort((h,l)=>l.score-h.score);s.length>n;)s.pop();s.some(h=>h.reducePos>t)&&this.recovering--}else if(s.length>1){e:for(let n=0;n<s.length-1;n++){let h=s[n];for(let l=n+1;l<s.length;l++){let a=s[l];if(h.sameState(a)||h.buffer.length>500&&a.buffer.length>500)if((h.score-a.score||h.buffer.length-a.buffer.length)>0)s.splice(l--,1);else{s.splice(n--,1);continue e}}}s.length>12&&s.splice(12,s.length-12)}this.minStackPos=s[0].pos;for(let n=1;n<s.length;n++)s[n].pos<this.minStackPos&&(this.minStackPos=s[n].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,s){let r=e.pos,{parser:o}=this,n=D?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let a=e.curContext&&e.curContext.tracker.strict,f=a?e.curContext.hash:0;for(let u=this.fragments.nodeAt(r);u;){let c=this.parser.nodeSet.types[u.type.id]==u.type?o.getGoto(e.state,u.type.id):-1;if(c>-1&&u.length&&(!a||(u.prop(k.contextHash)||0)==f))return e.useNode(u,c),D&&console.log(n+this.stackID(e)+` (via reuse of ${o.getName(u.type.id)})`),!0;if(!(u instanceof v)||u.children.length==0||u.positions[0]>0)break;let p=u.children[0];if(p instanceof v&&u.positions[0]==0)u=p;else break}}let h=o.stateSlot(e.state,4);if(h>0)return e.reduce(h),D&&console.log(n+this.stackID(e)+` (via always-reduce ${o.getName(h&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let a=0;a<l.length;){let f=l[a++],u=l[a++],c=l[a++],p=a==l.length||!s,g=p?e:e.split();if(g.apply(f,u,c),D&&console.log(n+this.stackID(g)+` (via ${f&65536?`reduce of ${o.getName(f&65535)}`:"shift"} for ${o.getName(u)} @ ${r}${g==e?"":", split"})`),p)return!0;g.pos>r?t.push(g):s.push(g)}return!1}advanceFully(e,t){let s=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>s)return lt(e,t),!0}}runRecovery(e,t,s){let r=null,o=!1;for(let n=0;n<e.length;n++){let h=e[n],l=t[n<<1],a=t[(n<<1)+1],f=D?this.stackID(h)+" -> ":"";if(h.deadEnd&&(o||(o=!0,h.restart(),D&&console.log(f+this.stackID(h)+" (restarted)"),this.advanceFully(h,s))))continue;let u=h.split(),c=f;for(let p=0;u.forceReduce()&&p<10&&(D&&console.log(c+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,s));p++)D&&(c=this.stackID(u)+" -> ");for(let p of h.recoverByInsert(l))D&&console.log(f+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,s);this.stream.end>h.pos?(a==h.pos&&(a++,l=0),h.recoverByDelete(l,a),D&&console.log(f+this.stackID(h)+` (via recover-delete ${this.parser.getName(l)})`),lt(h,s)):(!r||r.score<h.score)&&(r=h)}return r}stackToTree(e){return e.close(),v.build({buffer:he.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(Te||(Te=new WeakMap)).get(e);return t||Te.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function lt(i,e){for(let t=0;t<e.length;t++){let s=e[t];if(s.pos==i.pos&&s.sameState(i)){e[t].score<i.score&&(e[t]=i);return}}e.push(i)}var _e=class{constructor(e,t,s){this.source=e,this.flags=t,this.disabled=s}allows(e){return!this.disabled||this.disabled[e]==0}};var q=class extends ke{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let h=0;h<e.repeatNodeCount;h++)t.push("");let s=Object.keys(e.topRules).map(h=>e.topRules[h][1]),r=[];for(let h=0;h<t.length;h++)r.push([]);function o(h,l,a){r[h].push([l,l.deserialize(String(a))])}if(e.nodeProps)for(let h of e.nodeProps){let l=h[0];typeof l=="string"&&(l=k[l]);for(let a=1;a<h.length;){let f=h[a++];if(f>=0)o(f,l,h[a++]);else{let u=h[a+-f];for(let c=-f;c>0;c--)o(h[a++],l,u);a++}}}this.nodeSet=new se(t.map((h,l)=>A.define({name:l>=this.minRepeatTerm?void 0:h,id:l,props:r[l],top:s.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let n=ce(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let h=0;h<this.specializerSpecs.length;h++)this.specialized[h]=this.specializerSpecs[h].term;this.specializers=this.specializerSpecs.map(at),this.states=ce(e.states,Uint32Array),this.data=ce(e.stateData),this.goto=ce(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(h=>typeof h=="number"?new $(n,h):h),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,s){let r=new Qe(this,e,t,s);for(let o of this.wrappers)r=o(r,e,t,s);return r}getGoto(e,t,s=!1){let r=this.goto;if(t>=r[0])return-1;for(let o=r[t+1];;){let n=r[o++],h=n&1,l=r[o++];if(h&&s)return l;for(let a=o+(n>>1);o<a;o++)if(r[o]==e)return l;if(h)return-1}}hasAction(e,t){let s=this.data;for(let r=0;r<2;r++)for(let o=this.stateSlot(e,r?2:1),n;;o+=3){if((n=s[o])==65535)if(s[o+1]==1)n=s[o=U(s,o+2)];else{if(s[o+1]==2)return U(s,o+2);break}if(n==t||n==0)return U(s,o+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){if(t==this.stateSlot(e,4))return!0;for(let s=this.stateSlot(e,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=U(this.data,s+2);else return!1;if(t==U(this.data,s+1))return!0}}nextStates(e){let t=[];for(let s=this.stateSlot(e,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=U(this.data,s+2);else break;if(!(this.data[s+2]&1)){let r=this.data[s+1];t.some((o,n)=>n&1&&o==r)||t.push(this.data[s],r)}}return t}configure(e){let t=Object.assign(Object.create(q.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let s=this.topRules[e.top];if(!s)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=s}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(s=>{let r=e.tokenizers.find(o=>o.from==s);return r?r.to:s})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((s,r)=>{let o=e.specializers.find(h=>h.from==s.external);if(!o)return s;let n=Object.assign(Object.assign({},s),{external:o.to});return t.specializers[r]=at(n),n})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),s=t.map(()=>!1);if(e)for(let o of e.split(" ")){let n=t.indexOf(o);n>=0&&(s[n]=!0)}let r=null;for(let o=0;o<t.length;o++)if(!s[o])for(let n=this.dialects[t[o]],h;(h=this.data[n++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[h]=1;return new _e(e,s,r)}static deserialize(e){return new q(e)}};function U(i,e){return i[e]|i[e+1]<<16}function Nt(i){let e=null;for(let t of i){let s=t.p.stoppedAt;(t.pos==t.p.stream.end||s!=null&&t.pos>s)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function at(i){if(i.external){let e=i.extend?1:0;return(t,s)=>i.external(t,s)<<1|e}return i.get}var Ee=q.deserialize({version:14,states:"%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",stateData:"#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",goto:"#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",nodeNames:"\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:"6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",tokenizers:[0,1],topRules:{Filter:[0,1]},tokenPrec:0});var E=require("@vuu-ui/vuu-utils");var T,Le=class{constructor(){Ye(this,T,void 0)}setFilterCombinatorOp(e,t=N(this,T)){(0,E.isMultiClauseFilter)(t)&&t.op===e||Pe(this,T,{op:e,filters:[N(this,T)]})}add(e){if(N(this,T)===void 0)Pe(this,T,e);else if((0,E.isMultiClauseFilter)(N(this,T)))N(this,T).filters.push(e);else throw Error("Invalid filter passed to FilterExpression")}setColumn(e,t=N(this,T)){if((0,E.isMultiClauseFilter)(t)){let s=t.filters.at(-1);s&&this.setColumn(e,s)}else t&&(t.column=e)}setOp(e,t=N(this,T)){if((0,E.isMultiClauseFilter)(t)){let s=t.filters.at(-1);s&&this.setOp(e,s)}else t&&(t.op=e)}setValue(e,t=N(this,T)){var s;if((0,E.isMultiClauseFilter)(t)){let r=t.filters.at(-1);r&&this.setValue(e,r)}else(0,E.isMultiValueFilter)(t)?((s=t.values)!=null||(t.values=[]),t.values.push(e)):(0,E.isSingleValueFilter)(t)&&(t.value=e)}toJSON(e=N(this,T)){return this.name?{...e,name:this.name}:e}};T=new WeakMap;var ze=(i,e)=>{let t=new Le,s=i.cursor();do{let{name:r,from:o,to:n}=s;switch(r){case"ColumnValueExpression":t.add({});break;case"ColumnSetExpression":t.add({op:"in"});break;case"Or":case"And":t.setFilterCombinatorOp(e.substring(o,n));break;case"Column":t.setColumn(e.substring(o,n));break;case"Operator":t.setOp(e.substring(o,n));break;case"String":t.setValue(e.substring(o+1,n-1));break;case"Number":t.setValue(parseFloat(e.substring(o,n)));break;case"True":t.setValue(!0);break;case"False":t.setValue(!1);break;case"FilterName":t.name=e.substring(o,n);break;default:}}while(s.next());return t.toJSON()};var Qt=Ee.configure({strict:!0}),Be=i=>{let e=Qt.parse(i);return ze(e,i)};var ft=new Map,_t=()=>!1,Ue=(i,e)=>{let t=ft.get(e);if(t)return t;try{let s=Be(e);return t=We(i,s),ft.set(e,t),t}catch{return console.warn(`filter-evaluation-utils, failed to parse filter "${e}"`),_t}};function We(i,e){switch(e.op){case"in":return Et(i,e);case"=":return Lt(i,e);case">":return zt(i,e);case">=":return Bt(i,e);case"<":return Ut(i,e);case"<=":return Wt(i,e);case"starts":return jt(i,e);case"and":return Gt(i,e);case"or":return $t(i,e);default:return console.log(`unrecognized filter type ${e.op}`),()=>!0}}var Et=(i,e)=>t=>e.values.indexOf(t[i[e.column]])!==-1,Lt=(i,e)=>t=>t[i[e.column]]===e.value,zt=(i,e)=>t=>t[i[e.column]]>e.value,Bt=(i,e)=>t=>t[i[e.column]]>=e.value,Ut=(i,e)=>t=>t[i[e.column]]<e.value,Wt=(i,e)=>t=>t[i[e.column]]<=e.value,jt=(i,e)=>{let t=e.value;if(typeof t!="string")throw Error("string filter applied to value of wrong type");return s=>{let r=s[i[e.column]];if(typeof r!="string")throw Error("string filter applied to value of wrong type");return r.toLowerCase().startsWith(t.toLowerCase())}},Gt=(i,e)=>{let t=e.filters.map(s=>We(i,s));return s=>t.every(r=>r(s))};function $t(i,e){let t=e.filters.map(s=>We(i,s));return s=>t.some(r=>r(s))}var le=require("@vuu-ui/vuu-utils"),je=require("react"),Xt="addRowsFromInstruments",{KEY:ct}=le.metadataKeys,Yt={},pt=i=>i.type==="vuu-links",qt=i=>i.type==="vuu-link-created",Ht=i=>i.type==="vuu-link-removed",dt=i=>i.type==="vuu-menu",Zt=i=>dt(i)||pt(i),Kt=i=>i.type==="vuu-link-created"||i.type==="vuu-link-removed",Jt=i=>"rpcName"in i,es=i=>"menus"in i,ts=i=>i.name==="ROOT",gt=i=>i.context==="cell",ss=i=>i.context==="row",rs=i=>i.context==="selected-rows",is=(i,e,t=0)=>{switch(i){case"grid":return e==="selected-rows"?t>0:!0;case"header":return e==="grid";default:return!1}},ns=(i,e,t,s,r)=>{if(i==="cell"||i==="row")return Ue(r,s)(e);if(i==="selected-rows"){if(t.length===0)return!1;{let o=Ue(r,s);return t.every(o)}}return!0},os=i=>{let{rpcName:e}=i;return gt(i)?{field:i.field,rowKey:i.rowKey,rpcName:e,value:i.value,type:"VIEW_PORT_MENU_CELL_RPC"}:ss(i)?{rowKey:i.rowKey,row:i.row,rpcName:e,type:"VIEW_PORT_MENU_ROW_RPC"}:rs(i)?{rpcName:e,type:"VIEW_PORT_MENUS_SELECT_RPC"}:{rpcName:e,type:"VIEW_PORT_MENU_TABLE_RPC"}},hs=({filter:i})=>typeof i=="string"&&i.length>0,ls=(i,e)=>{switch(i.context){case"cell":return{...i,field:e.columnName,rowKey:e.row[ct],value:e.row[e.columnMap[e.columnName]]};case"row":return{...i,row:(0,le.getRowRecord)(e.row,e.columnMap),rowKey:e.row[ct]};default:return i}},mt=(i,e,t)=>{var s;return es(i)?i.menus.some(r=>mt(r,e,t)):is(e,i.context,(s=t.selectedRows)==null?void 0:s.length)?e==="grid"&&hs(i)?ns(i.context,t.row,t.selectedRows,i.filter,t.columnMap):gt(i)&&i.field!=="*"?i.field===t.columnName:!0:!1},bt=(i,e,t)=>{if(mt(i,e,t)){if(Jt(i))return{label:i.name,action:"MENU_RPC_CALL",options:ls(i,t)};{let s=i.menus.map(r=>bt(r,e,t)).filter(r=>r!==void 0);if(s.length>0)return{label:i.name,children:s}}}},as=({dataSource:i,menuActionConfig:e=Yt,onRpcResponse:t})=>{let s=(0,je.useCallback)((o,n)=>{let{visualLink:h,visualLinks:l,vuuMenu:a}=e,f=[];if(o==="grid"&&l&&!h&&l.forEach(u=>{let{link:c,label:p}=u,g=p||c.toTable;f.push({label:`Link to ${g}`,action:"link-table",options:u})}),a){let u=bt(a,o,n);ts(a)&&(0,le.isGroupMenuItemDescriptor)(u)?f.push(...u.children):u&&f.push(u)}return f},[e]),r=(0,je.useCallback)((o,n)=>{if(o==="MENU_RPC_CALL"){let h=os(n);return i.menuRpcCall(h).then(l=>{t&&l&&t&&t(l)}),!0}else{if(o==="link-table")return i.visualLink=n,!0;console.log(`useViewServer handleMenuAction, can't handle action type ${o}`)}return!1},[i,t]);return{buildViewserverMenuOptions:s,handleMenuAction:r}};var ae=require("react"),xt=require("@vuu-ui/vuu-data"),us=()=>{let[i,e]=(0,ae.useState)(),t=(0,ae.useCallback)(s=>{let r=new Map;return s.forEach(o=>{r.set(o.table.table,o)}),r},[]);return(0,ae.useEffect)(()=>{async function s(){let r=await(0,xt.getServerAPI)(),{tables:o}=await r.getTableList(),n=t(await Promise.all(o.map(h=>r.getTableSchema(h))));e(n)}s()},[t]),i};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|