diff --git a/docs/ARCH/11 - architecture_turnaround/11 - continuity_stabilization_plan_2026-04-17.md b/docs/ARCH/11 - architecture_turnaround/11 - continuity_stabilization_plan_2026-04-17.md index 6326077..4011941 100644 --- a/docs/ARCH/11 - architecture_turnaround/11 - continuity_stabilization_plan_2026-04-17.md +++ b/docs/ARCH/11 - architecture_turnaround/11 - continuity_stabilization_plan_2026-04-17.md @@ -179,6 +179,20 @@ Still open after the accepted phase8 replay: - proactive organization authority at the very beginning of a new multi-company bookkeeping session is still weaker than the target product feel; the current system now clarifies honestly and cleanly, but it does not yet always pre-offer company selection early in the conversational flow; - some user-facing inventory/counterparty labels inside business answers still deserve final presentation cleanup, but these are now post-stabilization quality refinements rather than continuity-authority blockers. +Latest phase9 proactive-authority evidence after the fresh multi-company replay: + +- a new live replay `address_truth_harness_phase9_proactive_scope_offer_live_20260418_rerun3` is accepted end-to-end with `5/5` steps green; +- on the very first smalltalk turn, the assistant now stays in normal living-chat mode but appends a business-first proactive organization offer instead of waiting for a later forced clarification; +- explicit company choice in the next turn is now fixed deterministically into session authority before the first accounting route, so later business turns inherit one stable `active organization`; +- the restored activity-age route for `ООО Альтернатива Плюс` is now proven again inside the same shared session, not only in isolated route checks; +- the previously broken same-date inventory pivot after receivables is now routed as `inventory_on_hand_as_of_date` with the carried date `31.03.2020` and the carried organization `ООО Альтернатива Плюс`, without falling back into repeated company clarification; +- this phase therefore closes the remaining gap called out at the end of phase8: proactive company authority is no longer purely reactive in fresh multi-company bookkeeping sessions. + +Still open after the accepted phase9 replay: + +- business answers are now semantically correct on this path, but some inventory list formatting still feels heavier and more mechanical than the target human style; +- the next architecture slice should keep expanding saved-session proof across additional real user chains, while separately tightening answer presentation so exact routes do not feel template-driven even when the truth path is already correct. + ## Ready Signal The project can leave the current breakpoint when: diff --git a/docs/orchestration/address_truth_harness_phase9_proactive_scope_offer.json b/docs/orchestration/address_truth_harness_phase9_proactive_scope_offer.json new file mode 100644 index 0000000..e2bae43 --- /dev/null +++ b/docs/orchestration/address_truth_harness_phase9_proactive_scope_offer.json @@ -0,0 +1,136 @@ +{ + "schema_version": "domain_truth_harness_spec_v1", + "scenario_id": "address_truth_harness_phase9_proactive_scope_offer", + "domain": "address_phase9_proactive_scope_offer", + "title": "Phase 9 proactive organization offer replay for fresh multi-company sessions", + "description": "Focused AGENT replay for the new living-chat authority layer. The scenario validates that a fresh smalltalk turn can proactively surface organization choice, that the selected company becomes active for the session, that organization activity age remains reachable, and that same-date inventory follow-up does not fall back into repeated company clarification.", + "bindings": {}, + "steps": [ + { + "step_id": "step_01_smalltalk_with_scope_offer", + "title": "Fresh smalltalk offers organization scope without technical garbage", + "question": "привет, как дела?", + "required_answer_patterns_any": [ + "(?i)привет|дела|норм|на связи", + "(?i)организац|компан" + ], + "forbidden_answer_patterns": [ + "(?i)tool_gate_reason", + "(?i)address_mode", + "(?i)living_reason", + "(?i)mcp", + "(?i)read_only", + "(?i)snapshot_items" + ], + "criticality": "critical", + "semantic_tags": [ + "meta_smalltalk", + "proactive_scope_offer" + ] + }, + { + "step_id": "step_02_choose_organization", + "title": "Bare company choice fixes active organization for the session", + "question": "Альтернатива Плюс", + "required_answer_patterns_any": [ + "(?i)фиксир|рабочую организац", + "(?i)Альтернатива Плюс" + ], + "forbidden_answer_patterns": [ + "(?i)mcp", + "(?i)read_only", + "(?i)snapshot_items" + ], + "criticality": "critical", + "semantic_tags": [ + "company_selected", + "living_scope_selection" + ] + }, + { + "step_id": "step_03_company_activity_age", + "title": "Organization activity age is answered after proactive selection", + "question": "а по Альтернативе Плюс сколько лет активности в базе 1С?", + "allowed_reply_types": [ + "factual", + "factual_with_explanation", + "partial_coverage" + ], + "expected_intents": [ + "counterparty_activity_lifecycle" + ], + "expected_recipe": "address_counterparty_activity_lifecycle_v1", + "required_direct_answer_patterns_any": [ + "(?i)активност", + "(?i)первая подтвержденная|не удается точно определить|лет" + ], + "forbidden_direct_answer_patterns": [ + "(?i)не найден контрагент", + "(?i)уточните точное наименование организации" + ], + "criticality": "critical", + "semantic_tags": [ + "organization_activity_age", + "company_selected" + ] + }, + { + "step_id": "step_04_receivables_root", + "title": "Receivables root keeps March 2020 in the active organization scope", + "question": "кто нам должен на март 2020?", + "allowed_reply_types": [ + "factual" + ], + "expected_intents": [ + "receivables_confirmed_as_of_date" + ], + "required_filters": { + "as_of_date": "2020-03-31", + "period_from": "2020-03-01", + "period_to": "2020-03-31" + }, + "required_direct_answer_patterns_any": [ + "(?i)дебитор", + "31\\.03\\.2020" + ], + "criticality": "critical", + "semantic_tags": [ + "settlements_receivables", + "company_selected" + ] + }, + { + "step_id": "step_05_inventory_same_date", + "title": "Inventory same-date follow-up does not ask for company again", + "question": "остатки по складу на эту же дату", + "allowed_reply_types": [ + "factual" + ], + "expected_intents": [ + "inventory_on_hand_as_of_date" + ], + "required_filters": { + "as_of_date": "{{step_04_receivables_root.filters.as_of_date}}", + "period_from": "{{step_04_receivables_root.filters.period_from}}", + "period_to": "{{step_04_receivables_root.filters.period_to}}" + }, + "required_direct_answer_patterns_all": [ + "(?i)на складе", + "31\\.03\\.2020" + ], + "forbidden_direct_answer_patterns": [ + "(?i)уточните организац", + "(?i)по какой компании" + ], + "required_filter_within_previous_step_period": { + "as_of_date": "step_04_receivables_root" + }, + "criticality": "critical", + "semantic_tags": [ + "inventory_root", + "same_date_pivot", + "company_authority" + ] + } + ] +} diff --git a/llm_normalizer/backend/dist/services/assistantAddressAttemptRuntimeAdapter.js b/llm_normalizer/backend/dist/services/assistantAddressAttemptRuntimeAdapter.js index 286ac05..f76f99d 100644 --- a/llm_normalizer/backend/dist/services/assistantAddressAttemptRuntimeAdapter.js +++ b/llm_normalizer/backend/dist/services/assistantAddressAttemptRuntimeAdapter.js @@ -66,6 +66,7 @@ async function runAssistantAddressAttemptRuntime(input) { hasOperationalAdminActionRequestSignal: input.hasOperationalAdminActionRequestSignal, hasOrganizationFactLookupSignal: input.hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal: input.hasOrganizationFactFollowupSignal, + hasLivingChatSignal: input.hasLivingChatSignal, shouldEmitOrganizationSelectionReply: input.shouldEmitOrganizationSelectionReply, hasAssistantCapabilityQuestionSignal: input.hasAssistantCapabilityQuestionSignal, resolveDataScopeProbe: input.resolveDataScopeProbe, @@ -73,6 +74,7 @@ async function runAssistantAddressAttemptRuntime(input) { applyGroundingGuard: input.applyGroundingGuard, buildAssistantSafetyRefusalReply: input.buildAssistantSafetyRefusalReply, buildAssistantDataScopeContractReply: input.buildAssistantDataScopeContractReply, + buildAssistantProactiveOrganizationOfferReply: input.buildAssistantProactiveOrganizationOfferReply, buildAssistantOrganizationFactBoundaryReply: input.buildAssistantOrganizationFactBoundaryReply, buildAssistantDataScopeSelectionReply: input.buildAssistantDataScopeSelectionReply, buildAssistantOperationalBoundaryReply: input.buildAssistantOperationalBoundaryReply, diff --git a/llm_normalizer/backend/dist/services/assistantBoundaryPolicy.js b/llm_normalizer/backend/dist/services/assistantBoundaryPolicy.js index ad48420..7cc711e 100644 --- a/llm_normalizer/backend/dist/services/assistantBoundaryPolicy.js +++ b/llm_normalizer/backend/dist/services/assistantBoundaryPolicy.js @@ -51,6 +51,28 @@ function createAssistantBoundaryPolicy(deps) { "Если в нем несколько организаций, скажите, по какой смотреть данные." ].join(" "); } + function buildAssistantProactiveOrganizationOfferReply(scopeProbe = null) { + const organizations = Array.isArray(scopeProbe?.organizations) + ? scopeProbe.organizations + .map((item) => normalizeSelectedOrganization(item, deps.normalizeOrganizationScopeValue)) + .filter((item) => item.length > 0) + .filter((item, index, array) => array.indexOf(item) === index) + : []; + if (organizations.length === 1) { + return [ + `Если дальше пойдём в данные 1С, могу сразу держать в контуре ${organizations[0]}.`, + "Можно просто писать вопрос по документам, остаткам, НДС или контрагентам." + ].join(" "); + } + if (organizations.length > 1) { + const preview = organizations.slice(0, 10).join(", "); + return [ + `Если дальше пойдём в данные 1С, могу сразу зафиксировать организацию: ${preview}.`, + "Просто напишите название компании, и дальше буду держать её активной в этой сессии." + ].join(" "); + } + return ""; + } function buildAssistantDataScopeSelectionReply(organization) { const selected = normalizeSelectedOrganization(organization, deps.normalizeOrganizationScopeValue); return [ @@ -161,6 +183,7 @@ function createAssistantBoundaryPolicy(deps) { } return { buildAssistantDataScopeContractReply, + buildAssistantProactiveOrganizationOfferReply, buildAssistantDataScopeSelectionReply, buildAssistantOrganizationFactBoundaryReply, buildAssistantOperationalBoundaryReply, diff --git a/llm_normalizer/backend/dist/services/assistantLivingChatAttemptInputBuilder.js b/llm_normalizer/backend/dist/services/assistantLivingChatAttemptInputBuilder.js index 22ce9eb..030c0ba 100644 --- a/llm_normalizer/backend/dist/services/assistantLivingChatAttemptInputBuilder.js +++ b/llm_normalizer/backend/dist/services/assistantLivingChatAttemptInputBuilder.js @@ -23,6 +23,7 @@ function buildAssistantLivingChatAttemptRuntimeInput(input) { hasOperationalAdminActionRequestSignal: input.hasOperationalAdminActionRequestSignal, hasOrganizationFactLookupSignal: input.hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal: input.hasOrganizationFactFollowupSignal, + hasLivingChatSignal: input.hasLivingChatSignal, shouldEmitOrganizationSelectionReply: input.shouldEmitOrganizationSelectionReply, hasAssistantCapabilityQuestionSignal: input.hasAssistantCapabilityQuestionSignal, resolveDataScopeProbe: input.resolveDataScopeProbe, @@ -30,6 +31,7 @@ function buildAssistantLivingChatAttemptRuntimeInput(input) { applyGroundingGuard: input.applyGroundingGuard, buildAssistantSafetyRefusalReply: input.buildAssistantSafetyRefusalReply, buildAssistantDataScopeContractReply: input.buildAssistantDataScopeContractReply, + buildAssistantProactiveOrganizationOfferReply: input.buildAssistantProactiveOrganizationOfferReply, buildAssistantOrganizationFactBoundaryReply: input.buildAssistantOrganizationFactBoundaryReply, buildAssistantDataScopeSelectionReply: input.buildAssistantDataScopeSelectionReply, buildAssistantOperationalBoundaryReply: input.buildAssistantOperationalBoundaryReply, diff --git a/llm_normalizer/backend/dist/services/assistantLivingChatAttemptRuntimeAdapter.js b/llm_normalizer/backend/dist/services/assistantLivingChatAttemptRuntimeAdapter.js index 6676aff..79a31eb 100644 --- a/llm_normalizer/backend/dist/services/assistantLivingChatAttemptRuntimeAdapter.js +++ b/llm_normalizer/backend/dist/services/assistantLivingChatAttemptRuntimeAdapter.js @@ -38,6 +38,7 @@ async function runAssistantLivingChatAttemptRuntime(input) { hasOperationalAdminActionRequestSignal: input.hasOperationalAdminActionRequestSignal, hasOrganizationFactLookupSignal: input.hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal: input.hasOrganizationFactFollowupSignal, + hasLivingChatSignal: input.hasLivingChatSignal, shouldEmitOrganizationSelectionReply: input.shouldEmitOrganizationSelectionReply, hasAssistantCapabilityQuestionSignal: input.hasAssistantCapabilityQuestionSignal, resolveDataScopeProbe: input.resolveDataScopeProbe, @@ -46,6 +47,7 @@ async function runAssistantLivingChatAttemptRuntime(input) { applyGroundingGuard: input.applyGroundingGuard, buildAssistantSafetyRefusalReply: input.buildAssistantSafetyRefusalReply, buildAssistantDataScopeContractReply: input.buildAssistantDataScopeContractReply, + buildAssistantProactiveOrganizationOfferReply: input.buildAssistantProactiveOrganizationOfferReply, buildAssistantOrganizationFactBoundaryReply: input.buildAssistantOrganizationFactBoundaryReply, buildAssistantDataScopeSelectionReply: input.buildAssistantDataScopeSelectionReply, buildAssistantOperationalBoundaryReply: input.buildAssistantOperationalBoundaryReply, diff --git a/llm_normalizer/backend/dist/services/assistantLivingChatAttemptRuntimeInputBuilder.js b/llm_normalizer/backend/dist/services/assistantLivingChatAttemptRuntimeInputBuilder.js index 15d1353..4215072 100644 --- a/llm_normalizer/backend/dist/services/assistantLivingChatAttemptRuntimeInputBuilder.js +++ b/llm_normalizer/backend/dist/services/assistantLivingChatAttemptRuntimeInputBuilder.js @@ -33,6 +33,7 @@ function buildAssistantLivingChatHandlerRuntimeInput(input) { hasOperationalAdminActionRequestSignal: input.hasOperationalAdminActionRequestSignal, hasOrganizationFactLookupSignal: input.hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal: input.hasOrganizationFactFollowupSignal, + hasLivingChatSignal: input.hasLivingChatSignal, shouldEmitOrganizationSelectionReply: input.shouldEmitOrganizationSelectionReply, hasAssistantCapabilityQuestionSignal: input.hasAssistantCapabilityQuestionSignal, resolveDataScopeProbe: input.resolveDataScopeProbe, @@ -41,6 +42,7 @@ function buildAssistantLivingChatHandlerRuntimeInput(input) { applyGroundingGuard: input.applyGroundingGuard, buildAssistantSafetyRefusalReply: input.buildAssistantSafetyRefusalReply, buildAssistantDataScopeContractReply: input.buildAssistantDataScopeContractReply, + buildAssistantProactiveOrganizationOfferReply: input.buildAssistantProactiveOrganizationOfferReply, buildAssistantOrganizationFactBoundaryReply: input.buildAssistantOrganizationFactBoundaryReply, buildAssistantDataScopeSelectionReply: input.buildAssistantDataScopeSelectionReply, buildAssistantOperationalBoundaryReply: input.buildAssistantOperationalBoundaryReply, diff --git a/llm_normalizer/backend/dist/services/assistantLivingChatHandlerRuntimeAdapter.js b/llm_normalizer/backend/dist/services/assistantLivingChatHandlerRuntimeAdapter.js index 825050b..0fe990c 100644 --- a/llm_normalizer/backend/dist/services/assistantLivingChatHandlerRuntimeAdapter.js +++ b/llm_normalizer/backend/dist/services/assistantLivingChatHandlerRuntimeAdapter.js @@ -23,6 +23,7 @@ async function tryHandleAssistantLivingChatRuntime(input) { hasOperationalAdminActionRequestSignal: input.hasOperationalAdminActionRequestSignal, hasOrganizationFactLookupSignal: input.hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal: input.hasOrganizationFactFollowupSignal, + hasLivingChatSignal: input.hasLivingChatSignal, shouldEmitOrganizationSelectionReply: input.shouldEmitOrganizationSelectionReply, hasAssistantCapabilityQuestionSignal: input.hasAssistantCapabilityQuestionSignal, resolveDataScopeProbe: input.resolveDataScopeProbe, @@ -31,6 +32,7 @@ async function tryHandleAssistantLivingChatRuntime(input) { applyGroundingGuard: input.applyGroundingGuard, buildAssistantSafetyRefusalReply: input.buildAssistantSafetyRefusalReply, buildAssistantDataScopeContractReply: input.buildAssistantDataScopeContractReply, + buildAssistantProactiveOrganizationOfferReply: input.buildAssistantProactiveOrganizationOfferReply, buildAssistantOrganizationFactBoundaryReply: input.buildAssistantOrganizationFactBoundaryReply, buildAssistantDataScopeSelectionReply: input.buildAssistantDataScopeSelectionReply, buildAssistantOperationalBoundaryReply: input.buildAssistantOperationalBoundaryReply, diff --git a/llm_normalizer/backend/dist/services/assistantLivingChatRuntimeAdapter.js b/llm_normalizer/backend/dist/services/assistantLivingChatRuntimeAdapter.js index e8129b2..3d496d7 100644 --- a/llm_normalizer/backend/dist/services/assistantLivingChatRuntimeAdapter.js +++ b/llm_normalizer/backend/dist/services/assistantLivingChatRuntimeAdapter.js @@ -65,6 +65,12 @@ function findLastAddressDebugWithItem(items) { } return null; } +function hasPriorAssistantTurn(items) { + if (!Array.isArray(items)) { + return false; + } + return items.some((item) => item && typeof item === "object" && item.role === "assistant"); +} function findLastAddressDebug(items) { if (!Array.isArray(items)) { return null; @@ -157,6 +163,7 @@ async function runAssistantLivingChatRuntime(input) { let livingChatScriptGuardReason = null; let livingChatGroundingGuardApplied = false; let livingChatGroundingGuardReason = null; + let livingChatProactiveScopeOfferApplied = false; let knownOrganizations = input.mergeKnownOrganizations(input.sessionScope.knownOrganizations ?? []); let selectedOrganization = input.toNonEmptyString(input.sessionScope.selectedOrganization); let activeOrganization = input.toNonEmptyString(input.sessionScope.activeOrganization); @@ -256,6 +263,31 @@ async function runAssistantLivingChatRuntime(input) { livingChatGroundingGuardReason = groundingGuard.reason; livingChatSource = "llm_chat_grounding_guard"; } + const shouldOfferProactiveOrganizationScope = !selectedOrganization && + !activeOrganization && + !hasPriorAssistantTurn(input.sessionItems) && + input.modeDecision?.mode === "chat" && + input.hasLivingChatSignal(userMessage); + if (shouldOfferProactiveOrganizationScope) { + const proactiveScopeProbe = await input.resolveDataScopeProbe(); + const mergedKnownOrganizations = input.mergeKnownOrganizations([ + ...knownOrganizations, + ...(Array.isArray(proactiveScopeProbe?.organizations) ? proactiveScopeProbe.organizations : []) + ]); + knownOrganizations = mergedKnownOrganizations; + if (!activeOrganization && mergedKnownOrganizations.length === 1) { + activeOrganization = mergedKnownOrganizations[0]; + } + const proactiveOffer = input.buildAssistantProactiveOrganizationOfferReply(proactiveScopeProbe); + if (proactiveOffer) { + chatText = [chatText, proactiveOffer].filter((part) => String(part ?? "").trim().length > 0).join(" "); + livingChatProactiveScopeOfferApplied = true; + livingChatSource = "llm_chat_with_proactive_scope_offer"; + if (!dataScopeProbe) { + dataScopeProbe = proactiveScopeProbe; + } + } + } } if (!chatText) { return { @@ -288,6 +320,7 @@ async function runAssistantLivingChatRuntime(input) { living_chat_script_guard_reason: livingChatScriptGuardReason, living_chat_grounding_guard_applied: livingChatGroundingGuardApplied, living_chat_grounding_guard_reason: livingChatGroundingGuardReason, + living_chat_proactive_scope_offer_applied: livingChatProactiveScopeOfferApplied, living_chat_data_scope_probe_status: dataScopeProbe?.status ?? null, living_chat_data_scope_probe_channel: dataScopeProbe?.channel ?? null, living_chat_data_scope_probe_org_count: Array.isArray(dataScopeProbe?.organizations) diff --git a/llm_normalizer/backend/dist/services/assistantService.js b/llm_normalizer/backend/dist/services/assistantService.js index 9daa4c6..290fb34 100644 --- a/llm_normalizer/backend/dist/services/assistantService.js +++ b/llm_normalizer/backend/dist/services/assistantService.js @@ -5023,6 +5023,7 @@ class AssistantService { hasOperationalAdminActionRequestSignal, hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal, + hasLivingChatSignal, shouldEmitOrganizationSelectionReply, hasAssistantCapabilityQuestionSignal, resolveDataScopeProbe: () => resolveAssistantDataScopeProbe(), @@ -5030,6 +5031,7 @@ class AssistantService { applyGroundingGuard: applyLivingChatGroundingGuardFromPolicy, buildAssistantSafetyRefusalReply: buildAssistantSafetyRefusalReplyFromPolicy, buildAssistantDataScopeContractReply: buildAssistantDataScopeContractReplyFromPolicy, + buildAssistantProactiveOrganizationOfferReply: assistantBoundaryPolicy.buildAssistantProactiveOrganizationOfferReply, buildAssistantOrganizationFactBoundaryReply: buildAssistantOrganizationFactBoundaryReplyFromPolicy, buildAssistantDataScopeSelectionReply: buildAssistantDataScopeSelectionReplyFromPolicy, buildAssistantOperationalBoundaryReply: buildAssistantOperationalBoundaryReplyFromPolicy, diff --git a/llm_normalizer/backend/dist/services/assistantTransitionPolicy.js b/llm_normalizer/backend/dist/services/assistantTransitionPolicy.js index d8bf49b..3277aca 100644 --- a/llm_normalizer/backend/dist/services/assistantTransitionPolicy.js +++ b/llm_normalizer/backend/dist/services/assistantTransitionPolicy.js @@ -35,6 +35,28 @@ function createAssistantTransitionPolicy(deps) { (hasRestatementCue || hasBareSnapshotSameDateCue || hasBareSnapshotSameDatePhraseCue) && !deps.hasForeignAccountingPivotOverInventoryMessage(normalized)); } + function hasExplicitInventorySameDatePivotSignal(userMessage) { + const normalized = deps + .compactWhitespace(deps.repairAddressMojibake(String(userMessage ?? "")).toLowerCase()) + .replace(/ё/g, "е"); + if (!normalized) { + return false; + } + const hasInventoryLexeme = /(?:остат|склад|товар|номенклатур|позиц)/iu.test(normalized); + if (!hasInventoryLexeme) { + return false; + } + const sameDatePhrases = [ + "на ту же дат", + "на эту же дат", + "на эту дат", + "эту дат", + "та же дата", + "тот же период", + "этот же период" + ]; + return sameDatePhrases.some((phrase) => normalized.includes(phrase)); + } function shouldKeepPreviousIntentForShortCounterpartyRetarget(userMessage, sourceIntent) { const normalized = deps.compactWhitespace(deps.repairAddressMojibake(String(userMessage ?? "")).toLowerCase()); if (!normalized || deps.countTokens(normalized) > 4) { @@ -170,6 +192,10 @@ function createAssistantTransitionPolicy(deps) { const hasInventoryRootRestatementAlternate = deps.toNonEmptyString(alternateMessage) ? hasInventoryRootRestatementLikeSignal(String(alternateMessage ?? ""), sourceIntentHint, Boolean(recentInventoryRootFrame)) : false; + const hasExplicitInventorySameDatePivotPrimary = hasExplicitInventorySameDatePivotSignal(userMessage); + const hasExplicitInventorySameDatePivotAlternate = deps.toNonEmptyString(alternateMessage) + ? hasExplicitInventorySameDatePivotSignal(String(alternateMessage ?? "")) + : false; let hasStrongFollowupReference = hasPrimaryIndexReferenceSignal || hasAlternateIndexReferenceSignal || hasOrganizationClarificationContinuation || @@ -451,6 +477,9 @@ function createAssistantTransitionPolicy(deps) { currentFrameKind === "generic") && (hasInventoryRootRestatementPrimary || hasInventoryRootRestatementAlternate) && !deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage)); + const explicitInventorySameDatePivot = Boolean(!inventoryRootFrame && + (hasExplicitInventorySameDatePivotPrimary || hasExplicitInventorySameDatePivotAlternate) && + !deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage)); const rootScopedPivot = rootContextOnlyPivot || inventoryRootTemporalPivot || inventoryRootRestatementPivot; if (rootScopedPivot) { previousIntent = null; @@ -540,7 +569,9 @@ function createAssistantTransitionPolicy(deps) { hasSelectedObjectInventorySignalAlternate)); const carryoverTargetIntent = followupSelectionMode === "carry_root_context" ? inventoryRootFrame?.intent ?? displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined - : displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined; + : explicitInventorySameDatePivot + ? "inventory_on_hand_as_of_date" + : displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined; return { followupContext: { previous_intent: previousIntent ?? undefined, diff --git a/llm_normalizer/backend/dist/services/assistantTurnRuntimeInputBuilder.js b/llm_normalizer/backend/dist/services/assistantTurnRuntimeInputBuilder.js index 2e91856..54b60b1 100644 --- a/llm_normalizer/backend/dist/services/assistantTurnRuntimeInputBuilder.js +++ b/llm_normalizer/backend/dist/services/assistantTurnRuntimeInputBuilder.js @@ -51,6 +51,7 @@ function buildAssistantAddressAttemptRuntimeInput(runtimeInput, deps) { hasOperationalAdminActionRequestSignal: deps.hasOperationalAdminActionRequestSignal, hasOrganizationFactLookupSignal: deps.hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal: deps.hasOrganizationFactFollowupSignal, + hasLivingChatSignal: deps.hasLivingChatSignal, shouldEmitOrganizationSelectionReply: deps.shouldEmitOrganizationSelectionReply, hasAssistantCapabilityQuestionSignal: deps.hasAssistantCapabilityQuestionSignal, resolveDataScopeProbe: deps.resolveDataScopeProbe, @@ -58,6 +59,7 @@ function buildAssistantAddressAttemptRuntimeInput(runtimeInput, deps) { applyGroundingGuard: deps.applyGroundingGuard, buildAssistantSafetyRefusalReply: deps.buildAssistantSafetyRefusalReply, buildAssistantDataScopeContractReply: deps.buildAssistantDataScopeContractReply, + buildAssistantProactiveOrganizationOfferReply: deps.buildAssistantProactiveOrganizationOfferReply, buildAssistantOrganizationFactBoundaryReply: deps.buildAssistantOrganizationFactBoundaryReply, buildAssistantDataScopeSelectionReply: deps.buildAssistantDataScopeSelectionReply, buildAssistantOperationalBoundaryReply: deps.buildAssistantOperationalBoundaryReply, diff --git a/llm_normalizer/backend/src/services/assistantAddressAttemptRuntimeAdapter.ts b/llm_normalizer/backend/src/services/assistantAddressAttemptRuntimeAdapter.ts index 7cc44b5..9c2c66c 100644 --- a/llm_normalizer/backend/src/services/assistantAddressAttemptRuntimeAdapter.ts +++ b/llm_normalizer/backend/src/services/assistantAddressAttemptRuntimeAdapter.ts @@ -62,6 +62,7 @@ export interface RunAssistantAddressAttemptRuntimeInput hasOperationalAdminActionRequestSignal: RunAssistantLivingChatAttemptRuntimeInput["hasOperationalAdminActionRequestSignal"]; hasOrganizationFactLookupSignal: RunAssistantLivingChatAttemptRuntimeInput["hasOrganizationFactLookupSignal"]; hasOrganizationFactFollowupSignal: RunAssistantLivingChatAttemptRuntimeInput["hasOrganizationFactFollowupSignal"]; + hasLivingChatSignal: RunAssistantLivingChatAttemptRuntimeInput["hasLivingChatSignal"]; shouldEmitOrganizationSelectionReply: RunAssistantLivingChatAttemptRuntimeInput["shouldEmitOrganizationSelectionReply"]; hasAssistantCapabilityQuestionSignal: RunAssistantLivingChatAttemptRuntimeInput["hasAssistantCapabilityQuestionSignal"]; resolveDataScopeProbe: RunAssistantLivingChatAttemptRuntimeInput["resolveDataScopeProbe"]; @@ -69,6 +70,8 @@ export interface RunAssistantAddressAttemptRuntimeInput applyGroundingGuard: RunAssistantLivingChatAttemptRuntimeInput["applyGroundingGuard"]; buildAssistantSafetyRefusalReply: RunAssistantLivingChatAttemptRuntimeInput["buildAssistantSafetyRefusalReply"]; buildAssistantDataScopeContractReply: RunAssistantLivingChatAttemptRuntimeInput["buildAssistantDataScopeContractReply"]; + buildAssistantProactiveOrganizationOfferReply: + RunAssistantLivingChatAttemptRuntimeInput["buildAssistantProactiveOrganizationOfferReply"]; buildAssistantOrganizationFactBoundaryReply: RunAssistantLivingChatAttemptRuntimeInput["buildAssistantOrganizationFactBoundaryReply"]; buildAssistantDataScopeSelectionReply: RunAssistantLivingChatAttemptRuntimeInput["buildAssistantDataScopeSelectionReply"]; buildAssistantOperationalBoundaryReply: RunAssistantLivingChatAttemptRuntimeInput["buildAssistantOperationalBoundaryReply"]; @@ -179,6 +182,7 @@ export async function runAssistantAddressAttemptRuntime( hasOperationalAdminActionRequestSignal: input.hasOperationalAdminActionRequestSignal, hasOrganizationFactLookupSignal: input.hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal: input.hasOrganizationFactFollowupSignal, + hasLivingChatSignal: input.hasLivingChatSignal, shouldEmitOrganizationSelectionReply: input.shouldEmitOrganizationSelectionReply, hasAssistantCapabilityQuestionSignal: input.hasAssistantCapabilityQuestionSignal, resolveDataScopeProbe: input.resolveDataScopeProbe, @@ -186,6 +190,7 @@ export async function runAssistantAddressAttemptRuntime( applyGroundingGuard: input.applyGroundingGuard, buildAssistantSafetyRefusalReply: input.buildAssistantSafetyRefusalReply, buildAssistantDataScopeContractReply: input.buildAssistantDataScopeContractReply, + buildAssistantProactiveOrganizationOfferReply: input.buildAssistantProactiveOrganizationOfferReply, buildAssistantOrganizationFactBoundaryReply: input.buildAssistantOrganizationFactBoundaryReply, buildAssistantDataScopeSelectionReply: input.buildAssistantDataScopeSelectionReply, buildAssistantOperationalBoundaryReply: input.buildAssistantOperationalBoundaryReply, diff --git a/llm_normalizer/backend/src/services/assistantBoundaryPolicy.ts b/llm_normalizer/backend/src/services/assistantBoundaryPolicy.ts index bee4eea..0fa8071 100644 --- a/llm_normalizer/backend/src/services/assistantBoundaryPolicy.ts +++ b/llm_normalizer/backend/src/services/assistantBoundaryPolicy.ts @@ -19,6 +19,7 @@ export interface AssistantBoundaryPolicyGroundingGuardInput { export interface AssistantBoundaryPolicy { buildAssistantDataScopeContractReply: (scopeProbe?: Record | null) => string; + buildAssistantProactiveOrganizationOfferReply: (scopeProbe?: Record | null) => string; buildAssistantDataScopeSelectionReply: (organization: unknown) => string; buildAssistantOrganizationFactBoundaryReply: (organization: unknown) => string; buildAssistantOperationalBoundaryReply: () => string; @@ -90,6 +91,32 @@ export function createAssistantBoundaryPolicy(deps: AssistantBoundaryPolicyDeps) ].join(" "); } + function buildAssistantProactiveOrganizationOfferReply(scopeProbe: Record | null = null): string { + const organizations = Array.isArray(scopeProbe?.organizations) + ? scopeProbe.organizations + .map((item) => normalizeSelectedOrganization(item, deps.normalizeOrganizationScopeValue)) + .filter((item) => item.length > 0) + .filter((item, index, array) => array.indexOf(item) === index) + : []; + + if (organizations.length === 1) { + return [ + `Если дальше пойдём в данные 1С, могу сразу держать в контуре ${organizations[0]}.`, + "Можно просто писать вопрос по документам, остаткам, НДС или контрагентам." + ].join(" "); + } + + if (organizations.length > 1) { + const preview = organizations.slice(0, 10).join(", "); + return [ + `Если дальше пойдём в данные 1С, могу сразу зафиксировать организацию: ${preview}.`, + "Просто напишите название компании, и дальше буду держать её активной в этой сессии." + ].join(" "); + } + + return ""; + } + function buildAssistantDataScopeSelectionReply(organization: unknown): string { const selected = normalizeSelectedOrganization(organization, deps.normalizeOrganizationScopeValue); return [ @@ -219,6 +246,7 @@ export function createAssistantBoundaryPolicy(deps: AssistantBoundaryPolicyDeps) return { buildAssistantDataScopeContractReply, + buildAssistantProactiveOrganizationOfferReply, buildAssistantDataScopeSelectionReply, buildAssistantOrganizationFactBoundaryReply, buildAssistantOperationalBoundaryReply, diff --git a/llm_normalizer/backend/src/services/assistantLivingChatAttemptInputBuilder.ts b/llm_normalizer/backend/src/services/assistantLivingChatAttemptInputBuilder.ts index f59643e..094b2fd 100644 --- a/llm_normalizer/backend/src/services/assistantLivingChatAttemptInputBuilder.ts +++ b/llm_normalizer/backend/src/services/assistantLivingChatAttemptInputBuilder.ts @@ -22,6 +22,7 @@ export interface BuildAssistantLivingChatAttemptRuntimeInputInput["hasOperationalAdminActionRequestSignal"]; hasOrganizationFactLookupSignal: RunAssistantLivingChatAttemptRuntimeInput["hasOrganizationFactLookupSignal"]; hasOrganizationFactFollowupSignal: RunAssistantLivingChatAttemptRuntimeInput["hasOrganizationFactFollowupSignal"]; + hasLivingChatSignal: RunAssistantLivingChatAttemptRuntimeInput["hasLivingChatSignal"]; shouldEmitOrganizationSelectionReply: RunAssistantLivingChatAttemptRuntimeInput["shouldEmitOrganizationSelectionReply"]; hasAssistantCapabilityQuestionSignal: RunAssistantLivingChatAttemptRuntimeInput["hasAssistantCapabilityQuestionSignal"]; resolveDataScopeProbe: RunAssistantLivingChatAttemptRuntimeInput["resolveDataScopeProbe"]; @@ -29,6 +30,8 @@ export interface BuildAssistantLivingChatAttemptRuntimeInputInput["applyGroundingGuard"]; buildAssistantSafetyRefusalReply: RunAssistantLivingChatAttemptRuntimeInput["buildAssistantSafetyRefusalReply"]; buildAssistantDataScopeContractReply: RunAssistantLivingChatAttemptRuntimeInput["buildAssistantDataScopeContractReply"]; + buildAssistantProactiveOrganizationOfferReply: + RunAssistantLivingChatAttemptRuntimeInput["buildAssistantProactiveOrganizationOfferReply"]; buildAssistantOrganizationFactBoundaryReply: RunAssistantLivingChatAttemptRuntimeInput["buildAssistantOrganizationFactBoundaryReply"]; buildAssistantDataScopeSelectionReply: RunAssistantLivingChatAttemptRuntimeInput["buildAssistantDataScopeSelectionReply"]; buildAssistantOperationalBoundaryReply: RunAssistantLivingChatAttemptRuntimeInput["buildAssistantOperationalBoundaryReply"]; @@ -73,6 +76,7 @@ export function buildAssistantLivingChatAttemptRuntimeInput boolean; hasOrganizationFactLookupSignal: (message: string) => boolean; hasOrganizationFactFollowupSignal: (message: string, items: unknown[]) => boolean; + hasLivingChatSignal: (message: string) => boolean; shouldEmitOrganizationSelectionReply: (message: string, activeOrganization: string | null) => boolean; hasAssistantCapabilityQuestionSignal: (message: string) => boolean; resolveDataScopeProbe: () => Promise | null>; @@ -51,6 +52,7 @@ export interface AssistantLivingChatRuntimeInput { }; buildAssistantSafetyRefusalReply: () => string; buildAssistantDataScopeContractReply: (scopeProbe: Record | null) => string; + buildAssistantProactiveOrganizationOfferReply: (scopeProbe: Record | null) => string; buildAssistantOrganizationFactBoundaryReply: (organization: string | null) => string; buildAssistantDataScopeSelectionReply: (organization: string | null) => string; buildAssistantOperationalBoundaryReply: () => string; @@ -134,6 +136,13 @@ function findLastAddressDebugWithItem(items: unknown[]): Record return null; } +function hasPriorAssistantTurn(items: unknown[]): boolean { + if (!Array.isArray(items)) { + return false; + } + return items.some((item) => item && typeof item === "object" && (item as { role?: string }).role === "assistant"); +} + function findLastAddressDebug(items: unknown[]): Record | null { if (!Array.isArray(items)) { return null; @@ -252,6 +261,7 @@ export async function runAssistantLivingChatRuntime( let livingChatScriptGuardReason: string | null = null; let livingChatGroundingGuardApplied = false; let livingChatGroundingGuardReason: string | null = null; + let livingChatProactiveScopeOfferApplied = false; let knownOrganizations = input.mergeKnownOrganizations(input.sessionScope.knownOrganizations ?? []); let selectedOrganization = input.toNonEmptyString(input.sessionScope.selectedOrganization); let activeOrganization = input.toNonEmptyString(input.sessionScope.activeOrganization); @@ -348,6 +358,33 @@ export async function runAssistantLivingChatRuntime( livingChatGroundingGuardReason = groundingGuard.reason; livingChatSource = "llm_chat_grounding_guard"; } + + const shouldOfferProactiveOrganizationScope = + !selectedOrganization && + !activeOrganization && + !hasPriorAssistantTurn(input.sessionItems) && + input.modeDecision?.mode === "chat" && + input.hasLivingChatSignal(userMessage); + if (shouldOfferProactiveOrganizationScope) { + const proactiveScopeProbe = await input.resolveDataScopeProbe(); + const mergedKnownOrganizations = input.mergeKnownOrganizations([ + ...knownOrganizations, + ...(Array.isArray(proactiveScopeProbe?.organizations) ? (proactiveScopeProbe.organizations as unknown[]) : []) + ]); + knownOrganizations = mergedKnownOrganizations; + if (!activeOrganization && mergedKnownOrganizations.length === 1) { + activeOrganization = mergedKnownOrganizations[0]; + } + const proactiveOffer = input.buildAssistantProactiveOrganizationOfferReply(proactiveScopeProbe); + if (proactiveOffer) { + chatText = [chatText, proactiveOffer].filter((part) => String(part ?? "").trim().length > 0).join(" "); + livingChatProactiveScopeOfferApplied = true; + livingChatSource = "llm_chat_with_proactive_scope_offer"; + if (!dataScopeProbe) { + dataScopeProbe = proactiveScopeProbe; + } + } + } } if (!chatText) { @@ -385,6 +422,7 @@ export async function runAssistantLivingChatRuntime( living_chat_script_guard_reason: livingChatScriptGuardReason, living_chat_grounding_guard_applied: livingChatGroundingGuardApplied, living_chat_grounding_guard_reason: livingChatGroundingGuardReason, + living_chat_proactive_scope_offer_applied: livingChatProactiveScopeOfferApplied, living_chat_data_scope_probe_status: dataScopeProbe?.status ?? null, living_chat_data_scope_probe_channel: dataScopeProbe?.channel ?? null, living_chat_data_scope_probe_org_count: Array.isArray(dataScopeProbe?.organizations) diff --git a/llm_normalizer/backend/src/services/assistantService.ts b/llm_normalizer/backend/src/services/assistantService.ts index bb357ba..46b9be0 100644 --- a/llm_normalizer/backend/src/services/assistantService.ts +++ b/llm_normalizer/backend/src/services/assistantService.ts @@ -4981,6 +4981,7 @@ export class AssistantService { hasOperationalAdminActionRequestSignal, hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal, + hasLivingChatSignal, shouldEmitOrganizationSelectionReply, hasAssistantCapabilityQuestionSignal, resolveDataScopeProbe: () => resolveAssistantDataScopeProbe(), @@ -4988,6 +4989,7 @@ export class AssistantService { applyGroundingGuard: applyLivingChatGroundingGuardFromPolicy, buildAssistantSafetyRefusalReply: buildAssistantSafetyRefusalReplyFromPolicy, buildAssistantDataScopeContractReply: buildAssistantDataScopeContractReplyFromPolicy, + buildAssistantProactiveOrganizationOfferReply: assistantBoundaryPolicy.buildAssistantProactiveOrganizationOfferReply, buildAssistantOrganizationFactBoundaryReply: buildAssistantOrganizationFactBoundaryReplyFromPolicy, buildAssistantDataScopeSelectionReply: buildAssistantDataScopeSelectionReplyFromPolicy, buildAssistantOperationalBoundaryReply: buildAssistantOperationalBoundaryReplyFromPolicy, diff --git a/llm_normalizer/backend/src/services/assistantTransitionPolicy.ts b/llm_normalizer/backend/src/services/assistantTransitionPolicy.ts index 67db28d..858d711 100644 --- a/llm_normalizer/backend/src/services/assistantTransitionPolicy.ts +++ b/llm_normalizer/backend/src/services/assistantTransitionPolicy.ts @@ -43,6 +43,29 @@ export function createAssistantTransitionPolicy(deps) { ); } + function hasExplicitInventorySameDatePivotSignal(userMessage) { + const normalized = deps + .compactWhitespace(deps.repairAddressMojibake(String(userMessage ?? "")).toLowerCase()) + .replace(/ё/g, "е"); + if (!normalized) { + return false; + } + const hasInventoryLexeme = /(?:остат|склад|товар|номенклатур|позиц)/iu.test(normalized); + if (!hasInventoryLexeme) { + return false; + } + const sameDatePhrases = [ + "на ту же дат", + "на эту же дат", + "на эту дат", + "эту дат", + "та же дата", + "тот же период", + "этот же период" + ]; + return sameDatePhrases.some((phrase) => normalized.includes(phrase)); + } + function shouldKeepPreviousIntentForShortCounterpartyRetarget(userMessage, sourceIntent) { const normalized = deps.compactWhitespace( deps.repairAddressMojibake(String(userMessage ?? "")).toLowerCase() @@ -227,6 +250,10 @@ export function createAssistantTransitionPolicy(deps) { Boolean(recentInventoryRootFrame) ) : false; + const hasExplicitInventorySameDatePivotPrimary = hasExplicitInventorySameDatePivotSignal(userMessage); + const hasExplicitInventorySameDatePivotAlternate = deps.toNonEmptyString(alternateMessage) + ? hasExplicitInventorySameDatePivotSignal(String(alternateMessage ?? "")) + : false; let hasStrongFollowupReference = hasPrimaryIndexReferenceSignal || hasAlternateIndexReferenceSignal || @@ -550,6 +577,11 @@ export function createAssistantTransitionPolicy(deps) { (hasInventoryRootRestatementPrimary || hasInventoryRootRestatementAlternate) && !deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage) ); + const explicitInventorySameDatePivot = Boolean( + !inventoryRootFrame && + (hasExplicitInventorySameDatePivotPrimary || hasExplicitInventorySameDatePivotAlternate) && + !deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage) + ); const rootScopedPivot = rootContextOnlyPivot || inventoryRootTemporalPivot || inventoryRootRestatementPivot; if (rootScopedPivot) { previousIntent = null; @@ -651,7 +683,9 @@ export function createAssistantTransitionPolicy(deps) { const carryoverTargetIntent = followupSelectionMode === "carry_root_context" ? inventoryRootFrame?.intent ?? displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined - : displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined; + : explicitInventorySameDatePivot + ? "inventory_on_hand_as_of_date" + : displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined; return { followupContext: { previous_intent: previousIntent ?? undefined, diff --git a/llm_normalizer/backend/src/services/assistantTurnRuntimeInputBuilder.ts b/llm_normalizer/backend/src/services/assistantTurnRuntimeInputBuilder.ts index 6378629..427168c 100644 --- a/llm_normalizer/backend/src/services/assistantTurnRuntimeInputBuilder.ts +++ b/llm_normalizer/backend/src/services/assistantTurnRuntimeInputBuilder.ts @@ -67,6 +67,7 @@ export interface AssistantTurnRuntimeBuilderDeps { AddressAttemptRuntimeInput["hasOperationalAdminActionRequestSignal"]; hasOrganizationFactLookupSignal: AddressAttemptRuntimeInput["hasOrganizationFactLookupSignal"]; hasOrganizationFactFollowupSignal: AddressAttemptRuntimeInput["hasOrganizationFactFollowupSignal"]; + hasLivingChatSignal: AddressAttemptRuntimeInput["hasLivingChatSignal"]; shouldEmitOrganizationSelectionReply: AddressAttemptRuntimeInput["shouldEmitOrganizationSelectionReply"]; hasAssistantCapabilityQuestionSignal: @@ -77,6 +78,8 @@ export interface AssistantTurnRuntimeBuilderDeps { buildAssistantSafetyRefusalReply: AddressAttemptRuntimeInput["buildAssistantSafetyRefusalReply"]; buildAssistantDataScopeContractReply: AddressAttemptRuntimeInput["buildAssistantDataScopeContractReply"]; + buildAssistantProactiveOrganizationOfferReply: + AddressAttemptRuntimeInput["buildAssistantProactiveOrganizationOfferReply"]; buildAssistantOrganizationFactBoundaryReply: AddressAttemptRuntimeInput["buildAssistantOrganizationFactBoundaryReply"]; buildAssistantDataScopeSelectionReply: @@ -164,6 +167,7 @@ export function buildAssistantAddressAttemptRuntimeInput hasOperationalAdminActionRequestSignal: deps.hasOperationalAdminActionRequestSignal, hasOrganizationFactLookupSignal: deps.hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal: deps.hasOrganizationFactFollowupSignal, + hasLivingChatSignal: deps.hasLivingChatSignal, shouldEmitOrganizationSelectionReply: deps.shouldEmitOrganizationSelectionReply, hasAssistantCapabilityQuestionSignal: deps.hasAssistantCapabilityQuestionSignal, resolveDataScopeProbe: deps.resolveDataScopeProbe, @@ -171,6 +175,7 @@ export function buildAssistantAddressAttemptRuntimeInput applyGroundingGuard: deps.applyGroundingGuard, buildAssistantSafetyRefusalReply: deps.buildAssistantSafetyRefusalReply, buildAssistantDataScopeContractReply: deps.buildAssistantDataScopeContractReply, + buildAssistantProactiveOrganizationOfferReply: deps.buildAssistantProactiveOrganizationOfferReply, buildAssistantOrganizationFactBoundaryReply: deps.buildAssistantOrganizationFactBoundaryReply, buildAssistantDataScopeSelectionReply: deps.buildAssistantDataScopeSelectionReply, buildAssistantOperationalBoundaryReply: deps.buildAssistantOperationalBoundaryReply, diff --git a/llm_normalizer/backend/tests/assistantBoundaryPolicy.test.ts b/llm_normalizer/backend/tests/assistantBoundaryPolicy.test.ts index e61502e..14e6a46 100644 --- a/llm_normalizer/backend/tests/assistantBoundaryPolicy.test.ts +++ b/llm_normalizer/backend/tests/assistantBoundaryPolicy.test.ts @@ -56,6 +56,23 @@ describe("assistantBoundaryPolicy", () => { expect(reply).not.toContain("\\"); }); + it("builds proactive organization offer without technical labels", () => { + const policy = createPolicy(); + + const reply = policy.buildAssistantProactiveOrganizationOfferReply({ + status: "resolved", + channel: "default", + organizations: ["ООО Альтернатива Плюс", "ООО Лайсвуд", "РАЙМ"] + }); + + expect(reply).toContain("Если дальше пойдём в данные 1С"); + expect(reply).toContain("ООО Альтернатива Плюс"); + expect(reply).toContain("ООО Лайсвуд"); + expect(reply).toContain("РАЙМ"); + expect(reply).not.toContain("MCP"); + expect(reply.toLowerCase()).not.toContain("snapshot"); + }); + it("strips unexpected CJK fragments from live chat reply", () => { const policy = createPolicy(); diff --git a/llm_normalizer/backend/tests/assistantLivingChatHandlerRuntimeAdapter.test.ts b/llm_normalizer/backend/tests/assistantLivingChatHandlerRuntimeAdapter.test.ts index 055afe3..b337157 100644 --- a/llm_normalizer/backend/tests/assistantLivingChatHandlerRuntimeAdapter.test.ts +++ b/llm_normalizer/backend/tests/assistantLivingChatHandlerRuntimeAdapter.test.ts @@ -23,6 +23,7 @@ function buildInput(overrides: Record = {}) { hasOperationalAdminActionRequestSignal: () => false, hasOrganizationFactLookupSignal: () => false, hasOrganizationFactFollowupSignal: () => false, + hasLivingChatSignal: () => true, shouldEmitOrganizationSelectionReply: () => false, hasAssistantCapabilityQuestionSignal: () => false, resolveDataScopeProbe: async () => null, diff --git a/llm_normalizer/backend/tests/assistantLivingChatRuntimeAdapter.test.ts b/llm_normalizer/backend/tests/assistantLivingChatRuntimeAdapter.test.ts index dc36f0d..9be473f 100644 --- a/llm_normalizer/backend/tests/assistantLivingChatRuntimeAdapter.test.ts +++ b/llm_normalizer/backend/tests/assistantLivingChatRuntimeAdapter.test.ts @@ -37,6 +37,7 @@ function buildRuntimeInput(overrides: Record = {}) { hasOperationalAdminActionRequestSignal: () => false, hasOrganizationFactLookupSignal: () => false, hasOrganizationFactFollowupSignal: () => false, + hasLivingChatSignal: () => true, shouldEmitOrganizationSelectionReply: () => false, hasAssistantCapabilityQuestionSignal: () => false, resolveDataScopeProbe, @@ -53,6 +54,7 @@ function buildRuntimeInput(overrides: Record = {}) { }), buildAssistantSafetyRefusalReply: () => "safety", buildAssistantDataScopeContractReply: () => "scope", + buildAssistantProactiveOrganizationOfferReply: () => "", buildAssistantOrganizationFactBoundaryReply: () => "org-boundary", buildAssistantDataScopeSelectionReply: () => "org-selection", buildAssistantOperationalBoundaryReply: () => "ops", @@ -134,6 +136,56 @@ describe("assistant living chat runtime adapter", () => { expect(executeLlmChat).toHaveBeenCalledTimes(1); }); + it("adds proactive organization offer on first smalltalk turn when multiple organizations are available", async () => { + const resolveDataScopeProbe = vi.fn(async () => ({ + status: "resolved", + channel: "default", + organizations: ["ООО Альтернатива Плюс", "ООО Лайсвуд", "РАЙМ"], + error: null + })); + const input = buildRuntimeInput({ + userMessage: "привет, как дела?", + resolveDataScopeProbe, + buildAssistantProactiveOrganizationOfferReply: (scopeProbe: Record | null) => { + const organizations = Array.isArray(scopeProbe?.organizations) ? scopeProbe.organizations.join(", ") : ""; + return `offer:${organizations}`; + } + }); + + const output = await runAssistantLivingChatRuntime(input); + + expect(output.handled).toBe(true); + expect(output.chatText).toContain("llm-text"); + expect(output.chatText).toContain("offer:ООО Альтернатива Плюс, ООО Лайсвуд, РАЙМ"); + expect(output.debug?.living_chat_response_source).toBe("llm_chat_with_proactive_scope_offer"); + expect(output.debug?.living_chat_proactive_scope_offer_applied).toBe(true); + expect(output.debug?.living_chat_data_scope_probe_org_count).toBe(3); + expect(output.debug?.assistant_known_organizations).toEqual(["ООО Альтернатива Плюс", "ООО Лайсвуд", "РАЙМ"]); + }); + + it("does not add proactive organization offer after the session already has assistant context", async () => { + const resolveDataScopeProbe = vi.fn(async () => ({ + status: "resolved", + channel: "default", + organizations: ["ООО Альтернатива Плюс", "ООО Лайсвуд"], + error: null + })); + const input = buildRuntimeInput({ + userMessage: "привет еще раз", + sessionItems: [{ role: "assistant", text: "Ранее уже отвечал." }], + resolveDataScopeProbe, + buildAssistantProactiveOrganizationOfferReply: () => "offer" + }); + + const output = await runAssistantLivingChatRuntime(input); + + expect(output.handled).toBe(true); + expect(output.chatText).toBe("llm-text"); + expect(output.debug?.living_chat_response_source).toBe("llm_chat"); + expect(output.debug?.living_chat_proactive_scope_offer_applied).toBe(false); + expect(resolveDataScopeProbe).not.toHaveBeenCalled(); + }); + it("builds deterministic memory recap for prior selected-object address context", async () => { const executeLlmChat = vi.fn(async () => "raw-llm"); const input = buildRuntimeInput({ @@ -144,6 +196,9 @@ describe("assistant living chat runtime adapter", () => { role: "assistant", debug: { execution_lane: "address_query", + answer_grounding_check: { + status: "grounded" + }, detected_intent: "inventory_purchase_provenance_for_item", extracted_filters: { item: "Зеркало для инвалидов поворотное травмобезопасное", @@ -160,7 +215,7 @@ describe("assistant living chat runtime adapter", () => { expect(output.handled).toBe(true); expect(output.chatText).toContain("Зеркало для инвалидов поворотное травмобезопасное"); - expect(output.chatText).toContain("кто поставил"); + expect(output.chatText).toContain("кто поставлял"); expect(output.debug?.living_chat_response_source).toBe("deterministic_memory_recap_contract"); expect(executeLlmChat).not.toHaveBeenCalled(); }); diff --git a/llm_normalizer/backend/tests/assistantTransitionPolicy.test.ts b/llm_normalizer/backend/tests/assistantTransitionPolicy.test.ts index 8423ab1..e3d68af 100644 --- a/llm_normalizer/backend/tests/assistantTransitionPolicy.test.ts +++ b/llm_normalizer/backend/tests/assistantTransitionPolicy.test.ts @@ -212,6 +212,48 @@ describe("assistantTransitionPolicy", () => { expect(contract.decision).toBe("continue_previous"); }); + it("retargets same-date inventory follow-up away from receivables intent", () => { + const policy = buildPolicy({ + findLastAddressAssistantItem: () => ({ + text: "Подтвержденная дебиторская задолженность на 31.03.2020 собрана.", + debug: { + detected_intent: "receivables_confirmed_as_of_date", + extracted_filters: { + organization: 'ООО "Альтернатива Плюс"', + as_of_date: "2020-03-31", + period_from: "2020-03-01", + period_to: "2020-03-31" + }, + anchor_type: "organization", + anchor_value_resolved: 'ООО "Альтернатива Плюс"' + } + }), + hasAddressFollowupContextSignal: () => true, + hasReferentialPointer: () => true, + findRecentInventoryRootFrame: () => null, + resolveAddressIntent: () => ({ intent: "unknown" }) + }); + + const carryover = policy.resolveAddressFollowupCarryoverContext( + "остатки по складу на эту же дату", + [], + null, + null, + null + ); + + expect(carryover?.followupSelectionMode).toBe("carry_previous_intent"); + expect(carryover?.followupContext?.previous_intent).toBe("receivables_confirmed_as_of_date"); + expect(carryover?.followupContext?.target_intent).toBe("inventory_on_hand_as_of_date"); + expect(carryover?.followupContext?.previous_filters).toMatchObject({ + organization: 'ООО "Альтернатива Плюс"', + as_of_date: "2020-03-31", + period_from: "2020-03-01", + period_to: "2020-03-31" + }); + expect(carryover?.followupContext?.root_context_only).toBeUndefined(); + }); + it("drops stale carryover for a fresh standalone topic from another intent family", () => { const policy = buildPolicy({ findLastAddressAssistantItem: () => ({ diff --git a/llm_normalizer/data/autorun_generators/history.json b/llm_normalizer/data/autorun_generators/history.json index c43587d..2e0a95d 100644 --- a/llm_normalizer/data/autorun_generators/history.json +++ b/llm_normalizer/data/autorun_generators/history.json @@ -9,7 +9,7 @@ "questions": [ "какие остатки на складе на март 2021", "давай по Альтернативе Плюс", - "тогда покажи остатки на март 2021", + "тогда покажи остатки на июль2017", "По выбранному объекту \"Столешница 600*3050*26 альмандин\": кто нам это поставил?", "а по этой позиции когда была закупка?", "покажи документы по этой позиции", diff --git a/llm_normalizer/data/eval_cases/assistant_autogen_saved_user_sessions_20260417150806_gen-ag04171508-760111.json b/llm_normalizer/data/eval_cases/assistant_autogen_saved_user_sessions_20260417150806_gen-ag04171508-760111.json index aaf1601..4cca394 100644 --- a/llm_normalizer/data/eval_cases/assistant_autogen_saved_user_sessions_20260417150806_gen-ag04171508-760111.json +++ b/llm_normalizer/data/eval_cases/assistant_autogen_saved_user_sessions_20260417150806_gen-ag04171508-760111.json @@ -2,11 +2,10 @@ "suite_id": "assistant_saved_session_gen-ag04171508-760111", "suite_version": "0.1.0", "schema_version": "assistant_saved_session_suite_v0_1", - "generated_at": "2026-04-17T15:08:06+00:00", + "generated_at": "2026-04-18T07:12:37.854Z", "generation_id": "gen-ag04171508-760111", "mode": "saved_user_sessions", "title": "AGENT replay for inventory clarification continuity and answer-shape cleanliness", - "domain": "inventory_answer_shape_and_continuity", "scenario_count": 1, "case_ids": [ "SAVED-001" @@ -26,7 +25,7 @@ "user_message": "давай по Альтернативе Плюс" }, { - "user_message": "тогда покажи остатки на март 2021" + "user_message": "тогда покажи остатки на июль2017" }, { "user_message": "По выбранному объекту \"Столешница 600*3050*26 альмандин\": кто нам это поставил?" @@ -46,4 +45,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/llm_normalizer/data/eval_cases/assistant_saved_session_runtime_job-a4V7FoXsdC.json b/llm_normalizer/data/eval_cases/assistant_saved_session_runtime_job-a4V7FoXsdC.json new file mode 100644 index 0000000..636220c --- /dev/null +++ b/llm_normalizer/data/eval_cases/assistant_saved_session_runtime_job-a4V7FoXsdC.json @@ -0,0 +1,111 @@ +{ + "suite_id": "assistant_saved_session_runtime_job-a4V7FoXsdC", + "suite_version": "0.1.0", + "schema_version": "assistant_saved_session_runtime_v0_1", + "title": "БОЛЬШОЙ ОБЩИЙ Ручная сессия 16.04.2026, 21:26:06", + "scenario_count": 1, + "case_ids": [ + "SAVED-001" + ], + "cases": [ + { + "case_id": "SAVED-001", + "scenario_tag": "saved_user_sessions_runtime", + "title": "БОЛЬШОЙ ОБЩИЙ Ручная сессия 16.04.2026, 21:26:06", + "question_type": "followup", + "broadness_level": "medium", + "turns": [ + { + "user_message": "приветик - че как там дела" + }, + { + "user_message": "расскажи что можешь интересного" + }, + { + "user_message": "кайф - что там на складе по остаткам?" + }, + { + "user_message": "а исторические остатки на другие даты умеешь?" + }, + { + "user_message": "давай на июль 2017" + }, + { + "user_message": "март 2016" + }, + { + "user_message": "По выбранному объекту \"Рабочая станция универсального специалиста (индивидуальное изготовление)\": где взяли это?" + }, + { + "user_message": "а кому продали?" + }, + { + "user_message": "у тебя написано кто контрагент: рабочая станция - это ошибка?" + }, + { + "user_message": "ндс можешь прикинуть на дату покупки рабочей станции?" + }, + { + "user_message": "а какой ндс мы должны сгрузить на март 2020?" + }, + { + "user_message": "прикинь какой ндс нам надо заплатить на февраль 2017" + }, + { + "user_message": "кто у нас самый доходный клиент за все время" + }, + { + "user_message": "кто нам должен денег на май 2017" + }, + { + "user_message": "а какой ндс мы должны примерно заплатить за этот период?" + }, + { + "user_message": "мы должны комуто денег на сегодня?" + }, + { + "user_message": "а нам?" + }, + { + "user_message": "какой у нас самый доходный год" + }, + { + "user_message": "а за 2017 мы скок заработали?" + }, + { + "user_message": "сколько вообще денег мы заработали за все время?" + }, + { + "user_message": "ты умеешь считать дельту по договорам?" + }, + { + "user_message": "по чепурнову покажи все доки" + }, + { + "user_message": "а по свк" + }, + { + "user_message": "а сейчас у нас есть что на складе?" + }, + { + "user_message": "что нам отгружать чепурнов? какой товар или услугу?" + }, + { + "user_message": "какие остатки на складе на сегодня" + }, + { + "user_message": "остатки на март 2016" + }, + { + "user_message": "хвосты покажи по счету 60 на август 2022" + }, + { + "user_message": "Есть ли остатки товара, которые закупались очень давно" + }, + { + "user_message": "Какие конкретно номенклатуры формируют остаток по складу на май 2020" + } + ] + } + ] +} \ No newline at end of file diff --git a/llm_normalizer/frontend/dist/assets/index-3F56oUw0.js b/llm_normalizer/frontend/dist/assets/index-3F56oUw0.js new file mode 100644 index 0000000..351bcae --- /dev/null +++ b/llm_normalizer/frontend/dist/assets/index-3F56oUw0.js @@ -0,0 +1,24 @@ +(function(){const h=document.createElement("link").relList;if(h&&h.supports&&h.supports("modulepreload"))return;for(const E of document.querySelectorAll('link[rel="modulepreload"]'))R(E);new MutationObserver(E=>{for(const I of E)if(I.type==="childList")for(const Q of I.addedNodes)Q.tagName==="LINK"&&Q.rel==="modulepreload"&&R(Q)}).observe(document,{childList:!0,subtree:!0});function m(E){const I={};return E.integrity&&(I.integrity=E.integrity),E.referrerPolicy&&(I.referrerPolicy=E.referrerPolicy),E.crossOrigin==="use-credentials"?I.credentials="include":E.crossOrigin==="anonymous"?I.credentials="omit":I.credentials="same-origin",I}function R(E){if(E.ep)return;E.ep=!0;const I=m(E);fetch(E.href,I)}})();function cd(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ya={exports:{}},jo={},xa={exports:{}},me={};var Uc;function xf(){if(Uc)return me;Uc=1;var i=Symbol.for("react.element"),h=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),I=Symbol.for("react.provider"),Q=Symbol.for("react.context"),le=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),z=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),X=Symbol.iterator;function ee(y){return y===null||typeof y!="object"?null:(y=X&&y[X]||y["@@iterator"],typeof y=="function"?y:null)}var Me={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ue=Object.assign,ce={};function pe(y,k,re){this.props=y,this.context=k,this.refs=ce,this.updater=re||Me}pe.prototype.isReactComponent={},pe.prototype.setState=function(y,k){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,k,"setState")},pe.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function Ve(){}Ve.prototype=pe.prototype;function Xe(y,k,re){this.props=y,this.context=k,this.refs=ce,this.updater=re||Me}var We=Xe.prototype=new Ve;We.constructor=Xe,ue(We,pe.prototype),We.isPureReactComponent=!0;var Ae=Array.isArray,$=Object.prototype.hasOwnProperty,oe={current:null},je={key:!0,ref:!0,__self:!0,__source:!0};function Be(y,k,re){var ie,ae={},he=null,ye=null;if(k!=null)for(ie in k.ref!==void 0&&(ye=k.ref),k.key!==void 0&&(he=""+k.key),k)$.call(k,ie)&&!je.hasOwnProperty(ie)&&(ae[ie]=k[ie]);var xe=arguments.length-2;if(xe===1)ae.children=re;else if(1>>1,k=M[y];if(0>>1;yE(ae,A))heE(ye,ae)?(M[y]=ye,M[he]=A,y=he):(M[y]=ae,M[ie]=A,y=ie);else if(heE(ye,A))M[y]=ye,M[he]=A,y=he;else break e}}return F}function E(M,F){var A=M.sortIndex-F.sortIndex;return A!==0?A:M.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var I=performance;i.unstable_now=function(){return I.now()}}else{var Q=Date,le=Q.now();i.unstable_now=function(){return Q.now()-le}}var te=[],z=[],Y=1,X=null,ee=3,Me=!1,ue=!1,ce=!1,pe=typeof setTimeout=="function"?setTimeout:null,Ve=typeof clearTimeout=="function"?clearTimeout:null,Xe=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function We(M){for(var F=m(z);F!==null;){if(F.callback===null)R(z);else if(F.startTime<=M)R(z),F.sortIndex=F.expirationTime,h(te,F);else break;F=m(z)}}function Ae(M){if(ce=!1,We(M),!ue)if(m(te)!==null)ue=!0,ne($);else{var F=m(z);F!==null&&Z(Ae,F.startTime-M)}}function $(M,F){ue=!1,ce&&(ce=!1,Ve(Be),Be=-1),Me=!0;var A=ee;try{for(We(F),X=m(te);X!==null&&(!(X.expirationTime>F)||M&&!Ut());){var y=X.callback;if(typeof y=="function"){X.callback=null,ee=X.priorityLevel;var k=y(X.expirationTime<=F);F=i.unstable_now(),typeof k=="function"?X.callback=k:X===m(te)&&R(te),We(F)}else R(te);X=m(te)}if(X!==null)var re=!0;else{var ie=m(z);ie!==null&&Z(Ae,ie.startTime-F),re=!1}return re}finally{X=null,ee=A,Me=!1}}var oe=!1,je=null,Be=-1,gt=5,ct=-1;function Ut(){return!(i.unstable_now()-ctM||125y?(M.sortIndex=A,h(z,M),m(te)===null&&M===m(z)&&(ce?(Ve(Be),Be=-1):ce=!0,Z(Ae,A-y))):(M.sortIndex=k,h(te,M),ue||Me||(ue=!0,ne($))),M},i.unstable_shouldYield=Ut,i.unstable_wrapCallback=function(M){var F=ee;return function(){var A=ee;ee=F;try{return M.apply(this,arguments)}finally{ee=A}}}})(wa)),wa}var Vc;function jf(){return Vc||(Vc=1,Sa.exports=kf()),Sa.exports}var Wc;function Cf(){if(Wc)return Ft;Wc=1;var i=Ma(),h=jf();function m(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),te=Object.prototype.hasOwnProperty,z=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Y={},X={};function ee(e){return te.call(X,e)?!0:te.call(Y,e)?!1:z.test(e)?X[e]=!0:(Y[e]=!0,!1)}function Me(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function ue(e,t,n,r){if(t===null||typeof t>"u"||Me(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ce(e,t,n,r,s,o,u){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=u}var pe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){pe[e]=new ce(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];pe[t]=new ce(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){pe[e]=new ce(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){pe[e]=new ce(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){pe[e]=new ce(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){pe[e]=new ce(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){pe[e]=new ce(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){pe[e]=new ce(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){pe[e]=new ce(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ve=/[\-:]([a-z])/g;function Xe(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ve,Xe);pe[t]=new ce(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ve,Xe);pe[t]=new ce(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ve,Xe);pe[t]=new ce(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){pe[e]=new ce(e,1,!1,e.toLowerCase(),null,!1,!1)}),pe.xlinkHref=new ce("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){pe[e]=new ce(e,1,!1,e.toLowerCase(),null,!0,!0)});function We(e,t,n,r){var s=pe.hasOwnProperty(t)?pe[t]:null;(s!==null?s.type!==0:r||!(2d||s[u]!==o[d]){var p=` +`+s[u].replace(" at new "," at ");return e.displayName&&p.includes("")&&(p=p.replace("",e.displayName)),p}while(1<=u&&0<=d);break}}}finally{re=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?k(e):""}function ae(e){switch(e.tag){case 5:return k(e.type);case 16:return k("Lazy");case 13:return k("Suspense");case 19:return k("SuspenseList");case 0:case 2:case 15:return e=ie(e.type,!1),e;case 11:return e=ie(e.type.render,!1),e;case 1:return e=ie(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case je:return"Fragment";case oe:return"Portal";case gt:return"Profiler";case Be:return"StrictMode";case B:return"Suspense";case Le:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ut:return(e.displayName||"Context")+".Consumer";case ct:return(e._context.displayName||"Context")+".Provider";case dt:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ke:return t=e.displayName||null,t!==null?t:he(e.type)||"Memo";case ne:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}function ye(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(t);case 8:return t===Be?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function xe(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function we(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ft(e){var t=we(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(u){r=""+u,o.call(this,u)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(u){r=""+u},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function qt(e){e._valueTracker||(e._valueTracker=ft(e))}function ir(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=we(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Cn(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function an(e,t){var n=t.checked;return A({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Pe(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=xe(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Bt(e,t){t=t.checked,t!=null&&We(e,"checked",t,!1)}function st(e,t){Bt(e,t);var n=xe(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?jt(e,t.type,n):t.hasOwnProperty("defaultValue")&&jt(e,t.type,xe(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function vt(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function jt(e,t,n){(t!=="number"||Cn(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var un=Array.isArray;function G(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=At.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Pn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ot={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ur=["Webkit","ms","Moz","O"];Object.keys(ot).forEach(function(e){ur.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ot[t]=ot[e]})});function cr(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ot.hasOwnProperty(e)&&ot[e]?(""+t).trim():t+"px"}function Tn(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=cr(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var $r=A({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function cn(e,t){if(t){if($r[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(m(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(m(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(m(61))}if(t.style!=null&&typeof t.style!="object")throw Error(m(62))}}function Kn(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ct=null;function Qe(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Rn=null,de=null,dn=null;function dr(e){if(e=ao(e)){if(typeof Rn!="function")throw Error(m(280));var t=e.stateNode;t&&(t=Vo(t),Rn(e.stateNode,e.type,t))}}function Fr(e){de?dn?dn.push(e):dn=[e]:de=e}function Ur(){if(de){var e=de,t=dn;if(dn=de=null,dr(e),t)for(e=0;e>>=0,e===0?32:31-(gr(e)/Fl|0)|0}var yr=64,Hr=4194304;function fe(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Nt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,o=e.pingedLanes,u=n&268435455;if(u!==0){var d=u&~s;d!==0?r=fe(d):(o&=u,o!==0&&(r=fe(o)))}else u=n&~s,u!==0?r=fe(u):o!==0&&(r=fe(o));if(r===0)return 0;if(t!==0&&t!==r&&(t&s)===0&&(s=r&-r,o=t&-t,s>=o||s===16&&(o&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function mn(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ht(t),e[t]=n}function pn(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Zt),La=" ",Ia=!1;function Da(e,t){switch(e){case"keyup":return Ee.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Oa(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ks=!1;function hd(e,t){switch(e){case"compositionend":return Oa(t);case"keypress":return t.which!==32?null:(Ia=!0,La);case"textInput":return e=t.data,e===La&&Ia?null:e;default:return null}}function gd(e,t){if(ks)return e==="compositionend"||!Fe&&Da(e,t)?(e=Xt(),qr=vn=Lt=null,ks=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ha(n)}}function Va(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Va(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Wa(){for(var e=window,t=Cn();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Cn(e.document)}return t}function ti(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Cd(e){var t=Wa(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Va(n.ownerDocument.documentElement,n)){if(r!==null&&ti(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!e.extend&&o>r&&(s=r,r=o,o=s),s=ba(n,o);var u=ba(n,r);s&&u&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==u.node||e.focusOffset!==u.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(u.node,u.offset)):(t.setEnd(u.node,u.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,js=null,ni=null,ro=null,ri=!1;function Ga(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ri||js==null||js!==Cn(r)||(r=js,"selectionStart"in r&&ti(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ro&&no(ro,r)||(ro=r,r=Qo(ni,"onSelect"),0Ts||(e.current=hi[Ts],hi[Ts]=null,Ts--)}function Ie(e,t){Ts++,hi[Ts]=e.current,e.current=t}var Er={},xt=Nr(Er),It=Nr(!1),es=Er;function Rs(e,t){var n=e.type.contextTypes;if(!n)return Er;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Dt(e){return e=e.childContextTypes,e!=null}function Wo(){ze(It),ze(xt)}function au(e,t,n){if(xt.current!==Er)throw Error(m(168));Ie(xt,t),Ie(It,n)}function uu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(m(108,ye(e)||"Unknown",s));return A({},n,r)}function Go(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Er,es=xt.current,Ie(xt,e),Ie(It,It.current),!0}function cu(e,t,n){var r=e.stateNode;if(!r)throw Error(m(169));n?(e=uu(e,t,es),r.__reactInternalMemoizedMergedChildContext=e,ze(It),ze(xt),Ie(xt,e)):ze(It),Ie(It,n)}var er=null,Ko=!1,gi=!1;function du(e){er===null?er=[e]:er.push(e)}function zd(e){Ko=!0,du(e)}function Pr(){if(!gi&&er!==null){gi=!0;var e=0,t=_e;try{var n=er;for(_e=1;e>=u,s-=u,tr=1<<32-Ht(t)+s|n<se?(ut=q,q=null):ut=q.sibling;var ke=j(x,q,_[se],T);if(ke===null){q===null&&(q=ut);break}e&&q&&ke.alternate===null&&t(x,q),g=o(ke,g,se),K===null?V=ke:K.sibling=ke,K=ke,q=ut}if(se===_.length)return n(x,q),Ue&&ns(x,se),V;if(q===null){for(;se<_.length;se++)q=P(x,_[se],T),q!==null&&(g=o(q,g,se),K===null?V=q:K.sibling=q,K=q);return Ue&&ns(x,se),V}for(q=r(x,q);se<_.length;se++)ut=D(q,x,se,_[se],T),ut!==null&&(e&&ut.alternate!==null&&q.delete(ut.key===null?se:ut.key),g=o(ut,g,se),K===null?V=ut:K.sibling=ut,K=ut);return e&&q.forEach(function(zr){return t(x,zr)}),Ue&&ns(x,se),V}function H(x,g,_,T){var V=F(_);if(typeof V!="function")throw Error(m(150));if(_=V.call(_),_==null)throw Error(m(151));for(var K=V=null,q=g,se=g=0,ut=null,ke=_.next();q!==null&&!ke.done;se++,ke=_.next()){q.index>se?(ut=q,q=null):ut=q.sibling;var zr=j(x,q,ke.value,T);if(zr===null){q===null&&(q=ut);break}e&&q&&zr.alternate===null&&t(x,q),g=o(zr,g,se),K===null?V=zr:K.sibling=zr,K=zr,q=ut}if(ke.done)return n(x,q),Ue&&ns(x,se),V;if(q===null){for(;!ke.done;se++,ke=_.next())ke=P(x,ke.value,T),ke!==null&&(g=o(ke,g,se),K===null?V=ke:K.sibling=ke,K=ke);return Ue&&ns(x,se),V}for(q=r(x,q);!ke.done;se++,ke=_.next())ke=D(q,x,se,ke.value,T),ke!==null&&(e&&ke.alternate!==null&&q.delete(ke.key===null?se:ke.key),g=o(ke,g,se),K===null?V=ke:K.sibling=ke,K=ke);return e&&q.forEach(function(yf){return t(x,yf)}),Ue&&ns(x,se),V}function Ye(x,g,_,T){if(typeof _=="object"&&_!==null&&_.type===je&&_.key===null&&(_=_.props.children),typeof _=="object"&&_!==null){switch(_.$$typeof){case $:e:{for(var V=_.key,K=g;K!==null;){if(K.key===V){if(V=_.type,V===je){if(K.tag===7){n(x,K.sibling),g=s(K,_.props.children),g.return=x,x=g;break e}}else if(K.elementType===V||typeof V=="object"&&V!==null&&V.$$typeof===ne&&vu(V)===K.type){n(x,K.sibling),g=s(K,_.props),g.ref=uo(x,K,_),g.return=x,x=g;break e}n(x,K);break}else t(x,K);K=K.sibling}_.type===je?(g=cs(_.props.children,x.mode,T,_.key),g.return=x,x=g):(T=wl(_.type,_.key,_.props,null,x.mode,T),T.ref=uo(x,g,_),T.return=x,x=T)}return u(x);case oe:e:{for(K=_.key;g!==null;){if(g.key===K)if(g.tag===4&&g.stateNode.containerInfo===_.containerInfo&&g.stateNode.implementation===_.implementation){n(x,g.sibling),g=s(g,_.children||[]),g.return=x,x=g;break e}else{n(x,g);break}else t(x,g);g=g.sibling}g=ma(_,x.mode,T),g.return=x,x=g}return u(x);case ne:return K=_._init,Ye(x,g,K(_._payload),T)}if(un(_))return U(x,g,_,T);if(F(_))return H(x,g,_,T);Xo(x,_)}return typeof _=="string"&&_!==""||typeof _=="number"?(_=""+_,g!==null&&g.tag===6?(n(x,g.sibling),g=s(g,_),g.return=x,x=g):(n(x,g),g=fa(_,x.mode,T),g.return=x,x=g),u(x)):n(x,g)}return Ye}var Is=yu(!0),xu=yu(!1),Zo=Nr(null),el=null,Ds=null,wi=null;function ki(){wi=Ds=el=null}function ji(e){var t=Zo.current;ze(Zo),e._currentValue=t}function Ci(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Os(e,t){el=e,wi=Ds=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ot=!0),e.firstContext=null)}function nn(e){var t=e._currentValue;if(wi!==e)if(e={context:e,memoizedValue:t,next:null},Ds===null){if(el===null)throw Error(m(308));Ds=e,el.dependencies={lanes:0,firstContext:e}}else Ds=Ds.next=e;return t}var rs=null;function Ni(e){rs===null?rs=[e]:rs.push(e)}function _u(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Ni(t)):(n.next=s.next,s.next=n),t.interleaved=n,rr(e,r)}function rr(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Tr=!1;function Ei(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Su(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function sr(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Rr(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(Se&2)!==0){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,rr(e,n)}return s=r.interleaved,s===null?(t.next=t,Ni(r)):(t.next=s.next,s.next=t),r.interleaved=t,rr(e,n)}function tl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xr(e,n)}}function wu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var u={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?s=o=u:o=o.next=u,n=n.next}while(n!==null);o===null?s=o=t:o=o.next=t}else s=o=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function nl(e,t,n,r){var s=e.updateQueue;Tr=!1;var o=s.firstBaseUpdate,u=s.lastBaseUpdate,d=s.shared.pending;if(d!==null){s.shared.pending=null;var p=d,S=p.next;p.next=null,u===null?o=S:u.next=S,u=p;var N=e.alternate;N!==null&&(N=N.updateQueue,d=N.lastBaseUpdate,d!==u&&(d===null?N.firstBaseUpdate=S:d.next=S,N.lastBaseUpdate=p))}if(o!==null){var P=s.baseState;u=0,N=S=p=null,d=o;do{var j=d.lane,D=d.eventTime;if((r&j)===j){N!==null&&(N=N.next={eventTime:D,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var U=e,H=d;switch(j=t,D=n,H.tag){case 1:if(U=H.payload,typeof U=="function"){P=U.call(D,P,j);break e}P=U;break e;case 3:U.flags=U.flags&-65537|128;case 0:if(U=H.payload,j=typeof U=="function"?U.call(D,P,j):U,j==null)break e;P=A({},P,j);break e;case 2:Tr=!0}}d.callback!==null&&d.lane!==0&&(e.flags|=64,j=s.effects,j===null?s.effects=[d]:j.push(d))}else D={eventTime:D,lane:j,tag:d.tag,payload:d.payload,callback:d.callback,next:null},N===null?(S=N=D,p=P):N=N.next=D,u|=j;if(d=d.next,d===null){if(d=s.shared.pending,d===null)break;j=d,d=j.next,j.next=null,s.lastBaseUpdate=j,s.shared.pending=null}}while(!0);if(N===null&&(p=P),s.baseState=p,s.firstBaseUpdate=S,s.lastBaseUpdate=N,t=s.shared.interleaved,t!==null){s=t;do u|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);ls|=u,e.lanes=u,e.memoizedState=P}}function ku(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Ai.transition;Ai.transition={};try{e(!1),t()}finally{_e=n,Ai.transition=r}}function Qu(){return rn().memoizedState}function Bd(e,t,n){var r=Ir(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Hu(e))bu(t,n);else if(n=_u(e,t,n,r),n!==null){var s=Mt();jn(n,e,r,s),Vu(n,t,r)}}function Qd(e,t,n){var r=Ir(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Hu(e))bu(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var u=t.lastRenderedState,d=o(u,n);if(s.hasEagerState=!0,s.eagerState=d,xn(d,u)){var p=t.interleaved;p===null?(s.next=s,Ni(t)):(s.next=p.next,p.next=s),t.interleaved=s;return}}catch{}n=_u(e,t,s,r),n!==null&&(s=Mt(),jn(n,e,r,s),Vu(n,t,r))}}function Hu(e){var t=e.alternate;return e===be||t!==null&&t===be}function bu(e,t){po=ol=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Vu(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xr(e,n)}}var al={readContext:nn,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},Hd={readContext:nn,useCallback:function(e,t){return Vn().memoizedState=[e,t===void 0?null:t],e},useContext:nn,useEffect:Iu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ll(4194308,4,zu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ll(4194308,4,e,t)},useInsertionEffect:function(e,t){return ll(4,2,e,t)},useMemo:function(e,t){var n=Vn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Vn();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Bd.bind(null,be,e),[r.memoizedState,e]},useRef:function(e){var t=Vn();return e={current:e},t.memoizedState=e},useState:Au,useDebugValue:Fi,useDeferredValue:function(e){return Vn().memoizedState=e},useTransition:function(){var e=Au(!1),t=e[0];return e=Ud.bind(null,e[1]),Vn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=be,s=Vn();if(Ue){if(n===void 0)throw Error(m(407));n=n()}else{if(n=t(),at===null)throw Error(m(349));(os&30)!==0||Eu(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,Iu(Tu.bind(null,r,o,e),[e]),r.flags|=2048,vo(9,Pu.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Vn(),t=at.identifierPrefix;if(Ue){var n=nr,r=tr;n=(r&~(1<<32-Ht(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ho++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=u.createElement(n,{is:r.is}):(e=u.createElement(n),n==="select"&&(u=e,r.multiple?u.multiple=!0:r.size&&(u.size=r.size))):e=u.createElementNS(e,n),e[Hn]=t,e[io]=r,dc(e,t,!1,!1),t.stateNode=e;e:{switch(u=Kn(n,r),n){case"dialog":Oe("cancel",e),Oe("close",e),s=r;break;case"iframe":case"object":case"embed":Oe("load",e),s=r;break;case"video":case"audio":for(s=0;sBs&&(t.flags|=128,r=!0,yo(o,!1),t.lanes=4194304)}else{if(!r)if(e=rl(u),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),yo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!u.alternate&&!Ue)return St(t),null}else 2*De()-o.renderingStartTime>Bs&&n!==1073741824&&(t.flags|=128,r=!0,yo(o,!1),t.lanes=4194304);o.isBackwards?(u.sibling=t.child,t.child=u):(n=o.last,n!==null?n.sibling=u:t.child=u,o.last=u)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=De(),t.sibling=null,n=He.current,Ie(He,r?n&1|2:n&1),t):(St(t),null);case 22:case 23:return ua(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(Kt&1073741824)!==0&&(St(t),t.subtreeFlags&6&&(t.flags|=8192)):St(t),null;case 24:return null;case 25:return null}throw Error(m(156,t.tag))}function Yd(e,t){switch(yi(t),t.tag){case 1:return Dt(t.type)&&Wo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zs(),ze(It),ze(xt),Mi(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Ti(t),null;case 13:if(ze(He),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(m(340));Ls()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ze(He),null;case 4:return zs(),null;case 10:return ji(t.type._context),null;case 22:case 23:return ua(),null;case 24:return null;default:return null}}var fl=!1,wt=!1,Xd=typeof WeakSet=="function"?WeakSet:Set,O=null;function Fs(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ge(e,t,r)}else n.current=null}function Yi(e,t,n){try{n()}catch(r){Ge(e,t,r)}}var pc=!1;function Zd(e,t){if(ui=gs,e=Wa(),ti(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var u=0,d=-1,p=-1,S=0,N=0,P=e,j=null;t:for(;;){for(var D;P!==n||s!==0&&P.nodeType!==3||(d=u+s),P!==o||r!==0&&P.nodeType!==3||(p=u+r),P.nodeType===3&&(u+=P.nodeValue.length),(D=P.firstChild)!==null;)j=P,P=D;for(;;){if(P===e)break t;if(j===n&&++S===s&&(d=u),j===o&&++N===r&&(p=u),(D=P.nextSibling)!==null)break;P=j,j=P.parentNode}P=D}n=d===-1||p===-1?null:{start:d,end:p}}else n=null}n=n||{start:0,end:0}}else n=null;for(ci={focusedElem:e,selectionRange:n},gs=!1,O=t;O!==null;)if(t=O,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,O=e;else for(;O!==null;){t=O;try{var U=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(U!==null){var H=U.memoizedProps,Ye=U.memoizedState,x=t.stateNode,g=x.getSnapshotBeforeUpdate(t.elementType===t.type?H:Sn(t.type,H),Ye);x.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var _=t.stateNode.containerInfo;_.nodeType===1?_.textContent="":_.nodeType===9&&_.documentElement&&_.removeChild(_.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(m(163))}}catch(T){Ge(t,t.return,T)}if(e=t.sibling,e!==null){e.return=t.return,O=e;break}O=t.return}return U=pc,pc=!1,U}function xo(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var o=s.destroy;s.destroy=void 0,o!==void 0&&Yi(t,n,o)}s=s.next}while(s!==r)}}function ml(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Xi(e){var t=e.ref;if(t!==null){var n=e.stateNode;e.tag,e=n,typeof t=="function"?t(e):t.current=e}}function hc(e){var t=e.alternate;t!==null&&(e.alternate=null,hc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Hn],delete t[io],delete t[pi],delete t[Dd],delete t[Od])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function gc(e){return e.tag===5||e.tag===3||e.tag===4}function vc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||gc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Zi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=bo));else if(r!==4&&(e=e.child,e!==null))for(Zi(e,t,n),e=e.sibling;e!==null;)Zi(e,t,n),e=e.sibling}function ea(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ea(e,t,n),e=e.sibling;e!==null;)ea(e,t,n),e=e.sibling}var pt=null,wn=!1;function Mr(e,t,n){for(n=n.child;n!==null;)yc(e,t,n),n=n.sibling}function yc(e,t,n){if(Yt&&typeof Yt.onCommitFiberUnmount=="function")try{Yt.onCommitFiberUnmount(On,n)}catch{}switch(n.tag){case 5:wt||Fs(n,t);case 6:var r=pt,s=wn;pt=null,Mr(e,t,n),pt=r,wn=s,pt!==null&&(wn?(e=pt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):pt.removeChild(n.stateNode));break;case 18:pt!==null&&(wn?(e=pt,n=n.stateNode,e.nodeType===8?mi(e.parentNode,n):e.nodeType===1&&mi(e,n),Gr(e)):mi(pt,n.stateNode));break;case 4:r=pt,s=wn,pt=n.stateNode.containerInfo,wn=!0,Mr(e,t,n),pt=r,wn=s;break;case 0:case 11:case 14:case 15:if(!wt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,u=o.destroy;o=o.tag,u!==void 0&&((o&2)!==0||(o&4)!==0)&&Yi(n,t,u),s=s.next}while(s!==r)}Mr(e,t,n);break;case 1:if(!wt&&(Fs(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(d){Ge(n,t,d)}Mr(e,t,n);break;case 21:Mr(e,t,n);break;case 22:n.mode&1?(wt=(r=wt)||n.memoizedState!==null,Mr(e,t,n),wt=r):Mr(e,t,n);break;default:Mr(e,t,n)}}function xc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Xd),t.forEach(function(r){var s=uf.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function kn(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=u),r&=~o}if(r=s,r=De()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*tf(r/1960))-r,10e?16:e,Lr===null)var r=!1;else{if(e=Lr,Lr=null,yl=0,(Se&6)!==0)throw Error(m(331));var s=Se;for(Se|=4,O=e.current;O!==null;){var o=O,u=o.child;if((O.flags&16)!==0){var d=o.deletions;if(d!==null){for(var p=0;pDe()-ra?as(e,0):na|=n),$t(e,t)}function Ac(e,t){t===0&&((e.mode&1)===0?t=1:(t=Hr,Hr<<=1,(Hr&130023424)===0&&(Hr=4194304)));var n=Mt();e=rr(e,t),e!==null&&(mn(e,t,n),$t(e,n))}function af(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ac(e,n)}function uf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(m(314))}r!==null&&r.delete(t),Ac(e,n)}var Lc;Lc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||It.current)Ot=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return Ot=!1,qd(e,t,n);Ot=(e.flags&131072)!==0}else Ot=!1,Ue&&(t.flags&1048576)!==0&&fu(t,Jo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;dl(e,t),e=t.pendingProps;var s=Rs(t,xt.current);Os(t,n),s=Ii(null,t,r,e,s,n);var o=Di();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Dt(r)?(o=!0,Go(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Ei(t),s.updater=ul,t.stateNode=s,s._reactInternals=t,Bi(t,r,e,n),t=Vi(null,t,r,!0,o,n)):(t.tag=0,Ue&&o&&vi(t),Rt(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(dl(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=df(r),e=Sn(r,e),s){case 0:t=bi(null,t,r,e,n);break e;case 1:t=oc(null,t,r,e,n);break e;case 11:t=ec(null,t,r,e,n);break e;case 14:t=tc(null,t,r,Sn(r.type,e),n);break e}throw Error(m(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Sn(r,s),bi(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Sn(r,s),oc(e,t,r,s,n);case 3:e:{if(lc(t),e===null)throw Error(m(387));r=t.pendingProps,o=t.memoizedState,s=o.element,Su(e,t),nl(t,r,null,n);var u=t.memoizedState;if(r=u.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:u.cache,pendingSuspenseBoundaries:u.pendingSuspenseBoundaries,transitions:u.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=$s(Error(m(423)),t),t=ic(e,t,r,n,s);break e}else if(r!==s){s=$s(Error(m(424)),t),t=ic(e,t,r,n,s);break e}else for(Gt=Cr(t.stateNode.containerInfo.firstChild),Wt=t,Ue=!0,_n=null,n=xu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ls(),r===s){t=or(e,t,n);break e}Rt(e,t,r,n)}t=t.child}return t;case 5:return ju(t),e===null&&_i(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,u=s.children,di(r,s)?u=null:o!==null&&di(r,o)&&(t.flags|=32),sc(e,t),Rt(e,t,u,n),t.child;case 6:return e===null&&_i(t),null;case 13:return ac(e,t,n);case 4:return Pi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Is(t,null,r,n):Rt(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Sn(r,s),ec(e,t,r,s,n);case 7:return Rt(e,t,t.pendingProps,n),t.child;case 8:return Rt(e,t,t.pendingProps.children,n),t.child;case 12:return Rt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,o=t.memoizedProps,u=s.value,Ie(Zo,r._currentValue),r._currentValue=u,o!==null)if(xn(o.value,u)){if(o.children===s.children&&!It.current){t=or(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var d=o.dependencies;if(d!==null){u=o.child;for(var p=d.firstContext;p!==null;){if(p.context===r){if(o.tag===1){p=sr(-1,n&-n),p.tag=2;var S=o.updateQueue;if(S!==null){S=S.shared;var N=S.pending;N===null?p.next=p:(p.next=N.next,N.next=p),S.pending=p}}o.lanes|=n,p=o.alternate,p!==null&&(p.lanes|=n),Ci(o.return,n,t),d.lanes|=n;break}p=p.next}}else if(o.tag===10)u=o.type===t.type?null:o.child;else if(o.tag===18){if(u=o.return,u===null)throw Error(m(341));u.lanes|=n,d=u.alternate,d!==null&&(d.lanes|=n),Ci(u,n,t),u=o.sibling}else u=o.child;if(u!==null)u.return=o;else for(u=o;u!==null;){if(u===t){u=null;break}if(o=u.sibling,o!==null){o.return=u.return,u=o;break}u=u.return}o=u}Rt(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Os(t,n),s=nn(s),r=r(s),t.flags|=1,Rt(e,t,r,n),t.child;case 14:return r=t.type,s=Sn(r,t.pendingProps),s=Sn(r.type,s),tc(e,t,r,s,n);case 15:return nc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Sn(r,s),dl(e,t),t.tag=1,Dt(r)?(e=!0,Go(t)):e=!1,Os(t,n),Gu(t,r,s),Bi(t,r,s,n),Vi(null,t,r,!0,e,n);case 19:return cc(e,t,n);case 22:return rc(e,t,n)}throw Error(m(156,t.tag))};function Ic(e,t){return pr(e,t)}function cf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function on(e,t,n,r){return new cf(e,t,n,r)}function da(e){return e=e.prototype,!(!e||!e.isReactComponent)}function df(e){if(typeof e=="function")return da(e)?1:0;if(e!=null){if(e=e.$$typeof,e===dt)return 11;if(e===Ke)return 14}return 2}function Or(e,t){var n=e.alternate;return n===null?(n=on(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function wl(e,t,n,r,s,o){var u=2;if(r=e,typeof e=="function")da(e)&&(u=1);else if(typeof e=="string")u=5;else e:switch(e){case je:return cs(n.children,s,o,t);case Be:u=8,s|=8;break;case gt:return e=on(12,n,t,s|2),e.elementType=gt,e.lanes=o,e;case B:return e=on(13,n,t,s),e.elementType=B,e.lanes=o,e;case Le:return e=on(19,n,t,s),e.elementType=Le,e.lanes=o,e;case Z:return kl(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ct:u=10;break e;case Ut:u=9;break e;case dt:u=11;break e;case Ke:u=14;break e;case ne:u=16,r=null;break e}throw Error(m(130,e==null?e:typeof e,""))}return t=on(u,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function cs(e,t,n,r){return e=on(7,e,r,t),e.lanes=n,e}function kl(e,t,n,r){return e=on(22,e,r,t),e.elementType=Z,e.lanes=n,e.stateNode={isHidden:!1},e}function fa(e,t,n){return e=on(6,e,null,t),e.lanes=n,e}function ma(e,t,n){return t=on(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ff(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pt(0),this.expirationTimes=Pt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pt(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function pa(e,t,n,r,s,o,u,d,p){return e=new ff(e,t,n,d,p),t===1?(t=1,o===!0&&(t|=8)):t=0,o=on(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ei(o),e}function mf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(h){console.error(h)}}return i(),_a.exports=Cf(),_a.exports}var Kc;function Ef(){if(Kc)return Rl;Kc=1;var i=Nf();return Rl.createRoot=i.createRoot,Rl.hydrateRoot=i.hydrateRoot,Rl}var Pf=Ef();const Tf=cd(Pf),Rf="/api";async function ve(i,h){const m=await fetch(`${Rf}${i}`,{...h,headers:{"Content-Type":"application/json",...h?.headers??{}}}),R=await m.json();if(!m.ok){const E=R.error?.message??"Ошибка запроса";throw new Error(E)}return R}const Re={async loadSharedConnectionConfig(){return ve("/llm/shared-connection")},async saveSharedConnectionConfig(i){return ve("/llm/shared-connection",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,model:i.model,baseUrl:i.baseUrl,temperature:i.temperature,maxOutputTokens:i.maxOutputTokens})})},async listModels(i){return ve("/llm/models",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,apiKey:i.apiKey,model:i.model,baseUrl:i.baseUrl})})},async testConnection(i){return ve("/llm/test-connection",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,apiKey:i.apiKey,model:i.model,baseUrl:i.baseUrl})})},async normalize(i){return ve("/normalize",{method:"POST",body:JSON.stringify({llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples,userQuestion:i.query.userQuestion,context:{period_hint:i.query.periodHint??"",business_context:i.query.businessContext??"",expected_route:i.query.expectedRoute??""},saveAsTestCase:!!i.saveAsTestCase,useMock:!!i.useMock})})},async loadHistory(){return ve("/history")},async loadTrace(i){return ve(`/history/${i}`)},async loadPresets(){return ve("/presets")},async savePreset(i){return ve("/presets/save",{method:"POST",body:JSON.stringify(i)})},async runEval(i){return ve("/eval/run",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples},caseIds:i.caseIds,useMock:!!i.useMock,mode:i.mode??"standard",caseSetFile:i.caseSetFile,rawQuestions:i.rawQuestions,eval_target:i.evalTarget,compare_with_report_file:i.compareWithReportFile,analysis_date:i.analysisDate})})},async startEvalRunAsync(i){return ve("/eval/run-async/start",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples},caseIds:i.caseIds,useMock:!!i.useMock,mode:i.mode??"standard",caseSetFile:i.caseSetFile,rawQuestions:i.rawQuestions,eval_target:i.evalTarget,compare_with_report_file:i.compareWithReportFile,questions:i.questions,scenarioQuestions:i.scenarioQuestions,scenarioTitle:i.scenarioTitle,analysis_date:i.analysisDate})})},async loadEvalRunAsyncStatus(i){return ve(`/eval/run-async/${encodeURIComponent(i)}`)},async startRun(){return ve("/accounting-agent/v1/runs/start",{method:"POST",body:JSON.stringify({initiator:"ndc_operator",source:"gui"})})},async finishRun(i){return ve("/accounting-agent/v1/runs/finish",{method:"POST",body:JSON.stringify({runId:i,status:"DONE",source:"gui",reason:"Остановлено оператором из GUI"})})},async listRuns(){return ve("/accounting-agent/v1/runs")},async listResults(){return ve("/accounting-agent/v1/results")},async runTrace(i){return ve(`/accounting-agent/v1/trace/run/${i}`)},async sendAssistantMessage(i){return ve("/assistant/message",{method:"POST",body:JSON.stringify({session_id:i.sessionId??"",mode:"assistant",message:i.userMessage,user_message:i.userMessage,llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion??"address_query_runtime_v1",systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples,context:{period_hint:i.context?.periodHint??"",business_context:i.context?.businessContext??""},useMock:!!i.useMock})})},async loadAssistantSession(i){return ve(`/assistant/session/${i}`)},async saveAutoRunAssistantSession(i){return ve("/autoruns/autogen/save-assistant-session",{method:"POST",body:JSON.stringify(i)})},async loadAssistantAnnotations(i){const h=new URLSearchParams;i?.session_id&&h.set("session_id",i.session_id),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const m=h.toString();return ve(`/assistant/annotations${m?`?${m}`:""}`)},async saveAssistantAnnotation(i){return ve("/assistant/annotations",{method:"POST",body:JSON.stringify(i)})},async loadAutoRunsHistory(i){const h=new URLSearchParams;i?.from&&h.set("from",i.from),i?.to&&h.set("to",i.to),i?.target&&h.set("target",i.target),i?.mode&&h.set("mode",i.mode),i?.use_mock&&h.set("use_mock",i.use_mock),i?.prompt_contains&&h.set("prompt_contains",i.prompt_contains),typeof i?.limit=="number"&&h.set("limit",String(i.limit)),typeof i?.scan_limit=="number"&&h.set("scan_limit",String(i.scan_limit));const m=h.toString();return ve(`/autoruns/history${m?`?${m}`:""}`)},async loadAutoRunDetail(i){return ve(`/autoruns/history/${encodeURIComponent(i)}`)},async loadAutoRunCaseDialog(i,h){return ve(`/autoruns/history/${encodeURIComponent(i)}/case/${encodeURIComponent(h)}/dialog`)},async loadAutoRunAnnotations(i){const h=new URLSearchParams;i?.run_id&&h.set("run_id",i.run_id),i?.case_id&&h.set("case_id",i.case_id),typeof i?.min_rating=="number"&&h.set("min_rating",String(i.min_rating)),i?.manual_case_decision&&h.set("manual_case_decision",i.manual_case_decision),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const m=h.toString();return ve(`/autoruns/annotations${m?`?${m}`:""}`)},async saveAutoRunAnnotation(i){return ve("/autoruns/annotations",{method:"POST",body:JSON.stringify(i)})},async updateAutoRunAnnotation(i){return ve(`/autoruns/annotations/${encodeURIComponent(i.annotation_id)}`,{method:"PATCH",body:JSON.stringify({resolved:i.resolved,resolved_by:i.resolved_by})})},async loadAutoRunPostAnalysis(i){const h=new URLSearchParams;i?.run_id&&h.set("run_id",i.run_id),typeof i?.limit_per_queue=="number"&&h.set("limit_per_queue",String(i.limit_per_queue)),typeof i?.annotation_limit=="number"&&h.set("annotation_limit",String(i.annotation_limit)),typeof i?.scan_limit=="number"&&h.set("scan_limit",String(i.scan_limit)),i?.from&&h.set("from",i.from),i?.to&&h.set("to",i.to),i?.target&&h.set("target",i.target),i?.mode&&h.set("mode",i.mode),i?.use_mock&&h.set("use_mock",i.use_mock),i?.prompt_contains&&h.set("prompt_contains",i.prompt_contains);const m=h.toString();return ve(`/autoruns/post-analysis${m?`?${m}`:""}`)},async loadAutoRunAutogenHistory(i){const h=new URLSearchParams;i?.mode&&h.set("mode",i.mode),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const m=h.toString();return ve(`/autoruns/autogen/history${m?`?${m}`:""}`)},async loadAutoRunAutogenPersonalityCatalog(){return ve("/autoruns/autogen/personality-catalog")},async updateAutoRunAutogenQuestions(i){return ve(`/autoruns/autogen/history/${encodeURIComponent(i.generation_id)}/questions`,{method:"PATCH",body:JSON.stringify({questions:i.questions})})},async deleteAutoRunAutogenHistoryRecord(i){return ve(`/autoruns/autogen/history/${encodeURIComponent(i)}`,{method:"DELETE"})},async generateAutoRunQuestions(i){return ve("/autoruns/autogen/generate",{method:"POST",body:JSON.stringify(i)})}},Mf=/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json|debug_payload|technical_breakdown)\b/i,Af=[/\b(?:debug_payload_json|technical_breakdown_json)\b/i,/\b(?:route_summary|semantic_profile|domain_scope|relation_patterns|account_scope)\b/i,/\b(?:coverage_report|retrieval_status|problem_unit_state|candidate_evidence)\b/i,/\b(?:graph_domain_scope|graph_runtime|selection_reason|why_included)\b/i];function Lf(i){try{return JSON.stringify(i,null,2)}catch{return String(i)}}function If(i){const h=String(i??""),m=h.match(Mf);return(m?h.slice(0,m.index):h).replace(/###\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)[\s\S]*?(?:```[\s\S]*?```|$)/gi,"").replace(/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)\b[\s\S]*$/gi,"").split(/\r?\n/g).map(Q=>Q.trimEnd()).filter(Q=>Q.trim().length>0).filter(Q=>!Af.some(le=>le.test(Q))).join(` +`).trim()}function Df(i,h,m="default"){const R=m==="technical",E=[];E.push("# Assistant conversation export"),E.push(`session_id: ${i||"n/a"}`),E.push(`export_mode: ${m}`),E.push(`exported_at: ${new Date().toISOString()}`),E.push("");for(let I=0;I{E.length!==0&&(R.push(E.join(` +`)),E=[])};for(const Q of m){const le=Q.trimEnd(),te=le.trim();if(!te){I();continue}const z=/^Блок\s+\d+\./i.test(te),Y=/^\d+\.\s/.test(te);(z||Y)&&E.length>0&&I(),E.push(le)}return I(),R.length>0?R:[i]}function Qf(i,h){const m=[],R=/\*\*(.+?)\*\*/g;let E=0,I=0,Q;for(;(Q=R.exec(i))!==null;)Q.index>E&&(m.push(l.jsx("span",{children:i.slice(E,Q.index)},`${h}-t-${I}`)),I+=1),m.push(l.jsx("strong",{children:Q[1]},`${h}-b-${I}`)),I+=1,E=R.lastIndex;return E0?m:[l.jsx("span",{children:i},`${h}-raw`)]}function Hf(i){const h=i.trimStart();return/^Блок\s+\d+\./i.test(h)?"assistant-msg-line heading":/^\d+\.\s/.test(h)?"assistant-msg-line numbered":/^-\s/.test(h)?"assistant-msg-line bullet":"assistant-msg-line"}function bf(i,h=40){const m=i.replace(/\s+/g," ").trim();if(m.length<=h)return m;const R=m.split(" ").slice(0,3).join(" ").trim();return R.length>=10&&R.length<=h?`${R}…`:`${m.slice(0,h-1).trimEnd()}…`}function fd(i){return i.replace(/\*\*(.+?)\*\*/g,"$1").replace(/^\d+\.\s*/,"").trim()}function Vf(i){const h=i.replace(/\r\n?/g,` +`).split(` +`).map(E=>E.trim()).find(Boolean),m=fd(h??"");return(m.split("|")[0]?.trim()??m).replace(/\s+/g," ").trim()}function Wf(i){const h=i.replace(/\r\n?/g,` +`).split(` +`).map(R=>R.trim()).find(Boolean);return!h||!/^\d+\.\s/.test(h)?!1:fd(h).includes("|")}function Gf(i,h){const m=h.replace(/\r\n?/g,` +`).replace(/\*\*(.+?)\*\*/g,"$1").split(` +`).map((E,I)=>{const Q=E.trim();return I===0?Q.replace(/^\d+\.\s*/,""):Q}).filter(Boolean).join(" ").replace(/\s+/g," ").trim();if(!m)return null;const R=Vf(h)||m;return{message_id:i.message_id,source_text:m,anchor_text:R,preview_text:bf(R)}}function Kf(i,h,m,R){return Bf(i.text).map((I,Q)=>{const le=I.split(` +`),te=i.role==="assistant"&&Wf(I),z=te?Gf(i,I):null,Y=!!z&&h?.message_id===z?.message_id&&h?.source_text===z?.source_text,X=le.map((ee,Me)=>l.jsx("p",{className:Hf(ee),children:Qf(ee,`line-${Q}-${Me}`)},`line-${Q}-${Me}`));return!te||!z?l.jsx("div",{className:"assistant-msg-block",children:X},`block-${Q}`):l.jsx("div",{className:Y?"assistant-msg-block selectable active":"assistant-msg-block selectable",role:"button",tabIndex:0,onClick:()=>{if(Y){R();return}m(z)},onKeyDown:ee=>{if(!(ee.key!=="Enter"&&ee.key!==" ")){if(ee.preventDefault(),Y){R();return}m(z)}},children:X},`block-${Q}`)})}function qf({sessionId:i,conversation:h,inputValue:m,onInputChange:R,selectedContextChip:E,onSelectContextChip:I,onClearContextChip:Q,useMock:le,onUseMockChange:te,onSend:z,onClear:Y,onSaveSession:X,busy:ee,saveBusy:Me=!1,saveDisabled:ue=!1,statusText:ce,errorMessage:pe,showSaveAction:Ve=!1,showCommentAction:Xe=!1,onCommentAssistantMessage:We,isAssistantMessageCommented:Ae,canCommentAssistantMessage:$}){const oe=v.useRef(null),je=v.useRef(!0),Be=v.useRef(null),[gt,ct]=v.useState("idle"),[Ut,dt]=v.useState("чат");function B(ne=!1){oe.current&&(ne&&(je.current=!0),oe.current.scrollTop=oe.current.scrollHeight)}v.useEffect(()=>{je.current&&B()},[h]),v.useEffect(()=>()=>{Be.current!==null&&window.clearTimeout(Be.current)},[]);async function Le(ne){if(h.length===0)return;const Z=Df(i,h,ne),M=await $f(Z);dt(ne==="technical"?"тех":"чат"),ct(M?"success":"error"),Be.current!==null&&window.clearTimeout(Be.current),Be.current=window.setTimeout(()=>{ct("idle")},2200)}function Ke(){if(!oe.current)return;const ne=oe.current,Z=ne.scrollHeight-ne.scrollTop-ne.clientHeight;je.current=Z<16}return l.jsx($l,{className:"assistant-panel-frame",title:"Режим ассистента",children:l.jsxs("div",{className:"assistant-live-shell",children:[l.jsxs("div",{className:"assistant-toolbar",children:[l.jsxs("div",{className:"assistant-toolbar-actions",children:[l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{Le("default")},disabled:h.length===0,title:"Экспорт только user-facing чата",children:"Скопировать чат"}),l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{Le("technical")},disabled:h.length===0,title:"Технический экспорт с debug payload",children:"Скопировать техчат"}),Ve?l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>X?.(),disabled:Me||ue,children:Me?"Сохраняю...":"Сохранить"}):null,l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>Y(),disabled:ee&&h.length===0,children:"Сбросить сессию"})]}),l.jsxs("div",{className:"assistant-toolbar-meta",children:[i?l.jsx("span",{className:"status-chip",children:`session: ${i}`}):null,l.jsxs("div",{className:"assistant-toolbar-meta-right",children:[ce?l.jsx("span",{className:"assistant-live-status",children:ce}):null,gt==="success"?l.jsxs("span",{className:"assistant-copy-feedback success",children:["Скопировано (",Ut,")"]}):null,gt==="error"?l.jsx("span",{className:"assistant-copy-feedback error",children:"Ошибка копирования"}):null]})]}),pe?l.jsx("p",{className:"error-text assistant-toolbar-error",children:pe}):null]}),l.jsx("div",{ref:oe,className:"assistant-chat-list",onScroll:Ke,children:h.map((ne,Z)=>{const M=ne.role==="assistant"&&Xe&&typeof We=="function"&&(typeof $=="function"?$(ne,Z):!0),F=ne.role==="assistant"&&typeof Ae=="function"?Ae(ne,Z):!1;return l.jsxs("article",{className:`assistant-msg ${ne.role}`,children:[l.jsxs("header",{className:"assistant-msg-head",children:[l.jsxs("div",{className:"assistant-msg-head-main",children:[l.jsx("strong",{children:Of(ne.role)}),l.jsx("span",{children:zf(ne.created_at)})]}),ne.role==="assistant"&&Xe?l.jsx("div",{className:"assistant-msg-head-actions",children:l.jsx("button",{type:"button",className:F?"autoruns-comment-icon assistant-comment-btn commented":"autoruns-comment-icon assistant-comment-btn",onClick:()=>We?.(ne,Z),disabled:!M,title:M?"Комментировать ответ ассистента":"Комментарий недоступен для этого сообщения","aria-label":M?"Комментировать ответ ассистента":"Комментарий недоступен для этого сообщения",children:l.jsx(Ff,{commented:F})})}):null]}),l.jsx("div",{className:"assistant-msg-body",children:Kf(ne,E,I,Q)}),ne.role==="assistant"&&ne.debug?l.jsxs("details",{className:"assistant-debug",children:[l.jsx("summary",{children:"Показать технический разбор"}),l.jsx(dd,{value:ne.debug})]}):null]},ne.message_id)})}),l.jsxs("div",{className:"assistant-compose",children:[E?l.jsxs("div",{className:"assistant-compose-context",children:[l.jsx("span",{className:"assistant-compose-context-label",children:"Выбранный объект"}),l.jsxs("div",{className:"assistant-compose-context-pill",title:E.source_text,children:[l.jsx("span",{className:"assistant-compose-context-pill-text",children:E.preview_text}),l.jsx("button",{type:"button",className:"assistant-compose-context-clear",onClick:Q,"aria-label":"Убрать выбранный объект",title:"Убрать выбранный объект",children:"×"})]})]}):null,l.jsxs("label",{className:"full-width",children:["Сообщение",l.jsx("textarea",{className:"assistant-input-textarea",value:m,onChange:ne=>R(ne.target.value),rows:4,placeholder:E?"Продолжите вопрос по выбранному объекту...":"Введите вопрос к данным компании..."})]}),l.jsxs("div",{className:"button-row assistant-send-row",children:[l.jsxs("label",{className:"checkbox-row",children:[l.jsx("input",{type:"checkbox",checked:le,onChange:ne=>te(ne.target.checked)}),"Mock-режим"]}),l.jsx("button",{type:"button",className:"assistant-send-btn",onClick:()=>{B(!0),z()},disabled:ee||!m.trim(),children:ee?"Выполняю...":"Отправить"})]})]})]})})}const Ml="http://127.0.0.1:1234/v1",qc="https://api.openai.com/v1",Ol="qwen2.5-14b-instruct-1m",Aa="unsloth/qwen3-30b-a3b-instruct-2507",Jf=[{value:Ol,label:"Qwen2.5 14B Instruct 1M"},{value:Aa,label:"Qwen3 30B A3B Instruct 2507"}];function Yf(i){return i.llmProvider!=="local"?"openai":i.model===Aa?"local_qwen3":i.model===Ol?"local_qwen25":"local_custom"}function Xf(i,h){const m=new Map;if(h)for(const R of Jf)m.set(R.value,R);for(const R of i)m.has(R)||m.set(R,{value:R,label:R});return Array.from(m.values())}function Zf({value:i,modelOptions:h,modelsBusy:m,onChange:R,onReloadModels:E,onTestConnection:I,onSaveLocalConfig:Q,lastStatus:le,busy:te,embedded:z=!1}){const Y=i.llmProvider==="local",X=Yf(i),ee=Xf(h,Y),Me=ee.some($=>$.value===i.model),[ue,ce]=v.useState(String(i.temperature)),[pe,Ve]=v.useState(String(i.maxOutputTokens));v.useEffect(()=>{ce(String(i.temperature))},[i.temperature]),v.useEffect(()=>{Ve(String(i.maxOutputTokens))},[i.maxOutputTokens]);const Xe=$=>{const oe=$.replace(",",".").trim();if(!oe){ce(String(i.temperature));return}const je=Number(oe);if(!Number.isFinite(je)){ce(String(i.temperature));return}R({...i,temperature:je}),ce(String(je))},We=$=>{const oe=$.trim();if(!oe){Ve(String(i.maxOutputTokens));return}const je=Number.parseInt(oe,10);if(!Number.isFinite(je)||je<=0){Ve(String(i.maxOutputTokens));return}R({...i,maxOutputTokens:je}),Ve(String(je))},Ae=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"grid-two",children:[l.jsxs("label",{children:["Provider",l.jsxs("select",{value:X,onChange:$=>{const oe=$.target.value;if(oe==="openai"){R({...i,llmProvider:"openai",baseUrl:qc});return}if(oe==="local_qwen25"){R({...i,llmProvider:"local",model:Ol,baseUrl:Ml});return}if(oe==="local_qwen3"){R({...i,llmProvider:"local",model:Aa,baseUrl:Ml});return}R({...i,llmProvider:"local",model:i.llmProvider==="local"?i.model:Ol,baseUrl:Ml})},children:[l.jsx("option",{value:"openai",children:"OpenAI (token)"}),l.jsx("option",{value:"local_qwen25",children:"Qwen2.5 14B Instruct 1M (Local LM Studio)"}),l.jsx("option",{value:"local_qwen3",children:"Qwen3 30B A3B Instruct 2507 (Local LM Studio)"}),l.jsx("option",{value:"local_custom",children:"Local custom (LM Studio / OpenAI-compatible)"})]})]}),l.jsxs("label",{children:["Model",l.jsxs("select",{value:Me?i.model:"__manual__",onChange:$=>{const oe=$.target.value;oe!=="__manual__"&&R({...i,model:oe})},children:[l.jsx("option",{value:"__manual__",children:"Manual input"}),ee.map($=>l.jsx("option",{value:$.value,children:$.label},$.value))]})]}),l.jsxs("label",{children:["Model ID (manual / current)",l.jsx("input",{value:i.model,onChange:$=>R({...i,model:$.target.value}),placeholder:"qwen2.5-14b-instruct-1m or unsloth/qwen3-30b-a3b-instruct-2507"})]}),Y?null:l.jsxs("label",{className:"full-width",children:["OpenAI API Key",l.jsx("input",{type:"password",value:i.apiKey,onChange:$=>R({...i,apiKey:$.target.value}),placeholder:"sk-..."})]}),l.jsxs("label",{className:Y?"full-width":void 0,children:[Y?"Local server base URL":"Base URL",l.jsx("input",{value:i.baseUrl,onChange:$=>R({...i,baseUrl:$.target.value}),placeholder:Y?Ml:qc})]}),l.jsxs("label",{children:["Temperature",l.jsx("input",{type:"number",step:"0.1",value:ue,onChange:$=>ce($.target.value),onBlur:$=>Xe($.target.value),onKeyDown:$=>{$.key==="Enter"&&Xe($.target.value)}})]}),l.jsxs("label",{children:["Max output tokens",l.jsx("input",{type:"number",value:pe,onChange:$=>Ve($.target.value),onBlur:$=>We($.target.value),onKeyDown:$=>{$.key==="Enter"&&We($.target.value)}})]})]}),l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>Q(),children:"Save local config"}),l.jsx("button",{type:"button",onClick:()=>E(),disabled:te||m,children:m?"Loading models...":"Load model list"}),l.jsx("button",{type:"button",onClick:()=>I(),disabled:te,children:te?"Checking...":"Test connection"})]})]});return z?l.jsxs("section",{className:"embedded-panel-section",children:[l.jsxs("div",{className:"embedded-panel-section-header",children:[l.jsxs("div",{children:[l.jsx("h4",{children:"LLM Connector"}),l.jsx("p",{children:"Switch between OpenAI cloud and local OpenAI-compatible server."})]}),l.jsx("span",{className:"status-chip",children:le||"Status: not checked"})]}),Ae]}):l.jsx($l,{title:"LLM Connector",subtitle:"Switch between OpenAI cloud and local OpenAI-compatible server.",actions:l.jsx("span",{className:"status-chip",children:le||"Status: not checked"}),children:Ae})}function em({value:i,onChange:h,presets:m,selectedPresetId:R,onSelectPreset:E,onLoadPreset:I,onSavePreset:Q,onResetDefaults:le,onDiffPrevious:te,presetName:z,onPresetNameChange:Y,diffSummary:X,embedded:ee=!1}){const Me=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"prompt-manager-grid",children:[l.jsxs("label",{children:["Системный prompt",l.jsx("textarea",{value:i.systemPrompt,onChange:ue=>h({...i,systemPrompt:ue.target.value}),rows:6})]}),l.jsxs("label",{children:["Developer / Instruction prompt",l.jsx("textarea",{value:i.developerPrompt,onChange:ue=>h({...i,developerPrompt:ue.target.value}),rows:6})]}),l.jsxs("label",{children:["Domain prompt",l.jsx("textarea",{value:i.domainPrompt,onChange:ue=>h({...i,domainPrompt:ue.target.value}),rows:6})]}),l.jsxs("label",{children:["Schema notes",l.jsx("textarea",{value:i.schemaNotes,onChange:ue=>h({...i,schemaNotes:ue.target.value}),rows:6})]}),l.jsxs("label",{className:"full-width",children:["Few-shot examples",l.jsx("textarea",{value:i.fewShotExamples,onChange:ue=>h({...i,fewShotExamples:ue.target.value}),rows:8})]})]}),l.jsxs("div",{className:"button-row",children:[l.jsxs("select",{value:R,onChange:ue=>E(ue.target.value),children:[l.jsx("option",{value:"",children:"Выберите preset..."}),m.map(ue=>l.jsx("option",{value:ue.id,children:ue.name},ue.id))]}),l.jsx("button",{type:"button",onClick:()=>I(),children:"Загрузить preset"}),l.jsx("input",{value:z,onChange:ue=>Y(ue.target.value),placeholder:"Имя для сохранения"}),l.jsx("button",{type:"button",onClick:()=>Q(),children:"Сохранить preset"}),l.jsx("button",{type:"button",onClick:()=>te(),children:"Diff с предыдущим"}),l.jsx("button",{type:"button",onClick:()=>le(),children:"Сбросить к default"})]}),X?l.jsx("p",{className:"diff-summary",children:X}):null]});return ee?l.jsxs("section",{className:"embedded-panel-section",children:[l.jsx("div",{className:"embedded-panel-section-header",children:l.jsxs("div",{children:[l.jsx("h4",{children:"Prompt Manager"}),l.jsx("p",{children:"Системный, developer и domain уровни управляются отдельно."})]})}),Me]}):l.jsx($l,{title:"Prompt Manager",subtitle:"Системный, developer и domain уровни управляются отдельно.",children:Me})}const ka={fromLocal:"",toLocal:"",target:"all",mode:"all",useMock:"any",promptContains:"",limit:120},Al="needs_dialog_policy_fix",kt="__all__",zl="__live__:",Jc="ndc_autoruns_ui_config_v1",Yc="ndc-autoruns-save",ja=["Анализ запроса","Получение данных","Подготовка ответа"];function tm(i,h){const m=i.trim();if(!m)return"";if(!h)return m;const R=m.toLowerCase(),E=h.anchor_text.trim(),I=E.toLowerCase();return I&&R.includes(I)?m:`По выбранному объекту "${E}": ${m}`}const Ra=[{id:"general",label:"Общий контур",domain:"",defaultPrompt:"Генерируй реалистичные живые вопросы бухгалтера по 1С. Добавляй разговорные формулировки и опечатки, но сохраняй бизнес-смысл."}];function nm(i=Ra){return i.reduce((h,m)=>(h[m.id]=m.defaultPrompt,h),{})}const Xc={mode:"codex_creative",count:24,personalityId:"general",personalityPrompts:nm(),persistToEvalCases:!0,generatedBy:"manual_reviewer"};function Ca(i){const h=String(i??"").trim();return/^\d{4}-\d{2}-\d{2}$/.test(h)?h:""}function Zc(i){const h=typeof i=="number"&&Number.isFinite(i)?Math.trunc(i):160;return Math.max(110,Math.min(520,h))}function rm(i){const h=i.getFullYear(),m=String(i.getMonth()+1).padStart(2,"0"),R=String(i.getDate()).padStart(2,"0"),E=String(i.getHours()).padStart(2,"0"),I=String(i.getMinutes()).padStart(2,"0");return`${h}-${m}-${R}T${E}:${I}`}function ed(){const i=new Date;return i.setDate(i.getDate()-14),rm(i)}function Ll(i){if(!i.trim())return;const h=Date.parse(i);if(Number.isFinite(h))return new Date(h).toISOString()}function ln(i){if(!i)return"нет данных";const h=Date.parse(i);return Number.isFinite(h)?new Date(h).toLocaleString("ru-RU"):i}function Na(i){return i==="saved_user_sessions"?"Пользовательские сессии":i}function md(i){return i?i.context?.agent_run===!0||i.context?.saved_case_set_kind==="agent_semantic_scenario"?!0:typeof i.title=="string"&&i.title.trim().toUpperCase().startsWith("AGENT"):!1}function td(i){const h=i.title??ln(i.created_at);return md(i)&&!h.trim().toUpperCase().startsWith("AGENT")?`AGENT | ${h}`:h}function sm(i){const h=i[i.length-1];return`Ручная сессия ${ln(h?.created_at??new Date().toISOString())}`}function om(i,h){return h<=0?0:Math.max(0,Math.min(100,Number((i/h*100).toFixed(1))))}function Il(i){return typeof i!="number"?"нет данных":`${i.toFixed(1)}%`}function lm(i){return i==="assistant_stage1"?"assistant/s1":i==="assistant_stage2"?"assistant/s2":i==="assistant_p0"?"assistant/p0":i}function nd(i){return i==="up"?"Рост":i==="down"?"Регресс":"Без изменений"}function Ea(i){const h=Math.max(1,Math.min(5,Math.round(i)));return`${"●".repeat(h)}${"○".repeat(5-h)}`}function rd(i){return i.length===0?l.jsx("p",{className:"muted",children:"Покрытие доменов пока не сформировано."}):l.jsx("div",{className:"autoruns-coverage-list",children:i.map(h=>{const m=om(h.closed_cases,h.total_cases);return l.jsxs("div",{className:"autoruns-coverage-item",children:[l.jsxs("div",{className:"autoruns-coverage-head",children:[l.jsx("strong",{children:h.domain}),l.jsxs("span",{children:[h.closed_cases,"/",h.total_cases," (",m,"%)"]})]}),l.jsx("div",{className:"autoruns-coverage-bar",children:l.jsx("div",{style:{width:`${m}%`}})})]},h.domain)})})}function Dl(i){return`${zl}${i}`}function Hs(i){return i.startsWith(zl)}function sd(i){return i.startsWith(zl)?i.slice(zl.length):""}function pd(i){const h=i.report_summary?.run_timestamp??i.created_at,m=Math.max(0,i.total_cases-i.completed_cases);return{run_id:Dl(i.job_id),eval_target:i.eval_target,run_timestamp:h,mode:"single-pass-strict",llm_provider:null,model:null,use_mock:null,analysis_date:i.report_summary?.analysis_date??i.analysis_date??null,prompt_version:null,schema_version:null,suite_id:i.case_set_file,cases_total:i.total_cases,requests_total:null,report_path:`async_job:${i.job_id}`,score_index:i.report_summary?.score_index??null,blocking_failures:0,quality_failures:0,closed_cases:i.completed_cases,open_cases:m,domain_coverage:[{domain:"runtime",total_cases:i.total_cases,closed_cases:i.completed_cases}]}}function Co(i,h){const m=pd(i),R=i.cases.map(Y=>({case_id:Y.case_id,domain:null,query_class:null,status:Y.status==="completed"?"closed":Y.status==="failed"?"open":"unknown",score_index:null,trace_id:null,reply_type:null,session_id:`${i.run_id}-${Y.case_id}`,dialog_available:Y.messages.length>0,commented_count:0,latest_annotation_at:null,avg_rating:null,checks:null,metric_subscores:null})),I=h!==kt&&R.some(Y=>Y.case_id===h)?h:R.length>0?kt:"",Q={ok:!0,run:m,coverage:{closed_cases:i.completed_cases,open_cases:Math.max(0,i.total_cases-i.completed_cases),domain_coverage:[{domain:"runtime",total_cases:i.total_cases,closed_cases:i.completed_cases}]},cases:R,annotations_summary:{total:0},report:i.report_summary?{run_id:i.report_summary.run_id,run_timestamp:i.report_summary.run_timestamp,score_index:i.report_summary.score_index,cases_total:i.report_summary.cases_total,analysis_date:i.report_summary.analysis_date??i.analysis_date??null}:{}},le=[];let te=0;if(I===kt)for(const Y of i.cases)for(let X=0;XX.case_id===I)??null;for(let X=0;X<(Y?.messages.length??0);X+=1){const ee=Y?.messages[X];ee&&le.push({...ee,message_index:X,case_id:I,case_message_index:X,commented:!1,annotation:null})}}const z={ok:!0,run_id:m.run_id,case_id:I,source:"assistant_session",session_id:I===kt?`${i.run_id}::__all__`:`${i.run_id}-${I}`,messages:le,decomposition:[],assistant_mode:{status:i.status,completed_cases:i.completed_cases,total_cases:i.total_cases},annotations:[]};return{detail:Q,dialog:z,caseId:I}}function im({commented:i}){const h=i?"comment-icon-svg commented":"comment-icon-svg";return l.jsx("svg",{className:h,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:l.jsx("path",{d:"M5 6.5h14v9H11.5l-4.5 3v-3H5z"})})}function od({resolved:i}){return l.jsxs("svg",{className:i?"resolve-icon-svg resolved":"resolve-icon-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),i?l.jsx("path",{d:"M5.1 8.2 7.2 10.3 11 6.5"}):null]})}function ld(){return l.jsxs("svg",{className:"autoruns-copy-icon-svg",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[l.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2.2"}),l.jsx("path",{d:"M15 7V5.8a1.8 1.8 0 0 0-1.8-1.8H5.8A1.8 1.8 0 0 0 4 5.8v7.4A1.8 1.8 0 0 0 5.8 15H7"})]})}function am(){return l.jsxs("svg",{className:"autoruns-question-grip-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[l.jsx("circle",{cx:"4",cy:"4",r:"1"}),l.jsx("circle",{cx:"8",cy:"4",r:"1"}),l.jsx("circle",{cx:"12",cy:"4",r:"1"}),l.jsx("circle",{cx:"4",cy:"8",r:"1"}),l.jsx("circle",{cx:"8",cy:"8",r:"1"}),l.jsx("circle",{cx:"12",cy:"8",r:"1"}),l.jsx("circle",{cx:"4",cy:"12",r:"1"}),l.jsx("circle",{cx:"8",cy:"12",r:"1"}),l.jsx("circle",{cx:"12",cy:"12",r:"1"})]})}function um({connection:i,modelOptions:h,modelsBusy:m,connectionStatus:R,connectionBusy:E,onConnectionChange:I,onReloadModels:Q,onSaveLocalConfig:le,onTestConnection:te,prompts:z,onPromptsChange:Y,promptPresets:X,selectedPresetId:ee,onSelectPreset:Me,onLoadPreset:ue,onSavePreset:ce,onResetDefaults:pe,onDiffPrevious:Ve,presetName:Xe,onPresetNameChange:We,diffSummary:Ae,assistantPromptVersion:$,decompositionPromptVersion:oe,showSettingsMode:je,showAutoRunsMode:Be,showAssistantMode:gt,showProgressMode:ct,showCommentsMode:Ut,onLog:dt}){const[B,Le]=v.useState({...ka,fromLocal:ed()}),[Ke,ne]=v.useState(""),[Z,M]=v.useState(null),[F,A]=v.useState(null),[y,k]=v.useState(null),[re,ie]=v.useState([]),[ae,he]=v.useState("all"),[ye,xe]=v.useState(!1),[we,ft]=v.useState(null),[qt,ir]=v.useState([]),[Cn,an]=v.useState(""),[Pe,Bt]=v.useState(""),[st,vt]=v.useState(""),[jt,un]=v.useState(Ra),[G,mt]=v.useState(Xc),[ar,Nn]=v.useState([]),[Gn,En]=v.useState(""),[ge,At]=v.useState([]),[Jt,Pn]=v.useState(!1),[ot,ur]=v.useState(null),[cr,Tn]=v.useState(""),[$r,cn]=v.useState(null),[Kn,Ct]=v.useState(null),[Qe,Rn]=v.useState(null),[de,dn]=v.useState(null),[dr,Fr]=v.useState(!1),[Ur,Mn]=v.useState(!1),[An,fr]=v.useState(!1),[qn,Ln]=v.useState(!1),[mr,In]=v.useState(!1),[C,J]=v.useState(!1),[b,Ce]=v.useState(!1),[qe,No]=v.useState(!1),[Eo,Po]=v.useState(""),[Dn,Je]=v.useState(""),[et,bs]=v.useState(""),[Qt,ds]=v.useState([]),[pr,hr]=v.useState([]),[Vs,Ws]=v.useState(""),[De,Gs]=v.useState(null),[Br,To]=v.useState(!1),[Qr,Ro]=v.useState(!1),[Mo,On]=v.useState(""),[Yt,Jn]=v.useState(""),[Ht,gr]=v.useState(String(ka.limit)),[Fl,vr]=v.useState(String(Xc.count)),[yr,Hr]=v.useState(160),[fe,Nt]=v.useState({open:!1,caseId:"",caseMessageIndex:-1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:Al,annotationAuthor:"manual_reviewer",saving:!1,error:""}),[Ne,fn]=v.useState({open:!1,messageIndex:-1,rating:3,comment:"",annotationAuthor:"manual_reviewer",saving:!1,error:""}),[Et,zn]=v.useState({open:!1,title:"",saving:!1,error:""}),[Pt,mn]=v.useState({open:!1,generationId:"",questionIndex:-1,questionText:"",saving:!1,error:""}),[pn,xr]=v.useState({open:!1,generationId:"",title:"",saving:!1,error:""}),_e=v.useRef(!1),br=v.useRef(null),fs=v.useRef(null),bt=G.mode==="saved_user_sessions",Vr=v.useMemo(()=>jt.find(a=>a.id===G.personalityId)??jt[0]??Ra[0],[G.personalityId,jt]),Tt=v.useMemo(()=>ar.filter(a=>a.mode===G.mode),[ar,G.mode]),$e=v.useMemo(()=>Tt.find(a=>a.generation_id===Gn)??Tt[0]??null,[Gn,Tt]),hn=v.useMemo(()=>ye?re.filter(a=>!a.resolved):re,[re,ye]),Te=hn.find(a=>a.annotation_id===Cn)??null,gn=y?.messages.find(a=>a.message_index===fe.messageIndex)??null,$n=v.useMemo(()=>{if(!y||fe.messageIndex<0)return null;for(let a=fe.messageIndex-1;a>=0;a-=1){const c=y.messages[a];if(c?.role==="user")return c}return null},[fe.messageIndex,y]),Vt=v.useMemo(()=>{const a=new Map;for(const c of pr)c.message_id&&a.set(c.message_id,c);return a},[pr]),_r=Ne.messageIndex>=0?Qt[Ne.messageIndex]??null:null,Sr=v.useMemo(()=>{if(Ne.messageIndex<0)return null;for(let a=Ne.messageIndex-1;a>=0;a-=1){const c=Qt[a];if(c?.role==="user")return c}return null},[Ne.messageIndex,Qt]),lt=v.useMemo(()=>{const a=hn.map(f=>({source:"autorun",key:`autorun:${f.annotation_id}`,updated_at:f.updated_at,rating:f.rating,autorun:f,assistant:null})),c=pr.map(f=>({source:"assistant_live",key:`assistant:${f.annotation_id}`,updated_at:f.updated_at,rating:f.rating,autorun:null,assistant:f}));return[...a,...c].sort((f,w)=>Date.parse(w.updated_at)-Date.parse(f.updated_at))},[pr,hn]),Ao=v.useMemo(()=>{if(lt.length===0)return null;const a=lt.reduce((c,f)=>c+f.rating,0)/lt.length;return Number(a.toFixed(2))},[lt]),ms=v.useMemo(()=>{const a=[...Z?.items??[]];return Qe&&a.unshift(pd(Qe)),Pe&&!a.some(c=>c.run_id===Pe)&&F?.run&&a.unshift(F.run),a},[Qe,Z?.items,F?.run,Pe]),W=v.useCallback(a=>{dt?.(`[autoruns] ${a}`)},[dt]),ps=v.useCallback(async a=>{const c=String(a??"").trim();if(!c){hr([]);return}try{const f=await Re.loadAssistantAnnotations({session_id:c,limit:400});hr(f.items??[])}catch(f){const w=f instanceof Error?f.message:String(f);W(`Assistant live annotations load error: ${w}`)}},[W]),Yn=v.useCallback(a=>{fn(c=>c.saving&&!a?.force?c:{open:!1,messageIndex:-1,rating:3,comment:"",annotationAuthor:"manual_reviewer",saving:!1,error:""})},[]),Xn=v.useCallback(a=>{zn(c=>c.saving&&!a?.force?c:{open:!1,title:"",saving:!1,error:""})},[]),Wr=v.useCallback(a=>{mn(c=>c.saving&&!a?.force?c:{open:!1,generationId:"",questionIndex:-1,questionText:"",saving:!1,error:""})},[]),hs=v.useCallback(a=>{xr(c=>c.saving&&!a?.force?c:{open:!1,generationId:"",title:"",saving:!1,error:""})},[]),Fn=v.useCallback(async(a,c,f)=>{a.stopPropagation(),a.preventDefault();const w=String(c??"").trim();if(w)try{if(navigator?.clipboard?.writeText)await navigator.clipboard.writeText(w);else{const L=document.createElement("textarea");L.value=w,L.setAttribute("readonly","true"),L.style.position="fixed",L.style.opacity="0",document.body.appendChild(L),L.select(),document.execCommand("copy"),document.body.removeChild(L)}W(`${f} copied: ${w}`)}catch(L){const Ee=L instanceof Error?L.message:String(L);Je(`Копирование ${f}: ${Ee}`),W(`copy ${f} error: ${Ee}`)}},[W]);function Gr(){let a=0;On(ja[0]);const c=window.setInterval(()=>{a=Math.min(a+1,ja.length-1),On(ja[a])},650);return()=>window.clearInterval(c)}const wr=v.useCallback(()=>{bs(""),ds([]),hr([]),Ws(""),Gs(null),On(""),Jn(""),Yn({force:!0}),W("Live-чат ассистента в истории автопрогонов сброшен.")},[Yn,W]),gs=v.useCallback(async()=>{const a=tm(Vs,De);if(!a)return;Ro(!0),Jn(""),Ws(""),ds(f=>[...f,{message_id:`autoruns-live-${Date.now()}`,session_id:et||"pending",role:"user",text:a,reply_type:null,created_at:new Date().toISOString(),trace_id:null,debug:null}]);const c=Gr();try{const f=await Re.sendAssistantMessage({connection:i,prompts:z,userMessage:a,sessionId:et||void 0,promptVersion:$,useMock:Br});bs(f.session_id),ds(f.conversation),await ps(f.session_id),On("Ответ готов"),W(`Live-ответ ассистента получен: trace=${f.debug.trace_id}`)}catch(f){const w=f instanceof Error?f.message:String(f);Jn(w),On("Ошибка ассистента"),W(`Live-чат ассистента: ошибка отправки сообщения: ${w}`)}finally{c(),Ro(!1)}},[Vs,De,et,Br,$,i,ps,W,z]),Ul=v.useCallback(()=>{if(!et.trim()||Qt.length===0){Jn("Сначала получите хотя бы один ответ в живой сессии ассистента.");return}Jn(""),zn({open:!0,title:sm(Qt),saving:!1,error:""})},[Qt,et]),Bl=v.useCallback(async()=>{const a=et.trim(),c=Et.title.trim();if(!a){zn(f=>({...f,error:"Активная сессия ассистента не найдена."}));return}if(!c){zn(f=>({...f,error:"Укажите название сессии."}));return}zn(f=>({...f,saving:!0,error:""}));try{const f=[z.systemPrompt,z.developerPrompt,z.domainPrompt,z.schemaNotes,z.fewShotExamples].join("||"),w=await Re.saveAutoRunAssistantSession({session_id:a,title:c,generated_by:G.generatedBy.trim()||void 0,context:{llm_provider:i.llmProvider,model:i.model,assistant_prompt_version:$,decomposition_prompt_version:oe,prompt_fingerprint:f}});Nn(L=>[w.generation,...L.filter(Ee=>Ee.generation_id!==w.generation.generation_id)]),mt(L=>({...L,mode:"saved_user_sessions"})),En(w.generation.generation_id),Xn({force:!0}),W(`Живая сессия сохранена в автопрогоны: ${w.generation.generation_id}`)}catch(f){const w=f instanceof Error?f.message:String(f);zn(L=>({...L,saving:!1,error:w})),W(`Assistant live save error: ${w}`)}},[Et.title,et,$,G.generatedBy,Xn,i.llmProvider,i.model,oe,W,z.developerPrompt,z.domainPrompt,z.fewShotExamples,z.schemaNotes,z.systemPrompt]),vs=v.useCallback(a=>{const c=a.trim();if(!c){gr(String(B.limit));return}if(!/^\d+$/.test(c)){gr(String(B.limit));return}const f=Number.parseInt(c,10);if(!Number.isFinite(f)){gr(String(B.limit));return}const w=Math.max(1,Math.min(500,f));w!==B.limit&&Le(L=>({...L,limit:w})),gr(String(w))},[B.limit]),Kr=v.useCallback(a=>{const c=a.trim();if(!c){vr(String(G.count));return}if(!/^\d+$/.test(c)){vr(String(G.count));return}const f=Number.parseInt(c,10);if(!Number.isFinite(f)){vr(String(G.count));return}const w=Math.max(1,Math.min(200,f));w!==G.count&&mt(L=>({...L,count:w})),vr(String(w))},[G.count]),ys=v.useCallback(a=>{Hr(Zc(a))},[]),Ks=v.useCallback(a=>{const c=a.currentTarget.offsetHeight;Number.isFinite(c)&&c>0&&ys(c)},[ys]),Lt=v.useCallback(async()=>{No(!0);try{const a=await Re.loadAutoRunAnnotations({limit:800,manual_case_decision:ae});ie(a.items),ft(a.manual_case_decision_schema??null),ir(a.available_manual_case_decisions??[]),an(c=>a.items.length===0?"":a.items.some(f=>f.annotation_id===c)?c:a.items[0].annotation_id)}catch(a){W(`Annotations load error: ${a instanceof Error?a.message:String(a)}`)}finally{No(!1)}},[ae,W]),vn=v.useCallback(async()=>{Ln(!0);try{const a=await Re.loadAutoRunAutogenHistory({limit:180});Nn(a.items)}catch(a){W(`Autogen history load error: ${a instanceof Error?a.message:String(a)}`)}finally{Ln(!1)}},[W]),qr=v.useCallback(async()=>{try{const c=(await Re.loadAutoRunAutogenPersonalityCatalog()).items.map(f=>({id:String(f.id??"").trim(),label:String(f.label??"").trim(),domain:typeof f.domain=="string"?f.domain.trim():"",defaultPrompt:String(f.default_prompt??"").trim()})).filter(f=>f.id.length>0&&f.label.length>0);if(c.length===0)return;un(c.map(f=>({id:f.id,label:f.label,domain:f.domain||"",defaultPrompt:f.defaultPrompt||"Генерируй реалистичные вопросы бухгалтера по выбранному профилю. Не выдумывай непокрытые возможности."})))}catch(a){W(`Autogen personality catalog load error: ${a instanceof Error?a.message:String(a)}`)}},[W]),Xt=v.useCallback(async()=>{fr(!0);try{const a=await Re.loadAutoRunPostAnalysis({run_id:Pe&&!Hs(Pe)?Pe:void 0,limit_per_queue:30,annotation_limit:1500,from:Ll(B.fromLocal),to:Ll(B.toLocal),target:B.target,mode:B.mode,use_mock:B.useMock,prompt_contains:B.promptContains.trim()||void 0});dn(a)}catch(a){W(`Post-analysis load error: ${a instanceof Error?a.message:String(a)}`),dn(null)}finally{fr(!1)}},[B.fromLocal,B.mode,B.promptContains,B.target,B.toLocal,B.useMock,W,Pe]),xs=v.useCallback(async()=>{Fr(!0),Je("");try{if(G.mode==="saved_user_sessions")throw new Error("Пользовательские сессии сохраняются из живого чата, а не генерируются автоматически.");const a=G.personalityPrompts[G.personalityId]??"",c=[z.systemPrompt,z.developerPrompt,z.domainPrompt,z.schemaNotes,z.fewShotExamples].join(` +`).slice(0,900),f=await Re.generateAutoRunQuestions({mode:G.mode,count:G.count,domain:Vr.domain||void 0,persist_to_eval_cases:G.persistToEvalCases,generated_by:G.generatedBy.trim()||void 0,llm:{llm_provider:i.llmProvider,api_key:i.apiKey,model:i.model,base_url:i.baseUrl,temperature:i.temperature,max_output_tokens:i.maxOutputTokens},context:{llm_provider:i.llmProvider,model:i.model,assistant_prompt_version:$,decomposition_prompt_version:oe,prompt_fingerprint:c,autogen_personality_id:Vr.id,autogen_personality_prompt:a.trim()||void 0}});W(`Generated ${f.generation.count} questions (${f.generation.mode}) id=${f.generation.generation_id}`+(f.generation.saved_case_set_file?` saved=${f.generation.saved_case_set_file}`:"")),En(f.generation.generation_id),At([...f.generation.questions??[]]),await vn()}catch(a){const c=a instanceof Error?a.message:String(a);Je(`Автогенерация: ${c}`),W(`Autogen generate error: ${c}`)}finally{Fr(!1)}},[$,G.count,G.generatedBy,G.mode,G.personalityId,G.personalityPrompts,G.persistToEvalCases,i.apiKey,i.baseUrl,i.llmProvider,i.maxOutputTokens,i.model,i.temperature,oe,vn,W,z.developerPrompt,z.domainPrompt,z.fewShotExamples,z.schemaNotes,z.systemPrompt,Vr.domain,Vr.id]),Un=v.useCallback(async(a,c)=>{if(Hs(a)){const f=sd(a);if(Qe&&Qe.job_id===f){const w=Co(Qe,c);Bt(a),vt(w.caseId),k(w.dialog);return}k(null);return}Ce(!0);try{const f=await Re.loadAutoRunCaseDialog(a,c);k(f)}catch(f){const w=f instanceof Error?f.message:String(f);Je(`Диалог кейса: ${w}`),k(null),W(`Dialog load error for ${a}/${c}: ${w}`)}finally{Ce(!1)}},[Qe,W]),yn=v.useCallback(async(a,c)=>{if(Hs(a)){const f=sd(a);if(Qe&&Qe.job_id===f){const w=Co(Qe,c??kt);Bt(a),vt(w.caseId),A(w.detail),k(w.dialog);return}Bt(a),vt(""),A(null),k(null);return}J(!0);try{const f=await Re.loadAutoRunDetail(a);A(f);const w=(c&&(c===kt||f.cases.some(L=>L.case_id===c))?c:"")||(f.cases.length>0?kt:"")||"";Bt(a),vt(w),w?await Un(a,w):k(null)}catch(f){const w=f instanceof Error?f.message:String(f);Je(`Детализация прогона: ${w}`),A(null),k(null),W(`Run detail load error for ${a}: ${w}`)}finally{J(!1)}},[Qe,Un,W]),tt=v.useCallback(async a=>{In(!0),Je("");try{const c=await Re.loadAutoRunsHistory({from:Ll(B.fromLocal),to:Ll(B.toLocal),target:B.target,mode:B.mode,use_mock:B.useMock,prompt_contains:B.promptContains.trim()||void 0,limit:B.limit});if(M(c),c.items.length===0){Bt(""),vt(""),A(null),k(null);return}const f=a?.keepSelection??!0,w=a?.preferredRunId??"",L=a?.preferredCaseId??"",Ee=f&&w&&c.items.some(Fe=>Fe.run_id===w)?w:c.items[0].run_id;await yn(Ee,f?L:void 0),Xt()}catch(c){const f=c instanceof Error?c.message:String(c);Je(`История прогонов: ${f}`),W(`History load error: ${f}`)}finally{In(!1)}},[B.fromLocal,B.limit,B.mode,B.promptContains,B.target,B.toLocal,B.useMock,Xt,yn,W]),yt=v.useCallback(()=>{br.current!==null&&(window.clearTimeout(br.current),br.current=null)},[]),Jr=v.useCallback(async a=>{try{const c=await Re.loadEvalRunAsyncStatus(a);Rn(c.job);const f=Dl(a);if(Pe===f){const w=Co(c.job,st||kt);A(w.detail),k(w.dialog),vt(w.caseId)}if(c.job.status==="completed"){yt(),Mn(!1);const w=c.job.report_summary?.run_id??c.job.run_id;await tt({keepSelection:!0,preferredRunId:w||Pe,preferredCaseId:kt}),await vn(),Rn(null);return}if(c.job.status==="failed"){yt(),Mn(!1),Je(`Запуск прогонов: ${c.job.error??"неизвестная ошибка"}`),W(`Autogen async run failed: ${c.job.error??"unknown error"}`);return}yt(),br.current=window.setTimeout(()=>{Jr(a)},500)}catch(c){yt(),Mn(!1);const f=c instanceof Error?c.message:String(c);Je(`Запуск прогонов: ${f}`),W(`Autogen async status error: ${f}`)}},[vn,tt,W,st,Pe,yt]),Yr=v.useCallback(async()=>{yt(),Mn(!0),Je("");try{const a=$e;if(!a)throw new Error("История автогенерации пуста. Сначала сгенерируйте пачку вопросов.");const c=ge.map(ws=>ws.trim()).filter(ws=>ws.length>0);if(c.length===0)throw new Error("Нет вопросов для запуска: список пустой после ручного редактирования.");const f=B.useMock==="true",w=Ca(Ke),L=a.mode==="saved_user_sessions",Fe=(await Re.startEvalRunAsync({connection:i,prompts:z,promptVersion:$,mode:"single-pass-strict",caseSetFile:L?void 0:a.saved_case_set_file??void 0,useMock:f,evalTarget:"assistant_stage1",questions:L?void 0:c,scenarioQuestions:L?c:void 0,scenarioTitle:L?a.title??void 0:void 0,analysisDate:L?void 0:w||void 0})).job;Rn(Fe);const Zt=Dl(Fe.job_id),Zs=Co(Fe,kt);Bt(Zt),vt(Zs.caseId),A(Zs.detail),k(Zs.dialog),W(`Запущен async-прогон job=${Fe.job_id}, run_id=${Fe.run_id}, вопросов=${c.length}`+(a.saved_case_set_file?`, base_case_set=${a.saved_case_set_file}`:"")+(L?", replay_mode=saved_user_session_scenario":w?`, analysis_date=${w}`:", analysis_date=current_state")),Jr(Fe.job_id)}catch(a){const c=a instanceof Error?a.message:String(a);Je(`Запуск прогонов: ${c}`),W(`Autogen run error: ${c}`),Mn(!1)}},[Ke,$,i,ge,B.useMock,W,Jr,z,$e,yt]),Ql=v.useCallback(a=>{if(a.role!=="assistant")return;const c=a.case_id??st,f=a.case_message_index??a.message_index;Nt({open:!0,caseId:c,caseMessageIndex:f,messageIndex:a.message_index,rating:a.annotation?.rating??3,comment:a.annotation?.comment??"",manualCaseDecision:a.annotation?.manual_case_decision??Al,annotationAuthor:a.annotation?.annotation_author??G.generatedBy,saving:!1,error:""})},[G.generatedBy,st]),kr=v.useCallback(a=>{Nt(c=>c.saving&&!a?.force?c:{open:!1,caseId:"",caseMessageIndex:-1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:Al,annotationAuthor:G.generatedBy,saving:!1,error:""})},[G.generatedBy]),qs=v.useCallback(async()=>{const a=Pe,c=fe.caseId,f=fe.caseMessageIndex;if(!(!a||!c||f<0)){if(Hs(a)){Nt(w=>({...w,error:"Комментарий можно сохранить после завершения прогона."}));return}if(!fe.comment.trim()){Nt(w=>({...w,error:"Добавьте комментарий."}));return}Nt(w=>({...w,saving:!0,error:""}));try{await Re.saveAutoRunAnnotation({run_id:a,case_id:c,message_index:f,rating:fe.rating,comment:fe.comment.trim(),manual_case_decision:fe.manualCaseDecision,annotation_author:fe.annotationAuthor.trim()||void 0}),kr({force:!0}),Promise.all([yn(a,st),Lt(),Xt()]).catch(w=>{const L=w instanceof Error?w.message:String(w);Je(`Обновление после комментария: ${L}`),W(`Comment refresh error: ${L}`)})}catch(w){Nt(L=>({...L,saving:!1,error:w instanceof Error?w.message:String(w)}))}}},[kr,fe.annotationAuthor,fe.caseId,fe.caseMessageIndex,fe.comment,fe.manualCaseDecision,fe.rating,Lt,Xt,yn,W,st,Pe]),Xr=v.useCallback(a=>a.role==="assistant",[]),_s=v.useCallback(a=>a.role==="assistant"&&Vt.has(a.message_id),[Vt]),Lo=v.useCallback((a,c)=>{if(a.role!=="assistant")return;const f=et.trim(),w=String(a.session_id??"").trim();if(!(f||w)){Jn("Сначала получите ответ ассистента в активной сессии.");return}!f&&w&&bs(w);const Ee=Vt.get(a.message_id)??null;Jn(""),fn({open:!0,messageIndex:c,rating:Ee?.rating??3,comment:Ee?.comment??"",annotationAuthor:Ee?.annotation_author??"manual_reviewer",saving:!1,error:""})},[Vt,et]),Hl=v.useCallback(async()=>{if(Ne.messageIndex<0)return;if(!Ne.comment.trim()){fn(f=>({...f,error:"Добавьте комментарий."}));return}const a=Qt[Ne.messageIndex]??null,c=et.trim()||(a?.role==="assistant"?String(a.session_id??"").trim():"");if(!c){fn(f=>({...f,error:"Сессия ассистента не найдена."}));return}fn(f=>({...f,saving:!0,error:""}));try{const f=await Re.saveAssistantAnnotation({session_id:c,message_index:Ne.messageIndex,rating:Ne.rating,comment:Ne.comment.trim(),annotation_author:Ne.annotationAuthor.trim()||void 0});hr(w=>{const L=[...w],Ee=L.findIndex(Fe=>Fe.annotation_id===f.annotation.annotation_id);return Ee>=0?L[Ee]=f.annotation:L.unshift(f.annotation),L.sort((Fe,Zt)=>Date.parse(Zt.updated_at)-Date.parse(Fe.updated_at))}),Yn({force:!0})}catch(f){const w=f instanceof Error?f.message:String(f);fn(L=>({...L,saving:!1,error:w}))}},[Ne.annotationAuthor,Ne.comment,Ne.messageIndex,Ne.rating,Qt,et,Yn]);v.useCallback(a=>{if(!$e||$e.mode!=="saved_user_sessions")return;const c=ge[a]??"";mn({open:!0,generationId:$e.generation_id,questionIndex:a,questionText:c,saving:!1,error:""})},[ge,$e]);const bl=v.useCallback(async()=>{const a=Pt.generationId,c=Pt.questionIndex;if(!a||c<0)return;const f=ge.filter((w,L)=>L!==c);if(f.length===0){mn(w=>({...w,error:"Нельзя удалить последний вопрос из сохраненной сессии."}));return}mn(w=>({...w,saving:!0,error:""}));try{const w=await Re.updateAutoRunAutogenQuestions({generation_id:a,questions:f});Nn(L=>L.map(Ee=>Ee.generation_id===a?w.generation:Ee)),At(w.generation.questions),Wr({force:!0}),W(`Обновлена сохраненная сессия: ${a}`)}catch(w){const L=w instanceof Error?w.message:String(w);mn(Ee=>({...Ee,saving:!1,error:L})),W(`Saved session question delete error: ${L}`)}},[Wr,ge,W,Pt.generationId,Pt.questionIndex]),Bn=v.useCallback(async(a,c)=>{const f=$e?.generation_id??"",w=c?.revertQuestions??ge;if(At(a),!f)return!0;Pn(!0);try{const L=await Re.updateAutoRunAutogenQuestions({generation_id:f,questions:a});return Nn(Ee=>Ee.map(Fe=>Fe.generation_id===f?L.generation:Fe)),At([...L.generation.questions??[]]),c?.successLog&&W(c.successLog),!0}catch(L){const Ee=L instanceof Error?L.message:String(L);return At(w),Je(`Вопросы к запуску: ${Ee}`),W(`Autogen questions update error: ${Ee}`),!1}finally{Pn(!1)}},[ge,W,$e]),Js=v.useCallback(a=>{ur(a),Tn(ge[a]??"")},[ge]),Qn=v.useCallback(()=>{ur(null),Tn("")},[]),Ss=v.useCallback(async a=>{if(a===null)return;const c=ge[a]??"",f=cr.trim();if(!f||f===c){Qn();return}const w=ge.map((Ee,Fe)=>Fe===a?f:Ee);await Bn(w,{successLog:`Список вопросов обновлен: ${$e?.generation_id??"local"}`,revertQuestions:ge})&&Qn()},[ge,cr,$e,Qn,Bn]),Vl=v.useCallback(()=>{Ss(ot)},[Ss,ot]),Wl=v.useCallback(a=>{if(a.key==="Enter"){a.preventDefault(),Ss(ot);return}a.key==="Escape"&&(a.preventDefault(),Qn())},[Ss,ot,Qn]),Gl=v.useCallback(async()=>{const a=[...ge,"Новый вопрос"],c=a.length-1;await Bn(a,{successLog:`В список добавлен вопрос: ${$e?.generation_id??"local"}`,revertQuestions:ge})&&(ur(c),Tn(a[c]))},[ge,$e,Bn]),Io=v.useCallback(async a=>{if(ge.length<=1){Je("В списке должен остаться хотя бы один вопрос.");return}const c=ge.filter((w,L)=>L!==a);await Bn(c,{successLog:`Из списка удален вопрос: ${$e?.generation_id??"local"}`,revertQuestions:ge})&&(ur(w=>w===null?w:w===a?null:w>a?w-1:w),Tn(""))},[ge,$e,Bn]),Kl=v.useCallback((a,c)=>{if(Jt){a.preventDefault();return}cn(c),Ct(c),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",String(c))},[Jt]),ql=v.useCallback((a,c)=>{a.preventDefault(),Kn!==c&&Ct(c),a.dataTransfer.dropEffect="move"},[Kn]),Jl=v.useCallback(async(a,c)=>{a.preventDefault();const f=$r;if(Ct(null),cn(null),f===null||f===c)return;const w=[...ge],[L]=w.splice(f,1);w.splice(c,0,L),await Bn(w,{successLog:`Порядок вопросов обновлен: ${$e?.generation_id??"local"}`,revertQuestions:ge})},[$r,ge,$e,Bn]),Yl=v.useCallback(()=>{cn(null),Ct(null)},[]),Ys=v.useCallback(a=>{xr({open:!0,generationId:a.generation_id,title:a.title??`${Na(a.mode)} ${ln(a.created_at)}`,saving:!1,error:""})},[]),Xl=v.useCallback(async()=>{const a=pn.generationId.trim();if(a){xr(c=>({...c,saving:!0,error:""}));try{const c=await Re.deleteAutoRunAutogenHistoryRecord(a);Nn(f=>f.filter(w=>w.generation_id!==c.generation_id)),hs({force:!0}),W(`Удален набор автопрогона: ${c.generation_id}`+(c.deleted_files.length>0?`, files=${c.deleted_files.length}`:""))}catch(c){const f=c instanceof Error?c.message:String(c);xr(w=>({...w,saving:!1,error:f})),W(`Autogen record delete error: ${f}`)}}},[pn.generationId,hs,W]),Do=v.useCallback(a=>{ie(c=>c.map(f=>f.annotation_id===a.annotation_id?{...f,...a}:f)),k(c=>c&&{...c,annotations:c.annotations.map(f=>f.annotation_id===a.annotation_id?a:f),messages:c.messages.map(f=>!f.annotation||f.annotation.annotation_id!==a.annotation_id?f:{...f,commented:!0,annotation:a})})},[]),Oo=v.useCallback(async(a,c)=>{if(a.annotation_id){if(Hs(a.run_id)){Je("Статус выполнения можно менять только для завершённых прогонов.");return}Po(a.annotation_id);try{const f=await Re.updateAutoRunAnnotation({annotation_id:a.annotation_id,resolved:c,resolved_by:G.generatedBy||void 0});Do(f.annotation),Xt()}catch(f){const w=f instanceof Error?f.message:String(f);Je(`Смена статуса кейса: ${w}`),W(`Annotation resolve toggle error: ${w}`)}finally{Po("")}}},[Do,G.generatedBy,Xt,W]),Xs=v.useCallback(async a=>{an(a.annotation_id),await yn(a.run_id,a.case_id),Z?.items.some(c=>c.run_id===a.run_id)||Je("Комментарий относится к прогону вне текущего фильтра. Детали загружены напрямую.")},[Z?.items,yn]);v.useEffect(()=>{_e.current||(_e.current=!0,tt({keepSelection:!1}),vn(),qr(),Xt())},[vn,qr,tt,Xt]),v.useEffect(()=>{_e.current&&Lt()},[ae,Lt]),v.useEffect(()=>{an(a=>hn.length===0?"":hn.some(c=>c.annotation_id===a)?a:hn[0].annotation_id)},[hn]),v.useEffect(()=>{En(a=>Tt.length===0?"":a&&Tt.some(c=>c.generation_id===a)?a:Tt[0].generation_id)},[Tt]),v.useEffect(()=>{if(!$e){At([]),Qn(),cn(null),Ct(null);return}At([...$e.questions]),Qn(),cn(null),Ct(null)},[$e,Qn]),v.useEffect(()=>{if(ot===null)return;const a=window.setTimeout(()=>{fs.current?.focus(),fs.current?.select()},0);return()=>window.clearTimeout(a)},[ot]),v.useEffect(()=>{gr(String(B.limit))},[B.limit]),v.useEffect(()=>{vr(String(G.count))},[G.count]),v.useEffect(()=>{if(!et.trim()){hr([]);return}ps(et)},[et,ps]),v.useEffect(()=>{if(!Qe)return;const a=Dl(Qe.job_id);if(Pe!==a)return;const c=Co(Qe,st||kt);A(c.detail),k(c.dialog),vt(c.caseId)},[Qe,st,Pe]),v.useEffect(()=>()=>{yt()},[yt]),v.useEffect(()=>{jt.length!==0&&mt(a=>{let c=!1;const f={...a.personalityPrompts};for(const L of jt)(typeof f[L.id]!="string"||f[L.id].trim().length===0)&&(f[L.id]=L.defaultPrompt,c=!0);let w=a.personalityId;return jt.some(L=>L.id===a.personalityId)||(w=jt[0].id,c=!0),c?{...a,personalityId:w,personalityPrompts:f}:a})},[jt]),v.useEffect(()=>{const a=localStorage.getItem(Jc);if(a)try{const c=JSON.parse(a);if(c.filters){const f=c.filters;Le(w=>({...w,...f,limit:typeof f.limit=="number"?Math.max(1,Math.min(500,f.limit)):w.limit}))}typeof c.analysisDate=="string"&&ne(Ca(c.analysisDate)),typeof c.autogenPersonalityPromptHeight=="number"&&Hr(Zc(c.autogenPersonalityPromptHeight)),c.autoGenSettings&&mt(f=>{const w={...f.personalityPrompts},L=c.autoGenSettings?.personalityPrompts??{};for(const[Fe,Zt]of Object.entries(L))typeof Zt=="string"&&Fe.trim().length>0&&(w[Fe.trim()]=Zt);const Ee=typeof c.autoGenSettings?.personalityId=="string"&&c.autoGenSettings.personalityId.trim().length>0?c.autoGenSettings.personalityId.trim():f.personalityId;return{...f,mode:c.autoGenSettings?.mode==="codex_creative"||c.autoGenSettings?.mode==="qwen_seed"||c.autoGenSettings?.mode==="saved_user_sessions"?c.autoGenSettings.mode:f.mode,count:typeof c.autoGenSettings?.count=="number"?Math.max(1,Math.min(200,c.autoGenSettings.count)):f.count,personalityId:Ee,personalityPrompts:w,persistToEvalCases:typeof c.autoGenSettings?.persistToEvalCases=="boolean"?c.autoGenSettings.persistToEvalCases:f.persistToEvalCases,generatedBy:typeof c.autoGenSettings?.generatedBy=="string"?c.autoGenSettings.generatedBy:f.generatedBy}}),(c.annotationDecisionFilter==="all"||typeof c.annotationDecisionFilter=="string"&&c.annotationDecisionFilter.length>0)&&he(c.annotationDecisionFilter),typeof c.hideResolvedAnnotations=="boolean"&&xe(c.hideResolvedAnnotations)}catch{}},[]);const zo=v.useCallback(()=>{const a={filters:B,analysisDate:Ke,autogenPersonalityPromptHeight:yr,autoGenSettings:{mode:G.mode,count:G.count,personalityId:G.personalityId,personalityPrompts:G.personalityPrompts,persistToEvalCases:G.persistToEvalCases,generatedBy:G.generatedBy},annotationDecisionFilter:ae,hideResolvedAnnotations:ye};localStorage.setItem(Jc,JSON.stringify(a))},[Ke,ae,G,yr,B,ye]);return v.useEffect(()=>{const a=()=>{zo(),W("Сохранены настройки панели автопрогонов.")};return window.addEventListener(Yc,a),()=>{window.removeEventListener(Yc,a)}},[W,zo]),l.jsxs($l,{className:"autoruns-frame",title:"",hideHeader:!0,children:[l.jsxs("div",{className:"autoruns-columns",children:[je?l.jsxs("section",{className:"autoruns-col autoruns-settings-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Настройки"})}),l.jsxs("div",{className:"autoruns-settings-stack",children:[l.jsx(Zf,{embedded:!0,value:i,modelOptions:h,modelsBusy:m,onChange:I,onReloadModels:Q,onSaveLocalConfig:le,onTestConnection:te,lastStatus:R,busy:E}),l.jsx(em,{embedded:!0,value:z,onChange:Y,presets:X,selectedPresetId:ee,onSelectPreset:Me,onLoadPreset:ue,onSavePreset:ce,onResetDefaults:pe,onDiffPrevious:Ve,presetName:Xe,onPresetNameChange:We,diffSummary:Ae})]})]}):null,Be?l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Автопрогоны"})}),l.jsx("h4",{children:"Настройки выборки"}),l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Дата с",l.jsx("input",{type:"datetime-local",value:B.fromLocal,onChange:a=>Le(c=>({...c,fromLocal:a.target.value}))})]}),l.jsxs("label",{children:["Дата по",l.jsx("input",{type:"datetime-local",value:B.toLocal,onChange:a=>Le(c=>({...c,toLocal:a.target.value}))})]}),l.jsxs("label",{children:["Целевой контур",l.jsxs("select",{value:B.target,onChange:a=>Le(c=>({...c,target:a.target.value})),children:[l.jsx("option",{value:"all",children:"все"}),(Z?.available.targets??[]).map(a=>l.jsx("option",{value:a,children:a},a))]})]}),l.jsxs("label",{children:["Режим",l.jsxs("select",{value:B.mode,onChange:a=>Le(c=>({...c,mode:a.target.value})),children:[l.jsx("option",{value:"all",children:"все"}),(Z?.available.modes??[]).map(a=>l.jsx("option",{value:a,children:a},a))]})]}),l.jsxs("label",{children:["Использовать mock",l.jsxs("select",{value:B.useMock,onChange:a=>Le(c=>({...c,useMock:a.target.value})),children:[l.jsx("option",{value:"any",children:"любой"}),l.jsx("option",{value:"true",children:"да"}),l.jsx("option",{value:"false",children:"нет"})]})]}),l.jsxs("label",{children:["Лимит",l.jsx("input",{type:"number",min:1,max:500,value:Ht,onChange:a=>{const c=a.target.value;(c===""||/^\d+$/.test(c))&&gr(c)},onBlur:a=>vs(a.target.value),onKeyDown:a=>{a.key==="Enter"&&vs(a.target.value)}})]}),l.jsxs("label",{className:"full-width",children:["Версия промпта содержит",l.jsx("input",{value:B.promptContains,onChange:a=>Le(c=>({...c,promptContains:a.target.value})),placeholder:"normalizer_v2_0_2 / address_query_runtime_v1",list:"autoruns-prompt-versions"})]})]}),l.jsx("datalist",{id:"autoruns-prompt-versions",children:(Z?.available.prompt_versions??[]).map(a=>l.jsx("option",{value:a},a))}),l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",disabled:mr,onClick:()=>{tt({keepSelection:!1})},children:mr?"Обновляю...":"Применить"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>{Le({...ka,fromLocal:ed()}),Je("")},children:"Сбросить фильтры"})]}),l.jsx("h4",{children:"Контур генерации"}),l.jsxs("div",{className:"autoruns-meta-list",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Провайдер:"}),l.jsx("strong",{children:i.llmProvider})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Модель:"}),l.jsx("strong",{children:i.model||"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Промпт ассистента:"}),l.jsx("strong",{children:$})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Промпт декомпозиции:"}),l.jsx("strong",{children:oe})]})]}),l.jsx("h4",{children:"Автопрогоны"}),l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Режимы",l.jsxs("select",{value:G.mode,onChange:a=>mt(c=>({...c,mode:a.target.value})),children:[l.jsx("option",{value:"codex_creative",children:"codex_creative"}),l.jsx("option",{value:"qwen_seed",children:"qwen_seed"}),l.jsx("option",{value:"saved_user_sessions",children:"Пользовательские сессии"})]})]}),bt?null:l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Кол-во",l.jsx("input",{type:"number",min:1,max:200,value:Fl,onChange:a=>{const c=a.target.value;(c===""||/^\d+$/.test(c))&&vr(c)},onBlur:a=>Kr(a.target.value),onKeyDown:a=>{a.key==="Enter"&&Kr(a.target.value)}})]}),l.jsxs("label",{children:["Личность автогенерации",l.jsx("select",{value:G.personalityId,onChange:a=>mt(c=>({...c,personalityId:a.target.value})),children:jt.map(a=>l.jsx("option",{value:a.id,children:a.label},a.id))})]}),l.jsxs("label",{children:["Кто генерирует",l.jsx("input",{value:G.generatedBy,onChange:a=>mt(c=>({...c,generatedBy:a.target.value})),placeholder:"manual_reviewer"})]}),l.jsxs("label",{className:"full-width",children:["Промпт личности",l.jsx("textarea",{className:"autoruns-personality-prompt",value:G.personalityPrompts[G.personalityId]??"",onChange:a=>mt(c=>({...c,personalityPrompts:{...c.personalityPrompts,[c.personalityId]:a.target.value}})),placeholder:"Текст промпта для выбранной личности автогенерации",style:{height:`${yr}px`},onMouseUp:Ks,onTouchEnd:Ks})]}),l.jsxs("label",{className:"checkbox-row",children:[l.jsx("input",{type:"checkbox",checked:G.persistToEvalCases,onChange:a=>mt(c=>({...c,persistToEvalCases:a.target.checked}))}),"Сохранять кейс-сет в `eval_cases`"]})]})]}),bt?null:l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Дата анализа (срез)",l.jsx("input",{type:"date",value:Ke,onChange:a=>ne(Ca(a.target.value))})]}),l.jsx("div",{className:"button-row",children:l.jsx("button",{type:"button",className:"tab",disabled:!Ke,onClick:()=>ne(""),children:"Сбросить дату среза"})})]}),l.jsxs("div",{className:"button-row",children:[bt?null:l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",disabled:dr,onClick:()=>{xs()},children:dr?"Генерирую...":"Сгенерировать пачку"}),l.jsx("button",{type:"button",className:"tab",disabled:qn,onClick:()=>{vn()},children:qn?"Обновляю...":"Обновить историю"})]}),l.jsx("button",{type:"button",className:"autoruns-run-launch-btn",disabled:Ur||ge.length===0||!$e,onClick:()=>{Yr()},children:Ur?"Запускаю...":"Запустить прогон"})]}),l.jsx("div",{className:"autoruns-form-grid",children:l.jsxs("label",{className:"full-width",children:[bt?"Сохраненная сессия":"Кейс-сет для запуска",l.jsxs("select",{value:Gn,onChange:a=>En(a.target.value),disabled:Tt.length===0,children:[Tt.length===0?l.jsx("option",{value:"",children:bt?"нет сохраненных сессий":"нет генераций"}):null,Tt.map(a=>l.jsxs("option",{value:a.generation_id,children:[ln(a.created_at)," | ",td(a)??Na(a.mode)," | ",a.count]},a.generation_id))]})]})}),l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"autoruns-generated-questions",children:[l.jsx("div",{className:"autoruns-generated-questions-head",children:l.jsxs("strong",{children:["Вопросы к запуску: ",ge.length]})}),ge.length===0?l.jsx("p",{className:"muted",children:bt?"Список вопросов пуст. Сначала сохраните живую пользовательскую сессию.":"Список вопросов пуст. Сгенерируйте пачку или добавьте вопрос вручную."}):l.jsx("div",{className:"autoruns-generated-questions-list",children:ge.map((a,c)=>l.jsxs("div",{className:["autoruns-generated-question-item",Kn===c?"drag-over":"",$r===c?"dragging":"",ot===c?"editing":""].filter(Boolean).join(" "),onDragOver:f=>ql(f,c),onDrop:f=>{Jl(f,c)},children:[l.jsx("button",{type:"button",className:"autoruns-question-grip-btn",draggable:!Jt&&ot!==c,disabled:Jt||ot===c,onDragStart:f=>Kl(f,c),onDragEnd:Yl,title:"Перетащить вопрос","aria-label":`Перетащить вопрос ${c+1}`,children:l.jsx(am,{})}),ot===c?l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:fs,className:"autoruns-generated-question-input",value:cr,onChange:f=>Tn(f.target.value),onBlur:Vl,onKeyDown:Wl,placeholder:"Текст вопроса",disabled:Jt}),l.jsx("button",{type:"button",className:"autoruns-remove-question-btn",onMouseDown:f=>f.preventDefault(),onClick:()=>{Io(c)},title:"Удалить вопрос","aria-label":`Удалить вопрос ${c+1}`,disabled:Jt,children:"×"})]}):l.jsxs("button",{type:"button",className:"autoruns-generated-question-text",onDoubleClick:()=>Js(c),title:"Двойной клик для редактирования",children:[c+1,". ",a]})]},`${c}-${a.slice(0,24)}`))}),l.jsx("button",{type:"button",className:"autoruns-add-question-btn",onClick:()=>{Gl()},disabled:!$e||Jt,children:"+"})]}),bt?l.jsx("h4",{children:"Сохраненные пользовательские сессии"}):l.jsx("p",{className:"muted",children:"Запуск выполняет `assistant_stage1` eval по выбранному кейс-сету."})]}),l.jsxs("div",{className:"autoruns-autogen-list",children:[qn?l.jsx("p",{className:"muted",children:bt?"Загружаю сохраненные пользовательские сессии...":"Загружаю историю автогенераций..."}):null,!qn&&Tt.length===0?l.jsx("p",{className:"muted",children:bt?"Сохраненные пользовательские сессии пока пусты.":"История автогенераций пока пустая."}):null,Tt.slice(0,30).map(a=>l.jsxs("article",{className:Gn===a.generation_id?"autoruns-autogen-item selected":"autoruns-autogen-item",onClick:()=>En(a.generation_id),children:[l.jsxs("header",{children:[l.jsx("strong",{children:td(a)}),l.jsxs("div",{className:"autoruns-autogen-card-actions",children:[l.jsx("span",{children:ln(a.created_at)}),l.jsx("button",{type:"button",className:"autoruns-autogen-delete-btn",onClick:c=>{c.preventDefault(),c.stopPropagation(),Ys(a)},title:"Удалить сохраненный набор","aria-label":`Удалить набор ${a.generation_id}`,children:"×"})]})]}),l.jsxs("div",{className:"autoruns-run-meta autoruns-run-id-row",children:[l.jsx("span",{children:a.generation_id}),l.jsx("span",{role:"button",tabIndex:0,className:"autoruns-copy-run-id-btn",onClick:c=>{Fn(c,a.generation_id,"set id")},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),Fn(c,a.generation_id,"set id"))},title:"Скопировать id набора","aria-label":`Скопировать id набора ${a.generation_id}`,children:l.jsx(ld,{})})]}),l.jsxs("div",{className:"autoruns-run-meta",children:["режим=",Na(a.mode)]}),l.jsxs("div",{className:"autoruns-run-meta",children:["тип=",md(a)?"АГЕНТНЫЙ ПРОГОН":"АВТОПРОГОН"]})]},a.generation_id))]}),l.jsxs("details",{className:"autoruns-prompt-details",children:[l.jsx("summary",{children:"Копия активного промпта (только чтение)"}),l.jsxs("label",{children:["Системный",l.jsx("textarea",{readOnly:!0,value:z.systemPrompt})]}),l.jsxs("label",{children:["Разработчика",l.jsx("textarea",{readOnly:!0,value:z.developerPrompt})]}),l.jsxs("label",{children:["Доменный",l.jsx("textarea",{readOnly:!0,value:z.domainPrompt})]}),l.jsxs("label",{children:["Заметки по схеме",l.jsx("textarea",{readOnly:!0,value:z.schemaNotes})]}),l.jsxs("label",{children:["Примеры few-shot",l.jsx("textarea",{readOnly:!0,value:z.fewShotExamples})]})]}),Dn?l.jsx("p",{className:"error-text",children:Dn}):null]}):null,l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Выдача прогонов"})}),l.jsxs("div",{className:"autoruns-stats-grid",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Всего"}),l.jsx("strong",{children:(Z?.stats.runs_total??0)+(Qe?1:0)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Средний score"}),l.jsx("strong",{children:Il(Z?.stats.avg_score_index??null)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Тренд"}),l.jsx("strong",{children:Z?nd(Z.stats.trend):"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Блокеры"}),l.jsx("strong",{children:Z?.stats.blocking_runs??0})]})]}),l.jsxs("div",{className:"autoruns-run-list",children:[ms.map(a=>l.jsxs("button",{type:"button",className:Pe===a.run_id?"autoruns-run-item selected":"autoruns-run-item",onClick:()=>{yn(a.run_id)},children:[l.jsxs("div",{className:"autoruns-run-head",children:[l.jsx("strong",{children:ln(a.run_timestamp)}),l.jsx("span",{children:lm(a.eval_target)})]}),l.jsxs("div",{className:"autoruns-run-meta autoruns-run-id-row",children:[l.jsx("span",{children:a.run_id}),l.jsx("span",{role:"button",tabIndex:0,className:"autoruns-copy-run-id-btn",onClick:c=>{Fn(c,a.run_id,"run id")},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),Fn(c,a.run_id,"run id"))},title:"Скопировать run id","aria-label":`Скопировать run id ${a.run_id}`,children:l.jsx(ld,{})})]}),l.jsxs("div",{className:"autoruns-run-meta",children:["режим=",a.mode??"нет данных"," | mock=",String(a.use_mock)]}),l.jsxs("div",{className:"autoruns-run-meta",children:["analysis_date=",a.analysis_date??"current_state"]}),a.llm_provider||a.model?l.jsxs("div",{className:"autoruns-run-meta",children:["llm=",a.llm_provider??"нет данных"," | модель=",a.model??"нет данных"]}):null,l.jsxs("div",{className:"autoruns-run-meta",children:["промпт=",a.prompt_version??"нет данных"]}),l.jsxs("div",{className:"autoruns-run-foot",children:[l.jsxs("span",{children:["оценка: ",Il(a.score_index)]}),l.jsxs("span",{children:["закрыто/открыто: ",a.closed_cases,"/",a.open_cases]})]}),l.jsxs("div",{className:"autoruns-run-foot",children:[l.jsxs("span",{children:["блокеры: ",a.blocking_failures]}),l.jsxs("span",{children:["качество: ",a.quality_failures]})]})]},a.run_id)),ms.length===0?l.jsx("p",{className:"muted",children:"За выбранный диапазон прогонов нет."}):null]})]}),l.jsxs("section",{className:"autoruns-col",children:[l.jsxs("div",{className:"autoruns-col-header",children:[l.jsx("h3",{children:"Диалог прогона"}),l.jsxs("div",{className:"autoruns-dialog-toolbar",children:[l.jsxs("label",{children:["Прогон",l.jsx("select",{value:Pe,onChange:a=>{const c=a.target.value;yn(c)},children:ms.map(a=>l.jsxs("option",{value:a.run_id,children:[ln(a.run_timestamp)," | ",a.run_id]},a.run_id))})]}),l.jsxs("label",{children:["Кейс",l.jsxs("select",{value:st,onChange:a=>{const c=a.target.value;vt(c),Pe&&c&&Un(Pe,c)},children:[(F?.cases.length??0)>0?l.jsx("option",{value:kt,children:"ВСЕ кейсы подряд"}):null,(F?.cases??[]).map(a=>l.jsxs("option",{value:a.case_id,children:[a.case_id," | ",a.status]},a.case_id))]})]})]})]}),l.jsxs("div",{className:"autoruns-case-list",children:[(F?.cases.length??0)>0?l.jsxs("button",{type:"button",className:st===kt?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{vt(kt),Pe&&Un(Pe,kt)},children:[l.jsx("span",{children:"ВСЕ кейсы подряд"}),l.jsx("span",{children:F?.cases.length})]},kt):null,(F?.cases??[]).map(a=>l.jsxs("button",{type:"button",className:st===a.case_id?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{vt(a.case_id),Pe&&Un(Pe,a.case_id)},children:[l.jsx("span",{children:a.case_id}),l.jsxs("span",{children:[a.status,a.commented_count>0?` | комм=${a.commented_count}`:""]})]},a.case_id))]}),l.jsxs("div",{className:"autoruns-dialog-view",children:[b||C?l.jsx("p",{className:"muted",children:"Загружаю диалог..."}):null,!b&&!C&&(y?.messages.length??0)===0?l.jsx("p",{className:"muted",children:"Диалог для этого прогона не найден."}):null,(y?.messages??[]).map((a,c)=>{const f=a.role==="assistant"?"assistant":"user";return l.jsxs("article",{className:`autoruns-msg ${f}`,children:[l.jsxs("header",{children:[l.jsx("strong",{children:f==="assistant"?"Система":"Модель/вопрос"}),l.jsxs("div",{className:"autoruns-msg-head-actions",children:[a.case_id?l.jsx("span",{className:"autoruns-msg-case-tag",children:a.case_id}):null,l.jsx("span",{children:a.created_at?ln(a.created_at):"нет данных"}),f==="assistant"&&!Hs(Pe)?l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:a.commented?"autoruns-comment-icon commented":"autoruns-comment-icon",onClick:()=>Ql(a),title:"\\u041a\\u043e\\u043c\\u043c\\u0435\\u043d\\u0442\\u0438\\u0440\\u043e\\u0432\\u0430\\u0442\\u044c \\u043e\\u0442\\u0432\\u0435\\u0442 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u044b","aria-label":"\\u041a\\u043e\\u043c\\u043c\\u0435\\u043d\\u0442\\u0438\\u0440\\u043e\\u0432\\u0430\\u0442\\u044c \\u043e\\u0442\\u0432\\u0435\\u0442 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u044b",children:l.jsx(im,{commented:a.commented})}),a.annotation?l.jsx("button",{type:"button",className:a.annotation.resolved?"autoruns-resolve-toggle resolved":"autoruns-resolve-toggle",onClick:()=>{Oo(a.annotation,!a.annotation.resolved)},disabled:Eo===a.annotation.annotation_id,title:a.annotation.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный","aria-label":a.annotation.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный",children:l.jsx(od,{resolved:a.annotation.resolved})}):null]}):null]})]}),l.jsx("p",{children:a.text}),f==="assistant"&&a.annotation?l.jsxs("div",{className:"autoruns-msg-annotation",children:[l.jsx("strong",{children:Ea(a.annotation.rating)}),l.jsx("span",{children:a.annotation.comment}),l.jsxs("span",{className:"muted",children:[a.annotation.manual_case_decision,a.annotation.annotation_author?` | ${a.annotation.annotation_author}`:""]})]}):null,(a.trace_id||a.reply_type)&&l.jsxs("footer",{children:[a.trace_id?l.jsxs("span",{children:["trace=",a.trace_id]}):null,a.reply_type?l.jsxs("span",{children:["reply_type=",a.reply_type]}):null]})]},a.message_id??`${f}-${c}`)})]})]}),gt?l.jsx("div",{className:"autoruns-col autoruns-assistant-live-col",children:l.jsx(qf,{sessionId:et,conversation:Qt,inputValue:Vs,onInputChange:Ws,selectedContextChip:De,onSelectContextChip:Gs,onClearContextChip:()=>Gs(null),useMock:Br,onUseMockChange:To,onSend:gs,onClear:wr,onSaveSession:Ul,busy:Qr,saveBusy:Et.saving,saveDisabled:!et.trim()||Qt.length===0||Qr,statusText:Mo,errorMessage:Yt,showSaveAction:!0,showCommentAction:!0,onCommentAssistantMessage:Lo,isAssistantMessageCommented:_s,canCommentAssistantMessage:Xr})}):null,ct?l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Прогресс / регресс"})}),l.jsxs("div",{className:"autoruns-stats-grid",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Последний score"}),l.jsx("strong",{children:Il(Z?.stats.latest_score_index??null)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Предыдущий"}),l.jsx("strong",{children:Il(Z?.stats.previous_score_index??null)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Тренд"}),l.jsx("strong",{children:Z?nd(Z.stats.trend):"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Пробелы качества"}),l.jsx("strong",{children:Z?.stats.quality_gap_runs??0})]})]}),l.jsx("h4",{children:"Покрытие доменов (история)"}),rd(Z?.stats.domain_coverage??[]),l.jsx("h4",{style:{marginTop:14},children:"Покрытие доменов (выбранный прогон)"}),rd(F?.coverage.domain_coverage??[]),l.jsx("h4",{style:{marginTop:14},children:"Очереди фиксов пост-анализа"}),An?l.jsx("p",{className:"muted",children:"Собираю пост-анализ..."}):null,An?null:l.jsx("div",{className:"autoruns-stats-grid",children:Object.entries(de?.post_analysis.stats.by_queue??{}).map(([a,c])=>l.jsxs("div",{children:[l.jsx("span",{children:a}),l.jsx("strong",{children:c})]},a))}),l.jsxs("div",{className:"autoruns-autogen-list",children:[(de?.post_analysis.recommended_regression_candidates??[]).slice(0,12).map(a=>l.jsxs("article",{className:"autoruns-autogen-item",children:[l.jsxs("header",{children:[l.jsx("strong",{children:a.manual_case_decision}),l.jsxs("span",{children:[a.rating,"/5"]})]}),l.jsxs("div",{className:"autoruns-run-meta",children:[a.domain??"неизвестно"," / ",a.query_class??"неизвестно"]}),l.jsx("p",{children:a.comment})]},a.annotation_id)),!An&&(de?.post_analysis.recommended_regression_candidates.length??0)===0?l.jsx("p",{className:"muted",children:"Рекомендованных кандидатов пока нет."}):null]})]}):null,Ut?l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Комментарии"})}),l.jsx("h4",{children:"Размеченные ответы"}),l.jsxs("div",{className:"autoruns-comment-filter-row",children:[l.jsxs("label",{children:["Фильтр решений",l.jsxs("select",{value:ae,onChange:a=>he(a.target.value),children:[l.jsx("option",{value:"all",children:"все"}),(qt.length>0?qt:we?.enum??[]).map(a=>l.jsx("option",{value:a,children:String(we?.labels?.[a]??a)},a))]})]}),l.jsx("button",{type:"button",className:"tab autoruns-resolved-filter-toggle",onClick:()=>xe(a=>!a),children:ye?"Показать выполненные":"Скрыть выполненные"})]}),l.jsxs("div",{className:"autoruns-stats-grid",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Комментариев"}),l.jsx("strong",{children:lt.length})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Средний рейтинг"}),l.jsx("strong",{children:Ao===null?"нет данных":`${Ao.toFixed(2)} / 5`})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Последний"}),l.jsx("strong",{children:lt.length>0?ln(lt[0].updated_at):"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Статус"}),l.jsx("strong",{children:qe?"обновляю":"готово"})]})]}),l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",disabled:qe,onClick:()=>{Lt()},children:qe?"Обновляю...":"Обновить список"}),l.jsx("button",{type:"button",className:"tab",disabled:An,onClick:()=>{Xt()},children:An?"Идет пост-анализ...":"Обновить пост-анализ"})]}),l.jsxs("div",{className:"autoruns-comments-list",children:[qe?l.jsx("p",{className:"muted",children:"Загружаю комментарии..."}):null,!qe&<.length===0?l.jsx("p",{className:"muted",children:re.length===0&&pr.length===0?"Пока нет откомментированных ответов.":"Нет открытых кейсов по текущему фильтру."}):null,lt.map(a=>{if(a.source==="assistant_live"){const f=a.assistant;return l.jsxs("article",{className:"autoruns-comment-item",children:[l.jsxs("div",{className:"autoruns-comment-head",children:[l.jsx("strong",{children:Ea(f.rating)}),l.jsx("div",{className:"autoruns-comment-head-actions",children:l.jsx("span",{children:ln(f.updated_at)})})]}),l.jsxs("div",{className:"autoruns-run-meta",children:["live-session: ",f.session_id]}),l.jsxs("div",{className:"autoruns-run-meta",children:["msg=",f.message_index]}),l.jsxs("div",{className:"autoruns-run-meta",children:["source=assistant_live",f.annotation_author?` | author=${f.annotation_author}`:""]}),f.context.question_text?l.jsxs("p",{children:["Q: ",f.context.question_text]}):null,f.context.answer_text?l.jsxs("p",{children:["A: ",f.context.answer_text]}):null,l.jsx("p",{children:f.comment})]},a.key)}const c=a.autorun;return l.jsxs("article",{className:Cn===c.annotation_id?"autoruns-comment-item selected":"autoruns-comment-item",onClick:()=>{Xs(c)},role:"button",tabIndex:0,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),Xs(c))},children:[l.jsxs("div",{className:"autoruns-comment-head",children:[l.jsx("strong",{children:Ea(c.rating)}),l.jsxs("div",{className:"autoruns-comment-head-actions",children:[l.jsx("span",{children:ln(c.updated_at)}),l.jsx("button",{type:"button",className:c.resolved?"autoruns-resolve-toggle resolved":"autoruns-resolve-toggle",onClick:f=>{f.preventDefault(),f.stopPropagation(),Oo(c,!c.resolved)},disabled:Eo===c.annotation_id,title:c.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный","aria-label":c.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный",children:l.jsx(od,{resolved:c.resolved})})]})]}),l.jsx("div",{className:"autoruns-run-meta",children:c.run_id}),l.jsxs("div",{className:"autoruns-run-meta",children:["case=",c.case_id," | msg=",c.message_index]}),l.jsxs("div",{className:"autoruns-run-meta",children:["decision=",c.manual_case_decision,c.annotation_author?` | author=${c.annotation_author}`:""]}),c.resolved_at?l.jsxs("div",{className:"autoruns-run-meta",children:["выполнено",": ",ln(c.resolved_at),c.resolved_by?` | by=${c.resolved_by}`:""]}):null,c.context.question_text?l.jsxs("p",{children:["Q: ",c.context.question_text]}):null,c.context.answer_text?l.jsxs("p",{children:["A: ",c.context.answer_text]}):null,l.jsx("p",{children:c.comment})]},a.key)})]}),Te?l.jsxs(l.Fragment,{children:[l.jsx("h4",{children:"Тех-контекст брака"}),l.jsxs("div",{className:"autoruns-meta-list",children:[l.jsxs("div",{children:[l.jsx("span",{children:"trace:"}),l.jsx("strong",{children:Te.technical_context.trace_id??"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"reply_type:"}),l.jsx("strong",{children:Te.technical_context.reply_type??"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"domain:"}),l.jsx("strong",{children:Te.technical_context.domain??"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"query_class:"}),l.jsx("strong",{children:Te.technical_context.query_class??"нет данных"})]})]}),l.jsx("h4",{children:"JSON разбор"}),l.jsx(dd,{value:{annotation_id:Te.annotation_id,run_id:Te.run_id,case_id:Te.case_id,message_index:Te.message_index,rating:Te.rating,comment:Te.comment,manual_case_decision:Te.manual_case_decision,annotation_author:Te.annotation_author,resolved:Te.resolved,resolved_at:Te.resolved_at,resolved_by:Te.resolved_by,context:Te.context,technical_context:Te.technical_context,case_summary:Te.case_summary?{case_id:Te.case_summary.case_id,domain:Te.case_summary.domain,query_class:Te.case_summary.query_class,checks:Te.case_summary.checks,metric_subscores:Te.case_summary.metric_subscores}:null}})]}):null]}):null]}),Et.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&Xn()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Сохранить ручную сессию"}),l.jsx("p",{className:"muted",children:"Технический чат будет сохранен в автопрогоны как пользовательская multi-turn сессия."}),l.jsxs("label",{children:["Название",l.jsx("input",{value:Et.title,onChange:a=>zn(c=>({...c,title:a.target.value})),placeholder:"Например: НДС и склад на март 2020",disabled:Et.saving})]}),Et.error?l.jsx("p",{className:"error-text",children:Et.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{Bl()},disabled:Et.saving,children:Et.saving?"Сохраняю...":"Сохранить"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>Xn(),disabled:Et.saving,children:"Отмена"})]})]})}):null,Pt.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&Wr()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Удалить вопрос"}),l.jsx("p",{className:"muted",children:"Действительно удалить вопрос из сохраненной пользовательской сессии?"}),l.jsx("p",{className:"autoruns-comment-quote",children:Pt.questionText}),Pt.error?l.jsx("p",{className:"error-text",children:Pt.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{bl()},disabled:Pt.saving,children:Pt.saving?"Удаляю...":"Да"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>Wr(),disabled:Pt.saving,children:"Нет"})]})]})}):null,pn.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&hs()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Удалить сохраненный набор"}),l.jsx("p",{className:"muted",children:"Будет удалена карточка истории и связанный файл кейс-сета на бэке."}),l.jsx("p",{className:"autoruns-comment-quote",children:pn.title}),pn.error?l.jsx("p",{className:"error-text",children:pn.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{Xl()},disabled:pn.saving,children:pn.saving?"Удаляю...":"Да"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>hs(),disabled:pn.saving,children:"Нет"})]})]})}):null,Ne.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&Yn()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Комментарий к ответу ассистента"}),l.jsx("p",{className:"muted",children:"Комментарий будет добавлен в общий список комментариев справа с меткой `assistant_live`."}),Sr?l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Вопрос пользователя"}),l.jsx("p",{className:"autoruns-comment-quote",children:Sr.text})]}):null,_r?l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Ответ ассистента"}),l.jsx("p",{className:"autoruns-comment-quote",children:_r.text})]}):null,l.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа ассистента",children:[1,2,3,4,5].map(a=>l.jsx("button",{type:"button",className:Ne.rating>=a?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>fn(c=>({...c,rating:a})),disabled:Ne.saving,"aria-label":`Оценка ${a}`,children:Ne.rating>=a?"●":"○"},a))}),l.jsx("div",{className:"autoruns-form-grid",children:l.jsxs("label",{children:["Автор комментария",l.jsx("input",{value:Ne.annotationAuthor,onChange:a=>fn(c=>({...c,annotationAuthor:a.target.value})),placeholder:"manual_reviewer",disabled:Ne.saving})]})}),l.jsxs("label",{children:["Комментарий",l.jsx("textarea",{value:Ne.comment,onChange:a=>fn(c=>({...c,comment:a.target.value})),placeholder:"Что именно не так в ответе и что нужно исправить.",rows:4,disabled:Ne.saving})]}),Ne.error?l.jsx("p",{className:"error-text",children:Ne.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{Hl()},disabled:Ne.saving,children:Ne.saving?"Сохраняю...":"Готово"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>Yn(),disabled:Ne.saving,children:"Отмена"})]})]})}):null,fe.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&kr()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Комментарий к ответу системы"}),l.jsx("p",{className:"muted",children:"Оцените ответ по 5-балльной шкале и добавьте комментарий по браку."}),gn?l.jsxs(l.Fragment,{children:[l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Вопрос пользователя"}),l.jsx("p",{className:"autoruns-comment-quote",children:$n?.text??"Вопрос в диалоге не найден."})]}),l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Ответ системы"}),l.jsx("p",{className:"autoruns-comment-quote",children:gn.text})]})]}):null,l.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа",children:[1,2,3,4,5].map(a=>l.jsx("button",{type:"button",className:fe.rating>=a?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>Nt(c=>({...c,rating:a})),disabled:fe.saving,"aria-label":`Оценка ${a}`,children:fe.rating>=a?"●":"○"},a))}),l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Решение по кейсу",l.jsx("select",{value:fe.manualCaseDecision,onChange:a=>Nt(c=>({...c,manualCaseDecision:a.target.value})),disabled:fe.saving,children:(qt.length>0?qt:we?.enum??[Al]).map(a=>l.jsx("option",{value:a,children:String(we?.labels?.[a]??a)},a))})]}),l.jsxs("label",{children:["Автор комментария",l.jsx("input",{value:fe.annotationAuthor,onChange:a=>Nt(c=>({...c,annotationAuthor:a.target.value})),placeholder:"manual_reviewer",disabled:fe.saving})]})]}),l.jsxs("label",{children:["Комментарий",l.jsx("textarea",{value:fe.comment,onChange:a=>Nt(c=>({...c,comment:a.target.value})),placeholder:"Почему ответ бракованный, что именно пошло не так, какие технические детали проверить.",rows:4,disabled:fe.saving})]}),fe.error?l.jsx("p",{className:"error-text",children:fe.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{qs()},disabled:fe.saving,children:fe.saving?"Сохраняю...":"Готово"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>kr(),disabled:fe.saving,children:"Отмена"})]})]})}):null]})}const cm={llmProvider:"openai",apiKey:"",model:"gpt-4o-mini",baseUrl:"https://api.openai.com/v1",temperature:0,maxOutputTokens:700},id={systemPrompt:"Ты semantic-normalizer для бухгалтерского ассистента NDC. Возвращай только JSON по схеме normalized_query_v2_0_2.",developerPrompt:"Сначала делай decomposition сообщения на task fragments, затем определяй domain scope и route-critical flags. Для каждого fragment заполняй execution_readiness + route_status + no_route_reason. Если fragment routable, не оставляй его в no_route.",domainPrompt:"Контур: данные текущего предприятия в 1С/NDC. In-scope: документы, проводки, взаиморасчеты, остатки, периодное закрытие, аномалии и контрольные проверки. Out-of-scope: общая теория, законы и оффтоп.",schemaNotes:"schema_version: normalized_query_v2_0_2. Строгий JSON без дополнительных полей.",fewShotExamples:"Q: Проверь по поставщикам хвосты и разложи цепочку документов/оплат. => fragment in_scope, flags: multi_entity + chain_explanation. Q: Как вообще по ФСБУ? => out_of_scope/generic_accounting."},dm={userQuestion:"",batchQuestionsRaw:"",periodHint:"",businessContext:"",expectedRoute:""},Pa={colors:{backgroundRgb:"18, 18, 18",mainSurfaceRgb:"25, 25, 25",horizontalSurfaceRgb:"30, 30, 30",focusSurfaceRgb:"35, 35, 35",assistantChipRgb:"18, 18, 18",assistantChipHoverRgb:"44, 44, 44",assistantChipSelectedRgb:"167, 59, 255",assistantChipSelectedTextRgb:"240, 240, 240",activeRgb:"167, 59, 255",activeTextRgb:"240, 240, 240",textMainRgb:"240, 240, 240",textMutedRgb:"166, 166, 166",dangerRgb:"126, 126, 126",scrollbarTrackRgb:"20, 20, 20",scrollbarThumbRgb:"30, 30, 30",scrollbarThumbHoverRgb:"30, 50, 30"},layout:{modeColumnWidthPx:406,modeToggleWidthPx:188}},ad="ndc_normalizer_session_config_v1",ud="ndc_autoruns_layout_config_v1",fm="ndc-autoruns-save",mm="autoruns",Ta="normalizer_v2_0_2",pm="address_query_runtime_v1",hm=["normalized","fragments","scope","flags","route","raw","validation","logs"];function gm(i){return`[${new Date().toLocaleTimeString("ru-RU")}] ${i}`}function vm(i,h){if(!h)return"Previous preset is not selected.";const R=["systemPrompt","developerPrompt","domainPrompt","schemaNotes","fewShotExamples"].filter(E=>i[E]!==h[E]).map(E=>`${E}: ${Math.abs(i[E].length-h[E].length)} chars delta`);return R.length===0?"No changes against previous preset.":`Changed fields: ${R.length}. ${R.join(" | ")}`}function ym(){const[i,h]=v.useState(cm),[m,R]=v.useState(id),[E,I]=v.useState(dm),[Q,le]=v.useState(null),[te,z]=v.useState([]),[Y,X]=v.useState([]),[ee,Me]=v.useState("normalized"),[ue,ce]=v.useState(!1),[pe,Ve]=v.useState(!1),[Xe,We]=v.useState([]),[Ae,$]=v.useState(""),[oe,je]=v.useState([]),[Be,gt]=v.useState(""),[ct,Ut]=v.useState("NDC custom preset"),[dt,B]=v.useState(null),[Le,Ke]=v.useState(""),[ne,Z]=v.useState(!1),[M,F]=v.useState([]),[A,y]=v.useState(""),[k,re]=v.useState([]),[ie,ae]=v.useState(!1),[he,ye]=v.useState(null),[xe,we]=v.useState(""),[ft,qt]=v.useState(mm),[ir,Cn]=v.useState(!0),[an,Pe]=v.useState(!0),[Bt,st]=v.useState(!0),[vt,jt]=v.useState(!0),[un,G]=v.useState(!0),[mt,ar]=v.useState(!0),[Nn,Gn]=v.useState(!0),[En,ge]=v.useState(!0),[At,Jt]=v.useState(!0),[Pn,ot]=v.useState(!0),[ur,cr]=v.useState(!0),[Tn,$r]=v.useState(!0),[cn,Kn]=v.useState(!0),Ct=v.useRef(!1),Qe=v.useRef(!1),Rn=v.useRef(!1);v.useEffect(()=>{const C=document.documentElement,{colors:J}=Pa;C.style.setProperty("--rgb-background",J.backgroundRgb),C.style.setProperty("--rgb-surface-main",J.mainSurfaceRgb),C.style.setProperty("--rgb-surface-horizontal",J.horizontalSurfaceRgb),C.style.setProperty("--rgb-surface-focus",J.focusSurfaceRgb),C.style.setProperty("--rgb-assistant-chip",J.assistantChipRgb),C.style.setProperty("--rgb-assistant-chip-hover",J.assistantChipHoverRgb),C.style.setProperty("--rgb-assistant-chip-selected",J.assistantChipSelectedRgb),C.style.setProperty("--rgb-assistant-chip-selected-text",J.assistantChipSelectedTextRgb),C.style.setProperty("--rgb-active",J.activeRgb),C.style.setProperty("--rgb-active-text",J.activeTextRgb),C.style.setProperty("--rgb-text-main",J.textMainRgb),C.style.setProperty("--rgb-text-muted",J.textMutedRgb),C.style.setProperty("--rgb-danger",J.dangerRgb),C.style.setProperty("--rgb-scrollbar-track",J.scrollbarTrackRgb),C.style.setProperty("--rgb-scrollbar-thumb",J.scrollbarThumbRgb),C.style.setProperty("--rgb-scrollbar-thumb-hover",J.scrollbarThumbHoverRgb),C.style.setProperty("--mode-column-width",`${Pa.layout.modeColumnWidthPx}px`),C.style.setProperty("--mode-toggle-width",`${Pa.layout.modeToggleWidthPx}px`)},[]);const de=C=>{X(J=>[gm(C),...J].slice(0,300))};v.useEffect(()=>{(async()=>{const b=localStorage.getItem(ad);if(b)try{const Ce=JSON.parse(b);h(qe=>({...qe,llmProvider:Ce.llmProvider==="local"?"local":"openai",model:Ce.model??qe.model,baseUrl:Ce.baseUrl??qe.baseUrl,temperature:Ce.temperature??qe.temperature,maxOutputTokens:Ce.maxOutputTokens??qe.maxOutputTokens}))}catch{}try{const Ce=await Re.loadSharedConnectionConfig();Ce.connection&&Ce.connection.llmProvider==="local"&&(h(qe=>({...qe,llmProvider:"local",model:Ce.connection?.model??qe.model,baseUrl:Ce.connection?.baseUrl??qe.baseUrl,temperature:Ce.connection?.temperature??qe.temperature,maxOutputTokens:Ce.connection?.maxOutputTokens??qe.maxOutputTokens})),de(`Shared local LLM config loaded: ${Ce.connection.model}`))}catch(Ce){de(`Shared local config load error: ${Ce instanceof Error?Ce.message:String(Ce)}`)}finally{Rn.current=!0}})();const J=localStorage.getItem(ud);if(J)try{const b=JSON.parse(J);(b.uiMode==="assistant"||b.uiMode==="autoruns"||b.uiMode==="decomposition")&&qt("autoruns"),b.activeTab&&hm.includes(b.activeTab)&&Me(b.activeTab),typeof b.showAutorunsSettingsMode=="boolean"&&Cn(b.showAutorunsSettingsMode),typeof b.showAutorunsAutoRunsMode=="boolean"&&Pe(b.showAutorunsAutoRunsMode),typeof b.showAutorunsAssistantMode=="boolean"&&st(b.showAutorunsAssistantMode),typeof b.showAutorunsDecompositionMode=="boolean"&&jt(b.showAutorunsDecompositionMode),typeof b.showAutorunsProgressMode=="boolean"&&G(b.showAutorunsProgressMode),typeof b.showAutorunsCommentsMode=="boolean"&&ar(b.showAutorunsCommentsMode),typeof b.showDecompositionConnectionMode=="boolean"&&Gn(b.showDecompositionConnectionMode),typeof b.showDecompositionPromptMode=="boolean"&&ge(b.showDecompositionPromptMode),typeof b.showDecompositionQueryMode=="boolean"&&Jt(b.showDecompositionQueryMode),typeof b.showDecompositionOutputMode=="boolean"&&ot(b.showDecompositionOutputMode),typeof b.showDecompositionMetricsMode=="boolean"&&cr(b.showDecompositionMetricsMode),typeof b.showDecompositionHistoryMode=="boolean"&&$r(b.showDecompositionHistoryMode),typeof b.showDecompositionRuntimeMode=="boolean"&&Kn(b.showDecompositionRuntimeMode),b.prompts&&(R(Ce=>({...Ce,...b.prompts})),Qe.current=!0)}catch{}dn(),dr(),Fr()},[]),v.useEffect(()=>{if(!Rn.current||i.llmProvider!=="local")return;const C=window.setTimeout(()=>{Re.saveSharedConnectionConfig(i).catch(J=>de(`Shared local config sync error: ${J instanceof Error?J.message:String(J)}`))},250);return()=>window.clearTimeout(C)},[i.baseUrl,i.llmProvider,i.maxOutputTokens,i.model,i.temperature]);async function dn(){try{const C=await Re.loadHistory();z(C.items??[])}catch(C){de(`History load error: ${C instanceof Error?C.message:String(C)}`)}}async function dr(){try{const J=(await Re.loadPresets()).presets??[];if(je(J),Qe.current){Ct.current=!0;return}if(Ct.current)return;const b=J.find(Ce=>Ce.prompt_version===Ta)??J.find(Ce=>Ce.id==="default-normalizer-v2_0_2");if(!b){Ct.current=!0,de(`Preset autoload skipped: ${Ta} not found.`);return}gt(b.id),B(m),R({systemPrompt:b.systemPrompt,developerPrompt:b.developerPrompt,domainPrompt:b.domainPrompt,schemaNotes:b.schemaNotes??"",fewShotExamples:b.fewShotExamples??""}),Ct.current=!0,de(`Preset autoloaded: ${b.name} (${b.prompt_version}).`)}catch(C){de(`Presets load error: ${C instanceof Error?C.message:String(C)}`)}}async function Fr(){try{const C=await Re.listRuns();F(C.items??[])}catch(C){de(`Runs load error: ${C instanceof Error?C.message:String(C)}`)}}function Ur(){if(localStorage.setItem(ad,JSON.stringify({model:i.model,llmProvider:i.llmProvider,baseUrl:i.baseUrl,temperature:i.temperature,maxOutputTokens:i.maxOutputTokens})),i.llmProvider==="local"){Re.saveSharedConnectionConfig(i).then(()=>{de("Local config saved and synced to shared agent config (without API key).")}).catch(C=>{de(`Local config saved, but shared sync failed: ${C instanceof Error?C.message:String(C)}`)});return}de("Local config saved (without API key).")}function Mn(){localStorage.setItem(ud,JSON.stringify({uiMode:ft,activeTab:ee,showAutorunsSettingsMode:ir,showAutorunsAutoRunsMode:an,showAutorunsAssistantMode:Bt,showAutorunsDecompositionMode:vt,showAutorunsProgressMode:un,showAutorunsCommentsMode:mt,showDecompositionConnectionMode:Nn,showDecompositionPromptMode:En,showDecompositionQueryMode:At,showDecompositionOutputMode:Pn,showDecompositionMetricsMode:ur,showDecompositionHistoryMode:Tn,showDecompositionRuntimeMode:cn,prompts:m})),window.dispatchEvent(new CustomEvent(fm)),de("UI layout and prompts saved.")}async function An(){ce(!0),we("");try{const C=await Re.testConnection(i);C.provider==="local"?C.model_found===!0?($(`LOCAL OK - ${C.model}`),de(`Local model is available: ${C.model} (catalog size=${C.models_count??"n/a"}).`)):C.model_found===!1?($(`LOCAL OK, model not loaded - ${C.model}`),de(`Local server is reachable, but model '${C.model}' is not in loaded catalog. Use 'Load model list' and select one of loaded models.`)):($(`LOCAL OK (model list unavailable) - ${C.model}`),de("Local server is reachable, but model catalog could not be verified.")):($(`OPENAI OK - ${C.model}`),de(`OpenAI connection ok: ${C.model}`))}catch(C){const J=C instanceof Error?C.message:String(C);$("Connection error"),we(`Test connection: ${J}`),de(`Test connection error: ${J}`)}finally{ce(!1)}}async function fr(){Ve(!0);try{const J=(await Re.listModels(i)).models??[];We(J),J.length>0&&h(b=>b.model&&J.includes(b.model)?b:{...b,model:J[0]}),de(`Model catalog loaded (${i.llmProvider}): ${J.length} items.`)}catch(C){const J=C instanceof Error?C.message:String(C);de(`Load model list error: ${J}`)}finally{Ve(!1)}}v.useEffect(()=>{We([])},[i.llmProvider,i.baseUrl]);function qn(){const C=oe.find(J=>J.id===Be);if(!C){de("Preset is not selected.");return}B(m),R({systemPrompt:C.systemPrompt,developerPrompt:C.developerPrompt,domainPrompt:C.domainPrompt,schemaNotes:C.schemaNotes??"",fewShotExamples:C.fewShotExamples??""}),de(`Preset loaded: ${C.name}`)}async function Ln(){try{await Re.savePreset({name:ct||"NDC preset",prompt_version:"normalizer_v2_0_2",systemPrompt:m.systemPrompt,developerPrompt:m.developerPrompt,domainPrompt:m.domainPrompt,schemaNotes:m.schemaNotes,fewShotExamples:m.fewShotExamples}),de("Preset saved."),await dr()}catch(C){de(`Preset save error: ${C instanceof Error?C.message:String(C)}`)}}function mr(){R(id),de("Prompt panel reset to defaults.")}function In(){const C=vm(m,dt);Ke(C),de(C)}return v.useEffect(()=>{if(!A){re([]);return}Re.runTrace(A).then(C=>re(C.items)).catch(C=>de(`Run trace error: ${C instanceof Error?C.message:String(C)}`))},[A]),l.jsxs("main",{className:"app-root app-root-autoruns",children:[l.jsxs("header",{className:"app-topbar",children:[l.jsxs("div",{className:"mode-switch-row",children:[l.jsx("button",{type:"button",className:"tab active",onClick:()=>qt("autoruns"),children:"Управление ассистентом"}),l.jsx("button",{type:"button",className:"tab",onClick:Mn,children:"Сохранить"})]}),l.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[l.jsx("button",{type:"button",className:ir?"tab active":"tab",onClick:()=>Cn(C=>!C),children:"Настройки"}),l.jsx("button",{type:"button",className:an?"tab active":"tab",onClick:()=>Pe(C=>!C),children:"Автопрогоны"}),l.jsx("button",{type:"button",className:Bt?"tab active":"tab",onClick:()=>st(C=>!C),children:"Режим ассистента"}),l.jsx("button",{type:"button",className:un?"tab active":"tab",onClick:()=>G(C=>!C),children:"Прогресс/регресс"}),l.jsx("button",{type:"button",className:mt?"tab active":"tab",onClick:()=>ar(C=>!C),children:"Комментарии"})]})]}),l.jsx("div",{className:"layout-grid layout-grid-autoruns",children:l.jsx(um,{connection:i,modelOptions:Xe,modelsBusy:pe,connectionStatus:Ae,connectionBusy:ue,onConnectionChange:h,onReloadModels:fr,onSaveLocalConfig:Ur,onTestConnection:An,prompts:m,onPromptsChange:R,promptPresets:oe,selectedPresetId:Be,onSelectPreset:gt,onLoadPreset:qn,onSavePreset:Ln,onResetDefaults:mr,onDiffPrevious:In,presetName:ct,onPresetNameChange:Ut,diffSummary:Le,assistantPromptVersion:pm,decompositionPromptVersion:Ta,showSettingsMode:ir,showAutoRunsMode:an,showAssistantMode:Bt,showProgressMode:un,showCommentsMode:mt,onLog:de})})]})}Tf.createRoot(document.getElementById("root")).render(l.jsx(wf.StrictMode,{children:l.jsx(ym,{})})); diff --git a/llm_normalizer/frontend/dist/assets/index-C8U6PD78.js b/llm_normalizer/frontend/dist/assets/index-C8U6PD78.js deleted file mode 100644 index dca72dd..0000000 --- a/llm_normalizer/frontend/dist/assets/index-C8U6PD78.js +++ /dev/null @@ -1,24 +0,0 @@ -(function(){const h=document.createElement("link").relList;if(h&&h.supports&&h.supports("modulepreload"))return;for(const E of document.querySelectorAll('link[rel="modulepreload"]'))R(E);new MutationObserver(E=>{for(const L of E)if(L.type==="childList")for(const Q of L.addedNodes)Q.tagName==="LINK"&&Q.rel==="modulepreload"&&R(Q)}).observe(document,{childList:!0,subtree:!0});function f(E){const L={};return E.integrity&&(L.integrity=E.integrity),E.referrerPolicy&&(L.referrerPolicy=E.referrerPolicy),E.crossOrigin==="use-credentials"?L.credentials="include":E.crossOrigin==="anonymous"?L.credentials="omit":L.credentials="same-origin",L}function R(E){if(E.ep)return;E.ep=!0;const L=f(E);fetch(E.href,L)}})();function qc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Zi={exports:{}},vo={},ea={exports:{}},fe={};var jc;function xf(){if(jc)return fe;jc=1;var i=Symbol.for("react.element"),h=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),L=Symbol.for("react.provider"),Q=Symbol.for("react.context"),le=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),z=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),X=Symbol.iterator;function ee(v){return v===null||typeof v!="object"?null:(v=X&&v[X]||v["@@iterator"],typeof v=="function"?v:null)}var Te={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ce=Object.assign,de={};function pe(v,w,re){this.props=v,this.context=w,this.refs=de,this.updater=re||Te}pe.prototype.isReactComponent={},pe.prototype.setState=function(v,w){if(typeof v!="object"&&typeof v!="function"&&v!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,v,w,"setState")},pe.prototype.forceUpdate=function(v){this.updater.enqueueForceUpdate(this,v,"forceUpdate")};function Qe(){}Qe.prototype=pe.prototype;function Je(v,w,re){this.props=v,this.context=w,this.refs=de,this.updater=re||Te}var be=Je.prototype=new Qe;be.constructor=Je,ce(be,pe.prototype),be.isPureReactComponent=!0;var Re=Array.isArray,F=Object.prototype.hasOwnProperty,oe={current:null},Ce={key:!0,ref:!0,__self:!0,__source:!0};function $e(v,w,re){var ie,ae={},he=null,xe=null;if(w!=null)for(ie in w.ref!==void 0&&(xe=w.ref),w.key!==void 0&&(he=""+w.key),w)F.call(w,ie)&&!Ce.hasOwnProperty(ie)&&(ae[ie]=w[ie]);var _e=arguments.length-2;if(_e===1)ae.children=re;else if(1<_e){for(var we=Array(_e),lt=0;lt<_e;lt++)we[lt]=arguments[lt+2];ae.children=we}if(v&&v.defaultProps)for(ie in _e=v.defaultProps,_e)ae[ie]===void 0&&(ae[ie]=_e[ie]);return{$$typeof:i,type:v,key:he,ref:xe,props:ae,_owner:oe.current}}function dt(v,w){return{$$typeof:i,type:v.type,key:w,ref:v.ref,props:v.props,_owner:v._owner}}function st(v){return typeof v=="object"&&v!==null&&v.$$typeof===i}function Dt(v){var w={"=":"=0",":":"=2"};return"$"+v.replace(/[=:]/g,function(re){return w[re]})}var ot=/\/+/g;function H(v,w){return typeof v=="object"&&v!==null&&v.key!=null?Dt(""+v.key):w.toString(36)}function Me(v,w,re,ie,ae){var he=typeof v;(he==="undefined"||he==="boolean")&&(v=null);var xe=!1;if(v===null)xe=!0;else switch(he){case"string":case"number":xe=!0;break;case"object":switch(v.$$typeof){case i:case h:xe=!0}}if(xe)return xe=v,ae=ae(xe),v=ie===""?"."+H(xe,0):ie,Re(ae)?(re="",v!=null&&(re=v.replace(ot,"$&/")+"/"),Me(ae,w,re,"",function(lt){return lt})):ae!=null&&(st(ae)&&(ae=dt(ae,re+(!ae.key||xe&&xe.key===ae.key?"":(""+ae.key).replace(ot,"$&/")+"/")+v)),w.push(ae)),1;if(xe=0,ie=ie===""?".":ie+":",Re(v))for(var _e=0;_e>>1,w=M[v];if(0>>1;vE(ae,A))heE(xe,ae)?(M[v]=xe,M[he]=A,v=he):(M[v]=ae,M[ie]=A,v=ie);else if(heE(xe,A))M[v]=xe,M[he]=A,v=he;else break e}}return U}function E(M,U){var A=M.sortIndex-U.sortIndex;return A!==0?A:M.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var L=performance;i.unstable_now=function(){return L.now()}}else{var Q=Date,le=Q.now();i.unstable_now=function(){return Q.now()-le}}var te=[],z=[],Y=1,X=null,ee=3,Te=!1,ce=!1,de=!1,pe=typeof setTimeout=="function"?setTimeout:null,Qe=typeof clearTimeout=="function"?clearTimeout:null,Je=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function be(M){for(var U=f(z);U!==null;){if(U.callback===null)R(z);else if(U.startTime<=M)R(z),U.sortIndex=U.expirationTime,h(te,U);else break;U=f(z)}}function Re(M){if(de=!1,be(M),!ce)if(f(te)!==null)ce=!0,ne(F);else{var U=f(z);U!==null&&Z(Re,U.startTime-M)}}function F(M,U){ce=!1,de&&(de=!1,Qe($e),$e=-1),Te=!0;var A=ee;try{for(be(U),X=f(te);X!==null&&(!(X.expirationTime>U)||M&&!Dt());){var v=X.callback;if(typeof v=="function"){X.callback=null,ee=X.priorityLevel;var w=v(X.expirationTime<=U);U=i.unstable_now(),typeof w=="function"?X.callback=w:X===f(te)&&R(te),be(U)}else R(te);X=f(te)}if(X!==null)var re=!0;else{var ie=f(z);ie!==null&&Z(Re,ie.startTime-U),re=!1}return re}finally{X=null,ee=A,Te=!1}}var oe=!1,Ce=null,$e=-1,dt=5,st=-1;function Dt(){return!(i.unstable_now()-stM||125v?(M.sortIndex=A,h(z,M),f(te)===null&&M===f(z)&&(de?(Qe($e),$e=-1):de=!0,Z(Re,A-v))):(M.sortIndex=w,h(te,M),ce||Te||(ce=!0,ne(F))),M},i.unstable_shouldYield=Dt,i.unstable_wrapCallback=function(M){var U=ee;return function(){var A=ee;ee=U;try{return M.apply(this,arguments)}finally{ee=A}}}})(ra)),ra}var Tc;function jf(){return Tc||(Tc=1,na.exports=kf()),na.exports}var Rc;function Cf(){if(Rc)return It;Rc=1;var i=fa(),h=jf();function f(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),te=Object.prototype.hasOwnProperty,z=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Y={},X={};function ee(e){return te.call(X,e)?!0:te.call(Y,e)?!1:z.test(e)?X[e]=!0:(Y[e]=!0,!1)}function Te(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function ce(e,t,n,r){if(t===null||typeof t>"u"||Te(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function de(e,t,n,r,s,o,u){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=u}var pe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){pe[e]=new de(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];pe[t]=new de(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){pe[e]=new de(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){pe[e]=new de(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){pe[e]=new de(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){pe[e]=new de(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){pe[e]=new de(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){pe[e]=new de(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){pe[e]=new de(e,5,!1,e.toLowerCase(),null,!1,!1)});var Qe=/[\-:]([a-z])/g;function Je(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Qe,Je);pe[t]=new de(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Qe,Je);pe[t]=new de(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Qe,Je);pe[t]=new de(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){pe[e]=new de(e,1,!1,e.toLowerCase(),null,!1,!1)}),pe.xlinkHref=new de("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){pe[e]=new de(e,1,!1,e.toLowerCase(),null,!0,!0)});function be(e,t,n,r){var s=pe.hasOwnProperty(t)?pe[t]:null;(s!==null?s.type!==0:r||!(2d||s[u]!==o[d]){var m=` -`+s[u].replace(" at new "," at ");return e.displayName&&m.includes("")&&(m=m.replace("",e.displayName)),m}while(1<=u&&0<=d);break}}}finally{re=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?w(e):""}function ae(e){switch(e.tag){case 5:return w(e.type);case 16:return w("Lazy");case 13:return w("Suspense");case 19:return w("SuspenseList");case 0:case 2:case 15:return e=ie(e.type,!1),e;case 11:return e=ie(e.type.render,!1),e;case 1:return e=ie(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ce:return"Fragment";case oe:return"Portal";case dt:return"Profiler";case $e:return"StrictMode";case H:return"Suspense";case Me:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Dt:return(e.displayName||"Context")+".Consumer";case st:return(e._context.displayName||"Context")+".Provider";case ot:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case We:return t=e.displayName||null,t!==null?t:he(e.type)||"Memo";case ne:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}function xe(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(t);case 8:return t===$e?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function _e(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function we(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function lt(e){var t=we(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(u){r=""+u,o.call(this,u)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(u){r=""+u},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Kt(e){e._valueTracker||(e._valueTracker=lt(e))}function Xn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=we(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function wn(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function nn(e,t){var n=t.checked;return A({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Ee(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=_e(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ot(e,t){t=t.checked,t!=null&&be(e,"checked",t,!1)}function et(e,t){Ot(e,t);var n=_e(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?St(e,t.type,n):t.hasOwnProperty("defaultValue")&&St(e,t.type,_e(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ft(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function St(e,t,n){(t!=="number"||wn(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var rn=Array.isArray;function W(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=zt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function sn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var on={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Zr=["Webkit","ms","Moz","O"];Object.keys(on).forEach(function(e){Zr.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),on[t]=on[e]})});function Nr(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||on.hasOwnProperty(e)&&on[e]?(""+t).trim():t+"px"}function Er(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Nr(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var es=A({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ln(e,t){if(t){if(es[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(f(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(f(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(f(61))}if(t.style!=null&&typeof t.style!="object")throw Error(f(62))}}function an(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var un=null;function cn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var On=null,me=null,dn=null;function er(e){if(e=to(e)){if(typeof On!="function")throw Error(f(280));var t=e.stateNode;t&&(t=Do(t),On(e.stateNode,e.type,t))}}function Pr(e){me?dn?dn.push(e):dn=[e]:me=e}function Tr(){if(me){var e=me,t=dn;if(dn=me=null,er(e),t)for(e=0;e>>=0,e===0?32:31-(Fn(e)/$t|0)|0}var Et=64,Un=4194304;function Bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Hn(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,o=e.pingedLanes,u=n&268435455;if(u!==0){var d=u&~s;d!==0?r=Bn(d):(o&=u,o!==0&&(r=Bn(o)))}else u=n&~s,u!==0?r=Bn(u):o!==0&&(r=Bn(o));if(r===0)return 0;if(t!==0&&t!==r&&(t&s)===0&&(s=r&-r,o=t&-t,s>=o||s===16&&(o&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Ne(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ue(t),e[t]=n}function So(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ws),va=" ",ya=!1;function xa(e,t){switch(e){case"keyup":return md.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _a(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ds=!1;function hd(e,t){switch(e){case"compositionend":return _a(t);case"keypress":return t.which!==32?null:(ya=!0,va);case"textInput":return e=t.data,e===va&&ya?null:e;default:return null}}function gd(e,t){if(ds)return e==="compositionend"||!Ll&&xa(e,t)?(e=Co(),ls=ar=Tn=null,ds=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ea(n)}}function Ta(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ta(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ra(){for(var e=window,t=wn();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=wn(e.document)}return t}function Ol(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Cd(e){var t=Ra(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ta(n.ownerDocument.documentElement,n)){if(r!==null&&Ol(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!e.extend&&o>r&&(s=r,r=o,o=s),s=Pa(n,o);var u=Pa(n,r);s&&u&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==u.node||e.focusOffset!==u.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(u.node,u.offset)):(t.setEnd(u.node,u.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,fs=null,zl=null,Js=null,$l=!1;function Ma(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$l||fs==null||fs!==wn(r)||(r=fs,"selectionStart"in r&&Ol(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Js&&Gs(Js,r)||(Js=r,r=Ao(zl,"onSelect"),0vs||(e.current=Jl[vs],Jl[vs]=null,vs--)}function Ae(e,t){vs++,Jl[vs]=e.current,e.current=t}var hr={},gt=pr(hr),Tt=pr(!1),Hr=hr;function ys(e,t){var n=e.type.contextTypes;if(!n)return hr;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Rt(e){return e=e.childContextTypes,e!=null}function Oo(){De(Tt),De(gt)}function Wa(e,t,n){if(gt.current!==hr)throw Error(f(168));Ae(gt,t),Ae(Tt,n)}function Ka(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(f(108,xe(e)||"Unknown",s));return A({},n,r)}function zo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||hr,Hr=gt.current,Ae(gt,e),Ae(Tt,Tt.current),!0}function qa(e,t,n){var r=e.stateNode;if(!r)throw Error(f(169));n?(e=Ka(e,t,Hr),r.__reactInternalMemoizedMergedChildContext=e,De(Tt),De(gt),Ae(gt,e)):De(Tt),Ae(Tt,n)}var Vn=null,$o=!1,Yl=!1;function Ga(e){Vn===null?Vn=[e]:Vn.push(e)}function zd(e){$o=!0,Ga(e)}function gr(){if(!Yl&&Vn!==null){Yl=!0;var e=0,t=ve;try{var n=Vn;for(ve=1;e>=u,s-=u,Wn=1<<32-Ue(t)+s|n<se?(rt=G,G=null):rt=G.sibling;var je=C(x,G,_[se],T);if(je===null){G===null&&(G=rt);break}e&&G&&je.alternate===null&&t(x,G),g=o(je,g,se),q===null?V=je:q.sibling=je,q=je,G=rt}if(se===_.length)return n(x,G),ze&&br(x,se),V;if(G===null){for(;se<_.length;se++)G=P(x,_[se],T),G!==null&&(g=o(G,g,se),q===null?V=G:q.sibling=G,q=G);return ze&&br(x,se),V}for(G=r(x,G);se<_.length;se++)rt=I(G,x,se,_[se],T),rt!==null&&(e&&rt.alternate!==null&&G.delete(rt.key===null?se:rt.key),g=o(rt,g,se),q===null?V=rt:q.sibling=rt,q=rt);return e&&G.forEach(function(Cr){return t(x,Cr)}),ze&&br(x,se),V}function b(x,g,_,T){var V=U(_);if(typeof V!="function")throw Error(f(150));if(_=V.call(_),_==null)throw Error(f(151));for(var q=V=null,G=g,se=g=0,rt=null,je=_.next();G!==null&&!je.done;se++,je=_.next()){G.index>se?(rt=G,G=null):rt=G.sibling;var Cr=C(x,G,je.value,T);if(Cr===null){G===null&&(G=rt);break}e&&G&&Cr.alternate===null&&t(x,G),g=o(Cr,g,se),q===null?V=Cr:q.sibling=Cr,q=Cr,G=rt}if(je.done)return n(x,G),ze&&br(x,se),V;if(G===null){for(;!je.done;se++,je=_.next())je=P(x,je.value,T),je!==null&&(g=o(je,g,se),q===null?V=je:q.sibling=je,q=je);return ze&&br(x,se),V}for(G=r(x,G);!je.done;se++,je=_.next())je=I(G,x,se,je.value,T),je!==null&&(e&&je.alternate!==null&&G.delete(je.key===null?se:je.key),g=o(je,g,se),q===null?V=je:q.sibling=je,q=je);return e&&G.forEach(function(yf){return t(x,yf)}),ze&&br(x,se),V}function Ge(x,g,_,T){if(typeof _=="object"&&_!==null&&_.type===Ce&&_.key===null&&(_=_.props.children),typeof _=="object"&&_!==null){switch(_.$$typeof){case F:e:{for(var V=_.key,q=g;q!==null;){if(q.key===V){if(V=_.type,V===Ce){if(q.tag===7){n(x,q.sibling),g=s(q,_.props.children),g.return=x,x=g;break e}}else if(q.elementType===V||typeof V=="object"&&V!==null&&V.$$typeof===ne&&tu(V)===q.type){n(x,q.sibling),g=s(q,_.props),g.ref=no(x,q,_),g.return=x,x=g;break e}n(x,q);break}else t(x,q);q=q.sibling}_.type===Ce?(g=Xr(_.props.children,x.mode,T,_.key),g.return=x,x=g):(T=fl(_.type,_.key,_.props,null,x.mode,T),T.ref=no(x,g,_),T.return=x,x=T)}return u(x);case oe:e:{for(q=_.key;g!==null;){if(g.key===q)if(g.tag===4&&g.stateNode.containerInfo===_.containerInfo&&g.stateNode.implementation===_.implementation){n(x,g.sibling),g=s(g,_.children||[]),g.return=x,x=g;break e}else{n(x,g);break}else t(x,g);g=g.sibling}g=qi(_,x.mode,T),g.return=x,x=g}return u(x);case ne:return q=_._init,Ge(x,g,q(_._payload),T)}if(rn(_))return B(x,g,_,T);if(U(_))return b(x,g,_,T);Ho(x,_)}return typeof _=="string"&&_!==""||typeof _=="number"?(_=""+_,g!==null&&g.tag===6?(n(x,g.sibling),g=s(g,_),g.return=x,x=g):(n(x,g),g=Ki(_,x.mode,T),g.return=x,x=g),u(x)):n(x,g)}return Ge}var ws=nu(!0),ru=nu(!1),Qo=pr(null),bo=null,ks=null,ri=null;function si(){ri=ks=bo=null}function oi(e){var t=Qo.current;De(Qo),e._currentValue=t}function li(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function js(e,t){bo=e,ri=ks=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Mt=!0),e.firstContext=null)}function Yt(e){var t=e._currentValue;if(ri!==e)if(e={context:e,memoizedValue:t,next:null},ks===null){if(bo===null)throw Error(f(308));ks=e,bo.dependencies={lanes:0,firstContext:e}}else ks=ks.next=e;return t}var Vr=null;function ii(e){Vr===null?Vr=[e]:Vr.push(e)}function su(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,ii(t)):(n.next=s.next,s.next=n),t.interleaved=n,qn(e,r)}function qn(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var vr=!1;function ai(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ou(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Gn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function yr(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(Se&2)!==0){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,qn(e,n)}return s=r.interleaved,s===null?(t.next=t,ii(r)):(t.next=s.next,s.next=t),r.interleaved=t,qn(e,n)}function Vo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,zs(e,n)}}function lu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var u={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?s=o=u:o=o.next=u,n=n.next}while(n!==null);o===null?s=o=t:o=o.next=t}else s=o=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Wo(e,t,n,r){var s=e.updateQueue;vr=!1;var o=s.firstBaseUpdate,u=s.lastBaseUpdate,d=s.shared.pending;if(d!==null){s.shared.pending=null;var m=d,S=m.next;m.next=null,u===null?o=S:u.next=S,u=m;var N=e.alternate;N!==null&&(N=N.updateQueue,d=N.lastBaseUpdate,d!==u&&(d===null?N.firstBaseUpdate=S:d.next=S,N.lastBaseUpdate=m))}if(o!==null){var P=s.baseState;u=0,N=S=m=null,d=o;do{var C=d.lane,I=d.eventTime;if((r&C)===C){N!==null&&(N=N.next={eventTime:I,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var B=e,b=d;switch(C=t,I=n,b.tag){case 1:if(B=b.payload,typeof B=="function"){P=B.call(I,P,C);break e}P=B;break e;case 3:B.flags=B.flags&-65537|128;case 0:if(B=b.payload,C=typeof B=="function"?B.call(I,P,C):B,C==null)break e;P=A({},P,C);break e;case 2:vr=!0}}d.callback!==null&&d.lane!==0&&(e.flags|=64,C=s.effects,C===null?s.effects=[d]:C.push(d))}else I={eventTime:I,lane:C,tag:d.tag,payload:d.payload,callback:d.callback,next:null},N===null?(S=N=I,m=P):N=N.next=I,u|=C;if(d=d.next,d===null){if(d=s.shared.pending,d===null)break;C=d,d=C.next,C.next=null,s.lastBaseUpdate=C,s.shared.pending=null}}while(!0);if(N===null&&(m=P),s.baseState=m,s.firstBaseUpdate=S,s.lastBaseUpdate=N,t=s.shared.interleaved,t!==null){s=t;do u|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);qr|=u,e.lanes=u,e.memoizedState=P}}function iu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=mi.transition;mi.transition={};try{e(!1),t()}finally{ve=n,mi.transition=r}}function Nu(){return Xt().memoizedState}function Bd(e,t,n){var r=wr(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Eu(e))Pu(t,n);else if(n=su(e,t,n,r),n!==null){var s=Nt();Sn(n,e,r,s),Tu(n,t,r)}}function Hd(e,t,n){var r=wr(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Eu(e))Pu(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var u=t.lastRenderedState,d=o(u,n);if(s.hasEagerState=!0,s.eagerState=d,gn(d,u)){var m=t.interleaved;m===null?(s.next=s,ii(t)):(s.next=m.next,m.next=s),t.interleaved=s;return}}catch{}n=su(e,t,s,r),n!==null&&(s=Nt(),Sn(n,e,r,s),Tu(n,t,r))}}function Eu(e){var t=e.alternate;return e===He||t!==null&&t===He}function Pu(e,t){lo=Go=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Tu(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,zs(e,n)}}var Xo={readContext:Yt,useCallback:vt,useContext:vt,useEffect:vt,useImperativeHandle:vt,useInsertionEffect:vt,useLayoutEffect:vt,useMemo:vt,useReducer:vt,useRef:vt,useState:vt,useDebugValue:vt,useDeferredValue:vt,useTransition:vt,useMutableSource:vt,useSyncExternalStore:vt,useId:vt,unstable_isNewReconciler:!1},Qd={readContext:Yt,useCallback:function(e,t){return An().memoizedState=[e,t===void 0?null:t],e},useContext:Yt,useEffect:yu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Jo(4194308,4,Su.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Jo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Jo(4,2,e,t)},useMemo:function(e,t){var n=An();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=An();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Bd.bind(null,He,e),[r.memoizedState,e]},useRef:function(e){var t=An();return e={current:e},t.memoizedState=e},useState:gu,useDebugValue:_i,useDeferredValue:function(e){return An().memoizedState=e},useTransition:function(){var e=gu(!1),t=e[0];return e=Ud.bind(null,e[1]),An().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=He,s=An();if(ze){if(n===void 0)throw Error(f(407));n=n()}else{if(n=t(),nt===null)throw Error(f(349));(Kr&30)!==0||du(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,yu(mu.bind(null,r,o,e),[e]),r.flags|=2048,uo(9,fu.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=An(),t=nt.identifierPrefix;if(ze){var n=Kn,r=Wn;n=(r&~(1<<32-Ue(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=io++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=u.createElement(n,{is:r.is}):(e=u.createElement(n),n==="select"&&(u=e,r.multiple?u.multiple=!0:r.size&&(u.size=r.size))):e=u.createElementNS(e,n),e[Rn]=t,e[eo]=r,Gu(e,t,!1,!1),t.stateNode=e;e:{switch(u=an(n,r),n){case"dialog":Ie("cancel",e),Ie("close",e),s=r;break;case"iframe":case"object":case"embed":Ie("load",e),s=r;break;case"video":case"audio":for(s=0;sTs&&(t.flags|=128,r=!0,co(o,!1),t.lanes=4194304)}else{if(!r)if(e=Ko(u),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),co(o,!0),o.tail===null&&o.tailMode==="hidden"&&!u.alternate&&!ze)return yt(t),null}else 2*Fe()-o.renderingStartTime>Ts&&n!==1073741824&&(t.flags|=128,r=!0,co(o,!1),t.lanes=4194304);o.isBackwards?(u.sibling=t.child,t.child=u):(n=o.last,n!==null?n.sibling=u:t.child=u,o.last=u)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Fe(),t.sibling=null,n=Be.current,Ae(Be,r?n&1|2:n&1),t):(yt(t),null);case 22:case 23:return bi(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(Wt&1073741824)!==0&&(yt(t),t.subtreeFlags&6&&(t.flags|=8192)):yt(t),null;case 24:return null;case 25:return null}throw Error(f(156,t.tag))}function Yd(e,t){switch(Zl(t),t.tag){case 1:return Rt(t.type)&&Oo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Cs(),De(Tt),De(gt),fi(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return ci(t),null;case 13:if(De(Be),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(f(340));Ss()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return De(Be),null;case 4:return Cs(),null;case 10:return oi(t.type._context),null;case 22:case 23:return bi(),null;case 24:return null;default:return null}}var nl=!1,xt=!1,Xd=typeof WeakSet=="function"?WeakSet:Set,O=null;function Es(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ve(e,t,r)}else n.current=null}function Ai(e,t,n){try{n()}catch(r){Ve(e,t,r)}}var Xu=!1;function Zd(e,t){if(bl=os,e=Ra(),Ol(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var u=0,d=-1,m=-1,S=0,N=0,P=e,C=null;t:for(;;){for(var I;P!==n||s!==0&&P.nodeType!==3||(d=u+s),P!==o||r!==0&&P.nodeType!==3||(m=u+r),P.nodeType===3&&(u+=P.nodeValue.length),(I=P.firstChild)!==null;)C=P,P=I;for(;;){if(P===e)break t;if(C===n&&++S===s&&(d=u),C===o&&++N===r&&(m=u),(I=P.nextSibling)!==null)break;P=C,C=P.parentNode}P=I}n=d===-1||m===-1?null:{start:d,end:m}}else n=null}n=n||{start:0,end:0}}else n=null;for(Vl={focusedElem:e,selectionRange:n},os=!1,O=t;O!==null;)if(t=O,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,O=e;else for(;O!==null;){t=O;try{var B=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(B!==null){var b=B.memoizedProps,Ge=B.memoizedState,x=t.stateNode,g=x.getSnapshotBeforeUpdate(t.elementType===t.type?b:yn(t.type,b),Ge);x.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var _=t.stateNode.containerInfo;_.nodeType===1?_.textContent="":_.nodeType===9&&_.documentElement&&_.removeChild(_.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(f(163))}}catch(T){Ve(t,t.return,T)}if(e=t.sibling,e!==null){e.return=t.return,O=e;break}O=t.return}return B=Xu,Xu=!1,B}function fo(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var o=s.destroy;s.destroy=void 0,o!==void 0&&Ai(t,n,o)}s=s.next}while(s!==r)}}function rl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Li(e){var t=e.ref;if(t!==null){var n=e.stateNode;e.tag,e=n,typeof t=="function"?t(e):t.current=e}}function Zu(e){var t=e.alternate;t!==null&&(e.alternate=null,Zu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Rn],delete t[eo],delete t[Gl],delete t[Dd],delete t[Od])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function ec(e){return e.tag===5||e.tag===3||e.tag===4}function tc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ec(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ii(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Io));else if(r!==4&&(e=e.child,e!==null))for(Ii(e,t,n),e=e.sibling;e!==null;)Ii(e,t,n),e=e.sibling}function Di(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Di(e,t,n),e=e.sibling;e!==null;)Di(e,t,n),e=e.sibling}var ut=null,xn=!1;function xr(e,t,n){for(n=n.child;n!==null;)nc(e,t,n),n=n.sibling}function nc(e,t,n){if(ue&&typeof ue.onCommitFiberUnmount=="function")try{ue.onCommitFiberUnmount(wt,n)}catch{}switch(n.tag){case 5:xt||Es(n,t);case 6:var r=ut,s=xn;ut=null,xr(e,t,n),ut=r,xn=s,ut!==null&&(xn?(e=ut,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):ut.removeChild(n.stateNode));break;case 18:ut!==null&&(xn?(e=ut,n=n.stateNode,e.nodeType===8?ql(e.parentNode,n):e.nodeType===1&&ql(e,n),ir(e)):ql(ut,n.stateNode));break;case 4:r=ut,s=xn,ut=n.stateNode.containerInfo,xn=!0,xr(e,t,n),ut=r,xn=s;break;case 0:case 11:case 14:case 15:if(!xt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,u=o.destroy;o=o.tag,u!==void 0&&((o&2)!==0||(o&4)!==0)&&Ai(n,t,u),s=s.next}while(s!==r)}xr(e,t,n);break;case 1:if(!xt&&(Es(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(d){Ve(n,t,d)}xr(e,t,n);break;case 21:xr(e,t,n);break;case 22:n.mode&1?(xt=(r=xt)||n.memoizedState!==null,xr(e,t,n),xt=r):xr(e,t,n);break;default:xr(e,t,n)}}function rc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Xd),t.forEach(function(r){var s=uf.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function _n(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=u),r&=~o}if(r=s,r=Fe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*tf(r/1960))-r,10e?16:e,Sr===null)var r=!1;else{if(e=Sr,Sr=null,al=0,(Se&6)!==0)throw Error(f(331));var s=Se;for(Se|=4,O=e.current;O!==null;){var o=O,u=o.child;if((O.flags&16)!==0){var d=o.deletions;if(d!==null){for(var m=0;mFe()-$i?Jr(e,0):zi|=n),Lt(e,t)}function gc(e,t){t===0&&((e.mode&1)===0?t=1:(t=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var n=Nt();e=qn(e,t),e!==null&&(Ne(e,t,n),Lt(e,n))}function af(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gc(e,n)}function uf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(f(314))}r!==null&&r.delete(t),gc(e,n)}var vc;vc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Tt.current)Mt=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return Mt=!1,Gd(e,t,n);Mt=(e.flags&131072)!==0}else Mt=!1,ze&&(t.flags&1048576)!==0&&Ja(t,Uo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;tl(e,t),e=t.pendingProps;var s=ys(t,gt.current);js(t,n),s=hi(null,t,r,e,s,n);var o=gi();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Rt(r)?(o=!0,zo(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,ai(t),s.updater=Zo,t.stateNode=s,s._reactInternals=t,wi(t,r,e,n),t=Ni(null,t,r,!0,o,n)):(t.tag=0,ze&&o&&Xl(t),Ct(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(tl(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=df(r),e=yn(r,e),s){case 0:t=Ci(null,t,r,e,n);break e;case 1:t=Qu(null,t,r,e,n);break e;case 11:t=$u(null,t,r,e,n);break e;case 14:t=Fu(null,t,r,yn(r.type,e),n);break e}throw Error(f(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:yn(r,s),Ci(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:yn(r,s),Qu(e,t,r,s,n);case 3:e:{if(bu(t),e===null)throw Error(f(387));r=t.pendingProps,o=t.memoizedState,s=o.element,ou(e,t),Wo(t,r,null,n);var u=t.memoizedState;if(r=u.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:u.cache,pendingSuspenseBoundaries:u.pendingSuspenseBoundaries,transitions:u.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=Ns(Error(f(423)),t),t=Vu(e,t,r,n,s);break e}else if(r!==s){s=Ns(Error(f(424)),t),t=Vu(e,t,r,n,s);break e}else for(Vt=mr(t.stateNode.containerInfo.firstChild),bt=t,ze=!0,vn=null,n=ru(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ss(),r===s){t=Jn(e,t,n);break e}Ct(e,t,r,n)}t=t.child}return t;case 5:return au(t),e===null&&ti(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,u=s.children,Wl(r,s)?u=null:o!==null&&Wl(r,o)&&(t.flags|=32),Hu(e,t),Ct(e,t,u,n),t.child;case 6:return e===null&&ti(t),null;case 13:return Wu(e,t,n);case 4:return ui(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ws(t,null,r,n):Ct(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:yn(r,s),$u(e,t,r,s,n);case 7:return Ct(e,t,t.pendingProps,n),t.child;case 8:return Ct(e,t,t.pendingProps.children,n),t.child;case 12:return Ct(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,o=t.memoizedProps,u=s.value,Ae(Qo,r._currentValue),r._currentValue=u,o!==null)if(gn(o.value,u)){if(o.children===s.children&&!Tt.current){t=Jn(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var d=o.dependencies;if(d!==null){u=o.child;for(var m=d.firstContext;m!==null;){if(m.context===r){if(o.tag===1){m=Gn(-1,n&-n),m.tag=2;var S=o.updateQueue;if(S!==null){S=S.shared;var N=S.pending;N===null?m.next=m:(m.next=N.next,N.next=m),S.pending=m}}o.lanes|=n,m=o.alternate,m!==null&&(m.lanes|=n),li(o.return,n,t),d.lanes|=n;break}m=m.next}}else if(o.tag===10)u=o.type===t.type?null:o.child;else if(o.tag===18){if(u=o.return,u===null)throw Error(f(341));u.lanes|=n,d=u.alternate,d!==null&&(d.lanes|=n),li(u,n,t),u=o.sibling}else u=o.child;if(u!==null)u.return=o;else for(u=o;u!==null;){if(u===t){u=null;break}if(o=u.sibling,o!==null){o.return=u.return,u=o;break}u=u.return}o=u}Ct(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,js(t,n),s=Yt(s),r=r(s),t.flags|=1,Ct(e,t,r,n),t.child;case 14:return r=t.type,s=yn(r,t.pendingProps),s=yn(r.type,s),Fu(e,t,r,s,n);case 15:return Uu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:yn(r,s),tl(e,t),t.tag=1,Rt(r)?(e=!0,zo(t)):e=!1,js(t,n),Mu(t,r,s),wi(t,r,s,n),Ni(null,t,r,!0,e,n);case 19:return qu(e,t,n);case 22:return Bu(e,t,n)}throw Error(f(156,t.tag))};function yc(e,t){return xo(e,t)}function cf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function en(e,t,n,r){return new cf(e,t,n,r)}function Wi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function df(e){if(typeof e=="function")return Wi(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ot)return 11;if(e===We)return 14}return 2}function jr(e,t){var n=e.alternate;return n===null?(n=en(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function fl(e,t,n,r,s,o){var u=2;if(r=e,typeof e=="function")Wi(e)&&(u=1);else if(typeof e=="string")u=5;else e:switch(e){case Ce:return Xr(n.children,s,o,t);case $e:u=8,s|=8;break;case dt:return e=en(12,n,t,s|2),e.elementType=dt,e.lanes=o,e;case H:return e=en(13,n,t,s),e.elementType=H,e.lanes=o,e;case Me:return e=en(19,n,t,s),e.elementType=Me,e.lanes=o,e;case Z:return ml(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case st:u=10;break e;case Dt:u=9;break e;case ot:u=11;break e;case We:u=14;break e;case ne:u=16,r=null;break e}throw Error(f(130,e==null?e:typeof e,""))}return t=en(u,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function Xr(e,t,n,r){return e=en(7,e,r,t),e.lanes=n,e}function ml(e,t,n,r){return e=en(22,e,r,t),e.elementType=Z,e.lanes=n,e.stateNode={isHidden:!1},e}function Ki(e,t,n){return e=en(6,e,null,t),e.lanes=n,e}function qi(e,t,n){return t=en(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ff(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=pn(0),this.expirationTimes=pn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pn(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Gi(e,t,n,r,s,o,u,d,m){return e=new ff(e,t,n,d,m),t===1?(t=1,o===!0&&(t|=8)):t=0,o=en(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ai(o),e}function mf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(h){console.error(h)}}return i(),ta.exports=Cf(),ta.exports}var Ac;function Ef(){if(Ac)return _l;Ac=1;var i=Nf();return _l.createRoot=i.createRoot,_l.hydrateRoot=i.hydrateRoot,_l}var Pf=Ef();const Tf=qc(Pf),Rf="/api";async function ye(i,h){const f=await fetch(`${Rf}${i}`,{...h,headers:{"Content-Type":"application/json",...h?.headers??{}}}),R=await f.json();if(!f.ok){const E=R.error?.message??"Ошибка запроса";throw new Error(E)}return R}const Pe={async loadSharedConnectionConfig(){return ye("/llm/shared-connection")},async saveSharedConnectionConfig(i){return ye("/llm/shared-connection",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,model:i.model,baseUrl:i.baseUrl,temperature:i.temperature,maxOutputTokens:i.maxOutputTokens})})},async listModels(i){return ye("/llm/models",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,apiKey:i.apiKey,model:i.model,baseUrl:i.baseUrl})})},async testConnection(i){return ye("/llm/test-connection",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,apiKey:i.apiKey,model:i.model,baseUrl:i.baseUrl})})},async normalize(i){return ye("/normalize",{method:"POST",body:JSON.stringify({llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples,userQuestion:i.query.userQuestion,context:{period_hint:i.query.periodHint??"",business_context:i.query.businessContext??"",expected_route:i.query.expectedRoute??""},saveAsTestCase:!!i.saveAsTestCase,useMock:!!i.useMock})})},async loadHistory(){return ye("/history")},async loadTrace(i){return ye(`/history/${i}`)},async loadPresets(){return ye("/presets")},async savePreset(i){return ye("/presets/save",{method:"POST",body:JSON.stringify(i)})},async runEval(i){return ye("/eval/run",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples},caseIds:i.caseIds,useMock:!!i.useMock,mode:i.mode??"standard",caseSetFile:i.caseSetFile,rawQuestions:i.rawQuestions,eval_target:i.evalTarget,compare_with_report_file:i.compareWithReportFile,analysis_date:i.analysisDate})})},async startEvalRunAsync(i){return ye("/eval/run-async/start",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples},caseIds:i.caseIds,useMock:!!i.useMock,mode:i.mode??"standard",caseSetFile:i.caseSetFile,rawQuestions:i.rawQuestions,eval_target:i.evalTarget,compare_with_report_file:i.compareWithReportFile,questions:i.questions,scenarioQuestions:i.scenarioQuestions,scenarioTitle:i.scenarioTitle,analysis_date:i.analysisDate})})},async loadEvalRunAsyncStatus(i){return ye(`/eval/run-async/${encodeURIComponent(i)}`)},async startRun(){return ye("/accounting-agent/v1/runs/start",{method:"POST",body:JSON.stringify({initiator:"ndc_operator",source:"gui"})})},async finishRun(i){return ye("/accounting-agent/v1/runs/finish",{method:"POST",body:JSON.stringify({runId:i,status:"DONE",source:"gui",reason:"Остановлено оператором из GUI"})})},async listRuns(){return ye("/accounting-agent/v1/runs")},async listResults(){return ye("/accounting-agent/v1/results")},async runTrace(i){return ye(`/accounting-agent/v1/trace/run/${i}`)},async sendAssistantMessage(i){return ye("/assistant/message",{method:"POST",body:JSON.stringify({session_id:i.sessionId??"",mode:"assistant",message:i.userMessage,user_message:i.userMessage,llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion??"address_query_runtime_v1",systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples,context:{period_hint:i.context?.periodHint??"",business_context:i.context?.businessContext??""},useMock:!!i.useMock})})},async loadAssistantSession(i){return ye(`/assistant/session/${i}`)},async saveAutoRunAssistantSession(i){return ye("/autoruns/autogen/save-assistant-session",{method:"POST",body:JSON.stringify(i)})},async loadAssistantAnnotations(i){const h=new URLSearchParams;i?.session_id&&h.set("session_id",i.session_id),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const f=h.toString();return ye(`/assistant/annotations${f?`?${f}`:""}`)},async saveAssistantAnnotation(i){return ye("/assistant/annotations",{method:"POST",body:JSON.stringify(i)})},async loadAutoRunsHistory(i){const h=new URLSearchParams;i?.from&&h.set("from",i.from),i?.to&&h.set("to",i.to),i?.target&&h.set("target",i.target),i?.mode&&h.set("mode",i.mode),i?.use_mock&&h.set("use_mock",i.use_mock),i?.prompt_contains&&h.set("prompt_contains",i.prompt_contains),typeof i?.limit=="number"&&h.set("limit",String(i.limit)),typeof i?.scan_limit=="number"&&h.set("scan_limit",String(i.scan_limit));const f=h.toString();return ye(`/autoruns/history${f?`?${f}`:""}`)},async loadAutoRunDetail(i){return ye(`/autoruns/history/${encodeURIComponent(i)}`)},async loadAutoRunCaseDialog(i,h){return ye(`/autoruns/history/${encodeURIComponent(i)}/case/${encodeURIComponent(h)}/dialog`)},async loadAutoRunAnnotations(i){const h=new URLSearchParams;i?.run_id&&h.set("run_id",i.run_id),i?.case_id&&h.set("case_id",i.case_id),typeof i?.min_rating=="number"&&h.set("min_rating",String(i.min_rating)),i?.manual_case_decision&&h.set("manual_case_decision",i.manual_case_decision),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const f=h.toString();return ye(`/autoruns/annotations${f?`?${f}`:""}`)},async saveAutoRunAnnotation(i){return ye("/autoruns/annotations",{method:"POST",body:JSON.stringify(i)})},async updateAutoRunAnnotation(i){return ye(`/autoruns/annotations/${encodeURIComponent(i.annotation_id)}`,{method:"PATCH",body:JSON.stringify({resolved:i.resolved,resolved_by:i.resolved_by})})},async loadAutoRunPostAnalysis(i){const h=new URLSearchParams;i?.run_id&&h.set("run_id",i.run_id),typeof i?.limit_per_queue=="number"&&h.set("limit_per_queue",String(i.limit_per_queue)),typeof i?.annotation_limit=="number"&&h.set("annotation_limit",String(i.annotation_limit)),typeof i?.scan_limit=="number"&&h.set("scan_limit",String(i.scan_limit)),i?.from&&h.set("from",i.from),i?.to&&h.set("to",i.to),i?.target&&h.set("target",i.target),i?.mode&&h.set("mode",i.mode),i?.use_mock&&h.set("use_mock",i.use_mock),i?.prompt_contains&&h.set("prompt_contains",i.prompt_contains);const f=h.toString();return ye(`/autoruns/post-analysis${f?`?${f}`:""}`)},async loadAutoRunAutogenHistory(i){const h=new URLSearchParams;i?.mode&&h.set("mode",i.mode),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const f=h.toString();return ye(`/autoruns/autogen/history${f?`?${f}`:""}`)},async loadAutoRunAutogenPersonalityCatalog(){return ye("/autoruns/autogen/personality-catalog")},async updateAutoRunAutogenQuestions(i){return ye(`/autoruns/autogen/history/${encodeURIComponent(i.generation_id)}/questions`,{method:"PATCH",body:JSON.stringify({questions:i.questions})})},async deleteAutoRunAutogenHistoryRecord(i){return ye(`/autoruns/autogen/history/${encodeURIComponent(i)}`,{method:"DELETE"})},async generateAutoRunQuestions(i){return ye("/autoruns/autogen/generate",{method:"POST",body:JSON.stringify(i)})}},Mf=/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json|debug_payload|technical_breakdown)\b/i,Af=[/\b(?:debug_payload_json|technical_breakdown_json)\b/i,/\b(?:route_summary|semantic_profile|domain_scope|relation_patterns|account_scope)\b/i,/\b(?:coverage_report|retrieval_status|problem_unit_state|candidate_evidence)\b/i,/\b(?:graph_domain_scope|graph_runtime|selection_reason|why_included)\b/i];function Lf(i){try{return JSON.stringify(i,null,2)}catch{return String(i)}}function If(i){const h=String(i??""),f=h.match(Mf);return(f?h.slice(0,f.index):h).replace(/###\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)[\s\S]*?(?:```[\s\S]*?```|$)/gi,"").replace(/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)\b[\s\S]*$/gi,"").split(/\r?\n/g).map(Q=>Q.trimEnd()).filter(Q=>Q.trim().length>0).filter(Q=>!Af.some(le=>le.test(Q))).join(` -`).trim()}function Df(i,h,f="default"){const R=f==="technical",E=[];E.push("# Assistant conversation export"),E.push(`session_id: ${i||"n/a"}`),E.push(`export_mode: ${f}`),E.push(`exported_at: ${new Date().toISOString()}`),E.push("");for(let L=0;L{E.length!==0&&(R.push(E.join(` -`)),E=[])};for(const Q of f){const le=Q.trimEnd(),te=le.trim();if(!te){L();continue}const z=/^Блок\s+\d+\./i.test(te),Y=/^\d+\.\s/.test(te);(z||Y)&&E.length>0&&L(),E.push(le)}return L(),R.length>0?R:[i]}function Hf(i,h){const f=[],R=/\*\*(.+?)\*\*/g;let E=0,L=0,Q;for(;(Q=R.exec(i))!==null;)Q.index>E&&(f.push(l.jsx("span",{children:i.slice(E,Q.index)},`${h}-t-${L}`)),L+=1),f.push(l.jsx("strong",{children:Q[1]},`${h}-b-${L}`)),L+=1,E=R.lastIndex;return E0?f:[l.jsx("span",{children:i},`${h}-raw`)]}function Qf(i){const h=i.trimStart();return/^Блок\s+\d+\./i.test(h)?"assistant-msg-line heading":/^\d+\.\s/.test(h)?"assistant-msg-line numbered":/^-\s/.test(h)?"assistant-msg-line bullet":"assistant-msg-line"}function bf(i,h=40){const f=i.replace(/\s+/g," ").trim();if(f.length<=h)return f;const R=f.split(" ").slice(0,3).join(" ").trim();return R.length>=10&&R.length<=h?`${R}…`:`${f.slice(0,h-1).trimEnd()}…`}function Jc(i){return i.replace(/\*\*(.+?)\*\*/g,"$1").replace(/^\d+\.\s*/,"").trim()}function Vf(i){const h=i.replace(/\r\n?/g,` -`).split(` -`).map(E=>E.trim()).find(Boolean),f=Jc(h??"");return(f.split("|")[0]?.trim()??f).replace(/\s+/g," ").trim()}function Wf(i){const h=i.replace(/\r\n?/g,` -`).split(` -`).map(R=>R.trim()).find(Boolean);return!h||!/^\d+\.\s/.test(h)?!1:Jc(h).includes("|")}function Kf(i,h){const f=h.replace(/\r\n?/g,` -`).replace(/\*\*(.+?)\*\*/g,"$1").split(` -`).map((E,L)=>{const Q=E.trim();return L===0?Q.replace(/^\d+\.\s*/,""):Q}).filter(Boolean).join(" ").replace(/\s+/g," ").trim();if(!f)return null;const R=Vf(h)||f;return{message_id:i.message_id,source_text:f,anchor_text:R,preview_text:bf(R)}}function qf(i,h,f,R){return Bf(i.text).map((L,Q)=>{const le=L.split(` -`),te=i.role==="assistant"&&Wf(L),z=te?Kf(i,L):null,Y=!!z&&h?.message_id===z?.message_id&&h?.source_text===z?.source_text,X=le.map((ee,Te)=>l.jsx("p",{className:Qf(ee),children:Hf(ee,`line-${Q}-${Te}`)},`line-${Q}-${Te}`));return!te||!z?l.jsx("div",{className:"assistant-msg-block",children:X},`block-${Q}`):l.jsx("div",{className:Y?"assistant-msg-block selectable active":"assistant-msg-block selectable",role:"button",tabIndex:0,onClick:()=>{if(Y){R();return}f(z)},onKeyDown:ee=>{if(!(ee.key!=="Enter"&&ee.key!==" ")){if(ee.preventDefault(),Y){R();return}f(z)}},children:X},`block-${Q}`)})}function Gf({sessionId:i,conversation:h,inputValue:f,onInputChange:R,selectedContextChip:E,onSelectContextChip:L,onClearContextChip:Q,useMock:le,onUseMockChange:te,onSend:z,onClear:Y,onSaveSession:X,busy:ee,saveBusy:Te=!1,saveDisabled:ce=!1,statusText:de,errorMessage:pe,showSaveAction:Qe=!1,showCommentAction:Je=!1,onCommentAssistantMessage:be,isAssistantMessageCommented:Re,canCommentAssistantMessage:F}){const oe=y.useRef(null),Ce=y.useRef(!0),$e=y.useRef(null),[dt,st]=y.useState("idle"),[Dt,ot]=y.useState("чат");function H(ne=!1){oe.current&&(ne&&(Ce.current=!0),oe.current.scrollTop=oe.current.scrollHeight)}y.useEffect(()=>{Ce.current&&H()},[h]),y.useEffect(()=>()=>{$e.current!==null&&window.clearTimeout($e.current)},[]);async function Me(ne){if(h.length===0)return;const Z=Df(i,h,ne),M=await $f(Z);ot(ne==="technical"?"тех":"чат"),st(M?"success":"error"),$e.current!==null&&window.clearTimeout($e.current),$e.current=window.setTimeout(()=>{st("idle")},2200)}function We(){if(!oe.current)return;const ne=oe.current,Z=ne.scrollHeight-ne.scrollTop-ne.clientHeight;Ce.current=Z<16}return l.jsx(Pl,{className:"assistant-panel-frame",title:"Режим ассистента",children:l.jsxs("div",{className:"assistant-live-shell",children:[l.jsxs("div",{className:"assistant-toolbar",children:[l.jsxs("div",{className:"assistant-toolbar-actions",children:[l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{Me("default")},disabled:h.length===0,title:"Экспорт только user-facing чата",children:"Скопировать чат"}),l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{Me("technical")},disabled:h.length===0,title:"Технический экспорт с debug payload",children:"Скопировать техчат"}),Qe?l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>X?.(),disabled:Te||ce,children:Te?"Сохраняю...":"Сохранить"}):null,l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>Y(),disabled:ee&&h.length===0,children:"Сбросить сессию"})]}),l.jsxs("div",{className:"assistant-toolbar-meta",children:[i?l.jsx("span",{className:"status-chip",children:`session: ${i}`}):null,l.jsxs("div",{className:"assistant-toolbar-meta-right",children:[de?l.jsx("span",{className:"assistant-live-status",children:de}):null,dt==="success"?l.jsxs("span",{className:"assistant-copy-feedback success",children:["Скопировано (",Dt,")"]}):null,dt==="error"?l.jsx("span",{className:"assistant-copy-feedback error",children:"Ошибка копирования"}):null]})]}),pe?l.jsx("p",{className:"error-text assistant-toolbar-error",children:pe}):null]}),l.jsx("div",{ref:oe,className:"assistant-chat-list",onScroll:We,children:h.map((ne,Z)=>{const M=ne.role==="assistant"&&Je&&typeof be=="function"&&(typeof F=="function"?F(ne,Z):!0),U=ne.role==="assistant"&&typeof Re=="function"?Re(ne,Z):!1;return l.jsxs("article",{className:`assistant-msg ${ne.role}`,children:[l.jsxs("header",{className:"assistant-msg-head",children:[l.jsxs("div",{className:"assistant-msg-head-main",children:[l.jsx("strong",{children:Of(ne.role)}),l.jsx("span",{children:zf(ne.created_at)})]}),ne.role==="assistant"&&Je?l.jsx("div",{className:"assistant-msg-head-actions",children:l.jsx("button",{type:"button",className:U?"autoruns-comment-icon assistant-comment-btn commented":"autoruns-comment-icon assistant-comment-btn",onClick:()=>be?.(ne,Z),disabled:!M,title:M?"Комментировать ответ ассистента":"Комментарий недоступен для этого сообщения","aria-label":M?"Комментировать ответ ассистента":"Комментарий недоступен для этого сообщения",children:l.jsx(Ff,{commented:U})})}):null]}),l.jsx("div",{className:"assistant-msg-body",children:qf(ne,E,L,Q)}),ne.role==="assistant"&&ne.debug?l.jsxs("details",{className:"assistant-debug",children:[l.jsx("summary",{children:"Показать технический разбор"}),l.jsx(Gc,{value:ne.debug})]}):null]},ne.message_id)})}),l.jsxs("div",{className:"assistant-compose",children:[E?l.jsxs("div",{className:"assistant-compose-context",children:[l.jsx("span",{className:"assistant-compose-context-label",children:"Выбранный объект"}),l.jsxs("div",{className:"assistant-compose-context-pill",title:E.source_text,children:[l.jsx("span",{className:"assistant-compose-context-pill-text",children:E.preview_text}),l.jsx("button",{type:"button",className:"assistant-compose-context-clear",onClick:Q,"aria-label":"Убрать выбранный объект",title:"Убрать выбранный объект",children:"×"})]})]}):null,l.jsxs("label",{className:"full-width",children:["Сообщение",l.jsx("textarea",{className:"assistant-input-textarea",value:f,onChange:ne=>R(ne.target.value),rows:4,placeholder:E?"Продолжите вопрос по выбранному объекту...":"Введите вопрос к данным компании..."})]}),l.jsxs("div",{className:"button-row assistant-send-row",children:[l.jsxs("label",{className:"checkbox-row",children:[l.jsx("input",{type:"checkbox",checked:le,onChange:ne=>te(ne.target.checked)}),"Mock-режим"]}),l.jsx("button",{type:"button",className:"assistant-send-btn",onClick:()=>{H(!0),z()},disabled:ee||!f.trim(),children:ee?"Выполняю...":"Отправить"})]})]})]})})}const Sl="http://127.0.0.1:1234/v1",Lc="https://api.openai.com/v1",Nl="qwen2.5-14b-instruct-1m",ma="unsloth/qwen3-30b-a3b-instruct-2507",Jf=[{value:Nl,label:"Qwen2.5 14B Instruct 1M"},{value:ma,label:"Qwen3 30B A3B Instruct 2507"}];function Yf(i){return i.llmProvider!=="local"?"openai":i.model===ma?"local_qwen3":i.model===Nl?"local_qwen25":"local_custom"}function Xf(i,h){const f=new Map;if(h)for(const R of Jf)f.set(R.value,R);for(const R of i)f.has(R)||f.set(R,{value:R,label:R});return Array.from(f.values())}function Zf({value:i,modelOptions:h,modelsBusy:f,onChange:R,onReloadModels:E,onTestConnection:L,onSaveLocalConfig:Q,lastStatus:le,busy:te,embedded:z=!1}){const Y=i.llmProvider==="local",X=Yf(i),ee=Xf(h,Y),Te=ee.some(F=>F.value===i.model),[ce,de]=y.useState(String(i.temperature)),[pe,Qe]=y.useState(String(i.maxOutputTokens));y.useEffect(()=>{de(String(i.temperature))},[i.temperature]),y.useEffect(()=>{Qe(String(i.maxOutputTokens))},[i.maxOutputTokens]);const Je=F=>{const oe=F.replace(",",".").trim();if(!oe){de(String(i.temperature));return}const Ce=Number(oe);if(!Number.isFinite(Ce)){de(String(i.temperature));return}R({...i,temperature:Ce}),de(String(Ce))},be=F=>{const oe=F.trim();if(!oe){Qe(String(i.maxOutputTokens));return}const Ce=Number.parseInt(oe,10);if(!Number.isFinite(Ce)||Ce<=0){Qe(String(i.maxOutputTokens));return}R({...i,maxOutputTokens:Ce}),Qe(String(Ce))},Re=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"grid-two",children:[l.jsxs("label",{children:["Provider",l.jsxs("select",{value:X,onChange:F=>{const oe=F.target.value;if(oe==="openai"){R({...i,llmProvider:"openai",baseUrl:Lc});return}if(oe==="local_qwen25"){R({...i,llmProvider:"local",model:Nl,baseUrl:Sl});return}if(oe==="local_qwen3"){R({...i,llmProvider:"local",model:ma,baseUrl:Sl});return}R({...i,llmProvider:"local",model:i.llmProvider==="local"?i.model:Nl,baseUrl:Sl})},children:[l.jsx("option",{value:"openai",children:"OpenAI (token)"}),l.jsx("option",{value:"local_qwen25",children:"Qwen2.5 14B Instruct 1M (Local LM Studio)"}),l.jsx("option",{value:"local_qwen3",children:"Qwen3 30B A3B Instruct 2507 (Local LM Studio)"}),l.jsx("option",{value:"local_custom",children:"Local custom (LM Studio / OpenAI-compatible)"})]})]}),l.jsxs("label",{children:["Model",l.jsxs("select",{value:Te?i.model:"__manual__",onChange:F=>{const oe=F.target.value;oe!=="__manual__"&&R({...i,model:oe})},children:[l.jsx("option",{value:"__manual__",children:"Manual input"}),ee.map(F=>l.jsx("option",{value:F.value,children:F.label},F.value))]})]}),l.jsxs("label",{children:["Model ID (manual / current)",l.jsx("input",{value:i.model,onChange:F=>R({...i,model:F.target.value}),placeholder:"qwen2.5-14b-instruct-1m or unsloth/qwen3-30b-a3b-instruct-2507"})]}),Y?null:l.jsxs("label",{className:"full-width",children:["OpenAI API Key",l.jsx("input",{type:"password",value:i.apiKey,onChange:F=>R({...i,apiKey:F.target.value}),placeholder:"sk-..."})]}),l.jsxs("label",{className:Y?"full-width":void 0,children:[Y?"Local server base URL":"Base URL",l.jsx("input",{value:i.baseUrl,onChange:F=>R({...i,baseUrl:F.target.value}),placeholder:Y?Sl:Lc})]}),l.jsxs("label",{children:["Temperature",l.jsx("input",{type:"number",step:"0.1",value:ce,onChange:F=>de(F.target.value),onBlur:F=>Je(F.target.value),onKeyDown:F=>{F.key==="Enter"&&Je(F.target.value)}})]}),l.jsxs("label",{children:["Max output tokens",l.jsx("input",{type:"number",value:pe,onChange:F=>Qe(F.target.value),onBlur:F=>be(F.target.value),onKeyDown:F=>{F.key==="Enter"&&be(F.target.value)}})]})]}),l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>Q(),children:"Save local config"}),l.jsx("button",{type:"button",onClick:()=>E(),disabled:te||f,children:f?"Loading models...":"Load model list"}),l.jsx("button",{type:"button",onClick:()=>L(),disabled:te,children:te?"Checking...":"Test connection"})]})]});return z?l.jsxs("section",{className:"embedded-panel-section",children:[l.jsxs("div",{className:"embedded-panel-section-header",children:[l.jsxs("div",{children:[l.jsx("h4",{children:"LLM Connector"}),l.jsx("p",{children:"Switch between OpenAI cloud and local OpenAI-compatible server."})]}),l.jsx("span",{className:"status-chip",children:le||"Status: not checked"})]}),Re]}):l.jsx(Pl,{title:"LLM Connector",subtitle:"Switch between OpenAI cloud and local OpenAI-compatible server.",actions:l.jsx("span",{className:"status-chip",children:le||"Status: not checked"}),children:Re})}function em({value:i,onChange:h,presets:f,selectedPresetId:R,onSelectPreset:E,onLoadPreset:L,onSavePreset:Q,onResetDefaults:le,onDiffPrevious:te,presetName:z,onPresetNameChange:Y,diffSummary:X,embedded:ee=!1}){const Te=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"prompt-manager-grid",children:[l.jsxs("label",{children:["Системный prompt",l.jsx("textarea",{value:i.systemPrompt,onChange:ce=>h({...i,systemPrompt:ce.target.value}),rows:6})]}),l.jsxs("label",{children:["Developer / Instruction prompt",l.jsx("textarea",{value:i.developerPrompt,onChange:ce=>h({...i,developerPrompt:ce.target.value}),rows:6})]}),l.jsxs("label",{children:["Domain prompt",l.jsx("textarea",{value:i.domainPrompt,onChange:ce=>h({...i,domainPrompt:ce.target.value}),rows:6})]}),l.jsxs("label",{children:["Schema notes",l.jsx("textarea",{value:i.schemaNotes,onChange:ce=>h({...i,schemaNotes:ce.target.value}),rows:6})]}),l.jsxs("label",{className:"full-width",children:["Few-shot examples",l.jsx("textarea",{value:i.fewShotExamples,onChange:ce=>h({...i,fewShotExamples:ce.target.value}),rows:8})]})]}),l.jsxs("div",{className:"button-row",children:[l.jsxs("select",{value:R,onChange:ce=>E(ce.target.value),children:[l.jsx("option",{value:"",children:"Выберите preset..."}),f.map(ce=>l.jsx("option",{value:ce.id,children:ce.name},ce.id))]}),l.jsx("button",{type:"button",onClick:()=>L(),children:"Загрузить preset"}),l.jsx("input",{value:z,onChange:ce=>Y(ce.target.value),placeholder:"Имя для сохранения"}),l.jsx("button",{type:"button",onClick:()=>Q(),children:"Сохранить preset"}),l.jsx("button",{type:"button",onClick:()=>te(),children:"Diff с предыдущим"}),l.jsx("button",{type:"button",onClick:()=>le(),children:"Сбросить к default"})]}),X?l.jsx("p",{className:"diff-summary",children:X}):null]});return ee?l.jsxs("section",{className:"embedded-panel-section",children:[l.jsx("div",{className:"embedded-panel-section-header",children:l.jsxs("div",{children:[l.jsx("h4",{children:"Prompt Manager"}),l.jsx("p",{children:"Системный, developer и domain уровни управляются отдельно."})]})}),Te]}):l.jsx(Pl,{title:"Prompt Manager",subtitle:"Системный, developer и domain уровни управляются отдельно.",children:Te})}const sa={fromLocal:"",toLocal:"",target:"all",mode:"all",useMock:"any",promptContains:"",limit:120},wl="needs_dialog_policy_fix",_t="__all__",El="__live__:",Ic="ndc_autoruns_ui_config_v1",Dc="ndc-autoruns-save",oa=["Анализ запроса","Получение данных","Подготовка ответа"];function tm(i,h){const f=i.trim();if(!f)return"";if(!h)return f;const R=f.toLowerCase(),E=h.anchor_text.trim(),L=E.toLowerCase();return L&&R.includes(L)?f:`По выбранному объекту "${E}": ${f}`}const da=[{id:"general",label:"Общий контур",domain:"",defaultPrompt:"Генерируй реалистичные живые вопросы бухгалтера по 1С. Добавляй разговорные формулировки и опечатки, но сохраняй бизнес-смысл."}];function nm(i=da){return i.reduce((h,f)=>(h[f.id]=f.defaultPrompt,h),{})}const Oc={mode:"codex_creative",count:24,personalityId:"general",personalityPrompts:nm(),persistToEvalCases:!0,generatedBy:"manual_reviewer"};function la(i){const h=String(i??"").trim();return/^\d{4}-\d{2}-\d{2}$/.test(h)?h:""}function zc(i){const h=typeof i=="number"&&Number.isFinite(i)?Math.trunc(i):160;return Math.max(110,Math.min(520,h))}function rm(i){const h=i.getFullYear(),f=String(i.getMonth()+1).padStart(2,"0"),R=String(i.getDate()).padStart(2,"0"),E=String(i.getHours()).padStart(2,"0"),L=String(i.getMinutes()).padStart(2,"0");return`${h}-${f}-${R}T${E}:${L}`}function $c(){const i=new Date;return i.setDate(i.getDate()-14),rm(i)}function kl(i){if(!i.trim())return;const h=Date.parse(i);if(Number.isFinite(h))return new Date(h).toISOString()}function tn(i){if(!i)return"нет данных";const h=Date.parse(i);return Number.isFinite(h)?new Date(h).toLocaleString("ru-RU"):i}function ia(i){return i==="saved_user_sessions"?"Пользовательские сессии":i}function Yc(i){return i?i.context?.agent_run===!0||i.context?.saved_case_set_kind==="agent_semantic_scenario"?!0:typeof i.title=="string"&&i.title.trim().toUpperCase().startsWith("AGENT"):!1}function Fc(i){const h=i.title??tn(i.created_at);return Yc(i)&&!h.trim().toUpperCase().startsWith("AGENT")?`AGENT | ${h}`:h}function sm(i){const h=i[i.length-1];return`Ручная сессия ${tn(h?.created_at??new Date().toISOString())}`}function om(i,h){return h<=0?0:Math.max(0,Math.min(100,Number((i/h*100).toFixed(1))))}function jl(i){return typeof i!="number"?"нет данных":`${i.toFixed(1)}%`}function lm(i){return i==="assistant_stage1"?"assistant/s1":i==="assistant_stage2"?"assistant/s2":i==="assistant_p0"?"assistant/p0":i}function Uc(i){return i==="up"?"Рост":i==="down"?"Регресс":"Без изменений"}function aa(i){const h=Math.max(1,Math.min(5,Math.round(i)));return`${"●".repeat(h)}${"○".repeat(5-h)}`}function Bc(i){return i.length===0?l.jsx("p",{className:"muted",children:"Покрытие доменов пока не сформировано."}):l.jsx("div",{className:"autoruns-coverage-list",children:i.map(h=>{const f=om(h.closed_cases,h.total_cases);return l.jsxs("div",{className:"autoruns-coverage-item",children:[l.jsxs("div",{className:"autoruns-coverage-head",children:[l.jsx("strong",{children:h.domain}),l.jsxs("span",{children:[h.closed_cases,"/",h.total_cases," (",f,"%)"]})]}),l.jsx("div",{className:"autoruns-coverage-bar",children:l.jsx("div",{style:{width:`${f}%`}})})]},h.domain)})})}function Cl(i){return`${El}${i}`}function Ms(i){return i.startsWith(El)}function Hc(i){return i.startsWith(El)?i.slice(El.length):""}function Xc(i){const h=i.report_summary?.run_timestamp??i.created_at,f=Math.max(0,i.total_cases-i.completed_cases);return{run_id:Cl(i.job_id),eval_target:i.eval_target,run_timestamp:h,mode:"single-pass-strict",llm_provider:null,model:null,use_mock:null,analysis_date:i.report_summary?.analysis_date??i.analysis_date??null,prompt_version:null,schema_version:null,suite_id:i.case_set_file,cases_total:i.total_cases,requests_total:null,report_path:`async_job:${i.job_id}`,score_index:i.report_summary?.score_index??null,blocking_failures:0,quality_failures:0,closed_cases:i.completed_cases,open_cases:f,domain_coverage:[{domain:"runtime",total_cases:i.total_cases,closed_cases:i.completed_cases}]}}function yo(i,h){const f=Xc(i),R=i.cases.map(Y=>({case_id:Y.case_id,domain:null,query_class:null,status:Y.status==="completed"?"closed":Y.status==="failed"?"open":"unknown",score_index:null,trace_id:null,reply_type:null,session_id:`${i.run_id}-${Y.case_id}`,dialog_available:Y.messages.length>0,commented_count:0,latest_annotation_at:null,avg_rating:null,checks:null,metric_subscores:null})),L=h!==_t&&R.some(Y=>Y.case_id===h)?h:R.length>0?_t:"",Q={ok:!0,run:f,coverage:{closed_cases:i.completed_cases,open_cases:Math.max(0,i.total_cases-i.completed_cases),domain_coverage:[{domain:"runtime",total_cases:i.total_cases,closed_cases:i.completed_cases}]},cases:R,annotations_summary:{total:0},report:i.report_summary?{run_id:i.report_summary.run_id,run_timestamp:i.report_summary.run_timestamp,score_index:i.report_summary.score_index,cases_total:i.report_summary.cases_total,analysis_date:i.report_summary.analysis_date??i.analysis_date??null}:{}},le=[];let te=0;if(L===_t)for(const Y of i.cases)for(let X=0;XX.case_id===L)??null;for(let X=0;X<(Y?.messages.length??0);X+=1){const ee=Y?.messages[X];ee&&le.push({...ee,message_index:X,case_id:L,case_message_index:X,commented:!1,annotation:null})}}const z={ok:!0,run_id:f.run_id,case_id:L,source:"assistant_session",session_id:L===_t?`${i.run_id}::__all__`:`${i.run_id}-${L}`,messages:le,decomposition:[],assistant_mode:{status:i.status,completed_cases:i.completed_cases,total_cases:i.total_cases},annotations:[]};return{detail:Q,dialog:z,caseId:L}}function im({commented:i}){const h=i?"comment-icon-svg commented":"comment-icon-svg";return l.jsx("svg",{className:h,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:l.jsx("path",{d:"M5 6.5h14v9H11.5l-4.5 3v-3H5z"})})}function Qc({resolved:i}){return l.jsxs("svg",{className:i?"resolve-icon-svg resolved":"resolve-icon-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),i?l.jsx("path",{d:"M5.1 8.2 7.2 10.3 11 6.5"}):null]})}function bc(){return l.jsxs("svg",{className:"autoruns-copy-icon-svg",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[l.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2.2"}),l.jsx("path",{d:"M15 7V5.8a1.8 1.8 0 0 0-1.8-1.8H5.8A1.8 1.8 0 0 0 4 5.8v7.4A1.8 1.8 0 0 0 5.8 15H7"})]})}function am({connection:i,modelOptions:h,modelsBusy:f,connectionStatus:R,connectionBusy:E,onConnectionChange:L,onReloadModels:Q,onSaveLocalConfig:le,onTestConnection:te,prompts:z,onPromptsChange:Y,promptPresets:X,selectedPresetId:ee,onSelectPreset:Te,onLoadPreset:ce,onSavePreset:de,onResetDefaults:pe,onDiffPrevious:Qe,presetName:Je,onPresetNameChange:be,diffSummary:Re,assistantPromptVersion:F,decompositionPromptVersion:oe,showSettingsMode:Ce,showAutoRunsMode:$e,showAssistantMode:dt,showProgressMode:st,showCommentsMode:Dt,onLog:ot}){const[H,Me]=y.useState({...sa,fromLocal:$c()}),[We,ne]=y.useState(""),[Z,M]=y.useState(null),[U,A]=y.useState(null),[v,w]=y.useState(null),[re,ie]=y.useState([]),[ae,he]=y.useState("all"),[xe,_e]=y.useState(!1),[we,lt]=y.useState(null),[Kt,Xn]=y.useState([]),[wn,nn]=y.useState(""),[Ee,Ot]=y.useState(""),[et,ft]=y.useState(""),[St,rn]=y.useState(da),[W,it]=y.useState(Oc),[Zn,In]=y.useState([]),[Dn,kn]=y.useState(""),[mt,zt]=y.useState([]),[Ke,sn]=y.useState(null),[on,Zr]=y.useState(null),[Nr,Er]=y.useState(!1),[es,ln]=y.useState(!1),[an,un]=y.useState(!1),[cn,On]=y.useState(!1),[me,dn]=y.useState(!1),[er,Pr]=y.useState(!1),[Tr,Rr]=y.useState(!1),[jn,tr]=y.useState(!1),[Mr,Cn]=y.useState(""),[nr,Oe]=y.useState(""),[k,K]=y.useState(""),[D,ke]=y.useState([]),[qe,Ar]=y.useState([]),[As,Ls]=y.useState(""),[fn,ts]=y.useState(null),[ns,Tl]=y.useState(!1),[Is,Ds]=y.useState(!1),[xo,rr]=y.useState(""),[Rl,zn]=y.useState(""),[Fe,sr]=y.useState(String(sa.limit)),[Os,$n]=y.useState(String(Oc.count)),[or,_o]=y.useState(160),[ge,wt]=y.useState({open:!1,caseId:"",caseMessageIndex:-1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:wl,annotationAuthor:"manual_reviewer",saving:!1,error:""}),[ue,mn]=y.useState({open:!1,messageIndex:-1,rating:3,comment:"",annotationAuthor:"manual_reviewer",saving:!1,error:""}),[Ue,Fn]=y.useState({open:!1,title:"",saving:!1,error:""}),[$t,Lr]=y.useState({open:!1,generationId:"",questionIndex:-1,questionText:"",saving:!1,error:""}),[Et,Un]=y.useState({open:!1,generationId:"",title:"",saving:!1,error:""}),Bn=y.useRef(!1),Hn=y.useRef(null),qt=W.mode==="saved_user_sessions",rs=y.useMemo(()=>St.find(a=>a.id===W.personalityId)??St[0]??da[0],[W.personalityId,St]),pt=y.useMemo(()=>Zn.filter(a=>a.mode===W.mode),[Zn,W.mode]),kt=y.useMemo(()=>pt.find(a=>a.generation_id===Dn)??pt[0]??null,[Dn,pt]),pn=y.useMemo(()=>xe?re.filter(a=>!a.resolved):re,[re,xe]),Ne=pn.find(a=>a.annotation_id===wn)??null,So=v?.messages.find(a=>a.message_index===ge.messageIndex)??null,zs=y.useMemo(()=>{if(!v||ge.messageIndex<0)return null;for(let a=ge.messageIndex-1;a>=0;a-=1){const c=v.messages[a];if(c?.role==="user")return c}return null},[ge.messageIndex,v]),ve=y.useMemo(()=>{const a=new Map;for(const c of qe)c.message_id&&a.set(c.message_id,c);return a},[qe]),$s=ue.messageIndex>=0?D[ue.messageIndex]??null:null,Fs=y.useMemo(()=>{if(ue.messageIndex<0)return null;for(let a=ue.messageIndex-1;a>=0;a-=1){const c=D[a];if(c?.role==="user")return c}return null},[ue.messageIndex,D]),Ft=y.useMemo(()=>{const a=pn.map(p=>({source:"autorun",key:`autorun:${p.annotation_id}`,updated_at:p.updated_at,rating:p.rating,autorun:p,assistant:null})),c=qe.map(p=>({source:"assistant_live",key:`assistant:${p.annotation_id}`,updated_at:p.updated_at,rating:p.rating,autorun:null,assistant:p}));return[...a,...c].sort((p,j)=>Date.parse(j.updated_at)-Date.parse(p.updated_at))},[qe,pn]),Us=y.useMemo(()=>{if(Ft.length===0)return null;const a=Ft.reduce((c,p)=>c+p.rating,0)/Ft.length;return Number(a.toFixed(2))},[Ft]),ss=y.useMemo(()=>{const a=[...Z?.items??[]];return Ke&&a.unshift(Xc(Ke)),Ee&&!a.some(c=>c.run_id===Ee)&&U?.run&&a.unshift(U.run),a},[Ke,Z?.items,U?.run,Ee]),J=y.useCallback(a=>{ot?.(`[autoruns] ${a}`)},[ot]),lr=y.useCallback(async a=>{const c=String(a??"").trim();if(!c){Ar([]);return}try{const p=await Pe.loadAssistantAnnotations({session_id:c,limit:400});Ar(p.items??[])}catch(p){const j=p instanceof Error?p.message:String(p);J(`Assistant live annotations load error: ${j}`)}},[J]),hn=y.useCallback(a=>{mn(c=>c.saving&&!a?.force?c:{open:!1,messageIndex:-1,rating:3,comment:"",annotationAuthor:"manual_reviewer",saving:!1,error:""})},[]),Ut=y.useCallback(a=>{Fn(c=>c.saving&&!a?.force?c:{open:!1,title:"",saving:!1,error:""})},[]),Bt=y.useCallback(a=>{Lr(c=>c.saving&&!a?.force?c:{open:!1,generationId:"",questionIndex:-1,questionText:"",saving:!1,error:""})},[]),Ht=y.useCallback(a=>{Un(c=>c.saving&&!a?.force?c:{open:!1,generationId:"",title:"",saving:!1,error:""})},[]),Nn=y.useCallback(async(a,c,p)=>{a.stopPropagation(),a.preventDefault();const j=String(c??"").trim();if(j)try{if(navigator?.clipboard?.writeText)await navigator.clipboard.writeText(j);else{const $=document.createElement("textarea");$.value=j,$.setAttribute("readonly","true"),$.style.position="fixed",$.style.opacity="0",document.body.appendChild($),$.select(),document.execCommand("copy"),document.body.removeChild($)}J(`${p} copied: ${j}`)}catch($){const Le=$ instanceof Error?$.message:String($);Oe(`Копирование ${p}: ${Le}`),J(`copy ${p} error: ${Le}`)}},[J]);function Ir(){let a=0;rr(oa[0]);const c=window.setInterval(()=>{a=Math.min(a+1,oa.length-1),rr(oa[a])},650);return()=>window.clearInterval(c)}const En=y.useCallback(()=>{K(""),ke([]),Ar([]),Ls(""),ts(null),rr(""),zn(""),hn({force:!0}),J("Live-чат ассистента в истории автопрогонов сброшен.")},[hn,J]),Ml=y.useCallback(async()=>{const a=tm(As,fn);if(!a)return;Ds(!0),zn(""),Ls(""),ke(p=>[...p,{message_id:`autoruns-live-${Date.now()}`,session_id:k||"pending",role:"user",text:a,reply_type:null,created_at:new Date().toISOString(),trace_id:null,debug:null}]);const c=Ir();try{const p=await Pe.sendAssistantMessage({connection:i,prompts:z,userMessage:a,sessionId:k||void 0,promptVersion:F,useMock:ns});K(p.session_id),ke(p.conversation),await lr(p.session_id),rr("Ответ готов"),J(`Live-ответ ассистента получен: trace=${p.debug.trace_id}`)}catch(p){const j=p instanceof Error?p.message:String(p);zn(j),rr("Ошибка ассистента"),J(`Live-чат ассистента: ошибка отправки сообщения: ${j}`)}finally{c(),Ds(!1)}},[As,fn,k,ns,F,i,lr,J,z]),wo=y.useCallback(()=>{if(!k.trim()||D.length===0){zn("Сначала получите хотя бы один ответ в живой сессии ассистента.");return}zn(""),Fn({open:!0,title:sm(D),saving:!1,error:""})},[D,k]),Dr=y.useCallback(async()=>{const a=k.trim(),c=Ue.title.trim();if(!a){Fn(p=>({...p,error:"Активная сессия ассистента не найдена."}));return}if(!c){Fn(p=>({...p,error:"Укажите название сессии."}));return}Fn(p=>({...p,saving:!0,error:""}));try{const p=[z.systemPrompt,z.developerPrompt,z.domainPrompt,z.schemaNotes,z.fewShotExamples].join("||"),j=await Pe.saveAutoRunAssistantSession({session_id:a,title:c,generated_by:W.generatedBy.trim()||void 0,context:{llm_provider:i.llmProvider,model:i.model,assistant_prompt_version:F,decomposition_prompt_version:oe,prompt_fingerprint:p}});In($=>[j.generation,...$.filter(Le=>Le.generation_id!==j.generation.generation_id)]),it($=>({...$,mode:"saved_user_sessions"})),kn(j.generation.generation_id),Ut({force:!0}),J(`Живая сессия сохранена в автопрогоны: ${j.generation.generation_id}`)}catch(p){const j=p instanceof Error?p.message:String(p);Fn($=>({...$,saving:!1,error:j})),J(`Assistant live save error: ${j}`)}},[Ue.title,k,F,W.generatedBy,Ut,i.llmProvider,i.model,oe,J,z.developerPrompt,z.domainPrompt,z.fewShotExamples,z.schemaNotes,z.systemPrompt]),ko=y.useCallback(a=>{const c=a.trim();if(!c){sr(String(H.limit));return}if(!/^\d+$/.test(c)){sr(String(H.limit));return}const p=Number.parseInt(c,10);if(!Number.isFinite(p)){sr(String(H.limit));return}const j=Math.max(1,Math.min(500,p));j!==H.limit&&Me($=>({...$,limit:j})),sr(String(j))},[H.limit]),Bs=y.useCallback(a=>{const c=a.trim();if(!c){$n(String(W.count));return}if(!/^\d+$/.test(c)){$n(String(W.count));return}const p=Number.parseInt(c,10);if(!Number.isFinite(p)){$n(String(W.count));return}const j=Math.max(1,Math.min(200,p));j!==W.count&&it($=>({...$,count:j})),$n(String(j))},[W.count]),Or=y.useCallback(a=>{_o(zc(a))},[]),Hs=y.useCallback(a=>{const c=a.currentTarget.offsetHeight;Number.isFinite(c)&&c>0&&Or(c)},[Or]),zr=y.useCallback(async()=>{tr(!0);try{const a=await Pe.loadAutoRunAnnotations({limit:800,manual_case_decision:ae});ie(a.items),lt(a.manual_case_decision_schema??null),Xn(a.available_manual_case_decisions??[]),nn(c=>a.items.length===0?"":a.items.some(p=>p.annotation_id===c)?c:a.items[0].annotation_id)}catch(a){J(`Annotations load error: ${a instanceof Error?a.message:String(a)}`)}finally{tr(!1)}},[ae,J]),Qt=y.useCallback(async()=>{On(!0);try{const a=await Pe.loadAutoRunAutogenHistory({limit:180});In(a.items)}catch(a){J(`Autogen history load error: ${a instanceof Error?a.message:String(a)}`)}finally{On(!1)}},[J]),ir=y.useCallback(async()=>{try{const c=(await Pe.loadAutoRunAutogenPersonalityCatalog()).items.map(p=>({id:String(p.id??"").trim(),label:String(p.label??"").trim(),domain:typeof p.domain=="string"?p.domain.trim():"",defaultPrompt:String(p.default_prompt??"").trim()})).filter(p=>p.id.length>0&&p.label.length>0);if(c.length===0)return;rn(c.map(p=>({id:p.id,label:p.label,domain:p.domain||"",defaultPrompt:p.defaultPrompt||"Генерируй реалистичные вопросы бухгалтера по выбранному профилю. Не выдумывай непокрытые возможности."})))}catch(a){J(`Autogen personality catalog load error: ${a instanceof Error?a.message:String(a)}`)}},[J]),ht=y.useCallback(async()=>{un(!0);try{const a=await Pe.loadAutoRunPostAnalysis({run_id:Ee&&!Ms(Ee)?Ee:void 0,limit_per_queue:30,annotation_limit:1500,from:kl(H.fromLocal),to:kl(H.toLocal),target:H.target,mode:H.mode,use_mock:H.useMock,prompt_contains:H.promptContains.trim()||void 0});Zr(a)}catch(a){J(`Post-analysis load error: ${a instanceof Error?a.message:String(a)}`),Zr(null)}finally{un(!1)}},[H.fromLocal,H.mode,H.promptContains,H.target,H.toLocal,H.useMock,J,Ee]),os=y.useCallback(async()=>{Er(!0),Oe("");try{if(W.mode==="saved_user_sessions")throw new Error("Пользовательские сессии сохраняются из живого чата, а не генерируются автоматически.");const a=W.personalityPrompts[W.personalityId]??"",c=[z.systemPrompt,z.developerPrompt,z.domainPrompt,z.schemaNotes,z.fewShotExamples].join(` -`).slice(0,900),p=await Pe.generateAutoRunQuestions({mode:W.mode,count:W.count,domain:rs.domain||void 0,persist_to_eval_cases:W.persistToEvalCases,generated_by:W.generatedBy.trim()||void 0,llm:{llm_provider:i.llmProvider,api_key:i.apiKey,model:i.model,base_url:i.baseUrl,temperature:i.temperature,max_output_tokens:i.maxOutputTokens},context:{llm_provider:i.llmProvider,model:i.model,assistant_prompt_version:F,decomposition_prompt_version:oe,prompt_fingerprint:c,autogen_personality_id:rs.id,autogen_personality_prompt:a.trim()||void 0}});J(`Generated ${p.generation.count} questions (${p.generation.mode}) id=${p.generation.generation_id}`+(p.generation.saved_case_set_file?` saved=${p.generation.saved_case_set_file}`:"")),kn(p.generation.generation_id),zt([...p.generation.questions??[]]),await Qt()}catch(a){const c=a instanceof Error?a.message:String(a);Oe(`Автогенерация: ${c}`),J(`Autogen generate error: ${c}`)}finally{Er(!1)}},[F,W.count,W.generatedBy,W.mode,W.personalityId,W.personalityPrompts,W.persistToEvalCases,i.apiKey,i.baseUrl,i.llmProvider,i.maxOutputTokens,i.model,i.temperature,oe,Qt,J,z.developerPrompt,z.domainPrompt,z.fewShotExamples,z.schemaNotes,z.systemPrompt,rs.domain,rs.id]),$r=y.useCallback(async(a,c)=>{if(Ms(a)){const p=Hc(a);if(Ke&&Ke.job_id===p){const j=yo(Ke,c);Ot(a),ft(j.caseId),w(j.dialog);return}w(null);return}Rr(!0);try{const p=await Pe.loadAutoRunCaseDialog(a,c);w(p)}catch(p){const j=p instanceof Error?p.message:String(p);Oe(`Диалог кейса: ${j}`),w(null),J(`Dialog load error for ${a}/${c}: ${j}`)}finally{Rr(!1)}},[Ke,J]),Pn=y.useCallback(async(a,c)=>{if(Ms(a)){const p=Hc(a);if(Ke&&Ke.job_id===p){const j=yo(Ke,c??_t);Ot(a),ft(j.caseId),A(j.detail),w(j.dialog);return}Ot(a),ft(""),A(null),w(null);return}Pr(!0);try{const p=await Pe.loadAutoRunDetail(a);A(p);const j=(c&&(c===_t||p.cases.some($=>$.case_id===c))?c:"")||(p.cases.length>0?_t:"")||"";Ot(a),ft(j),j?await $r(a,j):w(null)}catch(p){const j=p instanceof Error?p.message:String(p);Oe(`Детализация прогона: ${j}`),A(null),w(null),J(`Run detail load error for ${a}: ${j}`)}finally{Pr(!1)}},[Ke,$r,J]),Qn=y.useCallback(async a=>{dn(!0),Oe("");try{const c=await Pe.loadAutoRunsHistory({from:kl(H.fromLocal),to:kl(H.toLocal),target:H.target,mode:H.mode,use_mock:H.useMock,prompt_contains:H.promptContains.trim()||void 0,limit:H.limit});if(M(c),c.items.length===0){Ot(""),ft(""),A(null),w(null);return}const p=a?.keepSelection??!0,j=a?.preferredRunId??"",$=a?.preferredCaseId??"",Le=p&&j&&c.items.some(at=>at.run_id===j)?j:c.items[0].run_id;await Pn(Le,p?$:void 0),ht()}catch(c){const p=c instanceof Error?c.message:String(c);Oe(`История прогонов: ${p}`),J(`History load error: ${p}`)}finally{dn(!1)}},[H.fromLocal,H.limit,H.mode,H.promptContains,H.target,H.toLocal,H.useMock,ht,Pn,J]),Pt=y.useCallback(()=>{Hn.current!==null&&(window.clearTimeout(Hn.current),Hn.current=null)},[]),Fr=y.useCallback(async a=>{try{const c=await Pe.loadEvalRunAsyncStatus(a);sn(c.job);const p=Cl(a);if(Ee===p){const j=yo(c.job,et||_t);A(j.detail),w(j.dialog),ft(j.caseId)}if(c.job.status==="completed"){Pt(),ln(!1);const j=c.job.report_summary?.run_id??c.job.run_id;await Qn({keepSelection:!0,preferredRunId:j||Ee,preferredCaseId:_t}),await Qt(),sn(null);return}if(c.job.status==="failed"){Pt(),ln(!1),Oe(`Запуск прогонов: ${c.job.error??"неизвестная ошибка"}`),J(`Autogen async run failed: ${c.job.error??"unknown error"}`);return}Pt(),Hn.current=window.setTimeout(()=>{Fr(a)},500)}catch(c){Pt(),ln(!1);const p=c instanceof Error?c.message:String(c);Oe(`Запуск прогонов: ${p}`),J(`Autogen async status error: ${p}`)}},[Qt,Qn,J,et,Ee,Pt]),jo=y.useCallback(async()=>{Pt(),ln(!0),Oe("");try{const a=kt;if(!a)throw new Error("История автогенерации пуста. Сначала сгенерируйте пачку вопросов.");const c=mt.map(Vs=>Vs.trim()).filter(Vs=>Vs.length>0);if(c.length===0)throw new Error("Нет вопросов для запуска: список пустой после ручного редактирования.");const p=H.useMock==="true",j=la(We),$=a.mode==="saved_user_sessions",at=(await Pe.startEvalRunAsync({connection:i,prompts:z,promptVersion:F,mode:"single-pass-strict",caseSetFile:$?void 0:a.saved_case_set_file??void 0,useMock:p,evalTarget:"assistant_stage1",questions:$?void 0:c,scenarioQuestions:$?c:void 0,scenarioTitle:$?a.title??void 0:void 0,analysisDate:$?void 0:j||void 0})).job;sn(at);const dr=Cl(at.job_id),bs=yo(at,_t);Ot(dr),ft(bs.caseId),A(bs.detail),w(bs.dialog),J(`Запущен async-прогон job=${at.job_id}, run_id=${at.run_id}, вопросов=${c.length}`+(a.saved_case_set_file?`, base_case_set=${a.saved_case_set_file}`:"")+($?", replay_mode=saved_user_session_scenario":j?`, analysis_date=${j}`:", analysis_date=current_state")),Fr(at.job_id)}catch(a){const c=a instanceof Error?a.message:String(a);Oe(`Запуск прогонов: ${c}`),J(`Autogen run error: ${c}`),ln(!1)}},[We,F,i,mt,H.useMock,J,Fr,z,kt,Pt]),Tn=y.useCallback(a=>{if(a.role!=="assistant")return;const c=a.case_id??et,p=a.case_message_index??a.message_index;wt({open:!0,caseId:c,caseMessageIndex:p,messageIndex:a.message_index,rating:a.annotation?.rating??3,comment:a.annotation?.comment??"",manualCaseDecision:a.annotation?.manual_case_decision??wl,annotationAuthor:a.annotation?.annotation_author??W.generatedBy,saving:!1,error:""})},[W.generatedBy,et]),ar=y.useCallback(a=>{wt(c=>c.saving&&!a?.force?c:{open:!1,caseId:"",caseMessageIndex:-1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:wl,annotationAuthor:W.generatedBy,saving:!1,error:""})},[W.generatedBy]),ls=y.useCallback(async()=>{const a=Ee,c=ge.caseId,p=ge.caseMessageIndex;if(!(!a||!c||p<0)){if(Ms(a)){wt(j=>({...j,error:"Комментарий можно сохранить после завершения прогона."}));return}if(!ge.comment.trim()){wt(j=>({...j,error:"Добавьте комментарий."}));return}wt(j=>({...j,saving:!0,error:""}));try{await Pe.saveAutoRunAnnotation({run_id:a,case_id:c,message_index:p,rating:ge.rating,comment:ge.comment.trim(),manual_case_decision:ge.manualCaseDecision,annotation_author:ge.annotationAuthor.trim()||void 0}),ar({force:!0}),Promise.all([Pn(a,et),zr(),ht()]).catch(j=>{const $=j instanceof Error?j.message:String(j);Oe(`Обновление после комментария: ${$}`),J(`Comment refresh error: ${$}`)})}catch(j){wt($=>({...$,saving:!1,error:j instanceof Error?j.message:String(j)}))}}},[ar,ge.annotationAuthor,ge.caseId,ge.caseMessageIndex,ge.comment,ge.manualCaseDecision,ge.rating,zr,ht,Pn,J,et,Ee]),Co=y.useCallback(a=>a.role==="assistant",[]),is=y.useCallback(a=>a.role==="assistant"&&ve.has(a.message_id),[ve]),as=y.useCallback((a,c)=>{if(a.role!=="assistant")return;const p=k.trim(),j=String(a.session_id??"").trim();if(!(p||j)){zn("Сначала получите ответ ассистента в активной сессии.");return}!p&&j&&K(j);const Le=ve.get(a.message_id)??null;zn(""),mn({open:!0,messageIndex:c,rating:Le?.rating??3,comment:Le?.comment??"",annotationAuthor:Le?.annotation_author??"manual_reviewer",saving:!1,error:""})},[ve,k]),No=y.useCallback(async()=>{if(ue.messageIndex<0)return;if(!ue.comment.trim()){mn(p=>({...p,error:"Добавьте комментарий."}));return}const a=D[ue.messageIndex]??null,c=k.trim()||(a?.role==="assistant"?String(a.session_id??"").trim():"");if(!c){mn(p=>({...p,error:"Сессия ассистента не найдена."}));return}mn(p=>({...p,saving:!0,error:""}));try{const p=await Pe.saveAssistantAnnotation({session_id:c,message_index:ue.messageIndex,rating:ue.rating,comment:ue.comment.trim(),annotation_author:ue.annotationAuthor.trim()||void 0});Ar(j=>{const $=[...j],Le=$.findIndex(at=>at.annotation_id===p.annotation.annotation_id);return Le>=0?$[Le]=p.annotation:$.unshift(p.annotation),$.sort((at,dr)=>Date.parse(dr.updated_at)-Date.parse(at.updated_at))}),hn({force:!0})}catch(p){const j=p instanceof Error?p.message:String(p);mn($=>({...$,saving:!1,error:j}))}},[ue.annotationAuthor,ue.comment,ue.messageIndex,ue.rating,D,k,hn]),jt=y.useCallback(a=>{if(!kt||kt.mode!=="saved_user_sessions")return;const c=mt[a]??"";Lr({open:!0,generationId:kt.generation_id,questionIndex:a,questionText:c,saving:!1,error:""})},[mt,kt]),ur=y.useCallback(async()=>{const a=$t.generationId,c=$t.questionIndex;if(!a||c<0)return;const p=mt.filter((j,$)=>$!==c);if(p.length===0){Lr(j=>({...j,error:"Нельзя удалить последний вопрос из сохраненной сессии."}));return}Lr(j=>({...j,saving:!0,error:""}));try{const j=await Pe.updateAutoRunAutogenQuestions({generation_id:a,questions:p});In($=>$.map(Le=>Le.generation_id===a?j.generation:Le)),zt(j.generation.questions),Bt({force:!0}),J(`Обновлена сохраненная сессия: ${a}`)}catch(j){const $=j instanceof Error?j.message:String(j);Lr(Le=>({...Le,saving:!1,error:$})),J(`Saved session question delete error: ${$}`)}},[Bt,mt,J,$t.generationId,$t.questionIndex]),Qs=y.useCallback(a=>{Un({open:!0,generationId:a.generation_id,title:a.title??`${ia(a.mode)} ${tn(a.created_at)}`,saving:!1,error:""})},[]),Ur=y.useCallback(async()=>{const a=Et.generationId.trim();if(a){Un(c=>({...c,saving:!0,error:""}));try{const c=await Pe.deleteAutoRunAutogenHistoryRecord(a);In(p=>p.filter(j=>j.generation_id!==c.generation_id)),Ht({force:!0}),J(`Удален набор автопрогона: ${c.generation_id}`+(c.deleted_files.length>0?`, files=${c.deleted_files.length}`:""))}catch(c){const p=c instanceof Error?c.message:String(c);Un(j=>({...j,saving:!1,error:p})),J(`Autogen record delete error: ${p}`)}}},[Et.generationId,Ht,J]),Eo=y.useCallback(a=>{ie(c=>c.map(p=>p.annotation_id===a.annotation_id?{...p,...a}:p)),w(c=>c&&{...c,annotations:c.annotations.map(p=>p.annotation_id===a.annotation_id?a:p),messages:c.messages.map(p=>!p.annotation||p.annotation.annotation_id!==a.annotation_id?p:{...p,commented:!0,annotation:a})})},[]),us=y.useCallback(async(a,c)=>{if(a.annotation_id){if(Ms(a.run_id)){Oe("Статус выполнения можно менять только для завершённых прогонов.");return}Cn(a.annotation_id);try{const p=await Pe.updateAutoRunAnnotation({annotation_id:a.annotation_id,resolved:c,resolved_by:W.generatedBy||void 0});Eo(p.annotation),ht()}catch(p){const j=p instanceof Error?p.message:String(p);Oe(`Смена статуса кейса: ${j}`),J(`Annotation resolve toggle error: ${j}`)}finally{Cn("")}}},[Eo,W.generatedBy,ht,J]),cs=y.useCallback(async a=>{nn(a.annotation_id),await Pn(a.run_id,a.case_id),Z?.items.some(c=>c.run_id===a.run_id)||Oe("Комментарий относится к прогону вне текущего фильтра. Детали загружены напрямую.")},[Z?.items,Pn]);y.useEffect(()=>{Bn.current||(Bn.current=!0,Qn({keepSelection:!1}),Qt(),ir(),ht())},[Qt,ir,Qn,ht]),y.useEffect(()=>{Bn.current&&zr()},[ae,zr]),y.useEffect(()=>{nn(a=>pn.length===0?"":pn.some(c=>c.annotation_id===a)?a:pn[0].annotation_id)},[pn]),y.useEffect(()=>{kn(a=>pt.length===0?"":a&&pt.some(c=>c.generation_id===a)?a:pt[0].generation_id)},[pt]),y.useEffect(()=>{if(!kt){zt([]);return}zt([...kt.questions])},[kt]),y.useEffect(()=>{sr(String(H.limit))},[H.limit]),y.useEffect(()=>{$n(String(W.count))},[W.count]),y.useEffect(()=>{if(!k.trim()){Ar([]);return}lr(k)},[k,lr]),y.useEffect(()=>{if(!Ke)return;const a=Cl(Ke.job_id);if(Ee!==a)return;const c=yo(Ke,et||_t);A(c.detail),w(c.dialog),ft(c.caseId)},[Ke,et,Ee]),y.useEffect(()=>()=>{Pt()},[Pt]),y.useEffect(()=>{St.length!==0&&it(a=>{let c=!1;const p={...a.personalityPrompts};for(const $ of St)(typeof p[$.id]!="string"||p[$.id].trim().length===0)&&(p[$.id]=$.defaultPrompt,c=!0);let j=a.personalityId;return St.some($=>$.id===a.personalityId)||(j=St[0].id,c=!0),c?{...a,personalityId:j,personalityPrompts:p}:a})},[St]),y.useEffect(()=>{const a=localStorage.getItem(Ic);if(a)try{const c=JSON.parse(a);if(c.filters){const p=c.filters;Me(j=>({...j,...p,limit:typeof p.limit=="number"?Math.max(1,Math.min(500,p.limit)):j.limit}))}typeof c.analysisDate=="string"&&ne(la(c.analysisDate)),typeof c.autogenPersonalityPromptHeight=="number"&&_o(zc(c.autogenPersonalityPromptHeight)),c.autoGenSettings&&it(p=>{const j={...p.personalityPrompts},$=c.autoGenSettings?.personalityPrompts??{};for(const[at,dr]of Object.entries($))typeof dr=="string"&&at.trim().length>0&&(j[at.trim()]=dr);const Le=typeof c.autoGenSettings?.personalityId=="string"&&c.autoGenSettings.personalityId.trim().length>0?c.autoGenSettings.personalityId.trim():p.personalityId;return{...p,mode:c.autoGenSettings?.mode==="codex_creative"||c.autoGenSettings?.mode==="qwen_seed"||c.autoGenSettings?.mode==="saved_user_sessions"?c.autoGenSettings.mode:p.mode,count:typeof c.autoGenSettings?.count=="number"?Math.max(1,Math.min(200,c.autoGenSettings.count)):p.count,personalityId:Le,personalityPrompts:j,persistToEvalCases:typeof c.autoGenSettings?.persistToEvalCases=="boolean"?c.autoGenSettings.persistToEvalCases:p.persistToEvalCases,generatedBy:typeof c.autoGenSettings?.generatedBy=="string"?c.autoGenSettings.generatedBy:p.generatedBy}}),(c.annotationDecisionFilter==="all"||typeof c.annotationDecisionFilter=="string"&&c.annotationDecisionFilter.length>0)&&he(c.annotationDecisionFilter),typeof c.hideResolvedAnnotations=="boolean"&&_e(c.hideResolvedAnnotations)}catch{}},[]);const cr=y.useCallback(()=>{const a={filters:H,analysisDate:We,autogenPersonalityPromptHeight:or,autoGenSettings:{mode:W.mode,count:W.count,personalityId:W.personalityId,personalityPrompts:W.personalityPrompts,persistToEvalCases:W.persistToEvalCases,generatedBy:W.generatedBy},annotationDecisionFilter:ae,hideResolvedAnnotations:xe};localStorage.setItem(Ic,JSON.stringify(a))},[We,ae,W,or,H,xe]);return y.useEffect(()=>{const a=()=>{cr(),J("Сохранены настройки панели автопрогонов.")};return window.addEventListener(Dc,a),()=>{window.removeEventListener(Dc,a)}},[J,cr]),l.jsxs(Pl,{className:"autoruns-frame",title:"",hideHeader:!0,children:[l.jsxs("div",{className:"autoruns-columns",children:[Ce?l.jsxs("section",{className:"autoruns-col autoruns-settings-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Настройки"})}),l.jsxs("div",{className:"autoruns-settings-stack",children:[l.jsx(Zf,{embedded:!0,value:i,modelOptions:h,modelsBusy:f,onChange:L,onReloadModels:Q,onSaveLocalConfig:le,onTestConnection:te,lastStatus:R,busy:E}),l.jsx(em,{embedded:!0,value:z,onChange:Y,presets:X,selectedPresetId:ee,onSelectPreset:Te,onLoadPreset:ce,onSavePreset:de,onResetDefaults:pe,onDiffPrevious:Qe,presetName:Je,onPresetNameChange:be,diffSummary:Re})]})]}):null,$e?l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Автопрогоны"})}),l.jsx("h4",{children:"Настройки выборки"}),l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Дата с",l.jsx("input",{type:"datetime-local",value:H.fromLocal,onChange:a=>Me(c=>({...c,fromLocal:a.target.value}))})]}),l.jsxs("label",{children:["Дата по",l.jsx("input",{type:"datetime-local",value:H.toLocal,onChange:a=>Me(c=>({...c,toLocal:a.target.value}))})]}),l.jsxs("label",{children:["Целевой контур",l.jsxs("select",{value:H.target,onChange:a=>Me(c=>({...c,target:a.target.value})),children:[l.jsx("option",{value:"all",children:"все"}),(Z?.available.targets??[]).map(a=>l.jsx("option",{value:a,children:a},a))]})]}),l.jsxs("label",{children:["Режим",l.jsxs("select",{value:H.mode,onChange:a=>Me(c=>({...c,mode:a.target.value})),children:[l.jsx("option",{value:"all",children:"все"}),(Z?.available.modes??[]).map(a=>l.jsx("option",{value:a,children:a},a))]})]}),l.jsxs("label",{children:["Использовать mock",l.jsxs("select",{value:H.useMock,onChange:a=>Me(c=>({...c,useMock:a.target.value})),children:[l.jsx("option",{value:"any",children:"любой"}),l.jsx("option",{value:"true",children:"да"}),l.jsx("option",{value:"false",children:"нет"})]})]}),l.jsxs("label",{children:["Лимит",l.jsx("input",{type:"number",min:1,max:500,value:Fe,onChange:a=>{const c=a.target.value;(c===""||/^\d+$/.test(c))&&sr(c)},onBlur:a=>ko(a.target.value),onKeyDown:a=>{a.key==="Enter"&&ko(a.target.value)}})]}),l.jsxs("label",{className:"full-width",children:["Версия промпта содержит",l.jsx("input",{value:H.promptContains,onChange:a=>Me(c=>({...c,promptContains:a.target.value})),placeholder:"normalizer_v2_0_2 / address_query_runtime_v1",list:"autoruns-prompt-versions"})]})]}),l.jsx("datalist",{id:"autoruns-prompt-versions",children:(Z?.available.prompt_versions??[]).map(a=>l.jsx("option",{value:a},a))}),l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",disabled:me,onClick:()=>{Qn({keepSelection:!1})},children:me?"Обновляю...":"Применить"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>{Me({...sa,fromLocal:$c()}),Oe("")},children:"Сбросить фильтры"})]}),l.jsx("h4",{children:"Контур генерации"}),l.jsxs("div",{className:"autoruns-meta-list",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Провайдер:"}),l.jsx("strong",{children:i.llmProvider})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Модель:"}),l.jsx("strong",{children:i.model||"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Промпт ассистента:"}),l.jsx("strong",{children:F})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Промпт декомпозиции:"}),l.jsx("strong",{children:oe})]})]}),l.jsx("h4",{children:"Автопрогоны"}),l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Режимы",l.jsxs("select",{value:W.mode,onChange:a=>it(c=>({...c,mode:a.target.value})),children:[l.jsx("option",{value:"codex_creative",children:"codex_creative"}),l.jsx("option",{value:"qwen_seed",children:"qwen_seed"}),l.jsx("option",{value:"saved_user_sessions",children:"Пользовательские сессии"})]})]}),qt?null:l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Кол-во",l.jsx("input",{type:"number",min:1,max:200,value:Os,onChange:a=>{const c=a.target.value;(c===""||/^\d+$/.test(c))&&$n(c)},onBlur:a=>Bs(a.target.value),onKeyDown:a=>{a.key==="Enter"&&Bs(a.target.value)}})]}),l.jsxs("label",{children:["Личность автогенерации",l.jsx("select",{value:W.personalityId,onChange:a=>it(c=>({...c,personalityId:a.target.value})),children:St.map(a=>l.jsx("option",{value:a.id,children:a.label},a.id))})]}),l.jsxs("label",{children:["Кто генерирует",l.jsx("input",{value:W.generatedBy,onChange:a=>it(c=>({...c,generatedBy:a.target.value})),placeholder:"manual_reviewer"})]}),l.jsxs("label",{className:"full-width",children:["Промпт личности",l.jsx("textarea",{className:"autoruns-personality-prompt",value:W.personalityPrompts[W.personalityId]??"",onChange:a=>it(c=>({...c,personalityPrompts:{...c.personalityPrompts,[c.personalityId]:a.target.value}})),placeholder:"Текст промпта для выбранной личности автогенерации",style:{height:`${or}px`},onMouseUp:Hs,onTouchEnd:Hs})]}),l.jsxs("label",{className:"checkbox-row",children:[l.jsx("input",{type:"checkbox",checked:W.persistToEvalCases,onChange:a=>it(c=>({...c,persistToEvalCases:a.target.checked}))}),"Сохранять кейс-сет в `eval_cases`"]})]})]}),qt?null:l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Дата анализа (срез)",l.jsx("input",{type:"date",value:We,onChange:a=>ne(la(a.target.value))})]}),l.jsx("div",{className:"button-row",children:l.jsx("button",{type:"button",className:"tab",disabled:!We,onClick:()=>ne(""),children:"Сбросить дату среза"})})]}),l.jsxs("div",{className:"button-row",children:[qt?null:l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",disabled:Nr,onClick:()=>{os()},children:Nr?"Генерирую...":"Сгенерировать пачку"}),l.jsx("button",{type:"button",className:"tab",disabled:cn,onClick:()=>{Qt()},children:cn?"Обновляю...":"Обновить историю"})]}),l.jsx("button",{type:"button",className:"autoruns-run-launch-btn",disabled:es||mt.length===0||!kt,onClick:()=>{jo()},children:es?"Запускаю...":"Запустить прогон"})]}),l.jsx("div",{className:"autoruns-form-grid",children:l.jsxs("label",{className:"full-width",children:[qt?"Сохраненная сессия":"Кейс-сет для запуска",l.jsxs("select",{value:Dn,onChange:a=>kn(a.target.value),disabled:pt.length===0,children:[pt.length===0?l.jsx("option",{value:"",children:qt?"нет сохраненных сессий":"нет генераций"}):null,pt.map(a=>l.jsxs("option",{value:a.generation_id,children:[tn(a.created_at)," | ",Fc(a)??ia(a.mode)," | ",a.count]},a.generation_id))]})]})}),l.jsxs("div",{className:"autoruns-generated-questions",children:[l.jsxs("div",{className:"autoruns-generated-questions-head",children:[l.jsxs("strong",{children:["Вопросы к запуску: ",mt.length]}),l.jsx("button",{type:"button",className:"tab",onClick:()=>zt([...kt?.questions??[]]),disabled:!kt,children:"Восстановить"})]}),mt.length===0?l.jsx("p",{className:"muted",children:qt?"Список вопросов пуст. Сначала сохраните живую пользовательскую сессию.":"Список вопросов пуст. Сгенерируйте пачку или восстановите из выбранной генерации."}):l.jsx("div",{className:"autoruns-generated-questions-list",children:mt.map((a,c)=>l.jsxs("div",{className:"autoruns-generated-question-item",children:[l.jsxs("span",{children:[c+1,". ",a]}),l.jsx("button",{type:"button",className:"autoruns-remove-question-btn",onClick:()=>{if(qt){jt(c);return}zt(p=>p.filter((j,$)=>$!==c))},title:"Удалить вопрос из запуска","aria-label":"Удалить вопрос из запуска",children:"×"})]},`${c}-${a.slice(0,24)}`))})]}),l.jsx("p",{className:"muted",children:qt?"Запуск воспроизводит сохраненную пользовательскую сессию как один последовательный multi-turn сценарий assistant_stage1.":"Запуск выполняет `assistant_stage1` eval по выбранному кейс-сету."}),l.jsxs("div",{className:"autoruns-autogen-list",children:[cn?l.jsx("p",{className:"muted",children:qt?"Загружаю сохраненные пользовательские сессии...":"Загружаю историю автогенераций..."}):null,!cn&&pt.length===0?l.jsx("p",{className:"muted",children:qt?"Сохраненные пользовательские сессии пока пусты.":"История автогенераций пока пустая."}):null,pt.slice(0,30).map(a=>l.jsxs("article",{className:Dn===a.generation_id?"autoruns-autogen-item selected":"autoruns-autogen-item",onClick:()=>kn(a.generation_id),children:[l.jsxs("header",{children:[l.jsx("strong",{children:Fc(a)}),l.jsxs("div",{className:"autoruns-autogen-card-actions",children:[l.jsx("span",{children:tn(a.created_at)}),l.jsx("button",{type:"button",className:"autoruns-autogen-delete-btn",onClick:c=>{c.preventDefault(),c.stopPropagation(),Qs(a)},title:"Удалить сохраненный набор","aria-label":`Удалить набор ${a.generation_id}`,children:"×"})]})]}),l.jsxs("div",{className:"autoruns-run-meta autoruns-run-id-row",children:[l.jsx("span",{children:a.generation_id}),l.jsx("span",{role:"button",tabIndex:0,className:"autoruns-copy-run-id-btn",onClick:c=>{Nn(c,a.generation_id,"set id")},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),Nn(c,a.generation_id,"set id"))},title:"Скопировать id набора","aria-label":`Скопировать id набора ${a.generation_id}`,children:l.jsx(bc,{})})]}),l.jsxs("div",{className:"autoruns-run-meta",children:["режим=",ia(a.mode)]}),l.jsxs("div",{className:"autoruns-run-meta",children:["тип=",Yc(a)?"АГЕНТНЫЙ ПРОГОН":"АВТОПРОГОН"]})]},a.generation_id))]}),l.jsxs("details",{className:"autoruns-prompt-details",children:[l.jsx("summary",{children:"Копия активного промпта (только чтение)"}),l.jsxs("label",{children:["Системный",l.jsx("textarea",{readOnly:!0,value:z.systemPrompt})]}),l.jsxs("label",{children:["Разработчика",l.jsx("textarea",{readOnly:!0,value:z.developerPrompt})]}),l.jsxs("label",{children:["Доменный",l.jsx("textarea",{readOnly:!0,value:z.domainPrompt})]}),l.jsxs("label",{children:["Заметки по схеме",l.jsx("textarea",{readOnly:!0,value:z.schemaNotes})]}),l.jsxs("label",{children:["Примеры few-shot",l.jsx("textarea",{readOnly:!0,value:z.fewShotExamples})]})]}),nr?l.jsx("p",{className:"error-text",children:nr}):null]}):null,l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Выдача прогонов"})}),l.jsxs("div",{className:"autoruns-stats-grid",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Всего"}),l.jsx("strong",{children:(Z?.stats.runs_total??0)+(Ke?1:0)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Средний score"}),l.jsx("strong",{children:jl(Z?.stats.avg_score_index??null)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Тренд"}),l.jsx("strong",{children:Z?Uc(Z.stats.trend):"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Блокеры"}),l.jsx("strong",{children:Z?.stats.blocking_runs??0})]})]}),l.jsxs("div",{className:"autoruns-run-list",children:[ss.map(a=>l.jsxs("button",{type:"button",className:Ee===a.run_id?"autoruns-run-item selected":"autoruns-run-item",onClick:()=>{Pn(a.run_id)},children:[l.jsxs("div",{className:"autoruns-run-head",children:[l.jsx("strong",{children:tn(a.run_timestamp)}),l.jsx("span",{children:lm(a.eval_target)})]}),l.jsxs("div",{className:"autoruns-run-meta autoruns-run-id-row",children:[l.jsx("span",{children:a.run_id}),l.jsx("span",{role:"button",tabIndex:0,className:"autoruns-copy-run-id-btn",onClick:c=>{Nn(c,a.run_id,"run id")},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),Nn(c,a.run_id,"run id"))},title:"Скопировать run id","aria-label":`Скопировать run id ${a.run_id}`,children:l.jsx(bc,{})})]}),l.jsxs("div",{className:"autoruns-run-meta",children:["режим=",a.mode??"нет данных"," | mock=",String(a.use_mock)]}),l.jsxs("div",{className:"autoruns-run-meta",children:["analysis_date=",a.analysis_date??"current_state"]}),a.llm_provider||a.model?l.jsxs("div",{className:"autoruns-run-meta",children:["llm=",a.llm_provider??"нет данных"," | модель=",a.model??"нет данных"]}):null,l.jsxs("div",{className:"autoruns-run-meta",children:["промпт=",a.prompt_version??"нет данных"]}),l.jsxs("div",{className:"autoruns-run-foot",children:[l.jsxs("span",{children:["оценка: ",jl(a.score_index)]}),l.jsxs("span",{children:["закрыто/открыто: ",a.closed_cases,"/",a.open_cases]})]}),l.jsxs("div",{className:"autoruns-run-foot",children:[l.jsxs("span",{children:["блокеры: ",a.blocking_failures]}),l.jsxs("span",{children:["качество: ",a.quality_failures]})]})]},a.run_id)),ss.length===0?l.jsx("p",{className:"muted",children:"За выбранный диапазон прогонов нет."}):null]})]}),l.jsxs("section",{className:"autoruns-col",children:[l.jsxs("div",{className:"autoruns-col-header",children:[l.jsx("h3",{children:"Диалог прогона"}),l.jsxs("div",{className:"autoruns-dialog-toolbar",children:[l.jsxs("label",{children:["Прогон",l.jsx("select",{value:Ee,onChange:a=>{const c=a.target.value;Pn(c)},children:ss.map(a=>l.jsxs("option",{value:a.run_id,children:[tn(a.run_timestamp)," | ",a.run_id]},a.run_id))})]}),l.jsxs("label",{children:["Кейс",l.jsxs("select",{value:et,onChange:a=>{const c=a.target.value;ft(c),Ee&&c&&$r(Ee,c)},children:[(U?.cases.length??0)>0?l.jsx("option",{value:_t,children:"ВСЕ кейсы подряд"}):null,(U?.cases??[]).map(a=>l.jsxs("option",{value:a.case_id,children:[a.case_id," | ",a.status]},a.case_id))]})]})]})]}),l.jsxs("div",{className:"autoruns-case-list",children:[(U?.cases.length??0)>0?l.jsxs("button",{type:"button",className:et===_t?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{ft(_t),Ee&&$r(Ee,_t)},children:[l.jsx("span",{children:"ВСЕ кейсы подряд"}),l.jsx("span",{children:U?.cases.length})]},_t):null,(U?.cases??[]).map(a=>l.jsxs("button",{type:"button",className:et===a.case_id?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{ft(a.case_id),Ee&&$r(Ee,a.case_id)},children:[l.jsx("span",{children:a.case_id}),l.jsxs("span",{children:[a.status,a.commented_count>0?` | комм=${a.commented_count}`:""]})]},a.case_id))]}),l.jsxs("div",{className:"autoruns-dialog-view",children:[Tr||er?l.jsx("p",{className:"muted",children:"Загружаю диалог..."}):null,!Tr&&!er&&(v?.messages.length??0)===0?l.jsx("p",{className:"muted",children:"Диалог для этого прогона не найден."}):null,(v?.messages??[]).map((a,c)=>{const p=a.role==="assistant"?"assistant":"user";return l.jsxs("article",{className:`autoruns-msg ${p}`,children:[l.jsxs("header",{children:[l.jsx("strong",{children:p==="assistant"?"Система":"Модель/вопрос"}),l.jsxs("div",{className:"autoruns-msg-head-actions",children:[a.case_id?l.jsx("span",{className:"autoruns-msg-case-tag",children:a.case_id}):null,l.jsx("span",{children:a.created_at?tn(a.created_at):"нет данных"}),p==="assistant"&&!Ms(Ee)?l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:a.commented?"autoruns-comment-icon commented":"autoruns-comment-icon",onClick:()=>Tn(a),title:"\\u041a\\u043e\\u043c\\u043c\\u0435\\u043d\\u0442\\u0438\\u0440\\u043e\\u0432\\u0430\\u0442\\u044c \\u043e\\u0442\\u0432\\u0435\\u0442 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u044b","aria-label":"\\u041a\\u043e\\u043c\\u043c\\u0435\\u043d\\u0442\\u0438\\u0440\\u043e\\u0432\\u0430\\u0442\\u044c \\u043e\\u0442\\u0432\\u0435\\u0442 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u044b",children:l.jsx(im,{commented:a.commented})}),a.annotation?l.jsx("button",{type:"button",className:a.annotation.resolved?"autoruns-resolve-toggle resolved":"autoruns-resolve-toggle",onClick:()=>{us(a.annotation,!a.annotation.resolved)},disabled:Mr===a.annotation.annotation_id,title:a.annotation.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный","aria-label":a.annotation.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный",children:l.jsx(Qc,{resolved:a.annotation.resolved})}):null]}):null]})]}),l.jsx("p",{children:a.text}),p==="assistant"&&a.annotation?l.jsxs("div",{className:"autoruns-msg-annotation",children:[l.jsx("strong",{children:aa(a.annotation.rating)}),l.jsx("span",{children:a.annotation.comment}),l.jsxs("span",{className:"muted",children:[a.annotation.manual_case_decision,a.annotation.annotation_author?` | ${a.annotation.annotation_author}`:""]})]}):null,(a.trace_id||a.reply_type)&&l.jsxs("footer",{children:[a.trace_id?l.jsxs("span",{children:["trace=",a.trace_id]}):null,a.reply_type?l.jsxs("span",{children:["reply_type=",a.reply_type]}):null]})]},a.message_id??`${p}-${c}`)})]})]}),dt?l.jsx("div",{className:"autoruns-col autoruns-assistant-live-col",children:l.jsx(Gf,{sessionId:k,conversation:D,inputValue:As,onInputChange:Ls,selectedContextChip:fn,onSelectContextChip:ts,onClearContextChip:()=>ts(null),useMock:ns,onUseMockChange:Tl,onSend:Ml,onClear:En,onSaveSession:wo,busy:Is,saveBusy:Ue.saving,saveDisabled:!k.trim()||D.length===0||Is,statusText:xo,errorMessage:Rl,showSaveAction:!0,showCommentAction:!0,onCommentAssistantMessage:as,isAssistantMessageCommented:is,canCommentAssistantMessage:Co})}):null,st?l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Прогресс / регресс"})}),l.jsxs("div",{className:"autoruns-stats-grid",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Последний score"}),l.jsx("strong",{children:jl(Z?.stats.latest_score_index??null)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Предыдущий"}),l.jsx("strong",{children:jl(Z?.stats.previous_score_index??null)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Тренд"}),l.jsx("strong",{children:Z?Uc(Z.stats.trend):"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Пробелы качества"}),l.jsx("strong",{children:Z?.stats.quality_gap_runs??0})]})]}),l.jsx("h4",{children:"Покрытие доменов (история)"}),Bc(Z?.stats.domain_coverage??[]),l.jsx("h4",{style:{marginTop:14},children:"Покрытие доменов (выбранный прогон)"}),Bc(U?.coverage.domain_coverage??[]),l.jsx("h4",{style:{marginTop:14},children:"Очереди фиксов пост-анализа"}),an?l.jsx("p",{className:"muted",children:"Собираю пост-анализ..."}):null,an?null:l.jsx("div",{className:"autoruns-stats-grid",children:Object.entries(on?.post_analysis.stats.by_queue??{}).map(([a,c])=>l.jsxs("div",{children:[l.jsx("span",{children:a}),l.jsx("strong",{children:c})]},a))}),l.jsxs("div",{className:"autoruns-autogen-list",children:[(on?.post_analysis.recommended_regression_candidates??[]).slice(0,12).map(a=>l.jsxs("article",{className:"autoruns-autogen-item",children:[l.jsxs("header",{children:[l.jsx("strong",{children:a.manual_case_decision}),l.jsxs("span",{children:[a.rating,"/5"]})]}),l.jsxs("div",{className:"autoruns-run-meta",children:[a.domain??"неизвестно"," / ",a.query_class??"неизвестно"]}),l.jsx("p",{children:a.comment})]},a.annotation_id)),!an&&(on?.post_analysis.recommended_regression_candidates.length??0)===0?l.jsx("p",{className:"muted",children:"Рекомендованных кандидатов пока нет."}):null]})]}):null,Dt?l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Комментарии"})}),l.jsx("h4",{children:"Размеченные ответы"}),l.jsxs("div",{className:"autoruns-comment-filter-row",children:[l.jsxs("label",{children:["Фильтр решений",l.jsxs("select",{value:ae,onChange:a=>he(a.target.value),children:[l.jsx("option",{value:"all",children:"все"}),(Kt.length>0?Kt:we?.enum??[]).map(a=>l.jsx("option",{value:a,children:String(we?.labels?.[a]??a)},a))]})]}),l.jsx("button",{type:"button",className:"tab autoruns-resolved-filter-toggle",onClick:()=>_e(a=>!a),children:xe?"Показать выполненные":"Скрыть выполненные"})]}),l.jsxs("div",{className:"autoruns-stats-grid",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Комментариев"}),l.jsx("strong",{children:Ft.length})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Средний рейтинг"}),l.jsx("strong",{children:Us===null?"нет данных":`${Us.toFixed(2)} / 5`})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Последний"}),l.jsx("strong",{children:Ft.length>0?tn(Ft[0].updated_at):"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Статус"}),l.jsx("strong",{children:jn?"обновляю":"готово"})]})]}),l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",disabled:jn,onClick:()=>{zr()},children:jn?"Обновляю...":"Обновить список"}),l.jsx("button",{type:"button",className:"tab",disabled:an,onClick:()=>{ht()},children:an?"Идет пост-анализ...":"Обновить пост-анализ"})]}),l.jsxs("div",{className:"autoruns-comments-list",children:[jn?l.jsx("p",{className:"muted",children:"Загружаю комментарии..."}):null,!jn&&Ft.length===0?l.jsx("p",{className:"muted",children:re.length===0&&qe.length===0?"Пока нет откомментированных ответов.":"Нет открытых кейсов по текущему фильтру."}):null,Ft.map(a=>{if(a.source==="assistant_live"){const p=a.assistant;return l.jsxs("article",{className:"autoruns-comment-item",children:[l.jsxs("div",{className:"autoruns-comment-head",children:[l.jsx("strong",{children:aa(p.rating)}),l.jsx("div",{className:"autoruns-comment-head-actions",children:l.jsx("span",{children:tn(p.updated_at)})})]}),l.jsxs("div",{className:"autoruns-run-meta",children:["live-session: ",p.session_id]}),l.jsxs("div",{className:"autoruns-run-meta",children:["msg=",p.message_index]}),l.jsxs("div",{className:"autoruns-run-meta",children:["source=assistant_live",p.annotation_author?` | author=${p.annotation_author}`:""]}),p.context.question_text?l.jsxs("p",{children:["Q: ",p.context.question_text]}):null,p.context.answer_text?l.jsxs("p",{children:["A: ",p.context.answer_text]}):null,l.jsx("p",{children:p.comment})]},a.key)}const c=a.autorun;return l.jsxs("article",{className:wn===c.annotation_id?"autoruns-comment-item selected":"autoruns-comment-item",onClick:()=>{cs(c)},role:"button",tabIndex:0,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),cs(c))},children:[l.jsxs("div",{className:"autoruns-comment-head",children:[l.jsx("strong",{children:aa(c.rating)}),l.jsxs("div",{className:"autoruns-comment-head-actions",children:[l.jsx("span",{children:tn(c.updated_at)}),l.jsx("button",{type:"button",className:c.resolved?"autoruns-resolve-toggle resolved":"autoruns-resolve-toggle",onClick:p=>{p.preventDefault(),p.stopPropagation(),us(c,!c.resolved)},disabled:Mr===c.annotation_id,title:c.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный","aria-label":c.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный",children:l.jsx(Qc,{resolved:c.resolved})})]})]}),l.jsx("div",{className:"autoruns-run-meta",children:c.run_id}),l.jsxs("div",{className:"autoruns-run-meta",children:["case=",c.case_id," | msg=",c.message_index]}),l.jsxs("div",{className:"autoruns-run-meta",children:["decision=",c.manual_case_decision,c.annotation_author?` | author=${c.annotation_author}`:""]}),c.resolved_at?l.jsxs("div",{className:"autoruns-run-meta",children:["выполнено",": ",tn(c.resolved_at),c.resolved_by?` | by=${c.resolved_by}`:""]}):null,c.context.question_text?l.jsxs("p",{children:["Q: ",c.context.question_text]}):null,c.context.answer_text?l.jsxs("p",{children:["A: ",c.context.answer_text]}):null,l.jsx("p",{children:c.comment})]},a.key)})]}),Ne?l.jsxs(l.Fragment,{children:[l.jsx("h4",{children:"Тех-контекст брака"}),l.jsxs("div",{className:"autoruns-meta-list",children:[l.jsxs("div",{children:[l.jsx("span",{children:"trace:"}),l.jsx("strong",{children:Ne.technical_context.trace_id??"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"reply_type:"}),l.jsx("strong",{children:Ne.technical_context.reply_type??"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"domain:"}),l.jsx("strong",{children:Ne.technical_context.domain??"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"query_class:"}),l.jsx("strong",{children:Ne.technical_context.query_class??"нет данных"})]})]}),l.jsx("h4",{children:"JSON разбор"}),l.jsx(Gc,{value:{annotation_id:Ne.annotation_id,run_id:Ne.run_id,case_id:Ne.case_id,message_index:Ne.message_index,rating:Ne.rating,comment:Ne.comment,manual_case_decision:Ne.manual_case_decision,annotation_author:Ne.annotation_author,resolved:Ne.resolved,resolved_at:Ne.resolved_at,resolved_by:Ne.resolved_by,context:Ne.context,technical_context:Ne.technical_context,case_summary:Ne.case_summary?{case_id:Ne.case_summary.case_id,domain:Ne.case_summary.domain,query_class:Ne.case_summary.query_class,checks:Ne.case_summary.checks,metric_subscores:Ne.case_summary.metric_subscores}:null}})]}):null]}):null]}),Ue.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&Ut()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Сохранить ручную сессию"}),l.jsx("p",{className:"muted",children:"Технический чат будет сохранен в автопрогоны как пользовательская multi-turn сессия."}),l.jsxs("label",{children:["Название",l.jsx("input",{value:Ue.title,onChange:a=>Fn(c=>({...c,title:a.target.value})),placeholder:"Например: НДС и склад на март 2020",disabled:Ue.saving})]}),Ue.error?l.jsx("p",{className:"error-text",children:Ue.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{Dr()},disabled:Ue.saving,children:Ue.saving?"Сохраняю...":"Сохранить"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>Ut(),disabled:Ue.saving,children:"Отмена"})]})]})}):null,$t.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&Bt()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Удалить вопрос"}),l.jsx("p",{className:"muted",children:"Действительно удалить вопрос из сохраненной пользовательской сессии?"}),l.jsx("p",{className:"autoruns-comment-quote",children:$t.questionText}),$t.error?l.jsx("p",{className:"error-text",children:$t.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{ur()},disabled:$t.saving,children:$t.saving?"Удаляю...":"Да"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>Bt(),disabled:$t.saving,children:"Нет"})]})]})}):null,Et.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&Ht()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Удалить сохраненный набор"}),l.jsx("p",{className:"muted",children:"Будет удалена карточка истории и связанный файл кейс-сета на бэке."}),l.jsx("p",{className:"autoruns-comment-quote",children:Et.title}),Et.error?l.jsx("p",{className:"error-text",children:Et.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{Ur()},disabled:Et.saving,children:Et.saving?"Удаляю...":"Да"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>Ht(),disabled:Et.saving,children:"Нет"})]})]})}):null,ue.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&hn()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Комментарий к ответу ассистента"}),l.jsx("p",{className:"muted",children:"Комментарий будет добавлен в общий список комментариев справа с меткой `assistant_live`."}),Fs?l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Вопрос пользователя"}),l.jsx("p",{className:"autoruns-comment-quote",children:Fs.text})]}):null,$s?l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Ответ ассистента"}),l.jsx("p",{className:"autoruns-comment-quote",children:$s.text})]}):null,l.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа ассистента",children:[1,2,3,4,5].map(a=>l.jsx("button",{type:"button",className:ue.rating>=a?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>mn(c=>({...c,rating:a})),disabled:ue.saving,"aria-label":`Оценка ${a}`,children:ue.rating>=a?"●":"○"},a))}),l.jsx("div",{className:"autoruns-form-grid",children:l.jsxs("label",{children:["Автор комментария",l.jsx("input",{value:ue.annotationAuthor,onChange:a=>mn(c=>({...c,annotationAuthor:a.target.value})),placeholder:"manual_reviewer",disabled:ue.saving})]})}),l.jsxs("label",{children:["Комментарий",l.jsx("textarea",{value:ue.comment,onChange:a=>mn(c=>({...c,comment:a.target.value})),placeholder:"Что именно не так в ответе и что нужно исправить.",rows:4,disabled:ue.saving})]}),ue.error?l.jsx("p",{className:"error-text",children:ue.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{No()},disabled:ue.saving,children:ue.saving?"Сохраняю...":"Готово"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>hn(),disabled:ue.saving,children:"Отмена"})]})]})}):null,ge.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&ar()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Комментарий к ответу системы"}),l.jsx("p",{className:"muted",children:"Оцените ответ по 5-балльной шкале и добавьте комментарий по браку."}),So?l.jsxs(l.Fragment,{children:[l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Вопрос пользователя"}),l.jsx("p",{className:"autoruns-comment-quote",children:zs?.text??"Вопрос в диалоге не найден."})]}),l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Ответ системы"}),l.jsx("p",{className:"autoruns-comment-quote",children:So.text})]})]}):null,l.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа",children:[1,2,3,4,5].map(a=>l.jsx("button",{type:"button",className:ge.rating>=a?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>wt(c=>({...c,rating:a})),disabled:ge.saving,"aria-label":`Оценка ${a}`,children:ge.rating>=a?"●":"○"},a))}),l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Решение по кейсу",l.jsx("select",{value:ge.manualCaseDecision,onChange:a=>wt(c=>({...c,manualCaseDecision:a.target.value})),disabled:ge.saving,children:(Kt.length>0?Kt:we?.enum??[wl]).map(a=>l.jsx("option",{value:a,children:String(we?.labels?.[a]??a)},a))})]}),l.jsxs("label",{children:["Автор комментария",l.jsx("input",{value:ge.annotationAuthor,onChange:a=>wt(c=>({...c,annotationAuthor:a.target.value})),placeholder:"manual_reviewer",disabled:ge.saving})]})]}),l.jsxs("label",{children:["Комментарий",l.jsx("textarea",{value:ge.comment,onChange:a=>wt(c=>({...c,comment:a.target.value})),placeholder:"Почему ответ бракованный, что именно пошло не так, какие технические детали проверить.",rows:4,disabled:ge.saving})]}),ge.error?l.jsx("p",{className:"error-text",children:ge.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{ls()},disabled:ge.saving,children:ge.saving?"Сохраняю...":"Готово"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>ar(),disabled:ge.saving,children:"Отмена"})]})]})}):null]})}const um={llmProvider:"openai",apiKey:"",model:"gpt-4o-mini",baseUrl:"https://api.openai.com/v1",temperature:0,maxOutputTokens:700},Vc={systemPrompt:"Ты semantic-normalizer для бухгалтерского ассистента NDC. Возвращай только JSON по схеме normalized_query_v2_0_2.",developerPrompt:"Сначала делай decomposition сообщения на task fragments, затем определяй domain scope и route-critical flags. Для каждого fragment заполняй execution_readiness + route_status + no_route_reason. Если fragment routable, не оставляй его в no_route.",domainPrompt:"Контур: данные текущего предприятия в 1С/NDC. In-scope: документы, проводки, взаиморасчеты, остатки, периодное закрытие, аномалии и контрольные проверки. Out-of-scope: общая теория, законы и оффтоп.",schemaNotes:"schema_version: normalized_query_v2_0_2. Строгий JSON без дополнительных полей.",fewShotExamples:"Q: Проверь по поставщикам хвосты и разложи цепочку документов/оплат. => fragment in_scope, flags: multi_entity + chain_explanation. Q: Как вообще по ФСБУ? => out_of_scope/generic_accounting."},cm={userQuestion:"",batchQuestionsRaw:"",periodHint:"",businessContext:"",expectedRoute:""},ua={colors:{backgroundRgb:"18, 18, 18",mainSurfaceRgb:"25, 25, 25",horizontalSurfaceRgb:"30, 30, 30",focusSurfaceRgb:"35, 35, 35",assistantChipRgb:"18, 18, 18",assistantChipHoverRgb:"44, 44, 44",assistantChipSelectedRgb:"167, 59, 255",assistantChipSelectedTextRgb:"240, 240, 240",activeRgb:"167, 59, 255",activeTextRgb:"240, 240, 240",textMainRgb:"240, 240, 240",textMutedRgb:"166, 166, 166",dangerRgb:"126, 126, 126",scrollbarTrackRgb:"20, 20, 20",scrollbarThumbRgb:"30, 30, 30",scrollbarThumbHoverRgb:"30, 50, 30"},layout:{modeColumnWidthPx:406,modeToggleWidthPx:188}},Wc="ndc_normalizer_session_config_v1",Kc="ndc_autoruns_layout_config_v1",dm="ndc-autoruns-save",fm="autoruns",ca="normalizer_v2_0_2",mm="address_query_runtime_v1",pm=["normalized","fragments","scope","flags","route","raw","validation","logs"];function hm(i){return`[${new Date().toLocaleTimeString("ru-RU")}] ${i}`}function gm(i,h){if(!h)return"Previous preset is not selected.";const R=["systemPrompt","developerPrompt","domainPrompt","schemaNotes","fewShotExamples"].filter(E=>i[E]!==h[E]).map(E=>`${E}: ${Math.abs(i[E].length-h[E].length)} chars delta`);return R.length===0?"No changes against previous preset.":`Changed fields: ${R.length}. ${R.join(" | ")}`}function vm(){const[i,h]=y.useState(um),[f,R]=y.useState(Vc),[E,L]=y.useState(cm),[Q,le]=y.useState(null),[te,z]=y.useState([]),[Y,X]=y.useState([]),[ee,Te]=y.useState("normalized"),[ce,de]=y.useState(!1),[pe,Qe]=y.useState(!1),[Je,be]=y.useState([]),[Re,F]=y.useState(""),[oe,Ce]=y.useState([]),[$e,dt]=y.useState(""),[st,Dt]=y.useState("NDC custom preset"),[ot,H]=y.useState(null),[Me,We]=y.useState(""),[ne,Z]=y.useState(!1),[M,U]=y.useState([]),[A,v]=y.useState(""),[w,re]=y.useState([]),[ie,ae]=y.useState(!1),[he,xe]=y.useState(null),[_e,we]=y.useState(""),[lt,Kt]=y.useState(fm),[Xn,wn]=y.useState(!0),[nn,Ee]=y.useState(!0),[Ot,et]=y.useState(!0),[ft,St]=y.useState(!0),[rn,W]=y.useState(!0),[it,Zn]=y.useState(!0),[In,Dn]=y.useState(!0),[kn,mt]=y.useState(!0),[zt,Ke]=y.useState(!0),[sn,on]=y.useState(!0),[Zr,Nr]=y.useState(!0),[Er,es]=y.useState(!0),[ln,an]=y.useState(!0),un=y.useRef(!1),cn=y.useRef(!1),On=y.useRef(!1);y.useEffect(()=>{const k=document.documentElement,{colors:K}=ua;k.style.setProperty("--rgb-background",K.backgroundRgb),k.style.setProperty("--rgb-surface-main",K.mainSurfaceRgb),k.style.setProperty("--rgb-surface-horizontal",K.horizontalSurfaceRgb),k.style.setProperty("--rgb-surface-focus",K.focusSurfaceRgb),k.style.setProperty("--rgb-assistant-chip",K.assistantChipRgb),k.style.setProperty("--rgb-assistant-chip-hover",K.assistantChipHoverRgb),k.style.setProperty("--rgb-assistant-chip-selected",K.assistantChipSelectedRgb),k.style.setProperty("--rgb-assistant-chip-selected-text",K.assistantChipSelectedTextRgb),k.style.setProperty("--rgb-active",K.activeRgb),k.style.setProperty("--rgb-active-text",K.activeTextRgb),k.style.setProperty("--rgb-text-main",K.textMainRgb),k.style.setProperty("--rgb-text-muted",K.textMutedRgb),k.style.setProperty("--rgb-danger",K.dangerRgb),k.style.setProperty("--rgb-scrollbar-track",K.scrollbarTrackRgb),k.style.setProperty("--rgb-scrollbar-thumb",K.scrollbarThumbRgb),k.style.setProperty("--rgb-scrollbar-thumb-hover",K.scrollbarThumbHoverRgb),k.style.setProperty("--mode-column-width",`${ua.layout.modeColumnWidthPx}px`),k.style.setProperty("--mode-toggle-width",`${ua.layout.modeToggleWidthPx}px`)},[]);const me=k=>{X(K=>[hm(k),...K].slice(0,300))};y.useEffect(()=>{(async()=>{const D=localStorage.getItem(Wc);if(D)try{const ke=JSON.parse(D);h(qe=>({...qe,llmProvider:ke.llmProvider==="local"?"local":"openai",model:ke.model??qe.model,baseUrl:ke.baseUrl??qe.baseUrl,temperature:ke.temperature??qe.temperature,maxOutputTokens:ke.maxOutputTokens??qe.maxOutputTokens}))}catch{}try{const ke=await Pe.loadSharedConnectionConfig();ke.connection&&ke.connection.llmProvider==="local"&&(h(qe=>({...qe,llmProvider:"local",model:ke.connection?.model??qe.model,baseUrl:ke.connection?.baseUrl??qe.baseUrl,temperature:ke.connection?.temperature??qe.temperature,maxOutputTokens:ke.connection?.maxOutputTokens??qe.maxOutputTokens})),me(`Shared local LLM config loaded: ${ke.connection.model}`))}catch(ke){me(`Shared local config load error: ${ke instanceof Error?ke.message:String(ke)}`)}finally{On.current=!0}})();const K=localStorage.getItem(Kc);if(K)try{const D=JSON.parse(K);(D.uiMode==="assistant"||D.uiMode==="autoruns"||D.uiMode==="decomposition")&&Kt("autoruns"),D.activeTab&&pm.includes(D.activeTab)&&Te(D.activeTab),typeof D.showAutorunsSettingsMode=="boolean"&&wn(D.showAutorunsSettingsMode),typeof D.showAutorunsAutoRunsMode=="boolean"&&Ee(D.showAutorunsAutoRunsMode),typeof D.showAutorunsAssistantMode=="boolean"&&et(D.showAutorunsAssistantMode),typeof D.showAutorunsDecompositionMode=="boolean"&&St(D.showAutorunsDecompositionMode),typeof D.showAutorunsProgressMode=="boolean"&&W(D.showAutorunsProgressMode),typeof D.showAutorunsCommentsMode=="boolean"&&Zn(D.showAutorunsCommentsMode),typeof D.showDecompositionConnectionMode=="boolean"&&Dn(D.showDecompositionConnectionMode),typeof D.showDecompositionPromptMode=="boolean"&&mt(D.showDecompositionPromptMode),typeof D.showDecompositionQueryMode=="boolean"&&Ke(D.showDecompositionQueryMode),typeof D.showDecompositionOutputMode=="boolean"&&on(D.showDecompositionOutputMode),typeof D.showDecompositionMetricsMode=="boolean"&&Nr(D.showDecompositionMetricsMode),typeof D.showDecompositionHistoryMode=="boolean"&&es(D.showDecompositionHistoryMode),typeof D.showDecompositionRuntimeMode=="boolean"&&an(D.showDecompositionRuntimeMode),D.prompts&&(R(ke=>({...ke,...D.prompts})),cn.current=!0)}catch{}dn(),er(),Pr()},[]),y.useEffect(()=>{if(!On.current||i.llmProvider!=="local")return;const k=window.setTimeout(()=>{Pe.saveSharedConnectionConfig(i).catch(K=>me(`Shared local config sync error: ${K instanceof Error?K.message:String(K)}`))},250);return()=>window.clearTimeout(k)},[i.baseUrl,i.llmProvider,i.maxOutputTokens,i.model,i.temperature]);async function dn(){try{const k=await Pe.loadHistory();z(k.items??[])}catch(k){me(`History load error: ${k instanceof Error?k.message:String(k)}`)}}async function er(){try{const K=(await Pe.loadPresets()).presets??[];if(Ce(K),cn.current){un.current=!0;return}if(un.current)return;const D=K.find(ke=>ke.prompt_version===ca)??K.find(ke=>ke.id==="default-normalizer-v2_0_2");if(!D){un.current=!0,me(`Preset autoload skipped: ${ca} not found.`);return}dt(D.id),H(f),R({systemPrompt:D.systemPrompt,developerPrompt:D.developerPrompt,domainPrompt:D.domainPrompt,schemaNotes:D.schemaNotes??"",fewShotExamples:D.fewShotExamples??""}),un.current=!0,me(`Preset autoloaded: ${D.name} (${D.prompt_version}).`)}catch(k){me(`Presets load error: ${k instanceof Error?k.message:String(k)}`)}}async function Pr(){try{const k=await Pe.listRuns();U(k.items??[])}catch(k){me(`Runs load error: ${k instanceof Error?k.message:String(k)}`)}}function Tr(){if(localStorage.setItem(Wc,JSON.stringify({model:i.model,llmProvider:i.llmProvider,baseUrl:i.baseUrl,temperature:i.temperature,maxOutputTokens:i.maxOutputTokens})),i.llmProvider==="local"){Pe.saveSharedConnectionConfig(i).then(()=>{me("Local config saved and synced to shared agent config (without API key).")}).catch(k=>{me(`Local config saved, but shared sync failed: ${k instanceof Error?k.message:String(k)}`)});return}me("Local config saved (without API key).")}function Rr(){localStorage.setItem(Kc,JSON.stringify({uiMode:lt,activeTab:ee,showAutorunsSettingsMode:Xn,showAutorunsAutoRunsMode:nn,showAutorunsAssistantMode:Ot,showAutorunsDecompositionMode:ft,showAutorunsProgressMode:rn,showAutorunsCommentsMode:it,showDecompositionConnectionMode:In,showDecompositionPromptMode:kn,showDecompositionQueryMode:zt,showDecompositionOutputMode:sn,showDecompositionMetricsMode:Zr,showDecompositionHistoryMode:Er,showDecompositionRuntimeMode:ln,prompts:f})),window.dispatchEvent(new CustomEvent(dm)),me("UI layout and prompts saved.")}async function jn(){de(!0),we("");try{const k=await Pe.testConnection(i);k.provider==="local"?k.model_found===!0?(F(`LOCAL OK - ${k.model}`),me(`Local model is available: ${k.model} (catalog size=${k.models_count??"n/a"}).`)):k.model_found===!1?(F(`LOCAL OK, model not loaded - ${k.model}`),me(`Local server is reachable, but model '${k.model}' is not in loaded catalog. Use 'Load model list' and select one of loaded models.`)):(F(`LOCAL OK (model list unavailable) - ${k.model}`),me("Local server is reachable, but model catalog could not be verified.")):(F(`OPENAI OK - ${k.model}`),me(`OpenAI connection ok: ${k.model}`))}catch(k){const K=k instanceof Error?k.message:String(k);F("Connection error"),we(`Test connection: ${K}`),me(`Test connection error: ${K}`)}finally{de(!1)}}async function tr(){Qe(!0);try{const K=(await Pe.listModels(i)).models??[];be(K),K.length>0&&h(D=>D.model&&K.includes(D.model)?D:{...D,model:K[0]}),me(`Model catalog loaded (${i.llmProvider}): ${K.length} items.`)}catch(k){const K=k instanceof Error?k.message:String(k);me(`Load model list error: ${K}`)}finally{Qe(!1)}}y.useEffect(()=>{be([])},[i.llmProvider,i.baseUrl]);function Mr(){const k=oe.find(K=>K.id===$e);if(!k){me("Preset is not selected.");return}H(f),R({systemPrompt:k.systemPrompt,developerPrompt:k.developerPrompt,domainPrompt:k.domainPrompt,schemaNotes:k.schemaNotes??"",fewShotExamples:k.fewShotExamples??""}),me(`Preset loaded: ${k.name}`)}async function Cn(){try{await Pe.savePreset({name:st||"NDC preset",prompt_version:"normalizer_v2_0_2",systemPrompt:f.systemPrompt,developerPrompt:f.developerPrompt,domainPrompt:f.domainPrompt,schemaNotes:f.schemaNotes,fewShotExamples:f.fewShotExamples}),me("Preset saved."),await er()}catch(k){me(`Preset save error: ${k instanceof Error?k.message:String(k)}`)}}function nr(){R(Vc),me("Prompt panel reset to defaults.")}function Oe(){const k=gm(f,ot);We(k),me(k)}return y.useEffect(()=>{if(!A){re([]);return}Pe.runTrace(A).then(k=>re(k.items)).catch(k=>me(`Run trace error: ${k instanceof Error?k.message:String(k)}`))},[A]),l.jsxs("main",{className:"app-root app-root-autoruns",children:[l.jsxs("header",{className:"app-topbar",children:[l.jsxs("div",{className:"mode-switch-row",children:[l.jsx("button",{type:"button",className:"tab active",onClick:()=>Kt("autoruns"),children:"Управление ассистентом"}),l.jsx("button",{type:"button",className:"tab",onClick:Rr,children:"Сохранить"})]}),l.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[l.jsx("button",{type:"button",className:Xn?"tab active":"tab",onClick:()=>wn(k=>!k),children:"Настройки"}),l.jsx("button",{type:"button",className:nn?"tab active":"tab",onClick:()=>Ee(k=>!k),children:"Автопрогоны"}),l.jsx("button",{type:"button",className:Ot?"tab active":"tab",onClick:()=>et(k=>!k),children:"Режим ассистента"}),l.jsx("button",{type:"button",className:rn?"tab active":"tab",onClick:()=>W(k=>!k),children:"Прогресс/регресс"}),l.jsx("button",{type:"button",className:it?"tab active":"tab",onClick:()=>Zn(k=>!k),children:"Комментарии"})]})]}),l.jsx("div",{className:"layout-grid layout-grid-autoruns",children:l.jsx(am,{connection:i,modelOptions:Je,modelsBusy:pe,connectionStatus:Re,connectionBusy:ce,onConnectionChange:h,onReloadModels:tr,onSaveLocalConfig:Tr,onTestConnection:jn,prompts:f,onPromptsChange:R,promptPresets:oe,selectedPresetId:$e,onSelectPreset:dt,onLoadPreset:Mr,onSavePreset:Cn,onResetDefaults:nr,onDiffPrevious:Oe,presetName:st,onPresetNameChange:Dt,diffSummary:Me,assistantPromptVersion:mm,decompositionPromptVersion:ca,showSettingsMode:Xn,showAutoRunsMode:nn,showAssistantMode:Ot,showProgressMode:rn,showCommentsMode:it,onLog:me})})]})}Tf.createRoot(document.getElementById("root")).render(l.jsx(wf.StrictMode,{children:l.jsx(vm,{})})); diff --git a/llm_normalizer/frontend/dist/assets/index-CfrZGsZo.css b/llm_normalizer/frontend/dist/assets/index-DNDajOYc.css similarity index 74% rename from llm_normalizer/frontend/dist/assets/index-CfrZGsZo.css rename to llm_normalizer/frontend/dist/assets/index-DNDajOYc.css index 6bd5b2f..8ac182a 100644 --- a/llm_normalizer/frontend/dist/assets/index-CfrZGsZo.css +++ b/llm_normalizer/frontend/dist/assets/index-DNDajOYc.css @@ -1 +1 @@ -@import"https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=Space+Grotesk:wght@500;700&display=swap";:root{--rgb-background: 16, 16, 19;--rgb-surface-main: 26, 26, 31;--rgb-surface-horizontal: 32, 32, 38;--rgb-surface-focus: 40, 40, 47;--rgb-assistant-chip: 18, 18, 18;--rgb-assistant-chip-hover: 44, 44, 44;--rgb-assistant-chip-selected: 228, 142, 92;--rgb-assistant-chip-selected-text: 18, 18, 18;--rgb-active: 228, 142, 92;--rgb-active-text: 18, 18, 18;--rgb-text-main: 240, 240, 240;--rgb-text-muted: 166, 166, 170;--rgb-emerald: 126, 211, 154;--rgb-warning: 255, 196, 116;--rgb-danger: 255, 126, 126;--rgb-scrollbar-track: 31, 31, 36;--rgb-scrollbar-thumb: 74, 74, 82;--rgb-scrollbar-thumb-hover: 90, 90, 100;--mode-column-width: 440px;--mode-toggle-width: 188px;--bg-main: rgb(var(--rgb-background));--bg-soft: rgb(var(--rgb-surface-main));--bg-panel: rgb(var(--rgb-surface-main));--bg-panel-accent: rgb(var(--rgb-surface-horizontal));--surface-horizontal: rgb(var(--rgb-surface-horizontal));--surface-focus: rgb(var(--rgb-surface-focus));--line: transparent;--line-strong: rgba(var(--rgb-active), .48);--text-main: rgb(var(--rgb-text-main));--text-muted: rgb(var(--rgb-text-muted));--lime-main: rgb(var(--rgb-text-main));--lime-press: rgb(var(--rgb-text-main));--danger: rgb(var(--rgb-danger));--radius-lg: 20px;--radius-md: 14px;--shadow: none;--autoruns-col-width: var(--mode-column-width)}*{box-sizing:border-box;scrollbar-width:thin;scrollbar-color:rgb(var(--rgb-scrollbar-thumb)) rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar{width:10px;height:10px}*::-webkit-scrollbar-track{background:rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar-thumb{background:rgb(var(--rgb-scrollbar-thumb));border-radius:999px;border:2px solid rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar-thumb:hover{background:rgb(var(--rgb-scrollbar-thumb-hover))}html,body,#root{margin:0;min-height:100dvh;font-family:Manrope,Segoe UI,sans-serif;background:var(--bg-main);color:var(--text-main)}.app-root{max-width:1720px;margin:0 auto;padding:12px 16px 16px}.app-root.app-root-autoruns{max-width:none;width:100%;min-height:100dvh;max-height:100dvh;display:flex;flex-direction:column;overflow:hidden}.app-topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 12px;padding:0;min-height:38px}.layout-grid{display:grid;grid-template-columns:repeat(12,1fr);gap:16px}.layout-grid.layout-grid-autoruns,.layout-grid.layout-grid-mode-columns{min-height:0;flex:1 1 auto;grid-template-columns:minmax(0,1fr)}.mode-switch-row{display:flex;gap:8px;margin:0;padding:0}.mode-switch-row.mode-switch-row-right{margin-left:auto;justify-content:flex-end;max-width:72%;overflow-x:auto;overflow-y:hidden;padding-bottom:2px}.mode-switch-row .tab{white-space:nowrap}.mode-switch-row.mode-switch-row-right .tab{width:var(--mode-toggle-width);min-width:var(--mode-toggle-width);text-align:center}.mode-columns{display:flex;gap:12px;width:100%;min-height:0;flex:1 1 auto;overflow-x:auto;overflow-y:hidden;padding-bottom:4px}.mode-col{flex:0 0 var(--mode-column-width);width:var(--mode-column-width);min-height:0;height:100%;display:flex}.mode-col.mode-col-wide,.mode-col.mode-col-xwide{flex-basis:var(--mode-column-width);width:var(--mode-column-width)}.mode-col .panel-frame{width:100%;height:100%}.mode-col .panel-body{min-height:0;overflow:auto}.mode-columns-empty{min-width:360px;border-radius:14px;background:rgb(var(--rgb-surface-main));color:var(--text-muted);padding:14px}.panel-frame{grid-column:span 12;border:none;border-radius:var(--radius-lg);background:var(--bg-panel);overflow:hidden;box-shadow:none;animation:rise .4s ease-out;display:flex;flex-direction:column;min-height:0}.panel-header{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;padding:14px 18px 10px;border-bottom:none;background:var(--bg-panel-accent)}.panel-header h2{margin:0;font-size:1.02rem;letter-spacing:.02em}.panel-header p{margin:6px 0 0;font-size:.85rem;color:var(--text-muted)}.panel-body{padding:10px 12px 12px;min-height:0}.app-root-autoruns .autoruns-frame{height:100%}.app-root-autoruns .autoruns-frame .panel-body{flex:1 1 auto;overflow:hidden;display:flex;flex-direction:column;gap:10px;padding:10px 12px 12px;background:rgb(var(--rgb-background))}.status-chip{border:none;border-radius:999px;padding:4px 10px;color:var(--lime-main);font-size:.78rem;background:rgb(var(--rgb-surface-focus))}.assistant-toolbar{display:grid;gap:8px}.assistant-toolbar-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:center;gap:8px}.assistant-toolbar-meta{display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-toolbar-meta-right{margin-left:auto;display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0;flex-wrap:wrap}.assistant-live-status{color:var(--text-muted);font-size:.8rem;white-space:nowrap}.assistant-toolbar-error{margin:0}.assistant-copy-btn{width:100%;justify-self:stretch;background:transparent;border-color:transparent;color:var(--text-main);font-size:.6rem;line-height:1.1;white-space:nowrap;text-align:center;letter-spacing:0;padding:6px 8px;box-shadow:none;transform:none}.assistant-copy-btn:hover{background:rgb(var(--rgb-surface-focus));filter:none;box-shadow:none;transform:none}.assistant-copy-feedback{font-size:.76rem;color:var(--text-muted)}.assistant-copy-feedback.success{color:var(--lime-main)}.assistant-copy-feedback.error{color:var(--danger)}input,select,textarea,button{font-family:Manrope,sans-serif}label{display:flex;flex-direction:column;gap:6px;color:var(--text-muted);font-size:.84rem}input,select,textarea{border:none;border-radius:var(--radius-md);background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:10px 12px;outline:none;transition:background-color .18s ease}input:focus,select:focus,textarea:focus{border-color:transparent;box-shadow:none;outline:none;background:rgb(var(--rgb-surface-focus))}textarea{resize:vertical;min-height:86px;overflow-y:auto;overflow-x:hidden;scrollbar-gutter:stable}.assistant-input-textarea,.autoruns-personality-prompt{overflow-y:auto;overflow-x:hidden;scrollbar-gutter:stable both-edges;border-bottom-right-radius:6px}.assistant-input-textarea::-webkit-scrollbar-corner,.autoruns-personality-prompt::-webkit-scrollbar-corner{background:rgb(var(--rgb-surface-horizontal))}button{border:none;border-radius:999px;background:rgb(var(--rgb-surface-horizontal));color:rgb(var(--rgb-text-main));font-weight:700;font-size:.83rem;letter-spacing:.02em;cursor:pointer;padding:9px 14px;transition:background .2s ease,color .2s ease;outline:none;box-shadow:none}button:hover{border-color:transparent;background:rgb(var(--rgb-surface-focus))}button:disabled{opacity:.52;cursor:not-allowed}.button-row{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-top:12px}.checkbox-row{flex-direction:row;align-items:center;gap:8px;color:var(--text-main)}.grid-two{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.prompt-manager-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}.full-width{grid-column:1 / -1}.tab-row{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px}.tab{background:rgb(var(--rgb-surface-main));color:var(--text-main);border:none}.tab.active{border-color:transparent;background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-chat-list{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:8px;padding:10px;border:none;border-radius:12px;background:rgb(var(--rgb-surface-horizontal))}.assistant-chat-list .assistant-msg:first-child{margin-top:auto}.assistant-empty{padding:18px;text-align:center}.assistant-msg{border:none;border-radius:12px;background:rgb(var(--rgb-surface-focus));padding:8px 10px;display:grid;gap:6px;min-width:0}.assistant-msg.user{margin-left:12%;border-color:transparent;background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-msg.assistant{margin-right:12%;border-color:transparent}.assistant-msg.user .assistant-msg-head{color:rgba(var(--rgb-active-text),.9)}.assistant-msg.user .assistant-msg-body{color:rgb(var(--rgb-active-text))}.assistant-msg-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:0;font-size:.74rem;color:var(--text-muted)}.assistant-msg-head-main{flex:1 1 auto;min-width:0;display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-msg-head-actions{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto}.assistant-comment-btn{cursor:pointer}.assistant-comment-btn:disabled{opacity:.42;cursor:not-allowed}.assistant-msg.user .assistant-comment-btn{color:rgba(var(--rgb-active-text),.92)}.assistant-msg-body{display:grid;gap:10px;line-height:1.35;font-size:.84rem;min-width:0}.assistant-msg-block{display:grid;gap:4px;min-width:0}.assistant-msg-block.selectable{cursor:pointer;padding:8px 10px;border-radius:12px;transition:background .18s ease,color .18s ease}.assistant-msg-block.selectable:hover,.assistant-msg-block.selectable:focus-visible{background:rgba(var(--rgb-active),.18);outline:none}.assistant-msg-block.selectable.active{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-msg-block.selectable.active:hover,.assistant-msg-block.selectable.active:focus-visible{background:rgb(var(--rgb-active))}.assistant-msg-block.selectable.active .assistant-msg-line,.assistant-msg-block.selectable.active .assistant-msg-line strong{color:rgb(var(--rgb-active-text))}.assistant-msg-line{margin:0;white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere}.assistant-msg-line.heading{font-weight:700;letter-spacing:.01em}.assistant-msg-line.numbered{margin-top:2px}.assistant-msg-line strong{font-weight:800}.assistant-trace{margin-top:6px;color:var(--text-muted);font-size:.75rem}.assistant-debug{margin-top:8px}.assistant-debug summary{cursor:pointer;color:var(--lime-main);font-size:.8rem}.assistant-compose{margin-top:0;display:grid;gap:8px;flex:0 0 auto}.assistant-compose-context{display:grid;gap:6px;padding:10px 12px;border-radius:var(--radius-md);background:rgb(var(--rgb-surface-horizontal))}.assistant-compose-context-label{color:var(--text-muted);font-size:.74rem;font-weight:700;letter-spacing:.01em}.assistant-compose-context-pill{display:inline-flex;align-items:center;gap:8px;max-width:100%;width:fit-content;min-height:38px;padding:0 10px 0 12px;border-radius:999px;background:rgb(var(--rgb-assistant-chip-selected));color:rgb(var(--rgb-assistant-chip-selected-text))}.assistant-compose-context-pill-text{min-width:0;max-width:min(100%,460px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.82rem;font-weight:700}.assistant-compose-context-clear{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;min-width:24px;padding:0;border-radius:999px;background:#0000002e;color:inherit;font-size:.96rem;line-height:1}.assistant-compose-context-clear:hover{background:#00000047}.assistant-send-row{align-items:center;margin-top:2px}.assistant-send-btn{margin-left:auto}.assistant-comments-frame .panel-body{display:flex;flex-direction:column;min-height:0;overflow:hidden}.assistant-comments-shell{display:grid;gap:8px;min-height:0;height:100%}.assistant-comments-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-comments-list{display:grid;gap:8px;overflow:auto;min-height:0;padding-right:2px}.assistant-comment-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:6px}.assistant-comment-head{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:.75rem}.assistant-comment-item p{margin:0;white-space:pre-wrap;font-size:.8rem}.assistant-comment-meta{display:flex;flex-wrap:wrap;gap:8px;color:var(--text-muted);font-size:.74rem}.app-root-autoruns .assistant-panel-frame .panel-header{position:sticky;top:-12px;z-index:8;margin:-12px -12px 0;padding:12px 12px 10px;background:rgb(var(--rgb-surface-main))}.app-root-autoruns .assistant-panel-frame{overflow:visible}.app-root-autoruns .assistant-panel-frame .panel-body{flex:1 1 auto;padding:0 12px 12px;display:flex;flex-direction:column;min-height:0;overflow:hidden}.app-root-autoruns .assistant-panel-frame .assistant-live-shell{flex:1 1 auto;min-height:0;padding:12px;border-radius:14px;background:rgb(var(--rgb-background));display:flex;flex-direction:column;gap:10px}.app-root-autoruns .assistant-panel-frame .assistant-chat-list{overflow-y:auto}.app-root-autoruns .assistant-panel-frame .panel-header h2{margin:0;font-size:.95rem}.json-view{margin:0;width:100%;min-height:180px;max-height:420px;overflow:auto;background:rgb(var(--rgb-surface-horizontal));border:none;border-radius:var(--radius-md);padding:12px;color:rgb(var(--rgb-text-main));font-family:JetBrains Mono,Consolas,monospace;font-size:.78rem;line-height:1.45}.metrics-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}.metrics-grid div{background:rgba(var(--rgb-surface-main),.8);border:none;border-radius:12px;padding:10px;display:flex;flex-direction:column;gap:4px}.metrics-grid span{color:var(--text-muted);font-size:.75rem}.metrics-grid strong{font-size:.84rem;color:var(--lime-main)}.history-list{display:grid;gap:8px;max-height:340px;overflow:auto}.history-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-main));color:var(--text-main);padding:10px}.history-item p{margin:8px 0;color:var(--text-muted);font-size:.82rem}.history-item.selected{border-color:var(--line-strong)}.history-row{display:flex;justify-content:space-between;gap:8px;font-size:.76rem;color:var(--text-muted)}.runtime-grid{display:grid;grid-template-columns:1.2fr 1fr;gap:12px}.runtime-stack{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}.runtime-details{display:grid;gap:12px}.runtime-runs{max-height:360px;overflow:auto;display:grid;gap:8px}.eval-report-wrap{position:relative}.copy-cube-button{position:absolute;right:10px;bottom:10px;width:34px;height:34px;border-radius:10px;padding:0;min-width:34px;display:grid;place-items:center;font-size:.92rem;line-height:1}.muted{color:var(--text-muted)}.diff-summary{margin-top:10px;font-size:.82rem;color:var(--lime-main)}.error-text{margin-top:10px;color:var(--danger);font-size:.84rem}.autoruns-columns{display:flex;gap:12px;width:100%;min-height:0;flex:1 1 auto;overflow-x:auto;overflow-y:hidden;padding-bottom:4px}.autoruns-col{flex:0 0 var(--mode-column-width);width:var(--mode-column-width);height:100%;min-height:0;overflow-y:auto;overflow-x:hidden;border:none;border-radius:14px;background:rgb(var(--rgb-surface-main));padding:12px;scrollbar-gutter:stable}.autoruns-settings-col{display:flex;flex-direction:column}.autoruns-settings-stack{display:grid;gap:12px}.embedded-panel-section{display:grid;gap:12px;border-radius:12px;background:rgb(var(--rgb-surface-horizontal));padding:12px}.embedded-panel-section-header{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.embedded-panel-section-header h4{margin:0;color:var(--text-main);font-size:.92rem}.embedded-panel-section-header p{margin:6px 0 0;color:var(--text-muted);font-size:.78rem;line-height:1.4}.autoruns-assistant-live-col{background:rgb(var(--rgb-surface-main));padding:12px;overflow:hidden;scrollbar-gutter:auto}.autoruns-assistant-live-col .panel-frame{height:100%;background:rgb(var(--rgb-surface-main))}.autoruns-col h3{margin:0;font-size:.95rem}.autoruns-col h4{margin:12px 0 8px;font-size:.82rem;color:var(--text-muted)}.autoruns-col-header{position:sticky;top:-12px;z-index:8;margin:-12px -12px 10px;padding:12px 12px 10px;background:rgb(var(--rgb-surface-main))}.autoruns-col-header .tab-row{margin:8px 0 0}.autoruns-col-header .autoruns-dialog-toolbar{margin-top:8px}.autoruns-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.autoruns-meta-list{display:grid;gap:8px}.autoruns-meta-list>div{display:flex;justify-content:space-between;gap:8px;border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px 9px;font-size:.79rem}.autoruns-meta-list span{color:var(--text-muted)}.autoruns-prompt-details summary{cursor:pointer;color:var(--text-main);font-size:.8rem;margin-bottom:8px}.autoruns-prompt-details textarea{min-height:68px}.autoruns-stats-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:10px}.autoruns-stats-grid>div{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:3px}.autoruns-stats-grid span{color:var(--text-muted);font-size:.74rem}.autoruns-stats-grid strong{color:var(--lime-main);font-size:.84rem}.autoruns-run-list{display:grid;gap:8px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;padding-right:2px}.autoruns-run-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:10px;display:grid;gap:5px;transition:background-color .2s ease,box-shadow .2s ease}.autoruns-run-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text));box-shadow:none}.autoruns-run-item.selected .autoruns-run-meta{color:rgba(var(--rgb-active-text),.95)}.autoruns-run-head,.autoruns-run-foot{display:flex;justify-content:space-between;gap:8px;font-size:.76rem}.autoruns-run-meta{color:var(--text-muted);font-size:.75rem;word-break:break-word}.autoruns-run-id-row{display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0}.autoruns-run-id-row>span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-copy-run-id-btn{border:none;background:transparent;color:rgb(var(--rgb-text-main));width:16px;height:16px;min-width:16px;min-height:16px;padding:0;display:inline-flex;align-items:center;justify-content:center;border-radius:4px;opacity:.92;cursor:pointer}.autoruns-copy-run-id-btn:hover{color:rgb(var(--rgb-text-main));opacity:1;background:transparent;box-shadow:none;transform:none}.autoruns-copy-run-id-btn:focus-visible{outline:1px solid rgba(var(--rgb-text-main),.7);outline-offset:1px}.autoruns-copy-icon-svg{width:.82rem;height:.82rem;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.autoruns-dialog-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.autoruns-case-list{margin-top:8px;display:grid;gap:6px;max-height:180px;overflow:auto}.autoruns-case-item{width:100%;text-align:left;border-radius:10px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:7px 8px;display:flex;justify-content:space-between;gap:6px;font-size:.76rem}.autoruns-case-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text));box-shadow:none}.autoruns-dialog-view{margin-top:10px;border:none;border-radius:12px;background:rgb(var(--rgb-surface-horizontal));padding:10px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;display:grid;gap:8px}.autoruns-msg{border:none;border-radius:12px;background:rgb(var(--rgb-surface-focus));padding:8px 10px;display:grid;gap:6px;min-width:0;overflow:hidden}.autoruns-msg header,.autoruns-msg footer{display:flex;justify-content:space-between;align-items:flex-start;flex-wrap:wrap;min-width:0;gap:8px;font-size:.74rem;color:var(--text-muted)}.autoruns-msg-head-actions{display:flex;align-items:center;justify-content:flex-end;flex:1 1 auto;min-width:0;flex-wrap:wrap;gap:8px}.autoruns-msg-head-actions>span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-msg-case-tag{display:inline-flex;align-items:center;border-radius:999px;padding:2px 8px;font-size:.7rem;line-height:1;color:rgb(var(--rgb-active-text));background:rgba(var(--rgb-active),.24)}.autoruns-msg p{margin:0;white-space:pre-wrap;line-height:1.35;font-size:.84rem;overflow-wrap:anywhere;word-break:break-word}.autoruns-msg footer span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-comment-icon{border:none;background:transparent;color:rgb(var(--rgb-text-main));border-radius:0;min-width:16px;min-height:16px;width:16px;height:16px;padding:0;line-height:1;box-shadow:none;transform:none;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;opacity:.92}.autoruns-comment-icon:hover{background:transparent;color:rgb(var(--rgb-text-main));opacity:1;box-shadow:none;transform:none}.autoruns-comment-icon.commented{color:rgb(var(--rgb-active));background:transparent;box-shadow:none}.autoruns-comment-icon:focus-visible{outline:1px solid rgba(var(--rgb-text-main),.7);outline-offset:1px}.autoruns-comment-icon:disabled{opacity:.42;cursor:not-allowed}.comment-icon-svg{width:.82rem;height:.82rem;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round;fill:none}.comment-icon-svg.commented{stroke:rgb(var(--rgb-active));fill:none}.autoruns-resolve-toggle{border:none;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));border-radius:999px;width:22px;height:22px;min-width:22px;min-height:22px;padding:0;display:inline-flex;align-items:center;justify-content:center;box-shadow:none;transform:none}.autoruns-resolve-toggle:hover{background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-active));box-shadow:none;transform:none}.autoruns-resolve-toggle:disabled{opacity:.55;cursor:wait}.autoruns-resolve-toggle.resolved{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.resolve-icon-svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.resolve-icon-svg.resolved{fill:currentColor}.autoruns-msg-annotation{display:grid;gap:4px;border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:7px 8px;font-size:.78rem}.autoruns-comments-list{display:grid;gap:8px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;padding-right:2px;margin-top:6px}.autoruns-autogen-list{display:grid;gap:8px;max-height:none;min-height:0;overflow:auto;padding-right:2px}.autoruns-autogen-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:5px;cursor:pointer}.autoruns-autogen-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-autogen-item.selected .autoruns-run-meta,.autoruns-autogen-item.selected p{color:rgba(var(--rgb-active-text),.95)}.autoruns-autogen-item header{display:flex;justify-content:space-between;gap:8px;font-size:.76rem}.autoruns-autogen-item p{margin:0;color:var(--text-muted);white-space:pre-wrap;font-size:.8rem}.autoruns-run-launch-btn{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-run-launch-btn:hover{background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main))}.autoruns-run-launch-btn:disabled{background:rgba(var(--rgb-active),.38);color:rgba(var(--rgb-active-text),.88)}.autoruns-generated-questions{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:8px}.autoruns-generated-questions-head{display:flex;align-items:center;justify-content:space-between;gap:8px}.autoruns-generated-questions-list{display:grid;gap:6px;max-height:220px;overflow:auto;padding-right:2px}.autoruns-generated-question-item{position:relative;display:block;gap:8px;border:none;border-radius:9px;background:rgb(var(--rgb-surface-focus));padding:7px 30px 7px 8px;font-size:.78rem}.autoruns-generated-question-item span{display:block;white-space:pre-wrap}.autoruns-remove-question-btn{position:absolute;top:6px;right:6px;flex:0 0 auto;border:none;border-radius:0;background:transparent;color:rgb(var(--rgb-text-main));min-width:16px;width:16px;height:16px;padding:0;font-size:1rem;font-weight:700;line-height:1;display:inline-flex;align-items:center;justify-content:center;box-shadow:none;transition:color .15s ease}.autoruns-remove-question-btn:hover{background:transparent;color:rgb(var(--rgb-active));box-shadow:none}.autoruns-remove-question-btn:focus-visible{outline:none}.autoruns-personality-prompt{resize:vertical;min-height:110px}.autoruns-comment-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:9px;display:grid;gap:6px;cursor:pointer}.autoruns-comment-item p{margin:0;white-space:pre-wrap;color:var(--text-muted);font-size:.79rem}.autoruns-comment-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-comment-item.selected p,.autoruns-comment-item.selected .autoruns-run-meta,.autoruns-comment-item.selected .muted{color:rgba(var(--rgb-active-text),.94)}.autoruns-comment-item.selected .autoruns-resolve-toggle{background:rgba(var(--rgb-active-text),.18);color:rgb(var(--rgb-active-text))}.autoruns-comment-head{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:.75rem}.autoruns-comment-head-actions{display:inline-flex;align-items:center;gap:8px}.autoruns-comment-filter-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:10px;margin-bottom:8px}.autoruns-resolved-filter-toggle{min-height:38px;white-space:nowrap}.autoruns-msg.assistant{margin-right:12%}.autoruns-msg.user{margin-left:12%;border-color:transparent;background:rgb(var(--rgb-surface-focus))}.autoruns-decomposition-list{margin:0;padding-left:18px;display:grid;gap:7px;font-size:.8rem}.autoruns-comment-modal-backdrop{position:fixed;inset:0;background:rgba(var(--rgb-background),.74);display:grid;place-items:center;z-index:1800;padding:12px}.autoruns-comment-modal{width:min(660px,100%);border:none;border-radius:16px;background:rgb(var(--rgb-surface-horizontal));box-shadow:var(--shadow);padding:14px;display:grid;gap:10px}.autoruns-comment-modal h3{margin:0;font-size:.95rem}.autoruns-comment-quote{margin:0;border:none;border-radius:10px;background:rgb(var(--rgb-surface-focus));padding:8px;white-space:pre-wrap;max-height:150px;overflow:auto;font-size:.82rem}.autoruns-rating-row{display:flex;gap:8px}.autoruns-rating-dot{width:34px;height:34px;border-radius:999px;padding:0;border:none;background:rgb(var(--rgb-surface-focus));color:var(--text-muted);font-size:.95rem;box-shadow:none;transform:none}.autoruns-rating-dot:hover{border-color:var(--line-strong);box-shadow:none;transform:none}.autoruns-rating-dot.active{border-color:var(--line-strong);color:rgb(var(--rgb-active-text));background:rgb(var(--rgb-active))}.autoruns-coverage-list{display:grid;gap:8px}.autoruns-coverage-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px}.autoruns-coverage-head{display:flex;justify-content:space-between;gap:8px;font-size:.76rem;margin-bottom:5px}.autoruns-coverage-head span{color:var(--text-muted)}.autoruns-coverage-bar{height:7px;border-radius:999px;background:rgb(var(--rgb-surface-focus));overflow:hidden}.autoruns-coverage-bar>div{height:100%;border-radius:999px;background:rgb(var(--rgb-active))}.autoruns-autogen-card-actions{display:inline-flex;align-items:center;gap:8px}.autoruns-autogen-delete-btn{border:none;border-radius:0;width:22px;height:22px;min-width:22px;padding:0;background:transparent;color:rgb(var(--rgb-text-main));display:inline-flex;align-items:center;justify-content:center;font-size:1rem;font-weight:700;line-height:1;box-shadow:none;transition:color .15s ease}.autoruns-autogen-delete-btn:hover{background:transparent;color:rgb(var(--rgb-active));box-shadow:none}.autoruns-agent-acceptance{display:grid;gap:6px;margin-top:6px}.autoruns-agent-pill-row{display:flex;flex-wrap:wrap;gap:6px}.autoruns-agent-pill{display:inline-flex;align-items:center;justify-content:center;min-height:24px;padding:0 8px;border-radius:999px;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));font-size:.73rem;line-height:1;border:1px solid rgba(var(--rgb-text-main),.1)}.autoruns-agent-pill.neutral{color:var(--text-muted)}.autoruns-agent-pill.status-accepted{color:rgb(var(--rgb-emerald));border-color:rgba(var(--rgb-emerald),.32)}.autoruns-agent-pill.status-partial{color:rgb(var(--rgb-warning));border-color:rgba(var(--rgb-warning),.32)}.autoruns-agent-pill.status-blocked{color:rgb(var(--rgb-danger));border-color:rgba(var(--rgb-danger),.32)}.autoruns-agent-pill.status-unknown{color:var(--text-muted)}@media(max-width:1200px){:root{--mode-column-width: 400px}.metrics-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:920px){:root{--mode-column-width: 360px}.grid-two,.runtime-grid,.runtime-stack{grid-template-columns:1fr}.metrics-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.autoruns-form-grid,.autoruns-dialog-toolbar,.autoruns-stats-grid,.autoruns-comment-filter-row{grid-template-columns:1fr}}@media(max-width:640px){:root{--mode-column-width: 320px}.app-root{padding:18px 12px 24px}.metrics-grid{grid-template-columns:1fr}}@keyframes rise{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}} +@import"https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=Space+Grotesk:wght@500;700&display=swap";:root{--rgb-background: 16, 16, 19;--rgb-surface-main: 26, 26, 31;--rgb-surface-horizontal: 32, 32, 38;--rgb-surface-focus: 40, 40, 47;--rgb-assistant-chip: 18, 18, 18;--rgb-assistant-chip-hover: 44, 44, 44;--rgb-assistant-chip-selected: 228, 142, 92;--rgb-assistant-chip-selected-text: 18, 18, 18;--rgb-active: 228, 142, 92;--rgb-active-text: 18, 18, 18;--rgb-text-main: 240, 240, 240;--rgb-text-muted: 166, 166, 170;--rgb-emerald: 126, 211, 154;--rgb-warning: 255, 196, 116;--rgb-danger: 255, 126, 126;--rgb-scrollbar-track: 31, 31, 36;--rgb-scrollbar-thumb: 74, 74, 82;--rgb-scrollbar-thumb-hover: 90, 90, 100;--mode-column-width: 440px;--mode-toggle-width: 188px;--bg-main: rgb(var(--rgb-background));--bg-soft: rgb(var(--rgb-surface-main));--bg-panel: rgb(var(--rgb-surface-main));--bg-panel-accent: rgb(var(--rgb-surface-horizontal));--surface-horizontal: rgb(var(--rgb-surface-horizontal));--surface-focus: rgb(var(--rgb-surface-focus));--line: transparent;--line-strong: rgba(var(--rgb-active), .48);--text-main: rgb(var(--rgb-text-main));--text-muted: rgb(var(--rgb-text-muted));--lime-main: rgb(var(--rgb-text-main));--lime-press: rgb(var(--rgb-text-main));--danger: rgb(var(--rgb-danger));--radius-lg: 20px;--radius-md: 14px;--shadow: none;--autoruns-col-width: var(--mode-column-width)}*{box-sizing:border-box;scrollbar-width:thin;scrollbar-color:rgb(var(--rgb-scrollbar-thumb)) rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar{width:10px;height:10px}*::-webkit-scrollbar-track{background:rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar-thumb{background:rgb(var(--rgb-scrollbar-thumb));border-radius:999px;border:2px solid rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar-thumb:hover{background:rgb(var(--rgb-scrollbar-thumb-hover))}html,body,#root{margin:0;min-height:100dvh;font-family:Manrope,Segoe UI,sans-serif;background:var(--bg-main);color:var(--text-main)}.app-root{max-width:1720px;margin:0 auto;padding:12px 16px 16px}.app-root.app-root-autoruns{max-width:none;width:100%;min-height:100dvh;max-height:100dvh;display:flex;flex-direction:column;overflow:hidden}.app-topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 12px;padding:0;min-height:38px}.layout-grid{display:grid;grid-template-columns:repeat(12,1fr);gap:16px}.layout-grid.layout-grid-autoruns,.layout-grid.layout-grid-mode-columns{min-height:0;flex:1 1 auto;grid-template-columns:minmax(0,1fr)}.mode-switch-row{display:flex;gap:8px;margin:0;padding:0}.mode-switch-row.mode-switch-row-right{margin-left:auto;justify-content:flex-end;max-width:72%;overflow-x:auto;overflow-y:hidden;padding-bottom:2px}.mode-switch-row .tab{white-space:nowrap}.mode-switch-row.mode-switch-row-right .tab{width:var(--mode-toggle-width);min-width:var(--mode-toggle-width);text-align:center}.mode-columns{display:flex;gap:12px;width:100%;min-height:0;flex:1 1 auto;overflow-x:auto;overflow-y:hidden;padding-bottom:4px}.mode-col{flex:0 0 var(--mode-column-width);width:var(--mode-column-width);min-height:0;height:100%;display:flex}.mode-col.mode-col-wide,.mode-col.mode-col-xwide{flex-basis:var(--mode-column-width);width:var(--mode-column-width)}.mode-col .panel-frame{width:100%;height:100%}.mode-col .panel-body{min-height:0;overflow:auto}.mode-columns-empty{min-width:360px;border-radius:14px;background:rgb(var(--rgb-surface-main));color:var(--text-muted);padding:14px}.panel-frame{grid-column:span 12;border:none;border-radius:var(--radius-lg);background:var(--bg-panel);overflow:hidden;box-shadow:none;animation:rise .4s ease-out;display:flex;flex-direction:column;min-height:0}.panel-header{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;padding:14px 18px 10px;border-bottom:none;background:var(--bg-panel-accent)}.panel-header h2{margin:0;font-size:1.02rem;letter-spacing:.02em}.panel-header p{margin:6px 0 0;font-size:.85rem;color:var(--text-muted)}.panel-body{padding:10px 12px 12px;min-height:0}.app-root-autoruns .autoruns-frame{height:100%}.app-root-autoruns .autoruns-frame .panel-body{flex:1 1 auto;overflow:hidden;display:flex;flex-direction:column;gap:10px;padding:10px 12px 12px;background:rgb(var(--rgb-background))}.status-chip{border:none;border-radius:999px;padding:4px 10px;color:var(--lime-main);font-size:.78rem;background:rgb(var(--rgb-surface-focus))}.assistant-toolbar{display:grid;gap:8px}.assistant-toolbar-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:center;gap:8px}.assistant-toolbar-meta{display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-toolbar-meta-right{margin-left:auto;display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0;flex-wrap:wrap}.assistant-live-status{color:var(--text-muted);font-size:.8rem;white-space:nowrap}.assistant-toolbar-error{margin:0}.assistant-copy-btn{width:100%;justify-self:stretch;background:transparent;border-color:transparent;color:var(--text-main);font-size:.6rem;line-height:1.1;white-space:nowrap;text-align:center;letter-spacing:0;padding:6px 8px;box-shadow:none;transform:none}.assistant-copy-btn:hover{background:rgb(var(--rgb-surface-focus));filter:none;box-shadow:none;transform:none}.assistant-copy-feedback{font-size:.76rem;color:var(--text-muted)}.assistant-copy-feedback.success{color:var(--lime-main)}.assistant-copy-feedback.error{color:var(--danger)}input,select,textarea,button{font-family:Manrope,sans-serif}label{display:flex;flex-direction:column;gap:6px;color:var(--text-muted);font-size:.84rem}input,select,textarea{border:none;border-radius:var(--radius-md);background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:10px 12px;outline:none;transition:background-color .18s ease}input:focus,select:focus,textarea:focus{border-color:transparent;box-shadow:none;outline:none;background:rgb(var(--rgb-surface-focus))}textarea{resize:vertical;min-height:86px;overflow-y:auto;overflow-x:hidden;scrollbar-gutter:stable}.assistant-input-textarea,.autoruns-personality-prompt{overflow-y:auto;overflow-x:hidden;scrollbar-gutter:stable both-edges;border-bottom-right-radius:6px}.assistant-input-textarea::-webkit-scrollbar-corner,.autoruns-personality-prompt::-webkit-scrollbar-corner{background:rgb(var(--rgb-surface-horizontal))}button{border:none;border-radius:999px;background:rgb(var(--rgb-surface-horizontal));color:rgb(var(--rgb-text-main));font-weight:700;font-size:.83rem;letter-spacing:.02em;cursor:pointer;padding:9px 14px;transition:background .2s ease,color .2s ease;outline:none;box-shadow:none}button:hover{border-color:transparent;background:rgb(var(--rgb-surface-focus))}button:disabled{opacity:.52;cursor:not-allowed}.button-row{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-top:12px}.checkbox-row{flex-direction:row;align-items:center;gap:8px;color:var(--text-main)}.grid-two{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.prompt-manager-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}.full-width{grid-column:1 / -1}.tab-row{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px}.tab{background:rgb(var(--rgb-surface-main));color:var(--text-main);border:none}.tab.active{border-color:transparent;background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-chat-list{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:8px;padding:10px;border:none;border-radius:12px;background:rgb(var(--rgb-surface-horizontal))}.assistant-chat-list .assistant-msg:first-child{margin-top:auto}.assistant-empty{padding:18px;text-align:center}.assistant-msg{border:none;border-radius:12px;background:rgb(var(--rgb-surface-focus));padding:8px 10px;display:grid;gap:6px;min-width:0}.assistant-msg.user{margin-left:12%;border-color:transparent;background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-msg.assistant{margin-right:12%;border-color:transparent}.assistant-msg.user .assistant-msg-head{color:rgba(var(--rgb-active-text),.9)}.assistant-msg.user .assistant-msg-body{color:rgb(var(--rgb-active-text))}.assistant-msg-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:0;font-size:.74rem;color:var(--text-muted)}.assistant-msg-head-main{flex:1 1 auto;min-width:0;display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-msg-head-actions{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto}.assistant-comment-btn{cursor:pointer}.assistant-comment-btn:disabled{opacity:.42;cursor:not-allowed}.assistant-msg.user .assistant-comment-btn{color:rgba(var(--rgb-active-text),.92)}.assistant-msg-body{display:grid;gap:10px;line-height:1.35;font-size:.84rem;min-width:0}.assistant-msg-block{display:grid;gap:4px;min-width:0}.assistant-msg-block.selectable{cursor:pointer;padding:8px 10px;border-radius:12px;transition:background .18s ease,color .18s ease}.assistant-msg-block.selectable:hover,.assistant-msg-block.selectable:focus-visible{background:rgba(var(--rgb-active),.18);outline:none}.assistant-msg-block.selectable.active{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-msg-block.selectable.active:hover,.assistant-msg-block.selectable.active:focus-visible{background:rgb(var(--rgb-active))}.assistant-msg-block.selectable.active .assistant-msg-line,.assistant-msg-block.selectable.active .assistant-msg-line strong{color:rgb(var(--rgb-active-text))}.assistant-msg-line{margin:0;white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere}.assistant-msg-line.heading{font-weight:700;letter-spacing:.01em}.assistant-msg-line.numbered{margin-top:2px}.assistant-msg-line strong{font-weight:800}.assistant-trace{margin-top:6px;color:var(--text-muted);font-size:.75rem}.assistant-debug{margin-top:8px}.assistant-debug summary{cursor:pointer;color:var(--lime-main);font-size:.8rem}.assistant-compose{margin-top:0;display:grid;gap:8px;flex:0 0 auto}.assistant-compose-context{display:grid;gap:6px;padding:10px 12px;border-radius:var(--radius-md);background:rgb(var(--rgb-surface-horizontal))}.assistant-compose-context-label{color:var(--text-muted);font-size:.74rem;font-weight:700;letter-spacing:.01em}.assistant-compose-context-pill{display:inline-flex;align-items:center;gap:8px;max-width:100%;width:fit-content;min-height:38px;padding:0 10px 0 12px;border-radius:999px;background:rgb(var(--rgb-assistant-chip-selected));color:rgb(var(--rgb-assistant-chip-selected-text))}.assistant-compose-context-pill-text{min-width:0;max-width:min(100%,460px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.82rem;font-weight:700}.assistant-compose-context-clear{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;min-width:24px;padding:0;border-radius:999px;background:#0000002e;color:inherit;font-size:.96rem;line-height:1}.assistant-compose-context-clear:hover{background:#00000047}.assistant-send-row{align-items:center;margin-top:2px}.assistant-send-btn{margin-left:auto}.assistant-comments-frame .panel-body{display:flex;flex-direction:column;min-height:0;overflow:hidden}.assistant-comments-shell{display:grid;gap:8px;min-height:0;height:100%}.assistant-comments-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-comments-list{display:grid;gap:8px;overflow:auto;min-height:0;padding-right:2px}.assistant-comment-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:6px}.assistant-comment-head{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:.75rem}.assistant-comment-item p{margin:0;white-space:pre-wrap;font-size:.8rem}.assistant-comment-meta{display:flex;flex-wrap:wrap;gap:8px;color:var(--text-muted);font-size:.74rem}.app-root-autoruns .assistant-panel-frame .panel-header{position:sticky;top:-12px;z-index:8;margin:-12px -12px 0;padding:12px 12px 10px;background:rgb(var(--rgb-surface-main))}.app-root-autoruns .assistant-panel-frame{overflow:visible}.app-root-autoruns .assistant-panel-frame .panel-body{flex:1 1 auto;padding:0 12px 12px;display:flex;flex-direction:column;min-height:0;overflow:hidden}.app-root-autoruns .assistant-panel-frame .assistant-live-shell{flex:1 1 auto;min-height:0;padding:12px;border-radius:14px;background:rgb(var(--rgb-background));display:flex;flex-direction:column;gap:10px}.app-root-autoruns .assistant-panel-frame .assistant-chat-list{overflow-y:auto}.app-root-autoruns .assistant-panel-frame .panel-header h2{margin:0;font-size:.95rem}.json-view{margin:0;width:100%;min-height:180px;max-height:420px;overflow:auto;background:rgb(var(--rgb-surface-horizontal));border:none;border-radius:var(--radius-md);padding:12px;color:rgb(var(--rgb-text-main));font-family:JetBrains Mono,Consolas,monospace;font-size:.78rem;line-height:1.45}.metrics-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}.metrics-grid div{background:rgba(var(--rgb-surface-main),.8);border:none;border-radius:12px;padding:10px;display:flex;flex-direction:column;gap:4px}.metrics-grid span{color:var(--text-muted);font-size:.75rem}.metrics-grid strong{font-size:.84rem;color:var(--lime-main)}.history-list{display:grid;gap:8px;max-height:340px;overflow:auto}.history-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-main));color:var(--text-main);padding:10px}.history-item p{margin:8px 0;color:var(--text-muted);font-size:.82rem}.history-item.selected{border-color:var(--line-strong)}.history-row{display:flex;justify-content:space-between;gap:8px;font-size:.76rem;color:var(--text-muted)}.runtime-grid{display:grid;grid-template-columns:1.2fr 1fr;gap:12px}.runtime-stack{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}.runtime-details{display:grid;gap:12px}.runtime-runs{max-height:360px;overflow:auto;display:grid;gap:8px}.eval-report-wrap{position:relative}.copy-cube-button{position:absolute;right:10px;bottom:10px;width:34px;height:34px;border-radius:10px;padding:0;min-width:34px;display:grid;place-items:center;font-size:.92rem;line-height:1}.muted{color:var(--text-muted)}.diff-summary{margin-top:10px;font-size:.82rem;color:var(--lime-main)}.error-text{margin-top:10px;color:var(--danger);font-size:.84rem}.autoruns-columns{display:flex;gap:12px;width:100%;min-height:0;flex:1 1 auto;overflow-x:auto;overflow-y:hidden;padding-bottom:4px}.autoruns-col{flex:0 0 var(--mode-column-width);width:var(--mode-column-width);height:100%;min-height:0;overflow-y:auto;overflow-x:hidden;border:none;border-radius:14px;background:rgb(var(--rgb-surface-main));padding:12px;scrollbar-gutter:stable}.autoruns-settings-col{display:flex;flex-direction:column}.autoruns-settings-stack{display:grid;gap:12px}.embedded-panel-section{display:grid;gap:12px;border-radius:12px;background:rgb(var(--rgb-surface-horizontal));padding:12px}.embedded-panel-section-header{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.embedded-panel-section-header h4{margin:0;color:var(--text-main);font-size:.92rem}.embedded-panel-section-header p{margin:6px 0 0;color:var(--text-muted);font-size:.78rem;line-height:1.4}.autoruns-assistant-live-col{background:rgb(var(--rgb-surface-main));padding:12px;overflow:hidden;scrollbar-gutter:auto}.autoruns-assistant-live-col .panel-frame{height:100%;background:rgb(var(--rgb-surface-main))}.autoruns-col h3{margin:0;font-size:.95rem}.autoruns-col h4{margin:12px 0 8px;font-size:.82rem;color:var(--text-muted)}.autoruns-col-header{position:sticky;top:-12px;z-index:8;margin:-12px -12px 10px;padding:12px 12px 10px;background:rgb(var(--rgb-surface-main))}.autoruns-col-header .tab-row{margin:8px 0 0}.autoruns-col-header .autoruns-dialog-toolbar{margin-top:8px}.autoruns-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.autoruns-meta-list{display:grid;gap:8px}.autoruns-meta-list>div{display:flex;justify-content:space-between;gap:8px;border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px 9px;font-size:.79rem}.autoruns-meta-list span{color:var(--text-muted)}.autoruns-prompt-details summary{cursor:pointer;color:var(--text-main);font-size:.8rem;margin-bottom:8px}.autoruns-prompt-details textarea{min-height:68px}.autoruns-stats-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:10px}.autoruns-stats-grid>div{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:3px}.autoruns-stats-grid span{color:var(--text-muted);font-size:.74rem}.autoruns-stats-grid strong{color:var(--lime-main);font-size:.84rem}.autoruns-run-list{display:grid;gap:8px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;padding-right:2px}.autoruns-run-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:10px;display:grid;gap:5px;transition:background-color .2s ease,box-shadow .2s ease}.autoruns-run-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text));box-shadow:none}.autoruns-run-item.selected .autoruns-run-meta{color:rgba(var(--rgb-active-text),.95)}.autoruns-run-head,.autoruns-run-foot{display:flex;justify-content:space-between;gap:8px;font-size:.76rem}.autoruns-run-meta{color:var(--text-muted);font-size:.75rem;word-break:break-word}.autoruns-run-id-row{display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0}.autoruns-run-id-row>span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-copy-run-id-btn{border:none;background:transparent;color:rgb(var(--rgb-text-main));width:16px;height:16px;min-width:16px;min-height:16px;padding:0;display:inline-flex;align-items:center;justify-content:center;border-radius:4px;opacity:.92;cursor:pointer}.autoruns-copy-run-id-btn:hover{color:rgb(var(--rgb-text-main));opacity:1;background:transparent;box-shadow:none;transform:none}.autoruns-copy-run-id-btn:focus-visible{outline:1px solid rgba(var(--rgb-text-main),.7);outline-offset:1px}.autoruns-copy-icon-svg{width:.82rem;height:.82rem;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.autoruns-dialog-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.autoruns-case-list{margin-top:8px;display:grid;gap:6px;max-height:180px;overflow:auto}.autoruns-case-item{width:100%;text-align:left;border-radius:10px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:7px 8px;display:flex;justify-content:space-between;gap:6px;font-size:.76rem}.autoruns-case-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text));box-shadow:none}.autoruns-dialog-view{margin-top:10px;border:none;border-radius:12px;background:rgb(var(--rgb-surface-horizontal));padding:10px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;display:grid;gap:8px}.autoruns-msg{border:none;border-radius:12px;background:rgb(var(--rgb-surface-focus));padding:8px 10px;display:grid;gap:6px;min-width:0;overflow:hidden}.autoruns-msg header,.autoruns-msg footer{display:flex;justify-content:space-between;align-items:flex-start;flex-wrap:wrap;min-width:0;gap:8px;font-size:.74rem;color:var(--text-muted)}.autoruns-msg-head-actions{display:flex;align-items:center;justify-content:flex-end;flex:1 1 auto;min-width:0;flex-wrap:wrap;gap:8px}.autoruns-msg-head-actions>span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-msg-case-tag{display:inline-flex;align-items:center;border-radius:999px;padding:2px 8px;font-size:.7rem;line-height:1;color:rgb(var(--rgb-active-text));background:rgba(var(--rgb-active),.24)}.autoruns-msg p{margin:0;white-space:pre-wrap;line-height:1.35;font-size:.84rem;overflow-wrap:anywhere;word-break:break-word}.autoruns-msg footer span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-comment-icon{border:none;background:transparent;color:rgb(var(--rgb-text-main));border-radius:0;min-width:16px;min-height:16px;width:16px;height:16px;padding:0;line-height:1;box-shadow:none;transform:none;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;opacity:.92}.autoruns-comment-icon:hover{background:transparent;color:rgb(var(--rgb-text-main));opacity:1;box-shadow:none;transform:none}.autoruns-comment-icon.commented{color:rgb(var(--rgb-active));background:transparent;box-shadow:none}.autoruns-comment-icon:focus-visible{outline:1px solid rgba(var(--rgb-text-main),.7);outline-offset:1px}.autoruns-comment-icon:disabled{opacity:.42;cursor:not-allowed}.comment-icon-svg{width:.82rem;height:.82rem;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round;fill:none}.comment-icon-svg.commented{stroke:rgb(var(--rgb-active));fill:none}.autoruns-resolve-toggle{border:none;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));border-radius:999px;width:22px;height:22px;min-width:22px;min-height:22px;padding:0;display:inline-flex;align-items:center;justify-content:center;box-shadow:none;transform:none}.autoruns-resolve-toggle:hover{background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-active));box-shadow:none;transform:none}.autoruns-resolve-toggle:disabled{opacity:.55;cursor:wait}.autoruns-resolve-toggle.resolved{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.resolve-icon-svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.resolve-icon-svg.resolved{fill:currentColor}.autoruns-msg-annotation{display:grid;gap:4px;border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:7px 8px;font-size:.78rem}.autoruns-comments-list{display:grid;gap:8px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;padding-right:2px;margin-top:6px}.autoruns-autogen-list{display:grid;gap:8px;max-height:none;min-height:0;overflow:auto;padding-right:2px}.autoruns-autogen-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:5px;cursor:pointer}.autoruns-autogen-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-autogen-item.selected .autoruns-run-meta,.autoruns-autogen-item.selected p{color:rgba(var(--rgb-active-text),.95)}.autoruns-autogen-item header{display:flex;justify-content:space-between;gap:8px;font-size:.76rem}.autoruns-autogen-item p{margin:0;color:var(--text-muted);white-space:pre-wrap;font-size:.8rem}.autoruns-run-launch-btn{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-run-launch-btn:hover{background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main))}.autoruns-run-launch-btn:disabled{background:rgba(var(--rgb-active),.38);color:rgba(var(--rgb-active-text),.88)}.autoruns-generated-questions{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:8px}.autoruns-generated-questions-head{display:flex;align-items:center;justify-content:space-between;gap:8px}.autoruns-generated-questions-list{display:grid;gap:6px;max-height:220px;overflow:auto;padding-right:2px}.autoruns-generated-question-item{position:relative;display:grid;grid-template-columns:22px minmax(0,1fr) auto;align-items:start;gap:8px;border:none;border-radius:9px;background:rgb(var(--rgb-surface-focus));padding:7px 8px;font-size:.78rem;transition:background .15s ease,outline-color .15s ease,opacity .15s ease}.autoruns-generated-question-item.drag-over{outline:1px solid rgba(var(--rgb-active),.75)}.autoruns-generated-question-item.dragging{opacity:.72}.autoruns-generated-question-item.editing{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-question-grip-btn{width:18px;min-width:18px;height:18px;padding:0;border:none;border-radius:6px;background:transparent;color:var(--text-muted);display:inline-flex;align-items:center;justify-content:center;cursor:grab;margin-top:1px}.autoruns-question-grip-btn:hover:not(:disabled){color:rgb(var(--rgb-text-main));background:rgba(var(--rgb-background),.3)}.autoruns-generated-question-item.editing .autoruns-question-grip-btn{color:rgba(var(--rgb-active-text),.9)}.autoruns-generated-question-item.editing .autoruns-question-grip-btn:hover:not(:disabled){color:rgb(var(--rgb-active-text));background:rgba(var(--rgb-active-text),.14)}.autoruns-question-grip-btn:disabled{cursor:default;opacity:.45}.autoruns-question-grip-svg{width:14px;height:14px;fill:currentColor}.autoruns-generated-question-text{border:none;background:transparent;color:rgb(var(--rgb-text-main));padding:0;margin:0;text-align:left;font:inherit;white-space:pre-wrap;line-height:1.4;cursor:text}.autoruns-generated-question-text:hover{color:rgb(var(--rgb-active))}.autoruns-generated-question-input{width:100%;min-width:0;border:none;border-radius:8px;background:rgba(var(--rgb-background),.55);color:rgb(var(--rgb-text-main));padding:6px 8px;font:inherit;line-height:1.4}.autoruns-generated-question-input:focus{outline:none}.autoruns-generated-question-item.editing .autoruns-generated-question-input{background:rgba(var(--rgb-active-text),.14);color:rgb(var(--rgb-active-text))}.autoruns-generated-question-item.editing .autoruns-generated-question-input::placeholder{color:rgba(var(--rgb-active-text),.78)}.autoruns-add-question-btn{width:100%;min-height:30px;border-radius:8px;border:none;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));font-size:1.1rem;font-weight:700;line-height:1}.autoruns-add-question-btn:hover:not(:disabled){background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-add-question-btn:disabled{opacity:.5;cursor:default}.autoruns-remove-question-btn{flex:0 0 auto;border:none;border-radius:0;background:transparent;color:rgb(var(--rgb-text-main));min-width:16px;width:16px;height:16px;padding:0;font-size:1rem;font-weight:700;line-height:1;display:inline-flex;align-items:center;justify-content:center;box-shadow:none;transition:color .15s ease;align-self:start}.autoruns-remove-question-btn:hover{background:transparent;color:rgb(var(--rgb-active));box-shadow:none}.autoruns-generated-question-item.editing .autoruns-remove-question-btn{color:rgb(var(--rgb-active-text))}.autoruns-generated-question-item.editing .autoruns-remove-question-btn:hover{color:rgba(var(--rgb-active-text),.82)}.autoruns-remove-question-btn:focus-visible{outline:none}.autoruns-personality-prompt{resize:vertical;min-height:110px}.autoruns-comment-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:9px;display:grid;gap:6px;cursor:pointer}.autoruns-comment-item p{margin:0;white-space:pre-wrap;color:var(--text-muted);font-size:.79rem}.autoruns-comment-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-comment-item.selected p,.autoruns-comment-item.selected .autoruns-run-meta,.autoruns-comment-item.selected .muted{color:rgba(var(--rgb-active-text),.94)}.autoruns-comment-item.selected .autoruns-resolve-toggle{background:rgba(var(--rgb-active-text),.18);color:rgb(var(--rgb-active-text))}.autoruns-comment-head{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:.75rem}.autoruns-comment-head-actions{display:inline-flex;align-items:center;gap:8px}.autoruns-comment-filter-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:10px;margin-bottom:8px}.autoruns-resolved-filter-toggle{min-height:38px;white-space:nowrap}.autoruns-msg.assistant{margin-right:12%}.autoruns-msg.user{margin-left:12%;border-color:transparent;background:rgb(var(--rgb-surface-focus))}.autoruns-decomposition-list{margin:0;padding-left:18px;display:grid;gap:7px;font-size:.8rem}.autoruns-comment-modal-backdrop{position:fixed;inset:0;background:rgba(var(--rgb-background),.74);display:grid;place-items:center;z-index:1800;padding:12px}.autoruns-comment-modal{width:min(660px,100%);border:none;border-radius:16px;background:rgb(var(--rgb-surface-horizontal));box-shadow:var(--shadow);padding:14px;display:grid;gap:10px}.autoruns-comment-modal h3{margin:0;font-size:.95rem}.autoruns-comment-quote{margin:0;border:none;border-radius:10px;background:rgb(var(--rgb-surface-focus));padding:8px;white-space:pre-wrap;max-height:150px;overflow:auto;font-size:.82rem}.autoruns-rating-row{display:flex;gap:8px}.autoruns-rating-dot{width:34px;height:34px;border-radius:999px;padding:0;border:none;background:rgb(var(--rgb-surface-focus));color:var(--text-muted);font-size:.95rem;box-shadow:none;transform:none}.autoruns-rating-dot:hover{border-color:var(--line-strong);box-shadow:none;transform:none}.autoruns-rating-dot.active{border-color:var(--line-strong);color:rgb(var(--rgb-active-text));background:rgb(var(--rgb-active))}.autoruns-coverage-list{display:grid;gap:8px}.autoruns-coverage-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px}.autoruns-coverage-head{display:flex;justify-content:space-between;gap:8px;font-size:.76rem;margin-bottom:5px}.autoruns-coverage-head span{color:var(--text-muted)}.autoruns-coverage-bar{height:7px;border-radius:999px;background:rgb(var(--rgb-surface-focus));overflow:hidden}.autoruns-coverage-bar>div{height:100%;border-radius:999px;background:rgb(var(--rgb-active))}.autoruns-autogen-card-actions{display:inline-flex;align-items:center;gap:8px}.autoruns-autogen-delete-btn{border:none;border-radius:0;width:22px;height:22px;min-width:22px;padding:0;background:transparent;color:rgb(var(--rgb-text-main));display:inline-flex;align-items:center;justify-content:center;font-size:1rem;font-weight:700;line-height:1;box-shadow:none;transition:color .15s ease}.autoruns-autogen-delete-btn:hover{background:transparent;color:rgb(var(--rgb-active));box-shadow:none}.autoruns-agent-acceptance{display:grid;gap:6px;margin-top:6px}.autoruns-agent-pill-row{display:flex;flex-wrap:wrap;gap:6px}.autoruns-agent-pill{display:inline-flex;align-items:center;justify-content:center;min-height:24px;padding:0 8px;border-radius:999px;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));font-size:.73rem;line-height:1;border:1px solid rgba(var(--rgb-text-main),.1)}.autoruns-agent-pill.neutral{color:var(--text-muted)}.autoruns-agent-pill.status-accepted{color:rgb(var(--rgb-emerald));border-color:rgba(var(--rgb-emerald),.32)}.autoruns-agent-pill.status-partial{color:rgb(var(--rgb-warning));border-color:rgba(var(--rgb-warning),.32)}.autoruns-agent-pill.status-blocked{color:rgb(var(--rgb-danger));border-color:rgba(var(--rgb-danger),.32)}.autoruns-agent-pill.status-unknown{color:var(--text-muted)}@media(max-width:1200px){:root{--mode-column-width: 400px}.metrics-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:920px){:root{--mode-column-width: 360px}.grid-two,.runtime-grid,.runtime-stack{grid-template-columns:1fr}.metrics-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.autoruns-form-grid,.autoruns-dialog-toolbar,.autoruns-stats-grid,.autoruns-comment-filter-row{grid-template-columns:1fr}}@media(max-width:640px){:root{--mode-column-width: 320px}.app-root{padding:18px 12px 24px}.metrics-grid{grid-template-columns:1fr}}@keyframes rise{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}} diff --git a/llm_normalizer/frontend/dist/index.html b/llm_normalizer/frontend/dist/index.html index 34f8017..7612730 100644 --- a/llm_normalizer/frontend/dist/index.html +++ b/llm_normalizer/frontend/dist/index.html @@ -4,8 +4,8 @@ NDC AI Normalizer Playground - - + +
diff --git a/llm_normalizer/frontend/src/components/AutoRunsHistoryPanel.tsx b/llm_normalizer/frontend/src/components/AutoRunsHistoryPanel.tsx index 66f0fbb..65688b2 100644 --- a/llm_normalizer/frontend/src/components/AutoRunsHistoryPanel.tsx +++ b/llm_normalizer/frontend/src/components/AutoRunsHistoryPanel.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useMemo, useRef, useState, type SyntheticEvent } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState, type DragEvent, type KeyboardEvent, type SyntheticEvent } from "react"; import { apiClient } from "../api/client"; import type { AssistantConversationItem, @@ -553,6 +553,22 @@ function CopyOutlineIcon() { ); } +function QuestionGripIcon() { + return ( + + ); +} + export function AutoRunsHistoryPanel({ connection, modelOptions, @@ -605,6 +621,11 @@ export function AutoRunsHistoryPanel({ const [autoGenHistory, setAutoGenHistory] = useState([]); const [selectedAutogenGenerationId, setSelectedAutogenGenerationId] = useState(""); const [editableGeneratedQuestions, setEditableGeneratedQuestions] = useState([]); + const [generatedQuestionsBusy, setGeneratedQuestionsBusy] = useState(false); + const [editingQuestionIndex, setEditingQuestionIndex] = useState(null); + const [editingQuestionDraft, setEditingQuestionDraft] = useState(""); + const [draggingQuestionIndex, setDraggingQuestionIndex] = useState(null); + const [dragOverQuestionIndex, setDragOverQuestionIndex] = useState(null); const [activeAsyncJob, setActiveAsyncJob] = useState(null); const [postAnalysis, setPostAnalysis] = useState(null); const [autoGenBusy, setAutoGenBusy] = useState(false); @@ -674,6 +695,7 @@ export function AutoRunsHistoryPanel({ const initialLoadDoneRef = useRef(false); const asyncJobPollTimerRef = useRef(null); + const questionEditorRef = useRef(null); const isSavedUserSessionsMode = autoGenSettings.mode === "saved_user_sessions"; const selectedPersonality = useMemo( () => autogenPersonalities.find((item) => item.id === autoGenSettings.personalityId) ?? autogenPersonalities[0] ?? AUTOGEN_PERSONALITIES[0], @@ -1772,6 +1794,192 @@ export function AutoRunsHistoryPanel({ savedSessionQuestionDeleteModal.questionIndex ]); + const updateGeneratedQuestions = useCallback( + async (nextQuestions: string[], options?: { successLog?: string; revertQuestions?: string[] }) => { + const generationId = selectedAutogenGeneration?.generation_id ?? ""; + const revertQuestions = options?.revertQuestions ?? editableGeneratedQuestions; + + setEditableGeneratedQuestions(nextQuestions); + if (!generationId) { + return true; + } + + setGeneratedQuestionsBusy(true); + try { + const payload = await apiClient.updateAutoRunAutogenQuestions({ + generation_id: generationId, + questions: nextQuestions + }); + setAutoGenHistory((prev) => + prev.map((item) => (item.generation_id === generationId ? payload.generation : item)) + ); + setEditableGeneratedQuestions([...(payload.generation.questions ?? [])]); + if (options?.successLog) { + log(options.successLog); + } + return true; + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + setEditableGeneratedQuestions(revertQuestions); + setErrorText(`Вопросы к запуску: ${message}`); + log(`Autogen questions update error: ${message}`); + return false; + } finally { + setGeneratedQuestionsBusy(false); + } + }, + [editableGeneratedQuestions, log, selectedAutogenGeneration] + ); + + const startQuestionEdit = useCallback( + (questionIndex: number) => { + setEditingQuestionIndex(questionIndex); + setEditingQuestionDraft(editableGeneratedQuestions[questionIndex] ?? ""); + }, + [editableGeneratedQuestions] + ); + + const stopQuestionEdit = useCallback(() => { + setEditingQuestionIndex(null); + setEditingQuestionDraft(""); + }, []); + + const commitQuestionEdit = useCallback( + async (questionIndex: number | null) => { + if (questionIndex === null) { + return; + } + + const currentQuestion = editableGeneratedQuestions[questionIndex] ?? ""; + const nextText = editingQuestionDraft.trim(); + if (!nextText || nextText === currentQuestion) { + stopQuestionEdit(); + return; + } + + const nextQuestions = editableGeneratedQuestions.map((item, index) => (index === questionIndex ? nextText : item)); + const saved = await updateGeneratedQuestions(nextQuestions, { + successLog: `Список вопросов обновлен: ${selectedAutogenGeneration?.generation_id ?? "local"}`, + revertQuestions: editableGeneratedQuestions + }); + if (saved) { + stopQuestionEdit(); + } + }, + [editableGeneratedQuestions, editingQuestionDraft, selectedAutogenGeneration, stopQuestionEdit, updateGeneratedQuestions] + ); + + const handleQuestionEditorBlur = useCallback(() => { + void commitQuestionEdit(editingQuestionIndex); + }, [commitQuestionEdit, editingQuestionIndex]); + + const handleQuestionEditorKeyDown = useCallback( + (event: KeyboardEvent) => { + if (event.key === "Enter") { + event.preventDefault(); + void commitQuestionEdit(editingQuestionIndex); + return; + } + if (event.key === "Escape") { + event.preventDefault(); + stopQuestionEdit(); + } + }, + [commitQuestionEdit, editingQuestionIndex, stopQuestionEdit] + ); + + const handleAddGeneratedQuestion = useCallback(async () => { + const nextQuestions = [...editableGeneratedQuestions, "Новый вопрос"]; + const nextIndex = nextQuestions.length - 1; + const saved = await updateGeneratedQuestions(nextQuestions, { + successLog: `В список добавлен вопрос: ${selectedAutogenGeneration?.generation_id ?? "local"}`, + revertQuestions: editableGeneratedQuestions + }); + if (saved) { + setEditingQuestionIndex(nextIndex); + setEditingQuestionDraft(nextQuestions[nextIndex]); + } + }, [editableGeneratedQuestions, selectedAutogenGeneration, updateGeneratedQuestions]); + + const handleDeleteGeneratedQuestion = useCallback( + async (questionIndex: number) => { + if (editableGeneratedQuestions.length <= 1) { + setErrorText("В списке должен остаться хотя бы один вопрос."); + return; + } + + const nextQuestions = editableGeneratedQuestions.filter((_, index) => index !== questionIndex); + const saved = await updateGeneratedQuestions(nextQuestions, { + successLog: `Из списка удален вопрос: ${selectedAutogenGeneration?.generation_id ?? "local"}`, + revertQuestions: editableGeneratedQuestions + }); + if (!saved) { + return; + } + + setEditingQuestionIndex((prev) => { + if (prev === null) return prev; + if (prev === questionIndex) return null; + if (prev > questionIndex) return prev - 1; + return prev; + }); + setEditingQuestionDraft(""); + }, + [editableGeneratedQuestions, selectedAutogenGeneration, updateGeneratedQuestions] + ); + + const handleQuestionDragStart = useCallback( + (event: DragEvent, questionIndex: number) => { + if (generatedQuestionsBusy) { + event.preventDefault(); + return; + } + + setDraggingQuestionIndex(questionIndex); + setDragOverQuestionIndex(questionIndex); + event.dataTransfer.effectAllowed = "move"; + event.dataTransfer.setData("text/plain", String(questionIndex)); + }, + [generatedQuestionsBusy] + ); + + const handleQuestionDragOver = useCallback( + (event: DragEvent, questionIndex: number) => { + event.preventDefault(); + if (dragOverQuestionIndex !== questionIndex) { + setDragOverQuestionIndex(questionIndex); + } + event.dataTransfer.dropEffect = "move"; + }, + [dragOverQuestionIndex] + ); + + const handleQuestionDrop = useCallback( + async (event: DragEvent, questionIndex: number) => { + event.preventDefault(); + const fromIndex = draggingQuestionIndex; + setDragOverQuestionIndex(null); + setDraggingQuestionIndex(null); + if (fromIndex === null || fromIndex === questionIndex) { + return; + } + + const nextQuestions = [...editableGeneratedQuestions]; + const [movedQuestion] = nextQuestions.splice(fromIndex, 1); + nextQuestions.splice(questionIndex, 0, movedQuestion); + await updateGeneratedQuestions(nextQuestions, { + successLog: `Порядок вопросов обновлен: ${selectedAutogenGeneration?.generation_id ?? "local"}`, + revertQuestions: editableGeneratedQuestions + }); + }, + [draggingQuestionIndex, editableGeneratedQuestions, selectedAutogenGeneration, updateGeneratedQuestions] + ); + + const handleQuestionDragEnd = useCallback(() => { + setDraggingQuestionIndex(null); + setDragOverQuestionIndex(null); + }, []); + const openAutoGenDeleteModal = useCallback((item: AutoGenHistoryRecord) => { setAutoGenDeleteModal({ open: true, @@ -1905,10 +2113,27 @@ export function AutoRunsHistoryPanel({ useEffect(() => { if (!selectedAutogenGeneration) { setEditableGeneratedQuestions([]); + stopQuestionEdit(); + setDraggingQuestionIndex(null); + setDragOverQuestionIndex(null); return; } setEditableGeneratedQuestions([...selectedAutogenGeneration.questions]); - }, [selectedAutogenGeneration]); + stopQuestionEdit(); + setDraggingQuestionIndex(null); + setDragOverQuestionIndex(null); + }, [selectedAutogenGeneration, stopQuestionEdit]); + + useEffect(() => { + if (editingQuestionIndex === null) { + return; + } + const timer = window.setTimeout(() => { + questionEditorRef.current?.focus(); + questionEditorRef.current?.select(); + }, 0); + return () => window.clearTimeout(timer); + }, [editingQuestionIndex]); useEffect(() => { setLimitInput(String(filters.limit)); @@ -2403,6 +2628,9 @@ export function AutoRunsHistoryPanel({ + {false ? ( + <> + {/* generated questions editor */}
Вопросы к запуску: {editableGeneratedQuestions.length} @@ -2451,6 +2679,99 @@ export function AutoRunsHistoryPanel({ ? "Запуск воспроизводит сохраненную пользовательскую сессию как один последовательный multi-turn сценарий assistant_stage1." : "Запуск выполняет `assistant_stage1` eval по выбранному кейс-сету."}

+ + ) : ( + <> +
+
+ Вопросы к запуску: {editableGeneratedQuestions.length} +
+ {editableGeneratedQuestions.length === 0 ? ( +

+ {isSavedUserSessionsMode + ? "Список вопросов пуст. Сначала сохраните живую пользовательскую сессию." + : "Список вопросов пуст. Сгенерируйте пачку или добавьте вопрос вручную."} +

+ ) : ( +
+ {editableGeneratedQuestions.map((question, index) => ( +
handleQuestionDragOver(event, index)} + onDrop={(event) => void handleQuestionDrop(event, index)} + > + + {editingQuestionIndex === index ? ( + <> + setEditingQuestionDraft(event.target.value)} + onBlur={handleQuestionEditorBlur} + onKeyDown={handleQuestionEditorKeyDown} + placeholder="Текст вопроса" + disabled={generatedQuestionsBusy} + /> + + + ) : ( + + )} +
+ ))} +
+ )} + +
+ {isSavedUserSessionsMode ? ( +

Сохраненные пользовательские сессии

+ ) : ( +

Запуск выполняет `assistant_stage1` eval по выбранному кейс-сету.

+ )} + + )}
{autogenHistoryBusy ? ( diff --git a/llm_normalizer/frontend/src/styles.css b/llm_normalizer/frontend/src/styles.css index ee7c55c..71cfb24 100644 --- a/llm_normalizer/frontend/src/styles.css +++ b/llm_normalizer/frontend/src/styles.css @@ -1535,24 +1535,137 @@ button:disabled { .autoruns-generated-question-item { position: relative; - display: block; + display: grid; + grid-template-columns: 22px minmax(0, 1fr) auto; + align-items: start; gap: 8px; border: none; border-radius: 9px; background: rgb(var(--rgb-surface-focus)); - padding: 7px 30px 7px 8px; + padding: 7px 8px; font-size: 0.78rem; + transition: background 0.15s ease, outline-color 0.15s ease, opacity 0.15s ease; } -.autoruns-generated-question-item span { - display: block; +.autoruns-generated-question-item.drag-over { + outline: 1px solid rgba(var(--rgb-active), 0.75); +} + +.autoruns-generated-question-item.dragging { + opacity: 0.72; +} + +.autoruns-generated-question-item.editing { + background: rgb(var(--rgb-active)); + color: rgb(var(--rgb-active-text)); +} + +.autoruns-question-grip-btn { + width: 18px; + min-width: 18px; + height: 18px; + padding: 0; + border: none; + border-radius: 6px; + background: transparent; + color: var(--text-muted); + display: inline-flex; + align-items: center; + justify-content: center; + cursor: grab; + margin-top: 1px; +} + +.autoruns-question-grip-btn:hover:not(:disabled) { + color: rgb(var(--rgb-text-main)); + background: rgba(var(--rgb-background), 0.3); +} + +.autoruns-generated-question-item.editing .autoruns-question-grip-btn { + color: rgba(var(--rgb-active-text), 0.9); +} + +.autoruns-generated-question-item.editing .autoruns-question-grip-btn:hover:not(:disabled) { + color: rgb(var(--rgb-active-text)); + background: rgba(var(--rgb-active-text), 0.14); +} + +.autoruns-question-grip-btn:disabled { + cursor: default; + opacity: 0.45; +} + +.autoruns-question-grip-svg { + width: 14px; + height: 14px; + fill: currentColor; +} + +.autoruns-generated-question-text { + border: none; + background: transparent; + color: rgb(var(--rgb-text-main)); + padding: 0; + margin: 0; + text-align: left; + font: inherit; white-space: pre-wrap; + line-height: 1.4; + cursor: text; +} + +.autoruns-generated-question-text:hover { + color: rgb(var(--rgb-active)); +} + +.autoruns-generated-question-input { + width: 100%; + min-width: 0; + border: none; + border-radius: 8px; + background: rgba(var(--rgb-background), 0.55); + color: rgb(var(--rgb-text-main)); + padding: 6px 8px; + font: inherit; + line-height: 1.4; +} + +.autoruns-generated-question-input:focus { + outline: none; +} + +.autoruns-generated-question-item.editing .autoruns-generated-question-input { + background: rgba(var(--rgb-active-text), 0.14); + color: rgb(var(--rgb-active-text)); +} + +.autoruns-generated-question-item.editing .autoruns-generated-question-input::placeholder { + color: rgba(var(--rgb-active-text), 0.78); +} + +.autoruns-add-question-btn { + width: 100%; + min-height: 30px; + border-radius: 8px; + border: none; + background: rgb(var(--rgb-surface-focus)); + color: rgb(var(--rgb-text-main)); + font-size: 1.1rem; + font-weight: 700; + line-height: 1; +} + +.autoruns-add-question-btn:hover:not(:disabled) { + background: rgb(var(--rgb-active)); + color: rgb(var(--rgb-active-text)); +} + +.autoruns-add-question-btn:disabled { + opacity: 0.5; + cursor: default; } .autoruns-remove-question-btn { - position: absolute; - top: 6px; - right: 6px; flex: 0 0 auto; border: none; border-radius: 0; @@ -1570,6 +1683,7 @@ button:disabled { justify-content: center; box-shadow: none; transition: color 0.15s ease; + align-self: start; } .autoruns-remove-question-btn:hover { @@ -1578,6 +1692,14 @@ button:disabled { box-shadow: none; } +.autoruns-generated-question-item.editing .autoruns-remove-question-btn { + color: rgb(var(--rgb-active-text)); +} + +.autoruns-generated-question-item.editing .autoruns-remove-question-btn:hover { + color: rgba(var(--rgb-active-text), 0.82); +} + .autoruns-remove-question-btn:focus-visible { outline: none; }