@marvalt/dstyler 0.1.3

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 (69) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +34 -0
  3. package/dist/components/AutoBlock.d.ts +14 -0
  4. package/dist/components/AutoBlock.d.ts.map +1 -0
  5. package/dist/components/AutoSection.d.ts +15 -0
  6. package/dist/components/AutoSection.d.ts.map +1 -0
  7. package/dist/components/StyledPage.d.ts +18 -0
  8. package/dist/components/StyledPage.d.ts.map +1 -0
  9. package/dist/components/index.d.ts +10 -0
  10. package/dist/components/index.d.ts.map +1 -0
  11. package/dist/engine/detectSections.d.ts +23 -0
  12. package/dist/engine/detectSections.d.ts.map +1 -0
  13. package/dist/engine/index.d.ts +10 -0
  14. package/dist/engine/index.d.ts.map +1 -0
  15. package/dist/engine/renderBlock.d.ts +15 -0
  16. package/dist/engine/renderBlock.d.ts.map +1 -0
  17. package/dist/engine/selectTemplate.d.ts +14 -0
  18. package/dist/engine/selectTemplate.d.ts.map +1 -0
  19. package/dist/index.d.ts +288 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.esm.js +931 -0
  22. package/dist/index.esm.js.map +1 -0
  23. package/dist/index.js +947 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/providers/ThemeProvider.d.ts +14 -0
  26. package/dist/providers/ThemeProvider.d.ts.map +1 -0
  27. package/dist/providers/index.d.ts +8 -0
  28. package/dist/providers/index.d.ts.map +1 -0
  29. package/dist/templates/FooterMinimal.d.ts +14 -0
  30. package/dist/templates/FooterMinimal.d.ts.map +1 -0
  31. package/dist/templates/HeroDefault.d.ts +14 -0
  32. package/dist/templates/HeroDefault.d.ts.map +1 -0
  33. package/dist/templates/SectionBase.d.ts +14 -0
  34. package/dist/templates/SectionBase.d.ts.map +1 -0
  35. package/dist/templates/SectionWave.d.ts +16 -0
  36. package/dist/templates/SectionWave.d.ts.map +1 -0
  37. package/dist/templates/blocks/BlockButton.d.ts +10 -0
  38. package/dist/templates/blocks/BlockButton.d.ts.map +1 -0
  39. package/dist/templates/blocks/BlockForm.d.ts +10 -0
  40. package/dist/templates/blocks/BlockForm.d.ts.map +1 -0
  41. package/dist/templates/blocks/BlockImage.d.ts +10 -0
  42. package/dist/templates/blocks/BlockImage.d.ts.map +1 -0
  43. package/dist/templates/blocks/BlockText.d.ts +10 -0
  44. package/dist/templates/blocks/BlockText.d.ts.map +1 -0
  45. package/dist/templates/blocks/index.d.ts +11 -0
  46. package/dist/templates/blocks/index.d.ts.map +1 -0
  47. package/dist/templates/index.d.ts +11 -0
  48. package/dist/templates/index.d.ts.map +1 -0
  49. package/dist/tokens/css-vars.d.ts +12 -0
  50. package/dist/tokens/css-vars.d.ts.map +1 -0
  51. package/dist/tokens/index.d.ts +10 -0
  52. package/dist/tokens/index.d.ts.map +1 -0
  53. package/dist/tokens/tokens.d.ts +9 -0
  54. package/dist/tokens/tokens.d.ts.map +1 -0
  55. package/dist/tokens/wordpress-to-tokens.d.ts +12 -0
  56. package/dist/tokens/wordpress-to-tokens.d.ts.map +1 -0
  57. package/dist/types/block.d.ts +12 -0
  58. package/dist/types/block.d.ts.map +1 -0
  59. package/dist/types/index.d.ts +10 -0
  60. package/dist/types/index.d.ts.map +1 -0
  61. package/dist/types/section.d.ts +22 -0
  62. package/dist/types/section.d.ts.map +1 -0
  63. package/dist/types/theme.d.ts +58 -0
  64. package/dist/types/theme.d.ts.map +1 -0
  65. package/dist/utils/index.d.ts +8 -0
  66. package/dist/utils/index.d.ts.map +1 -0
  67. package/dist/utils/responsive.d.ts +11 -0
  68. package/dist/utils/responsive.d.ts.map +1 -0
  69. package/package.json +68 -0
package/dist/index.js ADDED
@@ -0,0 +1,947 @@
1
+ 'use strict';
2
+
3
+ var require$$0 = require('react');
4
+
5
+ var jsxRuntime = {exports: {}};
6
+
7
+ var reactJsxRuntime_production = {};
8
+
9
+ /**
10
+ * @license React
11
+ * react-jsx-runtime.production.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */
18
+
19
+ var hasRequiredReactJsxRuntime_production;
20
+
21
+ function requireReactJsxRuntime_production () {
22
+ if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
23
+ hasRequiredReactJsxRuntime_production = 1;
24
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
25
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
26
+ function jsxProd(type, config, maybeKey) {
27
+ var key = null;
28
+ void 0 !== maybeKey && (key = "" + maybeKey);
29
+ void 0 !== config.key && (key = "" + config.key);
30
+ if ("key" in config) {
31
+ maybeKey = {};
32
+ for (var propName in config)
33
+ "key" !== propName && (maybeKey[propName] = config[propName]);
34
+ } else maybeKey = config;
35
+ config = maybeKey.ref;
36
+ return {
37
+ $$typeof: REACT_ELEMENT_TYPE,
38
+ type: type,
39
+ key: key,
40
+ ref: void 0 !== config ? config : null,
41
+ props: maybeKey
42
+ };
43
+ }
44
+ reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
45
+ reactJsxRuntime_production.jsx = jsxProd;
46
+ reactJsxRuntime_production.jsxs = jsxProd;
47
+ return reactJsxRuntime_production;
48
+ }
49
+
50
+ var reactJsxRuntime_development = {};
51
+
52
+ /**
53
+ * @license React
54
+ * react-jsx-runtime.development.js
55
+ *
56
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
57
+ *
58
+ * This source code is licensed under the MIT license found in the
59
+ * LICENSE file in the root directory of this source tree.
60
+ */
61
+
62
+ var hasRequiredReactJsxRuntime_development;
63
+
64
+ function requireReactJsxRuntime_development () {
65
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
66
+ hasRequiredReactJsxRuntime_development = 1;
67
+ "production" !== process.env.NODE_ENV &&
68
+ (function () {
69
+ function getComponentNameFromType(type) {
70
+ if (null == type) return null;
71
+ if ("function" === typeof type)
72
+ return type.$$typeof === REACT_CLIENT_REFERENCE
73
+ ? null
74
+ : type.displayName || type.name || null;
75
+ if ("string" === typeof type) return type;
76
+ switch (type) {
77
+ case REACT_FRAGMENT_TYPE:
78
+ return "Fragment";
79
+ case REACT_PROFILER_TYPE:
80
+ return "Profiler";
81
+ case REACT_STRICT_MODE_TYPE:
82
+ return "StrictMode";
83
+ case REACT_SUSPENSE_TYPE:
84
+ return "Suspense";
85
+ case REACT_SUSPENSE_LIST_TYPE:
86
+ return "SuspenseList";
87
+ case REACT_ACTIVITY_TYPE:
88
+ return "Activity";
89
+ }
90
+ if ("object" === typeof type)
91
+ switch (
92
+ ("number" === typeof type.tag &&
93
+ console.error(
94
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
95
+ ),
96
+ type.$$typeof)
97
+ ) {
98
+ case REACT_PORTAL_TYPE:
99
+ return "Portal";
100
+ case REACT_CONTEXT_TYPE:
101
+ return type.displayName || "Context";
102
+ case REACT_CONSUMER_TYPE:
103
+ return (type._context.displayName || "Context") + ".Consumer";
104
+ case REACT_FORWARD_REF_TYPE:
105
+ var innerType = type.render;
106
+ type = type.displayName;
107
+ type ||
108
+ ((type = innerType.displayName || innerType.name || ""),
109
+ (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
110
+ return type;
111
+ case REACT_MEMO_TYPE:
112
+ return (
113
+ (innerType = type.displayName || null),
114
+ null !== innerType
115
+ ? innerType
116
+ : getComponentNameFromType(type.type) || "Memo"
117
+ );
118
+ case REACT_LAZY_TYPE:
119
+ innerType = type._payload;
120
+ type = type._init;
121
+ try {
122
+ return getComponentNameFromType(type(innerType));
123
+ } catch (x) {}
124
+ }
125
+ return null;
126
+ }
127
+ function testStringCoercion(value) {
128
+ return "" + value;
129
+ }
130
+ function checkKeyStringCoercion(value) {
131
+ try {
132
+ testStringCoercion(value);
133
+ var JSCompiler_inline_result = !1;
134
+ } catch (e) {
135
+ JSCompiler_inline_result = true;
136
+ }
137
+ if (JSCompiler_inline_result) {
138
+ JSCompiler_inline_result = console;
139
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
140
+ var JSCompiler_inline_result$jscomp$0 =
141
+ ("function" === typeof Symbol &&
142
+ Symbol.toStringTag &&
143
+ value[Symbol.toStringTag]) ||
144
+ value.constructor.name ||
145
+ "Object";
146
+ JSCompiler_temp_const.call(
147
+ JSCompiler_inline_result,
148
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
149
+ JSCompiler_inline_result$jscomp$0
150
+ );
151
+ return testStringCoercion(value);
152
+ }
153
+ }
154
+ function getTaskName(type) {
155
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
156
+ if (
157
+ "object" === typeof type &&
158
+ null !== type &&
159
+ type.$$typeof === REACT_LAZY_TYPE
160
+ )
161
+ return "<...>";
162
+ try {
163
+ var name = getComponentNameFromType(type);
164
+ return name ? "<" + name + ">" : "<...>";
165
+ } catch (x) {
166
+ return "<...>";
167
+ }
168
+ }
169
+ function getOwner() {
170
+ var dispatcher = ReactSharedInternals.A;
171
+ return null === dispatcher ? null : dispatcher.getOwner();
172
+ }
173
+ function UnknownOwner() {
174
+ return Error("react-stack-top-frame");
175
+ }
176
+ function hasValidKey(config) {
177
+ if (hasOwnProperty.call(config, "key")) {
178
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
179
+ if (getter && getter.isReactWarning) return false;
180
+ }
181
+ return void 0 !== config.key;
182
+ }
183
+ function defineKeyPropWarningGetter(props, displayName) {
184
+ function warnAboutAccessingKey() {
185
+ specialPropKeyWarningShown ||
186
+ ((specialPropKeyWarningShown = true),
187
+ console.error(
188
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
189
+ displayName
190
+ ));
191
+ }
192
+ warnAboutAccessingKey.isReactWarning = true;
193
+ Object.defineProperty(props, "key", {
194
+ get: warnAboutAccessingKey,
195
+ configurable: true
196
+ });
197
+ }
198
+ function elementRefGetterWithDeprecationWarning() {
199
+ var componentName = getComponentNameFromType(this.type);
200
+ didWarnAboutElementRef[componentName] ||
201
+ ((didWarnAboutElementRef[componentName] = true),
202
+ console.error(
203
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
204
+ ));
205
+ componentName = this.props.ref;
206
+ return void 0 !== componentName ? componentName : null;
207
+ }
208
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
209
+ var refProp = props.ref;
210
+ type = {
211
+ $$typeof: REACT_ELEMENT_TYPE,
212
+ type: type,
213
+ key: key,
214
+ props: props,
215
+ _owner: owner
216
+ };
217
+ null !== (void 0 !== refProp ? refProp : null)
218
+ ? Object.defineProperty(type, "ref", {
219
+ enumerable: false,
220
+ get: elementRefGetterWithDeprecationWarning
221
+ })
222
+ : Object.defineProperty(type, "ref", { enumerable: false, value: null });
223
+ type._store = {};
224
+ Object.defineProperty(type._store, "validated", {
225
+ configurable: false,
226
+ enumerable: false,
227
+ writable: true,
228
+ value: 0
229
+ });
230
+ Object.defineProperty(type, "_debugInfo", {
231
+ configurable: false,
232
+ enumerable: false,
233
+ writable: true,
234
+ value: null
235
+ });
236
+ Object.defineProperty(type, "_debugStack", {
237
+ configurable: false,
238
+ enumerable: false,
239
+ writable: true,
240
+ value: debugStack
241
+ });
242
+ Object.defineProperty(type, "_debugTask", {
243
+ configurable: false,
244
+ enumerable: false,
245
+ writable: true,
246
+ value: debugTask
247
+ });
248
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
249
+ return type;
250
+ }
251
+ function jsxDEVImpl(
252
+ type,
253
+ config,
254
+ maybeKey,
255
+ isStaticChildren,
256
+ debugStack,
257
+ debugTask
258
+ ) {
259
+ var children = config.children;
260
+ if (void 0 !== children)
261
+ if (isStaticChildren)
262
+ if (isArrayImpl(children)) {
263
+ for (
264
+ isStaticChildren = 0;
265
+ isStaticChildren < children.length;
266
+ isStaticChildren++
267
+ )
268
+ validateChildKeys(children[isStaticChildren]);
269
+ Object.freeze && Object.freeze(children);
270
+ } else
271
+ console.error(
272
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
273
+ );
274
+ else validateChildKeys(children);
275
+ if (hasOwnProperty.call(config, "key")) {
276
+ children = getComponentNameFromType(type);
277
+ var keys = Object.keys(config).filter(function (k) {
278
+ return "key" !== k;
279
+ });
280
+ isStaticChildren =
281
+ 0 < keys.length
282
+ ? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
283
+ : "{key: someKey}";
284
+ didWarnAboutKeySpread[children + isStaticChildren] ||
285
+ ((keys =
286
+ 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
287
+ console.error(
288
+ 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
289
+ isStaticChildren,
290
+ children,
291
+ keys,
292
+ children
293
+ ),
294
+ (didWarnAboutKeySpread[children + isStaticChildren] = true));
295
+ }
296
+ children = null;
297
+ void 0 !== maybeKey &&
298
+ (checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
299
+ hasValidKey(config) &&
300
+ (checkKeyStringCoercion(config.key), (children = "" + config.key));
301
+ if ("key" in config) {
302
+ maybeKey = {};
303
+ for (var propName in config)
304
+ "key" !== propName && (maybeKey[propName] = config[propName]);
305
+ } else maybeKey = config;
306
+ children &&
307
+ defineKeyPropWarningGetter(
308
+ maybeKey,
309
+ "function" === typeof type
310
+ ? type.displayName || type.name || "Unknown"
311
+ : type
312
+ );
313
+ return ReactElement(
314
+ type,
315
+ children,
316
+ maybeKey,
317
+ getOwner(),
318
+ debugStack,
319
+ debugTask
320
+ );
321
+ }
322
+ function validateChildKeys(node) {
323
+ isValidElement(node)
324
+ ? node._store && (node._store.validated = 1)
325
+ : "object" === typeof node &&
326
+ null !== node &&
327
+ node.$$typeof === REACT_LAZY_TYPE &&
328
+ ("fulfilled" === node._payload.status
329
+ ? isValidElement(node._payload.value) &&
330
+ node._payload.value._store &&
331
+ (node._payload.value._store.validated = 1)
332
+ : node._store && (node._store.validated = 1));
333
+ }
334
+ function isValidElement(object) {
335
+ return (
336
+ "object" === typeof object &&
337
+ null !== object &&
338
+ object.$$typeof === REACT_ELEMENT_TYPE
339
+ );
340
+ }
341
+ var React = require$$0,
342
+ REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
343
+ REACT_PORTAL_TYPE = Symbol.for("react.portal"),
344
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
345
+ REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
346
+ REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
347
+ REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
348
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
349
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
350
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
351
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
352
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
353
+ REACT_LAZY_TYPE = Symbol.for("react.lazy"),
354
+ REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
355
+ REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
356
+ ReactSharedInternals =
357
+ React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
358
+ hasOwnProperty = Object.prototype.hasOwnProperty,
359
+ isArrayImpl = Array.isArray,
360
+ createTask = console.createTask
361
+ ? console.createTask
362
+ : function () {
363
+ return null;
364
+ };
365
+ React = {
366
+ react_stack_bottom_frame: function (callStackForError) {
367
+ return callStackForError();
368
+ }
369
+ };
370
+ var specialPropKeyWarningShown;
371
+ var didWarnAboutElementRef = {};
372
+ var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
373
+ React,
374
+ UnknownOwner
375
+ )();
376
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
377
+ var didWarnAboutKeySpread = {};
378
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
379
+ reactJsxRuntime_development.jsx = function (type, config, maybeKey) {
380
+ var trackActualOwner =
381
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
382
+ return jsxDEVImpl(
383
+ type,
384
+ config,
385
+ maybeKey,
386
+ false,
387
+ trackActualOwner
388
+ ? Error("react-stack-top-frame")
389
+ : unknownOwnerDebugStack,
390
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
391
+ );
392
+ };
393
+ reactJsxRuntime_development.jsxs = function (type, config, maybeKey) {
394
+ var trackActualOwner =
395
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
396
+ return jsxDEVImpl(
397
+ type,
398
+ config,
399
+ maybeKey,
400
+ true,
401
+ trackActualOwner
402
+ ? Error("react-stack-top-frame")
403
+ : unknownOwnerDebugStack,
404
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
405
+ );
406
+ };
407
+ })();
408
+ return reactJsxRuntime_development;
409
+ }
410
+
411
+ if (process.env.NODE_ENV === 'production') {
412
+ jsxRuntime.exports = requireReactJsxRuntime_production();
413
+ } else {
414
+ jsxRuntime.exports = requireReactJsxRuntime_development();
415
+ }
416
+
417
+ var jsxRuntimeExports = jsxRuntime.exports;
418
+
419
+ /**
420
+ * @license GPL-3.0-or-later
421
+ *
422
+ * This file is part of the MarVAlt Open SDK.
423
+ * Copyright (c) 2025 Vibune Pty Ltd.
424
+ */
425
+ const defaultTokens = {
426
+ colors: {
427
+ primary: '#1a73e8',
428
+ secondary: '#34a853',
429
+ background: '#ffffff',
430
+ text: '#222222',
431
+ default: '#ffffff',
432
+ alternate: '#f5f5f5',
433
+ highlight: '#e8f0fe',
434
+ },
435
+ spacing: {
436
+ sm: 8,
437
+ md: 16,
438
+ lg: 32,
439
+ xl: 64,
440
+ },
441
+ typography: {
442
+ body: 'Inter, sans-serif',
443
+ heading: 'Inter, sans-serif',
444
+ scale: 1.2,
445
+ },
446
+ };
447
+
448
+ /**
449
+ * @license GPL-3.0-or-later
450
+ *
451
+ * This file is part of the MarVAlt Open SDK.
452
+ * Copyright (c) 2025 Vibune Pty Ltd.
453
+ */
454
+ /**
455
+ * Convert WordPress theme styles to design tokens
456
+ */
457
+ function convertWordPressToTokens(wpStyles) {
458
+ if (!wpStyles) {
459
+ return defaultTokens;
460
+ }
461
+ const tokens = {
462
+ ...defaultTokens,
463
+ colors: {
464
+ ...defaultTokens.colors,
465
+ ...(wpStyles.colors?.primary && { primary: wpStyles.colors.primary }),
466
+ ...(wpStyles.colors?.secondary && { secondary: wpStyles.colors.secondary }),
467
+ ...(wpStyles.colors?.text && { text: wpStyles.colors.text }),
468
+ ...(wpStyles.colors?.background && {
469
+ background: wpStyles.colors.background,
470
+ default: wpStyles.colors.background,
471
+ }),
472
+ },
473
+ typography: {
474
+ ...defaultTokens.typography,
475
+ ...(wpStyles.typography?.heading_font_family && {
476
+ heading: wpStyles.typography.heading_font_family
477
+ }),
478
+ ...(wpStyles.typography?.body_font_family && {
479
+ body: wpStyles.typography.body_font_family
480
+ }),
481
+ },
482
+ };
483
+ // Generate alternate and highlight colors from primary/background
484
+ if (tokens.colors.primary && tokens.colors.background) {
485
+ // Alternate: slightly darker/lighter than background
486
+ tokens.colors.alternate = adjustBrightness(tokens.colors.background, -0.05);
487
+ // Highlight: tinted with primary color
488
+ tokens.colors.highlight = blendColors(tokens.colors.background, tokens.colors.primary, 0.1);
489
+ }
490
+ return tokens;
491
+ }
492
+ /**
493
+ * Adjust brightness of a hex color
494
+ */
495
+ function adjustBrightness(hex, amount) {
496
+ const num = parseInt(hex.replace('#', ''), 16);
497
+ const r = Math.max(0, Math.min(255, ((num >> 16) & 0xff) + (amount * 255)));
498
+ const g = Math.max(0, Math.min(255, ((num >> 8) & 0xff) + (amount * 255)));
499
+ const b = Math.max(0, Math.min(255, (num & 0xff) + (amount * 255)));
500
+ return `#${((r << 16) | (g << 8) | b).toString(16).padStart(6, '0')}`;
501
+ }
502
+ /**
503
+ * Blend two colors
504
+ */
505
+ function blendColors(color1, color2, ratio) {
506
+ const c1 = hexToRgb(color1);
507
+ const c2 = hexToRgb(color2);
508
+ if (!c1 || !c2)
509
+ return color1;
510
+ const r = Math.round(c1.r + (c2.r - c1.r) * ratio);
511
+ const g = Math.round(c1.g + (c2.g - c1.g) * ratio);
512
+ const b = Math.round(c1.b + (c2.b - c1.b) * ratio);
513
+ return `rgb(${r}, ${g}, ${b})`;
514
+ }
515
+ function hexToRgb(hex) {
516
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
517
+ return result
518
+ ? {
519
+ r: parseInt(result[1], 16),
520
+ g: parseInt(result[2], 16),
521
+ b: parseInt(result[3], 16),
522
+ }
523
+ : null;
524
+ }
525
+
526
+ /**
527
+ * @license GPL-3.0-or-later
528
+ *
529
+ * This file is part of the MarVAlt Open SDK.
530
+ * Copyright (c) 2025 Vibune Pty Ltd.
531
+ */
532
+ /**
533
+ * Inject CSS variables from design tokens into the document
534
+ */
535
+ function injectCSSVariables(tokens) {
536
+ if (typeof document === 'undefined')
537
+ return;
538
+ const root = document.documentElement;
539
+ // Colors
540
+ root.style.setProperty('--dstyler-color-primary', tokens.colors.primary);
541
+ root.style.setProperty('--dstyler-color-secondary', tokens.colors.secondary);
542
+ root.style.setProperty('--dstyler-color-background', tokens.colors.background);
543
+ root.style.setProperty('--dstyler-color-text', tokens.colors.text);
544
+ root.style.setProperty('--dstyler-color-default', tokens.colors.default);
545
+ root.style.setProperty('--dstyler-color-alternate', tokens.colors.alternate);
546
+ root.style.setProperty('--dstyler-color-highlight', tokens.colors.highlight);
547
+ // Spacing
548
+ root.style.setProperty('--dstyler-spacing-sm', `${tokens.spacing.sm}px`);
549
+ root.style.setProperty('--dstyler-spacing-md', `${tokens.spacing.md}px`);
550
+ root.style.setProperty('--dstyler-spacing-lg', `${tokens.spacing.lg}px`);
551
+ root.style.setProperty('--dstyler-spacing-xl', `${tokens.spacing.xl}px`);
552
+ // Typography
553
+ root.style.setProperty('--dstyler-font-body', tokens.typography.body);
554
+ root.style.setProperty('--dstyler-font-heading', tokens.typography.heading);
555
+ root.style.setProperty('--dstyler-font-scale', tokens.typography.scale.toString());
556
+ }
557
+
558
+ const ThemeProvider = ({ children, wpStyles }) => {
559
+ require$$0.useEffect(() => {
560
+ const tokens = convertWordPressToTokens(wpStyles);
561
+ injectCSSVariables(tokens);
562
+ }, [wpStyles]);
563
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
564
+ };
565
+
566
+ /**
567
+ * @license GPL-3.0-or-later
568
+ *
569
+ * This file is part of the MarVAlt Open SDK.
570
+ * Copyright (c) 2025 Vibune Pty Ltd.
571
+ */
572
+ /**
573
+ * Select template component based on section properties
574
+ */
575
+ function selectTemplate(section) {
576
+ const block = section.block;
577
+ const attrs = block.attributes || {};
578
+ const className = section.customClass?.toLowerCase() || '';
579
+ // Check for hero/cover blocks
580
+ if (block.name === 'core/cover') {
581
+ return 'HeroDefault';
582
+ }
583
+ // Check for footer (could be detected by block name or class)
584
+ if (className.includes('footer') || block.name === 'core/footer') {
585
+ return 'FooterMinimal';
586
+ }
587
+ // Check for wave style
588
+ if (className.includes('wave') || attrs.style === 'wave') {
589
+ return 'SectionWave';
590
+ }
591
+ // Default section template
592
+ return 'SectionBase';
593
+ }
594
+
595
+ const SectionBase = ({ section, children }) => {
596
+ const style = section.style || 'default';
597
+ const bgColor = `var(--dstyler-color-${style})`;
598
+ const className = [
599
+ 'dstyler-section',
600
+ `dstyler-section-${style}`,
601
+ section.customClass,
602
+ ].filter(Boolean).join(' ');
603
+ return (jsxRuntimeExports.jsx("section", { className: className, id: section.customId, style: {
604
+ backgroundColor: bgColor,
605
+ padding: 'var(--dstyler-spacing-xl) var(--dstyler-spacing-md)',
606
+ }, children: jsxRuntimeExports.jsx("div", { style: {
607
+ maxWidth: 'var(--dstyler-container-max-width, 1200px)',
608
+ margin: '0 auto',
609
+ }, children: children }) }));
610
+ };
611
+
612
+ const SectionWave = ({ section, children, waveTop = true, waveBottom = true, }) => {
613
+ const style = section.style || 'default';
614
+ const bgColor = `var(--dstyler-color-${style})`;
615
+ const className = [
616
+ 'dstyler-section',
617
+ 'dstyler-section-wave',
618
+ `dstyler-section-${style}`,
619
+ section.customClass,
620
+ ].filter(Boolean).join(' ');
621
+ // Wave SVG
622
+ const waveSvg = (jsxRuntimeExports.jsx("svg", { viewBox: "0 0 1440 120", preserveAspectRatio: "none", style: {
623
+ width: '100%',
624
+ height: '60px',
625
+ display: 'block',
626
+ fill: bgColor,
627
+ }, children: jsxRuntimeExports.jsx("path", { d: "M0,60 C240,0 480,120 720,60 C960,0 1200,120 1440,60 L1440,120 L0,120 Z" }) }));
628
+ return (jsxRuntimeExports.jsxs("section", { className: className, id: section.customId, style: {
629
+ backgroundColor: bgColor,
630
+ position: 'relative',
631
+ }, children: [waveTop && (jsxRuntimeExports.jsx("div", { style: { marginTop: '-1px' }, children: waveSvg })), jsxRuntimeExports.jsx("div", { style: {
632
+ padding: 'var(--dstyler-spacing-xl) var(--dstyler-spacing-md)',
633
+ }, children: jsxRuntimeExports.jsx("div", { style: {
634
+ maxWidth: 'var(--dstyler-container-max-width, 1200px)',
635
+ margin: '0 auto',
636
+ }, children: children }) }), waveBottom && (jsxRuntimeExports.jsx("div", { style: { marginBottom: '-1px', transform: 'rotate(180deg)' }, children: waveSvg }))] }));
637
+ };
638
+
639
+ const HeroDefault = ({ section, children }) => {
640
+ const style = section.style || 'default';
641
+ const bgColor = `var(--dstyler-color-${style})`;
642
+ const className = [
643
+ 'dstyler-hero',
644
+ 'dstyler-hero-default',
645
+ `dstyler-hero-${style}`,
646
+ section.customClass,
647
+ ].filter(Boolean).join(' ');
648
+ return (jsxRuntimeExports.jsx("section", { className: className, id: section.customId, style: {
649
+ backgroundColor: bgColor,
650
+ padding: 'var(--dstyler-spacing-xl) var(--dstyler-spacing-md)',
651
+ minHeight: '50vh',
652
+ display: 'flex',
653
+ alignItems: 'center',
654
+ justifyContent: 'center',
655
+ }, children: jsxRuntimeExports.jsx("div", { style: {
656
+ maxWidth: 'var(--dstyler-container-max-width, 1200px)',
657
+ margin: '0 auto',
658
+ textAlign: 'center',
659
+ }, children: children }) }));
660
+ };
661
+
662
+ const FooterMinimal = ({ section, children }) => {
663
+ const style = section.style || 'default';
664
+ const bgColor = `var(--dstyler-color-${style})`;
665
+ const className = [
666
+ 'dstyler-footer',
667
+ 'dstyler-footer-minimal',
668
+ `dstyler-footer-${style}`,
669
+ section.customClass,
670
+ ].filter(Boolean).join(' ');
671
+ return (jsxRuntimeExports.jsx("footer", { className: className, id: section.customId, style: {
672
+ backgroundColor: bgColor,
673
+ padding: 'var(--dstyler-spacing-lg) var(--dstyler-spacing-md)',
674
+ borderTop: '1px solid var(--dstyler-color-alternate)',
675
+ }, children: jsxRuntimeExports.jsx("div", { style: {
676
+ maxWidth: 'var(--dstyler-container-max-width, 1200px)',
677
+ margin: '0 auto',
678
+ textAlign: 'center',
679
+ fontSize: '0.875rem',
680
+ color: 'var(--dstyler-color-text)',
681
+ }, children: children }) }));
682
+ };
683
+
684
+ /**
685
+ * @license GPL-3.0-or-later
686
+ *
687
+ * This file is part of the MarVAlt Open SDK.
688
+ * Copyright (c) 2025 Vibune Pty Ltd.
689
+ */
690
+ /**
691
+ * Select block renderer based on block type
692
+ */
693
+ function selectBlockRenderer(block) {
694
+ const blockName = block.name;
695
+ // Map WordPress block types to renderers
696
+ switch (blockName) {
697
+ case 'core/paragraph':
698
+ case 'core/heading':
699
+ return 'BlockText';
700
+ case 'core/image':
701
+ case 'core/gallery':
702
+ return 'BlockImage';
703
+ case 'core/button':
704
+ case 'core/buttons':
705
+ return 'BlockButton';
706
+ case 'core/html':
707
+ case 'core/shortcode':
708
+ // Check if it's a form shortcode
709
+ const attrs = block.attributes || {};
710
+ const content = attrs.content || attrs.html || '';
711
+ if (content.includes('[gravityform') || content.includes('[mauticform')) {
712
+ return 'BlockForm';
713
+ }
714
+ return 'BlockText';
715
+ default:
716
+ return 'BlockText'; // Default fallback
717
+ }
718
+ }
719
+
720
+ const BlockText = ({ block, className }) => {
721
+ const attrs = block.attributes || {};
722
+ const content = attrs.content || attrs.text || '';
723
+ const tagName = block.name === 'core/heading'
724
+ ? `h${attrs.level || 2}`
725
+ : 'p';
726
+ const Tag = tagName;
727
+ const style = {
728
+ fontFamily: 'var(--dstyler-font-body)',
729
+ color: 'var(--dstyler-color-text)',
730
+ marginBottom: 'var(--dstyler-spacing-md)',
731
+ };
732
+ if (block.name === 'core/heading') {
733
+ style.fontFamily = 'var(--dstyler-font-heading)';
734
+ style.fontSize = `calc(1rem * var(--dstyler-font-scale) * ${attrs.level || 2})`;
735
+ style.fontWeight = 'bold';
736
+ }
737
+ return (jsxRuntimeExports.jsx(Tag, { className: className, style: style, dangerouslySetInnerHTML: { __html: content } }));
738
+ };
739
+
740
+ const BlockImage = ({ block, className }) => {
741
+ const attrs = block.attributes || {};
742
+ const url = attrs.url || attrs.sourceUrl || '';
743
+ const alt = attrs.alt || attrs.altText || '';
744
+ const width = attrs.width;
745
+ const height = attrs.height;
746
+ if (!url)
747
+ return null;
748
+ const style = {
749
+ maxWidth: '100%',
750
+ height: 'auto',
751
+ marginBottom: 'var(--dstyler-spacing-md)',
752
+ borderRadius: '8px',
753
+ };
754
+ return (jsxRuntimeExports.jsx("img", { src: url, alt: alt, width: width, height: height, className: className, style: style, loading: "lazy" }));
755
+ };
756
+
757
+ const BlockButton = ({ block, className }) => {
758
+ const attrs = block.attributes || {};
759
+ const text = attrs.text || attrs.label || 'Button';
760
+ const url = attrs.url || attrs.linkUrl || '#';
761
+ const isExternal = typeof window !== 'undefined'
762
+ ? url.startsWith('http') && !url.includes(window.location.hostname)
763
+ : url.startsWith('http');
764
+ const style = {
765
+ display: 'inline-block',
766
+ padding: 'var(--dstyler-spacing-md) var(--dstyler-spacing-lg)',
767
+ backgroundColor: 'var(--dstyler-color-primary)',
768
+ color: '#ffffff',
769
+ textDecoration: 'none',
770
+ borderRadius: '4px',
771
+ fontWeight: '500',
772
+ marginBottom: 'var(--dstyler-spacing-md)',
773
+ transition: 'opacity 0.2s',
774
+ };
775
+ return (jsxRuntimeExports.jsx("a", { href: url, target: isExternal ? '_blank' : undefined, rel: isExternal ? 'noopener noreferrer' : undefined, className: className, style: style, onMouseEnter: (e) => {
776
+ e.currentTarget.style.opacity = '0.9';
777
+ }, onMouseLeave: (e) => {
778
+ e.currentTarget.style.opacity = '1';
779
+ }, children: text }));
780
+ };
781
+
782
+ const BlockForm = ({ block, className }) => {
783
+ const attrs = block.attributes || {};
784
+ const content = attrs.content || attrs.html || '';
785
+ // For now, just render the HTML content
786
+ // In the future, this could parse and render using Gravity Forms or Mautic components
787
+ const style = {
788
+ marginBottom: 'var(--dstyler-spacing-lg)',
789
+ };
790
+ return (jsxRuntimeExports.jsx("div", { className: className, style: style, dangerouslySetInnerHTML: { __html: content } }));
791
+ };
792
+
793
+ const AutoBlock = ({ block, registry }) => {
794
+ // If registry is provided, use it for rendering (integrates with wparser)
795
+ if (registry && registry.renderers[block.name]) {
796
+ const Renderer = registry.renderers[block.name];
797
+ return jsxRuntimeExports.jsx(Renderer, { block: block, context: { registry } });
798
+ }
799
+ // Otherwise, use dstyler's block renderers
800
+ const rendererName = selectBlockRenderer(block);
801
+ switch (rendererName) {
802
+ case 'BlockText':
803
+ return jsxRuntimeExports.jsx(BlockText, { block: block });
804
+ case 'BlockImage':
805
+ return jsxRuntimeExports.jsx(BlockImage, { block: block });
806
+ case 'BlockButton':
807
+ return jsxRuntimeExports.jsx(BlockButton, { block: block });
808
+ case 'BlockForm':
809
+ return jsxRuntimeExports.jsx(BlockForm, { block: block });
810
+ default:
811
+ // Fallback: render block name or content
812
+ return (jsxRuntimeExports.jsx("div", { style: { marginBottom: 'var(--dstyler-spacing-md)' }, children: jsxRuntimeExports.jsxs("pre", { style: { fontSize: '0.875rem', color: '#666' }, children: [block.name, ": ", JSON.stringify(block.attributes, null, 2)] }) }));
813
+ }
814
+ };
815
+
816
+ const AutoSection = ({ section, registry }) => {
817
+ const templateName = selectTemplate(section);
818
+ // Render blocks using AutoBlock or registry
819
+ const renderBlocks = () => {
820
+ if (registry) {
821
+ // Use registry for block rendering (integrates with wparser)
822
+ return section.blocks.map((block, index) => (jsxRuntimeExports.jsx(AutoBlock, { block: block, registry: registry }, `${block.name}-${index}`)));
823
+ }
824
+ // Fallback to simple block rendering
825
+ return section.blocks.map((block, index) => (jsxRuntimeExports.jsx(AutoBlock, { block: block }, `${block.name}-${index}`)));
826
+ };
827
+ // Select template component
828
+ switch (templateName) {
829
+ case 'SectionWave': {
830
+ const className = section.customClass?.toLowerCase() || '';
831
+ const waveTop = className.includes('wave-top') || !className.includes('wave-bottom');
832
+ const waveBottom = className.includes('wave-bottom') || !className.includes('wave-top');
833
+ return (jsxRuntimeExports.jsx(SectionWave, { section: section, waveTop: waveTop, waveBottom: waveBottom, children: renderBlocks() }));
834
+ }
835
+ case 'HeroDefault':
836
+ return (jsxRuntimeExports.jsx(HeroDefault, { section: section, children: renderBlocks() }));
837
+ case 'FooterMinimal':
838
+ return (jsxRuntimeExports.jsx(FooterMinimal, { section: section, children: renderBlocks() }));
839
+ default:
840
+ return (jsxRuntimeExports.jsx(SectionBase, { section: section, children: renderBlocks() }));
841
+ }
842
+ };
843
+
844
+ /**
845
+ * @license GPL-3.0-or-later
846
+ *
847
+ * This file is part of the MarVAlt Open SDK.
848
+ * Copyright (c) 2025 Vibune Pty Ltd.
849
+ */
850
+ /**
851
+ * Detect sections from WordPress blocks
852
+ * Sections are defined by core/group blocks (with or without alignment)
853
+ * Sub-sections are core/columns blocks inside groups
854
+ */
855
+ function detectSections(blocks) {
856
+ const sections = [];
857
+ let sectionIndex = 0;
858
+ for (const block of blocks) {
859
+ // core/group blocks are sections
860
+ if (block.name === 'core/group') {
861
+ const attrs = block.attributes || {};
862
+ const className = attrs.className;
863
+ const customId = attrs.id;
864
+ // Extract blocks from innerBlocks
865
+ const innerBlocks = block.innerBlocks || [];
866
+ sections.push({
867
+ id: `section-${sectionIndex}`,
868
+ type: 'section',
869
+ block,
870
+ blocks: innerBlocks,
871
+ index: sectionIndex,
872
+ customClass: className,
873
+ customId,
874
+ });
875
+ sectionIndex++;
876
+ }
877
+ }
878
+ return sections;
879
+ }
880
+ /**
881
+ * Determine section style based on alternating logic and custom classes
882
+ * Rules:
883
+ * - default is always first
884
+ * - after default follows alternate
885
+ * - highlight resets - next section is default
886
+ */
887
+ function determineSectionStyle(section, previousStyle) {
888
+ const className = section.customClass?.toLowerCase() || '';
889
+ // Check for custom class overrides first
890
+ if (className.includes('highlight') || className.includes('highlight-section')) {
891
+ return 'highlight';
892
+ }
893
+ if (className.includes('dark') || className.includes('dark-section')) {
894
+ return 'alternate';
895
+ }
896
+ if (className.includes('default') || className.includes('default-section')) {
897
+ return 'default';
898
+ }
899
+ // Alternating logic
900
+ if (section.index === 0) {
901
+ return 'default';
902
+ }
903
+ if (previousStyle === 'highlight') {
904
+ return 'default';
905
+ }
906
+ if (previousStyle === 'default') {
907
+ return 'alternate';
908
+ }
909
+ if (previousStyle === 'alternate') {
910
+ return 'default';
911
+ }
912
+ return 'default';
913
+ }
914
+
915
+ const StyledPage = ({ page, registry }) => {
916
+ const blocks = page.blocks || [];
917
+ // Detect sections from blocks
918
+ const sections = detectSections(blocks);
919
+ // Apply alternating style logic
920
+ let previousStyle;
921
+ const styledSections = sections.map((section) => {
922
+ const style = determineSectionStyle(section, previousStyle);
923
+ previousStyle = style;
924
+ return {
925
+ ...section,
926
+ style,
927
+ };
928
+ });
929
+ return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: styledSections.map((section) => (jsxRuntimeExports.jsx(AutoSection, { section: section, registry: registry }, section.id))) }));
930
+ };
931
+
932
+ exports.AutoBlock = AutoBlock;
933
+ exports.AutoSection = AutoSection;
934
+ exports.FooterMinimal = FooterMinimal;
935
+ exports.HeroDefault = HeroDefault;
936
+ exports.SectionBase = SectionBase;
937
+ exports.SectionWave = SectionWave;
938
+ exports.StyledPage = StyledPage;
939
+ exports.ThemeProvider = ThemeProvider;
940
+ exports.convertWordPressToTokens = convertWordPressToTokens;
941
+ exports.defaultTokens = defaultTokens;
942
+ exports.detectSections = detectSections;
943
+ exports.determineSectionStyle = determineSectionStyle;
944
+ exports.injectCSSVariables = injectCSSVariables;
945
+ exports.selectBlockRenderer = selectBlockRenderer;
946
+ exports.selectTemplate = selectTemplate;
947
+ //# sourceMappingURL=index.js.map