@krumio/trailhand-ui 1.10.1 → 1.11.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/dist/components/data-table/data-table.d.ts +8 -12
- package/dist/components/data-table/data-table.d.ts.map +1 -1
- package/dist/components/data-table/data-table.js +19 -116
- package/dist/components/data-table/data-table.js.map +1 -1
- package/dist/components/dock/dock.d.ts +70 -0
- package/dist/components/dock/dock.d.ts.map +1 -0
- package/dist/components/dock/dock.js +423 -0
- package/dist/components/dock/dock.js.map +1 -0
- package/dist/components/dock/index.d.ts +3 -0
- package/dist/components/dock/index.d.ts.map +1 -0
- package/dist/components/dock/index.js +2 -0
- package/dist/components/dock/index.js.map +1 -0
- package/dist/components/icon/icon.d.ts +4 -1
- package/dist/components/icon/icon.d.ts.map +1 -1
- package/dist/components/icon/icon.js +4 -1
- package/dist/components/icon/icon.js.map +1 -1
- package/dist/components/icon/index.d.ts +1 -0
- package/dist/components/icon/index.d.ts.map +1 -1
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.d.ts.map +1 -0
- package/dist/components/pagination/index.js +2 -0
- package/dist/components/pagination/index.js.map +1 -0
- package/dist/components/pagination/pagination.d.ts +66 -0
- package/dist/components/pagination/pagination.d.ts.map +1 -0
- package/dist/components/pagination/pagination.js +221 -0
- package/dist/components/pagination/pagination.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/debounce.d.ts +6 -0
- package/dist/utils/debounce.d.ts.map +1 -0
- package/dist/utils/debounce.js +25 -0
- package/dist/utils/debounce.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, html, css } from 'lit';
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
|
+
import 'iconify-icon';
|
|
10
|
+
import { addIcon } from 'iconify-icon';
|
|
11
|
+
import chevronLeft from '@iconify/icons-heroicons/chevron-left-20-solid';
|
|
12
|
+
import chevronRight from '@iconify/icons-heroicons/chevron-right-20-solid';
|
|
13
|
+
// Pre-load icons to avoid CDN delay
|
|
14
|
+
addIcon('heroicons:chevron-left-20-solid', chevronLeft);
|
|
15
|
+
addIcon('heroicons:chevron-right-20-solid', chevronRight);
|
|
16
|
+
/**
|
|
17
|
+
* A reusable pagination control: previous/next buttons, a "current / total"
|
|
18
|
+
* page indicator, and an optional "start-end of total" info string.
|
|
19
|
+
*
|
|
20
|
+
* This component does not track page state itself.
|
|
21
|
+
* The consumer passes `current-page` / `total-pages` (and, if `show-info`
|
|
22
|
+
* is enabled, the item-range props) and listens for the `page-change`
|
|
23
|
+
* event to apply the new page.
|
|
24
|
+
*
|
|
25
|
+
* @fires page-change - Detail: `{ page: number }`. Fired when the user
|
|
26
|
+
* clicks the previous or next button with a valid target page. The
|
|
27
|
+
* consumer owns page state and is responsible for applying it (and, for
|
|
28
|
+
* server-side pagination, fetching the corresponding data).
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```html
|
|
32
|
+
* <trailhand-pagination
|
|
33
|
+
* current-page="2"
|
|
34
|
+
* total-pages="8"
|
|
35
|
+
* start-item="11"
|
|
36
|
+
* end-item="20"
|
|
37
|
+
* total-items="76"
|
|
38
|
+
* @page-change=${(e) => this.goToPage(e.detail.page)}
|
|
39
|
+
* ></trailhand-pagination>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class Pagination extends LitElement {
|
|
43
|
+
constructor() {
|
|
44
|
+
super(...arguments);
|
|
45
|
+
/** The current page number (1-indexed). */
|
|
46
|
+
this.currentPage = 1;
|
|
47
|
+
/** Total number of pages. */
|
|
48
|
+
this.totalPages = 1;
|
|
49
|
+
/** First item index (1-indexed) shown on the current page. Used in the info text. */
|
|
50
|
+
this.startItem = 0;
|
|
51
|
+
/** Last item index (1-indexed) shown on the current page. Used in the info text. */
|
|
52
|
+
this.endItem = 0;
|
|
53
|
+
/** Total number of items across all pages. Used in the info text. */
|
|
54
|
+
this.totalItems = 0;
|
|
55
|
+
/** Whether to show the "start-end of total" info text. */
|
|
56
|
+
this.showInfo = true;
|
|
57
|
+
/** Disables both buttons, e.g. while a page fetch is in flight. */
|
|
58
|
+
this.disabled = false;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Emit a `page-change` event for the given target page.
|
|
62
|
+
* @param page - The page number to request.
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
_emitPageChange(page) {
|
|
66
|
+
this.dispatchEvent(new CustomEvent('page-change', {
|
|
67
|
+
detail: { page },
|
|
68
|
+
bubbles: true,
|
|
69
|
+
composed: true,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
_handlePrev() {
|
|
73
|
+
if (this.currentPage > 1 && !this.disabled) {
|
|
74
|
+
this._emitPageChange(this.currentPage - 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
_handleNext() {
|
|
78
|
+
if (this.currentPage < this.totalPages && !this.disabled) {
|
|
79
|
+
this._emitPageChange(this.currentPage + 1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
_renderChevronLeft() {
|
|
83
|
+
return html `
|
|
84
|
+
<iconify-icon
|
|
85
|
+
class="pagination__icon"
|
|
86
|
+
icon="heroicons:chevron-left-20-solid"
|
|
87
|
+
></iconify-icon>
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
_renderChevronRight() {
|
|
91
|
+
return html `
|
|
92
|
+
<iconify-icon
|
|
93
|
+
class="pagination__icon"
|
|
94
|
+
icon="heroicons:chevron-right-20-solid"
|
|
95
|
+
></iconify-icon>
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
render() {
|
|
99
|
+
return html `
|
|
100
|
+
<div class="pagination">
|
|
101
|
+
${this.showInfo
|
|
102
|
+
? html `
|
|
103
|
+
<div class="pagination__info">
|
|
104
|
+
${this.startItem}-${this.endItem} of ${this.totalItems}
|
|
105
|
+
</div>
|
|
106
|
+
`
|
|
107
|
+
: ''}
|
|
108
|
+
<div class="pagination__controls">
|
|
109
|
+
<button
|
|
110
|
+
class="pagination__btn"
|
|
111
|
+
?disabled=${this.currentPage === 1 || this.disabled}
|
|
112
|
+
@click=${this._handlePrev}
|
|
113
|
+
aria-label="Previous page"
|
|
114
|
+
>
|
|
115
|
+
${this._renderChevronLeft()}
|
|
116
|
+
</button>
|
|
117
|
+
|
|
118
|
+
<span class="pagination__current">
|
|
119
|
+
${this.currentPage} / ${this.totalPages}
|
|
120
|
+
</span>
|
|
121
|
+
|
|
122
|
+
<button
|
|
123
|
+
class="pagination__btn"
|
|
124
|
+
?disabled=${this.currentPage === this.totalPages || this.disabled}
|
|
125
|
+
@click=${this._handleNext}
|
|
126
|
+
aria-label="Next page"
|
|
127
|
+
>
|
|
128
|
+
${this._renderChevronRight()}
|
|
129
|
+
</button>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
Pagination.styles = css `
|
|
136
|
+
:host {
|
|
137
|
+
display: block;
|
|
138
|
+
font-family: var(--font-family, 'Poppins', sans-serif);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.pagination {
|
|
142
|
+
display: flex;
|
|
143
|
+
justify-content: space-between;
|
|
144
|
+
align-items: center;
|
|
145
|
+
padding: 1rem 0;
|
|
146
|
+
gap: 1rem;
|
|
147
|
+
flex-wrap: wrap;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.pagination__info {
|
|
151
|
+
color: var(--muted, var(--th-color-text-muted, #8D8D8D));
|
|
152
|
+
font-size: 13px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.pagination__controls {
|
|
156
|
+
display: flex;
|
|
157
|
+
align-items: center;
|
|
158
|
+
gap: 1rem;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.pagination__current {
|
|
162
|
+
color: var(--body-text, var(--th-color-text-primary, #212121));
|
|
163
|
+
font-size: 13px;
|
|
164
|
+
min-width: 60px;
|
|
165
|
+
text-align: center;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.pagination__btn {
|
|
169
|
+
display: flex;
|
|
170
|
+
align-items: center;
|
|
171
|
+
justify-content: center;
|
|
172
|
+
width: 32px;
|
|
173
|
+
height: 32px;
|
|
174
|
+
padding: 0;
|
|
175
|
+
border: 1px solid var(--border, var(--th-color-border, #D7D7D7));
|
|
176
|
+
border-radius: 4px;
|
|
177
|
+
background-color: var(--body-bg, var(--th-color-white, #FFFFFF));
|
|
178
|
+
color: var(--body-text, var(--th-color-text-primary, #212121));
|
|
179
|
+
cursor: pointer;
|
|
180
|
+
transition: all 0.2s;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.pagination__btn:hover:not(:disabled) {
|
|
184
|
+
background-color: var(--sortable-table-row-hover-bg, var(--th-color-grey-100, #FAFAFA));
|
|
185
|
+
border-color: var(--link, var(--th-color-primary, #3d98d3));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.pagination__btn:disabled {
|
|
189
|
+
opacity: 0.4;
|
|
190
|
+
cursor: not-allowed;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.pagination__icon {
|
|
194
|
+
width: 16px;
|
|
195
|
+
height: 16px;
|
|
196
|
+
}
|
|
197
|
+
`;
|
|
198
|
+
__decorate([
|
|
199
|
+
property({ type: Number, attribute: 'current-page' })
|
|
200
|
+
], Pagination.prototype, "currentPage", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
property({ type: Number, attribute: 'total-pages' })
|
|
203
|
+
], Pagination.prototype, "totalPages", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
property({ type: Number, attribute: 'start-item' })
|
|
206
|
+
], Pagination.prototype, "startItem", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
property({ type: Number, attribute: 'end-item' })
|
|
209
|
+
], Pagination.prototype, "endItem", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
property({ type: Number, attribute: 'total-items' })
|
|
212
|
+
], Pagination.prototype, "totalItems", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
property({ type: Boolean, attribute: 'show-info' })
|
|
215
|
+
], Pagination.prototype, "showInfo", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
property({ type: Boolean })
|
|
218
|
+
], Pagination.prototype, "disabled", void 0);
|
|
219
|
+
// Register the element
|
|
220
|
+
customElements.define('trailhand-pagination', Pagination);
|
|
221
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../../src/components/pagination/pagination.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,WAAW,MAAM,gDAAgD,CAAC;AACzE,OAAO,YAAY,MAAM,iDAAiD,CAAC;AAY3E,oCAAoC;AACpC,OAAO,CAAC,iCAAiC,EAAE,WAAW,CAAC,CAAC;AACxD,OAAO,CAAC,kCAAkC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AAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACX;AAqJnB,uBAAuB;AACvB,cAAc,CAAC,MAAM,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,5 +16,7 @@ export * from './components/dropdown';
|
|
|
16
16
|
export * from './components/code-editor';
|
|
17
17
|
export * from './components/text-area';
|
|
18
18
|
export * from './components/loading-spinner';
|
|
19
|
+
export * from './components/pagination';
|
|
20
|
+
export * from './components/dock';
|
|
19
21
|
export * from './utils';
|
|
20
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,8 @@ export * from './components/dropdown';
|
|
|
17
17
|
export * from './components/code-editor';
|
|
18
18
|
export * from './components/text-area';
|
|
19
19
|
export * from './components/loading-spinner';
|
|
20
|
+
export * from './components/pagination';
|
|
21
|
+
export * from './components/dock';
|
|
20
22
|
// Export utilities
|
|
21
23
|
export * from './utils';
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAElC,mBAAmB;AACnB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/utils/debounce.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI;IAC3D,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC/B,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CA0B9F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function debounce(fn, wait) {
|
|
2
|
+
let timer = null;
|
|
3
|
+
let lastArgs = null;
|
|
4
|
+
const debounced = ((...args) => {
|
|
5
|
+
lastArgs = args;
|
|
6
|
+
if (timer) {
|
|
7
|
+
clearTimeout(timer);
|
|
8
|
+
}
|
|
9
|
+
timer = setTimeout(() => {
|
|
10
|
+
timer = null;
|
|
11
|
+
fn(...lastArgs);
|
|
12
|
+
}, wait);
|
|
13
|
+
});
|
|
14
|
+
debounced.flush = () => {
|
|
15
|
+
if (timer) {
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
timer = null;
|
|
18
|
+
if (lastArgs) {
|
|
19
|
+
fn(...lastArgs);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return debounced;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../src/utils/debounce.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,QAAQ,CAAqC,EAAK,EAAE,IAAY;IAC9E,IAAI,KAAK,GAAyC,IAAI,CAAC;IACvD,IAAI,QAAQ,GAAyB,IAAI,CAAC;IAE1C,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,IAAmB,EAAE,EAAE;QAC5C,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,KAAK,EAAE,CAAC;YACV,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;QACD,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,KAAK,GAAG,IAAI,CAAC;YACb,EAAE,CAAC,GAAI,QAA0B,CAAC,CAAC;QACrC,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC,CAAiB,CAAC;IAEnB,SAAS,CAAC,KAAK,GAAG,GAAG,EAAE;QACrB,IAAI,KAAK,EAAE,CAAC;YACV,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,GAAG,IAAI,CAAC;YACb,IAAI,QAAQ,EAAE,CAAC;gBACb,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|