!function(){const t="/* MagicPages Search UI Styles - Original Design with mp-search- prefix */\n\n/* Base document styles */\n:root {\n    /* Color system */\n    --color-base-50: 255 255 255;\n    --color-base-100: 250 250 250;\n    --color-base-200: 229 231 235;\n    --color-base-300: 209 213 219;\n    --color-base-700: 55 65 81;\n    --color-base-800: 31 41 55;\n    --color-base-900: 17 24 39;\n    --color-base-950: 3 7 18;\n\n    /* Animation configs */\n    --transition-base: 80ms cubic-bezier(0.4, 0, 0.2, 1);\n    --transition-smooth: 120ms cubic-bezier(0.4, 0, 0.2, 1);\n    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);\n    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n}\n\n/* System/Default theme (light) */\n.mp-search-modal {\n    /* Size multiplier - rem equivalent */\n    --mp-rem: 16px;\n    \n    --color-surface: rgb(252, 252, 252);\n    --color-surface-elevated: rgb(255, 255, 255);\n    --color-surface-hover: rgba(0, 0, 0, 0.04);\n    --color-text: rgb(23, 23, 23);\n    --color-text-secondary: rgb(82, 82, 82);\n    --color-border: rgba(0, 0, 0, 0.08);\n    --color-backdrop: rgba(0, 0, 0, 0.15);\n    --accent-color: var(--ghost-accent-color, #6366f1);\n    --accent-color-hover: color-mix(in srgb, black 15%, var(--accent-color));\n    --color-result-bg: rgb(252, 252, 252);\n    --color-result-hover: color-mix(in srgb, var(--accent-color) 8%, transparent);\n}\n\n/* Dark theme */\n.mp-search-dark {\n    --color-surface: rgb(32, 32, 32);\n    --color-surface-elevated: rgb(45, 45, 45);\n    --color-surface-hover: rgba(255, 255, 255, 0.04);\n    --color-text: rgb(250, 250, 250);\n    --color-text-secondary: rgb(161, 161, 161);\n    --color-border: rgba(255, 255, 255, 0.08);\n    --color-backdrop: rgba(0, 0, 0, 0.4);\n    --accent-color: var(--ghost-accent-color, #818cf8);\n    --accent-color-hover: color-mix(in srgb, white 15%, var(--accent-color));\n    --color-result-bg: rgb(38, 38, 38);\n    --color-result-hover: color-mix(in srgb, var(--accent-color) 8%, transparent);\n}\n\n/* Font presets (`fontFamily` option). The core sets data-font on the host for\n   any value other than 'system'. These are :host rules, so the site's own CSS\n   on `magicpages-search` (outer context) beats them: a publisher can set\n   --mp-font / --mp-font-heading from Code Injection whatever the option says.\n   'system' sets nothing and every font-family below falls back to the system\n   stack the widget has always used. */\n:host([data-font=\"sans\"]) {\n    --mp-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n:host([data-font=\"serif\"]) {\n    --mp-font: ui-serif, Georgia, Cambria, 'Times New Roman', serif;\n}\n\n:host([data-font=\"mono\"]) {\n    --mp-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n}\n\n/* Ghost's {{ghost_head}} sets --gh-font-body / --gh-font-heading only when a\n   custom font is picked under Settings → Design. Otherwise fall back to the\n   theme's own body font, which the core reads at open into --mp-theme-font. */\n:host([data-font=\"theme\"]) {\n    --mp-font: var(--gh-font-body, var(--mp-theme-font, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif));\n    --mp-font-heading: var(--gh-font-heading, var(--mp-font));\n}\n\n/* Base typography for modal content */\n.mp-search-modal {\n    font-family: var(--mp-font, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);\n    line-height: 1.5;\n    font-size: var(--mp-rem);\n    -webkit-text-size-adjust: 100%;\n}\n\n.mp-search-modal * {\n    box-sizing: border-box;\n}\n\n.mp-search-modal button {\n    font-family: inherit;\n    font-size: inherit;\n    line-height: inherit;\n}\n\n/* Utility classes */\n.mp-search-hidden {\n    display: none !important;\n}\n\n/* Modal structure */\n.mp-search-modal {\n    position: fixed;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    display: flex;\n    background-color: var(--color-backdrop);\n    backdrop-filter: blur(4px);\n    align-items: flex-start;\n    justify-content: center;\n    -webkit-tap-highlight-color: transparent;\n    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);\n    /* Above subscribe button on mobile */\n    z-index: 3999999;\n\n    /* The root is a <dialog>, so neutralise the UA chrome it ships with\n       (border, auto margins and a max-width/height that would shrink it away\n       from the full-viewport overlay above). z-index still governs the\n       non-modal fallback path; once showModal() promotes this into the top\n       layer the stacking order is the browser's, not ours, which puts the\n       overlay above Ghost's subscribe button on desktop too. */\n    border: 0;\n    margin: 0;\n    max-width: none;\n    max-height: none;\n}\n\n/* Our own backdrop element provides the scrim, so the top-layer one stays out\n   of the way instead of double-darkening it. */\n.mp-search-modal::backdrop {\n    background: transparent;\n}\n\n@media (min-width: 640px) {\n    .mp-search-modal {\n        /* Below subscribe button on desktop */\n        z-index: 3999997;\n    }\n}\n\n/* Backdrop with glass effect */\n.mp-search-backdrop {\n    position: fixed;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    backdrop-filter: blur(8px);\n    background: var(--color-backdrop);\n    transition: opacity var(--transition-smooth);\n}\n\n/* Modal container and content */\n.mp-search-container {\n    position: relative;\n    z-index: 1;\n    width: 100%;\n    max-width: calc(42 * var(--mp-rem));\n    margin: 0 auto;\n    padding: 0;\n    height: 100vh;\n    display: flex;\n    flex-direction: column;\n    transition: transform 0.1s ease-out;\n}\n\n@media (min-width: 640px) {\n    .mp-search-container {\n        padding: calc(1.25 * var(--mp-rem));\n        height: auto;\n        max-height: 80vh;\n        min-height: 20vh;\n        margin-top: 5vh;\n    }\n}\n\n.mp-search-content {\n    background: var(--color-surface);\n    border: none;\n    border-radius: 0;\n    box-shadow: none;\n    overflow: hidden;\n    width: 100%;\n    position: relative;\n    height: 100%;\n    display: flex;\n    flex-direction: column;\n    /* Ensure content doesn't overflow viewport */\n    max-height: 100%;\n}\n\n@media (min-width: 640px) {\n    .mp-search-content {\n        border: 1px solid var(--color-border);\n        border-radius: calc(0.75 * var(--mp-rem));\n        box-shadow: var(--shadow-lg);\n    }\n}\n\n/* Loading state */\n.mp-search-loading {\n    display: none;\n    padding: calc(2 * var(--mp-rem)) calc(1.25 * var(--mp-rem));\n    text-align: center;\n    color: var(--color-text-secondary);\n}\n\n.mp-search-loading:not(.mp-search-hidden) {\n    display: block;\n}\n\n.mp-search-spinner {\n    display: inline-block;\n    width: calc(2 * var(--mp-rem));\n    height: calc(2 * var(--mp-rem));\n    margin-bottom: calc(1 * var(--mp-rem));\n    border: 2px solid var(--color-border);\n    border-top-color: var(--accent-color);\n    border-radius: 50%;\n    animation: mp-spin 0.8s linear infinite;\n}\n\n@keyframes mp-spin {\n    to {\n        transform: rotate(360deg);\n    }\n}\n\n/* Search header */\n.mp-search-header {\n    align-items: center;\n    border-bottom: 1px solid var(--color-border);\n    padding: calc(0.75 * var(--mp-rem)) calc(1.25 * var(--mp-rem));\n    position: relative;\n    background: var(--color-surface-elevated);\n    display: grid;\n    grid-template-columns: 1fr auto;\n    align-items: center;\n    gap: calc(1 * var(--mp-rem));\n}\n\n@media (min-width: 640px) {\n    .mp-search-header {\n        padding: calc(0.875 * var(--mp-rem)) calc(1.5 * var(--mp-rem));\n    }\n}\n\n.mp-search-form {\n    position: relative;\n    /* Reset Ghost theme form styles that may interfere */\n    padding: 0 !important;\n    margin: 0 !important;\n    border: none !important;\n    border-radius: 0 !important;\n    min-height: auto !important;\n    width: auto !important;\n    background: transparent !important;\n    display: block !important;\n    flex-direction: row !important;\n    align-items: normal !important;\n    gap: 0 !important;\n}\n\n.mp-search-form:before {\n    content: \"\";\n    background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='rgb(55, 65, 81)'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z' /%3E%3C/svg%3E\");\n    height: calc(1.125 * var(--mp-rem));\n    width: calc(1.125 * var(--mp-rem));\n    position: absolute;\n    left: calc(0.75 * var(--mp-rem));\n    top: 50%;\n    transform: translateY(-50%);\n    opacity: 0.7;\n    color: var(--color-text);\n    pointer-events: none;\n    z-index: 1;\n    transition: opacity var(--transition-base);\n}\n\n@media (min-width: 640px) {\n    .mp-search-form:before {\n        left: calc(0.875 * var(--mp-rem));\n    }\n}\n\n.mp-search-dark .mp-search-form:before {\n    background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='rgb(209, 213, 219)'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z' /%3E%3C/svg%3E\");\n}\n\n.mp-search-input {\n    -webkit-appearance: none;\n    background: transparent;\n    border-radius: calc(0.75 * var(--mp-rem));\n    border: 1px solid var(--color-border);\n    box-shadow: var(--shadow-sm);\n    color: var(--color-text);\n    font-size: calc(1 * var(--mp-rem));\n    height: calc(2.75 * var(--mp-rem));\n    outline: none;\n    padding: calc(0.75 * var(--mp-rem)) calc(0.75 * var(--mp-rem)) calc(0.75 * var(--mp-rem)) calc(2.75 * var(--mp-rem));\n    width: 100%;\n    transition: all var(--transition-smooth);\n    background: var(--color-surface);\n    letter-spacing: -0.011em;\n}\n\n/* Hide the search clear button */\n.mp-search-input::-webkit-search-cancel-button {\n    -webkit-appearance: none;\n    display: none;\n}\n\n@media (min-width: 640px) {\n    .mp-search-input {\n        font-size: calc(1.125 * var(--mp-rem));\n        height: calc(3 * var(--mp-rem));\n        padding: calc(0.875 * var(--mp-rem)) calc(0.875 * var(--mp-rem)) calc(0.875 * var(--mp-rem)) calc(3 * var(--mp-rem));\n    }\n}\n\n/* Form controls don't inherit font-family, so the search field has always\n   used the browser's input font. Keep that by default; once a fontFamily\n   preset is chosen, the field follows it like the rest of the surface. */\n:host([data-font]) .mp-search-input {\n    font-family: inherit;\n}\n\n.mp-search-input:focus,\n.mp-search-input:focus-visible {\n    background: var(--color-surface);\n    outline: none;\n    border-color: var(--accent-color);\n    box-shadow: 0 0 0 1px var(--accent-color);\n}\n\n.mp-search-input::placeholder {\n    color: var(--color-text-secondary);\n    opacity: 0.7;\n}\n\n/* Results container */\n.mp-search-results-container {\n    flex: 1;\n    overflow-y: auto;\n    overscroll-behavior: contain;\n    position: relative;\n    scroll-behavior: smooth;\n    padding: calc(0.5 * var(--mp-rem)) 0;\n    -webkit-overflow-scrolling: touch;\n    min-height: 0;\n    background: var(--color-surface);\n    padding: calc(0.75 * var(--mp-rem)) calc(calc(1.5 * var(--mp-rem)) - 6px) calc(0.75 * var(--mp-rem)) calc(1.5 * var(--mp-rem));\n}\n\n@media (min-width: 640px) {\n    .mp-search-results-container {\n        height: auto;\n        max-height: calc(80vh - calc(4 * var(--mp-rem)));\n        padding-bottom: calc(1 * var(--mp-rem));\n    }\n}\n\n.mp-search-results-container::-webkit-scrollbar {\n    width: 6px;\n}\n\n.mp-search-results-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.mp-search-results-container::-webkit-scrollbar-thumb {\n    background: var(--color-border);\n    border-radius: 3px;\n}\n\n.mp-search-results-container > :last-child {\n    margin-bottom: calc(0.75 * var(--mp-rem));\n}\n\n/* Common searches */\n.mp-search-common-searches {\n    padding: calc(0.75 * var(--mp-rem)) 0;\n    padding-right: 6px;\n    margin: 0;\n}\n\n.mp-search-common-searches-title {\n    color: var(--color-text-secondary);\n    font-size: calc(0.75 * var(--mp-rem));\n    font-weight: 600;\n    letter-spacing: 0.05em;\n    margin: 0 0 calc(0.75 * var(--mp-rem));\n    text-transform: uppercase;\n}\n\n#mp-search-common-searches-container {\n    display: flex;\n    flex-direction: column;\n    gap: calc(0.25 * var(--mp-rem));\n}\n\n.mp-search-common-search-btn {\n    background: transparent;\n    border: none;\n    color: var(--color-text);\n    border-radius: calc(0.5 * var(--mp-rem));\n    cursor: pointer;\n    display: flex;\n    align-items: center;\n    width: 100%;\n    padding: calc(0.75 * var(--mp-rem)) calc(1 * var(--mp-rem));\n    text-decoration: none;\n    transition: all var(--transition-base);\n    font-size: calc(0.875 * var(--mp-rem));\n    text-align: left;\n    border: 1px solid transparent;\n}\n\n.mp-search-common-search-btn:hover,\n.mp-search-common-search-btn.mp-search-selected {\n    background: var(--color-result-hover);\n    border-color: var(--accent-color);\n}\n\n/* Author profiles (showAuthorProfiles). The avatar classes are shared with\n   the palette and discovery layouts. */\n.mp-search-authors {\n    padding: calc(0.75 * var(--mp-rem)) 0 0;\n}\n\n.mp-search-authors-title {\n    color: var(--color-text-secondary);\n    font-size: calc(0.75 * var(--mp-rem));\n    font-weight: 600;\n    letter-spacing: 0.05em;\n    margin: 0 0 calc(0.5 * var(--mp-rem));\n    text-transform: uppercase;\n}\n\n.mp-search-authors-list {\n    display: flex;\n    flex-wrap: wrap;\n    gap: calc(0.5 * var(--mp-rem));\n}\n\n.mp-search-author-link {\n    display: inline-flex;\n    align-items: center;\n    gap: calc(0.5 * var(--mp-rem));\n    max-width: 100%;\n    padding: calc(0.375 * var(--mp-rem)) calc(0.875 * var(--mp-rem)) calc(0.375 * var(--mp-rem)) calc(0.375 * var(--mp-rem));\n    border: 1px solid var(--color-border);\n    border-radius: 999px;\n    background: var(--color-result-bg);\n    color: var(--color-text);\n    font-size: calc(0.875 * var(--mp-rem));\n    font-weight: 500;\n    text-decoration: none;\n    transition: background-color var(--transition-base), border-color var(--transition-base);\n}\n\n.mp-search-author-link:hover,\n.mp-search-author-link:focus,\n.mp-search-author-link.mp-search-selected {\n    background: var(--color-result-hover);\n    border-color: var(--accent-color);\n}\n\n.mp-search-author-name {\n    overflow: hidden;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n}\n\n.mp-search-author-avatar {\n    flex: 0 0 auto;\n    width: calc(1.75 * var(--mp-rem));\n    height: calc(1.75 * var(--mp-rem));\n    border-radius: 50%;\n    object-fit: cover;\n    display: block;\n    background: var(--color-result-hover);\n}\n\n.mp-search-author-avatar-empty {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    font-size: calc(0.8125 * var(--mp-rem));\n    font-weight: 600;\n    color: var(--accent-color);\n    background: color-mix(in srgb, var(--accent-color) 12%, transparent);\n}\n\n/* Reader-facing facet filters */\n.mp-search-facets {\n    display: flex;\n    flex-direction: column;\n    gap: calc(0.75 * var(--mp-rem));\n    padding: calc(0.75 * var(--mp-rem)) 0;\n}\n\n.mp-search-facet-group {\n    display: flex;\n    flex-direction: column;\n    gap: calc(0.5 * var(--mp-rem));\n}\n\n.mp-search-facet-group-label {\n    color: var(--color-text-secondary);\n    font-size: calc(0.75 * var(--mp-rem));\n    font-weight: 600;\n    letter-spacing: 0.05em;\n    text-transform: uppercase;\n}\n\n.mp-search-facet-chips {\n    display: flex;\n    flex-wrap: wrap;\n    gap: calc(0.5 * var(--mp-rem));\n}\n\n.mp-search-facet-chip {\n    background: transparent;\n    border: 1px solid var(--color-border, var(--color-result-hover));\n    color: var(--color-text);\n    border-radius: 999px;\n    cursor: pointer;\n    display: inline-flex;\n    align-items: center;\n    gap: calc(0.375 * var(--mp-rem));\n    padding: calc(0.375 * var(--mp-rem)) calc(0.75 * var(--mp-rem));\n    font-size: calc(0.8125 * var(--mp-rem));\n    line-height: 1.2;\n    transition: all var(--transition-base);\n}\n\n.mp-search-facet-chip:hover,\n.mp-search-facet-chip:focus-visible {\n    background: var(--color-result-hover);\n    border-color: var(--accent-color);\n}\n\n.mp-search-facet-chip-selected,\n.mp-search-facet-chip[aria-pressed=\"true\"] {\n    background: var(--accent-color);\n    border-color: var(--accent-color);\n    color: #fff;\n}\n\n.mp-search-facet-chip-count {\n    font-size: calc(0.6875 * var(--mp-rem));\n    font-variant-numeric: tabular-nums;\n    opacity: 0.7;\n}\n\n.mp-search-facet-clear {\n    align-self: flex-start;\n    background: transparent;\n    border: none;\n    color: var(--accent-color);\n    cursor: pointer;\n    font-size: calc(0.8125 * var(--mp-rem));\n    padding: calc(0.25 * var(--mp-rem)) 0;\n    text-decoration: underline;\n    transition: opacity var(--transition-base);\n}\n\n.mp-search-facet-clear:hover,\n.mp-search-facet-clear:focus-visible {\n    opacity: 0.7;\n}\n\n/* Truncation control. Reads as a quieter sibling of the chips it follows —\n   its job is to admit the list is abridged, not to compete with the values. */\n.mp-search-facet-more {\n    align-self: flex-start;\n    background: transparent;\n    border: none;\n    color: var(--accent-color);\n    cursor: pointer;\n    font-size: calc(0.8125 * var(--mp-rem));\n    padding: calc(0.25 * var(--mp-rem)) 0;\n    transition: opacity var(--transition-base);\n}\n\n.mp-search-facet-more:hover {\n    opacity: 0.7;\n    text-decoration: underline;\n}\n\n.mp-search-facet-more:focus-visible {\n    outline: 2px solid var(--accent-color);\n    outline-offset: 2px;\n    border-radius: calc(0.25 * var(--mp-rem));\n}\n\n.mp-search-hits-list {\n    margin-block-start: calc(0.5 * var(--mp-rem));\n    margin-block-end: calc(0.5 * var(--mp-rem));\n}\n\n/* Search result link wrapper */\n.mp-search-result-link {\n    text-decoration: none;\n    color: inherit;\n    display: block;\n}\n\n/* Search results */\n.mp-search-result-item {\n    border-radius: calc(0.75 * var(--mp-rem));\n    display: block;\n    margin: calc(0.5 * var(--mp-rem)) 0;\n    padding: calc(1.25 * var(--mp-rem));\n    text-decoration: none;\n    transition: background-color var(--transition-base), transform var(--transition-base);\n    border: 1px solid transparent;\n    word-break: break-word;\n    background: var(--color-result-bg);\n}\n\n.mp-search-result-link:hover .mp-search-result-item,\n.mp-search-result-link.mp-search-selected .mp-search-result-item,\n.mp-search-result-link:focus .mp-search-result-item {\n    background: var(--color-result-hover);\n    border-color: var(--accent-color);\n    transform: translateX(2px);\n}\n\n.mp-search-result-title {\n    font-family: var(--mp-font-heading, var(--mp-font, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif));\n    color: var(--accent-color);\n    font-size: calc(1.125 * var(--mp-rem));\n    font-weight: 600;\n    line-height: 1.4;\n    margin-top: 0;\n    margin-bottom: calc(0.5 * var(--mp-rem));\n    word-break: break-word;\n    transition: color var(--transition-base);\n}\n\n.mp-search-result-excerpt {\n    color: var(--color-text-secondary);\n    font-size: calc(0.9375 * var(--mp-rem));\n    line-height: 1.6;\n    margin: 0;\n    word-break: break-word;\n}\n\n/* Refined list row: thumbnail + body (title, excerpt, meta line) */\n.mp-search-result-item.mp-search-row {\n    display: flex;\n    gap: calc(0.875 * var(--mp-rem));\n    align-items: flex-start;\n}\n\n.mp-search-row-thumb {\n    flex: 0 0 auto;\n    width: calc(3.5 * var(--mp-rem));\n    height: calc(3.5 * var(--mp-rem));\n    border-radius: calc(0.5 * var(--mp-rem));\n    object-fit: cover;\n    display: block;\n    background: var(--color-result-hover);\n}\n\n.mp-search-row-thumb-empty {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    font-size: calc(1.25 * var(--mp-rem));\n    font-weight: 600;\n    color: var(--accent-color);\n    background: color-mix(in srgb, var(--accent-color) 12%, transparent);\n    text-transform: uppercase;\n}\n\n.mp-search-row-body {\n    flex: 1 1 auto;\n    min-width: 0;\n}\n\n.mp-search-row .mp-search-result-excerpt {\n    /* Clamp to one line in the dense row layout. */\n    display: -webkit-box;\n    -webkit-line-clamp: 1;\n    -webkit-box-orient: vertical;\n    overflow: hidden;\n}\n\n.mp-search-row-meta {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    gap: calc(0.375 * var(--mp-rem));\n    margin-top: calc(0.375 * var(--mp-rem));\n    font-size: calc(0.75 * var(--mp-rem));\n    color: var(--color-text-secondary);\n}\n\n.mp-search-row-meta-tag {\n    color: var(--accent-color);\n}\n\n.mp-search-row-meta-sep {\n    opacity: 0.5;\n}\n\n/* Gated result badge. The free-member badge stays quiet; the paid badge carries\n   the accent, so a reader can tell the two gates apart at a glance. Both derive\n   from the theme tokens, so light and dark follow with no extra rules. */\n.mp-search-gated-badge {\n    display: inline-flex;\n    align-items: center;\n    gap: calc(0.25 * var(--mp-rem));\n    margin-left: calc(0.5 * var(--mp-rem));\n    padding: calc(0.0625 * var(--mp-rem)) calc(0.4 * var(--mp-rem));\n    border-radius: 999px;\n    background: var(--color-result-hover);\n    color: var(--color-text-secondary);\n    font-size: calc(0.6875 * var(--mp-rem));\n    font-weight: 500;\n    letter-spacing: 0.02em;\n    vertical-align: middle;\n    white-space: nowrap;\n}\n\n.mp-search-gated-badge-paid {\n    background: color-mix(in srgb, var(--accent-color) 18%, transparent);\n    color: color-mix(in srgb, var(--accent-color) 85%, var(--color-text));\n    font-weight: 600;\n}\n\n/* Grid (card) layout */\n.mp-search-hits-list.mp-search-grid {\n    display: grid;\n    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));\n    gap: calc(0.75 * var(--mp-rem));\n}\n\n.mp-search-grid .mp-search-result-item {\n    margin: 0;\n    padding: 0;\n    overflow: hidden;\n    height: 100%;\n    display: flex;\n    flex-direction: column;\n}\n\n.mp-search-grid .mp-search-result-link:hover .mp-search-result-item,\n.mp-search-grid .mp-search-result-link.mp-search-selected .mp-search-result-item,\n.mp-search-grid .mp-search-result-link:focus .mp-search-result-item {\n    /* Cards lift instead of nudging sideways like list rows. */\n    transform: translateY(-2px);\n}\n\n.mp-search-card-image {\n    width: 100%;\n    aspect-ratio: 16 / 9;\n    object-fit: cover;\n    display: block;\n}\n\n.mp-search-card-image-empty {\n    background: linear-gradient(135deg, var(--color-result-hover), var(--color-result-bg));\n}\n\n.mp-search-card-body {\n    padding: calc(1 * var(--mp-rem));\n    display: flex;\n    flex-direction: column;\n    gap: calc(0.375 * var(--mp-rem));\n}\n\n.mp-search-card-tags {\n    display: flex;\n    flex-wrap: wrap;\n    gap: calc(0.375 * var(--mp-rem));\n    margin-top: calc(0.25 * var(--mp-rem));\n}\n\n.mp-search-card-tag {\n    background: var(--color-result-hover);\n    border-radius: 999px;\n    color: var(--color-text-secondary);\n    font-size: calc(0.6875 * var(--mp-rem));\n    padding: calc(0.125 * var(--mp-rem)) calc(0.5 * var(--mp-rem));\n}\n\n@media (max-width: 640px) {\n    .mp-search-hits-list.mp-search-grid {\n        grid-template-columns: 1fr;\n    }\n}\n\n/* Keyboard hints */\n.mp-search-hints {\n    display: flex;\n    align-items: center;\n    font-size: calc(0.75 * var(--mp-rem));\n    gap: calc(1 * var(--mp-rem));\n    color: var(--color-text-secondary);\n    white-space: nowrap;\n    user-select: none;\n    margin-right: calc(0.5 * var(--mp-rem));\n}\n\n.mp-search-kbd {\n    background: var(--color-surface-elevated);\n    border: 1px solid var(--color-border);\n    border-radius: calc(0.375 * var(--mp-rem));\n    color: var(--color-text-secondary);\n    font-size: calc(0.75 * var(--mp-rem));\n    padding: calc(0.25 * var(--mp-rem)) calc(0.375 * var(--mp-rem));\n    box-shadow: var(--shadow-sm);\n    font-size: calc(0.75 * var(--mp-rem));\n    font-weight: 500;\n    padding: calc(0.25 * var(--mp-rem)) calc(0.5 * var(--mp-rem));\n    box-shadow: var(--shadow-sm);\n    margin: 0 calc(0.25 * var(--mp-rem));\n}\n\n/* Empty state */\n.mp-search-empty {\n    padding: calc(2.5 * var(--mp-rem)) calc(1.5 * var(--mp-rem));\n    text-align: center;\n}\n\n.mp-search-empty-message {\n    color: var(--color-text-secondary);\n    font-size: calc(1 * var(--mp-rem));\n}\n\n/* Request-failure state. Deliberately distinct from the empty state above: a\n   reader whose request never reached the search host must not be told the\n   archive has nothing on their topic. */\n.mp-search-error {\n    padding: calc(2.5 * var(--mp-rem)) calc(1.5 * var(--mp-rem));\n    text-align: center;\n}\n\n.mp-search-error-title {\n    margin: 0;\n    color: var(--color-text);\n    font-size: calc(1 * var(--mp-rem));\n    font-weight: 600;\n}\n\n.mp-search-error-hint {\n    margin: calc(0.375 * var(--mp-rem)) 0 0;\n    color: var(--color-text-secondary);\n    font-size: calc(0.875 * var(--mp-rem));\n}\n\n/* \"Did you mean …\" prompt. Sits under the empty state's message, because that\n   is the moment it matters: the reader is looking at zero results and this is\n   the one route forward. */\n.mp-search-did-you-mean {\n    margin-top: calc(1 * var(--mp-rem));\n}\n\n.mp-search-did-you-mean-btn {\n    font: inherit;\n    font-size: calc(0.9375 * var(--mp-rem));\n    color: var(--color-text);\n    background: var(--color-surface-elevated);\n    border: 1px solid var(--color-border);\n    border-radius: 9999px;\n    padding: calc(0.4375 * var(--mp-rem)) calc(1 * var(--mp-rem));\n    cursor: pointer;\n    box-shadow: var(--shadow-sm);\n    transition: background var(--transition-base), border-color var(--transition-base);\n}\n\n.mp-search-did-you-mean-btn:hover {\n    background: var(--color-surface-hover);\n    border-color: var(--accent-color);\n}\n\n.mp-search-did-you-mean-btn:focus-visible {\n    outline: 2px solid var(--accent-color);\n    outline-offset: 2px;\n}\n\n.mp-search-did-you-mean-term {\n    color: var(--accent-color);\n    font-weight: 600;\n}\n\n/* Close button */\n.mp-search-close {\n    position: fixed;\n    top: calc(1.25 * var(--mp-rem));\n    right: calc(1.5 * var(--mp-rem));\n    width: calc(2 * var(--mp-rem));\n    height: calc(2 * var(--mp-rem));\n    border-radius: 9999px;\n    border: 1px solid var(--color-border);\n    background: var(--color-surface-elevated);\n    color: var(--color-text-secondary);\n    cursor: pointer;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    transition: all var(--transition-base);\n    font-size: calc(1.25 * var(--mp-rem));\n    line-height: 1;\n    z-index: 50;\n    padding: 0;\n}\n\n.mp-search-close:hover {\n    background: var(--color-surface-hover);\n    color: var(--color-text);\n    border-color: var(--accent-color);\n}\n\n.mp-search-close:focus-visible {\n    outline: none;\n    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--accent-color);\n    border-color: var(--accent-color);\n}\n\n/* Highlight styles */\n.mp-search-highlight,\n.mp-search mark {\n    background: none;\n    background: color-mix(in srgb, var(--accent-color) 15%, transparent);\n    color: color-mix(in srgb, var(--accent-color) 85%, var(--color-text));\n    font-weight: 600;\n    border-radius: 2px;\n    padding: 0 1px;\n}\n\n/* Specific styles for mark tags in search results */\n.mp-search-result-title mark,\n.mp-search-result-excerpt mark {\n    background: color-mix(in srgb, var(--accent-color) 15%, transparent);\n    color: color-mix(in srgb, var(--accent-color) 85%, var(--color-text));\n    font-weight: 600;\n    border-radius: 2px;\n    padding: 0 1px;\n}\n\n/* Mobile optimizations */\n@media (max-width: 640px) {\n    .mp-search-hints {\n        display: none;\n    }\n\n    .mp-search-content {\n        margin-top: 0;\n        border-radius: 0;\n        height: 100vh;\n    }\n\n    .mp-search-container {\n        padding: 0;\n        margin: 0;\n    }\n\n    .mp-search-results-container {\n        padding-bottom: calc(1.5 * var(--mp-rem));\n        max-height: calc(100vh - calc(4 * var(--mp-rem)));\n    }\n}\n\n/* Fix header positioning on mobile */\n@media (max-width: 640px) {\n    .mp-search-header {\n        padding-right: calc(4.25 * var(--mp-rem));\n    }\n}\n";var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.i&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var n=t.default;if("function"==typeof n){var e=function t(){var e=!1;try{e=this instanceof t}catch(t){}return e?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};e.prototype=n.prototype}else e={};return Object.defineProperty(e,"i",{value:!0}),Object.keys(t).forEach(function(n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}),e}var i={},o=function(t,n){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},o(t,n)};function s(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+n+" is not a constructor or null");function e(){this.constructor=t}o(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}var a=function(){return a=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var i in n=arguments[e])Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i]);return t},a.apply(this,arguments)};function c(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]])}return e}function u(t,n,e,r){var i,o=arguments.length,s=o<3?n:null===r?r=Object.getOwnPropertyDescriptor(n,e):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,n,e,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(n,e,s):i(n,e))||s);return o>3&&s&&Object.defineProperty(n,e,s),s}function h(t,n){return function(e,r){n(e,r,t)}}function l(t,n,e,r,i,o){function s(t){if(void 0!==t&&"function"!=typeof t)throw new TypeError("Function expected");return t}for(var a,c=r.kind,u="getter"===c?"get":"setter"===c?"set":"value",h=!n&&t?r.static?t:t.prototype:null,l=n||(h?Object.getOwnPropertyDescriptor(h,r.name):{}),f=!1,d=e.length-1;d>=0;d--){var p={};for(var m in r)p[m]="access"===m?{}:r[m];for(var m in r.access)p.access[m]=r.access[m];p.addInitializer=function(t){if(f)throw new TypeError("Cannot add initializers after decoration has completed");o.push(s(t||null))};var v=(0,e[d])("accessor"===c?{get:l.get,set:l.set}:l[u],p);if("accessor"===c){if(void 0===v)continue;if(null===v||"object"!=typeof v)throw new TypeError("Object expected");(a=s(v.get))&&(l.get=a),(a=s(v.set))&&(l.set=a),(a=s(v.init))&&i.unshift(a)}else(a=s(v))&&("field"===c?i.unshift(a):l[u]=a)}h&&Object.defineProperty(h,r.name,l),f=!0}function f(t,n,e){for(var r=arguments.length>2,i=0;i<n.length;i++)e=r?n[i].call(t,e):n[i].call(t);return r?e:void 0}function d(t){return"symbol"==typeof t?t:"".concat(t)}function p(t,n,e){return"symbol"==typeof n&&(n=n.description?"[".concat(n.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:e?"".concat(e," ",n):n})}function m(t,n){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,n)}function v(t,n,e,r){return new(e||(e=Promise))(function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(s,a)}c((r=r.apply(t,n||[])).next())})}function b(t,n){var e,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(e=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=n.call(t,o)}catch(t){a=[6,t],r=0}finally{e=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var g=Object.create?function(t,n,e,r){void 0===r&&(r=e);var i=Object.getOwnPropertyDescriptor(n,e);i&&!("get"in i?!n.i:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return n[e]}}),Object.defineProperty(t,r,i)}:function(t,n,e,r){void 0===r&&(r=e),t[r]=n[e]};function y(t,n){for(var e in t)"default"===e||Object.prototype.hasOwnProperty.call(n,e)||g(n,t,e)}function w(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,i,o=e.call(t),s=[];try{for(;(void 0===n||n-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(e=o.return)&&e.call(o)}finally{if(i)throw i.error}}return s}function x(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(_(arguments[n]));return t}function O(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var r=Array(t),i=0;for(n=0;n<e;n++)for(var o=arguments[n],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}function R(t,n,e){if(e||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))}function S(t){return this instanceof S?(this.v=t,this):new S(t)}function j(t,n,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=e.apply(t,n||[]),o=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(t){return function(n){return Promise.resolve(n).then(t,u)}}),r[Symbol.asyncIterator]=function(){return this},r;function s(t,n){i[t]&&(r[t]=function(n){return new Promise(function(e,r){o.push([t,n,e,r])>1||a(t,n)})},n&&(r[t]=n(r[t])))}function a(t,n){try{(e=i[t](n)).value instanceof S?Promise.resolve(e.value.v).then(c,u):h(o[0][2],e)}catch(t){h(o[0][3],t)}var e}function c(t){a("next",t)}function u(t){a("throw",t)}function h(t,n){t(n),o.shift(),o.length&&a(o[0][0],o[0][1])}}function k(t){var n,e;return n={},r("next"),r("throw",function(t){throw t}),r("return"),n[Symbol.iterator]=function(){return this},n;function r(r,i){n[r]=t[r]?function(n){return(e=!e)?{value:S(t[r](n)),done:!1}:i?i(n):n}:i}}function $(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,e=t[Symbol.asyncIterator];return e?e.call(t):(t=w(t),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(e){n[e]=t[e]&&function(n){return new Promise(function(r,i){!function(t,n,e,r){Promise.resolve(r).then(function(n){t({value:n,done:e})},n)}(r,i,(n=t[e](n)).done,n.value)})}}}function E(t,n){return Object.defineProperty?Object.defineProperty(t,"raw",{value:n}):t.raw=n,t}var C=Object.create?function(t,n){Object.defineProperty(t,"default",{enumerable:!0,value:n})}:function(t,n){t.default=n},T=function(t){return T=Object.getOwnPropertyNames||function(t){var n=[];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[n.length]=e);return n},T(t)};function A(t){if(t&&t.i)return t;var n={};if(null!=t)for(var e=T(t),r=0;r<e.length;r++)"default"!==e[r]&&g(n,t,e[r]);return C(n,t),n}function P(t){return t&&t.i?t:{default:t}}function M(t,n,e,r){if("a"===e&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?t!==n||!r:!n.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===e?r:"a"===e?r.call(t):r?r.value:n.get(t)}function N(t,n,e,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?t!==n||!i:!n.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,e):i?i.value=e:n.set(t,e),e}function U(t,n){if(null===n||"object"!=typeof n&&"function"!=typeof n)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof t?n===t:t.has(n)}function I(t,n,e){if(null!=n){if("object"!=typeof n&&"function"!=typeof n)throw new TypeError("Object expected.");var r,i;if(e){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=n[Symbol.asyncDispose]}if(void 0===r){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=n[Symbol.dispose],e&&(i=r)}if("function"!=typeof r)throw new TypeError("Object not disposable.");i&&(r=function(){try{i.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:n,dispose:r,async:e})}else e&&t.stack.push({async:!0});return n}var q="function"==typeof SuppressedError?SuppressedError:function(t,n,e){var r=Error(e);return r.name="SuppressedError",r.error=t,r.suppressed=n,r};function F(t){function n(n){t.error=t.hasError?new q(n,t.error,"An error was suppressed during disposal."):n,t.hasError=!0}var e,r=0;return function i(){for(;e=t.stack.pop();)try{if(!e.async&&1===r)return r=0,t.stack.push(e),Promise.resolve().then(i);if(e.dispose){var o=e.dispose.call(e.value);if(e.async)return r|=2,Promise.resolve(o).then(i,function(t){return n(t),i()})}else r|=1}catch(t){n(t)}if(1===r)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}()}function L(t,n){return"string"==typeof t&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,e,r,i,o){return e?n?".jsx":".js":!r||i&&o?r+i+"."+o.toLowerCase()+"js":t}):t}const D={o:s,u:a,h:c,l:u,p:h,m:l,_:f,O:d,R:p,S:m,j:v,k:b,$:g,C:y,T:w,A:_,P:x,M:O,N:R,U:S,I:j,F:k,L:$,D:E,B:A,H:P,J:M,G:N,K:U,W:I,X:F,Y:L},z=r(Object.freeze(Object.defineProperty({__proto__:null,W:I,get u(){return a},F:k,I:j,L:$,U:S,j:v,J:M,K:U,G:N,$:g,l:u,X:F,m:l,C:y,o:s,k:b,H:P,B:A,D:E,S:m,p:h,O:d,A:_,h:c,Y:L,_:f,R:p,P:x,N:R,M:O,T:w,default:D},Symbol.toStringTag,{value:"Module"})));var B,H={},J={},G={exports:{}},K=G.exports;function W(){return B||(B=1,n=K,e=function(){var t=function(){},n="undefined",e=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],i={},o=null;function s(t,n){var e=t[n];if("function"==typeof e.bind)return e.bind(t);try{return Function.prototype.bind.call(e,t)}catch(n){return function(){return Function.prototype.apply.call(e,t,arguments)}}}function a(){console.log&&(console.log.apply||Function.prototype.apply.call(console.log,console,arguments))}function c(){for(var e=this.getLevel(),i=0;i<r.length;i++){var o=r[i];this[o]=i<e?t:this.methodFactory(o,e,this.name)}if(this.log=this.debug,typeof console===n&&e<this.levels.SILENT)return"No console available for logging"}function u(t){return function(){typeof console!==n&&(c.call(this),this[t].apply(this,arguments))}}function h(r,i,o){return function(r){return"debug"===r&&(r="log"),typeof console!==n&&("trace"===r&&e?a:void 0!==console[r]?s(console,r):void 0!==console.log?s(console,"log"):t)}(r)||u.apply(this,arguments)}function l(t,e){var s,a,u,l=this,f="loglevel";function d(){var t;if(typeof window!==n&&f){try{t=window.localStorage[f]}catch(t){}if(typeof t===n)try{var e=window.document.cookie,r=encodeURIComponent(f),i=e.indexOf(r+"=");-1!==i&&(t=/^([^;]+)/.exec(e.slice(i+r.length+1))[1])}catch(t){}return void 0===l.levels[t]&&(t=void 0),t}}function p(t){var n=t;if("string"==typeof n&&void 0!==l.levels[n.toUpperCase()]&&(n=l.levels[n.toUpperCase()]),"number"==typeof n&&n>=0&&n<=l.levels.SILENT)return n;throw new TypeError("log.setLevel() called with invalid level: "+t)}"string"==typeof t?f+=":"+t:"symbol"==typeof t&&(f=void 0),l.name=t,l.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},l.methodFactory=e||h,l.getLevel=function(){return null!=u?u:null!=a?a:s},l.setLevel=function(t,e){return u=p(t),!1!==e&&function(t){var e=(r[t]||"silent").toUpperCase();if(typeof window!==n&&f){try{return void(window.localStorage[f]=e)}catch(t){}try{window.document.cookie=encodeURIComponent(f)+"="+e+";"}catch(t){}}}(u),c.call(l)},l.setDefaultLevel=function(t){a=p(t),d()||l.setLevel(t,!1)},l.resetLevel=function(){u=null,function(){if(typeof window!==n&&f){try{window.localStorage.removeItem(f)}catch(t){}try{window.document.cookie=encodeURIComponent(f)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(t){}}}(),c.call(l)},l.enableAll=function(t){l.setLevel(l.levels.TRACE,t)},l.disableAll=function(t){l.setLevel(l.levels.SILENT,t)},l.rebuild=function(){if(o!==l&&(s=p(o.getLevel())),c.call(l),o===l)for(var t in i)i[t].rebuild()},s=p(o?o.getLevel():"WARN");var m=d();null!=m&&(u=p(m)),c.call(l)}(o=new l).getLogger=function(t){if("symbol"!=typeof t&&"string"!=typeof t||""===t)throw new TypeError("You must supply a name when creating a logger.");var n=i[t];return n||(n=i[t]=new l(t,o.methodFactory)),n};var f=typeof window!==n?window.log:void 0;return o.noConflict=function(){return typeof window!==n&&window.log===o&&(window.log=f),o},o.getLoggers=function(){return i},o.default=o,o},(t=G).exports?t.exports=e():n.log=e()),G.exports;var t,n,e}var X,Y,V={},Z={},Q={};function tt(){if(X)return Q;X=1,Object.defineProperty(Q,"i",{value:!0});var t=z,n=function(n){function e(t,e,r){var i=this.constructor,o=n.call(this,t)||this;return o.name=i.name,o.httpBody=e,o.httpStatus=r,Object.setPrototypeOf(o,i.prototype),o}return t.o(e,n),e}(Error);return Q.default=n,Q}var nt,et,rt,it,ot,st,at,ct,ut,ht,lt={},ft={},dt={},pt={},mt={},vt={},bt={},gt={};function yt(){if(ut)return V;ut=1,Object.defineProperty(V,"i",{value:!0}),V.ImportError=V.TypesenseError=V.ServerError=V.RequestUnauthorized=V.RequestMalformed=V.ObjectUnprocessable=V.ObjectNotFound=V.ObjectAlreadyExists=V.MissingConfigurationError=V.HTTPError=void 0;var t=z,n=t.H(function(){if(Y)return Z;Y=1,Object.defineProperty(Z,"i",{value:!0});var t=z,n=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t.o(e,n),e}(t.H(tt()).default);return Z.default=n,Z}());V.HTTPError=n.default;var e=t.H(function(){if(nt)return lt;nt=1,Object.defineProperty(lt,"i",{value:!0});var t=z,n=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t.o(e,n),e}(t.H(tt()).default);return lt.default=n,lt}());V.MissingConfigurationError=e.default;var r=t.H(function(){if(et)return ft;et=1,Object.defineProperty(ft,"i",{value:!0});var t=z,n=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t.o(e,n),e}(t.H(tt()).default);return ft.default=n,ft}());V.ObjectAlreadyExists=r.default;var i=t.H(function(){if(rt)return dt;rt=1,Object.defineProperty(dt,"i",{value:!0});var t=z,n=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t.o(e,n),e}(t.H(tt()).default);return dt.default=n,dt}());V.ObjectNotFound=i.default;var o=t.H(function(){if(it)return pt;it=1,Object.defineProperty(pt,"i",{value:!0});var t=z,n=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t.o(e,n),e}(t.H(tt()).default);return pt.default=n,pt}());V.ObjectUnprocessable=o.default;var s=t.H(function(){if(ot)return mt;ot=1,Object.defineProperty(mt,"i",{value:!0});var t=z,n=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t.o(e,n),e}(t.H(tt()).default);return mt.default=n,mt}());V.RequestMalformed=s.default;var a=t.H(function(){if(st)return vt;st=1,Object.defineProperty(vt,"i",{value:!0});var t=z,n=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t.o(e,n),e}(t.H(tt()).default);return vt.default=n,vt}());V.RequestUnauthorized=a.default;var c=t.H(function(){if(at)return bt;at=1,Object.defineProperty(bt,"i",{value:!0});var t=z,n=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return t.o(e,n),e}(t.H(tt()).default);return bt.default=n,bt}());V.ServerError=c.default;var u=t.H(function(){if(ct)return gt;ct=1,Object.defineProperty(gt,"i",{value:!0});var t=z,n=function(n){function e(t,e,r){var i=n.call(this,t)||this;return i.importResults=e,i.payload=r,i}return t.o(e,n),e}(t.H(tt()).default);return gt.default=n,gt}());V.ImportError=u.default;var h=t.H(tt());return V.TypesenseError=h.default,V}function wt(){if(ht)return J;ht=1,Object.defineProperty(J,"i",{value:!0});var t=z,n=t.B(W()),e=yt(),r=function(){function r(e){var r=this;this.nodes=e.nodes||[],this.nodes=this.nodes.map(function(t){return r.setDefaultPathInNode(t)}).map(function(t){return r.setDefaultPortInNode(t)}).map(function(n){return t.u({},n)}),null==e.randomizeNodes&&(e.randomizeNodes=!0),!0===e.randomizeNodes&&this.shuffleArray(this.nodes),this.nearestNode=e.nearestNode,this.nearestNode=this.setDefaultPathInNode(this.nearestNode),this.nearestNode=this.setDefaultPortInNode(this.nearestNode),this.connectionTimeoutSeconds=e.connectionTimeoutSeconds||e.timeoutSeconds||5,this.healthcheckIntervalSeconds=e.healthcheckIntervalSeconds||60,this.numRetries=(void 0!==e.numRetries&&e.numRetries>=0?e.numRetries:this.nodes.length+(null==this.nearestNode?0:1))||3,this.retryIntervalSeconds=e.retryIntervalSeconds||.1,this.apiKey=e.apiKey,this.sendApiKeyAsQueryParam=e.sendApiKeyAsQueryParam,this.cacheSearchResultsForSeconds=e.cacheSearchResultsForSeconds||0,this.useServerSideSearchCache=e.useServerSideSearchCache||!1,this.axiosAdapter=e.axiosAdapter,this.logger=e.logger||n,this.logLevel=e.logLevel||"warn",this.logger.setLevel(this.logLevel),this.additionalHeaders=e.additionalHeaders,this.httpAgent=e.httpAgent,this.httpsAgent=e.httpsAgent,this.paramsSerializer=e.paramsSerializer,this.showDeprecationWarnings(e),this.validate()}return r.prototype.validate=function(){if(null==this.nodes||0===this.nodes.length||this.validateNodes())throw new e.MissingConfigurationError("Ensure that nodes[].protocol, nodes[].host and nodes[].port are set");if(null!=this.nearestNode&&this.isNodeMissingAnyParameters(this.nearestNode))throw new e.MissingConfigurationError("Ensure that nearestNodes.protocol, nearestNodes.host and nearestNodes.port are set");if(null==this.apiKey)throw new e.MissingConfigurationError("Ensure that apiKey is set");return!0},r.prototype.validateNodes=function(){var t=this;return this.nodes.some(function(n){return t.isNodeMissingAnyParameters(n)})},r.prototype.isNodeMissingAnyParameters=function(t){return!["protocol","host","port","path"].every(function(n){return t.hasOwnProperty(n)})&&null==t.url},r.prototype.setDefaultPathInNode=function(t){return null==t||t.hasOwnProperty("path")||(t.path=""),t},r.prototype.setDefaultPortInNode=function(t){if(null!=t&&!t.hasOwnProperty("port")&&t.hasOwnProperty("protocol"))switch(t.protocol){case"https":t.port=443;break;case"http":t.port=80}return t},r.prototype.showDeprecationWarnings=function(t){t.timeoutSeconds&&this.logger.warn("Deprecation warning: timeoutSeconds is now renamed to connectionTimeoutSeconds"),t.masterNode&&this.logger.warn("Deprecation warning: masterNode is now consolidated to nodes, starting with Typesense Server v0.12"),t.readReplicaNodes&&this.logger.warn("Deprecation warning: readReplicaNodes is now consolidated to nodes, starting with Typesense Server v0.12")},r.prototype.shuffleArray=function(t){for(var n,e=t.length-1;e>0;e--){var r=Math.floor(Math.random()*(e+1));n=[t[r],t[e]],t[e]=n[0],t[r]=n[1]}},r}();return J.default=r,J}var _t,xt,Ot={};function Rt(){if(xt)return _t;function t(t,n){return function(){return t.apply(n,arguments)}}xt=1;const{toString:e}=Object.prototype,{getPrototypeOf:r}=Object,{iterator:i,toStringTag:o}=Symbol,s=(({hasOwnProperty:t})=>(n,e)=>t.call(n,e))(Object.prototype),a=t=>"string"==typeof t&&("__proto__"===t||"constructor"===t||"prototype"===t),c=(t,n,e)=>t===Object.prototype||!e&&null===n,u=(t,n)=>{let e=t;const i=[];for(;null!=e;){if(-1!==i.indexOf(e))return!1;i.push(e);const o=r(e);if(c(e,o,e===t))return!1;if(s(e,n))return!0;e=o}return!1},h=(l=Object.create(null),t=>{const n=e.call(t);return l[n]||(l[n]=n.slice(8,-1).toLowerCase())});var l;const f=t=>(t=t.toLowerCase(),n=>h(n)===t),d=t=>n=>typeof n===t,{isArray:p}=Array,m=d("undefined");function v(t){return null!==t&&!m(t)&&null!==t.constructor&&!m(t.constructor)&&y(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const b=f("ArrayBuffer"),g=d("string"),y=d("function"),w=d("number"),_=t=>null!==t&&"object"==typeof t,x=t=>{if(!_(t))return!1;const n=r(t);return!(null!==n&&n!==Object.prototype&&null!==r(n)||u(t,o)||u(t,i))},O=f("Date"),R=f("File"),S=f("Blob"),j=f("FileList"),k=f("Set"),$="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n?n:{},E=void 0!==$.FormData?$.FormData:void 0,C=f("URLSearchParams"),[T,A,P,M]=["ReadableStream","Request","Response","Headers"].map(f);function N(t,n,{allOwnKeys:e=!1}={}){if(null==t)return;let r,i;if("object"!=typeof t&&(t=[t]),p(t))for(r=0,i=t.length;r<i;r++)n.call(null,t[r],r,t);else{if(v(t))return;const i=e?Object.getOwnPropertyNames(t):Object.keys(t),o=i.length;let s;for(r=0;r<o;r++)s=i[r],n.call(null,t[s],s,t)}}function U(t,n){if(v(t))return null;n=n.toLowerCase();const e=Object.keys(t);let r,i=e.length;for(;i-- >0;)if(r=e[i],n===r.toLowerCase())return r;return null}const I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:n,q=t=>!m(t)&&t!==I,F=(L="undefined"!=typeof Uint8Array&&r(Uint8Array),t=>L&&t instanceof L);var L;const D=f("HTMLFormElement"),{propertyIsEnumerable:z}=Object.prototype,B=f("RegExp"),H=(t,n)=>{const e=Object.getOwnPropertyDescriptors(t),r={};N(e,(e,i)=>{let o;!1!==(o=n(e,i,t))&&(r[i]=o||e)}),Object.defineProperties(t,r)},J=f("AsyncFunction"),G=(K="function"==typeof setImmediate,W=y(I.postMessage),K?setImmediate:W?(X="axios@"+Math.random(),Y=[],I.addEventListener("message",({source:t,data:n})=>{t===I&&n===X&&Y.length&&Y.shift()()},!1),t=>{Y.push(t),I.postMessage(X,"*")}):t=>setTimeout(t));var K,W,X,Y;const V="undefined"!=typeof queueMicrotask?queueMicrotask.bind(I):"undefined"!=typeof process&&process.nextTick||G,Z=t=>null!=t&&y(t[i]);var Q={isArray:p,isArrayBuffer:b,isBuffer:v,isFormData:t=>{if(!t)return!1;if(E&&t instanceof E)return!0;const n=r(t);if(!n||n===Object.prototype)return!1;if(!y(t.append))return!1;const e=h(t);return"formdata"===e||"object"===e&&y(t.toString)&&"[object FormData]"===t.toString()},isArrayBufferView:function(t){let n;return n="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&b(t.buffer),n},isString:g,isNumber:w,isBoolean:t=>!0===t||!1===t,isObject:_,isPlainObject:x,isEmptyObject:t=>{if(!_(t)||v(t))return!1;try{return 0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype}catch(t){return!1}},isReadableStream:T,isRequest:A,isResponse:P,isHeaders:M,isUndefined:m,isDate:O,isFile:R,isReactNativeBlob:t=>!(!t||void 0===t.uri),isReactNative:t=>t&&void 0!==t.getParts,isBlob:S,isRegExp:B,isFunction:y,isStream:t=>_(t)&&y(t.pipe),isURLSearchParams:C,isTypedArray:F,isFileList:j,forEach:N,merge:function t(...n){const{caseless:e,skipUndefined:r}=q(this)&&this||{},i={},o=(n,o)=>{if("__proto__"===o||"constructor"===o||"prototype"===o)return;const a=e&&"string"==typeof o&&U(i,o)||o,c=s(i,a)?i[a]:void 0;x(c)&&x(n)?i[a]=t(c,n):x(n)?i[a]=t({},n):p(n)?i[a]=n.slice():r&&m(n)||(i[a]=n)};for(let t=0,e=n.length;t<e;t++){const e=n[t];if(!e||v(e))continue;if(N(e,o),"object"!=typeof e||p(e))continue;const r=Object.getOwnPropertySymbols(e);for(let t=0;t<r.length;t++){const n=r[t];z.call(e,n)&&o(e[n],n)}}return i},extend:(n,e,r,{allOwnKeys:i}={})=>(N(e,(e,i)=>{r&&y(e)?Object.defineProperty(n,i,{__proto__:null,value:t(e,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(n,i,{__proto__:null,value:e,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),n),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,n,e,r)=>{t.prototype=Object.create(n.prototype,r),Object.defineProperty(t.prototype,"constructor",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{__proto__:null,value:n.prototype}),e&&Object.assign(t.prototype,e)},toFlatObject:(t,n,e,i)=>{let o,s,a;const c={};if(n=n||{},null==t)return n;do{for(o=Object.getOwnPropertyNames(t),s=o.length;s-- >0;)a=o[s],i&&!i(a,t,n)||c[a]||(n[a]=t[a],c[a]=!0);t=!1!==e&&r(t)}while(t&&(!e||e(t,n))&&t!==Object.prototype);return n},kindOf:h,kindOfTest:f,endsWith:(t,n,e)=>{t+="",(void 0===e||e>t.length)&&(e=t.length),e-=n.length;const r=t.indexOf(n,e);return-1!==r&&r===e},toArray:t=>{if(!t)return null;if(p(t))return t;let n=t.length;if(!w(n))return null;const e=Array(n);for(;n-- >0;)e[n]=t[n];return e},forEachEntry:(t,n)=>{const e=(t&&t[i]).call(t);let r;for(;(r=e.next())&&!r.done;){const e=r.value;n.call(t,e[0],e[1])}},matchAll:(t,n)=>{let e;const r=[];for(;null!==(e=t.exec(n));)r.push(e);return r},isHTMLForm:D,hasOwnProperty:s,hasOwnProp:s,hasOwnInPrototypeChain:u,getSafeProp:(t,n)=>null!=t&&u(t,n)?t[n]:void 0,toSafeFlatObject:t=>{if(null==t||"object"!=typeof t&&"function"!=typeof t)return t;const n=r(t);if(null===n&&(t=>{if(!Object.isExtensible(t))return!1;const n=Object.getOwnPropertyNames(t);return Object.getOwnPropertySymbols&&n.push(...Object.getOwnPropertySymbols(t)),n.every(n=>{if(a(n))return!1;const e=Object.getOwnPropertyDescriptor(t,n);return!!e&&e.configurable&&!0===e.writable})})(t))return t;const e=Object.create(null),i=Object.create(null),o=[];let u=t;for(;null!=u&&-1===o.indexOf(u);){o.push(u);const h=u===t?n:r(u);if(c(u,h,u===t))break;const l=Object.getOwnPropertyNames(u);Object.getOwnPropertySymbols&&l.push(...Object.getOwnPropertySymbols(u));for(const n of l)a(n)||s(i,n)||(e[n]=t[n],i[n]=!0);u=h}return e},reduceDescriptors:H,freezeMethods:t=>{H(t,(n,e)=>{if(y(t)&&["arguments","caller","callee"].includes(e))return!1;const r=t[e];y(r)&&(n.enumerable=!1,"writable"in n?n.writable=!1:n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+e+"'")}))})},toObjectSet:(t,n)=>{const e={},r=t=>{t.forEach(t=>{e[t]=!0})};return p(t)?r(t):r((t+"").split(n)),e},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,e){return n.toUpperCase()+e}),noop:()=>{},toFiniteNumber:(t,n)=>null!=t&&Number.isFinite(t=+t)?t:n,findKey:U,global:I,isContextDefined:q,isSpecCompliantForm:function(t){return!!(t&&y(t.append)&&"FormData"===t[o]&&t[i])},toJSONObject:t=>{const n=new WeakSet,e=t=>{if(_(t)){if(n.has(t))return;if(v(t))return t;if(!("toJSON"in t)){let r;if(n.add(t),k(t)){r=[];for(const n of t){const t=e(n);!m(t)&&r.push(t)}}else r=p(t)?[]:{},N(t,(t,n)=>{const i=e(t);!m(i)&&(r[n]=i)});return n.delete(t),r}}return t};return e(t)},isAsyncFn:J,isThenable:t=>t&&(_(t)||y(t))&&y(t.then)&&y(t.catch),setImmediate:G,asap:V,isIterable:Z,isSafeIterable:t=>null!=t&&u(t,i)&&Z(t)};const tt=Q.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),nt=RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),et=RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function rt(t,n){return Q.isArray(t)?t.map(t=>rt(t,n)):function(t){let n=0,e=t.length;for(;n<e;){const e=t.charCodeAt(n);if(9!==e&&32!==e)break;n+=1}for(;e>n;){const n=t.charCodeAt(e-1);if(9!==n&&32!==n)break;e-=1}return 0===n&&e===t.length?t:t.slice(n,e)}((t+"").replace(n,""))}function it(t){const n=Object.create(null);return Q.forEach(t.toJSON(),(t,e)=>{n[e]=(t=>rt(t,et))(t)}),n}const ot=Symbol("internals");function st(t){return t&&(t+"").trim().toLowerCase()}function at(t){return!1===t||null==t?t:Q.isArray(t)?t.map(at):(t=>rt(t,nt))(t+"")}const ct=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function ut(t){let n=0,e=t.length;for(;n<e;){const e=t.charCodeAt(n);if(9!==e&&32!==e)break;n+=1}for(;e>n;){const n=t.charCodeAt(e-1);if(9!==n&&32!==n)break;e-=1}return 0===n&&e===t.length?t:t.slice(n,e)}function ht(t,n,e,r,i){return Q.isFunction(r)?r.call(this,n,e):(i&&(n=e),Q.isString(n)?Q.isString(r)?-1!==n.indexOf(r):Q.isRegExp(r)?r.test(n):void 0:void 0)}class lt{constructor(t){t&&this.set(t)}set(t,n,e){const r=this;function i(t,n,e){const i=st(n);if(!i)return;const o=Q.findKey(r,i);(!o||void 0===r[o]||!0===e||void 0===e&&!1!==r[o])&&(r[o||n]=at(t))}const o=(t,n)=>Q.forEach(t,(t,e)=>i(t,e,n));if(Q.isPlainObject(t)||t instanceof this.constructor)o(t,n);else if(Q.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))o((t=>{const n={};let e,r,i;return t&&t.split("\n").forEach(function(t){i=t.indexOf(":"),e=t.substring(0,i).trim().toLowerCase(),r=t.substring(i+1).trim();const o=Q.hasOwnProp(n,e);!e||o&&Q.hasOwnProp(tt,e)||("set-cookie"===e?o?n[e].push(r):n[e]=[r]:n[e]=o?n[e]+", "+r:r)}),n})(t),n);else if(Q.isObject(t)&&Q.isSafeIterable(t)){let e,r,i=Object.create(null);for(const n of t){if(!Q.isArray(n))throw new TypeError("Object iterator must return a key-value pair");r=n[0],Q.hasOwnProp(i,r)?(e=i[r],i[r]=Q.isArray(e)?[...e,n[1]]:[e,n[1]]):i[r]=n[1]}o(i,n)}else null!=t&&i(n,t,e);return this}get(t,n){if(t=st(t)){const e=Q.findKey(this,t);if(e){const t=this[e];if(!n)return t;if(!0===n)return function(t){const n=Object.create(null),e=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=e.exec(t);)n[r[1]]=r[2];return n}(t);if(Q.isFunction(n))return n.call(this,t,e);if(Q.isRegExp(n))return n.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=st(t)){const e=Q.findKey(this,t);return!(!e||void 0===this[e]||n&&!ht(0,this[e],e,n))}return!1}delete(t,n){const e=this;let r=!1;function i(t){if(t=st(t)){const i=Q.findKey(e,t);!i||n&&!ht(0,e[i],i,n)||(delete e[i],r=!0)}}return Q.isArray(t)?t.forEach(i):i(t),r}clear(t){const n=Object.keys(this);let e=n.length,r=!1;for(;e--;){const i=n[e];t&&!ht(0,this[i],i,t,!0)||(delete this[i],r=!0)}return r}normalize(t){const n=this,e={};return Q.forEach(this,(r,i)=>{const o=Q.findKey(e,i);if(o)return n[o]=at(r),void delete n[i];const s=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,e)=>n.toUpperCase()+e)}(i):(i+"").trim();s!==i&&delete n[i],n[s]=at(r),e[s]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return Q.forEach(this,(e,r)=>{null!=e&&!1!==e&&(n[r]=t&&Q.isArray(e)?e.join(", "):e)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join("\n")}getSetCookie(){const t=this.get("set-cookie");return Q.isArray(t)?t:null==t||!1===t?[]:[t]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static parseParameters(t){return function(t){const n=Object.create(null),e=t+"";let r=0,i=!1,o=!1;function s(t){const i=ut(e.slice(r,t)),o=i.indexOf("=");if(o<1)return;const s=ut(i.slice(0,o));if(!ct.test(s))return;const a=s.toLowerCase();if("__proto__"===a||"constructor"===a||"prototype"===a)return;const c=ut(i.slice(o+1));n[a]=function(t){const n=t.length-1;if(n<1||34!==t.charCodeAt(0)||34!==t.charCodeAt(n))return t;let e="";for(let r=1;r<n;r++){const i=t.charCodeAt(r);if(34===i)return t;if(92===i&&(r+=1,r>=n))return t;e+=t[r]}return e}(c)}for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);i?o?o=!1:92===n?o=!0:34===n&&(i=!1):34===n?i=!0:44!==n&&59!==n||(s(t),r=t+1)}return s(e.length),n}(t)}static concat(t,...n){const e=new this(t);return n.forEach(t=>e.set(t)),e}static accessor(t){const n=(this[ot]=this[ot]={accessors:{}}).accessors,e=this.prototype;function r(t){const r=st(t);n[r]||(function(t,n){const e=Q.toCamelCase(" "+n);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+e,{__proto__:null,value:function(t,e,i){return this[r].call(this,n,t,e,i)},configurable:!0})})}(e,t),n[r]=!0)}return Q.isArray(t)?t.forEach(r):r(t),this}}lt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Q.reduceDescriptors(lt.prototype,({value:t},n)=>{let e=n[0].toUpperCase()+n.slice(1);return{get:()=>t,set(t){this[e]=t}}}),Q.freezeMethods(lt);const ft="[REDACTED ****]";function dt(t){try{return t+""}catch(t){return""}}class pt extends Error{static from(t,n,e,r,i,o){let s=t.message;!s&&Q.isArray(t.errors)&&t.errors.length&&(s=function(t){return t.errors.map(t=>{try{return t&&t.message?dt(t.message):dt(t)}catch(t){return""}}).filter(Boolean).join("; ")||t.name||"AggregateError"}(t));const a=new pt(s,n||t.code,e,r,i);return Object.defineProperty(a,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),a.name=t.name,null!=t.status&&null==a.status&&(a.status=t.status),o&&Object.assign(a,o),a}constructor(t,n,e,r,i){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),e&&(this.config=e),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){const t=this.config,n=t&&Q.hasOwnProp(t,"redact")?t.redact:void 0,e=Q.isArray(n)&&n.length>0?function(t,n){const e=new Set(n.map(t=>(t+"").toLowerCase())),r=[],i=t=>{if(null===t||"object"!=typeof t)return t;if(Q.isBuffer(t))return t;if(-1!==r.indexOf(t))return;let n;if(t instanceof lt&&(t=t.toJSON()),r.push(t),Q.isArray(t))n=[],t.forEach((t,e)=>{const r=i(t);Q.isUndefined(r)||(n[e]=r)});else{if(!Q.isPlainObject(t)&&function(t){if(Q.hasOwnProp(t,"toJSON"))return!0;let n=Object.getPrototypeOf(t);for(;n&&n!==Object.prototype;){if(Q.hasOwnProp(n,"toJSON"))return!0;n=Object.getPrototypeOf(n)}return!1}(t))return r.pop(),t;n=Object.create(null);for(const[r,o]of Object.entries(t)){const t=e.has(r.toLowerCase())?ft:i(o);Q.isUndefined(t)||(n[r]=t)}}return r.pop(),n};return i(t)}(t,n):Q.toJSONObject(t);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:e,code:this.code,status:this.status}}}function mt(t){return Q.isPlainObject(t)||Q.isArray(t)}function vt(t){return Q.endsWith(t,"[]")?t.slice(0,-2):t}function bt(t,n,e){return t?t.concat(n).map(function(t,n){return t=vt(t),!e&&n?"["+t+"]":t}).join(e?".":""):n}pt.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",pt.ERR_BAD_OPTION="ERR_BAD_OPTION",pt.ECONNABORTED="ECONNABORTED",pt.ETIMEDOUT="ETIMEDOUT",pt.ECONNREFUSED="ECONNREFUSED",pt.ERR_NETWORK="ERR_NETWORK",pt.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",pt.ERR_DEPRECATED="ERR_DEPRECATED",pt.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",pt.ERR_BAD_REQUEST="ERR_BAD_REQUEST",pt.ERR_CANCELED="ERR_CANCELED",pt.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",pt.ERR_INVALID_URL="ERR_INVALID_URL",pt.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const gt=Q.toFlatObject(Q,{},null,function(t){return/^is[A-Z]/.test(t)});function yt(t,n,e){if(!Q.isObject(t))throw new TypeError("target must be an object");n=n||new FormData;const r=(t,n)=>{const r=Q.getSafeProp(e,t);return Q.isUndefined(r)?n:r},i=r("metaTokens",!0),o=r("visitor")||p,s=r("dots",!1),a=r("indexes",!1),c=r("Blob")||"undefined"!=typeof Blob&&Blob,u=r("maxDepth",100),h=c&&Q.isSpecCompliantForm(n),l=[];if(!Q.isFunction(o))throw new TypeError("visitor must be a function");function f(t){if(null===t)return"";if(Q.isDate(t))return t.toISOString();if(Q.isBoolean(t))return t.toString();if(!h&&Q.isBlob(t))throw new pt("Blob is not supported. Use a Buffer instead.");if(Q.isArrayBuffer(t)||Q.isTypedArray(t)){if(h&&"function"==typeof c)return new c([t]);throw new pt("Blob is not supported. Use a Buffer instead.",pt.ERR_NOT_SUPPORT)}return t}function d(t){if(t>u)throw new pt("Object is too deeply nested ("+t+" levels). Max depth: "+u,pt.ERR_FORM_DATA_DEPTH_EXCEEDED)}function p(t,e,r){let o=t;if(Q.isReactNative(n)&&Q.isReactNativeBlob(t))return n.append(bt(r,e,s),f(t)),!1;if(t&&!r&&"object"==typeof t)if(Q.endsWith(e,"{}"))e=i?e:e.slice(0,-2),t=function(t){if(u===1/0)return JSON.stringify(t);const n=[];return JSON.stringify(t,function(t,e){if(!Q.isObject(e))return e;for(;n.length&&n[n.length-1]!==this;)n.pop();return n.push(e),d(1+n.length-1),e})}(t);else if(Q.isArray(t)&&function(t){return Q.isArray(t)&&!t.some(mt)}(t)||(Q.isFileList(t)||Q.endsWith(e,"[]"))&&(o=Q.toArray(t)))return e=vt(e),o.forEach(function(t,r){!Q.isUndefined(t)&&null!==t&&n.append(!0===a?bt([e],r,s):null===a?e:e+"[]",f(t))}),!1;return!!mt(t)||(n.append(bt(r,e,s),f(t)),!1)}const m=Object.assign(gt,{defaultVisitor:p,convertValue:f,isVisitable:mt});if(!Q.isObject(t))throw new TypeError("data must be an object");return function t(e,r,i=0){if(!Q.isUndefined(e)){if(d(i),-1!==l.indexOf(e))throw Error("Circular reference detected in "+r.join("."));l.push(e),Q.forEach(e,function(e,s){!0===(!(Q.isUndefined(e)||null===e)&&o.call(n,e,Q.isString(s)?s.trim():s,r,m))&&t(e,r?r.concat(s):[s],i+1)}),l.pop()}}(t),n}function wt(t){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(t){return n[t]})}function Ot(t,n){this.V=[],t&&yt(t,this,n)}const Rt=Ot.prototype;function St(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function jt(t,n,e){if(!n)return t;t=t||"";const r=Q.isFunction(e)?{serialize:e}:e,i=Q.getSafeProp(r,"encode")||St,o=Q.getSafeProp(r,"serialize");let s;if(s=o?o(n,r):Q.isURLSearchParams(n)?n.toString():new Ot(n,r).toString(i),s){const n=t.indexOf("#");-1!==n&&(t=t.slice(0,n)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t}Rt.append=function(t,n){this.V.push([t,n])},Rt.toString=function(t){const n=t?n=>t.call(this,n,wt):wt;return this.V.map(function(t){return n(t[0])+"="+n(t[1])},"").join("&")};const kt=Symbol("internals");function $t(t){return t?t.length:0}function Et(t){if(t)for(;t.length&&null===t[t.length-1];)t.pop()}function Ct(t,n){const e=t.handlers,r=$t(e);e!==n.handlersRef?(n.handlersRef=e,n.handlerEntries.clear()):r!==n.handlersLength&&(r?n.handlerEntries.forEach(function(t,r){e[t.index]!==t.handler&&n.handlerEntries.delete(r)}):n.handlerEntries.clear()),n.handlersLength=r}class Tt{constructor(){this.handlers=[],this[kt]={handlersRef:this.handlers,handlersLength:this.handlers.length,handlerEntries:new Map,iterationDepth:0,nextId:0}}use(t,n,e){const r={fulfilled:t,rejected:n,synchronous:!!e&&e.synchronous,runWhen:e?e.runWhen:null},i=this[kt];null==this.handlers&&(this.handlers=[]),Ct(this,i);const o=i.nextId++;return this.handlers.push(r),i.handlerEntries.set(o,{handler:r,index:this.handlers.length-1}),i.handlersLength=this.handlers.length,o}eject(t){const n=this[kt];Ct(this,n);const e=n.handlerEntries.get(t);if(e){if(n.handlerEntries.delete(t),this.handlers[e.index]!==e.handler)return;this.handlers[e.index]=null,n.iterationDepth||(Et(this.handlers),n.handlersLength=this.handlers.length)}}clear(){this.handlers&&(this.handlers=[],Ct(this,this[kt]))}forEach(t){const n=this[kt];Ct(this,n),n.iterationDepth++;try{Q.forEach(this.handlers,function(n){null!==n&&t(n)})}finally{--n.iterationDepth||(Ct(this,n),Et(this.handlers),n.handlersLength=$t(this.handlers))}}}var At={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},Pt={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ot,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Mt="undefined"!=typeof window&&"undefined"!=typeof document,Nt="object"==typeof navigator&&navigator||void 0,Ut=Mt&&(!Nt||["ReactNative","NativeScript","NS"].indexOf(Nt.product)<0),It="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,qt=Mt&&window.location.href||"http://localhost";var Ft={...Object.freeze({__proto__:null,hasBrowserEnv:Mt,hasStandardBrowserEnv:Ut,hasStandardBrowserWebWorkerEnv:It,navigator:Nt,origin:qt}),...Pt};function Lt(t){if(t>100)throw new pt("FormData field is too deeply nested ("+t+" levels). Max depth: 100",pt.ERR_FORM_DATA_DEPTH_EXCEEDED)}function Dt(t){function n(t,e,r,i){Lt(i);let o=t[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=t.length;return o=!o&&Q.isArray(r)?r.length:o,a?(Q.hasOwnProp(r,o)?r[o]=Q.isArray(r[o])?r[o].concat(e):[r[o],e]:r[o]=e,!s):(Q.hasOwnProp(r,o)&&Q.isObject(r[o])||(r[o]=[]),n(t,e,r[o],i)&&Q.isArray(r[o])&&(r[o]=function(t){const n={},e=Object.keys(t);let r;const i=e.length;let o;for(r=0;r<i;r++)o=e[r],n[o]=t[o];return n}(r[o])),!s)}if(Q.isFormData(t)&&Q.isFunction(t.entries)){const e={};return Q.forEachEntry(t,(t,r)=>{n(function(t){const n=[],e=/[^.[\]]+|\[([^.[\]]*)]/g;let r;for(;null!==(r=e.exec(t));)Lt(n.length),n.push("[]"===r[0]?"":r[1]||r[0]);return n}(t),r,e,0)}),e}return null}const zt=Object.freeze(["get","delete","head","options","post","put","patch","purge","link","unlink","query"]),Bt=(t,n)=>null!=t&&Q.hasOwnProp(t,n)?t[n]:void 0,Ht={transitional:At,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const e=n.getContentType()||"",r=e.indexOf("application/json")>-1,i=Q.isObject(t);if(i&&Q.isHTMLForm(t)&&(t=new FormData(t)),Q.isFormData(t))return r?JSON.stringify(Dt(t)):t;if(Q.isArrayBuffer(t)||Q.isBuffer(t)||Q.isStream(t)||Q.isFile(t)||Q.isBlob(t)||Q.isReadableStream(t))return t;if(Q.isArrayBufferView(t))return t.buffer;if(Q.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(i){const n=Bt(this,"formSerializer");if(e.indexOf("application/x-www-form-urlencoded")>-1)return function(t,n){return yt(t,new Ft.classes.URLSearchParams,{visitor:function(t,n,e,r){return Ft.isNode&&Q.isBuffer(t)?(this.append(n,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}(t,n).toString();if((o=Q.isFileList(t))||e.indexOf("multipart/form-data")>-1){const e=Bt(this,"env"),r=e&&e.FormData;return yt(o?{"files[]":t}:t,r&&new r,n)}}return i||r?(n.setContentType("application/json",!1),function(t){if(Q.isString(t))try{return(0,JSON.parse)(t),Q.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(0,JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const n=Bt(this,"transitional")||Ht.transitional,e=n&&n.forcedJSONParsing,r=Bt(this,"responseType"),i="json"===r;if(Q.isResponse(t)||Q.isReadableStream(t))return t;if(t&&Q.isString(t)&&(e&&!r||i)){const e=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(t,Bt(this,"parseReviver"))}catch(t){if(e){if("SyntaxError"===t.name)throw pt.from(t,pt.ERR_BAD_RESPONSE,this,null,Bt(this,"response"));throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ft.classes.FormData,Blob:Ft.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};function Jt(t,n){const e=this||Ht,r=n||e,i=lt.from(r.headers);let o=r.data;return Q.forEach(t,function(t){o=t.call(e,o,i.normalize(),n?n.status:void 0)}),i.normalize(),o}function Gt(t){return!(!t||!t.Z)}Q.forEach(zt,t=>{Ht.headers[t]={}});class Kt extends pt{constructor(t,n,e){super(t??"canceled",pt.ERR_CANCELED,n,e),this.name="CanceledError",this.Z=!0}}function Wt(t,n,e){const r=e.config.validateStatus;e.status&&r&&!r(e.status)?n(new pt("Request failed with status code "+e.status,e.status>=400&&e.status<500?pt.ERR_BAD_REQUEST:pt.ERR_BAD_RESPONSE,e.config,e.request,e)):t(e)}const Xt=/[\t\n\r]/g;function Yt(t){if("string"!=typeof t)return t;let n=0;for(;n<t.length&&t.charCodeAt(n)<=32;)n++;return t.slice(n).replace(Xt,"")}function Vt(t){const n=/^([-+\w]{1,25}):(?:\/\/)?/.exec(t);return n&&n[1]||""}const Zt=(t,n,e=3)=>{let r=0;const i=function(t,n){const e=Array(t=t||10),r=Array(t);let i,o=0,s=0;return n=void 0!==n?n:1e3,function(a){const c=Date.now(),u=r[s];i||(i=c),e[o]=a,r[o]=c;let h=s,l=0;for(;h!==o;)l+=e[h++],h%=t;if(o=(o+1)%t,o===s&&(s=(s+1)%t),c-i<n)return;const f=u&&c-u;return f?Math.round(1e3*l/f):void 0}}(50,250);return function(e,o){let s,a,c=0,u=1e3/o;const h=(e,o=Date.now())=>{c=o,s=null,a&&(clearTimeout(a),a=null),(e=>{if(!e||!Q.isNumber(e.loaded))return;const o=e.loaded,s=e.lengthComputable?e.total:void 0,a=Math.max(0,null!=s?Math.min(o,s):o),c=Math.max(0,a-r),u=i(c);r=Math.max(r,a),t({loaded:a,total:s,progress:s?a/s:void 0,bytes:c,rate:u||void 0,estimated:u&&s?(s-a)/u:void 0,event:e,lengthComputable:null!=s,[n?"download":"upload"]:!0})})(...e)};return[(...t)=>{const n=Date.now(),e=n-c;e>=u?h(t,n):(s=t,a||(a=setTimeout(()=>{a=null,h(s)},u-e)))},()=>s&&h(s),(...t)=>h(t)]}(0,e)},Qt=(t,n)=>{const e=null!=t;return[r=>n[0]({lengthComputable:e,total:t,loaded:r}),n[1]]},tn=(t,n=Q.asap)=>(...e)=>n(()=>t(...e));var nn=Ft.hasStandardBrowserEnv?((t,n)=>e=>(e=new URL(e,Ft.origin),t.protocol===e.protocol&&t.host===e.host&&(n||t.port===e.port)))(new URL(Ft.origin),Ft.navigator&&/(msie|trident)/i.test(Ft.navigator.userAgent)):()=>!0,en=Ft.hasStandardBrowserEnv?{write(t,n,e,r,i,o,s){if("undefined"==typeof document)return;const a=[`${t}=${encodeURIComponent(n)}`];Q.isNumber(e)&&a.push("expires="+new Date(e).toUTCString()),Q.isString(r)&&a.push("path="+r),Q.isString(i)&&a.push("domain="+i),!0===o&&a.push("secure"),Q.isString(s)&&a.push("SameSite="+s),document.cookie=a.join("; ")},read(t){if("undefined"==typeof document)return null;const n=document.cookie.split(";");for(let e=0;e<n.length;e++){const r=n[e].replace(/^\s+/,""),i=r.indexOf("=");if(-1!==i&&r.slice(0,i)===t)try{return decodeURIComponent(r.slice(i+1))}catch(t){return r.slice(i+1)}}return null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};const rn=/^https?:(?!\/\/)/i;function on(t,n){if("string"==typeof t){const e=Yt(t);if(rn.test(e))throw new pt(`Invalid URL ${JSON.stringify(function(t){const n=t.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${ft}@`),e=n.indexOf("#"),r=(-1===e?n:n.slice(0,e)).replace(/([?&][^=&#]*=)[^&#]*/g,"$1"+ft);return-1===e?r:`${r}#${i=n.slice(e+1),i?i.replace(/(^|&)([^=&]*=)?[^&]+/g,(t,n,e="")=>`${n}${e}${ft}`):i}`;var i}(e))}: missing "//" after protocol`,pt.ERR_INVALID_URL,n)}}function sn(t,n,e,r){on(n,r);let i=!("string"==typeof(o=n)&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o));var o;return t&&(i||!1===e)?(on(t,r),function(t,n){if(!n)return t;let e=t.length;for(;e>0&&47===t.charCodeAt(e-1);)e--;return t.slice(0,e)+"/"+n.replace(/^\/+/,"")}(t,n)):n}const an=t=>t instanceof lt?{...t}:t;function cn(t,n){t=t||{},n=n||{};const e=Object.create(null);function r(t,n,e,r){return Q.isPlainObject(t)&&Q.isPlainObject(n)?Q.merge.call({caseless:r},t,n):Q.isPlainObject(n)?Q.merge({},n):Q.isArray(n)?n.slice():n}function i(t,n,e,i){return Q.isUndefined(n)?Q.isUndefined(t)?void 0:r(void 0,t,0,i):r(t,n,0,i)}function o(t,n){if(!Q.isUndefined(n))return r(void 0,n)}function s(t,n){return Q.isUndefined(n)?Q.isUndefined(t)?void 0:r(void 0,t):r(void 0,n)}function a(e,i,o){return Q.hasOwnProp(n,o)?r(e,i):Q.hasOwnProp(t,o)?r(void 0,e):void 0}Object.defineProperty(e,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});const c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutErrorMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,allowedSocketPaths:s,responseEncoding:s,validateStatus:a,headers:(t,n,e)=>i(an(t),an(n),0,!0)};var u;return Q.forEach((u={...t,...n},Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(u).concat(Object.getOwnPropertySymbols(u).filter(t=>Object.getOwnPropertyDescriptor(u,t).enumerable)):Object.keys(u)),function(r){if("__proto__"===r||"constructor"===r||"prototype"===r)return;const o=Q.hasOwnProp(c,r)?c[r]:i,s=o(Q.hasOwnProp(t,r)?t[r]:void 0,Q.hasOwnProp(n,r)?n[r]:void 0,r);Q.isUndefined(s)&&o!==a||(e[r]=s)}),Q.hasOwnProp(n,"validateStatus")&&Q.isUndefined(n.validateStatus)&&!1===function(e){const r=Q.hasOwnProp(n,"transitional")?n.transitional:void 0;if(!Q.isUndefined(r)){if(!Q.isPlainObject(r))return;if(Q.hasOwnProp(r,e))return r[e]}const i=Q.hasOwnProp(t,"transitional")?t.transitional:void 0;if(Q.isPlainObject(i)&&Q.hasOwnProp(i,e))return i[e]}("validateStatusUndefinedResolves")&&(Q.hasOwnProp(t,"validateStatus")?e.validateStatus=r(void 0,t.validateStatus):delete e.validateStatus),e}const un=["content-type","content-length"];function hn(t){const n=cn({},t),e=t=>Q.hasOwnProp(n,t)?n[t]:void 0,r=e("data");let i=e("withXSRFToken");const o=e("xsrfHeaderName"),s=e("xsrfCookieName");let a=e("headers");const c=e("auth"),u=e("baseURL"),h=e("allowAbsoluteUrls"),l=e("url");if(n.headers=a=lt.from(a),n.url=jt(sn(u,l,h,n),e("params"),e("paramsSerializer")),c){const n=Q.getSafeProp(c,"username")||"",e=Q.getSafeProp(c,"password")||"";try{a.set("Authorization","Basic "+btoa(n+":"+(e?encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))):"")))}catch(n){throw pt.from(n,pt.ERR_BAD_OPTION_VALUE,t)}}if(Q.isFormData(r)){const t=Q.getSafeProp(r,"getHeaders");Ft.hasStandardBrowserEnv||Ft.hasStandardBrowserWebWorkerEnv||Q.isReactNative(r)?a.setContentType(void 0):Q.isFunction(t)&&function(t,n,e){"content-only"===e?Object.entries(n||{}).forEach(([n,e])=>{un.includes(n.toLowerCase())&&t.set(n,e)}):t.set(n)}(a,t.call(r),e("formDataHeaderPolicy"))}if(Ft.hasStandardBrowserEnv&&(Q.isFunction(i)&&(i=i(n)),!0===i||null==i&&nn(n.url))){const t=o&&s&&en.read(s);t&&a.set(o,t)}return n}var ln="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise(function(n,e){const r=hn(t);let i=r.data;const o=lt.from(r.headers).normalize();let s,a,c,u,h,l,{responseType:f,onUploadProgress:d,onDownloadProgress:p}=r;function m(){u&&u(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let v=new XMLHttpRequest;function b(i){if(!v)return;if(!(0!==v.status||"file"===(Vt(Yt(r.url))||Vt(Ft.origin))||v.responseURL&&v.responseURL.startsWith("file:")))return e(new pt("Request aborted",pt.ECONNABORTED,t,v)),m(),void(v=null);try{i?l&&l(i):h&&h()}catch(t){setTimeout(()=>{throw t})}if(!v)return;const o=lt.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders());Wt(function(t){n(t),m()},function(t){e(t),m()},{data:f&&"text"!==f&&"json"!==f?v.response:v.responseText,status:v.status,statusText:v.statusText,headers:o,config:t,request:v}),v=null}v.open(r.method.toUpperCase(),r.url,!0),v.timeout=r.timeout,"onloadend"in v?v.onloadend=b:v.onreadystatechange=function(){v&&4===v.readyState&&(0!==v.status||v.responseURL&&v.responseURL.startsWith("file:"))&&setTimeout(b)},v.onabort=function(){v&&(e(new pt("Request aborted",pt.ECONNABORTED,t,v)),m(),v=null)},v.onerror=function(n){const r=n&&n.message?n.message:"Network Error",i=new pt(r,pt.ERR_NETWORK,t,v);i.event=n||null,e(i),m(),v=null},v.ontimeout=function(){let n=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const i=r.transitional||At;r.timeoutErrorMessage&&(n=r.timeoutErrorMessage),e(new pt(n,i.clarifyTimeoutError?pt.ETIMEDOUT:pt.ECONNABORTED,t,v)),m(),v=null},void 0===i&&o.setContentType(null),"setRequestHeader"in v&&Q.forEach(it(o),function(t,n){v.setRequestHeader(n,t)}),Q.isUndefined(r.withCredentials)||(v.withCredentials=!!r.withCredentials),f&&"json"!==f&&(v.responseType=r.responseType),p&&([c,h,l]=Zt(p,!0),v.addEventListener("progress",c)),d&&v.upload&&([a,u]=Zt(d),v.upload.addEventListener("progress",a),v.upload.addEventListener("loadend",u)),(r.cancelToken||r.signal)&&(s=n=>{v&&(e(!n||n.type?new Kt(null,t,v):n),v.abort(),m(),v=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const g=Vt(r.url);if(g&&!Ft.protocols.includes(g))return e(new pt("Unsupported protocol "+g+":",pt.ERR_BAD_REQUEST,t)),void m();v.send(i||null)})};const fn=(t,n)=>{if(t=t?t.filter(Boolean):[],!n&&!t.length)return;const e=new AbortController;let r=!1;const i=function(t){if(!r){r=!0,s();const n=t instanceof Error?t:this.reason;e.abort(n instanceof pt?n:new Kt(n instanceof Error?n.message:n))}};let o=n&&setTimeout(()=>{o=null,i(new pt(`timeout of ${n}ms exceeded`,pt.ETIMEDOUT))},n);const s=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(t=>{t.unsubscribe?t.unsubscribe(i):t.removeEventListener("abort",i)}),t=null)};t.forEach(t=>{r||(t.aborted?i.call(t):t.addEventListener("abort",i,{once:!0}))});const{signal:a}=e;return a.unsubscribe=()=>Q.asap(s),a},dn=function*(t,n){let e=t.byteLength;if(e<n)return void(yield t);let r,i=0;for(;i<e;)r=i+n,yield t.slice(i,r),i=r},pn=(t,n,e,r)=>{const i=async function*(t,n){for await(const e of async function*(t){if(t[Symbol.asyncIterator])return void(yield*t);const n=t.getReader();try{for(;;){const{done:t,value:e}=await n.read();if(t)break;yield e}}finally{await n.cancel()}}(t))yield*dn(e,n)}(t,n);let o,s=0,a=t=>{o||(o=!0,r&&r(t))};return new ReadableStream({async pull(t){try{const{done:n,value:r}=await i.next();if(n)return a(),void t.close();let o=r.byteLength;if(e){let t=s+=o;e(t)}t.enqueue(new Uint8Array(r))}catch(t){throw a(t),t}},cancel:t=>(a(t),i.return())},{highWaterMark:2})},mn=t=>t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102,vn=(t,n,e)=>n+2<e&&mn(t.charCodeAt(n+1))&&mn(t.charCodeAt(n+2)),bn=t=>t<=57?t-48:(223&t)-55,gn=t=>t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||43===t||47===t||45===t||95===t,yn=t=>9===t||10===t||12===t||13===t||32===t,wn=t=>{const n=t.length;let e=0,r=0,i=!1;for(let o=0;o<n;o++){let s=t.charCodeAt(o);37===s&&vn(t,o,n)&&(s=16*bn(t.charCodeAt(o+1))+bn(t.charCodeAt(o+2)),o+=2),yn(s)||(61!==s?!gn(s)||r>0?i=!0:e++:r++)}return i||r>2||r>0&&(e+r)%4!=0||e%4==1?(t=>{const n=t.length;let e=0;return n>0&&61===t.charCodeAt(n-1)&&(e++,n>1&&61===t.charCodeAt(n-2)&&e++),Math.floor(3*(n-e)/4)})(t):(t=>{const n=t%4;return 3*Math.floor(t/4)+(2===n?1:3===n?2:0)})(e)},_n="1.20.0",xn={cache:"default",redirect:"follow",referrer:"about:client",referrerPolicy:"",mode:"cors",integrity:"",keepalive:!1,priority:"auto",window:null},{isFunction:On}=Q,Rn=t=>{if(!Q.isString(t))return t;try{return decodeURIComponent(t)}catch(n){return t}},Sn=(t,...n)=>{try{return!!t(...n)}catch(t){return!1}},jn=t=>{const n=void 0!==Q.global&&null!==Q.global?Q.global:globalThis,{ReadableStream:e,TextEncoder:r}=n;t=Q.merge.call({skipUndefined:!0},{Request:n.Request,Response:n.Response},t);const{fetch:i,Request:o,Response:s}=t,a=i?On(i):"function"==typeof fetch,c=On(o),u=On(s);if(!a)return!1;const h=a&&On(e),l=a&&("function"==typeof r?(f=new r,t=>f.encode(t)):async t=>new Uint8Array(await new o(t).arrayBuffer()));var f;const d=c&&h&&Sn(()=>{let t=!1;const n=new o(Ft.origin,{body:new e,method:"POST",get duplex(){return t=!0,"half"}}),r=n.headers.has("Content-Type");return null!=n.body&&n.body.cancel(),t&&!r}),p=u&&h&&Sn(()=>Q.isReadableStream(new s("").body)),m={stream:p&&(t=>t.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!m[t]&&(m[t]=(n,e)=>{let r=n&&n[t];if(r)return r.call(n);throw new pt(`Response type '${t}' is not supported`,pt.ERR_NOT_SUPPORT,e)})});const v=async t=>{if(null==t)return 0;if(Q.isBlob(t))return t.size;if(Q.isSpecCompliantForm(t)){const n=new o(Ft.origin,{method:"POST",body:t});return(await n.arrayBuffer()).byteLength}return Q.isArrayBufferView(t)||Q.isArrayBuffer(t)?t.byteLength:(Q.isURLSearchParams(t)&&(t+=""),Q.isString(t)?(await l(t)).byteLength:void 0)};return async t=>{let{url:n,method:e,data:a,signal:u,cancelToken:l,timeout:f,onDownloadProgress:b,onUploadProgress:g,responseType:y,headers:w,withCredentials:_="same-origin",fetchOptions:x,maxContentLength:O,maxBodyLength:R,maxRedirects:S}=hn(t);const j=Q.isNumber(O)&&O>-1,k=Q.isNumber(R)&&R>-1;let $=i||fetch;y=y?(y+"").toLowerCase():"text";let E=fn([u,l&&l.toAbortSignal()],f),C=null;const T=E&&E.unsubscribe&&(()=>{E.unsubscribe()});let A,P=null;const M=()=>new pt("Request body larger than maxBodyLength limit",pt.ERR_BAD_REQUEST,t,C);try{let i;const u=(U="auth",Q.hasOwnProp(t,U)?t[U]:void 0);if(u&&(i={username:Q.getSafeProp(u,"username")||"",password:Q.getSafeProp(u,"password")||""}),(t=>{const n=t.indexOf("://");let e=t;return-1!==n&&(e=e.slice(n+3)),e.includes("@")||e.includes(":")})(n)){const t=new URL(n,Ft.origin);i||!t.username&&!t.password||(i={username:Rn(t.username),password:Rn(t.password)}),(t.username||t.password)&&(t.username="",t.password="",n=t.href)}if(i&&(w.delete("authorization"),w.set("Authorization","Basic "+btoa((N=(i.username||"")+":"+(i.password||""),encodeURIComponent(N).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))))))),j&&"string"==typeof n&&n.startsWith("data:")&&function(t){const n="string"==typeof t?t.indexOf("#"):-1;return((t,n)=>{if(!t||"string"!=typeof t)return 0;if(!t.startsWith("data:"))return 0;const e=t.indexOf(",");if(e<0)return 0;const r=t.slice(5,e),i=t.slice(e+1);if(/;base64/i.test(r))return n(i);let o=0;for(let t=0,n=i.length;t<n;t++){const e=i.charCodeAt(t);if(37===e&&vn(i,t,n))o+=1,t+=2;else if(e<128)o+=1;else if(e<2048)o+=2;else if(e>=55296&&e<=56319&&t+1<n){const n=i.charCodeAt(t+1);n>=56320&&n<=57343?(o+=4,t++):o+=3}else o+=3}return o})(-1===n?t:t.slice(0,n),wn)}(n)>O)throw new pt("maxContentLength size of "+O+" exceeded",pt.ERR_BAD_RESPONSE,t,C);if(k&&"get"!==e&&"head"!==e){const t=await v(a);if("number"==typeof t&&isFinite(t)&&(A=t,t>R))throw M()}const l=k&&(Q.isReadableStream(a)||Q.isStream(a)),f=(t,n,e)=>pn(t,65536,t=>{if(k&&t>R)throw P=M();n&&n(t)},e);if(d&&"get"!==e&&"head"!==e&&(g||l)){if(A=A??await(async(t,n)=>Q.toFiniteNumber(t.getContentLength())??v(n))(w,a),0!==A||l){let t,e=new o(n,{method:"POST",body:a,duplex:"half"});if(Q.isFormData(a)&&(t=e.headers.get("content-type"))&&w.setContentType(t),e.body){const[t,n]=g&&Qt(A,Zt(tn(g)))||[];a=f(e.body,t,n)}}}else if(l&&!c&&h&&"get"!==e&&"head"!==e)a=f(a);else if(l&&c&&!d&&"get"!==e&&"head"!==e)throw new pt("Stream request bodies are not supported by the current fetch implementation",pt.ERR_NOT_SUPPORT,t,C);Q.isString(_)||(_=_?"include":"omit");const I=c&&"credentials"in o.prototype;if(Q.isFormData(a)){const t=w.getContentType();t&&/^multipart\/form-data/i.test(t)&&!/boundary=/i.test(t)&&w.delete("content-type")}w.set("User-Agent","axios/"+_n,!1);const q=null==x?x:Object.assign(Object.create(null),x);q&&(delete q.body,delete q.headers,delete q.method,delete q.signal,delete q.duplex,delete q.credentials);const F=Object.assign(Object.create(null),q,{signal:E,method:e.toUpperCase(),headers:it(w.normalize()),body:a,duplex:"half",credentials:I?_:void 0});c&&(Q.forEach(xn,(t,n)=>{void 0===F[n]&&(F[n]=t)}),void 0===F.signal&&(F.signal=null),void 0===F.body&&(F.body=null)),0===S&&(F.redirect="manual",q&&(q.redirect="manual")),C=c&&new o(n,F);let L=await(c?$(C,q):$(n,F));const D=lt.from(L.headers);if(j){const n=Q.toFiniteNumber(D.getContentLength());if(null!=n&&n>O)throw new pt("maxContentLength size of "+O+" exceeded",pt.ERR_BAD_RESPONSE,t,C)}const z=p&&("stream"===y||"response"===y);if(p&&L.body&&(b||j||z&&T)){const n={};["status","statusText","headers"].forEach(t=>{n[t]=L[t]});const e=Q.toFiniteNumber(D.getContentLength()),[r,i]=b&&Qt(e,Zt(tn(b),!0))||[];let o=0;const a=n=>{if(j&&(o=n,o>O))throw new pt("maxContentLength size of "+O+" exceeded",pt.ERR_BAD_RESPONSE,t,C);r&&r(n)};L=new s(pn(L.body,65536,a,()=>{i&&i(),T&&T()}),n)}y=y||"text";let B=await m[Q.findKey(m,y)||"text"](L,t);if(j&&!p&&!z){let n;if(null!=B&&("number"==typeof B.byteLength?n=B.byteLength:"number"==typeof B.size?n=B.size:"string"==typeof B&&(n="function"==typeof r?(new r).encode(B).byteLength:B.length)),"number"==typeof n&&n>O)throw new pt("maxContentLength size of "+O+" exceeded",pt.ERR_BAD_RESPONSE,t,C)}return!z&&T&&T(),await new Promise((n,e)=>{Wt(n,e,{data:B,headers:lt.from(L.headers),status:L.status,statusText:L.statusText,config:t,request:C})})}catch(n){if(T&&T(),E&&E.aborted&&E.reason instanceof pt){const e=E.reason;throw e.config=t,C&&(e.request=C),n!==e&&Object.defineProperty(e,"cause",{__proto__:null,value:n,writable:!0,enumerable:!1,configurable:!0}),e}if(P)throw C&&!P.request&&(P.request=C),P;if(n instanceof pt)throw C&&!n.request&&(n.request=C),n;if(n&&"TypeError"===n.name&&/Load failed|fetch/i.test(n.message)){const e=new pt("Network Error",pt.ERR_NETWORK,t,C,n&&n.response);throw Object.defineProperty(e,"cause",{__proto__:null,value:n.cause||n,writable:!0,enumerable:!1,configurable:!0}),e}throw pt.from(n,n&&n.code,t,C,n&&n.response)}var N,U}},kn=new Map,$n=t=>{let n=t&&t.env||{};const{fetch:e,Request:r,Response:i}=n,o=[r,i,e];let s,a,c=o.length,u=kn;for(;c--;)s=o[c],a=u.get(s),void 0===a&&u.set(s,a=c?new Map:jn(n)),u=a;return a};$n();const En={http:null,xhr:ln,fetch:{get:$n}};Q.forEach(En,(t,n)=>{if(t){try{Object.defineProperty(t,"name",{__proto__:null,value:n})}catch(t){}Object.defineProperty(t,"adapterName",{__proto__:null,value:n})}});const Cn=t=>"- "+t,Tn=t=>Q.isFunction(t)||null===t||!1===t;var An=function(t,n){t=Q.isArray(t)?t:[t];const{length:e}=t;let r,i;const o={};for(let s=0;s<e;s++){let e;if(r=t[s],i=r,!Tn(r)&&(i=En[(e=r+"").toLowerCase()],void 0===i))throw new pt(`Unknown adapter '${e}'`);if(i&&(Q.isFunction(i)||(i=i.get(n))))break;o[e||"#"+s]=i}if(!i){const t=Object.entries(o).map(([t,n])=>`adapter ${t} `+(!1===n?"is not supported by the environment":"is not available in the build"));let n=e?t.length>1?"since :\n"+t.map(Cn).join("\n"):" "+Cn(t[0]):"as no adapter specified";throw new pt("There is no suitable adapter to dispatch the request "+n,pt.ERR_NOT_SUPPORT)}return i};function Pn(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Kt(null,t)}function Mn(t){const n=Q.toSafeFlatObject(t);return Pn(n),n.headers=lt.from(Q.getSafeProp(n,"headers")),n.data=Jt.call(n,n.transformRequest),-1!==["post","put","patch"].indexOf(n.method)&&n.headers.setContentType("application/x-www-form-urlencoded",!1),An(n.adapter||Ht.adapter,n)(n).then(function(t){Pn(n),n.response=t;try{t.data=Jt.call(n,n.transformResponse,t)}finally{delete n.response}return t.headers=lt.from(t.headers),t},function(t){if(!Gt(t)&&(Pn(n),t&&t.response)){n.response=t.response;try{t.response.data=Jt.call(n,n.transformResponse,t.response)}finally{delete n.response}t.response.headers=lt.from(t.response.headers)}return Promise.reject(t)})}const Nn={};["object","boolean","number","function","string","symbol"].forEach((t,n)=>{Nn[t]=function(e){return typeof e===t||"a"+(n<1?"n ":" ")+t}});const Un={};Nn.transitional=function(t,n,e){return(r,i,o)=>{if(!1===t)throw new pt(function(t,n){return"[Axios v"+_n+"] Transitional option '"+t+"'"+n+(e?". "+e:"")}(i," has been removed"+(n?" in "+n:"")),pt.ERR_DEPRECATED);return n&&!Un[i]&&(Un[i]=!0),!t||t(r,i,o)}},Nn.spelling=function(t){return(t,n)=>!0};var In={assertOptions:function(t,n,e){if("object"!=typeof t||null===t)throw new pt("options must be an object",pt.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let i=r.length;for(;i-- >0;){const o=r[i],s=Object.prototype.hasOwnProperty.call(n,o)?n[o]:void 0;if(s){const n=t[o],e=void 0===n||s(n,o,t);if(!0!==e)throw new pt("option "+o+" must be "+e,pt.ERR_BAD_OPTION_VALUE);continue}if(!0!==e)throw new pt("Unknown option "+o,pt.ERR_BAD_OPTION)}},validators:Nn};const qn=In.validators;class Fn{constructor(t){this.defaults=t||{},this.interceptors={request:new Tt,response:new Tt}}async request(t,n){try{return await this.tt(t,n)}catch(t){if(t instanceof Error)try{let n={};Error.captureStackTrace?Error.captureStackTrace(n):n=Error();const e=n.stack;let r="";if("string"==typeof e){const t=e.indexOf("\n");r=-1===t?"":e.slice(t+1)}if(t.stack){if(r){const n=r.indexOf("\n"),e=-1===n?-1:r.indexOf("\n",n+1),i=-1===e?"":r.slice(e+1);(t.stack+"").endsWith(i)||(t.stack+="\n"+r)}}else t.stack=r}catch(t){}throw t}}tt(t,n){"string"==typeof t?(n=n||{}).url=t:n=t||{},n=cn(this.defaults,n);const{transitional:e,paramsSerializer:r,headers:i}=n;void 0!==e&&In.assertOptions(e,{silentJSONParsing:qn.transitional(qn.boolean),forcedJSONParsing:qn.transitional(qn.boolean),clarifyTimeoutError:qn.transitional(qn.boolean),legacyInterceptorReqResOrdering:qn.transitional(qn.boolean),advertiseZstdAcceptEncoding:qn.transitional(qn.boolean),validateStatusUndefinedResolves:qn.transitional(qn.boolean)},!1),null!=r&&(Q.isFunction(r)?n.paramsSerializer={serialize:r}:In.assertOptions(r,{encode:qn.function,serialize:qn.function},!0)),void 0!==n.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),In.assertOptions(n,{baseUrl:qn.spelling("baseURL"),withXsrfToken:qn.spelling("withXSRFToken")},!0),n.method=(Q.getSafeProp(n,"method")||Q.getSafeProp(this.defaults,"method")||"get").toLowerCase();let o=i&&Q.merge(i.common,i[n.method]);i&&Q.forEach(zt.concat("common"),t=>{delete i[t]}),n.headers=lt.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach(function(t){if("function"==typeof t.runWhen&&!1===t.runWhen(n))return;a=a&&t.synchronous;const e=n.transitional||At;e&&e.legacyInterceptorReqResOrdering?s.unshift(t.fulfilled,t.rejected):s.push(t.fulfilled,t.rejected)});const c=[];let u;this.interceptors.response.forEach(function(t){c.push(t.fulfilled,t.rejected)});let h,l=0;if(!a){const t=[Mn.bind(this),void 0];for(t.unshift(...s),t.push(...c),h=t.length,u=Promise.resolve(n);l<h;)u=u.then(t[l++],t[l++]);return u}h=s.length;let f=n;for(;l<h;){const t=s[l++],n=s[l++];try{f=t?t(f):f}catch(t){if(!n){u=Promise.reject(t);break}try{const e=n.call(this,t);Q.isThenable(e)&&(u=Promise.resolve(e).then(()=>Mn(f)))}catch(t){u=Promise.reject(t)}break}}if(!u)try{u=Mn(f)}catch(t){u=Promise.reject(t)}for(l=0,h=c.length;l<h;)u=u.then(c[l++],c[l++]);return u}getUri(t){return jt(sn((t=cn(this.defaults,t)).baseURL,t.url,t.allowAbsoluteUrls,t),t.params,t.paramsSerializer)}}Q.forEach(["delete","get","head","options"],function(t){Fn.prototype[t]=function(n,e){return this.request(cn(e||{},{method:t,url:n,data:e&&Q.hasOwnProp(e,"data")?e.data:void 0}))}}),Q.forEach(["post","put","patch","query"],function(t){function n(n){return function(e,r,i){return this.request(cn(i||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:e,data:r}))}}Fn.prototype[t]=n(),"query"!==t&&(Fn.prototype[t+"Form"]=n(!0))});class Ln{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(t){n=t});const e=this;this.promise.then(t=>{if(!e.nt)return;let n=e.nt.length;for(;n-- >0;)e.nt[n](t);e.nt=null}),this.promise.then=t=>{let n;const r=new Promise(t=>{e.subscribe(t),n=t}).then(t);return r.cancel=function(){e.unsubscribe(n)},r},t(function(t,r,i){e.reason||(e.reason=new Kt(t,r,i),n(e.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this.nt?this.nt.push(t):this.nt=[t]}unsubscribe(t){if(!this.nt)return;const n=this.nt.indexOf(t);-1!==n&&this.nt.splice(n,1)}toAbortSignal(){const t=new AbortController,n=n=>{t.abort(n)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Ln(function(n){t=n}),cancel:t}}}const Dn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,ContentTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,UnprocessableContent:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Dn).forEach(([t,n])=>{void 0===Dn[n]&&(Dn[n]=t)});const zn=function n(e){const r=new Fn(e),i=t(Fn.prototype.request,r);return Q.extend(i,Fn.prototype,r,{allOwnKeys:!0}),Q.extend(i,r,null,{allOwnKeys:!0}),i.create=function(t){return n(cn(e,t))},i}(Ht);return zn.Axios=Fn,zn.CanceledError=Kt,zn.CancelToken=Ln,zn.isCancel=Gt,zn.VERSION=_n,zn.toFormData=yt,zn.AxiosError=pt,zn.Cancel=zn.CanceledError,zn.all=function(t){return Promise.all(t)},zn.spread=function(t){return function(n){return t.apply(null,n)}},zn.isAxiosError=function(t){return Q.isObject(t)&&!0===t.isAxiosError},zn.mergeConfig=cn,zn.AxiosHeaders=lt,zn.formToJSON=t=>Dt(Q.isHTMLForm(t)?new FormData(t):t),zn.getAdapter=An,zn.HttpStatusCode=Dn,zn.default=zn,_t=zn}const St=r(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var jt,kt,$t,Et={},Ct={};function Tt(){if(kt)return Et;kt=1,Object.defineProperty(Et,"i",{value:!0}),Et.normalizeArrayableParams=function(r){var i=t.u({},r);if(!Object.keys(n.arrayableParams).filter(function(t){return Array.isArray(i[t])}).map(function(t){return i[t]=i[t].join(","),t}).length&&e(i))return i;if(!e(i))throw Error("Failed to normalize arrayable params: ".concat(JSON.stringify(i)));return i},Et.toErrorWithMessage=function(t){if("object"==typeof(n=t)&&null!==n&&"message"in n&&"string"==typeof n.message)return t;var n;try{return Error("string"==typeof t?t:JSON.stringify(t))}catch(n){return Error(t+"")}};var t=z,n=(jt||(jt=1,Object.defineProperty(Ct,"i",{value:!0}),Ct.arrayableParams=void 0,Ct.arrayableParams={query_by:"query_by",query_by_weights:"query_by_weights",facet_by:"facet_by",group_by:"group_by",include_fields:"include_fields",exclude_fields:"exclude_fields",highlight_fields:"highlight_fields",highlight_full_fields:"highlight_full_fields",pinned_hits:"pinned_hits",hidden_hits:"hidden_hits",infix:"infix",override_tags:"override_tags",num_typos:"num_typos",prefix:"prefix",synonym_sets:"synonym_sets",sort_by:"sort_by"}),Ct);function e(t){return Object.keys(n.arrayableParams).filter(function(n){return void 0!==t[n]}).every(function(n){return e=t[n],!Array.isArray(e);var e})}return Et}function At(){if($t)return Ot;$t=1,Object.defineProperty(Ot,"i",{value:!0});var t=z,n=t.H(Rt()),e=St,r=St,i=yt(),o=t.H(tt()),s=Tt(),a=!0,c="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node&&"undefined"==typeof window,u=function(){function u(t){this.configuration=t,this.apiKey=this.configuration.apiKey,this.nodes=null==this.configuration.nodes?this.configuration.nodes:JSON.parse(JSON.stringify(this.configuration.nodes)),this.nearestNode=null==this.configuration.nearestNode?this.configuration.nearestNode:JSON.parse(JSON.stringify(this.configuration.nearestNode)),this.connectionTimeoutSeconds=this.configuration.connectionTimeoutSeconds,this.healthcheckIntervalSeconds=this.configuration.healthcheckIntervalSeconds,this.numRetriesPerRequest=this.configuration.numRetries,this.retryIntervalSeconds=this.configuration.retryIntervalSeconds,this.sendApiKeyAsQueryParam=this.configuration.sendApiKeyAsQueryParam,this.additionalUserHeaders=this.configuration.additionalHeaders,this.logger=this.configuration.logger,this.initializeMetadataForNodes(),this.currentNodeIndex=-1}return u.prototype.get=function(n){return t.j(this,arguments,void 0,function(n,e,r){void 0===e&&(e={});var i=void 0===r?{}:r,o=i.abortSignal,s=void 0===o?null:o,a=i.responseType,c=void 0===a?void 0:a,u=i.streamConfig,h=void 0===u?void 0:u,l=i.isStreamingRequest;return t.k(this,function(t){return[2,this.performRequest("get",n,{queryParameters:e,abortSignal:s,responseType:c,streamConfig:h,isStreamingRequest:l})]})})},u.prototype.delete=function(n){return t.j(this,arguments,void 0,function(n,e){return void 0===e&&(e={}),t.k(this,function(t){return[2,this.performRequest("delete",n,{queryParameters:e,isStreamingRequest:!1})]})})},u.prototype.post=function(n){return t.j(this,arguments,void 0,function(n,e,r,i,o){void 0===e&&(e={}),void 0===r&&(r={}),void 0===i&&(i={});var s=void 0===o?{}:o,a=s.abortSignal,c=void 0===a?null:a,u=s.responseType,h=void 0===u?void 0:u,l=s.streamConfig,f=void 0===l?void 0:l,d=s.isStreamingRequest;return t.k(this,function(t){return[2,this.performRequest("post",n,{queryParameters:r,bodyParameters:e,additionalHeaders:i,abortSignal:c,responseType:h,streamConfig:f,isStreamingRequest:d})]})})},u.prototype.put=function(n){return t.j(this,arguments,void 0,function(n,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),t.k(this,function(t){return[2,this.performRequest("put",n,{queryParameters:r,bodyParameters:e,isStreamingRequest:!1})]})})},u.prototype.patch=function(n){return t.j(this,arguments,void 0,function(n,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),t.k(this,function(t){return[2,this.performRequest("patch",n,{queryParameters:r,bodyParameters:e,isStreamingRequest:!1})]})})},u.prototype.getAdapter=function(){if(this.configuration.axiosAdapter)return"function"==typeof this.configuration.axiosAdapter?this.configuration.axiosAdapter:"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent?n.default.getAdapter(this.configuration.axiosAdapter).bind(globalThis):n.default.getAdapter(this.configuration.axiosAdapter)},u.prototype.performRequest=function(i,o,s){return t.j(this,arguments,void 0,function(i,o,s){var u,h,l,f,d,p,m,v,b,g,y,w=s.queryParameters,_=void 0===w?null:w,x=s.bodyParameters,O=void 0===x?null:x,R=s.additionalHeaders,S=void 0===R?{}:R,j=s.abortSignal,k=void 0===j?null:j,$=s.responseType,E=void 0===$?void 0:$,C=s.skipConnectionTimeout,T=void 0!==C&&C,A=s.enableKeepAlive,P=void 0===A?void 0:A,M=s.streamConfig,N=void 0===M?void 0:M,U=s.isStreamingRequest;return t.k(this,function(s){switch(s.label){case 0:this.configuration.validate(),U&&(this.logger.debug("Request: Performing streaming request to ".concat(o)),c||"undefined"==typeof fetch||(this.logger.debug("Using fetch adapter for browser streaming"),E="stream")),u=Date.now(),l=!1,this.logger.debug("Request #".concat(u,": Performing ").concat(i.toUpperCase()," request: ").concat(o)),f=function(s){var f,p,m,w,x,R,j;return t.k(this,function($){switch($.label){case 0:if(f=d.getNextNode(u),d.logger.debug("Request #".concat(u,": Attempting ").concat(i.toUpperCase()," request Try #").concat(s," to Node ").concat(f.index)),k&&k.aborted)return[2,{value:Promise.reject(Error("Request aborted by caller."))}];p=void 0,$.label=1;case 1:return $.trys.push([1,3,5,6]),(m={method:i,url:d.uriFor(o,f),headers:Object.assign({},d.defaultHeaders(),S,d.additionalUserHeaders),maxContentLength:1/0,maxBodyLength:1/0,validateStatus:function(t){return t>0},transformResponse:[function(t,n){var e=t;return void 0!==n&&"string"==typeof t&&n["content-type"]&&n["content-type"].startsWith("application/json")&&(e=JSON.parse(t)),e}]}).adapter=U&&!c?"fetch":d.getAdapter(),!0!==T&&(m.timeout=1e3*d.connectionTimeoutSeconds),_&&0!==Object.keys(_).length&&(m.params=_),d.sendApiKeyAsQueryParam&&(m.params=m.params||{},m.params["x-typesense-api-key"]=d.apiKey),d.configuration.httpAgent?(d.logger.debug("Request #".concat(u,": Using custom httpAgent")),m.httpAgent=d.configuration.httpAgent):!0===P&&(c?(d.logger.debug("Request #".concat(u,": Enabling KeepAlive")),m.httpAgent=new e.Agent({keepAlive:!0})):d.logger.warn("Request #".concat(u,": Cannot use custom httpAgent in a browser environment to enable keepAlive"))),d.configuration.httpsAgent?(d.logger.debug("Request #".concat(u,": Using custom httpsAgent")),m.httpsAgent=d.configuration.httpsAgent):!0===P&&(c?(d.logger.debug("Request #".concat(u,": Enabling keepAlive")),m.httpsAgent=new r.Agent({keepAlive:!0})):d.logger.warn("Request #".concat(u,": Cannot use custom httpAgent in a browser environment to enable keepAlive"))),d.configuration.paramsSerializer&&(d.logger.debug("Request #".concat(u,": Using custom paramsSerializer")),m.paramsSerializer=d.configuration.paramsSerializer),O&&("string"==typeof O&&0!==O.length||"object"==typeof O&&0!==Object.keys(O).length)&&(m.data=O),k&&(w=n.default.CancelToken,x=w.source(),p=function(){l=!0,x.cancel()},k.addEventListener("abort",p),m.cancelToken=x.token),U?(m.responseType="stream",c||(m.headers=t.u(t.u({},m.headers),{Accept:"text/event-stream"}))):E&&(m.responseType=E),[4,(0,n.default)(m)];case 2:if((R=$.sent()).status>=1&&R.status<=499&&d.setNodeHealthcheck(f,a),d.logger.debug("Request #".concat(u,": Request to Node ").concat(f.index," was made. Response Code was ").concat(R.status,".")),R.status>=200&&R.status<300)return U?[2,{value:d.handleStreamingResponse(R,N)}]:[2,{value:Promise.resolve(R.data)}];if(R.status<500)return[2,{value:Promise.reject(d.customErrorForResponse(R,null===(v=R.data)||void 0===v?void 0:v.message,m.data))}];throw d.customErrorForResponse(R,null===(b=R.data)||void 0===b?void 0:b.message,m.data);case 3:return j=$.sent(),l||d.setNodeHealthcheck(f,!1),h=j,d.logger.warn("Request #".concat(u,": Request to Node ").concat(f.index,' failed due to "').concat(null!==(g=null==j?void 0:j.code)&&void 0!==g?g:""," ").concat(j.message).concat(null==j.response?"":" - "+JSON.stringify(null===(y=j.response)||void 0===y?void 0:y.data),'"')),l?[2,{value:Promise.reject(Error("Request aborted by caller."))}]:(U&&d.invokeOnErrorCallback(j,N),s<d.numRetriesPerRequest+1?(d.logger.warn("Request #".concat(u,": Sleeping for ").concat(d.retryIntervalSeconds,"s and then retrying request...")),[4,d.timer(d.retryIntervalSeconds)]):(d.logger.debug("Request #".concat(u,": No retries left. Raising last error")),[2,{value:Promise.reject(h)}]));case 4:return $.sent(),[3,6];case 5:return k&&p&&k.removeEventListener("abort",p),[7];case 6:return[2]}})},d=this,p=1,s.label=1;case 1:return p<=this.numRetriesPerRequest+1?[5,f(p)]:[3,4];case 2:if("object"==typeof(m=s.sent()))return[2,m.value];s.label=3;case 3:return p++,[3,1];case 4:return this.logger.debug("Request #".concat(u,": No retries left. Raising last error")),[2,Promise.reject(h)]}})})},u.prototype.processStreamingLine=function(t){if(!t.trim()||"data: [DONE]"===t)return null;if(t.startsWith("data: "))return this.processDataLine(t.slice(6).trim());if(t.trim().startsWith("{"))try{var n=JSON.parse(t.trim());return n&&"object"==typeof n?(n.conversation_id||(n.conversation_id="unknown"),n.message||""===n.message||(n.message=""),n):{conversation_id:"unknown",message:JSON.stringify(n)}}catch(n){return{conversation_id:"unknown",message:t.trim()}}return{conversation_id:"unknown",message:t.trim()}},u.prototype.processDataLine=function(t){if(!t)return null;if(t.startsWith("{"))try{var n=JSON.parse(t);return n&&"object"==typeof n?(n.conversation_id||(n.conversation_id="unknown"),n.message||""===n.message||(n.message=""),n):{conversation_id:"unknown",message:JSON.stringify(n)}}catch(n){return{conversation_id:"unknown",message:t}}return{conversation_id:"unknown",message:t}},u.prototype.handleStreamingResponse=function(n,e){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return this.logger.debug("Handling streaming response. Environment: ".concat(c?"Node.js":"Browser")),c&&n.data?[2,this.handleNodeStreaming(n,e)]:c?(this.logger.debug("Processing non-streaming response"),this.invokeOnCompleteCallback(n.data,e),[2,Promise.resolve(n.data)]):[2,this.handleBrowserStreaming(n,e)]})})},u.prototype.handleNodeStreaming=function(t,n){var e=this;return this.logger.debug("Processing Node.js stream"),new Promise(function(r,i){var o=t.data,s=[],a="";o.on("data",function(t){var r;try{var o=t.toString(),c=(a+=o).split("\n");a=null!==(r=c.pop())&&void 0!==r?r:"",e.processStreamLines(c,s,n)}catch(t){i(t)}}),o.on("end",function(){if(a.trim().length>0){var i=a.split("\n");e.processStreamLines(i,s,n)}e.finalizeStreamResult(s,r,t,n)}),o.on("error",function(t){e.logger.error("Stream error: ".concat(t)),e.invokeOnErrorCallback(t,n),i(t)})})},u.prototype.handleBrowserStreaming=function(n,e){var r=this;return this.logger.debug("Processing browser stream"),new Promise(function(i,o){return t.j(r,void 0,void 0,function(){return t.k(this,function(t){try{return n.data&&"function"==typeof n.data.getReader?[2,this.handleBrowserReadableStream(n.data,i,o,n,e)]:"string"==typeof n.data?[2,this.handleBrowserStringResponse(n.data,i,n,e)]:"object"==typeof n.data&&null!==n.data?(this.logger.debug("No stream found, but data object is available"),this.invokeOnCompleteCallback(n.data,e),[2,i(n.data)]):(this.logger.error("No usable data found in response"),[2,o(Error("No usable data found in response"))])}catch(t){this.logger.error("Error processing streaming response: ".concat(t)),this.invokeOnErrorCallback(t,e),o(t)}return[2]})})})},u.prototype.handleBrowserReadableStream=function(n,e,r,i,o){return t.j(this,void 0,void 0,function(){var s,a,c,u,h,l,f,d,p,m;return t.k(this,function(t){switch(t.label){case 0:this.logger.debug("Found ReadableStream in response.data"),s=n.getReader(),a=[],c="",t.label=1;case 1:t.trys.push([1,5,,6]),t.label=2;case 2:return[4,s.read()];case 3:return u=t.sent(),h=u.done,l=u.value,h?(this.logger.debug("Stream reading complete"),c.trim()&&(f=c.split("\n"),this.processStreamLines(f,a,o)),[3,4]):(d=(new TextDecoder).decode(l),this.logger.debug("Received chunk: ".concat(d.length," bytes")),p=(c+=d).split("\n"),c=p.pop()||"",this.processStreamLines(p,a,o),[3,2]);case 4:return this.finalizeStreamResult(a,e,i,o),[3,6];case 5:return m=t.sent(),this.logger.error("Stream error: ".concat(m)),this.invokeOnErrorCallback(m,o),r(m),[3,6];case 6:return[2]}})})},u.prototype.handleBrowserStringResponse=function(t,n,e,r){this.logger.debug("Processing text response as stream data");var i=[],o=t.split("\n");if(this.processStreamLines(o,i,r),i.length>0){var s=this.combineStreamingChunks(i);this.invokeOnCompleteCallback(s,r),n(s)}else this.logger.debug("No chunks processed, returning original API response"),this.invokeOnCompleteCallback(e.data,r),n(e.data)},u.prototype.processStreamLines=function(t,n,e){for(var r=0,i=t;r<i.length;r++){var o=i[r];if(o.trim()&&"data: [DONE]"!==o){var s=this.processStreamingLine(o);null!==s&&(this.invokeOnChunkCallback(s,e),n.push(s))}}},u.prototype.finalizeStreamResult=function(t,n,e,r){if(t.length>0){var i=this.combineStreamingChunks(t);this.logger.debug("Stream processing complete"),this.invokeOnCompleteCallback(i,r),n(i)}else this.logger.debug("No chunks processed, returning original API response"),this.invokeOnCompleteCallback(e.data,r),n(e.data)},u.prototype.combineStreamingChunks=function(t){if(0===t.length)return{};if(1===t.length)return t[0];var n=this.getMessageChunks(t);if(n.length>0)return this.combineMessageChunks(t,n);var e=t[t.length-1];if(!this.isCompleteSearchResponse(e))throw Error("Last chunk is not a complete search response");return e},u.prototype.getMessageChunks=function(t){return t.filter(this.isChunkMessage)},u.prototype.isChunkMessage=function(t){return"object"==typeof t&&null!==t&&"message"in t&&"conversation_id"in t},u.prototype.combineMessageChunks=function(t,n){this.logger.debug("Found ".concat(n.length," message chunks to combine"));var e=t[t.length-1];if(this.isCompleteSearchResponse(e))return e;var r=t.find(this.isCompleteSearchResponse);if(!r)throw Error("No metadata chunk found");return r},u.prototype.isCompleteSearchResponse=function(t){return"object"==typeof t&&null!==t&&Object.keys(t).length>0&&("results"in t||"found"in t||"hits"in t||"page"in t||"search_time_ms"in t)},u.prototype.getNextNode=function(t){if(void 0===t&&(t=0),null!=this.nearestNode){if(this.logger.debug("Request #".concat(t,": Nodes Health: Node ").concat(this.nearestNode.index," is ").concat(!0===this.nearestNode.isHealthy?"Healthy":"Unhealthy")),!0===this.nearestNode.isHealthy||this.nodeDueForHealthcheck(this.nearestNode,t))return this.logger.debug("Request #".concat(t,": Updated current node to Node ").concat(this.nearestNode.index)),this.nearestNode;this.logger.debug("Request #".concat(t,": Falling back to individual nodes"))}this.logger.debug("Request #".concat(t,": Nodes Health: ").concat(this.nodes.map(function(t){return"Node ".concat(t.index," is ").concat(!0===t.isHealthy?"Healthy":"Unhealthy")}).join(" || ")));for(var n=this.nodes[0],e=0;e<=this.nodes.length;e++)if(this.currentNodeIndex=(this.currentNodeIndex+1)%this.nodes.length,!0===(n=this.nodes[this.currentNodeIndex]).isHealthy||this.nodeDueForHealthcheck(n,t))return this.logger.debug("Request #".concat(t,": Updated current node to Node ").concat(n.index)),n;return this.logger.debug("Request #".concat(t,": No healthy nodes were found. Returning the next node, Node ").concat(n.index)),n},u.prototype.nodeDueForHealthcheck=function(t,n){void 0===n&&(n=0);var e=Date.now()-t.lastAccessTimestamp>1e3*this.healthcheckIntervalSeconds;return e&&this.logger.debug("Request #".concat(n,": Node ").concat(t.index," has exceeded healtcheckIntervalSeconds of ").concat(this.healthcheckIntervalSeconds,". Adding it back into rotation.")),e},u.prototype.initializeMetadataForNodes=function(){var t=this;null!=this.nearestNode&&(this.nearestNode.index="nearestNode",this.setNodeHealthcheck(this.nearestNode,a)),this.nodes.forEach(function(n,e){n.index=e,t.setNodeHealthcheck(n,a)})},u.prototype.setNodeHealthcheck=function(t,n){t.isHealthy=n,t.lastAccessTimestamp=Date.now()},u.prototype.uriFor=function(t,n){return null!=n.url?"".concat(n.url).concat(t):"".concat(n.protocol,"://").concat(n.host,":").concat(n.port).concat(n.path).concat(t)},u.prototype.defaultHeaders=function(){var t={};return this.sendApiKeyAsQueryParam||(t["X-TYPESENSE-API-KEY"]=this.apiKey),t["Content-Type"]="application/json",t},u.prototype.timer=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,new Promise(function(t){return setTimeout(t,1e3*n)})]})})},u.prototype.customErrorForResponse=function(t,n,e){var r="Request failed with HTTP code ".concat(t.status);return"string"==typeof n&&""!==n.trim()&&(r+=" | Server said: ".concat(n)),new o.default(r,e,t.status),400===t.status?new i.RequestMalformed(r,e,t.status):401===t.status?new i.RequestUnauthorized(r,e,t.status):404===t.status?new i.ObjectNotFound(r,e,t.status):409===t.status?new i.ObjectAlreadyExists(r,e,t.status):422===t.status?new i.ObjectUnprocessable(r,e,t.status):t.status>=500&&t.status<=599?new i.ServerError(r,e,t.status):new i.HTTPError(r,e,t.status)},u.prototype.invokeOnChunkCallback=function(t,n){if(null==n?void 0:n.onChunk)try{n.onChunk(t)}catch(t){this.logger.warn("Error in onChunk callback: ".concat(t))}},u.prototype.invokeOnCompleteCallback=function(t,n){if(null==n?void 0:n.onComplete)try{n.onComplete(t)}catch(t){this.logger.warn("Error in onComplete callback: ".concat(t))}},u.prototype.invokeOnErrorCallback=function(t,n){if(null==n?void 0:n.onError){var e=(0,s.toErrorWithMessage)(t);try{n.onError(e)}catch(t){this.logger.warn("Error in onError callback: ".concat(t))}}},u}();return Ot.default=u,Ot}var Pt,Mt={};function Nt(){if(Pt)return Mt;Pt=1,Object.defineProperty(Mt,"i",{value:!0});var t=z,n="/collections",e=function(){function e(t){this.apiCall=t}return e.prototype.create=function(e,r){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.post(n,e,r)]})})},e.prototype.retrieve=function(){return t.j(this,arguments,void 0,function(e){return void 0===e&&(e={}),t.k(this,function(t){return[2,this.apiCall.get(n,e)]})})},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return n},enumerable:!1,configurable:!0}),e}();return Mt.default=e,Mt}var Ut,It,qt,Ft={},Lt={},Dt={},zt={};function Bt(){if(Ut)return zt;Ut=1,Object.defineProperty(zt,"i",{value:!0});var t=z,n=function(){function n(){this.responseCache=new Map,this.responsePromiseCache=new Map}return n.prototype.clearCache=function(){this.responseCache=new Map,this.responsePromiseCache=new Map},n.prototype.perform=function(n,e,r,i){return t.j(this,void 0,void 0,function(){var o,s,a,c,u,h,l,f,d,p,m,v,b,g,y,w,_,x,O,R,S;return t.k(this,function(t){switch(t.label){case 0:if(s=(o=i||{}).cacheResponseForSeconds,a=void 0===s?120:s,c=o.maxSize,u=void 0===c?100:c,h=void 0===i||a<=0||u<=0,l=r.path,f=r.queryParams,d=r.body,p=r.headers,m=r.streamConfig,v=r.abortSignal,b=r.responseType,g=r.isStreamingRequest,h)return[2,this.executeRequest(n,e,l,f,d,p,{abortSignal:v,responseType:b,streamConfig:m,isStreamingRequest:g})];if(y=JSON.stringify(r),w=this.responseCache.get(y),_=Date.now(),w){if(_-w.requestTimestamp<1e3*a)return this.responseCache.delete(y),this.responseCache.set(y,w),[2,w.response];this.responseCache.delete(y)}if(x=this.responsePromiseCache.get(y)){if(_-x.requestTimestamp<1e3*a)return this.responsePromiseCache.delete(y),this.responsePromiseCache.set(y,x),[2,x.responsePromise];this.responsePromiseCache.delete(y)}return O=this.executeRequest(n,e,l,f,d,p,{abortSignal:v,responseType:b,streamConfig:m,isStreamingRequest:g}),this.responsePromiseCache.set(y,{requestTimestamp:_,responsePromise:O}),[4,O];case 1:return R=t.sent(),this.responseCache.set(y,{requestTimestamp:_,response:R}),this.responseCache.size>u&&(S=this.responseCache.keys().next().value)&&this.responseCache.delete(S),this.responsePromiseCache.size>u&&(S=this.responsePromiseCache.keys().next().value)&&this.responsePromiseCache.delete(S),[2,R]}})})},n.prototype.executeRequest=function(t,n,e,r,i,o,s){void 0===r&&(r={});var a=t[n];switch(n){case"get":return a.call(t,e,r,{abortSignal:null==s?void 0:s.abortSignal,responseType:null==s?void 0:s.responseType,streamConfig:null==s?void 0:s.streamConfig,isStreamingRequest:null==s?void 0:s.isStreamingRequest});case"delete":return a.call(t,e,r);case"post":return a.call(t,e,i,r,o||{},{abortSignal:null==s?void 0:s.abortSignal,responseType:null==s?void 0:s.responseType,streamConfig:null==s?void 0:s.streamConfig,isStreamingRequest:null==s?void 0:s.isStreamingRequest});case"put":case"patch":return a.call(t,e,i,r);default:throw Error("Unsupported method: ".concat(n+""))}},n}();return zt.default=n,zt}function Ht(){if(It)return Dt;It=1,Object.defineProperty(Dt,"i",{value:!0}),Dt.SearchOnlyDocuments=void 0;var t=z,n=t.H(Bt()),e=t.H(Nt()),r=Tt(),i="/documents",o=function(){function o(t,e,r){this.collectionName=t,this.apiCall=e,this.configuration=r,this.requestWithCache=new n.default}return o.prototype.clearCache=function(){this.requestWithCache.clearCache()},o.prototype.search=function(n){return t.j(this,arguments,void 0,function(n,e){var i,o,s,a,c,u,h=void 0===e?{}:e,l=h.cacheSearchResultsForSeconds,f=void 0===l?this.configuration.cacheSearchResultsForSeconds:l,d=h.abortSignal,p=void 0===d?null:d;return t.k(this,function(e){return i={},!0===this.configuration.useServerSideSearchCache&&(i.use_cache=!0),o=(0,r.normalizeArrayableParams)(n),s=o.streamConfig,a=t.h(o,["streamConfig"]),c=t.u(t.u({},i),a),u=!0===c.conversation_stream,[2,this.requestWithCache.perform(this.apiCall,"get",{path:this.endpointPath("search"),queryParams:c,streamConfig:s,abortSignal:p,isStreamingRequest:u},{cacheResponseForSeconds:f})]})})},o.prototype.endpointPath=function(t){return"".concat(e.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.collectionName)).concat(i).concat(void 0===t?"":"/"+t)},Object.defineProperty(o,"RESOURCEPATH",{get:function(){return i},enumerable:!1,configurable:!0}),o}();return Dt.SearchOnlyDocuments=o,Dt}function Jt(){if(qt)return Lt;qt=1,Object.defineProperty(Lt,"i",{value:!0});var t=z,n=yt(),e=Ht(),r="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,i=function(e){function i(t,n,r){return e.call(this,t,n,r)||this}return t.o(i,e),i.prototype.create=function(n){return t.j(this,arguments,void 0,function(n,e){return void 0===e&&(e={}),t.k(this,function(t){if(!n)throw Error("No document provided");return[2,this.apiCall.post(this.endpointPath(),n,e)]})})},i.prototype.upsert=function(n){return t.j(this,arguments,void 0,function(n,e){return void 0===e&&(e={}),t.k(this,function(t){if(!n)throw Error("No document provided");return[2,this.apiCall.post(this.endpointPath(),n,Object.assign({},e,{action:"upsert"}))]})})},i.prototype.update=function(n){return t.j(this,arguments,void 0,function(n,e){return void 0===e&&(e={}),t.k(this,function(t){if(!n)throw Error("No document provided");return null!=e.filter_by?[2,this.apiCall.patch(this.endpointPath(),n,Object.assign({},e))]:[2,this.apiCall.post(this.endpointPath(),n,Object.assign({},e,{action:"update"}))]})})},i.prototype.delete=function(){return t.j(this,arguments,void 0,function(n){return void 0===n&&(n={}),t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath(),n)]})})},i.prototype.createMany=function(n){return t.j(this,arguments,void 0,function(n,e){return void 0===e&&(e={}),t.k(this,function(t){return this.configuration.logger.warn("createMany is deprecated and will be removed in a future version. Use import instead, which now takes both an array of documents or a JSONL string of documents"),[2,this.import(n,e)]})})},i.prototype.import=function(e){return t.j(this,arguments,void 0,function(e,i){var o,s,a,c,u;return void 0===i&&(i={}),t.k(this,function(h){switch(h.label){case 0:if(o=t.u({throwOnFail:!0},i),Array.isArray(e)){if(0===e.length)throw new n.RequestMalformed("No documents provided");try{s=e.map(function(t){return JSON.stringify(t)}).join("\n")}catch(t){if(t instanceof RangeError&&t.message.includes("Too many properties to enumerate"))throw Error("".concat(t,"\n          It looks like you have reached a Node.js limit that restricts the number of keys in an Object: https://stackoverflow.com/questions/9282869/are-there-limits-to-the-number-of-properties-in-a-javascript-object\n\n         Please try reducing the number of keys in your document, or using CURL to import your data.\n          "));throw Error(t)}}else if(null==(l=s=e)||""===l||0===l.length)throw new n.RequestMalformed("No documents provided");return[4,this.apiCall.performRequest("post",this.endpointPath("import"),{queryParameters:o,bodyParameters:s,additionalHeaders:{"Content-Type":"text/plain"},skipConnectionTimeout:!0,enableKeepAlive:!!r})];case 1:if(a=h.sent(),Array.isArray(e)){if(c=a.split("\n").map(function(t){return JSON.parse(t)}),(u=c.filter(function(t){return!1===t.success})).length>0&&o.throwOnFail)throw new n.ImportError("".concat(c.length-u.length," documents imported successfully, ").concat(u.length," documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document."),c,{documentsInJSONLFormat:s,options:o,failedItems:u,successCount:c.length-u.length});return[2,c]}return[2,a]}var l})})},i.prototype.importStream=function(e){return t.j(this,arguments,void 0,function(e,i){var o,s,a,c;return void 0===i&&(i={}),t.k(this,function(u){switch(u.label){case 0:return o=t.u({throwOnFail:!0},i),[4,this.apiCall.performRequest("post",this.endpointPath("import"),{queryParameters:o,bodyParameters:e,additionalHeaders:{"Content-Type":"text/plain"},skipConnectionTimeout:!0,enableKeepAlive:!!r})];case 1:if(s=u.sent(),a=s.split("\n").map(function(t){return JSON.parse(t)}),(c=a.filter(function(t){return!1===t.success})).length>0&&o.throwOnFail)throw new n.ImportError("".concat(a.length-c.length," documents imported successfully, ").concat(c.length," documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document."),a,{documentsInJSONLFormat:e,options:o,failedItems:c,successCount:a.length-c.length});return[2,a]}})})},i.prototype.export=function(){return t.j(this,arguments,void 0,function(n){return void 0===n&&(n={}),t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath("export"),n)]})})},i.prototype.exportStream=function(){return t.j(this,arguments,void 0,function(n){return void 0===n&&(n={}),t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath("export"),n,{responseType:"stream"})]})})},i}(e.SearchOnlyDocuments);return Lt.default=i,Lt}var Gt,Kt={};function Wt(){if(Gt)return Kt;Gt=1,Object.defineProperty(Kt,"i",{value:!0});var t=z,n=t.H(Nt()),e=function(){function e(t,n){this.collectionName=t,this.apiCall=n}return e.prototype.upsert=function(n,e){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(n),e)]})})},e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.endpointPath=function(t){return"".concat(n.default.RESOURCEPATH,"/").concat(this.collectionName).concat(e.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/overrides"},enumerable:!1,configurable:!0}),e}();return Kt.default=e,Kt}var Xt,Yt,Vt={},Zt={};function Qt(){if(Yt)return Zt;Yt=1,Object.defineProperty(Zt,"i",{value:!0});var t=z,n=t.H(Nt()),e=function(){function e(t,n){this.collectionName=t,this.apiCall=n}return e.prototype.upsert=function(n,e){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(n),e)]})})},e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.endpointPath=function(t){return e.hasWarnedDeprecation||(e.hasWarnedDeprecation=!0),"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.collectionName)).concat(e.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/synonyms"},enumerable:!1,configurable:!0}),e.hasWarnedDeprecation=!1,e}();return Zt.default=e,Zt}var tn,nn,en,rn,on={},sn={},an={};function cn(){if(rn)return an;rn=1,Object.defineProperty(an,"i",{value:!0});var t=z,n="/aliases",e=function(){function e(t){this.apiCall=t}return e.prototype.upsert=function(n,e){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(n),e)]})})},e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(n)]})})},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH,"/").concat(encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return n},enumerable:!1,configurable:!0}),e}();return an.default=e,an}var un,hn,ln={},fn={};function dn(){if(hn)return fn;hn=1,Object.defineProperty(fn,"i",{value:!0});var t=z,n=St,e=Tt(),r="/keys",i=function(){function i(t){this.apiCall=t,this.apiCall=t}return i.prototype.create=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.post(i.RESOURCEPATH,n)]})})},i.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(r)]})})},i.prototype.generateScopedSearchKey=function(t,r){var i=(0,e.normalizeArrayableParams)(r),o=JSON.stringify(i),s=Buffer.from((0,n.createHmac)("sha256",t).update(o).digest("base64")),a=t.substr(0,4),c="".concat(s).concat(a).concat(o);return Buffer.from(c).toString("base64")},Object.defineProperty(i,"RESOURCEPATH",{get:function(){return r},enumerable:!1,configurable:!0}),i}();return fn.default=i,fn}var pn,mn,vn,bn,gn,yn,wn,_n={},xn={},On={},Rn={},Sn={},jn={},kn={};function $n(){if(wn)return kn;wn=1,Object.defineProperty(kn,"i",{value:!0});var t=z,n=t.H(Bt()),e=Tt(),r=function(){function r(t,e,r){void 0===r&&(r=!1),this.apiCall=t,this.configuration=e,this.useTextContentType=r,this.requestWithCache=new n.default,this.logger=this.apiCall.logger}return r.prototype.clearCache=function(){this.requestWithCache.clearCache()},r.prototype.perform=function(n,r,i){return t.j(this,void 0,void 0,function(){var o,s,a,c,u,h,l;return t.k(this,function(f){return o=r?t.u({},r):{},s=null!==(l=null==i?void 0:i.cacheSearchResultsForSeconds)&&void 0!==l?l:this.configuration.cacheSearchResultsForSeconds,!0===this.configuration.useServerSideSearchCache&&(o.use_cache=!0),!0===n.union&&this.hasAnySearchObjectPagination(n)&&this.logger.warn("Individual `searches` pagination parameters are ignored when `union: true` is set. Use a top-level pagination parameter instead. See https://typesense.org/docs/29.0/api/federated-multi-search.html#union-search"),a={union:n.union,searches:n.searches.map(e.normalizeArrayableParams)},c=o.streamConfig,u=t.h(o,["streamConfig"]),h=(0,e.normalizeArrayableParams)(u),[2,this.requestWithCache.perform(this.apiCall,"post",{path:"/multi_search",body:a,queryParams:h,headers:this.useTextContentType?{"content-type":"text/plain"}:{},streamConfig:c,abortSignal:null==i?void 0:i.abortSignal,isStreamingRequest:this.isStreamingRequest(o)},void 0!==s?{cacheResponseForSeconds:s}:void 0)]})})},r.prototype.isStreamingRequest=function(t){return void 0!==t.streamConfig},r.prototype.hasAnySearchObjectPagination=function(t){return t.searches.some(function(t){return void 0!==t.page||void 0!==t.per_page||void 0!==t.offset||void 0!==t.limit||void 0!==t.limit_hits})},r}();return kn.default=r,kn}var En,Cn={};function Tn(){if(En)return Cn;En=1,Object.defineProperty(Cn,"i",{value:!0});var t=z,n=Tt(),e=function(){function e(t){this.apiCall=t}return e.prototype.upsert=function(e,r){return t.j(this,void 0,void 0,function(){var i,o;return t.k(this,function(t){return"object"==typeof r.value&&"searches"in r.value?(i=r.value.searches.map(function(t){return(0,n.normalizeArrayableParams)(t)}),[2,this.apiCall.put(this.endpointPath(e),{value:{searches:i}})]):(o=(0,n.normalizeArrayableParams)(r.value),[2,this.apiCall.put(this.endpointPath(e),{value:o})])})})},e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/presets"},enumerable:!1,configurable:!0}),e}();return Cn.default=e,Cn}var An,Pn,Mn={},Nn={},Un={};function In(){if(Pn)return Un;Pn=1,Object.defineProperty(Un,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t,this.apiCall=t}return n.prototype.upsert=function(n,e){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(n),e)]})})},n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},n.prototype.endpointPath=function(t){return"".concat(n.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(n,"RESOURCEPATH",{get:function(){return"/analytics/rules"},enumerable:!1,configurable:!0}),n}();return Un.default=n,Un}var qn,Fn,Ln,Dn={},zn={};function Bn(){if(Fn)return zn;Fn=1,Object.defineProperty(zn,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t,this.apiCall=t}return n.prototype.create=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.post(this.endpointPath(),n)]})})},n.prototype.retrieve=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath(),n)]})})},n.prototype.endpointPath=function(t){return"".concat(n.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(n,"RESOURCEPATH",{get:function(){return"/analytics/events"},enumerable:!1,configurable:!0}),n}();return zn.default=n,zn}var Hn,Jn={},Gn={};function Kn(){if(Hn)return Gn;Hn=1,Object.defineProperty(Gn,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t,this.apiCall=t}return n.prototype.create=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.post(this.endpointPath(),n,{},{})]})})},n.prototype.upsert=function(n,e){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(n),e)]})})},n.prototype.retrieve=function(n){return t.j(this,void 0,void 0,function(){var e;return t.k(this,function(t){return e={},n&&(e.rule_tag=n),[2,this.apiCall.get(this.endpointPath(),e)]})})},n.prototype.endpointPath=function(t){return"".concat(n.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(n,"RESOURCEPATH",{get:function(){return"/analytics/rules"},enumerable:!1,configurable:!0}),n}();return Gn.default=n,Gn}var Wn,Xn,Yn,Vn={},Zn={};function Qn(){if(Yn)return Zn;Yn=1,Object.defineProperty(Zn,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t}return n.prototype.upsert=function(n,e){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(n),e)]})})},n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},n.prototype.endpointPath=function(t){return"".concat(n.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(n,"RESOURCEPATH",{get:function(){return"/stopwords"},enumerable:!1,configurable:!0}),n}();return Zn.default=n,Zn}var te,ne,ee={},re={},ie={};function oe(){if(ne)return ie;ne=1,Object.defineProperty(ie,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t,this.apiCall=t}return n.prototype.create=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.post(this.endpointPath(),n)]})})},n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},n.prototype.endpointPath=function(t){return"".concat(n.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(n,"RESOURCEPATH",{get:function(){return"/conversations/models"},enumerable:!1,configurable:!0}),n}();return ie.default=n,ie}var se,ae,ce={};function ue(){if(ae)return re;ae=1,Object.defineProperty(re,"i",{value:!0});var t=z,n=t.H(oe()),e=t.H(function(){if(se)return ce;se=1,Object.defineProperty(ce,"i",{value:!0});var t=z,n=t.H(oe()),e=function(){function e(t,n){this.id=t,this.apiCall=n}return e.prototype.update=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(),n)]})})},e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.id))},e}();return ce.default=e,ce}()),r="/conversations",i=function(){function i(t){this.apiCall=t,this.individualConversationModels={},this.apiCall=t,this.et=new n.default(this.apiCall)}return i.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(r)]})})},i.prototype.models=function(t){return void 0===t?this.et:(void 0===this.individualConversationModels[t]&&(this.individualConversationModels[t]=new e.default(t,this.apiCall)),this.individualConversationModels[t])},Object.defineProperty(i,"RESOURCEPATH",{get:function(){return r},enumerable:!1,configurable:!0}),i}();return re.default=i,re}var he,le,fe={},de={},pe={};function me(){if(le)return pe;le=1,Object.defineProperty(pe,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t,this.apiCall=t}return n.prototype.upsert=function(n,e){return t.j(this,void 0,void 0,function(){var r,i;return t.k(this,function(t){switch(t.label){case 0:return r=Array.isArray(e)?e.map(function(t){return JSON.stringify(t)}).join("\n"):e,[4,this.apiCall.performRequest("post",this.endpointPath("import"),{queryParameters:{id:n},bodyParameters:r,additionalHeaders:{"Content-Type":"text/plain"},skipConnectionTimeout:!0})];case 1:return i=t.sent(),[2,Array.isArray(e)?i.split("\n").map(function(t){return JSON.parse(t)}):i]}})})},n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},n.prototype.endpointPath=function(t){return void 0===t?"".concat(n.RESOURCEPATH):"".concat(n.RESOURCEPATH,"/").concat(encodeURIComponent(t))},Object.defineProperty(n,"RESOURCEPATH",{get:function(){return"/stemming/dictionaries"},enumerable:!1,configurable:!0}),n}();return pe.default=n,pe}var ve,be,ge,ye={},we={};function _e(){if(ge)return we;ge=1,Object.defineProperty(we,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t}return n.prototype.create=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.post(this.endpointPath(),n)]})})},n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},n.prototype.endpointPath=function(){return n.RESOURCEPATH},Object.defineProperty(n,"RESOURCEPATH",{get:function(){return"/nl_search_models"},enumerable:!1,configurable:!0}),n}();return we.default=n,we}var xe,Oe,Re={},Se={};function je(){if(Oe)return Se;Oe=1,Object.defineProperty(Se,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t}return n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(n.RESOURCEPATH)]})})},n.RESOURCEPATH="/synonym_sets",n}();return Se.default=n,Se}var ke,$e,Ee,Ce,Te={},Ae={},Pe={},Me={};function Ne(){if(Ce)return Me;Ce=1,Object.defineProperty(Me,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t}return n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(n.RESOURCEPATH)]})})},n.RESOURCEPATH="/curation_sets",n}();return Me.default=n,Me}var Ue,Ie,qe,Fe,Le={},De={},ze={};var Be,He,Je,Ge={},Ke={},We=function(){if(Je)return i;Je=1,Object.defineProperty(i,"i",{value:!0}),i.Errors=i.SearchClient=i.Client=void 0;var t=z,n=t.H(function(){if(Fe)return H;Fe=1,Object.defineProperty(H,"i",{value:!0});var t=z,n=t.H(wt()),e=t.H(At()),r=t.H(Nt()),i=t.H(function(){if(en)return Ft;en=1,Object.defineProperty(Ft,"i",{value:!0});var t=z,n=t.H(Nt()),e=t.H(Jt()),r=yt(),i=t.H(Wt()),o=t.H(function(){if(Xt)return Vt;Xt=1,Object.defineProperty(Vt,"i",{value:!0});var t=z,n=t.H(Nt()),e=t.H(Wt()),r=function(){function r(t,n,e){this.collectionName=t,this.overrideId=n,this.apiCall=e}return r.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},r.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},r.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.collectionName)).concat(e.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.overrideId))},r}();return Vt.default=r,Vt}()),s=t.H(Qt()),a=t.H(function(){if(tn)return on;tn=1,Object.defineProperty(on,"i",{value:!0});var t=z,n=t.H(Nt()),e=t.H(Qt()),r=function(){function r(t,n,e){this.collectionName=t,this.synonymId=n,this.apiCall=e}return r.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},r.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},r.prototype.endpointPath=function(){return r.hasWarnedDeprecation||(r.hasWarnedDeprecation=!0),"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.collectionName)).concat(e.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.synonymId))},r.hasWarnedDeprecation=!1,r}();return on.default=r,on}()),c=function(){if(nn)return sn;nn=1,Object.defineProperty(sn,"i",{value:!0}),sn.Document=void 0;var t=z,n=t.H(Nt()),e=t.H(Jt()),r=function(){function r(t,n,e){this.collectionName=t,this.documentId=n,this.apiCall=e}return r.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},r.prototype.delete=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath(),n)]})})},r.prototype.update=function(n){return t.j(this,arguments,void 0,function(n,e){return void 0===e&&(e={}),t.k(this,function(t){return[2,this.apiCall.patch(this.endpointPath(),n,e)]})})},r.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.collectionName)).concat(e.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.documentId))},r}();return sn.Document=r,sn}(),u=function(){function u(t,n,r){this.name=t,this.apiCall=n,this.configuration=r,this.individualDocuments={},this.individualOverrides={},this.individualSynonyms={},this.name=t,this.apiCall=n,this.configuration=r,this.rt=new e.default(this.name,this.apiCall,this.configuration),this.it=new i.default(this.name,this.apiCall),this.ot=new s.default(this.name,this.apiCall)}return u.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},u.prototype.update=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.patch(this.endpointPath(),n)]})})},u.prototype.delete=function(){return t.j(this,arguments,void 0,function(n){return void 0===n&&(n={}),t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath(),n)]})})},u.prototype.exists=function(){return t.j(this,void 0,void 0,function(){var n;return t.k(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.retrieve()];case 1:return t.sent(),[2,!0];case 2:if((n=t.sent())instanceof r.ObjectNotFound)return[2,!1];throw n;case 3:return[2]}})})},u.prototype.documents=function(t){return t?(void 0===this.individualDocuments[t]&&(this.individualDocuments[t]=new c.Document(this.name,t,this.apiCall)),this.individualDocuments[t]):this.rt},u.prototype.overrides=function(t){return void 0===t?this.it:(void 0===this.individualOverrides[t]&&(this.individualOverrides[t]=new o.default(this.name,t,this.apiCall)),this.individualOverrides[t])},u.prototype.synonyms=function(t){return void 0===t?this.ot:(void 0===this.individualSynonyms[t]&&(this.individualSynonyms[t]=new a.default(this.name,t,this.apiCall)),this.individualSynonyms[t])},u.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},u}();return Ft.default=u,Ft}()),o=t.H(cn()),s=t.H(function(){if(un)return ln;un=1,Object.defineProperty(ln,"i",{value:!0});var t=z,n=t.H(cn()),e=function(){function e(t,n){this.name=t,this.apiCall=n}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();return ln.default=e,ln}()),a=t.H(dn()),c=t.H(function(){if(pn)return _n;pn=1,Object.defineProperty(_n,"i",{value:!0});var t=z,n=t.H(dn()),e=function(){function e(t,n){this.id=t,this.apiCall=n}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.id))},e}();return _n.default=e,_n}()),u=t.H(function(){if(mn)return xn;mn=1,Object.defineProperty(xn,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t}return n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get("/debug")]})})},n}();return xn.default=n,xn}()),h=t.H(function(){if(vn)return On;vn=1,Object.defineProperty(On,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t}return n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get("/metrics.json")]})})},n}();return On.default=n,On}()),l=t.H(function(){if(bn)return Rn;bn=1,Object.defineProperty(Rn,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t}return n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get("/stats.json")]})})},n}();return Rn.default=n,Rn}()),f=t.H(function(){if(gn)return Sn;gn=1,Object.defineProperty(Sn,"i",{value:!0});var t=z,n=function(){function n(t){this.apiCall=t}return n.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get("/health")]})})},n}();return Sn.default=n,Sn}()),d=t.H(function(){if(yn)return jn;yn=1,Object.defineProperty(jn,"i",{value:!0});var t=z,n="/operations",e=function(){function e(t){this.apiCall=t}return e.prototype.perform=function(e){return t.j(this,arguments,void 0,function(e,r){return void 0===r&&(r={}),t.k(this,function(t){return[2,this.apiCall.post("".concat(n,"/").concat(e),{},r)]})})},e.prototype.getSchemaChanges=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get("".concat(n,"/schema_changes"))]})})},e}();return jn.default=e,jn}()),p=t.H($n()),m=t.H(Tn()),v=t.H(function(){if(An)return Mn;An=1,Object.defineProperty(Mn,"i",{value:!0});var t=z,n=t.H(Tn()),e=function(){function e(t,n){this.presetId=t,this.apiCall=n}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.presetId))},e}();return Mn.default=e,Mn}()),b=t.H(function(){if(Ln)return Nn;Ln=1,Object.defineProperty(Nn,"i",{value:!0});var t=z,n=t.H(In()),e=t.H(function(){if(qn)return Dn;qn=1,Object.defineProperty(Dn,"i",{value:!0});var t=z,n=t.H(In()),e=function(){function e(t,n){this.name=t,this.apiCall=n}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();return Dn.default=e,Dn}()),r=t.H(Bn()),i=function(){function t(t){this.apiCall=t,this.individualAnalyticsRules={},this.apiCall=t,this.st=new n.default(this.apiCall),this.ct=new r.default(this.apiCall)}return t.prototype.rules=function(n){return t.hasWarnedDeprecation||(t.hasWarnedDeprecation=!0),void 0===n?this.st:(void 0===this.individualAnalyticsRules[n]&&(this.individualAnalyticsRules[n]=new e.default(n,this.apiCall)),this.individualAnalyticsRules[n])},t.prototype.events=function(){return this.ct},Object.defineProperty(t,"RESOURCEPATH",{get:function(){return"/analytics"},enumerable:!1,configurable:!0}),t.hasWarnedDeprecation=!1,t}();return Nn.default=i,Nn}()),g=t.H(function(){if(Xn)return Jn;Xn=1,Object.defineProperty(Jn,"i",{value:!0});var t=z,n=t.H(Kn()),e=t.H(function(){if(Wn)return Vn;Wn=1,Object.defineProperty(Vn,"i",{value:!0});var t=z,n=t.H(Kn()),e=function(){function e(t,n){this.name=t,this.apiCall=n}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();return Vn.default=e,Vn}()),r=t.H(Bn()),i=function(){function t(t){this.apiCall=t,this.individualAnalyticsRules={},this.apiCall=t,this.st=new n.default(this.apiCall),this.ct=new r.default(this.apiCall)}return t.prototype.rules=function(t){return void 0===t?this.st:(void 0===this.individualAnalyticsRules[t]&&(this.individualAnalyticsRules[t]=new e.default(t,this.apiCall)),this.individualAnalyticsRules[t])},t.prototype.events=function(){return this.ct},Object.defineProperty(t,"RESOURCEPATH",{get:function(){return"/analytics"},enumerable:!1,configurable:!0}),t}();return Jn.default=i,Jn}()),y=t.H(Qn()),w=t.H(function(){if(te)return ee;te=1,Object.defineProperty(ee,"i",{value:!0});var t=z,n=t.H(Qn()),e=function(){function e(t,n){this.stopwordId=t,this.apiCall=n}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.stopwordId))},e}();return ee.default=e,ee}()),_=t.H(ue()),x=t.H(function(){if(he)return fe;he=1,Object.defineProperty(fe,"i",{value:!0});var t=z,n=t.H(ue()),e=function(){function e(t,n){this.id=t,this.apiCall=n}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.update=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(),n)]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.id))},e}();return fe.default=e,fe}()),O=t.H(function(){if(be)return de;be=1,Object.defineProperty(de,"i",{value:!0});var t=z,n=t.H(me()),e=t.H(function(){if(ve)return ye;ve=1,Object.defineProperty(ye,"i",{value:!0});var t=z,n=t.H(me()),e=function(){function e(t,n){this.id=t,this.apiCall=n}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.id))},e}();return ye.default=e,ye}()),r=function(){function t(t){this.apiCall=t,this.individualStemmingDictionaries={},this.apiCall=t,this.ut=new n.default(this.apiCall)}return t.prototype.dictionaries=function(t){return void 0===t?this.ut:(void 0===this.individualStemmingDictionaries[t]&&(this.individualStemmingDictionaries[t]=new e.default(t,this.apiCall)),this.individualStemmingDictionaries[t])},Object.defineProperty(t,"RESOURCEPATH",{get:function(){return"/stemming"},enumerable:!1,configurable:!0}),t}();return de.default=r,de}()),R=t.H(_e()),S=t.H(function(){if(xe)return Re;xe=1,Object.defineProperty(Re,"i",{value:!0});var t=z,n=t.H(_e()),e=function(){function e(t,n){this.id=t,this.apiCall=n}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.update=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(),n)]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.id))},e}();return Re.default=e,Re}()),j=t.H(je()),k=t.H(function(){if(Ee)return Te;Ee=1,Object.defineProperty(Te,"i",{value:!0});var t=z,n=t.H(je()),e=t.H(function(){if(ke)return Ae;ke=1,Object.defineProperty(Ae,"i",{value:!0});var t=z,n=t.H(je()),e=function(){function e(t,n){this.synonymSetName=t,this.apiCall=n}return e.prototype.upsert=function(n,e){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(n),e)]})})},e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.endpointPath=function(t){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.synonymSetName),"/items").concat(void 0===t?"":"/"+encodeURIComponent(t))},e}();return Ae.default=e,Ae}()),r=t.H(function(){if($e)return Pe;$e=1,Object.defineProperty(Pe,"i",{value:!0});var t=z,n=t.H(je()),e=function(){function e(t,n,e){this.synonymSetName=t,this.itemId=n,this.apiCall=e}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.synonymSetName),"/items/").concat(encodeURIComponent(this.itemId))},e}();return Pe.default=e,Pe}()),i=function(){function i(t,n){this.synonymSetName=t,this.apiCall=n,this.individualItems={},this.ht=new e.default(this.synonymSetName,n)}return i.prototype.upsert=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(),n)]})})},i.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},i.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},i.prototype.items=function(t){return void 0===t?this.ht:(void 0===this.individualItems[t]&&(this.individualItems[t]=new r.default(this.synonymSetName,t,this.apiCall)),this.individualItems[t])},i.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.synonymSetName))},i}();return Te.default=i,Te}()),$=t.H(Ne()),E=t.H(function(){if(qe)return Le;qe=1,Object.defineProperty(Le,"i",{value:!0});var t=z,n=t.H(Ne()),e=t.H(function(){if(Ue)return De;Ue=1,Object.defineProperty(De,"i",{value:!0});var t=z,n=t.H(Ne()),e=function(){function e(t,n){this.name=t,this.apiCall=n}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.endpointPath=function(t){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name),"/items").concat(void 0===t?"":"/"+encodeURIComponent(t))},e}();return De.default=e,De}()),r=t.H(function(){if(Ie)return ze;Ie=1,Object.defineProperty(ze,"i",{value:!0});var t=z,n=t.H(Ne()),e=function(){function e(t,n,e){this.name=t,this.itemId=n,this.apiCall=e}return e.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},e.prototype.upsert=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(),n)]})})},e.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},e.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name),"/items/").concat(encodeURIComponent(this.itemId))},e}();return ze.default=e,ze}()),i=function(){function i(t,n){this.name=t,this.apiCall=n,this.individualItems={},this.ht=new e.default(this.name,n)}return i.prototype.upsert=function(n){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.put(this.endpointPath(),n)]})})},i.prototype.retrieve=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.get(this.endpointPath())]})})},i.prototype.delete=function(){return t.j(this,void 0,void 0,function(){return t.k(this,function(t){return[2,this.apiCall.delete(this.endpointPath())]})})},i.prototype.items=function(t){return void 0===t?this.ht:(void 0===this.individualItems[t]&&(this.individualItems[t]=new r.default(this.name,t,this.apiCall)),this.individualItems[t])},i.prototype.endpointPath=function(){return"".concat(n.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},i}();return Le.default=i,Le}()),C=function(){function t(t){var i;t.sendApiKeyAsQueryParam=null!==(i=t.sendApiKeyAsQueryParam)&&void 0!==i&&i,this.configuration=new n.default(t),this.apiCall=new e.default(this.configuration),this.debug=new u.default(this.apiCall),this.metrics=new h.default(this.apiCall),this.stats=new l.default(this.apiCall),this.health=new f.default(this.apiCall),this.operations=new d.default(this.apiCall),this.multiSearch=new p.default(this.apiCall,this.configuration),this.lt=new r.default(this.apiCall),this.individualCollections={},this.ft=new o.default(this.apiCall),this.individualAliases={},this.dt=new a.default(this.apiCall),this.individualKeys={},this.vt=new m.default(this.apiCall),this.individualPresets={},this.bt=new y.default(this.apiCall),this.individualStopwords={},this.analytics=new g.default(this.apiCall),this.analyticsV1=new b.default(this.apiCall),this.stemming=new O.default(this.apiCall),this.gt=new _.default(this.apiCall),this.individualConversations={},this.yt=new R.default(this.apiCall),this.individualNLSearchModels={},this.wt=new j.default(this.apiCall),this.individualSynonymSets={},this._t=new $.default(this.apiCall),this.individualCurationSets={}}return t.prototype.collections=function(t){return void 0===t?this.lt:(void 0===this.individualCollections[t]&&(this.individualCollections[t]=new i.default(t,this.apiCall,this.configuration)),this.individualCollections[t])},t.prototype.aliases=function(t){return void 0===t?this.ft:(void 0===this.individualAliases[t]&&(this.individualAliases[t]=new s.default(t,this.apiCall)),this.individualAliases[t])},t.prototype.keys=function(t){return void 0===t?this.dt:(void 0===this.individualKeys[t]&&(this.individualKeys[t]=new c.default(t,this.apiCall)),this.individualKeys[t])},t.prototype.presets=function(t){return void 0===t?this.vt:(void 0===this.individualPresets[t]&&(this.individualPresets[t]=new v.default(t,this.apiCall)),this.individualPresets[t])},t.prototype.stopwords=function(t){return void 0===t?this.bt:(void 0===this.individualStopwords[t]&&(this.individualStopwords[t]=new w.default(t,this.apiCall)),this.individualStopwords[t])},t.prototype.conversations=function(t){return void 0===t?this.gt:(void 0===this.individualConversations[t]&&(this.individualConversations[t]=new x.default(t,this.apiCall)),this.individualConversations[t])},t.prototype.nlSearchModels=function(t){return void 0===t?this.yt:(void 0===this.individualNLSearchModels[t]&&(this.individualNLSearchModels[t]=new S.default(t,this.apiCall)),this.individualNLSearchModels[t])},t.prototype.synonymSets=function(t){return void 0===t?this.wt:(void 0===this.individualSynonymSets[t]&&(this.individualSynonymSets[t]=new k.default(t,this.apiCall)),this.individualSynonymSets[t])},t.prototype.curationSets=function(t){return void 0===t?this._t:(void 0===this.individualCurationSets[t]&&(this.individualCurationSets[t]=new E.default(t,this.apiCall)),this.individualCurationSets[t])},t}();return H.default=C,H}());i.Client=n.default;var e=t.H(function(){if(He)return Ge;He=1,Object.defineProperty(Ge,"i",{value:!0});var t=z,n=t.H(wt()),e=t.H(At()),r=t.H($n()),i=function(){if(Be)return Ke;Be=1,Object.defineProperty(Ke,"i",{value:!0}),Ke.SearchOnlyCollection=void 0;var t=Ht(),n=function(){function n(n,e,r){this.name=n,this.apiCall=e,this.configuration=r,this.rt=new t.SearchOnlyDocuments(this.name,this.apiCall,this.configuration)}return n.prototype.documents=function(){return this.rt},n}();return Ke.SearchOnlyCollection=n,Ke}(),o=function(){function t(t){var i;t.sendApiKeyAsQueryParam=null===(i=t.sendApiKeyAsQueryParam)||void 0===i||i,!0===t.sendApiKeyAsQueryParam&&(t.apiKey||"").length>2e3&&(t.sendApiKeyAsQueryParam=!1),this.configuration=new n.default(t),this.apiCall=new e.default(this.configuration),this.multiSearch=new r.default(this.apiCall,this.configuration,!0),this.individualCollections={}}return t.prototype.clearCache=function(){this.multiSearch.clearCache(),Object.entries(this.individualCollections).forEach(function(t){t[0],t[1].documents().clearCache()})},t.prototype.collections=function(t){if(t)return void 0===this.individualCollections[t]&&(this.individualCollections[t]=new i.SearchOnlyCollection(t,this.apiCall,this.configuration)),this.individualCollections[t];throw Error("Typesense.SearchClient only supports search operations, so the collectionName that needs to be searched must be specified. Use Typesense.Client if you need to access the collection object.")},t}();return Ge.default=o,Ge}());i.SearchClient=e.default;var r=t.B(yt());return i.Errors=r,i.default={Client:n.default,SearchClient:e.default,Errors:r},i}();const Xe=e(We);!function(){let n=!1,e=null;const r=["palette","discovery"],i=["system","theme","sans","serif","mono"],o=function(){try{if(document.currentScript&&document.currentScript.src)return document.currentScript.src;const t=document.getElementsByTagName("script");for(let n=t.length-1;n>=0;n--)if(t[n].src&&/(^|\/)search(\.min)?\.js(\?|$)/.test(t[n].src))return t[n].src}catch{}return""}(),s={},a={};function c(t){if(t&&"function"==typeof t.showModal&&!t.open)try{t.showModal()}catch{}}function u(t){t&&"function"==typeof t.close&&t.open&&t.close()}window.__mpRegisterSearchLayout=function(t,n){s[t]=n};let h=null;function l(t){if(h||!t||"function"!=typeof t.getAttribute)return;const n=t.getAttribute("data-key"),e=t.getAttribute("data-sodo-search");n&&e&&(h={key:n,url:e})}try{const t=document.currentScript;l(t&&t.hasAttribute("data-sodo-search")?t:document.querySelector("script[data-sodo-search]"))}catch{}function f(){if(!n)return;const t=document.querySelector("script[data-sodo-search]");t&&(l(t),t.remove());const e=document.getElementById("sodo-search-root");e&&e.remove()}const d="mp-search";function p(t,n,e){if(Math.abs(t.length-n.length)>e)return e+1;let r=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const o=[i];let s=i;for(let e=1;e<=n.length;e++){const a=t[i-1]===n[e-1]?0:1;o[e]=Math.min(r[e]+1,o[e-1]+1,r[e-1]+a),o[e]<s&&(s=o[e])}if(s>e)return e+1;r=o}return r[n.length]}function m(t){const n=[],e=t=>{Array.isArray(t)?t.forEach(e):"string"==typeof t&&t&&n.push(t)},r=t=>{t&&"object"==typeof t&&(Array.isArray(t)?t.forEach(r):(void 0!==t.matched_tokens&&e(t.matched_tokens),Object.values(t).forEach(t=>{t&&"object"==typeof t&&r(t)})))};return r(t&&t.highlight),r(t&&t.highlights),n}const v="/members/api/member";function b(t){return((t||"")+"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function g(t){return b(t).split(/[^\p{L}\p{N}]+/u).filter(Boolean)}function y(t){if(!t||"string"!=typeof t.name||!t.name.trim())return!1;if("string"!=typeof t.url||!t.url)return!1;try{const{protocol:n}=new URL(t.url,window.location.href);return"http:"===n||"https:"===n}catch{return!1}}class w extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.isModalOpen=!1,this.activeElement=null,this.scrollPosition=0,this.selectedIndex=-1,this.searchDebounceTimeout=null,this.surfaceReady=new Promise(t=>{this.markSurfaceReady=t}),this.searchSequence=0,this.cachedElements={},this.typesenseClient=null,this.authorProfiles=null,this.authorProfilesRequested=!1,this.lastQuery="",this.lastTrackedQuery=null,this.selectedFacets={},this.expandedFacets={},this.fetchedSuggestions=[],this.suggestionsFetched=!1,this.readerAccess="unknown",this.readerAccessPromise=null,this.defaultI18n={searchPlaceholder:"Search for anything",commonSearchesTitle:"Common searches",emptyStateMessage:"Start typing to search...",loadingMessage:"Searching...",noResultsMessage:"No results found for your search",didYouMeanLabel:"Did you mean {q}?",errorMessage:"Search is temporarily unavailable",errorHint:"Check your connection and try again.",navigateHint:"to navigate",closeHint:"to close",ariaSearchLabel:"Search",ariaCloseLabel:"Close search",ariaResultsLabel:"Search results",ariaArticleExcerpt:"Article excerpt",ariaModalLabel:"Search",ariaFacetsLabel:"Filters",clearFiltersLabel:"Clear filters",facetShowMoreLabel:"Show more",facetShowLessLabel:"Show less",membersLabel:"Members",ariaMembersLabel:"Members-only content",paidLabel:"Paid members",ariaPaidLabel:"Paid-members-only content",untitledPost:"Untitled",authorsGroupLabel:"Authors",relativeNow:"just now",relativeMinutes:"{n}m ago",relativeHours:"{n}h ago",relativeDays:"{n}d ago",relativeMonths:"{n}mo ago",relativeYears:"{n}y ago",paletteRecentGroup:"Recent searches",paletteRecentLabel:"recent",palettePostsGroup:"Posts",paletteTagsGroup:"Filter by topic",paletteAuthorsGroup:"Filter by author",paletteFilterAction:"Filter",paletteEmptyTitle:"Start typing to search",paletteEmptySub:"Posts, tags, and authors — fast.",paletteNoResultsTitle:"No results for “{q}”",paletteNoResultsSub:"Try a different term.",paletteSearching:"Searching…",paletteResultCountOne:"{n} result",paletteResultCountOther:"{n} results",paletteHintNavigate:"navigate",paletteHintOpen:"open",paletteHintNewTab:"new tab",paletteHintClose:"close",paletteRelativeNow:"just now",paletteRelativeMinutes:"{n}m ago",paletteRelativeHours:"{n}h ago",paletteRelativeDays:"{n}d ago",paletteRelativeMonths:"{n}mo ago",paletteRelativeYears:"{n}y ago",facetTopicsLabel:"Topics",facetAuthorsLabel:"Authors",byLabel:"By",readPostLabel:"Read post",resultLabel:"result",resultsLabel:"results",discoveryPreviewLabel:"Result preview",discoverySelectPrompt:"Select a result to preview it.",discoveryNoSelection:"No post selected.",discoveryEmptyTitle:"Search the archive",discoveryEmptyHint:"Start typing to explore posts. Use ↑ ↓ to move and ↵ to open.",discoveryNoFilters:"No filters available.",discoveryGatedNotice:"This post is available to members. Only the public teaser is shown here.",discoveryPaidNotice:"This post is available to paid members. Only the public teaser is shown here."}}connectedCallback(){if(n)return;const t=window.__MP_SEARCH_CONFIG__||{typesenseNodes:[{host:"localhost",port:"8108",protocol:"http"}],typesenseApiKey:null,collectionName:null,commonSearches:[],theme:"system",enableHighlighting:!0,enableDidYouMean:!0,searchFields:{title:{weight:5,highlight:!0},excerpt:{weight:3,highlight:!0},plaintext:{weight:4,highlight:!0},"tags.name":{weight:4,highlight:!0},"tags.slug":{weight:3,highlight:!0}}};if(this.config={...t,commonSearches:t.commonSearches||[],pinnedSearches:t.pinnedSearches||[],facets:t.facets||[],template:"grid"===t.template?"grid":"list",uiStyle:r.includes(t.uiStyle)?t.uiStyle:"modal",fontFamily:i.includes(t.fontFamily)?t.fontFamily:"system",showDates:!1!==t.showDates,showGroupLabels:!1!==t.showGroupLabels,memberAwareBadges:!0===t.memberAwareBadges,memberEndpoint:"string"==typeof t.memberEndpoint&&t.memberEndpoint.trim()?t.memberEndpoint.trim():v,showAuthorProfiles:!0===t.showAuthorProfiles,ghostContentApiKey:"string"==typeof t.ghostContentApiKey&&t.ghostContentApiKey.trim()?t.ghostContentApiKey.trim():null,ghostUrl:"string"==typeof t.ghostUrl&&t.ghostUrl.trim()?t.ghostUrl.trim():null},!this.config.typesenseNodes||!this.config.typesenseApiKey||!this.config.collectionName)throw Error("MagicPagesSearch: Missing required Typesense configuration");this.i18n={...this.defaultI18n,...this.config.i18n||{}},this.locale=this.config.locale||"en",this.resolveReaderAccess(),this.initReady=this.init(),this.initReady.then(this.markSurfaceReady,this.markSurfaceReady),n=!0}t(t){return this.i18n[t]||this.defaultI18n[t]||t}escapeHtmlAttr(t){return((t??"")+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}toRelativeUrl(t){if(!t)return"#";try{const n=new URL(t);return n.pathname+n.search+n.hash}catch{return t}}isAnalyticsEnabled(){return!(!this.config.analytics||!this.config.analytics.endpoint)}sendAnalyticsEvent(t){if(this.isAnalyticsEnabled())try{const{endpoint:n,siteId:e,token:r}=this.config.analytics,i={...t,siteId:e||null,token:r||void 0,ts:Date.now()},o=JSON.stringify(i);if("function"==typeof fetch)return void fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:o,keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{});if(navigator.sendBeacon){const t=new Blob([o],{type:"application/json"});navigator.sendBeacon(n,t)}}catch{}}trackSearch(t,n){this.isAnalyticsEnabled()&&t&&t!==this.lastTrackedQuery&&(this.lastTrackedQuery=t,this.sendAnalyticsEvent({type:"search",q:t,resultCount:n}),0===n&&this.sendAnalyticsEvent({type:"zero_result",q:t,resultCount:0}))}trackClick(t,n){this.isAnalyticsEnabled()&&this.lastQuery&&this.sendAnalyticsEvent({type:"click",q:this.lastQuery,resultId:t||null,position:"number"==typeof n?n:null})}getSuggestions(){const t=[...this.config.pinnedSearches||[],...this.fetchedSuggestions||[],...this.config.commonSearches||[]],n=new Set,e=[];for(const r of t){if("string"!=typeof r)continue;const t=r.trim();if(!t)continue;const i=t.toLowerCase();n.has(i)||(n.add(i),e.push(t))}return e}async fetchSuggestions(){if(!this.suggestionsFetched&&this.config.suggestionsUrl){this.suggestionsFetched=!0;try{const t=await fetch(this.config.suggestionsUrl,{method:"GET",mode:"cors",credentials:"omit"});if(!t.ok)return;const n=await t.json(),e=Array.isArray(n)?n:n?.suggestions;Array.isArray(e)&&(this.fetchedSuggestions=e.filter(t=>"string"==typeof t))}catch{}}}renderSuggestions(){this.commonSearches&&(this.commonSearches.innerHTML=this.getCommonSearchesInnerHtml(),this.attachCommonSearchListeners())}authorIndexSource(){if(!h)try{l(document.querySelector("script[data-sodo-search]"))}catch{}const t=this.config.ghostContentApiKey||h&&h.key;return t?{key:t,url:((this.config.ghostUrl||h&&h.url||window.location.origin)+"").replace(/\/+$/,"")}:null}loadAuthorProfiles(){if(!this.config.showAuthorProfiles||this.authorProfilesRequested)return;this.authorProfilesRequested=!0;const t=this.authorIndexSource();if(!t)return;const n="mp-search-authors:"+t.url;try{const t=JSON.parse(window.sessionStorage.getItem(n)||"null");if(Array.isArray(t))return void(this.authorProfiles=t.filter(y))}catch{}this.authorProfilesLoad=this.fetchAuthorProfiles(t).then(t=>{if(t){this.authorProfiles=t;try{window.sessionStorage.setItem(n,JSON.stringify(t))}catch{}this.isModalOpen&&this.refreshAuthorProfiles()}})}async fetchAuthorProfiles(t){try{const n=await fetch(`${t.url}/ghost/api/content/search-index/authors/?key=${encodeURIComponent(t.key)}`,{method:"GET",credentials:"omit"});if(!n.ok)return null;const e=await n.json();return e&&Array.isArray(e.authors)?e.authors.filter(y).map(t=>({id:t.id||null,slug:t.slug||null,name:t.name.trim(),url:t.url,profile_image:"string"==typeof t.profile_image&&t.profile_image?t.profile_image:null})):null}catch{return null}}normalizeAuthorProfile(t){const n=(Array.from(t.name)[0]||"").toUpperCase(),e=t.profile_image?`<img class="${d}-author-avatar" src="${this.escapeHtmlAttr(t.profile_image)}" alt="" loading="lazy" />`:`<span class="${d}-author-avatar ${d}-author-avatar-empty" aria-hidden="true">${this.escapeHtmlAttr(n)}</span>`;return{id:t.id,slug:t.slug,name:t.name,url:this.config.transformToRelativeUrls?this.toRelativeUrl(t.url):t.url,profileImage:t.profile_image,avatarHtml:e}}matchAuthorProfiles(t){if(!this.config.showAuthorProfiles||!Array.isArray(this.authorProfiles))return[];const n=g(t);return n.join("").length<2?[]:this.authorProfiles.filter(t=>function(t,n){const e=g(t);return n.every(t=>e.some(n=>n.startsWith(t)))}(t.name,n)).slice(0,3).map(t=>this.normalizeAuthorProfile(t))}findAuthorProfile(t){if(!this.config.showAuthorProfiles||!Array.isArray(this.authorProfiles))return null;const n=b(t).trim();if(!n)return null;const e=this.authorProfiles.find(t=>b(t.name)===n);return e?this.normalizeAuthorProfile(e):null}refreshAuthorProfiles(){this.activeLayout?"function"==typeof this.activeLayout.renderAuthorProfiles&&this.activeLayout.renderAuthorProfiles():this.renderAuthorProfiles(this.searchInput?this.searchInput.value:"")}renderAuthorProfiles(t){if(!this.authorsContainer)return;const n=this.matchAuthorProfiles(t);if(!n.length)return this.authorsContainer.innerHTML="",void this.authorsContainer.classList.add(d+"-hidden");this.authorsContainer.innerHTML=`\n                <div class="${d}-authors-title" aria-hidden="true">${this.escapeHtmlAttr(this.t("authorsGroupLabel"))}</div>\n                <div class="${d}-authors-list">\n                    ${n.map(t=>`\n                        <a href="${this.escapeHtmlAttr(t.url)}" class="${d}-author-link"${t.id?` data-author-id="${this.escapeHtmlAttr(t.id)}"`:""}>\n                            ${t.avatarHtml}\n                            <span class="${d}-author-name">${this.escapeHtmlAttr(t.name)}</span>\n                        </a>\n                    `).join("")}\n                </div>\n            `,this.authorsContainer.classList.remove(d+"-hidden")}isDarkTheme(){const t=window.matchMedia("(prefers-color-scheme: dark)").matches;return"light"!==this.config.theme&&("dark"===this.config.theme||t)}matchedSnippet(t,n){if(!this.config.enableHighlighting||!t||!t.highlight)return null;const e=t.highlight[n];return e?Array.isArray(e.matched_tokens)&&0===e.matched_tokens.length?null:e.snippet||e.value||null:null}normalizeHit(t,n){const e=t.document||{},r=((n,e)=>this.config.enableHighlighting&&t.highlight&&t.highlight[n]&&(t.highlight[n].snippet||t.highlight[n].value)||e)("title",this.escapeHtmlAttr(e.title))||this.t("untitledPost");let i=this.matchedSnippet(t,"excerpt")||this.matchedSnippet(t,"plaintext")||this.escapeHtmlAttr(e.excerpt||(e.plaintext||"").substring(0,160)||"");i&&i.length>200&&(i=i.substring(0,200)+"...");const o=this.config.transformToRelativeUrls?this.toRelativeUrl(e.url):e.url||"#",s=!!e.visibility&&"public"!==e.visibility;return{id:e.id,position:n,url:o,title:e.title||"",titleHtml:r,ariaTitle:this.escapeHtmlAttr((r+"").replace(/<[^>]*>/g,"")),excerptHtml:i,isGated:s,access:this.accessLevel(e.visibility),showBadge:this.needsBadge(e.visibility),visibility:e.visibility||"public",featureImage:e.feature_image||null,tags:Array.isArray(e.tags)?e.tags:[],authors:Array.isArray(e.authors)?e.authors:[],publishedAt:"number"==typeof e.published_at?e.published_at:null}}buildLayoutContext(){return{prefix:d,config:this.config,shadowRoot:this.shadowRoot,t:t=>this.t(t),escapeHtmlAttr:t=>this.escapeHtmlAttr(t),toRelativeUrl:t=>this.toRelativeUrl(t),getSuggestions:()=>this.getSuggestions(),getAuthorProfiles:t=>this.matchAuthorProfiles(t),findAuthorProfile:t=>this.findAuthorProfile(t),getSelectedFacets:()=>this.selectedFacets,toggleFacet:(t,n)=>{this.selectedFacets[t]||(this.selectedFacets[t]=new Set);const e=this.selectedFacets[t];e.has(n)?e.delete(n):e.add(n)},clearFacets:()=>{this.selectedFacets={}},getFacetRows:(t,n)=>{const e=(this.config.facets||[]).find(n=>n.field===t);return e?this.facetRows(e,Array.isArray(n)?n:[]):null},expandFacet:t=>this.expandFacet(t),collapseFacet:t=>this.collapseFacet(t),setFacetFilter:()=>{},search:t=>this.handleSearch(t),requery:()=>this.rerunQuery(),trackSearch:(t,n)=>this.trackSearch(t,n),trackClick:(t,n)=>this.trackClick(t,n),emitClick:(t,n)=>this.trackClick(t,n),close:()=>this.closeModal(),enterTopLayer:t=>c(t),exitTopLayer:t=>u(t),log:()=>{}}}async init(){if(this.applyFontFamily(),this.config.uiStyle&&"modal"!==this.config.uiStyle&&r.includes(this.config.uiStyle)){let n;try{n=await function(t){if(s[t])return Promise.resolve(s[t]);if(a[t])return a[t];const n=new Promise((n,e)=>{const r=document.createElement("script");r.src=function(t){const n=t+".min.js";return o?o.replace(/[^/]+(\?.*)?$/,n):n}(t),r.async=!0,r.onload=()=>{s[t]?n(s[t]):e(Error(`layout chunk "${t}" loaded but did not register`))},r.onerror=()=>e(Error(`failed to load layout chunk "${t}"`)),document.head.appendChild(r)});return a[t]=n,n.catch(()=>{delete a[t]}),n}(this.config.uiStyle)}catch(t){this.config.uiStyle="modal"}if(n)try{this.ctx=this.buildLayoutContext(),this.activeLayout=n(this.ctx);const e=document.createElement("style");e.textContent=t,this.shadowRoot.appendChild(e),"function"==typeof this.activeLayout.injectStyles&&this.activeLayout.injectStyles(this.shadowRoot);const r=document.createElement("div");for(r.innerHTML=this.activeLayout.buildMarkup();r.firstChild;)this.shadowRoot.appendChild(r.firstChild);return this.activeLayout.cacheElements(this.shadowRoot),this.activeLayout.setTheme(this.isDarkTheme()),this.activeLayout.bindEvents(),"function"==typeof this.activeLayout.handleKeydown&&this.shadowRoot.addEventListener("keydown",t=>{this.isModalOpen&&this.activeLayout.handleKeydown(t)&&t.stopPropagation()}),this.initGlobalShortcuts(),this.setupHashHandling(),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{this.activeLayout.setTheme(this.isDarkTheme())}),this.markSurfaceReady(),void await this.handleInitialState()}catch(t){this.activeLayout=null,this.config.uiStyle="modal",this.shadowRoot.replaceChildren()}}this.createShadowContent(),this.cacheElements(),this.updateTheme(),this.initEventListeners(),this.setupHashHandling(),this.markSurfaceReady(),await this.handleInitialState()}applyFontFamily(){i.includes(this.config.fontFamily)&&"system"!==this.config.fontFamily&&this.setAttribute("data-font",this.config.fontFamily)}syncThemeFont(){if("theme"!==this.config.fontFamily)return;const t=document.body?getComputedStyle(document.body).fontFamily:"";t?this.style.setProperty("--mp-theme-font",t):this.style.removeProperty("--mp-theme-font")}createShadowContent(){const n=document.createElement("style");n.textContent=t;const e=document.createElement("div");e.innerHTML=`\n                <dialog id="${d}-modal" class="${d}-modal ${d}-hidden" aria-modal="true" aria-label="${this.t("ariaModalLabel")}">\n                    <div class="${d}-backdrop"></div>\n                    <div class="${d}-container">\n                        <button class="${d}-close" aria-label="${this.t("ariaCloseLabel")}">\n                            <span aria-hidden="true">×</span>\n                        </button>\n                        <div class="${d}-content">\n                            <div class="${d}-header">\n                                <div id="${d}-searchbox" role="search">\n                                    <form class="${d}-form" role="search">\n                                        <input\n                                            type="search"\n                                            class="${d}-input"\n                                            placeholder="${this.t("searchPlaceholder")}"\n                                            autocomplete="off"\n                                            autocorrect="off"\n                                            autocapitalize="off"\n                                            spellcheck="false"\n                                            maxlength="512"\n                                            aria-label="${this.t("ariaSearchLabel")}"\n                                        />\n                                    </form>\n                                </div>\n                                <div class="${d}-hints">\n                                    <span>\n                                        <kbd class="${d}-kbd">↑↓</kbd>\n                                        ${this.t("navigateHint")}\n                                    </span>\n                                    <span>\n                                        <kbd class="${d}-kbd">esc</kbd>\n                                        ${this.t("closeHint")}\n                                    </span>\n                                </div>\n                            </div>\n                            <div class="${d}-results-container">\n                                ${this.getCommonSearchesHtml()}\n                                ${this.config.showAuthorProfiles?`<div id="${d}-authors" class="${d}-authors ${d}-hidden" role="group" aria-label="${this.escapeHtmlAttr(this.t("authorsGroupLabel"))}"></div>`:""}\n                                <div id="${d}-facets" class="${d}-facets ${d}-hidden" role="group" aria-label="${this.t("ariaFacetsLabel")}"></div>\n                                <div id="${d}-hits" class="${d}-hits-list" role="region" aria-label="${this.t("ariaResultsLabel")}"></div>\n                                <div id="${d}-loading" class="${d}-loading ${d}-hidden" role="status" aria-live="polite">\n                                    <div class="${d}-spinner" aria-hidden="true"></div>\n                                    <div>${this.t("loadingMessage")}</div>\n                                </div>\n                                <div id="${d}-empty" class="${d}-empty ${d}-hidden" role="status" aria-live="polite">\n                                    <div class="${d}-empty-message">\n                                        <p>${this.t("noResultsMessage")}</p>\n                                    </div>\n                                    <div id="${d}-did-you-mean" class="${d}-did-you-mean ${d}-hidden"></div>\n                                </div>\n                                <div id="${d}-error" class="${d}-error ${d}-hidden" role="alert">\n                                    <p class="${d}-error-title">${this.t("errorMessage")}</p>\n                                    <p class="${d}-error-hint">${this.t("errorHint")}</p>\n                                </div>\n                            </div>\n                        </div>\n                    </div>\n                </dialog>\n            `,this.shadowRoot.appendChild(n),this.shadowRoot.appendChild(e.firstElementChild)}cacheElements(){this.modal=this.shadowRoot.getElementById(d+"-modal"),this.searchInput=this.shadowRoot.querySelector(`.${d}-input`),this.searchForm=this.shadowRoot.querySelector(`.${d}-form`),this.hitsList=this.shadowRoot.querySelector(`#${d}-hits`),this.facetsContainer=this.shadowRoot.querySelector(`#${d}-facets`),this.commonSearches=this.shadowRoot.querySelector(`.${d}-common-searches`),this.loadingState=this.shadowRoot.querySelector(`#${d}-loading`),this.emptyState=this.shadowRoot.querySelector(`#${d}-empty`),this.errorState=this.shadowRoot.querySelector(`#${d}-error`),this.didYouMeanState=this.shadowRoot.querySelector(`#${d}-did-you-mean`),this.authorsContainer=this.shadowRoot.querySelector(`#${d}-authors`)}getCommonSearchesHtml(){return`\n                <div class="${d}-common-searches">\n                    ${this.getCommonSearchesInnerHtml()}\n                </div>\n            `}getCommonSearchesInnerHtml(){const t=this.getSuggestions();return t.length?`\n                <div class="${d}-common-searches-title" role="heading" aria-level="2">\n                    ${this.t("commonSearchesTitle")}\n                </div>\n                <div id="${d}-common-searches-container" role="list">\n                    ${t.map(t=>{const n=this.escapeHtmlAttr(t);return`\n                            <button type="button"\n                                class="${d}-common-search-btn"\n                                data-search="${n}"\n                                role="listitem">\n                                ${n}\n                            </button>\n                        `}).join("")}\n                </div>\n            `:`\n                    <div class="${d}-empty-message">${this.t("emptyStateMessage")}</div>\n                `}updateTheme(){const t=window.matchMedia("(prefers-color-scheme: dark)").matches,n="light"!==this.config.theme&&("dark"===this.config.theme||t);this.modal.classList.toggle(d+"-dark",n)}initGlobalShortcuts(){document.addEventListener("keydown",t=>{this.isModalOpen?"Escape"===t.key&&(t.preventDefault(),this.closeModal()):((t.metaKey||t.ctrlKey)&&"k"===t.key&&(t.preventDefault(),this.openModal()),"/"!==t.key||t.ctrlKey||t.metaKey||"INPUT"===t.target.tagName||"TEXTAREA"===t.target.tagName||(t.preventDefault(),this.openModal()))}),document.querySelectorAll("[data-ghost-search]").forEach(t=>{t.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.openModal()})})}initEventListeners(){this.shadowRoot.querySelector(`.${d}-close`).addEventListener("click",()=>this.closeModal()),this.modal.addEventListener("click",t=>{(t.target===this.modal||t.target.classList.contains(d+"-backdrop"))&&this.closeModal()}),this.modal.addEventListener("close",()=>this.closeModal()),this.shadowRoot.querySelector(`.${d}-container`).addEventListener("click",t=>t.stopPropagation()),this.searchForm.addEventListener("submit",t=>{t.preventDefault()}),this.searchInput.addEventListener("input",t=>{const n=t.target.value;this.searchDebounceTimeout&&clearTimeout(this.searchDebounceTimeout),this.searchDebounceTimeout=setTimeout(()=>{this.handleSearch(n)},80)}),this.hitsList&&this.hitsList.addEventListener("click",t=>{const n=t.target.closest(`.${d}-result-link`);if(!n)return;const e=+n.dataset.resultPosition;this.trackClick(n.dataset.resultId,Number.isNaN(e)?null:e)},!0),this.didYouMeanState&&this.didYouMeanState.addEventListener("click",t=>{const n=t.target.closest(`.${d}-did-you-mean-btn`);n&&(t.preventDefault(),this.applySearchTerm(n.dataset.search))}),this.attachCommonSearchListeners(),this.attachFacetListeners(),document.addEventListener("keydown",t=>{(t.metaKey||t.ctrlKey)&&"k"===t.key&&(t.preventDefault(),this.openModal()),"/"!==t.key||t.ctrlKey||t.metaKey||"INPUT"===t.target.tagName||"TEXTAREA"===t.target.tagName||(t.preventDefault(),this.openModal()),"Escape"===t.key&&this.isModalOpen&&(t.preventDefault(),this.closeModal())}),this.modal.addEventListener("keydown",t=>this.handleKeydown(t)),document.querySelectorAll("[data-ghost-search]").forEach(t=>{t.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.openModal()})}),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{this.updateTheme()})}attachCommonSearchListeners(){const t=this.shadowRoot.querySelector(`#${d}-common-searches-container`);if(!t)return;const n=t=>{const n=t.target.closest(`.${d}-common-search-btn`);n&&(t.preventDefault(),this.applySearchTerm(n.dataset.search))};t.addEventListener("click",n),t.addEventListener("touchend",n)}applySearchTerm(t){t&&this.searchInput&&(this.selectedIndex=-1,this.searchInput.value=t,this.searchInput.dispatchEvent(new Event("input",{bubbles:!0})),setTimeout(()=>{this.searchInput.focus(),this.searchInput.setSelectionRange(t.length,t.length)},0))}lockBodyScroll(){if(this.bodyScrollLocked)return;this.bodyScrollLocked=!0,this.scrollPosition=window.pageYOffset||document.documentElement.scrollTop;const t=document.documentElement;this.savedScrollbarGutter=null,window.innerWidth-t.clientWidth>0&&!/stable/.test(getComputedStyle(t).scrollbarGutter||"")&&(this.savedScrollbarGutter={value:t.style.getPropertyValue("scrollbar-gutter"),priority:t.style.getPropertyPriority("scrollbar-gutter")},t.style.setProperty("scrollbar-gutter","stable")),document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${this.scrollPosition}px`,document.body.style.width="100%"}unlockBodyScroll(){if(!this.bodyScrollLocked)return;this.bodyScrollLocked=!1,document.body.style.removeProperty("overflow"),document.body.style.removeProperty("position"),document.body.style.removeProperty("top"),document.body.style.removeProperty("width");const t=this.savedScrollbarGutter;if(t){const n=document.documentElement;t.value?n.style.setProperty("scrollbar-gutter",t.value,t.priority):n.style.removeProperty("scrollbar-gutter"),this.savedScrollbarGutter=null}window.scrollTo(0,this.scrollPosition)}async openModal(){if(this.isModalOpen)return;if(await this.surfaceReady,this.isModalOpen)return;this.syncThemeFont(),this.activeElement=document.activeElement,this.isModalOpen=!0,this.lockBodyScroll(),this.activeLayout?(this.activeLayout.onOpen(),this.activeLayout.focusInput()):this.modal&&(this.modal.classList.remove(d+"-hidden"),c(this.modal),setTimeout(()=>{this.searchInput&&this.searchInput.focus()},50)),this.config.suggestionsUrl&&!this.suggestionsFetched&&this.fetchSuggestions().then(()=>{this.activeLayout?this.activeLayout.renderSuggestions():this.renderSuggestions()}),this.loadAuthorProfiles(),"#/search"!==window.location.hash&&history.replaceState(null,null,`${window.location.pathname}${window.location.search}#/search`);const t=new URLSearchParams(window.location.search),n=t.get("s")||t.get("q");this.applyUrlQuery(n)}closeModal(){this.isModalOpen&&(this.isModalOpen=!1,this.unlockBodyScroll(),this.selectedIndex=-1,this.activeLayout?this.activeLayout.onClose():(u(this.modal),this.modal.classList.add(d+"-hidden"),this.searchInput&&(this.searchInput.value="")),this.lastQuery="",this.lastTrackedQuery=null,this.selectedFacets={},this.expandedFacets={},this.handleSearch(""),this.activeElement&&"function"==typeof this.activeElement.focus&&this.activeElement.focus(),"#/search"===window.location.hash&&history.replaceState(null,null,`${window.location.pathname}${window.location.search}`))}typesenseClientOptions(){const{connectionTimeoutSeconds:t,numRetries:n,retryIntervalSeconds:e}=this.config,r={nodes:this.config.typesenseNodes,apiKey:this.config.typesenseApiKey,connectionTimeoutSeconds:Number.isFinite(t)&&t>0?t:5};return Number.isInteger(n)&&n>=0&&(r.numRetries=n),Number.isFinite(e)&&e>=0&&(r.retryIntervalSeconds=e),r}getTypesenseClient(){return this.typesenseClient||(this.typesenseClient=new Xe.Client(this.typesenseClientOptions())),this.typesenseClient}logConfigIssueOnce(t,n){this.reportedConfigIssues||(this.reportedConfigIssues=new Set),this.reportedConfigIssues.has(t)||(this.reportedConfigIssues.add(t),console.error(n))}logSearchError(t){console.error("MagicPagesSearch: search request failed",t)}async handleSearch(t){t=t?.trim();const n=++this.searchSequence;if(!t)return this.selectedIndex=-1,this.activeLayout?void this.activeLayout.renderInitial():(this.hitsList&&this.hitsList.classList.add(d+"-hidden"),this.commonSearches&&this.commonSearches.classList.remove(d+"-hidden"),this.emptyState&&this.emptyState.classList.add(d+"-hidden"),this.errorState&&this.errorState.classList.add(d+"-hidden"),this.loadingState&&this.loadingState.classList.add(d+"-hidden"),this.facetsContainer&&this.facetsContainer.classList.add(d+"-hidden"),void this.renderAuthorProfiles(""));if(this.activeLayout){this.activeLayout.renderLoading();const e=this.getSearchParameters();try{const r=await this.getTypesenseClient().collections(this.config.collectionName).documents().search({q:t,...e});if(n!==this.searchSequence)return;const i="number"==typeof r.found?r.found:r.hits.length;if(this.lastQuery=t,this.trackSearch(t,i),this.config.facets?.length&&this.activeLayout.renderFacets(r.facet_counts,this.selectedFacets),!r.hits.length){this.activeLayout.renderEmpty(t);const r=await this.fetchDidYouMean(t,e);return void(r&&n===this.searchSequence&&"function"==typeof this.activeLayout.renderDidYouMean&&this.activeLayout.renderDidYouMean(r))}const o=r.hits.map((t,n)=>this.normalizeHit(t,n));this.activeLayout.renderResults(o,{query:t,found:i,facetCounts:r.facet_counts})}catch(e){if(this.logSearchError(e),n!==this.searchSequence)return;"function"==typeof this.activeLayout.renderError?this.activeLayout.renderError(t):this.activeLayout.renderEmpty(t)}return}this.commonSearches&&this.commonSearches.classList.add(d+"-hidden"),this.hitsList&&this.hitsList.classList.remove(d+"-hidden"),this.loadingState&&this.loadingState.classList.remove(d+"-hidden"),this.emptyState&&this.emptyState.classList.add(d+"-hidden"),this.errorState&&this.errorState.classList.add(d+"-hidden"),this.renderAuthorProfiles(t);try{const e=this.getSearchParameters(),r={q:t,...e},i=await this.getTypesenseClient().collections(this.config.collectionName).documents().search(r);if(n!==this.searchSequence)return;this.loadingState&&this.loadingState.classList.add(d+"-hidden");const o="number"==typeof i.found?i.found:i.hits.length;if(this.lastQuery=t,this.trackSearch(t,o),this.config.facets?.length&&this.renderFacets(i.facet_counts),0===i.hits.length){this.renderDidYouMean(null),this.emptyState&&this.emptyState.classList.remove(d+"-hidden"),this.hitsList&&(this.hitsList.innerHTML="",this.hitsList.classList.add(d+"-hidden"));const r=await this.fetchDidYouMean(t,e);return void(r&&n===this.searchSequence&&this.renderDidYouMean(r))}this.emptyState&&this.emptyState.classList.add(d+"-hidden"),this.hitsList.innerHTML="";const s=i.hits.map((t,n)=>{const e=((n,e)=>this.config.enableHighlighting&&t.highlight&&t.highlight[n]&&(t.highlight[n].snippet||t.highlight[n].value)||e)("title",t.document.title)||this.t("untitledPost");let r=this.matchedSnippet(t,"excerpt")||this.matchedSnippet(t,"plaintext")||this.escapeHtmlAttr(t.document.excerpt||t.document.plaintext?.substring(0,80)||"");r&&r.length>200&&(r=r.substring(0,200)+"...");const i=this.config.transformToRelativeUrls?this.toRelativeUrl(t.document.url):t.document.url||"#",o=!!t.document.visibility&&"public"!==t.document.visibility,s=this.needsBadge(t.document.visibility)?this.accessLevel(t.document.visibility):null;return`\n                        <a href="${i}"\n                            class="${d}-result-link${o?` ${d}-result-gated`:""}"\n                            data-result-id="${this.escapeHtmlAttr(t.document.id)}"\n                            data-result-position="${n}"\n                            ${o?`data-gated="${this.escapeHtmlAttr(t.document.visibility)}"`:""}\n                            aria-label="${e.replace(/<[^>]*>/g,"")}">\n                            ${"grid"===this.config.template?this.renderGridCard(t,e,r,s):this.renderListItem(t,e,r,s)}\n                        </a>\n                    `}).join("");this.hitsList.innerHTML=s,this.hitsList.classList.toggle(d+"-grid","grid"===this.config.template),this.hitsList.classList.remove(d+"-hidden")}catch(t){if(this.logSearchError(t),n!==this.searchSequence)return;this.loadingState&&this.loadingState.classList.add(d+"-hidden"),this.errorState&&this.errorState.classList.remove(d+"-hidden"),this.hitsList&&(this.hitsList.innerHTML="",this.hitsList.classList.add(d+"-hidden")),this.facetsContainer&&this.facetsContainer.classList.add(d+"-hidden")}}async fetchDidYouMean(t,n){if(!1===this.config.enableDidYouMean)return null;if(null==(e=n.num_typos)||""===e||(e+"").split(",").some(t=>+t.trim()>0))return null;var e;let r;try{r=await this.getTypesenseClient().collections(this.config.collectionName).documents().search({...n,q:t,num_typos:2})}catch(t){return this.logSearchError(t),null}const i=Array.isArray(r?.hits)?r.hits:[];return i.length?this.didYouMeanFromHits(t,i):null}didYouMeanFromHits(t,n){const e=[],r=new Set;for(const t of n.slice(0,3)){for(const n of m(t)){const t=n.toLowerCase();if(!r.has(t)&&(r.add(t),e.push(n),e.length>=24))break}if(e.length>=24)break}if(0===e.length)return null;let i=!1;const o=t.split(/\s+/).filter(Boolean).map(t=>{if(r.has(t.toLowerCase()))return t;const n=function(t){return t.length>=7?2:t.length>=4?1:0}(t);if(0===n)return t;let o=null,s=n+1;for(const r of e){const e=p(t.toLowerCase(),r.toLowerCase(),n);if(e<s&&(o=r,s=e,1===e))break}return o?(i=!0,o):t});return i?o.join(" "):null}renderDidYouMean(t){if(!this.didYouMeanState)return;if(!t)return this.didYouMeanState.innerHTML="",void this.didYouMeanState.classList.add(d+"-hidden");const n=this.escapeHtmlAttr(t),e=this.t("didYouMeanLabel").split("{q}").map(t=>this.escapeHtmlAttr(t)).join(`<strong class="${d}-did-you-mean-term">${n}</strong>`);this.didYouMeanState.innerHTML=`<button type="button" class="${d}-did-you-mean-btn" data-search="${n}">${e}</button>`,this.didYouMeanState.classList.remove(d+"-hidden")}addQueryField(t,n,e=1){if(!n)return!1;const r=((t.query_by||"")+"").split(",").map(t=>t.trim()).filter(Boolean);if(r.includes(n))return!1;if(r.push(n),t.query_by=r.join(","),t.query_by_weights){const n=(t.query_by_weights+"").split(",").map(t=>t.trim()).filter(Boolean);n.push(e+""),t.query_by_weights=n.join(",")}return!0}getSearchParameters(){const t=Object.keys(this.config.searchFields||{}).length>0?this.config.searchFields:{title:{weight:5,highlight:!0},excerpt:{weight:3,highlight:!0},plaintext:{weight:4,highlight:!0},"tags.name":{weight:4,highlight:!0},"tags.slug":{weight:3,highlight:!0}},n=[],e=[],r=[];Object.entries(t).forEach(([t,i])=>{n.push(t),e.push(i.weight||1),i.highlight&&r.push(t)});const i={query_by:n.join(","),query_by_weights:e.join(","),highlight_full_fields:r.join(","),highlight_affix_num_tokens:30,include_fields:"id,title,url,excerpt,plaintext,published_at,tags,authors,feature_image,visibility",num_typos:0,prefix:!0,per_page:20,drop_tokens_threshold:0,enable_nested_fields:!0,prioritize_exact_match:!0,sort_by:"_text_match:desc,published_at:desc"},o=this.config.typesenseSearchParams||{};o.query_by&&!o.query_by_weights&&delete i.query_by_weights;const s={...i,...o};if(Object.prototype.hasOwnProperty.call(o,"typo_tolerance")&&(delete s.typo_tolerance,o.typo_tolerance&&void 0===o.num_typos&&(s.num_typos=2),this.logConfigIssueOnce("typo_tolerance","MagicPagesSearch: `typo_tolerance` is not a Typesense search parameter and does nothing on its own. Reading it as `num_typos: 2` for now; set `num_typos` directly instead (0 matches strictly, 1–2 tolerate typos).")),this.config.searchAuthors&&this.addQueryField(s,"authors"),this.isAnalyticsEnabled()){const t=((s.include_fields||"")+"").split(",").map(t=>t.trim()).filter(Boolean);t.includes("id")||(t.unshift("id"),s.include_fields=t.join(","))}{const t=((s.include_fields||"")+"").split(",").map(t=>t.trim()).filter(Boolean);t.length&&!t.includes("visibility")&&(t.push("visibility"),s.include_fields=t.join(","))}if("grid"===this.config.template){const t=((s.include_fields||"")+"").split(",").map(t=>t.trim()).filter(Boolean);t.includes("feature_image")||(t.push("feature_image"),s.include_fields=t.join(","))}if(this.activeLayout&&"function"==typeof this.activeLayout.requiredFields){const t=this.activeLayout.requiredFields()||[];if(t.length){const n=((s.include_fields||"")+"").split(",").map(t=>t.trim()).filter(Boolean);let e=!1;for(const r of t)r&&!n.includes(r)&&(n.push(r),e=!0);e&&(s.include_fields=n.join(","))}}if(this.config.semanticSearch){const t=this.config.embeddingFieldName||"embedding";if(this.addQueryField(s,t)&&!s.vector_query){const n="number"==typeof this.config.semanticAlpha?this.config.semanticAlpha:.2,e="number"==typeof this.config.semanticDistanceThreshold?this.config.semanticDistanceThreshold:.8;s.vector_query=`${t}:([], alpha: ${n}, distance_threshold: ${e})`}}if(this.config.facets?.length){s.facet_by=this.config.facets.map(t=>t.field).join(",");const t=this.config.facets.map(t=>this.facetCap(t)),n=Math.max(...t);Number.isFinite(n)&&(s.max_facet_values=n+1);const e=this.composeFilterBy(s.filter_by);e?s.filter_by=e:delete s.filter_by}return s}facetLimit(t){const n=t&&t.limit;return Number.isFinite(n)&&n>0?Math.floor(n):10}facetCap(t){const n=this.facetLimit(t),e=t?this.expandedFacets[t.field]:void 0;return Number.isFinite(e)&&e>n?e:n}expandFacet(t){const n=(this.config.facets||[]).find(n=>n.field===t);n&&(this.expandedFacets[t]=this.facetCap(n)+40)}collapseFacet(t){delete this.expandedFacets[t]}facetRows(t,n){const e=this.facetCap(t),r=this.selectedFacets[t.field],i=n.slice(0,e);if(r&&r.size){const t=new Set(i.map(t=>t.value));for(const o of n.slice(e))r.has(o.value)&&!t.has(o.value)&&(i.push(o),t.add(o.value));for(const n of r)t.has(n)||(i.push({value:n,count:0}),t.add(n))}return{rows:i,truncated:n.length>e,expanded:e>this.facetLimit(t)}}buildFacetFilter(){const t=[];for(const n of this.config.facets||[]){const e=this.selectedFacets[n.field];if(!e||0===e.size)continue;const r=[...e].map(t=>`\`${(t+"").replace(/`/g,"")}\``).join(",");t.push(`${n.field}:=[${r}]`)}return t.join(" && ")}composeFilterBy(t){const n=this.buildFacetFilter(),e=(t||"").trim();return e&&n?`(${e}) && (${n})`:e||n}renderFacets(t){if(!this.facetsContainer)return;const n=Object.values(this.selectedFacets).some(t=>t&&t.size>0),e=Array.isArray(t)&&t.length>0;if(!this.config.facets?.length||!e&&!n)return this.facetsContainer.innerHTML="",void this.facetsContainer.classList.add(d+"-hidden");const r={};for(const n of e?t:[])r[n.field_name]=n.counts||[];const i=this.config.facets.map((t,n)=>{const e=r[t.field]||[],i=this.selectedFacets[t.field];if(!(0!==e.length||i&&i.size))return"";const{rows:o,truncated:s,expanded:a}=this.facetRows(t,e),c=o.map(({value:n,count:e})=>{const r=!!i&&i.has(n),o=this.escapeHtmlAttr(n);return`\n                        <button type="button"\n                            class="${d}-facet-chip${r?` ${d}-facet-chip-selected`:""}"\n                            data-facet-field="${this.escapeHtmlAttr(t.field)}"\n                            data-facet-value="${o}"\n                            aria-pressed="${r?"true":"false"}">\n                            <span class="${d}-facet-chip-label">${o}</span>\n                            <span class="${d}-facet-chip-count">${e}</span>\n                        </button>\n                    `}).join(""),u=`${d}-facet-chips-${n}`,h=s||a?`<button type="button"\n                            class="${d}-facet-more"\n                            data-facet-field="${this.escapeHtmlAttr(t.field)}"\n                            data-facet-expand="${s?"more":"less"}"\n                            aria-controls="${u}"\n                            aria-expanded="${a?"true":"false"}">${s?this.t("facetShowMoreLabel"):this.t("facetShowLessLabel")}</button>`:"";return`\n                    <div class="${d}-facet-group">\n                        <div class="${d}-facet-group-label">${this.escapeHtmlAttr(t.label||t.field)}</div>\n                        <div id="${u}" class="${d}-facet-chips" role="list">${c}</div>\n                        ${h}\n                    </div>\n                `}).join(""),o=n?`<button type="button" class="${d}-facet-clear">${this.t("clearFiltersLabel")}</button>`:"";this.facetsContainer.innerHTML=i+o,this.facetsContainer.classList.toggle(d+"-hidden",""===i.trim())}attachFacetListeners(){this.facetsContainer&&this.facetsContainer.addEventListener("click",t=>{if(t.target.closest(`.${d}-facet-clear`))return t.preventDefault(),this.selectedFacets={},void this.rerunQuery();const n=t.target.closest(`.${d}-facet-more`);if(n){t.preventDefault();const e=n.dataset.facetField;if(!e)return;return"less"===n.dataset.facetExpand?this.collapseFacet(e):this.expandFacet(e),void this.rerunQuery()}const e=t.target.closest(`.${d}-facet-chip`);if(!e)return;t.preventDefault();const r=e.dataset.facetField,i=e.dataset.facetValue;if(!r||void 0===i)return;this.selectedFacets[r]||(this.selectedFacets[r]=new Set);const o=this.selectedFacets[r];o.has(i)?o.delete(i):o.add(i),this.rerunQuery()})}rerunQuery(){const t=this.searchInput?.value?.trim()||this.lastQuery;t&&this.handleSearch(t)}accessLevel(t){const n=t||"public";return"public"===n?"public":"paid"===n||"tiers"===n?"paid":"members"}needsBadge(t){const n=this.accessLevel(t);return"public"!==n&&!(("free"===this.readerAccess||"paid"===this.readerAccess)&&"members"===n||"paid"===this.readerAccess&&"paid"===t)}resolveReaderAccess(){return this.config.memberAwareBadges?(this.readerAccessPromise||(this.readerAccessPromise=fetch(this.config.memberEndpoint||v,{credentials:"same-origin",cache:"no-store",headers:{Accept:"application/json"}}).then(async t=>{if(204===t.status)return"anonymous";if(!t.ok)return"unknown";const n=await t.json();return n&&n.paid?"paid":"free"}).catch(()=>"unknown").then(t=>(this.readerAccess=t,"free"!==t&&"paid"!==t||this.rerunQuery(),t))),this.readerAccessPromise):Promise.resolve("unknown")}gatedBadge(t){if(!t||"public"===t)return"";const n="paid"===t,e=this.escapeHtmlAttr(this.t(n?"paidLabel":"membersLabel")),r=this.escapeHtmlAttr(this.t(n?"ariaPaidLabel":"ariaMembersLabel"));return`<span class="${d}-gated-badge ${d}-gated-badge-${t}" aria-label="${r}">\n                        <span aria-hidden="true">🔒</span> ${e}\n                    </span>`}relativeDate(t){if(null==t)return"";const n=Date.now()-+t;if(Number.isNaN(n))return"";const e=Math.round(n/864e5);if(e>365)return this.t("relativeYears").replace("{n}",Math.round(e/365));if(e>30)return this.t("relativeMonths").replace("{n}",Math.round(e/30));if(e>=1)return this.t("relativeDays").replace("{n}",e);const r=Math.round(n/36e5);if(r>=1)return this.t("relativeHours").replace("{n}",r);const i=Math.round(n/6e4);return i>=1?this.t("relativeMinutes").replace("{n}",i):this.t("relativeNow")}renderListItem(t,n,e){if("string"==typeof t){const r=n||"";return`\n                    <article class="${d}-result-item" role="article">\n                        <h3 class="${d}-result-title" role="heading" aria-level="3">${t}${this.gatedBadge(e)}</h3>\n                        <p class="${d}-result-excerpt" aria-label="${this.t("ariaArticleExcerpt")}">${r}</p>\n                    </article>\n                `}const r=n,i=e,o=arguments[3],s=t.document||{},a=s.feature_image,c=this.escapeHtmlAttr((s.title||"?").trim().charAt(0).toUpperCase()||"?"),u=a?`<img class="${d}-row-thumb" src="${this.escapeHtmlAttr(a)}" alt="" loading="lazy" />`:`<span class="${d}-row-thumb ${d}-row-thumb-empty" aria-hidden="true">${c}</span>`,h=[],l=!1===this.config.showDates?"":this.relativeDate(s.published_at);l&&h.push(`<span>${this.escapeHtmlAttr(l)}</span>`);const f=Array.isArray(s.tags)&&s.tags.length?s.tags[0]:"";f&&h.push(`<span class="${d}-row-meta-tag">${this.escapeHtmlAttr(f)}</span>`);const p=Array.isArray(s.authors)&&s.authors.length?s.authors[0]:"";p&&h.push(`<span>${this.escapeHtmlAttr(p)}</span>`);const m=h.length?`<div class="${d}-row-meta">${h.join(`<span class="${d}-row-meta-sep" aria-hidden="true">·</span>`)}</div>`:"";return`\n                <article class="${d}-result-item ${d}-row" role="article">\n                    ${u}\n                    <div class="${d}-row-body">\n                        <h3 class="${d}-result-title" role="heading" aria-level="3">${r}${this.gatedBadge(o)}</h3>\n                        <p class="${d}-result-excerpt" aria-label="${this.t("ariaArticleExcerpt")}">${i}</p>\n                        ${m}\n                    </div>\n                </article>\n            `}renderGridCard(t,n,e,r){const i=t.document.feature_image,o=i?`<img class="${d}-card-image" src="${this.escapeHtmlAttr(i)}" alt="" loading="lazy" />`:`<div class="${d}-card-image ${d}-card-image-empty" aria-hidden="true"></div>`,s=Array.isArray(t.document.tags)?t.document.tags.slice(0,3):[],a=s.length?`<div class="${d}-card-tags">${s.map(t=>`<span class="${d}-card-tag">${this.escapeHtmlAttr(t)}</span>`).join("")}</div>`:"";return`\n                <article class="${d}-result-item ${d}-card" role="article">\n                    ${o}\n                    <div class="${d}-card-body">\n                        <h3 class="${d}-result-title" role="heading" aria-level="3">${n}${this.gatedBadge(r)}</h3>\n                        <p class="${d}-result-excerpt" aria-label="${this.t("ariaArticleExcerpt")}">${e}</p>\n                        ${a}\n                    </div>\n                </article>\n            `}handleKeydown(t){if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void this.closeModal();if(t.target===this.searchInput)switch(t.stopPropagation(),t.key){case"ArrowDown":t.preventDefault(),this.navigateResults("next");break;case"ArrowUp":t.preventDefault(),this.navigateResults("prev");break;case"Enter":-1!==this.selectedIndex&&(t.preventDefault(),this.handleEnterKey())}}navigableResults(){return[...this.shadowRoot.querySelectorAll(`.${d}-author-link, .${d}-result-link, .${d}-common-search-btn:not(.${d}-hidden)`)].filter(t=>null!==t.offsetParent&&!t.closest(`.${d}-hidden`))}navigateResults(t){const n=this.navigableResults();if(0===n.length)return;-1===this.selectedIndex?this.selectedIndex="next"===t?0:n.length-1:this.selectedIndex="next"===t?(this.selectedIndex+1)%n.length:(this.selectedIndex-1+n.length)%n.length,n.forEach(t=>t.classList.remove(d+"-selected"));const e=n[this.selectedIndex];e.classList.add(d+"-selected"),e.scrollIntoView({block:"nearest",behavior:"auto"})}handleEnterKey(){const t=this.navigableResults();if(this.selectedIndex>=0&&this.selectedIndex<t.length){const n=t[this.selectedIndex];if(n.classList.contains(d+"-author-link"))window.location.href=n.href;else if(n.classList.contains(d+"-result-link")){const t=+n.dataset.resultPosition;this.trackClick(n.dataset.resultId,Number.isNaN(t)?null:t),window.location.href=n.href}else this.searchInput.value=n.textContent.trim(),this.searchInput.dispatchEvent(new Event("input",{bubbles:!0}))}}setupHashHandling(){window.addEventListener("hashchange",()=>this.syncWithHash())}async syncWithHash(){const t=window.location.hash.startsWith("#/search");t!==this.isModalOpen&&(t?await this.openModal():this.closeModal())}applyUrlQuery(t){if(t){if(this.activeLayout)this.activeLayout.setQuery(t);else{if(!this.searchInput)return;this.searchInput.value=t}this.handleSearch(t)}}async handleInitialState(){const t=new URLSearchParams(window.location.search),n=t.get("s")||t.get("q"),e=window.location.hash.split("/");let r=null;e.length>2&&"search"===e[1]&&(r=decodeURIComponent(e[2]).replace(/\+/g," ")),r?(await this.openModal(),this.applyUrlQuery(r)):(n||"#/search"===window.location.hash)&&await this.openModal()}}function _(){const t=new URLSearchParams(window.location.search),r=t.has("s")||t.has("q");if(!window.magicPagesSearch&&(window.__MP_SEARCH_CONFIG__||"#/search"===window.location.hash||r||document.querySelectorAll("[data-ghost-search]").length>0)){const t=document.createElement("magicpages-search");document.body.appendChild(t),window.magicPagesSearch=t,function(){e=new MutationObserver(t=>{if(n)for(const n of t)for(const t of n.addedNodes)1===t.nodeType&&("SCRIPT"===t.tagName&&t.hasAttribute("data-sodo-search")?(l(t),t.remove()):"sodo-search-root"===t.id&&t.remove())}),e.observe(document.documentElement,{childList:!0,subtree:!0});const t=setInterval(f,100);setTimeout(()=>{clearInterval(t),e&&(e.disconnect(),e=null)},5e3)}()}}customElements.get("magicpages-search")||customElements.define("magicpages-search",w),window.MagicPagesSearch=w,new Promise(t=>{if(document.body)t();else{const n=new MutationObserver(()=>{document.body&&(n.disconnect(),t())});n.observe(document.documentElement,{childList:!0})}}).then(_),"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",_)}()}();
