@usesidekick/react 0.1.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.
Files changed (48) hide show
  1. package/README.md +246 -0
  2. package/dist/index.d.mts +358 -0
  3. package/dist/index.d.ts +358 -0
  4. package/dist/index.js +2470 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +2403 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/jsx-dev-runtime.d.mts +21 -0
  9. package/dist/jsx-dev-runtime.d.ts +21 -0
  10. package/dist/jsx-dev-runtime.js +160 -0
  11. package/dist/jsx-dev-runtime.js.map +1 -0
  12. package/dist/jsx-dev-runtime.mjs +122 -0
  13. package/dist/jsx-dev-runtime.mjs.map +1 -0
  14. package/dist/jsx-runtime.d.mts +26 -0
  15. package/dist/jsx-runtime.d.ts +26 -0
  16. package/dist/jsx-runtime.js +150 -0
  17. package/dist/jsx-runtime.js.map +1 -0
  18. package/dist/jsx-runtime.mjs +109 -0
  19. package/dist/jsx-runtime.mjs.map +1 -0
  20. package/dist/server/index.d.mts +235 -0
  21. package/dist/server/index.d.ts +235 -0
  22. package/dist/server/index.js +642 -0
  23. package/dist/server/index.js.map +1 -0
  24. package/dist/server/index.mjs +597 -0
  25. package/dist/server/index.mjs.map +1 -0
  26. package/package.json +64 -0
  27. package/src/components/SidekickPanel.tsx +868 -0
  28. package/src/components/index.ts +1 -0
  29. package/src/context.tsx +157 -0
  30. package/src/flags.ts +47 -0
  31. package/src/index.ts +71 -0
  32. package/src/jsx-dev-runtime.ts +138 -0
  33. package/src/jsx-runtime.ts +159 -0
  34. package/src/loader.ts +35 -0
  35. package/src/primitives/behavior.ts +70 -0
  36. package/src/primitives/data.ts +91 -0
  37. package/src/primitives/index.ts +3 -0
  38. package/src/primitives/ui.ts +268 -0
  39. package/src/provider.tsx +1264 -0
  40. package/src/runtime-loader.ts +106 -0
  41. package/src/server/drizzle-adapter.ts +53 -0
  42. package/src/server/drizzle-schema.ts +16 -0
  43. package/src/server/generate.ts +578 -0
  44. package/src/server/handler.ts +343 -0
  45. package/src/server/index.ts +20 -0
  46. package/src/server/storage.ts +1 -0
  47. package/src/server/types.ts +49 -0
  48. package/src/types.ts +295 -0
@@ -0,0 +1,122 @@
1
+ // src/jsx-dev-runtime.ts
2
+ import React2 from "react";
3
+
4
+ // src/jsx-runtime.ts
5
+ import React from "react";
6
+ var GLOBAL_KEY = "__SIDEKICK_JSX_CONFIG__";
7
+ function getGlobalConfig() {
8
+ const g = globalThis;
9
+ if (!g[GLOBAL_KEY]) {
10
+ g[GLOBAL_KEY] = {
11
+ getWrapper: null,
12
+ getReplacement: null,
13
+ listeners: /* @__PURE__ */ new Set(),
14
+ seenComponents: /* @__PURE__ */ new Set()
15
+ };
16
+ }
17
+ return g[GLOBAL_KEY];
18
+ }
19
+ var getDebug = () => typeof window !== "undefined" && window.__SIDEKICK_DEBUG__;
20
+ var Fragment = React.Fragment;
21
+ function configureJsxRuntime(wrapperGetter, replacementGetter) {
22
+ const config = getGlobalConfig();
23
+ config.getWrapper = wrapperGetter;
24
+ config.getReplacement = replacementGetter;
25
+ if (getDebug()) console.log("[Sidekick] JSX runtime configured (global)");
26
+ config.listeners.forEach((listener) => {
27
+ try {
28
+ listener();
29
+ } catch (e) {
30
+ console.error("[Sidekick] Config change listener error:", e);
31
+ }
32
+ });
33
+ }
34
+ function getSeenComponentsFromJsx() {
35
+ const config = getGlobalConfig();
36
+ return Array.from(config.seenComponents);
37
+ }
38
+
39
+ // src/jsx-dev-runtime.ts
40
+ var GLOBAL_KEY2 = "__SIDEKICK_JSX_CONFIG__";
41
+ function getGlobalConfig2() {
42
+ const g = globalThis;
43
+ if (!g[GLOBAL_KEY2]) {
44
+ g[GLOBAL_KEY2] = {
45
+ getWrapper: null,
46
+ getReplacement: null,
47
+ listeners: /* @__PURE__ */ new Set(),
48
+ seenComponents: /* @__PURE__ */ new Set()
49
+ };
50
+ }
51
+ return g[GLOBAL_KEY2];
52
+ }
53
+ var getDebug2 = () => typeof window !== "undefined" && window.__SIDEKICK_DEBUG__;
54
+ function getComponentName(type) {
55
+ if (!type) return null;
56
+ if (typeof type === "function") {
57
+ const fn = type;
58
+ if (fn.displayName) return fn.displayName;
59
+ if (fn.name) return fn.name;
60
+ return null;
61
+ }
62
+ if (typeof type === "object" && type !== null) {
63
+ const obj = type;
64
+ if (obj.displayName) return obj.displayName;
65
+ if (obj.$$typeof) {
66
+ if (obj.type) return getComponentName(obj.type);
67
+ if (obj.render) return getComponentName(obj.render);
68
+ }
69
+ }
70
+ return null;
71
+ }
72
+ function interceptType(type) {
73
+ if (typeof type === "function" || typeof type === "object" && type !== null) {
74
+ const name = getComponentName(type);
75
+ const debug = getDebug2();
76
+ const config = getGlobalConfig2();
77
+ if (name) {
78
+ if (debug && !config.seenComponents.has(name)) {
79
+ config.seenComponents.add(name);
80
+ console.log(`[Sidekick] Seen component: ${name}`);
81
+ }
82
+ if (config.getReplacement) {
83
+ const replacement = config.getReplacement(name);
84
+ if (replacement) {
85
+ if (debug) console.log(`[Sidekick] Replacing: ${name}`);
86
+ return replacement;
87
+ }
88
+ }
89
+ if (config.getWrapper) {
90
+ const wrapper = config.getWrapper(name);
91
+ if (wrapper) {
92
+ if (debug) console.log(`[Sidekick] Wrapping: ${name}`);
93
+ return wrapper(type);
94
+ }
95
+ }
96
+ }
97
+ }
98
+ return type;
99
+ }
100
+ function jsxDEV(type, props, key, _isStaticChildren, _source, _self) {
101
+ const { children, ...restProps } = props || {};
102
+ const finalProps = key !== void 0 ? { ...restProps, key } : restProps;
103
+ if (Array.isArray(children)) {
104
+ return React2.createElement(interceptType(type), finalProps, ...children);
105
+ }
106
+ return React2.createElement(interceptType(type), finalProps, children);
107
+ }
108
+ var Fragment2 = React2.Fragment;
109
+ function configureJsxDevRuntime(wrapperGetter, replacementGetter) {
110
+ const config = getGlobalConfig2();
111
+ config.getWrapper = wrapperGetter;
112
+ config.getReplacement = replacementGetter;
113
+ configureJsxRuntime(wrapperGetter, replacementGetter);
114
+ if (getDebug2()) console.log("[Sidekick] JSX dev runtime configured (global)");
115
+ }
116
+ export {
117
+ Fragment2 as Fragment,
118
+ configureJsxDevRuntime,
119
+ getSeenComponentsFromJsx,
120
+ jsxDEV
121
+ };
122
+ //# sourceMappingURL=jsx-dev-runtime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/jsx-dev-runtime.ts","../src/jsx-runtime.ts"],"sourcesContent":["/**\n * Custom JSX dev runtime that intercepts component creation.\n * This is used in development mode.\n * Uses React.createElement internally to avoid circular dependency with react/jsx-dev-runtime alias.\n *\n * IMPORTANT: Uses the same globalThis-based config as jsx-runtime.ts\n * so all module instances share the same configuration regardless of bundling.\n */\n\nimport React from 'react';\nimport { configureJsxRuntime, getSeenComponentsFromJsx } from './jsx-runtime';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype WrapperGetter = (name: string) => ((Component: any) => any) | undefined;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ReplacementGetter = (name: string) => any | undefined;\n\nconst GLOBAL_KEY = '__SIDEKICK_JSX_CONFIG__';\n\ninterface SidekickJsxConfig {\n getWrapper: WrapperGetter | null;\n getReplacement: ReplacementGetter | null;\n listeners: Set<() => void>;\n seenComponents: Set<string>;\n}\n\nfunction getGlobalConfig(): SidekickJsxConfig {\n const g = globalThis as Record<string, unknown>;\n if (!g[GLOBAL_KEY]) {\n g[GLOBAL_KEY] = {\n getWrapper: null,\n getReplacement: null,\n listeners: new Set(),\n seenComponents: new Set<string>(),\n };\n }\n return g[GLOBAL_KEY] as SidekickJsxConfig;\n}\n\n// Debug mode\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst getDebug = () => typeof window !== 'undefined' && (window as any).__SIDEKICK_DEBUG__;\n\nfunction getComponentName(type: unknown): string | null {\n if (!type) return null;\n\n if (typeof type === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fn = type as any;\n if (fn.displayName) return fn.displayName;\n if (fn.name) return fn.name;\n return null;\n }\n\n if (typeof type === 'object' && type !== null) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const obj = type as any;\n if (obj.displayName) return obj.displayName;\n if (obj.$$typeof) {\n if (obj.type) return getComponentName(obj.type);\n if (obj.render) return getComponentName(obj.render);\n }\n }\n\n return null;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction interceptType(type: any): any {\n if (typeof type === 'function' || (typeof type === 'object' && type !== null)) {\n const name = getComponentName(type);\n const debug = getDebug();\n const config = getGlobalConfig();\n\n if (name) {\n if (debug && !config.seenComponents.has(name)) {\n config.seenComponents.add(name);\n console.log(`[Sidekick] Seen component: ${name}`);\n }\n\n if (config.getReplacement) {\n const replacement = config.getReplacement(name);\n if (replacement) {\n if (debug) console.log(`[Sidekick] Replacing: ${name}`);\n return replacement;\n }\n }\n\n if (config.getWrapper) {\n const wrapper = config.getWrapper(name);\n if (wrapper) {\n if (debug) console.log(`[Sidekick] Wrapping: ${name}`);\n return wrapper(type);\n }\n }\n }\n }\n\n return type;\n}\n\n// Wrapped jsxDEV function - uses React.createElement to avoid circular alias\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function jsxDEV(\n type: any,\n props: any,\n key: string | undefined,\n _isStaticChildren: boolean,\n _source: any,\n _self: any\n) {\n const { children, ...restProps } = props || {};\n const finalProps = key !== undefined ? { ...restProps, key } : restProps;\n\n // Handle both single child and array of children\n if (Array.isArray(children)) {\n return React.createElement(interceptType(type), finalProps, ...children);\n }\n return React.createElement(interceptType(type), finalProps, children);\n}\n\n// Re-export Fragment from React\nexport const Fragment = React.Fragment;\n\n// Configuration function - configures the shared global state\nexport function configureJsxDevRuntime(\n wrapperGetter: WrapperGetter,\n replacementGetter: ReplacementGetter\n) {\n const config = getGlobalConfig();\n config.getWrapper = wrapperGetter;\n config.getReplacement = replacementGetter;\n // Also configure via the production runtime's function (for its listeners)\n configureJsxRuntime(wrapperGetter, replacementGetter);\n if (getDebug()) console.log('[Sidekick] JSX dev runtime configured (global)');\n}\n\nexport { getSeenComponentsFromJsx };\n","/**\n * Custom JSX runtime that intercepts component creation.\n * Uses React.createElement internally to avoid circular dependency with react/jsx-runtime alias.\n *\n * IMPORTANT: Uses globalThis to share state between module instances.\n * When bundled with splitting:false, index.mjs and jsx-runtime.mjs each get their own copy.\n * The provider configures the copy in index.mjs, but JSX calls use jsx-runtime.mjs.\n * By storing getters on globalThis, all instances share the same configuration.\n */\n\nimport React from 'react';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype WrapperGetter = (name: string) => ((Component: any) => any) | undefined;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ReplacementGetter = (name: string) => any | undefined;\ntype ConfigChangeListener = () => void;\n\nconst GLOBAL_KEY = '__SIDEKICK_JSX_CONFIG__';\n\ninterface SidekickJsxConfig {\n getWrapper: WrapperGetter | null;\n getReplacement: ReplacementGetter | null;\n listeners: Set<ConfigChangeListener>;\n seenComponents: Set<string>;\n}\n\nfunction getGlobalConfig(): SidekickJsxConfig {\n const g = globalThis as Record<string, unknown>;\n if (!g[GLOBAL_KEY]) {\n g[GLOBAL_KEY] = {\n getWrapper: null,\n getReplacement: null,\n listeners: new Set<ConfigChangeListener>(),\n seenComponents: new Set<string>(),\n };\n }\n return g[GLOBAL_KEY] as SidekickJsxConfig;\n}\n\n// Debug mode - check on each call since it might be set after module load\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst getDebug = () => typeof window !== 'undefined' && (window as any).__SIDEKICK_DEBUG__;\n\nfunction getComponentName(type: unknown): string | null {\n if (!type) return null;\n\n if (typeof type === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fn = type as any;\n if (fn.displayName) return fn.displayName;\n if (fn.name) return fn.name;\n return null;\n }\n\n if (typeof type === 'object' && type !== null) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const obj = type as any;\n if (obj.displayName) return obj.displayName;\n if (obj.$$typeof) {\n if (obj.type) return getComponentName(obj.type);\n if (obj.render) return getComponentName(obj.render);\n }\n }\n\n return null;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction interceptType(type: any): any {\n if (typeof type === 'function' || (typeof type === 'object' && type !== null)) {\n const name = getComponentName(type);\n const debug = getDebug();\n const config = getGlobalConfig();\n\n if (name) {\n if (debug && !config.seenComponents.has(name)) {\n config.seenComponents.add(name);\n console.log(`[Sidekick] Seen component: ${name}`);\n }\n\n if (config.getReplacement) {\n const replacement = config.getReplacement(name);\n if (replacement) {\n if (debug) console.log(`[Sidekick] Replacing: ${name}`);\n return replacement;\n }\n }\n\n if (config.getWrapper) {\n const wrapper = config.getWrapper(name);\n if (wrapper) {\n if (debug) console.log(`[Sidekick] Wrapping: ${name}`);\n return wrapper(type);\n }\n }\n }\n }\n\n return type;\n}\n\n// Wrapped jsx function - uses React.createElement to avoid circular alias\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function jsx(type: any, props: any, key?: string) {\n const { children, ...restProps } = props || {};\n const finalProps = key !== undefined ? { ...restProps, key } : restProps;\n return React.createElement(interceptType(type), finalProps, children);\n}\n\n// Wrapped jsxs function (for multiple children)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function jsxs(type: any, props: any, key?: string) {\n const { children, ...restProps } = props || {};\n const finalProps = key !== undefined ? { ...restProps, key } : restProps;\n // For jsxs, children is always an array\n return React.createElement(interceptType(type), finalProps, ...(children || []));\n}\n\n// Re-export Fragment from React\nexport const Fragment = React.Fragment;\n\n// Configuration function - called by SidekickProvider\nexport function configureJsxRuntime(\n wrapperGetter: WrapperGetter,\n replacementGetter: ReplacementGetter\n) {\n const config = getGlobalConfig();\n config.getWrapper = wrapperGetter;\n config.getReplacement = replacementGetter;\n if (getDebug()) console.log('[Sidekick] JSX runtime configured (global)');\n\n // Notify all listeners that config has changed\n config.listeners.forEach(listener => {\n try {\n listener();\n } catch (e) {\n console.error('[Sidekick] Config change listener error:', e);\n }\n });\n}\n\n// Subscribe to config changes (for triggering re-renders)\nexport function onConfigChange(listener: ConfigChangeListener): () => void {\n const config = getGlobalConfig();\n config.listeners.add(listener);\n return () => config.listeners.delete(listener);\n}\n\n// Check if the runtime is configured\nexport function isJsxRuntimeConfigured(): boolean {\n const config = getGlobalConfig();\n return config.getWrapper !== null || config.getReplacement !== null;\n}\n\nexport function getSeenComponentsFromJsx(): string[] {\n const config = getGlobalConfig();\n return Array.from(config.seenComponents);\n}\n"],"mappings":";AASA,OAAOA,YAAW;;;ACClB,OAAO,WAAW;AAQlB,IAAM,aAAa;AASnB,SAAS,kBAAqC;AAC5C,QAAM,IAAI;AACV,MAAI,CAAC,EAAE,UAAU,GAAG;AAClB,MAAE,UAAU,IAAI;AAAA,MACd,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,WAAW,oBAAI,IAA0B;AAAA,MACzC,gBAAgB,oBAAI,IAAY;AAAA,IAClC;AAAA,EACF;AACA,SAAO,EAAE,UAAU;AACrB;AAIA,IAAM,WAAW,MAAM,OAAO,WAAW,eAAgB,OAAe;AA8EjE,IAAM,WAAW,MAAM;AAGvB,SAAS,oBACd,eACA,mBACA;AACA,QAAM,SAAS,gBAAgB;AAC/B,SAAO,aAAa;AACpB,SAAO,iBAAiB;AACxB,MAAI,SAAS,EAAG,SAAQ,IAAI,4CAA4C;AAGxE,SAAO,UAAU,QAAQ,cAAY;AACnC,QAAI;AACF,eAAS;AAAA,IACX,SAAS,GAAG;AACV,cAAQ,MAAM,4CAA4C,CAAC;AAAA,IAC7D;AAAA,EACF,CAAC;AACH;AAeO,SAAS,2BAAqC;AACnD,QAAM,SAAS,gBAAgB;AAC/B,SAAO,MAAM,KAAK,OAAO,cAAc;AACzC;;;AD7IA,IAAMC,cAAa;AASnB,SAASC,mBAAqC;AAC5C,QAAM,IAAI;AACV,MAAI,CAAC,EAAED,WAAU,GAAG;AAClB,MAAEA,WAAU,IAAI;AAAA,MACd,YAAY;AAAA,MACZ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AO,SAAQ,IAAI,wBAAwB,IAAI,EAAE;AACrD,iBAAO,QAAQ,IAAI;AAAA,QACrB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAIO,SAAS,OACd,MACA,OACA,KACA,mBACA,SACA,OACA;AACA,QAAM,EAAE,UAAU,GAAG,UAAU,IAAI,SAAS,CAAC;AAC7C,QAAM,aAAa,QAAQ,SAAY,EAAE,GAAG,WAAW,IAAI,IAAI;AAG/D,MAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,WAAOE,OAAM,cAAc,cAAc,IAAI,GAAG,YAAY,GAAG,QAAQ;AAAA,EACzE;AACA,SAAOA,OAAM,cAAc,cAAc,IAAI,GAAG,YAAY,QAAQ;AACtE;AAGO,IAAMC,YAAWD,OAAM;AAGvB,SAAS,uBACd,eACA,mBACA;AACA,QAAM,SAASF,iBAAgB;AAC/B,SAAO,aAAa;AACpB,SAAO,iBAAiB;AAExB,sBAAoB,eAAe,iBAAiB;AACpD,MAAIC,UAAS,EAAG,SAAQ,IAAI,gDAAgD;AAC9E;","names":["React","GLOBAL_KEY","getGlobalConfig","getDebug","React","Fragment"]}
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * Custom JSX runtime that intercepts component creation.
5
+ * Uses React.createElement internally to avoid circular dependency with react/jsx-runtime alias.
6
+ *
7
+ * IMPORTANT: Uses globalThis to share state between module instances.
8
+ * When bundled with splitting:false, index.mjs and jsx-runtime.mjs each get their own copy.
9
+ * The provider configures the copy in index.mjs, but JSX calls use jsx-runtime.mjs.
10
+ * By storing getters on globalThis, all instances share the same configuration.
11
+ */
12
+
13
+ type WrapperGetter = (name: string) => ((Component: any) => any) | undefined;
14
+ type ReplacementGetter = (name: string) => any | undefined;
15
+ type ConfigChangeListener = () => void;
16
+ declare function jsx(type: any, props: any, key?: string): React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
17
+ declare function jsxs(type: any, props: any, key?: string): React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
18
+ declare const Fragment: React.ExoticComponent<{
19
+ children?: React.ReactNode | undefined;
20
+ }>;
21
+ declare function configureJsxRuntime(wrapperGetter: WrapperGetter, replacementGetter: ReplacementGetter): void;
22
+ declare function onConfigChange(listener: ConfigChangeListener): () => void;
23
+ declare function isJsxRuntimeConfigured(): boolean;
24
+ declare function getSeenComponentsFromJsx(): string[];
25
+
26
+ export { Fragment, configureJsxRuntime, getSeenComponentsFromJsx, isJsxRuntimeConfigured, jsx, jsxs, onConfigChange };
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * Custom JSX runtime that intercepts component creation.
5
+ * Uses React.createElement internally to avoid circular dependency with react/jsx-runtime alias.
6
+ *
7
+ * IMPORTANT: Uses globalThis to share state between module instances.
8
+ * When bundled with splitting:false, index.mjs and jsx-runtime.mjs each get their own copy.
9
+ * The provider configures the copy in index.mjs, but JSX calls use jsx-runtime.mjs.
10
+ * By storing getters on globalThis, all instances share the same configuration.
11
+ */
12
+
13
+ type WrapperGetter = (name: string) => ((Component: any) => any) | undefined;
14
+ type ReplacementGetter = (name: string) => any | undefined;
15
+ type ConfigChangeListener = () => void;
16
+ declare function jsx(type: any, props: any, key?: string): React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
17
+ declare function jsxs(type: any, props: any, key?: string): React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
18
+ declare const Fragment: React.ExoticComponent<{
19
+ children?: React.ReactNode | undefined;
20
+ }>;
21
+ declare function configureJsxRuntime(wrapperGetter: WrapperGetter, replacementGetter: ReplacementGetter): void;
22
+ declare function onConfigChange(listener: ConfigChangeListener): () => void;
23
+ declare function isJsxRuntimeConfigured(): boolean;
24
+ declare function getSeenComponentsFromJsx(): string[];
25
+
26
+ export { Fragment, configureJsxRuntime, getSeenComponentsFromJsx, isJsxRuntimeConfigured, jsx, jsxs, onConfigChange };
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/jsx-runtime.ts
31
+ var jsx_runtime_exports = {};
32
+ __export(jsx_runtime_exports, {
33
+ Fragment: () => Fragment,
34
+ configureJsxRuntime: () => configureJsxRuntime,
35
+ getSeenComponentsFromJsx: () => getSeenComponentsFromJsx,
36
+ isJsxRuntimeConfigured: () => isJsxRuntimeConfigured,
37
+ jsx: () => jsx,
38
+ jsxs: () => jsxs,
39
+ onConfigChange: () => onConfigChange
40
+ });
41
+ module.exports = __toCommonJS(jsx_runtime_exports);
42
+ var import_react = __toESM(require("react"));
43
+ var GLOBAL_KEY = "__SIDEKICK_JSX_CONFIG__";
44
+ function getGlobalConfig() {
45
+ const g = globalThis;
46
+ if (!g[GLOBAL_KEY]) {
47
+ g[GLOBAL_KEY] = {
48
+ getWrapper: null,
49
+ getReplacement: null,
50
+ listeners: /* @__PURE__ */ new Set(),
51
+ seenComponents: /* @__PURE__ */ new Set()
52
+ };
53
+ }
54
+ return g[GLOBAL_KEY];
55
+ }
56
+ var getDebug = () => typeof window !== "undefined" && window.__SIDEKICK_DEBUG__;
57
+ function getComponentName(type) {
58
+ if (!type) return null;
59
+ if (typeof type === "function") {
60
+ const fn = type;
61
+ if (fn.displayName) return fn.displayName;
62
+ if (fn.name) return fn.name;
63
+ return null;
64
+ }
65
+ if (typeof type === "object" && type !== null) {
66
+ const obj = type;
67
+ if (obj.displayName) return obj.displayName;
68
+ if (obj.$$typeof) {
69
+ if (obj.type) return getComponentName(obj.type);
70
+ if (obj.render) return getComponentName(obj.render);
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+ function interceptType(type) {
76
+ if (typeof type === "function" || typeof type === "object" && type !== null) {
77
+ const name = getComponentName(type);
78
+ const debug = getDebug();
79
+ const config = getGlobalConfig();
80
+ if (name) {
81
+ if (debug && !config.seenComponents.has(name)) {
82
+ config.seenComponents.add(name);
83
+ console.log(`[Sidekick] Seen component: ${name}`);
84
+ }
85
+ if (config.getReplacement) {
86
+ const replacement = config.getReplacement(name);
87
+ if (replacement) {
88
+ if (debug) console.log(`[Sidekick] Replacing: ${name}`);
89
+ return replacement;
90
+ }
91
+ }
92
+ if (config.getWrapper) {
93
+ const wrapper = config.getWrapper(name);
94
+ if (wrapper) {
95
+ if (debug) console.log(`[Sidekick] Wrapping: ${name}`);
96
+ return wrapper(type);
97
+ }
98
+ }
99
+ }
100
+ }
101
+ return type;
102
+ }
103
+ function jsx(type, props, key) {
104
+ const { children, ...restProps } = props || {};
105
+ const finalProps = key !== void 0 ? { ...restProps, key } : restProps;
106
+ return import_react.default.createElement(interceptType(type), finalProps, children);
107
+ }
108
+ function jsxs(type, props, key) {
109
+ const { children, ...restProps } = props || {};
110
+ const finalProps = key !== void 0 ? { ...restProps, key } : restProps;
111
+ return import_react.default.createElement(interceptType(type), finalProps, ...children || []);
112
+ }
113
+ var Fragment = import_react.default.Fragment;
114
+ function configureJsxRuntime(wrapperGetter, replacementGetter) {
115
+ const config = getGlobalConfig();
116
+ config.getWrapper = wrapperGetter;
117
+ config.getReplacement = replacementGetter;
118
+ if (getDebug()) console.log("[Sidekick] JSX runtime configured (global)");
119
+ config.listeners.forEach((listener) => {
120
+ try {
121
+ listener();
122
+ } catch (e) {
123
+ console.error("[Sidekick] Config change listener error:", e);
124
+ }
125
+ });
126
+ }
127
+ function onConfigChange(listener) {
128
+ const config = getGlobalConfig();
129
+ config.listeners.add(listener);
130
+ return () => config.listeners.delete(listener);
131
+ }
132
+ function isJsxRuntimeConfigured() {
133
+ const config = getGlobalConfig();
134
+ return config.getWrapper !== null || config.getReplacement !== null;
135
+ }
136
+ function getSeenComponentsFromJsx() {
137
+ const config = getGlobalConfig();
138
+ return Array.from(config.seenComponents);
139
+ }
140
+ // Annotate the CommonJS export names for ESM import in node:
141
+ 0 && (module.exports = {
142
+ Fragment,
143
+ configureJsxRuntime,
144
+ getSeenComponentsFromJsx,
145
+ isJsxRuntimeConfigured,
146
+ jsx,
147
+ jsxs,
148
+ onConfigChange
149
+ });
150
+ //# sourceMappingURL=jsx-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/jsx-runtime.ts"],"sourcesContent":["/**\n * Custom JSX runtime that intercepts component creation.\n * Uses React.createElement internally to avoid circular dependency with react/jsx-runtime alias.\n *\n * IMPORTANT: Uses globalThis to share state between module instances.\n * When bundled with splitting:false, index.mjs and jsx-runtime.mjs each get their own copy.\n * The provider configures the copy in index.mjs, but JSX calls use jsx-runtime.mjs.\n * By storing getters on globalThis, all instances share the same configuration.\n */\n\nimport React from 'react';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype WrapperGetter = (name: string) => ((Component: any) => any) | undefined;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ReplacementGetter = (name: string) => any | undefined;\ntype ConfigChangeListener = () => void;\n\nconst GLOBAL_KEY = '__SIDEKICK_JSX_CONFIG__';\n\ninterface SidekickJsxConfig {\n getWrapper: WrapperGetter | null;\n getReplacement: ReplacementGetter | null;\n listeners: Set<ConfigChangeListener>;\n seenComponents: Set<string>;\n}\n\nfunction getGlobalConfig(): SidekickJsxConfig {\n const g = globalThis as Record<string, unknown>;\n if (!g[GLOBAL_KEY]) {\n g[GLOBAL_KEY] = {\n getWrapper: null,\n getReplacement: null,\n listeners: new Set<ConfigChangeListener>(),\n seenComponents: new Set<string>(),\n };\n }\n return g[GLOBAL_KEY] as SidekickJsxConfig;\n}\n\n// Debug mode - check on each call since it might be set after module load\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst getDebug = () => typeof window !== 'undefined' && (window as any).__SIDEKICK_DEBUG__;\n\nfunction getComponentName(type: unknown): string | null {\n if (!type) return null;\n\n if (typeof type === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fn = type as any;\n if (fn.displayName) return fn.displayName;\n if (fn.name) return fn.name;\n return null;\n }\n\n if (typeof type === 'object' && type !== null) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const obj = type as any;\n if (obj.displayName) return obj.displayName;\n if (obj.$$typeof) {\n if (obj.type) return getComponentName(obj.type);\n if (obj.render) return getComponentName(obj.render);\n }\n }\n\n return null;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction interceptType(type: any): any {\n if (typeof type === 'function' || (typeof type === 'object' && type !== null)) {\n const name = getComponentName(type);\n const debug = getDebug();\n const config = getGlobalConfig();\n\n if (name) {\n if (debug && !config.seenComponents.has(name)) {\n config.seenComponents.add(name);\n console.log(`[Sidekick] Seen component: ${name}`);\n }\n\n if (config.getReplacement) {\n const replacement = config.getReplacement(name);\n if (replacement) {\n if (debug) console.log(`[Sidekick] Replacing: ${name}`);\n return replacement;\n }\n }\n\n if (config.getWrapper) {\n const wrapper = config.getWrapper(name);\n if (wrapper) {\n if (debug) console.log(`[Sidekick] Wrapping: ${name}`);\n return wrapper(type);\n }\n }\n }\n }\n\n return type;\n}\n\n// Wrapped jsx function - uses React.createElement to avoid circular alias\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function jsx(type: any, props: any, key?: string) {\n const { children, ...restProps } = props || {};\n const finalProps = key !== undefined ? { ...restProps, key } : restProps;\n return React.createElement(interceptType(type), finalProps, children);\n}\n\n// Wrapped jsxs function (for multiple children)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function jsxs(type: any, props: any, key?: string) {\n const { children, ...restProps } = props || {};\n const finalProps = key !== undefined ? { ...restProps, key } : restProps;\n // For jsxs, children is always an array\n return React.createElement(interceptType(type), finalProps, ...(children || []));\n}\n\n// Re-export Fragment from React\nexport const Fragment = React.Fragment;\n\n// Configuration function - called by SidekickProvider\nexport function configureJsxRuntime(\n wrapperGetter: WrapperGetter,\n replacementGetter: ReplacementGetter\n) {\n const config = getGlobalConfig();\n config.getWrapper = wrapperGetter;\n config.getReplacement = replacementGetter;\n if (getDebug()) console.log('[Sidekick] JSX runtime configured (global)');\n\n // Notify all listeners that config has changed\n config.listeners.forEach(listener => {\n try {\n listener();\n } catch (e) {\n console.error('[Sidekick] Config change listener error:', e);\n }\n });\n}\n\n// Subscribe to config changes (for triggering re-renders)\nexport function onConfigChange(listener: ConfigChangeListener): () => void {\n const config = getGlobalConfig();\n config.listeners.add(listener);\n return () => config.listeners.delete(listener);\n}\n\n// Check if the runtime is configured\nexport function isJsxRuntimeConfigured(): boolean {\n const config = getGlobalConfig();\n return config.getWrapper !== null || config.getReplacement !== null;\n}\n\nexport function getSeenComponentsFromJsx(): string[] {\n const config = getGlobalConfig();\n return Array.from(config.seenComponents);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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AAO,MAAM,OAAO,UAAU,OAAO,QAAQ;AAC/C;AAGO,SAAS,yBAAkC;AAChD,QAAM,SAAS,gBAAgB;AAC/B,SAAO,OAAO,eAAe,QAAQ,OAAO,mBAAmB;AACjE;AAEO,SAAS,2BAAqC;AACnD,QAAM,SAAS,gBAAgB;AAC/B,SAAO,MAAM,KAAK,OAAO,cAAc;AACzC;","names":["React"]}
@@ -0,0 +1,109 @@
1
+ // src/jsx-runtime.ts
2
+ import React from "react";
3
+ var GLOBAL_KEY = "__SIDEKICK_JSX_CONFIG__";
4
+ function getGlobalConfig() {
5
+ const g = globalThis;
6
+ if (!g[GLOBAL_KEY]) {
7
+ g[GLOBAL_KEY] = {
8
+ getWrapper: null,
9
+ getReplacement: null,
10
+ listeners: /* @__PURE__ */ new Set(),
11
+ seenComponents: /* @__PURE__ */ new Set()
12
+ };
13
+ }
14
+ return g[GLOBAL_KEY];
15
+ }
16
+ var getDebug = () => typeof window !== "undefined" && window.__SIDEKICK_DEBUG__;
17
+ function getComponentName(type) {
18
+ if (!type) return null;
19
+ if (typeof type === "function") {
20
+ const fn = type;
21
+ if (fn.displayName) return fn.displayName;
22
+ if (fn.name) return fn.name;
23
+ return null;
24
+ }
25
+ if (typeof type === "object" && type !== null) {
26
+ const obj = type;
27
+ if (obj.displayName) return obj.displayName;
28
+ if (obj.$$typeof) {
29
+ if (obj.type) return getComponentName(obj.type);
30
+ if (obj.render) return getComponentName(obj.render);
31
+ }
32
+ }
33
+ return null;
34
+ }
35
+ function interceptType(type) {
36
+ if (typeof type === "function" || typeof type === "object" && type !== null) {
37
+ const name = getComponentName(type);
38
+ const debug = getDebug();
39
+ const config = getGlobalConfig();
40
+ if (name) {
41
+ if (debug && !config.seenComponents.has(name)) {
42
+ config.seenComponents.add(name);
43
+ console.log(`[Sidekick] Seen component: ${name}`);
44
+ }
45
+ if (config.getReplacement) {
46
+ const replacement = config.getReplacement(name);
47
+ if (replacement) {
48
+ if (debug) console.log(`[Sidekick] Replacing: ${name}`);
49
+ return replacement;
50
+ }
51
+ }
52
+ if (config.getWrapper) {
53
+ const wrapper = config.getWrapper(name);
54
+ if (wrapper) {
55
+ if (debug) console.log(`[Sidekick] Wrapping: ${name}`);
56
+ return wrapper(type);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return type;
62
+ }
63
+ function jsx(type, props, key) {
64
+ const { children, ...restProps } = props || {};
65
+ const finalProps = key !== void 0 ? { ...restProps, key } : restProps;
66
+ return React.createElement(interceptType(type), finalProps, children);
67
+ }
68
+ function jsxs(type, props, key) {
69
+ const { children, ...restProps } = props || {};
70
+ const finalProps = key !== void 0 ? { ...restProps, key } : restProps;
71
+ return React.createElement(interceptType(type), finalProps, ...children || []);
72
+ }
73
+ var Fragment = React.Fragment;
74
+ function configureJsxRuntime(wrapperGetter, replacementGetter) {
75
+ const config = getGlobalConfig();
76
+ config.getWrapper = wrapperGetter;
77
+ config.getReplacement = replacementGetter;
78
+ if (getDebug()) console.log("[Sidekick] JSX runtime configured (global)");
79
+ config.listeners.forEach((listener) => {
80
+ try {
81
+ listener();
82
+ } catch (e) {
83
+ console.error("[Sidekick] Config change listener error:", e);
84
+ }
85
+ });
86
+ }
87
+ function onConfigChange(listener) {
88
+ const config = getGlobalConfig();
89
+ config.listeners.add(listener);
90
+ return () => config.listeners.delete(listener);
91
+ }
92
+ function isJsxRuntimeConfigured() {
93
+ const config = getGlobalConfig();
94
+ return config.getWrapper !== null || config.getReplacement !== null;
95
+ }
96
+ function getSeenComponentsFromJsx() {
97
+ const config = getGlobalConfig();
98
+ return Array.from(config.seenComponents);
99
+ }
100
+ export {
101
+ Fragment,
102
+ configureJsxRuntime,
103
+ getSeenComponentsFromJsx,
104
+ isJsxRuntimeConfigured,
105
+ jsx,
106
+ jsxs,
107
+ onConfigChange
108
+ };
109
+ //# sourceMappingURL=jsx-runtime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/jsx-runtime.ts"],"sourcesContent":["/**\n * Custom JSX runtime that intercepts component creation.\n * Uses React.createElement internally to avoid circular dependency with react/jsx-runtime alias.\n *\n * IMPORTANT: Uses globalThis to share state between module instances.\n * When bundled with splitting:false, index.mjs and jsx-runtime.mjs each get their own copy.\n * The provider configures the copy in index.mjs, but JSX calls use jsx-runtime.mjs.\n * By storing getters on globalThis, all instances share the same configuration.\n */\n\nimport React from 'react';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype WrapperGetter = (name: string) => ((Component: any) => any) | undefined;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ReplacementGetter = (name: string) => any | undefined;\ntype ConfigChangeListener = () => void;\n\nconst GLOBAL_KEY = '__SIDEKICK_JSX_CONFIG__';\n\ninterface SidekickJsxConfig {\n getWrapper: WrapperGetter | null;\n getReplacement: ReplacementGetter | null;\n listeners: Set<ConfigChangeListener>;\n seenComponents: Set<string>;\n}\n\nfunction getGlobalConfig(): SidekickJsxConfig {\n const g = globalThis as Record<string, unknown>;\n if (!g[GLOBAL_KEY]) {\n g[GLOBAL_KEY] = {\n getWrapper: null,\n getReplacement: null,\n listeners: new Set<ConfigChangeListener>(),\n seenComponents: new Set<string>(),\n };\n }\n return g[GLOBAL_KEY] as SidekickJsxConfig;\n}\n\n// Debug mode - check on each call since it might be set after module load\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst getDebug = () => typeof window !== 'undefined' && (window as any).__SIDEKICK_DEBUG__;\n\nfunction getComponentName(type: unknown): string | null {\n if (!type) return null;\n\n if (typeof type === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fn = type as any;\n if (fn.displayName) return fn.displayName;\n if (fn.name) return fn.name;\n return null;\n }\n\n if (typeof type === 'object' && type !== null) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const obj = type as any;\n if (obj.displayName) return obj.displayName;\n if (obj.$$typeof) {\n if (obj.type) return getComponentName(obj.type);\n if (obj.render) return getComponentName(obj.render);\n }\n }\n\n return null;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction interceptType(type: any): any {\n if (typeof type === 'function' || (typeof type === 'object' && type !== null)) {\n const name = getComponentName(type);\n const debug = getDebug();\n const config = getGlobalConfig();\n\n if (name) {\n if (debug && !config.seenComponents.has(name)) {\n config.seenComponents.add(name);\n console.log(`[Sidekick] Seen component: ${name}`);\n }\n\n if (config.getReplacement) {\n const replacement = config.getReplacement(name);\n if (replacement) {\n if (debug) console.log(`[Sidekick] Replacing: ${name}`);\n return replacement;\n }\n }\n\n if (config.getWrapper) {\n const wrapper = config.getWrapper(name);\n if (wrapper) {\n if (debug) console.log(`[Sidekick] Wrapping: ${name}`);\n return wrapper(type);\n }\n }\n }\n }\n\n return type;\n}\n\n// Wrapped jsx function - uses React.createElement to avoid circular alias\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function jsx(type: any, props: any, key?: string) {\n const { children, ...restProps } = props || {};\n const finalProps = key !== undefined ? { ...restProps, key } : restProps;\n return React.createElement(interceptType(type), finalProps, children);\n}\n\n// Wrapped jsxs function (for multiple children)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function jsxs(type: any, props: any, key?: string) {\n const { children, ...restProps } = props || {};\n const finalProps = key !== undefined ? { ...restProps, key } : restProps;\n // For jsxs, children is always an array\n return React.createElement(interceptType(type), finalProps, ...(children || []));\n}\n\n// Re-export Fragment from React\nexport const Fragment = React.Fragment;\n\n// Configuration function - called by SidekickProvider\nexport function configureJsxRuntime(\n wrapperGetter: WrapperGetter,\n replacementGetter: ReplacementGetter\n) {\n const config = getGlobalConfig();\n config.getWrapper = wrapperGetter;\n config.getReplacement = replacementGetter;\n if (getDebug()) console.log('[Sidekick] JSX runtime configured (global)');\n\n // Notify all listeners that config has changed\n config.listeners.forEach(listener => {\n try {\n listener();\n } catch (e) {\n console.error('[Sidekick] Config change listener error:', e);\n }\n });\n}\n\n// Subscribe to config changes (for triggering re-renders)\nexport function onConfigChange(listener: ConfigChangeListener): () => void {\n const config = getGlobalConfig();\n config.listeners.add(listener);\n return () => config.listeners.delete(listener);\n}\n\n// Check if the runtime is configured\nexport function isJsxRuntimeConfigured(): boolean {\n const config = getGlobalConfig();\n return config.getWrapper !== null || config.getReplacement !== null;\n}\n\nexport function getSeenComponentsFromJsx(): string[] {\n const config = getGlobalConfig();\n return Array.from(config.seenComponents);\n}\n"],"mappings":";AAUA,OAAO,WAAW;AAQlB,IAAM,aAAa;AASnB,SAAS,kBAAqC;AAC5C,QAAM,IAAI;AACV,MAAI,CAAC,EAAE,UAAU,GAAG;AAClB,MAAE,UAAU,IAAI;AAAA,MACd,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,WAAW,oBAAI,IAA0B;AAAA,MACzC,gBAAgB,oBAAI,IAAY;AAAA,IAClC;AAAA,EACF;AACA,SAAO,EAAE,UAAU;AACrB;AAIA,IAAM,WAAW,MAAM,OAAO,WAAW,eAAgB,OAAe;AAExE,SAAS,iBAAiB,MAA8B;AACtD,MAAI,CAAC,KAAM,QAAO;AAElB,MAAI,OAAO,SAAS,YAAY;AAE9B,UAAM,KAAK;AACX,QAAI,GAAG,YAAa,QAAO,GAAG;AAC9B,QAAI,GAAG,KAAM,QAAO,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,SAAS,YAAY,SAAS,MAAM;AAE7C,UAAM,MAAM;AACZ,QAAI,IAAI,YAAa,QAAO,IAAI;AAChC,QAAI,IAAI,UAAU;AAChB,UAAI,IAAI,KAAM,QAAO,iBAAiB,IAAI,IAAI;AAC9C,UAAI,IAAI,OAAQ,QAAO,iBAAiB,IAAI,MAAM;AAAA,IACpD;AAAA,EACF;AAEA,SAAO;AACT;AAGA,SAAS,cAAc,MAAgB;AACrC,MAAI,OAAO,SAAS,cAAe,OAAO,SAAS,YAAY,SAAS,MAAO;AAC7E,UAAM,OAAO,iBAAiB,IAAI;AAClC,UAAM,QAAQ,SAAS;AACvB,UAAM,SAAS,gBAAgB;AAE/B,QAAI,MAAM;AACR,UAAI,SA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