From 60a4bef88c8694ec1770b81810524b8cbc24058a Mon Sep 17 00:00:00 2001 From: dctouch Date: Thu, 9 Apr 2026 16:51:12 +0300 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=94=D0=A0=D0=95=D0=A1=D0=9D=D0=AB?= =?UTF-8?q?=D0=99=20=D0=A0=D0=95=D0=96=D0=98=D0=9C=20-=20=D0=B0=D0=B2?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B0=D0=BD=20=D0=B8=D1=81=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D1=8F=20-=20=D0=B1=D0=B0=D0=B7=D0=B0=20+=20=D0=94=D0=98?= =?UTF-8?q?=D0=97=D0=90=D0=99=D0=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...{index-iFxz5cXp.css => index-BVc11Mnb.css} | 2 +- .../{index-BDtb8kxy.js => index-BXQlrB3i.js} | 4 +-- llm_normalizer/frontend/dist/index.html | 4 +-- .../src/components/AutoRunsHistoryPanel.tsx | 28 +++++++++++++------ llm_normalizer/frontend/src/styles.css | 21 ++++++++++++-- 5 files changed, 44 insertions(+), 15 deletions(-) rename llm_normalizer/frontend/dist/assets/{index-iFxz5cXp.css => index-BVc11Mnb.css} (54%) rename llm_normalizer/frontend/dist/assets/{index-BDtb8kxy.js => index-BXQlrB3i.js} (86%) diff --git a/llm_normalizer/frontend/dist/assets/index-iFxz5cXp.css b/llm_normalizer/frontend/dist/assets/index-BVc11Mnb.css similarity index 54% rename from llm_normalizer/frontend/dist/assets/index-iFxz5cXp.css rename to llm_normalizer/frontend/dist/assets/index-BVc11Mnb.css index 3921e16..9b1061f 100644 --- a/llm_normalizer/frontend/dist/assets/index-iFxz5cXp.css +++ b/llm_normalizer/frontend/dist/assets/index-BVc11Mnb.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-active: 228, 142, 92;--rgb-active-text: 18, 18, 18;--rgb-text-main: 240, 240, 240;--rgb-text-muted: 166, 166, 170;--rgb-danger: 255, 126, 126;--rgb-scrollbar-track: 31, 31, 36;--rgb-scrollbar-thumb: 74, 74, 82;--rgb-scrollbar-thumb-hover: 90, 90, 100;--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: 360px}*{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{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}.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-panel-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:8px}.assistant-copy-btn{background:transparent;border-color:transparent;color:var(--text-main);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}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}.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{max-height:420px;overflow:auto;display:grid;gap:10px;padding:4px;border:none;border-radius:var(--radius-md);background:rgb(var(--rgb-surface-horizontal))}.assistant-empty{padding:18px;text-align:center}.assistant-msg{border:none;border-radius:12px;background:rgb(var(--rgb-surface-main));padding:10px}.assistant-msg.user{border-color:transparent;background:rgb(var(--rgb-surface-focus))}.assistant-msg.assistant{border-color:transparent}.assistant-msg-head{display:flex;justify-content:space-between;gap:8px;margin-bottom:6px;font-size:.78rem;color:var(--text-muted)}.assistant-msg-body{white-space:pre-wrap;line-height:1.45;font-size:.9rem}.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:12px;display:grid;gap:10px}.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-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(--autoruns-col-width);width:var(--autoruns-col-width);height:100%;min-height:0;overflow:auto;border:none;border-radius:14px;background:rgb(var(--rgb-surface-main));padding:12px;scrollbar-gutter:stable}.autoruns-col:nth-child(3){flex-basis:440px;width:440px}.autoruns-col h3{margin:0 0 10px;font-size:.95rem}.autoruns-col h4{margin:12px 0 8px;font-size:.82rem;color:var(--text-muted)}.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}.autoruns-run-item.selected{border-color:var(--line-strong)}.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-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{border-color:var(--line-strong)}.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}.autoruns-msg header,.autoruns-msg footer{display:flex;justify-content:space-between;gap:8px;font-size:.74rem;color:var(--text-muted)}.autoruns-msg-head-actions{display:flex;align-items:center;gap:8px}.autoruns-msg p{margin:0;white-space:pre-wrap;line-height:1.35;font-size:.84rem}.autoruns-comment-icon{border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);border-radius:999px;min-width:28px;min-height:28px;padding:0 8px;line-height:1;box-shadow:none;transform:none}.autoruns-comment-icon:hover{border-color:var(--line-strong);box-shadow:none;transform:none}.autoruns-comment-icon.commented{border-color:var(--line-strong);color:var(--lime-main);background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.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}.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}.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-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}.autoruns-comment-item p{margin:0;white-space:pre-wrap;color:var(--text-muted);font-size:.79rem}.autoruns-comment-item.selected{border-color:var(--line-strong)}.autoruns-comment-head{display:flex;justify-content:space-between;gap:8px;font-size:.75rem}.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))}@media(max-width:1200px){:root{--autoruns-col-width: 340px}.metrics-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:920px){:root{--autoruns-col-width: 320px}.grid-two,.runtime-grid{grid-template-columns:1fr}.metrics-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.autoruns-form-grid,.autoruns-dialog-toolbar,.autoruns-stats-grid{grid-template-columns:1fr}}@media(max-width:640px){:root{--autoruns-col-width: 300px}.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-active: 228, 142, 92;--rgb-active-text: 18, 18, 18;--rgb-text-main: 240, 240, 240;--rgb-text-muted: 166, 166, 170;--rgb-danger: 255, 126, 126;--rgb-scrollbar-track: 31, 31, 36;--rgb-scrollbar-thumb: 74, 74, 82;--rgb-scrollbar-thumb-hover: 90, 90, 100;--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: 360px}*{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{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}.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-panel-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:8px}.assistant-copy-btn{background:transparent;border-color:transparent;color:var(--text-main);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}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}.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{max-height:420px;overflow:auto;display:grid;gap:10px;padding:4px;border:none;border-radius:var(--radius-md);background:rgb(var(--rgb-surface-horizontal))}.assistant-empty{padding:18px;text-align:center}.assistant-msg{border:none;border-radius:12px;background:rgb(var(--rgb-surface-main));padding:10px}.assistant-msg.user{border-color:transparent;background:rgb(var(--rgb-surface-focus))}.assistant-msg.assistant{border-color:transparent}.assistant-msg-head{display:flex;justify-content:space-between;gap:8px;margin-bottom:6px;font-size:.78rem;color:var(--text-muted)}.assistant-msg-body{white-space:pre-wrap;line-height:1.45;font-size:.9rem}.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:12px;display:grid;gap:10px}.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-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(--autoruns-col-width);width:var(--autoruns-col-width);height:100%;min-height:0;overflow:auto;border:none;border-radius:14px;background:rgb(var(--rgb-surface-main));padding:12px;scrollbar-gutter:stable}.autoruns-col:nth-child(3){flex-basis:440px;width:440px}.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}.autoruns-run-item.selected{border-color:var(--line-strong)}.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-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{border-color:var(--line-strong)}.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}.autoruns-msg header,.autoruns-msg footer{display:flex;justify-content:space-between;gap:8px;font-size:.74rem;color:var(--text-muted)}.autoruns-msg-head-actions{display:flex;align-items:center;gap:8px}.autoruns-msg p{margin:0;white-space:pre-wrap;line-height:1.35;font-size:.84rem}.autoruns-comment-icon{border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);border-radius:999px;min-width:28px;min-height:28px;padding:0 8px;line-height:1;box-shadow:none;transform:none}.autoruns-comment-icon:hover{border-color:var(--line-strong);box-shadow:none;transform:none}.autoruns-comment-icon.commented{border-color:var(--line-strong);color:var(--lime-main);background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.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}.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}.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-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}.autoruns-comment-item p{margin:0;white-space:pre-wrap;color:var(--text-muted);font-size:.79rem}.autoruns-comment-item.selected{border-color:var(--line-strong)}.autoruns-comment-head{display:flex;justify-content:space-between;gap:8px;font-size:.75rem}.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))}@media(max-width:1200px){:root{--autoruns-col-width: 340px}.metrics-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:920px){:root{--autoruns-col-width: 320px}.grid-two,.runtime-grid{grid-template-columns:1fr}.metrics-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.autoruns-form-grid,.autoruns-dialog-toolbar,.autoruns-stats-grid{grid-template-columns:1fr}}@media(max-width:640px){:root{--autoruns-col-width: 300px}.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/assets/index-BDtb8kxy.js b/llm_normalizer/frontend/dist/assets/index-BXQlrB3i.js similarity index 86% rename from llm_normalizer/frontend/dist/assets/index-BDtb8kxy.js rename to llm_normalizer/frontend/dist/assets/index-BXQlrB3i.js index d02bfbf..9a161bc 100644 --- a/llm_normalizer/frontend/dist/assets/index-BDtb8kxy.js +++ b/llm_normalizer/frontend/dist/assets/index-BXQlrB3i.js @@ -6,8 +6,8 @@ `).replace(cd,"")}function El(e,t,n){if(t=ra(t),ra(e)!==t&&n)throw Error(p(425))}function Pl(){}var Vs=null,Qs=null;function Ws(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Ks=typeof setTimeout=="function"?setTimeout:void 0,dd=typeof clearTimeout=="function"?clearTimeout:void 0,la=typeof Promise=="function"?Promise:void 0,fd=typeof queueMicrotask=="function"?queueMicrotask:typeof la<"u"?function(e){return la.resolve(null).then(e).catch(pd)}:Ks;function pd(e){setTimeout(function(){throw e})}function qs(e,t){var n=t,r=0;do{var l=n.nextSibling;if(e.removeChild(n),l&&l.nodeType===8)if(n=l.data,n==="/$"){if(r===0){e.removeChild(l),Tr(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=l}while(n);Tr(t)}function wn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function sa(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var sr=Math.random().toString(36).slice(2),Qt="__reactFiber$"+sr,Br="__reactProps$"+sr,Xt="__reactContainer$"+sr,Gs="__reactEvents$"+sr,md="__reactListeners$"+sr,hd="__reactHandles$"+sr;function Fn(e){var t=e[Qt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Xt]||n[Qt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=sa(e);e!==null;){if(n=e[Qt])return n;e=sa(e)}return t}e=n,n=e.parentNode}return null}function Hr(e){return e=e[Qt]||e[Xt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function or(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(p(33))}function Rl(e){return e[Br]||null}var Ys=[],ir=-1;function jn(e){return{current:e}}function je(e){0>ir||(e.current=Ys[ir],Ys[ir]=null,ir--)}function _e(e,t){ir++,Ys[ir]=e.current,e.current=t}var kn={},nt=jn(kn),dt=jn(!1),Un=kn;function ar(e,t){var n=e.type.contextTypes;if(!n)return kn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function ft(e){return e=e.childContextTypes,e!=null}function Tl(){je(dt),je(nt)}function oa(e,t,n){if(nt.current!==kn)throw Error(p(168));_e(nt,t),_e(dt,n)}function ia(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(p(108,de(e)||"Unknown",l));return T({},n,r)}function Ll(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||kn,Un=nt.current,_e(nt,e),_e(dt,dt.current),!0}function aa(e,t,n){var r=e.stateNode;if(!r)throw Error(p(169));n?(e=ia(e,t,Un),r.__reactInternalMemoizedMergedChildContext=e,je(dt),je(nt),_e(nt,e)):je(dt),_e(dt,n)}var Zt=null,zl=!1,Js=!1;function ua(e){Zt===null?Zt=[e]:Zt.push(e)}function vd(e){zl=!0,ua(e)}function Cn(){if(!Js&&Zt!==null){Js=!0;var e=0,t=ve;try{var n=Zt;for(ve=1;e>=i,l-=i,bt=1<<32-It(t)+l|n<q?(Ge=W,W=null):Ge=W.sibling;var fe=S(v,W,g[q],C);if(fe===null){W===null&&(W=Ge);break}e&&W&&fe.alternate===null&&t(v,W),f=s(fe,f,q),Q===null?$=fe:Q.sibling=fe,Q=fe,W=Ge}if(q===g.length)return n(v,W),Ce&&Bn(v,q),$;if(W===null){for(;qq?(Ge=W,W=null):Ge=W.sibling;var Mn=S(v,W,fe.value,C);if(Mn===null){W===null&&(W=Ge);break}e&&W&&Mn.alternate===null&&t(v,W),f=s(Mn,f,q),Q===null?$=Mn:Q.sibling=Mn,Q=Mn,W=Ge}if(fe.done)return n(v,W),Ce&&Bn(v,q),$;if(W===null){for(;!fe.done;q++,fe=g.next())fe=j(v,fe.value,C),fe!==null&&(f=s(fe,f,q),Q===null?$=fe:Q.sibling=fe,Q=fe);return Ce&&Bn(v,q),$}for(W=r(v,W);!fe.done;q++,fe=g.next())fe=M(W,v,q,fe.value,C),fe!==null&&(e&&fe.alternate!==null&&W.delete(fe.key===null?q:fe.key),f=s(fe,f,q),Q===null?$=fe:Q.sibling=fe,Q=fe);return e&&W.forEach(function(Jd){return t(v,Jd)}),Ce&&Bn(v,q),$}function Fe(v,f,g,C){if(typeof g=="object"&&g!==null&&g.type===$e&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case ze:e:{for(var $=g.key,Q=f;Q!==null;){if(Q.key===$){if($=g.type,$===$e){if(Q.tag===7){n(v,Q.sibling),f=l(Q,g.props.children),f.return=v,v=f;break e}}else if(Q.elementType===$||typeof $=="object"&&$!==null&&$.$$typeof===b&&ha($)===Q.type){n(v,Q.sibling),f=l(Q,g.props),f.ref=Vr(v,Q,g),f.return=v,v=f;break e}n(v,Q);break}else t(v,Q);Q=Q.sibling}g.type===$e?(f=Yn(g.props.children,v.mode,C,g.key),f.return=v,v=f):(C=os(g.type,g.key,g.props,null,v.mode,C),C.ref=Vr(v,f,g),C.return=v,v=C)}return i(v);case X:e:{for(Q=g.key;f!==null;){if(f.key===Q)if(f.tag===4&&f.stateNode.containerInfo===g.containerInfo&&f.stateNode.implementation===g.implementation){n(v,f.sibling),f=l(f,g.children||[]),f.return=v,v=f;break e}else{n(v,f);break}else t(v,f);f=f.sibling}f=Go(g,v.mode,C),f.return=v,v=f}return i(v);case b:return Q=g._init,Fe(v,f,Q(g._payload),C)}if(Mt(g))return A(v,f,g,C);if(V(g))return U(v,f,g,C);Il(v,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,f!==null&&f.tag===6?(n(v,f.sibling),f=l(f,g),f.return=v,v=f):(n(v,f),f=qo(g,v.mode,C),f.return=v,v=f),i(v)):n(v,f)}return Fe}var fr=va(!0),ga=va(!1),Al=jn(null),Fl=null,pr=null,no=null;function ro(){no=pr=Fl=null}function lo(e){var t=Al.current;je(Al),e._currentValue=t}function so(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 mr(e,t){Fl=e,no=pr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(pt=!0),e.firstContext=null)}function Rt(e){var t=e._currentValue;if(no!==e)if(e={context:e,memoizedValue:t,next:null},pr===null){if(Fl===null)throw Error(p(308));pr=e,Fl.dependencies={lanes:0,firstContext:e}}else pr=pr.next=e;return t}var Hn=null;function oo(e){Hn===null?Hn=[e]:Hn.push(e)}function ya(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,oo(t)):(n.next=l.next,l.next=n),t.interleaved=n,tn(e,r)}function tn(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 Nn=!1;function io(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xa(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 nn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function En(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(ue&2)!==0){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,tn(e,n)}return l=r.interleaved,l===null?(t.next=t,oo(r)):(t.next=l.next,l.next=t),r.interleaved=t,tn(e,n)}function Ul(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,Ss(e,n)}}function _a(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?l=s=i:s=s.next=i,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,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 $l(e,t,n,r){var l=e.updateQueue;Nn=!1;var s=l.firstBaseUpdate,i=l.lastBaseUpdate,u=l.shared.pending;if(u!==null){l.shared.pending=null;var d=u,y=d.next;d.next=null,i===null?s=y:i.next=y,i=d;var w=e.alternate;w!==null&&(w=w.updateQueue,u=w.lastBaseUpdate,u!==i&&(u===null?w.firstBaseUpdate=y:u.next=y,w.lastBaseUpdate=d))}if(s!==null){var j=l.baseState;i=0,w=y=d=null,u=s;do{var S=u.lane,M=u.eventTime;if((r&S)===S){w!==null&&(w=w.next={eventTime:M,lane:0,tag:u.tag,payload:u.payload,callback:u.callback,next:null});e:{var A=e,U=u;switch(S=t,M=n,U.tag){case 1:if(A=U.payload,typeof A=="function"){j=A.call(M,j,S);break e}j=A;break e;case 3:A.flags=A.flags&-65537|128;case 0:if(A=U.payload,S=typeof A=="function"?A.call(M,j,S):A,S==null)break e;j=T({},j,S);break e;case 2:Nn=!0}}u.callback!==null&&u.lane!==0&&(e.flags|=64,S=l.effects,S===null?l.effects=[u]:S.push(u))}else M={eventTime:M,lane:S,tag:u.tag,payload:u.payload,callback:u.callback,next:null},w===null?(y=w=M,d=j):w=w.next=M,i|=S;if(u=u.next,u===null){if(u=l.shared.pending,u===null)break;S=u,u=S.next,S.next=null,l.lastBaseUpdate=S,l.shared.pending=null}}while(!0);if(w===null&&(d=j),l.baseState=d,l.firstBaseUpdate=y,l.lastBaseUpdate=w,t=l.shared.interleaved,t!==null){l=t;do i|=l.lane,l=l.next;while(l!==t)}else s===null&&(l.shared.lanes=0);Wn|=i,e.lanes=i,e.memoizedState=j}}function Sa(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=po.transition;po.transition={};try{e(!1),t()}finally{ve=n,po.transition=r}}function $a(){return Tt().memoizedState}function _d(e,t,n){var r=Ln(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ba(e))Ha(t,n);else if(n=ya(e,t,n,r),n!==null){var l=it();Ht(n,e,r,l),Va(n,t,r)}}function Sd(e,t,n){var r=Ln(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ba(e))Ha(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var i=t.lastRenderedState,u=s(i,n);if(l.hasEagerState=!0,l.eagerState=u,At(u,i)){var d=t.interleaved;d===null?(l.next=l,oo(t)):(l.next=d.next,d.next=l),t.interleaved=l;return}}catch{}n=ya(e,t,l,r),n!==null&&(l=it(),Ht(n,e,r,l),Va(n,t,r))}}function Ba(e){var t=e.alternate;return e===Re||t!==null&&t===Re}function Ha(e,t){qr=Vl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Va(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ss(e,n)}}var Kl={readContext:Rt,useCallback:rt,useContext:rt,useEffect:rt,useImperativeHandle:rt,useInsertionEffect:rt,useLayoutEffect:rt,useMemo:rt,useReducer:rt,useRef:rt,useState:rt,useDebugValue:rt,useDeferredValue:rt,useTransition:rt,useMutableSource:rt,useSyncExternalStore:rt,useId:rt,unstable_isNewReconciler:!1},wd={readContext:Rt,useCallback:function(e,t){return Kt().memoizedState=[e,t===void 0?null:t],e},useContext:Rt,useEffect:za,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ql(4194308,4,Da.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ql(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ql(4,2,e,t)},useMemo:function(e,t){var n=Kt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Kt();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=_d.bind(null,Re,e),[r.memoizedState,e]},useRef:function(e){var t=Kt();return e={current:e},t.memoizedState=e},useState:Ta,useDebugValue:_o,useDeferredValue:function(e){return Kt().memoizedState=e},useTransition:function(){var e=Ta(!1),t=e[0];return e=xd.bind(null,e[1]),Kt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Re,l=Kt();if(Ce){if(n===void 0)throw Error(p(407));n=n()}else{if(n=t(),qe===null)throw Error(p(349));(Qn&30)!==0||Ca(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,za(Ea.bind(null,r,s,e),[e]),r.flags|=2048,Jr(9,Na.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Kt(),t=qe.identifierPrefix;if(Ce){var n=en,r=bt;n=(r&~(1<<32-It(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Gr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Qt]=t,e[Br]=r,uu(e,t,!1,!1),t.stateNode=e;e:{switch(i=mn(n,r),n){case"dialog":we("cancel",e),we("close",e),l=r;break;case"iframe":case"object":case"embed":we("load",e),l=r;break;case"video":case"audio":for(l=0;lxr&&(t.flags|=128,r=!0,Xr(s,!1),t.lanes=4194304)}else{if(!r)if(e=Bl(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Xr(s,!0),s.tail===null&&s.tailMode==="hidden"&&!i.alternate&&!Ce)return lt(t),null}else 2*Ae()-s.renderingStartTime>xr&&n!==1073741824&&(t.flags|=128,r=!0,Xr(s,!1),t.lanes=4194304);s.isBackwards?(i.sibling=t.child,t.child=i):(n=s.last,n!==null?n.sibling=i:t.child=i,s.last=i)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Ae(),t.sibling=null,n=Pe.current,_e(Pe,r?n&1|2:n&1),t):(lt(t),null);case 22:case 23:return Qo(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(jt&1073741824)!==0&&(lt(t),t.subtreeFlags&6&&(t.flags|=8192)):lt(t),null;case 24:return null;case 25:return null}throw Error(p(156,t.tag))}function Td(e,t){switch(Zs(t),t.tag){case 1:return ft(t.type)&&Tl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return hr(),je(dt),je(nt),fo(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return uo(t),null;case 13:if(je(Pe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(p(340));dr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return je(Pe),null;case 4:return hr(),null;case 10:return lo(t.type._context),null;case 22:case 23:return Qo(),null;case 24:return null;default:return null}}var Jl=!1,st=!1,Ld=typeof WeakSet=="function"?WeakSet:Set,I=null;function gr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Me(e,t,r)}else n.current=null}function zo(e,t,n){try{n()}catch(r){Me(e,t,r)}}var fu=!1;function zd(e,t){if(Vs=vl,e=Qi(),Ds(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 l=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var i=0,u=-1,d=-1,y=0,w=0,j=e,S=null;t:for(;;){for(var M;j!==n||l!==0&&j.nodeType!==3||(u=i+l),j!==s||r!==0&&j.nodeType!==3||(d=i+r),j.nodeType===3&&(i+=j.nodeValue.length),(M=j.firstChild)!==null;)S=j,j=M;for(;;){if(j===e)break t;if(S===n&&++y===l&&(u=i),S===s&&++w===r&&(d=i),(M=j.nextSibling)!==null)break;j=S,S=j.parentNode}j=M}n=u===-1||d===-1?null:{start:u,end:d}}else n=null}n=n||{start:0,end:0}}else n=null;for(Qs={focusedElem:e,selectionRange:n},vl=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var A=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(A!==null){var U=A.memoizedProps,Fe=A.memoizedState,v=t.stateNode,f=v.getSnapshotBeforeUpdate(t.elementType===t.type?U:Ut(t.type,U),Fe);v.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var g=t.stateNode.containerInfo;g.nodeType===1?g.textContent="":g.nodeType===9&&g.documentElement&&g.removeChild(g.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(p(163))}}catch(C){Me(t,t.return,C)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return A=fu,fu=!1,A}function Zr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var s=l.destroy;l.destroy=void 0,s!==void 0&&zo(t,n,s)}l=l.next}while(l!==r)}}function Xl(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 Oo(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 pu(e){var t=e.alternate;t!==null&&(e.alternate=null,pu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Qt],delete t[Br],delete t[Gs],delete t[md],delete t[hd])),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 mu(e){return e.tag===5||e.tag===3||e.tag===4}function hu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||mu(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 Mo(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=Pl));else if(r!==4&&(e=e.child,e!==null))for(Mo(e,t,n),e=e.sibling;e!==null;)Mo(e,t,n),e=e.sibling}function Do(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(Do(e,t,n),e=e.sibling;e!==null;)Do(e,t,n),e=e.sibling}var Xe=null,$t=!1;function Pn(e,t,n){for(n=n.child;n!==null;)vu(e,t,n),n=n.sibling}function vu(e,t,n){if(Vt&&typeof Vt.onCommitFiberUnmount=="function")try{Vt.onCommitFiberUnmount(cl,n)}catch{}switch(n.tag){case 5:st||gr(n,t);case 6:var r=Xe,l=$t;Xe=null,Pn(e,t,n),Xe=r,$t=l,Xe!==null&&($t?(e=Xe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Xe.removeChild(n.stateNode));break;case 18:Xe!==null&&($t?(e=Xe,n=n.stateNode,e.nodeType===8?qs(e.parentNode,n):e.nodeType===1&&qs(e,n),Tr(e)):qs(Xe,n.stateNode));break;case 4:r=Xe,l=$t,Xe=n.stateNode.containerInfo,$t=!0,Pn(e,t,n),Xe=r,$t=l;break;case 0:case 11:case 14:case 15:if(!st&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,i=s.destroy;s=s.tag,i!==void 0&&((s&2)!==0||(s&4)!==0)&&zo(n,t,i),l=l.next}while(l!==r)}Pn(e,t,n);break;case 1:if(!st&&(gr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(u){Me(n,t,u)}Pn(e,t,n);break;case 21:Pn(e,t,n);break;case 22:n.mode&1?(st=(r=st)||n.memoizedState!==null,Pn(e,t,n),st=r):Pn(e,t,n);break;default:Pn(e,t,n)}}function gu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Ld),t.forEach(function(r){var l=Bd.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Bt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~s}if(r=l,r=Ae()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Md(r/1960))-r,10e?16:e,Tn===null)var r=!1;else{if(e=Tn,Tn=null,ns=0,(ue&6)!==0)throw Error(p(331));var l=ue;for(ue|=4,I=e.current;I!==null;){var s=I,i=s.child;if((I.flags&16)!==0){var u=s.deletions;if(u!==null){for(var d=0;dAe()-Fo?qn(e,0):Ao|=n),ht(e,t)}function Tu(e,t){t===0&&((e.mode&1)===0?t=1:(t=fl,fl<<=1,(fl&130023424)===0&&(fl=4194304)));var n=it();e=tn(e,t),e!==null&&(Cr(e,t,n),ht(e,n))}function $d(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Tu(e,n)}function Bd(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(p(314))}r!==null&&r.delete(t),Tu(e,n)}var Lu;Lu=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||dt.current)pt=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return pt=!1,Pd(e,t,n);pt=(e.flags&131072)!==0}else pt=!1,Ce&&(t.flags&1048576)!==0&&ca(t,Ml,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Yl(e,t),e=t.pendingProps;var l=ar(t,nt.current);mr(t,n),l=ho(null,t,r,e,l,n);var s=vo();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ft(r)?(s=!0,Ll(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,io(t),l.updater=ql,t.stateNode=l,l._reactInternals=t,wo(t,r,e,n),t=No(null,t,r,!0,s,n)):(t.tag=0,Ce&&s&&Xs(t),ot(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Yl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Vd(r),e=Ut(r,e),l){case 0:t=Co(null,t,r,e,n);break e;case 1:t=ru(null,t,r,e,n);break e;case 11:t=Za(null,t,r,e,n);break e;case 14:t=ba(null,t,r,Ut(r.type,e),n);break e}throw Error(p(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ut(r,l),Co(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ut(r,l),ru(e,t,r,l,n);case 3:e:{if(lu(t),e===null)throw Error(p(387));r=t.pendingProps,s=t.memoizedState,l=s.element,xa(e,t),$l(t,r,null,n);var i=t.memoizedState;if(r=i.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=vr(Error(p(423)),t),t=su(e,t,r,n,l);break e}else if(r!==l){l=vr(Error(p(424)),t),t=su(e,t,r,n,l);break e}else for(wt=wn(t.stateNode.containerInfo.firstChild),St=t,Ce=!0,Ft=null,n=ga(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(dr(),r===l){t=rn(e,t,n);break e}ot(e,t,r,n)}t=t.child}return t;case 5:return wa(t),e===null&&eo(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,i=l.children,Ws(r,l)?i=null:s!==null&&Ws(r,s)&&(t.flags|=32),nu(e,t),ot(e,t,i,n),t.child;case 6:return e===null&&eo(t),null;case 13:return ou(e,t,n);case 4:return ao(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=fr(t,null,r,n):ot(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ut(r,l),Za(e,t,r,l,n);case 7:return ot(e,t,t.pendingProps,n),t.child;case 8:return ot(e,t,t.pendingProps.children,n),t.child;case 12:return ot(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,i=l.value,_e(Al,r._currentValue),r._currentValue=i,s!==null)if(At(s.value,i)){if(s.children===l.children&&!dt.current){t=rn(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var u=s.dependencies;if(u!==null){i=s.child;for(var d=u.firstContext;d!==null;){if(d.context===r){if(s.tag===1){d=nn(-1,n&-n),d.tag=2;var y=s.updateQueue;if(y!==null){y=y.shared;var w=y.pending;w===null?d.next=d:(d.next=w.next,w.next=d),y.pending=d}}s.lanes|=n,d=s.alternate,d!==null&&(d.lanes|=n),so(s.return,n,t),u.lanes|=n;break}d=d.next}}else if(s.tag===10)i=s.type===t.type?null:s.child;else if(s.tag===18){if(i=s.return,i===null)throw Error(p(341));i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),so(i,n,t),i=s.sibling}else i=s.child;if(i!==null)i.return=s;else for(i=s;i!==null;){if(i===t){i=null;break}if(s=i.sibling,s!==null){s.return=i.return,i=s;break}i=i.return}s=i}ot(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,mr(t,n),l=Rt(l),r=r(l),t.flags|=1,ot(e,t,r,n),t.child;case 14:return r=t.type,l=Ut(r,t.pendingProps),l=Ut(r.type,l),ba(e,t,r,l,n);case 15:return eu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ut(r,l),Yl(e,t),t.tag=1,ft(r)?(e=!0,Ll(t)):e=!1,mr(t,n),Wa(t,r,l),wo(t,r,l,n),No(null,t,r,!0,e,n);case 19:return au(e,t,n);case 22:return tu(e,t,n)}throw Error(p(156,t.tag))};function zu(e,t){return di(e,t)}function Hd(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 zt(e,t,n,r){return new Hd(e,t,n,r)}function Ko(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Vd(e){if(typeof e=="function")return Ko(e)?1:0;if(e!=null){if(e=e.$$typeof,e===he)return 11;if(e===Ye)return 14}return 2}function On(e,t){var n=e.alternate;return n===null?(n=zt(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 os(e,t,n,r,l,s){var i=2;if(r=e,typeof e=="function")Ko(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case $e:return Yn(n.children,l,s,t);case Ne:i=8,l|=8;break;case ut:return e=zt(12,n,t,l|2),e.elementType=ut,e.lanes=s,e;case He:return e=zt(13,n,t,l),e.elementType=He,e.lanes=s,e;case Oe:return e=zt(19,n,t,l),e.elementType=Oe,e.lanes=s,e;case pe:return is(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case be:i=10;break e;case gt:i=9;break e;case he:i=11;break e;case Ye:i=14;break e;case b:i=16,r=null;break e}throw Error(p(130,e==null?e:typeof e,""))}return t=zt(i,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function Yn(e,t,n,r){return e=zt(7,e,r,t),e.lanes=n,e}function is(e,t,n,r){return e=zt(22,e,r,t),e.elementType=pe,e.lanes=n,e.stateNode={isHidden:!1},e}function qo(e,t,n){return e=zt(6,e,null,t),e.lanes=n,e}function Go(e,t,n){return t=zt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Qd(e,t,n,r,l){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=_s(0),this.expirationTimes=_s(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_s(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Yo(e,t,n,r,l,s,i,u,d){return e=new Qd(e,t,n,u,d),t===1?(t=1,s===!0&&(t|=8)):t=0,s=zt(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},io(s),e}function Wd(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(h){console.error(h)}}return a(),ti.exports=rf(),ti.exports}var Ku;function sf(){if(Ku)return ms;Ku=1;var a=lf();return ms.createRoot=a.createRoot,ms.hydrateRoot=a.hydrateRoot,ms}var of=sf();const af=rc(of),uf="/api";async function Te(a,h){const p=await fetch(`${uf}${a}`,{...h,headers:{"Content-Type":"application/json",...h?.headers??{}}}),D=await p.json();if(!p.ok){const k=D.error?.message??"Ошибка запроса";throw new Error(k)}return D}const Ue={async listModels(a){return Te("/llm/models",{method:"POST",body:JSON.stringify({llmProvider:a.llmProvider,apiKey:a.apiKey,model:a.model,baseUrl:a.baseUrl})})},async testConnection(a){return Te("/llm/test-connection",{method:"POST",body:JSON.stringify({llmProvider:a.llmProvider,apiKey:a.apiKey,model:a.model,baseUrl:a.baseUrl})})},async normalize(a){return Te("/normalize",{method:"POST",body:JSON.stringify({llmProvider:a.connection.llmProvider,apiKey:a.connection.apiKey,model:a.connection.model,baseUrl:a.connection.baseUrl,temperature:a.connection.temperature,maxOutputTokens:a.connection.maxOutputTokens,promptVersion:a.promptVersion,systemPrompt:a.prompts.systemPrompt,developerPrompt:a.prompts.developerPrompt,domainPrompt:a.prompts.domainPrompt,fewShotExamples:a.prompts.fewShotExamples,userQuestion:a.query.userQuestion,context:{period_hint:a.query.periodHint??"",business_context:a.query.businessContext??"",expected_route:a.query.expectedRoute??""},saveAsTestCase:!!a.saveAsTestCase,useMock:!!a.useMock})})},async loadHistory(){return Te("/history")},async loadTrace(a){return Te(`/history/${a}`)},async loadPresets(){return Te("/presets")},async savePreset(a){return Te("/presets/save",{method:"POST",body:JSON.stringify(a)})},async runEval(a){return Te("/eval/run",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:a.connection.llmProvider,apiKey:a.connection.apiKey,model:a.connection.model,baseUrl:a.connection.baseUrl,temperature:a.connection.temperature,maxOutputTokens:a.connection.maxOutputTokens,promptVersion:a.promptVersion,systemPrompt:a.prompts.systemPrompt,developerPrompt:a.prompts.developerPrompt,domainPrompt:a.prompts.domainPrompt,fewShotExamples:a.prompts.fewShotExamples},caseIds:a.caseIds,useMock:!!a.useMock,mode:a.mode??"standard",caseSetFile:a.caseSetFile,rawQuestions:a.rawQuestions})})},async startRun(){return Te("/accounting-agent/v1/runs/start",{method:"POST",body:JSON.stringify({initiator:"ndc_operator",source:"gui"})})},async finishRun(a){return Te("/accounting-agent/v1/runs/finish",{method:"POST",body:JSON.stringify({runId:a,status:"DONE",source:"gui",reason:"Остановлено оператором из GUI"})})},async listRuns(){return Te("/accounting-agent/v1/runs")},async listResults(){return Te("/accounting-agent/v1/results")},async runTrace(a){return Te(`/accounting-agent/v1/trace/run/${a}`)},async sendAssistantMessage(a){return Te("/assistant/message",{method:"POST",body:JSON.stringify({session_id:a.sessionId??"",mode:"assistant",message:a.userMessage,user_message:a.userMessage,llmProvider:a.connection.llmProvider,apiKey:a.connection.apiKey,model:a.connection.model,baseUrl:a.connection.baseUrl,temperature:a.connection.temperature,maxOutputTokens:a.connection.maxOutputTokens,promptVersion:a.promptVersion??"address_query_runtime_v1",systemPrompt:a.prompts.systemPrompt,developerPrompt:a.prompts.developerPrompt,domainPrompt:a.prompts.domainPrompt,fewShotExamples:a.prompts.fewShotExamples,context:{period_hint:a.context?.periodHint??"",business_context:a.context?.businessContext??""},useMock:!!a.useMock})})},async loadAssistantSession(a){return Te(`/assistant/session/${a}`)},async loadAutoRunsHistory(a){const h=new URLSearchParams;a?.from&&h.set("from",a.from),a?.to&&h.set("to",a.to),a?.target&&h.set("target",a.target),a?.mode&&h.set("mode",a.mode),a?.use_mock&&h.set("use_mock",a.use_mock),a?.prompt_contains&&h.set("prompt_contains",a.prompt_contains),typeof a?.limit=="number"&&h.set("limit",String(a.limit)),typeof a?.scan_limit=="number"&&h.set("scan_limit",String(a.scan_limit));const p=h.toString();return Te(`/autoruns/history${p?`?${p}`:""}`)},async loadAutoRunDetail(a){return Te(`/autoruns/history/${encodeURIComponent(a)}`)},async loadAutoRunCaseDialog(a,h){return Te(`/autoruns/history/${encodeURIComponent(a)}/case/${encodeURIComponent(h)}/dialog`)},async loadAutoRunAnnotations(a){const h=new URLSearchParams;a?.run_id&&h.set("run_id",a.run_id),a?.case_id&&h.set("case_id",a.case_id),typeof a?.min_rating=="number"&&h.set("min_rating",String(a.min_rating)),a?.manual_case_decision&&h.set("manual_case_decision",a.manual_case_decision),typeof a?.limit=="number"&&h.set("limit",String(a.limit));const p=h.toString();return Te(`/autoruns/annotations${p?`?${p}`:""}`)},async saveAutoRunAnnotation(a){return Te("/autoruns/annotations",{method:"POST",body:JSON.stringify(a)})},async loadAutoRunPostAnalysis(a){const h=new URLSearchParams;a?.run_id&&h.set("run_id",a.run_id),typeof a?.limit_per_queue=="number"&&h.set("limit_per_queue",String(a.limit_per_queue)),typeof a?.annotation_limit=="number"&&h.set("annotation_limit",String(a.annotation_limit)),typeof a?.scan_limit=="number"&&h.set("scan_limit",String(a.scan_limit)),a?.from&&h.set("from",a.from),a?.to&&h.set("to",a.to),a?.target&&h.set("target",a.target),a?.mode&&h.set("mode",a.mode),a?.use_mock&&h.set("use_mock",a.use_mock),a?.prompt_contains&&h.set("prompt_contains",a.prompt_contains);const p=h.toString();return Te(`/autoruns/post-analysis${p?`?${p}`:""}`)},async loadAutoRunAutogenHistory(a){const h=new URLSearchParams;a?.mode&&h.set("mode",a.mode),typeof a?.limit=="number"&&h.set("limit",String(a.limit));const p=h.toString();return Te(`/autoruns/autogen/history${p?`?${p}`:""}`)},async generateAutoRunQuestions(a){return Te("/autoruns/autogen/generate",{method:"POST",body:JSON.stringify(a)})}};function at({value:a}){return o.jsx("pre",{className:"json-view",children:JSON.stringify(a??{},null,2)})}function on({title:a,subtitle:h,actions:p,className:D,hideHeader:k,children:F}){return o.jsxs("section",{className:D?`panel-frame ${D}`:"panel-frame",children:[k?null:o.jsxs("header",{className:"panel-header",children:[o.jsxs("div",{children:[o.jsx("h2",{children:a}),h?o.jsx("p",{children:h}):null]}),p?o.jsx("div",{className:"panel-actions",children:p}):null]}),o.jsx("div",{className:"panel-body",children:F})]})}const qu={fromLocal:"",toLocal:"",target:"all",mode:"all",useMock:"any",promptContains:"",limit:120},hs="needs_dialog_policy_fix",cf={mode:"codex_creative",count:24,domain:"",persistToEvalCases:!0,generatedBy:"manual_reviewer"};function df(a){const h=a.getFullYear(),p=String(a.getMonth()+1).padStart(2,"0"),D=String(a.getDate()).padStart(2,"0"),k=String(a.getHours()).padStart(2,"0"),F=String(a.getMinutes()).padStart(2,"0");return`${h}-${p}-${D}T${k}:${F}`}function Gu(){const a=new Date;return a.setDate(a.getDate()-14),df(a)}function vs(a){if(!a.trim())return;const h=Date.parse(a);if(Number.isFinite(h))return new Date(h).toISOString()}function Sr(a){if(!a)return"нет данных";const h=Date.parse(a);return Number.isFinite(h)?new Date(h).toLocaleString("ru-RU"):a}function ff(a,h){return h<=0?0:Math.max(0,Math.min(100,Number((a/h*100).toFixed(1))))}function ll(a){return typeof a!="number"?"нет данных":`${a.toFixed(1)}%`}function pf(a){return a==="assistant_stage1"?"assistant/s1":a==="assistant_stage2"?"assistant/s2":a==="assistant_p0"?"assistant/p0":a}function Yu(a){return a==="up"?"Рост":a==="down"?"Регресс":"Без изменений"}function mf(a,h){return a.find(p=>p.case_id===h)??null}function Ju(a){const h=Math.max(1,Math.min(5,Math.round(a)));return`${"●".repeat(h)}${"○".repeat(5-h)}`}function Xu(a){return a.length===0?o.jsx("p",{className:"muted",children:"Покрытие доменов пока не сформировано."}):o.jsx("div",{className:"autoruns-coverage-list",children:a.map(h=>{const p=ff(h.closed_cases,h.total_cases);return o.jsxs("div",{className:"autoruns-coverage-item",children:[o.jsxs("div",{className:"autoruns-coverage-head",children:[o.jsx("strong",{children:h.domain}),o.jsxs("span",{children:[h.closed_cases,"/",h.total_cases," (",p,"%)"]})]}),o.jsx("div",{className:"autoruns-coverage-bar",children:o.jsx("div",{style:{width:`${p}%`}})})]},h.domain)})})}function hf({connection:a,prompts:h,assistantPromptVersion:p,decompositionPromptVersion:D,showAssistantMode:k,showDecompositionMode:F,showProgressMode:H,onLog:Z}){const[N,te]=P.useState({...qu,fromLocal:Gu()}),[ce,z]=P.useState("settings"),[L,Le]=P.useState(null),[me,re]=P.useState(null),[G,De]=P.useState(null),[ye,We]=P.useState([]),[xe,ze]=P.useState("all"),[X,$e]=P.useState(null),[Ne,ut]=P.useState([]),[be,gt]=P.useState(""),[he,He]=P.useState(""),[Oe,Ye]=P.useState(""),[b,pe]=P.useState(cf),[R,V]=P.useState([]),[T,m]=P.useState(null),[_,Y]=P.useState(!1),[J,le]=P.useState(!1),[ee,de]=P.useState(!1),[ae,oe]=P.useState(!1),[ke,Ot]=P.useState(!1),[an,Gt]=P.useState(!1),[kt,Dn]=P.useState(!1),[un,ct]=P.useState(""),[ie,et]=P.useState({open:!1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:hs,annotationAuthor:"manual_reviewer",saving:!1,error:""}),Mt=P.useRef(!1),yt=L?.items.find(c=>c.run_id===he)??me?.run??null,xt=me?mf(me.cases,Oe):null,ge=ye.find(c=>c.annotation_id===be)??null,cn=G?.messages.find(c=>c.message_index===ie.messageIndex)??null,dn=P.useMemo(()=>{if(ye.length===0)return null;const c=ye.reduce((E,ne)=>E+ne.rating,0)/ye.length;return Number(c.toFixed(2))},[ye]),Jn=P.useMemo(()=>{const c=[...L?.items??[]];return he&&!c.some(E=>E.run_id===he)&&me?.run&&c.unshift(me.run),c},[L?.items,me?.run,he]),Se=P.useCallback(c=>{Z?.(`[autoruns] ${c}`)},[Z]),Ct=P.useCallback(async()=>{Dn(!0);try{const c=await Ue.loadAutoRunAnnotations({limit:800,manual_case_decision:xe});We(c.items),$e(c.manual_case_decision_schema??null),ut(c.available_manual_case_decisions??[]),gt(E=>c.items.length===0?"":c.items.some(ne=>ne.annotation_id===E)?E:c.items[0].annotation_id)}catch(c){Se(`Annotations load error: ${c instanceof Error?c.message:String(c)}`)}finally{Dn(!1)}},[xe,Se]),Nt=P.useCallback(async()=>{de(!0);try{const c=await Ue.loadAutoRunAutogenHistory({limit:180});V(c.items)}catch(c){Se(`Autogen history load error: ${c instanceof Error?c.message:String(c)}`)}finally{de(!1)}},[Se]),Je=P.useCallback(async()=>{le(!0);try{const c=await Ue.loadAutoRunPostAnalysis({run_id:he||void 0,limit_per_queue:30,annotation_limit:1500,from:vs(N.fromLocal),to:vs(N.toLocal),target:N.target,mode:N.mode,use_mock:N.useMock,prompt_contains:N.promptContains.trim()||void 0});m(c)}catch(c){Se(`Post-analysis load error: ${c instanceof Error?c.message:String(c)}`),m(null)}finally{le(!1)}},[N.fromLocal,N.mode,N.promptContains,N.target,N.toLocal,N.useMock,Se,he]),K=P.useCallback(async()=>{Y(!0),ct("");try{const c=[h.systemPrompt,h.developerPrompt,h.domainPrompt,h.schemaNotes,h.fewShotExamples].join(` -`).slice(0,900),E=await Ue.generateAutoRunQuestions({mode:b.mode,count:b.count,domain:b.domain.trim()||void 0,persist_to_eval_cases:b.persistToEvalCases,generated_by:b.generatedBy.trim()||void 0,context:{llm_provider:a.llmProvider,model:a.model,assistant_prompt_version:p,decomposition_prompt_version:D,prompt_fingerprint:c}});Se(`Generated ${E.generation.count} questions (${E.generation.mode}) id=${E.generation.generation_id}`+(E.generation.saved_case_set_file?` saved=${E.generation.saved_case_set_file}`:"")),await Nt()}catch(c){const E=c instanceof Error?c.message:String(c);ct(`Автогенерация: ${E}`),Se(`Autogen generate error: ${E}`)}finally{Y(!1)}},[p,b.count,b.domain,b.generatedBy,b.mode,b.persistToEvalCases,a.llmProvider,a.model,D,Nt,Se,h.developerPrompt,h.domainPrompt,h.fewShotExamples,h.schemaNotes,h.systemPrompt]),fn=P.useCallback(async(c,E)=>{Gt(!0);try{const ne=await Ue.loadAutoRunCaseDialog(c,E);De(ne)}catch(ne){const Ee=ne instanceof Error?ne.message:String(ne);ct(`Диалог кейса: ${Ee}`),De(null),Se(`Dialog load error for ${c}/${E}: ${Ee}`)}finally{Gt(!1)}},[Se]),tt=P.useCallback(async(c,E)=>{Ot(!0);try{const ne=await Ue.loadAutoRunDetail(c);re(ne);const Ee=(E&&ne.cases.some(Jt=>Jt.case_id===E)?E:"")||ne.cases[0]?.case_id||"";He(c),Ye(Ee),Ee?await fn(c,Ee):De(null)}catch(ne){const Ee=ne instanceof Error?ne.message:String(ne);ct(`Детализация прогона: ${Ee}`),re(null),De(null),Se(`Run detail load error for ${c}: ${Ee}`)}finally{Ot(!1)}},[fn,Se]),Yt=P.useCallback(async c=>{oe(!0),ct("");try{const E=await Ue.loadAutoRunsHistory({from:vs(N.fromLocal),to:vs(N.toLocal),target:N.target,mode:N.mode,use_mock:N.useMock,prompt_contains:N.promptContains.trim()||void 0,limit:N.limit});if(Le(E),E.items.length===0){He(""),Ye(""),re(null),De(null);return}const ne=c?.keepSelection??!0,Ee=c?.preferredRunId??"",Jt=c?.preferredCaseId??"",Xn=ne&&Ee&&E.items.some(Zn=>Zn.run_id===Ee)?Ee:E.items[0].run_id;await tt(Xn,ne?Jt:void 0),Je()}catch(E){const ne=E instanceof Error?E.message:String(E);ct(`История прогонов: ${ne}`),Se(`History load error: ${ne}`)}finally{oe(!1)}},[N.fromLocal,N.limit,N.mode,N.promptContains,N.target,N.toLocal,N.useMock,Je,tt,Se]),pn=P.useCallback(c=>{c.role==="assistant"&&et({open:!0,messageIndex:c.message_index,rating:c.annotation?.rating??3,comment:c.annotation?.comment??"",manualCaseDecision:c.annotation?.manual_case_decision??hs,annotationAuthor:c.annotation?.annotation_author??b.generatedBy,saving:!1,error:""})},[b.generatedBy]),Dt=P.useCallback(()=>{et(c=>c.saving?c:{open:!1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:hs,annotationAuthor:b.generatedBy,saving:!1,error:""})},[b.generatedBy]),mn=P.useCallback(async()=>{if(!(!he||!Oe||ie.messageIndex<0)){if(!ie.comment.trim()){et(c=>({...c,error:"Добавьте комментарий."}));return}et(c=>({...c,saving:!0,error:""}));try{await Ue.saveAutoRunAnnotation({run_id:he,case_id:Oe,message_index:ie.messageIndex,rating:ie.rating,comment:ie.comment.trim(),manual_case_decision:ie.manualCaseDecision,annotation_author:ie.annotationAuthor.trim()||void 0}),await Promise.all([tt(he,Oe),Ct(),Je()]),Dt()}catch(c){et(E=>({...E,saving:!1,error:c instanceof Error?c.message:String(c)}))}}},[Dt,ie.annotationAuthor,ie.comment,ie.manualCaseDecision,ie.messageIndex,ie.rating,Ct,Je,tt,Oe,he]),hn=P.useCallback(async c=>{gt(c.annotation_id),z("settings"),await tt(c.run_id,c.case_id),L?.items.some(E=>E.run_id===c.run_id)||ct("Комментарий относится к прогону вне текущего фильтра. Детали загружены напрямую.")},[L?.items,tt]);return P.useEffect(()=>{Mt.current||(Mt.current=!0,Yt({keepSelection:!1}),Nt(),Je())},[Nt,Yt,Je]),P.useEffect(()=>{Mt.current&&Ct()},[xe,Ct]),o.jsxs(on,{className:"autoruns-frame",title:"",hideHeader:!0,children:[o.jsxs("div",{className:"autoruns-columns",children:[o.jsxs("section",{className:"autoruns-col",children:[o.jsx("h3",{children:"Левая панель"}),o.jsxs("div",{className:"tab-row",children:[o.jsx("button",{type:"button",className:ce==="settings"?"tab active":"tab",onClick:()=>z("settings"),children:"Настройки"}),o.jsx("button",{type:"button",className:ce==="comments"?"tab active":"tab",onClick:()=>z("comments"),children:"Комментарии"})]}),ce==="settings"?o.jsxs(o.Fragment,{children:[o.jsx("h4",{children:"Настройки выборки"}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Дата с",o.jsx("input",{type:"datetime-local",value:N.fromLocal,onChange:c=>te(E=>({...E,fromLocal:c.target.value}))})]}),o.jsxs("label",{children:["Дата по",o.jsx("input",{type:"datetime-local",value:N.toLocal,onChange:c=>te(E=>({...E,toLocal:c.target.value}))})]}),o.jsxs("label",{children:["Целевой контур",o.jsxs("select",{value:N.target,onChange:c=>te(E=>({...E,target:c.target.value})),children:[o.jsx("option",{value:"all",children:"все"}),(L?.available.targets??[]).map(c=>o.jsx("option",{value:c,children:c},c))]})]}),o.jsxs("label",{children:["Режим",o.jsxs("select",{value:N.mode,onChange:c=>te(E=>({...E,mode:c.target.value})),children:[o.jsx("option",{value:"all",children:"все"}),(L?.available.modes??[]).map(c=>o.jsx("option",{value:c,children:c},c))]})]}),o.jsxs("label",{children:["Использовать mock",o.jsxs("select",{value:N.useMock,onChange:c=>te(E=>({...E,useMock:c.target.value})),children:[o.jsx("option",{value:"any",children:"любой"}),o.jsx("option",{value:"true",children:"да"}),o.jsx("option",{value:"false",children:"нет"})]})]}),o.jsxs("label",{children:["Лимит",o.jsx("input",{type:"number",min:1,max:500,value:N.limit,onChange:c=>te(E=>({...E,limit:Number(c.target.value||120)}))})]}),o.jsxs("label",{className:"full-width",children:["Версия промпта содержит",o.jsx("input",{value:N.promptContains,onChange:c=>te(E=>({...E,promptContains:c.target.value})),placeholder:"normalizer_v2_0_2 / address_query_runtime_v1",list:"autoruns-prompt-versions"})]})]}),o.jsx("datalist",{id:"autoruns-prompt-versions",children:(L?.available.prompt_versions??[]).map(c=>o.jsx("option",{value:c},c))}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:ae,onClick:()=>{Yt({keepSelection:!1})},children:ae?"Обновляю...":"Применить"}),o.jsx("button",{type:"button",className:"tab",onClick:()=>{te({...qu,fromLocal:Gu()}),ct("")},children:"Сбросить фильтры"})]}),o.jsx("h4",{children:"Контур генерации"}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Провайдер:"}),o.jsx("strong",{children:a.llmProvider})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Модель:"}),o.jsx("strong",{children:a.model||"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Промпт ассистента:"}),o.jsx("strong",{children:p})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Промпт декомпозиции:"}),o.jsx("strong",{children:D})]})]}),o.jsx("h4",{children:"Автогенерация вопросов"}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Режим генерации",o.jsxs("select",{value:b.mode,onChange:c=>pe(E=>({...E,mode:c.target.value})),children:[o.jsx("option",{value:"codex_creative",children:"codex_creative"}),o.jsx("option",{value:"qwen_seed",children:"qwen_seed"})]})]}),o.jsxs("label",{children:["Кол-во",o.jsx("input",{type:"number",min:1,max:200,value:b.count,onChange:c=>pe(E=>({...E,count:Math.max(1,Math.min(200,Number(c.target.value||24)))}))})]}),o.jsxs("label",{children:["Домен (опц.)",o.jsx("input",{value:b.domain,onChange:c=>pe(E=>({...E,domain:c.target.value})),placeholder:"vat / settlements / counterparties"})]}),o.jsxs("label",{children:["Кто генерирует",o.jsx("input",{value:b.generatedBy,onChange:c=>pe(E=>({...E,generatedBy:c.target.value})),placeholder:"manual_reviewer"})]}),o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:b.persistToEvalCases,onChange:c=>pe(E=>({...E,persistToEvalCases:c.target.checked}))}),"Сохранять кейс-сет в `eval_cases`"]})]}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:_,onClick:()=>{K()},children:_?"Генерирую...":"Сгенерировать пачку"}),o.jsx("button",{type:"button",className:"tab",disabled:ee,onClick:()=>{Nt()},children:ee?"Обновляю...":"Обновить историю"})]}),o.jsxs("div",{className:"autoruns-autogen-list",children:[ee?o.jsx("p",{className:"muted",children:"Загружаю историю автогенераций..."}):null,!ee&&R.length===0?o.jsx("p",{className:"muted",children:"История автогенераций пока пустая."}):null,R.slice(0,30).map(c=>o.jsxs("article",{className:"autoruns-autogen-item",children:[o.jsxs("header",{children:[o.jsx("strong",{children:Sr(c.created_at)}),o.jsx("span",{children:c.mode})]}),o.jsxs("div",{className:"autoruns-run-meta",children:["id=",c.generation_id," | count=",c.count]}),o.jsxs("div",{className:"autoruns-run-meta",children:["домен=",c.domain??"общий",c.generated_by?` | автор=${c.generated_by}`:""]}),c.saved_case_set_file?o.jsxs("div",{className:"autoruns-run-meta",children:["кейс-сет=",c.saved_case_set_file]}):null,(c.questions??[]).length>0?o.jsx("p",{children:c.questions[0]}):null]},c.generation_id))]}),o.jsxs("details",{className:"autoruns-prompt-details",children:[o.jsx("summary",{children:"Копия активного промпта (только чтение)"}),o.jsxs("label",{children:["Системный",o.jsx("textarea",{readOnly:!0,value:h.systemPrompt})]}),o.jsxs("label",{children:["Разработчика",o.jsx("textarea",{readOnly:!0,value:h.developerPrompt})]}),o.jsxs("label",{children:["Доменный",o.jsx("textarea",{readOnly:!0,value:h.domainPrompt})]}),o.jsxs("label",{children:["Заметки по схеме",o.jsx("textarea",{readOnly:!0,value:h.schemaNotes})]}),o.jsxs("label",{children:["Примеры few-shot",o.jsx("textarea",{readOnly:!0,value:h.fewShotExamples})]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("h4",{children:"Размеченные ответы"}),o.jsx("div",{className:"autoruns-form-grid",children:o.jsxs("label",{children:["Фильтр решений",o.jsxs("select",{value:xe,onChange:c=>ze(c.target.value),children:[o.jsx("option",{value:"all",children:"все"}),(Ne.length>0?Ne:X?.enum??[]).map(c=>o.jsx("option",{value:c,children:String(X?.labels?.[c]??c)},c))]})]})}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Комментариев"}),o.jsx("strong",{children:ye.length})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Средний рейтинг"}),o.jsx("strong",{children:dn===null?"нет данных":`${dn.toFixed(2)} / 5`})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Последний"}),o.jsx("strong",{children:ye.length>0?Sr(ye[0].updated_at):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Статус"}),o.jsx("strong",{children:kt?"обновляю":"готово"})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:kt,onClick:()=>{Ct()},children:kt?"Обновляю...":"Обновить список"}),o.jsx("button",{type:"button",className:"tab",disabled:J,onClick:()=>{Je()},children:J?"Идет пост-анализ...":"Обновить пост-анализ"})]}),o.jsxs("div",{className:"autoruns-comments-list",children:[kt?o.jsx("p",{className:"muted",children:"Загружаю комментарии..."}):null,!kt&&ye.length===0?o.jsx("p",{className:"muted",children:"Пока нет откомментированных ответов."}):null,ye.map(c=>o.jsxs("button",{type:"button",className:be===c.annotation_id?"autoruns-comment-item selected":"autoruns-comment-item",onClick:()=>{hn(c)},children:[o.jsxs("div",{className:"autoruns-comment-head",children:[o.jsx("strong",{children:Ju(c.rating)}),o.jsx("span",{children:Sr(c.updated_at)})]}),o.jsx("div",{className:"autoruns-run-meta",children:c.run_id}),o.jsxs("div",{className:"autoruns-run-meta",children:["case=",c.case_id," | msg=",c.message_index]}),o.jsxs("div",{className:"autoruns-run-meta",children:["decision=",c.manual_case_decision,c.annotation_author?` | author=${c.annotation_author}`:""]}),o.jsx("p",{children:c.comment})]},c.annotation_id))]}),ge?o.jsxs(o.Fragment,{children:[o.jsx("h4",{children:"Тех-контекст брака"}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"trace:"}),o.jsx("strong",{children:ge.technical_context.trace_id??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"reply_type:"}),o.jsx("strong",{children:ge.technical_context.reply_type??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"domain:"}),o.jsx("strong",{children:ge.technical_context.domain??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"query_class:"}),o.jsx("strong",{children:ge.technical_context.query_class??"нет данных"})]})]}),o.jsx("h4",{children:"JSON разбор"}),o.jsx(at,{value:{annotation_id:ge.annotation_id,run_id:ge.run_id,case_id:ge.case_id,message_index:ge.message_index,rating:ge.rating,comment:ge.comment,manual_case_decision:ge.manual_case_decision,annotation_author:ge.annotation_author,context:ge.context,technical_context:ge.technical_context,case_summary:ge.case_summary?{case_id:ge.case_summary.case_id,domain:ge.case_summary.domain,query_class:ge.case_summary.query_class,checks:ge.case_summary.checks,metric_subscores:ge.case_summary.metric_subscores}:null}})]}):null]}),un?o.jsx("p",{className:"error-text",children:un}):null]}),o.jsxs("section",{className:"autoruns-col",children:[o.jsx("h3",{children:"Выдача прогонов"}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Всего"}),o.jsx("strong",{children:L?.stats.runs_total??0})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Средний score"}),o.jsx("strong",{children:ll(L?.stats.avg_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Тренд"}),o.jsx("strong",{children:L?Yu(L.stats.trend):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Блокеры"}),o.jsx("strong",{children:L?.stats.blocking_runs??0})]})]}),o.jsxs("div",{className:"autoruns-run-list",children:[(L?.items??[]).map(c=>o.jsxs("button",{type:"button",className:he===c.run_id?"autoruns-run-item selected":"autoruns-run-item",onClick:()=>{tt(c.run_id)},children:[o.jsxs("div",{className:"autoruns-run-head",children:[o.jsx("strong",{children:Sr(c.run_timestamp)}),o.jsx("span",{children:pf(c.eval_target)})]}),o.jsx("div",{className:"autoruns-run-meta",children:c.run_id}),o.jsxs("div",{className:"autoruns-run-meta",children:["режим=",c.mode??"нет данных"," | mock=",String(c.use_mock)]}),c.llm_provider||c.model?o.jsxs("div",{className:"autoruns-run-meta",children:["llm=",c.llm_provider??"нет данных"," | модель=",c.model??"нет данных"]}):null,o.jsxs("div",{className:"autoruns-run-meta",children:["промпт=",c.prompt_version??"нет данных"]}),o.jsxs("div",{className:"autoruns-run-foot",children:[o.jsxs("span",{children:["оценка: ",ll(c.score_index)]}),o.jsxs("span",{children:["закрыто/открыто: ",c.closed_cases,"/",c.open_cases]})]}),o.jsxs("div",{className:"autoruns-run-foot",children:[o.jsxs("span",{children:["блокеры: ",c.blocking_failures]}),o.jsxs("span",{children:["качество: ",c.quality_failures]})]})]},c.run_id)),(L?.items.length??0)===0?o.jsx("p",{className:"muted",children:"За выбранный диапазон прогонов нет."}):null]})]}),o.jsxs("section",{className:"autoruns-col",children:[o.jsx("h3",{children:"Диалог прогона"}),o.jsxs("div",{className:"autoruns-dialog-toolbar",children:[o.jsxs("label",{children:["Прогон",o.jsx("select",{value:he,onChange:c=>{const E=c.target.value;tt(E)},children:Jn.map(c=>o.jsxs("option",{value:c.run_id,children:[Sr(c.run_timestamp)," | ",c.run_id]},c.run_id))})]}),o.jsxs("label",{children:["Кейс",o.jsx("select",{value:Oe,onChange:c=>{const E=c.target.value;Ye(E),he&&E&&fn(he,E)},children:(me?.cases??[]).map(c=>o.jsxs("option",{value:c.case_id,children:[c.case_id," | ",c.status]},c.case_id))})]})]}),o.jsx("div",{className:"autoruns-case-list",children:(me?.cases??[]).map(c=>o.jsxs("button",{type:"button",className:Oe===c.case_id?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{Ye(c.case_id),he&&fn(he,c.case_id)},children:[o.jsx("span",{children:c.case_id}),o.jsxs("span",{children:[c.status,c.commented_count>0?` | 💬${c.commented_count}`:""]})]},c.case_id))}),o.jsxs("div",{className:"autoruns-dialog-view",children:[an||ke?o.jsx("p",{className:"muted",children:"Загружаю диалог..."}):null,!an&&!ke&&(G?.messages.length??0)===0?o.jsx("p",{className:"muted",children:"Диалог для этого кейса не найден."}):null,(G?.messages??[]).map((c,E)=>{const ne=c.role==="assistant"?"assistant":"user";return o.jsxs("article",{className:`autoruns-msg ${ne}`,children:[o.jsxs("header",{children:[o.jsx("strong",{children:ne==="assistant"?"Система":"Модель/вопрос"}),o.jsxs("div",{className:"autoruns-msg-head-actions",children:[o.jsx("span",{children:c.created_at?Sr(c.created_at):"нет данных"}),ne==="assistant"?o.jsx("button",{type:"button",className:c.commented?"autoruns-comment-icon commented":"autoruns-comment-icon",onClick:()=>pn(c),title:"Комментировать ответ системы",children:"💬"}):null]})]}),o.jsx("p",{children:c.text}),ne==="assistant"&&c.annotation?o.jsxs("div",{className:"autoruns-msg-annotation",children:[o.jsx("strong",{children:Ju(c.annotation.rating)}),o.jsx("span",{children:c.annotation.comment}),o.jsxs("span",{className:"muted",children:[c.annotation.manual_case_decision,c.annotation.annotation_author?` | ${c.annotation.annotation_author}`:""]})]}):null,(c.trace_id||c.reply_type)&&o.jsxs("footer",{children:[c.trace_id?o.jsxs("span",{children:["trace=",c.trace_id]}):null,c.reply_type?o.jsxs("span",{children:["reply_type=",c.reply_type]}):null]})]},c.message_id??`${ne}-${E}`)})]})]}),k?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("h3",{children:"Режим ассистента"}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"источник:"}),o.jsx("strong",{children:G?.source??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"сессия:"}),o.jsx("strong",{children:G?.session_id??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"контур прогона:"}),o.jsx("strong",{children:yt?.eval_target??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"оценка прогона:"}),o.jsx("strong",{children:ll(yt?.score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"комментарии:"}),o.jsx("strong",{children:me?.annotations_summary?.total??0})]})]}),o.jsx("h4",{children:"Пакет режима ассистента"}),o.jsx(at,{value:G?.assistant_mode??{note:"assistant_mode недоступен"}}),o.jsx("h4",{style:{marginTop:12},children:"Проверки кейса"}),o.jsx(at,{value:xt?.checks??{note:"checks недоступен"}}),o.jsx("h4",{style:{marginTop:12},children:"Сабскор метрик"}),o.jsx(at,{value:xt?.metric_subscores??{note:"metric_subscores недоступен"}})]}):null,F?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("h3",{children:"Режим декомпозиции"}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"кейс:"}),o.jsx("strong",{children:xt?.case_id??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"домен:"}),o.jsx("strong",{children:xt?.domain??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"класс запроса:"}),o.jsx("strong",{children:xt?.query_class??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"trace:"}),o.jsx("strong",{children:xt?.trace_id??"нет данных"})]})]}),o.jsx("h4",{children:"Шаги декомпозиции"}),(G?.decomposition.length??0)>0?o.jsx("ol",{className:"autoruns-decomposition-list",children:(G?.decomposition??[]).map((c,E)=>o.jsx("li",{children:c},`${E}-${c.slice(0,24)}`))}):o.jsx("p",{className:"muted",children:"В логах кейса нет явной декомпозиции."})]}):null,H?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("h3",{children:"Прогресс / регресс"}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Последний score"}),o.jsx("strong",{children:ll(L?.stats.latest_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Предыдущий"}),o.jsx("strong",{children:ll(L?.stats.previous_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Тренд"}),o.jsx("strong",{children:L?Yu(L.stats.trend):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Пробелы качества"}),o.jsx("strong",{children:L?.stats.quality_gap_runs??0})]})]}),o.jsx("h4",{children:"Покрытие доменов (история)"}),Xu(L?.stats.domain_coverage??[]),o.jsx("h4",{style:{marginTop:14},children:"Покрытие доменов (выбранный прогон)"}),Xu(me?.coverage.domain_coverage??[]),o.jsx("h4",{style:{marginTop:14},children:"Очереди фиксов пост-анализа"}),J?o.jsx("p",{className:"muted",children:"Собираю пост-анализ..."}):null,J?null:o.jsx("div",{className:"autoruns-stats-grid",children:Object.entries(T?.post_analysis.stats.by_queue??{}).map(([c,E])=>o.jsxs("div",{children:[o.jsx("span",{children:c}),o.jsx("strong",{children:E})]},c))}),o.jsxs("div",{className:"autoruns-autogen-list",children:[(T?.post_analysis.recommended_regression_candidates??[]).slice(0,12).map(c=>o.jsxs("article",{className:"autoruns-autogen-item",children:[o.jsxs("header",{children:[o.jsx("strong",{children:c.manual_case_decision}),o.jsxs("span",{children:[c.rating,"/5"]})]}),o.jsxs("div",{className:"autoruns-run-meta",children:[c.domain??"неизвестно"," / ",c.query_class??"неизвестно"]}),o.jsx("p",{children:c.comment})]},c.annotation_id)),!J&&(T?.post_analysis.recommended_regression_candidates.length??0)===0?o.jsx("p",{className:"muted",children:"Рекомендованных кандидатов пока нет."}):null]})]}):null]}),ie.open?o.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:c=>{c.target===c.currentTarget&&Dt()},children:o.jsxs("div",{className:"autoruns-comment-modal",children:[o.jsx("h3",{children:"Комментарий к ответу системы"}),o.jsx("p",{className:"muted",children:"Оцените ответ по 5-балльной шкале и добавьте комментарий по браку."}),cn?o.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[o.jsx("summary",{children:"Ответ системы"}),o.jsx("p",{className:"autoruns-comment-quote",children:cn.text})]}):null,o.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа",children:[1,2,3,4,5].map(c=>o.jsx("button",{type:"button",className:ie.rating>=c?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>et(E=>({...E,rating:c})),disabled:ie.saving,"aria-label":`Оценка ${c}`,children:ie.rating>=c?"●":"○"},c))}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Решение по кейсу",o.jsx("select",{value:ie.manualCaseDecision,onChange:c=>et(E=>({...E,manualCaseDecision:c.target.value})),disabled:ie.saving,children:(Ne.length>0?Ne:X?.enum??[hs]).map(c=>o.jsx("option",{value:c,children:String(X?.labels?.[c]??c)},c))})]}),o.jsxs("label",{children:["Автор комментария",o.jsx("input",{value:ie.annotationAuthor,onChange:c=>et(E=>({...E,annotationAuthor:c.target.value})),placeholder:"manual_reviewer",disabled:ie.saving})]})]}),o.jsxs("label",{children:["Комментарий",o.jsx("textarea",{value:ie.comment,onChange:c=>et(E=>({...E,comment:c.target.value})),placeholder:"Почему ответ бракованный, что именно пошло не так, какие технические детали проверить.",rows:4,disabled:ie.saving})]}),ie.error?o.jsx("p",{className:"error-text",children:ie.error}):null,o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>{mn()},disabled:ie.saving,children:ie.saving?"Сохраняю...":"Готово"}),o.jsx("button",{type:"button",className:"tab",onClick:Dt,disabled:ie.saving,children:"Отмена"})]})]})}):null]})}const vf=/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json|debug_payload|technical_breakdown)\b/i,gf=[/\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 yf(a){try{return JSON.stringify(a,null,2)}catch{return String(a)}}function xf(a){const h=String(a??""),p=h.match(vf);return(p?h.slice(0,p.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(H=>H.trimEnd()).filter(H=>H.trim().length>0).filter(H=>!gf.some(Z=>Z.test(H))).join(` +`).slice(0,900),E=await Ue.generateAutoRunQuestions({mode:b.mode,count:b.count,domain:b.domain.trim()||void 0,persist_to_eval_cases:b.persistToEvalCases,generated_by:b.generatedBy.trim()||void 0,context:{llm_provider:a.llmProvider,model:a.model,assistant_prompt_version:p,decomposition_prompt_version:D,prompt_fingerprint:c}});Se(`Generated ${E.generation.count} questions (${E.generation.mode}) id=${E.generation.generation_id}`+(E.generation.saved_case_set_file?` saved=${E.generation.saved_case_set_file}`:"")),await Nt()}catch(c){const E=c instanceof Error?c.message:String(c);ct(`Автогенерация: ${E}`),Se(`Autogen generate error: ${E}`)}finally{Y(!1)}},[p,b.count,b.domain,b.generatedBy,b.mode,b.persistToEvalCases,a.llmProvider,a.model,D,Nt,Se,h.developerPrompt,h.domainPrompt,h.fewShotExamples,h.schemaNotes,h.systemPrompt]),fn=P.useCallback(async(c,E)=>{Gt(!0);try{const ne=await Ue.loadAutoRunCaseDialog(c,E);De(ne)}catch(ne){const Ee=ne instanceof Error?ne.message:String(ne);ct(`Диалог кейса: ${Ee}`),De(null),Se(`Dialog load error for ${c}/${E}: ${Ee}`)}finally{Gt(!1)}},[Se]),tt=P.useCallback(async(c,E)=>{Ot(!0);try{const ne=await Ue.loadAutoRunDetail(c);re(ne);const Ee=(E&&ne.cases.some(Jt=>Jt.case_id===E)?E:"")||ne.cases[0]?.case_id||"";He(c),Ye(Ee),Ee?await fn(c,Ee):De(null)}catch(ne){const Ee=ne instanceof Error?ne.message:String(ne);ct(`Детализация прогона: ${Ee}`),re(null),De(null),Se(`Run detail load error for ${c}: ${Ee}`)}finally{Ot(!1)}},[fn,Se]),Yt=P.useCallback(async c=>{oe(!0),ct("");try{const E=await Ue.loadAutoRunsHistory({from:vs(N.fromLocal),to:vs(N.toLocal),target:N.target,mode:N.mode,use_mock:N.useMock,prompt_contains:N.promptContains.trim()||void 0,limit:N.limit});if(Le(E),E.items.length===0){He(""),Ye(""),re(null),De(null);return}const ne=c?.keepSelection??!0,Ee=c?.preferredRunId??"",Jt=c?.preferredCaseId??"",Xn=ne&&Ee&&E.items.some(Zn=>Zn.run_id===Ee)?Ee:E.items[0].run_id;await tt(Xn,ne?Jt:void 0),Je()}catch(E){const ne=E instanceof Error?E.message:String(E);ct(`История прогонов: ${ne}`),Se(`History load error: ${ne}`)}finally{oe(!1)}},[N.fromLocal,N.limit,N.mode,N.promptContains,N.target,N.toLocal,N.useMock,Je,tt,Se]),pn=P.useCallback(c=>{c.role==="assistant"&&et({open:!0,messageIndex:c.message_index,rating:c.annotation?.rating??3,comment:c.annotation?.comment??"",manualCaseDecision:c.annotation?.manual_case_decision??hs,annotationAuthor:c.annotation?.annotation_author??b.generatedBy,saving:!1,error:""})},[b.generatedBy]),Dt=P.useCallback(()=>{et(c=>c.saving?c:{open:!1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:hs,annotationAuthor:b.generatedBy,saving:!1,error:""})},[b.generatedBy]),mn=P.useCallback(async()=>{if(!(!he||!Oe||ie.messageIndex<0)){if(!ie.comment.trim()){et(c=>({...c,error:"Добавьте комментарий."}));return}et(c=>({...c,saving:!0,error:""}));try{await Ue.saveAutoRunAnnotation({run_id:he,case_id:Oe,message_index:ie.messageIndex,rating:ie.rating,comment:ie.comment.trim(),manual_case_decision:ie.manualCaseDecision,annotation_author:ie.annotationAuthor.trim()||void 0}),await Promise.all([tt(he,Oe),Ct(),Je()]),Dt()}catch(c){et(E=>({...E,saving:!1,error:c instanceof Error?c.message:String(c)}))}}},[Dt,ie.annotationAuthor,ie.comment,ie.manualCaseDecision,ie.messageIndex,ie.rating,Ct,Je,tt,Oe,he]),hn=P.useCallback(async c=>{gt(c.annotation_id),z("settings"),await tt(c.run_id,c.case_id),L?.items.some(E=>E.run_id===c.run_id)||ct("Комментарий относится к прогону вне текущего фильтра. Детали загружены напрямую.")},[L?.items,tt]);return P.useEffect(()=>{Mt.current||(Mt.current=!0,Yt({keepSelection:!1}),Nt(),Je())},[Nt,Yt,Je]),P.useEffect(()=>{Mt.current&&Ct()},[xe,Ct]),o.jsxs(on,{className:"autoruns-frame",title:"",hideHeader:!0,children:[o.jsxs("div",{className:"autoruns-columns",children:[o.jsxs("section",{className:"autoruns-col",children:[o.jsxs("div",{className:"autoruns-col-header",children:[o.jsx("h3",{children:"Левая панель"}),o.jsxs("div",{className:"tab-row",children:[o.jsx("button",{type:"button",className:ce==="settings"?"tab active":"tab",onClick:()=>z("settings"),children:"Настройки"}),o.jsx("button",{type:"button",className:ce==="comments"?"tab active":"tab",onClick:()=>z("comments"),children:"Комментарии"})]})]}),ce==="settings"?o.jsxs(o.Fragment,{children:[o.jsx("h4",{children:"Настройки выборки"}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Дата с",o.jsx("input",{type:"datetime-local",value:N.fromLocal,onChange:c=>te(E=>({...E,fromLocal:c.target.value}))})]}),o.jsxs("label",{children:["Дата по",o.jsx("input",{type:"datetime-local",value:N.toLocal,onChange:c=>te(E=>({...E,toLocal:c.target.value}))})]}),o.jsxs("label",{children:["Целевой контур",o.jsxs("select",{value:N.target,onChange:c=>te(E=>({...E,target:c.target.value})),children:[o.jsx("option",{value:"all",children:"все"}),(L?.available.targets??[]).map(c=>o.jsx("option",{value:c,children:c},c))]})]}),o.jsxs("label",{children:["Режим",o.jsxs("select",{value:N.mode,onChange:c=>te(E=>({...E,mode:c.target.value})),children:[o.jsx("option",{value:"all",children:"все"}),(L?.available.modes??[]).map(c=>o.jsx("option",{value:c,children:c},c))]})]}),o.jsxs("label",{children:["Использовать mock",o.jsxs("select",{value:N.useMock,onChange:c=>te(E=>({...E,useMock:c.target.value})),children:[o.jsx("option",{value:"any",children:"любой"}),o.jsx("option",{value:"true",children:"да"}),o.jsx("option",{value:"false",children:"нет"})]})]}),o.jsxs("label",{children:["Лимит",o.jsx("input",{type:"number",min:1,max:500,value:N.limit,onChange:c=>te(E=>({...E,limit:Number(c.target.value||120)}))})]}),o.jsxs("label",{className:"full-width",children:["Версия промпта содержит",o.jsx("input",{value:N.promptContains,onChange:c=>te(E=>({...E,promptContains:c.target.value})),placeholder:"normalizer_v2_0_2 / address_query_runtime_v1",list:"autoruns-prompt-versions"})]})]}),o.jsx("datalist",{id:"autoruns-prompt-versions",children:(L?.available.prompt_versions??[]).map(c=>o.jsx("option",{value:c},c))}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:ae,onClick:()=>{Yt({keepSelection:!1})},children:ae?"Обновляю...":"Применить"}),o.jsx("button",{type:"button",className:"tab",onClick:()=>{te({...qu,fromLocal:Gu()}),ct("")},children:"Сбросить фильтры"})]}),o.jsx("h4",{children:"Контур генерации"}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Провайдер:"}),o.jsx("strong",{children:a.llmProvider})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Модель:"}),o.jsx("strong",{children:a.model||"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Промпт ассистента:"}),o.jsx("strong",{children:p})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Промпт декомпозиции:"}),o.jsx("strong",{children:D})]})]}),o.jsx("h4",{children:"Автогенерация вопросов"}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Режим генерации",o.jsxs("select",{value:b.mode,onChange:c=>pe(E=>({...E,mode:c.target.value})),children:[o.jsx("option",{value:"codex_creative",children:"codex_creative"}),o.jsx("option",{value:"qwen_seed",children:"qwen_seed"})]})]}),o.jsxs("label",{children:["Кол-во",o.jsx("input",{type:"number",min:1,max:200,value:b.count,onChange:c=>pe(E=>({...E,count:Math.max(1,Math.min(200,Number(c.target.value||24)))}))})]}),o.jsxs("label",{children:["Домен (опц.)",o.jsx("input",{value:b.domain,onChange:c=>pe(E=>({...E,domain:c.target.value})),placeholder:"vat / settlements / counterparties"})]}),o.jsxs("label",{children:["Кто генерирует",o.jsx("input",{value:b.generatedBy,onChange:c=>pe(E=>({...E,generatedBy:c.target.value})),placeholder:"manual_reviewer"})]}),o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:b.persistToEvalCases,onChange:c=>pe(E=>({...E,persistToEvalCases:c.target.checked}))}),"Сохранять кейс-сет в `eval_cases`"]})]}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:_,onClick:()=>{K()},children:_?"Генерирую...":"Сгенерировать пачку"}),o.jsx("button",{type:"button",className:"tab",disabled:ee,onClick:()=>{Nt()},children:ee?"Обновляю...":"Обновить историю"})]}),o.jsxs("div",{className:"autoruns-autogen-list",children:[ee?o.jsx("p",{className:"muted",children:"Загружаю историю автогенераций..."}):null,!ee&&R.length===0?o.jsx("p",{className:"muted",children:"История автогенераций пока пустая."}):null,R.slice(0,30).map(c=>o.jsxs("article",{className:"autoruns-autogen-item",children:[o.jsxs("header",{children:[o.jsx("strong",{children:Sr(c.created_at)}),o.jsx("span",{children:c.mode})]}),o.jsxs("div",{className:"autoruns-run-meta",children:["id=",c.generation_id," | count=",c.count]}),o.jsxs("div",{className:"autoruns-run-meta",children:["домен=",c.domain??"общий",c.generated_by?` | автор=${c.generated_by}`:""]}),c.saved_case_set_file?o.jsxs("div",{className:"autoruns-run-meta",children:["кейс-сет=",c.saved_case_set_file]}):null,(c.questions??[]).length>0?o.jsx("p",{children:c.questions[0]}):null]},c.generation_id))]}),o.jsxs("details",{className:"autoruns-prompt-details",children:[o.jsx("summary",{children:"Копия активного промпта (только чтение)"}),o.jsxs("label",{children:["Системный",o.jsx("textarea",{readOnly:!0,value:h.systemPrompt})]}),o.jsxs("label",{children:["Разработчика",o.jsx("textarea",{readOnly:!0,value:h.developerPrompt})]}),o.jsxs("label",{children:["Доменный",o.jsx("textarea",{readOnly:!0,value:h.domainPrompt})]}),o.jsxs("label",{children:["Заметки по схеме",o.jsx("textarea",{readOnly:!0,value:h.schemaNotes})]}),o.jsxs("label",{children:["Примеры few-shot",o.jsx("textarea",{readOnly:!0,value:h.fewShotExamples})]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("h4",{children:"Размеченные ответы"}),o.jsx("div",{className:"autoruns-form-grid",children:o.jsxs("label",{children:["Фильтр решений",o.jsxs("select",{value:xe,onChange:c=>ze(c.target.value),children:[o.jsx("option",{value:"all",children:"все"}),(Ne.length>0?Ne:X?.enum??[]).map(c=>o.jsx("option",{value:c,children:String(X?.labels?.[c]??c)},c))]})]})}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Комментариев"}),o.jsx("strong",{children:ye.length})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Средний рейтинг"}),o.jsx("strong",{children:dn===null?"нет данных":`${dn.toFixed(2)} / 5`})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Последний"}),o.jsx("strong",{children:ye.length>0?Sr(ye[0].updated_at):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Статус"}),o.jsx("strong",{children:kt?"обновляю":"готово"})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:kt,onClick:()=>{Ct()},children:kt?"Обновляю...":"Обновить список"}),o.jsx("button",{type:"button",className:"tab",disabled:J,onClick:()=>{Je()},children:J?"Идет пост-анализ...":"Обновить пост-анализ"})]}),o.jsxs("div",{className:"autoruns-comments-list",children:[kt?o.jsx("p",{className:"muted",children:"Загружаю комментарии..."}):null,!kt&&ye.length===0?o.jsx("p",{className:"muted",children:"Пока нет откомментированных ответов."}):null,ye.map(c=>o.jsxs("button",{type:"button",className:be===c.annotation_id?"autoruns-comment-item selected":"autoruns-comment-item",onClick:()=>{hn(c)},children:[o.jsxs("div",{className:"autoruns-comment-head",children:[o.jsx("strong",{children:Ju(c.rating)}),o.jsx("span",{children:Sr(c.updated_at)})]}),o.jsx("div",{className:"autoruns-run-meta",children:c.run_id}),o.jsxs("div",{className:"autoruns-run-meta",children:["case=",c.case_id," | msg=",c.message_index]}),o.jsxs("div",{className:"autoruns-run-meta",children:["decision=",c.manual_case_decision,c.annotation_author?` | author=${c.annotation_author}`:""]}),o.jsx("p",{children:c.comment})]},c.annotation_id))]}),ge?o.jsxs(o.Fragment,{children:[o.jsx("h4",{children:"Тех-контекст брака"}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"trace:"}),o.jsx("strong",{children:ge.technical_context.trace_id??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"reply_type:"}),o.jsx("strong",{children:ge.technical_context.reply_type??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"domain:"}),o.jsx("strong",{children:ge.technical_context.domain??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"query_class:"}),o.jsx("strong",{children:ge.technical_context.query_class??"нет данных"})]})]}),o.jsx("h4",{children:"JSON разбор"}),o.jsx(at,{value:{annotation_id:ge.annotation_id,run_id:ge.run_id,case_id:ge.case_id,message_index:ge.message_index,rating:ge.rating,comment:ge.comment,manual_case_decision:ge.manual_case_decision,annotation_author:ge.annotation_author,context:ge.context,technical_context:ge.technical_context,case_summary:ge.case_summary?{case_id:ge.case_summary.case_id,domain:ge.case_summary.domain,query_class:ge.case_summary.query_class,checks:ge.case_summary.checks,metric_subscores:ge.case_summary.metric_subscores}:null}})]}):null]}),un?o.jsx("p",{className:"error-text",children:un}):null]}),o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Выдача прогонов"})}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Всего"}),o.jsx("strong",{children:L?.stats.runs_total??0})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Средний score"}),o.jsx("strong",{children:ll(L?.stats.avg_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Тренд"}),o.jsx("strong",{children:L?Yu(L.stats.trend):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Блокеры"}),o.jsx("strong",{children:L?.stats.blocking_runs??0})]})]}),o.jsxs("div",{className:"autoruns-run-list",children:[(L?.items??[]).map(c=>o.jsxs("button",{type:"button",className:he===c.run_id?"autoruns-run-item selected":"autoruns-run-item",onClick:()=>{tt(c.run_id)},children:[o.jsxs("div",{className:"autoruns-run-head",children:[o.jsx("strong",{children:Sr(c.run_timestamp)}),o.jsx("span",{children:pf(c.eval_target)})]}),o.jsx("div",{className:"autoruns-run-meta",children:c.run_id}),o.jsxs("div",{className:"autoruns-run-meta",children:["режим=",c.mode??"нет данных"," | mock=",String(c.use_mock)]}),c.llm_provider||c.model?o.jsxs("div",{className:"autoruns-run-meta",children:["llm=",c.llm_provider??"нет данных"," | модель=",c.model??"нет данных"]}):null,o.jsxs("div",{className:"autoruns-run-meta",children:["промпт=",c.prompt_version??"нет данных"]}),o.jsxs("div",{className:"autoruns-run-foot",children:[o.jsxs("span",{children:["оценка: ",ll(c.score_index)]}),o.jsxs("span",{children:["закрыто/открыто: ",c.closed_cases,"/",c.open_cases]})]}),o.jsxs("div",{className:"autoruns-run-foot",children:[o.jsxs("span",{children:["блокеры: ",c.blocking_failures]}),o.jsxs("span",{children:["качество: ",c.quality_failures]})]})]},c.run_id)),(L?.items.length??0)===0?o.jsx("p",{className:"muted",children:"За выбранный диапазон прогонов нет."}):null]})]}),o.jsxs("section",{className:"autoruns-col",children:[o.jsxs("div",{className:"autoruns-col-header",children:[o.jsx("h3",{children:"Диалог прогона"}),o.jsxs("div",{className:"autoruns-dialog-toolbar",children:[o.jsxs("label",{children:["Прогон",o.jsx("select",{value:he,onChange:c=>{const E=c.target.value;tt(E)},children:Jn.map(c=>o.jsxs("option",{value:c.run_id,children:[Sr(c.run_timestamp)," | ",c.run_id]},c.run_id))})]}),o.jsxs("label",{children:["Кейс",o.jsx("select",{value:Oe,onChange:c=>{const E=c.target.value;Ye(E),he&&E&&fn(he,E)},children:(me?.cases??[]).map(c=>o.jsxs("option",{value:c.case_id,children:[c.case_id," | ",c.status]},c.case_id))})]})]})]}),o.jsx("div",{className:"autoruns-case-list",children:(me?.cases??[]).map(c=>o.jsxs("button",{type:"button",className:Oe===c.case_id?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{Ye(c.case_id),he&&fn(he,c.case_id)},children:[o.jsx("span",{children:c.case_id}),o.jsxs("span",{children:[c.status,c.commented_count>0?` | 💬${c.commented_count}`:""]})]},c.case_id))}),o.jsxs("div",{className:"autoruns-dialog-view",children:[an||ke?o.jsx("p",{className:"muted",children:"Загружаю диалог..."}):null,!an&&!ke&&(G?.messages.length??0)===0?o.jsx("p",{className:"muted",children:"Диалог для этого кейса не найден."}):null,(G?.messages??[]).map((c,E)=>{const ne=c.role==="assistant"?"assistant":"user";return o.jsxs("article",{className:`autoruns-msg ${ne}`,children:[o.jsxs("header",{children:[o.jsx("strong",{children:ne==="assistant"?"Система":"Модель/вопрос"}),o.jsxs("div",{className:"autoruns-msg-head-actions",children:[o.jsx("span",{children:c.created_at?Sr(c.created_at):"нет данных"}),ne==="assistant"?o.jsx("button",{type:"button",className:c.commented?"autoruns-comment-icon commented":"autoruns-comment-icon",onClick:()=>pn(c),title:"Комментировать ответ системы",children:"💬"}):null]})]}),o.jsx("p",{children:c.text}),ne==="assistant"&&c.annotation?o.jsxs("div",{className:"autoruns-msg-annotation",children:[o.jsx("strong",{children:Ju(c.annotation.rating)}),o.jsx("span",{children:c.annotation.comment}),o.jsxs("span",{className:"muted",children:[c.annotation.manual_case_decision,c.annotation.annotation_author?` | ${c.annotation.annotation_author}`:""]})]}):null,(c.trace_id||c.reply_type)&&o.jsxs("footer",{children:[c.trace_id?o.jsxs("span",{children:["trace=",c.trace_id]}):null,c.reply_type?o.jsxs("span",{children:["reply_type=",c.reply_type]}):null]})]},c.message_id??`${ne}-${E}`)})]})]}),k?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Режим ассистента"})}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"источник:"}),o.jsx("strong",{children:G?.source??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"сессия:"}),o.jsx("strong",{children:G?.session_id??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"контур прогона:"}),o.jsx("strong",{children:yt?.eval_target??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"оценка прогона:"}),o.jsx("strong",{children:ll(yt?.score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"комментарии:"}),o.jsx("strong",{children:me?.annotations_summary?.total??0})]})]}),o.jsx("h4",{children:"Пакет режима ассистента"}),o.jsx(at,{value:G?.assistant_mode??{note:"assistant_mode недоступен"}}),o.jsx("h4",{style:{marginTop:12},children:"Проверки кейса"}),o.jsx(at,{value:xt?.checks??{note:"checks недоступен"}}),o.jsx("h4",{style:{marginTop:12},children:"Сабскор метрик"}),o.jsx(at,{value:xt?.metric_subscores??{note:"metric_subscores недоступен"}})]}):null,F?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Режим декомпозиции"})}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"кейс:"}),o.jsx("strong",{children:xt?.case_id??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"домен:"}),o.jsx("strong",{children:xt?.domain??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"класс запроса:"}),o.jsx("strong",{children:xt?.query_class??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"trace:"}),o.jsx("strong",{children:xt?.trace_id??"нет данных"})]})]}),o.jsx("h4",{children:"Шаги декомпозиции"}),(G?.decomposition.length??0)>0?o.jsx("ol",{className:"autoruns-decomposition-list",children:(G?.decomposition??[]).map((c,E)=>o.jsx("li",{children:c},`${E}-${c.slice(0,24)}`))}):o.jsx("p",{className:"muted",children:"В логах кейса нет явной декомпозиции."})]}):null,H?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Прогресс / регресс"})}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Последний score"}),o.jsx("strong",{children:ll(L?.stats.latest_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Предыдущий"}),o.jsx("strong",{children:ll(L?.stats.previous_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Тренд"}),o.jsx("strong",{children:L?Yu(L.stats.trend):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Пробелы качества"}),o.jsx("strong",{children:L?.stats.quality_gap_runs??0})]})]}),o.jsx("h4",{children:"Покрытие доменов (история)"}),Xu(L?.stats.domain_coverage??[]),o.jsx("h4",{style:{marginTop:14},children:"Покрытие доменов (выбранный прогон)"}),Xu(me?.coverage.domain_coverage??[]),o.jsx("h4",{style:{marginTop:14},children:"Очереди фиксов пост-анализа"}),J?o.jsx("p",{className:"muted",children:"Собираю пост-анализ..."}):null,J?null:o.jsx("div",{className:"autoruns-stats-grid",children:Object.entries(T?.post_analysis.stats.by_queue??{}).map(([c,E])=>o.jsxs("div",{children:[o.jsx("span",{children:c}),o.jsx("strong",{children:E})]},c))}),o.jsxs("div",{className:"autoruns-autogen-list",children:[(T?.post_analysis.recommended_regression_candidates??[]).slice(0,12).map(c=>o.jsxs("article",{className:"autoruns-autogen-item",children:[o.jsxs("header",{children:[o.jsx("strong",{children:c.manual_case_decision}),o.jsxs("span",{children:[c.rating,"/5"]})]}),o.jsxs("div",{className:"autoruns-run-meta",children:[c.domain??"неизвестно"," / ",c.query_class??"неизвестно"]}),o.jsx("p",{children:c.comment})]},c.annotation_id)),!J&&(T?.post_analysis.recommended_regression_candidates.length??0)===0?o.jsx("p",{className:"muted",children:"Рекомендованных кандидатов пока нет."}):null]})]}):null]}),ie.open?o.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:c=>{c.target===c.currentTarget&&Dt()},children:o.jsxs("div",{className:"autoruns-comment-modal",children:[o.jsx("h3",{children:"Комментарий к ответу системы"}),o.jsx("p",{className:"muted",children:"Оцените ответ по 5-балльной шкале и добавьте комментарий по браку."}),cn?o.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[o.jsx("summary",{children:"Ответ системы"}),o.jsx("p",{className:"autoruns-comment-quote",children:cn.text})]}):null,o.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа",children:[1,2,3,4,5].map(c=>o.jsx("button",{type:"button",className:ie.rating>=c?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>et(E=>({...E,rating:c})),disabled:ie.saving,"aria-label":`Оценка ${c}`,children:ie.rating>=c?"●":"○"},c))}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Решение по кейсу",o.jsx("select",{value:ie.manualCaseDecision,onChange:c=>et(E=>({...E,manualCaseDecision:c.target.value})),disabled:ie.saving,children:(Ne.length>0?Ne:X?.enum??[hs]).map(c=>o.jsx("option",{value:c,children:String(X?.labels?.[c]??c)},c))})]}),o.jsxs("label",{children:["Автор комментария",o.jsx("input",{value:ie.annotationAuthor,onChange:c=>et(E=>({...E,annotationAuthor:c.target.value})),placeholder:"manual_reviewer",disabled:ie.saving})]})]}),o.jsxs("label",{children:["Комментарий",o.jsx("textarea",{value:ie.comment,onChange:c=>et(E=>({...E,comment:c.target.value})),placeholder:"Почему ответ бракованный, что именно пошло не так, какие технические детали проверить.",rows:4,disabled:ie.saving})]}),ie.error?o.jsx("p",{className:"error-text",children:ie.error}):null,o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>{mn()},disabled:ie.saving,children:ie.saving?"Сохраняю...":"Готово"}),o.jsx("button",{type:"button",className:"tab",onClick:Dt,disabled:ie.saving,children:"Отмена"})]})]})}):null]})}const vf=/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json|debug_payload|technical_breakdown)\b/i,gf=[/\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 yf(a){try{return JSON.stringify(a,null,2)}catch{return String(a)}}function xf(a){const h=String(a??""),p=h.match(vf);return(p?h.slice(0,p.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(H=>H.trimEnd()).filter(H=>H.trim().length>0).filter(H=>!gf.some(Z=>Z.test(H))).join(` `).trim()}function _f(a,h,p="default"){const D=p==="technical",k=[];k.push("# Assistant conversation export"),k.push(`session_id: ${a||"n/a"}`),k.push(`export_mode: ${p}`),k.push(`exported_at: ${new Date().toISOString()}`),k.push("");for(let F=0;F{re.current&&(re.current.scrollTop=re.current.scrollHeight)},[h,Le]),P.useEffect(()=>()=>{G.current!==null&&window.clearTimeout(G.current)},[]);async function ze(X){if(h.length===0)return;const $e=_f(a,h,X),Ne=await jf($e);xe(X==="technical"?"тех":"чат"),ye(Ne?"success":"error"),G.current!==null&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{ye("idle")},2200)}return o.jsxs(on,{title:"Режим ассистента",subtitle:"Диалоговый слой поверх normalizer, маршрутизации и factual retrieval.",actions:o.jsxs("div",{className:"assistant-panel-actions",children:[o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{ze("default")},disabled:h.length===0,title:"Экспорт только user-facing чата",children:"Скопировать чат"}),o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{ze("technical")},disabled:h.length===0,title:"Технический экспорт с debug payload",children:"Скопировать техчат"}),De==="success"?o.jsxs("span",{className:"assistant-copy-feedback success",children:["Скопировано (",We,")"]}):null,De==="error"?o.jsx("span",{className:"assistant-copy-feedback error",children:"Ошибка копирования"}):null,o.jsx("span",{className:"status-chip",children:a?`session: ${a}`:"новая сессия"})]}),children:[o.jsxs("div",{ref:re,className:"assistant-chat-list",children:[h.length===0?o.jsx("div",{className:"assistant-empty muted",children:"Диалог пуст. Отправьте первый вопрос, чтобы запустить контур ассистента."}):null,h.map(X=>o.jsxs("article",{className:`assistant-msg ${X.role}`,children:[o.jsxs("header",{className:"assistant-msg-head",children:[o.jsx("strong",{children:Sf(X.role)}),o.jsx("span",{children:wf(X.created_at)})]}),o.jsx("div",{className:"assistant-msg-body",children:X.text}),X.role==="assistant"&&X.debug?o.jsxs("details",{className:"assistant-debug",children:[o.jsx("summary",{children:"Показать технический разбор"}),o.jsx(at,{value:X.debug})]}):null]},X.message_id))]}),o.jsxs("div",{className:"assistant-compose",children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{children:["Подсказка по периоду",o.jsx("input",{value:k,onChange:X=>F(X.target.value)})]}),o.jsxs("label",{children:["Бизнес-контекст",o.jsx("input",{value:H,onChange:X=>Z(X.target.value)})]})]}),o.jsxs("label",{className:"full-width",children:["Сообщение",o.jsx("textarea",{value:p,onChange:X=>D(X.target.value),rows:4,placeholder:"Введите вопрос к данным компании..."})]}),o.jsxs("div",{className:"button-row",children:[o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:N,onChange:X=>te(X.target.checked)}),"Mock-режим"]}),o.jsx("button",{type:"button",onClick:()=>ce(),disabled:L||!p.trim(),children:L?"Выполняю...":"Отправить"}),o.jsx("button",{type:"button",onClick:()=>z(),disabled:L&&h.length===0,children:"Сбросить сессию"})]}),Le?o.jsx("p",{className:"diff-summary",children:Le}):null,me?o.jsx("p",{className:"error-text",children:me}):null]})]})}function Zu({value:a,modelOptions:h,modelsBusy:p,onChange:D,onReloadModels:k,onTestConnection:F,onSaveLocalConfig:H,lastStatus:Z,busy:N}){const te=a.llmProvider==="local",ce=h.includes(a.model);return o.jsxs(on,{title:"LLM Connection",subtitle:"Switch between OpenAI cloud and local OpenAI-compatible server.",actions:o.jsx("span",{className:"status-chip",children:Z||"Status: not checked"}),children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{children:["Provider",o.jsxs("select",{value:a.llmProvider,onChange:z=>{const L=z.target.value==="local"?"local":"openai";D({...a,llmProvider:L,baseUrl:L==="local"?"http://127.0.0.1:1234/v1":"https://api.openai.com/v1"})},children:[o.jsx("option",{value:"openai",children:"OpenAI (token)"}),o.jsx("option",{value:"local",children:"Local (LM Studio / OpenAI-compatible)"})]})]}),o.jsxs("label",{children:["Model",o.jsxs("select",{value:ce?a.model:"__manual__",onChange:z=>{const L=z.target.value;L!=="__manual__"&&D({...a,model:L})},children:[o.jsx("option",{value:"__manual__",children:"Manual input"}),h.map(z=>o.jsx("option",{value:z,children:z},z))]})]}),o.jsxs("label",{children:["Model ID (manual)",o.jsx("input",{value:a.model,onChange:z=>D({...a,model:z.target.value}),placeholder:"qwen2.5-14b-instruct or lmstudio loaded model id"})]}),te?null:o.jsxs("label",{className:"full-width",children:["OpenAI API Key",o.jsx("input",{type:"password",value:a.apiKey,onChange:z=>D({...a,apiKey:z.target.value}),placeholder:"sk-..."})]}),o.jsxs("label",{className:te?"full-width":void 0,children:[te?"Local server base URL":"Base URL",o.jsx("input",{value:a.baseUrl,onChange:z=>D({...a,baseUrl:z.target.value}),placeholder:te?"http://127.0.0.1:1234/v1":"https://api.openai.com/v1"})]}),o.jsxs("label",{children:["Temperature",o.jsx("input",{type:"number",step:"0.1",value:a.temperature,onChange:z=>D({...a,temperature:Number(z.target.value)})})]}),o.jsxs("label",{children:["Max output tokens",o.jsx("input",{type:"number",value:a.maxOutputTokens,onChange:z=>D({...a,maxOutputTokens:Number(z.target.value)})})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>H(),children:"Save local config"}),o.jsx("button",{type:"button",onClick:()=>k(),disabled:N||p,children:p?"Loading models...":"Load model list"}),o.jsx("button",{type:"button",onClick:()=>F(),disabled:N,children:N?"Checking...":"Test connection"})]})]})}function Cf({items:a,onRefresh:h,onOpenTrace:p}){return o.jsx(on,{title:"История нормализаций",subtitle:"Короткий вопрос, confidence, route hint и статус валидации.",actions:o.jsx("button",{type:"button",onClick:()=>h(),children:"Обновить"}),children:o.jsxs("div",{className:"history-list",children:[a.length===0?o.jsx("p",{className:"muted",children:"История пока пустая."}):null,a.map(D=>o.jsxs("button",{type:"button",className:"history-item",onClick:()=>p(D.trace_id),children:[o.jsxs("div",{className:"history-row",children:[o.jsx("strong",{children:D.route_hint??"route: n/a"}),o.jsx("span",{children:D.validation_passed?"schema: ok":"schema: fail"})]}),o.jsx("p",{children:D.question_short}),o.jsxs("div",{className:"history-row",children:[o.jsx("span",{children:D.model}),o.jsx("span",{children:new Date(D.timestamp).toLocaleString("ru-RU")})]})]},D.trace_id))]})})}function sn(a){return a==null||a===""?"—":String(a)}function Nf({result:a}){return o.jsx(on,{title:"Runtime метрики",subtitle:"trace_id, токены, latency и статус валидации.",children:o.jsxs("div",{className:"metrics-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"trace_id"}),o.jsx("strong",{children:sn(a?.trace_id)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"request_started_at"}),o.jsx("strong",{children:sn(a?new Date(Date.now()-a.latency_ms).toISOString():null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"request_finished_at"}),o.jsx("strong",{children:sn(a?new Date().toISOString():null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"latency_ms"}),o.jsx("strong",{children:sn(a?.latency_ms)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"input_tokens"}),o.jsx("strong",{children:sn(a?.usage?.input_tokens)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"output_tokens"}),o.jsx("strong",{children:sn(a?.usage?.output_tokens)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"total_tokens"}),o.jsx("strong",{children:sn(a?.usage?.total_tokens)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"validation_status"}),o.jsx("strong",{children:a?.validation?.passed?"passed":"failed"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"prompt_version"}),o.jsx("strong",{children:sn(a?.prompt_version)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"schema_version"}),o.jsx("strong",{children:sn(a?.schema_version)})]})]})})}const Ef={normalized:"Normalized JSON",fragments:"Fragment View",scope:"Scope View",flags:"Flags View",route:"Route Simulation",raw:"Raw model output",validation:"Validation",logs:"Logs"};function Pf(a){return a&&typeof a=="object"?a:null}function Rf({tab:a,onTabChange:h,result:p,appLogs:D}){const k=["normalized","fragments","scope","flags","route","raw","validation","logs"],F=Pf(p?.normalized),H=String(F?.schema_version??""),Z=H==="normalized_query_v2"||H==="normalized_query_v2_0_1"||H==="normalized_query_v2_0_2",N=Z?{fragments:F?.fragments??[],discarded_fragments:F?.discarded_fragments??[]}:{note:"Fragment View доступен для normalized_query_v2."},te=Z?{message_in_scope:F?.message_in_scope??null,scope_confidence:F?.scope_confidence??null,contains_multiple_tasks:F?.contains_multiple_tasks??null,global_notes:F?.global_notes??null}:{note:"Scope View доступен для normalized_query_v2."},ce=Z?Array.isArray(F?.fragments)?(F?.fragments).map(z=>({fragment_id:z.fragment_id??null,domain_relevance:z.domain_relevance??null,candidate_labels:z.candidate_labels??[],execution_readiness:z.execution_readiness??null,clarification_reason:z.clarification_reason??null,soft_assumption_used:z.soft_assumption_used??[],route_status:z.route_status??null,no_route_reason:z.no_route_reason??null,flags:z.flags??{}})):[]:{note:"Flags View доступен для normalized_query_v2."};return o.jsxs(on,{title:"Выходные данные",subtitle:"Structured output и диагностические вкладки.",children:[o.jsx("div",{className:"tab-row",children:k.map(z=>o.jsx("button",{type:"button",className:a===z?"tab active":"tab",onClick:()=>h(z),children:Ef[z]},z))}),a==="normalized"?o.jsx(at,{value:p?.normalized??{note:"Нет данных."}}):null,a==="fragments"?o.jsx(at,{value:N}):null,a==="scope"?o.jsx(at,{value:te}):null,a==="flags"?o.jsx(at,{value:ce}):null,a==="route"?o.jsx(at,{value:p?.route_hint_summary??{note:"Нет данных."}}):null,a==="raw"?o.jsx(at,{value:p?.raw_model_output??{note:"Нет данных."}}):null,a==="validation"?o.jsx(at,{value:p?.validation??{note:"Нет данных."}}):null,a==="logs"?o.jsx(at,{value:D}):null]})}function bu({value:a,onChange:h,presets:p,selectedPresetId:D,onSelectPreset:k,onLoadPreset:F,onSavePreset:H,onResetDefaults:Z,onDiffPrevious:N,presetName:te,onPresetNameChange:ce,diffSummary:z}){return o.jsxs(on,{title:"Prompt Manager",subtitle:"Системный, developer и domain уровни управляются отдельно.",children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{children:["Системный prompt",o.jsx("textarea",{value:a.systemPrompt,onChange:L=>h({...a,systemPrompt:L.target.value}),rows:6})]}),o.jsxs("label",{children:["Developer / Instruction prompt",o.jsx("textarea",{value:a.developerPrompt,onChange:L=>h({...a,developerPrompt:L.target.value}),rows:6})]}),o.jsxs("label",{children:["Domain prompt",o.jsx("textarea",{value:a.domainPrompt,onChange:L=>h({...a,domainPrompt:L.target.value}),rows:6})]}),o.jsxs("label",{children:["Schema notes",o.jsx("textarea",{value:a.schemaNotes,onChange:L=>h({...a,schemaNotes:L.target.value}),rows:6})]}),o.jsxs("label",{className:"full-width",children:["Few-shot examples",o.jsx("textarea",{value:a.fewShotExamples,onChange:L=>h({...a,fewShotExamples:L.target.value}),rows:8})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsxs("select",{value:D,onChange:L=>k(L.target.value),children:[o.jsx("option",{value:"",children:"Выберите preset..."}),p.map(L=>o.jsx("option",{value:L.id,children:L.name},L.id))]}),o.jsx("button",{type:"button",onClick:()=>F(),children:"Загрузить preset"}),o.jsx("input",{value:te,onChange:L=>ce(L.target.value),placeholder:"Имя для сохранения"}),o.jsx("button",{type:"button",onClick:()=>H(),children:"Сохранить preset"}),o.jsx("button",{type:"button",onClick:()=>N(),children:"Diff с предыдущим"}),o.jsx("button",{type:"button",onClick:()=>Z(),children:"Сбросить к default"})]}),z?o.jsx("p",{className:"diff-summary",children:z}):null]})}function Tf({value:a,onChange:h,onApplyBatchFormat:p,onNormalize:D,busy:k,useMock:F,onUseMockChange:H,errorMessage:Z}){return o.jsxs(on,{title:"Запрос пользователя",subtitle:"NDC semantic front-end: нормализуем, но не отвечаем за бухгалтерскую суть.",children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{className:"full-width",children:["Raw user question",o.jsx("textarea",{value:a.userQuestion,onChange:N=>h({...a,userQuestion:N.target.value}),rows:6,placeholder:"Например: По каким покупателям у нас на конец июня висят отгрузки без оплаты..."})]}),o.jsxs("label",{className:"full-width",children:["Batch queries (`;` separator)",o.jsx("textarea",{value:a.batchQuestionsRaw,onChange:N=>h({...a,batchQuestionsRaw:N.target.value}),onBlur:()=>p(),rows:8,placeholder:"Вопрос 1; Вопрос 2; Вопрос 3"})]}),o.jsxs("label",{children:["Optional period context",o.jsx("input",{value:a.periodHint,onChange:N=>h({...a,periodHint:N.target.value})})]}),o.jsxs("label",{children:["Optional business context",o.jsx("input",{value:a.businessContext,onChange:N=>h({...a,businessContext:N.target.value})})]}),o.jsxs("label",{children:["Optional expected route (eval)",o.jsx("input",{value:a.expectedRoute,onChange:N=>h({...a,expectedRoute:N.target.value})})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:F,onChange:N=>H(N.target.checked)}),"Mock-режим (без вызова OpenAI)"]}),o.jsx("button",{type:"button",onClick:()=>p(),disabled:k||!a.batchQuestionsRaw.trim(),children:"Применить `;` в переносы"}),o.jsx("button",{type:"button",onClick:()=>D(!1),disabled:k||!a.userQuestion.trim(),children:k?"Нормализуем...":"Normalize"}),o.jsx("button",{type:"button",onClick:()=>D(!0),disabled:k||!a.userQuestion.trim(),children:k?"Сохраняем...":"Normalize + Save as test case"})]}),Z?o.jsx("p",{className:"error-text",children:Z}):null]})}function Lf({runs:a,selectedRunId:h,onSelectRun:p,onStartRun:D,onFinishRun:k,onRefreshRuns:F,onRunEval:H,onCopyEvalReport:Z,evalBusy:N,traceItems:te,evalReport:ce}){return o.jsxs(on,{title:"NDC Run Monitor",subtitle:"Важно: кнопка Запустить run создает только run-сущность. Кнопка eval запускает batch-проверку normalizer v2.0.2.",children:[o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>D(),children:"Запустить run"}),o.jsx("button",{type:"button",onClick:()=>k(),disabled:!h,children:"Завершить выбранный run"}),o.jsx("button",{type:"button",onClick:()=>F(),children:"Обновить runs"}),o.jsx("button",{type:"button",onClick:()=>H(),disabled:N,children:N?"Идет eval v2.0.2...":"Запустить eval v2.0.2"})]}),o.jsxs("div",{className:"runtime-grid",children:[o.jsxs("div",{className:"runtime-runs",children:[a.map(z=>o.jsxs("button",{type:"button",className:h===z.runId?"history-item selected":"history-item",onClick:()=>p(z.runId),children:[o.jsxs("div",{className:"history-row",children:[o.jsx("strong",{children:z.status}),o.jsx("span",{children:z.runId})]}),o.jsxs("div",{className:"history-row",children:[o.jsx("span",{children:z.sessionId}),o.jsx("span",{children:new Date(z.updatedAt).toLocaleString("ru-RU")})]})]},z.runId)),a.length===0?o.jsx("p",{className:"muted",children:"Нет активных запусков."}):null]}),o.jsxs("div",{children:[o.jsx("h3",{children:"Trace выбранного run"}),o.jsx(at,{value:te}),o.jsxs("div",{className:"eval-report-wrap",children:[o.jsx("h3",{style:{marginTop:12},children:"Отчет eval"}),o.jsx(at,{value:ce??{note:"Eval пока не запускался"}}),o.jsx("button",{type:"button",className:"copy-cube-button",title:"Скопировать отчет eval",onClick:()=>Z(),children:"⧉"})]})]})]})]})}const zf={llmProvider:"openai",apiKey:"",model:"gpt-4o-mini",baseUrl:"https://api.openai.com/v1",temperature:0,maxOutputTokens:700},ec={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."},Of={userQuestion:"",batchQuestionsRaw:"",periodHint:"",businessContext:"",expectedRoute:""},Mf={colors:{backgroundRgb:"18, 18, 18",mainSurfaceRgb:"23, 23, 23",horizontalSurfaceRgb:"40, 40, 40",focusSurfaceRgb:"30, 30, 30",activeRgb:"167, 59, 255",activeTextRgb:"18, 18, 18",textMainRgb:"240, 240, 240",textMutedRgb:"166, 166, 166",dangerRgb:"205, 126, 126",scrollbarTrackRgb:"20, 20, 20",scrollbarThumbRgb:"30, 30, 30",scrollbarThumbHoverRgb:"30, 50, 30"}},tc="ndc_normalizer_session_config_v1",li=["Анализ запроса","Получение данных","Подготовка ответа"],Df="assistant",si="normalizer_v2_0_2",nc="address_query_runtime_v1";function If(a){return`[${new Date().toLocaleTimeString("ru-RU")}] ${a}`}function Af(a,h){if(!h)return"Previous preset is not selected.";const D=["systemPrompt","developerPrompt","domainPrompt","schemaNotes","fewShotExamples"].filter(k=>a[k]!==h[k]).map(k=>`${k}: ${Math.abs(a[k].length-h[k].length)} chars delta`);return D.length===0?"No changes against previous preset.":`Changed fields: ${D.length}. ${D.join(" | ")}`}function Ff(){const[a,h]=P.useState(zf),[p,D]=P.useState(ec),[k,F]=P.useState(Of),[H,Z]=P.useState(null),[N,te]=P.useState([]),[ce,z]=P.useState([]),[L,Le]=P.useState("normalized"),[me,re]=P.useState(!1),[G,De]=P.useState(!1),[ye,We]=P.useState([]),[xe,ze]=P.useState(""),[X,$e]=P.useState([]),[Ne,ut]=P.useState(""),[be,gt]=P.useState("NDC custom preset"),[he,He]=P.useState(null),[Oe,Ye]=P.useState(""),[b,pe]=P.useState(!1),[R,V]=P.useState([]),[T,m]=P.useState(""),[_,Y]=P.useState([]),[J,le]=P.useState(!1),[ee,de]=P.useState(null),[ae,oe]=P.useState(""),[ke,Ot]=P.useState(Df),[an,Gt]=P.useState(!0),[kt,Dn]=P.useState(!0),[un,ct]=P.useState(!0),[ie,et]=P.useState(""),[Mt,yt]=P.useState([]),[xt,ge]=P.useState(""),[cn,dn]=P.useState(!1),[Jn,Se]=P.useState(""),[Ct,Nt]=P.useState(""),Je=P.useRef(!1);P.useEffect(()=>{const x=document.documentElement,{colors:O}=Mf;x.style.setProperty("--rgb-background",O.backgroundRgb),x.style.setProperty("--rgb-surface-main",O.mainSurfaceRgb),x.style.setProperty("--rgb-surface-horizontal",O.horizontalSurfaceRgb),x.style.setProperty("--rgb-surface-focus",O.focusSurfaceRgb),x.style.setProperty("--rgb-active",O.activeRgb),x.style.setProperty("--rgb-active-text",O.activeTextRgb),x.style.setProperty("--rgb-text-main",O.textMainRgb),x.style.setProperty("--rgb-text-muted",O.textMutedRgb),x.style.setProperty("--rgb-danger",O.dangerRgb),x.style.setProperty("--rgb-scrollbar-track",O.scrollbarTrackRgb),x.style.setProperty("--rgb-scrollbar-thumb",O.scrollbarThumbRgb),x.style.setProperty("--rgb-scrollbar-thumb-hover",O.scrollbarThumbHoverRgb)},[]);const K=x=>{z(O=>[If(x),...O].slice(0,300))};function fn(){let x=0;Se(li[0]);const O=window.setInterval(()=>{x=Math.min(x+1,li.length-1),Se(li[x])},650);return()=>window.clearInterval(O)}P.useEffect(()=>{const x=localStorage.getItem(tc);if(x)try{const O=JSON.parse(x);h(B=>({...B,llmProvider:O.llmProvider==="local"?"local":"openai",model:O.model??B.model,baseUrl:O.baseUrl??B.baseUrl,temperature:O.temperature??B.temperature,maxOutputTokens:O.maxOutputTokens??B.maxOutputTokens}))}catch{}tt(),Yt(),pn()},[]);async function tt(){try{const x=await Ue.loadHistory();te(x.items??[])}catch(x){K(`History load error: ${x instanceof Error?x.message:String(x)}`)}}async function Yt(){try{const O=(await Ue.loadPresets()).presets??[];if($e(O),Je.current)return;const B=O.find(Ie=>Ie.prompt_version===si)??O.find(Ie=>Ie.id==="default-normalizer-v2_0_2");if(!B){Je.current=!0,K(`Preset autoload skipped: ${si} not found.`);return}ut(B.id),He(p),D({systemPrompt:B.systemPrompt,developerPrompt:B.developerPrompt,domainPrompt:B.domainPrompt,schemaNotes:B.schemaNotes??"",fewShotExamples:B.fewShotExamples??""}),Je.current=!0,K(`Preset autoloaded: ${B.name} (${B.prompt_version}).`)}catch(x){K(`Presets load error: ${x instanceof Error?x.message:String(x)}`)}}async function pn(){try{const x=await Ue.listRuns();V(x.items??[])}catch(x){K(`Runs load error: ${x instanceof Error?x.message:String(x)}`)}}function Dt(){localStorage.setItem(tc,JSON.stringify({model:a.model,llmProvider:a.llmProvider,baseUrl:a.baseUrl,temperature:a.temperature,maxOutputTokens:a.maxOutputTokens})),K("Local config saved (without API key).")}async function mn(){re(!0),oe("");try{const x=await Ue.testConnection(a);x.provider==="local"?x.model_found===!0?(ze(`LOCAL OK - ${x.model}`),K(`Local model is available: ${x.model} (catalog size=${x.models_count??"n/a"}).`)):x.model_found===!1?(ze(`LOCAL OK, model not loaded - ${x.model}`),K(`Local server is reachable, but model '${x.model}' is not in loaded catalog. Use 'Load model list' and select one of loaded models.`)):(ze(`LOCAL OK (model list unavailable) - ${x.model}`),K("Local server is reachable, but model catalog could not be verified.")):(ze(`OPENAI OK - ${x.model}`),K(`OpenAI connection ok: ${x.model}`))}catch(x){const O=x instanceof Error?x.message:String(x);ze("Connection error"),oe(`Test connection: ${O}`),K(`Test connection error: ${O}`)}finally{re(!1)}}async function hn(){De(!0);try{const O=(await Ue.listModels(a)).models??[];We(O),O.length>0&&h(B=>B.model&&O.includes(B.model)?B:{...B,model:O[0]}),K(`Model catalog loaded (${a.llmProvider}): ${O.length} items.`)}catch(x){const O=x instanceof Error?x.message:String(x);K(`Load model list error: ${O}`)}finally{De(!1)}}P.useEffect(()=>{We([])},[a.llmProvider,a.baseUrl]);async function c(x){re(!0),oe("");try{const O=await Ue.normalize({connection:a,prompts:p,promptVersion:"normalizer_v2_0_2",query:{userQuestion:k.userQuestion,periodHint:k.periodHint,businessContext:k.businessContext,expectedRoute:k.expectedRoute},saveAsTestCase:x,useMock:b});Z(O),Le("normalized"),K(`Normalize done: trace=${O.trace_id}, validation=${O.validation.passed?"passed":"failed"}`),tt()}catch(O){const B=O instanceof Error?O.message:String(O);oe(`Normalize: ${B}`),K(`Normalize error: ${B}`)}finally{re(!1)}}function E(){const x=X.find(O=>O.id===Ne);if(!x){K("Preset is not selected.");return}He(p),D({systemPrompt:x.systemPrompt,developerPrompt:x.developerPrompt,domainPrompt:x.domainPrompt,schemaNotes:x.schemaNotes??"",fewShotExamples:x.fewShotExamples??""}),K(`Preset loaded: ${x.name}`)}async function ne(){try{await Ue.savePreset({name:be||"NDC preset",prompt_version:"normalizer_v2_0_2",systemPrompt:p.systemPrompt,developerPrompt:p.developerPrompt,domainPrompt:p.domainPrompt,schemaNotes:p.schemaNotes,fewShotExamples:p.fewShotExamples}),K("Preset saved."),await Yt()}catch(x){K(`Preset save error: ${x instanceof Error?x.message:String(x)}`)}}function Ee(){D(ec),K("Prompt panel reset to defaults.")}function Jt(){const x=Af(p,he);Ye(x),K(x)}function Xn(){const x=k.batchQuestionsRaw.split(";").map(O=>O.trim()).filter(Boolean).join(` +`)}function Sf(a){return a==="assistant"?"Ассистент":"Вы"}function wf(a){const h=new Date(a);return Number.isNaN(h.getTime())?a:h.toLocaleTimeString("ru-RU")}async function jf(a){if(navigator.clipboard&&window.isSecureContext)try{return await navigator.clipboard.writeText(a),!0}catch{}const h=document.createElement("textarea");h.value=a,h.setAttribute("readonly","true"),h.style.position="fixed",h.style.opacity="0",h.style.pointerEvents="none",document.body.appendChild(h),h.select();let p=!1;try{p=document.execCommand("copy")}catch{p=!1}finally{document.body.removeChild(h)}return p}function kf({sessionId:a,conversation:h,inputValue:p,onInputChange:D,periodHint:k,onPeriodHintChange:F,businessContext:H,onBusinessContextChange:Z,useMock:N,onUseMockChange:te,onSend:ce,onClear:z,busy:L,statusText:Le,errorMessage:me}){const re=P.useRef(null),G=P.useRef(null),[De,ye]=P.useState("idle"),[We,xe]=P.useState("чат");P.useEffect(()=>{re.current&&(re.current.scrollTop=re.current.scrollHeight)},[h,Le]),P.useEffect(()=>()=>{G.current!==null&&window.clearTimeout(G.current)},[]);async function ze(X){if(h.length===0)return;const $e=_f(a,h,X),Ne=await jf($e);xe(X==="technical"?"тех":"чат"),ye(Ne?"success":"error"),G.current!==null&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{ye("idle")},2200)}return o.jsxs(on,{title:"Режим ассистента",subtitle:"Диалоговый слой поверх normalizer, маршрутизации и factual retrieval.",actions:o.jsxs("div",{className:"assistant-panel-actions",children:[o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{ze("default")},disabled:h.length===0,title:"Экспорт только user-facing чата",children:"Скопировать чат"}),o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{ze("technical")},disabled:h.length===0,title:"Технический экспорт с debug payload",children:"Скопировать техчат"}),De==="success"?o.jsxs("span",{className:"assistant-copy-feedback success",children:["Скопировано (",We,")"]}):null,De==="error"?o.jsx("span",{className:"assistant-copy-feedback error",children:"Ошибка копирования"}):null,o.jsx("span",{className:"status-chip",children:a?`session: ${a}`:"новая сессия"})]}),children:[o.jsxs("div",{ref:re,className:"assistant-chat-list",children:[h.length===0?o.jsx("div",{className:"assistant-empty muted",children:"Диалог пуст. Отправьте первый вопрос, чтобы запустить контур ассистента."}):null,h.map(X=>o.jsxs("article",{className:`assistant-msg ${X.role}`,children:[o.jsxs("header",{className:"assistant-msg-head",children:[o.jsx("strong",{children:Sf(X.role)}),o.jsx("span",{children:wf(X.created_at)})]}),o.jsx("div",{className:"assistant-msg-body",children:X.text}),X.role==="assistant"&&X.debug?o.jsxs("details",{className:"assistant-debug",children:[o.jsx("summary",{children:"Показать технический разбор"}),o.jsx(at,{value:X.debug})]}):null]},X.message_id))]}),o.jsxs("div",{className:"assistant-compose",children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{children:["Подсказка по периоду",o.jsx("input",{value:k,onChange:X=>F(X.target.value)})]}),o.jsxs("label",{children:["Бизнес-контекст",o.jsx("input",{value:H,onChange:X=>Z(X.target.value)})]})]}),o.jsxs("label",{className:"full-width",children:["Сообщение",o.jsx("textarea",{value:p,onChange:X=>D(X.target.value),rows:4,placeholder:"Введите вопрос к данным компании..."})]}),o.jsxs("div",{className:"button-row",children:[o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:N,onChange:X=>te(X.target.checked)}),"Mock-режим"]}),o.jsx("button",{type:"button",onClick:()=>ce(),disabled:L||!p.trim(),children:L?"Выполняю...":"Отправить"}),o.jsx("button",{type:"button",onClick:()=>z(),disabled:L&&h.length===0,children:"Сбросить сессию"})]}),Le?o.jsx("p",{className:"diff-summary",children:Le}):null,me?o.jsx("p",{className:"error-text",children:me}):null]})]})}function Zu({value:a,modelOptions:h,modelsBusy:p,onChange:D,onReloadModels:k,onTestConnection:F,onSaveLocalConfig:H,lastStatus:Z,busy:N}){const te=a.llmProvider==="local",ce=h.includes(a.model);return o.jsxs(on,{title:"LLM Connection",subtitle:"Switch between OpenAI cloud and local OpenAI-compatible server.",actions:o.jsx("span",{className:"status-chip",children:Z||"Status: not checked"}),children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{children:["Provider",o.jsxs("select",{value:a.llmProvider,onChange:z=>{const L=z.target.value==="local"?"local":"openai";D({...a,llmProvider:L,baseUrl:L==="local"?"http://127.0.0.1:1234/v1":"https://api.openai.com/v1"})},children:[o.jsx("option",{value:"openai",children:"OpenAI (token)"}),o.jsx("option",{value:"local",children:"Local (LM Studio / OpenAI-compatible)"})]})]}),o.jsxs("label",{children:["Model",o.jsxs("select",{value:ce?a.model:"__manual__",onChange:z=>{const L=z.target.value;L!=="__manual__"&&D({...a,model:L})},children:[o.jsx("option",{value:"__manual__",children:"Manual input"}),h.map(z=>o.jsx("option",{value:z,children:z},z))]})]}),o.jsxs("label",{children:["Model ID (manual)",o.jsx("input",{value:a.model,onChange:z=>D({...a,model:z.target.value}),placeholder:"qwen2.5-14b-instruct or lmstudio loaded model id"})]}),te?null:o.jsxs("label",{className:"full-width",children:["OpenAI API Key",o.jsx("input",{type:"password",value:a.apiKey,onChange:z=>D({...a,apiKey:z.target.value}),placeholder:"sk-..."})]}),o.jsxs("label",{className:te?"full-width":void 0,children:[te?"Local server base URL":"Base URL",o.jsx("input",{value:a.baseUrl,onChange:z=>D({...a,baseUrl:z.target.value}),placeholder:te?"http://127.0.0.1:1234/v1":"https://api.openai.com/v1"})]}),o.jsxs("label",{children:["Temperature",o.jsx("input",{type:"number",step:"0.1",value:a.temperature,onChange:z=>D({...a,temperature:Number(z.target.value)})})]}),o.jsxs("label",{children:["Max output tokens",o.jsx("input",{type:"number",value:a.maxOutputTokens,onChange:z=>D({...a,maxOutputTokens:Number(z.target.value)})})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>H(),children:"Save local config"}),o.jsx("button",{type:"button",onClick:()=>k(),disabled:N||p,children:p?"Loading models...":"Load model list"}),o.jsx("button",{type:"button",onClick:()=>F(),disabled:N,children:N?"Checking...":"Test connection"})]})]})}function Cf({items:a,onRefresh:h,onOpenTrace:p}){return o.jsx(on,{title:"История нормализаций",subtitle:"Короткий вопрос, confidence, route hint и статус валидации.",actions:o.jsx("button",{type:"button",onClick:()=>h(),children:"Обновить"}),children:o.jsxs("div",{className:"history-list",children:[a.length===0?o.jsx("p",{className:"muted",children:"История пока пустая."}):null,a.map(D=>o.jsxs("button",{type:"button",className:"history-item",onClick:()=>p(D.trace_id),children:[o.jsxs("div",{className:"history-row",children:[o.jsx("strong",{children:D.route_hint??"route: n/a"}),o.jsx("span",{children:D.validation_passed?"schema: ok":"schema: fail"})]}),o.jsx("p",{children:D.question_short}),o.jsxs("div",{className:"history-row",children:[o.jsx("span",{children:D.model}),o.jsx("span",{children:new Date(D.timestamp).toLocaleString("ru-RU")})]})]},D.trace_id))]})})}function sn(a){return a==null||a===""?"—":String(a)}function Nf({result:a}){return o.jsx(on,{title:"Runtime метрики",subtitle:"trace_id, токены, latency и статус валидации.",children:o.jsxs("div",{className:"metrics-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"trace_id"}),o.jsx("strong",{children:sn(a?.trace_id)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"request_started_at"}),o.jsx("strong",{children:sn(a?new Date(Date.now()-a.latency_ms).toISOString():null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"request_finished_at"}),o.jsx("strong",{children:sn(a?new Date().toISOString():null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"latency_ms"}),o.jsx("strong",{children:sn(a?.latency_ms)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"input_tokens"}),o.jsx("strong",{children:sn(a?.usage?.input_tokens)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"output_tokens"}),o.jsx("strong",{children:sn(a?.usage?.output_tokens)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"total_tokens"}),o.jsx("strong",{children:sn(a?.usage?.total_tokens)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"validation_status"}),o.jsx("strong",{children:a?.validation?.passed?"passed":"failed"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"prompt_version"}),o.jsx("strong",{children:sn(a?.prompt_version)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"schema_version"}),o.jsx("strong",{children:sn(a?.schema_version)})]})]})})}const Ef={normalized:"Normalized JSON",fragments:"Fragment View",scope:"Scope View",flags:"Flags View",route:"Route Simulation",raw:"Raw model output",validation:"Validation",logs:"Logs"};function Pf(a){return a&&typeof a=="object"?a:null}function Rf({tab:a,onTabChange:h,result:p,appLogs:D}){const k=["normalized","fragments","scope","flags","route","raw","validation","logs"],F=Pf(p?.normalized),H=String(F?.schema_version??""),Z=H==="normalized_query_v2"||H==="normalized_query_v2_0_1"||H==="normalized_query_v2_0_2",N=Z?{fragments:F?.fragments??[],discarded_fragments:F?.discarded_fragments??[]}:{note:"Fragment View доступен для normalized_query_v2."},te=Z?{message_in_scope:F?.message_in_scope??null,scope_confidence:F?.scope_confidence??null,contains_multiple_tasks:F?.contains_multiple_tasks??null,global_notes:F?.global_notes??null}:{note:"Scope View доступен для normalized_query_v2."},ce=Z?Array.isArray(F?.fragments)?(F?.fragments).map(z=>({fragment_id:z.fragment_id??null,domain_relevance:z.domain_relevance??null,candidate_labels:z.candidate_labels??[],execution_readiness:z.execution_readiness??null,clarification_reason:z.clarification_reason??null,soft_assumption_used:z.soft_assumption_used??[],route_status:z.route_status??null,no_route_reason:z.no_route_reason??null,flags:z.flags??{}})):[]:{note:"Flags View доступен для normalized_query_v2."};return o.jsxs(on,{title:"Выходные данные",subtitle:"Structured output и диагностические вкладки.",children:[o.jsx("div",{className:"tab-row",children:k.map(z=>o.jsx("button",{type:"button",className:a===z?"tab active":"tab",onClick:()=>h(z),children:Ef[z]},z))}),a==="normalized"?o.jsx(at,{value:p?.normalized??{note:"Нет данных."}}):null,a==="fragments"?o.jsx(at,{value:N}):null,a==="scope"?o.jsx(at,{value:te}):null,a==="flags"?o.jsx(at,{value:ce}):null,a==="route"?o.jsx(at,{value:p?.route_hint_summary??{note:"Нет данных."}}):null,a==="raw"?o.jsx(at,{value:p?.raw_model_output??{note:"Нет данных."}}):null,a==="validation"?o.jsx(at,{value:p?.validation??{note:"Нет данных."}}):null,a==="logs"?o.jsx(at,{value:D}):null]})}function bu({value:a,onChange:h,presets:p,selectedPresetId:D,onSelectPreset:k,onLoadPreset:F,onSavePreset:H,onResetDefaults:Z,onDiffPrevious:N,presetName:te,onPresetNameChange:ce,diffSummary:z}){return o.jsxs(on,{title:"Prompt Manager",subtitle:"Системный, developer и domain уровни управляются отдельно.",children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{children:["Системный prompt",o.jsx("textarea",{value:a.systemPrompt,onChange:L=>h({...a,systemPrompt:L.target.value}),rows:6})]}),o.jsxs("label",{children:["Developer / Instruction prompt",o.jsx("textarea",{value:a.developerPrompt,onChange:L=>h({...a,developerPrompt:L.target.value}),rows:6})]}),o.jsxs("label",{children:["Domain prompt",o.jsx("textarea",{value:a.domainPrompt,onChange:L=>h({...a,domainPrompt:L.target.value}),rows:6})]}),o.jsxs("label",{children:["Schema notes",o.jsx("textarea",{value:a.schemaNotes,onChange:L=>h({...a,schemaNotes:L.target.value}),rows:6})]}),o.jsxs("label",{className:"full-width",children:["Few-shot examples",o.jsx("textarea",{value:a.fewShotExamples,onChange:L=>h({...a,fewShotExamples:L.target.value}),rows:8})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsxs("select",{value:D,onChange:L=>k(L.target.value),children:[o.jsx("option",{value:"",children:"Выберите preset..."}),p.map(L=>o.jsx("option",{value:L.id,children:L.name},L.id))]}),o.jsx("button",{type:"button",onClick:()=>F(),children:"Загрузить preset"}),o.jsx("input",{value:te,onChange:L=>ce(L.target.value),placeholder:"Имя для сохранения"}),o.jsx("button",{type:"button",onClick:()=>H(),children:"Сохранить preset"}),o.jsx("button",{type:"button",onClick:()=>N(),children:"Diff с предыдущим"}),o.jsx("button",{type:"button",onClick:()=>Z(),children:"Сбросить к default"})]}),z?o.jsx("p",{className:"diff-summary",children:z}):null]})}function Tf({value:a,onChange:h,onApplyBatchFormat:p,onNormalize:D,busy:k,useMock:F,onUseMockChange:H,errorMessage:Z}){return o.jsxs(on,{title:"Запрос пользователя",subtitle:"NDC semantic front-end: нормализуем, но не отвечаем за бухгалтерскую суть.",children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{className:"full-width",children:["Raw user question",o.jsx("textarea",{value:a.userQuestion,onChange:N=>h({...a,userQuestion:N.target.value}),rows:6,placeholder:"Например: По каким покупателям у нас на конец июня висят отгрузки без оплаты..."})]}),o.jsxs("label",{className:"full-width",children:["Batch queries (`;` separator)",o.jsx("textarea",{value:a.batchQuestionsRaw,onChange:N=>h({...a,batchQuestionsRaw:N.target.value}),onBlur:()=>p(),rows:8,placeholder:"Вопрос 1; Вопрос 2; Вопрос 3"})]}),o.jsxs("label",{children:["Optional period context",o.jsx("input",{value:a.periodHint,onChange:N=>h({...a,periodHint:N.target.value})})]}),o.jsxs("label",{children:["Optional business context",o.jsx("input",{value:a.businessContext,onChange:N=>h({...a,businessContext:N.target.value})})]}),o.jsxs("label",{children:["Optional expected route (eval)",o.jsx("input",{value:a.expectedRoute,onChange:N=>h({...a,expectedRoute:N.target.value})})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:F,onChange:N=>H(N.target.checked)}),"Mock-режим (без вызова OpenAI)"]}),o.jsx("button",{type:"button",onClick:()=>p(),disabled:k||!a.batchQuestionsRaw.trim(),children:"Применить `;` в переносы"}),o.jsx("button",{type:"button",onClick:()=>D(!1),disabled:k||!a.userQuestion.trim(),children:k?"Нормализуем...":"Normalize"}),o.jsx("button",{type:"button",onClick:()=>D(!0),disabled:k||!a.userQuestion.trim(),children:k?"Сохраняем...":"Normalize + Save as test case"})]}),Z?o.jsx("p",{className:"error-text",children:Z}):null]})}function Lf({runs:a,selectedRunId:h,onSelectRun:p,onStartRun:D,onFinishRun:k,onRefreshRuns:F,onRunEval:H,onCopyEvalReport:Z,evalBusy:N,traceItems:te,evalReport:ce}){return o.jsxs(on,{title:"NDC Run Monitor",subtitle:"Важно: кнопка Запустить run создает только run-сущность. Кнопка eval запускает batch-проверку normalizer v2.0.2.",children:[o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>D(),children:"Запустить run"}),o.jsx("button",{type:"button",onClick:()=>k(),disabled:!h,children:"Завершить выбранный run"}),o.jsx("button",{type:"button",onClick:()=>F(),children:"Обновить runs"}),o.jsx("button",{type:"button",onClick:()=>H(),disabled:N,children:N?"Идет eval v2.0.2...":"Запустить eval v2.0.2"})]}),o.jsxs("div",{className:"runtime-grid",children:[o.jsxs("div",{className:"runtime-runs",children:[a.map(z=>o.jsxs("button",{type:"button",className:h===z.runId?"history-item selected":"history-item",onClick:()=>p(z.runId),children:[o.jsxs("div",{className:"history-row",children:[o.jsx("strong",{children:z.status}),o.jsx("span",{children:z.runId})]}),o.jsxs("div",{className:"history-row",children:[o.jsx("span",{children:z.sessionId}),o.jsx("span",{children:new Date(z.updatedAt).toLocaleString("ru-RU")})]})]},z.runId)),a.length===0?o.jsx("p",{className:"muted",children:"Нет активных запусков."}):null]}),o.jsxs("div",{children:[o.jsx("h3",{children:"Trace выбранного run"}),o.jsx(at,{value:te}),o.jsxs("div",{className:"eval-report-wrap",children:[o.jsx("h3",{style:{marginTop:12},children:"Отчет eval"}),o.jsx(at,{value:ce??{note:"Eval пока не запускался"}}),o.jsx("button",{type:"button",className:"copy-cube-button",title:"Скопировать отчет eval",onClick:()=>Z(),children:"⧉"})]})]})]})]})}const zf={llmProvider:"openai",apiKey:"",model:"gpt-4o-mini",baseUrl:"https://api.openai.com/v1",temperature:0,maxOutputTokens:700},ec={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."},Of={userQuestion:"",batchQuestionsRaw:"",periodHint:"",businessContext:"",expectedRoute:""},Mf={colors:{backgroundRgb:"18, 18, 18",mainSurfaceRgb:"25, 25, 25",horizontalSurfaceRgb:"30, 30, 30",focusSurfaceRgb:"35, 35, 35",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"}},tc="ndc_normalizer_session_config_v1",li=["Анализ запроса","Получение данных","Подготовка ответа"],Df="assistant",si="normalizer_v2_0_2",nc="address_query_runtime_v1";function If(a){return`[${new Date().toLocaleTimeString("ru-RU")}] ${a}`}function Af(a,h){if(!h)return"Previous preset is not selected.";const D=["systemPrompt","developerPrompt","domainPrompt","schemaNotes","fewShotExamples"].filter(k=>a[k]!==h[k]).map(k=>`${k}: ${Math.abs(a[k].length-h[k].length)} chars delta`);return D.length===0?"No changes against previous preset.":`Changed fields: ${D.length}. ${D.join(" | ")}`}function Ff(){const[a,h]=P.useState(zf),[p,D]=P.useState(ec),[k,F]=P.useState(Of),[H,Z]=P.useState(null),[N,te]=P.useState([]),[ce,z]=P.useState([]),[L,Le]=P.useState("normalized"),[me,re]=P.useState(!1),[G,De]=P.useState(!1),[ye,We]=P.useState([]),[xe,ze]=P.useState(""),[X,$e]=P.useState([]),[Ne,ut]=P.useState(""),[be,gt]=P.useState("NDC custom preset"),[he,He]=P.useState(null),[Oe,Ye]=P.useState(""),[b,pe]=P.useState(!1),[R,V]=P.useState([]),[T,m]=P.useState(""),[_,Y]=P.useState([]),[J,le]=P.useState(!1),[ee,de]=P.useState(null),[ae,oe]=P.useState(""),[ke,Ot]=P.useState(Df),[an,Gt]=P.useState(!0),[kt,Dn]=P.useState(!0),[un,ct]=P.useState(!0),[ie,et]=P.useState(""),[Mt,yt]=P.useState([]),[xt,ge]=P.useState(""),[cn,dn]=P.useState(!1),[Jn,Se]=P.useState(""),[Ct,Nt]=P.useState(""),Je=P.useRef(!1);P.useEffect(()=>{const x=document.documentElement,{colors:O}=Mf;x.style.setProperty("--rgb-background",O.backgroundRgb),x.style.setProperty("--rgb-surface-main",O.mainSurfaceRgb),x.style.setProperty("--rgb-surface-horizontal",O.horizontalSurfaceRgb),x.style.setProperty("--rgb-surface-focus",O.focusSurfaceRgb),x.style.setProperty("--rgb-active",O.activeRgb),x.style.setProperty("--rgb-active-text",O.activeTextRgb),x.style.setProperty("--rgb-text-main",O.textMainRgb),x.style.setProperty("--rgb-text-muted",O.textMutedRgb),x.style.setProperty("--rgb-danger",O.dangerRgb),x.style.setProperty("--rgb-scrollbar-track",O.scrollbarTrackRgb),x.style.setProperty("--rgb-scrollbar-thumb",O.scrollbarThumbRgb),x.style.setProperty("--rgb-scrollbar-thumb-hover",O.scrollbarThumbHoverRgb)},[]);const K=x=>{z(O=>[If(x),...O].slice(0,300))};function fn(){let x=0;Se(li[0]);const O=window.setInterval(()=>{x=Math.min(x+1,li.length-1),Se(li[x])},650);return()=>window.clearInterval(O)}P.useEffect(()=>{const x=localStorage.getItem(tc);if(x)try{const O=JSON.parse(x);h(B=>({...B,llmProvider:O.llmProvider==="local"?"local":"openai",model:O.model??B.model,baseUrl:O.baseUrl??B.baseUrl,temperature:O.temperature??B.temperature,maxOutputTokens:O.maxOutputTokens??B.maxOutputTokens}))}catch{}tt(),Yt(),pn()},[]);async function tt(){try{const x=await Ue.loadHistory();te(x.items??[])}catch(x){K(`History load error: ${x instanceof Error?x.message:String(x)}`)}}async function Yt(){try{const O=(await Ue.loadPresets()).presets??[];if($e(O),Je.current)return;const B=O.find(Ie=>Ie.prompt_version===si)??O.find(Ie=>Ie.id==="default-normalizer-v2_0_2");if(!B){Je.current=!0,K(`Preset autoload skipped: ${si} not found.`);return}ut(B.id),He(p),D({systemPrompt:B.systemPrompt,developerPrompt:B.developerPrompt,domainPrompt:B.domainPrompt,schemaNotes:B.schemaNotes??"",fewShotExamples:B.fewShotExamples??""}),Je.current=!0,K(`Preset autoloaded: ${B.name} (${B.prompt_version}).`)}catch(x){K(`Presets load error: ${x instanceof Error?x.message:String(x)}`)}}async function pn(){try{const x=await Ue.listRuns();V(x.items??[])}catch(x){K(`Runs load error: ${x instanceof Error?x.message:String(x)}`)}}function Dt(){localStorage.setItem(tc,JSON.stringify({model:a.model,llmProvider:a.llmProvider,baseUrl:a.baseUrl,temperature:a.temperature,maxOutputTokens:a.maxOutputTokens})),K("Local config saved (without API key).")}async function mn(){re(!0),oe("");try{const x=await Ue.testConnection(a);x.provider==="local"?x.model_found===!0?(ze(`LOCAL OK - ${x.model}`),K(`Local model is available: ${x.model} (catalog size=${x.models_count??"n/a"}).`)):x.model_found===!1?(ze(`LOCAL OK, model not loaded - ${x.model}`),K(`Local server is reachable, but model '${x.model}' is not in loaded catalog. Use 'Load model list' and select one of loaded models.`)):(ze(`LOCAL OK (model list unavailable) - ${x.model}`),K("Local server is reachable, but model catalog could not be verified.")):(ze(`OPENAI OK - ${x.model}`),K(`OpenAI connection ok: ${x.model}`))}catch(x){const O=x instanceof Error?x.message:String(x);ze("Connection error"),oe(`Test connection: ${O}`),K(`Test connection error: ${O}`)}finally{re(!1)}}async function hn(){De(!0);try{const O=(await Ue.listModels(a)).models??[];We(O),O.length>0&&h(B=>B.model&&O.includes(B.model)?B:{...B,model:O[0]}),K(`Model catalog loaded (${a.llmProvider}): ${O.length} items.`)}catch(x){const O=x instanceof Error?x.message:String(x);K(`Load model list error: ${O}`)}finally{De(!1)}}P.useEffect(()=>{We([])},[a.llmProvider,a.baseUrl]);async function c(x){re(!0),oe("");try{const O=await Ue.normalize({connection:a,prompts:p,promptVersion:"normalizer_v2_0_2",query:{userQuestion:k.userQuestion,periodHint:k.periodHint,businessContext:k.businessContext,expectedRoute:k.expectedRoute},saveAsTestCase:x,useMock:b});Z(O),Le("normalized"),K(`Normalize done: trace=${O.trace_id}, validation=${O.validation.passed?"passed":"failed"}`),tt()}catch(O){const B=O instanceof Error?O.message:String(O);oe(`Normalize: ${B}`),K(`Normalize error: ${B}`)}finally{re(!1)}}function E(){const x=X.find(O=>O.id===Ne);if(!x){K("Preset is not selected.");return}He(p),D({systemPrompt:x.systemPrompt,developerPrompt:x.developerPrompt,domainPrompt:x.domainPrompt,schemaNotes:x.schemaNotes??"",fewShotExamples:x.fewShotExamples??""}),K(`Preset loaded: ${x.name}`)}async function ne(){try{await Ue.savePreset({name:be||"NDC preset",prompt_version:"normalizer_v2_0_2",systemPrompt:p.systemPrompt,developerPrompt:p.developerPrompt,domainPrompt:p.domainPrompt,schemaNotes:p.schemaNotes,fewShotExamples:p.fewShotExamples}),K("Preset saved."),await Yt()}catch(x){K(`Preset save error: ${x instanceof Error?x.message:String(x)}`)}}function Ee(){D(ec),K("Prompt panel reset to defaults.")}function Jt(){const x=Af(p,he);Ye(x),K(x)}function Xn(){const x=k.batchQuestionsRaw.split(";").map(O=>O.trim()).filter(Boolean).join(` `);x&&(F(O=>({...O,batchQuestionsRaw:x})),K("Batch field formatted: `;` converted to blank-line separators."))}async function Zn(x){try{const B=(await Ue.loadTrace(x)).trace,Ie=B.parsed_normalized_json??null;Z({trace_id:String(B.trace_id??x),ok:!!B.validation_result?.passed,normalized:Ie,route_hint_summary:B.route_hint_summary??(Ie?{route_hint:Ie.route_hint??null,confidence:Ie.confidence?.route_hint??null}:null),raw_model_output:B.raw_model_response??{},validation:B.validation_result??{passed:!1,errors:["validation not found"]},usage:B.usage??{input_tokens:0,output_tokens:0,total_tokens:0},latency_ms:Number(B.latency_ms??0),prompt_version:String(B.prompt_version??"unknown"),schema_version:String(B.schema_version??"unknown")}),Le("raw"),oe(""),K(`Trace opened: ${x}`)}catch(O){const B=O instanceof Error?O.message:String(O);oe(`Trace: ${B}`),K(`Trace open error ${x}: ${B}`)}}async function sl(){try{const x=await Ue.startRun();m(x.run.runId),K(`Run started: ${x.run.runId}`),K("Tip: start run does not execute normalize by itself. Use 'Run eval v2.0.2' button."),await pn()}catch(x){K(`Run start error: ${x instanceof Error?x.message:String(x)}`)}}async function ol(){if(T)try{await Ue.finishRun(T),K(`Run finished: ${T}`),await pn()}catch(x){K(`Run finish error: ${x instanceof Error?x.message:String(x)}`)}}async function wr(){le(!0),oe("");try{K("Starting eval in v2 contour.");const x=k.batchQuestionsRaw.trim()||k.userQuestion.trim();if(!x)throw new Error("Fill batch field or Raw user question first.");const O=await Ue.runEval({connection:a,prompts:p,promptVersion:"normalizer_v2_0_2",mode:"single-pass-strict",rawQuestions:x,useMock:b});de(O.report),K("Eval v2.0.2 run finished.");const B=O.report;if(B.run_id&&K(`Eval run id: ${B.run_id}`),B.metrics){const Ie=B.metrics;K(`Eval metrics v2.0.2: schema=${Ie.schema_validation_pass_rate??"n/a"}%, route_accuracy=${Ie.route_resolution_accuracy??"n/a"}%, no_route_precision=${Ie.no_route_precision??"n/a"}%, state_consistency=${Ie.execution_state_consistency_rate??"n/a"}%`)}await tt()}catch(x){const O=x instanceof Error?x.message:String(x);O.includes("Legacy eval runner supports normalized_query_v1 only")?(de({status:"plan_only",prompt_version:"normalizer_v2",reason:"backend eval runner is still legacy-v1 only",plan_file:"reports/v2_pilot_eval_plan.md",next_steps:["run cheap mock sanity for schema/fragment/scope","run small real batch (10-15 messages, temperature=0)","run challenge-30 replay with v2 metrics"]}),K("Backend is legacy-only for eval right now. Showing v2 pilot plan.")):(oe(`Eval: ${O}`),K(`Eval run error: ${O}`))}finally{le(!1)}}async function il(){try{const x=JSON.stringify(ee??{},null,2);await navigator.clipboard.writeText(x),K("Eval report copied to clipboard.")}catch(x){K(`Eval report copy error: ${x instanceof Error?x.message:String(x)}`)}}function In(){et(""),yt([]),ge(""),Se(""),Nt(""),K("Assistant session reset.")}async function jr(){const x=xt.trim();if(!x)return;dn(!0),Nt(""),ge(""),yt(B=>[...B,{message_id:`local-${Date.now()}`,session_id:ie||"pending",role:"user",text:x,reply_type:null,created_at:new Date().toISOString(),trace_id:null,debug:null}]);const O=fn();try{const B=await Ue.sendAssistantMessage({connection:a,prompts:p,userMessage:x,sessionId:ie||void 0,promptVersion:nc,context:{periodHint:k.periodHint,businessContext:k.businessContext},useMock:b});et(B.session_id),yt(B.conversation),Se("Ответ готов"),K(`Assistant reply received: trace=${B.debug.trace_id}`)}catch(B){const Ie=B instanceof Error?B.message:String(B);Nt(Ie),Se("Ошибка ассистента"),K(`Assistant error: ${Ie}`)}finally{O(),dn(!1)}}return P.useEffect(()=>{if(!T){Y([]);return}Ue.runTrace(T).then(x=>Y(x.items)).catch(x=>K(`Run trace error: ${x instanceof Error?x.message:String(x)}`))},[T]),o.jsxs("main",{className:`app-root ${ke==="autoruns"?"app-root-autoruns":""}`,children:[o.jsxs("header",{className:"app-topbar",children:[o.jsxs("div",{className:"mode-switch-row",children:[o.jsx("button",{type:"button",className:ke==="assistant"?"tab active":"tab",onClick:()=>Ot("assistant"),children:"Ассистент"}),o.jsx("button",{type:"button",className:ke==="decomposition"?"tab active":"tab",onClick:()=>Ot("decomposition"),children:"Декомпозиция"}),o.jsx("button",{type:"button",className:ke==="autoruns"?"tab active":"tab",onClick:()=>Ot("autoruns"),children:"История автопрогонов"})]}),ke==="autoruns"?o.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[o.jsx("button",{type:"button",className:an?"tab active":"tab",onClick:()=>Gt(x=>!x),children:"Режим ассистента"}),o.jsx("button",{type:"button",className:kt?"tab active":"tab",onClick:()=>Dn(x=>!x),children:"Режим декомпозиции"}),o.jsx("button",{type:"button",className:un?"tab active":"tab",onClick:()=>ct(x=>!x),children:"Прогресс/регресс"})]}):null]}),ke==="assistant"?o.jsxs("div",{className:"layout-grid",children:[o.jsx(Zu,{value:a,modelOptions:ye,modelsBusy:G,onChange:h,onReloadModels:hn,onSaveLocalConfig:Dt,onTestConnection:mn,lastStatus:xe,busy:me||cn}),o.jsx(bu,{value:p,onChange:D,presets:X,selectedPresetId:Ne,onSelectPreset:ut,onLoadPreset:E,onSavePreset:ne,onResetDefaults:Ee,onDiffPrevious:Jt,presetName:be,onPresetNameChange:gt,diffSummary:Oe}),o.jsx(kf,{sessionId:ie,conversation:Mt,inputValue:xt,onInputChange:ge,periodHint:k.periodHint,onPeriodHintChange:x=>F(O=>({...O,periodHint:x})),businessContext:k.businessContext,onBusinessContextChange:x=>F(O=>({...O,businessContext:x})),useMock:b,onUseMockChange:pe,onSend:jr,onClear:In,busy:cn,statusText:Jn,errorMessage:Ct})]}):ke==="decomposition"?o.jsxs("div",{className:"layout-grid",children:[o.jsx(Zu,{value:a,modelOptions:ye,modelsBusy:G,onChange:h,onReloadModels:hn,onSaveLocalConfig:Dt,onTestConnection:mn,lastStatus:xe,busy:me}),o.jsx(bu,{value:p,onChange:D,presets:X,selectedPresetId:Ne,onSelectPreset:ut,onLoadPreset:E,onSavePreset:ne,onResetDefaults:Ee,onDiffPrevious:Jt,presetName:be,onPresetNameChange:gt,diffSummary:Oe}),o.jsx(Tf,{value:k,onChange:F,onApplyBatchFormat:Xn,onNormalize:c,busy:me,useMock:b,onUseMockChange:pe,errorMessage:ae}),o.jsx(Rf,{tab:L,onTabChange:Le,result:H,appLogs:ce}),o.jsx(Nf,{result:H}),o.jsx(Cf,{items:N,onRefresh:tt,onOpenTrace:Zn}),o.jsx(Lf,{runs:R,selectedRunId:T,onSelectRun:m,onStartRun:sl,onFinishRun:ol,onRefreshRuns:pn,onRunEval:wr,onCopyEvalReport:il,evalBusy:J,traceItems:_,evalReport:ee})]}):o.jsx("div",{className:"layout-grid layout-grid-autoruns",children:o.jsx(hf,{connection:a,prompts:p,assistantPromptVersion:nc,decompositionPromptVersion:si,showAssistantMode:an,showDecompositionMode:kt,showProgressMode:un,onLog:K})})]})}af.createRoot(document.getElementById("root")).render(o.jsx(ef.StrictMode,{children:o.jsx(Ff,{})})); diff --git a/llm_normalizer/frontend/dist/index.html b/llm_normalizer/frontend/dist/index.html index 08a87f5..3364b41 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 d98c6ba..8c9aef9 100644 --- a/llm_normalizer/frontend/src/components/AutoRunsHistoryPanel.tsx +++ b/llm_normalizer/frontend/src/components/AutoRunsHistoryPanel.tsx @@ -568,14 +568,16 @@ export function AutoRunsHistoryPanel({ >
-

Левая панель

-
+
+

Левая панель

+
+
{leftTab === "settings" ? ( @@ -935,7 +937,9 @@ export function AutoRunsHistoryPanel({
-

Выдача прогонов

+
+

Выдача прогонов

+
Всего @@ -992,8 +996,9 @@ export function AutoRunsHistoryPanel({
-

Диалог прогона

-
+
+

Диалог прогона

+