@caartzee/theme-sdk 0.0.0-stage → 1.2.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 (179) hide show
  1. package/README.md +222 -2
  2. package/dist/bin/caartzee-theme.js +9223 -0
  3. package/dist/lib/index.js +11614 -0
  4. package/dist/types/src/auth/credentials-store.d.ts +18 -0
  5. package/dist/types/src/auth/index.d.ts +2 -0
  6. package/dist/types/src/auth/oauth-client.d.ts +39 -0
  7. package/dist/types/src/blocks/block-contract.d.ts +242 -0
  8. package/dist/types/src/candy/compatibility-matrix.d.ts +10 -0
  9. package/dist/types/src/candy/context-builder.d.ts +31 -0
  10. package/dist/types/src/candy/engine.d.ts +69 -0
  11. package/dist/types/src/candy/filters.d.ts +32 -0
  12. package/dist/types/src/candy/ide-support.d.ts +20 -0
  13. package/dist/types/src/candy/index.d.ts +9 -0
  14. package/dist/types/src/candy/schema-parser.d.ts +13 -0
  15. package/dist/types/src/candy/security.d.ts +54 -0
  16. package/dist/types/src/candy/tags.d.ts +11 -0
  17. package/dist/types/src/candy/types.d.ts +185 -0
  18. package/dist/types/src/cli/caartzee-cli.d.ts +9 -0
  19. package/dist/types/src/cli/candy-mcp.d.ts +2 -0
  20. package/dist/types/src/cli/candy-tool-server.d.ts +39 -0
  21. package/dist/types/src/cli/index.d.ts +1 -0
  22. package/dist/types/src/cli/mcp/component-tools.d.ts +2 -0
  23. package/dist/types/src/cli/mcp/docs-tools.d.ts +89 -0
  24. package/dist/types/src/cli/mcp/editor-tools.d.ts +22 -0
  25. package/dist/types/src/cli/mcp/resources-and-prompts.d.ts +2 -0
  26. package/dist/types/src/cli/mcp/testing-tools.d.ts +54 -0
  27. package/dist/types/src/cli/sdk-client.d.ts +12 -0
  28. package/dist/types/src/contracts/category-selection.d.ts +15 -0
  29. package/dist/types/src/contracts/commerce.d.ts +282 -0
  30. package/dist/types/src/contracts/footer-builder.d.ts +125 -0
  31. package/dist/types/src/contracts/hooks.d.ts +37 -0
  32. package/dist/types/src/contracts/manifest.d.ts +3127 -0
  33. package/dist/types/src/contracts/navigation.d.ts +39 -0
  34. package/dist/types/src/contracts/order-tracking.d.ts +40 -0
  35. package/dist/types/src/contracts/page.d.ts +262 -0
  36. package/dist/types/src/contracts/storefront-content.d.ts +60 -0
  37. package/dist/types/src/contracts/style-document.d.ts +2 -0
  38. package/dist/types/src/contracts/styles.d.ts +2002 -0
  39. package/dist/types/src/contracts/theme.d.ts +35 -0
  40. package/dist/types/src/dev-server/catalog-preview.d.ts +25 -0
  41. package/dist/types/src/dev-server/dev-server.d.ts +25 -0
  42. package/dist/types/src/dev-server/index.d.ts +1 -0
  43. package/dist/types/src/dev-server/local-commerce-runtime.d.ts +76 -0
  44. package/dist/types/src/dev-server/local-editor-server.d.ts +22 -0
  45. package/dist/types/src/dev-server/theme-preview.d.ts +8 -0
  46. package/dist/types/src/index.d.ts +27 -0
  47. package/dist/types/src/mock/index.d.ts +10 -0
  48. package/dist/types/src/mock/mock-categories.d.ts +2 -0
  49. package/dist/types/src/mock/mock-commerce.d.ts +55 -0
  50. package/dist/types/src/mock/mock-customer.d.ts +47 -0
  51. package/dist/types/src/mock/mock-hooks.d.ts +2 -0
  52. package/dist/types/src/mock/mock-products.d.ts +3 -0
  53. package/dist/types/src/rendering/commerce-pages.d.ts +16 -0
  54. package/dist/types/src/rendering/raw-html.d.ts +12 -0
  55. package/dist/types/src/rendering/section-wrapper.d.ts +30 -0
  56. package/dist/types/src/scaffold/candy-starter-assets.d.ts +2 -0
  57. package/dist/types/src/scaffold/commerce-generator.d.ts +3 -0
  58. package/dist/types/src/scaffold/index.d.ts +2 -0
  59. package/dist/types/src/scaffold/template-generator.d.ts +21 -0
  60. package/dist/types/src/sections/section-contract.d.ts +350 -0
  61. package/dist/types/src/settings/global-settings.d.ts +25 -0
  62. package/dist/types/src/templates/json-template.d.ts +991 -0
  63. package/dist/types/src/validation/package-validator.d.ts +53 -0
  64. package/dist/types/src/validation/rich-text.d.ts +24 -0
  65. package/package.json +29 -3
  66. package/templates/commerce/README.md +165 -0
  67. package/templates/commerce/assets/theme.css +1 -0
  68. package/templates/commerce/manifest.json +1 -0
  69. package/templates/commerce/src/blocks/index.ts +184 -0
  70. package/templates/commerce/src/config/settings-defaults.ts +25 -0
  71. package/templates/commerce/src/config/settings-schema.ts +102 -0
  72. package/templates/commerce/src/index.ts +90 -0
  73. package/templates/commerce/src/layouts/default.ts +275 -0
  74. package/templates/commerce/src/manifest.ts +976 -0
  75. package/templates/commerce/src/pages/account/components.ts +369 -0
  76. package/templates/commerce/src/pages/account/tabs.ts +792 -0
  77. package/templates/commerce/src/pages/account.ts +55 -0
  78. package/templates/commerce/src/pages/campaign.ts +423 -0
  79. package/templates/commerce/src/pages/cart.ts +261 -0
  80. package/templates/commerce/src/pages/category-detail.ts +124 -0
  81. package/templates/commerce/src/pages/category-list.ts +87 -0
  82. package/templates/commerce/src/pages/checkout.ts +712 -0
  83. package/templates/commerce/src/pages/commerce.ts +45 -0
  84. package/templates/commerce/src/pages/home.ts +160 -0
  85. package/templates/commerce/src/pages/index.ts +99 -0
  86. package/templates/commerce/src/pages/login.ts +204 -0
  87. package/templates/commerce/src/pages/order-success.ts +80 -0
  88. package/templates/commerce/src/pages/product-detail.ts +489 -0
  89. package/templates/commerce/src/pages/product-list.ts +125 -0
  90. package/templates/commerce/src/pages/search.ts +88 -0
  91. package/templates/commerce/src/pages/signup.ts +253 -0
  92. package/templates/commerce/src/pages/status.ts +7 -0
  93. package/templates/commerce/src/pages/theme-layout.ts +491 -0
  94. package/templates/commerce/src/pages/track-order.ts +196 -0
  95. package/templates/commerce/src/pages/wishlist.ts +83 -0
  96. package/templates/commerce/src/sections/about-story.ts +117 -0
  97. package/templates/commerce/src/sections/announcement-bar.ts +101 -0
  98. package/templates/commerce/src/sections/banner-grid.ts +319 -0
  99. package/templates/commerce/src/sections/campaign-banners.ts +158 -0
  100. package/templates/commerce/src/sections/category-slider.ts +144 -0
  101. package/templates/commerce/src/sections/content-builder.ts +123 -0
  102. package/templates/commerce/src/sections/content-controls.ts +45 -0
  103. package/templates/commerce/src/sections/custom-form.ts +59 -0
  104. package/templates/commerce/src/sections/faq-accordion.ts +123 -0
  105. package/templates/commerce/src/sections/footer.ts +728 -0
  106. package/templates/commerce/src/sections/header.ts +439 -0
  107. package/templates/commerce/src/sections/hero-slider.ts +492 -0
  108. package/templates/commerce/src/sections/hero.ts +137 -0
  109. package/templates/commerce/src/sections/index.ts +102 -0
  110. package/templates/commerce/src/sections/mobile-slider.ts +102 -0
  111. package/templates/commerce/src/sections/newsletter.ts +43 -0
  112. package/templates/commerce/src/sections/product-grid.ts +191 -0
  113. package/templates/commerce/src/sections/raw-html.ts +1 -0
  114. package/templates/commerce/src/sections/rich-text.ts +26 -0
  115. package/templates/commerce/src/sections/services-features.ts +211 -0
  116. package/templates/commerce/src/sections/testimonials.ts +194 -0
  117. package/templates/commerce/src/snippets/product-card.ts +178 -0
  118. package/templates/commerce/src/snippets/product-price.ts +46 -0
  119. package/templates/commerce/src/snippets/responsive-image.ts +29 -0
  120. package/templates/commerce/src/styles.ts +477 -0
  121. package/templates/commerce/src/templates/404.json +26 -0
  122. package/templates/commerce/src/templates/account.json +17 -0
  123. package/templates/commerce/src/templates/cart.json +17 -0
  124. package/templates/commerce/src/templates/category.json +16 -0
  125. package/templates/commerce/src/templates/checkout.json +15 -0
  126. package/templates/commerce/src/templates/collection.json +16 -0
  127. package/templates/commerce/src/templates/index.json +180 -0
  128. package/templates/commerce/src/templates/login.json +17 -0
  129. package/templates/commerce/src/templates/order-success.json +17 -0
  130. package/templates/commerce/src/templates/page.json +17 -0
  131. package/templates/commerce/src/templates/product.json +17 -0
  132. package/templates/commerce/src/templates/search.json +18 -0
  133. package/templates/commerce/src/templates/signup.json +17 -0
  134. package/templates/commerce/src/templates/track-order.json +17 -0
  135. package/templates/commerce/src/templates/wishlist.json +17 -0
  136. package/templates/commerce/src/templates.ts +510 -0
  137. package/templates/commerce/src/tokens.ts +22 -0
  138. package/templates/theme-candy-boilerplate/.editorconfig +14 -0
  139. package/templates/theme-candy-boilerplate/.gitattributes +1 -0
  140. package/templates/theme-candy-boilerplate/.vscode/extensions.json +7 -0
  141. package/templates/theme-candy-boilerplate/.vscode/settings.json +17 -0
  142. package/templates/theme-candy-boilerplate/assets/theme.css +78 -0
  143. package/templates/theme-candy-boilerplate/assets/theme.js +7 -0
  144. package/templates/theme-candy-boilerplate/candy.config.json +40 -0
  145. package/templates/theme-candy-boilerplate/index.ts +39 -0
  146. package/templates/theme-candy-boilerplate/layout/theme.candy +25 -0
  147. package/templates/theme-candy-boilerplate/locales/en.default.json +37 -0
  148. package/templates/theme-candy-boilerplate/manifest.json +123 -0
  149. package/templates/theme-candy-boilerplate/package.json +16 -0
  150. package/templates/theme-candy-boilerplate/schemas/settings_schema.json +36 -0
  151. package/templates/theme-candy-boilerplate/sections/featured-products.candy +89 -0
  152. package/templates/theme-candy-boilerplate/sections/footer.candy +50 -0
  153. package/templates/theme-candy-boilerplate/sections/header.candy +116 -0
  154. package/templates/theme-candy-boilerplate/sections/hero-banner.candy +135 -0
  155. package/templates/theme-candy-boilerplate/sections/image-with-text.candy +85 -0
  156. package/templates/theme-candy-boilerplate/snippets/price.candy +19 -0
  157. package/templates/theme-candy-boilerplate/snippets/product-card.candy +43 -0
  158. package/templates/theme-candy-boilerplate/templates/404.candy +12 -0
  159. package/templates/theme-candy-boilerplate/templates/cart.candy +51 -0
  160. package/templates/theme-candy-boilerplate/templates/collection.candy +51 -0
  161. package/templates/theme-candy-boilerplate/templates/index.candy +7 -0
  162. package/templates/theme-candy-boilerplate/templates/page.candy +10 -0
  163. package/templates/theme-candy-boilerplate/templates/product.candy +59 -0
  164. package/templates/theme-candy-boilerplate/templates/search.candy +40 -0
  165. package/templates/vscode-candy/LICENSE +21 -0
  166. package/templates/vscode-candy/README.md +22 -0
  167. package/templates/vscode-candy/extension.js +689 -0
  168. package/templates/vscode-candy/icons/candy-dark.svg +23 -0
  169. package/templates/vscode-candy/icons/candy-light.svg +23 -0
  170. package/templates/vscode-candy/icons/candy-logo.png +0 -0
  171. package/templates/vscode-candy/icons/candy-sweet-dark.svg +23 -0
  172. package/templates/vscode-candy/icons/candy-sweet-light.svg +23 -0
  173. package/templates/vscode-candy/language-configuration.json +47 -0
  174. package/templates/vscode-candy/package.json +118 -0
  175. package/templates/vscode-candy/schemas/candy-config.schema.json +56 -0
  176. package/templates/vscode-candy/schemas/candy-settings.schema.json +70 -0
  177. package/templates/vscode-candy/snippets/candy.code-snippets +270 -0
  178. package/templates/vscode-candy/syntaxes/candy.tmLanguage.json +296 -0
  179. package/templates/vscode-candy/vim/ftdetect/candy.vim +5 -0
@@ -0,0 +1,439 @@
1
+ import type { SectionRenderContext } from '@caartzee/theme-sdk';
2
+ import { escapeHtml, resolveNavItems, sanitizeNavUrl, type ResolvedNavItem } from '@caartzee/theme-sdk';
3
+
4
+ interface UtilityLinkItem {
5
+ label: string;
6
+ url: string;
7
+ }
8
+
9
+ /** Determine whether a header background color resolves to a dark surface. */
10
+ function isDarkHeaderBackground(color: string | undefined): boolean {
11
+ if (!color || !color.trim()) return true;
12
+ const trimmed = color.trim().toLowerCase();
13
+ if (trimmed === 'transparent' || trimmed === 'inherit' || trimmed === 'initial') return true;
14
+
15
+ const hexMatch = trimmed.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
16
+ if (hexMatch) {
17
+ const raw = hexMatch[1]!;
18
+ const full = raw.length === 3 ? raw.replace(/./g, (c) => c + c) : raw;
19
+ const r = parseInt(full.slice(0, 2), 16);
20
+ const g = parseInt(full.slice(2, 4), 16);
21
+ const b = parseInt(full.slice(4, 6), 16);
22
+ return (0.299 * r + 0.587 * g + 0.114 * b) / 255 < 0.55;
23
+ }
24
+
25
+ const rgbMatch = trimmed.match(/^rgba?\(\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*[,\s]\s*([\d.]+)(?:\s*[,/]\s*([\d.]+))?\s*\)$/);
26
+ if (rgbMatch) {
27
+ const r = Number(rgbMatch[1]);
28
+ const g = Number(rgbMatch[2]);
29
+ const b = Number(rgbMatch[3]);
30
+ const a = rgbMatch[4] !== undefined ? Number(rgbMatch[4]) : 1;
31
+ if (a < 0.25) return true;
32
+ return (0.299 * r + 0.587 * g + 0.114 * b) / 255 < 0.55;
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ /** Identify opaque raster image formats that carry solid (typically white) backgrounds. */
39
+ function isOpaqueRasterImageUrl(url: string): boolean {
40
+ return /\.(?:jpe?g|jfif|bmp)(?:$|[?#])/i.test(url.trim());
41
+ }
42
+
43
+ /**
44
+ * Starter Header Section - Dark Luxury Editorial Edition
45
+ *
46
+ * Features:
47
+ * - Dark utility announcement bar with assured shipping/security highlights and optional utility links
48
+ * - Dark obsidian sticky navigation bar with gold monogram bag badge, brand wordmark, active gold underline
49
+ * - Inline pill search form (/search?q=...), wishlist, account, and cart badge synced with SSR/client state
50
+ * - Dynamic theme navigation menu via Menu API, nav-item blocks, dropdowns, and responsive mobile drawer
51
+ */
52
+ export function renderStarterHeader(ctx: SectionRenderContext): string {
53
+ const settings = ctx.section.settings || {};
54
+ const blocks = ctx.section.blocks || [];
55
+
56
+ // 1. Resolve Logo Settings (Check 'logo' block first, fallback to section settings)
57
+ const logoBlock = blocks.find((b) => b.type === 'logo');
58
+ const lbSettings = logoBlock?.settings || {};
59
+
60
+ const logoImage = (typeof lbSettings.logoImage === 'string' && lbSettings.logoImage)
61
+ || (typeof ctx.globalSettings?.logoUrl === 'string' && ctx.globalSettings.logoUrl)
62
+ || (typeof settings.logoImage === 'string' && settings.logoImage)
63
+ || (typeof settings.logoUrl === 'string' && settings.logoUrl)
64
+ || '';
65
+
66
+ const logoWidth = Number(lbSettings.logoWidth || settings.logoWidth || 140);
67
+ const logoText = typeof lbSettings.logoText === 'string'
68
+ ? lbSettings.logoText
69
+ : (typeof ctx.globalSettings?.storeName === 'string' && ctx.globalSettings.storeName
70
+ ? ctx.globalSettings.storeName
71
+ : (typeof settings.logoText === 'string'
72
+ ? settings.logoText
73
+ : 'My Store'));
74
+
75
+ const showMonogram = lbSettings.showMonogram !== undefined
76
+ ? Boolean(lbSettings.showMonogram)
77
+ : (settings.showMonogram !== undefined ? Boolean(settings.showMonogram) : !logoImage);
78
+
79
+ // 2. Resolve Menu & Typography Settings (Check 'menu' block first, fallback to section settings)
80
+ const menuBlock = blocks.find((b) => b.type === 'menu');
81
+ const mbSettings = menuBlock?.settings || {};
82
+
83
+ const topLevelSize = (mbSettings.topLevelSize || settings.topLevelSize || '14px') as string;
84
+ const textCase = (mbSettings.case || settings.case || 'default') as string;
85
+ const isUppercase = textCase.toLowerCase() === 'uppercase';
86
+ const menuAlignment = (settings.menuAlignment || 'left') as string;
87
+
88
+ const customBgColor = (settings.backgroundColor || settings.menuBackgroundColor || mbSettings.backgroundColor) as string | undefined;
89
+ const customTextColor = (settings.textColor || settings.menuTextColor || mbSettings.textColor) as string | undefined;
90
+
91
+ // 3. Resolve Navigation Links (Menu API selected menu -> nav-item/link-item blocks -> settings.links)
92
+ const navLinks: ResolvedNavItem[] = resolveNavItems(settings.menuId != null && settings.menuId !== ''
93
+ ? { ...ctx.section, blocks: [], settings: { resolvedMenuItems: settings.resolvedMenuItems || [] } }
94
+ : ctx.section, []);
95
+
96
+ // 4. Announcement & Utility Bar Settings
97
+ const showAnnouncement = settings.showAnnouncement !== false;
98
+ const announcementText = typeof settings.announcementText === 'string' && settings.announcementText.trim()
99
+ ? settings.announcementText
100
+ : 'Free Shipping on Orders Over ₹799 | Easy Returns | 100% Secure Payment';
101
+ const announcementLink = typeof settings.announcementLink === 'string' ? sanitizeNavUrl(settings.announcementLink, '') : '';
102
+
103
+ const utilityLinks: UtilityLinkItem[] = Array.isArray(settings.utilityLinks)
104
+ ? (settings.utilityLinks as any[])
105
+ .filter((item) => item && typeof item.label === 'string' && item.label.trim())
106
+ .map((item) => ({
107
+ label: String(item.label).trim(),
108
+ url: sanitizeNavUrl(item.url, '#'),
109
+ }))
110
+ : [];
111
+
112
+ // 5. Resolve Utility Actions & Shell Settings
113
+ const sticky = settings.sticky !== false;
114
+ const showSearch = settings.showSearch !== false && settings.showSearchBar !== false;
115
+ const searchPlaceholder = typeof settings.searchPlaceholder === 'string' && settings.searchPlaceholder.trim()
116
+ ? settings.searchPlaceholder.trim()
117
+ : 'Search products...';
118
+ const showWishlist = settings.showWishlist !== false;
119
+ const showAccount = settings.showAccount !== false;
120
+ const showCart = settings.showCart !== false;
121
+
122
+ // Resolve Cart Count from SectionRenderContext (SSR initial cart or pageContext) or settings
123
+ const rawCart = (ctx as any).cart || (ctx.pageContext as any)?.cart;
124
+ const cartObj = rawCart?.cart || rawCart?.data?.cart || rawCart?.data || rawCart;
125
+ let resolvedCartCount = 0;
126
+ if (typeof cartObj?.itemCount === 'number') {
127
+ resolvedCartCount = cartObj.itemCount;
128
+ } else if (typeof cartObj?.item_count === 'number') {
129
+ resolvedCartCount = cartObj.item_count;
130
+ } else if (typeof rawCart?.itemCount === 'number') {
131
+ resolvedCartCount = rawCart.itemCount;
132
+ } else if (typeof rawCart?.item_count === 'number') {
133
+ resolvedCartCount = rawCart.item_count;
134
+ } else if (Array.isArray(cartObj?.items)) {
135
+ resolvedCartCount = cartObj.items.reduce((sum: number, it: any) => sum + (Number(it.quantity || it.qty) || 1), 0);
136
+ } else if (Array.isArray(rawCart?.items)) {
137
+ resolvedCartCount = rawCart.items.reduce((sum: number, it: any) => sum + (Number(it.quantity || it.qty) || 1), 0);
138
+ } else if (typeof settings.cartCount === 'number') {
139
+ resolvedCartCount = settings.cartCount;
140
+ }
141
+
142
+ // 6. CSS Styles & Alignment classes
143
+ const headerStyle = customBgColor ? `background-color: ${escapeHtml(customBgColor)};` : '';
144
+ const textInlineStyle = customTextColor ? `color: ${escapeHtml(customTextColor)};` : '';
145
+ const fontSizeStyle = topLevelSize ? `font-size: ${escapeHtml(topLevelSize)};` : '';
146
+
147
+ let alignmentClass = 'justify-start lg:ml-6';
148
+ if (menuAlignment === 'center') alignmentClass = 'justify-center';
149
+ if (menuAlignment === 'right') alignmentClass = 'justify-end mr-4';
150
+
151
+ const defaultLinkColorClass = customTextColor
152
+ ? ''
153
+ : 'text-stone-200 hover:text-[#e5b95c]';
154
+
155
+ const defaultIconColorClass = customTextColor
156
+ ? ''
157
+ : 'text-stone-200 hover:text-[#e5b95c]';
158
+
159
+ const sectionId = escapeHtml(ctx.section.id);
160
+ const sectionType = escapeHtml(ctx.section.type || 'starter-header');
161
+ const currentSlug = (ctx.pageContext as any)?.slug || ((ctx.pageContext as any)?.pageType === 'home' ? '/' : '');
162
+ const isDarkHeader = isDarkHeaderBackground(customBgColor);
163
+ const removeOpaqueLogoBg = Boolean(logoImage && isOpaqueRasterImageUrl(logoImage));
164
+ const logoFilterId = `sf-logo-key-${sectionId}`;
165
+ const logoImgClass = `sf-header-logo-img h-auto object-contain transition-transform group-hover:scale-105${removeOpaqueLogoBg && !isDarkHeader ? ' mix-blend-multiply' : ''}`;
166
+ const logoImgStyle = `max-width: ${logoWidth}px; max-height: 48px;${removeOpaqueLogoBg && isDarkHeader ? ` filter: url(#${logoFilterId});` : ''}`;
167
+
168
+ const announcementSegments = announcementText
169
+ .split('|')
170
+ .map((part) => part.trim())
171
+ .filter(Boolean);
172
+
173
+ const renderAnnouncementSegment = (seg: string, idx: number) => {
174
+ const lower = seg.toLowerCase();
175
+ const iconSvg = idx === 0
176
+ ? `<svg class="w-3.5 h-3.5 text-[#e5b95c] shrink-0" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M13 2L4 14h6l-1 8 9-12h-6l1-8z"/></svg>`
177
+ : lower.includes('secure') || lower.includes('payment')
178
+ ? `<svg class="w-3.5 h-3.5 text-[#e5b95c] shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><path stroke-linecap="round" stroke-linejoin="round" d="m9 12 2 2 4-4"/></svg>`
179
+ : '';
180
+ return `<span class="inline-flex items-center gap-1.5 whitespace-nowrap">${iconSvg}<span>${escapeHtml(seg)}</span></span>`;
181
+ };
182
+
183
+ return `
184
+ <!-- Header Section Shell -->
185
+ ${removeOpaqueLogoBg && isDarkHeader ? `
186
+ <svg aria-hidden="true" focusable="false" width="0" height="0" style="position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none;">
187
+ <defs>
188
+ <filter id="${logoFilterId}" color-interpolation-filters="sRGB" x="0%" y="0%" width="100%" height="100%">
189
+ <feColorMatrix in="SourceGraphic" type="matrix" values="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0" result="chR" />
190
+ <feColorMatrix in="SourceGraphic" type="matrix" values="0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0" result="chG" />
191
+ <feColorMatrix in="SourceGraphic" type="matrix" values="0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0" result="chB" />
192
+ <feBlend in="chR" in2="chG" mode="darken" result="minRG" />
193
+ <feBlend in="minRG" in2="chB" mode="darken" result="minRGB" />
194
+ <feColorMatrix in="minRGB" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0" result="minAlpha" />
195
+ <feComponentTransfer in="minAlpha" result="fgMask">
196
+ <feFuncA type="table" tableValues="1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.95 0.65 0 0 0" />
197
+ </feComponentTransfer>
198
+ <feComposite in="SourceGraphic" in2="fgMask" operator="in" />
199
+ </filter>
200
+ </defs>
201
+ </svg>
202
+ ` : ''}
203
+ <header class="sf-header sf-starter-header w-full ${sticky ? 'sticky top-0 z-50' : 'relative z-30'} ${customBgColor ? 'shadow-md' : 'bg-[#14100e]/95 text-white backdrop-blur-md border-b border-white/10 shadow-md'} transition-all duration-300" id="${sectionId}" data-section-id="${sectionId}" data-section-type="${sectionType}" data-region="header" style="${headerStyle}">
204
+
205
+ <!-- Top Dark Utility & Announcement Strip -->
206
+ ${showAnnouncement ? `
207
+ <div id="sf-announcement-${sectionId}" class="sf-announcement w-full bg-[#090706] text-stone-300 text-[11px] sm:text-xs font-medium py-2 border-b border-white/10 select-none">
208
+ <div class="max-w-[1360px] mx-auto px-4 sm:px-6 lg:px-8 flex items-center justify-between gap-4">
209
+ <div class="flex flex-wrap items-center gap-x-3 gap-y-1 min-w-0">
210
+ ${announcementSegments.map((seg, idx) => `
211
+ ${idx > 0 ? '<span class="text-white/20" aria-hidden="true">|</span>' : ''}
212
+ ${announcementLink && idx === 0
213
+ ? `<a href="${escapeHtml(announcementLink)}" class="hover:text-[#e5b95c] transition-colors inline-flex items-center">${renderAnnouncementSegment(seg, idx)}</a>`
214
+ : renderAnnouncementSegment(seg, idx)}
215
+ `).join('')}
216
+ </div>
217
+ ${utilityLinks.length > 0 ? `
218
+ <div class="hidden sm:flex items-center gap-3 shrink-0 text-stone-300">
219
+ ${utilityLinks.map((uLink, idx) => `
220
+ ${idx > 0 ? '<span class="text-white/20" aria-hidden="true">|</span>' : ''}
221
+ <a href="${escapeHtml(uLink.url)}" class="hover:text-[#e5b95c] transition-colors whitespace-nowrap">${escapeHtml(uLink.label)}</a>
222
+ `).join('')}
223
+ </div>
224
+ ` : ''}
225
+ </div>
226
+ </div>
227
+ ` : ''}
228
+
229
+ <div class="max-w-[1360px] mx-auto px-4 sm:px-6 lg:px-8">
230
+ <div class="sf-header-row flex items-center justify-between h-16 sm:h-[74px] gap-4">
231
+
232
+ <!-- Brand Logo / Identity -->
233
+ <div class="flex items-center gap-2.5 shrink-0">
234
+ <a href="/" class="group flex items-center gap-2.5 text-decoration-none">
235
+ ${logoImage ? `
236
+ <img src="${escapeHtml(logoImage)}" alt="${escapeHtml(logoText)}" class="${logoImgClass}" style="${logoImgStyle}" />
237
+ ` : ''}
238
+
239
+ ${showMonogram ? `
240
+ <span class="sf-header-monogram w-8 h-8 rounded-lg bg-gradient-to-br from-[#f2cf7e] to-[#c79131] text-[#14100e] flex items-center justify-center shadow-sm group-hover:scale-105 transition-transform shrink-0" aria-hidden="true">
241
+ <svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
242
+ <path d="M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z" />
243
+ <line x1="3" y1="6" x2="21" y2="6" />
244
+ <path d="M16 10a4 4 0 0 1-8 0" />
245
+ </svg>
246
+ </span>
247
+ ` : ''}
248
+
249
+ ${(!logoImage || logoText) ? `
250
+ <span class="sf-header-logo-text text-xl sm:text-2xl font-bold tracking-tight font-heading group-hover:opacity-90 transition-opacity ${customTextColor ? '' : 'text-white'}" data-element="heading" style="${textInlineStyle}">
251
+ ${escapeHtml(logoText)}
252
+ </span>
253
+ ` : ''}
254
+ </a>
255
+ </div>
256
+
257
+ <!-- Desktop Navigation Links -->
258
+ <nav class="hidden md:flex items-center gap-5 lg:gap-7 flex-1 min-w-0 ${alignmentClass}" aria-label="Primary Navigation">
259
+ ${navLinks.map((link) => {
260
+ const active = Boolean(currentSlug && currentSlug === link.url);
261
+ const linkLabel = escapeHtml(link.label);
262
+ const linkUrl = escapeHtml(link.url);
263
+ const highlightClass = link.highlight
264
+ ? 'text-[#e5b95c] font-semibold'
265
+ : (active ? 'text-[#e5b95c] font-semibold' : defaultLinkColorClass);
266
+
267
+ if (link.children && link.children.length > 0) {
268
+ const subItemsHtml = link.children
269
+ .map((child) => {
270
+ const childLabel = escapeHtml(child.label);
271
+ const childUrl = escapeHtml(child.url);
272
+ return `<li class="sf-header__dropdown-item"><a href="${childUrl}" class="sf-header__dropdown-link block px-4 py-2 text-sm text-stone-200 hover:text-[#e5b95c] hover:bg-white/5 rounded-md transition-colors">${childLabel}</a></li>`;
273
+ })
274
+ .join('\n');
275
+
276
+ return `
277
+ <div class="relative group sf-header__nav-item sf-header__nav-item--has-children shrink-0">
278
+ <a href="${linkUrl}" class="transition-colors relative py-1.5 text-sm inline-flex items-center gap-1 whitespace-nowrap ${isUppercase ? 'uppercase tracking-wider font-semibold' : 'font-medium'} ${highlightClass}" style="${textInlineStyle} ${fontSizeStyle}">
279
+ <span>${linkLabel}</span>
280
+ <svg class="w-3.5 h-3.5 opacity-70 group-hover:opacity-100 transition-transform group-hover:rotate-180" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /></svg>
281
+ ${active ? '<span class="absolute bottom-0 inset-x-0 h-0.5 rounded-full bg-[#e5b95c]"></span>' : ''}
282
+ </a>
283
+ <div class="absolute left-0 top-full pt-2 opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-all duration-200 z-50 min-w-[210px]">
284
+ <ul class="sf-header__dropdown-menu bg-[#1c1613] border border-white/15 rounded-xl shadow-2xl p-2 space-y-0.5">
285
+ ${subItemsHtml}
286
+ </ul>
287
+ </div>
288
+ </div>
289
+ `;
290
+ }
291
+
292
+ return `
293
+ <a href="${linkUrl}" class="transition-colors relative py-1.5 text-sm whitespace-nowrap shrink-0 ${isUppercase ? 'uppercase tracking-wider font-semibold' : 'font-medium'} ${highlightClass}" style="${textInlineStyle} ${fontSizeStyle}">
294
+ ${linkLabel}
295
+ ${active ? '<span class="absolute bottom-0 inset-x-0 h-0.5 rounded-full bg-[#e5b95c]"></span>' : ''}
296
+ </a>
297
+ `;
298
+ }).join('')}
299
+ </nav>
300
+
301
+ <!-- Search Pill, Header Action Icons & Mobile Toggle -->
302
+ <div class="flex items-center gap-1.5 sm:gap-2.5 shrink-0">
303
+ ${showSearch ? `
304
+ <form action="/search" method="GET" class="hidden xl:flex items-center gap-2 bg-white/10 hover:bg-white/15 focus-within:bg-white/15 border border-white/15 focus-within:border-[#e5b95c]/60 rounded-full px-3.5 py-1.5 w-64 transition-all">
305
+ <button type="submit" aria-label="Search Catalog" class="text-stone-400 hover:text-[#e5b95c] shrink-0">
306
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
307
+ <circle cx="11" cy="11" r="7.5" />
308
+ <line x1="21" y1="21" x2="16.5" y2="16.5" />
309
+ </svg>
310
+ </button>
311
+ <input
312
+ type="search"
313
+ name="q"
314
+ placeholder="${escapeHtml(searchPlaceholder)}"
315
+ aria-label="Search products"
316
+ class="w-full bg-transparent border-0 text-xs text-white placeholder-stone-400 focus:outline-none"
317
+ />
318
+ </form>
319
+ <a href="/search" aria-label="Search Catalog" class="xl:hidden p-2 rounded-full hover:bg-white/10 transition-all active:scale-95 ${defaultIconColorClass}" style="${textInlineStyle}">
320
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" stroke-width="1.8" viewBox="0 0 24 24">
321
+ <circle cx="11" cy="11" r="7.5" />
322
+ <line x1="21" y1="21" x2="16.5" y2="16.5" />
323
+ </svg>
324
+ </a>
325
+ ` : ''}
326
+
327
+ ${showWishlist ? `
328
+ <a href="/wishlist" aria-label="My Wishlist" class="hidden sm:inline-flex p-2 rounded-full hover:bg-white/10 transition-all active:scale-95 ${defaultIconColorClass}" style="${textInlineStyle}">
329
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" stroke-width="1.8" viewBox="0 0 24 24">
330
+ <path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" />
331
+ </svg>
332
+ </a>
333
+ ` : ''}
334
+
335
+ ${showAccount ? `
336
+ <a href="/account" aria-label="Customer Account" class="p-2 rounded-full hover:bg-white/10 transition-all active:scale-95 ${defaultIconColorClass}" style="${textInlineStyle}">
337
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" stroke-width="1.8" viewBox="0 0 24 24">
338
+ <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
339
+ <circle cx="12" cy="7" r="4" />
340
+ </svg>
341
+ </a>
342
+ ` : ''}
343
+
344
+ ${showCart ? `
345
+ <!-- Cart Trigger Button with Synced Badge -->
346
+ <a href="/cart" class="relative p-2 sm:p-2.5 rounded-full hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-all active:scale-95 ${defaultIconColorClass}" aria-label="Shopping Bag" style="${textInlineStyle} position: relative !important; display: inline-flex !important; align-items: center !important; justify-content: center !important;">
347
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" stroke-width="1.8" viewBox="0 0 24 24">
348
+ <path d="M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z" />
349
+ <line x1="3" y1="6" x2="21" y2="6" />
350
+ <path d="M16 10a4 4 0 0 1-8 0" />
351
+ </svg>
352
+ <span
353
+ class="sf-header__cart-badge js-cart-badge js-cart-count absolute -top-1 -right-1 rounded-full text-white text-[10px] font-bold shadow-sm pointer-events-none select-none transition-transform"
354
+ style="position: absolute !important; top: -2px !important; right: -2px !important; box-sizing: border-box !important; width: 18px !important; height: 18px !important; min-width: 18px !important; min-height: 18px !important; padding: 0 !important; background-color: #0f172a !important; color: #ffffff !important; border-radius: 9999px !important; border: 1.5px solid #ffffff !important; font-size: 10px !important; font-weight: 700 !important; line-height: 1 !important; display: ${resolvedCartCount > 0 ? 'inline-flex' : 'none'}; align-items: center !important; justify-content: center !important; z-index: 10 !important;"
355
+ data-count="${resolvedCartCount}"
356
+ >${resolvedCartCount}</span>
357
+ </a>
358
+ ` : ''}
359
+
360
+ <!-- Mobile Hamburger Button -->
361
+ <button type="button" class="md:hidden p-2 rounded-lg hover:bg-white/10 transition-all ${defaultIconColorClass}" id="sf-mobile-menu-btn-${sectionId}" aria-label="Toggle Navigation Menu" onclick="(function(){var el=document.getElementById('sf-mobile-drawer-${sectionId}');if(el){el.classList.toggle('hidden');}})()">
362
+ <svg class="w-6 h-6" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
363
+ <path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16" />
364
+ </svg>
365
+ </button>
366
+ </div>
367
+
368
+ </div>
369
+ </div>
370
+
371
+ <!-- Mobile Navigation Drawer -->
372
+ <div id="sf-mobile-drawer-${sectionId}" class="hidden md:hidden border-t border-white/10 bg-[#14100e] text-stone-200 px-4 pt-3 pb-6 space-y-2" style="${headerStyle}">
373
+ ${showSearch ? `
374
+ <form action="/search" method="GET" class="flex items-center gap-2 bg-white/10 border border-white/15 rounded-full px-3.5 py-2 mb-3">
375
+ <svg class="w-4 h-4 text-stone-400 shrink-0" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
376
+ <circle cx="11" cy="11" r="7.5" />
377
+ <line x1="21" y1="21" x2="16.5" y2="16.5" />
378
+ </svg>
379
+ <input type="search" name="q" placeholder="${escapeHtml(searchPlaceholder)}" class="w-full bg-transparent border-0 text-xs text-white placeholder-stone-400 focus:outline-none" />
380
+ </form>
381
+ ` : ''}
382
+
383
+ ${navLinks.map((link) => {
384
+ const linkLabel = escapeHtml(link.label);
385
+ const linkUrl = escapeHtml(link.url);
386
+ const highlightClass = link.highlight ? 'text-[#e5b95c] font-bold' : defaultLinkColorClass;
387
+
388
+ if (link.children && link.children.length > 0) {
389
+ const childLinks = link.children.map((child) => `
390
+ <a href="${escapeHtml(child.url)}" class="block pl-6 pr-3 py-1.5 text-sm text-stone-400 hover:text-[#e5b95c] transition-colors" style="${textInlineStyle}">
391
+ ${escapeHtml(child.label)}
392
+ </a>
393
+ `).join('');
394
+
395
+ return `
396
+ <div>
397
+ <a href="${linkUrl}" class="block px-3 py-2 text-base font-semibold ${highlightClass}" style="${textInlineStyle}">
398
+ ${linkLabel}
399
+ </a>
400
+ <div class="space-y-1">
401
+ ${childLinks}
402
+ </div>
403
+ </div>
404
+ `;
405
+ }
406
+
407
+ return `
408
+ <a href="${linkUrl}" class="block px-3 py-2 rounded-lg text-base ${isUppercase ? 'uppercase tracking-wider font-semibold' : 'font-medium'} ${highlightClass}" style="${textInlineStyle}">
409
+ ${linkLabel}
410
+ </a>
411
+ `;
412
+ }).join('')}
413
+
414
+ ${(showSearch || showWishlist || showAccount) ? `
415
+ <div class="pt-4 border-t border-white/10 flex items-center justify-around">
416
+ ${showSearch ? `
417
+ <a href="/search" class="flex items-center gap-2 text-sm font-medium ${defaultIconColorClass}" style="${textInlineStyle}">
418
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7.5"/><line x1="21" y1="21" x2="16.5" y2="16.5"/></svg>
419
+ Search
420
+ </a>
421
+ ` : ''}
422
+ ${showWishlist ? `
423
+ <a href="/wishlist" class="flex items-center gap-2 text-sm font-medium ${defaultIconColorClass}" style="${textInlineStyle}">
424
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>
425
+ Wishlist
426
+ </a>
427
+ ` : ''}
428
+ ${showAccount ? `
429
+ <a href="/account" class="flex items-center gap-2 text-sm font-medium ${defaultIconColorClass}" style="${textInlineStyle}">
430
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
431
+ Account
432
+ </a>
433
+ ` : ''}
434
+ </div>
435
+ ` : ''}
436
+ </div>
437
+ </header>
438
+ `;
439
+ }