@cartanova/qgrid-cli 2.5.3 → 2.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.ko.md +7 -2
  2. package/README.md +7 -2
  3. package/bundle/dist/application/monit/monit.frame.js +3 -3
  4. package/bundle/dist/application/qgrid/oauth.js +1 -1
  5. package/bundle/dist/application/qgrid/qgrid.dispatcher.js +36 -14
  6. package/bundle/dist/application/qgrid/qgrid.frame.js +19 -5
  7. package/bundle/dist/application/qgrid/tool-emulation-schema.js +93 -0
  8. package/bundle/dist/application/qgrid/tool-emulation.js +116 -96
  9. package/bundle/dist/application/request-log/request-log.model.js +3 -3
  10. package/bundle/dist/application/request-log-step/request-log-step.model.js +2 -2
  11. package/bundle/dist/application/token/token.model.js +2 -2
  12. package/bundle/dist/server-error-handler.js +15 -0
  13. package/bundle/dist/sonamu.config.js +4 -7
  14. package/bundle/dist/utils/providers/anthropic/anthropic-dispatcher.js +4 -3
  15. package/bundle/dist/utils/providers/anthropic/claude-session.js +7 -5
  16. package/bundle/dist/utils/providers/common/json-schema-keywords.js +77 -0
  17. package/bundle/dist/utils/providers/common/schema-validation.js +178 -0
  18. package/bundle/dist/utils/providers/common/strictifier.js +332 -42
  19. package/bundle/dist/utils/providers/openai/codex-worker.js +16 -8
  20. package/bundle/dist/utils/providers/openai/openai-dispatcher.js +5 -37
  21. package/bundle/dist/utils/providers/openai/openai-worker-pool-config.js +37 -0
  22. package/bundle/src/application/monit/monit.frame.ts +1 -1
  23. package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +103 -0
  24. package/bundle/src/application/qgrid/qgrid.dispatcher.test.ts +337 -0
  25. package/bundle/src/application/qgrid/qgrid.dispatcher.ts +45 -25
  26. package/bundle/src/application/qgrid/qgrid.frame.test.ts +580 -8
  27. package/bundle/src/application/qgrid/qgrid.frame.ts +28 -1
  28. package/bundle/src/application/qgrid/tool-emulation-schema.test.ts +188 -0
  29. package/bundle/src/application/qgrid/tool-emulation-schema.ts +177 -0
  30. package/bundle/src/application/qgrid/tool-emulation.test.ts +285 -67
  31. package/bundle/src/application/qgrid/tool-emulation.ts +199 -102
  32. package/bundle/src/server-error-handler.ts +22 -0
  33. package/bundle/src/sonamu.config.test.ts +37 -0
  34. package/bundle/src/sonamu.config.ts +2 -5
  35. package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.test.ts +44 -0
  36. package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.ts +2 -2
  37. package/bundle/src/utils/providers/anthropic/claude-session.test.ts +10 -0
  38. package/bundle/src/utils/providers/anthropic/claude-session.ts +6 -1
  39. package/bundle/src/utils/providers/common/json-schema-keywords.ts +72 -0
  40. package/bundle/src/utils/providers/common/schema-validation.test.ts +284 -0
  41. package/bundle/src/utils/providers/common/schema-validation.ts +308 -0
  42. package/bundle/src/utils/providers/common/strictifier.test.ts +746 -0
  43. package/bundle/src/utils/providers/common/strictifier.ts +520 -52
  44. package/bundle/src/utils/providers/openai/codex-worker.test.ts +31 -0
  45. package/bundle/src/utils/providers/openai/codex-worker.ts +12 -4
  46. package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +6 -4
  47. package/bundle/src/utils/providers/openai/openai-dispatcher.ts +6 -79
  48. package/bundle/src/utils/providers/openai/openai-worker-pool-config.ts +80 -0
  49. package/bundle/web-dist/client/assets/{index-DXdGBfB8.js → index-CN_kMswh.js} +3 -3
  50. package/bundle/web-dist/client/assets/{logs-D_j1yxC4.js → logs-6nYj9OKL.js} +1 -1
  51. package/bundle/web-dist/client/assets/{monit-CIToyoxW.js → monit-CaPH9Uwc.js} +1 -1
  52. package/bundle/web-dist/client/assets/{routes-Dd21A-wi.js → routes-Dh5HPi-b.js} +1 -1
  53. package/bundle/web-dist/client/assets/{show-DfePWRbc.js → show-Be_LVd9d.js} +1 -1
  54. package/bundle/web-dist/client/assets/{tokens-B4MV2fdk.js → tokens-CAi3zu_0.js} +1 -1
  55. package/bundle/web-dist/client/index.html +1 -1
  56. package/bundle/web-dist/server/entry-server.generated.js +1 -1
  57. package/package.json +1 -1
  58. package/skills/qgrid/references/ai-sdk-provider-contract.md +34 -2
  59. package/skills/qgrid/references/anthropic-claude-code-runtime.md +3 -0
  60. package/skills/qgrid/references/cli-env-and-server-boot.md +1 -1
  61. package/skills/qgrid/references/decision-rationale.md +10 -1
  62. package/skills/qgrid/references/docs-workflow.md +9 -0
  63. package/skills/qgrid/references/repo-map.md +2 -1
  64. package/skills/qgrid/references/tool-calling-and-multiturn.md +145 -6
  65. package/skills/qgrid/references/verification-and-debugging.md +16 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime-Dw2cE7zH.js";import{l as e,u as t}from"./vendor-tanstack-DJRQAbrY.js";import{i as n,r}from"./vendor-react-DH4kUfK2.js";import{d as i,f as a,u as o}from"./sd.generated-DbBC73_z.js";import{n as s}from"./index-DXdGBfB8.js";import{n as c,r as l,t as u}from"./cost-CpjVoAqp.js";import{a as d,n as f,r as p}from"./services.generated-BWyAypSh.js";n();var m=r(),h=e=>(0,m.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,m.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m15 18l-6-6l6-6`})}),g=e=>(0,m.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,m.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m9 18l6-6l-6-6`})}),_=50,v=`__unassigned__`;function y(e){let t=new Date(e);return`${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function b(e){return e.toLocaleString()}function x(e){let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}function S({status:e,requestedModel:t,servedModel:n,fallbackCount:r}){if(e===`running`)return(0,m.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-blue-100 text-blue-600 font-medium whitespace-nowrap`,children:`실행 중`});let i=t!==null&&n!==null&&t!==n,a=t!==null&&n===null;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`text-xs text-sand-500`,children:i?`${t} → ${n}`:n??t??`—`}),a&&(0,m.jsx)(`span`,{className:`ml-1 text-[9px] text-sand-400`,children:`요청`}),(r??0)>0&&(0,m.jsxs)(`span`,{className:`ml-1 text-[9px] text-caution-500`,children:[`×`,r]})]})}function C(e){return e<=0?`—`:e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}var w=[{label:`ID`,align:`left`,width:`w-12`},{label:`Date`,align:`left`,width:`w-20`},{label:`Project`,align:`left`,width:`w-20`},{label:`Token`,align:`left`,width:`w-24`},{label:`Model`,align:`left`,width:`w-20`},{label:`TTFT`,align:`left`,width:`w-16`},{label:`Duration`,align:`left`,width:`w-20`},{label:`In`,align:`left`,width:`w-16`},{label:`Out`,align:`left`,width:`w-20`},{label:`C.Read`,align:`left`,width:`w-20`},{label:`C.Write`,align:`left`,width:`w-20`},{label:`Hit`,align:`left`,width:`w-14`},{label:`Tools`,align:`left`,width:`w-14`},{label:`Cost`,align:`left`,width:`w-20`}];function T({search:n,onSearchChange:r}){let i=t(),a=n.page??1,o=n.token??``,s=n.project??``,{data:T}=d.useTokens(`A`),E=(T?.rows??[]).map(e=>e.name).filter(Boolean),{data:D}=f.useProjectNames(),O=D?.names??[],k=s===v?{project_name_is_null:!0}:s?{project_name:s}:{},{data:A,isLoading:j}=p.useRequestLogs(`P`,{num:_,page:a,orderBy:`id-desc`,...o?{token_name:o}:{},...k}),{data:M}=f.useTotalCost(o||void 0),N=A?.rows??[],P=A?.total??0,F=Math.ceil(P/_),I=e=>{r({...n,...e,page:1})};return(0,m.jsxs)(`div`,{className:`panel overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`panel-header flex items-center gap-3 px-5 py-2.5 flex-wrap`,children:[E.length>0&&(0,m.jsxs)(`select`,{value:o,onChange:e=>I({token:e.target.value||void 0}),className:`border border-sand-200/80 rounded-lg px-2.5 py-1.5 text-[11px] text-sand-700 bg-sand-50/50 focus:outline-none focus:border-sienna-300`,children:[(0,m.jsx)(`option`,{value:``,children:`All Tokens`}),E.map(e=>(0,m.jsx)(`option`,{value:e,children:e},e))]}),(0,m.jsxs)(`select`,{value:s,onChange:e=>I({project:e.target.value||void 0}),className:`border border-sand-200/80 rounded-lg px-2.5 py-1.5 text-[11px] text-sand-700 bg-sand-50/50 focus:outline-none focus:border-sienna-300`,children:[(0,m.jsx)(`option`,{value:``,children:`All Projects`}),(0,m.jsx)(`option`,{value:v,children:`(unassigned)`}),O.map(e=>(0,m.jsx)(`option`,{value:e,children:e},e))]}),(0,m.jsx)(`div`,{className:`flex-1`}),(0,m.jsxs)(`span`,{className:`text-[11px] text-sand-400`,children:[P,` results`]}),(0,m.jsx)(`span`,{className:`text-[11px] tabular-nums font-medium text-sienna-600`,children:l(M?.usd??0)})]}),j?(0,m.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:5}).map((e,t)=>(0,m.jsx)(`div`,{className:`h-8 bg-sand-100 rounded animate-pulse`},`skel-${t}`))}):N.length===0?(0,m.jsx)(`div`,{className:`text-sand-400 text-center py-12 text-sm`,children:`No requests yet.`}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`overflow-x-auto px-5 py-3`,children:(0,m.jsxs)(`table`,{className:`w-full text-[13px]`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`border-b border-sand-100/60`,children:[w.map(e=>{let t=e.label===`Duration`?`pl-5 pr-3`:e.width?`px-4`:`px-3`;return(0,m.jsx)(`th`,{className:`text-${e.align} ${e.width??``} ${e.width?`whitespace-nowrap`:``} ${t} py-1.5 text-[10px] uppercase text-sand-400 font-medium`,children:e.label},e.label)}),(0,m.jsx)(`th`,{className:`w-8`})]})}),(0,m.jsx)(`tbody`,{className:`divide-y divide-sand-100/60`,children:N.map(t=>(0,m.jsxs)(`tr`,{className:`transition-colors duration-150 hover:bg-sand-100/60 cursor-pointer`,onClick:e=>{if(e.metaKey||e.ctrlKey){window.open(`/requests/show?id=${t.id}`,`_blank`);return}i({to:`/requests/show`,search:{id:t.id}})},children:[(0,m.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,m.jsx)(e,{to:`/requests/show`,search:{id:t.id},onClick:e=>e.stopPropagation(),className:`text-xs text-sand-500 tabular-nums hover:text-sienna-500`,children:t.id})}),(0,m.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,m.jsx)(`span`,{className:`text-xs text-sand-400 tabular-nums`,children:y(t.created_at)})}),(0,m.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,m.jsx)(`span`,{className:`text-xs text-sand-600`,children:t.project_name??`—`})}),(0,m.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,m.jsx)(`span`,{className:`text-xs text-sand-500`,children:t.token_name})}),(0,m.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,m.jsx)(S,{status:t.status,requestedModel:t.requested_model_name,servedModel:t.model_name,fallbackCount:t.fallback_count})}),(0,m.jsx)(`td`,{className:`px-4 py-1.5 text-left tabular-nums text-sand-500 whitespace-nowrap`,children:C(t.ttft_ms)}),(0,m.jsx)(`td`,{className:`pl-5 pr-3 py-1.5 text-left tabular-nums text-sand-500 whitespace-nowrap`,children:x(t.duration_ms)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:b(t.input_tokens)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:b(t.output_tokens)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:b(t.cache_read_tokens)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:b(t.cache_creation_tokens)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:u(t)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-500`,children:t.tool_call_count>0?t.tool_call_count:`—`}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:t.image_cost_usd===null?t.cost_usd===null?`—`:c(t.cost_usd):c((t.cost_usd??0)+t.image_cost_usd)}),(0,m.jsx)(`td`,{className:`px-2 py-1.5`,children:(0,m.jsx)(g,{className:`size-4 text-sand-400`})})]},t.id))})]})}),F>1&&(0,m.jsxs)(`div`,{className:`flex items-center justify-center gap-3 px-5 py-2.5 border-t border-sand-100/60`,children:[(0,m.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:a===1,onClick:()=>r({...n,page:a-1}),children:(0,m.jsx)(h,{className:`size-4`})}),(0,m.jsxs)(`span`,{className:`text-[11px] text-sand-400 tabular-nums`,children:[a,` / `,F]}),(0,m.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:a===F,onClick:()=>r({...n,page:a+1}),children:(0,m.jsx)(g,{className:`size-4`})})]})]})]})}i({token:a().optional(),project:a().optional(),page:o().optional().default(1)});function E(){let e=s.useSearch(),t=s.useNavigate();return(0,m.jsx)(`div`,{className:`max-w-[100rem] mx-auto`,children:(0,m.jsx)(T,{search:e,onSearchChange:e=>t({search:e})})})}export{E as component};
1
+ import"./rolldown-runtime-Dw2cE7zH.js";import{l as e,u as t}from"./vendor-tanstack-DJRQAbrY.js";import{i as n,r}from"./vendor-react-DH4kUfK2.js";import{d as i,f as a,u as o}from"./sd.generated-DbBC73_z.js";import{n as s}from"./index-CN_kMswh.js";import{n as c,r as l,t as u}from"./cost-CpjVoAqp.js";import{a as d,n as f,r as p}from"./services.generated-BWyAypSh.js";n();var m=r(),h=e=>(0,m.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,m.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m15 18l-6-6l6-6`})}),g=e=>(0,m.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,m.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m9 18l6-6l-6-6`})}),_=50,v=`__unassigned__`;function y(e){let t=new Date(e);return`${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function b(e){return e.toLocaleString()}function x(e){let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}function S({status:e,requestedModel:t,servedModel:n,fallbackCount:r}){if(e===`running`)return(0,m.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-blue-100 text-blue-600 font-medium whitespace-nowrap`,children:`실행 중`});let i=t!==null&&n!==null&&t!==n,a=t!==null&&n===null;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`text-xs text-sand-500`,children:i?`${t} → ${n}`:n??t??`—`}),a&&(0,m.jsx)(`span`,{className:`ml-1 text-[9px] text-sand-400`,children:`요청`}),(r??0)>0&&(0,m.jsxs)(`span`,{className:`ml-1 text-[9px] text-caution-500`,children:[`×`,r]})]})}function C(e){return e<=0?`—`:e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}var w=[{label:`ID`,align:`left`,width:`w-12`},{label:`Date`,align:`left`,width:`w-20`},{label:`Project`,align:`left`,width:`w-20`},{label:`Token`,align:`left`,width:`w-24`},{label:`Model`,align:`left`,width:`w-20`},{label:`TTFT`,align:`left`,width:`w-16`},{label:`Duration`,align:`left`,width:`w-20`},{label:`In`,align:`left`,width:`w-16`},{label:`Out`,align:`left`,width:`w-20`},{label:`C.Read`,align:`left`,width:`w-20`},{label:`C.Write`,align:`left`,width:`w-20`},{label:`Hit`,align:`left`,width:`w-14`},{label:`Tools`,align:`left`,width:`w-14`},{label:`Cost`,align:`left`,width:`w-20`}];function T({search:n,onSearchChange:r}){let i=t(),a=n.page??1,o=n.token??``,s=n.project??``,{data:T}=d.useTokens(`A`),E=(T?.rows??[]).map(e=>e.name).filter(Boolean),{data:D}=f.useProjectNames(),O=D?.names??[],k=s===v?{project_name_is_null:!0}:s?{project_name:s}:{},{data:A,isLoading:j}=p.useRequestLogs(`P`,{num:_,page:a,orderBy:`id-desc`,...o?{token_name:o}:{},...k}),{data:M}=f.useTotalCost(o||void 0),N=A?.rows??[],P=A?.total??0,F=Math.ceil(P/_),I=e=>{r({...n,...e,page:1})};return(0,m.jsxs)(`div`,{className:`panel overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`panel-header flex items-center gap-3 px-5 py-2.5 flex-wrap`,children:[E.length>0&&(0,m.jsxs)(`select`,{value:o,onChange:e=>I({token:e.target.value||void 0}),className:`border border-sand-200/80 rounded-lg px-2.5 py-1.5 text-[11px] text-sand-700 bg-sand-50/50 focus:outline-none focus:border-sienna-300`,children:[(0,m.jsx)(`option`,{value:``,children:`All Tokens`}),E.map(e=>(0,m.jsx)(`option`,{value:e,children:e},e))]}),(0,m.jsxs)(`select`,{value:s,onChange:e=>I({project:e.target.value||void 0}),className:`border border-sand-200/80 rounded-lg px-2.5 py-1.5 text-[11px] text-sand-700 bg-sand-50/50 focus:outline-none focus:border-sienna-300`,children:[(0,m.jsx)(`option`,{value:``,children:`All Projects`}),(0,m.jsx)(`option`,{value:v,children:`(unassigned)`}),O.map(e=>(0,m.jsx)(`option`,{value:e,children:e},e))]}),(0,m.jsx)(`div`,{className:`flex-1`}),(0,m.jsxs)(`span`,{className:`text-[11px] text-sand-400`,children:[P,` results`]}),(0,m.jsx)(`span`,{className:`text-[11px] tabular-nums font-medium text-sienna-600`,children:l(M?.usd??0)})]}),j?(0,m.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:5}).map((e,t)=>(0,m.jsx)(`div`,{className:`h-8 bg-sand-100 rounded animate-pulse`},`skel-${t}`))}):N.length===0?(0,m.jsx)(`div`,{className:`text-sand-400 text-center py-12 text-sm`,children:`No requests yet.`}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`overflow-x-auto px-5 py-3`,children:(0,m.jsxs)(`table`,{className:`w-full text-[13px]`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`border-b border-sand-100/60`,children:[w.map(e=>{let t=e.label===`Duration`?`pl-5 pr-3`:e.width?`px-4`:`px-3`;return(0,m.jsx)(`th`,{className:`text-${e.align} ${e.width??``} ${e.width?`whitespace-nowrap`:``} ${t} py-1.5 text-[10px] uppercase text-sand-400 font-medium`,children:e.label},e.label)}),(0,m.jsx)(`th`,{className:`w-8`})]})}),(0,m.jsx)(`tbody`,{className:`divide-y divide-sand-100/60`,children:N.map(t=>(0,m.jsxs)(`tr`,{className:`transition-colors duration-150 hover:bg-sand-100/60 cursor-pointer`,onClick:e=>{if(e.metaKey||e.ctrlKey){window.open(`/requests/show?id=${t.id}`,`_blank`);return}i({to:`/requests/show`,search:{id:t.id}})},children:[(0,m.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,m.jsx)(e,{to:`/requests/show`,search:{id:t.id},onClick:e=>e.stopPropagation(),className:`text-xs text-sand-500 tabular-nums hover:text-sienna-500`,children:t.id})}),(0,m.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,m.jsx)(`span`,{className:`text-xs text-sand-400 tabular-nums`,children:y(t.created_at)})}),(0,m.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,m.jsx)(`span`,{className:`text-xs text-sand-600`,children:t.project_name??`—`})}),(0,m.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,m.jsx)(`span`,{className:`text-xs text-sand-500`,children:t.token_name})}),(0,m.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,m.jsx)(S,{status:t.status,requestedModel:t.requested_model_name,servedModel:t.model_name,fallbackCount:t.fallback_count})}),(0,m.jsx)(`td`,{className:`px-4 py-1.5 text-left tabular-nums text-sand-500 whitespace-nowrap`,children:C(t.ttft_ms)}),(0,m.jsx)(`td`,{className:`pl-5 pr-3 py-1.5 text-left tabular-nums text-sand-500 whitespace-nowrap`,children:x(t.duration_ms)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:b(t.input_tokens)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:b(t.output_tokens)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:b(t.cache_read_tokens)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:b(t.cache_creation_tokens)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:u(t)}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-500`,children:t.tool_call_count>0?t.tool_call_count:`—`}),(0,m.jsx)(`td`,{className:`px-3 py-1.5 text-left tabular-nums text-sand-700`,children:t.image_cost_usd===null?t.cost_usd===null?`—`:c(t.cost_usd):c((t.cost_usd??0)+t.image_cost_usd)}),(0,m.jsx)(`td`,{className:`px-2 py-1.5`,children:(0,m.jsx)(g,{className:`size-4 text-sand-400`})})]},t.id))})]})}),F>1&&(0,m.jsxs)(`div`,{className:`flex items-center justify-center gap-3 px-5 py-2.5 border-t border-sand-100/60`,children:[(0,m.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:a===1,onClick:()=>r({...n,page:a-1}),children:(0,m.jsx)(h,{className:`size-4`})}),(0,m.jsxs)(`span`,{className:`text-[11px] text-sand-400 tabular-nums`,children:[a,` / `,F]}),(0,m.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:a===F,onClick:()=>r({...n,page:a+1}),children:(0,m.jsx)(g,{className:`size-4`})})]})]})]})}i({token:a().optional(),project:a().optional(),page:o().optional().default(1)});function E(){let e=s.useSearch(),t=s.useNavigate();return(0,m.jsx)(`div`,{className:`max-w-[100rem] mx-auto`,children:(0,m.jsx)(T,{search:e,onSearchChange:e=>t({search:e})})})}export{E as component};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{_ as t}from"./vendor-tanstack-DJRQAbrY.js";import{i as n,n as r,r as i}from"./vendor-react-DH4kUfK2.js";import{d as a,l as o}from"./sd.generated-DbBC73_z.js";import{a as s,r as c}from"./index-DXdGBfB8.js";import{t as l}from"./services.generated-BWyAypSh.js";var u=e(n(),1),d=e(r(),1);function f(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function p(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function m(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var h=(e,t)=>Math.abs(e-t)<1.01,g=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},_,v=()=>{if(_!==void 0)return _;if(typeof navigator>`u`)return _=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return _=!0;let e=navigator.maxTouchPoints;return _=navigator.platform===`MacIntel`&&e!==void 0&&e>0},y=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},b=e=>e,x=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},S=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(y(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(y(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},C={passive:!0},w=typeof window>`u`?!0:`onscrollend`in window,T=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&w,o=0,s=a?null:g(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,C),a&&r.addEventListener(`scrollend`,u,C),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},E=(e,t)=>T(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),D=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},O=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},k=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:b,rangeExtractor:x,onChange:()=>{},measureElement:D,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=e.start+t;n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=p(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!v()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,C),e.addEventListener(`touchend`,n,C),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(v()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=p(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.getMeasurements=p(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=f(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),p=Array(a).fill(void 0),m=new Float64Array(a),h=0;for(let e=0;e<u;e++){let t=d[e];t&&(p[t.lane]===void 0&&h++,p[t.lane]=e,m[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,f,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=p[u],r=e===void 0?void 0:d[e];f=r?r.end+s:t+n}else if(h===a){let e=0,t=m[0],n=p[0];for(let r=1;r<a;r++){let i=m[r];(i<t||i===t&&p[r]<n)&&(e=r,t=i,n=p[r])}u=e,f=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,f=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=f+v;d[i]={index:i,start:f,size:v,end:y,key:e,lane:u},p[u]===void 0&&h++,p[u]=i,m[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=p(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=M(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=p(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(i)||this.scrollDirection!==`backward`):this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=p(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return m(t[A(0,t.length-1,r?e=>n[e*2]:e=>m(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(v()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&h(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},A=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function j(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function M(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=j(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=A(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var N=typeof document<`u`?u.useLayoutEffect:u.useEffect;function P({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=u.useReducer(e=>e+1,0)[1],a=u.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}let r=!!e.options.horizontal,i=t.mode===`transform`,o=r?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let n of c){let a=n.start-s,c=e.elementsCache.get(n.key);c&&t.lastPositions.get(c)!==a&&(t.lastPositions.set(c,a),i?c.style.transform=r?`translate3d(${a}px, 0, 0)`:`translate3d(0, ${a}px, 0)`:c.style[o]=`${a}px`)}},s={...r,onChange:(t,n)=>{var s;let c=a.current,l=!0;if(c.enabled){o(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,d.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=u.useState(()=>{let e=new k(s);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return c.setOptions(s),N(()=>c._didMount(),[]),N(()=>c._willUpdate()),N(()=>{o(c)}),c}function F(e){return P({observeElementRect:S,observeElementOffset:E,scrollToFn:O,...e})}var I=i(),L=e=>(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,I.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,I.jsx)(`path`,{d:`M3 12a9 9 0 0 1 9-9a9.75 9.75 0 0 1 6.74 2.74L21 8`}),(0,I.jsx)(`path`,{d:`M21 3v5h-5m5 4a9 9 0 0 1-9 9a9.75 9.75 0 0 1-6.74-2.74L3 16`}),(0,I.jsx)(`path`,{d:`M8 16H3v5`})]})}),R=1e3,z=5e3,B=4e3,V={trace:0,debug:1,info:2,warning:3,error:4,fatal:5},H=/autoscale|worker/i,U={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},W=new Intl.DateTimeFormat(`en-GB`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function G(e){return W.format(new Date(e))}function K(e){return e.join(`·`)}function q({search:e,onSearchChange:n}){let[r,i]=(0,u.useState)([]),a=(0,u.useRef)(void 0),o=(0,u.useRef)(void 0),c=(0,u.useRef)(0),[d,f]=(0,u.useState)(()=>Date.now()),p=t({queryKey:[`Monit`,`monitLogs`],queryFn:()=>l.monitLogs(a.current),refetchInterval:R,retry:!1}),m=t({...l.monitInfoQueryOptions(),staleTime:1/0}).data,h=p.data?.vitals;(0,u.useEffect)(()=>{let e=p.data;e&&g(e)},[p.data]);function g(e){let t=()=>++c.current;i(n=>{let r=n,i=[];o.current!==void 0&&e.processStartedAt!==o.current?(r=[],i.push({kind:`restart`,key:t(),processStartedAt:e.processStartedAt})):e.dropped>0&&i.push({kind:`dropped`,key:t(),count:e.dropped}),o.current=e.processStartedAt,a.current=e.nextCursor;let s=r.findLast(e=>e.kind===`log`)?.entry.seq;for(let n of e.entries)s!==void 0&&n.seq<=s||i.push({kind:`log`,key:t(),entry:n});if(i.length===0)return n;let c=[...r,...i];return c.length>B?c.slice(-B):c})}(0,u.useEffect)(()=>{let e=window.setInterval(()=>f(Date.now()),2e3);return()=>window.clearInterval(e)},[]);let _=r.length>0&&(p.isRefetchError||p.dataUpdatedAt>0&&d-p.dataUpdatedAt>z),v=(0,u.useMemo)(()=>r.filter(t=>{if(t.kind!==`log`)return!0;switch(e.level){case`scaling`:return H.test(t.entry.text);case`warn`:return(V[t.entry.level]??2)>=3;case`error`:return(V[t.entry.level]??2)>=4;default:return!0}}),[r,e.level]),y=(0,u.useRef)(null),b=F({count:v.length,getScrollElement:()=>y.current,estimateSize:()=>20,getItemKey:e=>v[e].key,anchorTo:`end`,followOnAppend:!0,scrollEndThreshold:80,overscan:12}),x=b.isAtEnd(),S=p.dataUpdatedAt>0,C=!S&&p.isError;return(0,I.jsxs)(`section`,{className:`panel overflow-hidden`,children:[(0,I.jsxs)(`header`,{className:`panel-header flex min-h-11 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-2 sm:px-5`,children:[(0,I.jsx)(`h2`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-sand-800`,children:`Server logs`}),(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-sand-700`,children:[(0,I.jsx)(`span`,{className:s(`size-1.5 rounded-full`,_||C?`bg-danger-400`:`bg-sienna-500 motion-safe:animate-pulse`)}),C?`Disconnected`:_?`Stale`:S?`Live`:`…`]}),o.current!==void 0&&(0,I.jsxs)(`span`,{className:`text-[11px] text-sand-500`,children:[`ephemeral · resets on restart · since `,G(o.current)]}),(0,I.jsx)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:(0,I.jsx)(`div`,{className:`segmented-control inline-flex`,role:`tablist`,"aria-label":`Log filter`,children:[{value:`all`,label:`All`},{value:`scaling`,label:`Scaling`},{value:`warn`,label:`Warn+`},{value:`error`,label:`Err+`}].map(t=>(0,I.jsx)(`button`,{type:`button`,"data-active":e.level===t.value,onClick:()=>n({...e,level:t.value}),className:`rounded-[6px] px-2.5 py-1 text-[11px] font-medium text-sand-500 transition-colors hover:text-sand-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sienna-300 data-[active=true]:text-sand-900`,children:t.label},t.value))})})]}),m&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-1 border-b border-sand-100 bg-sand-50/60 px-4 py-2 text-[11px] text-sand-600 sm:px-5`,children:[(0,I.jsxs)(`span`,{children:[`server `,(0,I.jsx)(`span`,{className:`font-mono text-sand-800`,children:m.serverUrl})]}),(0,I.jsxs)(`span`,{children:[`db`,` `,(0,I.jsxs)(`span`,{className:`font-mono text-sand-800`,children:[m.dbHost,`/`,m.dbName]})]}),(0,I.jsxs)(`span`,{children:[`workers/token`,` `,(0,I.jsxs)(`span`,{className:`font-mono text-sand-800`,children:[m.openai.minWorkersPerToken,`–`,m.openai.maxWorkersPerToken]}),` `,m.openai.autoscale?`autoscale`:`fixed`]}),h&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{children:[`openai workers`,` `,(0,I.jsxs)(`span`,{className:`font-mono text-sand-800`,children:[h.openaiReadyWorkerCount,`/`,h.openaiWorkerCount]}),` `,`ready`]}),(0,I.jsxs)(`span`,{children:[`queue`,` `,(0,I.jsx)(`span`,{className:s(`font-mono`,h.openaiQueueLength>0?`font-semibold text-caution-500`:`text-sand-800`),children:h.openaiQueueLength})]})]})]}),h&&(h.openaiWorkersByToken.length>0||h.anthropicTokenNames.length>0)&&(0,I.jsxs)(`div`,{className:`space-y-1.5 border-b border-sand-100 px-4 py-2.5 sm:px-5`,children:[h.openaiWorkersByToken.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`w-[4.5rem] shrink-0 text-[10px] font-medium uppercase tracking-[0.08em] text-sand-400`,children:`openai`}),h.openaiWorkersByToken.map(e=>(0,I.jsxs)(`span`,{title:`${e.name}: ${e.count} workers`,className:`inline-flex items-baseline gap-1.5 rounded-md border border-sand-200 bg-white px-2 py-1`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-sand-600`,children:e.name.split(`/`).pop()}),(0,I.jsx)(`span`,{className:`font-mono text-[13px] font-semibold tracking-[-0.02em] text-sand-900`,children:e.count})]},e.name))]}),h.anthropicTokenNames.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`w-[4.5rem] shrink-0 text-[10px] font-medium uppercase tracking-[0.08em] text-sand-400`,children:`anthropic`}),h.anthropicTokenNames.map(e=>(0,I.jsx)(`span`,{title:e,className:`inline-flex items-baseline rounded-md border border-sand-200 bg-white px-2 py-1 font-mono text-[11px] text-sand-600`,children:e.split(`/`).pop()},e))]})]}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`div`,{ref:y,role:`log`,"aria-label":`Server process logs`,tabIndex:0,className:`main-scroll h-[calc(100vh-232px)] min-h-[320px] overflow-y-auto bg-sand-900 px-4 py-3 font-mono text-[12px] leading-[1.6] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-sienna-400`,children:C?(0,I.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-sand-400`,children:[(0,I.jsxs)(`p`,{className:`text-[12px]`,children:[`Could not reach the qgrid server — is it running?`,p.error instanceof Error&&(0,I.jsx)(`span`,{className:`block text-center text-[11px] text-sand-500`,children:p.error.message})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>void p.refetch(),className:`inline-flex items-center gap-1.5 rounded-md border border-sand-600 px-2.5 py-1.5 text-[11px] font-medium text-sand-300 transition-colors hover:bg-sand-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sienna-400`,children:[(0,I.jsx)(L,{className:`size-3`}),`Retry now`]})]}):S?v.length===0?(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-sand-500`,children:r.length===0?`No log lines yet — waiting for activity since ${o.current===void 0?`startup`:G(o.current)}.`:`No lines match the current filters.`}):(0,I.jsx)(`div`,{className:`relative w-full`,style:{height:`${b.getTotalSize()}px`},children:b.getVirtualItems().map(e=>{let t=v[e.index];return(0,I.jsx)(`div`,{ref:b.measureElement,"data-index":e.index,className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${e.start}px)`},children:(0,I.jsx)(J,{item:t})},e.key)})}):(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-sand-500`,children:`Connecting to server logs…`})}),S&&!C&&!x&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>b.scrollToEnd(),className:`absolute bottom-4 right-5 inline-flex items-center gap-1.5 rounded-full border border-sand-600 bg-sand-800/90 px-3 py-1.5 text-[11px] font-medium text-sand-200 shadow-lg backdrop-blur transition-colors hover:bg-sand-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sienna-400`,children:`↓ Jump to live`})]})]})}function J({item:e}){if(e.kind===`restart`)return(0,I.jsxs)(`div`,{className:`py-1 text-center text-[11px] text-caution-400`,children:[`── process restarted · `,G(e.processStartedAt),` ──`]});if(e.kind===`dropped`)return(0,I.jsxs)(`div`,{className:`py-1 text-center text-[11px] italic text-sand-500`,children:[`── `,e.count,` lines dropped (buffer overflow) ──`]});let{entry:t}=e;return(0,I.jsxs)(`div`,{className:`whitespace-pre-wrap break-words text-sand-200`,children:[(0,I.jsx)(`span`,{className:`text-sand-500`,children:G(t.timestamp)}),` `,(0,I.jsx)(`span`,{className:s(`font-semibold`,t.level===`fatal`||t.level===`error`?`text-danger-400`:t.level===`warning`?`text-caution-400`:`text-sand-400`),children:U[t.level]??t.level.slice(0,3).toUpperCase()}),` `,(0,I.jsx)(`span`,{className:`text-sienna-300`,children:K(t.category)}),` `,(0,I.jsx)(`span`,{children:t.text})]})}a({level:o([`all`,`scaling`,`warn`,`error`]).optional().default(`all`)});function Y(){let e=c.useSearch(),t=c.useNavigate();return(0,I.jsx)(`div`,{className:`max-w-[100rem] mx-auto`,children:(0,I.jsx)(q,{search:e,onSearchChange:e=>t({search:e,replace:!0})})})}export{Y as component};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{_ as t}from"./vendor-tanstack-DJRQAbrY.js";import{i as n,n as r,r as i}from"./vendor-react-DH4kUfK2.js";import{d as a,l as o}from"./sd.generated-DbBC73_z.js";import{a as s,r as c}from"./index-CN_kMswh.js";import{t as l}from"./services.generated-BWyAypSh.js";var u=e(n(),1),d=e(r(),1);function f(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function p(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function m(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var h=(e,t)=>Math.abs(e-t)<1.01,g=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},_,v=()=>{if(_!==void 0)return _;if(typeof navigator>`u`)return _=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return _=!0;let e=navigator.maxTouchPoints;return _=navigator.platform===`MacIntel`&&e!==void 0&&e>0},y=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},b=e=>e,x=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},S=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(y(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(y(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},C={passive:!0},w=typeof window>`u`?!0:`onscrollend`in window,T=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&w,o=0,s=a?null:g(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,C),a&&r.addEventListener(`scrollend`,u,C),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},E=(e,t)=>T(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),D=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},O=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},k=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:b,rangeExtractor:x,onChange:()=>{},measureElement:D,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=e.start+t;n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=p(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!v()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,C),e.addEventListener(`touchend`,n,C),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(v()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=p(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.getMeasurements=p(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=f(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),p=Array(a).fill(void 0),m=new Float64Array(a),h=0;for(let e=0;e<u;e++){let t=d[e];t&&(p[t.lane]===void 0&&h++,p[t.lane]=e,m[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,f,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=p[u],r=e===void 0?void 0:d[e];f=r?r.end+s:t+n}else if(h===a){let e=0,t=m[0],n=p[0];for(let r=1;r<a;r++){let i=m[r];(i<t||i===t&&p[r]<n)&&(e=r,t=i,n=p[r])}u=e,f=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,f=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=f+v;d[i]={index:i,start:f,size:v,end:y,key:e,lane:u},p[u]===void 0&&h++,p[u]=i,m[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=p(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=M(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=p(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(i)||this.scrollDirection!==`backward`):this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=p(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return m(t[A(0,t.length-1,r?e=>n[e*2]:e=>m(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(v()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&h(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},A=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function j(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function M(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=j(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=A(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var N=typeof document<`u`?u.useLayoutEffect:u.useEffect;function P({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=u.useReducer(e=>e+1,0)[1],a=u.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}let r=!!e.options.horizontal,i=t.mode===`transform`,o=r?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let n of c){let a=n.start-s,c=e.elementsCache.get(n.key);c&&t.lastPositions.get(c)!==a&&(t.lastPositions.set(c,a),i?c.style.transform=r?`translate3d(${a}px, 0, 0)`:`translate3d(0, ${a}px, 0)`:c.style[o]=`${a}px`)}},s={...r,onChange:(t,n)=>{var s;let c=a.current,l=!0;if(c.enabled){o(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,d.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=u.useState(()=>{let e=new k(s);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return c.setOptions(s),N(()=>c._didMount(),[]),N(()=>c._willUpdate()),N(()=>{o(c)}),c}function F(e){return P({observeElementRect:S,observeElementOffset:E,scrollToFn:O,...e})}var I=i(),L=e=>(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,I.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,I.jsx)(`path`,{d:`M3 12a9 9 0 0 1 9-9a9.75 9.75 0 0 1 6.74 2.74L21 8`}),(0,I.jsx)(`path`,{d:`M21 3v5h-5m5 4a9 9 0 0 1-9 9a9.75 9.75 0 0 1-6.74-2.74L3 16`}),(0,I.jsx)(`path`,{d:`M8 16H3v5`})]})}),R=1e3,z=5e3,B=4e3,V={trace:0,debug:1,info:2,warning:3,error:4,fatal:5},H=/autoscale|worker/i,U={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},W=new Intl.DateTimeFormat(`en-GB`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function G(e){return W.format(new Date(e))}function K(e){return e.join(`·`)}function q({search:e,onSearchChange:n}){let[r,i]=(0,u.useState)([]),a=(0,u.useRef)(void 0),o=(0,u.useRef)(void 0),c=(0,u.useRef)(0),[d,f]=(0,u.useState)(()=>Date.now()),p=t({queryKey:[`Monit`,`monitLogs`],queryFn:()=>l.monitLogs(a.current),refetchInterval:R,retry:!1}),m=t({...l.monitInfoQueryOptions(),staleTime:1/0}).data,h=p.data?.vitals;(0,u.useEffect)(()=>{let e=p.data;e&&g(e)},[p.data]);function g(e){let t=()=>++c.current;i(n=>{let r=n,i=[];o.current!==void 0&&e.processStartedAt!==o.current?(r=[],i.push({kind:`restart`,key:t(),processStartedAt:e.processStartedAt})):e.dropped>0&&i.push({kind:`dropped`,key:t(),count:e.dropped}),o.current=e.processStartedAt,a.current=e.nextCursor;let s=r.findLast(e=>e.kind===`log`)?.entry.seq;for(let n of e.entries)s!==void 0&&n.seq<=s||i.push({kind:`log`,key:t(),entry:n});if(i.length===0)return n;let c=[...r,...i];return c.length>B?c.slice(-B):c})}(0,u.useEffect)(()=>{let e=window.setInterval(()=>f(Date.now()),2e3);return()=>window.clearInterval(e)},[]);let _=r.length>0&&(p.isRefetchError||p.dataUpdatedAt>0&&d-p.dataUpdatedAt>z),v=(0,u.useMemo)(()=>r.filter(t=>{if(t.kind!==`log`)return!0;switch(e.level){case`scaling`:return H.test(t.entry.text);case`warn`:return(V[t.entry.level]??2)>=3;case`error`:return(V[t.entry.level]??2)>=4;default:return!0}}),[r,e.level]),y=(0,u.useRef)(null),b=F({count:v.length,getScrollElement:()=>y.current,estimateSize:()=>20,getItemKey:e=>v[e].key,anchorTo:`end`,followOnAppend:!0,scrollEndThreshold:80,overscan:12}),x=b.isAtEnd(),S=p.dataUpdatedAt>0,C=!S&&p.isError;return(0,I.jsxs)(`section`,{className:`panel overflow-hidden`,children:[(0,I.jsxs)(`header`,{className:`panel-header flex min-h-11 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-2 sm:px-5`,children:[(0,I.jsx)(`h2`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-sand-800`,children:`Server logs`}),(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-sand-700`,children:[(0,I.jsx)(`span`,{className:s(`size-1.5 rounded-full`,_||C?`bg-danger-400`:`bg-sienna-500 motion-safe:animate-pulse`)}),C?`Disconnected`:_?`Stale`:S?`Live`:`…`]}),o.current!==void 0&&(0,I.jsxs)(`span`,{className:`text-[11px] text-sand-500`,children:[`ephemeral · resets on restart · since `,G(o.current)]}),(0,I.jsx)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:(0,I.jsx)(`div`,{className:`segmented-control inline-flex`,role:`tablist`,"aria-label":`Log filter`,children:[{value:`all`,label:`All`},{value:`scaling`,label:`Scaling`},{value:`warn`,label:`Warn+`},{value:`error`,label:`Err+`}].map(t=>(0,I.jsx)(`button`,{type:`button`,"data-active":e.level===t.value,onClick:()=>n({...e,level:t.value}),className:`rounded-[6px] px-2.5 py-1 text-[11px] font-medium text-sand-500 transition-colors hover:text-sand-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sienna-300 data-[active=true]:text-sand-900`,children:t.label},t.value))})})]}),m&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-1 border-b border-sand-100 bg-sand-50/60 px-4 py-2 text-[11px] text-sand-600 sm:px-5`,children:[(0,I.jsxs)(`span`,{children:[`server `,(0,I.jsx)(`span`,{className:`font-mono text-sand-800`,children:m.serverUrl})]}),(0,I.jsxs)(`span`,{children:[`db`,` `,(0,I.jsxs)(`span`,{className:`font-mono text-sand-800`,children:[m.dbHost,`/`,m.dbName]})]}),(0,I.jsxs)(`span`,{children:[`workers/token`,` `,(0,I.jsxs)(`span`,{className:`font-mono text-sand-800`,children:[m.openai.minWorkersPerToken,`–`,m.openai.maxWorkersPerToken]}),` `,m.openai.autoscale?`autoscale`:`fixed`]}),h&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{children:[`openai workers`,` `,(0,I.jsxs)(`span`,{className:`font-mono text-sand-800`,children:[h.openaiReadyWorkerCount,`/`,h.openaiWorkerCount]}),` `,`ready`]}),(0,I.jsxs)(`span`,{children:[`queue`,` `,(0,I.jsx)(`span`,{className:s(`font-mono`,h.openaiQueueLength>0?`font-semibold text-caution-500`:`text-sand-800`),children:h.openaiQueueLength})]})]})]}),h&&(h.openaiWorkersByToken.length>0||h.anthropicTokenNames.length>0)&&(0,I.jsxs)(`div`,{className:`space-y-1.5 border-b border-sand-100 px-4 py-2.5 sm:px-5`,children:[h.openaiWorkersByToken.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`w-[4.5rem] shrink-0 text-[10px] font-medium uppercase tracking-[0.08em] text-sand-400`,children:`openai`}),h.openaiWorkersByToken.map(e=>(0,I.jsxs)(`span`,{title:`${e.name}: ${e.count} workers`,className:`inline-flex items-baseline gap-1.5 rounded-md border border-sand-200 bg-white px-2 py-1`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-sand-600`,children:e.name.split(`/`).pop()}),(0,I.jsx)(`span`,{className:`font-mono text-[13px] font-semibold tracking-[-0.02em] text-sand-900`,children:e.count})]},e.name))]}),h.anthropicTokenNames.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`w-[4.5rem] shrink-0 text-[10px] font-medium uppercase tracking-[0.08em] text-sand-400`,children:`anthropic`}),h.anthropicTokenNames.map(e=>(0,I.jsx)(`span`,{title:e,className:`inline-flex items-baseline rounded-md border border-sand-200 bg-white px-2 py-1 font-mono text-[11px] text-sand-600`,children:e.split(`/`).pop()},e))]})]}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`div`,{ref:y,role:`log`,"aria-label":`Server process logs`,tabIndex:0,className:`main-scroll h-[calc(100vh-232px)] min-h-[320px] overflow-y-auto bg-sand-900 px-4 py-3 font-mono text-[12px] leading-[1.6] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-sienna-400`,children:C?(0,I.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-sand-400`,children:[(0,I.jsxs)(`p`,{className:`text-[12px]`,children:[`Could not reach the qgrid server — is it running?`,p.error instanceof Error&&(0,I.jsx)(`span`,{className:`block text-center text-[11px] text-sand-500`,children:p.error.message})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>void p.refetch(),className:`inline-flex items-center gap-1.5 rounded-md border border-sand-600 px-2.5 py-1.5 text-[11px] font-medium text-sand-300 transition-colors hover:bg-sand-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sienna-400`,children:[(0,I.jsx)(L,{className:`size-3`}),`Retry now`]})]}):S?v.length===0?(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-sand-500`,children:r.length===0?`No log lines yet — waiting for activity since ${o.current===void 0?`startup`:G(o.current)}.`:`No lines match the current filters.`}):(0,I.jsx)(`div`,{className:`relative w-full`,style:{height:`${b.getTotalSize()}px`},children:b.getVirtualItems().map(e=>{let t=v[e.index];return(0,I.jsx)(`div`,{ref:b.measureElement,"data-index":e.index,className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${e.start}px)`},children:(0,I.jsx)(J,{item:t})},e.key)})}):(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-sand-500`,children:`Connecting to server logs…`})}),S&&!C&&!x&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>b.scrollToEnd(),className:`absolute bottom-4 right-5 inline-flex items-center gap-1.5 rounded-full border border-sand-600 bg-sand-800/90 px-3 py-1.5 text-[11px] font-medium text-sand-200 shadow-lg backdrop-blur transition-colors hover:bg-sand-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sienna-400`,children:`↓ Jump to live`})]})]})}function J({item:e}){if(e.kind===`restart`)return(0,I.jsxs)(`div`,{className:`py-1 text-center text-[11px] text-caution-400`,children:[`── process restarted · `,G(e.processStartedAt),` ──`]});if(e.kind===`dropped`)return(0,I.jsxs)(`div`,{className:`py-1 text-center text-[11px] italic text-sand-500`,children:[`── `,e.count,` lines dropped (buffer overflow) ──`]});let{entry:t}=e;return(0,I.jsxs)(`div`,{className:`whitespace-pre-wrap break-words text-sand-200`,children:[(0,I.jsx)(`span`,{className:`text-sand-500`,children:G(t.timestamp)}),` `,(0,I.jsx)(`span`,{className:s(`font-semibold`,t.level===`fatal`||t.level===`error`?`text-danger-400`:t.level===`warning`?`text-caution-400`:`text-sand-400`),children:U[t.level]??t.level.slice(0,3).toUpperCase()}),` `,(0,I.jsx)(`span`,{className:`text-sienna-300`,children:K(t.category)}),` `,(0,I.jsx)(`span`,{children:t.text})]})}a({level:o([`all`,`scaling`,`warn`,`error`]).optional().default(`all`)});function Y(){let e=c.useSearch(),t=c.useNavigate();return(0,I.jsx)(`div`,{className:`max-w-[100rem] mx-auto`,children:(0,I.jsx)(q,{search:e,onSearchChange:e=>t({search:e,replace:!0})})})}export{Y as component};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{y as t}from"./vendor-tanstack-DJRQAbrY.js";import{i as n,n as r,r as i}from"./vendor-react-DH4kUfK2.js";import{i as a}from"./index-DXdGBfB8.js";import{r as o}from"./cost-CpjVoAqp.js";import{a as s,n as c}from"./services.generated-BWyAypSh.js";import{t as l}from"./use-update-token-mutation-DeDBiZiM.js";var u=e(r()),d=e(n());function f(){var e=[...arguments];return(0,d.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var p=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function m(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function h(e){return`nodeType`in e}function g(e){return e?m(e)?e:h(e)?e.ownerDocument?.defaultView??window:window:window}function _(e){let{Document:t}=g(e);return e instanceof t}function v(e){return m(e)?!1:e instanceof g(e).HTMLElement}function y(e){return e instanceof g(e).SVGElement}function b(e){return e?m(e)?e.document:h(e)?_(e)?e:v(e)||y(e)?e.ownerDocument:document:document:document}var x=p?d.useLayoutEffect:d.useEffect;function S(e){let t=(0,d.useRef)(e);return x(()=>{t.current=e}),(0,d.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function C(){let e=(0,d.useRef)(null);return[(0,d.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,d.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function w(e,t){let n=(0,d.useRef)();return(0,d.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function T(e){let t=S(e),n=(0,d.useRef)(null);return[n,(0,d.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}var E={};function ee(e,t){return(0,d.useMemo)(()=>{if(t)return t;let n=E[e]==null?0:E[e]+1;return E[e]=n,e+`-`+n},[e,t])}function te(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var D=te(1),O=te(-1);function k(e){return`clientX`in e&&`clientY`in e}function ne(e){if(!e)return!1;let{KeyboardEvent:t}=g(e.target);return t&&e instanceof t}function A(e){if(!e)return!1;let{TouchEvent:t}=g(e.target);return t&&e instanceof t}function j(e){if(A(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return k(e)?{x:e.clientX,y:e.clientY}:null}var M=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[M.Translate.toString(e),M.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),re={display:`none`};function N(e){let{id:t,value:n}=e;return d.createElement(`div`,{id:t,style:re},n)}function ie(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return d.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function P(){let[e,t]=(0,d.useState)(``);return{announce:(0,d.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var ae={draggable:`
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{y as t}from"./vendor-tanstack-DJRQAbrY.js";import{i as n,n as r,r as i}from"./vendor-react-DH4kUfK2.js";import{i as a}from"./index-CN_kMswh.js";import{r as o}from"./cost-CpjVoAqp.js";import{a as s,n as c}from"./services.generated-BWyAypSh.js";import{t as l}from"./use-update-token-mutation-DeDBiZiM.js";var u=e(r()),d=e(n());function f(){var e=[...arguments];return(0,d.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var p=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function m(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function h(e){return`nodeType`in e}function g(e){return e?m(e)?e:h(e)?e.ownerDocument?.defaultView??window:window:window}function _(e){let{Document:t}=g(e);return e instanceof t}function v(e){return m(e)?!1:e instanceof g(e).HTMLElement}function y(e){return e instanceof g(e).SVGElement}function b(e){return e?m(e)?e.document:h(e)?_(e)?e:v(e)||y(e)?e.ownerDocument:document:document:document}var x=p?d.useLayoutEffect:d.useEffect;function S(e){let t=(0,d.useRef)(e);return x(()=>{t.current=e}),(0,d.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function C(){let e=(0,d.useRef)(null);return[(0,d.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,d.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function w(e,t){let n=(0,d.useRef)();return(0,d.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function T(e){let t=S(e),n=(0,d.useRef)(null);return[n,(0,d.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}var E={};function ee(e,t){return(0,d.useMemo)(()=>{if(t)return t;let n=E[e]==null?0:E[e]+1;return E[e]=n,e+`-`+n},[e,t])}function te(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var D=te(1),O=te(-1);function k(e){return`clientX`in e&&`clientY`in e}function ne(e){if(!e)return!1;let{KeyboardEvent:t}=g(e.target);return t&&e instanceof t}function A(e){if(!e)return!1;let{TouchEvent:t}=g(e.target);return t&&e instanceof t}function j(e){if(A(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return k(e)?{x:e.clientX,y:e.clientY}:null}var M=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[M.Translate.toString(e),M.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),re={display:`none`};function N(e){let{id:t,value:n}=e;return d.createElement(`div`,{id:t,style:re},n)}function ie(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return d.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function P(){let[e,t]=(0,d.useState)(``);return{announce:(0,d.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var ae={draggable:`
2
2
  To pick up a draggable item, press the space bar.
3
3
  While dragging, use the arrow keys to move the item.
4
4
  Press space again to drop the item in its new position, or press escape to cancel.