@authhero/widget 0.4.1 → 0.5.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 (39) hide show
  1. package/README.md +21 -1
  2. package/dist/authhero-widget/authhero-widget.esm.js +1 -1
  3. package/dist/authhero-widget/index.esm.js +1 -1
  4. package/dist/authhero-widget/p-7989dabd.entry.js +1 -0
  5. package/dist/authhero-widget/{p-Doiemx6o.js → p-bMtPc5Dm.js} +1 -1
  6. package/dist/authhero-widget/p-fa60ab6e.entry.js +1 -0
  7. package/dist/cjs/authhero-node.cjs.entry.js +97 -9
  8. package/dist/cjs/authhero-widget.cjs.entry.js +82 -18
  9. package/dist/cjs/authhero-widget.cjs.js +2 -2
  10. package/dist/cjs/{index-D0xitTOL.js → index-Db4bZu99.js} +28 -3
  11. package/dist/cjs/index.cjs.js +1 -1
  12. package/dist/cjs/loader.cjs.js +2 -2
  13. package/dist/collection/components/authhero-node/authhero-node.css +237 -94
  14. package/dist/collection/components/authhero-node/authhero-node.js +101 -8
  15. package/dist/collection/components/authhero-widget/authhero-widget.css +128 -70
  16. package/dist/collection/components/authhero-widget/authhero-widget.js +30 -5
  17. package/dist/collection/utils/branding.js +52 -13
  18. package/dist/components/authhero-node.js +1 -1
  19. package/dist/components/authhero-widget.js +1 -1
  20. package/dist/components/index.js +1 -1
  21. package/dist/components/p-pupmqprs.js +1 -0
  22. package/dist/components/p-uIy4ySa4.js +1 -0
  23. package/dist/esm/authhero-node.entry.js +97 -9
  24. package/dist/esm/authhero-widget.entry.js +82 -18
  25. package/dist/esm/authhero-widget.js +3 -3
  26. package/dist/esm/{index-Doiemx6o.js → index-bMtPc5Dm.js} +28 -3
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/loader.js +3 -3
  29. package/dist/types/components/authhero-node/authhero-node.d.ts +14 -1
  30. package/dist/types/components/authhero-widget/authhero-widget.d.ts +8 -0
  31. package/hydrate/index.js +207 -29
  32. package/hydrate/index.mjs +207 -29
  33. package/package.json +9 -3
  34. package/dist/authhero-widget/p-2e93c814.entry.js +0 -1
  35. package/dist/authhero-widget/p-539fc666.entry.js +0 -1
  36. package/dist/collection/server/index.js +0 -453
  37. package/dist/components/p-086EZrPM.js +0 -1
  38. package/dist/components/p-DS6y_iDJ.js +0 -1
  39. package/dist/types/server/index.d.ts +0 -85
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-D0xitTOL.js');
3
+ var index = require('./index-Db4bZu99.js');
4
4
 
5
5
  /**
6
6
  * AuthHero Widget - Branding Utilities
@@ -167,39 +167,60 @@ function themeToCssVars(theme) {
167
167
  // Fonts
168
168
  if (theme.fonts) {
169
169
  const f = theme.fonts;
170
+ // reference_text_size is the base font size in pixels (default 16px)
171
+ const baseSize = f.reference_text_size || 16;
170
172
  if (f.font_url) {
171
173
  vars['--ah-font-url'] = f.font_url;
172
174
  }
173
175
  if (f.reference_text_size) {
174
176
  vars['--ah-font-size-base'] = `${f.reference_text_size}px`;
175
177
  }
178
+ // Title, subtitle, etc. sizes are percentages of the base size
176
179
  if (f.title?.size) {
177
- vars['--ah-font-size-title'] = `${f.title.size}px`;
180
+ const titlePx = Math.round((f.title.size / 100) * baseSize);
181
+ vars['--ah-font-size-title'] = `${titlePx}px`;
178
182
  }
179
183
  if (f.subtitle?.size) {
180
- vars['--ah-font-size-subtitle'] = `${f.subtitle.size}px`;
184
+ const subtitlePx = Math.round((f.subtitle.size / 100) * baseSize);
185
+ vars['--ah-font-size-subtitle'] = `${subtitlePx}px`;
181
186
  }
182
187
  if (f.body_text?.size) {
183
- vars['--ah-font-size-body'] = `${f.body_text.size}px`;
188
+ const bodyPx = Math.round((f.body_text.size / 100) * baseSize);
189
+ vars['--ah-font-size-body'] = `${bodyPx}px`;
184
190
  }
185
191
  if (f.input_labels?.size) {
186
- vars['--ah-font-size-label'] = `${f.input_labels.size}px`;
192
+ const labelPx = Math.round((f.input_labels.size / 100) * baseSize);
193
+ vars['--ah-font-size-label'] = `${labelPx}px`;
187
194
  }
188
195
  if (f.buttons_text?.size) {
189
- vars['--ah-font-size-btn'] = `${f.buttons_text.size}px`;
196
+ const btnPx = Math.round((f.buttons_text.size / 100) * baseSize);
197
+ vars['--ah-font-size-btn'] = `${btnPx}px`;
190
198
  }
191
199
  if (f.links?.size) {
192
- vars['--ah-font-size-link'] = `${f.links.size}px`;
200
+ const linkPx = Math.round((f.links.size / 100) * baseSize);
201
+ vars['--ah-font-size-link'] = `${linkPx}px`;
193
202
  }
194
203
  if (f.links_style === 'underlined') {
195
204
  vars['--ah-link-decoration'] = 'underline';
196
205
  }
197
- // Font weights
198
- if (f.title?.bold) {
199
- vars['--ah-font-weight-title'] = '700';
206
+ // Font weights - bold option sets font-weight to 700
207
+ if (f.title?.bold !== undefined) {
208
+ vars['--ah-font-weight-title'] = f.title.bold ? '700' : '400';
200
209
  }
201
- if (f.buttons_text?.bold) {
202
- vars['--ah-font-weight-btn'] = '600';
210
+ if (f.subtitle?.bold !== undefined) {
211
+ vars['--ah-font-weight-subtitle'] = f.subtitle.bold ? '700' : '400';
212
+ }
213
+ if (f.body_text?.bold !== undefined) {
214
+ vars['--ah-font-weight-body'] = f.body_text.bold ? '700' : '400';
215
+ }
216
+ if (f.input_labels?.bold !== undefined) {
217
+ vars['--ah-font-weight-label'] = f.input_labels.bold ? '700' : '400';
218
+ }
219
+ if (f.buttons_text?.bold !== undefined) {
220
+ vars['--ah-font-weight-btn'] = f.buttons_text.bold ? '600' : '400';
221
+ }
222
+ if (f.links?.bold !== undefined) {
223
+ vars['--ah-font-weight-link'] = f.links.bold ? '700' : '400';
203
224
  }
204
225
  }
205
226
  // Widget settings
@@ -216,9 +237,27 @@ function themeToCssVars(theme) {
216
237
  center: 'center',
217
238
  left: 'flex-start',
218
239
  right: 'flex-end',
219
- none: 'none',
220
240
  };
221
- vars['--ah-logo-align'] = positionMap[w.logo_position] ?? 'center';
241
+ if (w.logo_position === 'none') {
242
+ vars['--ah-logo-display'] = 'none';
243
+ }
244
+ else {
245
+ vars['--ah-logo-align'] = positionMap[w.logo_position] ?? 'center';
246
+ }
247
+ }
248
+ if (w.social_buttons_layout) {
249
+ // 'top' means social buttons above fields, 'bottom' means below
250
+ // Divider is always order 1 (middle)
251
+ if (w.social_buttons_layout === 'top') {
252
+ vars['--ah-social-order'] = '0';
253
+ vars['--ah-divider-order'] = '1';
254
+ vars['--ah-fields-order'] = '2';
255
+ }
256
+ else {
257
+ vars['--ah-social-order'] = '2';
258
+ vars['--ah-divider-order'] = '1';
259
+ vars['--ah-fields-order'] = '0';
260
+ }
222
261
  }
223
262
  }
224
263
  // Page background
@@ -251,7 +290,7 @@ function applyCssVars(element, vars) {
251
290
  });
252
291
  }
253
292
 
254
- const authheroWidgetCss = () => `:host{display:block;font-family:var(--ah-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif)}.widget-container{max-width:var(--ah-widget-max-width, 400px);margin:0 auto;padding:var(--ah-widget-padding, 2rem);background-color:var(--ah-color-bg, #ffffff);border-radius:var(--ah-widget-radius, 8px);box-shadow:var(--ah-widget-shadow, 0 2px 10px rgba(0, 0, 0, 0.1))}.logo{display:block;width:var(--ah-logo-size, 48px);height:var(--ah-logo-size, 48px);margin:0 auto var(--ah-space-6, 1.5rem);object-fit:contain;border-radius:var(--ah-logo-radius, 8px)}.title{font-size:var(--ah-font-size-2xl, 1.5rem);font-weight:var(--ah-font-weight-semibold, 600);text-align:center;margin:0 0 var(--ah-space-8, 2rem);color:var(--ah-color-text, #111827);line-height:var(--ah-line-height-tight, 1.25)}.message{padding:var(--ah-space-3, 0.75rem) var(--ah-space-4, 1rem);border-radius:var(--ah-radius-md, 4px);margin-bottom:var(--ah-space-4, 1rem);font-size:var(--ah-font-size-sm, 0.875rem);line-height:var(--ah-line-height-normal, 1.5)}.message-error{background-color:var(--ah-color-error-bg, #fee2e2);color:var(--ah-color-error, #dc2626);border:1px solid var(--ah-color-error-border, #fecaca)}.message-success{background-color:var(--ah-color-success-bg, #dcfce7);color:var(--ah-color-success, #16a34a);border:1px solid var(--ah-color-success-border, #bbf7d0)}form{display:flex;flex-direction:column;gap:var(--ah-space-4, 1rem)}.links{display:flex;flex-direction:column;align-items:center;gap:var(--ah-space-2, 0.5rem);margin-top:var(--ah-space-6, 1.5rem);padding-top:var(--ah-space-4, 1rem)}.link-wrapper{font-size:var(--ah-font-size-sm, 0.875rem);color:var(--ah-color-text-muted, #6b7280)}.link{color:var(--ah-color-primary, #0066cc);text-decoration:none;font-size:var(--ah-font-size-sm, 0.875rem);transition:color var(--ah-transition-fast, 150ms ease)}.link:hover{text-decoration:underline}.link:focus-visible{outline:2px solid var(--ah-color-primary, #0066cc);outline-offset:2px}.divider{display:flex;align-items:center;text-align:center;margin:var(--ah-space-2, 0.5rem) 0}.divider::before,.divider::after{content:'';flex:1;border-bottom:1px solid var(--ah-color-border-muted, #e5e7eb)}.divider-text{padding:0 var(--ah-space-4, 1rem);font-size:var(--ah-font-size-sm, 0.875rem);color:var(--ah-color-text-muted, #9ca3af);text-transform:uppercase;letter-spacing:0.05em}.loading-spinner{width:40px;height:40px;margin:var(--ah-space-8, 2rem) auto;border:3px solid var(--ah-color-border-muted, #f3f3f3);border-top:3px solid var(--ah-color-primary, #0066cc);border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.error-message{text-align:center;color:var(--ah-color-error, #dc2626);padding:var(--ah-space-4, 1rem)}`;
293
+ const authheroWidgetCss = () => `:host{display:block;font-family:var(--ah-font-family, 'ulp-font', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, sans-serif);font-size:var(--ah-font-size-base, 14px);line-height:var(--ah-line-height-base, 1.5);color:var(--ah-color-text, #1e212a);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.widget-container{max-width:var(--ah-widget-max-width, 400px);width:100%;margin:0 auto;background-color:var(--ah-color-bg, #ffffff);border-radius:var(--ah-widget-radius, 5px);box-shadow:var(--ah-widget-shadow, 0 4px 22px 0 rgba(0, 0, 0, 0.11));box-sizing:border-box}.widget-header{padding:var(--ah-header-padding, 40px 40px 24px)}.widget-body{padding:var(--ah-body-padding, 0 40px 40px)}.logo-wrapper{display:var(--ah-logo-display, flex);justify-content:var(--ah-logo-align, center)}.logo{display:block;height:var(--ah-logo-height, 52px);max-width:100%;width:auto;object-fit:contain}.title{font-size:var(--ah-font-size-title, 24px);font-weight:var(--ah-font-weight-title, 700);text-align:var(--ah-title-align, center);margin:var(--ah-title-margin, 24px 0 16px);color:var(--ah-color-header, #1e212a);line-height:1.2}.description{font-size:var(--ah-font-size-description, 14px);text-align:var(--ah-title-align, center);margin:var(--ah-description-margin, 0);color:var(--ah-color-text, #1e212a);line-height:1.5}.message{padding:12px 16px;border-radius:4px;margin-bottom:16px;font-size:14px;line-height:1.5}.message-error{background-color:var(--ah-color-error-bg, #ffeaea);color:var(--ah-color-error, #d03c38);border-left:3px solid var(--ah-color-error, #d03c38)}.message-success{background-color:var(--ah-color-success-bg, #e6f9f1);color:var(--ah-color-success, #13a769);border-left:3px solid var(--ah-color-success, #13a769)}form{display:flex;flex-direction:column}.form-content{display:flex;flex-direction:column}.social-section{display:flex;flex-direction:column;gap:8px;order:var(--ah-social-order, 2)}.fields-section{display:flex;flex-direction:column;order:var(--ah-fields-order, 0)}.divider{display:flex;align-items:center;text-align:center;margin:16px 0;order:var(--ah-divider-order, 1)}.divider::before,.divider::after{content:'';flex:1;border-bottom:1px solid var(--ah-color-border-muted, #c9cace)}.divider-text{padding:0 10px;font-size:12px;font-weight:400;color:var(--ah-color-text-muted, #65676e);text-transform:uppercase;letter-spacing:0}.links{display:flex;flex-direction:column;align-items:center;gap:8px;margin-top:16px}.link-wrapper{font-size:14px;color:var(--ah-color-text, #1e212a)}.link{color:var(--ah-color-link, #635dff);text-decoration:var(--ah-link-decoration, none);font-size:14px;font-weight:var(--ah-font-weight-link, 400);transition:color 150ms ease}.link:hover{text-decoration:underline}.link:focus-visible{outline:2px solid var(--ah-color-link, #635dff);outline-offset:2px;border-radius:2px}.loading-spinner{width:32px;height:32px;margin:24px auto;border:3px solid var(--ah-color-border-muted, #e0e1e3);border-top-color:var(--ah-color-primary, #635dff);border-radius:50%;animation:spin 0.8s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.error-message{text-align:center;color:var(--ah-color-error, #d03c38);padding:16px;font-size:14px}`;
255
294
 
256
295
  const AuthheroWidget = class {
257
296
  constructor(hostRef) {
@@ -509,6 +548,13 @@ const AuthheroWidget = class {
509
548
  }
510
549
  };
511
550
  handleButtonClick = (detail) => {
551
+ // If this is a submit button click, trigger form submission
552
+ if (detail.type === 'submit') {
553
+ // Create a synthetic submit event and call handleSubmit
554
+ const syntheticEvent = { preventDefault: () => { } };
555
+ this.handleSubmit(syntheticEvent);
556
+ return;
557
+ }
512
558
  this.buttonClick.emit(detail);
513
559
  };
514
560
  handleLinkClick = (e, link) => {
@@ -546,6 +592,20 @@ const AuthheroWidget = class {
546
592
  .filter((c) => c.visible !== false)
547
593
  .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
548
594
  }
595
+ /**
596
+ * Check if a component is a social button.
597
+ */
598
+ isSocialComponent(component) {
599
+ // Check the type property directly - FormComponent has a 'type' field
600
+ // SocialField has type 'SOCIAL'
601
+ return component.type === 'SOCIAL';
602
+ }
603
+ /**
604
+ * Check if a component is a divider.
605
+ */
606
+ isDividerComponent(component) {
607
+ return component.type === 'DIVIDER';
608
+ }
549
609
  render() {
550
610
  if (this.loading && !this._screen) {
551
611
  return (index.h("div", { class: "widget-container" }, index.h("div", { class: "loading-spinner" })));
@@ -556,9 +616,13 @@ const AuthheroWidget = class {
556
616
  const screenErrors = this.getScreenErrors();
557
617
  const screenSuccesses = this.getScreenSuccesses();
558
618
  const components = this.getOrderedComponents();
559
- // Get logo URL from branding props
560
- const logoUrl = this._branding?.logo_url;
561
- return (index.h("div", { class: "widget-container", part: "container" }, logoUrl && index.h("img", { class: "logo", part: "logo", src: logoUrl, alt: "Logo" }), this._screen.title && (index.h("h1", { class: "title", part: "title" }, this._screen.title)), this._screen.description && (index.h("p", { class: "description", part: "description" }, this._screen.description)), screenErrors.map((err) => (index.h("div", { class: "message message-error", part: "message message-error", key: err.id ?? err.text }, err.text))), screenSuccesses.map((msg) => (index.h("div", { class: "message message-success", part: "message message-success", key: msg.id ?? msg.text }, msg.text))), index.h("form", { onSubmit: this.handleSubmit, part: "form" }, components.map((component) => (index.h("authhero-node", { key: component.id, component: component, value: this.formData[component.id], onFieldChange: (e) => this.handleInputChange(e.detail.id, e.detail.value), onButtonClick: (e) => this.handleButtonClick(e.detail), disabled: this.loading })))), this._screen.links && this._screen.links.length > 0 && (index.h("div", { class: "links", part: "links" }, this._screen.links.map((link) => (index.h("span", { class: "link-wrapper", part: "link-wrapper", key: link.id ?? link.href }, link.linkText ? (index.h("span", null, link.text, ' ', index.h("a", { href: link.href, class: "link", part: "link", onClick: (e) => this.handleLinkClick(e, { id: link.id, href: link.href, text: link.linkText || link.text }) }, link.linkText))) : (index.h("a", { href: link.href, class: "link", part: "link", onClick: (e) => this.handleLinkClick(e, { id: link.id, href: link.href, text: link.text }) }, link.text)))))))));
619
+ // Separate social, divider, and field components for layout ordering
620
+ const socialComponents = components.filter(c => this.isSocialComponent(c));
621
+ const fieldComponents = components.filter(c => !this.isSocialComponent(c) && !this.isDividerComponent(c));
622
+ const hasDivider = components.some(c => this.isDividerComponent(c));
623
+ // Get logo URL from theme.widget (takes precedence) or branding
624
+ const logoUrl = this._theme?.widget?.logo_url || this._branding?.logo_url;
625
+ return (index.h("div", { class: "widget-container", part: "container" }, index.h("header", { class: "widget-header", part: "header" }, logoUrl && (index.h("div", { class: "logo-wrapper", part: "logo-wrapper" }, index.h("img", { class: "logo", part: "logo", src: logoUrl, alt: "Logo" }))), this._screen.title && (index.h("h1", { class: "title", part: "title" }, this._screen.title)), this._screen.description && (index.h("p", { class: "description", part: "description" }, this._screen.description))), index.h("div", { class: "widget-body", part: "body" }, screenErrors.map((err) => (index.h("div", { class: "message message-error", part: "message message-error", key: err.id ?? err.text }, err.text))), screenSuccesses.map((msg) => (index.h("div", { class: "message message-success", part: "message message-success", key: msg.id ?? msg.text }, msg.text))), index.h("form", { onSubmit: this.handleSubmit, part: "form" }, index.h("div", { class: "form-content" }, socialComponents.length > 0 && (index.h("div", { class: "social-section", part: "social-section" }, socialComponents.map((component) => (index.h("authhero-node", { key: component.id, component: component, value: this.formData[component.id], onFieldChange: (e) => this.handleInputChange(e.detail.id, e.detail.value), onButtonClick: (e) => this.handleButtonClick(e.detail), disabled: this.loading }))))), socialComponents.length > 0 && fieldComponents.length > 0 && hasDivider && (index.h("div", { class: "divider", part: "divider" }, index.h("span", { class: "divider-text" }, "Or"))), index.h("div", { class: "fields-section", part: "fields-section" }, fieldComponents.map((component) => (index.h("authhero-node", { key: component.id, component: component, value: this.formData[component.id], onFieldChange: (e) => this.handleInputChange(e.detail.id, e.detail.value), onButtonClick: (e) => this.handleButtonClick(e.detail), disabled: this.loading })))))), this._screen.links && this._screen.links.length > 0 && (index.h("div", { class: "links", part: "links" }, this._screen.links.map((link) => (index.h("span", { class: "link-wrapper", part: "link-wrapper", key: link.id ?? link.href }, link.linkText ? (index.h("span", null, link.text, ' ', index.h("a", { href: link.href, class: "link", part: "link", onClick: (e) => this.handleLinkClick(e, { id: link.id, href: link.href, text: link.linkText || link.text }) }, link.linkText))) : (index.h("a", { href: link.href, class: "link", part: "link", onClick: (e) => this.handleLinkClick(e, { id: link.id, href: link.href, text: link.text }) }, link.text))))))))));
562
626
  }
563
627
  static get watchers() { return {
564
628
  "screen": [{
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-D0xitTOL.js');
3
+ var index = require('./index-Db4bZu99.js');
4
4
  var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
5
 
6
6
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -19,7 +19,7 @@ var patchBrowser = () => {
19
19
 
20
20
  patchBrowser().then(async (options) => {
21
21
  await appGlobals.globalScripts();
22
- return index.bootstrapLazy([["authhero-node.cjs",[[513,"authhero-node",{"component":[16],"value":[1],"disabled":[4]}]]],["authhero-widget.cjs",[[513,"authhero-widget",{"screen":[1],"apiUrl":[1,"api-url"],"branding":[1],"theme":[1],"loading":[1028],"autoSubmit":[4,"auto-submit"],"_screen":[32],"_branding":[32],"_theme":[32],"formData":[32]},null,{"screen":[{"watchScreen":0}],"branding":[{"watchBranding":0}],"theme":[{"watchTheme":0}]}]]]], options);
22
+ return index.bootstrapLazy([["authhero-node.cjs",[[513,"authhero-node",{"component":[16],"value":[1],"disabled":[4],"passwordVisible":[32]}]]],["authhero-widget.cjs",[[513,"authhero-widget",{"screen":[1],"apiUrl":[1,"api-url"],"branding":[1],"theme":[1],"loading":[1028],"autoSubmit":[4,"auto-submit"],"_screen":[32],"_branding":[32],"_theme":[32],"formData":[32]},null,{"screen":[{"watchScreen":0}],"branding":[{"watchBranding":0}],"theme":[{"watchTheme":0}]}]]]], options);
23
23
  });
24
24
 
25
25
  exports.setNonce = index.setNonce;
@@ -252,6 +252,10 @@ var require_brace_expansion = __commonJS({
252
252
  }
253
253
  }
254
254
  });
255
+
256
+ // src/utils/constants.ts
257
+ var SVG_NS = "http://www.w3.org/2000/svg";
258
+ var HTML_NS = "http://www.w3.org/1999/xhtml";
255
259
  var PrimitiveType = /* @__PURE__ */ ((PrimitiveType2) => {
256
260
  PrimitiveType2["Undefined"] = "undefined";
257
261
  PrimitiveType2["Null"] = "null";
@@ -2793,7 +2797,7 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
2793
2797
  }
2794
2798
  } else {
2795
2799
  const isComplex = isComplexType(newValue);
2796
- if ((isProp || isComplex && newValue !== null) && true) {
2800
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
2797
2801
  try {
2798
2802
  if (!elm.tagName.includes("-")) {
2799
2803
  const n = newValue == null ? "" : newValue;
@@ -2890,14 +2894,21 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2890
2894
  if (newVNode2.$text$ !== null) {
2891
2895
  elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
2892
2896
  } else {
2897
+ if (!isSvgMode) {
2898
+ isSvgMode = newVNode2.$tag$ === "svg";
2899
+ }
2893
2900
  if (!win.document) {
2894
2901
  throw new Error(
2895
2902
  "You are trying to render a Stencil component in an environment that doesn't support the DOM. Make sure to populate the [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window/window) object before rendering a component."
2896
2903
  );
2897
2904
  }
2898
- elm = newVNode2.$elm$ = win.document.createElement(
2905
+ elm = newVNode2.$elm$ = win.document.createElementNS(
2906
+ isSvgMode ? SVG_NS : HTML_NS,
2899
2907
  newVNode2.$tag$
2900
- );
2908
+ ) ;
2909
+ if (isSvgMode && newVNode2.$tag$ === "foreignObject") {
2910
+ isSvgMode = false;
2911
+ }
2901
2912
  {
2902
2913
  updateElement(null, newVNode2, isSvgMode);
2903
2914
  }
@@ -2910,6 +2921,13 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2910
2921
  }
2911
2922
  }
2912
2923
  }
2924
+ {
2925
+ if (newVNode2.$tag$ === "svg") {
2926
+ isSvgMode = false;
2927
+ } else if (elm.tagName === "foreignObject") {
2928
+ isSvgMode = true;
2929
+ }
2930
+ }
2913
2931
  }
2914
2932
  elm["s-hn"] = hostTagName;
2915
2933
  return elm;
@@ -3045,8 +3063,12 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
3045
3063
  const elm = newVNode2.$elm$ = oldVNode.$elm$;
3046
3064
  const oldChildren = oldVNode.$children$;
3047
3065
  const newChildren = newVNode2.$children$;
3066
+ const tag = newVNode2.$tag$;
3048
3067
  const text = newVNode2.$text$;
3049
3068
  if (text === null) {
3069
+ {
3070
+ isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
3071
+ }
3050
3072
  {
3051
3073
  updateElement(oldVNode, newVNode2, isSvgMode, isInitialRender);
3052
3074
  }
@@ -3065,6 +3087,9 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
3065
3087
  } else if (isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) {
3066
3088
  newVNode2.$children$ = oldChildren;
3067
3089
  }
3090
+ if (isSvgMode && tag === "svg") {
3091
+ isSvgMode = false;
3092
+ }
3068
3093
  } else if (oldVNode.$text$ !== text) {
3069
3094
  elm.data = text;
3070
3095
  }