@krumio/trailhand-ui 1.4.1

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.
@@ -0,0 +1,321 @@
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, state } from 'lit/decorators.js';
9
+ /**
10
+ * A dropdown action menu component for displaying contextual actions.
11
+ * Typically used in table rows or cards to provide action options.
12
+ */
13
+ export class ActionMenu extends LitElement {
14
+ constructor() {
15
+ super();
16
+ this.actions = [];
17
+ this.resource = {};
18
+ this.disabled = false;
19
+ this._isOpen = false;
20
+ this._boundHandleClickOutside = this._handleClickOutside.bind(this);
21
+ }
22
+ connectedCallback() {
23
+ super.connectedCallback();
24
+ document.addEventListener('click', this._boundHandleClickOutside);
25
+ }
26
+ disconnectedCallback() {
27
+ super.disconnectedCallback();
28
+ document.removeEventListener('click', this._boundHandleClickOutside);
29
+ }
30
+ /**
31
+ * Handle clicks outside the menu to close it
32
+ * @param e - The click event
33
+ * @private
34
+ */
35
+ _handleClickOutside(e) {
36
+ const target = e.target;
37
+ if (this._isOpen && !this.contains(target)) {
38
+ this._isOpen = false;
39
+ }
40
+ }
41
+ /**
42
+ * Toggle the dropdown menu open/closed
43
+ * @param e - The click event
44
+ * @private
45
+ */
46
+ _toggleMenu(e) {
47
+ e.stopPropagation();
48
+ if (!this.disabled) {
49
+ this._isOpen = !this._isOpen;
50
+ }
51
+ }
52
+ /**
53
+ * Handle action click
54
+ * @param e - The click event
55
+ * @param action - The action object
56
+ * @private
57
+ */
58
+ _handleActionClick(e, action) {
59
+ e.stopPropagation();
60
+ if (this._isActionEnabled(action)) {
61
+ this._isOpen = false;
62
+ // Dispatch custom event
63
+ this.dispatchEvent(new CustomEvent('action-click', {
64
+ bubbles: true,
65
+ composed: true,
66
+ detail: { action, resource: this.resource }
67
+ }));
68
+ // Call action handler if provided
69
+ if (action.action && typeof action.action === 'function') {
70
+ action.action(this.resource);
71
+ }
72
+ }
73
+ }
74
+ /**
75
+ * Check if an action is enabled
76
+ * @param action - The action object
77
+ * @returns boolean
78
+ * @private
79
+ */
80
+ _isActionEnabled(action) {
81
+ if (!action.enabled)
82
+ return true;
83
+ if (typeof action.enabled === 'function') {
84
+ return action.enabled(this.resource);
85
+ }
86
+ return action.enabled;
87
+ }
88
+ /**
89
+ * Render the three-dots icon
90
+ * @returns TemplateResult
91
+ * @private
92
+ */
93
+ _renderIcon() {
94
+ return html `
95
+ <svg class="action-menu__icon" viewBox="0 0 16 16" fill="currentColor">
96
+ <circle cx="2" cy="8" r="1.5" />
97
+ <circle cx="8" cy="8" r="1.5" />
98
+ <circle cx="14" cy="8" r="1.5" />
99
+ </svg>
100
+ `;
101
+ }
102
+ /**
103
+ * Get actions to display
104
+ * @returns Array of actions
105
+ * @private
106
+ */
107
+ _getActions() {
108
+ // If actions are provided explicitly, use them
109
+ if (this.actions && this.actions.length > 0) {
110
+ return this.actions;
111
+ }
112
+ // Otherwise, try to get from resource.availableActions
113
+ if (this.resource && typeof this.resource.availableActions !== 'undefined') {
114
+ return this.resource.availableActions || [];
115
+ }
116
+ return [];
117
+ }
118
+ /**
119
+ * Render the component
120
+ * @returns TemplateResult
121
+ */
122
+ render() {
123
+ const allActions = this._getActions();
124
+ // Filter by visibility and enabled status
125
+ let visibleActions = allActions.filter(action => {
126
+ // Skip dividers in visibility check
127
+ if (action.divider)
128
+ return true;
129
+ // Check visible property
130
+ if (action.visible !== undefined) {
131
+ if (typeof action.visible === 'function') {
132
+ return action.visible(this.resource);
133
+ }
134
+ return action.visible;
135
+ }
136
+ // If no visible property, check enabled (hide if explicitly false)
137
+ if (action.enabled !== undefined && action.enabled === false) {
138
+ return false;
139
+ }
140
+ return true;
141
+ });
142
+ // Remove consecutive dividers and trailing/leading dividers
143
+ visibleActions = visibleActions.filter((action, index, arr) => {
144
+ if (!action.divider)
145
+ return true;
146
+ // Remove if first or last
147
+ if (index === 0 || index === arr.length - 1)
148
+ return false;
149
+ // Remove if next to another divider
150
+ if (arr[index - 1]?.divider || arr[index + 1]?.divider)
151
+ return false;
152
+ return true;
153
+ });
154
+ return html `
155
+ <button
156
+ class="action-menu__button"
157
+ ?disabled=${this.disabled}
158
+ @click=${this._toggleMenu}
159
+ aria-haspopup="true"
160
+ aria-expanded=${this._isOpen}
161
+ >
162
+ ${this._renderIcon()}
163
+ </button>
164
+
165
+ <div class="action-menu__dropdown ${this._isOpen ? 'action-menu__dropdown--open' : ''}">
166
+ ${visibleActions.length === 0 ? html `
167
+ <div class="action-menu__empty">No actions available</div>
168
+ ` : html `
169
+ <ul class="action-menu__list" role="menu">
170
+ ${visibleActions.map((action) => html `
171
+ ${action.divider ? html `
172
+ <li class="action-menu__divider" role="separator"></li>
173
+ ` : html `
174
+ <li class="action-menu__item" role="none">
175
+ <button
176
+ class="action-menu__action ${action.danger ? 'action-menu__action--danger' : ''}"
177
+ ?disabled=${!this._isActionEnabled(action)}
178
+ @click=${(e) => this._handleActionClick(e, action)}
179
+ role="menuitem"
180
+ >
181
+ ${action.label}
182
+ </button>
183
+ </li>
184
+ `}
185
+ `)}
186
+ </ul>
187
+ `}
188
+ </div>
189
+ `;
190
+ }
191
+ }
192
+ ActionMenu.styles = css `
193
+ :host {
194
+ display: inline-block;
195
+ position: relative;
196
+ }
197
+
198
+ .action-menu__button {
199
+ display: flex;
200
+ align-items: center;
201
+ justify-content: center;
202
+ width: 32px;
203
+ height: 32px;
204
+ padding: 0;
205
+ border: 1px solid var(--border, #ddd);
206
+ border-radius: 4px;
207
+ background-color: var(--body-bg, #fff);
208
+ color: var(--body-text, #333);
209
+ cursor: pointer;
210
+ transition: all 0.2s;
211
+ }
212
+
213
+ .action-menu__button:hover:not(:disabled) {
214
+ background-color: var(--sortable-table-row-hover-bg, #f5f5f5);
215
+ border-color: var(--link, #007bff);
216
+ }
217
+
218
+ .action-menu__button:disabled {
219
+ opacity: 0.4;
220
+ cursor: not-allowed;
221
+ }
222
+
223
+ .action-menu__icon {
224
+ width: 16px;
225
+ height: 16px;
226
+ }
227
+
228
+ .action-menu__dropdown {
229
+ position: absolute;
230
+ right: 0;
231
+ top: 100%;
232
+ margin-top: 4px;
233
+ min-width: 180px;
234
+ background-color: var(--body-bg, #fff);
235
+ border: 1px solid var(--border, #ddd);
236
+ border-radius: 4px;
237
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
238
+ z-index: 1000;
239
+ opacity: 0;
240
+ visibility: hidden;
241
+ transform: translateY(-10px);
242
+ transition: all 0.2s ease-in-out;
243
+ }
244
+
245
+ .action-menu__dropdown--open {
246
+ opacity: 1;
247
+ visibility: visible;
248
+ transform: translateY(0);
249
+ }
250
+
251
+ .action-menu__list {
252
+ list-style: none;
253
+ margin: 0;
254
+ padding: 0.5rem 0;
255
+ }
256
+
257
+ .action-menu__item {
258
+ margin: 0;
259
+ padding: 0;
260
+ }
261
+
262
+ .action-menu__action {
263
+ display: flex;
264
+ align-items: center;
265
+ gap: 0.5rem;
266
+ width: 100%;
267
+ padding: 0.5rem 1rem;
268
+ border: none;
269
+ background: none;
270
+ color: var(--body-text, #333);
271
+ font-size: 14px;
272
+ text-align: left;
273
+ cursor: pointer;
274
+ transition: background-color 0.15s;
275
+ }
276
+
277
+ .action-menu__action:hover:not(:disabled) {
278
+ background-color: var(--sortable-table-row-hover-bg, #f5f5f5);
279
+ }
280
+
281
+ .action-menu__action:disabled {
282
+ opacity: 0.4;
283
+ cursor: not-allowed;
284
+ }
285
+
286
+ .action-menu__action--danger {
287
+ color: var(--error, #dc3545);
288
+ }
289
+
290
+ .action-menu__action--danger:hover:not(:disabled) {
291
+ background-color: rgba(220, 53, 69, 0.1);
292
+ }
293
+
294
+ .action-menu__divider {
295
+ height: 1px;
296
+ margin: 0.5rem 0;
297
+ background-color: var(--border, #ddd);
298
+ }
299
+
300
+ .action-menu__empty {
301
+ padding: 1rem;
302
+ text-align: center;
303
+ color: var(--muted, #999);
304
+ font-size: 13px;
305
+ }
306
+ `;
307
+ __decorate([
308
+ property({ type: Array })
309
+ ], ActionMenu.prototype, "actions", void 0);
310
+ __decorate([
311
+ property({ type: Object })
312
+ ], ActionMenu.prototype, "resource", void 0);
313
+ __decorate([
314
+ property({ type: Boolean })
315
+ ], ActionMenu.prototype, "disabled", void 0);
316
+ __decorate([
317
+ state()
318
+ ], ActionMenu.prototype, "_isOpen", void 0);
319
+ // Register the element
320
+ customElements.define('action-menu', ActionMenu);
321
+ //# sourceMappingURL=action-menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-menu.js","sourceRoot":"","sources":["../Components/action-menu.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAsBpD;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IAmIxC;QACE,KAAK,EAAE,CAAC;QAlIV,YAAO,GAAqB,EAAE,CAAC;QAG/B,aAAQ,GAAiB,EAAE,CAAC;QAG5B,aAAQ,GAAG,KAAK,CAAC;QAGT,YAAO,GAAG,KAAK,CAAC;QA0HtB,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtE,CAAC;IAEQ,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,QAAQ,CAAC,gBAAgB,CAAC,OA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IAAI,CAAA;;;iDAG2B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,EAAE;gCACnE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;6BACjC,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,MAAM,CAAC;;;sBAGvD,MAAM,CAAC,KAAK;;;eAGnB;aACF,CAAC;;SAEL;;KAEJ,CAAC;IACJ,CAAC;;AA7Se,iBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkH3B,AAlHqB,CAkHpB;AA/HF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;2CACK;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CACC;AAG5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACX;AAGT;IADP,KAAK,EAAE;2CACgB;AAoT1B,uBAAuB;AACvB,cAAc,CAAC,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC"}
@@ -0,0 +1,91 @@
1
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(s){if(s.ep)return;s.ep=!0;const n=t(s);fetch(s.href,n)}})();/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const N=globalThis,K=N.ShadowRoot&&(N.ShadyCSS===void 0||N.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,V=Symbol(),Z=new WeakMap;let oe=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==V)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(K&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=Z.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Z.set(t,e))}return e}toString(){return this.cssText}};const pe=r=>new oe(typeof r=="string"?r:r+"",void 0,V),ue=(r,...e)=>{const t=r.length===1?r[0]:e.reduce(((i,s,n)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+r[n+1]),r[0]);return new oe(t,r,V)},fe=(r,e)=>{if(K)r.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const t of e){const i=document.createElement("style"),s=N.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,r.appendChild(i)}},X=K?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return pe(t)})(r):r;/**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ */const{is:$e,defineProperty:ge,getOwnPropertyDescriptor:me,getOwnPropertyNames:_e,getOwnPropertySymbols:ye,getPrototypeOf:Ae}=Object,g=globalThis,G=g.trustedTypes,be=G?G.emptyScript:"",j=g.reactiveElementPolyfillSupport,C=(r,e)=>r,R={toAttribute(r,e){switch(e){case Boolean:r=r?be:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},W=(r,e)=>!$e(r,e),Q={attribute:!0,type:String,converter:R,reflect:!1,useDefault:!1,hasChanged:W};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),g.litPropertyMetadata??(g.litPropertyMetadata=new WeakMap);let v=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Q){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&ge(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:n}=me(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:s,set(o){const a=s==null?void 0:s.call(this);n==null||n.call(this,o),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Q}static _$Ei(){if(this.hasOwnProperty(C("elementProperties")))return;const e=Ae(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(C("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(C("properties"))){const t=this.properties,i=[..._e(t),...ye(t)];for(const s of i)this.createProperty(s,t[s])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const s of i)t.unshift(X(s))}else e!==void 0&&t.push(X(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach((t=>t(this)))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return fe(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach((t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)}))}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach((t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)}))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){var n;const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){const o=(((n=i.converter)==null?void 0:n.toAttribute)!==void 0?i.converter:R).toAttribute(t,i.type);this._$Em=e,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(e,t){var n,o;const i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),h=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:R;this._$Em=s;const c=h.fromAttribute(t,a.type);this[s]=c??((o=this._$Ej)==null?void 0:o.get(s))??c,this._$Em=null}}requestUpdate(e,t,i){var s;if(e!==void 0){const n=this.constructor,o=this[e];if(i??(i=n.getPropertyOptions(e)),!((i.hasChanged??W)(o,t)||i.useDefault&&i.reflect&&o===((s=this._$Ej)==null?void 0:s.get(e))&&!this.hasAttribute(n._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:n},o){i&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??t??this[e]),n!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[n,o]of s){const{wrapped:a}=o,h=this[n];a!==!0||this._$AL.has(n)||h===void 0||this.C(n,void 0,o,h)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach((s=>{var n;return(n=s.hostUpdate)==null?void 0:n.call(s)})),this.update(t)):this._$EM()}catch(s){throw e=!1,this._$EM(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach((i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach((t=>this._$ET(t,this[t])))),this._$EM()}updated(e){}firstUpdated(e){}};v.elementStyles=[],v.shadowRootOptions={mode:"open"},v[C("elementProperties")]=new Map,v[C("finalized")]=new Map,j==null||j({ReactiveElement:v}),(g.reactiveElementVersions??(g.reactiveElementVersions=[])).push("2.1.1");/**
10
+ * @license
11
+ * Copyright 2017 Google LLC
12
+ * SPDX-License-Identifier: BSD-3-Clause
13
+ */const x=globalThis,D=x.trustedTypes,Y=D?D.createPolicy("lit-html",{createHTML:r=>r}):void 0,he="$lit$",$=`lit$${Math.random().toFixed(9).slice(2)}$`,ae="?"+$,ve=`<${ae}>`,b=document,O=()=>b.createComment(""),k=r=>r===null||typeof r!="object"&&typeof r!="function",F=Array.isArray,Ee=r=>F(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",z=`[
14
+ \f\r]`,w=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ee=/-->/g,te=/>/g,_=RegExp(`>|${z}(?:([^\\s"'>=/]+)(${z}*=${z}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),se=/'/g,ie=/"/g,le=/^(?:script|style|textarea|title)$/i,Se=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),we=Se(1),E=Symbol.for("lit-noChange"),d=Symbol.for("lit-nothing"),re=new WeakMap,y=b.createTreeWalker(b,129);function ce(r,e){if(!F(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Y!==void 0?Y.createHTML(e):e}const Ce=(r,e)=>{const t=r.length-1,i=[];let s,n=e===2?"<svg>":e===3?"<math>":"",o=w;for(let a=0;a<t;a++){const h=r[a];let c,p,l=-1,u=0;for(;u<h.length&&(o.lastIndex=u,p=o.exec(h),p!==null);)u=o.lastIndex,o===w?p[1]==="!--"?o=ee:p[1]!==void 0?o=te:p[2]!==void 0?(le.test(p[2])&&(s=RegExp("</"+p[2],"g")),o=_):p[3]!==void 0&&(o=_):o===_?p[0]===">"?(o=s??w,l=-1):p[1]===void 0?l=-2:(l=o.lastIndex-p[2].length,c=p[1],o=p[3]===void 0?_:p[3]==='"'?ie:se):o===ie||o===se?o=_:o===ee||o===te?o=w:(o=_,s=void 0);const f=o===_&&r[a+1].startsWith("/>")?" ":"";n+=o===w?h+ve:l>=0?(i.push(c),h.slice(0,l)+he+h.slice(l)+$+f):h+$+(l===-2?a:f)}return[ce(r,n+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class U{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,o=0;const a=e.length-1,h=this.parts,[c,p]=Ce(e,t);if(this.el=U.createElement(c,i),y.currentNode=this.el.content,t===2||t===3){const l=this.el.content.firstChild;l.replaceWith(...l.childNodes)}for(;(s=y.nextNode())!==null&&h.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const l of s.getAttributeNames())if(l.endsWith(he)){const u=p[o++],f=s.getAttribute(l).split($),L=/([.?@])?(.*)/.exec(u);h.push({type:1,index:n,name:L[2],strings:f,ctor:L[1]==="."?Pe:L[1]==="?"?Oe:L[1]==="@"?ke:I}),s.removeAttribute(l)}else l.startsWith($)&&(h.push({type:6,index:n}),s.removeAttribute(l));if(le.test(s.tagName)){const l=s.textContent.split($),u=l.length-1;if(u>0){s.textContent=D?D.emptyScript:"";for(let f=0;f<u;f++)s.append(l[f],O()),y.nextNode(),h.push({type:2,index:++n});s.append(l[u],O())}}}else if(s.nodeType===8)if(s.data===ae)h.push({type:2,index:n});else{let l=-1;for(;(l=s.data.indexOf($,l+1))!==-1;)h.push({type:7,index:n}),l+=$.length-1}n++}}static createElement(e,t){const i=b.createElement("template");return i.innerHTML=e,i}}function S(r,e,t=r,i){var o,a;if(e===E)return e;let s=i!==void 0?(o=t._$Co)==null?void 0:o[i]:t._$Cl;const n=k(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==n&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),n===void 0?s=void 0:(s=new n(r),s._$AT(r,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=S(r,s._$AS(r,e.values),s,i)),e}class xe{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=((e==null?void 0:e.creationScope)??b).importNode(t,!0);y.currentNode=s;let n=y.nextNode(),o=0,a=0,h=i[0];for(;h!==void 0;){if(o===h.index){let c;h.type===2?c=new T(n,n.nextSibling,this,e):h.type===1?c=new h.ctor(n,h.name,h.strings,this,e):h.type===6&&(c=new Ue(n,this,e)),this._$AV.push(c),h=i[++a]}o!==(h==null?void 0:h.index)&&(n=y.nextNode(),o++)}return y.currentNode=b,s}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class T{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=d,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=S(this,e,t),k(e)?e===d||e==null||e===""?(this._$AH!==d&&this._$AR(),this._$AH=d):e!==this._$AH&&e!==E&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Ee(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==d&&k(this._$AH)?this._$AA.nextSibling.data=e:this.T(b.createTextNode(e)),this._$AH=e}$(e){var n;const{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=U.createElement(ce(i.h,i.h[0]),this.options)),i);if(((n=this._$AH)==null?void 0:n._$AD)===s)this._$AH.p(t);else{const o=new xe(s,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=re.get(e.strings);return t===void 0&&re.set(e.strings,t=new U(e)),t}k(e){F(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new T(this.O(O()),this.O(O()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e!==this._$AB;){const s=e.nextSibling;e.remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class I{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=d,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=d}_$AI(e,t=this,i,s){const n=this.strings;let o=!1;if(n===void 0)e=S(this,e,t,0),o=!k(e)||e!==this._$AH&&e!==E,o&&(this._$AH=e);else{const a=e;let h,c;for(e=n[0],h=0;h<n.length-1;h++)c=S(this,a[i+h],t,h),c===E&&(c=this._$AH[h]),o||(o=!k(c)||c!==this._$AH[h]),c===d?e=d:e!==d&&(e+=(c??"")+n[h+1]),this._$AH[h]=c}o&&!s&&this.j(e)}j(e){e===d?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Pe extends I{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===d?void 0:e}}class Oe extends I{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==d)}}class ke extends I{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){if((e=S(this,e,t,0)??d)===E)return;const i=this._$AH,s=e===d&&i!==d||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,n=e!==d&&(i===d||s);s&&this.element.removeEventListener(this.name,this,i),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class Ue{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){S(this,e)}}const B=x.litHtmlPolyfillSupport;B==null||B(U,T),(x.litHtmlVersions??(x.litHtmlVersions=[])).push("3.3.1");const Te=(r,e,t)=>{const i=(t==null?void 0:t.renderBefore)??e;let s=i._$litPart$;if(s===void 0){const n=(t==null?void 0:t.renderBefore)??null;i._$litPart$=s=new T(e.insertBefore(O(),n),n,void 0,t??{})}return s._$AI(r),s};/**
16
+ * @license
17
+ * Copyright 2017 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */const A=globalThis;class P extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Te(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return E}}var ne;P._$litElement$=!0,P.finalized=!0,(ne=A.litElementHydrateSupport)==null||ne.call(A,{LitElement:P});const q=A.litElementPolyfillSupport;q==null||q({LitElement:P});(A.litElementVersions??(A.litElementVersions=[])).push("4.2.1");/**
20
+ * @license
21
+ * Copyright 2017 Google LLC
22
+ * SPDX-License-Identifier: BSD-3-Clause
23
+ */const He={attribute:!0,type:String,converter:R,reflect:!1,hasChanged:W},Me=(r=He,e,t)=>{const{kind:i,metadata:s}=t;let n=globalThis.litPropertyMetadata.get(s);if(n===void 0&&globalThis.litPropertyMetadata.set(s,n=new Map),i==="setter"&&((r=Object.create(r)).wrapped=!0),n.set(t.name,r),i==="accessor"){const{name:o}=t;return{set(a){const h=e.get.call(this);e.set.call(this,a),this.requestUpdate(o,h,r)},init(a){return a!==void 0&&this.C(o,void 0,r,a),a}}}if(i==="setter"){const{name:o}=t;return function(a){const h=this[o];e.call(this,a),this.requestUpdate(o,h,r)}}throw Error("Unsupported decorator location: "+i)};function H(r){return(e,t)=>typeof t=="object"?Me(r,e,t):((i,s,n)=>{const o=s.hasOwnProperty(n);return s.constructor.createProperty(n,i),o?Object.getOwnPropertyDescriptor(s,n):void 0})(r,e,t)}var Le=Object.defineProperty,M=(r,e,t,i)=>{for(var s=void 0,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=o(e,t,s)||s);return s&&Le(e,t,s),s};const J=class J extends P{constructor(){super(),this.checked=!1,this.onLabel="On",this.offLabel="Off",this.storageKey=null,this.name="",this.boundHandleExternalChange=this.handleExternalChange.bind(this),window.addEventListener("toggle-changed",this.boundHandleExternalChange)}connectedCallback(){if(super.connectedCallback(),this.storageKey){const e=localStorage.getItem(this.storageKey);e!==null&&(this.checked=e==="true")}}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("toggle-changed",this.boundHandleExternalChange)}handleExternalChange(e){const t=e;this.name&&t.detail.name===this.name&&(this.checked=t.detail.checked)}dispatchChangeEvent(e){const t=new CustomEvent("toggle-change",{bubbles:!0,composed:!0,detail:{checked:e,name:this.name}});this.dispatchEvent(t),this.name&&window.dispatchEvent(new CustomEvent("toggle-changed",{detail:{checked:e,name:this.name}}))}handleToggleChange(e){const t=e.target;this.checked=t.checked,this.storageKey&&localStorage.setItem(this.storageKey,this.checked.toString()),this.dispatchChangeEvent(this.checked)}render(){return we`
24
+ <span class="label">${this.offLabel}</span>
25
+ <label class="toggle-switch">
26
+ <input
27
+ type="checkbox"
28
+ .checked=${this.checked}
29
+ @change=${this.handleToggleChange}
30
+ >
31
+ <span class="slider"></span>
32
+ </label>
33
+ <span class="label">${this.onLabel}</span>
34
+ `}};J.styles=ue`
35
+ :host {
36
+ display: flex;
37
+ align-items: center;
38
+ margin-right: 10px;
39
+ }
40
+
41
+ .toggle-switch {
42
+ position: relative;
43
+ display: inline-block;
44
+ width: 44px;
45
+ height: 24px;
46
+ margin: 0 8px;
47
+ }
48
+
49
+ .toggle-switch input {
50
+ opacity: 0;
51
+ width: 0;
52
+ height: 0;
53
+ }
54
+
55
+ .slider {
56
+ position: absolute;
57
+ cursor: pointer;
58
+ top: 0;
59
+ left: 0;
60
+ right: 0;
61
+ bottom: 0;
62
+ background-color: #4a5568;
63
+ transition: .3s;
64
+ border-radius: 24px;
65
+ }
66
+
67
+ .slider:before {
68
+ position: absolute;
69
+ content: "";
70
+ height: 18px;
71
+ width: 18px;
72
+ left: 3px;
73
+ bottom: 3px;
74
+ background-color: white;
75
+ transition: .3s;
76
+ border-radius: 50%;
77
+ }
78
+
79
+ input:checked + .slider {
80
+ background-color: #3b82f6;
81
+ }
82
+
83
+ input:checked + .slider:before {
84
+ transform: translateX(20px);
85
+ }
86
+
87
+ .label {
88
+ font-size: 14px;
89
+ user-select: none;
90
+ }
91
+ `;let m=J;M([H({type:Boolean})],m.prototype,"checked");M([H({type:String,attribute:"on-label"})],m.prototype,"onLabel");M([H({type:String,attribute:"off-label"})],m.prototype,"offLabel");M([H({type:String,attribute:"storage-key"})],m.prototype,"storageKey");M([H({type:String})],m.prototype,"name");customElements.define("toggle-switch",m);const Ne=()=>{const r=localStorage.getItem("user-theme-preference");return r==="dark"||r==="light"?(de(r),r==="dark"):window.matchMedia("(prefers-color-scheme: dark)").matches},de=r=>{document.body.classList.remove("theme-dark","theme-light"),document.body.classList.add(`theme-${r}`)};customElements.whenDefined("toggle-switch").then(()=>{const r=document.querySelectorAll("toggle-switch"),e=Ne();r.forEach(t=>{t.checked=e}),r.forEach(t=>{t.addEventListener("toggle-change",i=>{const s=i.detail.checked?"dark":"light";localStorage.setItem("user-theme-preference",s),de(s)})})});customElements.whenDefined("toggle-switch").then(()=>{const r=document.querySelector("header toggle-switch");r.onLabel="🌙 Dark",r.offLabel="☀️ Light"});customElements.whenDefined("toggle-switch").then(()=>{const r=document.getElementById("sync1");r.onLabel="🌙",r.offLabel="☀️"});
@@ -0,0 +1,191 @@
1
+ import { LitElement, TemplateResult } from 'lit';
2
+ import './action-menu';
3
+ import 'iconify-icon';
4
+ /**
5
+ * Type definition for formatter functions
6
+ */
7
+ type FormatterFunction = (value: any) => string;
8
+ /**
9
+ * Type definition for sort functions
10
+ */
11
+ type SortFunction = (a: RowData, b: RowData, direction: 'asc' | 'desc') => number;
12
+ /**
13
+ * Type definition for link functions
14
+ */
15
+ type LinkFunction = (row: RowData) => string;
16
+ /**
17
+ * Type definition for row data
18
+ */
19
+ interface RowData {
20
+ [key: string]: any;
21
+ }
22
+ /**
23
+ * Type definition for column configuration
24
+ */
25
+ export interface DataTableColumn {
26
+ field: string;
27
+ label: string;
28
+ width?: string;
29
+ sortable?: boolean;
30
+ searchable?: boolean;
31
+ formatter?: string | ((value: any, row: RowData) => any);
32
+ sortFn?: SortFunction;
33
+ link?: string | LinkFunction;
34
+ linkTarget?: '_self' | '_blank' | '_parent' | '_top';
35
+ }
36
+ /**
37
+ * Data table formatters for common column types
38
+ */
39
+ export declare const dataTableFormatters: Record<string, FormatterFunction>;
40
+ /**
41
+ * A feature-rich data table component with sorting, filtering, and pagination.
42
+ * Supports custom cell rendering, row actions, and various formatters.
43
+ */
44
+ export declare class DataTable extends LitElement {
45
+ columns: DataTableColumn[];
46
+ rows: RowData[];
47
+ rowsPerPage: number;
48
+ searchable: boolean;
49
+ sortable: boolean;
50
+ paginated: boolean;
51
+ loading: boolean;
52
+ keyField: string;
53
+ rowActions: boolean;
54
+ rowActionsWidth: number;
55
+ emptyMessage: string;
56
+ noResultsMessage: string;
57
+ private _searchQuery;
58
+ private _currentPage;
59
+ private _sortColumn;
60
+ private _sortDirection;
61
+ static styles: import("lit").CSSResult;
62
+ /**
63
+ * Get nested value from object using dot notation
64
+ * @param obj - The object to extract value from
65
+ * @param path - The path (e.g., 'user.name')
66
+ * @returns The value at the path
67
+ * @private
68
+ */
69
+ private _getNestedValue;
70
+ /**
71
+ * Format a cell value using column formatter
72
+ * @param row - The row data
73
+ * @param column - The column definition
74
+ * @returns The formatted value
75
+ * @private
76
+ */
77
+ private _formatValue;
78
+ /**
79
+ * Get link URL for a cell if column has link property
80
+ * @param row - The row data
81
+ * @param column - The column definition
82
+ * @returns The link URL or null
83
+ * @private
84
+ */
85
+ private _getLinkUrl;
86
+ /**
87
+ * Render cell content with optional link
88
+ * @param row - The row data
89
+ * @param column - The column definition
90
+ * @returns The rendered cell content
91
+ * @private
92
+ */
93
+ private _renderCellContent;
94
+ /**
95
+ * Handle link click - emit navigation event instead of following link
96
+ * @param event - The click event
97
+ * @param url - The URL to navigate to
98
+ * @param row - The row data
99
+ * @private
100
+ */
101
+ private _handleLinkClick;
102
+ /**
103
+ * Get filtered rows based on search query
104
+ * @returns Filtered rows
105
+ * @private
106
+ */
107
+ private get _filteredRows();
108
+ /**
109
+ * Get sorted rows
110
+ * @returns Sorted rows
111
+ * @private
112
+ */
113
+ private get _sortedRows();
114
+ /**
115
+ * Get paginated rows
116
+ * @returns Paginated rows
117
+ * @private
118
+ */
119
+ private get _paginatedRows();
120
+ /**
121
+ * Get total number of pages
122
+ * @returns Total pages
123
+ * @private
124
+ */
125
+ private get _totalPages();
126
+ /**
127
+ * Get pagination info
128
+ * @returns Pagination info
129
+ * @private
130
+ */
131
+ private get _paginationInfo();
132
+ /**
133
+ * Handle search input
134
+ * @param e - The input event
135
+ * @private
136
+ */
137
+ private _handleSearch;
138
+ /**
139
+ * Handle column sort
140
+ * @param columnField - The column field to sort by
141
+ * @private
142
+ */
143
+ private _handleSort;
144
+ /**
145
+ * Navigate to a specific page
146
+ * @param page - The page number
147
+ */
148
+ goToPage(page: number): void;
149
+ /**
150
+ * Navigate to the next page
151
+ */
152
+ nextPage(): void;
153
+ /**
154
+ * Navigate to the previous page
155
+ */
156
+ prevPage(): void;
157
+ /**
158
+ * Reset search query
159
+ */
160
+ resetSearch(): void;
161
+ /**
162
+ * Reset sort to default state
163
+ */
164
+ resetSort(): void;
165
+ /**
166
+ * Render sort icon
167
+ * @param column - The column definition
168
+ * @returns TemplateResult
169
+ * @private
170
+ */
171
+ private _renderSortIcon;
172
+ /**
173
+ * Render chevron left icon
174
+ * @returns TemplateResult
175
+ * @private
176
+ */
177
+ private _renderChevronLeft;
178
+ /**
179
+ * Render chevron right icon
180
+ * @returns TemplateResult
181
+ * @private
182
+ */
183
+ private _renderChevronRight;
184
+ /**
185
+ * Render the component
186
+ * @returns TemplateResult
187
+ */
188
+ render(): TemplateResult;
189
+ }
190
+ export {};
191
+ //# sourceMappingURL=data-table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../Components/data-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAE5D,OAAO,eAAe,CAAC;AACvB,OAAO,cAAc,CAAC;AAatB;;GAEG;AACH,KAAK,iBAAiB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;AAEhD;;GAEG;AACH,KAAK,YAAY,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM,KAAK,MAAM,CAAC;AAElF;;GAEG;AAC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