@qaiddev/quests-embed 1.4.0 → 1.5.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.
@@ -1,44 +1,44 @@
1
- const L = `*{box-sizing:border-box}button{cursor:pointer;font-family:inherit}:where(.qaid-q-root){--qaid-q-card-bg: light-dark(#ffffff, #1f2937);--qaid-q-card-fg: light-dark(#1f2937, #f9fafb);--qaid-q-card-border: light-dark(#e5e7eb, #374151);--qaid-q-card-radius: 1rem;--qaid-q-card-padding: 1.5rem;--qaid-q-card-shadow: 0 25px 50px -12px light-dark(rgba(0, 0, 0, .25), rgba(0, 0, 0, .6));--qaid-q-muted-fg: light-dark(#6b7280, #9ca3af);--qaid-q-progress-track: light-dark(#e5e7eb, #374151);--qaid-q-btn-radius: .5rem;--qaid-q-btn-padding-y: .625rem;--qaid-q-btn-padding-x: 1.125rem;--qaid-q-btn-font-weight: 500;--qaid-q-btn-primary-bg: var(--qaid-q-accent, #10b981);--qaid-q-btn-primary-fg: var(--qaid-q-accent-text, #ffffff);--qaid-q-btn-primary-border: transparent;--qaid-q-btn-secondary-bg: transparent;--qaid-q-btn-secondary-fg: light-dark(#374151, #d1d5db);--qaid-q-btn-secondary-border: light-dark(#d1d5db, #4b5563);--qaid-q-btn-secondary-hover-bg: light-dark(#f3f4f6, #374151);--qaid-q-option-bg: light-dark(#ffffff, #111827);--qaid-q-option-bg-selected: color-mix(in srgb, var(--qaid-q-accent, #10b981) 10%, transparent);--qaid-q-option-bg-hover: light-dark(#f9fafb, #1f2937);--qaid-q-option-fg: light-dark(#1f2937, #f9fafb);--qaid-q-option-border: light-dark(#e5e7eb, #374151);--qaid-q-option-border-selected: var(--qaid-q-accent, #10b981);--qaid-q-option-border-hover: light-dark(#9ca3af, #4b5563);--qaid-q-option-radius: .625rem;--qaid-q-option-padding: .75rem .875rem;--qaid-q-marker-bg: light-dark(#ffffff, #111827);--qaid-q-marker-bg-selected: var(--qaid-q-accent, #10b981);--qaid-q-marker-border: light-dark(#d1d5db, #4b5563);--qaid-q-marker-icon: light-dark(#ffffff, #1f2937);--qaid-q-marker-radius: 50%;--qaid-q-input-bg: light-dark(#ffffff, #111827);--qaid-q-input-fg: light-dark(#1f2937, #f9fafb);--qaid-q-input-border: light-dark(#d1d5db, #374151);--qaid-q-input-radius: .625rem;--qaid-q-input-padding: .75rem .875rem;--qaid-q-input-placeholder: light-dark(#9ca3af, #6b7280);--qaid-q-gap: .75rem;--qaid-q-section-gap: 1.25rem}:where(.qaid-q-root.qaid-q-theme-light){--qaid-q-card-bg: #ffffff;--qaid-q-card-fg: #1f2937;--qaid-q-card-border: #e5e7eb;--qaid-q-card-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);--qaid-q-muted-fg: #6b7280;--qaid-q-progress-track: #e5e7eb;--qaid-q-btn-secondary-fg: #374151;--qaid-q-btn-secondary-border: #d1d5db;--qaid-q-btn-secondary-hover-bg: #f3f4f6;--qaid-q-option-bg: #ffffff;--qaid-q-option-bg-hover: #f9fafb;--qaid-q-option-fg: #1f2937;--qaid-q-option-border: #e5e7eb;--qaid-q-option-border-hover: #9ca3af;--qaid-q-marker-bg: #ffffff;--qaid-q-marker-border: #d1d5db;--qaid-q-marker-icon: #ffffff;--qaid-q-input-bg: #ffffff;--qaid-q-input-fg: #1f2937;--qaid-q-input-border: #d1d5db;--qaid-q-input-placeholder: #9ca3af}:where(.qaid-q-root.qaid-q-theme-dark){--qaid-q-card-bg: #1f2937;--qaid-q-card-fg: #f9fafb;--qaid-q-card-border: #374151;--qaid-q-card-shadow: 0 25px 50px -12px rgba(0, 0, 0, .6);--qaid-q-muted-fg: #9ca3af;--qaid-q-progress-track: #374151;--qaid-q-btn-secondary-fg: #d1d5db;--qaid-q-btn-secondary-border: #4b5563;--qaid-q-btn-secondary-hover-bg: #374151;--qaid-q-option-bg: #111827;--qaid-q-option-bg-hover: #1f2937;--qaid-q-option-fg: #f9fafb;--qaid-q-option-border: #374151;--qaid-q-option-border-hover: #4b5563;--qaid-q-marker-bg: #111827;--qaid-q-marker-border: #4b5563;--qaid-q-marker-icon: #1f2937;--qaid-q-input-bg: #111827;--qaid-q-input-fg: #f9fafb;--qaid-q-input-border: #374151;--qaid-q-input-placeholder: #6b7280}.qaid-q-root{color-scheme:light dark;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px);color:var(--qaid-q-card-fg)}.qaid-q-root.qaid-q-theme-light{color-scheme:light}.qaid-q-root.qaid-q-theme-dark{color-scheme:dark}.qaid-q-backdrop{position:fixed;inset:0;z-index:45;background:rgba(0,0,0,var(--qaid-backdrop-opacity, .4));animation:qaid-q-fade .18s ease-out}@keyframes qaid-q-fade{0%{opacity:0}to{opacity:1}}.qaid-q-modal{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:50;width:var(--qaid-modal-width, 480px);max-width:calc(100vw - 32px);max-height:calc(100vh - 32px);pointer-events:auto;display:flex;flex-direction:column}.qaid-q-card{background:var(--qaid-q-card-bg);color:var(--qaid-q-card-fg);border-radius:var(--qaid-q-card-radius);box-shadow:var(--qaid-q-card-shadow);padding:var(--qaid-q-card-padding);overflow:hidden;display:flex;flex-direction:column;min-height:0}:where(.qaid-q-root.qaid-q-inline) .qaid-q-card{box-shadow:none;border:1px solid var(--qaid-q-card-border);flex:1;min-height:0}:where(.qaid-q-root.qaid-q-inline){height:100%;display:flex;flex-direction:column;min-height:0}.qaid-q-header{display:flex;align-items:center;justify-content:space-between;gap:.75rem;margin-bottom:1rem}.qaid-q-title{font-size:1.125em;font-weight:700;margin:0;color:var(--qaid-q-card-fg)}.qaid-q-step-counter{font-size:.875em;color:var(--qaid-q-muted-fg);font-variant-numeric:tabular-nums;white-space:nowrap}.qaid-q-close{width:28px;height:28px;padding:0;border:none;border-radius:50%;background:transparent;color:var(--qaid-q-muted-fg);display:inline-flex;align-items:center;justify-content:center;-webkit-appearance:none;appearance:none}.qaid-q-close:hover{background:var(--qaid-q-btn-secondary-hover-bg);color:var(--qaid-q-card-fg)}.qaid-q-close:focus-visible{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 30%,transparent)}.qaid-q-progress{position:relative;height:4px;background:var(--qaid-q-progress-track);border-radius:9999px;overflow:hidden;margin-bottom:var(--qaid-q-section-gap)}.qaid-q-progress--inline{flex:1;min-width:60px;margin-bottom:0}.qaid-q-progress-fill{position:absolute;inset:0 auto 0 0;background:var(--qaid-q-accent, #10b981);border-radius:9999px;transition:width .3s ease;width:0%}.qaid-q-body{flex:1;min-height:0;overflow-y:auto;position:relative}.qaid-q-body[data-qaid-scroll=top]{-webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 2.5rem),transparent 100%);mask-image:linear-gradient(to bottom,#000 calc(100% - 2.5rem),transparent 100%)}.qaid-q-body[data-qaid-scroll=middle]{-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 2rem,#000 calc(100% - 2.5rem),transparent 100%);mask-image:linear-gradient(to bottom,transparent 0,#000 2rem,#000 calc(100% - 2.5rem),transparent 100%)}.qaid-q-body[data-qaid-scroll=bottom]{-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 2rem);mask-image:linear-gradient(to bottom,transparent 0,#000 2rem)}.qaid-q-scroll-cue{position:sticky;bottom:0;left:0;display:flex;justify-content:center;align-items:flex-end;height:1.5rem;margin-top:-1.5rem;pointer-events:none;color:var(--qaid-q-muted-fg)}.qaid-q-scroll-cue[hidden]{display:none}.qaid-q-scroll-cue svg{width:1.125rem;height:1.125rem;animation:qaid-q-nudge 1.6s ease-in-out infinite}@keyframes qaid-q-nudge{0%,to{transform:translateY(-2px);opacity:.55}50%{transform:translateY(2px);opacity:1}}.qaid-q-card[data-qaid-fit=compact] .qaid-q-options--image-vertical{grid-template-columns:repeat(auto-fit,minmax(104px,1fr));gap:.375rem}.qaid-q-card[data-qaid-fit=compact] .qaid-q-options--image-vertical .qaid-q-option{padding:.5rem;gap:.375rem}.qaid-q-card[data-qaid-fit=compact] .qaid-q-options--image-vertical .qaid-q-option-image{max-height:5.5rem;object-fit:contain}.qaid-q-card[data-qaid-fit=compact] .qaid-q-option-desc{font-size:.75em}.qaid-q-card[data-qaid-fit=compact] .qaid-q-step{gap:calc(var(--qaid-q-gap) * .6)}.qaid-q-card[data-qaid-fit=compact] .qaid-q-options--image-horizontal .qaid-q-option-image{width:36px;height:36px}.qaid-q-step{display:flex;flex-direction:column;gap:var(--qaid-q-gap);animation:qaid-q-slide .22s ease-out}@keyframes qaid-q-slide{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.qaid-q-no-motion .qaid-q-step,.qaid-q-no-motion.qaid-q-root{animation:none!important}.qaid-q-label{font-size:1.125em;font-weight:600;margin:0;color:var(--qaid-q-card-fg);line-height:1.35}.qaid-q-label .qaid-q-required{color:var(--qaid-q-error, #ef4444);margin-left:.25rem}.qaid-q-description{font-size:.875em;color:var(--qaid-q-muted-fg);margin:0;line-height:1.4}.qaid-q-error{font-size:.8125em;color:var(--qaid-q-error, #ef4444);margin:0}.qaid-q-error:empty{display:none}.qaid-q-input,.qaid-q-textarea{width:100%;padding:var(--qaid-q-input-padding);border:1px solid var(--qaid-q-input-border);border-radius:var(--qaid-q-input-radius);font-family:inherit;font-size:1em;background:var(--qaid-q-input-bg);color:var(--qaid-q-input-fg);transition:border-color .15s,box-shadow .15s;-webkit-appearance:none;appearance:none}.qaid-q-textarea{min-height:7rem;resize:vertical;font-family:inherit}.qaid-q-input:focus,.qaid-q-textarea:focus{outline:none;border-color:var(--qaid-q-focus, #6366f1);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 20%,transparent)}.qaid-q-input::placeholder,.qaid-q-textarea::placeholder{color:var(--qaid-q-input-placeholder)}.qaid-q-currency{position:relative}.qaid-q-currency-prefix{position:absolute;left:.875rem;top:50%;transform:translateY(-50%);color:var(--qaid-q-muted-fg);font-size:1em;font-weight:500;pointer-events:none}.qaid-q-currency .qaid-q-input{padding-left:2.25rem}.qaid-q-range-wrap{display:flex;flex-direction:column;gap:.5rem;padding:.5rem 0}.qaid-q-range-value{font-size:2em;font-weight:700;text-align:center;font-variant-numeric:tabular-nums;color:var(--qaid-q-accent, #10b981)}.qaid-q-range-value .qaid-q-range-unit{font-size:.5em;font-weight:500;color:var(--qaid-q-muted-fg);margin-left:.25rem}.qaid-q-range{width:100%;-webkit-appearance:none;appearance:none;height:6px;border-radius:9999px;background:var(--qaid-q-progress-track);outline:none}.qaid-q-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:24px;height:24px;border-radius:50%;background:var(--qaid-q-accent, #10b981);border:3px solid var(--qaid-q-card-bg);box-shadow:0 2px 6px #0003;cursor:pointer;transition:transform .1s}.qaid-q-range::-moz-range-thumb{width:24px;height:24px;border-radius:50%;background:var(--qaid-q-accent, #10b981);border:3px solid var(--qaid-q-card-bg);box-shadow:0 2px 6px #0003;cursor:pointer}.qaid-q-range:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 6px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 30%,transparent)}.qaid-q-range:focus-visible::-moz-range-thumb{box-shadow:0 0 0 6px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 30%,transparent)}.qaid-q-range-bounds{display:flex;justify-content:space-between;font-size:.8125em;color:var(--qaid-q-muted-fg);font-variant-numeric:tabular-nums}.qaid-q-options{display:flex;flex-direction:column;gap:.5rem}.qaid-q-option{display:flex;align-items:flex-start;gap:.625rem;padding:var(--qaid-q-option-padding);border:1px solid var(--qaid-q-option-border);border-radius:var(--qaid-q-option-radius);background:var(--qaid-q-option-bg);text-align:left;font-size:1em;color:var(--qaid-q-option-fg);cursor:pointer;transition:border-color .12s,background .12s,box-shadow .12s;-webkit-appearance:none;appearance:none;width:100%}.qaid-q-option:hover{border-color:var(--qaid-q-option-border-hover);background:var(--qaid-q-option-bg-hover)}.qaid-q-option:focus-visible{outline:none;border-color:var(--qaid-q-focus, #6366f1);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 25%,transparent)}.qaid-q-option.qaid-q-selected{border-color:var(--qaid-q-option-border-selected);background:var(--qaid-q-option-bg-selected)}.qaid-q-option-marker{flex-shrink:0;width:1.25rem;height:1.25rem;border:2px solid var(--qaid-q-marker-border);border-radius:var(--qaid-q-marker-radius);display:inline-flex;align-items:center;justify-content:center;margin-top:.125rem;background:var(--qaid-q-marker-bg);transition:border-color .12s,background .12s}.qaid-q-option.qaid-q-multi .qaid-q-option-marker{border-radius:.25rem}.qaid-q-option.qaid-q-selected .qaid-q-option-marker{border-color:var(--qaid-q-marker-bg-selected);background:var(--qaid-q-marker-bg-selected)}.qaid-q-option.qaid-q-selected .qaid-q-option-marker:after{content:"";display:block;width:.5rem;height:.5rem;border-radius:50%;background:var(--qaid-q-marker-icon)}.qaid-q-option.qaid-q-multi.qaid-q-selected .qaid-q-option-marker:after{content:"";display:block;width:70%;height:70%;border-radius:0;background:var(--qaid-q-marker-icon);-webkit-mask-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round' d='M5 12l4 4L19 7'/></svg>");mask-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round' d='M5 12l4 4L19 7'/></svg>");-webkit-mask-size:contain;mask-size:contain;-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;transform:none}.qaid-q-option-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:.125rem}.qaid-q-option-image{display:block;width:48px;height:48px;aspect-ratio:1 / 1;object-fit:cover;border-radius:.375rem;background:var(--qaid-q-progress-track);flex-shrink:0}.qaid-q-options--image-horizontal .qaid-q-option-body{flex-direction:row;align-items:center;gap:.75rem}.qaid-q-options--image-horizontal .qaid-q-option-body>:not(.qaid-q-option-image){flex:1;min-width:0;display:flex;flex-direction:column;gap:.125rem}.qaid-q-options--image-vertical{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:.5rem}.qaid-q-options--image-vertical .qaid-q-option{flex-direction:column;align-items:stretch;text-align:center;padding:.75rem;gap:.5rem}.qaid-q-options--image-vertical .qaid-q-option-body{align-items:center;text-align:center}.qaid-q-options--image-vertical .qaid-q-option-image{width:100%;height:auto;max-width:100%}.qaid-q-options--image-vertical .qaid-q-option-marker{position:absolute;top:.5rem;right:.5rem;margin-top:0}.qaid-q-options--image-vertical .qaid-q-option{position:relative}.qaid-q-options--image-vertical .qaid-q-option-key{position:absolute;top:.5rem;left:.5rem;align-self:auto}.qaid-q-option-label{font-weight:500;line-height:1.3}.qaid-q-option-desc{font-size:.8125em;color:var(--qaid-q-muted-fg);line-height:1.4}.qaid-q-option-key{flex-shrink:0;align-self:center;font-size:.7em;font-weight:600;padding:.125rem .375rem;border-radius:.25rem;background:var(--qaid-q-progress-track);color:var(--qaid-q-muted-fg);font-variant-numeric:tabular-nums}.qaid-q-footer{display:flex;align-items:center;justify-content:space-between;gap:.5rem;margin-top:var(--qaid-q-section-gap)}.qaid-q-footer--inline-progress{justify-content:flex-start;gap:.75rem}.qaid-q-footer-left,.qaid-q-footer-right{display:flex;gap:.5rem}.qaid-q-btn{padding:var(--qaid-q-btn-padding-y) var(--qaid-q-btn-padding-x);border-radius:var(--qaid-q-btn-radius);font-size:var(--qaid-q-btn-font-size, .9375em);font-weight:var(--qaid-q-btn-font-weight);border:1px solid transparent;cursor:pointer;transition:filter .15s,background .15s,color .15s;-webkit-appearance:none;appearance:none}.qaid-q-btn:focus-visible{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 30%,transparent)}.qaid-q-btn-secondary{background:var(--qaid-q-btn-secondary-bg);border-color:var(--qaid-q-btn-secondary-border);color:var(--qaid-q-btn-secondary-fg)}.qaid-q-btn-secondary:hover{background:var(--qaid-q-btn-secondary-hover-bg)}.qaid-q-btn-primary{background:var(--qaid-q-btn-primary-bg);color:var(--qaid-q-btn-primary-fg);border-color:var(--qaid-q-btn-primary-border)}.qaid-q-btn-primary:hover{filter:brightness(.9)}.qaid-q-btn-primary:disabled{opacity:.5;cursor:not-allowed;filter:none}.qaid-q-done{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:.5rem;padding:1.5rem 0;flex:1;min-height:0}.qaid-q-done-icon{width:48px;height:48px;border-radius:50%;background:color-mix(in srgb,var(--qaid-q-accent, #10b981) 18%,transparent);color:var(--qaid-q-accent, #10b981);display:inline-flex;align-items:center;justify-content:center;margin-bottom:.5rem}.qaid-q-done-title{font-size:1.25em;font-weight:700;margin:0}.qaid-q-done-message{color:var(--qaid-q-muted-fg);margin:0}.qaid-q-saving{display:inline-flex;align-items:center;gap:.375rem;font-size:.75em;color:var(--qaid-q-muted-fg);opacity:0;transition:opacity .2s}.qaid-q-saving.qaid-q-visible{opacity:1}.qaid-q-saving-dot{width:6px;height:6px;border-radius:50%;background:var(--qaid-q-accent, #10b981);animation:qaid-q-pulse 1.2s ease-in-out infinite}@keyframes qaid-q-pulse{0%,to{opacity:.3}50%{opacity:1}}:where(.qaid-q-root.qaid-q-unstyled) :where(.qaid-q-card,.qaid-q-header,.qaid-q-title,.qaid-q-description,.qaid-q-step,.qaid-q-label,.qaid-q-options,.qaid-q-option,.qaid-q-option-marker,.qaid-q-option-body,.qaid-q-option-label,.qaid-q-option-desc,.qaid-q-input,.qaid-q-textarea,.qaid-q-currency,.qaid-q-currency-prefix,.qaid-q-range,.qaid-q-range-wrap,.qaid-q-range-value,.qaid-q-btn,.qaid-q-footer,.qaid-q-progress,.qaid-q-progress-fill,.qaid-q-step-counter,.qaid-q-error,.qaid-q-saving,.qaid-q-done,.qaid-q-done-icon,.qaid-q-done-title,.qaid-q-done-message){all:unset;display:revert;box-sizing:border-box}.qaid-q-input:focus-visible,.qaid-q-textarea:focus-visible,.qaid-q-option:focus-visible,.qaid-q-btn:focus-visible,.qaid-q-close:focus-visible,.qaid-q-range:focus-visible{outline:2px solid transparent;outline-offset:2px}@media(prefers-reduced-motion:reduce){.qaid-q-root *,.qaid-q-root *:before,.qaid-q-root *:after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}.qaid-q-range::-webkit-slider-thumb{transition:none!important}.qaid-q-range::-moz-range-thumb{transition:none!important}}@media(forced-colors:active){.qaid-q-input:focus-visible,.qaid-q-textarea:focus-visible,.qaid-q-option:focus-visible,.qaid-q-btn:focus-visible,.qaid-q-close:focus-visible,.qaid-q-range:focus-visible{outline:2px solid Highlight;outline-offset:2px}.qaid-q-card{border:1px solid CanvasText}.qaid-q-input,.qaid-q-textarea,.qaid-q-option{border-color:CanvasText}.qaid-q-option.qaid-q-selected{border-color:Highlight}.qaid-q-option.qaid-q-selected .qaid-q-option-marker{forced-color-adjust:none;background:Highlight;border-color:Highlight}.qaid-q-option.qaid-q-selected .qaid-q-option-marker:after{background:HighlightText}.qaid-q-progress{forced-color-adjust:none;background:Canvas;border:1px solid CanvasText}.qaid-q-progress-fill{forced-color-adjust:none;background:Highlight}}`;
2
- const z = ":where(.qaid-q-root){--qaid-q-card-radius: 0;--qaid-q-card-shadow: none;--qaid-q-btn-radius: 0;--qaid-q-option-radius: 0;--qaid-q-option-bg-selected: transparent;--qaid-q-input-radius: 0}", H = ":where(.qaid-q-root){--qaid-q-card-radius: 1.5rem;--qaid-q-btn-radius: 9999px;--qaid-q-btn-padding-x: 1.5rem;--qaid-q-option-radius: 9999px;--qaid-q-option-padding: .75rem 1.125rem;--qaid-q-input-radius: 9999px;--qaid-q-input-padding: .75rem 1.125rem}", D = ":where(.qaid-q-root){--qaid-q-card-padding: 1rem;--qaid-q-btn-padding-y: .5rem;--qaid-q-btn-padding-x: .875rem;--qaid-q-option-padding: .5rem .625rem;--qaid-q-input-padding: .5rem .625rem;--qaid-q-gap: .5rem;--qaid-q-section-gap: .875rem}", O = {
1
+ const P = `*{box-sizing:border-box}button{cursor:pointer;font-family:inherit}:where(.qaid-q-root){--qaid-q-card-bg: light-dark(#ffffff, #1f2937);--qaid-q-card-fg: light-dark(#1f2937, #f9fafb);--qaid-q-card-border: light-dark(#e5e7eb, #374151);--qaid-q-card-radius: 1rem;--qaid-q-card-padding: 1.5rem;--qaid-q-card-shadow: 0 25px 50px -12px light-dark(rgba(0, 0, 0, .25), rgba(0, 0, 0, .6));--qaid-q-muted-fg: light-dark(#6b7280, #9ca3af);--qaid-q-progress-track: light-dark(#e5e7eb, #374151);--qaid-q-btn-radius: .5rem;--qaid-q-btn-padding-y: .625rem;--qaid-q-btn-padding-x: 1.125rem;--qaid-q-btn-font-weight: 500;--qaid-q-btn-primary-bg: var(--qaid-q-accent, #10b981);--qaid-q-btn-primary-fg: var(--qaid-q-accent-text, #ffffff);--qaid-q-btn-primary-border: transparent;--qaid-q-btn-secondary-bg: transparent;--qaid-q-btn-secondary-fg: light-dark(#374151, #d1d5db);--qaid-q-btn-secondary-border: light-dark(#d1d5db, #4b5563);--qaid-q-btn-secondary-hover-bg: light-dark(#f3f4f6, #374151);--qaid-q-option-bg: light-dark(#ffffff, #111827);--qaid-q-option-bg-selected: color-mix(in srgb, var(--qaid-q-accent, #10b981) 10%, transparent);--qaid-q-option-bg-hover: light-dark(#f9fafb, #1f2937);--qaid-q-option-fg: light-dark(#1f2937, #f9fafb);--qaid-q-option-border: light-dark(#e5e7eb, #374151);--qaid-q-option-border-selected: var(--qaid-q-accent, #10b981);--qaid-q-option-border-hover: light-dark(#9ca3af, #4b5563);--qaid-q-option-radius: .625rem;--qaid-q-option-padding: .75rem .875rem;--qaid-q-marker-bg: light-dark(#ffffff, #111827);--qaid-q-marker-bg-selected: var(--qaid-q-accent, #10b981);--qaid-q-marker-border: light-dark(#d1d5db, #4b5563);--qaid-q-marker-icon: light-dark(#ffffff, #1f2937);--qaid-q-marker-radius: 50%;--qaid-q-input-bg: light-dark(#ffffff, #111827);--qaid-q-input-fg: light-dark(#1f2937, #f9fafb);--qaid-q-input-border: light-dark(#d1d5db, #374151);--qaid-q-input-radius: .625rem;--qaid-q-input-padding: .75rem .875rem;--qaid-q-input-placeholder: light-dark(#9ca3af, #6b7280);--qaid-q-gap: .75rem;--qaid-q-section-gap: 1.25rem}:where(.qaid-q-root.qaid-q-theme-light){--qaid-q-card-bg: #ffffff;--qaid-q-card-fg: #1f2937;--qaid-q-card-border: #e5e7eb;--qaid-q-card-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);--qaid-q-muted-fg: #6b7280;--qaid-q-progress-track: #e5e7eb;--qaid-q-btn-secondary-fg: #374151;--qaid-q-btn-secondary-border: #d1d5db;--qaid-q-btn-secondary-hover-bg: #f3f4f6;--qaid-q-option-bg: #ffffff;--qaid-q-option-bg-hover: #f9fafb;--qaid-q-option-fg: #1f2937;--qaid-q-option-border: #e5e7eb;--qaid-q-option-border-hover: #9ca3af;--qaid-q-marker-bg: #ffffff;--qaid-q-marker-border: #d1d5db;--qaid-q-marker-icon: #ffffff;--qaid-q-input-bg: #ffffff;--qaid-q-input-fg: #1f2937;--qaid-q-input-border: #d1d5db;--qaid-q-input-placeholder: #9ca3af}:where(.qaid-q-root.qaid-q-theme-dark){--qaid-q-card-bg: #1f2937;--qaid-q-card-fg: #f9fafb;--qaid-q-card-border: #374151;--qaid-q-card-shadow: 0 25px 50px -12px rgba(0, 0, 0, .6);--qaid-q-muted-fg: #9ca3af;--qaid-q-progress-track: #374151;--qaid-q-btn-secondary-fg: #d1d5db;--qaid-q-btn-secondary-border: #4b5563;--qaid-q-btn-secondary-hover-bg: #374151;--qaid-q-option-bg: #111827;--qaid-q-option-bg-hover: #1f2937;--qaid-q-option-fg: #f9fafb;--qaid-q-option-border: #374151;--qaid-q-option-border-hover: #4b5563;--qaid-q-marker-bg: #111827;--qaid-q-marker-border: #4b5563;--qaid-q-marker-icon: #1f2937;--qaid-q-input-bg: #111827;--qaid-q-input-fg: #f9fafb;--qaid-q-input-border: #374151;--qaid-q-input-placeholder: #6b7280}.qaid-q-root{color-scheme:light dark;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px);color:var(--qaid-q-card-fg)}.qaid-q-root.qaid-q-theme-light{color-scheme:light}.qaid-q-root.qaid-q-theme-dark{color-scheme:dark}.qaid-q-backdrop{position:fixed;inset:0;z-index:45;background:rgba(0,0,0,var(--qaid-backdrop-opacity, .4));animation:qaid-q-fade .18s ease-out}@keyframes qaid-q-fade{0%{opacity:0}to{opacity:1}}.qaid-q-modal{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:50;width:var(--qaid-modal-width, 480px);max-width:calc(100vw - 32px);max-height:calc(100vh - 32px);pointer-events:auto;display:flex;flex-direction:column}.qaid-q-card{background:var(--qaid-q-card-bg);color:var(--qaid-q-card-fg);border-radius:var(--qaid-q-card-radius);box-shadow:var(--qaid-q-card-shadow);padding:var(--qaid-q-card-padding);overflow:hidden;display:flex;flex-direction:column;min-height:0}:where(.qaid-q-root.qaid-q-inline) .qaid-q-card{box-shadow:none;border:1px solid var(--qaid-q-card-border);flex:1;min-height:0}:where(.qaid-q-root.qaid-q-inline){height:100%;display:flex;flex-direction:column;min-height:0}.qaid-q-header{display:flex;align-items:center;justify-content:space-between;gap:.75rem;margin-bottom:1rem}.qaid-q-title{font-size:1.125em;font-weight:700;margin:0;color:var(--qaid-q-card-fg)}.qaid-q-step-counter{font-size:.875em;color:var(--qaid-q-muted-fg);font-variant-numeric:tabular-nums;white-space:nowrap}.qaid-q-close{width:28px;height:28px;padding:0;border:none;border-radius:50%;background:transparent;color:var(--qaid-q-muted-fg);display:inline-flex;align-items:center;justify-content:center;-webkit-appearance:none;appearance:none}.qaid-q-close:hover{background:var(--qaid-q-btn-secondary-hover-bg);color:var(--qaid-q-card-fg)}.qaid-q-close:focus-visible{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 30%,transparent)}.qaid-q-progress{position:relative;height:4px;background:var(--qaid-q-progress-track);border-radius:9999px;overflow:hidden;margin-bottom:var(--qaid-q-section-gap)}.qaid-q-progress--inline{flex:1;min-width:60px;margin-bottom:0}.qaid-q-progress-fill{position:absolute;inset:0 auto 0 0;background:var(--qaid-q-accent, #10b981);border-radius:9999px;transition:width .3s ease;width:0%}.qaid-q-body{flex:1;min-height:0;overflow-y:auto;position:relative}.qaid-q-body[data-qaid-scroll=top]{-webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 2.5rem),transparent 100%);mask-image:linear-gradient(to bottom,#000 calc(100% - 2.5rem),transparent 100%)}.qaid-q-body[data-qaid-scroll=middle]{-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 2rem,#000 calc(100% - 2.5rem),transparent 100%);mask-image:linear-gradient(to bottom,transparent 0,#000 2rem,#000 calc(100% - 2.5rem),transparent 100%)}.qaid-q-body[data-qaid-scroll=bottom]{-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 2rem);mask-image:linear-gradient(to bottom,transparent 0,#000 2rem)}.qaid-q-scroll-cue{position:sticky;bottom:0;left:0;display:flex;justify-content:center;align-items:flex-end;height:1.5rem;margin-top:-1.5rem;pointer-events:none;color:var(--qaid-q-muted-fg)}.qaid-q-scroll-cue[hidden]{display:none}.qaid-q-scroll-cue svg{width:1.125rem;height:1.125rem;animation:qaid-q-nudge 1.6s ease-in-out infinite}@keyframes qaid-q-nudge{0%,to{transform:translateY(-2px);opacity:.55}50%{transform:translateY(2px);opacity:1}}.qaid-q-card[data-qaid-fit=compact] .qaid-q-options--image-vertical{grid-template-columns:repeat(auto-fit,minmax(104px,1fr));gap:.375rem}.qaid-q-card[data-qaid-fit=compact] .qaid-q-options--image-vertical .qaid-q-option{padding:.5rem;gap:.375rem}.qaid-q-card[data-qaid-fit=compact] .qaid-q-options--image-vertical .qaid-q-option-image{max-height:5.5rem;object-fit:contain}.qaid-q-card[data-qaid-fit=compact] .qaid-q-option-desc{font-size:.75em}.qaid-q-card[data-qaid-fit=compact] .qaid-q-step{gap:calc(var(--qaid-q-gap) * .6)}.qaid-q-card[data-qaid-fit=compact] .qaid-q-options--image-horizontal .qaid-q-option-image{width:36px;height:36px}.qaid-q-step{display:flex;flex-direction:column;gap:var(--qaid-q-gap);animation:qaid-q-slide .22s ease-out}@keyframes qaid-q-slide{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.qaid-q-no-motion .qaid-q-step,.qaid-q-no-motion.qaid-q-root{animation:none!important}.qaid-q-label{font-size:1.125em;font-weight:600;margin:0;color:var(--qaid-q-card-fg);line-height:1.35}.qaid-q-label .qaid-q-required{color:var(--qaid-q-error, #ef4444);margin-left:.25rem}.qaid-q-description{font-size:.875em;color:var(--qaid-q-muted-fg);margin:0;line-height:1.4}.qaid-q-error{font-size:.8125em;color:var(--qaid-q-error, #ef4444);margin:0}.qaid-q-error:empty{display:none}.qaid-q-input,.qaid-q-textarea{width:100%;padding:var(--qaid-q-input-padding);border:1px solid var(--qaid-q-input-border);border-radius:var(--qaid-q-input-radius);font-family:inherit;font-size:1em;background:var(--qaid-q-input-bg);color:var(--qaid-q-input-fg);transition:border-color .15s,box-shadow .15s;-webkit-appearance:none;appearance:none}.qaid-q-textarea{min-height:7rem;resize:vertical;font-family:inherit}.qaid-q-input:focus,.qaid-q-textarea:focus{outline:none;border-color:var(--qaid-q-focus, #6366f1);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 20%,transparent)}.qaid-q-input::placeholder,.qaid-q-textarea::placeholder{color:var(--qaid-q-input-placeholder)}.qaid-q-currency{position:relative}.qaid-q-currency-prefix{position:absolute;left:.875rem;top:50%;transform:translateY(-50%);color:var(--qaid-q-muted-fg);font-size:1em;font-weight:500;pointer-events:none}.qaid-q-currency .qaid-q-input{padding-left:2.25rem}.qaid-q-range-wrap{display:flex;flex-direction:column;gap:.5rem;padding:.5rem 0}.qaid-q-range-value{font-size:2em;font-weight:700;text-align:center;font-variant-numeric:tabular-nums;color:var(--qaid-q-accent, #10b981)}.qaid-q-range-value .qaid-q-range-unit{font-size:.5em;font-weight:500;color:var(--qaid-q-muted-fg);margin-left:.25rem}.qaid-q-range{width:100%;-webkit-appearance:none;appearance:none;height:6px;border-radius:9999px;background:var(--qaid-q-progress-track);outline:none}.qaid-q-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:24px;height:24px;border-radius:50%;background:var(--qaid-q-accent, #10b981);border:3px solid var(--qaid-q-card-bg);box-shadow:0 2px 6px #0003;cursor:pointer;transition:transform .1s}.qaid-q-range::-moz-range-thumb{width:24px;height:24px;border-radius:50%;background:var(--qaid-q-accent, #10b981);border:3px solid var(--qaid-q-card-bg);box-shadow:0 2px 6px #0003;cursor:pointer}.qaid-q-range:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 6px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 30%,transparent)}.qaid-q-range:focus-visible::-moz-range-thumb{box-shadow:0 0 0 6px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 30%,transparent)}.qaid-q-range-bounds{display:flex;justify-content:space-between;font-size:.8125em;color:var(--qaid-q-muted-fg);font-variant-numeric:tabular-nums}.qaid-q-options{display:flex;flex-direction:column;gap:.5rem}.qaid-q-option{display:flex;align-items:flex-start;gap:.625rem;padding:var(--qaid-q-option-padding);border:1px solid var(--qaid-q-option-border);border-radius:var(--qaid-q-option-radius);background:var(--qaid-q-option-bg);text-align:left;font-size:1em;color:var(--qaid-q-option-fg);cursor:pointer;transition:border-color .12s,background .12s,box-shadow .12s;-webkit-appearance:none;appearance:none;width:100%}.qaid-q-option:hover{border-color:var(--qaid-q-option-border-hover);background:var(--qaid-q-option-bg-hover)}.qaid-q-option:focus-visible{outline:none;border-color:var(--qaid-q-focus, #6366f1);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 25%,transparent)}.qaid-q-option.qaid-q-selected{border-color:var(--qaid-q-option-border-selected);background:var(--qaid-q-option-bg-selected)}.qaid-q-option-marker{flex-shrink:0;width:1.25rem;height:1.25rem;border:2px solid var(--qaid-q-marker-border);border-radius:var(--qaid-q-marker-radius);display:inline-flex;align-items:center;justify-content:center;margin-top:.125rem;background:var(--qaid-q-marker-bg);transition:border-color .12s,background .12s}.qaid-q-option.qaid-q-multi .qaid-q-option-marker{border-radius:.25rem}.qaid-q-option.qaid-q-selected .qaid-q-option-marker{border-color:var(--qaid-q-marker-bg-selected);background:var(--qaid-q-marker-bg-selected)}.qaid-q-option.qaid-q-selected .qaid-q-option-marker:after{content:"";display:block;width:.5rem;height:.5rem;border-radius:50%;background:var(--qaid-q-marker-icon)}.qaid-q-option.qaid-q-multi.qaid-q-selected .qaid-q-option-marker:after{content:"";display:block;width:70%;height:70%;border-radius:0;background:var(--qaid-q-marker-icon);-webkit-mask-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round' d='M5 12l4 4L19 7'/></svg>");mask-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round' d='M5 12l4 4L19 7'/></svg>");-webkit-mask-size:contain;mask-size:contain;-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;transform:none}.qaid-q-option-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:.125rem}.qaid-q-option-image{display:block;width:48px;height:48px;aspect-ratio:1 / 1;object-fit:cover;border-radius:.375rem;background:var(--qaid-q-progress-track);flex-shrink:0}.qaid-q-options--image-horizontal .qaid-q-option-body{flex-direction:row;align-items:center;gap:.75rem}.qaid-q-options--image-horizontal .qaid-q-option-body>:not(.qaid-q-option-image){flex:1;min-width:0;display:flex;flex-direction:column;gap:.125rem}.qaid-q-options--image-vertical{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:.5rem}.qaid-q-options--image-vertical .qaid-q-option{flex-direction:column;align-items:stretch;text-align:center;padding:.75rem;gap:.5rem}.qaid-q-options--image-vertical .qaid-q-option-body{align-items:center;text-align:center}.qaid-q-options--image-vertical .qaid-q-option-image{width:100%;height:auto;max-width:100%}.qaid-q-options--image-vertical .qaid-q-option-marker{position:absolute;top:.5rem;right:.5rem;margin-top:0}.qaid-q-options--image-vertical .qaid-q-option{position:relative}.qaid-q-options--image-vertical .qaid-q-option-key{position:absolute;top:.5rem;left:.5rem;align-self:auto}.qaid-q-option-label{font-weight:500;line-height:1.3}.qaid-q-option-desc{font-size:.8125em;color:var(--qaid-q-muted-fg);line-height:1.4}.qaid-q-option-key{flex-shrink:0;align-self:center;font-size:.7em;font-weight:600;padding:.125rem .375rem;border-radius:.25rem;background:var(--qaid-q-progress-track);color:var(--qaid-q-muted-fg);font-variant-numeric:tabular-nums}.qaid-q-footer{display:flex;align-items:center;justify-content:space-between;gap:.5rem;margin-top:var(--qaid-q-section-gap)}.qaid-q-footer--inline-progress{justify-content:flex-start;gap:.75rem}.qaid-q-footer-left,.qaid-q-footer-right{display:flex;gap:.5rem}.qaid-q-btn{padding:var(--qaid-q-btn-padding-y) var(--qaid-q-btn-padding-x);border-radius:var(--qaid-q-btn-radius);font-size:var(--qaid-q-btn-font-size, .9375em);font-weight:var(--qaid-q-btn-font-weight);border:1px solid transparent;cursor:pointer;transition:filter .15s,background .15s,color .15s;-webkit-appearance:none;appearance:none}.qaid-q-btn:focus-visible{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-q-focus, #6366f1) 30%,transparent)}.qaid-q-btn-secondary{background:var(--qaid-q-btn-secondary-bg);border-color:var(--qaid-q-btn-secondary-border);color:var(--qaid-q-btn-secondary-fg)}.qaid-q-btn-secondary:hover{background:var(--qaid-q-btn-secondary-hover-bg)}.qaid-q-btn-primary{background:var(--qaid-q-btn-primary-bg);color:var(--qaid-q-btn-primary-fg);border-color:var(--qaid-q-btn-primary-border)}.qaid-q-btn-primary:hover{filter:brightness(.9)}.qaid-q-btn-primary:disabled{opacity:.5;cursor:not-allowed;filter:none}.qaid-q-done{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:.5rem;padding:1.5rem 0;flex:1;min-height:0}.qaid-q-done-icon{width:48px;height:48px;border-radius:50%;background:color-mix(in srgb,var(--qaid-q-accent, #10b981) 18%,transparent);color:var(--qaid-q-accent, #10b981);display:inline-flex;align-items:center;justify-content:center;margin-bottom:.5rem}.qaid-q-done-title{font-size:1.25em;font-weight:700;margin:0}.qaid-q-done-message{color:var(--qaid-q-muted-fg);margin:0}.qaid-q-submit-error{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:.5rem;padding:1.5rem 0;flex:1;min-height:0}.qaid-q-submit-error-title{font-size:1.25em;font-weight:700;margin:0}.qaid-q-submit-error-message{color:var(--qaid-q-muted-fg);margin:0}.qaid-q-submit-error-actions{display:flex;justify-content:center;gap:.5rem;margin-top:1rem}.qaid-q-saving{display:inline-flex;align-items:center;gap:.375rem;font-size:.75em;color:var(--qaid-q-muted-fg);opacity:0;transition:opacity .2s}.qaid-q-saving.qaid-q-visible{opacity:1}.qaid-q-saving-dot{width:6px;height:6px;border-radius:50%;background:var(--qaid-q-accent, #10b981);animation:qaid-q-pulse 1.2s ease-in-out infinite}@keyframes qaid-q-pulse{0%,to{opacity:.3}50%{opacity:1}}:where(.qaid-q-root.qaid-q-unstyled) :where(.qaid-q-card,.qaid-q-header,.qaid-q-title,.qaid-q-description,.qaid-q-step,.qaid-q-label,.qaid-q-options,.qaid-q-option,.qaid-q-option-marker,.qaid-q-option-body,.qaid-q-option-label,.qaid-q-option-desc,.qaid-q-input,.qaid-q-textarea,.qaid-q-currency,.qaid-q-currency-prefix,.qaid-q-range,.qaid-q-range-wrap,.qaid-q-range-value,.qaid-q-btn,.qaid-q-footer,.qaid-q-progress,.qaid-q-progress-fill,.qaid-q-step-counter,.qaid-q-error,.qaid-q-saving,.qaid-q-done,.qaid-q-done-icon,.qaid-q-done-title,.qaid-q-done-message,.qaid-q-submit-error,.qaid-q-submit-error-title,.qaid-q-submit-error-message,.qaid-q-submit-error-actions){all:unset;display:revert;box-sizing:border-box}.qaid-q-input:focus-visible,.qaid-q-textarea:focus-visible,.qaid-q-option:focus-visible,.qaid-q-btn:focus-visible,.qaid-q-close:focus-visible,.qaid-q-range:focus-visible{outline:2px solid transparent;outline-offset:2px}@media(prefers-reduced-motion:reduce){.qaid-q-root *,.qaid-q-root *:before,.qaid-q-root *:after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}.qaid-q-range::-webkit-slider-thumb{transition:none!important}.qaid-q-range::-moz-range-thumb{transition:none!important}}@media(forced-colors:active){.qaid-q-input:focus-visible,.qaid-q-textarea:focus-visible,.qaid-q-option:focus-visible,.qaid-q-btn:focus-visible,.qaid-q-close:focus-visible,.qaid-q-range:focus-visible{outline:2px solid Highlight;outline-offset:2px}.qaid-q-card{border:1px solid CanvasText}.qaid-q-input,.qaid-q-textarea,.qaid-q-option{border-color:CanvasText}.qaid-q-option.qaid-q-selected{border-color:Highlight}.qaid-q-option.qaid-q-selected .qaid-q-option-marker{forced-color-adjust:none;background:Highlight;border-color:Highlight}.qaid-q-option.qaid-q-selected .qaid-q-option-marker:after{background:HighlightText}.qaid-q-progress{forced-color-adjust:none;background:Canvas;border:1px solid CanvasText}.qaid-q-progress-fill{forced-color-adjust:none;background:Highlight}}`;
2
+ const z = ":where(.qaid-q-root){--qaid-q-card-radius: 0;--qaid-q-card-shadow: none;--qaid-q-btn-radius: 0;--qaid-q-option-radius: 0;--qaid-q-option-bg-selected: transparent;--qaid-q-input-radius: 0}", D = ":where(.qaid-q-root){--qaid-q-card-radius: 1.5rem;--qaid-q-btn-radius: 9999px;--qaid-q-btn-padding-x: 1.5rem;--qaid-q-option-radius: 9999px;--qaid-q-option-padding: .75rem 1.125rem;--qaid-q-input-radius: 9999px;--qaid-q-input-padding: .75rem 1.125rem}", V = ":where(.qaid-q-root){--qaid-q-card-padding: 1rem;--qaid-q-btn-padding-y: .5rem;--qaid-q-btn-padding-x: .875rem;--qaid-q-option-padding: .5rem .625rem;--qaid-q-input-padding: .5rem .625rem;--qaid-q-gap: .5rem;--qaid-q-section-gap: .875rem}", H = {
3
3
  default: "",
4
4
  minimal: z,
5
- pill: H,
6
- dense: D
5
+ pill: D,
6
+ dense: V
7
7
  };
8
- function V(t) {
9
- return O[t] ?? "";
8
+ function R(t) {
9
+ return H[t] ?? "";
10
10
  }
11
- function R(t, e, i) {
12
- const [a, n, o] = [t, e, i].map((r) => (r = r / 255, r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4)));
13
- return 0.2126 * a + 0.7152 * n + 0.0722 * o;
11
+ function j(t, e, i) {
12
+ const [a, n, r] = [t, e, i].map((s) => (s = s / 255, s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4)));
13
+ return 0.2126 * a + 0.7152 * n + 0.0722 * r;
14
14
  }
15
- function P(t) {
15
+ function U(t) {
16
16
  if (t.startsWith("#")) {
17
- const i = t.slice(1), a = i.length === 3 ? i.split("").map((o) => o + o).join("") : i, n = parseInt(a, 16);
17
+ const i = t.slice(1), a = i.length === 3 ? i.split("").map((r) => r + r).join("") : i, n = parseInt(a, 16);
18
18
  return { r: n >> 16 & 255, g: n >> 8 & 255, b: n & 255 };
19
19
  }
20
20
  const e = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
21
21
  return e ? { r: parseInt(e[1]), g: parseInt(e[2]), b: parseInt(e[3]) } : null;
22
22
  }
23
23
  function k(t) {
24
- const e = P(t);
25
- return e && R(e.r, e.g, e.b) > 0.4 ? "black" : "white";
24
+ const e = U(t);
25
+ return e && j(e.r, e.g, e.b) > 0.4 ? "black" : "white";
26
26
  }
27
- function j(t = {}) {
27
+ function $(t = {}) {
28
28
  const e = {};
29
29
  return t.accentColor !== void 0 && (e["--qaid-q-accent"] = t.accentColor, e["--qaid-q-accent-text"] = k(t.accentColor)), t.errorColor !== void 0 && (e["--qaid-q-error"] = t.errorColor), t.focusColor !== void 0 && (e["--qaid-q-focus"] = t.focusColor, e["--qaid-q-focus-text"] = k(t.focusColor)), t.modalWidth !== void 0 && (e["--qaid-modal-width"] = `${t.modalWidth}px`), t.backdropOpacity !== void 0 && (e["--qaid-backdrop-opacity"] = String(t.backdropOpacity)), t.fontFamily !== void 0 && (e["--qaid-font-family"] = t.fontFamily), t.fontSize !== void 0 && (e["--qaid-font-size"] = `${t.fontSize}px`), e;
30
30
  }
31
- function U(t, e) {
31
+ function F(t, e) {
32
32
  for (const [i, a] of Object.entries(e))
33
33
  t.style.setProperty(i, a);
34
34
  }
35
- function F() {
36
- return L;
35
+ function M() {
36
+ return P;
37
37
  }
38
- function M(t) {
39
- return V(t);
38
+ function Q(t) {
39
+ return R(t);
40
40
  }
41
- function b(t) {
41
+ function y(t) {
42
42
  let e = null;
43
43
  return {
44
44
  setInvalid(i) {
@@ -54,21 +54,21 @@ function b(t) {
54
54
  }
55
55
  };
56
56
  }
57
- function $(t) {
57
+ function K(t) {
58
58
  switch (t.question.type) {
59
59
  case "text":
60
- return Q(t.question, t);
61
- case "currency":
62
60
  return B(t.question, t);
63
- case "range":
61
+ case "currency":
64
62
  return _(t.question, t);
63
+ case "range":
64
+ return G(t.question, t);
65
65
  case "date":
66
- return W(t.question, t);
66
+ return J(t.question, t);
67
67
  case "multiple-choice":
68
- return G(t.question, t);
68
+ return X(t.question, t);
69
69
  }
70
70
  }
71
- function Q(t, e) {
71
+ function B(t, e) {
72
72
  const i = typeof e.initialValue == "string" ? e.initialValue : "";
73
73
  let a;
74
74
  if (t.multiline) {
@@ -76,7 +76,7 @@ function Q(t, e) {
76
76
  n.className = "qaid-q-textarea", n.value = i, t.placeholder && (n.placeholder = t.placeholder), t.maxLength && (n.maxLength = t.maxLength), a = n;
77
77
  } else {
78
78
  const n = document.createElement("input");
79
- n.className = "qaid-q-input", n.type = t.inputType ?? "text", n.value = i, t.placeholder && (n.placeholder = t.placeholder), t.maxLength && (n.maxLength = t.maxLength), n.setAttribute("autocomplete", K(t.inputType)), a = n;
79
+ n.className = "qaid-q-input", n.type = t.inputType ?? "text", n.value = i, t.placeholder && (n.placeholder = t.placeholder), t.maxLength && (n.maxLength = t.maxLength), n.setAttribute("autocomplete", Y(t.inputType)), a = n;
80
80
  }
81
81
  return a.setAttribute("aria-label", t.label), t.required && a.setAttribute("aria-required", "true"), a.addEventListener("input", () => {
82
82
  e.onChange(a.value);
@@ -104,10 +104,10 @@ function Q(t, e) {
104
104
  const n = a.value.trim();
105
105
  return !(n.length === 0 || t.minLength && n.length < t.minLength);
106
106
  },
107
- ...b(a)
107
+ ...y(a)
108
108
  };
109
109
  }
110
- function K(t) {
110
+ function Y(t) {
111
111
  switch (t) {
112
112
  case "email":
113
113
  return "email";
@@ -119,83 +119,83 @@ function K(t) {
119
119
  return "off";
120
120
  }
121
121
  }
122
- function B(t, e) {
122
+ function _(t, e) {
123
123
  const i = document.createElement("div");
124
124
  i.className = "qaid-q-currency";
125
125
  const a = document.createElement("span");
126
- a.className = "qaid-q-currency-prefix", a.textContent = Y(t.currency ?? "USD", t.locale), i.appendChild(a);
126
+ a.className = "qaid-q-currency-prefix", a.textContent = W(t.currency ?? "USD", t.locale), i.appendChild(a);
127
127
  const n = document.createElement("input");
128
128
  return n.className = "qaid-q-input", n.type = "number", n.inputMode = "decimal", n.step = "0.01", typeof t.min == "number" && (n.min = String(t.min)), typeof t.max == "number" && (n.max = String(t.max)), t.placeholder && (n.placeholder = t.placeholder), typeof e.initialValue == "number" ? n.value = String(e.initialValue) : typeof e.initialValue == "string" && e.initialValue !== "" && (n.value = e.initialValue), n.setAttribute("aria-label", t.label), t.required && n.setAttribute("aria-required", "true"), n.addEventListener("input", () => {
129
- const o = n.value;
130
- if (o === "")
129
+ const r = n.value;
130
+ if (r === "")
131
131
  e.onChange(null);
132
132
  else {
133
- const r = Number(o);
134
- e.onChange(Number.isNaN(r) ? null : r);
133
+ const s = Number(r);
134
+ e.onChange(Number.isNaN(s) ? null : s);
135
135
  }
136
- }), n.addEventListener("keydown", (o) => {
137
- o.key === "Enter" && !o.isComposing && (o.preventDefault(), e.onSubmit());
136
+ }), n.addEventListener("keydown", (r) => {
137
+ r.key === "Enter" && !r.isComposing && (r.preventDefault(), e.onSubmit());
138
138
  }), i.appendChild(n), {
139
139
  element: i,
140
140
  focus: () => n.focus(),
141
141
  getValue: () => {
142
142
  if (n.value === "") return null;
143
- const o = Number(n.value);
144
- return Number.isNaN(o) ? null : o;
143
+ const r = Number(n.value);
144
+ return Number.isNaN(r) ? null : r;
145
145
  },
146
146
  isValid: () => {
147
- const o = n.value === "" ? null : Number(n.value);
148
- return !(t.required && (o === null || Number.isNaN(o)) || o !== null && !Number.isNaN(o) && (typeof t.min == "number" && o < t.min || typeof t.max == "number" && o > t.max));
147
+ const r = n.value === "" ? null : Number(n.value);
148
+ return !(t.required && (r === null || Number.isNaN(r)) || r !== null && !Number.isNaN(r) && (typeof t.min == "number" && r < t.min || typeof t.max == "number" && r > t.max));
149
149
  },
150
- ...b(n)
150
+ ...y(n)
151
151
  };
152
152
  }
153
- function Y(t, e) {
153
+ function W(t, e) {
154
154
  try {
155
155
  return new Intl.NumberFormat(e, {
156
156
  style: "currency",
157
157
  currency: t,
158
158
  currencyDisplay: "narrowSymbol",
159
159
  maximumFractionDigits: 0
160
- }).formatToParts(0).find((o) => o.type === "currency")?.value ?? t;
160
+ }).formatToParts(0).find((r) => r.type === "currency")?.value ?? t;
161
161
  } catch {
162
162
  return t;
163
163
  }
164
164
  }
165
- function _(t, e) {
165
+ function G(t, e) {
166
166
  const i = document.createElement("div");
167
167
  i.className = "qaid-q-range-wrap";
168
168
  const a = document.createElement("div");
169
169
  a.className = "qaid-q-range-value";
170
170
  const n = document.createElement("span");
171
171
  if (a.appendChild(n), t.unit) {
172
- const s = document.createElement("span");
173
- s.className = "qaid-q-range-unit", s.textContent = t.unit, a.appendChild(s);
172
+ const l = document.createElement("span");
173
+ l.className = "qaid-q-range-unit", l.textContent = t.unit, a.appendChild(l);
174
174
  }
175
- const o = typeof e.initialValue == "number" ? e.initialValue : t.defaultValue ?? t.min, r = document.createElement("input");
176
- r.className = "qaid-q-range", r.type = "range", r.min = String(t.min), r.max = String(t.max), r.step = String(t.step ?? 1), r.value = String(o), r.setAttribute("aria-label", t.label), r.setAttribute("aria-valuemin", String(t.min)), r.setAttribute("aria-valuemax", String(t.max));
177
- const c = () => {
178
- n.textContent = r.value, r.setAttribute("aria-valuenow", r.value);
175
+ const r = typeof e.initialValue == "number" ? e.initialValue : t.defaultValue ?? t.min, s = document.createElement("input");
176
+ s.className = "qaid-q-range", s.type = "range", s.min = String(t.min), s.max = String(t.max), s.step = String(t.step ?? 1), s.value = String(r), s.setAttribute("aria-label", t.label), s.setAttribute("aria-valuemin", String(t.min)), s.setAttribute("aria-valuemax", String(t.max));
177
+ const o = () => {
178
+ n.textContent = s.value, s.setAttribute("aria-valuenow", s.value);
179
179
  };
180
- c(), r.addEventListener("input", () => {
181
- c(), e.onChange(Number(r.value));
182
- }), r.addEventListener("keydown", (s) => {
183
- s.key === "Enter" && (s.preventDefault(), e.onSubmit());
180
+ o(), s.addEventListener("input", () => {
181
+ o(), e.onChange(Number(s.value));
182
+ }), s.addEventListener("keydown", (l) => {
183
+ l.key === "Enter" && (l.preventDefault(), e.onSubmit());
184
184
  });
185
- const q = document.createElement("div");
186
- q.className = "qaid-q-range-bounds";
187
- const p = document.createElement("span");
188
- p.textContent = `${t.min}${t.unit ?? ""}`;
189
- const f = document.createElement("span");
190
- return f.textContent = `${t.max}${t.unit ?? ""}`, q.appendChild(p), q.appendChild(f), i.appendChild(a), i.appendChild(r), i.appendChild(q), queueMicrotask(() => e.onChange(Number(r.value))), {
185
+ const u = document.createElement("div");
186
+ u.className = "qaid-q-range-bounds";
187
+ const q = document.createElement("span");
188
+ q.textContent = `${t.min}${t.unit ?? ""}`;
189
+ const m = document.createElement("span");
190
+ return m.textContent = `${t.max}${t.unit ?? ""}`, u.appendChild(q), u.appendChild(m), i.appendChild(a), i.appendChild(s), i.appendChild(u), queueMicrotask(() => e.onChange(Number(s.value))), {
191
191
  element: i,
192
- focus: () => r.focus(),
193
- getValue: () => Number(r.value),
192
+ focus: () => s.focus(),
193
+ getValue: () => Number(s.value),
194
194
  isValid: () => !0,
195
- ...b(r)
195
+ ...y(s)
196
196
  };
197
197
  }
198
- function W(t, e) {
198
+ function J(t, e) {
199
199
  const i = document.createElement("input");
200
200
  return i.className = "qaid-q-input", i.type = "date", t.min && (i.min = t.min), t.max && (i.max = t.max), typeof e.initialValue == "string" && (i.value = e.initialValue), i.setAttribute("aria-label", t.label), t.required && i.setAttribute("aria-required", "true"), i.addEventListener("input", () => {
201
201
  e.onChange(i.value || null);
@@ -206,121 +206,128 @@ function W(t, e) {
206
206
  focus: () => i.focus(),
207
207
  getValue: () => i.value || null,
208
208
  isValid: () => t.required ? i.value !== "" : !0,
209
- ...b(i)
209
+ ...y(i)
210
210
  };
211
211
  }
212
- function G(t, e) {
213
- const i = document.createElement("div"), a = t.imageAlignment ?? "horizontal", o = t.options.some((s) => !!s.image) ? a === "vertical" ? " qaid-q-options--image-vertical" : " qaid-q-options--image-horizontal" : "";
214
- i.className = `qaid-q-options${o}`, i.setAttribute("role", t.multiple ? "group" : "radiogroup"), i.setAttribute("aria-label", t.label), t.required && i.setAttribute("aria-required", "true");
215
- const r = /* @__PURE__ */ new Set();
212
+ function X(t, e) {
213
+ const i = document.createElement("div"), a = t.imageAlignment ?? "horizontal", r = t.options.some((l) => !!l.image) ? a === "vertical" ? " qaid-q-options--image-vertical" : " qaid-q-options--image-horizontal" : "";
214
+ i.className = `qaid-q-options${r}`, i.setAttribute("role", t.multiple ? "group" : "radiogroup"), i.setAttribute("aria-label", t.label), t.required && i.setAttribute("aria-required", "true");
215
+ const s = /* @__PURE__ */ new Set();
216
216
  if (t.multiple && Array.isArray(e.initialValue))
217
- for (const s of e.initialValue) r.add(s);
218
- else !t.multiple && typeof e.initialValue == "string" && r.add(e.initialValue);
219
- const c = [];
220
- t.options.forEach((s, u) => {
221
- const d = document.createElement("button");
222
- d.type = "button", d.className = `qaid-q-option${t.multiple ? " qaid-q-multi" : ""}`, d.dataset.value = s.value, d.setAttribute("role", t.multiple ? "checkbox" : "radio"), d.setAttribute("aria-checked", r.has(s.value) ? "true" : "false"), r.has(s.value) && d.classList.add("qaid-q-selected");
223
- const m = document.createElement("span");
224
- m.className = "qaid-q-option-marker", m.setAttribute("aria-hidden", "true");
225
- const g = document.createElement("span");
226
- if (g.className = "qaid-q-option-body", s.image) {
227
- const l = document.createElement("img");
228
- l.className = "qaid-q-option-image", l.src = s.image, l.alt = "", l.loading = "lazy", l.decoding = "async", g.appendChild(l);
217
+ for (const l of e.initialValue) s.add(l);
218
+ else !t.multiple && typeof e.initialValue == "string" && s.add(e.initialValue);
219
+ const o = [];
220
+ t.options.forEach((l, h) => {
221
+ const c = document.createElement("button");
222
+ c.type = "button", c.className = `qaid-q-option${t.multiple ? " qaid-q-multi" : ""}`, c.dataset.value = l.value, c.setAttribute("role", t.multiple ? "checkbox" : "radio"), c.setAttribute("aria-checked", s.has(l.value) ? "true" : "false"), s.has(l.value) && c.classList.add("qaid-q-selected");
223
+ const p = document.createElement("span");
224
+ p.className = "qaid-q-option-marker", p.setAttribute("aria-hidden", "true");
225
+ const f = document.createElement("span");
226
+ if (f.className = "qaid-q-option-body", l.image) {
227
+ const d = document.createElement("img");
228
+ d.className = "qaid-q-option-image", d.src = l.image, d.alt = "", d.loading = "lazy", d.decoding = "async", f.appendChild(d);
229
229
  }
230
- const h = document.createElement("span");
231
- if (h.className = "qaid-q-option-label", h.textContent = s.label, g.appendChild(h), s.description) {
232
- const l = document.createElement("span");
233
- l.className = "qaid-q-option-desc", l.textContent = s.description, g.appendChild(l);
230
+ const g = document.createElement("span");
231
+ if (g.className = "qaid-q-option-label", g.textContent = l.label, f.appendChild(g), l.description) {
232
+ const d = document.createElement("span");
233
+ d.className = "qaid-q-option-desc", d.textContent = l.description, f.appendChild(d);
234
234
  }
235
- if (d.appendChild(m), d.appendChild(g), u < 9) {
236
- const l = document.createElement("span");
237
- l.className = "qaid-q-option-key", l.textContent = String(u + 1), l.setAttribute("aria-hidden", "true"), d.appendChild(l);
235
+ if (c.appendChild(p), c.appendChild(f), h < 9) {
236
+ const d = document.createElement("span");
237
+ d.className = "qaid-q-option-key", d.textContent = String(h + 1), d.setAttribute("aria-hidden", "true"), c.appendChild(d);
238
238
  }
239
- d.addEventListener("click", () => p(u)), d.addEventListener("keydown", (l) => {
240
- if (l.key === "ArrowDown" || l.key === "ArrowRight") {
241
- l.preventDefault(), q((u + 1) % c.length);
239
+ c.addEventListener("click", () => q(h)), c.addEventListener("keydown", (d) => {
240
+ if (d.key === "ArrowDown" || d.key === "ArrowRight") {
241
+ d.preventDefault(), u((h + 1) % o.length);
242
242
  return;
243
243
  }
244
- if (l.key === "ArrowUp" || l.key === "ArrowLeft") {
245
- l.preventDefault(), q((u - 1 + c.length) % c.length);
244
+ if (d.key === "ArrowUp" || d.key === "ArrowLeft") {
245
+ d.preventDefault(), u((h - 1 + o.length) % o.length);
246
246
  return;
247
247
  }
248
- !t.multiple && l.key === "Enter" && r.size > 0 && (l.preventDefault(), e.onSubmit());
249
- }), c.push(d), i.appendChild(d);
250
- }), i.addEventListener("keydown", (s) => {
251
- const u = s.key;
252
- if (u.length === 1 && u >= "1" && u <= "9") {
253
- const d = parseInt(u, 10) - 1;
254
- d < c.length && (s.preventDefault(), p(d), q(d));
248
+ !t.multiple && d.key === "Enter" && s.size > 0 && (d.preventDefault(), e.onSubmit());
249
+ }), o.push(c), i.appendChild(c);
250
+ }), i.addEventListener("keydown", (l) => {
251
+ const h = l.key;
252
+ if (h.length === 1 && h >= "1" && h <= "9") {
253
+ const c = parseInt(h, 10) - 1;
254
+ c < o.length && (l.preventDefault(), q(c), u(c));
255
255
  }
256
256
  });
257
- function q(s) {
258
- c[s]?.focus();
257
+ function u(l) {
258
+ o[l]?.focus();
259
259
  }
260
- function p(s) {
261
- const u = t.options[s].value;
262
- t.multiple ? r.has(u) ? r.delete(u) : r.add(u) : (r.clear(), r.add(u)), c.forEach((d) => {
263
- const m = d.dataset.value, g = r.has(m);
264
- d.classList.toggle("qaid-q-selected", g), d.setAttribute("aria-checked", g ? "true" : "false");
265
- }), e.onChange(f()), !t.multiple && e.autoAdvance && setTimeout(() => e.onAutoAdvance(), 180);
260
+ function q(l) {
261
+ const h = t.options[l].value;
262
+ t.multiple ? s.has(h) ? s.delete(h) : s.add(h) : (s.clear(), s.add(h)), o.forEach((c) => {
263
+ const p = c.dataset.value, f = s.has(p);
264
+ c.classList.toggle("qaid-q-selected", f), c.setAttribute("aria-checked", f ? "true" : "false");
265
+ }), e.onChange(m()), !t.multiple && e.autoAdvance && setTimeout(() => e.onAutoAdvance(), 180);
266
266
  }
267
- function f() {
268
- if (t.multiple) return Array.from(r);
269
- const s = r.values().next();
270
- return s.done ? null : s.value;
267
+ function m() {
268
+ if (t.multiple) return Array.from(s);
269
+ const l = s.values().next();
270
+ return l.done ? null : l.value;
271
271
  }
272
272
  return {
273
273
  element: i,
274
274
  focus: () => {
275
- (c.find((u) => u.classList.contains("qaid-q-selected")) ?? c[0])?.focus();
275
+ (o.find((h) => h.classList.contains("qaid-q-selected")) ?? o[0])?.focus();
276
276
  },
277
- getValue: () => f(),
278
- isValid: () => t.required ? r.size > 0 : !0,
279
- ...b(i)
277
+ getValue: () => m(),
278
+ isValid: () => t.required ? s.size > 0 : !0,
279
+ ...y(i)
280
280
  };
281
281
  }
282
- function J(t, e) {
283
- return t.questions.filter(
284
- (i) => i.visibleIf ? E(i.visibleIf, e) : !0
285
- );
282
+ function w(t, e) {
283
+ const i = /* @__PURE__ */ Object.create(null), a = [];
284
+ for (const n of t.questions)
285
+ n.visibleIf && !C(n.visibleIf, i) || (a.push(n), Object.prototype.hasOwnProperty.call(e, n.id) && (i[n.id] = e[n.id]));
286
+ return a;
287
+ }
288
+ function Z(t, e) {
289
+ const i = {};
290
+ for (const a of w(t, e))
291
+ Object.prototype.hasOwnProperty.call(e, a.id) && (i[a.id] = e[a.id]);
292
+ return i;
286
293
  }
287
- function E(t, e) {
294
+ function C(t, e) {
288
295
  if ("allOf" in t) {
289
296
  for (const n of t.allOf)
290
- if (!E(n, e)) return !1;
297
+ if (!C(n, e)) return !1;
291
298
  return !0;
292
299
  }
293
300
  if ("anyOf" in t) {
294
301
  for (const n of t.anyOf)
295
- if (E(n, e)) return !0;
302
+ if (C(n, e)) return !0;
296
303
  return !1;
297
304
  }
298
305
  const i = e[t.questionId], a = i != null && !(typeof i == "string" && i.trim() === "") && !(Array.isArray(i) && i.length === 0);
299
- return "answered" in t ? t.answered ? a : !a : a ? "equals" in t ? y(i, t.equals) : "notEquals" in t ? !y(i, t.notEquals) : "in" in t ? t.in.some((n) => y(i, n)) : !1 : !1;
306
+ return "answered" in t ? t.answered ? a : !a : a ? "equals" in t ? x(i, t.equals) : "notEquals" in t ? !x(i, t.notEquals) : "in" in t ? t.in.some((n) => x(i, n)) : !1 : !1;
300
307
  }
301
- function y(t, e) {
308
+ function x(t, e) {
302
309
  return Array.isArray(t) ? t.some((i) => i === e) : t === e;
303
310
  }
304
- const X = 360, x = 2;
305
- function Z(t) {
311
+ const ee = 360, E = 2;
312
+ function te(t) {
306
313
  const e = t.scrollHeight - t.clientHeight;
307
- return e <= x ? "none" : t.scrollTop <= x ? "top" : t.scrollTop >= e - x ? "bottom" : "middle";
314
+ return e <= E ? "none" : t.scrollTop <= E ? "top" : t.scrollTop >= e - E ? "bottom" : "middle";
308
315
  }
309
- function ee(t, e) {
310
- const i = Z(t);
316
+ function ie(t, e) {
317
+ const i = te(t);
311
318
  if (t.setAttribute("data-qaid-scroll", i), e) {
312
319
  const a = i === "top" || i === "middle";
313
320
  e.hidden = !a;
314
321
  }
315
322
  return i;
316
323
  }
317
- function te(t, e) {
318
- const i = e > 0 && e < X ? "compact" : "roomy";
324
+ function ae(t, e) {
325
+ const i = e > 0 && e < ee ? "compact" : "roomy";
319
326
  return t.setAttribute("data-qaid-fit", i), i;
320
327
  }
321
- function ie(t, e, i) {
328
+ function ne(t, e, i) {
322
329
  const a = () => {
323
- ee(t, i), te(e, t.clientHeight);
330
+ ie(t, i), ae(e, t.clientHeight);
324
331
  };
325
332
  t.addEventListener("scroll", a, { passive: !0 });
326
333
  let n = null;
@@ -331,7 +338,7 @@ function ie(t, e, i) {
331
338
  }
332
339
  };
333
340
  }
334
- const C = "data-qaid-a11y-live", ae = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;", ne = [
341
+ const A = "data-qaid-a11y-live", re = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;", se = [
335
342
  "a[href]",
336
343
  "button",
337
344
  "input",
@@ -339,25 +346,25 @@ const C = "data-qaid-a11y-live", ae = "position:absolute;width:1px;height:1px;ma
339
346
  "select",
340
347
  "[tabindex]"
341
348
  ].join(",");
342
- function re(t) {
349
+ function oe(t) {
343
350
  return t.ownerDocument || document;
344
351
  }
345
- function oe(t, e) {
352
+ function de(t, e) {
346
353
  const i = e ? "assertive" : "polite", a = t.querySelector(
347
- `[${C}="${i}"]`
354
+ `[${A}="${i}"]`
348
355
  );
349
356
  if (a) return a;
350
- const o = re(t).createElement("div");
351
- return o.setAttribute(C, i), o.setAttribute("role", e ? "alert" : "status"), o.setAttribute("aria-live", e ? "assertive" : "polite"), o.setAttribute("aria-atomic", "true"), o.style.cssText = ae, t.appendChild(o), o;
357
+ const r = oe(t).createElement("div");
358
+ return r.setAttribute(A, i), r.setAttribute("role", e ? "alert" : "status"), r.setAttribute("aria-live", e ? "assertive" : "polite"), r.setAttribute("aria-atomic", "true"), r.style.cssText = re, t.appendChild(r), r;
352
359
  }
353
360
  function v(t, e, i = {}) {
354
- const a = oe(t, !!i.assertive);
361
+ const a = de(t, !!i.assertive);
355
362
  a.textContent = "", a.textContent = e;
356
363
  }
357
- function se(t) {
364
+ function le(t) {
358
365
  return t.hasAttribute("disabled") ? !0 : t.disabled === !0;
359
366
  }
360
- function de(t) {
367
+ function ce(t) {
361
368
  let e = t;
362
369
  for (; e; ) {
363
370
  if (e.hasAttribute("hidden")) return !0;
@@ -368,52 +375,52 @@ function de(t) {
368
375
  }
369
376
  return !1;
370
377
  }
371
- function A(t) {
378
+ function S(t) {
372
379
  return Array.from(
373
- t.querySelectorAll(ne)
374
- ).filter((i) => !(i.getAttribute("tabindex") === "-1" || i instanceof HTMLInputElement && i.type === "hidden" || i instanceof HTMLAnchorElement && !i.getAttribute("href") || se(i) || de(i)));
380
+ t.querySelectorAll(se)
381
+ ).filter((i) => !(i.getAttribute("tabindex") === "-1" || i instanceof HTMLInputElement && i.type === "hidden" || i instanceof HTMLAnchorElement && !i.getAttribute("href") || le(i) || ce(i)));
375
382
  }
376
- function I(t) {
383
+ function T(t) {
377
384
  let e = t.activeElement;
378
385
  for (; e && e.shadowRoot && e.shadowRoot.activeElement; )
379
386
  e = e.shadowRoot.activeElement;
380
387
  return e instanceof HTMLElement ? e : null;
381
388
  }
382
- function le(t) {
389
+ function ue(t) {
383
390
  const e = t.ownerDocument || document;
384
391
  let i = !1;
385
- const a = (o) => {
386
- if (o.key !== "Tab") return;
387
- const r = A(t);
388
- if (r.length === 0) {
389
- o.preventDefault(), t.focus();
392
+ const a = (r) => {
393
+ if (r.key !== "Tab") return;
394
+ const s = S(t);
395
+ if (s.length === 0) {
396
+ r.preventDefault(), t.focus();
390
397
  return;
391
398
  }
392
- const c = r[0], q = r[r.length - 1], p = I(e), f = p ? r.indexOf(p) !== -1 : !1;
393
- o.shiftKey ? (!f || p === c) && (o.preventDefault(), q.focus()) : (!f || p === q) && (o.preventDefault(), c.focus());
399
+ const o = s[0], u = s[s.length - 1], q = T(e), m = q ? s.indexOf(q) !== -1 : !1;
400
+ r.shiftKey ? (!m || q === o) && (r.preventDefault(), u.focus()) : (!m || q === u) && (r.preventDefault(), o.focus());
394
401
  };
395
402
  t.addEventListener("keydown", a);
396
- const n = A(t);
403
+ const n = S(t);
397
404
  return n.length > 0 ? n[0].focus() : (t.hasAttribute("tabindex") || (t.setAttribute("tabindex", "-1"), i = !0), t.focus()), {
398
405
  release() {
399
406
  t.removeEventListener("keydown", a), i && (t.removeAttribute("tabindex"), i = !1);
400
407
  }
401
408
  };
402
409
  }
403
- function ce() {
404
- return I(document);
410
+ function he() {
411
+ return T(document);
405
412
  }
406
- function ue(t) {
413
+ function pe(t) {
407
414
  if (!(!t || typeof t.focus != "function"))
408
415
  try {
409
416
  t.focus();
410
417
  } catch {
411
418
  }
412
419
  }
413
- function he(t, e = {}) {
420
+ function qe(t, e = {}) {
414
421
  t.setAttribute("role", "dialog"), t.setAttribute("aria-modal", "true"), e.labelledbyId && t.setAttribute("aria-labelledby", e.labelledbyId), e.describedbyId && t.setAttribute("aria-describedby", e.describedbyId), e.label && t.setAttribute("aria-label", e.label);
415
422
  }
416
- function qe(t, e) {
423
+ function me(t, e) {
417
424
  let i = t;
418
425
  for (; i && i !== e; ) {
419
426
  const a = i.parentNode;
@@ -427,33 +434,45 @@ function qe(t, e) {
427
434
  }
428
435
  return null;
429
436
  }
430
- function pe(t) {
437
+ function fe(t) {
431
438
  const i = (t.ownerDocument || document).body;
432
439
  if (!i) return () => {
433
440
  };
434
- const a = qe(t, i), n = [];
435
- return Array.from(i.children).forEach((o) => {
436
- if (!(o instanceof HTMLElement) || a && o === a) return;
437
- const r = o.inert === !0, c = o.getAttribute("aria-hidden");
438
- r && c === "true" || (o.inert = !0, o.setAttribute("aria-hidden", "true"), n.push({ el: o, prevInert: r, prevAriaHidden: c }));
441
+ const a = me(t, i), n = [];
442
+ return Array.from(i.children).forEach((r) => {
443
+ if (!(r instanceof HTMLElement) || a && r === a) return;
444
+ const s = r.inert === !0, o = r.getAttribute("aria-hidden");
445
+ s && o === "true" || (r.inert = !0, r.setAttribute("aria-hidden", "true"), n.push({ el: r, prevInert: s, prevAriaHidden: o }));
439
446
  }), function() {
440
447
  for (; n.length; ) {
441
- const r = n.pop();
442
- r && (r.el.inert = r.prevInert, r.prevAriaHidden === null ? r.el.removeAttribute("aria-hidden") : r.el.setAttribute("aria-hidden", r.prevAriaHidden));
448
+ const s = n.pop();
449
+ s && (s.el.inert = s.prevInert, s.prevAriaHidden === null ? s.el.removeAttribute("aria-hidden") : s.el.setAttribute("aria-hidden", s.prevAriaHidden));
443
450
  }
444
451
  };
445
452
  }
446
- const S = "qaid_visitor_id";
447
- function me() {
453
+ const I = "qaid_visitor_id";
454
+ function N() {
455
+ const t = typeof crypto < "u" ? crypto : void 0;
456
+ if (t && typeof t.randomUUID == "function") return t.randomUUID();
457
+ const e = new Uint8Array(16);
458
+ if (t && typeof t.getRandomValues == "function")
459
+ t.getRandomValues(e);
460
+ else
461
+ for (let a = 0; a < e.length; a++) e[a] = Math.floor(Math.random() * 256);
462
+ e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
463
+ const i = Array.from(e, (a) => a.toString(16).padStart(2, "0")).join("");
464
+ return `${i.slice(0, 8)}-${i.slice(8, 12)}-${i.slice(12, 16)}-${i.slice(16, 20)}-${i.slice(20)}`;
465
+ }
466
+ function ge() {
448
467
  try {
449
- let t = localStorage.getItem(S);
450
- return t || (t = crypto.randomUUID(), localStorage.setItem(S, t)), t;
468
+ let t = localStorage.getItem(I);
469
+ return t || (t = N(), localStorage.setItem(I, t)), t;
451
470
  } catch {
452
- return crypto.randomUUID();
471
+ return N();
453
472
  }
454
473
  }
455
- const fe = '<svg width="14" height="14" viewBox="0 0 14 14" aria-hidden="true"><path d="M2 2l10 10M12 2L2 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" fill="none"/></svg>', ge = '<svg width="24" height="24" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12l4 4L19 7" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg>';
456
- class be {
474
+ const be = '<svg width="14" height="14" viewBox="0 0 14 14" aria-hidden="true"><path d="M2 2l10 10M12 2L2 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" fill="none"/></svg>', ve = '<svg width="24" height="24" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12l4 4L19 7" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg>';
475
+ class ye {
457
476
  config;
458
477
  questionnaire = null;
459
478
  inlineQuestionnaire;
@@ -467,6 +486,15 @@ class be {
467
486
  // Latched goToStep request when called before init finishes. Applied
468
487
  // once the questionnaire + visible list are ready.
469
488
  pendingGoToStep = null;
489
+ // Latched update() request, for the same reason: a host that swaps the
490
+ // questionnaire while init is still in flight would otherwise have its
491
+ // questionnaire overwritten by the one init is already loading.
492
+ pendingUpdate = null;
493
+ // Consumed by the next renderStep(). Set by update(), because a host
494
+ // swapping the questionnaire is not the reader navigating: pulling focus
495
+ // into the form would take it off whatever they are actually using — in
496
+ // an editor preview, the field they are typing the questionnaire into.
497
+ suppressStepFocus = !1;
470
498
  // True after the first step has rendered. Used so the focus-on-step
471
499
  // logic in renderStep() can distinguish initial mount (driven by the
472
500
  // `autoFocus` config) from subsequent step changes (always focused so
@@ -476,6 +504,17 @@ class be {
476
504
  answers = {};
477
505
  responseId = null;
478
506
  visitorId;
507
+ // The create-response request, so submit() can wait for one still in
508
+ // flight, and whether it is still running (a save stops waiting for an
509
+ // id the moment the create has failed, instead of sitting out 5 s).
510
+ createPromise = null;
511
+ createPending = !1;
512
+ // Set when an autosave was dropped because there was no response id to
513
+ // PATCH. submit() then re-sends every visible answer once it has an id,
514
+ // since a server may store answers from the PATCHes alone.
515
+ droppedSaves = !1;
516
+ // Guards submit() against a double click or a retry while one runs.
517
+ submitting = !1;
479
518
  // Per-question pending autosave (text/currency are debounced)
480
519
  pendingSaveTimer = null;
481
520
  pendingSaveQuestionId = null;
@@ -570,10 +609,10 @@ class be {
570
609
  backdropOpacity: e.backdropOpacity,
571
610
  fontFamily: e.fontFamily,
572
611
  fontSize: e.fontSize
573
- }, this.themeUrl = e.themeUrl, this.themeDocument = e.themeDocument, this.hostCss = e.css ?? "", this.metadata = e.metadata, this.onCompleteCb = e.onComplete, this.onCloseCb = e.onClose, this.inlineQuestionnaire = e.questionnaire, this.configUrl = e.configUrl, this.visitorId = me(), this.boundKeyDown = this.handleKeyDown.bind(this), this.init();
612
+ }, this.themeUrl = e.themeUrl, this.themeDocument = e.themeDocument, this.hostCss = e.css ?? "", this.metadata = e.metadata, this.onCompleteCb = e.onComplete, this.onCloseCb = e.onClose, this.inlineQuestionnaire = e.questionnaire, this.configUrl = e.configUrl, this.visitorId = ge(), this.boundKeyDown = this.handleKeyDown.bind(this), this.init();
574
613
  }
575
614
  async init() {
576
- this.cssVars = j(this.hostInlineVars), this.mountShell(), this.renderLoading();
615
+ this.cssVars = $(this.hostInlineVars), this.mountShell(), this.renderLoading();
577
616
  try {
578
617
  const [e, i] = await Promise.all([
579
618
  this.loadQuestionnaire(),
@@ -581,13 +620,13 @@ class be {
581
620
  ]);
582
621
  if (!e || !e.questions || e.questions.length === 0)
583
622
  throw new Error("Questionnaire is empty");
584
- if (this.questionnaire = e, this.applyResolvedTheme(i), this.recomputeVisible(), this.pendingGoToStep) {
623
+ if (this.questionnaire = this.pendingUpdate ?? e, this.pendingUpdate = null, this.applyResolvedTheme(i), this.recomputeVisible(), this.pendingGoToStep) {
585
624
  const a = this.visibleQuestions.findIndex(
586
625
  (n) => n.id === this.pendingGoToStep
587
626
  );
588
627
  a !== -1 && (this.stepIndex = a), this.pendingGoToStep = null;
589
628
  }
590
- this.createResponse(), this.state = "READY", this.renderHeader(), this.renderStep(), this.setupModalA11y();
629
+ this.startCreate(), this.state = "READY", this.renderHeader(), this.renderStep(), this.setupModalA11y();
591
630
  } catch (e) {
592
631
  this.state = "ERROR", this.renderError(e);
593
632
  }
@@ -631,23 +670,23 @@ class be {
631
670
  "qaid-q-theme-dark",
632
671
  a === "dark"
633
672
  ), this.rootEl.classList.toggle("qaid-q-unstyled", !!n);
634
- const o = [];
673
+ const r = [];
635
674
  if (e?.tokens && Object.keys(e.tokens).length > 0) {
636
- const r = Object.entries(e.tokens).filter(([, c]) => typeof c == "string" && c.trim() !== "").map(([c, q]) => ` ${c}: ${q};`).join(`
675
+ const s = Object.entries(e.tokens).filter(([, o]) => typeof o == "string" && o.trim() !== "").map(([o, u]) => ` ${o}: ${u};`).join(`
637
676
  `);
638
- r && o.push(`:where(.qaid-q-root) {
639
- ${r}
677
+ s && r.push(`:where(.qaid-q-root) {
678
+ ${s}
640
679
  }`);
641
680
  }
642
681
  if (i && i !== "default") {
643
- const r = M(i);
644
- r && o.push(r);
682
+ const s = Q(i);
683
+ s && r.push(s);
645
684
  }
646
- if (e?.css && e.css.trim() !== "" && o.push(e.css), this.hostCss && this.hostCss.trim() !== "" && o.push(this.hostCss), o.length > 0) {
647
- const r = document.createElement("style");
648
- r.setAttribute("data-qaid-q-theme", ""), r.textContent = o.join(`
685
+ if (e?.css && e.css.trim() !== "" && r.push(e.css), this.hostCss && this.hostCss.trim() !== "" && r.push(this.hostCss), r.length > 0) {
686
+ const s = document.createElement("style");
687
+ s.setAttribute("data-qaid-q-theme", ""), s.textContent = r.join(`
649
688
 
650
- `), this.shadowRoot.appendChild(r);
689
+ `), this.shadowRoot.appendChild(s);
651
690
  }
652
691
  }
653
692
  // ------------------------------------------------------------------
@@ -670,20 +709,20 @@ ${r}
670
709
  mountShell() {
671
710
  this.shadowHost = document.createElement("div"), this.shadowHost.setAttribute("data-qaid-quests", "");
672
711
  const e = this.config.container ? document.querySelector(this.config.container) : null;
673
- e ? (this.shadowHost.style.display = "block", this.shadowHost.style.height = "100%", this.shadowHost.style.minHeight = "0", e.appendChild(this.shadowHost), this.isUserContainer = !0) : (this.savedOpener = ce(), this.shadowHost.style.position = "fixed", this.shadowHost.style.inset = "0", this.shadowHost.style.zIndex = String(this.config.zIndex), this.shadowHost.style.pointerEvents = "none", document.body.appendChild(this.shadowHost)), this.shadowRoot = this.shadowHost.attachShadow({ mode: "open" });
712
+ e ? (this.shadowHost.style.display = "block", this.shadowHost.style.height = "100%", this.shadowHost.style.minHeight = "0", e.appendChild(this.shadowHost), this.isUserContainer = !0) : (this.savedOpener = he(), this.shadowHost.style.position = "fixed", this.shadowHost.style.inset = "0", this.shadowHost.style.zIndex = String(this.config.zIndex), this.shadowHost.style.pointerEvents = "none", document.body.appendChild(this.shadowHost)), this.shadowRoot = this.shadowHost.attachShadow({ mode: "open" });
674
713
  const i = document.createElement("style");
675
- if (i.textContent = F(), this.shadowRoot.appendChild(i), this.rootEl = document.createElement("div"), this.rootEl.className = [
714
+ if (i.textContent = M(), this.shadowRoot.appendChild(i), this.rootEl = document.createElement("div"), this.rootEl.className = [
676
715
  "qaid-q-root",
677
716
  this.isUserContainer ? "qaid-q-inline" : "",
678
717
  this.config.animate ? "" : "qaid-q-no-motion"
679
- ].filter(Boolean).join(" "), U(this.rootEl, this.cssVars), this.isUserContainer)
718
+ ].filter(Boolean).join(" "), F(this.rootEl, this.cssVars), this.isUserContainer)
680
719
  this.cardEl = document.createElement("div"), this.cardEl.className = "qaid-q-card", this.rootEl.appendChild(this.cardEl);
681
720
  else {
682
721
  this.backdropEl = document.createElement("div"), this.backdropEl.className = "qaid-q-backdrop", this.backdropEl.addEventListener("click", () => this.close()), this.rootEl.appendChild(this.backdropEl);
683
722
  const a = document.createElement("div");
684
723
  a.className = "qaid-q-modal", this.cardEl = document.createElement("div"), this.cardEl.className = "qaid-q-card", a.appendChild(this.cardEl), this.rootEl.appendChild(a);
685
724
  }
686
- this.shadowRoot.appendChild(this.rootEl), !this.isUserContainer && this.shadowHost && (this.shadowHost.style.pointerEvents = "auto"), !this.isUserContainer && this.cardEl && he(this.cardEl), document.addEventListener("keydown", this.boundKeyDown);
725
+ this.shadowRoot.appendChild(this.rootEl), !this.isUserContainer && this.shadowHost && (this.shadowHost.style.pointerEvents = "auto"), !this.isUserContainer && this.cardEl && qe(this.cardEl), document.addEventListener("keydown", this.boundKeyDown);
687
726
  }
688
727
  renderLoading() {
689
728
  if (!this.cardEl) return;
@@ -707,93 +746,94 @@ ${r}
707
746
  renderHeader() {
708
747
  if (!this.cardEl || !this.questionnaire) return;
709
748
  this.cardEl.replaceChildren();
710
- const e = !!this.questionnaire.hideProgress || this.questionnaire.questions.length <= 1, i = !e && this.effectiveProgressPosition() === "bottom", a = !!this.questionnaire.hideTitle, n = !!this.questionnaire.title && !a, o = !!this.questionnaire.description && !a, r = !this.isUserContainer, c = r || !i && !e;
749
+ const e = !!this.questionnaire.hideProgress || this.questionnaire.questions.length <= 1, i = !e && this.effectiveProgressPosition() === "bottom", a = !!this.questionnaire.hideTitle, n = !!this.questionnaire.title && !a, r = !!this.questionnaire.description && !a, s = !this.isUserContainer, o = s || !i && !e;
711
750
  this.savingEl = document.createElement("div"), this.savingEl.className = "qaid-q-saving";
751
+ const u = document.createElement("span");
752
+ u.className = "qaid-q-saving-dot";
712
753
  const q = document.createElement("span");
713
- q.className = "qaid-q-saving-dot";
714
- const p = document.createElement("span");
715
- p.textContent = "Saving…", this.savingEl.appendChild(q), this.savingEl.appendChild(p), this.stepCounterEl = document.createElement("div"), this.stepCounterEl.className = "qaid-q-step-counter", this.progressEl = document.createElement("div"), this.progressEl.className = i ? "qaid-q-progress qaid-q-progress--inline" : "qaid-q-progress", this.progressFillEl = document.createElement("div"), this.progressFillEl.className = "qaid-q-progress-fill", this.progressEl.appendChild(this.progressFillEl);
716
- const f = n || c;
717
- if (f) {
718
- const s = document.createElement("div");
719
- s.className = "qaid-q-header";
720
- const u = document.createElement("div");
721
- n && (this.titleEl = document.createElement("h2"), this.titleEl.className = "qaid-q-title", this.titleEl.textContent = this.questionnaire.title, u.appendChild(this.titleEl));
722
- const d = document.createElement("div");
723
- if (d.style.display = "flex", d.style.alignItems = "center", d.style.gap = "0.5rem", i || (d.appendChild(this.savingEl), e || d.appendChild(this.stepCounterEl)), r) {
724
- const m = document.createElement("button");
725
- m.type = "button", m.className = "qaid-q-close", m.setAttribute("aria-label", "Close form"), m.innerHTML = fe, m.addEventListener("click", () => this.close()), d.appendChild(m);
754
+ q.textContent = "Saving…", this.savingEl.appendChild(u), this.savingEl.appendChild(q), this.stepCounterEl = document.createElement("div"), this.stepCounterEl.className = "qaid-q-step-counter", this.progressEl = document.createElement("div"), this.progressEl.className = i ? "qaid-q-progress qaid-q-progress--inline" : "qaid-q-progress", this.progressFillEl = document.createElement("div"), this.progressFillEl.className = "qaid-q-progress-fill", this.progressEl.appendChild(this.progressFillEl);
755
+ const m = n || o;
756
+ if (m) {
757
+ const l = document.createElement("div");
758
+ l.className = "qaid-q-header";
759
+ const h = document.createElement("div");
760
+ n && (this.titleEl = document.createElement("h2"), this.titleEl.className = "qaid-q-title", this.titleEl.textContent = this.questionnaire.title, h.appendChild(this.titleEl));
761
+ const c = document.createElement("div");
762
+ if (c.style.display = "flex", c.style.alignItems = "center", c.style.gap = "0.5rem", i || (c.appendChild(this.savingEl), e || c.appendChild(this.stepCounterEl)), s) {
763
+ const p = document.createElement("button");
764
+ p.type = "button", p.className = "qaid-q-close", p.setAttribute("aria-label", "Close form"), p.innerHTML = be, p.addEventListener("click", () => this.close()), c.appendChild(p);
726
765
  }
727
- s.appendChild(u), s.appendChild(d), this.cardEl.appendChild(s);
766
+ l.appendChild(h), l.appendChild(c), this.cardEl.appendChild(l);
728
767
  }
729
768
  if (!this.isUserContainer && this.cardEl && (this.titleEl ? (this.titleEl.id = this.titleEl.id || "qaid-q-dialog-title", this.cardEl.setAttribute("aria-labelledby", this.titleEl.id), this.cardEl.removeAttribute("aria-label")) : (this.cardEl.removeAttribute("aria-labelledby"), this.cardEl.setAttribute(
730
769
  "aria-label",
731
770
  this.questionnaire.title ?? "Questionnaire"
732
- ))), o) {
733
- const s = document.createElement("p");
734
- s.className = "qaid-q-description", s.textContent = this.questionnaire.description, s.style.marginTop = f ? "-0.5rem" : "0", s.style.marginBottom = "0.75rem", this.cardEl.appendChild(s);
771
+ ))), r) {
772
+ const l = document.createElement("p");
773
+ l.className = "qaid-q-description", l.textContent = this.questionnaire.description, l.style.marginTop = m ? "-0.5rem" : "0", l.style.marginBottom = "0.75rem", this.cardEl.appendChild(l);
735
774
  }
736
- !i && !e && this.cardEl.appendChild(this.progressEl), this.bodyEl = document.createElement("div"), this.bodyEl.className = "qaid-q-body", this.cardEl.appendChild(this.bodyEl), this.footerEl = document.createElement("div"), this.footerEl.className = "qaid-q-footer", this.cardEl.appendChild(this.footerEl), this.scrollCueEl = document.createElement("div"), this.scrollCueEl.className = "qaid-q-scroll-cue", this.scrollCueEl.setAttribute("aria-hidden", "true"), this.scrollCueEl.hidden = !0, this.scrollCueEl.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>', this.bodyEl.appendChild(this.scrollCueEl), this.overflow = ie(this.bodyEl, this.cardEl, this.scrollCueEl);
775
+ !i && !e && this.cardEl.appendChild(this.progressEl), this.bodyEl = document.createElement("div"), this.bodyEl.className = "qaid-q-body", this.cardEl.appendChild(this.bodyEl), this.footerEl = document.createElement("div"), this.footerEl.className = "qaid-q-footer", this.cardEl.appendChild(this.footerEl), this.scrollCueEl = document.createElement("div"), this.scrollCueEl.className = "qaid-q-scroll-cue", this.scrollCueEl.setAttribute("aria-hidden", "true"), this.scrollCueEl.hidden = !0, this.scrollCueEl.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>', this.bodyEl.appendChild(this.scrollCueEl), this.overflow = ne(this.bodyEl, this.cardEl, this.scrollCueEl);
737
776
  }
738
777
  // ------------------------------------------------------------------
739
778
  // Step rendering
740
779
  // ------------------------------------------------------------------
741
780
  renderStep() {
742
- if (!this.questionnaire || !this.bodyEl || !this.footerEl) return;
743
- const e = this.visibleQuestions.length;
744
- if (e === 0) {
781
+ const e = this.suppressStepFocus;
782
+ if (this.suppressStepFocus = !1, !this.questionnaire || !this.bodyEl || !this.footerEl) return;
783
+ const i = this.visibleQuestions.length;
784
+ if (i === 0) {
745
785
  this.submit();
746
786
  return;
747
787
  }
748
- this.stepIndex >= e && (this.stepIndex = e - 1);
749
- const i = this.stepIndex, a = this.visibleQuestions[i];
750
- if (this.stepCounterEl && (this.stepCounterEl.textContent = `${i + 1} / ${e}`), this.progressFillEl) {
751
- const h = (i + 1) / e * 100;
752
- this.progressFillEl.style.width = `${h}%`;
788
+ this.stepIndex >= i && (this.stepIndex = i - 1);
789
+ const a = this.stepIndex, n = this.visibleQuestions[a];
790
+ if (this.stepCounterEl && (this.stepCounterEl.textContent = `${a + 1} / ${i}`), this.progressFillEl) {
791
+ const d = (a + 1) / i * 100;
792
+ this.progressFillEl.style.width = `${d}%`;
753
793
  }
754
- this.progressEl && (this.progressEl.setAttribute("role", "progressbar"), this.progressEl.setAttribute("aria-label", "Progress"), this.progressEl.setAttribute("aria-valuemin", "0"), this.progressEl.setAttribute("aria-valuemax", String(e)), this.progressEl.setAttribute("aria-valuenow", String(i + 1)), this.progressEl.setAttribute(
794
+ this.progressEl && (this.progressEl.setAttribute("role", "progressbar"), this.progressEl.setAttribute("aria-label", "Progress"), this.progressEl.setAttribute("aria-valuemin", "0"), this.progressEl.setAttribute("aria-valuemax", String(i)), this.progressEl.setAttribute("aria-valuenow", String(a + 1)), this.progressEl.setAttribute(
755
795
  "aria-valuetext",
756
- `Question ${i + 1} of ${e}`
757
- )), this.shadowRoot && e > 1 && v(this.shadowRoot, `Step ${i + 1} of ${e}`);
758
- const n = document.createElement("div");
759
- n.className = "qaid-q-step", n.setAttribute("role", "group"), n.setAttribute("aria-labelledby", `qaid-q-label-${i}`);
760
- const o = document.createElement("label");
761
- if (o.id = `qaid-q-label-${i}`, o.className = "qaid-q-label", o.textContent = a.label, a.required) {
762
- const h = document.createElement("span");
763
- h.className = "qaid-q-required", h.textContent = "*", h.setAttribute("aria-label", "required"), o.appendChild(h);
796
+ `Question ${a + 1} of ${i}`
797
+ )), this.shadowRoot && i > 1 && v(this.shadowRoot, `Step ${a + 1} of ${i}`);
798
+ const r = document.createElement("div");
799
+ r.className = "qaid-q-step", r.setAttribute("role", "group"), r.setAttribute("aria-labelledby", `qaid-q-label-${a}`);
800
+ const s = document.createElement("label");
801
+ if (s.id = `qaid-q-label-${a}`, s.className = "qaid-q-label", s.textContent = n.label, n.required) {
802
+ const d = document.createElement("span");
803
+ d.className = "qaid-q-required", d.textContent = "*", d.setAttribute("aria-label", "required"), s.appendChild(d);
764
804
  }
765
- if (n.appendChild(o), a.description) {
766
- const h = document.createElement("p");
767
- h.className = "qaid-q-description", h.textContent = a.description, n.appendChild(h);
805
+ if (r.appendChild(s), n.description) {
806
+ const d = document.createElement("p");
807
+ d.className = "qaid-q-description", d.textContent = n.description, r.appendChild(d);
768
808
  }
769
- const r = document.createElement("p");
770
- r.className = "qaid-q-error", r.id = `qaid-q-error-${i}`, r.setAttribute("aria-live", "polite");
771
- const c = this.answers[a.id] ?? null, q = i === e - 1, p = $({
772
- question: a,
773
- initialValue: c,
774
- onChange: (h) => {
775
- this.handleAnswerChange(a, h), r.textContent && (r.textContent = "", this.currentInput?.clearInvalid());
809
+ const o = document.createElement("p");
810
+ o.className = "qaid-q-error", o.id = `qaid-q-error-${a}`, o.setAttribute("aria-live", "polite");
811
+ const u = this.answers[n.id] ?? null, q = a === i - 1, m = K({
812
+ question: n,
813
+ initialValue: u,
814
+ onChange: (d) => {
815
+ this.handleAnswerChange(n, d), o.textContent && (o.textContent = "", this.currentInput?.clearInvalid());
776
816
  },
777
- onSubmit: () => this.advance(a, r),
778
- onAutoAdvance: () => this.advance(a, r),
817
+ onSubmit: () => this.advance(n, o),
818
+ onAutoAdvance: () => this.advance(n, o),
779
819
  autoAdvance: this.config.autoAdvance
780
820
  });
781
- this.currentInput = p, n.appendChild(p.element), n.appendChild(r), this.bodyEl.replaceChildren(n), this.scrollCueEl && this.bodyEl.appendChild(this.scrollCueEl), this.bodyEl.scrollTop = 0, this.overflow?.refresh(), this.footerEl.replaceChildren();
782
- const s = !(!!this.questionnaire.hideProgress || this.questionnaire.questions.length <= 1) && this.effectiveProgressPosition() === "bottom", u = i > 0 ? (() => {
783
- const h = document.createElement("button");
784
- return h.type = "button", h.className = "qaid-q-btn qaid-q-btn-secondary", h.textContent = this.questionnaire.backLabel ?? "Back", h.addEventListener("click", () => this.back()), h;
785
- })() : null, d = document.createElement("button");
786
- if (d.type = "button", d.className = "qaid-q-btn qaid-q-btn-primary", d.textContent = q ? this.questionnaire.submitLabel ?? "Submit" : this.questionnaire.nextLabel ?? "Next", d.addEventListener("click", () => this.advance(a, r)), s)
787
- this.footerEl.classList.add("qaid-q-footer--inline-progress"), u && this.footerEl.appendChild(u), this.progressEl && this.footerEl.appendChild(this.progressEl), this.savingEl && this.footerEl.appendChild(this.savingEl), this.stepCounterEl && this.footerEl.appendChild(this.stepCounterEl), this.footerEl.appendChild(d);
821
+ this.currentInput = m, r.appendChild(m.element), r.appendChild(o), this.bodyEl.replaceChildren(r), this.scrollCueEl && this.bodyEl.appendChild(this.scrollCueEl), this.bodyEl.scrollTop = 0, this.overflow?.refresh(), this.footerEl.replaceChildren();
822
+ const h = !(!!this.questionnaire.hideProgress || this.questionnaire.questions.length <= 1) && this.effectiveProgressPosition() === "bottom", c = a > 0 ? (() => {
823
+ const d = document.createElement("button");
824
+ return d.type = "button", d.className = "qaid-q-btn qaid-q-btn-secondary", d.textContent = this.questionnaire.backLabel ?? "Back", d.addEventListener("click", () => this.back()), d;
825
+ })() : null, p = document.createElement("button");
826
+ if (p.type = "button", p.className = "qaid-q-btn qaid-q-btn-primary", p.textContent = q ? this.questionnaire.submitLabel ?? "Submit" : this.questionnaire.nextLabel ?? "Next", p.addEventListener("click", () => this.advance(n, o)), h)
827
+ this.footerEl.classList.add("qaid-q-footer--inline-progress"), c && this.footerEl.appendChild(c), this.progressEl && this.footerEl.appendChild(this.progressEl), this.savingEl && this.footerEl.appendChild(this.savingEl), this.stepCounterEl && this.footerEl.appendChild(this.stepCounterEl), this.footerEl.appendChild(p);
788
828
  else {
789
829
  this.footerEl.classList.remove("qaid-q-footer--inline-progress");
790
- const h = document.createElement("div");
791
- h.className = "qaid-q-footer-left";
792
- const l = document.createElement("div");
793
- l.className = "qaid-q-footer-right", u && h.appendChild(u), l.appendChild(d), this.footerEl.appendChild(h), this.footerEl.appendChild(l);
830
+ const d = document.createElement("div");
831
+ d.className = "qaid-q-footer-left";
832
+ const b = document.createElement("div");
833
+ b.className = "qaid-q-footer-right", c && d.appendChild(c), b.appendChild(p), this.footerEl.appendChild(d), this.footerEl.appendChild(b);
794
834
  }
795
- const m = !this.hasRenderedStep;
796
- this.hasRenderedStep = !0, (!m || this.config.autoFocus) && requestAnimationFrame(() => p.focus());
835
+ const f = !this.hasRenderedStep;
836
+ this.hasRenderedStep = !0, !e && (!f || this.config.autoFocus) && requestAnimationFrame(() => m.focus());
797
837
  }
798
838
  renderDone() {
799
839
  if (!this.cardEl || !this.questionnaire) return;
@@ -801,22 +841,52 @@ ${r}
801
841
  const e = document.createElement("div");
802
842
  e.className = "qaid-q-done";
803
843
  const i = document.createElement("div");
804
- i.className = "qaid-q-done-icon", i.innerHTML = ge, e.appendChild(i);
844
+ i.className = "qaid-q-done-icon", i.innerHTML = ve, e.appendChild(i);
805
845
  const a = document.createElement("h3");
806
846
  a.className = "qaid-q-done-title";
807
847
  const n = this.questionnaire.thankYouTitle ?? "Thank you!";
808
848
  if (a.textContent = n, a.setAttribute("tabindex", "-1"), e.appendChild(a), this.questionnaire.thankYouMessage) {
809
- const o = document.createElement("p");
810
- o.className = "qaid-q-done-message", o.textContent = this.questionnaire.thankYouMessage, e.appendChild(o);
849
+ const r = document.createElement("p");
850
+ r.className = "qaid-q-done-message", r.textContent = this.questionnaire.thankYouMessage, e.appendChild(r);
811
851
  }
812
852
  if (!this.isUserContainer) {
813
- const o = document.createElement("button");
814
- o.type = "button", o.className = "qaid-q-btn qaid-q-btn-primary", o.textContent = "Close", o.style.marginTop = "1rem", o.addEventListener("click", () => this.close()), e.appendChild(o);
853
+ const r = document.createElement("button");
854
+ r.type = "button", r.className = "qaid-q-btn qaid-q-btn-primary", r.textContent = "Close", r.style.marginTop = "1rem", r.addEventListener("click", () => this.close()), e.appendChild(r);
815
855
  }
816
856
  if (this.cardEl.appendChild(e), requestAnimationFrame(() => a.focus()), this.shadowRoot) {
817
- const o = this.questionnaire.thankYouMessage ? `${n}. ${this.questionnaire.thankYouMessage}` : n;
818
- v(this.shadowRoot, o);
857
+ const r = this.questionnaire.thankYouMessage ? `${n}. ${this.questionnaire.thankYouMessage}` : n;
858
+ v(this.shadowRoot, r);
859
+ }
860
+ }
861
+ /**
862
+ * Shown instead of the thank-you screen when the response could not be
863
+ * created or the submit was refused. The answers stay in memory, so
864
+ * "Try again" re-runs the whole submit (re-creating the response first
865
+ * if needed) without the visitor re-entering anything.
866
+ */
867
+ renderSubmitError() {
868
+ if (this.state = "SUBMIT_FAILED", !this.cardEl) return;
869
+ this.cardEl.replaceChildren();
870
+ const e = document.createElement("div");
871
+ e.className = "qaid-q-submit-error";
872
+ const i = document.createElement("h3");
873
+ i.className = "qaid-q-submit-error-title";
874
+ const a = "Couldn't send your answers";
875
+ i.textContent = a, i.setAttribute("tabindex", "-1"), e.appendChild(i);
876
+ const n = document.createElement("p");
877
+ n.className = "qaid-q-submit-error-message";
878
+ const r = "Your answers are still here. Check your connection and try again.";
879
+ n.textContent = r, e.appendChild(n);
880
+ const s = document.createElement("div");
881
+ s.className = "qaid-q-submit-error-actions";
882
+ const o = document.createElement("button");
883
+ if (o.type = "button", o.className = "qaid-q-btn qaid-q-btn-primary", o.textContent = "Try again", o.addEventListener("click", () => {
884
+ this.submitting || (o.setAttribute("aria-disabled", "true"), o.textContent = "Sending…", this.submit());
885
+ }), s.appendChild(o), !this.isUserContainer) {
886
+ const u = document.createElement("button");
887
+ u.type = "button", u.className = "qaid-q-btn qaid-q-btn-secondary", u.textContent = "Close", u.addEventListener("click", () => this.close()), s.appendChild(u);
819
888
  }
889
+ e.appendChild(s), this.cardEl.appendChild(e), requestAnimationFrame(() => i.focus()), this.shadowRoot && v(this.shadowRoot, `${a}. ${r}`, { assertive: !0 });
820
890
  }
821
891
  // ------------------------------------------------------------------
822
892
  // Navigation
@@ -824,7 +894,7 @@ ${r}
824
894
  advance(e, i) {
825
895
  if (!this.currentInput || !this.questionnaire) return;
826
896
  if (!this.currentInput.isValid()) {
827
- i.textContent = ve(e), this.currentInput.setInvalid(i.id), this.currentInput.focus();
897
+ i.textContent = xe(e), this.currentInput.setInvalid(i.id), this.currentInput.focus();
828
898
  return;
829
899
  }
830
900
  if (this.handleAnswerChange(e, this.currentInput.getValue(), { immediate: !0 }), this.stepIndex === this.visibleQuestions.length - 1) {
@@ -840,7 +910,7 @@ ${r}
840
910
  // Answer handling + autosave
841
911
  // ------------------------------------------------------------------
842
912
  recomputeVisible() {
843
- this.questionnaire && (this.visibleQuestions = J(this.questionnaire, this.answers));
913
+ this.questionnaire && (this.visibleQuestions = w(this.questionnaire, this.answers));
844
914
  }
845
915
  handleAnswerChange(e, i, a = {}) {
846
916
  this.answers[e.id] = i, this.recomputeVisible();
@@ -866,18 +936,29 @@ ${r}
866
936
  }
867
937
  async doSave(e, i) {
868
938
  let a = 0;
869
- for (; this.responseId === null && a < 5e3; )
939
+ for (; this.responseId === null && this.createPending && a < 5e3; )
870
940
  await new Promise((n) => setTimeout(n, 50)), a += 50;
871
- if (this.responseId !== null)
872
- try {
873
- await fetch(`${this.config.endpoint}/${this.responseId}`, {
874
- method: "PATCH",
875
- headers: this.jsonHeaders(),
876
- body: JSON.stringify({ questionId: e, value: i })
877
- });
878
- } catch (n) {
879
- console.error("[quests-embed] failed to save answer:", n);
880
- }
941
+ if (this.responseId === null) {
942
+ this.droppedSaves = !0;
943
+ return;
944
+ }
945
+ await this.patchAnswer(e, i);
946
+ }
947
+ async patchAnswer(e, i) {
948
+ try {
949
+ await fetch(`${this.config.endpoint}/${this.responseId}`, {
950
+ method: "PATCH",
951
+ headers: this.jsonHeaders(),
952
+ body: JSON.stringify({ questionId: e, value: i })
953
+ });
954
+ } catch (a) {
955
+ console.error("[quests-embed] failed to save answer:", a);
956
+ }
957
+ }
958
+ startCreate() {
959
+ return this.createPending = !0, this.createPromise = this.createResponse().finally(() => {
960
+ this.createPending = !1;
961
+ }), this.createPromise;
881
962
  }
882
963
  async createResponse() {
883
964
  try {
@@ -893,32 +974,62 @@ ${r}
893
974
  metadata: this.metadata
894
975
  })
895
976
  });
896
- if (e.ok) {
897
- const i = await e.json();
898
- this.responseId = i.id;
977
+ if (!e.ok) {
978
+ console.error(
979
+ `[quests-embed] failed to create response (${e.status})`
980
+ );
981
+ return;
899
982
  }
983
+ const i = await e.json();
984
+ i && i.id !== null && i.id !== void 0 ? this.responseId = i.id : console.error("[quests-embed] create response returned no id");
900
985
  } catch (e) {
901
986
  console.error("[quests-embed] failed to create response:", e);
902
987
  }
903
988
  }
904
989
  async submit() {
905
- for (this.flushPendingSave(); this.inflightSaves > 0; )
906
- await new Promise((e) => setTimeout(e, 50));
907
- if (this.responseId !== null)
990
+ if (!this.submitting) {
991
+ this.submitting = !0;
908
992
  try {
909
- await fetch(`${this.config.endpoint}/${this.responseId}/submit`, {
910
- method: "POST",
911
- headers: this.jsonHeaders(),
912
- body: JSON.stringify({ answers: this.answers })
913
- });
914
- } catch (e) {
915
- console.error("[quests-embed] failed to submit:", e);
993
+ await this.trySubmit();
994
+ } finally {
995
+ this.submitting = !1;
916
996
  }
997
+ }
998
+ }
999
+ async trySubmit() {
1000
+ for (this.flushPendingSave(); this.inflightSaves > 0; )
1001
+ await new Promise((n) => setTimeout(n, 50));
1002
+ if (this.createPromise && await this.createPromise, this.responseId === null && await this.startCreate(), this.responseId === null) {
1003
+ this.renderSubmitError();
1004
+ return;
1005
+ }
1006
+ const e = this.questionnaire ? Z(this.questionnaire, this.answers) : {}, i = [];
1007
+ if (this.droppedSaves)
1008
+ for (const [n, r] of Object.entries(e))
1009
+ i.push(this.patchAnswer(n, r));
1010
+ for (const [n, r] of Object.entries(this.answers))
1011
+ !Object.prototype.hasOwnProperty.call(e, n) && r !== null && i.push(this.patchAnswer(n, null));
1012
+ await Promise.all(i), this.droppedSaves = !1;
1013
+ let a = !1;
1014
+ try {
1015
+ const n = await fetch(`${this.config.endpoint}/${this.responseId}/submit`, {
1016
+ method: "POST",
1017
+ headers: this.jsonHeaders(),
1018
+ body: JSON.stringify({ answers: e })
1019
+ });
1020
+ a = n.ok, a || console.error(`[quests-embed] submit was refused (${n.status})`);
1021
+ } catch (n) {
1022
+ console.error("[quests-embed] failed to submit:", n);
1023
+ }
1024
+ if (!a) {
1025
+ this.renderSubmitError();
1026
+ return;
1027
+ }
917
1028
  if (this.state = "DONE", this.renderDone(), this.onCompleteCb)
918
1029
  try {
919
- this.onCompleteCb({ ...this.answers });
920
- } catch (e) {
921
- console.error("[quests-embed] onComplete handler threw:", e);
1030
+ this.onCompleteCb({ ...e });
1031
+ } catch (n) {
1032
+ console.error("[quests-embed] onComplete handler threw:", n);
922
1033
  }
923
1034
  }
924
1035
  jsonHeaders() {
@@ -944,14 +1055,14 @@ ${r}
944
1055
  * never trapped or isolated.
945
1056
  */
946
1057
  setupModalA11y() {
947
- this.isUserContainer || !this.cardEl || this.focusTrap || (this.focusTrap = le(this.cardEl), this.inertRestore = pe(this.cardEl));
1058
+ this.isUserContainer || !this.cardEl || this.focusTrap || (this.focusTrap = ue(this.cardEl), this.inertRestore = fe(this.cardEl));
948
1059
  }
949
1060
  close() {
950
1061
  this.flushPendingSave(), this.destroy();
951
1062
  }
952
1063
  /** Destroy the embed and clean up all resources */
953
1064
  destroy() {
954
- if (document.removeEventListener("keydown", this.boundKeyDown), this.pendingSaveTimer && (clearTimeout(this.pendingSaveTimer), this.pendingSaveTimer = null), this.focusTrap && (this.focusTrap.release(), this.focusTrap = null), this.inertRestore && (this.inertRestore(), this.inertRestore = null), !this.isUserContainer && this.savedOpener && ue(this.savedOpener), this.savedOpener = null, this.shadowHost && (this.shadowHost.remove(), this.shadowHost = null, this.shadowRoot = null), this.rootEl = null, this.cardEl = null, this.overflow?.destroy(), this.overflow = null, this.bodyEl = null, this.scrollCueEl = null, this.footerEl = null, this.titleEl = null, this.stepCounterEl = null, this.progressFillEl = null, this.savingEl = null, this.backdropEl = null, this.currentInput = null, !this.closed && (this.closed = !0, this.onCloseCb))
1065
+ if (document.removeEventListener("keydown", this.boundKeyDown), this.pendingSaveTimer && (clearTimeout(this.pendingSaveTimer), this.pendingSaveTimer = null), this.focusTrap && (this.focusTrap.release(), this.focusTrap = null), this.inertRestore && (this.inertRestore(), this.inertRestore = null), !this.isUserContainer && this.savedOpener && pe(this.savedOpener), this.savedOpener = null, this.shadowHost && (this.shadowHost.remove(), this.shadowHost = null, this.shadowRoot = null), this.rootEl = null, this.cardEl = null, this.overflow?.destroy(), this.overflow = null, this.bodyEl = null, this.scrollCueEl = null, this.footerEl = null, this.titleEl = null, this.stepCounterEl = null, this.progressFillEl = null, this.savingEl = null, this.backdropEl = null, this.currentInput = null, !this.closed && (this.closed = !0, this.onCloseCb))
955
1066
  try {
956
1067
  this.onCloseCb();
957
1068
  } catch (e) {
@@ -973,6 +1084,47 @@ ${r}
973
1084
  const e = this.visibleQuestions[this.stepIndex];
974
1085
  return e ? e.id : null;
975
1086
  }
1087
+ /**
1088
+ * Swap in a new questionnaire without tearing the embed down.
1089
+ *
1090
+ * Built for editor previews, where the alternative — `destroy()` plus a
1091
+ * fresh construction on every edit — re-mounts the shadow root, repaints
1092
+ * the loading state, and re-runs both the theme fetch and the create
1093
+ * call. Because that path awaits the network it always paints a blank
1094
+ * frame first, which is what makes a live preview strobe while the author
1095
+ * types. This re-renders the header and the current step and nothing
1096
+ * else, synchronously: the shadow root, the resolved theme, the response
1097
+ * id and the answers so far all survive.
1098
+ *
1099
+ * Answers are kept for questions that still exist and dropped for ones
1100
+ * that don't, so `getAnswers()` never reports an id the questionnaire has
1101
+ * no question for. The reader's place is kept the same way: if the
1102
+ * question on screen is still present and visible, the embed stays on it,
1103
+ * otherwise the step index is clamped into range.
1104
+ *
1105
+ * Returns whether the update was applied. It is refused, leaving the
1106
+ * embed exactly as it was, when the questionnaire has no questions, or
1107
+ * once the reader has completed the form — resuming a submitted response
1108
+ * is not something this can decide on the host's behalf, so a host that
1109
+ * wants the new form there should rebuild. Called before the embed has
1110
+ * finished initializing, the update is latched and applied as soon as it
1111
+ * is ready (and reported as applied), the same way `goToStep` is.
1112
+ */
1113
+ update(e) {
1114
+ if (!e?.questions || e.questions.length === 0 || this.state === "DONE") return !1;
1115
+ if (this.state === "LOADING")
1116
+ return this.pendingUpdate = e, !0;
1117
+ const i = new Set(e.questions.map((o) => o.id)), a = {};
1118
+ for (const [o, u] of Object.entries(this.answers))
1119
+ i.has(o) && (a[o] = u);
1120
+ const n = w(e, a);
1121
+ if (n.length === 0) return !1;
1122
+ this.flushPendingSave();
1123
+ const r = this.getCurrentQuestionId();
1124
+ this.questionnaire = e, this.inlineQuestionnaire && (this.inlineQuestionnaire = e), this.state = "READY", this.answers = a, this.visibleQuestions = n;
1125
+ const s = r ? this.visibleQuestions.findIndex((o) => o.id === r) : -1;
1126
+ return this.stepIndex = s !== -1 ? s : Math.min(this.stepIndex, Math.max(0, this.visibleQuestions.length - 1)), this.suppressStepFocus = !0, this.renderHeader(), this.renderStep(), !0;
1127
+ }
976
1128
  /**
977
1129
  * Jump to the visible question with the given id. Returns true if
978
1130
  * the question is currently visible (and the embed navigated to
@@ -989,7 +1141,7 @@ ${r}
989
1141
  return i === -1 ? !1 : (i === this.stepIndex || (this.flushPendingSave(), this.stepIndex = i, this.renderStep()), !0);
990
1142
  }
991
1143
  }
992
- function ve(t) {
1144
+ function xe(t) {
993
1145
  switch (t.type) {
994
1146
  case "text":
995
1147
  return t.minLength ? `Please enter at least ${t.minLength} characters.` : "This field is required.";
@@ -1003,10 +1155,10 @@ function ve(t) {
1003
1155
  return "Please choose a value.";
1004
1156
  }
1005
1157
  }
1006
- function N(t) {
1158
+ function L(t) {
1007
1159
  return document.querySelector(t)?.textContent?.trim() ?? "";
1008
1160
  }
1009
- function ye() {
1161
+ function Ee() {
1010
1162
  const t = document.querySelector(
1011
1163
  'script[type="application/json"][data-quests-config]'
1012
1164
  );
@@ -1015,49 +1167,50 @@ function ye() {
1015
1167
  if (!e) return null;
1016
1168
  try {
1017
1169
  const i = JSON.parse(e);
1018
- return i.cssSelector && !i.css && (i.css = N(i.cssSelector), delete i.cssSelector), i;
1170
+ return i.cssSelector && !i.css && (i.css = L(i.cssSelector), delete i.cssSelector), i;
1019
1171
  } catch {
1020
1172
  return null;
1021
1173
  }
1022
1174
  }
1023
- function xe(t) {
1175
+ function we(t) {
1024
1176
  const e = t.getAttribute("data-endpoint");
1025
1177
  if (!e) return null;
1026
- const i = t.getAttribute("data-config-url"), a = t.getAttribute("data-api-key"), n = t.getAttribute("data-container"), o = t.getAttribute("data-zindex"), r = t.getAttribute("data-positive-color"), c = t.getAttribute("data-negative-color"), q = t.getAttribute("data-marker-color"), p = t.getAttribute("data-modal-width"), f = t.getAttribute("data-backdrop-opacity"), s = t.getAttribute("data-font-family"), u = t.getAttribute("data-font-size"), d = t.getAttribute("data-css-selector"), m = t.getAttribute("data-auto-advance"), g = t.getAttribute("data-save-debounce-ms"), h = t.getAttribute("data-theme-url"), l = t.getAttribute("data-preset"), w = t.getAttribute("data-theme"), T = t.getAttribute("data-unstyled");
1178
+ const i = t.getAttribute("data-config-url"), a = t.getAttribute("data-api-key"), n = t.getAttribute("data-container"), r = t.getAttribute("data-zindex"), s = t.getAttribute("data-positive-color"), o = t.getAttribute("data-negative-color"), u = t.getAttribute("data-marker-color"), q = t.getAttribute("data-modal-width"), m = t.getAttribute("data-backdrop-opacity"), l = t.getAttribute("data-font-family"), h = t.getAttribute("data-font-size"), c = t.getAttribute("data-css-selector"), p = t.getAttribute("data-auto-advance"), f = t.getAttribute("data-save-debounce-ms"), g = t.getAttribute("data-theme-url"), d = t.getAttribute("data-preset"), b = t.getAttribute("data-theme"), O = t.getAttribute("data-unstyled");
1027
1179
  return {
1028
1180
  endpoint: e,
1029
1181
  configUrl: i ?? void 0,
1030
1182
  apiKey: a ?? void 0,
1031
1183
  container: n ?? void 0,
1032
- zIndex: o ? parseInt(o, 10) : void 0,
1184
+ zIndex: r ? parseInt(r, 10) : void 0,
1033
1185
  colors: {
1034
- positive: r ?? void 0,
1035
- negative: c ?? void 0,
1036
- marker: q ?? void 0
1186
+ positive: s ?? void 0,
1187
+ negative: o ?? void 0,
1188
+ marker: u ?? void 0
1037
1189
  },
1038
- modalWidth: p ? parseInt(p, 10) : void 0,
1039
- backdropOpacity: f ? parseFloat(f) : void 0,
1040
- fontFamily: s ?? void 0,
1041
- fontSize: u ? parseInt(u, 10) : void 0,
1042
- css: d ? N(d) : void 0,
1043
- autoAdvance: m === "true" ? !0 : void 0,
1044
- saveDebounceMs: g ? parseInt(g, 10) : void 0,
1045
- themeUrl: h ?? void 0,
1046
- preset: l || void 0,
1047
- theme: w || void 0,
1048
- unstyled: T === "true" ? !0 : void 0
1190
+ modalWidth: q ? parseInt(q, 10) : void 0,
1191
+ backdropOpacity: m ? parseFloat(m) : void 0,
1192
+ fontFamily: l ?? void 0,
1193
+ fontSize: h ? parseInt(h, 10) : void 0,
1194
+ css: c ? L(c) : void 0,
1195
+ autoAdvance: p === "true" ? !0 : void 0,
1196
+ saveDebounceMs: f ? parseInt(f, 10) : void 0,
1197
+ themeUrl: g ?? void 0,
1198
+ preset: d || void 0,
1199
+ theme: b || void 0,
1200
+ unstyled: O === "true" ? !0 : void 0
1049
1201
  };
1050
1202
  }
1051
1203
  if (typeof document < "u") {
1052
- const t = () => {
1053
- const e = document.currentScript, i = ye(), a = e ? xe(e) : null, n = i ?? a;
1054
- n?.endpoint && (n.configUrl || n.questionnaire) && new be(n);
1204
+ const t = document.currentScript, e = () => {
1205
+ const i = t, a = Ee(), n = i ? we(i) : null, r = a ?? n;
1206
+ r?.endpoint && (r.configUrl || r.questionnaire) && new ye(r);
1055
1207
  };
1056
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : t();
1208
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : e();
1057
1209
  }
1058
1210
  export {
1059
- be as QaidQuests,
1060
- E as evaluateRule,
1061
- J as getVisibleQuestions
1211
+ ye as QaidQuests,
1212
+ C as evaluateRule,
1213
+ Z as getVisibleAnswers,
1214
+ w as getVisibleQuestions
1062
1215
  };
1063
1216
  //# sourceMappingURL=qaid-quests.js.map