failproofai 1.0.9-beta.0 → 1.0.9-beta.1

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 (143) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +5 -5
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +2 -2
  6. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  7. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  8. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  11. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
  12. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  13. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +2 -2
  15. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  16. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  17. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.rsc +14 -14
  20. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
  21. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
  22. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  23. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/audit/page/build-manifest.json +2 -2
  32. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
  33. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
  34. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  35. package/.next/standalone/.next/server/app/index.html +1 -1
  36. package/.next/standalone/.next/server/app/index.rsc +14 -14
  37. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +13 -13
  38. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +14 -14
  39. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  40. package/.next/standalone/.next/server/app/page/build-manifest.json +2 -2
  41. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  42. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  44. package/.next/standalone/.next/server/app/policies/page/build-manifest.json +2 -2
  45. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
  46. package/.next/standalone/.next/server/app/policies/page.js +1 -1
  47. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  49. package/.next/standalone/.next/server/app/project/[name]/page/build-manifest.json +2 -2
  50. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  51. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  53. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/build-manifest.json +2 -2
  54. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  55. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  56. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  58. package/.next/standalone/.next/server/app/projects/page/build-manifest.json +2 -2
  59. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  60. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  61. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  62. package/.next/standalone/.next/server/app/settings/page/build-manifest.json +2 -2
  63. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +8 -8
  64. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  65. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  66. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
  67. package/.next/standalone/.next/server/chunks/_09dz7xv._.js +1 -1
  68. package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
  69. package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
  70. package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_01r25oi._.js +2 -2
  71. package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_09z9-p7._.js +2 -2
  72. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
  73. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0tmz862._.js → [root-of-the-server]__03m2iw6._.js} +2 -2
  74. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__04usis8._.js +2 -2
  75. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__056wjo4._.js +2 -2
  76. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0n0xg95._.js +2 -2
  77. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0rwtwpm._.js +2 -2
  78. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__12e7nhs._.js → [root-of-the-server]__1-bm5zf._.js} +1 -1
  79. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11mayhe._.js +2 -2
  80. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__15578wp._.js +2 -2
  81. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1m_svbe._.js +2 -2
  82. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1pprgri._.js +2 -2
  83. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1q4p5b8._.js +2 -2
  84. package/.next/standalone/.next/server/chunks/ssr/_042cgl1._.js +1 -1
  85. package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
  86. package/.next/standalone/.next/server/chunks/ssr/_0bqoto4._.js +1 -1
  87. package/.next/standalone/.next/server/chunks/ssr/{_1p3iz2d._.js → _11ilmst._.js} +2 -2
  88. package/.next/standalone/.next/server/chunks/ssr/_1gb0ifp._.js +3 -3
  89. package/.next/standalone/.next/server/chunks/ssr/{_0n0lja6._.js → _1jatlmf._.js} +1 -1
  90. package/.next/standalone/.next/server/chunks/ssr/_1zopuov._.js +1 -1
  91. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +2 -2
  92. package/.next/standalone/.next/server/chunks/ssr/app_actions_get-scheduled-audit_ts_0ei9sni._.js +1 -1
  93. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
  94. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
  95. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
  96. package/.next/standalone/.next/server/chunks/ssr/app_settings_02tf1h4._.js +1 -1
  97. package/.next/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_11bnuzn._.js +1 -1
  98. package/.next/standalone/.next/server/chunks/ssr/src_hooks_effective-reviewers_ts_1h4wtvo._.js +1 -1
  99. package/.next/standalone/.next/server/middleware-build-manifest.js +5 -5
  100. package/.next/standalone/.next/server/pages/404.html +1 -1
  101. package/.next/standalone/.next/server/pages/500.html +1 -1
  102. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  103. package/.next/standalone/.next/server/server-reference-manifest.json +23 -23
  104. package/.next/standalone/.next/static/chunks/{06jxjnw8bfczc.js → 0542cuk_va8g1.js} +1 -1
  105. package/.next/standalone/.next/static/chunks/{2qsrrrl2maqsb.js → 08ckontevw-0w.js} +1 -1
  106. package/.next/standalone/.next/static/chunks/{42m0f2hh8vfb1.js → 0pefjgvu4x-sx.js} +1 -1
  107. package/.next/standalone/.next/static/chunks/{0snylg3y1i47a.js → 1-d48e9k-7e1a.js} +1 -1
  108. package/.next/standalone/.next/static/chunks/{03001k9jy-kst.js → 1r74hmr1wm_sd.js} +1 -1
  109. package/.next/standalone/.next/static/chunks/{0qejem4-zt-hy.js → 1uec0n0lcx5h1.js} +1 -1
  110. package/.next/standalone/.next/static/chunks/21-pqc3-l9ak2.js +6 -0
  111. package/.next/standalone/.next/static/chunks/{1h0if8ky362as.js → 21qlo00jis4w-.js} +1 -1
  112. package/.next/standalone/.next/static/chunks/{3rq7fjj9we0v3.js → 2n00c3zqyloy9.js} +1 -1
  113. package/.next/standalone/.next/static/chunks/{0247hc9ath5t-.js → 3tv107_for_n7.js} +1 -1
  114. package/.next/standalone/.next/static/chunks/{06k7gsfnb7jkh.js → 3vp54x0dyrrm6.js} +1 -1
  115. package/.next/standalone/.next/static/chunks/{turbopack-38nzuvp95_2rv.js → turbopack-11dn2pegmg9_9.js} +1 -1
  116. package/.next/standalone/fp-cloud-cli/uv.lock +3 -3
  117. package/.next/standalone/node_modules/@next/env/package.json +1 -1
  118. package/.next/standalone/node_modules/next/dist/build/swc/index.js +1 -1
  119. package/.next/standalone/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +1 -1
  120. package/.next/standalone/node_modules/next/dist/lib/patch-incorrect-lockfile.js +3 -3
  121. package/.next/standalone/node_modules/next/dist/server/config.js +1 -1
  122. package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +2 -2
  123. package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1 -1
  124. package/.next/standalone/node_modules/next/dist/server/lib/app-info-log.js +1 -1
  125. package/.next/standalone/node_modules/next/dist/server/lib/start-server.js +1 -1
  126. package/.next/standalone/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
  127. package/.next/standalone/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
  128. package/.next/standalone/node_modules/next/dist/telemetry/events/version.js +2 -2
  129. package/.next/standalone/node_modules/next/package.json +10 -10
  130. package/.next/standalone/package.json +11 -11
  131. package/.next/standalone/sdk/python/uv.lock +18 -18
  132. package/.next/standalone/server.js +1 -1
  133. package/dist/cli.mjs +911 -719
  134. package/dist/worker.mjs +4 -1
  135. package/package.json +11 -11
  136. package/src/hooks/integrations.ts +128 -18
  137. package/src/hooks/jev-activity.ts +5 -0
  138. package/src/hooks/policy-reviewability.ts +4 -2
  139. package/src/hooks/safe-config-write.ts +119 -0
  140. package/.next/standalone/.next/static/chunks/3ns-egfh8i8i5.js +0 -6
  141. /package/.next/standalone/.next/static/{z1C0kJVF0NCtWn5R88hW3 → ozuWoyIwOTqeUUjKqOKiH}/_buildManifest.js +0 -0
  142. /package/.next/standalone/.next/static/{z1C0kJVF0NCtWn5R88hW3 → ozuWoyIwOTqeUUjKqOKiH}/_clientMiddlewareManifest.js +0 -0
  143. /package/.next/standalone/.next/static/{z1C0kJVF0NCtWn5R88hW3 → ozuWoyIwOTqeUUjKqOKiH}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,36406,e=>{"use strict";let t;var s=e.i(43476),n=e.i(71645),r=e.i(74080);function i(e,t,s){let n,r=s.initialDeps??[],i=!0;function l(){let l=e();return(l.length!==r.length||l.some((e,t)=>r[t]!==e))&&(r=l,n=t(...l),(null==s?void 0:s.onChange)&&!(i&&s.skipInitialOnChange)&&s.onChange(n),i=!1),n}return l.updateDeps=e=>{r=e},l}function l(e,t){if(void 0!==e)return e;throw Error(`Unexpected undefined${t?`: ${t}`:""}`)}let o=(e,t)=>1.01>Math.abs(e-t),a=()=>{if(void 0!==t)return t;if("u"<typeof navigator)return t=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return t=!0;let e=navigator.maxTouchPoints;return t="MacIntel"===navigator.platform&&void 0!==e&&e>0},d=e=>e,c=e=>{let t=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,n=Array(s);for(let e=0;e<s;e++)n[e]=t+e;return n},u={passive:!0},h=(e,t)=>{let s=e.scrollElement;if(!s)return;let n=()=>{t({width:s.innerWidth,height:s.innerHeight})};return n(),s.addEventListener("resize",n,u),()=>{s.removeEventListener("resize",n)}},m="u"<typeof window||"onscrollend"in window,f=(e,t)=>((e,t,s)=>{var n,r;let i,l=e.scrollElement;if(!l)return;let o=e.targetWindow;if(!o)return;let a=e.options.useScrollendEvent&&m,d=0,c=a?null:(n=()=>t(s(l),!1),r=e.options.isScrollingResetDelay,Object.assign(function(...e){o.clearTimeout(i),i=o.setTimeout(()=>n.apply(this,e),r)},{cancel:()=>{o.clearTimeout(i)}})),h=e=>()=>{d=s(l),null==c||c(),t(d,e)},f=h(!0),p=h(!1);return l.addEventListener("scroll",f,u),a&&l.addEventListener("scrollend",p,u),()=>{l.removeEventListener("scroll",f),a&&l.removeEventListener("scrollend",p),null==c||c.cancel()}})(e,t,t=>e.options.horizontal?t.scrollX:t.scrollY),p=(e,t,s)=>{if(s.options.useCachedMeasurements){let t=s.indexFromElement(e),n=s.options.getItemKey(t);return s.itemSizeCache.get(n)??s.options.estimateSize(t)}if(null==t?void 0:t.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[s.options.horizontal?"inlineSize":"blockSize"])}if(!t){let t=s.indexFromElement(e),n=s.options.getItemKey(t),r=s.itemSizeCache.get(n);if(void 0!==r)return r}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},g=(e,{adjustments:t=0,behavior:s},n)=>{var r,i;null==(i=null==(r=n.scrollElement)?void 0:r.scrollTo)||i.call(r,{[n.options.horizontal?"left":"top"]:e+t,behavior:s})};class x{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=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._clampedAdjustment=null,this.elementsCache=new Map,this.now=()=>{var e,t,s;return(null==(s=null==(t=null==(e=this.targetWindow)?void 0:e.performance)?void 0:t.now)?void 0:s.call(t))??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(this.targetWindow&&this.targetWindow.ResizeObserver?e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,s=this.indexFromElement(t);if(!t.isConnected){for(let[e,s]of(this.observer.unobserve(t),this.elementsCache))if(s===t){this.elementsCache.delete(e);break}return}this.isIndexInRange(s)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}):null);return{disconnect:()=>{var s;null==(s=t())||s.disconnect(),e=null},observe:e=>{var s;return null==(s=t())?void 0:s.observe(e,{box:"border-box"})},unobserve:e=>{var s;return null==(s=t())?void 0:s.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{var t;let s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:d,rangeExtractor:c,onChange:()=>{},measureElement:p,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 t in e){let n=e[t];void 0!==n&&(s[t]=n)}let n=this.options,r=null,i=null,l=!1;if(void 0!==n&&n.enabled&&s.enabled&&"end"===s.anchorTo&&null!==this.scrollElement){let e=n.count,o=s.count,a=this.getMeasurements(),d=(null==(t=this._singleLaneMeasurements)?void 0:t.items)??a,c=e=>{var t;return"object"==typeof(t=d[e])?t.key:t},u=e>0?c(0):null,h=e>0?c(e-1):null;if(o!==e||e>0&&o>0&&(s.getItemKey(0)!==u||s.getItemKey(o-1)!==h)){l=!0;let t=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??a[0]:null;t&&(r=[t.key,this.getScrollOffset()-t.start]);let d=!0===s.followOnAppend?"auto":s.followOnAppend||null;d&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(0===e||s.getItemKey(o-1)!==h)&&(o>e||function(e,t,s,n){if(0===t)return!1;let r=n(0),i=new Set,l=0;for(;l<e;){let e=s(l);if(e===r)break;i.add(e),l++}let o=e-l;if(0===o||o>=t)return!1;for(let e=0;e<o;e++)if(n(e)!==s(l+e))return!1;for(let e=o;e<t;e++)if(i.has(n(e)))return!1;return!0}(e,o,c,s.getItemKey))&&(i=d)}}this.options=s,l&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,a=0;if(r&&null!==this.scrollOffset){let[e,t]=r,s=this.getMeasurements(),{count:n,getItemKey:l}=this.options,d=0;for(;d<n&&l(d)!==e;)d++;if(d<n){let e=s[d];if(e){let s=Math.max(0,e.start+t);i||s===this.scrollOffset||(a=s-this.scrollOffset,this.scrollOffset=s,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,a])},this.notify=e=>{var t,s;null==(s=(t=this.options).onChange)||s.call(t,this,e)},this.maybeNotify=i(()=>(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(),null!=this.rafId&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e,t;let s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s)return void this.maybeNotify();if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(e=this.scrollElement)?void 0:e.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&&null===this._intendedScrollOffset&&e===this.scrollOffset)return;null!==this._intendedScrollOffset&&1.5>Math.abs(e-this._intendedScrollOffset)&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,null!==this._clampedAdjustment&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let s=this.getScrollOffset();this.scrollDirection=t?s===e?this.scrollDirection:s<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,null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},s=()=>{this._iosTouching=!1,a()&&null!=this.targetWindow&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener("touchstart",t,u),e.addEventListener("touchend",s,u),this.unsubs.push(()=>{e.removeEventListener("touchstart",t),e.removeEventListener("touchend",s),null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let n=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,n&&this.scrollElement&&this.options.enabled){let[e,s,r,i]=n;null!==e&&!r&&(a()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?0!==i&&(this._iosDeferredAdjustment+=i):((null==(t=this.scrollState)?void 0:t.behavior)!=="smooth"||o(this.getScrollOffset()-i,this.scrollState.lastTargetOffset))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(null===this._clampedAdjustment||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,s=this.getMaxScrollOffset();s>t+.5&&(this._clampedAdjustment=e>s+.5?{target:e,maxAtWrite:s}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(0===this._iosDeferredAdjustment||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let s=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=s,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??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=i(()=>[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,s,n,r,i,l,o)=>(void 0!==this.prevLanes&&this.prevLanes!==i&&(this.lanesChangedFlag=!0),this.prevLanes=i,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:s,getItemKey:n,enabled:r,lanes:i,laneAssignmentMode:l,gap:o}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=i(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:s,getItemKey:n,enabled:r,lanes:i,laneAssignmentMode:l,gap:o},a)=>{var d,c;let u=this.itemSizeCache;if(!r)return this.measurementsCache=[],this._singleLaneMeasurements=null,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._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let h=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),1===i){let r,i,l=2*e,a=null==(d=this._singleLaneMeasurements)?void 0:d.flat;if(!a||a.length<l){let e=new Float64Array(l);a&&h>0&&e.set(a.subarray(0,2*h)),a=e}let m=0===h?Array(e):this._singleLaneMeasurements.items.slice();if(0===h)r=t+s;else{let e=h-1;r=a[2*e]+a[2*e+1]+o}for(let t=h;t<e;t++){let e=n(t);m[t]=e;let s=u.get(e),i="number"==typeof s?s:this.options.estimateSize(t);a[2*t]=r,a[2*t+1]=i,r+=i+o}this._singleLaneMeasurements={flat:a,items:m};let f=(c=a,i=m.length,new Proxy(m,{get(e,t,s){if("string"==typeof t){let s=t.charCodeAt(0);if(s>=48&&s<=57){let s=+t;if(Number.isInteger(s)&&s>=0&&s<i){let t=e[s];if("object"!=typeof t){let n=c[2*s];t=e[s]={index:s,key:t,start:n,size:c[2*s+1],end:n+c[2*s+1],lane:0}}return t}}if("length"===t)return i}return Reflect.get(e,t,s)}}));return this.measurementsCache=f,f}let m=this.measurementsCache.slice(0,h),f=Array(i).fill(void 0),p=new Float64Array(i),g=0;for(let e=0;e<h;e++){let t=m[e];t&&(void 0===f[t.lane]&&g++,f[t.lane]=e,p[t.lane]=t.end)}for(let r=h;r<e;r++){let e,a,d=n(r),c=this.laneAssignments.get(r),h="estimate"===l||u.has(d);if(void 0!==c&&this.options.lanes>1){let n=f[e=c],r=void 0!==n?m[n]:void 0;a=r?r.end+o:t+s}else if(g===i){let t=0,s=p[0],n=f[0];for(let e=1;e<i;e++){let r=p[e];(r<s||r===s&&f[e]<n)&&(t=e,s=r,n=f[e])}e=t,a=s+o,h&&this.laneAssignments.set(r,e)}else e=r%this.options.lanes,a=t+s,h&&this.laneAssignments.set(r,e);let x=u.get(d),y="number"==typeof x?x:this.options.estimateSize(r),b=a+y;m[r]={index:r,start:a,size:y,end:b,key:d,lane:e},void 0===f[e]&&g++,f[e]=r,p[e]=b}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=i(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,s,n)=>0===e.length||0===t?(this.range=null,null):(this.range=function(e,t,s,n,r){let i=e.length-1;if(e.length<=n)return{startIndex:0,endIndex:i};if(1===n&&null!==r){let e=function(e,t,s){let n=0;for(;n<=t;){let r=(n+t)/2|0,i=e[2*r];if(i<s)n=r+1;else{if(!(i>s))return r;t=r-1}}return n>0?n-1:0}(r,i,s),n=e,l=s+t;for(;n<i&&r[2*n]+r[2*n+1]<l;)n++;return{startIndex:e,endIndex:n}}let l=y(0,i,t=>e[t].start,s),o=l;if(1===n)for(;o<i&&e[o].end<s+t;)o++;else if(n>1){let r=Array(n).fill(0);for(;o<i&&r.some(e=>e<s+t);){let t=e[o];r[t.lane]=t.end,o++}let a=Array(n).fill(s+t);for(;l>=0&&a.some(e=>e>=s);){let t=e[l];a[t.lane]=t.start,l--}l=Math.max(0,l-l%n),o=Math.min(i,o+(n-1-o%n))}return{startIndex:l,endIndex:o}}(e,t,s,n,1===n&&null!==this._singleLaneMeasurements?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=i(()=>{let e=null,t=null,s=this.calculateRange();return s&&(e=s.startIndex,t=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,s,n,r)=>null===n||null===r?[]:e({startIndex:n,endIndex:r,overscan:t,count:s}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,s=e.getAttribute(t);return s?parseInt(s,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t;if(!this.scrollState||"smooth"!==this.scrollState.behavior)return!0;let s=this.scrollState.index??(null==(t=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))?void 0:t.index);if(void 0!==s&&this.range){let t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),n=Math.max(0,s-t),r=Math.min(this.options.count-1,s+t);return e>=n&&e<=r}return!0},this.measureElement=e=>{if(!e)return void this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let s=this.options.getItemKey(t),n=this.elementsCache.get(s);n!==e&&(n&&this.observer.unobserve(n),this.observer.observe(e),this.elementsCache.set(s,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var s,n,r;let i,l,o;if(!this.isIndexInRange(e))return;let a=null==(s=this._singleLaneMeasurements)?void 0:s.flat;if(1===this.options.lanes&&null!=a)o=this.options.getItemKey(e),l=a[2*e],i=a[2*e+1];else{let t=this.measurementsCache[e];if(!t)return;o=t.key,l=t.start,i=t.size}let d=this.itemSizeCache.get(o)??i,c=t-d;if(0!==c){let s="end"===this.options.anchorTo&&(null==(n=this.scrollState)?void 0:n.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,a=s?this.getTotalSize():0,u=this.getScrollOffset()+this.scrollAdjustments,h=this.itemSizeCache.has(o)?l+d<=u&&"backward"!==this.scrollDirection:l<u,m=(null==(r=this.scrollState)?void 0:r.behavior)!=="smooth"&&(void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:o,start:l,size:i,end:l+i,lane:0},c,this):h);(null===this.pendingMin||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(o,t),this.itemSizeCacheVersion++;let f=!1;s?f=this.applyScrollAdjustment(this.getTotalSize()-a):m&&(f=this.applyScrollAdjustment(c)),this.notify(f),this._retryClampedAdjustment()}},this.getVirtualItems=i(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let s=[];for(let n=0,r=e.length;n<r;n++){let r=t[e[n]];s.push(r)}return s},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{var t;let s=this.getMeasurements();if(0===s.length)return;let n=null==(t=this._singleLaneMeasurements)?void 0:t.flat,r=1===this.options.lanes&&null!=n,i=y(0,s.length-1,r?e=>n[2*e]:e=>l(s[e]).start,e);return l(s[i])},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,s=0)=>{if(!this.scrollElement)return 0;let n=this.getSize(),r=this.getScrollOffset();return"auto"===t&&(t=e>=r+n?"end":"start"),"center"===t?e+=(s-n)/2:"end"===t&&(e-=n),Math.max(Math.min(this.getMaxScrollOffset(),e),0)},this.getOffsetForIndex=(e,t="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));let s=this.getSize(),n=this.getScrollOffset(),r=this.measurementsCache[e];if(!r)return;if("auto"===t)if(r.end>=n+s-this.options.scrollPaddingEnd)t="end";else{if(!(r.start<=n+this.options.scrollPaddingStart))return[n,t];t="start"}if("end"===t&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let i="end"===t?r.end+this.options.scrollPaddingEnd:r.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(i,t,r.size),t]},this.scrollToOffset=(e,{align:t="start",behavior:s="auto"}={})=>{this._iosDeferredAdjustment=0;let n=this.getOffsetForAlignment(e,t),r=this.now();this.scrollState={index:null,align:t,behavior:s,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t="auto",behavior:s="auto"}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getOffsetForIndex(e,t);if(!n)return;let[r,i]=n,l=this.now();this.scrollState={index:e,align:i,behavior:s,startedAt:l,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t="auto"}={})=>{let s=this.getScrollOffset()+e,n=this.now();this.scrollState={index:null,align:"start",behavior:t,startedAt:n,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e="auto"}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:"end",behavior:e}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{var e,t;let s,n=this.getMeasurements();if(0===n.length)s=this.options.paddingStart;else if(1===this.options.lanes){let r=n.length-1,i=null==(e=this._singleLaneMeasurements)?void 0:e.flat;s=null!=i?i[2*r]+i[2*r+1]:(null==(t=n[r])?void 0:t.end)??0}else{let e=Array(this.options.lanes).fill(null),t=n.length-1;for(;t>=0&&e.some(e=>null===e);){let s=n[t];null===e[s.lane]&&(e[s.lane]=s.end),t--}s=Math.max(...e.filter(e=>null!==e))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(0===this.itemSizeCache.size)return e;for(let t of this.getMeasurements())t&&this.itemSizeCache.has(t.key)&&e.push({index:t.index,key:t.key,start:t.start,size:t.size,end:t.end,lane:t.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:s})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:s,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){if(0===e)return!1;if(a()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{let s=this.getScrollOffset()+this.scrollAdjustments+e,n=this.scrollElement,r=null!==n&&("scrollHeight"in n||"document"in n)?this.getMaxScrollOffset():null;return this._clampedAdjustment=null!==r&&s>r+.5?{target:s,maxAtWrite:r}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),null!==this.scrollOffset&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}null==this.rafId&&(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=null!=this.scrollState.index?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,t=e?e[0]:this.scrollState.lastTargetOffset,s=t!==this.scrollState.lastTargetOffset;if(!s&&o(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,s){let e=this.getSize()||600,s=Math.abs(t-this.getScrollOffset()),n="smooth"===this.scrollState.behavior&&s>e;this.scrollState.lastTargetOffset=t,n||(this.scrollState.behavior="auto"),this._scrollToOffset(t,{adjustments:void 0,behavior:n?"smooth":"auto"})}this.scheduleScrollReconcile()}}let y=(e,t,s,n)=>{for(;e<=t;){let r=(e+t)/2|0,i=s(r);if(i<n)e=r+1;else{if(!(i>n))return r;t=r-1}}return e>0?e-1:0},b="u">typeof document?n.useLayoutEffect:n.useEffect;var v=e.i(16327),j=e.i(56420);let S={name:"wrench",size:24,node:[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]};S.node;let w=(0,j.default)(S);function N(e){let t=new Map,s=new Map;for(let n of e){let e=n.uuid||`${n._source}:${n.timestamp}`,r=s.get(e)??0;s.set(e,r+1),t.set(n,0===r?e:`${e}#${r}`)}return t}let M={name:"user",size:24,node:[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]};M.node;let k=(0,j.default)(M),E={name:"bot",size:24,node:[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]};E.node;let T=(0,j.default)(E),I={name:"cpu",size:24,node:[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]};I.node;let A=(0,j.default)(I),C={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};C.node;let O=(0,j.default)(C),z={name:"message-square",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]};z.node;let _=(0,j.default)(z),D={name:"workflow",size:24,node:[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]};D.node;let F=(0,j.default)(D);var R=e.i(34713);let $=n.default.memo(function({entries:e,compact:t=!1}){let r=(0,n.useMemo)(()=>(function(e){let t=0,s=0,n=0,r=0,i=0,l=new Set;for(let o of e)if("user"===o.type&&t++,"queue-operation"===o.type&&i++,"assistant"===o.type){for(let e of(s++,o.message.content))"tool_use"===e.type&&("Task"===e.name&&(e.subagentType||e.subagentId)?r++:n++);o.message.model&&l.add(o.message.model)}let o="";if(e.length>=2){let t=e[e.length-1].timestampMs-e[0].timestampMs;o=(0,R.formatDuration)(t)}return{turnCount:i,userCount:t,assistantCount:s,toolCallCount:n,subagentCount:r,duration:o,models:Array.from(l)}})(e),[e]),i=t?"w-3.5 h-3.5":"w-4 h-4",l=t?"text-xs font-medium":"text-sm font-medium",o=t?"text-[10px] text-muted-foreground":"text-xs text-muted-foreground",a=[...t?[]:[{Icon:_,color:"text-primary",v:r.turnCount,l:"Turns"}],{Icon:k,color:"text-[color:var(--chart-1)]",v:r.userCount,l:"User"},{Icon:T,color:"text-[color:var(--chart-2)]",v:r.assistantCount,l:"Assistant"},{Icon:w,color:"text-[color:var(--chart-3)]",v:r.toolCallCount,l:t?"Tools":"Tool Calls"},{Icon:F,color:"text-[color:var(--chart-5)]",v:r.subagentCount,l:"Subagents"},{Icon:O,color:"text-[color:var(--chart-4)]",v:r.duration||"—",l:"Duration"},{Icon:A,color:"text-[color:var(--chart-5)]",v:r.models.length>0?r.models.join(", "):"—",l:t?"Model":"Model(s)"}];return(0,s.jsx)("div",{className:t?"bg-muted/30 border border-border/50 rounded-lg p-3 mb-3":"bg-card border border-border rounded-lg p-4",children:(0,s.jsx)("div",{className:`grid grid-cols-2 ${t?"sm:grid-cols-6 gap-3":"sm:grid-cols-4 lg:grid-cols-7 gap-4"}`,children:a.map(({Icon:e,color:t,v:n,l:r})=>(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e,{className:`${i} ${t}`}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:`${l} truncate max-w-[120px]`,children:n}),(0,s.jsx)("div",{className:o,children:r})]})]},r))})})}),L={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]};L.node;let W=(0,j.default)(L);var P=e.i(67927);function U(e){return JSON.stringify(e.raw,null,2)}let q=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0});function H(e){let t=new Date(e),s=q.format(t),n=t.getMilliseconds().toString().padStart(3,"0");return`${s}.${n}`}let B=n.default.memo(function({entry:e,isCollapsed:t,entryCount:n,onToggle:r}){let i="function"==typeof r,l=(0,s.jsxs)("div",{className:`flex items-center gap-2 px-3 py-1 rounded-full bg-primary/10 border border-primary/20 text-primary text-xs font-medium${i?" group-hover:bg-primary/20 transition-colors":""}`,children:[i?(0,s.jsx)(P.ChevronRight,{className:`w-3 h-3 transition-transform ${t?"":"rotate-90"}`}):(0,s.jsx)(W,{className:"w-3 h-3"}),(0,s.jsx)("span",{children:e.label}),(0,s.jsx)("span",{className:"text-muted-foreground",children:H(e.timestampMs)}),i&&t&&"number"==typeof n&&(0,s.jsxs)("span",{className:"ml-1 px-1.5 py-0.5 rounded bg-primary/20 text-[10px] leading-none",children:[n," ",1===n?"entry":"entries"]})]});return i?(0,s.jsxs)("button",{type:"button",onClick:r,className:"group flex items-center gap-3 py-3 px-4 w-full cursor-pointer",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-primary/30"}),l,(0,s.jsx)("div",{className:"flex-1 h-px bg-primary/30"})]}):(0,s.jsxs)("div",{className:"flex items-center gap-3 py-3 px-4",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-primary/30"}),l,(0,s.jsx)("div",{className:"flex-1 h-px bg-primary/30"})]})});var V=e.i(47163);let K={user:"User",assistant:"Assistant","file-history-snapshot":"Snapshot",progress:"Progress",system:"System","queue-operation":"Queue"},J={user:"bg-[color:var(--chart-1)]/20 text-[color:var(--chart-1)] border-[color:var(--chart-1)]/30",assistant:"bg-[color:var(--chart-2)]/20 text-[color:var(--chart-2)] border-[color:var(--chart-2)]/30","file-history-snapshot":"bg-[color:var(--chart-3)]/20 text-[color:var(--chart-3)] border-[color:var(--chart-3)]/30",progress:"bg-[color:var(--chart-5)]/20 text-[color:var(--chart-5)] border-[color:var(--chart-5)]/30",system:"bg-[color:var(--chart-4)]/20 text-[color:var(--chart-4)] border-[color:var(--chart-4)]/30","queue-operation":"bg-primary/20 text-primary border-primary/30"},Y={user:"border-l-[color:var(--chart-1)]",assistant:"border-l-[color:var(--chart-2)]","file-history-snapshot":"border-l-[color:var(--chart-3)]",progress:"border-l-[color:var(--chart-5)]",system:"border-l-[color:var(--chart-4)]","queue-operation":"border-l-primary"},X={name:"file-text",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]};X.node;let Q=(0,j.default)(X),G={name:"activity",size:24,node:[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]};G.node;let Z=(0,j.default)(G);var ee=e.i(66794);function et({type:e}){let t="w-4 h-4";switch(e){case"user":return(0,s.jsx)(k,{className:t});case"assistant":return(0,s.jsx)(T,{className:t});case"file-history-snapshot":return(0,s.jsx)(Q,{className:t});case"progress":return(0,s.jsx)(Z,{className:t});case"system":return(0,s.jsx)(ee.Settings,{className:t});case"queue-operation":return(0,s.jsx)(W,{className:t})}}function es({type:e}){return(0,s.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs font-mono rounded border ${J[e]}`,children:[(0,s.jsx)(et,{type:e}),K[e]]})}var en=e.i(24380);function er({block:e}){let t=(0,n.useMemo)(()=>JSON.stringify(e.input,null,2),[e]);return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("details",{open:!0,children:[(0,s.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:(0,s.jsxs)("span",{className:"inline-flex items-center gap-1",children:["Input",(0,s.jsx)(en.CopyButton,{text:t})]})}),(0,s.jsx)("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:t})]}),e.result?(0,s.jsxs)("div",{className:"border-l-2 border-primary/50 pl-3 space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 text-xs font-mono rounded border bg-primary/20 text-primary border-primary/30",children:"Result"}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:H(new Date(e.result.timestamp).getTime())})]}),e.result.content&&(0,s.jsxs)("details",{open:!0,children:[(0,s.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:(0,s.jsxs)("span",{className:"inline-flex items-center gap-1",children:["Output",(0,s.jsx)(en.CopyButton,{text:e.result.content})]})}),(0,s.jsx)("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:e.result.content})]}),e.result.images?.map((e,t)=>(0,s.jsx)("img",{src:`data:${e.mediaType};base64,${e.base64}`,alt:`Tool result image ${t+1}`,className:"mt-2 max-w-full rounded border border-border"},t))]}):(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"Tool did not return a result"})]})}let ei={name:"brain",size:24,node:[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]};ei.node;let el=(0,j.default)(ei),eo=n.default.memo(function({block:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l}){switch(e.type){case"text":return(0,s.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:e.text});case"tool_use":if("Task"===e.name&&(e.subagentType||e.subagentId)){let o=e.subagentId&&t?t.get(`agent-${e.subagentId}`):void 0;return(0,s.jsx)(ep,{block:e,subagentEntries:o,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l})}return(0,s.jsxs)("div",{className:"border border-border/50 rounded-lg p-3 bg-muted/10",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(w,{className:"w-4 h-4 text-primary flex-shrink-0"}),(0,s.jsx)("span",{className:"font-mono text-sm text-primary truncate min-w-0",children:e.name}),e.result&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:e.result.durationFormatted})]}),(0,s.jsx)(er,{block:e})]});case"thinking":return(0,s.jsx)("div",{className:"border border-[color:var(--chart-5)]/30 rounded-lg p-3 bg-[color:var(--chart-5)]/5",children:(0,s.jsxs)("details",{children:[(0,s.jsxs)("summary",{className:"flex items-center gap-2 text-xs cursor-pointer hover:text-foreground transition-colors text-[color:var(--chart-5)]",children:[(0,s.jsx)(el,{className:"w-4 h-4"}),(0,s.jsx)("span",{children:"Thinking"}),(0,s.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",e.thinking.length.toLocaleString()," chars)"]})]}),(0,s.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-xs text-muted-foreground p-2 bg-muted/30 rounded max-h-64 overflow-y-auto",children:e.thinking})]})})}});function ea({entry:e}){return(0,s.jsx)("div",{children:e.message.content&&(0,s.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:e.message.content})})}let ed=n.default.memo(function({entry:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l}){let{content:o}=e.message;return(0,s.jsx)("div",{className:"space-y-3",children:o.map((e,o)=>(0,s.jsx)(eo,{block:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l},o))})}),ec=n.default.memo(function({entry:e}){let t=(0,n.useMemo)(()=>{if("progress"===e.type){let t=e.raw.data,s=t?.agentId;return[t?.type,s&&`agent:${s}`].filter(Boolean).join(" | ")}return"file-history-snapshot"===e.type?"File history snapshot":e.type},[e.type,e.raw]);return(0,s.jsxs)("div",{className:"text-sm",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:t}),(0,s.jsxs)("details",{className:"mt-1",children:[(0,s.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:"Show raw JSON"}),(0,s.jsx)("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:U(e)})]})]})}),eu={name:"link-2",size:24,node:[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]};eu.node;let eh=(0,j.default)(eu);var em=e.i(55574);function ef({uuid:e}){let t=(0,n.useCallback)(async()=>{window.history.replaceState(null,"",`#entry-${e}`);try{await navigator.clipboard.writeText(window.location.href)}catch{let e=document.createElement("textarea");e.value=window.location.href,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}(0,em.toast)("Link copied")},[e]);return(0,s.jsx)("button",{onClick:t,title:"Copy link to entry",className:"inline-flex items-center justify-center rounded p-1 text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors opacity-0 group-hover:opacity-100 transition-opacity",children:(0,s.jsx)(eh,{className:"w-3.5 h-3.5"})})}function ep({block:e,subagentEntries:t,projectName:r,sessionId:i,highlightedUuid:l,autoExpandForUuid:o}){let a=!!(o&&t?.some(e=>e.uuid===o)),[d,c]=(0,n.useState)(a);(0,n.useEffect)(()=>{if(!a)return;let e=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(e)},[a]);let u=(0,n.useCallback)(()=>{c(e=>!e)},[]),h=t&&t.length>0,m=(0,n.useMemo)(()=>N(t??[]),[t]);return(0,s.jsxs)("div",{className:"border border-border/50 rounded-lg p-3 bg-muted/10",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(F,{className:"w-4 h-4 text-[color:var(--chart-5)]"}),(0,s.jsx)("span",{className:"font-mono text-sm text-[color:var(--chart-5)]",children:"Subagent"}),e.subagentType&&(0,s.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 text-xs font-mono rounded border bg-[color:var(--chart-5)]/20 text-[color:var(--chart-5)] border-[color:var(--chart-5)]/30",children:e.subagentType}),e.result&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground ml-auto",children:e.result.durationFormatted})]}),e.subagentDescription&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground mb-2",children:e.subagentDescription}),e.subagentId&&t&&(0,s.jsxs)("button",{onClick:u,className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded border border-primary/30 bg-primary/10 text-primary hover:bg-primary/20 transition-colors mb-2",children:[(0,s.jsx)(P.ChevronRight,{className:(0,V.cn)("w-3 h-3 transition-transform",d&&"rotate-90")}),(0,s.jsxs)("span",{children:["agent-",e.subagentId]}),(0,s.jsx)("span",{className:"text-muted-foreground",children:d?"Collapse":"View subagent log"})]}),d&&(0,s.jsxs)("div",{className:"ml-4 pl-3 border-l-2 border-primary/30 mt-2 space-y-2",children:[t&&0===t.length&&(0,s.jsx)("div",{className:"text-xs text-muted-foreground py-2",children:"No entries found in subagent log."}),h&&(0,s.jsx)(s.Fragment,{children:(0,s.jsx)($,{entries:t,compact:!0})}),t&&t.map(e=>"queue-operation"===e.type?(0,s.jsx)(B,{entry:e},m.get(e)):(0,s.jsx)(ex,{entry:e,projectName:r,sessionId:i,isHighlighted:!!l&&e.uuid===l},m.get(e)))]}),(0,s.jsx)(er,{block:e})]})}function eg({entry:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l}){switch(e.type){case"user":return(0,s.jsx)(ea,{entry:e});case"assistant":return(0,s.jsx)(ed,{entry:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l});case"file-history-snapshot":case"progress":case"system":return(0,s.jsx)(ec,{entry:e})}}let ex=n.default.memo(function({entry:e,entriesBySource:t,projectName:n,sessionId:r,isHighlighted:i,highlightedUuid:l,autoExpandForUuid:o}){return(0,s.jsxs)("div",{id:e.uuid?`entry-${e.uuid}`:void 0,className:(0,V.cn)(`group border-l-4 ${Y[e.type]} bg-card/50 rounded-r-lg mb-2 hover:bg-muted/30 transition-colors`,i&&"entry-highlighted"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border/30",children:[(0,s.jsx)(es,{type:e.type}),(0,s.jsxs)("div",{className:"flex items-center gap-1 ml-auto",children:[e.uuid&&(0,s.jsx)(ef,{uuid:e.uuid}),(0,s.jsx)(en.CopyButton,{text:function(e){switch(e.type){case"user":return e.message.content;case"assistant":return e.message.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n");case"file-history-snapshot":case"progress":case"system":return U(e);case"queue-operation":return e.label}}(e)}),(0,s.jsx)("span",{className:"text-xs font-mono text-muted-foreground whitespace-nowrap",children:H(e.timestampMs)})]})]}),(0,s.jsx)("div",{className:"px-4 py-3",children:(0,s.jsx)(eg,{entry:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:l,autoExpandForUuid:o})})]})},(e,t)=>e.entry===t.entry&&e.entriesBySource===t.entriesBySource&&e.projectName===t.projectName&&e.sessionId===t.sessionId&&e.isHighlighted===t.isHighlighted&&e.highlightedUuid===t.highlightedUuid&&e.autoExpandForUuid===t.autoExpandForUuid);var ey=e.i(34578),eb=e.i(84026),ev=e.i(29407),ej=e.i(16306),eS=e.i(82954),ew=e.i(73520),eN=e.i(85881);function eM({decision:e}){return"deny"===e?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-red-500/10 text-red-400 border border-red-500/20",children:[(0,s.jsx)(ev.ShieldX,{className:"h-3 w-3"}),"Deny"]}):"instruct"===e?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[(0,s.jsx)(ej.ShieldAlert,{className:"h-3 w-3"}),"Instruct"]}):(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(0,s.jsx)(eb.ShieldCheck,{className:"h-3 w-3"}),"Allow"]})}function ek({eventType:e}){return(0,s.jsx)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium bg-muted text-muted-foreground border border-border/50",children:e})}function eE({mode:e}){let t="default"===e;return(0,s.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${t?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:e})}function eT({ms:e}){return(0,s.jsx)("span",{className:`font-mono text-[0.7rem] ${e>500?"text-red-400":e>100?"text-amber-400":"text-muted-foreground"}`,children:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`})}function eI({value:e,onChange:t}){return(0,s.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5",children:[{label:"All",value:""},{label:"Allow",value:"allow"},{label:"Instruct",value:"instruct"},{label:"Deny",value:"deny"}].map(n=>(0,s.jsx)("button",{onClick:()=>t(n.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${e===n.value?"deny"===n.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===n.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===n.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:n.label},n.value))})}function eA({item:e}){return(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:9,className:"px-0 py-0",children:(0,s.jsxs)("div",{className:"px-6 py-3 bg-muted/20 border-t border-border/30 space-y-2 text-xs animate-expand",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-1.5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,s.jsx)("span",{className:"font-mono text-foreground",children:e.sessionId??"—"}),e.sessionId&&(0,s.jsx)(en.CopyButton,{text:e.sessionId})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,s.jsx)("span",{className:"font-mono text-foreground",children:e.cwd??"—"}),e.cwd&&(0,s.jsx)(en.CopyButton,{text:e.cwd})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,s.jsx)("span",{className:"font-mono text-foreground break-all",children:e.transcriptPath??"—"}),e.transcriptPath?.startsWith("opencode-db://")&&(0,s.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),e.policyNames&&e.policyNames.length>1&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,s.jsx)("span",{className:"font-mono text-foreground",children:e.policyNames.join(", ")})]}),e.reason&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,s.jsx)("span",{className:"text-foreground",children:e.reason})]})]})})})}function eC({sessionId:e,initialData:t}){let{intervalSec:r}=(0,eN.useAutoRefresh)(),[i,l]=(0,n.useState)(!1),[o,a]=(0,n.useState)(1),[d,c]=(0,n.useState)(t),[u,h]=(0,n.useState)(null),[m,f]=(0,n.useState)(""),[p,g]=(0,n.useState)(""),[x,y]=(0,n.useState)(""),b=(0,n.useRef)(null),j=(0,n.useRef)({filterDecision:m,filterEventType:p,filterPolicy:x});j.current={filterDecision:m,filterEventType:p,filterPolicy:x};let S=""!==m||""!==p||""!==x,w=(0,n.useCallback)(async t=>{try{let{filterDecision:s,filterEventType:n,filterPolicy:r}=j.current,i=await (0,ey.searchHookActivityAction)({sessionId:e,decision:s||void 0,eventType:n||void 0,policyName:r||void 0},t);c(i)}catch{}},[e]);(0,n.useEffect)(()=>{w(o);let e=setInterval(()=>w(o),r>0?1e3*r:5e3);return()=>clearInterval(e)},[o,w,r]),(0,n.useEffect)(()=>(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{a(1),h(null),w(1)},300),()=>{b.current&&clearTimeout(b.current)}),[m,p,x]);let N=d.entries,M=d.totalPages;return(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{onClick:()=>l(e=>!e),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(v.ChevronDown,{className:`w-4 h-4 text-muted-foreground transition-transform ${i?"-rotate-90":""}`}),(0,s.jsx)("span",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Hook Logs"})]}),!i&&(0,s.jsxs)("div",{className:"mt-2 bg-card border border-border rounded-lg overflow-hidden shadow-sm",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2.5 border-b border-border bg-muted/20",children:[(0,s.jsx)(eI,{value:m,onChange:f}),(0,s.jsxs)("select",{value:p,onChange:e=>g(e.target.value),className:"h-7 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow",children:[(0,s.jsx)("option",{value:"",children:"All Events"}),(0,s.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,s.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,s.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,s.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,s.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,s.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]}),(0,s.jsx)("div",{className:"relative",children:(0,s.jsx)("input",{type:"text",value:x,onChange:e=>y(e.target.value),placeholder:"Filter by policy…",className:"h-7 rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground w-44 focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow"})})]}),0===N.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[(0,s.jsx)(eS.Shield,{className:"h-10 w-10 text-muted-foreground/30"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mt-3",children:S?"No matching hook events.":"No hook events found."})]}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-xs",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border bg-muted/30",children:[(0,s.jsx)("th",{className:"px-4 py-2.5 font-medium w-6"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Decision"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Event"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Tool"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Policy"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Reason"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Duration"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Mode"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium text-right",children:"Time"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border/30",children:N.map((e,t)=>{let r="deny"===e.decision,i=u===t,l="instruct"===e.decision;return(0,s.jsxs)(n.default.Fragment,{children:[(0,s.jsxs)("tr",{onClick:()=>{h(e=>e===t?null:t)},className:`cursor-pointer transition-colors ${r?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":l?"bg-amber-500/[0.03] hover:bg-amber-500/[0.07] border-l-2 border-l-amber-500/40":t%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${i?"bg-muted/20":""}`,children:[(0,s.jsx)("td",{className:"px-4 py-2",children:(0,s.jsx)(v.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${i?"rotate-0":"-rotate-90"}`})}),(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)(eM,{decision:e.decision})}),(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)(ek,{eventType:e.eventType})}),(0,s.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:e.toolName??"—"}),(0,s.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:e.policyNames&&e.policyNames.length>1?(0,s.jsxs)("span",{title:e.policyNames.join(", "),children:[e.policyNames[0],(0,s.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",e.policyNames.length-1]})]}):e.policyName??"—"}),(0,s.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate max-w-[240px]",title:e.reason??"",children:e.reason??"—"}),(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)(eT,{ms:e.durationMs})}),(0,s.jsx)("td",{className:"px-3 py-2",children:e.permissionMode?(0,s.jsx)(eE,{mode:e.permissionMode}):"—"}),(0,s.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground whitespace-nowrap",title:new Date(e.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(0,R.formatRelativeTime)(e.timestamp)})]}),i&&(0,s.jsx)(eA,{item:e})]},`${e.timestamp}-${t}`)})})]})}),(0,s.jsx)(ew.default,{currentPage:o,totalPages:M,onPageChange:e=>{a(e),h(null)}})]})]})}function eO(e){let t=new Map;for(let s of e)if("assistant"===s.type)for(let e of s.message.content){if("tool_use"!==e.type||"Task"===e.name&&(e.subagentType||e.subagentId))continue;let s=t.get(e.name)||{count:0,totalDurationMs:0};s.count++,e.result?.durationMs&&(s.totalDurationMs+=e.result.durationMs),t.set(e.name,s)}return Array.from(t.entries()).map(([e,t])=>({name:e,...t})).sort((e,t)=>t.count-e.count)}function ez({tools:e,compact:t}){return(0,s.jsx)("div",{className:`bg-card border border-border rounded-lg ${t?"p-3":"p-4"}`,children:(0,s.jsx)("div",{className:`grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] ${t?"gap-2":"gap-3"}`,children:e.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,s.jsx)(w,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("div",{className:`${t?"text-xs":"text-sm"} font-mono font-medium truncate`,children:e.name}),(0,s.jsxs)("div",{className:"text-xs text-muted-foreground truncate",children:[e.count," call",1!==e.count?"s":"",e.totalDurationMs>0&&` \xb7 ${(e.totalDurationMs/1e3).toFixed(1)}s`]})]})]},e.name))})})}function e_(e,t){return t.get(e)??`${e.uuid}-${e.timestampMs}`}function eD(){let e=window.location.hash;return e.startsWith("#entry-")?e.slice(7):null}function eF({entries:e,entriesBySource:t,projectName:i,sessionId:l}){let o=(0,n.useMemo)(()=>Array.from(t.values()).flat(),[t]),[a,d]=(0,n.useState)(new Set),[c,u]=(0,n.useState)(0),[m,p]=(0,n.useState)(()=>eD()),y=(0,n.useRef)(void 0),v=(0,n.useRef)(!1),j=(0,n.useRef)(null);(0,n.useLayoutEffect)(()=>{let e=j.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().top+window.scrollY;u(e=>e===t?e:t)};t();let s=new ResizeObserver(t);return s.observe(document.body),window.addEventListener("resize",t),()=>{s.disconnect(),window.removeEventListener("resize",t)}},[]);let S=(0,n.useMemo)(()=>N(e),[e]),w=(0,n.useMemo)(()=>(function(e,t){let s=new Map,n=null,r=0;for(let i of e)"queue-operation"===i.type?(null!==n&&s.set(n,r),n=e_(i,t),r=0):null!==n&&r++;return null!==n&&s.set(n,r),s})(e,S),[e,S]),M=(0,n.useMemo)(()=>{let t;return t=!1,e.filter(e=>"queue-operation"===e.type?(t=a.has(e_(e,S)),!0):!t)},[e,a,S]),k=(0,n.useMemo)(()=>{let e=new Map;return M.forEach((t,s)=>{t.uuid&&e.set(t.uuid,s)}),e},[M]),E=(0,n.useMemo)(()=>(function(e){let t=new Map;for(let s of e)if("assistant"===s.type&&s.uuid)for(let e of s.message.content)"tool_use"===e.type&&"Task"===e.name&&e.subagentId&&t.set(e.subagentId,s.uuid);let s=new Map;for(let n of e){if(!n._source?.startsWith("agent-")||!n.uuid)continue;let e=n._source.slice(6),r=t.get(e);r&&s.set(n.uuid,r)}return s})(o),[o]),T=(0,n.useMemo)(()=>m&&E.has(m)?m:null,[m,E]),I=T?E.get(T)??null:null;(0,n.useEffect)(()=>{if(m)return y.current=setTimeout(()=>p(null),4e3),()=>{y.current&&clearTimeout(y.current)}},[]),(0,n.useEffect)(()=>{let e=()=>{let e=eD();p(e),v.current=!1,y.current&&clearTimeout(y.current),e&&(y.current=setTimeout(()=>p(null),4e3))};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);let A=(0,n.useMemo)(()=>{if(!m)return null;let t=I??m,s=e.some(e=>e.uuid===t),n=k.has(t);if(s&&!n){let s=null;for(let n of e)if("queue-operation"===n.type)s=e_(n,S);else if(n.uuid===t&&s)return s}return null},[m,I,e,k,S]);(0,n.useEffect)(()=>{if(!A)return;let e=requestAnimationFrame(()=>{d(e=>{if(!e.has(A))return e;let t=new Set(e);return t.delete(A),t})});return()=>cancelAnimationFrame(e)},[A]);let C=(0,n.useCallback)(e=>{d(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),O=(0,n.useCallback)(e=>S.get(M[e])??e,[S,M]),z=function({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:s="transform",...i}){let l=n.useReducer(e=>e+1,0)[1],o=n.useRef({enabled:t,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=s;let a=n.useRef(!1),d=e=>{let t=o.current;if(!t.enabled||!t.container)return;let s=e.getTotalSize();if(s!==t.lastSize){t.lastSize=s;let n=e.options.horizontal?"width":"height";t.container.style[n]=`${s}px`}},c=e=>{let t=o.current;if(!t.enabled||!t.container)return;d(e);let s=!!e.options.horizontal,n="transform"===t.mode,r=s?"left":"top",i=e.options.scrollMargin;for(let l of e.getVirtualItems()){let o=l.start-i,a=e.elementsCache.get(l.key);a&&t.lastPositions.get(a)!==o&&(t.lastPositions.set(a,o),n?a.style.transform=s?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:a.style[r]=`${o}px`)}},u={...i,onChange:(t,s)=>{var n;let d=o.current,u=!0;if(d.enabled){c(t);let e=t.range,s=d.prevRange;(u=!s||s.isScrolling!==t.isScrolling||s.startIndex!==(null==e?void 0:e.startIndex)||s.endIndex!==(null==e?void 0:e.endIndex))&&(d.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&s&&!a.current?(0,r.flushSync)(l):l()),null==(n=i.onChange)||n.call(i,t,s)}},[h]=n.useState(()=>{let e=new x(u),t=e.measureElement;return e.measureElement=e=>{a.current=!0;try{t(e)}finally{a.current=!1}},Object.assign(e,{containerRef:t=>{let s=o.current;if(s.container=t,s.lastSize=null,t&&s.enabled){let n=e.getTotalSize();s.lastSize=n;let r=e.options.horizontal?"width":"height";t.style[r]=`${n}px`}}})});return h.setOptions(u),b(()=>h._didMount(),[]),b(()=>(d(h),h._willUpdate())),b(()=>{c(h)}),h}({getScrollElement:()=>"u">typeof document?window:null,observeElementRect:h,observeElementOffset:f,scrollToFn:g,initialOffset:()=>"u">typeof document?window.scrollY:0,...{count:M.length,estimateSize:e=>(function(e){switch(e.type){case"queue-operation":return 48;case"user":return 90;case"assistant":return 80+120*e.message.content.length;default:return 100}})(M[e]),getItemKey:O,overscan:5,scrollMargin:c}});return(0,n.useEffect)(()=>{if(!m||v.current)return;let e=I??m,t=k.get(e);null!=t&&(v.current=!0,requestAnimationFrame(()=>{z.scrollToIndex(t,{align:"center"})}))},[m,I,k,z]),(0,s.jsx)("div",{ref:j,children:(0,s.jsx)("div",{style:{height:`${z.getTotalSize()}px`,width:"100%",position:"relative"},children:z.getVirtualItems().map(e=>{let n=M[e.index],r=!!m&&n.uuid===(I??m);return(0,s.jsx)("div",{"data-index":e.index,ref:z.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${e.start-z.options.scrollMargin}px)`},children:"queue-operation"===n.type?(0,s.jsx)(B,{entry:n,isCollapsed:a.has(e_(n,S)),entryCount:w.get(e_(n,S))??0,onToggle:()=>C(e_(n,S))}):(0,s.jsx)(ex,{entry:n,entriesBySource:t,projectName:i,sessionId:l,isHighlighted:!T&&r,highlightedUuid:T,autoExpandForUuid:T})},e.key)})})})}let eR=[];e.s([],76248),e.i(76248),e.s(["default",0,function({entries:e,projectName:t,sessionId:r}){let i=(0,n.useMemo)(()=>{let t=new Map;for(let s of e){let e=t.get(s._source);e?e.push(s):t.set(s._source,[s])}return t},[e]),l=i.get("session")??eR,o=(0,n.useMemo)(()=>(function(e){let t=new Map;for(let s of e)if("assistant"===s.type)for(let e of s.message.content)"tool_use"===e.type&&"Task"===e.name&&e.subagentId&&(t.has(e.subagentId)||t.set(e.subagentId,{id:e.subagentId,type:e.subagentType||"unknown",description:e.subagentDescription||""}));return Array.from(t.values())})(e),[e]),a=(0,n.useMemo)(()=>eO(l),[l]),[d,c]=(0,n.useState)(!1),[u,h]=(0,n.useState)(new Set),[m,f]=(0,n.useState)(!1),[p,g]=(0,n.useState)(null);(0,n.useEffect)(()=>{(0,ey.searchHookActivityAction)({sessionId:r},1).then(e=>{e.entries.length>0&&g(e)}).catch(()=>{})},[r]),(0,n.useEffect)(()=>{let e=()=>{window.location.hash.startsWith("#entry-")&&f(!1)};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);let x=(0,n.useCallback)(e=>{h(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]);return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)($,{entries:l}),p&&(0,s.jsx)(eC,{sessionId:r,initialData:p},r),o.length>0&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("button",{onClick:()=>c(e=>!e),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(v.ChevronDown,{className:`w-4 h-4 text-muted-foreground transition-transform ${d?"-rotate-90":""}`}),(0,s.jsx)("span",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Subagents"}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",o.length,")"]})]}),!d&&o.map(e=>{let t;return(0,s.jsxs)("div",{className:"pl-3 border-l-2 border-primary/30 space-y-2",children:[(0,s.jsxs)("button",{onClick:()=>x(e.id),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(v.ChevronDown,{className:`w-3.5 h-3.5 text-muted-foreground transition-transform ${u.has(e.id)?"-rotate-90":""}`}),(0,s.jsx)("span",{className:"text-sm font-bold",children:e.type}),e.description&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[400px]",children:e.description})]}),!u.has(e.id)&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)($,{entries:i.get(`agent-${e.id}`)||[],compact:!0}),(t=eO(i.get(`agent-${e.id}`)||[])).length>0?(0,s.jsx)(ez,{tools:t,compact:!0}):null]})]},e.id)})]}),a.length>0&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Tools"}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",a.reduce((e,t)=>e+t.count,0),")"]})]}),(0,s.jsx)(ez,{tools:a})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{onClick:()=>f(e=>!e),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(v.ChevronDown,{className:`w-4 h-4 text-muted-foreground transition-transform ${m?"-rotate-90":""}`}),(0,s.jsx)("span",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Logs"})]}),!m&&(0,s.jsx)("div",{className:"mt-2 bg-card border border-border rounded-lg p-4 shadow-sm",children:0===l.length?(0,s.jsx)("p",{className:"text-muted-foreground text-center py-8",children:"No entries found."}):(0,s.jsx)(eF,{entries:l,entriesBySource:i,projectName:t,sessionId:r})})]})]})}],36406)},5780,function(e){e.n(e.i(36406))}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,36406,e=>{"use strict";let t;var s=e.i(43476),n=e.i(71645),r=e.i(74080);function i(e,t,s){let n,r=s.initialDeps??[],i=!0;function l(){let l=e();return(l.length!==r.length||l.some((e,t)=>r[t]!==e))&&(r=l,n=t(...l),(null==s?void 0:s.onChange)&&!(i&&s.skipInitialOnChange)&&s.onChange(n),i=!1),n}return l.updateDeps=e=>{r=e},l}function l(e,t){if(void 0!==e)return e;throw Error(`Unexpected undefined${t?`: ${t}`:""}`)}let o=(e,t)=>1.01>Math.abs(e-t),a=()=>{if(void 0!==t)return t;if("u"<typeof navigator)return t=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return t=!0;let e=navigator.maxTouchPoints;return t="MacIntel"===navigator.platform&&void 0!==e&&e>0},d=e=>e,c=e=>{let t=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,n=Array(s);for(let e=0;e<s;e++)n[e]=t+e;return n},u={passive:!0},h=(e,t)=>{let s=e.scrollElement;if(!s)return;let n=()=>{t({width:s.innerWidth,height:s.innerHeight})};return n(),s.addEventListener("resize",n,u),()=>{s.removeEventListener("resize",n)}},m="u"<typeof window||"onscrollend"in window,f=(e,t)=>((e,t,s)=>{var n,r;let i,l=e.scrollElement;if(!l)return;let o=e.targetWindow;if(!o)return;let a=e.options.useScrollendEvent&&m,d=0,c=a?null:(n=()=>t(s(l),!1),r=e.options.isScrollingResetDelay,Object.assign(function(...e){o.clearTimeout(i),i=o.setTimeout(()=>n.apply(this,e),r)},{cancel:()=>{o.clearTimeout(i)}})),h=e=>()=>{d=s(l),null==c||c(),t(d,e)},f=h(!0),p=h(!1);return l.addEventListener("scroll",f,u),a&&l.addEventListener("scrollend",p,u),()=>{l.removeEventListener("scroll",f),a&&l.removeEventListener("scrollend",p),null==c||c.cancel()}})(e,t,t=>e.options.horizontal?t.scrollX:t.scrollY),p=(e,t,s)=>{if(s.options.useCachedMeasurements){let t=s.indexFromElement(e),n=s.options.getItemKey(t);return s.itemSizeCache.get(n)??s.options.estimateSize(t)}if(null==t?void 0:t.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[s.options.horizontal?"inlineSize":"blockSize"])}if(!t){let t=s.indexFromElement(e),n=s.options.getItemKey(t),r=s.itemSizeCache.get(n);if(void 0!==r)return r}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},g=(e,{adjustments:t=0,behavior:s},n)=>{var r,i;null==(i=null==(r=n.scrollElement)?void 0:r.scrollTo)||i.call(r,{[n.options.horizontal?"left":"top"]:e+t,behavior:s})};class x{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=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._clampedAdjustment=null,this.elementsCache=new Map,this.now=()=>{var e,t,s;return(null==(s=null==(t=null==(e=this.targetWindow)?void 0:e.performance)?void 0:t.now)?void 0:s.call(t))??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(this.targetWindow&&this.targetWindow.ResizeObserver?e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,s=this.indexFromElement(t);if(!t.isConnected){for(let[e,s]of(this.observer.unobserve(t),this.elementsCache))if(s===t){this.elementsCache.delete(e);break}return}this.isIndexInRange(s)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}):null);return{disconnect:()=>{var s;null==(s=t())||s.disconnect(),e=null},observe:e=>{var s;return null==(s=t())?void 0:s.observe(e,{box:"border-box"})},unobserve:e=>{var s;return null==(s=t())?void 0:s.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{var t;let s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:d,rangeExtractor:c,onChange:()=>{},measureElement:p,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 t in e){let n=e[t];void 0!==n&&(s[t]=n)}let n=this.options,r=null,i=null,l=!1;if(void 0!==n&&n.enabled&&s.enabled&&"end"===s.anchorTo&&null!==this.scrollElement){let e=n.count,o=s.count,a=this.getMeasurements(),d=(null==(t=this._singleLaneMeasurements)?void 0:t.items)??a,c=e=>{var t;return"object"==typeof(t=d[e])?t.key:t},u=e>0?c(0):null,h=e>0?c(e-1):null;if(o!==e||e>0&&o>0&&(s.getItemKey(0)!==u||s.getItemKey(o-1)!==h)){l=!0;let t=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??a[0]:null;t&&(r=[t.key,this.getScrollOffset()-t.start]);let d=!0===s.followOnAppend?"auto":s.followOnAppend||null;d&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(0===e||s.getItemKey(o-1)!==h)&&(o>e||function(e,t,s,n){if(0===t)return!1;let r=n(0),i=new Set,l=0;for(;l<e;){let e=s(l);if(e===r)break;i.add(e),l++}let o=e-l;if(0===o||o>=t)return!1;for(let e=0;e<o;e++)if(n(e)!==s(l+e))return!1;for(let e=o;e<t;e++)if(i.has(n(e)))return!1;return!0}(e,o,c,s.getItemKey))&&(i=d)}}this.options=s,l&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,a=0;if(r&&null!==this.scrollOffset){let[e,t]=r,s=this.getMeasurements(),{count:n,getItemKey:l}=this.options,d=0;for(;d<n&&l(d)!==e;)d++;if(d<n){let e=s[d];if(e){let s=Math.max(0,e.start+t);i||s===this.scrollOffset||(a=s-this.scrollOffset,this.scrollOffset=s,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,a])},this.notify=e=>{var t,s;null==(s=(t=this.options).onChange)||s.call(t,this,e)},this.maybeNotify=i(()=>(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(),null!=this.rafId&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e,t;let s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s)return void this.maybeNotify();if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(e=this.scrollElement)?void 0:e.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&&null===this._intendedScrollOffset&&e===this.scrollOffset)return;null!==this._intendedScrollOffset&&1.5>Math.abs(e-this._intendedScrollOffset)&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,null!==this._clampedAdjustment&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let s=this.getScrollOffset();this.scrollDirection=t?s===e?this.scrollDirection:s<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,null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},s=()=>{this._iosTouching=!1,a()&&null!=this.targetWindow&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener("touchstart",t,u),e.addEventListener("touchend",s,u),this.unsubs.push(()=>{e.removeEventListener("touchstart",t),e.removeEventListener("touchend",s),null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let n=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,n&&this.scrollElement&&this.options.enabled){let[e,s,r,i]=n;null!==e&&!r&&(a()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?0!==i&&(this._iosDeferredAdjustment+=i):((null==(t=this.scrollState)?void 0:t.behavior)!=="smooth"||o(this.getScrollOffset()-i,this.scrollState.lastTargetOffset))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(null===this._clampedAdjustment||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,s=this.getMaxScrollOffset();s>t+.5&&(this._clampedAdjustment=e>s+.5?{target:e,maxAtWrite:s}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(0===this._iosDeferredAdjustment||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let s=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=s,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??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=i(()=>[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,s,n,r,i,l,o)=>(void 0!==this.prevLanes&&this.prevLanes!==i&&(this.lanesChangedFlag=!0),this.prevLanes=i,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:s,getItemKey:n,enabled:r,lanes:i,laneAssignmentMode:l,gap:o}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=i(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:s,getItemKey:n,enabled:r,lanes:i,laneAssignmentMode:l,gap:o},a)=>{var d,c;let u=this.itemSizeCache;if(!r)return this.measurementsCache=[],this._singleLaneMeasurements=null,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._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let h=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),1===i){let r,i,l=2*e,a=null==(d=this._singleLaneMeasurements)?void 0:d.flat;if(!a||a.length<l){let e=new Float64Array(l);a&&h>0&&e.set(a.subarray(0,2*h)),a=e}let m=0===h?Array(e):this._singleLaneMeasurements.items.slice();if(0===h)r=t+s;else{let e=h-1;r=a[2*e]+a[2*e+1]+o}for(let t=h;t<e;t++){let e=n(t);m[t]=e;let s=u.get(e),i="number"==typeof s?s:this.options.estimateSize(t);a[2*t]=r,a[2*t+1]=i,r+=i+o}this._singleLaneMeasurements={flat:a,items:m};let f=(c=a,i=m.length,new Proxy(m,{get(e,t,s){if("string"==typeof t){let s=t.charCodeAt(0);if(s>=48&&s<=57){let s=+t;if(Number.isInteger(s)&&s>=0&&s<i){let t=e[s];if("object"!=typeof t){let n=c[2*s];t=e[s]={index:s,key:t,start:n,size:c[2*s+1],end:n+c[2*s+1],lane:0}}return t}}if("length"===t)return i}return Reflect.get(e,t,s)}}));return this.measurementsCache=f,f}let m=this.measurementsCache.slice(0,h),f=Array(i).fill(void 0),p=new Float64Array(i),g=0;for(let e=0;e<h;e++){let t=m[e];t&&(void 0===f[t.lane]&&g++,f[t.lane]=e,p[t.lane]=t.end)}for(let r=h;r<e;r++){let e,a,d=n(r),c=this.laneAssignments.get(r),h="estimate"===l||u.has(d);if(void 0!==c&&this.options.lanes>1){let n=f[e=c],r=void 0!==n?m[n]:void 0;a=r?r.end+o:t+s}else if(g===i){let t=0,s=p[0],n=f[0];for(let e=1;e<i;e++){let r=p[e];(r<s||r===s&&f[e]<n)&&(t=e,s=r,n=f[e])}e=t,a=s+o,h&&this.laneAssignments.set(r,e)}else e=r%this.options.lanes,a=t+s,h&&this.laneAssignments.set(r,e);let x=u.get(d),y="number"==typeof x?x:this.options.estimateSize(r),b=a+y;m[r]={index:r,start:a,size:y,end:b,key:d,lane:e},void 0===f[e]&&g++,f[e]=r,p[e]=b}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=i(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,s,n)=>0===e.length||0===t?(this.range=null,null):(this.range=function(e,t,s,n,r){let i=e.length-1;if(e.length<=n)return{startIndex:0,endIndex:i};if(1===n&&null!==r){let e=function(e,t,s){let n=0;for(;n<=t;){let r=(n+t)/2|0,i=e[2*r];if(i<s)n=r+1;else{if(!(i>s))return r;t=r-1}}return n>0?n-1:0}(r,i,s),n=e,l=s+t;for(;n<i&&r[2*n]+r[2*n+1]<l;)n++;return{startIndex:e,endIndex:n}}let l=y(0,i,t=>e[t].start,s),o=l;if(1===n)for(;o<i&&e[o].end<s+t;)o++;else if(n>1){let r=Array(n).fill(0);for(;o<i&&r.some(e=>e<s+t);){let t=e[o];r[t.lane]=t.end,o++}let a=Array(n).fill(s+t);for(;l>=0&&a.some(e=>e>=s);){let t=e[l];a[t.lane]=t.start,l--}l=Math.max(0,l-l%n),o=Math.min(i,o+(n-1-o%n))}return{startIndex:l,endIndex:o}}(e,t,s,n,1===n&&null!==this._singleLaneMeasurements?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=i(()=>{let e=null,t=null,s=this.calculateRange();return s&&(e=s.startIndex,t=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,s,n,r)=>null===n||null===r?[]:e({startIndex:n,endIndex:r,overscan:t,count:s}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,s=e.getAttribute(t);return s?parseInt(s,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t;if(!this.scrollState||"smooth"!==this.scrollState.behavior)return!0;let s=this.scrollState.index??(null==(t=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))?void 0:t.index);if(void 0!==s&&this.range){let t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),n=Math.max(0,s-t),r=Math.min(this.options.count-1,s+t);return e>=n&&e<=r}return!0},this.measureElement=e=>{if(!e)return void this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let s=this.options.getItemKey(t),n=this.elementsCache.get(s);n!==e&&(n&&this.observer.unobserve(n),this.observer.observe(e),this.elementsCache.set(s,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var s,n,r;let i,l,o;if(!this.isIndexInRange(e))return;let a=null==(s=this._singleLaneMeasurements)?void 0:s.flat;if(1===this.options.lanes&&null!=a)o=this.options.getItemKey(e),l=a[2*e],i=a[2*e+1];else{let t=this.measurementsCache[e];if(!t)return;o=t.key,l=t.start,i=t.size}let d=this.itemSizeCache.get(o)??i,c=t-d;if(0!==c){let s="end"===this.options.anchorTo&&(null==(n=this.scrollState)?void 0:n.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,a=s?this.getTotalSize():0,u=this.getScrollOffset()+this.scrollAdjustments,h=this.itemSizeCache.has(o)?l+d<=u&&"backward"!==this.scrollDirection:l<u,m=(null==(r=this.scrollState)?void 0:r.behavior)!=="smooth"&&(void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:o,start:l,size:i,end:l+i,lane:0},c,this):h);(null===this.pendingMin||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(o,t),this.itemSizeCacheVersion++;let f=!1;s?f=this.applyScrollAdjustment(this.getTotalSize()-a):m&&(f=this.applyScrollAdjustment(c)),this.notify(f),this._retryClampedAdjustment()}},this.getVirtualItems=i(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let s=[];for(let n=0,r=e.length;n<r;n++){let r=t[e[n]];s.push(r)}return s},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{var t;let s=this.getMeasurements();if(0===s.length)return;let n=null==(t=this._singleLaneMeasurements)?void 0:t.flat,r=1===this.options.lanes&&null!=n,i=y(0,s.length-1,r?e=>n[2*e]:e=>l(s[e]).start,e);return l(s[i])},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,s=0)=>{if(!this.scrollElement)return 0;let n=this.getSize(),r=this.getScrollOffset();return"auto"===t&&(t=e>=r+n?"end":"start"),"center"===t?e+=(s-n)/2:"end"===t&&(e-=n),Math.max(Math.min(this.getMaxScrollOffset(),e),0)},this.getOffsetForIndex=(e,t="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));let s=this.getSize(),n=this.getScrollOffset(),r=this.measurementsCache[e];if(!r)return;if("auto"===t)if(r.end>=n+s-this.options.scrollPaddingEnd)t="end";else{if(!(r.start<=n+this.options.scrollPaddingStart))return[n,t];t="start"}if("end"===t&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let i="end"===t?r.end+this.options.scrollPaddingEnd:r.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(i,t,r.size),t]},this.scrollToOffset=(e,{align:t="start",behavior:s="auto"}={})=>{this._iosDeferredAdjustment=0;let n=this.getOffsetForAlignment(e,t),r=this.now();this.scrollState={index:null,align:t,behavior:s,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t="auto",behavior:s="auto"}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getOffsetForIndex(e,t);if(!n)return;let[r,i]=n,l=this.now();this.scrollState={index:e,align:i,behavior:s,startedAt:l,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t="auto"}={})=>{let s=this.getScrollOffset()+e,n=this.now();this.scrollState={index:null,align:"start",behavior:t,startedAt:n,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e="auto"}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:"end",behavior:e}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{var e,t;let s,n=this.getMeasurements();if(0===n.length)s=this.options.paddingStart;else if(1===this.options.lanes){let r=n.length-1,i=null==(e=this._singleLaneMeasurements)?void 0:e.flat;s=null!=i?i[2*r]+i[2*r+1]:(null==(t=n[r])?void 0:t.end)??0}else{let e=Array(this.options.lanes).fill(null),t=n.length-1;for(;t>=0&&e.some(e=>null===e);){let s=n[t];null===e[s.lane]&&(e[s.lane]=s.end),t--}s=Math.max(...e.filter(e=>null!==e))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(0===this.itemSizeCache.size)return e;for(let t of this.getMeasurements())t&&this.itemSizeCache.has(t.key)&&e.push({index:t.index,key:t.key,start:t.start,size:t.size,end:t.end,lane:t.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:s})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:s,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){if(0===e)return!1;if(a()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{let s=this.getScrollOffset()+this.scrollAdjustments+e,n=this.scrollElement,r=null!==n&&("scrollHeight"in n||"document"in n)?this.getMaxScrollOffset():null;return this._clampedAdjustment=null!==r&&s>r+.5?{target:s,maxAtWrite:r}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),null!==this.scrollOffset&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}null==this.rafId&&(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=null!=this.scrollState.index?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,t=e?e[0]:this.scrollState.lastTargetOffset,s=t!==this.scrollState.lastTargetOffset;if(!s&&o(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,s){let e=this.getSize()||600,s=Math.abs(t-this.getScrollOffset()),n="smooth"===this.scrollState.behavior&&s>e;this.scrollState.lastTargetOffset=t,n||(this.scrollState.behavior="auto"),this._scrollToOffset(t,{adjustments:void 0,behavior:n?"smooth":"auto"})}this.scheduleScrollReconcile()}}let y=(e,t,s,n)=>{for(;e<=t;){let r=(e+t)/2|0,i=s(r);if(i<n)e=r+1;else{if(!(i>n))return r;t=r-1}}return e>0?e-1:0},b="u">typeof document?n.useLayoutEffect:n.useEffect;var v=e.i(16327),j=e.i(56420);let S={name:"wrench",size:24,node:[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]};S.node;let w=(0,j.default)(S);function N(e){let t=new Map,s=new Map;for(let n of e){let e=n.uuid||`${n._source}:${n.timestamp}`,r=s.get(e)??0;s.set(e,r+1),t.set(n,0===r?e:`${e}#${r}`)}return t}let M={name:"user",size:24,node:[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]};M.node;let k=(0,j.default)(M),E={name:"bot",size:24,node:[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]};E.node;let T=(0,j.default)(E),I={name:"cpu",size:24,node:[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]};I.node;let A=(0,j.default)(I),C={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};C.node;let O=(0,j.default)(C),z={name:"message-square",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]};z.node;let _=(0,j.default)(z),D={name:"workflow",size:24,node:[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]};D.node;let F=(0,j.default)(D);var R=e.i(34713);let $=n.default.memo(function({entries:e,compact:t=!1}){let r=(0,n.useMemo)(()=>(function(e){let t=0,s=0,n=0,r=0,i=0,l=new Set;for(let o of e)if("user"===o.type&&t++,"queue-operation"===o.type&&i++,"assistant"===o.type){for(let e of(s++,o.message.content))"tool_use"===e.type&&("Task"===e.name&&(e.subagentType||e.subagentId)?r++:n++);o.message.model&&l.add(o.message.model)}let o="";if(e.length>=2){let t=e[e.length-1].timestampMs-e[0].timestampMs;o=(0,R.formatDuration)(t)}return{turnCount:i,userCount:t,assistantCount:s,toolCallCount:n,subagentCount:r,duration:o,models:Array.from(l)}})(e),[e]),i=t?"w-3.5 h-3.5":"w-4 h-4",l=t?"text-xs font-medium":"text-sm font-medium",o=t?"text-[10px] text-muted-foreground":"text-xs text-muted-foreground",a=[...t?[]:[{Icon:_,color:"text-primary",v:r.turnCount,l:"Turns"}],{Icon:k,color:"text-[color:var(--chart-1)]",v:r.userCount,l:"User"},{Icon:T,color:"text-[color:var(--chart-2)]",v:r.assistantCount,l:"Assistant"},{Icon:w,color:"text-[color:var(--chart-3)]",v:r.toolCallCount,l:t?"Tools":"Tool Calls"},{Icon:F,color:"text-[color:var(--chart-5)]",v:r.subagentCount,l:"Subagents"},{Icon:O,color:"text-[color:var(--chart-4)]",v:r.duration||"—",l:"Duration"},{Icon:A,color:"text-[color:var(--chart-5)]",v:r.models.length>0?r.models.join(", "):"—",l:t?"Model":"Model(s)"}];return(0,s.jsx)("div",{className:t?"bg-muted/30 border border-border/50 rounded-lg p-3 mb-3":"bg-card border border-border rounded-lg p-4",children:(0,s.jsx)("div",{className:`grid grid-cols-2 ${t?"sm:grid-cols-6 gap-3":"sm:grid-cols-4 lg:grid-cols-7 gap-4"}`,children:a.map(({Icon:e,color:t,v:n,l:r})=>(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e,{className:`${i} ${t}`}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:`${l} truncate max-w-[120px]`,children:n}),(0,s.jsx)("div",{className:o,children:r})]})]},r))})})}),L={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]};L.node;let W=(0,j.default)(L);var P=e.i(67927);function U(e){return JSON.stringify(e.raw,null,2)}let q=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0});function H(e){let t=new Date(e),s=q.format(t),n=t.getMilliseconds().toString().padStart(3,"0");return`${s}.${n}`}let B=n.default.memo(function({entry:e,isCollapsed:t,entryCount:n,onToggle:r}){let i="function"==typeof r,l=(0,s.jsxs)("div",{className:`flex items-center gap-2 px-3 py-1 rounded-full bg-primary/10 border border-primary/20 text-primary text-xs font-medium${i?" group-hover:bg-primary/20 transition-colors":""}`,children:[i?(0,s.jsx)(P.ChevronRight,{className:`w-3 h-3 transition-transform ${t?"":"rotate-90"}`}):(0,s.jsx)(W,{className:"w-3 h-3"}),(0,s.jsx)("span",{children:e.label}),(0,s.jsx)("span",{className:"text-muted-foreground",children:H(e.timestampMs)}),i&&t&&"number"==typeof n&&(0,s.jsxs)("span",{className:"ml-1 px-1.5 py-0.5 rounded bg-primary/20 text-[10px] leading-none",children:[n," ",1===n?"entry":"entries"]})]});return i?(0,s.jsxs)("button",{type:"button",onClick:r,className:"group flex items-center gap-3 py-3 px-4 w-full cursor-pointer",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-primary/30"}),l,(0,s.jsx)("div",{className:"flex-1 h-px bg-primary/30"})]}):(0,s.jsxs)("div",{className:"flex items-center gap-3 py-3 px-4",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-primary/30"}),l,(0,s.jsx)("div",{className:"flex-1 h-px bg-primary/30"})]})});var V=e.i(47163);let K={user:"User",assistant:"Assistant","file-history-snapshot":"Snapshot",progress:"Progress",system:"System","queue-operation":"Queue"},J={user:"bg-[color:var(--chart-1)]/20 text-[color:var(--chart-1)] border-[color:var(--chart-1)]/30",assistant:"bg-[color:var(--chart-2)]/20 text-[color:var(--chart-2)] border-[color:var(--chart-2)]/30","file-history-snapshot":"bg-[color:var(--chart-3)]/20 text-[color:var(--chart-3)] border-[color:var(--chart-3)]/30",progress:"bg-[color:var(--chart-5)]/20 text-[color:var(--chart-5)] border-[color:var(--chart-5)]/30",system:"bg-[color:var(--chart-4)]/20 text-[color:var(--chart-4)] border-[color:var(--chart-4)]/30","queue-operation":"bg-primary/20 text-primary border-primary/30"},Y={user:"border-l-[color:var(--chart-1)]",assistant:"border-l-[color:var(--chart-2)]","file-history-snapshot":"border-l-[color:var(--chart-3)]",progress:"border-l-[color:var(--chart-5)]",system:"border-l-[color:var(--chart-4)]","queue-operation":"border-l-primary"},X={name:"file-text",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]};X.node;let Q=(0,j.default)(X),G={name:"activity",size:24,node:[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]};G.node;let Z=(0,j.default)(G);var ee=e.i(66794);function et({type:e}){let t="w-4 h-4";switch(e){case"user":return(0,s.jsx)(k,{className:t});case"assistant":return(0,s.jsx)(T,{className:t});case"file-history-snapshot":return(0,s.jsx)(Q,{className:t});case"progress":return(0,s.jsx)(Z,{className:t});case"system":return(0,s.jsx)(ee.Settings,{className:t});case"queue-operation":return(0,s.jsx)(W,{className:t})}}function es({type:e}){return(0,s.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs font-mono rounded border ${J[e]}`,children:[(0,s.jsx)(et,{type:e}),K[e]]})}var en=e.i(24380);function er({block:e}){let t=(0,n.useMemo)(()=>JSON.stringify(e.input,null,2),[e]);return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("details",{open:!0,children:[(0,s.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:(0,s.jsxs)("span",{className:"inline-flex items-center gap-1",children:["Input",(0,s.jsx)(en.CopyButton,{text:t})]})}),(0,s.jsx)("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:t})]}),e.result?(0,s.jsxs)("div",{className:"border-l-2 border-primary/50 pl-3 space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 text-xs font-mono rounded border bg-primary/20 text-primary border-primary/30",children:"Result"}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:H(new Date(e.result.timestamp).getTime())})]}),e.result.content&&(0,s.jsxs)("details",{open:!0,children:[(0,s.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:(0,s.jsxs)("span",{className:"inline-flex items-center gap-1",children:["Output",(0,s.jsx)(en.CopyButton,{text:e.result.content})]})}),(0,s.jsx)("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:e.result.content})]}),e.result.images?.map((e,t)=>(0,s.jsx)("img",{src:`data:${e.mediaType};base64,${e.base64}`,alt:`Tool result image ${t+1}`,className:"mt-2 max-w-full rounded border border-border"},t))]}):(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"Tool did not return a result"})]})}let ei={name:"brain",size:24,node:[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]};ei.node;let el=(0,j.default)(ei),eo=n.default.memo(function({block:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l}){switch(e.type){case"text":return(0,s.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:e.text});case"tool_use":if("Task"===e.name&&(e.subagentType||e.subagentId)){let o=e.subagentId&&t?t.get(`agent-${e.subagentId}`):void 0;return(0,s.jsx)(ep,{block:e,subagentEntries:o,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l})}return(0,s.jsxs)("div",{className:"border border-border/50 rounded-lg p-3 bg-muted/10",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(w,{className:"w-4 h-4 text-primary flex-shrink-0"}),(0,s.jsx)("span",{className:"font-mono text-sm text-primary truncate min-w-0",children:e.name}),e.result&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:e.result.durationFormatted})]}),(0,s.jsx)(er,{block:e})]});case"thinking":return(0,s.jsx)("div",{className:"border border-[color:var(--chart-5)]/30 rounded-lg p-3 bg-[color:var(--chart-5)]/5",children:(0,s.jsxs)("details",{children:[(0,s.jsxs)("summary",{className:"flex items-center gap-2 text-xs cursor-pointer hover:text-foreground transition-colors text-[color:var(--chart-5)]",children:[(0,s.jsx)(el,{className:"w-4 h-4"}),(0,s.jsx)("span",{children:"Thinking"}),(0,s.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",e.thinking.length.toLocaleString()," chars)"]})]}),(0,s.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-xs text-muted-foreground p-2 bg-muted/30 rounded max-h-64 overflow-y-auto",children:e.thinking})]})})}});function ea({entry:e}){return(0,s.jsx)("div",{children:e.message.content&&(0,s.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:e.message.content})})}let ed=n.default.memo(function({entry:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l}){let{content:o}=e.message;return(0,s.jsx)("div",{className:"space-y-3",children:o.map((e,o)=>(0,s.jsx)(eo,{block:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l},o))})}),ec=n.default.memo(function({entry:e}){let t=(0,n.useMemo)(()=>{if("progress"===e.type){let t=e.raw.data,s=t?.agentId;return[t?.type,s&&`agent:${s}`].filter(Boolean).join(" | ")}return"file-history-snapshot"===e.type?"File history snapshot":e.type},[e.type,e.raw]);return(0,s.jsxs)("div",{className:"text-sm",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:t}),(0,s.jsxs)("details",{className:"mt-1",children:[(0,s.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:"Show raw JSON"}),(0,s.jsx)("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:U(e)})]})]})}),eu={name:"link-2",size:24,node:[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]};eu.node;let eh=(0,j.default)(eu);var em=e.i(55574);function ef({uuid:e}){let t=(0,n.useCallback)(async()=>{window.history.replaceState(null,"",`#entry-${e}`);try{await navigator.clipboard.writeText(window.location.href)}catch{let e=document.createElement("textarea");e.value=window.location.href,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}(0,em.toast)("Link copied")},[e]);return(0,s.jsx)("button",{onClick:t,title:"Copy link to entry",className:"inline-flex items-center justify-center rounded p-1 text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors opacity-0 group-hover:opacity-100 transition-opacity",children:(0,s.jsx)(eh,{className:"w-3.5 h-3.5"})})}function ep({block:e,subagentEntries:t,projectName:r,sessionId:i,highlightedUuid:l,autoExpandForUuid:o}){let a=!!(o&&t?.some(e=>e.uuid===o)),[d,c]=(0,n.useState)(a);(0,n.useEffect)(()=>{if(!a)return;let e=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(e)},[a]);let u=(0,n.useCallback)(()=>{c(e=>!e)},[]),h=t&&t.length>0,m=(0,n.useMemo)(()=>N(t??[]),[t]);return(0,s.jsxs)("div",{className:"border border-border/50 rounded-lg p-3 bg-muted/10",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(F,{className:"w-4 h-4 text-[color:var(--chart-5)]"}),(0,s.jsx)("span",{className:"font-mono text-sm text-[color:var(--chart-5)]",children:"Subagent"}),e.subagentType&&(0,s.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 text-xs font-mono rounded border bg-[color:var(--chart-5)]/20 text-[color:var(--chart-5)] border-[color:var(--chart-5)]/30",children:e.subagentType}),e.result&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground ml-auto",children:e.result.durationFormatted})]}),e.subagentDescription&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground mb-2",children:e.subagentDescription}),e.subagentId&&t&&(0,s.jsxs)("button",{onClick:u,className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded border border-primary/30 bg-primary/10 text-primary hover:bg-primary/20 transition-colors mb-2",children:[(0,s.jsx)(P.ChevronRight,{className:(0,V.cn)("w-3 h-3 transition-transform",d&&"rotate-90")}),(0,s.jsxs)("span",{children:["agent-",e.subagentId]}),(0,s.jsx)("span",{className:"text-muted-foreground",children:d?"Collapse":"View subagent log"})]}),d&&(0,s.jsxs)("div",{className:"ml-4 pl-3 border-l-2 border-primary/30 mt-2 space-y-2",children:[t&&0===t.length&&(0,s.jsx)("div",{className:"text-xs text-muted-foreground py-2",children:"No entries found in subagent log."}),h&&(0,s.jsx)(s.Fragment,{children:(0,s.jsx)($,{entries:t,compact:!0})}),t&&t.map(e=>"queue-operation"===e.type?(0,s.jsx)(B,{entry:e},m.get(e)):(0,s.jsx)(ex,{entry:e,projectName:r,sessionId:i,isHighlighted:!!l&&e.uuid===l},m.get(e)))]}),(0,s.jsx)(er,{block:e})]})}function eg({entry:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l}){switch(e.type){case"user":return(0,s.jsx)(ea,{entry:e});case"assistant":return(0,s.jsx)(ed,{entry:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:i,autoExpandForUuid:l});case"file-history-snapshot":case"progress":case"system":return(0,s.jsx)(ec,{entry:e})}}let ex=n.default.memo(function({entry:e,entriesBySource:t,projectName:n,sessionId:r,isHighlighted:i,highlightedUuid:l,autoExpandForUuid:o}){return(0,s.jsxs)("div",{id:e.uuid?`entry-${e.uuid}`:void 0,className:(0,V.cn)(`group border-l-4 ${Y[e.type]} bg-card/50 rounded-r-lg mb-2 hover:bg-muted/30 transition-colors`,i&&"entry-highlighted"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border/30",children:[(0,s.jsx)(es,{type:e.type}),(0,s.jsxs)("div",{className:"flex items-center gap-1 ml-auto",children:[e.uuid&&(0,s.jsx)(ef,{uuid:e.uuid}),(0,s.jsx)(en.CopyButton,{text:function(e){switch(e.type){case"user":return e.message.content;case"assistant":return e.message.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n");case"file-history-snapshot":case"progress":case"system":return U(e);case"queue-operation":return e.label}}(e)}),(0,s.jsx)("span",{className:"text-xs font-mono text-muted-foreground whitespace-nowrap",children:H(e.timestampMs)})]})]}),(0,s.jsx)("div",{className:"px-4 py-3",children:(0,s.jsx)(eg,{entry:e,entriesBySource:t,projectName:n,sessionId:r,highlightedUuid:l,autoExpandForUuid:o})})]})},(e,t)=>e.entry===t.entry&&e.entriesBySource===t.entriesBySource&&e.projectName===t.projectName&&e.sessionId===t.sessionId&&e.isHighlighted===t.isHighlighted&&e.highlightedUuid===t.highlightedUuid&&e.autoExpandForUuid===t.autoExpandForUuid);var ey=e.i(50393),eb=e.i(84026),ev=e.i(29407),ej=e.i(16306),eS=e.i(82954),ew=e.i(73520),eN=e.i(85881);function eM({decision:e}){return"deny"===e?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-red-500/10 text-red-400 border border-red-500/20",children:[(0,s.jsx)(ev.ShieldX,{className:"h-3 w-3"}),"Deny"]}):"instruct"===e?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[(0,s.jsx)(ej.ShieldAlert,{className:"h-3 w-3"}),"Instruct"]}):(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(0,s.jsx)(eb.ShieldCheck,{className:"h-3 w-3"}),"Allow"]})}function ek({eventType:e}){return(0,s.jsx)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium bg-muted text-muted-foreground border border-border/50",children:e})}function eE({mode:e}){let t="default"===e;return(0,s.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${t?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:e})}function eT({ms:e}){return(0,s.jsx)("span",{className:`font-mono text-[0.7rem] ${e>500?"text-red-400":e>100?"text-amber-400":"text-muted-foreground"}`,children:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`})}function eI({value:e,onChange:t}){return(0,s.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5",children:[{label:"All",value:""},{label:"Allow",value:"allow"},{label:"Instruct",value:"instruct"},{label:"Deny",value:"deny"}].map(n=>(0,s.jsx)("button",{onClick:()=>t(n.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${e===n.value?"deny"===n.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===n.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===n.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:n.label},n.value))})}function eA({item:e}){return(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:9,className:"px-0 py-0",children:(0,s.jsxs)("div",{className:"px-6 py-3 bg-muted/20 border-t border-border/30 space-y-2 text-xs animate-expand",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-1.5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,s.jsx)("span",{className:"font-mono text-foreground",children:e.sessionId??"—"}),e.sessionId&&(0,s.jsx)(en.CopyButton,{text:e.sessionId})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,s.jsx)("span",{className:"font-mono text-foreground",children:e.cwd??"—"}),e.cwd&&(0,s.jsx)(en.CopyButton,{text:e.cwd})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,s.jsx)("span",{className:"font-mono text-foreground break-all",children:e.transcriptPath??"—"}),e.transcriptPath?.startsWith("opencode-db://")&&(0,s.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),e.policyNames&&e.policyNames.length>1&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,s.jsx)("span",{className:"font-mono text-foreground",children:e.policyNames.join(", ")})]}),e.reason&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,s.jsx)("span",{className:"text-foreground",children:e.reason})]})]})})})}function eC({sessionId:e,initialData:t}){let{intervalSec:r}=(0,eN.useAutoRefresh)(),[i,l]=(0,n.useState)(!1),[o,a]=(0,n.useState)(1),[d,c]=(0,n.useState)(t),[u,h]=(0,n.useState)(null),[m,f]=(0,n.useState)(""),[p,g]=(0,n.useState)(""),[x,y]=(0,n.useState)(""),b=(0,n.useRef)(null),j=(0,n.useRef)({filterDecision:m,filterEventType:p,filterPolicy:x});j.current={filterDecision:m,filterEventType:p,filterPolicy:x};let S=""!==m||""!==p||""!==x,w=(0,n.useCallback)(async t=>{try{let{filterDecision:s,filterEventType:n,filterPolicy:r}=j.current,i=await (0,ey.searchHookActivityAction)({sessionId:e,decision:s||void 0,eventType:n||void 0,policyName:r||void 0},t);c(i)}catch{}},[e]);(0,n.useEffect)(()=>{w(o);let e=setInterval(()=>w(o),r>0?1e3*r:5e3);return()=>clearInterval(e)},[o,w,r]),(0,n.useEffect)(()=>(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{a(1),h(null),w(1)},300),()=>{b.current&&clearTimeout(b.current)}),[m,p,x]);let N=d.entries,M=d.totalPages;return(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{onClick:()=>l(e=>!e),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(v.ChevronDown,{className:`w-4 h-4 text-muted-foreground transition-transform ${i?"-rotate-90":""}`}),(0,s.jsx)("span",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Hook Logs"})]}),!i&&(0,s.jsxs)("div",{className:"mt-2 bg-card border border-border rounded-lg overflow-hidden shadow-sm",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2.5 border-b border-border bg-muted/20",children:[(0,s.jsx)(eI,{value:m,onChange:f}),(0,s.jsxs)("select",{value:p,onChange:e=>g(e.target.value),className:"h-7 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow",children:[(0,s.jsx)("option",{value:"",children:"All Events"}),(0,s.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,s.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,s.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,s.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,s.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,s.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]}),(0,s.jsx)("div",{className:"relative",children:(0,s.jsx)("input",{type:"text",value:x,onChange:e=>y(e.target.value),placeholder:"Filter by policy…",className:"h-7 rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground w-44 focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow"})})]}),0===N.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[(0,s.jsx)(eS.Shield,{className:"h-10 w-10 text-muted-foreground/30"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mt-3",children:S?"No matching hook events.":"No hook events found."})]}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-xs",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border bg-muted/30",children:[(0,s.jsx)("th",{className:"px-4 py-2.5 font-medium w-6"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Decision"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Event"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Tool"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Policy"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Reason"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Duration"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Mode"}),(0,s.jsx)("th",{className:"px-3 py-2.5 font-medium text-right",children:"Time"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border/30",children:N.map((e,t)=>{let r="deny"===e.decision,i=u===t,l="instruct"===e.decision;return(0,s.jsxs)(n.default.Fragment,{children:[(0,s.jsxs)("tr",{onClick:()=>{h(e=>e===t?null:t)},className:`cursor-pointer transition-colors ${r?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":l?"bg-amber-500/[0.03] hover:bg-amber-500/[0.07] border-l-2 border-l-amber-500/40":t%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${i?"bg-muted/20":""}`,children:[(0,s.jsx)("td",{className:"px-4 py-2",children:(0,s.jsx)(v.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${i?"rotate-0":"-rotate-90"}`})}),(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)(eM,{decision:e.decision})}),(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)(ek,{eventType:e.eventType})}),(0,s.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:e.toolName??"—"}),(0,s.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:e.policyNames&&e.policyNames.length>1?(0,s.jsxs)("span",{title:e.policyNames.join(", "),children:[e.policyNames[0],(0,s.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",e.policyNames.length-1]})]}):e.policyName??"—"}),(0,s.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate max-w-[240px]",title:e.reason??"",children:e.reason??"—"}),(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)(eT,{ms:e.durationMs})}),(0,s.jsx)("td",{className:"px-3 py-2",children:e.permissionMode?(0,s.jsx)(eE,{mode:e.permissionMode}):"—"}),(0,s.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground whitespace-nowrap",title:new Date(e.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(0,R.formatRelativeTime)(e.timestamp)})]}),i&&(0,s.jsx)(eA,{item:e})]},`${e.timestamp}-${t}`)})})]})}),(0,s.jsx)(ew.default,{currentPage:o,totalPages:M,onPageChange:e=>{a(e),h(null)}})]})]})}function eO(e){let t=new Map;for(let s of e)if("assistant"===s.type)for(let e of s.message.content){if("tool_use"!==e.type||"Task"===e.name&&(e.subagentType||e.subagentId))continue;let s=t.get(e.name)||{count:0,totalDurationMs:0};s.count++,e.result?.durationMs&&(s.totalDurationMs+=e.result.durationMs),t.set(e.name,s)}return Array.from(t.entries()).map(([e,t])=>({name:e,...t})).sort((e,t)=>t.count-e.count)}function ez({tools:e,compact:t}){return(0,s.jsx)("div",{className:`bg-card border border-border rounded-lg ${t?"p-3":"p-4"}`,children:(0,s.jsx)("div",{className:`grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] ${t?"gap-2":"gap-3"}`,children:e.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,s.jsx)(w,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("div",{className:`${t?"text-xs":"text-sm"} font-mono font-medium truncate`,children:e.name}),(0,s.jsxs)("div",{className:"text-xs text-muted-foreground truncate",children:[e.count," call",1!==e.count?"s":"",e.totalDurationMs>0&&` \xb7 ${(e.totalDurationMs/1e3).toFixed(1)}s`]})]})]},e.name))})})}function e_(e,t){return t.get(e)??`${e.uuid}-${e.timestampMs}`}function eD(){let e=window.location.hash;return e.startsWith("#entry-")?e.slice(7):null}function eF({entries:e,entriesBySource:t,projectName:i,sessionId:l}){let o=(0,n.useMemo)(()=>Array.from(t.values()).flat(),[t]),[a,d]=(0,n.useState)(new Set),[c,u]=(0,n.useState)(0),[m,p]=(0,n.useState)(()=>eD()),y=(0,n.useRef)(void 0),v=(0,n.useRef)(!1),j=(0,n.useRef)(null);(0,n.useLayoutEffect)(()=>{let e=j.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().top+window.scrollY;u(e=>e===t?e:t)};t();let s=new ResizeObserver(t);return s.observe(document.body),window.addEventListener("resize",t),()=>{s.disconnect(),window.removeEventListener("resize",t)}},[]);let S=(0,n.useMemo)(()=>N(e),[e]),w=(0,n.useMemo)(()=>(function(e,t){let s=new Map,n=null,r=0;for(let i of e)"queue-operation"===i.type?(null!==n&&s.set(n,r),n=e_(i,t),r=0):null!==n&&r++;return null!==n&&s.set(n,r),s})(e,S),[e,S]),M=(0,n.useMemo)(()=>{let t;return t=!1,e.filter(e=>"queue-operation"===e.type?(t=a.has(e_(e,S)),!0):!t)},[e,a,S]),k=(0,n.useMemo)(()=>{let e=new Map;return M.forEach((t,s)=>{t.uuid&&e.set(t.uuid,s)}),e},[M]),E=(0,n.useMemo)(()=>(function(e){let t=new Map;for(let s of e)if("assistant"===s.type&&s.uuid)for(let e of s.message.content)"tool_use"===e.type&&"Task"===e.name&&e.subagentId&&t.set(e.subagentId,s.uuid);let s=new Map;for(let n of e){if(!n._source?.startsWith("agent-")||!n.uuid)continue;let e=n._source.slice(6),r=t.get(e);r&&s.set(n.uuid,r)}return s})(o),[o]),T=(0,n.useMemo)(()=>m&&E.has(m)?m:null,[m,E]),I=T?E.get(T)??null:null;(0,n.useEffect)(()=>{if(m)return y.current=setTimeout(()=>p(null),4e3),()=>{y.current&&clearTimeout(y.current)}},[]),(0,n.useEffect)(()=>{let e=()=>{let e=eD();p(e),v.current=!1,y.current&&clearTimeout(y.current),e&&(y.current=setTimeout(()=>p(null),4e3))};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);let A=(0,n.useMemo)(()=>{if(!m)return null;let t=I??m,s=e.some(e=>e.uuid===t),n=k.has(t);if(s&&!n){let s=null;for(let n of e)if("queue-operation"===n.type)s=e_(n,S);else if(n.uuid===t&&s)return s}return null},[m,I,e,k,S]);(0,n.useEffect)(()=>{if(!A)return;let e=requestAnimationFrame(()=>{d(e=>{if(!e.has(A))return e;let t=new Set(e);return t.delete(A),t})});return()=>cancelAnimationFrame(e)},[A]);let C=(0,n.useCallback)(e=>{d(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),O=(0,n.useCallback)(e=>S.get(M[e])??e,[S,M]),z=function({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:s="transform",...i}){let l=n.useReducer(e=>e+1,0)[1],o=n.useRef({enabled:t,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=s;let a=n.useRef(!1),d=e=>{let t=o.current;if(!t.enabled||!t.container)return;let s=e.getTotalSize();if(s!==t.lastSize){t.lastSize=s;let n=e.options.horizontal?"width":"height";t.container.style[n]=`${s}px`}},c=e=>{let t=o.current;if(!t.enabled||!t.container)return;d(e);let s=!!e.options.horizontal,n="transform"===t.mode,r=s?"left":"top",i=e.options.scrollMargin;for(let l of e.getVirtualItems()){let o=l.start-i,a=e.elementsCache.get(l.key);a&&t.lastPositions.get(a)!==o&&(t.lastPositions.set(a,o),n?a.style.transform=s?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:a.style[r]=`${o}px`)}},u={...i,onChange:(t,s)=>{var n;let d=o.current,u=!0;if(d.enabled){c(t);let e=t.range,s=d.prevRange;(u=!s||s.isScrolling!==t.isScrolling||s.startIndex!==(null==e?void 0:e.startIndex)||s.endIndex!==(null==e?void 0:e.endIndex))&&(d.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&s&&!a.current?(0,r.flushSync)(l):l()),null==(n=i.onChange)||n.call(i,t,s)}},[h]=n.useState(()=>{let e=new x(u),t=e.measureElement;return e.measureElement=e=>{a.current=!0;try{t(e)}finally{a.current=!1}},Object.assign(e,{containerRef:t=>{let s=o.current;if(s.container=t,s.lastSize=null,t&&s.enabled){let n=e.getTotalSize();s.lastSize=n;let r=e.options.horizontal?"width":"height";t.style[r]=`${n}px`}}})});return h.setOptions(u),b(()=>h._didMount(),[]),b(()=>(d(h),h._willUpdate())),b(()=>{c(h)}),h}({getScrollElement:()=>"u">typeof document?window:null,observeElementRect:h,observeElementOffset:f,scrollToFn:g,initialOffset:()=>"u">typeof document?window.scrollY:0,...{count:M.length,estimateSize:e=>(function(e){switch(e.type){case"queue-operation":return 48;case"user":return 90;case"assistant":return 80+120*e.message.content.length;default:return 100}})(M[e]),getItemKey:O,overscan:5,scrollMargin:c}});return(0,n.useEffect)(()=>{if(!m||v.current)return;let e=I??m,t=k.get(e);null!=t&&(v.current=!0,requestAnimationFrame(()=>{z.scrollToIndex(t,{align:"center"})}))},[m,I,k,z]),(0,s.jsx)("div",{ref:j,children:(0,s.jsx)("div",{style:{height:`${z.getTotalSize()}px`,width:"100%",position:"relative"},children:z.getVirtualItems().map(e=>{let n=M[e.index],r=!!m&&n.uuid===(I??m);return(0,s.jsx)("div",{"data-index":e.index,ref:z.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${e.start-z.options.scrollMargin}px)`},children:"queue-operation"===n.type?(0,s.jsx)(B,{entry:n,isCollapsed:a.has(e_(n,S)),entryCount:w.get(e_(n,S))??0,onToggle:()=>C(e_(n,S))}):(0,s.jsx)(ex,{entry:n,entriesBySource:t,projectName:i,sessionId:l,isHighlighted:!T&&r,highlightedUuid:T,autoExpandForUuid:T})},e.key)})})})}let eR=[];e.s([],76248),e.i(76248),e.s(["default",0,function({entries:e,projectName:t,sessionId:r}){let i=(0,n.useMemo)(()=>{let t=new Map;for(let s of e){let e=t.get(s._source);e?e.push(s):t.set(s._source,[s])}return t},[e]),l=i.get("session")??eR,o=(0,n.useMemo)(()=>(function(e){let t=new Map;for(let s of e)if("assistant"===s.type)for(let e of s.message.content)"tool_use"===e.type&&"Task"===e.name&&e.subagentId&&(t.has(e.subagentId)||t.set(e.subagentId,{id:e.subagentId,type:e.subagentType||"unknown",description:e.subagentDescription||""}));return Array.from(t.values())})(e),[e]),a=(0,n.useMemo)(()=>eO(l),[l]),[d,c]=(0,n.useState)(!1),[u,h]=(0,n.useState)(new Set),[m,f]=(0,n.useState)(!1),[p,g]=(0,n.useState)(null);(0,n.useEffect)(()=>{(0,ey.searchHookActivityAction)({sessionId:r},1).then(e=>{e.entries.length>0&&g(e)}).catch(()=>{})},[r]),(0,n.useEffect)(()=>{let e=()=>{window.location.hash.startsWith("#entry-")&&f(!1)};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);let x=(0,n.useCallback)(e=>{h(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]);return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)($,{entries:l}),p&&(0,s.jsx)(eC,{sessionId:r,initialData:p},r),o.length>0&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("button",{onClick:()=>c(e=>!e),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(v.ChevronDown,{className:`w-4 h-4 text-muted-foreground transition-transform ${d?"-rotate-90":""}`}),(0,s.jsx)("span",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Subagents"}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",o.length,")"]})]}),!d&&o.map(e=>{let t;return(0,s.jsxs)("div",{className:"pl-3 border-l-2 border-primary/30 space-y-2",children:[(0,s.jsxs)("button",{onClick:()=>x(e.id),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(v.ChevronDown,{className:`w-3.5 h-3.5 text-muted-foreground transition-transform ${u.has(e.id)?"-rotate-90":""}`}),(0,s.jsx)("span",{className:"text-sm font-bold",children:e.type}),e.description&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[400px]",children:e.description})]}),!u.has(e.id)&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)($,{entries:i.get(`agent-${e.id}`)||[],compact:!0}),(t=eO(i.get(`agent-${e.id}`)||[])).length>0?(0,s.jsx)(ez,{tools:t,compact:!0}):null]})]},e.id)})]}),a.length>0&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Tools"}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",a.reduce((e,t)=>e+t.count,0),")"]})]}),(0,s.jsx)(ez,{tools:a})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{onClick:()=>f(e=>!e),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,s.jsx)(v.ChevronDown,{className:`w-4 h-4 text-muted-foreground transition-transform ${m?"-rotate-90":""}`}),(0,s.jsx)("span",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Logs"})]}),!m&&(0,s.jsx)("div",{className:"mt-2 bg-card border border-border rounded-lg p-4 shadow-sm",children:0===l.length?(0,s.jsx)("p",{className:"text-muted-foreground text-center py-8",children:"No entries found."}):(0,s.jsx)(eF,{entries:l,entriesBySource:i,projectName:t,sessionId:r})})]})]})}],36406)},5780,function(e){e.n(e.i(36406))}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,53348,e=>{"use strict";var r=e.i(43476),t=e.i(71645),n=e.i(36287),i=e.i(9969);e.s(["default",0,function({error:e,reset:o}){return(0,t.useEffect)(()=>{(0,n.getTelemetryConfig)().then(r=>{(0,i.setClientTelemetryConfig)(r),(0,i.captureClientEvent)("client_error",{error_message:e.message,error_name:e.name,error_digest:e.digest,boundary:"global"})}).catch(()=>{})},[e]),(0,r.jsx)("html",{children:(0,r.jsx)("body",{children:(0,r.jsx)("main",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"#031035",color:"#f8fafc",fontFamily:"system-ui, sans-serif"},children:(0,r.jsxs)("div",{style:{textAlign:"center",padding:"2rem",border:"1px solid rgba(239,68,68,0.4)",borderRadius:"0.5rem",maxWidth:"500px"},children:[(0,r.jsx)("h2",{style:{color:"#ef4444",marginBottom:"0.5rem",fontSize:"1.25rem"},children:"Something went wrong"}),(0,r.jsx)("p",{style:{color:"#94a3b8",marginBottom:"1.5rem"},children:e.message||"An unexpected error occurred."}),(0,r.jsx)("button",{onClick:o,style:{padding:"0.5rem 1.25rem",background:"#3b82f6",color:"white",border:"none",borderRadius:"0.375rem",cursor:"pointer",fontSize:"0.875rem"},children:"Try again"})]})})})})}])}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,53348,e=>{"use strict";var r=e.i(43476),t=e.i(71645),n=e.i(70915),i=e.i(9969);e.s(["default",0,function({error:e,reset:o}){return(0,t.useEffect)(()=>{(0,n.getTelemetryConfig)().then(r=>{(0,i.setClientTelemetryConfig)(r),(0,i.captureClientEvent)("client_error",{error_message:e.message,error_name:e.name,error_digest:e.digest,boundary:"global"})}).catch(()=>{})},[e]),(0,r.jsx)("html",{children:(0,r.jsx)("body",{children:(0,r.jsx)("main",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"#031035",color:"#f8fafc",fontFamily:"system-ui, sans-serif"},children:(0,r.jsxs)("div",{style:{textAlign:"center",padding:"2rem",border:"1px solid rgba(239,68,68,0.4)",borderRadius:"0.5rem",maxWidth:"500px"},children:[(0,r.jsx)("h2",{style:{color:"#ef4444",marginBottom:"0.5rem",fontSize:"1.25rem"},children:"Something went wrong"}),(0,r.jsx)("p",{style:{color:"#94a3b8",marginBottom:"1.5rem"},children:e.message||"An unexpected error occurred."}),(0,r.jsx)("button",{onClick:o,style:{padding:"0.5rem 1.25rem",background:"#3b82f6",color:"white",border:"none",borderRadius:"0.375rem",cursor:"pointer",fontSize:"0.875rem"},children:"Try again"})]})})})})}])}]);
@@ -0,0 +1,6 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,64245,e=>{"use strict";var t=e.i(43476),s=e.i(71645),r=e.i(74080),n=e.i(22016),a=e.i(89664),l=e.i(16327),o=e.i(56420);let i={name:"code",size:24,node:[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]};i.node;let c=(0,o.default)(i);var d=e.i(8734);let m={name:"package",size:24,node:[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]};m.node;let u=(0,o.default)(m),p={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};p.node;let x=(0,o.default)(p);var h=e.i(66794),b=e.i(82954),f=e.i(16306),g=e.i(84026),v=e.i(29407);let j={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};j.node;let y=(0,o.default)(j),N={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle"]};N.node;let k=(0,o.default)(N);var w=e.i(63676),S=e.i(73520),P=e.i(95187);let C=(0,P.createServerReference)("40bc37a56aefa912c16db05694c078261098f19d07",P.callServer,void 0,P.findSourceMapURL,"getHookActivityAction");var _=e.i(50393);let $=(0,P.createServerReference)("001c16826dbc50af19b82abe5a6457f61e495d4a97",P.callServer,void 0,P.findSourceMapURL,"getActivePausesAction");function T({pauses:e,now:r}){let[n,a]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{let e=setInterval(()=>a(Date.now()),3e4);return()=>clearInterval(e)},[]);let l=r??n,o=e.filter(e=>e.expiresAt>l);if(0===o.length)return null;let i=o.reduce((e,t)=>e.expiresAt<t.expiresAt?e:t);return(0,t.jsxs)("div",{role:"status",className:"mb-4 flex items-start gap-2.5 rounded border border-amber-500/40 bg-amber-500/[0.07] px-3 py-2.5",children:[(0,t.jsx)(f.ShieldAlert,{className:"h-4 w-4 shrink-0 text-amber-500 mt-0.5","aria-hidden":"true"}),(0,t.jsxs)("div",{className:"text-xs leading-relaxed",children:[(0,t.jsxs)("p",{className:"font-medium text-foreground",children:["Enforcement is paused for ",o.length," session",1===o.length?"":"s"," —"," ",function(e){if(e<=0)return"expiring now";if(e<6e4)return"under a minute";let t=Math.round(e/6e4);if(t<60)return`${t}m`;let s=Math.floor(t/60),r=t%60;return 0===r?`${s}h`:`${s}h${r}m`}(i.expiresAt-l)," left",o.length>1?" on the next to expire":"","."]}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-0.5",children:["Builtin, custom and convention policies are suspended for"," ",1===o.length?"that session":"those sessions","; cloud-managed policies keep enforcing. It lifts on its own — or run"," ",(0,t.jsx)("span",{className:"font-mono text-foreground",children:"failproofai config --resume"}),"."]})]})]})}function M(){return(0,t.jsx)("span",{title:"Enforcement was paused for this session — local policies did not run",className:"ml-1.5 inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium uppercase tracking-wide border border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-500",children:"paused"})}function U({item:e}){if(!e.pausedBy)return null;let s="number"==typeof e.pauseExpiresAt?new Date(e.pauseExpiresAt).toLocaleTimeString():null;return(0,t.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3 mt-1 flex items-start gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2.5 py-2",children:[(0,t.jsx)(k,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,t.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-medium text-foreground",children:"Not enforced — paused."})," Enforcement was suspended for this session","cli"===e.pausedBy?" from the CLI":` by ${e.pausedBy}`,s?`, lifting at ${s}`:"",". Builtin, custom and convention policies did not run for this event; cloud-managed policies did."]})]})}let I=["evaluator","jevDecision","jevCleared","jevFallbackReason","jevLatencyMs","jevModel","jevMode"],R=new Set(["jev","jev-fallback"]),A=new Set(["allow","instruct","deny"]),E=new Set(["observe","enforce"]),L=/^([a-z0-9]+(?:-[a-z0-9]+)*)\s*(?:$|[:(])/,D=/^http-\d{3}$/,z="other",F=new Set(["aborted","cloudflare-error","cloudflare-incomplete","config","error","malformed","model-mismatch","network","no-api-key","no-transport","other","out-of-credits","prepare-error","provider-refused","rate-limited","request-cut","request-too-large","timeout","truncated","unavailable","upstream-error"]),B=new Map([["prepare","prepare-error"],["error","error"],["timeout","timeout"],["network","network"],["malformed","malformed"],["truncated","truncated"],["rate-limited","rate-limited"],["out-of-credits","out-of-credits"],["model-mismatch","model-mismatch"],["request-too-large","request-too-large"],["config","config"]]),W=/^[A-Za-z0-9._:/@~+-]{1,200}$/,O=/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/,q=/^(?:custom|pack|cloud|failproofai|\.failproofai-[A-Za-z0-9_-]{1,32})\//;function J(e){return!("string"!=typeof e||0===e.length||[...e].length>200||O.test(e))&&(!/\s/.test(e)||q.test(e))}function H(e){if(!I.some(t=>void 0!==e[t]))return e;let t={...e},s=e=>{delete t[e]};"string"==typeof t.evaluator&&R.has(t.evaluator)||s("evaluator"),"string"==typeof t.jevDecision&&A.has(t.jevDecision)||s("jevDecision");let r=void 0!==t.jevMode&&!("string"==typeof t.jevMode&&E.has(t.jevMode));if("string"==typeof t.jevMode&&E.has(t.jevMode)||s("jevMode"),r&&s("jevCleared"),Array.isArray(t.jevCleared)){let e=[...new Set(t.jevCleared.filter(J))].slice(0,64);t.jevCleared=e}else s("jevCleared");let n=function(e){if("string"!=typeof e)return;let t=e.trim().toLowerCase();if(0===t.length)return;let s=L.exec(t)?.[1];if(void 0===s||s.length>40)return z;if(D.test(s))return s;let r=B.get(s)??s;return F.has(r)?r:z}(t.jevFallbackReason);return void 0===n?s("jevFallbackReason"):t.jevFallbackReason=n,"number"==typeof t.jevLatencyMs&&Number.isFinite(t.jevLatencyMs)&&t.jevLatencyMs>=0?t.jevLatencyMs=Math.round(t.jevLatencyMs):s("jevLatencyMs"),"string"==typeof t.jevModel&&W.test(t.jevModel.trim())?t.jevModel=t.jevModel.trim():s("jevModel"),t}function X(e){return"jev-fallback"===e.evaluator?"fallback":"jev"!==e.evaluator?null:void 0!==e.jevCleared||void 0!==e.jevLatencyMs||void 0!==e.jevModel||"deny"===e.jevDecision||"instruct"===e.jevDecision?"answered":"allow"===e.jevDecision?"no-request":"not-consulted"}let K=new Set(["request-cut","truncated","model-mismatch"]);function V(e){return"jev-fallback"===e.evaluator&&(void 0!==e.jevDecision||K.has(e.jevFallbackReason??""))}let Z={allow:0,instruct:1,deny:2},G={cleared:{label:"jev cleared",title:"Jev reviewed a reviewable policy's block and cleared it",className:"border-sky-500/40 bg-sky-500/10 text-sky-600 dark:text-sky-400"},"would-clear":{label:"jev observe",title:"Observe mode: Jev would have cleared a block here; the regex result was enforced",className:"border-sky-500/30 bg-sky-500/5 text-sky-600/80 dark:text-sky-400/80"},"observe-stricter":{label:"jev observe",title:"Observe mode: Jev would have been stricter here; the regex result was enforced",className:"border-sky-500/30 bg-sky-500/5 text-sky-600/80 dark:text-sky-400/80"},"fallback-stricter":{label:"jev fallback",title:"Jev answered but its answer was not applied (e.g. the call was truncated); it would have been stricter than the regex result",className:"border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-400"},fallback:{label:"jev fallback",title:"Jev's answer was not used for this call (unavailable, truncated or mismatched); the regex policies decided alone",className:"border-muted-foreground/30 bg-muted/40 text-muted-foreground"}};function Q({item:e}){let s=function(e){let t=H(e),s=X(H(t));if(null===s||"not-consulted"===s||"no-request"===s)return null;let r=()=>(Z[t.jevDecision??"allow"]??0)>(Z[e.decision??"allow"]??0);if("fallback"===s)return void 0!==t.jevDecision&&r()?"fallback-stricter":"fallback";let n=(t.jevCleared??[]).length>0;return"observe"===t.jevMode?n?"would-clear":r()?"observe-stricter":null:n?"cleared":null}(e);if(!s)return null;let r=G[s];return(0,t.jsx)("span",{title:r.title,className:`ml-1.5 inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium uppercase tracking-wide border ${r.className}`,children:r.label})}function Y({item:e}){let s=function(e){let t=H(e),s=X(t);if(null===s)return null;if("not-consulted"===s)return["Jev not consulted: a hard policy's deny is final"];if("no-request"===s)return["Jev not asked: no semantic policy applies to this call"];let r=[];if("fallback"===s){let e=t.jevFallbackReason??"unknown reason";return V(t)?(r.push(`Jev's answer not applied: ${e}`),t.jevDecision&&r.push(`Jev verdict (not applied): ${t.jevDecision}`)):r.push(`Jev unavailable: ${e}`),r.push("the regex policies decided alone"),void 0!==t.jevLatencyMs&&r.push(`${t.jevLatencyMs} ms`),t.jevModel&&V(t)&&r.push(t.jevModel),r}t.jevDecision&&r.push(`Jev verdict: ${t.jevDecision}`);let n=t.jevCleared??[];return n.length>0&&r.push(`${"observe"===t.jevMode?"would have cleared":"cleared"} ${n.join(", ")}`),"observe"===t.jevMode&&r.push("observe mode: the regex result was enforced"),void 0!==t.jevLatencyMs&&r.push(`${t.jevLatencyMs} ms`),t.jevModel&&r.push(t.jevModel),0===r.length&&r.push("Jev answered"),r}(e);return s?(0,t.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Semantic review: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:s.join(" · ")})]}):null}let ee=(0,P.createServerReference)("009a4e877995e71e71e594fc4041ca59b74940c495",P.callServer,void 0,P.findSourceMapURL,"getHooksConfigAction"),et=(0,P.createServerReference)("60e6e93a69e767d5f42a7f2c56957e897d07ed3d83",P.callServer,void 0,P.findSourceMapURL,"toggleCustomPolicyAction"),es=(0,P.createServerReference)("00db3325da0dd1c94d35674c736ef9b795bb4485dc",P.callServer,void 0,P.findSourceMapURL,"addBundledPackWebAction"),er=(0,P.createServerReference)("60fa90f7f42e9777bda210c01687fd42e6c27616d6",P.callServer,void 0,P.findSourceMapURL,"addPackWebAction"),en=(0,P.createServerReference)("40bd53db9fed897ca2a5a873a1948213cd663aa9a7",P.callServer,void 0,P.findSourceMapURL,"previewPackWebAction"),ea=(0,P.createServerReference)("40044931971bb582c6fbb4059fc5fba40e90d8afe7",P.callServer,void 0,P.findSourceMapURL,"removePackWebAction"),el=(0,P.createServerReference)("70141135e47087fb5543c0becd2d386719f01d13e0",P.callServer,void 0,P.findSourceMapURL,"togglePackPolicyAction"),eo=(0,P.createServerReference)("60ede4b57cee43d28fa52ae152b09d18cd6a82a556",P.callServer,void 0,P.findSourceMapURL,"installHooksWebAction"),ei=(0,P.createServerReference)("60bfd5cebdfface692339258de0984451eddb5230e",P.callServer,void 0,P.findSourceMapURL,"removeHooksWebAction"),ec=(0,P.createServerReference)("60adf6ea8a8b8ba6abddfefe6a0489fe583753d488",P.callServer,void 0,P.findSourceMapURL,"updatePolicyParamsAction");var ed=e.i(85881),em=e.i(12344),eu=e.i(80060),ep=e.i(2711),ex=e.i(24578);let eh={claude:{PreToolUse:"block",UserPromptSubmit:"block",PermissionRequest:"block",Stop:"block",SubagentStop:"block",PreCompact:"block",PostToolBatch:"block",ConfigChange:"block",UserPromptExpansion:"block",TaskCreated:"block",TaskCompleted:"block",TeammateIdle:"block",Elicitation:"block",ElicitationResult:"block",PostToolUse:"observe",PostToolUseFailure:"observe",SessionStart:"observe",Setup:"observe",SubagentStart:"observe",SessionEnd:"observe",StopFailure:"observe",PermissionDenied:"observe",Notification:"observe",InstructionsLoaded:"observe",CwdChanged:"observe",FileChanged:"observe",PostCompact:"observe",WorktreeRemove:"observe"},codex:{PreToolUse:"block",PermissionRequest:"block",UserPromptSubmit:"block",Stop:"block",SubagentStop:"block",PostToolUse:"block",SessionStart:"observe",SubagentStart:"observe",PreCompact:"observe",PostCompact:"observe"},copilot:{PreToolUse:"block",Stop:"block",SubagentStop:"block",UserPromptSubmit:"block",PermissionRequest:"block",PostToolUse:"block",SessionStart:"observe",SessionEnd:"observe",PostToolUseFailure:"observe",PreCompact:"observe",Notification:"observe"},cursor:{PreToolUse:"block",Stop:"block",UserPromptSubmit:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"},opencode:{PreToolUse:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",UserPromptSubmit:"observe",PermissionRequest:"observe"},pi:{PreToolUse:"block",UserPromptSubmit:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",Stop:"observe"},hermes:{PreToolUse:"block",PostToolUse:"observe",SubagentStop:"observe",SessionStart:"observe",SessionEnd:"observe"},openclaw:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",SubagentStop:"observe",PreCompact:"observe"},factory:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PreCompact:"block",PostToolUse:"observe",SubagentStop:"observe",SessionStart:"observe",SessionEnd:"observe",Notification:"observe"},devin:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PermissionRequest:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"},antigravity:{PreToolUse:"block",Stop:"block",PostToolUse:"observe",UserPromptSubmit:"observe"},goose:{PreToolUse:"block",UserPromptSubmit:"observe",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"}};var eb=e.i(34713),ef=e.i(67881);function eg({sessionId:e,transcriptPath:s,integration:r,cwd:a}){if(!e)return(0,t.jsx)("span",{className:"text-muted-foreground",children:"\\u2014"});let l=e?e.slice(0,8):"—",o="codex"===r||(s?.includes("/.codex/")??!1),i="copilot"===r||(s?.includes("/.copilot/session-state/")??!1),c="cursor"===r||(s?.includes("/.cursor/")??!1),d="opencode"===r||(s?.includes("/.local/share/opencode/")??!1)||(s?.includes("/.opencode/")??!1),m="pi"===r||(s?.includes("/.pi/")??!1);if(o||i||c||d||m){let s,r=a?(s=/^([A-Za-z]):[\\/](.*)$/.exec(a))?s[1]+"--"+s[2].replace(/[\\/]/g,"-"):a.replace(/[\\/]/g,"-"):o?"codex":i?"copilot":c?"cursor":d?"opencode":"pi";return(0,t.jsx)(n.default,{href:`/project/${encodeURIComponent(r)}/session/${encodeURIComponent(e)}`,className:"text-primary hover:underline font-mono",onClick:e=>e.stopPropagation(),children:l})}let u=s?function(e){let t=e.replace(/\\/g,"/").split("/").filter(Boolean);if(t.length<2)return null;let s=t[t.length-2];return!s||s.startsWith(".")?null:s}(s):null;return u?(0,t.jsx)(n.default,{href:`/project/${encodeURIComponent(u)}/session/${encodeURIComponent(e)}`,className:"text-primary hover:underline font-mono",onClick:e=>e.stopPropagation(),children:l}):(0,t.jsx)("span",{className:"text-muted-foreground font-mono",children:l})}function ev({decision:e}){return"deny"===e?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-red-500/10 text-red-400 border border-red-500/20",children:[(0,t.jsx)(v.ShieldX,{className:"h-3 w-3"}),"Deny"]}):"instruct"===e?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[(0,t.jsx)(f.ShieldAlert,{className:"h-3 w-3"}),"Instruct"]}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(0,t.jsx)(g.ShieldCheck,{className:"h-3 w-3"}),"Allow"]})}function ej({eventType:e}){return(0,t.jsx)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium bg-muted text-muted-foreground border border-border/50",children:e})}function ey({integration:e}){if(!e)return null;let s=(0,ex.getCliLabel)(e),r=(0,ex.getCliBadgeClasses)(e);return(0,t.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${r}`,title:`Agent CLI: ${s}`,children:s})}function eN({mode:e}){let s="default"===e;return(0,t.jsx)("span",{title:e,className:`inline-block max-w-full truncate rounded px-1.5 py-0.5 align-middle text-[0.6rem] font-medium border ${s?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:e})}function ek({ms:e}){return(0,t.jsx)("span",{className:`font-mono text-[0.7rem] ${e>500?"text-red-400":e>100?"text-amber-400":"text-muted-foreground"}`,children:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`})}function ew({text:e,field:r}){let[n,l]=(0,s.useState)(!1),{capture:o}=(0,em.usePostHog)(),i=async t=>{t.stopPropagation(),o("activity_copy_clicked",{field:r??"unknown"});try{await navigator.clipboard.writeText(e),l(!0),setTimeout(()=>l(!1),1500)}catch{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),l(!0),setTimeout(()=>l(!1),1500)}};return(0,t.jsx)("button",{onClick:i,className:"inline-flex items-center justify-center h-5 w-5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Copy",children:n?(0,t.jsx)(a.Check,{className:"h-3 w-3 text-emerald-400"}):(0,t.jsx)(d.Copy,{className:"h-3 w-3"})})}function eS({value:e,onChange:s}){return(0,t.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5",children:[{label:"All",value:""},{label:"Allow",value:"allow"},{label:"Instruct",value:"instruct"},{label:"Deny",value:"deny"}].map(r=>(0,t.jsx)("button",{onClick:()=>s(r.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${e===r.value?"deny"===r.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===r.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===r.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r.label},r.value))})}function eP({stats:e}){let s=e.totalEvents>0?e.denyCount/e.totalEvents*100:0,r=s.toFixed(s>=10?0:1),n=0===e.denyCount?"":s>=5?" is-deny":s>=2?" is-warn":"";return(0,t.jsxs)("div",{className:"stat-bar",role:"group","aria-label":"Activity stats",children:[(0,t.jsxs)("div",{className:"stat-cell",children:[(0,t.jsx)("span",{className:"eyebrow",children:"total events"}),(0,t.jsx)("span",{className:"value",children:e.totalEvents.toLocaleString()}),(0,t.jsx)("span",{className:"meta",children:"across all installed agents"})]}),(0,t.jsxs)("div",{className:"stat-cell",children:[(0,t.jsx)("span",{className:"eyebrow",children:"deny rate"}),(0,t.jsxs)("span",{className:`value${n}`,children:[r,"%"]}),(0,t.jsxs)("span",{className:"meta",children:[e.denyCount.toLocaleString()," of ",e.totalEvents.toLocaleString()," denied"]})]}),(0,t.jsxs)("div",{className:"stat-cell",children:[(0,t.jsx)("span",{className:"eyebrow",children:"top policy"}),(0,t.jsx)("span",{className:"value",style:{fontSize:16,fontWeight:500,color:e.topPolicy?"var(--accent-pink)":"var(--dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.topPolicy??void 0,children:e.topPolicy??"—"}),(0,t.jsx)("span",{className:"meta",children:"most-evaluated policy in scope"})]})]})}function eC({item:e}){if("observe"!==function(e,t){if(!e||!t)return;let s=eh[e];if(s)return s[t]}(e.integration,e.eventType))return null;let s=e.matchedPolicies??[];if(0===s.length)return null;let r=e.integration?(0,ex.getCliLabel)(e.integration):"This CLI",n=s.map(e=>e.replace(/^(custom|\.failproofai-(project|user))\//,"")),a=1===n.length?n[0]:`${n.length} policies`,l="deny"===e.decision;return(0,t.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3 mt-1 flex items-start gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2.5 py-2",children:[(0,t.jsx)(k,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,t.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-medium text-foreground",children:l?"Not enforced.":"Ran, but cannot enforce here."})," ",(0,t.jsx)("span",{className:"font-mono",children:a})," ran on"," ",(0,t.jsx)("span",{className:"font-mono",children:e.eventType}),", but ",r," discards hook verdicts for this event",l?" — the action went ahead anyway.":", so a policy cannot block here."," ","Move the check to an event ",r," enforces on, such as"," ",(0,t.jsx)("span",{className:"font-mono",children:"PreToolUse"}),"."]})]})}function e_({item:e}){return(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:11,className:"px-0 py-0",children:(0,t.jsxs)("div",{className:"activity-detail animate-expand text-xs",children:[(0,t.jsxs)("span",{className:"activity-detail-eyebrow",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"▾"}),"event detail"]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-2",children:[(0,t.jsx)(U,{item:e}),(0,t.jsx)(eC,{item:e}),e.policySource&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Decided by: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:"cloud"===e.policySource&&e.cloudPolicyId?`cloud \xb7 ${e.cloudPolicyId} version ${e.cloudVersion}`:e.policySource})]}),(0,t.jsx)(Y,{item:e}),void 0!==e.cloudDeployment&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Cloud deployment: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.cloudDeployment})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.sessionId??"—"}),e.sessionId&&(0,t.jsx)(ew,{text:e.sessionId,field:"session_id"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.cwd??"—"}),e.cwd&&(0,t.jsx)(ew,{text:e.cwd,field:"cwd"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,t.jsx)("span",{className:"font-mono text-foreground break-all",children:e.transcriptPath??"—"}),e.transcriptPath?.startsWith("opencode-db://")&&(0,t.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),e.policyNames&&e.policyNames.length>1&&(0,t.jsxs)("div",{style:{marginTop:8},children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.policyNames.join(", ")})]}),e.reason&&(0,t.jsxs)("div",{style:{marginTop:8},children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,t.jsx)("span",{className:"text-foreground",children:e.reason})]})]})})})}function e$({hooksInstalled:e,onSwitchTab:r}){let{intervalSec:n}=(0,ed.useAutoRefresh)(),{capture:a}=(0,em.usePostHog)(),o=(0,eu.useUrlParams)(),i=(0,s.useRef)(!1),[c,d]=(0,s.useState)(()=>(0,ep.paramToPage)(o.get("page"))),[m,u]=(0,s.useState)(null),[p,x]=(0,s.useState)([]),[h,f]=(0,s.useState)(null),[g,v]=(0,s.useState)(()=>{let e=o.get("decision");return"allow"===e||"deny"===e||"instruct"===e?e:""}),[j,y]=(0,s.useState)(()=>o.get("event")??""),[N,k]=(0,s.useState)(()=>o.get("policy")??""),[w,P]=(0,s.useState)(()=>o.get("session")??""),[U,I]=(0,s.useState)(()=>{let e=o.get("cli");return(0,ex.isKnownCli)(e)?e:""}),[R,A]=(0,s.useState)(()=>{let e=o.get("source");return"custom"===e||"convention"===e||"cloud"===e||"pack"===e||"jev"===e?e:""}),E=(0,s.useRef)(null),L=(0,s.useRef)(!0),D=(0,s.useRef)({filterDecision:g,filterEventType:j,filterPolicy:N,filterSessionId:w,filterCli:U,filterSource:R});D.current={filterDecision:g,filterEventType:j,filterPolicy:N,filterSessionId:w,filterCli:U,filterSource:R},(0,s.useEffect)(()=>{if(!i.current){i.current=!0;return}o.setAll({decision:g||void 0,event:j||void 0,policy:N||void 0,session:w||void 0,cli:U||void 0,source:R||void 0,page:(0,ep.pageToParam)(c)})},[g,j,N,w,U,R,c]);let z=""!==g||""!==j||""!==N||""!==w||""!==U||""!==R,F=(0,s.useCallback)(async e=>{try{let t,{filterDecision:s,filterEventType:r,filterPolicy:n,filterSessionId:a,filterCli:l,filterSource:o}=D.current;t=""!==s||""!==r||""!==n||""!==a||""!==l||""!==o?await (0,_.searchHookActivityAction)({decision:s||void 0,eventType:r||void 0,policyName:n||void 0,sessionId:a||void 0,integration:l||void 0,source:o||void 0},e):await C(e),u(t)}catch{}},[]);(0,s.useEffect)(()=>{F(c);let e=setInterval(()=>F(c),n>0?1e3*n:5e3);return()=>clearInterval(e)},[c,F,n]),(0,s.useEffect)(()=>{let e=!1,t=()=>{$().then(t=>{e||x(t)}).catch(()=>{})};t();let s=setInterval(t,n>0?1e3*n:5e3);return()=>{e=!0,clearInterval(s)}},[n]),(0,s.useEffect)(()=>(E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{if(d(1),f(null),F(1),L.current){L.current=!1;return}a("activity_filter_changed",{active_filter_count:+(""!==g)+ +(""!==j)+ +(""!==N)+ +(""!==w)+ +(""!==U),has_decision:""!==g,has_event_type:""!==j,has_policy:""!==N,has_session:""!==w,has_cli:""!==U,decision:g||null,event_type:j||null,cli:U||null})},300),()=>{E.current&&clearTimeout(E.current)}),[g,j,N,w,U]);let B=m?.entries??[],W=m?.totalPages??1;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(T,{pauses:p}),m?.stats&&m.stats.totalEvents>0&&(0,t.jsx)("div",{style:{marginBottom:18},children:(0,t.jsx)(eP,{stats:m.stats})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"filter-bar",children:[(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"decision"}),(0,t.jsx)(eS,{value:g,onChange:v})]}),(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"event"}),(0,t.jsxs)("select",{value:j,onChange:e=>y(e.target.value),className:"filter-input",children:[(0,t.jsx)("option",{value:"",children:"all events"}),(0,t.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,t.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,t.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,t.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,t.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,t.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]})]}),(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"source"}),(0,t.jsxs)("select",{value:R,onChange:e=>{let t=e.target.value;A("custom"===t||"convention"===t||"cloud"===t||"pack"===t||"jev"===t?t:"")},className:"filter-input","aria-label":"Filter by policy source",children:[(0,t.jsx)("option",{value:"",children:"all sources"}),(0,t.jsx)("option",{value:"custom",children:"custom"}),(0,t.jsx)("option",{value:"convention",children:"convention"}),(0,t.jsx)("option",{value:"cloud",children:"cloud"}),(0,t.jsx)("option",{value:"pack",children:"pack"}),(0,t.jsx)("option",{value:"jev",children:"jev"})]})]}),(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"cli"}),(0,t.jsxs)("select",{value:U,onChange:e=>{let t=e.target.value;I(""===t||(0,ex.isKnownCli)(t)?t:"")},className:"filter-input","aria-label":"Filter by CLI",children:[(0,t.jsx)("option",{value:"",children:"all clis"}),ex.KNOWN_CLI_IDS.map(e=>(0,t.jsx)("option",{value:e,children:(0,ex.getCliLabel)(e)},e))]})]}),(0,t.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,t.jsx)("span",{className:"filter-label",children:"policy"}),(0,t.jsx)("input",{type:"text",value:N,onChange:e=>k(e.target.value),placeholder:"filter by policy…",className:"filter-input"})]}),(0,t.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,t.jsx)("span",{className:"filter-label",children:"session"}),(0,t.jsx)("input",{type:"text",value:w,onChange:e=>P(e.target.value),placeholder:"filter by session…",className:"filter-input"})]}),z&&(0,t.jsx)("button",{type:"button",className:"filter-clear",onClick:()=>{v(""),y(""),I(""),k(""),P(""),A("")},"aria-label":"Clear all filters",children:"[ clear ]"})]}),0===B.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,t.jsx)(b.Shield,{className:"h-12 w-12 text-muted-foreground/30"}),!1===e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-4 font-medium",children:"Policies are not installed"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:["Go to the"," ",(0,t.jsx)("button",{className:"underline hover:text-foreground transition-colors",onClick:()=>r?.("policies"),children:"Policies tab"})," ","and click ",(0,t.jsx)("span",{className:"font-mono bg-muted px-1 rounded",children:"Install"})," to enable policy monitoring."]})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-4",children:z?"No matching activity.":"Waiting for hook events…"})]}):(0,t.jsx)("div",{className:"overflow-x-auto activity-table-wrap",children:(0,t.jsxs)("table",{className:"w-full text-xs activity-table",style:{tableLayout:"fixed"},children:[(0,t.jsxs)("colgroup",{children:[(0,t.jsx)("col",{style:{width:32}}),(0,t.jsx)("col",{style:{width:"7%"}}),(0,t.jsx)("col",{style:{width:"9%"}}),(0,t.jsx)("col",{style:{width:"12%"}}),(0,t.jsx)("col",{style:{width:"11%"}}),(0,t.jsx)("col",{style:{width:"9%"}}),(0,t.jsx)("col",{style:{width:"13%"}}),(0,t.jsx)("col",{style:{width:"12%"}}),(0,t.jsx)("col",{style:{width:"11%"}}),(0,t.jsx)("col",{style:{width:"8%"}}),(0,t.jsx)("col",{style:{width:"8%"}})]}),(0,t.jsx)("thead",{className:"activity-thead",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"px-4 py-3"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Time"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Decision"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Event"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"CLI"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Tool"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Policy"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Reason"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Mode"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Duration"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Session"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border/30",children:B.map((e,r)=>{let n="deny"===e.decision,o=h===r,i="instruct"===e.decision;return(0,t.jsxs)(s.Fragment,{children:[(0,t.jsxs)("tr",{onClick:()=>{f(e=>{let t=e===r?null:r,s=B[r];return a("activity_row_toggled",{expanded:null!==t,decision:s?.decision??null,policy_name:s?.policyName??null,event_type:s?.eventType??null}),t})},className:`activity-data-row cursor-pointer transition-colors ${n?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":i?"bg-amber-500/[0.03] hover:bg-amber-500/[0.07] border-l-2 border-l-amber-500/40":r%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${o?"bg-muted/20":""}`,children:[(0,t.jsx)("td",{className:"px-4 py-2",children:(0,t.jsx)(l.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${o?"rotate-0":"-rotate-90"}`})}),(0,t.jsx)("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",title:new Date(e.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(0,eb.formatRelativeTime)(e.timestamp)}),(0,t.jsxs)("td",{className:"px-3 py-2",children:[(0,t.jsx)(ev,{decision:e.decision}),e.pausedBy&&(0,t.jsx)(M,{}),(0,t.jsx)(Q,{item:e})]}),(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)(ej,{eventType:e.eventType})}),(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)(ey,{integration:e.integration})}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:e.toolName??"—"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:e.policyNames&&e.policyNames.length>1?(0,t.jsxs)("span",{title:e.policyNames.join(", "),children:[e.policyNames[0],(0,t.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",e.policyNames.length-1]})]}):e.policyName??"—"}),(0,t.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate",title:e.reason??"",children:e.reason??"—"}),(0,t.jsx)("td",{className:"px-3 py-2",children:e.permissionMode?(0,t.jsx)(eN,{mode:e.permissionMode}):"—"}),(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)(ek,{ms:e.durationMs})}),(0,t.jsx)("td",{className:"px-3 py-2",title:e.sessionId??"",children:(0,t.jsx)(eg,{sessionId:e.sessionId,transcriptPath:e.transcriptPath,integration:e.integration,cwd:e.cwd})})]}),o&&(0,t.jsx)(e_,{item:e})]},`${e.timestamp}-${r}`)})})]})}),(0,t.jsx)(S.default,{currentPage:c,totalPages:W,onPageChange:e=>{a("activity_pagination_changed",{from_page:c,to_page:e,total_pages:W}),d(e),f(null)}})]})]})}function eT({enabled:e,onChange:s,disabled:r}){return(0,t.jsx)("button",{onClick:s,disabled:r,className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors disabled:opacity-40 ${e?"bg-emerald-500":"bg-muted-foreground/30"}`,"aria-label":e?"Disable policy":"Enable policy",children:(0,t.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform ${e?"translate-x-3.5":"translate-x-0.5"}`})})}function eM({policy:e,onClose:r,onSave:n}){let a=e.params??{},l=e.currentParams??{},[o,i]=(0,s.useState)(()=>{let e={};for(let[t,s]of Object.entries(a)){let r=t in l?l[t]:s.default;e[t]=r}return e});(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]);let c=(e,t)=>{i(s=>({...s,[e]:t}))};return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:e=>{e.target===e.currentTarget&&r()},children:(0,t.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-mono font-semibold text-foreground",children:e.name}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.description})]}),(0,t.jsx)("button",{onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,t.jsx)(w.X,{className:"h-4 w-4"})})]}),(0,t.jsx)("div",{className:"overflow-y-auto flex-1 px-4 py-4 space-y-4",children:Object.entries(a).map(([e,s])=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1 font-mono",children:e}),(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground mb-1.5",children:s.description}),((e,s)=>{let r=o[e];if("boolean"===s.type)return(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:!!r,onChange:t=>c(e,t.target.checked),className:"rounded border-border"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:s.description})]});if("number"===s.type)return(0,t.jsx)("input",{type:"number",value:"number"==typeof r?r:"",onChange:t=>c(e,Number(t.target.value)),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"});if("string[]"===s.type){let s=Array.isArray(r)?r.join("\n"):"";return(0,t.jsx)("textarea",{value:s,onChange:t=>c(e,t.target.value.split("\n").filter(e=>""!==e.trim())),rows:4,placeholder:"One entry per line",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-2 focus:ring-primary/40 resize-y"})}if("pattern[]"===s.type){let s=Array.isArray(r)?r:[];return(0,t.jsxs)("div",{className:"space-y-1.5",children:[s.map((r,n)=>(0,t.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,t.jsx)("input",{type:"text",value:r.regex,onChange:t=>{let r=[...s];r[n]={...r[n],regex:t.target.value},c(e,r)},placeholder:"regex",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs font-mono focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,t.jsx)("input",{type:"text",value:r.label,onChange:t=>{let r=[...s];r[n]={...r[n],label:t.target.value},c(e,r)},placeholder:"label",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,t.jsx)("button",{onClick:()=>c(e,s.filter((e,t)=>t!==n)),className:"text-muted-foreground/50 hover:text-destructive transition-colors",children:(0,t.jsx)(w.X,{className:"h-3.5 w-3.5"})})]},n)),(0,t.jsx)("button",{onClick:()=>c(e,[...s,{regex:"",label:""}]),className:"text-xs text-primary hover:underline",children:"+ Add pattern"})]})}return(0,t.jsx)("input",{type:"text",value:"string"==typeof r?r:"",onChange:t=>c(e,t.target.value),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"})})(e,s)]},e))}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,t.jsx)(ef.Button,{variant:"outline",size:"sm",onClick:r,className:"h-7 text-xs",children:"Cancel"}),(0,t.jsx)(ef.Button,{size:"sm",onClick:()=>n(o),className:"h-7 text-xs",children:"Save"})]})]})})}function eU({message:e,onDismiss:s,onInstall:n,isPending:a}){let{capture:l}=(0,em.usePostHog)();return(0,r.createPortal)((0,t.jsxs)("div",{className:"fixed top-4 right-4 z-[9999] w-full max-w-sm",style:{animation:"slideInFromRight 0.25s ease-out"},children:[(0,t.jsx)("style",{children:`
2
+ @keyframes slideInFromRight {
3
+ from { transform: translateX(calc(100% + 1rem)); opacity: 0; }
4
+ to { transform: translateX(0); opacity: 1; }
5
+ }
6
+ `}),(0,t.jsxs)("div",{className:"rounded-lg border border-red-500/40 bg-red-950/95 shadow-2xl shadow-red-900/40 overflow-hidden backdrop-blur-sm",children:[(0,t.jsx)("div",{className:"h-0.5 w-full bg-gradient-to-r from-red-600 via-red-400 to-red-600"}),(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"shrink-0 mt-0.5 flex h-5 w-5 items-center justify-center rounded-full bg-red-500 ring-2 ring-red-500/30",children:(0,t.jsx)(w.X,{className:"h-3 w-3 text-white",strokeWidth:3})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-[0.65rem] font-bold uppercase tracking-widest text-red-400 mb-0.5",children:"Error"}),(0,t.jsx)("p",{className:"text-sm text-red-100 leading-snug",children:e})]}),(0,t.jsx)("button",{onClick:s,className:"shrink-0 -mt-0.5 -mr-0.5 rounded p-0.5 text-red-400/60 transition-colors hover:bg-red-500/20 hover:text-red-200","aria-label":"Dismiss",children:(0,t.jsx)(w.X,{className:"h-4 w-4"})})]}),(0,t.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,t.jsx)(ef.Button,{size:"sm",onClick:()=>{l("hooks_install_from_error_clicked",{error_message:e.slice(0,200)}),s(),n()},disabled:a,className:"h-7 flex-1 border-0 bg-red-500 px-3 text-xs font-semibold text-white hover:bg-red-400 disabled:opacity-50",children:"Install hooks"}),(0,t.jsx)(ef.Button,{variant:"ghost",size:"sm",onClick:s,className:"h-7 px-3 text-xs text-red-400 hover:bg-red-500/10 hover:text-red-200",children:"Dismiss"})]})]})]})]}),document.body)}function eI({onHooksInstallChange:e}){let[r,n]=(0,s.useState)(null),[a,l]=(0,s.useTransition)(),[o,i]=(0,s.useState)(null),[d,m]=(0,s.useState)(null),[u,p]=(0,s.useState)(null),[x,f]=(0,s.useState)(()=>new Set),g=(0,s.useRef)(!1),{capture:v}=(0,em.usePostHog)(),j=(0,s.useCallback)((e,t)=>{v("action_error_displayed",{error_type:e,error_message:t.slice(0,200)}),i(t)},[v]),y=(0,s.useCallback)(async()=>{try{let t=await ee();n(t),e?.(t.clis.some(e=>e.installed))}catch{}},[e]);(0,s.useEffect)(()=>{y()},[y]),(0,s.useEffect)(()=>{r&&(g.current?f(new Set(r.clis.filter(e=>e.installed).map(e=>e.id))):(g.current=!0,f(new Set(r.clis.filter(e=>e.installed||e.detected).map(e=>e.id)))))},[r?.clis]);let N=(0,s.useMemo)(()=>new Set((r?.clis??[]).filter(e=>e.installed).map(e=>e.id)),[r?.clis]),k=(0,s.useMemo)(()=>{let e=[],t=[];for(let s of r?.clis??[]){let r=x.has(s.id);r&&!N.has(s.id)&&e.push(s.id),!r&&N.has(s.id)&&t.push(s.id)}return{toInstall:e,toRemove:t}},[r?.clis,x,N]),w=k.toInstall.length>0||k.toRemove.length>0,S=(e,t)=>{r&&(n(s=>s?{...s,customPolicies:s.customPolicies?.map(s=>s.id===e?{...s,enabled:!t}:s),conventionPolicies:s.conventionPolicies.map(s=>({...s,policies:s.policies.map(s=>s.id===e?{...s,enabled:!t}:s)}))}:s),l(async()=>{try{await et(e,!t)}catch{j("custom_policy_toggle","Failed to save custom policy change."),y()}}))},P=()=>{let{toInstall:e,toRemove:t}=k;(0!==e.length||0!==t.length)&&(v("cli_install_remove_submitted",{to_install:e,to_remove:t,count_install:e.length,count_remove:t.length}),l(async()=>{try{i(null),e.length>0&&await eo("user",e),t.length>0&&await ei("user",t)}catch(e){j("cli_apply",e instanceof Error?e.message:"Failed to apply changes.")}finally{await y()}}))};if(!r)return(0,t.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,t.jsxs)("span",{className:"text-sm text-muted-foreground",children:["Loading","…"]})});let C=r.clis.some(e=>e.installed),_=N.size,$=x.size,T=Array.from(new Set(r.policies.map(e=>e.category)));return(0,t.jsxs)(t.Fragment,{children:[u&&(0,t.jsx)(eM,{policy:u,onClose:()=>{v("policy_config_modal_closed",{policy_name:u.name,action:"cancel"}),p(null)},onSave:e=>{var t,s;if(!u)return;let r=u.packId?(t=u.packId,s=u.name,`pack/${t}/${s}`):u.name;p(null),l(async()=>{try{i(null),await ec(r,e),await y()}catch(e){j("param_update",e instanceof Error?e.message:"Failed to save configuration.")}})}}),(0,t.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4 px-5 py-3.5 border-b border-border/60 bg-muted/10",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-wrap",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:`h-2 w-2 rounded-full transition-shadow ${C?"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.6)]":"bg-muted-foreground/40"}`,"aria-hidden":!0}),(0,t.jsx)("span",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-foreground/90",children:"Integrations"})]}),(0,t.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,t.jsxs)("div",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-muted-foreground",children:[(0,t.jsx)("span",{className:"text-foreground tabular-nums",children:_.toString().padStart(2,"0")}),(0,t.jsxs)("span",{className:"opacity-50",children:[" / 0",r.clis.length," active"]})]}),w&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[0.65rem] uppercase tracking-[0.2em] font-mono text-pink-400",children:[(0,t.jsx)("span",{className:"h-1 w-1 rounded-full bg-pink-400 animate-pulse"}),k.toInstall.length+k.toRemove.length," pending"]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,t.jsx)(ef.Button,{variant:"outline",size:"sm",onClick:()=>{let e=Array.from(N).filter(e=>x.has(e));0!==e.length&&(v("cli_reinstall_submitted",{cli_ids:e,count:e.length}),l(async()=>{try{i(null),await eo("user",e)}catch(e){j("cli_reinstall",e instanceof Error?e.message:"Failed to reinstall.")}finally{await y()}}))},disabled:a||0===$,className:"text-xs h-7 px-3 font-mono",children:"Reinstall"}),(0,t.jsx)(ef.Button,{variant:"default",size:"sm",onClick:P,disabled:a||!w,className:"text-xs h-7 px-3 font-mono",children:"Apply changes"})]})]}),(0,t.jsx)("div",{className:"divide-y divide-border/30 border-b border-border/60",children:r.clis.map((e,s)=>{let n=x.has(e.id),l=N.has(e.id),o=n!==l,i=(0,ex.getCliBadgeClasses)(e.id),c=i.split(" ").find(e=>e.startsWith("text-"))??"text-foreground";return(0,t.jsxs)("label",{className:`group relative flex items-center gap-3 pl-6 pr-5 py-3 cursor-pointer transition-colors hover:bg-muted/15 ${o?"bg-pink-500/[0.04]":""}`,children:[(0,t.jsx)("div",{className:`absolute left-0 top-0 bottom-0 w-[3px] ${c} bg-current transition-opacity ${n?"opacity-100":"opacity-25 group-hover:opacity-60"}`,"aria-hidden":!0}),(0,t.jsx)("div",{className:"font-mono text-[0.65rem] text-muted-foreground/40 tabular-nums w-6 select-none",children:(s+1).toString().padStart(2,"0")}),(0,t.jsxs)("div",{className:"relative shrink-0",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:()=>{var t;return t=e.id,void f(e=>{let s=new Set(e),n=!s.has(t);n?s.add(t):s.delete(t);let a=r?.clis.find(e=>e.id===t);return v("cli_selection_toggled",{cli_id:t,checked:n,current_state:a?.installed?"installed":a?.detected?"detected":"inactive"}),s})},disabled:a,className:"sr-only peer","aria-label":`Toggle ${e.label}`}),(0,t.jsx)("div",{className:`h-[18px] w-[18px] rounded-sm border transition-all peer-focus-visible:ring-2 peer-focus-visible:ring-primary/40 ${n?"bg-primary border-primary":"bg-background/50 border-border group-hover:border-foreground/40"}`,children:n&&(0,t.jsx)("svg",{viewBox:"0 0 18 18",className:"h-full w-full text-primary-foreground",fill:"none","aria-hidden":!0,children:(0,t.jsx)("path",{d:"M4 9.5L7.5 12.5L14 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),(0,t.jsx)("div",{className:"min-w-[150px] shrink-0",children:(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[l?(0,t.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border ${i}`,children:[(0,t.jsx)("span",{className:"h-1 w-1 rounded-full bg-current shadow-[0_0_4px_currentColor]"}),"Active"]}):e.detected?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-border/60 text-muted-foreground/80 bg-muted/20",children:[(0,t.jsx)("span",{className:"h-1 w-1 rounded-full bg-current opacity-60"}),"Detected"]}):(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-border/30 text-muted-foreground/40",children:"Inactive"}),o&&(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-pink-500/40 text-pink-400 bg-pink-500/10",children:n?"+ install":"− remove"})]}),(0,t.jsx)("div",{className:"ml-auto hidden lg:block text-[0.7rem] font-mono text-muted-foreground/50 truncate max-w-[420px] group-hover:text-muted-foreground/80 transition-colors",title:e.settingsPath,children:e.settingsPath})]},e.id)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border/40 bg-muted/5",children:[(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:r.policies.filter(e=>e.enabled).length+(r.customPolicies?.filter(e=>e.enabled).length??0)+(r.conventionPolicies?.reduce((e,t)=>e+t.policies.filter(e=>e.enabled).length,0)??0)})," / ",r.policies.length+(r.customPolicies?.length??0)+(r.conventionPolicies?.reduce((e,t)=>e+t.policies.length,0)??0)," ","policies enabled"]}),C&&(0,t.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground/60",children:["· shared across ",_," active CLI",1===_?"":"s"]})]}),o&&(0,t.jsx)("div",{className:"px-4 py-2 bg-red-500/10 border-b border-red-500/20 text-xs text-red-400",children:o}),d&&(0,t.jsx)(eU,{message:d,onDismiss:()=>m(null),onInstall:P,isPending:a}),T.map(e=>{let s=r.policies.filter(t=>t.category===e),o=s.filter(e=>e.enabled).length;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[o," / ",s.length," enabled"]})]}),s.map(e=>(0,t.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,t.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,t.jsx)(eT,{enabled:e.enabled,onChange:()=>{var t;let s;return t=e.enabled,s=e.name,void(!r||(!r.clis.some(e=>e.installed)?m("Policies are not installed. Install policies to continue."):(m(null),n(r=>r?{...r,policies:r.policies.map(r=>r.name===s&&r.packId===e.packId?{...r,enabled:!t}:r),packs:r.packs.map(r=>r.id===e.packId?{...r,policies:r.policies.map(e=>e.name===s?{...e,enabled:!t}:e)}:r)}:r),l(async()=>{try{let r=await el(e.packId,s,!t);r.ok||(j("policy_toggle",r.error??"Failed to save policy change."),y())}catch{j("policy_toggle","Failed to save policy change."),y()}}))))},disabled:a})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:[(0,t.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:e.name}),e.beta&&(0,t.jsx)("span",{className:"shrink-0 text-[0.6rem] px-1 py-0.5 rounded border bg-violet-500/10 text-violet-400 border-violet-500/20",children:"beta"})]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:e.description}),e.eventScope&&(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:e.eventScope}),e.params&&Object.keys(e.params).length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1.5",children:Object.entries(e.params).map(([s,r])=>{let n=e.currentParams?.[s]??r.default,a=JSON.stringify(n)!==JSON.stringify(r.default);return(0,t.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[0.6rem] px-1.5 py-0.5 rounded border ${a?"bg-primary/10 text-primary/70 border-primary/20":"bg-muted/40 text-muted-foreground/55 border-border/40"}`,children:[(0,t.jsxs)("span",{className:"opacity-70",children:[s,":"]}),(0,t.jsx)("span",{children:function(e,t){if("string[]"===e||"pattern[]"===e){let s=Array.isArray(t)?t:[];return 0===s.length?"none":"pattern[]"===e?`${s.length} pattern${1!==s.length?"s":""}`:1===s.length?String(s[0]).slice(0,24):`${s.length} values`}return"boolean"===e?t?"on":"off":null==t||""===t?"—":String(t).slice(0,32)}(r.type,n)})]},s)})})]}),e.params&&Object.keys(e.params).length>0&&(0,t.jsx)("button",{className:"shrink-0 mt-0.5 text-muted-foreground hover:text-primary transition-colors",onClick:()=>{let t=Object.entries(e.params??{}).filter(([t,s])=>JSON.stringify(e.currentParams?.[t]??s.default)!==JSON.stringify(s.default)).length;v("policy_config_modal_opened",{policy_name:e.name,param_count:Object.keys(e.params??{}).length,has_customized_params:t>0,customized_count:t}),p(e)},title:"Edit parameters",children:(0,t.jsx)(h.Settings,{className:"h-3.5 w-3.5"})})]},`${e.packId}/${e.name}`))]},e)}),(r.customPoliciesPaths?.length||r.customPoliciesPath)&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:"Custom Policies"}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[r.customPolicies?.length??0," detected"]})]}),(r.customPoliciesPaths??[r.customPoliciesPath]).map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)(c,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e})]},e)),(0,t.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,t.jsx)(b.Shield,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,t.jsx)("p",{className:"text-[0.7rem] text-muted-foreground/70 leading-relaxed",children:"Re-run the install command to add, remove, or reorder files."})]}),r.customPolicies?.map(e=>(0,t.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,t.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,t.jsx)(eT,{enabled:e.enabled,onChange:()=>S(e.id,e.enabled),disabled:a})}),(0,t.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,t.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:e.name})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[e.description&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:e.description}),e.eventScope&&(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:e.eventScope})]})]},e.id))]}),r.conventionPolicies?.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsxs)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:["Convention Policies — ","project"===e.scope?"Project":"User"]}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[e.policies.length," hook",1===e.policies.length?"":"s"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)(c,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e.path})]}),0===e.policies.length?(0,t.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,t.jsx)(b.Shield,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,t.jsxs)("p",{className:"text-[0.7rem] text-muted-foreground/70 leading-relaxed",children:["No policies could be read from this file. It is still loaded at runtime — run ",(0,t.jsx)("span",{className:"font-mono",children:"failproofai policies"})," to see what it registers."]})]}):e.policies.map(s=>(0,t.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,t.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,t.jsx)(eT,{enabled:s.enabled,onChange:()=>S(s.id,s.enabled),disabled:a})}),(0,t.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,t.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:s.name})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[s.description&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:s.description}),s.eventScope&&(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:s.eventScope})]})]},`${e.path}:${s.name}`))]},e.path)),(0,t.jsx)(eR,{packs:r.packs??[],disabled:a,onChanged:y,onError:e=>j("pack_action",e)})]})]})}function eR({packs:e,disabled:r,onChanged:n,onError:a}){let[l,o]=(0,s.useState)(""),[i,c]=(0,s.useState)(null),[d,m]=(0,s.useState)(null),[p,h]=(0,s.useState)(null),{capture:b}=(0,em.usePostHog)(),f=async()=>{if(l.trim()){c("preview"),h(null);try{let e=await en(l);if(!e.ok)return void a(e.error??"Could not read that pack.");h(e)}finally{c(null)}}},g=async(e,t)=>{c(e),m(null);try{let e=await t();if(!e.ok)return void a(e.error??"Could not install that pack.");m(e.version?`${e.id}@${e.version}`:e.id??null),o(""),n()}catch(e){a(e instanceof Error?e.message:"Could not install that pack.")}finally{c(null)}};return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:"Policy Packs"}),(0,t.jsx)("span",{className:"text-[0.7rem] text-muted-foreground",children:0===e.length?"none installed":`${e.length} installed`})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)("input",{value:l,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&l.trim()&&!i&&(b("pack_install_submitted",{via:"input"}),g("input",()=>er(l)))},placeholder:"core · acme/ops · acme/ops@v1.2.0 · a release URL",spellCheck:!1,disabled:r||null!==i,className:"flex-1 min-w-[16rem] rounded-md border border-border/60 bg-background px-2.5 py-1.5 text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50","aria-label":"Pack source"}),(0,t.jsx)(ef.Button,{size:"sm",variant:"outline",disabled:r||null!==i||0===l.trim().length,onClick:()=>{b("pack_preview_submitted",{}),f()},children:"preview"===i?"Reading…":"Preview"}),(0,t.jsxs)(ef.Button,{size:"sm",variant:"default",disabled:r||null!==i||0===l.trim().length,onClick:()=>{b("pack_install_submitted",{via:"button"}),g("input",()=>er(l))},children:[(0,t.jsx)(x,{className:"h-3.5 w-3.5"}),"input"===i?"Installing…":"Install"]})]}),p?.ok&&(0,t.jsxs)("div",{className:"border-b border-border/20 bg-muted/5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,t.jsx)(u,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsxs)("span",{className:"text-xs font-mono text-foreground",children:[p.id,"@",p.version]}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[p.policies?.length??0," policies ·"," ",p.policies?.filter(e=>e.defaultEnabled).length??0," on by default",p.semantic&&p.semantic.length>0?` \xb7 ${p.semantic.length} Jev ${1===p.semantic.length?"check":"checks"}`:""]}),"observe"===p.effect&&(0,t.jsx)("span",{className:"text-[0.65rem] uppercase tracking-wider text-amber-500",children:"observes only"}),(0,t.jsx)("button",{onClick:()=>h(null),className:"ml-auto text-muted-foreground/60 hover:text-foreground","aria-label":"Close preview",children:(0,t.jsx)(w.X,{className:"h-3.5 w-3.5"})})]}),(0,t.jsx)("div",{className:"max-h-64 overflow-y-auto",children:p.policies?.map(e=>(0,t.jsxs)("div",{className:"flex items-start gap-3 px-4 py-2 border-t border-border/10",children:[(0,t.jsx)("span",{className:`text-[0.65rem] uppercase tracking-wider w-14 shrink-0 mt-0.5 ${e.defaultEnabled?"text-emerald-500":"text-muted-foreground/50"}`,children:e.defaultEnabled?"default":"opt-in"}),(0,t.jsx)("span",{className:"text-xs font-mono text-foreground w-56 shrink-0 truncate",children:e.name}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground leading-relaxed min-w-0",children:[e.description,(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5",children:e.category})]})]},e.name))}),(0,t.jsx)("div",{className:"px-4 py-2.5 border-t border-border/20",children:(0,t.jsxs)(ef.Button,{size:"sm",variant:"default",disabled:r||null!==i,onClick:()=>{b("pack_install_submitted",{via:"preview"}),g("input",()=>er(l)).then(()=>h(null))},children:[(0,t.jsx)(x,{className:"h-3.5 w-3.5"}),"Install its defaults"]})})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,t.jsx)("span",{className:"text-[0.7rem] text-muted-foreground/70 mr-1",children:"Failproof AI policies:"}),(0,t.jsx)(ef.Button,{size:"sm",variant:"outline",disabled:r||null!==i,onClick:()=>{b("pack_install_submitted",{via:"ours"}),g("ours",()=>er("FailproofAI/policies"))},children:"ours"===i?"Installing…":"Install from GitHub"}),(0,t.jsx)(ef.Button,{size:"sm",variant:"outline",disabled:r||null!==i,onClick:()=>{b("pack_install_submitted",{via:"bundled"}),g("bundled",()=>es())},children:"bundled"===i?"Installing…":"Install offline copy"}),d&&(0,t.jsxs)("span",{className:"text-[0.7rem] text-emerald-500 font-mono",children:["installed ",d]})]}),e.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)(u,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsxs)("span",{className:"text-xs font-mono text-foreground truncate",children:[e.id,e.version?`@${e.version}`:""]}),"observe"===e.effect&&(0,t.jsx)("span",{className:"text-[0.65rem] uppercase tracking-wider text-amber-500",children:"observing"}),(0,t.jsx)("span",{className:"text-[0.65rem] text-muted-foreground/50 font-mono truncate hidden lg:inline",children:e.source}),(0,t.jsx)("button",{onClick:()=>void g(e.id,()=>ea(e.id)),disabled:r||null!==i,className:"ml-auto text-muted-foreground/60 hover:text-foreground disabled:opacity-40","aria-label":`Remove ${e.id}`,children:(0,t.jsx)(y,{className:"h-3.5 w-3.5"})})]}),e.error?(0,t.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-amber-500/5",children:[(0,t.jsx)(k,{className:"h-3.5 w-3.5 text-amber-500 shrink-0 mt-0.5"}),(0,t.jsxs)("p",{className:"text-[0.7rem] text-muted-foreground leading-relaxed",children:["This pack will not load: ",e.error]})]}):(0,t.jsx)("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-border/20",children:(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[e.policies.filter(e=>e.enabled).length," of ",e.policies.length," on — listed by category above"]})})]},`${e.id}@${e.version}`))]})}function eA({activeTab:e,onChange:s}){return(0,t.jsx)("div",{className:"tabs",style:{padding:0,marginBottom:24},children:[{id:"activity",label:"Activity"},{id:"policies",label:"Configure"}].map(r=>(0,t.jsx)("button",{type:"button",onClick:()=>s(r.id),className:`tab${e===r.id?" is-active":""}`,children:r.label.toLowerCase()},r.id))})}e.s(["default",0,function({initialTab:e="activity"}){let r=(0,eu.useUrlParams)(),{capture:n}=(0,em.usePostHog)(),[a,l]=(0,s.useState)(e),[o,i]=(0,s.useState)(void 0),[c,d]=(0,s.useState)(null),[m,u]=(0,s.useState)([]);(0,s.useEffect)(()=>{ee().then(e=>{i(e.clis.some(e=>e.installed)),d({enabled:e.enabledPolicies.length,total:e.policies.length+(e.customPolicies?.length??0)+(e.conventionPolicies?.reduce((e,t)=>e+t.policies.length,0)??0)}),u(e.clis.filter(e=>e.installed).map(e=>e.label))}).catch(()=>i(void 0))},[]);let p=0===m.length?"Policy evaluations":m.length<=3?`Policy evaluations across ${m.join(", ")}`:`Policy evaluations across ${m.length} agents`,x=e=>{e!==a&&n("policies_tab_switched",{tab:e,from_tab:a}),l(e),r.setAll({tab:"activity"===e?void 0:e})};return(0,t.jsx)("main",{className:"report",children:(0,t.jsxs)("section",{className:"section","data-screen-label":"policies",children:[(0,t.jsx)("h2",{style:{fontFamily:"var(--font-mono)",fontSize:24,fontWeight:600,letterSpacing:"-0.01em",color:"var(--ink)",margin:"0 0 16px"},children:"activity"===a?"Policies":"Configure Policies"}),"activity"===a?(0,t.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:32,flexWrap:"wrap",margin:"0 0 24px"},children:[(0,t.jsxs)("div",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--ink-2)",lineHeight:1.7,flex:"1 1 480px",minWidth:0},children:[p,c&&(0,t.jsxs)("span",{style:{color:"var(--dim)"},children:[" · ","enabled policies"," ",(0,t.jsxs)("span",{style:{color:"var(--ink)",fontVariantNumeric:"tabular-nums"},children:[c.enabled,"/",c.total]})]})]}),(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:6,flex:"0 0 auto"},children:[(0,t.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:"0.22em",textTransform:"uppercase",color:"var(--dim)"},children:"want to change which policies fire?"}),(0,t.jsx)("button",{type:"button",className:"btn btn-primary",onClick:()=>x("policies"),children:"[ configure policies → ]"})]})]}):(0,t.jsx)("p",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--ink-2)",lineHeight:1.7,maxWidth:720,margin:"0 0 24px"},children:"switch policies on or off across your installed harnesses."}),(0,t.jsx)(eA,{activeTab:a,onChange:x}),"activity"===a?(0,t.jsx)(e$,{hooksInstalled:o,onSwitchTab:x}):(0,t.jsx)(eI,{onHooksInstallChange:i})]})})}],64245)}]);