import { c as create_ssr_component, v as validate_component, s as setContext, a as subscribe, b as createEventDispatcher, e as escape, d as add_attribute, f as spread, g as escape_object, m as missing_component, h as each, i as split_css_unit } from './ssr-6MZFlfLu.js'; import { computePosition, autoUpdate, offset, shift, flip, arrow } from '@floating-ui/dom'; import { w as writable } from './index2-f61NAEsz.js'; import { i as initializeModalStore, g as getModalStore } from './stores-0qksNY90.js'; import { i as initializeToastStore, g as getToastStore, M as ModalPromptEditor } from './ModalPromptEditor-isPsJANV.js'; import { p as prefersReducedMotionStore } from './ProgressBar.svelte_svelte_type_style_lang-H22V2Yrx.js'; const Header = create_ssr_component(($$result, $$props, $$bindings, slots) => { return ``; }); const storePopup = writable(void 0); const DRAWER_STORE_KEY = "drawerStore"; function initializeDrawerStore() { const drawerStore = drawerService(); return setContext(DRAWER_STORE_KEY, drawerStore); } function drawerService() { const { subscribe: subscribe2, set, update } = writable({}); return { subscribe: subscribe2, set, update, /** Open the drawer. */ open: (newSettings) => update(() => { return { open: true, ...newSettings }; }), /** Close the drawer. */ close: () => update((d) => { d.open = false; return d; }) }; } function initializeStores() { initializeModalStore(); initializeToastStore(); initializeDrawerStore(); } function cubicOut(t) { const f = t - 1; return f * f * f + 1; } function fly(node, { delay = 0, duration = 400, easing = cubicOut, x = 0, y = 0, opacity = 0 } = {}) { const style = getComputedStyle(node); const target_opacity = +style.opacity; const transform = style.transform === "none" ? "" : style.transform; const od = target_opacity * (1 - opacity); const [xValue, xUnit] = split_css_unit(x); const [yValue, yUnit] = split_css_unit(y); return { delay, duration, easing, css: (t, u) => ` transform: ${transform} translate(${(1 - t) * xValue}${xUnit}, ${(1 - t) * yValue}${yUnit}); opacity: ${target_opacity - od * u}` }; } const cBackdrop = "fixed top-0 left-0 right-0 bottom-0 bg-surface-backdrop-token p-4"; const cTransitionLayer = "w-full h-fit min-h-full overflow-y-auto flex justify-center"; const cModal = "block overflow-y-auto"; const cModalImage = "w-full h-auto"; const Modal = create_ssr_component(($$result, $$props, $$bindings, slots) => { let cPosition; let classesBackdrop; let classesTransitionLayer; let classesModal; let parent; let $modalStore, $$unsubscribe_modalStore; let $prefersReducedMotionStore, $$unsubscribe_prefersReducedMotionStore; $$unsubscribe_prefersReducedMotionStore = subscribe(prefersReducedMotionStore, (value) => $prefersReducedMotionStore = value); createEventDispatcher(); let { components = {} } = $$props; let { position = "items-center" } = $$props; let { background = "bg-surface-100-800-token" } = $$props; let { width = "w-modal" } = $$props; let { height = "h-auto" } = $$props; let { padding = "p-4" } = $$props; let { spacing = "space-y-4" } = $$props; let { rounded = "rounded-container-token" } = $$props; let { shadow = "shadow-xl" } = $$props; let { zIndex = "z-[999]" } = $$props; let { buttonNeutral = "variant-ghost-surface" } = $$props; let { buttonPositive = "variant-filled" } = $$props; let { buttonTextCancel = "Cancel" } = $$props; let { buttonTextConfirm = "Confirm" } = $$props; let { buttonTextSubmit = "Submit" } = $$props; let { regionBackdrop = "" } = $$props; let { regionHeader = "text-2xl font-bold" } = $$props; let { regionBody = "max-h-[200px] overflow-hidden" } = $$props; let { regionFooter = "flex justify-end space-x-2" } = $$props; let { transitions = !$prefersReducedMotionStore } = $$props; let { transitionIn = fly } = $$props; let { transitionInParams = { duration: 150, opacity: 0, x: 0, y: 100 } } = $$props; let { transitionOut = fly } = $$props; let { transitionOutParams = { duration: 150, opacity: 0, x: 0, y: 100 } } = $$props; let promptValue; const buttonTextDefaults = { buttonTextCancel, buttonTextConfirm, buttonTextSubmit }; let currentComponent; let modalElement; let windowHeight; let backdropOverflow = "overflow-y-hidden"; const modalStore = getModalStore(); $$unsubscribe_modalStore = subscribe(modalStore, (value) => $modalStore = value); function handleModals(modals) { if (modals[0].type === "prompt") promptValue = modals[0].value; buttonTextCancel = modals[0].buttonTextCancel || buttonTextDefaults.buttonTextCancel; buttonTextConfirm = modals[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm; buttonTextSubmit = modals[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit; currentComponent = typeof modals[0].component === "string" ? components[modals[0].component] : modals[0].component; } function onModalHeightChange(modal) { let modalHeight = modal?.clientHeight; if (!modalHeight) modalHeight = modal?.firstChild?.clientHeight; if (!modalHeight) return; if (modalHeight > windowHeight) { backdropOverflow = "overflow-y-auto"; } else { backdropOverflow = "overflow-y-hidden"; } } function onClose() { if ($modalStore[0].response) $modalStore[0].response(false); modalStore.close(); } if ($$props.components === void 0 && $$bindings.components && components !== void 0) $$bindings.components(components); if ($$props.position === void 0 && $$bindings.position && position !== void 0) $$bindings.position(position); if ($$props.background === void 0 && $$bindings.background && background !== void 0) $$bindings.background(background); if ($$props.width === void 0 && $$bindings.width && width !== void 0) $$bindings.width(width); if ($$props.height === void 0 && $$bindings.height && height !== void 0) $$bindings.height(height); if ($$props.padding === void 0 && $$bindings.padding && padding !== void 0) $$bindings.padding(padding); if ($$props.spacing === void 0 && $$bindings.spacing && spacing !== void 0) $$bindings.spacing(spacing); if ($$props.rounded === void 0 && $$bindings.rounded && rounded !== void 0) $$bindings.rounded(rounded); if ($$props.shadow === void 0 && $$bindings.shadow && shadow !== void 0) $$bindings.shadow(shadow); if ($$props.zIndex === void 0 && $$bindings.zIndex && zIndex !== void 0) $$bindings.zIndex(zIndex); if ($$props.buttonNeutral === void 0 && $$bindings.buttonNeutral && buttonNeutral !== void 0) $$bindings.buttonNeutral(buttonNeutral); if ($$props.buttonPositive === void 0 && $$bindings.buttonPositive && buttonPositive !== void 0) $$bindings.buttonPositive(buttonPositive); if ($$props.buttonTextCancel === void 0 && $$bindings.buttonTextCancel && buttonTextCancel !== void 0) $$bindings.buttonTextCancel(buttonTextCancel); if ($$props.buttonTextConfirm === void 0 && $$bindings.buttonTextConfirm && buttonTextConfirm !== void 0) $$bindings.buttonTextConfirm(buttonTextConfirm); if ($$props.buttonTextSubmit === void 0 && $$bindings.buttonTextSubmit && buttonTextSubmit !== void 0) $$bindings.buttonTextSubmit(buttonTextSubmit); if ($$props.regionBackdrop === void 0 && $$bindings.regionBackdrop && regionBackdrop !== void 0) $$bindings.regionBackdrop(regionBackdrop); if ($$props.regionHeader === void 0 && $$bindings.regionHeader && regionHeader !== void 0) $$bindings.regionHeader(regionHeader); if ($$props.regionBody === void 0 && $$bindings.regionBody && regionBody !== void 0) $$bindings.regionBody(regionBody); if ($$props.regionFooter === void 0 && $$bindings.regionFooter && regionFooter !== void 0) $$bindings.regionFooter(regionFooter); if ($$props.transitions === void 0 && $$bindings.transitions && transitions !== void 0) $$bindings.transitions(transitions); if ($$props.transitionIn === void 0 && $$bindings.transitionIn && transitionIn !== void 0) $$bindings.transitionIn(transitionIn); if ($$props.transitionInParams === void 0 && $$bindings.transitionInParams && transitionInParams !== void 0) $$bindings.transitionInParams(transitionInParams); if ($$props.transitionOut === void 0 && $$bindings.transitionOut && transitionOut !== void 0) $$bindings.transitionOut(transitionOut); if ($$props.transitionOutParams === void 0 && $$bindings.transitionOutParams && transitionOutParams !== void 0) $$bindings.transitionOutParams(transitionOutParams); { if ($modalStore.length) handleModals($modalStore); } { onModalHeightChange(modalElement); } cPosition = $modalStore[0]?.position ?? position; classesBackdrop = `${cBackdrop} ${regionBackdrop} ${zIndex} ${$$props.class ?? ""} ${$modalStore[0]?.backdropClasses ?? ""}`; classesTransitionLayer = `${cTransitionLayer} ${cPosition ?? ""}`; classesModal = `${cModal} ${background} ${width} ${height} ${padding} ${spacing} ${rounded} ${shadow} ${$modalStore[0]?.modalClasses ?? ""}`; parent = { position, // --- background, width, height, padding, spacing, rounded, shadow, // --- buttonNeutral, buttonPositive, buttonTextCancel, buttonTextConfirm, buttonTextSubmit, // --- regionBackdrop, regionHeader, regionBody, regionFooter, // --- onClose }; $$unsubscribe_modalStore(); $$unsubscribe_prefersReducedMotionStore(); return ` ${$modalStore.length > 0 ? `
${$modalStore[0].type !== "component" ? ` ` : ` `}
` : ``}`; }); const cWrapper = "flex fixed top-0 left-0 right-0 bottom-0 pointer-events-none"; const cSnackbar = "flex flex-col gap-y-2"; const cToast = "flex justify-between items-center pointer-events-auto"; const cToastActions = "flex items-center space-x-2"; const Toast = create_ssr_component(($$result, $$props, $$bindings, slots) => { let classesWrapper; let classesSnackbar; let classesToast; let filteredToasts; let $toastStore, $$unsubscribe_toastStore; let $prefersReducedMotionStore, $$unsubscribe_prefersReducedMotionStore; $$unsubscribe_prefersReducedMotionStore = subscribe(prefersReducedMotionStore, (value) => $prefersReducedMotionStore = value); const toastStore = getToastStore(); $$unsubscribe_toastStore = subscribe(toastStore, (value) => $toastStore = value); let { position = "b" } = $$props; let { max = 3 } = $$props; let { background = "variant-filled-secondary" } = $$props; let { width = "max-w-[640px]" } = $$props; let { color = "" } = $$props; let { padding = "p-4" } = $$props; let { spacing = "space-x-4" } = $$props; let { rounded = "rounded-container-token" } = $$props; let { shadow = "shadow-lg" } = $$props; let { zIndex = "z-[888]" } = $$props; let { buttonAction = "btn variant-filled" } = $$props; let { buttonDismiss = "btn-icon btn-icon-sm variant-filled" } = $$props; let { buttonDismissLabel = "✕" } = $$props; let { transitions = !$prefersReducedMotionStore } = $$props; let { transitionIn = fly } = $$props; let { transitionInParams = { duration: 250 } } = $$props; let { transitionOut = fly } = $$props; let { transitionOutParams = { duration: 250 } } = $$props; let cPosition; let cAlign; switch (position) { case "t": cPosition = "justify-center items-start"; cAlign = "items-center"; break; case "b": cPosition = "justify-center items-end"; cAlign = "items-center"; break; case "l": cPosition = "justify-start items-center"; cAlign = "items-start"; break; case "r": cPosition = "justify-end items-center"; cAlign = "items-end"; break; case "tl": cPosition = "justify-start items-start"; cAlign = "items-start"; break; case "tr": cPosition = "justify-end items-start"; cAlign = "items-end"; break; case "bl": cPosition = "justify-start items-end"; cAlign = "items-start"; break; case "br": cPosition = "justify-end items-end"; cAlign = "items-end"; break; } if ($$props.position === void 0 && $$bindings.position && position !== void 0) $$bindings.position(position); if ($$props.max === void 0 && $$bindings.max && max !== void 0) $$bindings.max(max); if ($$props.background === void 0 && $$bindings.background && background !== void 0) $$bindings.background(background); if ($$props.width === void 0 && $$bindings.width && width !== void 0) $$bindings.width(width); if ($$props.color === void 0 && $$bindings.color && color !== void 0) $$bindings.color(color); if ($$props.padding === void 0 && $$bindings.padding && padding !== void 0) $$bindings.padding(padding); if ($$props.spacing === void 0 && $$bindings.spacing && spacing !== void 0) $$bindings.spacing(spacing); if ($$props.rounded === void 0 && $$bindings.rounded && rounded !== void 0) $$bindings.rounded(rounded); if ($$props.shadow === void 0 && $$bindings.shadow && shadow !== void 0) $$bindings.shadow(shadow); if ($$props.zIndex === void 0 && $$bindings.zIndex && zIndex !== void 0) $$bindings.zIndex(zIndex); if ($$props.buttonAction === void 0 && $$bindings.buttonAction && buttonAction !== void 0) $$bindings.buttonAction(buttonAction); if ($$props.buttonDismiss === void 0 && $$bindings.buttonDismiss && buttonDismiss !== void 0) $$bindings.buttonDismiss(buttonDismiss); if ($$props.buttonDismissLabel === void 0 && $$bindings.buttonDismissLabel && buttonDismissLabel !== void 0) $$bindings.buttonDismissLabel(buttonDismissLabel); if ($$props.transitions === void 0 && $$bindings.transitions && transitions !== void 0) $$bindings.transitions(transitions); if ($$props.transitionIn === void 0 && $$bindings.transitionIn && transitionIn !== void 0) $$bindings.transitionIn(transitionIn); if ($$props.transitionInParams === void 0 && $$bindings.transitionInParams && transitionInParams !== void 0) $$bindings.transitionInParams(transitionInParams); if ($$props.transitionOut === void 0 && $$bindings.transitionOut && transitionOut !== void 0) $$bindings.transitionOut(transitionOut); if ($$props.transitionOutParams === void 0 && $$bindings.transitionOutParams && transitionOutParams !== void 0) $$bindings.transitionOutParams(transitionOutParams); classesWrapper = `${cWrapper} ${cPosition} ${zIndex} ${$$props.class || ""}`; classesSnackbar = `${cSnackbar} ${cAlign} ${padding}`; classesToast = `${cToast} ${width} ${color} ${padding} ${spacing} ${rounded} ${shadow}`; filteredToasts = Array.from($toastStore).slice(0, max); $$unsubscribe_toastStore(); $$unsubscribe_prefersReducedMotionStore(); return `${$toastStore.length ? `
${each(filteredToasts, (t, i) => { return `
${t.message}
${t.action || !t.hideDismiss ? `
${t.action ? `${t.action.label}` : ``} ${!t.hideDismiss ? `${escape(buttonDismissLabel)}` : ``}
` : ``}
`; })}
` : ``}`; }); const cBase$2 = "card p-4 shadow-xl space-y-4 w-3/4"; const LlmSettingsModal = create_ssr_component(($$result, $$props, $$bindings, slots) => { let $modalStore, $$unsubscribe_modalStore; let { parent } = $$props; const modalStore = getModalStore(); $$unsubscribe_modalStore = subscribe(modalStore, (value) => $modalStore = value); let localLlmParams; let stop = ""; if ($modalStore[0].meta) { localLlmParams = structuredClone($modalStore[0].meta); if (localLlmParams.predict_params == void 0) { localLlmParams.predict_params = {}; } stop = localLlmParams?.predict_params && localLlmParams.predict_params.stop ? localLlmParams.predict_params.stop.join("; ") : ""; } if ($$props.parent === void 0 && $$bindings.parent && parent !== void 0) $$bindings.parent(parent); $$unsubscribe_modalStore(); return ` ${$modalStore[0] ? `
${localLlmParams?.predict_params ? `
` : ``}
${localLlmParams?.predict_params ? ` ` : ``}
` : ``}`; }); const cBase$1 = "card p-4 shadow-xl space-y-4 w-3/4"; const SearchSettingsModal = create_ssr_component(($$result, $$props, $$bindings, slots) => { let $modalStore, $$unsubscribe_modalStore; let { parent } = $$props; const modalStore = getModalStore(); $$unsubscribe_modalStore = subscribe(modalStore, (value) => $modalStore = value); let localLlmParams; let stop = ""; if ($modalStore[0].meta) { localLlmParams = structuredClone($modalStore[0].meta); console.log("searchLlmParams", localLlmParams); stop = localLlmParams?.predict_params && localLlmParams.predict_params.stop ? localLlmParams.predict_params.stop.join("; ") : ""; } if ($$props.parent === void 0 && $$bindings.parent && parent !== void 0) $$bindings.parent(parent); let $$settled; let $$rendered; let previous_head = $$result.head; do { $$settled = true; $$result.head = previous_head; $$rendered = ` ${$modalStore[0] ? `
${localLlmParams?.predict_params ? `
` : ``}
${``}
` : ``}`; } while (!$$settled); $$unsubscribe_modalStore(); return $$rendered; }); const cBase = "card p-4 shadow-xl space-y-4 w-3/4"; const InvestigatorSettingsModal = create_ssr_component(($$result, $$props, $$bindings, slots) => { let $modalStore, $$unsubscribe_modalStore; let { parent } = $$props; const modalStore = getModalStore(); $$unsubscribe_modalStore = subscribe(modalStore, (value) => $modalStore = value); let localSettings; if ($modalStore[0].meta) { localSettings = structuredClone($modalStore[0].meta); console.log("investigator settings", localSettings); } if ($$props.parent === void 0 && $$bindings.parent && parent !== void 0) $$bindings.parent(parent); let $$settled; let $$rendered; let previous_head = $$result.head; do { $$settled = true; $$result.head = previous_head; $$rendered = ` ${$modalStore[0] && localSettings !== null ? `
${localSettings !== null ? `
Генерация вопросов
${validate_component(ModalPromptEditor, "ModalPromptEditor").$$render( $$result, { label: "system промпт", prompt: localSettings.prompts.createQuestions[0] }, { prompt: ($$value) => { localSettings.prompts.createQuestions[0] = $$value; $$settled = false; } }, {} )} ${validate_component(ModalPromptEditor, "ModalPromptEditor").$$render( $$result, { label: "user промпт", prompt: localSettings.prompts.createQuestions[1] }, { prompt: ($$value) => { localSettings.prompts.createQuestions[1] = $$value; $$settled = false; } }, {} )}
Ответы на вопросы
${validate_component(ModalPromptEditor, "ModalPromptEditor").$$render( $$result, { label: "system промпт", prompt: localSettings.prompts.answerQuestion[0] }, { prompt: ($$value) => { localSettings.prompts.answerQuestion[0] = $$value; $$settled = false; } }, {} )} ${validate_component(ModalPromptEditor, "ModalPromptEditor").$$render( $$result, { label: "user промпт", prompt: localSettings.prompts.answerQuestion[1] }, { prompt: ($$value) => { localSettings.prompts.answerQuestion[1] = $$value; $$settled = false; } }, {} )}
Финальный ответ
${validate_component(ModalPromptEditor, "ModalPromptEditor").$$render( $$result, { label: "system промпт", prompt: localSettings.prompts.generateFinalAnswer[0] }, { prompt: ($$value) => { localSettings.prompts.generateFinalAnswer[0] = $$value; $$settled = false; } }, {} )} ${validate_component(ModalPromptEditor, "ModalPromptEditor").$$render( $$result, { label: "user промпт", prompt: localSettings.prompts.generateFinalAnswer[1] }, { prompt: ($$value) => { localSettings.prompts.generateFinalAnswer[1] = $$value; $$settled = false; } }, {} )}
` : ``}
` : ``}`; } while (!$$settled); $$unsubscribe_modalStore(); return $$rendered; }); const css = { code: ".app.svelte-1w2a1im{display:flex;flex-direction:column;min-height:100vh}main.svelte-1w2a1im{flex:1;display:flex;flex-direction:column;width:100%;max-width:100rem;margin:0 auto;box-sizing:border-box;justify-content:center;height:100vh}@media(min-width: 480px){}", map: null }; const Layout = create_ssr_component(($$result, $$props, $$bindings, slots) => { storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow }); initializeStores(); const modalComponentRegistry = { llmSettingsModal: { ref: LlmSettingsModal }, searchSettingsModal: { ref: SearchSettingsModal }, investigatorSettingsModal: { ref: InvestigatorSettingsModal } }; $$result.css.add(css); return `${$$result.head += `${$$result.title = `LLM demo app`, ""}`, ""}
${validate_component(Header, "Header").$$render($$result, {}, {}, {})} ${validate_component(Toast, "Toast").$$render($$result, {}, {}, {})} ${validate_component(Modal, "Modal").$$render($$result, { components: modalComponentRegistry }, {}, {})}
${slots.default ? slots.default({}) : ``}
`; }); export { Layout as default }; //# sourceMappingURL=_layout.svelte-gqrelTz-.js.map