@dooboostore/simple-web-component 1.0.38 → 1.0.40

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.
Files changed (91) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +88 -871
  3. package/dist/cjs/SwcAppEngine.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +194 -111
  5. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  6. package/dist/cjs/decorators/applyNode.js +82 -80
  7. package/dist/cjs/decorators/applyNode.js.map +2 -2
  8. package/dist/cjs/decorators/applyProperty.js +213 -0
  9. package/dist/cjs/decorators/applyProperty.js.map +7 -0
  10. package/dist/cjs/decorators/applySlot.js +93 -82
  11. package/dist/cjs/decorators/applySlot.js.map +3 -3
  12. package/dist/cjs/decorators/changedAttributeThis.js.map +1 -1
  13. package/dist/cjs/decorators/elementDefine.js +14 -34
  14. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  15. package/dist/cjs/decorators/index.js +2 -2
  16. package/dist/cjs/decorators/index.js.map +2 -2
  17. package/dist/cjs/decorators/lifecycles.js +4 -4
  18. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  19. package/dist/cjs/decorators/state.js +0 -1
  20. package/dist/cjs/decorators/state.js.map +2 -2
  21. package/dist/cjs/elements/SwcApp.js.map +2 -2
  22. package/dist/cjs/types/index.js.map +1 -1
  23. package/dist/esm/SwcAppEngine.js.map +2 -2
  24. package/dist/esm/decorators/applyAttribute.js +196 -113
  25. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  26. package/dist/esm/decorators/applyNode.js +82 -80
  27. package/dist/esm/decorators/applyNode.js.map +2 -2
  28. package/dist/esm/decorators/applyProperty.js +194 -0
  29. package/dist/esm/decorators/applyProperty.js.map +7 -0
  30. package/dist/esm/decorators/applySlot.js +93 -82
  31. package/dist/esm/decorators/applySlot.js.map +3 -3
  32. package/dist/esm/decorators/changedAttributeThis.js.map +1 -1
  33. package/dist/esm/decorators/elementDefine.js +14 -34
  34. package/dist/esm/decorators/elementDefine.js.map +2 -2
  35. package/dist/esm/decorators/index.js +2 -2
  36. package/dist/esm/decorators/index.js.map +1 -1
  37. package/dist/esm/decorators/lifecycles.js +4 -4
  38. package/dist/esm/decorators/lifecycles.js.map +2 -2
  39. package/dist/esm/decorators/state.js +0 -1
  40. package/dist/esm/decorators/state.js.map +2 -2
  41. package/dist/esm/elements/SwcApp.js.map +2 -2
  42. package/dist/esm/types/index.js.map +1 -1
  43. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +525 -513
  44. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  45. package/dist/types/SwcAppEngine.d.ts.map +1 -1
  46. package/dist/types/decorators/applyAttribute.d.ts +56 -15
  47. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  48. package/dist/types/decorators/applyNode.d.ts +28 -24
  49. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  50. package/dist/types/decorators/applyProperty.d.ts +61 -0
  51. package/dist/types/decorators/applyProperty.d.ts.map +1 -0
  52. package/dist/types/decorators/applySlot.d.ts +17 -15
  53. package/dist/types/decorators/applySlot.d.ts.map +1 -1
  54. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  55. package/dist/types/decorators/index.d.ts +2 -2
  56. package/dist/types/decorators/index.d.ts.map +1 -1
  57. package/dist/types/decorators/lifecycles.d.ts +4 -4
  58. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  59. package/dist/types/decorators/state.d.ts.map +1 -1
  60. package/dist/types/elements/SwcApp.d.ts.map +1 -1
  61. package/dist/types/types/index.d.ts +1 -6
  62. package/dist/types/types/index.d.ts.map +1 -1
  63. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +525 -513
  64. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  65. package/package.json +1 -1
  66. package/src/SwcAppEngine.ts +1 -0
  67. package/src/decorators/applyAttribute.ts +311 -126
  68. package/src/decorators/applyNode.ts +108 -105
  69. package/src/decorators/applyProperty.ts +302 -0
  70. package/src/decorators/applySlot.ts +112 -94
  71. package/src/decorators/changedAttributeThis.ts +1 -1
  72. package/src/decorators/elementDefine.ts +44 -33
  73. package/src/decorators/index.ts +2 -3
  74. package/src/decorators/lifecycles.ts +6 -6
  75. package/src/decorators/state.ts +0 -1
  76. package/src/elements/SwcApp.ts +0 -1
  77. package/src/types/index.ts +7 -7
  78. package/dist/cjs/decorators/attribute.js +0 -187
  79. package/dist/cjs/decorators/attribute.js.map +0 -7
  80. package/dist/cjs/decorators/setProperty.js +0 -109
  81. package/dist/cjs/decorators/setProperty.js.map +0 -7
  82. package/dist/esm/decorators/attribute.js +0 -168
  83. package/dist/esm/decorators/attribute.js.map +0 -7
  84. package/dist/esm/decorators/setProperty.js +0 -90
  85. package/dist/esm/decorators/setProperty.js.map +0 -7
  86. package/dist/types/decorators/attribute.d.ts +0 -31
  87. package/dist/types/decorators/attribute.d.ts.map +0 -1
  88. package/dist/types/decorators/setProperty.d.ts +0 -17
  89. package/dist/types/decorators/setProperty.d.ts.map +0 -1
  90. package/src/decorators/attribute.ts +0 -223
  91. package/src/decorators/setProperty.ts +0 -112
@@ -1,140 +1,223 @@
1
- import { ReflectUtils } from "@dooboostore/core";
2
- import { ensureInit } from "./elementDefine.js";
1
+ import { ReflectUtils, FunctionUtils, ActionExpression } from "@dooboostore/core";
2
+ import { ensureInit, getElementConfig } from "./elementDefine.js";
3
3
  import { SwcUtils } from "../utils/Utils.js";
4
- const ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for("simple-web-component:attribute-apply");
5
- function createAttributeDecorator(action) {
6
- return (selector, nameOrOptions, options = {}) => {
7
- return (target, propertyKey, descriptor) => {
8
- const constructor = target.constructor;
9
- let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor);
10
- if (!metaList) {
11
- metaList = /* @__PURE__ */ new Map();
12
- ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);
4
+ import { ConvertUtils } from "@dooboostore/core-web";
5
+ const ATTRIBUTE_METADATA_KEY = Symbol.for("simple-web-component:attribute");
6
+ const convertValue = (val, type) => {
7
+ if (val === null || val === void 0) return val;
8
+ if (type === Number) return Number(val);
9
+ if (type === Boolean) return val === "false" || val === "0" ? false : true;
10
+ return val;
11
+ };
12
+ const getAttributeValue = (inst, attrName, options) => {
13
+ const conf = getElementConfig(inst);
14
+ const currentWin = inst._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
15
+ const targets = options?.selector ? resolveAttributeTargets(inst, options.selector, options) : [inst];
16
+ const primaryTarget = targets[0];
17
+ if (primaryTarget && typeof primaryTarget.hasAttribute === "function" && primaryTarget.hasAttribute(attrName)) {
18
+ let domVal = primaryTarget.getAttribute(attrName);
19
+ const ae = new ActionExpression(domVal);
20
+ const expr = ae.getFirstExpression("callReturn");
21
+ if (expr) {
22
+ try {
23
+ const result = FunctionUtils.executeReturn({
24
+ script: ConvertUtils.decodeHtmlEntity(expr.script, currentWin.document),
25
+ context: inst,
26
+ args: SwcUtils.getHelperAndHostSet(currentWin, inst)
27
+ });
28
+ return convertValue(result, options?.type);
29
+ } catch (err) {
30
+ console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, err);
31
+ return convertValue(domVal, options?.type);
13
32
  }
14
- let attributeName = typeof nameOrOptions === "string" ? nameOrOptions : void 0;
15
- let finalOptions = options;
16
- if (typeof nameOrOptions === "object" && nameOrOptions !== null) {
17
- finalOptions = nameOrOptions;
33
+ }
34
+ return convertValue(domVal, options?.type);
35
+ }
36
+ return null;
37
+ };
38
+ const resolveAttributeTargets = (inst, selector, options) => {
39
+ const conf = getElementConfig(inst);
40
+ const currentWin = conf.window;
41
+ const r = options.root || "auto";
42
+ const results = [];
43
+ const applyRoot = (target) => {
44
+ if (!target) return;
45
+ if (r === "auto") {
46
+ results.push(target);
47
+ } else {
48
+ if (r === "light" || r === "all") results.push(target);
49
+ if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
50
+ }
51
+ };
52
+ if (selector === "$this" || !selector) {
53
+ applyRoot(inst);
54
+ } else {
55
+ const hostSet = SwcUtils.getHostSet(inst);
56
+ if (selector === "$host") applyRoot(hostSet.$host);
57
+ else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
58
+ else if (selector === "$appHost") applyRoot(hostSet.$appHost);
59
+ else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
60
+ else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
61
+ else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
62
+ else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
63
+ else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
64
+ else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
65
+ else {
66
+ if (r === "shadow") {
67
+ const found = inst.shadowRoot?.querySelectorAll(selector);
68
+ if (found) results.push(...found);
69
+ } else if (r === "light") {
70
+ const found = inst.querySelectorAll(selector);
71
+ if (found) results.push(...found);
72
+ } else if (r === "all") {
73
+ const sMatch = inst.shadowRoot?.querySelectorAll(selector);
74
+ const lMatch = inst.querySelectorAll(selector);
75
+ if (sMatch) results.push(...sMatch);
76
+ if (lMatch) results.push(...lMatch);
77
+ } else {
78
+ const found = (inst.shadowRoot || inst).querySelectorAll(selector);
79
+ if (found) results.push(...found);
18
80
  }
19
- metaList.set(propertyKey, {
20
- propertyKey,
21
- selector,
22
- action,
23
- options: { ...finalOptions, name: attributeName }
81
+ }
82
+ }
83
+ return results;
84
+ };
85
+ function applyAttribute(selector, targetAttributeNameOrOptions, options) {
86
+ return (target, propertyKey, descriptor) => {
87
+ const constructor = target.constructor;
88
+ const designType = Reflect.getMetadata("design:type", target, propertyKey);
89
+ const metaType = descriptor && typeof descriptor.value === "function" ? "method" : "property";
90
+ let finalOptions = {};
91
+ let targetAttributeName;
92
+ if (typeof targetAttributeNameOrOptions === "string") {
93
+ targetAttributeName = targetAttributeNameOrOptions;
94
+ finalOptions = options || {};
95
+ } else if (targetAttributeNameOrOptions) {
96
+ finalOptions = targetAttributeNameOrOptions;
97
+ targetAttributeName = finalOptions.name || String(propertyKey);
98
+ } else {
99
+ targetAttributeName = String(propertyKey);
100
+ }
101
+ let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor);
102
+ if (!metaList) {
103
+ metaList = [];
104
+ ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);
105
+ }
106
+ metaList.push({
107
+ propertyKey,
108
+ selector,
109
+ targetAttributeName,
110
+ options: finalOptions,
111
+ type: metaType
112
+ });
113
+ const applyValueToTargets = (inst, resolvedValue) => {
114
+ const conf = getElementConfig(inst);
115
+ const currentWin = conf.window;
116
+ const targetEls = resolveAttributeTargets(inst, selector, finalOptions);
117
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
118
+ targetEls.forEach((targetEl) => {
119
+ if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: inst, helper: hostSet })) {
120
+ return;
121
+ }
122
+ if (resolvedValue === null) {
123
+ targetEl.removeAttribute(targetAttributeName);
124
+ } else if (resolvedValue !== void 0) {
125
+ targetEl.setAttribute(targetAttributeName, resolvedValue === true ? "" : String(resolvedValue));
126
+ }
24
127
  });
128
+ return resolvedValue;
129
+ };
130
+ if (descriptor && typeof descriptor.value === "function") {
25
131
  const original = descriptor.value;
26
132
  descriptor.value = function(...args) {
27
133
  ensureInit(this);
28
134
  const res = original.apply(this, args);
29
- const handleResult = (resolvedValue) => {
30
- if (resolvedValue !== void 0) {
31
- const win = this.ownerDocument?.defaultView || window;
32
- const host = this;
33
- const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
34
- const r = finalOptions.root || "auto";
35
- const targetEls = [];
36
- const applyRoot = (t) => {
37
- if (!t || !(t instanceof win.HTMLElement)) return;
38
- targetEls.push(t);
39
- };
40
- if (selector === "$this" || !selector) applyRoot(host);
41
- else if (selector === "$host") applyRoot(hostSet.$host);
42
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
43
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
44
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
45
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
46
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
47
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
48
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
49
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
50
- else {
51
- const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
52
- if (targetRoot) {
53
- const found = targetRoot.querySelectorAll(selector);
54
- if (found) targetEls.push(...Array.from(found));
55
- }
56
- }
57
- targetEls.forEach((targetEl) => {
58
- if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
59
- return;
60
- }
61
- const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
62
- if (action === "set" || action === "update") {
63
- if (attributeName) {
64
- if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
65
- targetEl.removeAttribute(attributeName);
66
- } else {
67
- targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
68
- }
69
- } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
70
- Object.entries(resolvedRes).forEach(([attr, val]) => {
71
- const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
72
- if (finalVal === null || finalVal === void 0 || finalVal === false) {
73
- targetEl.removeAttribute(attr);
74
- } else {
75
- targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
76
- }
77
- });
78
- }
79
- } else if (action === "remove") {
80
- if (attributeName) {
81
- targetEl.removeAttribute(attributeName);
82
- } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
83
- Object.entries(resolvedRes).forEach(([attr, val]) => {
84
- const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
85
- if (shouldRemove) targetEl.removeAttribute(attr);
86
- });
87
- } else {
88
- const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
89
- attrs.forEach((a) => targetEl.removeAttribute(String(a)));
90
- }
91
- }
92
- });
93
- }
94
- return resolvedValue;
95
- };
96
135
  if (res instanceof Promise) {
97
- return res.then(handleResult);
136
+ return res.then((v) => {
137
+ applyValueToTargets(this, v);
138
+ return v;
139
+ });
98
140
  } else {
99
- return handleResult(res);
141
+ applyValueToTargets(this, res);
142
+ return res;
100
143
  }
101
144
  };
102
- return descriptor;
103
- };
145
+ return;
146
+ }
147
+ Object.defineProperty(target, propertyKey, {
148
+ configurable: true,
149
+ enumerable: true,
150
+ get() {
151
+ ensureInit(this);
152
+ const mergedOptions = { ...finalOptions, selector, type: finalOptions.type || designType };
153
+ return getAttributeValue(this, targetAttributeName, mergedOptions);
154
+ },
155
+ set(value) {
156
+ ensureInit(this);
157
+ if (value instanceof Promise) {
158
+ value.then((v) => applyValueToTargets(this, v)).catch(() => {
159
+ });
160
+ } else {
161
+ applyValueToTargets(this, value);
162
+ }
163
+ }
164
+ });
104
165
  };
105
166
  }
106
- function applyAttribute(selector, action = "update", options = {}) {
107
- return createAttributeDecorator(action)(selector, options);
167
+ function attribute(selector, targetAttributeNameOrOptions, options) {
168
+ return applyAttribute(selector, targetAttributeNameOrOptions, options);
169
+ }
170
+ function attributeThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
171
+ if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol") {
172
+ return applyAttribute("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
173
+ }
174
+ if (typeof targetOrOptions === "string") {
175
+ return applyAttribute("$this", targetOrOptions, propertyKeyOrOptions);
176
+ } else if (targetOrOptions && typeof targetOrOptions === "object") {
177
+ return applyAttribute("$this", void 0, targetOrOptions);
178
+ } else {
179
+ return applyAttribute("$this", void 0, {});
180
+ }
181
+ }
182
+ function setAttribute(selector, targetAttributeNameOrOptions, options) {
183
+ return applyAttribute(selector, targetAttributeNameOrOptions, options);
108
184
  }
109
- const setAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("set")(selector, nameOrOptions, options);
110
- const updateAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("update")(selector, nameOrOptions, options);
111
- const removeAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("remove")(selector, nameOrOptions, options);
112
- function applyAttributeThis(action = "update", options = {}) {
113
- return createAttributeDecorator(action)("$this", options);
185
+ function setAttributeThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
186
+ if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
187
+ return applyAttribute("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
188
+ }
189
+ if (typeof targetOrOptions === "string") {
190
+ return applyAttribute("$this", targetOrOptions, propertyKeyOrOptions);
191
+ } else if (targetOrOptions && typeof targetOrOptions === "object") {
192
+ return applyAttribute("$this", void 0, targetOrOptions);
193
+ } else {
194
+ return applyAttribute("$this", void 0, {});
195
+ }
114
196
  }
115
- const setAttributeThis = (nameOrOptions, options = {}) => createAttributeDecorator("set")("$this", nameOrOptions, options);
116
- const updateAttributeThis = (nameOrOptions, options = {}) => createAttributeDecorator("update")("$this", nameOrOptions, options);
117
- const removeAttributeThis = (nameOrOptions, options = {}) => createAttributeDecorator("remove")("$this", nameOrOptions, options);
197
+ const findAllAttributeMetadata = (target) => {
198
+ const actualTarget = target instanceof Function ? target : target.constructor;
199
+ return ReflectUtils.findAllMetadata(ATTRIBUTE_METADATA_KEY, actualTarget).flat();
200
+ };
118
201
  const findAllAttributeApplyMetadata = (target) => {
119
202
  const result = /* @__PURE__ */ new Map();
120
- const maps = ReflectUtils.findAllMetadata(ATTRIBUTE_APPLY_METADATA_KEY, target);
121
- maps.forEach((map) => {
122
- if (map instanceof Map) {
123
- map.forEach((v, k) => result.set(k, v));
124
- }
203
+ findAllAttributeMetadata(target).forEach((meta) => {
204
+ result.set(meta.propertyKey, meta);
125
205
  });
126
206
  return result;
127
207
  };
208
+ var applyAttribute_default = applyAttribute;
128
209
  export {
129
- ATTRIBUTE_APPLY_METADATA_KEY,
210
+ ATTRIBUTE_METADATA_KEY,
130
211
  applyAttribute,
131
- applyAttributeThis,
212
+ attribute,
213
+ attributeThis,
214
+ convertValue,
215
+ applyAttribute_default as default,
132
216
  findAllAttributeApplyMetadata,
133
- removeAttribute,
134
- removeAttributeThis,
217
+ findAllAttributeMetadata,
218
+ getAttributeValue,
219
+ resolveAttributeTargets,
135
220
  setAttribute,
136
- setAttributeThis,
137
- updateAttribute,
138
- updateAttributeThis
221
+ setAttributeThis
139
222
  };
140
223
  //# sourceMappingURL=applyAttribute.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/applyAttribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport type AttributeAction = 'set' | 'update' | 'remove';\n\nexport interface AttributeApplyOptions extends SwcQueryOptions {\n name?: string;\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface AttributeApplyMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: AttributeAction;\n options: AttributeApplyOptions;\n}\n\nexport const ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for('simple-web-component:attribute-apply');\n\nfunction createAttributeDecorator(action: AttributeAction) {\n return (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor) as Map<string | symbol, AttributeApplyMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AttributeApplyMetadata>();\n ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);\n }\n\n let attributeName = typeof nameOrOptions === 'string' ? nameOrOptions : undefined;\n let finalOptions = options;\n \n if (typeof nameOrOptions === 'object' && nameOrOptions !== null) {\n finalOptions = nameOrOptions as AttributeApplyOptions;\n }\n\n metaList.set(propertyKey, { \n propertyKey, \n selector, \n action, \n options: { ...finalOptions, name: attributeName } \n });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n const handleResult = (resolvedValue: any) => {\n if (resolvedValue !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = finalOptions.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === '$this' || !selector) applyRoot(host);\n else if (selector === '$host') applyRoot(hostSet.$host);\n else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === '$appHost') applyRoot(hostSet.$appHost);\n else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, {currentThis: this, helper: hostSet})) {\n return;\n }\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n\n if (action === 'set' || action === 'update') {\n if (attributeName) {\n // Case: @setAttribute(selector, 'name')\n if (resolvedRes === null || resolvedRes === undefined || resolvedRes === false) {\n targetEl.removeAttribute(attributeName);\n } else {\n targetEl.setAttribute(attributeName, resolvedRes === true ? '' : String(resolvedRes));\n }\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n // Case: @applyAttribute(selector) with Object return\n Object.entries(resolvedRes as any).forEach(([attr, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n if (finalVal === null || finalVal === undefined || finalVal === false) {\n targetEl.removeAttribute(attr);\n } else {\n targetEl.setAttribute(attr, finalVal === true ? '' : String(finalVal));\n }\n });\n }\n } else if (action === 'remove') {\n if (attributeName) {\n targetEl.removeAttribute(attributeName);\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([attr, val]) => {\n const shouldRemove = typeof val === 'function' ? val(targetEl, hostSet) : !!val;\n if (shouldRemove) targetEl.removeAttribute(attr);\n });\n } else {\n const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];\n attrs.forEach(a => targetEl.removeAttribute(String(a)));\n }\n }\n });\n }\n return resolvedValue;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n return descriptor;\n };\n };\n}\n\nexport function applyAttribute(selector: string, action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {\n return createAttributeDecorator(action)(selector, options);\n}\n\nexport const setAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')(selector, nameOrOptions, options);\nexport const updateAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(selector, nameOrOptions, options);\nexport const removeAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(selector, nameOrOptions, options);\n\n// This versions\nexport function applyAttributeThis(action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {\n return createAttributeDecorator(action)('$this', options);\n}\nexport const setAttributeThis = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')('$this', nameOrOptions, options);\nexport const updateAttributeThis = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')('$this', nameOrOptions, options);\nexport const removeAttributeThis = (nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')('$this', nameOrOptions, options);\n\nexport const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeApplyMetadata> => {\n const result = new Map<string | symbol, AttributeApplyMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AttributeApplyMetadata>>(ATTRIBUTE_APPLY_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAiBlB,MAAM,+BAA+B,OAAO,IAAI,sCAAsC;AAE7F,SAAS,yBAAyB,QAAyB;AACzD,SAAO,CAAC,UAAkB,eAAgD,UAAiC,CAAC,MAAuB;AACjI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Ae,OAAO;AAGtM,SAAS,mBAAmB,SAA0B,UAAU,UAAiC,CAAC,GAAoB;AAC3H,SAAO,yBAAyB,MAAM,EAAE,SAAS,OAAO;AAC1D;AACO,MAAM,mBAAmB,CAAC,eAA+C,UAAiC,CAAC,MAAM,yBAAyB,KAAK,EAAE,SAAS,eAAe,OAAO;AAChL,MAAM,sBAAsB,CAAC,eAA+C,UAAiC,CAAC,MAAM,yBAAyB,QAAQ,EAAE,SAAS,eAAe,OAAO;AACtL,MAAM,sBAAsB,CAAC,eAAgD,UAAiC,CAAC,MAAM,yBAAyB,QAAQ,EAAE,SAAS,eAAe,OAAO;AAEvL,MAAM,gCAAgC,CAAC,WAA8D;AAC1G,QAAM,SAAS,oBAAI,IAA6C;AAChE,QAAM,OAAO,aAAa,gBAA8D,8BAA8B,MAAM;AAC5H,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
4
+ "sourcesContent": ["import {ReflectUtils, FunctionUtils, ActionExpression} from '@dooboostore/core';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\nimport {SwcQueryOptions, HelperHostSet} from '../types';\nimport {ConvertUtils} from '@dooboostore/core-web';\n\n// ============================================\n// Types & Interfaces\n// ============================================\n\nexport interface AttributeOptions extends SwcQueryOptions {\n name?: string;\n type?: typeof Number | typeof Boolean | typeof String;\n filter?: (target: HTMLElement, value: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n}\n\nexport interface AttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n targetAttributeName: string;\n options: AttributeOptions;\n type: 'property' | 'method';\n}\n\nexport const ATTRIBUTE_METADATA_KEY = Symbol.for('simple-web-component:attribute');\n\n// ============================================\n// Utilities\n// ============================================\n\nconst convertValue = (val: string | null, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\nexport {convertValue};\n\nexport const getAttributeValue = (inst: any, attrName: string, options?: AttributeOptions & { selector?: string }): any => {\n const conf = getElementConfig(inst);\n const currentWin = inst._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // If selector is not provided, use inst itself\n const targets = options?.selector ? resolveAttributeTargets(inst, options.selector, options) : [inst];\n\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function' && (primaryTarget as any).hasAttribute(attrName)) {\n let domVal = (primaryTarget as any).getAttribute(attrName);\n\n // \uD45C\uD604\uC2DD \uCCB4\uD06C\n const ae = new ActionExpression(domVal);\n const expr = ae.getFirstExpression('callReturn');\n if (expr) {\n try {\n const result = FunctionUtils.executeReturn({\n script: ConvertUtils.decodeHtmlEntity(expr.script, currentWin.document),\n context: inst,\n args: SwcUtils.getHelperAndHostSet(currentWin, inst)\n });\n return convertValue(result, options?.type);\n } catch (err) {\n console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, err);\n return convertValue(domVal, options?.type);\n }\n }\n\n return convertValue(domVal, options?.type);\n }\n\n // If no target found, return null\n return null;\n};\n\n/**\n * Resolve target elements based on selector and options\n * Handles special selectors ($this, $host, etc.) and CSS selectors\n * Returns HTMLElement[] for attribute operations\n */\nexport const resolveAttributeTargets = (inst: any, selector: string, options: AttributeOptions): HTMLElement[] => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const r = options.root || 'auto';\n const results: HTMLElement[] = [];\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (selector === '$this' || !selector) {\n applyRoot(inst);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (selector === '$host') applyRoot(hostSet.$host);\n else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === '$appHost') applyRoot(hostSet.$appHost as any);\n else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(selector);\n const lMatch = inst.querySelectorAll(selector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(selector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @applyAttribute decorator - set/get element attributes\n *\n * Usage:\n * - @applyAttribute('selector', 'attrName') - Set attribute with explicit name\n * - @applyAttribute('selector') - Use property name as attribute name\n * - @applyAttribute('selector', { name: 'attrName' }) - Set attribute via options\n * - Return null to remove attribute\n */\nexport function applyAttribute(selector: string, targetAttributeName: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function applyAttribute(selector: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function applyAttribute(selector: string, targetAttributeNameOrOptions?: string | AttributeOptions, options?: AttributeOptions): MethodDecorator & PropertyDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n // ensureInit(target as any);\n\n const constructor = target.constructor;\n const designType = (Reflect as any).getMetadata('design:type', target, propertyKey);\n const metaType: 'property' | 'method' = descriptor && typeof descriptor.value === 'function' ? 'method' : 'property';\n\n // Parse arguments\n let finalOptions: AttributeOptions = {};\n let targetAttributeName: string;\n\n if (typeof targetAttributeNameOrOptions === 'string') {\n // applyAttribute('selector', 'attrName', options?)\n targetAttributeName = targetAttributeNameOrOptions;\n finalOptions = options || {};\n } else if (targetAttributeNameOrOptions) {\n // applyAttribute('selector', options)\n finalOptions = targetAttributeNameOrOptions;\n targetAttributeName = finalOptions.name || String(propertyKey);\n } else {\n // applyAttribute('selector')\n targetAttributeName = String(propertyKey);\n }\n\n // Store metadata\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor) as AttributeMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.push({\n propertyKey,\n selector,\n targetAttributeName,\n options: finalOptions,\n type: metaType\n });\n\n // Helper: Apply resolved value to targets\n const applyValueToTargets = (inst: any, resolvedValue: any) => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const targetEls = resolveAttributeTargets(inst, selector, finalOptions);\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n\n targetEls.forEach(targetEl => {\n // Apply filter if provided\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, {currentThis: inst, helper: hostSet})) {\n return;\n }\n\n if (resolvedValue === null) {\n // Remove attribute if value is null\n targetEl.removeAttribute(targetAttributeName);\n } else if (resolvedValue !== undefined) {\n // Set attribute\n targetEl.setAttribute(targetAttributeName, resolvedValue === true ? '' : String(resolvedValue));\n }\n });\n\n return resolvedValue;\n };\n\n // Method decorator: wrap method to apply its return value to attributes\n if (descriptor && typeof descriptor.value === 'function') {\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n if (res instanceof Promise) {\n return res.then((v: any) => {\n applyValueToTargets(this, v);\n return v;\n });\n } else {\n applyValueToTargets(this, res);\n return res;\n }\n };\n return;\n }\n\n // Property decorator: define getter/setter to proxy to element attributes\n Object.defineProperty(target, propertyKey, {\n configurable: true,\n enumerable: true,\n get(this: any) {\n ensureInit(this);\n const mergedOptions = {...finalOptions, selector, type: finalOptions.type || designType};\n return getAttributeValue(this, targetAttributeName, mergedOptions);\n },\n set(this: any, value: any) {\n ensureInit(this);\n\n if (value instanceof Promise) {\n value.then((v: any) => applyValueToTargets(this, v)).catch(() => { /* swallow */\n });\n } else {\n applyValueToTargets(this, value);\n }\n }\n });\n };\n}\n\n// ============================================\n// Convenience Aliases\n// ============================================\n\n/**\n * @attribute - Alias for @applyAttribute\n */\nexport function attribute(selector: string, targetAttributeName: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function attribute(selector: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function attribute(selector: string, targetAttributeNameOrOptions?: string | AttributeOptions, options?: AttributeOptions): MethodDecorator & PropertyDecorator {\n return applyAttribute(selector, targetAttributeNameOrOptions as any, options);\n}\n\n/**\n * @attributeThis - Apply attribute on $this element\n * Can be used as: @attributeThis or @attributeThis('attrName') or @attributeThis({ name: 'attrName' })\n */\nexport function attributeThis(target: Object, propertyKey: string | symbol): void;\nexport function attributeThis(targetAttributeName: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function attributeThis(options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function attributeThis(targetOrOptions?: any, propertyKeyOrOptions?: any, descriptor?: PropertyDescriptor): any {\n // Direct decorator usage: @attributeThis\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null && !Array.isArray(targetOrOptions) &&\n typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol') {\n // Called as @attributeThis (target, propertyKey)\n return applyAttribute('$this', undefined as any, {})(targetOrOptions, propertyKeyOrOptions, descriptor);\n }\n\n // Called with parameters\n if (typeof targetOrOptions === 'string') {\n // @attributeThis('attrName', options?)\n return applyAttribute('$this', targetOrOptions, propertyKeyOrOptions);\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // @attributeThis({ name: 'attrName' })\n return applyAttribute('$this', undefined as any, targetOrOptions);\n } else {\n // @attributeThis() or @attributeThis\n return applyAttribute('$this', undefined as any, {});\n }\n}\n\n/**\n * @setAttribute - Alias for @applyAttribute (method-decorator semantics)\n */\nexport function setAttribute(selector: string, targetAttributeName: string, options?: AttributeOptions): MethodDecorator;\nexport function setAttribute(selector: string, options?: AttributeOptions): MethodDecorator;\nexport function setAttribute(selector: string, targetAttributeNameOrOptions?: string | AttributeOptions, options?: AttributeOptions): MethodDecorator {\n return applyAttribute(selector, targetAttributeNameOrOptions as any, options) as MethodDecorator;\n}\n\n/**\n * @setAttributeThis - Set attribute on $this element\n * Can be used as: @setAttributeThis or @setAttributeThis('attrName') or @setAttributeThis({ name: 'attrName' })\n */\nexport function setAttributeThis(target: Object, propertyKey: string | symbol): void;\nexport function setAttributeThis(targetAttributeName: string, options?: AttributeOptions): MethodDecorator;\nexport function setAttributeThis(options?: AttributeOptions): MethodDecorator;\nexport function setAttributeThis(targetOrOptions?: any, propertyKeyOrOptions?: any, descriptor?: PropertyDescriptor): any {\n // Direct decorator usage: @setAttributeThis\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null && !Array.isArray(targetOrOptions) &&\n (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {\n // Called as @setAttributeThis (target, propertyKey)\n return applyAttribute('$this', undefined as any, {})(targetOrOptions, propertyKeyOrOptions, descriptor);\n }\n\n // Called with parameters\n if (typeof targetOrOptions === 'string') {\n // @setAttributeThis('attrName', options?)\n return applyAttribute('$this', targetOrOptions, propertyKeyOrOptions) as MethodDecorator;\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // @setAttributeThis({ name: 'attrName' })\n return applyAttribute('$this', undefined as any, targetOrOptions) as MethodDecorator;\n } else {\n // @setAttributeThis() or @setAttributeThis\n return applyAttribute('$this', undefined as any, {}) as MethodDecorator;\n }\n}\n\n// ============================================\n// Metadata Helpers\n// ============================================\n\nexport const findAllAttributeMetadata = (target: any): AttributeMetadata[] => {\n const actualTarget = target instanceof Function ? target : target.constructor;\n return ReflectUtils.findAllMetadata<AttributeMetadata[]>(ATTRIBUTE_METADATA_KEY, actualTarget).flat();\n};\n\n// Backward compatibility alias\nexport const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeMetadata> => {\n const result = new Map<string | symbol, AttributeMetadata>();\n findAllAttributeMetadata(target).forEach(meta => {\n result.set(meta.propertyKey, meta);\n });\n return result;\n};\n\n\nexport default applyAttribute;\n"],
5
+ "mappings": "AAAA,SAAQ,cAAc,eAAe,wBAAuB;AAC5D,SAAQ,YAAY,wBAAuB;AAC3C,SAAQ,gBAAe;AAEvB,SAAQ,oBAAmB;AAoBpB,MAAM,yBAAyB,OAAO,IAAI,gCAAgC;AAMjF,MAAM,eAAe,CAAC,KAAoB,SAAmB;AAC3D,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AACtE,SAAO;AACT;AAIO,MAAM,oBAAoB,CAAC,MAAW,UAAkB,YAA4D;AACzH,QAAM,OAAO,iBAAiB,IAAI;AAClC,QAAM,aAAa,KAAK,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AAG7F,QAAM,UAAU,SAAS,WAAW,wBAAwB,MAAM,QAAQ,UAAU,OAAO,IAAI,CAAC,IAAI;AAEpG,QAAM,gBAAgB,QAAQ,CAAC;AAE/B,MAAI,iBAAiB,OAAQ,cAAsB,iBAAiB,cAAe,cAAsB,aAAa,QAAQ,GAAG;AAC/H,QAAI,SAAU,cAAsB,aAAa,QAAQ;AAGzD,UAAM,KAAK,IAAI,iBAAiB,MAAM;AACtC,UAAM,OAAO,GAAG,mBAAmB,YAAY;AAC/C,QAAI,MAAM;AACR,UAAI;AACF,cAAM,SAAS,cAA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